{
  "id": "776",
  "ident": "NS.00776",
  "slug": "erdos-1140",
  "title": "Erdős Problem 1140",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Do there exist infinitely many $n$ such that $n-2x^2$ is prime for all $x$ with $2x^2<n$?\n\nThe answer is no: see `erdos_1140.variants.at_most_one_exception`.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos1140.erdos_1140",
  "statement_lean": "theorem erdos_1140 : ¬ {n : ℕ | Erdos1140Prop n}.Infinite",
  "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 1140\n\n*References:*\n- [erdosproblems.com/1140](https://www.erdosproblems.com/1140)\n- [EpGi10] Epure, M. and Gica, A., *Principal quadratic real fields in connection with some\n  additive problems*. Bull. Math. Soc. Sci. Math. Roumanie (N.S.) (2010), 251-259.\n- [MoWi89] Mollin, R. A. and Williams, H. C., *Period four and real quadratic fields of class\n  number one*. Proc. Japan Acad. Ser. A Math. Sci. (1989), 89-93.\n- [Va99] Various, *Some of Paul's favorite problems*. Booklet produced for the conference\n  \"Paul Erdős and his mathematics\", Budapest, July 1999 (1999).\n-/\n\n@[expose] public section\n\nnamespace Erdos1140\n\n/-- $n \\geq 1$ and $n - 2x^2$ is prime for all integers $x \\geq 0$ with $2x^2 < n$. The value\n$x = 0$ is allowed, so $n$ itself is prime, as in the known list. -/\ndef Erdos1140Prop (n : ℕ) : Prop :=\n  0 < n ∧ ∀ x : ℕ, 2 * x ^ 2 < n → (n - 2 * x ^ 2).Prime\n\ninstance (n : ℕ) : Decidable (Erdos1140Prop n) :=\n  decidable_of_iff (0 < n ∧ ∀ x < n, 2 * x ^ 2 < n → (n - 2 * x ^ 2).Prime) <| by\n    unfold Erdos1140Prop\n    refine and_congr_right fun _ => ⟨fun h x hx => h x ?_ hx, fun h x _ hx => h x hx⟩\n    have := Nat.le_self_pow two_ne_zero x\n    omega\n\n/-- The known examples $2, 5, 7, 13, 31, 61, 181, 199$ have the property. -/\n@[category test, AMS 11]\ntheorem known_examples :\n    ∀ n ∈ ([2, 5, 7, 13, 31, 61, 181, 199] : List ℕ), Erdos1140Prop n := by\n  decide +kernel\n\n/-- Since $x = 0$ is allowed, $4$ does not have the property, although $4 - 2 \\cdot 1^2 = 2$ is\nprime. -/\n@[category test, AMS 11]\ntheorem not_four : ¬ Erdos1140Prop 4 := by\n  decide +kernel\n\n/--\nDo there exist infinitely many $n$ such that $n-2x^2$ is prime for all $x$ with $2x^2<n$?\n\nThe answer is no: see `erdos_1140.variants.at_most_one_exception`.\n-/\n@[category research solved, question, AMS 11]\ntheorem erdos_1140 : ¬ {n : ℕ | Erdos1140Prop n}.Infinite := by\n  sorry\n\n/--\nThe known such $n$ are $2,5,7,13,31,61,181,199$. It is known that these are, with at most one\nexception, all such $n$. An even such $n$ must be prime (take $x = 0$), so $n = 2$. Theorem 4.1\nof Epure and Gica [EpGi10] implies that the only such\n$n\\equiv 1\\pmod{4}$ are $5,13,61,181$, and their method, coupled with a result of Mollin and\nWilliams [MoWi89], implies that the only such $n\\equiv 3\\pmod{4}$ are $7,31,199$, and at most one\nother exception.\n-/\n@[category research solved, AMS 11]\ntheorem erdos_1140.variants.at_most_one_exception :\n    ({n : ℕ | Erdos1140Prop n} \\ {2, 5, 7, 13, 31, 61, 181, 199}).Subsingleton := by\n  sorry\n\nend Erdos1140\n",
  "statement_hash": "cd5db5ca18cc22d865ff1bd6b1a065e393e19334ddbe655e92f87e3172d11087",
  "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."
}