{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nCall an integer a 4-sum if it is $x_1^2 + x_2^2 + x_3^2 + x_4^2$ with integers $x_i$.\n\n**Reduction to odd primes.**\n\n1. By [[Euler's four-square identity|08WTN6SCQ6]], the product of two 4-sums is a 4-sum.\n2. We have $0 = 0^2 + 0^2 + 0^2 + 0^2$, $1 = 1^2 + 0^2 + 0^2 + 0^2$ and $2 = 1^2 + 1^2 + 0^2 + 0^2$.\n3. Each $n \\ge 1$ is a product of [[primes|0SN0MAEKYX]], by [[existence of prime factorization|020K0X7HVR]]. By step 1 and [[induction|0ASJVEFA9J]] on the number of factors, it suffices to show that each odd prime $p$ is a 4-sum.\n\n**A multiple of $p$ that is a 4-sum.** Fix an odd prime $p$ and put $h = (p - 1)/2$.\n\n4. If $0 \\le a \u003c a' \\le h$ and $a^2 \\equiv a'^2 \\pmod p$, then $p \\mid (a' - a)(a' + a)$. But $0 \u003c a' - a \u003c p$ and $0 \u003c a' + a \u003c p$, against [[Euclid's lemma|051VYKA1EX]].\n5. So the $h + 1$ numbers $a^2$ with $0 \\le a \\le h$ are distinct [[modulo|0TPW25CBN6]] $p$. Likewise the $h + 1$ numbers $-1 - b^2$ with $0 \\le b \\le h$ are distinct modulo $p$.\n6. Together these are $2h + 2 = p + 1$ numbers, with only $p$ residues. By the [[pigeonhole principle|0HGVCWQGY3]] and step 5, some $a^2 \\equiv -1 - b^2 \\pmod p$.\n7. So $a^2 + b^2 + 1^2 + 0^2 = n_0 p$ for an integer $n_0 \\ge 1$. Also $n_0 p \\le 2h^2 + 1 \u003c p^2$, so $n_0 \u003c p$.\n\n**Descent.**\n\n8. By the [[well-ordering principle|01BX15HSRR]], let $m$ be the least positive integer with $mp$ a 4-sum. By step 7, $1 \\le m \u003c p$. Write $mp = \\sum_i x_i^2$. We show $m = 1$, arguing by [[descent|0EFYCFHYFG]].\n9. Suppose $m$ is even. Then $\\sum_i x_i^2$ is even, so an even number of the $x_i$ are odd. Renumber so that $x_1 \\equiv x_2$ and $x_3 \\equiv x_4 \\pmod 2$.\n10. Then $\\frac{m}{2} p = \\left(\\frac{x_1 + x_2}{2}\\right)^2 + \\left(\\frac{x_1 - x_2}{2}\\right)^2 + \\left(\\frac{x_3 + x_4}{2}\\right)^2 + \\left(\\frac{x_3 - x_4}{2}\\right)^2$, with integer terms. This contradicts the minimality of $m$. So $m$ is odd.\n11. Suppose $m \u003e 1$, so $m \\ge 3$. By the [[division algorithm|0CHQKZFK5S]], choose $y_i \\equiv x_i \\pmod m$ with $\\abs{y_i} \u003c m/2$. This is possible as $m$ is odd.\n12. Then $\\sum_i y_i^2 \\equiv \\sum_i x_i^2 = mp \\equiv 0 \\pmod m$. Write $\\sum_i y_i^2 = mr$ with $r \\ge 0$. Since each $y_i^2 \u003c m^2/4$, we get $mr \u003c m^2$, so $r \u003c m$.\n13. If $r = 0$, every $y_i = 0$, so $m \\mid x_i$ for each $i$. Then $m^2 \\mid mp$, so $m \\mid p$. This is impossible for $1 \u003c m \u003c p$. So $1 \\le r \u003c m$.\n14. Apply Euler's identity with $a_i = x_i$ and $b = (y_1, -y_2, -y_3, -y_4)$. Then $(mp)(mr) = z_1^2 + z_2^2 + z_3^2 + z_4^2$ with\n$$z_1 = x_1y_1 + x_2y_2 + x_3y_3 + x_4y_4, \\quad z_2 = -x_1y_2 + x_2y_1 - x_3y_4 + x_4y_3,$$\n$$z_3 = -x_1y_3 + x_2y_4 + x_3y_1 - x_4y_2, \\quad z_4 = -x_1y_4 - x_2y_3 + x_3y_2 + x_4y_1.$$\n15. Modulo $m$, replace each $y_i$ by $x_i$. Then $z_1 \\equiv \\sum_i x_i^2 \\equiv 0$. In $z_2$, $z_3$, $z_4$ the terms cancel in pairs, for example $z_2 \\equiv -x_1x_2 + x_2x_1 - x_3x_4 + x_4x_3 = 0$.\n16. So $m$ divides each $z_i$. Dividing step 14 by $m^2$ gives $rp = \\sum_i (z_i/m)^2$, a 4-sum.\n17. Since $1 \\le r \u003c m$, this contradicts the minimality of $m$. So $m = 1$, and $p$ is a 4-sum.\n18. By step 3, every natural number $n$ is a sum of four squares.\n\n## Idea\n\nEuler's identity reduces the problem to primes. The pigeonhole principle gives a multiple $mp$ of $p$ that is a sum of four squares. If $m \u003e 1$, reducing the $x_i$ modulo $m$ and using the identity again gives a smaller multiple, so the least such $m$ is $1$.\n",
  "commit": "68a8c3dc73fd55004b2796431c607c30960d1a85",
  "front": {
    "kind": "proof",
    "msc": [
      "11E25"
    ],
    "name": "Proof of Lagrange's four-square theorem by descent",
    "proves": "0KYYSMEVHH",
    "sources": [
      {
        "locator": "The classical proof",
        "url": "https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem"
      }
    ],
    "tag": "GBQDYYA8SE",
    "uses": [
      "08WTN6SCQ6",
      "020K0X7HVR",
      "0HGVCWQGY3",
      "01BX15HSRR",
      "051VYKA1EX",
      "0CHQKZFK5S",
      "0TPW25CBN6",
      "0SN0MAEKYX",
      "0EFYCFHYFG",
      "0ASJVEFA9J"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/GBQDYYA8SE/",
  "links": [
    {
      "field": "proves",
      "target": "0KYYSMEVHH"
    },
    {
      "field": "uses",
      "target": "08WTN6SCQ6"
    },
    {
      "field": "uses",
      "target": "020K0X7HVR"
    },
    {
      "field": "uses",
      "target": "0HGVCWQGY3"
    },
    {
      "field": "uses",
      "target": "01BX15HSRR"
    },
    {
      "field": "uses",
      "target": "051VYKA1EX"
    },
    {
      "field": "uses",
      "target": "0CHQKZFK5S"
    },
    {
      "field": "uses",
      "target": "0TPW25CBN6"
    },
    {
      "field": "uses",
      "target": "0SN0MAEKYX"
    },
    {
      "field": "uses",
      "target": "0EFYCFHYFG"
    },
    {
      "field": "uses",
      "target": "0ASJVEFA9J"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/GBQDYYA8SE.md",
  "msc": [
    "11E25"
  ],
  "name": "Proof of Lagrange's four-square theorem by descent",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/GBQ/GBQDYYA8SE.md",
  "status": null,
  "tag": "GBQDYYA8SE",
  "uri": "m2://GBQDYYA8SE",
  "url": "https://math2.tamnd.com/wiki/proof-of-lagranges-four-square-theorem-by-descent/",
  "writing": {
    "tag": "GBQDYYA8SE",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
