# Section6.5Closure Operations on Relations¶ permalink

In Section 6.1, we studied relations and one important operation on relations, namely composition. This operation enables us to generate new relations from previously known relations. In Section 6.3, we discussed some key properties of relations. We now wish to consider the situation of constructing a new relation $r^+$ from an existing relation $r$ where, first, $r^+$ contains $r$ and, second, $r^{+ }$ satisfies the transitive property.

Consider a telephone network in which the main office $a$ is connected to, and can communicate to, individuals $b$ and $c$. Both $b$ and $c$ can communicate to another person, $d$; however, the main office cannot communicate with $d$. Assume communication is only one way, as indicated. This situation can be described by the relation $r = \{(a, b), (a, c), (b, d), (c, d)\}$. We would like to change the system so that the main office $a$ can communicate with person $d$ and still maintain the previous system. We, of course, want the most economical system.

This can be rephrased as follows; Find the smallest relation $r^{+ }$ which contains $r$ as a subset and which is transitive; $r^+ =\{(a, b), (a, c), (b, d), (c, d), (a, d)\}$.

##### Definition6.5.1Transitive Closure

Let $A$ be a set and $r$ be a relation on $A$. The transitive closure of $r$, denoted by $r^+$, is the smallest transitive relation that contains $r$ as a subset.

Let $A = \{1, 2, 3, 4\}$, and let $\mathcal{S} = \{(1, 2), (2, 3), (3, 4)\}$ be a relation on $A$. This relation is called the successor relation on $A$ since each element is related to its successor. How do we compute $\mathcal{S}^+$? By inspection we note that $(1, 3)$ must be in $\mathcal{S}^+$ . Let's analyze why. This is so because $(1,2) \in \mathcal{S}$ and $(2, 3) \in \mathcal{S}$, and the transitive property forces $(1,3)$ to be in $\mathcal{S}^+$.

In general, it follows that if $(a, b) \in \mathcal{S}$ and $(b, c) \in S,$ then $(a, c) \in \mathcal{S}^+$. This condition is exactly the membership requirement for the pair $(a, c)$ to be in the composition $\mathcal{S}\mathcal{S} = \mathcal{S}^2$. So every element in $\mathcal{S}^2$ must be an element in $\mathcal{S}^+$ . So we now know that, $\mathcal{S}^+$ contains at least $\mathcal{S} \cup \mathcal{S}^2$ . In particular, for this example, since $\mathcal{S} = \{(1, 2), (2, 3), (3, 4)\}$ and $\mathcal{S}^2 = \{(1, 3), (2, 4)\}$, we have $\mathcal{S} \cup \mathcal{S}^2 =\{(1, 2), (2, 3), (3, 4), (1, 3), (2, 4)\}$

Is the relation $\mathcal{S} \cup \mathcal{S}^2$ transitive? Again, by inspection, $(1, 4)$ is not an element of $\mathcal{S} \cup \mathcal{S}^2$, but $(1,3) \in \mathcal{S}^2$ and $(3, 4) \in \mathcal{S}$. Therefore, the composition $\mathcal{S}^2 \mathcal{S} = \mathcal{S}^3$ produces $(1, 4)$, and it must be an element of $\mathcal{S}^+$ since $(1,3)$ and $(3, 4)$ are required to be in $\mathcal{S}^+$. This shows that $\mathcal{S}^3 \subseteq \mathcal{S}^+$. This process must be continued until the resulting relation is transitive. If $A$ is finite, as is true in this example, the transitive closure will be obtained in a finite number of steps. For this example, $\mathcal{S}^+ =\mathcal{S}\cup \mathcal{S} ^2\cup \mathcal{S} ^3=\{(1, 2), (2, 3), (3, 4),(1, 3),(2, 4),(1,4)\}$

Let's now consider the matrix analogue of the transitive closure.

Consider the relation $r = \{(1, 4), (2, 1), (2, 2), (2, 3),(3, 2), (4, 3), (4, 5), (5, 1)\}$ on the set $A = \{1,2, 3, 4, 5\}$. The matrix of $r$ is $R=\left( \begin{array}{ccccc} 0 & 0 & 0 & 1 & 0 \\ 1 & 1 & 1 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 1 \\ 1 & 0 & 0 & 0 & 0 \\ \end{array} \right)$

Recall that $r^2, r^3, \ldots$ can be determined through computing the matrix powers $R^2, R^3, \ldots$. For our example,

How do we relate $\underset{i=1}{\overset{5}{\cup }}r^i$ to the powers of $R$?

Using this theorem, we find $R^+$ is the $5\times 5$ matrix consisting of all $1's$, thus, $r^+$ is all of $A \times A$.

Let $r$ be a relation on the set $\{1, 2, \dots , n\}$ with relation matrix $R$. The matrix of the transitive closure $R^+$, can be computed by the equation $R^+ = R + R ^2 + \cdots + R^n$. By using ordinary polynomial evaluation methods, you can compute $R^+$ with $n -1$ matrix multiplications: $R^+ = R(I + R(I +( \cdots R(I+ R) \cdots )))$

For example, if $n = 3$, $R = R(I + R(I + R))$.

We can make use of the fact that if $T$ is a relation matrix, $T + T = T$ due to the fact that $1 + 1 = 1$ in Boolean arithmetic. Let $S_k = R + R^2 + \cdots + R^k$. Then

\begin{equation*} \begin{split} R &= S_1\\ S_1(I+S_1)&=R(I+R)=R+R^2 = S_2 \\ S_2(I+S_2)&=(R+R^2)(I+R+R^2) \\ &=(R+R^2)+(R^2+R^3)+(R^3+R^4) \\ &=R+R^2+R^3+R^4 = S_4 \end{split} \end{equation*}

Similarly, $S_4(I+S_4)=S_8$ and by induction we can prove $S_{2^k}(I+S_{2^k})=S_{2^{k+1}}$

Notice how each matrix multiplication doubles the number of terms that have been added to the sum that you currently have computed. In algorithmic form, we can compute $R^+$ as follows.

##### Note6.5.5

• Often the higher-powered terms in $S_n$ do not contribute anything to $R^+$. When the condition $T = S$ becomes true in Step 3, this is an indication that no higher-powered terms are needed.

• To compute $R^+$ using this algorithm, you need to perform no more than $\lceil \log_2 n \rceil$ matrix multiplications, where $\lceil x \rceil$ is the least integer that is greater than or equal to $x$. For example, if $r$ is a relation on 25 elements, no more than $\lceil \log_2 25 \rceil = 5$ matrix multiplications are needed.

A second algorithm, Warshall's Algorithm, reduces computation time to the time that it takes to multiply two square matrices with the same order as the relation matrix in question.

##### 1

Let $A =\{1, 2, 3, 4, 5\}$ and $\mathcal{S}=\{(1,2),(2,4),(3,4),(4,5),(5,2)\}$. Compute $\mathcal{S}^+$ using the matrix representation of $\mathcal{S}$. Verify your results by checking against the result obtained directly from the definition of transitive closure.

##### 2

Let $A=\{1,2,3,4,6,12\}$ and $t=\{(a,b)\mid b/a \textrm{ is a prime number}\}$. Determine $t^+$ by any means but represent it as a matrix.

##### 3

1. Draw digraphs of the relations $\mathcal{S}$, $\mathcal{S}^2$, $\mathcal{S}^3$ , and $\mathcal{S}^+$ where $\mathcal{S}$ is defined in the first exercise above.

2. Verify that in terms of the graph of $\mathcal{S}$, $a \mathcal{S}^+ b$ if and only if $b$ is reachable from $a$ along a path of any finite nonzero length.
##### 4

Let $r$ be the relation represented by the following digraph.

1. Find $r^+$ using the definition based on order pairs.

2. Determine the digraph of $r^+$ directly from the digraph of $r$.

3. Verify your result in part (b) by computing the digraph from your result in part (a).

##### 5

1. Define reflexive closure and symmetric closure by imitating the definition of transitive closure.

2. Use your definitions to compute the reflexive and symmetric closures of examples in the text.

3. What are the transitive reflexive closures of these examples?

4. Convince yourself that the reflexive closure of the relation $<$ on the set of positive integers $\mathbb{P}$ is $\leq$.

##### 6

What common relations on $\mathbb{Z}$ are the transitive closures of the following relations?

1. $a S b$ if and only if $a + 1 = b$.

2. $a R b$ if and only if $| a - b | = 2$.

##### 7

1. Let $A$ be any set and $r$ a relation on $A$, prove that $\left(r^+\right)^+=r^+$.

2. Is the transitive closure of a symmetric relation always both symmetric and reflexive? Explain.

The definition of the Transitive Closure of $r$ refers to the “smallest transitive relation that contains $r$ as a subset.” Show that the intersection of all transitive relations on $A$ containing $r$ is a transitive relation containing $r$ and is precisely $r^+$.