The questions reads : Show that an arrow $f$ is regular if it has either a left or right inverse, and prove that every arrow in category $\mathbf{SET}$ ,with domain $\neq 0$, is regular.
My confusion sets in if I assume that I have to make use of the first result, because in context of set theory, left inverse is "equivalent" to injectivity (right "equivalent" to surjectivity). So it boils down to showing that every function in $\mathbf{SET}$ is either injective or surjective, but this is not true as there are lots of function that is neither of them.
So if I was not suppose to make use of the first result, how do I construct an arrow $g$ so that $fgf=f$
Any hints or insight is deeply appreciated.
Cheers and thanks
Let $A$ and $B$ be sets with $x_0\in A$ and let $f:A\to B$ be a function.
If $C$ denotes the image of $f$ then $\{f^{-1}(\{c\})\mid c\in C\}$ forms a partition of $A$.
According to the axiom of choice a set of representatives exists, i.e. a set $\{a_c\mid c\in C\}\subseteq A$ such that $\forall c\in C [a_c\in f^{-1}(\{c\})]$ or equivalently $\forall c\in C[f(a_c)=c]$.
Now let $g:B\to A$ be the function prescribed by $b\mapsto a_b$ if $b\in C$ and $b\mapsto x_0$ otherwise.
Then evidently $f\circ g\circ f=f$.