Congruence modulo n

We focus in this paragraph on an important relation in ℤ, the congruence relation modulo a positive integer n.

Definition 4.1.1. Let n be a given natural number. The Congruence modulo relation is defined thus:

ab (modulo n)  ⇔   n| ab   ⇔   ab = nk   for some k ∈ ℤ

To say that n divides ab is to say that ab = nk for some integer k.

For example, we can write 38 ≡ 14   (mod 12), because 38 − 14 = 24, which is a multiple of 12.

It easy to verify that this is an equivalence relation. So we may consider the equivalence classes, called congruence classes modulo n or residue classes modulo n, defined by this relation in a way to “lump together” into a single set integers which are congruent modulo r and then treat that set as a single mathematical object.

Definition 4.1.2. Given an integer a, we shall denote by [a]n, or, if no confusion may possibly arise, by [a], or by ā, the congruence class of a modulo n, is

[a]n = {b ∈ ℤ | bn a} = {a + hn | h ∈ ℤ} = {..., a −2n, an, a, a + n, a + 2n, ...}.

i.e.: "congruent integers to a modulo n" are those that may written in the form a + nh for a particular h ∈ ℤ. Indeed, if bn a thus ba is a multiple of n, so ba = nh for a particular h ∈ ℤ, i.e.: b = a + nh. This is the reason why equivalence classes modulo n are also called residue classes modulo n.

Theorem 4.1.3. ac (mod n) if and only if [a] = [c].

Proof. We must prove two things to meet the condition "if and only if"

  1. If ac (mod n), then [a] = [c].

  2. If [a] = [c], the [a] = [c].

We won't use the definition of congruence. Instead we use the fact that congruence is an equivalence relation hence reflexive, symmetric and transitive.

Assume first that ac (mod n). To prove that [a] = [c], we first show that [a] ⊆ [c]. To do this, let b ∈ [a]. Then by definition ba (mod n). Since ac (mod n), we have bc (mod n) by transitivity. Therefore, b ∈ [c] and [a] ⊆ [c]. Reversing the roles of a and c in this argument and using symmetry that is ca (mod n) is shown that [c] ⊆ [a]. Therefore, [a] = [c].

Conversely, assume that [a] = [c]. Since aa (mod n) by reflexivity, we have a ∈ [a] and, hence, a ∈ [c]. By definition of [c], we see that ac (mod n).□

Proposition 4.1.4. ab (mod n) if and only if a and b leave the same remainder when divided by n. Conversely if a and b leave the same remainder when divided by n, then a ≡ b mod n.

Proof. By definition of congruence a = b + hn for some integer h. By the division algorithm, b = nq + r where 0 ≤ r < n. Then a = b + hn = (nq + r) + hn = n(q + h) + r; therefore, by the division algorithm, a leaves the same remainder r when divided by n.
Conversely, suppose both a and b leave the same remainder r when divided by n. Then, again by the division algorithm, a = nq + r and b = nq' + r, where 0 ≤ r < n. Then ab = (nq + r) − (nq' + r) = n(qq'), so ab (mod n). □

For example 6 and 8 are congruent mod 2 because they have the same remainder r = 2 on division by 2.

If A and B are two sets, there are usually three possibilities: Either A and B are disjoint, or A = B, or AB is nonempty but AB. With congruence classes, however, there are only two possibilities:

Proposition 4.1.5. Two congruence classes modulo n are either disjoint or identical.

Proof. If [a] and [c] are disjoint, we are done. Suppose they are not, so [a] ∩ [c] is nonempty. Then there is an integer b with b ∈ [a] and b ∈ [c]. By definition of congruence class, ba (mod n) and bc (mod n). Therefore, by symmetry and transitivity, ac (mod n). Hence [a] = [c], by theorem 4.2.1, so if they are not disjoint they are identical.□

Corollary 4.1.6. Let n > 1 be an integer and consider congruence modulo n

  1. If a is any integer and r is the remainder when a is divided by n, then [a] = [r].

  2. There are exactly n distinct congruence classes, namely [0], [1], [n − 1].

Proof. Let a ∈ℤ by the division algorithm dividing by n, a = nq + r, with 0 ≤ r < n. Thus ar = qn so that ar (mod n). By theorem 4.2.1 [a] = [r]. The possible remainders are 0, 1, 2, ..., n − 1, that is there will be exactly n equivalence classes.

To complete the proof, we must show that these n classes are all distinct. To do this, we first show that no two of 0, 1, 2, ... , n − 1 are congruent modulo n. Suppose that s and t are distinct integers in the list 0, 1 , 2, ..., n − 1. Then one is larger than the other, say r, so that 0 ≤ s < t < n. Consequently, ts is a positive integer that is less than n. Hence, n does not divide ts, which means that ts. Thus, no two of 0, 1, 2, ... , n − 1 are congruent modulo n. Therefore, by Theorem 4.2.1, the classes [0], [1], [2], ... , [n − 1] are all distinct.□

Corollary 4.1.7. Every integer is congruent (mod n) to exactly one of the numbers in the list:

0, 1, 2, ...., (n − 1).

this number is indicated as

a mod n

Proof. As we may always divide an integer a by n (see proposition 2.3), if we denote by r the remainder of the division every integer a is congruent modulo n to an integer r such that 0 ≤ r < n, in fact a = r + nhar = nh.□

We indicate the set of all congruence classes of integers modulo n with ℤn or ℤ/n

n = {[a]n: 0 ≤ an − 1} = {[0]n, [1]n, [2]n, ..., [n − 1]n}

Be careful to note that we are considering here a set of sets: Each element of the finite set ℤn is in fact an infinite set of the form [k].

These n residue classes then partition the integers, meaning that each integer belongs to exactly one of these classes, and if distinct classes intersect, they are in fact equal. Alternatively, this means that

ℤ = [0] ∪ [1] ∪ [2] ∪ ··· ∪ [n − 1],

and the sets in this union are disjoint from one another pairwise. In particular, we have that

ℤ = [0]4 ∪ [1]4 ∪ [2]4 ∪ [3]4 =
{... , −4, 0, 4, 8, ...} ∪ {... , −3, 1, 5, 9, ...} ∪ {... , −2, 2, 6, 10, ...} ∪ {... , −1, 3, 7, 11, ...}.

If we consider ℤ9, every element of [k] falls into one of the first nine groups, from [0]9 to [8]9 and no number falls into more than one group, because as we have seen

an b  ⇐⇒  [a]n = [b]n

If n = 2, we only two possible remainder, 0 and 1 and consequently two classes, [0] e [1]: the first contains all integers {2k | k ∈ ℤ} the second all integers 2k + 1 | k ∈ ℤ }, i.e. the partition induced on ℤ is that of even and odd numbers.

For example the class [2]9 is made by integers of the form 2 + 9h for h ∈ ℤ equal to 0, 1, 2, 3, etc. we have thus 2 = 2 + 9 · 0, 11 = 2 + 9 · 1, 20 = 2 + 9 · 2, 29 = 2 + 9 · 3, and so forth, for negative h we obtain −7 = 2 + 9 · (−1), −16 = 2 + 9 · (−2), −25 = 2 + 9 · (−3), and so on. We have thus:

[2]9 = {... , −25, −16, −7, 2, 11, 20, 29, 38, ...};

[0]9 = {..., 0, 9, 18, 27, 36, ...} = {x ∈ ℤ | x ≡ 0 (mod 9)}
[1]9 = {..., 1, 10, 19, 28, 37, ...} = {x ∈ ℤ | x ≡ 1 (mod 9)}
[2]9 = {..., 2, 11, 20, 29, 38, ...} = {x ∈ ℤ | x ≡ 2 (mod 9)}
[3]9 = {..., 3, 12, 21, 30, 39, ...} = {x ∈ ℤ | x ≡ 3 (mod 9)}
[4]9 = {..., 4, 13, 22, 31, 40, ...} = {x ∈ ℤ | x ≡ 4 (mod 9)}
[5]9 = {..., 5, 14, 23, 32, 41, ...} = {x ∈ ℤ | x ≡ 5 (mod 9)}
[6]9 = {..., 6, 15, 24, 33, 42, ...} = {x ∈ ℤ | x ≡ 6 (mod 9)}
[7]9 = {..., 7, 16, 25, 34, 43, ...} = {x ∈ ℤ | x ≡ 7 (mod 9)}
[8]9 = {..., 8, 17, 26, 35, 44, ...} = {x ∈ ℤ | x ≡ 8 (mod 9)}
..
[20]9 = {..., 20, 29, 38, 46, 55, ... } = {x ∈ ℤ | x ≡ 20 (mod 9)
..

Each element of ℤn can be denoted in many different ways. For example, we know that

2 ≡ 5 (mod 3)    2 ≡ −1 (mod 3)    2 ≡ 14 (mod 3)

Therefore, by Theorem 4.2.1, [2] = [5] = [−1] = [14] in ℤ3.

For every integer a ∈ ℤ there is a congruence class [a] ∈ ℤn. Even though each element of ℤn (that is, each congruence class) has infinitely many different labels, there are only finitely many distinct classes by Corollary 4.0.6, which says in effect that

The set ℤn has exactly n elements.

The set ℤ3 consists of the three elements [0], [1], [2]. The elements [3], [4], [5], ... are just repetitions of [0], [1], [2], ....

It is easily checked that the map

ℤ/ℤn   →   ℤn

[a]   ↦   a mod n

which assigns to each residue class [a] the least non-negative residue of a modulo n, is a bijection.

Another definition of equivalence class by virtue of Corollary 4.0.4 is the following

Definition 4.1.8. An equivalence class modulo n is the set of all integers having the same remainder upon division by the modulo n.

Properties of ≡

The symbol used to denote congruence looks very much like an equal sign. The symbol ≡ was introduced by Gauss in the Disquisitiones, by virtue of the analogy with the equality relation. This is no accident since the relation of congruence has many of the same properties as the relation of equality. For example, we know that equality is

Reflexive: a = a for every integer a;

Symmetric: if a = b, then b = a;

Transitive: if a = b and b = c, then a = c.

We now see that congruence modulo n is also reflexive, symmetric, and transitive that is: an equivalence relation.

Proposition 4.1.9. For any integer n > 0. The congruent modulo n relation (≡n) on ℤ is an equivalence relation.

Proof. To show that congruent modulo n is an equivalent relation, we must prove that ≡n is reflexive, symmetric and transitive.

Reflexive. If a ∈ ℤ, we need to show that aa. We must show that there is a h ∈ ℤ such that aa = hn. This is simply k = 0.

Symmetric. Let a, b ∈ ℤ, assume that ab. We have to show that ba. If there exists an integer h ∈ ℤ so that ab = hn then ba = −hn holds true because (−h) is also an integer, so ≡ is symmetric.

Transitive. Let a, b ∈ ℤ, assume that ab and bc, we have to show that ac. We know from the definition of ≡ that there are integers h1 and h2 such that

ab = h1n   and   bc = h2n

Adding these two equations gives ac = (h1 + h2)n

Since h1 + h2 ∈ ℤ; ≡n is transitive.□

Notice that an integer is congruent to every other integer modulo 1, that is to say congruence modulo 1 is a trivial equivalence relation; for this reason in what follows we shall in general assume n > 1.

Congruence gets along well with addition and multiplication.

Proposition 4.1.10. Let a, b, c, d ∈ ℤ. For any integer n > 0 the following properties hold

ab (mod n),   cd (mod n)

 ⇓

Proof.

ab (mod n) ⇔ ab = hn

cd (mod n) ⇔ cd = kn

by adding up the two relations: a + c − (b + d) = (h + k)n i.e. a + cb + d (mod n). Analogously acbd = acad + adbd = a(cd) + (ab) = akn + hnd = (ak + hd)n thus acbd (mod n). □

Example 4.1.11. What time will be 314 hours from now?

Solution. 314 divided by 24 yields 13 and a 2 as remainder 314 = 13 ⋅ 24 + 2. So 13 days and 2 hours. So it is enough to add 2 hours to the current time. We have 314 − 2 = 13 ⋅ 24, so that we can write 314 ≡ 2 mod 24.

Example 4.1.12. If the time is 15.00 hours and 20 hours pass by, what time will be? if 83 hours elapse?

Solution. 15 + 20 ≡ 11 mod 24, then it is 11 hours. 15 + 83 ≡ 2 mod 24. It is 2 o'clock in the morning.

« Fibonacci Sequence Index Modular Arithmetic: Operations on ℤn »