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/DirichletError/L29abAux.lean

All files · 310 lines · source at the verified commit

1module
2
3public import E424.DirichletError.L29
4public import E424.DivisorMoments.Moments
5
6@[expose] public section
7
8/-!
9# Helpers for Lemma 29 a/b (`L29ab.lean`)
10
11Harmonic sums over windows, a constant-function bound for `Win.E`, and eventual power bounds.
12-/
13
14set_option linter.style.header false
15open Finset Filter
16
17namespace E424
18
19/-- `∑_{a < n ≤ b} 1/n ≤ log b - log a` for `1 ≤ a ≤ b`, by telescoping `1/n ≤ log n - log (n-1)`. -/
20theorem sum_inv_Ioc_le {a b : ℕ} (ha : 1 ≤ a) (hab : a ≤ b) :
21 ∑ n ∈ Ioc a b, (1 : ℝ) / n ≤ Real.log b - Real.log a := by
22 induction b, hab using Nat.le_induction with
23 | base => simp
24 | succ b hb ih =>
25 rw [Finset.sum_Ioc_succ_top hb]
26 have hb1 : (1 : ℝ) ≤ b := by exact_mod_cast ha.trans hb
27 have key : (1 : ℝ) / ((b : ℝ) + 1) ≤ Real.log ((b : ℝ) + 1) - Real.log b := by
28 have h := Real.one_sub_inv_le_log_of_pos (x := ((b : ℝ) + 1) / b) (by positivity)
29 rw [Real.log_div (by positivity) (by positivity)] at h
30 have e : 1 - (((b : ℝ) + 1) / b)⁻¹ = 1 / ((b : ℝ) + 1) := by
31 field_simp
32 ring
33 linarith
34 push_cast
35 linarith
36
37/-- `∑_{n ∈ W.pts} 1/n ≤ len + log 2` for `1 ≤ lo ≤ hi`. -/
38theorem pts_inv_sum_le (W : Win) (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi) :
39 ∑ n ∈ W.pts, (1 : ℝ) / n ≤ W.len + Real.log 2 := by
40 have hlo0 : 0 < W.lo := by linarith
41 have hhi0 : 0 < W.hi := by linarith
42 have hfl : 1 ≤ ⌊W.lo⌋₊ := Nat.le_floor (by exact_mod_cast hlo)
43 have hmono : ⌊W.lo⌋₊ ≤ ⌊W.hi⌋₊ := Nat.floor_mono hhi
44 have hfl' : 1 ≤ ⌊W.hi⌋₊ := hfl.trans hmono
45 refine (sum_inv_Ioc_le hfl hmono).trans ?_
46 have hf : (1 : ℝ) ≤ ⌊W.lo⌋₊ := by exact_mod_cast hfl
47 have h2 : W.lo / 2 ≤ (⌊W.lo⌋₊ : ℝ) := by
48 have := Nat.lt_floor_add_one W.lo
49 linarith
50 have h3 : Real.log (W.lo / 2) ≤ Real.log ⌊W.lo⌋₊ :=
51 Real.log_le_log (by positivity) h2
52 have h4 : Real.log ⌊W.hi⌋₊ ≤ Real.log W.hi :=
53 Real.log_le_log (Nat.cast_pos.mpr (by omega)) (Nat.floor_le hhi0.le)
54 rw [Real.log_div hlo0.ne' (by norm_num)] at h3
55 rw [Win.len, Real.log_div hhi0.ne' hlo0.ne']
56 linarith
57
58/-- The log-weighted average of a constant is at most twice the constant, once `log 2 ≤ len`. -/
59theorem E_const_le (W : Win) (K : ℝ) (hK : 0 ≤ K) (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi)
60 (hl : Real.log 2 ≤ W.len) : W.E (fun _ => K) ≤ 2 * K := by
61 have hlen : 0 < W.len := lt_of_lt_of_le (Real.log_pos one_lt_two) hl
62 have hs : W.sum (fun _ => K) = K * ∑ n ∈ W.pts, (1 : ℝ) / n := by
63 unfold Win.sum
64 rw [Finset.mul_sum]
65 exact Finset.sum_congr rfl fun n _ => by ring
66 have hsum := pts_inv_sum_le W hlo hhi
67 unfold Win.E
68 rw [hs, div_le_iff₀ hlen]
69 nlinarith
70
71/-- `c (log lo)^n ≤ lo^δ` for large `lo`, any `δ > 0`, `c > 0`. -/
72theorem eventually_log_pow_le (n : ℕ) {δ : ℝ} (hδ : 0 < δ) {c : ℝ} (hc : 0 < c) :
73 ∀ᶠ lo : ℝ in atTop, c * Real.log lo ^ n ≤ lo ^ δ := by
74 have h := (isLittleO_log_rpow_rpow_atTop (n : ℝ) hδ).bound (inv_pos.mpr hc)
75 filter_upwards [h, eventually_ge_atTop 1] with lo hlo hge
76 have hl : 0 ≤ Real.log lo := Real.log_nonneg hge
77 have hp : 0 ≤ lo ^ δ := Real.rpow_nonneg (by linarith) δ
78 simp only [Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hl n),
79 abs_of_nonneg hp] at hlo
80 calc c * Real.log lo ^ n ≤ c * (c⁻¹ * lo ^ δ) := mul_le_mul_of_nonneg_left hlo hc.le
81 _ = lo ^ δ := by field_simp
82
83/-- `8 x^N ≤ x^(N+3)` for `x ≥ 8`. -/
84theorem eight_mul_pow_le (x : ℝ) (N : ℕ) (hx : 8 ≤ x) : 8 * x ^ N ≤ x ^ (N + 3) := by
85 have h0 : 0 ≤ x ^ N := pow_nonneg (by linarith) N
86 have h3 : (8 : ℝ) ≤ x ^ 3 := le_trans (by norm_num) (pow_le_pow_left₀ (by norm_num) hx 3)
87 rw [pow_add]
88 calc 8 * x ^ N = x ^ N * 8 := mul_comm _ _
89 _ ≤ x ^ N * x ^ 3 := mul_le_mul_of_nonneg_left h3 h0
90
91/-- Final algebra of Lemma 29(b): with `M ≥ cS/100`, `R < ηQ`, `δ = e/(3 C29 G)`, `G = (1 + 100B/cS)²`,
92`e2 = e cS/(3 C29 100 B)`, `ηQ = e cS²/(3 C29 10⁴)`, the error bracket is at most `C(ε+ε') + e`. -/
93theorem L29b_alg (C29 B cS e δ G e2 ηQ R M ε ε' len : ℝ)
94 (hC29 : 0 < C29) (hB : 0 < B) (hc : 0 < cS) (he : 0 < e) (hM : cS / 100 ≤ M) (hMpos : 0 < M)
95 (hε : 0 ≤ ε) (hε' : 0 ≤ ε') (he2 : 0 < e2) (hR : R < ηQ) (hR0 : 0 ≤ R)
96 (hδ : δ = e / (3 * C29 * G)) (hG : G = (1 + 100 * B / cS) ^ 2)
97 (hηQ : ηQ = e * cS ^ 2 / (3 * C29 * 10 ^ 4)) (he2d : e2 = e * cS / (3 * C29 * (100 * B)))
98 (hδ0 : 0 < δ) (hlen : 0 ≤ len) :
99 C29 * len / M ^ 2 * (R + δ * (M + B) ^ 2 + B * (M * (ε + ε' + e2))) ≤
100 (C29 * (100 * B / cS) * (ε + ε') + e) * len := by
101 have h100 : cS ≤ 100 * M := by linarith
102 have hBM : B / M ≤ 100 * B / cS := by
103 rw [div_le_div_iff₀ hMpos hc]
104 calc B * cS ≤ B * (100 * M) := mul_le_mul_of_nonneg_left h100 hB.le
105 _ = 100 * B * M := by ring
106 have hG' : (M + B) ^ 2 / M ^ 2 ≤ G := by
107 have hrw : (M + B) ^ 2 / M ^ 2 = (1 + B / M) ^ 2 := by field_simp
108 rw [hrw, hG]
109 gcongr
110 have hinv : 1 / M ^ 2 ≤ 10 ^ 4 / cS ^ 2 := by
111 rw [div_le_div_iff₀ (pow_pos hMpos 2) (pow_pos hc 2)]
112 calc 1 * cS ^ 2 = cS ^ 2 := one_mul _
113 _ ≤ (100 * M) ^ 2 := pow_le_pow_left₀ hc.le h100 2
114 _ = 10 ^ 4 * M ^ 2 := by ring
115 have hs0 : 0 ≤ ε + ε' + e2 := by linarith
116 have hkey : C29 * len / M ^ 2 * (R + δ * (M + B) ^ 2 + B * (M * (ε + ε' + e2))) =
117 C29 * len * (R / M ^ 2 + δ * ((M + B) ^ 2 / M ^ 2) + B / M * (ε + ε' + e2)) := by
118 field_simp
119 rw [hkey]
120 have hA : R / M ^ 2 ≤ e / (3 * C29) := by
121 have h1 : R / M ^ 2 ≤ ηQ * (10 ^ 4 / cS ^ 2) := by
122 rw [div_eq_mul_one_div]
123 exact mul_le_mul hR.le hinv (by positivity) (by linarith)
124 refine h1.trans (le_of_eq ?_)
125 rw [hηQ]
126 field_simp
127 have hB' : B / M * (ε + ε' + e2) ≤ 100 * B / cS * (ε + ε' + e2) :=
128 mul_le_mul_of_nonneg_right hBM hs0
129 have hD' : δ * ((M + B) ^ 2 / M ^ 2) ≤ δ * G := mul_le_mul_of_nonneg_left hG' hδ0.le
130 have hinner : R / M ^ 2 + δ * ((M + B) ^ 2 / M ^ 2) + B / M * (ε + ε' + e2) ≤
131 e / (3 * C29) + δ * G + 100 * B / cS * (ε + ε' + e2) := by linarith
132 calc C29 * len * (R / M ^ 2 + δ * ((M + B) ^ 2 / M ^ 2) + B / M * (ε + ε' + e2))
133 ≤ C29 * len * (e / (3 * C29) + δ * G + 100 * B / cS * (ε + ε' + e2)) :=
134 mul_le_mul_of_nonneg_left hinner (by positivity)
135 _ = (C29 * (100 * B / cS) * (ε + ε') + e) * len := by
136 rw [hδ, hG, he2d]
137 field_simp
138 ring
139
140/-- `r b ≤ t/2 + (t/2) r⁴ + b/(2t)` for `0 ≤ b ≤ r`, `t > 0` (AM-GM: `r ≤ (t/2) r² + 1/(2t)`, then `r³ ≤ 1 + r⁴`). -/
141theorem pt_rb_le {r b t : ℝ} (hr : 0 ≤ r) (hb : 0 ≤ b) (hbr : b ≤ r) (ht : 0 < t) :
142 r * b ≤ t / 2 + t / 2 * r ^ 4 + 1 / (2 * t) * b := by
143 have key : r ≤ t / 2 * r ^ 2 + 1 / (2 * t) := by
144 have e : t / 2 * r ^ 2 + 1 / (2 * t) - r = (t * r - 1) ^ 2 / (2 * t) := by
145 field_simp
146 ring
147 have : 0 ≤ (t * r - 1) ^ 2 / (2 * t) := by positivity
148 linarith
149 have h3 : r ^ 3 ≤ 1 + r ^ 4 := by
150 nlinarith [mul_nonneg (sq_nonneg (r - 1)) (show (0 : ℝ) ≤ 3 * r ^ 2 + 2 * r + 1 by positivity)]
151 have h4 : r ^ 2 * b ≤ r ^ 3 := by
152 calc r ^ 2 * b ≤ r ^ 2 * r := mul_le_mul_of_nonneg_left hbr (sq_nonneg r)
153 _ = r ^ 3 := by ring
154 calc r * b ≤ (t / 2 * r ^ 2 + 1 / (2 * t)) * b := mul_le_mul_of_nonneg_right key hb
155 _ = t / 2 * (r ^ 2 * b) + 1 / (2 * t) * b := by ring
156 _ ≤ t / 2 * (1 + r ^ 4) + 1 / (2 * t) * b :=
157 by have := mul_le_mul_of_nonneg_left (h4.trans h3) (show (0 : ℝ) ≤ t / 2 by positivity); linarith
158 _ = t / 2 + t / 2 * r ^ 4 + 1 / (2 * t) * b := by ring
159
160/-- `bad_S(n) ≤ rc_S(n)`: the bad divisors are among the divisors in `S`. -/
161theorem badCount_le_rc (S : Finset ℕ) (n : ℕ) : badCount S n ≤ rc S n := by
162 unfold badCount rc
163 calc ∑ s ∈ S.filter (· ∣ n), ind (F n ≠ F (n / s))
164 ≤ ∑ s ∈ S.filter (· ∣ n), (1 : ℝ) := sum_le_sum fun s _ => by
165 unfold ind; split_ifs <;> norm_num
166 _ = _ := by simp
167
168/-- `E_W[rc·bad] ≤ t(1 + K/2) + E_W[bad]/(2t)` when `E_W[rc⁴] ≤ K`. -/
169theorem E_rb_le (W : Win) (S : Finset ℕ) {t K : ℝ} (ht : 0 < t) (hlo : 1 ≤ W.lo)
170 (hhi : W.lo ≤ W.hi) (hl : Real.log 2 ≤ W.len) (h4 : W.E (fun n => rc S n ^ 4) ≤ K) :
171 W.E (fun n => rc S n * badCount S n) ≤ t * (1 + K / 2) + 1 / (2 * t) * W.E (badCount S) := by
172 have hw : 0 ≤ W.len := le_trans (Real.log_nonneg one_le_two) hl
173 have h1 : W.E (fun n => rc S n * badCount S n) ≤
174 W.E (fun n => (t / 2 + t / 2 * rc S n ^ 4) + 1 / (2 * t) * badCount S n) :=
175 W.E_mono hw fun n _ => pt_rb_le (rc_nonneg S n) (Finset.sum_nonneg fun s _ => ind_nonneg _)
176 (badCount_le_rc S n) ht
177 have h2 : W.E (fun n => (t / 2 + t / 2 * rc S n ^ 4) + 1 / (2 * t) * badCount S n) =
178 W.E (fun _ => t / 2) + t / 2 * W.E (fun n => rc S n ^ 4) + 1 / (2 * t) * W.E (badCount S) := by
179 simp only [Win.E_add, Win.E_const_mul]
180 have hc : W.E (fun _ => t / 2) ≤ t := by
181 have := E_const_le W (t / 2) (by positivity) hlo hhi hl
182 linarith
183 have h5 : t / 2 * W.E (fun n => rc S n ^ 4) ≤ t / 2 * K :=
184 mul_le_mul_of_nonneg_left h4 (by positivity)
185 rw [h2] at h1
186 linarith
187
188/-- `E_W[(m - g)^4] ≤ 16 m⁴ + 8K` when `E_W[g⁴] ≤ K`, `log 2 ≤ len`. -/
189theorem E_fourth_le (W : Win) (g : ℕ → ℝ) (m K : ℝ) (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi)
190 (hl : Real.log 2 ≤ W.len) (hK : W.E (fun n => g n ^ 4) ≤ K) :
191 W.E (fun n => (m - g n) ^ 4) ≤ 16 * m ^ 4 + 8 * K := by
192 have hw : 0 ≤ W.len := le_trans (Real.log_nonneg one_le_two) hl
193 have hpt : ∀ n, (m - g n) ^ 4 ≤ (8 * m ^ 4) + 8 * g n ^ 4 := fun n => by
194 nlinarith [sq_nonneg (m ^ 2 - g n ^ 2), sq_nonneg (m - g n), sq_nonneg (m ^ 2), sq_nonneg (g n ^ 2),
195 sq_nonneg (m + g n), sq_nonneg (m * g n)]
196 have h1 := W.E_mono hw fun n _ => hpt n
197 have h2 : W.E (fun n => 8 * m ^ 4 + 8 * g n ^ 4) = 8 * W.E (fun _ => m ^ 4) + 8 * W.E (fun n => g n ^ 4) := by
198 simp only [Win.E_add, Win.E_const_mul]
199 have hc := E_const_le W (m ^ 4) (by positivity) hlo hhi hl
200 rw [h2] at h1
201 linarith
202
203/-- The shifted fourth moment `E_W[rc(·+h)⁴]`, bounded by the window moment on `[lo, hi+h]`
204(`n ↦ n+h` loses at most a factor `2` in `1/n` since `h ≤ lo`). -/
205theorem E_shift4_le (W : Win) (S : Finset ℕ) {C : ℝ} (hC0 : 0 ≤ C) (h : ℕ)
206 (hlo : 1 ≤ W.lo) (hhi : W.lo ≤ W.hi) (hl : 1 ≤ W.len) (hhlo : (h : ℝ) ≤ W.lo)
207 (hhhi : (h : ℝ) ≤ W.hi) (hcard : (S.card : ℝ) ^ 4 ≤ W.lo)
208 (hL : ∀ V : Win, 1 ≤ V.lo → V.lo ≤ V.hi →
209 V.sum (fun n => rc S n ^ 4) ≤ C * V.len + (S.card : ℝ) ^ 4 / V.lo) :
210 W.E (fun n => rc S (n + h) ^ 4) ≤ 2 * (2 * C + 1) := by
211 have hlo0 : 0 < W.lo := by linarith
212 have hhi0 : 0 < W.hi := by linarith
213 set V : Win := ⟨W.lo, W.hi + h⟩ with hVdef
214 have hVlo : V.lo = W.lo := rfl
215 have hVhi : V.hi = W.hi + h := rfl
216 -- the length grows by at most one
217 have hVlen : V.len ≤ W.len + 1 := by
218 have e1 : V.hi / V.lo = (V.hi / W.hi) * (W.hi / W.lo) := by
219 rw [hVlo, hVhi]; field_simp
220 have hA : Real.log (V.hi / V.lo) = Real.log (V.hi / W.hi) + Real.log (W.hi / W.lo) := by
221 rw [e1, Real.log_mul (by rw [hVhi]; positivity) (by positivity)]
222 have hB : Real.log (V.hi / W.hi) ≤ V.hi / W.hi - 1 :=
223 Real.log_le_sub_one_of_pos (by rw [hVhi]; positivity)
224 have hC2 : V.hi / W.hi ≤ 2 := by
225 rw [div_le_iff₀ hhi0, hVhi]; linarith
226 unfold Win.len
227 linarith
228 have hinj : Set.InjOn (fun n : ℕ => n + h) (W.pts : Set ℕ) := fun a _ b _ hab => by
229 simpa using hab
230 -- the sum over `W` is at most twice the sum over `V`
231 have hsum : W.sum (fun n => rc S (n + h) ^ 4) ≤ 2 * V.sum (fun n => rc S n ^ 4) := by
232 have step1 : ∀ n ∈ W.pts, rc S (n + h) ^ 4 / n ≤ 2 * (rc S (n + h) ^ 4 / ((n + h : ℕ) : ℝ)) := by
233 intro n hn
234 have hn' := Win.lo_lt_of_mem_pts hlo0.le hn
235 have hnh : (h : ℝ) ≤ n := by linarith
236 have hn0 : (0 : ℝ) < n := by linarith
237 have hnh0 : (0 : ℝ) < ((n + h : ℕ) : ℝ) := by push_cast; linarith
238 rw [mul_div_assoc', div_le_div_iff₀ hn0 hnh0]
239 push_cast
240 nlinarith [mul_nonneg (pow_nonneg (rc_nonneg S (n + h)) 4) (sub_nonneg.2 hnh)]
241 have hsub : W.pts.image (fun n => n + h) ⊆ V.pts := by
242 intro m hm
243 obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hm
244 obtain ⟨hnlo, hnhi⟩ := (Win.mem_pts hlo0.le hhi0.le).mp hn
245 refine (Win.mem_pts (by rw [hVlo]; exact hlo0.le) (by rw [hVhi]; positivity)).mpr ⟨?_, ?_⟩
246 · rw [hVlo]; push_cast; linarith
247 · rw [hVhi]; push_cast; linarith
248 have hnn : ∀ m ∈ V.pts, ∀ _ : m ∉ W.pts.image (fun n => n + h),
249 0 ≤ rc S m ^ 4 / (m : ℝ) := fun m _ _ => div_nonneg (pow_nonneg (rc_nonneg S m) 4) (Nat.cast_nonneg m)
250 calc W.sum (fun n => rc S (n + h) ^ 4)
251 = ∑ n ∈ W.pts, rc S (n + h) ^ 4 / (n : ℝ) := rfl
252 _ ≤ ∑ n ∈ W.pts, 2 * (rc S (n + h) ^ 4 / ((n + h : ℕ) : ℝ)) := sum_le_sum step1
253 _ = 2 * ∑ m ∈ W.pts.image (fun n => n + h), rc S m ^ 4 / (m : ℝ) := by
254 rw [Finset.sum_image hinj, Finset.mul_sum]
255 _ ≤ 2 * ∑ m ∈ V.pts, rc S m ^ 4 / (m : ℝ) :=
256 mul_le_mul_of_nonneg_left (Finset.sum_le_sum_of_subset_of_nonneg hsub hnn) (by norm_num)
257 _ = 2 * V.sum (fun n => rc S n ^ 4) := rfl
258 have hV' := hL V (by rw [hVlo]; exact hlo) (by rw [hVlo, hVhi]; linarith)
259 have hcard1 : (S.card : ℝ) ^ 4 / V.lo ≤ 1 := by
260 rw [hVlo, div_le_one hlo0]; exact hcard
261 have hlen0 : 0 < W.len := by linarith
262 have hC1 : C * 1 ≤ C * W.len := mul_le_mul_of_nonneg_left hl hC0
263 unfold Win.E
264 rw [div_le_iff₀ hlen0]
265 linarith [mul_le_mul_of_nonneg_left hVlen hC0]
266
267/-- Lower-order pieces of Lemma 29(a): `(log lo)^N ≤ exp √(log lo)` for large `lo`. -/
268theorem eventually_pow_le_exp_sqrt (N : ℕ) :
269 ∀ᶠ lo : ℝ in atTop, Real.log lo ^ N ≤ Real.exp (Real.sqrt (Real.log lo)) := by
270 filter_upwards [Real.tendsto_log_atTop.eventually_ge_atTop ((Nat.factorial (2 * N + 2) : ℕ) : ℝ)]
271 with lo hx
272 have hx0 : 0 ≤ Real.log lo := le_trans (Nat.cast_nonneg _) hx
273 have hfac : (0 : ℝ) < ((Nat.factorial (2 * N + 2) : ℕ) : ℝ) := by positivity
274 have h1 := Real.pow_div_factorial_le_exp (Real.sqrt (Real.log lo)) (Real.sqrt_nonneg _) (2 * N + 2)
275 have h2 : Real.sqrt (Real.log lo) ^ (2 * N + 2) = Real.log lo ^ (N + 1) := by
276 rw [show 2 * N + 2 = 2 * (N + 1) by ring, pow_mul, Real.sq_sqrt hx0]
277 rw [h2] at h1
278 have h3 : Real.log lo ^ N ≤ Real.log lo ^ (N + 1) / ((Nat.factorial (2 * N + 2) : ℕ) : ℝ) := by
279 rw [le_div_iff₀ hfac, pow_succ]
280 have hxN : 0 ≤ Real.log lo ^ N := pow_nonneg hx0 N
281 nlinarith
282 exact h3.trans h1
283
284/-- Final algebra of Lemma 29(a): the error bracket is at most `e`. -/
285theorem L29a_alg (C29 cS e m R s b len : ℝ) (hC29 : 0 < C29) (hc : 0 < cS) (he : 0 < e)
286 (hm : cS ≤ m) (hm0 : 0 < m) (hlen : 0 ≤ len) (hR0 : 0 ≤ R) (hb0 : 0 ≤ b)
287 (hR : R ≤ e * cS ^ 2 / (3 * C29)) (hb : b ≤ e * cS ^ 2 / (3 * C29))
288 (hs : s ≤ e * m ^ 2 / (3 * C29)) :
289 C29 * len / m ^ 2 * (R + s + b) ≤ e * len := by
290 have hm2 : cS ^ 2 ≤ m ^ 2 := pow_le_pow_left₀ hc.le hm 2
291 have hcS2 : 0 < cS ^ 2 := by positivity
292 have hm2p : 0 < m ^ 2 := by positivity
293 have hdiv : ∀ x : ℝ, 0 ≤ x → x / m ^ 2 ≤ x / cS ^ 2 := fun x hx =>
294 div_le_div_of_nonneg_left hx hcS2 hm2
295 have hR' : R / m ^ 2 ≤ e / (3 * C29) :=
296 (hdiv R hR0).trans ((div_le_div_of_nonneg_right hR hcS2.le).trans (le_of_eq (by field_simp)))
297 have hb' : b / m ^ 2 ≤ e / (3 * C29) :=
298 (hdiv b hb0).trans ((div_le_div_of_nonneg_right hb hcS2.le).trans (le_of_eq (by field_simp)))
299 have hs' : s / m ^ 2 ≤ e / (3 * C29) :=
300 (div_le_div_of_nonneg_right hs hm2p.le).trans (le_of_eq (by field_simp))
301 have key : C29 * len / m ^ 2 * (R + s + b) = C29 * len * (R / m ^ 2 + s / m ^ 2 + b / m ^ 2) := by
302 ring
303 rw [key]
304 have hsum : R / m ^ 2 + s / m ^ 2 + b / m ^ 2 ≤ 3 * (e / (3 * C29)) := by linarith
305 calc C29 * len * (R / m ^ 2 + s / m ^ 2 + b / m ^ 2) ≤ C29 * len * (3 * (e / (3 * C29))) :=
306 mul_le_mul_of_nonneg_left hsum (by positivity)
307 _ = e * len := by field_simp
308
309end E424
310