Problems / erdos-1094 / erdos-1094--h3--h3--h2
Sander equidistribution: Σ({n/p} − 1/2) log p = o(k)
erdos-1094--h3--h3--h2
open
Hole h_sander of erdos-1094--h3--h3 (split by 20261015T132200Z-t1015b-g-partial.lean).
$\displaystyle \forall C\in\mathbb{N},\ \varepsilon>0\ \exists K_4\ \forall n,k\in\mathbb{N}:\quad K_4<k,\ \ k^2\le C\cdot n\cdot\lfloor\log_2 k\rfloor,\ \ n<k^2 \implies \Bigl|\sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}} \Bigl(\Bigl\{\frac{n}{p}\Bigr\}-\frac12\Bigr)\log p\Bigr| \le \varepsilon k$
For every constant $C$ and every real $\varepsilon>0$ there is a threshold $K_4$ such that for all $k>K_4$ and all $n<k^2$ with $k^2\le C\,n\lfloor\log_2 k\rfloor$, the sum over primes $p$ with $k<2p$ and $20p<11k$ of $(\{n/p\}-\tfrac12)\log p$ has absolute value at most $\varepsilon k$. Here $\{n/p\}$ is Int.fract of the real quotient of the casts, $\log$ is Real.log, the sum runs over Finset.range k filtered by the three conditions, and the range hypotheses are in $\mathbb{N}$ where Nat.log 2 k is $\lfloor\log_2 k\rfloor$ (and $0$ for $k\le 1$), a natural number, so the right-hand side is a product of naturals.
Lean
theorem erdos_1094__h3__h3__h2 : ∀ (C : ℕ) (ε : ℝ),
(0 : ℝ) < ε →
∃ (K₄ : ℕ),
∀ (n k : ℕ),
K₄ < k →
k * k ≤ C * (n * Nat.log (2 : ℕ) k) →
n < k * k →
|∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k,
(Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑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 →
How it is being proved
Open. A direct proof, or proofs of its holes, close it.
Proved from this hole by 20261015T145123Z-t1015c-a02-partial.lean (merged in 40aad8949bad, attestation 000552).
h_l51→ erdos-1094--h3--h3--h2--h1 (open)$\displaystyle \forall C\in\mathbb{N},\ \delta>0\ \exists K_5\ \forall n,k\in\mathbb{N},\ K_5<k,\ k^2\le C n\lfloor\log_2 k\rfloor,\ n<k^2,\ \forall \sigma\in[0,1]:\quad \Bigl|\sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}}\ [\{n/p\}<\sigma]\,\log p \;-\; \sigma \sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}} \log p\Bigr| \le \delta k$
Read the partial proof (Lean)
private lemma floor_count (M : ℕ) (hM : 0 < M) (f : ℝ) (h0 : 0 ≤ f) (h1 : f < 1) :
f - 1 / M ≤ (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) ∧
(1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) ≤ f := by
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
set m := ⌊(M : ℝ) * f⌋₊ with hm
have hmf : (m : ℝ) ≤ M * f := Nat.floor_le (by positivity)
have hfm : M * f < m + 1 := Nat.lt_floor_add_one _
have hmM : m ≤ M := by
have : (m : ℝ) < M := by nlinarith
exact_mod_cast this.le
have key : ∀ j : ℕ, ((j : ℝ) / M ≤ f ↔ j ≤ m) := by
intro j
rw [div_le_iff₀ hMr, hm, Nat.le_floor_iff (by positivity), mul_comm]
have hsum : ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) = m := by
simp_rw [key]
rw [Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.sum_const, nsmul_eq_mul, mul_one]
have : (Finset.Icc 1 M).filter (fun j => j ≤ m) = Finset.Icc 1 m := by
ext j; simp only [Finset.mem_filter, Finset.mem_Icc]; omega
rw [this, Nat.card_Icc]; simp
rw [hsum]
constructor
· rw [div_mul_eq_mul_div, one_mul, le_div_iff₀ hMr, sub_mul, one_div, inv_mul_cancel₀ hMr.ne']; nlinarith
· rw [div_mul_eq_mul_div, one_mul, div_le_iff₀ hMr]; nlinarith
private lemma gauss_Icc (M : ℕ) : ∑ j ∈ Finset.Icc 1 M, (j : ℝ) = (M : ℝ) * (M + 1) / 2 := by
induction M with
| zero => simp
| succ m ih =>
rw [Finset.sum_Icc_succ_top (by omega), ih]
push_cast; ring
theorem erdos_1094__h3__h3__h2 : ∀ (C : ℕ) (ε : ℝ),
(0 : ℝ) < ε →
∃ (K₄ : ℕ),
∀ (n k : ℕ),
K₄ < k →
k * k ≤ C * (n * Nat.log (2 : ℕ) k) →
n < k * k →
|∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k,
(Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤
ε * (↑k : ℝ) := by
have h_theta : ∀ k : ℕ, ∑ p ∈ (Finset.range k).filter
(fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k), Real.log p ≤ 2 * k := by
intro k
have hsub : (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) ⊆
(Finset.Ioc 0 ⌊(k : ℝ)⌋₊).filter Nat.Prime := by
intro p hp
simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ioc, Nat.floor_natCast] at hp ⊢
exact ⟨⟨hp.2.1.pos, hp.1.le⟩, hp.2.1⟩
have hlog4 : Real.log 4 ≤ 2 := by
rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]
push_cast
linarith [Real.log_two_lt_d9]
calc _ ≤ Chebyshev.theta k := by
rw [Chebyshev.theta]
exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => Real.log_natCast_nonneg p)
_ ≤ Real.log 4 * k := Chebyshev.theta_le_log4_mul_x (by positivity)
_ ≤ 2 * k := by gcongr
have h_l51 : ∀ (C : ℕ) (δ : ℝ), 0 < δ → ∃ K₅ : ℕ, ∀ n k : ℕ, K₅ < k →
k * k ≤ C * (n * Nat.log 2 k) → n < k * k → ∀ σ : ℝ, 0 ≤ σ → σ ≤ 1 →
|∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k),
(if Int.fract ((n : ℝ) / p) < σ then Real.log p else 0) -
σ * ∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k),
Real.log p| ≤ δ * k := by
sorry
intro C ε hε
obtain ⟨K₅, hL5⟩ := h_l51 C (ε / 4) (by positivity)
refine ⟨K₅, fun n k hk hlow hup => ?_⟩
set S := (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) with hS
set L := ∑ p ∈ S, Real.log p with hLdef
have hlog0 : ∀ p : ℕ, 0 ≤ Real.log p := fun p => Real.log_natCast_nonneg p
have hL0 : 0 ≤ L := Finset.sum_nonneg (fun p _ => hlog0 p)
have hL2 : L ≤ 2 * k := h_theta k
have hk0 : (0 : ℝ) ≤ k := by positivity
set M : ℕ := ⌈4 / ε⌉₊ + 1 with hMdef
have hM : 0 < M := by omega
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
have hM4 : 4 / ε ≤ M := by
have := Nat.le_ceil (4 / ε)
have h2 : ((⌈4 / ε⌉₊ : ℕ) : ℝ) ≤ M := by exact_mod_cast (Nat.le_succ _)
linarith
have hinvM : 1 / (M : ℝ) ≤ ε / 4 := by
rw [div_le_iff₀ hMr]
have := (div_le_iff₀ hε).1 hM4
nlinarith
set f : ℕ → ℝ := fun p => Int.fract ((n : ℝ) / p) with hf
set A : ℕ → ℝ := fun p => (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M,
(if (j : ℝ) / M ≤ f p then (1 : ℝ) else 0) with hAdef
have hA : ∀ p, f p - 1 / M ≤ A p ∧ A p ≤ f p := fun p =>
floor_count M hM (f p) (Int.fract_nonneg _) (Int.fract_lt_one _)
-- the swap of the two sums
have hswap : ∑ p ∈ S, A p * Real.log p = (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M,
∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) := by
rw [Finset.sum_comm, Finset.mul_sum]
apply Finset.sum_congr rfl
intro p _
rw [hAdef]; simp only
rw [mul_assoc, Finset.sum_mul]
congr 1
apply Finset.sum_congr rfl
intro j _
split_ifs <;> simp
-- each inner sum is L minus the count below σ = j/M
have hinner : ∀ j ∈ Finset.Icc 1 M,
|∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - (L - ((j : ℝ) / M) * L)| ≤
ε / 4 * k := by
intro j hj
rw [Finset.mem_Icc] at hj
have hσ0 : (0 : ℝ) ≤ (j : ℝ) / M := by positivity
have hσ1 : (j : ℝ) / M ≤ 1 := by
rw [div_le_one hMr]; exact_mod_cast hj.2
have h := hL5 n k hk hlow hup ((j : ℝ) / M) hσ0 hσ1
have hsplit : ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) =
L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) := by
rw [hLdef, ← Finset.sum_sub_distrib]
apply Finset.sum_congr rfl
intro p _
by_cases hc : (j : ℝ) / M ≤ f p
· rw [if_pos hc, if_neg (not_lt.2 hc)]; ring
· rw [if_neg hc, if_pos (not_le.1 hc)]; ring
rw [hsplit]
have : L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (L - (j : ℝ) / M * L) =
-(∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (j : ℝ) / M * L) := by ring
rw [this, abs_neg]
exact h
-- sum over j
have hgsum : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = L * ((M : ℝ) - 1) / 2 := by
have : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) =
(M : ℝ) * L - (L / M) * ∑ j ∈ Finset.Icc 1 M, (j : ℝ) := by
rw [show ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) =
∑ j ∈ Finset.Icc 1 M, (L - L / M * (j : ℝ)) from
Finset.sum_congr rfl (fun j _ => by ring)]
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, Finset.sum_const, Nat.card_Icc]
simp only [nsmul_eq_mul, Nat.add_sub_cancel]
rw [this, gauss_Icc]; field_simp; ring
have hE : |∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) -
L * ((M : ℝ) - 1) / 2| ≤ M * (ε / 4 * k) := by
rw [← hgsum, ← Finset.sum_sub_distrib]
calc _ ≤ ∑ j ∈ Finset.Icc 1 M, |∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) -
(L - ((j : ℝ) / M) * L)| := Finset.abs_sum_le_sum_abs _ _
_ ≤ ∑ j ∈ Finset.Icc 1 M, ε / 4 * k := Finset.sum_le_sum hinner
_ = M * (ε / 4 * k) := by rw [Finset.sum_const, Nat.card_Icc]; simp
-- bracket Σ f log p between Σ A log p and Σ A log p + L/M
have hlo : ∑ p ∈ S, A p * Real.log p ≤ ∑ p ∈ S, f p * Real.log p :=
Finset.sum_le_sum (fun p _ => mul_le_mul_of_nonneg_right (hA p).2 (hlog0 p))
have hhi : ∑ p ∈ S, f p * Real.log p ≤ ∑ p ∈ S, A p * Real.log p + L / M := by
rw [hLdef, Finset.sum_div, ← Finset.sum_add_distrib]
apply Finset.sum_le_sum; intro p _
have := (hA p).1
have hl := hlog0 p
have : f p * Real.log p ≤ (A p + 1 / M) * Real.log p :=
mul_le_mul_of_nonneg_right (by linarith) hl
linarith [show (A p + 1 / M) * Real.log p = A p * Real.log p + Real.log p / M by ring]
have htarget : ∑ p ∈ S, (Int.fract ((n : ℝ) / p) - 1 / 2) * Real.log p =
∑ p ∈ S, f p * Real.log p - L / 2 := by
rw [hLdef, Finset.sum_div, ← Finset.sum_sub_distrib]
apply Finset.sum_congr rfl; intro p _; simp only [hf]; ring
rw [htarget]
have hAval : ∑ p ∈ S, A p * Real.log p =
(1 / (M : ℝ)) * (∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0)) :=
hswap
set T := ∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) with hT
have hE' := abs_le.1 hE
have hLM : L / M ≤ 2 * k * (ε / 4) := by
rw [div_eq_mul_one_div]
exact mul_le_mul hL2 hinvM (by positivity) (by positivity)
have hTM1 : (1 / (M : ℝ)) * T ≤ L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k := by
rw [one_div_mul_eq_div, div_le_iff₀ hMr]
have : (L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 + M * (ε / 4 * k) := by
field_simp
rw [this]; linarith [hE'.2]
have hTM2 : L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k ≤ (1 / (M : ℝ)) * T := by
rw [one_div_mul_eq_div, le_div_iff₀ hMr]
have : (L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 - M * (ε / 4 * k) := by
field_simp
rw [this]; linarith [hE'.1]
have hmid : L * ((M : ℝ) - 1) / 2 / M = L / 2 - L / M / 2 := by field_simp
rw [abs_le]
constructor <;> nlinarith [hLM, hlo, hhi, hTM1, hTM2, hmid, hAval, div_nonneg hL0 hMr.le]The gate replayed this file at its merge, each hole a sorry (D-12 #5); the whole file: targets/erdos-1094/nodes/erdos-1094--h3--h3--h2/attempts/20261015T145123Z-t1015c-a02-partial.lean
Closing it through its holes
Closable through its holes: once they are proved, a proof of this statement may name their theorems, which its Context already carries. A direct proof is accepted at any time.
What 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 (1 version)
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--h3--h3--h2».Context
open scoped Nat
/-! Hole `h_sander` 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__h3__h3__h2 : ∀ (C : ℕ) (ε : ℝ),
(0 : ℝ) < ε →
∃ (K₄ : ℕ),
∀ (n k : ℕ),
K₄ < k →
k * k ≤ C * (n * Nat.log (2 : ℕ) k) →
n < k * k →
|∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k,
(Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑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 f29-words, drafted with Claude Fable 5.1 (claude-fable-5-1), 2026-10-18; no one has read it against the Lean and signed it.
Draft · drafted, by the model named above
$\displaystyle \forall C\in\mathbb{N},\ \varepsilon>0\ \exists K_4\ \forall n,k\in\mathbb{N}:\quad K_4<k,\ \ k^2\le C\cdot n\cdot\lfloor\log_2 k\rfloor,\ \ n<k^2 \implies \Bigl|\sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}} \Bigl(\Bigl\{\frac{n}{p}\Bigr\}-\frac12\Bigr)\log p\Bigr| \le \varepsilon k$
For every constant $C$ and every real $\varepsilon>0$ there is a threshold $K_4$ such that for all $k>K_4$ and all $n<k^2$ with $k^2\le C\,n\lfloor\log_2 k\rfloor$, the sum over primes $p$ with $k<2p$ and $20p<11k$ of $(\{n/p\}-\tfrac12)\log p$ has absolute value at most $\varepsilon k$. Here $\{n/p\}$ is Int.fract of the real quotient of the casts, $\log$ is Real.log, the sum runs over Finset.range k filtered by the three conditions, and the range hypotheses are in $\mathbb{N}$ where Nat.log 2 k is $\lfloor\log_2 k\rfloor$ (and $0$ for $k\le 1$), a natural number, so the right-hand side is a product of naturals.
Rendered from gloss/48538564f621….md · Improve these words →
Rendered from targets/erdos-1094/nodes/erdos-1094--h3--h3--h2/Statement.lean. Origin: skeleton-hole.
Depends on (1), each in words
Depends on, each in words where someone has written them:
- erdos-1094--h3--h3--h2--h1: $\forall C\in\mathbb{N},\ \delta>0\ \exists K_5\ \forall n,k\in\mathbb{N},\ K_5<k,\ k^2\le C n\lfloor\log_2 k\rfloor,\ n<k^2,\ \forall \sigma\in[0,1]:\quad \Bigl|\sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}}\ [\{n/p\}<\sigma]\,\log p \;-\; \sigma \sum_{\substack{p \text{ prime}\\ k/2<p<11k/20}} \log p\Bigr| \le \delta k$
Attestation: none of a proof
No proof of this statement has been merged. A partial assembly merged under attestations/000552.json: it records an attempt, not a proof (see Attempts below).
Witness
Not checked — no run on this page records step 7 passing for it.
b0a73c3834b7.import Mathlib open scoped Nat theorem witness : ∃ (C : ℕ) (ε : ℝ), (0 : ℝ) < ε := ⟨0, 1, one_pos⟩
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 →
Attempts (1)
1 recorded. Routes refuted: none. Failure classes: none.
Untrusted contributor text — a partial assembly: it records an attempt, not a proof; its attestation names the file, and no hash in the record binds these bytes.
Untrusted: partial assembly (D-12 #5), by t1015c-a02; merged in 40aad8949bad under attestations/000552.json, whose step 2 took this file as a partial. A partial records an attempt, not a proof: the gate replayed it with its holes left as sorry. Rendered from targets/erdos-1094/nodes/erdos-1094--h3--h3--h2/attempts/20261015T145123Z-t1015c-a02-partial.lean.
Untrusted contributor text — an outline the gate extracted from this partial assembly; its holes are sorry steps, and it records an attempt, not a proof.
Outline of 20261015T145123Z-t1015c-a02-partial.lean, extracted by the gate at 067497e74a8b 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.
h_thetahave∀ (k : ℕ), ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ) ≤ (2 : ℝ) * (↑k : ℝ)Leaves
∀ (C : ℕ) (ε : ℝ), (0 : ℝ) < ε → ∃ (K₄ : ℕ), ∀ (n k : ℕ), K₄ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → |∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withh_theta : ∀ (k : ℕ), ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ) ≤ (2 : ℝ) * (↑k : ℝ).Uses library
Finset.rangerange nis the set of natural numbers less thann. ,Nat.PrimeNat.Prime pmeans thatpis a prime number, that is, a natural number at least 2 whose only divisors arepand1. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. .Lean, lines 51–67
have h_theta : ∀ k : ℕ, ∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k), Real.log p ≤ 2 * k := by intro k have hsub : (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) ⊆ (Finset.Ioc 0 ⌊(k : ℝ)⌋₊).filter Nat.Prime := by intro p hp simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ioc, Nat.floor_natCast] at hp ⊢ exact ⟨⟨hp.2.1.pos, hp.1.le⟩, hp.2.1⟩ have hlog4 : Real.log 4 ≤ 2 := by rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow] push_cast linarith [Real.log_two_lt_d9] calc _ ≤ Chebyshev.theta k := by rw [Chebyshev.theta] exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => Real.log_natCast_nonneg p) _ ≤ Real.log 4 * k := Chebyshev.theta_le_log4_mul_x (by positivity) _ ≤ 2 * k := by gcongrh_theta.hsubhave{p ∈ Finset.range k | Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k} ⊆ Finset.filter Nat.Prime (Finset.Ioc (0 : ℕ) ⌊(↑k : ℝ)⌋₊)Leaves
∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ) ≤ (2 : ℝ) * (↑k : ℝ), withhsub : {p ∈ Finset.range k | Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k} ⊆ Finset.filter Nat.Prime (Finset.Ioc (0 : ℕ) ⌊(↑k : ℝ)⌋₊).Uses library
Finset.rangerange nis the set of natural numbers less thann. ,Nat.PrimeNat.Prime pmeans thatpis a prime number, that is, a natural number at least 2 whose only divisors arepand1. ,Finset.IocThe finset $(a, b]$ of elementsxsuch thata < xandx ≤ b. ,Finset.mem_filter,Finset.mem_range,Finset.mem_Ioc,Nat.floor_natCast,And.introAnd.intro : a → b → a ∧ bis the constructor for the And operation. .Lean, lines 54–58
have hsub : (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) ⊆ (Finset.Ioc 0 ⌊(k : ℝ)⌋₊).filter Nat.Prime := by intro p hp simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ioc, Nat.floor_natCast] at hp ⊢ exact ⟨⟨hp.2.1.pos, hp.1.le⟩, hp.2.1⟩h_theta.hlog4haveReal.log (4 : ℝ) ≤ (2 : ℝ)Leaves
∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ) ≤ (2 : ℝ) * (↑k : ℝ), withhlog4 : Real.log (4 : ℝ) ≤ (2 : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Real.log_pow,Real.log_two_lt_d9.Lean, lines 59–62
have hlog4 : Real.log 4 ≤ 2 := by rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow] push_cast linarith [Real.log_two_lt_d9]h_theta.s3calc∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ) ≤ Chebyshev.theta (↑k : ℝ)Closes the goal.
Uses library
Chebyshev.thetaThe sum oflog pover primesp ≤ x. ,Finset.sum_le_sum_of_subset_of_nonneg,Real.log_natCast_nonneg.Lean, lines 63–65
calc _ ≤ Chebyshev.theta k := by rw [Chebyshev.theta] exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => Real.log_natCast_nonneg p)h_theta.s4calcChebyshev.theta (↑k : ℝ) ≤ Real.log (4 : ℝ) * (↑k : ℝ)Closes the goal.
Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Chebyshev.theta_le_log4_mul_xChebyshev's upper bound:θ x ≤ c xwith the constantc = log 4. .Lean, line 66
_ ≤ Real.log 4 * k := Chebyshev.theta_le_log4_mul_x (by positivity)
h_theta.s5calcCloses the goal.
Lean, line 67
_ ≤ 2 * k := by gcongr
h_l51hole∀ (C : ℕ) (δ : ℝ), (0 : ℝ) < δ → ∃ (K₅ : ℕ), ∀ (n k : ℕ), K₅ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → ∀ (σ : ℝ), (0 : ℝ) ≤ σ → σ ≤ (1 : ℝ) → |(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < σ then Real.log (↑p : ℝ) else (0 : ℝ)) - σ * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ δ * (↑k : ℝ)holeLeaves
∀ (C : ℕ) (ε : ℝ), (0 : ℝ) < ε → ∃ (K₄ : ℕ), ∀ (n k : ℕ), K₄ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → |∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withh_l51 : ∀ (C : ℕ) (δ : ℝ), (0 : ℝ) < δ → ∃ (K₅ : ℕ), ∀ (n k : ℕ), K₅ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → ∀ (σ : ℝ), (0 : ℝ) ≤ σ → σ ≤ (1 : ℝ) → |(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < σ then Real.log (↑p : ℝ) else (0 : ℝ)) - σ * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ δ * (↑k : ℝ).Uses library
Nat.loglog b n, is the logarithm of natural numbernin baseb. ,Finset.rangerange nis the set of natural numbers less thann. ,Nat.PrimeNat.Prime pmeans thatpis a prime number, that is, a natural number at least 2 whose only divisors arepand1. ,Int.fractInt.fract athe fractional part ofa, isaminus its floor. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. .Left open as a hole; its statement is erdos-1094--h3--h3--h2--h1 (open).
Lean, lines 68–74
have h_l51 : ∀ (C : ℕ) (δ : ℝ), 0 < δ → ∃ K₅ : ℕ, ∀ n k : ℕ, K₅ < k → k * k ≤ C * (n * Nat.log 2 k) → n < k * k → ∀ σ : ℝ, 0 ≤ σ → σ ≤ 1 → |∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k), (if Int.fract ((n : ℝ) / p) < σ then Real.log p else 0) - σ * ∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k), Real.log p| ≤ δ * k := by sorrys3obtain∃ (K₅ : ℕ), ∀ (n k : ℕ), K₅ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → ∀ (σ : ℝ), (0 : ℝ) ≤ σ → σ ≤ (1 : ℝ) → |(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < σ then Real.log (↑p : ℝ) else (0 : ℝ)) - σ * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ ε / (4 : ℝ) * (↑k : ℝ)Leaves
∃ (K₄ : ℕ), ∀ (n k : ℕ), K₄ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → |∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withK₅ : ℕ,hL5 : ∀ (n k : ℕ), K₅ < k → k * k ≤ C * (n * Nat.log (2 : ℕ) k) → n < k * k → ∀ (σ : ℝ), (0 : ℝ) ≤ σ → σ ≤ (1 : ℝ) → |(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < σ then Real.log (↑p : ℝ) else (0 : ℝ)) - σ * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ ε / (4 : ℝ) * (↑k : ℝ).Lean, line 76
obtain ⟨K₅, hL5⟩ := h_l51 C (ε / 4) (by positivity)
hlog0have∀ (p : ℕ), (0 : ℝ) ≤ Real.log (↑p : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhlog0 : ∀ (p : ℕ), (0 : ℝ) ≤ Real.log (↑p : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Real.log_natCast_nonneg.Lean, line 80
have hlog0 : ∀ p : ℕ, 0 ≤ Real.log p := fun p => Real.log_natCast_nonneg p
hL0have(0 : ℝ) ≤ LLeaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhL0 : (0 : ℝ) ≤ L.Uses library
Finset.sum_nonneg.Lean, line 81
have hL0 : 0 ≤ L := Finset.sum_nonneg (fun p _ => hlog0 p)
hL2haveL ≤ (2 : ℝ) * (↑k : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhL2 : L ≤ (2 : ℝ) * (↑k : ℝ).Lean, line 82
have hL2 : L ≤ 2 * k := h_theta k
hk0have(0 : ℝ) ≤ (↑k : ℝ)routine: positivityLeaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhk0 : (0 : ℝ) ≤ (↑k : ℝ).Lean, line 83
have hk0 : (0 : ℝ) ≤ k := by positivity
hMhave(0 : ℕ) < Mroutine: omegaLeaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhM : (0 : ℕ) < M.Lean, line 85
have hM : 0 < M := by omega
hMrhave(0 : ℝ) < (↑M : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhMr : (0 : ℝ) < (↑M : ℝ).Lean, line 86
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
hM4have(4 : ℝ) / ε ≤ (↑M : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhM4 : (4 : ℝ) / ε ≤ (↑M : ℝ).Lean, lines 87–90
have hM4 : 4 / ε ≤ M := by have := Nat.le_ceil (4 / ε) have h2 : ((⌈4 / ε⌉₊ : ℕ) : ℝ) ≤ M := by exact_mod_cast (Nat.le_succ _) linarithhM4.thishave(4 : ℝ) / ε ≤ (↑⌈(4 : ℝ) / ε⌉₊ : ℝ)Leaves
(4 : ℝ) / ε ≤ (↑M : ℝ), withthis : (4 : ℝ) / ε ≤ (↑⌈(4 : ℝ) / ε⌉₊ : ℝ).Uses library
Nat.le_ceil.Lean, line 88
have := Nat.le_ceil (4 / ε)
hM4.h2have(↑⌈(4 : ℝ) / ε⌉₊ : ℝ) ≤ (↑M : ℝ)Leaves
(4 : ℝ) / ε ≤ (↑M : ℝ), withh2 : (↑⌈(4 : ℝ) / ε⌉₊ : ℝ) ≤ (↑M : ℝ).Uses library
Nat.le_succ.Lean, line 89
have h2 : ((⌈4 / ε⌉₊ : ℕ) : ℝ) ≤ M := by exact_mod_cast (Nat.le_succ _)
hinvMhave(1 : ℝ) / (↑M : ℝ) ≤ ε / (4 : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhinvM : (1 : ℝ) / (↑M : ℝ) ≤ ε / (4 : ℝ).Uses library
div_le_iff₀Seediv_le_iff₀'for a version with multiplication on the other side. .Lean, lines 91–94
have hinvM : 1 / (M : ℝ) ≤ ε / 4 := by rw [div_le_iff₀ hMr] have := (div_le_iff₀ hε).1 hM4 nlinarithhinvM.thishave(4 : ℝ) ≤ (↑M : ℝ) * εLeaves
(1 : ℝ) ≤ ε / (4 : ℝ) * (↑M : ℝ), withthis : (4 : ℝ) ≤ (↑M : ℝ) * ε.Uses library
div_le_iff₀Seediv_le_iff₀'for a version with multiplication on the other side. .Lean, line 93
have := (div_le_iff₀ hε).1 hM4
hAhave∀ (p : ℕ), f p - (1 : ℝ) / (↑M : ℝ) ≤ A p ∧ A p ≤ f pLeaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhA : ∀ (p : ℕ), f p - (1 : ℝ) / (↑M : ℝ) ≤ A p ∧ A p ≤ f p.Uses library
Int.fract_nonneg,Int.fract_lt_one.Lean, lines 98–99
have hA : ∀ p, f p - 1 / M ≤ A p ∧ A p ≤ f p := fun p => floor_count M hM (f p) (Int.fract_nonneg _) (Int.fract_lt_one _)hswaphave∑ p ∈ S, A p * Real.log (↑p : ℝ) = (1 : ℝ) / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhswap : ∑ p ∈ S, A p * Real.log (↑p : ℝ) = (1 : ℝ) / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Finset.sum_comm,Finset.mul_sum,Finset.sum_congr,rflrfl : a = ais the unique constructor of the equality type. ,mul_assoc,Finset.sum_mul.Lean, lines 101–111
have hswap : ∑ p ∈ S, A p * Real.log p = (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) := by rw [Finset.sum_comm, Finset.mul_sum] apply Finset.sum_congr rfl intro p _ rw [hAdef]; simp only rw [mul_assoc, Finset.sum_mul] congr 1 apply Finset.sum_congr rfl intro j _ split_ifs <;> simphinnerhave∀ j ∈ Finset.Icc (1 : ℕ) M, |(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhinner : ∀ j ∈ Finset.Icc (1 : ℕ) M, |(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ).Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.mem_Icc,abs_neg.Lean, lines 113–134
have hinner : ∀ j ∈ Finset.Icc 1 M, |∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - (L - ((j : ℝ) / M) * L)| ≤ ε / 4 * k := by intro j hj rw [Finset.mem_Icc] at hj have hσ0 : (0 : ℝ) ≤ (j : ℝ) / M := by positivity have hσ1 : (j : ℝ) / M ≤ 1 := by rw [div_le_one hMr]; exact_mod_cast hj.2 have h := hL5 n k hk hlow hup ((j : ℝ) / M) hσ0 hσ1 have hsplit : ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) = L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) := by rw [hLdef, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro p _ by_cases hc : (j : ℝ) / M ≤ f p · rw [if_pos hc, if_neg (not_lt.2 hc)]; ring · rw [if_neg hc, if_pos (not_le.1 hc)]; ring rw [hsplit] have : L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (L - (j : ℝ) / M * L) = -(∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (j : ℝ) / M * L) := by ring rw [this, abs_neg] exact hhinner.h_x3c30(hσ0) have(0 : ℝ) ≤ (↑j : ℝ) / (↑M : ℝ)routine: positivityLeaves
|(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ), withhσ0 : (0 : ℝ) ≤ (↑j : ℝ) / (↑M : ℝ).Lean, line 118
have hσ0 : (0 : ℝ) ≤ (j : ℝ) / M := by positivity
hinner.h_x3c31(hσ1) have(↑j : ℝ) / (↑M : ℝ) ≤ (1 : ℝ)Leaves
|(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ), withhσ1 : (↑j : ℝ) / (↑M : ℝ) ≤ (1 : ℝ).Uses library
div_le_one.Lean, lines 119–120
have hσ1 : (j : ℝ) / M ≤ 1 := by rw [div_le_one hMr]; exact_mod_cast hj.2hinner.hhave|(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (↑j : ℝ) / (↑M : ℝ) * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ ε / (4 : ℝ) * (↑k : ℝ)Leaves
|(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ), withh : |(∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, if Int.fract ((↑n : ℝ) / (↑p : ℝ)) < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (↑j : ℝ) / (↑M : ℝ) * ∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k, Real.log (↑p : ℝ)| ≤ ε / (4 : ℝ) * (↑k : ℝ).Lean, line 121
have h := hL5 n k hk hlow hup ((j : ℝ) / M) hσ0 hσ1
hinner.hsplithave(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) = L - ∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)Leaves
|(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ), withhsplit : (∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) = L - ∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.sum_sub_distrib,Finset.sum_congr,rflrfl : a = ais the unique constructor of the equality type. .Lean, lines 122–129
have hsplit : ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) = L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) := by rw [hLdef, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro p _ by_cases hc : (j : ℝ) / M ≤ f p · rw [if_pos hc, if_neg (not_lt.2 hc)]; ring · rw [if_neg hc, if_pos (not_le.1 hc)]; ringhinner.hsplit.s1caseLeaves
(if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) = Real.log (↑p : ℝ) - if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ), withhc : (↑j : ℝ) / (↑M : ℝ) ≤ f p.Uses library
if_pos,if_neg,not_lt.Lean, line 128
· rw [if_pos hc, if_neg (not_lt.2 hc)]; ring
hinner.hsplit.s2caseLeaves
(if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) = Real.log (↑p : ℝ) - if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ), withhc : ¬(↑j : ℝ) / (↑M : ℝ) ≤ f p.Uses library
if_neg,if_pos,not_le.Lean, line 129
· rw [if_neg hc, if_pos (not_le.1 hc)]; ring
hinner.thishave(L - ∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L) = -((∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (↑j : ℝ) / (↑M : ℝ) * L)routine: ringLeaves
|(L - ∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ε / (4 : ℝ) * (↑k : ℝ), withthis : (L - ∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L) = -((∑ p ∈ S, if f p < (↑j : ℝ) / (↑M : ℝ) then Real.log (↑p : ℝ) else (0 : ℝ)) - (↑j : ℝ) / (↑M : ℝ) * L).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. .Lean, lines 131–132
have : L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (L - (j : ℝ) / M * L) = -(∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (j : ℝ) / M * L) := by ring
hgsumhave∑ j ∈ Finset.Icc (1 : ℕ) M, (L - (↑j : ℝ) / (↑M : ℝ) * L) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhgsum : ∑ j ∈ Finset.Icc (1 : ℕ) M, (L - (↑j : ℝ) / (↑M : ℝ) * L) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ).Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. .Lean, lines 136–144
have hgsum : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = L * ((M : ℝ) - 1) / 2 := by have : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = (M : ℝ) * L - (L / M) * ∑ j ∈ Finset.Icc 1 M, (j : ℝ) := by rw [show ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = ∑ j ∈ Finset.Icc 1 M, (L - L / M * (j : ℝ)) from Finset.sum_congr rfl (fun j _ => by ring)] rw [Finset.sum_sub_distrib, ← Finset.mul_sum, Finset.sum_const, Nat.card_Icc] simp only [nsmul_eq_mul, Nat.add_sub_cancel] rw [this, gauss_Icc]; field_simp; ringhgsum.thishave∑ j ∈ Finset.Icc (1 : ℕ) M, (L - (↑j : ℝ) / (↑M : ℝ) * L) = (↑M : ℝ) * L - L / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, (↑j : ℝ)Leaves
∑ j ∈ Finset.Icc (1 : ℕ) M, (L - (↑j : ℝ) / (↑M : ℝ) * L) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ), withthis : ∑ j ∈ Finset.Icc (1 : ℕ) M, (L - (↑j : ℝ) / (↑M : ℝ) * L) = (↑M : ℝ) * L - L / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, (↑j : ℝ).Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Finset.sum_congr,rflrfl : a = ais the unique constructor of the equality type. ,Finset.sum_sub_distrib,Finset.mul_sum,Finset.sum_const,Nat.card_Icc,nsmul_eq_mul,Nat.add_sub_cancel.Lean, lines 137–143
have : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = (M : ℝ) * L - (L / M) * ∑ j ∈ Finset.Icc 1 M, (j : ℝ) := by rw [show ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = ∑ j ∈ Finset.Icc 1 M, (L - L / M * (j : ℝ)) from Finset.sum_congr rfl (fun j _ => by ring)] rw [Finset.sum_sub_distrib, ← Finset.mul_sum, Finset.sum_const, Nat.card_Icc] simp only [nsmul_eq_mul, Nat.add_sub_cancel]
hEhave|(∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ)| ≤ (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhE : |(∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ)| ≤ (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ)).Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.sum_sub_distrib.Lean, lines 145–151
have hE : |∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - L * ((M : ℝ) - 1) / 2| ≤ M * (ε / 4 * k) := by rw [← hgsum, ← Finset.sum_sub_distrib] calc _ ≤ ∑ j ∈ Finset.Icc 1 M, |∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - (L - ((j : ℝ) / M) * L)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ j ∈ Finset.Icc 1 M, ε / 4 * k := Finset.sum_le_sum hinner _ = M * (ε / 4 * k) := by rw [Finset.sum_const, Nat.card_Icc]; simphE.s1calc|∑ i ∈ Finset.Icc (1 : ℕ) M, ((∑ p ∈ S, if (↑i : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑i : ℝ) / (↑M : ℝ) * L))| ≤ ∑ j ∈ Finset.Icc (1 : ℕ) M, |(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)|Closes the goal.
Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.abs_sum_le_sum_abs.Lean, lines 148–149
calc _ ≤ ∑ j ∈ Finset.Icc 1 M, |∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - (L - ((j : ℝ) / M) * L)| := Finset.abs_sum_le_sum_abs _ _hE.s2calc∑ j ∈ Finset.Icc (1 : ℕ) M, |(∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)) - (L - (↑j : ℝ) / (↑M : ℝ) * L)| ≤ ∑ j ∈ Finset.Icc (1 : ℕ) M, ε / (4 : ℝ) * (↑k : ℝ)Closes the goal.
Uses library
Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. ,Finset.sum_le_sumIn an ordered additive commutative monoid, if each summandf iof one finite sum is less than or equal to the corresponding summandg iof another finite sum, then∑ i ∈ s, f i ≤ ∑ i ∈ s, g i. .Lean, line 150
_ ≤ ∑ j ∈ Finset.Icc 1 M, ε / 4 * k := Finset.sum_le_sum hinner
hE.s3calcCloses the goal.
Uses library
Finset.sum_const,Nat.card_Icc.Lean, line 151
_ = M * (ε / 4 * k) := by rw [Finset.sum_const, Nat.card_Icc]; simp
hlohave∑ p ∈ S, A p * Real.log (↑p : ℝ) ≤ ∑ p ∈ S, f p * Real.log (↑p : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhlo : ∑ p ∈ S, A p * Real.log (↑p : ℝ) ≤ ∑ p ∈ S, f p * Real.log (↑p : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.sum_le_sumIn an ordered additive commutative monoid, if each summandf iof one finite sum is less than or equal to the corresponding summandg iof another finite sum, then∑ i ∈ s, f i ≤ ∑ i ∈ s, g i. ,mul_le_mul_of_nonneg_right.Lean, lines 153–154
have hlo : ∑ p ∈ S, A p * Real.log p ≤ ∑ p ∈ S, f p * Real.log p := Finset.sum_le_sum (fun p _ => mul_le_mul_of_nonneg_right (hA p).2 (hlog0 p))hhihave∑ p ∈ S, f p * Real.log (↑p : ℝ) ≤ ∑ p ∈ S, A p * Real.log (↑p : ℝ) + L / (↑M : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhhi : ∑ p ∈ S, f p * Real.log (↑p : ℝ) ≤ ∑ p ∈ S, A p * Real.log (↑p : ℝ) + L / (↑M : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.sum_div,Finset.sum_add_distrib,Finset.sum_le_sumIn an ordered additive commutative monoid, if each summandf iof one finite sum is less than or equal to the corresponding summandg iof another finite sum, then∑ i ∈ s, f i ≤ ∑ i ∈ s, g i. .Lean, lines 155–162
have hhi : ∑ p ∈ S, f p * Real.log p ≤ ∑ p ∈ S, A p * Real.log p + L / M := by rw [hLdef, Finset.sum_div, ← Finset.sum_add_distrib] apply Finset.sum_le_sum; intro p _ have := (hA p).1 have hl := hlog0 p have : f p * Real.log p ≤ (A p + 1 / M) * Real.log p := mul_le_mul_of_nonneg_right (by linarith) hl linarith [show (A p + 1 / M) * Real.log p = A p * Real.log p + Real.log p / M by ring]hhi.s1havef p - (1 : ℝ) / (↑M : ℝ) ≤ A pLeaves
f p * Real.log (↑p : ℝ) ≤ A p * Real.log (↑p : ℝ) + Real.log (↑p : ℝ) / (↑M : ℝ), withthis : f p - (1 : ℝ) / (↑M : ℝ) ≤ A p.hhi.hlhave(0 : ℝ) ≤ Real.log (↑p : ℝ)Leaves
f p * Real.log (↑p : ℝ) ≤ A p * Real.log (↑p : ℝ) + Real.log (↑p : ℝ) / (↑M : ℝ), withhl : (0 : ℝ) ≤ Real.log (↑p : ℝ).Lean, line 159
have hl := hlog0 p
hhi.s3havef p * Real.log (↑p : ℝ) ≤ (A p + (1 : ℝ) / (↑M : ℝ)) * Real.log (↑p : ℝ)Leaves
f p * Real.log (↑p : ℝ) ≤ A p * Real.log (↑p : ℝ) + Real.log (↑p : ℝ) / (↑M : ℝ), withthis : f p * Real.log (↑p : ℝ) ≤ (A p + (1 : ℝ) / (↑M : ℝ)) * Real.log (↑p : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,mul_le_mul_of_nonneg_right.Lean, lines 160–161
have : f p * Real.log p ≤ (A p + 1 / M) * Real.log p := mul_le_mul_of_nonneg_right (by linarith) hl
htargethave∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ) = ∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)Leaves
|∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤ ε * (↑k : ℝ), withhtarget : ∑ p ∈ S, (Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ) = ∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ).Uses library
Int.fractInt.fract athe fractional part ofa, isaminus its floor. ,Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.sum_div,Finset.sum_sub_distrib,Finset.sum_congr,rflrfl : a = ais the unique constructor of the equality type. .Lean, lines 163–166
have htarget : ∑ p ∈ S, (Int.fract ((n : ℝ) / p) - 1 / 2) * Real.log p = ∑ p ∈ S, f p * Real.log p - L / 2 := by rw [hLdef, Finset.sum_div, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro p _; simp only [hf]; ringhAvalhave∑ p ∈ S, A p * Real.log (↑p : ℝ) = (1 : ℝ) / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ)Leaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhAval : ∑ p ∈ S, A p * Real.log (↑p : ℝ) = (1 : ℝ) / (↑M : ℝ) * ∑ j ∈ Finset.Icc (1 : ℕ) M, ∑ p ∈ S, if (↑j : ℝ) / (↑M : ℝ) ≤ f p then Real.log (↑p : ℝ) else (0 : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,Finset.IccThe finset $[a, b]$ of elementsxsuch thata ≤ xandx ≤ b. .Lean, lines 168–170
have hAval : ∑ p ∈ S, A p * Real.log p = (1 / (M : ℝ)) * (∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0)) := hswaphE'have-((↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))) ≤ T - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) ∧ T - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) ≤ (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))Leaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhE' : -((↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))) ≤ T - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) ∧ T - L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) ≤ (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ)).Uses library
abs_le.Lean, line 172
have hE' := abs_le.1 hE
hLMhaveL / (↑M : ℝ) ≤ (2 : ℝ) * (↑k : ℝ) * (ε / (4 : ℝ))Leaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhLM : L / (↑M : ℝ) ≤ (2 : ℝ) * (↑k : ℝ) * (ε / (4 : ℝ)).Uses library
div_eq_mul_one_div,mul_le_mulAlias ofmul_le_mul_of_nonneg'. .Lean, lines 173–175
have hLM : L / M ≤ 2 * k * (ε / 4) := by rw [div_eq_mul_one_div] exact mul_le_mul hL2 hinvM (by positivity) (by positivity)hTM1have(1 : ℝ) / (↑M : ℝ) * T ≤ L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) + ε / (4 : ℝ) * (↑k : ℝ)Leaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhTM1 : (1 : ℝ) / (↑M : ℝ) * T ≤ L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) + ε / (4 : ℝ) * (↑k : ℝ).Uses library
one_div_mul_eq_div,div_le_iff₀Seediv_le_iff₀'for a version with multiplication on the other side. .Lean, lines 176–180
have hTM1 : (1 / (M : ℝ)) * T ≤ L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k := by rw [one_div_mul_eq_div, div_le_iff₀ hMr] have : (L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 + M * (ε / 4 * k) := by field_simp rw [this]; linarith [hE'.2]hTM1.thishave(L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) + ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) + (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))routine: field_simpLeaves
T ≤ (L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) + ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ), withthis : (L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) + ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) + (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ)).Lean, lines 178–179
have : (L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 + M * (ε / 4 * k) := by field_simp
hTM2haveL * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) - ε / (4 : ℝ) * (↑k : ℝ) ≤ (1 : ℝ) / (↑M : ℝ) * TLeaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhTM2 : L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) - ε / (4 : ℝ) * (↑k : ℝ) ≤ (1 : ℝ) / (↑M : ℝ) * T.Uses library
one_div_mul_eq_div,le_div_iff₀Seele_div_iff₀'for a version with multiplication on the other side. .Lean, lines 181–185
have hTM2 : L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k ≤ (1 / (M : ℝ)) * T := by rw [one_div_mul_eq_div, le_div_iff₀ hMr] have : (L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 - M * (ε / 4 * k) := by field_simp rw [this]; linarith [hE'.1]hTM2.thishave(L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) - ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) - (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ))routine: field_simpLeaves
(L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) - ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ) ≤ T, withthis : (L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) - ε / (4 : ℝ) * (↑k : ℝ)) * (↑M : ℝ) = L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) - (↑M : ℝ) * (ε / (4 : ℝ) * (↑k : ℝ)).Lean, lines 183–184
have : (L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 - M * (ε / 4 * k) := by field_simp
hmidhaveL * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) = L / (2 : ℝ) - L / (↑M : ℝ) / (2 : ℝ)routine: field_simpLeaves
|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ), withhmid : L * ((↑M : ℝ) - (1 : ℝ)) / (2 : ℝ) / (↑M : ℝ) = L / (2 : ℝ) - L / (↑M : ℝ) / (2 : ℝ).Lean, line 186
have hmid : L * ((M : ℝ) - 1) / 2 / M = L / 2 - L / M / 2 := by field_simp
closeterm|∑ p ∈ S, f p * Real.log (↑p : ℝ) - L / (2 : ℝ)| ≤ ε * (↑k : ℝ)Closes the goal.
Uses library
abs_le,div_nonneg.Lean, lines 187–188
rw [abs_le] constructor <;> nlinarith [hLM, hlo, hhi, hTM1, hTM2, hmid, hAval, div_nonneg hL0 hMr.le]
import Mathlib
import Nodes.«erdos-1094--h3--h3--h2».Context
open scoped Nat
/-! Hole `h_sander` 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 lemma floor_count (M : ℕ) (hM : 0 < M) (f : ℝ) (h0 : 0 ≤ f) (h1 : f < 1) :
f - 1 / M ≤ (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) ∧
(1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) ≤ f := by
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
set m := ⌊(M : ℝ) * f⌋₊ with hm
have hmf : (m : ℝ) ≤ M * f := Nat.floor_le (by positivity)
have hfm : M * f < m + 1 := Nat.lt_floor_add_one _
have hmM : m ≤ M := by
have : (m : ℝ) < M := by nlinarith
exact_mod_cast this.le
have key : ∀ j : ℕ, ((j : ℝ) / M ≤ f ↔ j ≤ m) := by
intro j
rw [div_le_iff₀ hMr, hm, Nat.le_floor_iff (by positivity), mul_comm]
have hsum : ∑ j ∈ Finset.Icc 1 M, (if (j : ℝ) / M ≤ f then (1 : ℝ) else 0) = m := by
simp_rw [key]
rw [Finset.sum_ite, Finset.sum_const_zero, add_zero, Finset.sum_const, nsmul_eq_mul, mul_one]
have : (Finset.Icc 1 M).filter (fun j => j ≤ m) = Finset.Icc 1 m := by
ext j; simp only [Finset.mem_filter, Finset.mem_Icc]; omega
rw [this, Nat.card_Icc]; simp
rw [hsum]
constructor
· rw [div_mul_eq_mul_div, one_mul, le_div_iff₀ hMr, sub_mul, one_div, inv_mul_cancel₀ hMr.ne']; nlinarith
· rw [div_mul_eq_mul_div, one_mul, div_le_iff₀ hMr]; nlinarith
private lemma gauss_Icc (M : ℕ) : ∑ j ∈ Finset.Icc 1 M, (j : ℝ) = (M : ℝ) * (M + 1) / 2 := by
induction M with
| zero => simp
| succ m ih =>
rw [Finset.sum_Icc_succ_top (by omega), ih]
push_cast; ring
theorem erdos_1094__h3__h3__h2 : ∀ (C : ℕ) (ε : ℝ),
(0 : ℝ) < ε →
∃ (K₄ : ℕ),
∀ (n k : ℕ),
K₄ < k →
k * k ≤ C * (n * Nat.log (2 : ℕ) k) →
n < k * k →
|∑ p ∈ Finset.range k with Nat.Prime p ∧ k < (2 : ℕ) * p ∧ (20 : ℕ) * p < (11 : ℕ) * k,
(Int.fract ((↑n : ℝ) / (↑p : ℝ)) - (1 / 2 : ℝ)) * Real.log (↑p : ℝ)| ≤
ε * (↑k : ℝ) := by
have h_theta : ∀ k : ℕ, ∑ p ∈ (Finset.range k).filter
(fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k), Real.log p ≤ 2 * k := by
intro k
have hsub : (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) ⊆
(Finset.Ioc 0 ⌊(k : ℝ)⌋₊).filter Nat.Prime := by
intro p hp
simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ioc, Nat.floor_natCast] at hp ⊢
exact ⟨⟨hp.2.1.pos, hp.1.le⟩, hp.2.1⟩
have hlog4 : Real.log 4 ≤ 2 := by
rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]
push_cast
linarith [Real.log_two_lt_d9]
calc _ ≤ Chebyshev.theta k := by
rw [Chebyshev.theta]
exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => Real.log_natCast_nonneg p)
_ ≤ Real.log 4 * k := Chebyshev.theta_le_log4_mul_x (by positivity)
_ ≤ 2 * k := by gcongr
have h_l51 : ∀ (C : ℕ) (δ : ℝ), 0 < δ → ∃ K₅ : ℕ, ∀ n k : ℕ, K₅ < k →
k * k ≤ C * (n * Nat.log 2 k) → n < k * k → ∀ σ : ℝ, 0 ≤ σ → σ ≤ 1 →
|∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k),
(if Int.fract ((n : ℝ) / p) < σ then Real.log p else 0) -
σ * ∑ p ∈ (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k),
Real.log p| ≤ δ * k := by
sorry
intro C ε hε
obtain ⟨K₅, hL5⟩ := h_l51 C (ε / 4) (by positivity)
refine ⟨K₅, fun n k hk hlow hup => ?_⟩
set S := (Finset.range k).filter (fun p => Nat.Prime p ∧ k < 2 * p ∧ 20 * p < 11 * k) with hS
set L := ∑ p ∈ S, Real.log p with hLdef
have hlog0 : ∀ p : ℕ, 0 ≤ Real.log p := fun p => Real.log_natCast_nonneg p
have hL0 : 0 ≤ L := Finset.sum_nonneg (fun p _ => hlog0 p)
have hL2 : L ≤ 2 * k := h_theta k
have hk0 : (0 : ℝ) ≤ k := by positivity
set M : ℕ := ⌈4 / ε⌉₊ + 1 with hMdef
have hM : 0 < M := by omega
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
have hM4 : 4 / ε ≤ M := by
have := Nat.le_ceil (4 / ε)
have h2 : ((⌈4 / ε⌉₊ : ℕ) : ℝ) ≤ M := by exact_mod_cast (Nat.le_succ _)
linarith
have hinvM : 1 / (M : ℝ) ≤ ε / 4 := by
rw [div_le_iff₀ hMr]
have := (div_le_iff₀ hε).1 hM4
nlinarith
set f : ℕ → ℝ := fun p => Int.fract ((n : ℝ) / p) with hf
set A : ℕ → ℝ := fun p => (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M,
(if (j : ℝ) / M ≤ f p then (1 : ℝ) else 0) with hAdef
have hA : ∀ p, f p - 1 / M ≤ A p ∧ A p ≤ f p := fun p =>
floor_count M hM (f p) (Int.fract_nonneg _) (Int.fract_lt_one _)
-- the swap of the two sums
have hswap : ∑ p ∈ S, A p * Real.log p = (1 / (M : ℝ)) * ∑ j ∈ Finset.Icc 1 M,
∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) := by
rw [Finset.sum_comm, Finset.mul_sum]
apply Finset.sum_congr rfl
intro p _
rw [hAdef]; simp only
rw [mul_assoc, Finset.sum_mul]
congr 1
apply Finset.sum_congr rfl
intro j _
split_ifs <;> simp
-- each inner sum is L minus the count below σ = j/M
have hinner : ∀ j ∈ Finset.Icc 1 M,
|∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) - (L - ((j : ℝ) / M) * L)| ≤
ε / 4 * k := by
intro j hj
rw [Finset.mem_Icc] at hj
have hσ0 : (0 : ℝ) ≤ (j : ℝ) / M := by positivity
have hσ1 : (j : ℝ) / M ≤ 1 := by
rw [div_le_one hMr]; exact_mod_cast hj.2
have h := hL5 n k hk hlow hup ((j : ℝ) / M) hσ0 hσ1
have hsplit : ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) =
L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) := by
rw [hLdef, ← Finset.sum_sub_distrib]
apply Finset.sum_congr rfl
intro p _
by_cases hc : (j : ℝ) / M ≤ f p
· rw [if_pos hc, if_neg (not_lt.2 hc)]; ring
· rw [if_neg hc, if_pos (not_le.1 hc)]; ring
rw [hsplit]
have : L - ∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (L - (j : ℝ) / M * L) =
-(∑ p ∈ S, (if f p < (j : ℝ) / M then Real.log p else 0) - (j : ℝ) / M * L) := by ring
rw [this, abs_neg]
exact h
-- sum over j
have hgsum : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) = L * ((M : ℝ) - 1) / 2 := by
have : ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) =
(M : ℝ) * L - (L / M) * ∑ j ∈ Finset.Icc 1 M, (j : ℝ) := by
rw [show ∑ j ∈ Finset.Icc 1 M, (L - ((j : ℝ) / M) * L) =
∑ j ∈ Finset.Icc 1 M, (L - L / M * (j : ℝ)) from
Finset.sum_congr rfl (fun j _ => by ring)]
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, Finset.sum_const, Nat.card_Icc]
simp only [nsmul_eq_mul, Nat.add_sub_cancel]
rw [this, gauss_Icc]; field_simp; ring
have hE : |∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) -
L * ((M : ℝ) - 1) / 2| ≤ M * (ε / 4 * k) := by
rw [← hgsum, ← Finset.sum_sub_distrib]
calc _ ≤ ∑ j ∈ Finset.Icc 1 M, |∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) -
(L - ((j : ℝ) / M) * L)| := Finset.abs_sum_le_sum_abs _ _
_ ≤ ∑ j ∈ Finset.Icc 1 M, ε / 4 * k := Finset.sum_le_sum hinner
_ = M * (ε / 4 * k) := by rw [Finset.sum_const, Nat.card_Icc]; simp
-- bracket Σ f log p between Σ A log p and Σ A log p + L/M
have hlo : ∑ p ∈ S, A p * Real.log p ≤ ∑ p ∈ S, f p * Real.log p :=
Finset.sum_le_sum (fun p _ => mul_le_mul_of_nonneg_right (hA p).2 (hlog0 p))
have hhi : ∑ p ∈ S, f p * Real.log p ≤ ∑ p ∈ S, A p * Real.log p + L / M := by
rw [hLdef, Finset.sum_div, ← Finset.sum_add_distrib]
apply Finset.sum_le_sum; intro p _
have := (hA p).1
have hl := hlog0 p
have : f p * Real.log p ≤ (A p + 1 / M) * Real.log p :=
mul_le_mul_of_nonneg_right (by linarith) hl
linarith [show (A p + 1 / M) * Real.log p = A p * Real.log p + Real.log p / M by ring]
have htarget : ∑ p ∈ S, (Int.fract ((n : ℝ) / p) - 1 / 2) * Real.log p =
∑ p ∈ S, f p * Real.log p - L / 2 := by
rw [hLdef, Finset.sum_div, ← Finset.sum_sub_distrib]
apply Finset.sum_congr rfl; intro p _; simp only [hf]; ring
rw [htarget]
have hAval : ∑ p ∈ S, A p * Real.log p =
(1 / (M : ℝ)) * (∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0)) :=
hswap
set T := ∑ j ∈ Finset.Icc 1 M, ∑ p ∈ S, (if (j : ℝ) / M ≤ f p then Real.log p else 0) with hT
have hE' := abs_le.1 hE
have hLM : L / M ≤ 2 * k * (ε / 4) := by
rw [div_eq_mul_one_div]
exact mul_le_mul hL2 hinvM (by positivity) (by positivity)
have hTM1 : (1 / (M : ℝ)) * T ≤ L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k := by
rw [one_div_mul_eq_div, div_le_iff₀ hMr]
have : (L * ((M : ℝ) - 1) / 2 / M + ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 + M * (ε / 4 * k) := by
field_simp
rw [this]; linarith [hE'.2]
have hTM2 : L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k ≤ (1 / (M : ℝ)) * T := by
rw [one_div_mul_eq_div, le_div_iff₀ hMr]
have : (L * ((M : ℝ) - 1) / 2 / M - ε / 4 * k) * M = L * ((M : ℝ) - 1) / 2 - M * (ε / 4 * k) := by
field_simp
rw [this]; linarith [hE'.1]
have hmid : L * ((M : ℝ) - 1) / 2 / M = L / 2 - L / M / 2 := by field_simp
rw [abs_le]
constructor <;> nlinarith [hLM, hlo, hhi, hTM1, hTM2, hmid, hAval, div_nonneg hL0 hMr.le]How to read this page
No explainer yet. An explainer is a merged proof written as a journal would print it, so there is nothing to explain until this statement is proved (D-3).