From e8ad5c422dde593d7cf1bc0edf0a0204d7fb5caf Mon Sep 17 00:00:00 2001 From: tukamilano Date: Mon, 21 Sep 2026 15:01:51 +0900 Subject: [PATCH] remove duplicate theorem --- .../EmpiricalProcess/FunctionClass.lean | 5 ++ .../LearningTheory/Rademacher/Dudley.lean | 1 + .../Rademacher/FiniteClass.lean | 2 + .../Rademacher/LipschitzBall.lean | 1 + .../Rademacher/LipschitzParameter.lean | 2 + .../LearningTheory/Rademacher/OneStep.lean | 1 + .../Concentration/HansonWright.lean | 12 ---- .../Probability/RandomMatrix/Basic.lean | 21 ++---- .../LeastSquares/Linear/MinimaxRate.lean | 6 +- .../LeastSquares/LocalGaussianComplexity.lean | 65 ++++--------------- .../LeastSquares/MasterErrorBound.lean | 8 +-- 11 files changed, 36 insertions(+), 88 deletions(-) diff --git a/StatsMLlib/LearningTheory/EmpiricalProcess/FunctionClass.lean b/StatsMLlib/LearningTheory/EmpiricalProcess/FunctionClass.lean index 7370b28..a01eb27 100644 --- a/StatsMLlib/LearningTheory/EmpiricalProcess/FunctionClass.lean +++ b/StatsMLlib/LearningTheory/EmpiricalProcess/FunctionClass.lean @@ -26,6 +26,9 @@ metric structure are induced from StatsMLlib's canonical empirical space. universe v open scoped BigOperators + +namespace EmpiricalProcess.FunctionClass + variable {𝒳 : Type v} variable {n : β„•} @@ -195,3 +198,5 @@ lemma empiricalFunctionSpace_totallyBounded [Fintype ΞΉ] : (Set.univ : Set (EmpiricalFunctionSpace F S)) := Set.finite_univ.totallyBounded end + +end EmpiricalProcess.FunctionClass diff --git a/StatsMLlib/LearningTheory/Rademacher/Dudley.lean b/StatsMLlib/LearningTheory/Rademacher/Dudley.lean index f32bbb1..baa2a07 100644 --- a/StatsMLlib/LearningTheory/Rademacher/Dudley.lean +++ b/StatsMLlib/LearningTheory/Rademacher/Dudley.lean @@ -35,6 +35,7 @@ This module builds dyadic covers of `EmpiricalFunctionSpace` using `coveringFins universe v u open scoped BigOperators open Classical ProbabilityTheory +open EmpiricalProcess.FunctionClass section Empirical variable {Z : Type v} diff --git a/StatsMLlib/LearningTheory/Rademacher/FiniteClass.lean b/StatsMLlib/LearningTheory/Rademacher/FiniteClass.lean index 4768b60..7b01af4 100644 --- a/StatsMLlib/LearningTheory/Rademacher/FiniteClass.lean +++ b/StatsMLlib/LearningTheory/Rademacher/FiniteClass.lean @@ -19,6 +19,7 @@ noncomputable section universe u v open MeasureTheory Real +open EmpiricalProcess.FunctionClass variable {n : β„•} {H : Type u} {𝒳 : Type v} @@ -186,6 +187,7 @@ noncomputable section universe u v w open MeasureTheory ProbabilityTheory Real +open EmpiricalProcess.FunctionClass open scoped ENNReal variable {n : β„•} diff --git a/StatsMLlib/LearningTheory/Rademacher/LipschitzBall.lean b/StatsMLlib/LearningTheory/Rademacher/LipschitzBall.lean index a6742bb..13e6357 100644 --- a/StatsMLlib/LearningTheory/Rademacher/LipschitzBall.lean +++ b/StatsMLlib/LearningTheory/Rademacher/LipschitzBall.lean @@ -30,6 +30,7 @@ because the latter is dominated by the former on any sample. noncomputable section open MeasureTheory Real unitInterval ProbabilityTheory +open EmpiricalProcess.FunctionClass namespace LipschitzBall diff --git a/StatsMLlib/LearningTheory/Rademacher/LipschitzParameter.lean b/StatsMLlib/LearningTheory/Rademacher/LipschitzParameter.lean index dc0732c..94300a1 100644 --- a/StatsMLlib/LearningTheory/Rademacher/LipschitzParameter.lean +++ b/StatsMLlib/LearningTheory/Rademacher/LipschitzParameter.lean @@ -21,6 +21,7 @@ noncomputable section universe u open MeasureTheory Real +open EmpiricalProcess.FunctionClass variable {n : β„•} {𝒳 : Type u} @@ -369,6 +370,7 @@ noncomputable section universe u v open MeasureTheory ProbabilityTheory Real TopologicalSpace +open EmpiricalProcess.FunctionClass open scoped ENNReal variable {n : β„•} diff --git a/StatsMLlib/LearningTheory/Rademacher/OneStep.lean b/StatsMLlib/LearningTheory/Rademacher/OneStep.lean index 419d9c0..1657e59 100644 --- a/StatsMLlib/LearningTheory/Rademacher/OneStep.lean +++ b/StatsMLlib/LearningTheory/Rademacher/OneStep.lean @@ -31,6 +31,7 @@ noncomputable section universe u v open MeasureTheory Real +open EmpiricalProcess.FunctionClass namespace ProbabilityTheory diff --git a/StatsMLlib/Probability/Concentration/HansonWright.lean b/StatsMLlib/Probability/Concentration/HansonWright.lean index 53bd67c..a787a35 100644 --- a/StatsMLlib/Probability/Concentration/HansonWright.lean +++ b/StatsMLlib/Probability/Concentration/HansonWright.lean @@ -3038,18 +3038,6 @@ lemma centeredQuadraticForm_eq_diagonal_add_offDiagonal {ΞΌ : Measure Ξ©} Β· intro i _ exact hdiag_term_int i -lemma hasSubgaussianMGF_mono_param {ΞΌ : Measure Ξ©} {X : Ξ© β†’ ℝ} {c d : ℝβ‰₯0} - (h : HasSubgaussianMGF X c ΞΌ) (hcd : (c : ℝ) ≀ d) : - HasSubgaussianMGF X d ΞΌ where - integrable_exp_mul t := h.integrable_exp_mul t - mgf_le t := by - have hmul : (c : ℝ) * t ^ 2 ≀ (d : ℝ) * t ^ 2 := - mul_le_mul_of_nonneg_right hcd (sq_nonneg t) - calc - mgf X ΞΌ t ≀ exp ((c : ℝ) * t ^ 2 / 2) := h.mgf_le t - _ ≀ exp ((d : ℝ) * t ^ 2 / 2) := by - exact exp_le_exp.mpr (by linarith) - /-- A finite independent linear combination of sub-Gaussian variables is sub-Gaussian. -/ lemma hasSubgaussianMGF_finset_sum_const_mul_of_iIndepFun {ΞΉ : Type*} {ΞΌ : Measure Ξ©} {X : ΞΉ β†’ Ξ© β†’ ℝ} (h_indep : iIndepFun X ΞΌ) {c : ΞΉ β†’ ℝβ‰₯0} diff --git a/StatsMLlib/Probability/RandomMatrix/Basic.lean b/StatsMLlib/Probability/RandomMatrix/Basic.lean index 8dbd52e..7d7241b 100644 --- a/StatsMLlib/Probability/RandomMatrix/Basic.lean +++ b/StatsMLlib/Probability/RandomMatrix/Basic.lean @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuanhe Zhang, Jason D. Lee, Fanghui Liu -/ import StatsMLlib.Analysis.NormedSpace.CoveringNumber.Euclidean +import StatsMLlib.LinearAlgebra.Matrix.SingularValue import StatsMLlib.Probability.Concentration.HansonWright import StatsMLlib.Probability.Independence.Grouping import StatsMLlib.Probability.Moments.Exponential @@ -117,24 +118,12 @@ def sampleCovarianceDeviationOperatorNorm {m n : β„•} (A : Matrix (Fin m) (Fin n ℝ := matrixOperatorNorm (sampleCovarianceDeviation A) -omit [MeasurableSpace Ξ©] in -/-- The Euclidean linear map associated to `Aα΅€A` is `A† ∘ A`. -/ -lemma conjTranspose_mul_self_toEuclideanLin {m n : β„•} - (A : Matrix (Fin m) (Fin n) ℝ) : - (A.conjTranspose * A).toEuclideanLin = - LinearMap.adjoint A.toEuclideanLin βˆ˜β‚— A.toEuclideanLin := by - rw [← Matrix.toEuclideanLin_conjTranspose_eq_adjoint A] - simpa [Matrix.toEuclideanLin_eq_toLin_orthonormal] using Matrix.toLin_mul - (v₁ := (EuclideanSpace.basisFun (Fin n) ℝ).toBasis) - (vβ‚‚ := (EuclideanSpace.basisFun (Fin m) ℝ).toBasis) - (v₃ := (EuclideanSpace.basisFun (Fin n) ℝ).toBasis) A.conjTranspose A - omit [MeasurableSpace Ξ©] in lemma inner_conjTranspose_mul_self_toEuclideanLin {m n : β„•} (A : Matrix (Fin m) (Fin n) ℝ) (x : EuclideanSpace ℝ (Fin n)) : inner ℝ ((A.conjTranspose * A).toEuclideanLin x) x = β€–A.toEuclideanLin xβ€– ^ 2 := by - rw [conjTranspose_mul_self_toEuclideanLin] + rw [Matrix.conjTranspose_mul_self_toEuclideanLin] rw [LinearMap.comp_apply] rw [LinearMap.adjoint_inner_left] rw [real_inner_self_eq_norm_sq] @@ -2226,7 +2215,7 @@ lemma upperTriangleQuadraticForm_hasSubgaussianMGF_of_norm_le_one {n : β„•} have h := upperTriangleQuadraticForm_hasSubgaussianMGF_explicit (A := A) (ΞΌ := ΞΌ) (K := K) h_indep hA_subG x - refine HansonWright.hasSubgaussianMGF_mono_param h ?_ + refine hasSubgaussianMGF_mono_param h ?_ change (((βˆ‘ p : UpperTriangleIndex n, Real.toNNReal (upperTriangleQuadraticCoeff x p ^ 2) * Real.toNNReal (K ^ 2)) : ℝβ‰₯0) : ℝ) ≀ (2 * K) ^ 2 @@ -2268,7 +2257,7 @@ lemma inner_randomMatrix_hasSubgaussianMGF {m n : β„•} have h := inner_randomMatrix_hasSubgaussianMGF_explicit (A := A) (ΞΌ := ΞΌ) (K := K) h_indep hA_subG x y - refine HansonWright.hasSubgaussianMGF_mono_param h ?_ + refine hasSubgaussianMGF_mono_param h ?_ change (((βˆ‘ p : Fin m Γ— Fin n, Real.toNNReal ((x p.2 * y p.1) ^ 2) * Real.toNNReal (K ^ 2)) : ℝβ‰₯0) : ℝ) ≀ K ^ 2 * β€–xβ€– ^ 2 * β€–yβ€– ^ 2 @@ -2287,7 +2276,7 @@ lemma inner_randomMatrix_hasSubgaussianMGF_of_norm_le_one {m n : β„•} have h := inner_randomMatrix_hasSubgaussianMGF (A := A) (ΞΌ := ΞΌ) (K := K) h_indep hA_subG x y - refine HansonWright.hasSubgaussianMGF_mono_param h ?_ + refine hasSubgaussianMGF_mono_param h ?_ change K ^ 2 * β€–xβ€– ^ 2 * β€–yβ€– ^ 2 ≀ K ^ 2 have hx2 : β€–xβ€– ^ 2 ≀ 1 := by nlinarith [norm_nonneg x, hx] diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean index ed649fb..e466cec 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/Linear/MinimaxRate.lean @@ -138,7 +138,7 @@ lemma linear_localizedBall_nonempty {Ξ΄ : ℝ} (hΞ΄ : 0 ≀ Ξ΄) ext i; rfl rw [h_eq] have h_zero : empiricalNorm n (fun _ : Fin n => (0 : ℝ)) = 0 := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm simp only [sq, mul_zero, sum_const_zero, mul_zero, Real.sqrt_zero] rw [h_zero] exact hΞ΄ @@ -149,7 +149,7 @@ lemma empiricalNorm_smul_linear {c : ℝ} (hc : 0 ≀ c) : empiricalNorm n (fun i => c * @inner ℝ _ _ ΞΈ (x i)) = c * empiricalNorm n (fun i => @inner ℝ _ _ ΞΈ (x i)) := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm have h_sq : βˆ€ i, (c * @inner ℝ _ _ ΞΈ (x i))^2 = c^2 * (@inner ℝ _ _ ΞΈ (x i))^2 := by intro i; ring simp_rw [h_sq] @@ -267,7 +267,7 @@ lemma linear_bddAbove_at_radius (hn : 0 < n) apply mul_le_mul_of_nonneg_left _ (norm_nonneg w') -- β€–hxβ€– ≀ √n Β· u from empiricalNorm h ≀ u have h_emp : empiricalNorm n (fun i => h (x i)) ≀ u := hh_norm - unfold empiricalNorm at h_emp + unfold EmpiricalProcess.empiricalNorm at h_emp have h_hx_norm : β€–hxβ€– = Real.sqrt (βˆ‘ i, (h (x i))^2) := by simp only [hx, EuclideanSpace.norm_eq] congr 1 diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean b/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean index e2e5e16..9fe1c8f 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/LocalGaussianComplexity.lean @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuanhe Zhang, Jason D. Lee, Fanghui Liu -/ import Mathlib +import StatsMLlib.LearningTheory.EmpiricalProcess.FunctionClass import StatsMLlib.Statistics.Regression.LeastSquares.Defs import StatsMLlib.Statistics.Regression.LeastSquares.SubGaussianity import StatsMLlib.Probability.Process.Dudley @@ -19,7 +20,6 @@ of empirical processes over function classes. ## Main definitions * `evalAtSample`: Evaluation map embedding functions into finite-dimensional space -* `empiricalDist`: Pseudo-metric on functions induced by empirical norm * `innerProductProcess`: The Gaussian process Z_v(w) = (1/n) Ξ£α΅’ wα΅’vα΅’ * `euclideanNorm`: L2 norm on Fin n β†’ ℝ @@ -65,31 +65,6 @@ This is the key embedding into the metric space structure. -/ def evalAtSample (n : β„•) (x : Fin n β†’ X) (g : X β†’ ℝ) : Fin n β†’ ℝ := fun i => g (x i) -/-- The empirical distance between two functions is the empirical norm of their difference -/ -noncomputable def empiricalDist (n : β„•) (x : Fin n β†’ X) (g₁ gβ‚‚ : X β†’ ℝ) : ℝ := - empiricalNorm n (fun i => g₁ (x i) - gβ‚‚ (x i)) - -/-- Empirical distance is non-negative -/ -lemma empiricalDist_nonneg (n : β„•) (x : Fin n β†’ X) (g₁ gβ‚‚ : X β†’ ℝ) : - 0 ≀ empiricalDist n x g₁ gβ‚‚ := - empiricalNorm_nonneg n _ - -/-- Empirical distance is symmetric -/ -lemma empiricalDist_comm (n : β„•) (x : Fin n β†’ X) (g₁ gβ‚‚ : X β†’ ℝ) : - empiricalDist n x g₁ gβ‚‚ = empiricalDist n x gβ‚‚ g₁ := by - unfold empiricalDist empiricalNorm - congr 1 - apply congr_arg - congr 1 - ext i - ring - -/-- Empirical distance from a function to itself is zero -/ -lemma empiricalDist_self (n : β„•) (x : Fin n β†’ X) (g : X β†’ ℝ) : - empiricalDist n x g g = 0 := by - unfold empiricalDist empiricalNorm - simp only [sub_self, sq, mul_zero, sum_const_zero, mul_zero, Real.sqrt_zero] - /-- Norm on EuclideanSpace in terms of sum of squares -/ lemma euclidean_norm_sq (n : β„•) (a : EuclideanSpace ℝ (Fin n)) : β€–aβ€– = Real.sqrt (βˆ‘ i : Fin n, (a i)^2) := by @@ -123,7 +98,7 @@ lemma empiricalNorm_add_le (n : β„•) (a b : Fin n β†’ ℝ) : /-- Triangle inequality: β€–a - bβ€– ≀ β€–aβ€– + β€–bβ€– for empirical norm -/ lemma empiricalNorm_sub_le (n : β„•) (a b : Fin n β†’ ℝ) : empiricalNorm n (fun i => a i - b i) ≀ empiricalNorm n a + empiricalNorm n b := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm by_cases hn : n = 0 Β· simp [hn] have hn_pos : (0 : ℝ) < n := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn) @@ -141,20 +116,6 @@ lemma empiricalNorm_sub_le (n : β„•) (a b : Fin n β†’ ℝ) : rw [ha_norm, hb_norm, hab_norm] exact norm_sub_le a' b' -/-- Empirical distance satisfies triangle inequality -/ -lemma empiricalDist_triangle (n : β„•) (x : Fin n β†’ X) (g₁ gβ‚‚ g₃ : X β†’ ℝ) : - empiricalDist n x g₁ g₃ ≀ empiricalDist n x g₁ gβ‚‚ + empiricalDist n x gβ‚‚ g₃ := by - unfold empiricalDist empiricalNorm - -- Key: (g₁ - g₃) = (g₁ - gβ‚‚) + (gβ‚‚ - g₃), so use Minkowski - have h_sum_eq : βˆ‘ i : Fin n, (g₁ (x i) - g₃ (x i))^2 = - βˆ‘ i : Fin n, ((g₁ (x i) - gβ‚‚ (x i)) + (gβ‚‚ (x i) - g₃ (x i)))^2 := by - apply Finset.sum_congr rfl - intro i _ - congr 1 - ring - rw [h_sum_eq] - exact empiricalNorm_add_le n (fun i => g₁ (x i) - gβ‚‚ (x i)) (fun i => gβ‚‚ (x i) - g₃ (x i)) - /-! ## Localized Ball Diameter Bound -/ /-- The diameter of a localized ball B_n(Ξ΄; H) is at most 2Ξ΄. @@ -163,14 +124,14 @@ For g₁, gβ‚‚ ∈ B_n(Ξ΄), we have: β€–g₁ - gβ‚‚β€–_n ≀ β€–g₁‖_n + β€–gβ‚‚β€–_n ≀ Ξ΄ + Ξ΄ = 2Ξ΄ -/ lemma localizedBall_diam_bound (n : β„•) (H : Set (X β†’ ℝ)) (Ξ΄ : ℝ) (x : Fin n β†’ X) (g₁ gβ‚‚ : X β†’ ℝ) (hg₁ : g₁ ∈ localizedBall H Ξ΄ x) (hgβ‚‚ : gβ‚‚ ∈ localizedBall H Ξ΄ x) : - empiricalDist n x g₁ gβ‚‚ ≀ 2 * Ξ΄ := by + EmpiricalProcess.FunctionClass.empiricalDist x g₁ gβ‚‚ ≀ 2 * Ξ΄ := by -- g₁ ∈ B_n(Ξ΄) means β€–g₁‖_n ≀ Ξ΄ -- gβ‚‚ ∈ B_n(Ξ΄) means β€–gβ‚‚β€–_n ≀ Ξ΄ have hg₁_norm : empiricalNorm n (fun i => g₁ (x i)) ≀ Ξ΄ := hg₁.2 have hgβ‚‚_norm : empiricalNorm n (fun i => gβ‚‚ (x i)) ≀ Ξ΄ := hgβ‚‚.2 -- By triangle inequality: β€–g₁ - gβ‚‚β€–_n ≀ β€–g₁‖_n + β€–gβ‚‚β€–_n ≀ 2Ξ΄ - unfold empiricalDist - calc empiricalNorm n (fun i => g₁ (x i) - gβ‚‚ (x i)) + show EmpiricalProcess.empiricalNorm n (fun i => g₁ (x i) - gβ‚‚ (x i)) ≀ 2 * Ξ΄ + calc EmpiricalProcess.empiricalNorm n (fun i => g₁ (x i) - gβ‚‚ (x i)) ≀ empiricalNorm n (fun i => g₁ (x i)) + empiricalNorm n (fun i => gβ‚‚ (x i)) := empiricalNorm_sub_le n (fun i => g₁ (x i)) (fun i => gβ‚‚ (x i)) _ ≀ Ξ΄ + Ξ΄ := add_le_add hg₁_norm hgβ‚‚_norm @@ -190,9 +151,7 @@ lemma localizedBall_diam (n : β„•) (H : Set (X β†’ ℝ)) (Ξ΄ : ℝ) (hΞ΄ : 0 ≀ -- dist(v₁, vβ‚‚) = empiricalDist n x g₁ gβ‚‚ rw [dist_empiricalMetricImage] -- Use the pointwise bound - have h := localizedBall_diam_bound n H Ξ΄ x g₁ gβ‚‚ hg₁ hgβ‚‚ - unfold empiricalDist at h - exact h + exact localizedBall_diam_bound n H Ξ΄ x g₁ gβ‚‚ hg₁ hgβ‚‚ /-! ## Sub-Gaussian Bridge to EmpiricalSpace -/ @@ -301,7 +260,7 @@ lemma empiricalProcess_smul (n : β„•) (x : Fin n β†’ X) (Ξ± : ℝ) (g : X β†’ /-- Empirical norm scales by absolute value of the scalar -/ lemma empiricalNorm_smul (n : β„•) (Ξ± : ℝ) (f : Fin n β†’ ℝ) : empiricalNorm n (Ξ± β€’ f) = |Ξ±| * empiricalNorm n f := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm simp only [Pi.smul_apply, smul_eq_mul, mul_pow] rw [← Finset.mul_sum] have h_rearrange : (n : ℝ)⁻¹ * (Ξ± ^ 2 * βˆ‘ i, f i ^ 2) = Ξ± ^ 2 * ((n : ℝ)⁻¹ * βˆ‘ i, f i ^ 2) := by @@ -342,7 +301,7 @@ lemma zero_mem_localizedBall_of_starShaped (n : β„•) (H : Set (X β†’ ℝ)) (Ξ΄ : Β· exact hH.1 -- 0 ∈ H from star-shaped property Β· -- β€–0β€–_n = 0 ≀ Ξ΄ simp only [Pi.zero_apply] - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm simp only [sq, mul_zero, sum_const_zero, mul_zero, Real.sqrt_zero] exact hΞ΄ @@ -429,7 +388,7 @@ lemma empiricalProcess_le_delta_norm (n : β„•) (hn : 0 < n) (x : Fin n β†’ X) (H inner_abs_le_norm_mul_norm' n w gx -- 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 empiricalNorm + unfold euclideanNorm EmpiricalProcess.empiricalNorm rw [sq_sqrt, sq_sqrt] Β· ring_nf rw [mul_inv_cancelβ‚€ hn_ne, one_mul] @@ -626,7 +585,7 @@ lemma gaussian_complexity_ratio_antitone (n : β„•) (H : Set (X β†’ ℝ)) (x : Fi (√n * empiricalNorm n (fun i => g (x i))) := by have heq : βˆ€ f : Fin n β†’ ℝ, √(βˆ‘ i : Fin n, f i ^ 2) = √n * empiricalNorm n f := by intro f - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm symm calc √n * √((n : ℝ)⁻¹ * βˆ‘ i : Fin n, f i ^ 2) = √n * (√((n : ℝ)⁻¹) * √(βˆ‘ i : Fin n, f i ^ 2)) := by @@ -830,7 +789,7 @@ lemma EmpiricalSpace.coord_sq_le (n : β„•) (i : Fin n) (v : EmpiricalSpace n) : (v i)^2 ≀ n * (empiricalNorm n v)^2 := by have hn_pos : 0 < n := Fin.pos i have hn_ne : (n : ℝ) β‰  0 := Nat.cast_ne_zero.mpr (ne_of_gt hn_pos) - unfold empiricalNorm + 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) @@ -1047,7 +1006,7 @@ lemma dudley_empiricalProcess (n : β„•) (hn : 0 < n) (x : Fin n β†’ X) 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 h_norm_nonneg : 0 ≀ empiricalNorm n (fun i => g (x i)) := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm positivity have h2 : (empiricalNorm n (fun i => g (x i)))^2 ≀ D^2 := by apply sq_le_sq' diff --git a/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean b/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean index 0cc9298..035144a 100644 --- a/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean +++ b/StatsMLlib/Statistics/Regression/LeastSquares/MasterErrorBound.lean @@ -69,7 +69,7 @@ constant sup_g β€–(Οƒ/n) g(x₁,...,xβ‚™)β€–β‚‚ = Οƒu/√n when restricted to /-- The Euclidean norm of g(x₁,...,xβ‚™) equals √n Β· β€–gβ€–_n. -/ lemma euclidean_norm_eq_sqrt_n_mul_empiricalNorm (hn : 0 < n) (g : X β†’ ℝ) (x : Fin n β†’ X) : Real.sqrt (βˆ‘ i, (g (x i))^2) = Real.sqrt n * empiricalNorm n (fun i => g (x i)) := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm have hn_pos : (0 : ℝ) < n := Nat.cast_pos.mpr hn have hn_ne : (n : ℝ) β‰  0 := ne_of_gt hn_pos -- RHS = √n * √(n⁻¹ * βˆ‘ gΒ²) = √(n * (n⁻¹ * βˆ‘ gΒ²)) = √(βˆ‘ gΒ²) = LHS @@ -441,7 +441,7 @@ lemma Z_le_sigma_mul_localComplexity (n : β„•) (hn : 0 < n) (Οƒ : ℝ) (H : Set Β· exact Real.sum_mul_le_sqrt_mul_sqrt Finset.univ w (fun i => h (x i)) have h_norm : Real.sqrt (βˆ‘ i, (h (x i))^2) ≀ Real.sqrt n * u := by have hh_norm := hh.2 - rw [empiricalNorm] at hh_norm + rw [EmpiricalProcess.empiricalNorm] at hh_norm -- From √((n⁻¹) * βˆ‘ h(x)Β²) ≀ u, we get βˆ‘ h(x)Β² ≀ n * uΒ² have h_sum_nonneg : 0 ≀ βˆ‘ i, (h (x i))^2 := Finset.sum_nonneg (fun i _ => sq_nonneg _) have h_sqrt_nonneg : 0 ≀ Real.sqrt ((n : ℝ)⁻¹ * βˆ‘ i, (h (x i))^2) := Real.sqrt_nonneg _ @@ -688,7 +688,7 @@ theorem bad_event_probability_bound (hn : 0 < n) {Οƒ Ξ΄_star u : ℝ} exact hsmul -- β€–g'β€–_n = u have hg'_norm : empiricalNorm n (fun i => g' (x i)) = u := by - unfold empiricalNorm + unfold EmpiricalProcess.empiricalNorm have h_sum : βˆ‘ k, (g' (x k))^2 = Ξ±^2 * βˆ‘ k, (g (x k))^2 := by simp only [hg'_def, mul_pow] rw [Finset.mul_sum] @@ -741,7 +741,7 @@ theorem bad_event_probability_bound (hn : 0 < n) {Οƒ Ξ΄_star u : ℝ} Β· exact Real.sum_mul_le_sqrt_mul_sqrt Finset.univ w (fun i => h (x i)) have h_norm_eq : Real.sqrt (βˆ‘ i, (h (x i))^2) = Real.sqrt n * u := by have hh_norm := hh.2 - rw [empiricalNorm] at hh_norm + rw [EmpiricalProcess.empiricalNorm] at hh_norm have h_sum : βˆ‘ i, (h (x i))^2 = n * u^2 := by 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