Let $f:A \rightarrow B$ be a map of sets. Prove that $f$ is injective if and only if given any set $C$ and any two set map $g_i:C \rightarrow A, i =1,2$, with compositions $f \circ g_1 = f \circ g_2$, then $g_1 = g_2$.
So I have proved the forward direction, which was quite easy. For the other direction, I am unsure if my approach is correct:
$(\Leftarrow):$ suppose that $f \circ g_1 = f \circ g_2$ implies $g_1 = g_2$ for any $g_1$ and $g_2$. And suppose that $f$ is not injective.
i.e. there exist $g_1(x)$ and $g_2(x)$ such that $f(g_1(x)) = f(g_2(x))$ and $g_1(x) \neq g_2(x)$
since $f(g_1(x)) = f(g_2(x))=f \circ g_1(x) = f \circ g_2(x)$, but our assumption $g_1=g_2$, and thus $g_1(x) = g_2(x)$, which is a contradiction.