Foundations/The Integers and Modular Arithmetic

Lesson 1.21,827 words

The Integers and Modular Arithmetic

The integers carry the template every ring later imitates: well-ordering drives induction, induction drives the division algorithm, and division drives the Euclidean algorithm, gcd, Bézout's identity, and unique factorization into primes. Quotienting by congruence mod n builds the first finite arithmetic, Z/nZ, whose invertible elements form the group of units.

╌╌╌╌

The integers are the first nontrivial algebraic object and the prototype for most of what follows. Their divisibility theory — the division algorithm, the Euclidean algorithm, Bézout's identity, unique factorization — reappears almost verbatim for polynomial rings and, abstractly, for Euclidean domains. Quotienting by congruence produces , the first finite arithmetic, and inside it the units form the first interesting finite group. Everything here rests on one axiom about how the positive integers are ordered.

Well-ordering and induction

The integers themselves are not well-ordered (they descend forever), and neither are the positive rationals (the set has no least member). Well-ordering is a genuine property of , and it is logically equivalent to the principle that lets us prove statements about all positive integers at once.

The base case anchors the chain; the inductive step carries each case to the next. A frequently more convenient variant strengthens the hypothesis:

Strong induction lets the step invoke every earlier case, not just the immediate predecessor — exactly what a recursive procedure like the Euclidean algorithm needs. Well-ordering, ordinary induction, and strong induction are three statements of one fact: a descending chain of positive integers must terminate.

The proof is the standard template: were to have no least element, one shows by strong induction that no integer below any given bound can lie in , forcing , a contradiction. We take well-ordering as the starting axiom and derive everything downstream from it.

The division algorithm

Long division, made exact and unique.

The remainder is what is left after subtracting off as many copies of as fit. On the number line, the multiples of chop the line into intervals of length ; the integer falls into exactly one of them, and measures how far sits past the multiple on its left.

With and , the multiples of tile the line; lands in the block starting at , so the quotient is and the remainder is the overshoot.

Existence and uniqueness is the model well-ordering argument. For existence, consider the set of nonnegative values leaves after subtracting multiples of . is nonempty (take very negative), so by well-ordering it has a least element . Then ; and , since would put into below , contradicting minimality. For uniqueness, if with both remainders in , then , so ; but forces , hence and .4

Divisibility and greatest common divisors

For integers , we write ( divides ) when for some . Divisibility is reflexive and transitive, and it respects integer combinations: if and , then for all . This last fact drives every gcd argument below.

Condition (ii) is stronger than is the largest common divisor by size: it says is divisible by every other common divisor. The two descriptions agree for the integers, but (ii) is the version that carries over to general rings.

The Euclidean algorithm

Computing by listing divisors is hopeless for large inputs. Iterating the division algorithm is fast. The key identity is that dividing by leaves the gcd unchanged:

because is an integer combination of and (so common divisors of divide ), and symmetrically shows common divisors of divide ; the two pairs have identical common divisors. Replacing by the smaller pair and repeating drives the remainder strictly down, , a descending chain of nonnegative integers that must hit . The last nonzero remainder is the gcd.5

Computing : each line divides the previous divisor by the previous remainder; the divisor-remainder pair slides down until the remainder is , and the last nonzero remainder, , is the gcd.

Running the recursion the other way expresses the gcd back in terms of and , which the extended algorithm tracks directly.

Algorithm:ExtendedEuclid(a,b)\textsc{ExtendedEuclid}(a, b) — returns (d,x,y)(d, x, y) with d=gcd(a,b)d = \gcd(a,b) and ax+by=dax + by = d
  1. 1
    require a0a \geq 0, b0b \geq 0, not both zero
  2. 2
    if b=0b = 0 then
  3. 3
    return (a, 1, 0)(a,\ 1,\ 0)
  4. 4
    (d, x, y)ExtendedEuclid(b, amodb)(d,\ x',\ y') \gets \textsc{ExtendedEuclid}(b,\ a \bmod b)
  5. 5
    xyx \gets y'
  6. 6
    yxa/byy \gets x' - \lfloor a / b \rfloor \cdot y'
  7. 7
    return (d, x, y)(d,\ x,\ y)

Bézout's identity

The extended algorithm's output is a theorem in its own right.

The second sentence gives a slick proof independent of the algorithm. Let and let be its least element (well-ordering again). Dividing, with ; then is an integer combination of and , so . Being below , it cannot lie in , so and ; likewise . Any common divisor of divides , so .

The coefficients are not unique: the general solution to is

Bézout's identity recurs throughout elementary number theory. It gives modular inverses (below), proves Euclid's lemma (next), and explains why is invertible mod precisely when .

Primes and unique factorization

Bézout turns the definition into the property that governs factorization.

The distinction Euclid's lemma captures, that a prime dividing a product must divide a factor, is the abstract line between irreducible and prime elements developed in the factorization chapter. In the two coincide, which is why factorization is unique.

Existence is strong induction: is prime (done) or factors as with both smaller, each of which factors by hypothesis. Uniqueness is Euclid's lemma: if , then divides the right side, so by the lemma it divides some , and both being prime, ; cancel and induct. Once factorizations are unique, the gcd and lcm read off directly. Writing and over a shared prime list (zero exponents allowed),

For large integers, factoring is hard while the Euclidean algorithm is fast, so this formula is a structural identity, not a practical gcd method — a gap several modern cryptosystems are built on.

The integers modulo n

Fix and define when . This is an equivalence relation, written ( is congruent to mod ). Its classes are the residue classes

and by the division algorithm every integer is congruent to exactly one of (its remainder). So there are precisely classes, and they partition .

These operations require a well-definedness check: the answer must not depend on which representative is chosen.

The elements of are classes, not integers, so the arithmetic differs from : mod , the sum , the clock-arithmetic students already know. Under addition alone, is the model finite cyclic group; its addition table is a completely regular Latin square.

The addition table of . Each row is the previous shifted one step, and every residue appears once per row and once per column — the Latin-square signature of a group.

Units modulo n

Multiplication mod is less uniform. Some classes have multiplicative inverses and some do not. The invertible ones form a distinguished set.

Bézout identifies exactly which classes qualify.

The proof is also an algorithm: to invert , run the extended Euclidean algorithm on and to get , and read off . For and , the algorithm gives , so in . The non-units are the classes sharing a factor with ; each is a zero divisor, annihilating some nonzero class ( with ), so it can never be invertible.

Multiplication mod . The shaded classes are the units, coprime to ; their products stay shaded (closure), while are zero divisors and never invertible.

Closure of the units under multiplication (the shaded sub-table lands inside the shaded classes) is the first observation that is a group, developed in the group axioms lesson. Its size is counted by Euler's function.

For a prime every nonzero class is coprime to , so and is a field. More generally , and is multiplicative on coprime arguments, when , which with the prime-power formula evaluates at any from its factorization.

The unit group is where modular arithmetic becomes group theory. Its order controls the exponents that reduce to , giving Fermat's little theorem and Euler's theorem once Lagrange's theorem is available, and the cyclic structure of is the model finite cyclic group examined in the cyclic groups lesson.

Footnotes

  1. Dummit & Foote, Abstract Algebra, §0.2, property (1) — the Well-Ordering of : every nonempty subset of has a minimal element.
  2. Judson, Abstract Algebra: Theory and Applications, §2.1 — the First and Second (Strong) Principles of Mathematical Induction and their equivalence with the Principle of Well-Ordering (Lemma 2.1, Theorem 2.2).
  3. Dummit & Foote, Abstract Algebra, §0.2, property (5) — the Division Algorithm: unique with , .
  4. Judson, Abstract Algebra: Theory and Applications, §2.2, Theorem 2.3 — the Division Algorithm, proved by applying the Well-Ordering Principle to , with the uniqueness argument. 2
  5. Dummit & Foote, Abstract Algebra, §0.2, property (6) — the Euclidean Algorithm as iterated division, terminating because remainders form a strictly decreasing sequence of nonnegative integers.
  6. Dummit & Foote, Abstract Algebra, §0.2, property (7) and Exercise 4 — the gcd as a -linear combination , and the general solution , .
  7. Judson, Abstract Algebra: Theory and Applications, §2.2, Theorem 2.4 and Corollary 2.5 — existence of with , via the least positive element of .
  8. Dummit & Foote, Abstract Algebra, §0.2, properties (8)–(9) — primes, Euclid's lemma ( or ), and the Fundamental Theorem of Arithmetic with the gcd/lcm exponent formulas. 2
  9. Dummit & Foote, Abstract Algebra, §0.3 — , well-definedness of modular addition and multiplication (Theorem 3), and (Proposition 4). 2

╌╌ END ╌╌