Restriction of Composition is Composition of Restriction

Theorem
Let $X, Y, Z$ be sets.

Let $f: X \to Y$ and $g: Y \to Z$ be mappings.

Let $S \subseteq X$.

Then $\left({g \circ f}\right) \restriction S = g \circ \left({f \restriction S}\right)$

Proof
By definitions of composition of mappings and restriction of mapping:
 * $\left({g \circ f}\right) \restriction S: S \to Z$ and $g \circ \left({f \restriction S}\right):S \to Z$

Let $s \in S$.

By definition of restriction of mapping:
 * $\left({\left({g \circ f}\right) \restriction S}\right)\left({s}\right) = \left({g \circ f}\right)\left({s}\right)$

Thus