{
  "id": "2842",
  "ident": "NS.02842",
  "slug": "erdos-682",
  "title": "Erdős Problem 682",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Is it true that for almost all $n$ there exists some $m\\in (p_n,p_{n+1})$ such that\n$$p(m) \\geq p_{n+1}-p_n,$$\nwhere $p(m)$ denotes the least prime factor of $m$?\n\nThis was solved in the affirmative by Gafni and Tao [GaTa25].\n\nThis was formalized in Lean by Codex and GPT-5.6 Sol.",
  "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": "Erdos682.erdos_682",
  "statement_lean": "theorem erdos_682 :\n    {n | ∃ m ∈ Set.Ioo (p n) (p (n + 1)), p (n + 1) - p n ≤ m.minFac}.HasDensity 1",
  "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 682\n\n*References:*\n- [erdosproblems.com/682](https://www.erdosproblems.com/682)\n- [Er79d] Erdős, P., Some unconventional problems in number theory. Acta Math. Acad. Sci. Hungar.\n  (1979), 71-80.\n- [GaTa25] A. Gafni and T. Tao, Rough numbers between consecutive primes. arXiv:2508.06463 (2025).\n-/\n\n@[expose] public section\n\nopen Filter Asymptotics\n\nnamespace Erdos682\n\n/-- The `n`th prime, indexed from zero: `p 0 = 2`, `p 1 = 3`, ... -/\nnoncomputable abbrev p (n : ℕ) : ℕ := Nat.nth Nat.Prime n\n\nset_option linter.style.formal_proof_palomar false in\n/--\nIs it true that for almost all $n$ there exists some $m\\in (p_n,p_{n+1})$ such that\n$$p(m) \\geq p_{n+1}-p_n,$$\nwhere $p(m)$ denotes the least prime factor of $m$?\n\nThis was solved in the affirmative by Gafni and Tao [GaTa25].\n\nThis was formalized in Lean by Codex and GPT-5.6 Sol.\n-/\n@[category research solved, question, AMS 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos682.lean#L5018\"]\ntheorem erdos_682 :\n    {n | ∃ m ∈ Set.Ioo (p n) (p (n + 1)), p (n + 1) - p n ≤ m.minFac}.HasDensity 1 := by\n  sorry\n\n/--\nGafni and Tao [GaTa25, Theorem 1.1] proved that the number of exceptional gaps\n$(p_n,p_{n+1})$ with $p_n\\in [X,2X]$ is\n$$\\ll \\frac{X}{(\\log X)^2}.$$\n-/\n@[category research solved, AMS 11]\ntheorem erdos_682.variants.exceptional_count :\n    (fun X : ℕ ↦ ({n | p n ∈ Set.Icc X (2 * X) ∧\n        ∀ m ∈ Set.Ioo (p n) (p (n + 1)), m.minFac < p (n + 1) - p n}.ncard : ℝ)) =O[atTop]\n      fun X : ℕ ↦ (X : ℝ) / Real.log X ^ 2 := by\n  sorry\n\n/--\nErdős first thought this should be true for all large $n$, but found a (conditional)\ncounterexample: Dickson's conjecture says there are infinitely many $d$ such that\n$$2183+30030d\\textrm{ and }2201+30030d$$\nare both prime, and then they must necessarily be consecutive primes. These give a counterexample\nsince $30030=2\\cdot 3 \\cdot 5\\cdot 7\\cdot 11\\cdot 13$ and every integer in $[2184,2200]$ is\ndivisible by at least one of these primes.\n\nThis was formalized in Lean by Codex and GPT-5.6 Sol.\n-/\n@[category textbook, AMS 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos682.lean#L5222\"]\ntheorem erdos_682.variants.dickson_counterexample (d : ℕ) (h₁ : (2183 + 30030 * d).Prime)\n    (h₂ : (2201 + 30030 * d).Prime) : ∃ n, p n = 2183 + 30030 * d ∧ p (n + 1) = 2201 + 30030 * d ∧\n      ∀ m ∈ Set.Ioo (p n) (p (n + 1)), m.minFac < p (n + 1) - p n := by\n  sorry\n\nend Erdos682\n",
  "statement_hash": "785e3894cf055940a986cd6d9cbe7287688aaf75c0a5c3a2a98feb1a27d8e71d",
  "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."
}