Let $f: S \rightarrow T$ and $g: T \rightarrow U$. The function $h: S \rightarrow U$ given by $h(s)=g(f(s))$ is the composite function of $g$ and $f$, denoted by $h=g \circ f$. Prove that, if $g \circ f$ is an injection, then $f$ is an injection. Hint: prove by contraposition.
I tried using $g \circ f(x)=g \circ f(y) \implies x = y$, to no avail.
If $f$ is not injective, then there exist $x, y \in S$, with $x \neq y$, such that $f(x) = f(y)$. Hence, $(g \circ f)(x) = g(f(x)) = g(f(y)) = (g \circ f)(y)$, so $g \circ f$ is not injective, contrary to hypothesis.