Home page for accesible maths 6 Equivalence relations and their applications

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

6.3 Combining congruence classes

In the previous section we saw that ‘‘congruence modulo 55’’ is an example of an equivalence relation on the set \mathbb{Z}; there are 55 congruence classes, 0^\widehat{0}, 1^\widehat{1}, 2^\widehat{2}, 3^\widehat{3} and 4^\widehat{4}, which partition \mathbb{Z}, meaning that every integer lies in exactly one of these classes. (Of course, there is nothing special about the natural number 55 here.) In this section we shall see that it is possible to give the collection of these classes an arithmetic, which in many ways is similar to the ordinary arithmetic of the integers themselves, but has the advantage of being much simpler; using it we shall be able to answer some apparently difficult questions very easily.

We start with a piece of notation.

Notation 6.3.1

Given mm\in\mathbb{N}, we write m\mathbb{Z}_{m} for the set of congruence classes modulo mm.

Thus m={0^,1^,,m-1^}\mathbb{Z}_{m}=\{\widehat{0},\widehat{1},\dots,\widehat{m-1}\}. Our goal is to decide how to equip the set m\mathbb{Z}_{m} with an addition and a multiplication.

We begin with addition, and for definiteness work in 5\mathbb{Z}_{5}; this means that we need, for example, to define the sum of 1^\widehat{1} and 2^\widehat{2}. Since 1+2=31+2=3, the obvious thing to do is to set this to be 3^\widehat{3}; but we have to be rather careful here, for the following reason. What we seem to be doing is taking two representative elements of the classes 1^\widehat{1} and 2^\widehat{2}, adding the elements and then taking the class containing the sum. However, the integer 11 is only one of many representatives of the class 1^\widehat{1}; likewise with the representative 22 of the class 2^\widehat{2}. If we had chosen other representatives, is it conceivable that we might have ended up with a different class for the sum? For example, we could instead have chosen representatives 1111 of 1^\widehat{1} and 77 of 2^\widehat{2}; then we would have calculated 11+7=1811+7=18 and obtained the class 18^\widehat{18} as the sum. Since 18^=3^\widehat{18}=\widehat{3}, in this case the answer is in fact the same; but we need to be sure that it will always be the same, no matter which representatives are chosen.

To make the point that this is not obvious, let us first consider a situation where things do not work properly. Continue to work in 5\mathbb{Z}_{5}, but instead of addition let us attempt to define taking powers; given a^,b^5\widehat{a},\widehat{b}\in\mathbb{Z}_{5}, can we define a^b^\widehat{a}\,^{\widehat{b}} as the class containing aba^{b}? Let a=2a=2 and b=1b=1. If we take the representatives 2a^2\in\widehat{a} and 1b^1\in\widehat{b}, then we have 21^=2^\widehat{2^{1}}=\widehat{2}. However, if instead we had taken the representative 6b^6\in\widehat{b} (and still 2a^2\in\widehat{a}), then we would have got 26^=64^=4^\widehat{2^{6}}=\widehat{64}=\widehat{4}. Now 2^4^\widehat{2}\neq\widehat{4}; so taking different representatives changes the final class, and we cannot define a^b^\widehat{a}\,^{\widehat{b}} in this way.

So there genuinely is something to be shown if our attempt to define addition is to work. Of course, we do not want to have to do lots of checks like that above (we would in fact need to do infinitely many!). Instead we require a general result, which generalizes Lemma 5.1.7.

Lemma 6.3.2

Suppose that acmodma\equiv c\bmod m and bdmodmb\equiv d\bmod m, where a,b,c,da,b,c,d\in\mathbb{Z} and mm\in\mathbb{N}. Then a+bc+dmodma+b\equiv c+d\bmod m, abcdmodmab\equiv cd\bmod m and -a-cmodm-a\equiv-c\bmod m.

Proof. Take q,rq,r\in\mathbb{Z} such that a=qm+ca=qm+c and b=rm+db=rm+d. Then we have

a+b=(qm+c)+(rm+d)=(q+r)m+(c+d),a+b=(qm+c)+(rm+d)=(q+r)m+(c+d),

so that a+bc+dmodma+b\equiv c+d\bmod m. Moreover,

ab=(qm+c)(rm+d)=(qrm+qd+cr)m+cd,ab=(qm+c)(rm+d)=(qrm+qd+cr)m+cd,

so that abcdmodmab\equiv cd\bmod m, and finally

-a=-(qm+c)=(-q)m+(-c),-a=-(qm+c)=(-q)m+(-c),

so that -a-cmodm-a\equiv-c\bmod m. \Box

Lemma 6.3.2 enables us to make the following definition without any ambiguity.

Definition 6.3.3

Given mm\in\mathbb{N} and a^, b^m\widehat{a},\,\widehat{b}\in\mathbb{Z}_{m}, define a^+b^=a+b^\widehat{a}+\widehat{b}=\widehat{a+b}, a^b^=ab^\widehat{a}\cdot\widehat{b}=\widehat{ab} and -b^=-b^-\widehat{b}=\widehat{-b}.

Our ‘‘new’’ addition and multiplication inherit many properties from the ordinary versions; for example, for all a,ba,b\in\mathbb{Z} we have a+b=b+aa+b=b+a and ab=baab=ba, and therefore

a^+b^=a+b^=b+a^=b^+a^  and  a^b^=ab^=ba^=b^a^.\widehat{a}+\widehat{b}=\widehat{a+b}=\widehat{b+a}=\widehat{b}+\widehat{a}% \qquad\hbox{and}\qquad\widehat{a}\cdot\widehat{b}=\widehat{ab}=\widehat{ba}=% \widehat{b}\cdot\widehat{a}.

Moreover, our system also has subtraction: in \mathbb{Z} we may regard a-ba-b as a+(-b)a+(-b), so in m\mathbb{Z}_{m} we set a^-b^=a^+(-b^)=a^+-b^=a-b^\widehat{a}-\widehat{b}=\widehat{a}+(-\widehat{b})=\widehat{a}+\widehat{-b}=% \widehat{a-b} as expected. (As in \mathbb{Z}, however, division is another matter.)

Since the set m\mathbb{Z}_{m} is finite, we may give addition and multiplication tables listing the results of combining any two classes. In 5\mathbb{Z}_{5}, for example, we obtain the following.

+0^1^2^3^4^0^0^1^2^3^4^1^1^2^3^4^0^2^2^3^4^0^1^3^3^4^0^1^2^4^4^0^1^2^3^    ×0^1^2^3^4^0^0^0^0^0^0^1^0^1^2^3^4^2^0^2^4^1^3^3^0^3^1^4^2^4^0^4^3^2^1^\begin{array}[]{|c|ccccc|}\hline+&\widehat{0}&\widehat{1}&\widehat{2}&\widehat% {3}&\widehat{4}\\ \hline\widehat{0}&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{3}&\widehat{4}% \\ \widehat{1}&\widehat{1}&\widehat{2}&\widehat{3}&\widehat{4}&\widehat{0}\\ \widehat{2}&\widehat{2}&\widehat{3}&\widehat{4}&\widehat{0}&\widehat{1}\\ \widehat{3}&\widehat{3}&\widehat{4}&\widehat{0}&\widehat{1}&\widehat{2}\\ \widehat{4}&\widehat{4}&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{3}\\ \hline\end{array}\qquad\qquad\begin{array}[]{|c|ccccc|}\hline\times&\widehat{0% }&\widehat{1}&\widehat{2}&\widehat{3}&\widehat{4}\\ \hline\widehat{0}&\widehat{0}&\widehat{0}&\widehat{0}&\widehat{0}&\widehat{0}% \\ \widehat{1}&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{3}&\widehat{4}\\ \widehat{2}&\widehat{0}&\widehat{2}&\widehat{4}&\widehat{1}&\widehat{3}\\ \widehat{3}&\widehat{0}&\widehat{3}&\widehat{1}&\widehat{4}&\widehat{2}\\ \widehat{4}&\widehat{0}&\widehat{4}&\widehat{3}&\widehat{2}&\widehat{1}\\ \hline\end{array}

In 4\mathbb{Z}_{4} we obtain instead these tables.

+0^1^2^3^0^0^1^2^3^1^1^2^3^0^2^2^3^0^1^3^3^0^1^2^    ×0^1^2^3^0^0^0^0^0^1^0^1^2^3^2^0^2^0^2^3^0^3^2^1^\begin{array}[]{|c|cccc|}\hline+&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{% 3}\\ \hline\widehat{0}&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{3}\\ \widehat{1}&\widehat{1}&\widehat{2}&\widehat{3}&\widehat{0}\\ \widehat{2}&\widehat{2}&\widehat{3}&\widehat{0}&\widehat{1}\\ \widehat{3}&\widehat{3}&\widehat{0}&\widehat{1}&\widehat{2}\\ \hline\end{array}\qquad\qquad\begin{array}[]{|c|cccc|}\hline\times&\widehat{0}% &\widehat{1}&\widehat{2}&\widehat{3}\\ \hline\widehat{0}&\widehat{0}&\widehat{0}&\widehat{0}&\widehat{0}\\ \widehat{1}&\widehat{0}&\widehat{1}&\widehat{2}&\widehat{3}\\ \widehat{2}&\widehat{0}&\widehat{2}&\widehat{0}&\widehat{2}\\ \widehat{3}&\widehat{0}&\widehat{3}&\widehat{2}&\widehat{1}\\ \hline\end{array}
Remark 6.3.4

The multiplication table above shows that 2^2^=0^\widehat{2}\cdot\widehat{2}=\widehat{0} in 4\mathbb{Z}_{4}. We say that 2^\widehat{2} is a zero divisor in 4\mathbb{Z}_{4}. Likewise, since 2^4^=8^=0^\widehat{2}\cdot\widehat{4}=\widehat{8}=\widehat{0} in 8\mathbb{Z}_{8}, we say that 2^\widehat{2} and 4^\widehat{4} are zero divisors in 8\mathbb{Z}_{8}.

Lemma 6.3.2 shows that if abmodma\equiv b\bmod m then a2b2modma^{2}\equiv b^{2}\bmod m; so we have the concept of ‘‘squares modulo mm’’. The following result is easy.

Proposition 6.3.5

All squares are congruent to 00 or 11 modulo 44.

Example 6.3.6

We have 72=49=412+11mod47^{2}=49=4\cdot 12+1\equiv 1\bmod 4.
Moreover, 102=100=4250mod410^{2}=100=4\cdot 25\equiv 0\bmod 4.

Proof. Let nn\in\mathbb{Z} be given. Since each integer is congruent to either 00, 11, 22 or 33 modulo 44, there are four cases to consider:

  • if n0mod4n\equiv 0\bmod 4, then n202=0mod4n^{2}\equiv 0^{2}=0\bmod 4;

  • if n1mod4n\equiv 1\bmod 4, then n212=1mod4n^{2}\equiv 1^{2}=1\bmod 4;

  • if n2mod4n\equiv 2\bmod 4, then n222=40mod4n^{2}\equiv 2^{2}=4\equiv 0\bmod 4;

  • otherwise n3mod4n\equiv 3\bmod 4, and n232=91mod4n^{2}\equiv 3^{2}=9\equiv 1\bmod 4. \Box

Note that this result can be read from the main diagonal of the multiplication table in 4\mathbb{Z}_{4} given above.

Corollary 6.3.7

Suppose that nn\in\mathbb{N} is congruent to 33 modulo 44. Then nn cannot be expressed as the sum of two squares.

Example 6.3.8

9770397703 is not a sum of two squares because 4|1004|100, so 4|977004|97700 and hence 977033mod4.97703\equiv 3\bmod 4.

Proof. We shall prove the statement by contraposition. To do so, we begin by expressing it symbolically; it can be rewritten as ‘‘p(¬q)p\Rightarrow(\neg q)’’, where

p:n3mod4  and  q:(a,b)(n=a2+b2).p\colon\quad n\equiv 3\bmod 4\qquad\text{and}\qquad q\colon\quad(\exists\,a,b% \in\mathbb{Z})(n=a^{2}+b^{2}).

Recall from Example 2.3.7 that the law of contraposition implies that the statement ‘‘p(¬q)p\Rightarrow(\neg q)’’ is logically equivalent to ‘‘(¬(¬q))(¬p)\bigl(\neg(\neg q)\bigr)\Rightarrow(\neg p)’’, that is, ‘‘q(¬p)q\Rightarrow(\neg p)’’.

To prove this final statement, suppose that qq is true, so that n=a2+b2n=a^{2}+b^{2} for some a,ba,b\in\mathbb{Z}. By Proposition 6.3.5, a2a^{2} and b2b^{2} are congruent to either 00 or 11 modulo 44, so there are four cases to consider:

  • if a20a^{2}\equiv 0 and b20mod4b^{2}\equiv 0\bmod 4, then n=a2+b20+0=03mod4n=a^{2}+b^{2}\equiv 0+0=0\not\equiv 3\bmod 4;

  • if a20a^{2}\equiv 0 and b21mod4b^{2}\equiv 1\bmod 4, then n=a2+b20+1=13mod4n=a^{2}+b^{2}\equiv 0+1=1\not\equiv 3\bmod 4; the case where a21a^{2}\equiv 1 and b20mod4b^{2}\equiv 0\bmod 4 is similar;

  • if a21a^{2}\equiv 1 and b21mod4b^{2}\equiv 1\bmod 4, then n=a2+b21+1=23mod4n=a^{2}+b^{2}\equiv 1+1=2\not\equiv 3\bmod 4.

Hence in each case n3mod4n\;\not\equiv 3\bmod 4, so pp is never satisfied, and the result follows. \Box

Remark 6.3.9

The converse of Corollary 6.3.7 is false. For example, 62mod46\equiv 2\bmod 4, so 63mod46\not\equiv 3\bmod 4, but 66 cannot be written as the sum of two squares. Indeed, the only squares less than or equal to 66 are 02=00^{2}=0, 12=11^{2}=1, and 22=22^{2}=2, and no two of these add up to 66.

Our observation above about taking squares modulo mm extends to cubes or indeed any powers: if abmodma\equiv b\bmod m then anbnmodma^{n}\equiv b^{n}\bmod m for any nn\in\mathbb{N}. (Do not confuse this with the remarks earlier about the impossibility of defining a^b^\widehat{a}\,^{\widehat{b}} for classes a^\widehat{a} and b^\widehat{b}; there we were attempting to raise one class to the power of another class, whereas what is being claimed here is simply that it makes sense to raise a class to a given power.)

This result enables us to simplify certain expressions when working modulo mm.

Example 6.3.10

Find 227mod152^{27}\bmod 15 without considering any numbers greater than 100100.

Note: this means ‘‘find x{0,1,2,,14}x\in\{0,1,2,\ldots,14\} such that 227xmod152^{27}\equiv x\bmod 15’’.

Solution. We compute 22=42^{2}=4, 23=82^{3}=8, 24=161mod152^{4}=16\equiv 1\bmod 15, so that

227=246+3=(24)623168=8mod15.2^{27}=2^{4\cdot 6+3}=(2^{4})^{6}\cdot 2^{3}\equiv 1^{6}\cdot 8=8\bmod 15.
Example 6.3.11

Find the remainder on dividing 3583^{58} by 77 without considering any numbers greater than 100100.

Solution. We compute 32=92mod73^{2}=9\equiv 2\bmod 7 and

33=33232=6-1mod7,3^{3}=3\cdot 3^{2}\equiv 3\cdot 2=6\equiv-1\bmod 7,

so that

358=3319+1=(33)193(-1)193=-34mod7,3^{58}=3^{3\cdot 19+1}=(3^{3})^{19}\cdot 3\equiv(-1)^{19}\cdot 3=-3\equiv 4% \bmod 7,

so the remainder is 4.4.

Example 6.3.12

Show that 5|(84n+2+42n)5|(8^{4n+2}+4^{2n}) for each nn\in\mathbb{N}.

Solution. We have 83mod58\equiv 3\bmod 5, so that 8232=9-1mod58^{2}\equiv 3^{2}=9\equiv-1\bmod 5, and hence

84n+2=(82)2n+1(-1)2n+1=-1mod5.8^{4n+2}=(8^{2})^{2n+1}\equiv(-1)^{2n+1}=-1\bmod 5.

Likewise, we see that 42=161mod54^{2}=16\equiv 1\bmod 5, so that

42n=(42)n1n=1mod5,4^{2n}=(4^{2})^{n}\equiv 1^{n}=1\bmod 5,

and thus 84n+2+42n(-1)+1=0mod58^{4n+2}+4^{2n}\equiv(-1)+1=0\bmod 5, which proves the result.

What we have succeeded in defining in this section is called modular arithmetic; it has the great advantage over ordinary arithmetic of requiring only very small calculations as the set involved is finite, but as we have seen it sometimes enables us to answer questions which would otherwise seem impossibly hard.