Composition of Relations is Associative

Theorem
$\newcommand {\Dom} [1] {\operatorname{Dom} \left({#1}\right)}$ $\newcommand {\Cdm} [1] {\operatorname{Cdm} \left({#1}\right)}$ The composition of relations is an associative binary operation:


 * $\left({\mathcal R_3 \circ \mathcal R_2}\right) \circ \mathcal R_1 = \mathcal R_3 \circ \left({\mathcal R_2 \circ \mathcal R_1}\right)$

Proof
First, note that from the definition of composition of relations, the following must be the case before the above expression is even to be defined:


 * $\Dom{\mathcal R_2} = \Cdm{\mathcal R_1}$
 * $\Dom{\mathcal R_3} = \Cdm{\mathcal R_2}$

The two composite relations can be seen to have the same domain, thus:

... and also the same codomain, thus:

So they are equal iff they have the same value at each point in their common domain, which this shows: