| 1 | module |
| 2 | |
| 3 | public import E424.LowBand.Defs |
| 4 | |
| 5 | @[expose] public section |
| 6 | |
| 7 | /-! |
| 8 | # Section 9: helpers for Lemma 40 |
| 9 | |
| 10 | Generic real analysis: measurability of `F̄`, Fubini for interval integrals, and the average of a |
| 11 | function over a sliding window. |
| 12 | -/ |
| 13 | |
| 14 | set_option linter.style.header false |
| 15 | open Finset MeasureTheory |
| 16 | |
| 17 | namespace E424 |
| 18 | |
| 19 | /-- `F̄` is measurable: a countable family of continuous functions selected by `⌊e^{x+1}⌋`. -/ |
| 20 | theorem measurable_Fb (Q : ℝ) : Measurable (Fb Q) := by |
| 21 | have hΦ : Measurable fun p : ℝ × ℕ => ∑ n ∈ Icc 1 p.2, F n / n * tri Q (p.1 - Real.log n) := by |
| 22 | refine measurable_from_prod_countable_left fun N => ?_ |
| 23 | show Measurable fun x : ℝ => ∑ n ∈ Icc 1 N, F n / n * tri Q (x - Real.log n) |
| 24 | refine Finset.measurable_sum _ fun n _ => ?_ |
| 25 | have : Continuous fun x : ℝ => F n / n * tri Q (x - Real.log n) := |
| 26 | continuous_const.mul ((Sm35.continuous_tri Q).comp (continuous_id.sub continuous_const)) |
| 27 | exact this.measurable |
| 28 | have hp : Measurable fun x : ℝ => (x, ⌊Real.exp (x + 1)⌋₊) := |
| 29 | measurable_id.prodMk (Nat.measurable_floor.comp (Real.measurable_exp.comp (measurable_id.add_const 1))) |
| 30 | have h2 := hΦ.comp hp |
| 31 | have h3 : Fb Q = (fun p : ℝ × ℕ => ∑ n ∈ Icc 1 p.2, F n / n * tri Q (p.1 - Real.log n)) ∘ fun x : ℝ => (x, ⌊Real.exp (x + 1)⌋₊) := by |
| 32 | funext x; rfl |
| 33 | rw [h3]; exact h2 |
| 34 | |
| 35 | /-- A measurable function bounded on `[a, b]` is interval integrable there. -/ |
| 36 | theorem ii_of_bdd {ψ : ℝ → ℝ} {a b M : ℝ} (hab : a ≤ b) (hψ : Measurable ψ) |
| 37 | (hM : ∀ x ∈ Set.Icc a b, |ψ x| ≤ M) : IntervalIntegrable ψ volume a b := by |
| 38 | rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab] |
| 39 | refine Measure.integrableOn_of_bounded (M := M) (by simp) hψ.aestronglyMeasurable ?_ |
| 40 | rw [ae_restrict_iff' measurableSet_Ioc] |
| 41 | refine Filter.Eventually.of_forall fun x hx => ?_ |
| 42 | rw [Real.norm_eq_abs] |
| 43 | exact hM x (Set.Ioc_subset_Icc_self hx) |
| 44 | |
| 45 | /-- Fubini for iterated interval integrals of a measurable function bounded on the rectangle; the |
| 46 | two inner integrals are interval integrable. -/ |
| 47 | theorem swap_ii {a b L M : ℝ} (hab : a ≤ b) (hL : 0 ≤ L) {G : ℝ → ℝ → ℝ} |
| 48 | (hG : Measurable (Function.uncurry G)) |
| 49 | (hM : ∀ z ∈ Set.Icc a b, ∀ x ∈ Set.Icc 0 L, |G z x| ≤ M) : |
| 50 | (∫ z in a..b, ∫ x in (0 : ℝ)..L, G z x) = (∫ x in (0 : ℝ)..L, ∫ z in a..b, G z x) ∧ |
| 51 | IntervalIntegrable (fun z => ∫ x in (0 : ℝ)..L, G z x) volume a b ∧ |
| 52 | IntervalIntegrable (fun x => ∫ z in a..b, G z x) volume 0 L := by |
| 53 | simp_rw [intervalIntegral.integral_of_le hab, intervalIntegral.integral_of_le hL] |
| 54 | have hint : Integrable (Function.uncurry G) |
| 55 | ((volume.restrict (Set.Ioc a b)).prod (volume.restrict (Set.Ioc 0 L))) := by |
| 56 | have hfin : IsFiniteMeasure ((volume.restrict (Set.Ioc a b)).prod (volume.restrict (Set.Ioc 0 L))) := |
| 57 | inferInstance |
| 58 | refine Integrable.of_bound (C := M) hG.aestronglyMeasurable ?_ |
| 59 | rw [Measure.prod_restrict, ae_restrict_iff' (measurableSet_Ioc.prod measurableSet_Ioc)] |
| 60 | refine Filter.Eventually.of_forall fun p hp => ?_ |
| 61 | rw [Real.norm_eq_abs] |
| 62 | exact hM p.1 (Set.Ioc_subset_Icc_self hp.1) p.2 (Set.Ioc_subset_Icc_self hp.2) |
| 63 | refine ⟨integral_integral_swap hint, ?_, ?_⟩ |
| 64 | · rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab] |
| 65 | exact hint.integral_prod_left |
| 66 | · rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hL] |
| 67 | exact hint.integral_prod_right |
| 68 | |
| 69 | /-- A nonnegative bounded measurable `ψ`, averaged over the window `[z, z + L]` and then integrated over |
| 70 | `z ∈ [a, b]`, is at most `L ∫_a^{b+L} ψ`. -/ |
| 71 | theorem avg_le {ψ : ℝ → ℝ} (hψ : Measurable ψ) (h0 : ∀ x, 0 ≤ ψ x) {a b L M : ℝ} (hab : a ≤ b) |
| 72 | (hL : 0 < L) (hM : ∀ x ∈ Set.Icc a (b + L), |ψ x| ≤ M) : |
| 73 | ∫ z in a..b, ∫ x in (0 : ℝ)..L, ψ (z + x) ≤ L * ∫ x in a..(b + L), ψ x := by |
| 74 | obtain ⟨he, -, hi2⟩ := swap_ii (M := M) hab hL.le (G := fun z x => ψ (z + x)) |
| 75 | (hψ.comp measurable_add) fun z hz x hx => hM _ ⟨by linarith [hz.1, hx.1], by linarith [hz.2, hx.2]⟩ |
| 76 | rw [he] |
| 77 | have hii : IntervalIntegrable ψ volume a (b + L) := ii_of_bdd (by linarith) hψ hM |
| 78 | have hpt : ∀ x ∈ Set.Icc (0 : ℝ) L, ∫ z in a..b, ψ (z + x) ≤ ∫ z in a..(b + L), ψ z := by |
| 79 | intro x hx |
| 80 | rw [intervalIntegral.integral_comp_add_right] |
| 81 | exact intervalIntegral.integral_mono_interval (by linarith [hx.1]) (by linarith) (by linarith [hx.2]) |
| 82 | (Filter.Eventually.of_forall h0) hii |
| 83 | calc ∫ x in (0 : ℝ)..L, ∫ z in a..b, ψ (z + x) ≤ ∫ x in (0 : ℝ)..L, ∫ z in a..(b + L), ψ z := |
| 84 | intervalIntegral.integral_mono_on hL.le hi2 intervalIntegrable_const hpt |
| 85 | _ = L * ∫ x in a..(b + L), ψ x := by simp |
| 86 | |
| 87 | /-- Deviation from the window average, integrated: if `∫_a^b |h z - h (z + x)| dz ≤ R` for every |
| 88 | `x ∈ [0, L]`, then `∫_a^b |h z - L⁻¹ ∫_0^L h (z + x) dx| dz ≤ R`. -/ |
| 89 | theorem avg_dev {h : ℝ → ℝ} (hh : Measurable h) {a b L M R : ℝ} (hab : a ≤ b) (hL : 0 < L) |
| 90 | (hM : ∀ x ∈ Set.Icc a (b + L), |h x| ≤ M) |
| 91 | (hR : ∀ x ∈ Set.Icc (0 : ℝ) L, ∫ z in a..b, |h z - h (z + x)| ≤ R) : |
| 92 | ∫ z in a..b, |h z - L⁻¹ * ∫ x in (0 : ℝ)..L, h (z + x)| ≤ R := by |
| 93 | obtain ⟨he, hi1, hi2⟩ := swap_ii (M := 2 * M) hab hL.le (G := fun z x => |h z - h (z + x)|) |
| 94 | ((hh.comp measurable_fst).sub (hh.comp measurable_add)).abs fun z hz x hx => by |
| 95 | have h1 := hM z ⟨hz.1, by linarith [hz.2]⟩ |
| 96 | have h2 := hM (z + x) ⟨by linarith [hz.1, hx.1], by linarith [hz.2, hx.2]⟩ |
| 97 | rw [abs_abs] |
| 98 | calc |h z - h (z + x)| ≤ |h z| + |h (z + x)| := abs_sub _ _ |
| 99 | _ ≤ 2 * M := by linarith |
| 100 | have hpt : ∀ z ∈ Set.Icc a b, |h z - L⁻¹ * ∫ x in (0 : ℝ)..L, h (z + x)| ≤ |
| 101 | L⁻¹ * ∫ x in (0 : ℝ)..L, |h z - h (z + x)| := by |
| 102 | intro z hz |
| 103 | have hiz : IntervalIntegrable (fun x => h (z + x)) volume 0 L := |
| 104 | ii_of_bdd (M := M) hL.le (hh.comp (measurable_const.add measurable_id)) fun x hx => |
| 105 | hM _ ⟨by linarith [hz.1, hx.1], by linarith [hz.2, hx.2]⟩ |
| 106 | have e1 : h z - L⁻¹ * ∫ x in (0 : ℝ)..L, h (z + x) = |
| 107 | L⁻¹ * ∫ x in (0 : ℝ)..L, (h z - h (z + x)) := by |
| 108 | rw [intervalIntegral.integral_sub intervalIntegrable_const hiz] |
| 109 | simp only [intervalIntegral.integral_const, smul_eq_mul, sub_zero] |
| 110 | field_simp |
| 111 | rw [e1, abs_mul, abs_of_pos (inv_pos.2 hL)] |
| 112 | exact mul_le_mul_of_nonneg_left (intervalIntegral.abs_integral_le_integral_abs hL.le) (inv_nonneg.2 hL.le) |
| 113 | have hS : ∫ z in a..b, |h z - L⁻¹ * ∫ x in (0 : ℝ)..L, h (z + x)| ≤ |
| 114 | ∫ z in a..b, L⁻¹ * ∫ x in (0 : ℝ)..L, |h z - h (z + x)| := by |
| 115 | rw [intervalIntegral.integral_of_le hab, intervalIntegral.integral_of_le hab] |
| 116 | refine integral_mono_of_nonneg (Filter.Eventually.of_forall fun z => abs_nonneg _) |
| 117 | ((intervalIntegrable_iff_integrableOn_Ioc_of_le hab).1 (hi1.const_mul L⁻¹)) ?_ |
| 118 | rw [Filter.EventuallyLE, ae_restrict_iff' measurableSet_Ioc] |
| 119 | exact Filter.Eventually.of_forall fun z hz => hpt z (Set.Ioc_subset_Icc_self hz) |
| 120 | refine hS.trans ?_ |
| 121 | rw [intervalIntegral.integral_const_mul, he] |
| 122 | have : ∫ x in (0 : ℝ)..L, ∫ z in a..b, |h z - h (z + x)| ≤ ∫ x in (0 : ℝ)..L, R := |
| 123 | intervalIntegral.integral_mono_on hL.le hi2 intervalIntegrable_const hR |
| 124 | calc L⁻¹ * ∫ x in (0 : ℝ)..L, ∫ z in a..b, |h z - h (z + x)| ≤ L⁻¹ * ∫ x in (0 : ℝ)..L, R := |
| 125 | mul_le_mul_of_nonneg_left this (inv_nonneg.2 hL.le) |
| 126 | _ = R := by simp; field_simp |
| 127 | |
| 128 | end E424 |
| 129 | |