Definition:Composition of Relations

Let $$\mathcal{R}_1 \subseteq S_1 \times S_2$$ and $$\mathcal{R}_2 \subseteq S_2 \times S_3$$ be relations, and $$\mathrm {Dom} \left ( {\mathcal{R}_2}\right) = \mathrm {Rng} \left ( {\mathcal{R}_1}\right)$$.

Then the composite of $$\mathcal{R}_1$$ and $$\mathcal{R}_2$$ is defined and denoted as:

$$\mathcal{R}_2 \circ \mathcal{R}_1 = \left\{{\left({x, z}\right): x \in S_1, z \in S_3: \exists y \in S_2: \left({x, y}\right) \in \mathcal{R}_1 \land \left({y, z}\right) \in \mathcal{R}_2}\right\}$$

Note that:

$$\mathcal{R}_2 \circ \mathcal{R}_1 \subseteq S_1 \times S_3$$

If $$\mathrm {Dom} \left ( {\mathcal{R}_2}\right) \ne \mathrm {Rng} \left ( {\mathcal{R}_1}\right)$$, then $$\mathcal{R}_2 \circ \mathcal{R}_1$$ is not defined.

Some authors write $$\mathcal{R}_2 \circ \mathcal{R}_1$$ as $$\mathcal{R}_2 \mathcal{R}_1$$.

That is, the composite relation $$\mathcal{R}_2 \circ \mathcal{R}_1$$ is defined as:

$$\mathcal{R}_2 \circ \mathcal{R}_1 \left( {S}\right) = \mathcal{R}_2 \left( {\mathcal{R}_1 \left({S}\right)}\right)$$