Equivalence Relations
An equivalence relation is a relation that is reflexive, symmetric and transitive, so it acts like “is the same as” in some way. It splits its set into equivalence classes: groups whose members are all related to each other and to nothing outside the group. Together, the classes form a partition of the set.
Before this lesson: Properties of Relations, Modular Arithmetic and Set Operations
The idea
“Was born in the same month as” is a relation on people. Everyone was born in the same month as themselves, it works in both directions, and if Ana matches Ben and Ben matches Cy, then Ana matches Cy. So it is reflexive, symmetric and transitive.
This relation sorts people into 12 groups, one for each month. Everyone in a group is related to everyone else in it, and no one is related to anyone in a different group. Every equivalence relation works this way: it sorts a set into separate groups of “equivalent” elements.
Equivalence relation definition and classes
A relation R on a set A is an equivalence relation if it is reflexive, symmetric and transitive (see the previous lesson). We often write a \sim b instead of a \, R \, b. The equivalence class of an element a is the set of everything related to it:
[a] = \{x \in A : x \sim a\}Any member of a class can name it; that member is a representative. The key facts are:
- Every element is in its own class: a \in [a], because R is reflexive.
- Two classes are either equal or disjoint: if a \sim b, then [a] = [b]; otherwise [a] \cap [b] = \emptyset.
- The classes form a partition of A: a collection of nonempty, pairwise disjoint subsets whose union is A.
- Conversely, every partition of A comes from exactly one equivalence relation: a ~ b when a and b are in the same block.
A quick way to build an equivalence relation: for any function f on A, the rule a \sim b \iff f(a) = f(b) is always an equivalence relation, because equality is. Its classes are the sets of elements with the same output. “Same birth month,” “same remainder mod n” and “same digit sum” all have this form.
How to work with an equivalence relation
- Check that R is reflexive, symmetric and transitive. One failure means R is not an equivalence relation.
- Pick an element a not yet in any class and list [a], everything related to a.
- Repeat with an element outside every class found so far, until every element is in a class.
- Check the answer: the classes should not overlap, and their union should be all of A.
Equivalence relation examples
Example 1: A relation on a small set
Let A = {1, 2, 3, 4, 5} and R = {(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (1, 3), (3, 1), (2, 4), (4, 2), (2, 5), (5, 2), (4, 5), (5, 4)}. Show that R is an equivalence relation and find its classes.
(1, 1), (2, 2), (3, 3), (4, 4), (5, 5) \in R
Reflexive: every loop is present.
(1, 3), (3, 1);\ (2, 4), (4, 2);\ (2, 5), (5, 2);\ (4, 5), (5, 4)
Symmetric: each pair appears with its reverse.
(1, 3), (3, 1) \Rightarrow (1, 1) \in R
Transitive: check the chains among 1 and 3.
(2, 4), (4, 5) \Rightarrow (2, 5) \in R
Check a chain among 2, 4 and 5.
(4, 2), (2, 5) \Rightarrow (4, 5) \in R
Every chain among 2, 4 and 5 closes, since all pairs among them are in R.
[1] = \{1, 3\}List everything related to 1.
[2] = \{2, 4, 5\}2 is not in [1]; list everything related to 2.
\{1, 3\} \cup \{2, 4, 5\} = AEvery element is now in a class.
Answer: R is an equivalence relation with two classes, {1, 3} and {2, 4, 5}.
Example 2: Congruence mod 3
On the integers, let a \sim b mean a \equiv b \pmod{3}, that is, 3 divides a − b. Show that this is an equivalence relation and describe its classes.
a - a = 0 = 3 \cdot 0
Reflexive: 3 divides 0.
b - a = -(a - b) = 3(-k)
Symmetric: if a − b = 3k, then 3 divides b − a.
a - c = (a - b) + (b - c)
Transitive: add and subtract b.
a - c = 3k + 3j = 3(k + j)
Substitute a − b = 3k and b − c = 3j, then factor out 3.
[0] = \{\ldots, -3, 0, 3, 6, \ldots\}The multiples of 3: remainder 0.
[1] = \{\ldots, -2, 1, 4, 7, \ldots\}Remainder 1 (−2 = 3(−1) + 1).
[2] = \{\ldots, -1, 2, 5, 8, \ldots\}Remainder 2 (−1 = 3(−1) + 2).
Answer: there are exactly three classes, one for each possible remainder, as in the diagram. Different names can give the same class: [7] = [1], because 7 − 1 = 6 is a multiple of 3. These classes are the residue classes of modular arithmetic.
Example 3: Fractions as equivalence classes
On pairs of integers (a, b) with b ≠ 0, let (a, b) \sim (c, d) mean ad = bc. Prove that ~ is transitive, and describe the class of (1, 2).
ad = bc,\quad cf = de
Suppose (a, b) ~ (c, d) and (c, d) ~ (e, f).
adf = bcf
Multiply both sides of ad = bc by f.
adf = bde
Replace cf with de on the right.
d(af - be) = 0
Subtract bde from both sides and factor out d.
af = be
d ≠ 0, so divide both sides by d.
(a, b) \sim (e, f)
This is the definition of ~. Transitive: yes.
[(1, 2)] = \{(1, 2), (2, 4), (-3, -6), \ldots\}(a, b) ~ (1, 2) exactly when a · 2 = b · 1, so b = 2a with a ≠ 0.
Answer: ~ is transitive (reflexive and symmetric are quick to check: ab = ba). The class of (1, 2) holds every pair (a, 2a) with a ≠ 0, which is every way to write the fraction 1/2. In fact, a rational number is an equivalence class of pairs, which is why \frac{1}{2} = \frac{2}{4} (see equivalent fractions).
Example 4: From a partition to the relation
The partition {{1, 2}, {3}, {4, 5, 6}} of {1, 2, 3, 4, 5, 6} defines an equivalence relation. How many ordered pairs does it contain?
2^2 = 4
The block {1, 2}: every ordered pair of its elements, (1, 1), (1, 2), (2, 1), (2, 2).
1^2 = 1
The block {3}: only (3, 3).
3^2 = 9
The block {4, 5, 6}: 3 choices for each entry of the pair.
4 + 1 + 9 = 14
Add the blocks: no pair belongs to two blocks.
Answer: the relation has 14 ordered pairs. In general, a block of size k contributes k^2 pairs.
Example 5: Grouping ID numbers (word problem)
A company gives each employee a 3-digit ID from 000 to 999. Call two IDs equivalent if their digits have the same sum. Is this an equivalence relation? How many classes are there, and how many IDs are in the class of 005?
f(xyz) = x + y + z
Define the digit-sum function.
a \sim b \iff f(a) = f(b)
Two IDs are equivalent exactly when f gives the same output.
\text{equivalence relation}Relations of the form f(a) = f(b) are always reflexive, symmetric and transitive.
f \in \{0, 1, \ldots, 27\}The smallest sum is 0 (000) and the largest is 27 (999).
27 - 0 + 1 = 28
Each possible sum is reached, so there are 28 classes.
x + y + z = 5
The class of 005 holds the IDs with digit sum 5.
\binom{5 + 2}{2} = \binom{7}{2}Count with stars and bars; no digit can exceed 5, so the limit of 9 never matters (see combinations with repetition).
\binom{7}{2} = \frac{7 \cdot 6}{2} = 21Evaluate.
Answer: yes, it is an equivalence relation with 28 classes, and the class of 005 contains 21 IDs, such as 005, 014, 113 and 500.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Calling a relation an equivalence relation without checking transitivity | “Is a friend of” or \lvert a - b \rvert \le 1 called an equivalence relation | Check all three properties; these two fail transitivity. |
| Listing overlapping classes | Classes {1, 2} and {2, 3} | Classes are equal or disjoint. If 1 ~ 2 and 2 ~ 3, then 1, 2 and 3 share one class. |
| Leaving an element out of its own class | [2] = {4, 5} | Reflexivity puts a in [a]: [2] = {2, 4, 5}. |
| Treating two names as two classes | “[1] and [7] are different classes mod 3” | [1] = [7] because 7 ≡ 1 (mod 3). |
| Counting only one direction of each pair | Block {4, 5, 6} gives 3 pairs | Count ordered pairs, including loops: 3^2 = 9. |
| Allowing an empty block in a partition | {{1, 2}, ∅, {3}} | Blocks of a partition must be nonempty. |
Related methods
Being isomorphic is an equivalence relation on graphs; see graph isomorphism.
The quotient set
The set of all equivalence classes is the quotient set, written A/~. For congruence mod n it is \mathbb{Z}_n = \{[0], [1], \ldots, [n-1]\}, the set where modular arithmetic takes place.
Counting equivalence relations
Because equivalence relations match partitions one to one, counting one counts the other. The number of partitions of an n-element set is the Bell number B_n: 1, 1, 2, 5, 15, 52, … for n = 0, 1, 2, 3, 4, 5.
Other kinds of relations
If you replace symmetric with antisymmetric, you get a partial order such as ≤ or “divides,” the topic of the next lesson. In geometry, congruence and similarity of figures are equivalence relations (see congruent figures).
Practice problems
- Is R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)} on {1, 2, 3} an equivalence relation? If so, find its classes.
- Is R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1), (2, 3), (3, 2)} on {1, 2, 3} an equivalence relation?
- List the equivalence classes of congruence mod 4 on the integers, and give four elements of [3].
- Mod 4, is [7] = [−5]?
- The partition {{a, b}, {c, d, e}} defines an equivalence relation on {a, b, c, d, e}. How many ordered pairs does it contain?
- On the real numbers, let x ~ y mean that x − y is an integer. Show that ~ is an equivalence relation and describe [0.5].
- On the integers, let a ~ b mean a^2 = b^2. Find [−3] and [0].
- On {1, 2, …, 12}, let a ~ b mean that a and b leave the same remainder when divided by 5. List the classes.
- How many equivalence relations are there on {1, 2, 3}?
- Using the relation from Example 3, is (2, 3) ~ (−4, −6)?
Show answers
1.
(1, 1), (2, 2), (3, 3) \in R
Reflexive: yes.
(1, 2), (2, 1) \in R
Symmetric: the only non-loop pairs come together.
(1, 2), (2, 1) \Rightarrow (1, 1) \in R
Transitive: the chains close (the other chains use loops).
[1] = \{1, 2\},\ [3] = \{3\}List the classes.
Answer: yes; the classes are {1, 2} and {3}
2.
(1, 2), (2, 3) \in R
Look for a chain.
(1, 3) \notin R
The shortcut is missing.
Answer: no; R is not transitive
3.
[0], [1], [2], [3]
One class for each remainder 0, 1, 2, 3.
[3] = \{\ldots, -5, -1, 3, 7, 11, \ldots\}Start at 3 and add or subtract 4.
Answer: four classes; for example −5, −1, 3 and 7 are in [3]
4.
7 - (-5) = 12
Subtract the representatives.
12 = 4 \cdot 3
12 is a multiple of 4, so 7 ≡ −5 (mod 4).
Answer: yes, [7] = [−5] (both equal [3])
5.
2^2 + 3^2 = 4 + 9
A block of size k gives k^2 ordered pairs.
4 + 9 = 13
Add.
Answer: 13
6.
x - x = 0 \in \mathbb{Z}Reflexive.
y - x = -(x - y) \in \mathbb{Z}Symmetric: the negative of an integer is an integer.
x - z = (x - y) + (y - z) \in \mathbb{Z}Transitive: a sum of integers is an integer.
[0.5] = \{0.5 + k : k \in \mathbb{Z}\}Everything that differs from 0.5 by an integer.
Answer: an equivalence relation; [0.5] = {…, −1.5, −0.5, 0.5, 1.5, …}
7.
a^2 = (-3)^2 = 9
[−3] holds every a with a² = 9.
a = \pm 3
Take square roots.
a^2 = 0 \Rightarrow a = 0
[0] holds only 0.
Answer: [−3] = {−3, 3} and [0] = {0}
8.
\{5, 10\}Remainder 0.
\{1, 6, 11\},\ \{2, 7, 12\}Remainders 1 and 2.
\{3, 8\},\ \{4, 9\}Remainders 3 and 4.
2 + 3 + 3 + 2 + 2 = 12
Check: every number from 1 to 12 is in exactly one class.
Answer: {5, 10}, {1, 6, 11}, {2, 7, 12}, {3, 8}, {4, 9}
9.
\{\{1, 2, 3\}\}One block: 1 partition.
\{\{1\}, \{2, 3\}\},\ \{\{2\}, \{1, 3\}\},\ \{\{3\}, \{1, 2\}\}A single plus a pair: 3 partitions.
\{\{1\}, \{2\}, \{3\}\}Three singles: 1 partition.
1 + 3 + 1 = 5
Each partition gives one equivalence relation.
Answer: 5 (the Bell number B₃)
10.
2 \cdot (-6) = -12
Compute ad with (a, b) = (2, 3) and (c, d) = (−4, −6).
3 \cdot (-4) = -12
Compute bc.
Answer: yes, ad = bc, so (2, 3) ~ (−4, −6); both name the fraction 2/3
Equivalence relations FAQ
What are the three properties of an equivalence relation?
Reflexive (a ~ a), symmetric (a ~ b implies b ~ a) and transitive (a ~ b and b ~ c imply a ~ c).
What is an equivalence class?
The equivalence class [a] is the set of all elements related to a. Two classes are either the same set or have no elements in common.
How are equivalence relations and partitions related?
Each equivalence relation splits its set into classes that form a partition, and each partition defines an equivalence relation in which two elements are related when they share a block. The two ideas carry the same information.
How many equivalence classes does congruence mod n have?
Exactly n, one for each remainder 0, 1, …, n − 1. They are often written [0], [1], …, [n − 1].
Summary
- An equivalence relation is reflexive, symmetric and transitive.
- The equivalence class of a is [a] = {x : x ~ a}, and a is always in [a].
- Classes are equal or disjoint, so they partition the set; every partition comes from exactly one equivalence relation.
- Any rule of the form “f(a) = f(b)” is an equivalence relation.
- Congruence mod n has n classes, the residue classes [0], …, [n − 1].
Previous lesson: Properties of Relations
Next lesson: Partial Orders
Back to the Discrete Math Index