Buckets:
| import Mathlib | |
| import OAI.Probability.Perceptron.Model | |
| namespace OAI | |
| noncomputable section | |
| namespace SphericalPerceptronFreeEnergy | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped Topology NNReal ENNReal | |
| section | |
| variable {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] | |
| {X : Ω → ℝ} | |
| omit [IsProbabilityMeasure μ] in | |
| lemma mem_interior_integrableExpSet_of_all | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) (t : ℝ) : | |
| t ∈ interior (integrableExpSet X μ) := by | |
| have he : integrableExpSet X μ=univ := Set.eq_univ_of_forall hX | |
| simp [he] | |
| omit [IsProbabilityMeasure μ] in | |
| lemma cgf_analytic_of_all | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) (t : ℝ) : | |
| AnalyticAt ℝ (cgf X μ) t := | |
| analyticAt_cgf (mem_interior_integrableExpSet_of_all μ hX t) | |
| lemma cgf_second_nonneg | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) (t : ℝ) : | |
| 0 ≤ deriv (deriv (cgf X μ)) t := by | |
| have hh := iteratedDeriv_two_cgf_eq_integral | |
| (mem_interior_integrableExpSet_of_all μ hX t) | |
| simp only [iteratedDeriv_succ,iteratedDeriv_zero] at hh | |
| rw [hh] | |
| exact div_nonneg (integral_nonneg fun ω => mul_nonneg (sq_nonneg _) (Real.exp_pos _).le) | |
| (mgf_pos (hX t)).le | |
| lemma cgf_deriv_monotone | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) : | |
| Monotone (deriv (cgf X μ)) := | |
| monotone_of_deriv_nonneg (fun t => (cgf_analytic_of_all μ hX t).deriv.differentiableAt) | |
| (cgf_second_nonneg μ hX) | |
| def entropicMean (p : ℝ) (X : Ω → ℝ) : ℝ := | |
| ∫ t : ℝ in (0:ℝ)..1, deriv (cgf X μ) (p*t) | |
| lemma entropicMean_eq_div (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) | |
| {p : ℝ} (hp : p ≠ 0) : entropicMean μ p X=cgf X μ p/p := by | |
| rw [entropicMean,intervalIntegral.integral_comp_mul_left _ hp] | |
| simp only [mul_zero,mul_one] | |
| have hc : Continuous (deriv (cgf X μ)) := continuous_iff_continuousAt.mpr | |
| (fun t => (cgf_analytic_of_all μ hX t).deriv.differentiableAt.continuousAt) | |
| rw [intervalIntegral.integral_eq_sub_of_hasDerivAt | |
| (fun t _ => (cgf_analytic_of_all μ hX t).differentiableAt.hasDerivAt) | |
| (hc.intervalIntegrable _ _),cgf_zero,sub_zero,smul_eq_mul,div_eq_mul_inv,mul_comm] | |
| lemma entropicMean_zero (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) : | |
| entropicMean μ 0 X=∫ ω, X ω ∂μ := by | |
| simp [entropicMean,deriv_cgf_zero (mem_interior_integrableExpSet_of_all μ hX 0)] | |
| lemma entropicMean_monotone (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) : | |
| Monotone (fun p => entropicMean μ p X) := by | |
| have hc : Continuous (deriv (cgf X μ)) := continuous_iff_continuousAt.mpr | |
| (fun t => (cgf_analytic_of_all μ hX t).deriv.differentiableAt.continuousAt) | |
| intro p q hpq | |
| apply intervalIntegral.integral_mono_on (by norm_num) | |
| ((hc.comp ((continuous_const.mul continuous_id) : Continuous (fun t : ℝ => p*t))).intervalIntegrable 0 1) | |
| ((hc.comp ((continuous_const.mul continuous_id) : Continuous (fun t : ℝ => q*t))).intervalIntegrable 0 1) | |
| intro t ht | |
| exact cgf_deriv_monotone μ hX (mul_le_mul_of_nonneg_right hpq ht.1) | |
| lemma entropicMean_param_bound | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) | |
| {K : ℝ} (hK : 0 ≤ K) | |
| (hbound : ∀ t ∈ Icc (0:ℝ) 1, deriv (deriv (cgf X μ)) t ≤ K) | |
| {p q : ℝ} (hp : p ∈ Icc (0:ℝ) 1) (hq : q ∈ Icc (0:ℝ) 1) : | |
| |entropicMean μ p X-entropicMean μ q X| ≤ K*|p-q| := by | |
| have hc : Continuous (deriv (cgf X μ)) := continuous_iff_continuousAt.mpr | |
| (fun t => (cgf_analytic_of_all μ hX t).deriv.differentiableAt.continuousAt) | |
| have hl : ∀ x ∈ Icc (0:ℝ) 1, ∀ y ∈ Icc (0:ℝ) 1, | |
| |deriv (cgf X μ) x-deriv (cgf X μ) y| ≤ K*|x-y| := by | |
| intro x hx y hy | |
| exact Convex.norm_image_sub_le_of_norm_hasDerivWithin_le | |
| (fun t _ => (cgf_analytic_of_all μ hX t).deriv.differentiableAt.hasDerivAt.hasDerivWithinAt) | |
| (fun t ht => by rw [Real.norm_eq_abs,abs_of_nonneg (cgf_second_nonneg μ hX t)]; exact hbound t ht) | |
| (convex_Icc (0:ℝ) 1) hy hx | |
| have hip : IntervalIntegrable (fun t : ℝ => deriv (cgf X μ) (p*t)) volume 0 1 := by | |
| exact (hc.comp ((continuous_const.mul continuous_id) : Continuous (fun t : ℝ => p*t))).intervalIntegrable 0 1 | |
| have hiq : IntervalIntegrable (fun t : ℝ => deriv (cgf X μ) (q*t)) volume 0 1 := by | |
| exact (hc.comp ((continuous_const.mul continuous_id) : Continuous (fun t : ℝ => q*t))).intervalIntegrable 0 1 | |
| unfold entropicMean | |
| rw [← intervalIntegral.integral_sub hip hiq] | |
| have H := intervalIntegral.norm_integral_le_of_norm_le_const | |
| (a := (0:ℝ)) (b := 1) (C := K*|p-q|) | |
| (f := fun t => deriv (cgf X μ) (p*t)-deriv (cgf X μ) (q*t)) (by | |
| intro t ht | |
| have ht' : t ∈ Icc (0:ℝ) 1 := by simpa using (Set.Ioc_subset_Icc_self ht) | |
| have hpt : p*t ∈ Icc (0:ℝ) 1 := ⟨mul_nonneg hp.1 ht'.1, | |
| (mul_le_mul hp.2 ht'.2 ht'.1 (by norm_num)).trans (by norm_num)⟩ | |
| have hqt : q*t ∈ Icc (0:ℝ) 1 := ⟨mul_nonneg hq.1 ht'.1, | |
| (mul_le_mul hq.2 ht'.2 ht'.1 (by norm_num)).trans (by norm_num)⟩ | |
| have hh := hl _ hpt _ hqt | |
| rw [← sub_mul,abs_mul,abs_of_nonneg ht'.1] at hh | |
| apply hh.trans | |
| have := mul_le_mul_of_nonneg_left ht'.2 (mul_nonneg hK (abs_nonneg (p-q))) | |
| nlinarith) | |
| simpa using H | |
| lemma cgf_second_le_of_moments | |
| (hX : ∀ t : ℝ, Integrable (fun ω => Real.exp (t * X ω)) μ) | |
| {t c K : ℝ} (hc : 0 < c) (hK : 0 ≤ K) (hl : c ≤ mgf X μ t) | |
| (hu : (∫ ω, (X ω)^2*Real.exp (t*X ω) ∂μ) ≤ K) : | |
| deriv (deriv (cgf X μ)) t ≤ K/c := by | |
| have hh := iteratedDeriv_two_cgf (mem_interior_integrableExpSet_of_all μ hX t) | |
| simp only [iteratedDeriv_succ,iteratedDeriv_zero] at hh | |
| rw [hh] | |
| calc | |
| _ ≤ (∫ ω, (X ω)^2*Real.exp (t*X ω) ∂μ)/mgf X μ t := sub_le_self _ (sq_nonneg _) | |
| _ ≤ K/mgf X μ t := div_le_div_of_nonneg_right hu (mgf_pos (hX t)).le | |
| _ ≤ K/c := div_le_div_of_nonneg_left hK hc hl | |
| end | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] | |
| [SecondCountableTopology E] [MeasurableSpace E] [BorelSpace E] | |
| (μ : Measure E) [IsGaussian μ] | |
| lemma gaussian_integrable_exp_norm (a : ℝ) : Integrable (fun y : E => Real.exp (a*‖y‖)) μ := by | |
| obtain ⟨c,hc,hI⟩ := IsGaussian.exists_integrable_exp_sq μ | |
| have hh (y : E) : a*‖y‖ ≤ c*‖y‖^2+a^2/(4*c) := by | |
| have h := sq_nonneg (2*c*‖y‖-a) | |
| have hd : a^2/(4*c)*(4*c)=a^2 := div_mul_cancel₀ _ (by positivity) | |
| nlinarith | |
| apply (hI.const_mul (Real.exp (a^2/(4*c)))).mono' (by fun_prop) | |
| exact ae_of_all _ fun y => by | |
| rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),← Real.exp_add] | |
| apply Real.exp_le_exp.mpr | |
| linarith [hh y] | |
| lemma gaussian_integrable_norm_sq_exp (a : ℝ) : | |
| Integrable (fun y : E => ‖y‖^2*Real.exp (a*‖y‖)) μ := by | |
| have he : integrableExpSet (fun y : E => ‖y‖) μ=univ := | |
| Set.eq_univ_of_forall (gaussian_integrable_exp_norm μ) | |
| have ht : a ∈ interior (integrableExpSet (fun y : E => ‖y‖) μ) := by simp [he] | |
| have h := integrable_pow_mul_exp_of_mem_interior_integrableExpSet ht 2 | |
| simpa using h | |
| lemma gaussian_integrable_exp_lipschitz {f : E → ℝ} {L : ℝ≥0} | |
| (hf : LipschitzWith L f) (a σ : ℝ) (x : E) : | |
| Integrable (fun y : E => Real.exp (a*f (x+σ • y))) μ := by | |
| have hbound (y : E) : a*f (x+σ • y) ≤ |a| *|f x|+(|a| *L*|σ|)*‖y‖ := by | |
| have hl := hf.dist_le_mul (x+σ • y) x | |
| simp only [dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs] at hl | |
| have hn := abs_add_le (f (x+σ • y)-f x) (f x) | |
| rw [sub_add_cancel] at hn | |
| have hmul := mul_le_mul_of_nonneg_left (le_trans hn (add_le_add hl le_rfl)) (abs_nonneg a) | |
| have hle := le_abs_self (a*f (x+σ • y)) | |
| rw [abs_mul] at hle | |
| nlinarith | |
| have hfc := hf.continuous | |
| apply ((gaussian_integrable_exp_norm μ (|a| *L*|σ|)).const_mul | |
| (Real.exp (|a| *|f x|))).mono' (by fun_prop) | |
| exact ae_of_all _ fun y => by | |
| rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),← Real.exp_add] | |
| exact Real.exp_le_exp.mpr (hbound y) | |
| lemma gaussian_integrable_lipschitz {f : E → ℝ} {L : ℝ≥0} | |
| (hf : LipschitzWith L f) (σ : ℝ) (x : E) : | |
| Integrable (fun y : E => f (x+σ • y)) μ := by | |
| have he : integrableExpSet (fun y : E => f (x+σ • y)) μ=univ := | |
| Set.eq_univ_of_forall (fun a => gaussian_integrable_exp_lipschitz μ hf a σ x) | |
| have ht : (0:ℝ) ∈ interior (integrableExpSet (fun y : E => f (x+σ • y)) μ) := by simp [he] | |
| exact (memLp_of_mem_interior_integrableExpSet ht (1:ℝ≥0)).integrable (by simp) | |
| end SphericalPerceptronFreeEnergy | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 8.77 kB
- Xet hash:
- dabbed3ee2c616987cecc08f1354eb31ab9bc4bd4042e5f5968d8ed2a19f37ad
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.