Add lean source and binary files (part 128)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/Probability/SKGap/Entropy/WeightedMomentComparison.lean +78 -0
- lean/OAI/Probability/SKGap/Entropy/WeightedRateAssembly.lean +39 -0
- lean/OAI/Probability/SKGap/Entropy/WeightedScalarMoments.lean +69 -0
- lean/OAI/Probability/SKGap/Entropy/WordUniformCost.lean +106 -0
- lean/OAI/Probability/SKGap/Gaussian/AdaptiveInnovationSquareTails.lean +96 -0
- lean/OAI/Probability/SKGap/Gaussian/ConditionalGramTail.lean +94 -0
- lean/OAI/Probability/SKGap/Gaussian/ConditionalUniformTail.lean +122 -0
- lean/OAI/Probability/SKGap/Gaussian/DiagonalNormTail.lean +47 -0
- lean/OAI/Probability/SKGap/Gaussian/FourierMoment.lean +74 -0
- lean/OAI/Probability/SKGap/Gaussian/GOEGaussian.lean +64 -0
- lean/OAI/Probability/SKGap/Gaussian/GOERowTail.lean +98 -0
- lean/OAI/Probability/SKGap/Gaussian/GOEScalarTail.lean +158 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussMoment.lean +511 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianCompactTailRate.lean +186 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianCoordinateMemLp.lean +109 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianCoordinates.lean +187 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianDisintegration.lean +56 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianFiniteIBPError.lean +43 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianGramMomentsJoined.lean +197 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianLinearDensity.lean +170 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianMarginal.lean +175 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianMatrixChaining.lean +82 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianPDFMoment.lean +172 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianPartition.lean +163 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianProductIntegral.lean +73 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianProductPower.lean +163 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianProductUpperTailLipschitz.lean +103 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianQuadratic.lean +202 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianQuadraticSupComparison.lean +147 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianRankCorrection.lean +429 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianRecipeEvent.lean +121 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianReductionPointwise.lean +73 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianRegression.lean +134 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianSign.lean +79 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianSquareTail.lean +153 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianTailScale.lean +179 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianTiltIdentity.lean +64 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianTiltMass.lean +171 -0
- lean/OAI/Probability/SKGap/Gaussian/GaussianVectorMoments.lean +63 -0
- lean/OAI/Probability/SKGap/Gaussian/IndependentBoundedAverageTailLaw.lean +234 -0
- lean/OAI/Probability/SKGap/Gaussian/LiteralWeakTail.lean +108 -0
- lean/OAI/Probability/SKGap/Gaussian/LocalGaussianMoments.lean +165 -0
- lean/OAI/Probability/SKGap/Gaussian/MatrixNormTail.lean +104 -0
- lean/OAI/Probability/SKGap/Gaussian/MatrixWordMoments.lean +93 -0
- lean/OAI/Probability/SKGap/Gaussian/PartitionSecondMoment.lean +144 -0
- lean/OAI/Probability/SKGap/Gaussian/PhiMoments.lean +138 -0
- lean/OAI/Probability/SKGap/Gaussian/PhiStein.lean +135 -0
- lean/OAI/Probability/SKGap/Gaussian/ProductGaussianDensity.lean +42 -0
- lean/OAI/Probability/SKGap/Gaussian/RegressionMoments.lean +63 -0
- lean/OAI/Probability/SKGap/Gaussian/ReplicaTailWeight.lean +318 -0
lean/OAI/Probability/SKGap/Entropy/WeightedMomentComparison.lean
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Model
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
variable {ι : Type*} [Fintype ι]
|
| 13 |
+
|
| 14 |
+
lemma sum_abs_le_sqrt_card_l2 (d : ι → ℝ) :
|
| 15 |
+
(∑ i, |d i|) ≤ √(Fintype.card ι:ℝ)*√(∑ i,d i^2) := by
|
| 16 |
+
simpa only [one_mul,one_pow,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one,
|
| 17 |
+
sq_abs] using Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun _ : ι => (1:ℝ)) (fun i => |d i|)
|
| 18 |
+
|
| 19 |
+
theorem weighted_moment_comparison (a v y f : ι → ℝ) {H C D R : ℝ}
|
| 20 |
+
(hH : 0 ≤ H) (hC : 0 ≤ C) (hD : 0 ≤ D) (hR : 1 ≤ R)
|
| 21 |
+
(ha : ∀ i, |a i-v i| ≤ D)
|
| 22 |
+
(hsmall : ∀ i, |y i| ≤ R → |f i| ≤ H)
|
| 23 |
+
(hlarge : ∀ i, |f i| ≤ C*(1+y i^2)) :
|
| 24 |
+
|∑ i,(a i-v i)*f i| ≤ H*√(Fintype.card ι:ℝ)*√(∑ i,(a i-v i)^2)+
|
| 25 |
+
2*C*D*∑ i,if R < |y i| then y i^2 else 0 := by
|
| 26 |
+
have hpoint (i : ι) : |(a i-v i)*f i| ≤ H*|a i-v i|+
|
| 27 |
+
2*C*D*(if R < |y i| then y i^2 else 0) := by
|
| 28 |
+
rw [abs_mul]
|
| 29 |
+
by_cases hi : R < |y i|
|
| 30 |
+
· rw [ite_eq_left hi]
|
| 31 |
+
have hy : 1 ≤ y i^2 := by nlinarith [sq_abs (y i)]
|
| 32 |
+
have hf : |f i| ≤ 2*C*y i^2 := (hlarge i).trans (by nlinarith)
|
| 33 |
+
have hh := mul_le_mul (ha i) hf (abs_nonneg _) hD
|
| 34 |
+
nlinarith [mul_nonneg hH (abs_nonneg (a i-v i))]
|
| 35 |
+
· rw [ite_eq_right hi,mul_zero,add_zero]
|
| 36 |
+
simpa only [mul_comm H] using mul_le_mul_of_nonneg_left (hsmall i (le_of_not_gt hi)) (abs_nonneg (a i-v i))
|
| 37 |
+
calc
|
| 38 |
+
_ ≤ ∑ i, |(a i-v i)*f i| := Finset.abs_sum_le_sum_abs _ _
|
| 39 |
+
_ ≤ ∑ i,(H*|a i-v i|+2*C*D*(if R < |y i| then y i^2 else 0)) :=
|
| 40 |
+
Finset.sum_le_sum (fun i _ => hpoint i)
|
| 41 |
+
_ = H*(∑ i,|a i-v i|)+2*C*D*∑ i,if R < |y i| then y i^2 else 0 := by
|
| 42 |
+
rw [Finset.sum_add_distrib,← Finset.mul_sum,← Finset.mul_sum]
|
| 43 |
+
_ ≤ _ := by
|
| 44 |
+
rw [mul_assoc H]
|
| 45 |
+
exact add_le_add (mul_le_mul_of_nonneg_left (sum_abs_le_sqrt_card_l2 _) hH) le_rfl
|
| 46 |
+
|
| 47 |
+
theorem normalized_weighted_moment_comparison {n : ℕ} (hn : 0 < n)
|
| 48 |
+
(a v y f : Fin n → ℝ) {H C D R ε ν : ℝ}
|
| 49 |
+
(hH : 0 ≤ H) (hC : 0 ≤ C) (hD : 0 ≤ D) (hR : 1 ≤ R)
|
| 50 |
+
(hε : 0 ≤ ε) (ha : ∀ i, |a i-v i| ≤ D)
|
| 51 |
+
(hsmall : ∀ i, |y i| ≤ R → |f i| ≤ H)
|
| 52 |
+
(hlarge : ∀ i, |f i| ≤ C*(1+y i^2))
|
| 53 |
+
(hclose : ∑ i,(a i-v i)^2 ≤ ε^2*(n:ℝ))
|
| 54 |
+
(htail : (∑ i,if R < |y i| then y i^2 else 0) ≤ ν*(n:ℝ)) :
|
| 55 |
+
|(∑ i,(a i-v i)*f i)/(n:ℝ)| ≤ H*ε+2*C*D*ν := by
|
| 56 |
+
have hnR : 0 < (n:ℝ) := by exact_mod_cast hn
|
| 57 |
+
have hnorm : √(∑ i,(a i-v i)^2) ≤ ε*√(n:ℝ) := by
|
| 58 |
+
apply Real.sqrt_le_iff.mpr
|
| 59 |
+
constructor
|
| 60 |
+
· positivity
|
| 61 |
+
· nlinarith [Real.sq_sqrt hnR.le]
|
| 62 |
+
have h := weighted_moment_comparison a v y f hH hC hD hR ha hsmall hlarge
|
| 63 |
+
simp only [Fintype.card_fin] at h
|
| 64 |
+
have h' : |∑ i,(a i-v i)*f i| ≤ (H*ε+2*C*D*ν)*(n:ℝ) := by
|
| 65 |
+
calc
|
| 66 |
+
_ ≤ _ := h
|
| 67 |
+
_ ≤ H*√(n:ℝ)*(ε*√(n:ℝ))+2*C*D*(ν*(n:ℝ)) := by
|
| 68 |
+
exact add_le_add (mul_le_mul_of_nonneg_left hnorm (by positivity))
|
| 69 |
+
(mul_le_mul_of_nonneg_left htail (by positivity))
|
| 70 |
+
_ = H*ε*(√(n:ℝ))^2+2*C*D*ν*(n:ℝ) := by ring
|
| 71 |
+
_ = _ := by rw [Real.sq_sqrt hnR.le]; ring
|
| 72 |
+
rw [abs_div,abs_of_pos hnR]
|
| 73 |
+
exact (div_le_iff₀ hnR).mpr h'
|
| 74 |
+
end SKGap
|
| 75 |
+
end
|
| 76 |
+
end
|
| 77 |
+
|
| 78 |
+
end OAI
|
lean/OAI/Probability/SKGap/Entropy/WeightedRateAssembly.lean
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.ScalarEmpirical
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 10 |
+
open scoped ENNReal
|
| 11 |
+
|
| 12 |
+
lemma weighted_four_region_bound {α : Type*} [MeasurableSpace α] (μ : Measure α)
|
| 13 |
+
(f g : α → ℝ≥0∞) (hg : Measurable g) (B F D : Set α)
|
| 14 |
+
(hB : MeasurableSet B) (hF : MeasurableSet F) (hD : MeasurableSet D)
|
| 15 |
+
(hfg : ∀ x, f x ≤ g x) (k : ℝ≥0∞)
|
| 16 |
+
(hgood : ∀ x ∈ B ∩ Fᶜ ∩ Dᶜ, f x ≤ g x*k) :
|
| 17 |
+
(∫⁻ x, f x ∂μ) ≤ (∫⁻ x in Bᶜ,g x ∂μ)+(∫⁻ x in B ∩ F,g x ∂μ)+
|
| 18 |
+
(∫⁻ x in D,g x ∂μ)+(∫⁻ x,g x ∂μ)*k := by
|
| 19 |
+
have bound (E : Set α) : (∫⁻ x in E,f x ∂μ) ≤ (∫⁻ x in E,g x ∂μ) := lintegral_mono hfg
|
| 20 |
+
have sub (E E' : Set α) (h : E ⊆ E') : (∫⁻ x in E,g x ∂μ) ≤ (∫⁻ x in E',g x ∂μ) :=
|
| 21 |
+
lintegral_mono_set h
|
| 22 |
+
have hgood' : (∫⁻ x in B ∩ Fᶜ ∩ Dᶜ,f x ∂μ) ≤ (∫⁻ x,g x ∂μ)*k := by
|
| 23 |
+
calc
|
| 24 |
+
_ ≤ ∫⁻ x in B ∩ Fᶜ ∩ Dᶜ,g x*k ∂μ :=
|
| 25 |
+
lintegral_mono_ae (ae_restrict_of_forall_mem ((hB.inter hF.compl).inter hD.compl) hgood)
|
| 26 |
+
_ = (∫⁻ x in B ∩ Fᶜ ∩ Dᶜ,g x ∂μ)*k := lintegral_mul_const _ hg
|
| 27 |
+
_ ≤ (∫⁻ x,g x ∂μ)*k := mul_le_mul' (lintegral_mono' Measure.restrict_le_self le_rfl) le_rfl
|
| 28 |
+
have h3 := (lintegral_split_le μ f (B ∩ Fᶜ) D).trans
|
| 29 |
+
(add_le_add ((bound _).trans (sub _ _ (fun _ h=>h.2))) hgood')
|
| 30 |
+
have h2 := (lintegral_split_le μ f B F).trans (add_le_add (bound _) h3)
|
| 31 |
+
have h1 := (lintegral_split_le μ f univ B).trans (add_le_add
|
| 32 |
+
(by simpa only [univ_inter] using h2) (by simpa only [univ_inter] using bound Bᶜ))
|
| 33 |
+
simpa only [Measure.restrict_univ,add_comm,add_left_comm,add_assoc] using h1
|
| 34 |
+
|
| 35 |
+
end SKGap
|
| 36 |
+
end
|
| 37 |
+
end
|
| 38 |
+
|
| 39 |
+
end OAI
|
lean/OAI/Probability/SKGap/Entropy/WeightedScalarMoments.lean
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Model
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Real MeasureTheory
|
| 10 |
+
open scoped BigOperators BoundedContinuousFunction
|
| 11 |
+
|
| 12 |
+
lemma scalarVariance_cosh (y : ℝ) : (1-tanh y^2)*cosh y^2=1 := by
|
| 13 |
+
rw [tanh_eq_sinh_div_cosh]
|
| 14 |
+
field_simp
|
| 15 |
+
exact cosh_sq_sub_sinh_sq y
|
| 16 |
+
|
| 17 |
+
lemma square_le_sinh_square (y : ℝ) : y^2 ≤ sinh y^2 := by
|
| 18 |
+
by_cases hy : 0 ≤ y
|
| 19 |
+
· have h := (self_le_sinh_iff).2 hy
|
| 20 |
+
have hs := (sinh_nonneg_iff).2 hy
|
| 21 |
+
nlinarith
|
| 22 |
+
· have h := (sinh_le_self_iff).2 (le_of_not_ge hy)
|
| 23 |
+
have hs := (sinh_nonpos_iff).2 (le_of_not_ge hy)
|
| 24 |
+
nlinarith
|
| 25 |
+
|
| 26 |
+
lemma scalarVariance_weight_bound (y : ℝ) : (1+y^2)*(1-tanh y^2) ≤ 1 := by
|
| 27 |
+
have hv : 0 ≤ 1-tanh y^2 := sub_nonneg.mpr (tanh_sq_lt_one y).le
|
| 28 |
+
have hb : 1+y^2 ≤ cosh y^2 := by linarith [square_le_sinh_square y,cosh_sq_sub_sinh_sq y]
|
| 29 |
+
have h := mul_le_mul_of_nonneg_right hb hv
|
| 30 |
+
rw [mul_comm (cosh y^2),scalarVariance_cosh] at h
|
| 31 |
+
exact h
|
| 32 |
+
|
| 33 |
+
lemma weightedScalarMoment_bound (k l : Fin 3) (y : ℝ) :
|
| 34 |
+
|y^(k:ℕ)*tanh y^(l:ℕ)*(1-tanh y^2)| ≤ 1 := by
|
| 35 |
+
have hv : 0 ≤ 1-tanh y^2 := sub_nonneg.mpr (tanh_sq_lt_one y).le
|
| 36 |
+
have ht : |tanh y|^(l:ℕ) ≤ 1 := pow_le_one₀ (abs_nonneg _) (abs_tanh_lt_one y).le
|
| 37 |
+
have hy : |y|^(k:ℕ) ≤ 1+y^2 := by
|
| 38 |
+
fin_cases k
|
| 39 |
+
· simp only [pow_zero]; nlinarith [sq_nonneg y]
|
| 40 |
+
· simp only [pow_one]
|
| 41 |
+
nlinarith [sq_nonneg (|y|-1),sq_abs y]
|
| 42 |
+
· simp only [pow_two,← sq_abs y]; nlinarith [sq_abs y]
|
| 43 |
+
calc
|
| 44 |
+
_ = (|y|^(k:ℕ)*|tanh y|^(l:ℕ))*(1-tanh y^2) := by
|
| 45 |
+
rw [abs_mul,abs_mul,abs_pow,abs_pow,abs_of_nonneg hv]
|
| 46 |
+
_ ≤ (1+y^2)*(1-tanh y^2) := by
|
| 47 |
+
apply mul_le_mul_of_nonneg_right _ hv
|
| 48 |
+
exact (mul_le_mul_of_nonneg_left ht (by positivity)).trans (by simpa using hy)
|
| 49 |
+
_ ≤ 1 := scalarVariance_weight_bound y
|
| 50 |
+
|
| 51 |
+
def weightedScalarMoment (k l : Fin 3) : ℝ →ᵇ ℝ :=
|
| 52 |
+
BoundedContinuousFunction.ofNormedAddCommGroup
|
| 53 |
+
(fun y => y^(k:ℕ)*tanh y^(l:ℕ)*(1-tanh y^2)) (by
|
| 54 |
+
have ht : Continuous tanh := by
|
| 55 |
+
change Continuous (fun y => tanh y)
|
| 56 |
+
simp_rw [tanh_eq_sinh_div_cosh]
|
| 57 |
+
exact continuous_sinh.div continuous_cosh (fun y => (cosh_pos y).ne')
|
| 58 |
+
fun_prop) (1:ℝ) (fun y => by
|
| 59 |
+
simpa only [Real.norm_eq_abs] using weightedScalarMoment_bound k l y)
|
| 60 |
+
|
| 61 |
+
lemma continuous_weightedScalarMoment_integral (k l : Fin 3) :
|
| 62 |
+
Continuous (fun P : ProbabilityMeasure ℝ => ∫ y, weightedScalarMoment k l y ∂P) :=
|
| 63 |
+
ProbabilityMeasure.continuous_integral_boundedContinuousFunction _
|
| 64 |
+
|
| 65 |
+
end SKGap
|
| 66 |
+
end
|
| 67 |
+
end
|
| 68 |
+
|
| 69 |
+
end OAI
|
lean/OAI/Probability/SKGap/Entropy/WordUniformCost.lean
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Matrix.WordExpectedRecursion
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Matrix Real Set
|
| 10 |
+
open scoped BigOperators SchwartzMap
|
| 11 |
+
|
| 12 |
+
lemma finite_cost_bound (g : ℕ→ℕ→ℕ→ℝ) (L : ℕ) :
|
| 13 |
+
∃ C : ℝ,0≤C ∧ ∀ u≤L,∀ v≤L,∀ q≤L,g u v q≤C := by
|
| 14 |
+
let C := ∑ u∈Finset.range (L+1),∑ v∈Finset.range (L+1),∑ q∈Finset.range (L+1),|g u v q|
|
| 15 |
+
refine ⟨C,by dsimp [C];positivity,?_⟩
|
| 16 |
+
intro u hu v hv q hq
|
| 17 |
+
calc
|
| 18 |
+
g u v q ≤ |g u v q| := le_abs_self _
|
| 19 |
+
_ ≤ ∑ r∈Finset.range (L+1),|g u v r| := Finset.single_le_sum (f := fun r => |g u v r|) (fun _ _=>abs_nonneg _) (Finset.mem_range.mpr (Nat.lt_succ_of_le hq))
|
| 20 |
+
_ ≤ ∑ w∈Finset.range (L+1),∑ r∈Finset.range (L+1),|g u w r| := Finset.single_le_sum (f := fun w => ∑ r∈Finset.range (L+1),|g u w r|) (fun w _=>Finset.sum_nonneg (fun r _=>abs_nonneg (g u w r))) (Finset.mem_range.mpr (Nat.lt_succ_of_le hv))
|
| 21 |
+
_ ≤ C := by
|
| 22 |
+
dsimp only [C]
|
| 23 |
+
exact Finset.single_le_sum (f := fun w => ∑ v∈Finset.range (L+1),∑ r∈Finset.range (L+1),|g w v r|) (fun w _=>Finset.sum_nonneg (fun v _=>Finset.sum_nonneg (fun r _=>abs_nonneg (g w v r)))) (Finset.mem_range.mpr (Nat.lt_succ_of_le hu))
|
| 24 |
+
|
| 25 |
+
lemma continuous_wordMarkedCost (B : NNReal) (j R A c : ℝ) (p q : ℕ) :
|
| 26 |
+
Continuous (fun z=>wordMarkedCost B j R A c z p q) := by
|
| 27 |
+
unfold wordMarkedCost markedRateConstant wordDifferentialBound
|
| 28 |
+
fun_prop
|
| 29 |
+
|
| 30 |
+
lemma wordMarkedCost_uniform (B : NNReal) (j R A c : ℝ) (L : ℕ) :
|
| 31 |
+
∃ C : ℝ,0≤C ∧ ∀ z∈Icc (0:ℝ) 1,∀ p≤L,∀ q≤L,
|
| 32 |
+
wordMarkedCost B j R A c z p q≤C := by
|
| 33 |
+
let H : ℝ→ℝ := fun z=>∑ p∈Finset.range (L+1),∑ q∈Finset.range (L+1),|wordMarkedCost B j R A c z p q|
|
| 34 |
+
have hH : Continuous H := by
|
| 35 |
+
unfold H
|
| 36 |
+
exact continuous_finsetSum _ (fun p _=>continuous_finsetSum _ (fun q _=>(continuous_wordMarkedCost B j R A c p q).abs))
|
| 37 |
+
obtain ⟨C,hC⟩ := isCompact_Icc.exists_bound_of_continuousOn hH.continuousOn
|
| 38 |
+
refine ⟨max 0 C,le_max_left _ _,?_⟩
|
| 39 |
+
intro z hz p hp q hq
|
| 40 |
+
have hb : wordMarkedCost B j R A c z p q≤H z := by
|
| 41 |
+
calc
|
| 42 |
+
_ ≤ |wordMarkedCost B j R A c z p q| := le_abs_self _
|
| 43 |
+
_ ≤ ∑ r∈Finset.range (L+1),|wordMarkedCost B j R A c z p r| :=
|
| 44 |
+
Finset.single_le_sum (f := fun r=>|wordMarkedCost B j R A c z p r|) (fun _ _=>abs_nonneg _) (Finset.mem_range.mpr (Nat.lt_succ_of_le hq))
|
| 45 |
+
_ ≤ H z := by
|
| 46 |
+
dsimp only [H]
|
| 47 |
+
exact Finset.single_le_sum (f := fun w=>∑ r∈Finset.range (L+1),|wordMarkedCost B j R A c z w r|) (fun w _=>Finset.sum_nonneg (fun r _=>abs_nonneg (wordMarkedCost B j R A c z w r)))
|
| 48 |
+
(Finset.mem_range.mpr (Nat.lt_succ_of_le hp))
|
| 49 |
+
have hbH : |H z|≤C := hC z hz
|
| 50 |
+
exact hb.trans ((le_abs_self _).trans (hbH.trans (le_max_right _ _)))
|
| 51 |
+
|
| 52 |
+
variable {ι : Type*}
|
| 53 |
+
lemma wordPartners_length_sides (a : ι→ℝ) (F : List (WordLetter ι)) (c : WordCut ι)
|
| 54 |
+
(hc : c∈wordPartners a F) : c.left.length≤F.length+1 ∧ c.right.length≤F.length+1 := by
|
| 55 |
+
have hh := wordPartners_lengths a F c hc
|
| 56 |
+
cases hi : c.inversePartner
|
| 57 |
+
· simp only [hi,Bool.false_eq_true,ite_false] at hh
|
| 58 |
+
omega
|
| 59 |
+
· have hs := wordPartners_inverse_sides a F c hc hi
|
| 60 |
+
have hL : inverseCount c.left≤c.left.length := List.countP_le_length
|
| 61 |
+
have hR : inverseCount c.right≤c.right.length := List.countP_le_length
|
| 62 |
+
simp only [hi,ite_true] at hh
|
| 63 |
+
omega
|
| 64 |
+
|
| 65 |
+
lemma wordRecursionAtCost_uniform {j B z C : ℝ} (hz : z∈Icc (0:ℝ) 1)
|
| 66 |
+
(hC : 0≤C) (L : ℕ) (hc : ∀ u≤L,∀ v≤L,∀ q≤L,wordLeadingCost j B u v q≤C)
|
| 67 |
+
(a : ι→ℝ) (P Q : List (WordLetter ι)) (hP : P.length+1+Q.length≤L) :
|
| 68 |
+
wordRecursionAtCost j B z a P Q≤(L:ℝ)*C := by
|
| 69 |
+
have hp : P.length≤L := by omega
|
| 70 |
+
have hq : Q.length≤L := by omega
|
| 71 |
+
have hz' (b : Bool) : |if b then z else 1|≤1 := by
|
| 72 |
+
split
|
| 73 |
+
· rw [abs_of_nonneg hz.1];exact hz.2
|
| 74 |
+
· simp
|
| 75 |
+
have hl (c : WordCut ι) (h : c∈wordPartners a P) :
|
| 76 |
+
|if c.inversePartner then z else 1| *wordLeadingCost j B c.left.length c.right.length Q.length≤C := by
|
| 77 |
+
have hb := wordPartners_length_sides a P c h
|
| 78 |
+
have hcost := hc c.left.length (by omega) c.right.length (by omega) Q.length hq
|
| 79 |
+
have hh := mul_le_mul_of_nonneg_left hcost (abs_nonneg (if c.inversePartner then z else 1))
|
| 80 |
+
exact hh.trans ((mul_le_mul_of_nonneg_right (hz' _) hC).trans_eq (one_mul C))
|
| 81 |
+
have hr (c : WordCut ι) (h : c∈wordPartners a Q) :
|
| 82 |
+
|if c.inversePartner then z else 1| *wordLeadingCost j B P.length c.left.length c.right.length≤C := by
|
| 83 |
+
have hb := wordPartners_length_sides a Q c h
|
| 84 |
+
have hcost := hc P.length hp c.left.length (by omega) c.right.length (by omega)
|
| 85 |
+
exact (mul_le_mul_of_nonneg_left hcost (abs_nonneg (if c.inversePartner then z else 1))).trans
|
| 86 |
+
((mul_le_mul_of_nonneg_right (hz' _) hC).trans_eq (one_mul C))
|
| 87 |
+
have hb (X : List (WordCut ι)) (f : WordCut ι→ℝ) (hf : ∀ x∈X,f x≤C) :
|
| 88 |
+
(X.map f).sum≤(X.length:ℝ)*C := by
|
| 89 |
+
induction X with
|
| 90 |
+
| nil => simp
|
| 91 |
+
| cons x X ih =>
|
| 92 |
+
simp only [List.map_cons,List.sum_cons,List.length_cons,Nat.cast_add,Nat.cast_one]
|
| 93 |
+
exact (add_le_add (hf x List.mem_cons_self) (ih (fun x hx=>hf x (List.mem_cons_of_mem _ hx)))).trans_eq (by ring)
|
| 94 |
+
have hsum := add_le_add (hb _ _ hl) (hb _ _ hr)
|
| 95 |
+
have hlen : ((wordPartners a P).length:ℝ)+(wordPartners a Q).length≤L := by
|
| 96 |
+
exact_mod_cast (show (wordPartners a P).length+(wordPartners a Q).length≤L by
|
| 97 |
+
have hh1 := wordPartners_card_bound a P
|
| 98 |
+
have hh2 := wordPartners_card_bound a Q
|
| 99 |
+
omega)
|
| 100 |
+
apply hsum.trans
|
| 101 |
+
nlinarith [mul_nonneg hC (sub_nonneg.mpr hlen)]
|
| 102 |
+
end SKGap
|
| 103 |
+
end
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/AdaptiveInnovationSquareTails.lean
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.SquareTail2
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open MeasureTheory ProbabilityTheory
|
| 14 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 15 |
+
open scoped BigOperators NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory
|
| 17 |
+
open scoped BigOperators NNReal ENNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
open MeasureTheory ProbabilityTheory
|
| 21 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 22 |
+
open scoped BigOperators
|
| 23 |
+
open MeasureTheory ProbabilityTheory
|
| 24 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 25 |
+
open scoped BigOperators
|
| 26 |
+
open scoped BigOperators NNReal ENNReal
|
| 27 |
+
open MeasureTheory Metric Set
|
| 28 |
+
open scoped BigOperators NNReal ENNReal
|
| 29 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 30 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 31 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 32 |
+
open scoped BigOperators Matrix.Norms.L2Operator
|
| 33 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 34 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 35 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 36 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 37 |
+
open scoped BigOperators ENNReal NNReal
|
| 38 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 39 |
+
open scoped BigOperators NNReal ENNReal Matrix
|
| 40 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 41 |
+
open scoped BigOperators ENNReal NNReal
|
| 42 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 43 |
+
open scoped BigOperators NNReal ENNReal
|
| 44 |
+
open scoped BigOperators
|
| 45 |
+
open MeasureTheory ProbabilityTheory
|
| 46 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
|
| 47 |
+
open scoped BigOperators
|
| 48 |
+
open Filter Topology
|
| 49 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 50 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 51 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 52 |
+
open Matrix
|
| 53 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise
|
| 54 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 55 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 56 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 57 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 58 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 59 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 60 |
+
namespace SKGapCutoff.Regression
|
| 61 |
+
|
| 62 |
+
theorem adaptive_innovation_squareTails
|
| 63 |
+
{H : ℕ → Type*} [∀ n, MeasurableSpace (H n)]
|
| 64 |
+
(ρ : ∀ n, Measure (H n)) [∀ n, IsProbabilityMeasure (ρ n)] (r : ℕ)
|
| 65 |
+
(U : ∀ n, H n → Fin n → Fin r → ℝ) (q : ∀ n, H n → Fin n → ℝ)
|
| 66 |
+
(hUm : ∀ n, Measurable (U n)) (hqm : ∀ n, Measurable (q n))
|
| 67 |
+
(hU : ∀ n h a, ∑ i, U n h i a^2 ≤ 1) (hq : ∀ n h, ∑ i, q n h i^2 ≤ 1) :
|
| 68 |
+
ExponentialSquareTails (fun n => (ρ n).prod (standardArrayLaw (Fin n ⊕ Unit)))
|
| 69 |
+
(fun n z i => Real.sqrt n *
|
| 70 |
+
queryInnovation (residualProjection (U n z.1)) (q n z.1) z.2 i) := by
|
| 71 |
+
have hs (n : ℕ) : HasLaw Prod.snd (standardArrayLaw (Fin n ⊕ Unit))
|
| 72 |
+
((ρ n).prod (standardArrayLaw (Fin n ⊕ Unit))) :=
|
| 73 |
+
⟨measurable_snd.aemeasurable, measurePreserving_snd.map_eq⟩
|
| 74 |
+
have ht : ExponentialSquareTails (fun n => (ρ n).prod (standardArrayLaw (Fin n ⊕ Unit)))
|
| 75 |
+
(fun _ z i => z.2 (Sum.inl i)) := by
|
| 76 |
+
refine iid_exponential_squareTails
|
| 77 |
+
(fun n => (ρ n).prod (standardArrayLaw (Fin n ⊕ Unit)))
|
| 78 |
+
(fun _ z i => z.2 (Sum.inl i))
|
| 79 |
+
(fun _ _ => (measurable_pi_apply _).comp measurable_snd) ?_ (gaussianReal 0 1) ?_ ?_
|
| 80 |
+
· intro n
|
| 81 |
+
apply iIndepFun_comp_hasLaw (hs n) (fun i g => g (Sum.inl i))
|
| 82 |
+
(fun _ => (measurable_pi_apply _).aemeasurable)
|
| 83 |
+
exact coordinates_independent.precomp Sum.inl_injective
|
| 84 |
+
· intro n i
|
| 85 |
+
exact (coordinate_hasLaw (Sum.inl i)).fun_comp (hs n)
|
| 86 |
+
· exact gaussian_integrable_exp_quarter_sq
|
| 87 |
+
exact ht.l2_stability (adaptive_innovation_error_exponential ρ r U q hUm hqm hU hq)
|
| 88 |
+
|
| 89 |
+
end SKGapCutoff.Regression
|
| 90 |
+
|
| 91 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 92 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/ConditionalGramTail.lean
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.GramColumnBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Matrix MeasureTheory ProbabilityTheory Real Set
|
| 10 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 11 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 12 |
+
|
| 13 |
+
omit [DecidableEq ι] in
|
| 14 |
+
lemma matrixBilinear_eq_pair (M : Matrix ι ι ℝ) (x y : EuclideanSpace ℝ ι) :
|
| 15 |
+
matrixBilinear M x y=matrixPair M x.ofLp y.ofLp := by
|
| 16 |
+
simp only [matrixBilinear,matrixPair,dotProduct,Matrix.mulVec,Finset.mul_sum]
|
| 17 |
+
congr 1; ext i; congr 1; ext k; ring
|
| 18 |
+
|
| 19 |
+
lemma exactG_transpose (j : ℝ) (a : ι → ℝ) {W : Matrix ι ι ℝ} (hW : Wᵀ=W) :
|
| 20 |
+
(exactG j a W)ᵀ=exactG j a W := by
|
| 21 |
+
simp only [exactG,Matrix.transpose_mul,Matrix.transpose_nonsing_inv,
|
| 22 |
+
Matrix.transpose_sub,Matrix.transpose_one,Matrix.transpose_smul,hW,
|
| 23 |
+
pathDiagonal,Matrix.diagonal_transpose,Matrix.mul_assoc]
|
| 24 |
+
|
| 25 |
+
def augmentedGramTolerance (B ε : ℝ) : ℝ :=
|
| 26 |
+
4*(ε+(sqrt B)⁻¹*(1+B)*ε+B⁻¹*(1+2*B+B^2)*ε)
|
| 27 |
+
|
| 28 |
+
def actualAugmentedGram {n : ℕ} (j : ℝ) (a : Fin n → ℝ)
|
| 29 |
+
(p : Fin 3 → EuclideanSpace ℝ (Fin n)) (u : EuclideanSpace ℝ (Fin n))
|
| 30 |
+
(g : MatrixCoordinates (Fin n) → ℝ) : Matrix ((Fin 3) ⊕ Unit) ((Fin 3) ⊕ Unit) ℝ :=
|
| 31 |
+
let B := j/(n:ℝ)*∑ i,a i
|
| 32 |
+
let W := goeMatrix (j/(n:ℝ)) g
|
| 33 |
+
let V := extendColumns (fun r => (p r).ofLp) (residualGramVector B W u.ofLp)
|
| 34 |
+
Vᵀ*exactG j a W*V
|
| 35 |
+
|
| 36 |
+
def diagonalAugmentedGram {n : ℕ} (a : Fin n → ℝ)
|
| 37 |
+
(p : Fin 3 → EuclideanSpace ℝ (Fin n)) :
|
| 38 |
+
Matrix ((Fin 3) ⊕ Unit) ((Fin 3) ⊕ Unit) ℝ :=
|
| 39 |
+
fromBlocks (fun r s => matrixPair (diagonal a) (p r).ofLp (p s).ofLp) 0 0 1
|
| 40 |
+
|
| 41 |
+
theorem conditional_augmented_gram_tail {j A U ε : ℝ}
|
| 42 |
+
(hj : 0 < j) (hA : 0 < A) (hs : sqrt j*A < 1) (hU : 0 ≤ U) (hε : 0 < ε) :
|
| 43 |
+
∃ (c : ℝ) (N : ℕ), 0 < c ∧ 0 < N ∧
|
| 44 |
+
∀ n, N ≤ n → ∀ a : Fin n → ℝ, (∀ i,0 ≤ a i) → (∀ i,a i ≤ A) →
|
| 45 |
+
0 < j/(n:ℝ)*∑ i,a i →
|
| 46 |
+
∀ (p : Fin 3 → EuclideanSpace ℝ (Fin n)) (u : EuclideanSpace ℝ (Fin n)),
|
| 47 |
+
(∀ r,‖p r‖ ≤ U) → ‖u‖ ≤ U → u.ofLp⬝ᵥu.ofLp=1 →
|
| 48 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
|
| 49 |
+
{g | ¬bilinearPathGood j A a g ∨
|
| 50 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε <
|
| 51 |
+
‖actualAugmentedGram j a p u g-diagonalAugmentedGram a p‖} ≤
|
| 52 |
+
99*Real.exp (-c*(n:ℝ)) := by
|
| 53 |
+
obtain ⟨c,N,hc,hN,ht⟩ := bilinear_deterministic_equivalents hj hA hs hU hε 4
|
| 54 |
+
refine ⟨c,N,hc,hN,?_⟩
|
| 55 |
+
intro n hn a ha haA hB p u hp hu hunit
|
| 56 |
+
let v : Fin 4 → EuclideanSpace ℝ (Fin n) := Fin.cons u p
|
| 57 |
+
have hv : ∀ r,‖v r‖ ≤ U := by
|
| 58 |
+
intro r
|
| 59 |
+
refine Fin.cases hu (fun r => hp r) r
|
| 60 |
+
have hh := ht n hn a ha haA v hv
|
| 61 |
+
apply (measureReal_mono (s₂ := {g | ¬bilinearPathGood j A a g ∨ ∃ r s k,
|
| 62 |
+
ε < |matrixBilinear (bilinearError k j a (goeMatrix (j/(n:ℝ)) g)) (v r) (v s)|})
|
| 63 |
+
?_ (measure_ne_top _ _)).trans (by norm_num only [Nat.cast_ofNat,show (3:ℝ)+6*4^2=99 by norm_num] at hh; exact hh)
|
| 64 |
+
intro g hg
|
| 65 |
+
by_contra hbad
|
| 66 |
+
change ¬(¬bilinearPathGood j A a g ∨ ∃ r s k,
|
| 67 |
+
ε < |matrixBilinear (bilinearError k j a (goeMatrix (j/(n:ℝ)) g)) (v r) (v s)|) at hbad
|
| 68 |
+
push Not at hbad
|
| 69 |
+
rcases hbad with ⟨hpath,hpair⟩
|
| 70 |
+
have he (r s : Fin 4) (k : Fin 3) :
|
| 71 |
+
|matrixPair (bilinearError k j a (goeMatrix (j/(n:ℝ)) g)) (v r).ofLp (v s).ofLp| ≤ ε := by
|
| 72 |
+
rw [← matrixBilinear_eq_pair]
|
| 73 |
+
exact hpair r s k
|
| 74 |
+
have h00 (r s : Fin 3) := he r.succ s.succ 0
|
| 75 |
+
have h0u (r : Fin 3) := he r.succ 0 0
|
| 76 |
+
have h1u (r : Fin 3) := he r.succ 0 1
|
| 77 |
+
have h0 := he 0 0 0
|
| 78 |
+
have h1 := he 0 0 1
|
| 79 |
+
have h2 := he 0 0 2
|
| 80 |
+
simp only [v,Fin.cons_succ,Fin.cons_zero,bilinearError,ite_true,ite_false,
|
| 81 |
+
Fin.reduceEq,Fintype.card_fin] at h00 h0u h1u h0 h1 h2
|
| 82 |
+
have hb := augmented_gram_error (exactG_transpose j a (goeMatrix_transpose _ g))
|
| 83 |
+
(goeMatrix_transpose _ g) (diagonal a) hB hε.le (fun r => (p r).ofLp) u.ofLp hunit
|
| 84 |
+
h00 h0u h1u h0 h1 h2
|
| 85 |
+
have hb' : ‖actualAugmentedGram j a p u g-diagonalAugmentedGram a p‖ ≤
|
| 86 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε := by
|
| 87 |
+
simpa only [actualAugmentedGram,diagonalAugmentedGram,augmentedGramTolerance,
|
| 88 |
+
Fintype.card_fin,Nat.cast_ofNat,show (3:ℝ)+1=4 by norm_num] using hb
|
| 89 |
+
exact hg.elim (fun hn => hn hpath) (fun he => not_lt_of_ge hb' he)
|
| 90 |
+
end SKGap
|
| 91 |
+
end
|
| 92 |
+
end
|
| 93 |
+
|
| 94 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/ConditionalUniformTail.lean
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GOEScalarTail
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Matrix MeasureTheory ProbabilityTheory Real Set
|
| 10 |
+
open scoped BigOperators MatrixOrder Matrix.Norms.Frobenius
|
| 11 |
+
|
| 12 |
+
theorem compact_conditional_uniform_tail {α : Type*} [TopologicalSpace α] [CompactSpace α]
|
| 13 |
+
{j A : ℝ} (hj : 0 < j) (hj1 : j < 1) (hA : 0 < A)
|
| 14 |
+
(hsub : sqrt j*A < 1)
|
| 15 |
+
(b e s q κ : α → ℝ) (hb : Continuous b) (he : Continuous e)
|
| 16 |
+
(hs : Continuous s) (hq : Continuous q) (hk : Continuous κ)
|
| 17 |
+
(hb0 : ∀ x,0 < b x) (hb1 : ∀ x,b x ≤ 1) (he0 : ∀ x,0 ≤ e x)
|
| 18 |
+
(hs0 : ∀ x,0 < s x) (hq0 : ∀ x,0 < q x)
|
| 19 |
+
(hkq : ∀ x,κ x^2=1-j*q x/s x) :
|
| 20 |
+
∃ δ ρ : ℝ, 0 < δ ∧ δ < 1 ∧ 0 < ρ ∧
|
| 21 |
+
∀ U : ℝ, 0 ≤ U → ∀ ε τ : ℝ, 0 < ε → 0 < τ → ∃ c : ℝ, ∃ N : ℕ, 0 < c ∧ 0 < N ∧
|
| 22 |
+
∀ n, N ≤ n → ∀ a : Fin n → ℝ, (∀ i,0 ≤ a i) → (∀ i,a i ≤ A) →
|
| 23 |
+
0 < j/(n:ℝ)*∑ i,a i →
|
| 24 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε < ρ/2 →
|
| 25 |
+
∀ p : Fin 3 → EuclideanSpace ℝ (Fin n), ∀ u : EuclideanSpace ℝ (Fin n),
|
| 26 |
+
(∀ r,‖p r‖ ≤ U) → ‖u‖ ≤ U → u.ofLp⬝ᵥu.ofLp=1 →
|
| 27 |
+
∀ x (C E : Matrix ((Fin 3) ⊕ Unit) ((Fin 3) ⊕ Unit) ℝ),
|
| 28 |
+
C.IsHermitian → E.IsHermitian → τ*‖E‖ < ρ/2 →
|
| 29 |
+
‖diagonalAugmentedGram a p-augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x))‖ < ρ/2 →
|
| 30 |
+
‖C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 31 |
+
j ((κ x-1)*√(j*b x)/√(q x))‖ < ρ/2 →
|
| 32 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
|
| 33 |
+
{g | ¬(conditionalBase j a g-
|
| 34 |
+
pathDiagonal a 1*conditionalUpdateColumns j a p u g*
|
| 35 |
+
(C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)*
|
| 36 |
+
(conditionalUpdateColumns j a p u g)ᵀ*pathDiagonal a 1-
|
| 37 |
+
(δ*((1-sqrt j*A)^2/4)) • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef} ≤
|
| 38 |
+
101*exp (-c*(n:ℝ)) := by
|
| 39 |
+
obtain ⟨δ,ρ,hδ,hδ1,hρ,hcrit⟩ := compact_conditional_rank_criterion hj hj1 b e s q κ
|
| 40 |
+
hb he hs hq hk hb0 hb1 he0 hs0 hq0 hkq
|
| 41 |
+
refine ⟨δ,ρ,hδ,hδ1,hρ,?_⟩
|
| 42 |
+
intro U hU ε τ hε hτ
|
| 43 |
+
obtain ⟨c₀,N,hc₀,hN,hgram⟩ := conditional_augmented_gram_tail hj hA hsub hU hε
|
| 44 |
+
let c₁ := τ^2/(π^2*(2*(U+1)^2)^2*j)
|
| 45 |
+
have hc₁ : 0 < c₁ := by dsimp [c₁]; positivity
|
| 46 |
+
refine ⟨min c₀ c₁,N,lt_min hc₀ hc₁,hN,?_⟩
|
| 47 |
+
intro n hn a ha haA hB heps p u hp hu hunit x C E hC hE hEbound hdiag hcoef
|
| 48 |
+
let μ := Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)
|
| 49 |
+
let badG := {g | ¬bilinearPathGood j A a g ∨
|
| 50 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε <
|
| 51 |
+
‖actualAugmentedGram j a p u g-diagonalAugmentedGram a p‖}
|
| 52 |
+
let badS := {g | τ ≤ |matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u|}
|
| 53 |
+
have hnpos := hN.trans_le hn
|
| 54 |
+
have hgprob : μ.real badG ≤ 99*exp (-c₀*(n:ℝ)) := hgram n hn a ha haA hB p u hp hu hunit
|
| 55 |
+
have hsprob : μ.real badS ≤ 2*exp (-c₁*(n:ℝ)) := by
|
| 56 |
+
have hh := goe_scalar_tail hnpos hj hU hτ.le u hu
|
| 57 |
+
convert hh using 1
|
| 58 |
+
congr 2
|
| 59 |
+
dsimp [c₁]
|
| 60 |
+
ring
|
| 61 |
+
have hsubsets : {g | ¬(conditionalBase j a g-
|
| 62 |
+
pathDiagonal a 1*conditionalUpdateColumns j a p u g*
|
| 63 |
+
(C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)*
|
| 64 |
+
(conditionalUpdateColumns j a p u g)ᵀ*pathDiagonal a 1-
|
| 65 |
+
(δ*((1-sqrt j*A)^2/4)) • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef} ⊆ badG ∪ badS := by
|
| 66 |
+
intro g hg
|
| 67 |
+
by_contra hbad
|
| 68 |
+
have hgG : g ∉ badG := fun hh => hbad (Or.inl hh)
|
| 69 |
+
have hgS : g ∉ badS := fun hh => hbad (Or.inr hh)
|
| 70 |
+
simp only [badG,mem_ofPred_eq,not_or,not_lt] at hgG
|
| 71 |
+
have hgS' : |matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u| < τ := lt_of_not_ge hgS
|
| 72 |
+
let D := pathDiagonal a 1
|
| 73 |
+
let S := conditionalBase j a g
|
| 74 |
+
let V := conditionalUpdateColumns j a p u g
|
| 75 |
+
let Cg := C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E
|
| 76 |
+
let lo := (1-sqrt j*A)^2/4
|
| 77 |
+
have hmargin : (S-lo • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef :=
|
| 78 |
+
bilinearPathGood_margin a g (not_not.mp hgG.1)
|
| 79 |
+
have hlo : 0 ≤ lo := by dsimp [lo]; positivity
|
| 80 |
+
have hSpos : S.PosDef := by
|
| 81 |
+
have hh := hmargin.add_posSemidef ((Matrix.PosSemidef.one : (1 : Matrix (Fin n) (Fin n) ℝ).PosSemidef).smul hlo)
|
| 82 |
+
convert hh using 1; abel
|
| 83 |
+
have hD : D.IsHermitian := isHermitian_diagonal_iff.mpr
|
| 84 |
+
(fun i => isSelfAdjoint_iff.mpr (star_trivial _))
|
| 85 |
+
have hCg : Cg.IsHermitian := hC.add (hE.smul (R := ℝ)
|
| 86 |
+
(isSelfAdjoint_iff.mpr (star_trivial _)))
|
| 87 |
+
have hG : ‖Vᵀ*D*S⁻¹*D*V-augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x))‖ < ρ := by
|
| 88 |
+
have hh := norm_sub_le_norm_sub_add_norm_sub (actualAugmentedGram j a p u g) (diagonalAugmentedGram a p)
|
| 89 |
+
(augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x)))
|
| 90 |
+
have heq : Vᵀ*D*S⁻¹*D*V=actualAugmentedGram j a p u g := by
|
| 91 |
+
simp only [V,D,S,conditionalUpdateColumns,conditionalBase,actualAugmentedGram,
|
| 92 |
+
exactG,Fintype.card_fin,Matrix.mul_assoc]
|
| 93 |
+
rw [heq]
|
| 94 |
+
exact hh.trans_lt (by linarith [hgG.2])
|
| 95 |
+
have hCgclose : ‖Cg-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 96 |
+
j ((κ x-1)*√(j*b x)/√(q x))‖ < ρ := by
|
| 97 |
+
have hn : ‖matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E‖ ≤ τ*‖E‖ := by
|
| 98 |
+
rw [norm_smul,Real.norm_eq_abs]
|
| 99 |
+
exact mul_le_mul_of_nonneg_right hgS'.le (norm_nonneg _)
|
| 100 |
+
have hh := norm_add_le (C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 101 |
+
j ((κ x-1)*√(j*b x)/√(q x))) (matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)
|
| 102 |
+
have heq : Cg-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 103 |
+
j ((κ x-1)*√(j*b x)/√(q x))=
|
| 104 |
+
(C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 105 |
+
j ((κ x-1)*√(j*b x)/√(q x)))+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E := by
|
| 106 |
+
dsimp [Cg]; abel
|
| 107 |
+
rw [heq]
|
| 108 |
+
exact hh.trans_lt (by linarith)
|
| 109 |
+
exact hg (hcrit x (Fin n) S D V Cg lo hSpos hD hCg hmargin.posSemidef hG hCgclose)
|
| 110 |
+
apply (measureReal_mono hsubsets (measure_ne_top _ _)).trans
|
| 111 |
+
apply (measureReal_union_le badG badS).trans
|
| 112 |
+
apply (add_le_add hgprob hsprob).trans
|
| 113 |
+
have he₀ : exp (-c₀*(n:ℝ)) ≤ exp (-min c₀ c₁*(n:ℝ)) := by
|
| 114 |
+
apply exp_le_exp.mpr; simpa only [neg_mul] using neg_le_neg (mul_le_mul_of_nonneg_right (min_le_left c₀ c₁) (Nat.cast_nonneg n : (0:ℝ) ≤ n))
|
| 115 |
+
have he₁ : exp (-c₁*(n:ℝ)) ≤ exp (-min c₀ c₁*(n:ℝ)) := by
|
| 116 |
+
apply exp_le_exp.mpr; simpa only [neg_mul] using neg_le_neg (mul_le_mul_of_nonneg_right (min_le_right c₀ c₁) (Nat.cast_nonneg n : (0:ℝ) ≤ n))
|
| 117 |
+
nlinarith
|
| 118 |
+
end SKGap
|
| 119 |
+
end
|
| 120 |
+
end
|
| 121 |
+
|
| 122 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/DiagonalNormTail.lean
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Matrix.GOEDiagonalSquare
|
| 3 |
+
import OAI.Probability.SKGap.Matrix.GOESubmatrix
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Matrix Real Set MeasureTheory ProbabilityTheory
|
| 11 |
+
open RealComplex
|
| 12 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 13 |
+
|
| 14 |
+
theorem zeroDiagGOE_norm_tail {j : ℝ} (hj : 0<j) {n : ℕ} (hn : 0<n) :
|
| 15 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n)=>gaussianReal 0 1))
|
| 16 |
+
{g | 2*sqrt j+1+1<opNorm (removeDiagonal (goeMatrix (j/n) g))} ≤
|
| 17 |
+
ENNReal.ofReal (2*exp (-(n:ℝ)/(π^2*j)))+
|
| 18 |
+
ENNReal.ofReal (2*(n:ℝ)*exp (-1/(8*(j/n)))) := by
|
| 19 |
+
let : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hn
|
| 20 |
+
let μ := gaussianCoordinates (MatrixCoordinates (Fin n))
|
| 21 |
+
have hr : 0<j/(n:ℝ) := div_pos hj (Nat.cast_pos.mpr hn)
|
| 22 |
+
let E := {g : MatrixCoordinates (Fin n)→ℝ | 2*sqrt j+1<opNorm (goeMatrix (j/n) g)}
|
| 23 |
+
let V := {g : MatrixCoordinates (Fin n)→ℝ | ∃ i,1 < |goeMatrix (j/n) g i i|}
|
| 24 |
+
have hs : {g | 2*sqrt j+1+1<opNorm (removeDiagonal (goeMatrix (j/n) g))}⊆E∪V := by
|
| 25 |
+
intro g hg
|
| 26 |
+
by_contra hh
|
| 27 |
+
have hh' : ¬2*sqrt j+1<opNorm (goeMatrix (j/n) g) ∧ ¬∃ i,1 < |goeMatrix (j/n) g i i| := by
|
| 28 |
+
simpa only [Set.mem_union,E,V,Set.mem_ofPred_eq,not_or] using hh
|
| 29 |
+
have hd : opNorm (Matrix.diagonal (fun i=>goeMatrix (j/n) g i i))≤1 :=
|
| 30 |
+
opNorm_diagonal_le zero_le_one (fun i=>le_of_not_gt (fun hi=>hh'.2 ⟨i,hi⟩))
|
| 31 |
+
have hsub := opNorm_sub (goeMatrix (j/n) g) (Matrix.diagonal (fun i=>goeMatrix (j/n) g i i))
|
| 32 |
+
exact (not_lt_of_ge (hsub.trans (add_le_add (le_of_not_gt hh'.1) hd))) hg
|
| 33 |
+
have he : μ E≤ENNReal.ofReal (2*exp (-(n:ℝ)/(π^2*j))) := by
|
| 34 |
+
rw [←ofReal_measureReal]
|
| 35 |
+
apply ENNReal.ofReal_le_ofReal
|
| 36 |
+
have ht := goe_norm_tail (ι:=Fin n) hj (show (0:ℝ)≤1 by norm_num)
|
| 37 |
+
simpa only [one_pow,neg_mul,one_mul,Fintype.card_fin,matrixOperator,μ,E,opNorm] using ht
|
| 38 |
+
have hv : μ V≤ENNReal.ofReal (2*(n:ℝ)*exp (-1/(8*(j/n)))) := by
|
| 39 |
+
rw [←ofReal_measureReal]
|
| 40 |
+
apply ENNReal.ofReal_le_ofReal
|
| 41 |
+
simpa only [one_pow,Fintype.card_fin] using goe_diagonal_tail (ι:=Fin n) hr (show (0:ℝ)≤1 by norm_num)
|
| 42 |
+
exact ((measure_mono hs).trans (measure_union_le E V)).trans (add_le_add he hv)
|
| 43 |
+
end SKGap
|
| 44 |
+
end
|
| 45 |
+
end
|
| 46 |
+
|
| 47 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/FourierMoment.lean
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.EntryLM
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
|
| 8 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 9 |
+
open scoped NNReal ENNReal
|
| 10 |
+
open Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
open Matrix Real
|
| 13 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 14 |
+
open Matrix Real
|
| 15 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 17 |
+
open MeasureTheory.Measure
|
| 18 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 19 |
+
open MeasureTheory
|
| 20 |
+
open MeasureTheory Set NormedSpace
|
| 21 |
+
open scoped Topology
|
| 22 |
+
open Matrix Real
|
| 23 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 24 |
+
namespace SKGap.ComplexMatrix
|
| 25 |
+
open MeasureTheory NormedSpace
|
| 26 |
+
open scoped FourierTransform SchwartzMap
|
| 27 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 28 |
+
|
| 29 |
+
noncomputable def fourierMoment (f : 𝓢(ℝ,ℂ)) (k : ℕ) : ℝ :=
|
| 30 |
+
∫ t : ℝ, ‖(𝓕 f) t‖*|t|^k
|
| 31 |
+
|
| 32 |
+
lemma fourierMoment_nonneg (f : 𝓢(ℝ,ℂ)) (k : ℕ) : 0 ≤ fourierMoment f k := by
|
| 33 |
+
apply integral_nonneg
|
| 34 |
+
intro t
|
| 35 |
+
positivity
|
| 36 |
+
|
| 37 |
+
lemma fourierMoment_integrable (f : 𝓢(ℝ,ℂ)) (k : ℕ) :
|
| 38 |
+
Integrable (fun t : ℝ => ‖(𝓕 f) t‖*|t|^k) := by
|
| 39 |
+
simpa only [Real.norm_eq_abs,mul_comm] using (𝓕 f).integrable_pow_mul volume k
|
| 40 |
+
|
| 41 |
+
lemma opNorm_rsmul (r : ℝ) (M : Matrix ι ι ℂ) : opNorm (r • M) = |r| * opNorm M := by
|
| 42 |
+
change opNorm ((r:ℂ) • M) = _
|
| 43 |
+
rw [opNorm_csmul,Complex.norm_real,Real.norm_eq_abs]
|
| 44 |
+
|
| 45 |
+
lemma schwartzMatrix_lipschitz (f : 𝓢(ℝ,ℂ)) (M N : Matrix ι ι ℂ)
|
| 46 |
+
(hM : Mᴴ = M) (hN : Nᴴ = N) :
|
| 47 |
+
‖schwartzMatrix f M-schwartzMatrix f N‖ ≤
|
| 48 |
+
(2*Real.pi*fourierMoment f 1)*‖M-N‖ := by
|
| 49 |
+
have hf₁ : Integrable (fun t : ℝ => ‖(𝓕 f) t‖*|t|) := by
|
| 50 |
+
simpa only [pow_one] using fourierMoment_integrable f 1
|
| 51 |
+
have hh := kernelMatrix_lipschitz (𝓕 f).integrable hf₁
|
| 52 |
+
((2*Real.pi:ℝ) • M) ((2*Real.pi:ℝ) • N) (by simp [hM]) (by simp [hN])
|
| 53 |
+
rw [← smul_sub,norm_smul,Real.norm_eq_abs,abs_of_pos (by positivity : 0 < (2*Real.pi:ℝ))] at hh
|
| 54 |
+
exact hh.trans_eq (by simp only [fourierMoment,pow_one]; ring)
|
| 55 |
+
|
| 56 |
+
lemma schwartzMatrix_four_point (f : 𝓢(ℝ,ℂ)) (a b c d : Matrix ι ι ℂ)
|
| 57 |
+
(ha : aᴴ = a) (hb : bᴴ = b) (hc : cᴴ = c) (hd : dᴴ = d) :
|
| 58 |
+
‖(schwartzMatrix f a-schwartzMatrix f b)-(schwartzMatrix f c-schwartzMatrix f d)‖ ≤
|
| 59 |
+
(2*Real.pi*fourierMoment f 1)*‖(a-b)-(c-d)‖ +
|
| 60 |
+
((2*Real.pi)^2*fourierMoment f 2)*(opNorm (a-c)+opNorm (b-d))*‖c-d‖ := by
|
| 61 |
+
have hf₁ : Integrable (fun t : ℝ => ‖(𝓕 f) t‖*|t|) := by
|
| 62 |
+
simpa only [pow_one] using fourierMoment_integrable f 1
|
| 63 |
+
have hh := kernelMatrix_four_point (𝓕 f).integrable hf₁ (fourierMoment_integrable f 2)
|
| 64 |
+
((2*Real.pi:ℝ) • a) ((2*Real.pi:ℝ) • b) ((2*Real.pi:ℝ) • c) ((2*Real.pi:ℝ) • d)
|
| 65 |
+
(by simp [ha]) (by simp [hb]) (by simp [hc]) (by simp [hd])
|
| 66 |
+
simp only [← smul_sub,norm_smul,opNorm_rsmul,Real.norm_eq_abs,
|
| 67 |
+
abs_of_pos (by positivity : 0 < (2*Real.pi:ℝ))] at hh
|
| 68 |
+
exact hh.trans_eq (by simp only [fourierMoment,pow_one]; ring)
|
| 69 |
+
|
| 70 |
+
end SKGap.ComplexMatrix
|
| 71 |
+
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GOEGaussian.lean
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Matrix.MatrixCoordinates
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 11 |
+
open scoped BigOperators ENNReal
|
| 12 |
+
|
| 13 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 14 |
+
|
| 15 |
+
def goeEntryCoeff (r : ℝ) : Matrix (ι × ι) (MatrixCoordinates ι) ℝ :=
|
| 16 |
+
fun p a => sqrt (2*r)/2 * ((if a=Sum.inl p then 1 else 0)+
|
| 17 |
+
(if a=Sum.inl (p.2,p.1) then 1 else 0))
|
| 18 |
+
|
| 19 |
+
lemma goeEntryCoeff_sample (r : ℝ) (g : MatrixCoordinates ι → ℝ) (i k : ι) :
|
| 20 |
+
(goeEntryCoeff r*ᵥg) (i,k) = goeMatrix r g i k := by
|
| 21 |
+
simp only [mulVec,dotProduct,goeEntryCoeff,mul_assoc,add_mul]
|
| 22 |
+
rw [← Finset.mul_sum,Finset.sum_add_distrib]
|
| 23 |
+
simp [goeMatrix]
|
| 24 |
+
|
| 25 |
+
lemma goe_matrix_gaussian (r : ℝ) :
|
| 26 |
+
HasGaussianLaw (fun (g : MatrixCoordinates ι → ℝ) (p : ι × ι) => goeMatrix r g p.1 p.2) (gaussianCoordinates (MatrixCoordinates ι)) := by
|
| 27 |
+
have hh := matrix_sample_gaussian (goeEntryCoeff (ι := ι) r)
|
| 28 |
+
simpa only [show (fun g => goeEntryCoeff (ι := ι) r*ᵥg) =
|
| 29 |
+
(fun g p => goeMatrix r g p.1 p.2) from funext (fun g => funext (fun p => goeEntryCoeff_sample r g p.1 p.2))] using hh
|
| 30 |
+
|
| 31 |
+
lemma goe_mean_zero (r : ℝ) (i k : ι) :
|
| 32 |
+
(∫ g, goeMatrix r g i k ∂gaussianCoordinates (MatrixCoordinates ι))=0 := by
|
| 33 |
+
simpa only [← goeEntryCoeff_sample,mulVec,dotProduct] using linear_gaussian_mean (goeEntryCoeff (ι := ι) r (i,k))
|
| 34 |
+
|
| 35 |
+
lemma goe_entry_cov {r : ℝ} (hr : 0 ≤ r) (i k l m : ι) :
|
| 36 |
+
cov[fun g => goeMatrix r g i k,fun g => goeMatrix r g l m;
|
| 37 |
+
gaussianCoordinates (MatrixCoordinates ι)] =
|
| 38 |
+
r*((if i=l then 1 else 0)*(if k=m then 1 else 0)+
|
| 39 |
+
(if i=m then 1 else 0)*(if k=l then 1 else 0)) := by
|
| 40 |
+
let μ := gaussianCoordinates (MatrixCoordinates ι)
|
| 41 |
+
have hm (a : MatrixCoordinates ι) := (coordinate_hasLaw a).hasGaussianLaw.memLp_two
|
| 42 |
+
change cov[fun g : MatrixCoordinates ι → ℝ => sqrt (2*r)/2*(g (.inl (i,k))+g (.inl (k,i))),
|
| 43 |
+
fun g => sqrt (2*r)/2*(g (.inl (l,m))+g (.inl (m,l))); μ]=_
|
| 44 |
+
rw [covariance_const_mul_left,covariance_const_mul_right]
|
| 45 |
+
change sqrt (2*r)/2*(sqrt (2*r)/2*cov[(fun g => g (.inl (i,k))) + (fun g => g (.inl (k,i))),
|
| 46 |
+
(fun g => g (.inl (l,m))) + (fun g => g (.inl (m,l)));gaussianCoordinates (MatrixCoordinates ι)]) = _
|
| 47 |
+
rw [covariance_add_left (hm _) (hm _) ((hm _).add (hm _)),
|
| 48 |
+
covariance_add_right (hm _) (hm _) (hm _),
|
| 49 |
+
covariance_add_right (hm _) (hm _) (hm _)]
|
| 50 |
+
simp only [coordinate_covariance,Sum.inl.injEq,Prod.mk.injEq]
|
| 51 |
+
have hs : (sqrt (2*r)/2)^2=r/2 := by rw [div_pow,sq_sqrt (by positivity)]; ring
|
| 52 |
+
have hs' : sqrt (2*r)/2*(sqrt (2*r)/2)=r/2 := by nlinarith only [hs]
|
| 53 |
+
rw [← mul_assoc,hs']
|
| 54 |
+
have hind (p q : Prop) [Decidable p] [Decidable q] :
|
| 55 |
+
(if p ∧ q then (1:ℝ) else 0)=(if p then 1 else 0)*(if q then 1 else 0) := by
|
| 56 |
+
split_ifs <;> simp_all
|
| 57 |
+
simp_rw [hind]
|
| 58 |
+
ring
|
| 59 |
+
|
| 60 |
+
end SKGap
|
| 61 |
+
end
|
| 62 |
+
end
|
| 63 |
+
|
| 64 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GOERowTail.lean
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Entropy.SparseSubsetEntropy
|
| 3 |
+
import OAI.Probability.SKGap.Matrix.TanhMatrixBounds
|
| 4 |
+
import OAI.Probability.SKGap.Matrix.GOERowLaw
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace SKGap
|
| 11 |
+
open MeasureTheory ProbabilityTheory Matrix Real Set
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
variable {n : ℕ}
|
| 14 |
+
|
| 15 |
+
lemma coupling_goe_offdiag (r : ℝ) (g : MatrixCoordinates (Fin n)→ℝ) (i k : Fin n)
|
| 16 |
+
(hik : i≠k) : coupling (goeDisorder r g) i k=goeMatrix r g i k := by
|
| 17 |
+
have h := congrFun (congrFun (coupling_goeDisorder r g) i) k
|
| 18 |
+
simpa only [of_apply,Matrix.sub_apply,diagonal_apply_ne _ hik,sub_zero] using h
|
| 19 |
+
|
| 20 |
+
lemma coupling_goe_row_square_sum (r : ℝ) (g : MatrixCoordinates (Fin n)→ℝ)
|
| 21 |
+
(i : Fin n) (S : Finset (Fin n)) :
|
| 22 |
+
(∑ k∈S,coupling (goeDisorder r g) i k^2)=∑ k : S.erase i,goeMatrix r g i k^2 := by
|
| 23 |
+
rw [Finset.sum_coe_sort (S.erase i) (fun k : Fin n=>goeMatrix r g i k^2)]
|
| 24 |
+
calc
|
| 25 |
+
_ = ∑ k∈S.erase i,coupling (goeDisorder r g) i k^2 :=
|
| 26 |
+
by
|
| 27 |
+
by_cases hi : i∈S
|
| 28 |
+
· rw [Finset.sum_erase_eq_sub hi]
|
| 29 |
+
simp [coupling]
|
| 30 |
+
· rw [Finset.erase_eq_self.mpr hi]
|
| 31 |
+
_ = _ := Finset.sum_congr rfl (fun k hk=>by rw [coupling_goe_offdiag r g i k (Ne.symm (Finset.ne_of_mem_erase hk))])
|
| 32 |
+
|
| 33 |
+
lemma coupling_goe_row_tail {r : ℝ} (hr : 0 < r) (i : Fin n) (S : Finset (Fin n)) (t : ℝ) :
|
| 34 |
+
(gaussianCoordinates (MatrixCoordinates (Fin n))).real
|
| 35 |
+
{g | t < ∑ k∈S,coupling (goeDisorder r g) i k^2} ≤
|
| 36 |
+
exp (-t/(4*r)+(S.card:ℝ)*log 2) := by
|
| 37 |
+
let e : S.erase i ↪ Fin n := ⟨Subtype.val,Subtype.val_injective⟩
|
| 38 |
+
have havoid (k : S.erase i) : e k≠i := Finset.ne_of_mem_erase k.2
|
| 39 |
+
have hm : MeasurableSet {v : S.erase i→ℝ | t < ∑ k,v k^2} := by measurability
|
| 40 |
+
simp_rw [coupling_goe_row_square_sum]
|
| 41 |
+
have heq := (goe_row_hasLaw hr.le i e havoid).measureReal_eq hm
|
| 42 |
+
change (gaussianCoordinates (MatrixCoordinates (Fin n))).real
|
| 43 |
+
{g | t < ∑ k : S.erase i,goeMatrix r g i k^2} = (Measure.pi (fun _ : S.erase i=>gaussianReal 0 (Real.toNNReal r))).real {v | t < ∑ k,v k^2} at heq
|
| 44 |
+
rw [heq]
|
| 45 |
+
apply (scaled_gaussian_square_tail hr t).trans
|
| 46 |
+
apply exp_le_exp.mpr
|
| 47 |
+
have hcard : (Fintype.card (S.erase i):ℝ) ≤ S.card := by
|
| 48 |
+
rw [Fintype.card_coe]
|
| 49 |
+
exact_mod_cast Finset.card_erase_le
|
| 50 |
+
exact add_le_add (le_refl _) (mul_le_mul_of_nonneg_right hcard (log_nonneg (show (1:ℝ) ≤ 2 by norm_num)))
|
| 51 |
+
|
| 52 |
+
lemma coupling_goe_sparse_rows_tail [NeZero n] {j α l t : ℝ}
|
| 53 |
+
(hj : 0 < j) (_hα : 0 ≤ α) (hl : 0 ≤ l) :
|
| 54 |
+
(gaussianCoordinates (MatrixCoordinates (Fin n))).real
|
| 55 |
+
{g | ∃ i : Fin n,∃ S : Finset (Fin n),(S.card:ℝ) ≤ α*(n:ℝ) ∧
|
| 56 |
+
t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2} ≤
|
| 57 |
+
(n:ℝ)*exp (-(n:ℝ)*(t/(4*j)-(l*α+log (1+exp (-l))+α*log 2))) := by
|
| 58 |
+
have hn : (0:ℝ) < n := by exact_mod_cast NeZero.pos n
|
| 59 |
+
have hsingle (i : Fin n) :
|
| 60 |
+
(gaussianCoordinates (MatrixCoordinates (Fin n))).real
|
| 61 |
+
{g | ∃ S : Finset (Fin n),(S.card:ℝ) ≤ α*(n:ℝ) ∧
|
| 62 |
+
t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2} ≤
|
| 63 |
+
exp (-(n:ℝ)*(t/(4*j)-(l*α+log (1+exp (-l))+α*log 2))) := by
|
| 64 |
+
have he : {g : MatrixCoordinates (Fin n)→ℝ | ∃ S : Finset (Fin n),(S.card:ℝ) ≤ α*(n:ℝ) ∧
|
| 65 |
+
t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2}=
|
| 66 |
+
⋃ S∈smallSupports (ι:=Fin n) α,{g | t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2} := by
|
| 67 |
+
ext g;simp [smallSupports]
|
| 68 |
+
rw [he]
|
| 69 |
+
have hb := sparse_union_bound (gaussianCoordinates (MatrixCoordinates (Fin n)))
|
| 70 |
+
(ι:=Fin n) (C:=1) (q:=t/(4*j)-α*log 2) (α:=α)
|
| 71 |
+
(fun S=>{g | t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2}) hl (by norm_num : (0:ℝ) ≤ 1) ?_
|
| 72 |
+
· convert hb using 1
|
| 73 |
+
simp only [one_mul,Fintype.card_fin]
|
| 74 |
+
congr 1
|
| 75 |
+
ring
|
| 76 |
+
intro S hS
|
| 77 |
+
have hc : (S.card:ℝ) ≤ α*(n:ℝ) := by simpa only [Fintype.card_fin] using (Finset.mem_filter.mp hS).2
|
| 78 |
+
apply (coupling_goe_row_tail (div_pos hj hn) i S t).trans
|
| 79 |
+
simp only [one_mul,Fintype.card_fin]
|
| 80 |
+
apply exp_le_exp.mpr
|
| 81 |
+
have hh := mul_le_mul_of_nonneg_right hc (log_nonneg (show (1:ℝ) ≤ 2 by norm_num))
|
| 82 |
+
have he' : -t/(4*(j/(n:ℝ))) = -(n:ℝ)*(t/(4*j)) := by field_simp
|
| 83 |
+
rw [he']
|
| 84 |
+
nlinarith only [hh]
|
| 85 |
+
have he : {g : MatrixCoordinates (Fin n)→ℝ | ∃ i : Fin n,∃ S : Finset (Fin n),(S.card:ℝ) ≤ α*(n:ℝ) ∧
|
| 86 |
+
t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2}=
|
| 87 |
+
⋃ i : Fin n,{g | ∃ S : Finset (Fin n),(S.card:ℝ) ≤ α*(n:ℝ) ∧
|
| 88 |
+
t < ∑ k∈S,coupling (goeDisorder (j/(n:ℝ)) g) i k^2} := by ext g;simp
|
| 89 |
+
rw [he]
|
| 90 |
+
apply (measureReal_iUnion_fintype_le _).trans
|
| 91 |
+
apply (Finset.sum_le_sum (fun i _=>hsingle i)).trans_eq
|
| 92 |
+
simp
|
| 93 |
+
end SKGap
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
end
|
| 97 |
+
|
| 98 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GOEScalarTail.lean
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.ConditionalGramTail
|
| 3 |
+
import OAI.Probability.SKGap.Localization.ConditionalRankAlgebra
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Matrix MeasureTheory ProbabilityTheory Real
|
| 11 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 12 |
+
|
| 13 |
+
theorem goe_scalar_tail {n : ℕ} (hn : 0 < n) {j U ε : ℝ}
|
| 14 |
+
(hj : 0 < j) (hU : 0 ≤ U) (hε : 0 ≤ ε)
|
| 15 |
+
(u : EuclideanSpace ℝ (Fin n)) (hu : ‖u‖ ≤ U) :
|
| 16 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
|
| 17 |
+
{g | ε ≤ |matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u|} ≤
|
| 18 |
+
2*exp (-(n:ℝ)*ε^2/(π^2*(2*(U+1)^2)^2*j)) := by
|
| 19 |
+
let : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hn
|
| 20 |
+
have h := goe_bilinear_concentration hj (by norm_num : (0:ℝ)≤1) hU
|
| 21 |
+
(by norm_num : (0:ℝ)≤0) hε (fun M => M) (fun _ _ _ => rfl)
|
| 22 |
+
(fun M N => by simp) 0 (by intro i; simp [goeEntry_integral]) u u hu hu
|
| 23 |
+
have hz : (diagonal (0 : Fin n → ℝ) : Matrix (Fin n) (Fin n) ℝ)=0 := by
|
| 24 |
+
ext i k; simp [Matrix.diagonal]
|
| 25 |
+
rw [hz] at h
|
| 26 |
+
simpa only [Fintype.card_fin,zero_mul,zero_add,sub_zero,
|
| 27 |
+
show (1:ℝ)+1=2 by norm_num] using h
|
| 28 |
+
end SKGap
|
| 29 |
+
end
|
| 30 |
+
end
|
| 31 |
+
|
| 32 |
+
section
|
| 33 |
+
noncomputable section
|
| 34 |
+
namespace SKGap
|
| 35 |
+
open Matrix MeasureTheory ProbabilityTheory Real Set
|
| 36 |
+
open scoped BigOperators MatrixOrder Matrix.Norms.Frobenius
|
| 37 |
+
|
| 38 |
+
def conditionalBase {n : ℕ} (j : ℝ) (a : Fin n → ℝ)
|
| 39 |
+
(g : MatrixCoordinates (Fin n) → ℝ) : Matrix (Fin n) (Fin n) ℝ :=
|
| 40 |
+
1-pathDiagonal a 1*(goeMatrix (j/(n:ℝ)) g-((j/(n:ℝ))*∑ i,a i) • 1)*pathDiagonal a 1
|
| 41 |
+
|
| 42 |
+
def conditionalUpdateColumns {n : ℕ} (j : ℝ) (a : Fin n → ℝ)
|
| 43 |
+
(p : Fin 3 → EuclideanSpace ℝ (Fin n)) (u : EuclideanSpace ℝ (Fin n))
|
| 44 |
+
(g : MatrixCoordinates (Fin n) → ℝ) : Matrix (Fin n) ((Fin 3) ⊕ Unit) ℝ :=
|
| 45 |
+
extendColumns (fun r => (p r).ofLp)
|
| 46 |
+
(residualGramVector (j/(n:ℝ)*∑ i,a i) (goeMatrix (j/(n:ℝ)) g) u.ofLp)
|
| 47 |
+
|
| 48 |
+
theorem compact_conditional_fixed_tail {α : Type*} [TopologicalSpace α] [CompactSpace α]
|
| 49 |
+
{j A U : ℝ} (hj : 0 < j) (hj1 : j < 1) (hA : 0 < A)
|
| 50 |
+
(hsub : sqrt j*A < 1) (hU : 0 ≤ U)
|
| 51 |
+
(b e s q κ : α → ℝ) (hb : Continuous b) (he : Continuous e)
|
| 52 |
+
(hs : Continuous s) (hq : Continuous q) (hk : Continuous κ)
|
| 53 |
+
(hb0 : ∀ x,0 < b x) (hb1 : ∀ x,b x ≤ 1) (he0 : ∀ x,0 ≤ e x)
|
| 54 |
+
(hs0 : ∀ x,0 < s x) (hq0 : ∀ x,0 < q x)
|
| 55 |
+
(hkq : ∀ x,κ x^2=1-j*q x/s x) :
|
| 56 |
+
∃ δ ρ : ℝ, 0 < δ ∧ δ < 1 ∧ 0 < ρ ∧
|
| 57 |
+
∀ ε τ : ℝ, 0 < ε → 0 < τ → ∃ c : ℝ, ∃ N : ℕ, 0 < c ∧ 0 < N ∧
|
| 58 |
+
∀ n, N ≤ n → ∀ a : Fin n → ℝ, (∀ i,0 ≤ a i) → (∀ i,a i ≤ A) →
|
| 59 |
+
0 < j/(n:ℝ)*∑ i,a i →
|
| 60 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε < ρ/2 →
|
| 61 |
+
∀ p : Fin 3 → EuclideanSpace ℝ (Fin n), ∀ u : EuclideanSpace ℝ (Fin n),
|
| 62 |
+
(∀ r,‖p r‖ ≤ U) → ‖u‖ ≤ U → u.ofLp⬝ᵥu.ofLp=1 →
|
| 63 |
+
∀ x (C E : Matrix ((Fin 3) ⊕ Unit) ((Fin 3) ⊕ Unit) ℝ),
|
| 64 |
+
C.IsHermitian → E.IsHermitian → τ*‖E‖ < ρ/2 →
|
| 65 |
+
‖diagonalAugmentedGram a p-augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x))‖ < ρ/2 →
|
| 66 |
+
‖C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 67 |
+
j ((κ x-1)*√(j*b x)/√(q x))‖ < ρ/2 →
|
| 68 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)).real
|
| 69 |
+
{g | ¬(conditionalBase j a g-
|
| 70 |
+
pathDiagonal a 1*conditionalUpdateColumns j a p u g*
|
| 71 |
+
(C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)*
|
| 72 |
+
(conditionalUpdateColumns j a p u g)ᵀ*pathDiagonal a 1-
|
| 73 |
+
(δ*((1-sqrt j*A)^2/4)) • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef} ≤
|
| 74 |
+
101*exp (-c*(n:ℝ)) := by
|
| 75 |
+
obtain ⟨δ,ρ,hδ,hδ1,hρ,hcrit⟩ := compact_conditional_rank_criterion hj hj1 b e s q κ
|
| 76 |
+
hb he hs hq hk hb0 hb1 he0 hs0 hq0 hkq
|
| 77 |
+
refine ⟨δ,ρ,hδ,hδ1,hρ,?_⟩
|
| 78 |
+
intro ε τ hε hτ
|
| 79 |
+
obtain ⟨c₀,N,hc₀,hN,hgram⟩ := conditional_augmented_gram_tail hj hA hsub hU hε
|
| 80 |
+
let c₁ := τ^2/(π^2*(2*(U+1)^2)^2*j)
|
| 81 |
+
have hc₁ : 0 < c₁ := by dsimp [c₁]; positivity
|
| 82 |
+
refine ⟨min c₀ c₁,N,lt_min hc₀ hc₁,hN,?_⟩
|
| 83 |
+
intro n hn a ha haA hB heps p u hp hu hunit x C E hC hE hEbound hdiag hcoef
|
| 84 |
+
let μ := Measure.pi (fun _ : MatrixCoordinates (Fin n) => gaussianReal 0 1)
|
| 85 |
+
let badG := {g | ¬bilinearPathGood j A a g ∨
|
| 86 |
+
augmentedGramTolerance (j/(n:ℝ)*∑ i,a i) ε <
|
| 87 |
+
‖actualAugmentedGram j a p u g-diagonalAugmentedGram a p‖}
|
| 88 |
+
let badS := {g | τ ≤ |matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u|}
|
| 89 |
+
have hnpos := hN.trans_le hn
|
| 90 |
+
have hgprob : μ.real badG ≤ 99*exp (-c₀*(n:ℝ)) := hgram n hn a ha haA hB p u hp hu hunit
|
| 91 |
+
have hsprob : μ.real badS ≤ 2*exp (-c₁*(n:ℝ)) := by
|
| 92 |
+
have hh := goe_scalar_tail hnpos hj hU hτ.le u hu
|
| 93 |
+
convert hh using 1
|
| 94 |
+
congr 2
|
| 95 |
+
dsimp [c₁]
|
| 96 |
+
ring
|
| 97 |
+
have hsubsets : {g | ¬(conditionalBase j a g-
|
| 98 |
+
pathDiagonal a 1*conditionalUpdateColumns j a p u g*
|
| 99 |
+
(C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)*
|
| 100 |
+
(conditionalUpdateColumns j a p u g)ᵀ*pathDiagonal a 1-
|
| 101 |
+
(δ*((1-sqrt j*A)^2/4)) • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef} ⊆ badG ∪ badS := by
|
| 102 |
+
intro g hg
|
| 103 |
+
by_contra hbad
|
| 104 |
+
have hgG : g ∉ badG := fun hh => hbad (Or.inl hh)
|
| 105 |
+
have hgS : g ∉ badS := fun hh => hbad (Or.inr hh)
|
| 106 |
+
simp only [badG,mem_ofPred_eq,not_or,not_lt] at hgG
|
| 107 |
+
have hgS' : |matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u| < τ := lt_of_not_ge hgS
|
| 108 |
+
let D := pathDiagonal a 1
|
| 109 |
+
let S := conditionalBase j a g
|
| 110 |
+
let V := conditionalUpdateColumns j a p u g
|
| 111 |
+
let Cg := C+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E
|
| 112 |
+
let lo := (1-sqrt j*A)^2/4
|
| 113 |
+
have hmargin : (S-lo • (1 : Matrix (Fin n) (Fin n) ℝ)).PosDef :=
|
| 114 |
+
bilinearPathGood_margin a g (not_not.mp hgG.1)
|
| 115 |
+
have hlo : 0 ≤ lo := by dsimp [lo]; positivity
|
| 116 |
+
have hSpos : S.PosDef := by
|
| 117 |
+
have hh := hmargin.add_posSemidef ((Matrix.PosSemidef.one : (1 : Matrix (Fin n) (Fin n) ℝ).PosSemidef).smul hlo)
|
| 118 |
+
convert hh using 1; abel
|
| 119 |
+
have hD : D.IsHermitian := isHermitian_diagonal_iff.mpr
|
| 120 |
+
(fun i => isSelfAdjoint_iff.mpr (star_trivial _))
|
| 121 |
+
have hCg : Cg.IsHermitian := hC.add (hE.smul (R := ℝ)
|
| 122 |
+
(isSelfAdjoint_iff.mpr (star_trivial _)))
|
| 123 |
+
have hG : ‖Vᵀ*D*S⁻¹*D*V-augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x))‖ < ρ := by
|
| 124 |
+
have hh := norm_sub_le_norm_sub_add_norm_sub (actualAugmentedGram j a p u g) (diagonalAugmentedGram a p)
|
| 125 |
+
(augmentedGram (ν := Unit) (limitingGram (b x) (e x) (s x)))
|
| 126 |
+
have heq : Vᵀ*D*S⁻¹*D*V=actualAugmentedGram j a p u g := by
|
| 127 |
+
simp only [V,D,S,conditionalUpdateColumns,conditionalBase,actualAugmentedGram,
|
| 128 |
+
exactG,Fintype.card_fin,Matrix.mul_assoc]
|
| 129 |
+
rw [heq]
|
| 130 |
+
exact hh.trans_lt (by linarith [hgG.2])
|
| 131 |
+
have hCgclose : ‖Cg-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 132 |
+
j ((κ x-1)*√(j*b x)/√(q x))‖ < ρ := by
|
| 133 |
+
have hn : ‖matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E‖ ≤ τ*‖E‖ := by
|
| 134 |
+
rw [norm_smul,Real.norm_eq_abs]
|
| 135 |
+
exact mul_le_mul_of_nonneg_right hgS'.le (norm_nonneg _)
|
| 136 |
+
have hh := norm_add_le (C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 137 |
+
j ((κ x-1)*√(j*b x)/√(q x))) (matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E)
|
| 138 |
+
have heq : Cg-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 139 |
+
j ((κ x-1)*√(j*b x)/√(q x))=
|
| 140 |
+
(C-conditionalCoefficient j ((2*j*q x+2*(j*b x)*(κ x-1))/q x)
|
| 141 |
+
j ((κ x-1)*√(j*b x)/√(q x)))+matrixBilinear (goeMatrix (j/(n:ℝ)) g) u u • E := by
|
| 142 |
+
dsimp [Cg]; abel
|
| 143 |
+
rw [heq]
|
| 144 |
+
exact hh.trans_lt (by linarith)
|
| 145 |
+
exact hg (hcrit x (Fin n) S D V Cg lo hSpos hD hCg hmargin.posSemidef hG hCgclose)
|
| 146 |
+
apply (measureReal_mono hsubsets (measure_ne_top _ _)).trans
|
| 147 |
+
apply (measureReal_union_le badG badS).trans
|
| 148 |
+
apply (add_le_add hgprob hsprob).trans
|
| 149 |
+
have he₀ : exp (-c₀*(n:ℝ)) ≤ exp (-min c₀ c₁*(n:ℝ)) := by
|
| 150 |
+
apply exp_le_exp.mpr; simpa only [neg_mul] using neg_le_neg (mul_le_mul_of_nonneg_right (min_le_left c₀ c₁) (Nat.cast_nonneg n : (0:ℝ) ≤ n))
|
| 151 |
+
have he₁ : exp (-c₁*(n:ℝ)) ≤ exp (-min c₀ c₁*(n:ℝ)) := by
|
| 152 |
+
apply exp_le_exp.mpr; simpa only [neg_mul] using neg_le_neg (mul_le_mul_of_nonneg_right (min_le_right c₀ c₁) (Nat.cast_nonneg n : (0:ℝ) ≤ n))
|
| 153 |
+
nlinarith
|
| 154 |
+
end SKGap
|
| 155 |
+
end
|
| 156 |
+
end
|
| 157 |
+
|
| 158 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussMoment.lean
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Model
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open MeasureTheory ProbabilityTheory
|
| 14 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 15 |
+
open scoped BigOperators NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory
|
| 17 |
+
open scoped BigOperators NNReal ENNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
open MeasureTheory ProbabilityTheory
|
| 21 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 22 |
+
open scoped BigOperators
|
| 23 |
+
open MeasureTheory ProbabilityTheory
|
| 24 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 25 |
+
open scoped BigOperators
|
| 26 |
+
open scoped BigOperators NNReal ENNReal
|
| 27 |
+
open MeasureTheory Metric Set
|
| 28 |
+
open scoped BigOperators NNReal ENNReal
|
| 29 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 30 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 31 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 32 |
+
open scoped BigOperators Matrix.Norms.L2Operator
|
| 33 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 34 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 35 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 36 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 37 |
+
open scoped BigOperators ENNReal NNReal
|
| 38 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 39 |
+
open scoped BigOperators NNReal ENNReal Matrix
|
| 40 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 41 |
+
open scoped BigOperators ENNReal NNReal
|
| 42 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 43 |
+
open scoped BigOperators NNReal ENNReal
|
| 44 |
+
open scoped BigOperators
|
| 45 |
+
open MeasureTheory ProbabilityTheory
|
| 46 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
|
| 47 |
+
open scoped BigOperators
|
| 48 |
+
open Filter Topology
|
| 49 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 50 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 51 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 52 |
+
open Matrix
|
| 53 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise
|
| 54 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 55 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 56 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 57 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 58 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 59 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 60 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 61 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 62 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 63 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 64 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 65 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 66 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 67 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 68 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 69 |
+
open scoped ENNReal Topology
|
| 70 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 71 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 72 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 73 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 74 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 75 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 76 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 77 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 78 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 79 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 80 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 81 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 82 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 83 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 84 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 85 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 86 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 87 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 88 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 89 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 90 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 91 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 92 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 93 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 94 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 95 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 96 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 97 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 98 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 99 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 100 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 101 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 102 |
+
open MeasureTheory ProbabilityTheory Filter Set Matrix
|
| 103 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 104 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 105 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 106 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 107 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 108 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 109 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 110 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 111 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 112 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 113 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 114 |
+
open Filter MeasureTheory ProbabilityTheory
|
| 115 |
+
open scoped Topology NNReal ENNReal
|
| 116 |
+
open Filter MeasureTheory ProbabilityTheory
|
| 117 |
+
open scoped Topology NNReal ENNReal
|
| 118 |
+
open MeasureTheory Filter
|
| 119 |
+
open scoped Topology NNReal ENNReal
|
| 120 |
+
namespace SKGapCutoff.Clock
|
| 121 |
+
|
| 122 |
+
noncomputable def gaussMoment (a : ℝ) (k : ℕ) (x : ℝ) : ℝ :=
|
| 123 |
+
x^k*Real.exp (-a*x^2)
|
| 124 |
+
|
| 125 |
+
lemma integrable_gaussMoment {a : ℝ} (ha : 0 < a) (k : ℕ) :
|
| 126 |
+
Integrable (gaussMoment a k) := by
|
| 127 |
+
have hk : (-1:ℝ) < (k:ℝ) := by have := (Nat.cast_nonneg k : (0:ℝ)≤k); linarith
|
| 128 |
+
have hh := integrable_rpow_mul_exp_neg_mul_sq ha hk
|
| 129 |
+
convert! hh using 1
|
| 130 |
+
ext x
|
| 131 |
+
exact (Real.rpow_natCast x k).symm |> congrArg (fun t => t*Real.exp (-a*x^2))
|
| 132 |
+
|
| 133 |
+
lemma hasDerivAt_gaussMoment (a : ℝ) (k : ℕ) (x : ℝ) :
|
| 134 |
+
HasDerivAt (gaussMoment a k)
|
| 135 |
+
((k:ℝ)*gaussMoment a (k-1) x-2*a*gaussMoment a (k+1) x) x := by
|
| 136 |
+
have he := ((((hasDerivAt_id x).pow 2).const_mul (-a)).exp)
|
| 137 |
+
convert! ((hasDerivAt_id x).pow k).mul he using 1
|
| 138 |
+
simp only [gaussMoment,pow_succ,Pi.pow_apply,id_eq,Nat.cast_ofNat,mul_one,pow_zero]
|
| 139 |
+
ring
|
| 140 |
+
|
| 141 |
+
lemma integrable_abs_add_one_pow_gauss {a : ℝ} (ha : 0 < a) (k : ℕ) :
|
| 142 |
+
Integrable (fun x : ℝ => (|x|+1)^k*Real.exp (-a*x^2)) := by
|
| 143 |
+
have hi (j : ℕ) : Integrable (fun x : ℝ => |x|^j*Real.exp (-a*x^2)) := by
|
| 144 |
+
simpa only [gaussMoment,Real.norm_eq_abs,abs_mul,abs_pow,
|
| 145 |
+
abs_of_nonneg (Real.exp_nonneg _)] using (integrable_gaussMoment ha j).norm
|
| 146 |
+
have hh := integrable_finsetSum (Finset.range (k+1))
|
| 147 |
+
(fun j _ => (hi j).mul_const (k.choose j:ℝ))
|
| 148 |
+
convert! hh using 1
|
| 149 |
+
ext x
|
| 150 |
+
rw [add_pow,Finset.sum_mul]
|
| 151 |
+
apply Finset.sum_congr rfl
|
| 152 |
+
intro j hj
|
| 153 |
+
simp only [one_pow,mul_one]
|
| 154 |
+
ring
|
| 155 |
+
|
| 156 |
+
noncomputable def momentEnvelope (a : ℝ) (k : ℕ) (x : ℝ) : ℝ :=
|
| 157 |
+
((k:ℝ)*(|x|+1)^(k-1)+2*a*(|x|+1)^(k+1))*Real.exp a*Real.exp (-(a/2)*x^2)
|
| 158 |
+
|
| 159 |
+
lemma integrable_momentEnvelope {a : ℝ} (ha : 0 < a) (k : ℕ) :
|
| 160 |
+
Integrable (momentEnvelope a k) := by
|
| 161 |
+
have hhalf : 0 < a/2 := by positivity
|
| 162 |
+
have hh := (((integrable_abs_add_one_pow_gauss hhalf (k-1)).const_mul (k:ℝ)).add
|
| 163 |
+
((integrable_abs_add_one_pow_gauss hhalf (k+1)).const_mul (2*a))).const_mul (Real.exp a)
|
| 164 |
+
convert! hh using 1
|
| 165 |
+
ext x
|
| 166 |
+
simp only [momentEnvelope,Pi.add_apply]
|
| 167 |
+
ring
|
| 168 |
+
|
| 169 |
+
lemma gaussMoment_deriv_bound {a : ℝ} (ha : 0 < a) (k : ℕ) (x z : ℝ)
|
| 170 |
+
(hz : z ∈ Set.Icc (x-1) (x+1)) :
|
| 171 |
+
|(k:ℝ)*gaussMoment a (k-1) z-2*a*gaussMoment a (k+1) z| ≤
|
| 172 |
+
momentEnvelope a k x := by
|
| 173 |
+
have hdist : |z-x| ≤ 1 := abs_le.mpr ⟨by linarith [hz.1],by linarith [hz.2]⟩
|
| 174 |
+
have hzabs : |z| ≤ |x|+1 := by
|
| 175 |
+
calc
|
| 176 |
+
|z| = |(z-x)+x| := by rw [sub_add_cancel]
|
| 177 |
+
_ ≤ |z-x|+|x| := abs_add_le _ _
|
| 178 |
+
_ ≤ |x|+1 := by linarith
|
| 179 |
+
have hsq : (z-x)^2 ≤ 1 := by
|
| 180 |
+
have hh := mul_self_le_mul_self (abs_nonneg (z-x)) hdist
|
| 181 |
+
nlinarith [sq_abs (z-x)]
|
| 182 |
+
have hquad : x^2/2-1 ≤ z^2 := by nlinarith [sq_nonneg (x-2*z)]
|
| 183 |
+
have he : Real.exp (-a*z^2) ≤ Real.exp a*Real.exp (-(a/2)*x^2) := by
|
| 184 |
+
rw [← Real.exp_add]
|
| 185 |
+
apply Real.exp_le_exp.mpr
|
| 186 |
+
nlinarith [mul_nonneg ha.le (sub_nonneg.mpr hquad)]
|
| 187 |
+
have h1 := pow_le_pow_left₀ (abs_nonneg z) hzabs (k-1)
|
| 188 |
+
have h2 := pow_le_pow_left₀ (abs_nonneg z) hzabs (k+1)
|
| 189 |
+
calc
|
| 190 |
+
_ ≤ |(k:ℝ)*gaussMoment a (k-1) z|+|2*a*gaussMoment a (k+1) z| := by
|
| 191 |
+
simpa only [Real.norm_eq_abs] using norm_sub_le
|
| 192 |
+
((k:ℝ)*gaussMoment a (k-1) z) (2*a*gaussMoment a (k+1) z)
|
| 193 |
+
_ = ((k:ℝ)*|z|^(k-1)+2*a*|z|^(k+1))*Real.exp (-a*z^2) := by
|
| 194 |
+
norm_num only [gaussMoment,abs_mul,abs_pow,abs_of_nonneg (Nat.cast_nonneg k : (0:ℝ)≤k),
|
| 195 |
+
abs_of_nonneg ha.le,abs_of_nonneg (Real.exp_nonneg _)]
|
| 196 |
+
ring
|
| 197 |
+
_ ≤ ((k:ℝ)*(|x|+1)^(k-1)+2*a*(|x|+1)^(k+1))*
|
| 198 |
+
(Real.exp a*Real.exp (-(a/2)*x^2)) := by
|
| 199 |
+
apply mul_le_mul _ he (Real.exp_nonneg _) (by positivity)
|
| 200 |
+
exact add_le_add (mul_le_mul_of_nonneg_left h1 (Nat.cast_nonneg _))
|
| 201 |
+
(mul_le_mul_of_nonneg_left h2 (by positivity))
|
| 202 |
+
_ = _ := by dsimp [momentEnvelope]; ring
|
| 203 |
+
|
| 204 |
+
noncomputable def diffMoment (a : ℝ) (k : ℕ) (h x : ℝ) : ℝ :=
|
| 205 |
+
(gaussMoment a k (x+h)-gaussMoment a k x)/h
|
| 206 |
+
|
| 207 |
+
lemma diffMoment_bound {a : ℝ} (ha : 0 < a) (k : ℕ) {h : ℝ}
|
| 208 |
+
(hh : 0 < h) (hh1 : h ≤ 1) (x : ℝ) :
|
| 209 |
+
|diffMoment a k h x| ≤ momentEnvelope a k x := by
|
| 210 |
+
have hmv := Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
|
| 211 |
+
(s := Set.Icc (x-1) (x+1))
|
| 212 |
+
(f := gaussMoment a k)
|
| 213 |
+
(f' := fun z => (k:ℝ)*gaussMoment a (k-1) z-2*a*gaussMoment a (k+1) z)
|
| 214 |
+
(fun z _ => (hasDerivAt_gaussMoment a k z).hasDerivWithinAt)
|
| 215 |
+
(fun z hz => by simpa only [Real.norm_eq_abs] using gaussMoment_deriv_bound ha k x z hz)
|
| 216 |
+
(convex_Icc _ _) (show x ∈ Set.Icc (x-1) (x+1) from ⟨by linarith,by linarith⟩)
|
| 217 |
+
(show x+h ∈ Set.Icc (x-1) (x+1) from ⟨by linarith,by linarith⟩)
|
| 218 |
+
rw [Real.norm_eq_abs,Real.norm_eq_abs,add_sub_cancel_left,abs_of_pos hh] at hmv
|
| 219 |
+
unfold diffMoment
|
| 220 |
+
rw [abs_div,abs_of_pos hh]
|
| 221 |
+
exact (div_le_iff₀ hh).mpr hmv
|
| 222 |
+
|
| 223 |
+
lemma integrable_diffMoment {a : ℝ} (ha : 0 < a) (k : ℕ) (h : ℝ) :
|
| 224 |
+
Integrable (diffMoment a k h) :=
|
| 225 |
+
(((integrable_gaussMoment ha k).comp_add_right h).sub
|
| 226 |
+
(integrable_gaussMoment ha k)).div_const h
|
| 227 |
+
|
| 228 |
+
lemma gaussMoment_derivative_L1 {a : ℝ} (ha : 0 < a) (k : ℕ) :
|
| 229 |
+
Tendsto (fun n : ℕ => ∫ x : ℝ,
|
| 230 |
+
|diffMoment a k (1/((n:ℝ)+1)) x-
|
| 231 |
+
((k:ℝ)*gaussMoment a (k-1) x-2*a*gaussMoment a (k+1) x)|)
|
| 232 |
+
atTop (𝓝 0) := by
|
| 233 |
+
let dg : ℝ → ℝ := fun x => (k:ℝ)*gaussMoment a (k-1) x-2*a*gaussMoment a (k+1) x
|
| 234 |
+
have hdg : Integrable dg := ((integrable_gaussMoment ha (k-1)).const_mul (k:ℝ)).sub
|
| 235 |
+
((integrable_gaussMoment ha (k+1)).const_mul (2*a))
|
| 236 |
+
have hstep : Tendsto (fun n : ℕ => 1/((n:ℝ)+1)) atTop (𝓝[≠] (0:ℝ)) := by
|
| 237 |
+
refine tendsto_nhdsWithin_iff.mpr ⟨tendsto_one_div_add_atTop_nhds_zero_nat, ?_⟩
|
| 238 |
+
exact Filter.Eventually.of_forall (fun n => by
|
| 239 |
+
simp only [Set.mem_compl_iff,Set.mem_singleton_iff]
|
| 240 |
+
exact ne_of_gt (by positivity))
|
| 241 |
+
have hp (x : ℝ) : Tendsto (fun n : ℕ => diffMoment a k (1/((n:ℝ)+1)) x)
|
| 242 |
+
atTop (𝓝 (dg x)) := by
|
| 243 |
+
have hh := (hasDerivAt_gaussMoment a k x).tendsto_slope_zero.comp hstep
|
| 244 |
+
simpa only [Function.comp_def,smul_eq_mul,div_eq_mul_inv,mul_comm,diffMoment,dg] using hh
|
| 245 |
+
have ht := tendsto_integral_of_dominated_convergence
|
| 246 |
+
(fun x => momentEnvelope a k x+|dg x|)
|
| 247 |
+
(F := fun n : ℕ => fun x => |diffMoment a k (1/((n:ℝ)+1)) x-dg x|)
|
| 248 |
+
(f := fun _ => (0:ℝ))
|
| 249 |
+
(fun n => ((integrable_diffMoment ha k _).sub hdg).abs.aestronglyMeasurable)
|
| 250 |
+
((integrable_momentEnvelope ha k).add hdg.abs)
|
| 251 |
+
(fun n => Filter.Eventually.of_forall (fun x => by
|
| 252 |
+
rw [Real.norm_eq_abs,abs_abs]
|
| 253 |
+
have htri : |diffMoment a k (1/((n:ℝ)+1)) x-dg x| ≤
|
| 254 |
+
|diffMoment a k (1/((n:ℝ)+1)) x|+|dg x| := by
|
| 255 |
+
simpa only [Real.norm_eq_abs] using
|
| 256 |
+
norm_sub_le (diffMoment a k (1/((n:ℝ)+1)) x) (dg x)
|
| 257 |
+
exact htri.trans (add_le_add (diffMoment_bound ha k (h := 1/((n:ℝ)+1)) (by positivity)
|
| 258 |
+
(by have := (Nat.cast_nonneg n : (0:ℝ)≤n); apply (div_le_one (by positivity)).mpr; linarith) x) le_rfl)))
|
| 259 |
+
(Filter.Eventually.of_forall (fun x => by simpa using ((hp x).sub_const (dg x)).abs))
|
| 260 |
+
simpa only [integral_zero] using ht
|
| 261 |
+
|
| 262 |
+
noncomputable def momentL1 (a : ℝ) (ha : 0 < a) (k : ℕ) (y : ℝ) : Lp ℝ 1 (volume : Measure ℝ) :=
|
| 263 |
+
Integrable.toL1 (fun x : ℝ => gaussMoment a k (x+y))
|
| 264 |
+
((integrable_gaussMoment ha k).comp_add_right y)
|
| 265 |
+
|
| 266 |
+
lemma norm_toL1_real {f : ℝ → ℝ} (hf : Integrable f) :
|
| 267 |
+
‖hf.toL1 f‖ = ∫ x : ℝ, |f x| := by
|
| 268 |
+
rw [Integrable.norm_toL1_eq_lintegral_enorm,
|
| 269 |
+
← integral_norm_eq_lintegral_enorm hf.aestronglyMeasurable]
|
| 270 |
+
simp only [Real.norm_eq_abs]
|
| 271 |
+
|
| 272 |
+
lemma momentL1_derivative {a : ℝ} (ha : 0 < a) (k : ℕ) (y : ℝ) :
|
| 273 |
+
Tendsto (fun n : ℕ => ((1/((n:ℝ)+1))⁻¹) •
|
| 274 |
+
(momentL1 a ha k (y+1/((n:ℝ)+1))-momentL1 a ha k y)) atTop
|
| 275 |
+
(𝓝 ((k:ℝ) • momentL1 a ha (k-1) y-(2*a) • momentL1 a ha (k+1) y)) := by
|
| 276 |
+
apply tendsto_iff_norm_sub_tendsto_zero.mpr
|
| 277 |
+
have he (n : ℕ) :
|
| 278 |
+
‖((1/((n:ℝ)+1))⁻¹) • (momentL1 a ha k (y+1/((n:ℝ)+1))-
|
| 279 |
+
momentL1 a ha k y)-((k:ℝ) • momentL1 a ha (k-1) y-
|
| 280 |
+
(2*a) • momentL1 a ha (k+1) y)‖ =
|
| 281 |
+
∫ x : ℝ, |diffMoment a k (1/((n:ℝ)+1)) x-
|
| 282 |
+
((k:ℝ)*gaussMoment a (k-1) x-2*a*gaussMoment a (k+1) x)| := by
|
| 283 |
+
let h : ℝ := 1/((n:ℝ)+1)
|
| 284 |
+
let f : ℝ → ℝ := fun x => h⁻¹ * (gaussMoment a k (x+(y+h))-
|
| 285 |
+
gaussMoment a k (x+y))-
|
| 286 |
+
((k:ℝ)*gaussMoment a (k-1) (x+y)-(2*a)*gaussMoment a (k+1) (x+y))
|
| 287 |
+
have hf : Integrable f :=
|
| 288 |
+
((((integrable_gaussMoment ha k).comp_add_right (y+h)).sub
|
| 289 |
+
((integrable_gaussMoment ha k).comp_add_right y)).const_mul h⁻¹).sub
|
| 290 |
+
((((integrable_gaussMoment ha (k-1)).comp_add_right y).const_mul (k:ℝ)).sub
|
| 291 |
+
(((integrable_gaussMoment ha (k+1)).comp_add_right y).const_mul (2*a)))
|
| 292 |
+
change ‖hf.toL1 f‖ = _
|
| 293 |
+
rw [norm_toL1_real]
|
| 294 |
+
have hfun : (fun x => |f x|) = fun x => |diffMoment a k h (x+y)-
|
| 295 |
+
((k:ℝ)*gaussMoment a (k-1) (x+y)-2*a*gaussMoment a (k+1) (x+y))| := by
|
| 296 |
+
funext x
|
| 297 |
+
simp only [f,diffMoment,add_assoc,div_eq_mul_inv,mul_comm]
|
| 298 |
+
rw [hfun]
|
| 299 |
+
exact integral_add_right_eq_self (fun x => |diffMoment a k h x-
|
| 300 |
+
((k:ℝ)*gaussMoment a (k-1) x-2*a*gaussMoment a (k+1) x)|) y
|
| 301 |
+
simp_rw [he]
|
| 302 |
+
exact gaussMoment_derivative_L1 ha k
|
| 303 |
+
|
| 304 |
+
lemma momentL1_mem_of_gaussian {a : ℝ} (ha : 0 < a)
|
| 305 |
+
(S : Submodule ℝ (Lp ℝ 1 (volume : Measure ℝ))) (hS : IsClosed (S : Set (Lp ℝ 1 (volume : Measure ℝ))))
|
| 306 |
+
(hbase : ∀ y, momentL1 a ha 0 y ∈ S) :
|
| 307 |
+
∀ k y, momentL1 a ha k y ∈ S := by
|
| 308 |
+
intro k
|
| 309 |
+
induction k using Nat.strong_induction_on with
|
| 310 |
+
| h k ih =>
|
| 311 |
+
intro y
|
| 312 |
+
cases k with
|
| 313 |
+
| zero => exact hbase y
|
| 314 |
+
| succ k =>
|
| 315 |
+
have hder : (k:ℝ) • momentL1 a ha (k-1) y-
|
| 316 |
+
(2*a) • momentL1 a ha (k+1) y ∈ S :=
|
| 317 |
+
hS.mem_of_tendsto (momentL1_derivative ha k y)
|
| 318 |
+
(Filter.Eventually.of_forall (fun n => S.smul_mem _
|
| 319 |
+
(S.sub_mem (ih k (by omega) _) (ih k (by omega) _))))
|
| 320 |
+
have hlow : (k:ℝ) • momentL1 a ha (k-1) y ∈ S :=
|
| 321 |
+
S.smul_mem _ (ih (k-1) (by omega) y)
|
| 322 |
+
have hhigh := S.sub_mem hlow hder
|
| 323 |
+
rw [sub_sub_cancel] at hhigh
|
| 324 |
+
have hn : (2*a) ≠ 0 := ne_of_gt (by positivity)
|
| 325 |
+
have hh := S.smul_mem (2*a)⁻¹ hhigh
|
| 326 |
+
simpa only [smul_smul,inv_mul_cancel₀ hn,one_smul] using hh
|
| 327 |
+
|
| 328 |
+
noncomputable def gaussianTaylor (a c : ℝ) (N : ℕ) (x : ℝ) : ℝ :=
|
| 329 |
+
∑ k ∈ Finset.range N, ((-c)^k/(Nat.factorial k : ℝ))*gaussMoment a (2*k) x
|
| 330 |
+
|
| 331 |
+
lemma gaussianTaylor_eq (a c : ℝ) (N : ℕ) (x : ℝ) :
|
| 332 |
+
gaussianTaylor a c N x =
|
| 333 |
+
(∑ k ∈ Finset.range N, (-c*x^2)^k/(Nat.factorial k : ℝ))*Real.exp (-a*x^2) := by
|
| 334 |
+
unfold gaussianTaylor gaussMoment
|
| 335 |
+
rw [Finset.sum_mul]
|
| 336 |
+
apply Finset.sum_congr rfl
|
| 337 |
+
intro k _
|
| 338 |
+
rw [mul_pow,← pow_mul]
|
| 339 |
+
ring
|
| 340 |
+
|
| 341 |
+
lemma gaussianTaylor_bound (a : ℝ) {c : ℝ} (hc : 0 ≤ c) (N : ℕ) (x : ℝ) :
|
| 342 |
+
|gaussianTaylor a c N x| ≤ Real.exp (-(a-c)*x^2) := by
|
| 343 |
+
rw [gaussianTaylor_eq,abs_mul,abs_of_pos (Real.exp_pos _)]
|
| 344 |
+
have habs : |∑ k ∈ Finset.range N, (-c*x^2)^k/(Nat.factorial k : ℝ)| ≤
|
| 345 |
+
∑ k ∈ Finset.range N, (c*x^2)^k/(Nat.factorial k : ℝ) := by
|
| 346 |
+
calc
|
| 347 |
+
_ ≤ ∑ k ∈ Finset.range N, |(-c*x^2)^k/(Nat.factorial k : ℝ)| :=
|
| 348 |
+
Finset.abs_sum_le_sum_abs _ _
|
| 349 |
+
_ = _ := by
|
| 350 |
+
apply Finset.sum_congr rfl
|
| 351 |
+
intro k _
|
| 352 |
+
rw [abs_div,abs_pow,abs_mul,abs_neg,abs_of_nonneg hc,
|
| 353 |
+
abs_of_nonneg (sq_nonneg x),abs_of_nonneg (Nat.cast_nonneg _)]
|
| 354 |
+
calc
|
| 355 |
+
_ ≤ Real.exp (c*x^2)*Real.exp (-a*x^2) :=
|
| 356 |
+
mul_le_mul_of_nonneg_right (habs.trans (Real.sum_le_exp_of_nonneg (by positivity) N))
|
| 357 |
+
(Real.exp_nonneg _)
|
| 358 |
+
_ = _ := by rw [← Real.exp_add]; congr 1; ring
|
| 359 |
+
|
| 360 |
+
lemma integrable_gaussianTaylor {a : ℝ} (ha : 0 < a) (c : ℝ) (N : ℕ) :
|
| 361 |
+
Integrable (gaussianTaylor a c N) :=
|
| 362 |
+
integrable_finsetSum _ (fun k _ => (integrable_gaussMoment ha (2*k)).const_mul _)
|
| 363 |
+
|
| 364 |
+
lemma gaussianTaylor_tendsto (a c x : ℝ) :
|
| 365 |
+
Tendsto (fun N : ℕ => gaussianTaylor a c N x) atTop (𝓝 (gaussMoment (a+c) 0 x)) := by
|
| 366 |
+
have ht := (NormedSpace.expSeries_div_hasSum_exp (-c*x^2)).tendsto_sum_nat.mul_const
|
| 367 |
+
(Real.exp (-a*x^2))
|
| 368 |
+
simpa only [gaussianTaylor_eq,← Real.exp_eq_exp_ℝ,← Real.exp_add,gaussMoment,pow_zero,one_mul,
|
| 369 |
+
show -c*x^2+-a*x^2=-(a+c)*x^2 by ring] using ht
|
| 370 |
+
|
| 371 |
+
lemma gaussianTaylor_L1 {a c : ℝ} (ha : 0 < a) (hc : 0 ≤ c) (hca : c < a) :
|
| 372 |
+
Tendsto (fun N : ℕ => ∫ x : ℝ,
|
| 373 |
+
|gaussianTaylor a c N x-gaussMoment (a+c) 0 x|) atTop (𝓝 0) := by
|
| 374 |
+
have hp : 0 < a+c := by linarith
|
| 375 |
+
have hm : 0 < a-c := by linarith
|
| 376 |
+
have hh := tendsto_integral_of_dominated_convergence
|
| 377 |
+
(fun x => Real.exp (-(a-c)*x^2)+Real.exp (-(a+c)*x^2))
|
| 378 |
+
(F := fun N : ℕ => fun x => |gaussianTaylor a c N x-gaussMoment (a+c) 0 x|)
|
| 379 |
+
(f := fun _ => (0:ℝ))
|
| 380 |
+
(fun N => ((integrable_gaussianTaylor ha c N).sub (integrable_gaussMoment hp 0)).abs.aestronglyMeasurable)
|
| 381 |
+
(by simpa only [Pi.add_def,gaussMoment,pow_zero,one_mul] using
|
| 382 |
+
(integrable_gaussMoment hm 0).add (integrable_gaussMoment hp 0))
|
| 383 |
+
(fun N => Filter.Eventually.of_forall (fun x => by
|
| 384 |
+
rw [Real.norm_eq_abs,abs_abs]
|
| 385 |
+
have htri := norm_sub_le (gaussianTaylor a c N x) (gaussMoment (a+c) 0 x)
|
| 386 |
+
simp only [Real.norm_eq_abs,gaussMoment,pow_zero,one_mul,abs_of_pos (Real.exp_pos _)] at htri
|
| 387 |
+
simpa only [gaussMoment,pow_zero,one_mul] using
|
| 388 |
+
htri.trans (add_le_add (gaussianTaylor_bound a hc N x) le_rfl)))
|
| 389 |
+
(Filter.Eventually.of_forall (fun x => by
|
| 390 |
+
simpa using ((gaussianTaylor_tendsto a c x).sub_const (gaussMoment (a+c) 0 x)).abs))
|
| 391 |
+
simpa only [integral_zero] using hh
|
| 392 |
+
|
| 393 |
+
lemma toL1_finsetSum {ι : Type*} (s : Finset ι) (f : ι → ℝ → ℝ)
|
| 394 |
+
(hf : ∀ i, Integrable (f i)) :
|
| 395 |
+
(integrable_finsetSum s (fun i _ => hf i)).toL1 (fun x => ∑ i ∈ s, f i x) =
|
| 396 |
+
∑ i ∈ s, (hf i).toL1 (f i) := by
|
| 397 |
+
classical
|
| 398 |
+
induction s using Finset.induction_on with
|
| 399 |
+
| empty =>
|
| 400 |
+
simp only [Finset.sum_empty]
|
| 401 |
+
exact Integrable.toL1_zero _
|
| 402 |
+
| @insert i s hi ih =>
|
| 403 |
+
simp only [Finset.sum_insert hi]
|
| 404 |
+
change (((hf i).add (integrable_finsetSum s (fun j _ => hf j))).toL1
|
| 405 |
+
(f i+(fun x => ∑ j ∈ s, f j x))) = _
|
| 406 |
+
rw [Integrable.toL1_add _ _ (hf i)
|
| 407 |
+
(integrable_finsetSum s (fun j _ => hf j)),ih]
|
| 408 |
+
|
| 409 |
+
lemma toL1_tendsto_of_integral_abs_sub {f : ℕ → ℝ → ℝ} {g : ℝ → ℝ}
|
| 410 |
+
(hf : ∀ n, Integrable (f n)) (hg : Integrable g)
|
| 411 |
+
(ht : Tendsto (fun n => ∫ x : ℝ, |f n x-g x|) atTop (𝓝 0)) :
|
| 412 |
+
Tendsto (fun n => (hf n).toL1 (f n)) atTop (𝓝 (hg.toL1 g)) := by
|
| 413 |
+
apply tendsto_iff_norm_sub_tendsto_zero.mpr
|
| 414 |
+
have he (n : ℕ) : ‖(hf n).toL1 (f n)-hg.toL1 g‖ = ∫ x : ℝ, |f n x-g x| := by
|
| 415 |
+
change ‖((hf n).sub hg).toL1 (f n-g)‖ = _
|
| 416 |
+
exact norm_toL1_real _
|
| 417 |
+
simpa only [he] using ht
|
| 418 |
+
|
| 419 |
+
lemma gaussian_increment_mem {a c : ℝ} (ha : 0 < a) (hc : 0 ≤ c) (hca : c < a)
|
| 420 |
+
(S : Submodule ℝ (Lp ℝ 1 (volume : Measure ℝ)))
|
| 421 |
+
(hS : IsClosed (S : Set (Lp ℝ 1 (volume : Measure ℝ))))
|
| 422 |
+
(hbase : ∀ y, momentL1 a ha 0 y ∈ S) :
|
| 423 |
+
∀ y, momentL1 (a+c) (by linarith) 0 y ∈ S := by
|
| 424 |
+
intro y
|
| 425 |
+
have hm := momentL1_mem_of_gaussian ha S hS hbase
|
| 426 |
+
let fp : ℕ → ℝ → ℝ := fun N x => gaussianTaylor a c N (x+y)
|
| 427 |
+
have hfp (N : ℕ) : Integrable (fp N) := (integrable_gaussianTaylor ha c N).comp_add_right y
|
| 428 |
+
have hin (N : ℕ) : (hfp N).toL1 (fp N) ∈ S := by
|
| 429 |
+
have he : (hfp N).toL1 (fp N) =
|
| 430 |
+
∑ k ∈ Finset.range N, ((-c)^k/(Nat.factorial k:ℝ)) • momentL1 a ha (2*k) y := by
|
| 431 |
+
exact toL1_finsetSum (Finset.range N)
|
| 432 |
+
(fun k x => ((-c)^k/(Nat.factorial k:ℝ))*gaussMoment a (2*k) (x+y))
|
| 433 |
+
(fun k => ((integrable_gaussMoment ha (2*k)).comp_add_right y).const_mul _)
|
| 434 |
+
rw [he]
|
| 435 |
+
exact S.sum_mem (fun k _ => S.smul_mem _ (hm _ y))
|
| 436 |
+
have ht : Tendsto (fun N => ∫ x : ℝ,
|
| 437 |
+
|fp N x-gaussMoment (a+c) 0 (x+y)|) atTop (𝓝 0) := by
|
| 438 |
+
have he (N : ℕ) : (∫ x : ℝ, |fp N x-gaussMoment (a+c) 0 (x+y)|) =
|
| 439 |
+
∫ x : ℝ, |gaussianTaylor a c N x-gaussMoment (a+c) 0 x| :=
|
| 440 |
+
integral_add_right_eq_self (fun x => |gaussianTaylor a c N x-gaussMoment (a+c) 0 x|) y
|
| 441 |
+
simpa only [he] using gaussianTaylor_L1 ha hc hca
|
| 442 |
+
exact hS.mem_of_tendsto (toL1_tendsto_of_integral_abs_sub hfp
|
| 443 |
+
((integrable_gaussMoment (by linarith : 0 < a+c) 0).comp_add_right y) ht)
|
| 444 |
+
(Filter.Eventually.of_forall hin)
|
| 445 |
+
|
| 446 |
+
lemma gaussian_wider_precision_mem {a b : ℝ} (ha : 0 < a) (hab : a ≤ b)
|
| 447 |
+
(S : Submodule ℝ (Lp ℝ 1 (volume : Measure ℝ)))
|
| 448 |
+
(hS : IsClosed (S : Set (Lp ℝ 1 (volume : Measure ℝ))))
|
| 449 |
+
(hbase : ∀ y, momentL1 a ha 0 y ∈ S) :
|
| 450 |
+
∀ y, momentL1 b (ha.trans_le hab) 0 y ∈ S := by
|
| 451 |
+
obtain ⟨N,hN⟩ := exists_nat_gt ((b-a)/a+1)
|
| 452 |
+
have hN0 : (0:ℝ) < N := by
|
| 453 |
+
have : 0 ≤ (b-a)/a := div_nonneg (sub_nonneg.mpr hab) ha.le
|
| 454 |
+
linarith
|
| 455 |
+
let c : ℝ := (b-a)/N
|
| 456 |
+
have hc : 0 ≤ c := div_nonneg (sub_nonneg.mpr hab) hN0.le
|
| 457 |
+
have hca : c < a := by
|
| 458 |
+
apply (div_lt_iff₀ hN0).mpr
|
| 459 |
+
have : (b-a)/a < (N:ℝ) := by linarith
|
| 460 |
+
have := (div_lt_iff₀ ha).mp this
|
| 461 |
+
linarith
|
| 462 |
+
have hall (n : ℕ) : ∀ y, momentL1 (a+(n:ℝ)*c) (by positivity) 0 y ∈ S := by
|
| 463 |
+
induction n with
|
| 464 |
+
| zero => simpa only [Nat.cast_zero,zero_mul,add_zero] using hbase
|
| 465 |
+
| succ n ih =>
|
| 466 |
+
have hh := gaussian_increment_mem (show 0 < a+(n:ℝ)*c by positivity) hc
|
| 467 |
+
(show c < a+(n:ℝ)*c by have := mul_nonneg (Nat.cast_nonneg n) hc; linarith) S hS ih
|
| 468 |
+
have he : a+(↑(n+1):ℝ)*c=(a+(n:ℝ)*c)+c := by push_cast; ring
|
| 469 |
+
simpa only [he] using hh
|
| 470 |
+
have he : a+(N:ℝ)*c = b := by dsimp [c]; field_simp [ne_of_gt hN0]; ring
|
| 471 |
+
simpa only [he] using hall N
|
| 472 |
+
|
| 473 |
+
lemma gaussian_mem_closed_span {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (y : ℝ) :
|
| 474 |
+
momentL1 b (ha.trans_le hab) 0 y ∈
|
| 475 |
+
(Submodule.span ℝ (Set.range (momentL1 a ha 0))).topologicalClosure := by
|
| 476 |
+
apply gaussian_wider_precision_mem ha hab _
|
| 477 |
+
(Submodule.isClosed_topologicalClosure _) (fun z => ?_) y
|
| 478 |
+
exact Submodule.le_topologicalClosure _ (Submodule.subset_span ⟨z,rfl⟩)
|
| 479 |
+
|
| 480 |
+
theorem finite_gaussian_approximation {a b ε : ℝ} (ha : 0 < a) (hab : a ≤ b)
|
| 481 |
+
(hε : 0 < ε) :
|
| 482 |
+
∃ (s : Finset ℝ) (c : ℝ → ℝ),
|
| 483 |
+
(∫ x : ℝ, |gaussMoment b 0 x-
|
| 484 |
+
∑ y ∈ s, c y*gaussMoment a 0 (x+y)|) < ε := by
|
| 485 |
+
classical
|
| 486 |
+
have hm := gaussian_mem_closed_span ha hab 0
|
| 487 |
+
change momentL1 b (ha.trans_le hab) 0 0 ∈
|
| 488 |
+
closure (↑(Submodule.span ℝ (Set.range (momentL1 a ha 0))) : Set _) at hm
|
| 489 |
+
obtain ⟨w,hw,hclose⟩ := Metric.mem_closure_iff.mp hm ε hε
|
| 490 |
+
obtain ⟨c,rfl⟩ := Finsupp.mem_span_range_iff_exists_finsupp.mp hw
|
| 491 |
+
refine ⟨c.support,c,?_⟩
|
| 492 |
+
let f : ℝ → ℝ := fun x => ∑ y ∈ c.support, c y*gaussMoment a 0 (x+y)
|
| 493 |
+
have hf : Integrable f := integrable_finsetSum _ (fun y _ =>
|
| 494 |
+
((integrable_gaussMoment ha 0).comp_add_right y).const_mul (c y))
|
| 495 |
+
have hfL : hf.toL1 f = c.sum (fun y z => z • momentL1 a ha 0 y) :=
|
| 496 |
+
toL1_finsetSum c.support (fun y x => c y*gaussMoment a 0 (x+y))
|
| 497 |
+
(fun y => ((integrable_gaussMoment ha 0).comp_add_right y).const_mul (c y))
|
| 498 |
+
rw [dist_eq_norm,← hfL] at hclose
|
| 499 |
+
change ‖((((integrable_gaussMoment (ha.trans_le hab) 0).comp_add_right 0).sub hf).toL1
|
| 500 |
+
(fun x => gaussMoment b 0 (x+0)-f x))‖ < ε at hclose
|
| 501 |
+
rw [norm_toL1_real] at hclose
|
| 502 |
+
simpa only [add_zero] using hclose
|
| 503 |
+
|
| 504 |
+
end SKGapCutoff.Clock
|
| 505 |
+
|
| 506 |
+
open MeasureTheory Filter ProbabilityTheory
|
| 507 |
+
open scoped Topology NNReal ENNReal
|
| 508 |
+
|
| 509 |
+
end
|
| 510 |
+
|
| 511 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianCompactTailRate.lean
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.ScalarEmpirical
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.SquareTail
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set Filter
|
| 10 |
+
open scoped NNReal ENNReal Topology
|
| 11 |
+
noncomputable section
|
| 12 |
+
open Real Set
|
| 13 |
+
noncomputable section
|
| 14 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 15 |
+
open scoped Topology NNReal ENNReal BoundedContinuousFunction
|
| 16 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 17 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 18 |
+
noncomputable section
|
| 19 |
+
open Set Filter Topology
|
| 20 |
+
noncomputable section
|
| 21 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 22 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 23 |
+
noncomputable section
|
| 24 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 25 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 26 |
+
noncomputable section
|
| 27 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 28 |
+
open scoped NNReal ENNReal
|
| 29 |
+
noncomputable section
|
| 30 |
+
open MeasureTheory ProbabilityTheory Real Filter Set
|
| 31 |
+
open scoped Topology NNReal ENNReal BoundedContinuousFunction
|
| 32 |
+
namespace SKGap
|
| 33 |
+
|
| 34 |
+
theorem gaussian_compact_tail_rate {X : Type*} [TopologicalSpace X] {K : Set X}
|
| 35 |
+
(hK : IsCompact K) {P : X → ProbabilityMeasure ℝ} {d s ψ : X → ℝ}
|
| 36 |
+
(hP : ContinuousOn P K) (hd : ContinuousOn d K) (hs : ContinuousOn s K)
|
| 37 |
+
(hψ : ContinuousOn ψ K) (hpos : ∀ x ∈ K, 0 < s x) (R : ℝ)
|
| 38 |
+
{α ν : ℝ} (hα : 0 < α) (hν : 0 < ν)
|
| 39 |
+
(hαs : ∀ x ∈ K, α < 1/(4*s x))
|
| 40 |
+
(hW : ∀ ε > 0, ∀ x ∈ K, ∃ f : ℝ →ᵇ ℝ, ψ x-(∫ y, f y ∂P x)+
|
| 41 |
+
log (∫ y, exp (f y) ∂gaussianReal (d x) (s x).toNNReal) < ε) :
|
| 42 |
+
∃ R₁ : ℝ, ∃ N : ℕ, ∀ n ≥ N, ∀ hn : 0 < n, ∀ z : (Fin n → ℝ) → X,
|
| 43 |
+
∀ E : Set (Fin n → ℝ), MeasurableSet E →
|
| 44 |
+
(∀ y ∈ E, z y ∈ K) →
|
| 45 |
+
(∀ y ∈ E, P (z y) = @empiricalLaw (Fin n) _ ⟨⟨0,hn⟩⟩ y) →
|
| 46 |
+
(∀ y ∈ E, ∑ i, (y i)^2 ≤ (n:ℝ)*R) →
|
| 47 |
+
(∀ y ∈ E, (n:ℝ)*ν ≤ ∑ i, squareTail R₁ (y i)) →
|
| 48 |
+
(∫⁻ y in E, ENNReal.ofReal (exp ((n:ℝ)*ψ (z y))*productNormal (d (z y)) (s (z y)) y)) ≤
|
| 49 |
+
ENNReal.ofReal (exp (-(α*ν/2)*(n:ℝ))) := by
|
| 50 |
+
classical
|
| 51 |
+
have hav : 0 < α*ν := mul_pos hα hν
|
| 52 |
+
obtain ⟨C,f,hC⟩ := finite_gaussian_test_cover hK hP hd hs hψ hpos R (α*ν/8)
|
| 53 |
+
(hW _ (by positivity))
|
| 54 |
+
have hinc (x : K) : ∀ᶠ r : ℝ in atTop,
|
| 55 |
+
log (∫ y, exp (f x y+α*squareTail r y) ∂gaussianReal (d x) (s x).toNNReal) ≤
|
| 56 |
+
log (∫ y, exp (f x y) ∂gaussianReal (d x) (s x).toNNReal)+α*ν/8 := by
|
| 57 |
+
have hp : (0:ℝ≥0) < (s x).toNNReal := Real.toNNReal_pos.mpr (hpos x x.2)
|
| 58 |
+
have ha : α < 1/(4*((s x).toNNReal:ℝ)) := by
|
| 59 |
+
simpa only [Real.coe_toNNReal _ (hpos x x.2).le] using hαs x x.2
|
| 60 |
+
have h := (tendsto_gaussian_tail_tilt (f x) (d := d x) hp hα.le ha).log
|
| 61 |
+
(tiltedNormal_mass_pos (f x) (d x) (s x).toNNReal).ne'
|
| 62 |
+
exact (h.eventually_lt_const (by linarith :
|
| 63 |
+
log (∫ y, exp (f x y) ∂gaussianReal (d x) (s x).toNNReal) <
|
| 64 |
+
log (∫ y, exp (f x y) ∂gaussianReal (d x) (s x).toNNReal)+α*ν/8)).mono
|
| 65 |
+
(fun _ hr => hr.le)
|
| 66 |
+
have hall : ∀ᶠ r : ℝ in atTop, ∀ x ∈ C,
|
| 67 |
+
log (∫ y, exp (f x y+α*squareTail r y) ∂gaussianReal (d x) (s x).toNNReal) ≤
|
| 68 |
+
log (∫ y, exp (f x y) ∂gaussianReal (d x) (s x).toNNReal)+α*ν/8 :=
|
| 69 |
+
(eventually_all_finset C).mpr (fun x _ => hinc x)
|
| 70 |
+
obtain ⟨R₁,hR₁⟩ := hall.exists
|
| 71 |
+
obtain ⟨N,hN⟩ := absorb_finite_exponential_factor C.card (show 0 < α*ν/4 by positivity)
|
| 72 |
+
refine ⟨R₁,N,?_⟩
|
| 73 |
+
intro n hn hn' z E hE hz hemp hmom htail
|
| 74 |
+
let : Nonempty (Fin n) := ⟨⟨0,hn'⟩⟩
|
| 75 |
+
have hh := gaussian_covered_tail_laplace C f (fun x : K => d x) (fun x : K => s x)
|
| 76 |
+
(fun x _ => hpos x x.2) (fun y => d (z y)) (fun y => s (z y)) (fun y => ψ (z y))
|
| 77 |
+
R (α*ν/8) (α*ν/8) α ν R₁ hα.le hE (fun y hy => hpos (z y) (hz y hy))
|
| 78 |
+
(by simpa only [Fintype.card_fin] using hmom) (by simpa only [Fintype.card_fin] using htail)
|
| 79 |
+
(fun x _ => integrable_gaussian_tail_test (f x) (Real.toNNReal_pos.mpr (hpos x x.2)) hα.le
|
| 80 |
+
(by simpa only [Real.coe_toNNReal _ (hpos x x.2).le] using hαs x x.2) R₁)
|
| 81 |
+
hR₁ (fun y hy => by
|
| 82 |
+
obtain ⟨x,hx,hcx⟩ := hC (z y) (hz y hy)
|
| 83 |
+
rw [hemp y hy] at hcx
|
| 84 |
+
exact ⟨x,hx,hcx⟩)
|
| 85 |
+
simp only [Fintype.card_fin] at hh
|
| 86 |
+
refine hh.trans (ENNReal.ofReal_le_ofReal ?_)
|
| 87 |
+
convert hN n hn (α*ν/8+α*ν/8-α*ν) using 1
|
| 88 |
+
congr 1
|
| 89 |
+
ring
|
| 90 |
+
|
| 91 |
+
end SKGap
|
| 92 |
+
|
| 93 |
+
namespace SKGap
|
| 94 |
+
lemma squareTail_antitone {R₁ R₂ : ℝ} (hR : R₁ ≤ R₂) (y : ℝ) :
|
| 95 |
+
squareTail R₂ y ≤ squareTail R₁ y := by
|
| 96 |
+
unfold squareTail
|
| 97 |
+
split_ifs <;> try positivity
|
| 98 |
+
· exact le_rfl
|
| 99 |
+
· exact (not_lt_of_ge hR (lt_of_lt_of_le (by assumption) (le_of_not_gt (by assumption)))).elim
|
| 100 |
+
|
| 101 |
+
theorem scalar_rate_iv {j t₀ T ν : ℝ} (hj : 0 < j) (hj1 : j < 1)
|
| 102 |
+
(ht₀ : 0 < t₀) (hT : t₀ ≤ T) (hν : 0 < ν) :
|
| 103 |
+
∃ R₁ : ℝ, ∃ a > 0, ∃ N : ℕ, ∀ R₂ ≥ R₁, ∀ n ≥ N, ∀ hn : 0 < n,
|
| 104 |
+
∀ t ∈ Icc t₀ T, ∀ σ ∈ Icc 0 1,
|
| 105 |
+
∀ E : Set (Fin n → ℝ), MeasurableSet E →
|
| 106 |
+
(∀ y ∈ E, (n:ℝ)*ν ≤ ∑ i, squareTail R₂ (y i)) →
|
| 107 |
+
(∫⁻ y in E, ENNReal.ofReal (@scalarIntegrand (Fin n) _ ⟨⟨0,hn⟩⟩ j t σ y)) ≤
|
| 108 |
+
ENNReal.ofReal (exp (-a*(n:ℝ))) := by
|
| 109 |
+
have hT0 : 0 ≤ T := ht₀.le.trans hT
|
| 110 |
+
obtain ⟨R,hR,hTail⟩ := scalar_uniform_tail hj.le hT0 ht₀ 1
|
| 111 |
+
let K := scalarBox j R T t₀
|
| 112 |
+
let α := 1/(8*(T+1+j))
|
| 113 |
+
have hα : 0 < α := by dsimp [α]; positivity
|
| 114 |
+
have hs (p : ScalarPoint) (hp : p ∈ K) : 0 < scalarS j p := ht₀.trans_le hp.2
|
| 115 |
+
have hmom : K ⊆ scalarMomentDomain R := fun _ hp => ⟨hp.1.1,mem_univ _⟩
|
| 116 |
+
have hαs (p : ScalarPoint) (hp : p ∈ K) : α < 1/(4*scalarS j p) := by
|
| 117 |
+
have hq := (scalarQMoment_bounds p.1).2
|
| 118 |
+
have hz := hp.1.2.2
|
| 119 |
+
have ht := hp.1.2.1
|
| 120 |
+
have hsup : scalarS j p ≤ T+1+j := by
|
| 121 |
+
unfold scalarS
|
| 122 |
+
have hmul := mul_le_mul_of_nonneg_left hq hj.le
|
| 123 |
+
nlinarith [sq_nonneg p.2.2,hz.1,hz.2,ht.2]
|
| 124 |
+
have hsp := hs p hp
|
| 125 |
+
dsimp [α]
|
| 126 |
+
apply one_div_lt_one_div_of_lt (by positivity : 0 < 4*scalarS j p)
|
| 127 |
+
nlinarith [hs p hp]
|
| 128 |
+
obtain ⟨R₁,N,hN⟩ := gaussian_compact_tail_rate (isCompact_scalarBox j R T t₀)
|
| 129 |
+
(P := fun p : ScalarPoint => p.1) continuous_fst.continuousOn
|
| 130 |
+
(continuous_scalarD j).continuousOn (continuous_scalarS j).continuousOn
|
| 131 |
+
(continuousOn_scalarPsi_of_pos hj.le hR.le hmom hs) hs R hα hν hαs
|
| 132 |
+
(fun ε hε p hp => scalar_weak_test (hmom hp) hj hj1 hp.1.2.1.1 (hs p hp) hε)
|
| 133 |
+
let b := min (α*ν/2) 1
|
| 134 |
+
have hb : 0 < b := lt_min (by positivity) zero_lt_one
|
| 135 |
+
obtain ⟨M,hM⟩ := absorb_finite_exponential_factor 2 (half_pos hb)
|
| 136 |
+
refine ⟨R₁,b/2,half_pos hb,max N M,?_⟩
|
| 137 |
+
intro R₂ hR₂ n hn hn' t ht σ hσ E hE htail
|
| 138 |
+
let : Nonempty (Fin n) := ⟨⟨0,hn'⟩⟩
|
| 139 |
+
have hsE (y : Fin n → ℝ) : t₀ ≤ scalarS j (scalarEmpirical y t σ) := by
|
| 140 |
+
unfold scalarS scalarEmpirical
|
| 141 |
+
dsimp only
|
| 142 |
+
have hq := mul_nonneg hj.le (scalarQMoment_bounds (empiricalLaw y)).1
|
| 143 |
+
nlinarith [sq_nonneg σ,ht.1]
|
| 144 |
+
let B : Set (Fin n → ℝ) := {y | ∑ i, (y i)^2 ≤ (n:ℝ)*R}
|
| 145 |
+
have hB : MeasurableSet B := isClosed_le (by fun_prop) continuous_const |>.measurableSet
|
| 146 |
+
have hc := hN n (le_trans (le_max_left _ _) hn) hn' (fun y => scalarEmpirical y t σ)
|
| 147 |
+
(E ∩ B) (hE.inter hB) (fun y hy => ⟨⟨empirical_momentBall y hR.le
|
| 148 |
+
(by simpa only [Fintype.card_fin] using (show ∑ i, (y i)^2 ≤ (n:ℝ)*R from hy.2)),
|
| 149 |
+
⟨ht₀.le.trans ht.1,ht.2⟩,hσ⟩,hsE y⟩) (fun _ _ => rfl) (fun _ hy => hy.2)
|
| 150 |
+
(fun y hy => (htail y hy.1).trans (Finset.sum_le_sum (fun i _ => squareTail_antitone hR₂ (y i))))
|
| 151 |
+
have hc' : (∫⁻ y in E ∩ B, ENNReal.ofReal (scalarIntegrand j t σ y)) ≤
|
| 152 |
+
ENNReal.ofReal (exp (-b*(n:ℝ))) := by
|
| 153 |
+
have hab : exp (-(α*ν/2)*(n:ℝ)) ≤ exp (-b*(n:ℝ)) := exp_le_exp.mpr (by
|
| 154 |
+
have hh := mul_le_mul_of_nonneg_right (min_le_left (α*ν/2) 1) (Nat.cast_nonneg (α := ℝ) n)
|
| 155 |
+
dsimp [b]; linarith only [hh])
|
| 156 |
+
simpa only [scalarIntegrand,Fintype.card_fin] using hc.trans (ENNReal.ofReal_le_ofReal hab)
|
| 157 |
+
have htail' := hTail n hn' t ⟨ht₀.le.trans ht.1,ht.2⟩ σ hσ (E ∩ Bᶜ) (hE.inter hB.compl)
|
| 158 |
+
(fun y _ => hsE y) (fun _ hy => le_of_lt (not_le.mp hy.2))
|
| 159 |
+
have he : exp (-(1:ℝ)*(n:ℝ)) ≤ exp (-b*(n:ℝ)) := exp_le_exp.mpr (by
|
| 160 |
+
have hh := mul_le_mul_of_nonneg_right (min_le_right (α*ν/2) 1) (Nat.cast_nonneg (α := ℝ) n)
|
| 161 |
+
dsimp [b]; linarith only [hh])
|
| 162 |
+
have htotal := (lintegral_split_le volume (fun y => ENNReal.ofReal (scalarIntegrand j t σ y)) E B).trans
|
| 163 |
+
(add_le_add hc' (htail'.trans (ENNReal.ofReal_le_ofReal he)))
|
| 164 |
+
have hadd : ENNReal.ofReal (exp (-b*(n:ℝ)))+ENNReal.ofReal (exp (-b*(n:ℝ))) =
|
| 165 |
+
ENNReal.ofReal (2*exp ((n:ℝ)*(-b))) := by
|
| 166 |
+
rw [← ENNReal.ofReal_add (exp_pos _).le (exp_pos _).le]
|
| 167 |
+
congr 1
|
| 168 |
+
ring_nf
|
| 169 |
+
rw [hadd] at htotal
|
| 170 |
+
refine htotal.trans (ENNReal.ofReal_le_ofReal ?_)
|
| 171 |
+
convert hM n (le_trans (le_max_right _ _) hn) (-b) using 1
|
| 172 |
+
congr 1
|
| 173 |
+
ring
|
| 174 |
+
|
| 175 |
+
end SKGap
|
| 176 |
+
end
|
| 177 |
+
end
|
| 178 |
+
end
|
| 179 |
+
end
|
| 180 |
+
end
|
| 181 |
+
end
|
| 182 |
+
end
|
| 183 |
+
end
|
| 184 |
+
end
|
| 185 |
+
|
| 186 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianCoordinateMemLp.lean
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Matrix.MatrixCoordinates
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 9 |
+
open scoped NNReal ENNReal
|
| 10 |
+
open Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
open Matrix Real
|
| 14 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 15 |
+
noncomputable section
|
| 16 |
+
open Matrix Real
|
| 17 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 18 |
+
noncomputable section
|
| 19 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 20 |
+
open MeasureTheory.Measure
|
| 21 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 22 |
+
open MeasureTheory
|
| 23 |
+
noncomputable section
|
| 24 |
+
noncomputable section
|
| 25 |
+
open MeasureTheory Set NormedSpace
|
| 26 |
+
open scoped Topology
|
| 27 |
+
noncomputable section
|
| 28 |
+
open Matrix Real
|
| 29 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 30 |
+
noncomputable section
|
| 31 |
+
open Set Real
|
| 32 |
+
open scoped Topology
|
| 33 |
+
noncomputable section
|
| 34 |
+
open Matrix Set Filter
|
| 35 |
+
open scoped Topology Matrix.Norms.Frobenius
|
| 36 |
+
noncomputable section
|
| 37 |
+
open Matrix NormedSpace ContinuousLinearMap
|
| 38 |
+
open scoped Matrix.Norms.Frobenius
|
| 39 |
+
noncomputable section
|
| 40 |
+
open Matrix
|
| 41 |
+
namespace SKGap
|
| 42 |
+
open MeasureTheory ProbabilityTheory Real
|
| 43 |
+
open scoped ENNReal NNReal
|
| 44 |
+
variable {ι : Type*} [Fintype ι]
|
| 45 |
+
|
| 46 |
+
lemma gaussianCoordinate_memLp (a : MatrixCoordinates ι) :
|
| 47 |
+
MemLp (fun g : MatrixCoordinates ι → ℝ => g a) 2
|
| 48 |
+
(Measure.pi (fun _ => gaussianReal 0 1)) := by
|
| 49 |
+
exact (IsGaussian.memLp_id (gaussianReal 0 1) 2 (by norm_num)).comp_measurePreserving
|
| 50 |
+
(measurePreserving_eval (fun _ : MatrixCoordinates ι => gaussianReal 0 1) a)
|
| 51 |
+
|
| 52 |
+
lemma gaussianCoordinate_integral_sq (a : MatrixCoordinates ι) :
|
| 53 |
+
(∫ g : MatrixCoordinates ι → ℝ, (g a)^2 ∂Measure.pi (fun _ => gaussianReal 0 1)) = 1 := by
|
| 54 |
+
rw [integral_comp_eval (μ := fun _ : MatrixCoordinates ι => gaussianReal 0 1) (i := a) (by fun_prop : AEStronglyMeasurable (fun x : ℝ => x^2) (gaussianReal 0 1))]
|
| 55 |
+
have hh := variance_fun_id_gaussianReal (μ := 0) (v := 1)
|
| 56 |
+
rw [variance_eq_integral (by fun_prop),integral_id_gaussianReal] at hh
|
| 57 |
+
simpa only [sub_zero,NNReal.coe_one] using hh
|
| 58 |
+
|
| 59 |
+
lemma goeEntry_memLp (r : ℝ) (i b : ι) :
|
| 60 |
+
MemLp (fun g => goeMatrix r g i b) 2
|
| 61 |
+
(Measure.pi (fun _ : MatrixCoordinates ι => gaussianReal 0 1)) := by
|
| 62 |
+
exact ((gaussianCoordinate_memLp (.inl (i,b))).add
|
| 63 |
+
(gaussianCoordinate_memLp (.inl (b,i)))).const_mul _
|
| 64 |
+
|
| 65 |
+
lemma goeEntry_integral_sq_le {r : ℝ} (hr : 0 ≤ r) (i b : ι) :
|
| 66 |
+
(∫ g, (goeMatrix r g i b)^2
|
| 67 |
+
∂Measure.pi (fun _ : MatrixCoordinates ι => gaussianReal 0 1)) ≤ 2*r := by
|
| 68 |
+
let μ := Measure.pi (fun _ : MatrixCoordinates ι => gaussianReal 0 1)
|
| 69 |
+
have h1 := (gaussianCoordinate_memLp (.inl (i,b))).integrable_sq
|
| 70 |
+
have h2 := (gaussianCoordinate_memLp (.inl (b,i))).integrable_sq
|
| 71 |
+
have hb (g : MatrixCoordinates ι → ℝ) : (goeMatrix r g i b)^2 ≤
|
| 72 |
+
r*((g (.inl (i,b)))^2+(g (.inl (b,i)))^2) := by
|
| 73 |
+
have hx : (g (.inl (i,b))+g (.inl (b,i)))^2 ≤
|
| 74 |
+
2*((g (.inl (i,b)))^2+(g (.inl (b,i)))^2) := by
|
| 75 |
+
nlinarith only [sq_nonneg (g (.inl (i,b))-g (.inl (b,i)))]
|
| 76 |
+
simp only [goeMatrix,mul_pow]
|
| 77 |
+
calc
|
| 78 |
+
_ ≤ (sqrt (2*r)/2)^2*(2*((g (.inl (i,b)))^2+(g (.inl (b,i)))^2)) :=
|
| 79 |
+
mul_le_mul_of_nonneg_left hx (sq_nonneg _)
|
| 80 |
+
_ = _ := by rw [div_pow,sq_sqrt (by positivity)]; ring
|
| 81 |
+
calc
|
| 82 |
+
_ ≤ ∫ g, r*((g (.inl (i,b)))^2+(g (.inl (b,i)))^2) ∂μ :=
|
| 83 |
+
integral_mono (goeEntry_memLp r i b).integrable_sq ((h1.add h2).const_mul r) hb
|
| 84 |
+
_ = 2*r := by
|
| 85 |
+
rw [integral_const_mul,integral_add h1 h2,gaussianCoordinate_integral_sq,
|
| 86 |
+
gaussianCoordinate_integral_sq]
|
| 87 |
+
ring
|
| 88 |
+
|
| 89 |
+
end SKGap
|
| 90 |
+
|
| 91 |
+
noncomputable section
|
| 92 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 93 |
+
open scoped ENNReal NNReal
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
end
|
| 97 |
+
end
|
| 98 |
+
end
|
| 99 |
+
end
|
| 100 |
+
end
|
| 101 |
+
end
|
| 102 |
+
end
|
| 103 |
+
end
|
| 104 |
+
end
|
| 105 |
+
end
|
| 106 |
+
end
|
| 107 |
+
end
|
| 108 |
+
|
| 109 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianCoordinates.lean
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.FiniteMax
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 9 |
+
open scoped NNReal ENNReal
|
| 10 |
+
open Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
open Matrix Real
|
| 14 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 15 |
+
noncomputable section
|
| 16 |
+
open Matrix Real
|
| 17 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 18 |
+
noncomputable section
|
| 19 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 20 |
+
open MeasureTheory.Measure
|
| 21 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 22 |
+
open MeasureTheory
|
| 23 |
+
noncomputable section
|
| 24 |
+
noncomputable section
|
| 25 |
+
open MeasureTheory Set NormedSpace
|
| 26 |
+
open scoped Topology
|
| 27 |
+
noncomputable section
|
| 28 |
+
open Matrix Real
|
| 29 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 30 |
+
noncomputable section
|
| 31 |
+
open Set Real
|
| 32 |
+
open scoped Topology
|
| 33 |
+
noncomputable section
|
| 34 |
+
open Matrix Set Filter
|
| 35 |
+
open scoped Topology Matrix.Norms.Frobenius
|
| 36 |
+
noncomputable section
|
| 37 |
+
open Matrix NormedSpace ContinuousLinearMap
|
| 38 |
+
open scoped Matrix.Norms.Frobenius
|
| 39 |
+
noncomputable section
|
| 40 |
+
open Matrix
|
| 41 |
+
noncomputable section
|
| 42 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 43 |
+
open scoped ENNReal NNReal
|
| 44 |
+
noncomputable section
|
| 45 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 46 |
+
open scoped NNReal ENNReal
|
| 47 |
+
namespace SKGap
|
| 48 |
+
section ArbitraryCoordinates
|
| 49 |
+
variable {I κ : Type*} [TopologicalSpace I] [CompactSpace I] [Nonempty I]
|
| 50 |
+
[Fintype κ]
|
| 51 |
+
|
| 52 |
+
def gaussianCoordinates (κ : Type*) [Fintype κ] : Measure (κ → ℝ) :=
|
| 53 |
+
Measure.pi (fun _ => gaussianReal 0 1)
|
| 54 |
+
|
| 55 |
+
instance : IsProbabilityMeasure (gaussianCoordinates κ) := by
|
| 56 |
+
unfold gaussianCoordinates
|
| 57 |
+
infer_instance
|
| 58 |
+
|
| 59 |
+
def gaussianAffine (m : I → ℝ) (a : I → κ → ℝ) (z : κ → ℝ) (i : I) : ℝ :=
|
| 60 |
+
m i + ∑ k, a i k * z k
|
| 61 |
+
|
| 62 |
+
def gaussianSup (m : I → ℝ) (a : I → κ → ℝ) (z : κ → ℝ) : ℝ :=
|
| 63 |
+
sSup (Set.range (gaussianAffine m a z))
|
| 64 |
+
|
| 65 |
+
omit [CompactSpace I] [Nonempty I] in
|
| 66 |
+
theorem continuous_gaussianAffine {m : I → ℝ} {a : I → κ → ℝ}
|
| 67 |
+
(hm : Continuous m) (ha : Continuous a) (z : κ → ℝ) :
|
| 68 |
+
Continuous (gaussianAffine m a z) :=
|
| 69 |
+
hm.add (continuous_finsetSum _ (fun k _ =>
|
| 70 |
+
((continuous_apply k).comp ha).mul continuous_const))
|
| 71 |
+
|
| 72 |
+
theorem gaussianSup_attained {m : I → ℝ} {a : I → κ → ℝ}
|
| 73 |
+
(hm : Continuous m) (ha : Continuous a) (z : κ → ℝ) :
|
| 74 |
+
∃ i, gaussianSup m a z = gaussianAffine m a z i ∧
|
| 75 |
+
∀ j, gaussianAffine m a z j ≤ gaussianAffine m a z i := by
|
| 76 |
+
obtain ⟨i, _, he, hi⟩ := isCompact_univ.exists_sSup_image_eq_and_ge
|
| 77 |
+
Set.univ_nonempty (continuous_gaussianAffine hm ha z).continuousOn
|
| 78 |
+
exact ⟨i, by simpa [gaussianSup] using he, fun j => hi j (Set.mem_univ _)⟩
|
| 79 |
+
|
| 80 |
+
theorem gaussianSup_le {m : I → ℝ} {a : I → κ → ℝ}
|
| 81 |
+
(hm : Continuous m) (ha : Continuous a) (z : κ → ℝ) {c : ℝ}
|
| 82 |
+
(hc : ∀ i, gaussianAffine m a z i ≤ c) : gaussianSup m a z ≤ c := by
|
| 83 |
+
obtain ⟨i, he, _⟩ := gaussianSup_attained hm ha z
|
| 84 |
+
rw [he]
|
| 85 |
+
exact hc i
|
| 86 |
+
|
| 87 |
+
omit [Nonempty I] in
|
| 88 |
+
theorem continuous_gaussianSup {m : I → ℝ} {a : I → κ → ℝ}
|
| 89 |
+
(hm : Continuous m) (ha : Continuous a) : Continuous (gaussianSup m a) := by
|
| 90 |
+
have hc : Continuous (fun p : (κ → ℝ) × I => gaussianAffine m a p.1 p.2) := by
|
| 91 |
+
exact (hm.comp continuous_snd).add (continuous_finsetSum _ (fun k _ =>
|
| 92 |
+
(((continuous_apply k).comp ha).comp continuous_snd).mul
|
| 93 |
+
((continuous_apply k).comp continuous_fst)))
|
| 94 |
+
change Continuous (fun z => sSup (Set.range (gaussianAffine m a z)))
|
| 95 |
+
simpa only [Set.image_univ] using isCompact_univ.continuous_sSup hc
|
| 96 |
+
|
| 97 |
+
theorem integrable_gaussianSup {m : I → ℝ} {a : I → κ → ℝ}
|
| 98 |
+
(hm : Continuous m) (ha : Continuous a) :
|
| 99 |
+
Integrable (gaussianSup m a) (gaussianCoordinates κ) := by
|
| 100 |
+
obtain ⟨M, hM⟩ := isCompact_univ.exists_bound_of_continuousOn hm.continuousOn
|
| 101 |
+
obtain ⟨A, hA⟩ := isCompact_univ.exists_bound_of_continuousOn ha.continuousOn
|
| 102 |
+
have hMb : ∀ i, |m i| ≤ M := fun i => by
|
| 103 |
+
simpa only [Real.norm_eq_abs] using hM i (Set.mem_univ _)
|
| 104 |
+
have hAb : ∀ i k, |a i k| ≤ A := by
|
| 105 |
+
intro i k
|
| 106 |
+
have hk : |a i k| ≤ ‖a i‖ := by
|
| 107 |
+
simpa only [Real.norm_eq_abs] using norm_le_pi_norm (a i) k
|
| 108 |
+
exact hk.trans (hA i (Set.mem_univ _))
|
| 109 |
+
apply ((integrable_const M).add ((integrable_finsetSum (Finset.univ : Finset κ) (fun k _ =>
|
| 110 |
+
((integrable_eval (i := k) IsGaussian.integrable_id).norm))).const_mul A)).mono'
|
| 111 |
+
(continuous_gaussianSup hm ha).aestronglyMeasurable
|
| 112 |
+
apply Filter.Eventually.of_forall
|
| 113 |
+
intro z
|
| 114 |
+
obtain ⟨i, he, _⟩ := gaussianSup_attained hm ha z
|
| 115 |
+
rw [he, Real.norm_eq_abs]
|
| 116 |
+
change |gaussianAffine m a z i| ≤ M + A * ∑ k, |z k|
|
| 117 |
+
calc
|
| 118 |
+
_ ≤ |m i| + |∑ k, a i k * z k| := abs_add_le _ _
|
| 119 |
+
_ ≤ M + ∑ k, |a i k * z k| :=
|
| 120 |
+
add_le_add (hMb i) (Finset.abs_sum_le_sum_abs _ _)
|
| 121 |
+
_ ≤ M + ∑ k, A * |z k| := by
|
| 122 |
+
gcongr with k
|
| 123 |
+
rw [abs_mul]
|
| 124 |
+
exact mul_le_mul_of_nonneg_right (hAb i k) (abs_nonneg _)
|
| 125 |
+
_ = _ := by rw [Finset.mul_sum]
|
| 126 |
+
|
| 127 |
+
theorem gaussianSup_comparison [Nonempty κ] {m : I → ℝ} {a b : I → κ → ℝ}
|
| 128 |
+
(hm : Continuous m) (ha : Continuous a) (hb : Continuous b)
|
| 129 |
+
(horth : ∀ i j, ∑ k, (a i k - a j k) * (b i k - b j k) = 0)
|
| 130 |
+
(hinc : ∀ i j, (∑ k, (b i k - b j k)^2) ≤ ∑ k, (a i k - a j k)^2) :
|
| 131 |
+
(∫ z, gaussianSup m b z ∂gaussianCoordinates κ) ≤
|
| 132 |
+
∫ z, gaussianSup m a z ∂gaussianCoordinates κ := by
|
| 133 |
+
obtain ⟨n, hn⟩ := Nat.exists_eq_succ_of_ne_zero (Fintype.card_ne_zero (α := κ))
|
| 134 |
+
let e : Fin (n + 1) ≃ κ := (finCongr hn.symm).trans (Fintype.equivFin κ).symm
|
| 135 |
+
let E := MeasurableEquiv.piCongrLeft (fun _ : κ => ℝ) e
|
| 136 |
+
let a' : I → Fin (n + 1) → ℝ := fun i k => a i (e k)
|
| 137 |
+
let b' : I → Fin (n + 1) → ℝ := fun i k => b i (e k)
|
| 138 |
+
have ha' : Continuous a' := continuous_pi (fun k => (continuous_apply (e k)).comp ha)
|
| 139 |
+
have hb' : Continuous b' := continuous_pi (fun k => (continuous_apply (e k)).comp hb)
|
| 140 |
+
have he (f : κ → ℝ) : ∑ k : Fin (n + 1), f (e k) = ∑ k : κ, f k := e.sum_comp f
|
| 141 |
+
have horth' (i j : I) : ∑ k, (a' i k - a' j k) * (b' i k - b' j k) = 0 := by
|
| 142 |
+
dsimp [a', b']
|
| 143 |
+
rw [he (fun k => (a i k - a j k) * (b i k - b j k))]
|
| 144 |
+
exact horth i j
|
| 145 |
+
have hinc' (i j : I) : (∑ k, (b' i k - b' j k)^2) ≤ ∑ k, (a' i k - a' j k)^2 := by
|
| 146 |
+
dsimp [a', b']
|
| 147 |
+
rw [he (fun k => (b i k - b j k)^2), he (fun k => (a i k - a j k)^2)]
|
| 148 |
+
exact hinc i j
|
| 149 |
+
have hpres : MeasurePreserving E (standardGaussianProduct (n + 1)) (gaussianCoordinates κ) :=
|
| 150 |
+
measurePreserving_piCongrLeft (fun _ => gaussianReal 0 1) e
|
| 151 |
+
have hpoint (c : I → κ → ℝ) (z : Fin (n + 1) → ℝ) :
|
| 152 |
+
gaussianSup m c (E z) = supProcess m (fun i k => c i (e k)) z := by
|
| 153 |
+
unfold gaussianSup supProcess
|
| 154 |
+
congr 1
|
| 155 |
+
congr 1
|
| 156 |
+
funext i
|
| 157 |
+
dsimp [gaussianAffine, affineProcess]
|
| 158 |
+
rw [← he (fun k => c i k * E z k)]
|
| 159 |
+
simp [E, MeasurableEquiv.piCongrLeft, Equiv.piCongrLeft]
|
| 160 |
+
rw [← hpres.integral_comp' (gaussianSup m b), ← hpres.integral_comp' (gaussianSup m a)]
|
| 161 |
+
simp_rw [hpoint]
|
| 162 |
+
exact gaussian_supProcess_comparison hm ha' hb' horth' hinc'
|
| 163 |
+
|
| 164 |
+
end ArbitraryCoordinates
|
| 165 |
+
end SKGap
|
| 166 |
+
|
| 167 |
+
noncomputable section
|
| 168 |
+
open scoped BigOperators
|
| 169 |
+
open MeasureTheory ProbabilityTheory
|
| 170 |
+
|
| 171 |
+
end
|
| 172 |
+
end
|
| 173 |
+
end
|
| 174 |
+
end
|
| 175 |
+
end
|
| 176 |
+
end
|
| 177 |
+
end
|
| 178 |
+
end
|
| 179 |
+
end
|
| 180 |
+
end
|
| 181 |
+
end
|
| 182 |
+
end
|
| 183 |
+
end
|
| 184 |
+
end
|
| 185 |
+
end
|
| 186 |
+
|
| 187 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianDisintegration.lean
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory Matrix
|
| 10 |
+
open scoped BigOperators ENNReal
|
| 11 |
+
namespace SKGap.GaussianRegression
|
| 12 |
+
|
| 13 |
+
lemma residual_joint_gaussian {Ω ι κ : Type*} [MeasurableSpace Ω]
|
| 14 |
+
[Fintype ι] [Fintype κ] {P : Measure Ω} {X : Ω → ι → ℝ} {Y : Ω → κ → ℝ}
|
| 15 |
+
(hXY : HasGaussianLaw (fun w => (X w,Y w)) P) (K : Matrix ι κ ℝ) :
|
| 16 |
+
HasGaussianLaw (fun w => (X w-K*ᵥ Y w,Y w)) P :=
|
| 17 |
+
hXY.map_fun (((ContinuousLinearMap.fst ℝ (ι → ℝ) (κ → ℝ))-
|
| 18 |
+
(matrixCLM K).comp (ContinuousLinearMap.snd ℝ (ι → ℝ) (κ → ℝ))).prod
|
| 19 |
+
(ContinuousLinearMap.snd ℝ (ι → ℝ) (κ → ℝ)))
|
| 20 |
+
|
| 21 |
+
theorem regression_joint_law {Ω ι κ : Type*} [MeasurableSpace Ω]
|
| 22 |
+
[Fintype ι] [Fintype κ] {P : Measure Ω} {X : Ω → ι → ℝ} {Y : Ω → κ → ℝ}
|
| 23 |
+
(hXY : HasGaussianLaw (fun w => (X w,Y w)) P) (K : Matrix ι κ ℝ)
|
| 24 |
+
(hcov : ∀ i k, cov[fun w => X w i, fun w => Y w k; P] =
|
| 25 |
+
∑ l, K i l * cov[fun w => Y w l,fun w => Y w k; P]) :
|
| 26 |
+
P.map (fun w => (X w,Y w)) =
|
| 27 |
+
((P.map (fun w => X w-K*ᵥ Y w)).prod (P.map Y)).map
|
| 28 |
+
(fun z : (ι → ℝ) × (κ → ℝ) => (z.1+K*ᵥ z.2,z.2)) := by
|
| 29 |
+
have := hXY.isProbabilityMeasure
|
| 30 |
+
have hR := residual_joint_gaussian hXY K
|
| 31 |
+
have hi := residual_independent hXY K hcov
|
| 32 |
+
rw [← hi.map_prod_eq_prod_map_map hR.fst.aemeasurable hR.snd.aemeasurable,
|
| 33 |
+
AEMeasurable.map_map_of_aemeasurable (by fun_prop) hR.aemeasurable]
|
| 34 |
+
congr 1
|
| 35 |
+
funext w
|
| 36 |
+
simp only [Function.comp_apply,sub_add_cancel]
|
| 37 |
+
|
| 38 |
+
theorem regression_lintegral {Ω ι κ : Type*} [MeasurableSpace Ω]
|
| 39 |
+
[Fintype ι] [Fintype κ] {P : Measure Ω} {X : Ω → ι → ℝ} {Y : Ω → κ → ℝ}
|
| 40 |
+
(hXY : HasGaussianLaw (fun w => (X w,Y w)) P) (K : Matrix ι κ ℝ)
|
| 41 |
+
(hcov : ∀ i k, cov[fun w => X w i, fun w => Y w k; P] =
|
| 42 |
+
∑ l, K i l * cov[fun w => Y w l,fun w => Y w k; P])
|
| 43 |
+
(F : (ι → ℝ) × (κ → ℝ) → ℝ≥0∞) (hF : Measurable F) :
|
| 44 |
+
(∫⁻ w, F (X w,Y w) ∂P) =
|
| 45 |
+
∫⁻ y, ∫⁻ r, F (r+K*ᵥ y,y) ∂P.map (fun w => X w-K*ᵥ Y w) ∂P.map Y := by
|
| 46 |
+
have := hXY.isProbabilityMeasure
|
| 47 |
+
rw [← lintegral_map' hF.aemeasurable hXY.aemeasurable,
|
| 48 |
+
regression_joint_law hXY K hcov,lintegral_map (by fun_prop) (by fun_prop),
|
| 49 |
+
lintegral_prod_symm]
|
| 50 |
+
fun_prop
|
| 51 |
+
|
| 52 |
+
end SKGap.GaussianRegression
|
| 53 |
+
end
|
| 54 |
+
end
|
| 55 |
+
|
| 56 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianFiniteIBPError.lean
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.CoordinateDeriv
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
noncomputable section
|
| 7 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 8 |
+
open scoped NNReal ENNReal
|
| 9 |
+
open Filter
|
| 10 |
+
open scoped Topology
|
| 11 |
+
namespace SKGap
|
| 12 |
+
variable {κ : Type*} [Fintype κ] [DecidableEq κ]
|
| 13 |
+
|
| 14 |
+
theorem gaussianFinite_IBP_error (i : κ)
|
| 15 |
+
{f d : (κ → ℝ) → ℝ} {L : ℝ≥0} {C D : ℝ} {s : Set (κ → ℝ)}
|
| 16 |
+
(hf : LipschitzWith L f) (hC : ∀ x, ‖f x‖ ≤ C)
|
| 17 |
+
(hd : Measurable d) (hD : ∀ x, ‖d x‖ ≤ D) (hs : MeasurableSet s)
|
| 18 |
+
(hder : ∀ x ∈ s, HasDerivAt (fun z => f (Function.update x i z)) (d x) (x i)) :
|
| 19 |
+
|(∫ x, x i*f x ∂Measure.pi (fun _ : κ => gaussianReal 0 1))-
|
| 20 |
+
∫ x, d x ∂Measure.pi (fun _ : κ => gaussianReal 0 1)| ≤
|
| 21 |
+
((L:ℝ)+D)*(Measure.pi (fun _ : κ => gaussianReal 0 1)).real sᶜ := by
|
| 22 |
+
let μ := Measure.pi (fun _ : κ => gaussianReal 0 1)
|
| 23 |
+
have hi : Integrable (finiteCoordinateDeriv i f) μ :=
|
| 24 |
+
Integrable.of_bound (measurable_finiteCoordinateDeriv i hf.continuous).aestronglyMeasurable
|
| 25 |
+
(L:ℝ) (ae_of_all _ (norm_finiteCoordinateDeriv_le i hf))
|
| 26 |
+
have hid : Integrable d μ := Integrable.of_bound hd.aestronglyMeasurable D (ae_of_all _ hD)
|
| 27 |
+
rw [gaussianFinite_lipschitz_IBP i hf hC,← integral_sub hi hid]
|
| 28 |
+
have he : (fun x => finiteCoordinateDeriv i f x-d x) =
|
| 29 |
+
sᶜ.indicator (fun x => finiteCoordinateDeriv i f x-d x) := by
|
| 30 |
+
funext x
|
| 31 |
+
by_cases hx : x ∈ s
|
| 32 |
+
· simp only [Set.indicator_of_notMem (show x ∉ sᶜ by simpa using hx),finiteCoordinateDeriv]
|
| 33 |
+
rw [(hder x hx).deriv,sub_self]
|
| 34 |
+
· rw [Set.indicator_of_mem hx]
|
| 35 |
+
rw [he,integral_indicator hs.compl]
|
| 36 |
+
exact norm_setIntegral_le_of_norm_le_const (measure_lt_top μ sᶜ) (fun x _ =>
|
| 37 |
+
(norm_sub_le _ _).trans (add_le_add (norm_finiteCoordinateDeriv_le i hf x) (hD x)))
|
| 38 |
+
|
| 39 |
+
end SKGap
|
| 40 |
+
|
| 41 |
+
end
|
| 42 |
+
|
| 43 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianGramMomentsJoined.lean
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.FiniteRankPositive
|
| 3 |
+
import OAI.Probability.SKGap.Localization.ScalarFixedPointJoined
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 11 |
+
open scoped NNReal ENNReal
|
| 12 |
+
namespace SKGap
|
| 13 |
+
|
| 14 |
+
end SKGap
|
| 15 |
+
|
| 16 |
+
namespace SKGap
|
| 17 |
+
|
| 18 |
+
def scalarGramVariance (y : ℝ) := 1-tanh y^2
|
| 19 |
+
|
| 20 |
+
def spinMixed (y : ℝ) := tanh y^2*scalarGramVariance y
|
| 21 |
+
|
| 22 |
+
lemma spinVariance_nonneg (y : ℝ) : 0 ≤ scalarGramVariance y :=
|
| 23 |
+
sub_nonneg.mpr (tanh_sq_lt_one y).le
|
| 24 |
+
|
| 25 |
+
lemma abs_spinVariance_le_one (y : ℝ) : |scalarGramVariance y| ≤ 1 := by
|
| 26 |
+
rw [abs_of_nonneg (spinVariance_nonneg y)]
|
| 27 |
+
unfold scalarGramVariance
|
| 28 |
+
nlinarith [sq_nonneg (tanh y)]
|
| 29 |
+
|
| 30 |
+
lemma abs_spinMixed_le_one (y : ℝ) : |spinMixed y| ≤ 1 := by
|
| 31 |
+
unfold spinMixed
|
| 32 |
+
rw [abs_mul,abs_of_nonneg (sq_nonneg _)]
|
| 33 |
+
calc
|
| 34 |
+
_ ≤ 1*1 := mul_le_mul (tanh_sq_lt_one y).le (abs_spinVariance_le_one y) (abs_nonneg _) zero_le_one
|
| 35 |
+
_ = 1 := one_mul 1
|
| 36 |
+
|
| 37 |
+
lemma integrable_spinVariance {μ : Measure ℝ} [IsFiniteMeasure μ] : Integrable scalarGramVariance μ :=
|
| 38 |
+
Integrable.of_bound (by unfold scalarGramVariance; fun_prop) 1
|
| 39 |
+
(ae_of_all _ (fun y => by simpa only [Real.norm_eq_abs] using abs_spinVariance_le_one y))
|
| 40 |
+
|
| 41 |
+
lemma integrable_spinMixed {μ : Measure ℝ} [IsFiniteMeasure μ] : Integrable spinMixed μ :=
|
| 42 |
+
Integrable.of_bound (by unfold spinMixed scalarGramVariance; fun_prop) 1
|
| 43 |
+
(ae_of_all _ (fun y => by simpa only [Real.norm_eq_abs] using abs_spinMixed_le_one y))
|
| 44 |
+
|
| 45 |
+
lemma gaussian_nishimori_variance (s : ℝ≥0) :
|
| 46 |
+
(∫ y, oddVariance y ∂gaussianReal s s) = ∫ y, spinMixed y ∂gaussianReal s s := by
|
| 47 |
+
by_cases hs : s = 0
|
| 48 |
+
· subst s; simp [oddVariance,spinMixed,scalarGramVariance]
|
| 49 |
+
have hi := (integrable_gaussian_iff hs).mp
|
| 50 |
+
(integrable_oddVariance.sub (integrable_spinMixed (μ := gaussianReal s s)))
|
| 51 |
+
let f : ℝ → ℝ := fun y => gaussianPDFReal s s y*(oddVariance y-spinMixed y)
|
| 52 |
+
have hf : Integrable f := hi
|
| 53 |
+
have hid (y : ℝ) : f y+f (-y) = 0 := by
|
| 54 |
+
have hh := gaussianPDFReal_diagonal_symmetry hs y
|
| 55 |
+
dsimp [f,oddVariance,spinMixed,scalarGramVariance]
|
| 56 |
+
rw [tanh_neg,neg_sq]
|
| 57 |
+
nlinarith [congrArg (fun x => tanh y*(1-tanh y^2)*x) hh]
|
| 58 |
+
have hz : (∫ y, f y)+(∫ y, f (-y)) = 0 := by
|
| 59 |
+
rw [← integral_add hf hf.comp_neg]
|
| 60 |
+
simp only [hid,integral_zero]
|
| 61 |
+
rw [integral_neg_eq_self] at hz
|
| 62 |
+
have hsub : ∫ y, oddVariance y-spinMixed y ∂gaussianReal s s = 0 := by
|
| 63 |
+
rw [integral_gaussianReal_eq_integral_smul hs]
|
| 64 |
+
change (∫ y, f y) = 0
|
| 65 |
+
linarith
|
| 66 |
+
rw [integral_sub integrable_oddVariance integrable_spinMixed] at hsub
|
| 67 |
+
exact sub_eq_zero.mp hsub
|
| 68 |
+
|
| 69 |
+
lemma hasDerivAt_spinVariance (y : ℝ) : HasDerivAt scalarGramVariance (-2*oddVariance y) y := by
|
| 70 |
+
convert! (hasDerivAt_const y (1:ℝ)).sub ((hasDerivAt_tanh y).pow 2) using 1
|
| 71 |
+
simp only [oddVariance]; norm_num; ring
|
| 72 |
+
|
| 73 |
+
lemma hasDerivAt_oddVariance (y : ℝ) :
|
| 74 |
+
HasDerivAt oddVariance (scalarGramVariance y-3*spinMixed y) y := by
|
| 75 |
+
convert! (hasDerivAt_tanh y).mul (hasDerivAt_spinVariance y) using 1
|
| 76 |
+
simp only [spinMixed,scalarGramVariance,oddVariance]; ring
|
| 77 |
+
|
| 78 |
+
lemma integrable_center_spinVariance (d : ℝ) (s : ℝ≥0) :
|
| 79 |
+
Integrable (fun y => (y-d)*scalarGramVariance y) (gaussianReal d s) := by
|
| 80 |
+
have h := ((IsGaussian.integrable_id (μ := gaussianReal d s)).sub (integrable_const d)).bdd_mul (f := scalarGramVariance)
|
| 81 |
+
(by unfold scalarGramVariance; fun_prop) (c := 1)
|
| 82 |
+
(ae_of_all _ (fun y => by simpa only [Real.norm_eq_abs] using abs_spinVariance_le_one y))
|
| 83 |
+
simpa only [mul_comm,Pi.sub_apply,id_eq] using h
|
| 84 |
+
|
| 85 |
+
lemma integrable_center_oddVariance (d : ℝ) (s : ℝ≥0) :
|
| 86 |
+
Integrable (fun y => (y-d)*oddVariance y) (gaussianReal d s) := by
|
| 87 |
+
have h := ((IsGaussian.integrable_id (μ := gaussianReal d s)).sub (integrable_const d)).bdd_mul (f := oddVariance)
|
| 88 |
+
(by unfold oddVariance; fun_prop) (c := 1)
|
| 89 |
+
(ae_of_all _ (fun y => by simpa only [Real.norm_eq_abs] using abs_oddVariance_le_one y))
|
| 90 |
+
simpa only [mul_comm,Pi.sub_apply,id_eq] using h
|
| 91 |
+
|
| 92 |
+
lemma integrable_center_sq_spinVariance (d : ℝ) (s : ℝ≥0) :
|
| 93 |
+
Integrable (fun y => (y-d)^2*scalarGramVariance y) (gaussianReal d s) := by
|
| 94 |
+
have hmem : MemLp (fun y : ℝ => y-d) 2 (gaussianReal d s) :=
|
| 95 |
+
(IsGaussian.memLp_id (gaussianReal d s) 2 (by norm_num)).sub (memLp_const d)
|
| 96 |
+
have h := hmem.integrable_sq.bdd_mul (f := scalarGramVariance)
|
| 97 |
+
(by unfold scalarGramVariance; fun_prop) (c := 1)
|
| 98 |
+
(ae_of_all _ (fun y => by simpa only [Real.norm_eq_abs] using abs_spinVariance_le_one y))
|
| 99 |
+
simpa only [mul_comm,Pi.sub_apply,id_eq] using h
|
| 100 |
+
|
| 101 |
+
theorem gaussian_weighted_gram_moments {s : ℝ≥0} (hs : 0 < s) :
|
| 102 |
+
(∫ y, (y-(s:ℝ))*scalarGramVariance y ∂gaussianReal s s) =
|
| 103 |
+
-2*(s:ℝ)*(∫ y, spinMixed y ∂gaussianReal s s) ∧
|
| 104 |
+
(∫ y, (y-(s:ℝ))*oddVariance y ∂gaussianReal s s) =
|
| 105 |
+
(s:ℝ)*((∫ y, scalarGramVariance y ∂gaussianReal s s)-3*(∫ y, spinMixed y ∂gaussianReal s s)) ∧
|
| 106 |
+
(∫ y, (y-(s:ℝ))^2*scalarGramVariance y ∂gaussianReal s s) =
|
| 107 |
+
(s:ℝ)*(∫ y, scalarGramVariance y ∂gaussianReal s s)+
|
| 108 |
+
(s:ℝ)^2*(-2*(∫ y, scalarGramVariance y ∂gaussianReal s s)+6*(∫ y, spinMixed y ∂gaussianReal s s)) := by
|
| 109 |
+
have h1 := gaussian_integration_by_parts hs.ne' hasDerivAt_spinVariance
|
| 110 |
+
integrable_spinVariance (integrable_oddVariance.const_mul (-2))
|
| 111 |
+
(integrable_center_spinVariance s s)
|
| 112 |
+
rw [integral_const_mul,gaussian_nishimori_variance] at h1
|
| 113 |
+
have h2 := gaussian_integration_by_parts hs.ne' hasDerivAt_oddVariance
|
| 114 |
+
integrable_oddVariance (integrable_spinVariance.sub (integrable_spinMixed.const_mul 3))
|
| 115 |
+
(integrable_center_oddVariance s s)
|
| 116 |
+
rw [integral_sub integrable_spinVariance (integrable_spinMixed.const_mul 3),integral_const_mul] at h2
|
| 117 |
+
have hder (y : ℝ) : HasDerivAt (fun y => (y-(s:ℝ))*scalarGramVariance y)
|
| 118 |
+
(scalarGramVariance y-2*((y-(s:ℝ))*oddVariance y)) y := by
|
| 119 |
+
convert! ((hasDerivAt_id y).sub_const (s:ℝ)).mul (hasDerivAt_spinVariance y) using 1
|
| 120 |
+
simp only [id_eq,one_mul]; ring
|
| 121 |
+
have h3 := gaussian_integration_by_parts hs.ne' hder (integrable_center_spinVariance s s)
|
| 122 |
+
(integrable_spinVariance.sub ((integrable_center_oddVariance s s).const_mul 2))
|
| 123 |
+
((integrable_center_sq_spinVariance s s).congr (ae_of_all _ (fun y => by ring)))
|
| 124 |
+
have h3' : (∫ y, (y-(s:ℝ))^2*scalarGramVariance y ∂gaussianReal s s) =
|
| 125 |
+
(s:ℝ)*((∫ y, scalarGramVariance y ∂gaussianReal s s)-2*(∫ y, (y-(s:ℝ))*oddVariance y ∂gaussianReal s s)) := by
|
| 126 |
+
convert h3 using 1
|
| 127 |
+
· congr 1; funext y; ring
|
| 128 |
+
· rw [integral_sub integrable_spinVariance ((integrable_center_oddVariance s s).const_mul 2),integral_const_mul]
|
| 129 |
+
refine ⟨?_,h2,?_⟩
|
| 130 |
+
· linarith [h1]
|
| 131 |
+
· rw [h3',h2]; ring
|
| 132 |
+
|
| 133 |
+
end SKGap
|
| 134 |
+
end
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
section
|
| 138 |
+
noncomputable section
|
| 139 |
+
namespace SKGap
|
| 140 |
+
open Real Matrix MeasureTheory ProbabilityTheory
|
| 141 |
+
open scoped NNReal BigOperators
|
| 142 |
+
|
| 143 |
+
def scalarGramVector (s y : ℝ) : Fin 3 → ℝ := ![1,tanh y,(y-s)/s]
|
| 144 |
+
|
| 145 |
+
theorem gaussian_weighted_gram_matrix {s : ℝ≥0} (hs : 0 < s) :
|
| 146 |
+
(fun i k : Fin 3 => ∫ y, scalarGramVariance y*scalarGramVector s y i*scalarGramVector s y k
|
| 147 |
+
∂gaussianReal s s)=
|
| 148 |
+
limitingGram (∫ y,scalarGramVariance y ∂gaussianReal s s)
|
| 149 |
+
(∫ y,spinMixed y ∂gaussianReal s s) s := by
|
| 150 |
+
have hsR : (s:ℝ) ≠ 0 := by exact_mod_cast hs.ne'
|
| 151 |
+
obtain ⟨h1,h2,h3⟩ := gaussian_weighted_gram_moments hs
|
| 152 |
+
have h01 : (∫ y,scalarGramVariance y*tanh y ∂gaussianReal s s)=∫ y,spinMixed y ∂gaussianReal s s := by
|
| 153 |
+
convert gaussian_nishimori_variance s using 1
|
| 154 |
+
congr 1; funext y; unfold oddVariance scalarGramVariance; ring
|
| 155 |
+
have h02 : (∫ y,scalarGramVariance y*((y-(s:ℝ))/(s:ℝ)) ∂gaussianReal s s)=
|
| 156 |
+
-2*(∫ y,spinMixed y ∂gaussianReal s s) := by
|
| 157 |
+
calc
|
| 158 |
+
_ = (∫ y,(y-(s:ℝ))*scalarGramVariance y ∂gaussianReal s s)/(s:ℝ) := by
|
| 159 |
+
rw [← integral_div]; congr 1; funext y; ring
|
| 160 |
+
_ = _ := by rw [h1]; field_simp
|
| 161 |
+
have h11 : (∫ y,scalarGramVariance y*tanh y*tanh y ∂gaussianReal s s)=
|
| 162 |
+
∫ y,spinMixed y ∂gaussianReal s s := by
|
| 163 |
+
congr 1; funext y; unfold spinMixed; ring
|
| 164 |
+
have h12 : (∫ y,scalarGramVariance y*tanh y*((y-(s:ℝ))/(s:ℝ)) ∂gaussianReal s s)=
|
| 165 |
+
(∫ y,scalarGramVariance y ∂gaussianReal s s)-3*(∫ y,spinMixed y ∂gaussianReal s s) := by
|
| 166 |
+
calc
|
| 167 |
+
_ = (∫ y,(y-(s:ℝ))*oddVariance y ∂gaussianReal s s)/(s:ℝ) := by
|
| 168 |
+
rw [← integral_div]; congr 1; funext y; unfold oddVariance scalarGramVariance; ring
|
| 169 |
+
_ = _ := by rw [h2]; field_simp
|
| 170 |
+
have h22 : (∫ y,scalarGramVariance y*((y-(s:ℝ))/(s:ℝ))*((y-(s:ℝ))/(s:ℝ)) ∂gaussianReal s s)=
|
| 171 |
+
(∫ y,scalarGramVariance y ∂gaussianReal s s)/(s:ℝ)-
|
| 172 |
+
2*(∫ y,scalarGramVariance y ∂gaussianReal s s)+6*(∫ y,spinMixed y ∂gaussianReal s s) := by
|
| 173 |
+
calc
|
| 174 |
+
_ = (∫ y,(y-(s:ℝ))^2*scalarGramVariance y ∂gaussianReal s s)/(s:ℝ)^2 := by
|
| 175 |
+
rw [← integral_div]; congr 1; funext y; ring
|
| 176 |
+
_ = _ := by rw [h3]; field_simp; ring
|
| 177 |
+
have hsym (i k : Fin 3) :
|
| 178 |
+
(∫ y,scalarGramVariance y*scalarGramVector s y i*scalarGramVector s y k ∂gaussianReal s s)=
|
| 179 |
+
∫ y,scalarGramVariance y*scalarGramVector s y k*scalarGramVector s y i ∂gaussianReal s s := by
|
| 180 |
+
congr 1; funext y; ring
|
| 181 |
+
ext i k
|
| 182 |
+
fin_cases i <;> fin_cases k
|
| 183 |
+
· simp [scalarGramVector,limitingGram]
|
| 184 |
+
· simpa [scalarGramVector,limitingGram] using h01
|
| 185 |
+
· simpa [scalarGramVector,limitingGram] using h02
|
| 186 |
+
· simpa [scalarGramVector,limitingGram] using (hsym 1 0).trans (by simpa [scalarGramVector] using h01)
|
| 187 |
+
· simpa [scalarGramVector,limitingGram] using h11
|
| 188 |
+
· simpa [scalarGramVector,limitingGram] using h12
|
| 189 |
+
· simpa [scalarGramVector,limitingGram] using (hsym 2 0).trans (by simpa [scalarGramVector] using h02)
|
| 190 |
+
· simpa [scalarGramVector,limitingGram] using (hsym 2 1).trans (by simpa [scalarGramVector] using h12)
|
| 191 |
+
· simpa [scalarGramVector,limitingGram] using h22
|
| 192 |
+
|
| 193 |
+
end SKGap
|
| 194 |
+
end
|
| 195 |
+
end
|
| 196 |
+
|
| 197 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianLinearDensity.lean
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 3 |
+
import OAI.Probability.SKGap.Localization.EqualityCurve
|
| 4 |
+
import OAI.Probability.SKGap.Localization.RankCovariance
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace SKGap.GaussianDensity
|
| 11 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 12 |
+
open scoped BigOperators ENNReal NNReal
|
| 13 |
+
variable {ι Ω : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace Ω]
|
| 14 |
+
{P : Measure Ω} {X : Ω → ι → ℝ}
|
| 15 |
+
|
| 16 |
+
theorem gaussian_density_of_matrix (hX : HasGaussianLaw X P) (A : Matrix ι ι ℝ) (hA : A.det ≠ 0)
|
| 17 |
+
(hm : ∀ i,(∫ w,X w i ∂P)=0)
|
| 18 |
+
(hc : ∀ i k,cov[fun w => X w i,fun w => X w k;P]=(A*Aᵀ) i k) :
|
| 19 |
+
P.map X=(volume : Measure (ι → ℝ)).withDensity (fun x => ENNReal.ofReal
|
| 20 |
+
(|A.det⁻¹| *∏ i,gaussianPDFReal 0 1 ((A⁻¹*ᵥx) i))) := by
|
| 21 |
+
have hl : P.map X=(gaussianCoordinates ι).map (fun x => A*ᵥx) := by
|
| 22 |
+
apply GaussianRegression.law_eq_of_mean_covariance hX (matrix_sample_gaussian A)
|
| 23 |
+
· intro i
|
| 24 |
+
rw [hm]
|
| 25 |
+
exact (linear_gaussian_mean (A i)).symm
|
| 26 |
+
· intro i k
|
| 27 |
+
rw [hc,matrix_sample_covariance]
|
| 28 |
+
rw [hl]
|
| 29 |
+
exact matrix_map_gaussian_density A hA
|
| 30 |
+
|
| 31 |
+
lemma gaussian_rankOne_density (hX : HasGaussianLaw X P) {a b : ℝ} (ha : 0 < a) (hb : 0 < b)
|
| 32 |
+
{u : ι → ℝ} (hu : u⬝ᵥu=1) (hm : ∀ i,(∫ w,X w i ∂P)=0)
|
| 33 |
+
(hc : ∀ i k,cov[fun w => X w i,fun w => X w k;P]=
|
| 34 |
+
rankOneTransform (a^2) (b^2) u i k) :
|
| 35 |
+
P.map X=(volume : Measure (ι → ℝ)).withDensity (fun x => ENNReal.ofReal
|
| 36 |
+
((a^(Fintype.card ι)*(b/a))⁻¹*∏ i,gaussianPDFReal 0 1
|
| 37 |
+
((rankOneTransform a⁻¹ b⁻¹ u*ᵥx) i))) := by
|
| 38 |
+
have hd : 0 < (rankOneTransform a b u).det := by
|
| 39 |
+
rw [rankOneTransform_det ha.ne' b hu]
|
| 40 |
+
positivity
|
| 41 |
+
have hc' : ∀ i k,cov[fun w => X w i,fun w => X w k;P]=
|
| 42 |
+
(rankOneTransform a b u*(rankOneTransform a b u)ᵀ) i k := by
|
| 43 |
+
intro i k
|
| 44 |
+
rw [hc,rankOneTransform_transpose,rankOneTransform_mul hu]
|
| 45 |
+
simp only [← pow_two]
|
| 46 |
+
rw [gaussian_density_of_matrix hX _ hd.ne' hm hc',
|
| 47 |
+
rankOneTransform_inv ha.ne' hb.ne' hu,abs_of_pos (inv_pos.mpr hd),rankOneTransform_det ha.ne' b hu]
|
| 48 |
+
|
| 49 |
+
end SKGap.GaussianDensity
|
| 50 |
+
end
|
| 51 |
+
end
|
| 52 |
+
|
| 53 |
+
section
|
| 54 |
+
noncomputable section
|
| 55 |
+
namespace SKGap.GaussianDensity
|
| 56 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 57 |
+
open scoped BigOperators ENNReal NNReal
|
| 58 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 59 |
+
|
| 60 |
+
def radialDensity (a : ℝ) (x : ι → ℝ) : ℝ :=
|
| 61 |
+
((sqrt (2*Real.pi)*a)⁻¹)^(Fintype.card ι)*exp (-(x⬝ᵥx)/(2*a^2))
|
| 62 |
+
|
| 63 |
+
omit [DecidableEq ι] in
|
| 64 |
+
lemma product_gaussianPDF_formula (v : ℝ≥0) (x : ι → ℝ) :
|
| 65 |
+
(∏ i,gaussianPDFReal 0 v (x i))=(sqrt (2*Real.pi*v))⁻¹^(Fintype.card ι)*
|
| 66 |
+
exp (-(x⬝ᵥx)/(2*v)) := by
|
| 67 |
+
simp only [gaussianPDFReal,sub_zero,Finset.prod_mul_distrib,Finset.prod_const,
|
| 68 |
+
Finset.card_univ,← exp_sum,← Finset.sum_div,← Finset.sum_neg_distrib,dotProduct,← pow_two]
|
| 69 |
+
|
| 70 |
+
omit [DecidableEq ι] in
|
| 71 |
+
lemma product_gaussianPDF_radial {a : ℝ} (ha : 0 ≤ a) (x : ι → ℝ) :
|
| 72 |
+
(∏ i,gaussianPDFReal 0 (NNReal.mk (a^2) (sq_nonneg a)) (x i))=radialDensity a x := by
|
| 73 |
+
rw [product_gaussianPDF_formula]
|
| 74 |
+
simp only [NNReal.coe_mk,radialDensity,sqrt_mul (by positivity : 0 ≤ 2*Real.pi),sqrt_sq ha]
|
| 75 |
+
|
| 76 |
+
lemma rankOne_density_radial {a b : ℝ} (ha : a ≠ 0) (hb : b ≠ 0)
|
| 77 |
+
{u : ι → ℝ} (hu : u⬝ᵥu=1) (x : ι → ℝ) :
|
| 78 |
+
(a^(Fintype.card ι)*(b/a))⁻¹*(∏ i,gaussianPDFReal 0 1
|
| 79 |
+
((rankOneTransform a⁻¹ b⁻¹ u*ᵥx) i)) =
|
| 80 |
+
(a/b)*radialDensity a x*exp ((b^2-a^2)/(2*a^2*b^2)*(u⬝ᵥx)^2) := by
|
| 81 |
+
rw [product_gaussianPDF_formula,rankOneTransform_norm_sq hu]
|
| 82 |
+
simp only [NNReal.coe_one,mul_one]
|
| 83 |
+
have he : -(a⁻¹^2*(x⬝ᵥx)+(b⁻¹^2-a⁻¹^2)*(u⬝ᵥx)^2)/2 =
|
| 84 |
+
-(x⬝ᵥx)/(2*a^2)+(b^2-a^2)/(2*a^2*b^2)*(u⬝ᵥx)^2 := by
|
| 85 |
+
field_simp
|
| 86 |
+
ring
|
| 87 |
+
rw [he,exp_add]
|
| 88 |
+
unfold radialDensity
|
| 89 |
+
have hc : (a^(Fintype.card ι)*(b/a))⁻¹*(sqrt (2*Real.pi))⁻¹^(Fintype.card ι)=
|
| 90 |
+
(a/b)*((sqrt (2*Real.pi)*a)⁻¹)^(Fintype.card ι) := by
|
| 91 |
+
simp only [_root_.mul_inv_rev,mul_pow,inv_pow,inv_inv,div_eq_mul_inv]
|
| 92 |
+
ring
|
| 93 |
+
rw [← mul_assoc,← mul_assoc,hc]
|
| 94 |
+
ring
|
| 95 |
+
|
| 96 |
+
end SKGap.GaussianDensity
|
| 97 |
+
end
|
| 98 |
+
end
|
| 99 |
+
|
| 100 |
+
section
|
| 101 |
+
noncomputable section
|
| 102 |
+
namespace SKGap.GaussianDensity
|
| 103 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 104 |
+
open scoped BigOperators ENNReal NNReal
|
| 105 |
+
variable {ι Ω : Type*} [Fintype ι] [DecidableEq ι] [MeasurableSpace Ω]
|
| 106 |
+
{P : Measure Ω} {X : Ω → ι → ℝ}
|
| 107 |
+
|
| 108 |
+
def rankOneDensity (s r : ℝ) (m x : ι → ℝ) : ℝ :=
|
| 109 |
+
sqrt (s/(s+r*(m⬝ᵥm)))*radialDensity (sqrt s) x*
|
| 110 |
+
exp (r/(2*s*(s+r*(m⬝ᵥm)))*(m⬝ᵥx)^2)
|
| 111 |
+
|
| 112 |
+
omit [Fintype ι] in
|
| 113 |
+
lemma rankOne_scaled_covariance (s r c : ℝ) (u : ι → ℝ) :
|
| 114 |
+
rankOneCovariance s r (c • u)=rankOneTransform s (s+r*c^2) u := by
|
| 115 |
+
ext i k
|
| 116 |
+
simp only [rankOneCovariance,rankOneTransform,Matrix.add_apply,Matrix.smul_apply,
|
| 117 |
+
smul_eq_mul,Matrix.vecMulVec_apply,Pi.smul_apply]
|
| 118 |
+
ring
|
| 119 |
+
|
| 120 |
+
lemma scaled_unit_exists [Nonempty ι] (m : ι → ℝ) :
|
| 121 |
+
∃ (c : ℝ) (u : ι → ℝ), 0 ≤ c ∧ u⬝ᵥu=1 ∧ m=c • u := by
|
| 122 |
+
by_cases hm : m=0
|
| 123 |
+
· let i : ι := Classical.choice inferInstance
|
| 124 |
+
refine ⟨0,Pi.single i 1,le_rfl,?_,by simp [hm]⟩
|
| 125 |
+
simp [dotProduct,Pi.single_apply]
|
| 126 |
+
· have hq : 0 < m⬝ᵥm := lt_of_le_of_ne
|
| 127 |
+
(Finset.sum_nonneg (fun i _ => mul_self_nonneg (m i)))
|
| 128 |
+
(Ne.symm (mt dotProduct_self_eq_zero.mp hm))
|
| 129 |
+
have hc : 0 < sqrt (m⬝ᵥm) := sqrt_pos.mpr hq
|
| 130 |
+
refine ⟨sqrt (m⬝ᵥm),(sqrt (m⬝ᵥm))⁻¹ • m,hc.le,?_,?_⟩
|
| 131 |
+
· simp only [smul_dotProduct,dotProduct_smul,smul_eq_mul]
|
| 132 |
+
have hh := sq_sqrt hq.le
|
| 133 |
+
field_simp
|
| 134 |
+
nlinarith
|
| 135 |
+
· simp [smul_smul,hc.ne']
|
| 136 |
+
|
| 137 |
+
theorem gaussian_rankOne_covariance_density [Nonempty ι]
|
| 138 |
+
(hX : HasGaussianLaw X P) {s r : ℝ} (hs : 0 < s) (hr : 0 ≤ r)
|
| 139 |
+
(m : ι → ℝ) (hm : ∀ i,(∫ w,X w i ∂P)=0)
|
| 140 |
+
(hc : ∀ i k,cov[fun w => X w i,fun w => X w k;P]=rankOneCovariance s r m i k) :
|
| 141 |
+
P.map X=(volume : Measure (ι → ℝ)).withDensity
|
| 142 |
+
(fun x => ENNReal.ofReal (rankOneDensity s r m x)) := by
|
| 143 |
+
obtain ⟨c,u,hcpos,hu,rfl⟩ := scaled_unit_exists m
|
| 144 |
+
have hS : 0 < s+r*c^2 := add_pos_of_pos_of_nonneg hs (mul_nonneg hr (sq_nonneg c))
|
| 145 |
+
have ha : 0 < sqrt s := sqrt_pos.mpr hs
|
| 146 |
+
have hb : 0 < sqrt (s+r*c^2) := sqrt_pos.mpr hS
|
| 147 |
+
have hc' : ∀ i k,cov[fun w => X w i,fun w => X w k;P]=
|
| 148 |
+
rankOneTransform ((sqrt s)^2) ((sqrt (s+r*c^2))^2) u i k := by
|
| 149 |
+
intro i k
|
| 150 |
+
rw [sq_sqrt hs.le,sq_sqrt hS.le,hc,rankOne_scaled_covariance]
|
| 151 |
+
rw [gaussian_rankOne_density hX ha hb hu hm hc']
|
| 152 |
+
congr 1
|
| 153 |
+
ext x
|
| 154 |
+
rw [rankOne_density_radial ha.ne' hb.ne' hu x]
|
| 155 |
+
simp only [rankOneDensity,smul_dotProduct,dotProduct_smul,smul_eq_mul,hu,mul_one,
|
| 156 |
+
sq_sqrt hs.le,sq_sqrt hS.le]
|
| 157 |
+
have hq : c*c=c^2 := by ring
|
| 158 |
+
rw [hq]
|
| 159 |
+
have hpref : sqrt s/sqrt (s+r*c^2)=sqrt (s/(s+r*c^2)) := (sqrt_div hs.le _).symm
|
| 160 |
+
rw [hpref]
|
| 161 |
+
congr 2
|
| 162 |
+
congr 1
|
| 163 |
+
field_simp
|
| 164 |
+
ring
|
| 165 |
+
|
| 166 |
+
end SKGap.GaussianDensity
|
| 167 |
+
end
|
| 168 |
+
end
|
| 169 |
+
|
| 170 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianMarginal.lean
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Posterior.History
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
namespace SKGap.GaussianHistory
|
| 7 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 8 |
+
open scoped BigOperators ENNReal NNReal
|
| 9 |
+
open GaussianStep
|
| 10 |
+
noncomputable section
|
| 11 |
+
variable {n : ℕ}
|
| 12 |
+
|
| 13 |
+
lemma pi_gaussian_add (m₁ m₂ : Fin n → ℝ) (v₁ v₂ : ℝ≥0) :
|
| 14 |
+
((Measure.pi fun i => gaussianReal (m₁ i) v₁).prod
|
| 15 |
+
(Measure.pi fun i => gaussianReal (m₂ i) v₂)).map
|
| 16 |
+
(fun z : (Fin n → ℝ) × (Fin n → ℝ) => fun i => z.1 i+z.2 i) =
|
| 17 |
+
Measure.pi (fun i => gaussianReal (m₁ i+m₂ i) (v₁+v₂)) := by
|
| 18 |
+
rw [← (measurePreserving_arrowProdEquivProdArrow ℝ ℝ (Fin n)
|
| 19 |
+
(fun i => gaussianReal (m₁ i) v₁) (fun i => gaussianReal (m₂ i) v₂)).map_eq]
|
| 20 |
+
rw [Measure.map_map (by fun_prop) (MeasurableEquiv.measurable _)]
|
| 21 |
+
change (Measure.pi (fun i => (gaussianReal (m₁ i) v₁).prod (gaussianReal (m₂ i) v₂))).map
|
| 22 |
+
(fun z i => (z i).1+(z i).2) = _
|
| 23 |
+
rw [Measure.pi_map_pi (f := fun _ (z : ℝ × ℝ) => z.1+z.2) (fun _ => by fun_prop)]
|
| 24 |
+
congr 1
|
| 25 |
+
funext i
|
| 26 |
+
exact gaussianReal_conv_gaussianReal
|
| 27 |
+
|
| 28 |
+
def field (t : ℝ) : {k : ℕ} → History n k → (Fin n → ℝ)
|
| 29 |
+
| 0, _ => 0
|
| 30 |
+
| _+1, h => fun i => field t h.1 i+sqrt t*h.2 i
|
| 31 |
+
|
| 32 |
+
lemma continuous_field (t : ℝ) : ∀k,Continuous (field (n := n) t (k := k))
|
| 33 |
+
| 0 => continuous_const
|
| 34 |
+
| k+1 => (continuous_field t k).comp continuous_fst |>.add
|
| 35 |
+
(by fun_prop)
|
| 36 |
+
|
| 37 |
+
lemma map_scaled_reference {t : ℝ} (ht : 0≤t) :
|
| 38 |
+
(GaussianStep.reference n).map (fun z : Fin n→ℝ => fun i => sqrt t*z i) =
|
| 39 |
+
Measure.pi (fun _ : Fin n => gaussianReal 0 (toNNReal t)) := by
|
| 40 |
+
unfold GaussianStep.reference
|
| 41 |
+
rw [Measure.pi_map_pi (fun _ => by fun_prop)]
|
| 42 |
+
congr 1
|
| 43 |
+
funext i
|
| 44 |
+
rw [gaussianReal_map_const_mul]
|
| 45 |
+
congr 1
|
| 46 |
+
· simp
|
| 47 |
+
· apply NNReal.coe_injective
|
| 48 |
+
simp [sq_sqrt ht,ht]
|
| 49 |
+
|
| 50 |
+
lemma map_field_reference {t : ℝ} (ht : 0≤t) : ∀k,
|
| 51 |
+
(reference n k).map (field t (k := k)) =
|
| 52 |
+
Measure.pi (fun _ : Fin n => gaussianReal 0 (toNNReal ((k:ℝ)*t)))
|
| 53 |
+
| 0 => by
|
| 54 |
+
simp only [reference,field,Nat.cast_zero,zero_mul,toNNReal_zero,gaussianReal_zero_var]
|
| 55 |
+
rw [Measure.map_dirac' (by fun_prop) ()]
|
| 56 |
+
apply (Measure.pi_eq (μ := fun _ : Fin n => Measure.dirac (0:ℝ)) (μ' := Measure.dirac (0:Fin n→ℝ)) ?_).symm
|
| 57 |
+
intro s hs
|
| 58 |
+
by_cases hx : ∀i:Fin n,(0:ℝ)∈s i
|
| 59 |
+
· rw [Measure.dirac_apply_of_mem (by simpa only [mem_univ_pi,Pi.zero_apply] using hx)]
|
| 60 |
+
symm
|
| 61 |
+
exact Finset.prod_eq_one (fun i _ => Measure.dirac_apply_of_mem (hx i))
|
| 62 |
+
· push Not at hx
|
| 63 |
+
obtain ⟨i,hi⟩ := hx
|
| 64 |
+
rw [Measure.dirac_apply' _ (MeasurableSet.univ_pi hs),
|
| 65 |
+
Set.indicator_of_notMem (by simp only [mem_univ_pi,Pi.zero_apply]; exact not_forall.mpr ⟨i,hi⟩)]
|
| 66 |
+
symm
|
| 67 |
+
exact Finset.prod_eq_zero (Finset.mem_univ i)
|
| 68 |
+
(by rw [Measure.dirac_apply' _ (hs i),Set.indicator_of_notMem hi])
|
| 69 |
+
| k+1 => by
|
| 70 |
+
change ((reference n k).prod (GaussianStep.reference n)).map
|
| 71 |
+
((fun z : (Fin n→ℝ) × (Fin n→ℝ) => fun i => z.1 i+z.2 i) ∘
|
| 72 |
+
Prod.map (field t) (fun z : Fin n→ℝ => fun i => sqrt t*z i)) = _
|
| 73 |
+
rw [← Measure.map_map (by fun_prop) ((continuous_field t k).measurable.prodMap (by fun_prop)), ← Measure.map_prod_map
|
| 74 |
+
(reference n k) (GaussianStep.reference n)
|
| 75 |
+
(continuous_field t k).measurable (by fun_prop),
|
| 76 |
+
map_field_reference ht k,map_scaled_reference ht,pi_gaussian_add]
|
| 77 |
+
congr 1
|
| 78 |
+
funext i
|
| 79 |
+
simp only [zero_add]
|
| 80 |
+
congr 1
|
| 81 |
+
rw [←toNNReal_add (mul_nonneg (by positivity) ht) ht]
|
| 82 |
+
congr 1
|
| 83 |
+
push_cast
|
| 84 |
+
ring
|
| 85 |
+
|
| 86 |
+
lemma likelihood_field (t : ℝ) (x : Spin n) : ∀{k : ℕ} (h : History n k),
|
| 87 |
+
likelihood t x h = exp ((∑i,spinValue (x i)*field t h i)-(k:ℝ)*t*(n:ℝ)/2)
|
| 88 |
+
| 0, _ => by simp [likelihood,field]
|
| 89 |
+
| k+1, h => by
|
| 90 |
+
rw [likelihood,likelihood_field t x h.1,GaussianStep.likelihood,←exp_add]
|
| 91 |
+
congr 1
|
| 92 |
+
simp only [field,Finset.sum_add_distrib,mul_add,Nat.cast_add,Nat.cast_one]
|
| 93 |
+
have he : (∑i,spinValue (x i)*(sqrt t*h.2 i)) = sqrt t*∑i,spinValue (x i)*h.2 i := by
|
| 94 |
+
rw [Finset.mul_sum]
|
| 95 |
+
apply Finset.sum_congr rfl
|
| 96 |
+
intro i _
|
| 97 |
+
ring
|
| 98 |
+
rw [he]
|
| 99 |
+
ring
|
| 100 |
+
|
| 101 |
+
lemma map_withDensity_comp {α β : Type*} [MeasurableSpace α] [MeasurableSpace β]
|
| 102 |
+
(μ : Measure α) (f : α→β) (g : β→ℝ≥0∞) (hf : Measurable f) (hg : Measurable g) :
|
| 103 |
+
(μ.withDensity (g ∘ f)).map f = (μ.map f).withDensity g := by
|
| 104 |
+
ext s hs
|
| 105 |
+
rw [Measure.map_apply hf hs,withDensity_apply _ (hf hs),withDensity_apply _ hs]
|
| 106 |
+
rw [←lintegral_indicator (hf hs),←lintegral_indicator hs,
|
| 107 |
+
lintegral_map (hg.indicator hs) hf]
|
| 108 |
+
apply lintegral_congr
|
| 109 |
+
intro x
|
| 110 |
+
by_cases hx : f x∈s <;> simp [hx]
|
| 111 |
+
|
| 112 |
+
theorem field_law (p : Prior n) {t : ℝ} (ht : 0≤t) (k : ℕ) :
|
| 113 |
+
(law p t k).map (field t) =
|
| 114 |
+
((GaussianStep.reference n).withDensity
|
| 115 |
+
(fun z => ENNReal.ofReal (GaussianStep.density p ((k:ℝ)*t) z))).map
|
| 116 |
+
(fun z : Fin n→ℝ => fun i => sqrt ((k:ℝ)*t)*z i) := by
|
| 117 |
+
let D : (Fin n→ℝ)→ℝ≥0∞ := fun y => ENNReal.ofReal
|
| 118 |
+
(∑ x, p x*exp ((∑i,spinValue (x i)*y i)-(k:ℝ)*t*(n:ℝ)/2))
|
| 119 |
+
have hD : Measurable D := by unfold D; fun_prop
|
| 120 |
+
have hd : (fun h : History n k => ENNReal.ofReal (density p t h))=D ∘ field t := by
|
| 121 |
+
funext h
|
| 122 |
+
simp only [density,likelihood_field,Function.comp_def,D]
|
| 123 |
+
have hs : (fun z => ENNReal.ofReal (GaussianStep.density p ((k:ℝ)*t) z)) =
|
| 124 |
+
D ∘ (fun z : Fin n→ℝ => fun i => sqrt ((k:ℝ)*t)*z i) := by
|
| 125 |
+
funext z
|
| 126 |
+
unfold D GaussianStep.density GaussianStep.likelihood
|
| 127 |
+
dsimp
|
| 128 |
+
congr 1
|
| 129 |
+
apply Finset.sum_congr rfl
|
| 130 |
+
intro x _
|
| 131 |
+
congr 2
|
| 132 |
+
rw [Finset.mul_sum]
|
| 133 |
+
congr 1
|
| 134 |
+
apply Finset.sum_congr rfl
|
| 135 |
+
intro i _
|
| 136 |
+
ring
|
| 137 |
+
rw [law,hd,hs,map_withDensity_comp _ _ _ (continuous_field t k).measurable hD,
|
| 138 |
+
map_withDensity_comp _ _ _ (by fun_prop) hD,map_field_reference ht,
|
| 139 |
+
map_scaled_reference (mul_nonneg (by positivity) ht)]
|
| 140 |
+
|
| 141 |
+
lemma weight_field (g : Disorder n) (h₀ y : Fin n→ℝ) (x : Spin n) :
|
| 142 |
+
weight g (h₀+y) x=weight g h₀ x*exp (∑i,spinValue (x i)*y i) := by
|
| 143 |
+
unfold weight hamiltonian
|
| 144 |
+
rw [←exp_add]
|
| 145 |
+
congr 1
|
| 146 |
+
simp only [Pi.add_apply,add_mul,Finset.sum_add_distrib]
|
| 147 |
+
have he : (∑i,y i*spinValue (x i))=∑i,spinValue (x i)*y i :=
|
| 148 |
+
Finset.sum_congr rfl (fun i _ => mul_comm _ _)
|
| 149 |
+
rw [he]
|
| 150 |
+
ring
|
| 151 |
+
|
| 152 |
+
lemma posterior_gibbs_field (g : Disorder n) (h₀ : Fin n→ℝ) (t : ℝ)
|
| 153 |
+
{k : ℕ} (h : History n k) : posterior (gibbsPrior g h₀) t h = gibbsPrior g (h₀+field t h) := by
|
| 154 |
+
have he (x : Spin n) : gibbsPrior g h₀ x*likelihood t x h =
|
| 155 |
+
(exp (-(k:ℝ)*t*(n:ℝ)/2)/partition g h₀)*weight g (h₀+field t h) x := by
|
| 156 |
+
rw [likelihood_field,weight_field]
|
| 157 |
+
change (weight g h₀ x/partition g h₀)*exp (_-_) = _
|
| 158 |
+
rw [exp_sub]
|
| 159 |
+
have hn : -(k:ℝ)*t*(n:ℝ)/2 = -((k:ℝ)*t*(n:ℝ)/2) := by ring
|
| 160 |
+
rw [hn,exp_neg]
|
| 161 |
+
ring
|
| 162 |
+
have hd : density (gibbsPrior g h₀) t h =
|
| 163 |
+
(exp (-(k:ℝ)*t*(n:ℝ)/2)/partition g h₀)*partition g (h₀+field t h) := by
|
| 164 |
+
simp only [density,he,←Finset.mul_sum,partition]
|
| 165 |
+
apply Prior.ext
|
| 166 |
+
funext x
|
| 167 |
+
change gibbsPrior g h₀ x*likelihood t x h/density (gibbsPrior g h₀) t h =
|
| 168 |
+
weight g (h₀+field t h) x/partition g (h₀+field t h)
|
| 169 |
+
rw [he,hd]
|
| 170 |
+
exact mul_div_mul_left _ _ (div_ne_zero (exp_ne_zero _) (partition_pos _ _).ne')
|
| 171 |
+
|
| 172 |
+
end
|
| 173 |
+
end SKGap.GaussianHistory
|
| 174 |
+
|
| 175 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianMatrixChaining.lean
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.MatrixNormTail
|
| 3 |
+
import OAI.Probability.SKGap.Localization.BoxChaining
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Matrix Real MeasureTheory ProbabilityTheory Set Filter
|
| 11 |
+
open scoped BigOperators Matrix.Norms.Frobenius Topology
|
| 12 |
+
variable {κ α : Type*} [Fintype κ] [Fintype α] [DecidableEq α]
|
| 13 |
+
|
| 14 |
+
def gaussianMatrixChainConstant (H B : ℝ) : ℝ :=
|
| 15 |
+
5*(matrixNormConstant*H+π*H*sqrt (B+1))
|
| 16 |
+
|
| 17 |
+
lemma gaussianMatrixChain_exponent {H B s : ℝ} (hH : 0<H) (hB : 0 ≤ B) (n : ℕ) :
|
| 18 |
+
-2*(π*H*sqrt (B+1))^2*s^2*(n:ℝ)/(π^2*H^2)=
|
| 19 |
+
-(2*(B+1))*s^2*(n:ℝ) := by
|
| 20 |
+
rw [mul_pow,mul_pow,sq_sqrt (by linarith : 0 ≤ B+1)]
|
| 21 |
+
field_simp
|
| 22 |
+
|
| 23 |
+
theorem gaussianMatrix_box_chaining {n : ℕ} (hn : 1 ≤ n) {H B : ℝ}
|
| 24 |
+
(hH : 0<H) (hB : 0 ≤ B) (hdim : log 16*(Fintype.card α:ℝ) ≤ B*(n:ℝ))
|
| 25 |
+
(F : (α→Icc (0:ℝ) 1)→EuclideanSpace ℝ κ→Matrix (Fin n) (Fin n) ℝ)
|
| 26 |
+
(hF : ∀ θ,LipschitzWith (Real.toNNReal (H/sqrt n)) (F θ))
|
| 27 |
+
(hi : ∀ k θ η,dist θ η ≤ 2*(1/4:ℝ)^k→
|
| 28 |
+
LipschitzWith (Real.toNNReal (H*(1/2:ℝ)^k/sqrt n)) (fun x=>F θ x-F η x))
|
| 29 |
+
(hc : ∀ g : κ→ℝ,Continuous (fun θ=>matrixCentered (F θ) (WithLp.toLp 2 g)))
|
| 30 |
+
(p : Bool) :
|
| 31 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 32 |
+
{g | ∃ θ,gaussianMatrixChainConstant H B< matrixWordSeminorm p (matrixCentered (F θ) (WithLp.toLp 2 g))} ≤
|
| 33 |
+
ENNReal.ofReal (3*exp (-(n:ℝ))) := by
|
| 34 |
+
let T := π*H*sqrt (B+1)
|
| 35 |
+
let b := matrixNormConstant*H+T
|
| 36 |
+
have hT : 0 ≤ T := by dsimp [T];positivity
|
| 37 |
+
have hC : 0 ≤ matrixNormConstant := zero_le_one.trans matrixNormConstant_bounds.1
|
| 38 |
+
have hb0 : 0 ≤ b := add_nonneg (mul_nonneg hC hH.le) hT
|
| 39 |
+
let r : ℕ→ℝ := fun k=>b*((k:ℝ)+1)*(1/2:ℝ)^k
|
| 40 |
+
have hsum : HasSum r (b*4) := by
|
| 41 |
+
have he : r=(fun k : ℕ=>b*(((k:ℝ)+1)*(1/2:ℝ)^k)) := by
|
| 42 |
+
funext k
|
| 43 |
+
dsimp [r]
|
| 44 |
+
ring
|
| 45 |
+
rw [he]
|
| 46 |
+
exact arithmetic_half_geometric_hasSum.mul_left b
|
| 47 |
+
have hbase (θ : α→Icc (0:ℝ) 1) : (Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 48 |
+
{g | b< matrixWordSeminorm p (matrixCentered (F θ) (WithLp.toLp 2 g))} ≤
|
| 49 |
+
ENNReal.ofReal (exp (-(2*(B+1))*(n:ℝ))) := by
|
| 50 |
+
have hh := gaussianMatrix_scaled_semnorm_tail hn hH (by norm_num : (0:ℝ)<1) hT
|
| 51 |
+
(by norm_num : (0:ℝ) ≤ 1) (F:=F θ) (by simpa only [mul_one] using hF θ) p
|
| 52 |
+
rw [gaussianMatrixChain_exponent hH hB] at hh
|
| 53 |
+
simpa only [T,b,mul_one,one_pow] using hh
|
| 54 |
+
have hincr (k : ℕ) (θ η : α→Icc (0:ℝ) 1) (hθ : dist θ η ≤ 2*(1/4:ℝ)^k) :
|
| 55 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 56 |
+
{g | r k< matrixWordSeminorm p (matrixCentered (F θ) (WithLp.toLp 2 g)-matrixCentered (F η) (WithLp.toLp 2 g))} ≤
|
| 57 |
+
ENNReal.ofReal (exp (-(2*(B+1))*((k:ℝ)+1)^2*(n:ℝ))) := by
|
| 58 |
+
have hh := gaussianMatrix_scaled_semnorm_tail hn hH (by positivity : (0:ℝ)<(1/2:ℝ)^k) hT
|
| 59 |
+
(by positivity : 0 ≤ (k:ℝ)+1) (hi k θ η hθ) p
|
| 60 |
+
rw [gaussianMatrixChain_exponent hH hB] at hh
|
| 61 |
+
simp_rw [matrixCentered_sub (hF θ) (hF η)] at hh
|
| 62 |
+
apply (measure_mono (show {g | r k< matrixWordSeminorm p (matrixCentered (F θ) (WithLp.toLp 2 g)-matrixCentered (F η) (WithLp.toLp 2 g))}⊆
|
| 63 |
+
{g | (matrixNormConstant*H+T*((k:ℝ)+1))*(1/2:ℝ)^k< matrixWordSeminorm p (matrixCentered (F θ) (WithLp.toLp 2 g)-matrixCentered (F η) (WithLp.toLp 2 g))} from ?_)).trans hh
|
| 64 |
+
intro g hg
|
| 65 |
+
change r k<_ at hg
|
| 66 |
+
change (matrixNormConstant*H+T*((k:ℝ)+1))*(1/2:ℝ)^k<_
|
| 67 |
+
apply lt_of_le_of_lt _ hg
|
| 68 |
+
dsimp [r,b]
|
| 69 |
+
apply mul_le_mul_of_nonneg_right _ (by positivity)
|
| 70 |
+
nlinarith only [mul_nonneg (mul_nonneg hC hH.le) (Nat.cast_nonneg k)]
|
| 71 |
+
have hh := box_chaining_probability (Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 72 |
+
(matrixWordSeminorm p) (matrixWordSeminorm_lipschitz p).continuous (matrixWordSeminorm_add p)
|
| 73 |
+
(fun θ g=>matrixCentered (F θ) (WithLp.toLp 2 g)) hc hn hB (by linarith : B+1 ≤ 2*(B+1))
|
| 74 |
+
hdim b r (fun k=>by dsimp [r];positivity) hsum.summable hbase hincr
|
| 75 |
+
rw [hsum.tsum_eq] at hh
|
| 76 |
+
have he : b+b*4=gaussianMatrixChainConstant H B := by dsimp [b,T,gaussianMatrixChainConstant];ring
|
| 77 |
+
rwa [he] at hh
|
| 78 |
+
end SKGap
|
| 79 |
+
end
|
| 80 |
+
end
|
| 81 |
+
|
| 82 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianPDFMoment.lean
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussMoment
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open MeasureTheory ProbabilityTheory
|
| 14 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 15 |
+
open scoped BigOperators NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory
|
| 17 |
+
open scoped BigOperators NNReal ENNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
open MeasureTheory ProbabilityTheory
|
| 21 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 22 |
+
open scoped BigOperators
|
| 23 |
+
open MeasureTheory ProbabilityTheory
|
| 24 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 25 |
+
open scoped BigOperators
|
| 26 |
+
open scoped BigOperators NNReal ENNReal
|
| 27 |
+
open MeasureTheory Metric Set
|
| 28 |
+
open scoped BigOperators NNReal ENNReal
|
| 29 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 30 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 31 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 32 |
+
open scoped BigOperators Matrix.Norms.L2Operator
|
| 33 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 34 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 35 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 36 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 37 |
+
open scoped BigOperators ENNReal NNReal
|
| 38 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 39 |
+
open scoped BigOperators NNReal ENNReal Matrix
|
| 40 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 41 |
+
open scoped BigOperators ENNReal NNReal
|
| 42 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 43 |
+
open scoped BigOperators NNReal ENNReal
|
| 44 |
+
open scoped BigOperators
|
| 45 |
+
open MeasureTheory ProbabilityTheory
|
| 46 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
|
| 47 |
+
open scoped BigOperators
|
| 48 |
+
open Filter Topology
|
| 49 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 50 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 51 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 52 |
+
open Matrix
|
| 53 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise
|
| 54 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 55 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 56 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 57 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 58 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 59 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 60 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 61 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 62 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 63 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 64 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 65 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 66 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 67 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 68 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 69 |
+
open scoped ENNReal Topology
|
| 70 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 71 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 72 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 73 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 74 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 75 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 76 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 77 |
+
open scoped ENNReal NNReal Topology BigOperators
|
| 78 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 79 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 80 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 81 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 82 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 83 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 84 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 85 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 86 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 87 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 88 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 89 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 90 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 91 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 92 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 93 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 94 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 95 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 96 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 97 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 98 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 99 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 100 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 101 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 102 |
+
open MeasureTheory ProbabilityTheory Filter Set Matrix
|
| 103 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 104 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 105 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 106 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 107 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 108 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 109 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 110 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 111 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 112 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 113 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix Matrix.Norms.Elementwise
|
| 114 |
+
open Filter MeasureTheory ProbabilityTheory
|
| 115 |
+
open scoped Topology NNReal ENNReal
|
| 116 |
+
open Filter MeasureTheory ProbabilityTheory
|
| 117 |
+
open scoped Topology NNReal ENNReal
|
| 118 |
+
open MeasureTheory Filter
|
| 119 |
+
open scoped Topology NNReal ENNReal
|
| 120 |
+
open MeasureTheory Filter ProbabilityTheory
|
| 121 |
+
open scoped Topology NNReal ENNReal
|
| 122 |
+
namespace SKGapCutoff.Clock
|
| 123 |
+
|
| 124 |
+
lemma gaussianPDF_moment (v : ℝ≥0) (y x : ℝ) :
|
| 125 |
+
gaussianPDFReal y v x = (Real.sqrt (2*Real.pi*v))⁻¹ *
|
| 126 |
+
gaussMoment (1/(2*(v:ℝ))) 0 (x-y) := by
|
| 127 |
+
unfold gaussianPDFReal gaussMoment
|
| 128 |
+
simp only [pow_zero,one_mul]
|
| 129 |
+
congr 2
|
| 130 |
+
ring
|
| 131 |
+
|
| 132 |
+
theorem finite_gaussianPDF_approximation {v w : ℝ≥0} (hv : 0 < v) (hw : 0 < w)
|
| 133 |
+
(hwv : w ≤ v) {ε : ℝ} (hε : 0 < ε) :
|
| 134 |
+
∃ (s : Finset ℝ) (c : ℝ → ℝ),
|
| 135 |
+
(∫ x : ℝ, |gaussianPDFReal 0 w x-
|
| 136 |
+
∑ y ∈ s, c y*gaussianPDFReal (-y) v x|) < ε := by
|
| 137 |
+
have hvR : (0:ℝ) < v := hv
|
| 138 |
+
have hwR : (0:ℝ) < w := hw
|
| 139 |
+
let kv : ℝ := (Real.sqrt (2*Real.pi*v))⁻¹
|
| 140 |
+
let kw : ℝ := (Real.sqrt (2*Real.pi*w))⁻¹
|
| 141 |
+
have hkv : 0 < kv := by dsimp [kv]; positivity
|
| 142 |
+
have hkw : 0 < kw := by dsimp [kw]; positivity
|
| 143 |
+
have hra : 0 < 1/(2*(v:ℝ)) := by positivity
|
| 144 |
+
have hrab : 1/(2*(v:ℝ)) ≤ 1/(2*(w:ℝ)) := by
|
| 145 |
+
apply one_div_le_one_div_of_le (by positivity)
|
| 146 |
+
exact mul_le_mul_of_nonneg_left (show (w:ℝ) ≤ v from hwv) (by norm_num)
|
| 147 |
+
obtain ⟨s,c,hc⟩ := finite_gaussian_approximation hra hrab (show 0 < ε/kw by positivity)
|
| 148 |
+
refine ⟨s,fun y => kw*c y/kv,?_⟩
|
| 149 |
+
have he (x : ℝ) : |gaussianPDFReal 0 w x-
|
| 150 |
+
∑ y ∈ s, (kw*c y/kv)*gaussianPDFReal (-y) v x| =
|
| 151 |
+
kw*|gaussMoment (1/(2*(w:ℝ))) 0 x-
|
| 152 |
+
∑ y ∈ s, c y*gaussMoment (1/(2*(v:ℝ))) 0 (x+y)| := by
|
| 153 |
+
simp only [gaussianPDF_moment,sub_zero,sub_neg_eq_add]
|
| 154 |
+
change |kw*gaussMoment (1/(2*(w:ℝ))) 0 x-
|
| 155 |
+
∑ y ∈ s, (kw*c y/kv)*(kv*gaussMoment (1/(2*(v:ℝ))) 0 (x+y))| = _
|
| 156 |
+
have hterm (y : ℝ) : (kw*c y/kv)*(kv*gaussMoment (1/(2*(v:ℝ))) 0 (x+y)) =
|
| 157 |
+
kw*(c y*gaussMoment (1/(2*(v:ℝ))) 0 (x+y)) := by field_simp
|
| 158 |
+
simp_rw [hterm]
|
| 159 |
+
rw [← Finset.mul_sum,← mul_sub,abs_mul,abs_of_pos hkw]
|
| 160 |
+
simp_rw [he]
|
| 161 |
+
rw [integral_const_mul]
|
| 162 |
+
have hh := mul_lt_mul_of_pos_left hc hkw
|
| 163 |
+
rwa [mul_div_cancel₀ _ hkw.ne'] at hh
|
| 164 |
+
|
| 165 |
+
end SKGapCutoff.Clock
|
| 166 |
+
|
| 167 |
+
open MeasureTheory Filter
|
| 168 |
+
open scoped Topology
|
| 169 |
+
|
| 170 |
+
end
|
| 171 |
+
|
| 172 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianPartition.lean
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Terminal.SpinEnergy
|
| 3 |
+
import OAI.Probability.SKGap.Entropy.GaussianExponentialLinear
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open MeasureTheory ProbabilityTheory Real
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
|
| 13 |
+
def edgeCoefficient {n : ℕ} (r : ℝ) (x : Spin n) : Edge n→ℝ :=
|
| 14 |
+
fun e=>sqrt r*spinValue (x e.1.1)*spinValue (x e.1.2)
|
| 15 |
+
|
| 16 |
+
def gaussianSpinPartition (n : ℕ) (r : ℝ) (g : Disorder n) : ℝ :=
|
| 17 |
+
∑ x : Spin n,exp (∑ e,edgeCoefficient r x e*g e)
|
| 18 |
+
|
| 19 |
+
lemma gaussianSpinPartition_eq_partition {n : ℕ} (r : ℝ) (g : Disorder n) :
|
| 20 |
+
gaussianSpinPartition n r g=partition (fun e=>sqrt r*g e) 0 := by
|
| 21 |
+
unfold gaussianSpinPartition partition weight
|
| 22 |
+
apply Finset.sum_congr rfl;intro x _
|
| 23 |
+
rw [edge_energy_formula]
|
| 24 |
+
congr 1
|
| 25 |
+
apply Finset.sum_congr rfl;intro e _
|
| 26 |
+
unfold edgeCoefficient;ring
|
| 27 |
+
|
| 28 |
+
lemma edgeCoefficient_sq_sum {n : ℕ} {r : ℝ} (hr : 0 ≤ r) (x : Spin n) :
|
| 29 |
+
(∑ e,edgeCoefficient r x e^2)= r*(Fintype.card (Edge n):ℝ) := by
|
| 30 |
+
simp only [edgeCoefficient,mul_pow,spinValue_sq,sq_sqrt hr,mul_one,
|
| 31 |
+
Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_comm]
|
| 32 |
+
|
| 33 |
+
lemma edgeCoefficient_add_sq {n : ℕ} {r : ℝ} (hr : 0 ≤ r) (x y : Spin n) (e : Edge n) :
|
| 34 |
+
(edgeCoefficient r x e+edgeCoefficient r y e)^2=
|
| 35 |
+
2*r+2*r*spinValue (spinMul x y e.1.1)*spinValue (spinMul x y e.1.2) := by
|
| 36 |
+
have hc : edgeCoefficient r x e*edgeCoefficient r y e=
|
| 37 |
+
r*spinValue (spinMul x y e.1.1)*spinValue (spinMul x y e.1.2) := by
|
| 38 |
+
rw [spinValue_mul,spinValue_mul]
|
| 39 |
+
unfold edgeCoefficient
|
| 40 |
+
calc
|
| 41 |
+
_ = (sqrt r)^2*spinValue (x e.1.1)*spinValue (y e.1.1)*spinValue (x e.1.2)*spinValue (y e.1.2) := by ring
|
| 42 |
+
_ = _ := by rw [sq_sqrt hr];ring
|
| 43 |
+
have hs (z : Spin n) : edgeCoefficient r z e^2=r := by
|
| 44 |
+
simp only [edgeCoefficient,mul_pow,spinValue_sq,sq_sqrt hr,mul_one]
|
| 45 |
+
nlinarith only [hc,hs x,hs y]
|
| 46 |
+
|
| 47 |
+
lemma edgeCoefficient_add_sq_sum {n : ℕ} {r : ℝ} (hr : 0 ≤ r) (x y : Spin n) :
|
| 48 |
+
(∑ e,(edgeCoefficient r x e+edgeCoefficient r y e)^2)=
|
| 49 |
+
2*r*(Fintype.card (Edge n):ℝ)+r*((∑ i,spinValue (spinMul x y i))^2-(n:ℝ)) := by
|
| 50 |
+
simp_rw [edgeCoefficient_add_sq hr x y]
|
| 51 |
+
rw [Finset.sum_add_distrib]
|
| 52 |
+
have he := edge_symmetric_sum (fun i=>spinValue (spinMul x y i))
|
| 53 |
+
simp only [spinValue_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_one] at he
|
| 54 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 55 |
+
have hsum : (∑ e : Edge n,2*r*spinValue (spinMul x y e.1.1)*spinValue (spinMul x y e.1.2))=
|
| 56 |
+
r*(2*∑ e : Edge n,spinValue (spinMul x y e.1.1)*spinValue (spinMul x y e.1.2)) := by
|
| 57 |
+
simp only [Finset.mul_sum];apply Finset.sum_congr rfl;intro e _;ring
|
| 58 |
+
rw [hsum,he];ring
|
| 59 |
+
|
| 60 |
+
lemma gaussianSpinPartition_integrable (n : ℕ) (r : ℝ) :
|
| 61 |
+
Integrable (gaussianSpinPartition n r) (gaussianCoordinates (Edge n)) :=
|
| 62 |
+
integrable_finsetSum _ (fun x _=>linear_gaussian_exp_integrable (edgeCoefficient r x))
|
| 63 |
+
|
| 64 |
+
lemma gaussianSpinPartition_integral {n : ℕ} {r : ℝ} (hr : 0 ≤ r) :
|
| 65 |
+
(∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))=
|
| 66 |
+
(Fintype.card (Spin n):ℝ)*exp (r*(Fintype.card (Edge n):ℝ)/2) := by
|
| 67 |
+
unfold gaussianSpinPartition
|
| 68 |
+
rw [integral_finsetSum _ (fun x _=>linear_gaussian_exp_integrable (edgeCoefficient r x))]
|
| 69 |
+
simp only [linear_gaussian_exp_integral,edgeCoefficient_sq_sum hr,
|
| 70 |
+
Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 71 |
+
|
| 72 |
+
lemma gaussianSpinPartition_square (n : ℕ) (r : ℝ) (g : Disorder n) :
|
| 73 |
+
(gaussianSpinPartition n r g)^2=
|
| 74 |
+
∑ x : Spin n,∑ y : Spin n,exp (∑ e,(edgeCoefficient r x e+edgeCoefficient r y e)*g e) := by
|
| 75 |
+
unfold gaussianSpinPartition
|
| 76 |
+
rw [sq,Finset.sum_mul_sum]
|
| 77 |
+
apply Finset.sum_congr rfl;intro x _
|
| 78 |
+
apply Finset.sum_congr rfl;intro y _
|
| 79 |
+
rw [← exp_add]
|
| 80 |
+
congr 1
|
| 81 |
+
simp only [add_mul,Finset.sum_add_distrib]
|
| 82 |
+
|
| 83 |
+
lemma gaussianSpinPartition_square_integrable (n : ℕ) (r : ℝ) :
|
| 84 |
+
Integrable (fun g=>(gaussianSpinPartition n r g)^2) (gaussianCoordinates (Edge n)) := by
|
| 85 |
+
simp_rw [gaussianSpinPartition_square]
|
| 86 |
+
exact integrable_finsetSum _ (fun x _=>integrable_finsetSum _
|
| 87 |
+
(fun y _=>linear_gaussian_exp_integrable (fun e=>edgeCoefficient r x e+edgeCoefficient r y e)))
|
| 88 |
+
|
| 89 |
+
lemma gaussianSpinPartition_square_integral {n : ℕ} {r : ℝ} (hr : 0 ≤ r) :
|
| 90 |
+
(∫ g,(gaussianSpinPartition n r g)^2 ∂gaussianCoordinates (Edge n))=
|
| 91 |
+
(Fintype.card (Spin n):ℝ)*exp (r*(Fintype.card (Edge n):ℝ)-r*(n:ℝ)/2)*
|
| 92 |
+
∑ x : Spin n,exp (r/2*(∑ i,spinValue (x i))^2) := by
|
| 93 |
+
simp_rw [gaussianSpinPartition_square]
|
| 94 |
+
rw [integral_finsetSum _ (fun x _=>integrable_finsetSum _
|
| 95 |
+
(fun y _=>linear_gaussian_exp_integrable (fun e=>edgeCoefficient r x e+edgeCoefficient r y e)))]
|
| 96 |
+
simp_rw [integral_finsetSum _ (fun y _=>linear_gaussian_exp_integrable _),
|
| 97 |
+
linear_gaussian_exp_integral,edgeCoefficient_add_sq_sum hr]
|
| 98 |
+
have he (x y : Spin n) : exp ((2*r*(Fintype.card (Edge n):ℝ)+
|
| 99 |
+
r*((∑ i,spinValue (spinMul x y i))^2-(n:ℝ)))/2)=
|
| 100 |
+
exp (r*(Fintype.card (Edge n):ℝ)-r*(n:ℝ)/2)*exp (r/2*(∑ i,spinValue (spinMul x y i))^2) := by
|
| 101 |
+
rw [← exp_add];congr 1;ring
|
| 102 |
+
simp_rw [he,← Finset.mul_sum]
|
| 103 |
+
have hs (x : Spin n) :
|
| 104 |
+
(∑ y : Spin n,exp (r/2*(∑ i,spinValue (spinMul x y i))^2))=
|
| 105 |
+
∑ y : Spin n,exp (r/2*(∑ i,spinValue (y i))^2) :=
|
| 106 |
+
sum_spinMul x (fun y=>exp (r/2*(∑ i,spinValue (y i))^2))
|
| 107 |
+
simp_rw [hs]
|
| 108 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_assoc]
|
| 109 |
+
ring
|
| 110 |
+
|
| 111 |
+
end SKGap
|
| 112 |
+
end
|
| 113 |
+
end
|
| 114 |
+
|
| 115 |
+
section
|
| 116 |
+
noncomputable section
|
| 117 |
+
namespace SKGap
|
| 118 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 119 |
+
|
| 120 |
+
lemma second_moment_positive_probability {Ω : Type*} [MeasurableSpace Ω]
|
| 121 |
+
(μ : Measure Ω) [IsProbabilityMeasure μ] (Z : Ω→ℝ)
|
| 122 |
+
(hZ : Measurable Z) (hi : Integrable Z μ) (hi2 : Integrable (fun x=>Z x^2) μ)
|
| 123 |
+
{M B : ℝ} (hM : 0 < M) (hB : 0 < B) (hmean : (∫ x,Z x ∂μ)=M)
|
| 124 |
+
(hmoment : (∫ x,Z x^2 ∂μ) ≤ B*M^2) :
|
| 125 |
+
1/(4*B) ≤ μ.real {x | M/2 ≤ Z x} := by
|
| 126 |
+
let S : Set Ω := {x | M/2 ≤ Z x}
|
| 127 |
+
have hS : MeasurableSet S := measurableSet_le measurable_const hZ
|
| 128 |
+
have hden : 0 < 4*B*M := by positivity
|
| 129 |
+
have hpoint : ∀ x,Z x ≤ M/2+B*M*S.indicator (fun _=>1) x+Z x^2/(4*B*M) := by
|
| 130 |
+
intro x
|
| 131 |
+
by_cases hx : x∈S
|
| 132 |
+
· rw [indicator_of_mem hx]
|
| 133 |
+
apply (mul_le_mul_iff_right₀ hden).mp
|
| 134 |
+
nlinarith [sq_nonneg (Z x-2*B*M),div_mul_cancel₀ (Z x^2) hden.ne',
|
| 135 |
+
mul_nonneg hB.le (sq_nonneg M)]
|
| 136 |
+
· rw [indicator_of_notMem hx]
|
| 137 |
+
change ¬ M/2 ≤ Z x at hx
|
| 138 |
+
have hn : 0 ≤ Z x^2/(4*B*M) := div_nonneg (sq_nonneg _) hden.le
|
| 139 |
+
nlinarith [not_le.mp hx]
|
| 140 |
+
have hiS : Integrable (S.indicator (fun _=> (1:ℝ))) μ := (integrable_const _).indicator hS
|
| 141 |
+
have hiA : Integrable (fun x=>M/2+B*M*S.indicator (fun _=>(1:ℝ)) x) μ :=
|
| 142 |
+
(integrable_const (M/2)).add (hiS.const_mul (B*M))
|
| 143 |
+
have hiB : Integrable (fun x=>B*M*S.indicator (fun _=>(1:ℝ)) x) μ := hiS.const_mul _
|
| 144 |
+
have hiC : Integrable (fun x=>Z x^2/(4*B*M)) μ := hi2.div_const _
|
| 145 |
+
have hh := integral_mono hi (hiA.add hiC) hpoint
|
| 146 |
+
change (∫ x,Z x ∂μ) ≤ ∫ x,M/2+B*M*S.indicator (fun _=>(1:ℝ)) x+Z x^2/(4*B*M) ∂μ at hh
|
| 147 |
+
rw [hmean,integral_add hiA hiC,integral_add (integrable_const (M/2)) hiB,
|
| 148 |
+
integral_const,integral_const_mul,integral_div,integral_indicator hS,
|
| 149 |
+
setIntegral_const] at hh
|
| 150 |
+
simp only [probReal_univ,smul_eq_mul,mul_one,one_mul] at hh
|
| 151 |
+
have hterm : (∫ x,Z x^2 ∂μ)/(4*B*M) ≤ M/4 := by
|
| 152 |
+
apply (div_le_iff₀ hden).mpr
|
| 153 |
+
nlinarith only [hmoment]
|
| 154 |
+
have hh' : 1 ≤ 4*B*μ.real S := by
|
| 155 |
+
have h : M/4 ≤ B*M*μ.real S := by linarith only [hh,hterm]
|
| 156 |
+
apply (mul_le_mul_iff_right₀ hM).mp
|
| 157 |
+
nlinarith only [h]
|
| 158 |
+
exact (div_le_iff₀ (show 0 < 4*B by positivity)).mpr (by nlinarith only [hh'])
|
| 159 |
+
end SKGap
|
| 160 |
+
end
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianProductIntegral.lean
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Terminal.PowExponentialPair
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 9 |
+
open scoped NNReal ENNReal
|
| 10 |
+
open Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
open Matrix Real
|
| 14 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 15 |
+
noncomputable section
|
| 16 |
+
open Matrix Real
|
| 17 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 18 |
+
noncomputable section
|
| 19 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 20 |
+
open MeasureTheory.Measure
|
| 21 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 22 |
+
namespace SKGap
|
| 23 |
+
open MeasureTheory ProbabilityTheory Real
|
| 24 |
+
open scoped Topology
|
| 25 |
+
section ProductMoments
|
| 26 |
+
variable {κ : Type*} [Fintype κ]
|
| 27 |
+
|
| 28 |
+
lemma gaussianProduct_integral (F : EuclideanSpace ℝ κ → ℝ) (hF : Continuous F) :
|
| 29 |
+
(∫ g : κ → ℝ, F (WithLp.toLp 2 g) ∂Measure.pi (fun _ => gaussianReal 0 1)) =
|
| 30 |
+
∫ x, F x ∂stdGaussian (EuclideanSpace ℝ κ) := by
|
| 31 |
+
rw [← map_pi_eq_stdGaussian]
|
| 32 |
+
exact (integral_map (by fun_prop) hF.aestronglyMeasurable).symm
|
| 33 |
+
|
| 34 |
+
lemma gaussianProduct_integrable_lipschitz {F : EuclideanSpace ℝ κ → ℝ}
|
| 35 |
+
{L : ℝ≥0} (hF : LipschitzWith L F) :
|
| 36 |
+
Integrable (fun g : κ → ℝ => F (WithLp.toLp 2 g))
|
| 37 |
+
(Measure.pi (fun _ => gaussianReal 0 1)) := by
|
| 38 |
+
have hi := gaussian_integrable_lipschitz (μ := stdGaussian (EuclideanSpace ℝ κ)) hF
|
| 39 |
+
rw [← map_pi_eq_stdGaussian] at hi
|
| 40 |
+
exact hi.comp_measurable (by fun_prop)
|
| 41 |
+
|
| 42 |
+
lemma gaussianProduct_abs_centered_moment {F : EuclideanSpace ℝ κ → ℝ}
|
| 43 |
+
{L : ℝ≥0} (hF : LipschitzWith L F) (hL : 0 < L) (k : ℕ) :
|
| 44 |
+
(∫ g : κ → ℝ, |F (WithLp.toLp 2 g)-
|
| 45 |
+
∫ h : κ → ℝ, F (WithLp.toLp 2 h) ∂Measure.pi (fun _ => gaussianReal 0 1)|^k
|
| 46 |
+
∂Measure.pi (fun _ => gaussianReal 0 1)) ≤
|
| 47 |
+
(2*(k.factorial : ℝ)*exp (π^2/8))*(L:ℝ)^k := by
|
| 48 |
+
rw [gaussianProduct_integral F hF.continuous]
|
| 49 |
+
rw [gaussianProduct_integral (fun x => |F x-∫ y, F y ∂stdGaussian _|^k) ((hF.continuous.sub continuous_const).abs.pow k)]
|
| 50 |
+
exact stdGaussian_abs_centered_moment hF hL k
|
| 51 |
+
|
| 52 |
+
lemma gaussianProduct_centered_L1 {F : EuclideanSpace ℝ κ → ℝ}
|
| 53 |
+
{L : ℝ≥0} (hF : LipschitzWith L F) (hL : 0 < L) :
|
| 54 |
+
(∫ g : κ → ℝ, |F (WithLp.toLp 2 g)-
|
| 55 |
+
∫ h : κ → ℝ, F (WithLp.toLp 2 h) ∂Measure.pi (fun _ => gaussianReal 0 1)|
|
| 56 |
+
∂Measure.pi (fun _ => gaussianReal 0 1)) ≤
|
| 57 |
+
(2*exp (π^2/8))*(L:ℝ) := by
|
| 58 |
+
simpa using gaussianProduct_abs_centered_moment hF hL 1
|
| 59 |
+
|
| 60 |
+
end ProductMoments
|
| 61 |
+
end SKGap
|
| 62 |
+
|
| 63 |
+
open MeasureTheory
|
| 64 |
+
noncomputable section
|
| 65 |
+
|
| 66 |
+
end
|
| 67 |
+
end
|
| 68 |
+
end
|
| 69 |
+
end
|
| 70 |
+
end
|
| 71 |
+
end
|
| 72 |
+
|
| 73 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianProductPower.lean
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianProductIntegral
|
| 3 |
+
import OAI.Probability.SKGap.Matrix.MatrixSeminorm
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Real MeasureTheory ProbabilityTheory
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {κ : Type*} [Fintype κ]
|
| 13 |
+
|
| 14 |
+
lemma gaussianProduct_integrable_exp_lipschitz {F : EuclideanSpace ℝ κ→ℝ}
|
| 15 |
+
{L : NNReal} (hF : LipschitzWith L F) (r : ℝ) :
|
| 16 |
+
Integrable (fun g : κ→ℝ=>exp (r*F (WithLp.toLp 2 g))) (Measure.pi (fun _=>gaussianReal 0 1)) := by
|
| 17 |
+
have hi := gaussian_integrable_exp_lipschitz (μ:=stdGaussian (EuclideanSpace ℝ κ)) hF r
|
| 18 |
+
rw [←map_pi_eq_stdGaussian] at hi
|
| 19 |
+
exact hi.comp_measurable (by fun_prop)
|
| 20 |
+
|
| 21 |
+
lemma gaussianProduct_integrable_abs_pow_lipschitz {F : EuclideanSpace ℝ κ→ℝ}
|
| 22 |
+
{L : NNReal} (hF : LipschitzWith L F) (k : ℕ) :
|
| 23 |
+
Integrable (fun g : κ→ℝ=>|F (WithLp.toLp 2 g)|^k) (Measure.pi (fun _=>gaussianReal 0 1)) := by
|
| 24 |
+
let μ := Measure.pi (fun _ : κ=>gaussianReal 0 1)
|
| 25 |
+
have h1 := gaussianProduct_integrable_exp_lipschitz hF 1
|
| 26 |
+
have h2 := gaussianProduct_integrable_exp_lipschitz hF (-1)
|
| 27 |
+
have hh := (h1.add h2).const_mul (k.factorial:ℝ)
|
| 28 |
+
apply hh.mono'
|
| 29 |
+
· exact ((hF.continuous.comp (by fun_prop : Continuous (WithLp.toLp 2 : (κ→ℝ)→EuclideanSpace ℝ κ))).abs.pow k).aestronglyMeasurable
|
| 30 |
+
· filter_upwards [] with g
|
| 31 |
+
simpa only [Real.norm_eq_abs,abs_pow,abs_abs,one_pow,div_one,Pi.add_apply] using
|
| 32 |
+
pow_le_exponential_pair (F (WithLp.toLp 2 g)) (by norm_num : (0:ℝ)<1) k
|
| 33 |
+
|
| 34 |
+
lemma gaussianProduct_integrable_pow_lipschitz {F : EuclideanSpace ℝ κ→ℝ}
|
| 35 |
+
{L : NNReal} (hF : LipschitzWith L F) (k : ℕ) :
|
| 36 |
+
Integrable (fun g : κ→ℝ=>F (WithLp.toLp 2 g)^k) (Measure.pi (fun _=>gaussianReal 0 1)) := by
|
| 37 |
+
apply (gaussianProduct_integrable_abs_pow_lipschitz hF k).mono'
|
| 38 |
+
· exact ((hF.continuous.comp (by fun_prop : Continuous (WithLp.toLp 2 : (κ→ℝ)→EuclideanSpace ℝ κ))).pow k).aestronglyMeasurable
|
| 39 |
+
· filter_upwards [] with g
|
| 40 |
+
simp only [Real.norm_eq_abs,abs_pow,le_refl]
|
| 41 |
+
end SKGap
|
| 42 |
+
end
|
| 43 |
+
end
|
| 44 |
+
|
| 45 |
+
section
|
| 46 |
+
noncomputable section
|
| 47 |
+
namespace SKGap
|
| 48 |
+
open Real Matrix MeasureTheory ProbabilityTheory Set
|
| 49 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 50 |
+
variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ]
|
| 51 |
+
|
| 52 |
+
def matrixEntryMean (F : EuclideanSpace ℝ κ→Matrix ι ι ℝ) : Matrix ι ι ℝ :=
|
| 53 |
+
fun i k=>∫ g : κ→ℝ,F (WithLp.toLp 2 g) i k ∂Measure.pi (fun _=>gaussianReal 0 1)
|
| 54 |
+
def matrixCentered (F : EuclideanSpace ℝ κ→Matrix ι ι ℝ) (x : EuclideanSpace ℝ κ) :=
|
| 55 |
+
F x-matrixEntryMean F
|
| 56 |
+
|
| 57 |
+
lemma matrixCentered_lipschitz {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 58 |
+
{L : NNReal} (hF : LipschitzWith L F) : LipschitzWith L (matrixCentered F) := by
|
| 59 |
+
apply LipschitzWith.of_dist_le_mul
|
| 60 |
+
intro x y
|
| 61 |
+
simpa only [matrixCentered,dist_sub_right] using hF.dist_le_mul x y
|
| 62 |
+
|
| 63 |
+
lemma matrixEntry_lip {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 64 |
+
{L : NNReal} (hF : LipschitzWith L F) (i k : ι) : LipschitzWith L (fun x=>F x i k) := by
|
| 65 |
+
simpa only [one_mul,Function.comp_def] using (matrixEntry_lipschitz i k).comp hF
|
| 66 |
+
|
| 67 |
+
lemma diagonalCentered_lip {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 68 |
+
{L : NNReal} (hF : LipschitzWith L F) : LipschitzWith L (fun x=>diagonalSeminorm (matrixCentered F x)) := by
|
| 69 |
+
simpa only [one_mul,Function.comp_def] using diagonalSeminorm_lipschitz.comp (matrixCentered_lipschitz hF)
|
| 70 |
+
lemma offDiagonalCentered_lip {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 71 |
+
{L : NNReal} (hF : LipschitzWith L F) : LipschitzWith L (fun x=>offDiagonalSeminorm (matrixCentered F x)) := by
|
| 72 |
+
simpa only [one_mul,Function.comp_def] using offDiagonalSeminorm_lipschitz.comp (matrixCentered_lipschitz hF)
|
| 73 |
+
|
| 74 |
+
lemma matrixCentered_even_moment {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 75 |
+
{L : NNReal} (hF : LipschitzWith L F) (hL : 0<L) (i b : ι) (k : ℕ) :
|
| 76 |
+
(∫ g : κ→ℝ,(matrixCentered F (WithLp.toLp 2 g) i b)^(2*k) ∂Measure.pi (fun _=>gaussianReal 0 1))≤
|
| 77 |
+
(2*((2*k).factorial:ℝ)*exp (π^2/8))*(L:ℝ)^(2*k) := by
|
| 78 |
+
have hh := gaussianProduct_abs_centered_moment (matrixEntry_lip hF i b) hL (2*k)
|
| 79 |
+
simpa only [matrixCentered,matrixEntryMean,Matrix.sub_apply,pow_mul,sq_abs] using hh
|
| 80 |
+
|
| 81 |
+
lemma diagonalCentered_second_moment {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 82 |
+
{L : NNReal} (hF : LipschitzWith L F) (hL : 0<L) :
|
| 83 |
+
(∫ g : κ→ℝ,diagonalSeminorm (matrixCentered F (WithLp.toLp 2 g))^2 ∂Measure.pi (fun _=>gaussianReal 0 1))≤
|
| 84 |
+
(Fintype.card ι:ℝ)*(4*exp (π^2/8))*(L:ℝ)^2 := by
|
| 85 |
+
simp_rw [diagonalSeminorm_sq]
|
| 86 |
+
rw [integral_finsetSum _ (fun i _=>gaussianProduct_integrable_pow_lipschitz (matrixEntry_lip (matrixCentered_lipschitz hF) i i) 2)]
|
| 87 |
+
apply (Finset.sum_le_sum (fun i _=>matrixCentered_even_moment hF hL i i 1)).trans_eq
|
| 88 |
+
norm_num [Finset.sum_const,mul_assoc]
|
| 89 |
+
|
| 90 |
+
lemma offDiagonalCentered_fourth_moment {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 91 |
+
{L : NNReal} (hF : LipschitzWith L F) (hL : 0<L) :
|
| 92 |
+
(∫ g : κ→ℝ,offDiagonalSeminorm (matrixCentered F (WithLp.toLp 2 g))^4 ∂Measure.pi (fun _=>gaussianReal 0 1))≤
|
| 93 |
+
(Fintype.card ι:ℝ)^2*(48*exp (π^2/8))*(L:ℝ)^4 := by
|
| 94 |
+
simp_rw [offDiagonalSeminorm_fourth]
|
| 95 |
+
have hi (p : ι×ι) : Integrable (fun g : κ→ℝ=>if p.1=p.2 then 0 else matrixCentered F (WithLp.toLp 2 g) p.1 p.2^4)
|
| 96 |
+
(Measure.pi (fun _=>gaussianReal 0 1)) := by
|
| 97 |
+
split_ifs
|
| 98 |
+
· exact integrable_const _
|
| 99 |
+
· exact gaussianProduct_integrable_pow_lipschitz (matrixEntry_lip (matrixCentered_lipschitz hF) p.1 p.2) 4
|
| 100 |
+
rw [integral_finsetSum _ (fun p _=>hi p)]
|
| 101 |
+
have hb (p : ι×ι) : (∫ g : κ→ℝ,(if p.1=p.2 then 0 else matrixCentered F (WithLp.toLp 2 g) p.1 p.2^4)
|
| 102 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)) ≤ (48*exp (π^2/8))*(L:ℝ)^4 := by
|
| 103 |
+
split_ifs
|
| 104 |
+
· simp only [integral_zero];positivity
|
| 105 |
+
· have hh := matrixCentered_even_moment hF hL p.1 p.2 2
|
| 106 |
+
norm_num at hh
|
| 107 |
+
exact hh
|
| 108 |
+
apply (Finset.sum_le_sum (fun p _=>hb p)).trans_eq
|
| 109 |
+
simp only [Finset.sum_const,Finset.card_univ,Fintype.card_prod,nsmul_eq_mul,Nat.cast_mul]
|
| 110 |
+
ring
|
| 111 |
+
|
| 112 |
+
lemma gaussianProduct_jensen_pow {F : EuclideanSpace ℝ κ→ℝ} {L : NNReal}
|
| 113 |
+
(hF : LipschitzWith L F) (hpos : ∀ x,0≤F x) (k : ℕ) :
|
| 114 |
+
(∫ g : κ→ℝ,F (WithLp.toLp 2 g) ∂Measure.pi (fun _=>gaussianReal 0 1))^k≤
|
| 115 |
+
∫ g : κ→ℝ,F (WithLp.toLp 2 g)^k ∂Measure.pi (fun _=>gaussianReal 0 1) := by
|
| 116 |
+
exact (convexOn_pow (𝕜:=ℝ) k).map_integral_le (by fun_prop) isClosed_Ici
|
| 117 |
+
(ae_of_all _ (fun g=>hpos (WithLp.toLp 2 g))) (gaussianProduct_integrable_lipschitz hF)
|
| 118 |
+
(gaussianProduct_integrable_pow_lipschitz hF k)
|
| 119 |
+
|
| 120 |
+
def matrixNormConstant : ℝ := 1+48*exp (π^2/8)
|
| 121 |
+
|
| 122 |
+
omit [Fintype ι] [DecidableEq ι] [Fintype κ] in
|
| 123 |
+
lemma matrixNormConstant_bounds : 1≤ matrixNormConstant ∧
|
| 124 |
+
4*exp (π^2/8)≤ matrixNormConstant^2 ∧ 48*exp (π^2/8)≤ matrixNormConstant^4 := by
|
| 125 |
+
have hE := (exp_pos (π^2/8)).le
|
| 126 |
+
have hC : 1≤ matrixNormConstant := by unfold matrixNormConstant;linarith
|
| 127 |
+
have hC2 : matrixNormConstant≤ matrixNormConstant^2 := by
|
| 128 |
+
simpa only [pow_one] using pow_le_pow_right₀ hC (by decide : 1≤2)
|
| 129 |
+
have hC4 : matrixNormConstant≤ matrixNormConstant^4 := by
|
| 130 |
+
simpa only [pow_one] using pow_le_pow_right₀ hC (by decide : 1≤4)
|
| 131 |
+
refine ⟨hC,?_,?_⟩ <;> unfold matrixNormConstant at * <;> linarith
|
| 132 |
+
|
| 133 |
+
lemma gaussianProduct_centered_matrix_norms {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 134 |
+
{L : NNReal} (hF : LipschitzWith L F) (hL : 0<L) :
|
| 135 |
+
(∫ g : κ→ℝ,diagonalSeminorm (matrixCentered F (WithLp.toLp 2 g)) ∂Measure.pi (fun _=>gaussianReal 0 1))≤
|
| 136 |
+
matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ) ∧
|
| 137 |
+
(∫ g : κ→ℝ,offDiagonalSeminorm (matrixCentered F (WithLp.toLp 2 g)) ∂Measure.pi (fun _=>gaussianReal 0 1))≤
|
| 138 |
+
matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ) := by
|
| 139 |
+
let : Fact (1≤(4:ENNReal)) := ⟨by norm_num⟩
|
| 140 |
+
have hC0 : 0≤ matrixNormConstant := zero_le_one.trans matrixNormConstant_bounds.1
|
| 141 |
+
have hcn : (0:ℝ)≤Fintype.card ι := Nat.cast_nonneg _
|
| 142 |
+
constructor
|
| 143 |
+
· apply le_of_pow_le_pow_left₀ (by decide : 2≠0) (by positivity)
|
| 144 |
+
have hJ := gaussianProduct_jensen_pow (diagonalCentered_lip hF) (fun x=>norm_nonneg (diagonalVector (matrixCentered F x))) 2
|
| 145 |
+
apply (hJ.trans (diagonalCentered_second_moment hF hL)).trans
|
| 146 |
+
rw [mul_pow,mul_pow,sq_sqrt hcn]
|
| 147 |
+
have hh := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left matrixNormConstant_bounds.2.1 hcn) (sq_nonneg (L:ℝ))
|
| 148 |
+
nlinarith only [hh]
|
| 149 |
+
· apply le_of_pow_le_pow_left₀ (by decide : 4≠0) (by positivity)
|
| 150 |
+
have hJ := gaussianProduct_jensen_pow (offDiagonalCentered_lip hF) (fun x=>norm_nonneg (offDiagonalVector (matrixCentered F x))) 4
|
| 151 |
+
apply (hJ.trans (offDiagonalCentered_fourth_moment hF hL)).trans
|
| 152 |
+
have hs : sqrt (Fintype.card ι)^4=(Fintype.card ι:ℝ)^2 := by
|
| 153 |
+
calc
|
| 154 |
+
_ = (sqrt (Fintype.card ι)^2)^2 := by ring
|
| 155 |
+
_ = _ := by rw [sq_sqrt hcn]
|
| 156 |
+
rw [mul_pow,mul_pow,hs]
|
| 157 |
+
have hh := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left matrixNormConstant_bounds.2.2 (sq_nonneg (Fintype.card ι:ℝ))) (by positivity : (0:ℝ)≤(L:ℝ)^4)
|
| 158 |
+
nlinarith only [hh]
|
| 159 |
+
end SKGap
|
| 160 |
+
end
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianProductUpperTailLipschitz.lean
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.StdGaussianMgfLipschitz
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 9 |
+
open scoped NNReal ENNReal
|
| 10 |
+
open Filter
|
| 11 |
+
open scoped Topology
|
| 12 |
+
noncomputable section
|
| 13 |
+
open Matrix Real
|
| 14 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 15 |
+
noncomputable section
|
| 16 |
+
open Matrix Real
|
| 17 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 18 |
+
noncomputable section
|
| 19 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 20 |
+
open MeasureTheory.Measure
|
| 21 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 22 |
+
open MeasureTheory
|
| 23 |
+
noncomputable section
|
| 24 |
+
noncomputable section
|
| 25 |
+
open MeasureTheory Set NormedSpace
|
| 26 |
+
open scoped Topology
|
| 27 |
+
noncomputable section
|
| 28 |
+
open Matrix Real
|
| 29 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 30 |
+
noncomputable section
|
| 31 |
+
open Set Real
|
| 32 |
+
open scoped Topology
|
| 33 |
+
noncomputable section
|
| 34 |
+
open Matrix Set Filter
|
| 35 |
+
open scoped Topology Matrix.Norms.Frobenius
|
| 36 |
+
noncomputable section
|
| 37 |
+
open Matrix NormedSpace ContinuousLinearMap
|
| 38 |
+
open scoped Matrix.Norms.Frobenius
|
| 39 |
+
noncomputable section
|
| 40 |
+
open Matrix
|
| 41 |
+
noncomputable section
|
| 42 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 43 |
+
open scoped ENNReal NNReal
|
| 44 |
+
noncomputable section
|
| 45 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 46 |
+
open scoped NNReal ENNReal
|
| 47 |
+
noncomputable section
|
| 48 |
+
open scoped BigOperators
|
| 49 |
+
open MeasureTheory ProbabilityTheory
|
| 50 |
+
open Real
|
| 51 |
+
namespace SKGap
|
| 52 |
+
section ProductGaussianConcentration
|
| 53 |
+
variable {κ : Type*} [Fintype κ]
|
| 54 |
+
|
| 55 |
+
theorem gaussianProduct_upper_tail_lipschitz {f : (κ → ℝ) → ℝ} {L : ℝ≥0}
|
| 56 |
+
(hf : LipschitzWith L (fun x : EuclideanSpace ℝ κ => f x.ofLp))
|
| 57 |
+
(hL : 0 < L) {u : ℝ} (hu : 0 ≤ u) :
|
| 58 |
+
(Measure.pi (fun _ : κ => gaussianReal 0 1)).real
|
| 59 |
+
{x | u ≤ f x - ∫ y, f y ∂Measure.pi (fun _ : κ => gaussianReal 0 1)} ≤
|
| 60 |
+
Real.exp (-2*u^2/(π^2*(L:ℝ)^2)) := by
|
| 61 |
+
let e : (κ → ℝ) ≃ᵐ EuclideanSpace ℝ κ := MeasurableEquiv.toLp 2 _
|
| 62 |
+
have hp : MeasurePreserving e (Measure.pi (fun _ : κ => gaussianReal 0 1))
|
| 63 |
+
(stdGaussian (EuclideanSpace ℝ κ)) :=
|
| 64 |
+
⟨e.measurable, map_pi_eq_stdGaussian⟩
|
| 65 |
+
have hi := hp.integral_comp' (fun x : EuclideanSpace ℝ κ => f x.ofLp)
|
| 66 |
+
change (∫ x, f x ∂Measure.pi (fun _ : κ => gaussianReal 0 1)) = _ at hi
|
| 67 |
+
have h := stdGaussian_upper_tail_lipschitz hf hL hu
|
| 68 |
+
rw [← hi] at h
|
| 69 |
+
have hs : MeasurableSet {x : EuclideanSpace ℝ κ |
|
| 70 |
+
u ≤ f x.ofLp - ∫ y, f y ∂Measure.pi (fun _ : κ => gaussianReal 0 1)} :=
|
| 71 |
+
measurableSet_le measurable_const (hf.continuous.measurable.sub_const _)
|
| 72 |
+
have he := hp.measure_preimage hs.nullMeasurableSet
|
| 73 |
+
have her := congrArg ENNReal.toReal he
|
| 74 |
+
change (Measure.pi (fun _ : κ => gaussianReal 0 1)).real
|
| 75 |
+
{x | u ≤ f x - ∫ y, f y ∂Measure.pi (fun _ : κ => gaussianReal 0 1)} = _ at her
|
| 76 |
+
rw [her]
|
| 77 |
+
exact h
|
| 78 |
+
|
| 79 |
+
end ProductGaussianConcentration
|
| 80 |
+
end SKGap
|
| 81 |
+
|
| 82 |
+
noncomputable section
|
| 83 |
+
open scoped BigOperators Topology
|
| 84 |
+
open Filter Real
|
| 85 |
+
|
| 86 |
+
end
|
| 87 |
+
end
|
| 88 |
+
end
|
| 89 |
+
end
|
| 90 |
+
end
|
| 91 |
+
end
|
| 92 |
+
end
|
| 93 |
+
end
|
| 94 |
+
end
|
| 95 |
+
end
|
| 96 |
+
end
|
| 97 |
+
end
|
| 98 |
+
end
|
| 99 |
+
end
|
| 100 |
+
end
|
| 101 |
+
end
|
| 102 |
+
|
| 103 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianQuadratic.lean
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Terminal.FiniteSpinCalculus
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.StandardGaussianProduct
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 10 |
+
open scoped NNReal ENNReal
|
| 11 |
+
open Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
noncomputable section
|
| 14 |
+
open Matrix Real
|
| 15 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 16 |
+
noncomputable section
|
| 17 |
+
open Matrix Real
|
| 18 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 19 |
+
noncomputable section
|
| 20 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 21 |
+
open MeasureTheory.Measure
|
| 22 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 23 |
+
open MeasureTheory
|
| 24 |
+
noncomputable section
|
| 25 |
+
noncomputable section
|
| 26 |
+
open MeasureTheory Set NormedSpace
|
| 27 |
+
open scoped Topology
|
| 28 |
+
noncomputable section
|
| 29 |
+
open Matrix Real
|
| 30 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 31 |
+
noncomputable section
|
| 32 |
+
open Set Real
|
| 33 |
+
open scoped Topology
|
| 34 |
+
noncomputable section
|
| 35 |
+
open Matrix Set Filter
|
| 36 |
+
open scoped Topology Matrix.Norms.Frobenius
|
| 37 |
+
noncomputable section
|
| 38 |
+
open Matrix NormedSpace ContinuousLinearMap
|
| 39 |
+
open scoped Matrix.Norms.Frobenius
|
| 40 |
+
noncomputable section
|
| 41 |
+
open Matrix
|
| 42 |
+
noncomputable section
|
| 43 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 44 |
+
open scoped ENNReal NNReal
|
| 45 |
+
noncomputable section
|
| 46 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 47 |
+
open scoped NNReal ENNReal
|
| 48 |
+
noncomputable section
|
| 49 |
+
open scoped BigOperators
|
| 50 |
+
open MeasureTheory ProbabilityTheory
|
| 51 |
+
open Real
|
| 52 |
+
namespace SKGap
|
| 53 |
+
open scoped BigOperators
|
| 54 |
+
|
| 55 |
+
lemma gaussian_integrable_pow (k : ℕ) :
|
| 56 |
+
Integrable (fun x : ℝ => x^k) (gaussianReal 0 1) := by
|
| 57 |
+
apply (integrable_norm_iff (by fun_prop)).mp
|
| 58 |
+
simpa only [id_eq, norm_pow] using
|
| 59 |
+
(IsGaussian.memLp_id (gaussianReal 0 1) (k : ℝ≥0∞) (by simp)).integrable_norm_pow'
|
| 60 |
+
|
| 61 |
+
lemma gaussian_memLp_sq : MemLp (fun x : ℝ => x^2) 2 (gaussianReal 0 1) := by
|
| 62 |
+
apply (memLp_two_iff_integrable_sq (by fun_prop)).mpr
|
| 63 |
+
simpa only [← pow_mul] using gaussian_integrable_pow 4
|
| 64 |
+
|
| 65 |
+
lemma gaussian_integral_sq : (∫ x : ℝ, x^2 ∂gaussianReal 0 1) = 1 := by
|
| 66 |
+
have h := variance_fun_id_gaussianReal (μ := 0) (v := 1)
|
| 67 |
+
rw [variance_eq_integral (by fun_prop), integral_id_gaussianReal] at h
|
| 68 |
+
simpa only [sub_zero, NNReal.coe_one] using h
|
| 69 |
+
|
| 70 |
+
lemma gaussian_integral_fourth : (∫ x : ℝ, x^4 ∂gaussianReal 0 1) = 3 := by
|
| 71 |
+
have hd (x : ℝ) : HasDerivAt (fun x : ℝ => x^3) (3*x^2) x := by
|
| 72 |
+
convert! (hasDerivAt_id x).pow 3 using 1; norm_num [Pi.pow_apply, id_eq]
|
| 73 |
+
have hi : Integrable (fun x : ℝ => (x - 0)*x^3) (gaussianReal 0 1) := by
|
| 74 |
+
simpa only [sub_zero, ← pow_succ'] using gaussian_integrable_pow 4
|
| 75 |
+
have h := gaussian_integration_by_parts (by norm_num : (1 : ℝ≥0) ≠ 0)
|
| 76 |
+
hd (gaussian_integrable_pow 3) ((gaussian_integrable_pow 2).const_mul 3) hi
|
| 77 |
+
simpa only [sub_zero, ← pow_succ', integral_const_mul, gaussian_integral_sq,
|
| 78 |
+
NNReal.coe_one, one_mul, mul_one] using h
|
| 79 |
+
|
| 80 |
+
lemma gaussian_variance_sq : Var[fun x : ℝ => x^2; gaussianReal 0 1] = 2 := by
|
| 81 |
+
rw [variance_eq_sub gaussian_memLp_sq]
|
| 82 |
+
simp only [Pi.pow_apply, ← pow_mul, gaussian_integral_fourth, gaussian_integral_sq]
|
| 83 |
+
norm_num
|
| 84 |
+
|
| 85 |
+
section Quadratic
|
| 86 |
+
variable {ι : Type*} [Fintype ι]
|
| 87 |
+
|
| 88 |
+
def gaussianQuadratic (a : ι → ℝ) (x : ι → ℝ) : ℝ := ∑ i, a i * (x i)^2
|
| 89 |
+
|
| 90 |
+
lemma gaussianQuadratic_memLp (a : ι → ℝ) :
|
| 91 |
+
MemLp (gaussianQuadratic a) 2 (Measure.pi (fun _ : ι => gaussianReal 0 1)) := by
|
| 92 |
+
apply memLp_finsetSum
|
| 93 |
+
intro i _
|
| 94 |
+
exact ((gaussian_memLp_sq.const_mul (a i)).comp_measurePreserving
|
| 95 |
+
(measurePreserving_eval (fun _ : ι => gaussianReal 0 1) i))
|
| 96 |
+
|
| 97 |
+
lemma gaussianQuadratic_mean (a : ι → ℝ) :
|
| 98 |
+
(∫ x, gaussianQuadratic a x ∂Measure.pi (fun _ : ι => gaussianReal 0 1)) = ∑ i, a i := by
|
| 99 |
+
unfold gaussianQuadratic
|
| 100 |
+
have hi (i : ι) : Integrable (fun x : ι → ℝ => a i * (x i)^2)
|
| 101 |
+
(Measure.pi (fun _ : ι => gaussianReal 0 1)) :=
|
| 102 |
+
((gaussian_memLp_sq.const_mul (a i)).comp_measurePreserving
|
| 103 |
+
(measurePreserving_eval (fun _ : ι => gaussianReal 0 1) i)).integrable (by norm_num)
|
| 104 |
+
rw [integral_finsetSum _ (fun i _ => hi i)]
|
| 105 |
+
apply Finset.sum_congr rfl
|
| 106 |
+
intro i _
|
| 107 |
+
rw [integral_const_mul]
|
| 108 |
+
have he : (∫ x : ι → ℝ, (x i)^2 ∂Measure.pi (fun _ : ι => gaussianReal 0 1)) =
|
| 109 |
+
∫ y : ℝ, y^2 ∂gaussianReal 0 1 :=
|
| 110 |
+
integral_comp_eval (μ := fun _ : ι => gaussianReal 0 1) (i := i)
|
| 111 |
+
(f := fun y : ℝ => y^2) (by fun_prop)
|
| 112 |
+
rw [he, gaussian_integral_sq, mul_one]
|
| 113 |
+
|
| 114 |
+
lemma gaussianQuadratic_variance (a : ι → ℝ) :
|
| 115 |
+
Var[gaussianQuadratic a; Measure.pi (fun _ : ι => gaussianReal 0 1)] =
|
| 116 |
+
2 * ∑ i, (a i)^2 := by
|
| 117 |
+
have h : Var[gaussianQuadratic a; Measure.pi (fun _ : ι => gaussianReal 0 1)] =
|
| 118 |
+
∑ i, Var[fun x : ℝ => a i * x^2; gaussianReal 0 1] := by
|
| 119 |
+
convert variance_sum_pi (fun i : ι => gaussian_memLp_sq.const_mul (a i)) using 1
|
| 120 |
+
congr 1
|
| 121 |
+
funext x
|
| 122 |
+
simp only [gaussianQuadratic, Finset.sum_apply]
|
| 123 |
+
rw [h]
|
| 124 |
+
simp only [variance_const_mul, gaussian_variance_sq, ← Finset.sum_mul]
|
| 125 |
+
ring
|
| 126 |
+
|
| 127 |
+
end Quadratic
|
| 128 |
+
|
| 129 |
+
lemma sqrt_sub_sq_le_abs_sub {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) :
|
| 130 |
+
(sqrt x - sqrt y)^2 ≤ |x-y| := by
|
| 131 |
+
have hx2 := sq_sqrt hx
|
| 132 |
+
have hy2 := sq_sqrt hy
|
| 133 |
+
rcases le_total x y with h | h
|
| 134 |
+
· rw [abs_of_nonpos (sub_nonpos.mpr h)]
|
| 135 |
+
have hh := sqrt_le_sqrt h
|
| 136 |
+
nlinarith [mul_nonneg (sqrt_nonneg x) (sub_nonneg.mpr hh)]
|
| 137 |
+
· rw [abs_of_nonneg (sub_nonneg.mpr h)]
|
| 138 |
+
have hh := sqrt_le_sqrt h
|
| 139 |
+
nlinarith [mul_nonneg (sqrt_nonneg y) (sub_nonneg.mpr hh)]
|
| 140 |
+
|
| 141 |
+
section Fluctuation
|
| 142 |
+
variable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]
|
| 143 |
+
|
| 144 |
+
omit [IsProbabilityMeasure μ] in
|
| 145 |
+
lemma memLp_sqrt_of_nonneg {f : Ω → ℝ} (hf : Integrable f μ)
|
| 146 |
+
(hpos : ∀ x, 0 ≤ f x) : MemLp (fun x => sqrt (f x)) 2 μ := by
|
| 147 |
+
apply (memLp_two_iff_integrable_sq
|
| 148 |
+
(Real.continuous_sqrt.comp_aestronglyMeasurable hf.aestronglyMeasurable)).mpr
|
| 149 |
+
exact hf.congr (Filter.Eventually.of_forall (fun x => (sq_sqrt (hpos x)).symm))
|
| 150 |
+
|
| 151 |
+
lemma integral_abs_le_sqrt_sq {f : Ω → ℝ} (hf : MemLp f 2 μ) :
|
| 152 |
+
(∫ x, |f x| ∂μ) ≤ sqrt (∫ x, (f x)^2 ∂μ) := by
|
| 153 |
+
have h0 := ProbabilityTheory.variance_nonneg (fun x => ‖f x‖) μ
|
| 154 |
+
rw [variance_eq_sub hf.norm] at h0
|
| 155 |
+
have hsq : (∫ x, |f x| ∂μ)^2 ≤ ∫ x, (f x)^2 ∂μ := by
|
| 156 |
+
simpa only [Real.norm_eq_abs, Pi.pow_apply, sq_abs, sub_nonneg] using h0
|
| 157 |
+
have hi : 0 ≤ ∫ x, (f x)^2 ∂μ := integral_nonneg (fun x => sq_nonneg _)
|
| 158 |
+
have hh := sq_sqrt hi
|
| 159 |
+
have hp := sqrt_nonneg (∫ x, (f x)^2 ∂μ)
|
| 160 |
+
nlinarith [sq_nonneg ((∫ x, |f x| ∂μ) - sqrt (∫ x, (f x)^2 ∂μ))]
|
| 161 |
+
|
| 162 |
+
theorem integral_sqrt_fluctuation {f : Ω → ℝ} (hf : MemLp f 2 μ)
|
| 163 |
+
(hpos : ∀ x, 0 ≤ f x) :
|
| 164 |
+
(∫ x, |sqrt (f x) - sqrt (∫ y, f y ∂μ)| ∂μ) ≤ sqrt (sqrt (Var[f; μ])) := by
|
| 165 |
+
let m := ∫ y, f y ∂μ
|
| 166 |
+
have hm : 0 ≤ m := integral_nonneg hpos
|
| 167 |
+
have hg : MemLp (fun x => f x - m) 2 μ := hf.sub (memLp_const m)
|
| 168 |
+
have hroot : MemLp (fun x => sqrt (f x) - sqrt m) 2 μ := by
|
| 169 |
+
apply (memLp_two_iff_integrable_sq ((Real.continuous_sqrt.comp_aestronglyMeasurable hf.aestronglyMeasurable).sub aestronglyMeasurable_const)).mpr
|
| 170 |
+
apply hg.integrable (by norm_num) |>.norm |>.mono'
|
| 171 |
+
(((Real.continuous_sqrt.comp_aestronglyMeasurable hf.aestronglyMeasurable).sub aestronglyMeasurable_const).pow 2)
|
| 172 |
+
filter_upwards [] with x
|
| 173 |
+
change |(sqrt (f x) - sqrt m)^2| ≤ |f x - m|
|
| 174 |
+
rw [abs_of_nonneg (sq_nonneg (sqrt (f x) - sqrt m))]
|
| 175 |
+
exact sqrt_sub_sq_le_abs_sub (hpos x) hm
|
| 176 |
+
have hdiff : (∫ x, (sqrt (f x) - sqrt m)^2 ∂μ) ≤ ∫ x, |f x-m| ∂μ := by
|
| 177 |
+
apply integral_mono hroot.integrable_sq (hg.integrable (by norm_num)).norm
|
| 178 |
+
exact fun x => sqrt_sub_sq_le_abs_sub (hpos x) hm
|
| 179 |
+
have hc := integral_abs_le_sqrt_sq hg
|
| 180 |
+
rw [← variance_eq_integral hf.aemeasurable] at hc
|
| 181 |
+
exact (integral_abs_le_sqrt_sq hroot).trans (sqrt_le_sqrt (hdiff.trans hc))
|
| 182 |
+
|
| 183 |
+
end Fluctuation
|
| 184 |
+
end SKGap
|
| 185 |
+
|
| 186 |
+
end
|
| 187 |
+
end
|
| 188 |
+
end
|
| 189 |
+
end
|
| 190 |
+
end
|
| 191 |
+
end
|
| 192 |
+
end
|
| 193 |
+
end
|
| 194 |
+
end
|
| 195 |
+
end
|
| 196 |
+
end
|
| 197 |
+
end
|
| 198 |
+
end
|
| 199 |
+
end
|
| 200 |
+
end
|
| 201 |
+
|
| 202 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianQuadraticSupComparison.lean
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianCoordinates
|
| 3 |
+
import OAI.Probability.SKGap.Localization.QuadraticCoeff
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 10 |
+
open scoped NNReal ENNReal
|
| 11 |
+
open Filter
|
| 12 |
+
open scoped Topology
|
| 13 |
+
noncomputable section
|
| 14 |
+
open Matrix Real
|
| 15 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal
|
| 16 |
+
noncomputable section
|
| 17 |
+
open Matrix Real
|
| 18 |
+
open scoped BigOperators Matrix.Norms.Frobenius NNReal
|
| 19 |
+
noncomputable section
|
| 20 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 21 |
+
open MeasureTheory.Measure
|
| 22 |
+
open scoped ENNReal NNReal MeasureTheory Topology
|
| 23 |
+
open MeasureTheory
|
| 24 |
+
noncomputable section
|
| 25 |
+
noncomputable section
|
| 26 |
+
open MeasureTheory Set NormedSpace
|
| 27 |
+
open scoped Topology
|
| 28 |
+
noncomputable section
|
| 29 |
+
open Matrix Real
|
| 30 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 31 |
+
noncomputable section
|
| 32 |
+
open Set Real
|
| 33 |
+
open scoped Topology
|
| 34 |
+
noncomputable section
|
| 35 |
+
open Matrix Set Filter
|
| 36 |
+
open scoped Topology Matrix.Norms.Frobenius
|
| 37 |
+
noncomputable section
|
| 38 |
+
open Matrix NormedSpace ContinuousLinearMap
|
| 39 |
+
open scoped Matrix.Norms.Frobenius
|
| 40 |
+
noncomputable section
|
| 41 |
+
open Matrix
|
| 42 |
+
noncomputable section
|
| 43 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 44 |
+
open scoped ENNReal NNReal
|
| 45 |
+
noncomputable section
|
| 46 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set
|
| 47 |
+
open scoped NNReal ENNReal
|
| 48 |
+
noncomputable section
|
| 49 |
+
open scoped BigOperators
|
| 50 |
+
open MeasureTheory ProbabilityTheory
|
| 51 |
+
namespace SKGap
|
| 52 |
+
section QuadraticComparison
|
| 53 |
+
variable {I ι : Type*} [TopologicalSpace I] [CompactSpace I] [Nonempty I]
|
| 54 |
+
[Fintype ι] [Nonempty ι]
|
| 55 |
+
|
| 56 |
+
theorem gaussian_quadraticSup_comparison {m : I → ℝ}
|
| 57 |
+
{w : I → EuclideanSpace ℝ ι} (hm : Continuous m) (hw : Continuous w)
|
| 58 |
+
{r : ℝ} (hr : 0 ≤ r) (z : ℝ) :
|
| 59 |
+
(∫ g, gaussianSup m (fun i k => z * quadraticCoeff r (w i) k) g
|
| 60 |
+
∂gaussianCoordinates (MatrixCoordinates ι)) ≤
|
| 61 |
+
∫ g, gaussianSup m (fun i k => z * linearCoeff r (w i) k) g
|
| 62 |
+
∂gaussianCoordinates (MatrixCoordinates ι) := by
|
| 63 |
+
have hc {q : EuclideanSpace ℝ ι → MatrixCoordinates ι → ℝ} (hq : Continuous q) :
|
| 64 |
+
Continuous (fun i k => z * q (w i) k) := by
|
| 65 |
+
apply continuous_pi
|
| 66 |
+
intro k
|
| 67 |
+
exact continuous_const.mul ((continuous_apply k).comp (hq.comp hw))
|
| 68 |
+
apply gaussianSup_comparison hm (hc (continuous_linearCoeff r))
|
| 69 |
+
(hc (continuous_quadraticCoeff r))
|
| 70 |
+
· intro i j
|
| 71 |
+
simp_rw [← mul_sub]
|
| 72 |
+
simp_rw [show ∀ k, (z * (linearCoeff r (w i) k - linearCoeff r (w j) k)) *
|
| 73 |
+
(z * (quadraticCoeff r (w i) k - quadraticCoeff r (w j) k)) =
|
| 74 |
+
z^2 * ((linearCoeff r (w i) k - linearCoeff r (w j) k) *
|
| 75 |
+
(quadraticCoeff r (w i) k - quadraticCoeff r (w j) k)) by intros; ring]
|
| 76 |
+
rw [← Finset.mul_sum, quadratic_linear_orthogonal, mul_zero]
|
| 77 |
+
· intro i j
|
| 78 |
+
simp_rw [← mul_sub, mul_pow, ← Finset.mul_sum]
|
| 79 |
+
exact mul_le_mul_of_nonneg_left (quadratic_linear_increment_le r hr (w i) (w j))
|
| 80 |
+
(sq_nonneg z)
|
| 81 |
+
end QuadraticComparison
|
| 82 |
+
end SKGap
|
| 83 |
+
|
| 84 |
+
namespace SKGap
|
| 85 |
+
section SupLipschitz
|
| 86 |
+
variable {I κ : Type*} [TopologicalSpace I] [CompactSpace I] [Nonempty I] [Fintype κ]
|
| 87 |
+
|
| 88 |
+
lemma gaussianAffine_le_gaussianSup {m : I → ℝ} {a : I → κ → ℝ}
|
| 89 |
+
(hm : Continuous m) (ha : Continuous a) (x : κ → ℝ) (i : I) :
|
| 90 |
+
gaussianAffine m a x i ≤ gaussianSup m a x := by
|
| 91 |
+
obtain ⟨j, hj, hmax⟩ := gaussianSup_attained hm ha x
|
| 92 |
+
rw [hj]
|
| 93 |
+
exact hmax i
|
| 94 |
+
|
| 95 |
+
lemma gaussianSup_sub_le {m : I → ℝ} {a : I → κ → ℝ}
|
| 96 |
+
(hm : Continuous m) (ha : Continuous a) {L : ℝ}
|
| 97 |
+
(hL : ∀ i, ‖WithLp.toLp 2 (a i)‖ ≤ L) (x y : EuclideanSpace ℝ κ) :
|
| 98 |
+
gaussianSup m a x.ofLp - gaussianSup m a y.ofLp ≤ L * ‖x-y‖ := by
|
| 99 |
+
obtain ⟨i, hi, _⟩ := gaussianSup_attained hm ha x.ofLp
|
| 100 |
+
calc
|
| 101 |
+
_ ≤ gaussianAffine m a x.ofLp i - gaussianAffine m a y.ofLp i := by
|
| 102 |
+
rw [hi]
|
| 103 |
+
exact sub_le_sub_left (gaussianAffine_le_gaussianSup hm ha y.ofLp i) _
|
| 104 |
+
_ = inner ℝ (WithLp.toLp 2 (a i)) (x-y) := by
|
| 105 |
+
simp only [gaussianAffine, PiLp.inner_apply, WithLp.ofLp_sub,
|
| 106 |
+
Pi.sub_apply, RCLike.inner_apply, conj_trivial]
|
| 107 |
+
rw [add_sub_add_left_eq_sub, ← Finset.sum_sub_distrib]
|
| 108 |
+
apply Finset.sum_congr rfl
|
| 109 |
+
intro k _
|
| 110 |
+
ring
|
| 111 |
+
_ ≤ ‖WithLp.toLp 2 (a i)‖ * ‖x-y‖ := real_inner_le_norm _ _
|
| 112 |
+
_ ≤ L * ‖x-y‖ := mul_le_mul_of_nonneg_right (hL i) (norm_nonneg _)
|
| 113 |
+
|
| 114 |
+
theorem gaussianSup_lipschitz {m : I → ℝ} {a : I → κ → ℝ}
|
| 115 |
+
(hm : Continuous m) (ha : Continuous a) {L : ℝ≥0}
|
| 116 |
+
(hL : ∀ i, ‖WithLp.toLp 2 (a i)‖ ≤ (L : ℝ)) :
|
| 117 |
+
LipschitzWith L (fun x : EuclideanSpace ℝ κ => gaussianSup m a x.ofLp) := by
|
| 118 |
+
apply LipschitzWith.of_dist_le_mul
|
| 119 |
+
intro x y
|
| 120 |
+
rw [Real.dist_eq, dist_eq_norm]
|
| 121 |
+
apply abs_le.mpr
|
| 122 |
+
constructor
|
| 123 |
+
· have h := gaussianSup_sub_le hm ha hL y x
|
| 124 |
+
rw [norm_sub_rev] at h
|
| 125 |
+
linarith
|
| 126 |
+
· exact gaussianSup_sub_le hm ha hL x y
|
| 127 |
+
|
| 128 |
+
end SupLipschitz
|
| 129 |
+
end SKGap
|
| 130 |
+
|
| 131 |
+
end
|
| 132 |
+
end
|
| 133 |
+
end
|
| 134 |
+
end
|
| 135 |
+
end
|
| 136 |
+
end
|
| 137 |
+
end
|
| 138 |
+
end
|
| 139 |
+
end
|
| 140 |
+
end
|
| 141 |
+
end
|
| 142 |
+
end
|
| 143 |
+
end
|
| 144 |
+
end
|
| 145 |
+
end
|
| 146 |
+
|
| 147 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianRankCorrection.lean
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.BilinearCoefficient
|
| 3 |
+
import OAI.Probability.SKGap.Localization.QueryResidual
|
| 4 |
+
import OAI.Probability.SKGap.Gaussian.SubgaussianAbsTail
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
open scoped BigOperators NNReal
|
| 15 |
+
open MeasureTheory ProbabilityTheory
|
| 16 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 17 |
+
open scoped BigOperators NNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 21 |
+
open scoped BigOperators NNReal ENNReal
|
| 22 |
+
open MeasureTheory ProbabilityTheory
|
| 23 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 24 |
+
open scoped BigOperators
|
| 25 |
+
open MeasureTheory ProbabilityTheory
|
| 26 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 27 |
+
open scoped BigOperators
|
| 28 |
+
open scoped BigOperators NNReal ENNReal
|
| 29 |
+
open MeasureTheory Metric Set
|
| 30 |
+
open scoped BigOperators NNReal ENNReal
|
| 31 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 32 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 33 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 34 |
+
open scoped BigOperators Matrix.Norms.L2Operator
|
| 35 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 36 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 37 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 38 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 39 |
+
open scoped BigOperators ENNReal NNReal
|
| 40 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 41 |
+
open scoped BigOperators NNReal ENNReal Matrix
|
| 42 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 43 |
+
open scoped BigOperators ENNReal NNReal
|
| 44 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 45 |
+
open scoped BigOperators NNReal ENNReal
|
| 46 |
+
open scoped BigOperators
|
| 47 |
+
open MeasureTheory ProbabilityTheory
|
| 48 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
|
| 49 |
+
namespace SKGapCutoff.Regression
|
| 50 |
+
|
| 51 |
+
noncomputable def gaussianRankCorrection {ι κ η : Type*} [Fintype κ] [Fintype η]
|
| 52 |
+
(V : ι → κ → ℝ) (W : κ → η → ℝ) (g : η → ℝ) (i : ι) : ℝ :=
|
| 53 |
+
∑ a, V i a * ∑ j, W a j * g j
|
| 54 |
+
|
| 55 |
+
lemma rankCorrection_sq_bound {ι κ : Type*} [Fintype ι] [Fintype κ]
|
| 56 |
+
(V : ι → κ → ℝ) (c : κ → ℝ) (M : ℝ)
|
| 57 |
+
(hV : ∀ a, ∑ i, V i a ^ 2 ≤ M) :
|
| 58 |
+
∑ i, (∑ a, V i a * c a)^2 ≤ M * Fintype.card κ * ∑ a, c a^2 := by
|
| 59 |
+
calc
|
| 60 |
+
_ ≤ ∑ i, (∑ a, V i a^2) * ∑ a, c a^2 :=
|
| 61 |
+
Finset.sum_le_sum (fun i _ => Finset.sum_mul_sq_le_sq_mul_sq _ _ _)
|
| 62 |
+
_ = (∑ a, ∑ i, V i a^2) * ∑ a, c a^2 := by
|
| 63 |
+
rw [← Finset.sum_mul, Finset.sum_comm]
|
| 64 |
+
_ ≤ (∑ _a : κ, M) * ∑ a, c a^2 := by
|
| 65 |
+
exact mul_le_mul_of_nonneg_right (Finset.sum_le_sum (fun a _ => hV a))
|
| 66 |
+
(Finset.sum_nonneg (fun a _ => sq_nonneg _))
|
| 67 |
+
_ = _ := by simp [mul_comm]
|
| 68 |
+
|
| 69 |
+
lemma gaussian_linear_unit_tail {η : Type*} [Fintype η] (W : η → ℝ)
|
| 70 |
+
(hW : ∑ j, W j^2 ≤ 1) (b : ℝ) (hb : 0 < b) :
|
| 71 |
+
standardArrayLaw η {g | b ≤ |∑ j, W j * g j|} ≤
|
| 72 |
+
2 * ENNReal.ofReal (Real.exp (-b^2/2)) := by
|
| 73 |
+
have h := RandomMatrix.gaussian_linear_abs_tail 1 W b b hb
|
| 74 |
+
refine h.trans (mul_le_mul' (le_refl 2) (ENNReal.ofReal_le_ofReal
|
| 75 |
+
(Real.exp_le_exp.mpr ?_)))
|
| 76 |
+
simp only [NNReal.coe_one, one_mul]
|
| 77 |
+
nlinarith [mul_le_mul_of_nonneg_right hW (sq_nonneg b)]
|
| 78 |
+
|
| 79 |
+
theorem gaussian_rank_correction_tail {ι κ η : Type*}
|
| 80 |
+
[Fintype ι] [Fintype κ] [Fintype η] [Nonempty κ]
|
| 81 |
+
(V : ι → κ → ℝ) (W : κ → η → ℝ)
|
| 82 |
+
(hV : ∀ a, ∑ i, V i a^2 ≤ 2) (hW : ∀ a, ∑ j, W a j^2 ≤ 1)
|
| 83 |
+
(N ε : ℝ) (hN : 0 < N) (hε : 0 < ε) :
|
| 84 |
+
standardArrayLaw η {g | N*ε < ∑ i, gaussianRankCorrection V W g i^2} ≤
|
| 85 |
+
(2 * Fintype.card κ : ℝ≥0∞) *
|
| 86 |
+
ENNReal.ofReal (Real.exp (-(N*ε)/(4*(Fintype.card κ : ℝ)^2))) := by
|
| 87 |
+
classical
|
| 88 |
+
let m : ℝ := Fintype.card κ
|
| 89 |
+
have hm : 0 < m := by
|
| 90 |
+
dsimp [m]
|
| 91 |
+
exact_mod_cast (Fintype.card_pos : 0 < Fintype.card κ)
|
| 92 |
+
let b : ℝ := Real.sqrt (N*ε/(2*m^2))
|
| 93 |
+
have hb : 0 < b := Real.sqrt_pos.mpr (by positivity)
|
| 94 |
+
have hb2 : b^2 = N*ε/(2*m^2) := Real.sq_sqrt (by positivity)
|
| 95 |
+
have hsub : {g | N*ε < ∑ i, gaussianRankCorrection V W g i^2} ⊆
|
| 96 |
+
⋃ a : κ, {g | b ≤ |∑ j, W a j*g j|} := by
|
| 97 |
+
intro g hg
|
| 98 |
+
by_contra hnot
|
| 99 |
+
have hcoeff (a : κ) : (∑ j, W a j*g j)^2 ≤ b^2 := by
|
| 100 |
+
have ha : |∑ j, W a j*g j| < b := lt_of_not_ge
|
| 101 |
+
(fun ha => hnot (Set.mem_iUnion.mpr ⟨a, ha⟩))
|
| 102 |
+
nlinarith [sq_abs (∑ j, W a j*g j), abs_nonneg (∑ j, W a j*g j)]
|
| 103 |
+
have he := rankCorrection_sq_bound V (fun a => ∑ j, W a j*g j) 2 hV
|
| 104 |
+
have hs : (∑ a, (∑ j, W a j*g j)^2) ≤ m*b^2 := by
|
| 105 |
+
calc
|
| 106 |
+
_ ≤ ∑ _a : κ, b^2 := Finset.sum_le_sum (fun a _ => hcoeff a)
|
| 107 |
+
_ = _ := by simp [m]
|
| 108 |
+
have he' : ∑ i, gaussianRankCorrection V W g i^2 ≤ N*ε := by
|
| 109 |
+
calc
|
| 110 |
+
_ ≤ 2*m * ∑ a, (∑ j, W a j*g j)^2 := he
|
| 111 |
+
_ ≤ 2*m*(m*b^2) := mul_le_mul_of_nonneg_left hs (by positivity)
|
| 112 |
+
_ = _ := by rw [hb2]; field_simp
|
| 113 |
+
exact not_lt_of_ge he' hg
|
| 114 |
+
calc
|
| 115 |
+
_ ≤ standardArrayLaw η (⋃ a : κ, {g | b ≤ |∑ j, W a j*g j|}) := measure_mono hsub
|
| 116 |
+
_ ≤ ∑ a : κ, standardArrayLaw η {g | b ≤ |∑ j, W a j*g j|} := measure_iUnion_fintype_le _ _
|
| 117 |
+
_ ≤ ∑ _a : κ, 2 * ENNReal.ofReal (Real.exp (-b^2/2)) :=
|
| 118 |
+
Finset.sum_le_sum (fun a _ => gaussian_linear_unit_tail (W a) (hW a) b hb)
|
| 119 |
+
_ = _ := by
|
| 120 |
+
have hbexp : -b^2/2 = -(N*ε)/(4*(Fintype.card κ : ℝ)^2) := by
|
| 121 |
+
rw [hb2]; dsimp [m]; ring
|
| 122 |
+
rw [hbexp]
|
| 123 |
+
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
|
| 124 |
+
ring
|
| 125 |
+
|
| 126 |
+
noncomputable def innovationErrorVectors {n r : ℕ}
|
| 127 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ) (i : Fin n) : Fin r ⊕ Bool → ℝ :=
|
| 128 |
+
Sum.elim (fun a => -U i a) (fun b => if b then Real.sqrt 2*q i else -q i)
|
| 129 |
+
|
| 130 |
+
def innovationErrorCoefficients {n r : ℕ}
|
| 131 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ) :
|
| 132 |
+
(Fin r ⊕ Bool) → (Fin n ⊕ Unit) → ℝ :=
|
| 133 |
+
Sum.elim (fun a => Sum.elim (fun j => U j a) (fun _ => 0))
|
| 134 |
+
(fun b => if b then Sum.elim (fun _ => 0) (fun _ => 1)
|
| 135 |
+
else Sum.elim q (fun _ => 0))
|
| 136 |
+
|
| 137 |
+
lemma innovationErrorVectors_sq_le {n r : ℕ}
|
| 138 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ)
|
| 139 |
+
(hU : ∀ a, ∑ i, U i a^2 ≤ 1) (hq : ∑ i, q i^2 ≤ 1)
|
| 140 |
+
(a : Fin r ⊕ Bool) : ∑ i, innovationErrorVectors U q i a^2 ≤ 2 := by
|
| 141 |
+
rcases a with a | (_ | _)
|
| 142 |
+
· simpa [innovationErrorVectors] using (hU a).trans (by norm_num : (1:ℝ) ≤ 2)
|
| 143 |
+
· simpa [innovationErrorVectors] using hq.trans (by norm_num : (1:ℝ) ≤ 2)
|
| 144 |
+
· simp only [innovationErrorVectors, Sum.elim_inr, ↓reduceIte,
|
| 145 |
+
mul_pow, Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 2), ← Finset.mul_sum]
|
| 146 |
+
linarith
|
| 147 |
+
|
| 148 |
+
lemma innovationErrorCoefficients_sq_le {n r : ℕ}
|
| 149 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ)
|
| 150 |
+
(hU : ∀ a, ∑ i, U i a^2 ≤ 1) (hq : ∑ i, q i^2 ≤ 1)
|
| 151 |
+
(a : Fin r ⊕ Bool) : ∑ j, innovationErrorCoefficients U q a j^2 ≤ 1 := by
|
| 152 |
+
rcases a with a | (_ | _)
|
| 153 |
+
· simpa [innovationErrorCoefficients, Fintype.sum_sum_type] using hU a
|
| 154 |
+
· simpa [innovationErrorCoefficients, Fintype.sum_sum_type] using hq
|
| 155 |
+
· simp [innovationErrorCoefficients, Fintype.sum_sum_type]
|
| 156 |
+
|
| 157 |
+
lemma queryInnovation_error_eq {n r : ℕ} (hn : 0 < n)
|
| 158 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ)
|
| 159 |
+
(g : (Fin n ⊕ Unit) → ℝ) (i : Fin n) :
|
| 160 |
+
Real.sqrt n * queryInnovation (residualProjection U) q g i - g (Sum.inl i) =
|
| 161 |
+
gaussianRankCorrection (innovationErrorVectors U q) (innovationErrorCoefficients U q) g i := by
|
| 162 |
+
have hsn : Real.sqrt (n:ℝ) ≠ 0 := (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hn)).ne'
|
| 163 |
+
have hh : ∑ k, (residualProjection U i k-q i*q k)*g (Sum.inl k) =
|
| 164 |
+
g (Sum.inl i) - ∑ a, U i a * (∑ k, U k a*g (Sum.inl k)) -
|
| 165 |
+
q i*(∑ k, q k*g (Sum.inl k)) := by
|
| 166 |
+
simp only [residualProjection, Matrix.sub_apply, Matrix.mul_apply, Matrix.transpose_apply,
|
| 167 |
+
sub_mul, Finset.sum_sub_distrib, Finset.sum_mul, mul_assoc]
|
| 168 |
+
rw [Finset.sum_comm]
|
| 169 |
+
simp [Matrix.one_apply, Finset.mul_sum]
|
| 170 |
+
simp only [queryInnovation, queryComplement_apply]
|
| 171 |
+
rw [mul_div_cancel₀ _ hsn, hh]
|
| 172 |
+
simp only [gaussianRankCorrection, innovationErrorVectors, innovationErrorCoefficients,
|
| 173 |
+
Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, Fintype.sum_bool, Bool.false_eq_true,
|
| 174 |
+
↓reduceIte, zero_mul, one_mul, Finset.sum_const_zero, add_zero,
|
| 175 |
+
Fintype.sum_unique, neg_mul, Finset.sum_neg_distrib]
|
| 176 |
+
ring
|
| 177 |
+
|
| 178 |
+
theorem queryInnovation_iid_error_tail {n r : ℕ} (hn : 0 < n)
|
| 179 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ)
|
| 180 |
+
(hU : ∀ a, ∑ i, U i a^2 ≤ 1) (hq : ∑ i, q i^2 ≤ 1)
|
| 181 |
+
(ε : ℝ) (hε : 0 < ε) :
|
| 182 |
+
standardArrayLaw (Fin n ⊕ Unit) {g | (n:ℝ)*ε < ∑ i,
|
| 183 |
+
(Real.sqrt n * queryInnovation (residualProjection U) q g i - g (Sum.inl i))^2} ≤
|
| 184 |
+
(2*(r+2) : ℝ≥0∞) * ENNReal.ofReal (Real.exp (-((n:ℝ)*ε)/(4*((r:ℝ)+2)^2))) := by
|
| 185 |
+
simp_rw [queryInnovation_error_eq hn U q]
|
| 186 |
+
have h := gaussian_rank_correction_tail (innovationErrorVectors U q)
|
| 187 |
+
(innovationErrorCoefficients U q) (innovationErrorVectors_sq_le U q hU hq)
|
| 188 |
+
(innovationErrorCoefficients_sq_le U q hU hq) n ε (Nat.cast_pos.mpr hn) hε
|
| 189 |
+
simpa only [Fintype.card_sum, Fintype.card_fin, Fintype.card_bool, Nat.cast_add,
|
| 190 |
+
Nat.cast_ofNat] using h
|
| 191 |
+
|
| 192 |
+
lemma probability_prod_section_bound {H A : Type*} [MeasurableSpace H] [MeasurableSpace A]
|
| 193 |
+
(ρ : Measure H) [IsProbabilityMeasure ρ] (μ : Measure A) [SFinite μ]
|
| 194 |
+
(s : Set (H × A)) (hs : MeasurableSet s) (b : ℝ≥0∞)
|
| 195 |
+
(hb : ∀ h, μ (Prod.mk h ⁻¹' s) ≤ b) : (ρ.prod μ) s ≤ b := by
|
| 196 |
+
rw [Measure.prod_apply hs]
|
| 197 |
+
calc
|
| 198 |
+
_ ≤ ∫⁻ _h, b ∂ρ := lintegral_mono hb
|
| 199 |
+
_ = _ := by simp
|
| 200 |
+
|
| 201 |
+
theorem adaptive_queryInnovation_iid_error_tail {n r : ℕ} (hn : 0 < n)
|
| 202 |
+
{H : Type*} [MeasurableSpace H] (ρ : Measure H) [IsProbabilityMeasure ρ]
|
| 203 |
+
(U : H → Fin n → Fin r → ℝ) (q : H → Fin n → ℝ)
|
| 204 |
+
(hUm : Measurable U) (hqm : Measurable q)
|
| 205 |
+
(hU : ∀ h a, ∑ i, U h i a^2 ≤ 1) (hq : ∀ h, ∑ i, q h i^2 ≤ 1)
|
| 206 |
+
(ε : ℝ) (hε : 0 < ε) :
|
| 207 |
+
(ρ.prod (standardArrayLaw (Fin n ⊕ Unit))) {z | (n:ℝ)*ε < ∑ i,
|
| 208 |
+
(Real.sqrt n * queryInnovation (residualProjection (U z.1)) (q z.1) z.2 i - z.2 (Sum.inl i))^2} ≤
|
| 209 |
+
(2*(r+2) : ℝ≥0∞) * ENNReal.ofReal (Real.exp (-((n:ℝ)*ε)/(4*((r:ℝ)+2)^2))) := by
|
| 210 |
+
have hP : Measurable (fun h => fun i j => residualProjection (U h) i j) := by
|
| 211 |
+
apply Measurable.of_eval
|
| 212 |
+
intro i
|
| 213 |
+
apply Measurable.of_eval
|
| 214 |
+
intro j
|
| 215 |
+
change Measurable (fun h => (if i=j then (1:ℝ) else 0) - ∑ a, U h i a*U h j a)
|
| 216 |
+
apply measurable_const.sub
|
| 217 |
+
apply Finset.measurable_sum
|
| 218 |
+
intro a _
|
| 219 |
+
exact ((measurable_pi_apply a).comp ((measurable_pi_apply i).comp hUm)).mul
|
| 220 |
+
((measurable_pi_apply a).comp ((measurable_pi_apply j).comp hUm))
|
| 221 |
+
have hI := measurable_queryInnovation_comp
|
| 222 |
+
(fun z : H × ((Fin n ⊕ Unit) → ℝ) => residualProjection (U z.1))
|
| 223 |
+
(fun z => q z.1) (fun z => z.2) (hP.comp measurable_fst)
|
| 224 |
+
(hqm.comp measurable_fst) measurable_snd
|
| 225 |
+
apply probability_prod_section_bound
|
| 226 |
+
· apply measurableSet_lt measurable_const
|
| 227 |
+
apply Finset.measurable_sum
|
| 228 |
+
intro i _
|
| 229 |
+
exact (((measurable_pi_apply i).comp hI).const_mul _ |>.sub
|
| 230 |
+
((measurable_pi_apply (Sum.inl i)).comp measurable_snd)).pow_const 2
|
| 231 |
+
· intro h
|
| 232 |
+
exact queryInnovation_iid_error_tail hn (U h) (q h) (hU h) (hq h) ε hε
|
| 233 |
+
|
| 234 |
+
lemma independent_bounded_average_tail {Ω : Type*} [MeasurableSpace Ω]
|
| 235 |
+
{μ : Measure Ω} [IsProbabilityMeasure μ] {n : ℕ} (hn : 0 < n)
|
| 236 |
+
(X : Fin n → Ω → ℝ) (hXi : iIndepFun X μ)
|
| 237 |
+
(hX : ∀ i, HasLaw (X i) (gaussianReal 0 1) μ) (f : Fin n → ℝ → ℝ)
|
| 238 |
+
(hf : ∀ i, Measurable (f i)) (B : ℝ) (hB : 0 ≤ B)
|
| 239 |
+
(hbound : ∀ i z, |f i z| ≤ B) (ε : ℝ) (hε : 0 ≤ ε) :
|
| 240 |
+
μ {g | ε ≤ |((∑ i, f i (X i g)) - ∑ i, ∫ z, f i z ∂gaussianReal 0 1)/(n:ℝ)|} ≤
|
| 241 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(2*B^2))) := by
|
| 242 |
+
let m (i : Fin n) := ∫ z, f i z ∂gaussianReal 0 1
|
| 243 |
+
have hi : iIndepFun (fun i (g : Ω) => f i (X i g)-m i) μ :=
|
| 244 |
+
hXi.comp (fun i z => f i z-m i) (fun i => (hf i).sub_const (m i))
|
| 245 |
+
have hm (i : Fin n) : (∫ g : Ω, f i (X i g) ∂μ) = m i :=
|
| 246 |
+
(hX i).integral_comp (hf i).aestronglyMeasurable
|
| 247 |
+
have hsub (i : Fin n) : HasSubgaussianMGF (fun g : Ω => f i (X i g)-m i)
|
| 248 |
+
((‖B-(-B)‖₊/2)^2) μ := by
|
| 249 |
+
have hb : ∀ᵐ g : Ω ∂μ, f i (X i g) ∈ Set.Icc (-B) B :=
|
| 250 |
+
Filter.Eventually.of_forall (fun g => abs_le.mp (hbound i (X i g)))
|
| 251 |
+
simpa only [hm] using hasSubgaussianMGF_of_mem_Icc
|
| 252 |
+
(show AEMeasurable (fun g : Ω => f i (X i g)) μ from
|
| 253 |
+
(hf i).comp_aemeasurable (hX i).aemeasurable) hb
|
| 254 |
+
have hh := subgaussian_abs_tail
|
| 255 |
+
(HasSubgaussianMGF.sum_of_iIndepFun hi (s := Finset.univ) (fun i _ => hsub i))
|
| 256 |
+
(ε*n) (by positivity)
|
| 257 |
+
have he (g : Ω) :
|
| 258 |
+
(ε*(n:ℝ) ≤ |∑ i, (f i (X i g)-m i)|) ↔
|
| 259 |
+
ε ≤ |((∑ i, f i (X i g)) - ∑ i, m i)/(n:ℝ)| := by
|
| 260 |
+
rw [Finset.sum_sub_distrib, abs_div, abs_of_pos (show (0:ℝ) < n from Nat.cast_pos.mpr hn)]
|
| 261 |
+
exact (le_div_iff₀ (Nat.cast_pos.mpr hn)).symm
|
| 262 |
+
simp only [he] at hh
|
| 263 |
+
convert hh using 1
|
| 264 |
+
congr 3
|
| 265 |
+
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul,
|
| 266 |
+
NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_pow, NNReal.coe_div, NNReal.coe_ofNat,
|
| 267 |
+
coe_nnnorm, Real.norm_eq_abs]
|
| 268 |
+
rw [abs_of_nonneg (by linarith : 0 ≤ B-(-B))]
|
| 269 |
+
have hn0 : (n:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hn)
|
| 270 |
+
by_cases hB0 : B=0
|
| 271 |
+
· simp [hB0]
|
| 272 |
+
· field_simp
|
| 273 |
+
ring
|
| 274 |
+
|
| 275 |
+
lemma average_Lipschitz_error_sq {n : ℕ} (hn : 0 < n)
|
| 276 |
+
(f : Fin n → ℝ → ℝ) {K : ℝ≥0} (hf : ∀ i, LipschitzWith K (f i))
|
| 277 |
+
(v w : Fin n → ℝ) :
|
| 278 |
+
|((∑ i, f i (v i))-(∑ i, f i (w i)))/(n:ℝ)|^2 ≤
|
| 279 |
+
(K:ℝ)^2 * (∑ i, (v i-w i)^2)/(n:ℝ) := by
|
| 280 |
+
have hnR : (0:ℝ) < n := Nat.cast_pos.mpr hn
|
| 281 |
+
rw [sq_abs, div_pow, ← Finset.sum_sub_distrib]
|
| 282 |
+
have hcs := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ
|
| 283 |
+
(fun i : Fin n => (1:ℝ)) (fun i => f i (v i)-f i (w i))
|
| 284 |
+
simp only [one_mul, one_pow, Finset.sum_const, Finset.card_univ,
|
| 285 |
+
Fintype.card_fin, nsmul_eq_mul, mul_one] at hcs
|
| 286 |
+
have hsite (i : Fin n) : (f i (v i)-f i (w i))^2 ≤ (K:ℝ)^2*(v i-w i)^2 := by
|
| 287 |
+
have h := (hf i).dist_le_mul (v i) (w i)
|
| 288 |
+
rw [Real.dist_eq, Real.dist_eq] at h
|
| 289 |
+
have hs := mul_self_le_mul_self (abs_nonneg _) h
|
| 290 |
+
simpa [← pow_two, mul_pow] using hs
|
| 291 |
+
apply (div_le_iff₀ (sq_pos_of_pos hnR)).mpr
|
| 292 |
+
calc
|
| 293 |
+
_ ≤ (n:ℝ) * ∑ i, (f i (v i)-f i (w i))^2 := hcs
|
| 294 |
+
_ ≤ (n:ℝ) * ∑ i, (K:ℝ)^2*(v i-w i)^2 :=
|
| 295 |
+
mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hsite i)) hnR.le
|
| 296 |
+
_ = _ := by rw [← Finset.mul_sum]; field_simp
|
| 297 |
+
|
| 298 |
+
theorem queryInnovation_empirical_tail {n r : ℕ} (hn : 0 < n)
|
| 299 |
+
(U : Matrix (Fin n) (Fin r) ℝ) (q : Fin n → ℝ)
|
| 300 |
+
(hU : ∀ a, ∑ i, U i a^2 ≤ 1) (hq : ∑ i, q i^2 ≤ 1)
|
| 301 |
+
(f : Fin n → ℝ → ℝ) {K : ℝ≥0} (hf : ∀ i, LipschitzWith K (f i))
|
| 302 |
+
(B : ℝ) (hB : 0 ≤ B) (hbound : ∀ i z, |f i z| ≤ B)
|
| 303 |
+
(ε : ℝ) (hε : 0 < ε) :
|
| 304 |
+
standardArrayLaw (Fin n ⊕ Unit) {g | ε ≤
|
| 305 |
+
|((∑ i, f i (Real.sqrt n * queryInnovation (residualProjection U) q g i)) -
|
| 306 |
+
∑ i, ∫ z, f i z ∂gaussianReal 0 1)/(n:ℝ)|} ≤
|
| 307 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(8*B^2))) +
|
| 308 |
+
(2*(r+2) : ℝ≥0∞) * ENNReal.ofReal
|
| 309 |
+
(Real.exp (-((n:ℝ)*ε^2)/(64*((K:ℝ)+1)^2*((r:ℝ)+2)^2))) := by
|
| 310 |
+
let δ := ε^2/(16*((K:ℝ)+1)^2)
|
| 311 |
+
have hδ : 0 < δ := by dsimp [δ]; positivity
|
| 312 |
+
have hnR : (0:ℝ) < n := Nat.cast_pos.mpr hn
|
| 313 |
+
let M := ∑ i, ∫ z, f i z ∂gaussianReal 0 1
|
| 314 |
+
let A (g : (Fin n ⊕ Unit) → ℝ) := ∑ i, f i (g (Sum.inl i))
|
| 315 |
+
let C (g : (Fin n ⊕ Unit) → ℝ) :=
|
| 316 |
+
∑ i, f i (Real.sqrt n * queryInnovation (residualProjection U) q g i)
|
| 317 |
+
let E (g : (Fin n ⊕ Unit) → ℝ) :=
|
| 318 |
+
∑ i, (Real.sqrt n * queryInnovation (residualProjection U) q g i-g (Sum.inl i))^2
|
| 319 |
+
have hi : iIndepFun (fun i : Fin n => fun g : (Fin n ⊕ Unit) → ℝ => g (Sum.inl i))
|
| 320 |
+
(standardArrayLaw (Fin n ⊕ Unit)) := coordinates_independent.precomp Sum.inl_injective
|
| 321 |
+
have h1 := independent_bounded_average_tail (μ := standardArrayLaw (Fin n ⊕ Unit)) hn
|
| 322 |
+
(fun i g => g (Sum.inl i)) hi (fun i => coordinate_hasLaw (Sum.inl i)) f
|
| 323 |
+
(fun i => (hf i).continuous.measurable) B hB hbound (ε/2) (by positivity)
|
| 324 |
+
have h2 := queryInnovation_iid_error_tail hn U q hU hq δ hδ
|
| 325 |
+
have hsub : {g | ε ≤ |(C g-M)/(n:ℝ)|} ⊆
|
| 326 |
+
{g | ε/2 ≤ |(A g-M)/(n:ℝ)|} ∪ {g | (n:ℝ)*δ < E g} := by
|
| 327 |
+
intro g hg
|
| 328 |
+
by_cases ha : ε/2 ≤ |(A g-M)/(n:ℝ)|
|
| 329 |
+
· exact Or.inl ha
|
| 330 |
+
apply Or.inr
|
| 331 |
+
by_contra he
|
| 332 |
+
have he' : E g ≤ (n:ℝ)*δ := le_of_not_gt he
|
| 333 |
+
have hcs := average_Lipschitz_error_sq hn f hf
|
| 334 |
+
(fun i => Real.sqrt n * queryInnovation (residualProjection U) q g i)
|
| 335 |
+
(fun i => g (Sum.inl i))
|
| 336 |
+
change |(C g-A g)/(n:ℝ)|^2 ≤ (K:ℝ)^2*E g/(n:ℝ) at hcs
|
| 337 |
+
have hk : (K:ℝ)^2*δ ≤ ε^2/16 := by
|
| 338 |
+
dsimp [δ]
|
| 339 |
+
have hkp : 0 < ((K:ℝ)+1)^2 := by positivity
|
| 340 |
+
apply (le_div_iff₀ (by norm_num : (0:ℝ)<16)).mpr
|
| 341 |
+
field_simp
|
| 342 |
+
have hkk : (K:ℝ)^2 ≤ ((K:ℝ)+1)^2 := by nlinarith [K.coe_nonneg]
|
| 343 |
+
exact hkk
|
| 344 |
+
have hsq : |(C g-A g)/(n:ℝ)|^2 ≤ ε^2/16 := hcs.trans
|
| 345 |
+
((calc
|
| 346 |
+
(K:ℝ)^2*E g/(n:ℝ) ≤ (K:ℝ)^2*((n:ℝ)*δ)/(n:ℝ) := by gcongr
|
| 347 |
+
_ = (K:ℝ)^2*δ := by field_simp).trans hk)
|
| 348 |
+
have hd : |(C g-A g)/(n:ℝ)| ≤ ε/2 := by
|
| 349 |
+
nlinarith [abs_nonneg ((C g-A g)/(n:ℝ))]
|
| 350 |
+
have ht := abs_add_le ((C g-A g)/(n:ℝ)) ((A g-M)/(n:ℝ))
|
| 351 |
+
rw [← add_div, sub_add_sub_cancel] at ht
|
| 352 |
+
have ha' : |(A g-M)/(n:ℝ)| < ε/2 := lt_of_not_ge ha
|
| 353 |
+
change ε ≤ |(C g-M)/(n:ℝ)| at hg
|
| 354 |
+
linarith
|
| 355 |
+
apply (measure_mono hsub).trans ((measure_union_le _ _).trans _)
|
| 356 |
+
have h1' : standardArrayLaw (Fin n ⊕ Unit) {g | ε/2 ≤ |(A g-M)/(n:ℝ)|} ≤
|
| 357 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(8*B^2))) := by
|
| 358 |
+
convert h1 using 1
|
| 359 |
+
congr 3
|
| 360 |
+
ring
|
| 361 |
+
have h2' : standardArrayLaw (Fin n ⊕ Unit) {g | (n:ℝ)*δ < E g} ≤
|
| 362 |
+
(2*(r+2) : ℝ≥0∞) * ENNReal.ofReal
|
| 363 |
+
(Real.exp (-((n:ℝ)*ε^2)/(64*((K:ℝ)+1)^2*((r:ℝ)+2)^2))) := by
|
| 364 |
+
convert h2 using 1
|
| 365 |
+
congr 3
|
| 366 |
+
dsimp [δ]
|
| 367 |
+
field_simp
|
| 368 |
+
ring
|
| 369 |
+
exact add_le_add h1' h2'
|
| 370 |
+
|
| 371 |
+
lemma measurable_residualProjection_comp {n r : ℕ} {H : Type*} [MeasurableSpace H]
|
| 372 |
+
(U : H → Fin n → Fin r → ℝ) (hU : Measurable U) :
|
| 373 |
+
Measurable (fun h => fun i j => residualProjection (U h) i j) := by
|
| 374 |
+
apply Measurable.of_eval
|
| 375 |
+
intro i
|
| 376 |
+
apply Measurable.of_eval
|
| 377 |
+
intro j
|
| 378 |
+
change Measurable (fun h => (if i=j then (1:ℝ) else 0) - ∑ a, U h i a*U h j a)
|
| 379 |
+
apply measurable_const.sub
|
| 380 |
+
apply Finset.measurable_sum
|
| 381 |
+
intro a _
|
| 382 |
+
exact ((measurable_pi_apply a).comp ((measurable_pi_apply i).comp hU)).mul
|
| 383 |
+
((measurable_pi_apply a).comp ((measurable_pi_apply j).comp hU))
|
| 384 |
+
|
| 385 |
+
theorem adaptive_queryInnovation_empirical_tail {n r : ℕ} (hn : 0 < n)
|
| 386 |
+
{H : Type*} [MeasurableSpace H] (ρ : Measure H) [IsProbabilityMeasure ρ]
|
| 387 |
+
(U : H → Fin n → Fin r → ℝ) (q : H → Fin n → ℝ)
|
| 388 |
+
(hUm : Measurable U) (hqm : Measurable q)
|
| 389 |
+
(hU : ∀ h a, ∑ i, U h i a^2 ≤ 1) (hq : ∀ h, ∑ i, q h i^2 ≤ 1)
|
| 390 |
+
(f : H → Fin n → ℝ → ℝ) (hfm : ∀ i, Measurable (fun z : H × ℝ => f z.1 i z.2))
|
| 391 |
+
{K : ℝ≥0} (hf : ∀ h i, LipschitzWith K (f h i))
|
| 392 |
+
(B : ℝ) (hB : 0 ≤ B) (hbound : ∀ h i z, |f h i z| ≤ B) (ε : ℝ) (hε : 0 < ε) :
|
| 393 |
+
(ρ.prod (standardArrayLaw (Fin n ⊕ Unit))) {z | ε ≤
|
| 394 |
+
|((∑ i, f z.1 i (Real.sqrt n *
|
| 395 |
+
queryInnovation (residualProjection (U z.1)) (q z.1) z.2 i)) -
|
| 396 |
+
∑ i, ∫ x, f z.1 i x ∂gaussianReal 0 1)/(n:ℝ)|} ≤
|
| 397 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(8*B^2))) +
|
| 398 |
+
(2*(r+2) : ℝ≥0∞) * ENNReal.ofReal
|
| 399 |
+
(Real.exp (-((n:ℝ)*ε^2)/(64*((K:ℝ)+1)^2*((r:ℝ)+2)^2))) := by
|
| 400 |
+
have hI := measurable_queryInnovation_comp
|
| 401 |
+
(fun z : H × ((Fin n ⊕ Unit) → ℝ) => residualProjection (U z.1))
|
| 402 |
+
(fun z => q z.1) (fun z => z.2)
|
| 403 |
+
((measurable_residualProjection_comp U hUm).comp measurable_fst)
|
| 404 |
+
(hqm.comp measurable_fst) measurable_snd
|
| 405 |
+
have hM (i : Fin n) : Measurable (fun h => ∫ x, f h i x ∂gaussianReal 0 1) :=
|
| 406 |
+
(hfm i).stronglyMeasurable.integral_prod_right.measurable
|
| 407 |
+
apply probability_prod_section_bound
|
| 408 |
+
· apply measurableSet_le measurable_const
|
| 409 |
+
apply Measurable.abs
|
| 410 |
+
apply Measurable.div_const
|
| 411 |
+
apply Measurable.sub
|
| 412 |
+
· apply Finset.measurable_sum
|
| 413 |
+
intro i _
|
| 414 |
+
exact (hfm i).comp (measurable_fst.prodMk (((measurable_pi_apply i).comp hI).const_mul _))
|
| 415 |
+
· apply Finset.measurable_sum
|
| 416 |
+
intro i _
|
| 417 |
+
exact (hM i).comp measurable_fst
|
| 418 |
+
· intro h
|
| 419 |
+
exact queryInnovation_empirical_tail hn (U h) (q h) (hU h) (hq h)
|
| 420 |
+
(f h) (hf h) B hB (hbound h) ε hε
|
| 421 |
+
|
| 422 |
+
end SKGapCutoff.Regression
|
| 423 |
+
|
| 424 |
+
open scoped BigOperators
|
| 425 |
+
open Filter Topology
|
| 426 |
+
|
| 427 |
+
end
|
| 428 |
+
|
| 429 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianRecipeEvent.lean
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Matrix.PrimaryWordEventBinding
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
namespace SKGapCutoff.Recipe
|
| 11 |
+
open SKGap SKGap.Noncrossing SKGap.Noncrossing.Primary MeasureTheory ProbabilityTheory Real Set
|
| 12 |
+
|
| 13 |
+
def ordinaryWordTail (j : ℝ) (L n : ℕ) : ENNReal :=
|
| 14 |
+
2*((wordPatternSet L L).card*ENNReal.ofReal (3*exp (-(n:ℝ)))+
|
| 15 |
+
ENNReal.ofReal (exp (-2*(n:ℝ)/(π^2*(sqrt (2*j))^2)))+
|
| 16 |
+
(ENNReal.ofReal (2*exp (-(n:ℝ)/(π^2*j)))+
|
| 17 |
+
ENNReal.ofReal (2*(n:ℝ)*exp (-1/(8*(j/n))))))
|
| 18 |
+
def recipeNormTail (j : ℝ) (n : ℕ) : ENNReal :=
|
| 19 |
+
ENNReal.ofReal (2*exp (-(n:ℝ)/(π^2*j)))+
|
| 20 |
+
ENNReal.ofReal (2*(n:ℝ)*exp (-1/(8*(j/n))))
|
| 21 |
+
|
| 22 |
+
theorem gaussian_recipe_event {j A : ℝ} (hj : 0<j) (hj1 : j<1) (hA : 1≤A)
|
| 23 |
+
(M Nmax : ℕ) : ∃R B W C : ℝ, ∃N : ℕ,
|
| 24 |
+
1≤R ∧ 0≤B ∧ 0≤W ∧ 0<C ∧ 0<N ∧ ∀n,N≤n→
|
| 25 |
+
(Measure.pi (fun _ : MatrixCoordinates (Fin n)=>gaussianReal 0 1))
|
| 26 |
+
{g | ¬RecipeMatrixEvent j R A B W C M Nmax
|
| 27 |
+
(removeDiagonal (goeMatrix (j/n) g))}≤
|
| 28 |
+
recipeNormTail j n+ordinaryWordTail j (2*M+2*Nmax+3) n := by
|
| 29 |
+
let R:=max A (2*sqrt j+1+1)
|
| 30 |
+
have hAR : A≤R:=le_max_left _ _
|
| 31 |
+
have hR : 1≤R:=hA.trans hAR
|
| 32 |
+
obtain ⟨C,N,hC,hN,hword⟩:=ordinary_word_event hj hj1 hA (2*M+2*Nmax+3)
|
| 33 |
+
refine ⟨R,primaryEventBudget j R C M,R^(2*Nmax+3)+C,C,N,hR,
|
| 34 |
+
primaryEventBudget_nonneg (by linarith) hC.le M,
|
| 35 |
+
add_nonneg (pow_nonneg (by linarith) _) hC.le,hC,hN,?_⟩
|
| 36 |
+
intro n hn
|
| 37 |
+
have hn0 : 0<n:=lt_of_lt_of_le hN hn
|
| 38 |
+
let μ:=Measure.pi (fun _ : MatrixCoordinates (Fin n)=>gaussianReal 0 1)
|
| 39 |
+
let E : Set (MatrixCoordinates (Fin n)→ℝ):=
|
| 40 |
+
{g | 2*sqrt j+1+1<SKGap.opNorm (removeDiagonal (goeMatrix (j/n) g))}
|
| 41 |
+
let F : Set (MatrixCoordinates (Fin n)→ℝ):=
|
| 42 |
+
{g | ¬WordSeminormBound (removeDiagonal (goeMatrix (j/n) g)) j A C (2*M+2*Nmax+3)}
|
| 43 |
+
have hE : μ E≤recipeNormTail j n:=zeroDiagGOE_norm_tail hj hn0
|
| 44 |
+
have hF : μ F≤ordinaryWordTail j (2*M+2*Nmax+3) n:=hword n hn
|
| 45 |
+
apply (measure_mono (t:=E∪F) ?_).trans ((measure_union_le _ _).trans (add_le_add hE hF))
|
| 46 |
+
intro g hg
|
| 47 |
+
by_contra hh
|
| 48 |
+
have hJ : SKGap.opNorm (removeDiagonal (goeMatrix (j/n) g))≤R := by
|
| 49 |
+
apply le_trans (le_of_not_gt (fun hbad=>hh (.inl hbad))) (le_max_right _ _)
|
| 50 |
+
have hw : WordSeminormBound (removeDiagonal (goeMatrix (j/n) g)) j A C (2*M+2*Nmax+3):=by
|
| 51 |
+
by_contra hbad; exact hh (.inr hbad)
|
| 52 |
+
exact hg (wordEvent_recipeEvent _ hn0 hR hA hAR hC.le hJ M Nmax hw)
|
| 53 |
+
|
| 54 |
+
end SKGapCutoff.Recipe
|
| 55 |
+
|
| 56 |
+
end
|
| 57 |
+
end
|
| 58 |
+
|
| 59 |
+
section
|
| 60 |
+
|
| 61 |
+
noncomputable section
|
| 62 |
+
open scoped BigOperators Topology
|
| 63 |
+
open Filter MeasureTheory ProbabilityTheory Real
|
| 64 |
+
namespace SKGapCutoff.Recipe
|
| 65 |
+
open SKGap SKGap.Noncrossing SKGap.Noncrossing.Primary
|
| 66 |
+
|
| 67 |
+
lemma exp_rate_limit {c : ℝ} (hc : 0<c) :
|
| 68 |
+
Tendsto (fun n : ℕ=>exp (-c*(n:ℝ))) atTop (𝓝 0) := by
|
| 69 |
+
simpa using (summable_pow_mul_exp_neg_nat_mul 0 hc).tendsto_atTop_zero
|
| 70 |
+
lemma n_exp_rate_limit {c : ℝ} (hc : 0<c) :
|
| 71 |
+
Tendsto (fun n : ℕ=>(n:ℝ)*exp (-c*(n:ℝ))) atTop (𝓝 0) := by
|
| 72 |
+
simpa using (summable_pow_mul_exp_neg_nat_mul 1 hc).tendsto_atTop_zero
|
| 73 |
+
|
| 74 |
+
lemma recipeNormTail_limit {j : ℝ} (hj : 0<j) :
|
| 75 |
+
Tendsto (recipeNormTail j) atTop (𝓝 0) := by
|
| 76 |
+
have h₁ : Tendsto (fun n : ℕ=>ENNReal.ofReal (2*exp (-(n:ℝ)/(π^2*j)))) atTop (𝓝 0) := by
|
| 77 |
+
have H:=ENNReal.tendsto_ofReal ((exp_rate_limit (c:=1/(π^2*j)) (by positivity)).const_mul 2)
|
| 78 |
+
simpa only [mul_zero,ENNReal.ofReal_zero,show ∀(n : ℕ),-(1/(π^2*j))*(n:ℝ)=-(n:ℝ)/(π^2*j) by intro n;ring] using H
|
| 79 |
+
have h₂ : Tendsto (fun n : ℕ=>ENNReal.ofReal (2*(n:ℝ)*exp (-1/(8*(j/n))))) atTop (𝓝 0) := by
|
| 80 |
+
have H:=ENNReal.tendsto_ofReal ((n_exp_rate_limit (c:=1/(8*j)) (by positivity)).const_mul 2)
|
| 81 |
+
have HH : Tendsto (fun n : ℕ=>ENNReal.ofReal (2*((n:ℝ)*exp (-(1/(8*j))*(n:ℝ))))) atTop (𝓝 0):=by simpa using H
|
| 82 |
+
apply HH.congr'
|
| 83 |
+
filter_upwards [eventually_ge_atTop 1] with n hn
|
| 84 |
+
have hn0 : (n:ℝ)≠0:=by exact_mod_cast (by omega : n≠0)
|
| 85 |
+
congr 1
|
| 86 |
+
rw [mul_assoc]
|
| 87 |
+
congr 2
|
| 88 |
+
field_simp
|
| 89 |
+
convert h₁.add h₂ using 1 <;> first | rfl | simp
|
| 90 |
+
|
| 91 |
+
lemma ordinaryWordTail_limit {j : ℝ} (hj : 0<j) (L : ℕ) :
|
| 92 |
+
Tendsto (ordinaryWordTail j L) atTop (𝓝 0) := by
|
| 93 |
+
have h₁ : Tendsto (fun n : ℕ=>ENNReal.ofReal (3*exp (-(n:ℝ)))) atTop (𝓝 0) := by
|
| 94 |
+
simpa using ENNReal.tendsto_ofReal ((exp_rate_limit (c:=1) (by norm_num)).const_mul 3)
|
| 95 |
+
have h₂ : Tendsto (fun n : ℕ=>ENNReal.ofReal (exp (-2*(n:ℝ)/(π^2*(sqrt (2*j))^2)))) atTop (𝓝 0) := by
|
| 96 |
+
have hsq : 0<(sqrt (2*j))^2:=by rw [sq_sqrt (by positivity)]; positivity
|
| 97 |
+
have H:=ENNReal.tendsto_ofReal (exp_rate_limit (c:=2/(π^2*(sqrt (2*j))^2)) (by positivity))
|
| 98 |
+
simpa only [ENNReal.ofReal_zero,show ∀(n : ℕ),-(2/(π^2*(sqrt (2*j))^2))*(n:ℝ)= -2*(n:ℝ)/(π^2*(sqrt (2*j))^2) by intro n;ring] using H
|
| 99 |
+
have h₃:=(ENNReal.Tendsto.const_mul h₁ (a:=((wordPatternSet L L).card:ENNReal)) (Or.inr (by simp))).add h₂ |>.add (recipeNormTail_limit hj)
|
| 100 |
+
convert ENNReal.Tendsto.const_mul h₃ (a:=2) (Or.inr (by simp)) using 1 <;> first | rfl | simp
|
| 101 |
+
|
| 102 |
+
theorem gaussian_recipe_event_probability {j A : ℝ} (hj : 0<j) (hj1 : j<1) (hA : 1≤A)
|
| 103 |
+
(M Nmax : ℕ) : ∃R B W C : ℝ, 1≤R ∧ 0≤B ∧ 0≤W ∧ 0<C ∧
|
| 104 |
+
Tendsto (fun n=>(Measure.pi (fun _ : MatrixCoordinates (Fin n)=>gaussianReal 0 1))
|
| 105 |
+
{g | ¬RecipeMatrixEvent j R A B W C M Nmax
|
| 106 |
+
(removeDiagonal (goeMatrix (j/n) g))}) atTop (𝓝 0) := by
|
| 107 |
+
obtain ⟨R,B,W,C,N,hR,hB,hW,hC,hN,hb⟩:=gaussian_recipe_event hj hj1 hA M Nmax
|
| 108 |
+
refine ⟨R,B,W,C,hR,hB,hW,hC,?_⟩
|
| 109 |
+
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds
|
| 110 |
+
(show Tendsto (fun n=>recipeNormTail j n+ordinaryWordTail j (2*M+2*Nmax+3) n) atTop (𝓝 0) from
|
| 111 |
+
by simpa using (recipeNormTail_limit hj).add (ordinaryWordTail_limit hj _))
|
| 112 |
+
(Filter.Eventually.of_forall (fun _=>bot_le))
|
| 113 |
+
filter_upwards [eventually_ge_atTop N] with n hn
|
| 114 |
+
exact hb n hn
|
| 115 |
+
|
| 116 |
+
end SKGapCutoff.Recipe
|
| 117 |
+
|
| 118 |
+
end
|
| 119 |
+
end
|
| 120 |
+
|
| 121 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianReductionPointwise.lean
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.ConditionalHessianLaw
|
| 3 |
+
import OAI.Probability.SKGap.Localization.ScalarEmpirical
|
| 4 |
+
import OAI.Probability.SKGap.Gaussian.ScalarGaussianReductionAlgebra
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace SKGap
|
| 11 |
+
open Matrix Real Set MeasureTheory ProbabilityTheory GaussianDensity
|
| 12 |
+
open scoped BigOperators Matrix.Norms.Frobenius ENNReal
|
| 13 |
+
|
| 14 |
+
lemma tapField_planted_observation {n : ℕ} [NeZero n] (j t σ : ℝ)
|
| 15 |
+
(y x : Fin n → ℝ) (W : Matrix (Fin n) (Fin n) ℝ) :
|
| 16 |
+
tapField j (plantedInteraction j W) (fun i=>t+x i) y=
|
| 17 |
+
empiricalObservation j t σ y-W*ᵥmagnetization y-x := by
|
| 18 |
+
ext i
|
| 19 |
+
simp only [tapField,plantedInteraction,Matrix.add_apply,Matrix.smul_apply,
|
| 20 |
+
smul_eq_mul,vecMulVec_apply,mul_one,add_mul,Finset.sum_add_distrib,
|
| 21 |
+
← Finset.mul_sum,empiricalObservation,scalarD,scalarM,integral_empiricalLaw,
|
| 22 |
+
Fintype.card_fin,scalarBMoment,scalarQMoment_empirical_overlap,onsager,
|
| 23 |
+
magnetization,Pi.sub_apply,Matrix.mulVec,dotProduct]
|
| 24 |
+
ring
|
| 25 |
+
|
| 26 |
+
lemma scalar_density_cancellation {n : ℕ} [NeZero n] {j t σ : ℝ}
|
| 27 |
+
(hj : 0 ≤ j) (ht : 0 ≤ t) (hσ : 0 < σ) (y : Fin n → ℝ) :
|
| 28 |
+
rankOneDensity ((j/(n:ℝ))*(magnetization y⬝ᵥmagnetization y)+(t+σ^2))
|
| 29 |
+
(j/(n:ℝ)) (magnetization y) (empiricalObservation j t σ y)*
|
| 30 |
+
exp ((n:ℝ)*j*(1-overlap y)^2/2)=
|
| 31 |
+
sqrt (scalarS j (scalarEmpirical y t σ)/
|
| 32 |
+
(scalarS j (scalarEmpirical y t σ)+j*scalarQMoment (empiricalLaw y)))*scalarIntegrand j t σ y := by
|
| 33 |
+
let p := scalarEmpirical y t σ
|
| 34 |
+
let q := scalarQMoment (empiricalLaw y)
|
| 35 |
+
let s := scalarS j p
|
| 36 |
+
let S := s+j*q
|
| 37 |
+
have hn : (n:ℝ) ≠ 0 := by exact_mod_cast NeZero.ne n
|
| 38 |
+
have hq : 0 ≤ q := (scalarQMoment_bounds _).1
|
| 39 |
+
have hs : 0 < s := add_pos_of_pos_of_nonneg (add_pos_of_nonneg_of_pos ht (sq_pos_of_pos hσ)) (mul_nonneg hj hq)
|
| 40 |
+
have hS : 0 < S := add_pos_of_pos_of_nonneg hs (mul_nonneg hj hq)
|
| 41 |
+
have hm : magnetization y⬝ᵥmagnetization y=(n:ℝ)*q := by
|
| 42 |
+
dsimp [q]
|
| 43 |
+
rw [scalarQMoment_empirical_overlap]
|
| 44 |
+
simp only [overlap,magnetization,dotProduct,← pow_two]
|
| 45 |
+
field_simp
|
| 46 |
+
have hx : (fun i=>y i-scalarD j p)⬝ᵥmagnetization y=(n:ℝ)*scalarA j p := by
|
| 47 |
+
rw [dotProduct_comm]
|
| 48 |
+
exact scalarA_empirical_sum j t σ y
|
| 49 |
+
have hs' : (j/(n:ℝ))*(magnetization y⬝ᵥmagnetization y)+(t+σ^2)=s := by
|
| 50 |
+
rw [hm]; dsimp [s,scalarS,p,scalarEmpirical,q]; field_simp; ring
|
| 51 |
+
rw [hs']
|
| 52 |
+
have hobs : empiricalObservation j t σ y=(fun i=>y i-scalarD j p)+(j*(1-q)) • magnetization y := rfl
|
| 53 |
+
rw [hobs]
|
| 54 |
+
have hc := rankOneDensity_cancellation hn hs hS.ne' (rfl : S=s+j*q)
|
| 55 |
+
(fun i=>y i-scalarD j p) (magnetization y) hm hx (b := 1-q)
|
| 56 |
+
have hb : 1-overlap y=1-q := by rw [← scalarQMoment_empirical_overlap]
|
| 57 |
+
rw [hb,hc]
|
| 58 |
+
have hd : productNormal (scalarD j p) s y=radialDensity (sqrt s) (fun i=>y i-scalarD j p) := by
|
| 59 |
+
unfold productNormal
|
| 60 |
+
rw [show s.toNNReal=NNReal.mk s hs.le from by ext; exact Real.coe_toNNReal _ hs.le]
|
| 61 |
+
exact gaussian_density_shift _ hs.le y
|
| 62 |
+
rw [scalarIntegrand,show scalarEmpirical y t σ=p from rfl,hd]
|
| 63 |
+
simp only [Fintype.card_fin]
|
| 64 |
+
have he : (n:ℝ)*j*(scalarA j p-s*(1-q))^2/(2*s*S)=(n:ℝ)*scalarPsi j p := by
|
| 65 |
+
dsimp [S,s,q,p,scalarPsi,scalarEmpirical]
|
| 66 |
+
ring
|
| 67 |
+
rw [he]
|
| 68 |
+
ring
|
| 69 |
+
end SKGap
|
| 70 |
+
end
|
| 71 |
+
end
|
| 72 |
+
|
| 73 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianRegression.lean
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianCoordinates
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory Matrix
|
| 10 |
+
open scoped BigOperators ENNReal
|
| 11 |
+
namespace SKGap.GaussianRegression
|
| 12 |
+
|
| 13 |
+
theorem law_eq_of_mean_covariance {Ω Ω' ι : Type*}
|
| 14 |
+
[MeasurableSpace Ω] [MeasurableSpace Ω'] [Fintype ι] [DecidableEq ι]
|
| 15 |
+
{P : Measure Ω} {P' : Measure Ω'} {X : Ω → ι → ℝ} {Y : Ω' → ι → ℝ}
|
| 16 |
+
(hX : HasGaussianLaw X P) (hY : HasGaussianLaw Y P')
|
| 17 |
+
(hm : ∀ i, (∫ w, X w i ∂P) = ∫ w, Y w i ∂P')
|
| 18 |
+
(hc : ∀ i k, cov[fun w => X w i, fun w => X w k; P] =
|
| 19 |
+
cov[fun w => Y w i, fun w => Y w k; P']) :
|
| 20 |
+
P.map X = P'.map Y := by
|
| 21 |
+
classical
|
| 22 |
+
have := hX.isProbabilityMeasure
|
| 23 |
+
have := hY.isProbabilityMeasure
|
| 24 |
+
apply Measure.ext_of_charFunDual
|
| 25 |
+
ext L
|
| 26 |
+
rw [hX.charFunDual_map_eq,hY.charFunDual_map_eq]
|
| 27 |
+
let c : ι → ℝ := fun i => L (fun k => if i=k then 1 else 0)
|
| 28 |
+
have hL (x : ι → ℝ) : L x = ∑ i, x i * c i := by
|
| 29 |
+
simpa only [c, smul_eq_mul, ContinuousLinearMap.coe_coe] using L.toLinearMap.pi_apply_eq_sum_univ x
|
| 30 |
+
have hLX : L ∘ X = fun w => ∑ i, X w i*c i := funext (fun w => hL (X w))
|
| 31 |
+
have hLY : L ∘ Y = fun w => ∑ i, Y w i*c i := funext (fun w => hL (Y w))
|
| 32 |
+
have hiX (i : ι) := (hX.eval i).memLp_two
|
| 33 |
+
have hiY (i : ι) := (hY.eval i).memLp_two
|
| 34 |
+
have hem : (∫ w, (L ∘ X) w ∂P) = ∫ w, (L ∘ Y) w ∂P' := by
|
| 35 |
+
rw [hLX,hLY]
|
| 36 |
+
rw [integral_finsetSum _ (fun i _ => ((hX.eval i).integrable.mul_const _)),
|
| 37 |
+
integral_finsetSum _ (fun i _ => ((hY.eval i).integrable.mul_const _))]
|
| 38 |
+
simp only [integral_mul_const,hm]
|
| 39 |
+
have hev : Var[L ∘ X; P] = Var[L ∘ Y; P'] := by
|
| 40 |
+
rw [← covariance_self (hX.map L).aemeasurable,
|
| 41 |
+
← covariance_self (hY.map L).aemeasurable]
|
| 42 |
+
rw [hLX,hLY]
|
| 43 |
+
rw [covariance_fun_sum_fun_sum (fun i => (hiX i).mul_const _) (fun i => (hiX i).mul_const _),
|
| 44 |
+
covariance_fun_sum_fun_sum (fun i => (hiY i).mul_const _) (fun i => (hiY i).mul_const _)]
|
| 45 |
+
simp only [covariance_mul_const_left,covariance_mul_const_right,hc]
|
| 46 |
+
rw [hev,hem]
|
| 47 |
+
|
| 48 |
+
def matrixCLM {ι κ : Type*} [Fintype κ] (A : Matrix ι κ ℝ) :
|
| 49 |
+
(κ → ℝ) →L[ℝ] (ι → ℝ) := A.mulVecLin.toContinuousLinearMap
|
| 50 |
+
|
| 51 |
+
@[simp] lemma matrixCLM_apply {ι κ : Type*} [Fintype κ] (A : Matrix ι κ ℝ) (x : κ → ℝ) :
|
| 52 |
+
matrixCLM A x = A *ᵥ x := rfl
|
| 53 |
+
|
| 54 |
+
theorem residual_independent {Ω ι κ : Type*} [MeasurableSpace Ω]
|
| 55 |
+
[Fintype ι] [Fintype κ] {P : Measure Ω} {X : Ω → ι → ℝ} {Y : Ω → κ → ℝ}
|
| 56 |
+
(hXY : HasGaussianLaw (fun w => (X w,Y w)) P) (K : Matrix ι κ ℝ)
|
| 57 |
+
(hcov : ∀ i k, cov[fun w => X w i, fun w => Y w k; P] =
|
| 58 |
+
∑ l, K i l * cov[fun w => Y w l,fun w => Y w k; P]) :
|
| 59 |
+
IndepFun (fun w => X w-K*ᵥ Y w) Y P := by
|
| 60 |
+
have := hXY.isProbabilityMeasure
|
| 61 |
+
have hR : HasGaussianLaw (fun w => (X w-K*ᵥ Y w,Y w)) P := by
|
| 62 |
+
exact hXY.map_fun (((ContinuousLinearMap.fst ℝ (ι → ℝ) (κ → ℝ))-
|
| 63 |
+
(matrixCLM K).comp (ContinuousLinearMap.snd ℝ (ι → ℝ) (κ → ℝ))).prod
|
| 64 |
+
(ContinuousLinearMap.snd ℝ (ι → ℝ) (κ → ℝ)))
|
| 65 |
+
apply hR.indepFun_of_covariance_eval
|
| 66 |
+
intro i k
|
| 67 |
+
change cov[fun w => X w i-∑ l, K i l*Y w l,fun w => Y w k; P]=0
|
| 68 |
+
have hK : MemLp (fun w => ∑ l, K i l*Y w l) 2 P :=
|
| 69 |
+
((hXY.snd.map (matrixCLM K)).eval i).memLp_two
|
| 70 |
+
rw [covariance_fun_sub_left (hXY.fst.eval i).memLp_two hK (hXY.snd.eval k).memLp_two]
|
| 71 |
+
rw [covariance_fun_sum_left (fun l => (hXY.snd.eval l).memLp_two.const_mul _)
|
| 72 |
+
(hXY.snd.eval k).memLp_two]
|
| 73 |
+
simp only [covariance_const_mul_left,hcov,sub_self]
|
| 74 |
+
|
| 75 |
+
end SKGap.GaussianRegression
|
| 76 |
+
end
|
| 77 |
+
end
|
| 78 |
+
|
| 79 |
+
section
|
| 80 |
+
noncomputable section
|
| 81 |
+
namespace SKGap
|
| 82 |
+
open MeasureTheory ProbabilityTheory Matrix
|
| 83 |
+
open scoped BigOperators ENNReal
|
| 84 |
+
|
| 85 |
+
lemma coordinate_hasLaw {κ : Type*} [Fintype κ] (i : κ) :
|
| 86 |
+
HasLaw (fun g : κ → ℝ => g i) (gaussianReal 0 1) (gaussianCoordinates κ) :=
|
| 87 |
+
⟨(measurable_pi_apply i).aemeasurable,
|
| 88 |
+
(measurePreserving_eval (fun _ : κ => gaussianReal 0 1) i).map_eq⟩
|
| 89 |
+
|
| 90 |
+
lemma coordinates_gaussian {κ : Type*} [Fintype κ] :
|
| 91 |
+
HasGaussianLaw (fun g : κ → ℝ => g) (gaussianCoordinates κ) :=
|
| 92 |
+
(iIndepFun_pi (fun _ : κ => aemeasurable_id)).hasGaussianLaw
|
| 93 |
+
(fun i => (coordinate_hasLaw i).hasGaussianLaw)
|
| 94 |
+
|
| 95 |
+
lemma coordinate_covariance {κ : Type*} [Fintype κ] [DecidableEq κ] (i k : κ) :
|
| 96 |
+
cov[fun g : κ → ℝ => g i,fun g : κ → ℝ => g k;gaussianCoordinates κ] =
|
| 97 |
+
if i=k then 1 else 0 := by
|
| 98 |
+
by_cases h : i=k
|
| 99 |
+
· subst k
|
| 100 |
+
rw [ite_eq_left rfl,covariance_self (measurable_pi_apply i).aemeasurable,
|
| 101 |
+
(coordinate_hasLaw i).variance_eq]
|
| 102 |
+
simp
|
| 103 |
+
· rw [ite_eq_right h]
|
| 104 |
+
exact ((iIndepFun_pi (fun _ : κ => aemeasurable_id)).indepFun h).covariance_eq_zero
|
| 105 |
+
(coordinate_hasLaw i).hasGaussianLaw.memLp_two (coordinate_hasLaw k).hasGaussianLaw.memLp_two
|
| 106 |
+
|
| 107 |
+
lemma linear_gaussian_mean {κ : Type*} [Fintype κ] (a : κ → ℝ) :
|
| 108 |
+
(∫ g, ∑ i, a i*g i ∂gaussianCoordinates κ) = 0 := by
|
| 109 |
+
rw [integral_finsetSum _ (fun i _ => (coordinate_hasLaw i).hasGaussianLaw.integrable.const_mul _)]
|
| 110 |
+
simp [integral_const_mul,(coordinate_hasLaw _).integral_eq]
|
| 111 |
+
|
| 112 |
+
lemma linear_gaussian_covariance {κ : Type*} [Fintype κ] [DecidableEq κ] (a b : κ → ℝ) :
|
| 113 |
+
cov[fun g => ∑ i, a i*g i,fun g => ∑ i, b i*g i;gaussianCoordinates κ] =
|
| 114 |
+
∑ i, a i*b i := by
|
| 115 |
+
rw [covariance_fun_sum_fun_sum
|
| 116 |
+
(fun i => (coordinate_hasLaw i).hasGaussianLaw.memLp_two.const_mul _)
|
| 117 |
+
(fun i => (coordinate_hasLaw i).hasGaussianLaw.memLp_two.const_mul _)]
|
| 118 |
+
simp only [covariance_const_mul_left,covariance_const_mul_right,coordinate_covariance]
|
| 119 |
+
simp [mul_comm]
|
| 120 |
+
|
| 121 |
+
lemma matrix_sample_gaussian {ι κ : Type*} [Fintype ι] [Fintype κ] (A : Matrix ι κ ℝ) :
|
| 122 |
+
HasGaussianLaw (fun g => A*ᵥg) (gaussianCoordinates κ) :=
|
| 123 |
+
coordinates_gaussian.map_fun (GaussianRegression.matrixCLM A)
|
| 124 |
+
|
| 125 |
+
lemma matrix_sample_covariance {ι κ : Type*} [Fintype κ] [DecidableEq κ]
|
| 126 |
+
(A : Matrix ι κ ℝ) (i k : ι) :
|
| 127 |
+
cov[fun g => (A*ᵥg) i,fun g => (A*ᵥg) k;gaussianCoordinates κ] = (A*Aᵀ) i k :=
|
| 128 |
+
linear_gaussian_covariance (A i) (A k)
|
| 129 |
+
|
| 130 |
+
end SKGap
|
| 131 |
+
end
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianSign.lean
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.Conjugation
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open Matrix MeasureTheory ProbabilityTheory
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
noncomputable def gaussianSignEquiv {κ : Type*} (q : κ → ℝ) (hq : ∀ b, q b^2=1) :
|
| 13 |
+
(κ → ℝ) ≃ᵐ (κ → ℝ) where
|
| 14 |
+
toFun g b := q b*g b
|
| 15 |
+
invFun g b := q b*g b
|
| 16 |
+
left_inv g := by ext b; dsimp; rw [← mul_assoc,← sq,hq b,one_mul]
|
| 17 |
+
right_inv g := by ext b; dsimp; rw [← mul_assoc,← sq,hq b,one_mul]
|
| 18 |
+
measurable_toFun := by change Measurable (fun g : κ → ℝ => fun b => q b*g b); fun_prop
|
| 19 |
+
measurable_invFun := by change Measurable (fun g : κ → ℝ => fun b => q b*g b); fun_prop
|
| 20 |
+
|
| 21 |
+
lemma gaussianSign_map {κ : Type*} [Fintype κ] (q : κ → ℝ) (hq : ∀ b, q b^2=1) :
|
| 22 |
+
(Measure.pi (fun _ : κ => gaussianReal 0 1)).map (gaussianSignEquiv q hq) =
|
| 23 |
+
Measure.pi (fun _ : κ => gaussianReal 0 1) := by
|
| 24 |
+
have he (b : κ) : (gaussianReal 0 1).map (fun x => q b*x) = gaussianReal 0 1 := by
|
| 25 |
+
rcases sq_eq_one_iff.mp (hq b) with h|h
|
| 26 |
+
· simp [h]
|
| 27 |
+
· simpa only [h,neg_one_mul,neg_zero] using (gaussianReal_map_neg (μ := (0:ℝ)) (v := 1))
|
| 28 |
+
change (Measure.pi (fun _ : κ => gaussianReal 0 1)).map (fun g b => q b*g b) = _
|
| 29 |
+
rw [Measure.pi_map_pi (fun _ => by fun_prop)]
|
| 30 |
+
simp only [he]
|
| 31 |
+
|
| 32 |
+
lemma gaussianSign_integral {κ : Type*} [Fintype κ] (q : κ → ℝ) (hq : ∀ b, q b^2=1)
|
| 33 |
+
(F : (κ → ℝ) → ℝ) :
|
| 34 |
+
(∫ g, F (gaussianSignEquiv q hq g) ∂Measure.pi (fun _ : κ => gaussianReal 0 1)) =
|
| 35 |
+
∫ g, F g ∂Measure.pi (fun _ : κ => gaussianReal 0 1) := by
|
| 36 |
+
rw [← integral_map_equiv,gaussianSign_map]
|
| 37 |
+
|
| 38 |
+
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
|
| 39 |
+
def goeSign (s : ι → ℝ) : MatrixCoordinates ι → ℝ :=
|
| 40 |
+
Sum.elim (fun p => s p.1*s p.2) (fun _ => 1)
|
| 41 |
+
|
| 42 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 43 |
+
lemma goeSign_sq (s : ι → ℝ) (hs : ∀ i, s i^2=1) (b : MatrixCoordinates ι) :
|
| 44 |
+
goeSign s b^2=1 := by
|
| 45 |
+
rcases b with ⟨i,k⟩|i
|
| 46 |
+
· simp only [goeSign,Sum.elim_inl,mul_pow,hs,one_mul]
|
| 47 |
+
· norm_num [goeSign]
|
| 48 |
+
|
| 49 |
+
omit [Fintype ι] [DecidableEq ι] in
|
| 50 |
+
lemma goeMatrix_sign (r : ℝ) (s : ι → ℝ) (hs : ∀ i, s i^2=1)
|
| 51 |
+
(g : MatrixCoordinates ι → ℝ) :
|
| 52 |
+
goeMatrix r (gaussianSignEquiv (goeSign s) (goeSign_sq s hs) g) =
|
| 53 |
+
signConjugate s (goeMatrix r g) := by
|
| 54 |
+
ext i k
|
| 55 |
+
dsimp [goeMatrix,gaussianSignEquiv,goeSign,signConjugate]
|
| 56 |
+
ring
|
| 57 |
+
|
| 58 |
+
lemma goe_equivariant_offdiag (r : ℝ) (F : Matrix ι ι ℝ → Matrix ι ι ℝ)
|
| 59 |
+
(hF : ∀ (s : ι → ℝ), (∀ i, s i^2=1) → ∀ M,
|
| 60 |
+
F (signConjugate s M)=signConjugate s (F M)) (i k : ι) (hik : i ≠ k) :
|
| 61 |
+
(∫ g, F (goeMatrix r g) i k ∂Measure.pi (fun _ : MatrixCoordinates ι => gaussianReal 0 1))=0 := by
|
| 62 |
+
let s : ι → ℝ := fun b => if b=i then -1 else 1
|
| 63 |
+
have hs : ∀ b, s b^2=1 := by intro b; dsimp [s]; split <;> norm_num
|
| 64 |
+
have hi := gaussianSign_integral (goeSign s) (goeSign_sq s hs) (fun g => F (goeMatrix r g) i k)
|
| 65 |
+
have hsi : s i = -1 := by simp [s]
|
| 66 |
+
have hsk : s k = 1 := by simp [s,Ne.symm hik]
|
| 67 |
+
have heq : (fun g => F (goeMatrix r (gaussianSignEquiv (goeSign s) (goeSign_sq s hs) g)) i k) =
|
| 68 |
+
(fun g => -F (goeMatrix r g) i k) := by
|
| 69 |
+
funext g
|
| 70 |
+
rw [goeMatrix_sign r s hs g,hF s hs]
|
| 71 |
+
change s i*s k*F (goeMatrix r g) i k = _
|
| 72 |
+
rw [hsi,hsk,neg_one_mul,neg_mul,one_mul]
|
| 73 |
+
rw [heq,integral_neg] at hi
|
| 74 |
+
linarith
|
| 75 |
+
end SKGap
|
| 76 |
+
end
|
| 77 |
+
end
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianSquareTail.lean
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open MeasureTheory ProbabilityTheory Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
lemma gaussian_square_exp_integral :
|
| 13 |
+
(∫ x : ℝ,exp (x^2/4) ∂gaussianReal 0 1) ≤ 2 := by
|
| 14 |
+
rw [gaussianReal_of_var_ne_zero 0 (one_ne_zero),
|
| 15 |
+
integral_withDensity_eq_integral_toReal_smul (measurable_gaussianPDF 0 1)
|
| 16 |
+
(ae_of_all _ (fun y=>by simp [gaussianPDF]))]
|
| 17 |
+
simp only [gaussianPDF,ENNReal.toReal_ofReal (gaussianPDFReal_nonneg _ _ _),smul_eq_mul]
|
| 18 |
+
have he : (fun x : ℝ=>gaussianPDFReal 0 1 x*exp (x^2/4))=
|
| 19 |
+
(fun x : ℝ=>(1/sqrt (2*Real.pi))*exp (-(1/4:ℝ)*x^2)) := by
|
| 20 |
+
funext x
|
| 21 |
+
simp only [gaussianPDFReal,NNReal.coe_one,sub_zero,mul_one]
|
| 22 |
+
rw [mul_assoc,← exp_add]
|
| 23 |
+
congr 2 <;> ring
|
| 24 |
+
rw [he,integral_const_mul,integral_gaussian]
|
| 25 |
+
have hp := Real.pi_pos
|
| 26 |
+
have h1 := sq_sqrt (show 0 ≤ 2*Real.pi by positivity)
|
| 27 |
+
have h2 := sq_sqrt (show 0 ≤ Real.pi/(1/4:ℝ) by positivity)
|
| 28 |
+
have h3 := sqrt_nonneg (2*Real.pi)
|
| 29 |
+
have h4 := sqrt_nonneg (Real.pi/(1/4:ℝ))
|
| 30 |
+
rw [one_div,mul_comm,← div_eq_mul_inv]
|
| 31 |
+
apply (div_le_iff₀ (sqrt_pos.mpr (by positivity))).mpr
|
| 32 |
+
nlinarith
|
| 33 |
+
|
| 34 |
+
lemma gaussian_square_exp_integrable :
|
| 35 |
+
Integrable (fun x : ℝ=>exp (x^2/4)) (gaussianReal 0 1) := by
|
| 36 |
+
rw [gaussianReal_of_var_ne_zero 0 (one_ne_zero),integrable_withDensity_iff
|
| 37 |
+
(measurable_gaussianPDF 0 1) (ae_of_all _ (fun y=>by simp [gaussianPDF]))]
|
| 38 |
+
simp only [gaussianPDF,ENNReal.toReal_ofReal (gaussianPDFReal_nonneg _ _ _)]
|
| 39 |
+
have hi := (integrable_exp_neg_mul_sq (show (0:ℝ) < 1/4 by norm_num)).const_mul (1/sqrt (2*Real.pi))
|
| 40 |
+
have he : (fun g : ℝ=>exp (g^2/4)*gaussianPDFReal 0 1 g)=
|
| 41 |
+
(fun g : ℝ=>(1/sqrt (2*Real.pi))*exp (-(1/4:ℝ)*g^2)) := by
|
| 42 |
+
funext g
|
| 43 |
+
simp only [gaussianPDFReal,NNReal.coe_one,sub_zero,mul_one]
|
| 44 |
+
rw [mul_left_comm,← exp_add]
|
| 45 |
+
congr 2 <;> ring
|
| 46 |
+
rw [he]
|
| 47 |
+
exact hi
|
| 48 |
+
|
| 49 |
+
lemma product_gaussian_square_exp_integral {ι : Type*} [Fintype ι] :
|
| 50 |
+
(∫ g : ι→ℝ,exp ((∑ i,g i^2)/4) ∂Measure.pi (fun _ : ι=>gaussianReal 0 1)) ≤
|
| 51 |
+
exp ((Fintype.card ι:ℝ)*log 2) := by
|
| 52 |
+
have he (g : ι→ℝ) : exp ((∑ i,g i^2)/4)=∏ i,exp (g i^2/4) := by
|
| 53 |
+
rw [← exp_sum,Finset.sum_div]
|
| 54 |
+
simp_rw [he]
|
| 55 |
+
rw [integral_fintype_prod_eq_prod (f:=fun _ : ι=>fun x : ℝ=>exp (x^2/4))]
|
| 56 |
+
calc
|
| 57 |
+
_ ≤ ∏ _i : ι,(2:ℝ) := Finset.prod_le_prod₀
|
| 58 |
+
(fun i _=>integral_nonneg (fun x=>(exp_pos _).le))
|
| 59 |
+
(fun i _=>gaussian_square_exp_integral)
|
| 60 |
+
_ = _ := by rw [Finset.prod_const,Finset.card_univ,exp_nat_mul,exp_log (by norm_num : (0:ℝ)<2)]
|
| 61 |
+
|
| 62 |
+
lemma product_gaussian_square_exp_integrable {ι : Type*} [Fintype ι] :
|
| 63 |
+
Integrable (fun g : ι→ℝ=>exp ((∑ i,g i^2)/4))
|
| 64 |
+
(Measure.pi (fun _ : ι=>gaussianReal 0 1)) := by
|
| 65 |
+
have hi := Integrable.fintype_prod (fun _ : ι=>gaussian_square_exp_integrable)
|
| 66 |
+
convert hi using 1
|
| 67 |
+
ext g
|
| 68 |
+
rw [← exp_sum,Finset.sum_div]
|
| 69 |
+
|
| 70 |
+
lemma product_gaussian_square_tail {ι : Type*} [Fintype ι] (t : ℝ) :
|
| 71 |
+
(Measure.pi (fun _ : ι=>gaussianReal 0 1)).real {g | t < ∑ i,g i^2} ≤
|
| 72 |
+
exp (-t/4+(Fintype.card ι:ℝ)*log 2) := by
|
| 73 |
+
have hm := mul_meas_ge_le_integral_of_nonneg
|
| 74 |
+
(ae_of_all (Measure.pi (fun _ : ι=>gaussianReal 0 1))
|
| 75 |
+
(fun g=>(exp_pos ((∑ i,g i^2)/4)).le)) product_gaussian_square_exp_integrable (exp (t/4))
|
| 76 |
+
have hs : {g : ι→ℝ| t < ∑ i,g i^2} ⊆ {g | exp (t/4) ≤ exp ((∑ i,g i^2)/4)} := by
|
| 77 |
+
intro g hg
|
| 78 |
+
exact exp_le_exp.mpr (by linarith only [show t < ∑ i,g i^2 from hg])
|
| 79 |
+
have hb := (mul_le_mul_of_nonneg_left (measureReal_mono hs)
|
| 80 |
+
(exp_pos (t/4)).le).trans (hm.trans product_gaussian_square_exp_integral)
|
| 81 |
+
rw [show -t/4+(Fintype.card ι:ℝ)*log 2=(Fintype.card ι:ℝ)*log 2-t/4 by ring,exp_sub]
|
| 82 |
+
apply (le_div_iff₀ (exp_pos _)).mpr
|
| 83 |
+
simpa only [mul_comm] using hb
|
| 84 |
+
end SKGap
|
| 85 |
+
end
|
| 86 |
+
end
|
| 87 |
+
|
| 88 |
+
section
|
| 89 |
+
noncomputable section
|
| 90 |
+
namespace SKGap
|
| 91 |
+
open MeasureTheory ProbabilityTheory Real
|
| 92 |
+
open scoped BigOperators NNReal
|
| 93 |
+
variable {κ : Type*} [Fintype κ]
|
| 94 |
+
|
| 95 |
+
lemma gaussian_scaled_coordinates_hasLaw {r : ℝ} (hr : 0 ≤ r) :
|
| 96 |
+
HasLaw (fun g : κ→ℝ=>fun k=>sqrt r*g k)
|
| 97 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 (Real.toNNReal r))) (gaussianCoordinates κ) := by
|
| 98 |
+
have hl (k : κ) : HasLaw (fun g : κ→ℝ=>sqrt r*g k)
|
| 99 |
+
(gaussianReal 0 (Real.toNNReal r)) (gaussianCoordinates κ) := by
|
| 100 |
+
have h := gaussianReal_const_mul (coordinate_hasLaw (κ:=κ) k) (sqrt r)
|
| 101 |
+
have hv : (⟨(sqrt r)^2,sq_nonneg _⟩:ℝ≥0)*1=Real.toNNReal r := by
|
| 102 |
+
apply NNReal.eq
|
| 103 |
+
change (sqrt r)^2*1=↑(Real.toNNReal r)
|
| 104 |
+
rw [mul_one,sq_sqrt hr,Real.coe_toNNReal _ hr]
|
| 105 |
+
rw [mul_zero] at h
|
| 106 |
+
convert h using 1
|
| 107 |
+
exact congrArg (gaussianReal 0) hv.symm
|
| 108 |
+
exact iIndepFun.hasLaw_pi hl ((iIndepFun_pi (fun _ : κ=>aemeasurable_id)).comp
|
| 109 |
+
(fun _=>fun x : ℝ=>sqrt r*x) (fun _=>by fun_prop))
|
| 110 |
+
|
| 111 |
+
lemma scaled_gaussian_square_tail {r : ℝ} (hr : 0 < r) (t : ℝ) :
|
| 112 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 (Real.toNNReal r))).real {g | t < ∑ i,g i^2} ≤
|
| 113 |
+
exp (-t/(4*r)+(Fintype.card κ:ℝ)*log 2) := by
|
| 114 |
+
have hm : MeasurableSet {g : κ→ℝ | t < ∑ i,g i^2} := by measurability
|
| 115 |
+
rw [← (gaussian_scaled_coordinates_hasLaw (κ:=κ) hr.le).measureReal_eq hm]
|
| 116 |
+
have he : {g : κ→ℝ | t < ∑ i,(sqrt r*g i)^2}={g | t/r < ∑ i,g i^2} := by
|
| 117 |
+
ext g
|
| 118 |
+
simp only [Set.mem_ofPred_eq,mul_pow,sq_sqrt hr.le,← Finset.mul_sum]
|
| 119 |
+
rw [div_lt_iff₀ hr,mul_comm]
|
| 120 |
+
rw [he]
|
| 121 |
+
simpa only [gaussianCoordinates,neg_div,div_div,mul_comm r (4:ℝ)] using
|
| 122 |
+
product_gaussian_square_tail (ι:=κ) (t/r)
|
| 123 |
+
end SKGap
|
| 124 |
+
end
|
| 125 |
+
end
|
| 126 |
+
|
| 127 |
+
section
|
| 128 |
+
noncomputable section
|
| 129 |
+
namespace SKGap
|
| 130 |
+
open MeasureTheory ProbabilityTheory Real
|
| 131 |
+
open scoped BigOperators
|
| 132 |
+
|
| 133 |
+
lemma gaussian_real_square_tail {r : ℝ} (hr : 0 < r) (t : ℝ) :
|
| 134 |
+
(gaussianReal 0 (Real.toNNReal r)).real {x : ℝ | t < x^2} ≤ exp (-t/(4*r)+log 2) := by
|
| 135 |
+
have h : HasLaw (fun v : Unit→ℝ=>v ()) (gaussianReal 0 (Real.toNNReal r))
|
| 136 |
+
(Measure.pi (fun _ : Unit=>gaussianReal 0 (Real.toNNReal r))) :=
|
| 137 |
+
⟨(measurable_pi_apply ()).aemeasurable,(measurePreserving_eval (fun _ : Unit=>gaussianReal 0 (Real.toNNReal r)) ()).map_eq⟩
|
| 138 |
+
rw [← h.measureReal_eq (by measurability : MeasurableSet {x : ℝ | t < x^2})]
|
| 139 |
+
simpa using scaled_gaussian_square_tail (κ:=Unit) hr t
|
| 140 |
+
|
| 141 |
+
lemma gaussian_real_abs_tail {r : ℝ} (hr : 0 < r) {d : ℝ} (hd : 0 ≤ d) :
|
| 142 |
+
(gaussianReal 0 (Real.toNNReal r)).real {x : ℝ | d < |x|} ≤ 2*exp (-d^2/(4*r)) := by
|
| 143 |
+
have he : {x : ℝ | d < |x|}={x | d^2 < x^2} := by
|
| 144 |
+
ext x
|
| 145 |
+
simpa only [Set.mem_ofPred_eq,sq_abs] using (sq_lt_sq₀ hd (abs_nonneg x)).symm
|
| 146 |
+
rw [he]
|
| 147 |
+
apply (gaussian_real_square_tail hr (d^2)).trans_eq
|
| 148 |
+
rw [exp_add,exp_log (by norm_num : (0:ℝ) < 2),mul_comm]
|
| 149 |
+
end SKGap
|
| 150 |
+
end
|
| 151 |
+
end
|
| 152 |
+
|
| 153 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianTailScale.lean
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.PartitionLogLipschitz
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap
|
| 9 |
+
open MeasureTheory ProbabilityTheory Real Filter Set
|
| 10 |
+
open scoped BigOperators NNReal Topology
|
| 11 |
+
|
| 12 |
+
lemma exists_gaussian_tail_quantile {p : ℝ} (hp : 0 < p) :
|
| 13 |
+
∃ c : ℝ, 0 < c ∧ exp (-2*c^2/π^2) < p := by
|
| 14 |
+
let c : ℝ := sqrt (π^2/2*(|log p|+1))
|
| 15 |
+
have hc : 0 < c := sqrt_pos.mpr (mul_pos (div_pos (sq_pos_of_pos pi_pos) (by norm_num)) (by positivity))
|
| 16 |
+
have hc2 : c^2=π^2/2*(|log p|+1) := sq_sqrt (by positivity)
|
| 17 |
+
refine ⟨c,hc,?_⟩
|
| 18 |
+
have he : -2*c^2/π^2= -(|log p|+1) := by rw [hc2];field_simp
|
| 19 |
+
rw [he]
|
| 20 |
+
apply lt_of_lt_of_eq ?_ (exp_log hp)
|
| 21 |
+
apply exp_lt_exp.mpr
|
| 22 |
+
linarith only [neg_abs_le (log p)]
|
| 23 |
+
|
| 24 |
+
lemma eventually_sqrt_cost_le_linear {δ c : ℝ} (hδ : 0 < δ) (hc : 0 ≤ c) :
|
| 25 |
+
∀ᶠ n : ℕ in atTop, log 2+c*sqrt (n:ℝ) ≤ δ*(n:ℝ)/2 := by
|
| 26 |
+
have hl : 0 ≤ log (2:ℝ) := log_nonneg (by norm_num)
|
| 27 |
+
have hlarge : ∀ᶠ n : ℕ in atTop, (4*c/δ)^2+4*log 2/δ ≤ (n:ℝ) :=
|
| 28 |
+
tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop _)
|
| 29 |
+
filter_upwards [hlarge] with n hn
|
| 30 |
+
have hn0 : (0:ℝ) ≤ n := by positivity
|
| 31 |
+
have hs : 4*c/δ ≤ sqrt (n:ℝ) := by
|
| 32 |
+
apply (sq_le_sq₀ (by positivity) (sqrt_nonneg _)).mp
|
| 33 |
+
rw [sq_sqrt hn0]
|
| 34 |
+
linarith only [hn,div_nonneg (mul_nonneg (by norm_num : (0:ℝ) ≤ 4) hl) hδ.le]
|
| 35 |
+
have hs' := (div_le_iff₀ hδ).mp hs
|
| 36 |
+
have he := sq_sqrt hn0
|
| 37 |
+
have hm := mul_le_mul_of_nonneg_right hs' (sqrt_nonneg (n:ℝ))
|
| 38 |
+
have hn' : 4*log 2/δ ≤ (n:ℝ) := by linarith only [hn,sq_nonneg (4*c/δ)]
|
| 39 |
+
have hl' := (div_le_iff₀ hδ).mp hn'
|
| 40 |
+
have hm' : 4*c*sqrt (n:ℝ) ≤ δ*(n:ℝ) := hm.trans_eq (by
|
| 41 |
+
calc sqrt (n:ℝ)*δ*sqrt (n:ℝ) = δ*(sqrt (n:ℝ))^2 := by ring
|
| 42 |
+
_ = δ*(n:ℝ) := by rw [he])
|
| 43 |
+
linarith only [hm',hl']
|
| 44 |
+
|
| 45 |
+
end SKGap
|
| 46 |
+
end
|
| 47 |
+
end
|
| 48 |
+
|
| 49 |
+
section
|
| 50 |
+
noncomputable section
|
| 51 |
+
namespace SKGap
|
| 52 |
+
open MeasureTheory ProbabilityTheory Real Filter Set
|
| 53 |
+
open scoped BigOperators NNReal Topology
|
| 54 |
+
|
| 55 |
+
lemma gaussianSpinPartition_log_mean_lower {j c : ℝ} (hj0 : 0 ≤ j) (hj : j < 1)
|
| 56 |
+
(hc : 0 < c) (hpc : exp (-2*c^2/π^2) < 1/(4*quadraticGaussianBound j))
|
| 57 |
+
{n : ℕ} (hn : 0 < n) {r : ℝ} (hr : 0 ≤ r) (hnr : (n:ℝ)*r ≤ j) :
|
| 58 |
+
log (∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))-log 2-c*sqrt (n:ℝ) ≤
|
| 59 |
+
∫ g,log (gaussianSpinPartition n r g) ∂gaussianCoordinates (Edge n) := by
|
| 60 |
+
have hM := gaussianSpinPartition_mean_pos (n:=n) hr
|
| 61 |
+
have hsub : {g | (∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))/2 ≤ gaussianSpinPartition n r g} ⊆
|
| 62 |
+
{g | log (∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))-log 2 ≤ log (gaussianSpinPartition n r g)} := by
|
| 63 |
+
intro g hg
|
| 64 |
+
simp only [mem_ofPred_eq] at hg ⊢
|
| 65 |
+
have h := log_le_log (div_pos hM (by norm_num)) hg
|
| 66 |
+
rwa [log_div hM.ne' (by norm_num : (2:ℝ) ≠ 0)] at h
|
| 67 |
+
exact gaussian_log_anchor (f:=fun g=>log (gaussianSpinPartition n r g)) (gaussianSpinPartition_log_lipschitz hr (hnr.trans hj.le))
|
| 68 |
+
(by exact_mod_cast sqrt_pos.mpr (show (0:ℝ) < n by exact_mod_cast hn)) hc hpc
|
| 69 |
+
((gaussianSpinPartition_positive_probability hj0 hj hr hnr).trans
|
| 70 |
+
(measureReal_mono hsub (measure_ne_top _ _)))
|
| 71 |
+
|
| 72 |
+
lemma gaussianSpinPartition_lower_tail_bound {j c δ : ℝ} (hj0 : 0 ≤ j) (hj : j < 1)
|
| 73 |
+
(hc : 0 < c) (hpc : exp (-2*c^2/π^2) < 1/(4*quadraticGaussianBound j)) (hδ : 0 < δ)
|
| 74 |
+
{n : ℕ} (hn : 0 < n) {r : ℝ} (hr : 0 ≤ r) (hnr : (n:ℝ)*r ≤ j)
|
| 75 |
+
(hbudget : log 2+c*sqrt (n:ℝ) ≤ δ*(n:ℝ)/2) :
|
| 76 |
+
(gaussianCoordinates (Edge n)).real
|
| 77 |
+
{g | gaussianSpinPartition n r g/(∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n)) < exp (-δ*(n:ℝ))} ≤
|
| 78 |
+
exp (-δ^2*(n:ℝ)/(2*π^2)) := by
|
| 79 |
+
have hnp : (0:ℝ) < n := by exact_mod_cast hn
|
| 80 |
+
have hM := gaussianSpinPartition_mean_pos (n:=n) hr
|
| 81 |
+
have ha := gaussianSpinPartition_log_mean_lower hj0 hj hc hpc hn hr hnr
|
| 82 |
+
have hsub : {g | gaussianSpinPartition n r g/(∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n)) < exp (-δ*(n:ℝ))} ⊆
|
| 83 |
+
{g | log (gaussianSpinPartition n r g)-(∫ g,log (gaussianSpinPartition n r g) ∂gaussianCoordinates (Edge n)) ≤ -(δ*(n:ℝ)/2)} := by
|
| 84 |
+
intro g hg
|
| 85 |
+
simp only [mem_ofPred_eq] at hg
|
| 86 |
+
have hg' := (div_lt_iff₀ hM).mp hg
|
| 87 |
+
have hlog := log_lt_log (gaussianSpinPartition_pos n r g) hg'
|
| 88 |
+
rw [log_mul (exp_pos _).ne' hM.ne',log_exp] at hlog
|
| 89 |
+
simp only [mem_ofPred_eq]
|
| 90 |
+
linarith only [hlog,ha,hbudget]
|
| 91 |
+
have htail := gaussianProduct_lower_tail_lipschitz (f:=fun g=>log (gaussianSpinPartition n r g))
|
| 92 |
+
(gaussianSpinPartition_log_lipschitz hr (hnr.trans hj.le))
|
| 93 |
+
(show (0:ℝ≥0) < ⟨sqrt (n:ℝ),sqrt_nonneg _⟩ from sqrt_pos.mpr hnp)
|
| 94 |
+
(show 0 ≤ δ*(n:ℝ)/2 by positivity)
|
| 95 |
+
have he : -2*(δ*(n:ℝ)/2)^2/(π^2*(sqrt (n:ℝ))^2)= -δ^2*(n:ℝ)/(2*π^2) := by
|
| 96 |
+
rw [sq_sqrt hnp.le]
|
| 97 |
+
field_simp
|
| 98 |
+
change _ ≤ exp (-2*(δ*(n:ℝ)/2)^2/(π^2*(sqrt (n:���))^2)) at htail
|
| 99 |
+
rw [he] at htail
|
| 100 |
+
exact (measureReal_mono hsub (measure_ne_top _ _)).trans htail
|
| 101 |
+
|
| 102 |
+
lemma gaussianSpinPartition_lower_tail_tendsto {j : ℝ} (hj0 : 0 ≤ j) (hj : j < 1)
|
| 103 |
+
{δ : ℝ} (hδ : 0 < δ) :
|
| 104 |
+
Tendsto (fun n : ℕ=>(gaussianCoordinates (Edge n)).real
|
| 105 |
+
{g | gaussianSpinPartition n (j/(n:ℝ)) g/
|
| 106 |
+
(∫ g,gaussianSpinPartition n (j/(n:ℝ)) g ∂gaussianCoordinates (Edge n)) < exp (-δ*(n:ℝ))}) atTop (𝓝 0) := by
|
| 107 |
+
obtain ⟨c,hc,hpc⟩ := exists_gaussian_tail_quantile
|
| 108 |
+
(show 0 < 1/(4*quadraticGaussianBound j) by
|
| 109 |
+
have hB := quadraticGaussianBound_ge_one hj0 hj; positivity)
|
| 110 |
+
have hb : ∀ᶠ n : ℕ in atTop,
|
| 111 |
+
(gaussianCoordinates (Edge n)).real {g | gaussianSpinPartition n (j/(n:ℝ)) g/
|
| 112 |
+
(∫ g,gaussianSpinPartition n (j/(n:ℝ)) g ∂gaussianCoordinates (Edge n)) < exp (-δ*(n:ℝ))} ≤
|
| 113 |
+
exp (-δ^2*(n:ℝ)/(2*π^2)) := by
|
| 114 |
+
filter_upwards [eventually_gt_atTop 0,eventually_sqrt_cost_le_linear hδ hc.le] with n hn hbudget
|
| 115 |
+
have hnp : (0:ℝ) < n := by exact_mod_cast hn
|
| 116 |
+
apply gaussianSpinPartition_lower_tail_bound hj0 hj hc hpc hδ hn (div_nonneg hj0 hnp.le) _ hbudget
|
| 117 |
+
rw [mul_div_cancel₀ _ hnp.ne']
|
| 118 |
+
have ht : Tendsto (fun n : ℕ=>exp (-δ^2*(n:ℝ)/(2*π^2))) atTop (𝓝 0) := by
|
| 119 |
+
have hpos : 0 < δ^2/(2*π^2) := by positivity
|
| 120 |
+
have hh : Tendsto (fun n : ℕ=>(δ^2/(2*π^2))*(n:ℝ)) atTop atTop :=
|
| 121 |
+
tendsto_natCast_atTop_atTop.const_mul_atTop hpos
|
| 122 |
+
convert tendsto_exp_neg_atTop_nhds_zero.comp hh using 1; ext n; congr 1; ring
|
| 123 |
+
exact squeeze_zero' (Eventually.of_forall (fun _=>measureReal_nonneg)) hb ht
|
| 124 |
+
end SKGap
|
| 125 |
+
end
|
| 126 |
+
end
|
| 127 |
+
|
| 128 |
+
section
|
| 129 |
+
noncomputable section
|
| 130 |
+
namespace SKGap
|
| 131 |
+
open MeasureTheory ProbabilityTheory Real Filter Set
|
| 132 |
+
open scoped BigOperators NNReal Topology
|
| 133 |
+
|
| 134 |
+
lemma gaussian_disorder_hasLaw (β : ℝ) (n : ℕ) :
|
| 135 |
+
HasLaw (fun g : Disorder n=>fun e=>sqrt (β^2/(n:ℝ))*g e) (disorderLaw β n)
|
| 136 |
+
(gaussianCoordinates (Edge n)) := by
|
| 137 |
+
have hr : 0 ≤ β^2/(n:ℝ) := by positivity
|
| 138 |
+
have hl (e : Edge n) : HasLaw (fun g : Disorder n=>sqrt (β^2/(n:ℝ))*g e)
|
| 139 |
+
(gaussianReal 0 (Real.toNNReal (β^2/(n:ℝ)))) (gaussianCoordinates (Edge n)) := by
|
| 140 |
+
have h := gaussianReal_const_mul (coordinate_hasLaw (κ:=Edge n) e) (sqrt (β^2/(n:ℝ)))
|
| 141 |
+
have hv : (⟨(sqrt (β^2/(n:ℝ)))^2,sq_nonneg _⟩:ℝ≥0)*1=Real.toNNReal (β^2/(n:ℝ)) := by
|
| 142 |
+
apply NNReal.eq
|
| 143 |
+
change (sqrt (β^2/(n:ℝ)))^2*1=↑(Real.toNNReal (β^2/(n:ℝ)))
|
| 144 |
+
rw [mul_one,sq_sqrt hr,Real.coe_toNNReal _ hr]
|
| 145 |
+
rw [mul_zero] at h
|
| 146 |
+
convert h using 1
|
| 147 |
+
exact congrArg (gaussianReal 0) hv.symm
|
| 148 |
+
exact iIndepFun.hasLaw_pi hl ((iIndepFun_pi (fun _ : Edge n=>aemeasurable_id)).comp
|
| 149 |
+
(fun _=>fun x : ℝ=>sqrt (β^2/(n:ℝ))*x) (fun _=>by fun_prop))
|
| 150 |
+
|
| 151 |
+
lemma partition_zero_measurable (n : ℕ) : Measurable (fun g : Disorder n=>partition g 0) := by
|
| 152 |
+
have he : (fun g : Disorder n=>partition g 0)=gaussianSpinPartition n 1 := by
|
| 153 |
+
ext g
|
| 154 |
+
rw [gaussianSpinPartition_eq_partition]
|
| 155 |
+
simp only [sqrt_one,one_mul]
|
| 156 |
+
rw [he]
|
| 157 |
+
exact gaussianSpinPartition_measurable n 1
|
| 158 |
+
|
| 159 |
+
lemma disorder_partition_mean (β : ℝ) (n : ℕ) :
|
| 160 |
+
(∫ g,partition g 0 ∂disorderLaw β n)=
|
| 161 |
+
∫ g,gaussianSpinPartition n (β^2/(n:ℝ)) g ∂gaussianCoordinates (Edge n) := by
|
| 162 |
+
have h := (gaussian_disorder_hasLaw β n).integral_comp (partition_zero_measurable n).aestronglyMeasurable
|
| 163 |
+
simpa only [Function.comp_def,gaussianSpinPartition_eq_partition] using h.symm
|
| 164 |
+
|
| 165 |
+
theorem disorder_partition_lower_tail {β : ℝ} (hβ : 0 < β) (hβ1 : β < 1)
|
| 166 |
+
{δ : ℝ} (hδ : 0 < δ) :
|
| 167 |
+
Tendsto (fun n : ℕ=>(disorderLaw β n).real
|
| 168 |
+
{g | partition g 0/(∫ g,partition g 0 ∂disorderLaw β n) < exp (-δ*(n:ℝ))}) atTop (𝓝 0) := by
|
| 169 |
+
have ht := gaussianSpinPartition_lower_tail_tendsto (sq_nonneg β) (show β^2 < 1 by nlinarith) hδ
|
| 170 |
+
apply ht.congr
|
| 171 |
+
intro n
|
| 172 |
+
rw [← (gaussian_disorder_hasLaw β n).measureReal_eq
|
| 173 |
+
(measurableSet_lt ((partition_zero_measurable n).div_const _) measurable_const)]
|
| 174 |
+
simp only [disorder_partition_mean,gaussianSpinPartition_eq_partition]
|
| 175 |
+
end SKGap
|
| 176 |
+
end
|
| 177 |
+
end
|
| 178 |
+
|
| 179 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianTiltIdentity.lean
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.ProductGaussianDensity
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open MeasureTheory ProbabilityTheory Real
|
| 11 |
+
open scoped BigOperators ENNReal
|
| 12 |
+
|
| 13 |
+
lemma gaussianPDFReal_standard_tilt (a x : ℝ) :
|
| 14 |
+
gaussianPDFReal a 1 x=gaussianPDFReal 0 1 x*exp (a*x-a^2/2) := by
|
| 15 |
+
simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]
|
| 16 |
+
have he : -(x-a)^2/2= -x^2/2+(a*x-a^2/2) := by ring
|
| 17 |
+
rw [he,exp_add]
|
| 18 |
+
ring
|
| 19 |
+
|
| 20 |
+
lemma gaussianCoordinates_tilt {κ : Type*} [Fintype κ] (a : κ→ℝ) :
|
| 21 |
+
(gaussianCoordinates κ).withDensity
|
| 22 |
+
(fun g=>ENNReal.ofReal (exp ((∑ i,a i*g i)-(∑ i,a i^2)/2))) =
|
| 23 |
+
Measure.pi (fun i=>gaussianReal (a i) 1) := by
|
| 24 |
+
have hp (g : κ→ℝ) : (∏ i,gaussianPDFReal (a i) 1 (g i))=
|
| 25 |
+
(∏ i,gaussianPDFReal 0 1 (g i))*exp ((∑ i,a i*g i)-(∑ i,a i^2)/2) := by
|
| 26 |
+
calc
|
| 27 |
+
_ = ∏ i, (gaussianPDFReal 0 1 (g i)*exp (a i*g i-a i^2/2)) :=
|
| 28 |
+
Finset.prod_congr rfl (fun i _=>gaussianPDFReal_standard_tilt _ _)
|
| 29 |
+
_ = _ := by
|
| 30 |
+
rw [Finset.prod_mul_distrib,← exp_sum]
|
| 31 |
+
congr 2
|
| 32 |
+
rw [Finset.sum_sub_distrib,Finset.sum_div]
|
| 33 |
+
change (Measure.pi (fun _ : κ=>gaussianReal 0 1)).withDensity _=_
|
| 34 |
+
rw [GaussianDensity.pi_gaussian_density (fun _ : κ=>0) (fun _=>1) (fun _=>one_ne_zero),
|
| 35 |
+
GaussianDensity.pi_gaussian_density a (fun _=>1) (fun _=>one_ne_zero)]
|
| 36 |
+
rw [← withDensity_mul _ (GaussianDensity.measurable_productPDF _ _) (by fun_prop)]
|
| 37 |
+
congr 1
|
| 38 |
+
ext g
|
| 39 |
+
simp only [Pi.mul_apply,hp]
|
| 40 |
+
exact (ENNReal.ofReal_mul (Finset.prod_nonneg (fun i _=>gaussianPDFReal_nonneg 0 1 (g i)))).symm
|
| 41 |
+
|
| 42 |
+
lemma gaussianCoordinates_shift_hasLaw {κ : Type*} [Fintype κ] (a : κ→ℝ) :
|
| 43 |
+
HasLaw (fun g : κ→ℝ => fun i=>g i+a i)
|
| 44 |
+
(Measure.pi (fun i=>gaussianReal (a i) 1)) (gaussianCoordinates κ) := by
|
| 45 |
+
have hl (i : κ) : HasLaw (fun g : κ→ℝ=>g i+a i)
|
| 46 |
+
(gaussianReal (a i) 1) (gaussianCoordinates κ) := by
|
| 47 |
+
simpa only [zero_add] using gaussianReal_add_const (coordinate_hasLaw i) (a i)
|
| 48 |
+
exact iIndepFun.hasLaw_pi hl ((iIndepFun_pi (fun _ : κ=>aemeasurable_id)).comp
|
| 49 |
+
(fun i=>fun x : ℝ=>x+a i) (fun _=>by fun_prop))
|
| 50 |
+
|
| 51 |
+
lemma gaussian_tilt_lintegral {κ : Type*} [Fintype κ] (a : κ→ℝ)
|
| 52 |
+
(f : (κ→ℝ)→ℝ≥0∞) (hf : Measurable f) :
|
| 53 |
+
(∫⁻ g,ENNReal.ofReal (exp ((∑ i,a i*g i)-(∑ i,a i^2)/2))*f g ∂gaussianCoordinates κ)=
|
| 54 |
+
∫⁻ g,f (fun i=>g i+a i) ∂gaussianCoordinates κ := by
|
| 55 |
+
have he := lintegral_withDensity_eq_lintegral_mul (gaussianCoordinates κ)
|
| 56 |
+
(f:=fun g=>ENNReal.ofReal (exp ((∑ i,a i*g i)-(∑ i,a i^2)/2))) (by fun_prop) hf
|
| 57 |
+
simp only [Pi.mul_apply] at he
|
| 58 |
+
rw [← he,gaussianCoordinates_tilt]
|
| 59 |
+
exact (gaussianCoordinates_shift_hasLaw a).lintegral_comp hf.aemeasurable |>.symm
|
| 60 |
+
end SKGap
|
| 61 |
+
end
|
| 62 |
+
end
|
| 63 |
+
|
| 64 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianTiltMass.lean
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.EmpiricalLaw
|
| 3 |
+
import OAI.Probability.SKGap.Matrix.NormalLogConst
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory ProbabilityTheory InformationTheory Real Set Filter
|
| 10 |
+
open scoped NNReal ENNReal Topology
|
| 11 |
+
noncomputable section
|
| 12 |
+
open Real Set
|
| 13 |
+
noncomputable section
|
| 14 |
+
open MeasureTheory ProbabilityTheory Real Set Filter
|
| 15 |
+
open scoped Topology NNReal ENNReal BoundedContinuousFunction
|
| 16 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 17 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 18 |
+
noncomputable section
|
| 19 |
+
open Set Filter Topology
|
| 20 |
+
noncomputable section
|
| 21 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 22 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 23 |
+
noncomputable section
|
| 24 |
+
open MeasureTheory ProbabilityTheory Filter Set Topology Real
|
| 25 |
+
open scoped NNReal ENNReal BoundedContinuousFunction
|
| 26 |
+
namespace SKGap
|
| 27 |
+
|
| 28 |
+
variable {ι : Type*} [Fintype ι] [Nonempty ι]
|
| 29 |
+
|
| 30 |
+
end SKGap
|
| 31 |
+
|
| 32 |
+
namespace SKGap
|
| 33 |
+
variable {ι : Type*} [Fintype ι] [Nonempty ι]
|
| 34 |
+
|
| 35 |
+
omit [Nonempty ι] in
|
| 36 |
+
lemma gaussian_tilt_mass (f : ℝ →ᵇ ℝ) (d : ℝ) {s : ℝ} (hs : 0 < s) (r : ℝ) :
|
| 37 |
+
(∫ y : ι → ℝ, exp ((Fintype.card ι : ℝ)*r -
|
| 38 |
+
(Fintype.card ι : ℝ)*log (∫ x, exp (f x) ∂gaussianReal d s.toNNReal)) *
|
| 39 |
+
(exp (∑ i, f (y i))*productNormal d s y)) = exp ((Fintype.card ι : ℝ)*r) := by
|
| 40 |
+
rw [integral_const_mul, product_tiltedNormal_integral f d hs, ← exp_add]
|
| 41 |
+
congr 1
|
| 42 |
+
ring
|
| 43 |
+
|
| 44 |
+
theorem gaussian_covered_laplace {X : Type*} (C : Finset X) (f : X → ℝ →ᵇ ℝ)
|
| 45 |
+
(d₀ s₀ : X → ℝ) (hs₀ : ∀ x ∈ C, 0 < s₀ x)
|
| 46 |
+
(d s ψ : (ι → ℝ) → ℝ) (R r : ℝ) {E : Set (ι → ℝ)} (hE : MeasurableSet E)
|
| 47 |
+
(hpos : ∀ y ∈ E, 0 < s y)
|
| 48 |
+
(hmom : ∀ y ∈ E, ∑ i, (y i)^2 ≤ (Fintype.card ι : ℝ)*R)
|
| 49 |
+
(hcover : ∀ y ∈ E, ∃ x ∈ C,
|
| 50 |
+
ψ y-(∫ u, f x u ∂empiricalLaw y)+normalDensityError R (d y) (s y) (d₀ x) (s₀ x)+
|
| 51 |
+
log (∫ u, exp (f x u) ∂gaussianReal (d₀ x) (s₀ x).toNNReal) < r) :
|
| 52 |
+
(∫⁻ y in E, ENNReal.ofReal (exp ((Fintype.card ι : ℝ)*ψ y)*productNormal (d y) (s y) y)) ≤
|
| 53 |
+
ENNReal.ofReal ((C.card : ℝ)*exp ((Fintype.card ι : ℝ)*r)) := by
|
| 54 |
+
classical
|
| 55 |
+
let F (x : X) (y : ι → ℝ) : ℝ :=
|
| 56 |
+
exp ((Fintype.card ι : ℝ)*r-(Fintype.card ι : ℝ)*
|
| 57 |
+
log (∫ u, exp (f x u) ∂gaussianReal (d₀ x) (s₀ x).toNNReal)) *
|
| 58 |
+
(exp (∑ i, f x (y i))*productNormal (d₀ x) (s₀ x) y)
|
| 59 |
+
have hFi (x : X) : Integrable (F x) :=
|
| 60 |
+
(product_tiltedNormal_integrable (f x) (d₀ x) (s₀ x)).const_mul _
|
| 61 |
+
have hFnn (x : X) (y : ι → ℝ) : 0 ≤ F x y :=
|
| 62 |
+
mul_nonneg (exp_pos _).le (mul_nonneg (exp_pos _).le (productNormal_nonneg _ _ _))
|
| 63 |
+
have hnorm (x : X) (hx : x ∈ C) : ∫ y, F x y = exp ((Fintype.card ι : ℝ)*r) :=
|
| 64 |
+
gaussian_tilt_mass (f x) (d₀ x) (hs₀ x hx) r
|
| 65 |
+
have hdom (y : ι → ℝ) (hy : y ∈ E) :
|
| 66 |
+
exp ((Fintype.card ι : ℝ)*ψ y)*productNormal (d y) (s y) y ≤ ∑ x ∈ C, F x y := by
|
| 67 |
+
obtain ⟨x,hx,hc⟩ := hcover y hy
|
| 68 |
+
have hdens := normalLogDensity_sum_sub_le (hmom y hy) (d y) (s y) (d₀ x) (s₀ x)
|
| 69 |
+
change _ ≤ (Fintype.card ι : ℝ)*normalDensityError R (d y) (s y) (d₀ x) (s₀ x) at hdens
|
| 70 |
+
have hn : (0 : ℝ) < Fintype.card ι := by exact_mod_cast (Fintype.card_pos (α := ι))
|
| 71 |
+
have hc' := mul_lt_mul_of_pos_left hc hn
|
| 72 |
+
have hemp := card_mul_integral_empiricalLaw y (f x)
|
| 73 |
+
have hsmall : exp ((Fintype.card ι : ℝ)*ψ y)*productNormal (d y) (s y) y ≤ F x y := by
|
| 74 |
+
dsimp only [F]
|
| 75 |
+
rw [productNormal_eq_exp _ (hpos y hy), productNormal_eq_exp _ (hs₀ x hx),
|
| 76 |
+
← exp_add, ← exp_add, ← exp_add]
|
| 77 |
+
apply exp_le_exp.mpr
|
| 78 |
+
nlinarith
|
| 79 |
+
exact hsmall.trans (Finset.single_le_sum (fun a _ => hFnn a y) hx)
|
| 80 |
+
have hsumI : Integrable (fun y => ∑ x ∈ C, F x y) := integrable_finsetSum C (fun x _ => hFi x)
|
| 81 |
+
calc
|
| 82 |
+
_ ≤ ∫⁻ y in E, ENNReal.ofReal (∑ x ∈ C, F x y) := lintegral_mono_ae
|
| 83 |
+
((ae_restrict_mem hE).mono (fun y hy => ENNReal.ofReal_le_ofReal (hdom y hy)))
|
| 84 |
+
_ ≤ ∫⁻ y, ENNReal.ofReal (∑ x ∈ C, F x y) := lintegral_mono' Measure.restrict_le_self (fun _ => le_rfl)
|
| 85 |
+
_ = ENNReal.ofReal (∫ y, ∑ x ∈ C, F x y) :=
|
| 86 |
+
(ofReal_integral_eq_lintegral_ofReal hsumI (ae_of_all _ (fun y => Finset.sum_nonneg (fun x _ => hFnn x y)))).symm
|
| 87 |
+
_ = _ := by
|
| 88 |
+
rw [integral_finsetSum C (fun x _ => hFi x)]
|
| 89 |
+
simp_rw [Finset.sum_congr rfl hnorm]
|
| 90 |
+
simp
|
| 91 |
+
|
| 92 |
+
end SKGap
|
| 93 |
+
|
| 94 |
+
namespace SKGap
|
| 95 |
+
|
| 96 |
+
theorem gaussian_compact_laplace {X : Type*} [TopologicalSpace X] {K : Set X}
|
| 97 |
+
(hK : IsCompact K) {P : X → ProbabilityMeasure ℝ} {d s ψ : X → ℝ}
|
| 98 |
+
(hP : ContinuousOn P K) (hd : ContinuousOn d K) (hs : ContinuousOn s K)
|
| 99 |
+
(hψ : ContinuousOn ψ K) (hpos : ∀ x ∈ K, 0 < s x) (R r : ℝ)
|
| 100 |
+
(hW : ∀ x ∈ K, ∃ f : ℝ →ᵇ ℝ, ψ x-(∫ y, f y ∂P x)+
|
| 101 |
+
log (∫ y, exp (f y) ∂gaussianReal (d x) (s x).toNNReal) < r) :
|
| 102 |
+
∃ M : ℕ, ∀ n : ℕ, ∀ hn : 0 < n, ∀ z : (Fin n → ℝ) → X,
|
| 103 |
+
∀ E : Set (Fin n → ℝ), MeasurableSet E →
|
| 104 |
+
(∀ y ∈ E, z y ∈ K) →
|
| 105 |
+
(∀ y ∈ E, P (z y) = @empiricalLaw (Fin n) _ ⟨⟨0,hn⟩⟩ y) →
|
| 106 |
+
(∀ y ∈ E, ∑ i, (y i)^2 ≤ (n:ℝ)*R) →
|
| 107 |
+
(∫⁻ y in E, ENNReal.ofReal (exp ((n:ℝ)*ψ (z y))*productNormal (d (z y)) (s (z y)) y)) ≤
|
| 108 |
+
ENNReal.ofReal ((M:ℝ)*exp ((n:ℝ)*r)) := by
|
| 109 |
+
classical
|
| 110 |
+
obtain ⟨C,f,hC⟩ := finite_gaussian_test_cover hK hP hd hs hψ hpos R r hW
|
| 111 |
+
refine ⟨C.card, ?_⟩
|
| 112 |
+
intro n hn z E hE hz hemp hmom
|
| 113 |
+
let : Nonempty (Fin n) := ⟨⟨0,hn⟩⟩
|
| 114 |
+
have hh := gaussian_covered_laplace C f (fun x : K => d x) (fun x : K => s x)
|
| 115 |
+
(fun x _ => hpos x x.2) (fun y => d (z y)) (fun y => s (z y))
|
| 116 |
+
(fun y => ψ (z y)) R r hE (fun y hy => hpos (z y) (hz y hy))
|
| 117 |
+
(by simpa only [Fintype.card_fin] using hmom) (fun y hy => by
|
| 118 |
+
obtain ⟨x,hx,hcx⟩ := hC (z y) (hz y hy)
|
| 119 |
+
rw [hemp y hy] at hcx
|
| 120 |
+
exact ⟨x,hx,hcx⟩)
|
| 121 |
+
simpa only [Fintype.card_fin] using hh
|
| 122 |
+
|
| 123 |
+
lemma absorb_finite_exponential_factor (M : ℕ) {ε : ℝ} (hε : 0 < ε) :
|
| 124 |
+
∃ N : ℕ, ∀ n ≥ N, ∀ r : ℝ,
|
| 125 |
+
(M:ℝ)*exp ((n:ℝ)*r) ≤ exp ((n:ℝ)*(r+ε)) := by
|
| 126 |
+
obtain ⟨N,hN⟩ := exists_nat_gt (log ((M:ℝ)+1)/ε)
|
| 127 |
+
refine ⟨N,?_⟩
|
| 128 |
+
intro n hn r
|
| 129 |
+
have hcast : (N:ℝ) ≤ n := by exact_mod_cast hn
|
| 130 |
+
have hnlog : log ((M:ℝ)+1) ≤ (n:ℝ)*ε := by
|
| 131 |
+
have h := (div_lt_iff₀ hε).mp hN
|
| 132 |
+
nlinarith
|
| 133 |
+
have he : (M:ℝ) ≤ exp ((n:ℝ)*ε) := by
|
| 134 |
+
have h := exp_le_exp.mpr hnlog
|
| 135 |
+
rw [exp_log (by positivity)] at h
|
| 136 |
+
linarith
|
| 137 |
+
calc
|
| 138 |
+
_ ≤ exp ((n:ℝ)*ε)*exp ((n:ℝ)*r) := mul_le_mul_of_nonneg_right he (exp_pos _).le
|
| 139 |
+
_ = _ := by rw [← exp_add]; congr 1; ring
|
| 140 |
+
|
| 141 |
+
theorem gaussian_compact_rate {X : Type*} [TopologicalSpace X] {K : Set X}
|
| 142 |
+
(hK : IsCompact K) {P : X → ProbabilityMeasure ℝ} {d s ψ : X → ℝ}
|
| 143 |
+
(hP : ContinuousOn P K) (hd : ContinuousOn d K) (hs : ContinuousOn s K)
|
| 144 |
+
(hψ : ContinuousOn ψ K) (hpos : ∀ x ∈ K, 0 < s x) (R r : ℝ)
|
| 145 |
+
(hW : ∀ x ∈ K, ∃ f : ℝ →ᵇ ℝ, ψ x-(∫ y, f y ∂P x)+
|
| 146 |
+
log (∫ y, exp (f y) ∂gaussianReal (d x) (s x).toNNReal) < r)
|
| 147 |
+
{ε : ℝ} (hε : 0 < ε) :
|
| 148 |
+
∃ N : ℕ, ∀ n ≥ N, ∀ hn : 0 < n, ∀ z : (Fin n → ℝ) → X,
|
| 149 |
+
∀ E : Set (Fin n → ℝ), MeasurableSet E →
|
| 150 |
+
(∀ y ∈ E, z y ∈ K) →
|
| 151 |
+
(∀ y ∈ E, P (z y) = @empiricalLaw (Fin n) _ ⟨⟨0,hn⟩⟩ y) →
|
| 152 |
+
(∀ y ∈ E, ∑ i, (y i)^2 ≤ (n:ℝ)*R) →
|
| 153 |
+
(∫⁻ y in E, ENNReal.ofReal (exp ((n:ℝ)*ψ (z y))*productNormal (d (z y)) (s (z y)) y)) ≤
|
| 154 |
+
ENNReal.ofReal (exp ((n:ℝ)*(r+ε))) := by
|
| 155 |
+
obtain ⟨M,hM⟩ := gaussian_compact_laplace hK hP hd hs hψ hpos R r hW
|
| 156 |
+
obtain ⟨N,hN⟩ := absorb_finite_exponential_factor M hε
|
| 157 |
+
refine ⟨N,?_⟩
|
| 158 |
+
intro n hn hn' z E hE hz hemp hmom
|
| 159 |
+
exact (hM n hn' z E hE hz hemp hmom).trans (ENNReal.ofReal_le_ofReal (hN n hn r))
|
| 160 |
+
|
| 161 |
+
end SKGap
|
| 162 |
+
|
| 163 |
+
end
|
| 164 |
+
end
|
| 165 |
+
end
|
| 166 |
+
end
|
| 167 |
+
end
|
| 168 |
+
end
|
| 169 |
+
end
|
| 170 |
+
|
| 171 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/GaussianVectorMoments.lean
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianQuadratic
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.GaussianRegression
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 11 |
+
open scoped BigOperators ENNReal NNReal
|
| 12 |
+
|
| 13 |
+
lemma gaussian_integral_fourth_variance (v : ℝ≥0) :
|
| 14 |
+
(∫ x : ℝ,x^4 ∂gaussianReal 0 v)=3*(v:ℝ)^2 := by
|
| 15 |
+
have hm : (gaussianReal 0 1).map (fun x : ℝ => sqrt (v:ℝ)*x)=gaussianReal 0 v := by
|
| 16 |
+
rw [gaussianReal_map_const_mul]
|
| 17 |
+
congr 1
|
| 18 |
+
· simp
|
| 19 |
+
· ext; simp [Real.sq_sqrt v.coe_nonneg]
|
| 20 |
+
rw [← hm,integral_map (by fun_prop) (by fun_prop)]
|
| 21 |
+
simp only [mul_pow,integral_const_mul,gaussian_integral_fourth]
|
| 22 |
+
rw [show sqrt (v:ℝ)^4=(v:ℝ)^2 by rw [show 4=2*2 by norm_num,pow_mul,Real.sq_sqrt v.coe_nonneg]]
|
| 23 |
+
ring
|
| 24 |
+
|
| 25 |
+
lemma gaussian_fourth_integrable (v : ℝ≥0) :
|
| 26 |
+
Integrable (fun x : ℝ => x^4) (gaussianReal 0 v) := by
|
| 27 |
+
apply (integrable_norm_iff (by fun_prop)).mp
|
| 28 |
+
simpa only [id_eq,norm_pow] using
|
| 29 |
+
(IsGaussian.memLp_id (gaussianReal 0 v) (4:ℝ≥0∞) (by norm_num)).integrable_norm_pow'
|
| 30 |
+
|
| 31 |
+
lemma linear_gaussian_fourth {κ : Type*} [Fintype κ] [DecidableEq κ] (a : κ → ℝ) :
|
| 32 |
+
(∫ g,(∑ i,a i*g i)^4 ∂gaussianCoordinates κ)=3*(∑ i,a i^2)^2 := by
|
| 33 |
+
let A : Matrix Unit κ ℝ := fun _ => a
|
| 34 |
+
have hg := (matrix_sample_gaussian A).eval ()
|
| 35 |
+
change HasGaussianLaw (fun g : κ → ℝ => ∑ i,a i*g i) (gaussianCoordinates κ) at hg
|
| 36 |
+
have hl : HasLaw _ _ _ := ⟨hg.aemeasurable,hg.map_eq_gaussianReal⟩
|
| 37 |
+
have hm := linear_gaussian_mean a
|
| 38 |
+
have hv : Var[fun g => ∑ i,a i*g i;gaussianCoordinates κ]=∑ i,a i^2 := by
|
| 39 |
+
rw [← covariance_self hg.aemeasurable]
|
| 40 |
+
simpa only [sq] using linear_gaussian_covariance a a
|
| 41 |
+
change HasLaw (fun g : κ → ℝ => ∑ i,a i*g i) _ _ at hl
|
| 42 |
+
rw [hm,hv] at hl
|
| 43 |
+
have he := hl.integral_comp (f := fun x : ℝ => x^4) (by fun_prop)
|
| 44 |
+
simp only [Function.comp_def] at he
|
| 45 |
+
rw [he,gaussian_integral_fourth_variance]
|
| 46 |
+
rw [Real.coe_toNNReal _ (Finset.sum_nonneg (fun i _ => sq_nonneg (a i)))]
|
| 47 |
+
|
| 48 |
+
lemma linear_gaussian_fourth_integrable {κ : Type*} [Fintype κ] (a : κ → ℝ) :
|
| 49 |
+
Integrable (fun g => (∑ i,a i*g i)^4) (gaussianCoordinates κ) := by
|
| 50 |
+
let A : Matrix Unit κ ℝ := fun _ => a
|
| 51 |
+
have hg := (matrix_sample_gaussian A).eval ()
|
| 52 |
+
change HasGaussianLaw (fun g : κ → ℝ => ∑ i,a i*g i) (gaussianCoordinates κ) at hg
|
| 53 |
+
have hl : HasLaw _ _ _ := ⟨hg.aemeasurable,hg.map_eq_gaussianReal⟩
|
| 54 |
+
rw [linear_gaussian_mean a] at hl
|
| 55 |
+
have hi := gaussian_fourth_integrable (Var[fun g : κ → ℝ => ∑ i,a i*g i;gaussianCoordinates κ].toNNReal)
|
| 56 |
+
rw [← hl.map_eq] at hi
|
| 57 |
+
exact (integrable_map_measure (by fun_prop) hl.aemeasurable).mp hi
|
| 58 |
+
|
| 59 |
+
end SKGap
|
| 60 |
+
end
|
| 61 |
+
end
|
| 62 |
+
|
| 63 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/IndependentBoundedAverageTailLaw.lean
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Entropy.ProdFst
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open MeasureTheory ProbabilityTheory
|
| 14 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 15 |
+
open scoped BigOperators NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory
|
| 17 |
+
open scoped BigOperators NNReal ENNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
open MeasureTheory ProbabilityTheory
|
| 21 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 22 |
+
open scoped BigOperators
|
| 23 |
+
open MeasureTheory ProbabilityTheory
|
| 24 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 25 |
+
open scoped BigOperators
|
| 26 |
+
open scoped BigOperators NNReal ENNReal
|
| 27 |
+
open MeasureTheory Metric Set
|
| 28 |
+
open scoped BigOperators NNReal ENNReal
|
| 29 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 30 |
+
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
|
| 31 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 32 |
+
open scoped BigOperators Matrix.Norms.L2Operator
|
| 33 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 34 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 35 |
+
open MeasureTheory ProbabilityTheory Filter Set
|
| 36 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 37 |
+
open scoped BigOperators ENNReal NNReal
|
| 38 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 39 |
+
open scoped BigOperators NNReal ENNReal Matrix
|
| 40 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 41 |
+
open scoped BigOperators ENNReal NNReal
|
| 42 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 43 |
+
open scoped BigOperators NNReal ENNReal
|
| 44 |
+
open scoped BigOperators
|
| 45 |
+
open MeasureTheory ProbabilityTheory
|
| 46 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
|
| 47 |
+
open scoped BigOperators
|
| 48 |
+
open Filter Topology
|
| 49 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 50 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 51 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 52 |
+
open Matrix
|
| 53 |
+
open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise
|
| 54 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 55 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 56 |
+
open MeasureTheory ProbabilityTheory Filter Matrix
|
| 57 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 58 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 59 |
+
open scoped BigOperators NNReal ENNReal Topology
|
| 60 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 61 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 62 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 63 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 64 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 65 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 66 |
+
namespace SKGapCutoff.Regression
|
| 67 |
+
lemma independent_bounded_average_tail_law {Ω : Type*} [MeasurableSpace Ω]
|
| 68 |
+
{μ : Measure Ω} [IsProbabilityMeasure μ]
|
| 69 |
+
{F : Type*} [MeasurableSpace F] (τ : Measure F) {n : ℕ} (hn : 0 < n)
|
| 70 |
+
(X : Fin n → Ω → F) (hXi : iIndepFun X μ)
|
| 71 |
+
(hX : ∀ i, HasLaw (X i) τ μ) (f : Fin n → F → ℝ)
|
| 72 |
+
(hf : ∀ i, Measurable (f i)) (B : ℝ) (hB : 0 ≤ B)
|
| 73 |
+
(hbound : ∀ i z, |f i z| ≤ B) (ε : ℝ) (hε : 0 ≤ ε) :
|
| 74 |
+
μ {g | ε ≤ |((∑ i, f i (X i g)) - ∑ i, ∫ z, f i z ∂τ)/(n:ℝ)|} ≤
|
| 75 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(2*B^2))) := by
|
| 76 |
+
let m (i : Fin n) := ∫ z, f i z ∂τ
|
| 77 |
+
have hi : iIndepFun (fun i (g : Ω) => f i (X i g)-m i) μ :=
|
| 78 |
+
hXi.comp (fun i z => f i z-m i) (fun i => (hf i).sub_const (m i))
|
| 79 |
+
have hm (i : Fin n) : (∫ g : Ω, f i (X i g) ∂μ) = m i :=
|
| 80 |
+
(hX i).integral_comp (hf i).aestronglyMeasurable
|
| 81 |
+
have hsub (i : Fin n) : HasSubgaussianMGF (fun g : Ω => f i (X i g)-m i)
|
| 82 |
+
((‖B-(-B)‖₊/2)^2) μ := by
|
| 83 |
+
have hb : ∀ᵐ g : Ω ∂μ, f i (X i g) ∈ Set.Icc (-B) B :=
|
| 84 |
+
Filter.Eventually.of_forall (fun g => abs_le.mp (hbound i (X i g)))
|
| 85 |
+
simpa only [hm] using hasSubgaussianMGF_of_mem_Icc
|
| 86 |
+
(show AEMeasurable (fun g : Ω => f i (X i g)) μ from
|
| 87 |
+
(hf i).comp_aemeasurable (hX i).aemeasurable) hb
|
| 88 |
+
have hh := subgaussian_abs_tail
|
| 89 |
+
(HasSubgaussianMGF.sum_of_iIndepFun hi (s := Finset.univ) (fun i _ => hsub i))
|
| 90 |
+
(ε*n) (by positivity)
|
| 91 |
+
have he (g : Ω) :
|
| 92 |
+
(ε*(n:ℝ) ≤ |∑ i, (f i (X i g)-m i)|) ↔
|
| 93 |
+
ε ≤ |((∑ i, f i (X i g)) - ∑ i, m i)/(n:ℝ)| := by
|
| 94 |
+
rw [Finset.sum_sub_distrib, abs_div, abs_of_pos (show (0:ℝ) < n from Nat.cast_pos.mpr hn)]
|
| 95 |
+
exact (le_div_iff₀ (Nat.cast_pos.mpr hn)).symm
|
| 96 |
+
simp only [he] at hh
|
| 97 |
+
convert hh using 1
|
| 98 |
+
congr 3
|
| 99 |
+
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul,
|
| 100 |
+
NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_pow, NNReal.coe_div, NNReal.coe_ofNat,
|
| 101 |
+
coe_nnnorm, Real.norm_eq_abs]
|
| 102 |
+
rw [abs_of_nonneg (by linarith : 0 ≤ B-(-B))]
|
| 103 |
+
have hn0 : (n:ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hn)
|
| 104 |
+
by_cases hB0 : B=0
|
| 105 |
+
· simp [hB0]
|
| 106 |
+
· field_simp
|
| 107 |
+
ring
|
| 108 |
+
|
| 109 |
+
lemma probability_average_lipschitz
|
| 110 |
+
{E F : Type*} [PseudoMetricSpace E] [PseudoMetricSpace F]
|
| 111 |
+
[MeasurableSpace F] [BorelSpace F]
|
| 112 |
+
(τ : Measure F) [IsProbabilityMeasure τ]
|
| 113 |
+
{f : E × F → ℝ} {K : ℝ≥0} (hf : LipschitzWith K f)
|
| 114 |
+
(B : ℝ) (hB : ∀ z, |f z| ≤ B) :
|
| 115 |
+
LipschitzWith K (fun x => ∫ y, f (x,y) ∂τ) := by
|
| 116 |
+
have hi (x : E) : Integrable (fun y => f (x,y)) τ := by
|
| 117 |
+
apply integrable_bounded_lipschitz τ (K := K) _ B (fun y => hB (x,y))
|
| 118 |
+
apply LipschitzWith.of_dist_le_mul
|
| 119 |
+
intro y z
|
| 120 |
+
simpa only [Prod.dist_eq, dist_self, max_eq_right (dist_nonneg)] using
|
| 121 |
+
hf.dist_le_mul (x,y) (x,z)
|
| 122 |
+
apply LipschitzWith.of_dist_le_mul
|
| 123 |
+
intro x y
|
| 124 |
+
rw [Real.dist_eq, ← integral_sub (hi x) (hi y)]
|
| 125 |
+
have hh := norm_integral_le_of_norm_le_const (μ := τ)
|
| 126 |
+
(C := (K:ℝ)*dist x y) (f := fun z => f (x,z)-f (y,z))
|
| 127 |
+
(Filter.Eventually.of_forall (fun z => by
|
| 128 |
+
simpa only [Real.norm_eq_abs, ← Real.dist_eq, Prod.dist_eq, dist_self,
|
| 129 |
+
max_eq_left (dist_nonneg)] using hf.dist_le_mul (x,z) (y,z)))
|
| 130 |
+
simpa using hh
|
| 131 |
+
|
| 132 |
+
lemma probability_average_bound {E F : Type*} [MeasurableSpace F]
|
| 133 |
+
(τ : Measure F) [IsProbabilityMeasure τ] {f : E × F → ℝ}
|
| 134 |
+
(B : ℝ) (hB : ∀ z, |f z| ≤ B) (x : E) :
|
| 135 |
+
|∫ z, f (x,z) ∂τ| ≤ B := by
|
| 136 |
+
have h := norm_integral_le_of_norm_le_const (μ := τ)
|
| 137 |
+
(C := B) (f := fun z => f (x,z))
|
| 138 |
+
(Filter.Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs] using hB (x,z)))
|
| 139 |
+
simpa using h
|
| 140 |
+
|
| 141 |
+
lemma iid_seed_empirical_tail
|
| 142 |
+
{E F H : Type*} [MeasurableSpace E] [MeasurableSpace F] [MeasurableSpace H]
|
| 143 |
+
(τ : Measure F) [IsProbabilityMeasure τ] (ρ : Measure H) [IsProbabilityMeasure ρ]
|
| 144 |
+
{n : ℕ} (hn : 0 < n) (X : H → Fin n → E) (hX : Measurable X)
|
| 145 |
+
(f : E × F → ℝ) (hf : Measurable f)
|
| 146 |
+
(B : ℝ) (hB : 0 ≤ B) (hbound : ∀ z, |f z| ≤ B) (ε : ℝ) (hε : 0 ≤ ε) :
|
| 147 |
+
(ρ.prod (Measure.pi (fun _ : Fin n => τ))) {z | ε ≤
|
| 148 |
+
|((∑ i, f (X z.1 i,z.2 i)) - ∑ i, ∫ w, f (X z.1 i,w) ∂τ)/(n:ℝ)|} ≤
|
| 149 |
+
2 * ENNReal.ofReal (Real.exp (-(ε^2*(n:ℝ))/(2*B^2))) := by
|
| 150 |
+
have hM : Measurable (fun x => ∫ y, f (x,y) ∂τ) :=
|
| 151 |
+
(show StronglyMeasurable (Function.uncurry (fun x y => f (x,y))) from
|
| 152 |
+
hf.stronglyMeasurable).integral_prod_right.measurable
|
| 153 |
+
apply probability_prod_section_bound
|
| 154 |
+
· apply measurableSet_le measurable_const
|
| 155 |
+
apply Measurable.abs
|
| 156 |
+
apply Measurable.div_const
|
| 157 |
+
apply Measurable.sub
|
| 158 |
+
· apply Finset.measurable_sum
|
| 159 |
+
intro i _
|
| 160 |
+
exact hf.comp ((((measurable_pi_apply i).comp hX).comp measurable_fst).prodMk
|
| 161 |
+
((measurable_pi_apply i).comp measurable_snd))
|
| 162 |
+
· apply Finset.measurable_sum
|
| 163 |
+
intro i _
|
| 164 |
+
exact hM.comp (((measurable_pi_apply i).comp hX).comp measurable_fst)
|
| 165 |
+
· intro h
|
| 166 |
+
exact independent_bounded_average_tail_law τ hn
|
| 167 |
+
(fun i (z : Fin n → F) => z i)
|
| 168 |
+
(iIndepFun_pi (fun _ => measurable_id.aemeasurable))
|
| 169 |
+
(fun i => (measurePreserving_eval (fun _ : Fin n => τ) i).hasLaw)
|
| 170 |
+
(fun i w => f (X h i,w)) (fun i => hf.comp measurable_prodMk_left)
|
| 171 |
+
B hB (fun i w => hbound _) ε hε
|
| 172 |
+
|
| 173 |
+
theorem ExponentialEmpiricalConcentration.iid_seed
|
| 174 |
+
{E F : Type*} [PseudoMetricSpace E] [MeasurableSpace E] [BorelSpace E]
|
| 175 |
+
[SecondCountableTopology E] [PseudoMetricSpace F] [MeasurableSpace F] [BorelSpace F]
|
| 176 |
+
[SecondCountableTopology F]
|
| 177 |
+
{H : ℕ → Type*} [∀ n, MeasurableSpace (H n)]
|
| 178 |
+
(ρ : ∀ n, Measure (H n)) [∀ n, IsProbabilityMeasure (ρ n)]
|
| 179 |
+
(ν : Measure E) [IsProbabilityMeasure ν] (τ : Measure F) [IsProbabilityMeasure τ]
|
| 180 |
+
(X : ∀ n, H n → Fin n → E) (hXm : ∀ n, Measurable (X n))
|
| 181 |
+
(hX : ExponentialEmpiricalConcentration ρ X ν) :
|
| 182 |
+
ExponentialEmpiricalConcentration
|
| 183 |
+
(fun n => (ρ n).prod (Measure.pi (fun _ : Fin n => τ)))
|
| 184 |
+
(fun n z i => (X n z.1 i,z.2 i)) (ν.prod τ) := by
|
| 185 |
+
intro f K hf B hbound ε hε
|
| 186 |
+
let D := |B|+1
|
| 187 |
+
have hD : 0 < D := by dsimp [D]; positivity
|
| 188 |
+
have hb : ∀ z, |f z| ≤ D := fun z => (hbound z).trans (by dsimp [D]; linarith [le_abs_self B])
|
| 189 |
+
let ψ : E → ℝ := fun x => ∫ y, f (x,y) ∂τ
|
| 190 |
+
have hp := probability_average_lipschitz τ hf D hb
|
| 191 |
+
have hpb := probability_average_bound τ D hb
|
| 192 |
+
have hm : ∫ z, f z ∂ν.prod τ = ∫ x, ψ x ∂ν :=
|
| 193 |
+
integral_prod f (integrable_bounded_lipschitz _ hf D hb)
|
| 194 |
+
have hold := ((hX.average ψ hp D hpb) (ε/2) (by positivity)).prod_fst
|
| 195 |
+
(fun n => Measure.pi (fun _ : Fin n => τ))
|
| 196 |
+
have hnew : ExponentiallyRare
|
| 197 |
+
(fun n => (ρ n).prod (Measure.pi (fun _ : Fin n => τ)))
|
| 198 |
+
(fun n => {z | ε/2 ≤ |((∑ i, f (X n z.1 i,z.2 i)) - ∑ i, ψ (X n z.1 i))/(n:ℝ)|}) := by
|
| 199 |
+
refine ⟨2,ε^2/(8*D^2),by norm_num,by positivity,?_⟩
|
| 200 |
+
filter_upwards [eventually_ge_atTop 1] with n hn
|
| 201 |
+
have hh := iid_seed_empirical_tail τ (ρ n) hn (X n) (hXm n) f hf.continuous.measurable
|
| 202 |
+
D hD.le hb (ε/2) (by positivity)
|
| 203 |
+
have he : -((ε/2)^2*(n:ℝ))/(2*D^2) = -(ε^2/(8*D^2))*(n:ℝ) := by
|
| 204 |
+
field_simp
|
| 205 |
+
ring
|
| 206 |
+
simpa only [ψ, he, ENNReal.ofReal_mul (by norm_num : (0:ℝ) ≤ 2), ENNReal.ofReal_ofNat]
|
| 207 |
+
using hh
|
| 208 |
+
apply (hold.union hnew).mono
|
| 209 |
+
refine Filter.Eventually.of_forall ?_
|
| 210 |
+
intro n z hz
|
| 211 |
+
change ε ≤ |(∑ i, f (X n z.1 i,z.2 i))/(n:ℝ)-∫ w, f w ∂ν.prod τ| at hz
|
| 212 |
+
rw [hm] at hz
|
| 213 |
+
by_cases ho : ε/2 ≤ dist ((∑ i, ψ (X n z.1 i))/(n:ℝ)) (∫ x, ψ x ∂ν)
|
| 214 |
+
· exact Or.inl ho
|
| 215 |
+
apply Or.inr
|
| 216 |
+
by_contra hn
|
| 217 |
+
have ho' : |(∑ i, ψ (X n z.1 i))/(n:ℝ) - ∫ x, ψ x ∂ν| < ε/2 := lt_of_not_ge ho
|
| 218 |
+
have hn' : |((∑ i, f (X n z.1 i,z.2 i)) - ∑ i, ψ (X n z.1 i))/(n:ℝ)| < ε/2 :=
|
| 219 |
+
lt_of_not_ge hn
|
| 220 |
+
rw [sub_div] at hn'
|
| 221 |
+
have ht := abs_add_le
|
| 222 |
+
((∑ i, f (X n z.1 i,z.2 i))/(n:ℝ) - (∑ i, ψ (X n z.1 i))/(n:ℝ))
|
| 223 |
+
((∑ i, ψ (X n z.1 i))/(n:ℝ) - ∫ x, ψ x ∂ν)
|
| 224 |
+
rw [sub_add_sub_cancel] at ht
|
| 225 |
+
linarith
|
| 226 |
+
|
| 227 |
+
end SKGapCutoff.Regression
|
| 228 |
+
|
| 229 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 230 |
+
open scoped NNReal ENNReal BigOperators Topology
|
| 231 |
+
|
| 232 |
+
end
|
| 233 |
+
|
| 234 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/LiteralWeakTail.lean
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.LiteralLocalWeak
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 10 |
+
namespace SKGapCutoff.Recipe
|
| 11 |
+
open Primary Static SKGap.Stein SKGap.Noncrossing.Primary SKGap.Noncrossing.Primary.Tensor.Series SKGap.Noncrossing.ClosedMarked
|
| 12 |
+
universe u
|
| 13 |
+
variable {Ω : Type u} {n : Ω→ℕ} {M : ℕ}
|
| 14 |
+
theorem literal_local_weak_terminal_targets (j : ℝ) (J : ∀b,Interaction (n b))
|
| 15 |
+
(h : ∀b,Fin (n b)→ℝ) (l : Fin M) (f : KernelExpr)
|
| 16 |
+
(a c : ∀b,Spin (n b)→ℝ) (r e : ∀b,Fin (n b)→ℝ)
|
| 17 |
+
(w y : ∀b,VectorFields (n b)) (E : ∀b,Set (Spin (n b)))
|
| 18 |
+
(hn : ∀b,0<n b) (he : ∀b,vectorNorm (e b)≤1)
|
| 19 |
+
{K B R Bc Va Vc V S F W C : ℝ}
|
| 20 |
+
(hK : 0≤K) (hB : 0≤B) (hBc : 0≤Bc) (hVa : 0≤Va) (hVc : 0≤Vc)
|
| 21 |
+
(hV : 0≤V) (hS : 0≤S) (hF : 0≤F) (hW : 0≤W) (hC : 0≤C)
|
| 22 |
+
(hop : ∀b,SKGap.opNorm (J b)≤K)
|
| 23 |
+
(hformal : ∀b x,∀q<M,ShapeBound (formalField j (J b) (h b) x q) B)
|
| 24 |
+
(ha : ∀b x,x∈flipNeighborhood (flipNeighborhood (E b))→|a b x|≤R)
|
| 25 |
+
(hc : ∀b x,x∈flipNeighborhood (flipNeighborhood (E b))→|Real.sqrt (n b:ℝ)*c b x|≤Bc)
|
| 26 |
+
(hDa : ∀b x,x∈flipNeighborhood (E b)→‖derivativeVector (a b) x‖≤Va)
|
| 27 |
+
(hDc : ∀b x,x∈flipNeighborhood (E b)→‖derivativeVector (fun v=>Real.sqrt (n b:ℝ)*c b v) x‖≤Vc)
|
| 28 |
+
(heq : ∀b x,x∈E b→LiteralEquations (J b) j f (fld j (J b) (h b) l.val)
|
| 29 |
+
(mag j (J b) (h b) l.val) (w b) (y b) (a b) (c b) (r b) (e b) x)
|
| 30 |
+
(hdiag : ∀b x,x∈flipNeighborhood (E b)→LiteralInitialDiagnostics
|
| 31 |
+
(literalInitial (J b) j (Real.sqrt (n b:ℝ)) f (fld j (J b) (h b) l.val)
|
| 32 |
+
(mag j (J b) (h b) l.val) (a b) (c b) (r b) (e b))
|
| 33 |
+
(w b) (y b) (primaryTree j (J b) (h b) x l.val) x V S F (literalResidualBudget j f R Bc l.val))
|
| 34 |
+
(P : ∀b,Observables (n b)) (hP : ∀b x,0≤P b x) (hp : ∀b,∑x,P b x=1)
|
| 35 |
+
(hm : ∀b x i,conditionalMean (P b) x i=mag j (J b) (h b) 1 x i)
|
| 36 |
+
(hJ : ∀b,(J b).IsSymm)
|
| 37 |
+
(hw : ∀b x,x∈flipNeighborhood (E b)→ClosedWordTestBound j
|
| 38 |
+
(fun i=>phi (fld j (J b) (h b) l.val x i) (r b i) (a b x)) (J b) (literalResidualBudget j f R Bc l.val) W (2*(2+2*l.val)+5))
|
| 39 |
+
(hd : ∀b x,x∈flipNeighborhood (E b)→ClosedWordDiagramBound j
|
| 40 |
+
(fun i=>phi (fld j (J b) (h b) l.val x i) (r b i) (a b x)) (J b) (literalResidualBudget j f R Bc l.val) C (2*M+2*(2+2*l.val)+4)) :
|
| 41 |
+
(∀p≤l.val,LocalUniformWeak E P (fun b x=>∑i,residual j (J b) (h b) p x i*w b x i)) ∧
|
| 42 |
+
LocalUniformWeak E P (fun b x=>∑i,residual j (J b) (h b) l.val x i*y b x i) ∧
|
| 43 |
+
LocalUniformWeak E P (fun b x=>∑i,residual j (J b) (h b) l.val x i*
|
| 44 |
+
(Real.tanh (fld j (J b) (h b) l.val x i)/Real.sqrt (n b:ℝ))) ∧
|
| 45 |
+
LocalUniformMultiplier E (fun b=>siteMean (fun x i=>phi (fld j (J b) (h b) l.val x i) (r b i) (a b x))) ∧
|
| 46 |
+
LocalUniformMultiplier E (fun b x=>j*onsager j (J b) (h b) l.val x) ∧
|
| 47 |
+
LocalUniformMultiplier E (fun b x=>Real.sqrt (n b:ℝ)*c b x) := by
|
| 48 |
+
let Kt:=2+|literalCoefficientBudget f j R Bc|
|
| 49 |
+
have hKt : 2≤Kt := by dsimp [Kt];linarith [abs_nonneg (literalCoefficientBudget f j R Bc)]
|
| 50 |
+
have hKt0 : 0≤Kt:=by linarith
|
| 51 |
+
have hA : 1≤literalResidualBudget j f R Bc l.val :=
|
| 52 |
+
(by linarith : 1≤Kt).trans (residualCoefficientBudget_ge j hKt0 l.val 0)
|
| 53 |
+
have C:=literal_finite_control j J h l f a c r e w y E hn he
|
| 54 |
+
hK hB hBc hVa hVc hA hV hS hF hW hC hop hformal ha hc hDa hDc heq hdiag
|
| 55 |
+
(2+2*l.val) hw hd
|
| 56 |
+
have H:=literal_full_local_family j J h l f a c r e w y E hn he hBc ha hc heq
|
| 57 |
+
have hclass : literalCoefficientBudget f j R Bc≤Kt := by
|
| 58 |
+
dsimp [Kt];linarith [le_abs_self (literalCoefficientBudget f j R Bc)]
|
| 59 |
+
have HH:=H.mono le_rfl le_rfl le_rfl hclass
|
| 60 |
+
have hb:=residualCoefficientBudget_antitone j hKt0 l.val
|
| 61 |
+
have rule:=local_uniform_residual_rule C hP hp hm hn hJ Sum.inl (fun _ _=>rfl)
|
| 62 |
+
(residualCoefficientBudget j Kt l.val) hb l.val l.isLt
|
| 63 |
+
(fun p _=>hb (Nat.zero_le p))
|
| 64 |
+
(fun p _=>hKt.trans (residualCoefficientBudget_ge j hKt0 l.val p))
|
| 65 |
+
(fun p hp=>le_of_eq (residualCoefficientBudget_step j Kt hp))
|
| 66 |
+
let D:=fun b=>literalFullData j (J b) (h b) l f (a b) (c b) (r b) (e b)
|
| 67 |
+
have allw : ∀p≤l.val,LocalUniformWeak E P (fun b x=>∑i,residual j (J b) (h b) p x i*w b x i) := by
|
| 68 |
+
intro p hp
|
| 69 |
+
have H':=HH.mono hp le_rfl le_rfl (residualCoefficientBudget_ge j hKt0 l.val p)
|
| 70 |
+
have hh:=rule p hp D 1 H' (by omega)
|
| 71 |
+
apply hh.congr_on
|
| 72 |
+
intro b x hx
|
| 73 |
+
rw [(H.initial b x hx).1]
|
| 74 |
+
refine ⟨allw,?_,?_,?_,?_,?_⟩
|
| 75 |
+
· have H' := HH.appendAuxiliary
|
| 76 |
+
have hh:=rule l.val le_rfl (fun b=>(D b).appendAuxiliary 1) 2
|
| 77 |
+
(H'.mono le_rfl le_rfl (by norm_num) (residualCoefficientBudget_ge j hKt0 l.val l.val)) (by omega)
|
| 78 |
+
apply hh.congr_on
|
| 79 |
+
intro b x hx
|
| 80 |
+
rw [show 2=1+1 from rfl,OrdinaryData.appendAuxiliary_started_source,(H.initial b x hx).2]
|
| 81 |
+
· have H' := HH.appendPrimary hn hKt l le_rfl
|
| 82 |
+
have hh:=rule l.val le_rfl (fun b=>(D b).appendPrimary 1 l) 2
|
| 83 |
+
(H'.mono le_rfl le_rfl (by norm_num) (residualCoefficientBudget_ge j hKt0 l.val l.val)) (by omega)
|
| 84 |
+
apply hh.congr
|
| 85 |
+
intro b x
|
| 86 |
+
rw [show 2=1+1 from rfl,OrdinaryData.appendPrimary_started_source]
|
| 87 |
+
rfl
|
| 88 |
+
|
| 89 |
+
· have hh:=C.means D 1 l.val Kt HH (by omega) (residualCoefficientBudget_ge j hKt0 l.val 0) 0
|
| 90 |
+
apply hh.congr
|
| 91 |
+
intro b x
|
| 92 |
+
congr 1
|
| 93 |
+
ext v i
|
| 94 |
+
dsimp only [D,literalFullData]
|
| 95 |
+
rw [OrdinaryData.unitPullback_auxCoefficient _ l Sum.inr _ _ _ rfl rfl]
|
| 96 |
+
exact literalInitial_coefficient _ _ _ _ _ _ _ _ _ _ _ _
|
| 97 |
+
· exact C.local_onsager_multiplier l.val l.isLt.le
|
| 98 |
+
· refine ⟨Bc,Vc,hBc,hVc,fun b x hx=>hc b x (Or.inl hx),?_⟩
|
| 99 |
+
intro b x hx
|
| 100 |
+
simpa only [norm_derivativeVector_sq] using
|
| 101 |
+
pow_le_pow_left₀ (norm_nonneg _) (hDc b x (Or.inl hx)) 2
|
| 102 |
+
|
| 103 |
+
end SKGapCutoff.Recipe
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/LocalGaussianMoments.lean
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianVectorMoments
|
| 3 |
+
import OAI.Probability.SKGap.Localization.LocalWhitening
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open MeasureTheory ProbabilityTheory Matrix Real
|
| 11 |
+
open scoped BigOperators ENNReal NNReal
|
| 12 |
+
|
| 13 |
+
lemma matrix_fourth_sum_integrable {ι κ : Type*} [Fintype ι] [Fintype κ]
|
| 14 |
+
(A : Matrix ι κ ℝ) :
|
| 15 |
+
Integrable (fun g => ∑ i,((A*ᵥg) i)^4) (gaussianCoordinates κ) := by
|
| 16 |
+
apply integrable_finsetSum
|
| 17 |
+
intro i _
|
| 18 |
+
exact linear_gaussian_fourth_integrable (A i)
|
| 19 |
+
|
| 20 |
+
lemma matrix_fourth_sum_mean {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq κ]
|
| 21 |
+
(A : Matrix ι κ ℝ) :
|
| 22 |
+
(∫ g,∑ i,((A*ᵥg) i)^4 ∂gaussianCoordinates κ)=3*∑ i,(∑ k,A i k^2)^2 := by
|
| 23 |
+
simp only [Matrix.mulVec,dotProduct]
|
| 24 |
+
rw [integral_finsetSum _ (fun i _ => linear_gaussian_fourth_integrable (A i)),Finset.mul_sum]
|
| 25 |
+
apply Finset.sum_congr rfl
|
| 26 |
+
intro i _
|
| 27 |
+
exact linear_gaussian_fourth (A i)
|
| 28 |
+
|
| 29 |
+
lemma matrix_fourth_sum_bound {n m : ℕ} (A : Matrix (Fin n) (Fin m) ℝ)
|
| 30 |
+
{c : ℝ} (hc : 0 ≤ c) (hb : ∀ i,∑ k,A i k^2 ≤ c) :
|
| 31 |
+
(∫ g,∑ i,((A*ᵥg) i)^4 ∂gaussianCoordinates (Fin m)) ≤ 3*(n:ℝ)*c^2 := by
|
| 32 |
+
rw [matrix_fourth_sum_mean]
|
| 33 |
+
have hs : (∑ i : Fin n,(∑ k,A i k^2)^2) ≤ ∑ _i : Fin n,c^2 := by
|
| 34 |
+
apply Finset.sum_le_sum
|
| 35 |
+
intro i _
|
| 36 |
+
exact (sq_le_sq₀ (Finset.sum_nonneg (fun k _ => sq_nonneg _)) hc).mpr (hb i)
|
| 37 |
+
simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] at hs
|
| 38 |
+
nlinarith
|
| 39 |
+
|
| 40 |
+
lemma matrix_norm_fourth_integrable {n m : ℕ} (A : Matrix (Fin n) (Fin m) ℝ) :
|
| 41 |
+
Integrable (fun g => vectorNorm (A*ᵥg)^4) (gaussianCoordinates (Fin m)) := by
|
| 42 |
+
apply ((matrix_fourth_sum_integrable A).const_mul (n:ℝ)).mono' ?_ ?_
|
| 43 |
+
· have he : (fun g => vectorNorm (A*ᵥg)^4)=fun g => (∑ i,((A*ᵥg) i)^2)^2 := by
|
| 44 |
+
funext g
|
| 45 |
+
rw [show vectorNorm (A*ᵥg)^4=(vectorNorm (A*ᵥg)^2)^2 by ring,vectorNorm_sq]
|
| 46 |
+
rfl
|
| 47 |
+
rw [he]
|
| 48 |
+
fun_prop
|
| 49 |
+
· filter_upwards [] with g
|
| 50 |
+
rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)]
|
| 51 |
+
exact vectorNorm_fourth_le (A*ᵥg)
|
| 52 |
+
|
| 53 |
+
lemma matrix_norm_fourth_bound {n m : ℕ} (A : Matrix (Fin n) (Fin m) ℝ)
|
| 54 |
+
{c : ℝ} (hc : 0 ≤ c) (hb : ∀ i,∑ k,A i k^2 ≤ c) :
|
| 55 |
+
(∫ g,vectorNorm (A*ᵥg)^4 ∂gaussianCoordinates (Fin m)) ≤ 3*(n:ℝ)^2*c^2 := by
|
| 56 |
+
calc
|
| 57 |
+
_ ≤ ∫ g,(n:ℝ)*(∑ i,((A*ᵥg) i)^4) ∂gaussianCoordinates (Fin m) :=
|
| 58 |
+
integral_mono (matrix_norm_fourth_integrable A)
|
| 59 |
+
((matrix_fourth_sum_integrable A).const_mul _) (fun g => vectorNorm_fourth_le _)
|
| 60 |
+
_ = (n:ℝ)*(∫ g,∑ i,((A*ᵥg) i)^4 ∂gaussianCoordinates (Fin m)) := integral_const_mul _ _
|
| 61 |
+
_ ≤ (n:ℝ)*(3*(n:ℝ)*c^2) := mul_le_mul_of_nonneg_left (matrix_fourth_sum_bound A hc hb) (Nat.cast_nonneg _)
|
| 62 |
+
_ = _ := by ring
|
| 63 |
+
|
| 64 |
+
theorem localGaussian_fourth_moments {n : ℕ} {U : Matrix (Fin n) (Fin n) ℝ}
|
| 65 |
+
(hU : U.IsHermitian) {γ σ : ℝ} (hγ : 0 < γ)
|
| 66 |
+
(hbound : ∀ g : Field n, vectorNorm (U*ᵥg) ≤ vectorNorm g/sqrt γ) :
|
| 67 |
+
(∫ g,∑ i,((σ • U)*ᵥg) i^4 ∂gaussianCoordinates (Fin n)) ≤ 3*(n:ℝ)*σ^4/γ^2 ∧
|
| 68 |
+
(∫ g,vectorNorm ((σ • U)*ᵥg)^4 ∂gaussianCoordinates (Fin n)) ≤ 3*(n:ℝ)^2*σ^4/γ^2 := by
|
| 69 |
+
have hb (i : Fin n) : ∑ k,(σ • U) i k^2 ≤ σ^2/γ := by
|
| 70 |
+
have hh := symmetric_row_sq_bound hU (inv_nonneg.mpr (sqrt_nonneg γ))
|
| 71 |
+
(fun g => by simpa only [div_eq_mul_inv,mul_comm] using hbound g) i
|
| 72 |
+
rw [inv_pow,Real.sq_sqrt hγ.le] at hh
|
| 73 |
+
simp only [Matrix.smul_apply,smul_eq_mul,mul_pow,← Finset.mul_sum]
|
| 74 |
+
exact (mul_le_mul_of_nonneg_left hh (sq_nonneg σ)).trans_eq (by ring)
|
| 75 |
+
have h1 := matrix_fourth_sum_bound (σ • U) (div_nonneg (sq_nonneg σ) hγ.le) hb
|
| 76 |
+
have h2 := matrix_norm_fourth_bound (σ • U) (div_nonneg (sq_nonneg σ) hγ.le) hb
|
| 77 |
+
constructor
|
| 78 |
+
· convert h1 using 1; ring
|
| 79 |
+
· convert h2 using 1; ring
|
| 80 |
+
|
| 81 |
+
end SKGap
|
| 82 |
+
end
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
section
|
| 86 |
+
noncomputable section
|
| 87 |
+
namespace SKGap
|
| 88 |
+
open MeasureTheory ProbabilityTheory Matrix Real Set
|
| 89 |
+
open scoped BigOperators ENNReal NNReal
|
| 90 |
+
|
| 91 |
+
lemma gaussian_vectorSqNorm_integrable (n : ℕ) :
|
| 92 |
+
Integrable (vectorSqNorm (n := n)) (gaussianCoordinates (Fin n)) := by
|
| 93 |
+
have hh := (gaussianQuadratic_memLp (fun _ : Fin n => (1:ℝ))).integrable (by norm_num)
|
| 94 |
+
change Integrable (fun g : Field n => ∑ i,1*g i^2) (gaussianCoordinates (Fin n)) at hh
|
| 95 |
+
change Integrable (fun g : Field n => ∑ i,g i^2) (gaussianCoordinates (Fin n))
|
| 96 |
+
simpa only [one_mul] using hh
|
| 97 |
+
|
| 98 |
+
lemma gaussian_vectorSqNorm_mean (n : ℕ) :
|
| 99 |
+
(∫ g,vectorSqNorm g ∂gaussianCoordinates (Fin n))=(n:ℝ) := by
|
| 100 |
+
simpa only [vectorSqNorm,gaussianQuadratic,one_mul,gaussianCoordinates,Finset.sum_const,
|
| 101 |
+
Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_one] using
|
| 102 |
+
gaussianQuadratic_mean (fun _ : Fin n => (1:ℝ))
|
| 103 |
+
|
| 104 |
+
def localGaussianBall (n : ℕ) : Set (Field n) := {g | vectorSqNorm g ≤ 4*(n:ℝ)}
|
| 105 |
+
|
| 106 |
+
lemma localGaussianBall_measurable (n : ℕ) : MeasurableSet (localGaussianBall n) := by
|
| 107 |
+
unfold localGaussianBall vectorSqNorm
|
| 108 |
+
exact measurableSet_le (by fun_prop) measurable_const
|
| 109 |
+
|
| 110 |
+
lemma localGaussianBall_norm {n : ℕ} {g : Field n} (hg : g ∈ localGaussianBall n) :
|
| 111 |
+
vectorNorm g ≤ 2*sqrt (n:ℝ) := by
|
| 112 |
+
apply (sq_le_sq₀ (vectorNorm_nonneg _) (by positivity)).mp
|
| 113 |
+
rw [vectorNorm_sq,mul_pow,Real.sq_sqrt (Nat.cast_nonneg _)]
|
| 114 |
+
simpa only [localGaussianBall,Set.mem_ofPred_eq,show (2:ℝ)^2=4 by norm_num] using hg
|
| 115 |
+
|
| 116 |
+
theorem localGaussianBall_probability {n : ℕ} (hn : 0 < n) :
|
| 117 |
+
3/4 ≤ (gaussianCoordinates (Fin n)).real (localGaussianBall n) := by
|
| 118 |
+
let μ := gaussianCoordinates (Fin n)
|
| 119 |
+
have hn0 : (0:ℝ) < n := by exact_mod_cast hn
|
| 120 |
+
have hh := mul_meas_ge_le_integral_of_nonneg
|
| 121 |
+
(μ := μ) (ae_of_all _ (fun g => vectorSqNorm_nonneg g))
|
| 122 |
+
(gaussian_vectorSqNorm_integrable n) (4*(n:ℝ))
|
| 123 |
+
rw [gaussian_vectorSqNorm_mean] at hh
|
| 124 |
+
have hsub : (localGaussianBall n)ᶜ ⊆ {g | 4*(n:ℝ) ≤ vectorSqNorm g} := by
|
| 125 |
+
intro g hg
|
| 126 |
+
change ¬ vectorSqNorm g ≤ 4*(n:ℝ) at hg
|
| 127 |
+
exact (lt_of_not_ge hg).le
|
| 128 |
+
have hmono := measureReal_mono hsub (measure_ne_top μ _)
|
| 129 |
+
have hc := probReal_compl_eq_one_sub (μ := μ) (localGaussianBall_measurable n)
|
| 130 |
+
rw [hc] at hmono
|
| 131 |
+
nlinarith
|
| 132 |
+
|
| 133 |
+
lemma localGaussianBall_ne_zero {n : ℕ} (hn : 0 < n) :
|
| 134 |
+
gaussianCoordinates (Fin n) (localGaussianBall n) ≠ 0 := by
|
| 135 |
+
intro he
|
| 136 |
+
have hh := localGaussianBall_probability hn
|
| 137 |
+
simp only [measureReal_def,he,ENNReal.toReal_zero] at hh
|
| 138 |
+
norm_num at hh
|
| 139 |
+
|
| 140 |
+
lemma integrable_cond_of_integrable {Ω E : Type*} [MeasurableSpace Ω]
|
| 141 |
+
[NormedAddCommGroup E] {μ : Measure Ω} {s : Set Ω} {f : Ω → E}
|
| 142 |
+
(hs : μ s ≠ 0) (hf : Integrable f μ) : Integrable f (cond μ s) := by
|
| 143 |
+
exact hf.restrict.smul_measure (ENNReal.inv_ne_top.mpr hs)
|
| 144 |
+
|
| 145 |
+
lemma integral_cond_nonneg_le_two {Ω : Type*} [MeasurableSpace Ω]
|
| 146 |
+
{μ : Measure Ω} [IsProbabilityMeasure μ] {s : Set Ω} {f : Ω → ℝ}
|
| 147 |
+
(hp : 1/2 ≤ μ.real s)
|
| 148 |
+
(hf : Integrable f μ) (hn : 0 ≤ᵐ[μ] f) :
|
| 149 |
+
(∫ x,f x ∂cond μ s) ≤ 2*∫ x,f x ∂μ := by
|
| 150 |
+
have hps : 0 < μ.real s := by linarith
|
| 151 |
+
have his : 0 ≤ ∫ x in s,f x ∂μ := integral_nonneg_of_ae (ae_restrict_of_ae hn)
|
| 152 |
+
have hsle : (∫ x in s,f x ∂μ) ≤ ∫ x,f x ∂μ :=
|
| 153 |
+
integral_mono_measure μ.restrict_le_self hn hf
|
| 154 |
+
have hinv : (μ.real s)⁻¹ ≤ 2 := by
|
| 155 |
+
rw [inv_eq_one_div]
|
| 156 |
+
exact (div_le_iff₀ hps).mpr (by linarith)
|
| 157 |
+
rw [ProbabilityTheory.cond,integral_smul_measure,ENNReal.toReal_inv]
|
| 158 |
+
change (μ.real s)⁻¹*(∫ x in s,f x ∂μ) ≤ _
|
| 159 |
+
exact (mul_le_mul_of_nonneg_right hinv his).trans (mul_le_mul_of_nonneg_left hsle (by norm_num))
|
| 160 |
+
|
| 161 |
+
end SKGap
|
| 162 |
+
end
|
| 163 |
+
end
|
| 164 |
+
|
| 165 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/MatrixNormTail.lean
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianProductUpperTailLipschitz
|
| 3 |
+
import OAI.Probability.SKGap.Gaussian.GaussianProductPower
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Matrix Real MeasureTheory ProbabilityTheory Set
|
| 11 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 12 |
+
variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ]
|
| 13 |
+
|
| 14 |
+
def matrixWordSeminorm (p : Bool) (M : Matrix ι ι ℝ) : ℝ :=
|
| 15 |
+
if p then offDiagonalSeminorm M else diagonalSeminorm M
|
| 16 |
+
lemma matrixWordSeminorm_lipschitz (p : Bool) : LipschitzWith 1 (matrixWordSeminorm (ι:=ι) p) := by
|
| 17 |
+
cases p
|
| 18 |
+
· exact diagonalSeminorm_lipschitz
|
| 19 |
+
· exact offDiagonalSeminorm_lipschitz
|
| 20 |
+
lemma matrixWordSeminorm_add (p : Bool) (M N : Matrix ι ι ℝ) :
|
| 21 |
+
matrixWordSeminorm p (M+N)≤ matrixWordSeminorm p M+matrixWordSeminorm p N := by
|
| 22 |
+
cases p
|
| 23 |
+
· exact diagonalSeminorm_add M N
|
| 24 |
+
· exact offDiagonalSeminorm_add M N
|
| 25 |
+
lemma matrixWordSeminorm_nonneg (p : Bool) (M : Matrix ι ι ℝ) : 0≤ matrixWordSeminorm p M := by
|
| 26 |
+
let : Fact (1≤(4:ENNReal)) := ⟨by norm_num⟩
|
| 27 |
+
cases p
|
| 28 |
+
· exact norm_nonneg (diagonalVector M)
|
| 29 |
+
· exact norm_nonneg (offDiagonalVector M)
|
| 30 |
+
|
| 31 |
+
lemma matrixCentered_sub {F G : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 32 |
+
{L K : NNReal} (hF : LipschitzWith L F) (hG : LipschitzWith K G) (x : EuclideanSpace ℝ κ) :
|
| 33 |
+
matrixCentered (fun y=>F y-G y) x=matrixCentered F x-matrixCentered G x := by
|
| 34 |
+
have hm : matrixEntryMean (fun y=>F y-G y)=matrixEntryMean F-matrixEntryMean G := by
|
| 35 |
+
ext i k
|
| 36 |
+
exact integral_sub (gaussianProduct_integrable_lipschitz (matrixEntry_lip hF i k))
|
| 37 |
+
(gaussianProduct_integrable_lipschitz (matrixEntry_lip hG i k))
|
| 38 |
+
simp only [matrixCentered,hm]
|
| 39 |
+
abel
|
| 40 |
+
|
| 41 |
+
lemma gaussianProduct_centered_matrix_tail {F : EuclideanSpace ℝ κ→Matrix ι ι ℝ}
|
| 42 |
+
{L : NNReal} (hF : LipschitzWith L F) (hL : 0<L) (p : Bool) {u : ℝ} (hu : 0≤u) :
|
| 43 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 44 |
+
{g | matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ)+u<
|
| 45 |
+
matrixWordSeminorm p (matrixCentered F (WithLp.toLp 2 g))}≤
|
| 46 |
+
ENNReal.ofReal (exp (-2*u^2/(π^2*(L:ℝ)^2))) := by
|
| 47 |
+
let μ := Measure.pi (fun _ : κ=>gaussianReal 0 1)
|
| 48 |
+
let X : (κ→ℝ)→ℝ := fun g=>matrixWordSeminorm p (matrixCentered F (WithLp.toLp 2 g))
|
| 49 |
+
have hXL : LipschitzWith L (fun x : EuclideanSpace ℝ κ=>X x.ofLp) := by
|
| 50 |
+
simpa only [X,WithLp.toLp_ofLp,one_mul,Function.comp_def] using
|
| 51 |
+
(matrixWordSeminorm_lipschitz p).comp (matrixCentered_lipschitz hF)
|
| 52 |
+
have hE : (∫ g,X g ∂μ)≤ matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ) := by
|
| 53 |
+
cases p
|
| 54 |
+
· exact (gaussianProduct_centered_matrix_norms hF hL).1
|
| 55 |
+
· exact (gaussianProduct_centered_matrix_norms hF hL).2
|
| 56 |
+
have htail := gaussianProduct_upper_tail_lipschitz hXL hL hu
|
| 57 |
+
have hmono : μ {g | matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ)+u<X g}≤
|
| 58 |
+
μ {g | u≤X g-∫ h,X h ∂μ} := by
|
| 59 |
+
apply measure_mono
|
| 60 |
+
intro g hg
|
| 61 |
+
change matrixNormConstant*sqrt (Fintype.card ι)*(L:ℝ)+u<X g at hg
|
| 62 |
+
change u≤X g-∫ h,X h ∂μ
|
| 63 |
+
linarith only [hg,hE]
|
| 64 |
+
apply hmono.trans
|
| 65 |
+
rw [←ENNReal.ofReal_toReal (measure_ne_top μ _)]
|
| 66 |
+
exact ENNReal.ofReal_le_ofReal htail
|
| 67 |
+
end SKGap
|
| 68 |
+
end
|
| 69 |
+
end
|
| 70 |
+
|
| 71 |
+
section
|
| 72 |
+
noncomputable section
|
| 73 |
+
namespace SKGap
|
| 74 |
+
open Matrix Real MeasureTheory ProbabilityTheory Set
|
| 75 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 76 |
+
variable {κ : Type*} [Fintype κ]
|
| 77 |
+
|
| 78 |
+
lemma gaussianMatrix_scaled_semnorm_tail {n : ℕ} (hn : 1 ≤ n)
|
| 79 |
+
{F : EuclideanSpace ℝ κ→Matrix (Fin n) (Fin n) ℝ} {H r T s : ℝ}
|
| 80 |
+
(hH : 0<H) (hr : 0<r) (hT : 0 ≤ T) (hs : 0 ≤ s)
|
| 81 |
+
(hF : LipschitzWith (Real.toNNReal (H*r/sqrt n)) F) (p : Bool) :
|
| 82 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 1))
|
| 83 |
+
{g | (matrixNormConstant*H+T*s)*r< matrixWordSeminorm p (matrixCentered F (WithLp.toLp 2 g))} ≤
|
| 84 |
+
ENNReal.ofReal (exp (-2*T^2*s^2*(n:ℝ)/(π^2*H^2))) := by
|
| 85 |
+
have hn0 : (0:ℝ)<n := by exact_mod_cast (show 0<n by omega)
|
| 86 |
+
have hnS := sqrt_pos.mpr hn0
|
| 87 |
+
have hL : 0<Real.toNNReal (H*r/sqrt n) := by exact_mod_cast (Real.toNNReal_pos.mpr (div_pos (mul_pos hH hr) hnS))
|
| 88 |
+
have hh := gaussianProduct_centered_matrix_tail hF hL p (mul_nonneg (mul_nonneg hT hs) hr.le)
|
| 89 |
+
have he : (matrixNormConstant*sqrt (Fintype.card (Fin n))*(Real.toNNReal (H*r/sqrt n):ℝ)+T*s*r)=
|
| 90 |
+
(matrixNormConstant*H+T*s)*r := by
|
| 91 |
+
rw [Fintype.card_fin,Real.coe_toNNReal _ (by positivity)]
|
| 92 |
+
field_simp
|
| 93 |
+
have he' : -2*(T*s*r)^2/(π^2*(Real.toNNReal (H*r/sqrt n):ℝ)^2)=
|
| 94 |
+
-2*T^2*s^2*(n:ℝ)/(π^2*H^2) := by
|
| 95 |
+
rw [Real.coe_toNNReal _ (by positivity)]
|
| 96 |
+
field_simp
|
| 97 |
+
rw [sq_sqrt hn0.le]
|
| 98 |
+
rw [he,he'] at hh
|
| 99 |
+
exact hh
|
| 100 |
+
end SKGap
|
| 101 |
+
end
|
| 102 |
+
end
|
| 103 |
+
|
| 104 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/MatrixWordMoments.lean
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianProductIntegral
|
| 3 |
+
import OAI.Probability.SKGap.Matrix.MatrixWordRegularity
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
section
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace SKGap
|
| 10 |
+
open Real Matrix MeasureTheory ProbabilityTheory
|
| 11 |
+
open scoped BigOperators Matrix.Norms.Frobenius
|
| 12 |
+
|
| 13 |
+
lemma goe_word_even_centered_moment {n : ℕ} (hn : 0<n) {j : ℝ} (hj : 0<j)
|
| 14 |
+
(F : List (Matrix (Fin n) (Fin n) ℝ→Matrix (Fin n) (Fin n) ℝ))
|
| 15 |
+
(hFl : 0<F.length) {R : NNReal} (hR : 0<R)
|
| 16 |
+
(hF : ∀ f∈F,∀ M,opNorm (f M) ≤ R) (hL : ∀ f∈F,LipschitzWith R f)
|
| 17 |
+
(i b : Fin n) (k : ℕ) :
|
| 18 |
+
(∫ g : MatrixCoordinates (Fin n)→ℝ,
|
| 19 |
+
|matrixFactorProduct F (goeMatrix (j/n) g) i b-
|
| 20 |
+
∫ h : MatrixCoordinates (Fin n)→ℝ,matrixFactorProduct F (goeMatrix (j/n) h) i b
|
| 21 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)|^(2*k)
|
| 22 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)) ≤
|
| 23 |
+
(2*((2*k).factorial:ℝ)*exp (π^2/8)) *
|
| 24 |
+
(((F.length:ℝ)*(R:ℝ)^F.length)^2*(2*j))^k/(n:ℝ)^k := by
|
| 25 |
+
have hnr : (0:ℝ)<n := Nat.cast_pos.mpr hn
|
| 26 |
+
have hRr : (0:ℝ)<R := hR
|
| 27 |
+
have hlr : (0:ℝ)<F.length := Nat.cast_pos.mpr hFl
|
| 28 |
+
let L : NNReal := ((F.length:NNReal)*R^F.length)*⟨sqrt (2*(j/n)),sqrt_nonneg _⟩
|
| 29 |
+
have hLp : 0<L := by change 0<((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*(j/n)); positivity
|
| 30 |
+
have hh := gaussianProduct_abs_centered_moment (goe_word_entry_lipschitz F hF hL (j/n) i b) hLp (2*k)
|
| 31 |
+
apply hh.trans_eq
|
| 32 |
+
change (2*((2*k).factorial:ℝ)*exp (π^2/8)) *
|
| 33 |
+
(((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*(j/n)))^(2*k) = _
|
| 34 |
+
rw [pow_mul,mul_pow,sq_sqrt (by positivity : 0 ≤ 2*(j/n))]
|
| 35 |
+
rw [show ((F.length:ℝ)*(R:ℝ)^F.length)^2*(2*(j/n))=
|
| 36 |
+
(((F.length:ℝ)*(R:ℝ)^F.length)^2*(2*j))/(n:ℝ) by ring,div_pow]
|
| 37 |
+
ring
|
| 38 |
+
|
| 39 |
+
lemma goe_word_trace_lip_scaled {n : ℕ} (hn : 0<n) {j : ℝ} (hj : 0≤j)
|
| 40 |
+
(F : List (Matrix (Fin n) (Fin n) ℝ→Matrix (Fin n) (Fin n) ℝ)) {R : NNReal}
|
| 41 |
+
(hF : ∀ f∈F,∀ M,opNorm (f M) ≤ R) (hL : ∀ f∈F,LipschitzWith R f) :
|
| 42 |
+
LipschitzWith ⟨((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ),by positivity⟩
|
| 43 |
+
(fun z : EuclideanSpace ℝ (MatrixCoordinates (Fin n))=>
|
| 44 |
+
trace (matrixFactorProduct F (goeMatrix (j/n) z))/(n:ℝ)) := by
|
| 45 |
+
have hnr : (0:ℝ)<n := Nat.cast_pos.mpr hn
|
| 46 |
+
have he : (n:ℝ)⁻¹*(sqrt (n:ℝ)*((F.length:ℝ)*(R:ℝ)^F.length))*sqrt (2*(j/n))=
|
| 47 |
+
((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ) := by
|
| 48 |
+
rw [show 2*(j/(n:ℝ))=(2*j)/(n:ℝ) by ring,sqrt_div (mul_nonneg (by norm_num) hj)]
|
| 49 |
+
field_simp [ne_of_gt hnr,ne_of_gt (sqrt_pos.2 hnr)]
|
| 50 |
+
have hh := goe_word_normalized_trace_lipschitz F hF hL (j/n)
|
| 51 |
+
simpa only [Fintype.card_fin,show (⟨(n:ℝ)⁻¹,inv_nonneg.mpr (Nat.cast_nonneg n)⟩ *
|
| 52 |
+
(⟨sqrt (n:ℝ),sqrt_nonneg _⟩*((F.length:NNReal)*R^F.length))*⟨sqrt (2*(j/n)),sqrt_nonneg _⟩ : NNReal)=
|
| 53 |
+
⟨((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ),by positivity⟩ from NNReal.eq he] using hh
|
| 54 |
+
|
| 55 |
+
theorem goe_word_trace_centered_L1 {n : ℕ} (hn : 0<n) {j : ℝ} (hj : 0<j)
|
| 56 |
+
(F : List (Matrix (Fin n) (Fin n) ℝ→Matrix (Fin n) (Fin n) ℝ))
|
| 57 |
+
(hFl : 0<F.length) {R : NNReal} (hR : 0<R)
|
| 58 |
+
(hF : ∀ f∈F,∀ M,opNorm (f M) ≤ R) (hL : ∀ f∈F,LipschitzWith R f) :
|
| 59 |
+
(∫ g : MatrixCoordinates (Fin n)→ℝ,
|
| 60 |
+
|trace (matrixFactorProduct F (goeMatrix (j/n) g))/(n:ℝ)-
|
| 61 |
+
∫ h : MatrixCoordinates (Fin n)→ℝ,trace (matrixFactorProduct F (goeMatrix (j/n) h))/(n:ℝ)
|
| 62 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)|
|
| 63 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)) ≤
|
| 64 |
+
(2*exp (π^2/8))*((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ) := by
|
| 65 |
+
have hnr : (0:ℝ)<n := Nat.cast_pos.mpr hn
|
| 66 |
+
have hRr : (0:ℝ)<R := hR
|
| 67 |
+
have hlr : (0:ℝ)<F.length := Nat.cast_pos.mpr hFl
|
| 68 |
+
have hh := gaussianProduct_centered_L1 (goe_word_trace_lip_scaled hn hj.le F hF hL)
|
| 69 |
+
(by change 0<((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ); positivity)
|
| 70 |
+
apply hh.trans_eq
|
| 71 |
+
change (2*exp (π^2/8))*(((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ))=_
|
| 72 |
+
ring
|
| 73 |
+
|
| 74 |
+
lemma goe_word_trace_centered_L1_all {n : ℕ} (hn : 0<n) {j : ℝ} (hj : 0<j)
|
| 75 |
+
(F : List (Matrix (Fin n) (Fin n) ℝ→Matrix (Fin n) (Fin n) ℝ))
|
| 76 |
+
{R : NNReal} (hR : 0<R)
|
| 77 |
+
(hF : ∀ f∈F,∀ M,opNorm (f M) ≤ R) (hL : ∀ f∈F,LipschitzWith R f) :
|
| 78 |
+
(∫ g : MatrixCoordinates (Fin n)→ℝ,
|
| 79 |
+
|trace (matrixFactorProduct F (goeMatrix (j/n) g))/(n:ℝ)-
|
| 80 |
+
∫ h : MatrixCoordinates (Fin n)→ℝ,trace (matrixFactorProduct F (goeMatrix (j/n) h))/(n:ℝ)
|
| 81 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)|
|
| 82 |
+
∂Measure.pi (fun _=>gaussianReal 0 1)) ≤
|
| 83 |
+
(2*exp (π^2/8))*((F.length:ℝ)*(R:ℝ)^F.length)*sqrt (2*j)/(n:ℝ) := by
|
| 84 |
+
by_cases he : F=[]
|
| 85 |
+
· subst F
|
| 86 |
+
simp only [matrixFactorProduct_nil,List.length_nil,Nat.cast_zero,zero_mul,mul_zero,zero_div]
|
| 87 |
+
simp
|
| 88 |
+
· exact goe_word_trace_centered_L1 hn hj F (List.length_pos_iff.mpr he) hR hF hL
|
| 89 |
+
end SKGap
|
| 90 |
+
end
|
| 91 |
+
end
|
| 92 |
+
|
| 93 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/PartitionSecondMoment.lean
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianProductUpperTailLipschitz
|
| 3 |
+
import OAI.Probability.SKGap.Terminal.SpinGaussianBound
|
| 4 |
+
import OAI.Probability.SKGap.Gaussian.GaussianPartition
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
section
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace SKGap
|
| 11 |
+
open MeasureTheory ProbabilityTheory Real
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
|
| 14 |
+
def quadraticGaussianBound (j : ℝ) : ℝ := ∫ g : ℝ, exp (j*g^2/2) ∂gaussianReal 0 1
|
| 15 |
+
|
| 16 |
+
lemma quadraticGaussianBound_ge_one {j : ℝ} (hj : 0 ≤ j) (hj1 : j < 1) :
|
| 17 |
+
1 ≤ quadraticGaussianBound j := by
|
| 18 |
+
have h := integral_mono (integrable_const (1:ℝ)) (gaussian_quadratic_integrable_sharp hj1)
|
| 19 |
+
(fun g : ℝ=>one_le_exp (by positivity : 0 ≤ j*g^2/2))
|
| 20 |
+
simpa [quadraticGaussianBound] using h
|
| 21 |
+
|
| 22 |
+
lemma gaussianSpinPartition_pos (n : ℕ) (r : ℝ) (g : Disorder n) :
|
| 23 |
+
0 < gaussianSpinPartition n r g :=
|
| 24 |
+
Finset.sum_pos (fun _ _=>exp_pos _) Finset.univ_nonempty
|
| 25 |
+
|
| 26 |
+
lemma gaussianSpinPartition_measurable (n : ℕ) (r : ℝ) : Measurable (gaussianSpinPartition n r) := by
|
| 27 |
+
unfold gaussianSpinPartition
|
| 28 |
+
exact Finset.measurable_sum _ (fun x _=>Real.measurable_exp.comp
|
| 29 |
+
(Finset.measurable_sum _ (fun e _=>(measurable_pi_apply e).const_mul _)))
|
| 30 |
+
|
| 31 |
+
lemma gaussianSpinPartition_mean_pos {n : ℕ} {r : ℝ} (hr : 0 ≤ r) :
|
| 32 |
+
0 < ∫ g, gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n) := by
|
| 33 |
+
rw [gaussianSpinPartition_integral hr]
|
| 34 |
+
exact mul_pos (by exact_mod_cast Fintype.card_pos) (exp_pos _)
|
| 35 |
+
|
| 36 |
+
lemma gaussianSpinPartition_second_moment {n : ℕ} {j r : ℝ} (hj : j < 1)
|
| 37 |
+
(hr : 0 ≤ r) (hnr : (n:ℝ)*r ≤ j) :
|
| 38 |
+
(∫ g,(gaussianSpinPartition n r g)^2 ∂gaussianCoordinates (Edge n)) ≤
|
| 39 |
+
quadraticGaussianBound j*(∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))^2 := by
|
| 40 |
+
rw [gaussianSpinPartition_square_integral hr,gaussianSpinPartition_integral hr]
|
| 41 |
+
have hc : (Fintype.card (Spin n):ℝ)=(2:ℝ)^n := by simp [Spin]
|
| 42 |
+
have he : exp (r*(Fintype.card (Edge n):ℝ)-r*(n:ℝ)/2) ≤ exp (r*(Fintype.card (Edge n):ℝ)) :=
|
| 43 |
+
exp_le_exp.mpr (by nlinarith [mul_nonneg hr (show (0:ℝ) ≤ n by positivity)])
|
| 44 |
+
have hb := spin_quadratic_sum_bound hj hr hnr
|
| 45 |
+
rw [← hc] at hb
|
| 46 |
+
have hB : 0 ≤ quadraticGaussianBound j := integral_nonneg (fun _=>(exp_pos _).le)
|
| 47 |
+
have hc0 : (0:ℝ) ≤ Fintype.card (Spin n) := by positivity
|
| 48 |
+
calc
|
| 49 |
+
_ ≤ (Fintype.card (Spin n):ℝ)*exp (r*(Fintype.card (Edge n):ℝ)-r*(n:ℝ)/2)*
|
| 50 |
+
((Fintype.card (Spin n):ℝ)*quadraticGaussianBound j) :=
|
| 51 |
+
mul_le_mul_of_nonneg_left hb (by positivity)
|
| 52 |
+
_ ≤ (Fintype.card (Spin n):ℝ)*exp (r*(Fintype.card (Edge n):ℝ))*
|
| 53 |
+
((Fintype.card (Spin n):ℝ)*quadraticGaussianBound j) :=
|
| 54 |
+
mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left he hc0) (mul_nonneg hc0 hB)
|
| 55 |
+
_ = _ := by
|
| 56 |
+
have h : exp (r*(Fintype.card (Edge n):ℝ))=exp (r*(Fintype.card (Edge n):ℝ)/2)^2 := by
|
| 57 |
+
rw [← exp_nat_mul];congr 1;ring
|
| 58 |
+
rw [h];ring
|
| 59 |
+
|
| 60 |
+
lemma gaussianSpinPartition_positive_probability {n : ℕ} {j r : ℝ} (hj0 : 0 ≤ j)
|
| 61 |
+
(hj : j < 1) (hr : 0 ≤ r) (hnr : (n:ℝ)*r ≤ j) :
|
| 62 |
+
1/(4*quadraticGaussianBound j) ≤ (gaussianCoordinates (Edge n)).real
|
| 63 |
+
{g | (∫ g,gaussianSpinPartition n r g ∂gaussianCoordinates (Edge n))/2 ≤ gaussianSpinPartition n r g} := by
|
| 64 |
+
exact second_moment_positive_probability _ _ (gaussianSpinPartition_measurable n r)
|
| 65 |
+
(gaussianSpinPartition_integrable n r) (gaussianSpinPartition_square_integrable n r)
|
| 66 |
+
(gaussianSpinPartition_mean_pos hr) (lt_of_lt_of_le zero_lt_one (quadraticGaussianBound_ge_one hj0 hj))
|
| 67 |
+
rfl (gaussianSpinPartition_second_moment hj hr hnr)
|
| 68 |
+
end SKGap
|
| 69 |
+
end
|
| 70 |
+
end
|
| 71 |
+
|
| 72 |
+
section
|
| 73 |
+
noncomputable section
|
| 74 |
+
namespace SKGap
|
| 75 |
+
open MeasureTheory ProbabilityTheory Real Set
|
| 76 |
+
open scoped BigOperators NNReal
|
| 77 |
+
|
| 78 |
+
lemma log_sum_exp_order {ι : Type*} [Fintype ι] [Nonempty ι]
|
| 79 |
+
(f g : ι→ℝ) (d : ℝ) (h : ∀ i,f i ≤ g i+d) :
|
| 80 |
+
log (∑ i,exp (f i)) ≤ log (∑ i,exp (g i))+d := by
|
| 81 |
+
have hp : 0 < ∑ i,exp (f i) := Finset.sum_pos (fun i _=>exp_pos _) Finset.univ_nonempty
|
| 82 |
+
have hq : 0 < ∑ i,exp (g i) := Finset.sum_pos (fun i _=>exp_pos _) Finset.univ_nonempty
|
| 83 |
+
have hh : (∑ i,exp (f i)) ≤ (∑ i,exp (g i))*exp d := by
|
| 84 |
+
rw [Finset.sum_mul]
|
| 85 |
+
exact Finset.sum_le_sum (fun i _=> (exp_le_exp.mpr (h i)).trans_eq (exp_add _ _))
|
| 86 |
+
have he := log_le_log hp hh
|
| 87 |
+
rw [log_mul hq.ne' (exp_pos _).ne',log_exp] at he
|
| 88 |
+
exact he
|
| 89 |
+
|
| 90 |
+
lemma log_sum_exp_lipschitz {ι : Type*} [Fintype ι] [Nonempty ι]
|
| 91 |
+
{E : Type*} [PseudoMetricSpace E] (f : ι→E→ℝ) {L : ℝ≥0}
|
| 92 |
+
(hf : ∀ i,LipschitzWith L (f i)) :
|
| 93 |
+
LipschitzWith L (fun x=>log (∑ i,exp (f i x))) := by
|
| 94 |
+
apply LipschitzWith.of_dist_le_mul
|
| 95 |
+
intro x y
|
| 96 |
+
rw [Real.dist_eq,abs_le]
|
| 97 |
+
constructor
|
| 98 |
+
· have hh := log_sum_exp_order (fun i=>f i y) (fun i=>f i x) ((L:ℝ)*dist x y)
|
| 99 |
+
(fun i=>by have hh := (hf i).dist_le_mul y x;rw [Real.dist_eq,dist_comm y x] at hh
|
| 100 |
+
linarith only [le_abs_self (f i y-f i x),hh])
|
| 101 |
+
linarith only [hh]
|
| 102 |
+
· have hh := log_sum_exp_order (fun i=>f i x) (fun i=>f i y) ((L:ℝ)*dist x y)
|
| 103 |
+
(fun i=>by have hh := (hf i).dist_le_mul x y;rw [Real.dist_eq] at hh
|
| 104 |
+
linarith only [le_abs_self (f i x-f i y),hh])
|
| 105 |
+
linarith only [hh]
|
| 106 |
+
|
| 107 |
+
lemma gaussianProduct_lower_tail_lipschitz {κ : Type*} [Fintype κ]
|
| 108 |
+
{f : (κ→ℝ)→ℝ} {L : ℝ≥0}
|
| 109 |
+
(hf : LipschitzWith L (fun x : EuclideanSpace ℝ κ=>f x.ofLp))
|
| 110 |
+
(hL : 0 < L) {u : ℝ} (hu : 0 ≤ u) :
|
| 111 |
+
(Measure.pi (fun _ : κ=>gaussianReal 0 1)).real
|
| 112 |
+
{x | f x-∫ y,f y ∂Measure.pi (fun _ : κ=>gaussianReal 0 1) ≤ -u} ≤
|
| 113 |
+
exp (-2*u^2/(π^2*(L:ℝ)^2)) := by
|
| 114 |
+
have hn : LipschitzWith L (fun x : EuclideanSpace ℝ κ=>-f x.ofLp) := by
|
| 115 |
+
apply LipschitzWith.of_dist_le_mul
|
| 116 |
+
intro x y
|
| 117 |
+
simpa only [Real.dist_eq,neg_sub_neg,abs_sub_comm] using hf.dist_le_mul x y
|
| 118 |
+
have h := gaussianProduct_upper_tail_lipschitz (f:=fun x=>-f x) hn hL hu
|
| 119 |
+
simp only [integral_neg] at h
|
| 120 |
+
convert h using 2
|
| 121 |
+
ext x;simp only [mem_ofPred_eq];constructor <;> intro hx <;> linarith only [hx]
|
| 122 |
+
|
| 123 |
+
lemma gaussian_log_anchor {κ : Type*} [Fintype κ]
|
| 124 |
+
{f : (κ→ℝ)→ℝ} {L : ℝ≥0}
|
| 125 |
+
(hf : LipschitzWith L (fun x : EuclideanSpace ℝ κ=>f x.ofLp))
|
| 126 |
+
(hL : 0 < L) {p b c : ℝ} (hc : 0 < c)
|
| 127 |
+
(hpc : exp (-2*c^2/π^2) < p)
|
| 128 |
+
(hp : p ≤ (Measure.pi (fun _ : κ=>gaussianReal 0 1)).real {x | b ≤ f x}) :
|
| 129 |
+
b-c*(L:ℝ) ≤ ∫ y,f y ∂Measure.pi (fun _ : κ=>gaussianReal 0 1) := by
|
| 130 |
+
by_contra hh
|
| 131 |
+
have hs : {x | b ≤ f x} ⊆ {x | c*(L:ℝ) ≤ f x-∫ y,f y ∂Measure.pi (fun _ : κ=>gaussianReal 0 1)} := by
|
| 132 |
+
intro x hx;dsimp only [mem_ofPred_eq] at *;linarith only [not_le.mp hh,hx]
|
| 133 |
+
have ht := gaussianProduct_upper_tail_lipschitz hf hL (mul_nonneg hc.le (NNReal.coe_nonneg L))
|
| 134 |
+
have he : -2*(c*(L:ℝ))^2/(π^2*(L:ℝ)^2)= -2*c^2/π^2 := by
|
| 135 |
+
have hLr : (L:ℝ) ≠ 0 := ne_of_gt hL
|
| 136 |
+
field_simp
|
| 137 |
+
rw [he] at ht
|
| 138 |
+
have hm := measureReal_mono hs (measure_ne_top (Measure.pi (fun _ : κ=>gaussianReal 0 1)) _)
|
| 139 |
+
linarith only [hp,ht,hm,hpc]
|
| 140 |
+
end SKGap
|
| 141 |
+
end
|
| 142 |
+
end
|
| 143 |
+
|
| 144 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/PhiMoments.lean
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.PhiBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory
|
| 10 |
+
namespace SKGap.Stein
|
| 11 |
+
|
| 12 |
+
def hyper (b : Bool) (x : ℝ) : ℝ := if b then Real.sinh x else Real.cosh x
|
| 13 |
+
lemma continuous_hyper (b : Bool) : Continuous (hyper b) := by unfold hyper; split_ifs <;> fun_prop
|
| 14 |
+
lemma hyper_hasDerivAt (b : Bool) (x : ℝ) : HasDerivAt (hyper b) (hyper (!b) x) x := by
|
| 15 |
+
cases b <;> simpa only [hyper,Bool.not_false,Bool.not_true,Bool.false_eq_true,ite_false,ite_true] using
|
| 16 |
+
(show HasDerivAt _ _ x from (by first | exact Real.hasDerivAt_cosh x | exact Real.hasDerivAt_sinh x))
|
| 17 |
+
|
| 18 |
+
lemma hyper_abs_le (b : Bool) (x : ℝ) : |hyper b x|≤Real.cosh x := by
|
| 19 |
+
cases b
|
| 20 |
+
· simp only [hyper,Bool.false_eq_true,ite_false,abs_of_pos (Real.cosh_pos _),le_refl]
|
| 21 |
+
· exact abs_sinh_le_cosh x
|
| 22 |
+
|
| 23 |
+
def momentNum (p q : ℕ) (b : Bool) (d a : ℝ) : ℝ :=
|
| 24 |
+
∫u in (0:ℝ)..1,weight a u*u^p*((1-u^2)/2)^q*hyper b (u*d)
|
| 25 |
+
|
| 26 |
+
def moment (p q : ℕ) (b : Bool) (z r a : ℝ) : ℝ :=
|
| 27 |
+
momentNum p q b (z-r) a/(Real.cosh z*Real.cosh r)
|
| 28 |
+
|
| 29 |
+
lemma moment_base (z r a : ℝ) : moment 0 0 false z r a=phi z r a := by
|
| 30 |
+
rw [phi_eq]
|
| 31 |
+
simp only [moment,momentNum,numerator,pow_zero,mul_one,hyper,Bool.false_eq_true,ite_false]
|
| 32 |
+
|
| 33 |
+
lemma momentNum_hasDerivAt_d (p q : ℕ) (b : Bool) (d a : ℝ) :
|
| 34 |
+
HasDerivAt (fun d=>momentNum p q b d a) (momentNum (p+1) q (!b) d a) d := by
|
| 35 |
+
unfold momentNum
|
| 36 |
+
apply hasDerivAt_integral01
|
| 37 |
+
(F:=fun d u=>weight a u*u^p*((1-u^2)/2)^q*hyper b (u*d))
|
| 38 |
+
(F':=fun d u=>weight a u*u^(p+1)*((1-u^2)/2)^q*hyper (!b) (u*d))
|
| 39 |
+
· exact (((continuous_weight a).comp continuous_snd).mul (continuous_snd.pow p)|>.mul
|
| 40 |
+
(((continuous_const.sub (continuous_snd.pow 2)).div_const 2).pow q)).mul
|
| 41 |
+
((continuous_hyper b).comp (continuous_snd.mul continuous_fst))
|
| 42 |
+
· exact (((continuous_weight a).comp continuous_snd).mul (continuous_snd.pow (p+1))|>.mul
|
| 43 |
+
(((continuous_const.sub (continuous_snd.pow 2)).div_const 2).pow q)).mul
|
| 44 |
+
((continuous_hyper (!b)).comp (continuous_snd.mul continuous_fst))
|
| 45 |
+
· intro d u
|
| 46 |
+
have H:=((hyper_hasDerivAt b (u*d)).comp d ((hasDerivAt_id d).const_mul u)).const_mul
|
| 47 |
+
(weight a u*u^p*((1-u^2)/2)^q)
|
| 48 |
+
convert! H using 1
|
| 49 |
+
simp only [pow_succ]
|
| 50 |
+
ring
|
| 51 |
+
|
| 52 |
+
lemma momentNum_hasDerivAt_a (p q : ℕ) (b : Bool) (d a : ℝ) :
|
| 53 |
+
HasDerivAt (fun a=>momentNum p q b d a) (momentNum p (q+1) b d a) a := by
|
| 54 |
+
unfold momentNum
|
| 55 |
+
apply hasDerivAt_integral01
|
| 56 |
+
(F:=fun a u=>weight a u*u^p*((1-u^2)/2)^q*hyper b (u*d))
|
| 57 |
+
(F':=fun a u=>weight a u*u^p*((1-u^2)/2)^(q+1)*hyper b (u*d))
|
| 58 |
+
· apply Continuous.mul
|
| 59 |
+
· unfold weight; fun_prop
|
| 60 |
+
· exact (continuous_hyper b).comp (continuous_snd.mul_const d)
|
| 61 |
+
· apply Continuous.mul
|
| 62 |
+
· unfold weight; fun_prop
|
| 63 |
+
· exact (continuous_hyper b).comp (continuous_snd.mul_const d)
|
| 64 |
+
· intro a u
|
| 65 |
+
have H:=((((hasDerivAt_id a).mul_const (1-u^2)).div_const 2).exp).mul_const
|
| 66 |
+
(u^p*((1-u^2)/2)^q*hyper b (u*d))
|
| 67 |
+
convert! H using 1 <;> (try funext x) <;> dsimp [weight] <;> simp only [pow_succ] <;> ring
|
| 68 |
+
|
| 69 |
+
lemma momentNum_abs_le (p q : ℕ) (b : Bool) (d a : ℝ) :
|
| 70 |
+
|momentNum p q b d a|≤ momentNum 0 0 false d a := by
|
| 71 |
+
unfold momentNum
|
| 72 |
+
apply (intervalIntegral.abs_integral_le_integral_abs (by norm_num : (0:ℝ)≤1)).trans
|
| 73 |
+
apply intervalIntegral.integral_mono_on (by norm_num : (0:ℝ)≤1)
|
| 74 |
+
· apply Continuous.intervalIntegrable
|
| 75 |
+
apply Continuous.abs
|
| 76 |
+
exact (((continuous_weight a).mul (continuous_id.pow p)).mul
|
| 77 |
+
(((continuous_const.sub (continuous_id.pow 2)).div_const 2).pow q)).mul
|
| 78 |
+
((continuous_hyper b).comp (continuous_id.mul_const d))
|
| 79 |
+
· apply Continuous.intervalIntegrable
|
| 80 |
+
exact (((continuous_weight a).mul (continuous_id.pow 0)).mul
|
| 81 |
+
(((continuous_const.sub (continuous_id.pow 2)).div_const 2).pow 0)).mul
|
| 82 |
+
((continuous_hyper false).comp (continuous_id.mul_const d))
|
| 83 |
+
· intro u hu
|
| 84 |
+
have hu2 : u^2≤1 := by nlinarith [hu.1,hu.2]
|
| 85 |
+
have hv0 : 0≤(1-u^2)/2 := by linarith
|
| 86 |
+
have hv1 : (1-u^2)/2≤1 := by nlinarith [sq_nonneg u]
|
| 87 |
+
have hp : u^p ≤ 1 := pow_le_one₀ hu.1 hu.2
|
| 88 |
+
have hq : ((1-u^2)/2)^q ≤ 1 := pow_le_one₀ hv0 hv1
|
| 89 |
+
simp only [abs_mul,abs_of_pos (show 0<weight a u from Real.exp_pos _),
|
| 90 |
+
abs_pow,abs_of_nonneg hu.1,abs_of_nonneg hv0,pow_zero,mul_one,
|
| 91 |
+
hyper,Bool.false_eq_true,ite_false]
|
| 92 |
+
have hH:=hyper_abs_le b (u*d)
|
| 93 |
+
change |if b=true then Real.sinh (u*d) else Real.cosh (u*d)|≤Real.cosh (u*d) at hH
|
| 94 |
+
have hprod : u^p*((1-u^2)/2)^q≤1 :=
|
| 95 |
+
(mul_le_mul hp hq (pow_nonneg hv0 q) (by norm_num)).trans_eq (one_mul 1)
|
| 96 |
+
have hh:=mul_le_mul (mul_le_mul_of_nonneg_left hprod (Real.exp_pos (a*(1-u^2)/2)).le)
|
| 97 |
+
hH (abs_nonneg _) (by positivity)
|
| 98 |
+
dsimp [weight] at *
|
| 99 |
+
nlinarith only [hh]
|
| 100 |
+
|
| 101 |
+
lemma moment_relative_bound (p q : ℕ) (b : Bool) (z r a : ℝ) :
|
| 102 |
+
|moment p q b z r a|≤phi z r a := by
|
| 103 |
+
rw [moment,abs_div,abs_of_pos (mul_pos (Real.cosh_pos _) (Real.cosh_pos _)),←moment_base]
|
| 104 |
+
exact div_le_div_of_nonneg_right (momentNum_abs_le p q b (z-r) a)
|
| 105 |
+
(mul_pos (Real.cosh_pos _) (Real.cosh_pos _)).le
|
| 106 |
+
|
| 107 |
+
lemma moment_hasDerivAt_z (p q : ℕ) (b : Bool) (z r a : ℝ) :
|
| 108 |
+
HasDerivAt (fun z=>moment p q b z r a)
|
| 109 |
+
(moment (p+1) q (!b) z r a-Real.tanh z*moment p q b z r a) z := by
|
| 110 |
+
have H:=((momentNum_hasDerivAt_d p q b (z-r) a).comp z ((hasDerivAt_id z).sub_const r)).div
|
| 111 |
+
((Real.hasDerivAt_cosh z).mul_const (Real.cosh r))
|
| 112 |
+
(ne_of_gt (mul_pos (Real.cosh_pos _) (Real.cosh_pos _)))
|
| 113 |
+
convert! H using 1
|
| 114 |
+
dsimp [moment]
|
| 115 |
+
rw [Real.tanh_eq_sinh_div_cosh]
|
| 116 |
+
field_simp [ne_of_gt (Real.cosh_pos z),ne_of_gt (Real.cosh_pos r)]
|
| 117 |
+
|
| 118 |
+
lemma moment_hasDerivAt_r (p q : ℕ) (b : Bool) (z r a : ℝ) :
|
| 119 |
+
HasDerivAt (fun r=>moment p q b z r a)
|
| 120 |
+
(-moment (p+1) q (!b) z r a-Real.tanh r*moment p q b z r a) r := by
|
| 121 |
+
have H:=((momentNum_hasDerivAt_d p q b (z-r) a).comp r ((hasDerivAt_id r).const_sub z)).div
|
| 122 |
+
((Real.hasDerivAt_cosh r).const_mul (Real.cosh z))
|
| 123 |
+
(ne_of_gt (mul_pos (Real.cosh_pos _) (Real.cosh_pos _)))
|
| 124 |
+
convert! H using 1
|
| 125 |
+
dsimp [moment]
|
| 126 |
+
rw [Real.tanh_eq_sinh_div_cosh]
|
| 127 |
+
field_simp [ne_of_gt (Real.cosh_pos z),ne_of_gt (Real.cosh_pos r)]
|
| 128 |
+
|
| 129 |
+
lemma moment_hasDerivAt_a (p q : ℕ) (b : Bool) (z r a : ℝ) :
|
| 130 |
+
HasDerivAt (fun a=>moment p q b z r a) (moment p (q+1) b z r a) a := by
|
| 131 |
+
exact (momentNum_hasDerivAt_a p q b (z-r) a).div_const _
|
| 132 |
+
|
| 133 |
+
end SKGap.Stein
|
| 134 |
+
|
| 135 |
+
end
|
| 136 |
+
end
|
| 137 |
+
|
| 138 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/PhiStein.lean
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Model
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
open MeasureTheory Filter
|
| 10 |
+
open scoped Topology
|
| 11 |
+
namespace SKGap.Stein
|
| 12 |
+
|
| 13 |
+
lemma hasDerivAt_integral01 {F F' : ℝ→ℝ→ℝ}
|
| 14 |
+
(hF : Continuous (fun p : ℝ×ℝ=>F p.1 p.2))
|
| 15 |
+
(hF' : Continuous (fun p : ℝ×ℝ=>F' p.1 p.2))
|
| 16 |
+
(hd : ∀ z u,HasDerivAt (fun z=>F z u) (F' z u) z) (z : ℝ) :
|
| 17 |
+
HasDerivAt (fun z=>∫u in (0:ℝ)..1,F z u) (∫u in (0:ℝ)..1,F' z u) z := by
|
| 18 |
+
obtain ⟨C,hC⟩ := (isCompact_Icc.prod isCompact_Icc).exists_bound_of_continuousOn
|
| 19 |
+
(hF'.continuousOn : ContinuousOn (fun p : ℝ×ℝ=>F' p.1 p.2)
|
| 20 |
+
((Set.Icc (z-1) (z+1))×ˢ(Set.Icc (0:ℝ) 1)))
|
| 21 |
+
have hc (x : ℝ) : Continuous (F x) := hF.comp (continuous_const.prodMk continuous_id)
|
| 22 |
+
have hc' (x : ℝ) : Continuous (F' x) := hF'.comp (continuous_const.prodMk continuous_id)
|
| 23 |
+
exact (intervalIntegral.hasDerivAt_integral_of_dominated_loc_of_deriv_le
|
| 24 |
+
(F:=F) (F':=F') (bound:=fun _=>C)
|
| 25 |
+
(s:=Set.Icc (z-1) (z+1)) (Icc_mem_nhds (by linarith) (by linarith))
|
| 26 |
+
(Eventually.of_forall (fun x=>(hc x).aestronglyMeasurable))
|
| 27 |
+
(hc z|>.intervalIntegrable _ _) (hc' z).aestronglyMeasurable
|
| 28 |
+
(Eventually.of_forall (by
|
| 29 |
+
intro u hu x hx
|
| 30 |
+
rw [Set.uIoc_of_le (by norm_num : (0:ℝ)≤1)] at hu
|
| 31 |
+
exact hC (x,u) ⟨hx,hu.1.le,hu.2⟩))
|
| 32 |
+
intervalIntegrable_const
|
| 33 |
+
(Eventually.of_forall (fun u _ x _=>hd x u))).2
|
| 34 |
+
|
| 35 |
+
def weight (a u : ℝ) : ℝ := Real.exp (a*(1-u^2)/2)
|
| 36 |
+
def numerator (z r a : ℝ) : ℝ := ∫u in (0:ℝ)..1,weight a u*Real.cosh (u*(z-r))
|
| 37 |
+
def numeratorZ (z r a : ℝ) : ℝ := ∫u in (0:ℝ)..1,weight a u*u*Real.sinh (u*(z-r))
|
| 38 |
+
def phi (z r a : ℝ) : ℝ := ∫u in (0:ℝ)..1,
|
| 39 |
+
weight a u*Real.cosh (u*(z-r))/(Real.cosh z*Real.cosh r)
|
| 40 |
+
def phiZ (z r a : ℝ) : ℝ := numeratorZ z r a/(Real.cosh z*Real.cosh r)-Real.tanh z*phi z r a
|
| 41 |
+
|
| 42 |
+
lemma continuous_weight (a : ℝ) : Continuous (weight a) := by unfold weight; fun_prop
|
| 43 |
+
|
| 44 |
+
lemma phi_eq (z r a : ℝ) : phi z r a=numerator z r a/(Real.cosh z*Real.cosh r) := by
|
| 45 |
+
exact intervalIntegral.integral_div _ _
|
| 46 |
+
|
| 47 |
+
lemma numerator_hasDerivAt (z r a : ℝ) :
|
| 48 |
+
HasDerivAt (fun z=>numerator z r a) (numeratorZ z r a) z := by
|
| 49 |
+
unfold numerator numeratorZ
|
| 50 |
+
apply hasDerivAt_integral01 (F:=fun z u=>weight a u*Real.cosh (u*(z-r)))
|
| 51 |
+
(F':=fun z u=>weight a u*u*Real.sinh (u*(z-r)))
|
| 52 |
+
· unfold weight; fun_prop
|
| 53 |
+
· unfold weight; fun_prop
|
| 54 |
+
· intro z u
|
| 55 |
+
convert! ((Real.hasDerivAt_cosh (u*(z-r))).comp z
|
| 56 |
+
(((hasDerivAt_id z).sub_const r).const_mul u)).const_mul (weight a u) using 1
|
| 57 |
+
ring
|
| 58 |
+
|
| 59 |
+
lemma phi_hasDerivAt (z r a : ℝ) : HasDerivAt (fun z=>phi z r a) (phiZ z r a) z := by
|
| 60 |
+
have h := (numerator_hasDerivAt z r a).div
|
| 61 |
+
((Real.hasDerivAt_cosh z).mul_const (Real.cosh r))
|
| 62 |
+
(ne_of_gt (mul_pos (Real.cosh_pos z) (Real.cosh_pos r)))
|
| 63 |
+
convert! h using 1
|
| 64 |
+
· funext x; exact phi_eq x r a
|
| 65 |
+
· rw [phiZ,phi_eq,Real.tanh_eq_sinh_div_cosh]
|
| 66 |
+
field_simp [ne_of_gt (Real.cosh_pos z),ne_of_gt (Real.cosh_pos r)]
|
| 67 |
+
|
| 68 |
+
lemma weight_hasDerivAt (a u : ℝ) : HasDerivAt (weight a) (-a*u*weight a u) u := by
|
| 69 |
+
unfold weight
|
| 70 |
+
convert! (Real.hasDerivAt_exp _).comp u
|
| 71 |
+
((((hasDerivAt_id u).pow 2).const_sub 1).const_mul a |>.div_const 2) using 1
|
| 72 |
+
dsimp
|
| 73 |
+
ring
|
| 74 |
+
|
| 75 |
+
lemma boundary_hasDerivAt (z r a u : ℝ) :
|
| 76 |
+
HasDerivAt (fun u=>weight a u*Real.sinh (u*(z-r)))
|
| 77 |
+
(weight a u*((z-r)*Real.cosh (u*(z-r))-a*u*Real.sinh (u*(z-r)))) u := by
|
| 78 |
+
convert! (weight_hasDerivAt a u).mul
|
| 79 |
+
((Real.hasDerivAt_sinh (u*(z-r))).comp u ((hasDerivAt_id u).mul_const (z-r))) using 1
|
| 80 |
+
dsimp
|
| 81 |
+
ring
|
| 82 |
+
|
| 83 |
+
lemma numerator_boundary (z r a : ℝ) :
|
| 84 |
+
(z-r)*numerator z r a-a*numeratorZ z r a=Real.sinh (z-r) := by
|
| 85 |
+
have hc1 : Continuous (fun u=>weight a u*Real.cosh (u*(z-r))) := by
|
| 86 |
+
exact (continuous_weight a).mul (by fun_prop)
|
| 87 |
+
have hc2 : Continuous (fun u=>weight a u*u*Real.sinh (u*(z-r))) := by
|
| 88 |
+
exact ((continuous_weight a).mul continuous_id).mul (by fun_prop)
|
| 89 |
+
have he : (fun u=>weight a u*((z-r)*Real.cosh (u*(z-r))-a*u*Real.sinh (u*(z-r))))=
|
| 90 |
+
(fun u=>(z-r)*(weight a u*Real.cosh (u*(z-r)))-a*(weight a u*u*Real.sinh (u*(z-r)))) := by
|
| 91 |
+
funext u; ring
|
| 92 |
+
have H:=intervalIntegral.integral_eq_sub_of_hasDerivAt
|
| 93 |
+
(a:=(0:ℝ)) (b:=1) (fun u _=>boundary_hasDerivAt z r a u)
|
| 94 |
+
(show IntervalIntegrable (fun u=>weight a u*((z-r)*Real.cosh (u*(z-r))-a*u*Real.sinh (u*(z-r)))) volume 0 1 from by
|
| 95 |
+
rw [he]; exact ((hc1.const_mul (z-r)).sub (hc2.const_mul a)).intervalIntegrable _ _)
|
| 96 |
+
rw [he,intervalIntegral.integral_sub ((hc1.const_mul (z-r)).intervalIntegrable _ _)
|
| 97 |
+
((hc2.const_mul a).intervalIntegrable _ _),intervalIntegral.integral_const_mul,
|
| 98 |
+
intervalIntegral.integral_const_mul] at H
|
| 99 |
+
simpa only [numerator,numeratorZ,weight,one_pow,sub_self,mul_zero,zero_div,
|
| 100 |
+
Real.exp_zero,one_mul,zero_mul,Real.sinh_zero,sub_zero] using H
|
| 101 |
+
|
| 102 |
+
theorem phi_stein (z r a : ℝ) :
|
| 103 |
+
(z-r-a*Real.tanh z)*phi z r a-a*phiZ z r a=Real.tanh z-Real.tanh r := by
|
| 104 |
+
rw [phiZ,phi_eq]
|
| 105 |
+
have H:=numerator_boundary z r a
|
| 106 |
+
have hId : Real.sinh (z-r)/(Real.cosh z*Real.cosh r)=Real.tanh z-Real.tanh r := by
|
| 107 |
+
rw [Real.sinh_sub,Real.tanh_eq_sinh_div_cosh,Real.tanh_eq_sinh_div_cosh]
|
| 108 |
+
field_simp [ne_of_gt (Real.cosh_pos z),ne_of_gt (Real.cosh_pos r)]
|
| 109 |
+
rw [←hId]
|
| 110 |
+
field_simp [ne_of_gt (Real.cosh_pos z),ne_of_gt (Real.cosh_pos r)]
|
| 111 |
+
nlinarith [H]
|
| 112 |
+
|
| 113 |
+
lemma phi_pos (z r a : ℝ) : 0<phi z r a := by
|
| 114 |
+
apply intervalIntegral.integral_pos (by norm_num : (0:ℝ)<1)
|
| 115 |
+
· apply Continuous.continuousOn; unfold weight
|
| 116 |
+
exact Continuous.div_const (by fun_prop) _
|
| 117 |
+
· intro u _; exact (div_pos (mul_pos (Real.exp_pos _) (Real.cosh_pos _))
|
| 118 |
+
(mul_pos (Real.cosh_pos _) (Real.cosh_pos _))).le
|
| 119 |
+
· exact ⟨0,by norm_num,div_pos (mul_pos (Real.exp_pos _) (Real.cosh_pos _))
|
| 120 |
+
(mul_pos (Real.cosh_pos _) (Real.cosh_pos _))⟩
|
| 121 |
+
|
| 122 |
+
lemma phiZ_at_diagonal (r a : ℝ) : phiZ r r a= -Real.tanh r*phi r r a := by
|
| 123 |
+
simp [phiZ,numeratorZ]
|
| 124 |
+
|
| 125 |
+
lemma phi_stein_deriv (z r a : ℝ) :
|
| 126 |
+
(z-r-a*Real.tanh z)*phi z r a-a*deriv (fun z=>phi z r a) z=Real.tanh z-Real.tanh r := by
|
| 127 |
+
rw [(phi_hasDerivAt z r a).deriv]
|
| 128 |
+
exact phi_stein z r a
|
| 129 |
+
|
| 130 |
+
end SKGap.Stein
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
end
|
| 134 |
+
|
| 135 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/ProductGaussianDensity.lean
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Model
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
open MeasureTheory ProbabilityTheory Matrix
|
| 9 |
+
open scoped BigOperators ENNReal NNReal
|
| 10 |
+
namespace SKGap.GaussianDensity
|
| 11 |
+
variable {ι : Type*} [Fintype ι]
|
| 12 |
+
|
| 13 |
+
theorem pi_gaussian_density (m : ι → ℝ) (v : ι → ℝ≥0) (hv : ∀ i,v i ≠ 0) :
|
| 14 |
+
Measure.pi (fun i => gaussianReal (m i) (v i)) =
|
| 15 |
+
(volume : Measure (ι → ℝ)).withDensity (fun x => ENNReal.ofReal (∏ i,gaussianPDFReal (m i) (v i) (x i))) := by
|
| 16 |
+
apply Measure.pi_eq
|
| 17 |
+
intro s hs
|
| 18 |
+
rw [withDensity_apply _ (MeasurableSet.univ_pi hs)]
|
| 19 |
+
have hi : Integrable (fun x : ι → ℝ => ∏ i,gaussianPDFReal (m i) (v i) (x i))
|
| 20 |
+
(volume.restrict (Set.univ.pi s)) := by
|
| 21 |
+
exact (Integrable.fintype_prod (fun i => integrable_gaussianPDFReal (m i) (v i))).restrict
|
| 22 |
+
rw [← ofReal_integral_eq_lintegral_ofReal hi (Filter.Eventually.of_forall
|
| 23 |
+
(fun x => Finset.prod_nonneg (fun i _ => gaussianPDFReal_nonneg _ _ _)))]
|
| 24 |
+
change ENNReal.ofReal (∫ x, (∏ i,gaussianPDFReal (m i) (v i) (x i))
|
| 25 |
+
∂(Measure.pi (fun _ : ι => (volume : Measure ℝ))).restrict (Set.univ.pi s))=_
|
| 26 |
+
rw [Measure.restrict_pi_pi,integral_fintype_prod_eq_prod,
|
| 27 |
+
ENNReal.ofReal_prod_of_nonneg (fun i _ => integral_nonneg (fun x => gaussianPDFReal_nonneg _ _ _))]
|
| 28 |
+
apply Finset.prod_congr rfl
|
| 29 |
+
intro i _
|
| 30 |
+
rw [gaussianReal_of_var_ne_zero _ (hv i),withDensity_apply _ (hs i)]
|
| 31 |
+
exact ofReal_integral_eq_lintegral_ofReal (integrable_gaussianPDFReal (m i) (v i)).restrict
|
| 32 |
+
(Filter.Eventually.of_forall (gaussianPDFReal_nonneg _ _))
|
| 33 |
+
|
| 34 |
+
lemma measurable_productPDF (m : ι → ℝ) (v : ι → ℝ≥0) :
|
| 35 |
+
Measurable (fun x : ι → ℝ => ENNReal.ofReal (∏ i,gaussianPDFReal (m i) (v i) (x i))) := by
|
| 36 |
+
fun_prop
|
| 37 |
+
|
| 38 |
+
end SKGap.GaussianDensity
|
| 39 |
+
end
|
| 40 |
+
end
|
| 41 |
+
|
| 42 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/RegressionMoments.lean
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Gaussian.GaussianDisintegration
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace SKGap.GaussianRegression
|
| 9 |
+
open MeasureTheory ProbabilityTheory Matrix
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {Ω ι κ : Type*} [MeasurableSpace Ω] [Fintype ι] [Fintype κ]
|
| 12 |
+
{P : Measure Ω} {X : Ω → ι → ℝ} {Y : Ω → κ → ℝ}
|
| 13 |
+
|
| 14 |
+
lemma residual_mean_zero (hXY : HasGaussianLaw (fun w => (X w,Y w)) P)
|
| 15 |
+
(K : Matrix ι κ ℝ) (hx : ∀ i, (∫ w, X w i ∂P)=0)
|
| 16 |
+
(hy : ∀ k, (∫ w, Y w k ∂P)=0) (i : ι) :
|
| 17 |
+
(∫ w, (X w-K*ᵥY w) i ∂P)=0 := by
|
| 18 |
+
have hK : Integrable (fun w => ∑ k,K i k*Y w k) P :=
|
| 19 |
+
((hXY.snd.map (matrixCLM K)).eval i).integrable
|
| 20 |
+
change (∫ w, X w i-∑ k, K i k*Y w k ∂P)=0
|
| 21 |
+
rw [integral_sub (hXY.fst.eval i).integrable hK,
|
| 22 |
+
integral_finsetSum _ (fun k _ => (hXY.snd.eval k).integrable.const_mul _)]
|
| 23 |
+
simp only [integral_const_mul,hx,hy,mul_zero,Finset.sum_const_zero,sub_zero]
|
| 24 |
+
|
| 25 |
+
lemma residual_cross_covariance (hXY : HasGaussianLaw (fun w => (X w,Y w)) P)
|
| 26 |
+
(K : Matrix ι κ ℝ)
|
| 27 |
+
(hc : ∀ i k, cov[fun w => X w i,fun w => Y w k;P]=
|
| 28 |
+
∑ l, K i l*cov[fun w => Y w l,fun w => Y w k;P]) (i : ι) (k : κ) :
|
| 29 |
+
cov[fun w => (X w-K*ᵥY w) i,fun w => Y w k;P]=0 := by
|
| 30 |
+
have := hXY.isProbabilityMeasure
|
| 31 |
+
have hK : MemLp (fun w => ∑ l,K i l*Y w l) 2 P :=
|
| 32 |
+
((hXY.snd.map (matrixCLM K)).eval i).memLp_two
|
| 33 |
+
change cov[fun w => X w i-∑ l,K i l*Y w l,fun w => Y w k;P]=0
|
| 34 |
+
rw [covariance_fun_sub_left (hXY.fst.eval i).memLp_two hK (hXY.snd.eval k).memLp_two,
|
| 35 |
+
covariance_fun_sum_left (fun l => (hXY.snd.eval l).memLp_two.const_mul _) (hXY.snd.eval k).memLp_two]
|
| 36 |
+
simp only [covariance_const_mul_left,hc,sub_self]
|
| 37 |
+
|
| 38 |
+
lemma residual_covariance (hXY : HasGaussianLaw (fun w => (X w,Y w)) P)
|
| 39 |
+
(K : Matrix ι κ ℝ)
|
| 40 |
+
(hc : ∀ i k, cov[fun w => X w i,fun w => Y w k;P]=
|
| 41 |
+
∑ l, K i l*cov[fun w => Y w l,fun w => Y w k;P]) (i k : ι) :
|
| 42 |
+
cov[fun w => (X w-K*ᵥY w) i,fun w => (X w-K*ᵥY w) k;P]=
|
| 43 |
+
cov[fun w => X w i,fun w => X w k;P]-
|
| 44 |
+
∑ l, K i l*cov[fun w => Y w l,fun w => X w k;P] := by
|
| 45 |
+
have := hXY.isProbabilityMeasure
|
| 46 |
+
have hR := (residual_joint_gaussian hXY K).fst
|
| 47 |
+
have hK (q : ι) : MemLp (fun w => ∑ l,K q l*Y w l) 2 P :=
|
| 48 |
+
((hXY.snd.map (matrixCLM K)).eval q).memLp_two
|
| 49 |
+
change cov[fun w => (X w-K*ᵥY w) i,fun w => X w k-∑ l,K k l*Y w l;P]=_
|
| 50 |
+
rw [covariance_fun_sub_right (hR.eval i).memLp_two (hXY.fst.eval k).memLp_two (hK k),
|
| 51 |
+
covariance_fun_sum_right (fun l => (hXY.snd.eval l).memLp_two.const_mul _) (hR.eval i).memLp_two]
|
| 52 |
+
simp only [covariance_const_mul_right,residual_cross_covariance hXY K hc,mul_zero,
|
| 53 |
+
Finset.sum_const_zero,sub_zero]
|
| 54 |
+
change cov[fun w => X w i-∑ l,K i l*Y w l,fun w => X w k;P]=_
|
| 55 |
+
rw [covariance_fun_sub_left (hXY.fst.eval i).memLp_two (hK i) (hXY.fst.eval k).memLp_two,
|
| 56 |
+
covariance_fun_sum_left (fun l => (hXY.snd.eval l).memLp_two.const_mul _) (hXY.fst.eval k).memLp_two]
|
| 57 |
+
simp only [covariance_const_mul_left]
|
| 58 |
+
|
| 59 |
+
end SKGap.GaussianRegression
|
| 60 |
+
end
|
| 61 |
+
end
|
| 62 |
+
|
| 63 |
+
end OAI
|
lean/OAI/Probability/SKGap/Gaussian/ReplicaTailWeight.lean
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
import OAI.Probability.SKGap.Localization.LogPartitionDeviationProbability
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
section
|
| 7 |
+
open scoped BigOperators
|
| 8 |
+
open scoped BigOperators
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open scoped BigOperators NNReal
|
| 13 |
+
open MeasureTheory ProbabilityTheory
|
| 14 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 15 |
+
open scoped BigOperators NNReal
|
| 16 |
+
open MeasureTheory ProbabilityTheory
|
| 17 |
+
open scoped BigOperators NNReal ENNReal
|
| 18 |
+
open MeasureTheory ProbabilityTheory Filter
|
| 19 |
+
open scoped BigOperators NNReal ENNReal
|
| 20 |
+
namespace SKGapCutoff
|
| 21 |
+
|
| 22 |
+
noncomputable def replicaTailWeight {n : ℕ} (J : Interaction n) (ε : ℝ) : ℝ :=
|
| 23 |
+
∑ x : Spin n, ∑ y : Spin n, if ε * n < |replicaOverlap x y| then
|
| 24 |
+
Real.exp (energy J x + energy J y) else 0
|
| 25 |
+
|
| 26 |
+
noncomputable def replicaTail {n : ℕ} (J : Interaction n) (ε : ℝ) : ℝ :=
|
| 27 |
+
∑ x : Spin n, ∑ y : Spin n, if ε * n < |replicaOverlap x y| then
|
| 28 |
+
gibbs J x * gibbs J y else 0
|
| 29 |
+
|
| 30 |
+
lemma replicaTailWeight_nonneg {n : ℕ} (J : Interaction n) (ε : ℝ) :
|
| 31 |
+
0 ≤ replicaTailWeight J ε := by
|
| 32 |
+
apply Finset.sum_nonneg
|
| 33 |
+
intro x _
|
| 34 |
+
apply Finset.sum_nonneg
|
| 35 |
+
intro y _
|
| 36 |
+
split_ifs <;> positivity
|
| 37 |
+
|
| 38 |
+
lemma replicaTail_eq_ratio {n : ℕ} (J : Interaction n) (ε : ℝ) :
|
| 39 |
+
replicaTail J ε = replicaTailWeight J ε / partition J ^ 2 := by
|
| 40 |
+
unfold replicaTail replicaTailWeight gibbs
|
| 41 |
+
simp_rw [Finset.sum_div]
|
| 42 |
+
apply Finset.sum_congr rfl
|
| 43 |
+
intro x _
|
| 44 |
+
apply Finset.sum_congr rfl
|
| 45 |
+
intro y _
|
| 46 |
+
split_ifs
|
| 47 |
+
· rw [Real.exp_add]
|
| 48 |
+
ring
|
| 49 |
+
· simp
|
| 50 |
+
|
| 51 |
+
lemma replicaTail_nonneg {n : ℕ} (J : Interaction n) (ε : ℝ) :
|
| 52 |
+
0 ≤ replicaTail J ε := by
|
| 53 |
+
rw [replicaTail_eq_ratio]
|
| 54 |
+
exact div_nonneg (replicaTailWeight_nonneg J ε) (sq_nonneg _)
|
| 55 |
+
|
| 56 |
+
lemma replicaTailWeight_le_partition_sq {n : ℕ} (J : Interaction n) (ε : ℝ) :
|
| 57 |
+
replicaTailWeight J ε ≤ partition J ^ 2 := by
|
| 58 |
+
rw [partition_sq_eq_sum]
|
| 59 |
+
apply Finset.sum_le_sum
|
| 60 |
+
intro x _
|
| 61 |
+
apply Finset.sum_le_sum
|
| 62 |
+
intro y _
|
| 63 |
+
split_ifs
|
| 64 |
+
· exact le_rfl
|
| 65 |
+
· positivity
|
| 66 |
+
|
| 67 |
+
lemma replicaTail_le_one {n : ℕ} (J : Interaction n) (ε : ℝ) :
|
| 68 |
+
replicaTail J ε ≤ 1 := by
|
| 69 |
+
rw [replicaTail_eq_ratio, div_le_one (sq_pos_of_pos (partition_pos J))]
|
| 70 |
+
exact replicaTailWeight_le_partition_sq J ε
|
| 71 |
+
|
| 72 |
+
lemma integrable_replicaTailWeight (β ε : ℝ) (n : ℕ) :
|
| 73 |
+
Integrable (fun g => replicaTailWeight (sampledInteraction g) ε) (disorderLaw β n) := by
|
| 74 |
+
apply integrable_finsetSum
|
| 75 |
+
intro x _
|
| 76 |
+
apply integrable_finsetSum
|
| 77 |
+
intro y _
|
| 78 |
+
by_cases h : ε * n < |replicaOverlap x y|
|
| 79 |
+
· simp only [h, ite_true]
|
| 80 |
+
exact integrable_exp_combined_energy β x y
|
| 81 |
+
· simp only [h, ite_false]
|
| 82 |
+
exact integrable_zero _ ℝ _
|
| 83 |
+
|
| 84 |
+
lemma integral_replicaTailWeight (β ε : ℝ) {n : ℕ} (hn : 0 < n) :
|
| 85 |
+
(∫ g, replicaTailWeight (sampledInteraction g) ε ∂disorderLaw β n) =
|
| 86 |
+
Real.exp (β^2*((n : ℝ)-2)/2) *
|
| 87 |
+
∑ x : Spin n, ∑ y : Spin n, if ε*n < |replicaOverlap x y| then
|
| 88 |
+
Real.exp (β^2 * replicaOverlap x y ^ 2 / (2*n)) else 0 := by
|
| 89 |
+
have hi (x y : Spin n) : Integrable (fun g =>
|
| 90 |
+
if ε*n < |replicaOverlap x y| then
|
| 91 |
+
Real.exp (energy (sampledInteraction g) x + energy (sampledInteraction g) y)
|
| 92 |
+
else 0) (disorderLaw β n) := by
|
| 93 |
+
split_ifs
|
| 94 |
+
· exact integrable_exp_combined_energy β x y
|
| 95 |
+
· exact integrable_zero _ ℝ _
|
| 96 |
+
unfold replicaTailWeight
|
| 97 |
+
rw [integral_finsetSum _ (fun x _ => integrable_finsetSum _ (fun y _ => hi x y))]
|
| 98 |
+
simp_rw [integral_finsetSum _ (fun y _ => hi _ y), Finset.mul_sum]
|
| 99 |
+
apply Finset.sum_congr rfl
|
| 100 |
+
intro x _
|
| 101 |
+
apply Finset.sum_congr rfl
|
| 102 |
+
intro y _
|
| 103 |
+
split_ifs
|
| 104 |
+
· rw [integral_exp_combined_energy β hn, Real.exp_add]
|
| 105 |
+
· simp
|
| 106 |
+
|
| 107 |
+
lemma replicaTailWeight_annealed_identity (β ε : ℝ) {n : ℕ} (hn : 0 < n) :
|
| 108 |
+
(∫ g, replicaTailWeight (sampledInteraction g) ε ∂disorderLaw β n) /
|
| 109 |
+
(∫ g, partition (sampledInteraction g) ∂disorderLaw β n)^2 =
|
| 110 |
+
Real.exp (-β^2/2) *
|
| 111 |
+
(∑ x : Spin n, if ε*n < |magnetization x| then
|
| 112 |
+
Real.exp (β^2 * magnetization x ^ 2 / (2*n)) else 0) / (2 : ℝ)^n := by
|
| 113 |
+
rw [integral_replicaTailWeight β ε hn, integral_partition_sampled β hn]
|
| 114 |
+
simp_rw [sum_replicaOverlap _ (fun z => if ε*n < |z| then Real.exp (β^2*z^2/(2*n)) else 0)]
|
| 115 |
+
simp only [Finset.sum_const, Finset.card_univ, card_spin, nsmul_eq_mul,
|
| 116 |
+
Nat.cast_pow, Nat.cast_ofNat, mul_pow]
|
| 117 |
+
have he : Real.exp (β^2*((n : ℝ)-2)/2) =
|
| 118 |
+
Real.exp (-β^2/2) * Real.exp (β^2*((n : ℝ)-1)/4)^2 := by
|
| 119 |
+
rw [← Real.exp_nat_mul, ← Real.exp_add]
|
| 120 |
+
congr 1
|
| 121 |
+
ring
|
| 122 |
+
rw [he]
|
| 123 |
+
field_simp
|
| 124 |
+
|
| 125 |
+
lemma sign_square_tail_le (β q ε : ℝ) (hβq : β^2 < q) (hq : q < 1)
|
| 126 |
+
(hε : 0 < ε) {n : ℕ} (hn : 0 < n) :
|
| 127 |
+
(∑ x : Spin n, if ε*n < |magnetization x| then
|
| 128 |
+
Real.exp (β^2 * magnetization x ^ 2 / (2*n)) else 0) / (2 : ℝ)^n ≤
|
| 129 |
+
Real.exp (-((q-β^2)*ε^2*n/2)) * (Real.sqrt (1-q))⁻¹ := by
|
| 130 |
+
have hq0 : 0 ≤ q := (sq_nonneg β).trans hβq.le
|
| 131 |
+
have hqβ : 0 ≤ q-β^2 := sub_nonneg.mpr hβq.le
|
| 132 |
+
have hnR : 0 < (n : ℝ) := by exact_mod_cast hn
|
| 133 |
+
have hs := sign_square_moment_le (Real.sqrt q) (by rwa [Real.sq_sqrt hq0]) hn
|
| 134 |
+
rw [Real.sq_sqrt hq0] at hs
|
| 135 |
+
have hpoint (x : Spin n) :
|
| 136 |
+
(if ε*n < |magnetization x| then Real.exp (β^2 * magnetization x ^ 2 / (2*n)) else 0) ≤
|
| 137 |
+
Real.exp (-((q-β^2)*ε^2*n/2)) * Real.exp (q * magnetization x ^ 2 / (2*n)) := by
|
| 138 |
+
split_ifs with hx
|
| 139 |
+
· rw [← Real.exp_add]
|
| 140 |
+
apply Real.exp_le_exp.mpr
|
| 141 |
+
have hsq : ε^2 * (n : ℝ)^2 ≤ magnetization x ^ 2 := by
|
| 142 |
+
have h := (sq_le_sq₀ (by positivity : 0 ≤ ε*(n : ℝ)) (abs_nonneg _)).mpr hx.le
|
| 143 |
+
simpa only [mul_pow, sq_abs] using h
|
| 144 |
+
have hm := mul_le_mul_of_nonneg_left hsq hqβ
|
| 145 |
+
have hd : (q-β^2)*ε^2*n/2 ≤ (q-β^2) * magnetization x ^ 2 / (2*n) := by
|
| 146 |
+
apply (le_div_iff₀ (by positivity : 0 < (2 : ℝ)*n)).mpr
|
| 147 |
+
nlinarith
|
| 148 |
+
rw [sub_mul q (β^2) (magnetization x^2), sub_div] at hd
|
| 149 |
+
linarith
|
| 150 |
+
· positivity
|
| 151 |
+
calc
|
| 152 |
+
_ ≤ (∑ x : Spin n, Real.exp (-((q-β^2)*ε^2*n/2)) *
|
| 153 |
+
Real.exp (q * magnetization x ^ 2 / (2*n))) / (2 : ℝ)^n :=
|
| 154 |
+
div_le_div_of_nonneg_right (Finset.sum_le_sum fun x _ => hpoint x) (by positivity)
|
| 155 |
+
_ = Real.exp (-((q-β^2)*ε^2*n/2)) *
|
| 156 |
+
((∑ x : Spin n, Real.exp (q * magnetization x^2/(2*n))) / (2 : ℝ)^n) := by
|
| 157 |
+
rw [← Finset.mul_sum]
|
| 158 |
+
ring
|
| 159 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left hs (Real.exp_pos _).le
|
| 160 |
+
|
| 161 |
+
lemma replicaTailWeight_annealed_bound (β q ε : ℝ) (hβq : β^2 < q) (hq : q < 1)
|
| 162 |
+
(hε : 0 < ε) {n : ℕ} (hn : 0 < n) :
|
| 163 |
+
(∫ g, replicaTailWeight (sampledInteraction g) ε ∂disorderLaw β n) /
|
| 164 |
+
(∫ g, partition (sampledInteraction g) ∂disorderLaw β n)^2 ≤
|
| 165 |
+
Real.exp (-((q-β^2)*ε^2*n/2)) * (Real.sqrt (1-q))⁻¹ := by
|
| 166 |
+
rw [replicaTailWeight_annealed_identity β ε hn, mul_div_assoc]
|
| 167 |
+
have he : Real.exp (-β^2/2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg β])
|
| 168 |
+
calc
|
| 169 |
+
_ ≤ Real.exp (-β^2/2) * (Real.exp (-((q-β^2)*ε^2*n/2)) * (Real.sqrt (1-q))⁻¹) :=
|
| 170 |
+
mul_le_mul_of_nonneg_left (sign_square_tail_le β q ε hβq hq hε hn) (Real.exp_pos _).le
|
| 171 |
+
_ ≤ _ := by simpa only [one_mul] using mul_le_mul_of_nonneg_right he (by positivity)
|
| 172 |
+
|
| 173 |
+
lemma probability_markov_real {E : Type*} [MeasurableSpace E] (μ : Measure E)
|
| 174 |
+
[IsFiniteMeasure μ] (Y : E → ℝ) (hY : Integrable Y μ) (hY0 : ∀ x, 0 ≤ Y x)
|
| 175 |
+
(t : ℝ) (ht : 0 < t) :
|
| 176 |
+
μ {x | t ≤ Y x} ≤ ENNReal.ofReal ((∫ x, Y x ∂μ) / t) := by
|
| 177 |
+
have h := mul_meas_ge_le_integral_of_nonneg (μ := μ)
|
| 178 |
+
(Filter.Eventually.of_forall hY0) hY t
|
| 179 |
+
rw [mul_comm t, ← le_div_iff₀ ht] at h
|
| 180 |
+
rw [← ENNReal.ofReal_toReal (measure_ne_top μ _)]
|
| 181 |
+
exact ENNReal.ofReal_le_ofReal h
|
| 182 |
+
|
| 183 |
+
lemma scalar_log_ratio_tail (Z m W δ a : ℝ) (hZ0 : 0 < Z) (hm : 0 < m)
|
| 184 |
+
(hδ : 0 < δ) (hlog : Real.log m-a ≤ Real.log Z) (hW : δ < W/Z^2) :
|
| 185 |
+
δ * Real.exp (-2*a) ≤ W/m^2 := by
|
| 186 |
+
have hZ : m * Real.exp (-a) ≤ Z := by
|
| 187 |
+
have he := Real.exp_le_exp.mpr hlog
|
| 188 |
+
rw [show Real.log m-a = Real.log m + (-a) by ring, Real.exp_add,
|
| 189 |
+
Real.exp_log hm, Real.exp_log hZ0] at he
|
| 190 |
+
exact he
|
| 191 |
+
have hZ2 := pow_le_pow_left₀ (mul_nonneg hm.le (Real.exp_pos _).le) hZ 2
|
| 192 |
+
have he : (m * Real.exp (-a))^2 = m^2 * Real.exp (-2*a) := by
|
| 193 |
+
rw [mul_pow, ← Real.exp_nat_mul]
|
| 194 |
+
congr 2
|
| 195 |
+
ring
|
| 196 |
+
rw [he] at hZ2
|
| 197 |
+
rw [lt_div_iff₀ (sq_pos_of_pos hZ0)] at hW
|
| 198 |
+
apply (le_div_iff₀ (sq_pos_of_pos hm)).mpr
|
| 199 |
+
nlinarith [mul_le_mul_of_nonneg_left hZ2 hδ.le]
|
| 200 |
+
|
| 201 |
+
lemma divide_exponential_scalar (W m δ a : ℝ) :
|
| 202 |
+
(W/m^2) / (δ*Real.exp (-2*a)) = (Real.exp (2*a)/δ) * (W/m^2) := by
|
| 203 |
+
rw [show -2*a = -(2*a) by ring, Real.exp_neg]
|
| 204 |
+
simp only [div_eq_mul_inv, mul_inv_rev, inv_inv]
|
| 205 |
+
ring
|
| 206 |
+
|
| 207 |
+
lemma replicaTail_probability_transfer (β ε δ a : ℝ) {n : ℕ} (hn : 0 < n)
|
| 208 |
+
(hδ : 0 < δ) :
|
| 209 |
+
(disorderLaw β n) {g | δ < replicaTail (sampledInteraction g) ε} ≤
|
| 210 |
+
(disorderLaw β n) {g | Real.log (partition (sampledInteraction g)) <
|
| 211 |
+
Real.log (∫ h, partition (sampledInteraction h) ∂disorderLaw β n) - a} +
|
| 212 |
+
ENNReal.ofReal ((Real.exp (2*a)/δ) *
|
| 213 |
+
((∫ g, replicaTailWeight (sampledInteraction g) ε ∂disorderLaw β n) /
|
| 214 |
+
(∫ g, partition (sampledInteraction g) ∂disorderLaw β n)^2)) := by
|
| 215 |
+
let μ := disorderLaw β n
|
| 216 |
+
let : IsProbabilityMeasure μ := by dsimp [μ, disorderLaw]; infer_instance
|
| 217 |
+
let m := ∫ g, partition (sampledInteraction g) ∂μ
|
| 218 |
+
have hm : 0 < m := by dsimp [m, μ]; rw [integral_partition_sampled β hn]; positivity
|
| 219 |
+
let Y := fun g : GaussianCoordinates n => replicaTailWeight (sampledInteraction g) ε / m^2
|
| 220 |
+
let t := δ * Real.exp (-2*a)
|
| 221 |
+
have ht : 0 < t := by dsimp [t]; positivity
|
| 222 |
+
have hY : Integrable Y μ := (integrable_replicaTailWeight β ε n).div_const _
|
| 223 |
+
have hY0 (g) : 0 ≤ Y g := div_nonneg (replicaTailWeight_nonneg _ ε) (sq_nonneg _)
|
| 224 |
+
have hsub : {g | δ < replicaTail (sampledInteraction g) ε} ⊆
|
| 225 |
+
{g | Real.log (partition (sampledInteraction g)) < Real.log m - a} ∪ {g | t ≤ Y g} := by
|
| 226 |
+
intro g hg
|
| 227 |
+
by_cases hl : Real.log (partition (sampledInteraction g)) < Real.log m - a
|
| 228 |
+
· exact Or.inl hl
|
| 229 |
+
right
|
| 230 |
+
change δ * Real.exp (-2*a) ≤ replicaTailWeight (sampledInteraction g) ε / m^2
|
| 231 |
+
apply scalar_log_ratio_tail _ _ _ _ _ (partition_pos _) hm hδ (le_of_not_gt hl)
|
| 232 |
+
rwa [← replicaTail_eq_ratio]
|
| 233 |
+
have hmarkov := probability_markov_real μ Y hY hY0 t ht
|
| 234 |
+
have hid : (∫ g, Y g ∂μ) / t = (Real.exp (2*a)/δ) *
|
| 235 |
+
((∫ g, replicaTailWeight (sampledInteraction g) ε ∂μ) / m^2) := by
|
| 236 |
+
dsimp [Y, t]
|
| 237 |
+
rw [integral_div, divide_exponential_scalar]
|
| 238 |
+
rw [hid] at hmarkov
|
| 239 |
+
exact (measure_mono hsub).trans ((measure_union_le _ _).trans
|
| 240 |
+
(add_le_add le_rfl hmarkov))
|
| 241 |
+
|
| 242 |
+
lemma replicaTail_disorder_probability_bound (β q ε δ : ℝ) (hβq : β^2 < q)
|
| 243 |
+
(hq : q < 1) (hε : 0 < ε) (hδ : 0 < δ) {n : ℕ} (hn : 0 < n) :
|
| 244 |
+
(disorderLaw β n) {g | δ < replicaTail (sampledInteraction g) ε} ≤
|
| 245 |
+
(disorderLaw β n) {g | (q-β^2)*ε^2/8 <
|
| 246 |
+
|(Real.log (partition (sampledInteraction g)) -
|
| 247 |
+
Real.log (∫ h, partition (sampledInteraction h) ∂disorderLaw β n)) / n|} +
|
| 248 |
+
ENNReal.ofReal (((Real.sqrt (1-q))⁻¹ / δ) * Real.exp (-((q-β^2)*ε^2*n/4))) := by
|
| 249 |
+
have hnR : 0 < (n : ℝ) := by exact_mod_cast hn
|
| 250 |
+
have h := replicaTail_probability_transfer β ε δ ((q-β^2)*ε^2*n/8) hn hδ
|
| 251 |
+
apply h.trans
|
| 252 |
+
apply add_le_add
|
| 253 |
+
· apply measure_mono
|
| 254 |
+
intro g hg
|
| 255 |
+
have hd : (Real.log (partition (sampledInteraction g)) -
|
| 256 |
+
Real.log (∫ h, partition (sampledInteraction h) ∂disorderLaw β n)) / n <
|
| 257 |
+
-((q-β^2)*ε^2/8) := by
|
| 258 |
+
apply (div_lt_iff₀ hnR).mpr
|
| 259 |
+
change Real.log (partition (sampledInteraction g)) < _ at hg
|
| 260 |
+
linarith
|
| 261 |
+
change (q-β^2)*ε^2/8 < _
|
| 262 |
+
linarith [neg_le_abs ((Real.log (partition (sampledInteraction g)) -
|
| 263 |
+
Real.log (∫ h, partition (sampledInteraction h) ∂disorderLaw β n)) / n)]
|
| 264 |
+
· apply ENNReal.ofReal_le_ofReal
|
| 265 |
+
calc
|
| 266 |
+
_ ≤ (Real.exp (2*((q-β^2)*ε^2*n/8))/δ) *
|
| 267 |
+
(Real.exp (-((q-β^2)*ε^2*n/2)) * (Real.sqrt (1-q))⁻¹) :=
|
| 268 |
+
mul_le_mul_of_nonneg_left (replicaTailWeight_annealed_bound β q ε hβq hq hε hn)
|
| 269 |
+
(by positivity)
|
| 270 |
+
_ = _ := by
|
| 271 |
+
have he : Real.exp (2*((q-β^2)*ε^2*(n : ℝ)/8)) *
|
| 272 |
+
Real.exp (-((q-β^2)*ε^2*n/2)) = Real.exp (-((q-β^2)*ε^2*n/4)) := by
|
| 273 |
+
rw [← Real.exp_add]
|
| 274 |
+
congr 1
|
| 275 |
+
ring
|
| 276 |
+
calc
|
| 277 |
+
_ = (Real.exp (2*((q-β^2)*ε^2*(n : ℝ)/8)) *
|
| 278 |
+
Real.exp (-((q-β^2)*ε^2*n/2))) * (Real.sqrt (1-q))⁻¹ / δ := by ring
|
| 279 |
+
_ = _ := by rw [he]; ring
|
| 280 |
+
|
| 281 |
+
lemma replica_overlap_vanishes (β : ℝ) (hβ : β^2 < 1) (ε : ℝ) (hε : 0 < ε) :
|
| 282 |
+
DisorderLimit β (fun _ J => replicaTail J ε) 0 := by
|
| 283 |
+
intro δ hδ
|
| 284 |
+
let q := (β^2+1)/2
|
| 285 |
+
have hβq : β^2 < q := by dsimp [q]; linarith
|
| 286 |
+
have hq : q < 1 := by dsimp [q]; linarith
|
| 287 |
+
have ha : 0 < (q-β^2)*ε^2/8 := by positivity
|
| 288 |
+
have hb : 0 < (q-β^2)*ε^2/4 := by positivity
|
| 289 |
+
have hlog := log_partition_annealed_difference_limit β hβ ((q-β^2)*ε^2/8) ha
|
| 290 |
+
simp only [sub_zero] at hlog
|
| 291 |
+
have hexp : Tendsto (fun n : ℕ => Real.exp (-((q-β^2)*ε^2*n/4))) atTop (nhds 0) := by
|
| 292 |
+
have hlin := (tendsto_natCast_atTop_atTop : Tendsto (fun n : ℕ => (n : ℝ)) atTop atTop)
|
| 293 |
+
|>.const_mul_atTop hb
|
| 294 |
+
have he := Real.tendsto_exp_neg_atTop_nhds_zero.comp hlin
|
| 295 |
+
convert he using 1
|
| 296 |
+
ext n
|
| 297 |
+
congr 1
|
| 298 |
+
ring
|
| 299 |
+
have hbound : Tendsto (fun n : ℕ => ENNReal.ofReal (((Real.sqrt (1-q))⁻¹/δ) *
|
| 300 |
+
Real.exp (-((q-β^2)*ε^2*n/4)))) atTop (nhds 0) := by
|
| 301 |
+
simpa only [Function.comp_def, mul_zero, ENNReal.ofReal_zero] using
|
| 302 |
+
ENNReal.continuous_ofReal.continuousAt.tendsto.comp (hexp.const_mul ((Real.sqrt (1-q))⁻¹/δ))
|
| 303 |
+
have hsum := hlog.add hbound
|
| 304 |
+
simp only [zero_add] at hsum
|
| 305 |
+
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hsum
|
| 306 |
+
(Eventually.of_forall (fun _ => bot_le))
|
| 307 |
+
filter_upwards [eventually_ge_atTop 1] with n hn
|
| 308 |
+
simpa only [sub_zero, abs_of_nonneg (replicaTail_nonneg _ _)] using
|
| 309 |
+
replicaTail_disorder_probability_bound β q ε δ hβq hq hε hδ (by omega : 0 < n)
|
| 310 |
+
|
| 311 |
+
end SKGapCutoff
|
| 312 |
+
|
| 313 |
+
open MeasureTheory ProbabilityTheory
|
| 314 |
+
open scoped BigOperators Matrix Matrix.Norms.Elementwise
|
| 315 |
+
|
| 316 |
+
end
|
| 317 |
+
|
| 318 |
+
end OAI
|