Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Equivalence relations

A function pairs each input with exactly one output, but "divides", "has the same birthday as" and "leaves the same remainder on division by 5 as" pair things far more freely, and they need a language of their own.

The previous lesson closed on the observation that many useful relations are not functions at all. This lesson defines relations, picks out the ones that say two things are "the same for present purposes", and shows that each of them cuts its set into pieces, which is how modular arithmetic and the fractions are built. It assumes sets, the Cartesian product A×B of all ordered pairs (a,b) with a∈A and b∈B, the quantifiers, and divisibility: a∣b when b=ak for some integer k.

Relations as sets of pairs

A relation on a set A is a subset of A×A. When the pair (a,b) belongs to it we say a is related to b and write a∼b. A relation is exactly the set of pairs it holds between, so two relations are equal when they contain the same pairs, however differently they were described.

Take A={1,2,3,4} and let a∼b mean a∣b. As a set of pairs this is

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

eight of the sixteen pairs in A×A. Order matters, since (2,4) is in the set and (4,2) is not. A relation on A can be any subset of A×A, and a set of n elements has n2 ordered pairs, so it carries 2n2 relations: for A={1,2,3}, 29=512.

A function from A to B fits the same mould. Its graph, {(a,f(a)):a∈A}, is a set of pairs in which every a∈A appears as a first coordinate exactly once, so functions are the relations with that property. On ℝ, x∼y when y=x2 is a function. The relation x∼y when x=y2 is not, and it fails both ways: 4 is related to 2 and to -2, and -1 is related to nothing. Divisibility above is not one either, since 1 is related to four elements.

Reflexive, symmetric and transitive

Three properties of a relation ∼ on A matter here, each a universal statement:

reflexive:∀a∈A(a∼a)
symmetric:∀a,b∈A(a∼b⇒b∼a)
transitive:∀a,b,c∈A((a∼b∧b∼c)⇒a∼c)

A relation with all three is an equivalence relation. Equality is the model, and "has the same birthday as" is another: everyone shares a birthday with themselves, sharing is mutual, and two people who share with a third share with each other.

Being universal, each property is broken by a single counterexample, and three relations on ℝ show that any two can hold without the third. The order x≤y is reflexive and transitive but not symmetric, since 1≤2 and not 2≤1. "Close to", meaning |x-y|≤1, is reflexive and symmetric but not transitive: 0 is close to 1 and 1 to 2, but 0 is not close to 2. And x∼y when xy>0 is symmetric and transitive (if xy>0 and yz>0, then x and z both have the sign of y) but not reflexive, since 0⋅0=0.

That last example refutes a tempting proof: "if a∼b then b∼a, so a∼a by transitivity". Each step is valid, but the argument needs some b with a∼b to start from, and for a=0 there is none. Reflexivity asks about every a, including those related to nothing.

Proving a relation is an equivalence

Such a proof is three short proofs, one per property, each a universal conditional: take arbitrary elements, assume the hypothesis, and reach the conclusion from the definition of the relation.

Example. On ℝ, let x∼y when x-y∈ℤ. Prove that ∼ is an equivalence relation.

Reflexive: let x∈ℝ. Then x-x=0, an integer, so x∼x. Symmetric: let x∼y, so x-y=k for some integer k. Then y-x=-k, also an integer, so y∼x. Transitive: let x∼y and y∼z, so x-y=k and y-z=m for integers k and m. Adding, x-z=k+m, an integer, so x∼z. All three hold, so ∼ is an equivalence relation.

Here 2.7∼0.7∼-3.3: two reals are related when they have the same fractional part. The three steps used that the integers contain 0 and are closed under negation and addition.

Now you. On the nonzero reals, let x∼y when xy∈ℚ. Prove that ∼ is an equivalence relation.

Answer

Reflexive: for x≠0, xx=1, which is rational, so x∼x. Symmetric: let xy=q with q rational. Since x≠0, q≠0, so yx=1q is rational and y∼x. Transitive: let xy=q and yz=r with q and r rational. Then xz=xy⋅yz=qr, which is rational, so x∼z. Hence ∼ is an equivalence relation.

Equivalence classes partition the set

Given an equivalence relation ∼ on A and a∈A, the equivalence class of a is everything related to it:

[a]={x∈A:x∼a}

Under the fractional part relation above, [0.7]={…,-1.3,-0.3,0.7,1.7,…}, and [0.7]=[2.7]: one class, two names. Any element of a class is a representative of it. A partition of A is a collection of nonempty subsets of A, its blocks, such that every element of A lies in exactly one block. Birthdays cut a room into at most 366 blocks, and that always happens.

Theorem. If ∼ is an equivalence relation on A, its equivalence classes form a partition of A.

First, every element is in its own class: a∼a by reflexivity, so a∈[a]. Hence every class is nonempty and every element lies in at least one class.

Second, if a∼b then [a]=[b], by double inclusion. Let x∈[a], so x∼a; with a∼b, transitivity gives x∼b, so x∈[b]. Conversely let x∈[b], so x∼b; symmetry turns a∼b into b∼a, and transitivity gives x∼a, so x∈[a].

Third, two classes are equal or disjoint. Suppose [a] and [b] share an element c, so c∼a and c∼b. Symmetry gives a∼c, transitivity gives a∼b, and the second step gives [a]=[b]. So no element lies in two different classes, and each lies in exactly one.

The converse holds too. Given a partition of A, let a∼b when a and b lie in the same block. This is reflexive because every element lies in some block, and symmetric because "the same block" ignores order. For transitivity, let a and b share a block S, and b and c a block T. Then b lies in both, and since it lies in exactly one block, S=T, so a and c share a block. The classes of this relation are the blocks, so equivalence relations on A and partitions of A are one idea described two ways. On {1,2,3} there are five partitions (all together, all apart, or a pair beside a singleton, in three ways), so only five of the 512 relations on that set are equivalence relations.

Congruence modulo n

Fix a positive integer n. Integers a and b are congruent modulo n, written a≡b(modn), when n∣a-b. So 17≡2(mod5) and -7≡2(mod3). The notation is Carl Friedrich Gauss's, from his Disquisitiones Arithmeticae of 1801, and a clock uses it daily: five hours after nine o'clock is two o'clock because 14≡2(mod12).

Example. Prove that congruence modulo n is an equivalence relation on ℤ.

Reflexive: for a∈ℤ, a-a=0=n⋅0, so a≡a(modn). Symmetric: let a≡b(modn), so a-b=nk for some integer k. Then b-a=n(-k), so b≡a(modn). Transitive: let a-b=nk and b-c=nm for integers k and m. Adding, a-c=n(k+m), so a≡c(modn). Congruence modulo n is therefore an equivalence relation.

Its classes, the congruence classes, number exactly n. Division with remainder writes every integer uniquely as a=qn+r with 0≤r<n, and then a-r=qn, so a∈[r]: every integer lies in one of [0],[1],…,[n-1]. These are different, because if 0≤r<s<n then s-r lies strictly between 0 and n, and no multiple of n does. For n=3:

[0]={…,-3,0,3,6,…}[1]={…,-2,1,4,7,…}[2]={…,-1,2,5,8,…}

So a≡b(modn) says exactly that a and b leave the same remainder on division by n.

Now you. On ℤ, let a∼b when 3∣a+2b. Prove that ∼ is an equivalence relation.

Answer

Reflexive: a+2a=3a, so a∼a. Symmetric: let a+2b=3k. Then b+2a=3(a+b)-(a+2b)=3(a+b-k), so b∼a. Transitive: let a+2b=3k and b+2c=3m. Then a+2c=(a+2b)+(b+2c)-3b=3(k+m-b), so a∼c. In fact a+2b=(a-b)+3b, so this is congruence modulo 3 in disguise, with three classes.

The fractions as classes of pairs

A fraction is written as a pair of integers, but different pairs name the same number: 12, 24 and -3-6 are one rational number written three ways. An equivalence relation makes this precise, and builds ℚ from ℤ without assuming the division it is meant to create.

Let P={(a,b)∈ℤ×ℤ:b≠0}, and for pairs in P let (a,b)∼(c,d) when ad=bc, the cross multiplication test stated with multiplication alone. It is reflexive, since ab=ba, and symmetric, since ad=bc is the same equation as cb=da. Transitivity is the real work.

Claim. If (a,b)∼(c,d) and (c,d)∼(e,f), then (a,b)∼(e,f).

We are given ad=bc and cf=de, and must show af=be. Multiplying the first equation by f gives adf=bcf, and by the second bcf=bde. Hence adf=bde, that is, d(af-be)=0. The pair (c,d) lies in P, so d≠0, and a product of integers is zero only when a factor is; so af=be.

The condition d≠0 is not a formality. Allow (0,0) and it is related to everything, since a⋅0=b⋅0. Then (1,2)∼(0,0) and (0,0)∼(3,5), but (1,2) is not related to (3,5), because 1⋅5=5 and 2⋅3=6. Transitivity would fail.

A rational number is now defined to be a class [(a,b)], written ab, and ℚ is the set of these classes. So 12 is the set {(1,2),(2,4),(-3,-6),…}, and the integer n reappears as the class of (n,1).

Well defined operations

Arithmetic on classes is defined through representatives, and that creates an obligation. A rule that picks a representative of a class and computes with it defines something only if every representative gives the same answer. Such a rule is well defined, and until that is proved it is not yet a function.

Here is one that fails. "Send [(a,b)] to a" looks like a function from ℚ to ℤ. But [(1,2)]=[(2,4)], and the rule sends this one class to 1 through one name and to 2 through the other. A school favourite fails the same way: "add the tops and add the bottoms" gives 12⊕13=25, yet with 24 for 12 it gives 37, and 25≠37 because 2⋅7=14 and 5⋅3=15.

Example. Prove that addition of rationals, [(a,b)]+[(c,d)]=[(ad+bc,bd)], is well defined.

First, bd≠0 because b≠0 and d≠0, so the result is a class of pairs in P. Now let (a,b)∼(a′,b′) and (c,d)∼(c′,d′), that is, ab′=ba′ and cd′=dc′. We must show (ad+bc,bd)∼(a′d′+b′c′,b′d′), that is, (ad+bc)b′d′=bd(a′d′+b′c′). Expanding and substituting,

(ad+bc)b′d′=(ab′)dd′+(cd′)bb′=(ba′)dd′+(dc′)bb′=bd(a′d′+b′c′)

So the sum depends only on the classes, and addition of rationals is well defined.

Congruence classes behave as well. Define [a]+[b]=[a+b] modulo n. If a≡a′(modn) and b≡b′(modn), then (a+b)-(a′+b′)=(a-a′)+(b-b′) is a sum of multiples of n, so a+b≡a′+b′(modn). Clock arithmetic is arithmetic on the twelve classes modulo 12, whether nine o'clock is represented by 9, 21 or -3.

Now you. Prove that multiplication of congruence classes modulo n, [a][b]=[ab], is well defined.

Answer

Let a-a′=nk and b-b′=nm for integers k and m. Then

ab-a′b′=a(b-b′)+b′(a-a′)=n(am+b′k)

so ab≡a′b′(modn), and the product class does not depend on the representatives. For example, 10≡1(mod9) gives 10k≡1(mod9) for every k, which is why a number and the sum of its digits leave the same remainder on division by 9.

Equivalence relations group things: they say when two objects are the same for present purposes, and cut a set into classes that become objects in their own right. The other great kind of relation ranks things instead. The order ≤ on the numbers, ⊆ on sets and divisibility on the positive integers are reflexive and transitive but far from symmetric, and the next lesson takes up these orders.