Understanding proof that $f$ is a monomorphism if and only if injective

functionssolution-verification

I'm trying to understand the proof in Aluffi's book that $f: A \to B$ is injective if and only if it is a monomorphism. I've added some detail and reordered some things in his proof. How does this look?

Suppose $f: A \to B$ is injective. If $A = \emptyset$, then the only functions $Z \to A$ is the empty function. Hence, $\alpha' = \alpha''$ vacuously. Suppose $A \neq \emptyset$. Then $f$ admits a left inverse $g: B \to A$, so $g \circ f = \mathrm{id}_A$. Given $\alpha', \alpha'': Z \to A$ with $f \circ \alpha' = f \circ \alpha''$, we have
\begin{align*}
\alpha' = \alpha \circ \mathrm{id}_A = \alpha' \circ \left(f \circ g\right) = \left(\alpha' \circ f\right) \circ g = \left(\alpha'' \circ f\right) \circ g = \alpha'' \circ \left(f \circ g\right) = \alpha'' \circ \mathrm{id}_A = \alpha'',
\end{align*}

so $f$ is a monomorphism, as desired. Conversely, suppose that $f$ is a monomorphism. If $A = \emptyset$, then $f: \emptyset \to B$ is vacuously injective, so suppose $A \neq \emptyset$. Take $Z = \{p\}$ for some element $p \in Z$, and suppose $f(a') = f(a'')$ for $a', a'' \in A$. Now, define $\alpha', \alpha'': Z \to A$ by $\alpha'(p) = a'$ and $\alpha''(p) = a''$. Then $f(\alpha'(p)) = f(\alpha''(p))$, i.e., $(f \circ \alpha')(p) = (f \circ \alpha'')(p)$. As $p$ is the only element of the domain $Z$, we have $f \circ \alpha' = f \circ \alpha''$. By the assumption that $f$ is a monomorphism, we deduce $\alpha' = \alpha''$, and hence $\alpha'(p) = \alpha''(p)$, i.e., $a' = a''$, so $f$ is injective, as desired.

Best Answer

Your solution is fine, but it does a lot of case analysis on whether sets are empty. This case analysis is unnecessary.

Fix a one-element set $1 = \{*\}$.

$f$ is a monomorphism implies $f$ is injective.

Proof: Suppose $f : A \to B$ is a monomorphism. Consider $a, b \in A$. Suppose $f(a) = f(b)$. Define functions $g, h : 1 \to A$ by $g(*) = a$, $h(*) = b$. Then $f(g(*)) = f(h(*))$, so $f \circ g = f \circ h$ by function extensionality. Since $f$ is mono, we have $g = h$. Therefore, $a = g(*) = h(*) = b$.

$f$ is injective implies $f$ is a monomorphism.

Proof: Suppose $f : A \to B$ is injective. Consider functions $g, h : C \to A$ such that $f \circ g = f \circ h$. We will use function extensionality to show that $g = h$. Consider an arbitrary $x \in C$. Then we have $f(g(x)) = f(h(x))$. Then since $f$ is injective, $g(x) = h(x)$. Therefore, $g = h$ by function extensionality.

This way, we don't require the law of excluded middle in our proof. This is very useful in situations where the law of excluded middle doesn't hold (for example, in the internal logic of toposes).