Condition for Composite Mapping on Right

Theorem
Let $$A, B, C$$ be sets.

Let $$f: B \to A$$ and $$g: C \to A$$ be mappings.

Let $$\mathcal{R}: C \to B$$ be a relation such that $$g = f \circ \mathcal{R}$$ is the composite of $\mathcal{R}$ and $f$.

Then $$\mathcal{R}$$ may be a mapping iff $$\operatorname {Im} \left({g}\right) \subseteq \operatorname {Im} \left({f}\right)$$

That is:
 * $$\operatorname {Im} \left({g}\right) \subseteq \operatorname {Im} \left({f}\right)$$ iff $$\exists h: C \to B$$ such that $$h$$ is a mapping and $$f \circ h = g$$

Sufficient Condition
Suppose $$\operatorname {Im} \left({g}\right) \subseteq \operatorname {Im} \left({f}\right)$$.

That is:
 * $$\forall x \in C: g \left({x}\right) \in \operatorname {Im} \left({f}\right)$$

and so:
 * $$\forall x \in C: \exists y \in B: g \left({x}\right) = f \left({y}\right)$$

Take any $$x \in C$$.

Consider the set $$Y_x = \left\{{y \in B: g \left({x}\right) = f \left({y}\right)}\right\}$$.

We know from above that $$Y_x \ne \varnothing$$.

So, using the Axiom of Choice, for each $$x$$ we may select some $$y_x \in Y_x$$.

Then we may define the mapping $$h: C \to B$$ such that:
 * $$\forall x \in C: h \left({x}\right) = y_x$$

We then see that:

$$ $$ $$

Thus we have constructed a mapping $$h$$ such that $$f \circ h = g$$, as required.

Necessary Condition
Suppose there exists some mapping $$h: C \to B$$ such that $$f \circ h = g$$.

Let $$y \in \operatorname {Im} \left({g}\right)$$. Then:

Then we have:

$$ $$ $$ $$ $$

Hence by definition of subset, $$\operatorname {Im} \left({g}\right) \subseteq \operatorname {Im} \left({f}\right)$$.

Comment
Hence we have a necessary and sufficient condition for determining whether the composition of mappings actually exists as a mapping.

Note that this is different from being given two mappings and creating their composition.