{
  "id": "8534",
  "ident": "NS.08534",
  "slug": "wikipedia-sumofthreecubes",
  "title": "Sum of three cubes",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Any rational number is a sum of three rational cubes.\n\nFirst proved by Ryley in 1825, which can be found in [Ri1930].\nThe below parametrization is brought from the MSE answer [MSE].\n\n[Ri1930] Richmond, H. W. \"On Rational Solutions of $x^3 + y^3 + z^3 = R$.\" Proceedings of the Edinburgh Mathematical Society 2.2 (1930): 92-100.\n[MSE] Kieren MacMillan, Proving that any rational number can be represented as the sum of the cubes of three rational numbers, https://math.stackexchange.com/q/4480969",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "SumOfThreeCubes.isSumOfThreeCubesRat_any",
  "statement_lean": "theorem isSumOfThreeCubesRat_any (r : ℚ) : IsSumOfThreeCubes r",
  "challenge_source": "/-\nCopyright 2025 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Sum of three cubes\n\nAn integer `n : ℤ` can be written as a sum of three cubes (of integers) if and only if\n`n` is not `4` or `5` mod `9`.\n\n*References:*\n - [Wikipedia](https://en.wikipedia.org/wiki/Sums_of_three_cubes)\n - [mathoverflow/100324](https://mathoverflow.net/a/100324)\nasked by user [*David Feldman*](https://mathoverflow.net/users/10909/david-feldman)\n-/\n\n@[expose] public section\n\nnamespace SumOfThreeCubes\n\nvariable {R : Type*} [Ring R]\n\n/-- The predicate that `n : R` is a sum of three cubes. -/\ndef IsSumOfThreeCubes (n : R) : Prop :=\n  ∃ x y z : R, n = x^3 + y^3 + z^3\n\n@[category test, AMS 11]\ntheorem isSumOfThreeCubes_2 : IsSumOfThreeCubes (2 : ℤ) :=\n  ⟨1, 1, 0, by norm_num⟩\n\n@[category test, AMS 11]\ntheorem isSumOfThreeCubes_33 : IsSumOfThreeCubes (33 : ℤ) :=\n  ⟨8866128975287528, -8778405442862239, -2736111468807040, by norm_num⟩\n\n@[category test, AMS 11]\ntheorem isSumOfThreeCubes_42 : IsSumOfThreeCubes (42 : ℤ) :=\n  ⟨-80538738812075974, 80435758145817515, 12602123297335631, by norm_num⟩\n\n@[category test, AMS 11]\ntheorem mod_9_of_isSumOfThreeCubes (n : ℤ) (hn : IsSumOfThreeCubes n) :\n    ¬(n ≡ 4 [ZMOD 9] ∨ n ≡ 5 [ZMOD 9]) := by\n  rw [show (9 : ℤ) = (9 : ℕ) from rfl, ← ZMod.intCast_eq_intCast_iff _ _ 9,\n    ← ZMod.intCast_eq_intCast_iff _ _ 9]\n  obtain ⟨x, y, z, hn⟩ := hn\n  replace hn := congrArg (fun x : ℤ ↦ (x : ZMod 9)) hn\n  simp only [Int.cast_add, Int.cast_pow] at hn\n  generalize (n : ZMod 9) = n at *\n  generalize (x : ZMod 9) = x at *\n  generalize (y : ZMod 9) = y at *\n  generalize (z : ZMod 9) = z at *\n  decide +revert\n\n/--\nAny rational number is a sum of three rational cubes.\n\nFirst proved by Ryley in 1825, which can be found in [Ri1930].\nThe below parametrization is brought from the MSE answer [MSE].\n\n[Ri1930] Richmond, H. W. \"On Rational Solutions of $x^3 + y^3 + z^3 = R$.\" Proceedings of the Edinburgh Mathematical Society 2.2 (1930): 92-100.\n[MSE] Kieren MacMillan, Proving that any rational number can be represented as the sum of the cubes of three rational numbers, https://math.stackexchange.com/q/4480969\n-/\n@[category research solved, AMS 11]\ntheorem isSumOfThreeCubesRat_any (r : ℚ) : IsSumOfThreeCubes r := by\n  by_cases h : r = 0\n  · exact ⟨0, 0, 0, by norm_num; exact h⟩\n  · let x := (r ^ 6 + 45 * r ^ 4 - 81 * r ^ 2 + 27) / (6 * r * (r ^ 2 + 3) ^ 2)\n    let y := (3 - r ^ 2) * (6 * r) / (r ^ 2 + 3) ^ 2\n    let z := (r ^ 2 + 6 * r + 3) * (- r ^ 2 + 6 * r - 3) / (6 * r * (r ^ 2 + 3))\n    use x, y, z\n    simp only [x, y, z]\n    field_simp\n    ring\n\n\n/-- An integer `n : ℤ` can be written as a sum of three cubes (of integers) if and only if\n`n` is not `4` or `5` mod `9`. -/\n@[category research open, question, AMS 11]\ntheorem isSumOfThreeCubes_iff_mod_9 :\n    ∀ n : ℤ, IsSumOfThreeCubes n ↔ ¬(n ≡ 4 [ZMOD 9] ∨ n ≡ 5 [ZMOD 9]) := by\n  sorry\n\nend SumOfThreeCubes\n",
  "statement_hash": "5ba2edab4e93687d150cd76a88cf16bbf8d8a4d978f8dabd6594d3fe8db49c81",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}