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/HighBand/L35Aux4.lean

All files · 250 lines · source at the verified commit

1module
2
3public import E424.HighBand.L35Aux3
4
5@[expose] public section
6
7/-!
8# Lemma 35, part 4: shift sums, overlap, and assembly
9-/
10
11set_option linter.style.header false
12open Finset MeasureTheory
13
14namespace E424.Sm35
15
16theorem measurable_floor_exp (g : ℕ → ℝ) : Measurable fun x : ℝ => g ⌊Real.exp x⌋₊ :=
17 (measurable_from_nat (f := g)).comp (Nat.measurable_floor.comp Real.measurable_exp)
18
19theorem integrable_floor_exp {g : ℕ → ℝ} {B : ℝ} (hB : ∀ n, |g n| ≤ B) (a b : ℝ) :
20 IntervalIntegrable (fun x => g ⌊Real.exp x⌋₊) volume a b := by
21 refine (intervalIntegrable_const (c := B)).mono_fun (measurable_floor_exp g).aestronglyMeasurable ?_
22 refine Filter.Eventually.of_forall fun x => ?_
23 change |g ⌊Real.exp x⌋₊| ≤ |B|
24 exact (hB _).trans (le_abs_self B)
25
26theorem int_floor {g : ℕ → ℝ} {B : ℝ} (h0 : ∀ n, 0 ≤ g n) (hB : ∀ n, g n ≤ B) {a b : ℕ} (ha : 1 ≤ a)
27 (hab : a ≤ b) :
28 ∫ x in Real.log a..Real.log b, g ⌊Real.exp x⌋₊ ≤ ∑ n ∈ Ico a b, g n / n := by
29 have hi := fun u v => integrable_floor_exp (g := g) (B := B)
30 (fun n => by rw [abs_of_nonneg (h0 n)]; exact hB n) u v
31 have h2 := intervalIntegral.sum_integral_adjacent_intervals_Ico (f := fun x => g ⌊Real.exp x⌋₊)
32 (a := fun k : ℕ => Real.log k) (μ := volume) (m := a) (n := b) hab (fun k _ => hi _ _)
33 rw [← h2]
34 refine sum_le_sum fun n hn => ?_
35 have hn0 : (0 : ℝ) < n := by
36 have := (mem_Ico.mp hn).1
37 exact_mod_cast (by omega : 0 < n)
38 have hlog : Real.log n ≤ Real.log (n + 1 : ℕ) := Real.log_le_log hn0 (by push_cast; linarith)
39 rw [intervalIntegral.integral_congr_Ioo_of_le (g := fun _ => g n) hlog]
40 · rw [intervalIntegral.integral_const, smul_eq_mul, div_eq_inv_mul]
41 refine mul_le_mul_of_nonneg_right ?_ (h0 n)
42 rw [← Real.log_div (by positivity) hn0.ne']
43 refine (Real.log_le_sub_one_of_pos (by positivity)).trans (le_of_eq ?_)
44 push_cast; field_simp; ring
45 · intro x hx
46 have h1 : (n : ℝ) ≤ Real.exp x := ((Real.log_lt_iff_lt_exp hn0).mp hx.1).le
47 have h3 : Real.exp x < n + 1 := by
48 have := (Real.lt_log_iff_exp_lt (by positivity)).mp hx.2
49 push_cast at this; exact this
50 have : ⌊Real.exp x⌋₊ = n := (Nat.floor_eq_iff (Real.exp_pos x).le).mpr ⟨h1, h3⟩
51 simp only [this]
52
53theorem abs_F_eq (a b : ℕ) : |F a - F b| ≤ ind (F a ≠ F b) := by
54 by_cases h : F a = F b
55 · rw [h, sub_self, abs_zero]; exact ind_nonneg _
56 · rw [ind_true h]; exact abs_F_sub_le a b
57
58/-- `∫ Kf ≤ 2 M · max_h (shift sum)`. -/
59theorem int_Kf (W : Win) (hlo : 1 ≤ W.lo) (hlt : W.lo < W.hi) (hlen : 6 ≤ W.len) (M : ℕ) (hM : (M : ℝ) ≤ W.lo) (D : ℝ)
60 (hD : ∀ h : ℕ, 1 ≤ h → h ≤ M → W.sum (fun n => ind (F (n + h) ≠ F n)) ≤ D) :
61 ∫ x in (Real.log W.lo + 3)..(Real.log W.hi - 3), Kf M ⌊Real.exp x⌋₊ ≤ 2 * M * D := by
62 have hlo0 : 0 < W.lo := by linarith
63 have hhi0 : 0 < W.hi := by linarith
64 have hlen' : W.len = Real.log W.hi - Real.log W.lo := Real.log_div hhi0.ne' hlo0.ne'
65 set E := Real.exp 3 with hE
66 have hE4 : 4 ≤ E := by have := Real.add_one_le_exp (3 : ℝ); linarith
67 have hE0 : 0 < E := by linarith
68 set a := ⌊E * W.lo⌋₊ with ha
69 set b := ⌈W.hi / E⌉₊ with hb
70 have ha1 : W.lo + M < a := by
71 have := Nat.lt_floor_add_one (E * W.lo)
72 rw [← ha] at this
73 nlinarith
74 have ha0 : 1 ≤ a := by
75 have : (0 : ℝ) < a := by linarith [(Nat.cast_nonneg M : (0 : ℝ) ≤ M)]
76 exact_mod_cast this
77 have ha0' : (0 : ℝ) < a := by exact_mod_cast ha0
78 have hla : Real.log a ≤ Real.log W.lo + 3 := by
79 rw [Real.log_le_iff_le_exp ha0', Real.exp_add, Real.exp_log hlo0, mul_comm]
80 exact Nat.floor_le (by positivity)
81 have hb0 : (0 : ℝ) < b := lt_of_lt_of_le (by positivity) (Nat.le_ceil (W.hi / E))
82 have hlb : Real.log W.hi - 3 ≤ Real.log b := by
83 rw [Real.le_log_iff_exp_le hb0, Real.exp_sub, Real.exp_log hhi0]
84 exact Nat.le_ceil _
85 have hab : a ≤ b := by
86 have : Real.log a ≤ Real.log b := by linarith
87 exact_mod_cast (Real.log_le_log_iff ha0' hb0).mp this
88 have hhiE : W.lo * E ≤ W.hi / E := by
89 rw [← Real.log_le_log_iff (by positivity) (by positivity), Real.log_mul hlo0.ne' hE0.ne',
90 Real.log_div hhi0.ne' hE0.ne', hE, Real.log_exp]
91 linarith
92 have hpts : ∀ n : ℕ, W.lo < n → n < b → n ∈ W.pts := by
93 intro n h1 h2
94 rw [Win.mem_pts hlo0.le hhi0.le]
95 refine ⟨h1, ?_⟩
96 have h3 : (n : ℝ) < W.hi / E := Nat.lt_ceil.mp h2
97 exact h3.le.trans (div_le_self hhi0.le (by linarith))
98 have hKB : ∀ n, |Kf M n| ≤ 2 * M := fun n => by
99 rw [abs_of_nonneg (Kf_nonneg M n)]; exact Kf_le M n
100 have h1 : ∫ x in (Real.log W.lo + 3)..(Real.log W.hi - 3), Kf M ⌊Real.exp x⌋₊ ≤
101 ∫ x in Real.log a..Real.log b, Kf M ⌊Real.exp x⌋₊ :=
102 intervalIntegral.integral_mono_interval hla (by linarith) hlb
103 (Filter.Eventually.of_forall fun x => Kf_nonneg _ _) (integrable_floor_exp hKB _ _)
104 refine h1.trans ((int_floor (Kf_nonneg M) (Kf_le M) ha0 hab).trans ?_)
105 unfold Kf
106 simp_rw [sum_div, add_div]
107 rw [sum_comm]
108 have key : ∀ h ∈ Icc 1 M, ∑ n ∈ Ico a b, (|F (n + h) - F n| / n + |F (n - h) - F n| / n) ≤ 2 * D := by
109 intro h hh
110 obtain ⟨hh1, hhM⟩ := mem_Icc.mp hh
111 have hhM' : (h : ℝ) ≤ M := by exact_mod_cast hhM
112 have hDh := hD h hh1 hhM
113 have hnn : ∀ n ∈ W.pts, 0 ≤ ind (F (n + h) ≠ F n) / (n : ℝ) :=
114 fun n _ => div_nonneg (ind_nonneg _) n.cast_nonneg
115 have hle : ∀ n ∈ Ico a b, W.lo + M < n := by
116 intro n hn
117 have : (a : ℝ) ≤ n := by exact_mod_cast (mem_Ico.mp hn).1
118 linarith
119 rw [sum_add_distrib]
120 have s1 : ∑ n ∈ Ico a b, |F (n + h) - F n| / n ≤ D := by
121 refine le_trans ?_ hDh
122 refine (sum_le_sum (g := fun n : ℕ => ind (F (n + h) ≠ F n) / (n : ℝ)) fun n _ =>
123 div_le_div_of_nonneg_right (abs_F_eq _ _) n.cast_nonneg).trans ?_
124 refine sum_le_sum_of_subset_of_nonneg (fun n hn => ?_) fun n hn _ => hnn n hn
125 exact hpts n (by linarith [hle n hn, (Nat.cast_nonneg M : (0 : ℝ) ≤ M)]) (mem_Ico.mp hn).2
126 have s2 : ∑ n ∈ Ico a b, |F (n - h) - F n| / n ≤ D := by
127 refine le_trans ?_ hDh
128 have hhn : ∀ n ∈ Ico a b, h ≤ n ∧ W.lo < ((n - h : ℕ) : ℝ) := by
129 intro n hn
130 have h3 := hle n hn
131 have h4 : h ≤ n := by
132 have : (h : ℝ) ≤ n := by linarith
133 exact_mod_cast this
134 refine ⟨h4, ?_⟩
135 rw [Nat.cast_sub h4]; linarith
136 refine (sum_le_sum (g := fun n : ℕ => ind (F ((n - h) + h) ≠ F (n - h)) / ((n - h : ℕ) : ℝ))
137 fun n hn => ?_).trans ?_
138 · obtain ⟨h4, h5⟩ := hhn n hn
139 rw [Nat.sub_add_cancel h4, abs_sub_comm]
140 refine div_le_div₀ (ind_nonneg _) (abs_F_eq _ _) (by linarith) ?_
141 exact_mod_cast Nat.sub_le n h
142 · rw [← sum_image (f := fun m : ℕ => ind (F (m + h) ≠ F m) / (m : ℝ)) (g := fun n => n - h)
143 (s := Ico a b)]
144 · refine sum_le_sum_of_subset_of_nonneg (fun m hm => ?_) fun n hn _ => hnn n hn
145 obtain ⟨n, hn, rfl⟩ := mem_image.mp hm
146 exact hpts _ (hhn n hn).2 (lt_of_le_of_lt (Nat.sub_le n h) (mem_Ico.mp hn).2)
147 · intro n hn n' hn' heq
148 have := (hhn n hn).1
149 have := (hhn n' hn').1
150 simp only at heq
151 omega
152 linarith
153 refine (sum_le_sum key).trans ?_
154 rw [sum_const, Nat.card_Icc, nsmul_eq_mul]
155 simp; linarith
156
157/- ## Overlap -/
158
159theorem card_overlap (s : Finset ℕ) (X : ℝ) :
160 (s.filter fun k : ℕ => X / 8 < 2 ^ k ∧ (2 : ℝ) ^ k < 2 * X).card ≤ 4 := by
161 set t := s.filter fun k : ℕ => X / 8 < 2 ^ k ∧ (2 : ℝ) ^ k < 2 * X with ht
162 rcases t.eq_empty_or_nonempty with h | h
163 · rw [h]; simp
164 · set k0 := t.min' h with hk0
165 have h0 := (mem_filter.mp (t.min'_mem h)).2
166 have hsub : t ⊆ Icc k0 (k0 + 3) := by
167 intro k hk
168 rw [mem_Icc]
169 refine ⟨t.min'_le k hk, ?_⟩
170 have h1 := (mem_filter.mp hk).2
171 have h2 : (2 : ℝ) ^ k < 2 ^ (k0 + 4) := by
172 rw [pow_add]; have := h0.1; rw [← hk0] at this; linarith [h1.2]
173 have := (pow_lt_pow_iff_right₀ (by norm_num : (1 : ℝ) < 2)).mp h2
174 omega
175 have := card_le_card hsub
176 rw [Nat.card_Icc] at this
177 omega
178
179theorem sq_sum_overlap (s : Finset ℕ) (X : ℝ) (y : ℕ → ℝ)
180 (hy : ∀ k ∈ s, ¬(X / 8 < 2 ^ k ∧ (2 : ℝ) ^ k < 2 * X) → y k = 0) :
181 (∑ k ∈ s, y k) ^ 2 ≤ 4 * ∑ k ∈ s, y k ^ 2 := by
182 have h1 : ∑ k ∈ s, y k = ∑ k ∈ s.filter (fun k : ℕ => X / 8 < 2 ^ k ∧ (2 : ℝ) ^ k < 2 * X), y k :=
183 (sum_filter_of_ne fun k hk hne => by_contra fun hc => hne (hy k hk hc)).symm
184 rw [h1]
185 refine sq_sum_le_card_mul_sum_sq.trans ?_
186 have h2 : ((s.filter fun k : ℕ => X / 8 < 2 ^ k ∧ (2 : ℝ) ^ k < 2 * X).card : ℝ) ≤ 4 := by
187 exact_mod_cast card_overlap s X
188 refine mul_le_mul h2 ?_ (sum_nonneg fun _ _ => sq_nonneg _) (by norm_num)
189 exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) fun _ _ _ => sq_nonneg _
190
191/-- The partition of unity along `𝒩(W)`. -/
192theorem sum_gw (W : Win) (hlo : 0 < W.lo) {y : ℝ} (h1 : 16 * W.lo ≤ y) (h2 : 16 * y ≤ W.hi)
193 (hy : 4 ≤ y) : ∑ k ∈ W.dy, gw (y / 2 ^ k) = 1 := by
194 have hn : y ≤ 2 ^ (⌈W.hi⌉₊ + 1) := by
195 have a1 : W.hi ≤ ⌈W.hi⌉₊ := Nat.le_ceil _
196 have a2 : ((⌈W.hi⌉₊ + 1 : ℕ) : ℝ) ≤ 2 ^ (⌈W.hi⌉₊ + 1) := by
197 exact_mod_cast (Nat.lt_two_pow_self).le
198 push_cast at a2
199 linarith
200 rw [← gw_sum y _ hy hn]
201 unfold Win.dy
202 refine sum_subset (filter_subset _ _) fun k hk hk' => gw_eq_zero ?_
203 have h3 : ¬(4 * W.lo ≤ (2 : ℝ) ^ k ∧ 16 * (2 : ℝ) ^ k ≤ W.hi) := fun hc =>
204 hk' (mem_filter.mpr ⟨hk, hc⟩)
205 have hp : (0 : ℝ) < 2 ^ k := by positivity
206 rw [not_and_or, not_le, not_le] at h3
207 rcases h3 with h3 | h3
208 · right; rw [le_div_iff₀ hp]; linarith
209 · left; rw [div_le_one hp]; linarith
210
211theorem card_dy (W : Win) (hlo : 1 ≤ W.lo) (hlo' : W.lo < W.hi) (hlen : 6 ≤ W.len) :
212 (W.dy.card : ℝ) ≤ 2 * W.len := by
213 have hlo0 : 0 < W.lo := by linarith
214 have hhi0 : 0 < W.hi := by linarith
215 have hl2 := Real.log_two_gt_d9
216 have hl2' := Real.log_two_lt_d9
217 have hl20 : 0 < Real.log 2 := by linarith
218 have hlen' : W.len = Real.log W.hi - Real.log W.lo := Real.log_div hhi0.ne' hlo0.ne'
219 set a := Real.log (4 * W.lo) / Real.log 2
220 set b := Real.log (W.hi / 16) / Real.log 2
221 have e4 : Real.log 4 = 2 * Real.log 2 := by
222 rw [← Real.log_rpow (by norm_num)]; norm_num
223 have e16 : Real.log 16 = 4 * Real.log 2 := by
224 rw [show (16 : ℝ) = 2 ^ (4 : ℕ) by norm_num, Real.log_pow]; norm_num
225 have hba : b - a = W.len / Real.log 2 - 6 := by
226 simp only [a, b]
227 rw [Real.log_mul (by norm_num) hlo0.ne', Real.log_div hhi0.ne' (by norm_num), e4, e16, hlen']
228 field_simp; ring
229 have hq : W.len / Real.log 2 ≤ 2 * W.len := by
230 rw [div_le_iff₀ hl20]; nlinarith
231 have hq' : 6 ≤ W.len / Real.log 2 := by
232 rw [le_div_iff₀ hl20]; nlinarith
233 have hsub : W.dy ⊆ (Icc 1 ⌈W.hi⌉₊).filter fun n : ℕ => a ≤ n ∧ (n : ℝ) ≤ b := by
234 intro k hk
235 obtain ⟨hk1, hk2, hk3⟩ := mem_filter.mp hk
236 have hk0 : 1 ≤ k := by
237 by_contra hc
238 have : k = 0 := by omega
239 rw [this] at hk2; norm_num at hk2; linarith
240 refine mem_filter.mpr ⟨mem_Icc.mpr ⟨hk0, by have := mem_range.mp hk1; omega⟩, ?_, ?_⟩
241 · simp only [a]
242 rw [div_le_iff₀ hl20, ← Real.log_pow]
243 exact Real.log_le_log (by positivity) hk2
244 · simp only [b]
245 rw [le_div_iff₀ hl20, ← Real.log_pow]
246 exact Real.log_le_log (by positivity) (by linarith)
247 refine le_trans (Nat.cast_le.mpr (card_le_card hsub)) ((card_le (by linarith)).trans (by linarith))
248
249end E424.Sm35
250