Prove that any map $f : X \to Y$ can be represented as composition of 1) inj and surj. 2) surj. and inj. I was given the following task

Prove that any map $f : X \to Y$ can be represented as

*

*composition $f = g \circ h$, where $g$ is a surjection and $h$ is injection

*composition $f = z \circ c$, where $z$ is a injection and $c$ is surjection


I have the proof for the first one


*

*Let $h = Id \rvert x$. It is obvious that $h$ must be injective, otherwise $h \neq Id \rvert x$.
Let $g$ map set $X$ to the exact image of $f$ and $g(x) = f(x)$. Then $g $ is surjective.
Therefore, $f = g(h(x)) = g(x) = y$.


and the second one

2.Let $c : X \to Im \rvert f$ map set X to the exact image of f and $f(x) = c(x)$. Then it is surjective.
Let $z = Id \rvert y$, such that $z(y) = y$. It is obvious, that $z$ is injective.
Therefore $f = z(c(x)) = z(y) = y$

Could you please verify my proof ? Please, tell me where I need to improve it.
 A: Your ideas for 2 don't work:
For 1 you can also use $Z= X{/}R_f$ where $R_f$ is the equivalence relation on $X$ defined by $(x,x') \in R_f \iff f(x)=f(x')$. Show that $q:x \to [x]_{R_f}$ is onto from $X$ to $Z$ and $\overline{f}([x]_{R_f}) = f(x)$ is injective (and well-defined) from $Z$ to $Y$.
And $f = \overline{f} \circ q$ is of the form injective $\circ$ surjective
Your idea for 1 does also work: let $Z = f[X] \subseteq Y$. Define $i_Z: Z \to Y$ to be the inclusion (clearly injective). Also $\tilde{f}: X \to Z$ defined by $\tilde{f}(x)=f(x)$ (surjective by definition) and $f = i_Z \circ \tilde{f}$ is of the form injective $\circ$ surjective too.
For the other order we could use $Z=X \times Y$ and $i_f: X \to Z$ defined by $i_f(x)=(x,f(x))$ is injective (the first coordinate ensures that) and $\pi_2: X \times Y \to Y$ defined by $\pi_2(x,y)=y$ is surjective. And so $f = \pi_2 \circ i_f$ is of the form surjective $\circ$ injective.
You can probably come up with more ideas for the second...
