If $g\circ f$ is injective and $f$ is surjective then $g$ is injective

Your proof is correct. I myself would prove it exactly the same. But, I think it's useful to know more than one way, so here is an alternative solution. It's not profoundly different, but I think it's still worth mentioning.

I'm assuming that $A$ is nonempty (and, since there is a map from $A$ to $B$, $B$ is also nonempty). When $A$ is empty there's not much to prove.

The solution uses left and right inverses. A function with non-empty domain is injective iff it has a left inverse, and a function is surjective iff it has a right inverse.

So, we know that $g\circ f$ has a left inverse $h:C \to A$ and $f$ has a right inverse $k: B \to A$. We want to show that $g$ has a left inverse. Just observe that $$ (f \circ h) \circ g = (f \circ h) \circ g \circ (f \circ k) = f \circ (h \circ g \circ f) \circ k = f \circ \mathrm{id}_A \circ k = f \circ k = \mathrm{id}_B, $$ so $(f \circ h)$ is a left inverse for $g$. It follows that $g$ is an injection.

PS: this solution is actually worse than your original one, because this one relies on the axiom of choice (it is used when we say that surjectivity is equivalent to having a right inverse). But it is good in the sense that we don't look at particular elements and manipulate maps as "opaque" objects.

Tags:

Functions