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/LowBand/L36Aux2.lean

All files · 277 lines · source at the verified commit

1module
2
3public import E424.LowBand.L36Aux
4
5@[expose] public section
6
7/-!
8# Section 9: the estimate of Lemma 36 for abstract `φn`, `φy`
9-/
10
11set_option linter.style.header false
12open Finset MeasureTheory
13
14namespace E424
15
16/-- First term of Lemma 36: `∑ |φ(log n) - F n| / n` against the integral. -/
17theorem L36_first {φ : ℝ → ℝ} {α β δ ς Λ K : ℝ} (hαβ : α ≤ β) (hK : 0 ≤ K)
18 (hlip : ∀ x x', α ≤ x → α ≤ x' → |φ x - φ x'| ≤ K * |x - x'|)
19 (hδ : K * Real.exp (-α) ≤ δ) (hδ0 : 0 ≤ δ) (hς : 0 ≤ ς) (hL : β - α ≤ Λ)
20 (hV : ∫ x in α..β, (F ⌊Real.exp x⌋₊ - φ x) ^ 2 ≤ ς * Λ) {g : ℕ → ℝ} (hg0 : ∀ n, 0 ≤ g n)
21 (hg : ∀ n : ℕ, Real.exp α ≤ n → g n = |φ (Real.log n) - F n|) :
22 ∑ n ∈ Ico ⌈Real.exp α⌉₊ ⌊Real.exp β⌋₊, g n / n ≤ 2 * (Real.sqrt ς * Λ + δ * Λ) := by
23 have hΛ : 0 ≤ Λ := by linarith
24 set A := ⌈Real.exp α⌉₊ with hA
25 set B := ⌊Real.exp β⌋₊ with hB
26 have hAe : Real.exp α ≤ A := Nat.le_ceil _
27 have hA1 : 1 ≤ A := Nat.one_le_iff_ne_zero.mpr (Nat.ceil_pos.mpr (Real.exp_pos α)).ne'
28 rcases le_total B A with hBA | hAB
29 · rw [Ico_eq_empty_of_le hBA, sum_empty]
30 have := Real.sqrt_nonneg ς
31 positivity
32 have hA0 : (0 : ℝ) < A := by exact_mod_cast hA1
33 have hB0 : (0 : ℝ) < B := lt_of_lt_of_le hA0 (by exact_mod_cast hAB)
34 have hαA : α ≤ Real.log A := (Real.le_log_iff_exp_le hA0).mpr hAe
35 have hBβ : Real.log B ≤ β := (Real.log_le_iff_le_exp hB0).mpr (Nat.floor_le (Real.exp_pos β).le)
36 have hlAB : Real.log A ≤ Real.log B := Real.log_le_log hA0 (by exact_mod_cast hAB)
37 have hc : ContinuousOn φ (Set.Icc α β) :=
38 continuousOn_of_lip (C := K) fun x hx y hy => hlip x y hx.1 hy.1
39 obtain ⟨i1, i2⟩ := ii_F_sub hαβ hc
40 have hψ : IntervalIntegrable (fun x => |F ⌊Real.exp x⌋₊ - φ x| + δ) volume α β :=
41 i1.abs.add intervalIntegrable_const
42 have hψ' : IntervalIntegrable (fun x => |F ⌊Real.exp x⌋₊ - φ x| + δ) volume (Real.log A) (Real.log B) := by
43 refine hψ.mono_set ?_
44 rw [Set.uIcc_of_le hlAB, Set.uIcc_of_le hαβ]
45 exact Set.Icc_subset_Icc hαA hBβ
46 refine (sum_div_le_int hA1 hAB hg0 hψ' ?_).trans (mul_le_mul_of_nonneg_left ?_ (by norm_num))
47 · intro n hn x hx1 hx2
48 have hn1 := (mem_Ico.mp hn).1
49 have hnA : (A : ℝ) ≤ n := by exact_mod_cast hn1
50 have hn0 : (0 : ℝ) < n := by linarith
51 have hne : Real.exp α ≤ n := by linarith
52 have hfl : ⌊Real.exp x⌋₊ = n := by
53 refine (Nat.floor_eq_iff (Real.exp_pos x).le).mpr ⟨((Real.log_lt_iff_lt_exp hn0).mp hx1).le, ?_⟩
54 have := (Real.lt_log_iff_exp_lt (by positivity)).mp hx2
55 push_cast at this; exact this
56 have hαn : α ≤ Real.log n := (Real.le_log_iff_exp_le hn0).mpr hne
57 have h1 := hlip (Real.log n) x hαn (by linarith)
58 have h2 : |Real.log n - x| ≤ Real.exp (-α) := by
59 have hc := (log_cell (n := n) (hA1.trans hn1)).2
60 rw [abs_sub_comm, abs_of_nonneg (by linarith)]
61 have : 1 / (n : ℝ) ≤ Real.exp (-α) := by
62 rw [Real.exp_neg, ← one_div]; exact one_div_le_one_div_of_le (Real.exp_pos α) hne
63 linarith
64 have h3 : |φ (Real.log n) - φ x| ≤ δ := h1.trans ((mul_le_mul_of_nonneg_left h2 hK).trans hδ)
65 rw [hfl, hg n hne]
66 have h4 := abs_sub_le (φ (Real.log n)) (φ x) (F n)
67 rw [abs_sub_comm (φ x)] at h4
68 linarith
69 · calc ∫ x in Real.log A..Real.log B, (|F ⌊Real.exp x⌋₊ - φ x| + δ)
70 ≤ ∫ x in α..β, (|F ⌊Real.exp x⌋₊ - φ x| + δ) :=
71 intervalIntegral.integral_mono_interval hαA hlAB hBβ
72 (Filter.Eventually.of_forall fun x => by positivity) hψ
73 _ = (∫ x in α..β, |F ⌊Real.exp x⌋₊ - φ x|) + (β - α) * δ := by
74 rw [intervalIntegral.integral_add i1.abs intervalIntegrable_const,
75 intervalIntegral.integral_const, smul_eq_mul]
76 _ ≤ Real.sqrt ς * Λ + δ * Λ := by
77 have := cs_avg hαβ i1 i2 hς hL hV
78 nlinarith
79
80theorem L36_core {S : Finset ℕ} {φn φy : ℝ → ℝ} {a b α β ℓ t δ ςn ςy Λ Kn Ky R : ℝ} (ha0 : 0 ≤ a) (hℓ : 0 ≤ ℓ)
81 (hα : α = a + ℓ) (hβ : β = b + ℓ + 2 * t) (ht : 0 ≤ t) (hab : a + 1 ≤ b)
82 (hS : ∀ s ∈ S, 1 ≤ s ∧ ℓ ≤ Real.log s ∧ Real.log s ≤ ℓ + t)
83 (hβt : Real.exp (β - t) + 1 ≤ Real.exp β) (hKn : 0 ≤ Kn)
84 (hn : ∀ x, α ≤ x → 0 ≤ φn x ∧ φn x ≤ 2)
85 (hnl : ∀ x x', α ≤ x → α ≤ x' → |φn x - φn x'| ≤ Kn * |x - x'|)
86 (hy : ∀ x, a ≤ x → 0 ≤ φy x ∧ φy x ≤ 2)
87 (hyl : ∀ x x', a ≤ x → a ≤ x' → |φy x - φy x'| ≤ Ky * |x - x'|)
88 (hδ : Kn * Real.exp (-a) ≤ δ) (hδ' : Real.exp (-a) ≤ δ) (hςn : 0 ≤ ςn) (hςy : 0 ≤ ςy)
89 (hΛ1 : 1 ≤ Λ) (hΛ : β - α ≤ Λ)
90 (hVn : ∫ x in α..β, (F ⌊Real.exp x⌋₊ - φn x) ^ 2 ≤ ςn * Λ)
91 (hVy : ∫ x in a..b, (F ⌊Real.exp x⌋₊ - φy x) ^ 2 ≤ ςy * Λ)
92 (hR0 : 0 ≤ R) (hR : ∀ n : ℕ, 1 ≤ n → (n : ℝ) ≤ Real.exp β → rc S n ≤ R) :
93 ∑ s ∈ S, 1 / (s : ℝ) * ∫ x in a..b, |φn (x + Real.log s) - φy x| ≤
94 ms S * (Real.sqrt ςy * Λ + 3 * (δ * Λ)) + R * (2 * (Real.sqrt ςn * Λ + δ * Λ)) +
95 ∑ n ∈ Ico ⌈Real.exp α⌉₊ ⌊Real.exp β⌋₊, badCount S n / n := by
96 have hδ0 : 0 ≤ δ := (Real.exp_pos _).le.trans hδ'
97 have hablt : a ≤ b := by linarith
98 have hbaΛ : b - a ≤ Λ := by linarith
99 set A := ⌈Real.exp a⌉₊ with hA
100 set B := ⌊Real.exp b⌋₊ + 1 with hB
101 have hea1 : 1 ≤ Real.exp a := Real.one_le_exp ha0
102 have hAe : Real.exp a ≤ A := Nat.le_ceil _
103 have hA0 : (0 : ℝ) < A := by linarith
104 have hA1 : 1 ≤ A := by exact_mod_cast (by linarith : (1 : ℝ) ≤ A)
105 have haA : a ≤ Real.log A := (Real.le_log_iff_exp_le hA0).mpr hAe
106 have hAa : Real.log A ≤ a + Real.exp (-a) := by
107 have h1 : (A : ℝ) ≤ Real.exp a * (1 + Real.exp (-a)) := by
108 rw [mul_add, ← Real.exp_add, add_neg_cancel, Real.exp_zero, mul_one]
109 exact (Nat.ceil_lt_add_one (Real.exp_pos a).le).le
110 have h2 := Real.log_le_log hA0 h1
111 rw [Real.log_mul (Real.exp_pos a).ne' (by positivity), Real.log_exp] at h2
112 have := Real.log_le_sub_one_of_pos (x := 1 + Real.exp (-a)) (by positivity)
113 linarith
114 have hAb : Real.log A ≤ b := by
115 have : Real.exp (-a) ≤ 1 := Real.exp_le_one_iff.mpr (by linarith)
116 linarith
117 have hBb : Real.exp b < B := by rw [hB]; push_cast; exact Nat.lt_floor_add_one _
118 have hB0 : (0 : ℝ) < B := (Real.exp_pos b).trans hBb
119 have hbB : b ≤ Real.log B := (Real.le_log_iff_exp_le hB0).mpr hBb.le
120 have hAB : A ≤ B := by
121 exact_mod_cast (Real.log_le_log_iff hA0 hB0).mp (hAb.trans hbB)
122 -- the truncated error
123 set g : ℕ → ℝ := fun n => if Real.exp α ≤ n then |φn (Real.log n) - F n| else 0 with hg
124 have hg0 : ∀ n, 0 ≤ g n := fun n => by
125 simp only [hg]; split_ifs
126 · positivity
127 · exact le_rfl
128 have hgB : ∀ n, g n ≤ 2 := fun n => by
129 simp only [hg]; split_ifs with h
130 · have h0 : (0 : ℝ) < n := (Real.exp_pos α).trans_le h
131 have h1 := hn _ ((Real.le_log_iff_exp_le h0).mpr h)
132 rw [abs_le]
133 constructor <;> linarith [h1.1, h1.2, F_nonneg n, F_le_one n]
134 · norm_num
135 set G : ℕ → ℕ → ℝ := fun s n => g n + |F n - F (n / s)| with hG
136 have hG0 : ∀ s n, 0 ≤ G s n := fun s n => add_nonneg (hg0 n) (abs_nonneg _)
137 have hGB : ∀ s n, G s n ≤ 3 := fun s n => by
138 have := Sm35.abs_F_sub_le n (n / s)
139 have := hgB n
140 simp only [hG]; linarith
141 -- integrability of the third term
142 have hcy : ContinuousOn φy (Set.Icc a b) :=
143 continuousOn_of_lip (C := Ky) fun x hx y hy => hyl x y hx.1 hy.1
144 obtain ⟨i1, i2⟩ := ii_F_sub hablt hcy
145 have i1' : IntervalIntegrable (fun x => F ⌊Real.exp x⌋₊ - φy x) volume (Real.log A) b := by
146 refine i1.mono_set ?_
147 rw [Set.uIcc_of_le hAb, Set.uIcc_of_le hablt]
148 exact Set.Icc_subset_Icc haA le_rfl
149 have third : ∫ x in Real.log A..b, |F ⌊Real.exp x⌋₊ - φy x| ≤ Real.sqrt ςy * Λ :=
150 (intervalIntegral.integral_mono_interval haA hAb le_rfl
151 (Filter.Eventually.of_forall fun x => abs_nonneg _) i1.abs).trans
152 (cs_avg hablt i1 i2 hςy hbaΛ hVy)
153 -- one `s`
154 have one : ∀ s ∈ S, ∫ x in a..b, |φn (x + Real.log s) - φy x| ≤
155 Real.sqrt ςy * Λ + 3 * (δ * Λ) + ∑ z ∈ Ico A B, G s (s * z) / z := by
156 intro s hs
157 obtain ⟨hs1, hsl, hsu⟩ := hS s hs
158 have hs0 : (0 : ℝ) < s := by exact_mod_cast hs1
159 have hcn : ContinuousOn (fun x => |φn (x + Real.log s) - φy x|) (Set.Icc a b) := by
160 refine ContinuousOn.abs (ContinuousOn.sub ?_ hcy)
161 refine continuousOn_of_lip (C := Kn) fun x hx y hy => ?_
162 have := hnl (x + Real.log s) (y + Real.log s) (by linarith [hx.1]) (by linarith [hy.1])
163 rwa [add_sub_add_right_eq_sub] at this
164 have j1 : IntervalIntegrable (fun x => |φn (x + Real.log s) - φy x|) volume a (Real.log A) :=
165 (hcn.mono (Set.Icc_subset_Icc le_rfl hAb)).intervalIntegrable_of_Icc haA
166 have j2 : IntervalIntegrable (fun x => |φn (x + Real.log s) - φy x|) volume (Real.log A) b :=
167 (hcn.mono (Set.Icc_subset_Icc haA le_rfl)).intervalIntegrable_of_Icc hAb
168 rw [← intervalIntegral.integral_add_adjacent_intervals j1 j2]
169 have p1 : ∫ x in a..Real.log A, |φn (x + Real.log s) - φy x| ≤ 2 * (δ * Λ) := by
170 have := intervalIntegral.integral_mono_on haA j1 (intervalIntegrable_const (c := 2)) fun x hx => by
171 have h1 := hn (x + Real.log s) (by linarith [hx.1])
172 have h2 := hy x hx.1
173 rw [abs_le]
174 constructor <;> linarith [h1.1, h1.2, h2.1, h2.2]
175 rw [intervalIntegral.integral_const, smul_eq_mul] at this
176 nlinarith
177 have k1 := Sm35.integrable_floor_exp (g := fun z => G s (s * z)) (B := 3)
178 (fun n => by rw [abs_of_nonneg (hG0 _ _)]; exact hGB _ _)
179 have p2 : ∫ x in Real.log A..b, |φn (x + Real.log s) - φy x| ≤
180 ∫ x in Real.log A..b, ((|F ⌊Real.exp x⌋₊ - φy x| + δ) + G s (s * ⌊Real.exp x⌋₊)) := by
181 refine intervalIntegral.integral_mono_on hAb j2
182 ((i1'.abs.add intervalIntegrable_const).add (k1 _ _)) fun x hx => ?_
183 set z := ⌊Real.exp x⌋₊ with hz
184 have hAx : (A : ℝ) ≤ Real.exp x := (Real.log_le_iff_le_exp hA0).mp hx.1
185 have hAz : A ≤ z := Nat.le_floor hAx
186 have hAz' : (A : ℝ) ≤ z := by exact_mod_cast hAz
187 have hz0 : (0 : ℝ) < z := by linarith
188 have hzx : Real.log z ≤ x := (Real.log_le_iff_le_exp hz0).mpr (Nat.floor_le (Real.exp_pos x).le)
189 have hxz : x ≤ Real.log (z + 1 : ℕ) :=
190 (Real.le_log_iff_exp_le (by positivity)).mpr (by push_cast; exact (Nat.lt_floor_add_one _).le)
191 have hd : |x + Real.log s - Real.log ((s * z : ℕ) : ℝ)| ≤ Real.exp (-a) := by
192 have hc := (log_cell (n := z) (hA1.trans hAz)).2
193 push_cast
194 rw [Real.log_mul hs0.ne' hz0.ne', show x + Real.log s - (Real.log s + Real.log z) = x - Real.log z by ring,
195 abs_of_nonneg (by linarith)]
196 have : 1 / (z : ℝ) ≤ Real.exp (-a) := by
197 rw [Real.exp_neg, ← one_div]; exact one_div_le_one_div_of_le (Real.exp_pos a) (by linarith)
198 linarith
199 have haz : a ≤ Real.log z := (Real.le_log_iff_exp_le hz0).mpr (by linarith)
200 have hαsz : α ≤ Real.log ((s * z : ℕ) : ℝ) := by
201 push_cast; rw [Real.log_mul hs0.ne' hz0.ne']; linarith
202 have hsz : Real.exp α ≤ ((s * z : ℕ) : ℝ) :=
203 (Real.le_log_iff_exp_le (by push_cast; positivity)).mp hαsz
204 have q1 : |φn (x + Real.log s) - φn (Real.log ((s * z : ℕ) : ℝ))| ≤ δ :=
205 (hnl _ _ (by linarith) hαsz).trans ((mul_le_mul_of_nonneg_left hd hKn).trans hδ)
206 have q2 : G s (s * z) = |φn (Real.log ((s * z : ℕ) : ℝ)) - F (s * z)| + |F (s * z) - F z| := by
207 simp only [hG, hg]
208 rw [if_pos hsz, Nat.mul_div_cancel_left _ (by omega)]
209 rw [q2]
210 have r1 := abs_sub_le (φn (x + Real.log s)) (φn (Real.log ((s * z : ℕ) : ℝ))) (φy x)
211 have r2 := abs_sub_le (φn (Real.log ((s * z : ℕ) : ℝ))) (F (s * z)) (φy x)
212 have r3 := abs_sub_le (F (s * z)) (F z) (φy x)
213 linarith
214 have p3 : ∫ x in Real.log A..b, G s (s * ⌊Real.exp x⌋₊) ≤ ∑ z ∈ Ico A B, G s (s * z) / z :=
215 (intervalIntegral.integral_mono_interval le_rfl hAb hbB
216 (Filter.Eventually.of_forall fun x => hG0 _ _) (k1 _ _)).trans
217 (Sm35.int_floor (g := fun z => G s (s * z)) (B := 3) (fun _ => hG0 _ _) (fun _ => hGB _ _) hA1 hAB)
218 rw [intervalIntegral.integral_add (i1'.abs.add intervalIntegrable_const) (k1 _ _),
219 intervalIntegral.integral_add i1'.abs intervalIntegrable_const,
220 intervalIntegral.integral_const, smul_eq_mul] at p2
221 have p4 : (b - Real.log A) * δ ≤ δ * Λ := by nlinarith
222 linarith
223 -- sum over `s`
224 set P := Ico ⌈Real.exp α⌉₊ ⌊Real.exp β⌋₊ with hP
225 have hmem : ∀ s ∈ S, ∀ z ∈ Ico A B, s * z ∈ P := by
226 intro s hs z hz
227 obtain ⟨hs1, hsl, hsu⟩ := hS s hs
228 have hs0 : (0 : ℝ) < s := by exact_mod_cast hs1
229 obtain ⟨hz1, hz2⟩ := mem_Ico.mp hz
230 have hAz' : (A : ℝ) ≤ z := by exact_mod_cast hz1
231 have hzb : (z : ℝ) ≤ Real.exp b := (Nat.le_floor_iff (Real.exp_pos b).le).mp (by omega)
232 have hsE : Real.exp ℓ ≤ s := (Real.le_log_iff_exp_le hs0).mp hsl
233 have hsE' : (s : ℝ) ≤ Real.exp (ℓ + t) := (Real.log_le_iff_le_exp hs0).mp hsu
234 rw [hP, mem_Ico]
235 constructor
236 · refine Nat.ceil_le.mpr ?_
237 rw [hα, add_comm, Real.exp_add]; push_cast
238 exact mul_le_mul hsE (by linarith) (Real.exp_pos a).le hs0.le
239 · refine Nat.le_floor ?_
240 refine le_trans ?_ hβt
241 push_cast
242 have : (s : ℝ) * z ≤ Real.exp (ℓ + t) * Real.exp b :=
243 mul_le_mul hsE' hzb z.cast_nonneg (Real.exp_pos _).le
244 rw [← Real.exp_add, show ℓ + t + b = β - t by rw [hβ]; ring] at this
245 linarith
246 have hdil := dilate_sum_le (S := S) (Z := Ico A B) (P := P) hG0 (fun s hs => (hS s hs).1) hmem
247 have hfirst : ∑ n ∈ P, g n / n ≤ 2 * (Real.sqrt ςn * Λ + δ * Λ) := by
248 refine L36_first (φ := φn) (by linarith) hKn hnl ?_ hδ0 hςn hΛ hVn hg0 fun n hn => if_pos hn
249 refine (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr ?_) hKn).trans hδ
250 linarith
251 have hsplit : ∑ n ∈ P, (∑ s ∈ S with s ∣ n, G s n) / n ≤
252 R * ∑ n ∈ P, g n / n + ∑ n ∈ P, badCount S n / n := by
253 rw [mul_sum, ← sum_add_distrib]
254 refine sum_le_sum fun n hn => ?_
255 have hn' := mem_Ico.mp hn
256 have hn1 : 1 ≤ n := by
257 have := Nat.ceil_pos.mpr (Real.exp_pos α)
258 omega
259 have hnβ : (n : ℝ) ≤ Real.exp β := (Nat.le_floor_iff (Real.exp_pos β).le).mp hn'.2.le
260 have e : ∑ s ∈ S with s ∣ n, G s n = rc S n * g n + badCount S n := by
261 simp only [hG]
262 rw [sum_add_distrib, sum_const, nsmul_eq_mul, badCount_eq]; rfl
263 rw [e, add_div, mul_div_assoc]
264 refine add_le_add (mul_le_mul_of_nonneg_right (hR n hn1 hnβ) ?_) le_rfl
265 exact div_nonneg (hg0 n) n.cast_nonneg
266 calc ∑ s ∈ S, 1 / (s : ℝ) * ∫ x in a..b, |φn (x + Real.log s) - φy x|
267 ≤ ∑ s ∈ S, 1 / (s : ℝ) * (Real.sqrt ςy * Λ + 3 * (δ * Λ) + ∑ z ∈ Ico A B, G s (s * z) / z) :=
268 sum_le_sum fun s hs => mul_le_mul_of_nonneg_left (one s hs) (by positivity)
269 _ = ms S * (Real.sqrt ςy * Λ + 3 * (δ * Λ)) + ∑ s ∈ S, 1 / (s : ℝ) * ∑ z ∈ Ico A B, G s (s * z) / z := by
270 simp_rw [mul_add (1 / ((_ : ℕ) : ℝ)) (Real.sqrt ςy * Λ + 3 * (δ * Λ))]
271 rw [sum_add_distrib, ← sum_mul]; rfl
272 _ ≤ _ := by
273 have := mul_le_mul_of_nonneg_left hfirst hR0
274 linarith
275
276end E424
277