Recursive Construction of Transitive Closure

Theorem
Given the relation $\mathcal R$, its transitive closure $\mathcal R^+$ can be constructed as follows:

From Relation contains Composite with Self iff Transitive, it follows that the following more compact form can be used to define construct the transitive closure of $\mathcal R$:

Let:
 * $\mathcal R^n := \begin{cases}

\mathcal R & : n = 0 \\ \mathcal R^{n-1} \circ \mathcal R & : n > 0 \end{cases}$

where $\circ$ denotes composition of relations.

Finally, let
 * $\displaystyle \mathcal R^+ = \bigcup_{i \in \N} \mathcal R^i$.

Then $\mathcal R^+$ is the transitive closure of $\mathcal R$.

Lemma
$\mathcal R^+ \circ \mathcal R = \mathcal R^+$

Proof
$\mathcal R \subseteq \mathcal R^+$ by the definition of union.

Suppose $(a,c) \in \mathcal R^+ \circ \mathcal R^+$.

Then for some $b\in S$, $(a,b) \in \mathcal R^+$ and $(b,c) \in \mathcal R^+$.

Thus for some $n$, $(a,b) \in \mathcal R^n$, and for some $m$, $(b,c) \in \mathcal R^m$.

But then, since Composition of Relations is Associative, $R^{n+m} = R^n \circ R^m$, so

$(a,c) \in \mathcal R^{n+m}$.

Theorem
Given the relation $\mathcal R$, its transitive closure $\mathcal R^+$ can be constructed as follows:

Let:
 * $\mathcal R^n := \begin{cases}

\mathcal R & : n = 0 \\ \mathcal R^{n-1} \cup \left\{{\left({x_1, x_3}\right): \exists x_2: \left({x_1, x_2}\right) \in \mathcal R^{n-1} \land \left({x_2, x_3}\right) \in \mathcal R^{n-1}}\right\} & : n > 0 \end{cases}$

Finally, let
 * $\displaystyle \mathcal R^+ = \bigcup_{i \in \N} \mathcal R^i$.

Then $R^+$ is the transitive closure of $R$.

Proof
We must show that:


 * $\mathcal R \subseteq \mathcal R^+$
 * $\mathcal R^+$ is transitive
 * $\mathcal R^+$ is the smallest relation with both of those characteristics.

Proof of Subset
$\mathcal R \subseteq \mathcal R^+$: $\mathcal R^+$ contains all of the $\mathcal R^i$, so in particular $\mathcal R^+$ contains $\mathcal R$.

Proof of Transitivity
Every element of $\mathcal R^+$ is in one of the $\mathcal R^i$.

From the method of construction of $\mathcal R^+$, we have that $\forall i, j \in \N: \mathcal R^i \subseteq \mathcal R^{\max \left({i, j}\right)}$.

Suppose $\left({s_1, s_2}\right) \in \mathcal R^j$ and $\left({s_2, s_3}\right) \in \mathcal R^k$.

Then as:
 * $\mathcal R^j \subseteq \mathcal R^{\max \left({j, k}\right)}$

and:
 * $\mathcal R^k \subseteq \mathcal R^{\max \left({j, k}\right)}$

it follows that:
 * $\left({s_1, s_2}\right) \in \mathcal R^{\max \left({j, k}\right)}$ and $\left({s_2, s_3}\right) \in \mathcal R^{\max \left({j, k}\right)}$

It follows from the method of construction that $\left({s_1, s_3}\right) \in \mathcal R^{\max \left({j, k}\right)}$.

Hence as $\mathcal R^{\max \left({j, k}\right)} \subseteq \mathcal R^+$, it follows that $\mathcal R^+$ is transitive.

Proof of being the smallest such relation
Let $\mathcal R'$ be any transitive relation containing $\mathcal R$.

We want to show that $\mathcal R^+ \subseteq \mathcal R'$.

It is sufficient to show that $\forall i \in \N: \mathcal R^i \subseteq \mathcal R'$.

Since $\mathcal R \subseteq \mathcal R'$, we have that $\mathcal R^0 \subseteq \mathcal R'$.

Suppose $\mathcal R^i \subseteq \mathcal R'$.

From the method of construction, as $\mathcal R'$ is transitive, $\mathcal R^{i+1} \subseteq \mathcal R'$.

Therefore, by induction, $\forall i \in \N: \mathcal R^i \subseteq \mathcal R'$.

So $\mathcal R^+ \subseteq \mathcal R'$, and hence the result.