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/L9.lean

All files · 622 lines · source at the verified commit

1module
2
3public import E424.RoughElements.L8
4public import E424.Tools.T2
5public import E424.Tools.T10
6public import E424.RoughElements.L9Aux
7
8@[expose] public section
9
10/-!
11# Section 3 of the outline: L9
12-/
13
14set_option linter.style.header false
15open Finset
16
17namespace E424
18
19open L9Aux
20
21/-- The set counted in Lemma 9. -/
22noncomputable def rough9 (a b X : ℝ) (ρ : ℕ) : Finset ℕ :=
23 open Classical in (AIoc (a * X) (b * X)).filter fun s =>
24 s % 54 = ρ ∧ Rough (X ^ (1 / 100 : ℝ)) s
25
26theorem mem_rough9 {a b X : ℝ} {ρ s : ℕ} (ha : 0 ≤ a * X) (hb : 0 ≤ b * X) :
27 s ∈ rough9 a b X ρ ↔ (a * X < s ∧ (s : ℝ) ≤ b * X) ∧ s ∈ A ∧ s % 54 = ρ ∧
28 Rough (X ^ (1 / 100 : ℝ)) s := by
29 simp only [rough9, AIoc, mem_filter, mem_Ioc, Nat.floor_lt ha, Nat.le_floor_iff hb]
30 tauto
31
32
33set_option maxHeartbeats 1000000 in
34/-- **Lemma 9** (sieve).
35
36Constants, in the order they are fixed:
37* `κ, K` from `inputK`; `α, x0` from `L3_top`; `cB, CB, KT` from `T2_brun_hooley`; `CM` from `T10_mertens_prod`;
38 `C8` from `L8`.
39* `ε = CB · √(C8/(α κ)) · (1 - 2^(-3/4))⁻¹`, and `K0 ≥ max(KT, 7, CB^4)` with `ε (K0/2)^(-3/4) ≤ cB/2`.
40* `P = ∏_{4 < p ≤ K0} p`; `k` from `L7 P`; `g = 6^k`; `a = min 1 (10 g α)`, `b = 84 g`,
41 `c = 25 cB α κ log K0 / CM`.
42* `X0` from `eventually_params`. For `X ≥ X0`: `t = X^(1/3)`, `z = X^(1/100)`, `n` a good exponent
43 with `Q = q^n ∈ [t, t²]`, `Z = X/Q ∈ [t, t²]`, `𝒵 = A ∩ (αZ/2, Z]`, `𝒞 = C_Q`.
44 Sieve over `𝒫 = ∏_{K0 < p ≤ z} p` with the Brun-Hooley weights `lm` of `T2`.
45
46Main term `M · cB · V` with `M = |𝒵||𝒞| ≥ ακX/2` and `V ≥ log K0 / (CM log z)`. Remainder
47`≤ M V ε (K0/2)^(-3/4)` by `dyadic_bound` on `L8`'s blocks. Survivors `s = S(Qz - c)` are in `rough9`
48and the map is injective. -/
49theorem L9 : ∃ a b c X0 : ℝ, 0 < a ∧ a ≤ 1 ∧ 1 ≤ b ∧ a < b ∧ 0 < c ∧ 1 < X0 ∧
50 ∀ X ≥ X0, ∀ ρ : ℕ, ρ = 53 ∨ ρ = 23 →
51 c * X / Real.log X ≤ (rough9 a b X ρ).card := by
52 classical
53 obtain ⟨κ, hκ, hκ1, K, hK⟩ := inputK
54 obtain ⟨α, hα, hα1, x0, hx0, hL3⟩ := L3_top
55 obtain ⟨cB, CB, KT, hcB, hCB1, hKT2, hT2⟩ := T2_brun_hooley
56 obtain ⟨CM, hCM, hT10⟩ := T10_mertens_prod
57 obtain ⟨C8, hC8, hL8⟩ := L8
58 have hr1 : (2 : ℝ) ^ (-(3 / 4 : ℝ)) < 1 :=
59 Real.rpow_lt_one_of_one_lt_of_neg (by norm_num) (by norm_num)
60 have hr0 : 0 ≤ (2 : ℝ) ^ (-(3 / 4 : ℝ)) := by positivity
61 set ε : ℝ := CB * Real.sqrt (C8 / (α * κ)) * (1 - (2 : ℝ) ^ (-(3 / 4 : ℝ)))⁻¹ with hε
62 have hεpos : 0 < ε :=
63 mul_pos (mul_pos (by linarith) (Real.sqrt_pos.2 (div_pos hC8 (mul_pos hα hκ))))
64 (inv_pos.2 (by linarith))
65 obtain ⟨K0, hK0T, hK07, hK0C, hK0ε⟩ :=
66 exists_K0 KT (t := cB / 2) (B := CB ^ 4) hεpos (by linarith)
67 have hK0R : (7 : ℝ) ≤ K0 := by exact_mod_cast hK07
68 -- the prime set of P, and its basic facts
69 set P : ℕ := ∏ p ∈ primesIoc 4 (K0 : ℝ), p with hP
70 have hmemP : ∀ p : ℕ, p ∈ primesIoc 4 (K0 : ℝ) ↔ 4 < p ∧ p ≤ K0 ∧ p.Prime := by
71 intro p
72 rw [BH.mem_primesIoc (by norm_num) (by positivity)]
73 constructor
74 · rintro ⟨h1, h2, h3⟩
75 exact ⟨by exact_mod_cast h1, by exact_mod_cast h2, h3⟩
76 · rintro ⟨h1, h2, h3⟩
77 exact ⟨by exact_mod_cast h1, by exact_mod_cast h2, h3⟩
78 have hPsq : Squarefree P := BH.squarefree_P (fun p hp => ((hmemP p).1 hp).2.2)
79 have hPpos : 0 < P := Finset.prod_pos fun p hp => ((hmemP p).1 hp).2.2.pos
80 have hcop6 : P.Coprime 6 := by
81 rw [hP]
82 refine Nat.Coprime.prod_left fun p hp => ?_
83 obtain ⟨_, _, hpr⟩ := (hmemP p).1 hp
84 refine (Nat.Prime.coprime_iff_not_dvd hpr).2 fun h => ?_
85 have := Nat.le_of_dvd (by norm_num) h
86 interval_cases p <;> first | omega | norm_num at hpr
87 have h35 : 35 ∣ P := by
88 have h5 : 5 ∈ primesIoc 4 (K0 : ℝ) := (hmemP 5).2 ⟨by norm_num, by omega, by norm_num⟩
89 have h7 : 7 ∈ primesIoc 4 (K0 : ℝ) := (hmemP 7).2 ⟨by norm_num, hK07, by norm_num⟩
90 have hsub : ({5, 7} : Finset ℕ) ⊆ primesIoc 4 (K0 : ℝ) := by
91 intro p hp
92 rw [Finset.mem_insert, Finset.mem_singleton] at hp
93 rcases hp with rfl | rfl <;> assumption
94 have := Finset.prod_dvd_prod_of_subset ({5, 7} : Finset ℕ) (primesIoc 4 (K0 : ℝ)) id hsub
95 rw [hP]
96 norm_num [Finset.prod_pair] at this ⊢
97 exact this
98 -- primes dividing `6P` are at most `K0`, and primes `≤ K0` (other than 2, 3) divide `P`
99 have hsmall : ∀ k : ℕ, k.Prime → k ∣ 6 * P → k ≤ K0 := by
100 intro k hk hdiv
101 rcases (Nat.Prime.dvd_mul hk).1 hdiv with h6 | hPk
102 · have := Nat.le_of_dvd (by norm_num) h6
103 omega
104 · rw [hP] at hPk
105 obtain ⟨q', hq', hkq⟩ := (Prime.dvd_finsetProd_iff hk.prime _).1 hPk
106 have hk' : k = q' := (Nat.prime_dvd_prime_iff_eq hk ((hmemP q').1 hq').2.2).1 hkq
107 rw [hk']
108 exact ((hmemP q').1 hq').2.1
109 have hdivP : ∀ k : ℕ, k.Prime → k ≤ K0 → k ∣ 6 * P := by
110 intro k hk hkK
111 by_cases h4 : k ≤ 4
112 · have h6 : k ∣ 6 := by
113 interval_cases k <;> first | decide | norm_num at hk
114 exact Dvd.dvd.mul_right h6 P
115 · have hkP : k ∣ P := by
116 rw [hP]
117 exact Finset.dvd_prod_of_mem (fun p => p) ((hmemP k).2 ⟨by omega, hkK, hk⟩)
118 exact Dvd.dvd.mul_left hkP 6
119 -- L7 gives the exponent `k` and the maps `o`
120 obtain ⟨k, hk2, hk⟩ := L7 P hcop6 hPpos
121 obtain ⟨X0, hX0⟩ := eventually_params (α := α) (x0 := x0)
122 (Cq := ((Inp.q : ℝ)) ^ (K + 2)) (K0r := (K0 : ℝ)) (P := (P : ℝ))
123 have hg1 : (1 : ℝ) ≤ (6 : ℝ) ^ k := one_le_pow₀ (by norm_num)
124 refine ⟨min 1 (10 * (6 : ℝ) ^ k * α), 84 * (6 : ℝ) ^ k,
125 25 * cB * α * κ * Real.log K0 / CM, max X0 2, lt_min one_pos (mul_pos (mul_pos (by norm_num)
126 (by linarith)) hα), min_le_left _ _, by linarith, ?_, ?_, ?_, ?_⟩
127 · exact lt_of_le_of_lt (min_le_left _ _) (by linarith)
128 · exact div_pos (mul_pos (mul_pos (mul_pos (mul_pos (by norm_num) hcB) hα) hκ)
129 (Real.log_pos (by linarith))) hCM
130 · exact lt_of_lt_of_le one_lt_two (le_max_right _ _)
131 intro X hX ρ hρ
132 obtain ⟨hX1, hz0, ht0, ht1, ht2, hQ0, hP8⟩ := hX0 X (le_of_max_le_left hX)
133 obtain ⟨o, ho, hAk, hmod⟩ := hk ρ hρ
134 have hXpos : 0 < X := by linarith
135 obtain ⟨t, ht⟩ : ∃ t : ℝ, t = X ^ (1 / 3 : ℝ) := ⟨_, rfl⟩
136 obtain ⟨z, hz⟩ : ∃ z : ℝ, z = X ^ (1 / 100 : ℝ) := ⟨_, rfl⟩
137 rw [← ht] at ht0 ht1 ht2 hQ0
138 rw [← hz] at hz0
139 have htpos : 0 < t := by rw [ht]; exact Real.rpow_pos_of_pos hXpos _
140 have hzpos : 0 < z := by rw [hz]; exact Real.rpow_pos_of_pos hXpos _
141 have ht1' : 1 < t := by rw [ht]; exact Real.one_lt_rpow hX1 (by norm_num)
142 have hX3 : t ^ 3 = X := by
143 rw [ht, ← Real.rpow_natCast, ← Real.rpow_mul hXpos.le]
144 norm_num
145 have hα0 : α ≠ 0 := hα.ne'
146 -- `8 P z^24 ≤ α t`, from `8P/α ≤ X^(7/75)` and `t = z^24 X^(7/75)`
147 have hz24P : 8 * (P : ℝ) * z ^ 24 ≤ α * t := by
148 have e1 : t = z ^ 24 * X ^ (7 / 75 : ℝ) := by
149 rw [ht, hz, ← Real.rpow_natCast (X ^ (1 / 100 : ℝ)) 24, ← Real.rpow_mul hXpos.le,
150 ← Real.rpow_add hXpos]
151 norm_num
152 calc 8 * (P : ℝ) * z ^ 24 = (8 * P / α) * (α * z ^ 24) := by field_simp
153 _ ≤ X ^ (7 / 75 : ℝ) * (α * z ^ 24) :=
154 mul_le_mul_of_nonneg_right hP8 (mul_nonneg hα.le (pow_nonneg hzpos.le 24))
155 _ = α * t := by rw [e1]; ring
156 -- the good exponent `n` and `Q = q^n ∈ [t, t²]`
157 have hqN : 2 ≤ Inp.q := by norm_num [Inp.q]
158 have hq2 : (2 : ℝ) ≤ Inp.q := by exact_mod_cast hqN
159 have hlogq : 0 < Real.log (Inp.q : ℝ) := Real.log_pos (by linarith)
160 have hlogX : 0 ≤ Real.log X := Real.log_nonneg hX1.le
161 obtain ⟨M, hM⟩ : ∃ M : ℕ, M = ⌈Real.log X / (3 * Real.log (Inp.q : ℝ))⌉₊ + 1 :=
162 ⟨_, rfl⟩
163 have hdiv0 : 0 ≤ Real.log X / (3 * Real.log (Inp.q : ℝ)) :=
164 div_nonneg hlogX (by linarith)
165 have hMlo : Real.log X / (3 * Real.log (Inp.q : ℝ)) ≤ M := by
166 have := Nat.le_ceil (Real.log X / (3 * Real.log (Inp.q : ℝ)))
167 rw [hM]
168 push_cast
169 linarith
170 have hMhi : (M : ℝ) ≤ Real.log X / (3 * Real.log (Inp.q : ℝ)) + 2 := by
171 have := Nat.ceil_lt_add_one hdiv0
172 rw [hM]
173 push_cast
174 linarith
175 have hMpos : 0 < M := by rw [hM]; omega
176 obtain ⟨n, hMn, hnK, 𝒞, hκQ, h𝒞⟩ := hK M hMpos
177 have hnle : (n : ℝ) ≤ M + K := by exact_mod_cast hnK
178 have hMn' : (M : ℝ) ≤ n := by exact_mod_cast hMn
179 have hnpos : 1 ≤ n := by omega
180 have hkey : Real.log X / (3 * Real.log (Inp.q : ℝ)) * Real.log (Inp.q : ℝ) =
181 Real.log X / 3 := by
182 field_simp
183 have hlogt : Real.log t = Real.log X / 3 := by
184 rw [ht, Real.log_rpow hXpos]
185 ring
186 have hQN : 0 < Inp.q ^ n := pow_pos (by omega) n
187 have hQpos : (0 : ℝ) < ((Inp.q ^ n : ℕ) : ℝ) := Nat.cast_pos.2 hQN
188 have hQlo : t ≤ ((Inp.q ^ n : ℕ) : ℝ) := by
189 rw [← Real.log_le_log_iff htpos hQpos, Nat.cast_pow, Real.log_pow, hlogt]
190 have := mul_le_mul_of_nonneg_right (hMlo.trans hMn') hlogq.le
191 rw [hkey] at this
192 exact this
193 have hQhi : ((Inp.q ^ n : ℕ) : ℝ) ≤ t ^ 2 := by
194 have ht2pos : 0 < t ^ 2 := by positivity
195 rw [← Real.log_le_log_iff hQpos ht2pos, Nat.cast_pow, Real.log_pow, Real.log_pow, hlogt]
196 have hlq : ((K : ℝ) + 2) * Real.log (Inp.q : ℝ) =
197 Real.log ((Inp.q : ℝ) ^ (K + 2)) := by
198 rw [Real.log_pow]
199 push_cast
200 ring
201 have hle : Real.log ((Inp.q : ℝ) ^ (K + 2)) ≤ Real.log t :=
202 Real.log_le_log (by positivity) hQ0
203 have hn2 : (n : ℝ) * Real.log (Inp.q : ℝ) ≤ (M + K) * Real.log (Inp.q : ℝ) :=
204 mul_le_mul_of_nonneg_right hnle hlogq.le
205 have hM2 : (M : ℝ) * Real.log (Inp.q : ℝ) ≤
206 Real.log X / 3 + 2 * Real.log (Inp.q : ℝ) := by
207 have := mul_le_mul_of_nonneg_right hMhi hlogq.le
208 rw [add_mul, hkey] at this
209 linarith
210 push_cast
211 linarith
212 -- `Z = X / Q ∈ [t, t²]`
213 obtain ⟨Z, hZ⟩ : ∃ Z : ℝ, Z = X / ((Inp.q ^ n : ℕ) : ℝ) := ⟨_, rfl⟩
214 have hQZ : ((Inp.q ^ n : ℕ) : ℝ) * Z = X := by
215 rw [hZ]
216 field_simp
217 have hZt : t ≤ Z := by
218 rw [hZ, le_div_iff₀ hQpos]
219 calc t * ((Inp.q ^ n : ℕ) : ℝ) ≤ t * t ^ 2 := mul_le_mul_of_nonneg_left hQhi htpos.le
220 _ = X := by rw [← hX3]; ring
221 have hx0Z : x0 ≤ Z := ht0.trans hZt
222 have hαt : 32 ≤ α * t := by
223 have := (div_le_iff₀ hα).1 ht1
224 linarith
225 have h4α : 4 ≤ α * t := by
226 have := (div_le_iff₀ hα).1 ht2
227 linarith
228 have hαZ : 32 ≤ α * Z := le_trans hαt (mul_le_mul_of_nonneg_left hZt hα.le)
229 have hZ0 : 0 ≤ Z := by linarith
230 -- the sieve set `𝒵 = A ∩ (αZ/2, Z]`, and `𝒞 = C_Q`
231 obtain ⟨𝒵, h𝒵⟩ : ∃ 𝒵 : Finset ℕ, 𝒵 = AIoc (α * Z / 2) Z := ⟨_, rfl⟩
232 have hcard𝒵 : α * Z / 2 ≤ (𝒵.card : ℝ) := by rw [h𝒵]; exact hL3 Z hx0Z
233 have hmem𝒵 : ∀ w ∈ 𝒵, α * Z / 2 < w ∧ (w : ℝ) ≤ Z ∧ w ∈ A := by
234 intro w hw
235 rw [h𝒵] at hw
236 have hu0 : 0 ≤ α * Z / 2 := div_nonneg (mul_nonneg hα.le hZ0) (by norm_num)
237 simp only [AIoc, Finset.mem_filter, Finset.mem_Ioc, Nat.floor_lt hu0,
238 Nat.le_floor_iff hZ0] at hw
239 exact ⟨hw.1.1, hw.1.2, hw.2⟩
240 have hcond𝒵 : ∀ w ∈ 𝒵, 1 ≤ w ∧ (w : ℝ) ≤ Z := by
241 intro w hw
242 obtain ⟨h1, h2, _⟩ := hmem𝒵 w hw
243 have h16 : (16 : ℝ) < w := by linarith
244 have h16' : 16 < w := by exact_mod_cast h16
245 exact ⟨by omega, h2⟩
246 have hcond𝒞 : ∀ c ∈ 𝒞, 0 < c ∧ c < Inp.q ^ n := fun c hc => ⟨(h𝒞 c hc).1, (h𝒞 c hc).2.1⟩
247 obtain ⟨w, hwN, hwS⟩ := hL8 P hPsq hcop6 h35 k o ho n hnpos α κ Z 𝒵 𝒞 hα hκ (by linarith)
248 (fun w hw => hcond𝒵 w hw) hcard𝒵 hcond𝒞 hκQ
249 -- the sieve data
250 obtain ⟨S, hS⟩ : ∃ S : ℕ × ℕ → ℕ,
251 S = fun p => sfun P k o (Inp.q ^ n * p.1 - p.2) := ⟨_, rfl⟩
252 obtain ⟨pairs, hpairs⟩ : ∃ pr : Finset (ℕ × ℕ), pr = 𝒵 ×ˢ 𝒞 := ⟨_, rfl⟩
253 obtain ⟨lm, lp, hz12, -, hsieve, hlow, -, hcon⟩ := hT2 K0 z hK0T hz0
254 set Pc : ℕ := ∏ p ∈ primesIoc (K0 : ℝ) z, p with hPc
255 set V : ℝ := ∏ p ∈ primesIoc (K0 : ℝ) z, (1 - 1 / (p : ℝ)) with hV
256 have hzN : 0 ≤ z := hzpos.le
257 have hK0N : (0 : ℝ) ≤ K0 := by positivity
258 -- primes of `Pc` exceed `K0`
259 have hbigp : ∀ p : ℕ, p.Prime → p ∣ Pc → K0 < p := by
260 intro p hp hpd
261 rw [hPc] at hpd
262 obtain ⟨q', hq', hpq⟩ := (Prime.dvd_finsetProd_iff hp.prime _).1 hpd
263 obtain ⟨h1, _, h3⟩ := (BH.mem_primesIoc hK0N hzN).1 hq'
264 have hpq' : p = q' := (Nat.prime_dvd_prime_iff_eq hp h3).1 hpq
265 rw [hpq']
266 exact_mod_cast h1
267 have hKbig : ∀ e ∈ Pc.divisors, e ≠ 1 → K0 < e := by
268 intro e he hne
269 have he1 : 1 < e := by
270 have := Nat.pos_of_mem_divisors he
271 omega
272 obtain ⟨p, hp⟩ := Nat.nonempty_primeFactors.2 he1
273 have hpe := Nat.prime_of_mem_primeFactors hp
274 have hpd := Nat.dvd_of_mem_primeFactors hp
275 exact lt_of_lt_of_le (hbigp p hpe (hpd.trans (Nat.dvd_of_mem_divisors he)))
276 (Nat.le_of_dvd (Nat.pos_of_mem_divisors he) hpd)
277 have hcopd : ∀ d ∈ Pc.divisors, d.Coprime (6 * P) := by
278 intro d hd
279 apply Nat.coprime_of_dvd
280 intro p hp hpd hp6
281 have h1 : K0 < p := hbigp p hp (hpd.trans (Nat.dvd_of_mem_divisors hd))
282 have h2 := hsmall p hp hp6
283 omega
284 -- the sieve identity (from L8) and the sieve inequality (from T2 (a))
285 have hNd : ∀ d ∈ Pc.divisors, ((pairs.filter fun p => d ∣ S p).card : ℝ) =
286 ((𝒵.card : ℝ) * 𝒞.card + ∑ e ∈ d.divisors.erase 1, w e) / d := by
287 intro d hd
288 have hd1 : 1 ≤ d := Nat.pos_of_mem_divisors hd
289 rw [hpairs, hS]
290 exact hwN d hd1 (hcopd d hd)
291 have hsv : ∑ d ∈ Pc.divisors, lm d * ((pairs.filter fun p => d ∣ S p).card : ℝ) ≤
292 ((pairs.filter fun p => (S p).Coprime Pc).card : ℝ) := by
293 apply sieve_count pairs S Pc lm
294 intro p _
295 exact (hsieve (S p)).1
296 have hexp := sieve_expand Pc lm w ((𝒵.card : ℝ) * 𝒞.card)
297 (fun d => ((pairs.filter fun p => d ∣ S p).card : ℝ)) hNd
298 have hMz0 : (0 : ℝ) ≤ (𝒵.card : ℝ) * 𝒞.card :=
299 mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)
300 have hVnn : 0 ≤ V := by
301 apply Finset.prod_nonneg
302 intro p hp
303 have hp2 : (2 : ℝ) ≤ p := by
304 exact_mod_cast ((BH.mem_primesIoc hK0N hzN).1 hp).2.2.two_le
305 have : 1 / (p : ℝ) ≤ 1 := by
306 rw [div_le_one (by linarith)]
307 linarith
308 linarith
309 -- main term
310 have hmain : ((𝒵.card : ℝ) * 𝒞.card) * (cB * V) ≤
311 ((𝒵.card : ℝ) * 𝒞.card) * ∑ d ∈ Pc.divisors, lm d / d :=
312 mul_le_mul_of_nonneg_left hlow hMz0
313 -- remainder: each `e ∈ Pc.divisors` with `e ≠ 1` and `e ≤ z^12` is in `T`
314 obtain ⟨T, hT⟩ : ∃ T : Finset ℕ, T = (Pc.divisors.erase 1).filter fun e : ℕ => (e : ℝ) ≤ z ^ 12 :=
315 ⟨_, rfl⟩
316 have hIzero : ∀ e ∈ Pc.divisors, z ^ 12 < (e : ℝ) →
317 ∑ d ∈ Pc.divisors with e ∣ d, lm d / d = 0 := by
318 intro e _ hbig
319 apply Finset.sum_eq_zero
320 intro d hd
321 rw [Finset.mem_filter] at hd
322 have hed : e ≤ d := Nat.le_of_dvd (Nat.pos_of_mem_divisors hd.1) hd.2
323 have hlt : z ^ 12 < (d : ℝ) := lt_of_lt_of_le hbig (by exact_mod_cast hed)
324 rw [(hz12 d hlt).1, zero_div]
325 have hTprop : ∀ e ∈ T, K0 < e ∧ (e : ℝ) ≤ z ^ 12 := by
326 intro e he
327 rw [hT, Finset.mem_filter, Finset.mem_erase] at he
328 exact ⟨hKbig e he.1.2 he.1.1, he.2⟩
329 -- dyadic blocks: each fibre of `T` lies in one `L8` block
330 have hBfib : ∀ j : ℕ, (2 : ℝ) ^ j < z ^ 12 →
331 ∑ e ∈ T.filter (fun e => Nat.log 2 (e - 1) = j), |w e| ≤
332 Real.sqrt (C8 / (α * κ)) * ((𝒵.card : ℝ) * 𝒞.card) := by
333 intro j hj
334 have hj' : ((2 ^ j : ℕ) : ℝ) < z ^ 12 := by push_cast; exact hj
335 have hsq : ((2 ^ j : ℕ) : ℝ) ^ 2 ≤ z ^ 24 := by
336 calc ((2 ^ j : ℕ) : ℝ) ^ 2 ≤ (z ^ 12) ^ 2 := pow_le_pow_left₀ (by positivity) hj'.le 2
337 _ = z ^ 24 := by ring
338 have h4 : 4 * ((2 ^ j : ℕ) : ℝ) ^ 2 * P ≤ α * t / 2 := by
339 have h1 : 4 * ((2 ^ j : ℕ) : ℝ) ^ 2 * (P : ℝ) ≤ 4 * z ^ 24 * P :=
340 mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hsq (by norm_num)) (Nat.cast_nonneg P)
341 linarith
342 have hαt' : α * t ≤ t := mul_le_of_le_one_left htpos.le hα1
343 have hE1 : 4 * ((2 ^ j : ℕ) : ℝ) ^ 2 * P ≤ ((Inp.q ^ n : ℕ) : ℝ) := by
344 linarith
345 have hE2 : 4 * ((2 ^ j : ℕ) : ℝ) ^ 2 * P ≤ Z := by
346 linarith
347 have hsub : T.filter (fun e => Nat.log 2 (e - 1) = j) ⊆
348 (Finset.Ioc (2 ^ j) (2 * 2 ^ j)).filter (fun e => e.Coprime (6 * P)) := by
349 intro e he
350 rw [Finset.mem_filter] at he
351 obtain ⟨heT, hlog⟩ := he
352 have hTe : e ∈ Pc.divisors.erase 1 := by
353 rw [hT] at heT
354 exact (Finset.mem_filter.1 heT).1
355 have hedv : e ∈ Pc.divisors := Finset.mem_of_mem_erase hTe
356 have hK := hKbig e hedv (Finset.ne_of_mem_erase hTe)
357 have hle1 : 2 ^ j ≤ e - 1 := by
358 have := Nat.pow_log_le_self 2 (show e - 1 ≠ 0 by omega)
359 rw [hlog] at this
360 exact this
361 have hlt1 : e - 1 < 2 ^ (j + 1) := by
362 have := Nat.lt_pow_succ_log_self (b := 2) (by norm_num) (e - 1)
363 rw [hlog] at this
364 exact this
365 rw [pow_succ] at hlt1
366 rw [Finset.mem_filter, Finset.mem_Ioc]
367 exact ⟨⟨by omega, by omega⟩, hcopd e hedv⟩
368 calc ∑ e ∈ T.filter (fun e => Nat.log 2 (e - 1) = j), |w e|
369 ≤ ∑ e ∈ (Finset.Ioc (2 ^ j) (2 * 2 ^ j)).filter (fun e => e.Coprime (6 * P)), |w e| :=
370 Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => abs_nonneg _)
371 _ ≤ Real.sqrt (C8 / (α * κ)) * ((𝒵.card : ℝ) * 𝒞.card) :=
372 hwS (2 ^ j) Nat.one_le_two_pow hE1 hE2
373 -- the remainder: `|∑_e w e · I e| ≤ CB V ∑_{e∈T} |w e| e^(-3/4)`, then `dyadic_bound`
374 have hTdiv : ∀ e ∈ T, e ∈ Pc.divisors := by
375 intro e he
376 rw [hT] at he
377 exact Finset.mem_of_mem_erase (Finset.mem_filter.1 he).1
378 have hpowp : ∀ e ∈ T, (CB : ℝ) ^ e.primeFactors.card / e ≤ (e : ℝ) ^ (-(3 / 4 : ℝ)) := by
379 intro e he
380 have hedv := hTdiv e he
381 have he0 : e ≠ 0 := (Nat.pos_of_mem_divisors hedv).ne'
382 have hpr : ∀ p ∈ e.primeFactors, CB ^ 4 ≤ (p : ℝ) := by
383 intro p hp
384 have hpp := Nat.prime_of_mem_primeFactors hp
385 have hpd := Nat.dvd_of_mem_primeFactors hp
386 have h1 := hbigp p hpp (hpd.trans (Nat.dvd_of_mem_divisors hedv))
387 have h2 : (K0 : ℝ) < p := by exact_mod_cast h1
388 linarith
389 have h1 := pow_card_primeFactors_le (C := CB) (by linarith) he0 hpr
390 have hepos : (0 : ℝ) < e := by exact_mod_cast Nat.pos_of_ne_zero he0
391 rw [div_le_iff₀ hepos]
392 calc (CB : ℝ) ^ e.primeFactors.card ≤ (e : ℝ) ^ (1 / 4 : ℝ) := h1
393 _ = (e : ℝ) ^ (-(3 / 4 : ℝ)) * e := by
394 rw [show (1 / 4 : ℝ) = -(3 / 4) + 1 by norm_num, Real.rpow_add hepos, Real.rpow_one]
395 have hCBV : 0 ≤ CB * V := mul_nonneg (by linarith) hVnn
396 have hdy := dyadic_bound (v := fun e => |w e|) (fun e => abs_nonneg _) (K0 := K0) (by omega)
397 (Y := z ^ 12) (B := Real.sqrt (C8 / (α * κ)) * ((𝒵.card : ℝ) * 𝒞.card))
398 (mul_nonneg (Real.sqrt_nonneg _) hMz0) T hTprop hBfib
399 have hRm : |∑ e ∈ Pc.divisors.erase 1, w e * ∑ d ∈ Pc.divisors with e ∣ d, lm d / d| ≤
400 CB * V * (Real.sqrt (C8 / (α * κ)) * ((𝒵.card : ℝ) * 𝒞.card) *
401 ((1 - (2 : ℝ) ^ (-(3 / 4 : ℝ)))⁻¹ * ((K0 : ℝ) / 2) ^ (-(3 / 4 : ℝ)))) := by
402 refine (Finset.abs_sum_le_sum_abs _ _).trans ?_
403 have hfilt : ∑ e ∈ Pc.divisors.erase 1, |w e * ∑ d ∈ Pc.divisors with e ∣ d, lm d / d| =
404 ∑ e ∈ T, |w e * ∑ d ∈ Pc.divisors with e ∣ d, lm d / d| := by
405 rw [hT]
406 refine (Finset.sum_filter_of_ne ?_).symm
407 intro e he hne
408 by_contra hp
409 have hp' := not_le.1 hp
410 apply hne
411 rw [hIzero e (Finset.mem_of_mem_erase he) hp', mul_zero, abs_zero]
412 rw [hfilt]
413 calc ∑ e ∈ T, |w e * ∑ d ∈ Pc.divisors with e ∣ d, lm d / d|
414 ≤ ∑ e ∈ T, CB * V * (|w e| * (e : ℝ) ^ (-(3 / 4 : ℝ))) := by
415 refine Finset.sum_le_sum fun e he => ?_
416 have hedv := hTdiv e he
417 have hI := hcon e hedv
418 have hpw := hpowp e he
419 rw [abs_mul]
420 calc |w e| * |∑ d ∈ Pc.divisors with e ∣ d, lm d / d|
421 ≤ |w e| * (CB * V * ((CB : ℝ) ^ e.primeFactors.card / e)) := by
422 refine mul_le_mul_of_nonneg_left (le_of_le_of_eq hI ?_) (abs_nonneg _)
423 ring
424 _ ≤ |w e| * (CB * V * (e : ℝ) ^ (-(3 / 4 : ℝ))) :=
425 mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hpw hCBV) (abs_nonneg _)
426 _ = CB * V * (|w e| * (e : ℝ) ^ (-(3 / 4 : ℝ))) := by ring
427 _ = CB * V * ∑ e ∈ T, |w e| * (e : ℝ) ^ (-(3 / 4 : ℝ)) := by rw [Finset.mul_sum]
428 _ ≤ CB * V * (Real.sqrt (C8 / (α * κ)) * ((𝒵.card : ℝ) * 𝒞.card) *
429 ((1 - (2 : ℝ) ^ (-(3 / 4 : ℝ)))⁻¹ * ((K0 : ℝ) / 2) ^ (-(3 / 4 : ℝ)))) :=
430 mul_le_mul_of_nonneg_left hdy hCBV
431 have hRm_final : |∑ e ∈ Pc.divisors.erase 1, w e * ∑ d ∈ Pc.divisors with e ∣ d, lm d / d| ≤
432 ((𝒵.card : ℝ) * 𝒞.card) * V * (cB / 2) := by
433 calc _ ≤ _ := hRm
434 _ = ((𝒵.card : ℝ) * 𝒞.card) * V * (ε * ((K0 : ℝ) / 2) ^ (-(3 / 4 : ℝ))) := by
435 rw [hε]
436 ring
437 _ ≤ ((𝒵.card : ℝ) * 𝒞.card) * V * (cB / 2) :=
438 mul_le_mul_of_nonneg_left hK0ε (mul_nonneg hMz0 hVnn)
439 -- the sieve lower bound
440 beta_reduce at hexp
441 have hGlow : ((𝒵.card : ℝ) * 𝒞.card) * V * (cB / 2) ≤
442 ((pairs.filter fun p => (S p).Coprime Pc).card : ℝ) := by
443 have h1 := hsv
444 rw [hexp] at h1
445 have h2 := (abs_le.1 hRm_final).1
446 linarith
447 -- V lower bound (Mertens), and the size of `𝒵 × 𝒞`
448 have h2K : (2 : ℝ) ≤ K0 := by linarith
449 have hVlow : Real.log K0 / (CM * Real.log z) ≤ V :=
450 L9Aux.V_lower hCM h2K hz0 (hT10 K0 z h2K hz0).1
451 have hlogz : Real.log z = Real.log X / 100 := by
452 rw [hz, Real.log_rpow hXpos]
453 ring
454 have hCM0 : CM ≠ 0 := hCM.ne'
455 have hlogX : 0 < Real.log X := Real.log_pos hX1
456 have hVlow' : 100 * Real.log K0 / (CM * Real.log X) ≤ V := by
457 have e1 : Real.log K0 / (CM * (Real.log X / 100)) = 100 * Real.log K0 / (CM * Real.log X) := by
458 field_simp
459 rw [← e1, ← hlogz]
460 exact hVlow
461 have hMz_lo : α * κ * X / 2 ≤ (𝒵.card : ℝ) * 𝒞.card := by
462 calc α * κ * X / 2 = (α * Z / 2) * (κ * ((Inp.q ^ n : ℕ) : ℝ)) := by
463 rw [← hQZ]
464 ring
465 _ ≤ (𝒵.card : ℝ) * 𝒞.card :=
466 mul_le_mul hcard𝒵 hκQ (mul_nonneg hκ.le hQpos.le) (Nat.cast_nonneg _)
467 -- every pair in the sieve has its entries in range
468 have hpf : ∀ p ∈ pairs, 16 < p.1 ∧ p.2 < Inp.q ^ n ∧ α * Z / 2 < (p.1 : ℝ) ∧
469 (p.1 : ℝ) ≤ Z ∧ p.1 ∈ A ∧ p.2 ∈ 𝒞 := by
470 intro p hp
471 rw [hpairs, Finset.mem_product] at hp
472 obtain ⟨hw1, hc1⟩ := hp
473 obtain ⟨hlo, hhi, hA⟩ := hmem𝒵 p.1 hw1
474 have h16 : (16 : ℝ) < p.1 := by linarith
475 have h16' : 16 < p.1 := by exact_mod_cast h16
476 exact ⟨h16', (h𝒞 p.2 hc1).2.1, hlo, hhi, hA, hc1⟩
477 have hxpos : ∀ p ∈ pairs, 1 ≤ Inp.q ^ n * p.1 - p.2 ∧ 14 < Inp.q ^ n * p.1 - p.2 := by
478 intro p hp
479 obtain ⟨h16, hcQ, -⟩ := hpf p hp
480 have hQ16 : Inp.q ^ n * 16 ≤ Inp.q ^ n * p.1 := Nat.mul_le_mul_left _ h16.le
481 constructor <;> omega
482 have hA6 : 0 < 10 * (6 : ℝ) ^ k * α := mul_pos (mul_pos (by norm_num) (by positivity)) hα
483 have hpos6 : (0 : ℝ) < 6 ^ k := by positivity
484 -- injection of the surviving pairs into `rough9`
485 have hcardG : (pairs.filter fun p => (S p).Coprime Pc).card ≤
486 (rough9 (min 1 (10 * (6 : ℝ) ^ k * α)) (84 * (6 : ℝ) ^ k) X ρ).card := by
487 apply Finset.card_le_card_of_injOn (fun p => S p)
488 · rintro ⟨w1, c1⟩ hp
489 obtain ⟨hp1, hcop⟩ := Finset.mem_filter.1 hp
490 obtain ⟨h16, hcQ, hlo, hhi, hA1, hc1⟩ := hpf _ hp1
491 have h16' : 16 < w1 := h16
492 have hcQ' : c1 < Inp.q ^ n := hcQ
493 have hlo' : α * Z / 2 < (w1 : ℝ) := hlo
494 have hhi' : (w1 : ℝ) ≤ Z := hhi
495 have hA1' : w1 ∈ A := hA1
496 have hxp := hxpos _ hp1
497 have hx1 : 1 ≤ Inp.q ^ n * w1 - c1 := hxp.1
498 have hx14 : 14 < Inp.q ^ n * w1 - c1 := hxp.2
499 have hsub1 : c1 ≤ Inp.q ^ n * w1 := by omega
500 have hSp : S (w1, c1) = sfun P k o (Inp.q ^ n * w1 - c1) := by rw [hS]
501 have hcopS : Nat.Coprime (sfun P k o (Inp.q ^ n * w1 - c1)) Pc := by
502 rw [← hSp]
503 exact hcop
504 have hxA : Inp.q ^ n * w1 - c1 ∈ A := (h𝒞 c1 hc1).2.2 w1 hA1' (by omega)
505 have hAk' := hAk _ hxA hx14
506 have hmod' := hmod _ hx1
507 -- real size bounds for `x = Q w1 - c1`
508 have hQpos' : (0 : ℝ) < ((Inp.q ^ n : ℕ) : ℝ) := hQpos
509 have hxR : ((Inp.q ^ n * w1 - c1 : ℕ) : ℝ) =
510 ((Inp.q ^ n : ℕ) : ℝ) * (w1 : ℝ) - (c1 : ℝ) := by
511 rw [Nat.cast_sub hsub1, Nat.cast_mul]
512 have hc1R : (c1 : ℝ) + 1 ≤ ((Inp.q ^ n : ℕ) : ℝ) := by
513 have : c1 + 1 ≤ Inp.q ^ n := hcQ'
514 exact_mod_cast this
515 have hQw : α * X / 2 ≤ ((Inp.q ^ n : ℕ) : ℝ) * (w1 : ℝ) := by
516 have h1 := mul_le_mul_of_nonneg_left hlo'.le hQpos'.le
517 have h2 : ((Inp.q ^ n : ℕ) : ℝ) * (α * Z / 2) = α * X / 2 := by
518 rw [← hQZ]
519 ring
520 linarith
521 have h4X : 4 * t ^ 2 ≤ α * X := by
522 calc 4 * t ^ 2 ≤ (α * t) * t ^ 2 := mul_le_mul_of_nonneg_right h4α (sq_nonneg t)
523 _ = α * X := by rw [← hX3]; ring
524 have hQle : ((Inp.q ^ n : ℕ) : ℝ) ≤ α * X / 4 := by linarith [hQhi]
525 have hxm : α * X / 4 ≤ (((Inp.q ^ n * w1 - c1 : ℕ) : ℝ)) - 1 := by
526 rw [hxR]
527 linarith
528 -- the bounds `a X < s ≤ b X`
529 have hupN := (sfun_bounds (P := P) ho hx1).2
530 have hlowN := (sfun_bounds (P := P) ho hx1).1
531 have hxX : (((Inp.q ^ n * w1 - c1 : ℕ) : ℝ)) ≤ X := by
532 rw [hxR]
533 have h1 : ((Inp.q ^ n : ℕ) : ℝ) * (w1 : ℝ) ≤ ((Inp.q ^ n : ℕ) : ℝ) * Z :=
534 mul_le_mul_of_nonneg_left hhi' hQpos'.le
535 rw [hQZ] at h1
536 linarith
537 have hupR : (sfun P k o (Inp.q ^ n * w1 - c1) : ℝ) < 84 * 6 ^ k * X := by
538 have h1 : ((sfun P k o (Inp.q ^ n * w1 - c1) : ℕ) : ℝ) <
539 ((84 * (6 ^ k * (Inp.q ^ n * w1 - c1)) : ℕ) : ℝ) := by exact_mod_cast hupN
540 push_cast [Nat.cast_sub hx1] at h1
541 have h2 : (6 : ℝ) ^ k * ((((Inp.q ^ n * w1 - c1 : ℕ) : ℝ))) ≤ 6 ^ k * X :=
542 mul_le_mul_of_nonneg_left hxX hpos6.le
543 linarith
544 have hlowR : 84 * (6 : ℝ) ^ k * (α * X / 4) ≤ (sfun P k o (Inp.q ^ n * w1 - c1) : ℝ) := by
545 have h1 : ((84 * (6 ^ k * (Inp.q ^ n * w1 - c1 - 1)) : ℕ) : ℝ) ≤
546 ((sfun P k o (Inp.q ^ n * w1 - c1) : ℕ) : ℝ) := by exact_mod_cast hlowN
547 have h2 : (((Inp.q ^ n * w1 - c1 - 1 : ℕ)) : ℝ) = (((Inp.q ^ n * w1 - c1 : ℕ) : ℝ)) - 1 := by
548 rw [Nat.cast_sub (by omega)]
549 simp
550 push_cast [Nat.cast_sub (show 1 ≤ Inp.q ^ n * w1 - c1 by omega)] at h1
551 have h3 : (6 : ℝ) ^ k * (α * X / 4) ≤ 6 ^ k * ((((Inp.q ^ n * w1 - c1 : ℕ) : ℝ)) - 1) :=
552 mul_le_mul_of_nonneg_left hxm hpos6.le
553 linarith
554 have hmin : min 1 (10 * (6 : ℝ) ^ k * α) * X ≤ 10 * (6 : ℝ) ^ k * α * X :=
555 mul_le_mul_of_nonneg_right (min_le_right _ _) hXpos.le
556 have hpos' : 0 < (6 : ℝ) ^ k * α * X := mul_pos (mul_pos hpos6 hα) hXpos
557 show S (w1, c1) ∈ rough9 (min 1 (10 * (6 : ℝ) ^ k * α)) (84 * (6 : ℝ) ^ k) X ρ
558 rw [hSp, mem_rough9 (mul_nonneg (le_min zero_le_one hA6.le) hXpos.le)
559 (mul_nonneg (by positivity) hXpos.le), ← hz]
560 refine ⟨⟨?_, by linarith⟩, hAk', hmod'.1, ?_⟩
561 · linarith
562 · intro q' hq' hdvd
563 by_contra hle
564 have hle' : (q' : ℝ) ≤ z := not_lt.1 hle
565 by_cases hK : q' ≤ K0
566 · have h6 : q' ∣ 6 * P := hdivP q' hq' hK
567 have h84 : q' ∣ 84 * P := dvd_trans h6 ⟨14, by ring⟩
568 have h1 : q' ∣ sfun P k o (Inp.q ^ n * w1 - c1) + 1 :=
569 dvd_trans h84 hmod'.2
570 have h2 : q' ∣ 1 := (Nat.dvd_add_right hdvd).1 h1
571 have h3 := Nat.dvd_one.1 h2
572 have h4 := hq'.one_lt
573 omega
574 · have hK' : K0 < q' := by omega
575 have hqPc : q' ∣ Pc := by
576 rw [hPc]
577 exact Finset.dvd_prod_of_mem (fun p => p)
578 ((BH.mem_primesIoc hK0N hzN).2 ⟨by exact_mod_cast hK', hle', hq'⟩)
579 have hg : q' ∣ Nat.gcd (sfun P k o (Inp.q ^ n * w1 - c1)) Pc :=
580 Nat.dvd_gcd hdvd hqPc
581 rw [Nat.Coprime.gcd_eq_one hcopS] at hg
582 have h3 := Nat.dvd_one.1 hg
583 have h4 := hq'.one_lt
584 omega
585 · rintro ⟨w1, c1⟩ hp1 ⟨w2, c2⟩ hp2 heq
586 have hp1' := (Finset.mem_filter.1 hp1).1
587 have hp2' := (Finset.mem_filter.1 hp2).1
588 have hca : c1 < Inp.q ^ n := (hpf _ hp1').2.1
589 have hcb : c2 < Inp.q ^ n := (hpf _ hp2').2.1
590 have hx1 : 1 ≤ Inp.q ^ n * w1 - c1 := (hxpos _ hp1').1
591 have hx2 : 1 ≤ Inp.q ^ n * w2 - c2 := (hxpos _ hp2').1
592 have heq' : S (w1, c1) = S (w2, c2) := heq
593 rw [hS] at heq'
594 have hxeq := sfun_injOn (P := P) ho (Set.mem_Ici.2 hx1) (Set.mem_Ici.2 hx2) heq'
595 obtain ⟨hw, hc⟩ := qz_inj hca hcb hxeq hx1
596 rw [hw, hc]
597 -- assemble: main term ≥ ακX/2 · cB/2 · (100 log K0 / (CM log X))
598 have hlX' : Real.log X ≠ 0 := hlogX.ne'
599 have hfinal_eq : 25 * cB * α * κ * Real.log K0 / CM * X / Real.log X =
600 (α * κ * X / 2) * (cB / 2) * (100 * Real.log K0 / (CM * Real.log X)) := by
601 field_simp
602 ring
603 have hK0one : (1 : ℝ) ≤ K0 := by linarith
604 have hYnn : 0 ≤ 100 * Real.log K0 / (CM * Real.log X) :=
605 div_nonneg (mul_nonneg (by norm_num) (Real.log_nonneg hK0one)) (mul_nonneg hCM.le hlogX.le)
606 calc 25 * cB * α * κ * Real.log K0 / CM * X / Real.log X
607 = (α * κ * X / 2) * (cB / 2) * (100 * Real.log K0 / (CM * Real.log X)) := hfinal_eq
608 _ ≤ ((𝒵.card : ℝ) * 𝒞.card) * (cB / 2) * V :=
609 mul_le_mul (mul_le_mul_of_nonneg_right hMz_lo (by linarith)) hVlow' hYnn
610 (mul_nonneg hMz0 (by linarith))
611 _ = ((𝒵.card : ℝ) * 𝒞.card) * V * (cB / 2) := by ring
612 _ ≤ ((pairs.filter fun p => (S p).Coprime Pc).card : ℝ) := hGlow
613 _ ≤ ((rough9 (min 1 (10 * (6 : ℝ) ^ k * α)) (84 * (6 : ℝ) ^ k) X ρ).card : ℝ) := by
614 exact_mod_cast hcardG
615
616
617
618
619
620
621end E424
622