From dd8f5a00a4773271aba8cc4e2202040c1ffd36b7 Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:37 +0900 Subject: [PATCH 1/7] Use the registered names for the style linter options Six linter options in `lakefile.lean` used names that no Mathlib linter registers, so Lean ignored them and those linters never ran. Rename them to `linter.style.{longLine,cdot,dollarSyntax,refine,missingEnd}` and drop `linter.setOption`, which is already covered by `linter.style.setOption`. Merge after the warning fixes for #71 have landed. Closes #71. Co-Authored-By: Claude Opus 5.5 --- lakefile.lean | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lakefile.lean b/lakefile.lean index 99554c8..082f6e1 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -3,14 +3,13 @@ open Lake DSL abbrev linter : Array LeanOption := #[ ⟨`linter.hashCommand, true⟩, - ⟨`linter.missingEnd, true⟩, - ⟨`linter.cdot, true⟩, - ⟨`linter.dollarSyntax, true⟩, + ⟨`linter.style.missingEnd, true⟩, + ⟨`linter.style.cdot, true⟩, + ⟨`linter.style.dollarSyntax, true⟩, ⟨`linter.style.lambdaSyntax, true⟩, - ⟨`linter.longLine, true⟩, + ⟨`linter.style.longLine, true⟩, ⟨`linter.oldObtain, true,⟩, - ⟨`linter.refine, true⟩, - ⟨`linter.setOption, true⟩, + ⟨`linter.style.refine, true⟩, ⟨`linter.style.setOption, true⟩, ⟨`linter.style.maxHeartbeats, true⟩ ] From d7bbb78558e917064f378cc9c01f330fed6ec3f5 Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:22 +0900 Subject: [PATCH 2/7] Fix style linter warnings in Probability/Process Wrap lines over 100 characters and fix the other style linter warnings (`refine'`, focusing dots, missing `end`) reported once the linter option names in `lakefile.lean` are corrected. Formatting only; no statement changes. Part of #71. Co-Authored-By: Claude Opus 5.5 --- StatsMLlib/Probability/Process/Dudley.lean | 334 ++++--- .../Probability/Process/FiniteMaximum.lean | 6 +- .../Probability/Process/SubGaussian.lean | 37 +- .../Probability/Process/TruncatedDudley.lean | 829 ++++++++++++------ 4 files changed, 819 insertions(+), 387 deletions(-) diff --git a/StatsMLlib/Probability/Process/Dudley.lean b/StatsMLlib/Probability/Process/Dudley.lean index 535ac13..36e61f0 100644 --- a/StatsMLlib/Probability/Process/Dudley.lean +++ b/StatsMLlib/Probability/Process/Dudley.lean @@ -344,7 +344,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} apply Finset.sup'_le hT intro u hu calc f u ≤ |f u| := le_abs_self _ - _ ≤ ∑ v ∈ T, |f v| := Finset.single_le_sum (f := fun v => |f v|) (fun _ _ => abs_nonneg _) hu + _ ≤ ∑ v ∈ T, |f v| := + Finset.single_le_sum (f := fun v => |f v|) (fun _ _ => abs_nonneg _) hu -- Similar bound for pairs have h_sup'_abs_bound_pair : ∀ {T : Finset (A × A)} (hT : T.Nonempty) (f : A × A → ℝ), @@ -362,7 +363,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} · apply Finset.sup'_le hT intro p hp calc f p ≤ |f p| := le_abs_self _ - _ ≤ ∑ q ∈ T, |f q| := Finset.single_le_sum (f := fun q => |f q|) (fun _ _ => abs_nonneg _) hp + _ ≤ ∑ q ∈ T, |f q| := + Finset.single_le_sum (f := fun q => |f q|) (fun _ _ => abs_nonneg _) hp have h_SBase_fin_int : Integrable SBase_fin μ := by have h_dom_int : Integrable (fun ω => ∑ u ∈ dn.nets 0, |X u ω - X t₀ ω|) μ := @@ -417,7 +419,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} -- Base level integral bound: E[SBase_fin] ≤ C * σ * D * √(log |net_0|) have h_base_bound_card_ge_2 : (dn.nets 0).card ≥ 2 → - ∃ C : ℝ, C > 0 ∧ C ≤ Real.sqrt 2 ∧ ∫ ω, SBase_fin ω ∂μ ≤ C * σ * D * Real.sqrt (Real.log (dn.nets 0).card) := by + ∃ C : ℝ, C > 0 ∧ C ≤ Real.sqrt 2 ∧ + ∫ ω, SBase_fin ω ∂μ ≤ C * σ * D * Real.sqrt (Real.log (dn.nets 0).card) := by intro hcard -- Pick a base point u₀ from net_0 using the nonemptiness witness let u₀ := (hnet_nonempty 0).choose @@ -438,7 +441,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} intro ω simp only [SBase_fin, SBase_shifted] -- sup_u (X u - X t₀) = sup_u ((X u - X u₀) + (X u₀ - X t₀)) - have h_rewrite : ∀ u, X u ω - X t₀ ω = (X u ω - X u₀ ω) + (X u₀ ω - X t₀ ω) := fun u => by ring + have h_rewrite : ∀ u, X u ω - X t₀ ω = (X u ω - X u₀ ω) + (X u₀ ω - X t₀ ω) := + fun u => by ring have h_eq_fns : (fun u => X u ω - X t₀ ω) = (fun u => (X u ω - X u₀ ω) + (X u₀ ω - X t₀ ω)) := funext h_rewrite rw [h_eq_fns] @@ -484,7 +488,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} have h_int_eq : ∫ ω, SBase_fin ω ∂μ = ∫ ω, SBase_shifted ω ∂μ + ∫ ω, (X u₀ ω - X t₀ ω) ∂μ := by calc ∫ ω, SBase_fin ω ∂μ _ = ∫ ω, SBase_shifted ω + (X u₀ ω - X t₀ ω) ∂μ := by congr; exact funext h_shift - _ = ∫ ω, SBase_shifted ω ∂μ + ∫ ω, (X u₀ ω - X t₀ ω) ∂μ := integral_add h_shifted_int (hX_int u₀ t₀) + _ = ∫ ω, SBase_shifted ω ∂μ + ∫ ω, (X u₀ ω - X t₀ ω) ∂μ := + integral_add h_shifted_int (hX_int u₀ t₀) -- The centering kills the second term rw [h_int_eq, hX_centered u₀ t₀, add_zero] -- Now bound the shifted sup using subGaussian_finite_max_bound' @@ -498,7 +503,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} have h_sup'_to_biSup : ∀ ω, SBase_shifted ω = ⨆ u ∈ dn.nets 0, (X u ω - X u₀ ω) := by intro ω simp only [SBase_shifted] - rw [← biSup_eq_sup'_of_finset (hnet_nonempty 0) (fun u => X u ω - X u₀ ω) (h_nonneg_witness ω)] + rw [← biSup_eq_sup'_of_finset (hnet_nonempty 0) (fun u => X u ω - X u₀ ω) + (h_nonneg_witness ω)] calc ∫ ω, SBase_shifted ω ∂μ _ = ∫ ω, ⨆ u ∈ dn.nets 0, (X u ω - X u₀ ω) ∂μ := by congr; exact funext h_sup'_to_biSup _ ≤ C * σ * D * Real.sqrt (Real.log (dn.nets 0).card) := hC_bound_all u₀ hu₀_mem @@ -541,7 +547,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} exact h_sup'_abs_bound (hnet_nonempty K) (fun u => X u ω - X t₀ ω) -- Pathwise bound: S_net ≤ SBase_fin + ∑ SΔ_trans k (tail is exactly zero) - have h_S_net_pathwise_trans : ∀ᵐ ω ∂μ, S_net ω ≤ SBase_fin ω + ∑ k ∈ Finset.range K, SΔ_trans k ω := by + have h_S_net_pathwise_trans : + ∀ᵐ ω ∂μ, S_net ω ≤ SBase_fin ω + ∑ k ∈ Finset.range K, SΔ_trans k ω := by apply Filter.Eventually.of_forall intro ω apply Finset.sup'_le (hnet_nonempty K) @@ -556,7 +563,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} have h_incr : ∀ k ∈ Finset.range K, X (transProj (k + 1) u) ω - X (transProj k u) ω ≤ SΔ_trans k ω := by intro k hk - have h_pair_mem : (transProj k u, transProj (k + 1) u) ∈ (h_chain_trans_finite k).toFinset := by + have h_pair_mem : + (transProj k u, transProj (k + 1) u) ∈ (h_chain_trans_finite k).toFinset := by simp only [Set.Finite.mem_toFinset] exact ⟨u, hu, rfl, rfl⟩ exact Finset.le_sup' (fun p => X p.2 ω - X p.1 ω) h_pair_mem @@ -634,18 +642,22 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} -- h1: ∫ SBase_fin ≤ (2√2) σ · dyadicRHS have h1 : ∫ (ω : Ω), SBase_fin ω ∂μ ≤ (2 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := by -- D · sqrtE(ε₁) ≤ 2 · dyadicRHS (k=0 term gives D · 2⁻¹ · sqrtE(ε₁)) - have h_sqrtE_le_rhs : D * sqrtEntropy (dyadicScale D 1) s ≤ 2 * dyadicRHS_real s D (K + 1) := by + have h_sqrtE_le_rhs : + D * sqrtEntropy (dyadicScale D 1) s ≤ 2 * dyadicRHS_real s D (K + 1) := by unfold dyadicRHS_real dyadicScale -- For (K + 1), the sum is over Finset.range (K + 1), which includes k = 0 - have h_sum_has_zero : 0 ∈ Finset.range (K + 1) := Finset.mem_range.mpr (Nat.zero_lt_succ K) + have h_sum_has_zero : 0 ∈ Finset.range (K + 1) := + Finset.mem_range.mpr (Nat.zero_lt_succ K) -- The sum includes at least the k=0 term, which has value (1/2) * sqrtE(D/2, s) - let f : ℕ → ℝ := fun k => (2 : ℝ)^(-((k : ℤ) + 1)) * sqrtEntropy (D * (2 : ℝ)^(-((k : ℤ) + 1))) s + let f : ℕ → ℝ := fun k => + (2 : ℝ)^(-((k : ℤ) + 1)) * sqrtEntropy (D * (2 : ℝ)^(-((k : ℤ) + 1))) s have h_single := Finset.single_le_sum (f := f) (a := 0) (fun k _ => mul_nonneg (by positivity) (sqrtEntropy_nonneg _ _)) h_sum_has_zero -- So: f 0 = (1/2) * sqrtE(D/2, s) ≤ sum - have h_tail_nonneg : 0 ≤ D * (2 : ℝ)^(-((K + 1) : ℤ)) * sqrtEntropy (D * (2 : ℝ)^(-((K + 1) : ℤ))) s := by + have h_tail_nonneg : 0 ≤ D * (2 : ℝ)^(-((K + 1) : ℤ)) * + sqrtEntropy (D * (2 : ℝ)^(-((K + 1) : ℤ))) s := by apply mul_nonneg (mul_nonneg (le_of_lt hD) (by positivity)) (sqrtEntropy_nonneg _ _) -- Now the main calc: D * sqrtE ≤ 2 * dyadicRHS_real -- Convert h_single to explicit form: f 0 = 2^(-1) * sqrtE(D * 2^(-1), s) @@ -660,14 +672,16 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} _ = D * sqrtEntropy (D * (2 : ℝ)⁻¹) s := by rw [h_two_inv] _ = 2 * (D * (2 : ℝ)⁻¹ * sqrtEntropy (D * (2 : ℝ)⁻¹) s) := by ring _ ≤ 2 * (D * ∑ k ∈ Finset.range (K + 1), f k) := by - have h_assoc : D * 2⁻¹ * sqrtEntropy (D * 2⁻¹) s = D * (2⁻¹ * sqrtEntropy (D * 2⁻¹) s) := by ring + have h_assoc : D * 2⁻¹ * sqrtEntropy (D * 2⁻¹) s = + D * (2⁻¹ * sqrtEntropy (D * 2⁻¹) s) := by ring rw [h_assoc] exact mul_le_mul_of_nonneg_left h_D_single (by norm_num : (0 : ℝ) ≤ 2) _ = 2 * (D * ∑ k ∈ Finset.range (K + 1), (2 : ℝ)^(-((k : ℤ) + 1)) * sqrtEntropy (D * (2 : ℝ)^(-((k : ℤ) + 1))) s) := by rfl _ ≤ 2 * (D * ∑ k ∈ Finset.range (K + 1), (2 : ℝ)^(-((k : ℤ) + 1)) * sqrtEntropy (D * (2 : ℝ)^(-((k : ℤ) + 1))) s + - D * (2 : ℝ)^(-((K + 1) : ℤ)) * sqrtEntropy (D * (2 : ℝ)^(-((K + 1) : ℤ))) s) := by + D * (2 : ℝ)^(-((K + 1) : ℤ)) * + sqrtEntropy (D * (2 : ℝ)^(-((K + 1) : ℤ))) s) := by linarith calc ∫ (ω : Ω), SBase_fin ω ∂μ _ ≤ C_base * σ * D * sqrtEntropy (dyadicScale D 1) s := h_base_sqrtE @@ -689,12 +703,15 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} · apply mul_nonneg (le_of_lt hD) apply Finset.sum_nonneg intro k _ - apply mul_nonneg (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _) (sqrtEntropy_nonneg _ _) - · apply mul_nonneg (mul_nonneg (le_of_lt hD) (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _)) + apply mul_nonneg (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _) + (sqrtEntropy_nonneg _ _) + · apply mul_nonneg + (mul_nonneg (le_of_lt hD) (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _)) exact sqrtEntropy_nonneg _ _ calc C_base * 2 * σ * dyadicRHS_real s D (K + 1) _ = C_base * 2 * (σ * dyadicRHS_real s D (K + 1)) := by ring - _ ≤ (2 * Real.sqrt 2) * (σ * dyadicRHS_real s D (K + 1)) := mul_le_mul_of_nonneg_right h_CB_bound h_rhs_nonneg' + _ ≤ (2 * Real.sqrt 2) * (σ * dyadicRHS_real s D (K + 1)) := + mul_le_mul_of_nonneg_right h_CB_bound h_rhs_nonneg' _ = (2 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := by ring -- Integrability of SΔ_trans (via domination by SΔ_fin for k < K, constant 0 for k ≥ K) @@ -732,7 +749,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} · calc SΔ_trans k ω _ ≤ SΔ_fin k ω := h_upper ω _ ≤ |SΔ_fin k ω| := le_abs_self _ - _ ≤ |SΔ_fin k ω| + |X p₀.2 ω - X p₀.1 ω| := by linarith [abs_nonneg (X p₀.2 ω - X p₀.1 ω)] + _ ≤ |SΔ_fin k ω| + |X p₀.2 ω - X p₀.1 ω| := by + linarith [abs_nonneg (X p₀.2 ω - X p₀.1 ω)] apply Integrable.mono ((h_SΔ_fin_int k).abs.add hp₀_int.abs) h_meas filter_upwards with ω simp only [Pi.add_apply, Real.norm_eq_abs] @@ -752,15 +770,19 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} simp only [Set.Finite.mem_toFinset] at hp obtain ⟨u, hu, hp1, hp2⟩ := hp simp only [transProj] at hp1 hp2 - have h1 : transitiveProj dn hnet_nonempty K k u = u := transitiveProj_of_le dn hnet_nonempty K k hk u - have h2 : transitiveProj dn hnet_nonempty K (k + 1) u = u := transitiveProj_of_le dn hnet_nonempty K (k + 1) (by omega) u + have h1 : transitiveProj dn hnet_nonempty K k u = u := + transitiveProj_of_le dn hnet_nonempty K k hk u + have h2 : transitiveProj dn hnet_nonempty K (k + 1) u = u := + transitiveProj_of_le dn hnet_nonempty K (k + 1) (by omega) u rw [hp1, hp2, h1, h2, sub_self] · -- 0 ≤ sup (since all elements equal 0) have hp₀' := (h_chain_trans_finite k).mem_toFinset.mp hp₀ obtain ⟨u₀, hu₀, hp₀_1, hp₀_2⟩ := hp₀' simp only [transProj] at hp₀_1 hp₀_2 - have h1 : transitiveProj dn hnet_nonempty K k u₀ = u₀ := transitiveProj_of_le dn hnet_nonempty K k hk u₀ - have h2 : transitiveProj dn hnet_nonempty K (k + 1) u₀ = u₀ := transitiveProj_of_le dn hnet_nonempty K (k + 1) (by omega) u₀ + have h1 : transitiveProj dn hnet_nonempty K k u₀ = u₀ := + transitiveProj_of_le dn hnet_nonempty K k hk u₀ + have h2 : transitiveProj dn hnet_nonempty K (k + 1) u₀ = u₀ := + transitiveProj_of_le dn hnet_nonempty K (k + 1) (by omega) u₀ calc (0 : ℝ) = X u₀ ω - X u₀ ω := by ring _ = X p₀.2 ω - X p₀.1 ω := by rw [hp₀_1, hp₀_2, h1, h2] _ ≤ SΔ_trans k ω := h_lower ω @@ -807,7 +829,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} Real.log_le_log h_mgf_pos h_mgf_bound _ = t^2 * (σ * dyadicScale D k)^2 / 2 := Real.log_exp _ calc ∫ ω, SΔ_trans k ω ∂μ - _ ≤ (σ * dyadicScale D k) * Real.sqrt (2 * Real.log (h_chain_trans_finite k).toFinset.card) := + _ ≤ (σ * dyadicScale D k) * + Real.sqrt (2 * Real.log (h_chain_trans_finite k).toFinset.card) := expected_max_subGaussian hσ'_pos h_ne hcard_trans (fun p _ => ((hX_meas p.2).sub (hX_meas p.1)).aemeasurable) (fun p _ => hX_int p.2 p.1) @@ -879,7 +902,8 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} apply sqrt_log_card_le_sqrtEntropy_of_card_le (dyadicScale_pos hD (k + 2)) hs -- Convert from ℕ ≤ ℕ (after untop) to WithTop ℕ ≤ WithTop ℕ have hne : coveringNumber (dyadicScale D (k + 2)) s ≠ ⊤ := - ne_top_of_lt (coveringNumber_lt_top_of_totallyBounded (dyadicScale_pos hD (k + 2)) hs) + ne_top_of_lt + (coveringNumber_lt_top_of_totallyBounded (dyadicScale_pos hD (k + 2)) hs) rw [← WithTop.coe_untop (coveringNumber (dyadicScale D (k + 2)) s) hne] exact WithTop.coe_le_coe.mpr (hcard_bound (k + 1)) have h_sum_le : ∑ k ∈ Finset.range K, dyadicScale D k * @@ -892,12 +916,16 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} have h2d_trans : ∑ k ∈ Finset.range K, dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s ≤ 4 * dyadicRHS_real s D (K + 1) := by have h_scale_factor : ∀ k, dyadicScale D k = 4 * dyadicScale D (k + 2) := by - intro k; simp only [dyadicScale]; rw [zpow_neg, zpow_neg, zpow_natCast, zpow_natCast] + intro k; simp only [dyadicScale] + rw [zpow_neg, zpow_neg, zpow_natCast, zpow_natCast] have h_pow : (2:ℝ)^(k+2) = (2:ℝ)^k * 4 := by rw [pow_add]; norm_num rw [h_pow]; field_simp - have h_sum_eq : ∑ k ∈ Finset.range K, dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s = - 4 * ∑ k ∈ Finset.range K, dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s := by - have : ∀ k ∈ Finset.range K, dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s = + have h_sum_eq : + ∑ k ∈ Finset.range K, dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s = + 4 * ∑ k ∈ Finset.range K, + dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s := by + have : ∀ k ∈ Finset.range K, + dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s = 4 * (dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s) := by intro k _; rw [h_scale_factor k]; ring rw [Finset.sum_congr rfl this, ← Finset.mul_sum] @@ -906,38 +934,53 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} unfold dyadicRHS_real have h_unfold_scale_k2 : ∀ k, dyadicScale D (k + 2) = D * (2:ℝ)^(-((k:ℤ) + 2)) := by intro k; simp only [dyadicScale, Nat.cast_add, Nat.cast_ofNat] - have h_sum_rewrite : ∑ k ∈ Finset.range K, dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s = - D * ∑ k ∈ Finset.range K, (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s := by - have : ∀ k ∈ Finset.range K, dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s = + have h_sum_rewrite : ∑ k ∈ Finset.range K, + dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s = + D * ∑ k ∈ Finset.range K, + (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s := by + have : ∀ k ∈ Finset.range K, + dyadicScale D (k + 2) * sqrtEntropy (dyadicScale D (k + 2)) s = D * ((2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s) := by intro k _; rw [h_unfold_scale_k2 k]; ring rw [Finset.sum_congr rfl this, ← Finset.mul_sum] rw [h_sum_rewrite] - have h_index_shift : ∑ k ∈ Finset.range K, (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s ≤ - ∑ k ∈ Finset.range (K + 1), (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s := by - let f := fun j : ℕ => (2:ℝ)^(-((j:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((j:ℤ) + 1))) s - have h_lhs_eq : ∑ k ∈ Finset.range K, (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s = + have h_index_shift : ∑ k ∈ Finset.range K, + (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s ≤ + ∑ k ∈ Finset.range (K + 1), + (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s := by + let f := fun j : ℕ => + (2:ℝ)^(-((j:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((j:ℤ) + 1))) s + have h_lhs_eq : ∑ k ∈ Finset.range K, + (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s = ∑ k ∈ Finset.range K, f (k + 1) := by apply Finset.sum_congr rfl; intro k _; simp only [f]; congr 2 rw [h_lhs_eq] - have h_sum_ico : ∑ k ∈ Finset.range K, f (k + 1) = ∑ j ∈ Finset.Ico 1 (K + 1), f j := by + have h_sum_ico : + ∑ k ∈ Finset.range K, f (k + 1) = ∑ j ∈ Finset.Ico 1 (K + 1), f j := by symm; rw [Finset.sum_Ico_eq_sum_range]; simp only [Nat.add_sub_cancel] apply Finset.sum_congr rfl; intro x _; ring_nf rw [h_sum_ico] apply Finset.sum_le_sum_of_subset_of_nonneg · intro j hj; simp only [Finset.mem_Ico, Finset.mem_range] at hj ⊢; omega - · intro j _ _; apply mul_nonneg (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _) (sqrtEntropy_nonneg _ _) - calc D * ∑ k ∈ Finset.range K, (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s - _ ≤ D * ∑ k ∈ Finset.range (K + 1), (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s := by + · intro j _ _ + apply mul_nonneg (zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) _) + (sqrtEntropy_nonneg _ _) + calc D * ∑ k ∈ Finset.range K, + (2:ℝ)^(-((k:ℤ) + 2)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 2))) s + _ ≤ D * ∑ k ∈ Finset.range (K + 1), + (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s := by apply mul_le_mul_of_nonneg_left h_index_shift (le_of_lt hD) - _ ≤ D * ∑ k ∈ Finset.range (K + 1), (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s + + _ ≤ D * ∑ k ∈ Finset.range (K + 1), + (2:ℝ)^(-((k:ℤ) + 1)) * sqrtEntropy (D * (2:ℝ)^(-((k:ℤ) + 1))) s + D * (2:ℝ)^(-((K + 1):ℤ)) * sqrtEntropy (D * (2:ℝ)^(-((K + 1):ℤ))) s := by apply le_add_of_nonneg_right apply mul_nonneg (mul_nonneg (le_of_lt hD) _) (sqrtEntropy_nonneg _ _) apply zpow_nonneg (by norm_num : (0:ℝ) ≤ 2) -- Final assembly: √2 × 4 = 4√2 (exact) - calc Real.sqrt 2 * σ * ∑ k ∈ Finset.range K, dyadicScale D k * Real.sqrt (Real.log (dn.nets (k + 1)).card) - _ ≤ Real.sqrt 2 * σ * ∑ k ∈ Finset.range K, dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s := by + calc Real.sqrt 2 * σ * ∑ k ∈ Finset.range K, + dyadicScale D k * Real.sqrt (Real.log (dn.nets (k + 1)).card) + _ ≤ Real.sqrt 2 * σ * ∑ k ∈ Finset.range K, + dyadicScale D k * sqrtEntropy (dyadicScale D (k + 2)) s := by apply mul_le_mul_of_nonneg_left h_sum_le apply mul_nonneg (Real.sqrt_nonneg _) (le_of_lt hσ) _ ≤ Real.sqrt 2 * σ * (4 * dyadicRHS_real s D (K + 1)) := by @@ -952,10 +995,12 @@ lemma dudley_chaining_bound_core {Ω : Type u} [MeasurableSpace Ω] {A : Type v} exact h_SΔ_trans_int k -- Sum bound using transitive projection (6√2) - have h_sum_bound_trans : ∫ (ω : Ω), SBase_fin ω ∂μ + ∫ (ω : Ω), ∑ k ∈ Finset.range K, SΔ_trans k ω ∂μ + have h_sum_bound_trans : + ∫ (ω : Ω), SBase_fin ω ∂μ + ∫ (ω : Ω), ∑ k ∈ Finset.range K, SΔ_trans k ω ∂μ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := by calc ∫ (ω : Ω), SBase_fin ω ∂μ + ∫ (ω : Ω), ∑ k ∈ Finset.range K, SΔ_trans k ω ∂μ - _ ≤ (2 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + (4 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := + _ ≤ (2 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + + (4 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := add_le_add h1 h2_trans _ = (2 * Real.sqrt 2 + 4 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := by ring _ = (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := by ring @@ -1024,7 +1069,8 @@ the expected supremum is bounded by the entropy integral: where {tₙ} is a dense sequence in s. The constant 12√2 ≈ 17 arises from transitive projection in the dyadic chaining argument. -/ -theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : Type v} [PseudoMetricSpace A] +theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : Type v} + [PseudoMetricSpace A] {μ : Measure Ω} [IsProbabilityMeasure μ] {X : A → Ω → ℝ} {σ : ℝ} (hσ : 0 < σ) (hX : IsSubGaussianProcess μ X σ) @@ -1038,7 +1084,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : -- Finiteness and continuity for limit argument (hfinite : entropyIntegralENNReal s D ≠ ⊤) (hcont : ∀ ω, Continuous (fun (t : ↥s) => X t.1 ω)) : - ∫ ω, ⨆ n : ℕ, X (denseSeqInTB hs ⟨t₀, ht₀⟩ n).1 ω ∂μ ≤ (12 * Real.sqrt 2) * σ * entropyIntegral s D := by + ∫ ω, ⨆ n : ℕ, X (denseSeqInTB hs ⟨t₀, ht₀⟩ n).1 ω ∂μ ≤ + (12 * Real.sqrt 2) * σ * entropyIntegral s D := by classical -- ══════════════════════════════════════════════════════════════════════════════ @@ -1092,7 +1139,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : simp only [Y, hcenter ω, sub_zero] conv_lhs => arg 2; ext ω; rw [h_Y_eq ω] have hcard_bound : ∀ k, (dn.nets k).card ≤ (coveringNumber (dyadicScale D (k + 1)) s).untop - (ne_top_of_lt (coveringNumber_lt_top_of_totallyBounded (dyadicScale_pos hD (k + 1)) hs)) := by + (ne_top_of_lt + (coveringNumber_lt_top_of_totallyBounded (dyadicScale_pos hD (k + 1)) hs)) := by intro k exact dn_good.card_bound k exact dudley_chaining_bound_core hσ hX hs hD hdiam K hK hX_meas hX_int hX_centered @@ -1132,7 +1180,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : _ < ε := hN K hK -- X(proj_K(tₙ))(ω) → X(tₙ)(ω) by path continuity - have h_X_tendsto : ∀ n ω, Filter.Tendsto (fun K => X (proj K n) ω) Filter.atTop (nhds (X (t n) ω)) := by + have h_X_tendsto : + ∀ n ω, Filter.Tendsto (fun K => X (proj K n) ω) Filter.atTop (nhds (X (t n) ω)) := by intro n ω have h_cont_at := (hcont ω).continuousAt (x := ⟨t n, ht_mem n⟩) have h_proj_in_s : ∀ K, proj K n ∈ s := fun K => dn.nets_subset K (h_proj_mem K n) @@ -1197,7 +1246,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : simp only [Finset.sup'_apply] -- Uniform L¹ bound: 𝔼[|Y_K|] = 𝔼[Y_K] + 2𝔼[Y_K⁻] ≤ C₁ + 2√(2π)σD - have h_bound_exist : ∃ R : NNReal, ∀ K, 1 ≤ K → MeasureTheory.eLpNorm (Y K) 1 μ ≤ (R : ℝ≥0∞) := by + have h_bound_exist : + ∃ R : NNReal, ∀ K, 1 ≤ K → MeasureTheory.eLpNorm (Y K) 1 μ ≤ (R : ℝ≥0∞) := by -- dyadicRHS bounded by 4 * entropyIntegral have h_rhs_bounded : ∃ C₁ : ℝ, 0 < C₁ ∧ ∀ K, 1 ≤ K → dyadicRHS_real s D (K + 1) ≤ C₁ := by have hδ_pos : ∀ K : ℕ, 0 < D * (2 : ℝ)^(-((K + 1) : ℤ)) := by @@ -1234,9 +1284,11 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : apply zpow_le_one_of_nonpos₀ (by norm_num : (1 : ℝ) ≤ 2) simp only [Left.neg_nonpos_iff] exact Int.natCast_nonneg (K + 1) - calc D * (2 : ℝ) ^ (-((K + 1) : ℤ)) ≤ D * 1 := mul_le_mul_of_nonneg_left h1 (le_of_lt hD) + calc D * (2 : ℝ) ^ (-((K + 1) : ℤ)) ≤ D * 1 := + mul_le_mul_of_nonneg_left h1 (le_of_lt hD) _ = D := mul_one D - have h_le_gap : δ * sqrtEntropy δ s ≤ entropyIntegral s D - entropyIntegralTrunc s δ D := by + have h_le_gap : + δ * sqrtEntropy δ s ≤ entropyIntegral s D - entropyIntegralTrunc s δ D := by have h_gap_eq : entropyIntegral s D - entropyIntegralTrunc s δ D = (entropyIntegralENNReal s D - entropyIntegralENNRealTrunc s δ D).toReal := by unfold entropyIntegral entropyIntegralTrunc @@ -1362,7 +1414,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : _ ≤ Real.sqrt (2 * Real.pi) * σ * D := h_proj_abs_bound K -- E[|Y_K|] ≤ C via |Y| = Y + 2Y⁻ - have h_abs_bound : ∀ K, 1 ≤ K → ∫ ω, |Y K ω| ∂μ ≤ (6 * Real.sqrt 2) * σ * C₁ + 2 * Real.sqrt (2 * Real.pi) * σ * D := by + have h_abs_bound : ∀ K, 1 ≤ K → ∫ ω, |Y K ω| ∂μ ≤ + (6 * Real.sqrt 2) * σ * C₁ + 2 * Real.sqrt (2 * Real.pi) * σ * D := by intro K hK have h_abs_eq : ∀ ω, |Y K ω| = Y K ω + 2 * (Y K ω)⁻ := by intro ω @@ -1378,7 +1431,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : conv_lhs => arg 2; ext ω; rw [h_abs_eq ω] rw [h_int_split] calc ∫ ω, Y K ω ∂μ + 2 * ∫ ω, (Y K ω)⁻ ∂μ - _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + 2 * (Real.sqrt (2 * Real.pi) * σ * D) := by + _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + + 2 * (Real.sqrt (2 * Real.pi) * σ * D) := by apply add_le_add (h_core_bound K hK) apply mul_le_mul_of_nonneg_left (h_neg_part_bound K hK) (by norm_num) _ ≤ (6 * Real.sqrt 2) * σ * C₁ + 2 * (Real.sqrt (2 * Real.pi) * σ * D) := by @@ -1398,7 +1452,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : rw [MeasureTheory.eLpNorm_one_eq_lintegral_enorm (h_Y_meas K).aestronglyMeasurable] simp only [Real.enorm_eq_ofReal_abs] have h_int_abs := (h_Y_int K hK).abs - rw [← MeasureTheory.ofReal_integral_eq_lintegral_ofReal h_int_abs (ae_of_all μ (fun ω => abs_nonneg _))] + rw [← MeasureTheory.ofReal_integral_eq_lintegral_ofReal h_int_abs + (ae_of_all μ (fun ω => abs_nonneg _))] exact ENNReal.ofReal_le_coe.mpr (h_abs_bound K hK) obtain ⟨R, hR⟩ := h_bound_exist @@ -1442,7 +1497,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : exact tendsto_le_liminf_of_le' (h_X_tendsto n ω) (fun K => h_le_Y K n ω) (h_Y_bdd_below ω) h_liminf_ne_top - have h_pointwise_sup : ∀ᵐ ω ∂μ, (⨆ n, X (t n) ω) ≤ Filter.liminf (fun K => Y K ω) Filter.atTop := by + have h_pointwise_sup : + ∀ᵐ ω ∂μ, (⨆ n, X (t n) ω) ≤ Filter.liminf (fun K => Y K ω) Filter.atTop := by filter_upwards [h_pointwise] with ω h_all_n by_cases h_bdd : BddAbove (Set.range (fun n => X (t n) ω)) · exact ciSup_le (fun n => h_all_n n) @@ -1508,18 +1564,21 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : exact h1.sub h2 -- E[|Δ_K|] ≤ 3√(2π)σD·2^{-K} via sub-Gaussian first moment bound - have h_Δ_moment : ∀ K, ∫ ω, |Δ K ω| ∂μ ≤ 3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ)) := by + have h_Δ_moment : + ∀ K, ∫ ω, |Δ K ω| ∂μ ≤ 3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ)) := by intro K have h_bound := subGaussian_first_moment_bound hσ hX (proj (K + 1) 0) (proj K 0) (hX_int (proj (K + 1) 0) (proj K 0)) (hX_int_exp (proj (K + 1) 0) (proj K 0)) - have h_dist : dist (proj (K + 1) 0) (proj K 0) ≤ dyadicScale D (K + 1) + dyadicScale D K := by + have h_dist : + dist (proj (K + 1) 0) (proj K 0) ≤ dyadicScale D (K + 1) + dyadicScale D K := by calc dist (proj (K + 1) 0) (proj K 0) ≤ dist (proj (K + 1) 0) (t 0) + dist (t 0) (proj K 0) := dist_triangle _ _ _ _ ≤ dyadicScale D (K + 1) + dyadicScale D K := by apply add_le_add · rw [dist_comm]; exact h_proj_dist (K + 1) 0 · exact h_proj_dist K 0 - have h_scale_bound : dyadicScale D (K + 1) + dyadicScale D K ≤ 3 * D * (2 : ℝ)^(-(K : ℤ)) := by + have h_scale_bound : + dyadicScale D (K + 1) + dyadicScale D K ≤ 3 * D * (2 : ℝ)^(-(K : ℤ)) := by simp only [dyadicScale] have h1 : (2 : ℝ)^(-(↑(K + 1) : ℤ)) = (2 : ℝ)^(-(K : ℤ)) / 2 := by have : (↑(K + 1) : ℤ) = (K : ℤ) + 1 := by simp @@ -1529,7 +1588,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : calc D * ((2 : ℝ)^(-(K : ℤ)) / 2) + D * (2 : ℝ)^(-(K : ℤ)) = D * (2 : ℝ)^(-(K : ℤ)) * (1/2 + 1) := by ring _ = D * (2 : ℝ)^(-(K : ℤ)) * (3/2) := by norm_num - _ ≤ 3 * D * (2 : ℝ)^(-(K : ℤ)) := by nlinarith [hD.le, zpow_nonneg (by norm_num : (0 : ℝ) ≤ 2) (-(K : ℤ))] + _ ≤ 3 * D * (2 : ℝ)^(-(K : ℤ)) := by + nlinarith [hD.le, zpow_nonneg (by norm_num : (0 : ℝ) ≤ 2) (-(K : ℤ))] calc ∫ ω, |Δ K ω| ∂μ = ∫ ω, |X (proj (K + 1) 0) ω - X (proj K 0) ω| ∂μ := rfl _ ≤ Real.sqrt (2 * Real.pi) * σ * dist (proj (K + 1) 0) (proj K 0) := h_bound _ ≤ Real.sqrt (2 * Real.pi) * σ * (dyadicScale D (K + 1) + dyadicScale D K) := by @@ -1570,13 +1630,16 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : simp only [Real.norm_eq_abs] at h_int_norm exact h_int_norm · exact ae_of_all μ (fun ω => abs_nonneg _) - _ ≤ ∑' (K : ℕ), ENNReal.ofReal (3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) := by + _ ≤ ∑' (K : ℕ), + ENNReal.ofReal (3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) := by apply ENNReal.tsum_le_tsum intro K exact ENNReal.ofReal_le_ofReal (h_Δ_moment K) _ < ⊤ := by - calc ∑' (K : ℕ), ENNReal.ofReal (3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) - = ENNReal.ofReal (∑' (K : ℕ), 3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) := by + calc ∑' (K : ℕ), + ENNReal.ofReal (3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) + = ENNReal.ofReal + (∑' (K : ℕ), 3 * Real.sqrt (2 * Real.pi) * σ * D * (2 : ℝ)^(-(K : ℤ))) := by rw [ENNReal.ofReal_tsum_of_nonneg] · intro K apply mul_nonneg @@ -1607,7 +1670,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : exact (Real.coe_toNNReal _ (abs_nonneg _)).symm -- Telescoping bound: |g| ≤ |X(t₀)| + |X(proj_0(0)) - X(t₀)| + ∑_K |Δ_K| - have h_g_bound_ae : ∀ᵐ ω ∂μ, |g ω| ≤ |X (t 0) ω| + |X (proj 0 0) ω - X (t 0) ω| + ∑' K, |Δ K ω| := by + have h_g_bound_ae : + ∀ᵐ ω ∂μ, |g ω| ≤ |X (t 0) ω| + |X (proj 0 0) ω - X (t 0) ω| + ∑' K, |Δ K ω| := by filter_upwards [h_Δ_summable_ae] with ω h_summable have h_conv := h_X_tendsto 0 ω have h_telescope : ∀ K, X (proj K 0) ω - X (proj 0 0) ω = ∑ j ∈ Finset.range K, Δ j ω := by @@ -1623,7 +1687,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : calc |X (proj K 0) ω - X (t 0) ω| = |(X (proj K 0) ω - X (proj 0 0) ω) + (X (proj 0 0) ω - X (t 0) ω)| := by ring_nf _ ≤ |X (proj K 0) ω - X (proj 0 0) ω| + |X (proj 0 0) ω - X (t 0) ω| := abs_add_le _ _ - _ = |∑ j ∈ Finset.range K, Δ j ω| + |X (proj 0 0) ω - X (t 0) ω| := by rw [h_telescope K] + _ = |∑ j ∈ Finset.range K, Δ j ω| + |X (proj 0 0) ω - X (t 0) ω| := by + rw [h_telescope K] _ ≤ ∑ j ∈ Finset.range K, |Δ j ω| + |X (proj 0 0) ω - X (t 0) ω| := by gcongr exact Finset.abs_sum_le_sum_abs _ _ @@ -1663,7 +1728,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : _ = |X (t 0) ω| + |X (proj 0 0) ω - X (t 0) ω| + ∑' J, |Δ J ω| := by ring -- Dominating function is integrable (∑' K, |Δ K| via interchange of sum and integral) - have h_dom_int : Integrable (fun ω => |X (t 0) ω| + |X (proj 0 0) ω - X (t 0) ω| + ∑' K, |Δ K ω|) μ := by + have h_dom_int : + Integrable (fun ω => |X (t 0) ω| + |X (proj 0 0) ω - X (t 0) ω| + ∑' K, |Δ K ω|) μ := by apply Integrable.add apply Integrable.add · exact h_t0_int.abs @@ -1708,7 +1774,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : rw [ofReal_integral_eq_lintegral_ofReal (h_Δ_abs_int K) (ae_of_all μ (fun ω => abs_nonneg _))] _ < ⊤ := by - have h_nonneg : ∀ K, 0 ≤ ∫ ω, |Δ K ω| ∂μ := fun K => integral_nonneg (fun _ => abs_nonneg _) + have h_nonneg : ∀ K, 0 ≤ ∫ ω, |Δ K ω| ∂μ := + fun K => integral_nonneg (fun _ => abs_nonneg _) rw [← ENNReal.ofReal_tsum_of_nonneg h_nonneg h_sum_Δ_summable] exact ENNReal.ofReal_lt_top exact ⟨h_ae_meas, h_finite⟩ @@ -1824,8 +1891,10 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : · -- Unbounded case: liminf = 0 have h_liminf_eq_zero : Filter.liminf (fun K => Z K ω) Filter.atTop = 0 := by unfold Filter.liminf Filter.limsInf - have h_unbdd : ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by - simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] at h_cobdd + have h_unbdd : + ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by + simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] + at h_cobdd intro ⟨b, hb⟩ apply h_cobdd use b @@ -1977,7 +2046,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have h_meas : Measurable (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) := Measurable.liminf (fun K => h_Z_meas K) -- Step 2: liminf Z is nonnegative a.e. - have h_nonneg_ae : 0 ≤ᵐ[μ] (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) := by + have h_nonneg_ae : + 0 ≤ᵐ[μ] (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) := by filter_upwards [h_liminf_Z] with ω hω show 0 ≤ Filter.liminf (fun K => Z K ω) Filter.atTop by_cases hcobdd : Filter.IsCoboundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) @@ -1985,12 +2055,15 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : exact Filter.Eventually.of_forall (fun K => h_Z_nonneg K ω) · -- Unbounded case: liminf = 0 in ℝ unfold Filter.liminf Filter.limsInf - have h_unbdd : ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by - simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] at hcobdd + have h_unbdd : + ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by + simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] + at hcobdd intro ⟨b, hb⟩; apply hcobdd; use b; intro a ha; exact hb ha rw [Real.sSup_of_not_bddAbove h_unbdd] -- Step 3: lintegral is finite - use Fatou and bounds on ∫ Z_K - have h_lintegral_finite : ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≠ ⊤ := by + have h_lintegral_finite : + ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≠ ⊤ := by let g' : ℕ → Ω → ℝ≥0∞ := fun K ω => ENNReal.ofReal (Z K ω) have hg'_meas : ∀ K, Measurable (g' K) := fun K => ENNReal.measurable_ofReal.comp (h_Z_meas K) @@ -1999,13 +2072,15 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : MeasureTheory.lintegral_liminf_le hg'_meas -- Bound: use dyadicRHS converges → bounded -- Direct bound: dyadicRHS ≤ 4 * entropyIntegral (using upstream lemma) - have h_dyadic_bdd : ∃ B : ℝ, 0 ≤ B ∧ ∀ K, 1 ≤ K → dyadicRHS_real s D (K + 1) ≤ B := by + have h_dyadic_bdd : + ∃ B : ℝ, 0 ≤ B ∧ ∀ K, 1 ≤ K → dyadicRHS_real s D (K + 1) ≤ B := by use 4 * entropyIntegral s D + 1 constructor · have h_int_nonneg := entropyIntegral_nonneg (s := s) (D := D) linarith · intro K hK - have := dyadicRHS_le_four_times_entropyIntegral hs hD (Nat.le_add_left 1 K) hfinite + have := + dyadicRHS_le_four_times_entropyIntegral hs hD (Nat.le_add_left 1 K) hfinite linarith obtain ⟨C, hC_nonneg, hC_bound⟩ := h_dyadic_bdd -- Include |∫ g| in bound since ∫ g might be negative @@ -2016,23 +2091,29 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : calc ∫ ω, Z K ω ∂μ = ∫ ω, Y K ω ∂μ - ∫ ω, g ω ∂μ := MeasureTheory.integral_sub (h_Y_int K hK) h_g_int _ ≤ ∫ ω, Y K ω ∂μ + |∫ ω, g ω ∂μ| := by linarith [neg_abs_le (∫ ω, g ω ∂μ)] - _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + |∫ ω, g ω ∂μ| := by linarith + _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + |∫ ω, g ω ∂μ| := by + linarith _ ≤ B := by simp only [B] have h1 : dyadicRHS_real s D (K + 1) ≤ C := hC_bound K hK - have h2 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ (6 * Real.sqrt 2) * σ * C := by + have h2 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ + (6 * Real.sqrt 2) * σ * C := by apply mul_le_mul_of_nonneg_left h1 positivity linarith - have h_lintegral_eq : ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ = ENNReal.ofReal (∫ ω, Z K ω ∂μ) := + have h_lintegral_eq : + ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ = ENNReal.ofReal (∫ ω, Z K ω ∂μ) := fun K hK => by have h_nonneg_K : 0 ≤ᵐ[μ] Z K := Filter.Eventually.of_forall (h_Z_nonneg K) symm - exact MeasureTheory.ofReal_integral_eq_lintegral_ofReal (h_Z_int K hK) h_nonneg_K - have h_lintegral_bound : ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ ≤ ENNReal.ofReal B := fun K hK => by + exact MeasureTheory.ofReal_integral_eq_lintegral_ofReal (h_Z_int K hK) + h_nonneg_K + have h_lintegral_bound : + ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ ≤ ENNReal.ofReal B := fun K hK => by rw [h_lintegral_eq K hK] exact ENNReal.ofReal_le_ofReal (hB_bound K hK) - have h_liminf_bound : Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := by + have h_liminf_bound : + Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := by apply Filter.liminf_le_of_le · exact ⟨0, Filter.Eventually.of_forall (fun _ => zero_le)⟩ · intro b hb @@ -2042,10 +2123,12 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have h_and := Filter.Eventually.and hb h_evt obtain ⟨K, hK_ge, hK_le⟩ := h_and.exists exact le_trans hK_ge hK_le - have h_ofReal_liminf_le : ∀ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ≤ + have h_ofReal_liminf_le : + ∀ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ≤ Filter.liminf (fun K => g' K ω) Filter.atTop := fun ω => by by_cases hcobdd : Filter.IsCoboundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) - · have h_bdd_below : Filter.IsBoundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) := + · have h_bdd_below : + Filter.IsBoundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) := Filter.isBoundedUnder_of_eventually_ge (Filter.Eventually.of_forall (fun K => h_Z_nonneg K ω)) have h_mono : Monotone ENNReal.ofReal := fun _ _ h => ENNReal.ofReal_le_ofReal h @@ -2053,8 +2136,10 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : ENNReal.continuous_ofReal.continuousAt hcobdd h_bdd_below rw [h_eq]; rfl · unfold Filter.liminf Filter.limsInf - have h_unbdd : ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by - simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] at hcobdd + have h_unbdd : ¬BddAbove + {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by + simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] + at hcobdd intro ⟨b, hb⟩; apply hcobdd; use b; intro a ha; exact hb ha rw [Real.sSup_of_not_bddAbove h_unbdd] simp only [ENNReal.ofReal_zero, zero_le] @@ -2064,9 +2149,11 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : MeasureTheory.lintegral_mono h_ofReal_liminf_le have h2 : ∫⁻ ω, Filter.liminf (fun K => g' K ω) Filter.atTop ∂μ ≤ Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop := h_fatou_enn - have h3 : Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := + have h3 : + Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := h_liminf_bound - have h_chain : ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≤ + have h_chain : + ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≤ ENNReal.ofReal B := le_trans h1 (le_trans h2 h3) rw [h_eq_top] at h_chain exact absurd (top_unique h_chain).symm ENNReal.top_ne_ofReal @@ -2089,15 +2176,18 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : rw [Filter.eventually_map, Filter.eventually_atTop] use 1 intro K hK - have h_dyadic_le := dyadicRHS_le_four_times_entropyIntegral hs hD (Nat.le_add_left 1 K) hfinite - calc ∫ ω, Y K ω ∂μ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := h_core_bound K hK + have h_dyadic_le := + dyadicRHS_le_four_times_entropyIntegral hs hD (Nat.le_add_left 1 K) hfinite + calc ∫ ω, Y K ω ∂μ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) := + h_core_bound K hK _ ≤ (6 * Real.sqrt 2) * σ * (4 * entropyIntegral s D) := by apply mul_le_mul_of_nonneg_left h_dyadic_le apply mul_nonneg (by positivity : (0:ℝ) ≤ 6 * Real.sqrt 2) (le_of_lt hσ) have h_cobdd : Filter.IsCoboundedUnder (· ≥ ·) Filter.atTop (fun K => ∫ ω, Y K ω ∂μ) := h_bdd_above.isCoboundedUnder_ge -- Rewrite the h_int_eq to use + (-c) form - have h_int_eq' : ∀ᶠ K in Filter.atTop, ∫ ω, Z K ω ∂μ = ∫ ω, Y K ω ∂μ + (-(∫ ω, g ω ∂μ)) := by + have h_int_eq' : + ∀ᶠ K in Filter.atTop, ∫ ω, Z K ω ∂μ = ∫ ω, Y K ω ∂μ + (-(∫ ω, g ω ∂μ)) := by filter_upwards [h_int_eq] with K hK linarith calc Filter.liminf (fun K => ∫ ω, Z K ω ∂μ) Filter.atTop @@ -2124,7 +2214,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : Filter.liminf (fun K => Z K ω) Filter.atTop + g ω := by filter_upwards [h_liminf_Z] with ω hω linarith - have h_int_liminf_Z : Integrable (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) μ := by + have h_int_liminf_Z : + Integrable (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) μ := by have h_meas : Measurable (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) := Measurable.liminf (fun K => h_Z_meas K) have h_nonneg_ae : 0 ≤ᵐ[μ] (fun ω => Filter.liminf (fun K => Z K ω) Filter.atTop) := by @@ -2134,11 +2225,14 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : · apply Filter.le_liminf_of_le hcobdd exact Filter.Eventually.of_forall (fun K => h_Z_nonneg K ω) · unfold Filter.liminf Filter.limsInf - have h_unbdd : ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by - simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] at hcobdd + have h_unbdd : + ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by + simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] + at hcobdd intro ⟨b, hb⟩; apply hcobdd; use b; intro a ha; exact hb ha rw [Real.sSup_of_not_bddAbove h_unbdd] - have h_lintegral_finite : ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≠ ⊤ := by + have h_lintegral_finite : + ∫⁻ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ∂μ ≠ ⊤ := by let g' : ℕ → Ω → ℝ≥0∞ := fun K ω => ENNReal.ofReal (Z K ω) have hg'_meas : ∀ K, Measurable (g' K) := fun K => ENNReal.measurable_ofReal.comp (h_Z_meas K) @@ -2161,11 +2255,13 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : calc ∫ ω, Z K ω ∂μ = ∫ ω, Y K ω ∂μ - ∫ ω, g ω ∂μ := MeasureTheory.integral_sub (h_Y_int K hK) h_g_int _ ≤ ∫ ω, Y K ω ∂μ + |∫ ω, g ω ∂μ| := by linarith [neg_abs_le (∫ ω, g ω ∂μ)] - _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + |∫ ω, g ω ∂μ| := by linarith + _ ≤ (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) + |∫ ω, g ω ∂μ| := by + linarith _ ≤ B := by simp only [B] have h1 : dyadicRHS_real s D (K + 1) ≤ C := hC_bound K hK - have h2 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ (6 * Real.sqrt 2) * σ * C := by + have h2 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ + (6 * Real.sqrt 2) * σ * C := by apply mul_le_mul_of_nonneg_left h1; positivity linarith have h_lintegral_eq : ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ = ENNReal.ofReal (∫ ω, Z K ω ∂μ) := @@ -2173,10 +2269,12 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have h_nonneg_K : 0 ≤ᵐ[μ] Z K := Filter.Eventually.of_forall (h_Z_nonneg K) symm exact MeasureTheory.ofReal_integral_eq_lintegral_ofReal (h_Z_int K hK) h_nonneg_K - have h_lintegral_bound : ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ ≤ ENNReal.ofReal B := fun K hK => by + have h_lintegral_bound : + ∀ K, 1 ≤ K → ∫⁻ ω, g' K ω ∂μ ≤ ENNReal.ofReal B := fun K hK => by rw [h_lintegral_eq K hK] exact ENNReal.ofReal_le_ofReal (hB_bound K hK) - have h_liminf_bound : Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := by + have h_liminf_bound : + Filter.liminf (fun K => ∫⁻ ω, g' K ω ∂μ) Filter.atTop ≤ ENNReal.ofReal B := by apply Filter.liminf_le_of_le · exact ⟨0, Filter.Eventually.of_forall (fun _ => zero_le)⟩ · intro b hb @@ -2186,7 +2284,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have h_and := Filter.Eventually.and hb h_evt obtain ⟨K, hK_ge, hK_le⟩ := h_and.exists exact le_trans hK_ge hK_le - have h_ofReal_liminf_le : ∀ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ≤ + have h_ofReal_liminf_le : + ∀ ω, ENNReal.ofReal (Filter.liminf (fun K => Z K ω) Filter.atTop) ≤ Filter.liminf (fun K => g' K ω) Filter.atTop := fun ω => by by_cases hcobdd : Filter.IsCoboundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) · have h_bdd_below : Filter.IsBoundedUnder (· ≥ ·) Filter.atTop (fun K => Z K ω) := @@ -2197,8 +2296,10 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : ENNReal.continuous_ofReal.continuousAt hcobdd h_bdd_below rw [h_eq]; rfl · unfold Filter.liminf Filter.limsInf - have h_unbdd : ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by - simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] at hcobdd + have h_unbdd : + ¬BddAbove {a | ∀ᶠ n in Filter.map (fun K => Z K ω) Filter.atTop, a ≤ n} := by + simp only [Filter.IsCoboundedUnder, Filter.IsCobounded, Filter.eventually_map] + at hcobdd intro ⟨b, hb⟩; apply hcobdd; use b; intro a ha; exact hb ha rw [Real.sSup_of_not_bddAbove h_unbdd] simp only [ENNReal.ofReal_zero, zero_le] @@ -2254,7 +2355,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : rw [abs_of_nonneg h_sup_nonneg] calc ⨆ n, X (t n) ω ≤ Filter.liminf (fun K => Y K ω) Filter.atTop := hω _ ≤ |Filter.liminf (fun K => Y K ω) Filter.atTop| := le_abs_self _ - _ ≤ |X (t 0) ω| + |Filter.liminf (fun K => Y K ω) Filter.atTop| := le_add_of_nonneg_left (abs_nonneg _) + _ ≤ |X (t 0) ω| + |Filter.liminf (fun K => Y K ω) Filter.atTop| := + le_add_of_nonneg_left (abs_nonneg _) · -- sup < 0 push Not at h_sup_nonneg -- |sup| = -sup ≤ -X(t 0) since X(t 0) ≤ sup @@ -2262,7 +2364,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have h_X_t0_le : X (t 0) ω ≤ ⨆ n, X (t n) ω := le_ciSup h_bdd_above 0 calc -(⨆ n, X (t n) ω) ≤ -X (t 0) ω := neg_le_neg h_X_t0_le _ ≤ |X (t 0) ω| := neg_le_abs _ - _ ≤ |X (t 0) ω| + |Filter.liminf (fun K => Y K ω) Filter.atTop| := le_add_of_nonneg_right (abs_nonneg _) + _ ≤ |X (t 0) ω| + |Filter.liminf (fun K => Y K ω) Filter.atTop| := + le_add_of_nonneg_right (abs_nonneg _) exact MeasureTheory.integral_mono_ae h_int_sup h_int_liminf h_pointwise_sup exact le_trans h_step1 h_fatou_Y @@ -2305,7 +2408,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : have hδ_pos' : 0 < δ := hδ_pos K have hδ_le_D : δ ≤ D := by simp only [δ] - have h1 : (2 : ℝ) ^ (-((K + 1) : ℤ)) ≤ 1 := zpow_le_one_of_nonpos₀ (by norm_num) (by linarith) + have h1 : (2 : ℝ) ^ (-((K + 1) : ℤ)) ≤ 1 := + zpow_le_one_of_nonpos₀ (by norm_num) (by linarith) calc D * (2 : ℝ) ^ (-((K + 1) : ℤ)) ≤ D * 1 := mul_le_mul_of_nonneg_left h1 (le_of_lt hD) _ = D := mul_one D -- The gap equals the integral over (0, δ] @@ -2382,7 +2486,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : -- Upper bound: dyadicRHS ≤ 2*entropyIntegral + 2*δf(δ) have h_dyadic_upper : ∀ K, 1 ≤ K → dyadicRHS_real s D (K + 1) ≤ - 2 * entropyIntegral s D + 2 * (D * 2^(-((K+1) : ℤ))) * sqrtEntropy (D * 2^(-((K+1) : ℤ))) s := by + 2 * entropyIntegral s D + + 2 * (D * 2^(-((K+1) : ℤ))) * sqrtEntropy (D * 2^(-((K+1) : ℤ))) s := by intro K hK have h1 := dyadicRHS_le_twice_entropyIntegralTrunc_add_tail hs hD (Nat.le_add_left 1 K) have h2 := entropyIntegralTrunc_le_entropyIntegral hD (K + 1) hfinite @@ -2395,7 +2500,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : linarith -- (11√2)σ * dyadicRHS is bounded above (needed for IsCoboundedUnder) - have h_rhs_bounded_above : ∃ B : ℝ, ∀ K, 1 ≤ K → (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ B := by + have h_rhs_bounded_above : + ∃ B : ℝ, ∀ K, 1 ≤ K → (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ B := by use (6 * Real.sqrt 2) * σ * (4 * entropyIntegral s D) intro K hK have h_le := dyadicRHS_le_four_times_entropyIntegral hs hD (Nat.le_add_left 1 K) hfinite @@ -2415,12 +2521,14 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : obtain ⟨N, hN⟩ := ha -- At K = max N 1, we have both: function(K) ≥ a and function(K) ≤ B have hK : max N 1 ≥ 1 := le_max_right N 1 - have h1 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (max N 1 + 1) ≥ a := hN (max N 1) (le_max_left N 1) + have h1 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (max N 1 + 1) ≥ a := + hN (max N 1) (le_max_left N 1) have h2 : (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (max N 1 + 1) ≤ B := hB (max N 1) hK linarith -- Upper bound on liminf: liminf((6√2)σ*dyadicRHS) ≤ (12√2)σ*entropyIntegral - have h_liminf_upper : Filter.liminf (fun K => (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1)) Filter.atTop + have h_liminf_upper : + Filter.liminf (fun K => (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1)) Filter.atTop ≤ (12 * Real.sqrt 2) * σ * entropyIntegral s D := by -- For each K: (6√2)σ*dyadicRHS ≤ (12√2)σ*entropyIntegral + (12√2)σ*tail(K) have h_upper_with_tail : ∀ K, 1 ≤ K → (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1) ≤ @@ -2434,11 +2542,13 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : apply mul_le_mul_of_nonneg_left h apply mul_nonneg (by positivity : (0:ℝ) ≤ 6 * Real.sqrt 2) (le_of_lt hσ) _ = (12 * Real.sqrt 2) * σ * entropyIntegral s D + - (12 * Real.sqrt 2) * σ * (D * 2^(-((K+1) : ℤ))) * sqrtEntropy (D * 2^(-((K+1) : ℤ))) s := by ring + (12 * Real.sqrt 2) * σ * (D * 2^(-((K+1) : ℤ))) * + sqrtEntropy (D * 2^(-((K+1) : ℤ))) s := by ring -- The tail tends to 0, so liminf(tail) = 0 have h_tail_tendsto_scaled : Filter.Tendsto - (fun K : ℕ => (12 * Real.sqrt 2) * σ * (D * (2 : ℝ)^(-(↑K + 1 : ℤ))) * sqrtEntropy (D * (2 : ℝ)^(-(↑K + 1 : ℤ))) s) + (fun K : ℕ => (12 * Real.sqrt 2) * σ * (D * (2 : ℝ)^(-(↑K + 1 : ℤ))) * + sqrtEntropy (D * (2 : ℝ)^(-(↑K + 1 : ℤ))) s) Filter.atTop (nhds 0) := by have h := h_tail_tendsto.const_mul ((6 * Real.sqrt 2) * σ) simp only [mul_zero] at h @@ -2457,7 +2567,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : simp only [add_zero] at h_sum exact h_sum - have h_liminf_eq : Filter.liminf g Filter.atTop = (12 * Real.sqrt 2) * σ * entropyIntegral s D := + have h_liminf_eq : + Filter.liminf g Filter.atTop = (12 * Real.sqrt 2) * σ * entropyIntegral s D := h_const_plus_vanishing.liminf_eq -- (6√2)σ * dyadicRHS is bounded below by 0 @@ -2517,7 +2628,8 @@ theorem dudley_chaining_bound_countable {Ω : Type u} [MeasurableSpace Ω] {A : calc ∫ ω, ⨆ n, X (t n) ω ∂μ _ ≤ Filter.liminf (fun K => ∫ ω, Y K ω ∂μ) Filter.atTop := h_fatou - _ ≤ Filter.liminf (fun K => (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1)) Filter.atTop := by + _ ≤ Filter.liminf (fun K => (6 * Real.sqrt 2) * σ * dyadicRHS_real s D (K + 1)) + Filter.atTop := by apply Filter.liminf_le_liminf · filter_upwards [Filter.eventually_ge_atTop 1] with K hK exact h_core_bound K hK diff --git a/StatsMLlib/Probability/Process/FiniteMaximum.lean b/StatsMLlib/Probability/Process/FiniteMaximum.lean index 05f861d..4f9e242 100644 --- a/StatsMLlib/Probability/Process/FiniteMaximum.lean +++ b/StatsMLlib/Probability/Process/FiniteMaximum.lean @@ -131,7 +131,8 @@ theorem expected_max_subGaussian {ι : Type*} have h1 : (sqrt (2 * log n) / σ)^2 = (2 * log n) / σ^2 := by rw [div_pow, sq_sqrt (by positivity : 0 ≤ 2 * log n)] calc (1 / (sqrt (2 * log n) / σ)) * (log n + (sqrt (2 * log n) / σ)^2 * σ^2 / 2) - _ = (σ / sqrt (2 * log n)) * (log n + (2 * log n) / σ^2 * σ^2 / 2) := by rw [one_div, inv_div, h1] + _ = (σ / sqrt (2 * log n)) * (log n + (2 * log n) / σ^2 * σ^2 / 2) := by + rw [one_div, inv_div, h1] _ = (σ / sqrt (2 * log n)) * (log n + log n) := by congr 1 field_simp @@ -178,7 +179,8 @@ theorem expected_max_subGaussian {ι : Type*} · exact ae_of_all μ (fun ω => (exp_pos _).le) · exact hsum_int · exact ae_of_all μ (fun ω => exp_mul_sup'_le_sum hs (fun i => X i ω) t_opt) - _ = ∑ i ∈ s, ∫ ω, exp (t_opt * X i ω) ∂μ := integral_finsetSum s (fun i hi => hX_int_exp i hi t_opt) + _ = ∑ i ∈ s, ∫ ω, exp (t_opt * X i ω) ∂μ := + integral_finsetSum s (fun i hi => hX_int_exp i hi t_opt) _ ≤ ∑ i ∈ s, exp (t_opt^2 * σ^2 / 2) := Finset.sum_le_sum (fun i hi => hMGF_bound i hi) _ = n * exp (t_opt^2 * σ^2 / 2) := by simp [Finset.sum_const, hn_def] diff --git a/StatsMLlib/Probability/Process/SubGaussian.lean b/StatsMLlib/Probability/Process/SubGaussian.lean index 850c09f..bfdecb5 100644 --- a/StatsMLlib/Probability/Process/SubGaussian.lean +++ b/StatsMLlib/Probability/Process/SubGaussian.lean @@ -202,8 +202,7 @@ lemma IsSubGaussian.integrable {Ω : Type*} [MeasurableSpace Ω] obtain ⟨_, h_mgf⟩ := h_sg have h_exp_pos := h_mgf.integrable_exp_mul 1 have h_exp_neg := h_mgf.integrable_exp_mul (-1) - refine' Integrable.mono' _ _ _ - · exact fun ω => Real.exp (X ω) + Real.exp (-X ω) + refine Integrable.mono' (g := fun ω => Real.exp (X ω) + Real.exp (-X ω)) ?_ ?_ ?_ · exact Integrable.add (by simpa using h_exp_pos) (by simpa using h_exp_neg) · exact h_mgf.aestronglyMeasurable · filter_upwards [] with ω using @@ -221,18 +220,17 @@ lemma integrable_ciSup_of_fintype {Ω : Type*} [MeasurableSpace Ω] {Y : ι → Ω → ℝ} {μ : Measure Ω} (h_int : ∀ i, Integrable (Y i) μ) : Integrable (fun x => ⨆ i, Y i x) μ := by - refine' Integrable.mono' _ _ _ - · exact fun x => ∑ i, |Y i x| + refine Integrable.mono' (g := fun x => ∑ i, |Y i x|) ?_ ?_ ?_ · exact integrable_finsetSum _ fun i _ => (h_int i).abs · have h_aesm : ∀ i, AEStronglyMeasurable (fun x => Y i x) μ := fun i => (h_int i).aestronglyMeasurable choose g hg using h_aesm - refine' ⟨fun x => ⨆ i, g i x, ?_, ?_⟩ + refine ⟨fun x => ⨆ i, g i x, ?_, ?_⟩ · exact (Measurable.iSup fun i => (hg i).1.measurable).stronglyMeasurable · filter_upwards [ae_all_iff.2 fun i => (hg i).2] with x hx using by simp +decide [hx] · filter_upwards [] with x - refine' abs_le.mpr ⟨?_, ?_⟩ + refine abs_le.mpr ⟨?_, ?_⟩ · exact le_trans (neg_le_neg (Finset.single_le_sum (fun i _ => abs_nonneg (Y i x)) @@ -333,7 +331,8 @@ theorem subGaussian_tail_bound_one_sided {μ : Measure Ω} [IsProbabilityMeasure have h_sgb : ∀ l : ℝ, cgf (fun ω => X s ω - X t ω) μ l ≤ l^2 * (σ * dist s t)^2 / 2 := by intro l unfold cgf mgf - have h_mgf_bound : μ[fun ω => exp (l * (X s ω - X t ω))] ≤ exp (l^2 * (σ * dist s t)^2 / 2) := by + have h_mgf_bound : + μ[fun ω => exp (l * (X s ω - X t ω))] ≤ exp (l^2 * (σ * dist s t)^2 / 2) := by calc μ[fun ω => exp (l * (X s ω - X t ω))] _ ≤ exp (l^2 * σ^2 * (dist s t)^2 / 2) := hX s t l _ = exp (l^2 * (σ * dist s t)^2 / 2) := by ring_nf @@ -490,7 +489,8 @@ lemma ae_eq_zero_of_mgf_le_one {μ : Measure Ω} [IsProbabilityMeasure μ] rw [ae_iff] have h_neg_mgf : ∀ l : ℝ, μ[fun ω => exp (l * (-Y ω))] ≤ 1 := fun l => by convert hY_mgf (-l) using 2; ext ω; ring_nf - have h_neg_int_exp_pos : ∀ l : ℝ, 0 < l → Integrable (fun ω => exp (l * (-Y ω))) μ := fun l hl => by + have h_neg_int_exp_pos : + ∀ l : ℝ, 0 < l → Integrable (fun ω => exp (l * (-Y ω))) μ := fun l hl => by have h_neg_l : -l < 0 := by linarith convert hY_int_exp_neg (-l) h_neg_l using 1; ext ω; ring_nf have h_tail_zero_neg : ∀ ε : ℝ, 0 < ε → μ {ω | -Y ω > ε} = 0 := fun ε hε => by @@ -500,7 +500,8 @@ lemma ae_eq_zero_of_mgf_le_one {μ : Measure Ω} [IsProbabilityMeasure μ] (μ := μ) (f := fun ω => exp ((k + 1 : ℝ) * (-Y ω))) (ae_of_all μ (fun _ => (exp_pos _).le)) (h_neg_int_exp_pos (k + 1) hk1) (exp ((k + 1 : ℝ) * ε)) - have h_subset : {ω | -Y ω > ε} ⊆ {ω | exp ((k + 1 : ℝ) * ε) ≤ exp ((k + 1 : ℝ) * (-Y ω))} := by + have h_subset : + {ω | -Y ω > ε} ⊆ {ω | exp ((k + 1 : ℝ) * ε) ≤ exp ((k + 1 : ℝ) * (-Y ω))} := by intro ω hω simp only [mem_ofPred_eq] at hω ⊢ exact exp_le_exp.mpr (mul_lt_mul_of_pos_left hω hk1).le @@ -608,7 +609,8 @@ theorem subGaussian_first_moment_bound {μ : Measure Ω} [IsProbabilityMeasure convert h using 3 field_simp; ring have h_abs_nonneg : 0 ≤ᵐ[μ] (fun ω => |Y ω|) := ae_of_all μ (fun _ => abs_nonneg _) - have h_abs_meas : AEStronglyMeasurable (fun ω => |Y ω|) μ := h_int_abs.aestronglyMeasurable + have h_abs_meas : AEStronglyMeasurable (fun ω => |Y ω|) μ := + h_int_abs.aestronglyMeasurable have h_abs_aemeas : AEMeasurable (fun ω => |Y ω|) μ := h_abs_meas.aemeasurable rw [integral_eq_lintegral_of_nonneg_ae h_abs_nonneg h_abs_meas] rw [lintegral_eq_lintegral_tail h_abs_aemeas h_abs_nonneg] @@ -623,15 +625,19 @@ theorem subGaussian_first_moment_bound {μ : Measure Ω} [IsProbabilityMeasure apply MeasureTheory.lintegral_mono_ae filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht exact h_tail_ennreal t (Set.mem_Ioi.mp ht) - have h_gaussian_integrable : Integrable (fun t => 2 * exp (-t^2 / (2 * τ^2))) (volume.restrict (Ioi (0 : ℝ))) := by + have h_gaussian_integrable : + Integrable (fun t => 2 * exp (-t^2 / (2 * τ^2))) (volume.restrict (Ioi (0 : ℝ))) := by apply Integrable.const_mul - have h_form : (fun t : ℝ => exp (-t^2 / (2 * τ^2))) = (fun t : ℝ => exp (-(1/(2*τ^2)) * t^2)) := by + have h_form : (fun t : ℝ => exp (-t^2 / (2 * τ^2))) = + (fun t : ℝ => exp (-(1/(2*τ^2)) * t^2)) := by ext t; congr 1; field_simp rw [h_form] exact integrableOn_Ioi_exp_neg_mul_sq_iff.mpr (by positivity : 0 < 1 / (2 * τ^2)) - have h_gaussian_nonneg : 0 ≤ᵐ[volume.restrict (Ioi (0 : ℝ))] (fun t => 2 * exp (-t^2 / (2 * τ^2))) := + have h_gaussian_nonneg : + 0 ≤ᵐ[volume.restrict (Ioi (0 : ℝ))] (fun t => 2 * exp (-t^2 / (2 * τ^2))) := ae_of_all _ (fun _ => by positivity) - have h_ofReal_lintegral : ∫⁻ t in Ioi (0 : ℝ), ENNReal.ofReal (2 * exp (-t^2 / (2 * τ^2))) = + have h_ofReal_lintegral : + ∫⁻ t in Ioi (0 : ℝ), ENNReal.ofReal (2 * exp (-t^2 / (2 * τ^2))) = ENNReal.ofReal (∫ t in Ioi (0 : ℝ), 2 * exp (-t^2 / (2 * τ^2))) := by rw [← ofReal_integral_eq_lintegral_ofReal h_gaussian_integrable h_gaussian_nonneg] rw [h_ofReal_lintegral] at h_lintegral_bound @@ -785,7 +791,8 @@ theorem subGaussian_finite_max_bound' {μ : Measure Ω} [IsProbabilityMeasure μ exact hω exact T.eventually_all.mpr (fun t ht => h_ae_forall t ht) -- biSup = sup' for nonempty finite set - have h_biSup : ∀ ω, ⨆ t ∈ T, (X t ω - X t₀ ω) = T.sup' hT_ne (fun t => X t ω - X t₀ ω) := + have h_biSup : + ∀ ω, ⨆ t ∈ T, (X t ω - X t₀ ω) = T.sup' hT_ne (fun t => X t ω - X t₀ ω) := fun ω => biSup_eq_sup'_of_finset hT_ne _ ⟨t₀, ht₀, by simp only [sub_self, le_refl]⟩ have h_sup_ae : (fun ω => ⨆ t ∈ T, (X t ω - X t₀ ω)) =ᵐ[μ] (fun _ => 0) := by filter_upwards [h_all_ae] with ω h_all diff --git a/StatsMLlib/Probability/Process/TruncatedDudley.lean b/StatsMLlib/Probability/Process/TruncatedDudley.lean index 679d9d4..8f30a98 100644 --- a/StatsMLlib/Probability/Process/TruncatedDudley.lean +++ b/StatsMLlib/Probability/Process/TruncatedDudley.lean @@ -76,10 +76,12 @@ lemma one_step_discretization_bound globalOsc X T ≤ 2 * localOsc X T δ + 2 * (⨆ u ∈ U, |X u - X u₀|) := by by_contra h_contra; - obtain ⟨θ, θ', hθθ', h_ineq⟩ : ∃ θ θ', θ ∈ T ∧ θ' ∈ T ∧ X θ - X θ' > 2 * localOsc X T δ + 2 * ⨆ u ∈ U, |X u - X u₀| := by + obtain ⟨θ, θ', hθθ', h_ineq⟩ : ∃ θ θ', θ ∈ T ∧ θ' ∈ T ∧ X θ - X θ' > 2 * localOsc X T δ + 2 * + ⨆ u ∈ U, |X u - X u₀| := by simp +zetaDelta at *; convert exists_lt_of_lt_csSup _ h_contra using 1; - · exact ⟨ fun ⟨ θ, hθ, x, hx, h ⟩ => ⟨ _, ⟨ θ, hθ, x, hx, rfl ⟩, h ⟩, by rintro ⟨ a, ⟨ θ, hθ, x, hx, rfl ⟩, h ⟩ ; exact ⟨ θ, hθ, x, hx, h ⟩ ⟩; + · exact ⟨ fun ⟨ θ, hθ, x, hx, h ⟩ => ⟨ _, ⟨ θ, hθ, x, hx, rfl ⟩, h ⟩, + by rintro ⟨ a, ⟨ θ, hθ, x, hx, rfl ⟩, h ⟩ ; exact ⟨ θ, hθ, x, hx, h ⟩ ⟩; · exact ⟨ _, ⟨ u₀, hU_subset hu₀, u₀, hU_subset hu₀, rfl ⟩ ⟩; obtain ⟨πθ, hπθ⟩ : ∃ πθ ∈ U, dist θ πθ ≤ δ := by @@ -90,34 +92,54 @@ lemma one_step_discretization_bound have h_triangle : X θ - X θ' ≤ (X θ - X πθ) + (X πθ - X πθ') + (X πθ' - X θ') := by linarith have h_local_osc : X θ - X πθ ≤ localOsc X T δ ∧ X πθ' - X θ' ≤ localOsc X T δ := by - refine' ⟨ le_csSup _ _, le_csSup _ _ ⟩; - · by_cases h_bdd : BddAbove (Set.image (fun p : α × α => X p.1 - X p.2) {p : α × α | p.1 ∈ T ∧ p.2 ∈ T ∧ dist p.1 p.2 ≤ δ}); - · exact ⟨ h_bdd.choose, by rintro x ⟨ y, hy, z, hz, h, rfl ⟩ ; exact h_bdd.choose_spec ⟨ ( y, z ), ⟨ hy, hz, h ⟩, rfl ⟩ ⟩; + refine ⟨ le_csSup ?_ ?_, le_csSup ?_ ?_ ⟩; + · by_cases h_bdd : + BddAbove (Set.image (fun p : α × α => X p.1 - X p.2) {p : α × α | p.1 ∈ T ∧ p.2 ∈ T ∧ + dist p.1 p.2 ≤ δ}); + · exact + ⟨ h_bdd.choose, + by rintro x ⟨ y, hy, z, hz, h, rfl ⟩ ; exact h_bdd.choose_spec ⟨ ( y, z ), ⟨ hy, hz, h ⟩, + rfl ⟩ ⟩; · unfold globalOsc localOsc at h_contra; rw [ Real.sSup_of_not_bddAbove ] at h_contra; · rw [ Real.sSup_of_not_bddAbove ] at h_contra; - · exact False.elim <| h_contra <| add_nonneg ( mul_nonneg zero_le_two <| by norm_num ) <| mul_nonneg zero_le_two <| Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _; - · exact fun ⟨ M, hM ⟩ => h_bdd ⟨ M, Set.forall_mem_image.2 fun p hp => hM ⟨ p.1, hp.1, p.2, hp.2.1, hp.2.2, rfl ⟩ ⟩; + · exact False.elim <| h_contra <| + add_nonneg ( mul_nonneg zero_le_two <| by norm_num ) <| mul_nonneg zero_le_two <| + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _; + · exact fun ⟨ M, hM ⟩ => + h_bdd ⟨ M, Set.forall_mem_image.2 fun p hp => + hM ⟨ p.1, hp.1, p.2, hp.2.1, hp.2.2, rfl ⟩ ⟩; · rintro ⟨M, hM⟩ exact h_bdd ⟨M, Set.forall_mem_image.2 fun p hp => hM ⟨p.1, hp.1, p.2, hp.2.1, rfl⟩⟩ · exact ⟨ θ, hθθ', πθ, hU_subset hπθ.1, hπθ.2, rfl ⟩; - · by_cases h_bdd : BddAbove (Set.image (fun p : α × α => X p.1 - X p.2) {p : α × α | p.1 ∈ T ∧ p.2 ∈ T ∧ dist p.1 p.2 ≤ δ}); - · exact ⟨ h_bdd.choose, by rintro x ⟨ y, hy, z, hz, h, rfl ⟩ ; exact h_bdd.choose_spec ⟨ ( y, z ), ⟨ hy, hz, h ⟩, rfl ⟩ ⟩; + · by_cases h_bdd : + BddAbove (Set.image (fun p : α × α => X p.1 - X p.2) {p : α × α | p.1 ∈ T ∧ p.2 ∈ T ∧ + dist p.1 p.2 ≤ δ}); + · exact + ⟨ h_bdd.choose, + by rintro x ⟨ y, hy, z, hz, h, rfl ⟩ ; exact h_bdd.choose_spec ⟨ ( y, z ), ⟨ hy, hz, h ⟩, + rfl ⟩ ⟩; · unfold globalOsc localOsc at h_contra; rw [ Real.sSup_of_not_bddAbove ] at h_contra; · rw [ Real.sSup_of_not_bddAbove ] at h_contra; - · exact False.elim <| h_contra <| add_nonneg ( mul_nonneg zero_le_two <| by norm_num ) <| mul_nonneg zero_le_two <| Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _; - · exact fun ⟨ M, hM ⟩ => h_bdd ⟨ M, Set.forall_mem_image.2 fun p hp => hM ⟨ p.1, hp.1, p.2, hp.2.1, hp.2.2, rfl ⟩ ⟩; + · exact False.elim <| h_contra <| + add_nonneg ( mul_nonneg zero_le_two <| by norm_num ) <| mul_nonneg zero_le_two <| + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _; + · exact fun ⟨ M, hM ⟩ => + h_bdd ⟨ M, Set.forall_mem_image.2 fun p hp => + hM ⟨ p.1, hp.1, p.2, hp.2.1, hp.2.2, rfl ⟩ ⟩; · rintro ⟨M, hM⟩ exact h_bdd ⟨M, Set.forall_mem_image.2 fun p hp => hM ⟨p.1, hp.1, p.2, hp.2.1, rfl⟩⟩ · exact ⟨ πθ', hU_subset hπθ'.1, θ', h_ineq.1, by simpa [ dist_comm ] using hπθ'.2, rfl ⟩ have h_max_abs : X πθ - X πθ' ≤ 2 * ⨆ u ∈ U, |X u - X u₀| := by - have h_max_abs : |X πθ - X u₀| ≤ ⨆ u ∈ U, |X u - X u₀| ∧ |X πθ' - X u₀| ≤ ⨆ u ∈ U, |X u - X u₀| := by + have h_max_abs : |X πθ - X u₀| ≤ ⨆ u ∈ U, |X u - X u₀| ∧ |X πθ' - X u₀| ≤ ⨆ u ∈ U, |X u - + X u₀| := by have h_bdd_abs : BddAbove (Set.range fun u : α => ⨆ (_ : u ∈ U), |X u - X u₀|) := by refine ⟨∑ u ∈ hU_fin.toFinset, |X u - X u₀|, Set.forall_mem_range.2 fun u => ?_⟩ rw [@ciSup_eq_ite] split_ifs with hu - · exact Finset.single_le_sum (fun u _ => abs_nonneg (X u - X u₀)) (hU_fin.mem_toFinset.mpr hu) + · exact Finset.single_le_sum (fun u _ => abs_nonneg (X u - X u₀)) + (hU_fin.mem_toFinset.mpr hu) · exact le_trans (by norm_num) (Finset.sum_nonneg fun u _ => abs_nonneg (X u - X u₀)) have h_mem_sup (u : α) (hu : u ∈ U) : |X u - X u₀| ≤ ⨆ (_ : u ∈ U), |X u - X u₀| := by exact le_ciSup ⟨|X u - X u₀|, Set.forall_mem_range.2 fun _ => le_rfl⟩ hu @@ -146,9 +168,9 @@ lemma mgf_max_bound {α : Type*} [MeasurableSpace α] have h_max_exp_bound : ∫ x, Real.exp (t * ⨆ k, Y k x) ∂μ ≤ ∑ k, ∫ x, Real.exp (t * Y k x) ∂μ := by rw [ ← MeasureTheory.integral_finsetSum ]; - · refine' MeasureTheory.integral_mono_of_nonneg _ _ _; + · refine MeasureTheory.integral_mono_of_nonneg ?_ ?_ ?_; · exact Filter.Eventually.of_forall fun x => Real.exp_nonneg _; - · refine' MeasureTheory.integrable_finsetSum _ fun i _ => _; + · refine MeasureTheory.integrable_finsetSum _ fun i _ => ?_; exact sub_gaussian_integrable (h_sg i) t; · filter_upwards [ ] with x; @@ -158,7 +180,9 @@ lemma mgf_max_bound {α : Type*} [MeasurableSpace α] (IsCompact.sSup_mem (isCompact_range <| show Continuous fun k => Y k x from by continuity) (Set.nonempty_of_mem <| Set.mem_range_self ⟨0, hM⟩)) - exact le_trans ( by rw [ ← h_max.choose_spec ] ) ( Finset.single_le_sum ( fun k _ => Real.exp_nonneg ( t * Y k x ) ) ( Finset.mem_univ _ ) ); + exact le_trans ( by rw [ ← h_max.choose_spec ] ) + ( Finset.single_le_sum ( fun k _ => Real.exp_nonneg ( t * Y k x ) ) + ( Finset.mem_univ _ ) ); exact h_max_exp; · exact fun k _ => sub_gaussian_integrable ( h_sg k ) t; @@ -193,29 +217,38 @@ lemma metric_entropy_bound_for_sub_gaussian_maxima have h_max_bound : ∀ t > 0, ∫ x, (⨆ k, Y k x) ∂μ ≤ (Real.log M) / t + σ_sq * t / 2 := by intro t ht - have h_jensen : Real.exp (t * (∫ x, (⨆ k, Y k x) ∂μ)) ≤ ∫ x, Real.exp (t * (⨆ k, Y k x)) ∂μ := by + have h_jensen : Real.exp (t * (∫ x, (⨆ k, Y k x) ∂μ)) ≤ ∫ x, + Real.exp (t * (⨆ k, Y k x)) ∂μ := by by_cases h_integrable : MeasureTheory.Integrable (fun x => ⨆ k, Y k x) μ; · have h_jensen : ConvexOn ℝ (Set.univ : Set ℝ) Real.exp := by exact convexOn_exp; - have h_jensen : Real.exp (∫ x, t * (⨆ k, Y k x) ∂μ) ≤ ∫ x, Real.exp (t * (⨆ k, Y k x)) ∂μ := by + have h_jensen : Real.exp (∫ x, t * (⨆ k, Y k x) ∂μ) ≤ ∫ x, + Real.exp (t * (⨆ k, Y k x)) ∂μ := by apply_rules [ h_jensen.map_integral_le ]; · exact Real.continuousOn_exp; · exact isClosed_univ; · exact Filter.Eventually.of_forall fun x => Set.mem_univ _; · exact h_integrable.const_mul t; - · have h_integrable_exp : ∀ k, MeasureTheory.Integrable (fun x => Real.exp (t * Y k x)) μ := by + · have h_integrable_exp : ∀ k, + MeasureTheory.Integrable (fun x => Real.exp (t * Y k x)) μ := by exact fun k => sub_gaussian_integrable (h_sg k) t; - refine' MeasureTheory.Integrable.mono' ( MeasureTheory.integrable_finsetSum _ fun k _ => h_integrable_exp k ) _ _; - exact Finset.univ; - · exact Real.continuous_exp.comp_aestronglyMeasurable ( h_integrable.aestronglyMeasurable.const_mul _ ); + refine MeasureTheory.Integrable.mono' + ( MeasureTheory.integrable_finsetSum Finset.univ fun k _ => + h_integrable_exp k ) ?_ ?_; + · exact Real.continuous_exp.comp_aestronglyMeasurable + ( h_integrable.aestronglyMeasurable.const_mul _ ); · filter_upwards [ ] with x; rcases M with ( _ | _ | M ) <;> simp_all +decide [ Fin.sum_univ_succ ]; - have h_exp_sup : Real.exp (t * ⨆ k, Y k x) ≤ ∑ k : Fin (M + 2), Real.exp (t * Y k x) := by + have h_exp_sup : Real.exp (t * ⨆ k, Y k x) ≤ ∑ k : Fin (M + 2), + Real.exp (t * Y k x) := by have h_exp_sup : ∃ k, Y k x = ⨆ k, Y k x := by exact exists_eq_ciSup_of_finite; - exact le_trans ( by rw [ ← h_exp_sup.choose_spec ] ) ( Finset.single_le_sum ( fun k _ => Real.exp_nonneg ( t * Y k x ) ) ( Finset.mem_univ _ ) ); - exact h_exp_sup.trans_eq ( by rw [ Fin.sum_univ_succ, Fin.sum_univ_succ ] ; simp +decide ); + exact le_trans ( by rw [ ← h_exp_sup.choose_spec ] ) + ( Finset.single_le_sum ( fun k _ => Real.exp_nonneg ( t * Y k x ) ) + ( Finset.mem_univ _ ) ); + exact h_exp_sup.trans_eq + ( by rw [ Fin.sum_univ_succ, Fin.sum_univ_succ ] ; simp +decide ); simpa only [ MeasureTheory.integral_const_mul ] using h_jensen; · have h_integrable : ∀ k, MeasureTheory.Integrable (fun x => Y k x) μ := by intro k @@ -224,52 +257,80 @@ lemma metric_entropy_bound_for_sub_gaussian_maxima have h_integrable : MeasureTheory.Integrable (fun x => Y k x) μ := by have := h_mgf.integrable_exp_mul; have := this 1; - refine' MeasureTheory.Integrable.mono' _ _ _; - exact fun ω => Real.exp ( Y k ω ) + Real.exp ( -Y k ω ); - · exact MeasureTheory.Integrable.add ( by simpa using this ) ( by simpa using ‹∀ t : ℝ, MeasureTheory.Integrable ( fun ω => Real.exp ( t * Y k ω ) ) μ› ( -1 ) ); + refine MeasureTheory.Integrable.mono' + (g := fun ω => Real.exp ( Y k ω ) + Real.exp ( -Y k ω )) ?_ ?_ ?_; + · exact MeasureTheory.Integrable.add ( by simpa using this ) ( by + simpa using ‹∀ t : ℝ, MeasureTheory.Integrable + ( fun ω => Real.exp ( t * Y k ω ) ) μ› ( -1 ) ); · have := h_mgf.aestronglyMeasurable; exact this; - · filter_upwards [ ] with ω using abs_le.mpr ⟨ by linarith [ Real.add_one_le_exp ( Y k ω ), Real.add_one_le_exp ( -Y k ω ), Real.exp_pos ( Y k ω ), Real.exp_pos ( -Y k ω ) ], by linarith [ Real.add_one_le_exp ( Y k ω ), Real.add_one_le_exp ( -Y k ω ), Real.exp_pos ( Y k ω ), Real.exp_pos ( -Y k ω ) ] ⟩ + · filter_upwards [ ] with ω using abs_le.mpr + ⟨ by linarith [ Real.add_one_le_exp ( Y k ω ), Real.add_one_le_exp ( -Y k ω ), + Real.exp_pos ( Y k ω ), Real.exp_pos ( -Y k ω ) ], + by linarith [ Real.add_one_le_exp ( Y k ω ), Real.add_one_le_exp ( -Y k ω ), + Real.exp_pos ( Y k ω ), Real.exp_pos ( -Y k ω ) ] ⟩ exact h_integrable; have h_integrable : MeasureTheory.Integrable (fun x => ⨆ k, Y k x) μ := by - refine' MeasureTheory.Integrable.mono' _ _ _; - refine' fun x => ∑ k, |Y k x|; - · exact MeasureTheory.integrable_finsetSum _ fun k _ => MeasureTheory.Integrable.abs ( h_integrable k ); + refine MeasureTheory.Integrable.mono' (g := fun x => ∑ k, |Y k x|) ?_ ?_ ?_; + · exact MeasureTheory.integrable_finsetSum _ fun k _ => + MeasureTheory.Integrable.abs ( h_integrable k ); · have h_integrable : ∀ k, MeasureTheory.AEStronglyMeasurable (fun x => Y k x) μ := by exact fun k => ( h_integrable k |> MeasureTheory.Integrable.aestronglyMeasurable ); - have h_integrable : ∀ {f : Fin M → α → ℝ}, (∀ k, MeasureTheory.AEStronglyMeasurable (fun x => f k x) μ) → MeasureTheory.AEStronglyMeasurable (fun x => ⨆ k, f k x) μ := by + have h_integrable : ∀ {f : Fin M → α → ℝ}, + (∀ k, MeasureTheory.AEStronglyMeasurable (fun x => f k x) μ) → + MeasureTheory.AEStronglyMeasurable (fun x => ⨆ k, f k x) μ := by intro f hf; choose g hg using hf; - refine' ⟨ fun x => ⨆ k, g k x, _, _ ⟩; + refine ⟨ fun x => ⨆ k, g k x, ?_, ?_ ⟩; · exact (Measurable.iSup fun k => (hg k).1.measurable).stronglyMeasurable; - · filter_upwards [ MeasureTheory.ae_all_iff.2 fun k => hg k |>.2 ] with x hx using by simp +decide [ hx ] ; + · filter_upwards [ MeasureTheory.ae_all_iff.2 fun k => + hg k |>.2 ] with x hx using by simp +decide [ hx ] ; exact h_integrable ‹_›; · filter_upwards [ ] with x; - refine' abs_le.mpr ⟨ _, _ ⟩; - · exact le_trans ( neg_le_neg ( Finset.single_le_sum ( fun k _ => abs_nonneg ( Y k x ) ) ( Finset.mem_univ ⟨ 0, hM ⟩ ) ) ) ( le_trans ( neg_le_of_abs_le ( by simp +decide ) ) ( le_ciSup ( Finite.bddAbove_range fun k => Y k x ) ⟨ 0, hM ⟩ ) ); - · convert ciSup_le fun k => show Y k x ≤ ∑ k, |Y k x| from le_trans ( le_abs_self _ ) ( Finset.single_le_sum ( fun a _ => abs_nonneg ( Y a x ) ) ( Finset.mem_univ k ) ) using 1; + refine abs_le.mpr ⟨ ?_, ?_ ⟩; + · exact le_trans + ( neg_le_neg ( Finset.single_le_sum ( fun k _ => abs_nonneg ( Y k x ) ) + ( Finset.mem_univ ⟨ 0, hM ⟩ ) ) ) + ( le_trans ( neg_le_of_abs_le ( by simp +decide ) ) + ( le_ciSup ( Finite.bddAbove_range fun k => Y k x ) ⟨ 0, hM ⟩ ) ); + · convert ciSup_le fun k => show Y k x ≤ ∑ k, |Y k x| from + le_trans ( le_abs_self _ ) + ( Finset.single_le_sum ( fun a _ => abs_nonneg ( Y a x ) ) ( Finset.mem_univ k ) ) + using 1; exact ⟨ ⟨ 0, hM ⟩ ⟩; contradiction; have h_mgf_bound : ∫ x, Real.exp (t * (⨆ k, Y k x)) ∂μ ≤ M * Real.exp (σ_sq * t^2 / 2) := by convert mgf_max_bound hM h_sg t using 1; have := Real.log_le_log ( by positivity ) ( h_jensen.trans h_mgf_bound ); - rw [ Real.log_mul ( by positivity ) ( by positivity ), Real.log_exp, Real.log_exp ] at this ; rw [ div_add_div, le_div_iff₀ ] <;> nlinarith; + rw [ Real.log_mul ( by positivity ) ( by positivity ), Real.log_exp, + Real.log_exp ] at this ; rw [ div_add_div, le_div_iff₀ ] <;> nlinarith; by_cases hσ_pos : 0 < σ_sq; · by_cases hM_one : M = 1 <;> simp_all +decide [ div_eq_mul_inv ]; · contrapose! h_max_bound; - exact ⟨ ( ∫ x, ⨆ k, Y k x ∂μ ) / σ_sq, div_pos h_max_bound hσ_pos, by ring_nf; nlinarith [ mul_inv_cancel₀ hσ_pos.ne' ] ⟩; - · convert h_max_bound ( Real.sqrt ( 2 * Real.log M / σ_sq ) ) ( by exact Real.sqrt_pos.mpr ( div_pos ( mul_pos zero_lt_two ( Real.log_pos ( mod_cast lt_of_le_of_ne hM ( Ne.symm hM_one ) ) ) ) hσ_pos ) ) using 1 ; ring_nf ; norm_num [ hσ_pos.le, hσ_pos.ne' ] ; ring_nf ; norm_num [ hσ_pos.le, hσ_pos.ne', hM.ne' ] ; + exact ⟨ ( ∫ x, ⨆ k, Y k x ∂μ ) / σ_sq, div_pos h_max_bound hσ_pos, + by ring_nf; nlinarith [ mul_inv_cancel₀ hσ_pos.ne' ] ⟩; + · convert h_max_bound ( Real.sqrt ( 2 * Real.log M / σ_sq ) ) + ( by exact Real.sqrt_pos.mpr ( div_pos + ( mul_pos zero_lt_two ( Real.log_pos ( mod_cast lt_of_le_of_ne hM ( Ne.symm hM_one ) ) ) ) + hσ_pos ) ) using 1 ; ring_nf ; norm_num [ hσ_pos.le, hσ_pos.ne' ] ; ring_nf ; + norm_num [ hσ_pos.le, hσ_pos.ne', hM.ne' ] ; have hlog_pos : 0 < Real.log M := by exact Real.log_pos (mod_cast lt_of_le_of_ne hM (Ne.symm hM_one)) have hsqrtσ_pos : 0 < Real.sqrt σ_sq := Real.sqrt_pos.mpr hσ_pos have hsqrtlog_pos : 0 < Real.sqrt (Real.log M) := Real.sqrt_pos.mpr hlog_pos field_simp [hσ_pos.ne', hsqrtσ_pos.ne', hsqrtlog_pos.ne'] - rw [Real.sq_sqrt (by positivity : (0 : ℝ) ≤ 2), Real.sq_sqrt hσ_pos.le, Real.sq_sqrt hlog_pos.le] + rw [Real.sq_sqrt (by positivity : (0 : ℝ) ≤ 2), Real.sq_sqrt hσ_pos.le, + Real.sq_sqrt hlog_pos.le] ring · norm_num [ show σ_sq = 0 by linarith ] at *; contrapose! h_max_bound; - exact ⟨ ( Real.log M + 1 ) / ( ∫ x, ⨆ k, Y k x ∂μ ), div_pos ( add_pos_of_nonneg_of_pos ( Real.log_nonneg ( Nat.one_le_cast.2 hM ) ) zero_lt_one ) h_max_bound, by rw [ div_div_eq_mul_div, div_lt_iff₀ ] <;> nlinarith [ Real.log_nonneg ( Nat.one_le_cast.2 hM ) ] ⟩ + exact ⟨ ( Real.log M + 1 ) / ( ∫ x, ⨆ k, Y k x ∂μ ), + div_pos ( add_pos_of_nonneg_of_pos ( Real.log_nonneg ( Nat.one_le_cast.2 hM ) ) zero_lt_one ) + h_max_bound, + by + rw [ div_div_eq_mul_div, div_lt_iff₀ ] <;> + nlinarith [ Real.log_nonneg ( Nat.one_le_cast.2 hM ) ] ⟩ /- Bound for the Riemann sum of a non-increasing function with a geometric sequence. @@ -282,22 +343,64 @@ lemma geometric_sum_bound 2 * ∫ x in (D * 2 ^ (-(L + 1 : ℤ)))..(D * 2 ^ (-1 : ℤ)), f x := by induction' L with L ih <;> norm_num [ Finset.sum_range_succ, zpow_add₀, zpow_sub₀ ] at *; - have h_split : ∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2), f x = (∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2 * (2 ^ L)⁻¹), f x) + (∫ x in (D * (1 / 2 * (2 ^ L)⁻¹))..D * (1 / 2), f x) := by - rw [ intervalIntegral.integral_add_adjacent_intervals ] <;> apply_rules [ MeasureTheory.IntegrableOn.intervalIntegrable ]; - · rw [ Set.uIcc_of_le ( by nlinarith [ show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity ] ) ]; - exact ( hf.mono ( Set.Icc_subset_Icc ( by positivity ) ( by nlinarith [ show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, inv_le_one_of_one_le₀ ( show ( 1 : ℝ ) ≤ 2 ^ L by exact one_le_pow₀ ( by norm_num ) ) ] ) ) ) |> fun h => h.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ); + have h_split : ∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2), f x = + (∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2 * (2 ^ L)⁻¹), f x) + + (∫ x in (D * (1 / 2 * (2 ^ L)⁻¹))..D * (1 / 2), f x) := by + rw [ intervalIntegral.integral_add_adjacent_intervals ] <;> + apply_rules [ MeasureTheory.IntegrableOn.intervalIntegrable ]; + · rw + [ Set.uIcc_of_le + ( by nlinarith [ show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity ] ) ]; + exact ( hf.mono ( Set.Icc_subset_Icc ( by positivity ) ( by + nlinarith [ show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, + inv_le_one_of_one_le₀ + ( show ( 1 : ℝ ) ≤ 2 ^ L by exact one_le_pow₀ ( by norm_num ) ) ] ) ) ) |> + fun h => h.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ); · field_simp; - exact ( hf.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) ) |> fun h => h.mono_set ( by rw [ Set.uIcc_of_le ( by gcongr ; norm_cast ; linarith [ Nat.one_le_pow L 2 zero_lt_two ] ) ] ; exact Set.Icc_subset_Icc ( by positivity ) ( by linarith [ show D / 2 ≤ D by linarith ] ) ); - - have h_integral_bound : ∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2 * (2 ^ L)⁻¹), f x ≥ (D * (1 / 2 * (2 ^ L)⁻¹) - D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹))) * f (D * (1 / 2 * (2 ^ L)⁻¹)) := by - have h_integral_bound : ∀ x ∈ Set.Icc (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹))) (D * (1 / 2 * (2 ^ L)⁻¹)), f x ≥ f (D * (1 / 2 * (2 ^ L)⁻¹)) := by - intro x hx; exact hf ⟨ by nlinarith [ hx.1, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) ) by positivity ], by nlinarith [ hx.2, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, show ( 2 ^ L : ℝ ) ⁻¹ ≤ 1 by exact inv_le_one_of_one_le₀ <| one_le_pow₀ <| by norm_num ] ⟩ ⟨ by nlinarith [ hx.1, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) ) by positivity ], by nlinarith [ hx.2, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, show ( 2 ^ L : ℝ ) ⁻¹ ≤ 1 by exact inv_le_one_of_one_le₀ <| one_le_pow₀ <| by norm_num ] ⟩ hx.2; - refine' le_trans _ ( intervalIntegral.integral_mono_on _ _ _ h_integral_bound ) <;> norm_num; - · exact mul_le_mul_of_nonneg_left ( mul_le_mul_of_nonneg_left ( mul_le_of_le_one_left ( by positivity ) ( by norm_num ) ) ( by positivity ) ) hD.le; + exact ( hf.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) ) |> fun h => + h.mono_set ( by + rw [ Set.uIcc_of_le + ( by gcongr ; norm_cast ; linarith [ Nat.one_le_pow L 2 zero_lt_two ] ) ] ; + exact Set.Icc_subset_Icc ( by positivity ) + ( by linarith [ show D / 2 ≤ D by linarith ] ) ); + + have h_integral_bound : ∫ x in (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹)))..D * (1 / 2 * (2 ^ L)⁻¹), + f x ≥ (D * (1 / 2 * (2 ^ L)⁻¹) - D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹))) * + f (D * (1 / 2 * (2 ^ L)⁻¹)) := by + have h_integral_bound : ∀ x ∈ Set.Icc (D * (1 / 2 * (1 / 2 * (2 ^ L)⁻¹))) + (D * (1 / 2 * (2 ^ L)⁻¹)), f x ≥ f (D * (1 / 2 * (2 ^ L)⁻¹)) := by + intro x hx; exact hf + ⟨ + by + nlinarith [ hx.1, + show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) ) by positivity ], + by + nlinarith [ hx.2, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, + show ( 2 ^ L : ℝ ) ⁻¹ ≤ 1 by + exact inv_le_one_of_one_le₀ <| one_le_pow₀ <| by norm_num ] + ⟩ + ⟨ + by + nlinarith [ hx.1, + show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) ) by positivity ], + by + nlinarith [ hx.2, show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, + show ( 2 ^ L : ℝ ) ⁻¹ ≤ 1 by + exact inv_le_one_of_one_le₀ <| one_le_pow₀ <| by norm_num ] + ⟩ hx.2; + refine le_trans ?_ ( intervalIntegral.integral_mono_on ?_ ?_ ?_ h_integral_bound ) <;> norm_num; + · exact mul_le_mul_of_nonneg_left + ( mul_le_mul_of_nonneg_left ( mul_le_of_le_one_left ( by positivity ) ( by norm_num ) ) + ( by positivity ) ) hD.le; · apply_rules [ MeasureTheory.IntegrableOn.intervalIntegrable ]; rw [ Set.uIcc_of_le ( by nlinarith [ show ( 0 : ℝ ) < D * ( 2 ^ L ) ⁻¹ by positivity ] ) ]; - exact ( hf.mono ( Set.Icc_subset_Icc ( by positivity ) ( by nlinarith [ show ( 2 ^ L : ℝ ) ⁻¹ ≤ 1 by exact inv_le_one_of_one_le₀ ( one_le_pow₀ ( by norm_num ) ) ] ) ) ) |> fun h => h.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ); - linarith [ inv_pos.mpr ( pow_pos ( zero_lt_two' ℝ ) L ), mul_inv_cancel₀ ( ne_of_gt ( pow_pos ( zero_lt_two' ℝ ) L ) ), pow_pos ( zero_lt_two' ℝ ) L ] + exact ( hf.mono ( Set.Icc_subset_Icc ( by positivity ) ( by + nlinarith [ show ( 0 : ℝ ) ≤ D * ( 1 / 2 * ( 2 ^ L ) ⁻¹ ) by positivity, + inv_le_one_of_one_le₀ + ( show ( 1 : ℝ ) ≤ 2 ^ L by exact one_le_pow₀ ( by norm_num ) ) ] ) ) ) |> + fun h => h.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ); + linarith [ inv_pos.mpr ( pow_pos ( zero_lt_two' ℝ ) L ), + mul_inv_cancel₀ ( ne_of_gt ( pow_pos ( zero_lt_two' ℝ ) L ) ), pow_pos ( zero_lt_two' ℝ ) L ] /- Auxiliary real-valued truncated Dudley integral for the internal Nat-valued cardinality. @@ -314,11 +417,14 @@ lemma telescoping_sum_bound {L : ℕ} (hL : 1 ≤ L) (gamma : ℕ → α) (X : α → ℝ) : - |X (gamma L) - X (gamma 1)| ≤ ∑ k ∈ Finset.range (L - 1), |X (gamma (k + 2)) - X (gamma (k + 1))| := by + |X (gamma L) - X (gamma 1)| ≤ ∑ k ∈ Finset.range (L - 1), |X (gamma (k + 2)) - + X (gamma (k + 1))| := by induction' L with L ih; · contradiction; · rcases L with ( _ | L ) <;> simp_all +decide [ Finset.sum_range_succ ]; - cases abs_cases ( X ( gamma ( L + 2 ) ) - X ( gamma 1 ) ) <;> cases abs_cases ( X ( gamma ( L + 2 ) ) - X ( gamma ( L + 1 ) ) ) <;> cases abs_cases ( X ( gamma ( L + 1 ) ) - X ( gamma 1 ) ) <;> linarith + cases abs_cases ( X ( gamma ( L + 2 ) ) - X ( gamma 1 ) ) <;> + cases abs_cases ( X ( gamma ( L + 2 ) ) - X ( gamma ( L + 1 ) ) ) <;> + cases abs_cases ( X ( gamma ( L + 1 ) ) - X ( gamma 1 ) ) <;> linarith /- Bound for a single step in the chain. @@ -332,10 +438,11 @@ lemma single_step_bound {X : α → ℝ} (gamma : ℕ → α) (k : ℕ) - (h_chain_step : ∃ (h_succ : gamma (k + 2) ∈ U (k + 2)), gamma (k + 1) = pi_map (k + 1) ⟨gamma (k + 2), h_succ⟩) + (h_chain_step : ∃ (h_succ : gamma (k + 2) ∈ U (k + 2)), gamma (k + 1) = + pi_map (k + 1) ⟨gamma (k + 2), h_succ⟩) : |X (gamma (k + 2)) - X (gamma (k + 1))| ≤ ⨆ (u : U (k + 2)), |X u - X (pi_map (k + 1) u)| := by - refine' le_trans _ ( le_ciSup _ ⟨ gamma ( k + 2 ), h_chain_step.choose ⟩ ) + refine le_trans ?_ ( le_ciSup ?_ ⟨ gamma ( k + 2 ), h_chain_step.choose ⟩ ) · simp [h_chain_step.choose_spec] · exact Set.Finite.bddAbove <| Set.Finite.subset @@ -357,19 +464,23 @@ lemma single_chain_bound {pi_map : (k : ℕ) → U (k + 1) → U k} {X : α → ℝ} (gamma : ℕ → α) - (h_chain : ∀ k, 1 ≤ k → k < L → ∃ (h_succ : gamma (k + 1) ∈ U (k + 1)), gamma k = pi_map k ⟨gamma (k + 1), h_succ⟩) + (h_chain : ∀ k, 1 ≤ k → k < L → ∃ (h_succ : gamma (k + 1) ∈ U (k + 1)), gamma k = + pi_map k ⟨gamma (k + 1), h_succ⟩) : - |X (gamma L) - X (gamma 1)| ≤ ∑ k ∈ Finset.range (L - 1), (⨆ (u : U (k + 2)), |X u - X (pi_map (k + 1) u)|) := by + |X (gamma L) - X (gamma 1)| ≤ ∑ k ∈ Finset.range (L - 1), + (⨆ (u : U (k + 2)), |X u - X (pi_map (k + 1) u)|) := by have := @telescoping_sum_bound α L hL gamma X; - refine' le_trans this ( Finset.sum_le_sum fun k hk => _ ); + refine le_trans this ( Finset.sum_le_sum fun k hk => ?_ ); simpa using (single_step_bound hU_finite gamma k (h_chain (k + 1) (by omega) (Nat.lt_pred_iff.mp (Finset.mem_range.mp hk)))) /- -If a finite covering exists, there exists a minimal finite covering with cardinality equal to the cardinality. +If a finite covering exists, there exists a minimal finite covering with cardinality equal to the + cardinality. -/ -lemma exists_minimal_covering_of_finite_covering {α : Type*} [PseudoMetricSpace α] {T : Set α} {δ : ℝ} (h : ∃ u : Set α, u.Finite ∧ IsSubsetENet T u δ) : +lemma exists_minimal_covering_of_finite_covering {α : Type*} [PseudoMetricSpace α] {T : Set α} + {δ : ℝ} (h : ∃ u : Set α, u.Finite ∧ IsSubsetENet T u δ) : ∃ u : Set α, u.Finite ∧ IsSubsetENet T u δ ∧ u.ncard = subsetENetCard T δ := by obtain ⟨ u, hu ⟩ := Nat.sInf_mem (show Set.Nonempty { n : ℕ | ∃ u : Finset α, IsSubsetENet T u δ ∧ u.card = n } from by @@ -399,16 +510,21 @@ lemma exists_dudley_chain (∀ m < L, (U_seq m).ncard = subsetENetCard T (epsilon m)) ∧ (∀ m < L, IsSubsetENet T (U_seq m) (epsilon m)) ∧ (∀ m < L, ∀ u ∈ U_seq (m + 1), pi_map m u ∈ U_seq m ∧ dist u (pi_map m u) ≤ epsilon m) := by - have h_chain_construction : ∀ m < L, ∃ U_seq : (m : ℕ) → Set α, (∀ m < L, (U_seq m).Finite ∧ IsSubsetENet T (U_seq m) (epsilon m) ∧ (U_seq m).ncard = subsetENetCard T (epsilon m)) ∧ U_seq m ⊆ T ∧ U_seq L = U := by + have h_chain_construction : ∀ m < L, ∃ U_seq : (m : ℕ) → Set α, + (∀ m < L, (U_seq m).Finite ∧ IsSubsetENet T (U_seq m) (epsilon m) ∧ (U_seq m).ncard = + subsetENetCard T (epsilon m)) ∧ U_seq m ⊆ T ∧ U_seq L = U := by intro m hm; - have hU_seq : ∀ m < L, ∃ U_seq : Set α, U_seq.Finite ∧ IsSubsetENet T U_seq (epsilon m) ∧ U_seq.ncard = subsetENetCard T (epsilon m) := by + have hU_seq : ∀ m < L, ∃ U_seq : Set α, U_seq.Finite ∧ + IsSubsetENet T U_seq (epsilon m) ∧ U_seq.ncard = subsetENetCard T (epsilon m) := by exact fun m a => exists_minimal_covering_of_finite_covering (h_finite_covering m a); choose! U_seq hU_seq using hU_seq; use fun n => if n = L then U else U_seq n; simp +zetaDelta at *; - exact ⟨ fun n hn => by rw [ ite_eq_right ( ne_of_lt hn ) ] ; exact hU_seq n hn, by rw [ ite_eq_right ( ne_of_lt hm ) ] ; exact hU_seq m hm |>.2.1.1 ⟩; + exact ⟨ fun n hn => by rw [ ite_eq_right ( ne_of_lt hn ) ] ; exact hU_seq n hn, + by rw [ ite_eq_right ( ne_of_lt hm ) ] ; exact hU_seq m hm |>.2.1.1 ⟩; cases' L with L L; - · exact ⟨ fun _ => U, fun _ => id, fun _ => hU_finite, fun _ => hU_subset, rfl, by norm_num, by norm_num, by norm_num ⟩; + · exact ⟨ fun _ => U, fun _ => id, fun _ => hU_finite, fun _ => hU_subset, rfl, + by norm_num, by norm_num, by norm_num ⟩; · obtain ⟨ U_seq, hU_seq₁, hU_seq₂, hU_seq ⟩ := h_chain_construction L ( Nat.lt_succ_self L ); use fun m => if m < L + 1 then U_seq m else U_seq (L + 1); have h_pi_map : ∀ m < L + 1, ∀ u ∈ U_seq (m + 1), ∃ v ∈ U_seq m, dist u v ≤ epsilon m := by @@ -469,7 +585,8 @@ lemma sub_gaussian_max_abs_bound change HasSubgaussianMGF (-Y i) ⟨σ_sq, hσi⟩ μ exact hYi.neg⟩ - have h_metric_entropy_bound : ∫ ω, ⨆ i, Z i ω ∂μ ≤ Real.sqrt (2 * σ_sq * Real.log (Fintype.card (ι ⊕ ι))) := by + have h_metric_entropy_bound : ∫ ω, ⨆ i, Z i ω ∂μ ≤ + Real.sqrt (2 * σ_sq * Real.log (Fintype.card (ι ⊕ ι))) := by convert metric_entropy_bound_for_sub_gaussian_maxima _ _ _; any_goals assumption; any_goals exact fun i ω => Z ( Fintype.equivFin ( ι ⊕ ι ) |>.symm i ) ω; @@ -479,19 +596,22 @@ lemma sub_gaussian_max_abs_bound convert h_metric_entropy_bound using 3 <;> norm_num [ two_mul ]; rw [ @ciSup_eq_of_forall_le_of_forall_lt_exists_gt ]; · intro i; exact (by - exact max_le ( le_ciSup ( Finite.bddAbove_range fun i => Z i _ ) ( Sum.inl i ) ) ( le_ciSup ( Finite.bddAbove_range fun i => Z i _ ) ( Sum.inr i ) )); + exact max_le ( le_ciSup ( Finite.bddAbove_range fun i => Z i _ ) ( Sum.inl i ) ) + ( le_ciSup ( Finite.bddAbove_range fun i => Z i _ ) ( Sum.inr i ) )); · intro w hw; contrapose! hw; convert ciSup_le _; · exact Sum.nonemptyRight; - · rintro ( i | i ) <;> [ exact le_trans ( le_abs_self _ ) ( hw i ) ; exact le_trans ( neg_le_abs _ ) ( hw i ) ] + · rintro ( i | i ) <;> + [ exact le_trans ( le_abs_self _ ) ( hw i ) ; exact le_trans ( neg_le_abs _ ) ( hw i ) ] /- Expectation bound for a single step in the chain. -/ lemma expectation_bound_chain_step {α : Type*} [PseudoMetricSpace α] - {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] + {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} + [MeasureTheory.IsProbabilityMeasure μ] {T : Set α} {X : Ω → α → ℝ} (h_sg : ∀ x ∈ T, ∀ y ∈ T, IsSubGaussian (fun ω => X ω x - X ω y) (dist x y ^ 2) μ) @@ -504,21 +624,23 @@ lemma expectation_bound_chain_step (eps : ℝ) (h_eps : 0 ≤ eps) (h_dist : ∀ u ∈ U_next, dist u (pi_map u) ≤ eps) : - ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ eps * Real.sqrt (2 * Real.log (U_next.ncard)) + eps * Real.sqrt (2 * Real.log 2) := by + ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ eps * + Real.sqrt (2 * Real.log (U_next.ncard)) + eps * Real.sqrt (2 * Real.log 2) := by cases' hU_next_finite.exists_finset_coe with F hF; by_cases hF_empty : F.Nonempty <;> simp_all +decide; - · - set Y : F → Ω → ℝ := fun u ω => X ω u - X ω (pi_map u); + · set Y : F → Ω → ℝ := fun u ω => X ω u - X ω (pi_map u); - have h_Y_bound : ∫ ω, (⨆ u : F, |Y u ω|) ∂μ ≤ Real.sqrt (2 * eps^2 * Real.log (2 * F.card)) := by + have h_Y_bound : ∫ ω, (⨆ u : F, |Y u ω|) ∂μ ≤ + Real.sqrt (2 * eps^2 * Real.log (2 * F.card)) := by have h_Y_bound : ∀ u : F, IsSubGaussian (Y u) (eps^2) μ := by intro u - specialize h_sg u.val (hU_next_subset (hF.subset u.prop)) (pi_map u.val) (hU_curr_subset (h_pi u.val (hF.subset u.prop))); - refine' ⟨ _, _ ⟩; + specialize h_sg u.val (hU_next_subset (hF.subset u.prop)) (pi_map u.val) + (hU_curr_subset (h_pi u.val (hF.subset u.prop))); + refine ⟨ ?_, ?_ ⟩; exact sq_nonneg _; - refine' ⟨ _, fun t => _ ⟩; + refine ⟨ ?_, fun t => ?_ ⟩; · exact fun t => sub_gaussian_integrable h_sg t; - · refine' le_trans ( h_sg.choose_spec.2 t ) _; + · refine le_trans ( h_sg.choose_spec.2 t ) ?_; exact Real.exp_le_exp.mpr ( by gcongr exact (sq_le_sq₀ dist_nonneg h_eps).2 (h_dist _ (hF.subset u.2)) ); @@ -625,7 +747,8 @@ lemma chain_projection_mem {α : Type*} {U : ℕ → Set α} (L : ℕ) (pi_map : /- Telescoping sum bound for the chain projection. -The difference between the value at the start and end of the chain is bounded by the sum of differences along the chain. +The difference between the value at the start and end of the chain is bounded + by the sum of differences along the chain. -/ lemma chain_telescoping_bound {α : Type*} @@ -635,7 +758,8 @@ lemma chain_telescoping_bound (u : α) : |X (chain_projection L pi_map u L) - X (chain_projection L pi_map u 1)| ≤ - ∑ k ∈ Finset.range (L - 1), |X (chain_projection L pi_map u (k + 2)) - X (chain_projection L pi_map u (k + 1))| := by + ∑ k ∈ Finset.range (L - 1), |X (chain_projection L pi_map u (k + 2)) - + X (chain_projection L pi_map u (k + 1))| := by simpa using (telescoping_sum_bound (L := L) hL (gamma := fun k => chain_projection L pi_map u k) (X := X)) @@ -656,17 +780,22 @@ lemma chain_projection_step_bound : |X (chain_projection L pi_map u (k + 2)) - X (chain_projection L pi_map u (k + 1))| ≤ (⨆ z ∈ U (k + 2), |X z - X (pi_map (k + 1) z)|) := by - rw [ show chain_projection L pi_map u ( k+2 ) = chain_projection L pi_map u ( k+2 ) from rfl, show chain_projection L pi_map u ( k+1 ) = pi_map ( k+1 ) ( chain_projection L pi_map u ( k+2 ) ) from ?_ ]; + rw [ show chain_projection L pi_map u ( k+2 ) = chain_projection L pi_map u ( k+2 ) from + rfl, show chain_projection L pi_map u ( k+1 ) = + pi_map ( k+1 ) ( chain_projection L pi_map u ( k+2 ) ) from ?_ ]; · have h_chain_finite : chain_projection L pi_map u (k + 2) ∈ U (k + 2) := by apply chain_projection_mem; · assumption; · exact h_chain; · omega; - refine' le_trans _ ( le_ciSup _ ( chain_projection L pi_map u ( k + 2 ) ) ); - · exact le_ciSup ⟨|X (chain_projection L pi_map u (k + 2)) - X (pi_map (k + 1) (chain_projection L pi_map u (k + 2)))|, + refine le_trans ?_ ( le_ciSup ?_ ( chain_projection L pi_map u ( k + 2 ) ) ); + · exact le_ciSup ⟨|X (chain_projection L pi_map u (k + 2)) - + X (pi_map (k + 1) (chain_projection L pi_map u (k + 2)))|, Set.forall_mem_range.2 fun _ => le_rfl⟩ h_chain_finite; - · obtain ⟨ M, hM ⟩ := Set.Finite.bddAbove ( Set.Finite.image ( fun z => |X z - X ( pi_map ( k + 1 ) z ) - 0| ) ( hU_finite ( k + 2 ) ) ); - refine' ⟨ Max.max M 1, Set.forall_mem_range.2 fun z => _ ⟩; + · obtain ⟨ M, hM ⟩ := + Set.Finite.bddAbove ( Set.Finite.image ( fun z => |X z - X ( pi_map ( k + 1 ) z ) - 0| ) + ( hU_finite ( k + 2 ) ) ); + refine ⟨ Max.max M 1, Set.forall_mem_range.2 fun z => ?_ ⟩; rw [ @ciSup_eq_ite ] split_ifs with hz · exact le_trans (by simpa using hM ⟨z, hz, rfl⟩) (le_max_left _ _) @@ -674,7 +803,8 @@ lemma chain_projection_step_bound · exact chain_projection_step L pi_map u ( k + 1 ) ( by omega ) /- -Bounds the difference between X(u) and X(projection of u at step 1) by the sum of suprema of differences at each step. +Bounds the difference between X(u) and X(projection of u at step 1) + by the sum of suprema of differences at each step. Requires U to be finite. -/ lemma chain_projection_bound @@ -703,7 +833,8 @@ lemma chain_projection_bound chain_projection_step_bound hU_finite u hu h_chain k (Finset.mem_range.mp hk) /- -Bounds the supremum of the difference between X(u) and X(projection of u at step 1) over all u in U_L. +Bounds the supremum of the difference between X(u) and X(projection of u at step 1) over all u in + U_L. -/ lemma chain_sup_projection_bound {α : Type*} @@ -717,13 +848,15 @@ lemma chain_sup_projection_bound (⨆ u ∈ U L, |X u - X (chain_projection L pi_map u 1)|) ≤ ∑ k ∈ Finset.range (L - 1), (⨆ z ∈ U (k + 2), |X z - X (pi_map (k + 1) z)|) := by by_contra h_contra; - obtain ⟨u, hu⟩ : ∃ u ∈ U L, |X u - X (chain_projection L pi_map u 1)| > ∑ k ∈ Finset.range (L - 1), (⨆ z ∈ U (k + 2), |X z - X (pi_map (k + 1) z)|) := by + obtain ⟨u, hu⟩ : ∃ u ∈ U L, |X u - X (chain_projection L pi_map u 1)| > ∑ k ∈ + Finset.range (L - 1), (⨆ z ∈ U (k + 2), |X z - X (pi_map (k + 1) z)|) := by push Not at h_contra; have h_nonempty : (U L).Nonempty := by by_contra h_empty rw [Set.not_nonempty_iff_eq_empty.mp h_empty] at h_contra simp at h_contra - exact not_lt_of_ge (Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _) h_contra + exact not_lt_of_ge (Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => abs_nonneg _) h_contra have : Nonempty α := ⟨h_nonempty.some⟩ have : Nonempty (U L) := Set.Nonempty.to_subtype h_nonempty let f : U L → ℝ := fun u => |X u - X (chain_projection L pi_map u 1)| @@ -736,8 +869,11 @@ lemma chain_sup_projection_bound simp [f] exact le_trans h_nonneg (le_ciSup h_bdd ⟨h_nonempty.some, h_nonempty.choose_spec⟩) have hciSup : (⨆ u : U L, f u) = ⨆ u ∈ U L, |X u - X (chain_projection L pi_map u 1)| := by - simpa [f] using (ciSup_subtype_fun (s := U L) (f := fun u => |X u - X (chain_projection L pi_map u 1)|) h_bdd h_empty_le) - have h_contra' : ∑ k ∈ Finset.range (L - 1), ⨆ z ∈ U (k + 2), |X z - X (pi_map (k + 1) z)| < ⨆ u : U L, f u := by + simpa [f] using + (ciSup_subtype_fun (s := U L) (f := fun u => |X u - X (chain_projection L pi_map u 1)|) + h_bdd h_empty_le) + have h_contra' : ∑ k ∈ Finset.range (L - 1), ⨆ z ∈ U (k + 2), |X z - + X (pi_map (k + 1) z)| < ⨆ u : U L, f u := by rw [hciSup] exact h_contra obtain ⟨u, hu⟩ := exists_lt_of_lt_ciSup h_contra' @@ -754,7 +890,7 @@ lemma finite_sup_bound (u v : α) (hu : u ∈ A) (hv : v ∈ A) : |X u - X v| ≤ ⨆ x ∈ A, ⨆ y ∈ A, |X x - X y| := by have h_finset : ∀ x ∈ A, ∀ y ∈ A, |X x - X y| ≤ ⨆ x ∈ A, ⨆ y ∈ A, |X x - X y| := by - refine' fun x hx y hy => le_trans _ ( le_ciSup _ x ); + refine fun x hx y hy => le_trans ?_ ( le_ciSup ?_ x ); · exact le_trans (le_trans @@ -765,16 +901,21 @@ lemma finite_sup_bound Set.forall_mem_range.2 fun y => by rw [ciSup_eq_ite] split_ifs with hy' - · exact Finset.single_le_sum (fun i _ => abs_nonneg (X x - X i)) (hA.mem_toFinset.mpr hy') - · exact le_trans (by norm_num) (Finset.sum_nonneg fun i _ => abs_nonneg (X x - X i)) ⟩) + · exact Finset.single_le_sum + (fun i _ => abs_nonneg (X x - X i)) (hA.mem_toFinset.mpr hy') + · exact le_trans (by norm_num) + (Finset.sum_nonneg fun i _ => abs_nonneg (X x - X i)) ⟩) y)) (le_ciSup ⟨⨆ y ∈ A, |X x - X y|, Set.forall_mem_range.2 fun _ => le_rfl⟩ hx) - · - have h_finite_range : Set.Finite (Set.range (fun x : α => ⨆ (hx : x ∈ A), ⨆ y ∈ A, |X x - X y|)) := by + · have h_finite_range : + Set.Finite (Set.range (fun x : α => ⨆ (hx : x ∈ A), ⨆ y ∈ A, |X x - X y|)) := by - have h_finite_range : Set.Finite (Set.image (fun x => ⨆ (hx : x ∈ A), ⨆ y ∈ A, |X x - X y|) A) := by + have h_finite_range : + Set.Finite (Set.image (fun x => ⨆ (hx : x ∈ A), ⨆ y ∈ A, |X x - X y|) A) := by exact hA.image _; - exact Set.Finite.subset ( h_finite_range.union ( Set.finite_singleton 0 ) ) ( Set.range_subset_iff.2 fun x => if hx : x ∈ A then Or.inl ⟨ x, hx, rfl ⟩ else Or.inr <| by simp [hx] ); + exact Set.Finite.subset ( h_finite_range.union ( Set.finite_singleton 0 ) ) + ( Set.range_subset_iff.2 fun x => if hx : x ∈ + A then Or.inl ⟨ x, hx, rfl ⟩ else Or.inr <| by simp [hx] ); exact h_finite_range.bddAbove; exact h_finset u hu v hv @@ -799,8 +940,11 @@ lemma dudley_chain_bound_pointwise set u1 := chain_projection L pi_map u 1 set v1 := chain_projection L pi_map v 1 have h_triangle : |X u - X v| ≤ |X u - X u1| + |X u1 - X v1| + |X v1 - X v| := by - cases abs_cases ( X u - X v ) <;> cases abs_cases ( X u - X u1 ) <;> cases abs_cases ( X u1 - X v1 ) <;> cases abs_cases ( X v1 - X v ) <;> linarith; - have h_chain_bound : ∀ (w : α) (hw : w ∈ U_seq L), |X w - X (chain_projection L pi_map w 1)| ≤ ∑ k ∈ Finset.range (L - 1), (⨆ z ∈ U_seq (k + 2), |X z - X (pi_map (k + 1) z)|) := by + cases abs_cases ( X u - X v ) <;> cases abs_cases ( X u - X u1 ) <;> + cases abs_cases ( X u1 - X v1 ) <;> cases abs_cases ( X v1 - X v ) <;> linarith; + have h_chain_bound : ∀ (w : α) (hw : w ∈ U_seq L), |X w - + X (chain_projection L pi_map w 1)| ≤ ∑ k ∈ Finset.range (L - 1), + (⨆ z ∈ U_seq (k + 2), |X z - X (pi_map (k + 1) z)|) := by exact fun w hw => chain_projection_bound hL hU_finite w hw h_chain; have h_sup_bound : |X u1 - X v1| ≤ ⨆ x ∈ U_seq 1, ⨆ y ∈ U_seq 1, |X x - X y| := by @@ -841,24 +985,39 @@ lemma integral_dudley_chain_bound (hU_finite : ∀ m, (U_seq m).Finite) (h_chain : ∀ m < L, ∀ u ∈ U_seq (m + 1), pi_map m u ∈ U_seq m) (h_integrable_1 : Integrable (fun ω => ⨆ x ∈ U_seq 1, ⨆ y ∈ U_seq 1, |X ω x - X ω y|) P) - (h_integrable_2 : ∀ k < L - 1, Integrable (fun ω => ⨆ z ∈ U_seq (k + 2), |X ω z - X ω (pi_map (k + 1) z)|) P) + (h_integrable_2 : ∀ k < L - 1, Integrable (fun ω => ⨆ z ∈ U_seq (k + 2), |X ω z - + X ω (pi_map (k + 1) z)|) P) : ∫ ω, (⨆ u ∈ U_seq L, ⨆ v ∈ U_seq L, |X ω u - X ω v|) ∂P ≤ ∫ ω, (⨆ x ∈ U_seq 1, ⨆ y ∈ U_seq 1, |X ω x - X ω y|) ∂P + - 2 * ∑ k ∈ Finset.range (L - 1), ∫ ω, (⨆ z ∈ U_seq (k + 2), |X ω z - X ω (pi_map (k + 1) z)|) ∂P := by + 2 * ∑ k ∈ Finset.range (L - 1), ∫ ω, + (⨆ z ∈ U_seq (k + 2), |X ω z - X ω (pi_map (k + 1) z)|) ∂P := by rw [ ← MeasureTheory.integral_finsetSum ]; · rw [ ← MeasureTheory.integral_const_mul ]; rw [ ← MeasureTheory.integral_add ]; · by_contra h_contra; - refine' h_contra ( MeasureTheory.integral_mono _ _ fun ω => _ ); - · exact ( by by_contra h; rw [ MeasureTheory.integral_undef h ] at h_contra; exact h_contra <| by exact le_trans ( by norm_num ) <| MeasureTheory.integral_nonneg fun _ => add_nonneg ( by exact Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) <| mul_nonneg zero_le_two <| Finset.sum_nonneg fun _ _ => by exact Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ); - · exact MeasureTheory.Integrable.add h_integrable_1 ( MeasureTheory.Integrable.const_mul ( MeasureTheory.integrable_finsetSum _ fun i hi => h_integrable_2 i ( Finset.mem_range.mp hi ) ) _ ); - · - have h_pointwise : ∀ u ∈ U_seq L, ∀ v ∈ U_seq L, |X ω u - X ω v| ≤ (⨆ x ∈ U_seq 1, ⨆ y ∈ U_seq 1, |X ω x - X ω y|) + 2 * ∑ k ∈ Finset.range (L - 1), (⨆ z ∈ U_seq (k + 2), |X ω z - X ω (pi_map (k + 1) z)|) := by + refine h_contra ( MeasureTheory.integral_mono ?_ ?_ fun ω => ?_ ); + · exact ( by + by_contra h; rw [ MeasureTheory.integral_undef h ] at h_contra; + exact h_contra <| by + exact le_trans ( by norm_num ) <| MeasureTheory.integral_nonneg fun _ => + add_nonneg ( by exact Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) <| + mul_nonneg zero_le_two <| Finset.sum_nonneg fun _ _ => by + exact Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ); + · exact MeasureTheory.Integrable.add h_integrable_1 + ( MeasureTheory.Integrable.const_mul ( MeasureTheory.integrable_finsetSum _ fun i hi => + h_integrable_2 i ( Finset.mem_range.mp hi ) ) _ ); + · have h_pointwise : ∀ u ∈ U_seq L, ∀ v ∈ U_seq L, |X ω u - X ω v| ≤ + (⨆ x ∈ U_seq 1, ⨆ y ∈ U_seq 1, |X ω x - X ω y|) + 2 * ∑ k ∈ Finset.range (L - 1), + (⨆ z ∈ U_seq (k + 2), |X ω z - X ω (pi_map (k + 1) z)|) := by exact fun u a v a_1 => dudley_chain_bound_pointwise hL hU_finite h_chain u a v a_1; by_cases hL_empty : U_seq L = ∅; · simp [hL_empty]; - exact add_nonneg ( Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ); + exact add_nonneg ( Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) + ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => abs_nonneg _ ) ); · obtain ⟨u, hu⟩ : ∃ u, u ∈ U_seq L := by exact Set.nonempty_iff_ne_empty.2 hL_empty; convert ciSup_le fun v => ?_; @@ -868,11 +1027,23 @@ lemma integral_dudley_chain_bound · convert ciSup_le fun w => ?_; · exact Nonempty.intro (pi_map L (pi_map L u)); · rw [ @ciSup_eq_ite ]; - split_ifs with hw <;> [ exact h_pointwise _ hv _ hw; exact le_trans ( by norm_num ) ( add_nonneg ( Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ) ) ]; + split_ifs with hw <;> + [ exact h_pointwise _ hv _ hw; + exact le_trans ( by norm_num ) + ( add_nonneg ( Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) + ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ) ) ]; · simp +decide [ Real.sSup_empty ]; - exact add_nonneg ( Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ); + exact add_nonneg ( Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => + abs_nonneg _ ) + ( mul_nonneg zero_le_two ( Finset.sum_nonneg fun _ _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _ ) ); · exact h_integrable_1; - · exact MeasureTheory.Integrable.const_mul ( MeasureTheory.integrable_finsetSum _ fun i hi => h_integrable_2 i ( Finset.mem_range.mp hi ) ) _; + · exact MeasureTheory.Integrable.const_mul + ( MeasureTheory.integrable_finsetSum _ fun i hi => + h_integrable_2 i ( Finset.mem_range.mp hi ) ) _; · exact fun k hk => h_integrable_2 k ( Finset.mem_range.mp hk ) /- @@ -888,31 +1059,53 @@ lemma dudley_analytical_sum_bound 8 * ∫ x in Set.Icc (D * 2 ^ (-(L + 1 : ℝ))) (D * 2 ^ (-1 : ℝ)), f x := by induction' L with L ih; · norm_num; - · - have h_split : ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-1 : ℝ))), f x = (∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f x) + (∫ x in (Icc (D * 2 ^ (-(L + 1) : ℝ)) (D * 2 ^ (-1 : ℝ))), f x) := by - rw [ MeasureTheory.integral_Icc_eq_integral_Ioc, MeasureTheory.integral_Icc_eq_integral_Ioc, MeasureTheory.integral_Icc_eq_integral_Ioc, ← MeasureTheory.setIntegral_union ] <;> norm_num; + · have h_split : ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-1 : ℝ))), f x = + (∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f x) + + (∫ x in (Icc (D * 2 ^ (-(L + 1) : ℝ)) (D * 2 ^ (-1 : ℝ))), f x) := by + rw [ MeasureTheory.integral_Icc_eq_integral_Ioc, + MeasureTheory.integral_Icc_eq_integral_Ioc, MeasureTheory.integral_Icc_eq_integral_Ioc, + ← MeasureTheory.setIntegral_union ] <;> norm_num; · rw [ Set.Ioc_union_Ioc_eq_Ioc ] <;> norm_num [ Real.rpow_add, Real.rpow_neg ]; - · exact mul_le_mul_of_nonneg_left ( mul_le_mul_of_nonneg_right ( by norm_num ) ( by positivity ) ) hD.le; - · exact mul_le_mul_of_nonneg_left ( mul_le_of_le_one_right ( by norm_num ) ( inv_le_one_of_one_le₀ ( one_le_pow₀ ( by norm_num ) ) ) ) hD.le; - · refine' MeasureTheory.IntegrableOn.mono_set _ _; - exact Set.Icc 0 D; + · exact mul_le_mul_of_nonneg_left + ( mul_le_mul_of_nonneg_right ( by norm_num ) ( by positivity ) ) hD.le; + · exact mul_le_mul_of_nonneg_left + ( mul_le_of_le_one_right ( by norm_num ) + ( inv_le_one_of_one_le₀ ( one_le_pow₀ ( by norm_num ) ) ) ) hD.le; + · refine MeasureTheory.IntegrableOn.mono_set (t := Set.Icc 0 D) ?_ ?_; · exact ( hf_antitone.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) ); - · exact fun x hx => ⟨ le_trans ( by positivity ) hx.1.le, le_trans hx.2 ( by exact mul_le_of_le_one_right hD.le ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ) ⟩; - · refine' MeasureTheory.IntegrableOn.mono_set _ ( Set.Ioc_subset_Icc_self ); - refine' MeasureTheory.IntegrableOn.mono_set _ _; - exact Set.Icc 0 D; + · exact fun x hx => ⟨ le_trans ( by positivity ) hx.1.le, le_trans hx.2 ( by + exact mul_le_of_le_one_right hD.le + ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ) ⟩; + · refine MeasureTheory.IntegrableOn.mono_set ?_ ( Set.Ioc_subset_Icc_self ); + refine MeasureTheory.IntegrableOn.mono_set (t := Set.Icc 0 D) ?_ ?_; · exact ( hf_antitone.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) ); - · exact Set.Icc_subset_Icc ( by positivity ) ( by nlinarith [ Real.rpow_pos_of_pos zero_lt_two ( -1 + -L : ℝ ) ] ); - - have h_integral_bound : ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f x ≥ (D * 2 ^ (-(L + 1) : ℝ) - D * 2 ^ (-(L + 2) : ℝ)) * f (D * 2 ^ (-(L + 1) : ℝ)) := by - have h_integral_bound : ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f x ≥ ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f (D * 2 ^ (-(L + 1) : ℝ)) := by - refine' MeasureTheory.setIntegral_mono_on _ _ _ _ <;> norm_num; - · refine' ( hf_antitone.integrableOn_isCompact _ ) |> fun h => h.mono_set _; + · exact Set.Icc_subset_Icc ( by positivity ) + ( by nlinarith [ Real.rpow_pos_of_pos zero_lt_two ( -1 + -L : ℝ ) ] ); + + have h_integral_bound : ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), + f x ≥ (D * 2 ^ (-(L + 1) : ℝ) - D * 2 ^ (-(L + 2) : ℝ)) * f (D * 2 ^ (-(L + 1) : ℝ)) := by + have h_integral_bound : + ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), f x ≥ + ∫ x in (Icc (D * 2 ^ (-(L + 2) : ℝ)) (D * 2 ^ (-(L + 1) : ℝ))), + f (D * 2 ^ (-(L + 1) : ℝ)) := by + refine MeasureTheory.setIntegral_mono_on ?_ ?_ ?_ ?_ <;> norm_num; + · refine ( hf_antitone.integrableOn_isCompact ?_ ) |> fun h => h.mono_set ?_; · exact CompactIccSpace.isCompact_Icc; - · exact Set.Icc_subset_Icc ( by positivity ) ( by exact mul_le_of_le_one_right hD.le ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ); - · intro x hx₁ hx₂; refine' hf_antitone _ _ _ <;> norm_num [ Real.rpow_add, Real.rpow_neg ] at * <;> try nlinarith [ Real.rpow_pos_of_pos zero_lt_two ( -1 + -L : ℝ ), Real.rpow_pos_of_pos zero_lt_two ( -2 + -L : ℝ ) ] ; - · constructor <;> nlinarith [ inv_pos.mpr ( pow_pos ( zero_lt_two' ℝ ) L ), mul_inv_cancel₀ ( ne_of_gt ( pow_pos ( zero_lt_two' ℝ ) L ) ), pow_le_pow_right₀ ( by norm_num : ( 1 : ℝ ) ≤ 2 ) ( show L ≥ 0 by norm_num ) ]; - · exact ⟨ hD.le, mul_le_of_le_one_right hD.le ( by linarith [ inv_le_one_of_one_le₀ ( one_le_pow₀ ( by norm_num : ( 1 : ℝ ) ≤ 2 ) : ( 1 : ℝ ) ≤ 2 ^ L ) ] ) ⟩; + · exact Set.Icc_subset_Icc ( by positivity ) ( by + exact mul_le_of_le_one_right hD.le + ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ); + · intro x hx₁ hx₂; refine hf_antitone ?_ ?_ ?_ <;> + norm_num [ Real.rpow_add, Real.rpow_neg ] at * <;> + try nlinarith [ Real.rpow_pos_of_pos zero_lt_two ( -1 + -L : ℝ ), + Real.rpow_pos_of_pos zero_lt_two ( -2 + -L : ℝ ) ] ; + · constructor <;> nlinarith [ inv_pos.mpr ( pow_pos ( zero_lt_two' ℝ ) L ), + mul_inv_cancel₀ ( ne_of_gt ( pow_pos ( zero_lt_two' ℝ ) L ) ), + pow_le_pow_right₀ ( by norm_num : ( 1 : ℝ ) ≤ 2 ) ( show L ≥ 0 by norm_num ) ]; + · exact + ⟨ hD.le, + mul_le_of_le_one_right hD.le + ( by linarith [ inv_le_one_of_one_le₀ ( one_le_pow₀ + ( by norm_num : ( 1 : ℝ ) ≤ 2 ) : ( 1 : ℝ ) ≤ 2 ^ L ) ] ) ⟩; convert h_integral_bound using 1 ; norm_num [ Real.rpow_add, Real.rpow_neg ] ; ring_nf; exact Or.inl ( mul_le_mul_of_nonneg_left ( by norm_num ) ( by positivity ) ); have hp1 : (2:ℝ) ^ (-((L:ℝ) + 1)) = 2 ^ (-(L:ℝ)) / 2 := by @@ -937,7 +1130,8 @@ lemma dudley_analytical_sum_bound /- If `u` is a centered `δ`-net, it is also a centered `δ'`-net for `δ ≤ δ'`. -/ -lemma IsSubsetENet_mono {α : Type*} [PseudoMetricSpace α] {T : Set α} {u : Set α} {δ δ' : ℝ} (h : δ ≤ δ') (hu : IsSubsetENet T u δ) : +lemma IsSubsetENet_mono {α : Type*} [PseudoMetricSpace α] {T : Set α} {u : Set α} {δ δ' : ℝ} + (h : δ ≤ δ') (hu : IsSubsetENet T u δ) : IsSubsetENet T u δ' := by obtain ⟨hfin, hnet⟩ := hu.2 exact ⟨hu.1, hfin, hnet.mono_eps h⟩ @@ -945,13 +1139,15 @@ lemma IsSubsetENet_mono {α : Type*} [PseudoMetricSpace α] {T : Set α} {u : Se /- If a finite centered net exists for the smaller radius, `subsetENetCard` is non-increasing. -/ -lemma subsetENetCard_le_of_le {α : Type*} [PseudoMetricSpace α] {T : Set α} {δ δ' : ℝ} (h : δ ≤ δ') (h_ex : ∃ u : Set α, IsSubsetENet T u δ ∧ u.Finite) : +lemma subsetENetCard_le_of_le {α : Type*} [PseudoMetricSpace α] {T : Set α} {δ δ' : ℝ} (h : δ ≤ δ') + (h_ex : ∃ u : Set α, IsSubsetENet T u δ ∧ u.Finite) : subsetENetCard T δ' ≤ subsetENetCard T δ := by set S := fun r => {n : ℕ | ∃ u : Finset α, IsSubsetENet T u r ∧ u.card = n} with hS_def have hS_nonempty : S δ ≠ ∅ := by - rcases h_ex with ⟨ u, hu₁, hu₂ ⟩ ; exact Set.Nonempty.ne_empty ⟨ _, ⟨ hu₂.toFinset, by simpa using hu₁, rfl ⟩ ⟩ ; - refine' le_csInf _ _; + rcases h_ex with ⟨ u, hu₁, hu₂ ⟩ ; + exact Set.Nonempty.ne_empty ⟨ _, ⟨ hu₂.toFinset, by simpa using hu₁, rfl ⟩ ⟩ ; + refine le_csInf ?_ ?_; · exact Set.nonempty_iff_ne_empty.2 hS_nonempty; · rintro n ⟨ u, hu, rfl ⟩; exact Nat.sInf_le ⟨ u, IsSubsetENet_mono h hu, rfl ⟩ @@ -1045,27 +1241,21 @@ lemma exists_dudley_chain_consistent refine ⟨fun m => if m ≤ M then {cstar} else U_seq₀ m, fun m u => if m ≤ M then cstar else pi_map₀ m u, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ - · - intro m; dsimp only; split_ifs <;> [exact Set.finite_singleton _; exact hUf₀ m] - · - intro m; dsimp only; split_ifs + · intro m; dsimp only; split_ifs <;> [exact Set.finite_singleton _; exact hUf₀ m] + · intro m; dsimp only; split_ifs · exact Set.singleton_subset_iff.mpr hcstar_T · exact hUs₀ m - · - dsimp only; rw [ite_eq_right (not_le.mpr hM_lt)]; exact hUL₀ - · - intro m hm; dsimp only; split_ifs with h + · dsimp only; rw [ite_eq_right (not_le.mpr hM_lt)]; exact hUL₀ + · intro m hm; dsimp only; split_ifs with h · rw [Set.ncard_singleton]; exact (h_all_sing m h hm).symm · exact hUn₀ m hm - · - intro m hm; dsimp only; split_ifs with h + · intro m hm; dsimp only; split_ifs with h · exact IsSubsetENet.of_exists_dist (Set.finite_singleton cstar) (Set.singleton_subset_iff.mpr hcstar_T) (fun x hx => ⟨cstar, Set.mem_singleton _, le_trans (hcstar_cov x hx) (h_eps_antitone m M h)⟩) · exact hUc₀ m hm - · - intro m hm u hu; dsimp only at hu ⊢ + · intro m hm u hu; dsimp only at hu ⊢ by_cases hm_le : m ≤ M · simp only [ite_eq_left hm_le] constructor @@ -1079,8 +1269,7 @@ lemma exists_dudley_chain_consistent · simp only [ite_eq_right hm_le] have hm1_gt : ¬(m + 1 ≤ M) := fun h => hm_le (by omega) simp only [ite_eq_right hm1_gt] at hu; exact hUp₀ m hm u hu - · - intro m hm hN u hu; dsimp only at hu ⊢ + · intro m hm hN u hu; dsimp only at hu ⊢ have hm1_le_M : m + 1 ≤ M := by by_contra h; push Not at h; exact hM_max (m + 1) h hm hN simp only [ite_eq_left (show m ≤ M by omega), ite_eq_left hm1_le_M] at hu ⊢ @@ -1118,12 +1307,15 @@ lemma sub_gaussian_max_diff_bound set ι := {p : α × α | p.1 ∈ U ∧ p.2 ∈ U}; - have h_metric_entropy : ∫ ω, (⨆ p : ι, (X ω p.val.1) - (X ω p.val.2)) ∂μ ≤ Real.sqrt (2 * σ_sq * Real.log (ι.ncard)) := by - have h_card : ∫ ω, (⨆ p : ι, (X ω p.val.1 - X ω p.val.2)) ∂μ ≤ Real.sqrt (2 * σ_sq * Real.log (Nat.card ι)) := by + have h_metric_entropy : ∫ ω, (⨆ p : ι, (X ω p.val.1) - (X ω p.val.2)) ∂μ ≤ + Real.sqrt (2 * σ_sq * Real.log (ι.ncard)) := by + have h_card : ∫ ω, (⨆ p : ι, (X ω p.val.1 - X ω p.val.2)) ∂μ ≤ + Real.sqrt (2 * σ_sq * Real.log (Nat.card ι)) := by have h_finite : Finite ι := by exact Set.Finite.to_subtype ( hU_fin.prod hU_fin ) have h_nonempty : Nonempty ι := by - exact ⟨ ⟨ hU_nonempty.some, hU_nonempty.some ⟩, hU_nonempty.choose_spec, hU_nonempty.choose_spec ⟩ + exact ⟨ ⟨ hU_nonempty.some, hU_nonempty.some ⟩, hU_nonempty.choose_spec, + hU_nonempty.choose_spec ⟩ convert metric_entropy_bound_for_sub_gaussian_maxima_fintype _ _; all_goals try assumption; convert Nat.card_eq_fintype_card; @@ -1139,31 +1331,55 @@ lemma sub_gaussian_max_diff_bound · exact ⟨ i ⟩; · intro x; rw [ @ciSup_eq_ite ]; - split_ifs <;> [ exact le_ciSup ( show BddAbove ( Set.range fun p : { p : α × α // p.1 ∈ U ∧ p.2 ∈ U } => X _ p.val.1 - X _ p.val.2 ) from by - exact Set.Finite.bddAbove ( Set.Finite.subset ( hU_fin.prod hU_fin |> Set.Finite.image fun p : α × α => X ‹_› p.1 - X ‹_› p.2 ) fun p hp => by + split_ifs <;> + [ exact le_ciSup + ( show BddAbove ( Set.range fun p : { p : α × α // p.1 ∈ U ∧ p.2 ∈ U } => + X _ p.val.1 - X _ p.val.2 ) from by + exact + Set.Finite.bddAbove + ( Set.Finite.subset ( hU_fin.prod hU_fin |> + Set.Finite.image fun p : α × α => X ‹_› p.1 - + X ‹_› p.2 ) fun p hp => by rcases hp with ⟨q, rfl⟩ - exact ⟨q.1, ⟨q.2.1, q.2.2⟩, rfl⟩ ) ) ⟨ ( i, x ), hi, by assumption ⟩ ; exact le_trans ( by norm_num ) ( Real.sSup_nonneg _ fun p hp => by unreachable! ) ]; - refine' le_trans _ ( le_ciSup _ ⟨ ( i, i ), hi, hi ⟩ ) ; norm_num; - exact Set.Finite.bddAbove ( Set.Finite.subset ( Set.Finite.image ( fun p : α × α => X ‹_› p.1 - X ‹_› p.2 ) ( hU_fin.prod hU_fin ) ) fun p hp => by + exact ⟨q.1, ⟨q.2.1, q.2.2⟩, rfl⟩ ) ) + ⟨ ( i, x ), hi, by assumption ⟩ ; + exact le_trans ( by norm_num ) + ( Real.sSup_nonneg _ fun p hp => + by unreachable! ) ]; + refine le_trans ?_ ( le_ciSup ?_ ⟨ ( i, i ), hi, hi ⟩ ) ; norm_num; + exact Set.Finite.bddAbove + ( Set.Finite.subset ( Set.Finite.image ( fun p : α × α => X ‹_› p.1 - X ‹_› p.2 ) + ( hU_fin.prod hU_fin ) ) fun p hp => by rcases hp with ⟨q, rfl⟩ exact ⟨q, ⟨q.2.1, q.2.2⟩, rfl⟩ ); - · refine' le_trans _ ( le_ciSup _ ⟨ ( hU_nonempty.some, hU_nonempty.some ), hU_nonempty.choose_spec, hU_nonempty.choose_spec ⟩ ) ; norm_num; - exact Set.Finite.bddAbove ( Set.Finite.subset ( hU_fin.prod hU_fin |> Set.Finite.image fun p : α × α => X ‹_› p.1 - X ‹_› p.2 ) fun x hx => by + · refine le_trans ?_ + ( le_ciSup ?_ ⟨ ( hU_nonempty.some, hU_nonempty.some ), hU_nonempty.choose_spec, + hU_nonempty.choose_spec ⟩ ) ; norm_num; + exact Set.Finite.bddAbove + ( Set.Finite.subset ( hU_fin.prod hU_fin |> Set.Finite.image fun p : α × α => + X ‹_› p.1 - X ‹_› p.2 ) fun x hx => by rcases hx with ⟨q, rfl⟩ exact ⟨q, ⟨q.2.1, q.2.2⟩, rfl⟩ ); · intro w hw obtain ⟨p, hp⟩ : ∃ p : ι, w < X ‹_› p.val.1 - X ‹_› p.val.2 := by contrapose! hw; convert ciSup_le _; - · exact ⟨ ⟨ ⟨ hU_nonempty.some, hU_nonempty.some ⟩, hU_nonempty.choose_spec, hU_nonempty.choose_spec ⟩ ⟩; + · exact ⟨ ⟨ ⟨ hU_nonempty.some, hU_nonempty.some ⟩, hU_nonempty.choose_spec, + hU_nonempty.choose_spec ⟩ ⟩; · exact hw; use p.val.1; rw [ ciSup_pos ]; - · refine' lt_of_lt_of_le hp ( le_trans _ ( le_ciSup _ p.val.2 ) ); - · exact le_ciSup ⟨X ‹_› p.val.1 - X ‹_› p.val.2, Set.forall_mem_range.2 fun _ => le_rfl⟩ p.2.2 - · refine' ⟨ ∑ v ∈ hU_fin.toFinset, |X ‹_› p.val.1 - X ‹_› v|, Set.forall_mem_range.2 fun v => _ ⟩; + · refine lt_of_lt_of_le hp ( le_trans ?_ ( le_ciSup ?_ p.val.2 ) ); + · exact le_ciSup ⟨X ‹_› p.val.1 - X ‹_› p.val.2, Set.forall_mem_range.2 fun _ => + le_rfl⟩ p.2.2 + · refine ⟨ ∑ v ∈ hU_fin.toFinset, |X ‹_› p.val.1 - X ‹_› v|, + Set.forall_mem_range.2 fun v => ?_ ⟩; rw [ @ciSup_eq_ite ]; - split_ifs <;> [ exact le_trans ( le_abs_self _ ) ( Finset.single_le_sum ( fun a _ => abs_nonneg ( X ‹_› p.val.1 - X ‹_› a ) ) ( hU_fin.mem_toFinset.mpr ‹_› ) ) ; exact le_trans ( by norm_num ) ( Finset.sum_nonneg fun a _ => abs_nonneg _ ) ]; + split_ifs <;> + [ exact le_trans ( le_abs_self _ ) + ( Finset.single_le_sum ( fun a _ => abs_nonneg ( X ‹_› p.val.1 - X ‹_› a ) ) + ( hU_fin.mem_toFinset.mpr ‹_› ) ) ; + exact le_trans ( by norm_num ) ( Finset.sum_nonneg fun a _ => abs_nonneg _ ) ]; · exact p.2.1; · rw [ show ι = U ×ˢ U by ext x; simp [ι, Set.mem_prod], Set.ncard_prod ] ; simp +decide [ sq ] @@ -1175,7 +1391,7 @@ lemma IsSubGaussian_mono {α : Type*} [MeasurableSpace α] (h : IsSubGaussian X σ_sq μ) (hle : σ_sq ≤ σ_sq') : IsSubGaussian X σ_sq' μ := by obtain ⟨ h₁, h₂ ⟩ := h; - refine' ⟨ _, _ ⟩; + refine ⟨ ?_, ?_ ⟩; linarith; constructor; · intro t; @@ -1186,7 +1402,8 @@ lemma IsSubGaussian_mono {α : Type*} [MeasurableSpace α] exact hle ) ) /- -For a symmetric nonempty bounded set of reals, the supremum of the absolute values equals the supremum of the values. +For a symmetric nonempty bounded set of reals, + the supremum of the absolute values equals the supremum of the values. -/ lemma sSup_abs_eq_sSup_of_symmetric {S : Set ℝ} (hS_nonempty : S.Nonempty) (hS_bdd : BddAbove S) @@ -1194,30 +1411,48 @@ lemma sSup_abs_eq_sSup_of_symmetric sSup (Set.image abs S) = sSup S := by rw [ @csSup_eq_of_forall_le_of_forall_lt_exists_gt ]; · exact hS_nonempty.image _; - · rintro _ ⟨ x, hx, rfl ⟩ ; cases abs_cases x <;> linarith [ le_csSup hS_bdd hx, le_csSup hS_bdd ( hS_symm x hx ) ] ; + · rintro _ ⟨ x, hx, rfl ⟩ ; cases abs_cases x <;> + linarith [ le_csSup hS_bdd hx, le_csSup hS_bdd ( hS_symm x hx ) ] ; · intro w hw; rcases exists_lt_of_lt_csSup hS_nonempty hw with ⟨ x, hx₁, hx₂ ⟩; exact ⟨ |x|, Set.mem_image_of_mem _ hx₁, by cases abs_cases x <;> linarith ⟩ /- -For a finite nonempty set S, the maximum absolute difference of f on S equals the maximum difference of f on S. +For a finite nonempty set S, the maximum absolute difference of f on S equals the maximum difference + of f on S. -/ -lemma sup_abs_diff_eq_sup_diff_finite {α : Type*} {f : α → ℝ} (S : Set α) (hS : S.Finite) (hS_nonempty : S.Nonempty) : +lemma sup_abs_diff_eq_sup_diff_finite {α : Type*} {f : α → ℝ} (S : Set α) (hS : S.Finite) + (hS_nonempty : S.Nonempty) : (⨆ u ∈ S, ⨆ v ∈ S, |f u - f v|) = (⨆ u ∈ S, ⨆ v ∈ S, f u - f v) := by set D := {d : ℝ | ∃ u ∈ S, ∃ v ∈ S, d = f u - f v} with hD; have hD_bounded : BddAbove D ∧ BddBelow D := by - exact ⟨ ⟨ ∑ u ∈ hS.toFinset, |f u| + ∑ u ∈ hS.toFinset, |f u|, by rintro x ⟨ u, hu, v, hv, rfl ⟩ ; cases abs_cases ( f u ) <;> cases abs_cases ( f v ) <;> linarith [ Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hu ), Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hv ) ] ⟩, ⟨ - ( ∑ u ∈ hS.toFinset, |f u| + ∑ u ∈ hS.toFinset, |f u| ), by rintro x ⟨ u, hu, v, hv, rfl ⟩ ; cases abs_cases ( f u ) <;> cases abs_cases ( f v ) <;> linarith [ Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hu ), Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hv ) ] ⟩ ⟩; + exact ⟨ ⟨ ∑ u ∈ hS.toFinset, |f u| + ∑ u ∈ hS.toFinset, |f u|, by + rintro x ⟨ u, hu, v, hv, rfl ⟩ ; cases abs_cases ( f u ) <;> cases abs_cases ( f v ) <;> + linarith [ + Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hu ), + Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) + ( hS.mem_toFinset.mpr hv ) ] ⟩, + ⟨ - ( ∑ u ∈ hS.toFinset, |f u| + ∑ u ∈ hS.toFinset, |f u| ), by + rintro x ⟨ u, hu, v, hv, rfl ⟩ ; cases abs_cases ( f u ) <;> cases abs_cases ( f v ) <;> + linarith [ + Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) ( hS.mem_toFinset.mpr hu ), + Finset.single_le_sum ( fun a _ => abs_nonneg ( f a ) ) + ( hS.mem_toFinset.mpr hv ) ] ⟩ ⟩; have hD_abs_eq_D : sSup (Set.image abs D) = sSup D := by apply_rules [ sSup_abs_eq_sSup_of_symmetric ]; - · exact ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl ⟩ ⟩; + · exact ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl ⟩ ⟩; · exact hD_bounded.1; · rintro _ ⟨ u, hu, v, hv, rfl ⟩ ; exact ⟨ v, hv, u, hu, by ring ⟩; convert hD_abs_eq_D using 1; · rw [ @csSup_eq_of_forall_le_of_forall_lt_exists_gt ]; - · exact ⟨ _, ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl ⟩, rfl ⟩ ⟩; + · exact + ⟨ _, + ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl ⟩, rfl ⟩ ⟩; · simp +zetaDelta at *; intro a x u hu v hv; subst hv; exact finite_sup_bound hS f x u hu v; · intro w hw; @@ -1231,33 +1466,50 @@ lemma sup_abs_diff_eq_sup_diff_finite {α : Type*} {f : α → ℝ} (S : Set α) · exact ⟨ x ⟩; · intro y; rw [ @ciSup_eq_ite ] ; split_ifs with h; · exact hw _ ⟨_, ⟨x, hx, y, h, rfl⟩, rfl⟩; - · simp only [Real.sSup_empty]; exact le_trans (abs_nonneg _) (hw _ ⟨_, ⟨hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl⟩, rfl⟩); + · simp only [Real.sSup_empty]; + exact le_trans (abs_nonneg _) + (hw _ + ⟨_, ⟨hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl⟩, rfl⟩); · simp +decide [ Real.sSup_empty ]; - exact le_trans ( abs_nonneg _ ) ( hw _ ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl ⟩, rfl ⟩ ); + exact le_trans ( abs_nonneg _ ) + ( hw _ ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl ⟩, rfl ⟩ ); · convert ( ciSup_eq_of_forall_le_of_forall_lt_exists_gt _ _ ); · exact ⟨ hS_nonempty.some ⟩; · intro u; by_cases hu : u ∈ S <;> simp +decide [ hu ] ; · convert ciSup_le fun v => ?_; · exact ⟨ u ⟩; · rw [ @ciSup_eq_ite ]; - split_ifs <;> [ exact le_csSup hD_bounded.1 ⟨ u, hu, v, ‹_›, rfl ⟩ ; exact le_trans ( by norm_num ) ( show 0 ≤ sSup D from le_trans ( by norm_num ) ( le_csSup hD_bounded.1 ⟨ u, hu, u, hu, rfl ⟩ ) ) ]; - · exact le_trans ( by norm_num ) ( le_csSup hD_bounded.1 ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl ⟩ ); + split_ifs <;> [ exact le_csSup hD_bounded.1 ⟨ u, hu, v, ‹_›, rfl ⟩ ; + exact le_trans ( by norm_num ) ( show 0 ≤ sSup D from + le_trans ( by norm_num ) ( le_csSup hD_bounded.1 ⟨ u, hu, u, hu, rfl ⟩ ) ) ]; + · exact le_trans ( by norm_num ) + ( le_csSup hD_bounded.1 ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl ⟩ ); · intro w hw; - rcases exists_lt_of_lt_csSup ( show D.Nonempty from ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, hS_nonempty.choose_spec, rfl ⟩ ⟩ ) hw with ⟨ d, ⟨ u, hu, v, hv, rfl ⟩, hd ⟩; + rcases exists_lt_of_lt_csSup ( show D.Nonempty from + ⟨ _, ⟨ hS_nonempty.some, hS_nonempty.choose_spec, hS_nonempty.some, + hS_nonempty.choose_spec, rfl ⟩ ⟩ ) hw with ⟨ d, ⟨ u, hu, v, hv, rfl ⟩, hd ⟩; use u; simp +decide [ hu ]; - refine' lt_of_lt_of_le hd ( le_trans _ ( le_ciSup _ v ) ); + refine lt_of_lt_of_le hd ( le_trans ?_ ( le_ciSup ?_ v ) ); · exact le_ciSup ⟨f u - f v, Set.forall_mem_range.2 fun _ => le_rfl⟩ hv; - · refine' ⟨ ∑ x ∈ hS.toFinset, |f u - f x|, Set.forall_mem_range.2 fun x => _ ⟩; + · refine ⟨ ∑ x ∈ hS.toFinset, |f u - f x|, Set.forall_mem_range.2 fun x => ?_ ⟩; rw [ @ciSup_eq_ite ]; - split_ifs <;> [ exact le_trans ( le_abs_self _ ) ( Finset.single_le_sum ( fun x _ => abs_nonneg ( f u - f x ) ) ( hS.mem_toFinset.mpr ‹_› ) ) ; exact le_trans ( by norm_num ) ( Finset.sum_nonneg fun x _ => abs_nonneg _ ) ] + split_ifs <;> + [ exact le_trans ( le_abs_self _ ) + ( Finset.single_le_sum ( fun x _ => abs_nonneg ( f u - f x ) ) + ( hS.mem_toFinset.mpr ‹_› ) ) ; + exact le_trans ( by norm_num ) ( Finset.sum_nonneg fun x _ => abs_nonneg _ ) ] /- Bound for the base case of the Dudley chain (U_1). -/ lemma dudley_base_bound {α : Type*} [PseudoMetricSpace α] - {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] + {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} + [MeasureTheory.IsProbabilityMeasure μ] {T : Set α} {X : Ω → α → ℝ} {D : ℝ} (hD : 0 ≤ D) @@ -1266,18 +1518,22 @@ lemma dudley_base_bound (hU_card : U.ncard ≤ subsetENetCard T (D / 2)) (h_diam : ∀ u ∈ U, ∀ v ∈ U, dist u v ≤ D) : - ∫ ω, (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) ∂μ ≤ 2 * D * Real.sqrt (Real.log (subsetENetCard T (D / 2))) := by + ∫ ω, (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) ∂μ ≤ 2 * D * + Real.sqrt (Real.log (subsetENetCard T (D / 2))) := by by_contra h_contra; - have h_sub_gaussian_max_diff_bound : ∫ ω, (⨆ u ∈ U, ⨆ v ∈ U, X ω u - X ω v) ∂μ ≤ Real.sqrt (2 * D^2 * Real.log (U.ncard^2)) := by + have h_sub_gaussian_max_diff_bound : ∫ ω, (⨆ u ∈ U, ⨆ v ∈ U, X ω u - X ω v) ∂μ ≤ + Real.sqrt (2 * D^2 * Real.log (U.ncard^2)) := by convert sub_gaussian_max_diff_bound hU_finite hU_nonempty _ _ using 1; · exact borel α; · infer_instance; · positivity; - · exact fun u hu v hv => IsSubGaussian_mono ( h_sg u ( hU_subset hu ) v ( hU_subset hv ) ) ( pow_le_pow_left₀ ( dist_nonneg ) ( h_diam u hu v hv ) 2 ); - refine' h_contra ( le_trans _ ( h_sub_gaussian_max_diff_bound.trans _ ) ); - · - have h_abs_eq_sup : ∀ ω, (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) = (⨆ u ∈ U, ⨆ v ∈ U, X ω u - X ω v) := by + · exact fun u hu v hv => + IsSubGaussian_mono ( h_sg u ( hU_subset hu ) v ( hU_subset hv ) ) + ( pow_le_pow_left₀ ( dist_nonneg ) ( h_diam u hu v hv ) 2 ); + refine h_contra ( le_trans ?_ ( h_sub_gaussian_max_diff_bound.trans ?_ ) ); + · have h_abs_eq_sup : ∀ ω, (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) = + (⨆ u ∈ U, ⨆ v ∈ U, X ω u - X ω v) := by exact fun ω => sup_abs_diff_eq_sup_diff_finite U hU_finite hU_nonempty; simp +decide only [h_abs_eq_sup]; rfl; @@ -1298,14 +1554,18 @@ Inequality for logarithms used in Dudley's bound. lemma log_inequality_for_dudley (N : ℕ) (hN : 2 ≤ N) : Real.sqrt (2 * Real.log (2 * N)) ≤ 2 * Real.sqrt (Real.log N) := by rw [ Real.sqrt_le_left ] <;> ring_nf <;> norm_num; - rw [ Real.sq_sqrt ( Real.log_nonneg ( by norm_cast; linarith ) ) ] ; rw [ Real.log_mul ( by positivity ) ( by positivity ) ] ; ring_nf ; nlinarith [ Real.log_two_gt_d9, Real.log_le_log ( by positivity ) ( show ( N :ℝ ) ≥ 2 by norm_cast ) ] ; + rw [ Real.sq_sqrt ( Real.log_nonneg ( by norm_cast; linarith ) ) ] ; + rw [ Real.log_mul ( by positivity ) ( by positivity ) ] ; ring_nf ; + nlinarith [ Real.log_two_gt_d9, Real.log_le_log ( by positivity ) ( show ( N :ℝ ) ≥ + 2 by norm_cast ) ] ; /- Bound for a single step in the Dudley chain. -/ lemma dudley_step_bound {α : Type*} [PseudoMetricSpace α] - {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] + {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} + [MeasureTheory.IsProbabilityMeasure μ] {T : Set α} {X : Ω → α → ℝ} (h_sg : ∀ x ∈ T, ∀ y ∈ T, IsSubGaussian (fun ω => X ω x - X ω y) (dist x y ^ 2) μ) @@ -1320,22 +1580,39 @@ lemma dudley_step_bound (h_card : U_next.ncard ≤ subsetENetCard T (eps / 2)) (h_consistent : subsetENetCard T (eps / 2) = 1 → ∀ u ∈ U_next, u = pi_map u) : - ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ 4 * eps * Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by + ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ 4 * eps * + Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by have h_exp_bound : ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ eps * Real.sqrt (2 * Real.log (U_next.ncard)) + eps * Real.sqrt (2 * Real.log 2) := by apply_rules [ expectation_bound_chain_step ]; by_cases h_card_ge_two : 2 ≤ subsetENetCard T (eps / 2); - · - have h_log_ineq : Real.sqrt (2 * Real.log (U_next.ncard)) + Real.sqrt (2 * Real.log 2) ≤ 4 * Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by - have h_log_ineq : Real.sqrt (2 * Real.log (U_next.ncard)) ≤ Real.sqrt (2 * Real.log (subsetENetCard T (eps / 2))) := by + · have h_log_ineq : Real.sqrt (2 * Real.log (U_next.ncard)) + Real.sqrt (2 * Real.log 2) ≤ + 4 * Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by + have h_log_ineq : Real.sqrt (2 * Real.log (U_next.ncard)) ≤ + Real.sqrt (2 * Real.log (subsetENetCard T (eps / 2))) := by by_cases hU_next_empty : U_next.ncard = 0; · simp [hU_next_empty]; - · exact Real.sqrt_le_sqrt <| mul_le_mul_of_nonneg_left ( Real.log_le_log ( Nat.cast_pos.mpr <| Nat.pos_of_ne_zero hU_next_empty ) <| Nat.cast_le.mpr h_card ) zero_le_two; - have h_log_ineq : Real.sqrt (2 * Real.log 2) ≤ 2 * Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by + · exact Real.sqrt_le_sqrt <| + mul_le_mul_of_nonneg_left + ( Real.log_le_log ( Nat.cast_pos.mpr <| Nat.pos_of_ne_zero hU_next_empty ) <| + Nat.cast_le.mpr h_card ) zero_le_two; + have h_log_ineq : Real.sqrt (2 * Real.log 2) ≤ 2 * + Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by rw [ Real.sqrt_le_iff ]; - exact ⟨ by positivity, by rw [ mul_pow, Real.sq_sqrt ( Real.log_nonneg ( mod_cast h_card_ge_two.trans' ( by norm_num ) ) ) ] ; nlinarith [ Real.log_pos one_lt_two, Real.log_le_log ( by positivity ) ( show ( subsetENetCard T ( eps / 2 ) : ℝ ) ≥ 2 by norm_cast ) ] ⟩; - linarith [ show Real.sqrt ( 2 * Real.log ( subsetENetCard T ( eps / 2 ) ) ) ≤ 2 * Real.sqrt ( Real.log ( subsetENetCard T ( eps / 2 ) ) ) by rw [ Real.sqrt_mul ( by positivity ) ] ; nlinarith [ Real.sqrt_nonneg 2, Real.sqrt_nonneg ( Real.log ( subsetENetCard T ( eps / 2 ) ) ), Real.mul_self_sqrt ( show 0 ≤ 2 by positivity ), Real.mul_self_sqrt ( show 0 ≤ Real.log ( subsetENetCard T ( eps / 2 ) ) by exact Real.log_nonneg ( by norm_cast; linarith ) ) ] ]; + exact ⟨ by positivity, by + rw [ mul_pow, Real.sq_sqrt + ( Real.log_nonneg ( mod_cast h_card_ge_two.trans' ( by norm_num ) ) ) ] ; + nlinarith [ Real.log_pos one_lt_two, Real.log_le_log ( by positivity ) + ( show ( subsetENetCard T ( eps / 2 ) : ℝ ) ≥ 2 by norm_cast ) ] ⟩; + linarith [ show Real.sqrt ( 2 * Real.log ( subsetENetCard T ( eps / 2 ) ) ) ≤ + 2 * Real.sqrt ( Real.log ( subsetENetCard T ( eps / 2 ) ) ) by + rw [ Real.sqrt_mul ( by positivity ) ] ; + nlinarith [ Real.sqrt_nonneg 2, + Real.sqrt_nonneg ( Real.log ( subsetENetCard T ( eps / 2 ) ) ), + Real.mul_self_sqrt ( show 0 ≤ 2 by positivity ), + Real.mul_self_sqrt ( show 0 ≤ Real.log ( subsetENetCard T ( eps / 2 ) ) by + exact Real.log_nonneg ( by norm_cast; linarith ) ) ] ]; nlinarith; · interval_cases _ : subsetENetCard T ( eps / 2 ) <;> simp +decide at h_card ⊢; · simp_all +decide [ Set.ncard_def ]; @@ -1343,7 +1620,7 @@ lemma dudley_step_bound filter_upwards [ ] with; by_cases hU_nonempty : U_next.Nonempty · have : Nonempty α := ⟨hU_nonempty.some⟩ - refine' le_antisymm _ _; + refine le_antisymm ?_ ?_; · apply ciSup_le intro u rw [ ciSup_eq_ite ] @@ -1363,16 +1640,21 @@ lemma dudley_sum_bound (L : ℕ) (hL : 1 ≤ L) : ∑ k ∈ Finset.range (L - 1), 4 * (D * 2 ^ (-(k + 1 : ℝ))) * f (D * 2 ^ (-(k + 2 : ℝ))) ≤ 16 * ∫ x in Set.Icc (D * 2 ^ (-(L + 1 : ℝ))) (D * 2 ^ (-2 : ℝ)), f x := by - convert dudley_analytical_sum_bound _ _ _ using 1 <;> norm_num [ mul_assoc, mul_comm, mul_left_comm ]; + convert dudley_analytical_sum_bound _ _ _ using 1 <;> + norm_num [ mul_assoc, mul_comm, mul_left_comm ]; rotate_left; rotate_left; use fun x => f ( x / 2 ); exact D; any_goals exact L - 1; · exact hD; - · exact fun x hx y hy hxy => hf_antitone ⟨ by linarith [ hx.1 ], by linarith [ hx.2 ] ⟩ ⟨ by linarith [ hy.1 ], by linarith [ hy.2 ] ⟩ ( by linarith ); + · exact fun x hx y hy hxy => hf_antitone ⟨ by linarith [ hx.1 ], by linarith [ hx.2 ] ⟩ + ⟨ by linarith [ hy.1 ], by linarith [ hy.2 ] ⟩ ( by linarith ); · norm_num [ Real.rpow_add, Real.rpow_neg ] ; ring_nf; - · rw [ MeasureTheory.integral_Icc_eq_integral_Ioc, MeasureTheory.integral_Icc_eq_integral_Ioc ] ; rw [ ← intervalIntegral.integral_of_le, ← intervalIntegral.integral_of_le ] <;> norm_num [ Real.rpow_add, Real.rpow_neg ] <;> ring_nf <;> norm_num [ hD.le ] ; + · rw [ MeasureTheory.integral_Icc_eq_integral_Ioc, + MeasureTheory.integral_Icc_eq_integral_Ioc ] ; + rw [ ← intervalIntegral.integral_of_le, ← intervalIntegral.integral_of_le ] <;> + norm_num [ Real.rpow_add, Real.rpow_neg ] <;> ring_nf <;> norm_num [ hD.le ] ; · cases L <;> norm_num [ pow_succ' ] at * ; ring_nf at *; · exact mul_le_of_le_one_right hD.le ( pow_le_one₀ ( by norm_num ) ( by norm_num ) ); · nlinarith [ pow_le_pow_of_le_one ( by norm_num : ( 0 : ℝ ) ≤ 1 / 2 ) ( by norm_num ) hL ] @@ -1393,18 +1675,22 @@ lemma dudley_base_bound_integral apply_rules [ subsetENetCard_antitoneOn_Ioc ]; intro x hx y hy hxy; simp +zetaDelta at *; - by_cases h : subsetENetCard T y = 0 <;> by_cases h' : subsetENetCard T x = 0 <;> simp_all +decide; + by_cases h : subsetENetCard T y = 0 <;> by_cases h' : subsetENetCard T x = 0 <;> + simp_all +decide; · exact False.elim <| by simpa [h, h'] using hf_antitone ⟨hx.1, hx.2⟩ ⟨hy.1, hy.2⟩ hxy - · exact Real.sqrt_le_sqrt ( Real.log_le_log ( Nat.cast_pos.mpr ( Nat.pos_of_ne_zero h ) ) ( Nat.cast_le.mpr ( hf_antitone ⟨ hx.1, hx.2 ⟩ ⟨ hy.1, hy.2 ⟩ hxy ) ) ); - - have h_integral_bound : ∫ x in Set.Icc (D / 4) (D / 2), f x ≥ ∫ x in Set.Icc (D / 4) (D / 2), f (D / 2) := by - refine' MeasureTheory.setIntegral_mono_on _ _ _ _ <;> norm_num; - · - have hf_antitone_on : AntitoneOn f (Set.Icc (D / 4) (D / 2)) := by + · exact Real.sqrt_le_sqrt + ( Real.log_le_log ( Nat.cast_pos.mpr ( Nat.pos_of_ne_zero h ) ) + ( Nat.cast_le.mpr ( hf_antitone ⟨ hx.1, hx.2 ⟩ ⟨ hy.1, hy.2 ⟩ hxy ) ) ); + + have h_integral_bound : ∫ x in Set.Icc (D / 4) (D / 2), f x ≥ + ∫ x in Set.Icc (D / 4) (D / 2), f (D / 2) := by + refine MeasureTheory.setIntegral_mono_on ?_ ?_ ?_ ?_ <;> norm_num; + · have hf_antitone_on : AntitoneOn f (Set.Icc (D / 4) (D / 2)) := by exact hf_antitone.mono ( fun x hx => ⟨ by linarith [ hx.1 ], by linarith [ hx.2 ] ⟩ ); exact ( hf_antitone_on.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) ); - · intro x hx₁ hx₂; exact hf_antitone ⟨ by linarith, by linarith ⟩ ⟨ by linarith, by linarith ⟩ ( by linarith ) ; + · intro x hx₁ hx₂; exact hf_antitone ⟨ by linarith, by linarith ⟩ + ⟨ by linarith, by linarith ⟩ ( by linarith ) ; have hlen : max (D / 2 - D / 4) 0 = D / 4 := by rw [max_eq_left] · ring_nf @@ -1426,21 +1712,35 @@ lemma dudley_term_bound 4 * (D * 2 ^ (-(k + 1 : ℝ))) * f (D * 2 ^ (-(k + 2 : ℝ))) ≤ 16 * ∫ x in Set.Icc (D * 2 ^ (-(k + 3 : ℝ))) (D * 2 ^ (-(k + 2 : ℝ))), f x := by - have h_int_le : ∫ x in (Set.Icc (D * 2 ^ (-(k + 3 : ℝ))) (D * 2 ^ (-(k + 2 : ℝ)))), f x ≥ ∫ x in (Set.Icc (D * 2 ^ (-(k + 3 : ℝ))) (D * 2 ^ (-(k + 2 : ℝ)))), f (D * 2 ^ (-(k + 2 : ℝ))) := by - refine' MeasureTheory.setIntegral_mono_on _ _ _ _ <;> norm_num; - · refine' ( hf_antitone.mono _ ) |> fun h => h.integrableOn_isCompact ( CompactIccSpace.isCompact_Icc ) |> fun h => h.mono_set ( Set.Icc_subset_Icc _ _ ); - exact fun ⦃a⦄ a => a; + have h_int_le : ∫ x in (Set.Icc (D * 2 ^ (-(k + 3 : ℝ))) (D * 2 ^ (-(k + 2 : ℝ)))), f x ≥ + ∫ x in (Set.Icc (D * 2 ^ (-(k + 3 : ℝ))) (D * 2 ^ (-(k + 2 : ℝ)))), + f (D * 2 ^ (-(k + 2 : ℝ))) := by + refine MeasureTheory.setIntegral_mono_on ?_ ?_ ?_ ?_ <;> norm_num; + · refine ( hf_antitone.integrableOn_isCompact CompactIccSpace.isCompact_Icc ).mono_set + ( Set.Icc_subset_Icc ?_ ?_ ); · positivity; - · exact mul_le_of_le_one_right hD.le ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ); + · exact mul_le_of_le_one_right hD.le + ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ); · intro x hx₁ hx₂; apply_rules [ hf_antitone ] ; ring_nf at *; norm_num at *; - · exact ⟨ le_trans ( by positivity ) hx₁, le_trans hx₂ ( mul_le_of_le_one_right ( by positivity ) ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ) ⟩; - · exact ⟨ by positivity, by exact mul_le_of_le_one_right hD.le ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ⟩; + · exact ⟨ le_trans ( by positivity ) hx₁, + le_trans hx₂ + ( mul_le_of_le_one_right ( by positivity ) + ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ) ⟩; + · exact ⟨ by positivity, by + exact mul_le_of_le_one_right hD.le + ( by rw [ Real.rpow_le_one_iff_of_pos ] <;> norm_num ; linarith ) ⟩; norm_num [ Real.rpow_add, Real.rpow_neg ] at *; - rw [ max_eq_left ] at h_int_le <;> nlinarith [ show 0 < D * ( 1 / 2 * ( 2 ^ k : ℝ ) ⁻¹ ) by positivity, show 0 < D * ( 1 / 8 * ( 2 ^ k : ℝ ) ⁻¹ ) by positivity, inv_pos.mpr ( show 0 < ( 2 ^ k : ℝ ) by positivity ) ] + rw [ max_eq_left ] at h_int_le <;> + nlinarith + [ show 0 < D * + ( 1 / 2 * ( 2 ^ k : ℝ ) ⁻¹ ) + by positivity, show 0 < D * ( 1 / 8 * ( 2 ^ k : ℝ ) ⁻¹ ) by positivity, inv_pos.mpr ( show 0 + < ( 2 ^ k : ℝ ) by positivity ) ] lemma dudley_step_bound_tight {α : Type*} [PseudoMetricSpace α] - {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} [MeasureTheory.IsProbabilityMeasure μ] + {Ω : Type*} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} + [MeasureTheory.IsProbabilityMeasure μ] {T : Set α} {X : Ω → α → ℝ} (h_sg : ∀ x ∈ T, ∀ y ∈ T, IsSubGaussian (fun ω => X ω x - X ω y) (dist x y ^ 2) μ) @@ -1455,10 +1755,11 @@ lemma dudley_step_bound_tight (h_card : U_next.ncard ≤ subsetENetCard T (eps / 2)) (h_consistent : subsetENetCard T (eps / 2) = 1 → ∀ u ∈ U_next, u = pi_map u) : - ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ 2 * eps * Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by + ∫ ω, (⨆ u ∈ U_next, |X ω u - X ω (pi_map u)|) ∂μ ≤ 2 * eps * + Real.sqrt (Real.log (subsetENetCard T (eps / 2))) := by by_cases h_cases : subsetENetCard T (eps / 2) = 1; · norm_num [ h_cases ]; - refine' MeasureTheory.integral_nonpos fun ω => _; + refine MeasureTheory.integral_nonpos fun ω => ?_; by_cases hU_nonempty : U_next.Nonempty · have : Nonempty α := ⟨hU_nonempty.some⟩ apply ciSup_le @@ -1472,15 +1773,19 @@ lemma dudley_step_bound_tight · norm_num · rw [Set.not_nonempty_iff_eq_empty.mp hU_nonempty] simp - · - set N := subsetENetCard T (eps / 2); - - have h_sub_gaussian_max_abs_bound : ∫ ω, ⨆ u ∈ U_next, |X ω u - X ω (pi_map u)| ∂μ ≤ eps * Real.sqrt (2 * Real.log (2 * U_next.ncard)) := by - have h_sub_gaussian_max_abs_bound : ∀ u ∈ U_next, IsSubGaussian (fun ω => X ω u - X ω (pi_map u)) (eps ^ 2) μ := by - intro u hu; specialize h_sg u ( hU_next_subset hu ) ( pi_map u ) ( hU_curr_subset ( h_pi u hu ) ) ; exact (by + · set N := subsetENetCard T (eps / 2); + + have h_sub_gaussian_max_abs_bound : ∫ ω, ⨆ u ∈ U_next, |X ω u - X ω (pi_map u)| ∂μ ≤ + eps * Real.sqrt (2 * Real.log (2 * U_next.ncard)) := by + have h_sub_gaussian_max_abs_bound : ∀ u ∈ U_next, + IsSubGaussian (fun ω => X ω u - X ω (pi_map u)) (eps ^ 2) μ := by + intro u hu; specialize h_sg u ( hU_next_subset hu ) ( pi_map u ) + ( hU_curr_subset ( h_pi u hu ) ) ; exact (by exact IsSubGaussian_mono h_sg ( pow_le_pow_left₀ ( dist_nonneg ) ( h_dist u hu ) 2 )); by_cases h : U_next.Nonempty; - · convert sub_gaussian_max_abs_bound ( show 0 ≤ eps ^ 2 by positivity ) ( show ∀ i : U_next, IsSubGaussian ( fun ω => X ω i - X ω ( pi_map i ) ) ( eps ^ 2 ) μ from fun i => h_sub_gaussian_max_abs_bound i i.2 ) using 1; + · convert sub_gaussian_max_abs_bound ( show 0 ≤ eps ^ 2 by positivity ) + ( show ∀ i : U_next, IsSubGaussian ( fun ω => X ω i - X ω ( pi_map i ) ) + ( eps ^ 2 ) μ from fun i => h_sub_gaussian_max_abs_bound i i.2 ) using 1; any_goals exact Set.Finite.fintype hU_next_finite; · congr! 2; convert ( ciSup_eq_of_forall_le_of_forall_lt_exists_gt _ _ ); @@ -1489,7 +1794,9 @@ lemma dudley_step_bound_tight rw [ @ciSup_eq_ite ]; split_ifs <;> norm_num; · apply le_csSup; - · exact Set.Finite.bddAbove ( Set.Finite.subset ( hU_next_finite.image fun u => |X ‹_› u - X ‹_› ( pi_map u )| ) fun x hx => by + · exact Set.Finite.bddAbove + ( Set.Finite.subset ( hU_next_finite.image fun u => |X ‹_› u - + X ‹_› ( pi_map u )| ) fun x hx => by rcases hx with ⟨u, rfl⟩ exact ⟨u, u.2, rfl⟩ ); · exact ⟨ ⟨ i, by assumption ⟩, rfl ⟩; @@ -1503,16 +1810,18 @@ lemma dudley_step_bound_tight · exact ⟨ h.some, h.choose_spec ⟩; · rw [ show U_next = ∅ by simp [ Set.not_nonempty_iff_eq_empty.mp h ] ] ; norm_num; - have h_log_inequality : Real.sqrt (2 * Real.log (2 * U_next.ncard)) ≤ 2 * Real.sqrt (Real.log N) := by + have h_log_inequality : Real.sqrt (2 * Real.log (2 * U_next.ncard)) ≤ 2 * + Real.sqrt (Real.log N) := by have h_log_inequality : Real.sqrt (2 * Real.log (2 * N)) ≤ 2 * Real.sqrt (Real.log N) := by by_cases hN : N = 0; · simp [hN]; - · have h_log_inequality : Real.sqrt (2 * Real.log (2 * N)) ≤ 2 * Real.sqrt (Real.log N) := by + · have h_log_inequality : Real.sqrt (2 * Real.log (2 * N)) ≤ 2 * + Real.sqrt (Real.log N) := by have hN_ge_2 : 2 ≤ N := by exact Nat.lt_of_le_of_ne ( Nat.pos_of_ne_zero hN ) ( Ne.symm h_cases ) exact log_inequality_for_dudley N hN_ge_2; exact h_log_inequality; - refine' le_trans _ h_log_inequality; + refine le_trans ?_ h_log_inequality; by_cases h : U_next.ncard = 0 · simp [h] · have hU_next_ncard_pos : 0 < U_next.ncard := Nat.pos_of_ne_zero h @@ -1551,14 +1860,18 @@ lemma dudleyEntropyIntegral_antitone have hf_antitone : AntitoneOn f (Set.Icc δ₁ D) := by intro x hx y hy hxy simp +zetaDelta - by_cases h : subsetENetCard T y = 0 <;> by_cases h' : subsetENetCard T x = 0 <;> simp_all +decide + by_cases h : subsetENetCard T y = 0 <;> by_cases h' : subsetENetCard T x = 0 <;> + simp_all +decide · exact False.elim <| by simpa [h, h'] using subsetENetCard_antitoneOn_Ioc h_finite_cov ⟨by linarith [hx.1], by linarith [hx.2]⟩ ⟨by linarith [hy.1], by linarith [hy.2]⟩ hxy - · exact Real.sqrt_le_sqrt (Real.log_le_log (Nat.cast_pos.mpr (Nat.pos_of_ne_zero h)) (Nat.cast_le.mpr (subsetENetCard_antitoneOn_Ioc h_finite_cov ⟨by linarith [hx.1], by linarith [hx.2]⟩ ⟨by linarith [hy.1], by linarith [hy.2]⟩ hxy))) + · exact Real.sqrt_le_sqrt (Real.log_le_log (Nat.cast_pos.mpr (Nat.pos_of_ne_zero h)) + (Nat.cast_le.mpr + (subsetENetCard_antitoneOn_Ioc h_finite_cov ⟨by linarith [hx.1], by linarith [hx.2]⟩ + ⟨by linarith [hy.1], by linarith [hy.2]⟩ hxy))) exact hf_antitone.integrableOn_isCompact isCompact_Icc · exact Filter.Eventually.of_forall fun x => Real.sqrt_nonneg _ · exact Filter.Eventually.of_forall fun x hx => ⟨by linarith [hx.1], hx.2⟩ @@ -1579,15 +1892,18 @@ lemma expectation_one_step_bound ∫ ω, globalOsc (X ω) T ∂P ≤ 2 * ∫ ω, localOsc (X ω) T δ ∂P + 2 * ∫ ω, (⨆ u ∈ U, |X ω u - X ω u₀|) ∂P := by - have h_pointwise : ∀ ω, globalOsc (X ω) T ≤ 2 * localOsc (X ω) T δ + 2 * (⨆ u ∈ U, |X ω u - X ω u₀|) := + have h_pointwise : ∀ ω, globalOsc (X ω) T ≤ 2 * localOsc (X ω) T δ + 2 * + (⨆ u ∈ U, |X ω u - X ω u₀|) := fun ω => one_step_discretization_bound hU_fin hU_subset hU_cover u₀ hu₀ - have h_rhs_integrable : Integrable (fun ω => 2 * localOsc (X ω) T δ + 2 * (⨆ u ∈ U, |X ω u - X ω u₀|)) P := + have h_rhs_integrable : + Integrable (fun ω => 2 * localOsc (X ω) T δ + 2 * (⨆ u ∈ U, |X ω u - X ω u₀|)) P := (h_integrable_local.const_mul 2).add (h_integrable_sup.const_mul 2) calc ∫ ω, globalOsc (X ω) T ∂P ≤ ∫ ω, (2 * localOsc (X ω) T δ + 2 * (⨆ u ∈ U, |X ω u - X ω u₀|)) ∂P := MeasureTheory.integral_mono h_integrable_global h_rhs_integrable (fun ω => h_pointwise ω) _ = 2 * ∫ ω, localOsc (X ω) T δ ∂P + 2 * ∫ ω, (⨆ u ∈ U, |X ω u - X ω u₀|) ∂P := by - rw [MeasureTheory.integral_add (h_integrable_local.const_mul 2) (h_integrable_sup.const_mul 2), + rw [MeasureTheory.integral_add (h_integrable_local.const_mul 2) + (h_integrable_sup.const_mul 2), MeasureTheory.integral_const_mul, MeasureTheory.integral_const_mul] /- @@ -1607,7 +1923,8 @@ lemma basepoint_to_pairwise rw [@ciSup_eq_ite] split_ifs with hu · exact finite_sup_bound hU_fin X u u₀ hu hu₀ - · exact le_trans (by norm_num) (Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _) + · exact le_trans (by norm_num) (Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => + Real.iSup_nonneg fun _ => Real.iSup_nonneg fun _ => abs_nonneg _) /-- Finite step suprema of sub-Gaussian increments are integrable. -/ lemma integrable_step_sup_of_subGaussian @@ -1703,7 +2020,8 @@ lemma integrable_pairwise_sup_of_subGaussian simp /- -Chaining entropy bound: the expected pairwise sup over a finite cover is bounded by the entropy integral. +Chaining entropy bound: + the expected pairwise sup over a finite cover is bounded by the entropy integral. This is the core technical lemma combining the chain construction with the base and step bounds. -/ lemma chaining_entropy_bound @@ -1722,8 +2040,7 @@ lemma chaining_entropy_bound 16 * dudleyEntropyIntegral T (δ' / 4) D := by by_cases hU_single : U.ncard ≤ 1 - · - have hU1 : U.ncard = 1 := Nat.le_antisymm hU_single + · have hU1 : U.ncard = 1 := Nat.le_antisymm hU_single (Set.ncard_pos hU_fin |>.mpr hU_nonempty) obtain ⟨u₀, hu₀_eq⟩ := Set.ncard_eq_one.mp hU1 refine le_trans ?_ (mul_nonneg (by norm_num : (0:ℝ) ≤ 16) ?_) @@ -1882,28 +2199,21 @@ lemma chaining_entropy_bound have hk_lt : k < L - 1 := Finset.mem_range.mp hk_range apply dudley_step_bound_tight h_sg (U_seq (k + 1)) (U_seq (k + 2)) (hUs (k + 1)) (hUs (k + 2)) (hUf (k + 2)) - · - intro u hu; exact (hUp (k + 1) (by omega) u hu).1 - · - exact (h_eps_pos (k + 1)).le - · - intro u hu; exact (hUp (k + 1) (by omega) u hu).2 - · - rw [h_eps_half] + · intro u hu; exact (hUp (k + 1) (by omega) u hu).1 + · exact (h_eps_pos (k + 1)).le + · intro u hu; exact (hUp (k + 1) (by omega) u hu).2 + · rw [h_eps_half] by_cases h_case : k + 2 < L · exact le_of_eq (hUn (k + 2) h_case) · have hk2_eq : k + 2 = L := by omega rw [hk2_eq, hUL] exact le_trans hU_ncard (subsetENetCard_antitoneOn_Ioc h_finite_cov ⟨h_eps_pos L, h_eps_le_D L⟩ ⟨hδ', le_trans hδ'D (by linarith)⟩ heps_L_le) - · - intro h_eq_1 u hu + · intro h_eq_1 u hu rw [h_eps_half] at h_eq_1 by_cases h_kL : k + 2 < L - · - exact (h_chain_consistent (k + 1) (by omega) h_eq_1 u hu).symm - · - exfalso + · exact (h_chain_consistent (k + 1) (by omega) h_eq_1 u hu).symm + · exfalso have hk2_eq : k + 2 = L := by omega rw [hk2_eq] at h_eq_1 have : 2 ≤ subsetENetCard T (eps L) := @@ -2098,7 +2408,8 @@ theorem truncated_dudley_entropy_bound_aux h_integrable_global h_integrable_local h_integrable_sup have h_bp : ∀ ω, (⨆ u ∈ U, |X ω u - X ω u₀|) ≤ (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) := fun ω => basepoint_to_pairwise hU_fin hu₀ - have h_integrable_pairwise := integrable_pairwise_sup_of_subGaussian h_sg hU_fin hU_subset ⟨u₀, hu₀⟩ + have h_integrable_pairwise := integrable_pairwise_sup_of_subGaussian h_sg hU_fin hU_subset + ⟨u₀, hu₀⟩ have h_sup_le_pairwise : ∫ ω, (⨆ u ∈ U, |X ω u - X ω u₀|) ∂P ≤ ∫ ω, (⨆ u ∈ U, ⨆ v ∈ U, |X ω u - X ω v|) ∂P := MeasureTheory.integral_mono h_integrable_sup h_integrable_pairwise h_bp From fe8419c40d7bb6ed7f0b541696f88a510b5dc00a Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:22 +0900 Subject: [PATCH 3/7] Fix style linter warnings in Probability/Concentration Wrap lines over 100 characters and fix the other style linter warnings (`refine'`, focusing dots, missing `end`) reported once the linter option names in `lakefile.lean` are corrected. Formatting only; no statement changes. Part of #71. Co-Authored-By: Claude Opus 5.5 --- .../Probability/Concentration/EfronStein.lean | 653 ++++++++++++------ .../Concentration/HansonWright.lean | 9 +- .../Probability/Concentration/Hoeffding.lean | 6 +- .../LogSobolev/GaussianCompactSupport.lean | 3 +- .../LogSobolev/GaussianOneDim.lean | 6 +- .../LogSobolev/GaussianTensorization.lean | 12 +- .../Concentration/LogSobolev/TwoPoint.lean | 42 +- .../Probability/Concentration/Maximal.lean | 37 +- .../Probability/Concentration/McDiarmid.lean | 196 ++++-- 9 files changed, 651 insertions(+), 313 deletions(-) diff --git a/StatsMLlib/Probability/Concentration/EfronStein.lean b/StatsMLlib/Probability/Concentration/EfronStein.lean index 2d33f31..7e3739c 100644 --- a/StatsMLlib/Probability/Concentration/EfronStein.lean +++ b/StatsMLlib/Probability/Concentration/EfronStein.lean @@ -170,7 +170,8 @@ lemma condExpExceptCoord_expectation (hf : Integrable f μˢ) : calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i exact hmp.integrable_comp hf.aestronglyMeasurable |>.mpr hf @@ -178,7 +179,8 @@ lemma condExpExceptCoord_expectation (hf : Integrable f μˢ) : /-- The difference f - E^{(i)}f has zero expectation with respect to coordinate i. -/ lemma condExpExceptCoord_sub_self_integral_coord (x : Fin n → Ω) (hf_slice : Integrable (fun y => f (Function.update x i y)) (μs i)) : - ∫ y, (f (Function.update x i y) - condExpExceptCoord (μs := μs) i f (Function.update x i y)) ∂(μs i) = 0 := by + ∫ y, (f (Function.update x i y) - condExpExceptCoord (μs := μs) i f (Function.update x i y)) + ∂(μs i) = 0 := by simp only [condExpExceptCoord] rw [integral_sub] · simp_rw [Function.update_idem] @@ -229,7 +231,8 @@ lemma expectation_sq_diff_eq_expectation_condVar (i : Fin n) (_hf : Integrable f calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i exact hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 @@ -277,10 +280,12 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf.aestronglyMeasurable |>.mpr hf unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -294,10 +299,12 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -312,10 +319,12 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 exact hg_int.prod_right_ae -- A.e. slice integrability for f (from hcond_int proof) @@ -329,10 +338,12 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf.aestronglyMeasurable |>.mpr hf exact hg_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) i f z)^2) μˢ := by @@ -371,7 +382,8 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) linarith [h_zero, this] -- Rewrite D as E^{(i)}f * (f - E^{(i)}f) - have hD_factor : ∀ z, D z = condExpExceptCoord (μs := μs) i f z * (f z - condExpExceptCoord (μs := μs) i f z) := by + have hD_factor : ∀ z, + D z = condExpExceptCoord (μs := μs) i f z * (f z - condExpExceptCoord (μs := μs) i f z) := by intro z simp only [hD_def, sq] ring @@ -389,10 +401,12 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf.aestronglyMeasurable |>.mpr hf exact hg_int.prod_right_ae @@ -413,7 +427,8 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) -- Use integral_update_eq_integral: ∫ D dμˢ = ∫ y, (∫ x, D(update x i y) dμˢ) dμ -- Then swap order and use h_inner_zero_ae - have hD_uncurry_int : Integrable (Function.uncurry (fun y x => D (Function.update x i y))) ((μs i).prod μˢ) := by + have hD_uncurry_int : + Integrable (Function.uncurry (fun y x => D (Function.update x i y))) ((μs i).prod μˢ) := by -- Transform to composition with Prod.swap have hmp : MeasurePreserving (fun p : Ω × (Fin n → Ω) => Function.update p.2 i p.1) ((μs i).prod μˢ) μˢ := by @@ -422,7 +437,8 @@ lemma integral_mul_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) · exact map_update_prod_pi i exact hmp.integrable_comp hD_int.aestronglyMeasurable |>.mpr hD_int calc ∫ z, D z ∂μˢ - = ∫ y, ∫ x, D (Function.update x i y) ∂μˢ ∂(μs i) := (integral_update_eq_integral i D hD_int).symm + = ∫ y, ∫ x, D (Function.update x i y) ∂μˢ ∂(μs i) := + (integral_update_eq_integral i D hD_int).symm _ = ∫ x, ∫ y, D (Function.update x i y) ∂(μs i) ∂μˢ := by rw [integral_integral_swap hD_uncurry_int] _ = ∫ x, 0 ∂μˢ := by @@ -450,12 +466,16 @@ lemma total_variance_identity (i : Fin n) (f : (Fin n → Ω) → ℝ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left -- Show (condExpExceptCoord)² is integrable via Jensen bound @@ -469,11 +489,14 @@ lemma total_variance_identity (i : Fin n) (f : (Fin n → Ω) → ℝ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -486,11 +509,14 @@ lemma total_variance_identity (i : Fin n) (f : (Fin n → Ω) → ℝ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 exact hg_int.prod_right_ae have hf_slice_ae : ∀ᵐ x ∂μˢ, Integrable (fun y => f (Function.update x i y)) (μs i) := by @@ -502,12 +528,16 @@ lemma total_variance_identity (i : Fin n) (f : (Fin n → Ω) → ℝ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) exact hg_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) i f z)^2) μˢ := by apply Integrable.mono' hcond_sq_int @@ -530,7 +560,8 @@ lemma total_variance_identity (i : Fin n) (f : (Fin n → Ω) → ℝ) have hdiff_memLp : MemLp (fun x => f x - condExpExceptCoord (μs := μs) i f x) 2 μˢ := hf.sub hcond_memLp exact hdiff_memLp.integrable_sq - have hcondVar := expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int + have hcondVar := + expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int rw [← hcondVar] have h_expand : ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μˢ = ∫ x, (f x)^2 ∂μˢ - 2 * ∫ x, f x * condExpExceptCoord (μs := μs) i f x ∂μˢ + @@ -595,12 +626,16 @@ lemma sum_variance_condExp_le (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left have hf2 := hf.integrable_sq @@ -613,11 +648,14 @@ lemma sum_variance_condExp_le (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -630,11 +668,14 @@ lemma sum_variance_condExp_le (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 exact hg_int.prod_right_ae have hf_slice_ae : ∀ᵐ x ∂μˢ, Integrable (fun y => f (Function.update x i y)) (μs i) := by @@ -646,12 +687,16 @@ lemma sum_variance_condExp_le (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) exact hg_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) i f z)^2) μˢ := by apply Integrable.mono' hcond_sq_int @@ -671,7 +716,8 @@ lemma sum_variance_condExp_le (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) hf.sub hcond_memLp have hf2_int : Integrable (fun x => (f x - condExpExceptCoord (μs := μs) i f x)^2) μˢ := hdiff_memLp.integrable_sq - have hcondVar := expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int + have hcondVar := + expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int linarith -- Sum: ∑ Var(E^{(i)}f) = n * Var(f) - ∑ E[(f - E^{(i)}f)²] have hsum_eq : ∑ i, variance (condExpExceptCoord (μs := μs) i f) μˢ = @@ -693,8 +739,10 @@ These lemmas are used for the inductive step in the Efron-Stein proof. section Tensorization -/-- A.e. commutativity of conditional expectations: E^{(i)}(E^{(j)}f) = E^{(j)}(E^{(i)}f) a.e. for i ≠ j. - This follows from Fubini since the conditional expectations integrate over independent coordinates. -/ +/-- A.e. commutativity of conditional expectations: + E^{(i)}(E^{(j)}f) = E^{(j)}(E^{(i)}f) a.e. for i ≠ j. + This follows from Fubini since the conditional expectations integrate over independent + coordinates. -/ lemma condExpExceptCoord_comm_ae {i j : Fin n} (hij : i ≠ j) (f : (Fin n → Ω) → ℝ) (hf : Integrable f μˢ) : condExpExceptCoord (μs := μs) i (condExpExceptCoord (μs := μs) j f) =ᶠ[ae μˢ] @@ -715,8 +763,10 @@ lemma condExpExceptCoord_comm_ae {i j : Fin n} (hij : i ≠ j) (f : (Fin n → (μˢ.prod ((μs i).prod (μs j))) μˢ := by constructor · -- Measurability: compose update operations - have h1 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) := measurable_update' (a := i) - have h2 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) := measurable_update' (a := j) + have h1 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) := + measurable_update' (a := i) + have h2 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) := + measurable_update' (a := j) have h3 : Measurable (fun p : (Fin n → Ω) × Ω × Ω => (p.1, p.2.1)) := Measurable.prodMk measurable_fst (measurable_fst.comp measurable_snd) have h4 : Measurable (fun p : (Fin n → Ω) × Ω × Ω => (Function.update p.1 i p.2.1, p.2.2)) := @@ -734,7 +784,8 @@ lemma condExpExceptCoord_comm_ae {i j : Fin n} (hij : i ≠ j) (f : (Fin n → -- So preimage is {(x, (y, z)) : z ∈ s j, y ∈ s i, ∀ k ≠ i,j, x(k) ∈ s(k)} have preimage_eq : (fun p : (Fin n → Ω) × Ω × Ω => Function.update (Function.update p.1 i p.2.1) j p.2.2) ⁻¹' (Set.univ.pi s) = - (Set.univ.pi (fun k => if k = i ∨ k = j then Set.univ else s k)) ×ˢ ((s i) ×ˢ (s j)) := by + (Set.univ.pi (fun k => if k = i ∨ k = j then Set.univ else s k)) ×ˢ + ((s i) ×ˢ (s j)) := by ext ⟨x, y, z⟩ simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, true_implies, Set.mem_prod] constructor @@ -793,18 +844,23 @@ lemma condExpExceptCoord_comm_ae {i j : Fin n} (hij : i ≠ j) (f : (Fin n → have hmemi : i ∈ Finset.univ.erase j := Finset.mem_erase.mpr ⟨hij, Finset.mem_univ i⟩ have hmemj : j ∈ Finset.univ := Finset.mem_univ j calc (∏ k ∈ (Finset.univ.erase i).erase j, (μs k) (s k)) * ((μs i) (s i) * (μs j) (s j)) - _ = (∏ k ∈ (Finset.univ.erase i).erase j, (μs k) (s k)) * (μs i) (s i) * (μs j) (s j) := by ring + _ = (∏ k ∈ (Finset.univ.erase i).erase j, (μs k) (s k)) * (μs i) (s i) * + (μs j) (s j) := by + ring _ = (∏ k ∈ Finset.univ.erase j, (μs k) (s k)) * (μs j) (s j) := by have : (Finset.univ.erase j).erase i = (Finset.univ.erase i).erase j := Finset.erase_right_comm rw [← this, Finset.prod_erase_mul _ _ hmemi] _ = ∏ k, (μs k) (s k) := Finset.prod_erase_mul _ _ hmemj · -- Measurability of the map - have h1 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) := measurable_update' (a := i) - have h2 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) := measurable_update' (a := j) + have h1 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) := + measurable_update' (a := i) + have h2 : Measurable (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) := + measurable_update' (a := j) have h3 : Measurable (fun p : (Fin n → Ω) × Ω × Ω => (p.1, p.2.1)) := Measurable.prodMk measurable_fst (measurable_fst.comp measurable_snd) - have h4 : Measurable (fun p : (Fin n → Ω) × Ω × Ω => (Function.update p.1 i p.2.1, p.2.2)) := + have h4 : + Measurable (fun p : (Fin n → Ω) × Ω × Ω => (Function.update p.1 i p.2.1, p.2.2)) := Measurable.prodMk (h1.comp h3) (measurable_snd.comp measurable_snd) exact h2.comp h4 · exact MeasurableSet.univ_pi (fun k => hs k) @@ -843,11 +899,14 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) (measurable_update' (a := j)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs j))) := + (Measure.map_map hh measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg.aestronglyMeasurable |>.mpr hg exact hg_int.prod_right_ae have hf2_slice_ae : ∀ᵐ x ∂μˢ, Integrable (fun y => (g (Function.update x j y))^2) (μs j) := by @@ -859,11 +918,14 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) (measurable_update' (a := j)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs j))) := + (Measure.map_map hh measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg2.aestronglyMeasurable |>.mpr hg2 exact hg2_int.prod_right_ae filter_upwards [hf_slice_ae, hf2_slice_ae] with x hslice_int hslice_sq_int @@ -886,10 +948,12 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg2.aestronglyMeasurable |>.mpr hg2 unfold condExpExceptCoord simpa [Pi.pow_apply] using hg2_int.integral_prod_left @@ -904,10 +968,12 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg.aestronglyMeasurable |>.mpr hg unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -922,11 +988,14 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) (measurable_update' (a := j)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs j))) := + (Measure.map_map hh measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg2_int : Integrable (fun p : (Fin n → Ω) × Ω => (g^2) (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg2.aestronglyMeasurable |>.mpr hg2 exact hg2_int.prod_right_ae have hf_slice_ae' : ∀ᵐ x ∂μˢ, Integrable (fun y => g (Function.update x j y)) (μs j) := by @@ -938,11 +1007,14 @@ lemma jensen_sq_condExpExceptCoord (j : Fin n) (g : (Fin n → Ω) → ℝ) (measurable_update' (a := j)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 j p.2) (μˢ.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μˢ.prod (μs j))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) ((μs j).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs j))) := + (Measure.map_map hh measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 j q.1) + ((μs j).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi j - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) (μˢ.prod (μs j)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => g (Function.update p.1 j p.2)) + (μˢ.prod (μs j)) := hmp.integrable_comp hg.aestronglyMeasurable |>.mpr hg exact hg_int.prod_right_ae apply Integrable.mono' hcond_sq_int @@ -993,12 +1065,15 @@ lemma memLp_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) (hf : Me (measurable_update' (a := i)).comp measurable_swap calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + (Measure.map Prod.swap (μˢ.prod (μs i))) := + (Measure.map_map hh measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i -- f = mk f on μˢ-a.e., so f ∘ update = (mk f) ∘ update on (μˢ × μ)-a.e. - have hae_prod : (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) =ᶠ[ae (μˢ.prod (μs i))] + have hae_prod : + (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) =ᶠ[ae (μˢ.prod (μs i))] (fun p => hf.aestronglyMeasurable.mk f (Function.update p.1 i p.2)) := by have := hmp.quasiMeasurePreserving.ae_eq_comp hae filter_upwards [this] with p hp @@ -1029,17 +1104,20 @@ lemma memLp_condExpExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) (hf : Me calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hf2_prod : Integrable (fun p : (Fin n → Ω) × Ω => (f^2) (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hf2_prod : Integrable (fun p : (Fin n → Ω) × Ω => (f^2) (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf2.aestronglyMeasurable |>.mpr hf2 have hcondE_sq_int : Integrable (condExpExceptCoord (μs := μs) i (f^2)) μˢ := by unfold condExpExceptCoord simpa [Pi.pow_apply] using hf2_prod.integral_prod_left -- Now use that (condExp f)² ≤ condExp(f²) ae (Jensen pointwise) -- First get slice integrability - have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := hmp.integrable_comp hf_int.aestronglyMeasurable |>.mpr hf_int have hf_slice_ae : ∀ᵐ x ∂μˢ, Integrable (fun y => f (Function.update x i y)) (μs i) := hf_prod.prod_right_ae @@ -1080,8 +1158,10 @@ lemma sq_diff_condExpExceptCoord_bound [NeZero n] {j : Fin n} (h0j : (0 : Fin n) ∫ x, (f x - condExpExceptCoord (μs := μs) j f x)^2 ∂μˢ := by -- Linearity: E^{(0)}f - E^{(0)}(E^{(j)}f) = E^{(0)}(f - E^{(j)}f) a.e. have hlin : (fun x => condExpExceptCoord (μs := μs) (0 : Fin n) f x - - condExpExceptCoord (μs := μs) (0 : Fin n) (condExpExceptCoord (μs := μs) j f) x) =ᶠ[ae μˢ] - (fun x => condExpExceptCoord (μs := μs) (0 : Fin n) (fun y => f y - condExpExceptCoord (μs := μs) j f y) x) := by + condExpExceptCoord (μs := μs) (0 : Fin n) + (condExpExceptCoord (μs := μs) j f) x) =ᶠ[ae μˢ] + (fun x => condExpExceptCoord (μs := μs) (0 : Fin n) + (fun y => f y - condExpExceptCoord (μs := μs) j f y) x) := by -- First establish a.e. slice integrability have hmp : MeasurePreserving (fun p : (Fin n → Ω) × Ω => Function.update p.1 (0 : Fin n) p.2) (μˢ.prod (μs 0)) μˢ := by @@ -1089,25 +1169,36 @@ lemma sq_diff_condExpExceptCoord_bound [NeZero n] {j : Fin n} (h0j : (0 : Fin n) · exact measurable_update' (a := (0 : Fin n)) · have hh : Measurable (fun q : Ω × (Fin n → Ω) => Function.update q.2 (0 : Fin n) q.1) := (measurable_update' (a := (0 : Fin n))).comp measurable_swap - calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 (0 : Fin n) p.2) (μˢ.prod (μs 0)) + calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 (0 : Fin n) p.2) + (μˢ.prod (μs 0)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 (0 : Fin n) q.1) (Measure.map Prod.swap (μˢ.prod (μs 0))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 (0 : Fin n) q.1) ((μs 0).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 (0 : Fin n) q.1) + ((μs 0).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi (0 : Fin n) - have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 (0 : Fin n) p.2)) (μˢ.prod (μs 0)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 (0 : Fin n) p.2)) + (μˢ.prod (μs 0)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) have hint_f : ∀ᵐ x ∂μˢ, Integrable (fun y => f (Function.update x (0 : Fin n) y)) (μs 0) := hf_prod.prod_right_ae have hcond_f := memLp_condExpExceptCoord j f hf - have hcond_prod : Integrable (fun p : (Fin n → Ω) × Ω => condExpExceptCoord (μs := μs) j f (Function.update p.1 (0 : Fin n) p.2)) (μˢ.prod (μs 0)) := - hmp.integrable_comp (hcond_f.integrable one_le_two).aestronglyMeasurable |>.mpr (hcond_f.integrable one_le_two) - have hint_cond : ∀ᵐ x ∂μˢ, Integrable (fun y => condExpExceptCoord (μs := μs) j f (Function.update x (0 : Fin n) y)) (μs 0) := + have hcond_prod : Integrable (fun p : (Fin n → Ω) × Ω => + condExpExceptCoord (μs := μs) j f (Function.update p.1 (0 : Fin n) p.2)) + (μˢ.prod (μs 0)) := + hmp.integrable_comp (hcond_f.integrable one_le_two).aestronglyMeasurable |>.mpr + (hcond_f.integrable one_le_two) + have hint_cond : ∀ᵐ x ∂μˢ, + Integrable (fun y => condExpExceptCoord (μs := μs) j f (Function.update x (0 : Fin n) y)) + (μs 0) := hcond_prod.prod_right_ae -- Now use filter_upwards with both ae integrability hypotheses filter_upwards [hint_f, hint_cond] with x hx_f hx_cond - show ∫ y, f (Function.update x 0 y) ∂(μs 0) - ∫ y, condExpExceptCoord (μs := μs) j f (Function.update x 0 y) ∂(μs 0) = - ∫ y, (f (Function.update x 0 y) - condExpExceptCoord (μs := μs) j f (Function.update x 0 y)) ∂(μs 0) + show ∫ y, f (Function.update x 0 y) ∂(μs 0) - + ∫ y, condExpExceptCoord (μs := μs) j f (Function.update x 0 y) ∂(μs 0) = + ∫ y, (f (Function.update x 0 y) - condExpExceptCoord (μs := μs) j f (Function.update x 0 y)) + ∂(μs 0) exact (integral_sub hx_f hx_cond).symm -- Apply Jensen to g = f - E^{(j)}f let g := fun y => f y - condExpExceptCoord (μs := μs) j f y @@ -1117,7 +1208,8 @@ lemma sq_diff_condExpExceptCoord_bound [NeZero n] {j : Fin n} (h0j : (0 : Fin n) have hjensenG := jensen_sq_condExpExceptCoord (0 : Fin n) g hg_int hg2 -- Need to connect the LHS with condExp of g have hae_eq : (fun x => condExpExceptCoord (μs := μs) (0 : Fin n) f x - - condExpExceptCoord (μs := μs) j (condExpExceptCoord (μs := μs) (0 : Fin n) f) x) =ᶠ[ae μˢ] + condExpExceptCoord (μs := μs) j + (condExpExceptCoord (μs := μs) (0 : Fin n) f) x) =ᶠ[ae μˢ] (fun x => condExpExceptCoord (μs := μs) (0 : Fin n) g x) := by have hcomm' := condExpExceptCoord_comm_ae h0j f (hf.integrable one_le_two) filter_upwards [hcomm', hlin] with x hx1 hx2 @@ -1141,7 +1233,8 @@ lemma sq_diff_condExpExceptCoord_bound_gen [NeZero n] {i j : Fin n} (hij : i ≠ -- Linearity: E^{(i)}f - E^{(i)}(E^{(j)}f) = E^{(i)}(f - E^{(j)}f) a.e. have hlin : (fun x => condExpExceptCoord (μs := μs) i f x - condExpExceptCoord (μs := μs) i (condExpExceptCoord (μs := μs) j f) x) =ᶠ[ae μˢ] - (fun x => condExpExceptCoord (μs := μs) i (fun y => f y - condExpExceptCoord (μs := μs) j f y) x) := by + (fun x => condExpExceptCoord (μs := μs) i + (fun y => f y - condExpExceptCoord (μs := μs) j f y) x) := by have hmp : MeasurePreserving (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) μˢ := by constructor @@ -1151,21 +1244,30 @@ lemma sq_diff_condExpExceptCoord_bound_gen [NeZero n] {i j : Fin n} (hij : i ≠ calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hh measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hf_prod : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) have hint_f : ∀ᵐ x ∂μˢ, Integrable (fun y => f (Function.update x i y)) (μs i) := hf_prod.prod_right_ae have hcond_f := memLp_condExpExceptCoord j f hf - have hcond_prod : Integrable (fun p : (Fin n → Ω) × Ω => condExpExceptCoord (μs := μs) j f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := - hmp.integrable_comp (hcond_f.integrable one_le_two).aestronglyMeasurable |>.mpr (hcond_f.integrable one_le_two) - have hint_cond : ∀ᵐ x ∂μˢ, Integrable (fun y => condExpExceptCoord (μs := μs) j f (Function.update x i y)) (μs i) := + have hcond_prod : Integrable (fun p : (Fin n → Ω) × Ω => + condExpExceptCoord (μs := μs) j f (Function.update p.1 i p.2)) + (μˢ.prod (μs i)) := + hmp.integrable_comp (hcond_f.integrable one_le_two).aestronglyMeasurable |>.mpr + (hcond_f.integrable one_le_two) + have hint_cond : ∀ᵐ x ∂μˢ, + Integrable (fun y => condExpExceptCoord (μs := μs) j f (Function.update x i y)) (μs i) := hcond_prod.prod_right_ae filter_upwards [hint_f, hint_cond] with x hx_f hx_cond - show ∫ y, f (Function.update x i y) ∂(μs i) - ∫ y, condExpExceptCoord (μs := μs) j f (Function.update x i y) ∂(μs i) = - ∫ y, (f (Function.update x i y) - condExpExceptCoord (μs := μs) j f (Function.update x i y)) ∂(μs i) + show ∫ y, f (Function.update x i y) ∂(μs i) - + ∫ y, condExpExceptCoord (μs := μs) j f (Function.update x i y) ∂(μs i) = + ∫ y, (f (Function.update x i y) - condExpExceptCoord (μs := μs) j f (Function.update x i y)) + ∂(μs i) exact (integral_sub hx_f hx_cond).symm -- Apply Jensen to g = f - E^{(j)}f let g := fun y => f y - condExpExceptCoord (μs := μs) j f y @@ -1189,7 +1291,8 @@ lemma sq_diff_condExpExceptCoord_bound_gen [NeZero n] {i j : Fin n} (hij : i ≠ _ = ∫ x, (f x - condExpExceptCoord (μs := μs) j f x)^2 ∂μˢ := rfl /-- Idempotence of conditional expectation: E^{(i)}(E^{(i)}f) = E^{(i)}f. - Since E^{(i)}f doesn't depend on coordinate i, integrating over i again gives the same result. -/ + Since E^{(i)}f doesn't depend on coordinate i, integrating over i again gives the same + result. -/ lemma condExpExceptCoord_idempotent (i : Fin n) (f : (Fin n → Ω) → ℝ) : condExpExceptCoord (μs := μs) i (condExpExceptCoord (μs := μs) i f) = condExpExceptCoord (μs := μs) i f := by @@ -1269,7 +1372,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : change Measure.map (MeasurableEquiv.funUnique (Fin 1) Ω) (Measure.pi fun _ : Fin 1 => μs 0) = μs 0 exact hmp.map_eq - have h2 : (Measure.map e (Measure.pi (fun _ : Fin 1 => μs 0))).map e.symm = (μs 0).map e.symm := by + have h2 : (Measure.map e (Measure.pi (fun _ : Fin 1 => μs 0))).map e.symm = + (μs 0).map e.symm := by rw [h1] rw [MeasurableEquiv.map_symm_map] at h2 exact h2 @@ -1291,7 +1395,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have : ∀ i : Fin (k+2), SFinite (μs i) := fun i => inferInstance have : ∀ i : Fin (k+2), IsFiniteMeasure (μs i) := fun i => inferInstance - have hcond_int_i : ∀ i : Fin ((k+1)+1), Integrable (condExpExceptCoord (μs := μs) i f) μ_curr := by + have hcond_int_i : + ∀ i : Fin ((k+1)+1), Integrable (condExpExceptCoord (μs := μs) i f) μ_curr := by intro i have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) μ_curr := by @@ -1299,23 +1404,30 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left - have hsum_nonneg : 0 ≤ ∑ i : Fin ((k+1)+1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by + have hsum_nonneg : + 0 ≤ ∑ i : Fin ((k+1)+1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by apply Finset.sum_nonneg intro i _ apply integral_nonneg (fun x => sq_nonneg _) - have heach_term : ∀ i : Fin ((k+1)+1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr ≤ + have heach_term : ∀ i : Fin ((k+1)+1), + ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr ≤ variance f μ_curr := by intro i have htv := total_variance_identity (μs := μs) i f hf @@ -1328,30 +1440,41 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := + have hg_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := hmp.integrable_comp hf2'.aestronglyMeasurable |>.mpr hf2' unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left - have hf2_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y) ^ 2) (μs i) := by + have hf2_slice_ae : + ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y) ^ 2) (μs i) := by have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) μ_curr := by constructor · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := + have hg_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := hmp.integrable_comp hf2'.aestronglyMeasurable |>.mpr hf2' exact hg_int.prod_right_ae have hf_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y)) (μs i) := by @@ -1361,14 +1484,19 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) exact hg_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) i f z)^2) μ_curr := by apply Integrable.mono' hcond_sq_int @@ -1389,7 +1517,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : hf.sub hcond_memLp have hf2_int : Integrable (fun x => (f x - condExpExceptCoord (μs := μs) i f x)^2) μ_curr := hdiff_memLp.integrable_sq - have hcondVar := expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int + have hcondVar := + expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int linarith have h_condVar : ∀ i, ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = @@ -1404,30 +1533,41 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := + have hg_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := hmp.integrable_comp hf2'.aestronglyMeasurable |>.mpr hf2' unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left - have hf2_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y) ^ 2) (μs i) := by + have hf2_slice_ae : + ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y) ^ 2) (μs i) := by have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) μ_curr := by constructor · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := + have hg_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (f ^ 2) (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := hmp.integrable_comp hf2'.aestronglyMeasurable |>.mpr hf2' exact hg_int.prod_right_ae have hf_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => f (Function.update x i y)) (μs i) := by @@ -1437,14 +1577,19 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · exact measurable_update' (a := i) · have hg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) := (measurable_update' (a := i)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) (μ_curr.prod (μs i)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 i p.2) + (μ_curr.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) - (Measure.map Prod.swap (μ_curr.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) ((μs i).prod μ_curr) := by + (Measure.map Prod.swap (μ_curr.prod (μs i))) := + (Measure.map_map hg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 i q.1) + ((μs i).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) (μ_curr.prod (μs i)) := - hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr (hf.integrable one_le_two) + have hg_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => f (Function.update p.1 i p.2)) + (μ_curr.prod (μs i)) := + hmp.integrable_comp (hf.integrable one_le_two).aestronglyMeasurable |>.mpr + (hf.integrable one_le_two) exact hg_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) i f z)^2) μ_curr := by apply Integrable.mono' hcond_sq_int @@ -1465,11 +1610,13 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : hf.sub hcond_memLp have hf2_int : Integrable (fun x => (f x - condExpExceptCoord (μs := μs) i f x)^2) μ_curr := hdiff_memLp.integrable_sq - have hcondVar := expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int + have hcondVar := + expectation_sq_diff_eq_expectation_condVar (f := f) i (hf.integrable one_le_two) hf2_int linarith - have h_sum : ∑ i : Fin ((k + 1) + 1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = - ((k + 1) + 1 : ℕ) * variance f μ_curr - + have h_sum : + ∑ i : Fin ((k + 1) + 1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = + ((k + 1) + 1 : ℕ) * variance f μ_curr - ∑ i, variance (condExpExceptCoord (μs := μs) i f) μ_curr := by simp_rw [h_condVar] rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_fin] @@ -1481,7 +1628,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hvar_nonneg := variance_nonneg f μ_curr - have hvar_cond_le : ∀ i, variance (condExpExceptCoord (μs := μs) i f) μ_curr ≤ variance f μ_curr := by + have hvar_cond_le : + ∀ i, variance (condExpExceptCoord (μs := μs) i f) μ_curr ≤ variance f μ_curr := by intro i have hcv := h_condVar i have h_nonneg : 0 ≤ ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := @@ -1502,7 +1650,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hsplit : ∑ i : Fin ((k+1)+1), ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = ∫ x, (f x - condExpExceptCoord (μs := μs) 0 f x)^2 ∂μ_curr + - ∑ i : Fin ((k+1)+1) with i ≠ 0, ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by + ∑ i : Fin ((k+1)+1) with i ≠ 0, + ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (0 : Fin ((k+1)+1)))] congr 1 apply Finset.sum_congr @@ -1515,15 +1664,18 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = (k + 1 : ℕ) * variance f μ_curr - ∑ i : Fin ((k+1)+1) with i ≠ 0, variance (condExpExceptCoord (μs := μs) i f) μ_curr := by - have hstep : ∑ i : Fin ((k+1)+1) with i ≠ 0, ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = - ∑ i : Fin ((k+1)+1) with i ≠ 0, (variance f μ_curr - variance (condExpExceptCoord (μs := μs) i f) μ_curr) := by + have hstep : ∑ i : Fin ((k+1)+1) with i ≠ 0, + ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr = + ∑ i : Fin ((k+1)+1) with i ≠ 0, + (variance f μ_curr - variance (condExpExceptCoord (μs := μs) i f) μ_curr) := by apply Finset.sum_congr rfl intro i _ exact h_condVar i rw [hstep, Finset.sum_sub_distrib] congr 1 rw [Finset.sum_const] - have hcard : (Finset.filter (fun i => i ≠ 0) (Finset.univ : Finset (Fin ((k+1)+1)))).card = k + 1 := by + have hcard : + (Finset.filter (fun i => i ≠ 0) (Finset.univ : Finset (Fin ((k+1)+1)))).card = k + 1 := by rw [Finset.filter_ne', Finset.card_erase_of_mem (Finset.mem_univ (0 : Fin ((k+1)+1)))] simp only [Finset.card_univ, Fintype.card_fin] omega @@ -1565,69 +1717,99 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hg_int := hg_memLp.integrable one_le_two have hg2 := hg_memLp.integrable_sq have hcond_g_int : Integrable (condExpExceptCoord (μs := μs) j g) μ_curr := by - have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + have hmp : + MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) μ_curr := by constructor · exact measurable_update' (a := j) - · have hgg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := + · have hgg : + Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := (measurable_update' (a := j)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + (μ_curr.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μ_curr.prod (μs j))) := (Measure.map_map hgg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) ((μs j).prod μ_curr) := by + (Measure.map Prod.swap (μ_curr.prod (μs j))) := + (Measure.map_map hgg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) + ((μs j).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi j - have hg_prod_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => g (Function.update p.1 j p.2)) (μ_curr.prod (μs j)) := + have hg_prod_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => g (Function.update p.1 j p.2)) + (μ_curr.prod (μs j)) := hmp.integrable_comp hg_int.aestronglyMeasurable |>.mpr hg_int unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_prod_int.integral_prod_left have hcond_g_sq_int : Integrable (condExpExceptCoord (μs := μs) j (g ^ 2)) μ_curr := by - have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + have hmp : + MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) μ_curr := by constructor · exact measurable_update' (a := j) - · have hgg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := + · have hgg : + Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := (measurable_update' (a := j)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + (μ_curr.prod (μs j)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) + (Measure.map Prod.swap (μ_curr.prod (μs j))) := + (Measure.map_map hgg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μ_curr.prod (μs j))) := (Measure.map_map hgg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) ((μs j).prod μ_curr) := by + ((μs j).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi j - have hg_prod_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (g ^ 2) (Function.update p.1 j p.2)) (μ_curr.prod (μs j)) := + have hg_prod_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (g ^ 2) (Function.update p.1 j p.2)) + (μ_curr.prod (μs j)) := hmp.integrable_comp hg2.aestronglyMeasurable |>.mpr hg2 unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_prod_int.integral_prod_left - have hg2_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => g (Function.update x j y) ^ 2) (μs j) := by - have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + have hg2_slice_ae : + ∀ᵐ x ∂μ_curr, Integrable (fun y => g (Function.update x j y) ^ 2) (μs j) := by + have hmp : + MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) μ_curr := by constructor · exact measurable_update' (a := j) - · have hgg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := + · have hgg : + Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := (measurable_update' (a := j)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + (μ_curr.prod (μs j)) _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μ_curr.prod (μs j))) := (Measure.map_map hgg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) ((μs j).prod μ_curr) := by + (Measure.map Prod.swap (μ_curr.prod (μs j))) := + (Measure.map_map hgg measurable_swap).symm + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) + ((μs j).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi j - have hg_prod_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (g ^ 2) (Function.update p.1 j p.2)) (μ_curr.prod (μs j)) := + have hg_prod_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => (g ^ 2) (Function.update p.1 j p.2)) + (μ_curr.prod (μs j)) := hmp.integrable_comp hg2.aestronglyMeasurable |>.mpr hg2 exact hg_prod_int.prod_right_ae - have hg_slice_ae : ∀ᵐ x ∂μ_curr, Integrable (fun y => g (Function.update x j y)) (μs j) := by - have hmp : MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + have hg_slice_ae : + ∀ᵐ x ∂μ_curr, Integrable (fun y => g (Function.update x j y)) (μs j) := by + have hmp : + MeasurePreserving (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) μ_curr := by constructor · exact measurable_update' (a := j) - · have hgg : Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := + · have hgg : + Measurable (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) := (measurable_update' (a := j)).comp measurable_swap - calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) (μ_curr.prod (μs j)) + calc Measure.map (fun p : (Fin ((k+1)+1) → Ω) × Ω => Function.update p.1 j p.2) + (μ_curr.prod (μs j)) + _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) + (Measure.map Prod.swap (μ_curr.prod (μs j))) := + (Measure.map_map hgg measurable_swap).symm _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) - (Measure.map Prod.swap (μ_curr.prod (μs j))) := (Measure.map_map hgg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin ((k+1)+1) → Ω) => Function.update q.2 j q.1) ((μs j).prod μ_curr) := by + ((μs j).prod μ_curr) := by rw [Measure.prod_swap] _ = μ_curr := map_update_prod_pi j - have hg_prod_int : Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => g (Function.update p.1 j p.2)) (μ_curr.prod (μs j)) := + have hg_prod_int : + Integrable (fun p : (Fin ((k+1)+1) → Ω) × Ω => g (Function.update p.1 j p.2)) + (μ_curr.prod (μs j)) := hmp.integrable_comp hg_int.aestronglyMeasurable |>.mpr hg_int exact hg_prod_int.prod_right_ae have hsq_int : Integrable (fun z => (condExpExceptCoord (μs := μs) j g z)^2) μ_curr := by @@ -1647,13 +1829,16 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : exact hsq_int have hdiff_memLp : MemLp (fun x => g x - condExpExceptCoord (μs := μs) j g x) 2 μ_curr := hg_memLp.sub hcond_g_memLp - have hg2_int' : Integrable (fun x => (g x - condExpExceptCoord (μs := μs) j g x)^2) μ_curr := + have hg2_int' : + Integrable (fun x => (g x - condExpExceptCoord (μs := μs) j g x)^2) μ_curr := hdiff_memLp.integrable_sq have hcondVar := expectation_sq_diff_eq_expectation_condVar (f := g) j hg_int hg2_int' linarith - have hg_sum : ∑ j : Fin ((k+1)+1), ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = - ((k+1)+1 : ℕ) * variance g μ_curr - ∑ j, variance (condExpExceptCoord (μs := μs) j g) μ_curr := by + have hg_sum : + ∑ j : Fin ((k+1)+1), ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = + ((k+1)+1 : ℕ) * variance g μ_curr - + ∑ j, variance (condExpExceptCoord (μs := μs) j g) μ_curr := by simp_rw [hg_condVar] rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_fin] simp only [nsmul_eq_mul, Nat.cast_add, Nat.cast_one] @@ -1663,16 +1848,21 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hvar_g_nonneg : 0 ≤ variance g μ_curr := variance_nonneg _ _ - have hterm_nonneg : ∀ j : Fin ((k+1)+1), 0 ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by + have hterm_nonneg : + ∀ j : Fin ((k+1)+1), 0 ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by intro j; apply integral_nonneg (fun x => sq_nonneg _) - have hg_split : ∑ j : Fin ((k+1)+1), ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = + have hg_split : + ∑ j : Fin ((k+1)+1), ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = ∫ x, (g x - condExpExceptCoord (μs := μs) 0 g x)^2 ∂μ_curr + - ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by + ∑ j : Fin ((k+1)+1) with j ≠ 0, + ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (0 : Fin ((k+1)+1)))] congr 1 apply Finset.sum_congr - · ext i; simp only [Finset.mem_erase, Finset.mem_univ, Finset.mem_filter, and_true, ne_eq]; tauto + · ext i + simp only [Finset.mem_erase, Finset.mem_univ, Finset.mem_filter, and_true, ne_eq] + tauto · intro _ _; rfl rw [hg_split, h_idem_term, zero_add] at hg_sum @@ -1704,14 +1894,18 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · intro ⟨hi0, hi1⟩; exact ⟨hi1, hi0⟩ · intro _ _; rfl - have hvar_proj_le : ∀ j : Fin ((k+1)+1), variance (condExpExceptCoord (μs := μs) j g) μ_curr ≤ variance g μ_curr := by + have hvar_proj_le : ∀ j : Fin ((k+1)+1), + variance (condExpExceptCoord (μs := μs) j g) μ_curr ≤ variance g μ_curr := by intro j have hcv := hg_condVar j have h_nonneg := hterm_nonneg j linarith - have hvar_e0g : variance (condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) g) μ_curr = variance g μ_curr := by - have hidem : condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) g = g := condExpExceptCoord_idempotent 0 f + have hvar_e0g : + variance (condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) g) μ_curr = + variance g μ_curr := by + have hidem : condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) g = g := + condExpExceptCoord_idempotent 0 f simp only [hidem] have hsum_var_bound : ∑ j : Fin ((k+1)+1) with j ≠ 0, @@ -1719,7 +1913,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : calc ∑ j : Fin ((k+1)+1) with j ≠ 0, variance (condExpExceptCoord (μs := μs) j g) μ_curr _ ≤ ∑ j : Fin ((k+1)+1) with j ≠ 0, variance g μ_curr := by apply Finset.sum_le_sum; intro j _; exact hvar_proj_le j - _ = (Finset.filter (fun j => j ≠ 0) (Finset.univ : Finset (Fin ((k+1)+1)))).card * variance g μ_curr := by + _ = (Finset.filter (fun j => j ≠ 0) (Finset.univ : Finset (Fin ((k+1)+1)))).card * + variance g μ_curr := by rw [Finset.sum_const, nsmul_eq_mul] _ = (k+1 : ℕ) * variance g μ_curr := by congr 1 @@ -1727,13 +1922,16 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : simp only [Finset.card_univ, Fintype.card_fin] rfl - have hsum_var_split : ∑ j : Fin ((k+1)+1), variance (condExpExceptCoord (μs := μs) j g) μ_curr = + have hsum_var_split : + ∑ j : Fin ((k+1)+1), variance (condExpExceptCoord (μs := μs) j g) μ_curr = variance g μ_curr + ∑ j : Fin ((k+1)+1) with j ≠ 0, variance (condExpExceptCoord (μs := μs) j g) μ_curr := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (0 : Fin ((k+1)+1))), hvar_e0g] congr 1 apply Finset.sum_congr - · ext i; simp only [Finset.mem_erase, Finset.mem_univ, Finset.mem_filter, and_true, ne_eq]; tauto + · ext i + simp only [Finset.mem_erase, Finset.mem_univ, Finset.mem_filter, and_true, ne_eq] + tauto · intro _ _; rfl rw [hsum_var_split] at hg_sum @@ -1741,7 +1939,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = (k+1 : ℕ) * variance g μ_curr - ∑ j : Fin ((k+1)+1) with j ≠ 0, variance (condExpExceptCoord (μs := μs) j g) μ_curr := by - have heq : ((k+1+1) : ℕ) * variance g μ_curr - (variance g μ_curr + ∑ j : Fin ((k+1)+1) with j ≠ 0, + have heq : + ((k+1+1) : ℕ) * variance g μ_curr - (variance g μ_curr + ∑ j : Fin ((k+1)+1) with j ≠ 0, variance (condExpExceptCoord (μs := μs) j g) μ_curr) = ((k+1) : ℕ) * variance g μ_curr - ∑ j : Fin ((k+1)+1) with j ≠ 0, variance (condExpExceptCoord (μs := μs) j g) μ_curr := by @@ -1760,7 +1959,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : rw [hsum_singleton] have hg_indep : ∀ x y, g (Function.update x (0 : Fin 2) y) = g x := fun x y => condExpExceptCoord_update (μs := μs) (0 : Fin 2) f x y - have he1g_indep0 : ∀ x y, condExpExceptCoord (μs := μs) (1 : Fin 2) g (Function.update x 0 y) = + have he1g_indep0 : + ∀ x y, condExpExceptCoord (μs := μs) (1 : Fin 2) g (Function.update x 0 y) = condExpExceptCoord (μs := μs) (1 : Fin 2) g x := by intro x y simp only [condExpExceptCoord] @@ -1769,7 +1969,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : Function.update (Function.update x 1 w) 0 y := by ext i; fin_cases i <;> simp [Function.update] rw [hcomm, hg_indep] - have he1g_indep1 : ∀ x y, condExpExceptCoord (μs := μs) (1 : Fin 2) g (Function.update x 1 y) = + have he1g_indep1 : + ∀ x y, condExpExceptCoord (μs := μs) (1 : Fin 2) g (Function.update x 1 y) = condExpExceptCoord (μs := μs) (1 : Fin 2) g x := fun x y => condExpExceptCoord_update (μs := μs) (1 : Fin 2) g x y by_cases hne : Nonempty (Fin 2 → Ω) @@ -1799,7 +2000,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have h1ne0 : (1 : Fin 2) ≠ 0 := by simp exact h_sq_bound 1 h1ne0 · have hkey : variance g μ_curr ≤ - ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by + ∑ j : Fin ((k+1)+1) with j ≠ 0, + ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := by let h : ℕ → ((Fin ((k+1)+1) → Ω) → ℝ) := fun m => Nat.recOn m g (fun m' h_prev => if hm' : m' + 1 < (k+1)+1 then @@ -1808,7 +2010,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hh0 : h 0 = g := rfl have hh_succ : ∀ m (hm : m < k + 1), - h (m + 1) = condExpExceptCoord (μs := μs) ⟨m + 1, Nat.add_lt_add_right hm 1⟩ (h m) := by + h (m + 1) = + condExpExceptCoord (μs := μs) ⟨m + 1, Nat.add_lt_add_right hm 1⟩ (h m) := by intro m hm simp only [h] have hcond : m + 1 < (k+1)+1 := by omega @@ -1831,11 +2034,13 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : variance (h (m+1)) μ_curr := by intro m hm have hm_le : m ≤ k + 1 := by omega - have htv := total_variance_identity (μs := μs) ⟨m + 1, by omega⟩ (h m) (hh_memLp m hm_le) + have htv := + total_variance_identity (μs := μs) ⟨m + 1, by omega⟩ (h m) (hh_memLp m hm_le) have hcv := expectation_sq_diff_eq_expectation_condVar (f := h m) ⟨m + 1, by omega⟩ ((hh_memLp m hm_le).integrable one_le_two) - (((hh_memLp m hm_le).sub (memLp_condExpExceptCoord ⟨m + 1, by omega⟩ _ (hh_memLp m hm_le))).integrable_sq) + (((hh_memLp m hm_le).sub + (memLp_condExpExceptCoord ⟨m + 1, by omega⟩ _ (hh_memLp m hm_le))).integrable_sq) have heq : condExpExceptCoord (μs := μs) ⟨m + 1, by omega⟩ (h m) = h (m + 1) := by rw [hh_succ m hm] rw [heq] at htv hcv @@ -1859,12 +2064,16 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : calc ∫ x, (condExpExceptCoord (μs := μs) ⟨m' + 1, by omega⟩ (h m') x - condExpExceptCoord (μs := μs) ⟨m' + 2, by omega⟩ (condExpExceptCoord (μs := μs) ⟨m' + 1, by omega⟩ (h m')) x)^2 ∂μ_curr - _ ≤ ∫ x, ((h m') x - condExpExceptCoord (μs := μs) ⟨m' + 2, by omega⟩ (h m') x)^2 ∂μ_curr := hstep1 - _ ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m' + 2, by omega⟩ g x)^2 ∂μ_curr := by + _ ≤ ∫ x, ((h m') x - condExpExceptCoord (μs := μs) ⟨m' + 2, by omega⟩ (h m') x)^2 + ∂μ_curr := + hstep1 + _ ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m' + 2, by omega⟩ g x)^2 + ∂μ_curr := by clear ih have hbound : ∀ m'' (hm''_le : m'' ≤ k + 1) (j : ℕ) (hj_bound : j ≤ k + 1) (hj_ne : ∀ i, i ≤ m'' → j ≠ i), - ∫ x, ((h m'') x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ (h m'') x)^2 ∂μ_curr ≤ + ∫ x, ((h m'') x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ (h m'') x)^2 + ∂μ_curr ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ g x)^2 ∂μ_curr := by intro m'' induction m'' with @@ -1880,12 +2089,19 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hij' : (⟨m''' + 1, by omega⟩ : Fin ((k+1)+1)) ≠ ⟨j, by omega⟩ := by simp only [ne_eq, Fin.ext_iff] omega - have hstep := sq_diff_condExpExceptCoord_bound_gen hij' (h m''') (hh_memLp m''' hm'''_le') + have hstep := + sq_diff_condExpExceptCoord_bound_gen hij' (h m''') + (hh_memLp m''' hm'''_le') calc ∫ x, (condExpExceptCoord (μs := μs) ⟨m''' + 1, by omega⟩ (h m''') x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ - (condExpExceptCoord (μs := μs) ⟨m''' + 1, by omega⟩ (h m''')) x)^2 ∂μ_curr - _ ≤ ∫ x, ((h m''') x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ (h m''') x)^2 ∂μ_curr := hstep - _ ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ g x)^2 ∂μ_curr := by + (condExpExceptCoord (μs := μs) ⟨m''' + 1, by omega⟩ + (h m''')) x)^2 + ∂μ_curr + _ ≤ ∫ x, ((h m''') x - + condExpExceptCoord (μs := μs) ⟨j, by omega⟩ (h m''') x)^2 ∂μ_curr := + hstep + _ ≤ ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨j, by omega⟩ g x)^2 + ∂μ_curr := by apply ih_inner hm'''_le' j hj_bound intro i hi have := hj_ne i (by omega : i ≤ m''' + 1) @@ -1896,7 +2112,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have hsum_eq : ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr = - ∑ m : Fin (k+1), ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m.val + 1, by omega⟩ g x)^2 ∂μ_curr := by + ∑ m : Fin (k+1), + ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m.val + 1, by omega⟩ g x)^2 ∂μ_curr := by rw [show Finset.filter (· ≠ 0) Finset.univ = Finset.map ⟨Fin.succ, Fin.succ_injective _⟩ Finset.univ by ext j @@ -1954,7 +2171,8 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : have h_eq := htelescope_eq (k + 1) (le_refl _) simp only [hh0] at h_eq have hvar_hkp1_zero : variance (h (k + 1)) μ_curr = 0 := by - have h_indep : ∀ m (hm : m ≤ k + 1) (j : Fin ((k+1)+1)) (hj : j.val ≤ m) (x : Fin ((k+1)+1) → Ω) (y : Ω), + have h_indep : ∀ m (hm : m ≤ k + 1) (j : Fin ((k+1)+1)) (hj : j.val ≤ m) + (x : Fin ((k+1)+1) → Ω) (y : Ω), h m (Function.update x j y) = h m x := by intro m induction m with @@ -2018,13 +2236,17 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : · have hj_eq : j = ⟨m', by omega⟩ := Fin.ext hjeq rw [hj_eq] simp only [↓reduceIte, Nat.lt_succ_self, Function.update_self] - · have hjgt : j.val > m' := Nat.lt_of_le_of_ne (Nat.not_lt.mp hjm) (Ne.symm hjeq) + · have hjgt : j.val > m' := + Nat.lt_of_le_of_ne (Nat.not_lt.mp hjm) (Ne.symm hjeq) have hnjm : ¬(j.val < m') := Nat.not_lt.mpr (Nat.le_of_lt hjgt) - have hnjm1 : ¬(j.val < m' + 1) := Nat.not_lt.mpr (Nat.succ_le_of_lt hjgt) + have hnjm1 : + ¬(j.val < m' + 1) := Nat.not_lt.mpr (Nat.succ_le_of_lt hjgt) have hne : j ≠ ⟨m', by omega⟩ := by simp only [ne_eq, Fin.ext_iff]; omega - simp only [hnjm, hnjm1, ↓reduceIte, Function.update, hne, ↓reduceDIte] - rw [heq, h_indep (k+1) (le_refl _) ⟨m', by omega⟩ (by omega : m' ≤ k+1), ihm' hm''] + simp only [hnjm, hnjm1, ↓reduceIte, Function.update, hne, + ↓reduceDIte] + rw [heq, h_indep (k+1) (le_refl _) ⟨m', by omega⟩ (by omega : m' ≤ k+1), + ihm' hm''] have hfinal : (fun j => if j.val < (k+1)+1 then x₀ j else y j) = x₀ := by ext j; simp [j.isLt] rw [← hfinal, ← hrev ((k+1)+1) (le_refl _)] @@ -2041,27 +2263,36 @@ theorem efronStein (f : (Fin n → Ω) → ℝ) (hf : MemLp f 2 μˢ) : calc variance g μ_curr _ ≤ ∑ m : Fin (k+1), ∫ x, ((h m.val) x - (h (m.val + 1)) x)^2 ∂μ_curr := htelescope - _ ≤ ∑ m : Fin (k+1), ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m.val + 1, by omega⟩ g x)^2 ∂μ_curr := by + _ ≤ ∑ m : Fin (k+1), + ∫ x, (g x - condExpExceptCoord (μs := μs) ⟨m.val + 1, by omega⟩ g x)^2 ∂μ_curr := by apply Finset.sum_le_sum intro m _ exact hcontract m.val (by have := m.isLt; omega) - _ = ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := hsum_eq.symm + _ = ∑ j : Fin ((k+1)+1) with j ≠ 0, + ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := hsum_eq.symm calc variance g μ_curr - _ ≤ ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := hkey - _ ≤ ∑ j : Fin ((k+1)+1) with j ≠ 0, ∫ x, (f x - condExpExceptCoord (μs := μs) j f x)^2 ∂μ_curr := h_sum_bound + _ ≤ ∑ j : Fin ((k+1)+1) with j ≠ 0, + ∫ x, (g x - condExpExceptCoord (μs := μs) j g x)^2 ∂μ_curr := + hkey + _ ≤ ∑ j : Fin ((k+1)+1) with j ≠ 0, + ∫ x, (f x - condExpExceptCoord (μs := μs) j f x)^2 ∂μ_curr := + h_sum_bound rw [hsplit] have hcondvar_eq := expectation_sq_diff_eq_expectation_condVar (f := f) (0 : Fin ((k+1)+1)) - (hf.integrable one_le_two) ((hf.sub (memLp_condExpExceptCoord (0 : Fin ((k+1)+1)) f hf)).integrable_sq) + (hf.integrable one_le_two) + ((hf.sub (memLp_condExpExceptCoord (0 : Fin ((k+1)+1)) f hf)).integrable_sq) calc variance f μ_curr _ = ∫ x, condVarExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f x ∂μ_curr + variance (condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f) μ_curr := htv0 _ = ∫ x, (f x - condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f x)^2 ∂μ_curr + - variance (condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f) μ_curr := by rw [hcondvar_eq] + variance (condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f) μ_curr := by + rw [hcondvar_eq] _ ≤ ∫ x, (f x - condExpExceptCoord (μs := μs) (0 : Fin ((k+1)+1)) f x)^2 ∂μ_curr + - ∑ i : Fin ((k+1)+1) with i ≠ 0, ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by + ∑ i : Fin ((k+1)+1) with i ≠ 0, + ∫ x, (f x - condExpExceptCoord (μs := μs) i f x)^2 ∂μ_curr := by linarith [hkey_bound] end MainTheorem diff --git a/StatsMLlib/Probability/Concentration/HansonWright.lean b/StatsMLlib/Probability/Concentration/HansonWright.lean index a787a35..68d92b3 100644 --- a/StatsMLlib/Probability/Concentration/HansonWright.lean +++ b/StatsMLlib/Probability/Concentration/HansonWright.lean @@ -231,7 +231,8 @@ lemma coordinateMask_apply {n : ℕ} (s : Finset (Fin n)) (x : EuclideanSpace ℝ (Fin n)) (i : Fin n) : coordinateMask s x i = if i ∈ s then x i else 0 := rfl -/-- Embed a tuple indexed by a finite set into Euclidean space, filling other coordinates by zero. -/ +/-- Embed a tuple indexed by a finite set into Euclidean space, filling other coordinates by +zero. -/ def subtypeMask {n : ℕ} (s : Finset (Fin n)) (x : s → ℝ) : EuclideanSpace ℝ (Fin n) := WithLp.toLp 2 fun i => if h : i ∈ s then x ⟨i, h⟩ else 0 @@ -3199,7 +3200,8 @@ lemma integral_exp_norm_toEuclideanCLM_randomVector_sq_le {μ : Measure Ω} constructor · filter_upwards with g exact - (inner_randomVector_hasSubgaussianMGF_of_iIndepFun h_indep hX_subG (U g)).integrable_exp_mul s + (inner_randomVector_hasSubgaussianMGF_of_iIndepFun h_indep hX_subG (U g)).integrable_exp_mul + s · have hnorm_outer_bound : (fun g : E => ‖∫ ω, ‖f (g, ω)‖ ∂μ‖) ≤ᵐ[γ] fun g : E => exp ((K ^ 2 * θ) * inner ℝ (S g) g) := by @@ -3362,7 +3364,8 @@ lemma integrable_exp_norm_toEuclideanCLM_randomVector_sq {μ : Measure Ω} constructor · filter_upwards with g exact - (inner_randomVector_hasSubgaussianMGF_of_iIndepFun h_indep hX_subG (U g)).integrable_exp_mul s + (inner_randomVector_hasSubgaussianMGF_of_iIndepFun h_indep hX_subG (U g)).integrable_exp_mul + s · have hnorm_outer_bound : (fun g : E => ‖∫ ω, ‖f (g, ω)‖ ∂μ‖) ≤ᵐ[γ] fun g : E => exp ((K ^ 2 * θ) * inner ℝ (S g) g) := by diff --git a/StatsMLlib/Probability/Concentration/Hoeffding.lean b/StatsMLlib/Probability/Concentration/Hoeffding.lean index d1a3beb..0beca7d 100644 --- a/StatsMLlib/Probability/Concentration/Hoeffding.lean +++ b/StatsMLlib/Probability/Concentration/Hoeffding.lean @@ -40,7 +40,8 @@ theorem cgf_zero_deriv [IsProbabilityMeasure μ] {X : Ω → ℝ} (h0 : μ[X] = simp only [zero_mul, tilted_const', measure_univ, inv_one, one_smul] exact h0 -theorem cgf_le_quadratic_of_nonneg [IsProbabilityMeasure μ] (t a b : ℝ) {X : Ω → ℝ} (ht : 0 ≤ t) (hX : AEMeasurable X μ) +theorem cgf_le_quadratic_of_nonneg [IsProbabilityMeasure μ] (t a b : ℝ) {X : Ω → ℝ} (ht : 0 ≤ t) + (hX : AEMeasurable X μ) (h : ∀ᵐ (ω : Ω) ∂μ, X ω ∈ Set.Icc a b) (h0 : ∫ (x : Ω), X x ∂μ = 0) (w : ¬t = 0) : cgf X μ t ≤ t ^ 2 * (b - a) ^ 2 / 8 := by let f := fun t ↦ cgf X μ t @@ -89,7 +90,8 @@ theorem cgf_le_quadratic_of_nonneg [IsProbabilityMeasure μ] (t a b : ℝ) {X : isProbabilityMeasure_tilted (integrable_expt_bound hX h) have hμ := tilted_absolutelyContinuous μ fun ω ↦ x * X ω apply variance_eq_sub <| - MeasureTheory.memLp_of_bounded (hμ h) (AEMeasurable.aestronglyMeasurable (hX.mono_ac hμ)) 2 + MeasureTheory.memLp_of_bounded (hμ h) + (AEMeasurable.aestronglyMeasurable (hX.mono_ac hμ)) 2 rw [p] simp only [Pi.pow_apply, mul_one] ring diff --git a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianCompactSupport.lean b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianCompactSupport.lean index 6e6a667..4a0d06d 100644 --- a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianCompactSupport.lean +++ b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianCompactSupport.lean @@ -60,7 +60,8 @@ theorem gaussian_logSobolev_CompSmo {f : ℝ → ℝ} (hf : CompactlySupportedSm ∂rademacherProductMeasure (n + 1)) atTop (𝓝 (4 * ∫ x, (deriv f x)^2 ∂stdGaussianMeasure)) := tendsto_sum_sq_shifted_four_deriv_sq hf - -- Step 3: The RHS of the discrete inequality converges to (1/2) * 4 * ∫ (deriv f)² = 2 * ∫ (deriv f)² + -- Step 3: The RHS of the discrete inequality converges to + -- (1/2) * 4 * ∫ (deriv f)² = 2 * ∫ (deriv f)² have h_rhs : Tendsto (fun n => (1/2 : ℝ) * ∑ i : Fin (n + 1), ∫ x, (f (rademacherSumProd (n + 1) x) - f (rademacherSumShifted (n + 1) i x))^2 ∂rademacherProductMeasure (n + 1)) atTop diff --git a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianOneDim.lean b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianOneDim.lean index 5b4a950..dd419bb 100644 --- a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianOneDim.lean +++ b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianOneDim.lean @@ -493,7 +493,8 @@ theorem gaussian_logSobolev_W12_real {f : ℝ → ℝ} have hf_mem : MemLp (fun x => ‖fderiv ℝ f x‖) 2 μ := hf.2.norm have hg_mem : ∀ k, MemLp (fun x => ‖fderiv ℝ (g k) x‖) 2 μ := by intro k - obtain ⟨C, hC_nonneg, hC_bound⟩ := TaylorBound.deriv_bounded_of_compactlySupported (hg_compact k) + obtain ⟨C, hC_nonneg, hC_bound⟩ := + TaylorBound.deriv_bounded_of_compactlySupported (hg_compact k) have h_bound : ∀ x, ‖fderiv ℝ (g k) x‖ ≤ C := by intro x have h_deriv : |deriv (g k) x| ≤ C := hC_bound x @@ -811,7 +812,8 @@ theorem gaussian_logSobolev_W12_real {f : ℝ → ℝ} have hq_cont : Continuous q := hf_diff.continuous.pow 2 exact (phi_continuous.comp hq_cont).add continuous_const have h_asm : AEStronglyMeasurable h μ := h_cont.aestronglyMeasurable - have h_lintegral_le : ∫⁻ x, ENNReal.ofReal (h x) ∂μ ≤ ENNReal.ofReal (L + 1 / Real.exp 1) := by + have h_lintegral_le : + ∫⁻ x, ENNReal.ofReal (h x) ∂μ ≤ ENNReal.ofReal (L + 1 / Real.exp 1) := by calc ∫⁻ x, ENNReal.ofReal (h x) ∂μ = ∫⁻ x, Filter.liminf (fun n => ENNReal.ofReal (hk n x)) atTop ∂μ := by refine lintegral_congr_ae ?_ diff --git a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianTensorization.lean b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianTensorization.lean index 1170fcd..7240a77 100644 --- a/StatsMLlib/Probability/Concentration/LogSobolev/GaussianTensorization.lean +++ b/StatsMLlib/Probability/Concentration/LogSobolev/GaussianTensorization.lean @@ -316,7 +316,8 @@ lemma sum_expected_condEnt_le_grad_norm (n : ℕ) (g : (Fin n → ℝ) → ℝ) Measure.map (fun p : (Fin n → ℝ) × ℝ => Function.update p.1 i p.2) ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1)) = Measure.map (fun q : ℝ × (Fin n → ℝ) => Function.update q.2 i q.1) - (Measure.map Prod.swap ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1))) := by + (Measure.map Prod.swap + ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1))) := by -- update ∘ swap rw [Measure.map_map h_map measurable_swap] rfl @@ -375,7 +376,8 @@ lemma sum_expected_condEnt_le_grad_norm (n : ℕ) (g : (Fin n → ℝ) → ℝ) Measure.map (fun p : (Fin n → ℝ) × ℝ => Function.update p.1 i p.2) ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1)) = Measure.map (fun q : ℝ × (Fin n → ℝ) => Function.update q.2 i q.1) - (Measure.map Prod.swap ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1))) := by + (Measure.map Prod.swap + ((GaussianMeasure.stdGaussianPi n).prod (gaussianReal 0 1))) := by rw [Measure.map_map h_map measurable_swap] rfl _ = Measure.map (fun q : ℝ × (Fin n → ℝ) => Function.update q.2 i q.1) @@ -423,7 +425,8 @@ lemma sum_expected_condEnt_le_grad_norm (n : ℕ) (g : (Fin n → ℝ) → ℝ) -- factor out the constant 2 have h_sum'' : ∑ i ∈ Finset.univ, 2 * ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n) = - 2 * ∑ i ∈ Finset.univ, ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n) := by + 2 * ∑ i ∈ Finset.univ, + ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n) := by simpa using (Finset.mul_sum (s := Finset.univ) (f := fun i => ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n)) @@ -432,7 +435,8 @@ lemma sum_expected_condEnt_le_grad_norm (n : ℕ) (g : (Fin n → ℝ) → ℝ) ∑ i ∈ Finset.univ, ∫ x, SubAddEnt.condEntExceptCoord (μs := fun _ : Fin n => gaussianReal 0 1) i (fun z => (g z)^2) x ∂(GaussianMeasure.stdGaussianPi n) ≤ - 2 * ∑ i ∈ Finset.univ, ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n) := by + 2 * ∑ i ∈ Finset.univ, + ∫ z, (partialDeriv i g z)^2 ∂(GaussianMeasure.stdGaussianPi n) := by simpa [h_sum''] using h_sum' convert h_sum''' using 1 -- convert sum of integrals to integral of sum diff --git a/StatsMLlib/Probability/Concentration/LogSobolev/TwoPoint.lean b/StatsMLlib/Probability/Concentration/LogSobolev/TwoPoint.lean index 3b45b5f..be66701 100644 --- a/StatsMLlib/Probability/Concentration/LogSobolev/TwoPoint.lean +++ b/StatsMLlib/Probability/Concentration/LogSobolev/TwoPoint.lean @@ -170,7 +170,8 @@ theorem deriv_deriv_gPlus {t : ℝ} (ht : -1 < t) : deriv (deriv gPlus) t = 1 / exact deriv_gPlus hs rw [Filter.EventuallyEq.deriv_eq hdiff] have h1 : DifferentiableAt ℝ (fun s => 1 + s) t := differentiableAt_id.const_add 1 - have hlog_diff : DifferentiableAt ℝ (fun s => log (1 + s)) t := (differentiableAt_log h.ne').comp t h1 + have hlog_diff : DifferentiableAt ℝ (fun s => log (1 + s)) t := + (differentiableAt_log h.ne').comp t h1 have h_deriv_add : deriv (fun s => log (1 + s) + 1) t = deriv (fun s => log (1 + s)) t + deriv (fun _ => (1 : ℝ)) t := deriv_add hlog_diff (differentiableAt_const 1) @@ -191,7 +192,8 @@ theorem deriv_deriv_gMinus {t : ℝ} (ht : t < 1) : deriv (deriv gMinus) t = 1 / exact deriv_gMinus hs rw [Filter.EventuallyEq.deriv_eq hdiff] have h1 : DifferentiableAt ℝ (fun s => 1 - s) t := differentiableAt_id.const_sub 1 - have hlog_diff : DifferentiableAt ℝ (fun s => log (1 - s)) t := (differentiableAt_log h.ne').comp t h1 + have hlog_diff : DifferentiableAt ℝ (fun s => log (1 - s)) t := + (differentiableAt_log h.ne').comp t h1 have h_deriv_sub : deriv (fun s => -log (1 - s) - 1) t = deriv (fun y => -log (1 - y)) t - deriv (fun _ => (1 : ℝ)) t := deriv_sub hlog_diff.neg (differentiableAt_const 1) @@ -218,8 +220,10 @@ theorem deriv2_phi {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : rw [Filter.EventuallyEq.deriv_eq hdiff] have hd1 : DifferentiableAt ℝ (fun s => 1 + s) t := differentiableAt_id.const_add 1 have hd2 : DifferentiableAt ℝ (fun s => 1 - s) t := differentiableAt_id.const_sub 1 - have hlog1_diff : DifferentiableAt ℝ (fun s => log (1 + s)) t := (differentiableAt_log h1.ne').comp t hd1 - have hlog2_diff : DifferentiableAt ℝ (fun s => log (1 - s)) t := (differentiableAt_log h2.ne').comp t hd2 + have hlog1_diff : DifferentiableAt ℝ (fun s => log (1 + s)) t := + (differentiableAt_log h1.ne').comp t hd1 + have hlog2_diff : DifferentiableAt ℝ (fun s => log (1 - s)) t := + (differentiableAt_log h2.ne').comp t hd2 have h_deriv_sub : deriv (fun s => log (1 + s) - log (1 - s)) t = deriv (fun s => log (1 + s)) t - deriv (fun s => log (1 - s)) t := deriv_sub hlog1_diff hlog2_diff @@ -352,7 +356,8 @@ theorem two_point_inequality {a b : ℝ} (ha : 0 < a) (hb : 0 < b) : -- Apply convexity definition have hconvex := hconv.2 ha_mem hb_mem hw1 hw2 hsum simp only [smul_eq_mul] at hconvex - -- hconvex : (1/2 * a + 1/2 * b) * log(1/2 * a + 1/2 * b) ≤ 1/2 * (a * log a) + 1/2 * (b * log b) + -- hconvex : (1/2 * a + 1/2 * b) * log(1/2 * a + 1/2 * b) ≤ + -- 1/2 * (a * log a) + 1/2 * (b * log b) have hmid' : 1/2 * a + 1/2 * b = (a + b) / 2 := by ring rw [hmid'] at hconvex have hrhs : 1/2 * (a * log a) + 1/2 * (b * log b) = (a * log a + b * log b) / 2 := by ring @@ -423,7 +428,8 @@ theorem deriv_sqrtTerm {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : have hd_inner_val : deriv (fun s => 1 - s^2) t = -2 * t := by have hd_const : DifferentiableAt ℝ (fun _ : ℝ => (1 : ℝ)) t := differentiableAt_const 1 have hd_pow : DifferentiableAt ℝ (fun s => s^2) t := differentiableAt_pow 2 - have h_sub_deriv : deriv (fun s => 1 - s^2) t = deriv (fun _ => (1 : ℝ)) t - deriv (fun s => s^2) t := + have h_sub_deriv : + deriv (fun s => 1 - s^2) t = deriv (fun _ => (1 : ℝ)) t - deriv (fun s => s^2) t := deriv_sub hd_const hd_pow -- Compute deriv (fun s => s^2) t explicitly using HasDerivAt have hd_sq : deriv (fun s : ℝ => s^2) t = 2 * t := by @@ -518,7 +524,8 @@ theorem deriv2_sqrtTerm {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : have d_inner : deriv (fun s => 1 - s^2) t = -2 * t := by have hd_const : DifferentiableAt ℝ (fun _ : ℝ => (1 : ℝ)) t := differentiableAt_const 1 have hd_pow : DifferentiableAt ℝ (fun s => s^2) t := differentiableAt_pow 2 - have h_sub_deriv : deriv (fun s => 1 - s^2) t = deriv (fun _ => (1 : ℝ)) t - deriv (fun s => s^2) t := + have h_sub_deriv : + deriv (fun s => 1 - s^2) t = deriv (fun _ => (1 : ℝ)) t - deriv (fun s => s^2) t := deriv_sub hd_const hd_pow have hd_sq : deriv (fun s : ℝ => s^2) t = 2 * t := by have h := hasDerivAt_pow 2 t @@ -612,7 +619,8 @@ theorem differentiableAt_deriv_rothausDefect {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ differentiableAt_const 1 |>.sub (differentiableAt_pow 2) have hd1 : DifferentiableAt ℝ (fun s => 1 + s) t := differentiableAt_id.const_add 1 have hd2 : DifferentiableAt ℝ (fun s => 1 - s) t := differentiableAt_id.const_sub 1 - have hdiff_rhs : DifferentiableAt ℝ (fun s => 2 * s / sqrt (1 - s^2) - (log (1 + s) - log (1 - s))) t := + have hdiff_rhs : + DifferentiableAt ℝ (fun s => 2 * s / sqrt (1 - s^2) - (log (1 + s) - log (1 - s))) t := (hd_num.div (hd_inner.sqrt h1.ne') (sqrt_ne_zero'.mpr h1)).sub (((differentiableAt_log h1p.ne').comp t hd1).sub ((differentiableAt_log h1m.ne').comp t hd2)) exact hdiff_rhs.congr_of_eventuallyEq heq @@ -646,11 +654,14 @@ theorem rothausDefect_nonneg {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : 0 ≤ rot intro x hx have hx_mem : x ∈ Ioo (-1 : ℝ) 1 := ⟨by linarith [ht.1, hξ₁_mem.1, hx.1], by linarith [hx.2]⟩ exact (differentiableAt_deriv_rothausDefect hx_mem).differentiableWithinAt - obtain ⟨ξ₂, hξ₂_mem, hξ₂_eq⟩ := exists_deriv_eq_slope (deriv rothausDefect) hξ₁_neg hcont' hdiff' + obtain ⟨ξ₂, hξ₂_mem, hξ₂_eq⟩ := + exists_deriv_eq_slope (deriv rothausDefect) hξ₁_neg hcont' hdiff' simp only [deriv_rothausDefect_zero] at hξ₂_eq -- deriv rothausDefect(0) - deriv rothausDefect(ξ₁) = deriv² rothausDefect(ξ₂) * (0 - ξ₁) - -- So deriv rothausDefect(ξ₁) = -deriv² rothausDefect(ξ₂) * (-ξ₁) = deriv² rothausDefect(ξ₂) * ξ₁ - have hξ₂_in : ξ₂ ∈ Ioo (-1 : ℝ) 1 := ⟨by linarith [ht.1, hξ₁_mem.1, hξ₂_mem.1], by linarith [hξ₂_mem.2]⟩ + -- So deriv rothausDefect(ξ₁) = -deriv² rothausDefect(ξ₂) * (-ξ₁) + -- = deriv² rothausDefect(ξ₂) * ξ₁ + have hξ₂_in : ξ₂ ∈ Ioo (-1 : ℝ) 1 := + ⟨by linarith [ht.1, hξ₁_mem.1, hξ₂_mem.1], by linarith [hξ₂_mem.2]⟩ have h_deriv_ξ₁ : deriv rothausDefect ξ₁ = deriv (deriv rothausDefect) ξ₂ * ξ₁ := by -- hξ₂_eq : deriv (deriv rothausDefect) ξ₂ = (0 - deriv rothausDefect ξ₁) / (0 - ξ₁) have hξ₁_ne : ξ₁ ≠ 0 := ne_of_lt hξ₁_neg @@ -659,7 +670,8 @@ theorem rothausDefect_nonneg {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : 0 ≤ rot exact sub_ne_zero.mpr hξ₁_ne.symm simp only [zero_sub] at h1 linarith - -- Now combine: rothausDefect(t) = deriv rothausDefect(ξ₁) * t / t = -deriv rothausDefect(ξ₁) * (-t) / (-t) + -- Now combine: rothausDefect(t) = deriv rothausDefect(ξ₁) * t / t + -- = -deriv rothausDefect(ξ₁) * (-t) / (-t) have h_rothausDefect_t : rothausDefect t = deriv (deriv rothausDefect) ξ₂ * ξ₁ * t := by -- hξ₁_eq : deriv rothausDefect ξ₁ = (0 - rothausDefect t) / (0 - t) have ht_ne : t ≠ 0 := ne_of_lt ht_neg @@ -701,9 +713,11 @@ theorem rothausDefect_nonneg {t : ℝ} (ht : t ∈ Ioo (-1 : ℝ) 1) : 0 ≤ rot intro x hx have hx_mem : x ∈ Ioo (-1 : ℝ) 1 := ⟨by linarith [hx.1], by linarith [ht.2, hξ₁_mem.2, hx.2]⟩ exact (differentiableAt_deriv_rothausDefect hx_mem).differentiableWithinAt - obtain ⟨ξ₂, hξ₂_mem, hξ₂_eq⟩ := exists_deriv_eq_slope (deriv rothausDefect) hξ₁_pos hcont' hdiff' + obtain ⟨ξ₂, hξ₂_mem, hξ₂_eq⟩ := + exists_deriv_eq_slope (deriv rothausDefect) hξ₁_pos hcont' hdiff' simp only [deriv_rothausDefect_zero] at hξ₂_eq - have hξ₂_in : ξ₂ ∈ Ioo (-1 : ℝ) 1 := ⟨by linarith [hξ₂_mem.1], by linarith [ht.2, hξ₁_mem.2, hξ₂_mem.2]⟩ + have hξ₂_in : ξ₂ ∈ Ioo (-1 : ℝ) 1 := + ⟨by linarith [hξ₂_mem.1], by linarith [ht.2, hξ₁_mem.2, hξ₂_mem.2]⟩ have h_deriv_ξ₁ : deriv rothausDefect ξ₁ = deriv (deriv rothausDefect) ξ₂ * ξ₁ := by -- hξ₂_eq : deriv (deriv rothausDefect) ξ₂ = (deriv rothausDefect ξ₁ - 0) / (ξ₁ - 0) have hξ₁_ne : ξ₁ ≠ 0 := ne_of_gt hξ₁_pos diff --git a/StatsMLlib/Probability/Concentration/Maximal.lean b/StatsMLlib/Probability/Concentration/Maximal.lean index ece4cbb..c35e235 100644 --- a/StatsMLlib/Probability/Concentration/Maximal.lean +++ b/StatsMLlib/Probability/Concentration/Maximal.lean @@ -42,7 +42,8 @@ variable {ι : Type*} [DecidableEq ι] omit [IsProbabilityMeasure μ] [DecidableEq ι] in theorem integrable_of_subgaussian (X : ι → Ω → ℝ) (j : ι) (r : ℝ) - (p : ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ ENNReal.ofReal (rexp (t ^ 2 * r ^ 2 / 2))) + (p : ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ + ENNReal.ofReal (rexp (t ^ 2 * r ^ 2 / 2))) (q : AEMeasurable (X j) μ) : Integrable (X j) μ := by constructor exact aestronglyMeasurable_iff_aemeasurable.mpr q @@ -75,9 +76,11 @@ theorem integrable_of_subgaussian (X : ι → Ω → ℝ) (j : ι) (r : ℝ) apply lintegral_congr intro a refine ENNReal.ofReal_add (exp_nonneg (-X j a)) (exp_nonneg (X j a)) - _ = (∫⁻ (a : Ω), ENNReal.ofReal (rexp (-(X j a))) ∂μ) + ∫⁻ (a : Ω), ENNReal.ofReal (rexp ((X j a))) ∂μ := by + _ = (∫⁻ (a : Ω), ENNReal.ofReal (rexp (-(X j a))) ∂μ) + + ∫⁻ (a : Ω), ENNReal.ofReal (rexp ((X j a))) ∂μ := by rw [MeasureTheory.lintegral_add_left'] - refine AEMeasurable.ennreal_ofReal (Measurable.comp_aemeasurable' measurable_exp (AEMeasurable.neg q)) + refine AEMeasurable.ennreal_ofReal + (Measurable.comp_aemeasurable' measurable_exp (AEMeasurable.neg q)) _ ≤ ENNReal.ofReal (rexp (r ^ 2 / 2)) + ENNReal.ofReal (rexp (r ^ 2 / 2)) := by have p0 := p 1 simp only [one_mul, one_pow] at p0 @@ -94,14 +97,16 @@ private lemma measurable_expt' (X : Ω → ℝ) (t : ℝ) (hX : AEMeasurable X omit [IsProbabilityMeasure μ] [DecidableEq ι] in private theorem integrable_exp_of_subgaussian (X : ι → Ω → ℝ) (j : ι) (r : ℝ) - (p : ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ ENNReal.ofReal (rexp (t ^ 2 * r ^ 2 / 2))) + (p : ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ + ENNReal.ofReal (rexp (t ^ 2 * r ^ 2 / 2))) (t : ℝ) (q : AEMeasurable (X j) μ) : Integrable (fun x ↦ rexp (t * X j x)) μ := by constructor refine measurable_expt' μ (X j) t ?left.hX exact q dsimp [HasFiniteIntegral] - rw [lintegral_congr (by intro a; rw [enorm_eq_ofReal_abs]; simp : ∀ a, ‖rexp (t * X j a)‖ₑ = ENNReal.ofReal (rexp (t * X j a)))] + rw [lintegral_congr (by intro a; rw [enorm_eq_ofReal_abs]; simp : + ∀ a, ‖rexp (t * X j a)‖ₑ = ENNReal.ofReal (rexp (t * X j a)))] exact trans (p t) ENNReal.ofReal_lt_top @@ -171,9 +176,11 @@ lemma maximal_inequality_supR' ∫ ω, Finset.sup' s' hs' (fun j => X j ω) ∂μ ≤ (Finset.sup' s' hs' R) * Real.sqrt (2 * Real.log n) := by intro r' - have p1 : ∀ j ∈ s', ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ ENNReal.ofReal (rexp (t ^ 2 * s'.sup' hs' r' ^ 2 / 2)) := by + have p1 : ∀ j ∈ s', ∀ (t : ℝ), ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ ≤ + ENNReal.ofReal (rexp (t ^ 2 * s'.sup' hs' r' ^ 2 / 2)) := by intro j hj t - have w : ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ = ENNReal.ofReal (∫ (ω : Ω), (rexp (t * X j ω)) ∂μ) := by + have w : ∫⁻ (ω : Ω), ENNReal.ofReal (rexp (t * X j ω)) ∂μ = + ENNReal.ofReal (∫ (ω : Ω), (rexp (t * X j ω)) ∂μ) := by refine Eq.symm (ofReal_integral_eq_lintegral_ofReal ?hfi ?f_nn) constructor refine measurable_expt' μ (X j) t ?hfi.left.hX @@ -190,7 +197,8 @@ lemma maximal_inequality_supR' apply lintegral_mono_ae filter_upwards intro a - have w' : ↑‖rexp (t * X j a)‖₊ = ENNReal.ofReal (rexp (t * X j a)) := Real.enorm_eq_ofReal (exp_nonneg (t * X j a)) + have w' : ↑‖rexp (t * X j a)‖₊ = ENNReal.ofReal (rexp (t * X j a)) := + Real.enorm_eq_ofReal (exp_nonneg (t * X j a)) rw [w'] refine ENNReal.ofReal_le_ofReal ?h.h.h refine exp_le_exp.mpr ?h.h.h.a @@ -258,7 +266,8 @@ lemma maximal_inequality_supR' intro i hi exact exp_nonneg (t * Y i j a) _ = ∏ i ∈ s, ∫⁻ (ω : Ω), ENNReal.ofReal (Real.exp (t * Y i j ω)) ∂μ := by - apply ProbabilityTheory.lintegral_prod_eq_prod_lintegral_of_indepFun (s := s) (X := fun i ω ↦ ENNReal.ofReal (Real.exp (t * Y i j ω))) + apply ProbabilityTheory.lintegral_prod_eq_prod_lintegral_of_indepFun (s := s) + (X := fun i ω ↦ ENNReal.ofReal (Real.exp (t * Y i j ω))) · change iIndepFun (fun i ↦ (fun x : ℝ ↦ ENNReal.ofReal (Real.exp (t * x))) ∘ Y i j) μ refine ProbabilityTheory.iIndepFun.comp (s_ind j hj) ?_ ?_ intro i @@ -275,7 +284,8 @@ lemma maximal_inequality_supR' apply Measurable.const_mul simp_all only _ ≤ ∏ i ∈ s, ENNReal.ofReal (Real.exp (t ^ 2 * r i j ^ 2 / 2)) := by - suffices ∀ i ∈ s, ∫⁻ (ω : Ω), ENNReal.ofReal (Real.exp (t * Y i j ω)) ∂μ ≤ ENNReal.ofReal (Real.exp (t ^ 2 * r i j ^ 2 / 2)) from by + suffices ∀ i ∈ s, ∫⁻ (ω : Ω), ENNReal.ofReal (Real.exp (t * Y i j ω)) ∂μ ≤ + ENNReal.ofReal (Real.exp (t ^ 2 * r i j ^ 2 / 2)) from by exact Finset.prod_le_prod this intro i hi have : t ^ 2 * r i j ^ 2 / 2 = t ^ 2 * (r i j - (- r i j)) ^ 2 / 8 := by @@ -335,7 +345,8 @@ lemma maximal_inequality_supR' rw [exp_le_exp] have : ∑ i ∈ s, r i j ^ 2 ≤ s'.sup' hs' r' ^ 2 := by dsimp [r'] - have : (s'.sup' hs' fun j ↦ √(∑ i ∈ s, r i j ^ 2)) ^ 2 = (s'.sup' hs' fun j ↦ (∑ i ∈ s, r i j ^ 2)) := by + have : (s'.sup' hs' fun j ↦ √(∑ i ∈ s, r i j ^ 2)) ^ 2 = + (s'.sup' hs' fun j ↦ (∑ i ∈ s, r i j ^ 2)) := by rw [sup'_pow] apply congrArg ext j @@ -480,9 +491,9 @@ lemma maximal_inequality_supR have q : ∀ i ∈ s, Integrable (Y i j) μ := by intro i hi constructor - . apply AEMeasurable.aestronglyMeasurable + · apply AEMeasurable.aestronglyMeasurable exact Measurable.aemeasurable (y_mea i j) - . apply MeasureTheory.HasFiniteIntegral.of_bounded + · apply MeasureTheory.HasFiniteIntegral.of_bounded filter_upwards with ω exact abs_le.mpr ⟨y_neg i hi j (by grind) ω, y_pos i hi j (by grind) ω⟩ convert MeasureTheory.integral_finsetSum s q diff --git a/StatsMLlib/Probability/Concentration/McDiarmid.lean b/StatsMLlib/Probability/Concentration/McDiarmid.lean index 84008f0..0ff96fd 100644 --- a/StatsMLlib/Probability/Concentration/McDiarmid.lean +++ b/StatsMLlib/Probability/Concentration/McDiarmid.lean @@ -154,16 +154,22 @@ variable {m : ℕ} {Ω : Type*} [MeasurableSpace Ω] -- Y_k(x_0, …, x_{k-1}) := ∫ f(x_0, …, x_{k-1}, X_k, …, X_{m-1}) dΩ -- A_k(x_0, …, x_{k-1}) := inf_x ∫ f(x_0, …, x_{k-1}, x, X_{k+1}, …, X_{m-1}) dΩ -- B_k(x_0, …, x_{k-1}) := sup_x ∫ f(x_0, …, x_{k-1}, x, X_{k+1}, …, X_{m-1}) dΩ -noncomputable def expressionY (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) (k : Fin m.succ) (Xk : Fin k → 𝓧) : ℝ := +noncomputable def expressionY (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) + (k : Fin m.succ) (Xk : Fin k → 𝓧) : ℝ := ∫ (x : Ω), (fun ω ↦ f' fun i ↦ if h : i.1 < k.1 then Xk ⟨i.1, h⟩ else X' i ω) x ∂μ -noncomputable def expressionA (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) (k: Fin m) (Xk : Fin k → 𝓧) := - ⨅ (x : 𝓧), μ[fun ω ↦ f' (fun i ↦ if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x else X' i ω)] +noncomputable def expressionA (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) + (k: Fin m) (Xk : Fin k → 𝓧) := + ⨅ (x : 𝓧), μ[fun ω ↦ f' (fun i ↦ + if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x else X' i ω)] -noncomputable def expressionB (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) (k: Fin m) (Xk : Fin k → 𝓧) := - ⨆ (x : 𝓧), μ[fun ω ↦ f' (fun i ↦ if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x else X' i ω)] +noncomputable def expressionB (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) + (k: Fin m) (Xk : Fin k → 𝓧) := + ⨆ (x : 𝓧), μ[fun ω ↦ f' (fun i ↦ + if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x else X' i ω)] -noncomputable def expressionV (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) (k : Fin m) (Xk : Fin k → 𝓧) := +noncomputable def expressionV (μ : Measure Ω) (X' : Fin m → Ω → 𝓧) (f' : (Fin m → 𝓧) → ℝ) + (k : Fin m) (Xk : Fin k → 𝓧) := fun ω ↦ expressionY μ X' f' k.succ (Fin.snoc Xk (X' k ω)) - expressionY μ X' f' k.castSucc Xk variable {μ : Measure Ω} [IsProbabilityMeasure μ] @@ -184,7 +190,8 @@ omit [IsProbabilityMeasure μ] in lemma Y_snoc_eq (k : Fin m) (Xk : Fin k → 𝓧) (x : 𝓧) : expressionY μ X' f' k.succ (Fin.snoc Xk x) = - μ[fun ω ↦ f' fun i ↦ if h : i.1 < k.1 then Xk ⟨i.1, h⟩ else if i.1 = k.1 then x else X' i ω] := by + μ[fun ω ↦ f' fun i ↦ + if h : i.1 < k.1 then Xk ⟨i.1, h⟩ else if i.1 = k.1 then x else X' i ω] := by apply integral_congr_ae filter_upwards with ω apply congr rfl @@ -215,15 +222,18 @@ lemma bound_f' (x₀ : 𝓧): ∀ (xi : Fin m → 𝓧), |f' xi| ≤ |f' (fun _ ↦ x₀)| + ∑ i : Fin m, c' i := by have h (k : ℕ) : (h' : k ≤ m) → ∀ xi : (Fin m → 𝓧), |f' xi| ≤ - |f' (fun i ↦ if i.1 < k then x₀ else xi i)| + ∑ (i : Fin k), c' ⟨i.1, by linarith [i.2, h']⟩ := by + |f' (fun i ↦ if i.1 < k then x₀ else xi i)| + + ∑ (i : Fin k), c' ⟨i.1, by linarith [i.2, h']⟩ := by induction' k with k ih · simp only [zero_le, not_lt_zero, ↓reduceIte, Finset.univ_eq_empty, Finset.sum_empty, add_zero, le_refl, implies_true] · intro h' xi apply le_trans <| ih (by linarith [h']) xi - have : |f' (fun i ↦ if i.1 < k then x₀ else xi i)| - |f' fun i ↦ if i.1 < k + 1 then x₀ else xi i| ≤ c' ⟨k, h'⟩ := by + have : |f' (fun i ↦ if i.1 < k then x₀ else xi i)| - + |f' fun i ↦ if i.1 < k + 1 then x₀ else xi i| ≤ c' ⟨k, h'⟩ := by apply le_trans (abs_sub_abs_le_abs_sub _ _) - have : (fun i ↦ if i.1 < k + 1 then x₀ else xi i) = Function.update (fun i ↦ if i.1 < k then x₀ else xi i) ⟨k, by linarith [h']⟩ x₀ := by + have : (fun i ↦ if i.1 < k + 1 then x₀ else xi i) = + Function.update (fun i ↦ if i.1 < k then x₀ else xi i) ⟨k, by linarith [h']⟩ x₀ := by ext i if hik : i.1 < k then have : i.1 < k+1 := by linarith @@ -247,7 +257,8 @@ lemma bound_f' rw [Function.update_of_ne this, ite_eq_right hik] rw [this] apply hfι - have : ∑ (i : Fin (k+1)), c' ⟨i.1, by linarith [i.2, h']⟩ = (∑ (i : Fin k), c' ⟨i.1, by linarith [i.2, h']⟩) + c' ⟨k, h'⟩ := by + have : ∑ (i : Fin (k+1)), c' ⟨i.1, by linarith [i.2, h']⟩ = + (∑ (i : Fin k), c' ⟨i.1, by linarith [i.2, h']⟩) + c' ⟨k, h'⟩ := by apply Fin.sum_univ_castSucc rw [this] linarith @@ -259,7 +270,8 @@ lemma bound_f' rw [this] at h' exact h' -lemma hAY (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) +lemma hAY + (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (x₀ : 𝓧) (k : Fin m) (Xk : Fin k → 𝓧) (x : 𝓧) : expressionA μ X' f' k Xk ≤ expressionY μ X' f' (Fin.succ k) (Fin.snoc Xk x) := by rw [Y_snoc_eq k Xk x] @@ -272,9 +284,11 @@ lemma hAY (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' ( filter_upwards with _ apply bound_f' hfι x₀ -lemma hBddAbove (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) +lemma hBddAbove + (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (x₀ : 𝓧) (k : Fin m) (Xk : Fin k → 𝓧) : BddAbove (Set.range fun x ↦ - ∫ (a : Ω), (fun ω ↦ f' fun i ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i ω) a ∂μ):= by + ∫ (a : Ω), (fun ω ↦ f' fun i ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i ω) a ∂μ):= by use |f' (fun _ ↦ x₀)| + ∑ i : Fin m, c' i intro r ⟨x, heqr⟩ rw [←heqr] @@ -283,7 +297,8 @@ lemma hBddAbove (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x filter_upwards with _ apply bound_f' hfι x₀ -lemma hYB (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) +lemma hYB + (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (x₀ : 𝓧) (k : Fin m) (Xk : Fin k → 𝓧) (x : 𝓧) : expressionB μ X' f' k Xk ≥ expressionY μ X' f' (Fin.succ k) (Fin.snoc Xk x) := by rw [Y_snoc_eq k Xk x] @@ -298,8 +313,10 @@ lemma hmeasurableY (k : Fin m.succ) : Measurable (expressionY μ X' f' k) := by apply stronglyMeasurable_iff_measurable.mp apply StronglyMeasurable.integral_prod_left - have : (Function.uncurry fun (x : Ω) (y : Fin k.1 → 𝓧) ↦ f' fun (i : Fin m) ↦ if h : i.1 < k.1 then y ⟨↑i, h⟩ else X' i x) - = f' ∘ (fun xy : (Ω × (Fin k.1 → 𝓧)) ↦ fun (i : Fin m) ↦ if h : i.1 < k.1 then xy.2 ⟨↑i, h⟩ else X' i xy.1) := rfl + have : (Function.uncurry fun (x : Ω) (y : Fin k.1 → 𝓧) ↦ + f' fun (i : Fin m) ↦ if h : i.1 < k.1 then y ⟨↑i, h⟩ else X' i x) + = f' ∘ (fun xy : (Ω × (Fin k.1 → 𝓧)) ↦ + fun (i : Fin m) ↦ if h : i.1 < k.1 then xy.2 ⟨↑i, h⟩ else X' i xy.1) := rfl rw [this] apply StronglyMeasurable.comp_measurable hf'' apply Measurable.of_eval @@ -315,7 +332,8 @@ lemma hmeasurableY · apply measurable_pi_apply · exact measurable_snd else - have : (fun (c : Ω × (Fin k.1 → 𝓧)) ↦ if h : i.1 < k.1 then c.2 ⟨↑i, h⟩ else X' i c.1) = (X' i) ∘ Prod.fst := by + have : (fun (c : Ω × (Fin k.1 → 𝓧)) ↦ if h : i.1 < k.1 then c.2 ⟨↑i, h⟩ else X' i c.1) = + (X' i) ∘ Prod.fst := by ext c rw [dite_eq_right h] simp @@ -324,7 +342,8 @@ lemma hmeasurableY · exact hX'' i · exact measurable_fst -lemma hYbdd (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) +lemma hYbdd + (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (x₀ : 𝓧) (k : Fin m.succ) (Xk : Fin k → 𝓧) : |expressionY μ X' f' k Xk| ≤ |f' (fun _ ↦ x₀)| + ∑ i : Fin m, c' i := by apply abs_expectation_le_of_abs_le_const @@ -339,14 +358,17 @@ lemma hintegrablelefts (hf'' : StronglyMeasurable f') {t'' : ℝ} (ht'' : t'' ≥ 0) (E : ℝ) (k : ℕ) (h : k ≤ m): - Integrable (fun x ↦ Real.exp (t'' * ((expressionY μ X' f' ⟨k, Nat.lt_add_one_of_le h⟩ fun i ↦ X' (Fin.castLE h i) x) - E))) μ := by + Integrable (fun x ↦ + Real.exp (t'' * ((expressionY μ X' f' ⟨k, Nat.lt_add_one_of_le h⟩ + fun i ↦ X' (Fin.castLE h i) x) - E))) μ := by constructor · apply Measurable.aestronglyMeasurable apply Measurable.exp apply Measurable.const_mul apply Measurable.sub_const _ E have : (fun x ↦ expressionY μ X' f' ⟨k, Nat.lt_add_one_of_le h⟩ fun i ↦ X' (Fin.castLE h i) x) - = expressionY μ X' f' ⟨k, Nat.lt_add_one_of_le h⟩ ∘ fun x ↦ fun i ↦ X' (Fin.castLE h i) x := rfl + = expressionY μ X' f' ⟨k, Nat.lt_add_one_of_le h⟩ ∘ + fun x ↦ fun i ↦ X' (Fin.castLE h i) x := rfl rw [this] apply (hmeasurableY hX'' hf'' ⟨k, Nat.lt_add_one_of_le h⟩).comp apply Measurable.of_eval @@ -369,7 +391,8 @@ lemma hintegrableAB (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (hf'' : StronglyMeasurable f') (k : Fin m) (Xk : Fin k → 𝓧) (x : 𝓧) : - Integrable (fun a ↦ f' fun i ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i a) μ := by + Integrable (fun a ↦ f' fun i ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i a) μ := by let x₀ : 𝓧 := (Classical.inhabited_of_nonempty hnonempty𝓧).default constructor · apply @AEStronglyMeasurable.comp_aemeasurable (Fin m → 𝓧) ℝ _ f' Ω @@ -378,20 +401,23 @@ lemma hintegrableAB apply measurable_pi_iff.mpr intro i if h₀ : i.1 < k.1 then - have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = fun _ ↦ Xk ⟨i.1, h₀⟩ := by + have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = + fun _ ↦ Xk ⟨i.1, h₀⟩ := by ext x rw [dite_eq_left h₀] rw [this] exact measurable_const else if h₁ : i.1 = k.1 then - have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = fun _ ↦ x := by + have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = + fun _ ↦ x := by ext x rw [dite_eq_right h₀, ite_eq_left h₁] rw [this] exact measurable_const else - have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = fun x_1 ↦ X' i x_1 := by + have : (fun x_1 ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x else X' i x_1) = + fun x_1 ↦ X' i x_1 := by ext x rw [dite_eq_right h₀, ite_eq_right h₁] rw [this] @@ -413,13 +439,16 @@ lemma hAB apply (ciSup_le_iff (hBddAbove hfι x₀ k Xk)).mpr intro x₂ calc - _ ≤ ∫ (ω : Ω), (f' fun i ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω) + c' k ∂μ := by + _ ≤ ∫ (ω : Ω), (f' fun i ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω) + c' k ∂μ := by apply integral_mono exact hintegrableAB hX'' hfι hf'' k Xk x₂ exact integrable_add_const_iff.mpr (hintegrableAB hX'' hfι hf'' k Xk x₁) intro ω - have : (fun i : Fin m ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω) - = Function.update (fun i : Fin m ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₂ else X' i ω) k x₁ := by + have : (fun i : Fin m ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω) + = Function.update (fun i : Fin m ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₂ else X' i ω) k x₁ := by ext i if h : i.1 < k.1 then have : i ≠ k := Fin.ne_of_lt h @@ -438,8 +467,10 @@ lemma hAB apply tsub_le_iff_left.mp apply le_of_max_le_left apply hfι - _ = (∫ (ω : Ω), f' fun i ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω ∂μ) - + (∫ (_ : Ω), c' k ∂μ) := integral_add (hintegrableAB hX'' hfι hf'' k Xk x₁) (integrable_const (c' k)) + _ = (∫ (ω : Ω), f' fun i ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if i.1 = k.1 then x₁ else X' i ω ∂μ) + + (∫ (_ : Ω), c' k ∂μ) := + integral_add (hintegrableAB hX'' hfι hf'' k Xk x₁) (integrable_const (c' k)) _ = _ := add_left_cancel_iff.mpr (expectation_const (c' k)) -- we use independency for the martingale property @@ -451,7 +482,8 @@ lemma hmartingale (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (hf'' : StronglyMeasurable f') (k : Fin m) (Xk : Fin k → 𝓧) : - ∫ (ω : Ω), expressionY μ X' f' k.succ (Fin.snoc Xk (X' k ω)) ∂μ = expressionY μ X' f' k.castSucc Xk := by + ∫ (ω : Ω), expressionY μ X' f' k.succ (Fin.snoc Xk (X' k ω)) ∂μ = + expressionY μ X' f' k.castSucc Xk := by let S : Finset (Fin m) := {i : Fin m | i.1 > k.1} let T : Finset (Fin m) := {k} have hST : Disjoint T S := by @@ -530,7 +562,10 @@ lemma hmartingale apply measurable_pi_iff.mpr intro i if h : i < k then - have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = fun _ ↦ Xk ⟨i.1, h⟩ := by + have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ + else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = + fun _ ↦ Xk ⟨i.1, h⟩ := by simp only [Fin.val_fin_lt] ext x rw [dite_eq_left h] @@ -538,14 +573,20 @@ lemma hmartingale exact measurable_const else if h' : i.1 = k.1 then - have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = fun x ↦ x.1 elT := by + have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ + else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = + fun x ↦ x.1 elT := by simp only [Fin.val_fin_lt] ext x rw [dite_eq_right h, dite_eq_left h'] rw [this] exact Measurable.eval measurable_fst else - have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ if h : i.1 < k.1 then Xk ⟨↑i, h⟩ else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = fun x ↦ x.2 (toelS i h h') := by + have : (fun x : (T → 𝓧) × (S → 𝓧) ↦ + if h : i.1 < k.1 then Xk ⟨↑i, h⟩ + else if h' : i.1 = k.1 then x.1 elT else x.2 (toelS i h h')) = + fun x ↦ x.2 (toelS i h h') := by simp only [Fin.val_fin_lt] ext x rw [dite_eq_right h, dite_eq_right h'] @@ -557,7 +598,8 @@ lemma hmartingale exact Measurable.of_eval fun a ↦ hX'' ↑a · exact hindep · let x₀ : 𝓧 := (Classical.inhabited_of_nonempty hnonempty𝓧).default - apply @MeasureTheory.HasFiniteIntegral.of_bounded _ _ _ _ _ _ F (|f' (fun _ ↦ x₀)| + ∑ i : Fin m, c' i) + apply @MeasureTheory.HasFiniteIntegral.of_bounded _ _ _ _ _ _ F + (|f' (fun _ ↦ x₀)| + ∑ i : Fin m, c' i) filter_upwards with ⟨t, s⟩ apply bound_f' hfι x₀ @@ -567,7 +609,8 @@ lemma hhoeffding_V {c' : Fin m → ℝ} (hfι : ∀ (i : Fin m) (x : Fin m → 𝓧) (x' : 𝓧), |f' x - f' (Function.update x i x')| ≤ c' i) (hf'' : StronglyMeasurable f') (t'' : ℝ) - (k : Fin m) (Xk : Fin k → 𝓧) : ∫ (ω : Ω), (t'' * (expressionV μ X' f' k Xk ω)).exp ∂μ ≤ (t''^2 * (c' k)^2 / 8).exp := by + (k : Fin m) (Xk : Fin k → 𝓧) : + ∫ (ω : Ω), (t'' * (expressionV μ X' f' k Xk ω)).exp ∂μ ≤ (t''^2 * (c' k)^2 / 8).exp := by let Y : Π (k: Fin m.succ), (Fin k → 𝓧) → ℝ := expressionY μ X' f' let A : Π (k: Fin m), (Fin k → 𝓧) → ℝ := expressionA μ X' f' let B : Π (k: Fin m), (Fin k → 𝓧) → ℝ := expressionB μ X' f' @@ -626,10 +669,12 @@ lemma hhoeffding_V rw [this] apply pow_le_pow_left₀ _ _ 2 · apply sub_nonneg.mpr - let c : ℝ := μ[fun ω ↦ f' (fun i ↦ if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x₀ else X' i ω)] + let c : ℝ := μ[fun ω ↦ f' (fun i ↦ + if h : i.1 < k.1 then Xk ⟨i.1,h⟩ else if i.1 = k.1 then x₀ else X' i ω)] calc _ ≤ c := le_of_le_of_eq (hAY hfι x₀ k Xk x₀) (Y_snoc_eq k Xk x₀) - _ ≤ _ := (le_iff_le_of_cmp_eq_cmp (congrFun (congrArg cmp (Y_snoc_eq k Xk x₀)) (B k Xk))).mp + _ ≤ _ := (le_iff_le_of_cmp_eq_cmp + (congrFun (congrArg cmp (Y_snoc_eq k Xk x₀)) (B k Xk))).mp (hYB hfι x₀ k Xk x₀) · exact tsub_le_iff_left.mpr (hAB hX'' hfι hf'' k Xk) @@ -641,7 +686,8 @@ lemma heqind (hf'' : StronglyMeasurable f') {t'' : ℝ} (ht'' : t'' ≥ 0) (x₀ : 𝓧) (k : ℕ) (h : k ≤ m) : - ∫ (ω : Ω), (t'' *(expressionY μ X' f' ⟨k,Nat.lt_add_one_of_le h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h i) ω) - expressionY μ X' f' 0 (fun _ ↦ x₀))).exp ∂μ + ∫ (ω : Ω), (t'' *(expressionY μ X' f' ⟨k,Nat.lt_add_one_of_le h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h i) ω) - expressionY μ X' f' 0 (fun _ ↦ x₀))).exp ∂μ ≤ ((t'' ^2 * ∑ (i : Fin k), c' (Fin.castLE h i) ^ 2)/8).exp := by let Y : Π (k: Fin m.succ), (Fin k → 𝓧) → ℝ := expressionY μ X' f' let V : Π (k : Fin m), (Fin k → 𝓧) → Ω → ℝ := expressionV μ X' f' @@ -655,7 +701,8 @@ lemma heqind · have ih := ih <| Nat.le_of_succ_le h calc _ = ∫ (ω : Ω), ∫ (ω' : Ω), (t'' *(Y ⟨k+1,Nat.lt_add_one_of_le h⟩ - (Fin.snoc (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) (X' ⟨k,h⟩ ω')) - E)).exp ∂μ ∂μ := by + (Fin.snoc (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) (X' ⟨k,h⟩ ω')) - + E)).exp ∂μ ∂μ := by let S : Finset (Fin m) := {i : Fin m | i.1 < k} let T : Finset (Fin m) := {⟨k,h⟩} have hST : Disjoint S T := by @@ -669,10 +716,13 @@ lemma heqind Fin.val_castLE, Fin.is_lt, and_self, S] let elT : T := ⟨⟨k,h⟩, Finset.mem_singleton.mpr rfl⟩ let F : (S → 𝓧) × (T → 𝓧) → ℝ := fun ⟨s,t⟩ ↦ - Real.exp (t'' * (Y ⟨k + 1, Nat.lt_add_one_of_le h⟩ (Fin.snoc (fun i ↦ s (toelS i)) (t elT)) - E)) + Real.exp (t'' * (Y ⟨k + 1, Nat.lt_add_one_of_le h⟩ + (Fin.snoc (fun i ↦ s (toelS i)) (t elT)) - E)) let gT : Ω → T → 𝓧 := fun ω t ↦ X' t.1 ω let gS : Ω → S → 𝓧 := fun ω s ↦ X' s.1 ω - have hlefteq : ∫ (ω : Ω), Real.exp (t'' * ((Y ⟨k + 1, Nat.lt_add_one_of_le h⟩ fun i ↦ X' (Fin.castLE h i) ω) - E)) ∂μ + have hlefteq : ∫ (ω : Ω), + Real.exp (t'' * ((Y ⟨k + 1, Nat.lt_add_one_of_le h⟩ + fun i ↦ X' (Fin.castLE h i) ω) - E)) ∂μ = ∫ (ω : Ω), F ⟨gS ω, gT ω⟩ ∂μ := by apply congrArg ext ω @@ -723,7 +773,8 @@ lemma heqind apply measurable_pi_iff.mpr intro i if h' : i.1 < k then - have : (fun x : (S → 𝓧) × (T → 𝓧) ↦ @Fin.snoc k (fun _ ↦ 𝓧) (fun i ↦ x.1 (toelS i)) (x.2 elT) i) + have : (fun x : (S → 𝓧) × (T → 𝓧) ↦ + @Fin.snoc k (fun _ ↦ 𝓧) (fun i ↦ x.1 (toelS i)) (x.2 elT) i) = (fun x ↦ x (toelS ⟨i, h'⟩)) ∘ Prod.fst := by ext x dsimp [Fin.snoc] @@ -733,7 +784,8 @@ lemma heqind apply Measurable.comp _ measurable_fst exact measurable_pi_apply (toelS ⟨↑i, h'⟩) else - have : (fun x : (S → 𝓧) × (T → 𝓧) ↦ @Fin.snoc k (fun _ ↦ 𝓧) (fun i ↦ x.1 (toelS i)) (x.2 elT) i) + have : (fun x : (S → 𝓧) × (T → 𝓧) ↦ + @Fin.snoc k (fun _ ↦ 𝓧) (fun i ↦ x.1 (toelS i)) (x.2 elT) i) = (fun x ↦ x elT) ∘ Prod.snd := by ext x dsimp [Fin.snoc] @@ -755,7 +807,8 @@ lemma heqind apply tsub_le_tsub_right _ E apply le_of_max_le_left apply hYbdd hfι x₀ - _ = ∫ (ω : Ω), ∫ (ω' : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp + _ = ∫ (ω : Ω), ∫ (ω' : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp * (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp ∂μ ∂μ := by dsimp only [V] apply congrArg @@ -763,7 +816,8 @@ lemma heqind apply congrArg ext ω' calc - _ = (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E) + _ = (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E) + t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp := by apply congrArg rw [←mul_add] @@ -772,26 +826,37 @@ lemma heqind simp only [Nat.succ_eq_add_one, Fin.castLE_castSucc, Fin.succ_mk, Fin.castSucc_mk, sub_add_sub_cancel'] _ = _ := by apply Real.exp_add - _ = ∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp - * ∫ (ω' : Ω), (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp ∂μ ∂μ := by + _ = ∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp + * ∫ (ω' : Ω), (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp + ∂μ ∂μ := by apply congrArg ext ω exact integral_const_mul - (Real.exp (t'' * ((Y ⟨k, Nat.lt_succ_of_lt h⟩ fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E))) + (Real.exp (t'' * ((Y ⟨k, Nat.lt_succ_of_lt h⟩ + fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E))) fun a ↦ Real.exp (t'' * V ⟨k, h⟩ (fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) a) - _ ≤ ∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp + _ ≤ ∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp * (t'' ^2 * (c' ⟨k, h⟩)^2 / 8).exp ∂μ := by have (h : k ≤ m) : - Integrable (fun x ↦ Real.exp (t'' * ((Y ⟨k, Nat.lt_add_one_of_le h⟩ fun i ↦ X' (Fin.castLE h i) x) - E))) μ := + Integrable (fun x ↦ Real.exp (t'' * ((Y ⟨k, Nat.lt_add_one_of_le h⟩ + fun i ↦ X' (Fin.castLE h i) x) - E))) μ := hintegrablelefts hX'' hfι hf'' ht'' E k h have hintegrableleft := this (Nat.le_of_succ_le h) simp only [Nat.succ_eq_add_one] at hintegrableleft apply integral_mono - · have : (fun (ω : Ω) ↦ (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp - * ∫ (ω' : Ω), (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp ∂μ) - = (fun (ω : Ω) ↦ (∫ (ω' : Ω), (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp ∂μ) - * (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp) := by + · have : (fun (ω : Ω) ↦ (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp + * ∫ (ω' : Ω), + (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp + ∂μ) + = (fun (ω : Ω) ↦ (∫ (ω' : Ω), + (t'' *(V ⟨k,h⟩ fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) ω').exp + ∂μ) + * (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp) := by ext ω rw [mul_comm] rw [this] @@ -816,8 +881,10 @@ lemma heqind simp only [Fin.snoc, dite_eq_right h', cast_eq] change Measurable (X' _ ∘ Prod.fst) exact (hX'' _).comp measurable_fst - · have : (fun a : Ω × Ω ↦ Y (⟨k, h⟩ : Fin m).castSucc fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) a.2) - = (Y (⟨k, h⟩ : Fin m).castSucc) ∘ (fun a : Ω ↦ fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) a) ∘ Prod.snd := rfl + · have : (fun a : Ω × Ω ↦ + Y (⟨k, h⟩ : Fin m).castSucc fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) a.2) + = (Y (⟨k, h⟩ : Fin m).castSucc) ∘ + (fun a : Ω ↦ fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) a) ∘ Prod.snd := rfl dsimp dsimp at this rw [this] @@ -837,13 +904,16 @@ lemma heqind apply (abs_sub _ _).trans apply add_le_add · apply hYbdd hfι x₀ - · apply hYbdd hfι x₀ (⟨k, h⟩ : Fin m).castSucc fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) ω - · apply Integrable.mul_const (by simp; exact hintegrableleft) (Real.exp (t'' ^ 2 * c' ⟨k, h⟩ ^ 2 / 8)) + · apply hYbdd hfι x₀ (⟨k, h⟩ : Fin m).castSucc + fun i ↦ X' (Fin.castLE h (Fin.castSucc i)) ω + · apply Integrable.mul_const (by simp; exact hintegrableleft) + (Real.exp (t'' ^ 2 * c' ⟨k, h⟩ ^ 2 / 8)) · intro ω apply mul_le_mul_of_nonneg_left · apply hhoeffding_V hX'' hIndep' hfι hf'' t'' · apply Real.exp_nonneg - _ = (∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp ∂μ) + _ = (∫ (ω : Ω), (t'' *(Y ⟨k,Nat.lt_succ_of_lt h⟩ + (fun (i : Fin k) ↦ X' (Fin.castLE h (Fin.castSucc i)) ω) - E)).exp ∂μ) * (t'' ^2 * (c' ⟨k, h⟩)^2 / 8).exp := by apply integral_mul_const _ ≤ Real.exp ((t'' ^2 * ∑ i : Fin k, c' (Fin.castLE (Nat.le_of_succ_le h) i) ^ 2) / 8) @@ -894,7 +964,8 @@ theorem mcdiarmid_inequality_aux integral_const, smul_eq_mul, Fin.val_zero, not_lt_zero, expressionY] at this have hintegrable : - Integrable (fun x ↦ Real.exp (t'' * ((Y ⟨m, Nat.lt_add_one_of_le le_rfl⟩ fun i ↦ X' (Fin.castLE le_rfl i) x) - E))) μ + Integrable (fun x ↦ Real.exp (t'' * ((Y ⟨m, Nat.lt_add_one_of_le le_rfl⟩ + fun i ↦ X' (Fin.castLE le_rfl i) x) - E))) μ := hintegrablelefts hX'' hfι hf'' ht'' E m le_rfl simp only [Nat.succ_eq_add_one, Fin.castLE_rfl, id_eq, Fin.is_lt, ↓reduceDIte, Fin.eta, integral_const, smul_eq_mul, Fin.val_zero, @@ -977,8 +1048,7 @@ theorem mcdiarmid_inequality_pos have ht'' : t * ∑ (i' : Fin m), c' i' ^2 ≤ 1 := by have : ∑ (i' : Fin m), c' i' ^2 = ∑ (i : ι), c i ^2 := by exact Fintype.sum_equiv ιm.symm (fun x ↦ c' x ^ 2) (fun x ↦ c x ^ 2) (congrFun rfl) - rw [this] - assumption + rwa [this] if ht : t ≥ 0 then have := mcdiarmid_inequality_aux hX'' hIndep' hfι hf'' hε ht ht'' have eq : (f' ∘ Function.swap fun i ↦ X (ιm.symm i)) = (f ∘ Function.swap X) := by From 80ea0d3cc599ed8d6ccf0ca87706c2bcc18b1b19 Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:20:06 +0900 Subject: [PATCH 4/7] Wrap long lines in LogSobolev/Bernoulli.lean Part of #71. Co-Authored-By: Claude Opus 5.5 --- .../Concentration/LogSobolev/Bernoulli.lean | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/StatsMLlib/Probability/Concentration/LogSobolev/Bernoulli.lean b/StatsMLlib/Probability/Concentration/LogSobolev/Bernoulli.lean index cf532ac..49b3d09 100644 --- a/StatsMLlib/Probability/Concentration/LogSobolev/Bernoulli.lean +++ b/StatsMLlib/Probability/Concentration/LogSobolev/Bernoulli.lean @@ -798,7 +798,8 @@ theorem jensenGap_joint_convex (x₀ x₁ y₀ y₁ : ℝ) linarith [hy₁.lt_of_ne' hs₁_zero] -- jensenGap(x₁/2, y₁/2) = (s₁/4) * D(p₁) and jensenGap(x₁, y₁) = (s₁/2) * D(p₁) have hsum_half_pos : 0 < x₁/2 + y₁/2 := by linarith - rw [jensenGap_eq_scaled_binaryKL (by linarith : 0 ≤ x₁/2) (by linarith : 0 ≤ y₁/2) hsum_half_pos] + rw [jensenGap_eq_scaled_binaryKL (by linarith : 0 ≤ x₁/2) (by linarith : 0 ≤ y₁/2) + hsum_half_pos] rw [jensenGap_eq_scaled_binaryKL hx₁ hy₁ hs₁_pos] -- Goal: 2 * ((x₁/2 + y₁/2) / 2 * D(...)) ≤ (x₁ + y₁) / 2 * D(x₁/(x₁+y₁)) -- Note: (x₁/2 + y₁/2) / 2 = (x₁ + y₁) / 4 and (x₁/2)/(x₁/2 + y₁/2) = x₁/(x₁+y₁) @@ -827,7 +828,8 @@ theorem jensenGap_joint_convex (x₀ x₁ y₀ y₁ : ℝ) simp only [hs₀, hx₀_eq, zero_add] at hs₀_zero linarith [hy₀.lt_of_ne' hs₀_zero] have hsum_half_pos₀ : 0 < x₀/2 + y₀/2 := by linarith - rw [jensenGap_eq_scaled_binaryKL (by linarith : 0 ≤ x₀/2) (by linarith : 0 ≤ y₀/2) hsum_half_pos₀] + rw [jensenGap_eq_scaled_binaryKL (by linarith : 0 ≤ x₀/2) (by linarith : 0 ≤ y₀/2) + hsum_half_pos₀] rw [jensenGap_eq_scaled_binaryKL hx₀ hy₀ hs₀_pos] -- Similar simplification as the s₁ case have hp₀_eq' : x₀ / 2 / (x₀ / 2 + y₀ / 2) = x₀ / (x₀ + y₀) := by field_simp @@ -1152,14 +1154,18 @@ theorem han_inequality {n : ℕ} (h : (Fin n → Bool) → ℝ) : rw [bernoulli_integral_succ_split] -- Goal: (∫ sliceTrue + ∫ sliceFalse) / 2 = ∫ (castSucc true + castSucc false) / 2 -- First simplify LHS - have h_sliceTrue : ∫ ε', twoPointEntropyCoord j (sliceTrue h) ε' ∂(bernoulliUniform n) = - ∫ ε', twoPointEntropyCoord (Fin.castSucc j) h (Fin.snoc ε' true) ∂(bernoulliUniform n) := by + have h_sliceTrue : + ∫ ε', twoPointEntropyCoord j (sliceTrue h) ε' ∂(bernoulliUniform n) = + ∫ ε', twoPointEntropyCoord (Fin.castSucc j) h (Fin.snoc ε' true) + ∂(bernoulliUniform n) := by apply integral_congr_ae filter_upwards with ε' rw [twoPointEntropyCoord_castSucc_eq_slice j h ε' true] simp only [ite_true] - have h_sliceFalse : ∫ ε', twoPointEntropyCoord j (sliceFalse h) ε' ∂(bernoulliUniform n) = - ∫ ε', twoPointEntropyCoord (Fin.castSucc j) h (Fin.snoc ε' false) ∂(bernoulliUniform n) := by + have h_sliceFalse : + ∫ ε', twoPointEntropyCoord j (sliceFalse h) ε' ∂(bernoulliUniform n) = + ∫ ε', twoPointEntropyCoord (Fin.castSucc j) h (Fin.snoc ε' false) + ∂(bernoulliUniform n) := by apply integral_congr_ae filter_upwards with ε' rw [twoPointEntropyCoord_castSucc_eq_slice j h ε' false] @@ -1169,8 +1175,10 @@ theorem han_inequality {n : ℕ} (h : (Fin n → Bool) → ℝ) : rw [integral_div] -- Step 6: Sum over j < n - have hsum_bound : ∑ j : Fin n, ∫ ε', twoPointEntropyCoord j (condMeanSqrt h) ε' ∂(bernoulliUniform n) ≤ - ∑ j : Fin n, ∫ ε, twoPointEntropyCoord (Fin.castSucc j) h ε ∂(bernoulliUniform (n+1)) := by + have hsum_bound : + ∑ j : Fin n, ∫ ε', twoPointEntropyCoord j (condMeanSqrt h) ε' ∂(bernoulliUniform n) ≤ + ∑ j : Fin n, ∫ ε, twoPointEntropyCoord (Fin.castSucc j) h ε + ∂(bernoulliUniform (n+1)) := by apply Finset.sum_le_sum intro j _ exact hconv_bound j @@ -1186,7 +1194,8 @@ theorem han_inequality {n : ℕ} (h : (Fin n → Bool) → ℝ) : ∑ j : Fin n, ∫ ε', twoPointEntropyCoord j (condMeanSqrt h) ε' ∂(bernoulliUniform n) := by exact add_le_add_right hih _ _ ≤ ∫ ε, twoPointEntropyCoord (Fin.last n) h ε ∂(bernoulliUniform (n+1)) + - ∑ j : Fin n, ∫ ε, twoPointEntropyCoord (Fin.castSucc j) h ε ∂(bernoulliUniform (n+1)) := by + ∑ j : Fin n, ∫ ε, twoPointEntropyCoord (Fin.castSucc j) h ε + ∂(bernoulliUniform (n+1)) := by exact add_le_add_right hsum_bound _ _ = ∑ j : Fin (n+1), ∫ ε, twoPointEntropyCoord j h ε ∂(bernoulliUniform (n+1)) := by -- Split sum over Fin (n+1) into castSucc terms plus last term @@ -1300,7 +1309,8 @@ theorem rademacherSumProd_flip_eq_shifted {n : ℕ} [NeZero n] (j : Fin n) exact h2 i (Finset.mem_of_mem_erase hi) (Finset.ne_of_mem_erase hi) _ = -x j + (∑ i : Fin n, x i - x j) := by have hsum_erase : ∑ i ∈ Finset.univ.erase j, x i = ∑ i : Fin n, x i - x j := by - have hsplit := Finset.add_sum_erase Finset.univ (fun i : Fin n => x i) (Finset.mem_univ j) + have hsplit := + Finset.add_sum_erase Finset.univ (fun i : Fin n => x i) (Finset.mem_univ j) linarith rw [hsum_erase] _ = (∑ i : Fin n, x i) - 2 * x j := by ring @@ -1321,7 +1331,8 @@ theorem continuous_rademacherSumProd (n : ℕ) : Continuous (rademacherSumProd n exact continuous_apply i exact hsum.const_smul ((√n)⁻¹) -/-- Key lemma: The bernoulliUniform measure pushes forward to rademacherProductMeasure via toRademacher. -/ +/-- Key lemma: The bernoulliUniform measure pushes forward to rademacherProductMeasure via +toRademacher. -/ theorem bernoulliUniform_map_toRademacher {n : ℕ} : (bernoulliUniform n).map toRademacher = rademacherProductMeasure n := by -- Both measures are probability measures supported on {±1}^n with equal weights @@ -1331,7 +1342,8 @@ theorem bernoulliUniform_map_toRademacher {n : ℕ} : induction n with | zero => -- For n = 0, both spaces are singletons - simp only [bernoulliUniform, rademacherProductMeasure, Measure.map_apply measurable_toRademacher hs] + simp only [bernoulliUniform, rademacherProductMeasure, + Measure.map_apply measurable_toRademacher hs] -- Simplify LHS: (1⁻¹ • count) = count since 1⁻¹ = 1 in ENNReal simp only [Finset.card_univ, Fintype.card_fun, Fintype.card_fin, Fintype.card_bool, pow_zero, Nat.cast_one, inv_one, one_smul] @@ -1379,7 +1391,8 @@ theorem bernoulliUniform_map_toRademacher {n : ℕ} : unfold rademacherProductMeasure rw [Measure.pi_pi (fun _ => RademacherApprox.rademacherMeasure)] -- Each factor is rademacherMeasure {toRademacher ε i} = 1/2 - have h_each : ∀ i : Fin (n+1), RademacherApprox.rademacherMeasure {toRademacher ε i} = 1/2 := by + have h_each : + ∀ i : Fin (n+1), RademacherApprox.rademacherMeasure {toRademacher ε i} = 1/2 := by intro i unfold toRademacher signValue RademacherApprox.rademacherMeasure simp only [Measure.coe_add, Measure.coe_smul, Pi.add_apply, Pi.smul_apply, smul_eq_mul] @@ -1534,7 +1547,8 @@ theorem gradient_eq_sum_shifted {n : ℕ} [NeZero n] {f : ℝ → ℝ} (hf : Con simp only [gradientNormSq] -- Step 2: Exchange integral and sum (integral of sum = sum of integrals for finite sums) rw [integral_finsetSum Finset.univ (fun j _ => Integrable.of_finite)] - -- Step 3: For each term, show the integrand is the same after using flip-to-shifted correspondence + -- Step 3: For each term, show the integrand is the same after using flip-to-shifted + -- correspondence congr 1 ext j have hflip : ∀ ε, rademacherSumProd n (toRademacher (flipCoord j ε)) = From f6115a120c8805e551b6160e38a4eec064ca2a6a Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:22 +0900 Subject: [PATCH 5/7] Fix style linter warnings in LearningTheory Wrap lines over 100 characters and fix the other style linter warnings (`refine'`, focusing dots, missing `end`) reported once the linter option names in `lakefile.lean` are corrected. Formatting only; no statement changes. Part of #71. Co-Authored-By: Claude Opus 5.5 --- .../EmpiricalProcess/Metric.lean | 3 +- .../FunctionClass/LinearPredictor/L1.lean | 12 +- .../FunctionClass/LinearPredictor/L2.lean | 94 ++-- .../LearningTheory/Rademacher/Complexity.lean | 197 ++++--- .../LearningTheory/Rademacher/Dudley.lean | 526 ++++++++++++------ .../LearningTheory/Rademacher/Massart.lean | 17 +- .../LearningTheory/Rademacher/Signs.lean | 22 +- .../Rademacher/Symmetrization.lean | 191 ++++--- .../UniformDeviation/Bounds.lean | 12 +- 9 files changed, 732 insertions(+), 342 deletions(-) diff --git a/StatsMLlib/LearningTheory/EmpiricalProcess/Metric.lean b/StatsMLlib/LearningTheory/EmpiricalProcess/Metric.lean index 664ee75..1c2eb95 100644 --- a/StatsMLlib/LearningTheory/EmpiricalProcess/Metric.lean +++ b/StatsMLlib/LearningTheory/EmpiricalProcess/Metric.lean @@ -175,7 +175,8 @@ lemma ofFun_toFun (n : ℕ) (v : EmpiricalSpace n) : ofFun n (toFun n v) = v := end EmpiricalSpace -/-- Empirical metric image: Map a function g : X → ℝ to its empirical representation in EmpiricalSpace n. +/-- Empirical metric image: Map a function g : X → ℝ to its empirical representation in +EmpiricalSpace n. This is the evaluation at sample points: g ↦ (g(x₁), ..., g(xₙ)). -/ def empiricalMetricImage {X : Type*} (n : ℕ) (x : Fin n → X) (g : X → ℝ) : EmpiricalSpace n := fun i => g (x i) diff --git a/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L1.lean b/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L1.lean index 9357937..0fa2482 100644 --- a/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L1.lean +++ b/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L1.lean @@ -324,11 +324,13 @@ theorem linear_predictor_l1_bound' intro j hj calc ∑ k : Fin n, (σ k : ℝ) * ((w' i).1 j * ((Subtype.val ∘ Y') k j)) - = ∑ k : Fin n, (w' i).1 j * ((σ k : ℝ) * ((Subtype.val ∘ Y') k j)) := by + = ∑ k : Fin n, (w' i).1 j * + ((σ k : ℝ) * ((Subtype.val ∘ Y') k j)) := by refine Finset.sum_congr rfl ?_ intro k hk ring - _ = (w' i).1 j * ∑ k : Fin n, (σ k : ℝ) * ((Subtype.val ∘ Y') k j) := by + _ = (w' i).1 j * ∑ k : Fin n, (σ k : ℝ) * ((Subtype.val ∘ Y') k j) + := by rw [Finset.mul_sum] _ = ∑ j : Fin d, (w' i).1 j * z j := by rw [Finset.mul_sum] @@ -710,11 +712,13 @@ theorem linear_predictor_l1_bound_of_sample' intro j hj calc ∑ k : Fin n, (σ k : ℝ) * ((w' i).1 j * ((Subtype.val ∘ Y') k j)) - = ∑ k : Fin n, (w' i).1 j * ((σ k : ℝ) * ((Subtype.val ∘ Y') k j)) := by + = ∑ k : Fin n, (w' i).1 j * + ((σ k : ℝ) * ((Subtype.val ∘ Y') k j)) := by refine Finset.sum_congr rfl ?_ intro k hk ring - _ = (w' i).1 j * ∑ k : Fin n, (σ k : ℝ) * ((Subtype.val ∘ Y') k j) := by + _ = (w' i).1 j * ∑ k : Fin n, (σ k : ℝ) * ((Subtype.val ∘ Y') k j) + := by rw [Finset.mul_sum] _ = ∑ j : Fin d, (w' i).1 j * z j := by rw [Finset.mul_sum] diff --git a/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L2.lean b/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L2.lean index 35fde98..25f922b 100644 --- a/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L2.lean +++ b/StatsMLlib/LearningTheory/FunctionClass/LinearPredictor/L2.lean @@ -17,7 +17,8 @@ The empirical Rademacher bound for linear predictors with Euclidean parameter an ## Main definitions -This module uses Euclidean spaces and the empirical Rademacher complexity from `StatsMLlib.LearningTheory.Rademacher.Defs`. +This module uses Euclidean spaces and the empirical Rademacher complexity from +`StatsMLlib.LearningTheory.Rademacher.Defs`. ## Main results @@ -36,10 +37,12 @@ variable (d n : ℕ) (Y : Fin n → EuclideanSpace ℝ (Fin d)) (σ : Signs n) local notation "⟪" x ", " y "⟫" => @inner ℝ _ _ x y theorem weighted_sum_norm_squared_expansion: - ‖∑ k : Fin n, (σ k : ℝ) • Y k‖ ^ 2 = ∑ k : Fin n, ∑ l : Fin n, ⟪(σ k : ℝ) • Y k, (σ l : ℝ) • Y l⟫ := by + ‖∑ k : Fin n, (σ k : ℝ) • Y k‖ ^ 2 = + ∑ k : Fin n, ∑ l : Fin n, ⟪(σ k : ℝ) • Y k, (σ l : ℝ) • Y l⟫ := by let g := fun l ↦ (σ l : ℝ) • Y l calc - _ = ⟪∑ k : Fin n, g k, ∑ l : Fin n, g l⟫ := Eq.symm (real_inner_self_eq_norm_sq (∑ k : Fin n, g k)) + _ = ⟪∑ k : Fin n, g k, ∑ l : Fin n, g l⟫ := + Eq.symm (real_inner_self_eq_norm_sq (∑ k : Fin n, g k)) _ = ∑ k : Fin n, ⟪g k, ∑ l : Fin n, g l⟫ := sum_inner Finset.univ g (∑ l : Fin n, g l) _ = ∑ k : Fin n, ∑ l : Fin n, ⟪g k, g l⟫ := by apply congrArg @@ -47,7 +50,8 @@ theorem weighted_sum_norm_squared_expansion: exact inner_sum Finset.univ g (g k) theorem individual_weighted_norms_sum: - ∑ k : Fin n, ‖(σ k : ℝ) • Y k‖ ^ 2 = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then 0 else ⟪(σ k : ℝ) • Y k, (σ l : ℝ) • Y l⟫ := by + ∑ k : Fin n, ‖(σ k : ℝ) • Y k‖ ^ 2 = ∑ k : Fin n, ∑ l : Fin n, if k ≠ + l then 0 else ⟪(σ k : ℝ) • Y k, (σ l : ℝ) • Y l⟫ := by let g := fun l ↦ (σ l : ℝ) • Y l trans ∑ k : Fin n, ⟪g k, g k⟫ · apply congrArg @@ -58,26 +62,32 @@ theorem individual_weighted_norms_sum: theorem rademacher_sum_variance_zero (Y : Fin n → EuclideanSpace ℝ (Fin d)): - ∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • Y k‖ ^ 2 - ∑ k : Fin n, ‖(σ k : ℝ) • Y k‖ ^ 2) = 0 := by + ∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • Y k‖ ^ 2 - ∑ k : Fin n, ‖(σ k : ℝ) • Y k‖ ^ 2) = 0 + := by calc - _ = ∑ σ : Signs n, ∑ k : Fin n, ∑ l : Fin n, (if k ≠ l then (⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫) else (0 : ℝ)) := by + _ = ∑ σ : Signs n, ∑ k : Fin n, ∑ l : Fin n, (if k ≠ l then (⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • + (Y l)⟫) else (0 : ℝ)) := by apply congrArg ext σ let g (l : Fin n) : EuclideanSpace ℝ (Fin d) := (σ l : ℝ) • (Y l) rw [weighted_sum_norm_squared_expansion d n Y σ, individual_weighted_norms_sum d n Y σ] - suffices (∑ k : Fin n, ∑ l : Fin n, ⟪g k, g l⟫ - ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then (0 : ℝ) else ⟪g k, g l⟫) = + suffices (∑ k : Fin n, ∑ l : Fin n, ⟪g k, g l⟫ - ∑ k : Fin n, ∑ l : Fin n, if k ≠ + l then (0 : ℝ) else ⟪g k, g l⟫) = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then ⟪g k, g l⟫ else (0 : ℝ) from by exact this - have t : (∑ k : Fin n, ∑ l : Fin n, ⟪g k, g l⟫ - ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then (0 : ℝ) else ⟪g k, g l⟫) = + have t : (∑ k : Fin n, ∑ l : Fin n, ⟪g k, g l⟫ - ∑ k : Fin n, ∑ l : Fin n, if k ≠ + l then (0 : ℝ) else ⟪g k, g l⟫) = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then ⟪g k, g l⟫ else (0 : ℝ) := by calc - _ = ∑ k : Fin n, ((∑ l : Fin n, ⟪g k, g l⟫) - (∑ l : Fin n, if k ≠ l then (0 : ℝ) else ⟪g k, g l⟫)) := by + _ = ∑ k : Fin n, ((∑ l : Fin n, ⟪g k, g l⟫) - (∑ l : Fin n, if k ≠ + l then (0 : ℝ) else ⟪g k, g l⟫)) := by simp _ = ∑ k : Fin n, ∑ l : Fin n, (⟪g k, g l⟫ - if k ≠ l then (0 : ℝ) else ⟪g k, g l⟫) := by apply congrArg ext k simp - _ = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then ⟪g k, g l⟫ - (0 : ℝ) else ⟪g k, g l⟫ - ⟪g k, g l⟫ := by + _ = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then ⟪g k, g l⟫ - (0 : ℝ) else ⟪g k, g l⟫ - ⟪g k, g l⟫ + := by apply congrArg ext k apply congrArg @@ -86,9 +96,11 @@ theorem rademacher_sum_variance_zero _ = ∑ k : Fin n, ∑ l : Fin n, if k ≠ l then ⟪g k, g l⟫ else (0 : ℝ) := by simp rw [t] _ = _ := by - have e : ∀ (k l : Fin n), k ≠ l → ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ = (0 : ℝ) := by + have e : ∀ (k l : Fin n), k ≠ l → ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ = + (0 : ℝ) := by intro k l pkl - have : ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ = ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) * ⟪Y k, Y l⟫ := by + have : ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ = ∑ σ : Signs n, (σ k : ℝ) * + (σ l : ℝ) * ⟪Y k, Y l⟫ := by calc _ = ∑ σ : Signs n, (σ k : ℝ) * ⟪Y k, (σ l : ℝ) • (Y l)⟫ := by apply congrArg @@ -113,13 +125,16 @@ theorem rademacher_sum_variance_zero _ = _ := by simp exact rademacher_orthogonality n k l pkl calc - _ = ∑ k : Fin n, ∑ σ : Signs n, ∑ l : Fin n, (if k ≠ l then ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ else (0 : ℝ)) := by + _ = ∑ k : Fin n, ∑ σ : Signs n, ∑ l : Fin n, (if k ≠ l then ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • + (Y l)⟫ else (0 : ℝ)) := by rw [Finset.sum_comm] - _ = ∑ k : Fin n, ∑ l : Fin n, ∑ σ : Signs n, (if k ≠ l then ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ else (0 : ℝ)) := by + _ = ∑ k : Fin n, ∑ l : Fin n, ∑ σ : Signs n, (if k ≠ l then ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • + (Y l)⟫ else (0 : ℝ)) := by apply congrArg ext k rw [Finset.sum_comm] - _ = ∑ k : Fin n, ∑ l : Fin n, (if k ≠ l then ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • (Y l)⟫ else (0 : ℝ)) := by + _ = ∑ k : Fin n, ∑ l : Fin n, (if k ≠ l then ∑ σ : Signs n, ⟪(σ k : ℝ) • (Y k), (σ l : ℝ) • + (Y l)⟫ else (0 : ℝ)) := by apply congrArg ext k apply congrArg @@ -245,7 +260,8 @@ theorem linear_predictor_l2_bound' repeat apply congrArg rw [Finset.mul_sum] _ = (n : ℝ)⁻¹ * - (W * (((Fintype.card (Signs n) : ℝ))⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖)) := by + (W * (((Fintype.card (Signs n) : ℝ))⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖)) + := by apply congrArg ring _ = W * (n : ℝ)⁻¹ * ((Fintype.card (Signs n) : ℝ)⁻¹ * @@ -258,35 +274,48 @@ theorem linear_predictor_l2_bound' · apply le_sqrt_of_sq_le let f (σ : Signs n) := (1 : ℝ) let g (σ : Signs n) := ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ * ((Fintype.card (Signs n) : ℝ))⁻¹ - suffices (∑ σ : Signs n, f σ * g σ) ^ 2 ≤ (∑ σ : Signs n, (f σ) ^ 2) * (∑ σ : Signs n, (g σ) ^ 2) from by + suffices (∑ σ : Signs n, f σ * g σ) ^ 2 ≤ (∑ σ : Signs n, (f σ) ^ 2) * + (∑ σ : Signs n, (g σ) ^ 2) from by dsimp [f, g] at this simp only [Int.reduceNeg, one_mul, one_pow, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] at this - have p : (((Fintype.card (Signs n)) : ℝ)⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖) = - (∑ x_1 : Signs n, ‖∑ k : Fin n, (x_1 k : ℝ) • (Y k)‖ * ((Fintype.card (Signs n)) : ℝ)⁻¹) := by - trans (∑ x_1 : Signs n, ‖∑ k : Fin n, (x_1 k : ℝ) • (Y k)‖) * ((Fintype.card (Signs n)) : ℝ)⁻¹ + have p : (((Fintype.card (Signs n)) : ℝ)⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • + (Y k)‖) = + (∑ x_1 : Signs n, ‖∑ k : Fin n, (x_1 k : ℝ) • (Y k)‖ * ((Fintype.card (Signs n)) : ℝ)⁻¹) + := by + trans (∑ x_1 : Signs n, ‖∑ k : Fin n, (x_1 k : ℝ) • (Y k)‖) * + ((Fintype.card (Signs n)) : ℝ)⁻¹ · ring · apply Finset.sum_mul - have q : (Fintype.card (Signs n) : ℝ) * ∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ * (Fintype.card (Signs n) : ℝ)⁻¹) ^ 2 = - ((Fintype.card (Signs n)) : ℝ)⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2 := by + have q : (Fintype.card (Signs n) : ℝ) * ∑ σ : Signs n, + (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ * (Fintype.card (Signs n) : ℝ)⁻¹) ^ 2 = + ((Fintype.card (Signs n)) : ℝ)⁻¹ * ∑ σ : Signs n, ‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2 + := by calc - _ = (Fintype.card (Signs n) : ℝ) * ∑ σ : Signs n, ((‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2) * ((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) := by + _ = (Fintype.card (Signs n) : ℝ) * ∑ σ : Signs n, + ((‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2) * ((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) := by repeat apply congrArg ext σ field_simp - _ = (Fintype.card (Signs n) : ℝ) * ((∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2)) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2)) := by + _ = (Fintype.card (Signs n) : ℝ) * ((∑ σ : Signs n, + (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2)) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2)) + := by apply congrArg symm apply Finset.sum_mul - _ = (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) * (∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2)) := by + _ = (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) * + (∑ σ : Signs n, (‖∑ k : Fin n, (σ k : ℝ) • (Y k)‖ ^ 2)) := by ring _ = _ := by - have e : (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) = (Fintype.card (Signs n) : ℝ)⁻¹ := by + have e : (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) ^ 2) = + (Fintype.card (Signs n) : ℝ)⁻¹ := by calc - _ = (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) * ((Fintype.card (Signs n) : ℝ)⁻¹)) := by + _ = (Fintype.card (Signs n) : ℝ) * (((Fintype.card (Signs n) : ℝ)⁻¹) * + ((Fintype.card (Signs n) : ℝ)⁻¹)) := by apply congrArg apply pow_two - _ = ((Fintype.card (Signs n) : ℝ) * ((Fintype.card (Signs n) : ℝ)⁻¹)) * ((Fintype.card (Signs n) : ℝ)⁻¹) := by + _ = ((Fintype.card (Signs n) : ℝ) * ((Fintype.card (Signs n) : ℝ)⁻¹)) * + ((Fintype.card (Signs n) : ℝ)⁻¹) := by symm apply mul_assoc _ = _ := by simp @@ -344,8 +373,10 @@ theorem linear_predictor_l2_bound' ∑ σ : Signs n, (∑ k : Fin n, X ^ 2)) = ((n : ℝ) * X ^ 2) := by calc - _ = ((Fintype.card (Signs n) : ℝ))⁻¹ * ((Fintype.card (Signs n) : ℝ) * ((n : ℝ) * X ^ 2)) := by simp - _ = ((Fintype.card (Signs n) : ℝ))⁻¹ * (Fintype.card (Signs n) : ℝ) * ((n : ℝ) * X ^ 2) := by ring + _ = ((Fintype.card (Signs n) : ℝ))⁻¹ * ((Fintype.card (Signs n) : ℝ) * ((n : ℝ) * X ^ 2)) + := by simp + _ = ((Fintype.card (Signs n) : ℝ))⁻¹ * (Fintype.card (Signs n) : ℝ) * ((n : ℝ) * X ^ 2) + := by ring _ = ((n : ℝ) * X ^ 2) := by field_simp rw [q] @@ -359,7 +390,8 @@ theorem linear_predictor_l2_bound' _ = X * W * ((n : ℝ)⁻¹ * √(n : ℝ)) := by ring _ = X * W * (1 / √(n : ℝ)) := by by_cases hn : 0 < n - · rw [(by apply eq_one_div_of_mul_eq_one_left; field_simp; exact sq_sqrt (Nat.cast_nonneg' n) : ((n : ℝ)⁻¹ * √(n : ℝ)) = (1 / √(n : ℝ)))] + · rw [(by apply eq_one_div_of_mul_eq_one_left; field_simp; exact sq_sqrt (Nat.cast_nonneg' n) : + ((n : ℝ)⁻¹ * √(n : ℝ)) = (1 / √(n : ℝ)))] · simp only [not_lt, nonpos_iff_eq_zero] at hn rw [hn] simp diff --git a/StatsMLlib/LearningTheory/Rademacher/Complexity.lean b/StatsMLlib/LearningTheory/Rademacher/Complexity.lean index c08ff78..654e86e 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Complexity.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Complexity.lean @@ -74,7 +74,8 @@ theorem abs_signed_sum_le_card_mul_bound [Nonempty ι] {X : Ω → Z} (i : ι) (ω : Fin n → Ω) (σ : Signs n) : |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k))| ≤ ↑n * b := by calc - _ ≤ ∑ k : Fin n, (|↑↑(σ k) * f i (X (ω k))|) := Finset.univ.abs_sum_le_sum_abs (fun k ↦ ↑↑(σ k) * f i (X (ω k))) + _ ≤ ∑ k : Fin n, (|↑↑(σ k) * f i (X (ω k))|) := Finset.univ.abs_sum_le_sum_abs (fun k ↦ ↑↑(σ k) * + f i (X (ω k))) _ = ∑ k : Fin n, |f i (X (ω k))| := by congr; ext k; simp only [Int.reduceNeg, abs_mul, Signs.apply_abs', one_mul] _ ≤ ∑ k : Fin n, b := Finset.sum_le_sum fun k _ ↦ hf' i (X (ω k)) @@ -100,13 +101,15 @@ lemma symmetrization_signed_sup_le_add (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * (f i (X (ω k).1) - f i (X (ω k).2))|) ≤ fun ω ↦ - ((↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω k).1)|) + - (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω k).2)| := by + ((↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * + f i (X (ω k).1)|) + + (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω k).2)| + := by intro ω dsimp rw [←mul_add] apply mul_le_mul_of_nonneg_left - . rw [←Finset.sum_add_distrib] + · rw [←Finset.sum_add_distrib] apply Finset.sum_le_sum intro σ _ calc @@ -142,7 +145,8 @@ lemma symmetrization_signed_sup_le_add · apply inv_nonneg_of_nonneg exact Nat.cast_nonneg' (Fintype.card (Signs n)) -theorem iSup_integral_toReal_le_integral_iSup_toReal {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsFiniteMeasure μ] {ι : Sort*} [Countable ι] (f : ι → α → ℝ≥0∞) +theorem iSup_integral_toReal_le_integral_iSup_toReal {α : Type*} [MeasurableSpace α] (μ : Measure α) + [IsFiniteMeasure μ] {ι : Sort*} [Countable ι] (f : ι → α → ℝ≥0∞) (hfm : ∀ i, Measurable (f i)) {b : ℝ≥0∞} (hb : b ≠ ⊤) (hf : ∀ i, ∀ x, f i x ≤ b) : ⨆ i, ∫ a, (f i a).toReal ∂μ ≤ ∫ a, ⨆ i, (f i a).toReal ∂μ := by have hf_le : ∀ i, ∀ x, f i x < ⊤ := by @@ -205,7 +209,8 @@ theorem iSup_integral_toReal_le_integral_iSup_toReal {α : Type*} [MeasurableSpa apply iSup_lintegral_le -- TODO: add appropriate integrability assumptions for `f` -theorem iSup_integral_le {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsFiniteMeasure μ] {ι : Sort*} [Countable ι] +theorem iSup_integral_le {α : Type*} [MeasurableSpace α] (μ : Measure α) [IsFiniteMeasure μ] + {ι : Sort*} [Countable ι] (f : ι → α → ℝ) (hf : ∀ (i : ι), Measurable fun a ↦ f i a) {b : ℝ} @@ -254,8 +259,10 @@ theorem measurable_sum_sub_right {X : Ω → Z} (hf : ∀ (i : ι), Measurable ( intro k _ apply ((hf i).comp measurable_const).sub ((hf i).comp (measurable_pi_apply k)) -theorem measurable_signed_sup_sum_fst_core [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) := by +theorem measurable_signed_sup_sum_fst_core [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : + Measurable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * + f i (X (ω.1 k))|) := by apply Finset.univ.measurable_sum intro σ _ apply Measurable.iSup @@ -266,9 +273,11 @@ theorem measurable_signed_sup_sum_fst_core [Countable ι] {X : Ω → Z} (hf : apply measurable_const.mul apply (hf i).comp measurable_fst.eval -theorem measurable_signed_sup_sum_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : +theorem measurable_signed_sup_sum_fst [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : Measurable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ - (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) := by + (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) + := by apply measurable_const.mul apply measurable_signed_sup_sum_fst_core hf @@ -376,7 +385,8 @@ theorem abs_sum_sup_signed_le_pow_mul_bound {X : Ω → Z} simp only [iSup_of_isEmpty] exact mul_nonneg (Nat.cast_nonneg n) hb -theorem integrable_signed_sup_sum_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_signed_sup_sum_fst [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hb : 0 ≤ b) (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : Integrable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) @@ -393,7 +403,8 @@ theorem integrable_signed_sup_sum_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i theorem measurable_sup_abs_integral_sum_sub {X : Ω → Z} [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable fun ω : Fin n → Ω ↦ ⨆ i, |∫ (x : Fin n → Ω), ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k))) ∂μⁿ| := by + Measurable fun ω : Fin n → Ω ↦ ⨆ i, |∫ (x : Fin n → Ω), ∑ k : Fin n, + (f i (X (ω k)) - f i (X (x k))) ∂μⁿ| := by apply Measurable.iSup intro i refine Measurable.max ?hf.left.hf.hf.hf ?hf.left.hf.hf.hg @@ -428,10 +439,12 @@ theorem measurable_pi_sum [AddCommMonoid Z] [MeasurableSpace Z][MeasurableAdd₂ intro k _ apply hX.comp (measurable_pi_apply k) -theorem measurable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : +theorem measurable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : Measurable (fun ω : Fin n → (Ω × Ω) ↦ - (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * (f i (X (ω k).1) - f i (X (ω k).2))|) := by + (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * + (f i (X (ω k).1) - f i (X (ω k).2))|) := by apply Measurable.mul measurable_const apply Finset.univ.measurable_sum intro σ _ @@ -516,11 +529,13 @@ theorem bddAbove_range_abs_sum_signed_sub [Countable ι] {X : Ω → Z} apply hz simp -theorem integrable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hb : 0 ≤ b) (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : Integrable (fun ω : Fin n → (Ω × Ω) ↦ - (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * (f i (X (ω k).1) - f i (X (ω k).2))|) + (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * + (f i (X (ω k).1) - f i (X (ω k).2))|) (Measure.pi fun _ ↦ μ.prod μ) := by rw [← memLp_one_iff_integrable] apply MemLp.of_bound (measurable_signed_sup_sum_sub hf).aestronglyMeasurable (n * (b + b)) @@ -578,7 +593,8 @@ theorem integrable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ (i by_cases h : Nonempty ι · apply ciSup_le intro i - suffices ∑ k : Fin n, (|f i (X (ω k).1)| + |f i (X (ω k).2)|) ≤ ∑ k : Fin n, (b + b) from by + suffices ∑ k : Fin n, (|f i (X (ω k).1)| + |f i (X (ω k).2)|) ≤ + ∑ k : Fin n, (b + b) from by apply le_trans this _ apply le_of_eq simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, smul_add, nsmul_eq_mul] @@ -589,8 +605,10 @@ theorem integrable_signed_sup_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ (i apply mul_nonneg (Nat.cast_nonneg n) exact Left.add_nonneg hb hb -theorem measurable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable (fun ω : Fin n → Ω × Ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).1)|) := by +theorem measurable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : + Measurable (fun ω : Fin n → Ω × Ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * + ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).1)|) := by apply Measurable.mul measurable_const apply Finset.univ.measurable_sum intro σ _ @@ -602,9 +620,11 @@ theorem measurable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} (hf : apply measurable_const.mul apply (hf i).comp (measurable_pi_apply k).fst -theorem integrable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hb : 0 ≤ b) (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : - Integrable (fun ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).1)|) + Integrable (fun ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * + f i (X (ω k).1)|) (Measure.pi fun _ ↦ μ.prod μ) := by rw [← memLp_one_iff_integrable] apply MemLp.of_bound (measurable_signed_sup_sum_pair_fst hf).aestronglyMeasurable (n * b) @@ -615,8 +635,10 @@ theorem integrable_signed_sup_sum_pair_fst [Countable ι] {X : Ω → Z} (hf : rw [mul_comm (↑n * b)] apply abs_sum_sup_signed_le_pow_mul_bound hb hf' -theorem measurable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable (fun ω : Fin n → Ω × Ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).2)|) := by +theorem measurable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : + Measurable (fun ω : Fin n → Ω × Ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * + ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).2)|) := by apply Measurable.mul measurable_const apply Finset.univ.measurable_sum intro σ _ @@ -628,9 +650,11 @@ theorem measurable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} (hf : apply measurable_const.mul apply (hf i).comp (measurable_pi_apply k).snd -theorem integrable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hb : 0 ≤ b) (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : - Integrable (fun ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω k).2)|) + Integrable (fun ω ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * + f i (X (ω k).2)|) (Measure.pi fun _ ↦ μ.prod μ) := by rw [← memLp_one_iff_integrable] apply MemLp.of_bound (measurable_signed_sup_sum_pair_snd hf).aestronglyMeasurable (n * b) @@ -643,7 +667,8 @@ theorem integrable_signed_sup_sum_pair_snd [Countable ι] {X : Ω → Z} (hf : theorem integrable_sup_abs_integral_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι] [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : - Integrable (fun a ↦ ⨆ i, |∫ (x : Fin n → Ω), ∑ k : Fin n, (f i (X (a k)) - f i (X (x k))) ∂μⁿ|) μⁿ := by + Integrable (fun a ↦ ⨆ i, |∫ (x : Fin n → Ω), ∑ k : Fin n, (f i (X (a k)) - f i (X (x k))) ∂μⁿ|) μⁿ + := by constructor · apply Measurable.aestronglyMeasurable apply measurable_sup_abs_integral_sum_sub hf @@ -654,10 +679,12 @@ theorem integrable_sup_abs_integral_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι simp only [Finset.sum_sub_distrib, abs_abs] rw [abs_le] constructor - · suffices ∀ (x : Fin n → Ω), (-(↑n * (b + b)) ≤ ∑ x : Fin n, f i (X (ω' x)) - ∑ x_1 : Fin n, f i (X (x x_1))) from by + · suffices ∀ (x : Fin n → Ω), (-(↑n * (b + b)) ≤ ∑ x : Fin n, f i (X (ω' x)) - + ∑ x_1 : Fin n, f i (X (x x_1))) from by calc _ = ∫ (x : Fin n → Ω), -(↑n * (b + b)) ∂μⁿ := by simp - _ ≤ ∫ (x : Fin n → Ω), ∑ x : Fin n, f i (X (ω' x)) - ∑ x_1 : Fin n, f i (X (x x_1)) ∂μⁿ := by + _ ≤ ∫ (x : Fin n → Ω), ∑ x : Fin n, f i (X (ω' x)) - + ∑ x_1 : Fin n, f i (X (x x_1)) ∂μⁿ := by apply MeasureTheory.integral_mono · exact integrable_const _ · constructor @@ -709,7 +736,8 @@ theorem integrable_sup_abs_integral_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι exact fun i_1 a ↦ le_of_max_le_left (hf' i (X (x i_1))) _ = ↑n * b := by simp linarith - · have p : (∫ (x : Fin n → Ω), ∑ x : Fin n, f i (X (ω' x)) - ∑ x_1 : Fin n, f i (X (x x_1)) ∂μⁿ) ≤ (∫ (x : Fin n → Ω), ↑n * (b + b) ∂μⁿ) := by + · have p : (∫ (x : Fin n → Ω), ∑ x : Fin n, f i (X (ω' x)) - + ∑ x_1 : Fin n, f i (X (x x_1)) ∂μⁿ) ≤ (∫ (x : Fin n → Ω), ↑n * (b + b) ∂μⁿ) := by apply integral_mono apply Integrable.sub constructor @@ -749,7 +777,8 @@ theorem integrable_sup_abs_integral_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι exact p omit [MeasurableSpace Ω] in -theorem bounded_difference_of_bounded {f : ι → Z → ℝ} {X : Ω → Z} {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) +theorem bounded_difference_of_bounded {f : ι → Z → ℝ} {X : Ω → Z} {b : ℝ} + (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) (ω : Fin n → Ω) (i : ι) (ω' : Fin n → Ω) : |∑ k : Fin n, (f i (X (ω k)) - f i (X (ω' k)))| ≤ ↑n * (b + b) := calc @@ -766,7 +795,8 @@ theorem bounded_difference_of_bounded {f : ι → Z → ℝ} {X : Ω → Z} {b : _ = _ := by ring -theorem measurable_norm_sup_abs_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) (ω : Fin n → Ω) : +theorem measurable_norm_sup_abs_sum_sub [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) (ω : Fin n → Ω) : Measurable (fun ω' : Fin n → Ω ↦ ‖⨆ i, |∑ k : Fin n, (f i (X (ω k)) - f i (X (ω' k)))|‖) := by apply Measurable.norm apply Measurable.iSup @@ -778,7 +808,8 @@ theorem measurable_norm_sup_abs_sum_sub [Countable ι] {X : Ω → Z} (hf : ∀ apply (hf i).comp measurable_const exact measurable_eval_comp hf i k -theorem integrable_norm_sup_abs_sum_sub [Nonempty ι] [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_norm_sup_abs_sum_sub [Nonempty ι] [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) (ω : Fin n → Ω) : Integrable (fun ω' ↦ ‖⨆ i, |∑ k : Fin n, (f i (X (ω k)) - f i (X (ω' k)))|‖) μⁿ := by rw [← memLp_one_iff_integrable] @@ -790,8 +821,10 @@ theorem integrable_norm_sup_abs_sum_sub [Nonempty ι] [Countable ι] {X : Ω → simp only [abs_abs] apply bounded_difference_of_bounded hf' -theorem measurable_signed_sup_sum_prod_fst [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) := by +theorem measurable_signed_sup_sum_prod_fst [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) : + Measurable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (↑(Fintype.card (Signs n)))⁻¹ * + ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) := by apply Measurable.mul measurable_const apply Finset.univ.measurable_sum intro σ _ @@ -804,9 +837,11 @@ theorem measurable_signed_sup_sum_prod_fst [Countable ι] {X : Ω → Z} (hf : apply (hf i).comp apply measurable_fst.eval -theorem integrable_signed_sup_sum_prod_fst [Nonempty ι] [Countable ι] {X : Ω → Z} (hf : ∀ (i : ι), Measurable (f i ∘ X)) +theorem integrable_signed_sup_sum_prod_fst [Nonempty ι] [Countable ι] {X : Ω → Z} + (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : - Integrable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (↑(Fintype.card (Signs n)))⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) + Integrable (fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (↑(Fintype.card (Signs n)))⁻¹ * + ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, ↑↑(σ k) * f i (X (ω.1 k))|) (μⁿ.prod μⁿ) := by simp_rw [← memLp_one_iff_integrable] apply MemLp.of_bound (measurable_signed_sup_sum_prod_fst hf).aestronglyMeasurable (n * b) @@ -875,9 +910,11 @@ theorem integrable_sup_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Counta apply bounded_difference_of_bounded hf' theorem integrable_integral_sup_abs_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι] - [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : + [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} + (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : Integrable - (fun ω ↦ ∫ (x : Fin n → Ω), (fun ω' ↦ ⨆ i, |∑ k : Fin n, (f i (X (ω k)) - f i (X (ω' k)))|) x ∂μⁿ) + (fun ω ↦ ∫ (x : Fin n → Ω), (fun ω' ↦ ⨆ i, |∑ k : Fin n, + (f i (X (ω k)) - f i (X (ω' k)))|) x ∂μⁿ) μⁿ := by simp_rw [← memLp_one_iff_integrable] refine MemLp.of_bound ?_ (n*(b+b)) ?_ @@ -922,7 +959,8 @@ theorem integrable_integral_sup_abs_sum_sub {X : Ω → Z} [inst_2 : Nonempty ι theorem measurable_sup_abs_sum_sub_prod{X : Ω → Z} [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) : - Measurable (fun ω : ((Fin n → Ω) × (Fin n → Ω)) ↦ ⨆ i, |∑ k : Fin n, (f i (X (ω.1 k)) - f i (X (ω.2 k)))|) := by + Measurable (fun ω : ((Fin n → Ω) × (Fin n → Ω)) ↦ ⨆ i, |∑ k : Fin n, + (f i (X (ω.1 k)) - f i (X (ω.2 k)))|) := by apply Measurable.iSup intro i apply Measurable.abs @@ -933,7 +971,8 @@ theorem measurable_sup_abs_sum_sub_prod{X : Ω → Z} apply (hf i).comp measurable_snd.eval theorem integrable_sup_abs_sum_sub_prod {X : Ω → Z} [inst_2 : Nonempty ι] - [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : + [inst_3 : Countable ι] (hf : ∀ (i : ι), Measurable (f i ∘ X)) {b : ℝ} + (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : Integrable (fun ω ↦ ⨆ i, |∑ k : Fin n, (f i (X (ω.1 k)) - f i (X (ω.2 k)))|) (μⁿ.prod μⁿ) := by rw [← memLp_one_iff_integrable] @@ -949,16 +988,19 @@ theorem integral_sum_sub_eq_sum_sub_integral {X : Ω → Z} (hf : ∀ i, Measura (∫ (ω' : Fin n → Ω), ∑ k : Fin n, (f i (X (ω k)) - f i (X (ω' k))) ∂μⁿ) = ∑ k : Fin n, (f i (X (ω k)) - ∫ (ω' : Fin n → Ω), f i (X (ω' k)) ∂μⁿ) := calc - _ = (∫ (ω' : Fin n → Ω), (∑ k : Fin n, (f i (X (ω k))) - (∑ k : Fin n, f i (X (ω' k)))) ∂μⁿ) := by + _ = (∫ (ω' : Fin n → Ω), (∑ k : Fin n, (f i (X (ω k))) - (∑ k : Fin n, f i (X (ω' k)))) ∂μⁿ) + := by apply congrArg funext ω' exact Finset.sum_sub_distrib (fun x ↦ f i (X (ω x))) fun x ↦ f i (X (ω' x)) - _ = (∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω k)) ∂μⁿ) - (∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω' k)) ∂μⁿ) := by + _ = (∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω k)) ∂μⁿ) - + (∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω' k)) ∂μⁿ) := by apply integral_sub · simp · apply integrable_finsetSum exact fun i_1 a ↦ integrable_eval_comp hf hf' i i_1 - _ = (∑ k : Fin n, f i (X (ω k)) - ∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω' k)) ∂μⁿ) := by simp + _ = (∑ k : Fin n, f i (X (ω k)) - ∫ (ω' : Fin n → Ω), ∑ k : Fin n, f i (X (ω' k)) ∂μⁿ) + := by simp _ = (∑ k : Fin n, f i (X (ω k)) - ∑ k : Fin n, ∫ (ω' : Fin n → Ω), f i (X (ω' k)) ∂μⁿ) := by simp only [sub_right_inj] exact integral_finsetSum Finset.univ (fun i_1 a ↦ integrable_eval_comp hf hf' i i_1) @@ -972,7 +1014,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) : (μⁿ.prod μⁿ)[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ ((Fintype.card (Signs n) : ℝ)⁻¹ * ∑ σ : Signs n, ⨆ i, (|∑ k : Fin n, (σ k : ℝ) * f i (X (ω.1 k))|))] - + ((Measure.pi fun _ ↦ μ).prod (Measure.pi fun _ ↦ μ))[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (Fintype.card (Signs n) : ℝ)⁻¹ * + + ((Measure.pi fun _ ↦ μ).prod (Measure.pi fun _ ↦ μ))[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ + (Fintype.card (Signs n) : ℝ)⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω.2 k))|] = (2 * μⁿ[fun ω : Fin n → Ω ↦ (Fintype.card (Signs n) : ℝ)⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω k))|] : ℝ) := by @@ -998,7 +1041,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul apply Measurable.iSup intro i_1 refine Measurable.max ?left.hf.hf.h.hf.hf.hf ?left.hf.hf.h.hf.hf.hg - have k0 : ∀ (k : Fin n), Measurable (fun (b : (Fin n → Ω) × (Fin n → Ω)) ↦ (i k : ℝ) * f i_1 (X (b.2 k))) := by + have k0 : ∀ (k : Fin n), Measurable (fun (b : (Fin n → Ω) × (Fin n → Ω)) ↦ (i k : ℝ) * + f i_1 (X (b.2 k))) := by intro k apply Measurable.mul exact measurable_const @@ -1007,7 +1051,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul exact measurable_snd exact Finset.measurable_sum Finset.univ fun i a ↦ k0 i apply Measurable.neg - have k0 : ∀ (k : Fin n), Measurable (fun (b : (Fin n → Ω) × (Fin n → Ω)) ↦ (i k : ℝ) * f i_1 (X (b.2 k))) := by + have k0 : ∀ (k : Fin n), Measurable (fun (b : (Fin n → Ω) × (Fin n → Ω)) ↦ (i k : ℝ) * + f i_1 (X (b.2 k))) := by intro k apply Measurable.mul exact measurable_const @@ -1020,7 +1065,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul simp only [Signs.card, Nat.cast_pow, Nat.cast_ofNat, Int.reduceNeg, norm_mul, norm_inv, norm_pow, norm_ofNat, norm_eq_abs] rw [inv_mul_le_iff₀] - have l0 : |(∑ σ : Signs n, (⨆ i, |(∑ k : Fin n, (σ k : ℝ) * f i (X (a.2 k)))|))| ≤ ↑(2 ^ n) * (↑n * b) := by + have l0 : |(∑ σ : Signs n, (⨆ i, |(∑ k : Fin n, (σ k : ℝ) * f i (X (a.2 k)))|))| ≤ + ↑(2 ^ n) * (↑n * b) := by calc _ ≤ ∑ σ : Signs n, |(⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (a.2 k))|)| := by apply Finset.abs_sum_le_sum_abs @@ -1032,7 +1078,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul simp only [Int.reduceNeg, abs_abs] have l1 : |∑ k : Fin n, (i k : ℝ) * f i_1 (X (a.2 k))| ≤ ↑n * b := by calc - _ ≤ ∑ k : Fin n, |(i k : ℝ) * f i_1 (X (a.2 k))| := by apply Finset.abs_sum_le_sum_abs + _ ≤ ∑ k : Fin n, |(i k : ℝ) * f i_1 (X (a.2 k))| + := by apply Finset.abs_sum_le_sum_abs _ ≤ ∑ k : Fin n, b := by apply Finset.sum_le_sum intro i_2 hi_2 @@ -1050,7 +1097,8 @@ theorem integral_fst_signed_sup_add_integral_snd_eq_two_mul theorem bddAbove_range_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Countable ι] (hf : ∀ i, Measurable (f i ∘ X)) {b : ℝ} (hf' : ∀ (i : ι) (z : Z), |f i z| ≤ b) (ω : Fin n → Ω) : - BddAbove (Set.range fun i ↦ ∫ (x : Fin n → Ω), |∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))| ∂μⁿ) := by + BddAbove (Set.range fun i ↦ ∫ (x : Fin n → Ω), |∑ k : Fin n, + (f i (X (ω k)) - f i (X (x k)))| ∂μⁿ) := by have hp : ∀ (i : ι) (j : Fin n), Integrable (fun (a : Fin n → Ω) ↦ f i (X (a j))) μⁿ := by apply integrable_eval_comp hf hf' have hr : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ (Set.range fun i ↦ f i (X (ω k))), y ≤ C := by @@ -1060,7 +1108,8 @@ theorem bddAbove_range_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Counta obtain ⟨i, hi⟩ := hy rw [← hi] exact le_of_max_le_left (hf' i (X (ω k))) - have hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ (Set.range fun i ↦ f i (X (ω k))), C ≤ y := by + have hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ (Set.range fun i ↦ f i (X (ω k))), C ≤ y + := by exists -b intro ω k y hy simp only [Set.mem_range] at hy @@ -1083,22 +1132,31 @@ theorem bddAbove_range_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Counta obtain ⟨i, hi⟩ := hx rw [← hi] exact neg_le_of_abs_le (hf' i (X (ω k))) - have hq0 : ∀ (ω x: Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i ↦ (f i (X (ω k)) - f i (X (x k)))) := + have hq0 : ∀ (ω x: Fin n → Ω) (k : Fin n), BddAbove (Set.range fun i ↦ + (f i (X (ω k)) - f i (X (x k)))) := fun ω' x k => BddAbove.range_add (hq ω' k) (BddBelow.range_neg (hq' x k)) - have hq1 : ∀ (ω x: Fin n → Ω), BddAbove (Set.range fun i ↦ ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) := - fun ω' x => BddAbove.range_comp_left (bddAbove_range_pi.mpr (hq0 ω' x)) fun f g hfg => Finset.sum_le_sum fun i a ↦ hfg i - have hq2 : ∀ (ω x: Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i ↦ (f i (X (ω k)) - f i (X (x k)))) := + have hq1 : ∀ (ω x: Fin n → Ω), BddAbove (Set.range fun i ↦ + ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) := + fun ω' x => BddAbove.range_comp_left (bddAbove_range_pi.mpr (hq0 ω' x)) fun f g hfg => + Finset.sum_le_sum fun i a ↦ hfg i + have hq2 : ∀ (ω x: Fin n → Ω) (k : Fin n), BddBelow (Set.range fun i ↦ + (f i (X (ω k)) - f i (X (x k)))) := fun ω' x k => BddBelow.range_add (hq' ω' k) (BddAbove.range_neg (hq x k)) - have hq3 : ∀ (ω x: Fin n → Ω), BddBelow (Set.range fun i ↦ ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) := - fun ω' x => BddBelow.range_comp_left (bddBelow_range_pi.mpr (hq2 ω' x)) (fun f g hfg => Finset.sum_le_sum fun i a ↦ hfg i) - have hq1 : ∀ (ω x: Fin n → Ω), BddAbove (Set.range fun i ↦ |∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))|) := by + have hq3 : ∀ (ω x: Fin n → Ω), BddBelow (Set.range fun i ↦ + ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) := + fun ω' x => BddBelow.range_comp_left (bddBelow_range_pi.mpr (hq2 ω' x)) + (fun f g hfg => Finset.sum_le_sum fun i a ↦ hfg i) + have hq1 : ∀ (ω x: Fin n → Ω), BddAbove (Set.range fun i ↦ + |∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))|) := by intro ω x obtain hq1'' := hq1 ω x obtain hq3'' := hq3 ω x - have hr : ∃ a b, (Set.range fun i ↦ ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) ⊆ Set.Icc a b := by + have hr : ∃ a b, (Set.range fun i ↦ ∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))) ⊆ Set.Icc a b + := by rw [<- bddBelow_bddAbove_iff_subset_Icc] exact And.symm ⟨hq1 ω x, hq3 ω x⟩ - have hr' : ∃ a b, (Set.range fun i ↦ |∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))|) ⊆ Set.Icc a b := by + have hr' : ∃ a b, (Set.range fun i ↦ |∑ k : Fin n, (f i (X (ω k)) - f i (X (x k)))|) ⊆ + Set.Icc a b := by obtain ⟨a, b, hab⟩ := hr use min a (-b) use max (-a) b @@ -1127,7 +1185,8 @@ theorem bddAbove_range_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Counta obtain ⟨D, hr1⟩ := hr' apply BddAbove.range_mono intro a - suffices (∫ (x : Fin n → Ω), |∑ k : Fin n, (f a (X (ω k)) - f a (X (x k)))| ∂μⁿ) ≤ n * (C - D) from by + suffices (∫ (x : Fin n → Ω), |∑ k : Fin n, (f a (X (ω k)) - f a (X (x k)))| ∂μⁿ) ≤ n * + (C - D) from by exact this have hr2 : ∀ (x : Fin n → Ω), |∑ k : Fin n, (f a (X (ω k)) - f a (X (x k)))| ≤ ↑n * (C - D) := by intro x @@ -1148,7 +1207,8 @@ theorem bddAbove_range_integral_abs_sum_sub {X : Ω → Z} [Nonempty ι] [Counta exact Finset.sum_le_sum fun i a ↦ w0 i _ = ↑n * (C - D) := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] - have u : (∫ (x : Fin n → Ω), |∑ k : Fin n, (f a (X (ω k)) - f a (X (x k)))| ∂μⁿ) ≤ ↑n * (C - D) := by + have u : (∫ (x : Fin n → Ω), |∑ k : Fin n, (f a (X (ω k)) - f a (X (x k)))| ∂μⁿ) ≤ ↑n * (C - D) + := by calc _ ≤ (∫ (x : Fin n → Ω), n * (C - D) ∂μⁿ) := by apply integral_mono @@ -1200,7 +1260,8 @@ theorem replace_mean_with_coordinate_mean {X : Ω → Z} [Nonempty ι] [Countabl congr ext k apply congrArg - have : (Measure.map (fun f ↦ f k) (μⁿ))[fun y ↦ f i (X y)] = μⁿ[fun x : Fin n → Ω ↦ f i (X (x k))] := + have : (Measure.map (fun f ↦ f k) (μⁿ))[fun y ↦ f i (X y)] = μⁿ[fun x : Fin n → Ω ↦ f i (X (x k))] + := integral_map (measurable_pi_apply k).aemeasurable (Measurable.aestronglyMeasurable (hf i)) rw [← this, pi_map_eval k] @@ -1220,7 +1281,8 @@ theorem expectation_le_rademacher {X : Ω → Z} [Nonempty ι] [Countable ι] obtain ⟨i, hi⟩ := hy rw [← hi] exact le_of_max_le_left (hf' i (X (ω k))) - have hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ (Set.range fun i ↦ f i (X (ω k))), C ≤ y := by + have hr' : ∃ C, ∀ (ω : Fin n → Ω) (k : Fin n), ∀ y ∈ (Set.range fun i ↦ f i (X (ω k))), C ≤ y + := by exists -b intro ω k y hy simp only [Set.mem_range] at hy @@ -1284,10 +1346,12 @@ theorem expectation_le_rademacher {X : Ω → Z} [Nonempty ι] [Countable ι] -- TODO: integrability · apply integrable_sup_integral_abs_sum_sub hf hf' · apply integrable_integral_sup_abs_sum_sub hf hf' - _ = (Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω ↦ ⨆ i, |∑ k : Fin n, (f i (X (ω k).1) - f i (X (ω k).2))|] := by + _ = (Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω ↦ + ⨆ i, |∑ k : Fin n, (f i (X (ω k).1) - f i (X (ω k).2))|] := by -- Rewrite using the product measure dsimp only - rw [←integral_prod fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ ⨆ i, |∑ k : Fin n, (f i (X (ω.1 k)) - f i (X (ω.2 k)))|] + rw [←integral_prod fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ + ⨆ i, |∑ k : Fin n, (f i (X (ω.1 k)) - f i (X (ω.2 k)))|] let mp := measurePreserving_arrowProdEquivProdArrow Ω Ω (Fin n) (fun _ ↦ μ) (fun _ ↦ μ) rw [←mp.map_eq, integral_map mp.measurable.aemeasurable] · rfl @@ -1352,7 +1416,8 @@ theorem expectation_le_rademacher {X : Ω → Z} [Nonempty ι] [Countable ι] exact measurable_signed_sup_sum_fst_core hf _ = (μⁿ.prod μⁿ)[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ ((Fintype.card (Signs n) : ℝ)⁻¹ * ∑ σ : Signs n, ⨆ i, (|∑ k : Fin n, (σ k : ℝ) * f i (X (ω.1 k))|))] - + ((Measure.pi fun _ ↦ μ).prod (Measure.pi fun _ ↦ μ))[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ (Fintype.card (Signs n) : ℝ)⁻¹ * + + ((Measure.pi fun _ ↦ μ).prod (Measure.pi fun _ ↦ μ))[fun ω : (Fin n → Ω) × (Fin n → Ω) ↦ + (Fintype.card (Signs n) : ℝ)⁻¹ * ∑ σ : Signs n, ⨆ i, |∑ k : Fin n, (σ k : ℝ) * f i (X (ω.2 k))|] := by -- Move the sum outside the integral apply integral_add diff --git a/StatsMLlib/LearningTheory/Rademacher/Dudley.lean b/StatsMLlib/LearningTheory/Rademacher/Dudley.lean index baa2a07..14b0b72 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Dudley.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Dudley.lean @@ -73,7 +73,8 @@ private lemma ej_pos (c_pos : 0 < c) : ∀ j, (ej c j > 0) := by simp only [gt_iff_lt, Nat.ofNat_pos, pow_pos, div_pos_iff_of_pos_right] exact c_pos -private noncomputable abbrev cj (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (j : ℕ) +private noncomputable abbrev cj (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (j : ℕ) := coveringFinset h (ej_pos c_pos j) -- Factor out commonly used expressions private noncomputable abbrev signs_card_inv (m : ℕ) : ℝ := (Fintype.card (Signs m) : ℝ)⁻¹ @@ -86,7 +87,8 @@ private lemma e_nonempty : exact ⟨⟨i⟩, by simp⟩ omit [Nonempty ι] in -private lemma exists_cover_approximation (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) +private lemma exists_cover_approximation (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (fh : ι) (j : ℕ) : ∃ f_j : EmpiricalFunctionSpace F S, f_j ∈ cj c_pos h j ∧ empiricalDist S (F fh) f_j ≤ ej c j := by have : ⟨fh⟩ ∈ ⋃ y ∈ coveringFinset h (ej_pos c_pos j), Metric.closedBall y (ej c j) @@ -98,7 +100,9 @@ private lemma exists_cover_approximation (c_pos : 0 < c) (h : TotallyBounded (Se · exact hy' · exact hy'' -private noncomputable def coverApprox (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : ι → ℕ → EmpiricalFunctionSpace F S := +private noncomputable def coverApprox (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : ι → ℕ → + EmpiricalFunctionSpace F S := fun fh j => Classical.choose (exists_cover_approximation c_pos h fh j) omit [Nonempty ι] in @@ -115,23 +119,30 @@ private lemma empiricalDist_coverApprox_le_radius (c_pos : 0 < c) classical exact (Classical.choose_spec (exists_cover_approximation c_pos h fh j)).2 -private noncomputable def chainApprox (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : ι → ℕ → Z → ℝ := +private noncomputable def chainApprox (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : ι → ℕ → Z → ℝ := fun fh j => if j = 0 then 0 else (coverApprox c_pos h fh j : Z → ℝ) omit [Nonempty ι] in -private lemma chainApprox_def (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))): ∀ fh j, chainApprox c_pos h fh j = if j = 0 then 0 else (coverApprox c_pos h fh j : Z → ℝ) := by +private lemma chainApprox_def (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))): ∀ fh j, + chainApprox c_pos h fh j = if j = 0 then 0 else (coverApprox c_pos h fh j : Z → ℝ) := by intro fh j dsimp [chainApprox] omit [Nonempty ι] in -private lemma chainApprox_succ (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) - (fh : ι) (j : ℕ) : chainApprox c_pos h fh (j + 1) = (coverApprox c_pos h fh (j + 1) : Z → ℝ) := by +private lemma chainApprox_succ (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) + (fh : ι) (j : ℕ) : chainApprox c_pos h fh (j + 1) = (coverApprox c_pos h fh (j + 1) : Z → ℝ) + := by simp [chainApprox] omit [Nonempty ι] in -private lemma chain_decomposition (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) +private lemma chain_decomposition (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (fh : ι) (n : ℕ): - F fh = F fh - chainApprox c_pos h fh n + ∑ j : Fin n, (chainApprox c_pos h fh ((j : ℕ) + 1) - chainApprox c_pos h fh ((j : ℕ))) := by + F fh = F fh - chainApprox c_pos h fh n + ∑ j : Fin n, + (chainApprox c_pos h fh ((j : ℕ) + 1) - chainApprox c_pos h fh ((j : ℕ))) := by induction n with | zero => simp [chainApprox] | succ n hn => @@ -141,7 +152,8 @@ private lemma chain_decomposition (c_pos : 0 < c) (h : TotallyBounded (Set.univ ring_nf omit [Nonempty ι] in -private lemma pointwise_bound_from_empirical_norm (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (i : Fin m) (hm_pos : 0 < m) : +private lemma pointwise_bound_from_empirical_norm (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) + (i : Fin m) (hm_pos : 0 < m) : ∀ (f : ι), |F f (S i)| ≤ √↑m * c := by intro f dsimp [empiricalNorm] at cs @@ -163,7 +175,9 @@ private lemma pointwise_bound_from_empirical_norm (cs : ∀ f : ι, empiricalNor apply mul_le_mul_of_nonneg_left fcs exact le_of_lt hm_sqrt_pos -private lemma chainApprox_pointwise_bound (c_pos : 0 < c) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (i_1 : ℕ) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : +private lemma chainApprox_pointwise_bound (c_pos : 0 < c) (m_pos : 0 < m) + (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (i_1 : ℕ) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : ∀ (i_2 : Fin m) (a : ι), |chainApprox c_pos h a i_1 (S i_2)| ≤ √↑m * c := by dsimp [chainApprox] by_cases h0 : i_1 = 0 @@ -179,8 +193,11 @@ private lemma chainApprox_pointwise_bound (c_pos : 0 < c) (m_pos : 0 < m) (cs : apply cs exact m_pos -private lemma chainApprox_increment_bound (c_pos : 0 < c) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (i_1 : ℕ) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : - ∀ (i_2 : Fin m) (a : ι), |chainApprox c_pos h a (i_1 + 1) (S i_2) - chainApprox c_pos h a (i_1) (S i_2)| ≤ 2 * (√↑m * c) := by +private lemma chainApprox_increment_bound (c_pos : 0 < c) (m_pos : 0 < m) + (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (i_1 : ℕ) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) : + ∀ (i_2 : Fin m) (a : ι), |chainApprox c_pos h a (i_1 + 1) (S i_2) - chainApprox c_pos h a (i_1) + (S i_2)| ≤ 2 * (√↑m * c) := by intro i_2 a calc _ ≤ |chainApprox c_pos h a (i_1 + 1) (S i_2)| + |chainApprox c_pos h a i_1 (S i_2)| := by @@ -195,10 +212,12 @@ private lemma chainApprox_increment_bound (c_pos : 0 < c) (m_pos : 0 < m) (cs : exact cs _ = _ := by ring -theorem splitBound.bddAbove_main_term {c_pos : 0 < c} (cs : ∀ (f : ι), empiricalNorm S (F f) ≤ c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) +theorem splitBound.bddAbove_main_term {c_pos : 0 < c} (cs : ∀ (f : ι), empiricalNorm S (F f) ≤ c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : ¬m = 0) (i : Signs m): - BddAbove (Set.range fun fh ↦ ∑ i_1, ↑↑(i i_1) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1))) := by + BddAbove (Set.range fun fh ↦ ∑ i_1, ↑↑(i i_1) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1))) + := by rw [bddAbove_def] classical refine ⟨m * (2 * (Real.sqrt (m : ℝ) * c)), ?_⟩ @@ -225,21 +244,27 @@ theorem splitBound.bddAbove_main_term {c_pos : 0 < c} (cs : ∀ (f : ι), empiri _ ≤ ∑ i_1, (Real.sqrt (m : ℝ) * c + Real.sqrt (m : ℝ) * c) := by refine Finset.sum_le_sum ?_ intro i_1 _ - have hF : |F fh (S i_1)| ≤ Real.sqrt (m : ℝ) * c := pointwise_bound_from_empirical_norm cs i_1 hmpos fh - have hG : |chainApprox c_pos h fh n (S i_1)| ≤ Real.sqrt (m : ℝ) * c := chainApprox_pointwise_bound c_pos hmpos cs n h i_1 fh - have : |F fh (S i_1)| + |chainApprox c_pos h fh n (S i_1)| ≤ Real.sqrt (m : ℝ) * c + Real.sqrt (m : ℝ) * c := by + have hF : |F fh (S i_1)| ≤ Real.sqrt (m : ℝ) * c + := pointwise_bound_from_empirical_norm cs i_1 hmpos fh + have hG : |chainApprox c_pos h fh n (S i_1)| ≤ Real.sqrt (m : ℝ) * c + := chainApprox_pointwise_bound c_pos hmpos cs n h i_1 fh + have : |F fh (S i_1)| + |chainApprox c_pos h fh n (S i_1)| ≤ Real.sqrt (m : ℝ) * c + + Real.sqrt (m : ℝ) * c := by nlinarith exact this _ = m * (2 * (Real.sqrt (m : ℝ) * c)) := by simp grind -theorem splitBound.bddAbove_increment_term {c_pos : 0 < c} (cs : ∀ (f : ι), empiricalNorm S (F f) ≤ c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) +theorem splitBound.bddAbove_increment_term {c_pos : 0 < c} + (cs : ∀ (f : ι), empiricalNorm S (F f) ≤ c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : ¬m = 0) (i : Signs m) : BddAbove (Set.range fun fh ↦ - ∑ x_1 : Fin n, ∑ i_1, ↑↑(i i_1) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1))) := by + ∑ x_1 : Fin n, ∑ i_1, ↑↑(i i_1) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - + chainApprox c_pos h fh (↑x_1) (S i_1))) := by rw [bddAbove_def] classical refine ⟨(n : ℝ) * m * (2 * (Real.sqrt (m : ℝ) * c)), ?_⟩ @@ -247,14 +272,17 @@ theorem splitBound.bddAbove_increment_term {c_pos : 0 < c} (cs : ∀ (f : ι), e rcases hy with ⟨fh, rfl⟩ have hmpos : 0 < m := Nat.pos_of_ne_zero m_pos calc - (∑ x_1 : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1))) - ≤ ∑ x_1 : Fin n, ∑ i_1, |(i i_1 : ℝ) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1))| := by + (∑ x_1 : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - + chainApprox c_pos h fh (↑x_1) (S i_1))) + ≤ ∑ x_1 : Fin n, ∑ i_1, |(i i_1 : ℝ) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - + chainApprox c_pos h fh (↑x_1) (S i_1))| := by refine Finset.sum_le_sum ?_ intro _ _ refine Finset.sum_le_sum ?_ intro _ _ exact le_abs_self _ - _ = ∑ x_1 : Fin n, ∑ i_1, |chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1)| := by + _ = ∑ x_1 : Fin n, ∑ i_1, |chainApprox c_pos h fh (↑x_1 + 1) + (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1)| := by apply Finset.sum_congr rfl intro _ _ apply Finset.sum_congr rfl @@ -269,19 +297,23 @@ theorem splitBound.bddAbove_increment_term {c_pos : 0 < c} (cs : ∀ (f : ι), e intro x_1 _ refine Finset.sum_le_sum ?_ intro i_1 _ - have hdiff : |chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1)| ≤ 2 * (Real.sqrt (m : ℝ) * c) := + have hdiff : |chainApprox c_pos h fh (↑x_1 + 1) + (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1)| ≤ 2 * (Real.sqrt (m : ℝ) * c) := chainApprox_increment_bound c_pos hmpos cs (↑x_1) h i_1 fh nlinarith _ = (n : ℝ) * m * (2 * (Real.sqrt (m : ℝ) * c)) := by simp [Finset.sum_const, Finset.card_univ, mul_assoc, mul_left_comm, mul_comm] -- Split the target into the main term and the increment term. -private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) : +private lemma split_main_and_increment_terms {c_pos : 0 < c} + (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) : empiricalRademacherComplexity_without_abs m F S ≤ ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * ((F fh (S i)) - chainApprox c_pos h fh n (S i)))) + ∑ j : Fin n, ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - chainApprox c_pos h fh j (S i)))) := by + (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - + chainApprox c_pos h fh j (S i)))) := by by_cases m_pos : m = 0 · simp [m_pos] subst m_pos @@ -303,7 +335,8 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e ring _ = (m : ℝ)⁻¹ * (signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * (((F fh) (S i) - chainApprox c_pos h fh n (S i)) + - (∑ j : Fin n, (chainApprox c_pos h fh ((j : ℕ) + 1) (S i) - chainApprox c_pos h fh ((j : ℕ)) (S i)))))) := by + (∑ j : Fin n, (chainApprox c_pos h fh ((j : ℕ) + 1) (S i) - + chainApprox c_pos h fh ((j : ℕ)) (S i)))))) := by repeat apply congrArg ext σ repeat apply congrArg @@ -319,32 +352,49 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e _ ≤ (m : ℝ)⁻¹ * ((signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * ((F fh) (S i) - chainApprox c_pos h fh n (S i)))) + signs_card_inv m * ∑ j : Fin n, (∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - chainApprox c_pos h fh j (S i))))) := by + (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - + chainApprox c_pos h fh j (S i))))) := by rw [<- left_distrib] rw [Finset.sum_comm] apply mul_le_mul_of_nonneg_left · apply mul_le_mul_of_nonneg_left - · have w : (∑ σ : Signs m, ⨆ fh, ∑ i, (σ i : ℝ) * (F fh (S i) - chainApprox c_pos h fh n (S i))) + ∑ y : Signs m, ∑ x : Fin n, ⨆ fh, ∑ i,(y i : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)) - = ∑ σ : Signs m, ((⨆ fh, ∑ i, (σ i : ℝ) * (F fh (S i) - chainApprox c_pos h fh n (S i))) + (∑ x : Fin n, ⨆ fh, ∑ i, (σ i : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)))) := by - let chainApprox_increment_bound (σ : Signs m) := ⨆ fh, ∑ i, (σ i : ℝ) * (F fh (S i) - chainApprox c_pos h fh n (S i)) - let chainApprox_pointwise_bound (y : Signs m) := ∑ x : Fin n, ⨆ fh, ∑ i,(y i : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)) - have w' : ∑ σ : Signs m, chainApprox_increment_bound σ + ∑ y : Signs m, chainApprox_pointwise_bound y = ∑ σ : Signs m, (chainApprox_increment_bound σ + chainApprox_pointwise_bound σ) := Eq.symm Finset.sum_add_distrib + · have w : (∑ σ : Signs m, ⨆ fh, ∑ i, (σ i : ℝ) * + (F fh (S i) - chainApprox c_pos h fh n (S i))) + + ∑ y : Signs m, ∑ x : Fin n, ⨆ fh, ∑ i,(y i : ℝ) * + (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)) + = ∑ σ : Signs m, ((⨆ fh, ∑ i, (σ i : ℝ) * (F fh (S i) - + chainApprox c_pos h fh n (S i))) + (∑ x : Fin n, ⨆ fh, ∑ i, (σ i : ℝ) * + (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)))) + := by + let chainApprox_increment_bound (σ : Signs m) := ⨆ fh, ∑ i, (σ i : ℝ) * + (F fh (S i) - chainApprox c_pos h fh n (S i)) + let chainApprox_pointwise_bound (y : Signs m) := ∑ x : Fin n, ⨆ fh, ∑ i,(y i : ℝ) * + (chainApprox c_pos h fh (↑x + 1) (S i) - chainApprox c_pos h fh (↑x) (S i)) + have w' : ∑ σ : Signs m, chainApprox_increment_bound σ + + ∑ y : Signs m, chainApprox_pointwise_bound y = + ∑ σ : Signs m, (chainApprox_increment_bound σ + chainApprox_pointwise_bound σ) + := Eq.symm Finset.sum_add_distrib dsimp [chainApprox_increment_bound, chainApprox_pointwise_bound] at w' exact w' rw [w] apply Finset.sum_le_sum intro i hi - have q : ⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1) + ∑ j : Fin n, (chainApprox c_pos h fh ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h fh ((j : ℕ)) (S i_1))) ≤ + have q : ⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1) + + ∑ j : Fin n, (chainApprox c_pos h fh ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h fh ((j : ℕ)) (S i_1))) ≤ (⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1))) + - ⨆ fh, ∑ x : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i_1) - chainApprox c_pos h fh (↑x) (S i_1)) := by + ⨆ fh, ∑ x : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i_1) - + chainApprox c_pos h fh (↑x) (S i_1)) := by apply ciSup_le intro x -- split the inner sum into a constant part and the telescoping part have hx_split : (∑ i_1, (i i_1 : ℝ) * (F x (S i_1) - chainApprox c_pos h x n (S i_1) + - ∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) + ∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)))) = (∑ i_1, (i i_1 : ℝ) * (F x (S i_1) - chainApprox c_pos h x n (S i_1))) + - (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) := by + (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)))) := by -- distribute the product over the inner addition and split the outer sum simp [mul_add, Finset.sum_add_distrib] -- bound each part by the respective suprema @@ -352,30 +402,46 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e ⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1)) := by apply le_ciSup_of_le · exact splitBound.bddAbove_main_term cs h n m_pos i - · exact Preorder.le_refl (∑ i_1, ↑↑(i i_1) * (F x (S i_1) - chainApprox c_pos h x n (S i_1))) + · exact Preorder.le_refl (∑ i_1, ↑↑(i i_1) * + (F x (S i_1) - chainApprox c_pos h x n (S i_1))) calc - (∑ i_1, (i i_1 : ℝ) * (F x (S i_1) - chainApprox c_pos h x n (S i_1) + ∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) + (∑ i_1, (i i_1 : ℝ) * (F x (S i_1) - chainApprox c_pos h x n (S i_1) + + ∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)))) = _ := hx_split _ ≤ (⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1))) + - (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) := by + (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)))) := by nlinarith _ ≤ (⨆ fh, ∑ i_1, (i i_1 : ℝ) * (F fh (S i_1) - chainApprox c_pos h fh n (S i_1))) + - (⨆ fh, ∑ x : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x + 1) (S i_1) - chainApprox c_pos h fh (↑x) (S i_1))) := by + (⨆ fh, ∑ x : Fin n, ∑ i_1, (i i_1 : ℝ) * + (chainApprox c_pos h fh (↑x + 1) (S i_1) - + chainApprox c_pos h fh (↑x) (S i_1))) := by -- rewrite the second sum as a double sum and take fh = x in the supremum have hx2_swap : - (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) - = ∑ j : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)) := by + (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) + = ∑ j : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h x ((j : ℕ) + + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)) := by -- expand the outer product into an inner sum and then swap the summations - have h_expand : (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)))) - = ∑ i_1, ∑ j : Fin n, (i i_1 : ℝ) * (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1)) := by + have h_expand : (∑ i_1, (i i_1 : ℝ) * (∑ j : Fin n, + (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)))) + = ∑ i_1, ∑ j : Fin n, (i i_1 : ℝ) * + (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1)) := by apply Finset.sum_congr rfl intro i1 hi1 -- move the scalar inside the inner sum rw [Finset.mul_sum] rw [h_expand] rw [Finset.sum_comm] - have hx2 : (∑ j : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - chainApprox c_pos h x ((j : ℕ)) (S i_1))) ≤ - ⨆ fh, ∑ x_1 : Fin n, ∑ i_1, (i i_1 : ℝ) * (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - chainApprox c_pos h fh (↑x_1) (S i_1)) := by + have hx2 : (∑ j : Fin n, ∑ i_1, (i i_1 : ℝ) * + (chainApprox c_pos h x ((j : ℕ) + 1) (S i_1) - + chainApprox c_pos h x ((j : ℕ)) (S i_1))) ≤ + ⨆ fh, ∑ x_1 : Fin n, ∑ i_1, (i i_1 : ℝ) * + (chainApprox c_pos h fh (↑x_1 + 1) (S i_1) - + chainApprox c_pos h fh (↑x_1) (S i_1)) := by apply le_ciSup_of_le · exact splitBound.bddAbove_increment_term cs h n m_pos i · apply Preorder.le_refl @@ -395,7 +461,10 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e simp intro a calc - _ ≤ ∑ i_2, |(i i_2 : ℝ) * (chainApprox c_pos h a (↑i_1 + 1) (S i_2) - chainApprox c_pos h a (↑i_1) (S i_2))| := Finset.sum_le_sum (fun i_2 hi_2 ↦ le_abs_self ((i i_2 : ℝ) * (chainApprox c_pos h a (↑i_1 + 1) (S i_2) - chainApprox c_pos h a (↑i_1) (S i_2)))) + _ ≤ ∑ i_2, |(i i_2 : ℝ) * (chainApprox c_pos h a (↑i_1 + 1) (S i_2) - + chainApprox c_pos h a (↑i_1) (S i_2))| + := Finset.sum_le_sum (fun i_2 hi_2 ↦ le_abs_self ((i i_2 : ℝ) * + (chainApprox c_pos h a (↑i_1 + 1) (S i_2) - chainApprox c_pos h a (↑i_1) (S i_2)))) _ ≤ ∑ i_2 : Fin m, 2 * (√↑m * c) := by apply Finset.sum_le_sum intro i_2 hi_2 @@ -406,7 +475,9 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e · apply Nat.pos_of_ne_zero m_pos · exact cs _ = _ := by simp - · change ∑ i_1_1, (i i_1_1 : ℝ) * (chainApprox c_pos h x' (↑i_1 + 1) (S i_1_1) - chainApprox c_pos h x' (↑i_1) (S i_1_1)) ≤ ∑ i_2, (i i_2 : ℝ) * (chainApprox c_pos h x' (↑i_1 + 1) (S i_2) - chainApprox c_pos h x' (↑i_1) (S i_2)) + · change ∑ i_1_1, (i i_1_1 : ℝ) * (chainApprox c_pos h x' (↑i_1 + 1) (S i_1_1) - + chainApprox c_pos h x' (↑i_1) (S i_1_1)) ≤ ∑ i_2, (i i_2 : ℝ) * + (chainApprox c_pos h x' (↑i_1 + 1) (S i_2) - chainApprox c_pos h x' (↑i_1) (S i_2)) simp · dsimp [signs_card_inv] simp @@ -414,14 +485,16 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e _ = (m : ℝ)⁻¹ * ((signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * ((F fh) (S i) - chainApprox c_pos h fh n (S i)))) + ∑ j : Fin n, ( signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - chainApprox c_pos h fh j (S i))))) := by + (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - + chainApprox c_pos h fh j (S i))))) := by simp left simp [Finset.mul_sum] _ = ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * ((F fh) (S i) - chainApprox c_pos h fh n (S i)))) + (m : ℝ)⁻¹ * ∑ j : Fin n, ( signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - chainApprox c_pos h fh j (S i)))) := by + (∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h fh (j+1) (S i) - + chainApprox c_pos h fh j (S i)))) := by rw [mul_add] rw [mul_assoc] _ = _ := by @@ -429,7 +502,8 @@ private lemma split_main_and_increment_terms {c_pos : 0 < c} (cs : ∀ f : ι, e simp [Finset.mul_sum, mul_assoc] omit [Nonempty ι] in -private lemma empiricalDist_to_chainApprox_le_ej (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (fh : ι) (n : ℕ) +private lemma empiricalDist_to_chainApprox_le_ej (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (fh : ι) (n : ℕ) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : empiricalDist S (F fh) (chainApprox c_pos h fh n) ≤ c / 2 ^ n := by by_cases h' : n = 0 @@ -440,14 +514,17 @@ private lemma empiricalDist_to_chainApprox_le_ej (c_pos : 0 < c) (h : TotallyBou private lemma signed_sum_le_empiricalDist (f g : Z → ℝ) (σ : Signs m) : ∑ i : Fin m, (σ i : ℝ) * (f (S i) - g (S i)) ≤ m * empiricalDist S f g := by calc - _ = @inner ℝ (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ)) (WithLp.toLp 2 fun i ↦ f (S i) - g (S i)) := by + _ = @inner ℝ (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ)) + (WithLp.toLp 2 fun i ↦ f (S i) - g (S i)) := by simp [inner] congr ext _ rw [mul_comm] -- Use Cauchy-Schwarz inequality - _ ≤ (@norm (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ))) * (@norm (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ f (S i) - g (S i))) := - @real_inner_le_norm (EuclideanSpace ℝ (Fin m)) _ _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ)) (WithLp.toLp 2 fun i ↦ f (S i) - g (S i)) + _ ≤ (@norm (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ))) * + (@norm (EuclideanSpace ℝ (Fin m)) _ (WithLp.toLp 2 fun i ↦ f (S i) - g (S i))) := + @real_inner_le_norm (EuclideanSpace ℝ (Fin m)) _ _ (WithLp.toLp 2 fun i ↦ (σ i : ℝ)) + (WithLp.toLp 2 fun i ↦ f (S i) - g (S i)) _ = m * empiricalDist S f g := by simp [norm, empiricalNorm, EmpiricalProcess.empiricalNorm] have : (∑ i, (σ i : ℝ) ^ 2) = m := by @@ -472,9 +549,11 @@ private lemma signed_sum_le_empiricalDist (f g : Z → ℝ) (σ : Signs m) : -- Part A omit [Nonempty ι] in -private lemma partA_sup_bound (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) +private lemma partA_sup_bound (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (n : ℕ) : ∀ (σ : Signs m) (fh : ι), - ((∑ i : Fin m, (σ i : ℝ) * ((F fh) (S i) - chainApprox c_pos h fh n (S i))) ≤ (m : ℝ) * (ej c n)) := by + ((∑ i : Fin m, (σ i : ℝ) * ((F fh) (S i) - chainApprox c_pos h fh n (S i))) ≤ (m : ℝ) * (ej c n)) + := by intro σ fh unfold ej apply le_trans (signed_sum_le_empiricalDist (F fh) (chainApprox c_pos h fh n) σ) @@ -483,13 +562,16 @@ private lemma partA_sup_bound (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Se -- Part B (uses Massart's finite-class bound) -- We compare increments via the paired class: -- {(p_j(f), p_{j-1}(f)) | f ∈ F}. -private noncomputable def incrementSet (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def incrementSet (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := {chainApprox c_pos h fh (j + 1) - chainApprox c_pos h fh j | fh : ι} -private noncomputable def incrementPairSet (c_pos : 0 < c) (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def incrementPairSet (c_pos : 0 < c) + (h : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := {(chainApprox c_pos h fh (j + 1), chainApprox c_pos h fh j) | fh : ι} -private lemma finite_chainApprox_image (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma finite_chainApprox_image (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : {chainApprox c_pos h' fh j | fh : ι}.Finite := by dsimp [chainApprox] by_cases h : (j : ℕ) = 0 @@ -511,43 +593,54 @@ private lemma finite_chainApprox_image (c_pos : 0 < c) (h' : TotallyBounded (Set exact hmem · exact hpr -private noncomputable def nextApproxSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := +private noncomputable def nextApproxSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := {chainApprox c_pos h' fh (j + 1) | fh : ι} -private noncomputable def currApproxSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := +private noncomputable def currApproxSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := {chainApprox c_pos h' fh j | fh : ι} -private noncomputable def approxPairSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := +private noncomputable def approxPairSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := (nextApproxSet c_pos h' n j) ×ˢ (currApproxSet c_pos h' n j) -private lemma finite_nextApproxSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma finite_nextApproxSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (nextApproxSet c_pos h' n j).Finite := finite_chainApprox_image c_pos h' (n+1) ⟨j + 1, by simp⟩ -private lemma finite_currApproxSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma finite_currApproxSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (currApproxSet c_pos h' n j).Finite := finite_chainApprox_image c_pos h' n j -private lemma finite_approxPairSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : - ((nextApproxSet c_pos h' n j) ×ˢ (currApproxSet c_pos h' n j)).Finite := (finite_nextApproxSet c_pos h' n j).prod (finite_currApproxSet c_pos h' n j) +private lemma finite_approxPairSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : + ((nextApproxSet c_pos h' n j) ×ˢ (currApproxSet c_pos h' n j)).Finite + := (finite_nextApproxSet c_pos h' n j).prod (finite_currApproxSet c_pos h' n j) omit [Nonempty ι] in -private lemma incrementPairSet_subset_approxPairSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma incrementPairSet_subset_approxPairSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementPairSet c_pos h' n j) ⊆ (approxPairSet c_pos h' n j) := by intro f hf obtain ⟨f0, hg⟩ := hf rw [<- hg] refine Set.mk_mem_prod (by use f0) (by use f0) -private lemma finite_incrementPairSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma finite_incrementPairSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementPairSet c_pos h' n j).Finite := by unfold incrementPairSet refine (finite_approxPairSet c_pos h' n j).subset ?_ apply incrementPairSet_subset_approxPairSet -private lemma finite_incrementSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma finite_incrementSet (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementSet c_pos h' n j).Finite := by unfold incrementSet let f : (Z → ℝ) × (Z → ℝ) → (Z → ℝ) := fun p => p.1 - p.2 - have : {chainApprox c_pos h' fh (j + 1) - chainApprox c_pos h' fh j | fh : ι} = f '' incrementPairSet c_pos h' n j := by + have : {chainApprox c_pos h' fh (j + 1) - chainApprox c_pos h' fh j | fh : ι} = + f '' incrementPairSet c_pos h' n j := by ext x simp [incrementPairSet] constructor @@ -558,34 +651,42 @@ private lemma finite_incrementSet (c_pos : 0 < c) (h' : TotallyBounded (Set.univ rw [this] exact (finite_incrementPairSet c_pos h' n j).image f -private noncomputable def nextApproxFinset (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def nextApproxFinset (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := Set.Finite.toFinset (finite_nextApproxSet c_pos h' n j) -private noncomputable def currApproxFinset (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def currApproxFinset (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := Set.Finite.toFinset (finite_currApproxSet c_pos h' n j) -private noncomputable def incrementFinset (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def incrementFinset (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := Set.Finite.toFinset (finite_incrementSet c_pos h' n j) -private noncomputable def incrementPairFinset (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def incrementPairFinset (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := Set.Finite.toFinset (finite_incrementPairSet c_pos h' n j) -private noncomputable def approxPairFinset (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) +private noncomputable def approxPairFinset (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) := Set.Finite.toFinset (finite_approxPairSet c_pos h' n j) -private lemma incrementFinset_nonempty (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma incrementFinset_nonempty (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementFinset c_pos h' n j).Nonempty := by dsimp [incrementFinset] simp only [Set.Finite.toFinset_nonempty] exact ⟨_, ⟨Classical.arbitrary ι, rfl⟩⟩ -private lemma incrementPairFinset_nonempty (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma incrementPairFinset_nonempty (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementPairFinset c_pos h' n j).Nonempty := by dsimp [incrementPairFinset] simp only [Set.Finite.toFinset_nonempty] exact ⟨_, ⟨Classical.arbitrary ι, rfl⟩⟩ -private lemma incrementFinset_card_le_incrementPairFinset_card (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma incrementFinset_card_le_incrementPairFinset_card (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementFinset c_pos h' n j).card ≤ (incrementPairFinset c_pos h' n j).card := by unfold incrementFinset incrementPairFinset let f : (Z → ℝ) × (Z → ℝ) → (Z → ℝ) := fun p => p.1 - p.2 @@ -598,15 +699,18 @@ private lemma incrementFinset_card_le_incrementPairFinset_card (c_pos : 0 < c) ( refine ⟨_, _, ?_, rfl⟩ exact ⟨fh, rfl⟩ -private lemma incrementPairFinset_card_le_approxPairFinset_card (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma incrementPairFinset_card_le_approxPairFinset_card (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (incrementPairFinset c_pos h' n j).card ≤ (approxPairFinset c_pos h' n j).card := by unfold incrementPairFinset approxPairFinset refine Finset.card_le_card ?_ refine Set.Finite.toFinset_subset_toFinset.mpr ?_ apply incrementPairSet_subset_approxPairSet -private lemma approxPairFinset_card_eq_product (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : - (approxPairFinset c_pos h' n j).card = (nextApproxFinset c_pos h' n j).card * (currApproxFinset c_pos h' n j).card := by +private lemma approxPairFinset_card_eq_product (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : + (approxPairFinset c_pos h' n j).card = (nextApproxFinset c_pos h' n j).card * + (currApproxFinset c_pos h' n j).card := by rw [<- Finset.card_product] refine Finset.card_eq_of_equiv ?_ simp @@ -614,15 +718,18 @@ private lemma approxPairFinset_card_eq_product (c_pos : 0 < c) (h' : TotallyBoun simp exact Equiv.refl _ -private lemma nextApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : +private lemma nextApproxFinset_card_le_cover_card (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) : (nextApproxFinset c_pos h' n j).card ≤ (cj c_pos h' ((j : ℕ) + 1)).card := by - -- expand `nextApproxFinset`: it is the finset of functions of the form `chainApprox c_pos h' fh (j+1)` + -- expand `nextApproxFinset`: it is the finset of functions of the form `chainApprox c_pos h' fh + -- (j+1)` -- coming from the cover at scale `j+1`. dsimp [nextApproxFinset] classical -- image of the cover under coercion to functions -- coerce elements of the cover to functions before taking the image - let T : Finset (Z → ℝ) := (cj c_pos h' ((j : ℕ) + 1)).image (fun q : EmpiricalFunctionSpace F S => (q : Z → ℝ)) + let T : Finset (Z → ℝ) := (cj c_pos h' ((j : ℕ) + 1)).image (fun q : EmpiricalFunctionSpace F S => + (q : Z → ℝ)) -- every element of `nextApproxFinset` comes from this image via `coverApprox_mem_cover` have hsubset : Set.Finite.toFinset (finite_nextApproxSet c_pos h' n j) ⊆ T := by intro x hx @@ -630,7 +737,8 @@ private lemma nextApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyB simpa [nextApproxFinset] using hx rcases hxA with ⟨fh, rfl⟩ -- rewrite chainApprox at successor - have hG : chainApprox c_pos h' fh ((j : ℕ) + 1) = (coverApprox c_pos h' fh ((j : ℕ) + 1) : Z → ℝ) := by + have hG : chainApprox c_pos h' fh ((j : ℕ) + 1) = + (coverApprox c_pos h' fh ((j : ℕ) + 1) : Z → ℝ) := by simp [chainApprox_succ] -- show the corresponding `coverApprox` lies in the cover have hmem : coverApprox c_pos h' fh ((j : ℕ) + 1) ∈ cj c_pos h' ((j : ℕ) + 1) := by @@ -648,16 +756,22 @@ private lemma nextApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyB have hT_le : T.card ≤ (cj c_pos h' ((j : ℕ) + 1)).card := Finset.card_image_le exact hcard_le_T.trans hT_le -private lemma currApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) (n_pos : 0 < n) : +private lemma currApproxFinset_card_le_cover_card (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) + (j : Fin n) (n_pos : 0 < n) : (currApproxFinset c_pos h' n j).card ≤ (cj c_pos h' (j : ℕ)).card := by - -- expand `currApproxFinset`: functions of the form `chainApprox … fh j` live in the cover at scale `j` + -- expand `currApproxFinset`: functions of the form `chainApprox … fh j` live in the cover at + -- scale `j` dsimp [currApproxFinset] classical -- image of the cover under coercion to functions - let T : Finset (Z → ℝ) := (cj c_pos h' ((j : ℕ))).image (fun q : EmpiricalFunctionSpace F S => (q : Z → ℝ)) - -- every element of `currApproxFinset` comes from this image via `coverApprox_mem_cover`, with a small case split on `(j : ℕ) = 0` + let T : Finset (Z → ℝ) := (cj c_pos h' ((j : ℕ))).image (fun q : EmpiricalFunctionSpace F S => + (q : Z → ℝ)) + -- every element of `currApproxFinset` comes from this image via `coverApprox_mem_cover`, with a + -- small case split on `(j : ℕ) = 0` by_cases hzero : ((j : ℕ)) = 0 - · -- when j = 0, chainApprox = 0 so currApproxFinset has card 1 ≤ card of the cover (nonempty via coverApprox_mem_cover) + · -- when j = 0, chainApprox = 0 so currApproxFinset has card 1 ≤ card of the cover + -- (nonempty via coverApprox_mem_cover) rw [hzero] -- currApproxFinset card is 1 have hKB : (currApproxFinset c_pos h' n ⟨0, by @@ -686,7 +800,8 @@ private lemma currApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyB have hBcard : (Set.Finite.toFinset (finite_currApproxSet c_pos h' n ⟨0, n_pos⟩)).card = 1 := by -- currApproxFinset is exactly this toFinset simpa [currApproxFinset] using hKB - have : (Set.Finite.toFinset (finite_currApproxSet c_pos h' n ⟨0, n_pos⟩)).card ≤ (cj c_pos h' 0).card := by + have : (Set.Finite.toFinset (finite_currApproxSet c_pos h' n ⟨0, n_pos⟩)).card ≤ + (cj c_pos h' 0).card := by -- rewrite the left card to 1 and use the cover-card lower bound simpa [hBcard] using hcover_card exact this @@ -695,12 +810,14 @@ private lemma currApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyB intro x hx have hxB : x ∈ currApproxSet c_pos h' n j := by simpa [currApproxFinset] using hx rcases hxB with ⟨fh, rfl⟩ - have hG : chainApprox c_pos h' fh ((j : ℕ)) = (coverApprox c_pos h' fh ((j : ℕ)) : Z → ℝ) := by + have hG : chainApprox c_pos h' fh ((j : ℕ)) = (coverApprox c_pos h' fh ((j : ℕ)) : Z → ℝ) + := by have : ∃ k, (j : ℕ) = k + 1 := Nat.exists_eq_succ_of_ne_zero hzero rcases this with ⟨k, hk⟩ rw [hk] simp [chainApprox_succ] - have hmem : coverApprox c_pos h' fh ((j : ℕ)) ∈ cj c_pos h' ((j : ℕ)) := coverApprox_mem_cover c_pos h' fh ((j : ℕ)) + have hmem : coverApprox c_pos h' fh ((j : ℕ)) ∈ cj c_pos h' ((j : ℕ)) + := coverApprox_mem_cover c_pos h' fh ((j : ℕ)) have hQmem : (coverApprox c_pos h' fh ((j : ℕ)) : Z → ℝ) ∈ T := by dsimp [T] refine Finset.mem_image.mpr ?_ @@ -711,7 +828,9 @@ private lemma currApproxFinset_card_le_cover_card (c_pos : 0 < c) (h' : TotallyB have hT_le : T.card ≤ (cj c_pos h' ((j : ℕ))).card := Finset.card_image_le exact hcard_le_T.trans hT_le -private lemma incrementPairFinset_card_le_cover_product_card (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) (n_pos : 0 < n): +private lemma incrementPairFinset_card_le_cover_product_card (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) + (n_pos : 0 < n): (incrementPairFinset c_pos h' n j).card ≤ (cj c_pos h' (j+1)).card * (cj c_pos h' j).card := by calc _ ≤ (approxPairFinset c_pos h' n j).card := by @@ -727,31 +846,42 @@ private lemma incrementPairFinset_card_le_cover_product_card (c_pos : 0 < c) (h' simp omit [Nonempty ι] in -private lemma chainApprox_increment_signed_sum_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (j : ℕ) +private lemma chainApprox_increment_signed_sum_bound (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (j : ℕ) (σ : Signs m) (fh : ι) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : - ∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h' fh (j + 1) - chainApprox c_pos h' fh j) (S i) ≤ m * (c / 2 ^ (j+1) + c / 2 ^ j) := by + ∑ i : Fin m, (σ i : ℝ) * (chainApprox c_pos h' fh (j + 1) - chainApprox c_pos h' fh j) + (S i) ≤ m * (c / 2 ^ (j+1) + c / 2 ^ j) := by calc _ ≤ m * empiricalDist S (chainApprox c_pos h' fh (j + 1)) (chainApprox c_pos h' fh j) := by - apply signed_sum_le_empiricalDist (chainApprox c_pos h' fh (j + 1)) (chainApprox c_pos h' fh j) σ + apply signed_sum_le_empiricalDist (chainApprox c_pos h' fh (j + 1)) + (chainApprox c_pos h' fh j) σ _ ≤ _ := by apply mul_le_mul_of_nonneg_left _ (by simp) calc - _ ≤ empiricalDist S (chainApprox c_pos h' fh (j + 1)) (F fh) + empiricalDist S (F fh) (chainApprox c_pos h' fh j) := by - apply @dist_triangle _ (empiricalPMet S) (chainApprox c_pos h' fh (j + 1)) (F fh) (chainApprox c_pos h' fh j) + _ ≤ empiricalDist S (chainApprox c_pos h' fh (j + 1)) (F fh) + empiricalDist S (F fh) + (chainApprox c_pos h' fh j) := by + apply @dist_triangle _ (empiricalPMet S) (chainApprox c_pos h' fh (j + 1)) (F fh) + (chainApprox c_pos h' fh j) _ ≤ _ := by rw [←empiricalDist_comm S (F fh) (chainApprox c_pos h' fh (j+1))] apply add_le_add · exact empiricalDist_to_chainApprox_le_ej c_pos h' fh (j+1) cs · exact empiricalDist_to_chainApprox_le_ej c_pos h' fh j cs -private lemma massart_bound_for_increment_term (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) (m_pos : 0 < m) +private lemma massart_bound_for_increment_term (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) + (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, (∑ i : Fin m, (σ i : ℝ) * ((chainApprox c_pos h' fh (j+1) - chainApprox c_pos h' fh j) (S i)))) - ≤ ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ √(∑ i, (|j (S i)|) ^ 2)) * (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m := by - let C := ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ √(∑ i, (|j (S i)|) ^ 2)) + ≤ ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ + √(∑ i, (|j (S i)|) ^ 2)) * + (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m := by + let C := ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ + √(∑ i, (|j (S i)|) ^ 2)) calc - _ = ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ (fh : {x // x ∈ incrementFinset c_pos h' n j}), + _ = ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ (fh : {x // x ∈ + incrementFinset c_pos h' n j}), (∑ i : Fin m, (σ i : ℝ) * (fh.val (S i)))) := by congr ext σ @@ -805,13 +935,15 @@ private lemma massart_bound_for_increment_term (c_pos : 0 < c) (h' : TotallyBoun apply Real.mul_iSup_of_nonneg apply inv_nonneg_of_nonneg exact Nat.cast_nonneg' m - _ = empiricalRademacherComplexity_pmf_without_abs m (F_on (ι:=(Z → ℝ)) (Z:=Z) (fun hk : Z → ℝ => hk) (incrementFinset c_pos h' n j)) S := by + _ = empiricalRademacherComplexity_pmf_without_abs m (F_on (ι:=(Z → ℝ)) (Z:=Z) (fun hk : Z → ℝ => + hk) (incrementFinset c_pos h' n j)) S := by simp only [empiricalRademacherComplexity_pmf_without_abs, signVecPMF, Signs.card, Nat.cast_pow, Nat.cast_ofNat, Int.reduceNeg, Finset.mul_sum, PMF.integral_eq_sum, PMF.uniformOfFintype_apply, ENNReal.toReal_inv, ENNReal.toReal_pow, ENNReal.toReal_ofNat, smul_eq_mul, signs_card_inv] rfl - _ ≤ C * (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m := by + _ ≤ C * (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m + := by apply le_of_le_of_eq · apply massart_lemma_pmf (C := C) · exact incrementFinset_nonempty c_pos h' n j @@ -838,7 +970,8 @@ private lemma massart_bound_for_increment_term (c_pos : 0 < c) (h' : TotallyBoun have : Real.sqrt (i (S j) ^ 2) ≤ Real.sqrt (∑ x : Fin m, i (S x) ^ 2) := by exact Real.sqrt_le_sqrt hsq simpa [Real.sqrt_sq_eq_abs] using this - · have : √(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card)) = √(2 * Real.log ↑(incrementFinset c_pos h' n j).card) := by + · have : √(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card)) = + √(2 * Real.log ↑(incrementFinset c_pos h' n j).card) := by apply congrArg apply congrArg apply congrArg @@ -855,26 +988,38 @@ private lemma massart_bound_for_increment_term (c_pos : 0 < c) (h' : TotallyBoun simp only [sq_abs, Nat.cast_nonneg, pow_succ_nonneg, Real.sqrt_div', Real.sqrt_sq] field_simp -theorem partB.mem_incrementPairFinset_repr (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) +theorem partB.mem_incrementPairFinset_repr (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (j : Fin n) (hk : (Z → ℝ) × (Z → ℝ)) - (hk0 : hk ∈ incrementPairFinset c_pos h' n j) : ∃ fh, (chainApprox c_pos h' fh ((j : ℕ) + 1), chainApprox c_pos h' fh (j : ℕ)) = hk := by + (hk0 : hk ∈ incrementPairFinset c_pos h' n j) : ∃ fh, (chainApprox c_pos h' fh ((j : ℕ) + 1), + chainApprox c_pos h' fh (j : ℕ)) = hk := by dsimp [incrementPairFinset] at hk0 simp at hk0 dsimp [incrementPairSet] at hk0 exact hk0 -private lemma partB_sum_bound_via_massart (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) +private lemma partB_sum_bound_via_massart (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (n_pos : 0 < n): ∑ j : Fin n, ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * ((chainApprox c_pos h' fh (j+1) - chainApprox c_pos h' fh j) (S i)))) ≤ - ∑ j : Fin n, (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) * (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) / ↑m := by + (∑ i : Fin m, (σ i : ℝ) * ((chainApprox c_pos h' fh (j+1) - + chainApprox c_pos h' fh j) (S i)))) ≤ + ∑ j : Fin n, + (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) + fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) * + (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) / ↑m := by -- It suffices to prove the bound term-by-term in the finite sum over j. apply Finset.sum_le_sum intro j hj -- Replace the supremum over f with a finite supremum over the paired class. calc - _ ≤ ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ √(∑ i, (|j (S i)|) ^ 2)) * (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m := massart_bound_for_increment_term c_pos h' n j m_pos cs - _ ≤ ((Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i) ) ^ 2)) * (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card)))) / m := by + _ ≤ ((incrementFinset c_pos h' n j).sup' (incrementFinset_nonempty c_pos h' n j) fun j ↦ + √(∑ i, (|j (S i)|) ^ 2)) * + (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card))) / m := + massart_bound_for_increment_term c_pos h' n j m_pos cs + _ ≤ ((Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) + fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i) ) ^ 2)) * + (√(2 * Real.log ((Set.Finite.toFinset (finite_incrementSet c_pos h' n j)).card)))) / m := by apply div_le_div_of_nonneg_right _ _ apply mul_le_mul_of_nonneg_right _ _ apply Finset.sup'_le _ _ @@ -882,15 +1027,19 @@ private lemma partB_sum_bound_via_massart (c_pos : 0 < c) (h' : TotallyBounded ( simp only [Set.Finite.mem_toFinset, incrementFinset] at hk0 obtain ⟨fh, hfh⟩ := hk0 rw [<- hfh] - have : √(∑ i, |(chainApprox c_pos h' fh ((j : ℕ) + 1) - chainApprox c_pos h' fh (j : ℕ)) (S i)| ^ 2) = √(∑ i : Fin m, ((chainApprox c_pos h' fh ((j : ℕ) + 1) - chainApprox c_pos h' fh (j : ℕ)) (S i)) ^ 2) := by + have : √(∑ i, |(chainApprox c_pos h' fh ((j : ℕ) + 1) - + chainApprox c_pos h' fh (j : ℕ)) (S i)| ^ 2) = √(∑ i : Fin m, + ((chainApprox c_pos h' fh ((j : ℕ) + 1) - chainApprox c_pos h' fh (j : ℕ)) (S i)) ^ 2) := by congr ext i exact sq_abs _ rw [this] - have : ⟨chainApprox c_pos h' fh ((j : ℕ) + 1), chainApprox c_pos h' fh (j : ℕ)⟩ ∈ incrementPairFinset c_pos h' n j := by + have : ⟨chainApprox c_pos h' fh ((j : ℕ) + 1), chainApprox c_pos h' fh (j : ℕ)⟩ ∈ + incrementPairFinset c_pos h' n j := by simp only [Set.Finite.mem_toFinset, incrementPairFinset, incrementPairSet] use fh - exact Finset.le_sup' (fun hk : (Z → ℝ) × (Z → ℝ) ↦ Real.sqrt (∑ i : Fin m, ((hk.1 - hk.2) (S i) ) ^ 2)) this + exact Finset.le_sup' (fun hk : (Z → ℝ) × (Z → ℝ) ↦ Real.sqrt (∑ i : Fin m, + ((hk.1 - hk.2) (S i) ) ^ 2)) this simp simp _ ≤ _ := by @@ -899,57 +1048,76 @@ private lemma partB_sum_bound_via_massart (c_pos : 0 < c) (h' : TotallyBounded ( · apply Real.sqrt_le_sqrt refine mul_le_mul_of_nonneg_left ?_ (by simp) apply Real.log_le_log - · simp; exact (Set.Finite.toFinset_nonempty (finite_incrementSet c_pos h' n j)).mp (incrementFinset_nonempty c_pos h' n j) + · simp; exact (Set.Finite.toFinset_nonempty (finite_incrementSet c_pos h' n j)).mp + (incrementFinset_nonempty c_pos h' n j) · norm_cast apply (incrementFinset_card_le_incrementPairFinset_card c_pos h' n j).trans simpa only [cj, coveringFinset_card] using (incrementPairFinset_card_le_cover_product_card c_pos h' n j n_pos) · obtain ⟨fh⟩ := (by assumption : Nonempty ι) - have hem : ⟨chainApprox c_pos h' fh (j + 1), chainApprox c_pos h' fh j⟩ ∈ incrementPairFinset c_pos h' n j := by + have hem : ⟨chainApprox c_pos h' fh (j + 1), chainApprox c_pos h' fh j⟩ ∈ + incrementPairFinset c_pos h' n j := by simp only [Set.Finite.mem_toFinset, incrementPairFinset, incrementPairSet] use fh apply le_trans _ (Finset.le_sup' _ hem) apply Real.sqrt_nonneg · simp -private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) +private lemma partB_bound (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : ∑ j : Fin n, ((m : ℝ)⁻¹ * signs_card_inv m * ∑ σ : Signs m, ⨆ fh : ι, - (∑ i : Fin m, (σ i : ℝ) * ((chainApprox c_pos h' fh (j+1) - chainApprox c_pos h' fh j) (S i)))) ≤ - ∑ j : Fin n, 6 * (ej c (j+1) - ej c (j+2)) * (√(4 * Real.log (coveringNumberNat h' (ej c (j+1))))/((Real.sqrt m))) := by + (∑ i : Fin m, (σ i : ℝ) * ((chainApprox c_pos h' fh (j+1) - + chainApprox c_pos h' fh j) (S i)))) ≤ + ∑ j : Fin n, 6 * (ej c (j+1) - ej c (j+2)) * + (√(4 * Real.log (coveringNumberNat h' (ej c (j+1))))/((Real.sqrt m))) := by calc - _ ≤ ∑ j : Fin n, (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) * (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) / ↑m := by + _ ≤ ∑ j : Fin n, + (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) + fun hk ↦ √(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) * + (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) / + ↑m := by by_cases n_pos : 0 < n · exact partB_sum_bound_via_massart c_pos h' n m_pos cs n_pos · simp at n_pos rw [n_pos] simp - _ = ∑ j : Fin n, (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) fun hk ↦ (√(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) / ↑m) * (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) := by + _ = ∑ j : Fin n, + (Finset.sup' (incrementPairFinset c_pos h' n j) (incrementPairFinset_nonempty c_pos h' n j) + fun hk ↦ (√(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2)) / ↑m) * + (√(2 * Real.log (coveringNumberNat h' (ej c (j+1)) * coveringNumberNat h' (ej c j)))) := by apply congrArg ext j rw [<- div_mul_eq_mul_div] rw [Mathlib.Tactic.LinearCombination.mul_eq_const] rw [Finset.sup'_div₀ (ha := by positivity)] - _ ≤ ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))/ Real.sqrt m) * (√(2 * Real.log ((coveringNumberNat h' (ej c (j+1))) * (coveringNumberNat h' (ej c j)))))) := by + _ ≤ ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))/ Real.sqrt m) * + (√(2 * Real.log ((coveringNumberNat h' (ej c (j+1))) * (coveringNumberNat h' (ej c j)))))) + := by refine Finset.sum_le_sum ?_ intro j hj apply mul_le_mul_of_nonneg_right -- The remaining estimate follows from the pair-class representation. - · have r0 (hk : (Z → ℝ) × (Z → ℝ)) (hk0 : hk ∈ incrementPairFinset c_pos h' n j) : ∃ fh, (chainApprox c_pos h' fh (j + 1), chainApprox c_pos h' fh j) = hk := by + · have r0 (hk : (Z → ℝ) × (Z → ℝ)) (hk0 : hk ∈ incrementPairFinset c_pos h' n j) : ∃ fh, + (chainApprox c_pos h' fh (j + 1), chainApprox c_pos h' fh j) = hk := by dsimp [incrementPairFinset] at hk0 simp at hk0 dsimp [incrementPairSet] at hk0 exact hk0 have fh (hk : (Z → ℝ) × (Z → ℝ)) (hk0 : hk ∈ incrementPairFinset c_pos h' n j) : ι := Classical.choose (r0 hk hk0) - suffices ∀ (hk : (Z → ℝ) × (Z → ℝ)) (hk0 : hk ∈ incrementPairFinset c_pos h' n j), (√(∑ i, ((hk.1 - hk.2) (S i)) ^ 2)) / ↑m ≤ 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) / Real.sqrt m from by + suffices ∀ (hk : (Z → ℝ) × (Z → ℝ)) (hk0 : hk ∈ incrementPairFinset c_pos h' n j), + (√(∑ i, ((hk.1 - hk.2) (S i)) ^ 2)) / ↑m ≤ 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) / + Real.sqrt m from by rw [Finset.sup'_le_iff] exact this intro hk hk0 - have hk1 : hk ∈ incrementPairSet c_pos h' n j := by dsimp [incrementPairFinset] at hk0; simp at hk0; exact hk0 + have hk1 : hk ∈ incrementPairSet c_pos h' n j + := by dsimp [incrementPairFinset] at hk0; simp at hk0; exact hk0 dsimp [incrementPairSet] at hk1 obtain ⟨x, fhx⟩ := hk1 - have r : √(∑ i, ((hk.1 - hk.2) (S i)) ^ 2) ≤ √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) := by + have r : √(∑ i, ((hk.1 - hk.2) (S i)) ^ 2) ≤ √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) + + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) := by let ai : EuclideanSpace ℝ (Fin m) := WithLp.toLp 2 fun i ↦ (hk.1 - (F x)) (S i) let aj : EuclideanSpace ℝ (Fin m) := WithLp.toLp 2 fun i ↦ (hk.2 - (F x)) (S i) have norm_calc : ‖ai - aj‖ = √(∑ i : Fin m, ((hk.1 - hk.2) (S i)) ^ 2) := by @@ -972,14 +1140,17 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( · dsimp [aj, norm] simp rw [Real.sqrt_eq_rpow];simp - have r' : √(∑ i, ((hk.1 - hk.2) (S i)) ^ 2) / ↑m ≤ √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) / ↑m + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) / ↑m := by + have r' : √(∑ i, ((hk.1 - hk.2) (S i)) ^ 2) / ↑m ≤ √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) / ↑m + + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) / ↑m := by have : (√(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2)) / ↑m = - √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) / ↑m + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) / ↑m := by + √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2) / ↑m + √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2) / ↑m + := by ring rw [← this] exact div_le_div_of_nonneg_right r (Nat.cast_nonneg m) apply le_trans r' - have rp : 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) / Real.sqrt m = (ej c (j + 1) / Real.sqrt m) + (ej c j / Real.sqrt m) := by + have rp : 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) / Real.sqrt m = + (ej c (j + 1) / Real.sqrt m) + (ej c j / Real.sqrt m) := by suffices 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) = ej c (j + 1) + ej c j from by rw [this] exact add_div (ej c ((j : ℕ) + 1)) (ej c (j : ℕ)) (Real.sqrt m) @@ -1024,7 +1195,8 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( suffices √(∑ i, ((hk.1 - (F x)) (S i)) ^ 2 / ↑m) ≤ ej c (j + 1) from by rw [<- Finset.sum_div] at this simp at this - have u : √(∑ i, (hk.1 - F x) (S i) ^ 2) / ↑m = (√(∑ i, (hk.1 - F x) (S i) ^ 2) / √↑m) / √↑m := by + have u : √(∑ i, (hk.1 - F x) (S i) ^ 2) / ↑m = (√(∑ i, (hk.1 - F x) (S i) ^ 2) / √↑m) / + √↑m := by field_simp congr apply Real.sq_sqrt @@ -1034,14 +1206,16 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( simp have gh : hk.1 = chainApprox c_pos h' x ((j : ℕ) + 1) := by rw [<- fhx] rw [gh] - have : √(∑ i, (chainApprox c_pos h' x ((j : ℕ) + 1) - F x) (S i) ^ 2 / ↑m) = empiricalDist S (F x) (chainApprox c_pos h' x ((j : ℕ) + 1)) := by + have : √(∑ i, (chainApprox c_pos h' x ((j : ℕ) + 1) - F x) (S i) ^ 2 / ↑m) = + empiricalDist S (F x) (chainApprox c_pos h' x ((j : ℕ) + 1)) := by rw [empiricalDist_comm] dsimp [empiricalDist, empiricalNorm] apply congrArg simp [div_eq_mul_inv, mul_comm] exact Eq.symm - (Finset.mul_sum Finset.univ (fun i ↦ (chainApprox c_pos h' x (↑j + 1) (S i) - F x (S i)) ^ 2) + (Finset.mul_sum Finset.univ + (fun i ↦ (chainApprox c_pos h' x (↑j + 1) (S i) - F x (S i)) ^ 2) (↑m)⁻¹) rw [this] dsimp only [ej] @@ -1050,7 +1224,8 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( suffices √(∑ i, ((hk.2 - (F x)) (S i)) ^ 2 / ↑m) ≤ ej c j from by rw [<- Finset.sum_div] at this simp at this - have u : √(∑ i, (hk.2 - F x) (S i) ^ 2) / ↑m = (√(∑ i, (hk.2 - F x) (S i) ^ 2) / √↑m) / √↑m := by + have u : √(∑ i, (hk.2 - F x) (S i) ^ 2) / ↑m = (√(∑ i, (hk.2 - F x) (S i) ^ 2) / √↑m) / + √↑m := by field_simp congr apply Real.sq_sqrt @@ -1061,14 +1236,16 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( have gh : hk.2 = chainApprox c_pos h' x j := by rw [<- fhx] rw [gh] - have : √(∑ i, (chainApprox c_pos h' x j - F x) (S i) ^ 2 / ↑m) = empiricalDist S (F x) (chainApprox c_pos h' x j) := by + have : √(∑ i, (chainApprox c_pos h' x j - F x) (S i) ^ 2 / ↑m) = empiricalDist S (F x) + (chainApprox c_pos h' x j) := by rw [empiricalDist_comm] dsimp [empiricalDist, empiricalNorm] apply congrArg simp [div_eq_mul_inv, mul_comm] exact Eq.symm - (Finset.mul_sum Finset.univ (fun i ↦ (chainApprox c_pos h' x (↑j) (S i) - F x (S i)) ^ 2) + (Finset.mul_sum Finset.univ + (fun i ↦ (chainApprox c_pos h' x (↑j) (S i) - F x (S i)) ^ 2) (↑m)⁻¹) rw [this] dsimp only [ej] @@ -1077,12 +1254,17 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( apply add_le_add r0 r1 · exact Real.sqrt_nonneg - (2 * Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * ↑(coveringNumberNat h' (ej c (j : ℕ))))) - _ = ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))) * (√(2 * Real.log ((coveringNumberNat h' (ej c (j+1))) * (coveringNumberNat h' (ej c j)))))/(Real.sqrt m)) := by + (2 * Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * + ↑(coveringNumberNat h' (ej c (j : ℕ))))) + _ = ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))) * (√(2 * + Real.log ((coveringNumberNat h' (ej c (j+1))) * + (coveringNumberNat h' (ej c j)))))/(Real.sqrt m)) := by apply congrArg ext j field_simp - _ ≤ ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))) * (√(2 * Real.log ((coveringNumberNat h' (ej c (j+1))) * (coveringNumberNat h' (ej c (j+1))))))/(Real.sqrt m)):= by + _ ≤ ∑ j : Fin n, ((6 * (ej c (j+1) - ej c (j+2))) * (√(2 * + Real.log ((coveringNumberNat h' (ej c (j+1))) * + (coveringNumberNat h' (ej c (j+1))))))/(Real.sqrt m)):= by refine Finset.sum_le_sum ?_ intro s si refine div_le_div_of_nonneg_right ?_ ?_ @@ -1096,7 +1278,8 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( apply Real.log_le_log refine Left.mul_pos ?_ ?_ repeat (norm_cast; apply coveringNumber_nonzero; simp; apply ej_pos c_pos) - refine (mul_le_mul_iff_of_pos_left (by norm_cast; apply coveringNumber_nonzero; simp; apply ej_pos c_pos)).mpr ?_ + refine (mul_le_mul_iff_of_pos_left + (by norm_cast; apply coveringNumber_nonzero; simp; apply ej_pos c_pos)).mpr ?_ · norm_cast apply coveringNumber_antitone repeat(apply ej_pos c_pos) @@ -1113,11 +1296,13 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( refine (pow_le_pow_iff_right₀ ?_).mpr ?_ repeat simp simp - _ = ∑ j : Fin n, 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * (√(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) / (Real.sqrt m)) := by + _ = ∑ j : Fin n, 6 * (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * + (√(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) / (Real.sqrt m)) := by repeat apply congrArg ext j -- Factor out the covering number calculation - have covering_calc : √(Real.log ((coveringNumberNat h' (ej c ((j : ℕ) + 1))) * (coveringNumberNat h' (ej c ((j : ℕ) + 1))))) = + have covering_calc : √(Real.log ((coveringNumberNat h' (ej c ((j : ℕ) + 1))) * + (coveringNumberNat h' (ej c ((j : ℕ) + 1))))) = √(2 * Real.log (coveringNumberNat h' (ej c ((j : ℕ) + 1)))) := by calc _ = √(Real.log ((coveringNumberNat h' (ej c ((j : ℕ) + 1))) ^ 2)) := by @@ -1129,7 +1314,8 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( rw [Real.log_pow] norm_cast _ = _ := by simp - have : √(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) = √2 * √(2 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) := by + have : √(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) = √2 * + √(2 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) := by simp rw [<- mul_assoc] simp @@ -1139,14 +1325,19 @@ private lemma partB_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set ( rw [this, <- covering_calc] rw [mul_div_assoc] apply congrArg - have : √(2 * Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))))) = - √2 * √(Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))))) := by + have : √(2 * Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * + ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))))) = + √2 * √(Real.log (↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))) * + ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1))))) := by simp rw [this] -- Convert the Part A/Part B bound into the final finite-sum expression. -private lemma combine_partA_partB (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) +private lemma combine_partA_partB (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : - empiricalRademacherComplexity_without_abs m F S ≤ (ej c n) + 12 / (Real.sqrt m)*(∑ j : Fin n, ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) := by + empiricalRademacherComplexity_without_abs m F S ≤ (ej c n) + 12 / + (Real.sqrt m)*(∑ j : Fin n, + ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) := by apply le_trans (split_main_and_increment_terms cs h' n) refine add_le_add ?_ ?_ · rw [mul_assoc] @@ -1163,7 +1354,8 @@ private lemma combine_partA_partB (c_pos : 0 < c) (h' : TotallyBounded (Set.univ simp only [exists_const] refine mul_nonneg (by simp) (by apply ej_nonneg c_pos) · rw [<- mul_assoc] - rw [(by refine mul_inv_cancel₀ (by dsimp[Signs]; simp) : (Fintype.card (Signs m) : ℝ) * signs_card_inv m = 1)] + rw [(by refine mul_inv_cancel₀ (by dsimp[Signs]; simp) : (Fintype.card (Signs m) : ℝ) * + signs_card_inv m = 1)] simp only [one_mul] refine Finset.sum_le_sum ?_ intro i hi @@ -1202,8 +1394,10 @@ private lemma combine_partA_partB (c_pos : 0 < c) (h' : TotallyBounded (Set.univ apply congrArg ext j calc - _ = (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * (6 * (√(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) / (Real.sqrt m))) := by ring - _ = ((ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * ((12 / (Real.sqrt m)) * √(Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))))) := by + _ = (ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * (6 * + (√(4 * Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) / (Real.sqrt m))) := by ring + _ = ((ej c ((j : ℕ) + 1) - ej c ((j : ℕ) + 2)) * ((12 / (Real.sqrt m)) * + √(Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))))) := by apply congrArg calc _ = 6 * (2 * √(Real.log ↑(coveringNumberNat h' (ej c ((j : ℕ) + 1)))) / (Real.sqrt m)) := by @@ -1294,7 +1488,8 @@ theorem AntitoneOn.leftRiemann_sum_le_integral (n : ℕ) (f : ℕ → ℝ) (g : exact antitone_const_tsub rw [s0, s1] rw [<- intervalIntegral.sum_integral_adjacent_intervals] - have t : ∑ j : Fin n, (f (j : ℕ) - f ((j : ℕ) + 1)) * g (f (j : ℕ)) = ∑ j : Fin n, (h ((j : ℕ) + 1) - h (j : ℕ)) * g (h ((j : ℕ) + 1)) := by + have t : ∑ j : Fin n, (f (j : ℕ) - f ((j : ℕ) + 1)) * g (f (j : ℕ)) = + ∑ j : Fin n, (h ((j : ℕ) + 1) - h (j : ℕ)) * g (h ((j : ℕ) + 1)) := by let φ : Fin n ≃ Fin n := { toFun := fun j => ⟨n - 1 - j, by @@ -1331,7 +1526,8 @@ theorem AntitoneOn.leftRiemann_sum_le_integral (n : ℕ) (f : ℕ → ℝ) (g : apply congrArg grind rw [t] - have u : ∑ k ∈ Finset.range n, ∫ (x : ℝ) in h k..h (k + 1), g x = ∑ k : Fin n, ∫ (x : ℝ) in h k..h (k + 1), g x := by + have u : ∑ k ∈ Finset.range n, ∫ (x : ℝ) in h k..h (k + 1), g x = + ∑ k : Fin n, ∫ (x : ℝ) in h k..h (k + 1), g x := by exact Finset.sum_range fun i ↦ ∫ (x : ℝ) in h i..h (i + 1), g x rw [u] apply Finset.sum_le_sum @@ -1368,17 +1564,24 @@ private lemma ej_antitone (c_nonneg : 0 ≤ c) : Antitone (fun n : ℕ ↦ ej c norm_num exact c_nonneg -private lemma entropy_sum_to_integral_bound (c_pos : 0 < c) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) +private lemma entropy_sum_to_integral_bound (c_pos : 0 < c) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (n : ℕ) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) : - empiricalRademacherComplexity_without_abs m F S ≤ 2 * (ej c (n+1)) + 12 / (Real.sqrt m)*(∫ (x : ℝ) in (ej c (n+1))..(c/2),√(Real.log (coveringNumberNat h' x))) := by + empiricalRademacherComplexity_without_abs m F S ≤ 2 * (ej c (n+1)) + 12 / + (Real.sqrt m)*(∫ (x : ℝ) in (ej c (n+1))..(c/2),√(Real.log (coveringNumberNat h' x))) := by calc - _ ≤ (ej c n) + 12 / (Real.sqrt m)*(∑ j : Fin n, ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) := combine_partA_partB c_pos h' n m_pos cs - _ = 2 * (ej c (n+1)) + 12 / (Real.sqrt m)*(∑ j : Fin n, ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) := by + _ ≤ (ej c n) + 12 / (Real.sqrt m)*(∑ j : Fin n, ((ej c (j+1) - + ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) + := combine_partA_partB c_pos h' n m_pos cs + _ = 2 * (ej c (n+1)) + 12 / (Real.sqrt m)*(∑ j : Fin n, + ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) := by refine add_right_cancel_iff.mpr ?_ dsimp [ej] grind _ ≤ _ := by - suffices (∑ j : Fin n, ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) ≤ (∫ (x : ℝ) in (ej c (n + 1))..(c/2),√(Real.log (coveringNumberNat h' x))) from by + suffices (∑ j : Fin n, + ((ej c (j+1) - ej c (j+2))*√(Real.log (coveringNumberNat h' (ej c (j+1)))))) ≤ + (∫ (x : ℝ) in (ej c (n + 1))..(c/2),√(Real.log (coveringNumberNat h' x))) from by refine (add_le_add_iff_left (2 * ej c (n + 1))).mpr ?_ apply mul_le_mul_of_nonneg_left exact this @@ -1527,7 +1730,8 @@ private lemma choose_dyadic_scale_for_epsilon (ε : ℝ) (ε_pos : 0 < ε) (c_ε rw [<- h2] exact Int.le_ceil (Real.logb 2 (c / ε)) -theorem dudley_entropy_integral' {ε : ℝ} (ε_pos : 0 < ε) (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) +theorem dudley_entropy_integral' {ε : ℝ} (ε_pos : 0 < ε) + (h' : TotallyBounded (Set.univ : Set (EmpiricalFunctionSpace F S))) (m_pos : 0 < m) (cs : ∀ f : ι, empiricalNorm S (F f) ≤ c) (ε_le_c_div_2 : ε < c/2) : empiricalRademacherComplexity_without_abs m F S ≤ @@ -2087,3 +2291,5 @@ example htb hnorm hδ hδ_one end Generalization + +end Empirical diff --git a/StatsMLlib/LearningTheory/Rademacher/Massart.lean b/StatsMLlib/LearningTheory/Rademacher/Massart.lean index c8dc6aa..25c855a 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Massart.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Massart.lean @@ -67,7 +67,8 @@ lemma measurablespace_eq : instMeasurableSpaceSigns m = MeasurableSpace.pi := by rfl lemma measure_eq : - (signVecPMF m).toMeasure ≍ Measure.pi fun (_ : Fin m) ↦ (PMF.uniformOfFintype ({-1, 1} : Finset ℤ)).toMeasure := by + (signVecPMF m).toMeasure ≍ Measure.pi fun (_ : Fin m) ↦ + (PMF.uniformOfFintype ({-1, 1} : Finset ℤ)).toMeasure := by apply heq_of_eq apply Eq.symm apply Measure.pi_eq @@ -156,7 +157,8 @@ theorem massart_lemma_pmf.sign_mean_zero {Z : Type v} {m : ℕ} ∫ (ω : Signs m), ↑↑(ω a) * f (S a) ∂(signVecPMF m).toMeasure = 0 := by rw [PMF.integral_eq_tsum] · dsimp [signVecPMF, PMF.uniformOfFintype] - simp only [Finset.mem_univ, ↓reduceIte, Signs.card, Nat.cast_pow, Nat.cast_ofNat, ENNReal.toReal_inv, + simp only [Finset.mem_univ, ↓reduceIte, Signs.card, Nat.cast_pow, Nat.cast_ofNat, + ENNReal.toReal_inv, ENNReal.toReal_pow, ENNReal.toReal_ofNat, Int.reduceNeg] rw [tsum_mul_left] suffices ∑' (a_1 : Signs m), (↑↑(a_1 a) * f (S a)) = 0 from by @@ -176,7 +178,8 @@ lemma massart_lemma_pmf have hbridge : empiricalRademacherComplexity_pmf_without_abs m (F_on (ι:=ι) (Z:=Z) F f) S = ∫ σ, Finset.sup' f hs - (fun j => MassartNotation.X (F:=F) (S:=S) (m:=m) (ι:=ι) j σ) ∂(signVecPMF m).toMeasure := by + (fun j => MassartNotation.X (F:=F) (S:=S) (m:=m) (ι:=ι) j σ) + ∂(signVecPMF m).toMeasure := by dsimp [empiricalRademacherComplexity_pmf_without_abs] dsimp [MassartNotation.X] dsimp [MassartNotation.Y] @@ -298,8 +301,10 @@ lemma massart_lemma_pmf measurability) · intro a af have signs_coord_indep : - iIndepFun (fun i ↦ MassartNotation.Y (F:=F) (S:=S) (m:=m) i a) (signVecPMF m).toMeasure := by - have h : ∀ (i : Fin m), Measurable fun (σi : ({-1, 1} : Finset ℤ)) ↦ (↑m)⁻¹ * (σi.1 : ℝ) * F a (S i) := by + iIndepFun (fun i ↦ MassartNotation.Y (F:=F) (S:=S) (m:=m) i a) + (signVecPMF m).toMeasure := by + have h : ∀ (i : Fin m), Measurable fun (σi : ({-1, 1} : Finset ℤ)) ↦ (↑m)⁻¹ * (σi.1 : ℝ) * + F a (S i) := by intro i measurability convert iIndepFun.comp pi_eval_iIndepFun @@ -311,3 +316,5 @@ lemma massart_lemma_pmf · intro a af apply MassartNotation.xy_identity exact af + +end ProbabilityTheory diff --git a/StatsMLlib/LearningTheory/Rademacher/Signs.lean b/StatsMLlib/LearningTheory/Rademacher/Signs.lean index af04301..674feaf 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Signs.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Signs.lean @@ -69,7 +69,8 @@ theorem double_rademacher_flip (σ : Signs n) : rademacher_flip n k (rademacher_ · dsimp [rademacher_flip] simp [h] -theorem bijective_rademacher_flip : Bijective (rademacher_flip n k) := Involutive.bijective (double_rademacher_flip n k) +theorem bijective_rademacher_flip : Bijective (rademacher_flip n k) + := Involutive.bijective (double_rademacher_flip n k) theorem sign_sum_eq_zero : ∑ σ : Signs n, (σ k : ℝ) = 0 := by have : ∑ σ : Signs n, (σ k : ℝ) = ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) := by @@ -94,7 +95,8 @@ theorem sign_sum_eq_zero : ∑ σ : Signs n, (σ k : ℝ) = 0 := by _ = 0 := by simp grind -theorem sign_flip_product_invariance : ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) * (rademacher_flip n k σ l : ℝ) := by +theorem sign_flip_product_invariance : ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = + ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) * (rademacher_flip n k σ l : ℝ) := by apply Finset.sum_bijective · apply bijective_rademacher_flip exact k @@ -126,15 +128,18 @@ theorem pair_sum_zero (pkl : k ≠ l) : ∀ σ : Fin n → ({-1, 1} : Finset ℤ theorem rademacher_orthogonality (n : ℕ) (k l : Fin n) (pkl : k ≠ l): ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = 0 := by have sum_partition : ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = - (1/2) * ∑ σ : Signs n, ((σ k : ℝ) * σ l + (rademacher_flip n k σ) k * (rademacher_flip n k σ) l) := by + (1/2) * ∑ σ : Signs n, ((σ k : ℝ) * σ l + (rademacher_flip n k σ) k * + (rademacher_flip n k σ) l) := by calc _ = (1/2) * (∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) + ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ)) := by field_simp simp only [Int.reduceNeg, mul_eq_mul_left_iff] left norm_num - _ = (1/2) * (∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) + ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) * (rademacher_flip n k σ l : ℝ)) := by - have p : ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) * (rademacher_flip n k σ l : ℝ) := sign_flip_product_invariance n k l + _ = (1/2) * (∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) + ∑ σ : Signs n, + (rademacher_flip n k σ k : ℝ) * (rademacher_flip n k σ l : ℝ)) := by + have p : ∑ σ : Signs n, (σ k : ℝ) * (σ l : ℝ) = ∑ σ : Signs n, (rademacher_flip n k σ k : ℝ) * + (rademacher_flip n k σ l : ℝ) := sign_flip_product_invariance n k l rw [p] _ = _ := by apply congrArg @@ -170,7 +175,7 @@ lemma empiricalRademacherComplexity_eq_empiricalRademacherComplexity_pmf ext σ simp exact CommMonoid.mul_comm ((signVecPMF n) σ).toReal (g σ) - . dsimp [g] + · dsimp [g] rw [<- MeasureTheory.memLp_one_iff_integrable] simp have huniform : @@ -190,7 +195,8 @@ noncomputable def empiricalRademacherComplexity_pmf_without_abs lemma empiricalRademacherComplexity_without_abs_eq_empiricalRademacherComplexity_pmf_without_abs (f : ι → 𝒳 → ℝ) (S : Fin n → 𝒳) : - empiricalRademacherComplexity_without_abs n f S = empiricalRademacherComplexity_pmf_without_abs n f S := by + empiricalRademacherComplexity_without_abs n f S = + empiricalRademacherComplexity_pmf_without_abs n f S := by dsimp [empiricalRademacherComplexity_without_abs, empiricalRademacherComplexity_pmf_without_abs] set g : Signs n → ℝ := (fun σ => ⨆ i, (n : ℝ)⁻¹ * ∑ k : Fin n, (((σ k).1 : ℤ) : ℝ) * f i (S k)) @@ -202,7 +208,7 @@ lemma empiricalRademacherComplexity_without_abs_eq_empiricalRademacherComplexity ext σ simp exact CommMonoid.mul_comm ((signVecPMF n) σ).toReal (g σ) - . dsimp [g] + · dsimp [g] rw [<- MeasureTheory.memLp_one_iff_integrable] simp have huniform : diff --git a/StatsMLlib/LearningTheory/Rademacher/Symmetrization.lean b/StatsMLlib/LearningTheory/Rademacher/Symmetrization.lean index e7bb61a..6610c26 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Symmetrization.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Symmetrization.lean @@ -18,7 +18,8 @@ Measure-theoretic infrastructure for symmetrizing empirical processes with finit ## Main definitions -This module works with the `Signs` type and Rademacher complexity definitions from `StatsMLlib.LearningTheory.Rademacher.Defs`. +This module works with the `Signs` type and Rademacher complexity definitions from +`StatsMLlib.LearningTheory.Rademacher.Defs`. ## Main results @@ -73,18 +74,21 @@ theorem Signs.apply_abs' (σ : Signs n) (k : Fin n) : (|σ k| : ℝ) = 1 := by simp theorem measurable_snocEquiv: - @Measurable (Ω × (Fin n → Ω)) (Fin (n + 1) → Ω) Prod.instMeasurableSpace MeasurableSpace.pi fun f ↦ Fin.snoc f.2 f.1 := by + @Measurable (Ω × (Fin n → Ω)) + (Fin (n + 1) → Ω) Prod.instMeasurableSpace MeasurableSpace.pi fun f ↦ Fin.snoc f.2 f.1 := by apply Measurable.of_eval intro i dsimp [Fin.snoc] if h : i.1 < n then - have : (fun c : Ω × (Fin n → Ω) ↦ if h : ↑i < n then c.2 (i.castLT h) else c.1) = fun c ↦ c.2 (i.castLT h) := by + have : (fun c : Ω × (Fin n → Ω) ↦ if h : ↑i < n then c.2 (i.castLT h) else c.1) = fun c ↦ + c.2 (i.castLT h) := by ext c rw [dite_eq_left h] rw [this] exact Measurable.eval measurable_snd else - have : (fun c : Ω × (Fin n → Ω)↦ if h : ↑i < n then c.2 (i.castLT h) else c.1) = fun c ↦ c.1 := by + have : (fun c : Ω × (Fin n → Ω)↦ if h : ↑i < n then c.2 (i.castLT h) else c.1) = fun c ↦ c.1 + := by ext c rw [dite_eq_right h] rw [this] @@ -92,12 +96,14 @@ theorem measurable_snocEquiv: lemma measure_equiv : (MeasureTheory.Measure.pi (fun _ ↦ μ) : Measure (Fin n.succ → Ω)) - = (μ.prod (MeasureTheory.Measure.pi (fun _ ↦ μ) : Measure (Fin n → Ω))).map (Fin.snocEquiv (fun _ ↦ Ω)):= by + = (μ.prod (MeasureTheory.Measure.pi (fun _ ↦ μ) : Measure (Fin n → Ω))).map + (Fin.snocEquiv (fun _ ↦ Ω)):= by dsimp [Fin.snocEquiv] apply Measure.pi_eq intros s hs rw [Measure.map_apply measurable_snocEquiv (MeasurableSet.univ_pi hs)] - have : ((fun (f : Ω × (Fin n → Ω)) (x : Fin (n+1)) ↦ @Fin.snoc n (fun x ↦ Ω) f.2 f.1 x) ⁻¹' Set.univ.pi s) + have : ((fun (f : Ω × (Fin n → Ω)) (x : Fin (n+1)) ↦ @Fin.snoc n (fun x ↦ + Ω) f.2 f.1 x) ⁻¹' Set.univ.pi s) = (s (Fin.last n)) ×ˢ (Set.univ.pi (s ∘ Fin.castSucc)) := by ext ω simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, forall_const, Set.mem_prod, @@ -196,16 +202,19 @@ lemma ineq (ω : Ω × Ω) {b : ℝ} (h𝓕': ∀ I : ι, ∀ z : Z, |f I z| ≤ (ih : ∀ (c : ι → ℝ), (∃ C, ∀ I : ι, |c I| ≤ C) → (∫ (ω' : Fin n → Ω × Ω), - (⨆ I : ι, ∑ i : Fin n, (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I) ∂Measure.pi fun _ ↦ μ.prod μ) = + (⨆ I : ι, ∑ i : Fin n, (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I) + ∂Measure.pi fun _ ↦ μ.prod μ) = ∫ (ω' : Fin n → Ω × Ω), (2⁻¹ ^ n * - ∑ σ : Fin n → ({-1, 1} : Finset ℤ), ⨆ I : ι, ∑ i : Fin n, (σ i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I) + ∑ σ : Fin n → ({-1, 1} : Finset ℤ), ⨆ I : ι, ∑ i : Fin n, (σ i) * + (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I) ∂Measure.pi fun _ ↦ μ.prod μ): let μ2n : Measure ((Fin n) → Ω × Ω):= MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ) (μ2n)[fun ω' : Fin n → Ω × Ω ↦ ⨆ I : ι, (∑ i : Fin n, (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)] = (μ2n)[fun ω' : (Fin n) → Ω × Ω ↦ (2:ℝ)⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)] := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)] := by apply ih (fun I ↦ (f I (X ω.1) - f I (X ω.2)) + c I) use b+b+C exact boundedness₀ h𝓕' hC ω @@ -213,14 +222,18 @@ lemma ineq (ω : Ω × Ω) {b : ℝ} (h𝓕': ∀ I : ι, ∀ z : Z, |f I z| ≤ omit [MeasurableSpace Ω] in lemma inineq (ω : Ω × Ω) (ω': Fin n → Ω × Ω) {c : ι → ℝ}: (2 : ℝ)⁻¹ * ((2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.2) - f I (X ω.1) + c I)) + + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.2) - f I (X ω.1) + c I)) + 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.1) - f I (X ω.2) + c I)) + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.1) - f I (X ω.2) + c I)) = 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), - (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I)) := by + (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I)) := by calc _ = 2⁻¹ ^ (n+1) * ∑ σ' ∈ ({-1, 1} : Finset ℤ), (∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (σ' * (f I (X ω.1) - f I (X ω.2)) + c I)) := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (σ' * (f I (X ω.1) - f I (X ω.2)) + c I)) := by rw [←mul_add, ←mul_assoc] simp only [inv_pow, Int.reduceNeg, Finset.mem_singleton, reduceCtorEq, not_false_eq_true, Finset.sum_insert, Int.cast_neg, Int.cast_one, neg_mul, one_mul, neg_sub, @@ -258,7 +271,8 @@ lemma measurable_sum_part [Countable ι] lemma measurable₀ [Countable ι] (h𝓕 : ∀ (I : ι), Measurable (f I ∘ X)) (n : ℕ) (c : ι → ℝ) : - Measurable fun ω : Fin n → Ω × Ω ↦ ⨆ I, ∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2)) + c I := by + Measurable fun ω : Fin n → Ω × Ω ↦ ⨆ I, ∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2)) + c I + := by apply Measurable.iSup intro I apply Measurable.add_const @@ -281,9 +295,11 @@ theorem abs_iSup_le [Nonempty ι] {f : ι → ℝ} {a : ℝ} (hf : ∀ i, |f i| omit [MeasurableSpace Ω] in lemma bound_lem {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) - (ω : Fin n → Ω × Ω) (I : ι) : |∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2))| ≤ ↑n * (b + b) := by + (ω : Fin n → Ω × Ω) (I : ι) : |∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2))| ≤ ↑n * (b + b) + := by calc - _ ≤ ∑ i : Fin n, |f I (X (ω i).1) - f I (X (ω i).2)| := IsAbsoluteValue.abv_sum abs (fun i ↦ f I (X (ω i).1) - f I (X (ω i).2)) Finset.univ + _ ≤ ∑ i : Fin n, |f I (X (ω i).1) - f I (X (ω i).2)| + := IsAbsoluteValue.abv_sum abs (fun i ↦ f I (X (ω i).1) - f I (X (ω i).2)) Finset.univ _ ≤ ∑ i : Fin n, (b+b) := by apply Fintype.sum_mono intro i @@ -293,7 +309,8 @@ lemma bound_lem {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) ring_nf omit [MeasurableSpace Ω] in -lemma bound_isum' [Nonempty ι] {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} (hC : ∀ (I : ι), |c I| ≤ C) +lemma bound_isum' [Nonempty ι] {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} + (hC : ∀ (I : ι), |c I| ≤ C) (ω : Fin n → Ω × Ω) : |⨆ I, ∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2)) + c I| ≤ ↑n * (b + b) + C := by apply abs_iSup_le @@ -308,7 +325,8 @@ lemma bound_lem' {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) (ω : Fin n → Ω × Ω) (I : ι) (σ : Fin n → ({-1, 1} : Finset ℤ)): |∑ i : Fin n, (σ i) * (f I (X (ω i).1) - f I (X (ω i).2))| ≤ ↑n * (b + b) := by calc - _ ≤ ∑ i : Fin n, |(σ i) * (f I (X (ω i).1) - f I (X (ω i).2))| := IsAbsoluteValue.abv_sum abs _ Finset.univ + _ ≤ ∑ i : Fin n, |(σ i) * (f I (X (ω i).1) - f I (X (ω i).2))| + := IsAbsoluteValue.abv_sum abs _ Finset.univ _ ≤ ∑ i : Fin n, (b+b) := by apply Fintype.sum_mono intro i @@ -322,7 +340,8 @@ lemma bound_lem' {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) ring_nf omit [MeasurableSpace Ω] in -lemma bound_isum [Nonempty ι] {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} (hC : ∀ (I : ι), |c I| ≤ C) +lemma bound_isum [Nonempty ι] {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} + (hC : ∀ (I : ι), |c I| ≤ C) (ω : Fin n → Ω × Ω) (σ : Fin n → ({-1, 1} : Finset ℤ)) : |⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω i).1) - f I (X (ω i).2)) + c I| ≤ ↑n * (b + b) + C := by apply abs_iSup_le @@ -336,7 +355,8 @@ lemma integrable₀ [Countable ι] [Nonempty ι] (h𝓕 : ∀ (I : ι), Measurable (f I ∘ X)) {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {n : ℕ} {c : ι → ℝ} {C : ℝ} (hC : ∀ (I : ι), |c I| ≤ C) : let μ2n := Measure.pi fun _ ↦ μ.prod μ; - Integrable (fun ω ↦ ⨆ I, ∑ i : Fin n, (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + (f I (X ω.1.1) - f I (X ω.1.2) + c I)) + Integrable (fun ω ↦ ⨆ I, ∑ i : Fin n, (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + + (f I (X ω.1.1) - f I (X ω.1.2) + c I)) ((μ.prod μ).prod μ2n) := by constructor · apply Measurable.aestronglyMeasurable @@ -359,7 +379,8 @@ lemma bound_σsum [Nonempty ι] {b : ℝ} (h𝓕' : ∀ (I : ι) (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} (hC : ∀ (I : ι), |c I| ≤ C) (ω' : Fin n → Ω × Ω) : |2⁻¹ ^ n * - ∑ σ : Fin n → ({-1, 1} : Finset ℤ), ⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I| ≤ + ∑ σ : Fin n → ({-1, 1} : Finset ℤ), ⨆ I, ∑ i : Fin n, ↑↑(σ i) * + (f I (X (ω' i).1) - f I (X (ω' i).2)) + c I| ≤ ↑n * (b + b) + C := by rw [abs_mul, abs_of_pos (by simp)] have : |∑ σ : Fin n → ({-1, 1} : Finset ℤ), @@ -386,7 +407,8 @@ lemma bound_σsum [Nonempty ι] _ = _ := by simp theorem integrable₁' [Countable ι] [Nonempty ι] - (h𝓕 : ∀ I : ι, Measurable (f I ∘ X)) {b : ℝ} (h𝓕' : ∀ I : ι, ∀ (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} + (h𝓕 : ∀ I : ι, Measurable (f I ∘ X)) {b : ℝ} (h𝓕' : ∀ I : ι, ∀ (z : Z), |f I z| ≤ b) {c : ι → ℝ} + {C : ℝ} (hC : ∀ I : ι, |c I| ≤ C) : let μ2n := Measure.pi fun _ ↦ μ.prod μ; Integrable @@ -420,14 +442,16 @@ theorem integrable₁' [Countable ι] [Nonempty ι] theorem integrable₁ (ω : Ω × Ω) [Countable ι] [Nonempty ι] - (h𝓕 : ∀ I : ι, Measurable (f I ∘ X)) {b : ℝ} (h𝓕' : ∀ I : ι, ∀ (z : Z), |f I z| ≤ b) {c : ι → ℝ} {C : ℝ} + (h𝓕 : ∀ I : ι, Measurable (f I ∘ X)) {b : ℝ} (h𝓕' : ∀ I : ι, ∀ (z : Z), |f I z| ≤ b) {c : ι → ℝ} + {C : ℝ} (hC : ∀ I : ι, |c I| ≤ C) : let μ2n := Measure.pi fun _ ↦ μ.prod μ; Integrable (fun a ↦ 2⁻¹ ^ n * ∑ σ : Fin n → ({-1, 1} : Finset ℤ), - ⨆ I : ι, ∑ i : Fin n, (σ i) * (f I (X (a i).1) - f I (X (a i).2)) + (f I (X ω.1) - f I (X ω.2) + c I)) + ⨆ I : ι, ∑ i : Fin n, (σ i) * (f I (X (a i).1) - f I (X (a i).2)) + + (f I (X ω.1) - f I (X ω.2) + c I)) μ2n := by exact integrable₁' h𝓕 h𝓕' (boundedness₀ h𝓕' hC ω) @@ -440,14 +464,17 @@ theorem integrable₂ [Countable ι] [Nonempty ι] (fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Fin n → ({-1, 1} : Finset ℤ), - ⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + (f I (X a.1) - f I (X a.2) + c I)) + ⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + + (f I (X a.1) - f I (X a.2) + c I)) x ∂ Measure.pi fun _ ↦ μ.prod μ) (μ.prod μ) := by constructor · apply StronglyMeasurable.aestronglyMeasurable - apply @StronglyMeasurable.integral_prod_right' (Ω × Ω) (Fin n → (Ω × Ω)) ℝ _ _ (Measure.pi fun _ ↦ μ.prod μ) _ _ _ (fun ω ↦ (2⁻¹ ^ n * + apply @StronglyMeasurable.integral_prod_right' (Ω × Ω) + (Fin n → (Ω × Ω)) ℝ _ _ (Measure.pi fun _ ↦ μ.prod μ) _ _ _ (fun ω ↦ (2⁻¹ ^ n * ∑ σ : Fin n → ({-1, 1} : Finset ℤ), - ⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + (f I (X ω.1.1) - f I (X ω.1.2) + c I))) + ⨆ I, ∑ i : Fin n, ↑↑(σ i) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + + (f I (X ω.1.1) - f I (X ω.1.2) + c I))) apply Measurable.stronglyMeasurable apply Measurable.const_mul apply Finset.measurable_sum Finset.univ @@ -503,18 +530,21 @@ theorem integrable₃ [Countable ι] [Nonempty ι] dsimp rw [abs_mul, abs_of_pos (by simp)] have : |∑ σ : Fin (n+1) → ({-1, 1} : Finset ℤ), - ⨆ I : ι, ∑ i : Fin n, (σ (Fin.castSucc i)) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + ((σ (Fin.last n)) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I)| + ⨆ I : ι, ∑ i : Fin n, (σ (Fin.castSucc i)) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + + ((σ (Fin.last n)) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I)| ≤ 2^(n+1) * (n*(b+b)+(b+b+C)) := by calc _ ≤ ∑ σ : Fin (n+1) → ({-1, 1} : Finset ℤ), - |⨆ I : ι, ∑ i : Fin n, (σ (Fin.castSucc i)) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + ((σ (Fin.last n)) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I)| := by + |⨆ I : ι, ∑ i : Fin n, (σ (Fin.castSucc i)) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + + ((σ (Fin.last n)) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I)| := by apply Finset.abs_sum_le_sum_abs _ ≤ ∑ σ : Fin (n+1) → ({-1, 1} : Finset ℤ), (n*(b+b)+(b+b+C)) := by apply Finset.sum_le_sum intro σ _ apply bound_isum h𝓕' exact boundedness₁ h𝓕' hC ω.1 (σ (Fin.last n)) - _ = (Finset.univ : Finset (Fin (n+1) → ({-1, 1} : Finset ℤ))).card • (n*(b+b)+(b+b+C)) := Finset.sum_const (n*(b+b)+(b+b+C)) + _ = (Finset.univ : Finset (Fin (n+1) → ({-1, 1} : Finset ℤ))).card • (n*(b+b)+(b+b+C)) + := Finset.sum_const (n*(b+b)+(b+b+C)) _ = _ := by simp only [Int.reduceNeg, Finset.card_univ, Finset.mem_insert, Finset.mem_singleton, Fintype.card_pi, Fintype.card_coe, reduceCtorEq, not_false_eq_true, @@ -531,26 +561,33 @@ lemma ineq2 (ω : Ω × Ω) [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Me {c : ι → ℝ} {C : ℝ} (hC : ∀ I : ι, |c I| ≤ C): let μ2n : Measure ((Fin n) → Ω × Ω):= MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ) (2 : ℝ)⁻¹ * ((μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - (⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.2) - f I (X ω.1) + c I))] + + (⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.2) - f I (X ω.1) + c I))] + (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - (⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.1) - f I (X ω.2) + c I))]) + (⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.1) - f I (X ω.2) + c I))]) = (μ2n)[fun ω' ↦ (2 : ℝ)⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), - (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I))] := by + (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I))] := by let μ2n : Measure ((Fin n) → Ω × Ω):= MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ) calc _ = (2 : ℝ)⁻¹ * ((μ2n)[fun ω' ↦ (2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.2) - f I (X ω.1) + c I)) + + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.2) - f I (X ω.1) + c I)) + 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.1) - f I (X ω.2) + c I)]) := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.1) - f I (X ω.2) + c I)]) := by apply congr_arg apply Eq.symm apply integral_add · apply integrable₁ ω.swap h𝓕 h𝓕' hC · apply integrable₁ ω h𝓕 h𝓕' hC _ = (μ2n)[fun ω' ↦ (2 : ℝ)⁻¹ * ((2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.2) - f I (X ω.1) + c I)) + + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.2) - f I (X ω.1) + c I)) + 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + (f I (X ω.1) - f I (X ω.2) + c I))] := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + (f I (X ω.1) - f I (X ω.2) + c I))] := by apply Eq.symm apply integral_const_mul _ = _ := by @@ -561,25 +598,30 @@ lemma ineq2 (ω : Ω × Ω) [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Me lemma aux₃ [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Measurable (f I ∘ X)) {b : ℝ} (h𝓕': ∀ I : ι, ∀ z : Z, |f I z| ≤ b): - ∀ (c : ι → ℝ), (∃ C : ℝ, ∀ I : ι, |c I| ≤ C) → (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω + ∀ (c : ι → ℝ), (∃ C : ℝ, ∀ I : ι, |c I| ≤ C) → (MeasureTheory.Measure.pi (fun _ ↦ + μ.prod μ))[fun ω : Fin n → Ω × Ω ↦ ⨆ I : ι, ∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2)) + c I] = (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω - ↦ 2⁻¹ ^ n * ∑ σ : Signs n, (⨆ I : ι, ∑ i : Fin n, σ i * (f I (X (ω i).1) - f I (X (ω i).2)) + c I)]:= by + ↦ 2⁻¹ ^ n * ∑ σ : Signs n, + (⨆ I : ι, ∑ i : Fin n, σ i * (f I (X (ω i).1) - f I (X (ω i).2)) + c I)]:= by induction' n with n ih · simp · rintro c ⟨C, hC⟩ let μ2n : Measure ((Fin n) → Ω × Ω):= MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ) calc - _ = (((μ.prod μ).prod μ2n).map (Fin.snocEquiv (fun _ ↦ Ω × Ω)))[fun ω ↦ ⨆ I : ι, ∑ i : Fin (n + 1), (f I (X (ω i).1) - f I (X (ω i).2)) + c I] := by + _ = (((μ.prod μ).prod μ2n).map (Fin.snocEquiv (fun _ ↦ Ω × Ω)))[fun ω ↦ + ⨆ I : ι, ∑ i : Fin (n + 1), (f I (X (ω i).1) - f I (X (ω i).2)) + c I] := by rw [measure_equiv] - _ = ((μ.prod μ).prod μ2n)[(fun ω ↦ ⨆ I : ι, ∑ i : Fin (n + 1), (f I (X (ω i).1) - f I (X (ω i).2)) + c I) ∘ (Fin.snocEquiv (fun _ ↦ Ω × Ω))] := by + _ = ((μ.prod μ).prod μ2n)[(fun ω ↦ ⨆ I : ι, ∑ i : Fin (n + 1), + (f I (X (ω i).1) - f I (X (ω i).2)) + c I) ∘ (Fin.snocEquiv (fun _ ↦ Ω × Ω))] := by apply integral_map · apply Measurable.aemeasurable dsimp [Fin.snocEquiv] exact measurable_snocEquiv · apply Measurable.aestronglyMeasurable exact measurable₀ h𝓕 (n+1) c - _ = ((μ.prod μ).prod μ2n)[fun ω ↦ ⨆ I : ι, ∑ i : Fin n, (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + ((f I (X ω.1.1) - f I (X ω.1.2)) + c I)] := by + _ = ((μ.prod μ).prod μ2n)[fun ω ↦ ⨆ I : ι, ∑ i : Fin n, + (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + ((f I (X ω.1.1) - f I (X ω.1.2)) + c I)] := by apply congr_arg ext dsimp @@ -587,55 +629,71 @@ lemma aux₃ [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Measurable (f I ext f rw [Fin.sum_univ_castSucc, add_assoc] simp - _ = (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ ⨆ I : ι, ∑ i : Fin n, (f I (X (ω' i).1) - f I (X (ω' i).2)) + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by + _ = (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ ⨆ I : ι, ∑ i : Fin n, + (f I (X (ω' i).1) - f I (X (ω' i).2)) + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by apply integral_prod apply integrable₀ h𝓕 h𝓕' hC _ = (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by apply congr_arg ext ω dsimp exact (ineq ω h𝓕' hC ih) -- Removing the parentheses triggers an unexpected error - _ = (2:ℝ)⁻¹ * ((μ.prod μ)[fun ω'' ↦ (fun ω ↦ ((μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.2) - f I (X ω.1)) + c I)])) ω''.swap] + - (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)]]) := by + _ = (2:ℝ)⁻¹ * ((μ.prod μ)[fun ω'' ↦ (fun ω ↦ ((μ2n)[fun ω' ↦ 2⁻¹ ^ n * + ∑ σ : Signs n, ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.2) - f I (X ω.1)) + c I)])) ω''.swap] + + (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : ι, + (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)]]) := by grind only [= Prod.snd_swap, = Prod.swap_prod_mk, = Prod.fst_swap, cases eager Prod, cases Or] - _ = (2:ℝ)⁻¹ * ((μ.prod μ)[fun ω ↦ (μ2n)[fun ω' : Fin n → (Ω × Ω) ↦ (2:ℝ)⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.2) - f I (X ω.1)) + c I)]] + + _ = (2:ℝ)⁻¹ * ((μ.prod μ)[fun ω ↦ (μ2n)[fun ω' : Fin n → (Ω × Ω) ↦ (2:ℝ)⁻¹ ^ n * + ∑ σ : Signs n, + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.2) - f I (X ω.1)) + c I)]] + (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)]]) := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)]]) := by apply congr_arg apply congrFun apply congr_arg apply integral_prod_swap _ = (2:ℝ)⁻¹ * (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.2) - f I (X ω.1)) + c I)] + + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.2) - f I (X ω.1)) + c I)] + (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)]] := by apply congr_arg apply Eq.symm apply integral_add · exact (integrable₂ h𝓕 h𝓕' hC).swap · exact integrable₂ h𝓕 h𝓕' hC _ = (μ.prod μ)[fun ω ↦ 2⁻¹ * ((μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.2) - f I (X ω.1)) + c I)] + + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.2) - f I (X ω.1)) + c I)] + (μ2n)[fun ω' ↦ 2⁻¹ ^ n * ∑ σ : Signs n, - ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + ((f I (X ω.1) - f I (X ω.2)) + c I)])] := by + ⨆ I : ι, (∑ i : Fin n, σ i * (f I (X (ω' i).1) - f I (X (ω' i).2))) + + ((f I (X ω.1) - f I (X ω.2)) + c I)])] := by apply Eq.symm apply integral_const_mul _ = (μ.prod μ)[fun ω ↦ (μ2n)[fun ω' ↦ (2:ℝ)⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), - (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I))]] := by + (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω' i).1) - f I (X (ω' i).2)) + + (σ (Fin.last n) * (f I (X ω.1) - f I (X ω.2)) + c I))]] := by apply congr_arg ext ω dsimp exact ineq2 ω h𝓕 h𝓕' hC _ = ((μ.prod μ).prod μ2n)[fun ω ↦ 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), - (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + (σ (Fin.last n) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I))] := by + (⨆ I : ι, ∑ i : Fin n, σ (Fin.castSucc i) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2)) + + (σ (Fin.last n) * (f I (X ω.1.1) - f I (X ω.1.2)) + c I))] := by apply Eq.symm apply integral_prod exact integrable₃ h𝓕 h𝓕' hC _ = ((μ.prod μ).prod μ2n)[(fun ω : Fin (n+1) → Ω × Ω - ↦ 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), (⨆ I : ι, ∑ i : Fin (n+1), σ i * (f I (X (ω i).1) - f I (X (ω i).2)) + c I)) + ↦ 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), (⨆ I : ι, ∑ i : Fin (n+1), σ i * + (f I (X (ω i).1) - f I (X (ω i).2)) + c I)) ∘ (Fin.snocEquiv fun _ ↦ (Ω × Ω))] := by apply congr_arg ext ω @@ -645,9 +703,11 @@ lemma aux₃ [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Measurable (f I apply iSup_congr intro I have : ∑ i : Fin (n + 1), (σ i) * - (f I (X (@Fin.snoc n (fun _ ↦ Ω × Ω) ω.2 ω.1 i).1) - f I (X (@Fin.snoc n (fun _ ↦ Ω × Ω) ω.2 ω.1 i).2)) + (f I (X (@Fin.snoc n (fun _ ↦ Ω × Ω) ω.2 ω.1 i).1) - + f I (X (@Fin.snoc n (fun _ ↦ Ω × Ω) ω.2 ω.1 i).2)) = ∑ i : Fin (n + 1), - Fin.snoc (fun i : Fin n ↦ (σ (Fin.castSucc i)) * (f I (X (ω.2 i).1) - f I (X (ω.2 i).2))) + Fin.snoc (fun i : Fin n ↦ (σ (Fin.castSucc i)) * + (f I (X (ω.2 i).1) - f I (X (ω.2 i).2))) ((σ (Fin.last n)) * (f I (X ω.1.1) - f I (X ω.1.2))) i := by congr ext i @@ -662,7 +722,8 @@ lemma aux₃ [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι, Measurable (f I simp only [Fin.snocEquiv_apply] rw [this, Fin.sum_snoc, add_assoc] _ = (((μ.prod μ).prod μ2n).map (Fin.snocEquiv fun _ ↦ (Ω × Ω)))[(fun ω : Fin (n+1) → Ω × Ω - ↦ 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), (⨆ I : ι, ∑ i : Fin (n+1), σ i * (f I (X (ω i).1) - f I (X (ω i).2)) + c I))] := by + ↦ 2⁻¹ ^ (n+1) * ∑ σ : Signs (n + 1), (⨆ I : ι, ∑ i : Fin (n+1), σ i * + (f I (X (ω i).1) - f I (X (ω i).2)) + c I))] := by apply Eq.symm apply integral_map · apply Measurable.aemeasurable @@ -684,9 +745,11 @@ theorem symmetrization_equation [Countable ι] [Nonempty ι] (h𝓕 : ∀ I : ι simp only [Finset.sum_sub_distrib, inv_pow, Int.reduceNeg] exact this -lemma sup_abs_lemma [Nonempty ι] {V : (Z → ℝ) → ℝ} (hV₀: ∀ f, V (-f) = - (V f)) (hV₁: BddAbove (Set.range fun i ↦ |V (f i)|)): +lemma sup_abs_lemma [Nonempty ι] {V : (Z → ℝ) → ℝ} (hV₀: ∀ f, V (-f) = - (V f)) + (hV₁: BddAbove (Set.range fun i ↦ |V (f i)|)): ⨆ i : ι, |V (f i)| = ⨆ i : Fin 2 × ι, V (if i.1.1 == 0 then f i.2 else -(f i.2)) := by - have hV₁' : BddAbove (Set.range fun i : Fin 2 × ι ↦ V (if i.1.1 == 0 then f i.2 else -(f i.2))) := by + have hV₁' : BddAbove (Set.range fun i : Fin 2 × ι ↦ V (if i.1.1 == 0 then f i.2 else -(f i.2))) + := by obtain ⟨a,ha⟩ := hV₁ use a dsimp [upperBounds] at * @@ -724,7 +787,8 @@ theorem abs_symmetrization_equation [Countable ι] [Nonempty ι] (h𝓕 : ∀ I (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω ↦ ⨆ I : ι, |∑ i : Fin n, (f I (X (ω i).1) - f I (X (ω i).2))|] = (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω - ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : ι, |∑ i : Fin n, σ i * (f I (X (ω i).1) - f I (X (ω i).2))|]:= by + ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : ι, |∑ i : Fin n, σ i * + (f I (X (ω i).1) - f I (X (ω i).2))|]:= by let f' : (Fin 2 × ι) → Z → ℝ := fun i ↦ if i.1.1 == 0 then f i.2 else -(f i.2) calc _ = (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω @@ -748,7 +812,8 @@ theorem abs_symmetrization_equation [Countable ι] [Nonempty ι] (h𝓕 : ∀ I exact bound_lem h𝓕' ω I exact sup_abs_lemma hV₀ hV₁ _ = (MeasureTheory.Measure.pi (fun _ ↦ μ.prod μ))[fun ω : Fin n → Ω × Ω - ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : Fin 2 × ι, ∑ i : Fin n, σ i * (f' I (X (ω i).1) - f' I (X (ω i).2))]:= by + ↦ 2⁻¹ ^ n * ∑ σ : Signs n, ⨆ I : Fin 2 × ι, ∑ i : Fin n, σ i * + (f' I (X (ω i).1) - f' I (X (ω i).2))]:= by have h𝓕₂ : ∀ I, Measurable (f' I ∘ X) := by dsimp [f'] rintro ⟨s, I⟩ diff --git a/StatsMLlib/LearningTheory/UniformDeviation/Bounds.lean b/StatsMLlib/LearningTheory/UniformDeviation/Bounds.lean index db11a62..5b21893 100644 --- a/StatsMLlib/LearningTheory/UniformDeviation/Bounds.lean +++ b/StatsMLlib/LearningTheory/UniformDeviation/Bounds.lean @@ -45,7 +45,8 @@ theorem uniform_deviation_expectation_le_two_smul_rademacher_complexity (hn : 0 < n) (X : Ω → 𝒳) (hf : ∀ i, Measurable (f i ∘ X)) {b : ℝ} (hb : 0 ≤ b) (hf' : ∀ i x, |f i x| ≤ b) : - μⁿ[fun ω : Fin n → Ω ↦ uniformDeviation n f μ X (X ∘ ω)] ≤ 2 * rademacherComplexity n f μ X := by + μⁿ[fun ω : Fin n → Ω ↦ uniformDeviation n f μ X (X ∘ ω)] ≤ 2 * rademacherComplexity n f μ X + := by apply le_of_mul_le_mul_left _ (Nat.cast_pos.mpr hn) calc (n : ℝ) * μⁿ[fun ω : Fin n → Ω ↦ uniformDeviation n f μ X (X ∘ ω)] = @@ -122,7 +123,8 @@ theorem uniform_deviation_tail_bound_countable intro ω h have : 2 * rademacherComplexity n f μ X + ε ≤ uniformDeviation n f μ X (X ∘ ω) := h have : μⁿ[fun ω ↦ uniformDeviation n f μ X (X ∘ ω)] ≤ 2 * rademacherComplexity n f μ X := - uniform_deviation_expectation_le_two_smul_rademacher_complexity hn X (fun i ↦ (hf i).comp hX) hb hf' + uniform_deviation_expectation_le_two_smul_rademacher_complexity hn X (fun i ↦ + (hf i).comp hX) hb hf' show ε ≤ uniformDeviation n f μ X (X ∘ ω) - μⁿ[fun ω ↦ uniformDeviation n f μ X (X ∘ ω)] linarith @@ -192,7 +194,8 @@ lemma uniformDeviation_eq apply Measurable.aestronglyMeasurable measurability -/-- (Main Theorem) Separable-class tail bound obtained via reduction to a countable dense subclass. -/ +/-- (Main Theorem) Separable-class tail bound obtained via reduction to a countable dense +subclass. -/ theorem uniform_deviation_tail_bound_separable [MeasurableSpace 𝒳] [Nonempty 𝒳] [Nonempty ι] [TopologicalSpace ι] [SeparableSpace ι] [FirstCountableTopology ι] @@ -207,7 +210,8 @@ theorem uniform_deviation_tail_bound_separable (- ε ^ 2 * t * n).exp := by let f' := f ∘ denseSeq ι calc - _ = (μⁿ (fun ω ↦ 2 * rademacherComplexity n f' μ X + ε ≤ uniformDeviation n f' μ X (X ∘ ω))).toReal := by + _ = (μⁿ (fun ω ↦ 2 * rademacherComplexity n f' μ X + ε ≤ + uniformDeviation n f' μ X (X ∘ ω))).toReal := by congr ext ω rw [RademacherComplexity_eq n f hf'' μ X] From 39c3375ccb1a818b38bf91cd25104b80a61556c4 Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:22 +0900 Subject: [PATCH 6/7] Fix style linter warnings in Statistics, Analysis, Topology and LinearAlgebra Wrap lines over 100 characters and fix the other style linter warnings (`refine'`, focusing dots, missing `end`) reported once the linter option names in `lakefile.lean` are corrected. Formatting only; no statement changes. Part of #71. Co-Authored-By: Claude Opus 5.5 --- StatsMLlib/Analysis/MetricEntropy/Basic.lean | 15 ++- .../Analysis/MetricEntropy/Chaining.lean | 10 +- .../NormedSpace/CoveringNumber/Euclidean.lean | 43 ++++--- .../NormedSpace/CoveringNumber/L1.lean | 76 ++++++++---- .../LinearAlgebra/Matrix/CourantFischer.lean | 14 ++- StatsMLlib/LinearAlgebra/Matrix/Lieb.lean | 3 +- .../LinearAlgebra/Matrix/SingularValue.lean | 3 +- .../LeastSquares/L1/CoveringBound.lean | 66 +++++++---- .../LeastSquares/L1/LocalizedBall.lean | 6 +- .../LeastSquares/L1/PredictorClass.lean | 3 +- .../LeastSquares/Linear/DesignMatrix.lean | 6 +- .../LeastSquares/Linear/EmpiricalProcess.lean | 60 ++++++---- .../LeastSquares/Linear/EntropyIntegral.lean | 111 ++++++++++++------ .../Linear/EuclideanReduction.lean | 45 ++++--- .../Linear/GaussianComplexity.lean | 36 ++++-- .../LeastSquares/Linear/IntegralBounds.lean | 6 +- .../LeastSquares/Linear/LocalizedBall.lean | 6 +- .../LeastSquares/Linear/MinimaxRate.lean | 65 ++++++---- .../LeastSquares/Linear/PredictorClass.lean | 3 +- .../LeastSquares/LocalGaussianComplexity.lean | 73 ++++++++---- .../Regression/LeastSquares/Localization.lean | 15 ++- .../LeastSquares/MasterErrorBound.lean | 75 ++++++++---- .../LeastSquares/SubGaussianity.lean | 3 +- .../MetricSpace/CoveringNumber/Basic.lean | 19 ++- .../Topology/SeparableSpace/Supremum.lean | 11 +- 25 files changed, 512 insertions(+), 261 deletions(-) diff --git a/StatsMLlib/Analysis/MetricEntropy/Basic.lean b/StatsMLlib/Analysis/MetricEntropy/Basic.lean index c54046e..2847b5c 100644 --- a/StatsMLlib/Analysis/MetricEntropy/Basic.lean +++ b/StatsMLlib/Analysis/MetricEntropy/Basic.lean @@ -52,7 +52,8 @@ lemma metricEntropyOfNat_nonneg (n : ℕ) : 0 ≤ metricEntropyOfNat n := by · push Not at hn exact Real.log_nonneg (Nat.one_le_cast.mpr (Nat.one_le_of_lt hn)) -lemma metricEntropyOfNat_mono {n m : ℕ} (h : n ≤ m) : metricEntropyOfNat n ≤ metricEntropyOfNat m := by +lemma metricEntropyOfNat_mono {n m : ℕ} (h : n ≤ m) : + metricEntropyOfNat n ≤ metricEntropyOfNat m := by unfold metricEntropyOfNat split_ifs with hn hm hm · exact le_rfl @@ -296,7 +297,8 @@ lemma sqrt_log_card_le_sqrtEntropy_of_card_le {eps : ℝ} {s : Set A} {n : ℕ} interval_cases n · simp · simp - have hlog_m : 0 ≤ Real.log (m : ℝ) := Real.log_nonneg (Nat.one_le_cast.mpr (by omega : 1 ≤ m)) + have hlog_m : 0 ≤ Real.log (m : ℝ) := + Real.log_nonneg (Nat.one_le_cast.mpr (by omega : 1 ≤ m)) linarith · -- n > 1: use log monotonicity push Not at hn1 @@ -331,11 +333,13 @@ lemma sqrt_log_mul_le {a b : ℕ} (ha : 1 ≤ a) (hb : 1 ≤ b) : have hsq_a : Real.sqrt (Real.log (a : ℝ))^2 = Real.log (a : ℝ) := Real.sq_sqrt hlog_a_nonneg have hsq_b : Real.sqrt (Real.log (b : ℝ))^2 = Real.log (b : ℝ) := Real.sq_sqrt hlog_b_nonneg have hsq : (Real.sqrt (Real.log (a : ℝ)) + Real.sqrt (Real.log (b : ℝ)))^2 = - Real.log (a : ℝ) + 2 * Real.sqrt (Real.log (a : ℝ)) * Real.sqrt (Real.log (b : ℝ)) + Real.log (b : ℝ) := by + Real.log (a : ℝ) + 2 * Real.sqrt (Real.log (a : ℝ)) * Real.sqrt (Real.log (b : ℝ)) + + Real.log (b : ℝ) := by ring_nf rw [hsq_a, hsq_b] rw [hsq] - have h_cross_nonneg : 0 ≤ 2 * Real.sqrt (Real.log (a : ℝ)) * Real.sqrt (Real.log (b : ℝ)) := by positivity + have h_cross_nonneg : + 0 ≤ 2 * Real.sqrt (Real.log (a : ℝ)) * Real.sqrt (Real.log (b : ℝ)) := by positivity linarith calc Real.sqrt (Real.log (a : ℝ) + Real.log (b : ℝ)) _ ≤ Real.sqrt ((Real.sqrt (Real.log a) + Real.sqrt (Real.log b))^2) := Real.sqrt_le_sqrt key @@ -859,7 +863,8 @@ lemma entropyIntegralENNRealTrunc_le_dyadic_sum_strong have hhalf_le_D : D / 2 ≤ D := by linarith have hhalf_pos : 0 < D / 2 := by linarith -- Split the integral - -- Note: goal has `let δ := D * 2 ^ (-↑(n' + 1 + 1))` which equals our local δ = D * 2 ^ (-↑(n' + 2)) + -- Note: goal has `let δ := D * 2 ^ (-↑(n' + 1 + 1))` which equals our local + -- δ = D * 2 ^ (-↑(n' + 2)) -- n' + 1 + 1 = n' + 2 definitionally, so we can just intro and use the split directly intro δ' have hδ'_eq : δ' = δ := rfl diff --git a/StatsMLlib/Analysis/MetricEntropy/Chaining.lean b/StatsMLlib/Analysis/MetricEntropy/Chaining.lean index caa117b..105fbed 100644 --- a/StatsMLlib/Analysis/MetricEntropy/Chaining.lean +++ b/StatsMLlib/Analysis/MetricEntropy/Chaining.lean @@ -70,15 +70,16 @@ theorem exists_dyadicNets {s : Set A} (hs : TotallyBounded s) {D : ℝ} (hD : 0 /-- DyadicNets with cardinality bounds: each net at scale k has cardinality bounded by the covering number at the next finer scale (k+1). This bound is crucial for relating chaining arguments to covering numbers in Dudley's theorem. -/ -structure GoodDyadicNets (s : Set A) (D : ℝ) (hD : 0 < D) (hs : TotallyBounded s) extends DyadicNets s D where +structure GoodDyadicNets (s : Set A) (D : ℝ) (hD : 0 < D) (hs : TotallyBounded s) + extends DyadicNets s D where /-- Each net at scale k has cardinality ≤ coveringNumber at scale k+1 -/ card_bound : ∀ k, (nets k).card ≤ (coveringNumber (dyadicScale D (k + 1)) s).untop (ne_top_of_lt (coveringNumber_lt_top_of_totallyBounded (dyadicScale_pos hD (k + 1)) hs)) /-- Good dyadic nets exist for nonempty totally bounded sets. The key insight: use exists_enet_subset_from_half at each scale, which gives an eps-net - inside s with cardinality ≤ coveringNumber(eps/2). Since dyadicScale D k / 2 = dyadicScale D (k+1), - this gives the desired cardinality bound. -/ + inside s with cardinality ≤ coveringNumber(eps/2). Since + dyadicScale D k / 2 = dyadicScale D (k+1), this gives the desired cardinality bound. -/ theorem exists_goodDyadicNets {s : Set A} (hs : TotallyBounded s) (hsne : s.Nonempty) {D : ℝ} (hD : 0 < D) : Nonempty (GoodDyadicNets s D hD hs) := by @@ -116,7 +117,8 @@ lemma exists_near_in_net {t : Finset A} {eps : ℝ} {s : Set A} /-- The chaining approximation: for any point x and any level K, there exists a sequence of approximations through the nets. -/ -theorem chaining_approximation {s : Set A} {D : ℝ} (dn : DyadicNets s D) {x : A} (hx : x ∈ s) (K : ℕ) : +theorem chaining_approximation {s : Set A} {D : ℝ} (dn : DyadicNets s D) {x : A} (hx : x ∈ s) + (K : ℕ) : ∃ y ∈ dn.nets K, dist x y ≤ dyadicScale D K := exists_near_in_net (dn.isNet K) hx diff --git a/StatsMLlib/Analysis/NormedSpace/CoveringNumber/Euclidean.lean b/StatsMLlib/Analysis/NormedSpace/CoveringNumber/Euclidean.lean index 276efd1..4402148 100644 --- a/StatsMLlib/Analysis/NormedSpace/CoveringNumber/Euclidean.lean +++ b/StatsMLlib/Analysis/NormedSpace/CoveringNumber/Euclidean.lean @@ -36,12 +36,14 @@ abbrev euclideanBall (R : ℝ) : Set (EuclideanSpace ℝ ι) := Metric.closedBal omit [Nonempty ι] in /-- The Euclidean ball is totally bounded (since it's compact in finite dimensions). -/ -lemma euclideanBall_totallyBounded (R : ℝ) : TotallyBounded (euclideanBall R : Set (EuclideanSpace ℝ ι)) := +lemma euclideanBall_totallyBounded (R : ℝ) : + TotallyBounded (euclideanBall R : Set (EuclideanSpace ℝ ι)) := (ProperSpace.isCompact_closedBall 0 R).totallyBounded omit [Nonempty ι] in /-- The Euclidean ball is nonempty for non-negative radius. -/ -lemma euclideanBall_nonempty {R : ℝ} (hR : 0 ≤ R) : (euclideanBall R : Set (EuclideanSpace ℝ ι)).Nonempty := +lemma euclideanBall_nonempty {R : ℝ} (hR : 0 ≤ R) : + (euclideanBall R : Set (EuclideanSpace ℝ ι)).Nonempty := ⟨0, Metric.mem_closedBall_self hR⟩ /-- If points x and y are ε-separated (dist x y > ε), then the closed balls of radius ε/2 @@ -62,7 +64,8 @@ lemma packing_halfBalls_pairwiseDisjoint {E : Type*} [PseudoMetricSpace E] have hsep := hpacking.2 hx hy hxy exact closedBall_half_disjoint heps hsep -/-- A half-radius ball around a point in closedBall(0, R) is contained in closedBall(0, R + eps/2). -/ +/-- A half-radius ball around a point in closedBall(0, R) is contained in +closedBall(0, R + eps/2). -/ lemma halfBall_subset_enlargedBall {E : Type*} [SeminormedAddCommGroup E] {x : E} {R eps : ℝ} (hx : x ∈ Metric.closedBall (0 : E) R) : Metric.closedBall x (eps / 2) ⊆ Metric.closedBall (0 : E) (R + eps / 2) := by @@ -162,12 +165,14 @@ lemma packing_card_bound_aux ENNReal.ofReal ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := fun x => volume_closedBall_eq_rpow x (eps / 2) heps_half_nonneg -- Volume of large ball - have hvol_large : MeasureTheory.volume (Metric.closedBall (0 : EuclideanSpace ℝ ι) (R + eps / 2)) = + have hvol_large : + MeasureTheory.volume (Metric.closedBall (0 : EuclideanSpace ℝ ι) (R + eps / 2)) = ENNReal.ofReal ((R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := volume_closedBall_eq_rpow 0 (R + eps / 2) hR_plus_pos -- Sum of small ball volumes have hvol_sum : ∑ x ∈ t, MeasureTheory.volume (Metric.closedBall x (eps / 2)) = - t.card * ENNReal.ofReal ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := by + t.card * ENNReal.ofReal + ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := by simp only [hvol_small] rw [sum_const] simp only [nsmul_eq_mul] @@ -178,13 +183,18 @@ lemma packing_card_bound_aux have hconst_pos := euclideanBallVolumeConst_pos (Fintype.card ι) have hsmall_pos : 0 < (eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := mul_pos (pow_pos heps_half_pos _) hconst_pos - have hlarge_pos : 0 < (R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := + have hlarge_pos : + 0 < (R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := mul_pos (pow_pos (by linarith : 0 < R + eps / 2) _) hconst_pos - have hlarge_nonneg : 0 ≤ (R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := + have hlarge_nonneg : + 0 ≤ (R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := le_of_lt hlarge_pos -- Use ENNReal.ofReal for the bound - have h : t.card * ENNReal.ofReal ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) ≤ - ENNReal.ofReal ((R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := hvol_le + have h : + t.card * ENNReal.ofReal + ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) ≤ + ENNReal.ofReal ((R + eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) := + hvol_le rw [← ENNReal.ofReal_natCast] at h rw [← ENNReal.ofReal_mul (Nat.cast_nonneg _)] at h have h' := ENNReal.ofReal_le_ofReal_iff hlarge_nonneg |>.mp h @@ -194,7 +204,8 @@ lemma packing_card_bound_aux have hcancel : (t.card : ℝ) ≤ (R + eps / 2) ^ Fintype.card ι / (eps / 2) ^ Fintype.card ι := by have hne : (eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) ≠ 0 := ne_of_gt hsmall_pos - have hsmall_nonneg : 0 ≤ (eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := + have hsmall_nonneg : + 0 ≤ (eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι) := le_of_lt hsmall_pos calc (t.card : ℝ) _ = t.card * ((eps / 2) ^ Fintype.card ι * euclideanBallVolumeConst (Fintype.card ι)) / @@ -241,7 +252,8 @@ lemma separated_finite_of_totallyBounded {E : Type*} [PseudoMetricSpace E] t.Finite := by -- If s is covered by finitely many ε/2-balls, any ε-separated set has bounded cardinality have heps2 : 0 < eps / 2 := by linarith - obtain ⟨cover, _, hcover_finite, hcover⟩ := Metric.finite_approx_of_totallyBounded hs (eps / 2) heps2 + obtain ⟨cover, _, hcover_finite, hcover⟩ := + Metric.finite_approx_of_totallyBounded hs (eps / 2) heps2 -- Each ε/2-ball can contain at most one point from t -- Define a function from t to cover: for each x ∈ t, pick a c ∈ cover with x ∈ ball(c, eps/2) classical @@ -265,7 +277,8 @@ lemma separated_finite_of_totallyBounded {E : Type*} [PseudoMetricSpace E] have hsep_xy := ht_sep hx hy hxy have hdist : dist x y < eps := by have heq' : (hmaps x hx).choose = (hmaps y hy).choose := heq - calc dist x y ≤ dist x (hmaps x hx).choose + dist (hmaps x hx).choose y := dist_triangle _ _ _ + calc dist x y ≤ dist x (hmaps x hx).choose + dist (hmaps x hx).choose y := + dist_triangle _ _ _ _ < eps / 2 + eps / 2 := by apply add_lt_add · exact Metric.mem_ball.mp hxc @@ -285,7 +298,8 @@ lemma exists_maximal_packing {E : Type*} [PseudoMetricSpace E] classical -- Get the cover that bounds packing sizes have heps2 : 0 < eps / 2 := by linarith - obtain ⟨cover, _, hcover_finite, hcover⟩ := Metric.finite_approx_of_totallyBounded hs (eps / 2) heps2 + obtain ⟨cover, _, hcover_finite, hcover⟩ := + Metric.finite_approx_of_totallyBounded hs (eps / 2) heps2 -- Any packing has size at most |cover| have hbound : ∀ t : Finset E, IsPacking t eps s → t.card ≤ cover.ncard := by intro t ht @@ -308,7 +322,8 @@ lemma exists_maximal_packing {E : Type*} [PseudoMetricSpace E] have hsep_xy := ht_sep hx hy hxy have heq' : (hmaps x hx).choose = (hmaps y hy).choose := heq have hdist : dist x y < eps := by - calc dist x y ≤ dist x (hmaps x hx).choose + dist (hmaps x hx).choose y := dist_triangle _ _ _ + calc dist x y ≤ dist x (hmaps x hx).choose + dist (hmaps x hx).choose y := + dist_triangle _ _ _ _ < eps / 2 + eps / 2 := by apply add_lt_add · exact Metric.mem_ball.mp hxc diff --git a/StatsMLlib/Analysis/NormedSpace/CoveringNumber/L1.lean b/StatsMLlib/Analysis/NormedSpace/CoveringNumber/L1.lean index bba2313..6b07617 100644 --- a/StatsMLlib/Analysis/NormedSpace/CoveringNumber/L1.lean +++ b/StatsMLlib/Analysis/NormedSpace/CoveringNumber/L1.lean @@ -41,7 +41,8 @@ variable {d : ℕ} -- MeasurableSpace for Option (Fin d) using discrete sigma-algebra instance instMeasurableSpaceOptionFin (d : ℕ) : MeasurableSpace (Option (Fin d)) := ⊤ -instance instMeasurableSingletonClassOptionFin (d : ℕ) : MeasurableSingletonClass (Option (Fin d)) := +instance instMeasurableSingletonClassOptionFin (d : ℕ) : + MeasurableSingletonClass (Option (Fin d)) := ⟨fun _ => trivial⟩ -- L1 norm on EuclideanSpace ℝ (Fin d) @@ -62,7 +63,8 @@ lemma sgn_sq (x : ℝ) : sgn x ^ 2 = 1 := by by_cases hx : 0 ≤ x <;> simp [sgn, hx] -- vector-valued random variable depending on θ -noncomputable def vecθ (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) : Option (Fin d) → EuclideanSpace ℝ (Fin d) +noncomputable def vecθ (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) : + Option (Fin d) → EuclideanSpace ℝ (Fin d) | none => 0 | some j => EuclideanSpace.single j (R * sgn (θ j)) @@ -212,7 +214,8 @@ lemma l1pmf_second_moment_coord (θ : EuclideanSpace ℝ (Fin d)) {R : ℝ} (hR -- Simplify nested if with same condition have hsum_simp : ∀ x, (if j = x then (if j = x then ((l1pmf θ R hθ) (some x)).toReal • (R * sgn (θ x) * (R * sgn (θ x))) else 0) else 0) = - (if j = x then ((l1pmf θ R hθ) (some x)).toReal • (R * sgn (θ x) * (R * sgn (θ x))) else 0) := by + (if j = x then ((l1pmf θ R hθ) (some x)).toReal • (R * sgn (θ x) * (R * sgn (θ x))) + else 0) := by intro x; split_ifs <;> rfl simp only [hsum_simp] rw [Finset.sum_ite_eq Finset.univ j (fun x => _ • ((R * sgn (θ x)) * (R * sgn (θ x))))] @@ -325,7 +328,8 @@ lemma exists_avgθ_close (θ : EuclideanSpace ℝ (Fin d)) {R eps : ℝ} (hR : 0 calc ∫ ω, ((avgθ θ R k ω).ofLp j - θ.ofLp j) ^ 2 ∂ν ≤ (k : ℝ)⁻¹ * (∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ) := by -- Define centered random variable - let Y := fun i (ω : Fin k → Option (Fin d)) => (vecθ θ R (ω i)).ofLp j - θ.ofLp j + let Y := fun i (ω : Fin k → Option (Fin d)) => + (vecθ θ R (ω i)).ofLp j - θ.ofLp j have havg_Y : ∀ ω, (avgθ θ R k ω).ofLp j - θ.ofLp j = (↑k)⁻¹ * ∑ i, Y i ω := by intro ω rw [havg_coord] @@ -341,25 +345,33 @@ lemma exists_avgθ_close (θ : EuclideanSpace ℝ (Fin d)) {R eps : ℝ} (hR : 0 have hkne : (k : ℝ) ≠ 0 := ne_of_gt hkpos field_simp simp_rw [havg_Y] - have hsq_factor : ∀ ω, ((↑k)⁻¹ * ∑ i, Y i ω) ^ 2 = (↑k)⁻¹ ^ 2 * (∑ i, Y i ω) ^ 2 := by intro ω; ring + have hsq_factor : + ∀ ω, ((↑k)⁻¹ * ∑ i, Y i ω) ^ 2 = (↑k)⁻¹ ^ 2 * (∑ i, Y i ω) ^ 2 := by + intro ω; ring simp_rw [hsq_factor] rw [integral_const_mul] - have hexpand_sq : ∀ ω, (∑ i, Y i ω) ^ 2 = ∑ i, ∑ l, Y i ω * Y l ω := by intro ω; rw [sq, Finset.sum_mul_sum] + have hexpand_sq : ∀ ω, (∑ i, Y i ω) ^ 2 = ∑ i, ∑ l, Y i ω * Y l ω := by + intro ω; rw [sq, Finset.sum_mul_sum] simp_rw [hexpand_sq] rw [integral_finsetSum]; swap; · intro i _; exact Integrable.of_finite simp_rw [integral_finsetSum _ (fun _ _ => Integrable.of_finite)] -- Establish independence of Y_i under ν using iIndepFun_pi - have hindep : ProbabilityTheory.iIndepFun (fun i (ω : Fin k → Option (Fin d)) => Y i ω) ν := by + have hindep : ProbabilityTheory.iIndepFun + (fun i (ω : Fin k → Option (Fin d)) => Y i ω) ν := by simp only [Y] - have hμprob : ∀ _ : Fin k, IsProbabilityMeasure μ := fun _ => by simp only [μ]; infer_instance + have hμprob : ∀ _ : Fin k, IsProbabilityMeasure μ := fun _ => by + simp only [μ]; infer_instance -- First establish that coordinate projections are iIndepFun let f : (i : Fin k) → Option (Fin d) → Option (Fin d) := fun _ => id - have hf_meas : ∀ i, AEMeasurable (f i) μ := fun _ => measurable_id.aemeasurable - have hid := @ProbabilityTheory.iIndepFun_pi (Fin k) _ (fun _ => Option (Fin d)) _ - (fun _ => μ) hμprob (fun _ => Option (Fin d)) _ f hf_meas + have hf_meas : ∀ i, AEMeasurable (f i) μ := fun _ => + measurable_id.aemeasurable + have hid := + @ProbabilityTheory.iIndepFun_pi (Fin k) _ (fun _ => Option (Fin d)) _ + (fun _ => μ) hμprob (fun _ => Option (Fin d)) _ f hf_meas simp only [f, id_eq] at hid -- Now compose with the centering function - let g : (i : Fin k) → Option (Fin d) → ℝ := fun _ o => (vecθ θ R o).ofLp j - θ.ofLp j + let g : (i : Fin k) → Option (Fin d) → ℝ := fun _ o => + (vecθ θ R o).ofLp j - θ.ofLp j have hg_meas : ∀ i, Measurable (g i) := fun _ => measurable_of_countable _ have hcomp := hid.comp g hg_meas simp only [g] at hcomp @@ -367,28 +379,41 @@ lemma exists_avgθ_close (θ : EuclideanSpace ℝ (Fin d)) {R eps : ℝ} (hR : 0 -- Show each Y_i has mean 0 have hY_mean_zero : ∀ i, ∫ ω, Y i ω ∂ν = 0 := by intro i; simp only [Y] - have hmeas : AEStronglyMeasurable (fun o : Option (Fin d) => (vecθ θ R o).ofLp j - θ.ofLp j) μ := by + have hmeas : AEStronglyMeasurable + (fun o : Option (Fin d) => (vecθ θ R o).ofLp j - θ.ofLp j) μ := by exact Measurable.aestronglyMeasurable (measurable_of_countable _) - have heq := MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := i) hmeas - simp only [μ, ν] at heq ⊢; rw [heq, integral_sub (Integrable.of_finite) (Integrable.of_finite), hmean, integral_const] - have hμprob : IsProbabilityMeasure ((l1pmf θ R hθ).toMeasure) := by infer_instance + have heq := + MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := i) hmeas + simp only [μ, ν] at heq ⊢ + rw [heq, integral_sub (Integrable.of_finite) (Integrable.of_finite), hmean, + integral_const] + have hμprob : IsProbabilityMeasure ((l1pmf θ R hθ).toMeasure) := by + infer_instance unfold Measure.real rw [hμprob.measure_univ, ENNReal.toReal_one, smul_eq_mul, one_mul, sub_self] -- Cross terms (i ≠ l) vanish due to independence and zero mean have hcross : ∀ i l, i ≠ l → ∫ ω, Y i ω * Y l ω ∂ν = 0 := by intro i l hil; have hpair := hindep.indepFun hil - have hmeas_i : AEStronglyMeasurable (Y i) ν := Measurable.aestronglyMeasurable (measurable_of_countable _) - have hmeas_l : AEStronglyMeasurable (Y l) ν := Measurable.aestronglyMeasurable (measurable_of_countable _) - rw [ProbabilityTheory.IndepFun.integral_fun_mul_eq_mul_integral hpair hmeas_i hmeas_l, hY_mean_zero i, hY_mean_zero l, mul_zero] + have hmeas_i : AEStronglyMeasurable (Y i) ν := + Measurable.aestronglyMeasurable (measurable_of_countable _) + have hmeas_l : AEStronglyMeasurable (Y l) ν := + Measurable.aestronglyMeasurable (measurable_of_countable _) + rw [ProbabilityTheory.IndepFun.integral_fun_mul_eq_mul_integral hpair hmeas_i + hmeas_l, + hY_mean_zero i, hY_mean_zero l, mul_zero] -- Diagonal terms equal single-sample variance - have hdiag : ∀ i, ∫ ω, Y i ω * Y i ω ∂ν = ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by + have hdiag : ∀ i, + ∫ ω, Y i ω * Y i ω ∂ν = ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by intro i; simp only [Y] - have hmeas : AEStronglyMeasurable (fun o : Option (Fin d) => ((vecθ θ R o).ofLp j - θ.ofLp j)^2) μ := by + have hmeas : AEStronglyMeasurable + (fun o : Option (Fin d) => ((vecθ θ R o).ofLp j - θ.ofLp j)^2) μ := by exact Measurable.aestronglyMeasurable (measurable_of_countable _) - have heq := MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := i) hmeas + have heq := + MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := i) hmeas simp only [μ, ν] at heq ⊢; convert heq using 2; ext ω; ring -- Simplify sum: only diagonal terms survive - have hsum_eq : ∑ i : Fin k, ∑ l : Fin k, ∫ ω, Y i ω * Y l ω ∂ν = ∑ i : Fin k, ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by + have hsum_eq : ∑ i : Fin k, ∑ l : Fin k, ∫ ω, Y i ω * Y l ω ∂ν = + ∑ i : Fin k, ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by congr 1; ext i rw [Finset.sum_eq_single (a := i)] · exact hdiag i @@ -396,8 +421,9 @@ lemma exists_avgθ_close (θ : EuclideanSpace ℝ (Fin d)) {R eps : ℝ} (hR : 0 · intro hi; exact (hi (Finset.mem_univ i)).elim rw [hsum_eq, Finset.sum_const, Finset.card_fin] -- Now k⁻² * (k * ∫ ...) = k⁻¹ * ∫ ... - have halg : ((↑k)⁻¹ : ℝ) ^ 2 * (↑k * ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ) = - (↑k)⁻¹ * ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by + have halg : + ((↑k)⁻¹ : ℝ) ^ 2 * (↑k * ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ) = + (↑k)⁻¹ * ∫ o, ((vecθ θ R o).ofLp j - θ.ofLp j)^2 ∂μ := by have hkne : (k : ℝ) ≠ 0 := ne_of_gt hkpos field_simp rw [nsmul_eq_mul, halg] diff --git a/StatsMLlib/LinearAlgebra/Matrix/CourantFischer.lean b/StatsMLlib/LinearAlgebra/Matrix/CourantFischer.lean index dce92f3..760eff3 100644 --- a/StatsMLlib/LinearAlgebra/Matrix/CourantFischer.lean +++ b/StatsMLlib/LinearAlgebra/Matrix/CourantFischer.lean @@ -472,13 +472,15 @@ theorem bddBelow_range_singularQuotientOn [FiniteDimensional 𝕜 E] rintro _ ⟨x, rfl⟩ exact hC ⟨⟨(x : E), x.property⟩, rfl⟩ -/-- The restricted singular-quotient infimum is bounded above by every nonzero vector in the subspace. -/ +/-- The restricted singular-quotient infimum is bounded above by every nonzero vector in the +subspace. -/ theorem minSingularQuotientOn_le_of_mem [FiniteDimensional 𝕜 E] (T : E →ₗ[𝕜] F) {U : Submodule 𝕜 E} {x : E} (hxU : x ∈ U) (hx0 : x ≠ 0) : minSingularQuotientOn T U ≤ singularQuotient T x := by exact ciInf_le (bddBelow_range_singularQuotientOn T U) ⟨⟨x, hxU⟩, hx0⟩ -/-- The restricted singular-quotient supremum is bounded below by every nonzero vector in the subspace. -/ +/-- The restricted singular-quotient supremum is bounded below by every nonzero vector in the +subspace. -/ theorem le_maxSingularQuotientOn_of_mem [FiniteDimensional 𝕜 E] (T : E →ₗ[𝕜] F) {U : Submodule 𝕜 E} {x : E} (hxU : x ∈ U) (hx0 : x ≠ 0) : singularQuotient T x ≤ maxSingularQuotientOn T U := by @@ -1138,7 +1140,8 @@ theorem hasEigenvalue_iInf_rayleigh [Nontrivial E] (hT : T.IsSymmetric) : (⨅ x : { x : E // x ≠ 0 }, RCLike.re ⟪T x, x⟫ / ‖(x : E)‖ ^ 2 : ℝ) := hT.hasEigenvalue_iInf_of_finiteDimensional -/-- Eigenvectors in the sorted orthonormal eigenbasis attain their eigenvalues as Rayleigh quotients. -/ +/-- Eigenvectors in the sorted orthonormal eigenbasis attain their eigenvalues as Rayleigh +quotients. -/ theorem rayleighQuotient_eigenvectorBasis {n : ℕ} (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) (i : Fin n) : LinearMap.rayleighQuotient T (hT.eigenvectorBasis hn i) = @@ -1421,9 +1424,8 @@ theorem singularValues_eq_singularCourantFischerMaxMin_succ exact le_ciSup hbd ⟨L, hLdim⟩ · unfold singularCourantFischerMaxMin refine ciSup_le fun U => ?_ - obtain ⟨x, hxU, hxTrailing, hx0⟩ := - T.isSymmetric_adjoint_comp_self.exists_ne_zero_mem_inf_trailingEigenSubspace_of_finrank_eq_succ - hn i U U.property + obtain ⟨x, hxU, hxTrailing, hx0⟩ := T.isSymmetric_adjoint_comp_self + |>.exists_ne_zero_mem_inf_trailingEigenSubspace_of_finrank_eq_succ hn i U U.property exact (minSingularQuotientOn_le_of_mem T hxU hx0).trans (singularQuotient_le_singularValues_of_mem_gram_trailingEigenSubspace T hn i hxTrailing hx0) diff --git a/StatsMLlib/LinearAlgebra/Matrix/Lieb.lean b/StatsMLlib/LinearAlgebra/Matrix/Lieb.lean index 919723d..b17da5a 100644 --- a/StatsMLlib/LinearAlgebra/Matrix/Lieb.lean +++ b/StatsMLlib/LinearAlgebra/Matrix/Lieb.lean @@ -96,7 +96,8 @@ variable {n : Type*} [Fintype n] [DecidableEq n] /-! ## CStar bridge for real matrices -/ -/-- The entrywise inclusion from real matrices to complex matrices as a star algebra homomorphism. -/ +/-- The entrywise inclusion from real matrices to complex matrices as a star algebra +homomorphism. -/ noncomputable def realMatrixToComplexMatrixStarAlgHom : Matrix n n ℝ →⋆ₐ[ℝ] Matrix n n ℂ := { (RCLike.ofRealStarAlgHom ℂ).toAlgHom.mapMatrix with diff --git a/StatsMLlib/LinearAlgebra/Matrix/SingularValue.lean b/StatsMLlib/LinearAlgebra/Matrix/SingularValue.lean index 0f17cd4..e30523e 100644 --- a/StatsMLlib/LinearAlgebra/Matrix/SingularValue.lean +++ b/StatsMLlib/LinearAlgebra/Matrix/SingularValue.lean @@ -479,7 +479,8 @@ theorem conjTranspose_mul_self_eq_sum_sq_singularValue_vecMulVec [DecidableEq m] Aᴴ * A = ∑ i : Fin (Fintype.card n), ((A.singularValues i ^ 2 : ℝ) : 𝕜) • - Matrix.vecMulVec (A.rightSingularVectorBasis i) (star (A.rightSingularVectorBasis i)) := by + Matrix.vecMulVec (A.rightSingularVectorBasis i) + (star (A.rightSingularVectorBasis i)) := by apply Matrix.toEuclideanLin.injective apply LinearMap.ext intro x diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/L1/CoveringBound.lean b/StatsMLlib/Statistics/Regression/LeastSquares/L1/CoveringBound.lean index cf85ce8..a292b39 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/L1/CoveringBound.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/L1/CoveringBound.lean @@ -265,7 +265,8 @@ lemma maureySign_sq (x : ℝ) : maureySign x ^ 2 = 1 := by This is the unbiasedness property of Maurey's random variable. -/ lemma maureyPMF_mean_coord (x : Fin n → EuclideanSpace ℝ (Fin d)) (θ : EuclideanSpace ℝ (Fin d)) {R : ℝ} (hR : 0 < R) (hθ : l1norm θ ≤ R) (i : Fin n) : - ∫ o, maureyVec x R o i ∂(maureyPMF θ R hθ).toMeasure = (1 / Real.sqrt n) * @inner ℝ _ _ θ (x i) := by + ∫ o, maureyVec x R o i ∂(maureyPMF θ R hθ).toMeasure = + (1 / Real.sqrt n) * @inner ℝ _ _ θ (x i) := by classical rw [PMF.integral_eq_sum, Fintype.sum_option] -- The none term contributes 0 @@ -280,7 +281,8 @@ lemma maureyPMF_mean_coord (x : Fin n → EuclideanSpace ℝ (Fin d)) -- For each j, only one of (j, true) and (j, false) contributes -- The expression after simp is: (R * (if b then 1 else -1)) / √n * (x i).ofLp j have hsum_eq : ∑ j : Fin d, ∑ b : Bool, - (maureyPMF θ R hθ (some (j, b))).toReal * ((R * (if b then 1 else -1)) / Real.sqrt n * (x i) j) = + (maureyPMF θ R hθ (some (j, b))).toReal * + ((R * (if b then 1 else -1)) / Real.sqrt n * (x i) j) = ∑ j : Fin d, (‖θ j‖ / R) * (R / Real.sqrt n * maureySign (θ j) * (x i) j) := by congr 1 ext j @@ -298,7 +300,8 @@ lemma maureyPMF_mean_coord (x : Fin n → EuclideanSpace ℝ (Fin d)) simp only [hj, decide_false, Bool.false_eq_true, ↓reduceIte, Bool.true_eq_false, ENNReal.toReal_zero, ENNReal.toReal_ofReal (div_nonneg (norm_nonneg _) (le_of_lt hR))] - -- Simplify: 0 * ... + ‖θ j‖/R * (R * (-1) / √n * (x i) j) = ‖θ j‖/R * (R / √n * (-1) * (x i) j) + -- Simplify: 0 * ... + ‖θ j‖/R * (R * (-1) / √n * (x i) j) + -- = ‖θ j‖/R * (R / √n * (-1) * (x i) j) have hsign : maureySign (θ j) = -1 := by simp [maureySign, hj] rw [hsign, zero_mul, zero_add] ring @@ -329,7 +332,8 @@ lemma maureyPMF_variance_bound (x : Fin n → EuclideanSpace ℝ (Fin d)) classical rw [PMF.integral_eq_sum, Fintype.sum_option] simp only [maureyVec_none, sq, smul_eq_mul] - have hzero_term : (maureyPMF θ R hθ none).toReal * ∑ i : Fin n, (0 : EmpiricalSpace n) i * (0 : EmpiricalSpace n) i = 0 := by + have hzero_term : (maureyPMF θ R hθ none).toReal * + ∑ i : Fin n, (0 : EmpiricalSpace n) i * (0 : EmpiricalSpace n) i = 0 := by have h0 : ∀ i : Fin n, (0 : EmpiricalSpace n) i = 0 := fun _ => rfl simp only [h0, mul_zero, Finset.sum_const_zero, mul_zero] rw [hzero_term, zero_add] @@ -362,9 +366,11 @@ lemma maureyPMF_variance_bound (x : Fin n → EuclideanSpace ℝ (Fin d)) Bool.true_eq_false, ENNReal.toReal_zero, zero_mul, zero_add, ENNReal.toReal_ofReal (div_nonneg (norm_nonneg _) (le_of_lt hR))] congr 1 - have heach : ∀ i : Fin n, -(R / Real.sqrt n) * (x i).ofLp j * (-(R / Real.sqrt n) * (x i).ofLp j) = + have heach : ∀ i : Fin n, + -(R / Real.sqrt n) * (x i).ofLp j * (-(R / Real.sqrt n) * (x i).ofLp j) = R^2 / n * ((x i).ofLp j)^2 := fun i => by - have hterm : -(R / Real.sqrt n) * (x i).ofLp j = -(R / Real.sqrt n * (x i).ofLp j) := neg_mul _ _ + have hterm : -(R / Real.sqrt n) * (x i).ofLp j = -(R / Real.sqrt n * (x i).ofLp j) := + neg_mul _ _ rw [hterm, neg_mul_neg, ← sq, mul_pow, div_pow, hsqrt_sq] simp only [mul_neg_one, neg_div] simp only [heach, ← Finset.mul_sum] @@ -403,12 +409,14 @@ lemma maureyPMF_variance_bound (x : Fin n → EuclideanSpace ℝ (Fin d)) /-- Product PMF weight: the probability of sample configuration f under the product PMF. This is Π_{l < k} P(f l) where P = maureyPMF θ R. -/ -noncomputable def productPMFWeight (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) (hθ : l1norm θ ≤ R) (k : ℕ) : +noncomputable def productPMFWeight (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) (hθ : l1norm θ ≤ R) + (k : ℕ) : (Fin k → Option (Fin d × Bool)) → ℝ≥0∞ := fun f => ∏ l : Fin k, (maureyPMF θ R hθ) (f l) /-- The product PMF weights sum to 1 (it's a valid PMF). -/ -lemma productPMFWeight_sum_eq_one (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) (hθ : l1norm θ ≤ R) (k : ℕ) : +lemma productPMFWeight_sum_eq_one (θ : EuclideanSpace ℝ (Fin d)) (R : ℝ) (hθ : l1norm θ ≤ R) + (k : ℕ) : ∑ f : Fin k → Option (Fin d × Bool), productPMFWeight θ R hθ k f = 1 := by unfold productPMFWeight -- Use Fintype.sum_pow: (∑ a, f a) ^ n = ∑ p, ∏ i, f (p i) @@ -624,7 +632,8 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) have hn_pos : (0 : ℝ) < n := Nat.cast_pos.mpr hn have hkne : (k : ℝ) ≠ 0 := ne_of_gt hk_pos have hn_ge_1 : (1 : ℝ) ≤ n := Nat.one_le_cast.mpr hn - have hl1_nonneg : 0 ≤ l1norm θ := Finset.sum_nonneg (s := Finset.univ) (fun i _ => norm_nonneg (θ i)) + have hl1_nonneg : 0 ≤ l1norm θ := + Finset.sum_nonneg (s := Finset.univ) (fun i _ => norm_nonneg (θ i)) have hR_nonneg : 0 ≤ R := le_of_lt hR have hE_eq : E = ∫ f, distSq f ∂ν := by rw [MeasureTheory.integral_fintype (Integrable.of_finite : Integrable distSq ν)] @@ -636,10 +645,12 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) congr 1; ext l rw [PMF.toMeasure_apply_singleton _ (f l) (measurableSet_singleton _)] rw [Measure.real, hν_singleton] - have hdistSq_eq : ∀ f, distSq f = (1 / n : ℝ) * ∑ i : Fin n, (maureyAvg x R k f i - target i)^2 := by + have hdistSq_eq : ∀ f, + distSq f = (1 / n : ℝ) * ∑ i : Fin n, (maureyAvg x R k f i - target i)^2 := by intro f simp only [distSq] - have hdist : dist (maureyAvg x R k f) target = empiricalNorm n (maureyAvg x R k f - target) := rfl + have hdist : dist (maureyAvg x R k f) target = + empiricalNorm n (maureyAvg x R k f - target) := rfl rw [hdist] have hd := empiricalNorm_sq n (maureyAvg x R k f - target) rw [hd, one_div] @@ -679,8 +690,10 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) let g : (l : Fin k) → Option (Fin d × Bool) → ℝ := fun _ o => maureyVec x R o i - target i have hg_meas : ∀ l, Measurable (g l) := fun _ => measurable_of_countable _ - have hid := @ProbabilityTheory.iIndepFun_pi (Fin k) _ (fun _ => Option (Fin d × Bool)) _ - (fun _ => μ) hμprob' (fun _ => Option (Fin d × Bool)) _ (fun _ => id) (fun _ => measurable_id.aemeasurable) + have hid := + @ProbabilityTheory.iIndepFun_pi (Fin k) _ (fun _ => Option (Fin d × Bool)) _ + (fun _ => μ) hμprob' (fun _ => Option (Fin d × Bool)) _ (fun _ => id) + (fun _ => measurable_id.aemeasurable) simp only [id_eq] at hid have hcomp := hid.comp g hg_meas simp only [g] at hcomp @@ -689,14 +702,17 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) intro l simp only [Y] have hmeas : AEStronglyMeasurable (fun o : Option (Fin d × Bool) => - maureyVec x R o i - target i) μ := Measurable.aestronglyMeasurable (measurable_of_countable _) - have heq := MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := l) hmeas + maureyVec x R o i - target i) μ := + Measurable.aestronglyMeasurable (measurable_of_countable _) + have heq := + MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := l) hmeas simp only [μ, ν] at heq ⊢ rw [heq, MeasureTheory.integral_sub Integrable.of_finite Integrable.of_finite] rw [hmean_i, htarget_i, MeasureTheory.integral_const] simp only [smul_eq_mul, Measure.real] have hprob : ((maureyPMF θ R hθ).toMeasure Set.univ).toReal = 1 := by - have hμ_prob : IsProbabilityMeasure (maureyPMF θ R hθ).toMeasure := by infer_instance + have hμ_prob : IsProbabilityMeasure (maureyPMF θ R hθ).toMeasure := by + infer_instance rw [hμ_prob.measure_univ, ENNReal.toReal_one] rw [hprob, one_mul, sub_self] have hcross : ∀ l₁ l₂, l₁ ≠ l₂ → ∫ f, Y l₁ f * Y l₂ f ∂ν = 0 := by @@ -706,7 +722,8 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) Measurable.aestronglyMeasurable (measurable_of_countable _) have hmeas_2 : AEStronglyMeasurable (Y l₂) ν := Measurable.aestronglyMeasurable (measurable_of_countable _) - rw [ProbabilityTheory.IndepFun.integral_fun_mul_eq_mul_integral hpair hmeas_1 hmeas_2] + rw [ProbabilityTheory.IndepFun.integral_fun_mul_eq_mul_integral hpair hmeas_1 + hmeas_2] rw [hY_mean_zero l₁, hY_mean_zero l₂, mul_zero] have hdiag : ∀ l, ∫ f, Y l f * Y l f ∂ν = ∫ o, (maureyVec x R o i - target i)^2 ∂μ := by @@ -715,7 +732,8 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) have hmeas : AEStronglyMeasurable (fun o : Option (Fin d × Bool) => (maureyVec x R o i - target i)^2) μ := Measurable.aestronglyMeasurable (measurable_of_countable _) - have heq := MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := l) hmeas + have heq := + MeasureTheory.integral_comp_eval (μ := fun _ : Fin k => μ) (i := l) hmeas simp only [μ, ν] at heq ⊢ convert heq using 2 ext f; ring @@ -754,8 +772,10 @@ lemma maurey_exists_good_sample (x : Fin n → EuclideanSpace ℝ (Fin d)) _ = ∫ o, (maureyVec x R o i)^2 ∂μ - 2 * target i * ∫ o, maureyVec x R o i ∂μ + ∫ o, (target i)^2 ∂μ := by - rw [MeasureTheory.integral_add Integrable.of_finite Integrable.of_finite] - rw [MeasureTheory.integral_sub Integrable.of_finite Integrable.of_finite] + rw [MeasureTheory.integral_add Integrable.of_finite + Integrable.of_finite] + rw [MeasureTheory.integral_sub Integrable.of_finite + Integrable.of_finite] rw [MeasureTheory.integral_const_mul] _ = ∫ o, (maureyVec x R o i)^2 ∂μ - 2 * target i * target i + (target i)^2 := by @@ -863,7 +883,8 @@ lemma exists_maureyAvg_close (x : Fin n → EuclideanSpace ℝ (Fin d)) simp only [h0, Finset.sum_const_zero, mul_zero] rfl -- Since target is a let-binding, use show to make it match - show dist (maureyAvg x R k (fun _ => none)) (fun i => (1 / Real.sqrt n) * @inner ℝ _ _ θ (x i)) ≤ ε + show dist (maureyAvg x R k (fun _ => none)) + (fun i => (1 / Real.sqrt n) * @inner ℝ _ _ θ (x i)) ≤ ε rw [havg] have htgt' : (fun i => (1 / Real.sqrt n) * @inner ℝ _ _ θ (x i)) = (0 : EmpiricalSpace n) := by funext i @@ -1070,7 +1091,8 @@ lemma EmpiricalSpace_closedBall_bounded (n : ℕ) (r : ℝ) : theorem l1LocalizedBallImage_bounded {d : ℕ} {R δ : ℝ} {θ_star : EuclideanSpace ℝ (Fin d)} (x : Fin n → EuclideanSpace ℝ (Fin d)) : Bornology.IsBounded (l1EmpiricalImage x '' (l1LocalizedBall d R δ θ_star x)) := - Bornology.IsBounded.subset (EmpiricalSpace_closedBall_bounded n δ) l1EmpiricalImage_subset_closedBall + Bornology.IsBounded.subset (EmpiricalSpace_closedBall_bounded n δ) + l1EmpiricalImage_subset_closedBall /-! ## Localized ℓ₁ Ball Image Covering Bound diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/L1/LocalizedBall.lean b/StatsMLlib/Statistics/Regression/LeastSquares/L1/LocalizedBall.lean index 000c77e..c5bc946 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/L1/LocalizedBall.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/L1/LocalizedBall.lean @@ -83,7 +83,8 @@ theorem l1LocalizedBall_param_bound {d : ℕ} {R δ : ℝ} {θ_star : EuclideanS obtain ⟨Δ, hΔ_norm, hΔ_eq⟩ := l1ShiftedClass_param_bound hθ_star h_shifted exact ⟨Δ, hΔ_norm, hΔ_eq, by rw [hΔ_eq] at h_norm; exact h_norm⟩ -/-- Under column norm bound, functions in B_n(δ) correspond to Δ with ‖Δ‖₁ ≤ 2R and ‖Δ‖₁-controlled empirical norm -/ +/-- Under column norm bound, functions in B_n(δ) correspond to Δ with ‖Δ‖₁ ≤ 2R and +‖Δ‖₁-controlled empirical norm -/ theorem l1LocalizedBall_param_empirical_bound {d : ℕ} {R δ : ℝ} {θ_star : EuclideanSpace ℝ (Fin d)} (hθ_star : l1norm θ_star ≤ R) {x : Fin n → EuclideanSpace ℝ (Fin d)} @@ -142,7 +143,8 @@ lemma l1EmpiricalImage_dist_zero (x : Fin n → EuclideanSpace ℝ (Fin d)) (h : (EuclideanSpace ℝ (Fin d)) → ℝ) : dist (l1EmpiricalImage x h) (0 : EmpiricalSpace n) = empiricalNorm n (fun i => h (x i)) := by unfold dist EmpiricalSpace.instDist - show empiricalNorm n ((l1EmpiricalImage x h) - (0 : EmpiricalSpace n)) = empiricalNorm n (fun i => h (x i)) + show empiricalNorm n ((l1EmpiricalImage x h) - (0 : EmpiricalSpace n)) = + empiricalNorm n (fun i => h (x i)) congr 1 ext i -- (l1EmpiricalImage x h - 0) i = h (x i) diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/L1/PredictorClass.lean b/StatsMLlib/Statistics/Regression/LeastSquares/L1/PredictorClass.lean index 979be3e..f448743 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/L1/PredictorClass.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/L1/PredictorClass.lean @@ -116,7 +116,8 @@ lemma l1norm_add_le (θ₁ θ₂ : EuclideanSpace ℝ (Fin d)) : exact norm_add_le (θ₁ i) (θ₂ i) _ = (∑ i, ‖θ₁ i‖) + (∑ i, ‖θ₂ i‖) := Finset.sum_add_distrib -/-- Addition in l1PredictorClass: if f, g ∈ F with radii R₁, R₂, then f + g is in F with radius R₁ + R₂ -/ +/-- Addition in l1PredictorClass: if f, g ∈ F with radii R₁, R₂, then f + g is in F with +radius R₁ + R₂ -/ lemma add_mem_l1PredictorClass_of_radii {f g : (EuclideanSpace ℝ (Fin d)) → ℝ} {R₁ R₂ : ℝ} (hf : f ∈ l1PredictorClass d R₁) (hg : g ∈ l1PredictorClass d R₂) : f + g ∈ l1PredictorClass d (R₁ + R₂) := by diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/DesignMatrix.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/DesignMatrix.lean index 04ffb16..410af06 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/DesignMatrix.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/DesignMatrix.lean @@ -12,7 +12,8 @@ This file defines the design matrix multiplication and its connection to empiric ## Main Definitions -* `designMatrixMul`: The design matrix multiplication X maps θ ∈ ℝ^d to (⟨θ, x₁⟩, ..., ⟨θ, xₙ⟩) ∈ ℝ^n +* `designMatrixMul`: The design matrix multiplication X maps θ ∈ ℝ^d to + (⟨θ, x₁⟩, ..., ⟨θ, xₙ⟩) ∈ ℝ^n * `designMatrixLinearMap`: The design matrix as a linear map ## Main Results @@ -42,7 +43,8 @@ the empirical norm ‖g‖_n = (1/√n)‖Xu‖₂. /-- The design matrix multiplication: X maps θ ∈ ℝ^d to (⟨θ, x₁⟩, ..., ⟨θ, xₙ⟩) ∈ ℝ^n. We use WithLp.equiv to properly convert between Fin n → ℝ and EuclideanSpace ℝ (Fin n). -/ -noncomputable def designMatrixMul (x : Fin n → EuclideanSpace ℝ (Fin d)) (θ : EuclideanSpace ℝ (Fin d)) : +noncomputable def designMatrixMul (x : Fin n → EuclideanSpace ℝ (Fin d)) + (θ : EuclideanSpace ℝ (Fin d)) : EuclideanSpace ℝ (Fin n) := (WithLp.equiv 2 (Fin n → ℝ)).symm (fun i => @inner ℝ _ _ θ (x i)) diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EmpiricalProcess.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EmpiricalProcess.lean index a3f08d1..697bad3 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EmpiricalProcess.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EmpiricalProcess.lean @@ -14,7 +14,8 @@ restricted to the linear predictor class. ## Main Results -* `linear_innerProductProcess_continuous`: Inner product process is continuous on localized ball image +* `linear_innerProductProcess_continuous`: Inner product process is continuous on localized ball + image * `linear_empiricalProcess_sup_integrable_pos`: Positive supremum is integrable * `linear_empiricalProcess_sup_integrable_neg`: Negative supremum is integrable @@ -50,31 +51,37 @@ lemma linear_empiricalProcess_bddAbove (hn : 0 < n) by_cases hg : g ∈ localizedBall (linearPredictorClass d) δ x · simp only [ciSup_pos hg] calc transform (empiricalProcess n x g w) ≤ |empiricalProcess n x g w| := h_transform _ - _ ≤ δ / Real.sqrt n * euclideanNorm n w := empiricalProcess_le_delta_norm n hn x (linearPredictorClass d) δ hδ g hg w + _ ≤ δ / Real.sqrt n * euclideanNorm n w := + empiricalProcess_le_delta_norm n hn x (linearPredictorClass d) δ hδ g hg w · rw [ciSup_neg hg, Real.sSup_empty] apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) (euclideanNorm_nonneg _ _) -/-- Helper: AEStronglyMeasurable for biSup of transformed empirical process via lower semicontinuity. -/ +/-- Helper: AEStronglyMeasurable for biSup of transformed empirical process via lower +semicontinuity. -/ lemma linear_empiricalProcess_sup_aestronglyMeasurable (hn : 0 < n) (x : Fin n → EuclideanSpace ℝ (Fin d)) {δ : ℝ} (hδ : 0 < δ) (transform : ℝ → ℝ) (h_transform : ∀ y, transform y ≤ |y|) (h_cont : Continuous transform) : AEStronglyMeasurable (fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w)) (stdGaussianPi n) := by - set F := fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w) with hF_def + set F := fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, + transform (empiricalProcess n x g w) with hF_def set f : ((EuclideanSpace ℝ (Fin d)) → ℝ) → (Fin n → ℝ) → ℝ := fun g w => - ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), transform (empiricalProcess n x g w) with hf_def + ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), + transform (empiricalProcess n x g w) with hf_def have h_bdd : ∀ w, BddAbove (Set.range fun g => f g w) := fun w => by simpa only [hf_def] using linear_empiricalProcess_bddAbove hn x hδ transform h_transform w have h_lsc : LowerSemicontinuous F := by rw [hF_def] - have heq : (fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w)) = + have heq : (fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, + transform (empiricalProcess n x g w)) = fun w => ⨆ g, f g w := by ext w; simp only [hf_def] rw [heq] apply lowerSemicontinuous_ciSup h_bdd intro g; simp only [hf_def] by_cases hg : g ∈ localizedBall (linearPredictorClass d) δ x - · have heq2 : (fun w => ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), transform (empiricalProcess n x g w)) = + · have heq2 : (fun w => ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), + transform (empiricalProcess n x g w)) = (fun w => transform (empiricalProcess n x g w)) := by ext w; exact ciSup_pos hg rw [heq2] apply Continuous.lowerSemicontinuous @@ -82,15 +89,18 @@ lemma linear_empiricalProcess_sup_aestronglyMeasurable (hn : 0 < n) unfold empiricalProcess apply continuous_const.mul apply continuous_finsetSum _ (fun i _ => continuous_apply i |>.mul continuous_const) - · have heq2 : (fun w => ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), transform (empiricalProcess n x g w)) = + · have heq2 : (fun w => ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), + transform (empiricalProcess n x g w)) = fun _ => (0 : ℝ) := by ext w; rw [ciSup_neg hg, Real.sSup_empty] rw [heq2]; exact lowerSemicontinuous_const exact h_lsc.measurable.aestronglyMeasurable -/-- Helper: Integrability of biSup of transformed empirical process when transform(0)=0 and transform(y)≤|y|. -/ +/-- Helper: Integrability of biSup of transformed empirical process when transform(0)=0 and +transform(y)≤|y|. -/ lemma linear_empiricalProcess_sup_integrable_of_transform (hn : 0 < n) (x : Fin n → EuclideanSpace ℝ (Fin d)) {δ : ℝ} (hδ : 0 < δ) - (transform : ℝ → ℝ) (h_transform_zero : transform 0 = 0) (h_transform_le : ∀ y, transform y ≤ |y|) + (transform : ℝ → ℝ) (h_transform_zero : transform 0 = 0) + (h_transform_le : ∀ y, transform y ≤ |y|) (h_cont : Continuous transform) : Integrable (fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w)) (stdGaussianPi n) := by @@ -99,20 +109,26 @@ lemma linear_empiricalProcess_sup_integrable_of_transform (hn : 0 < n) have h0 : (0 : (EuclideanSpace ℝ (Fin d)) → ℝ) ∈ localizedBall (linearPredictorClass d) δ x := zero_mem_localizedBall_of_starShaped n (linearPredictorClass d) δ (le_of_lt hδ) x hstar -- The supremum is non-negative (since 0 ∈ ball and transform(Z(0)) = transform(0) = 0) - have h_sup_nonneg : ∀ w, 0 ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w) := by + have h_sup_nonneg : ∀ w, 0 ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, + transform (empiricalProcess n x g w) := by intro w - have hZ0 : transform (empiricalProcess n x 0 w) = 0 := by simp [empiricalProcess, h_transform_zero] + have hZ0 : transform (empiricalProcess n x 0 w) = 0 := by + simp [empiricalProcess, h_transform_zero] have hbdd := linear_empiricalProcess_bddAbove hn x hδ transform h_transform_le w calc (0 : ℝ) = transform (empiricalProcess n x 0 w) := hZ0.symm _ = ⨆ (_ : (0 : (EuclideanSpace ℝ (Fin d)) → ℝ) ∈ localizedBall (linearPredictorClass d) δ x), transform (empiricalProcess n x 0 w) := by simp [h0] - _ ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w) := le_ciSup hbdd 0 - have h_aesm := linear_empiricalProcess_sup_aestronglyMeasurable hn x hδ transform h_transform_le h_cont + _ ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, transform (empiricalProcess n x g w) := + le_ciSup hbdd 0 + have h_aesm := + linear_empiricalProcess_sup_aestronglyMeasurable hn x hδ transform h_transform_le h_cont apply hint.mono h_aesm filter_upwards with w - have h_sup_abs_nonneg : 0 ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := + have h_sup_abs_nonneg : + 0 ≤ ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := Real.iSup_nonneg (fun g => Real.iSup_nonneg (fun _ => abs_nonneg _)) - rw [Real.norm_eq_abs, abs_of_nonneg (h_sup_nonneg w), Real.norm_eq_abs, abs_of_nonneg h_sup_abs_nonneg] + rw [Real.norm_eq_abs, abs_of_nonneg (h_sup_nonneg w), Real.norm_eq_abs, + abs_of_nonneg h_sup_abs_nonneg] apply Real.iSup_le _ h_sup_abs_nonneg intro g apply Real.iSup_le _ h_sup_abs_nonneg @@ -122,14 +138,17 @@ lemma linear_empiricalProcess_sup_integrable_of_transform (hn : 0 < n) use δ / Real.sqrt n * euclideanNorm n w intro r hr; simp only [Set.mem_range] at hr; obtain ⟨g', rfl⟩ := hr by_cases hg' : g' ∈ localizedBall (linearPredictorClass d) δ x - · simp only [ciSup_pos hg']; exact empiricalProcess_le_delta_norm n hn x (linearPredictorClass d) δ hδ g' hg' w + · simp only [ciSup_pos hg'] + exact empiricalProcess_le_delta_norm n hn x (linearPredictorClass d) δ hδ g' hg' w · rw [ciSup_neg hg', Real.sSup_empty] apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) (euclideanNorm_nonneg _ _) calc transform (empiricalProcess n x g w) ≤ |empiricalProcess n x g w| := h_transform_le _ _ = |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := rfl - _ = ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := by simp [hg] - _ ≤ ⨆ g' ∈ localizedBall (linearPredictorClass d) δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g' (x i)| := le_ciSup hbdd g + _ = ⨆ (_ : g ∈ localizedBall (linearPredictorClass d) δ x), + |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := by simp [hg] + _ ≤ ⨆ g' ∈ localizedBall (linearPredictorClass d) δ x, + |(n : ℝ)⁻¹ * ∑ i, w i * g' (x i)| := le_ciSup hbdd g /-- The supremum of empirical process (positive direction) is integrable for linear predictors. -/ lemma linear_empiricalProcess_sup_integrable_pos (hn : 0 < n) @@ -143,6 +162,7 @@ lemma linear_empiricalProcess_sup_integrable_neg (hn : 0 < n) (x : Fin n → EuclideanSpace ℝ (Fin d)) {δ : ℝ} (hδ : 0 < δ) : Integrable (fun w => ⨆ g ∈ localizedBall (linearPredictorClass d) δ x, -empiricalProcess n x g w) (stdGaussianPi n) := - linear_empiricalProcess_sup_integrable_of_transform hn x hδ Neg.neg neg_zero neg_le_abs continuous_neg + linear_empiricalProcess_sup_integrable_of_transform hn x hδ Neg.neg neg_zero neg_le_abs + continuous_neg end LeastSquares diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EntropyIntegral.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EntropyIntegral.lean index c8ad3a6..10c7e24 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EntropyIntegral.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EntropyIntegral.lean @@ -76,7 +76,8 @@ lemma linearLocalizedBallImage_totallyBounded (hn : 0 < n) intro ε hε -- Get a finite cover for the image have hε_scaled : 0 < ε * Real.sqrt n := mul_pos hε hsqrt_pos - obtain ⟨t, ht_finite, ht_cover⟩ := Metric.totallyBounded_iff.mp htb_euc (ε * Real.sqrt n) hε_scaled + obtain ⟨t, ht_finite, ht_cover⟩ := + Metric.totallyBounded_iff.mp htb_euc (ε * Real.sqrt n) hε_scaled -- Map back to EmpiricalSpace use t.image (euclideanToEmpirical n) constructor @@ -84,7 +85,8 @@ lemma linearLocalizedBallImage_totallyBounded (hn : 0 < n) · intro y hy -- y is in linearLocalizedBallImage -- empiricalToEuclidean y is in the image, so covered by some ball - have hy_euc : empiricalToEuclidean n y ∈ empiricalToEuclidean n '' linearLocalizedBallImage n d δ x := + have hy_euc : + empiricalToEuclidean n y ∈ empiricalToEuclidean n '' linearLocalizedBallImage n d δ x := Set.mem_image_of_mem _ hy have hy_cover := ht_cover hy_euc rw [Set.mem_iUnion₂] at hy_cover @@ -95,7 +97,8 @@ lemma linearLocalizedBallImage_totallyBounded (hn : 0 < n) -- dist y (euclideanToEmpirical z) = dist(empiricalToEuclidean y, z) / √n have hdist := dist_euclidean_eq_sqrt_n_mul_dist_empirical hn y (euclideanToEmpirical n z) simp only [empiricalToEuclidean_euclideanToEmpirical] at hdist - have hdist' : dist y (euclideanToEmpirical n z) = dist (empiricalToEuclidean n y) z / Real.sqrt n := by + have hdist' : + dist y (euclideanToEmpirical n z) = dist (empiricalToEuclidean n y) z / Real.sqrt n := by have hne : Real.sqrt n ≠ 0 := ne_of_gt hsqrt_pos field_simp at hdist ⊢ linarith @@ -154,15 +157,20 @@ lemma metricEntropy_linearLocalizedBall_le (hn : 0 < n) (hd : 0 < d) -- m = coveringNumber ε (linearLocalizedBallImage) -- Need to show: metricEntropyOfNat m ≤ d * log(1 + 2δ/ε) -- The covering number of euclideanBall is finite - have htb_ball : TotallyBounded (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) := + have htb_ball : + TotallyBounded (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) := euclideanBall_totallyBounded _ - have hfin_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) < ⊤ := + have hfin_ball : coveringNumber (ε * Real.sqrt n) + (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) < ⊤ := coveringNumber_lt_top_of_totallyBounded hε_scaled htb_ball - have hne_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) ≠ ⊤ := + have hne_ball : coveringNumber (ε * Real.sqrt n) + (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) ≠ ⊤ := ne_top_of_lt hfin_ball -- Extract natural number from ball covering number - let m_ball := (coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d)))).untop hne_ball - have hm_ball_eq : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) = m_ball := + let m_ball := (coveringNumber (ε * Real.sqrt n) + (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d)))).untop hne_ball + have hm_ball_eq : coveringNumber (ε * Real.sqrt n) + (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) = m_ball := (WithTop.coe_untop _ hne_ball).symm -- m ≤ m_ball (using that euclideanBall = Metric.closedBall 0) have hm_le_ball : m ≤ m_ball := by @@ -190,7 +198,8 @@ lemma metricEntropy_linearLocalizedBall_le (hn : 0 < n) (hd : 0 < d) lemma sqrtEntropy_linearLocalizedBall_le (hn : 0 < n) (hd : 0 < d) (x : Fin n → EuclideanSpace ℝ (Fin d)) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hinj : Function.Injective (designMatrixMul x)) : - sqrtEntropy ε (linearLocalizedBallImage n d δ x) ≤ Real.sqrt (d * Real.log (1 + 2 * δ / ε)) := by + sqrtEntropy ε (linearLocalizedBallImage n d δ x) ≤ + Real.sqrt (d * Real.log (1 + 2 * δ / ε)) := by unfold sqrtEntropy apply Real.sqrt_le_sqrt exact metricEntropy_linearLocalizedBall_le hn hd x hε hδ hinj @@ -226,7 +235,8 @@ theorem linearEntropyIntegral_le_explicit (hn : 0 < n) (hd : 0 < d) intro ε hε exact Real.sqrt_nonneg _ -- Measurability of the explicit bound function - have hmeas : Measurable (fun ε : ℝ => ENNReal.ofReal (Real.sqrt (d * Real.log (1 + 2 * δ / ε)))) := by + have hmeas : + Measurable (fun ε : ℝ => ENNReal.ofReal (Real.sqrt (d * Real.log (1 + 2 * δ / ε)))) := by apply ENNReal.measurable_ofReal.comp apply Measurable.sqrt apply Measurable.mul measurable_const @@ -271,7 +281,8 @@ theorem linearEntropyIntegral_le_explicit (hn : 0 < n) (hd : 0 < d) _ = Real.sqrt d * Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt d * Real.sqrt (-Real.log ε) := by rw [Real.sqrt_mul (Nat.cast_nonneg d), Real.sqrt_mul (Nat.cast_nonneg d)] - _ = Real.sqrt d * (Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt (-Real.log ε)) := by ring + _ = Real.sqrt d * (Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt (-Real.log ε)) := by + ring -- Establish integrability of the bounding function have h_Ioo_finite : volume (Set.Ioo (0 : ℝ) 1) ≠ ⊤ := by rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top @@ -319,7 +330,8 @@ theorem linearEntropyIntegral_le_explicit (hn : 0 < n) (hd : 0 < d) _ = Real.sqrt d * Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt d * Real.sqrt (-Real.log ε) := by rw [Real.sqrt_mul (Nat.cast_nonneg d), Real.sqrt_mul (Nat.cast_nonneg d)] - _ = Real.sqrt d * (Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt (-Real.log ε)) := by ring + _ = Real.sqrt d * (Real.sqrt (Real.log (1 + 2 * δ)) + Real.sqrt (-Real.log ε)) := by + ring -- Establish integrability of the bounding function have h_Ioo_finite : volume (Set.Ioo (0 : ℝ) 1) ≠ ⊤ := by rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top @@ -368,7 +380,8 @@ theorem linearEntropyIntegral_le_explicit (hn : 0 < n) (hd : 0 < d) intro ε hε exact hnn ε hε calc (∫⁻ ε in Set.Ioc (0 : ℝ) D, dudleyIntegrand ε (linearLocalizedBallImage n d δ x)) - ≤ ∫⁻ ε in Set.Ioc (0 : ℝ) D, ENNReal.ofReal (Real.sqrt (d * Real.log (1 + 2 * δ / ε))) := hmono + ≤ ∫⁻ ε in Set.Ioc (0 : ℝ) D, + ENNReal.ofReal (Real.sqrt (d * Real.log (1 + 2 * δ / ε))) := hmono _ = ENNReal.ofReal (∫ ε in Set.Ioc (0 : ℝ) D, Real.sqrt (d * Real.log (1 + 2 * δ / ε))) := by rw [← MeasureTheory.ofReal_integral_eq_lintegral_ofReal] · exact hint @@ -571,7 +584,8 @@ lemma linearEntropyIntegral_integrableOn {δ D : ℝ} (hδ : 0 < δ) (hDδ : D · -- (0, 1]: same bound as D ≤ 1 case rw [integrableOn_Ioc_iff_integrableOn_Ioo] have hlog_1_2d_nonneg : 0 ≤ Real.log (1 + 2 * δ) := Real.log_nonneg (by linarith) - have hfin : volume (Set.Ioo (0:ℝ) 1) ≠ ⊤ := by rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top + have hfin : volume (Set.Ioo (0:ℝ) 1) ≠ ⊤ := by + rw [Real.volume_Ioo]; exact ENNReal.ofReal_ne_top have hint_const : MeasureTheory.IntegrableOn (fun _ : ℝ => Real.sqrt d * Real.sqrt (Real.log (1 + 2 * δ))) (Set.Ioo 0 1) volume := @@ -622,7 +636,8 @@ lemma linearEntropyIntegral_integrableOn {δ D : ℝ} (hδ : 0 < δ) (hDδ : D rw [Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _)] have hu_ge : 1 ≤ u := le_of_lt hu.1 have h_term_pos : 0 < 1 + 2 * δ / u := by - have : 0 < 2 * δ / u := div_pos (by linarith) (lt_of_lt_of_le (by linarith : (0:ℝ) < 1) hu_ge) + have : 0 < 2 * δ / u := + div_pos (by linarith) (lt_of_lt_of_le (by linarith : (0:ℝ) < 1) hu_ge) linarith apply Real.sqrt_le_sqrt apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg d) @@ -667,7 +682,8 @@ These lemmas generalize the entropy bounds from requiring full rank (hinj) to on that the design matrix has positive rank. The bounds use `designMatrixRank x` instead of `d`. -/ /-- The metric entropy of the linear localized ball is bounded by r * log(1 + 2δ/ε) - where r = designMatrixRank x. This follows from the covering number bound N(ε, s) ≤ (1 + 2δ/ε)^r. -/ + where r = designMatrixRank x. This follows from the covering number bound + N(ε, s) ≤ (1 + 2δ/ε)^r. -/ lemma metricEntropy_linearLocalizedBall_rank_le (hn : 0 < n) (x : Fin n → EuclideanSpace ℝ (Fin d)) {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) (hr : 0 < designMatrixRank x) : @@ -706,15 +722,20 @@ lemma metricEntropy_linearLocalizedBall_rank_le (hn : 0 < n) -- m = coveringNumber ε (linearLocalizedBallImage) -- Need to show: metricEntropyOfNat m ≤ r * log(1 + 2δ/ε) -- The covering number of euclideanBall is finite - have htb_ball : TotallyBounded (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) := + have htb_ball : TotallyBounded (euclideanBall (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) := euclideanBall_totallyBounded _ - have hfin_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) < ⊤ := + have hfin_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) < ⊤ := coveringNumber_lt_top_of_totallyBounded hε_scaled htb_ball - have hne_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) ≠ ⊤ := + have hne_ball : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) ≠ ⊤ := ne_top_of_lt hfin_ball -- Extract natural number from ball covering number - let m_ball := (coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x))))).untop hne_ball - have hm_ball_eq : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) = m_ball := + let m_ball := (coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x))))).untop hne_ball + have hm_ball_eq : coveringNumber (ε * Real.sqrt n) (euclideanBall (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) = m_ball := (WithTop.coe_untop _ hne_ball).symm -- m ≤ m_ball (using that euclideanBall = Metric.closedBall 0) have hm_le_ball : m ≤ m_ball := by @@ -724,7 +745,8 @@ lemma metricEntropy_linearLocalizedBall_rank_le (hn : 0 < n) have hball_le : (m_ball : ℝ) ≤ (1 + 2 * δ / ε) ^ (designMatrixRank x) := by convert hball_bound using 2 -- m ≤ (1 + 2δ/ε)^r - have hm_le : (m : ℝ) ≤ (1 + 2 * δ / ε) ^ (designMatrixRank x) := le_trans (Nat.cast_le.mpr hm_le_ball) hball_le + have hm_le : (m : ℝ) ≤ (1 + 2 * δ / ε) ^ (designMatrixRank x) := + le_trans (Nat.cast_le.mpr hm_le_ball) hball_le -- Use metricEntropyOfNat_le_log have hN_pos : 1 < (1 + 2 * δ / ε) ^ (designMatrixRank x) := by have hbase : 1 < 1 + 2 * δ / ε := by @@ -733,7 +755,8 @@ lemma metricEntropy_linearLocalizedBall_rank_le (hn : 0 < n) have hr_ne : designMatrixRank x ≠ 0 := Nat.pos_iff_ne_zero.mp hr exact one_lt_pow₀ hbase hr_ne calc metricEntropyOfNat m - ≤ Real.log ((1 + 2 * δ / ε) ^ (designMatrixRank x)) := metricEntropyOfNat_le_log hN_pos hm_le + ≤ Real.log ((1 + 2 * δ / ε) ^ (designMatrixRank x)) := + metricEntropyOfNat_le_log hN_pos hm_le _ = (designMatrixRank x) * Real.log (1 + 2 * δ / ε) := by rw [Real.log_pow] /-- The square root entropy bound using rank. -/ @@ -774,17 +797,21 @@ theorem linearEntropyIntegral_rank_le (hn : 0 < n) dudleyIntegrand ε (linearLocalizedBallImage n d δ x) ≤ ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := fun ε hε => dudleyIntegrand_linearLocalizedBall_rank_le hn x hε.1 hδ hr - have hnn : ∀ ε ∈ Set.Ioc (0 : ℝ) (2*δ), 0 ≤ Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)) := + have hnn : ∀ ε ∈ Set.Ioc (0 : ℝ) (2*δ), + 0 ≤ Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)) := fun _ _ => Real.sqrt_nonneg _ - have hmeas : Measurable (fun ε : ℝ => ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)))) := by + have hmeas : Measurable (fun ε : ℝ => + ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)))) := by apply ENNReal.measurable_ofReal.comp apply Measurable.sqrt apply Measurable.mul measurable_const apply Real.measurable_log.comp apply Measurable.add measurable_const apply Measurable.div measurable_const measurable_id - have hmono : ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), dudleyIntegrand ε (linearLocalizedBallImage n d δ x) ≤ - ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := by + have hmono : ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), + dudleyIntegrand ε (linearLocalizedBallImage n d δ x) ≤ + ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), + ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := by apply MeasureTheory.setLIntegral_mono hmeas intro ε hε exact hbound ε hε @@ -796,8 +823,10 @@ theorem linearEntropyIntegral_rank_le (hn : 0 < n) intro ε hε exact hnn ε hε calc (∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), dudleyIntegrand ε (linearLocalizedBallImage n d δ x)) - ≤ ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := hmono - _ = ENNReal.ofReal (∫ ε in Set.Ioc (0 : ℝ) (2*δ), Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := by + ≤ ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), + ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := hmono + _ = ENNReal.ofReal (∫ ε in Set.Ioc (0 : ℝ) (2*δ), + Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := by rw [← MeasureTheory.ofReal_integral_eq_lintegral_ofReal] · exact hint · apply MeasureTheory.ae_of_all @@ -809,20 +838,23 @@ theorem linearEntropyIntegral_rank_le (hn : 0 < n) rw [intervalIntegral.integral_of_le (by linarith : (0 : ℝ) ≤ 2 * δ)] -- Step 3: Change of variables ε = 2δu have h3 : ∫ ε in (0 : ℝ)..(2*δ), Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)) = - (2*δ) * ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) := by + (2*δ) * ∫ u in (0 : ℝ)..1, + Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) := by have := @intervalIntegral.mul_integral_comp_mul_left 0 1 (fun ε => Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) (2*δ) simp only [mul_zero, mul_one] at this exact this.symm -- Step 4: Helper lemma for simplification 2δ/(2δu) = 1/u for u > 0 - have h4 : ∀ u ∈ Set.Ioo (0 : ℝ) 1, (fun u => Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u)))) u = + have h4 : ∀ u ∈ Set.Ioo (0 : ℝ) 1, + (fun u => Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u)))) u = (fun u => Real.sqrt ((designMatrixRank x) * Real.log (1 + 1 / u))) u := by intro u ⟨hu_pos, _⟩ have h2δ_ne : (2 : ℝ) * δ ≠ 0 := by linarith simp only congr 2 rw [div_mul_eq_div_div, div_self h2δ_ne, one_div] - have h4' : ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) = + have h4' : + ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) = ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 1 / u)) := by rw [intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] rw [intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1)] @@ -874,7 +906,8 @@ theorem linearEntropyIntegral_rank_le (hn : 0 < n) rw [Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _)] calc Real.sqrt ((designMatrixRank x) * Real.log (1 + 1 / u)) ≤ Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 / u)) := h5 u hu - _ ≤ Real.sqrt (designMatrixRank x) * (Real.sqrt (Real.log 3) + Real.sqrt (-Real.log u)) := by + _ ≤ Real.sqrt (designMatrixRank x) * + (Real.sqrt (Real.log 3) + Real.sqrt (-Real.log u)) := by rw [Real.sqrt_mul (Nat.cast_nonneg (designMatrixRank x))] exact mul_le_mul_of_nonneg_left (sqrt_log_one_plus_two_div_bound hu) (Real.sqrt_nonneg (designMatrixRank x)) @@ -903,11 +936,14 @@ theorem linearEntropyIntegral_rank_le (hn : 0 < n) calc linearEntropyIntegral n d δ (2*δ) x ≤ ∫ ε in Set.Ioc 0 (2*δ), Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)) := h1 _ = ∫ ε in (0 : ℝ)..(2*δ), Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε)) := h2 - _ = (2*δ) * ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) := h3 - _ = (2*δ) * ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 1 / u)) := by rw [h4'] + _ = (2*δ) * ∫ u in (0 : ℝ)..1, + Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ((2*δ) * u))) := h3 + _ = (2*δ) * ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 1 / u)) := by + rw [h4'] _ ≤ (2*δ) * ∫ u in (0 : ℝ)..1, Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 / u)) := by apply mul_le_mul_of_nonneg_left h5_bound (by linarith) - _ = (2*δ) * (Real.sqrt (designMatrixRank x) * ∫ u in (0 : ℝ)..1, Real.sqrt (Real.log (1 + 2 / u))) := by rw [h6] + _ = (2*δ) * (Real.sqrt (designMatrixRank x) * + ∫ u in (0 : ℝ)..1, Real.sqrt (Real.log (1 + 2 / u))) := by rw [h6] _ < (2*δ) * (Real.sqrt (designMatrixRank x) * 2) := by apply mul_lt_mul_of_pos_left _ hD apply mul_lt_mul_of_pos_left h7 (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hr)) @@ -930,7 +966,8 @@ lemma linearEntropyIntegralENNReal_rank_ne_top (hn : 0 < n) ≤ ∫⁻ ε in Set.Ioc (0 : ℝ) (2*δ), ENNReal.ofReal (Real.sqrt ((designMatrixRank x) * Real.log (1 + 2 * δ / ε))) := by apply MeasureTheory.setLIntegral_mono - · exact (ENNReal.measurable_ofReal.comp (measurable_sqrt_d_log_one_plus_c_div (designMatrixRank x) (2*δ))) + · exact (ENNReal.measurable_ofReal.comp + (measurable_sqrt_d_log_one_plus_c_div (designMatrixRank x) (2*δ))) · intro ε hε exact hbound_dudley ε hε _ = ENNReal.ofReal (∫ ε in Set.Ioc (0 : ℝ) (2*δ), diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EuclideanReduction.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EuclideanReduction.lean index 4d0a7ed..c82c01d 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EuclideanReduction.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/EuclideanReduction.lean @@ -44,7 +44,8 @@ N(s, B_n(δ), ‖·‖_n) = N(s√n, B_2^n(δ√n) ∩ range(X), ‖·‖_2) -/ /-- The identity map from EmpiricalSpace n to EuclideanSpace ℝ (Fin n). - This preserves values but changes the metric: dist in EmpiricalSpace = (1/√n) * dist in EuclideanSpace -/ + This preserves values but changes the metric: + dist in EmpiricalSpace = (1/√n) * dist in EuclideanSpace -/ def empiricalToEuclidean (n : ℕ) (v : EmpiricalSpace n) : EuclideanSpace ℝ (Fin n) := (WithLp.equiv 2 (Fin n → ℝ)).symm v @@ -184,7 +185,8 @@ lemma empiricalToEuclidean_bijective : Function.Bijective (empiricalToEuclidean use euclideanToEmpirical n v simp -/-- Scaling property: for any s > 0, an s-net in EmpiricalSpace induces an (s√n)-net in EuclideanSpace -/ +/-- Scaling property: for any s > 0, an s-net in EmpiricalSpace induces an (s√n)-net in + EuclideanSpace -/ theorem isENet_empiricalToEuclidean_image (hn : 0 < n) {t : Finset (EmpiricalSpace n)} {s : ℝ} {S : Set (EmpiricalSpace n)} (hnet : IsENet t s S) : @@ -217,7 +219,8 @@ theorem linearCoveringNumber_eq_euclidean (hn : 0 < n) apply le_antisymm · -- coveringNumber s (linearLocalizedBallImage) ≤ coveringNumber (s*√n) (image) -- If the RHS is ⊤, the inequality is trivial - by_cases h : coveringNumber (s * Real.sqrt n) (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) = ⊤ + by_cases h : coveringNumber (s * Real.sqrt n) + (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) = ⊤ · simp [h] -- Otherwise, get a finite (s*√n)-net for the image push Not at h @@ -225,7 +228,8 @@ theorem linearCoveringNumber_eq_euclidean (hn : 0 < n) IsENet t (s * Real.sqrt n) (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) ∧ (t.card : WithTop ℕ) = m}.Nonempty := by by_contra hemp - have : coveringNumber (s * Real.sqrt n) (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) = ⊤ := by + have : coveringNumber (s * Real.sqrt n) + (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) = ⊤ := by unfold _root_.coveringNumber simp only [Set.not_nonempty_iff_eq_empty.mp hemp, WithTop.sInf_empty] exact h this @@ -237,7 +241,8 @@ theorem linearCoveringNumber_eq_euclidean (hn : 0 < n) -- Show t_emp is an s-net for linearLocalizedBallImage have ht_emp_net : IsENet t_emp s (linearLocalizedBallImage n d δ x) := by intro y hy - have hy' : empiricalToEuclidean n y ∈ empiricalToEuclidean n '' linearLocalizedBallImage n d δ x := + have hy' : empiricalToEuclidean n y ∈ + empiricalToEuclidean n '' linearLocalizedBallImage n d δ x := Set.mem_image_of_mem _ hy have hcover := ht_net hy' rw [Set.mem_iUnion₂] at hcover @@ -259,7 +264,8 @@ theorem linearCoveringNumber_eq_euclidean (hn : 0 < n) calc coveringNumber s (linearLocalizedBallImage n d δ x) ≤ t_emp.card := coveringNumber_le_card ht_emp_net _ ≤ t_euc.card := by exact_mod_cast Finset.card_image_le - _ = coveringNumber (s * Real.sqrt n) (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) := ht_card + _ = coveringNumber (s * Real.sqrt n) + (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) := ht_card · -- coveringNumber (s*√n) (image) ≤ coveringNumber s (linearLocalizedBallImage) by_cases h : coveringNumber s (linearLocalizedBallImage n d δ x) = ⊤ · simp [h] @@ -277,7 +283,8 @@ theorem linearCoveringNumber_eq_euclidean (hn : 0 < n) let t_euc : Finset (EuclideanSpace ℝ (Fin n)) := t_emp.image (empiricalToEuclidean n) -- Show t_euc is an (s*√n)-net for the image have ht_euc_net := isENet_empiricalToEuclidean_image hn ht_net - calc coveringNumber (s * Real.sqrt n) (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) + calc coveringNumber (s * Real.sqrt n) + (empiricalToEuclidean n '' linearLocalizedBallImage n d δ x) ≤ t_euc.card := coveringNumber_le_card ht_euc_net _ ≤ t_emp.card := by exact_mod_cast Finset.card_image_le _ = coveringNumber s (linearLocalizedBallImage n d δ x) := ht_card @@ -401,7 +408,8 @@ lemma euclideanLocalizedBall_subset_range (x : Fin n → EuclideanSpace ℝ (Fin /-- Any d-dimensional subspace of a Euclidean space admits an isometric linear equivalence to ℝ^d. This is a fundamental result: all finite-dimensional inner product spaces of the same dimension are isometrically isomorphic. -/ -lemma exists_linearIsometryEquiv_of_finrank_eq (hd : 0 < d) (V : Submodule ℝ (EuclideanSpace ℝ (Fin n))) +lemma exists_linearIsometryEquiv_of_finrank_eq (hd : 0 < d) + (V : Submodule ℝ (EuclideanSpace ℝ (Fin n))) (hV : Module.finrank ℝ V = d) : Nonempty (V ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin d)) := by have : FiniteDimensional ℝ V := Module.finite_of_finrank_pos (hV ▸ hd) @@ -476,7 +484,8 @@ theorem linearCoveringNumber_le_euclideanBall_d (hn : 0 < n) (hd : 0 < d) (x : Fin n → EuclideanSpace ℝ (Fin d)) {s δ : ℝ} (hinj : Function.Injective (designMatrixMul x)) : linearCoveringNumber n d s δ x ≤ - coveringNumber (s * Real.sqrt n) (Metric.closedBall 0 (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) := by + coveringNumber (s * Real.sqrt n) + (Metric.closedBall 0 (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin d))) := by -- Step 1: Use linearCoveringNumber_eq_euclidean rw [linearCoveringNumber_eq_euclidean hn x] -- Step 2: Get the d-dimensional subspace V = range(X) @@ -494,14 +503,16 @@ theorem linearCoveringNumber_le_euclideanBall_d (hn : 0 < n) (hd : 0 < d) tauto rw [hlocalized_eq] -- Step 5: The ball ∩ V equals the image of the ball in V under the inclusion - have hinter_eq : Metric.closedBall (0 : EuclideanSpace ℝ (Fin n)) (δ * Real.sqrt n) ∩ (V : Set _) = + have hinter_eq : + Metric.closedBall (0 : EuclideanSpace ℝ (Fin n)) (δ * Real.sqrt n) ∩ (V : Set _) = V.subtypeL '' (Metric.closedBall (0 : V) (δ * Real.sqrt n)) := by rw [submodule_closedBall_eq_inter] rw [hinter_eq] -- Step 6: Use that ball ∩ V = (V.subtypeL ∘ e.symm) '' ball_d -- The composition V.subtypeL ∘ e.symm is an isometric embedding ℝ^d → ℝ^n -- e.symm maps ball_d to ball_V - have he_symm_ball : e.symm '' (Metric.closedBall (0 : EuclideanSpace ℝ (Fin d)) (δ * Real.sqrt n)) = + have he_symm_ball : + e.symm '' (Metric.closedBall (0 : EuclideanSpace ℝ (Fin d)) (δ * Real.sqrt n)) = Metric.closedBall (0 : V) (δ * Real.sqrt n) := by rw [e.symm.image_closedBall 0 (δ * Real.sqrt n), e.symm.map_zero] -- So V.subtypeL '' ball_V = V.subtypeL '' (e.symm '' ball_d) @@ -540,7 +551,8 @@ theorem linearCoveringNumber_le_euclideanBall_rank (hn : 0 < n) (hr : 0 < designMatrixRank x) : linearCoveringNumber n d s δ x ≤ coveringNumber (s * Real.sqrt n) - (Metric.closedBall 0 (δ * Real.sqrt n) : Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) := by + (Metric.closedBall 0 (δ * Real.sqrt n) : + Set (EuclideanSpace ℝ (Fin (designMatrixRank x)))) := by -- Step 1: Use linearCoveringNumber_eq_euclidean rw [linearCoveringNumber_eq_euclidean hn x] -- Step 2: Get the r-dimensional subspace V = range(X) @@ -558,20 +570,23 @@ theorem linearCoveringNumber_le_euclideanBall_rank (hn : 0 < n) tauto rw [hlocalized_eq] -- Step 5: The ball ∩ V equals the image of the ball in V under the inclusion - have hinter_eq : Metric.closedBall (0 : EuclideanSpace ℝ (Fin n)) (δ * Real.sqrt n) ∩ (V : Set _) = + have hinter_eq : + Metric.closedBall (0 : EuclideanSpace ℝ (Fin n)) (δ * Real.sqrt n) ∩ (V : Set _) = V.subtypeL '' (Metric.closedBall (0 : V) (δ * Real.sqrt n)) := by rw [submodule_closedBall_eq_inter] rw [hinter_eq] -- Step 6: Use that ball ∩ V = (V.subtypeL ∘ e.symm) '' ball_r -- The composition V.subtypeL ∘ e.symm is an isometric embedding ℝ^r → ℝ^n -- e.symm maps ball_r to ball_V - have he_symm_ball : e.symm '' (Metric.closedBall (0 : EuclideanSpace ℝ (Fin (designMatrixRank x))) (δ * Real.sqrt n)) = + have he_symm_ball : e.symm '' + (Metric.closedBall (0 : EuclideanSpace ℝ (Fin (designMatrixRank x))) (δ * Real.sqrt n)) = Metric.closedBall (0 : V) (δ * Real.sqrt n) := by rw [e.symm.image_closedBall 0 (δ * Real.sqrt n), e.symm.map_zero] -- So V.subtypeL '' ball_V = V.subtypeL '' (e.symm '' ball_r) rw [← he_symm_ball, ← Set.image_comp] -- The composition f = V.subtypeL ∘ e.symm is an isometric embedding - let f : EuclideanSpace ℝ (Fin (designMatrixRank x)) → EuclideanSpace ℝ (Fin n) := V.subtypeL ∘ e.symm + let f : EuclideanSpace ℝ (Fin (designMatrixRank x)) → EuclideanSpace ℝ (Fin n) := + V.subtypeL ∘ e.symm have hf_isometry : Isometry f := by apply Isometry.comp · intro v w diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/GaussianComplexity.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/GaussianComplexity.lean index 7a3691d..7b2ab13 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/GaussianComplexity.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/GaussianComplexity.lean @@ -45,23 +45,31 @@ theorem linear_local_gaussian_complexity_bound (n d : ℕ) (hn : 0 < n) (hd : 0 -- Step 1: Apply local_gaussian_complexity_bound have h1 := local_gaussian_complexity_bound n hn (linearPredictorClass d) δ hδ x linearPredictorClass_isStarShaped - (by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linearLocalizedBallImage_totallyBounded hn x δ) - (by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linearEntropyIntegralENNReal_ne_top hn hd x hδ hinj) - (fun w => by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linear_innerProductProcess_continuous x w) + (by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linearLocalizedBallImage_totallyBounded hn x δ) + (by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linearEntropyIntegralENNReal_ne_top hn hd x hδ hinj) + (fun w => by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linear_innerProductProcess_continuous x w) (linear_empiricalProcess_sup_integrable_pos hn x hδ) (linear_empiricalProcess_sup_integrable_neg hn x hδ) -- Step 2: Get the entropy integral bound have h2 := linearEntropyIntegral_le hn hd x hδ hinj -- Step 3: Connect linearEntropyIntegral to entropyIntegral have heq : linearEntropyIntegral n d δ (2*δ) x = - entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) (2*δ) := by + entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) + (2*δ) := by unfold linearEntropyIntegral rw [← linearLocalizedBallImage_eq_empiricalImage] rw [heq] at h2 -- Step 4: Combine bounds calc LocalGaussianComplexity n (linearPredictorClass d) δ x ≤ (24 * Real.sqrt 2) / Real.sqrt n * - entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) (2*δ) := h1 + entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) + (2*δ) := h1 _ ≤ (24 * Real.sqrt 2) / Real.sqrt n * (4 * δ * Real.sqrt d) := by apply mul_le_mul_of_nonneg_left (le_of_lt h2) apply div_nonneg _ (Real.sqrt_nonneg n) @@ -86,23 +94,31 @@ theorem linear_local_gaussian_complexity_bound_rank (n d : ℕ) (hn : 0 < n) -- Step 1: Apply local_gaussian_complexity_bound have h1 := local_gaussian_complexity_bound n hn (linearPredictorClass d) δ hδ x linearPredictorClass_isStarShaped - (by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linearLocalizedBallImage_totallyBounded hn x δ) - (by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linearEntropyIntegralENNReal_rank_ne_top hn x hδ hr) - (fun w => by rw [← linearLocalizedBallImage_eq_empiricalImage]; exact linear_innerProductProcess_continuous x w) + (by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linearLocalizedBallImage_totallyBounded hn x δ) + (by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linearEntropyIntegralENNReal_rank_ne_top hn x hδ hr) + (fun w => by + rw [← linearLocalizedBallImage_eq_empiricalImage] + exact linear_innerProductProcess_continuous x w) (linear_empiricalProcess_sup_integrable_pos hn x hδ) (linear_empiricalProcess_sup_integrable_neg hn x hδ) -- Step 2: Get the entropy integral bound using rank have h2 := linearEntropyIntegral_rank_le hn x hδ hr -- Step 3: Connect linearEntropyIntegral to entropyIntegral have heq : linearEntropyIntegral n d δ (2*δ) x = - entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) (2*δ) := by + entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) + (2*δ) := by unfold linearEntropyIntegral rw [← linearLocalizedBallImage_eq_empiricalImage] rw [heq] at h2 -- Step 4: Combine bounds calc LocalGaussianComplexity n (linearPredictorClass d) δ x ≤ (24 * Real.sqrt 2) / Real.sqrt n * - entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) (2*δ) := h1 + entropyIntegral (empiricalMetricImage n x '' localizedBall (linearPredictorClass d) δ x) + (2*δ) := h1 _ ≤ (24 * Real.sqrt 2) / Real.sqrt n * (4 * δ * Real.sqrt (designMatrixRank x)) := by apply mul_le_mul_of_nonneg_left (le_of_lt h2) apply div_nonneg _ (Real.sqrt_nonneg n) diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/IntegralBounds.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/IntegralBounds.lean index 69e6d34..ce7cfbb 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/IntegralBounds.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/IntegralBounds.lean @@ -190,7 +190,8 @@ lemma integral_sqrt_neg_log_Ioo : intro t ht simp only [abs_neg, abs_of_pos (Real.exp_pos _), Real.log_exp, neg_neg] rw [smul_eq_mul, mul_comm] - have h_int_eq : ∫ x in Set.Ioi (0 : ℝ), |-(Real.exp (-x))| • Real.sqrt (-Real.log (Real.exp (-x))) = + have h_int_eq : + ∫ x in Set.Ioi (0 : ℝ), |-(Real.exp (-x))| • Real.sqrt (-Real.log (Real.exp (-x))) = ∫ t in Set.Ioi (0 : ℝ), Real.sqrt t * Real.exp (-t) := by apply MeasureTheory.setIntegral_congr_fun measurableSet_Ioi exact h_eq @@ -339,7 +340,8 @@ theorem integral_constant_bound : (∫ u in Set.Ioo (0 : ℝ) 1, Real.sqrt (Real.log 3)) + ∫ u in Set.Ioo (0 : ℝ) 1, Real.sqrt (-Real.log u) := MeasureTheory.integral_add h_const_int integrableOn_sqrt_neg_log - -- Evaluate the first integral: ∫ √(log 3) du over Ioo 0 1 = √(log 3) * measure(Ioo 0 1) = √(log 3) + -- Evaluate the first integral: + -- ∫ √(log 3) du over Ioo 0 1 = √(log 3) * measure(Ioo 0 1) = √(log 3) have h_const : ∫ u in Set.Ioo (0 : ℝ) 1, Real.sqrt (Real.log 3) = Real.sqrt (Real.log 3) := by rw [MeasureTheory.setIntegral_const] -- Need to show: volume.real (Set.Ioo 0 1) • √(log 3) = √(log 3) diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/LocalizedBall.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/LocalizedBall.lean index 344a674..caee40c 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/LocalizedBall.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/LocalizedBall.lean @@ -193,13 +193,15 @@ theorem diam_linearLocalizedBallImage_le (hn : 0 < n) ext i simp only [designMatrixMul_apply, inner_sub_left] rfl - have h_norm_bound : ‖designMatrixMul x (θ₁ - θ₂)‖ ≤ ‖designMatrixMul x θ₁‖ + ‖designMatrixMul x θ₂‖ := by + have h_norm_bound : + ‖designMatrixMul x (θ₁ - θ₂)‖ ≤ ‖designMatrixMul x θ₁‖ + ‖designMatrixMul x θ₂‖ := by rw [h_linear] exact norm_sub_le _ _ calc (n : ℝ)⁻¹.sqrt * ‖designMatrixMul x (θ₁ - θ₂)‖ ≤ (n : ℝ)⁻¹.sqrt * (‖designMatrixMul x θ₁‖ + ‖designMatrixMul x θ₂‖) := by apply mul_le_mul_of_nonneg_left h_norm_bound hsqrt_inv_nonneg - _ = (n : ℝ)⁻¹.sqrt * ‖designMatrixMul x θ₁‖ + (n : ℝ)⁻¹.sqrt * ‖designMatrixMul x θ₂‖ := by ring + _ = (n : ℝ)⁻¹.sqrt * ‖designMatrixMul x θ₁‖ + + (n : ℝ)⁻¹.sqrt * ‖designMatrixMul x θ₂‖ := by ring _ ≤ δ + δ := by apply add_le_add · -- (n⁻¹).sqrt * ‖Xθ₁‖ ≤ δ diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean index e466cec..09aff05 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean @@ -221,8 +221,9 @@ lemma linear_empiricalSphere_nonempty (hn : 0 < n) (hd : 0 < d) rw [div_mul_cancel₀] exact ne_of_gt h_emp_norm_pos -/-- Integrability of the absolute supremum empirical process at positive radius for linear predictors. -This uses the general `localGaussianComplexity_integrand_integrable` lemma for star-shaped sets. -/ +/-- Integrability of the absolute supremum empirical process at positive radius for linear +predictors. This uses the general `localGaussianComplexity_integrand_integrable` lemma for +star-shaped sets. -/ lemma linear_integrable_at_radius (x : Fin n → EuclideanSpace ℝ (Fin d)) {δ : ℝ} (hδ : 0 < δ) {f_star : EuclideanSpace ℝ (Fin d) → ℝ} (hf_star : f_star ∈ linearPredictorClass d) : @@ -236,7 +237,8 @@ The bound follows from Cauchy-Schwarz: the empirical process is bounded by ‖w lemma linear_bddAbove_at_radius (hn : 0 < n) (x : Fin n → EuclideanSpace ℝ (Fin d)) {u : ℝ} (hu : 0 < u) {f_star : EuclideanSpace ℝ (Fin d) → ℝ} (hf_star : f_star ∈ linearPredictorClass d) : - ∀ w : Fin n → ℝ, BddAbove {y | ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) f_star) u x, + ∀ w : Fin n → ℝ, BddAbove {y | + ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) f_star) u x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)|} := by rw [shiftedClass_eq_self_of_linear hf_star] intro w @@ -290,7 +292,8 @@ lemma linear_bddAbove_at_radius (hn : 0 < n) rwa [h_cancel] at hmul calc Real.sqrt (∑ i, (h (x i))^2) ≤ Real.sqrt (n * u^2) := Real.sqrt_le_sqrt h_sum - _ = Real.sqrt n * u := by rw [Real.sqrt_mul (Nat.cast_nonneg n), Real.sqrt_sq (le_of_lt hu)] + _ = Real.sqrt n * u := by + rw [Real.sqrt_mul (Nat.cast_nonneg n), Real.sqrt_sq (le_of_lt hu)] _ = Real.sqrt n * ‖w'‖ * u := by ring calc |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| = (n : ℝ)⁻¹ * |∑ i, w i * h (x i)| := by @@ -344,21 +347,26 @@ theorem linear_minimax_rate (hn : 0 < n) (hd : 0 < d) rw [← sq] exact Real.sqrt_sq (le_of_lt hδ_star_pos) -- Nonemptiness of empirical sphere at √(δ_star²) = δ_star - have hne : (empiricalSphere n (shiftedClass (linearPredictorClass d) M.f_star) (Real.sqrt (δ_star * δ_star)) M.x).Nonempty := by + have hne : (empiricalSphere n (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x).Nonempty := by rw [h_sqrt_eq] exact linear_empiricalSphere_nonempty hn hd M.x hδ_star_pos hinj hf_star -- Integrability at √(t·δ_star) = δ_star - have hint_u : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := by + have hint_u : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) + (stdGaussianPi n) := by rw [h_sqrt_eq] exact linear_integrable_at_radius M.x hδ_star_pos hf_star -- Integrability at δ_star - have hint_δ : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := + have hint_δ : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := linear_integrable_at_radius M.x hδ_star_pos hf_star -- Boundedness at √(t·δ_star) = δ_star - have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by + have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | + ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by rw [h_sqrt_eq] exact linear_bddAbove_at_radius hn M.x hδ_star_pos hf_star -- Step 2: Apply master_error_bound with t = δ_star @@ -425,18 +433,23 @@ theorem linear_minimax_rate_explicit (hn : 0 < n) (hd : 0 < d) have h_sqrt_eq : Real.sqrt (δ_star * δ_star) = δ_star := by rw [← sq] exact Real.sqrt_sq (le_of_lt hδ_pos) - have hne : (empiricalSphere n (shiftedClass (linearPredictorClass d) M.f_star) (Real.sqrt (δ_star * δ_star)) M.x).Nonempty := by + have hne : (empiricalSphere n (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x).Nonempty := by rw [h_sqrt_eq] exact linear_empiricalSphere_nonempty hn hd M.x hδ_pos hinj hf_star - have hint_u : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := by + have hint_u : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) + (stdGaussianPi n) := by rw [h_sqrt_eq] exact linear_integrable_at_radius M.x hδ_pos hf_star - have hint_δ : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := + have hint_δ : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := linear_integrable_at_radius M.x hδ_pos hf_star - have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by + have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | + ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by rw [h_sqrt_eq] exact linear_bddAbove_at_radius hn M.x hδ_pos hf_star have h_master := master_error_bound hn M (linearPredictorClass d) hf_star δ_star hδ_pos @@ -621,17 +634,21 @@ theorem linear_minimax_rate_rank (hn : 0 < n) rw [h_sqrt_eq] exact linear_empiricalSphere_nonempty_rank hn M.x hδ_star_pos hr hf_star -- Integrability at √(t·δ_star) = δ_star - have hint_u : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := by + have hint_u : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) + (stdGaussianPi n) := by rw [h_sqrt_eq] exact linear_integrable_at_radius M.x hδ_star_pos hf_star -- Integrability at δ_star - have hint_δ : Integrable (fun w => ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := + have hint_δ : Integrable (fun w => + ⨆ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + δ_star M.x, |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|) (stdGaussianPi n) := linear_integrable_at_radius M.x hδ_star_pos hf_star -- Boundedness at √(t·δ_star) = δ_star - have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) - (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by + have hbdd : ∀ w : Fin n → ℝ, BddAbove {y | + ∃ h ∈ localizedBall (shiftedClass (linearPredictorClass d) M.f_star) + (Real.sqrt (δ_star * δ_star)) M.x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (M.x i)|} := by rw [h_sqrt_eq] exact linear_bddAbove_at_radius hn M.x hδ_star_pos hf_star -- Step 2: Apply master_error_bound with t = δ_star diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/PredictorClass.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/PredictorClass.lean index 79df552..eef83b6 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/PredictorClass.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/PredictorClass.lean @@ -46,7 +46,8 @@ def linearPredictorClass (d : ℕ) : Set ((EuclideanSpace ℝ (Fin d)) → ℝ) {f | ∃ θ : EuclideanSpace ℝ (Fin d), f = fun x => @inner ℝ _ _ θ x} /-- Zero function is a linear predictor (with θ = 0) -/ -lemma zero_mem_linearPredictorClass : (0 : (EuclideanSpace ℝ (Fin d)) → ℝ) ∈ linearPredictorClass d := by +lemma zero_mem_linearPredictorClass : + (0 : (EuclideanSpace ℝ (Fin d)) → ℝ) ∈ linearPredictorClass d := by use 0 ext x simp only [Pi.zero_apply, inner_zero_left] diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean b/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean index 9fe1c8f..760e701 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean @@ -54,7 +54,8 @@ lemma gaussianReal_zero_map_neg (v : NNReal) : simpa [h2] using h /-- Standard Gaussian is negation-invariant -/ -instance gaussianReal_zero_IsNegInvariant (v : NNReal) : (gaussianReal (0 : ℝ) v).IsNegInvariant where +instance gaussianReal_zero_IsNegInvariant (v : NNReal) : + (gaussianReal (0 : ℝ) v).IsNegInvariant where neg_eq_self := by rw [Measure.neg_def, gaussianReal_zero_map_neg] @@ -176,7 +177,8 @@ lemma innerProductProcess_sub (n : ℕ) (v₁ v₂ : EmpiricalSpace n) (w : Fin rw [h_sub] ring -/-- Key: The empirical process Z_g equals the inner product process applied to empiricalMetricImage -/ +/-- Key: The empirical process Z_g equals the inner product process applied to +empiricalMetricImage -/ lemma empiricalProcess_eq_innerProductProcess (n : ℕ) (x : Fin n → X) (g : X → ℝ) (w : Fin n → ℝ) : empiricalProcess n x g w = innerProductProcess n (empiricalMetricImage n x g) w := by unfold empiricalProcess innerProductProcess empiricalMetricImage @@ -370,7 +372,8 @@ lemma inner_abs_le_norm_mul_norm' (n : ℕ) (a b : Fin n → ℝ) : -- Combine: -(∑ab) ≤ √... means -√... ≤ ∑ab rw [abs_le] constructor - · linarith [mul_nonneg (Real.sqrt_nonneg (∑ i : Fin n, a i ^ 2)) (Real.sqrt_nonneg (∑ i : Fin n, b i ^ 2))] + · linarith [mul_nonneg (Real.sqrt_nonneg (∑ i : Fin n, a i ^ 2)) + (Real.sqrt_nonneg (∑ i : Fin n, b i ^ 2))] · exact h_upper /-- Empirical process is bounded by δ times normalized w norm -/ @@ -386,7 +389,8 @@ lemma empiricalProcess_le_delta_norm (n : ℕ) (hn : 0 < n) (x : Fin n → X) (H -- Cauchy-Schwarz: |∑ wᵢgᵢ| ≤ √(Σ wᵢ²) * √(Σ gᵢ²) have h_cs : |∑ i, w i * gx i| ≤ euclideanNorm n w * euclideanNorm n gx := inner_abs_le_norm_mul_norm' n w gx - -- euclideanNorm gx = √(Σ gᵢ²), and empiricalNorm = √(n⁻¹ Σ gᵢ²), so euclideanNorm = √n * empiricalNorm + -- euclideanNorm gx = √(Σ gᵢ²), and empiricalNorm = √(n⁻¹ Σ gᵢ²), + -- so euclideanNorm = √n * empiricalNorm have h_norm_gx_sq : (euclideanNorm n gx)^2 = n * (empiricalNorm n gx)^2 := by unfold euclideanNorm EmpiricalProcess.empiricalNorm rw [sq_sqrt, sq_sqrt] @@ -437,8 +441,10 @@ lemma empiricalProcess_le_delta_norm (n : ℕ) (hn : 0 < n) (x : Fin n → X) (H This follows from Cauchy-Schwarz: sup_{g ∈ B_n(δ)} |Z w g| ≤ δ * ‖w‖ / √n, and the Gaussian norm is integrable by Fernique's theorem. -/ -lemma localGaussianComplexity_integrand_integrable (n : ℕ) (H : Set (X → ℝ)) (δ : ℝ) (hδ : 0 < δ) (x : Fin n → X) : - Integrable (fun w => ⨆ g ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)|) (stdGaussianPi n) := by +lemma localGaussianComplexity_integrand_integrable (n : ℕ) (H : Set (X → ℝ)) (δ : ℝ) (hδ : 0 < δ) + (x : Fin n → X) : + Integrable (fun w => ⨆ g ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)|) + (stdGaussianPi n) := by by_cases hn : n = 0 case pos => subst hn @@ -457,10 +463,12 @@ lemma localGaussianComplexity_integrand_integrable (n : ℕ) (H : Set (X → ℝ case neg => push Not at hn have hn_pos : 0 < n := Nat.pos_of_ne_zero hn - have h_bound_int : Integrable (fun w => δ / Real.sqrt n * euclideanNorm n w) (stdGaussianPi n) := + have h_bound_int : + Integrable (fun w => δ / Real.sqrt n * euclideanNorm n w) (stdGaussianPi n) := (euclideanNorm_integrable_stdGaussianPi n).const_mul _ apply Integrable.mono' h_bound_int - · set F : (Fin n → ℝ) → ℝ := fun w => ⨆ g ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| + · set F : (Fin n → ℝ) → ℝ := + fun w => ⨆ g ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| set f : (X → ℝ) → (Fin n → ℝ) → ℝ := fun g w => ⨆ (_ : g ∈ localizedBall H δ x), |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| have h_bdd : ∀ w, BddAbove (Set.range fun g => f g w) := fun w => by @@ -473,7 +481,8 @@ lemma localGaussianComplexity_integrand_integrable (n : ℕ) (H : Set (X → ℝ exact empiricalProcess_le_delta_norm n hn_pos x H δ hδ g hg w · show f g w ≤ _ simp only [f, ciSup_neg hg, Real.sSup_empty] - apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) (euclideanNorm_nonneg _ _) + apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) + (euclideanNorm_nonneg _ _) have h_lsc : LowerSemicontinuous F := by have heq : F = fun w => ⨆ g, f g w := by ext w; rfl rw [heq]; apply lowerSemicontinuous_ciSup h_bdd; intro g @@ -499,7 +508,8 @@ lemma localGaussianComplexity_integrand_integrable (n : ℕ) (H : Set (X → ℝ · intro g; by_cases hg : g ∈ localizedBall H δ x · simp only [ciSup_pos hg]; exact empiricalProcess_le_delta_norm n hn_pos x H δ hδ g hg w · rw [ciSup_neg hg, Real.sSup_empty] - apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) (euclideanNorm_nonneg _ _) + apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) + (euclideanNorm_nonneg _ _) · apply mul_nonneg (div_nonneg (le_of_lt hδ) (Real.sqrt_nonneg _)) (euclideanNorm_nonneg _ _) /-- For star-shaped H, the function δ ↦ G_n(δ;H)/δ is non-increasing. @@ -560,10 +570,13 @@ lemma gaussian_complexity_ratio_antitone (n : ℕ) (H : Set (X → ℝ)) (x : Fi have hn_pos : (0 : ℝ) < n := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) have hn_nonneg : (0 : ℝ) ≤ n := le_of_lt hn_pos have hinv_nonneg : (0 : ℝ) ≤ (n : ℝ)⁻¹ := inv_nonneg.mpr hn_nonneg - have hCS_upper := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => w i) (fun i => g (x i)) - have hCS_neg : ∑ i : Fin n, (-(w i)) * g (x i) ≤ √(∑ i : Fin n, (-(w i)) ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := + have hCS_upper := + Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => w i) (fun i => g (x i)) + have hCS_neg : ∑ i : Fin n, (-(w i)) * g (x i) ≤ + √(∑ i : Fin n, (-(w i)) ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => -(w i)) (fun i => g (x i)) - have hCS_neg' : -(∑ i : Fin n, w i * g (x i)) ≤ √(∑ i : Fin n, w i ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := by + have hCS_neg' : -(∑ i : Fin n, w i * g (x i)) ≤ + √(∑ i : Fin n, w i ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := by have h1 : ∑ i : Fin n, (-(w i)) * g (x i) = -(∑ i : Fin n, w i * g (x i)) := by simp only [neg_mul, Finset.sum_neg_distrib] have h2 : ∑ i : Fin n, (-(w i)) ^ 2 = ∑ i : Fin n, w i ^ 2 := by @@ -571,10 +584,12 @@ lemma gaussian_complexity_ratio_antitone (n : ℕ) (H : Set (X → ℝ)) (x : Fi intro i _; ring rw [h1, h2] at hCS_neg exact hCS_neg - have hCS : |∑ i : Fin n, w i * g (x i)| ≤ √(∑ i : Fin n, w i ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := by + have hCS : |∑ i : Fin n, w i * g (x i)| ≤ + √(∑ i : Fin n, w i ^ 2) * √(∑ i : Fin n, g (x i) ^ 2) := by rw [abs_le] constructor - · linarith [mul_nonneg (Real.sqrt_nonneg (∑ i : Fin n, w i ^ 2)) (Real.sqrt_nonneg (∑ i : Fin n, g (x i) ^ 2))] + · linarith [mul_nonneg (Real.sqrt_nonneg (∑ i : Fin n, w i ^ 2)) + (Real.sqrt_nonneg (∑ i : Fin n, g (x i) ^ 2))] · exact hCS_upper calc |(n : ℝ)⁻¹ * ∑ i : Fin n, w i * g (x i)| = (n : ℝ)⁻¹ * |∑ i : Fin n, w i * g (x i)| := by @@ -632,7 +647,8 @@ lemma gaussian_complexity_ratio_antitone (n : ℕ) (H : Set (X → ℝ)) (x : Fi ≤ (∫ w, (t / δ) * ⨆ g ∈ localizedBall H δ x, Z w g ∂stdGaussianPi n) * δ := by apply mul_le_mul_of_nonneg_right _ (le_of_lt hδ) apply integral_mono_of_nonneg - · apply ae_of_all; intro w; exact Real.iSup_nonneg (fun _ => Real.iSup_nonneg (fun _ => abs_nonneg _)) + · apply ae_of_all; intro w + exact Real.iSup_nonneg (fun _ => Real.iSup_nonneg (fun _ => abs_nonneg _)) · apply Integrable.const_mul exact localGaussianComplexity_integrand_integrable n H δ hδ x · exact ae_of_all _ h_pointwise @@ -663,8 +679,8 @@ lemma empiricalProcess_zero (n : ℕ) (x : Fin n → X) (w : Fin n → ℝ) : /-- For star-shaped H, E[sup |Z_g|] ≤ 2 E[sup Z_g] under Gaussian measure. Uses Gaussian symmetry: E[sup(-Z_g)] = E[sup Z_g] since w and -w have the same distribution. -/ -lemma integral_abs_sup_le_two_mul_integral_sup_of_starShaped (n : ℕ) (H : Set (X → ℝ)) (x : Fin n → X) - (hH : IsStarShaped H) +lemma integral_abs_sup_le_two_mul_integral_sup_of_starShaped (n : ℕ) (H : Set (X → ℝ)) + (x : Fin n → X) (hH : IsStarShaped H) (hint_pos : Integrable (fun w => ⨆ g ∈ H, empiricalProcess n x g w) (stdGaussianPi n)) (hint_neg : Integrable (fun w => ⨆ g ∈ H, -empiricalProcess n x g w) (stdGaussianPi n)) : ∫ w, ⨆ g ∈ H, |empiricalProcess n x g w| ∂(stdGaussianPi n) ≤ @@ -725,7 +741,8 @@ lemma integral_abs_sup_le_two_mul_integral_sup_of_starShaped (n : ℕ) (H : Set linarith have h_nonneg_pos : 0 ≤ ⨆ g ∈ H, Z g w := h_nonneg_sup (fun g => Z g w) (hZ0 w) hbdd_pos - have h_nonneg_neg : 0 ≤ ⨆ g ∈ H, -Z g w := h_nonneg_sup (fun g => -Z g w) (by simp [hZ0 w]) hbdd_neg + have h_nonneg_neg : 0 ≤ ⨆ g ∈ H, -Z g w := + h_nonneg_sup (fun g => -Z g w) (by simp [hZ0 w]) hbdd_neg apply ciSup_le intro g @@ -792,7 +809,8 @@ lemma EmpiricalSpace.coord_sq_le (n : ℕ) (i : Fin n) (v : EmpiricalSpace n) : unfold EmpiricalProcess.empiricalNorm rw [sq_sqrt (by positivity : 0 ≤ (n : ℝ)⁻¹ * ∑ j : Fin n, (v j)^2)] have h_single : (v i : ℝ)^2 ≤ ∑ j : Fin n, (v j : ℝ)^2 := by - exact Finset.single_le_sum (f := fun j => (v j : ℝ)^2) (fun j _ => sq_nonneg _) (Finset.mem_univ i) + exact Finset.single_le_sum (f := fun j => (v j : ℝ)^2) (fun j _ => sq_nonneg _) + (Finset.mem_univ i) calc (v i)^2 ≤ ∑ j : Fin n, (v j)^2 := h_single _ = n * ((n : ℝ)⁻¹ * ∑ j : Fin n, (v j)^2) := by field_simp @@ -957,12 +975,14 @@ lemma dudley_empiricalProcess (n : ℕ) (hn : 0 < n) (x : Fin n → X) have hcont' : ∀ w, Continuous (fun (v : ↥Gx) => Z v.1 w) := hcont have h_sup_eq : ∀ w, (⨆ g ∈ G, empiricalProcess n x g w) = ⨆ v ∈ Gx, innerProductProcess n v w := fun w => by - have h_eq : ∀ g, empiricalProcess n x g w = innerProductProcess n (empiricalMetricImage n x g) w := + have h_eq : ∀ g, + empiricalProcess n x g w = innerProductProcess n (empiricalMetricImage n x g) w := fun g => empiricalProcess_eq_innerProductProcess n x g w simp_rw [h_eq] simp only [Gx] have hG_nonempty : G.Nonempty := hG_ne - have h_bdd : BddAbove (Set.range fun (g : ↥G) => innerProductProcess n (empiricalMetricImage n x g.1) w) := by + have h_bdd : BddAbove (Set.range fun (g : ↥G) => + innerProductProcess n (empiricalMetricImage n x g.1) w) := by use Real.sqrt (∑ i, (w i)^2) * D + 1 intro y hy obtain ⟨⟨g, hg⟩, rfl⟩ := hy @@ -1004,7 +1024,8 @@ lemma dudley_empiricalProcess (n : ℕ) (hn : 0 < n) (x : Fin n → X) have hn_pos : (0 : ℝ) < n := Nat.cast_pos.mpr hn have hD_nonneg : 0 ≤ D := le_of_lt hD have h_sum_sq : ∑ i, (g (x i))^2 ≤ n * D^2 := by - have h1 : empiricalNorm n (fun i => g (x i)) = Real.sqrt ((n : ℝ)⁻¹ * ∑ i, (g (x i))^2) := rfl + have h1 : empiricalNorm n (fun i => g (x i)) = + Real.sqrt ((n : ℝ)⁻¹ * ∑ i, (g (x i))^2) := rfl have h_norm_nonneg : 0 ≤ empiricalNorm n (fun i => g (x i)) := by unfold EmpiricalProcess.empiricalNorm positivity @@ -1117,7 +1138,8 @@ lemma local_gaussian_complexity_bound (n : ℕ) (hn : 0 < n) (H : Set (X → ℝ (hint_neg : Integrable (fun w => ⨆ g ∈ localizedBall H δ x, -empiricalProcess n x g w) (stdGaussianPi n)) : LocalGaussianComplexity n H δ x ≤ - (24 * Real.sqrt 2) / Real.sqrt n * entropyIntegral (empiricalMetricImage n x '' localizedBall H δ x) (2*δ) := by + (24 * Real.sqrt 2) / Real.sqrt n * + entropyIntegral (empiricalMetricImage n x '' localizedBall H δ x) (2*δ) := by let G := localizedBall H δ x let Gx := empiricalMetricImage n x '' G let μ := stdGaussianPi n @@ -1128,7 +1150,8 @@ lemma local_gaussian_complexity_bound (n : ℕ) (hn : 0 < n) (H : Set (X → ℝ have hdiam : Metric.diam Gx ≤ 2 * δ := localizedBall_diam n H δ (le_of_lt hδ) x have h0_center : ∀ i, (0 : X → ℝ) (x i) = 0 := fun _ => rfl unfold LocalGaussianComplexity - have h_abs_bound := integral_abs_sup_le_two_mul_integral_sup_of_starShaped n G x hG_star hint_pos hint_neg + have h_abs_bound := + integral_abs_sup_le_two_mul_integral_sup_of_starShaped n G x hG_star hint_pos hint_neg have h_dudley := dudley_empiricalProcess n hn x G hH_tb (2*δ) hD hdiam (0 : X → ℝ) h0_G h0_center hfinite hcont calc ∫ w, ⨆ h ∈ G, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| ∂μ diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Localization.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Localization.lean index 7d1db4f..d56e9e6 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Localization.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Localization.lean @@ -81,7 +81,8 @@ lemma empiricalNorm_smul_of_nonneg {f : Fin n → ℝ} {α : ℝ} (hα : 0 ≤ simp only [h1] rw [← Finset.mul_sum] -- Goal: √(n⁻¹ * (α² * Σf²)) = α * √(n⁻¹ * Σf²) - have h2 : (n : ℝ)⁻¹ * (α ^ 2 * ∑ i : Fin n, f i ^ 2) = α ^ 2 * ((n : ℝ)⁻¹ * ∑ i : Fin n, f i ^ 2) := by + have h2 : (n : ℝ)⁻¹ * (α ^ 2 * ∑ i : Fin n, f i ^ 2) = + α ^ 2 * ((n : ℝ)⁻¹ * ∑ i : Fin n, f i ^ 2) := by ring rw [h2] rw [Real.sqrt_mul (sq_nonneg α)] @@ -242,7 +243,8 @@ lemma scaled_biSup_le {H : Set (X → ℝ)} (hH : IsStarShaped H) have h0_mem : (0 : X → ℝ) ∈ localizedBall H t x := zero_mem_localizedBall hH ht have h0_val : |(n : ℝ)⁻¹ * ∑ i, w i * (0 : X → ℝ) (x i)| = 0 := by simp only [Pi.zero_apply, mul_zero, Finset.sum_const_zero, mul_zero, abs_zero] - have h0_in : (0 : ℝ) ∈ {y | ∃ h ∈ localizedBall H t x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)|} := by + have h0_in : + (0 : ℝ) ∈ {y | ∃ h ∈ localizedBall H t x, y = |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)|} := by exact ⟨0, h0_mem, h0_val.symm⟩ exact le_trans (le_refl 0) (hM h0_in) use M -- Same bound works since localizedBall δ ⊆ localizedBall t @@ -315,7 +317,8 @@ lemma scaled_biSup_le {H : Set (X → ℝ)} (hH : IsStarShaped H) have h_empty : IsEmpty (h ∈ localizedBall H t x) := by rw [isEmpty_Prop] exact hh - have h_zero : (⨆ _ : h ∈ localizedBall H t x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| * (δ / t)) = 0 := by + have h_zero : + (⨆ _ : h ∈ localizedBall H t x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| * (δ / t)) = 0 := by simp only [iSup_of_empty'] exact Real.sSup_empty rw [h_zero] @@ -367,7 +370,8 @@ theorem gaussian_complexity_monotone {H : Set (X → ℝ)} (hH : IsStarShaped H) rw [h_lhs] -- Rewrite RHS to have t on the left: (∫ sup_δ) * t = t * (∫ sup_δ) - rw [mul_comm (∫ w, ⨆ h ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| ∂(stdGaussianPi n)) t] + rw [mul_comm + (∫ w, ⨆ h ∈ localizedBall H δ x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| ∂(stdGaussianPi n)) t] -- It suffices to show (δ/t) * ∫ sup_t ≤ ∫ sup_δ, then multiply by t apply mul_le_mul_of_nonneg_left _ (le_of_lt ht) @@ -375,7 +379,8 @@ theorem gaussian_complexity_monotone {H : Set (X → ℝ)} (hH : IsStarShaped H) -- Pull scalar into the integral: c * ∫ f = ∫ c • f have h_smul_eq : δ / t * (∫ w, ⨆ h ∈ localizedBall H t x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)| ∂(stdGaussianPi n)) = - ∫ w, (δ / t) * (⨆ h ∈ localizedBall H t x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)|) ∂(stdGaussianPi n) := by + ∫ w, (δ / t) * (⨆ h ∈ localizedBall H t x, |(n : ℝ)⁻¹ * ∑ i, w i * h (x i)|) + ∂(stdGaussianPi n) := by rw [← smul_eq_mul, ← integral_smul] simp only [smul_eq_mul] rw [h_smul_eq] diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean b/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean index 035144a..19b3ea0 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean @@ -107,7 +107,8 @@ Z(u) is a supremum of linear functions ⟨a_g, w⟩ with ‖a_g‖₂ ≤ σu/ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) (H : Set (X → ℝ)) (x : Fin n → X) (hne : (empiricalSphere n H u x).Nonempty) - (hbdd : ∀ w : Fin n → ℝ, BddAbove {y | ∃ g ∈ empiricalSphere n H u x, y = |σ / n * ∑ i, w i * g (x i)|}) : + (hbdd : ∀ w : Fin n → ℝ, + BddAbove {y | ∃ g ∈ empiricalSphere n H u x, y = |σ / n * ∑ i, w i * g (x i)|}) : LipschitzWith (Real.toNNReal (σ * u / Real.sqrt n)) (Z_supremum n σ H u x ∘ (EuclideanSpace.equiv (Fin n) ℝ)) := by rw [lipschitzWith_iff_dist_le_mul] @@ -160,7 +161,8 @@ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) ext i ring rw [h_inner] - have h_cs_inner := abs_sum_le_sqrt_sq_mul_sqrt_sq (fun i => w₁ i - w₂ i) (fun i => σ / n * g (x i)) + have h_cs_inner := + abs_sum_le_sqrt_sq_mul_sqrt_sq (fun i => w₁ i - w₂ i) (fun i => σ / n * g (x i)) calc |∑ i, (w₁ i - w₂ i) * (σ / n * g (x i))| ≤ Real.sqrt (∑ i, (w₁ i - w₂ i)^2) * Real.sqrt (∑ i, (σ / n * g (x i))^2) := h_cs_inner _ = Real.sqrt (∑ i, (w₁ i - w₂ i)^2) * (σ * u / Real.sqrt n) := by @@ -238,7 +240,8 @@ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) rw [← heq]; dsimp only [] by_cases hh : h ∈ empiricalSphere n H u x · rw [ciSup_pos hh]; apply le_csSup hbdd₂; exact ⟨h, hh, rfl⟩ - · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg; intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _⟩ + · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg + intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _⟩ · apply mul_nonneg hL_nonneg dist_nonneg -- Z(w₂) ≤ Z(w₁) + L * dist (by symmetry) have h_sub₂ : (⨆ g ∈ empiricalSphere n H u x, |σ / n * ∑ i, w₂ i * g (x i)|) ≤ @@ -286,7 +289,8 @@ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) rw [← heq]; dsimp only [] by_cases hh : h ∈ empiricalSphere n H u x · rw [ciSup_pos hh]; apply le_csSup hbdd₁; exact ⟨h, hh, rfl⟩ - · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg; intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _ + · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg + intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _ apply le_ciSup_of_le hbdd₁' g rw [ciSup_pos hg] have h3' : |σ / n * ∑ i, (w₂ i - w₁ i) * g (x i)| ≤ σ * u / Real.sqrt n * dist v₂ v₁ := by @@ -301,9 +305,11 @@ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) ext i ring rw [h_inner] - have h_cs_inner := abs_sum_le_sqrt_sq_mul_sqrt_sq (fun i => w₂ i - w₁ i) (fun i => σ / n * g (x i)) + have h_cs_inner := + abs_sum_le_sqrt_sq_mul_sqrt_sq (fun i => w₂ i - w₁ i) (fun i => σ / n * g (x i)) calc |∑ i, (w₂ i - w₁ i) * (σ / n * g (x i))| - ≤ Real.sqrt (∑ i, (w₂ i - w₁ i)^2) * Real.sqrt (∑ i, (σ / n * g (x i))^2) := h_cs_inner + ≤ Real.sqrt (∑ i, (w₂ i - w₁ i)^2) * Real.sqrt (∑ i, (σ / n * g (x i))^2) := + h_cs_inner _ = Real.sqrt (∑ i, (w₂ i - w₁ i)^2) * (σ * u / Real.sqrt n) := by congr 1 exact coefficient_euclidean_norm hn σ u hσ g x hg_norm @@ -329,7 +335,8 @@ lemma Z_supremum_lipschitz (hn : 0 < n) (σ u : ℝ) (hσ : 0 < σ) (hu : 0 < u) rw [← heq]; dsimp only [] by_cases hh : h ∈ empiricalSphere n H u x · rw [ciSup_pos hh]; apply le_csSup hbdd₁; exact ⟨h, hh, rfl⟩ - · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg; intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _⟩ + · rw [ciSup_neg hh, Real.sSup_empty]; apply Real.sSup_nonneg + intro y ⟨_, _, hy⟩; exact hy ▸ abs_nonneg _⟩ · apply mul_nonneg hL_nonneg dist_nonneg -- Combine to get |Z(w₁) - Z(w₂)| ≤ L * dist rw [abs_sub_le_iff] @@ -432,10 +439,12 @@ lemma Z_le_sigma_mul_localComplexity (n : ℕ) (hn : 0 < n) (σ : ℝ) (H : Set by_cases hh : h ∈ localizedBall H u x · simp only [ciSup_pos hh] -- |σ/n * ∑ w_i h(x_i)| ≤ bound - have h_cs : |∑ i, w i * h (x i)| ≤ Real.sqrt (∑ i, (w i)^2) * Real.sqrt (∑ i, (h (x i))^2) := by + have h_cs : |∑ i, w i * h (x i)| ≤ + Real.sqrt (∑ i, (w i)^2) * Real.sqrt (∑ i, (h (x i))^2) := by rw [abs_le] constructor - · have h' := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => -w i) (fun i => h (x i)) + · have h' := + Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => -w i) (fun i => h (x i)) simp_rw [neg_mul, Finset.sum_neg_distrib, neg_sq] at h' linarith · exact Real.sum_mul_le_sqrt_mul_sqrt Finset.univ w (fun i => h (x i)) @@ -453,7 +462,8 @@ lemma Z_le_sigma_mul_localComplexity (n : ℕ) (hn : 0 < n) (σ : ℝ) (H : Set calc ∑ i, (h (x i))^2 = n * ((n : ℝ)⁻¹ * ∑ i, (h (x i))^2) := by field_simp _ ≤ n * u^2 := by nlinarith [sq_nonneg u] calc Real.sqrt (∑ i, (h (x i))^2) ≤ Real.sqrt (n * u^2) := Real.sqrt_le_sqrt h_sum - _ = Real.sqrt n * |u| := Real.sqrt_mul (Nat.cast_nonneg n) (u^2) ▸ Real.sqrt_sq_eq_abs u ▸ rfl + _ = Real.sqrt n * |u| := + Real.sqrt_mul (Nat.cast_nonneg n) (u^2) ▸ Real.sqrt_sq_eq_abs u ▸ rfl _ = Real.sqrt n * u := by rw [abs_of_nonneg h_u_nonneg] calc |σ / n * ∑ i, w i * h (x i)| = |σ| / n * |∑ i, w i * h (x i)| := by rw [abs_mul, abs_div] @@ -462,7 +472,8 @@ lemma Z_le_sigma_mul_localComplexity (n : ℕ) (hn : 0 < n) (σ : ℝ) (H : Set _ ≤ |σ| / n * (Real.sqrt (∑ i, (w i)^2) * Real.sqrt (∑ i, (h (x i))^2)) := by apply mul_le_mul_of_nonneg_left h_cs; positivity _ ≤ |σ| / n * (Real.sqrt (∑ i, (w i)^2) * (Real.sqrt n * u)) := by - apply mul_le_mul_of_nonneg_left; apply mul_le_mul_of_nonneg_left h_norm; positivity; positivity + apply mul_le_mul_of_nonneg_left; apply mul_le_mul_of_nonneg_left h_norm + positivity; positivity _ = |σ| * u * Real.sqrt (∑ i, (w i)^2) / Real.sqrt n := by field_simp rw [Real.sq_sqrt (Nat.cast_nonneg n)] @@ -470,7 +481,8 @@ lemma Z_le_sigma_mul_localComplexity (n : ℕ) (hn : 0 < n) (σ : ℝ) (H : Set _ ≤ bound := le_add_of_nonneg_right (by linarith) · -- When h ∉ ball, the inner iSup is sSup ∅ = 0 in ℝ have h_iSup_eq : (⨆ _ : h ∈ localizedBall H u x, |σ / n * ∑ i, w i * h (x i)|) = 0 := by - have h_range_empty : Set.range (fun _ : h ∈ localizedBall H u x => |σ / n * ∑ i, w i * h (x i)|) = ∅ := by + have h_range_empty : Set.range + (fun _ : h ∈ localizedBall H u x => |σ / n * ∑ i, w i * h (x i)|) = ∅ := by ext y simp only [Set.mem_range, Set.mem_empty_iff_false, iff_false] intro ⟨hmem, _⟩ @@ -557,7 +569,8 @@ lemma Z_le_sigma_mul_localComplexity (n : ℕ) (hn : 0 < n) (σ : ℝ) (H : Set -- Now factor out σ have h2 : ⨆ g ∈ localizedBall H u x, |σ / n * ∑ i, w i * g (x i)| = σ * ⨆ g ∈ localizedBall H u x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := by - have h_factor : ∀ g : X → ℝ, |σ / n * ∑ i, w i * g (x i)| = σ * |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := by + have h_factor : ∀ g : X → ℝ, + |σ / n * ∑ i, w i * g (x i)| = σ * |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)| := by intro g rw [div_eq_mul_inv, mul_assoc, abs_mul, abs_of_pos hσ] conv_lhs => @@ -591,7 +604,8 @@ lemma Z_expectation_bound (hn : 0 < n) {σ δ_star u : ℝ} σ * (⨆ g ∈ localizedBall H u x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)|) := fun w => Z_le_sigma_mul_localComplexity n hn σ H u x w hσ have h_int_bound : ∫ w, Z_supremum n σ H u x w ∂(stdGaussianPi n) ≤ - ∫ w, σ * (⨆ g ∈ localizedBall H u x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)|) ∂(stdGaussianPi n) := by + ∫ w, σ * (⨆ g ∈ localizedBall H u x, |(n : ℝ)⁻¹ * ∑ i, w i * g (x i)|) + ∂(stdGaussianPi n) := by apply integral_mono_of_nonneg · -- Z is nonneg apply ae_of_all @@ -732,10 +746,12 @@ theorem bad_event_probability_bound (hn : 0 < n) {σ δ_star u : ℝ} by_cases hh : h ∈ empiricalSphere n H u x · simp only [ciSup_pos hh] -- Bound using Cauchy-Schwarz (same as in Z_le_sigma_mul_localComplexity) - have h_cs : |∑ i, w i * h (x i)| ≤ Real.sqrt (∑ i, (w i)^2) * Real.sqrt (∑ i, (h (x i))^2) := by + have h_cs : |∑ i, w i * h (x i)| ≤ + Real.sqrt (∑ i, (w i)^2) * Real.sqrt (∑ i, (h (x i))^2) := by rw [abs_le] constructor - · have h' := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => -w i) (fun i => h (x i)) + · have h' := + Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i => -w i) (fun i => h (x i)) simp_rw [neg_mul, Finset.sum_neg_distrib, neg_sq] at h' linarith · exact Real.sum_mul_le_sqrt_mul_sqrt Finset.univ w (fun i => h (x i)) @@ -746,7 +762,8 @@ theorem bad_event_probability_bound (hn : 0 < n) {σ δ_star u : ℝ} have h_inner_nonneg : 0 ≤ (n : ℝ)⁻¹ * ∑ i, (h (x i))^2 := by positivity have h_eq : (n : ℝ)⁻¹ * ∑ i, (h (x i))^2 = u^2 := by calc (n : ℝ)⁻¹ * ∑ i, (h (x i))^2 - = Real.sqrt ((n : ℝ)⁻¹ * ∑ i, (h (x i))^2) ^ 2 := (sq_sqrt h_inner_nonneg).symm + = Real.sqrt ((n : ℝ)⁻¹ * ∑ i, (h (x i))^2) ^ 2 := + (sq_sqrt h_inner_nonneg).symm _ = u ^ 2 := by rw [hh_norm] have hn_pos' : (0 : ℝ) < n := Nat.cast_pos.mpr hn field_simp at h_eq ⊢ @@ -763,10 +780,13 @@ theorem bad_event_probability_bound (hn : 0 < n) {σ δ_star u : ℝ} _ = |σ| / n * (Real.sqrt (∑ i, (w i)^2) * (Real.sqrt n * u)) := by rw [h_norm_eq] _ = |σ| * u * Real.sqrt (∑ i, (w i)^2) / Real.sqrt n := by field_simp; rw [Real.sq_sqrt (Nat.cast_nonneg n)]; ring - _ ≤ |σ| * u * Real.sqrt (∑ i, (w i)^2) / Real.sqrt n + 1 := le_add_of_nonneg_right (by linarith) + _ ≤ |σ| * u * Real.sqrt (∑ i, (w i)^2) / Real.sqrt n + 1 := + le_add_of_nonneg_right (by linarith) · -- h ∉ sphere, so inner iSup = sSup ∅ = 0 - have h_eq_zero : (⨆ _ : h ∈ empiricalSphere n H u x, |σ / n * ∑ i, w i * h (x i)|) = 0 := by - have h_range_empty : Set.range (fun _ : h ∈ empiricalSphere n H u x => |σ / n * ∑ i, w i * h (x i)|) = ∅ := by + have h_eq_zero : + (⨆ _ : h ∈ empiricalSphere n H u x, |σ / n * ∑ i, w i * h (x i)|) = 0 := by + have h_range_empty : Set.range + (fun _ : h ∈ empiricalSphere n H u x => |σ / n * ∑ i, w i * h (x i)|) = ∅ := by ext y; simp only [Set.mem_range, Set.mem_empty_iff_false, iff_false] intro ⟨hmem, _⟩; exact hh hmem simp only [iSup, h_range_empty, Real.sSup_empty] @@ -803,7 +823,8 @@ theorem bad_event_probability_bound (hn : 0 < n) {σ δ_star u : ℝ} -- Transfer: measures of sets match have h_meas_eq : μ_E {y | u^2 ≤ Z_E y - ∫ z, Z_E z ∂μ_E} = - stdGaussianPi n {w | u^2 ≤ Z_supremum n σ H u x w - ∫ z, Z_supremum n σ H u x z ∂(stdGaussianPi n)} := by + stdGaussianPi n + {w | u^2 ≤ Z_supremum n σ H u x w - ∫ z, Z_supremum n σ H u x z ∂(stdGaussianPi n)} := by -- First rewrite the integral using h_int_eq conv_lhs => rw [h_int_eq] simp only [μ_E, stdGaussianE] @@ -866,7 +887,8 @@ lemma goodEvent_implies_process_bound {n : ℕ} {σ t δ_star : ℝ} {H : Set (X → ℝ)} {x : Fin n → X} {w : Fin n → ℝ} (hw : w ∈ goodEvent n σ H t δ_star x) (g : X → ℝ) (hg : g ∈ empiricalOuterRegion n H (Real.sqrt (t * δ_star)) x) : - |σ / n * ∑ i, w i * g (x i)| < 2 * empiricalNorm n (fun i => g (x i)) * Real.sqrt (t * δ_star) := by + |σ / n * ∑ i, w i * g (x i)| < + 2 * empiricalNorm n (fun i => g (x i)) * Real.sqrt (t * δ_star) := by simp only [goodEvent, Set.mem_compl_iff, badEvent, Set.mem_ofPred_eq] at hw push Not at hw exact hw g hg @@ -926,7 +948,8 @@ theorem master_error_bound (hn : 0 < n) -- The good event implies the bound have h_good_implies : goodEvent n M.σ H t δ_star M.x ⊆ - {w | (empiricalNorm n (fun i => f_hat w (M.x i) - M.f_star (M.x i)))^2 ≤ 16 * t * δ_star} := by + {w | (empiricalNorm n (fun i => f_hat w (M.x i) - M.f_star (M.x i)))^2 ≤ + 16 * t * δ_star} := by intro w hw simp only [Set.mem_ofPred_eq] -- Set Δ = f_hat - f_star @@ -953,7 +976,8 @@ theorem master_error_bound (hn : 0 < n) exact le_of_lt hcase -- Use the good event bound - have h_process_bound := goodEvent_implies_process_bound hw (fun y => f_hat w y - M.f_star y) hΔ_outer + have h_process_bound := + goodEvent_implies_process_bound hw (fun y => f_hat w y - M.f_star y) hΔ_outer -- Use basic inequality have h_basic := basic_inequality hn M F (f_hat w) w (hf_hat w) hF_star @@ -967,7 +991,8 @@ theorem master_error_bound (hn : 0 < n) -- |σ/n Σ wᵢΔᵢ| < 2‖Δ‖_n u calc M.σ / ↑n * ∑ i, w i * (f_hat w (M.x i) - M.f_star (M.x i)) ≤ |M.σ / ↑n * ∑ i, w i * (f_hat w (M.x i) - M.f_star (M.x i))| := le_abs_self _ - _ ≤ 2 * empiricalNorm n (fun i => (fun y => f_hat w y - M.f_star y) (M.x i)) * u := le_of_lt h_abs + _ ≤ 2 * empiricalNorm n (fun i => (fun y => f_hat w y - M.f_star y) (M.x i)) * u := + le_of_lt h_abs _ = 2 * norm_Δ * u := by simp only [hnorm_def, hΔ_def] -- From basic inequality: (1/2)‖Δ‖_n² ≤ (σ/n) Σ wᵢΔᵢ diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/SubGaussianity.lean b/StatsMLlib/Statistics/Regression/LeastSquares/SubGaussianity.lean index 22d74eb..44def53 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/SubGaussianity.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/SubGaussianity.lean @@ -128,7 +128,8 @@ lemma empiricalProcess_increment_mgf (n : ℕ) [NeZero n] (x : Fin n → X) -- Step 4: Expand stdGaussianPi and use Fubini unfold stdGaussianPi -- Use integral_fin_nat_prod_eq_prod to factor the integral - have h_fubini : (∫ w : (i : Fin n) → ℝ, ∏ i, Real.exp (t * a i * w i) ∂(Measure.pi fun _ => gaussianReal 0 1)) = + have h_fubini : (∫ w : (i : Fin n) → ℝ, ∏ i, Real.exp (t * a i * w i) + ∂(Measure.pi fun _ => gaussianReal 0 1)) = ∏ i : Fin n, ∫ x : ℝ, Real.exp (t * a i * x) ∂(gaussianReal 0 1) := by exact integral_fin_nat_prod_eq_prod (fun i x => Real.exp (t * a i * x)) rw [h_fubini] diff --git a/StatsMLlib/Topology/MetricSpace/CoveringNumber/Basic.lean b/StatsMLlib/Topology/MetricSpace/CoveringNumber/Basic.lean index 7571c9e..f9023b2 100644 --- a/StatsMLlib/Topology/MetricSpace/CoveringNumber/Basic.lean +++ b/StatsMLlib/Topology/MetricSpace/CoveringNumber/Basic.lean @@ -70,7 +70,8 @@ lemma coveringNumber_le_card {A : Type*} [PseudoMetricSpace A] {t : Finset A} {e `coveringNumber_le_card` asks for an `IsENet`, which is phrased with closed balls; a cover by open balls of the same radius is a stronger hypothesis, so it is often the one available at a use site. -/ -lemma coveringNumber_le_card_of_cover {A : Type*} [PseudoMetricSpace A] {t : Finset A} {eps : ℝ} {s : Set A} +lemma coveringNumber_le_card_of_cover {A : Type*} [PseudoMetricSpace A] {t : Finset A} {eps : ℝ} + {s : Set A} (ht : s ⊆ ⋃ y ∈ t, Metric.ball y eps) : coveringNumber eps s ≤ (t.card : WithTop ℕ) := by refine coveringNumber_le_card ?_ @@ -81,7 +82,8 @@ lemma coveringNumber_le_card_of_cover {A : Type*} [PseudoMetricSpace A] {t : Fin /-- Every subset of a finite pseudometric space is covered by taking all of its points as centres, so its covering number is at most the cardinality of the type. -/ -lemma coveringNumber_le_fintype_card {A : Type*} [PseudoMetricSpace A] [Fintype A] {eps : ℝ} (heps : 0 < eps) (s : Set A) : +lemma coveringNumber_le_fintype_card {A : Type*} [PseudoMetricSpace A] [Fintype A] {eps : ℝ} + (heps : 0 < eps) (s : Set A) : coveringNumber eps s ≤ (Fintype.card A : WithTop ℕ) := by classical refine le_trans (coveringNumber_le_card (t := Finset.univ) ?_) ?_ @@ -255,7 +257,8 @@ lemma exists_optimal_enet {eps : ℝ} {s : Set A} (heps : 0 < eps) (hs : TotallyBounded s) : ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = coveringNumber eps s := by -- The set of cardinalities of eps-nets is nonempty - have hne_set : {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n}.Nonempty := by + have hne_set : + {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n}.Nonempty := by obtain ⟨t, ht⟩ := exists_finset_isENet_of_totallyBounded heps hs exact ⟨t.card, t, ht, rfl⟩ exact csInf_mem hne_set @@ -332,8 +335,10 @@ lemma coveringNumber_pos_of_nonempty_totallyBounded {eps : ℝ} {s : Set A} rw [h] at hn have hzero : coveringNumber eps s = 0 := hn unfold coveringNumber at hzero - have hmem : (0 : WithTop ℕ) ∈ {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n} := by - have hne_set : {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n}.Nonempty := by + have hmem : (0 : WithTop ℕ) ∈ + {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n} := by + have hne_set : + {n : WithTop ℕ | ∃ t : Finset A, IsENet t eps s ∧ (t.card : WithTop ℕ) = n}.Nonempty := by obtain ⟨t, ht⟩ := exists_finset_isENet_of_totallyBounded heps hs exact ⟨t.card, t, ht, rfl⟩ have hsInf := csInf_mem hne_set @@ -531,7 +536,9 @@ theorem coveringNumber_image_of_isometry {f : A → B} (hf : Isometry f) (hbij : by_cases hcover : coveringNumber eps (f '' s) = ⊤ · simp [hcover] push Not at hcover - have hne : {m : WithTop ℕ | ∃ t : Finset B, IsENet t eps (f '' s) ∧ (t.card : WithTop ℕ) = m}.Nonempty := by + have hne : + {m : WithTop ℕ | + ∃ t : Finset B, IsENet t eps (f '' s) ∧ (t.card : WithTop ℕ) = m}.Nonempty := by by_contra hemp have : coveringNumber eps (f '' s) = ⊤ := by unfold coveringNumber diff --git a/StatsMLlib/Topology/SeparableSpace/Supremum.lean b/StatsMLlib/Topology/SeparableSpace/Supremum.lean index e963350..0900b43 100644 --- a/StatsMLlib/Topology/SeparableSpace/Supremum.lean +++ b/StatsMLlib/Topology/SeparableSpace/Supremum.lean @@ -14,8 +14,8 @@ universe u v w open TopologicalSpace -lemma closure_mem_le_sSup {E : Type v} [ConditionallyCompleteLattice E] [TopologicalSpace E] [OrderClosedTopology E] - {s : Set E} (hs' : BddAbove s) {b : E} (hb : b ∈ closure s) : +lemma closure_mem_le_sSup {E : Type v} [ConditionallyCompleteLattice E] [TopologicalSpace E] + [OrderClosedTopology E] {s : Set E} (hs' : BddAbove s) {b : E} (hb : b ∈ closure s) : b ≤ sSup s := by have : s ⊆ Set.Iic (sSup s) := by intro x hx @@ -24,8 +24,8 @@ lemma closure_mem_le_sSup {E : Type v} [ConditionallyCompleteLattice E] [Topolog apply closure_minimal this isClosed_Iic exact this hb -lemma sSup_eq_closure_sSup {E : Type v} [ConditionallyCompleteLattice E] [TopologicalSpace E] [OrderClosedTopology E] - {s : Set E} (hs : s.Nonempty) (hs' : BddAbove s) : +lemma sSup_eq_closure_sSup {E : Type v} [ConditionallyCompleteLattice E] [TopologicalSpace E] + [OrderClosedTopology E] {s : Set E} (hs : s.Nonempty) (hs' : BddAbove s) : sSup s = sSup (closure s) := by have h' : (BddAbove (closure s)) := by use sSup s @@ -37,7 +37,8 @@ lemma sSup_eq_closure_sSup {E : Type v} [ConditionallyCompleteLattice E] [Topolo · apply csSup_le (by aesop) exact fun b hb ↦ closure_mem_le_sSup hs' hb -lemma closure_range_eq_closure_denseSeq {X : Type u} [TopologicalSpace X] [SeparableSpace X] [Nonempty X] +lemma closure_range_eq_closure_denseSeq {X : Type u} [TopologicalSpace X] [SeparableSpace X] + [Nonempty X] {E : Type v} [ConditionallyCompleteLattice E] [TopologicalSpace E] [OrderClosedTopology E] {f : X → E} (hf : Continuous f) : closure (Set.range f) = closure (Set.range (f ∘ denseSeq X)) := by From 459ace7e9021b2a6c4d9998e73b292d45cb70a4f Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 19 Oct 2026 14:08:22 +0900 Subject: [PATCH 7/7] Fix style linter warnings in the remaining Probability modules Wrap lines over 100 characters and fix the other style linter warnings (`refine'`, focusing dots, missing `end`) reported once the linter option names in `lakefile.lean` are corrected. Formatting only; no statement changes. Part of #71. Co-Authored-By: Claude Opus 5.5 --- .../Entropy/Conditional/Basic.lean | 21 ++-- .../Entropy/Conditional/Decomposition.lean | 3 +- .../Entropy/Conditional/Subadditivity.lean | 76 ++++++++---- StatsMLlib/Probability/Entropy/Duality.lean | 9 +- .../Probability/Entropy/Variational.lean | 12 +- StatsMLlib/Probability/Gaussian/Basic.lean | 9 +- .../Probability/Gaussian/Lipschitz.lean | 9 +- .../Gaussian/LipschitzConcentration.lean | 79 ++++++++----- .../Gaussian/Poincare/EfronStein.lean | 24 ++-- .../Probability/Gaussian/Poincare/Limit.lean | 33 ++++-- .../Poincare/RademacherApproximation.lean | 6 +- .../Probability/Gaussian/Poincare/Taylor.lean | 31 +++-- .../Probability/Gaussian/Sobolev/Cutoff.lean | 63 ++++++---- .../Probability/Gaussian/Sobolev/Defs.lean | 14 ++- .../Probability/Gaussian/Sobolev/Density.lean | 44 ++++--- .../Gaussian/Sobolev/Mollification.lean | 109 ++++++++++++------ .../GraphicalModel/Factorization.lean | 6 +- .../Probability/Independence/FinsetPi.lean | 3 +- StatsMLlib/Probability/Moments/Cumulant.lean | 2 + .../Probability/RandomMatrix/Basic.lean | 10 +- .../Probability/RandomMatrix/Bernstein.lean | 11 +- StatsMLlib/Probability/SmallBall.lean | 12 +- 22 files changed, 392 insertions(+), 194 deletions(-) diff --git a/StatsMLlib/Probability/Entropy/Conditional/Basic.lean b/StatsMLlib/Probability/Entropy/Conditional/Basic.lean index 990f1ad..ddd31fe 100644 --- a/StatsMLlib/Probability/Entropy/Conditional/Basic.lean +++ b/StatsMLlib/Probability/Entropy/Conditional/Basic.lean @@ -40,7 +40,8 @@ local notation "μˢ" => Measure.pi μs ## Definition of Conditional Entropy -/ -/-- Conditional entropy Ent^{(i)}(f)(x) = E^{(i)}[f log f](x) - E^{(i)}[f](x) · log(E^{(i)}[f](x)). -/ +/-- Conditional entropy +Ent^{(i)}(f)(x) = E^{(i)}[f log f](x) - E^{(i)}[f](x) · log(E^{(i)}[f](x)). -/ noncomputable def condEntExceptCoord (i : Fin n) (f : (Fin n → Ω) → ℝ) : (Fin n → Ω) → ℝ := fun x => condExpExceptCoord (μs := μs) i (fun z => f z * log (f z)) x - condExpExceptCoord (μs := μs) i f x * log (condExpExceptCoord (μs := μs) i f x) @@ -129,10 +130,12 @@ lemma condExpExceptCoord_integrable (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => + f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := hmp.integrable_comp hf_int.aestronglyMeasurable |>.mpr hf_int unfold condExpExceptCoord simpa [Pi.pow_apply] using hg_int.integral_prod_left @@ -152,10 +155,12 @@ lemma integrable_update_slice (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i - have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := + have hg_int : Integrable (fun p : (Fin n → Ω) × Ω => + f (Function.update p.1 i p.2)) (μˢ.prod (μs i)) := hmp.integrable_comp hf_int.aestronglyMeasurable |>.mpr hf_int exact hg_int.prod_right_ae @@ -174,7 +179,8 @@ lemma ae_nonneg_slice_of_ae_nonneg (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i -- Transfer the a.e. condition through the measure-preserving map @@ -220,7 +226,8 @@ lemma condExpExceptCoord_mul_log_integrable (i : Fin n) (f : (Fin n → Ω) → have hg_nn : 0 ≤ᵐ[μˢ] g := condExpExceptCoord_nonneg_ae i f hf_nn -- h is integrable (by condExpExceptCoord_integrable) - have hh_int : Integrable h μˢ := condExpExceptCoord_integrable i (fun z => f z * log (f z)) hf_log_int + have hh_int : Integrable h μˢ := + condExpExceptCoord_integrable i (fun z => f z * log (f z)) hf_log_int -- g is strongly measurable have hg_sm : StronglyMeasurable g := diff --git a/StatsMLlib/Probability/Entropy/Conditional/Decomposition.lean b/StatsMLlib/Probability/Entropy/Conditional/Decomposition.lean index b2a1aaa..b82c7b0 100644 --- a/StatsMLlib/Probability/Entropy/Conditional/Decomposition.lean +++ b/StatsMLlib/Probability/Entropy/Conditional/Decomposition.lean @@ -131,7 +131,8 @@ lemma condExpFirstK_zero (f : (Fin n → Ω) → ℝ) (x : Fin n → Ω) : unfold condExpFirstK -- When k = 0, the condition j.val < 0 is false for all j, so we always pick y j -- Therefore f (fun j => if j.val < 0 then x j else y j) = f y - have h : ∀ y : Fin n → Ω, f (fun j => if j.val < (0 : Fin (n + 1)).val then x j else y j) = f y := by + have h : ∀ y : Fin n → Ω, + f (fun j => if j.val < (0 : Fin (n + 1)).val then x j else y j) = f y := by intro y -- j.val < 0 is false for all j : Fin n, so if-then-else reduces to y j simp only [Fin.val_zero, Nat.not_lt_zero, ↓reduceIte] diff --git a/StatsMLlib/Probability/Entropy/Conditional/Subadditivity.lean b/StatsMLlib/Probability/Entropy/Conditional/Subadditivity.lean index 12baf8f..7196c65 100644 --- a/StatsMLlib/Probability/Entropy/Conditional/Subadditivity.lean +++ b/StatsMLlib/Probability/Entropy/Conditional/Subadditivity.lean @@ -351,7 +351,8 @@ lemma f_mul_log_condExpFirstK_integrable (k : Fin (n + 1)) (f : (Fin n → Ω) have hfφ_int : Integrable (f ∘ φ) (μˢ.prod μˢ) := hφ_mp.integrable_comp_of_integrable hf_int -- The product function (x, y) ↦ f(φ(x,y)) * log(T(x)) is integrable - have hprod_int : Integrable (fun p : (Fin n → Ω) × (Fin n → Ω) => f (φ p) * log (T p.1)) (μˢ.prod μˢ) := by + have hprod_int : Integrable (fun p : (Fin n → Ω) × (Fin n → Ω) => f (φ p) * + log (T p.1)) (μˢ.prod μˢ) := by -- Use Fubini for integrability have hprod_aesm : AEStronglyMeasurable (fun p => f (φ p) * log (T p.1)) (μˢ.prod μˢ) := by @@ -372,7 +373,8 @@ lemma f_mul_log_condExpFirstK_integrable (k : Fin (n + 1)) (f : (Fin n → Ω) rw [norm_mul] rw [h1] have h2 : ∫ y, ‖f (φ (x, y))‖ * ‖log (T x)‖ ∂μˢ = ‖log (T x)‖ * ∫ y, ‖f (φ (x, y))‖ ∂μˢ := by - have heq : ∀ y, ‖f (φ (x, y))‖ * ‖log (T x)‖ = ‖log (T x)‖ * ‖f (φ (x, y))‖ := fun y => mul_comm _ _ + have heq : ∀ y, ‖f (φ (x, y))‖ * ‖log (T x)‖ = ‖log (T x)‖ * ‖f (φ (x, y))‖ := + fun y => mul_comm _ _ simp_rw [heq] exact integral_const_mul _ _ rw [h2] @@ -408,7 +410,8 @@ lemma f_mul_log_condExpFirstK_integrable (k : Fin (n + 1)) (f : (Fin n → Ω) simp_rw [hnorm_eq] rw [ofReal_integral_eq_lintegral_ofReal] · -- Integrability of the norm function - have heq : (fun y => ‖f (φ (x, y)) * log (T x)‖) = (fun y => ‖f (φ (x, y))‖ * ‖log (T x)‖) := by + have heq : (fun y => ‖f (φ (x, y)) * log (T x)‖) = + (fun y => ‖f (φ (x, y))‖ * ‖log (T x)‖) := by ext y; exact norm_mul _ _ rw [heq] exact hint.norm.mul_const _ @@ -491,7 +494,8 @@ theorem condExpFirstK_tower_of_integrable_slice (k : Fin n) (f : (Fin n → Ω) -- Show RHS inner integrand equals G z w have hRHS_eq : ∀ z : Ω, ∀ w : Fin n → Ω, (fun j => if j.val < (k.succ : Fin (n + 1)).val then - (Function.update x k z) j else w j) = (fun j => if j.val < k.val then x j else if j = k then z else w j) := by + (Function.update x k z) j else w j) = + (fun j => if j.val < k.val then x j else if j = k then z else w j) := by intro z w ext j simp only [Fin.val_succ] @@ -507,7 +511,8 @@ theorem condExpFirstK_tower_of_integrable_slice (k : Fin n) (f : (Fin n → Ω) simp only [hj_eq, Nat.lt_succ_self, ↓reduceIte, Nat.lt_irrefl] exact Function.update_self k z x · -- j ≠ k and j.val ≥ k.val, so j.val > k.val, so j.val ≥ k.val + 1 - have hj_gt : j.val > k.val := Nat.lt_of_le_of_ne (Nat.le_of_not_lt hj_lt) (fun h => hj_eq (Fin.ext h.symm)) + have hj_gt : j.val > k.val := + Nat.lt_of_le_of_ne (Nat.le_of_not_lt hj_lt) (fun h => hj_eq (Fin.ext h.symm)) have hj_ge_succ : ¬(j.val < k.val + 1) := Nat.not_lt_of_ge hj_gt simp only [hj_ge_succ, ↓reduceIte, hj_lt, hj_eq] @@ -536,11 +541,13 @@ theorem condExpFirstK_tower_of_integrable_slice (k : Fin n) (f : (Fin n → Ω) · by_cases hj_eq : j = k · subst hj_eq simp only [Nat.lt_succ_self, ↓reduceIte, hj_lt] - · have hj_gt : j.val > k.val := Nat.lt_of_le_of_ne (Nat.le_of_not_lt hj_lt) (fun h => hj_eq (Fin.ext h.symm)) + · have hj_gt : j.val > k.val := + Nat.lt_of_le_of_ne (Nat.le_of_not_lt hj_lt) (fun h => hj_eq (Fin.ext h.symm)) have hj_ge_succ : ¬(j.val < k.val + 1) := Nat.not_lt_of_ge hj_gt simp only [hj_ge_succ, ↓reduceIte, hj_lt, hj_eq] - -- Show: for all w, the integrand in the unfolded RHS equals f(...) with (if j = k then z else x j) + -- Show: for all w, the integrand in the unfolded RHS equals f(...) with + -- (if j = k then z else x j) have hRHS_update_eq : ∀ z : Ω, ∀ w : Fin n → Ω, ∀ j : Fin n, (if j.val < (k.succ : Fin (n + 1)).val then (Function.update x k z) j else w j) = (if j.val < (k.succ : Fin (n + 1)).val then (if j = k then z else x j) else w j) := by @@ -555,7 +562,8 @@ theorem condExpFirstK_tower_of_integrable_slice (k : Fin n) (f : (Fin n → Ω) -- Now use the simplified form have hRHS_simp : ∀ z : Ω, ∀ w : Fin n → Ω, (fun j => if j.val < (k.succ : Fin (n + 1)).val then (Function.update x k z) j else w j) = - (fun j => if j.val < (k.succ : Fin (n + 1)).val then (if j = k then z else x j) else w j) := by + (fun j => if j.val < (k.succ : Fin (n + 1)).val then (if j = k then z else x j) + else w j) := by intro z w; ext j; exact hRHS_update_eq z w j have hRHS_eq_G' : ∀ z : Ω, ∀ w : Fin n → Ω, @@ -683,7 +691,8 @@ theorem condExpFirstK_tower (k : Fin n) (f : (Fin n → Ω) → ℝ) · simp only [hφ_def, ite_eq_right h]; exact measurable_snd.eval -- Key: φ is measure-preserving from μˢ.prod μˢ to μˢ - have hφ_mp : MeasurePreserving φ (μˢ.prod μˢ) μˢ := ⟨hφ_meas, map_select_coords_prod_pi k.castSucc⟩ + have hφ_mp : MeasurePreserving φ (μˢ.prod μˢ) μˢ := + ⟨hφ_meas, map_select_coords_prod_pi k.castSucc⟩ -- f ∘ φ is integrable on μˢ.prod μˢ because f is integrable on μˢ have hcomp_int : Integrable (f ∘ φ) (μˢ.prod μˢ) := @@ -788,7 +797,8 @@ lemma condExpExceptCoord_mul_log_condExpFirstK_integrable (i : Fin n) (f : (Fin calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i @@ -830,15 +840,18 @@ lemma condExpExceptCoord_mul_log_condExpFirstK_integrable (i : Fin n) (f : (Fin _ = ∫⁻ p, ‖f (Function.update p.1 i p.2) * log (T_i p.1)‖₊ ∂(μˢ.prod (μs i)) := by symm exact lintegral_prod _ ((hf_meas.comp (measurable_update' (a := i))).mul - (measurable_log.comp (hT_meas.comp measurable_fst))).nnnorm.coe_nnreal_ennreal.aemeasurable + (measurable_log.comp + (hT_meas.comp measurable_fst))).nnnorm.coe_nnreal_ennreal.aemeasurable -- Use T_i(update x i y) = T_i(x) - _ = ∫⁻ p, ‖f (Function.update p.1 i p.2) * log (T_i (Function.update p.1 i p.2))‖₊ ∂(μˢ.prod (μs i)) := by + _ = ∫⁻ p, ‖f (Function.update p.1 i p.2) * + log (T_i (Function.update p.1 i p.2))‖₊ ∂(μˢ.prod (μs i)) := by apply lintegral_congr intro p rw [hlogT_const p.1 p.2] -- Apply measure-preserving property _ = ∫⁻ z, ‖f z * log (T_i z)‖₊ ∂μˢ := by - have h := hmp.lintegral_comp (hf_meas.mul (measurable_log.comp hT_meas)).nnnorm.coe_nnreal_ennreal + have h := + hmp.lintegral_comp (hf_meas.mul (measurable_log.comp hT_meas)).nnnorm.coe_nnreal_ennreal exact h _ < ⊤ := hflogT_int.2 @@ -867,7 +880,8 @@ lemma condExpFirstK_pos_on_slice_ae (i : Fin n) (f : (Fin n → Ω) → ℝ) calc Measure.map (fun p : (Fin n → Ω) × Ω => Function.update p.1 i p.2) (μˢ.prod (μs i)) _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) (Measure.map Prod.swap (μˢ.prod (μs i))) := (Measure.map_map hg' measurable_swap).symm - _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) ((μs i).prod μˢ) := by + _ = Measure.map (fun q : Ω × (Fin n → Ω) => Function.update q.2 i q.1) + ((μs i).prod μˢ) := by rw [Measure.prod_swap] _ = μˢ := map_update_prod_pi i @@ -996,8 +1010,10 @@ lemma condExpFirstK_pos_on_slice_ae (i : Fin n) (f : (Fin n → Ω) → ℝ) rw [← ae_iff] exact hT_nonneg rw [ae_iff] - have h_eq : {p : (Fin n → Ω) × Ω | ¬0 ≤ condExpFirstK (μs := μs) i.succ f (Function.update p.1 i p.2)} = - (fun p => Function.update p.1 i p.2) ⁻¹' {x | ¬0 ≤ condExpFirstK (μs := μs) i.succ f x} := rfl + have h_eq : + {p : (Fin n → Ω) × Ω | ¬0 ≤ condExpFirstK (μs := μs) i.succ f (Function.update p.1 i p.2)} = + (fun p => Function.update p.1 i p.2) ⁻¹' + {x | ¬0 ≤ condExpFirstK (μs := μs) i.succ f x} := rfl rw [h_eq] have hbad_meas : MeasurableSet {x | ¬0 ≤ condExpFirstK (μs := μs) i.succ f x} := (condExpFirstK_measurable i.succ f hf_meas) measurableSet_Ici.compl @@ -1057,7 +1073,8 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) have h_rw : (fun x => f x * (log (condExpFirstK (μs := μs) i.succ f x) - log (condExpFirstK (μs := μs) i.castSucc f x))) =ᵐ[μˢ] (fun x => f x * (log (condExpFirstK (μs := μs) i.succ f x) - - log (condExpExceptCoord (μs := μs) i (condExpFirstK (μs := μs) i.succ f) x))) := by + log (condExpExceptCoord (μs := μs) i + (condExpFirstK (μs := μs) i.succ f) x))) := by filter_upwards [h_tower] with x hx rw [hx] @@ -1065,7 +1082,8 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) have h_indep : ∀ x y : Fin n → Ω, condExpExceptCoord (μs := μs) i (condExpFirstK (μs := μs) i.succ f) x = - condExpExceptCoord (μs := μs) i (condExpFirstK (μs := μs) i.succ f) (Function.update x i (y i)) := by + condExpExceptCoord (μs := μs) i (condExpFirstK (μs := μs) i.succ f) + (Function.update x i (y i)) := by intro x y rw [condExpExceptCoord_update] @@ -1088,7 +1106,8 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) have h_nonneg_ae : ∀ᵐ x ∂μˢ, 0 ≤ condEntExceptCoord (μs := μs) i f x := by filter_upwards [hnn_ae, hint_ae, hlogint_ae] with x hnn hint hlogint exact condEntExceptCoord_nonneg_at i f x hnn hint hlogint - have h_log_const_factor : ∀ x, ∫ y, f (Function.update x i y) * log (condExpExceptCoord (μs := μs) i T x) ∂(μs i) = + have h_log_const_factor : ∀ x, ∫ y, f (Function.update x i y) * + log (condExpExceptCoord (μs := μs) i T x) ∂(μs i) = log (condExpExceptCoord (μs := μs) i T x) * condExpExceptCoord (μs := μs) i f x := by intro x have h_comm : ∀ y, f (Function.update x i y) * log (condExpExceptCoord (μs := μs) i T x) = @@ -1108,7 +1127,9 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) have h_slice_bound : ∀ᵐ x ∂μˢ, EflogT x - Ef x * log (ET x) ≤ Eflogf x - Ef x * log (Ef x) := by - filter_upwards [hnn_ae, hint_ae, hlogint_ae, hT_slice_nn_ae, hT_slice_int_ae, hflogT_slice_int_ae, condExpFirstK_pos_on_slice_ae i f hf_meas hf_nn hf_int] with x hnn hint hlogint hT'_nn_ae hT'_int hYlogT'_int_x hT'_pos_on_Y_raw + filter_upwards [hnn_ae, hint_ae, hlogint_ae, hT_slice_nn_ae, hT_slice_int_ae, + hflogT_slice_int_ae, condExpFirstK_pos_on_slice_ae i f hf_meas hf_nn hf_int] + with x hnn hint hlogint hT'_nn_ae hT'_int hYlogT'_int_x hT'_pos_on_Y_raw set Y := fun y => f (Function.update x i y) with hY_def set T' := fun y => T (Function.update x i y) with hT'_def have hEf_eq : Ef x = ∫ y, Y y ∂(μs i) := rfl @@ -1195,7 +1216,8 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) have hLHS_eq : ∫ x, f x * (log (T x) - log (condExpExceptCoord (μs := μs) i T x)) ∂μˢ = ∫ x, (EflogT x - Ef x * log (ET x)) ∂μˢ := by have h1 : ∫ x, f x * (log (T x) - log (condExpExceptCoord (μs := μs) i T x)) ∂μˢ = - ∫ x, f x * log (T x) ∂μˢ - ∫ x, f x * log (condExpExceptCoord (μs := μs) i T x) ∂μˢ := by + ∫ x, f x * log (T x) ∂μˢ - ∫ x, f x * + log (condExpExceptCoord (μs := μs) i T x) ∂μˢ := by have h_eq : ∀ x, f x * (log (T x) - log (condExpExceptCoord (μs := μs) i T x)) = f x * log (T x) - f x * log (condExpExceptCoord (μs := μs) i T x) := by intro x; ring @@ -1222,10 +1244,12 @@ theorem term_le_expected_condEnt (i : Fin n) (f : (Fin n → Ω) → ℝ) exact this.symm have h_integrand_eq : ∀ y, log (condExpExceptCoord (μs := μs) i T (Function.update x i y)) * f (Function.update x i y) = - log (condExpExceptCoord (μs := μs) i T x) * f (Function.update x i y) := by + log (condExpExceptCoord (μs := μs) i T x) * + f (Function.update x i y) := by intro y rw [h_ET_const y] - calc ∫ y, log (condExpExceptCoord i T (Function.update x i y)) * f (Function.update x i y) ∂μs i + calc ∫ y, log (condExpExceptCoord i T (Function.update x i y)) * + f (Function.update x i y) ∂μs i = ∫ y, log (condExpExceptCoord i T x) * f (Function.update x i y) ∂μs i := by apply integral_congr_ae; filter_upwards with y; exact h_integrand_eq y _ = log (condExpExceptCoord i T x) * ∫ y, f (Function.update x i y) ∂μs i := @@ -1324,7 +1348,8 @@ theorem entropy_subadditive (f : (Fin n → Ω) → ℝ) have h_eq : (fun x => f x * (log (condExpFirstK (μs := μs) i.succ f x) - log (condExpFirstK (μs := μs) i.castSucc f x))) =ᵐ[μˢ] (fun x => f x * (log (condExpFirstK (μs := μs) i.succ f x) - - log (condExpExceptCoord (μs := μs) i (condExpFirstK (μs := μs) i.succ f) x))) := by + log (condExpExceptCoord (μs := μs) i + (condExpFirstK (μs := μs) i.succ f) x))) := by filter_upwards [h_tower] with x hx rw [hx] apply Integrable.congr _ h_eq.symm @@ -1336,7 +1361,8 @@ theorem entropy_subadditive (f : (Fin n → Ω) → ℝ) simp_rw [h_decomp] exact Integrable.sub (f_mul_log_condExpFirstK_integrable i.succ f hf_meas hf_nn hf_int hf_log_int) - (f_mul_log_condExpExceptCoord_condExpFirstK_integrable i f hf_meas hf_nn hf_int hf_log_int) + (f_mul_log_condExpExceptCoord_condExpFirstK_integrable i f hf_meas hf_nn + hf_int hf_log_int) rw [integral_finsetSum Finset.univ (fun i _ => h_term_int i)] have h_ent_eq : LogSobolev.entropy μˢ f = diff --git a/StatsMLlib/Probability/Entropy/Duality.lean b/StatsMLlib/Probability/Entropy/Duality.lean index 3d4e92e..ea735ca 100644 --- a/StatsMLlib/Probability/Entropy/Duality.lean +++ b/StatsMLlib/Probability/Entropy/Duality.lean @@ -381,7 +381,8 @@ lemma optimalU_in_dualEntropySet [IsProbabilityMeasure μ] · rfl · simp only [zero_mul] -- Show optimalU_mul_Y_toReal is integrable - have h_eq2 : (fun ω => Y ω * log (Y ω) - log mean * Y ω) =ᵐ[μ] optimalU_mul_Y_toReal Y mean := by + have h_eq2 : (fun ω => Y ω * log (Y ω) - log mean * Y ω) =ᵐ[μ] + optimalU_mul_Y_toReal Y mean := by filter_upwards [hY_nn] with ω hY_nn_ω simp only [optimalU_mul_Y_toReal] split_ifs with hY_pos @@ -418,7 +419,8 @@ lemma zero_in_dualEntropySet_of_mean_zero [IsProbabilityMeasure μ] (Y : Ω → ℝ) : (0 : ℝ) ∈ dualEntropySet μ Y := by -- Use U = 0 (constant function) - refine ⟨fun _ => (0 : ℝ), measurable_const.coe_real_ereal, ?_, fun _ => 0, measurable_const, ?_, ?_, ?_⟩ + refine ⟨fun _ => (0 : ℝ), measurable_const.coe_real_ereal, ?_, fun _ => 0, + measurable_const, ?_, ?_, ?_⟩ · -- E[e^0] = E[1] = 1 simp only [expIntegralEReal, lintegral_const, MeasureTheory.measure_univ] simp only [EReal.coe_zero, EReal.exp_zero, one_mul] @@ -684,7 +686,8 @@ theorem entropy_duality [IsProbabilityMeasure μ] · -- sSup ≤ entropy: all elements ≤ entropy apply csSup_le · -- Set is nonempty (entropy is in it) - exact ⟨entropy μ Y, optimalU_in_dualEntropySet Y hY_meas hY_nn hY_int hY_mean_pos hY_log_int⟩ + exact ⟨entropy μ Y, + optimalU_in_dualEntropySet Y hY_meas hY_nn hY_int hY_mean_pos hY_log_int⟩ · -- All elements ≤ entropy intro x hx exact dualEntropySet_le_entropy Y hY_meas hY_nn hY_int hY_log_int x hx diff --git a/StatsMLlib/Probability/Entropy/Variational.lean b/StatsMLlib/Probability/Entropy/Variational.lean index 9295a80..8edec87 100644 --- a/StatsMLlib/Probability/Entropy/Variational.lean +++ b/StatsMLlib/Probability/Entropy/Variational.lean @@ -251,7 +251,8 @@ lemma entropy_mem_dualEntropySetT [IsProbabilityMeasure μ] ∫ ω, Y ω * Real.log (Y ω) ∂μ - (∫ ω, Y ω ∂μ) * Real.log (∫ ω', Y ω' ∂μ) := by rw [integral_congr_ae h_eq] rw [integral_sub hY_log_int h_const_int] - have h_const : ∫ ω, Real.log (∫ ω', Y ω' ∂μ) * Y ω ∂μ = Real.log (∫ ω', Y ω' ∂μ) * ∫ ω, Y ω ∂μ := by + have h_const : ∫ ω, Real.log (∫ ω', Y ω' ∂μ) * Y ω ∂μ = + Real.log (∫ ω', Y ω' ∂μ) * ∫ ω, Y ω ∂μ := by rw [← integral_const_mul] rw [h_const] ring @@ -365,7 +366,8 @@ theorem entropy_duality_T [IsProbabilityMeasure μ] integrable_const 1, ?_, ?_⟩ · simp only [integral_const, probReal_univ, smul_eq_mul, mul_one, zero_lt_one] · have h1_int : ∫ ω, (1 : ℝ) ∂μ = 1 := by simp [integral_const, probReal_univ] - have h1_pos_on_Y : ∀ᵐ ω ∂μ, 0 < Y ω → 0 < (1 : ℝ) := Eventually.of_forall (fun _ _ => one_pos) + have h1_pos_on_Y : ∀ᵐ ω ∂μ, 0 < Y ω → 0 < (1 : ℝ) := + Eventually.of_forall (fun _ _ => one_pos) rw [integralYLogT_of_pos_on_Y Y (fun _ => 1) h1_pos_on_Y] simp only [Real.log_one, h1_int, sub_self, mul_zero, integral_const, smul_zero] rfl @@ -377,7 +379,8 @@ theorem entropy_duality_T [IsProbabilityMeasure μ] integrable_const 1, ?_, ?_⟩ · simp only [integral_const, probReal_univ, smul_eq_mul, mul_one, zero_lt_one] · have h1_int : ∫ ω, (1 : ℝ) ∂μ = 1 := by simp [integral_const, probReal_univ] - have h1_pos_on_Y : ∀ᵐ ω ∂μ, 0 < Y ω → 0 < (1 : ℝ) := Eventually.of_forall (fun _ _ => one_pos) + have h1_pos_on_Y : ∀ᵐ ω ∂μ, 0 < Y ω → 0 < (1 : ℝ) := + Eventually.of_forall (fun _ _ => one_pos) rw [integralYLogT_of_pos_on_Y Y (fun _ => 1) h1_pos_on_Y] simp only [Real.log_one, h1_int, sub_self, mul_zero, integral_const, smul_zero] rfl @@ -463,7 +466,8 @@ theorem entropy_ge_integral_log_real [IsProbabilityMeasure μ] (∫ ω, Y ω * (Real.log (T ω) - Real.log (∫ ω', T ω' ∂μ)) ∂μ) ≤ entropy μ Y := by -- When T > 0 on {Y > 0}, integralYLogT equals the Bochner integral have h_eq := integralYLogT_of_pos_on_Y Y T hT_pos_on_Y - have h_le := entropy_ge_integral_log Y hY_meas hY_nn hY_int hY_log_int T hT_meas hT_nn hT_int hT_mean_pos + have h_le := + entropy_ge_integral_log Y hY_meas hY_nn hY_int hY_log_int T hT_meas hT_nn hT_int hT_mean_pos rw [h_eq] at h_le exact EReal.coe_le_coe_iff.mp h_le diff --git a/StatsMLlib/Probability/Gaussian/Basic.lean b/StatsMLlib/Probability/Gaussian/Basic.lean index f386d7d..d2d6c36 100644 --- a/StatsMLlib/Probability/Gaussian/Basic.lean +++ b/StatsMLlib/Probability/Gaussian/Basic.lean @@ -64,9 +64,11 @@ instance stdGaussianE_isProbabilityMeasure : IsProbabilityMeasure (stdGaussianE unfold stdGaussianE infer_instance -/-- Transfer of integrals: integrating f over stdGaussianE equals integrating f ∘ e.symm over stdGaussianPi. -/ +/-- Transfer of integrals: integrating f over stdGaussianE equals integrating f ∘ e.symm over +stdGaussianPi. -/ lemma integral_stdGaussianE_eq (f : EuclideanSpace ℝ (Fin n) → ℝ) : - ∫ x, f x ∂(stdGaussianE n) = ∫ w, f ((EuclideanSpace.equiv (Fin n) ℝ).symm w) ∂(stdGaussianPi n) := by + ∫ x, f x ∂(stdGaussianE n) = + ∫ w, f ((EuclideanSpace.equiv (Fin n) ℝ).symm w) ∂(stdGaussianPi n) := by unfold stdGaussianE exact integral_map_equiv (EuclideanSpace.equiv (Fin n) ℝ).symm.toHomeomorph.toMeasurableEquiv f @@ -303,7 +305,8 @@ lemma integrable_id_gaussianReal {v : NNReal} (hv : v ≠ 0) : have hconst : (0 : ℝ) < (Real.sqrt (2 * π * v))⁻¹ := by simp only [inv_pos, Real.sqrt_pos] exact mul_pos (mul_pos two_pos Real.pi_pos) hv_pos - have hpdf_eq : ∀ x, (gaussianPDF 0 v x).toReal = (Real.sqrt (2 * π * v))⁻¹ * exp (-(2 * (v : ℝ))⁻¹ * x ^ 2) := by + have hpdf_eq : ∀ x, (gaussianPDF 0 v x).toReal = (Real.sqrt (2 * π * v))⁻¹ * + exp (-(2 * (v : ℝ))⁻¹ * x ^ 2) := by intro x simp only [gaussianPDF, gaussianPDFReal, sub_zero] rw [ENNReal.toReal_ofReal] diff --git a/StatsMLlib/Probability/Gaussian/Lipschitz.lean b/StatsMLlib/Probability/Gaussian/Lipschitz.lean index 60e42cb..f49db95 100644 --- a/StatsMLlib/Probability/Gaussian/Lipschitz.lean +++ b/StatsMLlib/Probability/Gaussian/Lipschitz.lean @@ -56,11 +56,13 @@ lemma integrable_exp_mul_abs_eval_stdGaussianPi (t : ℝ) (i : Fin n) : have h_eq : exp (t * -w i) = exp (-t * w i) := by ring_nf rw [h_eq] exact le_add_of_nonneg_left (le_of_lt (exp_pos _)) - have h_sum_int : Integrable (fun w => exp (t * w i) + exp (-t * w i)) (GaussianMeasure.stdGaussianPi n) := + have h_sum_int : + Integrable (fun w => exp (t * w i) + exp (-t * w i)) (GaussianMeasure.stdGaussianPi n) := (GaussianMeasure.integrable_exp_mul_eval_stdGaussianPi i t).add (GaussianMeasure.integrable_exp_mul_eval_stdGaussianPi i (-t)) apply Integrable.mono h_sum_int - · exact (continuous_exp.comp (continuous_const.mul (continuous_abs.comp (continuous_apply i)))).aestronglyMeasurable + · exact (continuous_exp.comp + (continuous_const.mul (continuous_abs.comp (continuous_apply i)))).aestronglyMeasurable · filter_upwards with w simp only [Real.norm_eq_abs, abs_exp] have h_sum_pos : 0 ≤ exp (t * w i) + exp (-t * w i) := @@ -72,7 +74,8 @@ lemma integrable_exp_mul_abs_eval_stdGaussianPi (t : ℝ) (i : Fin n) : lemma norm_integrable_stdGaussianPi : Integrable (fun w : Fin n → ℝ => ‖w‖) (GaussianMeasure.stdGaussianPi n) := by -- Use ‖w‖ ≤ Σᵢ |wᵢ| for pi-norm (sup norm) - apply Integrable.mono (integrable_finsetSum Finset.univ (fun i _ => integrable_abs_eval_stdGaussianPi i)) + apply Integrable.mono (integrable_finsetSum Finset.univ (fun i _ => + integrable_abs_eval_stdGaussianPi i)) · exact continuous_norm.aestronglyMeasurable · filter_upwards with w simp only [Real.norm_eq_abs] diff --git a/StatsMLlib/Probability/Gaussian/LipschitzConcentration.lean b/StatsMLlib/Probability/Gaussian/LipschitzConcentration.lean index a537e1c..a43d266 100644 --- a/StatsMLlib/Probability/Gaussian/LipschitzConcentration.lean +++ b/StatsMLlib/Probability/Gaussian/LipschitzConcentration.lean @@ -17,7 +17,8 @@ The C¹ case uses Herbst argument with LSI. General Lipschitz follows by mollification approximation: f_ε → f with preserved Lipschitz constant. -/ -open MeasureTheory ProbabilityTheory Real Finset BigOperators Function GaussianMeasure GaussianSobolev +open MeasureTheory ProbabilityTheory Real Finset BigOperators Function GaussianMeasure + GaussianSobolev open scoped ENNReal namespace GaussianLipConcen @@ -59,12 +60,14 @@ lemma lipschitz_gradNormSq_bound {f : (Fin n → ℝ) → ℝ} {L : ℝ} (hL : 0 simp only [mul_one] at h exact h -- The partial derivatives of f equal those of f' at corresponding points - have h_partial_eq : ∀ i, GaussianLSI.partialDeriv i f x = fderiv ℝ f' (e.symm x) (EuclideanSpace.single i 1) := by + have h_partial_eq : ∀ i, GaussianLSI.partialDeriv i f x = + fderiv ℝ f' (e.symm x) (EuclideanSpace.single i 1) := by intro i simp only [GaussianLSI.partialDeriv, f'] -- The derivative of f ∘ e at e.symm x applied to EuclideanSpace.single i 1 -- equals the derivative of f at x applied to Pi.single i 1 - have h_chain := fderiv_comp (e.symm x) (hf_C1.differentiable (by norm_num) (e (e.symm x))) e.differentiable.differentiableAt + have h_chain := fderiv_comp (e.symm x) (hf_C1.differentiable (by norm_num) (e (e.symm x))) + e.differentiable.differentiableAt rw [h_chain] simp only [ContinuousLinearMap.comp_apply] congr 1 @@ -303,7 +306,8 @@ lemma ratio_bound_gronwall (φ : ℝ → ℝ) (t : ℝ) (ht : 0 < t) have h_mono : ∀ s, s ∈ Set.Ioo 0 t → φ s / s ≥ φ t / t := fun s hs => by have h_ratio_cont : ContinuousAt (fun x => φ x / x) t := ContinuousAt.div (hφ_diff t).continuousAt continuousAt_id (ne_of_gt ht) - have h_tendsto : Filter.Tendsto (fun y => φ y / y) (nhdsWithin t (Set.Iio t)) (nhds (φ t / t)) := + have h_tendsto : + Filter.Tendsto (fun y => φ y / y) (nhdsWithin t (Set.Iio t)) (nhds (φ t / t)) := h_ratio_cont.tendsto.mono_left nhdsWithin_le_nhds have : (nhdsWithin t (Set.Iio t)).NeBot := inferInstance apply le_of_tendsto h_tendsto @@ -345,7 +349,8 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} have h_gsq_eq : ∀ x, (g x)^2 = exp (s * f_c x) := by intro x; unfold g; rw [sq, ← exp_add]; congr 1; ring -- Gradient of g: |∇g|² = (s/2)² |∇f|² g² - have h_grad_g : ∀ x, GaussianLSI.gradNormSq n g x = (s/2)^2 * GaussianLSI.gradNormSq n f x * (g x)^2 := by + have h_grad_g : ∀ x, GaussianLSI.gradNormSq n g x = (s/2)^2 * + GaussianLSI.gradNormSq n f x * (g x)^2 := by intro x unfold GaussianLSI.gradNormSq GaussianLSI.partialDeriv g have h_deriv : ∀ i, fderiv ℝ (fun x => exp (s / 2 * f_c x)) x (Pi.single i 1) = @@ -399,8 +404,10 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} intro i _ apply Measurable.pow _ measurable_const unfold GaussianLSI.partialDeriv g - have hg_C1 : ContDiff ℝ 1 g := ContDiff.exp (ContDiff.mul contDiff_const (hf_C1.sub contDiff_const)) - have hg_cont : Continuous (fderiv ℝ g) := (hg_C1.fderiv_right (m := 0) le_rfl).continuous + have hg_C1 : ContDiff ℝ 1 g := + ContDiff.exp (ContDiff.mul contDiff_const (hf_C1.sub contDiff_const)) + have hg_cont : Continuous (fderiv ℝ g) := + (hg_C1.fderiv_right (m := 0) le_rfl).continuous have h_eval_cont : Continuous (fun L : (Fin n → ℝ) →L[ℝ] ℝ => L (Pi.single i 1)) := ContinuousLinearMap.apply ℝ ℝ (Pi.single i 1) |>.continuous exact (h_eval_cont.comp hg_cont).measurable @@ -414,7 +421,8 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} · intro x; exact h_grad_g_bound x _ = (s/2)^2 * σ^2 * ∫ x, (g x)^2 ∂μ := by rw [integral_const_mul] -- Prepare LSI hypotheses for g - have hg_C1 : ContDiff ℝ 1 g := ContDiff.exp (ContDiff.mul contDiff_const (hf_C1.sub contDiff_const)) + have hg_C1 : ContDiff ℝ 1 g := + ContDiff.exp (ContDiff.mul contDiff_const (hf_C1.sub contDiff_const)) have hg_diff : Differentiable ℝ g := hg_C1.differentiable (by norm_num) have hg_grad_cont : ∀ i, Continuous (fun x => GaussianLSI.partialDeriv i g x) := by intro i @@ -424,7 +432,9 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} have h_gsq_int : Integrable (fun x => (g x)^2) μ := by have h_exp_int := lipschitz_exp_integrable (le_of_lt hL_lip) hf_lip s convert h_exp_int using 1; ext x; exact h_gsq_eq x - have hg_memLp : MemLp g 2 μ := (MeasureTheory.memLp_two_iff_integrable_sq hg_diff.continuous.aestronglyMeasurable).mpr h_gsq_int + have hg_memLp : MemLp g 2 μ := + (MeasureTheory.memLp_two_iff_integrable_sq hg_diff.continuous.aestronglyMeasurable).mpr + h_gsq_int have hg_partial_memLp : ∀ i, MemLp (fun x => GaussianLSI.partialDeriv i g x) 2 μ := by intro i have h_bound : ∀ x, (GaussianLSI.partialDeriv i g x)^2 ≤ (s/2)^2 * σ^2 * (g x)^2 := fun x => by @@ -442,14 +452,16 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} simp only [Real.norm_eq_abs] rw [abs_of_nonneg (sq_nonneg _)] exact h_bound x - exact (MeasureTheory.memLp_two_iff_integrable_sq (hg_grad_cont i).aestronglyMeasurable).mpr h_partial_int + exact (MeasureTheory.memLp_two_iff_integrable_sq + (hg_grad_cont i).aestronglyMeasurable).mpr h_partial_int have hg_W12 : GaussianLSI.MemW12GaussianPi n g μ := ⟨hg_memLp, hg_partial_memLp⟩ -- Log-integrability: g² * log(g²) = exp(s * f_c) * (s * f_c) have hg_log_int : Integrable (fun x => (g x)^2 * log ((g x)^2)) μ := by have h_eq : ∀ x, (g x)^2 * log ((g x)^2) = exp (s * f_c x) * (s * f_c x) := by intro x; rw [h_gsq_eq x]; congr 1; rw [log_exp] simp_rw [h_eq] - have h_eq' : (fun x => exp (s * f_c x) * (s * f_c x)) = fun x => s * (f_c x * exp (s * f_c x)) := by + have h_eq' : + (fun x => exp (s * f_c x) * (s * f_c x)) = fun x => s * (f_c x * exp (s * f_c x)) := by ext x; ring rw [h_eq'] apply Integrable.const_mul @@ -466,18 +478,21 @@ lemma entropy_bound_exp_scaled {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} calc f_c x * exp (s * f_c x) ≤ exp (f_c x) * exp (s * f_c x) := by apply mul_le_mul_of_nonneg_right h' (exp_pos _).le _ = exp ((1 + s) * f_c x) := by rw [← exp_add]; ring_nf - _ ≤ exp ((1 + s) * f_c x) + exp ((s - 1) * f_c x) := by linarith [exp_pos ((s - 1) * f_c x)] + _ ≤ exp ((1 + s) * f_c x) + exp ((s - 1) * f_c x) := + by linarith [exp_pos ((s - 1) * f_c x)] · push Not at hfc; rw [abs_of_neg hfc] have h' : -f_c x ≤ exp (-f_c x) := by rw [abs_of_neg hfc] at h; exact h calc (-f_c x) * exp (s * f_c x) ≤ exp (-f_c x) * exp (s * f_c x) := by apply mul_le_mul_of_nonneg_right h' (exp_pos _).le _ = exp ((s - 1) * f_c x) := by rw [← exp_add]; ring_nf - _ ≤ exp ((1 + s) * f_c x) + exp ((s - 1) * f_c x) := by linarith [exp_pos ((1 + s) * f_c x)] + _ ≤ exp ((1 + s) * f_c x) + exp ((s - 1) * f_c x) := + by linarith [exp_pos ((1 + s) * f_c x)] have h_dom_int : Integrable (fun x => exp ((1 + s) * f_c x) + exp ((s - 1) * f_c x)) μ := (lipschitz_exp_integrable (le_of_lt hL_lip) hf_lip (1 + s)).add (lipschitz_exp_integrable (le_of_lt hL_lip) hf_lip (s - 1)) apply Integrable.mono' h_dom_int - · exact hfc_cont.aestronglyMeasurable.mul (continuous_exp.comp (continuous_const.mul hfc_cont)).aestronglyMeasurable + · exact hfc_cont.aestronglyMeasurable.mul + (continuous_exp.comp (continuous_const.mul hfc_cont)).aestronglyMeasurable · filter_upwards with x; rw [Real.norm_eq_abs]; exact h_fc_bound x -- Apply LSI and chain inequalities have h_lsi := GaussianLSI.gaussian_logSobolev_W12_pi hg_W12 hg_diff hg_grad_cont hg_log_int @@ -501,7 +516,8 @@ theorem cgf_bound {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} let μ := stdGaussianPi n let f_c := fun x => f x - ∫ y, f y ∂μ let g := fun x => exp (t / 2 * f_c x) - have h_grad_g : ∀ x, GaussianLSI.gradNormSq n g x = (t/2)^2 * GaussianLSI.gradNormSq n f x * (g x)^2 := by + have h_grad_g : ∀ x, GaussianLSI.gradNormSq n g x = (t/2)^2 * + GaussianLSI.gradNormSq n f x * (g x)^2 := by intro x unfold GaussianLSI.gradNormSq GaussianLSI.partialDeriv g have h_deriv : ∀ i, fderiv ℝ (fun x => exp (t / 2 * f_c x)) x (Pi.single i 1) = @@ -586,13 +602,15 @@ theorem cgf_bound {f : (Fin n → ℝ) → ℝ} {σ L_lip : ℝ} apply integral_exp_pos exact lipschitz_exp_integrable (le_of_lt hL_lip) hf_lip s field_simp - have h_log_eq : ∀ x, exp (s * f_c x) * log (exp (s * f_c x)) = exp (s * f_c x) * (s * f_c x) := by + have h_log_eq : ∀ x, exp (s * f_c x) * log (exp (s * f_c x)) = + exp (s * f_c x) * (s * f_c x) := by intro x; rw [log_exp] simp_rw [h_log_eq] rw [← h_mgf_s] congr 1 have h_eq : ∫ x, exp (s * f_c x) * (s * f_c x) ∂μ = s * ∫ x, f_c x * exp (s * f_c x) ∂μ := by - conv_lhs => arg 2; ext x; rw [show exp (s * f_c x) * (s * f_c x) = s * (f_c x * exp (s * f_c x)) by ring] + conv_lhs => arg 2; ext x; rw [show exp (s * f_c x) * (s * f_c x) = s * + (f_c x * exp (s * f_c x)) by ring] exact MeasureTheory.integral_const_mul s _ exact h_eq have h_diff_ineq : ∀ s, s * deriv (cgf f_c μ) s - cgf f_c μ s ≤ s^2 * σ^2 / 2 := by @@ -774,11 +792,13 @@ lemma lipschitzE_integrable {f : EuclideanSpace ℝ (Fin n) → ℝ} {L : ℝ} ( rw [h_eq, integrable_map_equiv e] let f' := f ∘ (EuclideanSpace.equiv (Fin n) ℝ).symm have hf'_lip : LipschitzWith (Real.toNNReal (Real.sqrt n * L)) f' := by - have he_lip : LipschitzWith (Real.toNNReal (Real.sqrt n)) (EuclideanSpace.equiv (Fin n) ℝ).symm := by + have he_lip : LipschitzWith (Real.toNNReal (Real.sqrt n)) + (EuclideanSpace.equiv (Fin n) ℝ).symm := by rw [lipschitzWith_iff_dist_le_mul] intro w₁ w₂ rw [Real.coe_toNNReal _ (Real.sqrt_nonneg n)] - have h_norm : ∀ v : Fin n → ℝ, ‖(EuclideanSpace.equiv (Fin n) ℝ).symm v‖ ≤ Real.sqrt n * ‖v‖ := by + have h_norm : ∀ v : Fin n → ℝ, ‖(EuclideanSpace.equiv (Fin n) ℝ).symm v‖ ≤ + Real.sqrt n * ‖v‖ := by intro v rw [EuclideanSpace.norm_eq] have h_sum : ∑ i, ‖v i‖^2 ≤ n * ‖v‖^2 := by @@ -792,8 +812,10 @@ lemma lipschitzE_integrable {f : EuclideanSpace ℝ (Fin n) → ℝ} {L : ℝ} ( _ = Real.sqrt n * Real.sqrt (‖v‖^2) := Real.sqrt_mul (Nat.cast_nonneg n) _ _ = Real.sqrt n * |‖v‖| := by rw [Real.sqrt_sq_eq_abs] _ = Real.sqrt n * ‖v‖ := by rw [abs_of_nonneg (norm_nonneg _)] - calc dist ((EuclideanSpace.equiv (Fin n) ℝ).symm w₁) ((EuclideanSpace.equiv (Fin n) ℝ).symm w₂) - = ‖(EuclideanSpace.equiv (Fin n) ℝ).symm w₁ - (EuclideanSpace.equiv (Fin n) ℝ).symm w₂‖ := dist_eq_norm _ _ + calc dist ((EuclideanSpace.equiv (Fin n) ℝ).symm w₁) + ((EuclideanSpace.equiv (Fin n) ℝ).symm w₂) + = ‖(EuclideanSpace.equiv (Fin n) ℝ).symm w₁ - (EuclideanSpace.equiv (Fin n) ℝ).symm w₂‖ := + dist_eq_norm _ _ _ = ‖(EuclideanSpace.equiv (Fin n) ℝ).symm (w₁ - w₂)‖ := by simp [map_sub] _ ≤ Real.sqrt n * ‖w₁ - w₂‖ := h_norm _ _ = Real.sqrt n * dist w₁ w₂ := by rw [dist_eq_norm] @@ -841,7 +863,8 @@ lemma lipschitz_gradNormSq_bound_E {f : EuclideanSpace ℝ (Fin n) → ℝ} {L : exact hf_diff have h_fderiv_esymm : fderiv ℝ (↑e.symm) (e x) = (e.symm : (Fin n → ℝ) →L[ℝ] _) := ContinuousLinearEquiv.fderiv e.symm - have h_fderiv_comp : fderiv ℝ (f ∘ e.symm) (e x) = (fderiv ℝ f x).comp (e.symm : (Fin n → ℝ) →L[ℝ] _) := by + have h_fderiv_comp : fderiv ℝ (f ∘ e.symm) (e x) = + (fderiv ℝ f x).comp (e.symm : (Fin n → ℝ) →L[ℝ] _) := by have := fderiv_comp (e x) hf_diff' he_diff rw [this, h_fderiv_esymm] congr 1 @@ -868,9 +891,11 @@ local notation "𝔼" => EuclideanSpace ℝ (Fin n) /-- Pointwise convergence of exponentials: exp(t * f_ε(x)) → exp(t * f(x)). -/ lemma exp_mollify_tendsto_of_lipschitz {f : 𝔼 → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) (t : ℝ) (x : 𝔼) : - Tendsto (fun ε => exp (t * mollify ε f x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds (exp (t * f x))) := by + Tendsto (fun ε => + exp (t * mollify ε f x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds (exp (t * f x))) := by have h_moll := mollify_tendsto_of_lipschitz hf x - exact (continuous_exp.tendsto _).comp ((continuous_const.mul continuous_id).tendsto (f x) |>.comp h_moll) + exact (continuous_exp.tendsto _).comp + ((continuous_const.mul continuous_id).tendsto (f x) |>.comp h_moll) /-- Mollified Lipschitz functions are Lipschitz with the same constant. -/ lemma mollify_lipschitzWith' {f : 𝔼 → ℝ} {L : ℝ≥0} {ε : ℝ} (hε : 0 < ε) @@ -1071,7 +1096,8 @@ lemma centered_mgf_mollify_tendsto_of_lipschitz {f : 𝔼 → ℝ} {L : ℝ≥0} intro g simp_rw [h_factor] exact MeasureTheory.integral_const_mul _ _ - have h_goal : Tendsto (fun ε => exp (-t * ∫ y, mollify ε f y ∂μ) * (∫ x, exp (t * mollify ε f x) ∂μ)) + have h_goal : Tendsto (fun ε => exp (-t * ∫ y, mollify ε f y ∂μ) * + (∫ x, exp (t * mollify ε f x) ∂μ)) (nhdsWithin 0 (Set.Ioi 0)) (nhds (exp (-t * ∫ y, f y ∂μ) * (∫ x, exp (t * f x) ∂μ))) := by apply Tendsto.mul @@ -1186,7 +1212,8 @@ lemma lipschitz_cgf_bound_C1 {f : 𝔼 → ℝ} {L : ℝ} have h_gradbound : ∀ w, GaussianLSI.gradNormSq n f' w ≤ L^2 := fun w => lipschitz_gradNormSq_bound_E (le_of_lt hL) hf_lip hf_C1 (e.symm w) have h_cgf' : cgf (fun w => f' w - ∫ z, f' z ∂μ') μ' t ≤ t^2 * L^2 / 2 := - cgf_bound hL hf'_lip (mul_pos (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hn)) hL) hf'_C1 h_gradbound hf'_int t + cgf_bound hL hf'_lip (mul_pos (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hn)) hL) hf'_C1 + h_gradbound hf'_int t simp only [cgf, mgf] have h_eq : ∫ x, exp (t * (f x - ∫ y, f y ∂μ)) ∂μ = ∫ w, exp (t * (f' w - ∫ z, f' z ∂μ')) ∂μ' := by diff --git a/StatsMLlib/Probability/Gaussian/Poincare/EfronStein.lean b/StatsMLlib/Probability/Gaussian/Poincare/EfronStein.lean index 20ead97..bad8ca9 100644 --- a/StatsMLlib/Probability/Gaussian/Poincare/EfronStein.lean +++ b/StatsMLlib/Probability/Gaussian/Poincare/EfronStein.lean @@ -303,7 +303,8 @@ lemma sq_diff_flipped_eq_sq_ZPlus_ZMinus (f : ℝ → ℝ) (ε : ℕ → Ω → rw [this] ring -/-- **Key Lemma**: The squared conditional deviation equals 1/4 times the squared flipped difference. +/-- **Key Lemma**: The squared conditional deviation equals 1/4 times the squared flipped +difference. (Z - E^{(i)}[Z])² = (1/4)(Z - Z^{(i)})² -/ theorem sq_condExp_deviation_eq_quarter_sq_flip (f : ℝ → ℝ) (ε : ℕ → Ω → ℝ) (i : Fin n) (ω : Ω) (hε : ε i ω = 1 ∨ ε i ω = -1) : @@ -418,7 +419,8 @@ For `f ∈ C_c²(ℝ)` and the normalized Rademacher sum `S_n`: -/ theorem variance_rademacherSum_efronStein (f : ℝ → ℝ) (hf : CompactlySupportedSmooth f) : variance (fun x : RademacherSpace n => f (rademacherSumProd n x)) (rademacherProductMeasure n) ≤ - (n : ℝ) / 4 * ∫ x, (f (aPlusProd n 0 x) - f (aMinusProd n 0 x))^2 ∂(rademacherProductMeasure n) := by + (n : ℝ) / 4 * + ∫ x, (f (aPlusProd n 0 x) - f (aMinusProd n 0 x))^2 ∂(rademacherProductMeasure n) := by -- For n = 0, we have a contradiction with NeZero n by_cases hn0 : n = 0 · exact absurd hn0 (NeZero.ne n) @@ -517,10 +519,12 @@ theorem variance_rademacherSum_efronStein (f : ℝ → ℝ) (hf : CompactlySuppo · apply AEStronglyMeasurable.sub · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).add - ((measurable_const.sub (measurable_pi_apply i)).div measurable_const)).aemeasurable + ((measurable_const.sub (measurable_pi_apply i)).div + measurable_const)).aemeasurable · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).sub - ((measurable_const.add (measurable_pi_apply i)).div measurable_const)).aemeasurable + ((measurable_const.add (measurable_pi_apply i)).div + measurable_const)).aemeasurable · linarith [hC 0, norm_nonneg (f 0)] · filter_upwards with x calc ‖f (aPlusProd n i x) - f (aMinusProd n i x)‖ @@ -567,7 +571,8 @@ theorem variance_rademacherSum_efronStein (f : ℝ → ℝ) (hf : CompactlySuppo -- So f(update x i 1) = f(a⁺) and f(update x i (-1)) = f(a⁻) have hf1 : f (rademacherSumProd n (Function.update x i 1)) = f (aPlusProd n i x) := by unfold aPlusProd; rw [hupdate_1] - have hfneg1 : f (rademacherSumProd n (Function.update x i (-1))) = f (aMinusProd n i x) := by + have hfneg1 : f (rademacherSumProd n (Function.update x i (-1))) = + f (aMinusProd n i x) := by unfold aMinusProd; rw [hupdate_neg1] rw [hcond, hf1, hfneg1] -- Now the computation depends on whether x i = 1 or x i = -1 @@ -577,14 +582,16 @@ theorem variance_rademacherSum_efronStein (f : ℝ → ℝ) (hf : CompactlySuppo have ha_eq : f (aPlusProd n i x) = f (rademacherSumProd n x) := by congr 1; unfold aPlusProd; simp [hpos] rw [ha_eq] - -- LHS = (f(S_n) - (1/2 * f(S_n) + 1/2 * f(a⁻)))² = (1/2 * (f(S_n) - f(a⁻)))² = 1/4 * (f(S_n) - f(a⁻))² + -- LHS = (f(S_n) - (1/2 * f(S_n) + 1/2 * f(a⁻)))² = (1/2 * (f(S_n) - f(a⁻)))² + -- = 1/4 * (f(S_n) - f(a⁻))² ring_nf exact le_refl _ · -- x i = -1: f(S_n) = f(a⁻) (since a⁻ = S_n when x i = -1) have ha_eq : f (aMinusProd n i x) = f (rademacherSumProd n x) := by congr 1; unfold aMinusProd; simp [hneg] rw [ha_eq] - -- LHS = (f(S_n) - (1/2 * f(a⁺) + 1/2 * f(S_n)))² = (1/2 * (f(S_n) - f(a⁺)))² = 1/4 * (f(a⁺) - f(S_n))² + -- LHS = (f(S_n) - (1/2 * f(a⁺) + 1/2 * f(S_n)))² = (1/2 * (f(S_n) - f(a⁺)))² + -- = 1/4 * (f(a⁺) - f(S_n))² ring_nf exact le_refl _ _ = (n : ℝ) / 4 * ∫ x, (f (aPlusProd n 0 x) - f (aMinusProd n 0 x))^2 @@ -592,7 +599,8 @@ theorem variance_rademacherSum_efronStein (f : ℝ → ℝ) (hf : CompactlySuppo -- By symmetry, all n terms are equal since the Rademacher variables are i.i.d. -- ∑ᵢ (1/4) * E[...] = n * (1/4) * E[term at i=0] = (n/4) * E[...] -- The integral ∫ (f(a⁺ᵢ(x)) - f(a⁻ᵢ(x)))² dμ(x) is the same for all i - have hall_eq : ∀ i ∈ Finset.univ, (1/4 : ℝ) * ∫ x, (f (aPlusProd n i x) - f (aMinusProd n i x))^2 + have hall_eq : ∀ i ∈ Finset.univ, (1/4 : ℝ) * + ∫ x, (f (aPlusProd n i x) - f (aMinusProd n i x))^2 ∂(rademacherProductMeasure n) = (1/4 : ℝ) * ∫ x, (f (aPlusProd n 0 x) - f (aMinusProd n 0 x))^2 ∂(rademacherProductMeasure n) := by diff --git a/StatsMLlib/Probability/Gaussian/Poincare/Limit.lean b/StatsMLlib/Probability/Gaussian/Poincare/Limit.lean index a4ef8fe..63eb114 100644 --- a/StatsMLlib/Probability/Gaussian/Poincare/Limit.lean +++ b/StatsMLlib/Probability/Gaussian/Poincare/Limit.lean @@ -163,7 +163,8 @@ lemma tendsto_cos_pow_exp (t : ℝ) : rw [Asymptotics.isLittleO_iff] intro c hc -- Use cos(x) = 1 - x²/2 + O(x⁴) and eventually |t/√n| ≤ 1 - filter_upwards [eventually_ge_atTop (max (Nat.ceil (t^2) + 1) (Nat.ceil (|t|^4 * (5/96) / c) + 1))] + filter_upwards [eventually_ge_atTop + (max (Nat.ceil (t^2) + 1) (Nat.ceil (|t|^4 * (5/96) / c) + 1))] with n hn have hn1 : n ≥ Nat.ceil (t^2) + 1 := le_of_max_le_left hn have hn2 : n ≥ Nat.ceil (|t|^4 * (5/96) / c) + 1 := le_of_max_le_right hn @@ -439,7 +440,8 @@ lemma taylor_bound_on_law {f : ℝ → ℝ} (hf : CompactlySupportedSmooth f) (n have eq2 : ∫ x, f x ∂(rademacherProductMeasure (n + 1)).map (rademacherSumProd (n + 1)) = ∫ x, f (rademacherSumProd (n + 1) x) ∂rademacherProductMeasure (n + 1) := by rw [integral_map haem hf.continuous.aestronglyMeasurable] - have eq3 : ∫ x, (deriv f x)^2 ∂(rademacherProductMeasure (n + 1)).map (rademacherSumProd (n + 1)) = + have eq3 : ∫ x, + (deriv f x)^2 ∂(rademacherProductMeasure (n + 1)).map (rademacherSumProd (n + 1)) = ∫ x, (deriv f (rademacherSumProd (n + 1) x))^2 ∂rademacherProductMeasure (n + 1) := by simpa only [Pi.pow_apply] using integral_map haem ((deriv_continuous_of_compactlySupported hf).pow 2).aestronglyMeasurable @@ -448,7 +450,8 @@ lemma taylor_bound_on_law {f : ℝ → ℝ} (hf : CompactlySupportedSmooth f) (n rw [integral_map haem (deriv_continuous_of_compactlySupported hf).abs.aestronglyMeasurable] rw [eq1, eq2, eq3, eq4] -- Convert variance on product space - have hvar : variance (fun x => f (rademacherSumProd (n + 1) x)) (rademacherProductMeasure (n + 1)) = + have hvar : variance (fun x => f (rademacherSumProd (n + 1) x)) + (rademacherProductMeasure (n + 1)) = ∫ x, (f (rademacherSumProd (n + 1) x))^2 ∂rademacherProductMeasure (n + 1) - (∫ x, f (rademacherSumProd (n + 1) x) ∂rademacherProductMeasure (n + 1))^2 := by rw [variance_eq_sub] @@ -762,7 +765,8 @@ theorem tendsto_n_sq_diff_sub_four_deriv_sq {f : ℝ → ℝ} (hf : CompactlySup simp only [Nat.cast_add, Nat.cast_one] exact Filter.tendsto_atTop_add_const_right atTop 1 tendsto_natCast_atTop_atTop exact tendsto_inv_atTop_zero.comp (tendsto_sqrt_atTop.comp h') - have h16KC' : Tendsto (fun n : ℕ => 16 * K * C' * (Real.sqrt (↑(n + 1) : ℝ))⁻¹) atTop (𝓝 0) := by + have h16KC' : Tendsto (fun n : ℕ => 16 * K * C' * + (Real.sqrt (↑(n + 1) : ℝ))⁻¹) atTop (𝓝 0) := by simpa using hsqrt_tendsto.const_mul (16 * K * C') simp_rw [div_eq_mul_inv] exact h16KC' @@ -811,10 +815,12 @@ theorem tendsto_n_sq_diff_sub_four_deriv_sq {f : ℝ → ℝ} (hf : CompactlySup apply AEStronglyMeasurable.sub · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd (n + 1)).add - ((measurable_const.sub (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.sub (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd (n + 1)).sub - ((measurable_const.add (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.add (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · exact hC'_nonneg · filter_upwards with x exact rescaledDiff_bounded hf (n + 1) x @@ -913,7 +919,8 @@ theorem tendsto_sum_sq_diff_four_deriv_sq {f : ℝ → ℝ} (hf : CompactlySuppo have hσ_symm : σ.symm = σ := Equiv.symm_swap 0 i have hσ_i : σ i = 0 := Equiv.swap_apply_right 0 i -- rademacherSumProd is invariant under coordinate permutation - have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = rademacherSumProd (n + 1) x := by + have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = + rademacherSumProd (n + 1) x := by intro x unfold rademacherSumProd rw [MeasurableEquiv.coe_piCongrLeft] @@ -1055,7 +1062,8 @@ theorem tendsto_sum_sq_shifted_four_deriv_sq {f : ℝ → ℝ} (hf : CompactlySu have hσ_symm : σ.symm = σ := Equiv.symm_swap 0 i have hσ_i : σ i = 0 := Equiv.swap_apply_right 0 i -- rademacherSumProd is invariant under coordinate permutation - have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = rademacherSumProd (n + 1) x := by + have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = + rademacherSumProd (n + 1) x := by intro x unfold rademacherSumProd rw [MeasurableEquiv.coe_piCongrLeft] @@ -1089,7 +1097,8 @@ theorem tendsto_sum_sq_shifted_four_deriv_sq {f : ℝ → ℝ} (hf : CompactlySu let swapEquiv := MeasurableEquiv.piCongrLeft (fun _ : Fin (n + 1) => ℝ) σ have hσ_symm : σ.symm = σ := Equiv.symm_swap 0 i have hσ_i : σ i = 0 := Equiv.swap_apply_right 0 i - have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = rademacherSumProd (n + 1) x := by + have hsum_inv : ∀ x, rademacherSumProd (n + 1) (swapEquiv x) = + rademacherSumProd (n + 1) x := by intro x unfold rademacherSumProd rw [MeasurableEquiv.coe_piCongrLeft] @@ -1176,7 +1185,8 @@ def compactlySupportedSqMulLogToBCF {f : ℝ → ℝ} (hf : CompactlySupportedSm let M := Classical.choose (sq_mul_log_sq_bounded_of_compactlySupported hf) BoundedContinuousFunction.ofNormedAddCommGroup (fun x => (f x)^2 * Real.log ((f x)^2)) (continuous_sq_mul_log_sq hf) M (fun x => by - rw [Real.norm_eq_abs]; exact Classical.choose_spec (sq_mul_log_sq_bounded_of_compactlySupported hf) x) + rw [Real.norm_eq_abs]; exact Classical.choose_spec + (sq_mul_log_sq_bounded_of_compactlySupported hf) x) @[simp] lemma compactlySupportedSqMulLogToBCF_apply {f : ℝ → ℝ} (hf : CompactlySupportedSmooth f) (x : ℝ) : @@ -1227,7 +1237,8 @@ theorem tendsto_entropy_f_sq {f : ℝ → ℝ} (hf : CompactlySupportedSmooth f) -- Term 3: (∫ f²) * log(∫ f²) converges (composition of h2 with continuous function x * log x) have h3 : Tendsto (fun n => (∫ x, (f x)^2 ∂(rademacherLaw (n + 1)).toMeasure) * Real.log (∫ x, (f x)^2 ∂(rademacherLaw (n + 1)).toMeasure)) - atTop (𝓝 ((∫ x, (f x)^2 ∂stdGaussianMeasure) * Real.log (∫ x, (f x)^2 ∂stdGaussianMeasure))) := by + atTop (𝓝 ((∫ x, (f x)^2 ∂stdGaussianMeasure) * + Real.log (∫ x, (f x)^2 ∂stdGaussianMeasure))) := by -- Use that x * log x is continuous, so g(aₙ) → g(a) when aₙ → a exact Real.continuous_mul_log.continuousAt.tendsto.comp h2 -- Combine: entropy = term1 - term3 diff --git a/StatsMLlib/Probability/Gaussian/Poincare/RademacherApproximation.lean b/StatsMLlib/Probability/Gaussian/Poincare/RademacherApproximation.lean index 122bc33..2ab9669 100644 --- a/StatsMLlib/Probability/Gaussian/Poincare/RademacherApproximation.lean +++ b/StatsMLlib/Probability/Gaussian/Poincare/RademacherApproximation.lean @@ -109,7 +109,8 @@ theorem rademacher_second_moment : ∫ x, x^2 ∂rademacherMeasure = 1 := by simp /-- The variance of a Rademacher random variable is 1. -/ -theorem rademacher_variance_one : ∫ x, x^2 ∂rademacherMeasure - (∫ x, x ∂rademacherMeasure)^2 = 1 := by +theorem rademacher_variance_one : ∫ x, x^2 ∂rademacherMeasure - + (∫ x, x ∂rademacherMeasure)^2 = 1 := by rw [rademacher_expectation_zero, rademacher_second_moment] ring @@ -170,7 +171,8 @@ lemma IndepRademacherSeq.integrable (seq : IndepRademacherSeq Ω P) (i : ℕ) : Integrable (seq.ε i) (↑P) := by -- Use the fact that P.map ε_i = rademacherMeasure and id is integrable on rademacherMeasure have h := seq.isRademacher i - have him := integrable_map_measure (μ := ↑P) aestronglyMeasurable_id (seq.measurable i).aemeasurable + have him := + integrable_map_measure (μ := ↑P) aestronglyMeasurable_id (seq.measurable i).aemeasurable rw [h] at him exact him.mp integrable_id_rademacherMeasure diff --git a/StatsMLlib/Probability/Gaussian/Poincare/Taylor.lean b/StatsMLlib/Probability/Gaussian/Poincare/Taylor.lean index 06835af..b66af8d 100644 --- a/StatsMLlib/Probability/Gaussian/Poincare/Taylor.lean +++ b/StatsMLlib/Probability/Gaussian/Poincare/Taylor.lean @@ -20,7 +20,8 @@ Rademacher sums. * `sq_deviation_sum`: `(a⁺ - Sₙ)² + (a⁻ - Sₙ)² = 4/n` for Rademacher variables. * `deriv2_bounded_of_compactlySupported`: For `f ∈ C_c²(ℝ)`, `sup|f''| < ∞`. * `taylor_diff_bound`: The Taylor expansion bound on `|f(a⁺) - f(a⁻)|`. -* `variance_rademacherSum_taylor_bound`: The refined variance bound using Taylor's theorem, `Var(f(Sₙ)) ≤ E[f'(Sₙ)²] + (4K/√n)E[|f'(Sₙ)|] + 4K²/n`. +* `variance_rademacherSum_taylor_bound`: The refined variance bound using Taylor's theorem, + `Var(f(Sₙ)) ≤ E[f'(Sₙ)²] + (4K/√n)E[|f'(Sₙ)|] + 4K²/n`. -/ @@ -603,10 +604,12 @@ theorem variance_rademacherSum_simple_bound {f : ℝ → ℝ} (hf : CompactlySup · apply AEStronglyMeasurable.sub · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).add - ((measurable_const.sub (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.sub (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).sub - ((measurable_const.add (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.add (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · linarith [hC 0, norm_nonneg (f 0)] · filter_upwards with x calc ‖f (aPlusProd n 0 x) - f (aMinusProd n 0 x)‖ @@ -674,7 +677,8 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup -- Bound the integral calc variance (fun x => f (rademacherSumProd n x)) μ ≤ (n : ℝ) / 4 * ∫ x, (f (aPlusProd n 0 x) - f (aMinusProd n 0 x))^2 ∂μ := hES - _ ≤ (n : ℝ) / 4 * ∫ x, (2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n)^2 ∂μ := by + _ ≤ (n : ℝ) / 4 * + ∫ x, (2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n)^2 ∂μ := by apply mul_le_mul_of_nonneg_left _ (div_nonneg (Nat.cast_nonneg n) (by norm_num)) apply integral_mono_ae · -- Integrability of LHS @@ -683,10 +687,12 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup · apply AEStronglyMeasurable.sub · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).add - ((measurable_const.sub (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.sub (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · exact hf.continuous.aestronglyMeasurable.comp_aemeasurable ((measurable_rademacherSumProd n).sub - ((measurable_const.add (measurable_pi_apply 0)).div measurable_const)).aemeasurable + ((measurable_const.add (measurable_pi_apply 0)).div + measurable_const)).aemeasurable · linarith [hC 0, norm_nonneg (f 0)] · filter_upwards with x calc ‖f (aPlusProd n 0 x) - f (aMinusProd n 0 x)‖ @@ -700,7 +706,9 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup apply integrable_sq_of_bounded (C := 2 * C' / Real.sqrt n + 4 * K / n) · apply AEStronglyMeasurable.add · apply AEStronglyMeasurable.mul aestronglyMeasurable_const - exact (continuous_abs.comp (deriv_continuous_of_compactlySupported hf)).aestronglyMeasurable.comp_aemeasurable + exact AEStronglyMeasurable.comp_aemeasurable + (continuous_abs.comp + (deriv_continuous_of_compactlySupported hf)).aestronglyMeasurable (measurable_rademacherSumProd n).aemeasurable · exact aestronglyMeasurable_const · apply add_nonneg @@ -709,7 +717,8 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup · filter_upwards with x have h1 : |deriv f (rademacherSumProd n x)| ≤ C' := hC' _ calc ‖2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n‖ - = |2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n| := Real.norm_eq_abs _ + = |2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n| := + Real.norm_eq_abs _ _ = 2 / Real.sqrt n * |deriv f (rademacherSumProd n x)| + 4 * K / n := by apply abs_of_nonneg apply add_nonneg @@ -717,7 +726,8 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup · apply div_nonneg (mul_nonneg (by norm_num) hK_nonneg) (Nat.cast_nonneg n) _ ≤ 2 / Real.sqrt n * C' + 4 * K / n := by apply add_le_add - · apply mul_le_mul_of_nonneg_left h1 (div_nonneg (by norm_num) (le_of_lt hsqrt_pos)) + · apply mul_le_mul_of_nonneg_left h1 + (div_nonneg (by norm_num) (le_of_lt hsqrt_pos)) · exact le_refl _ _ = 2 * C' / Real.sqrt n + 4 * K / n := by ring · exact hbound @@ -727,7 +737,8 @@ theorem variance_rademacherSum_taylor_bound {f : ℝ → ℝ} (hf : CompactlySup congr 1 apply integral_congr_ae filter_upwards with x - have h_deriv_sq : |deriv f (rademacherSumProd n x)|^2 = (deriv f (rademacherSumProd n x))^2 := + have h_deriv_sq : |deriv f (rademacherSumProd n x)|^2 = + (deriv f (rademacherSumProd n x))^2 := sq_abs _ have hsqrt_inv_sq : (Real.sqrt n)⁻¹ ^ 2 = (n : ℝ)⁻¹ := by rw [inv_pow, hsqrt_sq] diff --git a/StatsMLlib/Probability/Gaussian/Sobolev/Cutoff.lean b/StatsMLlib/Probability/Gaussian/Sobolev/Cutoff.lean index 8642fee..04cd71b 100644 --- a/StatsMLlib/Probability/Gaussian/Sobolev/Cutoff.lean +++ b/StatsMLlib/Probability/Gaussian/Sobolev/Cutoff.lean @@ -154,12 +154,14 @@ lemma smoothCutoffR_fderiv_bound {R : ℝ} (hR : 0 < R) : apply mul_le_mul · -- ‖fderiv ℝ smoothCutoff (‖x‖ / R)‖ ≤ C -- fderiv of scalar function = deriv times identity - have heq : fderiv ℝ smoothCutoff (‖x‖ / R) = (deriv smoothCutoff (‖x‖ / R)) • (1 : ℝ →L[ℝ] ℝ) := by + have heq : fderiv ℝ smoothCutoff (‖x‖ / R) = (deriv smoothCutoff (‖x‖ / R)) • + (1 : ℝ →L[ℝ] ℝ) := by ext simp only [smul_apply, one_apply_eq_self, smul_eq_mul] rw [fderiv_eq_smul_deriv, smul_eq_mul, mul_comm] rw [heq, norm_smul, norm_one, mul_one, Real.norm_eq_abs] - calc |deriv smoothCutoff (‖x‖ / R)| = ‖deriv smoothCutoff (‖x‖ / R)‖ := (Real.norm_eq_abs _).symm + calc |deriv smoothCutoff (‖x‖ / R)| = ‖deriv smoothCutoff (‖x‖ / R)‖ := + (Real.norm_eq_abs _).symm _ ≤ C := hC_bound (‖x‖ / R) · exact fderiv_norm_div_bound hR x · exact norm_nonneg _ @@ -175,7 +177,8 @@ lemma cutoff_L2_convergence (f : E n → ℝ) (hf : MemLp f 2 (stdGaussianE n)) Filter.Tendsto (fun R => eLpNorm (f - f * smoothCutoffR R) 2 (stdGaussianE n)) Filter.atTop (nhds 0) := by -- Rewrite: f - f·χ_R = f·(1 - χ_R) - have heq : ∀ R : ℝ, ∀ x : E n, (f - f * (smoothCutoffR (n := n) R)) x = f x * (1 - smoothCutoffR R x) := by + have heq : ∀ R : ℝ, ∀ x : E n, (f - f * (smoothCutoffR (n := n) R)) x = f x * + (1 - smoothCutoffR R x) := by intro R x simp only [Pi.sub_apply, Pi.mul_apply] ring @@ -191,7 +194,8 @@ lemma cutoff_L2_convergence (f : E n → ℝ) (hf : MemLp f 2 (stdGaussianE n)) · linarith · linarith -- Pointwise convergence: (1 - χ_R)(x) → 0 for all x - have h_ptwise : ∀ x : E n, Filter.Tendsto (fun R => 1 - smoothCutoffR (n := n) R x) Filter.atTop (nhds 0) := by + have h_ptwise : ∀ x : E n, + Filter.Tendsto (fun R => 1 - smoothCutoffR (n := n) R x) Filter.atTop (nhds 0) := by intro x have htends : Filter.Tendsto (fun R => smoothCutoffR R x) Filter.atTop (nhds 1) := smoothCutoffR_tendsto_one x @@ -282,10 +286,12 @@ lemma cutoff_L2_convergence (f : E n → ℝ) (hf : MemLp f 2 (stdGaussianE n)) have h1 : Filter.Tendsto (fun R => f' x * (1 - smoothCutoffR R x)) Filter.atTop (nhds 0) := by rw [← mul_zero (f' x)] exact Filter.Tendsto.const_mul (f' x) (h_ptwise x) - have h2 : Filter.Tendsto (fun R => ‖f' x * (1 - smoothCutoffR R x)‖₊) Filter.atTop (nhds (0 : ℝ≥0)) := by + have h2 : Filter.Tendsto (fun R => ‖f' x * (1 - smoothCutoffR R x)‖₊) Filter.atTop + (nhds (0 : ℝ≥0)) := by rw [← @nnnorm_zero ℝ _] exact Filter.Tendsto.nnnorm h1 - have h3 : Filter.Tendsto (fun R => (‖f' x * (1 - smoothCutoffR R x)‖₊ : ℝ≥0∞)) Filter.atTop (nhds 0) := by + have h3 : Filter.Tendsto (fun R => + (‖f' x * (1 - smoothCutoffR R x)‖₊ : ℝ≥0∞)) Filter.atTop (nhds 0) := by exact ENNReal.tendsto_coe.mpr h2 -- (‖·‖₊ : ℝ≥0∞) → 0 implies (‖·‖₊)^2 → 0 have h0_pow : (0 : ℝ≥0∞) ^ (2 : ℝ) = 0 := ENNReal.zero_rpow_of_pos (by norm_num : (0 : ℝ) < 2) @@ -358,7 +364,8 @@ lemma cutoff_gradient_error_bound (f : E n → ℝ) constructor <;> linarith -- Pointwise convergence: (1 - χ_R)(x) → 0 for all x - have h_ptwise : ∀ x : E n, Filter.Tendsto (fun R => 1 - smoothCutoffR (n := n) R x) Filter.atTop (nhds 0) := by + have h_ptwise : ∀ x : E n, + Filter.Tendsto (fun R => 1 - smoothCutoffR (n := n) R x) Filter.atTop (nhds 0) := by intro x have htends : Filter.Tendsto (fun R => smoothCutoffR R x) Filter.atTop (nhds 1) := smoothCutoffR_tendsto_one x @@ -442,10 +449,12 @@ lemma cutoff_gradient_error_bound (f : E n → ℝ) have h1 : Filter.Tendsto (fun R => (1 - smoothCutoffR R x) • g' x) Filter.atTop (nhds 0) := by rw [← zero_smul ℝ (g' x)] exact Filter.Tendsto.smul (h_ptwise x) tendsto_const_nhds - have h2 : Filter.Tendsto (fun R => ‖(1 - smoothCutoffR R x) • g' x‖₊) Filter.atTop (nhds (0 : ℝ≥0)) := by + have h2 : Filter.Tendsto (fun R => ‖(1 - smoothCutoffR R x) • g' x‖₊) Filter.atTop + (nhds (0 : ℝ≥0)) := by rw [← @nnnorm_zero (E n →L[ℝ] ℝ) _] exact Filter.Tendsto.nnnorm h1 - have h3 : Filter.Tendsto (fun R => (‖(1 - smoothCutoffR R x) • g' x‖₊ : ℝ≥0∞)) Filter.atTop (nhds 0) := by + have h3 : Filter.Tendsto (fun R => + (‖(1 - smoothCutoffR R x) • g' x‖₊ : ℝ≥0∞)) Filter.atTop (nhds 0) := by exact ENNReal.tendsto_coe.mpr h2 have h0_pow : (0 : ℝ≥0∞) ^ (2 : ℝ) = 0 := ENNReal.zero_rpow_of_pos (by norm_num : (0 : ℝ) < 2) rw [← h0_pow] @@ -469,7 +478,8 @@ lemma cutoff_gradient_error_bound (f : E n → ℝ) exact hlintegral'_tendsto -- Convert lintegral → 0 to eLpNorm → 0 - have heLpNorm_eq : ∀ R, eLpNorm (fun x => (1 - smoothCutoffR R x) • fderiv ℝ f x) 2 (stdGaussianE n) = + have heLpNorm_eq : ∀ R, + eLpNorm (fun x => (1 - smoothCutoffR R x) • fderiv ℝ f x) 2 (stdGaussianE n) = (∫⁻ x, F R x ∂(stdGaussianE n)) ^ (2⁻¹ : ℝ) := by intro R have hχR_cont : Continuous (smoothCutoffR (n := n) R) := by @@ -500,7 +510,8 @@ lemma cutoff_gradient_extra_term (f : E n → ℝ) (hf : MemLp f 2 (stdGaussianE let C := smoothCutoff_deriv_bounded.choose have hC_pos : 0 < C := smoothCutoff_deriv_bounded.choose_spec.1 have hC_bound : ∀ x : ℝ, ‖deriv smoothCutoff x‖ ≤ C := smoothCutoff_deriv_bounded.choose_spec.2 - -- For R > 0, derive the bound for smoothCutoffR (inline the key steps from smoothCutoffR_fderiv_bound) + -- For R > 0, derive the bound for smoothCutoffR + -- (inline the key steps from smoothCutoffR_fderiv_bound) have hbound : ∀ R : ℝ, 0 < R → ∀ x : E n, ‖fderiv ℝ (smoothCutoffR (n := n) R) x‖ ≤ C / R := by intro R hR x by_cases hxR : ‖x‖ < R @@ -542,12 +553,14 @@ lemma cutoff_gradient_extra_term (f : E n → ℝ) (hf : MemLp f 2 (stdGaussianE ContinuousLinearMap.opNorm_comp_le _ _ _ ≤ C * (1 / R) := by apply mul_le_mul - · have heq : fderiv ℝ smoothCutoff (‖x‖ / R) = (deriv smoothCutoff (‖x‖ / R)) • (1 : ℝ →L[ℝ] ℝ) := by + · have heq : fderiv ℝ smoothCutoff (‖x‖ / R) = (deriv smoothCutoff (‖x‖ / R)) • + (1 : ℝ →L[ℝ] ℝ) := by ext simp only [smul_apply, one_apply_eq_self, smul_eq_mul] rw [fderiv_eq_smul_deriv, smul_eq_mul, mul_comm] rw [heq, norm_smul, norm_one, mul_one, Real.norm_eq_abs] - calc |deriv smoothCutoff (‖x‖ / R)| = ‖deriv smoothCutoff (‖x‖ / R)‖ := (Real.norm_eq_abs _).symm + calc |deriv smoothCutoff (‖x‖ / R)| = ‖deriv smoothCutoff (‖x‖ / R)‖ := + (Real.norm_eq_abs _).symm _ ≤ C := hC_bound (‖x‖ / R) · exact fderiv_norm_div_bound hR x · exact norm_nonneg _ @@ -752,7 +765,8 @@ lemma fderiv_zero_at_ball_boundary {R : ℝ} {f g : E n → ℝ} {x : E n} rw [h2, norm_neg, norm_smul, Real.norm_of_nonneg ht_pos.le] rw [h3, h4, h2, zero_sub, norm_neg] at hδ_prop have h5 : L (-(t • x)) = -(t * L x) := by simp only [map_neg, map_smul, smul_eq_mul] - rw [h5, norm_neg, Real.norm_eq_abs, abs_mul, abs_of_pos ht_pos, ← Real.norm_eq_abs (L x)] at hδ_prop + rw [h5, norm_neg, Real.norm_eq_abs, abs_mul, abs_of_pos ht_pos, + ← Real.norm_eq_abs (L x)] at hδ_prop have h6 : ε * (t * ‖x‖) = t * ‖L x‖ / 2 := by simp only [ε]; field_simp rw [h6] at hδ_prop linarith [mul_pos ht_pos hpos] @@ -762,10 +776,12 @@ lemma fderiv_zero_at_ball_boundary {R : ℝ} {f g : E n → ℝ} {x : E n} by_contra hLw_ne have hLw_pos : 0 < |L w| := abs_pos.mpr hLw_ne -- Use ε = |L w| / (4(‖x‖ + ‖w‖)) to get contradiction - have hε : 0 < |L w| / (4 * (‖x‖ + ‖w‖ + 1)) := div_pos hLw_pos (by linarith [norm_nonneg x, norm_nonneg w]) + have hε : 0 < |L w| / (4 * (‖x‖ + ‖w‖ + 1)) := + div_pos hLw_pos (by linarith [norm_nonneg x, norm_nonneg w]) obtain ⟨δ, hδ_pos, hδ_prop⟩ := Metric.eventually_nhds_iff.mp (h_fderiv_at.isLittleO.def hε) let t_ineq := R^2 / (R^2 + ‖w‖^2 + 1) - have ht_ineq_pos : 0 < t_ineq := div_pos (sq_pos_of_pos hR) (by linarith [sq_nonneg R, sq_nonneg ‖w‖]) + have ht_ineq_pos : 0 < t_ineq := + div_pos (sq_pos_of_pos hR) (by linarith [sq_nonneg R, sq_nonneg ‖w‖]) let t := min (min (δ / (2 * (‖x‖ + ‖w‖ + 1))) (1/2)) t_ineq have ht_pos : 0 < t := lt_min (lt_min (div_pos hδ_pos (mul_pos (by norm_num) (by linarith [norm_nonneg x, norm_nonneg w]))) (by norm_num)) ht_ineq_pos @@ -908,12 +924,14 @@ theorem tendsto_cutoff_W12 (f : E n → ℝ) (hf : MemW12Gaussian n f (stdGaussi by_cases hf_diff : DifferentiableAt ℝ f x · -- f differentiable: use product rule and triangle inequality have hχ_diff : DifferentiableAt ℝ (smoothCutoffR R) x := - (smoothCutoffR_contDiff hR_pos).differentiable (WithTop.coe_ne_zero.mpr WithTop.top_ne_zero) x + (smoothCutoffR_contDiff hR_pos).differentiable + (WithTop.coe_ne_zero.mpr WithTop.top_ne_zero) x have h1 : fderiv ℝ (f * smoothCutoffR R - f) x = fderiv ℝ (f * smoothCutoffR R) x - fderiv ℝ f x := fderiv_sub (hf_diff.mul hχ_diff) hf_diff rw [h1, fderiv_mul hf_diff hχ_diff] - have heq : f x • fderiv ℝ (smoothCutoffR R) x + smoothCutoffR R x • fderiv ℝ f x - fderiv ℝ f x = + have heq : f x • fderiv ℝ (smoothCutoffR R) x + smoothCutoffR R x • fderiv ℝ f x - + fderiv ℝ f x = f x • fderiv ℝ (smoothCutoffR R) x - (1 - smoothCutoffR R x) • fderiv ℝ f x := by ext v simp only [sub_apply, add_apply, @@ -976,10 +994,12 @@ theorem tendsto_cutoff_W12 (f : E n → ℝ) (hf : MemW12Gaussian n f (stdGaussi have hy_norm : ‖y‖ < R := by have h1 : ‖y‖ ≤ ‖x‖ + ‖y - x‖ := norm_le_insert' y x linarith - have hχ_y : smoothCutoffR R y = 1 := smoothCutoffR_eq_one_of_norm_le hR_pos (le_of_lt hy_norm) + have hχ_y : smoothCutoffR R y = 1 := + smoothCutoffR_eq_one_of_norm_le hR_pos (le_of_lt hy_norm) simp only [Pi.mul_apply, Pi.sub_apply, hχ_y, mul_one, sub_self] have hfderiv_zero : fderiv ℝ (f * smoothCutoffR R - f) x = 0 := by - have h_eq : (f * smoothCutoffR (n := n) R - f) =ᶠ[nhds x] (fun _ : E n => (0 : ℝ)) := by + have h_eq : (f * smoothCutoffR (n := n) R - f) =ᶠ[nhds x] + (fun _ : E n => (0 : ℝ)) := by filter_upwards [h_local_zero] with y hy; exact hy rw [Filter.EventuallyEq.fderiv_eq (𝕜 := ℝ) h_eq] exact fderiv_const_apply (0 : ℝ) @@ -1048,7 +1068,8 @@ theorem tendsto_cutoff_W12 (f : E n → ℝ) (hf : MemW12Gaussian n f (stdGaussi have hmeas1 : AEStronglyMeasurable term2 (stdGaussianE n) := hf_L2.aestronglyMeasurable.smul hcont_fderiv.aestronglyMeasurable have hmeas2 : AEStronglyMeasurable term1 (stdGaussianE n) := - ((continuous_const.sub hcont_cutoff).aestronglyMeasurable).smul hf_grad.aestronglyMeasurable + ((continuous_const.sub hcont_cutoff).aestronglyMeasurable).smul + hf_grad.aestronglyMeasurable have hstep2 := eLpNorm_norm_add_le hmeas1 hmeas2 -- Combine and reorder have hreorder : eLpNorm term2 2 (stdGaussianE n) + eLpNorm term1 2 (stdGaussianE n) = diff --git a/StatsMLlib/Probability/Gaussian/Sobolev/Defs.lean b/StatsMLlib/Probability/Gaussian/Sobolev/Defs.lean index 5598ad8..9d80cd8 100644 --- a/StatsMLlib/Probability/Gaussian/Sobolev/Defs.lean +++ b/StatsMLlib/Probability/Gaussian/Sobolev/Defs.lean @@ -20,8 +20,8 @@ import Mathlib.Analysis.Normed.Module.FiniteDimension /-! # Strong Gaussian Sobolev Space Definitions -This file defines the Gaussian Sobolev space W^{1,2}(γ) for C¹ function space and related infrastructure -for the density theorem: C_c^∞(ℝⁿ) is dense in W^{1,2}(γ) for C¹. +This file defines the Gaussian Sobolev space W^{1,2}(γ) for C¹ function space and related +infrastructure for the density theorem: C_c^∞(ℝⁿ) is dense in W^{1,2}(γ) for C¹. ## Main Definitions @@ -207,7 +207,8 @@ lemma smoothCutoffR_nonneg (R : ℝ) (x : E n) : 0 ≤ smoothCutoffR R x := lemma smoothCutoffR_le_one (R : ℝ) (x : E n) : smoothCutoffR R x ≤ 1 := smoothCutoff_le_one _ -lemma smoothCutoffR_contDiff {R : ℝ} (hR : 0 < R) : ContDiff ℝ (⊤ : ℕ∞) (smoothCutoffR R : E n → ℝ) := by +lemma smoothCutoffR_contDiff {R : ℝ} (hR : 0 < R) : + ContDiff ℝ (⊤ : ℕ∞) (smoothCutoffR R : E n → ℝ) := by rw [contDiff_iff_contDiffAt] intro x by_cases hx : ‖x‖ < R @@ -525,7 +526,9 @@ lemma stdMollifierEps_eq_zero_of_abs_ge {ε : ℝ} (hε : 0 < ε) {x : ℝ} (hx have h1 : (-1 : ℝ) * ε < x := by calc (-1 : ℝ) * ε = -ε := by ring _ = (-ε / ε) * ε := by rw [div_mul_cancel₀]; exact ne_of_gt hε - _ < (x / ε) * ε := by apply mul_lt_mul_of_pos_right; rw [neg_div]; simp [ne_of_gt hε]; exact hleft; exact hε + _ < (x / ε) * ε := by + apply mul_lt_mul_of_pos_right; rw [neg_div]; simp [ne_of_gt hε]; exact hleft + exact hε _ = x := by rw [div_mul_cancel₀]; exact ne_of_gt hε linarith have hx_ge : x ≥ ε := by @@ -570,7 +573,8 @@ lemma stdMollifierEps_integral_eq_one {ε : ℝ} (hε : 0 < ε) : rw [h_eq] -- Use integral_comp_smul: ∫ f(R • x) = |R^{-dim}| • ∫ f(x) -- For dim = 1: ∫ f(ε⁻¹ • x) = |ε| • ∫ f(x) - rw [MeasureTheory.Measure.integral_comp_smul_of_nonneg volume stdMollifier ε⁻¹ (hR := inv_nonneg.mpr hε.le)] + rw [MeasureTheory.Measure.integral_comp_smul_of_nonneg volume stdMollifier ε⁻¹ + (hR := inv_nonneg.mpr hε.le)] have hdim : Module.finrank ℝ ℝ = 1 := Module.finrank_self ℝ simp only [hdim, pow_one, inv_inv, smul_eq_mul, stdMollifier_integral_eq_one, mul_one] field_simp diff --git a/StatsMLlib/Probability/Gaussian/Sobolev/Density.lean b/StatsMLlib/Probability/Gaussian/Sobolev/Density.lean index 36a581b..c8ad016 100644 --- a/StatsMLlib/Probability/Gaussian/Sobolev/Density.lean +++ b/StatsMLlib/Probability/Gaussian/Sobolev/Density.lean @@ -10,7 +10,8 @@ import StatsMLlib.Probability.Gaussian.Sobolev.Mollification /-! # Density of Smooth Compactly Supported Functions in W^{1,2}(γ) -This file proves the main theorem: C_c^∞(ℝⁿ) is dense in the Strong Gaussian Sobolev space W^{1,2}(γ). +This file proves the main theorem: C_c^∞(ℝⁿ) is dense in the Strong Gaussian Sobolev space +W^{1,2}(γ). ## Main Results @@ -594,11 +595,14 @@ lemma eLpNorm_toE1Fun_eq (f : ℝ → ℝ) (p : ℝ≥0∞) unfold toE1Fun rw [stdGaussianE_1_eq_map_gaussianReal] -- The key: f ∘ equivE1Real is AEStronglyMeasurable on map measure - have hg : AEStronglyMeasurable (f ∘ equivE1Real) (Measure.map equivE1Real.symm (gaussianReal 0 1)) := by - -- Use comp_measurable: AEStronglyMeasurable g (map f μ) → Measurable f → AEStronglyMeasurable (g ∘ f) μ + have hg : + AEStronglyMeasurable (f ∘ equivE1Real) (Measure.map equivE1Real.symm (gaussianReal 0 1)) := by + -- Use comp_measurable: + -- AEStronglyMeasurable g (map f μ) → Measurable f → AEStronglyMeasurable (g ∘ f) μ -- Here μ = map e.symm (gaussianReal 0 1), f = e, g = f (the original function) -- So map e μ = map e (map e.symm (gaussianReal 0 1)) = gaussianReal 0 1 - have h_map_map : Measure.map equivE1Real (Measure.map equivE1Real.symm (gaussianReal 0 1)) = gaussianReal 0 1 := by + have h_map_map : Measure.map equivE1Real (Measure.map equivE1Real.symm (gaussianReal 0 1)) = + gaussianReal 0 1 := by rw [Measure.map_map measurable_equivE1Real measurable_equivE1Real_symm] simp only [Equiv.self_comp_symm] exact Measure.map_id @@ -611,9 +615,12 @@ lemma eLpNorm_toE1Fun_eq (f : ℝ → ℝ) (p : ℝ≥0∞) /-- The fderiv of toE1Fun f at a point relates to the fderiv of f. -/ lemma fderiv_toE1Fun (f : ℝ → ℝ) (hf_diff : Differentiable ℝ f) (x : GaussianSobolev.E 1) : - fderiv ℝ (toE1Fun f) x = (fderiv ℝ f (equivE1Real x)).comp (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) := by + fderiv ℝ (toE1Fun f) x = + (fderiv ℝ f (equivE1Real x)).comp + (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) := by unfold toE1Fun - have hdiff_eq : DifferentiableAt ℝ equivE1Real x := linearIsometryEquivE1Real.differentiable.differentiableAt + have hdiff_eq : DifferentiableAt ℝ equivE1Real x := + linearIsometryEquivE1Real.differentiable.differentiableAt rw [fderiv_comp x (hf_diff (equivE1Real x)) hdiff_eq] congr 1 -- fderiv of a linear isometry equiv is itself @@ -643,7 +650,8 @@ lemma memW12Gaussian_toE1Fun (f : ℝ → ℝ) (hf : MemW12GaussianReal f (gauss rw [MeasurableEquiv.memLp_map_measure_iff measurableEquivE1Real.symm] have heq : toE1Fun f ∘ measurableEquivE1Real.symm = f := by ext x - simp only [toE1Fun, Function.comp_apply, measurableEquivE1Real_symm_eq, Equiv.apply_symm_apply] + simp only [toE1Fun, Function.comp_apply, measurableEquivE1Real_symm_eq, + Equiv.apply_symm_apply] rw [heq] exact hf.1 · -- fderiv of toE1Fun f ∈ Lp²(stdGaussianE 1) @@ -662,20 +670,23 @@ lemma memW12Gaussian_toE1Fun (f : ℝ → ℝ) (hf : MemW12GaussianReal f (gauss -- Use: ‖L.comp iso‖ = ‖L‖ for isometries have hiso_eq : (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) = linearIsometryEquivE1Real.toLinearIsometry.toContinuousLinearMap := rfl - have hnorm_eq : ∀ y, ‖(fderiv ℝ f y).comp (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ)‖ = + have hnorm_eq : ∀ y, + ‖(fderiv ℝ f y).comp (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ)‖ = ‖fderiv ℝ f y‖ := by intro y rw [hiso_eq] exact ContinuousLinearMap.opNorm_comp_linearIsometryEquiv (fderiv ℝ f y) linearIsometryEquivE1Real - -- Use MemLp.of_le: MemLp g p μ → AEStronglyMeasurable f μ → (∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) → MemLp f p μ + -- Use MemLp.of_le: + -- MemLp g p μ → AEStronglyMeasurable f μ → (∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) → MemLp f p μ apply MemLp.of_le hf.2 · -- AEStronglyMeasurable: (fderiv ℝ f ·).comp iso is measurable -- The map L ↦ L.comp iso is a continuous linear map (apply compSL.flip to iso) let iso := (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) -- compSL.flip iso : (ℝ →L[ℝ] ℝ) →L[ℝ] (E 1 →L[ℝ] ℝ) maps L to L.comp iso let compWithIso : (ℝ →L[ℝ] ℝ) →L[ℝ] (GaussianSobolev.E 1 →L[ℝ] ℝ) := - (ContinuousLinearMap.compSL (GaussianSobolev.E 1) ℝ ℝ (RingHom.id ℝ) (RingHom.id ℝ)).flip iso + (ContinuousLinearMap.compSL (GaussianSobolev.E 1) ℝ ℝ (RingHom.id ℝ) + (RingHom.id ℝ)).flip iso exact compWithIso.continuous.comp_aestronglyMeasurable hf.2.aestronglyMeasurable · filter_upwards with x rw [hnorm_eq] @@ -692,7 +703,9 @@ lemma continuous_fderiv_toE1Fun (f : ℝ → ℝ) (hf_diff : Differentiable ℝ (hf_cont : Continuous (fun x => fderiv ℝ f x)) : Continuous (fun x => fderiv ℝ (toE1Fun f) x) := by have heq : (fun x => fderiv ℝ (toE1Fun f) x) = - fun x => (fderiv ℝ f (equivE1Real x)).comp (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) := by + fun x => + (fderiv ℝ f (equivE1Real x)).comp + (linearIsometryEquivE1Real : GaussianSobolev.E 1 →L[ℝ] ℝ) := by funext x exact fderiv_toE1Fun f hf_diff x rw [heq] @@ -761,7 +774,8 @@ lemma gaussianSobolevNormSq_fromE1Fun (g : GaussianSobolev.E 1 → ℝ) (hg_smoo rw [stdGaussianE_1_eq_map_gaussianReal] -- Need: AEStronglyMeasurable (‖fderiv ℝ g ·‖) (map equivE1Real.symm (gaussianReal 0 1)) have hfderiv_cont : Continuous (fderiv ℝ g) := hg_smooth.continuous_fderiv one_ne_zero - have hgrad_aesm : AEStronglyMeasurable (fun x => ‖fderiv ℝ g x‖) (Measure.map equivE1Real.symm (gaussianReal 0 1)) := + have hgrad_aesm : AEStronglyMeasurable (fun x => ‖fderiv ℝ g x‖) + (Measure.map equivE1Real.symm (gaussianReal 0 1)) := (continuous_norm.comp hfderiv_cont).aestronglyMeasurable rw [eLpNorm_map_measure hgrad_aesm haem] -- Need to prove the functions are equal, which makes the eLpNorms equal @@ -773,9 +787,11 @@ lemma gaussianSobolevNormSq_fromE1Fun (g : GaussianSobolev.E 1 → ℝ) (hg_smoo -- equivE1Real.symm = linearIsometryEquivE1Real.symm as functions have heq_symm : ⇑equivE1Real.symm = ⇑linearIsometryEquivE1Real.symm := rfl have h : fderiv ℝ (g ∘ equivE1Real.symm) x = - (fderiv ℝ g (equivE1Real.symm x)).comp (linearIsometryEquivE1Real.symm : ℝ →L[ℝ] GaussianSobolev.E 1) := by + (fderiv ℝ g (equivE1Real.symm x)).comp + (linearIsometryEquivE1Real.symm : ℝ →L[ℝ] GaussianSobolev.E 1) := by conv_lhs => rw [heq_symm] - rw [fderiv_comp x (hg_diff _) linearIsometryEquivE1Real.symm.differentiable.differentiableAt] + rw [fderiv_comp x (hg_diff _) + linearIsometryEquivE1Real.symm.differentiable.differentiableAt] congr 1 exact linearIsometryEquivE1Real.symm.toContinuousLinearEquiv.fderiv rw [h] diff --git a/StatsMLlib/Probability/Gaussian/Sobolev/Mollification.lean b/StatsMLlib/Probability/Gaussian/Sobolev/Mollification.lean index fcb3f6b..d3bf2ce 100644 --- a/StatsMLlib/Probability/Gaussian/Sobolev/Mollification.lean +++ b/StatsMLlib/Probability/Gaussian/Sobolev/Mollification.lean @@ -18,7 +18,8 @@ in W^{1,2}(γ) for functions with compact support. * `mollify_smooth` - f ⋆ ρ_ε is smooth (C^∞) * `mollify_compact_support` - if f has compact support, so does f ⋆ ρ_ε -* `mollify_L2_convergence_gaussian_continuous` - mollification L² convergence for continuous functions +* `mollify_L2_convergence_gaussian_continuous` - mollification L² convergence for continuous + functions * `mollify_L2_convergence_gaussian` - ‖g ⋆ ρ_ε - g‖_{L²(γ)} → 0 as ε → 0 * `tendsto_mollify_W12` - For fixed R, f^(R,ε) → f^(R) in W^{1,2}(γ) as ε → 0 @@ -228,7 +229,8 @@ lemma mollify_tendsto_pointwise {n : ℕ} {g : E n → ℝ} (hg_cont : Continuou rw [show g x = ∫ y, g x * stdMollifierPi n ε y by rw [MeasureTheory.integral_const_mul, h_int_one, mul_one]] rw [← integral_sub] - · have h_bound : |∫ y, g (x - y) * stdMollifierPi n ε y - g x * stdMollifierPi n ε y| ≤ δ / 2 := by + · have h_bound : |∫ y, g (x - y) * stdMollifierPi n ε y - g x * + stdMollifierPi n ε y| ≤ δ / 2 := by calc |∫ y, g (x - y) * stdMollifierPi n ε y - g x * stdMollifierPi n ε y| = |∫ y, (g (x - y) - g x) * stdMollifierPi n ε y| := by congr 1; congr 1; ext y; ring @@ -240,7 +242,8 @@ lemma mollify_tendsto_pointwise {n : ℕ} {g : E n → ℝ} (hg_cont : Continuou apply integral_mono_of_nonneg · filter_upwards with y exact mul_nonneg (abs_nonneg _) (stdMollifierPi_nonneg ε hε_pos y) - · exact Integrable.const_mul ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport + · exact Integrable.const_mul + ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport (stdMollifierPi_hasCompactSupport hε_pos)) _ · filter_upwards with y by_cases hy_supp : y ∈ tsupport (stdMollifierPi n ε) @@ -258,7 +261,8 @@ lemma mollify_tendsto_pointwise {n : ℕ} {g : E n → ℝ} (hg_cont : Continuou exact stdMollifierPi_nonneg ε hε_pos y · have hy_not_supp : y ∉ Function.support (stdMollifierPi n ε) := fun h => hy_supp (subset_closure h) - have hy_zero : stdMollifierPi n ε y = 0 := Function.notMem_support.mp hy_not_supp + have hy_zero : stdMollifierPi n ε y = 0 := + Function.notMem_support.mp hy_not_supp simp only [hy_zero, mul_zero, le_refl] _ = (δ / 2) * ∫ y, stdMollifierPi n ε y := MeasureTheory.integral_const_mul _ _ _ = (δ / 2) * 1 := by rw [h_int_one] @@ -270,7 +274,8 @@ lemma mollify_tendsto_pointwise {n : ℕ} {g : E n → ℝ} (hg_cont : Continuou have hprod_supp : HasCompactSupport (fun y => g (x - y) * stdMollifierPi n ε y) := (stdMollifierPi_hasCompactSupport hε_pos).mul_left exact hprod_cont.integrable_of_hasCompactSupport hprod_supp - · exact Integrable.const_mul ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport + · exact Integrable.const_mul + ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport (stdMollifierPi_hasCompactSupport hε_pos)) (g x) /-! #### Uniform Convergence on Compact Sets -/ @@ -333,7 +338,8 @@ lemma mollify_tendsto_uniformly_on_compact {n : ℕ} {g : E n → ℝ} {K : Set rw [show g x = ∫ y, g x * stdMollifierPi n ε y by rw [MeasureTheory.integral_const_mul, h_int_one, mul_one]] rw [← integral_sub] - · have h_bound : |∫ y, g (x - y) * stdMollifierPi n ε y - g x * stdMollifierPi n ε y| ≤ δ / 2 := by + · have h_bound : |∫ y, g (x - y) * stdMollifierPi n ε y - g x * + stdMollifierPi n ε y| ≤ δ / 2 := by calc |∫ y, g (x - y) * stdMollifierPi n ε y - g x * stdMollifierPi n ε y| = |∫ y, (g (x - y) - g x) * stdMollifierPi n ε y| := by congr 1; congr 1; ext y; ring @@ -343,8 +349,10 @@ lemma mollify_tendsto_uniformly_on_compact {n : ℕ} {g : E n → ℝ} {K : Set rw [abs_mul, abs_of_nonneg (stdMollifierPi_nonneg ε hε_pos y)] _ ≤ ∫ y, (δ / 2) * stdMollifierPi n ε y := by apply integral_mono_of_nonneg - · exact ae_of_all _ fun y => mul_nonneg (abs_nonneg _) (stdMollifierPi_nonneg ε hε_pos y) - · exact Integrable.const_mul ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport + · exact ae_of_all _ fun y => + mul_nonneg (abs_nonneg _) (stdMollifierPi_nonneg ε hε_pos y) + · exact Integrable.const_mul + ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport (stdMollifierPi_hasCompactSupport hε_pos)) _ · apply ae_of_all _ intro y @@ -367,7 +375,8 @@ lemma mollify_tendsto_uniformly_on_compact {n : ℕ} {g : E n → ℝ} {K : Set exact Set.add_mem_add hx (Metric.mem_closedBall_self (by linarith : (0 : ℝ) ≤ 1)) have hg_close := hη_unif (x - y) hxy_mem x hx_mem hdist simp only [dist_eq_norm, Real.norm_eq_abs] at hg_close - exact mul_le_mul_of_nonneg_right (le_of_lt hg_close) (stdMollifierPi_nonneg ε hε_pos y) + exact mul_le_mul_of_nonneg_right (le_of_lt hg_close) + (stdMollifierPi_nonneg ε hε_pos y) · have hy_not_supp : y ∉ Function.support (stdMollifierPi n ε) := fun h => hy_supp (subset_closure h) have hy_zero : stdMollifierPi n ε y = 0 := Function.notMem_support.mp hy_not_supp @@ -383,7 +392,8 @@ lemma mollify_tendsto_uniformly_on_compact {n : ℕ} {g : E n → ℝ} {K : Set ring rw [h_neg, abs_neg] linarith [h_bound] - · exact Integrable.const_mul ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport + · exact Integrable.const_mul + ((stdMollifierPi_contDiff hε_pos).continuous.integrable_of_hasCompactSupport (stdMollifierPi_hasCompactSupport hε_pos)) (g x) · have hg_sub_cont : Continuous (fun y => g (x - y)) := hg_cont.comp (continuous_sub_left x) have hprod_cont : Continuous (fun y => g (x - y) * stdMollifierPi n ε y) := @@ -433,7 +443,8 @@ lemma eLpNorm_tendsto_zero_of_tendstoUniformly_restrict {n : ℕ} {f : ℕ → E obtain ⟨N, hN⟩ := hN use N intro i hi - have h_bound : eLpNorm (f i - g) 2 (volume.restrict s) ≤ ENNReal.ofReal δ * (volume s) ^ (1/2 : ℝ) := by + have h_bound : eLpNorm (f i - g) 2 (volume.restrict s) ≤ ENNReal.ofReal δ * + (volume s) ^ (1/2 : ℝ) := by calc eLpNorm (f i - g) 2 (volume.restrict s) ≤ eLpNorm (fun _ => δ) 2 (volume.restrict s) := by apply eLpNorm_mono_ae (hfg_meas i).restrict @@ -471,7 +482,8 @@ lemma eLpNorm_tendsto_zero_of_tendstoUniformly_restrict {n : ℕ} {f : ℕ → E apply div_nonneg ENNReal.toReal_nonneg linarith [h_sqrt_pos] rw [← ENNReal.ofReal_mul hε_nonneg] - have h_simp : ε.toReal / (2 * (volume s).toReal.sqrt) * (volume s).toReal.sqrt = ε.toReal / 2 := by + have h_simp : ε.toReal / (2 * (volume s).toReal.sqrt) * + (volume s).toReal.sqrt = ε.toReal / 2 := by field_simp rw [h_simp] calc ENNReal.ofReal (ε.toReal / 2) @@ -577,7 +589,8 @@ lemma mollify_L2_convergence_continuous {n : ℕ} {g : E n → ℝ} {R : ℝ} (h (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by rw [ENNReal.tendsto_nhds_zero] intro δ hδ - have hK : IsCompact (Metric.closedBall (0 : E n) (2 * R + 1)) := isCompact_closedBall 0 (2 * R + 1) + have hK : IsCompact (Metric.closedBall (0 : E n) (2 * R + 1)) := + isCompact_closedBall 0 (2 * R + 1) have hμ : volume (Metric.closedBall (0 : E n) (2 * R + 1)) < ⊤ := by exact measure_closedBall_lt_top have h_unif := mollify_tendsto_uniformly_on_compact hK hg_cont @@ -598,7 +611,8 @@ lemma mollify_L2_convergence_continuous {n : ℕ} {g : E n → ℝ} {R : ℝ} (h have h_evt_sqrt : ∀ᶠ (ε : ℝ) in nhdsWithin 0 (Set.Ioi 0), ε * Real.sqrt (n : ℝ) < 1 := by by_cases hn : n = 0 · simp only [hn, Nat.cast_zero, Real.sqrt_zero, mul_zero, zero_lt_one, Filter.eventually_true] - · have hn_pos : 0 < Real.sqrt (n : ℝ) := Real.sqrt_pos.mpr (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)) + · have hn_pos : 0 < Real.sqrt (n : ℝ) := + Real.sqrt_pos.mpr (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)) have h_bound : 0 < 1 / Real.sqrt (n : ℝ) := div_pos one_pos hn_pos filter_upwards [Ioo_mem_nhdsGT h_bound] with ε hε calc ε * Real.sqrt n < (1 / Real.sqrt n) * Real.sqrt n := by @@ -608,7 +622,8 @@ lemma mollify_L2_convergence_continuous {n : ℕ} {g : E n → ℝ} {R : ℝ} (h filter_upwards [self_mem_nhdsWithin] with ε hε exact hε filter_upwards [h_evt, h_evt_sqrt, h_evt_pos] with ε hε_unif hε_sqrt hε_pos - have h_supp_diff : ∀ x, x ∉ Metric.closedBall (0 : E n) (2 * R + 1) → (mollify ε g - g) x = 0 := by + have h_supp_diff : ∀ x, x ∉ Metric.closedBall (0 : E n) (2 * R + 1) → + (mollify ε g - g) x = 0 := by intro x hx simp only [Pi.sub_apply] have hg_x : g x = 0 := by @@ -674,7 +689,8 @@ lemma mollify_L2_convergence_continuous {n : ℕ} {g : E n → ℝ} {R : ℝ} (h simp only [Pi.sub_apply] at h rw [h, abs_zero] exact hη_pos.le - _ = ENNReal.ofReal |η| * (volume.restrict (Metric.closedBall (0 : E n) (2 * R + 1)) Set.univ) ^ (1/2 : ℝ) := by + _ = ENNReal.ofReal |η| * + (volume.restrict (Metric.closedBall (0 : E n) (2 * R + 1)) Set.univ) ^ (1/2 : ℝ) := by rw [eLpNorm_const] · congr 1 · rw [Real.enorm_eq_ofReal_abs] @@ -701,12 +717,16 @@ lemma mollify_L2_convergence_continuous {n : ℕ} {g : E n → ℝ} {R : ℝ} (h exact ENNReal.ofReal_pos.mpr h_rad_pos rw [h_pow] at this exact (lt_irrefl 0 this).elim - · have hgamma : 0 < Real.Gamma (Fintype.card (Fin n) / 2 + 1) := Real.Gamma_pos_of_pos (by positivity) + · have hgamma : 0 < Real.Gamma (Fintype.card (Fin n) / 2 + 1) := + Real.Gamma_pos_of_pos (by positivity) have hsqrt : 0 < Real.sqrt Real.pi := Real.sqrt_pos.mpr Real.pi_pos have hpow : 0 < Real.sqrt Real.pi ^ Fintype.card (Fin n) := pow_pos hsqrt _ - have h_pos : 0 < Real.sqrt Real.pi ^ Fintype.card (Fin n) / Real.Gamma (Fintype.card (Fin n) / 2 + 1) := + have h_pos : 0 < Real.sqrt Real.pi ^ Fintype.card (Fin n) / + Real.Gamma (Fintype.card (Fin n) / 2 + 1) := div_pos hpow hgamma - have h_ne : (0 : ℝ≥0∞) < ENNReal.ofReal (Real.sqrt Real.pi ^ Fintype.card (Fin n) / Real.Gamma (Fintype.card (Fin n) / 2 + 1)) := + have h_ne : (0 : ℝ≥0∞) < + ENNReal.ofReal (Real.sqrt Real.pi ^ Fintype.card (Fin n) / + Real.Gamma (Fintype.card (Fin n) / 2 + 1)) := ENNReal.ofReal_pos.mpr h_pos rw [h_const] at h_ne exact (lt_irrefl 0 h_ne).elim @@ -937,12 +957,16 @@ lemma mollify_L2_convergence_gaussian_continuous {n : ℕ} {g : E n → ℝ} {R rw [ENNReal.toReal_rpow] exact (ENNReal.ofReal_toReal h_rpow_ne_top).symm rw [h1] - rw [← ENNReal.ofReal_mul (by linarith : 0 ≤ δr / (2 * (stdGaussianE n K).toReal.sqrt + 1))] - calc ENNReal.ofReal (δr / (2 * (stdGaussianE n K).toReal.sqrt + 1) * (stdGaussianE n K).toReal.sqrt) + rw [← ENNReal.ofReal_mul (by linarith : 0 ≤ δr / + (2 * (stdGaussianE n K).toReal.sqrt + 1))] + calc ENNReal.ofReal (δr / (2 * (stdGaussianE n K).toReal.sqrt + 1) * + (stdGaussianE n K).toReal.sqrt) ≤ ENNReal.ofReal δr := by apply ENNReal.ofReal_le_ofReal - calc (δr / (2 * (stdGaussianE n K).toReal.sqrt + 1)) * (stdGaussianE n K).toReal.sqrt - = δr * ((stdGaussianE n K).toReal.sqrt / (2 * (stdGaussianE n K).toReal.sqrt + 1)) := by ring + calc (δr / (2 * (stdGaussianE n K).toReal.sqrt + 1)) * + (stdGaussianE n K).toReal.sqrt + = δr * ((stdGaussianE n K).toReal.sqrt / + (2 * (stdGaussianE n K).toReal.sqrt + 1)) := by ring _ ≤ δr * 1 := by apply mul_le_mul_of_nonneg_left _ hδr_pos.le rw [div_le_one h_denom_pos] @@ -1001,8 +1025,10 @@ lemma cutoff_product_fderiv_continuous {f : E n → ℝ} {R : ℝ} (hR : 0 < R) (hf_diff : Differentiable ℝ f) (hf_grad_cont : Continuous (fun x => fderiv ℝ f x)) : Continuous (fun x => fderiv ℝ (f * smoothCutoffR R) x) := by - have hχ_diff := (@smoothCutoffR_contDiff n R hR).differentiable (WithTop.coe_ne_zero.mpr ENat.top_ne_zero) - have hχ_cont : Continuous (fun x => smoothCutoffR R x) := (@smoothCutoffR_contDiff n R hR).continuous + have hχ_diff := + (@smoothCutoffR_contDiff n R hR).differentiable (WithTop.coe_ne_zero.mpr ENat.top_ne_zero) + have hχ_cont : Continuous (fun x => smoothCutoffR R x) := + (@smoothCutoffR_contDiff n R hR).continuous have hχ_fderiv_cont : Continuous (fun x => fderiv ℝ (smoothCutoffR R) x) := (@smoothCutoffR_contDiff n R hR).continuous_fderiv (WithTop.coe_ne_zero.mpr ENat.top_ne_zero) have h_eq : ∀ x, fderiv ℝ (f * smoothCutoffR R) x = @@ -1076,7 +1102,8 @@ lemma gradient_L2_convergence_gaussian {g : E n → ℝ} {R : ℝ} (hR : 0 < R) (hg_diff : Differentiable ℝ g) (hg_grad_cont : Continuous (fun x => fderiv ℝ g x)) (hg_supp : tsupport g ⊆ Metric.closedBall 0 (2 * R)) : - Filter.Tendsto (fun ε => eLpNorm (fun x => ‖fderiv ℝ (mollify ε g) x - fderiv ℝ g x‖) 2 (stdGaussianE n)) + Filter.Tendsto (fun ε => + eLpNorm (fun x => ‖fderiv ℝ (mollify ε g) x - fderiv ℝ g x‖) 2 (stdGaussianE n)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by have hg_c1 : ContDiff ℝ 1 g := contDiff_one_iff_fderiv.mpr ⟨hg_diff, hg_grad_cont⟩ have hg_compact : HasCompactSupport g := @@ -1173,7 +1200,8 @@ lemma gradient_L2_convergence_gaussian {g : E n → ℝ} {R : ℝ} (hR : 0 < R) set δ' := δ / (Real.sqrt n + 1) with hδ'_def have hδ'_pos : δ' > 0 := div_pos hδ (by linarith [Real.sqrt_nonneg n]) have h_finite_inter : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), - ∀ i, ∀ x ∈ K', dist (fderiv ℝ g x (b i)) (mollify ε (fun y => fderiv ℝ g y (b i)) x) < δ' := by + ∀ i, ∀ x ∈ K', + dist (fderiv ℝ g x (b i)) (mollify ε (fun y => fderiv ℝ g y (b i)) x) < δ' := by have := Filter.eventually_all.mpr (fun i => h_eps_i i δ' hδ'_pos) filter_upwards [this] with ε hε i x hx exact hε i x hx @@ -1187,11 +1215,13 @@ lemma gradient_L2_convergence_gaussian {g : E n → ℝ} {R : ℝ} (hR : 0 < R) simp only [Metric.mem_ball, dist_zero_right, Real.norm_eq_abs, abs_of_pos hε_pos] exact hε_lt_ε₀ have hε_in_Ioi : ε ∈ Set.Ioi (0 : ℝ) := hε_pos - have h_bound_basis : ∀ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| < δ' := by + have h_bound_basis : ∀ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - + fderiv ℝ g x (b i)| < δ' := by intro i have := hU_cond ε hε_in_U hε_in_Ioi i x (hK_sub_K' hx) rwa [Real.dist_eq, abs_sub_comm] at this - have h_commute : ∀ i, fderiv ℝ (mollify ε g) x (b i) = mollify ε (fun y => fderiv ℝ g y (b i)) x := by + have h_commute : ∀ i, fderiv ℝ (mollify ε g) x (b i) = + mollify ε (fun y => fderiv ℝ g y (b i)) x := by intro i exact fderiv_mollify_eq_mollify_fderiv_apply hε_pos hg_c1 hg_compact x (b i) have h_bound_sqrt : Real.sqrt n * δ' < δ := by @@ -1218,10 +1248,13 @@ lemma gradient_L2_convergence_gaussian {g : E n → ℝ} {R : ℝ} (hR : 0 < R) (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| ≤ ∑ i : Fin n, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| := by - calc |∑ i, b.repr v i * (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| - ≤ ∑ i, |b.repr v i * (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| := + calc |∑ i, b.repr v i * + (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| + ≤ ∑ i, |b.repr v i * + (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| := Finset.abs_sum_le_sum_abs _ _ - _ = ∑ i, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| := by + _ = ∑ i, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - + fderiv ℝ g x (b i)| := by congr 1; ext i; exact abs_mul _ _ have h2 : ∑ i : Fin n, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| @@ -1253,10 +1286,13 @@ lemma gradient_L2_convergence_gaussian {g : E n → ℝ} {R : ℝ} (hR : 0 < R) rw [Real.sqrt_mul (Nat.cast_nonneg n), Real.sqrt_sq (le_of_lt hδ'_pos)] calc |∑ i, b.repr v i * (mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i))| - ≤ ∑ i, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| := h1 + ≤ ∑ i, |b.repr v i| * |mollify ε (fun y => fderiv ℝ g y (b i)) x - + fderiv ℝ g x (b i)| := h1 _ ≤ (∑ i, |b.repr v i| ^ 2).sqrt * - (∑ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| ^ 2).sqrt := h2 - _ = 1 * (∑ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - fderiv ℝ g x (b i)| ^ 2).sqrt := by + (∑ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - + fderiv ℝ g x (b i)| ^ 2).sqrt := h2 + _ = 1 * (∑ i, |mollify ε (fun y => fderiv ℝ g y (b i)) x - + fderiv ℝ g x (b i)| ^ 2).sqrt := by rw [h_sum_eq_one] _ ≤ 1 * (Real.sqrt n * δ') := by apply mul_le_mul_of_nonneg_left h_sum_bound zero_le_one @@ -1318,7 +1354,8 @@ lemma tendsto_mollify_W12 {n : ℕ} (f : E n → ℝ) {R : ℝ} (hR : 0 < R) (hf_diff : Differentiable ℝ f) (hf_grad_cont : Continuous (fun x => fderiv ℝ f x)) : Filter.Tendsto (fun ε => - GaussianSobolevNormSq n (mollify ε (f * smoothCutoffR R) - f * smoothCutoffR R) (stdGaussianE n)) + GaussianSobolevNormSq n (mollify ε (f * smoothCutoffR R) - f * smoothCutoffR R) + (stdGaussianE n)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by set g := f * smoothCutoffR R have hg_supp : tsupport g ⊆ Metric.closedBall 0 (2 * R) := cutoff_product_support hR diff --git a/StatsMLlib/Probability/GraphicalModel/Factorization.lean b/StatsMLlib/Probability/GraphicalModel/Factorization.lean index 962a51e..765a0a2 100644 --- a/StatsMLlib/Probability/GraphicalModel/Factorization.lean +++ b/StatsMLlib/Probability/GraphicalModel/Factorization.lean @@ -40,7 +40,8 @@ def Factorizes (G : SimpleGraph V) [DecidableRel G.Adj] (p : (∀ v, Ω v) → /-- A product `h · k` with `h` depending on `A ∪ S` and `k` on `B ∪ S`, where `A ∪ B ∪ S` covers all vertices, makes `A` and `B` independent given `S`. -/ theorem DiscreteCondIndep.of_mul {A B S : Finset V} (hAB : Disjoint A B) (hAS : Disjoint A S) - (hcover : A ∪ B ∪ S = univ) {h k : (∀ v, Ω v) → ℝ} (hh : DependsOn h ((A ∪ S : Finset V) : Set V)) + (hcover : A ∪ B ∪ S = univ) {h k : (∀ v, Ω v) → ℝ} + (hh : DependsOn h ((A ∪ S : Finset V) : Set V)) (hk : DependsOn k ((B ∪ S : Finset V) : Set V)) (hp : ∀ x, p x = h x * k x) : DiscreteCondIndep p A B S := by have hmem : ∀ v, v ∈ A ∨ v ∈ B ∨ v ∈ S := fun v ↦ by @@ -118,7 +119,8 @@ private theorem dependsOn_prod {ι : Type*} {s : Finset ι} {f : ι → (∀ v, /-- A function that factorises over `G` satisfies the global Markov property. Split the clique potentials into those inside `Ã ∪ S`, where `Ã` is the set reachable from `A` avoiding `S`, and the rest, which avoid `Ã`. -/ -theorem Factorizes.isGlobalMarkov (hF : Factorizes G p) : IsGlobalMarkov G (DiscreteCondIndep p) := by +theorem Factorizes.isGlobalMarkov (hF : Factorizes G p) : IsGlobalMarkov G + (DiscreteCondIndep p) := by obtain ⟨ψ, -, hψ, hp⟩ := hF intro S A B hSA hSB hAB hsep set R := G.reachFinset S A diff --git a/StatsMLlib/Probability/Independence/FinsetPi.lean b/StatsMLlib/Probability/Independence/FinsetPi.lean index 119e0eb..f0fb7d2 100644 --- a/StatsMLlib/Probability/Independence/FinsetPi.lean +++ b/StatsMLlib/Probability/Independence/FinsetPi.lean @@ -43,7 +43,8 @@ theorem pi_map_eval {ι: Type*} {Ω : ι → Type*} [Fintype ι] [DecidableEq ι _ = _ := by exact Fintype.prod_ite_eq' k fun j ↦ μ k s -variable {Ω ι: Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ] [Fintype ι] [DecidableEq ι] +variable {Ω ι: Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ] [Fintype ι] + [DecidableEq ι] theorem pi_eval_iIndepFun : iIndepFun Function.eval (Measure.pi fun _ ↦ μ : Measure (ι → Ω)) := by diff --git a/StatsMLlib/Probability/Moments/Cumulant.lean b/StatsMLlib/Probability/Moments/Cumulant.lean index 7361aad..25c3333 100644 --- a/StatsMLlib/Probability/Moments/Cumulant.lean +++ b/StatsMLlib/Probability/Moments/Cumulant.lean @@ -385,3 +385,5 @@ theorem cgf_deriv_two [IsFiniteMeasure μ] [NeZero μ] (a b : ℝ) · exact (mgf_pos' (NeZero.ne μ) (integrable_expt_bound hX h)).ne' end GeneratingFunctionDerivatives + +end ProbabilityTheory diff --git a/StatsMLlib/Probability/RandomMatrix/Basic.lean b/StatsMLlib/Probability/RandomMatrix/Basic.lean index 7d7241b..786cd0f 100644 --- a/StatsMLlib/Probability/RandomMatrix/Basic.lean +++ b/StatsMLlib/Probability/RandomMatrix/Basic.lean @@ -480,8 +480,8 @@ def euclideanUnitBall (n : ℕ) : Set (EuclideanSpace ℝ (Fin n)) := /-- A pair of finite nets used to discretize the bilinear form `(x, y) ↦ ⟪A x, y⟫` for an `m × n` matrix. The underlying net notion is the generic -`IsENet` from `StatsMLlib.Topology.MetricSpace.CoveringNumber.Basic`; this structure only packages the domain and codomain nets -needed for rectangular matrix operator norms. +`IsENet` from `StatsMLlib.Topology.MetricSpace.CoveringNumber.Basic`; this structure only +packages the domain and codomain nets needed for rectangular matrix operator norms. -/ structure MatrixBilinearNet (m n : ℕ) (ε : ℝ) where domainNet : Finset (EuclideanSpace ℝ (Fin n)) @@ -5052,7 +5052,8 @@ theorem norm_subgaussian_matrices_expectation_hdp_of_pos {m n : ℕ} (hm : 0 < m Integrable (fun ω => signed.sup' hsigned_nonempty (fun q => Z q ω)) μ := by refine Integrable.mono (integrable_finsetSum signed (fun q hq => (hZ_int q hq).abs)) ?_ ?_ - · convert (Finset.measurable_sup' hsigned_nonempty (fun q hq => hZ_meas q hq)).aestronglyMeasurable using 1 + · convert (Finset.measurable_sup' hsigned_nonempty (fun q hq => + hZ_meas q hq)).aestronglyMeasurable using 1 funext ω simp only [Finset.sup'_apply] · refine ae_of_all μ (fun ω => ?_) @@ -5459,7 +5460,8 @@ theorem sampleCovarianceDeviationOperatorNorm_expectation_hdp_bound_of_pos have hsup_int : Integrable (fun ω => signed.sup' hsigned_nonempty (fun q => Z q ω)) μ := by refine Integrable.mono (integrable_finsetSum signed (fun q hq => (hZ_int q hq).abs)) ?_ ?_ - · convert (Finset.measurable_sup' hsigned_nonempty (fun q hq => hZ_meas q hq)).aestronglyMeasurable using 1 + · convert (Finset.measurable_sup' hsigned_nonempty (fun q hq => + hZ_meas q hq)).aestronglyMeasurable using 1 funext ω simp only [Finset.sup'_apply] · refine ae_of_all μ (fun ω => ?_) diff --git a/StatsMLlib/Probability/RandomMatrix/Bernstein.lean b/StatsMLlib/Probability/RandomMatrix/Bernstein.lean index 6ec4ba2..cc5aa0a 100644 --- a/StatsMLlib/Probability/RandomMatrix/Bernstein.lean +++ b/StatsMLlib/Probability/RandomMatrix/Bernstein.lean @@ -47,7 +47,7 @@ This file records the HDP Theorem 5.4.1 statement in the local random-matrix not bound. * `RMT.matrixBernstein_lieb_recursion_of_independent`: the arbitrary finite-family HDP Step 2 recursion for independent summands. -* `RMT.matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda`: +* `matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda`: the nondegenerate HDP norm-tail bound from the exact Step 2 recursion and Lemma 5.4.10 bounds. * `RMT.matrixBernstein_norm_tail_le_of_trace_exp_variance_bounds_at_optimizingLambda`: the nondegenerate HDP norm-tail bound from the two variance-matrix trace bounds. @@ -2298,7 +2298,8 @@ The nondegenerate HDP norm-tail bound from the exact remaining Step 2 and Step 3 * the Lieb-recursion trace bounds for `X` and `-X`, and * the individual matrix MGF Loewner bounds of HDP Lemma 5.4.10 for `X` and `-X`. -/ -theorem matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda +theorem + matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda {n N : ℕ} (hn : 0 < n) (X : Fin N → Ω → Matrix (Fin n) (Fin n) ℝ) (μ : Measure Ω) [IsProbabilityMeasure μ] {K t : ℝ} @@ -2399,7 +2400,8 @@ using the functional-calculus reduction for HDP Lemma 5.4.10. The only remaining the scalar inequality `exp(λx) ≤ 1 + λx + g(λ)x²` on `[-K, K]`. -/ -theorem matrixBernstein_norm_tail_le_of_lieb_recursions_and_mgfRate_scalar_envelope_at_optimizingLambda +theorem + matrixBernstein_norm_tail_le_of_lieb_recursions_and_mgfRate_scalar_envelope_at_optimizingLambda {n N : ℕ} (hn : 0 < n) (X : Fin N → Ω → Matrix (Fin n) (Fin n) ℝ) (μ : Measure Ω) [IsProbabilityMeasure μ] {K t : ℝ} @@ -2512,7 +2514,8 @@ theorem matrixBernstein_norm_tail_le_of_lieb_recursions_and_mgfRate_scalar_envel (by intro i; simpa [Xneg, l] using h_exp_int_neg i) h_integrable_neg h_square_integrable_neg h_mean_zero_neg hXneg_symmetric h_norm_bound_neg (by simpa [Xneg, l] using hscalar) - exact matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda + exact + matrixBernstein_norm_tail_le_of_lieb_recursions_and_individual_mgf_bounds_at_optimizingLambda hn X μ hσ hK ht h_square_integrable hX_symmetric htrace_int htrace_int_neg (by simpa [l] using hindividual_pos) (by simpa [Xneg, l] using hindividual_pos_neg) diff --git a/StatsMLlib/Probability/SmallBall.lean b/StatsMLlib/Probability/SmallBall.lean index 054655b..d234a71 100644 --- a/StatsMLlib/Probability/SmallBall.lean +++ b/StatsMLlib/Probability/SmallBall.lean @@ -74,8 +74,10 @@ lemma integral_exp_neg_mul_le_inv_of_dens_le_one simp [hf_supp x hx] exact integrableOn_zero.congr_fun h_zero measurableSet_Iio · -- On Ici 0: bounded by exp(-tx) which is integrable - have hf_aesm : AEStronglyMeasurable (fun x => (f x).toReal * exp (-t * x)) (volume.restrict (Ici 0)) := - (hf_meas.ennreal_toReal.mul (measurable_exp.comp (measurable_const.mul measurable_id))).aestronglyMeasurable + have hf_aesm : + AEStronglyMeasurable (fun x => (f x).toReal * exp (-t * x)) (volume.restrict (Ici 0)) := + (hf_meas.ennreal_toReal.mul + (measurable_exp.comp (measurable_const.mul measurable_id))).aestronglyMeasurable -- exp(-tx) is integrable on Ici 0 = Ioi 0 ∪ {0} have h_exp_int_Ici : IntegrableOn (fun x => exp (-t * x)) (Ici 0) volume := by rw [show Ici (0 : ℝ) = Ioi 0 ∪ {0} by ext; simp [le_iff_lt_or_eq, eq_comm]] @@ -212,7 +214,8 @@ theorem mgf_neg_le_inv_of_pdf_bounded have h_eq : ∫ ω, exp ((-t) * X ω) ∂μ = ∫ x, (pdf X μ volume x).toReal * exp ((-t) * x) := by have hf_aesm : AEStronglyMeasurable (fun x : ℝ => exp ((-t) * x)) volume := (measurable_exp.comp (measurable_const.mul measurable_id)).aestronglyMeasurable - have h := @pdf.integral_pdf_smul _ _ _ _ μ volume _ _ _ _ X hpdf (fun x => exp ((-t) * x)) hf_aesm + have h := + @pdf.integral_pdf_smul _ _ _ _ μ volume _ _ _ _ X hpdf (fun x => exp ((-t) * x)) hf_aesm simp only [smul_eq_mul] at h exact h.symm rw [h_eq] @@ -222,7 +225,8 @@ theorem mgf_neg_le_inv_of_pdf_bounded -- So pdf is 0 a.e. on (-∞, 0) have h_map : μ.map X (Iio 0) = 0 := by rw [Measure.map_apply hX measurableSet_Iio] - have h_subset : X ⁻¹' Iio 0 ⊆ {ω | ¬(0 ≤ X ω)} := fun ω hω => not_le.mpr (Set.mem_preimage.mp hω) + have h_subset : X ⁻¹' Iio 0 ⊆ {ω | ¬(0 ≤ X ω)} := + fun ω hω => not_le.mpr (Set.mem_preimage.mp hω) exact measure_mono_null h_subset (ae_iff.mp hX_nn) -- Use that pdf integrates to the pushforward measure have h_integral : ∫⁻ x in Iio 0, pdf X μ volume x ∂volume ≤ μ.map X (Iio 0) :=