Recursive Construction of Transitive Closure

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.

Alternative definition of construction
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.

Then:
 * $\displaystyle \mathcal R^+ = \bigcup_{i \in \N} \mathcal R^i$.