Problems / erdos-1094 / erdos-1094--h2--h1--h1--h6
small n: a prime above k/2 with two multiples
erdos-1094--h2--h1--h1--h6
proved
Hole h_small of C(n,k) with no prime factor ≤ k, 2k ≤ n < k³ (split by 20261111T190000Z-t1111-a-partial.lean).
$\displaystyle \neg\,\text{BHP}\ \ \lor\ \ \exists k_0\in\mathbb{N}\ \forall k\ge k_0\ \forall n\in\mathbb{N}:\ \ 2k\le n\le\tfrac12\bigl(\tfrac{k}{2}\bigr)^{2-21/40}+2k\ \Longrightarrow\ \exists p\text{ prime},\ \ k<2p,\ \ (n\bmod p)+p<k$
Either the Baker–Harman–Pintz short-interval prime count fails, or for all large $k$ and every natural number $n$ with $2k\le n\le\tfrac12(k/2)^{2-21/40}+2k$ there is a prime $p>k/2$ with $(n\bmod p)+p<k$. Here BHP is the statement of the node erdos-1094--h2--h2--h1, word for word: $\exists C>0\ \exists k_0\ \forall k\ge k_0:\ C\,k^{21/40}/\log k\le\#\{p\text{ prime}:k<p<k+k^{21/40}\}$, the primes counted as the integers of the interval $(\lfloor k\rfloor,\lceil k+k^{21/40}\rceil)$ that are positive, prime in absolute value and lie strictly between $k$ and $k+k^{21/40}$ over the reals.
$k$, $n$ and $p$ are natural numbers and $n\bmod p$ is the remainder of $n$ on division by $p$. The upper bound on $n$ is an inequality of real numbers: $k/2$ is the real number (not rounded), $2-21/40$ is a real exponent and $\log$ is the natural logarithm.
Since $n\bmod p\ge 0$, the conclusion forces $k/2<p<k$. The inequality $(n\bmod p)+p<k$ says exactly that the two largest multiples of $p$ not exceeding $n$, namely $n-(n\bmod p)$ and $n-(n\bmod p)-p$, both lie among the $k$ consecutive integers $n-k+1,\dots,n$.
Lean
theorem erdos_1094__h2__h1__h1__h6 : (¬∃ (C : ℝ),
(0 : ℝ) < C ∧
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤
(↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ |
(0 : ℤ) < p ∧
Nat.Prime p.natAbs ∧
(↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card :
ℝ)) ∨
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
∀ (n : ℕ),
(2 : ℕ) * k ≤ n →
(↑n : ℝ) ≤ (1 / 2 : ℝ) * ((↑k : ℝ) / (2 : ℝ)) ^ ((2 : ℝ) - (21 / 40 : ℝ)) + (2 : ℝ) * (↑k : ℝ) →
∃ (p : ℕ), Nat.Prime p ∧ k < (2 : ℕ) * p ∧ n % p + p < k := by
sorryWhy does it end in sorry?
A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →
Explainer
Informal account, unverified — unverified prose about a kernel-checked proof; shown section by section, each labelled with who drafted, wrote or verified it (D-3 v3.31).
Unverified: explainer, its words from explainer/05507e89cb43….md, written by t1111-c, drafted with Claude Fable 5.2 (claude-fable-5-2), 2026-11-11.
Draft · drafted, by the model named above
The proof
Write $\theta = 21/40$ and let BHP be the first alternative's hypothesis: for some $C > 0$ and all large $k$, the interval $(k, k + k^{\theta})$ holds at least $C k^{\theta}/\log k$ primes. If BHP fails, the first alternative holds and nothing is left to prove; this is the Lean's by_cases. So assume BHP. The claim is then: for all large $k$ and all $n$ with $$2k \le n \le \tfrac12 (k/2)^{2-\theta} + 2k$$ there is a prime $p$ with $k < 2p$ and $(n \bmod p) + p < k$. The work is in six helper lemmas placed before the theorem; they are described here in the order of the argument.
Two multiples in the window (sm_carry_of_mult)
Let $p \ge 1$ and $j$ be natural numbers with $$n - k < j\,p \qquad\text{and}\qquad (j+1)\,p \le n .$$ Then $(n \bmod p) + p < k$. Indeed $\lfloor n/p \rfloor \ge j+1$, so $n \bmod p = n - p\lfloor n/p\rfloor \le n - (j+1)p$, and $n - (j+1)p + p = n - jp < k$. So it is enough to find a prime $p > k/2$ and a $j$ for which the two multiples $jp$ and $(j+1)p$ lie in $(n-k, n]$.
A prime in every short window (sm_window)
For all large natural $K$ and every real $a$ with $K \le a \le K + 3K^{\theta}$ there is a prime $p$ with $a < p < a + K^{\theta}$.
This is the window lemma of van Doorn and Tang's small-range proof (the node erdos-1094--h2--h2--h2--h1) with $3K^{\theta}$ where they have $2K^{\theta}$, and the proof is theirs. Put $N = \lceil a \rceil$, so $K \le N \le K + 3K^{\theta} + 1$. BHP at $N$ gives at least $C N^{\theta}/\log N$ primes in $(N, N + N^{\theta})$. Moving the right end of an interval down from $N + N^{\theta}$ to $a + K^{\theta}$ loses at most (length moved) $+\,1$ primes, which is at most $N^{\theta} - K^{\theta} + 2$. By subadditivity of $x \mapsto x^{\theta}$, $$N^{\theta} - K^{\theta} \le (N - K)^{\theta} \le (4K^{\theta})^{\theta} = 4^{\theta} K^{\theta^{2}} .$$ Since $\theta^{2} < \theta$, the loss $4^{\theta}K^{\theta^{2}} + 2$ is smaller than $C N^{\theta}/\log N$ for large $K$ (here $N \le 5K$ and $\log N \le 2\log K$ are used to compare $N$ with $K$). So a prime remains in $(N, a + K^{\theta})$, and $N \ge a$.
The two cases (sm_caseA, sm_caseB, sm_core)
Let $K = \lfloor k/2 \rfloor$, so $K \le k/2 \le K + \tfrac12$, let $h = K^{\theta} \ge 1$, and let $J = \lfloor 2n/k \rfloor$, so that $$J k \le 2n < (J+1) k , \qquad J \ge 4 .$$ Assume also the size condition $h\,(J+1) \le k/2$, proved in the last step.
Case A: $J(k + 2h) \le 2n$. Take a prime $p$ with $k/2 < p < k/2 + h$ (window lemma at $a = k/2$). Then $J p < J(k/2 + h) \le n$, and $(J-1)\,p > (J-1)k/2 > n - k$ because $2n < (J+1)k$. So $j = J - 1$ works.
Case B: $2n < J(k + 2h)$. Put $a = (n-k)/(J-2)$. From $Jk \le 2n$ we get $a \ge k/2 \ge K$. From the case hypothesis, $(J-2)\,a = n - k < (J-2)k/2 + J h$, and since $k/2 \le K + \tfrac12$, $h \ge 1$ and $J - 2 \ge 2$ this gives $a \le K + 3h$. Take a prime $p$ with $a < p < a + h$. Then $p > k/2$ and $(J-2)\,p > n - k$. For the other multiple, $$(J-1)\,p < (J-1)(a + h), \qquad (J-1)(a+h) \le n \iff n + (J-1)(J-2)\,h \le (J-1)\,k ,$$ and the right-hand inequality follows from $2n < J(k + 2h)$ and $h(J+1) \le k/2$: it reduces to $J + (J-1)(J-2) \le (J-2)(J+1)$, that is $J \ge 4$. So $j = J - 2$ works.
In both cases $p > k/2$, which is $k < 2p$.
The size condition (sm_small_gen)
Write $x = k/2$. From $J k \le 2n \le x^{2-\theta} + 4k$ and $k = 2x$ we get $J \le \tfrac12 x^{1-\theta} + 4$. Also $h = K^{\theta} \le x^{\theta}$. Hence $$h\,(J+1) \le x^{\theta}\bigl(\tfrac12 x^{1-\theta} + 5\bigr) = \tfrac{x}{2} + 5x^{\theta} \le x$$ as soon as $x^{1-\theta} \ge 10$, which holds for all large $k$ because $x^{1-\theta} \to \infty$. The threshold $k_0$ is the larger of this bound and twice the window lemma's threshold (plus 2), so that $K$ is past the latter.
On the range
Van Doorn and Tang's small range for primes above $k$ is $n \le \tfrac12 k^{2-\theta}$. Here the window of Case B starts at the exact lower end $a = (n-k)/(J-2)$ of the interval of primes having the two multiples $(J-2)p$, $(J-1)p$ in $(n-k, n]$; the argument above needs only $h(J+1) \le k/2$, which holds for $n \le c\,(k/2)^{2-\theta}$ with any fixed $c < 1$ and large $k$. The stated bound $\tfrac12 (k/2)^{2-\theta} + 2k$ is the one the parent's assembly uses.
History: 1 version on record
2026-11-11 · written by t1111-c, drafted with Claude Fable 5.2 (claude-fable-5-2) · not signed · current · explainer/05507e89cb43….md · the first version of its chain
Read this version
The proof
Write $\theta = 21/40$ and let BHP be the first alternative's hypothesis: for some $C > 0$ and all large $k$, the interval $(k, k + k^{\theta})$ holds at least $C k^{\theta}/\log k$ primes. If BHP fails, the first alternative holds and nothing is left to prove; this is the Lean's
by_cases. So assume BHP. The claim is then: for all large $k$ and all $n$ with $$2k \le n \le \tfrac12 (k/2)^{2-\theta} + 2k$$ there is a prime $p$ with $k < 2p$ and $(n \bmod p) + p < k$. The work is in six helper lemmas placed before the theorem; they are described here in the order of the argument.Two multiples in the window (
sm_carry_of_mult)Let $p \ge 1$ and $j$ be natural numbers with $$n - k < j\,p \qquad\text{and}\qquad (j+1)\,p \le n .$$ Then $(n \bmod p) + p < k$. Indeed $\lfloor n/p \rfloor \ge j+1$, so $n \bmod p = n - p\lfloor n/p\rfloor \le n - (j+1)p$, and $n - (j+1)p + p = n - jp < k$. So it is enough to find a prime $p > k/2$ and a $j$ for which the two multiples $jp$ and $(j+1)p$ lie in $(n-k, n]$.
A prime in every short window (
sm_window)For all large natural $K$ and every real $a$ with $K \le a \le K + 3K^{\theta}$ there is a prime $p$ with $a < p < a + K^{\theta}$.
This is the window lemma of van Doorn and Tang's small-range proof (the node
erdos-1094--h2--h2--h2--h1) with $3K^{\theta}$ where they have $2K^{\theta}$, and the proof is theirs. Put $N = \lceil a \rceil$, so $K \le N \le K + 3K^{\theta} + 1$. BHP at $N$ gives at least $C N^{\theta}/\log N$ primes in $(N, N + N^{\theta})$. Moving the right end of an interval down from $N + N^{\theta}$ to $a + K^{\theta}$ loses at most (length moved) $+\,1$ primes, which is at most $N^{\theta} - K^{\theta} + 2$. By subadditivity of $x \mapsto x^{\theta}$, $$N^{\theta} - K^{\theta} \le (N - K)^{\theta} \le (4K^{\theta})^{\theta} = 4^{\theta} K^{\theta^{2}} .$$ Since $\theta^{2} < \theta$, the loss $4^{\theta}K^{\theta^{2}} + 2$ is smaller than $C N^{\theta}/\log N$ for large $K$ (here $N \le 5K$ and $\log N \le 2\log K$ are used to compare $N$ with $K$). So a prime remains in $(N, a + K^{\theta})$, and $N \ge a$.The two cases (
sm_caseA,sm_caseB,sm_core)Let $K = \lfloor k/2 \rfloor$, so $K \le k/2 \le K + \tfrac12$, let $h = K^{\theta} \ge 1$, and let $J = \lfloor 2n/k \rfloor$, so that $$J k \le 2n < (J+1) k , \qquad J \ge 4 .$$ Assume also the size condition $h\,(J+1) \le k/2$, proved in the last step.
Case A: $J(k + 2h) \le 2n$. Take a prime $p$ with $k/2 < p < k/2 + h$ (window lemma at $a = k/2$). Then $J p < J(k/2 + h) \le n$, and $(J-1)\,p > (J-1)k/2 > n - k$ because $2n < (J+1)k$. So $j = J - 1$ works.
Case B: $2n < J(k + 2h)$. Put $a = (n-k)/(J-2)$. From $Jk \le 2n$ we get $a \ge k/2 \ge K$. From the case hypothesis, $(J-2)\,a = n - k < (J-2)k/2 + J h$, and since $k/2 \le K + \tfrac12$, $h \ge 1$ and $J - 2 \ge 2$ this gives $a \le K + 3h$. Take a prime $p$ with $a < p < a + h$. Then $p > k/2$ and $(J-2)\,p > n - k$. For the other multiple, $$(J-1)\,p < (J-1)(a + h), \qquad (J-1)(a+h) \le n \iff n + (J-1)(J-2)\,h \le (J-1)\,k ,$$ and the right-hand inequality follows from $2n < J(k + 2h)$ and $h(J+1) \le k/2$: it reduces to $J + (J-1)(J-2) \le (J-2)(J+1)$, that is $J \ge 4$. So $j = J - 2$ works.
In both cases $p > k/2$, which is $k < 2p$.
The size condition (
sm_small_gen)Write $x = k/2$. From $J k \le 2n \le x^{2-\theta} + 4k$ and $k = 2x$ we get $J \le \tfrac12 x^{1-\theta} + 4$. Also $h = K^{\theta} \le x^{\theta}$. Hence $$h\,(J+1) \le x^{\theta}\bigl(\tfrac12 x^{1-\theta} + 5\bigr) = \tfrac{x}{2} + 5x^{\theta} \le x$$ as soon as $x^{1-\theta} \ge 10$, which holds for all large $k$ because $x^{1-\theta} \to \infty$. The threshold $k_0$ is the larger of this bound and twice the window lemma's threshold (plus 2), so that $K$ is past the latter.
On the range
Van Doorn and Tang's small range for primes above $k$ is $n \le \tfrac12 k^{2-\theta}$. Here the window of Case B starts at the exact lower end $a = (n-k)/(J-2)$ of the interval of primes having the two multiples $(J-2)p$, $(J-1)p$ in $(n-k, n]$; the argument above needs only $h(J+1) \le k/2$, which holds for $n \le c\,(k/2)^{2-\theta}$ with any fixed $c < 1$ and large $k$. The stated bound $\tfrac12 (k/2)^{2-\theta} + 2k$ is the one the parent's assembly uses.
Improve these words → Nothing is edited: a correction is a new version, and every version stays on the record (D-3 v3.30).
How it was proved
Proved by Proof.lean, checked by the kernel. Its attestation, 001293.erdos-1094--h2--h1--h1--h6, records the gate’s run.
The proof step by step (outline)
Checked by the kernel — an outline of the attested proof below: attestations/001293.erdos-1094--h2--h1--h1--h6.json, merge commit 770951feaea3.
Outline of Proof.lean, extracted by the gate at cc2e782e6648 from the proof’s elaboration: each step is a claim the proof establishes and the goal it leaves. Open a step for what it uses and its Lean lines.
s1caseLeaves
(¬∃ (C : ℝ), (0 : ℝ) < C ∧ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤ (↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ | (0 : ℤ) < p ∧ Nat.Prime p.natAbs ∧ (↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card : ℝ)) ∨ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → ∀ (n : ℕ), (2 : ℕ) * k ≤ n → (↑n : ℝ) ≤ (1 / 2 : ℝ) * ((↑k : ℝ) / (2 : ℝ)) ^ ((2 : ℝ) - (21 / 40 : ℝ)) + (2 : ℝ) * (↑k : ℝ) → ∃ (p : ℕ), Nat.Prime p ∧ k < (2 : ℕ) * p ∧ n % p + p < k, withhB : ∃ (C : ℝ), (0 : ℝ) < C ∧ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤ (↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ | (0 : ℤ) < p ∧ Nat.Prime p.natAbs ∧ (↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card : ℝ).Uses library
Or.inrOr.inris "right injection" into anOr. .Lean, line 328
· exact Or.inr (sm_small_gen (21 / 40) (by norm_num) (by norm_num) hB)
targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h6/Proof.lean, line 328 at
95be5d21dd3d↗s2caseLeaves
(¬∃ (C : ℝ), (0 : ℝ) < C ∧ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤ (↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ | (0 : ℤ) < p ∧ Nat.Prime p.natAbs ∧ (↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card : ℝ)) ∨ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → ∀ (n : ℕ), (2 : ℕ) * k ≤ n → (↑n : ℝ) ≤ (1 / 2 : ℝ) * ((↑k : ℝ) / (2 : ℝ)) ^ ((2 : ℝ) - (21 / 40 : ℝ)) + (2 : ℝ) * (↑k : ℝ) → ∃ (p : ℕ), Nat.Prime p ∧ k < (2 : ℕ) * p ∧ n % p + p < k, withhB : ¬∃ (C : ℝ), (0 : ℝ) < C ∧ ∃ (k₀ : ℕ), ∀ (k : ℕ), k₀ ≤ k → C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤ (↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ | (0 : ℤ) < p ∧ Nat.Prime p.natAbs ∧ (↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card : ℝ).Uses library
Or.inlOr.inlis "left injection" into anOr. .Lean, line 329
· exact Or.inl hB
targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h6/Proof.lean, line 329 at
95be5d21dd3d↗
The proof in Lean (Proof.lean)
Checked by the kernel — these bytes are the ones its attestation names: attestations/001293.erdos-1094--h2--h1--h1--h6.json, merge commit 770951feaea3.
artifact_hash of the attestation below, so these are the bytes the gate checked. Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h6/Proof.lean, sha256 835c4de888c9.import Mathlib
import Nodes.«erdos-1094--h2--h1--h1--h6».Context
open scoped Nat
/-! Hole `h_small` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/
private theorem sm_window (θ : ℝ) (hθ0 : 0 < θ) (hθ1 : θ < 1)
(hB0 : ∃ C : ℝ, 0 < C ∧ ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → C * (k : ℝ) ^ θ / Real.log k ≤
(((Finset.Ioo ⌊(k : ℝ)⌋ ⌈(k : ℝ) + (k : ℝ) ^ θ⌉).filter (fun p : ℤ => 0 < p ∧ (p.natAbs).Prime ∧ (k : ℝ) < (p : ℝ) ∧ (p : ℝ) < (k : ℝ) + (k : ℝ) ^ θ)).card : ℝ)) :
∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → ∀ a : ℝ, (k : ℝ) ≤ a → a ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ → ∃ p : ℕ, p.Prime ∧ a < (p : ℝ) ∧ (p : ℝ) < a + (k : ℝ) ^ θ := by
obtain ⟨pc, hpc⟩ : ∃ pc : ℝ → ℝ → ℕ, ∀ a b : ℝ, pc a b = ((Finset.Ioo ⌊a⌋ ⌈b⌉).filter (fun p : ℤ => 0 < p ∧ (p.natAbs).Prime ∧ a < (p : ℝ) ∧ (p : ℝ) < b)).card := ⟨_, fun _ _ => rfl⟩
have primeCard_le_add : ∀ (a b c : ℝ), b ≤ c → (pc a c : ℝ) ≤ (pc a b : ℝ) + (c - b + 1) := by
intro a b c hbc; rw [hpc, hpc]; clear hpc hθ0 hθ1
-- Let S(t) := (Finset.Ioo ⌊a⌋ ⌈t⌉).filter (fun p : ℤ => 0 < p ∧ p.natAbs.Prime ∧ a < (p:ℝ) ∧ (p:ℝ) < t).
set S := fun t : ℝ => Finset.filter (fun p : ℤ => 0 < p ∧ p.natAbs.Prime ∧ a < (p : ℝ) ∧ (p : ℝ) < t) (Finset.Ioo ⌊a⌋ ⌈t⌉);
-- Show `S(c) ⊆ S(b) ∪ Finset.Ico ⌈b⌉ ⌈c⌉`.
have h_subset : S c ⊆ S b ∪ Finset.Ico ⌈b⌉ ⌈c⌉ := by
intro p hp; by_cases h : ( p : ℝ ) < b <;> simp_all +decide ;
· exact Or.inl <| Finset.mem_filter.mpr ⟨ Finset.mem_Ioo.mpr ⟨ Finset.mem_Ioo.mp ( Finset.mem_filter.mp hp |>.1 ) |>.1, Int.lt_ceil.mpr h ⟩, Finset.mem_filter.mp hp |>.2.1, Finset.mem_filter.mp hp |>.2.2.1, Finset.mem_filter.mp hp |>.2.2.2.1, h ⟩;
· exact Or.inr ⟨ Int.ceil_le.mpr h, Finset.mem_Ioo.mp ( Finset.mem_filter.mp hp |>.1 ) |>.2 ⟩;
-- Thus by `Finset.card_le_card` and `Finset.card_union_le`, `S(c).card ≤ S(b).card + (Finset.Ico ⌈b⌉ ⌈c⌉).card`.
have h_card : (S c).card ≤ (S b).card + (Finset.Ico ⌈b⌉ ⌈c⌉).card := by
exact le_trans ( Finset.card_le_card h_subset ) ( Finset.card_union_le _ _ );
have hI : ((Finset.Ico ⌈b⌉ ⌈c⌉).card : ℝ) ≤ c - b + 1 := by
rw [Int.card_Ico]
have h0 : (0 : ℤ) ≤ ⌈c⌉ - ⌈b⌉ := sub_nonneg.mpr (Int.ceil_mono hbc)
have h1 : (((⌈c⌉ - ⌈b⌉).toNat : ℕ) : ℝ) = ((⌈c⌉ - ⌈b⌉ : ℤ) : ℝ) := by
rw [← Int.cast_natCast, Int.toNat_of_nonneg h0]
rw [h1]
push_cast
linarith [Int.ceil_lt_add_one c, Int.le_ceil b]
refine le_trans (Nat.cast_le.mpr h_card) ?_
push_cast
linarith [hI]
have exists_prime_of_primeCard_pos : ∀ (a b : ℝ), 0 < pc a b → ∃ p : ℕ, p.Prime ∧ a < (p : ℝ) ∧ (p : ℝ) < b := by
intro a b h; rw [hpc] at h; clear hpc
obtain ⟨ p, hp ⟩ := Finset.card_pos.mp h;
cases p <;> aesop
have tendsto_log_rpow_mul_rpow_neg : ∀ (b c : ℝ), 0 < c → Filter.Tendsto (fun x : ℝ => (Real.log x) ^ b * x ^ (-c)) Filter.atTop (nhds 0) := by
intro b c hc
-- Use the fact that `Real.log x ^ b` is little-o of `x ^ c` as `x` tends to infinity.
have h_log : (fun x : ℝ => Real.log x ^ b) =o[Filter.atTop] (fun x : ℝ => x ^ c) :=
isLittleO_log_rpow_rpow_atTop b hc
convert h_log.tendsto_div_nhds_zero.congr' _ using 1;
filter_upwards [ Filter.eventually_gt_atTop 0 ] with x hx using by rw [ div_eq_mul_inv, Real.rpow_neg hx.le ] ;
have poly_log_lt : ∀ (A α β tt : ℝ), α < tt → ∀ (C : ℝ), 0 < C → ∀ᶠ k : ℕ in Filter.atTop, A * (k : ℝ) ^ α * (Real.log k) ^ β ≤ C * (k : ℝ) ^ tt / Real.log k := by
intro A α β tt hα C hC
-- Let's choose any $C > 0$ and derive a contradiction.
have h_lim : Filter.Tendsto (fun k : ℕ => (A * (k : ℝ) ^ α * (Real.log k) ^ β) / ((k : ℝ) ^ tt / (Real.log k))) Filter.atTop (nhds 0) := by
-- Simplify the expression inside the limit.
suffices h_simp : Filter.Tendsto (fun k : ℕ => A * (Real.log k) ^ (β + 1) * (k : ℝ) ^ (α - tt)) Filter.atTop (nhds 0) by
refine h_simp.congr' ?_;
filter_upwards [ Filter.eventually_gt_atTop 1 ] with k hk ; rw [ Real.rpow_sub ( by positivity ) ] ; ring_nf;
rw [ Real.rpow_add ( Real.log_pos ( Nat.one_lt_cast.mpr hk ) ), Real.rpow_one ] ; norm_num ; ring;
have := @tendsto_log_rpow_mul_rpow_neg ( β + 1 ) ( tt - α ) ?_;
· convert this.const_mul A |> Filter.Tendsto.comp <| tendsto_natCast_atTop_atTop using 2 <;> norm_num ; ring;
· linarith;
filter_upwards [ h_lim.eventually ( gt_mem_nhds hC ), Filter.eventually_gt_atTop 1 ] with k hk₁ hk₂;
rw [ div_lt_iff₀ ( div_pos ( Real.rpow_pos_of_pos ( Nat.cast_pos.mpr hk₂.le ) _ ) ( Real.log_pos ( Nat.one_lt_cast.mpr hk₂ ) ) ) ] at hk₁ ; ring_nf at hk₁ ⊢ ; linarith
have excess_le : ∀ (k N : ℕ), 1 ≤ k → (k : ℝ) ≤ (N : ℝ) → (N : ℝ) ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ + 1 → (N : ℝ) ^ θ - (k : ℝ) ^ θ ≤ (4 : ℝ) ^ θ * (k : ℝ) ^ (θ * θ) := by
intro k N hk hkN hNk
-- Subexcess bound: `(N:ℝ)^θ - (k:ℝ)^θ ≤ ((N:ℝ) - k)^θ`
have h_subex : (N : ℝ) ^ θ - (k : ℝ) ^ θ ≤ ((N : ℝ) - k) ^ θ := by
rw [ sub_le_iff_le_add' ];
convert Real.rpow_add_le_add_rpow _ _ _ _ using 1 <;> norm_num;
· exact_mod_cast hkN;
· exact hθ0.le;
· exact le_of_lt hθ1;
refine le_trans h_subex ?_;
refine' le_trans ( Real.rpow_le_rpow ( sub_nonneg.mpr hkN ) ( show ( N : ℝ ) - k ≤ 4 * ( k : ℝ ) ^ θ by linarith [ show ( k : ℝ ) ^ θ ≥ 1 by exact Real.one_le_rpow ( by norm_cast ) ( by exact hθ0.le ) ] ) ( hθ0.le ) ) _;
rw [ Real.mul_rpow ( by positivity ) ( by positivity ), ← Real.rpow_mul ( by positivity ) ]
have count_beats_excess : ∀ (C : ℝ), 0 < C → ∀ᶠ k : ℕ in Filter.atTop, ∀ N : ℕ, (k : ℝ) ≤ (N : ℝ) → (N : ℝ) ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ + 1 → (N : ℝ) ^ θ - (k : ℝ) ^ θ + 2 < C * (N : ℝ) ^ θ / Real.log N := by
intro C hC; clear primeCard_le_add exists_prime_of_primeCard_pos tendsto_log_rpow_mul_rpow_neg hpc
-- Step 1: produce a purely-k bound and then specialize to N.
have step1 : ∀ᶠ k : ℕ in Filter.atTop, (4 : ℝ) ^ θ * (k : ℝ) ^ (θ * θ) + 3 ≤ (C / 2) * (k : ℝ) ^ θ / Real.log k := by
-- Apply `poly_log_lt` to each term separately.
have hA : ∀ᶠ k : ℕ in Filter.atTop, (4 : ℝ) ^ θ * (k : ℝ) ^ (θ * θ) ≤ (C / 4) * (k : ℝ) ^ θ / Real.log k := by
have := poly_log_lt ( ( 4 : ℝ ) ^ θ ) ( θ * θ ) 0 θ ( by nlinarith [ show 0 < θ by exact hθ0, show θ < 1 by exact hθ1 ] ) ( C / 4 ) ( by positivity );
aesop
have hB : ∀ᶠ k : ℕ in Filter.atTop, 3 ≤ (C / 4) * (k : ℝ) ^ θ / Real.log k := by
have := poly_log_lt ( 3 : ℝ ) 0 0 θ hθ0 ( C / 4 ) ( by positivity ) ; aesop;
filter_upwards [ hA, hB ] with k hk₁ hk₂ using by ring_nf at hk₁ hk₂ ⊢; linarith;
-- Step 2: Filter_upwards on [step1, eventually_ge_atTop 4] with k, hkA, hk4.
filter_upwards [step1, Filter.eventually_ge_atTop 5] with k hkA hk4;
intro N hkN hNk
have hN_le_4k : (N : ℝ) ≤ 5 * (k : ℝ) := by
linarith [ show ( k : ℝ ) ^ θ ≤ k by exact le_trans ( Real.rpow_le_rpow_of_exponent_le ( by norm_cast; linarith ) <| show θ ≤ 1 by exact le_of_lt <| hθ1 ) <| by norm_num, show ( k : ℝ ) ≥ 5 by norm_cast ]
have h_logN_le_2logk : Real.log (N : ℝ) ≤ 2 * Real.log (k : ℝ) := by
erw [ ← Real.log_pow ] ; gcongr ; norm_cast at *;
· linarith;
· norm_cast at *; nlinarith;
have h_logN_pos : 0 < Real.log (N : ℝ) := by
exact Real.log_pos <| by norm_cast at *; linarith;
have h_exp_bound : (N : ℝ) ^ θ - (k : ℝ) ^ θ + 2 < (C / 2) * (k : ℝ) ^ θ / Real.log k := by
have h_exp_bound : (N : ℝ) ^ θ - (k : ℝ) ^ θ ≤ (4 : ℝ) ^ θ * (k : ℝ) ^ (θ * θ) := by
apply excess_le k N (by linarith) hkN hNk;
linarith
have h_rhs_bound : (C / 2) * (k : ℝ) ^ θ / Real.log k ≤ C * (N : ℝ) ^ θ / Real.log N := by
rw [ div_le_div_iff₀ ] <;> try positivity;
· have h_rhs_bound : (k : ℝ) ^ θ * Real.log N ≤ 2 * (N : ℝ) ^ θ * Real.log k := by
have h_rhs_bound : (k : ℝ) ^ θ ≤ (N : ℝ) ^ θ := by
exact Real.rpow_le_rpow ( by positivity ) hkN ( by exact hθ0.le );
nlinarith [ Real.rpow_pos_of_pos ( by positivity : 0 < ( k : ℝ ) ) θ ];
nlinarith;
· exact Real.log_pos <| by norm_cast; linarith;
linarith [h_exp_bound, h_rhs_bound]
have hB : ∃ C : ℝ, 0 < C ∧ ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → C * (k : ℝ) ^ θ / Real.log k ≤ (pc (k : ℝ) ((k : ℝ) + (k : ℝ) ^ θ) : ℝ) := by
obtain ⟨C, hC, k₀, hk⟩ := hB0
exact ⟨C, hC, k₀, fun k hk' => by rw [hpc]; exact hk k hk'⟩
clear hB0
have exists_prime_in_window : ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → ∀ a : ℝ, (k : ℝ) ≤ a → a ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ → ∃ p : ℕ, p.Prime ∧ a < (p : ℝ) ∧ (p : ℝ) < a + (k : ℝ) ^ θ := by
clear tendsto_log_rpow_mul_rpow_neg poly_log_lt excess_le hpc
obtain ⟨ C, hC, k₀, hk₀ ⟩ := hB;
-- Choose `k₀' := max (max k₀ k₁) 2`.
obtain ⟨ k₁, hk₁ ⟩ := Filter.eventually_atTop.mp (count_beats_excess C hC)
use max (max k₀ k₁) 2;
intros k hk a ha₁ ha₂
set N := ⌈a⌉₊ with hN
have hN₁ : (k : ℝ) ≤ (N : ℝ) := by
exact_mod_cast ha₁.trans <| Nat.le_ceil _
have hN₂ : (N : ℝ) ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ + 1 := by
exact le_trans ( Nat.ceil_lt_add_one ( by linarith ) |> le_of_lt ) ( by linarith )
have hN₃ : (N : ℝ) < a + 1 := by
exact Nat.ceil_lt_add_one ( by linarith [ show ( k : ℝ ) ≥ 2 by norm_cast; linarith [ le_max_right ( max k₀ k₁ ) 2 ] ] )
have hN₄ : (k : ℝ) ≤ N := by
exact_mod_cast hN₁
have hN₅ : (N : ℝ) ≤ (k : ℝ) + 3 * (k : ℝ) ^ θ + 1 := by
convert hN₂ using 1;
-- Apply `hk₀` to get `bhpN : C*(N:ℝ)^θ/Real.log N ≤ pc (N:ℝ) ((N:ℝ)+(N:ℝ)^θ)`.
have h_bhpN : C * (N : ℝ) ^ θ / Real.log N ≤ pc (N : ℝ) ((N : ℝ) + (N : ℝ) ^ θ) := by
exact hk₀ N ( by norm_cast at *; linarith [ Nat.le_max_left ( max k₀ k₁ ) 2, Nat.le_max_right ( max k₀ k₁ ) 2, Nat.le_max_left k₀ k₁, Nat.le_max_right k₀ k₁ ] );
-- Apply `primeCard_le_add` to bound the prime count in `(N, a + k^θ)`.
have h_primeCard_le_add : pc (N : ℝ) (a + (k : ℝ) ^ θ) ≥ pc (N : ℝ) ((N : ℝ) + (N : ℝ) ^ θ) - ((N : ℝ) ^ θ - (k : ℝ) ^ θ + 2) := by
have h_primeCard_le_add : pc (N : ℝ) ((N : ℝ) + (N : ℝ) ^ θ) ≤ pc (N : ℝ) (a + (k : ℝ) ^ θ) + ((N : ℝ) + (N : ℝ) ^ θ - (a + (k : ℝ) ^ θ) + 1) := by
convert primeCard_le_add ( N : ℝ ) ( a + ( k : ℝ ) ^ θ ) ( N + ( N : ℝ ) ^ θ ) _ using 1;
exact add_le_add ( Nat.le_ceil _ ) ( Real.rpow_le_rpow ( by linarith ) ( by linarith ) ( by exact hθ0.le ) );
linarith;
-- Therefore, `pc (N:ℝ) (a + k^θ) > 0`.
have h_primeCard_pos : 0 < pc (N : ℝ) (a + (k : ℝ) ^ θ) := by
exact_mod_cast ( by linarith [ hk₁ k ( by linarith [ le_max_left ( max k₀ k₁ ) 2, le_max_right ( max k₀ k₁ ) 2, le_max_left k₀ k₁, le_max_right k₀ k₁ ] ) N hN₄ hN₅ ] : ( 0 : ℝ ) < pc ( N : ℝ ) ( a + k ^ θ ) );
exact exists_prime_of_primeCard_pos _ _ h_primeCard_pos |> fun ⟨ p, hp₁, hp₂, hp₃ ⟩ => ⟨ p, hp₁, by linarith [ Nat.le_ceil a, show ( p : ℝ ) ≥ N by exact_mod_cast hp₂.le ], hp₃ ⟩
exact exists_prime_in_window
private theorem sm_carry_of_mult (n k p j : ℕ) (hp : 0 < p) (h1 : n < j * p + k)
(h2 : (j + 1) * p ≤ n) : n % p + p < k := by
have h3 : j + 1 ≤ n / p := (Nat.le_div_iff_mul_le hp).2 h2
have h4 : p * (n / p) + n % p = n := Nat.div_add_mod n p
have h5 : p * (j + 1) ≤ p * (n / p) := Nat.mul_le_mul_left p h3
have e : p * (j + 1) = j * p + p := by ring
omega
private theorem sm_caseA (k n j : ℕ) (h : ℝ) (hj : 3 ≤ j)
(hJ2 : 2 * n < (j + 1 + 1) * k)
(hc : ((j : ℝ) + 1) * (k + 2 * h) ≤ 2 * n)
(p : ℕ) (hp1 : (k : ℝ) / 2 < p) (hp2 : (p : ℝ) < k / 2 + h) :
n < j * p + k ∧ (j + 1) * p ≤ n := by
have hj0 : (0 : ℝ) < j := by exact_mod_cast (show 0 < j by omega)
have hJ2' : (2 : ℝ) * n < ((j : ℝ) + 1 + 1) * k := by exact_mod_cast hJ2
have e1 : (j : ℝ) * ((k : ℝ) / 2) < j * p := mul_lt_mul_of_pos_left hp1 hj0
have e2 : ((j : ℝ) + 1) * p < (j + 1) * (k / 2 + h) :=
mul_lt_mul_of_pos_left hp2 (by linarith)
constructor
· have : (n : ℝ) < (j : ℝ) * p + k := by linarith
exact_mod_cast this
· have : ((j : ℝ) + 1) * p ≤ n := by linarith
exact_mod_cast this
private theorem sm_caseB (k n K j : ℕ) (h : ℝ) (hh : 1 ≤ h) (hj : 2 ≤ j)
(hK1 : (K : ℝ) ≤ k / 2) (hK2 : (k : ℝ) / 2 ≤ K + 1 / 2)
(hJ1 : (j + 2) * k ≤ 2 * n)
(hc : (2 : ℝ) * n < ((j : ℝ) + 2) * (k + 2 * h))
(hsize : h * ((j : ℝ) + 2 + 1) ≤ (k : ℝ) / 2)
(hW : ∀ a : ℝ, (K : ℝ) ≤ a → a ≤ K + 3 * h → ∃ p : ℕ, p.Prime ∧ a < p ∧ (p : ℝ) < a + h) :
∃ p : ℕ, p.Prime ∧ k < 2 * p ∧ n < j * p + k ∧ (j + 1) * p ≤ n := by
have hj0 : (0 : ℝ) < j := by exact_mod_cast (show 0 < j by omega)
have hj2 : (2 : ℝ) ≤ j := by exact_mod_cast hj
have hJ1' : ((j : ℝ) + 2) * k ≤ 2 * n := by exact_mod_cast hJ1
have hhj1 : 2 * h ≤ h * j := by nlinarith
have hhj2 : (j : ℝ) ≤ h * j := by nlinarith
have haj : ((n : ℝ) - k) / j * j = n - k := div_mul_cancel₀ _ (ne_of_gt hj0)
have ha1 : (k : ℝ) / 2 ≤ ((n : ℝ) - k) / j := by
rw [le_div_iff₀ hj0]; linarith
have ha2 : ((n : ℝ) - k) / j ≤ K + 3 * h := by
rw [div_le_iff₀ hj0]
have : (j : ℝ) * ((k : ℝ) / 2) ≤ j * (K + 1 / 2) := mul_le_mul_of_nonneg_left hK2 hj0.le
linarith
obtain ⟨p, hp, hp1, hp2⟩ := hW (((n : ℝ) - k) / j) (le_trans hK1 ha1) ha2
refine ⟨p, hp, ?_, ?_, ?_⟩
· have : (k : ℝ) < 2 * p := by linarith
exact_mod_cast this
· have e1 : ((n : ℝ) - k) / j * j < p * j := mul_lt_mul_of_pos_right hp1 hj0
have : (n : ℝ) < (j : ℝ) * p + k := by linarith
exact_mod_cast this
· have e2 : (p : ℝ) * j < (((n : ℝ) - k) / j + h) * j := mul_lt_mul_of_pos_right hp2 hj0
have e3 : (j : ℝ) * (h * ((j : ℝ) + 2 + 1)) ≤ j * ((k : ℝ) / 2) :=
mul_le_mul_of_nonneg_left hsize hj0.le
have e4 : (j : ℝ) * (2 * h) ≤ j * (h * j) := mul_le_mul_of_nonneg_left hhj1 hj0.le
-- j * ((j+1) p) ≤ j * n
have e5 : (j : ℝ) * (((j : ℝ) + 1) * p) ≤ j * n := by
have e6 : (p : ℝ) * j * (j + 1) < (((n : ℝ) - k) / j + h) * j * (j + 1) :=
mul_lt_mul_of_pos_right e2 (by linarith)
have e7 : (((n : ℝ) - k) / j + h) * j * (j + 1) = (n - k + h * j) * (j + 1) := by
rw [add_mul, haj]
nlinarith
have : ((j : ℝ) + 1) * p ≤ n := le_of_mul_le_mul_left e5 hj0
exact_mod_cast this
private theorem sm_core (k n K J : ℕ) (h : ℝ) (hh : 1 ≤ h)
(hK1 : (K : ℝ) ≤ k / 2) (hK2 : (k : ℝ) / 2 ≤ K + 1 / 2)
(hJ4 : 4 ≤ J) (hJ1 : J * k ≤ 2 * n) (hJ2 : 2 * n < (J + 1) * k)
(hsize : h * ((J : ℝ) + 1) ≤ (k : ℝ) / 2)
(hW : ∀ a : ℝ, (K : ℝ) ≤ a → a ≤ K + 3 * h → ∃ p : ℕ, p.Prime ∧ a < p ∧ (p : ℝ) < a + h) :
∃ p : ℕ, p.Prime ∧ k < 2 * p ∧ n % p + p < k := by
by_cases hc : (J : ℝ) * (k + 2 * h) ≤ 2 * n
· obtain ⟨j, rfl⟩ : ∃ j, J = j + 1 := ⟨J - 1, by omega⟩
obtain ⟨p, hp, hp1, hp2⟩ := hW ((k : ℝ) / 2) hK1 (by linarith)
have hc' : ((j : ℝ) + 1) * (k + 2 * h) ≤ 2 * n := by exact_mod_cast hc
obtain ⟨h1, h2⟩ := sm_caseA k n j h (by omega) hJ2 hc' p hp1 hp2
refine ⟨p, hp, ?_, sm_carry_of_mult n k p j hp.pos h1 h2⟩
have : (k : ℝ) < 2 * p := by linarith
exact_mod_cast this
· push Not at hc
obtain ⟨j, rfl⟩ : ∃ j, J = j + 2 := ⟨J - 2, by omega⟩
have hc' : (2 : ℝ) * n < ((j : ℝ) + 2) * (k + 2 * h) := by exact_mod_cast hc
have hs' : h * ((j : ℝ) + 2 + 1) ≤ (k : ℝ) / 2 := by exact_mod_cast hsize
obtain ⟨p, hp, hkp, h1, h2⟩ := sm_caseB k n K j h hh (by omega) hK1 hK2 hJ1 hc' hs' hW
exact ⟨p, hp, hkp, sm_carry_of_mult n k p j hp.pos h1 h2⟩
private theorem sm_small_gen (θ : ℝ) (hθ0 : 0 < θ) (hθ1 : θ < 1)
(hB0 : ∃ C : ℝ, 0 < C ∧ ∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → C * (k : ℝ) ^ θ / Real.log k ≤
(((Finset.Ioo ⌊(k : ℝ)⌋ ⌈(k : ℝ) + (k : ℝ) ^ θ⌉).filter (fun p : ℤ => 0 < p ∧ (p.natAbs).Prime ∧ (k : ℝ) < (p : ℝ) ∧ (p : ℝ) < (k : ℝ) + (k : ℝ) ^ θ)).card : ℝ)) :
∃ k₀ : ℕ, ∀ k : ℕ, k₀ ≤ k → ∀ n : ℕ, 2 * k ≤ n →
(n : ℝ) ≤ (1 / 2 : ℝ) * ((k : ℝ) / 2) ^ ((2 : ℝ) - θ) + 2 * (k : ℝ) →
∃ p : ℕ, p.Prime ∧ k < 2 * p ∧ n % p + p < k := by
obtain ⟨kw, hw⟩ := sm_window θ hθ0 hθ1 hB0
have hv : ∀ᶠ x : ℝ in Filter.atTop, (10 : ℝ) ≤ x ^ (1 - θ) :=
(tendsto_rpow_atTop (by linarith : (0 : ℝ) < 1 - θ)).eventually_ge_atTop 10
obtain ⟨x₀, hx₀⟩ := Filter.eventually_atTop.mp hv
refine ⟨max (2 * kw + 2) (2 * ⌈x₀⌉₊ + 2), ?_⟩
intro k hk n hn1 hn2
have hk1 : 2 * kw + 2 ≤ k := le_trans (le_max_left _ _) hk
have hk2 : 2 * ⌈x₀⌉₊ + 2 ≤ k := le_trans (le_max_right _ _) hk
have hkpos : 0 < k := by omega
-- J = ⌊2n/k⌋
have hJ1 : (2 * n / k) * k ≤ 2 * n := Nat.div_mul_le_self _ _
have hJ2 : 2 * n < (2 * n / k + 1) * k := by
have e1 := Nat.div_add_mod (2 * n) k
have e2 := Nat.mod_lt (2 * n) hkpos
have e3 : (2 * n / k + 1) * k = k * (2 * n / k) + k := by ring
omega
have hJ4 : 4 ≤ 2 * n / k := (Nat.le_div_iff_mul_le hkpos).2 (by omega)
generalize 2 * n / k = J at hJ1 hJ2 hJ4
-- K = ⌊k/2⌋
obtain ⟨K, hK⟩ : ∃ K : ℕ, K = k / 2 := ⟨_, rfl⟩
have hKk1 : 2 * K ≤ k := by omega
have hKk2 : k ≤ 2 * K + 1 := by omega
have hkwK : kw ≤ K := by omega
have hK1 : (K : ℝ) ≤ (k : ℝ) / 2 := by
have : ((2 * K : ℕ) : ℝ) ≤ (k : ℝ) := by exact_mod_cast hKk1
push_cast at this; linarith
have hK2 : (k : ℝ) / 2 ≤ (K : ℝ) + 1 / 2 := by
have : (k : ℝ) ≤ ((2 * K + 1 : ℕ) : ℝ) := by exact_mod_cast hKk2
push_cast at this; linarith
have hKone : (1 : ℝ) ≤ (K : ℝ) := by exact_mod_cast (show 1 ≤ K by omega)
have hx0 : (0 : ℝ) < (k : ℝ) / 2 := by linarith
have hxx : x₀ ≤ (k : ℝ) / 2 := by
have h1 : ((2 * ⌈x₀⌉₊ + 2 : ℕ) : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk2
push_cast at h1
linarith [Nat.le_ceil x₀]
have hv10 : (10 : ℝ) ≤ ((k : ℝ) / 2) ^ (1 - θ) := hx₀ _ hxx
have hu : (0 : ℝ) < ((k : ℝ) / 2) ^ θ := Real.rpow_pos_of_pos hx0 _
have huv : ((k : ℝ) / 2) ^ θ * ((k : ℝ) / 2) ^ (1 - θ) = (k : ℝ) / 2 := by
rw [← Real.rpow_add hx0]; simp
have hpow : ((k : ℝ) / 2) ^ ((2 : ℝ) - θ) = ((k : ℝ) / 2) ^ (1 - θ) * ((k : ℝ) / 2) := by
rw [show (2 : ℝ) - θ = (1 - θ) + 1 by ring, Real.rpow_add hx0, Real.rpow_one]
have hh1 : (1 : ℝ) ≤ (K : ℝ) ^ θ := Real.one_le_rpow hKone hθ0.le
have hhu : (K : ℝ) ^ θ ≤ ((k : ℝ) / 2) ^ θ := Real.rpow_le_rpow (by linarith) hK1 hθ0.le
have hJ1' : (J : ℝ) * (k : ℝ) ≤ 2 * (n : ℝ) := by exact_mod_cast hJ1
rw [hpow] at hn2
generalize ((k : ℝ) / 2) ^ (1 - θ) = v at hv10 huv hn2
generalize ((k : ℝ) / 2) ^ θ = u at hu huv hhu
have hwK := hw K hkwK
clear hw
generalize (K : ℝ) ^ θ = h at hh1 hhu hwK
have hJv : (J : ℝ) ≤ v / 2 + 4 := by
have e : (J : ℝ) * 2 * ((k : ℝ) / 2) ≤ (v + 8) * ((k : ℝ) / 2) := by linarith
have := le_of_mul_le_mul_right e hx0
linarith
have hsize : h * ((J : ℝ) + 1) ≤ (k : ℝ) / 2 := by
have hJ0 : (0 : ℝ) ≤ (J : ℝ) + 1 := by positivity
have a1 : h * ((J : ℝ) + 1) ≤ u * ((J : ℝ) + 1) := mul_le_mul_of_nonneg_right hhu hJ0
have a2 : u * ((J : ℝ) + 1) ≤ u * (v / 2 + 5) := mul_le_mul_of_nonneg_left (by linarith) hu.le
have a3 : u * 10 ≤ u * v := mul_le_mul_of_nonneg_left hv10 hu.le
linarith
exact sm_core k n K J h hh1 hK1 hK2 hJ4 hJ1 hJ2 hsize hwK
theorem erdos_1094__h2__h1__h1__h6 : (¬∃ (C : ℝ),
(0 : ℝ) < C ∧
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤
(↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ |
(0 : ℤ) < p ∧
Nat.Prime p.natAbs ∧
(↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card :
ℝ)) ∨
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
∀ (n : ℕ),
(2 : ℕ) * k ≤ n →
(↑n : ℝ) ≤ (1 / 2 : ℝ) * ((↑k : ℝ) / (2 : ℝ)) ^ ((2 : ℝ) - (21 / 40 : ℝ)) + (2 : ℝ) * (↑k : ℝ) →
∃ (p : ℕ), Nat.Prime p ∧ k < (2 : ℕ) * p ∧ n % p + p < k := by
by_cases hB : ∃ (C : ℝ),
(0 : ℝ) < C ∧
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤
(↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ |
(0 : ℤ) < p ∧
Nat.Prime p.natAbs ∧ (↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card :
ℝ)
· exact Or.inr (sm_small_gen (21 / 40) (by norm_num) (by norm_num) hB)
· exact Or.inl hBWhat is known
Work on it
How to contribute → · Pull requests in flight ↗ · See it in the problem’s graph →
Record
Statement: the Lean file and its words (2 versions)
Statement not audited — only a problem’s root statement is audited for fidelity (D-9); the kernel checks a proof against this Lean as written.
import Mathlib
import Nodes.«erdos-1094--h2--h1--h1--h6».Context
open scoped Nat
/-! Hole `h_small` of a merged partial proof, as a node (D-12 #5, D-29).
Statement generated by the gate from the assembly; immutable (D-3). -/
theorem erdos_1094__h2__h1__h1__h6 : (¬∃ (C : ℝ),
(0 : ℝ) < C ∧
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
C * (↑k : ℝ) ^ (21 / 40 : ℝ) / Real.log (↑k : ℝ) ≤
(↑{p ∈ Finset.Ioo ⌊(↑k : ℝ)⌋ ⌈(↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)⌉ |
(0 : ℤ) < p ∧
Nat.Prime p.natAbs ∧
(↑k : ℝ) < (↑p : ℝ) ∧ (↑p : ℝ) < (↑k : ℝ) + (↑k : ℝ) ^ (21 / 40 : ℝ)}.card :
ℝ)) ∨
∃ (k₀ : ℕ),
∀ (k : ℕ),
k₀ ≤ k →
∀ (n : ℕ),
(2 : ℕ) * k ≤ n →
(↑n : ℝ) ≤ (1 / 2 : ℝ) * ((↑k : ℝ) / (2 : ℝ)) ^ ((2 : ℝ) - (21 / 40 : ℝ)) + (2 : ℝ) * (↑k : ℝ) →
∃ (p : ℕ), Nat.Prime p ∧ k < (2 : ℕ) * p ∧ n % p + p < k := by
sorryA statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →
In words, unverified — what this statement says; written by t1111-c, drafted with Claude Fable 5.2 (claude-fable-5-2), 2026-11-11; no one has read it against the Lean and signed it.
Draft · drafted, by the model named above
$\displaystyle \neg\,\text{BHP}\ \ \lor\ \ \exists k_0\in\mathbb{N}\ \forall k\ge k_0\ \forall n\in\mathbb{N}:\ \ 2k\le n\le\tfrac12\bigl(\tfrac{k}{2}\bigr)^{2-21/40}+2k\ \Longrightarrow\ \exists p\text{ prime},\ \ k<2p,\ \ (n\bmod p)+p<k$
Either the Baker–Harman–Pintz short-interval prime count fails, or for all large $k$ and every natural number $n$ with $2k\le n\le\tfrac12(k/2)^{2-21/40}+2k$ there is a prime $p>k/2$ with $(n\bmod p)+p<k$. Here BHP is the statement of the node erdos-1094--h2--h2--h1, word for word: $\exists C>0\ \exists k_0\ \forall k\ge k_0:\ C\,k^{21/40}/\log k\le\#\{p\text{ prime}:k<p<k+k^{21/40}\}$, the primes counted as the integers of the interval $(\lfloor k\rfloor,\lceil k+k^{21/40}\rceil)$ that are positive, prime in absolute value and lie strictly between $k$ and $k+k^{21/40}$ over the reals.
$k$, $n$ and $p$ are natural numbers and $n\bmod p$ is the remainder of $n$ on division by $p$. The upper bound on $n$ is an inequality of real numbers: $k/2$ is the real number (not rounded), $2-21/40$ is a real exponent and $\log$ is the natural logarithm.
Since $n\bmod p\ge 0$, the conclusion forces $k/2<p<k$. The inequality $(n\bmod p)+p<k$ says exactly that the two largest multiples of $p$ not exceeding $n$, namely $n-(n\bmod p)$ and $n-(n\bmod p)-p$, both lie among the $k$ consecutive integers $n-k+1,\dots,n$.
Rendered from gloss/1876c4e6884a….md · Improve these words →
History: 2 versions on record
2026-11-11 · written by t1111-a, drafted with claude-fable-5-2 · not signed · gloss/672a12c6c8fa….md · the first version of its chain
Read this version
$\displaystyle \text{BHP fails, or } \exists k_0\ \forall k \ge k_0\ \forall n,\ 2k \le n \le \tfrac12 (k/2)^{2-21/40} + 2k:\ \exists p \text{ prime},\ k < 2p,\ (n \bmod p) + p < k$
The condition $(n \bmod p) + p < k$ says that two multiples of $p$ lie among $n-k+1, \dots, n$. BHP is the statement of the hole
h_bhp.2026-11-11 · written by t1111-c, drafted with Claude Fable 5.2 (claude-fable-5-2) · not signed · current · gloss/1876c4e6884a….md · diff to its predecessor
Read this version
$\displaystyle \neg\,\text{BHP}\ \ \lor\ \ \exists k_0\in\mathbb{N}\ \forall k\ge k_0\ \forall n\in\mathbb{N}:\ \ 2k\le n\le\tfrac12\bigl(\tfrac{k}{2}\bigr)^{2-21/40}+2k\ \Longrightarrow\ \exists p\text{ prime},\ \ k<2p,\ \ (n\bmod p)+p<k$
Either the Baker–Harman–Pintz short-interval prime count fails, or for all large $k$ and every natural number $n$ with $2k\le n\le\tfrac12(k/2)^{2-21/40}+2k$ there is a prime $p>k/2$ with $(n\bmod p)+p<k$. Here BHP is the statement of the node
erdos-1094--h2--h2--h1, word for word: $\exists C>0\ \exists k_0\ \forall k\ge k_0:\ C\,k^{21/40}/\log k\le\#\{p\text{ prime}:k<p<k+k^{21/40}\}$, the primes counted as the integers of the interval $(\lfloor k\rfloor,\lceil k+k^{21/40}\rceil)$ that are positive, prime in absolute value and lie strictly between $k$ and $k+k^{21/40}$ over the reals.$k$, $n$ and $p$ are natural numbers and $n\bmod p$ is the remainder of $n$ on division by $p$. The upper bound on $n$ is an inequality of real numbers: $k/2$ is the real number (not rounded), $2-21/40$ is a real exponent and $\log$ is the natural logarithm.
Since $n\bmod p\ge 0$, the conclusion forces $k/2<p<k$. The inequality $(n\bmod p)+p<k$ says exactly that the two largest multiples of $p$ not exceeding $n$, namely $n-(n\bmod p)$ and $n-(n\bmod p)-p$, both lie among the $k$ consecutive integers $n-k+1,\dots,n$.
Diff of 1876c4e6884a against 672a12c6c8fa
@@ -1,3 +1,7 @@ -$$\text{BHP fails, or } \exists k_0\ \forall k \ge k_0\ \forall n,\ 2k \le n \le \tfrac12 (k/2)^{2-21/40} + 2k:\ \exists p \text{ prime},\ k < 2p,\ (n \bmod p) + p < k$$ +$$\neg\,\text{BHP}\ \ \lor\ \ \exists k_0\in\mathbb{N}\ \forall k\ge k_0\ \forall n\in\mathbb{N}:\ \ 2k\le n\le\tfrac12\bigl(\tfrac{k}{2}\bigr)^{2-21/40}+2k\ \Longrightarrow\ \exists p\text{ prime},\ \ k<2p,\ \ (n\bmod p)+p<k$$ -The condition $(n \bmod p) + p < k$ says that two multiples of $p$ lie among $n-k+1, \dots, n$. BHP is the statement of the hole `h_bhp`. +Either the Baker–Harman–Pintz short-interval prime count fails, or for all large $k$ and every natural number $n$ with $2k\le n\le\tfrac12(k/2)^{2-21/40}+2k$ there is a prime $p>k/2$ with $(n\bmod p)+p<k$. Here BHP is the statement of the node `erdos-1094--h2--h2--h1`, word for word: $\exists C>0\ \exists k_0\ \forall k\ge k_0:\ C\,k^{21/40}/\log k\le\#\{p\text{ prime}:k<p<k+k^{21/40}\}$, the primes counted as the integers of the interval $(\lfloor k\rfloor,\lceil k+k^{21/40}\rceil)$ that are positive, prime in absolute value and lie strictly between $k$ and $k+k^{21/40}$ over the reals. + +$k$, $n$ and $p$ are natural numbers and $n\bmod p$ is the remainder of $n$ on division by $p$. The upper bound on $n$ is an inequality of real numbers: $k/2$ is the real number (not rounded), $2-21/40$ is a real exponent and $\log$ is the natural logarithm. + +Since $n\bmod p\ge 0$, the conclusion forces $k/2<p<k$. The inequality $(n\bmod p)+p<k$ says exactly that the two largest multiples of $p$ not exceeding $n$, namely $n-(n\bmod p)$ and $n-(n\bmod p)-p$, both lie among the $k$ consecutive integers $n-k+1,\dots,n$.
Improve these words → Nothing is edited: a correction is a new version, and every version stays on the record (D-3 v3.30).
Rendered from targets/erdos-1094/nodes/erdos-1094--h2--h1--h1--h6/Statement.lean. Origin: compiler-derived.
Attestation: pass, 7 of 7 checks
Checked by the kernel — the gate’s record of the run: attestations/001293.erdos-1094--h2--h1--h1--h6.json, merge commit 770951feaea3.
Verdict pass, from attestations/001293.erdos-1094--h2--h1--h1--h6.json.
- Submitter
t1111-a- Toolchain
- leanprover/lean4:v4.33.1 (hash
f54d0bc916bf76a7fae460ce9d078ccd1f74aeb4fd12c4b6546bca28b6aa1c63) - Mathlib
- 0df444a360eaa60ab8c11dca51a86af692955474
- Reviewer
- none needed (intermediate)
| Step | Check | Result |
|---|---|---|
| 1 | toolchain | pass |
| 2 | paths | pass |
| 4 | kernel-replay | pass |
| 5 | axioms | pass |
| 6 | hazards | pass |
| 7 | witness | pass |
| 8 | deps | pass |
Witness
Checked by the kernel — step 7 passed in the run its attestation records: attestations/001293.erdos-1094--h2--h1--h1--h6.json, merge commit 770951feaea3.
1aa8a1c1b9f3.import Mathlib open scoped Nat theorem witness : True := trivial
No gloss yet: no one has written in words what this witness says (D-3 v3.30); the Lean above is the witness. How to write one →