In the last section we saw that congruence mod \(n\) is an equivalence relation. In this section we will explore this relation in more detail. We will also introduce the concept of modular arithmetic.
In some applications, and often in computer science, the remainder, \(r\text{,}\) when \(a\) is divided by \(n\) is denoted \(r=a \mod n\text{.}\) When using equals (=), we will mean the specific remainder. When using congruence (\(\equiv\)), we will mean the relation. For example, \(2=12 \mod 5\text{,}\) but many numbers can satisfy the congruence: \(17 \equiv 12 \mod 5\text{,}\) etc.
We use modular arithmetic and equivalence mod \(n\) when we want to think about remainders when dividing by \(n\text{.}\) A familiar example is clock time. Suppose it is 11 am and you have an appointment in 3 hours. In general, you would not think of your appointment for 14 oβclock. You would think of noon as 0, and get that your appointment is at 2 oβclock. There are many more applications in algebra, cryptography, and computer science where we want to classify integers by their remainders mod \(n\text{.}\)
Assume \(a=b+kn\) for some \(k\in \mathbb{Z}\text{.}\) By the Quotient-Remainder Theorem, \(a=qn+r\) with \(0\leq r< n\text{.}\) Thus, \(b+kn=qn+r\text{.}\) Solving for \(b\text{,}\) we get \(b=(q-k)n+r\text{.}\) But by uniqueness of the remainder, \(b\) has remainder \(r\text{.}\)
Now assume \(a\) and \(b\) have the same remainder when divided by \(n\text{.}\) By the Quotient-Remainder Theorem, \(a=qn+r\) and \(b=q'n+r\text{.}\) Substituting in for \(r\text{,}\)\(a=qn+b-q'n=b+(q-q')n\text{.}\) Since \((q-q')\in \mathbb{Z}\text{,}\) let \(k=q-q'\text{.}\)
The residue of \(a\) modulo \(n\) is the remainder when \(a\) is divided by \(n\text{.}\) The set \(\{0, 1, \ldots, n-1\}\) forms a complete set of residues mod \(n\).
Congruence mod \(n\) is an equivalence relation on \(\mathbb{Z}\) with equivalence classes \([0], [1], \ldots [n-1]\text{.}\) Furthermore, \([a]=\{m\in \mathbb{Z} : m=a+kn, k\in \mathbb{Z}\}\text{.}\)
Find the equivalence classes for congruence mod 5. List several elements of each equivalence class. What do the elements of each congruence class look like?
Modular arithmetic is just the process of adding, subtracting, and multiplying, where we treat integers with the same remainder mod \(n\text{,}\) as equivalent. Thus, we can replace any integer with itβs remainder.
We can write integers using their decimal expansion. For example, we can write 592 as a decimal expansion: \((5\times 100)+(9\times 10)+2=5\times 10^2+9\times 10^1+2\times 10^0\text{.}\)
We define \(\mathbb{Z}_n=\{0, 1, \ldots, n-1\}\text{,}\) where \(k\in\mathbb{Z}_n\) represents the equivalence class \([k]\text{.}\) Although this sounds complicated, we just do regular arithmetic with \(1, \ldots, n-1\) and reduce to the remainder mod \(n\text{.}\)
Prove the transitivity of modular congruence. That is, prove for all \(a, b, c, n\in \mathbb{Z}\) with \(n>1\text{,}\) if \(a\equiv b \mod n\) and \(b\equiv c \mod n\text{,}\) then \(a\equiv c \mod n\text{.}\)
Prove for all \(a, c, n, m\in \mathbb{Z}\) with \(n>1\text{,}\) and \(m\geq 1\text{,}\) if \(a\equiv c \mod n\text{,}\) then \(a^m\equiv c^m \mod n\text{.}\)
The previous problem will be helpful, as will writing \(N\) as a decimal expansion (see ActivityΒ 8.4.7). It can be useful in proving that a number is divisible by 9 to instead show that it is congruent to 0 mod 9. Also note, this is an βif and only ifβ statement so your proof requires two parts.