How does it follow that $P = Q$ in this universal property of coproducts of abelian groups?
I'm reading Martin Brandenburg's explanation of why:
Given that $P$ is a coproduct of the abelian groups $A_i$, how can we deduce - from the universal property, not from the construction of $P$ - that every element of $P$ is a finite sum of elements coming from the $A_i$?
He says: Now, for the proof, let $Q$ be the subgroup of $P$ generated by the images of the $A_i$. Then the universal property of $P$ induces a canonical homomorphism $f: P \to Q$, and one checks that it is inverse to the inclusion $g: Q \hookrightarrow P$. It follows that $P = Q$.
I simply don't understand how it follows that $P = Q$ or rather why $g \circ f = \mathrm{id}$ on $P$? Can someone please explain?
I get that $f(P) = Q$ where $f$ is surjective. I also get that $f\circ g = \mathrm{id}$ on the domain $Q$ but why should $g \circ f = \mathrm{id}$ on $P$?
Let $\iota_j\colon A_j\to P$ be the canonical injections; let $Q=\langle \iota_j(A_j)\mid j\in I\rangle$ be the subgroup the images generate. Let $\iota'_j\colon A_j \to Q$ be the co-restrictions of the $\iota_j$. Let $g\colon Q\hookrightarrow P$ be the subgroup embedding. Note that $\iota_j = g\circ \iota'_j$.
The morphisms $g\circ \iota'_j\colon A_j\to Q\to P$ induce a unique morphism $\phi\colon P\to P$ such that $\phi\circ\iota_j = g\circ\iota'_j$ for all $j$. Now, it is clear that $\mathrm{id}_P$ satisfies this condition as well (that is, $\mathrm{id}_P\circ\iota_j = g\circ \iota'_j$ for all $j$), so the uniqueness clause of the universal property of $P$ tells you that $\phi=\mathrm{id}_P$.
On the other hand, the morphisms $\iota'_j\colon A_j\to Q$ induce a unique morphism $f\colon P\to Q$ such that $\iota'_j = f\circ\iota_j$ for each $j$. Then $g\circ\iota'_j = g\circ f\circ\iota_j$ holds for each $j$. But that means that $g\circ f$ has the same property as $\phi$, and therefore that $g\circ f = \phi = \mathrm{id}_P$, as desired.