Lagrange's four-square theorem
ProvedFamousTheorems.sum_four_squaresmathlibnumber-theory
Every natural number is a sum of four squares.
Conjectured by Bachet, proved by Lagrange in 1770. Four is optimal: is not a sum of three squares, and indeed Legendre characterised the numbers needing four as those of the form .
The standard proof combines Euler's four-square identity — the product of two sums of four squares is again one, reflecting multiplicativity of the quaternion norm — with a descent argument showing that if some multiple of a prime is a sum of four squares then so is a smaller one.
Preamble
import Mathlib
Formal statement
namespace FamousTheorems theorem sum_four_squares : ∀ n : ℕ, ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n := by sorry end FamousTheorems
Source
One of Freek Wiedijk's "100 theorems"; formalized in Mathlib. Proof here reduces to the corresponding Mathlib result.