That looks very clean. Thank you very much. It was the fact that the domain and codomain had to be equal that was causing most of the trouble it seems.
I'm trying to prove that the axiom of choice is equivalent to the following statement:
For any set X and any function f:X\to X, there exists a function g:X\to X such that f\circ g\circ f=f.
I was able to prove that the AoC implies this, but I'm having a harder time going the other...