MAT2033 · Week 12 · relations

Relations: properties, equivalence relations and partial orders

Checking whether a relation is reflexive, symmetric, antisymmetric or transitive, taking composites and closures, and drawing equivalence classes and Hasse diagrams. Classic question types for the final.

binary relationrelation on a setreflexiveirreflexivesymmetricantisymmetrictransitivecomposite of relationstransitive closureequivalence relationequivalence classpartitionpartial orderposetHasse diagramleast upper boundn-ary relation

Relations are a generalization of functions. In a function every input had exactly one output; in a relation an element can be related to nothing or to many things. This week is a final exam topic. The question types expected on the exam: checking the four properties of a given relation, “Prove that RR is an equivalence relation”, writing equivalence classes, drawing a Hasse diagram and counting relations.

Golden rules:

  1. “For every” properties (reflexive) are broken by a single missing pair, and “if … then” properties (symmetric, transitive) are broken by a single counterexample.
  2. Antisymmetric does not mean “not symmetric”. Both can be true at the same time or false at the same time.
  3. Equivalence = reflexive + symmetric + transitive. Partial order = reflexive + antisymmetric + transitive.
  4. For the composite S∘RS\circ R: first RR, then SS.

Definitions

A binary relation from AA to BB is any subset of A×BA\times B. Instead of (a,b)∈R(a,b)\in R we write a R ba\,R\,b. A relation from AA to AA is called a “relation on AA”.

Intuition: let AA be students and BB be courses. ”aa takes course bb” is a relation. A student may take no courses or five courses. Every function is a relation; the converse is not true.

If ∣A∣=n|A| = n there are ∣A×A∣=n2|A\times A| = n^2 pairs, and each is either in the relation or not. So there are 2n22^{n^2} relations on AA.

The four properties

Let RR be a relation on AA.

PropertyDefinitionHow it looks in the matrix MRM_RTo break it
reflexive∀a (a,a)∈R\forall a\ (a,a)\in Rthe diagonal is all 1one (a,a)(a,a) missing
irreflexive∀a (a,a)∉R\forall a\ (a,a)\notin Rthe diagonal is all 0one (a,a)(a,a) present
symmetric(a,b)∈R→(b,a)∈R(a,b)\in R \to (b,a)\in RM=MTM = M^T(a,b)(a,b) present, (b,a)(b,a) absent
antisymmetric(a,b)∈R∧(b,a)∈R→a=b(a,b)\in R \wedge (b,a)\in R \to a = boff the diagonal mijm_{ij} and mjim_{ji} are not both 1a≠ba\neq b, both present
transitive(a,b)∈R∧(b,c)∈R→(a,c)∈R(a,b)\in R \wedge (b,c)\in R \to (a,c)\in RM[2]≤MM^{[2]} \le M (Boolean)(a,b),(b,c)(a,b),(b,c) present, (a,c)(a,c) absent

Example 1. ≤\le on {1,2,3,4}\{1,2,3,4\}: every a≤aa\le a (reflexive). 1≤21\le 2 but 2≰12\not\le 1 (not symmetric). If a≤ba\le b and b≤ab \le a then a=ba = b (antisymmetric). If a≤b≤ca\le b\le c then a≤ca \le c (transitive).

Example 2. R={(1,1),(1,2),(2,1)}R = \{(1,1),(1,2),(2,1)\} on {1,2,3}\{1,2,3\}:

reflexive?      (2,2) missing              -> NO
symmetric?      (1,2) and (2,1) both present  -> YES
antisymmetric?  (1,2),(2,1) present but 1 != 2  -> NO
transitive?     (2,1),(1,2) present, (2,2) missing   -> NO

PITFALL · Skipping the case a=ca = c in the transitivity check. In Example 2, (2,1)(2,1) and (1,2)(1,2) require (2,2)(2,2). Most students look only at chains of “three distinct elements” and miss this.

TIP · the empty condition. For “if … then” properties, if the premise is never satisfied, the property is automatically true. The empty relation is symmetric, antisymmetric and transitive (but not reflexive if AA is nonempty).

Counting relations

∣A∣=n|A| = n. There are nn pairs on the diagonal and n2−nn^2 - n off the diagonal; the off-diagonal pairs are grouped into matchings {a,b}\{a,b\}, and there are n(n−1)2\frac{n(n-1)}{2} matchings.

TypeNumbern=3n=3
all relations2n22^{n^2}512
reflexive2n2−n2^{n^2-n}64
symmetric2n(n+1)/22^{n(n+1)/2}64
antisymmetric2n⋅3n(n−1)/22^n\cdot 3^{n(n-1)/2}216
reflexive and symmetric2n(n−1)/22^{n(n-1)/2}8

The logic: in symmetric the diagonal pairs are free (2n2^n), and each matching is “both or neither” (22 choices). In antisymmetric there are 3 choices for each matching: only (a,b)(a,b), only (b,a)(b,a), neither.

Composites and powers of relations

If RR: A→BA\to B and SS: B→CB \to C, then

S∘R={(a,c):∃b ((a,b)∈R∧(b,c)∈S)}.S\circ R = \{(a,c) : \exists b\ \big((a,b)\in R \wedge (b,c)\in S\big)\}.

Like function composition: go first with RR, then continue with SS. Powers: R1=RR^1 = R, Rn+1=Rn∘RR^{n+1} = R^n \circ R. An important theorem: RR is transitive   ⟺  \iff Rn⊆RR^n \subseteq R for every n≥1n\ge 1.

Transitive closure R∗R^*: the smallest transitive relation containing RR. Think of it as a directed graph: if there is a path from aa to bb, then (a,b)∈R∗(a,b)\in R^*. With matrices, MR∗=MR∨MR[2]∨⋯∨MR[n]M_{R^*} = M_R \vee M_R^{[2]} \vee \dots \vee M_R^{[n]}; in practice the Warshall algorithm is used.

Equivalence relations

A relation that is reflexive, symmetric and transitive is called an equivalence relation. Intuition: a “sameness” relation like “plays on the same team”, “gives the same remainder”, “born in the same year”.

The equivalence class of aa: [a]R={s:(a,s)∈R}[a]_R = \{s : (a,s)\in R\}.

Basic theorem: equivalence classes are either identical or disjoint, and their union is AA. So they form a partition. Conversely, every partition defines an equivalence relation (“being in the same block”). That is why the number of equivalence relations on an nn-element set equals the number of partitions (the Bell number): 5 for n=3n = 3, 15 for n=4n = 4.

The most classic example: congruence modulo mm. a≡b(modm)a \equiv b \pmod m if and only if m∣a−bm \mid a - b. There are mm classes: [0],[1],…,[m−1][0], [1], \dots, [m-1].

A fully written proof

Claim. Let m>1m > 1 be an integer. The relation R={(a,b):a≡b(modm)}R = \{(a,b) : a \equiv b \pmod m\} on Z\mathbb{Z} is an equivalence relation.

Proof. Reflexive. For every integer aa, a−a=0=m⋅0a - a = 0 = m\cdot 0, so m∣a−am \mid a - a and a R aa\,R\,a. Symmetric. Suppose a R ba\,R\,b. Then a−b=mka - b = mk for some integer kk. Hence b−a=m(−k)b - a = m(-k), and −k-k is an integer, so b R ab\,R\,a. Transitive. Suppose a R ba\,R\,b and b R cb\,R\,c. Then a−b=mka - b = mk and b−c=mlb - c = ml for some integers k,lk, l. Adding, a−c=m(k+l)a - c = m(k + l), so m∣a−cm \mid a - c and a R ca\,R\,c. Since RR is reflexive, symmetric and transitive, it is an equivalence relation. ■\blacksquare

In plain words: write each property under a separate heading, write the definition (a−b=mka - b = mk) out explicitly, and at the end add a closing sentence that mentions all three. Instructors give marks per property.

Partial orders

A relation that is reflexive, antisymmetric and transitive is called a partial order; the pair (S,≼)(S, \preccurlyeq) is called a poset. Examples: ≤\le on numbers, ∣\mid on positive integers, ⊆\subseteq on sets.

It is “partial” because two elements need not be comparable: 2∤32 \nmid 3 and 3∤23\nmid 2. If every pair is comparable it is called a total order.

Hasse diagram

A short way to draw a poset. From the directed graph remove three things:

  1. the diagonal loops (already known from reflexivity),
  2. the edges that come from transitivity (the edge aa-cc if a≼b≼ca \preccurlyeq b \preccurlyeq c),
  3. the arrow directions (the smaller is drawn lower).

Only the cover pairs remain: a≺ba \prec b with no element in between.

Example. The divisors of 18, {1,2,3,6,9,18}\{1,2,3,6,9,18\}, with divisibility:

level 3:             18
                    /  \
level 2:           6    9
                  / \  /
level 1:         2   3
                  \ /
level 0:           1
edges: 1-2, 1-3, 2-6, 3-6, 3-9, 6-18, 9-18   (7 edges)

Terms: maximal (nothing above it), minimal (nothing below it), greatest/least element (greater/smaller than everyone, must be unique), upper bound (greater than or equal to everything in a subset), least upper bound (the smallest of the upper bounds). For divisibility, lub = lcm, glb = gcd.

n-ary relations (briefly)

A subset of A1×A2×⋯×AnA_1\times A_2\times\dots\times A_n is called an n-ary relation. A database table is exactly this: each row is an nn-tuple, each column is a field. Selection filters rows, projection removes columns, join matches two tables on common fields. On the final it comes at most as one definition question.

Common mistakes

WrongThe truth
“Not symmetric, so antisymmetric”Independent properties; {(1,2),(2,1),(1,3)}\{(1,2),(2,1),(1,3)\} is neither
Skipping the chain (a,b),(b,a)(a,b),(b,a) in transitivity(a,a)(a,a) is needed too
Thinking “some (a,a)(a,a) present” is enough for reflexive(a,a)(a,a) for every aa
Applying SS first in S∘RS\circ RFirst RR, then SS
Drawing a transitive edge like 11-44 in a Hasse diagramOnly pairs with no element in between
Maximal = greatestThere can be several maximal elements; greatest is larger than everyone and unique
3n23^{n^2} for counting antisymmetric relations2n⋅3n(n−1)/22^n \cdot 3^{n(n-1)/2}: 2 choices on the diagonal, 3 per matching
Putting an element in two classes when writing equivalence classesClasses are disjoint; every element is in exactly one class

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Let R={(a,b):a∣b}R = \{(a,b) : a \mid b\} on A={1,2,3,4}A = \{1,2,3,4\}. List the number of ordered pairs in RR and determine whether RR is reflexive, symmetric, antisymmetric, transitive.

Show answer
8 pairs; reflexive, not symmetric, antisymmetric, transitive

The pairs: (1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4), 8 in total.
Every a∣aa \mid a, so it is reflexive. (1,2)∈R(1,2) \in R but (2,1)∉R(2,1) \notin R, so it is not symmetric. a∣ba \mid b and b∣ab \mid a (for positive numbers) give a=ba = b, so it is antisymmetric. If a∣ba\mid b and b∣cb \mid c then a∣ca \mid c, so it is transitive. Conclusion: a partial order.

Question 2easy

Show that R={(1,1),(1,2),(2,1),(2,2),(3,3)}R = \{(1,1),(1,2),(2,1),(2,2),(3,3)\} on {1,2,3}\{1,2,3\} is an equivalence relation and list its equivalence classes.

Show answer
Classes: {1,2} and {3}

Reflexive: (1,1),(2,2),(3,3)(1,1),(2,2),(3,3) are all present. Symmetric: the only off-diagonal pairs are (1,2)(1,2) and (2,1)(2,1), and both are present. Transitive: for (1,2),(2,1)(1,2),(2,1) we have (1,1)(1,1); for (2,1),(1,2)(2,1),(1,2) we have (2,2)(2,2); the other chains involve the diagonal.[1]={1,2}=[2][1] = \{1,2\} = [2], [3]={3}[3] = \{3\}. The classes {1,2}\{1,2\} and {3}\{3\} form a partition of the set.

Question 3easy

How many binary relations are there on a set with 4 elements?

Show answer
65536

A relation is a subset of A×AA \times A. ∣A×A∣=16|A\times A| = 16, and each pair is either in or out: 216=655362^{16} = 65536.

Question 4medium

How many reflexive relations are there on a set with 4 elements?

Show answer
4096

The 4 diagonal pairs (a,a)(a,a) must be present. The remaining 16−4=1216 - 4 = 12 pairs are free: 212=40962^{12} = 4096.

Question 5medium

How many antisymmetric relations are there on a set with 3 elements?

Show answer
216

The 3 pairs on the diagonal are free: 232^3. Off the diagonal there are C(3,2)=3C(3,2) = 3 matchings of the form {a,b}\{a,b\}. For each there are 3 choices: only (a,b)(a,b), only (b,a)(b,a), neither (both together is forbidden).
Total 23⋅33=8⋅27=2162^3 \cdot 3^3 = 8 \cdot 27 = 216.

Question 6medium

On {1,2,3}\{1,2,3\} let R={(1,2),(1,3),(2,3)}R = \{(1,2),(1,3),(2,3)\} and S={(2,1),(3,2),(3,3)}S = \{(2,1),(3,2),(3,3)\}. Find S∘RS \circ R.

Show answer
{(1,1),(1,2),(1,3),(2,2),(2,3)}

S∘R={(a,c):∃b, (a,b)∈R and (b,c)∈S}S\circ R = \{(a,c) : \exists b,\ (a,b)\in R \text{ and } (b,c)\in S\}. First RR, then SS.(1,2)(1,2) with (2,1)(2,1): (1,1)(1,1). (1,3)(1,3) with (3,2)(3,2), (3,3)(3,3): (1,2)(1,2), (1,3)(1,3). (2,3)(2,3) with (3,2)(3,2), (3,3)(3,3): (2,2)(2,2), (2,3)(2,3).
The result is {(1,1),(1,2),(1,3),(2,2),(2,3)}\{(1,1),(1,2),(1,3),(2,2),(2,3)\}. (In the reverse order R∘S={(2,2),(2,3),(3,3)}R\circ S = \{(2,2),(2,3),(3,3)\}, which is different.)

Question 7medium

Let RR be congruence modulo 4 on A={0,1,…,11}A = \{0, 1, \dots, 11\}. Find the equivalence class of 7 and the number of ordered pairs in RR.

Show answer
[7] = {3, 7, 11}; 36 pairs

[7]={x∈A:x≡7(mod4)}={3,7,11}[7] = \{x \in A : x \equiv 7 \pmod 4\} = \{3, 7, 11\}.
There are 4 classes ([0],[1],[2],[3][0],[1],[2],[3]), each with 3 elements. Every ordered pair from within one class is in the relation: 32=93^2 = 9. Total 4⋅9=364 \cdot 9 = 36.

Question 8hard

How many different equivalence relations are there on a set with 4 elements?

Show answer
15

Equivalence relations correspond one-to-one with partitions. Count by block structure of the 4 elements:
one block {4}\{4\}: 1. 3+13+1: 4. 2+22+2: 3. 2+1+12+1+1: C(4,2)=6C(4,2) = 6. 1+1+1+11+1+1+1: 1. Total 1+4+3+6+1=151+4+3+6+1 = 15.

Question 9medium

Consider the poset ({1,2,3,4,6,12},∣)(\{1,2,3,4,6,12\}, \mid). How many edges does its Hasse diagram have? Find the least upper bound and the greatest lower bound of {4,6}\{4, 6\}.

Show answer
7 edges; lub = 12, glb = 2

A Hasse edge is only a pair with "no element in between" (a cover): 1-21\text{-}2, 1-31\text{-}3, 2-42\text{-}4, 2-62\text{-}6, 3-63\text{-}6, 4-124\text{-}12, 6-126\text{-}12. Total 7 (1-41\text{-}4 is not drawn, since 2 lies in between).
Upper bounds: those that are multiples of both 4 and 6, only 12. The least upper bound is 12. Lower bounds: those that divide both, {1,2}\{1,2\}, the greatest is 2.

Question 10hard

Let RR be the relation on Z\mathbb{Z} with a R ba\,R\,b iff a+ba + b is even. Prove that RR is an equivalence relation and describe its equivalence classes.

Show answer
Equivalence relation; two classes: even and odd integers

Reflexive: a+a=2aa + a = 2a is even, so a R aa\,R\,a.
Symmetric: if a+ba + b is even then b+a=a+bb + a = a + b is also even.
Transitive: let a+b=2ka + b = 2k, b+c=2mb + c = 2m. Add: a+2b+c=2k+2ma + 2b + c = 2k + 2m, so a+c=2(k+m−b)a + c = 2(k + m - b), even. Thus a R ca\,R\,c.
Classes: [0][0] = the even numbers, [1][1] = the odd numbers. (a+ba+b is even if and only if aa and bb have the same parity.)

Question 11medium

Find the transitive closure of R={(1,2),(2,3),(3,4)}R = \{(1,2),(2,3),(3,4)\} on {1,2,3,4}\{1,2,3,4\}.

Show answer
{(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}

Transitive closure = every (a,b)(a,b) for which there is a path in the directed graph. Paths: 1→21\to2, 1→2→31\to2\to3, 1→2→3→41\to2\to3\to4, 2→32\to3, 2→3→42\to3\to4, 3→43\to4.
The added pairs are (1,3)(1,3), (2,4)(2,4), (1,4)(1,4). Total 6 pairs. (There is no cycle, so no diagonal pairs appear.)

Question 12hard

Let a R ba\,R\,b iff a≤b+1a \le b + 1 on Z\mathbb{Z}. Is RR reflexive, symmetric, antisymmetric, transitive? Give counterexamples where it fails.

Show answer
Reflexive only

Reflexive: a≤a+1a \le a + 1, true.
Not symmetric: (0,5)(0, 5) is in (0≤60 \le 6) but (5,0)(5, 0) is not (5≤15 \le 1 is false).
Not antisymmetric: both (2,1)(2,1) (2≤22 \le 2) and (1,2)(1,2) (1≤31 \le 3) are in, but 1≠21 \neq 2.
Not transitive: (3,2)(3,2) and (2,1)(2,1) are in, but (3,1)(3,1) is not, because 3≤23 \le 2 is false.

Verification: The properties of every relation were checked by brute force over all pairs with node; the counting formulas were verified by counting one by one for n = 2, 3 (and for equivalence relations n = 4, 2^16 relations); composites, transitive closure (Warshall) and Hasse edges were computed in code (verify/MAT2033/12.mjs).

Review card

Relation R ⊆ A x A; if |A| = n there are 2^(n^2) relations Reflexive: EVERY (a,a) is PRESENT -> 2^(n^2 - n) of them Irreflexive: NO (a,a) at all Symmetric: if (a,b) then (b,a) -> 2^(n(n+1)/2) Antisymmetric: if both (a,b) and (b,a) then a = b -> 2^n * 3^(n(n-1)/2) Transitive: if (a,b), (b,c) then (a,c) too Can be symmetric and antisymmetric at once (diagonal only); "not" one is not the other S o R: first R then S; (a,c): a R b and b S c Equivalence = refl + sym + trans; classes give a partition; mod m -> m classes Partial order = refl + antisym + trans; Hasse: no loops/directions/transitive edges lub: least upper bound, glb: greatest lower bound; for divides, lcm and gcd Matrix: refl diagonal all 1, sym M = M^T, transitive closure with Warshall