Problems / erdos-257 / variant-6b364d2b--h1
Tao–Teräväinen Theorem 5.1 (technical reduction)
variant-6b364d2b--h1
open
Hole h1 of variant-6b364d2b (split by 20261022T160309Z-t1022-l-partial.lean).
$\displaystyle \forall q \ge 1\ \exists c_0 > 0\ \forall \delta > 0:\ \text{a prime cube } p_\varepsilon = p_0 + \textstyle\sum_k \varepsilon_k v_k, \text{ a finite set of } n \text{ obeying (5.5)--(5.6), a split } S_0 \sqcup S_1 \sqcup S_2 \text{ of the primes} \le B \text{ with } X_p \text{ constant on } S_0,\ |X_p| \le \delta \text{ on } S_1,\ M \text{ even},\ \kappa_1, \dots, \kappa_5 \le \delta,\ \sum_{p \in S_1} \operatorname{Var} X_p \ge c_0$
Theorem 5.1 of arXiv:2512.01739v2 (p. 49) for n uniform on the finite set Ns, where X_p(n) = q sum_{1<=h<=H} sum_eps (-1)^|eps| 1[p | n + r_{eps,h+K}] / 2^(h+K) is (5.13), and kappa_1, kappa_2, kappa_3 are (5.10), (5.11), (5.14) as printed (expectation and sums swapped). kappa_4, kappa_5 are (5.16), (5.17) as printed, with X'_p independent copies (n uniform on Ns^{S_1}) and e = exp 1 in (5.17). One part is taken from the paper's proof rather than its statement: (5.19), |X_p| small on S_1 (shown in section 5.6 from (5.36)). It does not mention the sum or rationality: it is about prime factors of shifted integers, and in the paper its proof rests on the paper's Theorem 3.1 and on Lemma 5.2.
Lean
theorem variant_6b364d2b__h1 : ∀ (q : ℕ),
(0 : ℕ) < q →
∃ (c0 : ℝ),
(0 : ℝ) < c0 ∧
∀ (δ : ℝ),
(0 : ℝ) < δ →
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m :
ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r :
(Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ),
(∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧
(∀ (ε : Fin K → Bool) (h : ℕ),
r ε h =
p0 * (↑h : ℤ) +
∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧
(∀ (p : ℕ) (n : ℤ),
X p n =
(↑q : ℝ) *
∑ k ∈ Finset.range H,
(∑ ε : Fin K → Bool,
sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) /
(2 : ℝ) ^ (k + K + (1 : ℕ))) ∧
Even M ∧
(∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧
(∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧
Ns.Nonempty ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
(n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) =
(↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
∀ k < H,
(0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧
S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
Disjoint S1 S2 ∧
(∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),
p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧
(∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑ ε : Fin K → Bool,
∑' (k : ℕ),
(if P ε ^ (2 : ℕ) ∣ P ε * m n ε + P ε * (k + (1 : ℕ)) then (1 : ℝ)
else (0 : ℝ)) /
(2 : ℝ) ^ (k + (1 : ℕ)) ≤
δ ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑' (k : ℕ),
(∑ ε : Fin K → Bool,
(↑((ArithmeticFunction.cardDistinctFactors : ℕ → ℕ)
(n + r ε (k + H + K + (1 : ℕ))).toNat) :
ℝ)) /
(2 : ℝ) ^ (k + H + K + (1 : ℕ)) ≤
δ ∧
√((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ (2 : ℕ)) ≤ δ ∧
∑ j ∈ Finset.range (M + (1 : ℕ)),
((2 : ℝ) * Real.pi) ^ j / (↑j.factorial : ℝ) *
|(↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j -
(↑(Fintype.piFinset fun (x : ↥S1) => Ns).card : ℝ)⁻¹ *
∑ ω ∈ Fintype.piFinset fun (x : ↥S1) => Ns,
(∑ p : ↥S1, X (↑p : ℕ) (ω p)) ^ j| ≤
δ ∧
(∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
((2 : ℝ) * Real.pi * Real.exp (1 : ℝ) * X p n) +
∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
(-((2 : ℝ) * Real.pi * Real.exp (1 : ℝ)) * X p n)) /
Real.exp (1 : ℝ) ^ M ≤
δ ∧
c0 ≤
∑ p ∈ S1,
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ (2 : ℕ) -
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ (2 : ℕ)) := 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 20261023T140825Z-t1023-f2-partial.lean (merged in 17322888f918, attestation 000957).
tt_sec5_setup→ variant-6b364d2b--h1--h1 (open)$\displaystyle \forall q \ge 1,\ T,\ \delta > 0,\ P_0\ \ \exists P \ge P_0,\ 2^K \le (\log P)^{2/3},\ H \le (\log P)^{2/3}\ \ \forall (p_0, v)\ \ \exists (N_s, S_1, S_2, M, \eta, w, R):\ \kappa_2, \kappa_3, \kappa_4, \kappa_5 \le \delta,\ \sum_{\varepsilon} \frac{1+\eta}{p_\varepsilon} \le \delta,\ \frac{q}{2^{K+1}} \le \delta,\ 2^K T \le \log\log R - \log\log w$
Read the partial proof (Lean)
private lemma a52_cb_small_part (n : ℕ) (n_pos : 0 < n) :
∏ x ∈ Finset.range (2 * n / 3 + 1), x ^ (Nat.centralBinom n).factorization x ≤
(2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) := by
have n2_pos : 1 ≤ 2 * n := by omega
let S := {p ∈ Finset.range (2 * n / 3 + 1) | Nat.Prime p}
let f x := x ^ n.centralBinom.factorization x
have : ∏ x ∈ S, f x = ∏ x ∈ Finset.range (2 * n / 3 + 1), f x := by
refine Finset.prod_filter_of_ne fun p _ h => ?_
contrapose! h; dsimp only [f]
rw [Nat.factorization_eq_zero_of_not_prime n.centralBinom h, _root_.pow_zero]
change ∏ x ∈ Finset.range (2 * n / 3 + 1), f x ≤ _
rw [← this, ← Finset.prod_filter_mul_prod_filter_not S (· ≤ Nat.sqrt (2 * n))]
apply mul_le_mul'
· refine (Finset.prod_le_prod' fun p _ => (?_ : f p ≤ 2 * n)).trans ?_
· exact Nat.pow_factorization_choose_le (mul_pos two_pos n_pos)
have : (Finset.Icc 1 (Nat.sqrt (2 * n))).card = Nat.sqrt (2 * n) := by
rw [Nat.card_Icc, Nat.add_sub_cancel]
rw [Finset.prod_const]
refine pow_right_mono₀ n2_pos ((Finset.card_le_card fun x hx => ?_).trans this.le)
obtain ⟨h1, h2⟩ := Finset.mem_filter.1 hx
exact Finset.mem_Icc.mpr ⟨(Finset.mem_filter.1 h1).2.one_lt.le, h2⟩
· refine le_trans ?_ (primorial_le_4_pow (2 * n / 3))
refine (Finset.prod_le_prod' fun p hp => (?_ : f p ≤ p)).trans ?_
· obtain ⟨h1, h2⟩ := Finset.mem_filter.1 hp
refine (pow_right_mono₀ (Finset.mem_filter.1 h1).2.one_lt.le ?_).trans (pow_one p).le
exact Nat.factorization_choose_le_one (Nat.sqrt_lt'.mp <| not_le.1 h2)
refine Finset.prod_le_prod_of_subset_of_one_le' (Finset.filter_subset _ _) ?_
exact fun p hp _ => (Finset.mem_filter.1 hp).2.one_lt.le
private lemma a52_cb_large_part (n : ℕ) (n_large : 2 < n) :
∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1), x ^ (Nat.centralBinom n).factorization x ≤
(2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
calc ∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1), x ^ (Nat.centralBinom n).factorization x
≤ ∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1),
(if x.Prime ∧ n < x then 2 * n else 1) := by
apply Finset.prod_le_prod'
intro x hx
rw [Finset.mem_Ico] at hx
split_ifs with h
· exact Nat.pow_factorization_choose_le (by omega)
· by_cases hp : x.Prime
· have hxn : x ≤ n := by
by_contra hc; exact h ⟨hp, by omega⟩
rw [Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul n_large hxn (by omega)]
simp
· rw [Nat.factorization_eq_zero_of_not_prime _ hp]; simp
_ = ∏ x ∈ (Finset.Ico (2 * n / 3 + 1) (2 * n + 1)).filter (fun x => x.Prime ∧ n < x),
2 * n := (Finset.prod_filter _ _).symm
_ = (2 * n) ^ ((Finset.Ico (2 * n / 3 + 1) (2 * n + 1)).filter
(fun x => x.Prime ∧ n < x)).card := Finset.prod_const _
_ ≤ (2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
apply pow_le_pow_right₀ (by omega)
apply Finset.card_le_card
intro x hx
simp only [Finset.mem_filter, Finset.mem_Ico, Finset.mem_Ioc] at hx ⊢
exact ⟨⟨hx.2.2, by omega⟩, hx.2.1⟩
private lemma a52_cb_bound (n : ℕ) (n_large : 2 < n) :
Nat.centralBinom n ≤ (2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) *
(2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
rw [← Nat.prod_pow_factorization_centralBinom,
← Finset.prod_range_mul_prod_Ico _ (show 2 * n / 3 + 1 ≤ 2 * n + 1 by omega)]
exact mul_le_mul' (a52_cb_small_part n (by omega)) (a52_cb_large_part n n_large)
private lemma a52_cb_log_ineq (n : ℕ) (hn : 4 ≤ n) :
(n : ℝ) * Real.log 4 < Real.log n + Real.sqrt (2 * n) * Real.log (2 * n) +
(2 * n / 3) * Real.log 4 +
(((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ) * Real.log (2 * n) := by
set k := ((Finset.Ioc n (2 * n)).filter Nat.Prime).card
have h1 : 4 ^ n < n * ((2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) * (2 * n) ^ k) :=
lt_of_lt_of_le (Nat.four_pow_lt_mul_centralBinom n hn)
(Nat.mul_le_mul_left _ (a52_cb_bound n (by omega)))
have h2 : ((4 : ℝ) ^ n) < (n : ℝ) * ((2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) *
(2 * n) ^ k) := by exact_mod_cast h1
have hnpos : (0 : ℝ) < n := by positivity
have h3 := Real.log_lt_log (by positivity) h2
rw [Real.log_pow, Real.log_mul (by positivity) (by positivity),
Real.log_mul (by positivity) (by positivity), Real.log_mul (by positivity) (by positivity),
Real.log_pow, Real.log_pow, Real.log_pow] at h3
have hs : (Nat.sqrt (2 * n) : ℝ) ≤ Real.sqrt (2 * n) := by
have := @Real.nat_sqrt_le_real_sqrt (2 * n); push_cast at this; exact this
have hd : ((2 * n / 3 : ℕ) : ℝ) ≤ 2 * n / 3 := by
have := @Nat.cast_div_le ℝ _ _ _ (2 * n) 3; push_cast at this; exact this
have hL : 0 ≤ Real.log (2 * n) := Real.log_nonneg (by
have : (4 : ℝ) ≤ n := by exact_mod_cast hn
linarith)
have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num)
nlinarith [mul_le_mul_of_nonneg_right hs hL, mul_le_mul_of_nonneg_right hd hl4]
private theorem a52_primes_in_dyadic_lower :
∃ c : ℝ, 0 < c ∧ ∃ N : ℕ, ∀ n : ℕ, N ≤ n →
c * (n : ℝ) / Real.log n ≤ (((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ) := by
refine ⟨1 / 10, by norm_num, 10 ^ 8, fun n hn => ?_⟩
have key := a52_cb_log_ineq n (le_trans (by norm_num) hn)
set k : ℝ := (((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ)
have hk0 : 0 ≤ k := by positivity
have hnR : (10 : ℝ) ^ 8 ≤ n := by exact_mod_cast hn
have hn0 : (0 : ℝ) < n := by linarith
set t := Real.sqrt (Real.sqrt n) with ht
have hsq : Real.sqrt n = t ^ 2 := (Real.sq_sqrt (Real.sqrt_nonneg _)).symm
have hn4 : (n : ℝ) = t ^ 4 := by
rw [show t ^ 4 = (t ^ 2) ^ 2 by ring, ← hsq, Real.sq_sqrt hn0.le]
have ht100 : 100 ≤ t := by
rw [ht, Real.le_sqrt (by norm_num) (Real.sqrt_nonneg _), Real.le_sqrt (by norm_num) hn0.le]
linarith
have hlogn : Real.log n = 4 * Real.log t := by
rw [hn4, Real.log_pow]; norm_num
have hlogt : Real.log t ≤ t := by
have := Real.log_le_sub_one_of_pos (show 0 < t by linarith); linarith
have hlogt0 : 0 < Real.log t := Real.log_pos (by linarith)
have hs2 : Real.sqrt (2 * n) ≤ 3 / 2 * t ^ 2 := by
rw [Real.sqrt_mul (by norm_num), hsq]
have : Real.sqrt 2 ≤ 3 / 2 := by
rw [Real.sqrt_le_left (by norm_num)]; norm_num
nlinarith
have hL : Real.log (2 * n) = Real.log 2 + Real.log n :=
Real.log_mul (by norm_num) hn0.ne'
have hl2 : Real.log 2 ≤ Real.log n := Real.log_le_log (by norm_num) (by linarith)
have hl20 : 0 < Real.log 2 := Real.log_pos (by norm_num)
have hl4 : Real.log 4 = 2 * Real.log 2 := by
rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]; norm_num
have hl2v := Real.log_two_gt_d9
rw [div_le_iff₀ (by rw [hlogn]; positivity)]
rw [hL, hl4, hlogn] at key
rw [hlogn]
have h1 : Real.sqrt (2 * n) * (Real.log 2 + 4 * Real.log t) ≤
3 / 2 * t ^ 2 * (8 * t) := by
apply mul_le_mul hs2 (by linarith) (by positivity) (by positivity)
have h2 : k * (Real.log 2 + 4 * Real.log t) ≤ k * (8 * Real.log t) := by
apply mul_le_mul_of_nonneg_left _ hk0; linarith
have h3 : (n : ℝ) * Real.log 2 * (2 / 3) < 4 * Real.log t + 12 * t ^ 3 + k * (8 * Real.log t) := by
linarith
have h4 : (n : ℝ) * 0.6931471803 ≤ (n : ℝ) * Real.log 2 :=
mul_le_mul_of_nonneg_left hl2v.le hn0.le
have h5 : t ^ 4 ≥ 100 * t ^ 3 := by nlinarith [pow_pos (show (0:ℝ) < t by linarith) 3]
have h6 : t ^ 3 ≥ 10000 * t := by nlinarith [mul_pos (show (0:ℝ) < t by linarith) (show (0:ℝ) < t by linarith)]
rw [hn4] at h3 h4 ⊢
nlinarith
-- The vertex offset of the cube with generators `v` selected by `ε`.
private def a52_cubeSum {K : ℕ} (v : Fin K → ℕ) (ε : Fin K → Bool) : ℕ :=
∑ k, if ε k then v k else 0
-- Splitting off the first generator.
private lemma a52_cubeSum_cons {K : ℕ} (d : ℕ) (v : Fin K → ℕ) (ε : Fin (K + 1) → Bool) :
a52_cubeSum (Fin.cons d v : Fin (K + 1) → ℕ) ε = (if ε 0 then d else 0) + a52_cubeSum v (Fin.tail ε) := by
simp [a52_cubeSum, Fin.sum_univ_succ, Fin.tail]
rfl
-- Counting ordered pairs `x < y` in `A`.
private lemma a52_pair_count (A : Finset ℕ) :
2 * ∑ x ∈ A, (A.filter (fun y => x < y)).card + A.card = A.card ^ 2 := by
induction A using Finset.induction_on_max with
| empty => simp
| insert m A hm ih =>
have hmA : m ∉ A := fun h => lt_irrefl _ (hm m h)
rw [Finset.sum_insert hmA, Finset.card_insert_of_notMem hmA]
have h1 : ((insert m A).filter (fun y => m < y)).card = 0 := by
rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff]
intro y hy
rcases Finset.mem_insert.1 hy with rfl | hy
· exact lt_irrefl _
· exact fun h => lt_asymm h (hm y hy)
have h2 : ∀ x ∈ A, ((insert m A).filter (fun y => x < y)).card
= (A.filter (fun y => x < y)).card + 1 := by
intro x hx
rw [Finset.filter_insert, if_pos (hm x hx), Finset.card_insert_of_notMem (by simp [hmA])]
rw [h1, Finset.sum_congr rfl h2, Finset.sum_add_distrib]
simp only [Finset.sum_const, smul_eq_mul, mul_one]
nlinarith [ih]
-- The representation-count sum equals the number of pairs `x < y`.
private lemma a52_sum_r_eq (N : ℕ) (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 N) :
∑ d ∈ Finset.Icc 1 N, (A.filter (fun x => x + d ∈ A)).card
= ∑ x ∈ A, (A.filter (fun y => x < y)).card := by
simp only [Finset.card_filter]
rw [Finset.sum_comm]
refine Finset.sum_congr rfl fun x hx => ?_
rw [← Finset.card_filter, ← Finset.card_filter]
refine Finset.card_nbij' (fun d => x + d) (fun y => y - x) ?_ ?_ ?_ ?_
· intro d hd
simp only [Finset.coe_filter, Finset.mem_Icc, Set.mem_setOf_eq] at hd ⊢
exact ⟨hd.2, by omega⟩
· intro y hy
simp only [Finset.coe_filter, Finset.mem_Icc, Set.mem_setOf_eq] at hy ⊢
have := Finset.mem_Icc.1 (hA hy.1)
refine ⟨⟨by omega, by omega⟩, ?_⟩
rw [Nat.add_sub_cancel' hy.2.le]; exact hy.1
· intro d _; simp
· intro y hy
simp only [Finset.coe_filter, Set.mem_setOf_eq] at hy
simp only
omega
-- Pigeonhole: a popular difference avoiding the forbidden set exists.
private lemma a52_good_d_exists (N : ℕ) (A : Finset ℕ) (F : Finset ℤ) (hA : A ⊆ Finset.Icc 1 N)
(hn : 16 * (F.card + 1) ≤ A.card) :
∃ d ∈ Finset.Icc 1 N, A.card ^ 2 ≤ 4 * N * (A.filter (fun x => x + d ∈ A)).card ∧
(d : ℤ) ∉ F ∧ -(d : ℤ) ∉ F := by
set n := A.card with hn_def
set r : ℕ → ℕ := fun d => (A.filter (fun x => x + d ∈ A)).card with hr_def
set G := (Finset.Icc 1 N).filter (fun d => n ^ 2 ≤ 4 * N * r d) with hG_def
set G' := (Finset.Icc 1 N).filter (fun d => ¬ n ^ 2 ≤ 4 * N * r d) with hG'_def
set B := (Finset.Icc 1 N).filter (fun d : ℕ => (d : ℤ) ∈ F ∨ -(d : ℤ) ∈ F) with hB_def
have hB : B.card ≤ 2 * F.card := by
have hsub : B ⊆ F.image (fun f => f.toNat) ∪ F.image (fun f => (-f).toNat) := by
intro d hd
simp only [hB_def, Finset.mem_filter] at hd
rcases hd.2 with h | h
· exact Finset.mem_union_left _ (Finset.mem_image.2 ⟨_, h, by simp⟩)
· exact Finset.mem_union_right _ (Finset.mem_image.2 ⟨_, h, by simp⟩)
calc B.card ≤ _ := Finset.card_le_card hsub
_ ≤ _ := Finset.card_union_le _ _
_ ≤ F.card + F.card := add_le_add Finset.card_image_le Finset.card_image_le
_ = _ := by ring
have hnpos : 0 < n := by omega
have hN : 0 < N := by
obtain ⟨a, ha⟩ := Finset.card_pos.1 hnpos
have := Finset.mem_Icc.1 (hA ha)
omega
have hsum := a52_sum_r_eq N A hA
have hpc := a52_pair_count A
have hsplit : ∑ d ∈ Finset.Icc 1 N, r d = ∑ d ∈ G, r d + ∑ d ∈ G', r d :=
(Finset.sum_filter_add_sum_filter_not _ _ _).symm
have hGs : ∑ d ∈ G, r d ≤ G.card * n := by
have := Finset.sum_le_card_nsmul G r n (fun d _ => Finset.card_filter_le _ _)
simpa using this
have hG's : 4 * N * ∑ d ∈ G', r d ≤ N * n ^ 2 := by
rw [Finset.mul_sum]
calc ∑ d ∈ G', 4 * N * r d ≤ ∑ d ∈ G', n ^ 2 := by
refine Finset.sum_le_sum fun d hd => ?_
simp only [hG'_def, Finset.mem_filter] at hd
omega
_ = G'.card * n ^ 2 := by simp
_ ≤ N * n ^ 2 := by
refine Nat.mul_le_mul_right _ ?_
calc G'.card ≤ (Finset.Icc 1 N).card := Finset.card_filter_le _ _
_ = N := by simp
have hS : ∑ d ∈ Finset.Icc 1 N, r d = ∑ x ∈ A, (A.filter (fun y => x < y)).card := hsum
have key : N * n * n ≤ N * n * (4 * G.card + 2) := by
nlinarith
have key2 : n ≤ 4 * G.card + 2 := Nat.le_of_mul_le_mul_left key (by positivity)
have hlt : B.card < G.card := by omega
obtain ⟨d, hdG, hdB⟩ := Finset.exists_mem_notMem_of_card_lt_card hlt
simp only [hG_def, Finset.mem_filter] at hdG
simp only [hB_def, Finset.mem_filter, not_and, not_or] at hdB
exact ⟨d, hdG.1, hdG.2, (hdB hdG.1).1, (hdB hdG.1).2⟩
-- Density increment for the next level.
private lemma a52_density_step (N n n' c c' : ℝ) (K : ℕ) (hn : 0 < n) (hn' : 0 < n') (hN : 0 ≤ N)
(hc : 0 ≤ c) (hc' : c' ≤ 3 * c) (hr : n ^ 2 ≤ 4 * N * n')
(h : c * (16 * N / n) ^ (2 ^ (K + 2)) ≤ N) :
c' * (16 * N / n') ^ (2 ^ (K + 1)) ≤ N := by
set x := 16 * N / n with hx
have hx0 : 0 ≤ x := by positivity
have h1 : 16 * N / n' ≤ x ^ 2 / 4 := by
rw [hx, div_pow, div_div, div_le_div_iff₀ hn' (by positivity)]
nlinarith [mul_le_mul_of_nonneg_left hr (by positivity : (0:ℝ) ≤ 16 * N)]
set m := 2 ^ (K + 1) with hm
have hm1 : 1 ≤ m := Nat.one_le_two_pow
have h2 : (16 * N / n') ^ m ≤ x ^ (2 ^ (K + 2)) / 4 := by
calc (16 * N / n') ^ m ≤ (x ^ 2 / 4) ^ m := pow_le_pow_left₀ (by positivity) h1 m
_ = x ^ (2 ^ (K + 2)) / 4 ^ m := by
rw [div_pow, ← pow_mul]; congr 2; rw [hm, pow_succ 2 (K + 1)]; ring
_ ≤ x ^ (2 ^ (K + 2)) / 4 := by
apply div_le_div_of_nonneg_left (by positivity) (by norm_num)
calc (4:ℝ) = 4 ^ 1 := by norm_num
_ ≤ 4 ^ m := pow_le_pow_right₀ (by norm_num) hm1
calc c' * (16 * N / n') ^ m ≤ (3 * c) * (x ^ (2 ^ (K + 2)) / 4) :=
mul_le_mul hc' h2 (by positivity) (by positivity)
_ ≤ c * x ^ (2 ^ (K + 2)) := by nlinarith [pow_nonneg hx0 (2 ^ (K + 2))]
_ ≤ N := h
-- The density hypothesis forces `A` to be large compared with the forbidden set.
private lemma a52_size_bound (N n c : ℝ) (M : ℕ) (hM : 2 ≤ M) (hn : 0 < n) (hnN : n ≤ N)
(hc : 0 ≤ c) (h : c * (16 * N / n) ^ M ≤ N) : 256 * c ≤ n := by
set x := 16 * N / n with hx
have hN : 0 < N := lt_of_lt_of_le hn hnN
have hx16 : 16 ≤ x := by rw [hx, le_div_iff₀ hn]; linarith
have h1 : x ^ 2 ≤ x ^ M := pow_le_pow_right₀ (by linarith) hM
have h2 : c * (16 * x) ≤ N := by nlinarith
have h3 : 256 * c * N ≤ n * N := by
have : c * (16 * x) * n = 256 * c * N := by rw [hx]; field_simp; ring
nlinarith
exact le_of_mul_le_mul_right h3 hN
-- Cube lemma with finitely many nontrivial linear constraints `α * a + ∑ c_k v_k + f ≠ 0`
-- on the base point `a` and the generators `v`.
private lemma a52_cube_lin_aux (K : ℕ) : ∀ (N : ℕ) (A : Finset ℕ)
(C : Finset ((Fin K → ℤ) × ℤ × ℤ)), A ⊆ Finset.Icc 1 N → A.Nonempty →
(∀ q ∈ C, q.2.1 ≠ 0 ∨ q.1 ≠ 0) →
((C.card : ℝ) + 1) * (16 * (N : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ N →
∃ (a : ℕ) (v : Fin K → ℕ), (∀ k, 0 < v k) ∧
(∀ q ∈ C, q.2.1 * (a : ℤ) + ∑ k, q.1 k * (v k : ℤ) + q.2.2 ≠ 0) ∧
∀ ε, a + a52_cubeSum v ε ∈ A := by
induction K with
| zero =>
intro N A C hA hne hC h
have hn0 : 0 < A.card := hne.card_pos
have hnN : A.card ≤ N := by simpa using Finset.card_le_card hA
have hbig : 256 * ((C.card : ℝ) + 1) ≤ A.card :=
a52_size_bound N A.card _ (2 ^ (0 + 1)) (by norm_num)
(by exact_mod_cast hn0) (by exact_mod_cast hnN) (by positivity) h
have hlt : (C.image (fun q => (-q.2.2 / q.2.1).toNat)).card < A.card := by
have h1 : (C.image (fun q => (-q.2.2 / q.2.1).toNat)).card ≤ C.card :=
Finset.card_image_le
have : (C.card : ℝ) < A.card := by linarith
have : C.card < A.card := by exact_mod_cast this
omega
obtain ⟨a, haA, haB⟩ := Finset.exists_mem_notMem_of_card_lt_card hlt
refine ⟨a, Fin.elim0, fun k => k.elim0, ?_, fun ε => by simpa [a52_cubeSum] using haA⟩
intro q hq heq
have hα : q.2.1 ≠ 0 := by
rcases hC q hq with h | h
· exact h
· exact absurd (funext fun k => k.elim0) h
simp only [Finset.univ_eq_empty, Finset.sum_empty, add_zero] at heq
apply haB
refine Finset.mem_image.2 ⟨q, hq, ?_⟩
have : -q.2.2 / q.2.1 = a := by
rw [show -q.2.2 = q.2.1 * a by linarith]; exact Int.mul_ediv_cancel_left _ hα
rw [this]; simp
| succ K ih =>
intro N A C hA hne hC h
have hn0 : 0 < A.card := hne.card_pos
have hnN : A.card ≤ N := by simpa using Finset.card_le_card hA
have hbig : 256 * ((C.card : ℝ) + 1) ≤ A.card :=
a52_size_bound N A.card _ (2 ^ (K + 1 + 1))
(by calc 2 = 2 ^ 1 := by norm_num
_ ≤ 2 ^ (K + 1 + 1) := Nat.pow_le_pow_right (by norm_num) (by omega))
(by exact_mod_cast hn0) (by exact_mod_cast hnN) (by positivity) h
set F : Finset ℤ := C.image (fun q => -q.2.2 / q.1 0) with hF_def
have hFc : F.card ≤ C.card := Finset.card_image_le
have hbig' : 16 * (F.card + 1) ≤ A.card := by
have : (16 : ℝ) * (C.card + 1) ≤ A.card := by linarith
have : 16 * (C.card + 1) ≤ A.card := by exact_mod_cast this
omega
obtain ⟨d, hdI, hdr, hdF, -⟩ := a52_good_d_exists N A F hA hbig'
have hd0 : 0 < d := (Finset.mem_Icc.1 hdI).1
set A' := A.filter (fun x => x + d ∈ A) with hA'_def
set C' : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
(C.filter (fun q => q.2.1 ≠ 0 ∨ Fin.tail q.1 ≠ 0)).image
(fun q => (Fin.tail q.1, q.2.1, q.2.2 + q.1 0 * d)) with hC'_def
have hC'card : C'.card ≤ C.card :=
Finset.card_image_le.trans (Finset.card_filter_le _ _)
have hA'sub : A' ⊆ Finset.Icc 1 N := (Finset.filter_subset _ _).trans hA
have hA'pos : 0 < A'.card := by
rcases Nat.eq_zero_or_pos A'.card with hc | hc
· rw [hc, mul_zero, Nat.le_zero, pow_eq_zero_iff two_ne_zero] at hdr
omega
· exact hc
have hC' : ∀ q ∈ C', q.2.1 ≠ 0 ∨ q.1 ≠ 0 := by
intro q hq
obtain ⟨q0, hq0, rfl⟩ := Finset.mem_image.1 hq
exact (Finset.mem_filter.1 hq0).2
have hstep : ((C'.card : ℝ) + 1) * (16 * (N : ℝ) / A'.card) ^ (2 ^ (K + 1)) ≤ N := by
have hcc : (C'.card : ℝ) ≤ C.card := by exact_mod_cast hC'card
refine a52_density_step N A.card A'.card (C.card + 1) (C'.card + 1) K
(by exact_mod_cast hn0) (by exact_mod_cast hA'pos) (by positivity) (by positivity)
(by linarith) (by exact_mod_cast hdr) h
obtain ⟨a, v, hv, hlin, hmem⟩ := ih N A' C' hA'sub (Finset.card_pos.1 hA'pos) hC' hstep
refine ⟨a, Fin.cons d v, ?_, ?_, ?_⟩
· intro k
refine Fin.cases hd0 (fun i => ?_) k
simpa using hv i
· intro q hq
rw [Fin.sum_univ_succ]
simp only [Fin.cons_zero, Fin.cons_succ]
by_cases hgood : q.2.1 ≠ 0 ∨ Fin.tail q.1 ≠ 0
· have := hlin _ (Finset.mem_image.2 ⟨q, Finset.mem_filter.2 ⟨hq, hgood⟩, rfl⟩)
simp only [Fin.tail] at this
intro h; apply this; linarith
· push_neg at hgood
obtain ⟨hα, htail⟩ := hgood
have hts : ∀ i : Fin K, q.1 i.succ = 0 := fun i => congrFun htail i
have hc0 : q.1 0 ≠ 0 := by
rcases hC q hq with h | h
· exact absurd hα h
· intro h0; apply h; funext k
exact Fin.cases h0 (fun i => hts i) k
simp only [hα, hts, zero_mul, Finset.sum_const_zero, add_zero, zero_add]
intro heq
apply hdF
refine Finset.mem_image.2 ⟨q, hq, ?_⟩
rw [show -q.2.2 = q.1 0 * d by linarith]; exact Int.mul_ediv_cancel_left _ hc0
· intro ε
rw [a52_cubeSum_cons]
have hm := hmem (Fin.tail ε)
rw [hA'_def, Finset.mem_filter] at hm
cases ε 0
· simpa using hm.1
· simpa [add_comm, add_left_comm, add_assoc] using hm.2
-- Constraints encoding distinctness of the cube vertices.
private def a52_vertexConstraints (K : ℕ) : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
((Finset.univ : Finset ((Fin K → Bool) × (Fin K → Bool))).filter (fun p => p.1 ≠ p.2)).image
(fun p => (fun k => (if p.1 k then 1 else 0) - (if p.2 k then 1 else 0), 0, 0))
-- Coefficient of `v k` in the shift `r(ε, h)`.
private def a52_shiftCoeff {K : ℕ} (ε : Fin K → Bool) (h : ℕ) (k : Fin K) : ℤ :=
if ε k then ((h + 1 + K : ℕ) : ℤ) - ((k.1 : ℤ) + 1) else 0
-- Constraints encoding distinctness of the shifts.
private def a52_shiftConstraints (K H : ℕ) : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
((Finset.univ : Finset (((Fin K → Bool) × Fin H) × ((Fin K → Bool) × Fin H))).filter
(fun p => p.1 ≠ p.2)).image
(fun p => (fun k => a52_shiftCoeff p.1.1 p.1.2.1 k - a52_shiftCoeff p.2.1 p.2.2.1 k,
((p.1.2.1 + 1 + K : ℕ) : ℤ) - ((p.2.2.1 + 1 + K : ℕ) : ℤ), 0))
private lemma a52_constraints_nontrivial (K H : ℕ) :
∀ q ∈ a52_vertexConstraints K ∪ a52_shiftConstraints K H, q.2.1 ≠ 0 ∨ q.1 ≠ 0 := by
intro q hq
rcases Finset.mem_union.1 hq with hq | hq
· obtain ⟨⟨ε, ε'⟩, hp, rfl⟩ := Finset.mem_image.1 hq
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hp
right
obtain ⟨k, hk⟩ := Function.ne_iff.1 hp
intro h0
have := congrFun h0 k
simp only [Pi.zero_apply] at this
cases h1 : ε k <;> cases h2 : ε' k <;> simp_all
· obtain ⟨⟨⟨ε, h⟩, ⟨ε', h'⟩⟩, hp, rfl⟩ := Finset.mem_image.1 hq
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hp
by_cases hh : h = h'
· subst hh
right
have hne : ε ≠ ε' := fun he => hp (by rw [he])
obtain ⟨k, hk⟩ := Function.ne_iff.1 hne
intro h0
have := congrFun h0 k
simp only [Pi.zero_apply, a52_shiftCoeff] at this
have hk2 := k.2
cases h1 : ε k <;> cases h2 : ε' k <;> simp_all <;> omega
· left
intro h0
apply hh
apply Fin.ext
push_cast at h0
omega
private lemma a52_vertex_diff {K : ℕ} (a : ℤ) (v : Fin K → ℤ) (ε ε' : Fin K → Bool) :
(a + ∑ k, if ε k then v k else 0) - (a + ∑ k, if ε' k then v k else 0) =
∑ k, ((if ε k then 1 else 0) - (if ε' k then 1 else 0)) * v k := by
rw [add_sub_add_left_eq_sub, ← Finset.sum_sub_distrib]
refine Finset.sum_congr rfl fun k _ => ?_
split_ifs <;> ring
private lemma a52_shift_diff {K : ℕ} (a : ℤ) (v : Fin K → ℤ) (ε ε' : Fin K → Bool) (h h' : ℕ) :
((a + ∑ k, if ε k then v k else 0) * ((h + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε k then v k else 0)) -
((a + ∑ k, if ε' k then v k else 0) * ((h' + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε' k then v k else 0)) =
(((h + 1 + K : ℕ) : ℤ) - ((h' + 1 + K : ℕ) : ℤ)) * a +
∑ k, (a52_shiftCoeff ε h k - a52_shiftCoeff ε' h' k) * v k := by
have : ∀ k, (a52_shiftCoeff ε h k - a52_shiftCoeff ε' h' k) * v k =
(if ε k then v k else 0) * ((h + 1 + K : ℕ) : ℤ) - ((k.1 : ℤ) + 1) * (if ε k then v k else 0)
- ((if ε' k then v k else 0) * ((h' + 1 + K : ℕ) : ℤ)
- ((k.1 : ℤ) + 1) * (if ε' k then v k else 0)) := by
intro k; simp only [a52_shiftCoeff]; split_ifs <;> ring
simp only [this, Finset.sum_sub_distrib, add_mul, Finset.sum_mul]
ring
/-- Qualitative Lemma 5.2 of TT (arXiv:2512.01739v2, p. 50), without the window `[P/2, P]`:
for all `K, H` there are `p₀, v` with the `2^K` numbers `p_ε = p₀ + ∑ ε_k v_k` distinct primes and
the shifts `r_{ε,h+K} = p_ε (h+K) - ∑_k k ε_k v_k` (`ε ∈ {0,1}^K`, `1 ≤ h ≤ H`) pairwise distinct.
(The paper needs the quantitative form with the primes in `[P/2, P]`.) -/
-- Asymptotic inequality behind the quantitative cube lemma (θ < 1).
private lemma a52_quant_asymp_real (θ D : ℝ) (hθ : θ < 1) :
∀ᶠ y : ℝ in Filter.atTop, 4 * Real.log y + 2 * y ^ θ * (Real.log D + Real.log y) + Real.log 6 ≤ y := by
have h1 : (fun y : ℝ => Real.log y) =o[Filter.atTop] (fun y => y) := Real.isLittleO_log_id_atTop
have hr : 0 < 1 - θ := by linarith
have h3 : (fun y : ℝ => y ^ θ * (Real.log D + Real.log y)) =o[Filter.atTop] (fun y => y) := by
have hc : (fun _ : ℝ => Real.log D) =o[Filter.atTop] (fun y : ℝ => y ^ (1 - θ)) :=
Asymptotics.isLittleO_const_left.2
(Or.inr (tendsto_norm_atTop_atTop.comp (tendsto_rpow_atTop hr)))
have hl : (fun y : ℝ => Real.log D + Real.log y) =o[Filter.atTop] (fun y => y ^ (1 - θ)) :=
hc.add (isLittleO_log_rpow_atTop hr)
have := (Asymptotics.isBigO_refl (fun y : ℝ => y ^ θ) Filter.atTop).mul_isLittleO hl
refine this.congr' Filter.EventuallyEq.rfl ?_
filter_upwards [Filter.eventually_gt_atTop 0] with y hy
rw [← Real.rpow_add hy]; simp
have h4 : (fun _ : ℝ => (1:ℝ)) =o[Filter.atTop] (fun y => y) := Asymptotics.isLittleO_const_id_atTop 1
have hsum : (fun y : ℝ => 4 * Real.log y + 2 * y ^ θ * (Real.log D + Real.log y) + Real.log 6)
=o[Filter.atTop] (fun y => y) := by
have := ((h1.const_mul_left 4).add (h3.const_mul_left 2)).add (h4.const_mul_left (Real.log 6))
refine this.congr_left (fun y => by ring)
filter_upwards [hsum.bound one_pos, Filter.eventually_ge_atTop 0] with y hy hy0
rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg hy0, one_mul] at hy
exact (le_abs_self _).trans hy
-- The same inequality along naturals `P`, in the shape needed for `a52_cube_lin_aux`.
private lemma a52_quant_asymp_nat (θ D : ℝ) (hθ : θ < 1) (hD : 1 ≤ D) :
∃ P1 : ℕ, ∀ P : ℕ, P1 ≤ P → 1 ≤ Real.log P ∧
3 * Real.log P ^ 4 * (D * Real.log P) ^ (2 * Real.log P ^ θ) ≤ (P : ℝ) / 2 := by
have ht : Filter.Tendsto (fun P : ℕ => Real.log P) Filter.atTop Filter.atTop :=
Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
obtain ⟨P1, hP1⟩ := Filter.eventually_atTop.1
(ht.eventually ((a52_quant_asymp_real θ D hθ).and (Filter.eventually_ge_atTop 1)))
refine ⟨P1, fun P hP => ?_⟩
obtain ⟨h, hy1⟩ := hP1 P hP
refine ⟨hy1, ?_⟩
set y := Real.log P with hy
have hP0 : (0 : ℝ) < P := by
by_contra hc
have : (P : ℝ) = 0 := le_antisymm (not_lt.1 hc) (Nat.cast_nonneg _)
rw [hy, this, Real.log_zero] at hy1; linarith
have hy0 : 0 < y := by linarith
have hDy : 0 < D * y := by positivity
have hD0 : 0 < D := by linarith
rw [← Real.log_le_log_iff (by positivity) (by positivity), Real.log_mul (by positivity)
(by positivity), Real.log_mul (by positivity) (by positivity), Real.log_pow,
Real.log_rpow hDy, Real.log_mul hD0.ne' hy0.ne', Real.log_div hP0.ne' (by norm_num),
← hy]
have h6 : Real.log 6 = Real.log 3 + Real.log 2 := by
rw [← Real.log_mul (by norm_num) (by norm_num)]; norm_num
push_cast
linarith
-- Counting bound on the constraint set.
private lemma a52_quant_constraints_card (K H : ℕ) :
((a52_vertexConstraints K ∪ a52_shiftConstraints K H).card : ℝ) ≤
((2 : ℝ) ^ K) ^ 2 + ((2 : ℝ) ^ K * H) ^ 2 := by
have h1 : (a52_vertexConstraints K).card ≤ (2 ^ K) ^ 2 := by
unfold a52_vertexConstraints
refine (Finset.card_image_le).trans ((Finset.card_filter_le _ _).trans ?_)
rw [Finset.card_univ, Fintype.card_prod, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin,
sq]
have h2 : (a52_shiftConstraints K H).card ≤ (2 ^ K * H) ^ 2 := by
unfold a52_shiftConstraints
refine (Finset.card_image_le).trans ((Finset.card_filter_le _ _).trans ?_)
rw [Finset.card_univ, Fintype.card_prod, Fintype.card_prod, Fintype.card_fun, Fintype.card_bool,
Fintype.card_fin, Fintype.card_fin, sq]
have h3 := (Finset.card_union_le (a52_vertexConstraints K) (a52_shiftConstraints K H)).trans
(Nat.add_le_add h1 h2)
exact_mod_cast h3
/- Quantitative Lemma 5.2 of Tao–Teräväinen (arXiv:2512.01739v2, p. 50): K and H may grow with P.
For every θ < 1 and all large P: whenever 2^K ≤ (log P)^θ and H ≤ (log P)^θ, there are p₀, v with
the 2^K numbers p_ε = p₀ + Σ ε_k v_k distinct primes in the window (P/2, P], and the shifts
r_{ε,h+K} = p_ε (h+K) − Σ_k k ε_k v_k (ε ∈ {0,1}^K, 1 ≤ h ≤ H) pairwise distinct.
(The paper takes 2^K ≈ H ≈ (log P)^{2/3}; see `a52_hilbert_cube_primes_quant_two_thirds`.) -/
private theorem a52_hilbert_cube_primes_quant (θ : ℝ) (hθ : θ < 1) :
∃ P0 : ℕ, ∀ P : ℕ, P0 ≤ P → ∀ K H : ℕ,
(2 : ℝ) ^ K ≤ Real.log P ^ θ → (H : ℝ) ≤ Real.log P ^ θ →
∃ (p0 : ℤ) (v : Fin K → ℤ),
(∀ ε : Fin K → Bool, ∃ p : ℕ, p.Prime ∧ P < 2 * p ∧ p ≤ P ∧
(p : ℤ) = p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) := by
obtain ⟨c, hc, N0, hN0⟩ := a52_primes_in_dyadic_lower
set D : ℝ := 32 / c + 1 with hD
have hD1 : 1 ≤ D := by rw [hD]; linarith [div_pos (by norm_num : (0:ℝ) < 32) hc]
obtain ⟨P1, hP1⟩ := a52_quant_asymp_nat θ D hθ hD1
refine ⟨max P1 (2 * N0 + 6), fun P hP K H hK hH => ?_⟩
have hPP1 : P1 ≤ P := le_trans (le_max_left _ _) hP
have hPN : 2 * N0 + 6 ≤ P := le_trans (le_max_right _ _) hP
obtain ⟨hy1, hasym⟩ := hP1 P hPP1
set C := a52_vertexConstraints K ∪ a52_shiftConstraints K H with hCdef
set n := P / 2 with hndef
have hnN0 : N0 ≤ n := by omega
have hn3 : 3 ≤ n := by omega
set A := (Finset.Ioc n (2 * n)).filter Nat.Prime with hAdef
set y := Real.log P with hy
set L := y ^ θ with hL
have hnr : (3 : ℝ) ≤ n := by exact_mod_cast hn3
have hlogn : 0 < Real.log n := Real.log_pos (by linarith)
have hlognP : Real.log n ≤ y :=
Real.log_le_log (by linarith) (by exact_mod_cast Nat.div_le_self P 2)
have hcard : c * (n : ℝ) / Real.log n ≤ (A.card : ℝ) := hN0 n hnN0
have hApos : (0 : ℝ) < A.card := lt_of_lt_of_le (by positivity) hcard
have hne : A.Nonempty := Finset.card_pos.mp (by exact_mod_cast hApos)
have hsub : A ⊆ Finset.Icc 1 (2 * n) := by
intro x hx
simp only [hAdef, Finset.mem_filter, Finset.mem_Ioc] at hx
exact Finset.mem_Icc.mpr ⟨by omega, hx.1.2⟩
have hbound : 16 * ((2 * n : ℕ) : ℝ) / A.card ≤ D * y := by
rw [div_le_iff₀ hApos]
calc 16 * ((2 * n : ℕ) : ℝ) = (32 / c * Real.log n) * (c * n / Real.log n) := by
push_cast; field_simp; ring
_ ≤ (32 / c * Real.log n) * A.card :=
mul_le_mul_of_nonneg_left hcard (by positivity)
_ ≤ (D * y) * A.card := by
apply mul_le_mul_of_nonneg_right _ hApos.le
have h32 : 0 ≤ 32 / c := by positivity
calc 32 / c * Real.log n ≤ 32 / c * y := mul_le_mul_of_nonneg_left hlognP h32
_ ≤ D * y := mul_le_mul_of_nonneg_right (by rw [hD]; linarith) (by linarith)
have hL1 : 1 ≤ L := le_trans (one_le_pow₀ (by norm_num)) hK
have hLy : L ≤ y := by
have := Real.rpow_le_rpow_of_exponent_le hy1 hθ.le
rwa [Real.rpow_one] at this
have hH0 : (0 : ℝ) ≤ H := Nat.cast_nonneg H
have h2K0 : (0 : ℝ) ≤ 2 ^ K := by positivity
have hCcard : (C.card : ℝ) + 1 ≤ 3 * y ^ 4 := by
have h1 := a52_quant_constraints_card K H
have hKH : (2 : ℝ) ^ K * H ≤ L * L := mul_le_mul hK hH hH0 (by linarith)
have hsq1 : ((2 : ℝ) ^ K) ^ 2 ≤ L ^ 2 := pow_le_pow_left₀ h2K0 hK 2
have hsq2 : ((2 : ℝ) ^ K * H) ^ 2 ≤ (L * L) ^ 2 := pow_le_pow_left₀ (by positivity) hKH 2
have hL4 : L ^ 2 ≤ L ^ 4 := pow_le_pow_right₀ hL1 (by norm_num)
have hL4' : (1 : ℝ) ≤ L ^ 4 := one_le_pow₀ hL1
have hLy4 : L ^ 4 ≤ y ^ 4 := pow_le_pow_left₀ (by linarith) hLy 4
have hC : (C.card : ℝ) ≤ ((2 : ℝ) ^ K) ^ 2 + ((2 : ℝ) ^ K * H) ^ 2 := h1
nlinarith
have hDy1 : 1 ≤ D * y := by nlinarith
have hX0 : 0 ≤ 16 * ((2 * n : ℕ) : ℝ) / A.card := by positivity
have hexp : (((2 ^ (K + 1) : ℕ) : ℝ)) ≤ 2 * L := by
push_cast; rw [pow_succ]; linarith
have hXpow : (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ (D * y) ^ (2 * L) := by
calc (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ (D * y) ^ (2 ^ (K + 1)) :=
pow_le_pow_left₀ hX0 hbound _
_ = (D * y) ^ (((2 ^ (K + 1) : ℕ) : ℝ)) := (Real.rpow_natCast _ _).symm
_ ≤ (D * y) ^ (2 * L) := Real.rpow_le_rpow_of_exponent_le hDy1 hexp
have hNP : (P : ℝ) / 2 ≤ ((2 * n : ℕ) : ℝ) := by
have h1 : P ≤ 2 * n + 1 := by omega
have h2 : (P : ℝ) ≤ ((2 * n : ℕ) : ℝ) + 1 := by exact_mod_cast h1
have h3 : (6 : ℝ) ≤ P := by exact_mod_cast (le_trans (by omega) hPN)
linarith
have hpow : ((C.card : ℝ) + 1) * (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤
((2 * n : ℕ) : ℝ) := by
calc ((C.card : ℝ) + 1) * (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1))
≤ (3 * y ^ 4) * (D * y) ^ (2 * L) :=
mul_le_mul hCcard hXpow (by positivity) (by positivity)
_ ≤ (P : ℝ) / 2 := hasym
_ ≤ _ := hNP
obtain ⟨a, v, -, hlin, hmem⟩ :=
a52_cube_lin_aux K (2 * n) A C hsub hne (a52_constraints_nontrivial K H) hpow
have hcast : ∀ ε : Fin K → Bool,
((a + a52_cubeSum v ε : ℕ) : ℤ) = (a : ℤ) + ∑ k, if ε k then (v k : ℤ) else 0 := by
intro ε; simp [a52_cubeSum, Nat.cast_sum, Nat.cast_ite]
refine ⟨a, fun k => v k, fun ε => ?_, ?_, ?_⟩
· have h := hmem ε
simp only [hAdef, Finset.mem_filter, Finset.mem_Ioc] at h
exact ⟨_, h.2, by omega, by omega, hcast ε⟩
· intro ε ε' heq
by_contra hne'
have hq : ((fun k => (if ε k then (1 : ℤ) else 0) - (if ε' k then 1 else 0)), (0 : ℤ),
(0 : ℤ)) ∈ C :=
Finset.mem_union_left _ (Finset.mem_image.2 ⟨(ε, ε'), Finset.mem_filter.2 ⟨Finset.mem_univ _, hne'⟩, rfl⟩)
apply hlin _ hq
have hd := a52_vertex_diff (a : ℤ) (fun k => (v k : ℤ)) ε ε'
simp only at heq hd ⊢
rw [heq, sub_self] at hd
simp only [zero_mul, zero_add, add_zero]
exact hd.symm
· rintro ⟨ε, h⟩ ⟨ε', h'⟩ heq
by_contra hne'
have hq : ((fun k => a52_shiftCoeff ε h.1 k - a52_shiftCoeff ε' h'.1 k),
((h.1 + 1 + K : ℕ) : ℤ) - ((h'.1 + 1 + K : ℕ) : ℤ), (0 : ℤ)) ∈ C :=
Finset.mem_union_right _
(Finset.mem_image.2 ⟨((ε, h), (ε', h')), Finset.mem_filter.2 ⟨Finset.mem_univ _, hne'⟩, rfl⟩)
apply hlin _ hq
have hd := a52_shift_diff (a : ℤ) (fun k => (v k : ℤ)) ε ε' h.1 h'.1
simp only at heq hd ⊢
rw [heq, sub_self] at hd
rw [add_zero]
exact hd.symm
private theorem a52_hilbert_cube_primes_quant_two_thirds :
∃ P0 : ℕ, ∀ P : ℕ, P0 ≤ P → ∀ K H : ℕ,
(2 : ℝ) ^ K ≤ Real.log P ^ ((2 : ℝ) / 3) → (H : ℝ) ≤ Real.log P ^ ((2 : ℝ) / 3) →
∃ (p0 : ℤ) (v : Fin K → ℤ),
(∀ ε : Fin K → Bool, ∃ p : ℕ, p.Prime ∧ P < 2 * p ∧ p ≤ P ∧
(p : ℤ) = p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) :=
a52_hilbert_cube_primes_quant (2 / 3) (by norm_num)
private theorem mf_log_factorial (n : ℕ) :
Real.log (n.factorial : ℝ) =
∑ p ∈ (Finset.Iic n).filter Nat.Prime, (padicValNat p n.factorial : ℝ) * Real.log p := by
have hsub : (n.factorial).factorization.support ⊆ (Finset.Iic n).filter Nat.Prime := by
intro p hp
rw [Nat.support_factorization] at hp
have hpp := Nat.prime_of_mem_primeFactors hp
have hdvd := Nat.dvd_of_mem_primeFactors hp
simp only [Finset.mem_filter, Finset.mem_Iic]
exact ⟨(hpp.dvd_factorial).1 hdvd, hpp⟩
rw [Real.log_nat_eq_sum_factorization, Finsupp.sum_of_support_subset _ hsub _ (by intros; simp)]
apply Finset.sum_congr rfl
intro p hp
rw [Nat.factorization_def _ (Finset.mem_filter.1 hp).2]
/-- `v_p(n!) ≥ ⌊n/p⌋ > n/p - 1`. -/
private theorem mf_padic_lower (n p : ℕ) (hp : p.Prime) :
(n : ℝ) / p - 1 ≤ (padicValNat p n.factorial : ℝ) := by
haveI := Fact.mk hp
have hp0 : (0:ℝ) < p := by exact_mod_cast hp.pos
have h1 : n / p ≤ padicValNat p n.factorial := by
rw [padicValNat_factorial (b := Nat.log p n + 1) (Nat.lt_succ_self _)]
rcases Nat.lt_or_ge n p with h | h
· rw [Nat.div_eq_of_lt h]; exact Nat.zero_le _
· have hlog : 0 < Nat.log p n := Nat.log_pos hp.one_lt h
have hmem : 1 ∈ Finset.Ico 1 (Nat.log p n + 1) := by
simp only [Finset.mem_Ico]; omega
calc n / p = n / p ^ 1 := by rw [pow_one]
_ ≤ _ := Finset.single_le_sum (f := fun i => n / p ^ i) (fun i _ => Nat.zero_le _) hmem
have h2 : (n : ℝ) < ((n / p : ℕ) : ℝ) * p + p := by
exact_mod_cast Nat.lt_div_mul_add hp.pos
have h3 : (n : ℝ) / p - 1 < ((n / p : ℕ) : ℝ) := by
rw [div_sub_one hp0.ne', div_lt_iff₀ hp0]; linarith
have h4 : ((n / p : ℕ) : ℝ) ≤ (padicValNat p n.factorial : ℝ) := by exact_mod_cast h1
linarith
/-- `(p - 1) v_p(n!) ≤ n`. -/
private theorem mf_padic_upper (n p : ℕ) (hp : p.Prime) :
((p : ℝ) - 1) * (padicValNat p n.factorial : ℝ) ≤ n := by
haveI := Fact.mk hp
rcases Nat.eq_zero_or_pos n with rfl | hn
· simp
have h := sub_one_mul_padicValNat_factorial_lt_of_ne_zero p hn.ne'
have h' : ((p - 1 : ℕ) : ℝ) * (padicValNat p n.factorial : ℝ) ≤ n := by exact_mod_cast h.le
rwa [Nat.cast_sub hp.one_le, Nat.cast_one] at h'
/-- Chebyshev: `θ(n) ≤ n log 4`. -/
private theorem mf_theta (n : ℕ) :
∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p ≤ Real.log 4 * n := by
have h := Chebyshev.theta_le_log4_mul_x (x := (n : ℝ)) (Nat.cast_nonneg n)
rw [Chebyshev.theta_eq_sum_Icc, Nat.floor_natCast] at h
have : Finset.Icc 0 n = Finset.Iic n := by ext; simp
rwa [this] at h
private theorem mf_log_fact_le (n : ℕ) : Real.log (n.factorial : ℝ) ≤ n * Real.log n := by
have h0 : (0:ℝ) < n.factorial := by exact_mod_cast Nat.factorial_pos n
have h : (n.factorial : ℝ) ≤ (n:ℝ) ^ n := by exact_mod_cast Nat.factorial_le_pow n
calc Real.log (n.factorial : ℝ) ≤ Real.log ((n:ℝ)^n) := Real.log_le_log h0 h
_ = n * Real.log n := by rw [Real.log_pow]
private theorem mf_log_fact_ge (n : ℕ) : n * Real.log n - n ≤ Real.log (n.factorial : ℝ) := by
have h0 : (0:ℝ) < n.factorial := by exact_mod_cast Nat.factorial_pos n
rcases Nat.eq_zero_or_pos n with rfl | hn
· simp
have h := Real.pow_div_factorial_le_exp (n : ℝ) (Nat.cast_nonneg n) n
have hn' : (0:ℝ) < n := by exact_mod_cast hn
have hpos : (0:ℝ) < (n:ℝ)^n / n.factorial := by positivity
have := Real.log_le_log hpos h
rw [Real.log_exp, Real.log_div (by positivity) h0.ne', Real.log_pow] at this
linarith
private theorem mf_term_le (p : ℕ) (hp : 2 ≤ p) :
Real.log p / (p * (p - 1)) ≤ 4 * (1 / (p : ℝ) ^ (3/2 : ℝ)) := by
have hp' : (2:ℝ) ≤ p := by exact_mod_cast hp
have hp0 : (0:ℝ) < p := by linarith
have hs0 : 0 < (p:ℝ) ^ (1/2 : ℝ) := Real.rpow_pos_of_pos hp0 _
have hss : (p:ℝ) ^ (1/2 : ℝ) * (p:ℝ) ^ (1/2 : ℝ) = p := by
rw [← Real.rpow_add hp0]; norm_num
have h32 : (p:ℝ) ^ (3/2 : ℝ) = p * (p:ℝ) ^ (1/2 : ℝ) := by
rw [show (3/2:ℝ) = 1 + 1/2 by norm_num, Real.rpow_add hp0, Real.rpow_one]
have hlog : Real.log p ≤ 2 * (p:ℝ) ^ (1/2 : ℝ) := by
have := Real.log_le_rpow_div (x := (p:ℝ)) (ε := 1/2) hp0.le (by norm_num)
have e : (p:ℝ) ^ (1/2 : ℝ) / (1/2) = 2 * (p:ℝ) ^ (1/2 : ℝ) := by ring
linarith
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by linarith)
rw [h32, mul_one_div, div_le_div_iff₀ (by nlinarith) (by positivity)]
have h1 : Real.log p * (p:ℝ) ^ (1/2 : ℝ) ≤ 2 * p := by nlinarith
nlinarith
/-- `∑_{p ≤ n} log p / (p (p - 1))` is bounded. -/
private theorem mf_tail_bound : ∃ C0 : ℝ, ∀ n : ℕ,
∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / (p * (p - 1)) ≤ C0 := by
have hsum : Summable (fun m : ℕ => 4 * (1 / (m : ℝ) ^ (3/2 : ℝ))) :=
(Real.summable_one_div_nat_rpow.2 (by norm_num)).mul_left 4
refine ⟨∑' m : ℕ, 4 * (1 / (m : ℝ) ^ (3/2 : ℝ)), fun n => ?_⟩
calc _ ≤ ∑ p ∈ (Finset.Iic n).filter Nat.Prime, 4 * (1 / (p : ℝ) ^ (3/2 : ℝ)) :=
Finset.sum_le_sum fun p hp => mf_term_le p (Finset.mem_filter.1 hp).2.two_le
_ ≤ _ := hsum.sum_le_tsum _ (fun i _ => by positivity)
/-- Mertens' first theorem: `∑_{p ≤ n} log p / p = log n + O(1)`. -/
private theorem u_mertens_first :
∃ C : ℝ, ∀ n : ℕ, 2 ≤ n →
|(∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) - Real.log n| ≤ C := by
obtain ⟨C0, hC0⟩ := mf_tail_bound
refine ⟨Real.log 4 + 1 + |C0|, fun n hn => ?_⟩
have hn0 : (0:ℝ) < n := by exact_mod_cast (show 0 < n by omega)
have hL := mf_log_factorial n
have hup : (n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p)
≤ Real.log (n.factorial : ℝ) + Real.log 4 * n := by
have : (n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) ≤
∑ p ∈ (Finset.Iic n).filter Nat.Prime,
((padicValNat p n.factorial : ℝ) * Real.log p + Real.log p) := by
rw [Finset.mul_sum]
apply Finset.sum_le_sum
intro p hp
have hpp := (Finset.mem_filter.1 hp).2
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by exact_mod_cast hpp.one_lt.le)
have hv := mf_padic_lower n p hpp
have e : (n:ℝ) * (Real.log p / p) = ((n:ℝ) / p) * Real.log p := by ring
rw [e]; nlinarith
rw [Finset.sum_add_distrib, ← hL] at this
linarith [mf_theta n]
have hlo : Real.log (n.factorial : ℝ) ≤
(n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) + n * C0 := by
rw [hL]
have : ∑ p ∈ (Finset.Iic n).filter Nat.Prime, (padicValNat p n.factorial : ℝ) * Real.log p ≤
∑ p ∈ (Finset.Iic n).filter Nat.Prime,
((n:ℝ) * (Real.log p / p) + n * (Real.log p / (p * (p - 1)))) := by
apply Finset.sum_le_sum
intro p hp
have hpp := (Finset.mem_filter.1 hp).2
have hp2 : (2:ℝ) ≤ p := by exact_mod_cast hpp.two_le
have hpne : (p:ℝ) ≠ 0 := by linarith
have hp1 : (p:ℝ) - 1 ≠ 0 := by linarith
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by linarith)
have hv := mf_padic_upper n p hpp
have key : (n:ℝ) * (Real.log p / p) + n * (Real.log p / (p * (p - 1)))
= (n:ℝ) / (p - 1) * Real.log p := by
field_simp; ring
rw [key]
have : (padicValNat p n.factorial : ℝ) ≤ n / (p - 1) := by
rw [le_div_iff₀ (by linarith)]; linarith
exact mul_le_mul_of_nonneg_right this hlog0
rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] at this
have := hC0 n
nlinarith
have h1 := mf_log_fact_le n
have h2 := mf_log_fact_ge n
have hSup : (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) ≤ Real.log n + Real.log 4 := by
by_contra h; push_neg at h; nlinarith
have hSlo : Real.log n - 1 - C0 ≤ (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) := by
by_contra h; push_neg at h; nlinarith
have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num)
rw [abs_le]; constructor
· linarith [le_abs_self C0]
· linarith [abs_nonneg C0]
private theorem ms_Iic_succ (g : ℕ → ℝ) (n : ℕ) :
∑ p ∈ (Finset.Iic (n+1)).filter Nat.Prime, g p =
∑ p ∈ (Finset.Iic n).filter Nat.Prime, g p + if (n+1).Prime then g (n+1) else 0 := by
have h : ∀ m : ℕ, Finset.Iic m = Finset.range (m+1) := by
intro m; ext x; simp [Nat.lt_succ_iff]
rw [h, h, Finset.sum_filter, Finset.sum_filter, Finset.sum_range_succ]
private theorem ms_Iic_two : (Finset.Iic 2).filter Nat.Prime = {2} := by
ext x
simp only [Finset.mem_filter, Finset.mem_Iic, Finset.mem_singleton]
constructor
· rintro ⟨h1, h2⟩
interval_cases x
· exact absurd h2 Nat.not_prime_zero
· exact absurd h2 Nat.not_prime_one
· rfl
· rintro rfl; exact ⟨le_rfl, Nat.prime_two⟩
/-- Discrete Abel summation of `1/p = (log p / p) / log p`. -/
private theorem ms_abel (n : ℕ) (hn : 2 ≤ n) :
∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1:ℝ) / p =
(∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n +
∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
induction n, hn using Nat.le_induction with
| base =>
rw [ms_Iic_two]
have hl2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne'
simp only [Finset.sum_singleton, Finset.Ico_self, Finset.sum_empty, Nat.cast_ofNat, add_zero]
field_simp
| succ n hn ih =>
have hB := ms_Iic_succ (fun p : ℕ => (1:ℝ) / p) n
have hA := ms_Iic_succ (fun p : ℕ => Real.log p / p) n
rw [Finset.sum_Ico_succ_top hn, hB, hA, ih]
have hm : ((n:ℝ) + 1) ≠ 0 := by positivity
have hL : Real.log ((n:ℝ) + 1) ≠ 0 := (Real.log_pos (by
have : (2:ℝ) ≤ n := by exact_mod_cast hn
linarith)).ne'
push_cast
split_ifs with hp
· field_simp
ring
· ring
private theorem ms_tele (F : ℕ → ℝ) (n : ℕ) (hn : 2 ≤ n) :
∑ k ∈ Finset.Ico 2 n, (F (k+1) - F k) = F n - F 2 := by
induction n, hn using Nat.le_induction with
| base => simp
| succ n hn ih => rw [Finset.sum_Ico_succ_top hn, ih]; ring
/-- For `k ≥ 2`, with `u = log k`, `v = log (k+1)`, `d = 1/u - 1/v`:
`loglog(k+1) - loglog k - d ≤ u d ≤ loglog(k+1) - loglog k` and `0 ≤ d`. -/
private theorem ms_point (k : ℕ) (hk : 2 ≤ k) :
Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k)
- (1 / Real.log k - 1 / Real.log ((k:ℝ)+1))
≤ Real.log k * (1 / Real.log k - 1 / Real.log ((k:ℝ)+1)) ∧
Real.log k * (1 / Real.log k - 1 / Real.log ((k:ℝ)+1))
≤ Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k) ∧
0 ≤ 1 / Real.log k - 1 / Real.log ((k:ℝ)+1) := by
have hk' : (2:ℝ) ≤ k := by exact_mod_cast hk
have hu : 0 < Real.log k := Real.log_pos (by linarith)
have huv : Real.log k < Real.log ((k:ℝ)+1) := Real.log_lt_log (by linarith) (by linarith)
have hv : 0 < Real.log ((k:ℝ)+1) := by linarith
have hvu1 : Real.log ((k:ℝ)+1) - Real.log k ≤ 1 := by
have h := Real.log_le_sub_one_of_pos (x := ((k:ℝ)+1)/k) (by positivity)
rw [Real.log_div (by positivity) (by positivity)] at h
have e : ((k:ℝ)+1)/k - 1 = 1/k := by field_simp; ring
have : 1/(k:ℝ) ≤ 1 := by rw [div_le_one (by positivity)]; linarith
linarith
set u := Real.log k
set v := Real.log ((k:ℝ)+1)
have hll : Real.log v - Real.log u = Real.log (v/u) := (Real.log_div hv.ne' hu.ne').symm
have hvu0 : 0 < v / u := by positivity
have hup := Real.log_le_sub_one_of_pos hvu0
have hlo := Real.one_sub_inv_le_log_of_pos hvu0
have e1 : u * (1/u - 1/v) = 1 - (v/u)⁻¹ := by field_simp
have e2 : v/u - 1 - (1/u - 1/v) - u * (1/u - 1/v) = (v - u - 1) * (v - u) / (u * v) := by
field_simp; ring
have hneg : (v - u - 1) * (v - u) / (u * v) ≤ 0 :=
div_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonpos_of_nonneg (by linarith) (by linarith))
(by positivity)
have hd : 0 ≤ 1/u - 1/v := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hu huv.le
refine ⟨by linarith, by linarith, hd⟩
/-- Mertens' second theorem: `∑_{p ≤ n} 1/p = log log n + O(1)`. -/
private theorem u_mertens_second :
∃ C : ℝ, ∀ n : ℕ, 3 ≤ n →
|(∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1 : ℝ) / p) - Real.log (Real.log n)| ≤ C := by
obtain ⟨C, hC⟩ := u_mertens_first
have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num)
have hC0 : 0 ≤ C := le_trans (abs_nonneg _) (hC 2 le_rfl)
refine ⟨2 + |Real.log (Real.log 2)| + (1 + 2 * C) / Real.log 2, fun n hn => ?_⟩
have hn2 : 2 ≤ n := by omega
have hn' : (2:ℝ) ≤ n := by exact_mod_cast hn2
have hln : Real.log 2 ≤ Real.log n := Real.log_le_log (by norm_num) hn'
have hab := ms_abel n hn2
have hD : ∑ k ∈ Finset.Ico 2 n, (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))
= 1 / Real.log 2 - 1 / Real.log n := by
calc _ = ∑ k ∈ Finset.Ico 2 n,
((fun k : ℕ => -(1 / Real.log k)) (k+1) - (fun k : ℕ => -(1 / Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele (fun k : ℕ => -(1 / Real.log k)) n hn2
_ = _ := by push_cast; ring
have hLL : ∑ k ∈ Finset.Ico 2 n,
(Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
= Real.log (Real.log n) - Real.log (Real.log 2) := by
calc _ = ∑ k ∈ Finset.Ico 2 n,
((fun k : ℕ => Real.log (Real.log k)) (k+1) - (fun k : ℕ => Real.log (Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele (fun k : ℕ => Real.log (Real.log k)) n hn2
_ = _ := by push_cast; ring
-- per-term bounds on the Abel sum
have hS_up : ∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) ≤
∑ k ∈ Finset.Ico 2 n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
+ C * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := (Finset.mem_Ico.1 hk).1
obtain ⟨_, h2, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
have hS_lo : ∑ k ∈ Finset.Ico 2 n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
- (1 + C) * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) ≤
∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := (Finset.mem_Ico.1 hk).1
obtain ⟨h1, _, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
rw [Finset.sum_add_distrib, ← Finset.mul_sum, hLL, hD] at hS_up
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, hLL, hD] at hS_lo
-- the boundary term
have hAn := abs_le.1 (hC n hn2)
have hlnpos : 0 < Real.log n := by linarith
have hB1 : (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n ≤ 1 + C / Real.log 2 := by
rw [div_le_iff₀ hlnpos]
have : C / Real.log 2 * Real.log n ≥ C := by
rw [ge_iff_le, div_mul_eq_mul_div, le_div_iff₀ hl2]; nlinarith
nlinarith
have hB2 : 1 - C / Real.log 2 ≤ (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n := by
rw [le_div_iff₀ hlnpos]
have : C / Real.log 2 * Real.log n ≥ C := by
rw [ge_iff_le, div_mul_eq_mul_div, le_div_iff₀ hl2]; nlinarith
nlinarith
have hDle : 1 / Real.log 2 - 1 / Real.log n ≤ 1 / Real.log 2 := by
have : 0 < 1 / Real.log n := by positivity
linarith
have hD0 : 0 ≤ 1 / Real.log 2 - 1 / Real.log n := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hl2 hln
have hCD : C * (1 / Real.log 2 - 1 / Real.log n) ≤ C / Real.log 2 := by
have := mul_le_mul_of_nonneg_left hDle hC0; rw [mul_one_div] at this; exact this
have hCD' : (1 + C) * (1 / Real.log 2 - 1 / Real.log n) ≤ (1 + C) / Real.log 2 := by
have := mul_le_mul_of_nonneg_left hDle (by linarith : (0:ℝ) ≤ 1 + C)
rw [mul_one_div] at this; exact this
have e : (1 + 2 * C) / Real.log 2 = 1 / Real.log 2 + C / Real.log 2 + C / Real.log 2 := by ring
have e' : (1 + C) / Real.log 2 = 1 / Real.log 2 + C / Real.log 2 := by ring
have hll2 := abs_le.1 (le_refl |Real.log (Real.log 2)|)
have h12 : 0 ≤ 1 / Real.log 2 := by positivity
rw [hab, abs_le]; constructor
· nlinarith
· nlinarith
private theorem ms_tele' (F : ℕ → ℝ) (m n : ℕ) (hmn : m ≤ n) :
∑ k ∈ Finset.Ico m n, (F (k+1) - F k) = F n - F m := by
induction n, hmn using Nat.le_induction with
| base => simp
| succ n hn ih => rw [Finset.sum_Ico_succ_top hn, ih]; ring
/-- Mertens' second theorem with the error `O(1 / log m)` on a range `(m, n]`:
`∑_{m < p ≤ n} 1/p = log log n - log log m + O(1 / log m)`. Equivalent to the classical
form `∑_{p ≤ n} 1/p = log log n + M + O(1 / log n)` (it says the left side minus `log log n`
is Cauchy at rate `1 / log m`), and directly gives the dyadic sums `∑_{P/2 < p ≤ P} 1/p`. -/
private theorem u_mertens_second_interval : ∃ C : ℝ, ∀ m n : ℕ, 2 ≤ m → m ≤ n →
|((∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1 : ℝ) / p)
- ∑ p ∈ (Finset.Iic m).filter Nat.Prime, (1 : ℝ) / p)
- (Real.log (Real.log n) - Real.log (Real.log m))| ≤ C / Real.log m := by
obtain ⟨C, hC⟩ := u_mertens_first
have hC0 : 0 ≤ C := le_trans (abs_nonneg _) (hC 2 le_rfl)
refine ⟨3 * C + 1, fun m n hm hmn => ?_⟩
have hn2 : 2 ≤ n := le_trans hm hmn
have hm' : (2:ℝ) ≤ m := by exact_mod_cast hm
have hmn' : (m:ℝ) ≤ n := by exact_mod_cast hmn
have hlm : 0 < Real.log m := Real.log_pos (by linarith)
have hlmn : Real.log m ≤ Real.log n := Real.log_le_log (by linarith) hmn'
have hln : 0 < Real.log n := by linarith
have habn := ms_abel n hn2
have habm := ms_abel m hm
have hsplit := Finset.sum_Ico_consecutive
(fun k : ℕ => (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) hm hmn
have hD : ∑ k ∈ Finset.Ico m n, (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))
= 1 / Real.log m - 1 / Real.log n := by
calc _ = ∑ k ∈ Finset.Ico m n,
((fun k : ℕ => -(1 / Real.log k)) (k+1) - (fun k : ℕ => -(1 / Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele' (fun k : ℕ => -(1 / Real.log k)) m n hmn
_ = _ := by ring
have hLL : ∑ k ∈ Finset.Ico m n,
(Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
= Real.log (Real.log n) - Real.log (Real.log m) := by
calc _ = ∑ k ∈ Finset.Ico m n,
((fun k : ℕ => Real.log (Real.log k)) (k+1) - (fun k : ℕ => Real.log (Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele' (fun k : ℕ => Real.log (Real.log k)) m n hmn
have hS_up : ∑ k ∈ Finset.Ico m n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) ≤
∑ k ∈ Finset.Ico m n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
+ C * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := le_trans hm (Finset.mem_Ico.1 hk).1
obtain ⟨_, h2, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
have hS_lo : ∑ k ∈ Finset.Ico m n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
- (1 + C) * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) ≤
∑ k ∈ Finset.Ico m n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := le_trans hm (Finset.mem_Ico.1 hk).1
obtain ⟨h1, _, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
rw [Finset.sum_add_distrib, ← Finset.mul_sum, hLL, hD] at hS_up
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, hLL, hD] at hS_lo
-- boundary terms: A(j)/log j = 1 + R(j)/log j with |R(j)/log j| ≤ C / log m
have hb : ∀ j : ℕ, m ≤ j →
|(∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) / Real.log j - 1|
≤ C / Real.log m := by
intro j hj
have hj2 : 2 ≤ j := le_trans hm hj
have hlj : Real.log m ≤ Real.log j :=
Real.log_le_log (by linarith) (by exact_mod_cast hj)
have hljpos : 0 < Real.log j := by linarith
have e : (∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) / Real.log j - 1
= ((∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) - Real.log j) / Real.log j := by
field_simp
rw [e, abs_div, abs_of_pos hljpos]
calc _ ≤ C / Real.log j := div_le_div_of_nonneg_right (hC j hj2) hljpos.le
_ ≤ C / Real.log m := div_le_div_of_nonneg_left hC0 hlm hlj
have hbn := abs_le.1 (hb n hmn)
have hbm := abs_le.1 (hb m le_rfl)
have hDle : 1 / Real.log m - 1 / Real.log n ≤ 1 / Real.log m := by
have : 0 < 1 / Real.log n := by positivity
linarith
have hD0 : 0 ≤ 1 / Real.log m - 1 / Real.log n := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hlm hlmn
have hCD : C * (1 / Real.log m - 1 / Real.log n) ≤ C / Real.log m := by
have := mul_le_mul_of_nonneg_left hDle hC0; rw [mul_one_div] at this; exact this
have hCD' : (1 + C) * (1 / Real.log m - 1 / Real.log n) ≤ (1 + C) / Real.log m := by
have := mul_le_mul_of_nonneg_left hDle (by linarith : (0:ℝ) ≤ 1 + C)
rw [mul_one_div] at this; exact this
have e1 : (3 * C + 1) / Real.log m = C / Real.log m + C / Real.log m + (1 + C) / Real.log m := by
ring
have h1m : 0 ≤ C / Real.log m := by positivity
rw [habn, habm, ← hsplit, abs_le]; constructor
· nlinarith
· nlinarith
/-- If at most one cell `(k, ε)` has `p ∣ n + r_{ε,k+K+1}`, the phase `X_p(n)` of (5.13)
is at most `q / 2^(K+1)` in size: the bound (5.36) behind (5.19). -/
private theorem w_X_le {K : ℕ} (q : ℝ) (hq : 0 ≤ q) (H : ℕ) (sgn : (Fin K → Bool) → ℝ)
(hs : ∀ ε, |sgn ε| ≤ 1) (r : (Fin K → Bool) → ℕ → ℤ) (p : ℕ) (n : ℤ)
(huniq : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool,
p ∣ (n + r ε1 (k1 + K + 1)).toNat → p ∣ (n + r ε2 (k2 + K + 1)).toNat → k1 = k2 ∧ ε1 = ε2) :
|q * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1)|
≤ q / 2 ^ (K + 1) := by
rw [abs_mul, abs_of_nonneg hq, div_eq_mul_inv q]
refine mul_le_mul_of_nonneg_left ?_ hq
by_cases hex : ∃ k < H, ∃ ε : Fin K → Bool, p ∣ (n + r ε (k + K + 1)).toNat
· obtain ⟨k0, hk0, ε0, hd0⟩ := hex
have hinner : ∀ k ∈ Finset.range H, k ≠ k0 →
(∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1) = 0 := by
intro k hk hne
rw [div_eq_zero_iff]; left
refine Finset.sum_eq_zero fun ε _ => ?_
rw [if_neg, mul_zero]
intro hd
exact hne (huniq k (Finset.mem_range.mp hk) k0 hk0 ε ε0 hd hd0).1
rw [Finset.sum_eq_single k0 hinner (fun h => absurd (Finset.mem_range.mpr hk0) h)]
have hsingle : ∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k0 + K + 1)).toNat then (1 : ℝ) else 0) = sgn ε0 := by
rw [Finset.sum_eq_single ε0]
· rw [if_pos hd0, mul_one]
· intro ε _ hne
rw [if_neg, mul_zero]
intro hd
exact hne (huniq k0 hk0 k0 hk0 ε ε0 hd hd0).2
· intro h; exact absurd (Finset.mem_univ ε0) h
rw [hsingle, abs_div, abs_of_pos (by positivity : (0 : ℝ) < 2 ^ (k0 + K + 1))]
calc |sgn ε0| / 2 ^ (k0 + K + 1) ≤ 1 / 2 ^ (k0 + K + 1) :=
div_le_div_of_nonneg_right (hs ε0) (by positivity)
_ ≤ 1 / 2 ^ (K + 1) :=
div_le_div_of_nonneg_left zero_le_one (by positivity)
(pow_le_pow_right₀ (by norm_num) (by omega))
_ = (2 ^ (K + 1) : ℝ)⁻¹ := one_div _
· push Not at hex
have hz : ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1) = 0 := by
refine Finset.sum_eq_zero fun k hk => ?_
rw [div_eq_zero_iff]; left
refine Finset.sum_eq_zero fun ε _ => ?_
rw [if_neg (hex k (Finset.mem_range.mp hk) ε), mul_zero]
rw [hz, abs_zero]; positivity
/-- No collisions: if `p` divides none of the differences of two distinct shifts, and the
shifted numbers are positive, at most one cell is divisible by `p`. -/
private theorem w_uniq_of_no_collision {K : ℕ} (H : ℕ) (r : (Fin K → Bool) → ℕ → ℤ) (p : ℕ)
(n : ℤ) (hpos : ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1)) :
∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool,
p ∣ (n + r ε1 (k1 + K + 1)).toNat → p ∣ (n + r ε2 (k2 + K + 1)).toNat → k1 = k2 ∧ ε1 = ε2 := by
intro k1 hk1 k2 hk2 ε1 ε2 hd1 hd2
by_contra hne
rw [not_and_or] at hne
apply hcoll k1 hk1 k2 hk2 ε1 ε2 hne
have e1 : (p : ℤ) ∣ n + r ε1 (k1 + K + 1) := by
have := Int.natCast_dvd_natCast.mpr hd1
rwa [Int.toNat_of_nonneg (hpos ε1 k1 hk1).le] at this
have e2 : (p : ℤ) ∣ n + r ε2 (k2 + K + 1) := by
have := Int.natCast_dvd_natCast.mpr hd2
rwa [Int.toNat_of_nonneg (hpos ε2 k2 hk2).le] at this
have := dvd_sub e1 e2
rwa [add_sub_add_left_eq_sub] at this
/-- (5.19) from the set-up, in the exact shapes of T's hole: if no prime of `S1` divides a
difference of two distinct shifts (S1 avoids the discriminant), and `q / 2^(K+1) ≤ δ`, then
`|X_p(n)| ≤ δ` on `S1 × Ns`. -/
private theorem w_5_19 (q : ℕ) (δ : ℝ) (K H : ℕ) (Ns : Finset ℤ) (S1 : Finset ℕ)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hK : (q : ℝ) / 2 ^ (K + 1) ≤ δ) :
∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ := by
intro p hp n hn
have hs : ∀ ε, |sgn ε| ≤ 1 := by
intro ε
rw [hsgn ε, Finset.abs_prod]
refine le_of_eq (Finset.prod_eq_one fun i _ => ?_)
split_ifs <;> norm_num
rw [hX p n]
exact (w_X_le (q : ℝ) (Nat.cast_nonneg q) H sgn hs r p n
(w_uniq_of_no_collision H r p n (fun ε k hk => hpos n hn ε k hk) (hcoll p hp))).trans hK
/-- A sum with at most one nonzero term squares termwise. -/
private theorem w_sq_sum_of_single {ι : Type*} (s : Finset ι) (f : ι → ℝ)
(h : ∀ i ∈ s, ∀ j ∈ s, f i ≠ 0 → f j ≠ 0 → i = j) :
(∑ i ∈ s, f i) ^ 2 = ∑ i ∈ s, f i ^ 2 := by
by_cases hex : ∃ i ∈ s, f i ≠ 0
· obtain ⟨i0, hi0, hf0⟩ := hex
have hz : ∀ j ∈ s, j ≠ i0 → f j = 0 := fun j hj hne => by
by_contra hfj; exact hne (h j hj i0 hi0 hfj hf0)
rw [Finset.sum_eq_single i0 hz (fun h' => absurd hi0 h'),
Finset.sum_eq_single i0 (fun j hj hne => by rw [hz j hj hne]; ring) (fun h' => absurd hi0 h')]
· push Not at hex
rw [Finset.sum_eq_zero hex, Finset.sum_eq_zero fun i hi => by rw [hex i hi]; ring]
ring
/-- `Σ_ε (-1)^{|ε|} = 0` for `K ≥ 1`. -/
private theorem w_sum_sgn_eq_zero {K : ℕ} (hK : 1 ≤ K) (sgn : (Fin K → Bool) → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1) :
∑ ε : Fin K → Bool, sgn ε = 0 := by
simp_rw [hsgn]
rw [← Fintype.piFinset_univ, ← Finset.prod_univ_sum (fun _ : Fin K => (Finset.univ : Finset Bool))
(fun _ b => if b then (-1 : ℝ) else 1)]
exact Finset.prod_eq_zero (Finset.mem_univ ⟨0, hK⟩) (by simp)
/-- S8h with the paper's approximate equidistribution (5.35): if every residue class mod `p`
holds `#Ns/p` points of `Ns` up to a relative error `η ≤ 1`, then
`Var X_p ≥ (1 − η) q²/(2^(K+2) p) − (η q / p)²`. -/
private theorem w_var_lower_approx (q : ℕ) (K H : ℕ) (hK : 1 ≤ K) (hH : 1 ≤ H) (Ns : Finset ℤ)
(hNs : Ns.Nonempty) (p : ℕ) (hp : 0 < p) (η : ℝ) (hη : 0 ≤ η) (hη1 : η ≤ 1)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hequi : ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card) :
(1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p)) - (η * q / p) ^ 2 ≤
(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ 2 - ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ 2 := by
set C := Finset.range H ×ˢ (Finset.univ : Finset (Fin K → Bool)) with hC
set a : ℕ × (Fin K → Bool) → ℝ := fun c => (q : ℝ) * sgn c.2 / 2 ^ (c.1 + K + 1) with ha
set ind : ℤ → ℕ × (Fin K → Bool) → ℝ :=
fun n c => if (p : ℤ) ∣ n + r c.2 (c.1 + K + 1) then 1 else 0 with hind
set N : ℝ := (Ns.card : ℝ) with hN
have hNpos : 0 < N := by rw [hN]; exact_mod_cast hNs.card_pos
have hpR : (0 : ℝ) < p := by exact_mod_cast hp
have hdv : ∀ z : ℤ, 0 ≤ z → (p ∣ z.toNat ↔ (p : ℤ) ∣ z) := fun z hz => by
rw [← Int.natCast_dvd_natCast, Int.toNat_of_nonneg hz]
have hXc : ∀ n ∈ Ns, X p n = ∑ c ∈ C, a c * ind n c := by
intro n hn
rw [hX, hC, Finset.sum_product, Finset.mul_sum]
refine Finset.sum_congr rfl fun k hk => ?_
rw [Finset.sum_div, Finset.mul_sum]
refine Finset.sum_congr rfl fun ε _ => ?_
have hz := (hpos n hn ε k (Finset.mem_range.mp hk)).le
simp only [ha, hind]
by_cases h : (p : ℤ) ∣ n + r ε (k + K + 1)
· rw [if_pos h, if_pos ((hdv _ hz).mpr h)]; ring
· rw [if_neg h, if_neg (fun h' => h ((hdv _ hz).mp h'))]; ring
have hcnt : ∀ c : ℕ × (Fin K → Bool), |(∑ n ∈ Ns, ind n c) - N / p| ≤ η * N / p := by
intro c
have h := hequi (r c.2 (c.1 + K + 1))
have hs : ∑ n ∈ Ns, ind n c = ((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) := by
simp only [hind]; rw [Finset.sum_boole]
rw [hs]
have e : ((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) - N / p
= (((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) * p - N) / p := by
field_simp
rw [e, abs_div, abs_of_pos hpR]
exact div_le_div_of_nonneg_right h hpR.le
have hsq : ∀ n ∈ Ns, X p n ^ 2 = ∑ c ∈ C, a c ^ 2 * ind n c := by
intro n hn
rw [hXc n hn, w_sq_sum_of_single]
· refine Finset.sum_congr rfl fun c _ => ?_
simp only [hind]; split_ifs <;> ring
· intro c hc c' hc' h1 h2
have d1 : (p : ℤ) ∣ n + r c.2 (c.1 + K + 1) := by
by_contra h; apply h1; simp only [hind, if_neg h, mul_zero]
have d2 : (p : ℤ) ∣ n + r c'.2 (c'.1 + K + 1) := by
by_contra h; apply h2; simp only [hind, if_neg h, mul_zero]
by_contra hne
have hor : c.1 ≠ c'.1 ∨ c.2 ≠ c'.2 := by
by_contra h; push Not at h; exact hne (Prod.ext h.1 h.2)
rw [hC, Finset.mem_product] at hc hc'
apply hcoll c.1 (Finset.mem_range.mp hc.1) c'.1 (Finset.mem_range.mp hc'.1) c.2 c'.2 hor
have := dvd_sub d1 d2
rwa [add_sub_add_left_eq_sub] at this
-- Σ_c a c = 0 and Σ_c |a c| ≤ q
have hsuma : ∑ c ∈ C, a c = 0 := by
rw [hC, Finset.sum_product]
refine Finset.sum_eq_zero fun k _ => ?_
simp only [ha]
rw [← Finset.sum_div, ← Finset.mul_sum, w_sum_sgn_eq_zero hK sgn hsgn]; ring
have habs : ∑ c ∈ C, |a c| ≤ q := by
have hs1 : ∀ ε : Fin K → Bool, |sgn ε| = 1 := by
intro ε; rw [hsgn ε, Finset.abs_prod]
exact Finset.prod_eq_one fun i _ => by split_ifs <;> norm_num
rw [hC, Finset.sum_product]
simp only [ha, abs_div, abs_mul, hs1, Nat.abs_cast, mul_one, abs_pow, abs_two]
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Fintype.card_fun,
Fintype.card_bool, Fintype.card_fin]
have hk : ∀ k ∈ Finset.range H, ((2 ^ K : ℕ) : ℝ) * ((q : ℝ) / 2 ^ (k + K + 1))
= (q : ℝ) * ((1 / 2) * (1 / 2) ^ k) := by
intro k _; push_cast; rw [pow_add, pow_add]; field_simp
rw [mul_assoc, ← mul_pow]; norm_num
rw [Finset.sum_congr rfl hk, ← Finset.mul_sum, ← Finset.mul_sum]
have hg := sum_geometric_two_le H
have hq0 : (0 : ℝ) ≤ q := Nat.cast_nonneg q
nlinarith
have hmean : |(N)⁻¹ * ∑ n ∈ Ns, X p n| ≤ η * q / p := by
rw [Finset.sum_congr rfl hXc, Finset.sum_comm]
simp_rw [← Finset.mul_sum]
have e : ∑ c ∈ C, a c * ∑ n ∈ Ns, ind n c = ∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p) := by
simp_rw [mul_sub]; rw [Finset.sum_sub_distrib, ← Finset.sum_mul, hsuma]; ring
rw [e, abs_mul, abs_inv, abs_of_pos hNpos]
have hb : |∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p)| ≤ q * (η * N / p) := by
refine (Finset.abs_sum_le_sum_abs _ _).trans ?_
calc ∑ c ∈ C, |a c * ((∑ n ∈ Ns, ind n c) - N / p)|
≤ ∑ c ∈ C, |a c| * (η * N / p) := Finset.sum_le_sum fun c _ => by
rw [abs_mul]; exact mul_le_mul_of_nonneg_left (hcnt c) (abs_nonneg _)
_ = (∑ c ∈ C, |a c|) * (η * N / p) := by rw [Finset.sum_mul]
_ ≤ q * (η * N / p) := mul_le_mul_of_nonneg_right habs (by positivity)
calc N⁻¹ * |∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p)| ≤ N⁻¹ * (q * (η * N / p)) :=
mul_le_mul_of_nonneg_left hb (by positivity)
_ = η * q / p := by field_simp
have hsecond : (1 - η) * (N / p) * ∑ c ∈ C, a c ^ 2 ≤ ∑ n ∈ Ns, X p n ^ 2 := by
rw [Finset.sum_congr rfl hsq, Finset.sum_comm]
simp_rw [← Finset.mul_sum]
rw [Finset.mul_sum]
refine Finset.sum_le_sum fun c _ => ?_
have h := hcnt c
rw [abs_le] at h
have : (1 - η) * (N / p) ≤ ∑ n ∈ Ns, ind n c := by
have : (1 - η) * (N / p) = N / p - η * N / p := by ring
linarith [h.1]
nlinarith [sq_nonneg (a c)]
have hlow : (q : ℝ) ^ 2 / 2 ^ (K + 2) ≤ ∑ c ∈ C, a c ^ 2 := by
have hsub : ({0} : Finset ℕ) ×ˢ (Finset.univ : Finset (Fin K → Bool)) ⊆ C := by
rw [hC]; exact Finset.product_subset_product_left
(Finset.singleton_subset_iff.mpr (Finset.mem_range.mpr hH))
refine le_trans (le_of_eq ?_) (Finset.sum_le_sum_of_subset_of_nonneg hsub
fun c _ _ => sq_nonneg _)
rw [Finset.sum_product, Finset.sum_singleton]
have hs2 : ∀ ε : Fin K → Bool, sgn ε ^ 2 = 1 := by
intro ε
rw [hsgn ε, ← Finset.prod_pow]
exact Finset.prod_eq_one fun i _ => by split_ifs <;> norm_num
simp only [ha, div_pow, mul_pow, hs2, mul_one]
rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
simp only [Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, zero_add]
push_cast
rw [pow_succ 2 (K + 1), pow_succ 2 K]
field_simp
have hEX2 : (1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p)) ≤ N⁻¹ * ∑ n ∈ Ns, X p n ^ 2 := by
have h1 : (1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p))
= N⁻¹ * ((1 - η) * (N / p) * ((q : ℝ) ^ 2 / 2 ^ (K + 2))) := by
field_simp
rw [h1]
refine mul_le_mul_of_nonneg_left (le_trans ?_ hsecond) (by positivity)
exact mul_le_mul_of_nonneg_left hlow (mul_nonneg (by linarith) (by positivity))
have hEX : (N⁻¹ * ∑ n ∈ Ns, X p n) ^ 2 ≤ (η * q / p) ^ 2 := by
rw [← sq_abs]
exact pow_le_pow_left₀ (abs_nonneg _) hmean 2
linarith
/-- (5.21) from the set-up: summing `w_var_lower_approx` over `S1`. If every `p ∈ S1` avoids the
shifts' discriminant and `n` is equidistributed mod `p` up to relative error `η ≤ 1`, then
`Σ_{S1} Var X_p ≥ (1-η) q²/2^(K+2) Σ_{S1} 1/p − η² q² Σ_{S1} 1/p²`; the hole's `c0 ≤ Σ Var`
follows as soon as the right side is `≥ c0` (by Mertens, `Σ_{S1} 1/p ≍ log₂ R − log₂ W`). -/
private theorem w_5_21 (q : ℕ) (K H : ℕ) (hK : 1 ≤ K) (hH : 1 ≤ H) (Ns : Finset ℤ)
(hNs : Ns.Nonempty) (S1 : Finset ℕ) (hS1 : ∀ p ∈ S1, 0 < p) (η : ℝ) (hη : 0 ≤ η)
(hη1 : η ≤ 1) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hequi : ∀ p ∈ S1, ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card) (c0 : ℝ)
(hc0 : c0 ≤ (1 - η) * ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * ∑ p ∈ S1, (1 : ℝ) / p
- η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / p ^ 2) :
c0 ≤ ∑ p ∈ S1, ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ 2
- ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ 2) := by
refine hc0.trans ?_
rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib]
refine Finset.sum_le_sum fun p hp => le_trans (le_of_eq ?_)
(w_var_lower_approx q K H hK hH Ns hNs p (hS1 p hp) η hη hη1 sgn r X hsgn hX hpos
(hcoll p hp) (hequi p hp))
have : (0 : ℝ) < p := by exact_mod_cast hS1 p hp
field_simp
/-- One vertex of κ₁ (§5.7): if `m n ε` is equidistributed mod `P ε` on `Ns` up to a factor
`1 + η`, the average of `Σ_k 1[P² ∣ P m + P (k+1)] / 2^(k+1)` is at most `(1 + η)/P`. -/
private theorem w_kappa1_eps (Ns : Finset ℤ) (P : ℕ) (hP : 0 < P) (m : ℤ → ℕ) (η : ℝ)
(hequi : ∀ a : ℕ, ((Ns.filter fun n => P ∣ m n + a).card : ℝ) * P ≤ (1 + η) * Ns.card) :
∑ n ∈ Ns, ∑' k : ℕ, (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P := by
have hdv : ∀ n (k : ℕ), (P ^ 2 ∣ P * m n + P * (k + 1) ↔ P ∣ m n + (k + 1)) := by
intro n k
rw [pow_two, ← mul_add]
exact Nat.mul_dvd_mul_iff_left hP
have hsum : ∀ n ∈ Ns, Summable fun k : ℕ =>
(if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1) := by
intro n _
refine Summable.of_nonneg_of_le (fun k => by positivity) (fun k => ?_)
((summable_geometric_two).mul_left (1 / 2))
have : (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) ≤ 1 := by split_ifs <;> norm_num
calc (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ 1 / 2 ^ (k + 1) := div_le_div_of_nonneg_right this (by positivity)
_ = 1 / 2 * (1 / 2) ^ k := by
rw [pow_succ]; field_simp; rw [← mul_pow]; norm_num
rw [← Summable.tsum_finsetSum hsum]
have hPR : (0 : ℝ) < P := by exact_mod_cast hP
have hterm : ∀ k : ℕ, ∑ n ∈ Ns,
(if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) := by
intro k
rw [← Finset.sum_div]
simp_rw [hdv]
rw [Finset.sum_boole]
have h := hequi (k + 1)
have : ((Ns.filter fun n => P ∣ m n + (k + 1)).card : ℝ) ≤ (1 + η) * Ns.card / P := by
rw [le_div_iff₀ hPR]; exact_mod_cast h
calc ((Ns.filter fun n => P ∣ m n + (k + 1)).card : ℝ) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P / 2 ^ (k + 1) := div_le_div_of_nonneg_right this (by positivity)
_ = (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) := by
rw [pow_succ]; field_simp; rw [mul_assoc, ← mul_pow]; norm_num
have hS : Summable fun k : ℕ => (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) :=
((summable_geometric_two).mul_left (1 / 2)).mul_left _
refine (Summable.tsum_le_tsum hterm (summable_sum fun n hn => hsum n hn) hS).trans (le_of_eq ?_)
rw [tsum_mul_left, tsum_mul_left, tsum_geometric_two]; ring
/-- κ₁ of (5.10), T's exact conjunct: with `m n ε` equidistributed mod `P ε` up to `1 + η` for
every vertex `ε`, `κ₁ ≤ Σ_ε (1 + η)/P_ε` (≤ 2^K (1+η) / min P_ε, which is `o(1)` since
`P_ε ≥ P/2` and `2^K ≈ (log₃ x)²`). -/
private theorem w_kappa1 {K : ℕ} (Ns : Finset ℤ) (P : (Fin K → Bool) → ℕ) (hP : ∀ ε, 0 < P ε)
(m : ℤ → (Fin K → Bool) → ℕ) (η : ℝ) (hη : 0 ≤ η)
(hequi : ∀ ε, ∀ a : ℕ, ((Ns.filter fun n => P ε ∣ m n ε + a).card : ℝ) * P ε
≤ (1 + η) * Ns.card) :
(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, ∑' k : ℕ,
(if P ε ^ 2 ∣ P ε * m n ε + P ε * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ ∑ ε : Fin K → Bool, (1 + η) / P ε := by
rcases Ns.eq_empty_or_nonempty with h | hne
· subst h; simp only [Finset.card_empty, Nat.cast_zero, inv_zero, zero_mul]
exact Finset.sum_nonneg fun ε _ => div_nonneg (by linarith) (Nat.cast_nonneg _)
have hN : (0 : ℝ) < Ns.card := by exact_mod_cast hne.card_pos
rw [Finset.sum_comm, Finset.mul_sum]
refine Finset.sum_le_sum fun ε _ => ?_
have := w_kappa1_eps Ns (P ε) (hP ε) (fun n => m n ε) η (hequi ε)
calc (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' k : ℕ,
(if P ε ^ 2 ∣ P ε * m n ε + P ε * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (Ns.card : ℝ)⁻¹ * ((1 + η) * Ns.card / P ε) :=
mul_le_mul_of_nonneg_left this (by positivity)
_ = (1 + η) / P ε := by field_simp
/-- `X_p(n)` depends on `n` only through `n mod p` (for positive shifted values). -/
private theorem w_X_congr {K : ℕ} (q H : ℕ) (sgn : (Fin K → Bool) → ℝ)
(r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(p : ℕ) (n n' : ℤ) (hn : ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hn' : ∀ ε, ∀ k < H, 0 < n' + r ε (k + K + 1)) (hpn : (p : ℤ) ∣ n - n') :
X p n = X p n' := by
have hdv : ∀ z : ℤ, 0 ≤ z → (p ∣ z.toNat ↔ (p : ℤ) ∣ z) := fun z hz => by
rw [← Int.natCast_dvd_natCast, Int.toNat_of_nonneg hz]
rw [hX, hX]
congr 1
refine Finset.sum_congr rfl fun k hk => ?_
congr 1
refine Finset.sum_congr rfl fun ε _ => ?_
have hk' := Finset.mem_range.mp hk
have e : (p ∣ (n + r ε (k + K + 1)).toNat) ↔ (p ∣ (n' + r ε (k + K + 1)).toNat) := by
rw [hdv _ (hn ε k hk').le, hdv _ (hn' ε k hk').le]
constructor
· intro h
have := dvd_sub h hpn
rwa [show n + r ε (k + K + 1) - (n - n') = n' + r ε (k + K + 1) by ring] at this
· intro h
have := dvd_add h hpn
rwa [show n' + r ε (k + K + 1) + (n - n') = n + r ε (k + K + 1) by ring] at this
by_cases h : p ∣ (n + r ε (k + K + 1)).toNat
· rw [if_pos h, if_pos (e.mp h)]
· rw [if_neg h, if_neg (fun h' => h (e.mpr h'))]
/-- The `S₀` conjunct of T's hole (§5.6, (5.33)): if `Ns` lies in one residue class modulo
every prime `p ≤ B` outside `S1 ∪ S2` (the paper takes `n ≡ 0 mod W♭` and fixes `n mod p_ε`
by (5.5)), then `X_p` is constant on `Ns` for those `p`. -/
private theorem w_S0 {K : ℕ} (q H B : ℕ) (Ns : Finset ℤ) (S1 S2 : Finset ℕ)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcls : ∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, (p : ℤ) ∣ n - n') :
∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n' :=
fun p hp h1 h2 n hn n' hn' => w_X_congr q H sgn r X hX p n n' (hpos n hn) (hpos n' hn')
(hcls p hp h1 h2 n hn n' hn')
/-- `∑_{p ∈ S} 1/p² ≤ 1` for any finite set of integers `≥ 2` (from Mathlib's `sum_Ioo_inv_sq_le`). -/
private theorem f2_sum_inv_sq_le_one (S : Finset ℕ) (hS : ∀ p ∈ S, 2 ≤ p) :
∑ p ∈ S, (1 : ℝ) / (p : ℝ) ^ 2 ≤ 1 := by
have hsub : S ⊆ Finset.Ioo 1 (S.sup id + 1) := by
intro p hp
have h2 := hS p hp
have hle : p ≤ S.sup id := Finset.le_sup (f := id) hp
simp only [Finset.mem_Ioo]; omega
calc ∑ p ∈ S, (1 : ℝ) / (p : ℝ) ^ 2 = ∑ p ∈ S, ((p : ℝ) ^ 2)⁻¹ := by
simp only [one_div]
_ ≤ ∑ p ∈ Finset.Ioo 1 (S.sup id + 1), ((p : ℝ) ^ 2)⁻¹ :=
Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity)
_ ≤ 2 / ((1 : ℕ) + 1 : ℝ) := sum_Ioo_inv_sq_le 1 _
_ = 1 := by norm_num
/-- The primes of `(w, R]` as a difference of two `Iic` sums. -/
private theorem f2_sum_Ioc (f : ℕ → ℝ) (w R : ℕ) (h : w ≤ R) :
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime, f p
= ∑ p ∈ (Finset.Iic R).filter Nat.Prime, f p - ∑ p ∈ (Finset.Iic w).filter Nat.Prime, f p := by
have hsub : (Finset.Iic w).filter Nat.Prime ⊆ (Finset.Iic R).filter Nat.Prime := by
intro x hx
simp only [Finset.mem_filter, Finset.mem_Iic] at hx ⊢
exact ⟨hx.1.trans h, hx.2⟩
have heq : (Finset.Ioc w R).filter Nat.Prime
= (Finset.Iic R).filter Nat.Prime \ (Finset.Iic w).filter Nat.Prime := by
ext x
simp only [Finset.mem_filter, Finset.mem_Ioc, Finset.mem_Iic, Finset.mem_sdiff]
constructor
· rintro ⟨⟨h1, h2⟩, hp⟩
exact ⟨⟨h2, hp⟩, fun h3 => by omega⟩
· rintro ⟨⟨h2, hp⟩, h3⟩
refine ⟨⟨?_, h2⟩, hp⟩
by_contra h4
exact h3 ⟨by omega, hp⟩
rw [heq, ← Finset.sum_sdiff hsub]
ring
/-- `S1` keeps all but a reciprocal mass `≤ 1` of the primes of `(w, R]`. -/
private theorem f2_S1_lower (S1 : Finset ℕ) (w R : ℕ)
(hmiss : ∑ p ∈ (Finset.Ioc w R).filter Nat.Prime \ S1, (1 : ℝ) / p ≤ 1) :
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime, (1 : ℝ) / p - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p := by
set A := (Finset.Ioc w R).filter Nat.Prime
have h1 : ∑ p ∈ A, (1 : ℝ) / p ≤ ∑ p ∈ (A \ S1) ∪ S1, (1 : ℝ) / p :=
Finset.sum_le_sum_of_subset_of_nonneg (fun x hx => by
by_cases hxs : x ∈ S1
· exact Finset.mem_union_right _ hxs
· exact Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨hx, hxs⟩))
(fun _ _ _ => by positivity)
rw [Finset.sum_union Finset.sdiff_disjoint] at h1
linarith
/-- Mertens' second theorem on `S1` gives the variance conjunct: with `c0 = q²/8`. -/
private theorem f2_c0 (q K : ℕ) (S1 : Finset ℕ) (hS1 : ∀ p ∈ S1, 2 ≤ p) (η : ℝ)
(hη0 : 0 ≤ η) (hη : η ≤ 1 / 4) (C : ℝ) (hC : 0 ≤ C)
(hs : (2 : ℝ) ^ K * (C + 2) - C - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p) :
(q : ℝ) ^ 2 / 8 ≤ (1 - η) * ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * ∑ p ∈ S1, (1 : ℝ) / p
- η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / p ^ 2 := by
have hsq := f2_sum_inv_sq_le_one S1 hS1
have hsq0 : 0 ≤ ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 := Finset.sum_nonneg (fun _ _ => by positivity)
have h2K : (1 : ℝ) ≤ 2 ^ K := one_le_pow₀ (by norm_num)
set S := ∑ p ∈ S1, (1 : ℝ) / p
have hS : (2 : ℝ) ^ K ≤ S := by nlinarith
have hq0 : 0 ≤ (q : ℝ) ^ 2 := sq_nonneg _
have hpos : (0 : ℝ) < 2 ^ (K + 2) := by positivity
have hA : (q : ℝ) ^ 2 / 4 ≤ ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * S := by
rw [div_mul_eq_mul_div, le_div_iff₀ hpos, pow_add]
nlinarith
have hB : η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 ≤ (q : ℝ) ^ 2 / 16 := by
have : η ^ 2 ≤ 1 / 16 := by nlinarith
calc η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 ≤ η ^ 2 * (q : ℝ) ^ 2 * 1 :=
mul_le_mul_of_nonneg_left hsq (by positivity)
_ ≤ 1 / 16 * (q : ℝ) ^ 2 * 1 := by gcongr
_ = (q : ℝ) ^ 2 / 16 := by ring
have hC' : 0 ≤ ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * S := by positivity
nlinarith
/-- `log w ≥ 1` once `w ≥ 3`. -/
private theorem f2_one_le_log (w : ℕ) (hw : 3 ≤ w) : 1 ≤ Real.log w := by
have h3 : (3 : ℝ) ≤ w := by exact_mod_cast hw
rw [Real.le_log_iff_exp_le (by linarith)]
linarith [Real.exp_one_lt_d9]
theorem variant_6b364d2b__h1 : ∀ (q : ℕ),
(0 : ℕ) < q →
∃ (c0 : ℝ),
(0 : ℝ) < c0 ∧
∀ (δ : ℝ),
(0 : ℝ) < δ →
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m :
ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r :
(Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ),
(∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧
(∀ (ε : Fin K → Bool) (h : ℕ),
r ε h =
p0 * (↑h : ℤ) +
∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧
(∀ (p : ℕ) (n : ℤ),
X p n =
(↑q : ℝ) *
∑ k ∈ Finset.range H,
(∑ ε : Fin K → Bool,
sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) /
(2 : ℝ) ^ (k + K + (1 : ℕ))) ∧
Even M ∧
(∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧
(∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧
Ns.Nonempty ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
(n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) =
(↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
∀ k < H,
(0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧
S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
Disjoint S1 S2 ∧
(∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),
p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧
(∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑ ε : Fin K → Bool,
∑' (k : ℕ),
(if P ε ^ (2 : ℕ) ∣ P ε * m n ε + P ε * (k + (1 : ℕ)) then (1 : ℝ)
else (0 : ℝ)) /
(2 : ℝ) ^ (k + (1 : ℕ)) ≤
δ ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑' (k : ℕ),
(∑ ε : Fin K → Bool,
(↑((ArithmeticFunction.cardDistinctFactors : ℕ → ℕ)
(n + r ε (k + H + K + (1 : ℕ))).toNat) :
ℝ)) /
(2 : ℝ) ^ (k + H + K + (1 : ℕ)) ≤
δ ∧
√((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ (2 : ℕ)) ≤ δ ∧
∑ j ∈ Finset.range (M + (1 : ℕ)),
((2 : ℝ) * Real.pi) ^ j / (↑j.factorial : ℝ) *
|(↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j -
(↑(Fintype.piFinset fun (x : ↥S1) => Ns).card : ℝ)⁻¹ *
∑ ω ∈ Fintype.piFinset fun (x : ↥S1) => Ns,
(∑ p : ↥S1, X (↑p : ℕ) (ω p)) ^ j| ≤
δ ∧
(∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
((2 : ℝ) * Real.pi * Real.exp (1 : ℝ) * X p n) +
∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
(-((2 : ℝ) * Real.pi * Real.exp (1 : ℝ)) * X p n)) /
Real.exp (1 : ℝ) ^ M ≤
δ ∧
c0 ≤
∑ p ∈ S1,
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ (2 : ℕ) -
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ (2 : ℕ)) := by
-- approach: Tao–Teräväinen §§5.5–5.11 in Lean: Lemma 5.2 and Mertens proved; κ₁, (5.19), S₀, variance from the set-up; κ₂–κ₅ left
-- licence: CC-BY-4.0
-- label: Tao–Teräväinen §§5.6–5.14: κ₂–κ₅ for each Lemma 5.2 cube
-- claim: $\forall q \ge 1,\ T,\ \delta > 0,\ P_0\ \ \exists P \ge P_0,\ 2^K \le (\log P)^{2/3},\ H \le (\log P)^{2/3}\ \ \forall (p_0, v)\ \ \exists (N_s, S_1, S_2, M, \eta, w, R):\ \kappa_2, \kappa_3, \kappa_4, \kappa_5 \le \delta,\ \sum_{\varepsilon} \frac{1+\eta}{p_\varepsilon} \le \delta,\ \frac{q}{2^{K+1}} \le \delta,\ 2^K T \le \log\log R - \log\log w$
-- What is left of Tao–Teräväinen Theorem 5.1 (arXiv:2512.01739v2, p. 49) once the set-up is fixed:
-- for every prime cube that Lemma 5.2 produces in (P/2, P], a random n (uniform on Ns) obeying
-- (5.5)-(5.6) and (5.33), the prime split S₀/S₁/S₂ of §5.6 (S₁ avoids the discriminant of the near
-- shifts), equidistribution (5.35) mod each p_ε and each p ∈ S₁ up to η, and the estimates
-- κ₂ (§5.8), κ₃ (§§5.12-5.14, the paper's use of its Theorem 3.1(i)), κ₄ (§5.9), κ₅ (§5.10).
-- The parameter clause 2^K T ≤ log log R - log log w is §5.11's (log₂R - log₂W)/2^K → ∞.
-- Proved here, not in the hole: Lemma 5.2 (quantitative; Aristotle for t1023-f2, from t1022-s's
-- and t1022-x's projects), Mertens' second theorem on S₁ (t1022-u), κ₁ (§5.7), (5.19), S₀ and the
-- variance step (t1022-w's reduction), and the exact variance bound c₀ = q²/8 (t1023-f2).
have tt_sec5_setup : ∀ q : ℕ, 0 < q → ∀ T : ℝ, ∀ δ : ℝ, 0 < δ → ∀ P0 : ℕ,
∃ (Pw K H : ℕ), P0 ≤ Pw ∧ 1 ≤ K ∧ 1 ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧
(H : ℝ) ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧
∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ),
(∀ ε : Fin K → Bool, Nat.Prime (P ε) ∧ Pw < 2 * P ε ∧ P ε ≤ Pw ∧
(P ε : ℤ) = p0 + ∑ k, if ε k then v k else 0) →
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) →
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) →
∃ (B : ℕ) (Ns : Finset ℤ)
(m : ℤ → (Fin K → Bool) → ℕ) (S1 S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ)
(r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w R : ℕ),
((∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1) ∧
(∀ ε (h : ℕ), r ε h = p0 * h + ∑ k : Fin K, ((h : ℤ) - (k.1 + 1)) * (if ε k then v k else 0)) ∧
(∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1)) ∧
Even M) ∧
(Ns.Nonempty ∧
(∀ n ∈ Ns, ∀ ε, n - ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε k then v k else 0) = P ε * m n ε) ∧
(∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) ∧ n + r ε (k + K + 1) ≤ B)) ∧
(S1 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧ S2 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧
Disjoint S1 S2 ∧
(∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, (p : ℤ) ∣ n - n') ∧
(∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))) ∧
(0 ≤ η ∧ η ≤ 1 / 4 ∧
(∀ ε, ∀ a : ℕ, ((Ns.filter fun n => P ε ∣ m n ε + a).card : ℝ) * P ε ≤ (1 + η) * Ns.card) ∧
(∀ p ∈ S1, ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card)) ∧
((q : ℝ) / 2 ^ (K + 1) ≤ δ ∧ ∑ ε : Fin K → Bool, (1 + η) / P ε ≤ δ) ∧
((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' k : ℕ, (∑ ε : Fin K → Bool,
(ArithmeticFunction.cardDistinctFactors (n + r ε (k + H + K + 1)).toNat : ℝ))
/ 2 ^ (k + H + K + 1) ≤ δ ∧
Real.sqrt ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ 2) ≤ δ ∧
∑ j ∈ Finset.range (M + 1), (2 * Real.pi) ^ j / j.factorial
* |(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j
- ((Fintype.piFinset (fun _ : S1 => Ns)).card : ℝ)⁻¹
* ∑ ω ∈ Fintype.piFinset (fun _ : S1 => Ns), (∑ p : S1, X p (ω p)) ^ j| ≤ δ ∧
(∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp (2 * Real.pi * Real.exp 1 * X p n)
+ ∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns,
Real.exp (-(2 * Real.pi * Real.exp 1) * X p n)) / Real.exp 1 ^ M ≤ δ) ∧
(3 ≤ w ∧ w ≤ R ∧
(2 : ℝ) ^ K * T ≤ Real.log (Real.log R) - Real.log (Real.log w) ∧
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime \ S1, (1 : ℝ) / p ≤ 1) := sorry
obtain ⟨C, hC⟩ := u_mertens_second_interval
have hC0 : 0 ≤ C := by
have h := (abs_nonneg _).trans (hC 2 2 le_rfl le_rfl)
have hl : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num)
by_contra hneg
have : C / Real.log 2 < 0 := div_neg_of_neg_of_pos (lt_of_not_ge hneg) hl
linarith
intro q hq
refine ⟨(q : ℝ) ^ 2 / 8, by positivity, fun δ hδ => ?_⟩
-- Tao–Teräväinen Lemma 5.2 (quantitative), proved above: a prime cube in `(Pw/2, Pw]`.
obtain ⟨P0, hP0⟩ := a52_hilbert_cube_primes_quant_two_thirds
obtain ⟨Pw, K, H, hPw, hK1, hH1, hK23, hH23, hrest⟩ := tt_sec5_setup q hq (C + 2) δ hδ P0
obtain ⟨p0, v, hcube, hinj1, hinj2⟩ := hP0 Pw hPw K H hK23 hH23
choose P hPc using hcube
have hP : ∀ ε, (P ε : ℤ) = p0 + ∑ k : Fin K, (if ε k then v k else 0) := fun ε => (hPc ε).2.2.2
have hpr : ∀ ε, (P ε).Prime := fun ε => (hPc ε).1
obtain ⟨B, Ns, m, S1, S2, sgn, r, X, M, η, w, R, ⟨hsgn, hr, hX, hM⟩, ⟨hNs, hm, hrange⟩,
⟨hS1, hS2, hdisj, hcls, hcoll⟩, ⟨hη0, hη14, hequiP, hequi⟩, ⟨hKq, hk1s⟩, ⟨hk2, hk3, hk4, hk5⟩,
⟨hw3, hwR, hT, hmiss⟩⟩ := hrest p0 v P hPc hinj1 hinj2
have hη1 : η ≤ 1 := by linarith
have hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) :=
fun n hn ε k hk => (hrange n hn ε k hk).1
have hS1p : ∀ p ∈ S1, Nat.Prime p := fun p hp => (Finset.mem_filter.mp (hS1 hp)).2
-- Mertens' second theorem on `(w, R]`, then on `S1`.
have hlogw := f2_one_le_log w hw3
have hmert := hC w R (by omega) hwR
rw [abs_le] at hmert
have hCw : C / Real.log w ≤ C := div_le_self hC0 hlogw
have hIoc := f2_sum_Ioc (fun p => (1 : ℝ) / p) w R hwR
have hlow := f2_S1_lower S1 w R hmiss
have hs : (2 : ℝ) ^ K * (C + 2) - C - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p := by
linarith [hmert.1]
have hc0' := f2_c0 q K S1 (fun p hp => (hS1p p hp).two_le) η hη0 hη14 C hC0 hs
refine ⟨K, p0, v, P, H, B, Ns, m, S1, S2, sgn, r, X, M, hsgn, hr, hX, hM, hP, hpr, hNs, hm, hrange,
hS1, hS2, hdisj, w_S0 q H B Ns S1 S2 sgn r X hX hpos hcls,
w_5_19 q δ K H Ns S1 sgn r X hsgn hX hpos hcoll hKq,
(w_kappa1 Ns P (fun ε => (hpr ε).pos) m η hη0 hequiP).trans hk1s, hk2, hk3, hk4, hk5,
w_5_21 q K H hK1 hH1 Ns hNs S1 (fun p hp => (hS1p p hp).pos) η hη0 hη1
sgn r X hsgn hX hpos hcoll hequi _ hc0'⟩The gate replayed this file at its merge, each hole a sorry (D-12 #5); the whole file: targets/erdos-257/nodes/variant-6b364d2b--h1/attempts/20261023T140825Z-t1023-f2-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.«variant-6b364d2b--h1».Context
/-! Hole `h1` 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 variant_6b364d2b__h1 : ∀ (q : ℕ),
(0 : ℕ) < q →
∃ (c0 : ℝ),
(0 : ℝ) < c0 ∧
∀ (δ : ℝ),
(0 : ℝ) < δ →
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m :
ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r :
(Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ),
(∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧
(∀ (ε : Fin K → Bool) (h : ℕ),
r ε h =
p0 * (↑h : ℤ) +
∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧
(∀ (p : ℕ) (n : ℤ),
X p n =
(↑q : ℝ) *
∑ k ∈ Finset.range H,
(∑ ε : Fin K → Bool,
sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) /
(2 : ℝ) ^ (k + K + (1 : ℕ))) ∧
Even M ∧
(∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧
(∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧
Ns.Nonempty ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
(n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) =
(↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
∀ k < H,
(0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧
S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
Disjoint S1 S2 ∧
(∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),
p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧
(∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑ ε : Fin K → Bool,
∑' (k : ℕ),
(if P ε ^ (2 : ℕ) ∣ P ε * m n ε + P ε * (k + (1 : ℕ)) then (1 : ℝ)
else (0 : ℝ)) /
(2 : ℝ) ^ (k + (1 : ℕ)) ≤
δ ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑' (k : ℕ),
(∑ ε : Fin K → Bool,
(↑((ArithmeticFunction.cardDistinctFactors : ℕ → ℕ)
(n + r ε (k + H + K + (1 : ℕ))).toNat) :
ℝ)) /
(2 : ℝ) ^ (k + H + K + (1 : ℕ)) ≤
δ ∧
√((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ (2 : ℕ)) ≤ δ ∧
∑ j ∈ Finset.range (M + (1 : ℕ)),
((2 : ℝ) * Real.pi) ^ j / (↑j.factorial : ℝ) *
|(↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j -
(↑(Fintype.piFinset fun (x : ↥S1) => Ns).card : ℝ)⁻¹ *
∑ ω ∈ Fintype.piFinset fun (x : ↥S1) => Ns,
(∑ p : ↥S1, X (↑p : ℕ) (ω p)) ^ j| ≤
δ ∧
(∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
((2 : ℝ) * Real.pi * Real.exp (1 : ℝ) * X p n) +
∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
(-((2 : ℝ) * Real.pi * Real.exp (1 : ℝ)) * X p n)) /
Real.exp (1 : ℝ) ^ M ≤
δ ∧
c0 ≤
∑ p ∈ S1,
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ (2 : ℕ) -
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ (2 : ℕ)) := 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 t1022-l, drafted with Claude Opus 5.5 (agent t1022-t), 2026-10-23; no one has read it against the Lean and signed it.
Draft · drafted, by the model named above
$\displaystyle \forall q \ge 1\ \exists c_0 > 0\ \forall \delta > 0:\ \text{a prime cube } p_\varepsilon = p_0 + \textstyle\sum_k \varepsilon_k v_k, \text{ a finite set of } n \text{ obeying (5.5)--(5.6), a split } S_0 \sqcup S_1 \sqcup S_2 \text{ of the primes} \le B \text{ with } X_p \text{ constant on } S_0,\ |X_p| \le \delta \text{ on } S_1,\ M \text{ even},\ \kappa_1, \dots, \kappa_5 \le \delta,\ \sum_{p \in S_1} \operatorname{Var} X_p \ge c_0$
Theorem 5.1 of arXiv:2512.01739v2 (p. 49) for n uniform on the finite set Ns, where X_p(n) = q sum_{1<=h<=H} sum_eps (-1)^|eps| 1[p | n + r_{eps,h+K}] / 2^(h+K) is (5.13), and kappa_1, kappa_2, kappa_3 are (5.10), (5.11), (5.14) as printed (expectation and sums swapped). kappa_4, kappa_5 are (5.16), (5.17) as printed, with X'_p independent copies (n uniform on Ns^{S_1}) and e = exp 1 in (5.17). One part is taken from the paper's proof rather than its statement: (5.19), |X_p| small on S_1 (shown in section 5.6 from (5.36)). It does not mention the sum or rationality: it is about prime factors of shifted integers, and in the paper its proof rests on the paper's Theorem 3.1 and on Lemma 5.2.
Rendered from gloss/9915413f81de….md · Improve these words →
Rendered from targets/erdos-257/nodes/variant-6b364d2b--h1/Statement.lean. Origin: compiler-derived.
Depends on (1), each in words
Depends on, each in words where someone has written them:
- variant-6b364d2b--h1--h1: $\forall q \ge 1,\ T,\ \delta > 0,\ P_0\ \ \exists P \ge P_0,\ 2^K \le (\log P)^{2/3},\ H \le (\log P)^{2/3}\ \ \forall (p_0, v)\ \ \exists (N_s, S_1, S_2, M, \eta, w, R):\ \kappa_2, \kappa_3, \kappa_4, \kappa_5 \le \delta,\ \sum_{\varepsilon} \frac{1+\eta}{p_\varepsilon} \le \delta,\ \frac{q}{2^{K+1}} \le \delta,\ 2^K T \le \log\log R - \log\log w$
Attestation: none of a proof
No proof of this statement has been merged. A partial assembly merged under attestations/000957.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.
6e5582fcf7b2.import Mathlib /-- The hypotheses of Theorem 5.1 as a hole: some positive denominator `q` exists. -/ theorem witness : ∃ (q : ℕ), (0 : ℕ) < q := ⟨1, Nat.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 (2)
2 recorded. Routes refuted: none. Failure classes: budget-exhausted 1.
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 t1023-f2; merged in 17322888f918 under attestations/000957.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-257/nodes/variant-6b364d2b--h1/attempts/20261023T140825Z-t1023-f2-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 20261023T140825Z-t1023-f2-partial.lean, extracted by the gate at 1bd7ca70c9ee 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.
tt_sec5_setuphole∀ (q : ℕ), (0 : ℕ) < q → ∀ (T δ : ℝ), (0 : ℝ) < δ → ∀ (P0 : ℕ), ∃ (Pw : ℕ) (K : ℕ) (H : ℕ), P0 ≤ Pw ∧ (1 : ℕ) ≤ K ∧ (1 : ℕ) ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ (↑H : ℝ) ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ ∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ), (∀ (ε : Fin K → Bool), Nat.Prime (P ε) ∧ Pw < (2 : ℕ) * P ε ∧ P ε ≤ Pw ∧ (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)) → ∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w : ℕ) (R : ℕ), ((∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : (truncated)holeLeaves
∀ (q : ℕ), (0 : ℕ) < q → ∃ (c0 : ℝ), (0 : ℝ) < c0 ∧ ∀ (δ : ℝ), (0 : ℝ) < δ → ∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ (truncated), withtt_sec5_setup : ∀ (q : ℕ), (0 : ℕ) < q → ∀ (T δ : ℝ), (0 : ℝ) < δ → ∀ (P0 : ℕ), ∃ (Pw : ℕ) (K : ℕ) (H : ℕ), P0 ≤ Pw ∧ (1 : ℕ) ≤ K ∧ (1 : ℕ) ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ (↑H : ℝ) ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ ∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ), (∀ (ε : Fin K → Bool), Nat.Prime (P ε) ∧ Pw < (2 : ℕ) * P ε ∧ P ε ≤ Pw ∧ (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)) → ∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w : ℕ) (R : ℕ), ((∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : (truncated).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,FinNatural numbers less than some upper bound. ,BoolThe Boolean values,trueandfalse. ,Nat.PrimeNat.Prime pmeans thatpis a prime number, that is, a natural number at least 2 whose only divisors arepand1. ,Function.InjectiveA functionf : α → βis called injective iff x = f yimpliesx = y. ,FinsetFinset αis the type of finite sets of elements ofα. ,Finset.rangerange nis the set of natural numbers less thann. ,EvenAn elementaof a typeαwith addition satisfiesEven aifa = r + r, for somer : α. ,DisjointTwo elements of a lattice are disjoint if their inf is the bottom element. ,ArithmeticFunction.cardDistinctFactorsω nis the number of distinct prime factors ofn. ,Real.sqrtThe square root of a real number. ,Real.piThe number π = 3.14159265... ,Fintype.piFinsetGiven for alla : αa finsett aofδ a, then one can define the finsetFintype.piFinset tof all functions taking values int afor alla. ,Real.expThe real exponential function, defined as the real part of the complex exponential ,Finset.IocThe finset $(a, b]$ of elementsxsuch thata < xandx ≤ b. .Left open as a hole; its statement is variant-6b364d2b--h1--h1 (open).
Lean, lines 1670–1715
have tt_sec5_setup : ∀ q : ℕ, 0 < q → ∀ T : ℝ, ∀ δ : ℝ, 0 < δ → ∀ P0 : ℕ, ∃ (Pw K H : ℕ), P0 ≤ Pw ∧ 1 ≤ K ∧ 1 ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧ (H : ℝ) ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧ ∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ), (∀ ε : Fin K → Bool, Nat.Prime (P ε) ∧ Pw < 2 * P ε ∧ P ε ≤ Pw ∧ (P ε : ℤ) = p0 + ∑ k, if ε k then v k else 0) → Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) → Function.Injective (fun x : (Fin K → Bool) × Fin H => (p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ) - ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) → ∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w R : ℕ), ((∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1) ∧ (∀ ε (h : ℕ), r ε h = p0 * h + ∑ k : Fin K, ((h : ℤ) - (k.1 + 1)) * (if ε k then v k else 0)) ∧ (∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * (if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1)) ∧ Even M) ∧ (Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ ε, n - ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε k then v k else 0) = P ε * m n ε) ∧ (∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) ∧ n + r ε (k + K + 1) ≤ B)) ∧ (S1 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧ S2 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧ Disjoint S1 S2 ∧ (∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, (p : ℤ) ∣ n - n') ∧ (∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) → ¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))) ∧ (0 ≤ η ∧ η ≤ 1 / 4 ∧ (∀ ε, ∀ a : ℕ, ((Ns.filter fun n => P ε ∣ m n ε + a).card : ℝ) * P ε ≤ (1 + η) * Ns.card) ∧ (∀ p ∈ S1, ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card| ≤ η * Ns.card)) ∧ ((q : ℝ) / 2 ^ (K + 1) ≤ δ ∧ ∑ ε : Fin K → Bool, (1 + η) / P ε ≤ δ) ∧ ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' k : ℕ, (∑ ε : Fin K → Bool, (ArithmeticFunction.cardDistinctFactors (n + r ε (k + H + K + 1)).toNat : ℝ)) / 2 ^ (k + H + K + 1) ≤ δ ∧ Real.sqrt ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ 2) ≤ δ ∧ ∑ j ∈ Finset.range (M + 1), (2 * Real.pi) ^ j / j.factorial * |(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j - ((Fintype.piFinset (fun _ : S1 => Ns)).card : ℝ)⁻¹ * ∑ ω ∈ Fintype.piFinset (fun _ : S1 => Ns), (∑ p : S1, X p (ω p)) ^ j| ≤ δ ∧ (∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp (2 * Real.pi * Real.exp 1 * X p n) + ∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp (-(2 * Real.pi * Real.exp 1) * X p n)) / Real.exp 1 ^ M ≤ δ) ∧ (3 ≤ w ∧ w ≤ R ∧ (2 : ℝ) ^ K * T ≤ Real.log (Real.log R) - Real.log (Real.log w) ∧ ∑ p ∈ (Finset.Ioc w R).filter Nat.Prime \ S1, (1 : ℝ) / p ≤ 1) := sorrys2obtain∃ (C : ℝ), ∀ (m n : ℕ), (2 : ℕ) ≤ m → m ≤ n → |∑ p ≤ n with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ m with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (Real.log (Real.log (↑n : ℝ)) - Real.log (Real.log (↑m : ℝ)))| ≤ C / Real.log (↑m : ℝ)Leaves
∀ (q : ℕ), (0 : ℕ) < q → ∃ (c0 : ℝ), (0 : ℝ) < c0 ∧ ∀ (δ : ℝ), (0 : ℝ) < δ → ∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ (truncated), withC : ℝ,hC : ∀ (m n : ℕ), (2 : ℕ) ≤ m → m ≤ n → |∑ p ≤ n with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ m with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (Real.log (Real.log (↑n : ℝ)) - Real.log (Real.log (↑m : ℝ)))| ≤ C / Real.log (↑m : ℝ).Lean, line 1716
obtain ⟨C, hC⟩ := u_mertens_second_interval
hC0have(0 : ℝ) ≤ CLeaves
∀ (q : ℕ), (0 : ℕ) < q → ∃ (c0 : ℝ), (0 : ℝ) < c0 ∧ ∀ (δ : ℝ), (0 : ℝ) < δ → ∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ (truncated), withhC0 : (0 : ℝ) ≤ C.Lean, lines 1717–1722
have hC0 : 0 ≤ C := by have h := (abs_nonneg _).trans (hC 2 2 le_rfl le_rfl) have hl : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num) by_contra hneg have : C / Real.log 2 < 0 := div_neg_of_neg_of_pos (lt_of_not_ge hneg) hl linarithhC0.hhave(0 : ℝ) ≤ C / Real.log (↑(2 : ℕ) : ℝ)Leaves
(0 : ℝ) ≤ C, withh : (0 : ℝ) ≤ C / Real.log (↑(2 : ℕ) : ℝ).Uses library
abs_nonneg,le_rflA version ofle_reflwhere the argument is implicit .Lean, line 1718
have h := (abs_nonneg _).trans (hC 2 2 le_rfl le_rfl)
hC0.hlhave(0 : ℝ) < Real.log (2 : ℝ)Leaves
(0 : ℝ) ≤ C, withhl : (0 : ℝ) < Real.log (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_pos.Lean, line 1719
have hl : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num)
hC0.thishaveC / Real.log (2 : ℝ) < (0 : ℝ)Leaves
False, withthis : C / Real.log (2 : ℝ) < (0 : ℝ).Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,div_neg_of_neg_of_pos,lt_of_not_ge.Lean, line 1721
have : C / Real.log 2 < 0 := div_neg_of_neg_of_pos (lt_of_not_ge hneg) hl
s4obtain∃ (P0 : ℕ), ∀ (P : ℕ), P0 ≤ P → ∀ (K H : ℕ), (2 : ℝ) ^ K ≤ Real.log (↑P : ℝ) ^ (2 / 3 : ℝ) → (↑H : ℝ) ≤ Real.log (↑P : ℝ) ^ (2 / 3 : ℝ) → ∃ (p0 : ℤ) (v : Fin K → ℤ), (∀ (ε : Fin K → Bool), ∃ (p : ℕ), Nat.Prime p ∧ P < (2 : ℕ) * p ∧ p ≤ P ∧ (↑p : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withP0 : ℕ,hP0 : ∀ (P : ℕ), P0 ≤ P → ∀ (K H : ℕ), (2 : ℝ) ^ K ≤ Real.log (↑P : ℝ) ^ (2 / 3 : ℝ) → (↑H : ℝ) ≤ Real.log (↑P : ℝ) ^ (2 / 3 : ℝ) → ∃ (p0 : ℤ) (v : Fin K → ℤ), (∀ (ε : Fin K → Bool), ∃ (p : ℕ), Nat.Prime p ∧ P < (2 : ℕ) * p ∧ p ≤ P ∧ (↑p : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ).Lean, line 1726
obtain ⟨P0, hP0⟩ := a52_hilbert_cube_primes_quant_two_thirds
s5obtain∃ (Pw : ℕ) (K : ℕ) (H : ℕ), P0 ≤ Pw ∧ (1 : ℕ) ≤ K ∧ (1 : ℕ) ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ (↑H : ℝ) ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ) ∧ ∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ), (∀ (ε : Fin K → Bool), Nat.Prime (P ε) ∧ Pw < (2 : ℕ) * P ε ∧ P ε ≤ Pw ∧ (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)) → ∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w : ℕ) (R : ℕ), ((∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ (truncated)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withPw : ℕ,K : ℕ,H : ℕ,hPw : P0 ≤ Pw,hK1 : (1 : ℕ) ≤ K,hH1 : (1 : ℕ) ≤ H,hK23 : (2 : ℝ) ^ K ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ),hH23 : (↑H : ℝ) ≤ Real.log (↑Pw : ℝ) ^ (2 / 3 : ℝ),hrest : ∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ), (∀ (ε : Fin K → Bool), Nat.Prime (P ε) ∧ Pw < (2 : ℕ) * P ε ∧ P ε ≤ Pw ∧ (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) → (Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)) → ∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w : ℕ) (R : ℕ), ((∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M) ∧ (Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ ∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ (S1 ⊆ Finset.filter Nat.Prime (Finset.rang (truncated).Lean, line 1727
obtain ⟨Pw, K, H, hPw, hK1, hH1, hK23, hH23, hrest⟩ := tt_sec5_setup q hq (C + 2) δ hδ P0
s6obtain∃ (p0 : ℤ) (v : Fin K → ℤ), (∀ (ε : Fin K → Bool), ∃ (p : ℕ), Nat.Prime p ∧ Pw < (2 : ℕ) * p ∧ p ≤ Pw ∧ (↑p : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withp0 : ℤ,v : Fin K → ℤ,hcube : ∀ (ε : Fin K → Bool), ∃ (p : ℕ), Nat.Prime p ∧ Pw < (2 : ℕ) * p ∧ p ≤ Pw ∧ (↑p : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ),hinj1 : Function.Injective fun (ε : Fin K → Bool) => p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ),hinj2 : Function.Injective fun (x : (Fin K → Bool) × Fin H) => (p0 + ∑ k : Fin K, if x.1 k = true then v k else (0 : ℤ)) * (↑((↑x.2 : ℕ) + (1 : ℕ) + K) : ℤ) - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if x.1 k = true then v k else (0 : ℤ).Lean, line 1728
obtain ⟨p0, v, hcube, hinj1, hinj2⟩ := hP0 Pw hPw K H hK23 hH23
hPhave∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhP : ∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ).Uses library
FinNatural numbers less than some upper bound. .Lean, line 1730
have hP : ∀ ε, (P ε : ℤ) = p0 + ∑ k : Fin K, (if ε k then v k else 0) := fun ε => (hPc ε).2.2.2
hprhave∀ (ε : Fin K → Bool), Nat.Prime (P ε)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhpr : ∀ (ε : Fin K → Bool), Nat.Prime (P ε).Lean, line 1731
have hpr : ∀ ε, (P ε).Prime := fun ε => (hPc ε).1
s9obtain∃ (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w : ℕ) (R : ℕ), ((∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M) ∧ (Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ ∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ (S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, (↑p : ℤ) ∣ n - n') ∧ ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ (ε1 ε2 : Fin K → Bool), k1 ≠ k2 ∨ ε1 ≠ ε2 → ¬(↑p : ℤ) ∣ r ε1 (k1 + K + (1 : ℕ)) - r ε2 (k2 + K + (1 : ℕ))) ∧ ((0 : ℝ) ≤ η ∧ η ≤ (1 / 4 : ℝ) ∧ (∀ (ε : Fin K → Bool) (a : ℕ), (↑{n ∈ Ns | P ε ∣ m n ε + a}.card : ℝ) * (↑(P ε) : ℝ) ≤ ((1 : ℝ) + η) * (↑Ns.card : ℝ)) ∧ ∀ p ∈ S1, ∀ (a : ℤ), |(↑{n ∈ Ns | (↑p : ℤ (truncated)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withB : ℕ,Ns : Finset ℤ,m : ℤ → (Fin K → Bool) → ℕ,S1 : Finset ℕ,S2 : Finset ℕ,sgn : (Fin K → Bool) → ℝ,r : (Fin K → Bool) → ℕ → ℤ,X : ℕ → ℤ → ℝ,M : ℕ,η : ℝ,w : ℕ,R : ℕ,hsgn : ∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ),hr : ∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ),hX : ∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ)),hM : Even M,hNs : Ns.Nonempty,hm : ∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ),hrange : ∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ),hS1 : S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),hS2 : S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),hdisj : Disjoint S1 S2,hcls : ∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, (↑p : ℤ) ∣ n - n',hcoll : ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ (ε1 ε2 : Fin K → Bool), k1 ≠ k2 ∨ ε1 ≠ ε2 → ¬(↑p : ℤ) ∣ r ε1 (k1 + K + (1 : ℕ)) - r ε2 (k2 + K + (1 : ℕ)),hη0 : (0 : ℝ) ≤ η,hη14 : η ≤ (1 / 4 : ℝ),hequiP : ∀ (ε : Fin K → Bool) (a : ℕ), (↑{n ∈ Ns | P ε ∣ m n ε + a}.card : ℝ) * (↑(P ε) : ℝ) ≤ ((1 : ℝ) + η) * (↑Ns.card : ℝ),hequi : ∀ p ∈ S1, ∀ (a : ℤ), |(↑{n ∈ Ns | (↑p : ℤ) ∣ n + a}.card : ℝ) * (↑p : ℝ) - (↑Ns.card : ℝ)| ≤ η * (↑Ns.card : ℝ),hKq : (↑q : ℝ) / (2 : ℝ) ^ (K + (1 : ℕ)) ≤ δ,hk1s : ∑ ε : Fin K → Bool, ((1 : ℝ) + η) / (↑(P ε) : ℝ) ≤ δ,hk2 : (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' (k : ℕ), (∑ ε : Fin K → Bool, (↑((ArithmeticFunction.cardDistinctFactors : ℕ → ℕ) (n + r ε (k + H + K + (1 : ℕ))).toNat) : ℝ)) / (2 : ℝ) ^ (k + H + K + (1 : ℕ)) ≤ δ,hk3 : √((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ (2 : ℕ)) ≤ δ,hk4 : ∑ j ∈ Finset.range (M + (1 : ℕ)), ((2 : ℝ) * Real.pi) ^ j / (↑j.factorial : ℝ) * |(↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j - (↑(Fintype.piFinset fun (x : ↥S1) => Ns).card : ℝ)⁻¹ * ∑ ω ∈ Fintype.piFinset fun (x : ↥S1) => Ns, (∑ p : ↥S1, X (↑p : ℕ) (ω p)) ^ j| ≤ δ,hk5 : (∏ p ∈ S1, (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp ((2 : ℝ) * Real.pi * Real.exp (1 : ℝ) * X p n) + ∏ p ∈ S1, (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp (-((2 : ℝ) * Real.pi * Real.exp (1 : ℝ)) * X p n)) / Real.exp (1 : ℝ) ^ M ≤ δ,hw3 : (3 : ℕ) ≤ w,hwR : w ≤ R,hT : (2 : ℝ) ^ K * (C + (2 : ℝ)) ≤ Real.log (Real.log (↑R : ℝ)) - Real.log (Real.log (↑w : ℝ)),hmiss : ∑ p ∈ Finset.filter Nat.Prime (Finset.Ioc w R) \ S1, (1 : ℝ) / (↑p : ℝ) ≤ (1 : ℝ).Lean, lines 1732–1734
obtain ⟨B, Ns, m, S1, S2, sgn, r, X, M, η, w, R, ⟨hsgn, hr, hX, hM⟩, ⟨hNs, hm, hrange⟩, ⟨hS1, hS2, hdisj, hcls, hcoll⟩, ⟨hη0, hη14, hequiP, hequi⟩, ⟨hKq, hk1s⟩, ⟨hk2, hk3, hk4, hk5⟩, ⟨hw3, hwR, hT, hmiss⟩⟩ := hrest p0 v P hPc hinj1 hinj2h_x3b71(hη1) haveη ≤ (1 : ℝ)routine: linarithLeaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhη1 : η ≤ (1 : ℝ).Lean, line 1735
have hη1 : η ≤ 1 := by linarith
hposhave∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ))Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhpos : ∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)).Lean, lines 1736–1737
have hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) := fun n hn ε k hk => (hrange n hn ε k hk).1hS1phave∀ p ∈ S1, Nat.Prime pLeaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhS1p : ∀ p ∈ S1, Nat.Prime p.Uses library
Nat.PrimeNat.Prime pmeans thatpis a prime number, that is, a natural number at least 2 whose only divisors arepand1. ,Finset.mem_filter.Lean, line 1738
have hS1p : ∀ p ∈ S1, Nat.Prime p := fun p hp => (Finset.mem_filter.mp (hS1 hp)).2
hlogwhave(1 : ℝ) ≤ Real.log (↑w : ℝ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhlogw : (1 : ℝ) ≤ Real.log (↑w : ℝ).Lean, line 1740
have hlogw := f2_one_le_log w hw3
hmerthave|∑ p ≤ R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ w with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (Real.log (Real.log (↑R : ℝ)) - Real.log (Real.log (↑w : ℝ)))| ≤ C / Real.log (↑w : ℝ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhmert : |∑ p ≤ R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ w with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (Real.log (Real.log (↑R : ℝ)) - Real.log (Real.log (↑w : ℝ)))| ≤ C / Real.log (↑w : ℝ).Lean, line 1741
have hmert := hC w R (by omega) hwR
hCwhaveC / Real.log (↑w : ℝ) ≤ CLeaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhCw : C / Real.log (↑w : ℝ) ≤ C.Uses library
Real.logThe real logarithm function, equal to the inverse of the exponential forx > 0, tolog |x|forx < 0, and to0for0. ,div_le_self.Lean, line 1743
have hCw : C / Real.log w ≤ C := div_le_self hC0 hlogw
hIochave∑ p ∈ Finset.Ioc w R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) = ∑ p ≤ R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ w with Nat.Prime p, (1 : ℝ) / (↑p : ℝ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhIoc : ∑ p ∈ Finset.Ioc w R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) = ∑ p ≤ R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - ∑ p ≤ w with Nat.Prime p, (1 : ℝ) / (↑p : ℝ).Lean, line 1744
have hIoc := f2_sum_Ioc (fun p => (1 : ℝ) / p) w R hwR
hlowhave∑ p ∈ Finset.Ioc w R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (1 : ℝ) ≤ ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhlow : ∑ p ∈ Finset.Ioc w R with Nat.Prime p, (1 : ℝ) / (↑p : ℝ) - (1 : ℝ) ≤ ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ).Lean, line 1745
have hlow := f2_S1_lower S1 w R hmiss
hshave(2 : ℝ) ^ K * (C + (2 : ℝ)) - C - (1 : ℝ) ≤ ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ)routine: linarithLeaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhs : (2 : ℝ) ^ K * (C + (2 : ℝ)) - C - (1 : ℝ) ≤ ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ).Lean, lines 1746–1747
have hs : (2 : ℝ) ^ K * (C + 2) - C - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p := by linarith [hmert.1]hc0'have(↑q : ℝ) ^ (2 : ℕ) / (8 : ℝ) ≤ ((1 : ℝ) - η) * ((↑q : ℝ) ^ (2 : ℕ) / (2 : ℝ) ^ (K + (2 : ℕ))) * ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ) - η ^ (2 : ℕ) * (↑q : ℝ) ^ (2 : ℕ) * ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ) ^ (2 : ℕ)Leaves
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated), withhc0' : (↑q : ℝ) ^ (2 : ℕ) / (8 : ℝ) ≤ ((1 : ℝ) - η) * ((↑q : ℝ) ^ (2 : ℕ) / (2 : ℝ) ^ (K + (2 : ℕ))) * ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ) - η ^ (2 : ℕ) * (↑q : ℝ) ^ (2 : ℕ) * ∑ p ∈ S1, (1 : ℝ) / (↑p : ℝ) ^ (2 : ℕ).Lean, line 1748
have hc0' := f2_c0 q K S1 (fun p hp => (hS1p p hp).two_le) η hη0 hη14 C hC0 hs
closeterm∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m : ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ), (∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧ (∀ (ε : Fin K → Bool) (h : ℕ), r ε h = p0 * (↑h : ℤ) + ∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧ (∀ (p : ℕ) (n : ℤ), X p n = (↑q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) / (2 : ℝ) ^ (k + K + (1 : ℕ))) ∧ Even M ∧ (∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧ (∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧ Ns.Nonempty ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), (n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) = (↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧ (∀ n ∈ Ns, ∀ (ε : Fin K → Bool), ∀ k < H, (0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧ S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧ Disjoint S1 S2 ∧ (∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))), p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧ (∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧ (↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, (truncated)Closes the goal.
Uses library
Exists.introExistential introduction. .Lean, lines 1749–1754
refine ⟨K, p0, v, P, H, B, Ns, m, S1, S2, sgn, r, X, M, hsgn, hr, hX, hM, hP, hpr, hNs, hm, hrange, hS1, hS2, hdisj, w_S0 q H B Ns S1 S2 sgn r X hX hpos hcls, w_5_19 q δ K H Ns S1 sgn r X hsgn hX hpos hcoll hKq, (w_kappa1 Ns P (fun ε => (hpr ε).pos) m η hη0 hequiP).trans hk1s, hk2, hk3, hk4, hk5, w_5_21 q K H hK1 hH1 Ns hNs S1 (fun p hp => (hS1p p hp).pos) η hη0 hη1 sgn r X hsgn hX hpos hcoll hequi _ hc0'⟩
import Mathlib
import Nodes.«variant-6b364d2b--h1».Context
/-! Hole `h1` 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 a52_cb_small_part (n : ℕ) (n_pos : 0 < n) :
∏ x ∈ Finset.range (2 * n / 3 + 1), x ^ (Nat.centralBinom n).factorization x ≤
(2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) := by
have n2_pos : 1 ≤ 2 * n := by omega
let S := {p ∈ Finset.range (2 * n / 3 + 1) | Nat.Prime p}
let f x := x ^ n.centralBinom.factorization x
have : ∏ x ∈ S, f x = ∏ x ∈ Finset.range (2 * n / 3 + 1), f x := by
refine Finset.prod_filter_of_ne fun p _ h => ?_
contrapose! h; dsimp only [f]
rw [Nat.factorization_eq_zero_of_not_prime n.centralBinom h, _root_.pow_zero]
change ∏ x ∈ Finset.range (2 * n / 3 + 1), f x ≤ _
rw [← this, ← Finset.prod_filter_mul_prod_filter_not S (· ≤ Nat.sqrt (2 * n))]
apply mul_le_mul'
· refine (Finset.prod_le_prod' fun p _ => (?_ : f p ≤ 2 * n)).trans ?_
· exact Nat.pow_factorization_choose_le (mul_pos two_pos n_pos)
have : (Finset.Icc 1 (Nat.sqrt (2 * n))).card = Nat.sqrt (2 * n) := by
rw [Nat.card_Icc, Nat.add_sub_cancel]
rw [Finset.prod_const]
refine pow_right_mono₀ n2_pos ((Finset.card_le_card fun x hx => ?_).trans this.le)
obtain ⟨h1, h2⟩ := Finset.mem_filter.1 hx
exact Finset.mem_Icc.mpr ⟨(Finset.mem_filter.1 h1).2.one_lt.le, h2⟩
· refine le_trans ?_ (primorial_le_4_pow (2 * n / 3))
refine (Finset.prod_le_prod' fun p hp => (?_ : f p ≤ p)).trans ?_
· obtain ⟨h1, h2⟩ := Finset.mem_filter.1 hp
refine (pow_right_mono₀ (Finset.mem_filter.1 h1).2.one_lt.le ?_).trans (pow_one p).le
exact Nat.factorization_choose_le_one (Nat.sqrt_lt'.mp <| not_le.1 h2)
refine Finset.prod_le_prod_of_subset_of_one_le' (Finset.filter_subset _ _) ?_
exact fun p hp _ => (Finset.mem_filter.1 hp).2.one_lt.le
private lemma a52_cb_large_part (n : ℕ) (n_large : 2 < n) :
∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1), x ^ (Nat.centralBinom n).factorization x ≤
(2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
calc ∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1), x ^ (Nat.centralBinom n).factorization x
≤ ∏ x ∈ Finset.Ico (2 * n / 3 + 1) (2 * n + 1),
(if x.Prime ∧ n < x then 2 * n else 1) := by
apply Finset.prod_le_prod'
intro x hx
rw [Finset.mem_Ico] at hx
split_ifs with h
· exact Nat.pow_factorization_choose_le (by omega)
· by_cases hp : x.Prime
· have hxn : x ≤ n := by
by_contra hc; exact h ⟨hp, by omega⟩
rw [Nat.factorization_centralBinom_of_two_mul_self_lt_three_mul n_large hxn (by omega)]
simp
· rw [Nat.factorization_eq_zero_of_not_prime _ hp]; simp
_ = ∏ x ∈ (Finset.Ico (2 * n / 3 + 1) (2 * n + 1)).filter (fun x => x.Prime ∧ n < x),
2 * n := (Finset.prod_filter _ _).symm
_ = (2 * n) ^ ((Finset.Ico (2 * n / 3 + 1) (2 * n + 1)).filter
(fun x => x.Prime ∧ n < x)).card := Finset.prod_const _
_ ≤ (2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
apply pow_le_pow_right₀ (by omega)
apply Finset.card_le_card
intro x hx
simp only [Finset.mem_filter, Finset.mem_Ico, Finset.mem_Ioc] at hx ⊢
exact ⟨⟨hx.2.2, by omega⟩, hx.2.1⟩
private lemma a52_cb_bound (n : ℕ) (n_large : 2 < n) :
Nat.centralBinom n ≤ (2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) *
(2 * n) ^ ((Finset.Ioc n (2 * n)).filter Nat.Prime).card := by
rw [← Nat.prod_pow_factorization_centralBinom,
← Finset.prod_range_mul_prod_Ico _ (show 2 * n / 3 + 1 ≤ 2 * n + 1 by omega)]
exact mul_le_mul' (a52_cb_small_part n (by omega)) (a52_cb_large_part n n_large)
private lemma a52_cb_log_ineq (n : ℕ) (hn : 4 ≤ n) :
(n : ℝ) * Real.log 4 < Real.log n + Real.sqrt (2 * n) * Real.log (2 * n) +
(2 * n / 3) * Real.log 4 +
(((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ) * Real.log (2 * n) := by
set k := ((Finset.Ioc n (2 * n)).filter Nat.Prime).card
have h1 : 4 ^ n < n * ((2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) * (2 * n) ^ k) :=
lt_of_lt_of_le (Nat.four_pow_lt_mul_centralBinom n hn)
(Nat.mul_le_mul_left _ (a52_cb_bound n (by omega)))
have h2 : ((4 : ℝ) ^ n) < (n : ℝ) * ((2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) *
(2 * n) ^ k) := by exact_mod_cast h1
have hnpos : (0 : ℝ) < n := by positivity
have h3 := Real.log_lt_log (by positivity) h2
rw [Real.log_pow, Real.log_mul (by positivity) (by positivity),
Real.log_mul (by positivity) (by positivity), Real.log_mul (by positivity) (by positivity),
Real.log_pow, Real.log_pow, Real.log_pow] at h3
have hs : (Nat.sqrt (2 * n) : ℝ) ≤ Real.sqrt (2 * n) := by
have := @Real.nat_sqrt_le_real_sqrt (2 * n); push_cast at this; exact this
have hd : ((2 * n / 3 : ℕ) : ℝ) ≤ 2 * n / 3 := by
have := @Nat.cast_div_le ℝ _ _ _ (2 * n) 3; push_cast at this; exact this
have hL : 0 ≤ Real.log (2 * n) := Real.log_nonneg (by
have : (4 : ℝ) ≤ n := by exact_mod_cast hn
linarith)
have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num)
nlinarith [mul_le_mul_of_nonneg_right hs hL, mul_le_mul_of_nonneg_right hd hl4]
private theorem a52_primes_in_dyadic_lower :
∃ c : ℝ, 0 < c ∧ ∃ N : ℕ, ∀ n : ℕ, N ≤ n →
c * (n : ℝ) / Real.log n ≤ (((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ) := by
refine ⟨1 / 10, by norm_num, 10 ^ 8, fun n hn => ?_⟩
have key := a52_cb_log_ineq n (le_trans (by norm_num) hn)
set k : ℝ := (((Finset.Ioc n (2 * n)).filter Nat.Prime).card : ℝ)
have hk0 : 0 ≤ k := by positivity
have hnR : (10 : ℝ) ^ 8 ≤ n := by exact_mod_cast hn
have hn0 : (0 : ℝ) < n := by linarith
set t := Real.sqrt (Real.sqrt n) with ht
have hsq : Real.sqrt n = t ^ 2 := (Real.sq_sqrt (Real.sqrt_nonneg _)).symm
have hn4 : (n : ℝ) = t ^ 4 := by
rw [show t ^ 4 = (t ^ 2) ^ 2 by ring, ← hsq, Real.sq_sqrt hn0.le]
have ht100 : 100 ≤ t := by
rw [ht, Real.le_sqrt (by norm_num) (Real.sqrt_nonneg _), Real.le_sqrt (by norm_num) hn0.le]
linarith
have hlogn : Real.log n = 4 * Real.log t := by
rw [hn4, Real.log_pow]; norm_num
have hlogt : Real.log t ≤ t := by
have := Real.log_le_sub_one_of_pos (show 0 < t by linarith); linarith
have hlogt0 : 0 < Real.log t := Real.log_pos (by linarith)
have hs2 : Real.sqrt (2 * n) ≤ 3 / 2 * t ^ 2 := by
rw [Real.sqrt_mul (by norm_num), hsq]
have : Real.sqrt 2 ≤ 3 / 2 := by
rw [Real.sqrt_le_left (by norm_num)]; norm_num
nlinarith
have hL : Real.log (2 * n) = Real.log 2 + Real.log n :=
Real.log_mul (by norm_num) hn0.ne'
have hl2 : Real.log 2 ≤ Real.log n := Real.log_le_log (by norm_num) (by linarith)
have hl20 : 0 < Real.log 2 := Real.log_pos (by norm_num)
have hl4 : Real.log 4 = 2 * Real.log 2 := by
rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]; norm_num
have hl2v := Real.log_two_gt_d9
rw [div_le_iff₀ (by rw [hlogn]; positivity)]
rw [hL, hl4, hlogn] at key
rw [hlogn]
have h1 : Real.sqrt (2 * n) * (Real.log 2 + 4 * Real.log t) ≤
3 / 2 * t ^ 2 * (8 * t) := by
apply mul_le_mul hs2 (by linarith) (by positivity) (by positivity)
have h2 : k * (Real.log 2 + 4 * Real.log t) ≤ k * (8 * Real.log t) := by
apply mul_le_mul_of_nonneg_left _ hk0; linarith
have h3 : (n : ℝ) * Real.log 2 * (2 / 3) < 4 * Real.log t + 12 * t ^ 3 + k * (8 * Real.log t) := by
linarith
have h4 : (n : ℝ) * 0.6931471803 ≤ (n : ℝ) * Real.log 2 :=
mul_le_mul_of_nonneg_left hl2v.le hn0.le
have h5 : t ^ 4 ≥ 100 * t ^ 3 := by nlinarith [pow_pos (show (0:ℝ) < t by linarith) 3]
have h6 : t ^ 3 ≥ 10000 * t := by nlinarith [mul_pos (show (0:ℝ) < t by linarith) (show (0:ℝ) < t by linarith)]
rw [hn4] at h3 h4 ⊢
nlinarith
-- The vertex offset of the cube with generators `v` selected by `ε`.
private def a52_cubeSum {K : ℕ} (v : Fin K → ℕ) (ε : Fin K → Bool) : ℕ :=
∑ k, if ε k then v k else 0
-- Splitting off the first generator.
private lemma a52_cubeSum_cons {K : ℕ} (d : ℕ) (v : Fin K → ℕ) (ε : Fin (K + 1) → Bool) :
a52_cubeSum (Fin.cons d v : Fin (K + 1) → ℕ) ε = (if ε 0 then d else 0) + a52_cubeSum v (Fin.tail ε) := by
simp [a52_cubeSum, Fin.sum_univ_succ, Fin.tail]
rfl
-- Counting ordered pairs `x < y` in `A`.
private lemma a52_pair_count (A : Finset ℕ) :
2 * ∑ x ∈ A, (A.filter (fun y => x < y)).card + A.card = A.card ^ 2 := by
induction A using Finset.induction_on_max with
| empty => simp
| insert m A hm ih =>
have hmA : m ∉ A := fun h => lt_irrefl _ (hm m h)
rw [Finset.sum_insert hmA, Finset.card_insert_of_notMem hmA]
have h1 : ((insert m A).filter (fun y => m < y)).card = 0 := by
rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff]
intro y hy
rcases Finset.mem_insert.1 hy with rfl | hy
· exact lt_irrefl _
· exact fun h => lt_asymm h (hm y hy)
have h2 : ∀ x ∈ A, ((insert m A).filter (fun y => x < y)).card
= (A.filter (fun y => x < y)).card + 1 := by
intro x hx
rw [Finset.filter_insert, if_pos (hm x hx), Finset.card_insert_of_notMem (by simp [hmA])]
rw [h1, Finset.sum_congr rfl h2, Finset.sum_add_distrib]
simp only [Finset.sum_const, smul_eq_mul, mul_one]
nlinarith [ih]
-- The representation-count sum equals the number of pairs `x < y`.
private lemma a52_sum_r_eq (N : ℕ) (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 N) :
∑ d ∈ Finset.Icc 1 N, (A.filter (fun x => x + d ∈ A)).card
= ∑ x ∈ A, (A.filter (fun y => x < y)).card := by
simp only [Finset.card_filter]
rw [Finset.sum_comm]
refine Finset.sum_congr rfl fun x hx => ?_
rw [← Finset.card_filter, ← Finset.card_filter]
refine Finset.card_nbij' (fun d => x + d) (fun y => y - x) ?_ ?_ ?_ ?_
· intro d hd
simp only [Finset.coe_filter, Finset.mem_Icc, Set.mem_setOf_eq] at hd ⊢
exact ⟨hd.2, by omega⟩
· intro y hy
simp only [Finset.coe_filter, Finset.mem_Icc, Set.mem_setOf_eq] at hy ⊢
have := Finset.mem_Icc.1 (hA hy.1)
refine ⟨⟨by omega, by omega⟩, ?_⟩
rw [Nat.add_sub_cancel' hy.2.le]; exact hy.1
· intro d _; simp
· intro y hy
simp only [Finset.coe_filter, Set.mem_setOf_eq] at hy
simp only
omega
-- Pigeonhole: a popular difference avoiding the forbidden set exists.
private lemma a52_good_d_exists (N : ℕ) (A : Finset ℕ) (F : Finset ℤ) (hA : A ⊆ Finset.Icc 1 N)
(hn : 16 * (F.card + 1) ≤ A.card) :
∃ d ∈ Finset.Icc 1 N, A.card ^ 2 ≤ 4 * N * (A.filter (fun x => x + d ∈ A)).card ∧
(d : ℤ) ∉ F ∧ -(d : ℤ) ∉ F := by
set n := A.card with hn_def
set r : ℕ → ℕ := fun d => (A.filter (fun x => x + d ∈ A)).card with hr_def
set G := (Finset.Icc 1 N).filter (fun d => n ^ 2 ≤ 4 * N * r d) with hG_def
set G' := (Finset.Icc 1 N).filter (fun d => ¬ n ^ 2 ≤ 4 * N * r d) with hG'_def
set B := (Finset.Icc 1 N).filter (fun d : ℕ => (d : ℤ) ∈ F ∨ -(d : ℤ) ∈ F) with hB_def
have hB : B.card ≤ 2 * F.card := by
have hsub : B ⊆ F.image (fun f => f.toNat) ∪ F.image (fun f => (-f).toNat) := by
intro d hd
simp only [hB_def, Finset.mem_filter] at hd
rcases hd.2 with h | h
· exact Finset.mem_union_left _ (Finset.mem_image.2 ⟨_, h, by simp⟩)
· exact Finset.mem_union_right _ (Finset.mem_image.2 ⟨_, h, by simp⟩)
calc B.card ≤ _ := Finset.card_le_card hsub
_ ≤ _ := Finset.card_union_le _ _
_ ≤ F.card + F.card := add_le_add Finset.card_image_le Finset.card_image_le
_ = _ := by ring
have hnpos : 0 < n := by omega
have hN : 0 < N := by
obtain ⟨a, ha⟩ := Finset.card_pos.1 hnpos
have := Finset.mem_Icc.1 (hA ha)
omega
have hsum := a52_sum_r_eq N A hA
have hpc := a52_pair_count A
have hsplit : ∑ d ∈ Finset.Icc 1 N, r d = ∑ d ∈ G, r d + ∑ d ∈ G', r d :=
(Finset.sum_filter_add_sum_filter_not _ _ _).symm
have hGs : ∑ d ∈ G, r d ≤ G.card * n := by
have := Finset.sum_le_card_nsmul G r n (fun d _ => Finset.card_filter_le _ _)
simpa using this
have hG's : 4 * N * ∑ d ∈ G', r d ≤ N * n ^ 2 := by
rw [Finset.mul_sum]
calc ∑ d ∈ G', 4 * N * r d ≤ ∑ d ∈ G', n ^ 2 := by
refine Finset.sum_le_sum fun d hd => ?_
simp only [hG'_def, Finset.mem_filter] at hd
omega
_ = G'.card * n ^ 2 := by simp
_ ≤ N * n ^ 2 := by
refine Nat.mul_le_mul_right _ ?_
calc G'.card ≤ (Finset.Icc 1 N).card := Finset.card_filter_le _ _
_ = N := by simp
have hS : ∑ d ∈ Finset.Icc 1 N, r d = ∑ x ∈ A, (A.filter (fun y => x < y)).card := hsum
have key : N * n * n ≤ N * n * (4 * G.card + 2) := by
nlinarith
have key2 : n ≤ 4 * G.card + 2 := Nat.le_of_mul_le_mul_left key (by positivity)
have hlt : B.card < G.card := by omega
obtain ⟨d, hdG, hdB⟩ := Finset.exists_mem_notMem_of_card_lt_card hlt
simp only [hG_def, Finset.mem_filter] at hdG
simp only [hB_def, Finset.mem_filter, not_and, not_or] at hdB
exact ⟨d, hdG.1, hdG.2, (hdB hdG.1).1, (hdB hdG.1).2⟩
-- Density increment for the next level.
private lemma a52_density_step (N n n' c c' : ℝ) (K : ℕ) (hn : 0 < n) (hn' : 0 < n') (hN : 0 ≤ N)
(hc : 0 ≤ c) (hc' : c' ≤ 3 * c) (hr : n ^ 2 ≤ 4 * N * n')
(h : c * (16 * N / n) ^ (2 ^ (K + 2)) ≤ N) :
c' * (16 * N / n') ^ (2 ^ (K + 1)) ≤ N := by
set x := 16 * N / n with hx
have hx0 : 0 ≤ x := by positivity
have h1 : 16 * N / n' ≤ x ^ 2 / 4 := by
rw [hx, div_pow, div_div, div_le_div_iff₀ hn' (by positivity)]
nlinarith [mul_le_mul_of_nonneg_left hr (by positivity : (0:ℝ) ≤ 16 * N)]
set m := 2 ^ (K + 1) with hm
have hm1 : 1 ≤ m := Nat.one_le_two_pow
have h2 : (16 * N / n') ^ m ≤ x ^ (2 ^ (K + 2)) / 4 := by
calc (16 * N / n') ^ m ≤ (x ^ 2 / 4) ^ m := pow_le_pow_left₀ (by positivity) h1 m
_ = x ^ (2 ^ (K + 2)) / 4 ^ m := by
rw [div_pow, ← pow_mul]; congr 2; rw [hm, pow_succ 2 (K + 1)]; ring
_ ≤ x ^ (2 ^ (K + 2)) / 4 := by
apply div_le_div_of_nonneg_left (by positivity) (by norm_num)
calc (4:ℝ) = 4 ^ 1 := by norm_num
_ ≤ 4 ^ m := pow_le_pow_right₀ (by norm_num) hm1
calc c' * (16 * N / n') ^ m ≤ (3 * c) * (x ^ (2 ^ (K + 2)) / 4) :=
mul_le_mul hc' h2 (by positivity) (by positivity)
_ ≤ c * x ^ (2 ^ (K + 2)) := by nlinarith [pow_nonneg hx0 (2 ^ (K + 2))]
_ ≤ N := h
-- The density hypothesis forces `A` to be large compared with the forbidden set.
private lemma a52_size_bound (N n c : ℝ) (M : ℕ) (hM : 2 ≤ M) (hn : 0 < n) (hnN : n ≤ N)
(hc : 0 ≤ c) (h : c * (16 * N / n) ^ M ≤ N) : 256 * c ≤ n := by
set x := 16 * N / n with hx
have hN : 0 < N := lt_of_lt_of_le hn hnN
have hx16 : 16 ≤ x := by rw [hx, le_div_iff₀ hn]; linarith
have h1 : x ^ 2 ≤ x ^ M := pow_le_pow_right₀ (by linarith) hM
have h2 : c * (16 * x) ≤ N := by nlinarith
have h3 : 256 * c * N ≤ n * N := by
have : c * (16 * x) * n = 256 * c * N := by rw [hx]; field_simp; ring
nlinarith
exact le_of_mul_le_mul_right h3 hN
-- Cube lemma with finitely many nontrivial linear constraints `α * a + ∑ c_k v_k + f ≠ 0`
-- on the base point `a` and the generators `v`.
private lemma a52_cube_lin_aux (K : ℕ) : ∀ (N : ℕ) (A : Finset ℕ)
(C : Finset ((Fin K → ℤ) × ℤ × ℤ)), A ⊆ Finset.Icc 1 N → A.Nonempty →
(∀ q ∈ C, q.2.1 ≠ 0 ∨ q.1 ≠ 0) →
((C.card : ℝ) + 1) * (16 * (N : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ N →
∃ (a : ℕ) (v : Fin K → ℕ), (∀ k, 0 < v k) ∧
(∀ q ∈ C, q.2.1 * (a : ℤ) + ∑ k, q.1 k * (v k : ℤ) + q.2.2 ≠ 0) ∧
∀ ε, a + a52_cubeSum v ε ∈ A := by
induction K with
| zero =>
intro N A C hA hne hC h
have hn0 : 0 < A.card := hne.card_pos
have hnN : A.card ≤ N := by simpa using Finset.card_le_card hA
have hbig : 256 * ((C.card : ℝ) + 1) ≤ A.card :=
a52_size_bound N A.card _ (2 ^ (0 + 1)) (by norm_num)
(by exact_mod_cast hn0) (by exact_mod_cast hnN) (by positivity) h
have hlt : (C.image (fun q => (-q.2.2 / q.2.1).toNat)).card < A.card := by
have h1 : (C.image (fun q => (-q.2.2 / q.2.1).toNat)).card ≤ C.card :=
Finset.card_image_le
have : (C.card : ℝ) < A.card := by linarith
have : C.card < A.card := by exact_mod_cast this
omega
obtain ⟨a, haA, haB⟩ := Finset.exists_mem_notMem_of_card_lt_card hlt
refine ⟨a, Fin.elim0, fun k => k.elim0, ?_, fun ε => by simpa [a52_cubeSum] using haA⟩
intro q hq heq
have hα : q.2.1 ≠ 0 := by
rcases hC q hq with h | h
· exact h
· exact absurd (funext fun k => k.elim0) h
simp only [Finset.univ_eq_empty, Finset.sum_empty, add_zero] at heq
apply haB
refine Finset.mem_image.2 ⟨q, hq, ?_⟩
have : -q.2.2 / q.2.1 = a := by
rw [show -q.2.2 = q.2.1 * a by linarith]; exact Int.mul_ediv_cancel_left _ hα
rw [this]; simp
| succ K ih =>
intro N A C hA hne hC h
have hn0 : 0 < A.card := hne.card_pos
have hnN : A.card ≤ N := by simpa using Finset.card_le_card hA
have hbig : 256 * ((C.card : ℝ) + 1) ≤ A.card :=
a52_size_bound N A.card _ (2 ^ (K + 1 + 1))
(by calc 2 = 2 ^ 1 := by norm_num
_ ≤ 2 ^ (K + 1 + 1) := Nat.pow_le_pow_right (by norm_num) (by omega))
(by exact_mod_cast hn0) (by exact_mod_cast hnN) (by positivity) h
set F : Finset ℤ := C.image (fun q => -q.2.2 / q.1 0) with hF_def
have hFc : F.card ≤ C.card := Finset.card_image_le
have hbig' : 16 * (F.card + 1) ≤ A.card := by
have : (16 : ℝ) * (C.card + 1) ≤ A.card := by linarith
have : 16 * (C.card + 1) ≤ A.card := by exact_mod_cast this
omega
obtain ⟨d, hdI, hdr, hdF, -⟩ := a52_good_d_exists N A F hA hbig'
have hd0 : 0 < d := (Finset.mem_Icc.1 hdI).1
set A' := A.filter (fun x => x + d ∈ A) with hA'_def
set C' : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
(C.filter (fun q => q.2.1 ≠ 0 ∨ Fin.tail q.1 ≠ 0)).image
(fun q => (Fin.tail q.1, q.2.1, q.2.2 + q.1 0 * d)) with hC'_def
have hC'card : C'.card ≤ C.card :=
Finset.card_image_le.trans (Finset.card_filter_le _ _)
have hA'sub : A' ⊆ Finset.Icc 1 N := (Finset.filter_subset _ _).trans hA
have hA'pos : 0 < A'.card := by
rcases Nat.eq_zero_or_pos A'.card with hc | hc
· rw [hc, mul_zero, Nat.le_zero, pow_eq_zero_iff two_ne_zero] at hdr
omega
· exact hc
have hC' : ∀ q ∈ C', q.2.1 ≠ 0 ∨ q.1 ≠ 0 := by
intro q hq
obtain ⟨q0, hq0, rfl⟩ := Finset.mem_image.1 hq
exact (Finset.mem_filter.1 hq0).2
have hstep : ((C'.card : ℝ) + 1) * (16 * (N : ℝ) / A'.card) ^ (2 ^ (K + 1)) ≤ N := by
have hcc : (C'.card : ℝ) ≤ C.card := by exact_mod_cast hC'card
refine a52_density_step N A.card A'.card (C.card + 1) (C'.card + 1) K
(by exact_mod_cast hn0) (by exact_mod_cast hA'pos) (by positivity) (by positivity)
(by linarith) (by exact_mod_cast hdr) h
obtain ⟨a, v, hv, hlin, hmem⟩ := ih N A' C' hA'sub (Finset.card_pos.1 hA'pos) hC' hstep
refine ⟨a, Fin.cons d v, ?_, ?_, ?_⟩
· intro k
refine Fin.cases hd0 (fun i => ?_) k
simpa using hv i
· intro q hq
rw [Fin.sum_univ_succ]
simp only [Fin.cons_zero, Fin.cons_succ]
by_cases hgood : q.2.1 ≠ 0 ∨ Fin.tail q.1 ≠ 0
· have := hlin _ (Finset.mem_image.2 ⟨q, Finset.mem_filter.2 ⟨hq, hgood⟩, rfl⟩)
simp only [Fin.tail] at this
intro h; apply this; linarith
· push_neg at hgood
obtain ⟨hα, htail⟩ := hgood
have hts : ∀ i : Fin K, q.1 i.succ = 0 := fun i => congrFun htail i
have hc0 : q.1 0 ≠ 0 := by
rcases hC q hq with h | h
· exact absurd hα h
· intro h0; apply h; funext k
exact Fin.cases h0 (fun i => hts i) k
simp only [hα, hts, zero_mul, Finset.sum_const_zero, add_zero, zero_add]
intro heq
apply hdF
refine Finset.mem_image.2 ⟨q, hq, ?_⟩
rw [show -q.2.2 = q.1 0 * d by linarith]; exact Int.mul_ediv_cancel_left _ hc0
· intro ε
rw [a52_cubeSum_cons]
have hm := hmem (Fin.tail ε)
rw [hA'_def, Finset.mem_filter] at hm
cases ε 0
· simpa using hm.1
· simpa [add_comm, add_left_comm, add_assoc] using hm.2
-- Constraints encoding distinctness of the cube vertices.
private def a52_vertexConstraints (K : ℕ) : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
((Finset.univ : Finset ((Fin K → Bool) × (Fin K → Bool))).filter (fun p => p.1 ≠ p.2)).image
(fun p => (fun k => (if p.1 k then 1 else 0) - (if p.2 k then 1 else 0), 0, 0))
-- Coefficient of `v k` in the shift `r(ε, h)`.
private def a52_shiftCoeff {K : ℕ} (ε : Fin K → Bool) (h : ℕ) (k : Fin K) : ℤ :=
if ε k then ((h + 1 + K : ℕ) : ℤ) - ((k.1 : ℤ) + 1) else 0
-- Constraints encoding distinctness of the shifts.
private def a52_shiftConstraints (K H : ℕ) : Finset ((Fin K → ℤ) × ℤ × ℤ) :=
((Finset.univ : Finset (((Fin K → Bool) × Fin H) × ((Fin K → Bool) × Fin H))).filter
(fun p => p.1 ≠ p.2)).image
(fun p => (fun k => a52_shiftCoeff p.1.1 p.1.2.1 k - a52_shiftCoeff p.2.1 p.2.2.1 k,
((p.1.2.1 + 1 + K : ℕ) : ℤ) - ((p.2.2.1 + 1 + K : ℕ) : ℤ), 0))
private lemma a52_constraints_nontrivial (K H : ℕ) :
∀ q ∈ a52_vertexConstraints K ∪ a52_shiftConstraints K H, q.2.1 ≠ 0 ∨ q.1 ≠ 0 := by
intro q hq
rcases Finset.mem_union.1 hq with hq | hq
· obtain ⟨⟨ε, ε'⟩, hp, rfl⟩ := Finset.mem_image.1 hq
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hp
right
obtain ⟨k, hk⟩ := Function.ne_iff.1 hp
intro h0
have := congrFun h0 k
simp only [Pi.zero_apply] at this
cases h1 : ε k <;> cases h2 : ε' k <;> simp_all
· obtain ⟨⟨⟨ε, h⟩, ⟨ε', h'⟩⟩, hp, rfl⟩ := Finset.mem_image.1 hq
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hp
by_cases hh : h = h'
· subst hh
right
have hne : ε ≠ ε' := fun he => hp (by rw [he])
obtain ⟨k, hk⟩ := Function.ne_iff.1 hne
intro h0
have := congrFun h0 k
simp only [Pi.zero_apply, a52_shiftCoeff] at this
have hk2 := k.2
cases h1 : ε k <;> cases h2 : ε' k <;> simp_all <;> omega
· left
intro h0
apply hh
apply Fin.ext
push_cast at h0
omega
private lemma a52_vertex_diff {K : ℕ} (a : ℤ) (v : Fin K → ℤ) (ε ε' : Fin K → Bool) :
(a + ∑ k, if ε k then v k else 0) - (a + ∑ k, if ε' k then v k else 0) =
∑ k, ((if ε k then 1 else 0) - (if ε' k then 1 else 0)) * v k := by
rw [add_sub_add_left_eq_sub, ← Finset.sum_sub_distrib]
refine Finset.sum_congr rfl fun k _ => ?_
split_ifs <;> ring
private lemma a52_shift_diff {K : ℕ} (a : ℤ) (v : Fin K → ℤ) (ε ε' : Fin K → Bool) (h h' : ℕ) :
((a + ∑ k, if ε k then v k else 0) * ((h + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε k then v k else 0)) -
((a + ∑ k, if ε' k then v k else 0) * ((h' + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε' k then v k else 0)) =
(((h + 1 + K : ℕ) : ℤ) - ((h' + 1 + K : ℕ) : ℤ)) * a +
∑ k, (a52_shiftCoeff ε h k - a52_shiftCoeff ε' h' k) * v k := by
have : ∀ k, (a52_shiftCoeff ε h k - a52_shiftCoeff ε' h' k) * v k =
(if ε k then v k else 0) * ((h + 1 + K : ℕ) : ℤ) - ((k.1 : ℤ) + 1) * (if ε k then v k else 0)
- ((if ε' k then v k else 0) * ((h' + 1 + K : ℕ) : ℤ)
- ((k.1 : ℤ) + 1) * (if ε' k then v k else 0)) := by
intro k; simp only [a52_shiftCoeff]; split_ifs <;> ring
simp only [this, Finset.sum_sub_distrib, add_mul, Finset.sum_mul]
ring
/-- Qualitative Lemma 5.2 of TT (arXiv:2512.01739v2, p. 50), without the window `[P/2, P]`:
for all `K, H` there are `p₀, v` with the `2^K` numbers `p_ε = p₀ + ∑ ε_k v_k` distinct primes and
the shifts `r_{ε,h+K} = p_ε (h+K) - ∑_k k ε_k v_k` (`ε ∈ {0,1}^K`, `1 ≤ h ≤ H`) pairwise distinct.
(The paper needs the quantitative form with the primes in `[P/2, P]`.) -/
-- Asymptotic inequality behind the quantitative cube lemma (θ < 1).
private lemma a52_quant_asymp_real (θ D : ℝ) (hθ : θ < 1) :
∀ᶠ y : ℝ in Filter.atTop, 4 * Real.log y + 2 * y ^ θ * (Real.log D + Real.log y) + Real.log 6 ≤ y := by
have h1 : (fun y : ℝ => Real.log y) =o[Filter.atTop] (fun y => y) := Real.isLittleO_log_id_atTop
have hr : 0 < 1 - θ := by linarith
have h3 : (fun y : ℝ => y ^ θ * (Real.log D + Real.log y)) =o[Filter.atTop] (fun y => y) := by
have hc : (fun _ : ℝ => Real.log D) =o[Filter.atTop] (fun y : ℝ => y ^ (1 - θ)) :=
Asymptotics.isLittleO_const_left.2
(Or.inr (tendsto_norm_atTop_atTop.comp (tendsto_rpow_atTop hr)))
have hl : (fun y : ℝ => Real.log D + Real.log y) =o[Filter.atTop] (fun y => y ^ (1 - θ)) :=
hc.add (isLittleO_log_rpow_atTop hr)
have := (Asymptotics.isBigO_refl (fun y : ℝ => y ^ θ) Filter.atTop).mul_isLittleO hl
refine this.congr' Filter.EventuallyEq.rfl ?_
filter_upwards [Filter.eventually_gt_atTop 0] with y hy
rw [← Real.rpow_add hy]; simp
have h4 : (fun _ : ℝ => (1:ℝ)) =o[Filter.atTop] (fun y => y) := Asymptotics.isLittleO_const_id_atTop 1
have hsum : (fun y : ℝ => 4 * Real.log y + 2 * y ^ θ * (Real.log D + Real.log y) + Real.log 6)
=o[Filter.atTop] (fun y => y) := by
have := ((h1.const_mul_left 4).add (h3.const_mul_left 2)).add (h4.const_mul_left (Real.log 6))
refine this.congr_left (fun y => by ring)
filter_upwards [hsum.bound one_pos, Filter.eventually_ge_atTop 0] with y hy hy0
rw [Real.norm_eq_abs, Real.norm_eq_abs, abs_of_nonneg hy0, one_mul] at hy
exact (le_abs_self _).trans hy
-- The same inequality along naturals `P`, in the shape needed for `a52_cube_lin_aux`.
private lemma a52_quant_asymp_nat (θ D : ℝ) (hθ : θ < 1) (hD : 1 ≤ D) :
∃ P1 : ℕ, ∀ P : ℕ, P1 ≤ P → 1 ≤ Real.log P ∧
3 * Real.log P ^ 4 * (D * Real.log P) ^ (2 * Real.log P ^ θ) ≤ (P : ℝ) / 2 := by
have ht : Filter.Tendsto (fun P : ℕ => Real.log P) Filter.atTop Filter.atTop :=
Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
obtain ⟨P1, hP1⟩ := Filter.eventually_atTop.1
(ht.eventually ((a52_quant_asymp_real θ D hθ).and (Filter.eventually_ge_atTop 1)))
refine ⟨P1, fun P hP => ?_⟩
obtain ⟨h, hy1⟩ := hP1 P hP
refine ⟨hy1, ?_⟩
set y := Real.log P with hy
have hP0 : (0 : ℝ) < P := by
by_contra hc
have : (P : ℝ) = 0 := le_antisymm (not_lt.1 hc) (Nat.cast_nonneg _)
rw [hy, this, Real.log_zero] at hy1; linarith
have hy0 : 0 < y := by linarith
have hDy : 0 < D * y := by positivity
have hD0 : 0 < D := by linarith
rw [← Real.log_le_log_iff (by positivity) (by positivity), Real.log_mul (by positivity)
(by positivity), Real.log_mul (by positivity) (by positivity), Real.log_pow,
Real.log_rpow hDy, Real.log_mul hD0.ne' hy0.ne', Real.log_div hP0.ne' (by norm_num),
← hy]
have h6 : Real.log 6 = Real.log 3 + Real.log 2 := by
rw [← Real.log_mul (by norm_num) (by norm_num)]; norm_num
push_cast
linarith
-- Counting bound on the constraint set.
private lemma a52_quant_constraints_card (K H : ℕ) :
((a52_vertexConstraints K ∪ a52_shiftConstraints K H).card : ℝ) ≤
((2 : ℝ) ^ K) ^ 2 + ((2 : ℝ) ^ K * H) ^ 2 := by
have h1 : (a52_vertexConstraints K).card ≤ (2 ^ K) ^ 2 := by
unfold a52_vertexConstraints
refine (Finset.card_image_le).trans ((Finset.card_filter_le _ _).trans ?_)
rw [Finset.card_univ, Fintype.card_prod, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin,
sq]
have h2 : (a52_shiftConstraints K H).card ≤ (2 ^ K * H) ^ 2 := by
unfold a52_shiftConstraints
refine (Finset.card_image_le).trans ((Finset.card_filter_le _ _).trans ?_)
rw [Finset.card_univ, Fintype.card_prod, Fintype.card_prod, Fintype.card_fun, Fintype.card_bool,
Fintype.card_fin, Fintype.card_fin, sq]
have h3 := (Finset.card_union_le (a52_vertexConstraints K) (a52_shiftConstraints K H)).trans
(Nat.add_le_add h1 h2)
exact_mod_cast h3
/- Quantitative Lemma 5.2 of Tao–Teräväinen (arXiv:2512.01739v2, p. 50): K and H may grow with P.
For every θ < 1 and all large P: whenever 2^K ≤ (log P)^θ and H ≤ (log P)^θ, there are p₀, v with
the 2^K numbers p_ε = p₀ + Σ ε_k v_k distinct primes in the window (P/2, P], and the shifts
r_{ε,h+K} = p_ε (h+K) − Σ_k k ε_k v_k (ε ∈ {0,1}^K, 1 ≤ h ≤ H) pairwise distinct.
(The paper takes 2^K ≈ H ≈ (log P)^{2/3}; see `a52_hilbert_cube_primes_quant_two_thirds`.) -/
private theorem a52_hilbert_cube_primes_quant (θ : ℝ) (hθ : θ < 1) :
∃ P0 : ℕ, ∀ P : ℕ, P0 ≤ P → ∀ K H : ℕ,
(2 : ℝ) ^ K ≤ Real.log P ^ θ → (H : ℝ) ≤ Real.log P ^ θ →
∃ (p0 : ℤ) (v : Fin K → ℤ),
(∀ ε : Fin K → Bool, ∃ p : ℕ, p.Prime ∧ P < 2 * p ∧ p ≤ P ∧
(p : ℤ) = p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) := by
obtain ⟨c, hc, N0, hN0⟩ := a52_primes_in_dyadic_lower
set D : ℝ := 32 / c + 1 with hD
have hD1 : 1 ≤ D := by rw [hD]; linarith [div_pos (by norm_num : (0:ℝ) < 32) hc]
obtain ⟨P1, hP1⟩ := a52_quant_asymp_nat θ D hθ hD1
refine ⟨max P1 (2 * N0 + 6), fun P hP K H hK hH => ?_⟩
have hPP1 : P1 ≤ P := le_trans (le_max_left _ _) hP
have hPN : 2 * N0 + 6 ≤ P := le_trans (le_max_right _ _) hP
obtain ⟨hy1, hasym⟩ := hP1 P hPP1
set C := a52_vertexConstraints K ∪ a52_shiftConstraints K H with hCdef
set n := P / 2 with hndef
have hnN0 : N0 ≤ n := by omega
have hn3 : 3 ≤ n := by omega
set A := (Finset.Ioc n (2 * n)).filter Nat.Prime with hAdef
set y := Real.log P with hy
set L := y ^ θ with hL
have hnr : (3 : ℝ) ≤ n := by exact_mod_cast hn3
have hlogn : 0 < Real.log n := Real.log_pos (by linarith)
have hlognP : Real.log n ≤ y :=
Real.log_le_log (by linarith) (by exact_mod_cast Nat.div_le_self P 2)
have hcard : c * (n : ℝ) / Real.log n ≤ (A.card : ℝ) := hN0 n hnN0
have hApos : (0 : ℝ) < A.card := lt_of_lt_of_le (by positivity) hcard
have hne : A.Nonempty := Finset.card_pos.mp (by exact_mod_cast hApos)
have hsub : A ⊆ Finset.Icc 1 (2 * n) := by
intro x hx
simp only [hAdef, Finset.mem_filter, Finset.mem_Ioc] at hx
exact Finset.mem_Icc.mpr ⟨by omega, hx.1.2⟩
have hbound : 16 * ((2 * n : ℕ) : ℝ) / A.card ≤ D * y := by
rw [div_le_iff₀ hApos]
calc 16 * ((2 * n : ℕ) : ℝ) = (32 / c * Real.log n) * (c * n / Real.log n) := by
push_cast; field_simp; ring
_ ≤ (32 / c * Real.log n) * A.card :=
mul_le_mul_of_nonneg_left hcard (by positivity)
_ ≤ (D * y) * A.card := by
apply mul_le_mul_of_nonneg_right _ hApos.le
have h32 : 0 ≤ 32 / c := by positivity
calc 32 / c * Real.log n ≤ 32 / c * y := mul_le_mul_of_nonneg_left hlognP h32
_ ≤ D * y := mul_le_mul_of_nonneg_right (by rw [hD]; linarith) (by linarith)
have hL1 : 1 ≤ L := le_trans (one_le_pow₀ (by norm_num)) hK
have hLy : L ≤ y := by
have := Real.rpow_le_rpow_of_exponent_le hy1 hθ.le
rwa [Real.rpow_one] at this
have hH0 : (0 : ℝ) ≤ H := Nat.cast_nonneg H
have h2K0 : (0 : ℝ) ≤ 2 ^ K := by positivity
have hCcard : (C.card : ℝ) + 1 ≤ 3 * y ^ 4 := by
have h1 := a52_quant_constraints_card K H
have hKH : (2 : ℝ) ^ K * H ≤ L * L := mul_le_mul hK hH hH0 (by linarith)
have hsq1 : ((2 : ℝ) ^ K) ^ 2 ≤ L ^ 2 := pow_le_pow_left₀ h2K0 hK 2
have hsq2 : ((2 : ℝ) ^ K * H) ^ 2 ≤ (L * L) ^ 2 := pow_le_pow_left₀ (by positivity) hKH 2
have hL4 : L ^ 2 ≤ L ^ 4 := pow_le_pow_right₀ hL1 (by norm_num)
have hL4' : (1 : ℝ) ≤ L ^ 4 := one_le_pow₀ hL1
have hLy4 : L ^ 4 ≤ y ^ 4 := pow_le_pow_left₀ (by linarith) hLy 4
have hC : (C.card : ℝ) ≤ ((2 : ℝ) ^ K) ^ 2 + ((2 : ℝ) ^ K * H) ^ 2 := h1
nlinarith
have hDy1 : 1 ≤ D * y := by nlinarith
have hX0 : 0 ≤ 16 * ((2 * n : ℕ) : ℝ) / A.card := by positivity
have hexp : (((2 ^ (K + 1) : ℕ) : ℝ)) ≤ 2 * L := by
push_cast; rw [pow_succ]; linarith
have hXpow : (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ (D * y) ^ (2 * L) := by
calc (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤ (D * y) ^ (2 ^ (K + 1)) :=
pow_le_pow_left₀ hX0 hbound _
_ = (D * y) ^ (((2 ^ (K + 1) : ℕ) : ℝ)) := (Real.rpow_natCast _ _).symm
_ ≤ (D * y) ^ (2 * L) := Real.rpow_le_rpow_of_exponent_le hDy1 hexp
have hNP : (P : ℝ) / 2 ≤ ((2 * n : ℕ) : ℝ) := by
have h1 : P ≤ 2 * n + 1 := by omega
have h2 : (P : ℝ) ≤ ((2 * n : ℕ) : ℝ) + 1 := by exact_mod_cast h1
have h3 : (6 : ℝ) ≤ P := by exact_mod_cast (le_trans (by omega) hPN)
linarith
have hpow : ((C.card : ℝ) + 1) * (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1)) ≤
((2 * n : ℕ) : ℝ) := by
calc ((C.card : ℝ) + 1) * (16 * ((2 * n : ℕ) : ℝ) / A.card) ^ (2 ^ (K + 1))
≤ (3 * y ^ 4) * (D * y) ^ (2 * L) :=
mul_le_mul hCcard hXpow (by positivity) (by positivity)
_ ≤ (P : ℝ) / 2 := hasym
_ ≤ _ := hNP
obtain ⟨a, v, -, hlin, hmem⟩ :=
a52_cube_lin_aux K (2 * n) A C hsub hne (a52_constraints_nontrivial K H) hpow
have hcast : ∀ ε : Fin K → Bool,
((a + a52_cubeSum v ε : ℕ) : ℤ) = (a : ℤ) + ∑ k, if ε k then (v k : ℤ) else 0 := by
intro ε; simp [a52_cubeSum, Nat.cast_sum, Nat.cast_ite]
refine ⟨a, fun k => v k, fun ε => ?_, ?_, ?_⟩
· have h := hmem ε
simp only [hAdef, Finset.mem_filter, Finset.mem_Ioc] at h
exact ⟨_, h.2, by omega, by omega, hcast ε⟩
· intro ε ε' heq
by_contra hne'
have hq : ((fun k => (if ε k then (1 : ℤ) else 0) - (if ε' k then 1 else 0)), (0 : ℤ),
(0 : ℤ)) ∈ C :=
Finset.mem_union_left _ (Finset.mem_image.2 ⟨(ε, ε'), Finset.mem_filter.2 ⟨Finset.mem_univ _, hne'⟩, rfl⟩)
apply hlin _ hq
have hd := a52_vertex_diff (a : ℤ) (fun k => (v k : ℤ)) ε ε'
simp only at heq hd ⊢
rw [heq, sub_self] at hd
simp only [zero_mul, zero_add, add_zero]
exact hd.symm
· rintro ⟨ε, h⟩ ⟨ε', h'⟩ heq
by_contra hne'
have hq : ((fun k => a52_shiftCoeff ε h.1 k - a52_shiftCoeff ε' h'.1 k),
((h.1 + 1 + K : ℕ) : ℤ) - ((h'.1 + 1 + K : ℕ) : ℤ), (0 : ℤ)) ∈ C :=
Finset.mem_union_right _
(Finset.mem_image.2 ⟨((ε, h), (ε', h')), Finset.mem_filter.2 ⟨Finset.mem_univ _, hne'⟩, rfl⟩)
apply hlin _ hq
have hd := a52_shift_diff (a : ℤ) (fun k => (v k : ℤ)) ε ε' h.1 h'.1
simp only at heq hd ⊢
rw [heq, sub_self] at hd
rw [add_zero]
exact hd.symm
private theorem a52_hilbert_cube_primes_quant_two_thirds :
∃ P0 : ℕ, ∀ P : ℕ, P0 ≤ P → ∀ K H : ℕ,
(2 : ℝ) ^ K ≤ Real.log P ^ ((2 : ℝ) / 3) → (H : ℝ) ≤ Real.log P ^ ((2 : ℝ) / 3) →
∃ (p0 : ℤ) (v : Fin K → ℤ),
(∀ ε : Fin K → Bool, ∃ p : ℕ, p.Prime ∧ P < 2 * p ∧ p ≤ P ∧
(p : ℤ) = p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) ∧
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) :=
a52_hilbert_cube_primes_quant (2 / 3) (by norm_num)
private theorem mf_log_factorial (n : ℕ) :
Real.log (n.factorial : ℝ) =
∑ p ∈ (Finset.Iic n).filter Nat.Prime, (padicValNat p n.factorial : ℝ) * Real.log p := by
have hsub : (n.factorial).factorization.support ⊆ (Finset.Iic n).filter Nat.Prime := by
intro p hp
rw [Nat.support_factorization] at hp
have hpp := Nat.prime_of_mem_primeFactors hp
have hdvd := Nat.dvd_of_mem_primeFactors hp
simp only [Finset.mem_filter, Finset.mem_Iic]
exact ⟨(hpp.dvd_factorial).1 hdvd, hpp⟩
rw [Real.log_nat_eq_sum_factorization, Finsupp.sum_of_support_subset _ hsub _ (by intros; simp)]
apply Finset.sum_congr rfl
intro p hp
rw [Nat.factorization_def _ (Finset.mem_filter.1 hp).2]
/-- `v_p(n!) ≥ ⌊n/p⌋ > n/p - 1`. -/
private theorem mf_padic_lower (n p : ℕ) (hp : p.Prime) :
(n : ℝ) / p - 1 ≤ (padicValNat p n.factorial : ℝ) := by
haveI := Fact.mk hp
have hp0 : (0:ℝ) < p := by exact_mod_cast hp.pos
have h1 : n / p ≤ padicValNat p n.factorial := by
rw [padicValNat_factorial (b := Nat.log p n + 1) (Nat.lt_succ_self _)]
rcases Nat.lt_or_ge n p with h | h
· rw [Nat.div_eq_of_lt h]; exact Nat.zero_le _
· have hlog : 0 < Nat.log p n := Nat.log_pos hp.one_lt h
have hmem : 1 ∈ Finset.Ico 1 (Nat.log p n + 1) := by
simp only [Finset.mem_Ico]; omega
calc n / p = n / p ^ 1 := by rw [pow_one]
_ ≤ _ := Finset.single_le_sum (f := fun i => n / p ^ i) (fun i _ => Nat.zero_le _) hmem
have h2 : (n : ℝ) < ((n / p : ℕ) : ℝ) * p + p := by
exact_mod_cast Nat.lt_div_mul_add hp.pos
have h3 : (n : ℝ) / p - 1 < ((n / p : ℕ) : ℝ) := by
rw [div_sub_one hp0.ne', div_lt_iff₀ hp0]; linarith
have h4 : ((n / p : ℕ) : ℝ) ≤ (padicValNat p n.factorial : ℝ) := by exact_mod_cast h1
linarith
/-- `(p - 1) v_p(n!) ≤ n`. -/
private theorem mf_padic_upper (n p : ℕ) (hp : p.Prime) :
((p : ℝ) - 1) * (padicValNat p n.factorial : ℝ) ≤ n := by
haveI := Fact.mk hp
rcases Nat.eq_zero_or_pos n with rfl | hn
· simp
have h := sub_one_mul_padicValNat_factorial_lt_of_ne_zero p hn.ne'
have h' : ((p - 1 : ℕ) : ℝ) * (padicValNat p n.factorial : ℝ) ≤ n := by exact_mod_cast h.le
rwa [Nat.cast_sub hp.one_le, Nat.cast_one] at h'
/-- Chebyshev: `θ(n) ≤ n log 4`. -/
private theorem mf_theta (n : ℕ) :
∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p ≤ Real.log 4 * n := by
have h := Chebyshev.theta_le_log4_mul_x (x := (n : ℝ)) (Nat.cast_nonneg n)
rw [Chebyshev.theta_eq_sum_Icc, Nat.floor_natCast] at h
have : Finset.Icc 0 n = Finset.Iic n := by ext; simp
rwa [this] at h
private theorem mf_log_fact_le (n : ℕ) : Real.log (n.factorial : ℝ) ≤ n * Real.log n := by
have h0 : (0:ℝ) < n.factorial := by exact_mod_cast Nat.factorial_pos n
have h : (n.factorial : ℝ) ≤ (n:ℝ) ^ n := by exact_mod_cast Nat.factorial_le_pow n
calc Real.log (n.factorial : ℝ) ≤ Real.log ((n:ℝ)^n) := Real.log_le_log h0 h
_ = n * Real.log n := by rw [Real.log_pow]
private theorem mf_log_fact_ge (n : ℕ) : n * Real.log n - n ≤ Real.log (n.factorial : ℝ) := by
have h0 : (0:ℝ) < n.factorial := by exact_mod_cast Nat.factorial_pos n
rcases Nat.eq_zero_or_pos n with rfl | hn
· simp
have h := Real.pow_div_factorial_le_exp (n : ℝ) (Nat.cast_nonneg n) n
have hn' : (0:ℝ) < n := by exact_mod_cast hn
have hpos : (0:ℝ) < (n:ℝ)^n / n.factorial := by positivity
have := Real.log_le_log hpos h
rw [Real.log_exp, Real.log_div (by positivity) h0.ne', Real.log_pow] at this
linarith
private theorem mf_term_le (p : ℕ) (hp : 2 ≤ p) :
Real.log p / (p * (p - 1)) ≤ 4 * (1 / (p : ℝ) ^ (3/2 : ℝ)) := by
have hp' : (2:ℝ) ≤ p := by exact_mod_cast hp
have hp0 : (0:ℝ) < p := by linarith
have hs0 : 0 < (p:ℝ) ^ (1/2 : ℝ) := Real.rpow_pos_of_pos hp0 _
have hss : (p:ℝ) ^ (1/2 : ℝ) * (p:ℝ) ^ (1/2 : ℝ) = p := by
rw [← Real.rpow_add hp0]; norm_num
have h32 : (p:ℝ) ^ (3/2 : ℝ) = p * (p:ℝ) ^ (1/2 : ℝ) := by
rw [show (3/2:ℝ) = 1 + 1/2 by norm_num, Real.rpow_add hp0, Real.rpow_one]
have hlog : Real.log p ≤ 2 * (p:ℝ) ^ (1/2 : ℝ) := by
have := Real.log_le_rpow_div (x := (p:ℝ)) (ε := 1/2) hp0.le (by norm_num)
have e : (p:ℝ) ^ (1/2 : ℝ) / (1/2) = 2 * (p:ℝ) ^ (1/2 : ℝ) := by ring
linarith
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by linarith)
rw [h32, mul_one_div, div_le_div_iff₀ (by nlinarith) (by positivity)]
have h1 : Real.log p * (p:ℝ) ^ (1/2 : ℝ) ≤ 2 * p := by nlinarith
nlinarith
/-- `∑_{p ≤ n} log p / (p (p - 1))` is bounded. -/
private theorem mf_tail_bound : ∃ C0 : ℝ, ∀ n : ℕ,
∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / (p * (p - 1)) ≤ C0 := by
have hsum : Summable (fun m : ℕ => 4 * (1 / (m : ℝ) ^ (3/2 : ℝ))) :=
(Real.summable_one_div_nat_rpow.2 (by norm_num)).mul_left 4
refine ⟨∑' m : ℕ, 4 * (1 / (m : ℝ) ^ (3/2 : ℝ)), fun n => ?_⟩
calc _ ≤ ∑ p ∈ (Finset.Iic n).filter Nat.Prime, 4 * (1 / (p : ℝ) ^ (3/2 : ℝ)) :=
Finset.sum_le_sum fun p hp => mf_term_le p (Finset.mem_filter.1 hp).2.two_le
_ ≤ _ := hsum.sum_le_tsum _ (fun i _ => by positivity)
/-- Mertens' first theorem: `∑_{p ≤ n} log p / p = log n + O(1)`. -/
private theorem u_mertens_first :
∃ C : ℝ, ∀ n : ℕ, 2 ≤ n →
|(∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) - Real.log n| ≤ C := by
obtain ⟨C0, hC0⟩ := mf_tail_bound
refine ⟨Real.log 4 + 1 + |C0|, fun n hn => ?_⟩
have hn0 : (0:ℝ) < n := by exact_mod_cast (show 0 < n by omega)
have hL := mf_log_factorial n
have hup : (n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p)
≤ Real.log (n.factorial : ℝ) + Real.log 4 * n := by
have : (n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) ≤
∑ p ∈ (Finset.Iic n).filter Nat.Prime,
((padicValNat p n.factorial : ℝ) * Real.log p + Real.log p) := by
rw [Finset.mul_sum]
apply Finset.sum_le_sum
intro p hp
have hpp := (Finset.mem_filter.1 hp).2
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by exact_mod_cast hpp.one_lt.le)
have hv := mf_padic_lower n p hpp
have e : (n:ℝ) * (Real.log p / p) = ((n:ℝ) / p) * Real.log p := by ring
rw [e]; nlinarith
rw [Finset.sum_add_distrib, ← hL] at this
linarith [mf_theta n]
have hlo : Real.log (n.factorial : ℝ) ≤
(n:ℝ) * (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) + n * C0 := by
rw [hL]
have : ∑ p ∈ (Finset.Iic n).filter Nat.Prime, (padicValNat p n.factorial : ℝ) * Real.log p ≤
∑ p ∈ (Finset.Iic n).filter Nat.Prime,
((n:ℝ) * (Real.log p / p) + n * (Real.log p / (p * (p - 1)))) := by
apply Finset.sum_le_sum
intro p hp
have hpp := (Finset.mem_filter.1 hp).2
have hp2 : (2:ℝ) ≤ p := by exact_mod_cast hpp.two_le
have hpne : (p:ℝ) ≠ 0 := by linarith
have hp1 : (p:ℝ) - 1 ≠ 0 := by linarith
have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by linarith)
have hv := mf_padic_upper n p hpp
have key : (n:ℝ) * (Real.log p / p) + n * (Real.log p / (p * (p - 1)))
= (n:ℝ) / (p - 1) * Real.log p := by
field_simp; ring
rw [key]
have : (padicValNat p n.factorial : ℝ) ≤ n / (p - 1) := by
rw [le_div_iff₀ (by linarith)]; linarith
exact mul_le_mul_of_nonneg_right this hlog0
rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] at this
have := hC0 n
nlinarith
have h1 := mf_log_fact_le n
have h2 := mf_log_fact_ge n
have hSup : (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) ≤ Real.log n + Real.log 4 := by
by_contra h; push_neg at h; nlinarith
have hSlo : Real.log n - 1 - C0 ≤ (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) := by
by_contra h; push_neg at h; nlinarith
have hl4 : 0 ≤ Real.log 4 := Real.log_nonneg (by norm_num)
rw [abs_le]; constructor
· linarith [le_abs_self C0]
· linarith [abs_nonneg C0]
private theorem ms_Iic_succ (g : ℕ → ℝ) (n : ℕ) :
∑ p ∈ (Finset.Iic (n+1)).filter Nat.Prime, g p =
∑ p ∈ (Finset.Iic n).filter Nat.Prime, g p + if (n+1).Prime then g (n+1) else 0 := by
have h : ∀ m : ℕ, Finset.Iic m = Finset.range (m+1) := by
intro m; ext x; simp [Nat.lt_succ_iff]
rw [h, h, Finset.sum_filter, Finset.sum_filter, Finset.sum_range_succ]
private theorem ms_Iic_two : (Finset.Iic 2).filter Nat.Prime = {2} := by
ext x
simp only [Finset.mem_filter, Finset.mem_Iic, Finset.mem_singleton]
constructor
· rintro ⟨h1, h2⟩
interval_cases x
· exact absurd h2 Nat.not_prime_zero
· exact absurd h2 Nat.not_prime_one
· rfl
· rintro rfl; exact ⟨le_rfl, Nat.prime_two⟩
/-- Discrete Abel summation of `1/p = (log p / p) / log p`. -/
private theorem ms_abel (n : ℕ) (hn : 2 ≤ n) :
∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1:ℝ) / p =
(∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n +
∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
induction n, hn using Nat.le_induction with
| base =>
rw [ms_Iic_two]
have hl2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne'
simp only [Finset.sum_singleton, Finset.Ico_self, Finset.sum_empty, Nat.cast_ofNat, add_zero]
field_simp
| succ n hn ih =>
have hB := ms_Iic_succ (fun p : ℕ => (1:ℝ) / p) n
have hA := ms_Iic_succ (fun p : ℕ => Real.log p / p) n
rw [Finset.sum_Ico_succ_top hn, hB, hA, ih]
have hm : ((n:ℝ) + 1) ≠ 0 := by positivity
have hL : Real.log ((n:ℝ) + 1) ≠ 0 := (Real.log_pos (by
have : (2:ℝ) ≤ n := by exact_mod_cast hn
linarith)).ne'
push_cast
split_ifs with hp
· field_simp
ring
· ring
private theorem ms_tele (F : ℕ → ℝ) (n : ℕ) (hn : 2 ≤ n) :
∑ k ∈ Finset.Ico 2 n, (F (k+1) - F k) = F n - F 2 := by
induction n, hn using Nat.le_induction with
| base => simp
| succ n hn ih => rw [Finset.sum_Ico_succ_top hn, ih]; ring
/-- For `k ≥ 2`, with `u = log k`, `v = log (k+1)`, `d = 1/u - 1/v`:
`loglog(k+1) - loglog k - d ≤ u d ≤ loglog(k+1) - loglog k` and `0 ≤ d`. -/
private theorem ms_point (k : ℕ) (hk : 2 ≤ k) :
Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k)
- (1 / Real.log k - 1 / Real.log ((k:ℝ)+1))
≤ Real.log k * (1 / Real.log k - 1 / Real.log ((k:ℝ)+1)) ∧
Real.log k * (1 / Real.log k - 1 / Real.log ((k:ℝ)+1))
≤ Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k) ∧
0 ≤ 1 / Real.log k - 1 / Real.log ((k:ℝ)+1) := by
have hk' : (2:ℝ) ≤ k := by exact_mod_cast hk
have hu : 0 < Real.log k := Real.log_pos (by linarith)
have huv : Real.log k < Real.log ((k:ℝ)+1) := Real.log_lt_log (by linarith) (by linarith)
have hv : 0 < Real.log ((k:ℝ)+1) := by linarith
have hvu1 : Real.log ((k:ℝ)+1) - Real.log k ≤ 1 := by
have h := Real.log_le_sub_one_of_pos (x := ((k:ℝ)+1)/k) (by positivity)
rw [Real.log_div (by positivity) (by positivity)] at h
have e : ((k:ℝ)+1)/k - 1 = 1/k := by field_simp; ring
have : 1/(k:ℝ) ≤ 1 := by rw [div_le_one (by positivity)]; linarith
linarith
set u := Real.log k
set v := Real.log ((k:ℝ)+1)
have hll : Real.log v - Real.log u = Real.log (v/u) := (Real.log_div hv.ne' hu.ne').symm
have hvu0 : 0 < v / u := by positivity
have hup := Real.log_le_sub_one_of_pos hvu0
have hlo := Real.one_sub_inv_le_log_of_pos hvu0
have e1 : u * (1/u - 1/v) = 1 - (v/u)⁻¹ := by field_simp
have e2 : v/u - 1 - (1/u - 1/v) - u * (1/u - 1/v) = (v - u - 1) * (v - u) / (u * v) := by
field_simp; ring
have hneg : (v - u - 1) * (v - u) / (u * v) ≤ 0 :=
div_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonpos_of_nonneg (by linarith) (by linarith))
(by positivity)
have hd : 0 ≤ 1/u - 1/v := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hu huv.le
refine ⟨by linarith, by linarith, hd⟩
/-- Mertens' second theorem: `∑_{p ≤ n} 1/p = log log n + O(1)`. -/
private theorem u_mertens_second :
∃ C : ℝ, ∀ n : ℕ, 3 ≤ n →
|(∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1 : ℝ) / p) - Real.log (Real.log n)| ≤ C := by
obtain ⟨C, hC⟩ := u_mertens_first
have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num)
have hC0 : 0 ≤ C := le_trans (abs_nonneg _) (hC 2 le_rfl)
refine ⟨2 + |Real.log (Real.log 2)| + (1 + 2 * C) / Real.log 2, fun n hn => ?_⟩
have hn2 : 2 ≤ n := by omega
have hn' : (2:ℝ) ≤ n := by exact_mod_cast hn2
have hln : Real.log 2 ≤ Real.log n := Real.log_le_log (by norm_num) hn'
have hab := ms_abel n hn2
have hD : ∑ k ∈ Finset.Ico 2 n, (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))
= 1 / Real.log 2 - 1 / Real.log n := by
calc _ = ∑ k ∈ Finset.Ico 2 n,
((fun k : ℕ => -(1 / Real.log k)) (k+1) - (fun k : ℕ => -(1 / Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele (fun k : ℕ => -(1 / Real.log k)) n hn2
_ = _ := by push_cast; ring
have hLL : ∑ k ∈ Finset.Ico 2 n,
(Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
= Real.log (Real.log n) - Real.log (Real.log 2) := by
calc _ = ∑ k ∈ Finset.Ico 2 n,
((fun k : ℕ => Real.log (Real.log k)) (k+1) - (fun k : ℕ => Real.log (Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele (fun k : ℕ => Real.log (Real.log k)) n hn2
_ = _ := by push_cast; ring
-- per-term bounds on the Abel sum
have hS_up : ∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) ≤
∑ k ∈ Finset.Ico 2 n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
+ C * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := (Finset.mem_Ico.1 hk).1
obtain ⟨_, h2, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
have hS_lo : ∑ k ∈ Finset.Ico 2 n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
- (1 + C) * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) ≤
∑ k ∈ Finset.Ico 2 n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := (Finset.mem_Ico.1 hk).1
obtain ⟨h1, _, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
rw [Finset.sum_add_distrib, ← Finset.mul_sum, hLL, hD] at hS_up
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, hLL, hD] at hS_lo
-- the boundary term
have hAn := abs_le.1 (hC n hn2)
have hlnpos : 0 < Real.log n := by linarith
have hB1 : (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n ≤ 1 + C / Real.log 2 := by
rw [div_le_iff₀ hlnpos]
have : C / Real.log 2 * Real.log n ≥ C := by
rw [ge_iff_le, div_mul_eq_mul_div, le_div_iff₀ hl2]; nlinarith
nlinarith
have hB2 : 1 - C / Real.log 2 ≤ (∑ p ∈ (Finset.Iic n).filter Nat.Prime, Real.log p / p) / Real.log n := by
rw [le_div_iff₀ hlnpos]
have : C / Real.log 2 * Real.log n ≥ C := by
rw [ge_iff_le, div_mul_eq_mul_div, le_div_iff₀ hl2]; nlinarith
nlinarith
have hDle : 1 / Real.log 2 - 1 / Real.log n ≤ 1 / Real.log 2 := by
have : 0 < 1 / Real.log n := by positivity
linarith
have hD0 : 0 ≤ 1 / Real.log 2 - 1 / Real.log n := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hl2 hln
have hCD : C * (1 / Real.log 2 - 1 / Real.log n) ≤ C / Real.log 2 := by
have := mul_le_mul_of_nonneg_left hDle hC0; rw [mul_one_div] at this; exact this
have hCD' : (1 + C) * (1 / Real.log 2 - 1 / Real.log n) ≤ (1 + C) / Real.log 2 := by
have := mul_le_mul_of_nonneg_left hDle (by linarith : (0:ℝ) ≤ 1 + C)
rw [mul_one_div] at this; exact this
have e : (1 + 2 * C) / Real.log 2 = 1 / Real.log 2 + C / Real.log 2 + C / Real.log 2 := by ring
have e' : (1 + C) / Real.log 2 = 1 / Real.log 2 + C / Real.log 2 := by ring
have hll2 := abs_le.1 (le_refl |Real.log (Real.log 2)|)
have h12 : 0 ≤ 1 / Real.log 2 := by positivity
rw [hab, abs_le]; constructor
· nlinarith
· nlinarith
private theorem ms_tele' (F : ℕ → ℝ) (m n : ℕ) (hmn : m ≤ n) :
∑ k ∈ Finset.Ico m n, (F (k+1) - F k) = F n - F m := by
induction n, hmn using Nat.le_induction with
| base => simp
| succ n hn ih => rw [Finset.sum_Ico_succ_top hn, ih]; ring
/-- Mertens' second theorem with the error `O(1 / log m)` on a range `(m, n]`:
`∑_{m < p ≤ n} 1/p = log log n - log log m + O(1 / log m)`. Equivalent to the classical
form `∑_{p ≤ n} 1/p = log log n + M + O(1 / log n)` (it says the left side minus `log log n`
is Cauchy at rate `1 / log m`), and directly gives the dyadic sums `∑_{P/2 < p ≤ P} 1/p`. -/
private theorem u_mertens_second_interval : ∃ C : ℝ, ∀ m n : ℕ, 2 ≤ m → m ≤ n →
|((∑ p ∈ (Finset.Iic n).filter Nat.Prime, (1 : ℝ) / p)
- ∑ p ∈ (Finset.Iic m).filter Nat.Prime, (1 : ℝ) / p)
- (Real.log (Real.log n) - Real.log (Real.log m))| ≤ C / Real.log m := by
obtain ⟨C, hC⟩ := u_mertens_first
have hC0 : 0 ≤ C := le_trans (abs_nonneg _) (hC 2 le_rfl)
refine ⟨3 * C + 1, fun m n hm hmn => ?_⟩
have hn2 : 2 ≤ n := le_trans hm hmn
have hm' : (2:ℝ) ≤ m := by exact_mod_cast hm
have hmn' : (m:ℝ) ≤ n := by exact_mod_cast hmn
have hlm : 0 < Real.log m := Real.log_pos (by linarith)
have hlmn : Real.log m ≤ Real.log n := Real.log_le_log (by linarith) hmn'
have hln : 0 < Real.log n := by linarith
have habn := ms_abel n hn2
have habm := ms_abel m hm
have hsplit := Finset.sum_Ico_consecutive
(fun k : ℕ => (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) hm hmn
have hD : ∑ k ∈ Finset.Ico m n, (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))
= 1 / Real.log m - 1 / Real.log n := by
calc _ = ∑ k ∈ Finset.Ico m n,
((fun k : ℕ => -(1 / Real.log k)) (k+1) - (fun k : ℕ => -(1 / Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele' (fun k : ℕ => -(1 / Real.log k)) m n hmn
_ = _ := by ring
have hLL : ∑ k ∈ Finset.Ico m n,
(Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
= Real.log (Real.log n) - Real.log (Real.log m) := by
calc _ = ∑ k ∈ Finset.Ico m n,
((fun k : ℕ => Real.log (Real.log k)) (k+1) - (fun k : ℕ => Real.log (Real.log k)) k) :=
Finset.sum_congr rfl (fun k _ => by push_cast; ring)
_ = _ := ms_tele' (fun k : ℕ => Real.log (Real.log k)) m n hmn
have hS_up : ∑ k ∈ Finset.Ico m n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) ≤
∑ k ∈ Finset.Ico m n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
+ C * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := le_trans hm (Finset.mem_Ico.1 hk).1
obtain ⟨_, h2, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
have hS_lo : ∑ k ∈ Finset.Ico m n, ((Real.log (Real.log ((k:ℝ)+1)) - Real.log (Real.log k))
- (1 + C) * (1 / Real.log k - 1 / Real.log ((k:ℝ) + 1))) ≤
∑ k ∈ Finset.Ico m n, (∑ p ∈ (Finset.Iic k).filter Nat.Prime, Real.log p / p) *
(1 / Real.log k - 1 / Real.log ((k:ℝ) + 1)) := by
apply Finset.sum_le_sum
intro k hk
have hk2 : 2 ≤ k := le_trans hm (Finset.mem_Ico.1 hk).1
obtain ⟨h1, _, h3⟩ := ms_point k hk2
have hA := abs_le.1 (hC k hk2)
nlinarith
rw [Finset.sum_add_distrib, ← Finset.mul_sum, hLL, hD] at hS_up
rw [Finset.sum_sub_distrib, ← Finset.mul_sum, hLL, hD] at hS_lo
-- boundary terms: A(j)/log j = 1 + R(j)/log j with |R(j)/log j| ≤ C / log m
have hb : ∀ j : ℕ, m ≤ j →
|(∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) / Real.log j - 1|
≤ C / Real.log m := by
intro j hj
have hj2 : 2 ≤ j := le_trans hm hj
have hlj : Real.log m ≤ Real.log j :=
Real.log_le_log (by linarith) (by exact_mod_cast hj)
have hljpos : 0 < Real.log j := by linarith
have e : (∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) / Real.log j - 1
= ((∑ p ∈ (Finset.Iic j).filter Nat.Prime, Real.log p / p) - Real.log j) / Real.log j := by
field_simp
rw [e, abs_div, abs_of_pos hljpos]
calc _ ≤ C / Real.log j := div_le_div_of_nonneg_right (hC j hj2) hljpos.le
_ ≤ C / Real.log m := div_le_div_of_nonneg_left hC0 hlm hlj
have hbn := abs_le.1 (hb n hmn)
have hbm := abs_le.1 (hb m le_rfl)
have hDle : 1 / Real.log m - 1 / Real.log n ≤ 1 / Real.log m := by
have : 0 < 1 / Real.log n := by positivity
linarith
have hD0 : 0 ≤ 1 / Real.log m - 1 / Real.log n := by
rw [sub_nonneg]; exact one_div_le_one_div_of_le hlm hlmn
have hCD : C * (1 / Real.log m - 1 / Real.log n) ≤ C / Real.log m := by
have := mul_le_mul_of_nonneg_left hDle hC0; rw [mul_one_div] at this; exact this
have hCD' : (1 + C) * (1 / Real.log m - 1 / Real.log n) ≤ (1 + C) / Real.log m := by
have := mul_le_mul_of_nonneg_left hDle (by linarith : (0:ℝ) ≤ 1 + C)
rw [mul_one_div] at this; exact this
have e1 : (3 * C + 1) / Real.log m = C / Real.log m + C / Real.log m + (1 + C) / Real.log m := by
ring
have h1m : 0 ≤ C / Real.log m := by positivity
rw [habn, habm, ← hsplit, abs_le]; constructor
· nlinarith
· nlinarith
/-- If at most one cell `(k, ε)` has `p ∣ n + r_{ε,k+K+1}`, the phase `X_p(n)` of (5.13)
is at most `q / 2^(K+1)` in size: the bound (5.36) behind (5.19). -/
private theorem w_X_le {K : ℕ} (q : ℝ) (hq : 0 ≤ q) (H : ℕ) (sgn : (Fin K → Bool) → ℝ)
(hs : ∀ ε, |sgn ε| ≤ 1) (r : (Fin K → Bool) → ℕ → ℤ) (p : ℕ) (n : ℤ)
(huniq : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool,
p ∣ (n + r ε1 (k1 + K + 1)).toNat → p ∣ (n + r ε2 (k2 + K + 1)).toNat → k1 = k2 ∧ ε1 = ε2) :
|q * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1)|
≤ q / 2 ^ (K + 1) := by
rw [abs_mul, abs_of_nonneg hq, div_eq_mul_inv q]
refine mul_le_mul_of_nonneg_left ?_ hq
by_cases hex : ∃ k < H, ∃ ε : Fin K → Bool, p ∣ (n + r ε (k + K + 1)).toNat
· obtain ⟨k0, hk0, ε0, hd0⟩ := hex
have hinner : ∀ k ∈ Finset.range H, k ≠ k0 →
(∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1) = 0 := by
intro k hk hne
rw [div_eq_zero_iff]; left
refine Finset.sum_eq_zero fun ε _ => ?_
rw [if_neg, mul_zero]
intro hd
exact hne (huniq k (Finset.mem_range.mp hk) k0 hk0 ε ε0 hd hd0).1
rw [Finset.sum_eq_single k0 hinner (fun h => absurd (Finset.mem_range.mpr hk0) h)]
have hsingle : ∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k0 + K + 1)).toNat then (1 : ℝ) else 0) = sgn ε0 := by
rw [Finset.sum_eq_single ε0]
· rw [if_pos hd0, mul_one]
· intro ε _ hne
rw [if_neg, mul_zero]
intro hd
exact hne (huniq k0 hk0 k0 hk0 ε ε0 hd hd0).2
· intro h; exact absurd (Finset.mem_univ ε0) h
rw [hsingle, abs_div, abs_of_pos (by positivity : (0 : ℝ) < 2 ^ (k0 + K + 1))]
calc |sgn ε0| / 2 ^ (k0 + K + 1) ≤ 1 / 2 ^ (k0 + K + 1) :=
div_le_div_of_nonneg_right (hs ε0) (by positivity)
_ ≤ 1 / 2 ^ (K + 1) :=
div_le_div_of_nonneg_left zero_le_one (by positivity)
(pow_le_pow_right₀ (by norm_num) (by omega))
_ = (2 ^ (K + 1) : ℝ)⁻¹ := one_div _
· push Not at hex
have hz : ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1) = 0 := by
refine Finset.sum_eq_zero fun k hk => ?_
rw [div_eq_zero_iff]; left
refine Finset.sum_eq_zero fun ε _ => ?_
rw [if_neg (hex k (Finset.mem_range.mp hk) ε), mul_zero]
rw [hz, abs_zero]; positivity
/-- No collisions: if `p` divides none of the differences of two distinct shifts, and the
shifted numbers are positive, at most one cell is divisible by `p`. -/
private theorem w_uniq_of_no_collision {K : ℕ} (H : ℕ) (r : (Fin K → Bool) → ℕ → ℤ) (p : ℕ)
(n : ℤ) (hpos : ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1)) :
∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool,
p ∣ (n + r ε1 (k1 + K + 1)).toNat → p ∣ (n + r ε2 (k2 + K + 1)).toNat → k1 = k2 ∧ ε1 = ε2 := by
intro k1 hk1 k2 hk2 ε1 ε2 hd1 hd2
by_contra hne
rw [not_and_or] at hne
apply hcoll k1 hk1 k2 hk2 ε1 ε2 hne
have e1 : (p : ℤ) ∣ n + r ε1 (k1 + K + 1) := by
have := Int.natCast_dvd_natCast.mpr hd1
rwa [Int.toNat_of_nonneg (hpos ε1 k1 hk1).le] at this
have e2 : (p : ℤ) ∣ n + r ε2 (k2 + K + 1) := by
have := Int.natCast_dvd_natCast.mpr hd2
rwa [Int.toNat_of_nonneg (hpos ε2 k2 hk2).le] at this
have := dvd_sub e1 e2
rwa [add_sub_add_left_eq_sub] at this
/-- (5.19) from the set-up, in the exact shapes of T's hole: if no prime of `S1` divides a
difference of two distinct shifts (S1 avoids the discriminant), and `q / 2^(K+1) ≤ δ`, then
`|X_p(n)| ≤ δ` on `S1 × Ns`. -/
private theorem w_5_19 (q : ℕ) (δ : ℝ) (K H : ℕ) (Ns : Finset ℤ) (S1 : Finset ℕ)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hK : (q : ℝ) / 2 ^ (K + 1) ≤ δ) :
∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ := by
intro p hp n hn
have hs : ∀ ε, |sgn ε| ≤ 1 := by
intro ε
rw [hsgn ε, Finset.abs_prod]
refine le_of_eq (Finset.prod_eq_one fun i _ => ?_)
split_ifs <;> norm_num
rw [hX p n]
exact (w_X_le (q : ℝ) (Nat.cast_nonneg q) H sgn hs r p n
(w_uniq_of_no_collision H r p n (fun ε k hk => hpos n hn ε k hk) (hcoll p hp))).trans hK
/-- A sum with at most one nonzero term squares termwise. -/
private theorem w_sq_sum_of_single {ι : Type*} (s : Finset ι) (f : ι → ℝ)
(h : ∀ i ∈ s, ∀ j ∈ s, f i ≠ 0 → f j ≠ 0 → i = j) :
(∑ i ∈ s, f i) ^ 2 = ∑ i ∈ s, f i ^ 2 := by
by_cases hex : ∃ i ∈ s, f i ≠ 0
· obtain ⟨i0, hi0, hf0⟩ := hex
have hz : ∀ j ∈ s, j ≠ i0 → f j = 0 := fun j hj hne => by
by_contra hfj; exact hne (h j hj i0 hi0 hfj hf0)
rw [Finset.sum_eq_single i0 hz (fun h' => absurd hi0 h'),
Finset.sum_eq_single i0 (fun j hj hne => by rw [hz j hj hne]; ring) (fun h' => absurd hi0 h')]
· push Not at hex
rw [Finset.sum_eq_zero hex, Finset.sum_eq_zero fun i hi => by rw [hex i hi]; ring]
ring
/-- `Σ_ε (-1)^{|ε|} = 0` for `K ≥ 1`. -/
private theorem w_sum_sgn_eq_zero {K : ℕ} (hK : 1 ≤ K) (sgn : (Fin K → Bool) → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1) :
∑ ε : Fin K → Bool, sgn ε = 0 := by
simp_rw [hsgn]
rw [← Fintype.piFinset_univ, ← Finset.prod_univ_sum (fun _ : Fin K => (Finset.univ : Finset Bool))
(fun _ b => if b then (-1 : ℝ) else 1)]
exact Finset.prod_eq_zero (Finset.mem_univ ⟨0, hK⟩) (by simp)
/-- S8h with the paper's approximate equidistribution (5.35): if every residue class mod `p`
holds `#Ns/p` points of `Ns` up to a relative error `η ≤ 1`, then
`Var X_p ≥ (1 − η) q²/(2^(K+2) p) − (η q / p)²`. -/
private theorem w_var_lower_approx (q : ℕ) (K H : ℕ) (hK : 1 ≤ K) (hH : 1 ≤ H) (Ns : Finset ℤ)
(hNs : Ns.Nonempty) (p : ℕ) (hp : 0 < p) (η : ℝ) (hη : 0 ≤ η) (hη1 : η ≤ 1)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hequi : ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card) :
(1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p)) - (η * q / p) ^ 2 ≤
(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ 2 - ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ 2 := by
set C := Finset.range H ×ˢ (Finset.univ : Finset (Fin K → Bool)) with hC
set a : ℕ × (Fin K → Bool) → ℝ := fun c => (q : ℝ) * sgn c.2 / 2 ^ (c.1 + K + 1) with ha
set ind : ℤ → ℕ × (Fin K → Bool) → ℝ :=
fun n c => if (p : ℤ) ∣ n + r c.2 (c.1 + K + 1) then 1 else 0 with hind
set N : ℝ := (Ns.card : ℝ) with hN
have hNpos : 0 < N := by rw [hN]; exact_mod_cast hNs.card_pos
have hpR : (0 : ℝ) < p := by exact_mod_cast hp
have hdv : ∀ z : ℤ, 0 ≤ z → (p ∣ z.toNat ↔ (p : ℤ) ∣ z) := fun z hz => by
rw [← Int.natCast_dvd_natCast, Int.toNat_of_nonneg hz]
have hXc : ∀ n ∈ Ns, X p n = ∑ c ∈ C, a c * ind n c := by
intro n hn
rw [hX, hC, Finset.sum_product, Finset.mul_sum]
refine Finset.sum_congr rfl fun k hk => ?_
rw [Finset.sum_div, Finset.mul_sum]
refine Finset.sum_congr rfl fun ε _ => ?_
have hz := (hpos n hn ε k (Finset.mem_range.mp hk)).le
simp only [ha, hind]
by_cases h : (p : ℤ) ∣ n + r ε (k + K + 1)
· rw [if_pos h, if_pos ((hdv _ hz).mpr h)]; ring
· rw [if_neg h, if_neg (fun h' => h ((hdv _ hz).mp h'))]; ring
have hcnt : ∀ c : ℕ × (Fin K → Bool), |(∑ n ∈ Ns, ind n c) - N / p| ≤ η * N / p := by
intro c
have h := hequi (r c.2 (c.1 + K + 1))
have hs : ∑ n ∈ Ns, ind n c = ((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) := by
simp only [hind]; rw [Finset.sum_boole]
rw [hs]
have e : ((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) - N / p
= (((Ns.filter fun n => (p : ℤ) ∣ n + r c.2 (c.1 + K + 1)).card : ℝ) * p - N) / p := by
field_simp
rw [e, abs_div, abs_of_pos hpR]
exact div_le_div_of_nonneg_right h hpR.le
have hsq : ∀ n ∈ Ns, X p n ^ 2 = ∑ c ∈ C, a c ^ 2 * ind n c := by
intro n hn
rw [hXc n hn, w_sq_sum_of_single]
· refine Finset.sum_congr rfl fun c _ => ?_
simp only [hind]; split_ifs <;> ring
· intro c hc c' hc' h1 h2
have d1 : (p : ℤ) ∣ n + r c.2 (c.1 + K + 1) := by
by_contra h; apply h1; simp only [hind, if_neg h, mul_zero]
have d2 : (p : ℤ) ∣ n + r c'.2 (c'.1 + K + 1) := by
by_contra h; apply h2; simp only [hind, if_neg h, mul_zero]
by_contra hne
have hor : c.1 ≠ c'.1 ∨ c.2 ≠ c'.2 := by
by_contra h; push Not at h; exact hne (Prod.ext h.1 h.2)
rw [hC, Finset.mem_product] at hc hc'
apply hcoll c.1 (Finset.mem_range.mp hc.1) c'.1 (Finset.mem_range.mp hc'.1) c.2 c'.2 hor
have := dvd_sub d1 d2
rwa [add_sub_add_left_eq_sub] at this
-- Σ_c a c = 0 and Σ_c |a c| ≤ q
have hsuma : ∑ c ∈ C, a c = 0 := by
rw [hC, Finset.sum_product]
refine Finset.sum_eq_zero fun k _ => ?_
simp only [ha]
rw [← Finset.sum_div, ← Finset.mul_sum, w_sum_sgn_eq_zero hK sgn hsgn]; ring
have habs : ∑ c ∈ C, |a c| ≤ q := by
have hs1 : ∀ ε : Fin K → Bool, |sgn ε| = 1 := by
intro ε; rw [hsgn ε, Finset.abs_prod]
exact Finset.prod_eq_one fun i _ => by split_ifs <;> norm_num
rw [hC, Finset.sum_product]
simp only [ha, abs_div, abs_mul, hs1, Nat.abs_cast, mul_one, abs_pow, abs_two]
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Fintype.card_fun,
Fintype.card_bool, Fintype.card_fin]
have hk : ∀ k ∈ Finset.range H, ((2 ^ K : ℕ) : ℝ) * ((q : ℝ) / 2 ^ (k + K + 1))
= (q : ℝ) * ((1 / 2) * (1 / 2) ^ k) := by
intro k _; push_cast; rw [pow_add, pow_add]; field_simp
rw [mul_assoc, ← mul_pow]; norm_num
rw [Finset.sum_congr rfl hk, ← Finset.mul_sum, ← Finset.mul_sum]
have hg := sum_geometric_two_le H
have hq0 : (0 : ℝ) ≤ q := Nat.cast_nonneg q
nlinarith
have hmean : |(N)⁻¹ * ∑ n ∈ Ns, X p n| ≤ η * q / p := by
rw [Finset.sum_congr rfl hXc, Finset.sum_comm]
simp_rw [← Finset.mul_sum]
have e : ∑ c ∈ C, a c * ∑ n ∈ Ns, ind n c = ∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p) := by
simp_rw [mul_sub]; rw [Finset.sum_sub_distrib, ← Finset.sum_mul, hsuma]; ring
rw [e, abs_mul, abs_inv, abs_of_pos hNpos]
have hb : |∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p)| ≤ q * (η * N / p) := by
refine (Finset.abs_sum_le_sum_abs _ _).trans ?_
calc ∑ c ∈ C, |a c * ((∑ n ∈ Ns, ind n c) - N / p)|
≤ ∑ c ∈ C, |a c| * (η * N / p) := Finset.sum_le_sum fun c _ => by
rw [abs_mul]; exact mul_le_mul_of_nonneg_left (hcnt c) (abs_nonneg _)
_ = (∑ c ∈ C, |a c|) * (η * N / p) := by rw [Finset.sum_mul]
_ ≤ q * (η * N / p) := mul_le_mul_of_nonneg_right habs (by positivity)
calc N⁻¹ * |∑ c ∈ C, a c * ((∑ n ∈ Ns, ind n c) - N / p)| ≤ N⁻¹ * (q * (η * N / p)) :=
mul_le_mul_of_nonneg_left hb (by positivity)
_ = η * q / p := by field_simp
have hsecond : (1 - η) * (N / p) * ∑ c ∈ C, a c ^ 2 ≤ ∑ n ∈ Ns, X p n ^ 2 := by
rw [Finset.sum_congr rfl hsq, Finset.sum_comm]
simp_rw [← Finset.mul_sum]
rw [Finset.mul_sum]
refine Finset.sum_le_sum fun c _ => ?_
have h := hcnt c
rw [abs_le] at h
have : (1 - η) * (N / p) ≤ ∑ n ∈ Ns, ind n c := by
have : (1 - η) * (N / p) = N / p - η * N / p := by ring
linarith [h.1]
nlinarith [sq_nonneg (a c)]
have hlow : (q : ℝ) ^ 2 / 2 ^ (K + 2) ≤ ∑ c ∈ C, a c ^ 2 := by
have hsub : ({0} : Finset ℕ) ×ˢ (Finset.univ : Finset (Fin K → Bool)) ⊆ C := by
rw [hC]; exact Finset.product_subset_product_left
(Finset.singleton_subset_iff.mpr (Finset.mem_range.mpr hH))
refine le_trans (le_of_eq ?_) (Finset.sum_le_sum_of_subset_of_nonneg hsub
fun c _ _ => sq_nonneg _)
rw [Finset.sum_product, Finset.sum_singleton]
have hs2 : ∀ ε : Fin K → Bool, sgn ε ^ 2 = 1 := by
intro ε
rw [hsgn ε, ← Finset.prod_pow]
exact Finset.prod_eq_one fun i _ => by split_ifs <;> norm_num
simp only [ha, div_pow, mul_pow, hs2, mul_one]
rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
simp only [Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, zero_add]
push_cast
rw [pow_succ 2 (K + 1), pow_succ 2 K]
field_simp
have hEX2 : (1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p)) ≤ N⁻¹ * ∑ n ∈ Ns, X p n ^ 2 := by
have h1 : (1 - η) * ((q : ℝ) ^ 2 / (2 ^ (K + 2) * p))
= N⁻¹ * ((1 - η) * (N / p) * ((q : ℝ) ^ 2 / 2 ^ (K + 2))) := by
field_simp
rw [h1]
refine mul_le_mul_of_nonneg_left (le_trans ?_ hsecond) (by positivity)
exact mul_le_mul_of_nonneg_left hlow (mul_nonneg (by linarith) (by positivity))
have hEX : (N⁻¹ * ∑ n ∈ Ns, X p n) ^ 2 ≤ (η * q / p) ^ 2 := by
rw [← sq_abs]
exact pow_le_pow_left₀ (abs_nonneg _) hmean 2
linarith
/-- (5.21) from the set-up: summing `w_var_lower_approx` over `S1`. If every `p ∈ S1` avoids the
shifts' discriminant and `n` is equidistributed mod `p` up to relative error `η ≤ 1`, then
`Σ_{S1} Var X_p ≥ (1-η) q²/2^(K+2) Σ_{S1} 1/p − η² q² Σ_{S1} 1/p²`; the hole's `c0 ≤ Σ Var`
follows as soon as the right side is `≥ c0` (by Mertens, `Σ_{S1} 1/p ≍ log₂ R − log₂ W`). -/
private theorem w_5_21 (q : ℕ) (K H : ℕ) (hK : 1 ≤ K) (hH : 1 ≤ H) (Ns : Finset ℤ)
(hNs : Ns.Nonempty) (S1 : Finset ℕ) (hS1 : ∀ p ∈ S1, 0 < p) (η : ℝ) (hη : 0 ≤ η)
(hη1 : η ≤ 1) (sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hsgn : ∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcoll : ∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))
(hequi : ∀ p ∈ S1, ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card) (c0 : ℝ)
(hc0 : c0 ≤ (1 - η) * ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * ∑ p ∈ S1, (1 : ℝ) / p
- η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / p ^ 2) :
c0 ≤ ∑ p ∈ S1, ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ 2
- ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ 2) := by
refine hc0.trans ?_
rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib]
refine Finset.sum_le_sum fun p hp => le_trans (le_of_eq ?_)
(w_var_lower_approx q K H hK hH Ns hNs p (hS1 p hp) η hη hη1 sgn r X hsgn hX hpos
(hcoll p hp) (hequi p hp))
have : (0 : ℝ) < p := by exact_mod_cast hS1 p hp
field_simp
/-- One vertex of κ₁ (§5.7): if `m n ε` is equidistributed mod `P ε` on `Ns` up to a factor
`1 + η`, the average of `Σ_k 1[P² ∣ P m + P (k+1)] / 2^(k+1)` is at most `(1 + η)/P`. -/
private theorem w_kappa1_eps (Ns : Finset ℤ) (P : ℕ) (hP : 0 < P) (m : ℤ → ℕ) (η : ℝ)
(hequi : ∀ a : ℕ, ((Ns.filter fun n => P ∣ m n + a).card : ℝ) * P ≤ (1 + η) * Ns.card) :
∑ n ∈ Ns, ∑' k : ℕ, (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P := by
have hdv : ∀ n (k : ℕ), (P ^ 2 ∣ P * m n + P * (k + 1) ↔ P ∣ m n + (k + 1)) := by
intro n k
rw [pow_two, ← mul_add]
exact Nat.mul_dvd_mul_iff_left hP
have hsum : ∀ n ∈ Ns, Summable fun k : ℕ =>
(if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1) := by
intro n _
refine Summable.of_nonneg_of_le (fun k => by positivity) (fun k => ?_)
((summable_geometric_two).mul_left (1 / 2))
have : (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) ≤ 1 := by split_ifs <;> norm_num
calc (if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ 1 / 2 ^ (k + 1) := div_le_div_of_nonneg_right this (by positivity)
_ = 1 / 2 * (1 / 2) ^ k := by
rw [pow_succ]; field_simp; rw [← mul_pow]; norm_num
rw [← Summable.tsum_finsetSum hsum]
have hPR : (0 : ℝ) < P := by exact_mod_cast hP
have hterm : ∀ k : ℕ, ∑ n ∈ Ns,
(if P ^ 2 ∣ P * m n + P * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) := by
intro k
rw [← Finset.sum_div]
simp_rw [hdv]
rw [Finset.sum_boole]
have h := hequi (k + 1)
have : ((Ns.filter fun n => P ∣ m n + (k + 1)).card : ℝ) ≤ (1 + η) * Ns.card / P := by
rw [le_div_iff₀ hPR]; exact_mod_cast h
calc ((Ns.filter fun n => P ∣ m n + (k + 1)).card : ℝ) / 2 ^ (k + 1)
≤ (1 + η) * Ns.card / P / 2 ^ (k + 1) := div_le_div_of_nonneg_right this (by positivity)
_ = (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) := by
rw [pow_succ]; field_simp; rw [mul_assoc, ← mul_pow]; norm_num
have hS : Summable fun k : ℕ => (1 + η) * Ns.card / P * (1 / 2 * (1 / 2) ^ k) :=
((summable_geometric_two).mul_left (1 / 2)).mul_left _
refine (Summable.tsum_le_tsum hterm (summable_sum fun n hn => hsum n hn) hS).trans (le_of_eq ?_)
rw [tsum_mul_left, tsum_mul_left, tsum_geometric_two]; ring
/-- κ₁ of (5.10), T's exact conjunct: with `m n ε` equidistributed mod `P ε` up to `1 + η` for
every vertex `ε`, `κ₁ ≤ Σ_ε (1 + η)/P_ε` (≤ 2^K (1+η) / min P_ε, which is `o(1)` since
`P_ε ≥ P/2` and `2^K ≈ (log₃ x)²`). -/
private theorem w_kappa1 {K : ℕ} (Ns : Finset ℤ) (P : (Fin K → Bool) → ℕ) (hP : ∀ ε, 0 < P ε)
(m : ℤ → (Fin K → Bool) → ℕ) (η : ℝ) (hη : 0 ≤ η)
(hequi : ∀ ε, ∀ a : ℕ, ((Ns.filter fun n => P ε ∣ m n ε + a).card : ℝ) * P ε
≤ (1 + η) * Ns.card) :
(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑ ε : Fin K → Bool, ∑' k : ℕ,
(if P ε ^ 2 ∣ P ε * m n ε + P ε * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ ∑ ε : Fin K → Bool, (1 + η) / P ε := by
rcases Ns.eq_empty_or_nonempty with h | hne
· subst h; simp only [Finset.card_empty, Nat.cast_zero, inv_zero, zero_mul]
exact Finset.sum_nonneg fun ε _ => div_nonneg (by linarith) (Nat.cast_nonneg _)
have hN : (0 : ℝ) < Ns.card := by exact_mod_cast hne.card_pos
rw [Finset.sum_comm, Finset.mul_sum]
refine Finset.sum_le_sum fun ε _ => ?_
have := w_kappa1_eps Ns (P ε) (hP ε) (fun n => m n ε) η (hequi ε)
calc (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' k : ℕ,
(if P ε ^ 2 ∣ P ε * m n ε + P ε * (k + 1) then (1 : ℝ) else 0) / 2 ^ (k + 1)
≤ (Ns.card : ℝ)⁻¹ * ((1 + η) * Ns.card / P ε) :=
mul_le_mul_of_nonneg_left this (by positivity)
_ = (1 + η) / P ε := by field_simp
/-- `X_p(n)` depends on `n` only through `n mod p` (for positive shifted values). -/
private theorem w_X_congr {K : ℕ} (q H : ℕ) (sgn : (Fin K → Bool) → ℝ)
(r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(p : ℕ) (n n' : ℤ) (hn : ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hn' : ∀ ε, ∀ k < H, 0 < n' + r ε (k + K + 1)) (hpn : (p : ℤ) ∣ n - n') :
X p n = X p n' := by
have hdv : ∀ z : ℤ, 0 ≤ z → (p ∣ z.toNat ↔ (p : ℤ) ∣ z) := fun z hz => by
rw [← Int.natCast_dvd_natCast, Int.toNat_of_nonneg hz]
rw [hX, hX]
congr 1
refine Finset.sum_congr rfl fun k hk => ?_
congr 1
refine Finset.sum_congr rfl fun ε _ => ?_
have hk' := Finset.mem_range.mp hk
have e : (p ∣ (n + r ε (k + K + 1)).toNat) ↔ (p ∣ (n' + r ε (k + K + 1)).toNat) := by
rw [hdv _ (hn ε k hk').le, hdv _ (hn' ε k hk').le]
constructor
· intro h
have := dvd_sub h hpn
rwa [show n + r ε (k + K + 1) - (n - n') = n' + r ε (k + K + 1) by ring] at this
· intro h
have := dvd_add h hpn
rwa [show n' + r ε (k + K + 1) + (n - n') = n + r ε (k + K + 1) by ring] at this
by_cases h : p ∣ (n + r ε (k + K + 1)).toNat
· rw [if_pos h, if_pos (e.mp h)]
· rw [if_neg h, if_neg (fun h' => h (e.mpr h'))]
/-- The `S₀` conjunct of T's hole (§5.6, (5.33)): if `Ns` lies in one residue class modulo
every prime `p ≤ B` outside `S1 ∪ S2` (the paper takes `n ≡ 0 mod W♭` and fixes `n mod p_ε`
by (5.5)), then `X_p` is constant on `Ns` for those `p`. -/
private theorem w_S0 {K : ℕ} (q H B : ℕ) (Ns : Finset ℤ) (S1 S2 : Finset ℕ)
(sgn : (Fin K → Bool) → ℝ) (r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ)
(hX : ∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1))
(hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1))
(hcls : ∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, (p : ℤ) ∣ n - n') :
∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n' :=
fun p hp h1 h2 n hn n' hn' => w_X_congr q H sgn r X hX p n n' (hpos n hn) (hpos n' hn')
(hcls p hp h1 h2 n hn n' hn')
/-- `∑_{p ∈ S} 1/p² ≤ 1` for any finite set of integers `≥ 2` (from Mathlib's `sum_Ioo_inv_sq_le`). -/
private theorem f2_sum_inv_sq_le_one (S : Finset ℕ) (hS : ∀ p ∈ S, 2 ≤ p) :
∑ p ∈ S, (1 : ℝ) / (p : ℝ) ^ 2 ≤ 1 := by
have hsub : S ⊆ Finset.Ioo 1 (S.sup id + 1) := by
intro p hp
have h2 := hS p hp
have hle : p ≤ S.sup id := Finset.le_sup (f := id) hp
simp only [Finset.mem_Ioo]; omega
calc ∑ p ∈ S, (1 : ℝ) / (p : ℝ) ^ 2 = ∑ p ∈ S, ((p : ℝ) ^ 2)⁻¹ := by
simp only [one_div]
_ ≤ ∑ p ∈ Finset.Ioo 1 (S.sup id + 1), ((p : ℝ) ^ 2)⁻¹ :=
Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity)
_ ≤ 2 / ((1 : ℕ) + 1 : ℝ) := sum_Ioo_inv_sq_le 1 _
_ = 1 := by norm_num
/-- The primes of `(w, R]` as a difference of two `Iic` sums. -/
private theorem f2_sum_Ioc (f : ℕ → ℝ) (w R : ℕ) (h : w ≤ R) :
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime, f p
= ∑ p ∈ (Finset.Iic R).filter Nat.Prime, f p - ∑ p ∈ (Finset.Iic w).filter Nat.Prime, f p := by
have hsub : (Finset.Iic w).filter Nat.Prime ⊆ (Finset.Iic R).filter Nat.Prime := by
intro x hx
simp only [Finset.mem_filter, Finset.mem_Iic] at hx ⊢
exact ⟨hx.1.trans h, hx.2⟩
have heq : (Finset.Ioc w R).filter Nat.Prime
= (Finset.Iic R).filter Nat.Prime \ (Finset.Iic w).filter Nat.Prime := by
ext x
simp only [Finset.mem_filter, Finset.mem_Ioc, Finset.mem_Iic, Finset.mem_sdiff]
constructor
· rintro ⟨⟨h1, h2⟩, hp⟩
exact ⟨⟨h2, hp⟩, fun h3 => by omega⟩
· rintro ⟨⟨h2, hp⟩, h3⟩
refine ⟨⟨?_, h2⟩, hp⟩
by_contra h4
exact h3 ⟨by omega, hp⟩
rw [heq, ← Finset.sum_sdiff hsub]
ring
/-- `S1` keeps all but a reciprocal mass `≤ 1` of the primes of `(w, R]`. -/
private theorem f2_S1_lower (S1 : Finset ℕ) (w R : ℕ)
(hmiss : ∑ p ∈ (Finset.Ioc w R).filter Nat.Prime \ S1, (1 : ℝ) / p ≤ 1) :
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime, (1 : ℝ) / p - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p := by
set A := (Finset.Ioc w R).filter Nat.Prime
have h1 : ∑ p ∈ A, (1 : ℝ) / p ≤ ∑ p ∈ (A \ S1) ∪ S1, (1 : ℝ) / p :=
Finset.sum_le_sum_of_subset_of_nonneg (fun x hx => by
by_cases hxs : x ∈ S1
· exact Finset.mem_union_right _ hxs
· exact Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨hx, hxs⟩))
(fun _ _ _ => by positivity)
rw [Finset.sum_union Finset.sdiff_disjoint] at h1
linarith
/-- Mertens' second theorem on `S1` gives the variance conjunct: with `c0 = q²/8`. -/
private theorem f2_c0 (q K : ℕ) (S1 : Finset ℕ) (hS1 : ∀ p ∈ S1, 2 ≤ p) (η : ℝ)
(hη0 : 0 ≤ η) (hη : η ≤ 1 / 4) (C : ℝ) (hC : 0 ≤ C)
(hs : (2 : ℝ) ^ K * (C + 2) - C - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p) :
(q : ℝ) ^ 2 / 8 ≤ (1 - η) * ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * ∑ p ∈ S1, (1 : ℝ) / p
- η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / p ^ 2 := by
have hsq := f2_sum_inv_sq_le_one S1 hS1
have hsq0 : 0 ≤ ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 := Finset.sum_nonneg (fun _ _ => by positivity)
have h2K : (1 : ℝ) ≤ 2 ^ K := one_le_pow₀ (by norm_num)
set S := ∑ p ∈ S1, (1 : ℝ) / p
have hS : (2 : ℝ) ^ K ≤ S := by nlinarith
have hq0 : 0 ≤ (q : ℝ) ^ 2 := sq_nonneg _
have hpos : (0 : ℝ) < 2 ^ (K + 2) := by positivity
have hA : (q : ℝ) ^ 2 / 4 ≤ ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * S := by
rw [div_mul_eq_mul_div, le_div_iff₀ hpos, pow_add]
nlinarith
have hB : η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 ≤ (q : ℝ) ^ 2 / 16 := by
have : η ^ 2 ≤ 1 / 16 := by nlinarith
calc η ^ 2 * (q : ℝ) ^ 2 * ∑ p ∈ S1, (1 : ℝ) / (p : ℝ) ^ 2 ≤ η ^ 2 * (q : ℝ) ^ 2 * 1 :=
mul_le_mul_of_nonneg_left hsq (by positivity)
_ ≤ 1 / 16 * (q : ℝ) ^ 2 * 1 := by gcongr
_ = (q : ℝ) ^ 2 / 16 := by ring
have hC' : 0 ≤ ((q : ℝ) ^ 2 / 2 ^ (K + 2)) * S := by positivity
nlinarith
/-- `log w ≥ 1` once `w ≥ 3`. -/
private theorem f2_one_le_log (w : ℕ) (hw : 3 ≤ w) : 1 ≤ Real.log w := by
have h3 : (3 : ℝ) ≤ w := by exact_mod_cast hw
rw [Real.le_log_iff_exp_le (by linarith)]
linarith [Real.exp_one_lt_d9]
theorem variant_6b364d2b__h1 : ∀ (q : ℕ),
(0 : ℕ) < q →
∃ (c0 : ℝ),
(0 : ℝ) < c0 ∧
∀ (δ : ℝ),
(0 : ℝ) < δ →
∃ (K : ℕ) (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ) (H : ℕ) (B : ℕ) (Ns : Finset ℤ) (m :
ℤ → (Fin K → Bool) → ℕ) (S1 : Finset ℕ) (S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ) (r :
(Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ),
(∀ (ε : Fin K → Bool), sgn ε = ∏ i : Fin K, if ε i = true then (-1 : ℝ) else (1 : ℝ)) ∧
(∀ (ε : Fin K → Bool) (h : ℕ),
r ε h =
p0 * (↑h : ℤ) +
∑ k : Fin K, ((↑h : ℤ) - ((↑(↑k : ℕ) : ℤ) + (1 : ℤ))) * if ε k = true then v k else (0 : ℤ)) ∧
(∀ (p : ℕ) (n : ℤ),
X p n =
(↑q : ℝ) *
∑ k ∈ Finset.range H,
(∑ ε : Fin K → Bool,
sgn ε * if p ∣ (n + r ε (k + K + (1 : ℕ))).toNat then (1 : ℝ) else (0 : ℝ)) /
(2 : ℝ) ^ (k + K + (1 : ℕ))) ∧
Even M ∧
(∀ (ε : Fin K → Bool), (↑(P ε) : ℤ) = p0 + ∑ k : Fin K, if ε k = true then v k else (0 : ℤ)) ∧
(∀ (ε : Fin K → Bool), Nat.Prime (P ε)) ∧
Ns.Nonempty ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
(n - ∑ k : Fin K, ((↑(↑k : ℕ) : ℤ) + (1 : ℤ)) * if ε k = true then v k else (0 : ℤ)) =
(↑(P ε) : ℤ) * (↑(m n ε) : ℤ)) ∧
(∀ n ∈ Ns,
∀ (ε : Fin K → Bool),
∀ k < H,
(0 : ℤ) < n + r ε (k + K + (1 : ℕ)) ∧ n + r ε (k + K + (1 : ℕ)) ≤ (↑B : ℤ)) ∧
S1 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
S2 ⊆ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))) ∧
Disjoint S1 S2 ∧
(∀ p ∈ Finset.filter Nat.Prime (Finset.range (B + (1 : ℕ))),
p ∉ S1 → p ∉ S2 → ∀ n ∈ Ns, ∀ n' ∈ Ns, X p n = X p n') ∧
(∀ p ∈ S1, ∀ n ∈ Ns, |X p n| ≤ δ) ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑ ε : Fin K → Bool,
∑' (k : ℕ),
(if P ε ^ (2 : ℕ) ∣ P ε * m n ε + P ε * (k + (1 : ℕ)) then (1 : ℝ)
else (0 : ℝ)) /
(2 : ℝ) ^ (k + (1 : ℕ)) ≤
δ ∧
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
∑' (k : ℕ),
(∑ ε : Fin K → Bool,
(↑((ArithmeticFunction.cardDistinctFactors : ℕ → ℕ)
(n + r ε (k + H + K + (1 : ℕ))).toNat) :
ℝ)) /
(2 : ℝ) ^ (k + H + K + (1 : ℕ)) ≤
δ ∧
√((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ (2 : ℕ)) ≤ δ ∧
∑ j ∈ Finset.range (M + (1 : ℕ)),
((2 : ℝ) * Real.pi) ^ j / (↑j.factorial : ℝ) *
|(↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j -
(↑(Fintype.piFinset fun (x : ↥S1) => Ns).card : ℝ)⁻¹ *
∑ ω ∈ Fintype.piFinset fun (x : ↥S1) => Ns,
(∑ p : ↥S1, X (↑p : ℕ) (ω p)) ^ j| ≤
δ ∧
(∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
((2 : ℝ) * Real.pi * Real.exp (1 : ℝ) * X p n) +
∏ p ∈ S1,
(↑Ns.card : ℝ)⁻¹ *
∑ n ∈ Ns,
Real.exp
(-((2 : ℝ) * Real.pi * Real.exp (1 : ℝ)) * X p n)) /
Real.exp (1 : ℝ) ^ M ≤
δ ∧
c0 ≤
∑ p ∈ S1,
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n ^ (2 : ℕ) -
((↑Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, X p n) ^ (2 : ℕ)) := by
-- approach: Tao–Teräväinen §§5.5–5.11 in Lean: Lemma 5.2 and Mertens proved; κ₁, (5.19), S₀, variance from the set-up; κ₂–κ₅ left
-- licence: CC-BY-4.0
-- label: Tao–Teräväinen §§5.6–5.14: κ₂–κ₅ for each Lemma 5.2 cube
-- claim: $\forall q \ge 1,\ T,\ \delta > 0,\ P_0\ \ \exists P \ge P_0,\ 2^K \le (\log P)^{2/3},\ H \le (\log P)^{2/3}\ \ \forall (p_0, v)\ \ \exists (N_s, S_1, S_2, M, \eta, w, R):\ \kappa_2, \kappa_3, \kappa_4, \kappa_5 \le \delta,\ \sum_{\varepsilon} \frac{1+\eta}{p_\varepsilon} \le \delta,\ \frac{q}{2^{K+1}} \le \delta,\ 2^K T \le \log\log R - \log\log w$
-- What is left of Tao–Teräväinen Theorem 5.1 (arXiv:2512.01739v2, p. 49) once the set-up is fixed:
-- for every prime cube that Lemma 5.2 produces in (P/2, P], a random n (uniform on Ns) obeying
-- (5.5)-(5.6) and (5.33), the prime split S₀/S₁/S₂ of §5.6 (S₁ avoids the discriminant of the near
-- shifts), equidistribution (5.35) mod each p_ε and each p ∈ S₁ up to η, and the estimates
-- κ₂ (§5.8), κ₃ (§§5.12-5.14, the paper's use of its Theorem 3.1(i)), κ₄ (§5.9), κ₅ (§5.10).
-- The parameter clause 2^K T ≤ log log R - log log w is §5.11's (log₂R - log₂W)/2^K → ∞.
-- Proved here, not in the hole: Lemma 5.2 (quantitative; Aristotle for t1023-f2, from t1022-s's
-- and t1022-x's projects), Mertens' second theorem on S₁ (t1022-u), κ₁ (§5.7), (5.19), S₀ and the
-- variance step (t1022-w's reduction), and the exact variance bound c₀ = q²/8 (t1023-f2).
have tt_sec5_setup : ∀ q : ℕ, 0 < q → ∀ T : ℝ, ∀ δ : ℝ, 0 < δ → ∀ P0 : ℕ,
∃ (Pw K H : ℕ), P0 ≤ Pw ∧ 1 ≤ K ∧ 1 ≤ H ∧ (2 : ℝ) ^ K ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧
(H : ℝ) ≤ Real.log Pw ^ ((2 : ℝ) / 3) ∧
∀ (p0 : ℤ) (v : Fin K → ℤ) (P : (Fin K → Bool) → ℕ),
(∀ ε : Fin K → Bool, Nat.Prime (P ε) ∧ Pw < 2 * P ε ∧ P ε ≤ Pw ∧
(P ε : ℤ) = p0 + ∑ k, if ε k then v k else 0) →
Function.Injective (fun ε : Fin K → Bool => p0 + ∑ k, if ε k then v k else 0) →
Function.Injective (fun x : (Fin K → Bool) × Fin H =>
(p0 + ∑ k, if x.1 k then v k else 0) * ((x.2.1 + 1 + K : ℕ) : ℤ)
- ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if x.1 k then v k else 0)) →
∃ (B : ℕ) (Ns : Finset ℤ)
(m : ℤ → (Fin K → Bool) → ℕ) (S1 S2 : Finset ℕ) (sgn : (Fin K → Bool) → ℝ)
(r : (Fin K → Bool) → ℕ → ℤ) (X : ℕ → ℤ → ℝ) (M : ℕ) (η : ℝ) (w R : ℕ),
((∀ ε, sgn ε = ∏ i, if ε i then (-1 : ℝ) else 1) ∧
(∀ ε (h : ℕ), r ε h = p0 * h + ∑ k : Fin K, ((h : ℤ) - (k.1 + 1)) * (if ε k then v k else 0)) ∧
(∀ p n, X p n = (q : ℝ) * ∑ k ∈ Finset.range H, (∑ ε : Fin K → Bool, sgn ε *
(if p ∣ (n + r ε (k + K + 1)).toNat then (1 : ℝ) else 0)) / 2 ^ (k + K + 1)) ∧
Even M) ∧
(Ns.Nonempty ∧
(∀ n ∈ Ns, ∀ ε, n - ∑ k : Fin K, ((k.1 : ℤ) + 1) * (if ε k then v k else 0) = P ε * m n ε) ∧
(∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) ∧ n + r ε (k + K + 1) ≤ B)) ∧
(S1 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧ S2 ⊆ (Finset.range (B + 1)).filter Nat.Prime ∧
Disjoint S1 S2 ∧
(∀ p ∈ (Finset.range (B + 1)).filter Nat.Prime, p ∉ S1 → p ∉ S2 →
∀ n ∈ Ns, ∀ n' ∈ Ns, (p : ℤ) ∣ n - n') ∧
(∀ p ∈ S1, ∀ k1 < H, ∀ k2 < H, ∀ ε1 ε2 : Fin K → Bool, (k1 ≠ k2 ∨ ε1 ≠ ε2) →
¬ (p : ℤ) ∣ r ε1 (k1 + K + 1) - r ε2 (k2 + K + 1))) ∧
(0 ≤ η ∧ η ≤ 1 / 4 ∧
(∀ ε, ∀ a : ℕ, ((Ns.filter fun n => P ε ∣ m n ε + a).card : ℝ) * P ε ≤ (1 + η) * Ns.card) ∧
(∀ p ∈ S1, ∀ a : ℤ, |((Ns.filter fun n => (p : ℤ) ∣ n + a).card : ℝ) * p - Ns.card|
≤ η * Ns.card)) ∧
((q : ℝ) / 2 ^ (K + 1) ≤ δ ∧ ∑ ε : Fin K → Bool, (1 + η) / P ε ≤ δ) ∧
((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, ∑' k : ℕ, (∑ ε : Fin K → Bool,
(ArithmeticFunction.cardDistinctFactors (n + r ε (k + H + K + 1)).toNat : ℝ))
/ 2 ^ (k + H + K + 1) ≤ δ ∧
Real.sqrt ((Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S2, X p n) ^ 2) ≤ δ ∧
∑ j ∈ Finset.range (M + 1), (2 * Real.pi) ^ j / j.factorial
* |(Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, (∑ p ∈ S1, X p n) ^ j
- ((Fintype.piFinset (fun _ : S1 => Ns)).card : ℝ)⁻¹
* ∑ ω ∈ Fintype.piFinset (fun _ : S1 => Ns), (∑ p : S1, X p (ω p)) ^ j| ≤ δ ∧
(∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns, Real.exp (2 * Real.pi * Real.exp 1 * X p n)
+ ∏ p ∈ S1, (Ns.card : ℝ)⁻¹ * ∑ n ∈ Ns,
Real.exp (-(2 * Real.pi * Real.exp 1) * X p n)) / Real.exp 1 ^ M ≤ δ) ∧
(3 ≤ w ∧ w ≤ R ∧
(2 : ℝ) ^ K * T ≤ Real.log (Real.log R) - Real.log (Real.log w) ∧
∑ p ∈ (Finset.Ioc w R).filter Nat.Prime \ S1, (1 : ℝ) / p ≤ 1) := sorry
obtain ⟨C, hC⟩ := u_mertens_second_interval
have hC0 : 0 ≤ C := by
have h := (abs_nonneg _).trans (hC 2 2 le_rfl le_rfl)
have hl : (0 : ℝ) < Real.log 2 := Real.log_pos (by norm_num)
by_contra hneg
have : C / Real.log 2 < 0 := div_neg_of_neg_of_pos (lt_of_not_ge hneg) hl
linarith
intro q hq
refine ⟨(q : ℝ) ^ 2 / 8, by positivity, fun δ hδ => ?_⟩
-- Tao–Teräväinen Lemma 5.2 (quantitative), proved above: a prime cube in `(Pw/2, Pw]`.
obtain ⟨P0, hP0⟩ := a52_hilbert_cube_primes_quant_two_thirds
obtain ⟨Pw, K, H, hPw, hK1, hH1, hK23, hH23, hrest⟩ := tt_sec5_setup q hq (C + 2) δ hδ P0
obtain ⟨p0, v, hcube, hinj1, hinj2⟩ := hP0 Pw hPw K H hK23 hH23
choose P hPc using hcube
have hP : ∀ ε, (P ε : ℤ) = p0 + ∑ k : Fin K, (if ε k then v k else 0) := fun ε => (hPc ε).2.2.2
have hpr : ∀ ε, (P ε).Prime := fun ε => (hPc ε).1
obtain ⟨B, Ns, m, S1, S2, sgn, r, X, M, η, w, R, ⟨hsgn, hr, hX, hM⟩, ⟨hNs, hm, hrange⟩,
⟨hS1, hS2, hdisj, hcls, hcoll⟩, ⟨hη0, hη14, hequiP, hequi⟩, ⟨hKq, hk1s⟩, ⟨hk2, hk3, hk4, hk5⟩,
⟨hw3, hwR, hT, hmiss⟩⟩ := hrest p0 v P hPc hinj1 hinj2
have hη1 : η ≤ 1 := by linarith
have hpos : ∀ n ∈ Ns, ∀ ε, ∀ k < H, 0 < n + r ε (k + K + 1) :=
fun n hn ε k hk => (hrange n hn ε k hk).1
have hS1p : ∀ p ∈ S1, Nat.Prime p := fun p hp => (Finset.mem_filter.mp (hS1 hp)).2
-- Mertens' second theorem on `(w, R]`, then on `S1`.
have hlogw := f2_one_le_log w hw3
have hmert := hC w R (by omega) hwR
rw [abs_le] at hmert
have hCw : C / Real.log w ≤ C := div_le_self hC0 hlogw
have hIoc := f2_sum_Ioc (fun p => (1 : ℝ) / p) w R hwR
have hlow := f2_S1_lower S1 w R hmiss
have hs : (2 : ℝ) ^ K * (C + 2) - C - 1 ≤ ∑ p ∈ S1, (1 : ℝ) / p := by
linarith [hmert.1]
have hc0' := f2_c0 q K S1 (fun p hp => (hS1p p hp).two_le) η hη0 hη14 C hC0 hs
refine ⟨K, p0, v, P, H, B, Ns, m, S1, S2, sgn, r, X, M, hsgn, hr, hX, hM, hP, hpr, hNs, hm, hrange,
hS1, hS2, hdisj, w_S0 q H B Ns S1 S2 sgn r X hX hpos hcls,
w_5_19 q δ K H Ns S1 sgn r X hsgn hX hpos hcoll hKq,
(w_kappa1 Ns P (fun ε => (hpr ε).pos) m η hη0 hequiP).trans hk1s, hk2, hk3, hk4, hk5,
w_5_21 q K H hK1 hH1 Ns hNs S1 (fun p hp => (hS1p p hp).pos) η hη0 hη1
sgn r X hsgn hX hpos hcoll hequi _ hc0'⟩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).