Is my proof correct? (function composition, surjectivity) 
Exercise. Given sets $E$, $F$, $G$ and functions $g : E \to F$ surjective, and $f : E \to G$. Prove that there's a function $h : F \to G$ such that $f = h \circ g$ if and only if the equality $g(x) = g(y)$, with $x, y \in E$, implies the equality $f(x) = f(y)$.

My strategy was the following.
Right to left. I assume that $h$ exists. Then if $g(x) = g(y)$, $h(g(x)) = h(g(y))$. Therefore $f(x) = f(y)$ by definition.
Left to right. I assume that the equality $g(x) = g(y)$, with $x,y \in E$, implies the equality $f(x) = f(y)$. Given that $g$ is surjective, $g^{-1}(g(E)) = g^{-1}(F) = E$. Therefore $f(g^{-1}\circ g(x)) = f(x)$ [note: I know that $f$ and $g$'s values at any given point $x\in E$ have the same preimages, but I don't know how to state this more formally.]. I can then define $h: F \to G$ such that $h(x) = f\circ g^{-1}(x)$, and it verifies the stated condition.

As Arturo has written in the comment $g$ will not necessary have an inverse. Here's a minimal example: $$E=\{0,1\}\\F=\{0\}\\G=\{0\}$$
In this case, all three functions, $f,g,h$, will be the constant map to $0$ (with different domain/range).
To me, there are two issues in your proof


*

*You seem to have only used the surjective property of $g$ but you haven't really used your assumption: $$g(x)=g(y)\Rightarrow f(x)=f(y)$$

*You even wrote down that you cannot state something more formally (which really is the critical part of the proof)


The idea of your proof is more or less correct, but you will need to define what you are calling $g^{-1}$ into an actual function. You will need to pick a representative and use the $g(x)=g(y)\Rightarrow f(x)=f(y)$ assumption to show that $h$ has the properties needed.
