Learn · The Concrete Discrete Math of Real Systems
growing
Midnight Is Zero Again
Remainders turn repetition into a finite world where addition, multiplication, schedules, checksums, and inverses obey one reusable set of laws.
If a number divides the difference of two numbers and , then and are said to be congruent.
— Carl Friedrich Gauss, Disquisitiones Arithmeticae, article 1, 1801 English translation
The preceding chapter ended with a finite machine returning to a state it had visited before. Here that repetition becomes arithmetic. You will define congruence; prove that addition and multiplication respect it; find when division is legal by computing inverses; and use the laws to explain schedules, circular storage, and check digits. You will also retrieve the book's earlier distinction between a value and its equivalence class.
Four hours after twenty-three
Write the hours after 23 without stopping:
23, 24, 25, 26, 27, …
Now write what the clock displays:
23, 0, 1, 2, 3, …
The clock has not made equal to as integers. It has declared them equivalent for the purpose of hour-of-day: their difference, 24, is a whole number of revolutions. We write
More generally, exactly when divides . Every integer belongs to one of equivalence classes, labeled by the remainders .
Congruence modulo n — equality of remainders after division by . It is an equivalence relation: reflexive, symmetric, and transitive. See MIT Mathematics for Computer Science, number theory readings.
Note
The person behind congruence notation. Carl Friedrich Gauss (1777–1855) introduced the systematic notation and theory of congruences in Disquisitiones Arithmeticae. Arithmetic with remainders long predates him, including the Chinese remainder problem; the attribution is to Gauss's formulation, not the invention of remainder reasoning.
Reduce whenever you like
The useful miracle is compatibility. If and modulo , then
and
For addition, subtract the right side from the left: . Both pieces are multiples of , so their sum is. Multiplication follows by writing .
That proof grants an engineering license: reduce before an operation, after it, or between every step. The final remainder cannot change. Large exponents become manageable by repeated squaring and reduction; ring-buffer indices become (index + 1) mod capacity; weekday arithmetic never leaves seven states.
The remainder classes support addition and multiplication, with and as identities and additive inverses obtained by walking around the circle backward. This is the ring of integers modulo .
Ring — a set with addition and multiplication obeying the familiar associative and distributive laws, with additive inverses. Modular integers form a ring. See Wolfram MathWorld's reference definition.
Division has a gate
On an ordinary calculator, divide by any nonzero number. On a clock, division means multiplying by an inverse. The inverse of modulo is a number satisfying
Modulo 7, the inverse of 3 is 5 because . Modulo 6, 3 has no inverse: its multiples visit only 0 and 3. The exact boundary is gcd(a,n) = 1. Bézout's identity proves it. If , reducing modulo leaves ; conversely, an inverse gives such an integer equation.
The gate in motion. The first cell checks the divisor's inverse; the second performs the division. Pliara Math publishes both results as one inert transcript that the reader's browser verifies before adding MathML.
denominator := modular(2, 7)
inverse_witness := modular(4, 7)
expect(denominator * inverse_witness == modular(1, 7))
inverse_witness
numerator := modular(3, 7)
denominator := modular(2, 7)
expect(denominator == modular(2, 7))
numerator / denominator
Notebook evidence
- Language
- pliara.math/1
- Profile
- pliara.math.exact-v1
- Artifact
- 1e7af9fb56e50ca87b672b5a10d94645f21f4da105de4a440d33619a8de4015c
- Cells
- 2
- Initial trust
- claimed observation
When is prime, every nonzero remainder is coprime to , so every nonzero value has an inverse. The modular ring becomes a field. This is why prime moduli appear so often: division regains its ordinary shape everywhere except zero.
A check digit is a conserved remainder
Suppose a code chooses its final digit so the weighted digit sum is congruent to zero modulo 10. At the receiver, recompute the sum. A single changed digit usually changes the remainder, exposing damage. The check does not prove the message is correct—different damaged messages can share one remainder, as the pigeonhole chapter already guaranteed. It purchases a quantified class of detectable errors, not certainty.
The Luhn method, patented by IBM researcher Hans Peter Luhn, uses alternating weights and decimal digit sums so common transcription errors disturb the final congruence.
Note
The person behind the Luhn algorithm. Hans Peter Luhn (1896–1964) was an IBM researcher whose work also shaped information retrieval and keyword indexing. His 1954 filing, granted as US Patent 2,950,048, describes the checking method now bearing his name. A check digit detects selected mistakes; it is not a cryptographic signature and does not establish who produced the number.
Where the circle runs out
- Modular equality always names its modulus. Omitting it changes the claim.
- Cancellation is unsafe without an inverse. From one may cancel only when is invertible modulo .
- Wraparound in machine integers resembles modular arithmetic, but language rules differ. Signed overflow may trap, wrap, or be undefined.
- A small checksum has unavoidable collisions. It detects a promised error family; it does not authenticate adversarial data.
Lessons
- Congruence groups integers by equal remainder.
- Addition and multiplication respect congruence, so reduction may happen at any point.
- A remainder is divisible only by values coprime to the modulus; prime moduli make every nonzero class invertible.
- Circular schedules, buffer indices, and check digits are the same algebra in different clothing.
Practice
- Without looking back, compute modulo 7 by reducing after each squaring.
- Explain why has more than one solution and which failed cancellation would hide them.
- A service rotates among 11 shards by request number modulo 11. Which shard receives request 10,000? Show a reduction that never handles a large number.
- One day later, reconstruct the rule for modular invertibility from the phrase “shares no factor with the clock.”
The next question is about damage
A check digit can say that a word probably moved to the wrong remainder class. It usually cannot say which digit changed, much less repair it. To correct damage, valid messages must be placed far enough apart that a received word remains closest to only one of them. The next chapter turns redundancy into geometry.
References
- Gauss. “Disquisitiones Arithmeticae.” 1801. — articles 1–12 introduce congruence systematically
- Lehman, Leighton, Meyer. “Mathematics for Computer Science.” MIT OpenCourseWare, 2024. — the number-theory chapters prove the laws and Bézout's identity
- Luhn. “Computer for Verifying Numbers.” US Patent 2,950,048, 1960. — the primary specification of the decimal checking method