# Composition of relations

Let $R$ be the following relation from $\{1, 2, 3\}$ to $\{a, b, c, d\}$: $$R = \{(1, a), (1, d), (2, c), (3, a), (3, d)\}.$$ Let $S$ be the following relation from $\{a, b, c, d\}$ to $\{1, 2, 3\}$: $$S = \{(a, 3), (b, 3), (c, 1), (c, 2), (d, 1)\}.$$ Then $$R \circ S = \{(1, 3), (1, 1), (2, 1), (2, 2), (3, 3), (3, 1)\},$$ $$S \circ R = \{(a, a), (a, d), (b, a), (b, d), (c, a), (c, d), (c, c), (d, a), (d, d)\}.$$

What I don't understand is why isn't $(1,2)$ in $R \circ S$. Also why isn't $(a,c)$, $(b,c)$, $(c,a)$, $(d,c)$ in $S \circ R$.

-

In order for $(1,2)$ to be in $R\circ S$, there would have to be some $x\in \{a,b,c,d\}$ such that $(1,x)\in R$ and $(x,2)\in S$, but there is no such $x$. We have $(1,a)\in R$ and $(1,d)\in R$, but neither $(a,2)$ nor $(d,2)$ are in $S$.
Similarly, in order for $(a,c)$ to be in $S\circ R$, there would have to be some $n\in\{1,2,3\}$ such that $(a,n)\in S$ and $(n,c)\in R$, but there is no such $n$. Again similarly for $(b,c)$, $(c,a)$, and $(d,c)$.