Download data/lean/OAI/Probability/SKGap/Entropy/ParameterMapWeight.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Entropy/ParameterMapWeight.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/SKGap/Entropy/ParameterMapWeight.lean
-
curl -L -o ParameterMapWeight.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Entropy/ParameterMapWeight.lean
13.3 kB
| import Mathlib | |
| import OAI.Probability.SKGap.Entropy.ExponentiallyRare | |
| namespace OAI | |
| section | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| open scoped BigOperators | |
| open scoped BigOperators NNReal | |
| open MeasureTheory ProbabilityTheory | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators NNReal | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators NNReal ENNReal | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators NNReal ENNReal | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators Matrix Matrix.Norms.Elementwise | |
| open scoped BigOperators | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators Matrix Matrix.Norms.Elementwise | |
| open scoped BigOperators | |
| open scoped BigOperators NNReal ENNReal | |
| open MeasureTheory Metric Set | |
| open scoped BigOperators NNReal ENNReal | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Matrix.Norms.L2Operator | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Matrix Matrix.Norms.Elementwise | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators ENNReal NNReal | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators NNReal ENNReal Matrix | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators ENNReal NNReal | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators NNReal ENNReal | |
| open scoped BigOperators | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal | |
| open scoped BigOperators | |
| open Filter Topology | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped NNReal ENNReal BigOperators Topology | |
| open MeasureTheory ProbabilityTheory Filter | |
| open Matrix | |
| open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators NNReal ENNReal Topology | |
| namespace SKGapCutoff.Regression | |
| theorem ExponentialEmpiricalConcentration.parameter_map_weight | |
| {E F A : Type*} [PseudoMetricSpace E] [MeasurableSpace E] [BorelSpace E] | |
| [PseudoMetricSpace F] [MeasurableSpace F] [BorelSpace F] [PseudoMetricSpace A] | |
| {H : β β Type*} [β n, MeasurableSpace (H n)] | |
| {Ο : β n, Measure (H n)} {X : β n, H n β Fin n β E} {Ξ½ : Measure E} | |
| (hX : ExponentialEmpiricalConcentration Ο X Ξ½) | |
| (C : β n, H n β A) (c : A) (hC : ExponentialConvergence Ο C c) | |
| (g : A β E β F) {L : ββ₯0} (hg : LipschitzWith L (g c)) | |
| (W : E β β) (D : β) (hD : 0 < D) | |
| (hgc : β a x, dist (g a x) (g c x) β€ dist a c * W x) | |
| (hrare : ExponentiallyRare Ο (fun n => {h | D β€ (β i, W (X n h i))/(n:β)})) : | |
| ExponentialEmpiricalConcentration Ο (fun n h i => g (C n h) (X n h i)) | |
| (Ξ½.map (g c)) := by | |
| have hxmap := hX.map (g c) hg | |
| intro f K hf B hB Ξ΅ hΞ΅ | |
| have hs : ExponentiallyRare Ο (fun n => {h | Ξ΅/2 β€ | |
| |(β i, f (g c (X n h i)))/(n:β) - β« x, f x βΞ½.map (g c)|}) := | |
| hxmap f K hf B hB (Ξ΅/2) (by positivity) | |
| let Ξ΄ := Ξ΅/(2*((K:β)*D+1)) | |
| have hΞ΄ : 0 < Ξ΄ := by dsimp [Ξ΄]; positivity | |
| apply ((hs.union (hC Ξ΄ hΞ΄)).union hrare).mono | |
| filter_upwards [eventually_ge_atTop 1] with n hn | |
| intro h hh | |
| by_cases hb : Ξ΅/2 β€ |(β i, f (g c (X n h i)))/(n:β) - β« x, f x βΞ½.map (g c)| | |
| Β· exact Or.inl (Or.inl hb) | |
| by_cases hcnot : Ξ΄ β€ dist (C n h) c | |
| Β· exact Or.inl (Or.inr hcnot) | |
| apply Or.inr | |
| by_contra hlarge | |
| have hcclose : dist (C n h) c < Ξ΄ := lt_of_not_ge hcnot | |
| have hsmall : (β i, W (X n h i))/(n:β) < D := lt_of_not_ge hlarge | |
| have hnR : (0:β) < n := Nat.cast_pos.mpr hn | |
| have hdiff : |(β i, f (g (C n h) (X n h i)))/(n:β) - | |
| (β i, f (g c (X n h i)))/(n:β)| β€ (K:β)*dist (C n h) c*D := by | |
| rw [β sub_div, β Finset.sum_sub_distrib, abs_div, abs_of_pos hnR] | |
| calc | |
| |β i, (f (g (C n h) (X n h i))-f (g c (X n h i)))|/(n:β) β€ | |
| (β i, |f (g (C n h) (X n h i))-f (g c (X n h i))|)/(n:β) := by | |
| gcongr | |
| exact Finset.abs_sum_le_sum_abs _ _ | |
| _ β€ (β i : Fin n, (K:β)*dist (C n h) c*W (X n h i))/(n:β) := by | |
| gcongr with i | |
| exact (hf.dist_le_mul _ _).trans | |
| (by calc | |
| (K:β)*dist (g (C n h) (X n h i)) (g c (X n h i)) β€ | |
| (K:β)*(dist (C n h) c*W (X n h i)) := | |
| mul_le_mul_of_nonneg_left (hgc _ _) K.coe_nonneg | |
| _ = (K:β)*dist (C n h) c*W (X n h i) := by ring) | |
| _ = (K:β)*dist (C n h) c*((β i, W (X n h i))/(n:β)) := by | |
| rw [β Finset.mul_sum]; ring | |
| _ β€ (K:β)*dist (C n h) c*D := | |
| mul_le_mul_of_nonneg_left hsmall.le (mul_nonneg K.coe_nonneg dist_nonneg) | |
| have hΞ΄bound : (K:β)*Ξ΄*D β€ Ξ΅/2 := by | |
| dsimp [Ξ΄] | |
| have hp : 0 < 2*((K:β)*D+1) := by positivity | |
| apply (le_div_iffβ (by norm_num : (0:β)<2)).mpr | |
| field_simp | |
| nlinarith [mul_nonneg K.coe_nonneg hD.le] | |
| have hstep : (K:β)*dist (C n h) c*D β€ Ξ΅/2 := | |
| (mul_le_mul_of_nonneg_right | |
| (mul_le_mul_of_nonneg_left hcclose.le K.coe_nonneg) hD.le).trans hΞ΄bound | |
| have ht := abs_add_le | |
| ((β i, f (g (C n h) (X n h i)))/(n:β) - (β i, f (g c (X n h i)))/(n:β)) | |
| ((β i, f (g c (X n h i)))/(n:β) - β« x, f x βΞ½.map (g c)) | |
| rw [sub_add_sub_cancel] at ht | |
| have hb' := lt_of_not_ge hb | |
| exact (not_lt_of_ge hh) (ht.trans_lt (by linarith)) | |
| lemma average_lipschitz_metric_sq {E : Type*} [PseudoMetricSpace E] | |
| {n : β} (hn : 0 < n) (f : E β β) {K : ββ₯0} (hf : LipschitzWith K f) | |
| (v w : Fin n β E) : | |
| |((β i, f (v i))-(β i, f (w i)))/(n:β)|^2 β€ | |
| (K:β)^2 * (β i, (dist (v i) (w i))^2)/(n:β) := by | |
| have hnR : (0:β) < n := Nat.cast_pos.mpr hn | |
| rw [sq_abs, div_pow, β Finset.sum_sub_distrib] | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ | |
| (fun i : Fin n => (1:β)) (fun i => f (v i)-f (w i)) | |
| simp only [one_mul, one_pow, Finset.sum_const, Finset.card_univ, | |
| Fintype.card_fin, nsmul_eq_mul, mul_one] at hcs | |
| have hsite (i : Fin n) : (f (v i)-f (w i))^2 β€ (K:β)^2*(dist (v i) (w i))^2 := by | |
| have h := hf.dist_le_mul (v i) (w i) | |
| rw [Real.dist_eq] at h | |
| have hs := mul_self_le_mul_self (abs_nonneg _) h | |
| simpa [β pow_two, mul_pow] using hs | |
| apply (div_le_iffβ (sq_pos_of_pos hnR)).mpr | |
| calc | |
| _ β€ (n:β) * β i, (f (v i)-f (w i))^2 := hcs | |
| _ β€ (n:β) * β i, (K:β)^2*(dist (v i) (w i))^2 := | |
| mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun i _ => hsite i)) hnR.le | |
| _ = _ := by rw [β Finset.mul_sum]; field_simp | |
| theorem ExponentialEmpiricalConcentration.l2_stability | |
| {E : Type*} [PseudoMetricSpace E] [MeasurableSpace E] | |
| {H : β β Type*} [β n, MeasurableSpace (H n)] | |
| {Ο : β n, Measure (H n)} {X Y : β n, H n β Fin n β E} {Ξ½ : Measure E} | |
| (hX : ExponentialEmpiricalConcentration Ο X Ξ½) | |
| (hXY : ExponentialConvergence Ο | |
| (fun n h => (β i, (dist (X n h i) (Y n h i))^2)/(n:β)) 0) : | |
| ExponentialEmpiricalConcentration Ο Y Ξ½ := by | |
| intro f K hf B hB Ξ΅ hΞ΅ | |
| have hs : ExponentiallyRare Ο (fun n => {h | Ξ΅/2 β€ | |
| |(β i, f (X n h i))/(n:β) - β« x, f x βΞ½|}) := | |
| hX f K hf B hB (Ξ΅/2) (by positivity) | |
| let Ξ΄ := Ξ΅^2/(4*((K:β)^2+1)) | |
| have hΞ΄ : 0 < Ξ΄ := by dsimp [Ξ΄]; positivity | |
| apply (hs.union (hXY Ξ΄ hΞ΄)).mono | |
| filter_upwards [eventually_ge_atTop 1] with n hn | |
| intro h hh | |
| by_cases hb : Ξ΅/2 β€ |(β i, f (X n h i))/(n:β) - β« x, f x βΞ½| | |
| Β· exact Or.inl hb | |
| apply Or.inr | |
| by_contra hbad | |
| have hclose : (β i, (dist (X n h i) (Y n h i))^2)/(n:β) < Ξ΄ := by | |
| change ¬δ β€ dist ((β i, (dist (X n h i) (Y n h i))^2)/(n:β)) 0 at hbad | |
| have hk := lt_of_not_ge hbad | |
| simpa only [Real.dist_eq, sub_zero, abs_of_nonneg (by positivity : | |
| 0 β€ (β i, (dist (X n h i) (Y n h i))^2)/(n:β))] using hk | |
| have hbound := average_lipschitz_metric_sq hn f hf (X n h) (Y n h) | |
| rw [mul_div_assoc] at hbound | |
| have hΞ΄bound : (K:β)^2*Ξ΄ < Ξ΅^2/4 := by | |
| dsimp [Ξ΄] | |
| have hp : 0 < 4*((K:β)^2+1) := by positivity | |
| apply (lt_div_iffβ (by norm_num : (0:β)<4)).mpr | |
| field_simp | |
| nlinarith [sq_pos_of_pos hΞ΅] | |
| have hsmall : |(β i, f (X n h i))/(n:β) - (β i, f (Y n h i))/(n:β)| < Ξ΅/2 := by | |
| rw [β sub_div] | |
| have ht : |((β i, f (X n h i))-(β i, f (Y n h i)))/(n:β)|^2 < Ξ΅^2/4 := | |
| hbound.trans_lt ((mul_le_mul_of_nonneg_left hclose.le (sq_nonneg _)).trans_lt hΞ΄bound) | |
| nlinarith [abs_nonneg (((β i, f (X n h i))-(β i, f (Y n h i)))/(n:β))] | |
| have ht := abs_add_le | |
| ((β i, f (Y n h i))/(n:β) - (β i, f (X n h i))/(n:β)) | |
| ((β i, f (X n h i))/(n:β) - β« x, f x βΞ½) | |
| rw [sub_add_sub_cancel, abs_sub_comm ((β i, f (Y n h i))/(n:β)) | |
| ((β i, f (X n h i))/(n:β))] at ht | |
| have hb' := lt_of_not_ge hb | |
| exact (not_lt_of_ge hh) (ht.trans_lt (by linarith)) | |
| lemma ExponentialConvergence.dominated_zero | |
| {H : β β Type*} [β n, MeasurableSpace (H n)] | |
| {Ο : β n, Measure (H n)} {X Y : β n, H n β β} | |
| (hX : ExponentialConvergence Ο X 0) {A : β n, Set (H n)} | |
| (hA : ExponentiallyRare Ο A) (B : β) (hB : 0 β€ B) | |
| (hXY : βαΆ n in atTop, β h β A n, |Y n h| β€ B*|X n h|) : | |
| ExponentialConvergence Ο Y 0 := by | |
| intro Ξ΅ hΞ΅ | |
| let Ξ΄ := Ξ΅/(B+1) | |
| have hΞ΄ : 0 < Ξ΄ := by dsimp [Ξ΄]; positivity | |
| apply (hA.union (hX Ξ΄ hΞ΄)).mono | |
| filter_upwards [hXY] with n hn | |
| intro h hh | |
| by_cases ha : h β A n | |
| Β· exact Or.inl ha | |
| apply Or.inr | |
| by_contra hx | |
| change ¬δ †dist (X n h) 0 at hx | |
| have hx' : |X n h| < Ξ΄ := by simpa only [Real.dist_eq, sub_zero] using lt_of_not_ge hx | |
| have hy : Ξ΅ β€ |Y n h| := by simpa only [Set.mem_ofPred_eq, Real.dist_eq, sub_zero] using hh | |
| have hΞ΄B : B*Ξ΄ < Ξ΅ := by | |
| dsimp [Ξ΄] | |
| rw [β mul_div_assoc] | |
| apply (div_lt_iffβ (by positivity : 0 < B+1)).mpr | |
| nlinarith | |
| exact (not_lt_of_ge hy) ((hn h ha).trans_lt | |
| ((mul_le_mul_of_nonneg_left hx'.le hB).trans_lt hΞ΄B)) | |
| theorem ExponentialConvergence.operator_omit | |
| {H E F : β β Type*} [β n, MeasurableSpace (H n)] | |
| [β n, NormedAddCommGroup (E n)] [β n, NormedSpace β (E n)] | |
| [β n, NormedAddCommGroup (F n)] [β n, NormedSpace β (F n)] | |
| {Ο : β n, Measure (H n)} (A : β n, H n β E n βL[β] F n) | |
| (X : β n, H n β E n) | |
| (hX : ExponentialConvergence Ο (fun n h => βX n hβ^2/(n:β)) 0) | |
| (M : β) | |
| (hA : ExponentiallyRare Ο (fun n => {h | M β€ βA n hβ})) : | |
| ExponentialConvergence Ο (fun n h => βA n h (X n h)β^2/(n:β)) 0 := by | |
| apply hX.dominated_zero hA (M^2) (sq_nonneg _) | |
| refine Filter.Eventually.of_forall ?_ | |
| intro n h hn | |
| have ha : βA n hβ < M := lt_of_not_ge hn | |
| rw [abs_of_nonneg (by positivity : 0 β€ βA n h (X n h)β^2/(n:β)), | |
| abs_of_nonneg (by positivity : 0 β€ βX n hβ^2/(n:β)), β mul_div_assoc] | |
| apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) | |
| calc | |
| βA n h (X n h)β^2 β€ (M*βX n hβ)^2 := | |
| pow_le_pow_leftβ (norm_nonneg _) ((A n h).le_opNorm (X n h) |>.trans | |
| (mul_le_mul_of_nonneg_right ha.le (norm_nonneg _))) 2 | |
| _ = _ := by ring | |
| lemma empirical_quadratic_expansion {n : β} {ΞΉ : Type*} [Fintype ΞΉ] | |
| (f : ΞΉ β Fin n β β) (c : ΞΉ β β) : | |
| (β a, (β i, c i*f i a)^2)/(n:β) = | |
| β i, β j, c i*((β a, f i a*f j a)/(n:β))*c j := by | |
| calc | |
| _ = (β i, β j, β a, c i*f i a*(c j*f j a))/(n:β) := by | |
| congr 1 | |
| simp only [pow_two, Finset.sum_mul, Finset.mul_sum] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| ring | |
| _ = _ := by | |
| simp_rw [Finset.sum_div, Finset.mul_sum, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| ring | |
| lemma ExponentialEmpiricalConcentration.linear_combination_second_moment | |
| {E : Type*} [PseudoMetricSpace E] [MeasurableSpace E] | |
| {H : β β Type*} [β n, MeasurableSpace (H n)] | |
| {Ο : β n, Measure (H n)} {X : β n, H n β Fin n β E} {Ξ½ : Measure E} | |
| (hX : ExponentialEmpiricalConcentration Ο X Ξ½) | |
| {ΞΉ : Type*} [Fintype ΞΉ] (f : ΞΉ β E β β) {K B : ββ₯0} | |
| (hf : β i, LipschitzWith K (f i)) (hB : β i x, |f i x| β€ B) | |
| (C : β n, H n β ΞΉ β β) (c : ΞΉ β β) (hC : ExponentialConvergence Ο C c) : | |
| ExponentialConvergence Ο (fun n h => (β a, (β i, C n h i*f i (X n h a))^2)/(n:β)) | |
| (β i, β j, c i*(β« x, f i x*f j x βΞ½)*c j) := by | |
| have hc : Continuous (fun z : (ΞΉ β ΞΉ β β) Γ (ΞΉ β β) => | |
| β i, β j, z.2 i*z.1 i j*z.2 j) := by fun_prop | |
| have hh := ((hX.gram f hf hB).prod hC).continuous_map hc.continuousAt | |
| simpa only [empirical_quadratic_expansion] using hh | |
| end SKGapCutoff.Regression | |
| open MeasureTheory ProbabilityTheory Filter Matrix | |
| open scoped NNReal ENNReal BigOperators Topology | |
| end | |
| end OAI | |