Download data/lean/OAI/Probability/Perceptron/Sphere/SphereLimit.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Sphere/SphereLimit.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Perceptron/Sphere/SphereLimit.lean
-
curl -L -o SphereLimit.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Sphere/SphereLimit.lean
14.9 kB
| import Mathlib | |
| import OAI.Probability.Perceptron.Variational.ShellBridge | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped ENNReal NNReal Topology BigOperators BoundedContinuousFunction | |
| namespace SphericalPerceptronFreeEnergy | |
| def normalizedCoordinateSphereLog (n k : β) (Ο : β β β) | |
| (p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k) : β := | |
| coordinateAngularLog n k Ο (Real.sqrt (n+1:β)) ((fun i _ => p.1 i),p.2) / ((n+1:β):β) | |
| def expectedCoordinateSphereLog (n k : β) (Ο : β β β) (z : Fin k β β) (r : ββ₯0) : β := | |
| β« p, normalizedCoordinateSphereLog n k Ο p βcoordinateCascadeLaw (n+1) k z r | |
| lemma normalizedCoordinateSphereLog_measurable (n k : β) (Ο : β β β) : | |
| Measurable (normalizedCoordinateSphereLog n k Ο) := by | |
| have hm := (coordinateAngularLog_measurable n k Ο (Real.sqrt (n+1:β))).comp | |
| (show Measurable (fun p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k => | |
| ((fun (i : Fin (n+1)) (_ : β) => p.1 i),p.2)) from by fun_prop) | |
| exact hm.div_const _ | |
| lemma normalizedCoordinateSphereLog_integrable (n k : β) (Ο : β β β) {b : β} | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (hp : 0 < quadraticCascadePrecision Ο b k z) (r : ββ₯0) : | |
| Integrable (normalizedCoordinateSphereLog n k Ο) (coordinateCascadeLaw (n+1) k z r) := | |
| (coordinateAngularLog_integrable n k Ο (Real.sqrt (n+1:β)) z hz hz0 hz1 hp r).div_const _ | |
| lemma normalizedCoordinateSphereLog_nonneg (n k : β) (Ο : β β β) {b : β} | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (hp : 0 < quadraticCascadePrecision Ο b k z) (r : ββ₯0) : | |
| 0 β€α΅[coordinateCascadeLaw (n+1) k z r] normalizedCoordinateSphereLog n k Ο := by | |
| have hb : 0 < b := hp.trans_le (quadraticCascadePrecision_le Ο b k z (fun i => (hz0 i).le)) | |
| filter_upwards [canonicalCoordinateBase_pos (n+1) k Ο z hz hz0 hz1 r, | |
| canonicalCoordinateTotal_pos (n+1) k Ο b z hz hz0 hz1 hp r] with p h0 hc | |
| exact div_nonneg (coordinateAngularLog_regular n k Ο _ hb _ h0 hc).2.1 (by positivity) | |
| lemma expectedCoordinateSphereLog_upper (n k : β) (Ο : β β β) {b Ξ΅ : β} | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (hp : 0 < quadraticCascadePrecision Ο b k z) (r : ββ₯0) | |
| (hΞ΅ : 0 β€ Ξ΅) (hΞ΅1 : Ξ΅ β€ 1) | |
| (hm : 0 < (canonicalRadialMass n b).real (normSquareBand n Ξ΅)) : | |
| expectedCoordinateSphereLog n k Ο z r β€ | |
| (1+Ξ΅)*canonicalGaussianFreeValue Ο k z r b- | |
| Real.log ((canonicalRadialMass n b).real (normSquareBand n Ξ΅))/((n+1:β):β)+ | |
| Ξ΅*(Real.log b/2+2*b) := by | |
| let ΞΌ := coordinateCascadeLaw (n+1) k z r | |
| let C := fun p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k => | |
| canonicalCoordinateLog (n+1) k Ο b ((fun i _ => p.1 i),p.2) | |
| let M := Real.log ((canonicalRadialMass n b).real (normSquareBand n Ξ΅)) | |
| let d : β := n+1 | |
| have hd : 0 < d := by dsimp [d]; positivity | |
| have hb : 0 < b := hp.trans_le (quadraticCascadePrecision_le Ο b k z (fun i => (hz0 i).le)) | |
| have hi : Integrable C ΞΌ := (canonical_coordinate_joint_mean (n+1) Ο b k z hz hz0 hz1 hp r).1 | |
| have he : (β« p, C p βΞΌ) = d*canonicalGaussianFreeValue Ο k z r b := by | |
| simpa [d,C,ΞΌ,coordinateCascadeLaw] using (canonical_coordinate_joint_mean (n+1) Ο b k z hz hz0 hz1 hp r).2 | |
| have hni := normalizedCoordinateSphereLog_integrable n k Ο z hz hz0 hz1 hp r | |
| have hbi : Integrable (fun p => (1+Ξ΅)*C p/d-M/d+Ξ΅*(Real.log b/2+2*b)) ΞΌ := | |
| (((hi.const_mul (1+Ξ΅)).div_const d).sub (integrable_const _)).add (integrable_const _) | |
| have hlo : βα΅ p βΞΌ, normalizedCoordinateSphereLog n k Ο p β€ | |
| (1+Ξ΅)*C p/d-M/d+Ξ΅*(Real.log b/2+2*b) := by | |
| filter_upwards [canonicalCoordinateBase_pos (n+1) k Ο z hz hz0 hz1 r, | |
| canonicalCoordinateTotal_pos (n+1) k Ο b z hz hz0 hz1 hp r] with p h0 hc | |
| have hraw := canonicalCoordinate_unitSphere_upper n k Ο hb hΞ΅ hΞ΅1 _ h0 hc hm | |
| have hh := div_le_div_of_nonneg_right hraw hd.le | |
| have heq : ((1+Ξ΅)*C p-M+Ξ΅*((n+1:β):β)*(Real.log b/2+2*b))/d = | |
| (1+Ξ΅)*C p/d-M/d+Ξ΅*(Real.log b/2+2*b) := by | |
| dsimp only [d] | |
| push_cast | |
| field_simp | |
| change coordinateAngularLog n k Ο (Real.sqrt (n+1:β)) ((fun i _ => p.1 i),p.2)/d β€ | |
| ((1+Ξ΅)*C p-M+Ξ΅*((n+1:β):β)*(Real.log b/2+2*b))/d at hh | |
| rw [heq] at hh | |
| simpa only [normalizedCoordinateSphereLog,d,Nat.cast_add,Nat.cast_one] using hh | |
| have hh := integral_mono_ae hni hbi hlo | |
| have hcalc : (β« p, (1+Ξ΅)*C p/d-M/d+Ξ΅*(Real.log b/2+2*b) βΞΌ) = | |
| (1+Ξ΅)*canonicalGaussianFreeValue Ο k z r b-M/d+Ξ΅*(Real.log b/2+2*b) := by | |
| rw [integral_add (f := fun p => (1+Ξ΅)*C p/d-M/d) | |
| (g := fun _ => Ξ΅*(Real.log b/2+2*b)) | |
| (((hi.const_mul (1+Ξ΅)).div_const d).sub (integrable_const (M/d))) | |
| (integrable_const (Ξ΅*(Real.log b/2+2*b))), | |
| integral_sub (f := fun p => (1+Ξ΅)*C p/d) (g := fun _ => M/d) | |
| ((hi.const_mul (1+Ξ΅)).div_const d) (integrable_const (M/d)), | |
| integral_div,integral_const_mul,he] | |
| simp only [integral_const,probReal_univ,one_smul] | |
| field_simp | |
| rw [hcalc] at hh | |
| simpa [expectedCoordinateSphereLog,M,d] using hh | |
| lemma expectedCoordinateSphereLog_upper_eventually (k : β) (Ο : β β β) {b Ξ΅ : β} | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (hp : 0 < quadraticCascadePrecision Ο b k z) (r : ββ₯0) (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ < 1) : | |
| βαΆ n : β in atTop, expectedCoordinateSphereLog n k Ο z r β€ | |
| canonicalGaussianFreeValue Ο k z r b+(b-1)/2+ | |
| Ξ΅*(canonicalGaussianFreeValue Ο k z r b+Real.log b/2+2*b+|1-b|/2)+ | |
| Real.log 2/((n+1:β):β) := by | |
| have hb : 0 < b := hp.trans_le (quadraticCascadePrecision_le Ο b k z (fun i => (hz0 i).le)) | |
| filter_upwards [canonicalRadial_band_eventually_half hΞ΅ hΞ΅1] with n hn | |
| have hm := (canonicalRadial_band_mass_bounds n hb hn).1 | |
| have hmp : 0 < (canonicalRadialMass n b).real (normSquareBand n Ξ΅) := | |
| (by positivity : 0 < Real.exp (((n+1:β):β)*((1-b)/2-|1-b| * Ξ΅/2))/2).trans_le hm | |
| have hu := expectedCoordinateSphereLog_upper n k Ο z hz hz0 hz1 hp r hΞ΅.le hΞ΅1.le hmp | |
| have hl := (canonicalRadial_band_log_bounds n hb hn).1 | |
| linarith | |
| lemma normalizedCoordinateSphereLog_lower_probability (k : β) (Ο : β β β) | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (r : ββ₯0) (b : β) (hp : 0 < quadraticCascadePrecision Ο b k z) | |
| (hstat : -1/(2*b)+quadraticCascadeReciprocalSlope Ο b k z- | |
| (r:β)/(2*(quadraticCascadePrecision Ο b k z)^2) = -1/2) | |
| {Ξ΅ a : β} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ < 1) | |
| (ha : a < canonicalGaussianFreeValue Ο k z r b+(b-1)/2- | |
| Ξ΅*(canonicalGaussianFreeValue Ο k z r b+Real.log b/2+2*b+|1-b|/2)) : | |
| Tendsto (fun n : β => (coordinateCascadeLaw (n+1) k z r).real | |
| {p | a β€ normalizedCoordinateSphereLog n k Ο p}) atTop (π 1) := by | |
| let C := canonicalGaussianFreeValue Ο k z r b | |
| let K := Real.log b/2+2*b | |
| let L := C+(b-1)/2-Ξ΅*(C+K+|1-b|/2) | |
| let Ξ΄ := L-a | |
| have hΞ΄ : 0 < Ξ΄ := by | |
| apply sub_pos.mpr | |
| simpa [L,C,K,add_assoc] using ha | |
| let ΞΌ := fun n => coordinateCascadeLaw (n+1) k z r | |
| let F := fun n (p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k) => | |
| canonicalCoordinateLog (n+1) k Ο b ((fun i _ => p.1 i),p.2) | |
| let B := fun n => {p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k | | |
| (canonicalCoordinateBandTotalE n k Ο b Ξ΅ ((fun i _ => p.1 i),p.2)).toReal < | |
| decoratedTerminalTotal (canonicalCoordinateStep (n+1) Ο) | |
| (canonicalCoordinatePotential (n+1) b) k ((fun i _ => p.1 i),p.2)/2} | |
| let D := fun n => {p : (Fin (n+1) β β) Γ DecoratedCascade (Fin (n+1) β β) k | | |
| (Ξ΄/2)*((n+1:β):β) β€ |F n p-((n+1:β):β)*C|} | |
| have hB : Tendsto (fun n => ΞΌ n (B n)) atTop (π 0) := | |
| canonicalCoordinate_bad_half_band_tendsto_zero k Ο z hz hz0 hz1 r b hp hstat hΞ΅ | |
| have hD : Tendsto (fun n => ΞΌ n (D n)) atTop (π 0) := | |
| (canonical_coordinate_converges Ο b k z hz hz0 hz1 hp r (half_pos hΞ΄)).comp | |
| (tendsto_add_atTop_nat 1) | |
| have hsum := hB.add hD | |
| simp only [add_zero] at hsum | |
| have ht : Tendsto (fun n : β => Real.log 2/((n+1:β):β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1)) | |
| have hev : βαΆ n : β in atTop, Real.log 2/((n+1:β):β) < Ξ΄/2 := | |
| ht.eventually (gt_mem_nhds (half_pos hΞ΄)) | |
| have hb : 0 < b := hp.trans_le (quadraticCascadePrecision_le Ο b k z (fun i => (hz0 i).le)) | |
| have hbad : Tendsto (fun n => ΞΌ n {p | normalizedCoordinateSphereLog n k Ο p < a}) atTop (π 0) := by | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hsum | |
| (Eventually.of_forall (fun _ => bot_le)) | |
| filter_upwards [hev,canonicalRadial_band_eventually_half hΞ΅ hΞ΅1] with n hn hhalf | |
| apply le_trans (measure_mono_ae (t := B n βͺ D n) ?_) (measure_union_le _ _) | |
| filter_upwards [canonicalCoordinateBase_pos (n+1) k Ο z hz hz0 hz1 r, | |
| canonicalCoordinateTotal_pos (n+1) k Ο b z hz hz0 hz1 hp r] with p h0 hc | |
| intro hbad | |
| by_cases hpB : p β B n | |
| Β· exact Or.inl hpB | |
| Β· right | |
| by_contra hpD | |
| have hm := (canonicalRadial_band_mass_bounds n hb hhalf).1 | |
| have hmp : 0 < (canonicalRadialMass n b).real (normSquareBand n Ξ΅) := | |
| (by positivity : 0 < Real.exp (((n+1:β):β)*((1-b)/2-|1-b| * Ξ΅/2))/2).trans_le hm | |
| have hu := (canonicalRadial_band_log_bounds n hb hhalf).2 | |
| have hraw := canonicalCoordinate_unitSphere_lower n k Ο hb hΞ΅.le hΞ΅1.le _ h0 hc hmp | |
| (le_of_not_gt hpB) | |
| have hd : 0 < ((n+1:β):β) := by positivity | |
| have hlow := (div_le_div_of_nonneg_right hraw hd.le) | |
| have herr : |F n p-((n+1:β):β)*C| < (Ξ΄/2)*((n+1:β):β) := not_le.mp hpD | |
| have herr' : C-Ξ΄/2 < F n p/((n+1:β):β) := by | |
| apply (lt_div_iffβ hd).mpr | |
| have hh := (abs_lt.mp herr).1 | |
| nlinarith | |
| have he : ((1-Ξ΅)*F n p-Real.log 2- | |
| Real.log ((canonicalRadialMass n b).real (normSquareBand n Ξ΅))- | |
| Ξ΅*((n+1:β):β)*K)/((n+1:β):β) = | |
| (1-Ξ΅)*(F n p/((n+1:β):β))-Real.log 2/((n+1:β):β)- | |
| Real.log ((canonicalRadialMass n b).real (normSquareBand n Ξ΅))/((n+1:β):β)-Ξ΅*K := by | |
| field_simp | |
| change ((1-Ξ΅)*F n p-Real.log 2- | |
| Real.log ((canonicalRadialMass n b).real (normSquareBand n Ξ΅))- | |
| Ξ΅*((n+1:β):β)*K)/((n+1:β):β) β€ normalizedCoordinateSphereLog n k Ο p at hlow | |
| rw [he] at hlow | |
| have hmule := mul_lt_mul_of_pos_left herr' (sub_pos.mpr hΞ΅1) | |
| have haeq : a = L-Ξ΄ := by dsimp [Ξ΄]; ring | |
| change normalizedCoordinateSphereLog n k Ο p < a at hbad | |
| dsimp only [L] at haeq | |
| nlinarith [mul_nonneg hΞ΅.le hΞ΄.le] | |
| have hreal : Tendsto (fun n => (ΞΌ n).real {p | normalizedCoordinateSphereLog n k Ο p < a}) atTop (π 0) := by | |
| exact (ENNReal.tendsto_toReal (by simp : (0:ββ₯0β) β β€)).comp hbad | |
| have hone : Tendsto (fun n => 1-(ΞΌ n).real {p | normalizedCoordinateSphereLog n k Ο p < a}) atTop (π 1) := by | |
| simpa using (tendsto_const_nhds (x := (1:β))).sub hreal | |
| convert hone using 1 | |
| ext n | |
| have hmeas : MeasurableSet {p | normalizedCoordinateSphereLog n k Ο p < a} := | |
| measurableSet_lt (normalizedCoordinateSphereLog_measurable n k Ο) measurable_const | |
| rw [β probReal_compl_eq_one_sub hmeas] | |
| congr 1 | |
| ext p | |
| simp only [mem_compl_iff,mem_ofPred_eq,not_lt] | |
| lemma expectedCoordinateSphereLog_lower_eventually (k : β) (Ο : β β β) | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (r : ββ₯0) (b : β) (hp : 0 < quadraticCascadePrecision Ο b k z) | |
| (hstat : -1/(2*b)+quadraticCascadeReciprocalSlope Ο b k z- | |
| (r:β)/(2*(quadraticCascadePrecision Ο b k z)^2) = -1/2) | |
| {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ < 1) : | |
| β a : β, a < canonicalGaussianFreeValue Ο k z r b+(b-1)/2- | |
| Ξ΅*(canonicalGaussianFreeValue Ο k z r b+Real.log b/2+2*b+|1-b|/2) β | |
| βαΆ n : β in atTop, a < expectedCoordinateSphereLog n k Ο z r := by | |
| apply expected_eventually_gt_of_probability_lower | |
| (fun n => coordinateCascadeLaw (n+1) k z r) (fun n => normalizedCoordinateSphereLog n k Ο) | |
| (fun n => normalizedCoordinateSphereLog_integrable n k Ο z hz hz0 hz1 hp r) | |
| (fun n => normalizedCoordinateSphereLog_nonneg n k Ο z hz hz0 hz1 hp r) | |
| exact fun a ha => normalizedCoordinateSphereLog_lower_probability k Ο z hz hz0 hz1 r b hp hstat hΞ΅ hΞ΅1 ha | |
| theorem expectedCoordinateSphereLog_tendsto (k : β) (Ο : β β β) | |
| (z : Fin k β β) (hz : StrictMono z) (hz0 : β i, 0 < z i) (hz1 : β i, z i < 1) | |
| (r : ββ₯0) (b : β) (hp : 0 < quadraticCascadePrecision Ο b k z) | |
| (hstat : -1/(2*b)+quadraticCascadeReciprocalSlope Ο b k z- | |
| (r:β)/(2*(quadraticCascadePrecision Ο b k z)^2) = -1/2) : | |
| Tendsto (fun n : β => expectedCoordinateSphereLog n k Ο z r) atTop | |
| (π (canonicalGaussianFreeValue Ο k z r b+(b-1)/2)) := by | |
| let T := canonicalGaussianFreeValue Ο k z r b+(b-1)/2 | |
| let A := canonicalGaussianFreeValue Ο k z r b+Real.log b/2+2*b+|1-b|/2 | |
| let e := fun j : β => 1/((j+1:β):β) | |
| have he : Tendsto e atTop (π 0) := | |
| tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1)) | |
| have he0 : β j, 0 < e j := by intro j; dsimp [e]; positivity | |
| have he1 : βαΆ j in atTop, e j < 1 := he.eventually (gt_mem_nhds zero_lt_one) | |
| have hl : Tendsto (fun j => T-e j*A) atTop (π T) := by | |
| simpa using tendsto_const_nhds.sub (he.mul_const A) | |
| have hu : Tendsto (fun j => T+e j*A) atTop (π T) := by | |
| simpa using tendsto_const_nhds.add (he.mul_const A) | |
| apply tendsto_order.mpr | |
| constructor | |
| Β· intro a ha | |
| obtain β¨j,hj1,hjaβ© := (he1.and (hl.eventually (lt_mem_nhds ha))).exists | |
| exact expectedCoordinateSphereLog_lower_eventually k Ο z hz hz0 hz1 r b hp hstat (he0 j) hj1 a hja | |
| Β· intro a ha | |
| obtain β¨j,hj1,hjaβ© := (he1.and (hu.eventually (gt_mem_nhds ha))).exists | |
| have ht : Tendsto (fun n : β => T+e j*A+Real.log 2/((n+1:β):β)) atTop (π (T+e j*A)) := by | |
| have hh : Tendsto (fun n : β => Real.log 2/((n+1:β):β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop (tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1)) | |
| simpa using tendsto_const_nhds.add hh | |
| filter_upwards [expectedCoordinateSphereLog_upper_eventually k Ο z hz hz0 hz1 hp r (he0 j) hj1, | |
| ht.eventually (gt_mem_nhds hja)] with n hn hn' | |
| exact hn.trans_lt hn' | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |