I'm trying to prove the injectivity of $f: X \to Y$ in $g \circ f = id_X$ (with $g : Y \to X$). This is what I came up with and I'd appreciate someone pointing out any mistakes.
1 $$x \neq x' \implies id_X(x) \neq id_X(x')$$ 2 $$\implies (g \circ f) (x) \neq (g \circ f )(x')$$ 3 $$\implies g(f(x)) \neq g(f(x'))$$ 4 $$\implies f(x) \neq f(x')$$
The surjectivity of $g$ permits the implication in (4), right? Thanks in advance.
A direct proof.
Assume $f(a) = f(b)$.
Thus $a = gf(a) = gf(b) = b$.