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

All files · 223 lines · source at the verified commit

1module
2
3public import E424.LowBand.L40Aux
4public import E424.Setup.L3log
5
6@[expose] public section
7
8/-!
9# Section 9: helpers for Lemma 40, part 2
10
11Sums over integers against integrals of `g (⌊e^x⌋)`, the integral form of `L3_log`, and the
12Cauchy-Schwarz step.
13-/
14
15set_option linter.style.header false
16open Finset MeasureTheory
17
18namespace E424
19
20/-- On the cell `[log n, log (n+1)]` the function `g ⌊e^x⌋` is the constant `g n`. -/
21theorem cell_int (g : ℕ → ℝ) {n : ℕ} (hn : 1 ≤ n) :
22 ∫ x in Real.log n..Real.log (n + 1 : ℕ), g ⌊Real.exp x⌋₊ = g n * Real.log ((n + 1) / n) := by
23 have hn0 : (0 : ℝ) < n := by exact_mod_cast hn
24 have hlog : Real.log n ≤ Real.log (n + 1 : ℕ) := Real.log_le_log hn0 (by push_cast; linarith)
25 rw [intervalIntegral.integral_congr_Ioo_of_le (g := fun _ => g n) hlog]
26 · rw [intervalIntegral.integral_const, smul_eq_mul, mul_comm]
27 congr 1
28 push_cast
29 rw [Real.log_div (by positivity) hn0.ne']
30 · intro x hx
31 have h1 : (n : ℝ) ≤ Real.exp x := ((Real.log_lt_iff_lt_exp hn0).mp hx.1).le
32 have h3 : Real.exp x < n + 1 := by
33 have := (Real.lt_log_iff_exp_lt (by positivity)).mp hx.2
34 push_cast at this; exact this
35 have : ⌊Real.exp x⌋₊ = n := (Nat.floor_eq_iff (Real.exp_pos x).le).mpr ⟨h1, h3⟩
36 simp only [this]
37
38/-- A sum over integers is at most the integral of the step function, plus `B / m - B / M`. -/
39theorem sum_le_int {g : ℕ → ℝ} {B : ℝ} (h0 : ∀ n, 0 ≤ g n) (hB : ∀ n, g n ≤ B) {m M : ℕ}
40 (hm : 1 ≤ m) (hmM : m ≤ M) :
41 ∑ n ∈ Ico m M, g n / n ≤ (∫ x in Real.log m..Real.log M, g ⌊Real.exp x⌋₊) + (B / m - B / M) := by
42 have hB0 : 0 ≤ B := (h0 0).trans (hB 0)
43 have hi := fun u v => Sm35.integrable_floor_exp (g := g) (B := B)
44 (fun n => by rw [abs_of_nonneg (h0 n)]; exact hB n) u v
45 induction M, hmM using Nat.le_induction with
46 | base => simp
47 | succ M hmM ih =>
48 have hM1 : 1 ≤ M := hm.trans hmM
49 have hM0 : (0 : ℝ) < M := by exact_mod_cast hM1
50 rw [Finset.sum_Ico_succ_top hmM, ← intervalIntegral.integral_add_adjacent_intervals (hi _ _)
51 (hi (Real.log M) (Real.log (M + 1 : ℕ))), cell_int g hM1]
52 have hlog : 1 / ((M : ℝ) + 1) ≤ Real.log (((M : ℝ) + 1) / M) := by
53 have := Real.one_sub_inv_le_log_of_pos (x := ((M : ℝ) + 1) / M) (by positivity)
54 have e : 1 - (((M : ℝ) + 1) / M)⁻¹ = 1 / ((M : ℝ) + 1) := by field_simp; ring
55 linarith
56 have h1 : g M * (1 / ((M : ℝ) + 1)) ≤ g M * Real.log (((M : ℝ) + 1) / M) :=
57 mul_le_mul_of_nonneg_left hlog (h0 M)
58 have h2 : g M / M ≤ g M * (1 / ((M : ℝ) + 1)) + B / ((M : ℝ) * (M + 1)) := by
59 have : g M / M = g M * (1 / ((M : ℝ) + 1)) + g M / ((M : ℝ) * (M + 1)) := by field_simp
60 rw [this]
61 gcongr
62 exact hB M
63 have h3 : B / ((M : ℝ) * (M + 1)) = B / M - B / ((M + 1 : ℕ) : ℝ) := by
64 push_cast; field_simp; ring
65 linarith
66
67/-- On `A`, `F` vanishes off `G1`: `ind (n ∈ A) ≤ (1 - F n) + ind (n ∈ G1)`. -/
68theorem ind_A_le (n : ℕ) : ind (n ∈ A) ≤ (1 - F n) + ind (n ∈ G1) := by
69 have h1 := F_le_one n
70 have h2 := ind_nonneg (n ∈ G1)
71 by_cases hA : n ∈ A
72 · rw [ind_true hA]
73 by_cases hG : n ∈ G1
74 · rw [ind_true hG]; linarith
75 · have hU : n ∈ U := A_subset_U hA
76 have hf : f n = 0 := ind_false fun hB => hB.2 hA
77 have : F n = f n := by
78 by_contra hne; exact hG ⟨hU, hne⟩
79 rw [this, hf]; linarith
80 · rw [ind_false hA]; linarith
81
82/-- **`L3_log` in integral form**, with the exceptional set `G1`. -/
83theorem L3_int : ∃ α > (0 : ℝ), α ≤ 1 ∧ ∃ x0 ≥ (1 : ℝ), ∀ u v : ℝ, x0 ≤ u → u ≤ v →
84 α * Real.log (v / u) - 3 ≤
85 ∫ x in Real.log u..Real.log v, ((1 - F ⌊Real.exp x⌋₊) + ind (⌊Real.exp x⌋₊ ∈ G1)) := by
86 obtain ⟨α, hα, hα1, x0, hx0, h3⟩ := L3_log
87 refine ⟨α, hα, hα1, max x0 2, le_trans (by norm_num) (le_max_right _ _), fun u v hu huv => ?_⟩
88 have hu2 : (2 : ℝ) ≤ u := (le_max_right _ _).trans hu
89 have hux : x0 ≤ u := (le_max_left _ _).trans hu
90 have hu0 : 0 < u := by linarith
91 have hv0 : 0 < v := by linarith
92 have hlb := h3 u v hux huv
93 set φ : ℕ → ℝ := fun n => (1 - F n) + ind (n ∈ G1) with hφ
94 have hφ0 : ∀ n, 0 ≤ φ n := fun n => by
95 have := F_le_one n; have := ind_nonneg (n ∈ G1); simp only [hφ]; linarith
96 have hφ2 : ∀ n, φ n ≤ 2 := fun n => by
97 have := F_nonneg n; have := ind_le_one (n ∈ G1); simp only [hφ]; linarith
98 set m := ⌊u⌋₊ + 1 with hm
99 set M := ⌊v⌋₊ + 1 with hM
100 have hum : u < m := by rw [hm]; push_cast; exact Nat.lt_floor_add_one u
101 have hvM : v < M := by rw [hM]; push_cast; exact Nat.lt_floor_add_one v
102 have hMv : (M : ℝ) ≤ v + 1 := by
103 rw [hM]; push_cast; linarith [Nat.floor_le hv0.le]
104 have hm3 : (3 : ℝ) ≤ m := by
105 have : (2 : ℝ) ≤ ⌊u⌋₊ := by
106 have := Nat.le_floor hu2; exact_mod_cast this
107 rw [hm]; push_cast; linarith
108 have hm1 : 1 ≤ m := by omega
109 have hmM : m ≤ M := by
110 rw [hm, hM]; exact Nat.succ_le_succ (Nat.floor_mono huv)
111 have hsum : (Win.mk u v).sum (fun n => ind (n ∈ A)) = ∑ n ∈ Ico m M, ind (n ∈ A) / n := by
112 show ∑ n ∈ Ioc ⌊u⌋₊ ⌊v⌋₊, ind (n ∈ A) / n = _
113 have : Ioc ⌊u⌋₊ ⌊v⌋₊ = Ico m M := by
114 ext n; simp only [Finset.mem_Ioc, Finset.mem_Ico, hm, hM]; omega
115 rw [this]
116 have hle1 : ∑ n ∈ Ico m M, ind (n ∈ A) / n ≤ ∑ n ∈ Ico m M, φ n / n :=
117 Finset.sum_le_sum fun n _ => div_le_div_of_nonneg_right (ind_A_le n) (Nat.cast_nonneg n)
118 have hle2 := sum_le_int hφ0 hφ2 hm1 hmM
119 have hint : ∀ a b : ℝ, IntervalIntegrable (fun x => φ ⌊Real.exp x⌋₊) volume a b := fun a b =>
120 Sm35.integrable_floor_exp (B := 2) (fun n => by rw [abs_of_nonneg (hφ0 n)]; exact hφ2 n) a b
121 have hlu : Real.log u ≤ Real.log m := Real.log_le_log hu0 hum.le
122 have hlv : Real.log v ≤ Real.log M := Real.log_le_log hv0 hvM.le
123 have hmM' : Real.log m ≤ Real.log M := Real.log_le_log (by linarith) (by exact_mod_cast hmM)
124 have hI1 : ∫ x in Real.log m..Real.log M, φ ⌊Real.exp x⌋₊ ≤
125 ∫ x in Real.log u..Real.log M, φ ⌊Real.exp x⌋₊ :=
126 intervalIntegral.integral_mono_interval hlu hmM' le_rfl
127 (Filter.Eventually.of_forall fun x => hφ0 _) (hint _ _)
128 have hI2 := intervalIntegral.integral_add_adjacent_intervals (hint (Real.log u) (Real.log v))
129 (hint (Real.log v) (Real.log M))
130 have hI3 : ∫ x in Real.log v..Real.log M, φ ⌊Real.exp x⌋₊ ≤ 2 * (Real.log M - Real.log v) := by
131 have := intervalIntegral.integral_mono_on hlv (hint _ _) (intervalIntegrable_const (c := (2 : ℝ)))
132 (fun x _ => hφ2 _)
133 simp only [intervalIntegral.integral_const, smul_eq_mul] at this
134 linarith
135 have hI4 : Real.log M - Real.log v ≤ 1 / 2 := by
136 rw [← Real.log_div (by linarith) hv0.ne']
137 refine (Real.log_le_sub_one_of_pos (by positivity)).trans ?_
138 rw [div_sub_one hv0.ne', div_le_iff₀ hv0]
139 linarith
140 have hlogd : Real.log (v / u) = Real.log v - Real.log u := Real.log_div hv0.ne' hu0.ne'
141 have h2m : 2 / (m : ℝ) ≤ 1 := by rw [div_le_one (by linarith)]; linarith
142 have hM0 : (0 : ℝ) ≤ 2 / (M : ℝ) := by positivity
143 rw [hsum] at hlb
144 linarith
145
146/-- The integers of a window as an `Ico`. -/
147theorem pts_eq_Ico (W : Win) : W.pts = Ico (⌊W.lo⌋₊ + 1) (⌊W.hi⌋₊ + 1) := by
148 ext n; simp only [Win.pts, Finset.mem_Ioc, Finset.mem_Ico]; omega
149
150/-- The sum over a window is at most the integral over a subinterval plus edges. -/
151theorem win_sum_le {g : ℕ → ℝ} (h0 : ∀ n, 0 ≤ g n) (h1 : ∀ n, g n ≤ 1) {W : Win}
152 (hlt : W.lo < W.hi) {a b : ℝ}
153 (ha : Real.log (⌊W.lo⌋₊ + 1 : ℕ) ≤ a) (hb : b ≤ Real.log (⌊W.hi⌋₊ + 1 : ℕ)) :
154 W.sum g ≤ (∫ x in a..b, g ⌊Real.exp x⌋₊) + (a - Real.log (⌊W.lo⌋₊ + 1 : ℕ)) +
155 (Real.log (⌊W.hi⌋₊ + 1 : ℕ) - b) + 1 := by
156 have hm1 : 1 ≤ ⌊W.lo⌋₊ + 1 := by omega
157 have hmM : ⌊W.lo⌋₊ + 1 ≤ ⌊W.hi⌋₊ + 1 := Nat.succ_le_succ (Nat.floor_mono hlt.le)
158 have hs := sum_le_int h0 h1 hm1 hmM
159 have hi := fun u v => Sm35.integrable_floor_exp (g := g) (B := 1)
160 (fun n => by rw [abs_of_nonneg (h0 n)]; exact h1 n) u v
161 have hsplit := intervalIntegral.integral_add_adjacent_intervals (hi (Real.log (⌊W.lo⌋₊ + 1 : ℕ)) a) (hi a b)
162 have hsplit2 := intervalIntegral.integral_add_adjacent_intervals
163 (hi (Real.log (⌊W.lo⌋₊ + 1 : ℕ)) b) (hi b (Real.log (⌊W.hi⌋₊ + 1 : ℕ)))
164 have e1 : ∫ x in Real.log (⌊W.lo⌋₊ + 1 : ℕ)..a, g ⌊Real.exp x⌋₊ ≤ a - Real.log (⌊W.lo⌋₊ + 1 : ℕ) := by
165 have := intervalIntegral.integral_mono_on ha (hi _ _) (intervalIntegrable_const (c := (1 : ℝ)))
166 (fun x _ => h1 _)
167 simpa using this
168 have e2 : ∫ x in b..Real.log (⌊W.hi⌋₊ + 1 : ℕ), g ⌊Real.exp x⌋₊ ≤ Real.log (⌊W.hi⌋₊ + 1 : ℕ) - b := by
169 have := intervalIntegral.integral_mono_on hb (hi _ _) (intervalIntegrable_const (c := (1 : ℝ)))
170 (fun x _ => h1 _)
171 simpa using this
172 have hmpos : (0 : ℝ) < ((⌊W.lo⌋₊ + 1 : ℕ) : ℝ) := by positivity
173 have hMpos : (0 : ℝ) ≤ 1 / ((⌊W.hi⌋₊ + 1 : ℕ) : ℝ) := by positivity
174 have hmle : 1 / ((⌊W.lo⌋₊ + 1 : ℕ) : ℝ) ≤ 1 := by
175 rw [div_le_one hmpos]; exact_mod_cast hm1
176 rw [Win.sum, pts_eq_Ico]
177 have e3 : (1 : ℝ) / ((⌊W.lo⌋₊ + 1 : ℕ) : ℝ) - 1 / ((⌊W.hi⌋₊ + 1 : ℕ) : ℝ) ≤ 1 := by linarith
178 have e4 : (∫ x in Real.log (⌊W.lo⌋₊ + 1 : ℕ)..Real.log (⌊W.hi⌋₊ + 1 : ℕ), g ⌊Real.exp x⌋₊) =
179 (∫ x in Real.log (⌊W.lo⌋₊ + 1 : ℕ)..a, g ⌊Real.exp x⌋₊) + (∫ x in a..b, g ⌊Real.exp x⌋₊) +
180 ∫ x in b..Real.log (⌊W.hi⌋₊ + 1 : ℕ), g ⌊Real.exp x⌋₊ := by
181 linarith
182 simp only [one_div] at e3 hs
183 linarith
184
185/-- An integral over a subinterval is at most the sum over the window. -/
186theorem win_int_le {g : ℕ → ℝ} (h0 : ∀ n, 0 ≤ g n) (h1 : ∀ n, g n ≤ 1) {W : Win}
187 (hlt : W.lo < W.hi) {a b : ℝ}
188 (ha : Real.log (⌊W.lo⌋₊ + 1 : ℕ) ≤ a) (hab : a ≤ b) (hb : b ≤ Real.log (⌊W.hi⌋₊ + 1 : ℕ)) :
189 (∫ x in a..b, g ⌊Real.exp x⌋₊) ≤ W.sum g := by
190 have hm1 : 1 ≤ ⌊W.lo⌋₊ + 1 := by omega
191 have hmM : ⌊W.lo⌋₊ + 1 ≤ ⌊W.hi⌋₊ + 1 := Nat.succ_le_succ (Nat.floor_mono hlt.le)
192 have hi := fun u v => Sm35.integrable_floor_exp (g := g) (B := 1)
193 (fun n => by rw [abs_of_nonneg (h0 n)]; exact h1 n) u v
194 rw [Win.sum, pts_eq_Ico]
195 refine le_trans ?_ (Sm35.int_floor h0 h1 hm1 hmM)
196 exact intervalIntegral.integral_mono_interval ha hab hb (Filter.Eventually.of_forall fun x => h0 _) (hi _ _)
197
198/-- Cauchy-Schwarz in the form `∫ |u| ≤ λ D` when `∫ u² ≤ λ² D` and `q - p ≤ D`. -/
199theorem l1_le {u : ℝ → ℝ} {p q lam D : ℝ} (hpq : p ≤ q) (hlam : 0 < lam) (hD : q - p ≤ D)
200 (h1 : IntervalIntegrable (fun x => |u x|) volume p q)
201 (h2 : IntervalIntegrable (fun x => u x ^ 2) volume p q)
202 (hsq : ∫ x in p..q, u x ^ 2 ≤ lam ^ 2 * D) :
203 ∫ x in p..q, |u x| ≤ lam * D := by
204 have hpt : ∀ x ∈ Set.Icc p q, |u x| ≤ lam / 2 + u x ^ 2 / (2 * lam) := by
205 intro x _
206 rw [← sub_nonneg]
207 have : lam / 2 + u x ^ 2 / (2 * lam) - |u x| = (|u x| - lam) ^ 2 / (2 * lam) := by
208 have : u x ^ 2 = |u x| ^ 2 := (sq_abs _).symm
209 rw [this]; field_simp; ring
210 rw [this]; positivity
211 have h3 := intervalIntegral.integral_mono_on hpq h1
212 ((intervalIntegrable_const (c := lam / 2)).add (h2.div_const (2 * lam))) hpt
213 rw [intervalIntegral.integral_add intervalIntegrable_const (h2.div_const (2 * lam))] at h3
214 have h5 : ∫ x in p..q, u x ^ 2 / (2 * lam) = (∫ x in p..q, u x ^ 2) / (2 * lam) :=
215 intervalIntegral.integral_div _ _
216 simp only [intervalIntegral.integral_const, smul_eq_mul] at h3
217 rw [h5] at h3
218 have h4 : (∫ x in p..q, u x ^ 2) / (2 * lam) ≤ lam / 2 * D := by
219 rw [div_le_iff₀ (by positivity)]; nlinarith
220 nlinarith
221
222end E424
223