Download lean/OAI/Probability/Perceptron/Variational/CountableGaussianIBP.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 6.73 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/Perceptron/Variational/CountableGaussianIBP.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/Perceptron/Variational/CountableGaussianIBP.lean
-
curl -L -o CountableGaussianIBP.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/Perceptron/Variational/CountableGaussianIBP.lean
6.73 kB
| import Mathlib | |
| import OAI.Probability.Perceptron.Variational.CountableGaussianResampling | |
| import OAI.Probability.Perceptron.Interpolation.IntegrableReplicaGibbs | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped Topology NNReal ENNReal BigOperators | |
| namespace SphericalPerceptronFreeEnergy | |
| variable {S : Type*} [MeasurableSpace S] (μ : Measure S) [IsProbabilityMeasure μ] | |
| omit [IsProbabilityMeasure μ] in | |
| lemma countableGaussian_affine_zero_exp_integrable (i : ℕ) | |
| {H : (ℕ → ℝ) → S → ℝ} {v : S → ℝ} (hv : Measurable v) | |
| {C : ℝ} (hvC : ∀ x, |v x| ≤ C) | |
| (haff : ∀ g t x, H (Function.update g i t) x = H (Function.update g i 0) x+t*v x) | |
| (hi : ∀ᵐ g ∂countableGaussianLaw, Integrable (fun x => Real.exp (H g x)) μ) : | |
| ∀ᵐ g ∂countableGaussianLaw, | |
| Integrable (fun x => Real.exp (H (Function.update g i 0) x)) μ := by | |
| have hp := (resampleGaussianCoordinate_measurePreserving i).quasiMeasurePreserving.ae hi | |
| have hs := Measure.measurePreserving_swap.quasiMeasurePreserving.ae hp | |
| filter_upwards [Measure.ae_ae_of_ae_prod hs] with g hg | |
| obtain ⟨t,ht⟩ := hg.exists | |
| change Integrable (fun x => Real.exp (H (Function.update g i t) x)) μ at ht | |
| have hb (x) : ‖Real.exp (-t*v x)‖ ≤ Real.exp (|t| * C) := by | |
| rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] | |
| apply Real.exp_le_exp.mpr | |
| exact (le_abs_self _).trans (by | |
| rw [abs_mul,abs_neg] | |
| exact mul_le_mul_of_nonneg_left (hvC x) (abs_nonneg t)) | |
| have hh := ht.mul_bdd ((hv.const_mul (-t)).exp.aestronglyMeasurable) | |
| (ae_of_all _ hb) | |
| apply hh.congr | |
| exact ae_of_all _ fun x => by | |
| dsimp only | |
| rw [← Real.exp_add,haff] | |
| congr 1 | |
| ring | |
| lemma countableGaussian_coordinate_tilt_ibp (i : ℕ) | |
| {H : (ℕ → ℝ) → S → ℝ} {v F : S → ℝ} | |
| (hH : Measurable (Function.uncurry H)) (hv : Measurable v) (hF : Measurable F) | |
| {C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D) | |
| (hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) | |
| (haff : ∀ g t x, H (Function.update g i t) x = H (Function.update g i 0) x+t*v x) | |
| (hi0 : ∀ᵐ g ∂countableGaussianLaw, | |
| Integrable (fun x => Real.exp (H (Function.update g i 0) x)) μ) : | |
| (∫ g, g i*tiltMean μ (H g) F 1 ∂countableGaussianLaw) = | |
| ∫ g, tiltMean μ (H g) (fun x => v x*F x) 1- | |
| tiltMean μ (H g) F 1*tiltMean μ (H g) v 1 ∂countableGaussianLaw := by | |
| let R (g : ℕ → ℝ) := tiltMean μ (H g) (fun x => v x*F x) 1- | |
| tiltMean μ (H g) F 1*tiltMean μ (H g) v 1 | |
| have hm (K : S → ℝ) (hK : Measurable K) := measurable_tiltMean μ hH hK | |
| have hHg (g) : Measurable (H g) := hH.comp (measurable_const.prodMk measurable_id) | |
| have hb (K : S → ℝ) (hK : Measurable K) {B : ℝ} (hB : 0 ≤ B) | |
| (hKB : ∀ x, |K x| ≤ B) (g) : |tiltMean μ (H g) K 1| ≤ B := | |
| tiltMean_bound_general μ (hHg g) hK hB hKB | |
| have hvF (x : S) : |v x*F x| ≤ C*D := by | |
| rw [abs_mul] | |
| exact mul_le_mul (hvC x) (hFD x) (abs_nonneg _) hC | |
| have hRm : Measurable R := (hm _ (hv.mul hF)).sub ((hm _ hF).mul (hm _ hv)) | |
| have hRb (g) : |R g| ≤ 2*C*D := by | |
| calc | |
| _ ≤ |tiltMean μ (H g) (fun x => v x*F x) 1|+ | |
| |tiltMean μ (H g) F 1*tiltMean μ (H g) v 1| := abs_sub _ _ | |
| _ ≤ C*D+D*C := add_le_add (hb _ (hv.mul hF) (mul_nonneg hC hD) hvF g) (by | |
| rw [abs_mul] | |
| exact mul_le_mul (hb _ hF hD hFD g) (hb _ hv hC hvC g) (abs_nonneg _) hD) | |
| _ = _ := by ring | |
| let e := resampleGaussianCoordinate i | |
| have he := resampleGaussianCoordinate_measurePreserving i | |
| have intmap (K : (ℕ → ℝ) → ℝ) (hK : Measurable K) : | |
| (∫ p, K (e p) ∂(gaussianReal 0 1).prod countableGaussianLaw) = ∫ g, K g ∂countableGaussianLaw := by | |
| simpa only [he.map_eq] using | |
| (integral_map (μ := (gaussianReal 0 1).prod countableGaussianLaw) he.measurable.aemeasurable hK.aestronglyMeasurable).symm | |
| have hmF : Measurable (fun p : ℝ×(ℕ → ℝ) => tiltMean μ (H (e p)) F 1) := | |
| (hm _ hF).comp he.measurable | |
| have hiF : Integrable (fun p : ℝ×(ℕ → ℝ) => p.1*tiltMean μ (H (e p)) F 1) | |
| ((gaussianReal 0 1).prod countableGaussianLaw) := by | |
| apply ((memLp_id_gaussianReal (μ := 0) (v := 1) 1).integrable (by norm_num)).comp_fst countableGaussianLaw |>.mul_bdd | |
| hmF.aestronglyMeasurable | |
| exact ae_of_all _ fun p => by simpa only [Real.norm_eq_abs] using hb _ hF hD hFD (e p) | |
| have hiR : Integrable (fun p => R (e p)) ((gaussianReal 0 1).prod countableGaussianLaw) := | |
| Integrable.of_bound (hRm.comp he.measurable).aestronglyMeasurable (2*C*D) | |
| (ae_of_all _ fun p => by simpa only [Real.norm_eq_abs] using hRb (e p)) | |
| change (∫ g, g i*tiltMean μ (H g) F 1 ∂countableGaussianLaw) = ∫ g, R g ∂countableGaussianLaw | |
| rw [← intmap (fun g => g i*tiltMean μ (H g) F 1) ((measurable_pi_apply i).mul (hm _ hF)),← intmap _ hRm] | |
| simp only [e,resampleGaussianCoordinate,Function.update_self] | |
| change (∫ p, p.1*tiltMean μ (H (e p)) F 1 ∂(gaussianReal 0 1).prod countableGaussianLaw) = | |
| ∫ p, R (e p) ∂(gaussianReal 0 1).prod countableGaussianLaw | |
| rw [integral_prod_symm _ hiF,integral_prod_symm _ hiR] | |
| apply integral_congr_ae | |
| filter_upwards [hi0] with g hg | |
| let w : S → ℝ := H (Function.update g i 0) | |
| have hwm : Measurable w := hHg _ | |
| have hwI : Integrable (fun x => Real.exp (1*w x)) μ := by simpa only [one_mul] using hg | |
| let := tilt_law_probability_of_integrable μ hwI | |
| have heK (K : S → ℝ) (u : ℝ) : tiltMean (tiltLaw μ w 1) v K u = | |
| tiltMean μ (H (Function.update g i u)) K 1 := by | |
| rw [tilt_mean_twice_of_integrable μ hwm hwI u] | |
| congr 2 | |
| funext x | |
| simp only [one_mul] | |
| exact (haff g u x).symm | |
| have hh := gaussian_tilt_integrationByParts (tiltLaw μ w 1) hv hF hC hD hvC hFD | |
| simp_rw [heK] at hh | |
| exact hh | |
| lemma countableGaussian_coordinate_tilt_ibp_of_exp_integrable (i : ℕ) | |
| {H : (ℕ → ℝ) → S → ℝ} {v F : S → ℝ} | |
| (hH : Measurable (Function.uncurry H)) (hv : Measurable v) (hF : Measurable F) | |
| {C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D) | |
| (hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) | |
| (haff : ∀ g t x, H (Function.update g i t) x = H (Function.update g i 0) x+t*v x) | |
| (hi : ∀ᵐ g ∂countableGaussianLaw, Integrable (fun x => Real.exp (H g x)) μ) : | |
| (∫ g, g i*tiltMean μ (H g) F 1 ∂countableGaussianLaw) = | |
| ∫ g, tiltMean μ (H g) (fun x => v x*F x) 1- | |
| tiltMean μ (H g) F 1*tiltMean μ (H g) v 1 ∂countableGaussianLaw := | |
| countableGaussian_coordinate_tilt_ibp μ i hH hv hF hC hD hvC hFD haff | |
| (countableGaussian_affine_zero_exp_integrable μ i hv hvC haff hi) | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |