{
  "id": "2145",
  "ident": "NS.02145",
  "slug": "erdos-438",
  "title": "Erdős Problem 438",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "How large can $A \\subseteq \\{1, \\ldots, N\\}$ be if $A + A$ contains no square numbers?\n\nA problem of Erdős [Er80, Er80c, ErGr80]. Taking all integers $\\equiv 1 \\pmod 3$ gives\n$|A| \\ge N/3$, and Massias observed that all integers\n$\\equiv 1, 5, 9, 13, 14, 17, 21, 25, 26, 29, 30 \\pmod{32}$ give $|A| \\ge \\frac{11}{32} N$.\nLagarias, Odlyzko and Shearer [LOS83] proved that $11/32$ is sharp for the modular version of the\nproblem, and Khalfalah, Lodha and Szemerédi [KLS02] proved that it is sharp in general: the\nmaximal such $A$ satisfies $|A| \\le (\\frac{11}{32} + o(1)) N$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos438.erdos_438",
  "statement_lean": "theorem erdos_438 :\n    Tendsto (fun N : ℕ ↦ (extremalSize N : ℝ) / (N : ℝ)) atTop (𝓝 ((11 : ℝ) / 32))",
  "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-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 438\n\n*References:*\n- [erdosproblems.com/438](https://www.erdosproblems.com/438)\n- [Er80] Erdős, Paul, *A survey of problems in combinatorial number theory*. Ann. Discrete Math.\n  (1980), 89-115.\n- [Er80c] Erdős, Paul, *Nine little known problems in combinatorial number theory*. Normat (1980),\n  155-164, 180.\n- [ErGr80] Erdős, P. and Graham, R., *Old and new problems and results in combinatorial number\n  theory*. Monographies de L'Enseignement Mathematique (1980).\n- [LOS83] Lagarias, J. C. and Odlyzko, A. M. and Shearer, J. B., *On the density of sequences of\n  integers the sum of no two of which is a square. II. General sequences*. J. Combin. Theory Ser. A\n  (1983), 123-139.\n- [KLS02] Khalfalah, A. and Lodha, S. and Szemerédi, E., *Tight bound for the density of sequence\n  of integers the sum of no two of which is a perfect square*. Discrete Math. (2002), 243-255.\n-/\n\n@[expose] public section\n\nopen Filter\nopen scoped Topology\n\nnamespace Erdos438\n\n/-- A finite set of natural numbers is square-sum-free if the sum of any two of its elements\n(possibly equal) is not a square. -/\ndef SquareSumFree (A : Finset ℕ) : Prop :=\n  ∀ a ∈ A, ∀ b ∈ A, ¬ IsSquare (a + b)\n\n/-- The largest size of a square-sum-free subset of `{1, …, N}`. -/\nnoncomputable def extremalSize (N : ℕ) : ℕ := by\n  classical\n  exact ((Finset.Icc 1 N).powerset.filter SquareSumFree).sup Finset.card\n\nset_option linter.style.formal_proof_palomar false in\n/--\nHow large can $A \\subseteq \\{1, \\ldots, N\\}$ be if $A + A$ contains no square numbers?\n\nA problem of Erdős [Er80, Er80c, ErGr80]. Taking all integers $\\equiv 1 \\pmod 3$ gives\n$|A| \\ge N/3$, and Massias observed that all integers\n$\\equiv 1, 5, 9, 13, 14, 17, 21, 25, 26, 29, 30 \\pmod{32}$ give $|A| \\ge \\frac{11}{32} N$.\nLagarias, Odlyzko and Shearer [LOS83] proved that $11/32$ is sharp for the modular version of the\nproblem, and Khalfalah, Lodha and Szemerédi [KLS02] proved that it is sharp in general: the\nmaximal such $A$ satisfies $|A| \\le (\\frac{11}{32} + o(1)) N$.\n-/\n@[category research solved, AMS 11, formal_proof using lean4 at\n  \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos438.lean#L46\"]\ntheorem erdos_438 :\n    Tendsto (fun N : ℕ ↦ (extremalSize N : ℝ) / (N : ℝ)) atTop (𝓝 ((11 : ℝ) / 32)) := by\n  sorry\n\nend Erdos438\n",
  "statement_hash": "d7bf31d3a703abd4cc6fe46e9f25f8f7fe1375503108aa2e3a308b77a7063129",
  "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."
}