So I wanted to show that in the category $\mathbf{SET}$, all idempotent splits. Fix an idempotent $f$, I wish to find 2 arrows $g,h$ such that $f=hg$ and $gh = 1$.
I'm having some trouble "decomposing" such an $f$. However what I did notice is that if I can find an injective $h$ and a surjective $g$, then $gh = 1$ is fulfilled automatically since
$f^2 = f \rightarrow hghg = hg \\ \rightarrow ghg = g\ \text{ (Since h is injective hence monic in Set)} \\ \rightarrow gh = 1\ (\ \text{Since g is surjective, hence an epi in Set})$
So how can I decompose an idempotent $f$ into an injective and surjective component ?
If I'm on the wrong track, any hints/insights is deeply appreciated.
Cheers and thanks
In the category of sets every morphism $f$ factors as $f=gh$, where $h$ is epic (surjective) and $g$ is monic (injective).
What are $g$ and $h$? Consider a map $f\colon X\to Y$ (this can be done generally) and the equivalence relation $\sim_f$ on $X$ defined by $a\sim_f b$ if and only if $f(a)=f(b)$.
Let $X/{\sim_f}$ be the quotient set and $h\colon X\to X/{\sim_f}$ be the obvious map that sends $x\in X$ to the equivalence class it belongs to. Now prove that there exists a unique map $g\colon X/{\sim_f}\to Y$ such that $gh(x)=f(x)$, for every $x\in X$.
In the case $f\colon X\to X$ is idempotent, from $f^2=f$ we get $$ ghgh=gh $$ Since $g$ is monic, it is left cancellable; since $h$ is epic, it is right cancellable. Therefore $hg=1$.