Injection iff Monomorphism in Category of Sets

Theorem
Let $\mathbf{Set}$ be the category of sets.

Let $f: X \to Y$ be a morphism in $\mathbf{Set}$, i.e. a mapping.

Then $f$ is an injection iff it is a monomorphism.

Necessary Condition
Suppose that $f$ is injective.

Suppose further that we have mappings $g, h: Z \to X$ such that $g \ne h$.

Then necessarily there exists some $z \in Z$ such that $g \left({z}\right) \ne h \left({z}\right)$ by Equality of Mappings.

As $f$ is injective, it follows that:


 * $f \left({g \left({z}\right)}\right) \ne f \left({h \left({z}\right)}\right)$

which, again by Equality of Mappings, means that $g \circ f \ne h \circ f$.

Hence $f$ is monic, by the Rule of Transposition.

Sufficient Condition
Suppose that $f: X \rightarrowtail Y$ is a monomorphism.

By definition of injection, it will suffice to show that:


 * $x \ne x' \implies f \left({x}\right) \ne f \left({x'}\right)$

To this end, consider a singleton $\left\{{a}\right\}$, and define:


 * $\bar x: \left\{{a}\right\} \to X, \bar x \left({a}\right) := x$
 * $\bar x': \left\{{a}\right\} \to X, \bar x' \left({a}\right) := x'$

In particular, $\bar x \ne \bar x'$, and so, $f$ being monic, we deduce:


 * $f \circ \bar x \ne f \circ \bar x'$

It follows that it must be that:

Hence $f$ is injective.