Lagrange's Four-Square Theorem
Statement
Lagrange's four-square theorem (1770): every non-negative integer can be expressed as the sum of four perfect squares:
Note that is allowed, so the four squares need not be positive. By contrast, not every integer is a sum of three squares (see Legendre's Three-Square TheoremLegendre's Three-Square TheoremA positive integer is a sum of three squares iff it is not of the form 4^a(8b+7)Read more →).
Visualization
Representations of through as sums of four squares (minimal number of non-zero terms where possible):
| Representation | |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
The number is the smallest positive integer that requires all four squares to be non-zero.
Proof Sketch
- Euler's four-square identity. The product of two sums of four squares is again a sum of four squares:
This reduces the theorem to prime numbers. 2. Every prime is a sum of four squares. For : . For an odd prime : show that is a sum of two squares mod , then apply the pigeonhole principle to find with . This gives for some . A descent argument reduces to . 3. Every integer is a product of primes (by the Fundamental Theorem of ArithmeticFundamental Theorem of ArithmeticEvery integer greater than 1 has a unique prime factorizationRead more →), so Euler's identity propagates the four-square property.
Connections
This theorem generalises Sum of Two SquaresSum of Two SquaresA prime is a sum of two perfect squares if and only if it equals 2 or is congruent to 1 mod 4Read more →, which characterises exactly which integers are sums of two squares. The proof technique via quaternion norms is a precursor to the Cayley–Dickson construction, also appearing in Cauchy–Schwarz InequalityCauchy–Schwarz InequalityThe inner product of two vectors is bounded by the product of their normsRead more → proofs via inner products.
Lean4 Proof
import Mathlib.NumberTheory.SumFourSquares
/-- Lagrange's four-square theorem: every natural number is a sum of four squares.
Direct alias of `Nat.sum_four_squares` in Mathlib. -/
theorem lagrange (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n :=
Nat.sum_four_squares n
/-- Explicit witness: 7 = 2² + 1² + 1² + 1². -/
theorem four_sq_7 : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = 7 :=
⟨2, 1, 1, 1, by norm_num⟩Referenced by
- Legendre's Three-Square TheoremNumber Theory
- Sum of Two SquaresNumber Theory
- Chebyshev's Bounds for π(n)Number Theory