{
  "id": "7779",
  "ident": "NS.07779",
  "slug": "wikipedia-cramerconjecture",
  "title": "Cramér's Conjecture on Prime Gaps",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "**Cramér's Conjecture** [Cr36]: consecutive prime differences satisfy\n$p_{n+1} - p_n = O((\\log p_n)^2)$ as $n \\to \\infty$.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "wikipedia",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "CramerConjecture.cramer_conjecture",
  "statement_lean": "theorem cramer_conjecture :\n    (fun n : ℕ => (primeGap n : ℝ)) =O[Filter.atTop]\n      (fun n : ℕ => (Real.log (Nat.nth Nat.Prime n)) ^ 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# Cramér's Conjecture on Prime Gaps\n\nWrite $p_n$ for the $n$-th prime (`Nat.nth Nat.Prime`, with $p_0 = 2$) and $g_n = p_{n+1} - p_n$\n(`primeGap n`). Using an independent random prime heuristic, Harald Cramér [Cr36] conjectured in\n1936 that $g_n = O((\\log p_n)^2)$; his random model further predicts\n$$\\limsup_{n \\to \\infty} \\frac{p_{n+1} - p_n}{(\\log p_n)^2} = 1,$$\nwhile numerical searches also test the strict inequality $g_n < (\\log p_n)^2$ for $n \\ge 4$\n($p_n \\ge 11$). Accounting for Helmut Maier's short-interval oscillations [Ma85] and small-prime\nsieve factors, Andrew Granville [Gr95] conjectured instead that the limit superior is at least\n$2 e^{-\\gamma} \\approx 1.1229$ (contradicting $\\limsup = 1$). Unconditionally, Baker, Harman, and\nPintz [BHP01] proved $g_n = O(p_n^{0.525})$. See also `Erdos5`, `Erdos233`, `Andrica`, `Oppermann`,\nand `Firoozbakht` (`Firoozbakht.firoozbakht_conjecture_consequence`).\n\n*References:*\n- [Wikipedia](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_conjecture)\n- [We31] E. Westzynthius (1931), Commentat. Phys.-Math. **5**, no. 25, 1–37.\n- [Cr36] H. Cramér (1936), Acta Arith. **2**, no. 1, 23–46.\n- [Ma85] H. Maier (1985), Michigan Math. J. **32**, no. 2, 221–225.\n- [Gr95] A. Granville (1995), Scand. Actuar. J. **1995**, no. 1, 12–28.\n- [BHP01] R. C. Baker, G. Harman, and J. Pintz (2001), Proc. London Math. Soc. (3) **83**, no. 3,\n  532–562.\n-/\n\n@[expose] public section\n\nopen scoped Asymptotics\n\nnamespace CramerConjecture\n\n/-- Cramér's normalized prime-gap ratio $\\dfrac{p_{n+1} - p_n}{(\\log p_n)^2}$. Since $p_n \\ge 2$\nfor all $n \\in \\mathbb{N}$, the denominator $(\\log p_n)^2$ is always strictly positive. -/\nnoncomputable def cramerRatio (n : ℕ) : ℝ :=\n  (primeGap n : ℝ) / (Real.log (Nat.nth Nat.Prime n)) ^ 2\n\n/-- Each of $n = 0$ ($p_0 = 2, g_0 = 1$), $n = 1$ ($p_1 = 3, g_1 = 2$, ratio $\\approx 1.657$),\nand $n = 3$ ($p_3 = 7, p_4 = 11, g_3 = 4$) satisfies `1 < cramerRatio n`, showing that `4 ≤ n`\nis sharp in `cramer_conjecture.variants.strict_bound`, with `cramerRatio 1 < 2`. -/\n@[category test, AMS 11]\ntheorem cramerRatio_small_index_bounds :\n    1 < cramerRatio 0 ∧ 1 < cramerRatio 1 ∧ cramerRatio 1 < 2 ∧ 1 < cramerRatio 3 := by\n  have hg0 : primeGap 0 = 1 := by\n    simp [primeGap, Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three]\n  have hg1 : primeGap 1 = 2 := by\n    simp [primeGap, Nat.nth_prime_one_eq_three, Nat.nth_prime_two_eq_five]\n  have hg3 : primeGap 3 = 4 := by\n    simp [primeGap, Nat.nth_prime_three_eq_seven, Nat.nth_prime_four_eq_eleven]\n  refine ⟨?_, ?_, ?_, ?_⟩\n  · rw [cramerRatio, hg0, Nat.nth_prime_zero_eq_two]\n    have hpos : 0 < Real.log 2 := Real.log_pos (by norm_num)\n    have hlt1 : Real.log 2 < 1 := by linarith [Real.log_two_lt_d9]\n    simpa using (one_lt_inv₀ (sq_pos_of_pos hpos)).mpr (by nlinarith)\n  · rw [cramerRatio, hg1, Nat.nth_prime_one_eq_three]\n    have hpos : 0 < Real.log 3 := Real.log_pos (by norm_num)\n    have hpow : Real.log ((3 : ℝ) ^ 3) < 4 := (Real.log_lt_iff_lt_exp (by norm_num)).mpr (by\n      rw [show (4 : ℝ) = (4 : ℕ) * (1 : ℝ) by norm_num, Real.exp_nat_mul]\n      nlinarith [Real.exp_one_gt_d9, sq_nonneg (Real.exp 1 - 2.7)])\n    rw [Real.log_pow] at hpow\n    exact (one_lt_div (sq_pos_of_pos hpos)).mpr (by push_cast at hpow ⊢; nlinarith)\n  · rw [cramerRatio, hg1, Nat.nth_prime_one_eq_three]\n    have hgt1 : 1 < Real.log 3 :=\n      (Real.lt_log_iff_exp_lt (by norm_num)).mpr (by linarith [Real.exp_one_lt_d9])\n    exact (div_lt_iff₀ (by positivity)).mpr (by push_cast; nlinarith)\n  · rw [cramerRatio, hg3, Nat.nth_prime_three_eq_seven]\n    have hpos : 0 < Real.log 7 := Real.log_pos (by norm_num)\n    have hlt2 : Real.log 7 < 2 := (Real.log_lt_iff_lt_exp (by norm_num)).mpr\n      (by rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add]; nlinarith [Real.exp_one_gt_d9])\n    exact (one_lt_div (sq_pos_of_pos hpos)).mpr (by push_cast; nlinarith)\n\n/-- **Cramér's Conjecture** [Cr36]: consecutive prime differences satisfy\n$p_{n+1} - p_n = O((\\log p_n)^2)$ as $n \\to \\infty$. -/\n@[category research open, AMS 11]\ntheorem cramer_conjecture :\n    (fun n : ℕ => (primeGap n : ℝ)) =O[Filter.atTop]\n      (fun n : ℕ => (Real.log (Nat.nth Nat.Prime n)) ^ 2) := by\n  sorry\n\n/-- **Cramér's Heuristic Limit-Superior Prediction**: $\\limsup_{n \\to \\infty} g_n / (\\log p_n)^2 =\n1$. Rather than an explicit conjecture in [Cr36], this stronger statement comes from Cramér's\nprobabilistic prime model and contradicts `cramer_conjecture.variants.granville`\n($2 e^{-\\gamma} > 1$). -/\n@[category research open, AMS 11]\ntheorem cramer_conjecture.variants.limsup_eq_one :\n    (∀ ε : ℝ, 0 < ε → ∀ᶠ n in Filter.atTop, cramerRatio n ≤ 1 + ε) ∧\n      (∀ ε : ℝ, 0 < ε → ∃ᶠ n in Filter.atTop, 1 - ε ≤ cramerRatio n) := by\n  sorry\n\n/-- **Strong Numerical Cramér Inequality**: for every $n \\ge 4$ ($p_n \\ge 11$),\n$p_{n+1} - p_n < (\\log p_n)^2$ (indices $n \\in \\{0, 1, 3\\}$ fail; see\n`cramerRatio_small_index_bounds`, and compare `Firoozbakht.firoozbakht_conjecture_consequence` for\nthe stronger bound $p_{n+1} - p_n < (\\log p_n)^2 - \\log p_n$ on the same range). -/\n@[category research open, AMS 11]\ntheorem cramer_conjecture.variants.strict_bound (n : ℕ) (hn : 4 ≤ n) :\n    cramerRatio n < 1 := by\n  sorry\n\n/-- **Cramér–Granville Conjecture** [Gr95]: $\\limsup_{n \\to \\infty} g_n / (\\log p_n)^2 \\ge\n2 e^{-\\gamma}$, stated without conditional `ℝ`-suprema as infinitely many $n$ satisfying\n$\\operatorname{cramerRatio}(n) \\ge c$ for each $c < 2 e^{-\\gamma}$ (contradicting\n`limsup_eq_one` and `strict_bound`). -/\n@[category research open, AMS 11]\ntheorem cramer_conjecture.variants.granville (c : ℝ)\n    (hc : c < 2 * Real.exp (-Real.eulerMascheroniConstant)) :\n    ∃ᶠ n : ℕ in Filter.atTop, c ≤ cramerRatio n := by\n  sorry\n\n/-- **Cramér's Conditional Prime Gap Bound** [Cr36]: under `RiemannHypothesis`,\n$p_{n+1} - p_n = O(\\sqrt{p_n} \\log p_n)$. -/\n@[category research solved, AMS 11]\ntheorem cramer_conjecture.variants.conditional_rh (hRH : RiemannHypothesis) :\n    (fun n : ℕ => (primeGap n : ℝ)) =O[Filter.atTop]\n      (fun n : ℕ => Real.sqrt (Nat.nth Nat.Prime n) * Real.log (Nat.nth Nat.Prime n)) := by\n  sorry\n\n/-- **Westzynthius's Theorem** [We31] (cf. `Erdos5.erdos_5.variants.westzynthius`): for every real\n$M$, infinitely many indices $n$ satisfy $p_{n+1} - p_n \\ge M \\log p_n$. -/\n@[category research solved, AMS 11]\ntheorem cramer_conjecture.variants.westzynthius (M : ℝ) :\n    ∃ᶠ n : ℕ in Filter.atTop,\n      M * Real.log (Nat.nth Nat.Prime n : ℝ) ≤ (primeGap n : ℝ) := by\n  sorry\n\n/-- **Baker–Harman–Pintz Bound** [BHP01]: $p_{n+1} - p_n = O(p_n^{0.525})$ as $n \\to \\infty$. -/\n@[category research solved, AMS 11]\ntheorem cramer_conjecture.variants.baker_harman_pintz :\n    (fun n : ℕ => (primeGap n : ℝ)) =O[Filter.atTop]\n      (fun n : ℕ => (Nat.nth Nat.Prime n : ℝ) ^ (0.525 : ℝ)) := by\n  sorry\n\nend CramerConjecture\n",
  "statement_hash": "9af74117a56d5af3076ee74cdec83fb570aa591eed1615da3a23caf6c90d90d2",
  "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."
}