Skip to main content

Section 13.2 Composition

Composition may be a familiar idea from algebra. Suppose you have functions \(f\) and \(g\) such that \(f(x)=y\) and \(g(y)=z\text{.}\) Then you have a third function \(fg\) such that \(fg(x) = z\text{,}\) called the composition of \(f\) and \(g\text{.}\) You probably called \(fg\) something like \(g \circ f\) instead, but we have good reason to call it \(fg\text{.}\)

A composition of relations is the identical idea, but without the extra restrictions that make a relation into a function.

Definition 13.2.1.

Let \(R\) be a relation from \(X\) to \(Y\text{,}\) and \(S\) be a relation from \(Y\) to \(Z\text{.}\) Their composition is the relation

\begin{equation*} RS = \{(x,z) \; | \; \exists y \text{ s.t. } (x,y) \in R \text { and } (y,z) \in S \}. \end{equation*}

The composition of \(R\) with itself \(n\) times is denoted \(R^n\text{.}\)

Let \(R = \{ (x_1,y_2), (x_2,y_3), (x_3,y_1) \}\) be a relation from \(X=\{x_1,x_2,x_3\}\) to \(Y=\{y_1,y_2,y_3\}\text{,}\) and \(S = \{(y_1,z_1), (y_1,z_2), (y_2,z_2)\}\) be a relation from \(Y\) to \(Z=\{z_1,z_2\}\text{.}\) What is \(RS\text{?}\)

The relation \(RS\) is the set of all pairs \((x,z)\) for which there is a \(y\) “connecting” the \(x\) and the \(z\text{.}\) Looking at the given relations we may identify the following pairs: \((x_1,z_2)\) via \(y_2\text{,}\) \((x_3,z_1)\) via \(y_1\text{,}\) and \((x_3,z_2)\) also via \(y_1\text{.}\) Therefore

\begin{equation*} RS = \{(x_1, z_2), (x_3,z_1), (x_3,z_2)\}. \end{equation*}

The following diagram illustrates this composition.

The composition is illustrated. Elements of \(X\text{,}\) drawn in a blue circle, are related via arrows to the corresponding elements of \(Y\text{,}\) drawn in a red circle. Elements of \(Y\) are related to elements of \(Z\text{,}\) drawn in a yellow circle. The composition is created by “gluing” arrows together.
Figure 13.2.3.

The composition is illustrated. Elements of \(X\text{,}\) drawn in a blue circle, are related via arrows to the corresponding elements of \(Y\text{,}\) drawn in a red circle. Elements of \(Y\) are related to elements of \(Z\text{,}\) drawn in a yellow circle. The composition is created by “gluing” arrows together.

Observe that \(SR\) does not exist because the codomain of \(S\) is not the domain of \(R\text{.}\)

You may tell yourself, “I don't want to draw this diagram every time I compute a composition.” And you may tell yourself, “If the relations involved were large, I would like to be able to make a computer do this job for me.” Fortunately this apparatus is already in place! Recall the criteria for a pair \((x_i,z_j)\) appearing in the composition for sets whose elements are labeled numerically:

“\(x_i\) is related to \(z_j\) if there exists a \(k\) such that \(x_k\) is related to \(y_k\) and \(y_k\) is related to \(z_k\text{.}\)”

You may recall this exact language has appeared before:

“The Boolean dot product of a row matrix \((A_i)\) and a column matrix \((C_j)\) is \(1\) if there exists a \(k\) such that \(A_k\) and \(C_k\) are both \(1\text{.}\)”

It is precisely the multiplication of Boolean matrices that will find the necessary \(y_k\)'s for us:

In the last example we let \(R = \{ (x_1,y_2), (x_2,y_3), (x_3,y_1) \}\) be a relation from \(X=\{x_1,x_2,x_3\}\) to \(Y=\{y_1,y_2,y_3\}\text{,}\) and \(S = \{(y_1,z_1), (y_1,z_2), (y_2,z_2)\}\) be a relation from \(Y\) to \(Z=\{z_1,z_2\}\text{.}\)

The matrix for \(R\) is

\begin{equation*} M_R = \left( \begin{array}{ccc} 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp 1 \\ 1 \amp 0 \amp 0 \end{array} \right) \end{equation*}

and the matrix for \(S\) is

\begin{equation*} M_S = \left( \begin{array}{cc} 1 \amp 1 \\ 0 \amp 1 \\ 0 \amp 0 \end{array} \right). \end{equation*}

Their product is

\begin{equation*} \left( \begin{array}{ccc} 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp 1 \\ 1 \amp 0 \amp 0 \end{array} \right) \left( \begin{array}{cc} 1 \amp 1 \\ 0 \amp 1 \\ 0 \amp 0 \end{array} \right) = \left( \begin{array}{cc} 0 \amp 1 \\ 0 \amp 0 \\ 1 \amp 1 \end{array} \right), \end{equation*}

which you should verify yourself is also the matrix for

\begin{equation*} RS = \{(x_1, z_2), (x_3,z_1), (x_3,z_2)\}. \end{equation*}