I'm aware that there's a simple proof by contradiction for this, mainly:
Assume $x_1 \neq x_2$. If $f(x_1)=f(x_2)$, then $g(f(x_1))=g(f(x_2))$ which, since $g \circ f$ is injective, implies $x_1=x_2$. By contradiction, $f$ is injective.
I wanted to see if the method of direct proof I used is valid. Could someone just skim over it and alert me if there's any gaps? Here's the proof I came up with:
$$\exists ! x \in D(g \circ f) = A (\forall w \in R(g \circ f) \subseteq C)$$ $$\implies \exists ! y \in R(f) \subseteq B (\forall w \in R(g \circ f) \subseteq C)$$ $$\implies \exists ! x \in D(g \circ f)=D(f)=A (\forall y \in R(f) \subseteq B)$$ $$\implies \exists ! x \in A (\forall y \in R(f) \subseteq B)$$
Hence, $f$ is injective.
Rewritten in words:
Because $f$ is injective, there's a unique $x$ for each $g(f(x))\in C$. Since $g \circ f$ is a function from $R(f)$ onto $C$, this implies there's a unique $y\in R(f)$ for each $g(f(x))\in C$. Since there exists a unique $x$ and unique $y$ for each $g(f(x))\in C$, then there must exist a unique $x$ for each $y \in R(f)$, hence making $f$ injective.
To me, I believe the second implication I made, assuming there exits a unique $x$ for every $y$ just because there existed a unique $y$ for each $w$, seems like a large step -- so I'm really doubting if that's a valid move.