Def/Composite function

=Associativity=

Composition of functions is associative in the following sense. Suppose that $X,Y,Z,W$ are sets, and $f \colon X \rightarrow Y$, $g \colon Y \rightarrow Z$, and $h \colon Z \rightarrow W$ are functions. Then the following holds: $$h \circ (g \circ f) = (h \circ g) \circ f.$$

This can be seen by the following identifications of sets.

$$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists z \in Z, [g \circ f](x) = z \wedge h(z) = w \}.$$ $$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists z \in Z, (x,z) \in [g \circ f] \wedge h(z) = w \}.$$ $$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists z \in Z, \left( \exists y \in Y (f(x) = y \wedge g(y) = z) \right) \wedge h(z) = w \}.$$ $$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists y \in Y, \exists z \in Z, f(x) = y \wedge h(z) = w \wedge g(y) = z\}.$$ $$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists y \in Y, (\exists z \in Z, g(y) = z \wedge h(z) = w) \wedge f(x) = y \}.$$ $$h \circ (g \circ f) = \{ (x,w) \in X \times W \mbox{ such that } \exists y \in Y, [h \circ g](y)=w \wedge f(x) = y \}.$$ $$h \circ (g \circ f) = (h \circ g) \circ f.$$