{
  "id": "1417",
  "ident": "NS.01417",
  "slug": "erdos-235",
  "title": "Erdős Problem 235",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Let $N_k=2\\cdot 3\\cdots p_k$ and $\\{a_1<a_2<\\cdots <a_{\\phi(N_k)}\\}$ be the integers $<N_k$ which\nare relatively prime to $N_k$. Then, for any $c\\geq 0$, the limit\n$$\\frac{\\#\\{ a_i-a_{i-1}\\leq c \\frac{N_k}{\\phi(N_k)} : 2\\leq i\\leq \\phi(N_k)\\}}{\\phi(N_k)}$$\nexists and is a continuous function of $c$.\n\nSolved by Hooley [Ho65], who proved that these gaps have an exponential distribution: that is, if\n$f(c)$ is the function in question, then\n$$f(c)=(1+o(1))(1-e^{-c})$$\n(where the $o(1)$ goes to $0$ uniformly as $k\\to \\infty$).\n\nSee also [234](https://www.erdosproblems.com/234) for a more difficult version of this problem using\nactual primes.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos235.erdos_235",
  "statement_lean": "theorem erdos_235 :\n    ∃ f : ℝ → ℝ, ContinuousOn f (Set.Ici (0 : ℝ)) ∧\n      ∀ c, 0 ≤ c → Tendsto (fun k ↦ proportion k c) atTop (𝓝 (f c))",
  "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 235\n\n*References:*\n- [erdosproblems.com/235](https://www.erdosproblems.com/235)\n- [Ho65] Hooley, Christopher, _On the difference between consecutive numbers prime to $n$_. II.\n  Publ. Math. Debrecen (1965), 39--49.\n-/\n\n@[expose] public section\n\nopen Filter\nopen scoped Topology\n\nnamespace Erdos235\n\n/-- The product of the first `k + 1` primes.\nOn [erdosproblems.com/235](https://www.erdosproblems.com/235) this is $N_{k+1}=2\\cdot 3\\cdots p_{k+1}$.\nThe limit as $k\\to\\infty$ is the same for either indexing. -/\nnoncomputable def N (k : ℕ) : ℕ :=\n  primorial (Nat.nth Nat.Prime k)\n\n/-- The increasing list of integers `< n` that are coprime to `n`. -/\ndef coprimeList (n : ℕ) : List ℕ :=\n  ({a ∈ Finset.range n | n.Coprime a}).sort (· ≤ ·)\n\n/-- The gaps $a_i - a_{i-1}$ between consecutive entries of `coprimeList n`. -/\ndef gaps (n : ℕ) : List ℕ :=\n  (coprimeList n).zipWith (fun a b ↦ b - a) (coprimeList n).tail\n\n/-- The number of gaps of size at most $c \\cdot n / \\varphi(n)$. -/\nnoncomputable def countGaps (n : ℕ) (c : ℝ) : ℕ :=\n  (gaps n).countP fun g ↦ decide ((g : ℝ) ≤ c * (n : ℝ) / (n.totient : ℝ))\n\n/-- The proportion appearing in `erdos_235`, for the primorial `N k`. -/\nnoncomputable def proportion (k : ℕ) (c : ℝ) : ℝ :=\n  (countGaps (N k) c : ℝ) / ((N k).totient : ℝ)\n\n/-- `N 0` is the primorial of $2$. -/\n@[category test, AMS 11]\ntheorem N_zero : N 0 = 2 := by\n  simp [N, Nat.nth_prime_zero_eq_two, primorial_two]\n\n/-- `N 1` is the primorial of $3$. -/\n@[category test, AMS 11]\ntheorem N_one : N 1 = 6 := by\n  simp [N, Nat.nth_prime_one_eq_three]\n  decide\n\n/-- `coprimeList n` has length $\\varphi(n)$. -/\n@[category test, AMS 11]\ntheorem coprimeList_length (n : ℕ) : (coprimeList n).length = n.totient := by\n  rw [coprimeList, Finset.length_sort (· ≤ ·), Nat.totient_eq_card_coprime]\n\n/-- $\\varphi(N_k)$ is positive, so the proportion is not a division by zero. -/\n@[category test, AMS 11]\ntheorem totient_N_pos (k : ℕ) : 0 < (N k).totient := by\n  rw [Nat.totient_pos]\n  exact primorial_pos (Nat.nth Nat.Prime k)\n\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $N_k=2\\cdot 3\\cdots p_k$ and $\\{a_1<a_2<\\cdots <a_{\\phi(N_k)}\\}$ be the integers $<N_k$ which\nare relatively prime to $N_k$. Then, for any $c\\geq 0$, the limit\n$$\\frac{\\#\\{ a_i-a_{i-1}\\leq c \\frac{N_k}{\\phi(N_k)} : 2\\leq i\\leq \\phi(N_k)\\}}{\\phi(N_k)}$$\nexists and is a continuous function of $c$.\n\nSolved by Hooley [Ho65], who proved that these gaps have an exponential distribution: that is, if\n$f(c)$ is the function in question, then\n$$f(c)=(1+o(1))(1-e^{-c})$$\n(where the $o(1)$ goes to $0$ uniformly as $k\\to \\infty$).\n\nSee also [234](https://www.erdosproblems.com/234) for a more difficult version of this problem using\nactual primes.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos235.lean#L4266\"]\ntheorem erdos_235 :\n    ∃ f : ℝ → ℝ, ContinuousOn f (Set.Ici (0 : ℝ)) ∧\n      ∀ c, 0 ≤ c → Tendsto (fun k ↦ proportion k c) atTop (𝓝 (f c)) := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nHooley [Ho65] proved that the limit in `erdos_235` is $1-e^{-c}$.\nFor each fixed $c\\geq 0$,\n$$f(c)=(1+o(1))(1-e^{-c})$$\nas $k\\to\\infty$.\n-/\n@[category research solved, AMS 11,\n  formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos235.lean#L4266\"]\ntheorem erdos_235.variants.hooley (c : ℝ) (hc : 0 ≤ c) :\n    Tendsto (fun k ↦ proportion k c) atTop (𝓝 (1 - Real.exp (-c))) := by\n  sorry\n\nend Erdos235\n",
  "statement_hash": "0280ddeb89627599f51062a24f5ba27a46ba1fd1926c579def2d3b5ea7c76f30",
  "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."
}