For nonempty sets $A$ and $B$ and functions $ f: A \to B$ and $g: B \to A$, suppose that $ g \circ f = i_A$. Prove that if $f$ is onto, then $g$ is $1-1$.
Here is what I started, I don't think it's correct.
Suppose $f$ is onto i.e for each element $b \in B$ there is an element of $a\in A$, $f(a)=b$. (definition of onto).
Let $y,\ z$ be any two elements of $B$.Then $y=f(a)$ and $z=f(b)$ for some $a,b \in A$.
If $g(y)=g(z)$, then $g(f(a)) = g(f(b))$,which implies that $a=b$, so $f(a)=f(b)$, so $y=z$.
Thus, whenever $g$ maps $y$ and $z$ to the same element in $A$, $y=z$, so $g$ is one-to-one.
PS: New to proof writing, any constructive criticism is much appreciated.