Lecture 14

Proposition

Here are some properties of congruences, true for all integers:

  1. We always have aa(modm)a\equiv a\pmod{m};

  2. If ab(modm)a\equiv b\pmod{m}, then ba(modm)b\equiv a\pmod{m};

  3. If ab(modm)a\equiv b\pmod{m} and bc(modm)b\equiv c\pmod{m}, then ac(modm)a\equiv c\pmod{m};

  4. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then a+cb+d(modm)a+c\equiv b+d\pmod{m};

  5. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then acbd(modm)a-c\equiv b-d\pmod{m};

  6. If ab(modm)a\equiv b\pmod{m} and cd(modm)c\equiv d\pmod{m}, then acbd(modm)ac\equiv bd\pmod{m}.

Proof

For (a):

Since aa=0a-a=0, we have m(aa)m\mid(a-a).

For (b):

If ab(modm)a\equiv b\pmod{m}, we have m(ab)m\mid (a-b). But then m(ab)m\mid-(a-b), which says m(ba)m\mid(b-a), or in other words ba(modm)b\equiv a\pmod{m}.

For (c):

As ab(modm)a\equiv b\pmod{m}, we have m(ab)m\mid (a-b); similarly as bc(modm)b\equiv c\pmod{m}, we have m(bc)m\mid(b-c). But then m((ab)+(bc))=(ac),m\mid((a-b)+(b-c))=(a-c), which says that ac(modm)a\equiv c\pmod{m}.

For (d):

As ab(modm)a\equiv b\pmod{m}, we can write ab=kma-b=km for some integer kk; similarly, as cd(modm)c\equiv d\pmod{m}, we can write cd=lmc-d=lm for some integer ll.

As a result, (a+c)(b+d)=(ab)+(cd)=km+lm=(k+l)m,(a+c)-(b+d) = (a-b)+(c-d) = km + lm = (k+l)m, so m((a+c)(b+d))m\mid\left((a+c)-(b+d)\right), so a+cb+d(modm)a+c\equiv b+d\pmod{m}.

For (e):

As above, we can write ab=kma-b=km, and cd=lmc-d=lm. Then (ac)(bd)=(ab)(cd)=kmlm=(kl)m,(a-c)-(b-d) = (a-b)-(c-d) = km - lm = (k-l)m, so m((ac)(bd))m\mid((a-c)-(b-d)), so acbd(modm)a-c\equiv b-d\pmod{m}.

For (f):

As ab(modm)a\equiv b\pmod{m}, then we can write a=b+kma = b+km for some integer kk (since aba-b is a multiple of mm). Similarly, as cd(modm)c\equiv d\pmod{m} we can write c=d+lmc = d+lm.

But then ac=(b+km)(d+lm)=bd+(bl+dk+klm)mac = (b+km)(d+lm) = bd + (bl+dk+klm)m, which says that acbd(modm)ac\equiv bd\pmod{m}.

I interpret all that as saying that, provided you’re careful and justify any unusual steps, the language of congruences behaves somewhat like equality. (In particular, our choice of notation, looking a bit like an overenthusiastic equals sign, wasn’t a bad choice). This philosophy will get heavy use from now on!

Back at school, you probably learned facts like “an odd number times an even number is an even number”. We can now give an systematic explanation of facts like these, using modular arithmetic.

If aa is odd and bb is even then a1(mod2)b0(mod2)\begin{aligned} a &\equiv 1 \pmod{2}\\ b &\equiv 0 \pmod{2}\\\end{aligned} and then (because we can multiply congruences) ab1×0=0(mod2),ab \equiv 1\times 0 = 0\pmod{2}, which says that abab is even.

Since we can add congruences, we can give similar explanations of addition facts (like “an odd number plus an even number is an odd number”).

The language of congruences gives us ways of writing down similar facts about other moduli.

For example, if a3(mod7)a\equiv 3\pmod{7}, and b4(mod7)b\equiv 4\pmod{7}, then ab125(mod7)ab\equiv 12{}\equiv 5\pmod{7}.

We can use these ideas to make multiplication tables of congruences. For example, here’s a multiplication table modulo 55:

×\times 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

So, for example, this tells us that 2×43(mod5)2\times 4\equiv 3\pmod{5}.

Notice that this shares some features with a usual multiplication table. For example, there is a column and a row of zeroes, because if you multiply something by something congruent to zero mod 55, you get something congruent to zero mod 55. Also, multiplying by 11 doesn’t change anything.

Why do we only need to consider rows and columns numbered from 00 to 44? This is a consequence of division with remainder.

Proposition

Let aa and bb be integers, with b>0b>0. Then aa is congruent (modulo bb) to a unique integer in the set {0,1,,b1}.\{0,1,\ldots,b-1\}.

Proof

We’ll show that such a number exists, first, and then we’ll show that it’s unique.

By division with remainder, we can write a=qb+ra=qb+r for some integer qq and some integer rr with 0r<b0\leq r<b. But then that says that ar=qba-r=qb, and hence ar(modb)a\equiv r\pmod{b}. That shows that aa is congruent to some number in that set.

Now, we’ll prove uniqueness. In fact we never proved that division with a unique remainder was possible, so let’s mend that now.

Suppose that ar1(modb)a\equiv r_1\pmod{b} and also ar2(modb)a\equiv r_2\pmod{b}. Then 0=aar2r1(modb)0=a-a\equiv r_2-r_1\pmod{b} by subtracting, so b(r2r1)b\mid(r_2-r_1).

But since 0r1<b0\leq r_1<b and 0r2<b0\leq r_2<b, we have b=0b<r2r1<b0=b.-b = 0-b < r_2-r_1 < b-0 = b. So r2r1r_2-r_1 is a multiple of bb strictly between b-b and bb: it must be zero, so r1=r2r_1=r_2, which proves uniqueness.

This proposition has a lot of consequences.

It means we can divide up the integers into sets, called congruence classes or residue classes, based on which number from {0,,b1}\{0,\ldots,b-1\} they’re congruent to. So, for b=5b=5, we divide the integers into:

Many people, particularly those who like numerical calculations with integers (like computer programmers), use all this as an excuse to define a function, which in some languages is written “%\%”, which gives the remainder upon division (so that a%ba\% b is an integer between 00 and b1b-1). So they say, for example, that 137%100=37137\% 100 = 37.

This works fairly well for the computer programmers, but for us it’s a little unsatisfying. While it’s true that every number is congruent (modulo 77) to a unique number from {0,1,2,3,4,5,6}\{0,1,2,3,4,5,6\}, there’s nothing much special about that set. It’s also true that every number is congruent (modulo 77) to a unique number in the set {1,2,3,4,5,6,7}\{1,2,3,4,5,6,7\}. And it’s also true that every number is congruent (modulo 77) to a unique number in the set {3,2,1,0,1,2,3}\{-3,-2,-1,0,1,2,3\}. And, in fact, I can think of situations where all those facts are useful.

So it’s important we just think of the unique number in {0,,b1}\{0,\ldots,b-1\} as just one out of many equally good ways of describing our number, up to congruence modulo bb.

Next semester, you’ll come to regard the integers, considered up to congruence modulo mm, as a system of numbers in its own right (and why not? We can add them and subtract them and multiply them, all considered only up to congruence modulo mm). This system of numbers is commonly called Z/mZ\mathbb{Z}/m\mathbb{Z} (for reasons which will remain obscure at least for a year or two more).

So, for example, the system Z/2Z\mathbb{Z}/2\mathbb{Z} consists of two “numbers” which could be called “even” and “odd” (or 0 and 1), subject to the arithmetic laws you’d expect (like even+odd=odd\text{even} + \text{odd} = \text{odd}).

This is novel in one important sense. In the past, every time we’ve introduced a new system of numbers, it’s contained the system we were thinking about before. We’ve built NZQRC.\mathbb{N}\subset \mathbb{Z}\subset \mathbb{Q}\subset \mathbb{R}\subset \mathbb{C}. But Z/mZ\mathbb{Z}/m\mathbb{Z} doesn’t seem to work like this in this framework. It’s related to Z\mathbb{Z}, but doesn’t really live inside it. Similarly, the set of “times of day” isn’t a subset of the set of times: for example, there’s no one special point of time in history called “2pm”, just many examples of 2pm on many different days.

In the case where m=2m=2, you’re probably comfortable with the fact that “odd” and “even” form something like a system of numbers (because you can add them and subtract them and multiply them), but while they’ve obviously got something to do with Z\mathbb{Z}, there’s no one integer called “odd” and no one integer called “even”.

Modular arithmetic, to other moduli, is similar (we just don’t have clever names like “even” and “odd”).

Congruence equations

We’ve now laid the foundations of modular arithmetic, the study of congruences. After all that philosophy, we should do some sums.

The set of all solutions to x3(mod7)x\equiv 3\pmod{7} seems like a perfectly explicit description of a class of numbers: it’s a congruence class modulo 77, the class of numbers of the form 7n+37n+3. So we can start listing them easily: ,11,4,3,10,17,.\ldots, -11, -4, 3, 10, 17, \ldots.

But what is the set of solutions to 5x3(mod7)5x\equiv 3\pmod{7}?

That’s not a particularly satisfactory description of a set of numbers: it’s a pain to list them, so we should ask for better.

However, we can get a more satisfactory list just using techniques we already know. The condition 5x3(mod7)5x\equiv3\pmod{7} says that 75x37\mid 5x-3, which in turn says that 7k=5x37k=5x-3 for some kk. Rearranging, that says that 5x7k=35x-7k=3. But we know how to get a general solution for those!

Indeed, we find that gcd(5,7)=1\gcd(5,7)=1, and as 131\mid 3 there are solutions. First we try to find a single one.

We can get a solution to 5x7k=15x-7k=1 (by guessing, or by using Euclid’s algorithm backwards) such as x=3,k=2x=3,k=2. This means (by tripling both sides) that a solution to 5x7k=35x-7k=3 is given by x=9,k=6x=9, k=6.

To find other solutions, we subtract 5×97×6=35\times9-7\times6=3 from 5x7k=35x-7k=3 to get 5(x9)7(k6)=05(x-9)-7(k-6)=0.

Hence 5(x9)=7(k6)5(x-9) = 7(k-6), so 75(x9)7\mid 5(x-9). As 77 and 55 are coprime, this means that 7(x9)7\mid(x-9). So it’s equivalent to x2(mod7)x\equiv 2\pmod{7}, which is a nice description!

We can regard linear equations in modular arithmetic as asking about division. After all, asking about solutions to the linear equation 5x=35x=3 is asking “can we divide 33 by 55”? So the fact that 2×53(mod7)2\times 5\equiv 3\pmod{7} might be regarded as saying that we can divide 33 by 55 (modulo 77), and we get 22 when we do so.

But division in modular arithmetic is more complicated than in the integers. Of course, integer division is unique where it exists. In other words, if I choose integers aa and bb (with bb nonzero) and ask about integer solutions to ax=b,ax=b, then two things can happen: either there is a unique solution (as with 3x=63x=6), or there’s no solution at all (as with 4x=74x=7).

That’s not true in modular arithmetic, as the following examples show: