{
  "id": "797",
  "ident": "NS.00797",
  "slug": "erdos-1148",
  "title": "Erdős Problem 1148",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Can every large integer $n$ be written as $n=x^2+y^2-z^2$ with $\\max(x^2,y^2,z^2)\\leq n$?\n\nThis was proved affirmatively by Chojecki [Ch26], using a Duke-type equidistribution theorem.\nA Lean formalisation of the reduction (conditional on a Duke-type equidistribution theorem) exists;\nsee the [forum discussion](https://www.erdosproblems.com/forum/thread/1148#post-4849). The linked\nformal proof (plby/lean-proofs) removes the Duke hypothesis; it is stated over `ℤ`, as\n`∃ N, ∀ n ≥ N, ∃ x y z : ℤ, n = x ^ 2 + y ^ 2 - z ^ 2 ∧ max (x ^ 2) (max (y ^ 2) (z ^ 2)) ≤ n`,\nwhich gives the statement below by taking absolute values.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos1148.erdos_1148",
  "statement_lean": "theorem erdos_1148 : ∀ᶠ n in atTop, Erdos1148Prop n",
  "challenge_source": "/-\nCopyright 2026 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# Erdős Problem 1148\n\n*References:*\n- [erdosproblems.com/1148](https://www.erdosproblems.com/1148)\n- [Ch26] P. Chojecki, [Bounded Representations by $x^2 + y^2 - z^2$](https://www.ulam.ai/research/erdos1148-full.pdf) (2026)\n- [Va99] Various, Some of Paul's favorite problems. Booklet produced for the conference \"Paul Erdős\n  and his mathematics\", Budapest, July 1999 (1999).\n-/\n\n@[expose] public section\n\nopen Filter\n\nnamespace Erdos1148\n\n/--\nA natural number $n$ which can be written as $n$ if $n = x^2 + y^2 - z^2$ with $\\max(x^2, y^2, z^2)\n\\leq n$.\n-/\ndef Erdos1148Prop (n : ℕ) : Prop :=\n  ∃ x y z : ℕ, n = x ^ 2 + y ^ 2 - z ^ 2 ∧ x ^ 2 ≤ n ∧ y ^ 2 ≤ n ∧ z ^ 2 ≤ n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nCan every large integer $n$ be written as $n=x^2+y^2-z^2$ with $\\max(x^2,y^2,z^2)\\leq n$?\n\nThis was proved affirmatively by Chojecki [Ch26], using a Duke-type equidistribution theorem.\nA Lean formalisation of the reduction (conditional on a Duke-type equidistribution theorem) exists;\nsee the [forum discussion](https://www.erdosproblems.com/forum/thread/1148#post-4849). The linked\nformal proof (plby/lean-proofs) removes the Duke hypothesis; it is stated over `ℤ`, as\n`∃ N, ∀ n ≥ N, ∃ x y z : ℤ, n = x ^ 2 + y ^ 2 - z ^ 2 ∧ max (x ^ 2) (max (y ^ 2) (z ^ 2)) ≤ n`,\nwhich gives the statement below by taking absolute values.\n-/\n@[category research solved, question, AMS 11, formal_proof using lean4 at\n  \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos1148.lean#L238\"]\ntheorem erdos_1148 : ∀ᶠ n in atTop, Erdos1148Prop n := by\n  sorry\n\n/--\nThe largest integer known which cannot be written this way is $6563$.\n-/\nprivate instance (n : ℕ) : Decidable (Erdos1148Prop n) :=\n  decidable_of_iff\n    (∃ x ∈ Finset.range (Nat.sqrt n + 1), ∃ y ∈ Finset.range (Nat.sqrt n + 1),\n      ∃ z ∈ Finset.range (Nat.sqrt n + 1),\n      n = x ^ 2 + y ^ 2 - z ^ 2 ∧ x ^ 2 ≤ n ∧ y ^ 2 ≤ n ∧ z ^ 2 ≤ n)\n    (by\n      constructor\n      · rintro ⟨x, -, y, -, z, -, h⟩; exact ⟨x, y, z, h⟩\n      · rintro ⟨x, y, z, h1, h2, h3, h4⟩\n        refine ⟨x, Finset.mem_range.mpr ?_, y, Finset.mem_range.mpr ?_,\n                z, Finset.mem_range.mpr ?_, h1, h2, h3, h4⟩\n        all_goals (simp only [Nat.lt_succ_iff]; exact Nat.le_sqrt'.mpr ‹_›))\n\n/--\nThe integer $6563$ cannot be written as $x^2 + y^2 - z^2$ with $\\max(x^2, y^2, z^2) \\leq 6563$.\n-/\n@[category textbook, AMS 11]\ntheorem erdos_1148.variants.lower_bound : ¬ Erdos1148Prop 6563 := by\n  decide +native\n\n/--\nThe weaker property: $n = x^2 + y^2 - z^2$ such that $\\max(x^2, y^2, z^2) \\leq n + 2\\sqrt{n}$.\n-/\ndef erdos_1148_weaker_prop (n : ℕ) : Prop :=\n  ∃ x y z : ℕ, n = x ^ 2 + y ^ 2 - z ^ 2 ∧\n    (x ^ 2 : ℝ) ≤ n + 2 * Real.sqrt n ∧\n    (y ^ 2 : ℝ) ≤ n + 2 * Real.sqrt n ∧\n    (z ^ 2 : ℝ) ≤ n + 2 * Real.sqrt n\n\n/--\n[Va99] reports this is 'obvious' if we replace $\\leq n$ with $\\leq n+2\\sqrt{n}$.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_1148.variants.weaker : ∀ n, erdos_1148_weaker_prop n := by\n  sorry\n\nend Erdos1148\n",
  "statement_hash": "7cd625c13e47f70482fd50f5064bf236bf556a9d98fbd94b5998b22f6d31a0c2",
  "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."
}