I'm trying to prove that if $g \circ f$ is injective, then f must also be injective. I have written a proof, which I believe has a bad step in it, and I would like feedback.
Assume $g \circ f$ is injective. Now suppose $g\circ f(x) = g\circ f(y)$ for some $x, y$ in the domain of $f$ (call it $X$). Because the composition is injective, $x = y$.
Now suppose $f$ were not injective. Then for some $x', y' \in X, ~f(x') = f(y')$ but $x' \neq y'$. Thus $g \circ f(x') = g \circ f(y')$ but $y' \ne x'$ This implies $g \circ f$ is not injective, which is a contradiction. Therefore $f$ must be injective. $\Box $
This seems spurious to me, because it implies that $g$ itself needs to be injective (I feel but cannot state rigorously that this is implicit in the step that derives the contradiction) and I know that $g$ need not be injective itself (though again, I know this heuristically and cannot think of an example).
Here is another question that is identical (Composition of functions injective implies one of them is injective?) but it seems like the same assumption is being made; which is that the fact that $~f(x') = f(y') \Rightarrow g \circ f(x') = g \circ f(y')$ and that this contradicts the injectivity of $g$ as $x' \ne y'$
Can anyone help clarify my thinking here?