Prove that if $g \circ f$ is injective, then $f$ must also be injective.
$g(f(x))$ is injective.
Then, $x\neq x’ \implies (g\circ f)(x) \neq (g\circ f)(x’)$.
Suppose for the sake of contradiction: $f(x)=f(x’) \nRightarrow x=x’$
Then this implies that it is logically possible that for some $x$ and $x’$:
$f(x)=f(x’) \implies (g\circ f)(x) \neq (g\circ f)(x’) \implies g(f(x))\neq g(f(x’))$
But if $f(x)=f(x’)$, then $f(x)=f(x’) \implies g(f(x))\neq g(f(x))$ which is a contradiction.
Therefore $f(x)=f(x’) \implies x=x’$, that is, $f$ is also injective.
I’ve numbered the lines to make it easier to reference a mistake if I’ve made one. My concern is (3.). I think it should be correct to say that if (2.) holds, then that suggests that it is logically possible that $x\neq x’$ could hold under $f(x)=f(x’)$.