IUM lectures on Numbers

3.6. Modular arithmetic

We will now give a short introduction to congruences of integers. Here again the notion of equivalence relation is of vital importance. Note that the notion of division extends easily to integers: if x,y are integers then we say x\mid y if there exists an integer z with y=xz.

Definition 59

Let a,b\in\mathbb{Z} and n\in\mathbb{N},n>0. We say that a is congruent to b modulo n if n\mid(a-b).\ Notation: a\equiv b \mod n.

Example 60

22\equiv 4 \mod 9, since 22-4=18, and 9\mid18.

Proposition 61

Let a,b,c\in\mathbb{Z} and n\in\mathbb{N},n>0.

  1. a\equiv a \mod n, for all a\in \mathbb{Z}.

  2. If a\equiv b\mod n, then b\equiv a\mod n.

  3. If a\equiv b\mod n and b\equiv c\mod n, then a\equiv c\mod n.

Proof

  1. a-a=0, and n\mid0 for all n, which yields the result.

  2. b-a=-(a-b). Hence since n\mid(a-b), then n\mid-(a-b)=b-a.

  3. If n\mid(a-b) and n\mid(b-c), then n\mid(a-b)+(b-c)=a-c, which by definition means that a\equiv c\mod n.

The last proposition exactly means that congruence modulo n is an equivalence relation on \Z. We denote the equivalence class of a by [a]_n:=\{b\in\mathbb{Z}\,:\,b\equiv a\mod n\} and we call it a congruence class.

For example, the congruence class [7]_{10} is all the integers congruent to 7 mod 10, so it's \{\ldots,-23,-13,-3,7,17,27,37,\ldots\}.

Here's a useful result.

Proposition 62

Let a,b\in\mathbb{Z} and n a positive integer. Then a\equiv b\mod n if and only if a and b have the same remainder after division by n.

Proof

Let a=qn+r and b=q'n+r' be the Euclidean division of a and b by n with 0\leq r,r'< n. Then we get immediately a-b=(q-q')n+(r-r').

Assume that a\equiv b\mod n. By definition n\mid(q-q')n+(r-r'), therefore n\mid(r-r'). But 0\leq r,r'< n, therefore -n<r-r'<n and the only multiple of n in this range is 0. Hence r=r' and a and b have the same remainder after division by n.

Conversely if r=r', then a-b=(q-q')n and n\mid a-b which by definition means exactly a\equiv b\mod n.

We want now to find out how many congruence classes exist modulo n. Let us look at it when n=1,2,3 to try to understand what is going on.

Note that 1 divides every integer. Hence if a and b are any integers then a\equiv b\mod 1. Hence there is only one congruence class modulo~1. In other words [0]_1=[1]_1=[2]_1=\dots=\mathbb{Z}.

If n=2, for any two integers a,b such that a\equiv b\mod 2, we have that a=2k+b, which means that [a]_n=\{\dots,a-4,a-2,a,a+2,a+4\dots\}, hence a and b have necessarily the same parity (they are either both odd or both even). There are therefore two classes of integers modulo 2: the even numbers [0]_2=\{\ldots,-4,-2,0,2,4,\ldots\} and the odd numbers [1]_2=\{\ldots,-5,-3,-1,1,3,5,\ldots\}. We have \cdots=[-2]_2=[0]_2=[2]_2=[4]_2\dots\textrm{ and } \cdots=[-1]_2=[1]_2=[3]_2=[5]_2=\dots so [a]=[a'] if and only if the integers a and a' are congruent mod n.

If n=3, we have a=3k+b for some integers k and this reduces to the three cases 3k,3k+1,3k+2. Therefore we get three congruence classes modulo 3, i.e. [0]_3, [1]_3 and [2]_3.

We can recognize a pattern here. In fact we can show the following result.

Proposition 63

There are exactly n congruence classes modulo n.

Proof

We are first going to show that the equivalence classes [0]_n, [1]_n, ..., [n-1]_n are all different. Let a,b\in\mathbb{Z}, 0\leq a,b\leq n-1. Assume that [a]_n=[b]_n. Then n\mid a-b by definition. But this is impossible since -n<a-b<n and the only multiple of n in this range is 0, meaning a=b.

Now we prove that these are the only possible classes. Again given any integer a, consider the Euclidean division of a by n given by a=qn+r, 0\leq r <n. Obviously n\mid a-r and consequently [a]_n=[r]_n. Therefore since 0\leq r <n any integer a is congruent modulo n to exactly one of the integers 0,1,\dots n-1, which by our previous considerations are not congruent to each other.

The last proposition means that every integer is congruent to exactly one of the numbers 0,1,\ldots,n-1, so there are exactly n equivalence classes. We write \mathbb{Z}/n\mathbb{Z} =: \{ [0]_n, [1]_n, ..., [n-1]_n\} for the set of equivalence classes modulo n. These are infinitely many new worlds of numbers, where, like the integers, we can do addition, subtraction and multiplication (but still not division: you'll have to wait for the next chapter to see that).

From now on n will be fixed, and we'll just write [a] for [a]_n. We now want to define operations on this new set. In order to do this we need the following

Lemma 64 (pre-addition and pre-multiplication for integers mod n)

Suppose that a, a', b, b'\in \mathbb{Z} are integers such that a\equiv a'\mod n and b\equiv b'\mod n. Then

  1. a+b\equiv a'+b'\mod n;

  2. ab\equiv a'b'\mod n.

Proof

Exercise! See problem sheet 2.

This lemma means that if we choose integers a and b and calculate a+b or ab, and then you choose two other representatives a'\in [a] and b'\in [b] and calculate a'+b' or a'b' we get the same element of \mathbb{Z}/n\mathbb{Z}. This is the same idea we used to define the addition and multiplication on the integers: we needed our operation to be independent of the elements of the class. We can therefore define the following well-defined addition and multiplication on \mathbb{Z}/n\mathbb{Z}: \begin{align*} &+:\mathbb{Z}/n\mathbb{Z}\times\mathbb{Z}/n\mathbb{Z}\rightarrow\mathbb{Z}/n\mathbb{Z}, &&([a]_n,[b]_n)\mapsto [a+b]_n\\ &\times:\mathbb{Z}/n\mathbb{Z}\times\mathbb{Z}/n\mathbb{Z}\rightarrow\mathbb{Z}/n\mathbb{Z}, &&([a]_n,[b]_n)\mapsto [ab]_n. \end{align*} We can now ask all the usual questions: whether (x+y)+z=x+(y+z) and x(y+z)=xy+xz and so on for this new world of numbers; the answer is that again all these things are true, and not hard to prove, but let us leave this for now because I want to talk about division.