Is every monomorphism an injection?
We say a morphism is a monomorphism if $fg=fh$ implies $g=h$. So if $f$ is a monomorphism, is it necessarily an injection? i.e. $f(x)=f(y)$ implies $x=y$.
My approach is to consider a specific morphism $g_x$ who map every elements to $x$, thus $f(x)=f(y) \Rightarrow fg_x=fg_y \Rightarrow g_x=g_y \Rightarrow x=y$. But not every category allows this $g_x$. For exemple, the category of linear space.
Although in the category of linear space this question can be solved in another way, I want to know some general approach about the question.
Solution 1:
"Injection" makes sense in a concrete category, namely a category $C$ equipped with a faithful functor $F : C \to \text{Set}$: a morphism $f$ is an injection if $F(f)$ is an injection (equivalently, a monomorphism).
Faithful functors always reflect monomorphisms: if $F(f)$ is a monomorphism, then so is $f$. The proof is straightforward. If $fg = fh$, then $F(fg) = F(fh)$, so $F(f) F(g) = F(f) F(h)$. Now, if $F(f)$ is a monomorphism, then $F(g) = F(h)$. And if $F$ is faithful, then $g = h$. Hence injective maps are always monos.
In the other direction, if $F$ preserves pullbacks, then it also preserves monomorphisms. This is because a map is a monomorphism iff its kernel pair is trivial, and the kernel pair is a pullback. With this hypothesis, mono implies injective. Altogether:
In a concrete category where the forgetful functor $F$ preserves pullbacks, the monomorphisms are precisely the injective maps.
This condition is commonly satisfied in practice; for example, $F$ preserves pullbacks whenever it has a left adjoint (the "free" functor).
Dually, if $F$ is preserves pushouts, the epimorphisms are precisely the surjective maps. Unfortunately it's much less common for forgetful functors to preserve pushouts: for example, the forgetful functor from groups or rings to sets does not preserve pushouts, and in fact it's not true that the epimorphisms of rings are precisely the surjective maps.
Solution 2:
Even if in the category you're working in, the objects are sets, the morphisms are functions, and the identity morphism is the literal identity map, then monomorphisms don't have to be injective.
(Very cheap) counterexample: let $A, B$ be distinct sets, and let $f:A \rightarrow B$ be any function which is not injective. Let $\mathscr C$ be the category whose objects are the sets $A, B$, and for which $$\textrm{Hom}_{\mathscr C}(A,B) = \{f\}$$ $$\textrm{Hom}_{\mathscr C}(A,A) = \{1_A\}$$ $$\textrm{Hom}_{\mathscr C}(B,B) = \{1_B\}$$ $$\textrm{Hom}_{\mathscr C}(B,A) = \emptyset$$ You can see that if $C$ is an object of $\mathscr C$ (necessarily $C = A$ or $B$), and $g, h$ are morphisms from $C$ to $A$ with $f \circ g = f \circ h$, then $g = h$.