Surjection iff Right Cancellable/Necessary Condition/Proof 1

Theorem
Let $f$ be a surjection.

Then $f$ is right cancellable.

Proof
Let $f: X \to Y$ be surjective.

Let $h_1: Y \to Z, h_2: Y \to Z: h_1 \circ f = h_2 \circ f$.

As $f$ is a surjection, $\operatorname{Im} \left({f}\right) = Y$ by definition.

But in order for $h_1 \circ f$ to be defined, it is necessary that $Y = \operatorname{Dom} \left({h_1}\right)$.

Similarly, for $h_2 \circ f$ to be defined, it is necessary that $Y = \operatorname{Dom} \left({h_2}\right)$.

So it follows that the domains of $h_1$ and $h_2$ are the same.

Also:
 * The codomain of $h_1$ equals the codomain of $h_1 \circ f$
 * The codomain of $h_2$ equals the codomain of $h_2 \circ f$

again by definition of composition of mappings.

Now, we have shown that the domains and codomains of $h_1$ and $h_2$ are the same.

All we need to do now to prove that $h_1 = h_2$, and therefore that $f$ is right cancellable, is to show that:
 * $\forall y \in Y: h_1 \left({y}\right) = h_2 \left({y}\right)$.

So, let $y \in Y$.

As $f$ is surjective, $\exists x \in X: y = f \left({x}\right)$. Thus:

Thus $h_1 \left({y}\right) = h_2 \left({y}\right)$ and thus $f$ is right cancellable.