Surjection iff Right Cancellable

Theorem
A mapping $f$ is a surjection iff $f$ is right cancellable.

Sufficient Condition
Suppose $f: X \to Y$ is surjective.

Suppose $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: again by definition of composition of mappings.
 * 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$

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.

Necessary Condition
Suppose $f$ is a mapping which is not surjective.

Then $\exists y_1 \in Y: \neg \exists x \in X: f \left({x}\right) = y_1$.

Let $Z = \left\{{a, b}\right\}$.

Let $h_1$ and $h_2$ be defined as follows.


 * $h_1 \left({y}\right) = a: y \in Y$

\begin{cases} a & : y \ne y_1 \\ b & : y = y_1 \end{cases}$
 * $h_2 \left({y}\right) =

Thus we have $h_1 \ne h_2$ such that $h_1 \circ f = h_2 \circ f$, and therefore $f$ is not right cancellable.

It follows from the Rule of Transposition that if $f$ is right cancellable, then $f$ must be surjective.

Sufficient Condition
Suppose $f: X \to Y$ is surjective.

Then from Surjection iff Right Inverse:
 * $\exists g: Y \to X: f \circ g = I_Y$

Suppose $h \circ f = k \circ f$ for two mappings $h: Y \to Z$ and $k: Y \to Z$.

Then:

Thus $f$ is right cancellable.

So surjectivity implies right cancellability.

Necessary Condition
Now suppose $f: X \to Y$ is a right cancellable mapping.

If $Y$ contains only one element, then by definition $Y$ is a singleton and it automatically follows from Mapping to Singleton is Surjection that $f$ is a surjection.

So we suppose that $Y$ contains at least two elements.

Call those two elements $a$ and $b$, and we note that $a \ne b$.

We define the two mappings $h, k$ as follows:
 * $h: Y \to Y: \forall x \in Y: h \left({x}\right) = \begin{cases}

x & : x \in \operatorname{Im} \left({f}\right) \\ a & : x \notin \operatorname{Im} \left({f}\right) \end{cases}$


 * $k: Y \to Y: \forall x \in Y: k \left({x}\right) = \begin{cases}

x & : x \in \operatorname{Im} \left({f}\right) \\ b & : x \notin \operatorname{Im} \left({f}\right) \end{cases}$

It is clear that:
 * $\forall y \in X: h \left({f \left({y}\right)}\right) = f \left({y}\right) = k \left({f \left({y}\right)}\right)$

and so $h \circ f = k \circ f$.

But by hypothesis, $f$ is right cancellable.

Thus $h = k$.

Now, suppose $Y \ne \operatorname{Im} \left({f}\right)$, and so $\operatorname{Im} \left({f}\right) \subset Y$.

That is, $\exists x \in Y: x \notin \operatorname{Im} \left({f}\right)$.

It follows that $a = h \left({x}\right) = k \left({x}\right) = b$.

But we posited that $a \ne b$.

From this contradiction we conclude that $Y = \operatorname{Im} \left({f}\right)$

So, by Surjection iff Image equals Codomain, $f$ must be a surjection.

Also see

 * Injection iff Left Cancellable