Modular arithmetic [01D0]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
In the previous lecture, we considered the modular normal form of an integer 0\leq [k]_m <m, which had the defining property that k \equiv [k]_m\mod m. In this lecture, we will use this idea to create a new number system \mathbb {Z}_m for each modulus m, which is called the integers modulo m.
Definition Modular integers [01D2]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
For a positive integer m, the integers modulo m consist of the set \mathbb {Z}_m \coloneqq {\mathopen {}\left \{0,\ldots ,m-1\right \}\mathclose {}} with the modular +_m and multiplication \cdot _m defined as follows, using the modular normal forms of naturals:
\begin {aligned} k +_m l &= [k + l]_m &&= \operatorname {rem}{\mathopen {}\left (k+l,m\right )\mathclose {}} \\ k\cdot _m l &= [k+l]_m &&= \operatorname {rem}{\mathopen {}\left (k\cdot l, m\right )\mathclose {}} \end {aligned}In other words, for all k,l:\mathbb {Z}_m, k+_m l\quad \text {and}\quad k\cdot _m l are the unique modular integers in \mathbb {Z}_m such that \begin {aligned} k+_m l &\equiv k+ l &\mod m,\\ k\cdot _m l &\equiv k \cdot l &\mod m\text {.} \end {aligned}
Observation Equality of modular integers is congruence [01F0]
- October 28, 2026
- Jon Sterling
For any modular integers i,j:\mathbb {Z}_m, we have i=j if and only if i\equiv j \mod m.
Proof.
- October 28, 2026
- Jon Sterling
Example Integers modulo 2 [01D3]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
The modular-arithmetic structure {\mathopen {}\left (\mathbb {Z}_2,+_2,0,\cdot _2,1\right )\mathclose {}} is that of the booleans with XOR as addition and AND as multiplication.
Proof.
- October 8, 2026
- Marcelo Fiore, Jon Sterling
To verify the claim, rather than explicitly calculating the values of the additive and multiplicative structure, we instead use the universal property of their definitions. In particular, we need only check the following for all x,y\in {\mathopen {}\left \{0,1\right \}\mathclose {}}:
x \oplus y \equiv x + y \mod 2\text {,} \qquad x\land y \equiv x \cdot y \mod 2\text {.}This is easily seen by constructing addition and multiplication tables.
| \oplus | 0 | 1 |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 0 |
| \land | 0 | 1 |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
Example Addition and multiplication in \mathbb {Z}_4 [01D4]
- October 8, 2026
The addition and multiplication tables for the integers modulo 4 are as follows:
| +_4 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 |
| 1 | 1 | 2 | 3 | 0 |
| 2 | 2 | 3 | 0 | 1 |
| 3 | 3 | 0 | 1 | 2 |
| \cdot _4 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 2 | 3 |
| 2 | 0 | 2 | 0 | 2 |
| 3 | 0 | 3 | 2 | 1 |
Notice how the addition table has a cyclic pattern, while there is no obvious pattern in the multiplication table.
From the addition and multiplication tables, we can readily read tables for additive and multiplicative inverses, where they exist:
| additive inverse | multiplicative inverse | |
|---|---|---|
| 0 | 0 | none |
| 1 | 3 | 1 |
| 2 | 2 | none |
| 3 | 1 | 3 |
Interstingly, we have one non-trivial multiplicative inverse: 3\cdot _4 3 = 1.
Example Addition and multiplication in \mathbb {Z}_5 [01D5]
- October 8, 2026
- Marcelo Fiore, Jon Sterling
The addition and multiplication tables for the integers modulo 5 are as follows:
| +_5 | 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 |
| \cdot _5 | 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 |
From the addition and multiplication tables, we can readily read a table of additive and multiplicative inverses:
| additive inverse | multiplicative inverse | |
|---|---|---|
| 0 | 0 | none |
| 1 | 4 | 1 |
| 2 | 3 | 3 |
| 3 | 2 | 2 |
| 4 | 1 | 4 |
Proposition Commutative rings of modular integers [01D6]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
For each positive integer m, the modular arithmetic structure (\mathbb {Z}_m, +_m,0,\cdot _m,1) is a commutative ring.
Proof.
- October 12, 2026
- Marcelo Fiore, Jon Sterling
You may do this as an exercise; the most interest part lies in establishing the associativity laws of addition and multiplication.
Proposition Reciprocals of modular integers [01D7]
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let m be a positive integer. A modular integer k:\mathbb {Z}_m has a reciprocal if and only if there exist integers i,j such that k\cdot i+m\cdot j = 1.
Proof.
- October 12, 2026
- Marcelo Fiore, Jon Sterling
Let m be a positive integer and fix k:\mathbb {Z}_m.
In the forward direction, we assume that k has a reciprocal in \mathbb {Z}_m, i.e. some \bar {k}:\mathbb {Z}_m such that k\cdot _m \bar {k} \equiv 1\mod m. We must find integers i,j such that k\cdot i + m \cdot j = 1. Choosing i \coloneqq \bar {k}, we have k\cdot i \equiv k\cdot _m i \equiv 1 \mod m and therefore m \mid (k\cdot i - 1) and hence k\cdot i - 1 = m\cdot l for some l. Hence k\cdot i - m\cdot l = 1, so we may choose j\coloneqq -l.
In the backward direction, we suppose that we have i,j such that k\cdot i + m\cdot j = 1. We must find a reciprocal for k; in fact, the modular normal form [i]_m is such a reciprocal:
\begin {aligned} k \cdot _m [i]_m &= [k\cdot i]_m \\ &\equiv k\cdot i &\mod m \\ &= 1 - m\cdot j \\ &\equiv 1 &\mod m \end {aligned}