{
  "artifactId": "artifact.library.mathlib.lagrange-four-square-theorem.v001",
  "candidateOnly": false,
  "category": "Number theory",
  "claimBoundary": "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.",
  "collectionSlug": "landmark-theorems-in-mathlib",
  "exactFormalStatement": "theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n",
  "family": "Additive number theory",
  "id": "library.mathlib.lagrange-four-square-theorem.v001",
  "links": {
    "collection": "/collections/landmark-theorems-in-mathlib/",
    "collectionData": "/data/collections/mathlib-landmarks.json",
    "entry": "/library-theorems/lagrange-four-square-theorem/",
    "entryData": "/data/library-theorems/lagrange-four-square-theorem.json",
    "evidence": "/proofs/artifact.library.mathlib.lagrange-four-square-theorem.v001.html",
    "evidenceData": "/data/proofs/artifact.library.mathlib.lagrange-four-square-theorem.v001.evidence.json",
    "source": "/sources/upstream/lagrange-four-square-theorem/"
  },
  "landmark": {
    "completeFormalType": "theorem Nat.sum_four_squares (n : ℕ) : ∃ a b c d : ℕ, a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = n",
    "concepts": [
      "sum of squares",
      "Euler four-square identity",
      "prime descent",
      "minimal multiplier",
      "multiplicative induction"
    ],
    "plainLanguage": "For every natural number n, there are four natural numbers—some of which may be zero—whose squares add exactly to n.",
    "poster": {
      "alt": "An ivory number-theory poster shows exactly four square tiles, Euler multiplication rosettes, a shrinking prime multiplier, the four-square equation, five proof movements, and existence-only scope.",
      "byteSize": 2689192,
      "caption": "Every natural number has a representation as four natural-number squares, with zero terms allowed.",
      "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.",
      "derivatives": [
        {
          "byteSize": 140184,
          "height": 960,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-poster-v1-640.webp",
          "sha256": "sha256:fd4686c16c7dc2990df68d3a3eb59a41a06f8263fe2ab49657209ef3b301ae6d",
          "width": 640
        },
        {
          "byteSize": 290506,
          "height": 1536,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-poster-v1-1024.webp",
          "sha256": "sha256:10c37e565212bea8302e466b70b368ea0a4805f0b23a8095efc351ab085e5de6",
          "width": 1024
        }
      ],
      "generatedAt": "2026-07-22T01:26:27Z",
      "height": 1536,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-poster-v1.png",
      "sha256": "sha256:e529768f32751cb0d978dcfcaedadcd0e6081920de997586cac89bbc03b630fd",
      "title": "Lagrange's Four-Square Theorem at a glance",
      "width": 1024,
      "kind": "theorem_poster",
      "transcript": "NUMBER THEORY · FOUR SQUARES\nLAGRANGE'S FOUR-SQUARE THEOREM\nEvery natural number is a sum of four natural-number squares\nn = a² + b² + c² + d²\nFOUR-SQUARE REPRESENTATIONS MULTIPLY\nHOW THE CHECKED ROUTE MOVES\n1 · Euler's identity preserves four-square form under products\n2 · Seed a multiple of each prime with four squares\n3 · Choose the smallest possible positive multiplier\n4 · Descend to multiplier one\n5 · Induct over prime multiplication\nEXACT SCOPE\nExistence only. Zero terms are allowed; no representation count or uniqueness."
    },
    "visual": {
      "alt": "Four-armed square-tipped rosettes combine through a gold Euler braid while nested multiplier collars descend around one prime token before final multiplicative assembly.",
      "byteSize": 3228808,
      "caption": "Euler multiplication and a least-multiplier prime descent assemble four-square representations for every natural number.",
      "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.",
      "derivatives": [
        {
          "byteSize": 63306,
          "height": 427,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-schematic-v1-640.webp",
          "sha256": "sha256:0be94e837fc05ffd2fe7fe699d4395b8ea91e24df83a6eaf4e734e5559a35b23",
          "width": 640
        },
        {
          "byteSize": 213864,
          "height": 800,
          "mediaType": "image/webp",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-schematic-v1-1200.webp",
          "sha256": "sha256:c0ab7037c56dc70a3ea53a7dafa918d46acde194ef3ae20cf624b46ee454d694",
          "width": 1200
        }
      ],
      "generatedAt": "2026-07-21T23:43:52Z",
      "height": 1024,
      "mediaType": "image/png",
      "modelRequested": "gpt-image-2",
      "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/theorem-schematic-v1.png",
      "sha256": "sha256:816f20be43ce4e3e0ac2bed6b0138bd943a313da078a6ab674c88b4d238560b8",
      "title": "Lagrange's Four-Square Theorem schematic",
      "width": 1536
    },
    "walkthrough": {
      "introduction": "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.",
      "pages": [
        {
          "alt": "Two four-armed engraved rosettes with square ivory tips enter an antique-gold braid and emerge as one four-armed rosette.",
          "byteSize": 3260260,
          "caption": "Euler's identity combines two four-coordinate representations while preserving the sum-of-four-squares form of their product.",
          "description": "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.",
          "derivatives": [
            {
              "byteSize": 44484,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-01-v1-640.webp",
              "sha256": "sha256:074b949d71f06d162097194b2ea09ee9d7051219b56ea3eb1c11be5c29972513",
              "width": 640
            },
            {
              "byteSize": 180714,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-01-v1-1200.webp",
              "sha256": "sha256:34a008bd346d692a9424a5bd4be6d2ddd267ad420c86813ffc2a8c66bc05454c",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-21T23:28:42Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-01-v1.png",
          "sha256": "sha256:5bd6da9b6306fefb2fa007bb2e553490bc8d565f22c65cede38d874a1d145c1b",
          "title": "Two four-square representations multiply into another",
          "width": 1536,
          "equation": "(sum of four squares) · (sum of four squares) = sum of four squares",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 1
        },
        {
          "alt": "A four-armed representation rosette surrounds a faceted antique-gold prime token and an emerald multiplier collar prepared for descent.",
          "byteSize": 2885662,
          "caption": "A modular sum-of-two-squares argument yields a four-square representation of k p with the multiplier strictly between zero and p.",
          "description": "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.",
          "derivatives": [
            {
              "byteSize": 33936,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-02-v1-640.webp",
              "sha256": "sha256:160b4abce8d45196f6c623bfcbba1ea2cb0cd6bc0ad69f8877d50b0ed5df5936",
              "width": 640
            },
            {
              "byteSize": 129766,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-02-v1-1200.webp",
              "sha256": "sha256:c54fd3953edebfda57f79b5fc385e92a4dcbe5a3561769fd362f6732ac94f5cb",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-22T01:26:27Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-02-v1.png",
          "sha256": "sha256:cef61e2b4c7714df3e8a93c3677a92d4aaad09b1dfb29df0b4c1fcb31b456a96",
          "title": "Start with four squares equal to a small positive multiple of a prime",
          "width": 1536,
          "equation": "0 < k < p and a²+b²+c²+d² = k p",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 2
        },
        {
          "alt": "Cobalt residue beads move within the four square tiles while nested emerald collars shrink concentrically around the same gold prime token.",
          "byteSize": 2922633,
          "caption": "Choose the least represented positive multiplier; halve it when even, or replace all four coordinates by least absolute residues when odd.",
          "description": "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.",
          "derivatives": [
            {
              "byteSize": 45404,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-03-v1-640.webp",
              "sha256": "sha256:201570987f8b21d2be2f9934e1a5b13aaacb86c57fc3c71397d7f160c20d228c",
              "width": 640
            },
            {
              "byteSize": 155710,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-03-v1-1200.webp",
              "sha256": "sha256:bde7a3324511adef4e668efbf9daa8e56e76ad30c7a292446398c89178194bbb",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-21T23:36:12Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-03-v1.png",
          "sha256": "sha256:1b0f98823bc3d38e49b68b3467d95fb43770b718dc30067f7321401f1f0b706e",
          "title": "Minimality prepares a smaller multiplier",
          "width": 1536,
          "equation": "m minimal; either m/2 or 0 < r < m",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 3
        },
        {
          "alt": "The reduced four-armed rosette and original representation rejoin through the gold Euler braid, leaving the prime token at a unit-sized collar beside one restrained red minimality fracture.",
          "byteSize": 2826175,
          "caption": "Euler's identity combines the reduced residues with the original representation and, after division, represents r p, contradicting minimality.",
          "description": "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.",
          "derivatives": [
            {
              "byteSize": 32384,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-04-v1-640.webp",
              "sha256": "sha256:28416875ed95e33a18c2986e6f1d6fba51ebaec84cb339073cc23db89fe0edbb",
              "width": 640
            },
            {
              "byteSize": 119658,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-04-v1-1200.webp",
              "sha256": "sha256:f43e3b2f462fcc999f8bf29e9eebd15304cb024c92281cb647c254662de3f8da",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-21T23:39:20Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-04-v1.png",
          "sha256": "sha256:4321cc423a5f711e6a2dbded6ab2011b19027e9d82fd842756b9906861fd10c1",
          "title": "The four-square identity completes the descent",
          "width": 1536,
          "equation": "m = 1; hence p = a²+b²+c²+d²",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 4
        },
        {
          "alt": "Several four-armed prime rosettes combine through recurring gold braids into one final complete four-square rosette, with blank ivory tiles allowed.",
          "byteSize": 3019359,
          "caption": "Zero and one are immediate, primes use the descent, and products use Euler's identity, completing multiplicative induction.",
          "description": "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.",
          "derivatives": [
            {
              "byteSize": 42124,
              "height": 427,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-05-v1-640.webp",
              "sha256": "sha256:f258dbe31978015cec8485a745ab781eb0791e0bfadc97aa8ee89eb753a0d79b",
              "width": 640
            },
            {
              "byteSize": 152704,
              "height": 800,
              "mediaType": "image/webp",
              "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-05-v1-1200.webp",
              "sha256": "sha256:5344604f9533057c31f7210902c70129a9fc18219660252a7e1ce1e5357228bd",
              "width": 1200
            }
          ],
          "generatedAt": "2026-07-21T23:51:47Z",
          "height": 1024,
          "mediaType": "image/png",
          "modelRequested": "gpt-image-2",
          "publicPath": "/assets/library-theorems/lagrange-four-square-theorem/proof-walkthrough-05-v1.png",
          "sha256": "sha256:1554c3157497cc74d831b5a09874a52dca8cfc11602a6a4ad0eb1440151643af",
          "title": "Multiplicative induction reaches every natural number",
          "width": 1536,
          "equation": "∀ n : ℕ, ∃ a b c d : ℕ, a²+b²+c²+d²=n",
          "kind": "proof_walkthrough_page",
          "sequenceIndex": 5
        }
      ],
      "title": "Euler multiplication and Lagrange descent"
    },
    "whyLandmark": "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."
  },
  "nonClaims": [
    "Proof Atlas did not originate Lagrange's Four-Square Theorem or Mathlib's declaration.",
    "The theorem asserts existence only: it neither counts representations nor requires every term to be nonzero.",
    "The generated explanation and visuals are not proof evidence."
  ],
  "publicExportEligible": true,
  "relationship": "upstream_direct",
  "schemaVersion": "library-theorem-entry-data.v1",
  "statementId": "statement.library.mathlib.lagrange-four-square-theorem.v001",
  "statusAxes": {
    "acceptedAtlasResult": "Not recorded for the preferred artifact",
    "locallyReproduced": "Exact upstream declaration replayed",
    "reviewedPage": "2 of 3 presentation reviews recorded",
    "upstreamIndexed": "Pinned source bytes verified locally"
  },
  "summary": "Every natural number is a sum of four squares of natural numbers.",
  "targetId": "target.library.mathlib.lagrange-four-square-theorem.v001",
  "title": "Lagrange's Four-Square Theorem",
  "upstreamOrigin": {
    "declarationName": "Nat.sum_four_squares",
    "immutableSourceUrl": "https://github.com/leanprover-community/mathlib4/blob/5e932f97dd25535344f80f9dd8da3aab83df0fe6/Mathlib/NumberTheory/SumFourSquares.lean#L199",
    "packageName": "mathlib",
    "repositoryUrl": "https://github.com/leanprover-community/mathlib4",
    "sourceArtifactHash": "sha256:1bc309254aa0aabc39c9802eb6ec2358468f7b4d4cf13efdde8888995558eb4a",
    "sourceByteLength": 10569,
    "sourceCommit": "5e932f97dd25535344f80f9dd8da3aab83df0fe6",
    "sourceFile": "Mathlib/NumberTheory/SumFourSquares.lean",
    "sourceLine": 199,
    "verificationKind": "git_worktree"
  },
  "publicPresentationReview": {
    "status": "reviewed"
  }
}
