Commutativity of morphisms and existence of unique map Let $X,Y,Z$ be sets
Suppose $f:X\rightarrow Z$ and $g: X\rightarrow Y$ are two maps. Suppose $g$ is surjective. Show that there exists a unique map $h: Y\rightarrow Z$ such that $h\circ g= f$
This problem is really a problem in elementary set theory.
Existence:
Since $g$ is surjective, for each $y\in Y$ there exists atleast one $x\in X$ such that $g(x)=y$.
So define $h:Y\rightarrow Z$ by specifying $h(y)=f(x)$.
Now, we need to verify that the map $h$ is well defined. In other words,
If $y_1=y_2$ then $h(y_1)=h(y_2)$.
To this end, suppose $y_1=y_2$ for $y_i\in Y$. By surjectivity of $g$, there exists some $x_1,x_2\in X$ such that $g(x_1)=g(x_2)$. Since $y_1=y_2$, we may assume $x_1=x_2$. Since $f$ is well defined, $f(x_1)=f(x_2)$ and so, $h(y_1)=h(y_2)$. Clearly, $h\circ g=f$.
Uniqueness:
Suppose there exists another map $h':Y\rightarrow Z$ for which $h'\circ g=f$.
I must now show that $h=h'$. For $y\in Y$, there exists some $x\in X$, such that $g(x)=y$. Hence,
$h(y)=f(x)=h'(g(x))=h'(y)$.
Therefore $h=h'$.
Is this correct?
 A: Your “well-definedness” proof for $h$ is incorrect. The problem is that your definition depends on a choice of $x$.
What you really need to show is that $x_1$ and $x_2$ are two elements of $X$ such that $g(x_1)=g(x_2)$, then $f(x_1)=f(x_2)$. You do not get to assume that $x_1=x_2$. Because look at your definition for $h$. It just says “find any $x$ that maps to $y$, and use that $x$.” You don’t put any restrictions on $x$ other than that it has to map to $y$, and so you don’t get to say “we may assume that $x_1=x_2$.” You most definitely do not get to assume that.
Frankly, I don’t think the statement you have written is even true. Say $X=\{1,2\}$, $Y=\{a\}$, and $Z=\{1,2\}$. If $f\colon X\to Z$ is the identity, and $g\colon X\to Y$ is the only map from $X$ to $Y$, then there is no map $h\colon Y\to Z$ such that $h\circ g =f$. For the composition to be surjective you need $h$ to be surjective, and there are no surjections from $Y$ to $Z$.
Run your argument through this example to see why it fails.
