Download data/lean/OAI/Probability/Perceptron/Pressure/VectorPartition.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.97 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Pressure/VectorPartition.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Perceptron/Pressure/VectorPartition.lean
-
curl -L -o VectorPartition.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Perceptron/Pressure/VectorPartition.lean
6.97 kB
| import Mathlib | |
| import OAI.Probability.Perceptron.Sphere.GaussianRotation | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped ENNReal NNReal Topology BigOperators BoundedContinuousFunction | |
| open MeasureTheory ProbabilityTheory Set Filter | |
| open scoped ENNReal NNReal BigOperators Topology RealInnerProductSpace | |
| namespace SphericalPerceptronFreeEnergy | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] | |
| variable {S : Type*} [MeasurableSpace S] (Ο : Measure S) [IsProbabilityMeasure Ο] | |
| {W : S β β} {V : S β StrongDual β E} | |
| def vectorPartition (W : S β β) (V : S β StrongDual β E) (x : E) : β := | |
| β« s, Real.exp (W s + V s x) βΟ | |
| def vectorLogPartition (W : S β β) (V : S β StrongDual β E) (x : E) : β := | |
| Real.log (vectorPartition Ο W V x) | |
| def vectorLogDerivative (W : S β β) (V : S β StrongDual β E) (x : E) : StrongDual β E := | |
| (vectorPartition Ο W V x)β»ΒΉ β’ (β« s, Real.exp (W s + V s x) β’ V s βΟ) | |
| omit [FiniteDimensional β E] [MeasurableSpace E] [BorelSpace E] [MeasurableSpace S] in | |
| lemma vectorEnergy_bound {K C : β} (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) | |
| (x : E) (s : S) : |W s + V s x| β€ K+C*βxβ := by | |
| apply (abs_add_le _ _).trans | |
| apply add_le_add (hW s) | |
| exact (ContinuousLinearMap.le_opNorm _ _).trans | |
| (mul_le_mul_of_nonneg_right (hV s) (norm_nonneg x)) | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorPartition_integrable (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) (x : E) : | |
| Integrable (fun s => Real.exp (W s + V s x)) Ο := by | |
| refine Integrable.of_bound (by fun_prop) (Real.exp (K+C*βxβ)) (ae_of_all _ fun s => ?_) | |
| rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| exact Real.exp_le_exp.mpr ((le_abs_self _).trans (vectorEnergy_bound hW hV x s)) | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorPartition_pos (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) (x : E) : | |
| 0 < vectorPartition Ο W V x := by | |
| apply integral_pos_iff_support_of_nonneg (fun s => (Real.exp_pos _).le) | |
| (vectorPartition_integrable Ο hWm hVm hW hV x) |>.mpr | |
| simp [Function.support,Real.exp_ne_zero] | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorPartition_hasFDerivAt (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hC : 0 β€ C) (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) (x : E) : | |
| HasFDerivAt (vectorPartition Ο W V) (β« s, Real.exp (W s+V s x) β’ V s βΟ) x := by | |
| apply hasFDerivAt_integral_of_dominated_of_fderiv_le | |
| (s := Metric.ball x 1) (bound := fun _ => Real.exp (K+C*(βxβ+1))*C) | |
| (F' := fun y s => Real.exp (W s+V s y) β’ V s) (Metric.ball_mem_nhds x zero_lt_one) | |
| (Filter.Eventually.of_forall fun y => by fun_prop) | |
| (vectorPartition_integrable Ο hWm hVm hW hV x) (by fun_prop) | |
| (ae_of_all _ fun s y hy => ?_) (integrable_const _) (ae_of_all _ fun s y _ => ?_) | |
| Β· have hy' : βyβ β€ βxβ+1 := by | |
| have hh : βy-xβ < 1 := by simpa only [Metric.mem_ball,dist_eq_norm] using hy | |
| have hn := norm_add_le (y-x) x | |
| rw [sub_add_cancel] at hn | |
| linarith | |
| rw [norm_smul,Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| apply mul_le_mul _ (hV _) (norm_nonneg _) (Real.exp_pos _).le | |
| apply Real.exp_le_exp.mpr | |
| exact ((le_abs_self _).trans (vectorEnergy_bound hW hV y s)).trans | |
| (add_le_add le_rfl (mul_le_mul_of_nonneg_left hy' hC)) | |
| Β· exact (((V s).hasFDerivAt).const_add (W s)).exp | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorLogPartition_hasFDerivAt (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hC : 0 β€ C) (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) (x : E) : | |
| HasFDerivAt (vectorLogPartition Ο W V) (vectorLogDerivative Ο W V x) x := | |
| (vectorPartition_hasFDerivAt Ο hWm hVm hC hW hV x).log | |
| (vectorPartition_pos Ο hWm hVm hW hV x).ne' | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorLogDerivative_bound (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) (x : E) : | |
| βvectorLogDerivative Ο W V xβ β€ C := by | |
| have hp := vectorPartition_pos Ο hWm hVm hW hV x | |
| have hn : ββ« s, Real.exp (W s+V s x) β’ V s βΟβ β€ C*vectorPartition Ο W V x := by | |
| have hh := norm_integral_le_of_norm_le (f := fun s => Real.exp (W s+V s x) β’ V s) | |
| ((vectorPartition_integrable Ο hWm hVm hW hV x).const_mul C) | |
| (ae_of_all _ fun s => by | |
| rw [norm_smul,Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| exact (mul_le_mul_of_nonneg_left (hV s) (Real.exp_pos _).le).trans_eq (mul_comm ..)) | |
| simpa only [integral_const_mul,vectorPartition] using hh | |
| rw [vectorLogDerivative,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hp)] | |
| calc | |
| _ β€ (vectorPartition Ο W V x)β»ΒΉ*(C*vectorPartition Ο W V x) := | |
| mul_le_mul_of_nonneg_left hn (inv_nonneg.mpr hp.le) | |
| _ = C := by field_simp | |
| omit [MeasurableSpace E] [BorelSpace E] in | |
| lemma vectorLogDerivative_continuous (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hC : 0 β€ C) (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) : | |
| Continuous (vectorLogDerivative Ο W V) := by | |
| apply continuous_iff_continuousAt.mpr | |
| intro x | |
| have hp := (vectorPartition_hasFDerivAt Ο hWm hVm hC hW hV x).continuousAt | |
| apply (hp.invβ (vectorPartition_pos Ο hWm hVm hW hV x).ne').smul | |
| apply continuousAt_of_dominated (bound := fun _ => Real.exp (K+C*(βxβ+1))*C) | |
| Β· exact Filter.Eventually.of_forall fun y => by fun_prop | |
| Β· filter_upwards [Metric.ball_mem_nhds x zero_lt_one] with y hy | |
| exact ae_of_all _ fun s => by | |
| have hy' : βyβ β€ βxβ+1 := by | |
| have hh : βy-xβ < 1 := by simpa only [Metric.mem_ball,dist_eq_norm] using hy | |
| have hn := norm_add_le (y-x) x | |
| rw [sub_add_cancel] at hn | |
| linarith | |
| rw [norm_smul,Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| apply mul_le_mul _ (hV _) (norm_nonneg _) (Real.exp_pos _).le | |
| apply Real.exp_le_exp.mpr | |
| exact ((le_abs_self _).trans (vectorEnergy_bound hW hV y s)).trans | |
| (add_le_add le_rfl (mul_le_mul_of_nonneg_left hy' hC)) | |
| Β· exact integrable_const _ | |
| Β· exact ae_of_all _ fun s => by fun_prop | |
| lemma vectorLogPartition_gaussian_variance (hWm : Measurable W) (hVm : Measurable V) | |
| {K C : β} (hC : 0 β€ C) (hW : β s, |W s| β€ K) (hV : β s, βV sβ β€ C) : | |
| variance (vectorLogPartition Ο W V) (stdGaussian E) β€ (Real.pi^2/8)*C^2 := | |
| stdGaussian_variance_le_of_fderiv_bound | |
| (vectorLogPartition_hasFDerivAt Ο hWm hVm hC hW hV) | |
| (vectorLogDerivative_continuous Ο hWm hVm hC hW hV) hC | |
| (vectorLogDerivative_bound Ο hWm hVm hW hV) | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |