Public Mathlib landmark · existing upstream theorem · read-only

Number theory · existing Mathlib theorem

Lagrange's Four-Square Theorem

For every natural number n, there are four natural numbers—some of which may be zero—whose squares add exactly to n.

Four separate status axes

Upstream indexedPinned source bytes verified locally
Locally reproducedExact upstream declaration replayed
Reviewed page2 of 3 presentation reviews recorded
Accepted Atlas resultNot recorded for the preferred artifact

These states distinguish upstream identity, local reproduction, review, and Atlas acceptance. This page is part of the public, read-only Mathlib landmark collection.

Formal orientation

Statement map

Statement map for Lagrange's Four-Square TheoremEvery natural number is a sum of four squares of natural numbers. The pinned upstream declaration is Nat.sum_four_squares. The exact checked statement is theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n.Mathematical readingEvery natural number isa sum of four squares ofnatural numbers.Pinned declarationmathlib ·Nat.sum_four_squaresExact checked formtheoremNat.sum_four_squares (n: ℕ) : ∃ a b c d : ℕ, a^ 2 + b ^ 2 + c ^ 2 + d^ 2 = nStatement map for Lagrange's Four-Square TheoremEvery natural number is a sum of four squares of natural numbers. The pinned upstream declaration is Nat.sum_four_squares. The exact checked statement is theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n.Mathematical readingEvery natural number isa sum of four squares ofnatural numbers.Pinned declarationmathlib ·Nat.sum_four_squaresExact checked formtheoremNat.sum_four_squares (n: ℕ) : ∃ a b c d : ℕ, a^ 2 + b ^ 2 + c ^ 2 + d^ 2 = n

This deterministic map orients the reader from the mathematical summary to the pinned declaration and exact checked form. The HTML statement below is authoritative.

The theorem at a glance

Lagrange's Four-Square Theorem at a glance

A source-bound editorial overview of the exact Mathlib formulation. The image is explanatory; the statement map, formal type, and pinned source remain authoritative.

Every natural number has a representation as four natural-number squares, with zero terms allowed. Generated explanation only; the exact HTML statement and pinned source are authoritative.
Detailed visual description

The poster connects the exact four-square statement to Euler multiplication, the modular prime seed, least-multiplier descent, and final multiplicative induction without adding a representation count or uniqueness claim.

Euler multiplication and a least-multiplier prime descent assemble four-square representations for every natural number. Generated explanation only; the exact HTML statement and pinned source are authoritative.
Detailed visual description

The recurring four-arm rosette represents one sum of four squares. Euler's braid preserves that form under multiplication, the multiplier around a prime shrinks to one, and prime representations then assemble into a representation of an arbitrary natural number.

Complementary intuition

A mathematical landmark

Lagrange's theorem gives a universal additive representation of every natural number. Mathlib's proof combines Euler's four-square identity, prime descent, and multiplicative induction.

The low-text schematic gives the theorem a visual identity; it does not replace the source-bound poster or exact statement.

Authoritative formal type

Exact Mathlib statement

theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n
Selected evidence declaration text
theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n

Proof architecture

Euler multiplication and Lagrange descent

5 curated stages

Mathlib proves that every natural number is a sum of four natural-number squares by establishing Euler's multiplicative identity, representing a multiple of each prime, descending a least positive multiplier to one, and extending prime representations to all naturals by multiplicative induction.

These source-anchored stages explain the retained Mathlib proof route. They are generated explanations, not proof evidence or an extracted Lean proof-term dependency graph.

  1. Two four-square representations multiply into another

    Euler's identity combines two four-coordinate representations while preserving the sum-of-four-squares form of their product.

    (sum of four squares) · (sum of four squares) = sum of four squares

    The proof first establishes Euler's four-square identity in a commutative ring and then a natural-number version using integer absolute values. This identity supplies the multiplicative step used both in prime descent and in the final induction.

  2. Start with four squares equal to a small positive multiple of a prime

    A modular sum-of-two-squares argument yields a four-square representation of k p with the multiplier strictly between zero and p.

    0 < k < p and a²+b²+c²+d² = k p

    For an odd prime, Mathlib uses a congruence for a sum of two squares modulo p, adds the square of one and the square of zero, and extracts a positive multiplier smaller than the prime. The prime two is handled directly.

  3. Minimality prepares a smaller multiplier

    Choose the least represented positive multiplier; halve it when even, or replace all four coordinates by least absolute residues when odd.

    m minimal; either m/2 or 0 < r < m

    Nat.findX selects a minimal positive m with four squares equal to m p. If m is even, a parity lemma divides the representation by two. If m is odd, each coordinate is replaced by a congruent representative with absolute value less than half m, producing a positive quotient r<m.

  4. The four-square identity completes the descent

    Euler's identity combines the reduced residues with the original representation and, after division, represents r p, contradicting minimality.

    m = 1; hence p = a²+b²+c²+d²

    In the odd case, a reordered four-square representation of m r is multiplied by the representation of m p. The Euler outputs are all divisible by m; division yields a four-square representation of r p with r<m. Together with the even case, this makes every assumption m>1 impossible, so the prime itself is a sum of four squares.

  5. Multiplicative induction reaches every natural number

    Zero and one are immediate, primes use the descent, and products use Euler's identity, completing multiplicative induction.

    ∀ n : ℕ, ∃ a b c d : ℕ, a²+b²+c²+d²=n

    Nat.sum_four_squares invokes Nat.recOnMul. The zero and one cases use representations with zero terms; the prime case invokes the theorem from page 4; and the product case combines two inductive representations with Euler's identity. Therefore every natural number has a four-square representation.

Claim boundary

No new theorem is claimed

This target indexes Mathlib's existence theorem that every natural number is a sum of four squares of natural numbers. It does not count representations, require all four terms to be nonzero, or claim a new proof.

Provenance

Origin and evidence stay separate

Existing declaration
Nat.sum_four_squares in mathlib
Relationship
The checked artifact is the upstream declaration itself
Preferred checked artifact
artifact.library.mathlib.lagrange-four-square-theorem.v001
Source handling
Verified upstream reference; no mirrored source package