树木覆盖的森林与林间草地
库布龙森林 · Jean-Baptiste-Camille Corot / National Gallery of Art

Set operations compare membership of each ordered pair in two relations. Composition connects pairs through an intermediate element; powers repeat this operation to describe walks of a given length.

1. Set Operations on Relations

Let R,S⊆A×BR,S\subseteq A\times B. Their union, intersection, difference, and symmetric difference are also relations from AA to BB.

OperationCondition for (a,b)(a,b) to belong
R∪SR\cup SIt belongs to at least one of the relations
R∩SR\cap SIt belongs to both relations
R−SR-SIt belongs to RR but not to SS
R⊕S=(R−S)∪(S−R)R\oplus S=(R-S)\cup(S-R)It belongs to exactly one relation
R‾=(A×B)−R\overline R=(A\times B)-RIt does not belong to RR, but remains within the specified Cartesian product

The complement depends on the underlying sets: it does not include arbitrary pairs outside A×BA\times B. The symmetric difference can also be written as (R∪S)−(R∩S)(R\cup S)-(R\cap S).

Example: Computing set operations. Let A={1,2,3}A=\{1,2,3\}, B={1,2,3,4}B=\{1,2,3,4\}, and

R={(1,1),(2,2),(3,3)},S={(1,1),(1,2),(1,3),(1,4)}.R=\{(1,1),(2,2),(3,3)\},\qquad S=\{(1,1),(1,2),(1,3),(1,4)\}.

Find R∪SR\cup S, R∩SR\cap S, R−SR-S, S−RS-R, and R⊕SR\oplus S.

Show solution and steps

The only shared pair is (1,1)(1,1). Therefore,

R∪S={(1,1),(1,2),(1,3),(1,4),(2,2),(3,3)},R∩S={(1,1)},R−S={(2,2),(3,3)},S−R={(1,2),(1,3),(1,4)},R⊕S={(1,2),(1,3),(1,4),(2,2),(3,3)}.\begin{aligned} R\cup S&=\{(1,1),(1,2),(1,3),(1,4),(2,2),(3,3)\},\\ R\cap S&=\{(1,1)\},\\ R-S&=\{(2,2),(3,3)\},\\ S-R&=\{(1,2),(1,3),(1,4)\},\\ R\oplus S&=\{(1,2),(1,3),(1,4),(2,2),(3,3)\}. \end{aligned}

Union records each pair once. Symmetric difference excludes the shared members. Difference depends on the order of the operands.

Interpreting an application. If RR records courses a student has completed and SS records courses required for graduation, then S−RS-R records required courses still unfinished, while R∩SR\cap S records completed requirements. The objects remain student–course pairs; these operations do not discard either component.

Example: Order relations on the real numbers. Let L={(x,y)∈R2∣x<y}L=\{(x,y)\in\mathbb R^2\mid x<y\} and G={(x,y)∈R2∣x>y}G=\{(x,y)\in\mathbb R^2\mid x>y\}. Find their union, intersection, two differences, and symmetric difference. Also find the complement of their union in R2\mathbb R^2.

Show solution and steps

A real pair satisfies exactly one of x<yx<y, x=yx=y, or x>yx>y. Thus

L∪G={(x,y)∣x≠y},L∩G=∅,L−G=L,G−L=G,L⊕G={(x,y)∣x≠y},L∪G‾={(x,x)∣x∈R}.\begin{aligned} L\cup G&=\{(x,y)\mid x\ne y\},& L\cap G&=\varnothing,\\ L-G&=L,&G-L&=G,\\ L\oplus G&=\{(x,y)\mid x\ne y\},& \overline{L\cup G}&=\{(x,x)\mid x\in\mathbb R\}. \end{aligned}

The union excludes the entire diagonal, so it is not the universal relation. The differences preserve the original relations because no pair belongs to both. The complement result follows from the stated universe R2\mathbb R^2.

Inverses and Set Operations

For R,S⊆X×YR,S\subseteq X\times Y,

(R−1)−1=R,(R∪S)−1=R−1∪S−1,(R∩S)−1=R−1∩S−1,(R−S)−1=R−1−S−1,R⊆S  ⟺  R−1⊆S−1.\begin{aligned} (R^{-1})^{-1}&=R,\\ (R\cup S)^{-1}&=R^{-1}\cup S^{-1},\\ (R\cap S)^{-1}&=R^{-1}\cap S^{-1},\\ (R-S)^{-1}&=R^{-1}-S^{-1},\\ R\subseteq S&\iff R^{-1}\subseteq S^{-1}. \end{aligned}

Reversing each ordered pair preserves the membership conditions in these set operations.

2. Composition

Definition and Order of Evaluation

For R⊆A×BR\subseteq A\times B and S⊆B×CS\subseteq B\times C, define

S∘R={(a,c)∣∃b∈B, (a,b)∈R∧(b,c)∈S}.S\circ R=\{(a,c)\mid\exists b\in B,\ (a,b)\in R\land(b,c)\in S\}.

In S∘RS\circ R, follow RR first and SS second. At least one intermediate element bb must exist; it need not be unique. If several intermediate elements produce the same (a,c)(a,c), that pair appears only once in the resulting set.

For each starting element aa, list all bb reachable through RR. Next list all cc reachable from those bb through SS. Retain only the starting and ending elements. The relation on the right is used first, as in function composition.

Example: Composing through an intermediate set. Let

A={1,2,3},B={1,2,3,4},C={0,1,2},R={(1,1),(1,4),(2,3),(3,1),(3,4)}⊆A×B,S={(1,0),(2,0),(3,1),(3,2),(4,1)}⊆B×C.\begin{gathered} A=\{1,2,3\},\quad B=\{1,2,3,4\},\quad C=\{0,1,2\},\\ R=\{(1,1),(1,4),(2,3),(3,1),(3,4)\}\subseteq A\times B,\\ S=\{(1,0),(2,0),(3,1),(3,2),(4,1)\}\subseteq B\times C. \end{gathered}

Find S∘RS\circ R and identify the intermediate elements producing its pairs.

A three-column composition diagram showing the R edges from A to B and the S edges from B to C

Figure 1. Follow one edge of R and then one of S. Identical numbers in different columns occupy positions in their respective sets; keep the columns distinct when following edges.
Show solution and steps
Start aaIntermediate bb through RREnd cc through SSResulting pairs
11, 41→0; 4→1(1,0),(1,1)(1,0),(1,1)
233→1 and 3→2(2,1),(2,2)(2,1),(2,2)
31, 41→0; 4→1(3,0),(3,1)(3,0),(3,1)

Thus,

S∘R={(1,0),(1,1),(2,1),(2,2),(3,0),(3,1)}.S\circ R=\{(1,0),(1,1),(2,1),(2,2),(3,0),(3,1)\}.

For example, (2,2)(2,2) is produced through intermediate element 3. The pair (2,0)(2,0) in SS is never used because no pair in RR has second component 2.

Associativity and Failure of Commutativity

For relations R:A→BR:A\to B, S:B→CS:B\to C, and T:C→DT:C\to D,

T∘(S∘R)=(T∘S)∘R.T\circ(S\circ R)=(T\circ S)\circ R.

The arrows indicate the source and target sets of a relation, not that it must be a function. Both sides require elements b∈Bb\in B and c∈Cc\in C satisfying aRbaRb, bScbSc, and cTdcTd. Changing the parentheses does not change these three-step connections.

Composition is generally not commutative. Reversing the order may fail to match the source and target sets. Even when both relations are on the same set, the results can differ.

Supplementary example: A counterexample to commutativity. On A={1,2}A=\{1,2\}, let R={(1,2)}R=\{(1,2)\} and S={(2,1)}S=\{(2,1)\}. Find S∘RS\circ R and R∘SR\circ S.

Show solution and steps

Following RR then SS gives 1→2→11\to2\to1, so S∘R={(1,1)}S\circ R=\{(1,1)\}. Following SS then RR gives 2→1→22\to1\to2, so R∘S={(2,2)}R\circ S=\{(2,2)\}. The results are different.

Inverse of a Composition

For R⊆A×BR\subseteq A\times B and S⊆B×CS\subseteq B\times C,

(S∘R)−1=R−1∘S−1.(S\circ R)^{-1}=R^{-1}\circ S^{-1}.

Reverse the connection a→Rb→Sca\xrightarrow R b\xrightarrow S c to obtain c→S−1b→R−1ac\xrightarrow{S^{-1}}b\xrightarrow{R^{-1}}a. Taking the inverse of a composition reverses the order as well as each relation.

3. Powers and Transitivity

Powers Describe an Exact Number of Steps

For a relation RR on AA, its positive integer powers are defined recursively:

R1=R,Rn+1=Rn∘R(n≥1).R^1=R,\qquad R^{n+1}=R^n\circ R\quad(n\ge1).

A pair (a,b)(a,b) belongs to RnR^n when there is a directed walk of exactly nn edges from aa to bb. Vertices and edges may repeat. Connections using between one and nn edges are represented by R∪R2∪⋯∪RnR\cup R^2\cup\cdots\cup R^n. To allow zero steps as well, include IAI_A.

Example: Computing successive powers. On A={1,2,3,4}A=\{1,2,3,4\}, let

R={(1,1),(2,1),(3,2),(4,3)}.R=\{(1,1),(2,1),(3,2),(4,3)\}.

Find R2R^2, R3R^3, and R4R^4, and give a general expression for RnR^n when n≥3n\ge3.

A directed chain from 4 through 3 and 2 to 1, with a loop at vertex 1

Figure 2. After reaching 1, a walk can continue around its loop. This loop explains why the higher powers stabilize in this example; stabilization is not guaranteed for every relation.
Show solution and steps

Record the endpoint for each starting vertex and walk length:

Start1 step2 steps3 steps4 or more steps
11111
21111
32111
43211

Consequently,

R2={(1,1),(2,1),(3,1),(4,2)},R3={(1,1),(2,1),(3,1),(4,1)},R4=R3,Rn=R3(n≥3).\begin{aligned} R^2&=\{(1,1),(2,1),(3,1),(4,2)\},\\ R^3&=\{(1,1),(2,1),(3,1),(4,1)\},\\ R^4&=R^3,\qquad R^n=R^3\quad(n\ge3). \end{aligned}

After three steps, every walk ends at 1. Further steps follow the loop at 1, so Rn=R3R^n=R^3 for all n≥3n\ge3.

When a zeroth power is used, it is normally defined by R0=IAR^0=I_A, representing a zero-step walk that stays at its starting point. One may also define R−n=(R−1)nR^{-n}=(R^{-1})^n, but these negative powers do not generally behave as cancellable algebraic inverses.

Zeroth powers and inverse relations. The definition R0=IAR^0=I_A does not imply R∘R−1=IAR\circ R^{-1}=I_A for a general relation. For A={1,2}A=\{1,2\} and R={(1,2)}R=\{(1,2)\}, we obtain R∘R−1={(2,2)}≠IAR\circ R^{-1}=\{(2,2)\}\ne I_A. Both R∘R−1=IAR\circ R^{-1}=I_A and R−1∘R=IAR^{-1}\circ R=I_A hold when RR is the graph of a bijection from AA to itself. Positive powers remain defined by repeated composition.

Testing Transitivity with the Second Power

By definition, R2R^2 contains the starting and ending elements of every two-step connection. Hence

R is transitive  ⟺  R2⊆R  ⟺  ∀n≥1, Rn⊆R.\begin{aligned} R\text{ is transitive} &\iff R^2\subseteq R\\ &\iff \forall n\ge1,\ R^n\subseteq R. \end{aligned}

The first equivalence is the definition of transitivity. If every positive power is contained in RR, taking n=2n=2 proves transitivity. For the converse, use induction:

  1. For n=1n=1, R1=R⊆RR^1=R\subseteq R.
  2. Assume Rn⊆RR^n\subseteq R. If (a,b)∈Rn+1(a,b)\in R^{n+1}, there is an xx with (a,x)∈R(a,x)\in R and (x,b)∈Rn(x,b)\in R^n.
  3. The induction hypothesis gives (x,b)∈R(x,b)\in R. Transitivity then gives (a,b)∈R(a,b)\in R, proving Rn+1⊆RR^{n+1}\subseteq R.

Transitivity requires containment, not equality. For instance, R={(1,2)}R=\{(1,2)\} is transitive even though R2=∅R^2=\varnothing. If RR is both reflexive and transitive, then R⊆R2R\subseteq R^2: precede each existing edge by the loop at its starting vertex. Thus R2=RR^2=R, and every positive power equals RR.

From Repeated Connections to a Closure

The relation containing all positive-length connections is

R+=⋃n≥1Rn.R^+=\bigcup_{n\ge1}R^n.

It contains RR. Concatenating two finite walks gives another finite walk, so R+R^+ is transitive. Any transitive relation containing RR must contain every RnR^n, and therefore R+R^+. Thus R+R^+ is the smallest transitive relation containing RR, called the transitive closure.

Adding only R2R^2 may be insufficient. For R={(1,2),(2,3),(3,4)}R=\{(1,2),(2,3),(3,4)\}, the relation R∪R2R\cup R^2 contains (1,3)(1,3) and (3,4)(3,4) but lacks the required (1,4)(1,4). Three-step connections must also be considered.

4. Review and Self-Check

  1. Prove that R∪R−1R\cup R^{-1} is symmetric for every relation RR on AA.
  2. Must the union of two transitive relations be transitive? What about their intersection?
  3. For R={(1,2),(2,1)}R=\{(1,2),(2,1)\} on A={1,2}A=\{1,2\}, find R2R^2 and R3R^3. Do its powers eventually stabilize?
Show self-check answers
  1. If (a,b)(a,b) comes from RR, its reverse belongs to R−1R^{-1}. If it comes from R−1R^{-1}, its reverse belongs to RR. Either way, the union contains the reverse pair.
  2. The union need not be transitive. On {1,2,3}\{1,2,3\}, R={(1,2)}R=\{(1,2)\} and S={(2,3)}S=\{(2,3)\} are individually transitive, but their union lacks (1,3)(1,3). The intersection is transitive: two consecutive pairs in it belong to both relations, so their shortcut belongs to both and therefore to the intersection.
  3. R2=IAR^2=I_A and R3=RR^3=R. Every even power is IAI_A and every odd power is RR. The sequence is periodic rather than eventually constant.

Glossary and Sources

TermMain idea
Composition of relationsS∘RS\circ R: first RR, then SS
Powers of a relationRnR^n: exactly nn steps
Symmetric differenceR⊕SR\oplus S: membership in exactly one relation
Transitive closureThe smallest transitive relation containing the original relation
Directed walkA sequence of directed edges in which vertices and edges may repeat
  • Course slides.
  • Rosen, 8th edition, Section 9.1: printed pages 606–608, PDF pages 629–631. The closure connection uses the opening of Section 9.4 on printed page 628, PDF page 651.
  • Figures 1 and 2 are redrawn from the edge sets in the worked examples. The noncommutativity example, the vacuous and periodic power examples, and the counterexample to cancellation with inverse relations are supplementary derivations.

Assigned textbook exercises: Section 9.1, Exercise 32 on composition, printed page 609 / PDF page 632; Exercise 50(a, b) on counting transitive relations on one and two elements; Exercise 58 on computing R2R^2 through R5R^5, with the last two exercises on printed page 610 / PDF page 633. The Boolean matrix method in Note 1.4 can assist with higher powers.

Updated:

RelationsCompositionPowers