{
  "id": "8180",
  "ident": "NS.08180",
  "slug": "wikipedia-maximalprimegap",
  "title": "Shanks's asymptotic conjecture for maximal prime gaps",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Shanks's maximal prime gap conjecture (1964): the maximal prime gap $G(x)$ starting below $x$\nsatisfies $G(x) \\sim (\\log x)^2$ as $x \\to \\infty$ (contradicted by Granville's refinement\npredicting $\\limsup_{n \\to \\infty} g_n / (\\log p_n)^2 \\ge 2e^{-\\gamma}$).",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "MaximalPrimeGap.shanks_maximal_prime_gap_conjecture",
  "statement_lean": "theorem shanks_maximal_prime_gap_conjecture :\n    (fun x : ℝ => (sup_primeGap x : ℝ)) ~[Filter.atTop]\n      (fun x : ℝ => (Real.log x) ^ 2)",
  "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# Shanks's asymptotic conjecture for maximal prime gaps\n\nWriting $p_n$ for the $n$-th prime ($0$-indexed, $p_0 = 2$) and $g_n = p_{n+1} - p_n$ (`primeGap n`)\nfor the $n$-th prime gap, let $G(x) = \\max_{p_n < x} g_n$ (`sup_primeGap x`) denote the largest\nprime gap starting below $x$ (which has the same asymptotic growth as $\\max_{p_n \\le x} g_n$). An\nindex $n$ marks a record (maximal) gap whenever $g_m < g_n$ for all $m < n$. Strengthening\nCramér's prime-gap heuristic, Daniel Shanks (1964) conjectured that $G(x) \\sim (\\log x)^2$ as\n$x \\to \\infty$. By contrast, Andrew Granville's (1995) sieve-adjusted model predicts\n$\\limsup_{n \\to \\infty} g_n / (\\log p_n)^2 \\ge 2e^{-\\gamma} \\approx 1.1229$, contradicting\nShanks's conjecture. See also `Erdos5`.\n\n*References:*\n- [Wikipedia](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_conjecture#Shanks_conjecture)\n- [Wikipedia: Prime gap](https://en.wikipedia.org/wiki/Prime_gap#Numerical_results)\n- D. Shanks, *On maximal gaps between successive primes*, Math. Comp. **18** (1964), no. 88,\n  646–651.\n- A. Granville, *Harald Cramér and the distribution of prime numbers*, Scand. Actuar. J. **1995**\n  (1995), no. 1, 12–28.\n-/\n\n@[expose] public section\n\nopen scoped Asymptotics\n\nnamespace MaximalPrimeGap\n\n/-- Predicate that index $n$ achieves a strictly larger `primeGap` than all earlier indices\n$m < n$. -/\ndef IsMaximalPrimeGapIndex (n : ℕ) : Prop :=\n  ∀ m : ℕ, m < n → primeGap m < primeGap n\n\n/-- Checks the first three indices and `sup_primeGap` at $x = 6$: $g_0 = 1$ and $g_1 = 2$ are\nrecord gaps, $g_2 = 2$ is not, and $G(6) = \\max(1, 2, 2) = 2$. -/\n@[category test, AMS 11]\ntheorem maximal_prime_gap_initial_indices :\n    IsMaximalPrimeGapIndex 0 ∧ IsMaximalPrimeGapIndex 1 ∧ ¬ IsMaximalPrimeGapIndex 2 ∧\n      sup_primeGap 6 = 2 := by\n  have hp0 : Nat.nth Nat.Prime 0 = 2 := Nat.nth_prime_zero_eq_two\n  have hp1 : Nat.nth Nat.Prime 1 = 3 := Nat.nth_prime_one_eq_three\n  have hp2 : Nat.nth Nat.Prime 2 = 5 := Nat.nth_prime_two_eq_five\n  have hp3 : Nat.nth Nat.Prime 3 = 7 := Nat.nth_prime_three_eq_seven\n  have hg0 : primeGap 0 = 1 := by simp [primeGap, hp0, hp1]\n  have hg1 : primeGap 1 = 2 := by simp [primeGap, hp1, hp2]\n  have hg2 : primeGap 2 = 2 := by simp [primeGap, hp2, hp3]\n  refine ⟨fun _ hm => by omega, ?_, ?_, ?_⟩\n  · intro m hm\n    have hm0 : m = 0 := by omega\n    subst hm0\n    omega\n  · intro h2\n    have hlt := h2 1 (by omega)\n    omega\n  · unfold sup_primeGap\n    have hc : ⌈(6 : ℝ)⌉₊ = 6 := by norm_num\n    have hpc : Nat.primeCounting' 6 = 3 := by decide\n    rw [hc, hpc]\n    simp [Finset.range_add_one, hg0, hg1, hg2]\n\n/-- Index $0$ ($g_0 = 3 - 2 = 1$) is vacuously a record prime gap index. -/\n@[category API, AMS 11]\ntheorem isMaximalPrimeGapIndex_zero : IsMaximalPrimeGapIndex 0 :=\n  maximal_prime_gap_initial_indices.1\n\n/-- Infinitely many indices $n$ achieve a new record prime gap, since prime gaps are unbounded. -/\n@[category textbook, AMS 11]\ntheorem infinite_maximalPrimeGapIndex :\n    {n : ℕ | IsMaximalPrimeGapIndex n}.Infinite := by\n  sorry\n\n/-- Shanks's maximal prime gap conjecture (1964): the maximal prime gap $G(x)$ starting below $x$\nsatisfies $G(x) \\sim (\\log x)^2$ as $x \\to \\infty$ (contradicted by Granville's refinement\npredicting $\\limsup_{n \\to \\infty} g_n / (\\log p_n)^2 \\ge 2e^{-\\gamma}$). -/\n@[category research open, AMS 11]\ntheorem shanks_maximal_prime_gap_conjecture :\n    (fun x : ℝ => (sup_primeGap x : ℝ)) ~[Filter.atTop]\n      (fun x : ℝ => (Real.log x) ^ 2) := by\n  sorry\n\n/-- Record-index consequence of Shanks's conjecture (derived as a corollary of\n`shanks_maximal_prime_gap_conjecture` rather than stated directly on Wikipedia): as $n$ runs\nthrough indices with `IsMaximalPrimeGapIndex n`, the ratio $g_n / (\\log p_n)^2$ converges to\n$1$. -/\n@[category research open, AMS 11]\ntheorem shanks_maximal_prime_gap_conjecture.variants.record_indices :\n    Filter.Tendsto\n      (fun k : {n : ℕ // IsMaximalPrimeGapIndex n} =>\n        (primeGap k.1 : ℝ) / (Real.log (Nat.nth Nat.Prime k.1 : ℝ)) ^ 2)\n      Filter.atTop (nhds 1) := by\n  sorry\n\nend MaximalPrimeGap\n",
  "statement_hash": "7f56d450d6e3fa0c6df89d4fb8da9815d40a553f511af98e4cf6e1c4bdf0c22f",
  "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."
}