This journal is in preparation. Submissions are open as a pilot and the editorial board is being formed. Articles marked Demonstration show the format only.
Journal of Machine-Verified MathematicsPeer-reviewed mathematics with machine-checked proofs, for the age of AI

E424/RoughElements/L9Aux.lean

All files · 278 lines · source at the verified commit

1module
2
3public import E424.ToolDefs
4
5@[expose] public section
6
7/-!
8# Lemma 9 auxiliaries (E424, section 3)
9
10Three pure lemmas used by `L9`:
11- `V_lower`: lower bound for the Mertens product `∏_{u<p≤v} (1 - 1/p)`, from its upper bound on the inverse.
12- `pow_card_primeFactors_le`: `C ^ ω(e) ≤ e ^ (1/4)` when every prime factor of `e` is at least `C ^ 4`.
13- `dyadic_bound`: `∑ v e * e ^ (-3/4)` over `e > K0`, when each dyadic block `2^j < e ≤ 2^(j+1)` has
14 weight at most `B`; the bound is `B` times a geometric constant times `(K0/2)^(-3/4)`.
15-/
16
17set_option linter.style.header false
18open Finset
19
20namespace E424.L9Aux
21
22/-- Lower bound for the Mertens product, from the upper bound `hT` on the product of inverses. -/
23theorem V_lower {C : ℝ} (hC : 0 < C) {u v : ℝ} (hu : 2 ≤ u) (huv : u ≤ v)
24 (hT : ∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ))⁻¹ ≤ C * Real.log v / Real.log u) :
25 Real.log u / (C * Real.log v) ≤ ∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ)) := by
26 have hpos : ∀ p ∈ primesIoc u v, 0 < 1 - 1 / (p : ℝ) := by
27 intro p hp
28 have hprime : p.Prime := (Finset.mem_filter.mp hp).2
29 have h2 : (2 : ℝ) ≤ p := by exact_mod_cast hprime.two_le
30 rw [sub_pos, div_lt_one (by linarith)]
31 linarith
32 have hP : 0 < ∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ)) := Finset.prod_pos hpos
33 have hlu : 0 < Real.log u := Real.log_pos (by linarith)
34 have hlv : 0 < Real.log v := lt_of_lt_of_le hlu (Real.log_le_log (by linarith) huv)
35 have hCv : 0 < C * Real.log v := mul_pos hC hlv
36 rw [Finset.prod_inv_distrib] at hT
37 have h1 : 1 ≤ (∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ))) * (C * Real.log v / Real.log u) := by
38 have := mul_le_mul_of_nonneg_left hT hP.le
39 rwa [mul_inv_cancel₀ hP.ne'] at this
40 have hx : 0 < C * Real.log v / Real.log u := div_pos hCv hlu
41 calc Real.log u / (C * Real.log v) = 1 / (C * Real.log v / Real.log u) := by
42 field_simp
43 _ ≤ (∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ))) * (C * Real.log v / Real.log u) /
44 (C * Real.log v / Real.log u) := by gcongr
45 _ = ∏ p ∈ primesIoc u v, (1 - 1 / (p : ℝ)) := by field_simp
46
47/-- `C ^ ω(e) ≤ e ^ (1/4)` when every prime factor of `e` is at least `C ^ 4`. -/
48theorem pow_card_primeFactors_le {C : ℝ} (hC : 0 ≤ C) {e : ℕ} (he : e ≠ 0)
49 (hp : ∀ p ∈ e.primeFactors, C ^ 4 ≤ (p : ℝ)) :
50 C ^ e.primeFactors.card ≤ (e : ℝ) ^ (1 / 4 : ℝ) := by
51 rw [← Finset.prod_const]
52 have h2 : ∏ _p ∈ e.primeFactors, C ≤ ∏ p ∈ e.primeFactors, (p : ℝ) ^ (1 / 4 : ℝ) := by
53 apply Finset.prod_le_prod₀ (fun _ _ => hC)
54 intro p hpm
55 calc C = (C ^ 4) ^ (1 / 4 : ℝ) := by
56 rw [← Real.rpow_natCast, ← Real.rpow_mul hC]
57 norm_num
58 _ ≤ (p : ℝ) ^ (1 / 4 : ℝ) :=
59 Real.rpow_le_rpow (pow_nonneg hC 4) (hp p hpm) (by norm_num)
60 have h3 : ∏ p ∈ e.primeFactors, (p : ℝ) ^ (1 / 4 : ℝ) =
61 (∏ p ∈ e.primeFactors, (p : ℝ)) ^ (1 / 4 : ℝ) :=
62 (Real.finsetProd_rpow _ _ (fun p _ => Nat.cast_nonneg p) _)
63 have h4 : ∏ p ∈ e.primeFactors, (p : ℝ) ≤ (e : ℝ) := by
64 have : (∏ p ∈ e.primeFactors, p) ≤ e :=
65 Nat.le_of_dvd (Nat.pos_of_ne_zero he) (Nat.prod_primeFactors_dvd e)
66 rw [← Nat.cast_prod]
67 exact_mod_cast this
68 have h5 : (∏ p ∈ e.primeFactors, (p : ℝ)) ^ (1 / 4 : ℝ) ≤ (e : ℝ) ^ (1 / 4 : ℝ) :=
69 Real.rpow_le_rpow (Finset.prod_nonneg fun p _ => Nat.cast_nonneg p) h4 (by norm_num)
70 rw [h3] at h2
71 exact h2.trans h5
72
73/-- Dyadic summation. Weight `e ^ (-3/4)` on `e ∈ T`, where `T ⊆ (K0, Y]`. Each dyadic fiber
74`{e | ⌊log₂ (e-1)⌋ = j}` (that is `2^j < e ≤ 2^(j+1)`) carries mass at most `B` in `v`, as long as
75`2^j < Y`. The total is `B` times a geometric constant times `(K0/2)^(-3/4)`. -/
76theorem dyadic_bound {v : ℕ → ℝ} (hv : ∀ e, 0 ≤ v e) {K0 : ℕ} (hK0 : 1 ≤ K0) {Y B : ℝ}
77 (hB0 : 0 ≤ B) (T : Finset ℕ) (hT : ∀ e ∈ T, K0 < e ∧ (e : ℝ) ≤ Y)
78 (hB : ∀ j : ℕ, (2 : ℝ) ^ j < Y → ∑ e ∈ T.filter (fun e => Nat.log 2 (e - 1) = j), v e ≤ B) :
79 ∑ e ∈ T, v e * (e : ℝ) ^ (-(3 / 4 : ℝ)) ≤
80 B * ((1 - (2 : ℝ) ^ (-(3 / 4 : ℝ)))⁻¹ * ((K0 : ℝ) / 2) ^ (-(3 / 4 : ℝ))) := by
81 set s : ℝ := -(3 / 4 : ℝ) with hs
82 set r : ℝ := (2 : ℝ) ^ s with hr
83 set L : ℕ → ℕ := fun e => Nat.log 2 (e - 1) with hL
84 have hr0 : 0 ≤ r := by positivity
85 have hr1 : r < 1 := Real.rpow_lt_one_of_one_lt_of_neg (by norm_num) (by norm_num)
86 have hpow : ∀ j : ℕ, ((2 : ℝ) ^ j) ^ s = r ^ j := by
87 intro j
88 rw [hr, ← Real.rpow_natCast, ← Real.rpow_mul (by norm_num), ← Real.rpow_natCast,
89 ← Real.rpow_mul (by norm_num)]
90 congr 1
91 ring
92 -- every `e ∈ T` lies strictly above its fiber's `2^j`
93 have hgt : ∀ e ∈ T, (2 : ℝ) ^ (L e) < e := by
94 intro e he
95 have hK := (hT e he).1
96 have h1 : 2 ^ (L e) ≤ e - 1 := Nat.pow_log_le_self 2 (by omega)
97 have h2 : 2 ^ (L e) < e := by omega
98 exact_mod_cast h2
99 have hsup : ∀ e ∈ T, K0 ≤ e - 1 ∧ e - 1 < 2 ^ ((L e) + 1) := by
100 intro e he
101 have hK := (hT e he).1
102 refine ⟨by omega, ?_⟩
103 have := Nat.lt_pow_succ_log_self (b := 2) (by norm_num) (e - 1)
104 exact this
105 classical
106 rw [← Finset.sum_fiberwise_of_maps_to (g := L) (t := T.image L)
107 (fun e he => Finset.mem_image_of_mem L he)]
108 -- each fiber
109 have hfiber : ∀ j ∈ T.image L, ∑ e ∈ T.filter (fun e => L e = j), v e * (e : ℝ) ^ s ≤
110 B * r ^ j := by
111 intro j hj
112 obtain ⟨e0, he0, hLe0⟩ := Finset.mem_image.mp hj
113 have hYj : (2 : ℝ) ^ j < Y := by
114 have h1 := hgt e0 he0
115 rw [hLe0] at h1
116 exact h1.trans_le (hT e0 he0).2
117 calc ∑ e ∈ T.filter (fun e => L e = j), v e * (e : ℝ) ^ s
118 ≤ ∑ e ∈ T.filter (fun e => L e = j), v e * r ^ j := by
119 refine Finset.sum_le_sum fun e he => ?_
120 have hle := Finset.mem_filter.mp he
121 have hpos : (0 : ℝ) < (2 : ℝ) ^ j := by positivity
122 have hjle : (2 : ℝ) ^ j ≤ e := by
123 have := hgt e hle.1
124 rw [hle.2] at this
125 exact this.le
126 rw [← hpow]
127 exact mul_le_mul_of_nonneg_left
128 (Real.rpow_le_rpow_of_nonpos hpos hjle (by norm_num [hs])) (hv e)
129 _ = (∑ e ∈ T.filter (fun e => L e = j), v e) * r ^ j := by rw [Finset.sum_mul]
130 _ ≤ B * r ^ j := by
131 refine mul_le_mul_of_nonneg_right ?_ (by positivity)
132 exact hB j hYj
133 refine (Finset.sum_le_sum hfiber).trans ?_
134 rw [← Finset.mul_sum]
135 refine mul_le_mul_of_nonneg_left ?_ hB0
136 -- the fibers live in `[j0, N)`, `j0 = ⌊log₂ K0⌋`
137 set j0 := Nat.log 2 K0 with hj0
138 set N := (T.image L).sup id + 1 with hN
139 have hsub : T.image L ⊆ Finset.Ico j0 N := by
140 intro j hj
141 obtain ⟨e, he, rfl⟩ := Finset.mem_image.mp hj
142 rw [Finset.mem_Ico]
143 refine ⟨?_, ?_⟩
144 · have h1 := (hsup e he).2
145 have hK0 : K0 < 2 ^ (L e + 1) := by have := (hsup e he).1; omega
146 have := Nat.log_lt_of_lt_pow (by omega : K0 ≠ 0) hK0
147 omega
148 · have := Finset.le_sup (f := id) (Finset.mem_image_of_mem L he)
149 simp only [id] at this
150 omega
151 have hK0lt : K0 < 2 ^ (j0 + 1) := Nat.lt_pow_succ_log_self (by norm_num) K0
152 have hK0R : (K0 : ℝ) < 2 ^ (j0 + 1) := by exact_mod_cast hK0lt
153 have hhalf : (K0 : ℝ) / 2 ≤ (2 : ℝ) ^ j0 := by rw [pow_succ] at hK0R; linarith
154 have hK0pos : (0 : ℝ) < (K0 : ℝ) / 2 := by
155 have : (1 : ℝ) ≤ K0 := by exact_mod_cast hK0
156 linarith
157 have hrj : r ^ j0 ≤ ((K0 : ℝ) / 2) ^ s := by
158 rw [← hpow]
159 exact Real.rpow_le_rpow_of_nonpos hK0pos hhalf (by norm_num [hs])
160 calc ∑ j ∈ T.image L, r ^ j ≤ ∑ j ∈ Finset.Ico j0 N, r ^ j :=
161 Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity)
162 _ ≤ r ^ j0 / (1 - r) := geom_sum_Ico_le_of_lt_one hr0 hr1
163 _ = (1 - r)⁻¹ * r ^ j0 := by rw [div_eq_inv_mul]
164 _ ≤ (1 - r)⁻¹ * ((K0 : ℝ) / 2) ^ s :=
165 mul_le_mul_of_nonneg_left hrj (inv_nonneg.2 (by linarith))
166
167/-- Sieve counting: the weighted sum `∑_{d ∣ P} lm d · #{p | d ∣ S p}` is at most the number of pairs
168whose value is coprime to `P`, provided the Brun-Hooley weights satisfy `∑_{d ∣ (S p, P)} lm d ≤ [(S p, P) = 1]`. -/
169theorem sieve_count (pairs : Finset (ℕ × ℕ)) (S : ℕ × ℕ → ℕ) (P : ℕ) (lm : ℕ → ℝ)
170 (hlm : ∀ p ∈ pairs, ∑ d ∈ P.divisors with d ∣ S p, lm d ≤ if (S p).Coprime P then 1 else 0) :
171 ∑ d ∈ P.divisors, lm d * ((pairs.filter fun p => d ∣ S p).card : ℝ) ≤
172 ((pairs.filter fun p => (S p).Coprime P).card : ℝ) := by
173 classical
174 have hL : ∑ d ∈ P.divisors, lm d * ((pairs.filter fun p => d ∣ S p).card : ℝ) =
175 ∑ p ∈ pairs, ∑ d ∈ P.divisors with d ∣ S p, lm d := by
176 simp only [Finset.card_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, Nat.cast_zero,
177 Finset.mul_sum, Finset.sum_filter]
178 rw [Finset.sum_comm]
179 refine Finset.sum_congr rfl fun p _ => Finset.sum_congr rfl fun d _ => ?_
180 split_ifs <;> simp
181 have hR : ((pairs.filter fun p => (S p).Coprime P).card : ℝ) =
182 ∑ p ∈ pairs, if (S p).Coprime P then 1 else 0 := by
183 rw [Finset.card_filter]
184 push_cast
185 rfl
186 rw [hL, hR]
187 exact Finset.sum_le_sum hlm
188
189/-- Expanding `∑_d lm d · N_d` when `N_d = (M + ∑_{e ∣ d, e > 1} w e) / d` for every `d ∣ P`:
190the main term `M ∑ lm d / d` and the error `∑_{e > 1} w e ∑_{e ∣ d} lm d / d`. -/
191theorem sieve_expand (P : ℕ) (lm w : ℕ → ℝ) (M : ℝ) (N : ℕ → ℝ)
192 (hN : ∀ d ∈ P.divisors, N d = (M + ∑ e ∈ d.divisors.erase 1, w e) / d) :
193 ∑ d ∈ P.divisors, lm d * N d = M * ∑ d ∈ P.divisors, lm d / d +
194 ∑ e ∈ P.divisors.erase 1, w e * ∑ d ∈ P.divisors with e ∣ d, lm d / d := by
195 classical
196 rw [Finset.sum_congr rfl fun d hd => by rw [hN d hd]]
197 have h1 : ∀ d ∈ P.divisors, lm d * ((M + ∑ e ∈ d.divisors.erase 1, w e) / d) =
198 M * (lm d / d) + ∑ e ∈ d.divisors.erase 1, (lm d / d) * w e := by
199 intro d _
200 rw [← Finset.mul_sum]
201 ring
202 rw [Finset.sum_congr rfl h1, Finset.sum_add_distrib, ← Finset.mul_sum]
203 congr 1
204 rw [Finset.sum_comm' (t' := P.divisors.erase 1) (s' := fun e => P.divisors.filter fun d => e ∣ d)]
205 · refine Finset.sum_congr rfl fun e _ => ?_
206 rw [← Finset.sum_mul, mul_comm]
207 · intro d e
208 simp only [Finset.mem_erase, Nat.mem_divisors, Finset.mem_filter, ne_eq]
209 have hdvd : ∀ x y : ℕ, y ∣ x → x ∣ P → y ∣ P := fun _ _ h1 h2 => h1.trans h2
210 have hne : ∀ x : ℕ, x ∣ P → P ≠ 0 → x ≠ 0 := fun _ h1 h2 => by
211 rintro rfl
212 exact h2 (zero_dvd_iff.mp h1)
213 constructor <;> intro h <;> aesop
214
215/-- Choice of `K0`: large, above `KT`, `7` and `B`, with `m · (K0/2)^(-3/4) ≤ t`. -/
216theorem exists_K0 (KT : ℕ) {m t B : ℝ} (hm : 0 < m) (ht : 0 < t) :
217 ∃ K0 : ℕ, KT ≤ K0 ∧ 7 ≤ K0 ∧ B ≤ K0 ∧ m * ((K0 : ℝ) / 2) ^ (-(3 / 4 : ℝ)) ≤ t := by
218 have hT : Filter.Tendsto (fun K : ℕ => ((K : ℝ) / 2) ^ (-(3 / 4 : ℝ))) Filter.atTop
219 (nhds 0) :=
220 (tendsto_rpow_neg_atTop (by norm_num : (0 : ℝ) < 3 / 4)).comp
221 (tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 2))
222 have h1 : ∀ᶠ K : ℕ in Filter.atTop, ((K : ℝ) / 2) ^ (-(3 / 4 : ℝ)) < t / m :=
223 (tendsto_order.1 hT).2 _ (div_pos ht hm)
224 obtain ⟨K1, hK1⟩ := Filter.eventually_atTop.1 h1
225 refine ⟨K1 + KT + 7 + ⌈B⌉₊, by omega, by omega, ?_, ?_⟩
226 · have hB : B ≤ ⌈B⌉₊ := Nat.le_ceil B
227 have hc : ⌈B⌉₊ ≤ K1 + KT + 7 + ⌈B⌉₊ := by omega
228 have hc' : (⌈B⌉₊ : ℝ) ≤ ((K1 + KT + 7 + ⌈B⌉₊ : ℕ) : ℝ) := by exact_mod_cast hc
229 linarith
230 · have h := hK1 (K1 + KT + 7 + ⌈B⌉₊) (by omega)
231 have h' := (lt_div_iff₀ hm).1 h
232 rw [mul_comm]
233 exact h'.le
234
235/-- Eventually in `X`, the size conditions of `L9` hold. With `t = X^(1/3)` and `z = X^(1/100)`. -/
236theorem eventually_params {α x0 Cq K0r P : ℝ} :
237 ∃ X0 : ℝ, ∀ X ≥ X0, 1 < X ∧ K0r ≤ X ^ (1 / 100 : ℝ) ∧ x0 ≤ X ^ (1 / 3 : ℝ) ∧
238 32 / α ≤ X ^ (1 / 3 : ℝ) ∧ 4 / α ≤ X ^ (1 / 3 : ℝ) ∧ Cq ≤ X ^ (1 / 3 : ℝ) ∧
239 8 * P / α ≤ X ^ (7 / 75 : ℝ) := by
240 have h1 : ∀ᶠ X in Filter.atTop, K0r ≤ X ^ (1 / 100 : ℝ) :=
241 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop K0r
242 have h2 : ∀ᶠ X in Filter.atTop, x0 ≤ X ^ (1 / 3 : ℝ) :=
243 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop x0
244 have h3 : ∀ᶠ X in Filter.atTop, 32 / α ≤ X ^ (1 / 3 : ℝ) :=
245 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _
246 have h4 : ∀ᶠ X in Filter.atTop, 4 / α ≤ X ^ (1 / 3 : ℝ) :=
247 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _
248 have h5 : ∀ᶠ X in Filter.atTop, Cq ≤ X ^ (1 / 3 : ℝ) :=
249 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop Cq
250 have h6 : ∀ᶠ X in Filter.atTop, 8 * P / α ≤ X ^ (7 / 75 : ℝ) :=
251 (tendsto_rpow_atTop (by norm_num)).eventually_ge_atTop _
252 have h7 : ∀ᶠ X : ℝ in Filter.atTop, 1 < X := Filter.eventually_gt_atTop 1
253 have hall : ∀ᶠ X in Filter.atTop, 1 < X ∧ K0r ≤ X ^ (1 / 100 : ℝ) ∧ x0 ≤ X ^ (1 / 3 : ℝ) ∧
254 32 / α ≤ X ^ (1 / 3 : ℝ) ∧ 4 / α ≤ X ^ (1 / 3 : ℝ) ∧ Cq ≤ X ^ (1 / 3 : ℝ) ∧
255 8 * P / α ≤ X ^ (7 / 75 : ℝ) := by
256 filter_upwards [h1, h2, h3, h4, h5, h6, h7] with X e1 e2 e3 e4 e5 e6 e7
257 exact ⟨e7, e1, e2, e3, e4, e5, e6⟩
258 exact Filter.eventually_atTop.1 hall
259
260/-- `(z, c) ↦ Q z - c` is injective on pairs with `0 < c < Q`, `1 ≤ Q z - c`. -/
261theorem qz_inj {Q z1 z2 c1 c2 : ℕ} (hc1 : c1 < Q) (hc2 : c2 < Q)
262 (h : Q * z1 - c1 = Q * z2 - c2) (hx : 1 ≤ Q * z1 - c1) : z1 = z2 ∧ c1 = c2 := by
263 have e1 : c1 ≤ Q * z1 := by omega
264 have e2 : c2 ≤ Q * z2 := by omega
265 have hz : z1 = z2 := by
266 rcases lt_trichotomy z1 z2 with h12 | h12 | h12
267 · have h3 : Q * (z1 + 1) ≤ Q * z2 := Nat.mul_le_mul_left Q h12
268 rw [mul_add, mul_one] at h3
269 omega
270 · exact h12
271 · have h3 : Q * (z2 + 1) ≤ Q * z1 := Nat.mul_le_mul_left Q h12
272 rw [mul_add, mul_one] at h3
273 omega
274 subst hz
275 exact ⟨rfl, by omega⟩
276
277end E424.L9Aux
278