roseking's picture
Add lean source and binary files (part 125)
dd14c26 verified
Raw History Blame Contribute Delete
34.9 kB
import Mathlib
namespace OAI
/-! Partition Pow Le. -/
noncomputable section
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology ENNReal NNReal BoundedContinuousFunction
namespace IsingPerceptron
lemma partition_pow_le {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsProbabilityMeasure ν] {H : X → ℝ} (p : ℕ)
(h1 : Integrable (fun x => Real.exp (H x)) ν)
(hp : Integrable (fun x => Real.exp ((p:ℝ)*H x)) ν) :
(∫ x, Real.exp (H x) ∂ν)^p ≤ ∫ x, Real.exp ((p:ℝ)*H x) ∂ν := by
simpa only [Function.comp_def, Real.exp_nat_mul] using
(convexOn_pow p).map_integral_le (continuous_pow p).continuousOn isClosed_Ici
(Filter.Eventually.of_forall (fun x => (Real.exp_pos (H x)).le)) h1
(by simpa only [Function.comp_def, Real.exp_nat_mul] using hp)
lemma exp_integral_le_partition {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsProbabilityMeasure ν] {H : X → ℝ}
(hH : Integrable H ν) (he : Integrable (fun x => Real.exp (H x)) ν) :
Real.exp (∫ x, H x ∂ν) ≤ ∫ x, Real.exp (H x) ∂ν := by
exact convexOn_exp.map_integral_le Real.continuous_exp.continuousOn isClosed_univ
(Filter.Eventually.of_forall (fun _ => mem_univ _)) hH he
lemma partition_inv_pow_le {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsProbabilityMeasure ν] {H : X → ℝ} (p : ℕ)
(hH : Integrable H ν)
(h1 : Integrable (fun x => Real.exp (H x)) ν)
(hp : Integrable (fun x => Real.exp (-(p:ℝ)*H x)) ν) :
((∫ x, Real.exp (H x) ∂ν)^p)⁻¹ ≤ ∫ x, Real.exp (-(p:ℝ)*H x) ∂ν := by
have hj := exp_integral_le_partition hH h1
have hz : 0 < ∫ x, Real.exp (H x) ∂ν := (Real.exp_pos _).trans_le hj
calc
_ ≤ (Real.exp (∫ x, H x ∂ν)^p)⁻¹ :=
(inv_le_inv₀ (pow_pos hz _) (pow_pos (Real.exp_pos _) _)).mpr
(pow_le_pow_left₀ (Real.exp_pos _).le hj _)
_ = Real.exp (∫ x, -(p:ℝ)*H x ∂ν) := by
rw [integral_const_mul, ← Real.exp_nat_mul, ← Real.exp_neg]
congr 1
ring
_ ≤ _ := exp_integral_le_partition (hH.const_mul _) hp
lemma gaussian_field_exp_integrable {Ω X : Type*} [MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H : Ω × X → ℝ} (hm : Measurable H) {v : X → NNReal} {K : ℝ}
(hg : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K) (t : ℝ) :
Integrable (fun z => Real.exp (t*H z)) (μ.prod ν) ∧
(∫ ω, ∫ x, Real.exp (t*H (ω,x)) ∂ν ∂μ) ≤ Real.exp (t^2*K/2) := by
have he : Measurable (fun z => Real.exp (t*H z)) := hm.const_mul t |>.exp
have hsec : ∀ x, Integrable (fun ω => Real.exp (t*H (ω,x))) μ := by
intro x
have hx : Measurable (fun ω => H (ω,x)) := hm.comp (measurable_id.prodMk measurable_const)
apply (integrable_map_measure (g := fun y : ℝ => Real.exp (t*y)) (μ := μ) (by fun_prop) hx.aemeasurable).mp
rw [hg x]
exact integrable_exp_mul_gaussianReal t
have hb (x : X) : (∫ ω, Real.exp (t*H (ω,x)) ∂μ) ≤ Real.exp (t^2*K/2) := by
have h := mgf_gaussianReal (X := fun ω => H (ω, x))
⟨(hm.comp (measurable_id.prodMk measurable_const)).aemeasurable, hg x⟩ t
simp only [mgf, zero_mul, zero_add] at h
rw [h]
apply Real.exp_le_exp.mpr
nlinarith [mul_le_mul_of_nonneg_right (hv x) (sq_nonneg t)]
have hi : Integrable (fun z => Real.exp (t*H z)) (μ.prod ν) := by
apply (integrable_prod_iff' he.aestronglyMeasurable).mpr
refine ⟨Filter.Eventually.of_forall hsec, ?_⟩
apply Integrable.of_bound he.stronglyMeasurable.norm.integral_prod_left'.aestronglyMeasurable
(Real.exp (t^2*K/2))
refine Filter.Eventually.of_forall fun x => ?_
simpa only [Real.norm_eq_abs, abs_of_nonneg (Real.exp_pos _).le,
abs_of_nonneg (integral_nonneg (μ := μ) (f := fun ω : Ω => Real.exp (t*H (ω,x))) (fun ω => (Real.exp_pos _).le))] using hb x
refine ⟨hi, ?_⟩
rw [integral_integral_swap hi]
calc
_ ≤ ∫ _ : X, Real.exp (t^2*K/2) ∂ν :=
integral_mono hi.integral_prod_right (integrable_const _) hb
_ = _ := by simp
lemma abs_le_exp_add_exp_neg (x : ℝ) : |x| ≤ Real.exp x + Real.exp (-x) := by
rcases le_total 0 x with hx | hx
· rw [abs_of_nonneg hx]
linarith [Real.add_one_le_exp x, Real.exp_pos (-x)]
· rw [abs_of_nonpos hx]
linarith [Real.add_one_le_exp (-x), Real.exp_pos x]
lemma gaussian_field_integrable {Ω X : Type*} [MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H : Ω × X → ℝ} (hm : Measurable H) {v : X → NNReal} {K : ℝ}
(hg : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K) : Integrable H (μ.prod ν) := by
have hp := (gaussian_field_exp_integrable (ν := ν) hm hg hv (1:ℝ)).1
have hn := (gaussian_field_exp_integrable (ν := ν) hm hg hv (-1:ℝ)).1
apply (hp.add hn).mono' hm.aestronglyMeasurable
exact Filter.Eventually.of_forall fun z => by
simpa only [Pi.add_apply, Real.norm_eq_abs, one_mul, neg_one_mul] using abs_le_exp_add_exp_neg (H z)
lemma gaussian_partition_moments {Ω X : Type*} [MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H : Ω × X → ℝ} (hm : Measurable H) {v : X → NNReal} {K : ℝ}
(hg : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K) (p : ℕ) :
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
Integrable (fun ω => Z ω^p) μ ∧ Integrable (fun ω => (Z ω^p)⁻¹) μ ∧
(∫ ω, Z ω^p ∂μ) ≤ Real.exp ((p:ℝ)^2*K/2) ∧
(∫ ω, (Z ω^p)⁻¹ ∂μ) ≤ Real.exp ((p:ℝ)^2*K/2) := by
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
change Integrable (fun ω => Z ω^p) μ ∧ Integrable (fun ω => (Z ω^p)⁻¹) μ ∧ _
have hmZ : Measurable Z := hm.exp.stronglyMeasurable.integral_prod_right'.measurable
have hH := gaussian_field_integrable (ν := ν) hm hg hv
have h1 := (gaussian_field_exp_integrable (ν := ν) hm hg hv (1:ℝ)).1
simp only [one_mul] at h1
obtain ⟨hip, hbp⟩ := gaussian_field_exp_integrable (ν := ν) hm hg hv (p:ℝ)
obtain ⟨hin, hbn⟩ := gaussian_field_exp_integrable (ν := ν) hm hg hv (-(p:ℝ))
have hp : ∀ᵐ ω ∂μ, Z ω^p ≤ ∫ x, Real.exp ((p:ℝ)*H (ω,x)) ∂ν := by
filter_upwards [h1.prod_right_ae, hip.prod_right_ae] with ω hω hωp
exact partition_pow_le p hω hωp
have hn : ∀ᵐ ω ∂μ, (Z ω^p)⁻¹ ≤ ∫ x, Real.exp (-(p:ℝ)*H (ω,x)) ∂ν := by
filter_upwards [hH.prod_right_ae, h1.prod_right_ae, hin.prod_right_ae] with ω hω hω1 hωn
exact partition_inv_pow_le p hω hω1 hωn
have hz (ω) : 0 ≤ Z ω := integral_nonneg (fun _ => (Real.exp_pos _).le)
have hpint : Integrable (fun ω => Z ω^p) μ := by
apply hip.integral_prod_left.mono' (hmZ.pow_const p).aestronglyMeasurable
simpa only [Real.norm_eq_abs, abs_of_nonneg (pow_nonneg (hz _) _)] using hp
have hnint : Integrable (fun ω => (Z ω^p)⁻¹) μ := by
apply hin.integral_prod_left.mono' ((hmZ.pow_const p).inv).aestronglyMeasurable
simpa only [Pi.inv_apply, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (pow_nonneg (hz _) _))] using hn
refine ⟨hpint, hnint, (integral_mono_ae hpint hip.integral_prod_left hp).trans hbp, ?_⟩
simpa only [neg_sq] using (integral_mono_ae hnint hin.integral_prod_left hn).trans hbn
lemma exp_weighted_abs_fourth_bound (h y : ℝ) :
(Real.exp h*|y|)^4 ≤ Real.exp (8*h)+Real.exp (8*y)+Real.exp (-8*y) := by
have hy : |y| ≤ Real.exp |y| := by linarith [Real.add_one_le_exp |y|]
have hp := pow_le_pow_left₀ (abs_nonneg y) hy 4
have he : (Real.exp |y|)^4 = Real.exp (4*|y|) := by
rw [← Real.exp_nat_mul]; norm_num
rw [he] at hp
have hm := mul_le_mul_of_nonneg_left hp (show 0 ≤ (Real.exp h)^4 by positivity)
have heh : (Real.exp h)^4 = Real.exp (4*h) := by
rw [← Real.exp_nat_mul]; norm_num
rw [heh] at hm
have hs1 : (Real.exp (4*h))^2 = Real.exp (8*h) := by
rw [← Real.exp_nat_mul]; congr 1; ring
have hs2 : (Real.exp (4*|y|))^2 = Real.exp (8*|y|) := by
rw [← Real.exp_nat_mul]; congr 1; ring
have hay : Real.exp (8*|y|) ≤ Real.exp (8*y)+Real.exp (-8*y) := by
rcases le_total 0 y with hy | hy
· rw [abs_of_nonneg hy]; linarith [Real.exp_pos (-8*y)]
· rw [abs_of_nonpos hy]
have he : 8*(-y) = -8*y := by ring
rw [he]; linarith [Real.exp_pos (8*y)]
rw [mul_pow, heh]
have hs := sq_nonneg (Real.exp (4*h)-Real.exp (4*|y|))
have hp0 := mul_nonneg (Real.exp_pos (4*h)).le (Real.exp_pos (4*|y|)).le
nlinarith
lemma gaussian_insertion_numerator_fourth {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H Y : Ω × X → ℝ} (hmH : Measurable H) (hmY : Measurable Y)
{v w : X → NNReal} {K L : ℝ}
(hgH : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hgY : ∀ x, μ.map (fun ω => Y (ω,x)) = gaussianReal 0 (w x))
(hv : ∀ x, (v x : ℝ) ≤ K) (hw : ∀ x, (w x : ℝ) ≤ L) :
let A := fun ω => ∫ x, Real.exp (H (ω,x))*|Y (ω,x)| ∂ν
Integrable (fun z => Real.exp (H z)*|Y z|) (μ.prod ν) ∧
Integrable (fun ω => A ω^4) μ ∧
(∫ ω, A ω^4 ∂μ) ≤ Real.exp (32*K)+2*Real.exp (32*L) := by
let Q := fun z => Real.exp (8*H z)+Real.exp (8*Y z)+Real.exp (-8*Y z)
let A := fun ω => ∫ x, Real.exp (H (ω,x))*|Y (ω,x)| ∂ν
obtain ⟨hiH,hbH⟩ := gaussian_field_exp_integrable (ν := ν) hmH hgH hv 8
obtain ⟨hiY,hbY⟩ := gaussian_field_exp_integrable (ν := ν) hmY hgY hw 8
obtain ⟨hinY,hbnY⟩ := gaussian_field_exp_integrable (ν := ν) hmY hgY hw (-8)
have hiQ : Integrable Q (μ.prod ν) := (hiH.add hiY).add hinY
have hmA : Measurable A := (hmH.exp.mul hmY.abs).stronglyMeasurable.integral_prod_right'.measurable
have hnp (z : Ω × X) : 0 ≤ Real.exp (H z)*|Y z| := by positivity
have hb4 (z : Ω × X) : (Real.exp (H z)*|Y z|)^4 ≤ Q z :=
exp_weighted_abs_fourth_bound (H z) (Y z)
have hi4 : Integrable (fun z => (Real.exp (H z)*|Y z|)^4) (μ.prod ν) := by
apply hiQ.mono' ((hmH.exp.mul hmY.abs).pow_const 4).aestronglyMeasurable
exact Filter.Eventually.of_forall fun z => by
simpa only [Real.norm_eq_abs, Pi.mul_apply, abs_of_nonneg (pow_nonneg (hnp z) _)] using hb4 z
have hi1 : Integrable (fun z => Real.exp (H z)*|Y z|) (μ.prod ν) := by
apply ((integrable_const (1:ℝ)).add hiQ).mono' (hmH.exp.mul hmY.abs).aestronglyMeasurable
refine Filter.Eventually.of_forall fun z => ?_
simp only [Pi.add_apply, Pi.mul_apply, Real.norm_eq_abs, abs_of_nonneg (hnp z)]
have ha := hnp z
have hp : Real.exp (H z)*|Y z| ≤ 1+(Real.exp (H z)*|Y z|)^4 := by
nlinarith [sq_nonneg (Real.exp (H z)*|Y z|),
sq_nonneg ((Real.exp (H z)*|Y z|)^2-1),
sq_nonneg (Real.exp (H z)*|Y z|-1)]
linarith [hb4 z]
have hAle : ∀ᵐ ω ∂μ, A ω^4 ≤ ∫ x, Q (ω,x) ∂ν := by
filter_upwards [hi1.prod_right_ae, hi4.prod_right_ae, hiQ.prod_right_ae] with ω h1 h4 hQ
have hJ := (convexOn_pow 4).map_integral_le (continuous_pow 4).continuousOn isClosed_Ici
(Filter.Eventually.of_forall (fun x => hnp (ω,x))) h1 h4
exact hJ.trans (integral_mono h4 hQ (fun x => hb4 (ω,x)))
have hiA : Integrable (fun ω => A ω^4) μ := by
apply hiQ.integral_prod_left.mono' (hmA.pow_const 4).aestronglyMeasurable
filter_upwards [hAle] with ω hω
rw [Real.norm_eq_abs, abs_of_nonneg (by positivity : 0 ≤ A ω^4)]
exact hω
refine ⟨hi1, hiA, (integral_mono_ae hiA hiQ.integral_prod_left hAle).trans ?_⟩
have he : (∫ ω, ∫ x, Q (ω,x) ∂ν ∂μ) =
(∫ ω, ∫ x, Real.exp (8*H (ω,x)) ∂ν ∂μ) +
(∫ ω, ∫ x, Real.exp (8*Y (ω,x)) ∂ν ∂μ) +
(∫ ω, ∫ x, Real.exp (-8*Y (ω,x)) ∂ν ∂μ) := by
rw [← integral_prod _ hiQ, ← integral_prod _ hiH,
← integral_prod _ hiY, ← integral_prod _ hinY]
exact integral_add (hiH.add hiY) hinY |>.trans
(congrArg (fun r => r+∫ z, Real.exp (-8*Y z) ∂μ.prod ν) (integral_add hiH hiY))
rw [he]
have hK : (8:ℝ)^2*K/2 = 32*K := by ring
have hL : (8:ℝ)^2*L/2 = 32*L := by ring
have hnL : (-8:ℝ)^2*L/2 = 32*L := by ring
rw [hK] at hbH
rw [hL] at hbY
rw [hnL] at hbnY
linarith
lemma square_product_le_fourths (x y : ℝ) : (x*y)^2 ≤ (x^4+y^4)/2 := by
nlinarith [sq_nonneg (x^2-y^2)]
theorem gaussian_gibbs_abs_insertion_second {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H Y : Ω × X → ℝ} (hmH : Measurable H) (hmY : Measurable Y)
{v w : X → NNReal} {K L : ℝ}
(hgH : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hgY : ∀ x, μ.map (fun ω => Y (ω,x)) = gaussianReal 0 (w x))
(hv : ∀ x, (v x : ℝ) ≤ K) (hw : ∀ x, (w x : ℝ) ≤ L) :
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
let A := fun ω => ∫ x, Real.exp (H (ω,x))*|Y (ω,x)| ∂ν
Integrable (fun ω => (A ω/Z ω)^2) μ ∧
(∫ ω, (A ω/Z ω)^2 ∂μ) ≤
(Real.exp (32*K)+2*Real.exp (32*L)+Real.exp (8*K))/2 := by
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
let A := fun ω => ∫ x, Real.exp (H (ω,x))*|Y (ω,x)| ∂ν
obtain ⟨_,hiA,hbA⟩ := gaussian_insertion_numerator_fourth (ν := ν) hmH hmY hgH hgY hv hw
obtain ⟨_,hiZ,_,hbZ⟩ := gaussian_partition_moments (ν := ν) hmH hgH hv 4
change Integrable (fun ω => A ω^4) μ at hiA
change Integrable (fun ω => (Z ω^4)⁻¹) μ at hiZ
have hmZ : Measurable Z := hmH.exp.stronglyMeasurable.integral_prod_right'.measurable
have hmA : Measurable A := (hmH.exp.mul hmY.abs).stronglyMeasurable.integral_prod_right'.measurable
have hb (ω : Ω) : (A ω/Z ω)^2 ≤ (A ω^4+(Z ω^4)⁻¹)/2 := by
simpa only [div_eq_mul_inv, inv_pow] using square_product_le_fourths (A ω) (Z ω)⁻¹
have hi : Integrable (fun ω => (A ω/Z ω)^2) μ := by
apply ((hiA.add hiZ).div_const 2).mono' ((hmA.div hmZ).pow_const 2).aestronglyMeasurable
refine Filter.Eventually.of_forall fun ω => ?_
simpa only [Pi.add_apply, Pi.div_apply, Real.norm_eq_abs, abs_of_nonneg (sq_nonneg (A ω/Z ω))] using hb ω
refine ⟨hi, (integral_mono hi ((hiA.add hiZ).div_const 2) hb).trans ?_⟩
simp only [Pi.add_apply]
rw [integral_div, integral_add hiA hiZ]
have he : (4:ℝ)^2*K/2 = 8*K := by ring
simp only [Nat.cast_ofNat] at hbZ
rw [he] at hbZ
exact div_le_div_of_nonneg_right (add_le_add hbA hbZ) (by norm_num)
lemma log_square_le_partition_moments {x : ℝ} (hx : 0 < x) :
(Real.log x)^2 ≤ 2*(x^2+(x^2)⁻¹) := by
have hp := Real.log_le_sub_one_of_pos hx
have hn := Real.log_le_sub_one_of_pos (inv_pos.mpr hx)
rw [Real.log_inv] at hn
have hB : |Real.log x| ≤ x+x⁻¹ := by
apply abs_le.mpr
constructor <;> linarith [inv_pos.mpr hx]
have hs := pow_le_pow_left₀ (abs_nonneg (Real.log x)) hB 2
rw [sq_abs] at hs
rw [← inv_pow]
nlinarith [sq_nonneg (x-x⁻¹)]
lemma gaussian_log_partition_second {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H : Ω × X → ℝ} (hm : Measurable H) {v : X → NNReal} {K : ℝ}
(hg : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K) :
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
Integrable (fun ω => (Real.log (Z ω))^2) μ ∧
(∫ ω, (Real.log (Z ω))^2 ∂μ) ≤ 4*Real.exp (2*K) := by
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
have hmZ : Measurable Z := hm.exp.stronglyMeasurable.integral_prod_right'.measurable
obtain ⟨hip,hin,hbp,hbn⟩ := gaussian_partition_moments (ν := ν) hm hg hv 2
change Integrable (fun ω => Z ω^2) μ at hip
change Integrable (fun ω => (Z ω^2)⁻¹) μ at hin
have hH := gaussian_field_integrable (ν := ν) hm hg hv
have he := (gaussian_field_exp_integrable (ν := ν) hm hg hv 1).1
simp only [one_mul] at he
have hb : ∀ᵐ ω ∂μ, (Real.log (Z ω))^2 ≤ 2*(Z ω^2+(Z ω^2)⁻¹) := by
filter_upwards [hH.prod_right_ae, he.prod_right_ae] with ω hω hωe
apply log_square_le_partition_moments
exact (Real.exp_pos _).trans_le (exp_integral_le_partition hω hωe)
have hi : Integrable (fun ω => (Real.log (Z ω))^2) μ := by
apply ((hip.add hin).const_mul 2).mono' (hmZ.log.pow_const 2).aestronglyMeasurable
filter_upwards [hb] with ω hω
simpa only [Pi.add_apply, Real.norm_eq_abs, abs_of_nonneg (sq_nonneg (Real.log (Z ω)))] using hω
refine ⟨hi, (integral_mono_ae hi ((hip.add hin).const_mul 2) hb).trans ?_⟩
simp only [Pi.add_apply]
rw [integral_const_mul, integral_add hip hin]
have hx : (2:ℝ)^2*K/2 = 2*K := by ring
simp only [Nat.cast_ofNat] at hbp hbn
rw [hx] at hbp hbn
linarith
lemma uniformIntegrable_of_second_moment_bound {I Ω : Type*} [MeasurableSpace Ω]
{μ : Measure Ω} [IsFiniteMeasure μ] {f : I → Ω → ℝ} {C : ℝ}
(hm : ∀ i, Measurable (f i)) (hi : ∀ i, Integrable (fun ω => (f i ω)^2) μ)
(hb : ∀ i, (∫ ω, (f i ω)^2 ∂μ) ≤ C) : UniformIntegrable f 1 μ := by
apply uniformIntegrable_of le_rfl ENNReal.one_ne_top (fun i => (hm i).aestronglyMeasurable)
intro ε hε
by_cases hεtop : ε = ∞
· subst ε
exact ⟨0, fun _ => le_top⟩
have hεreal := ENNReal.toReal_pos hε.ne' hεtop
let A := (|C|+1)/ε.toReal
have hA : 0 < A := div_pos (by positivity) hεreal
refine ⟨⟨A,hA.le⟩, fun i => ?_⟩
let S := {ω : Ω | (⟨A,hA.le⟩ : NNReal) ≤ ‖f i ω‖₊}
have hs : MeasurableSet S := by
change MeasurableSet {ω : Ω | A ≤ ‖f i ω‖}
exact measurableSet_le measurable_const (hm i).norm
have hfi : Integrable (f i) μ :=
((memLp_two_iff_integrable_sq (hm i).aestronglyMeasurable).mpr (hi i)).integrable (by norm_num)
have hint := hfi.indicator hs
have hle : ∀ ω, ‖S.indicator (f i) ω‖ ≤ (f i ω)^2/A := by
intro ω
by_cases hω : ω ∈ S
· rw [Set.indicator_of_mem hω, Real.norm_eq_abs]
have ha : A ≤ |f i ω| := by exact_mod_cast hω
apply (le_div_iff₀ hA).mpr
nlinarith [sq_abs (f i ω), mul_le_mul_of_nonneg_left ha (abs_nonneg (f i ω))]
· rw [Set.indicator_of_notMem hω, norm_zero]
positivity
change eLpNorm (S.indicator (f i)) 1 μ ≤ ε
rw [eLpNorm_one_eq_lintegral_enorm hint.aestronglyMeasurable,
← ofReal_integral_norm_eq_lintegral_enorm hint, ← ENNReal.ofReal_toReal hεtop]
apply ENNReal.ofReal_le_ofReal
calc
_ ≤ ∫ ω, (f i ω)^2/A ∂μ := integral_mono hint.norm ((hi i).div_const A) hle
_ = (∫ ω, (f i ω)^2 ∂μ)/A := integral_div _ _
_ ≤ C/A := div_le_div_of_nonneg_right (hb i) hA.le
_ ≤ ε.toReal := by
apply (div_le_iff₀ hA).mpr
dsimp [A]
rw [mul_div_cancel₀ _ hεreal.ne']
linarith [le_abs_self C]
lemma integral_tendsto_of_second_moment_bound {Ω : Type*} [MeasurableSpace Ω]
{μ : Measure Ω} [IsFiniteMeasure μ] {f : ℕ → Ω → ℝ} {g : Ω → ℝ} {C : ℝ}
(hm : ∀ i, Measurable (f i)) (hi : ∀ i, Integrable (fun ω => (f i ω)^2) μ)
(hb : ∀ i, (∫ ω, (f i ω)^2 ∂μ) ≤ C)
(ht : ∀ᵐ ω ∂μ, Tendsto (fun i => f i ω) atTop (𝓝 (g ω))) :
Integrable g μ ∧ Tendsto (fun i => ∫ ω, f i ω ∂μ) atTop (𝓝 (∫ ω, g ω ∂μ)) := by
have hu := uniformIntegrable_of_second_moment_bound hm hi hb
have hg := hu.integrable_of_ae_tendsto ht
refine ⟨hg, ?_⟩
apply tendsto_integral_of_L1 g hg.aestronglyMeasurable
(Eventually.of_forall (fun i => (hu.memLp i).integrable le_rfl))
simpa only [eLpNorm_one_eq_lintegral_enorm
((hm _).aestronglyMeasurable.sub hg.aestronglyMeasurable), Pi.sub_apply] using
tendsto_Lp_finite_of_tendsto_ae (by norm_num : (1:ENNReal) ≤ 1)
ENNReal.one_ne_top (fun i => (hm i).aestronglyMeasurable) (memLp_one_iff_integrable.mpr hg) hu.unifIntegrable ht
def normalizedRestriction {X : Type*} [MeasurableSpace X]
(ν : Measure X) (A : Set X) : Measure X := (ν A)⁻¹ • ν.restrict A
lemma normalizedRestriction_probability {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsFiniteMeasure ν] {A : Set X} (hA : ν A ≠ 0) :
IsProbabilityMeasure (normalizedRestriction ν A) := by
constructor
simp only [normalizedRestriction, Measure.smul_apply, Measure.restrict_apply_univ,
smul_eq_mul]
exact ENNReal.inv_mul_cancel hA (measure_ne_top _ _)
lemma integral_normalizedRestriction {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsFiniteMeasure ν] (A : Set X) (f : X → ℝ) :
(∫ x, f x ∂normalizedRestriction ν A) = (∫ x in A, f x ∂ν)/(ν A).toReal := by
rw [normalizedRestriction, integral_smul_measure]
simp only [ENNReal.toReal_inv, smul_eq_mul, div_eq_mul_inv, mul_comm]
lemma integral_restriction_tendsto {X : Type*} [MeasurableSpace X]
{ν : Measure X} {A : ℕ → Set X} (hm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) {f : X → ℝ} (hi : Integrable f ν) :
Tendsto (fun n => ∫ x in A n, f x ∂ν) atTop (𝓝 (∫ x, f x ∂ν)) := by
simp_rw [← integral_indicator (hm _)]
apply tendsto_integral_of_dominated_convergence (fun x => ‖f x‖)
· exact fun n => hi.aestronglyMeasurable.indicator (hm n)
· exact hi.norm
· exact fun n => Eventually.of_forall (fun x => norm_indicator_le_norm_self _ _)
· refine Eventually.of_forall fun x => ?_
exact tendsto_const_nhds.congr' ((hA x).mono (fun n hn => (indicator_of_mem hn f).symm))
lemma normalized_restriction_integral_tendsto {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsProbabilityMeasure ν]
{A : ℕ → Set X} (hm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) {f : X → ℝ} (hi : Integrable f ν) :
Tendsto (fun n => ∫ x, f x ∂normalizedRestriction ν (A n))
atTop (𝓝 (∫ x, f x ∂ν)) := by
have hmass : Tendsto (fun n => (ν (A n)).toReal) atTop (𝓝 (1:ℝ)) := by
simpa only [integral_const, Measure.restrict_apply_univ, measureReal_def,
smul_eq_mul, mul_one, measure_univ, ENNReal.toReal_one] using
integral_restriction_tendsto hm hA (integrable_const (1:ℝ) (μ := ν))
have ht := (integral_restriction_tendsto hm hA hi).div hmass (by norm_num : (1:ℝ) ≠ 0)
convert ht using 1
· funext n
exact integral_normalizedRestriction (A n) f
· rw [div_one]
lemma normalized_restriction_gibbs_tendsto {X : Type*} [MeasurableSpace X]
{ν : Measure X} [IsProbabilityMeasure ν]
{A : ℕ → Set X} (hm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) {H Y : X → ℝ}
(he : Integrable (fun x => Real.exp (H x)) ν)
(hi : Integrable (fun x => Real.exp (H x)*Y x) ν)
(hz : (∫ x, Real.exp (H x) ∂ν) ≠ 0) :
Tendsto (fun n => (∫ x, Real.exp (H x)*Y x ∂normalizedRestriction ν (A n))/
(∫ x, Real.exp (H x) ∂normalizedRestriction ν (A n))) atTop
(𝓝 ((∫ x, Real.exp (H x)*Y x ∂ν)/(∫ x, Real.exp (H x) ∂ν))) :=
(normalized_restriction_integral_tendsto hm hA hi).div
(normalized_restriction_integral_tendsto hm hA he) hz
theorem gaussian_log_restriction_expectation_tendsto {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H : Ω × X → ℝ} (hm : Measurable H) {v : X → NNReal} {K : ℝ}
(hg : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K)
{A : ℕ → Set X} (hAm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) (hpos : ∀ n, ν (A n) ≠ 0) :
Tendsto (fun n => ∫ ω, Real.log (∫ x, Real.exp (H (ω,x))
∂normalizedRestriction ν (A n)) ∂μ) atTop
(𝓝 (∫ ω, Real.log (∫ x, Real.exp (H (ω,x)) ∂ν) ∂μ)) := by
let νn := fun n => normalizedRestriction ν (A n)
have : ∀ n, IsProbabilityMeasure (νn n) := fun n => normalizedRestriction_probability (hpos n)
have hmZ (n) : Measurable (fun ω => Real.log (∫ x, Real.exp (H (ω,x)) ∂νn n)) :=
hm.exp.stronglyMeasurable.integral_prod_right'.measurable.log
have hi (n) := gaussian_log_partition_second (ν := νn n) hm hg hv
apply (integral_tendsto_of_second_moment_bound hmZ (fun n => (hi n).1)
(fun n => (hi n).2) ?_).2
have he := (gaussian_field_exp_integrable (ν := ν) hm hg hv 1).1
simp only [one_mul] at he
have hH := gaussian_field_integrable (ν := ν) hm hg hv
filter_upwards [he.prod_right_ae,hH.prod_right_ae] with ω heω hHω
have hz : 0 < ∫ x, Real.exp (H (ω,x)) ∂ν :=
(Real.exp_pos _).trans_le (exp_integral_le_partition hHω heω)
exact (Real.continuousAt_log hz.ne').tendsto.comp
(normalized_restriction_integral_tendsto hAm hA heω)
lemma gaussian_bounded_insertion_second {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H Y D : Ω × X → ℝ} (hmH : Measurable H) (hmY : Measurable Y)
(hmD : Measurable D) {c : ℝ} (_hc : 0 ≤ c) (hD : ∀ z, |D z| ≤ c)
{v w : X → NNReal} {K L : ℝ}
(hgH : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hgY : ∀ x, μ.map (fun ω => Y (ω,x)) = gaussianReal 0 (w x))
(hv : ∀ x, (v x : ℝ) ≤ K) (hw : ∀ x, (w x : ℝ) ≤ L) :
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
let B := fun ω => ∫ x, Real.exp (H (ω,x))*Y (ω,x)*D (ω,x) ∂ν
Integrable (fun z => Real.exp (H z)*Y z*D z) (μ.prod ν) ∧
Integrable (fun ω => (B ω/Z ω)^2) μ ∧
(∫ ω, (B ω/Z ω)^2 ∂μ) ≤
c^2*((Real.exp (32*K)+2*Real.exp (32*L)+Real.exp (8*K))/2) := by
let Z := fun ω => ∫ x, Real.exp (H (ω,x)) ∂ν
let B := fun ω => ∫ x, Real.exp (H (ω,x))*Y (ω,x)*D (ω,x) ∂ν
let A := fun ω => ∫ x, Real.exp (H (ω,x))*|Y (ω,x)| ∂ν
have hiA := (gaussian_insertion_numerator_fourth (ν := ν) hmH hmY hgH hgY hv hw).1
have hiB : Integrable (fun z => Real.exp (H z)*Y z*D z) (μ.prod ν) := by
apply (hiA.const_mul c).mono' (hmH.exp.mul hmY |>.mul hmD).aestronglyMeasurable
refine Eventually.of_forall fun z => ?_
simp only [Pi.mul_apply, Real.norm_eq_abs, abs_mul, abs_of_pos (Real.exp_pos _)]
nlinarith [mul_le_mul_of_nonneg_left (hD z) (mul_nonneg (Real.exp_pos (H z)).le (abs_nonneg (Y z)))]
have hBA : ∀ᵐ ω ∂μ, (B ω/Z ω)^2 ≤ c^2*(A ω/Z ω)^2 := by
filter_upwards [hiA.prod_right_ae,hiB.prod_right_ae] with ω hAω hBω
have ha : |B ω| ≤ c*A ω := by
calc
_ ≤ ∫ x, |Real.exp (H (ω,x))*Y (ω,x)*D (ω,x)| ∂ν := abs_integral_le_integral_abs
_ ≤ ∫ x, c*(Real.exp (H (ω,x))*|Y (ω,x)|) ∂ν := by
apply integral_mono hBω.abs (hAω.const_mul c)
intro x
dsimp only
rw [abs_mul,abs_mul,abs_of_pos (Real.exp_pos _)]
nlinarith [mul_le_mul_of_nonneg_left (hD (ω,x))
(mul_nonneg (Real.exp_pos (H (ω,x))).le (abs_nonneg (Y (ω,x))))]
_ = c*A ω := integral_const_mul _ _
have hz : 0 ≤ Z ω := integral_nonneg (fun _ => (Real.exp_pos _).le)
have hb : |B ω/Z ω| ≤ c*A ω/Z ω := by
rw [abs_div,abs_of_nonneg hz]
exact div_le_div_of_nonneg_right ha hz
have hs := pow_le_pow_left₀ (abs_nonneg (B ω/Z ω)) hb 2
rw [sq_abs] at hs
simpa only [mul_div_assoc,mul_pow] using hs
have hi := gaussian_gibbs_abs_insertion_second (ν := ν) hmH hmY hgH hgY hv hw
have hmB : Measurable B := (hmH.exp.mul hmY |>.mul hmD).stronglyMeasurable.integral_prod_right'.measurable
have hmZ : Measurable Z := hmH.exp.stronglyMeasurable.integral_prod_right'.measurable
have hiSq : Integrable (fun ω => (B ω/Z ω)^2) μ := by
apply (hi.1.const_mul (c^2)).mono' ((hmB.div hmZ).pow_const 2).aestronglyMeasurable
filter_upwards [hBA] with ω hω
simpa only [Pi.div_apply,Real.norm_eq_abs,abs_of_nonneg (sq_nonneg (B ω/Z ω))] using hω
refine ⟨hiB,hiSq,?_⟩
calc
_ ≤ ∫ ω, c^2*(A ω/Z ω)^2 ∂μ := integral_mono_ae hiSq (hi.1.const_mul (c^2)) hBA
_ = c^2*(∫ ω, (A ω/Z ω)^2 ∂μ) := integral_const_mul _ _
_ ≤ _ := mul_le_mul_of_nonneg_left hi.2 (sq_nonneg c)
theorem gaussian_insertion_restriction_expectation_tendsto {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H Y D : Ω × X → ℝ} (hmH : Measurable H) (hmY : Measurable Y)
(hmD : Measurable D) {c : ℝ} (hc : 0 ≤ c) (hD : ∀ z, |D z| ≤ c)
{v w : X → NNReal} {K L : ℝ}
(hgH : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hgY : ∀ x, μ.map (fun ω => Y (ω,x)) = gaussianReal 0 (w x))
(hv : ∀ x, (v x : ℝ) ≤ K) (hw : ∀ x, (w x : ℝ) ≤ L)
{A : ℕ → Set X} (hAm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) (hpos : ∀ n, ν (A n) ≠ 0) :
Tendsto (fun n => ∫ ω, (∫ x, Real.exp (H (ω,x))*Y (ω,x)*D (ω,x)
∂normalizedRestriction ν (A n))/(∫ x, Real.exp (H (ω,x))
∂normalizedRestriction ν (A n)) ∂μ) atTop
(𝓝 (∫ ω, (∫ x, Real.exp (H (ω,x))*Y (ω,x)*D (ω,x) ∂ν)/
(∫ x, Real.exp (H (ω,x)) ∂ν) ∂μ)) := by
let νn := fun n => normalizedRestriction ν (A n)
have : ∀ n, IsProbabilityMeasure (νn n) := fun n => normalizedRestriction_probability (hpos n)
have hmB (n) : Measurable (fun ω => (∫ x, Real.exp (H (ω,x))*Y (ω,x)*D (ω,x) ∂νn n)/
(∫ x, Real.exp (H (ω,x)) ∂νn n)) :=
(hmH.exp.mul hmY |>.mul hmD).stronglyMeasurable.integral_prod_right'.measurable.div
hmH.exp.stronglyMeasurable.integral_prod_right'.measurable
have hi (n) := gaussian_bounded_insertion_second (ν := νn n) hmH hmY hmD hc hD hgH hgY hv hw
apply (integral_tendsto_of_second_moment_bound hmB (fun n => (hi n).2.1)
(fun n => (hi n).2.2) ?_).2
have he := (gaussian_field_exp_integrable (ν := ν) hmH hgH hv 1).1
simp only [one_mul] at he
have hH := gaussian_field_integrable (ν := ν) hmH hgH hv
have hB := (gaussian_bounded_insertion_second (ν := ν) hmH hmY hmD hc hD hgH hgY hv hw).1
filter_upwards [he.prod_right_ae,hH.prod_right_ae,hB.prod_right_ae] with ω heω hHω hBω
have hz : 0 < ∫ x, Real.exp (H (ω,x)) ∂ν :=
(Real.exp_pos _).trans_le (exp_integral_le_partition hHω heω)
exact (normalized_restriction_integral_tendsto hAm hA hBω).div
(normalized_restriction_integral_tendsto hAm hA heω) hz.ne'
lemma abs_bounded_gibbs_test_le {X : Type*} [MeasurableSpace X]
{ν : Measure X} {H D : X → ℝ} (he : Integrable (fun x => Real.exp (H x)) ν)
(hmD : Measurable D) {c : ℝ} (hc : 0 ≤ c) (hD : ∀ x, |D x| ≤ c) :
|(∫ x, Real.exp (H x)*D x ∂ν)/(∫ x, Real.exp (H x) ∂ν)| ≤ c := by
have hi := he.mul_bdd hmD.aestronglyMeasurable
(Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs] using hD x))
have hb : |∫ x, Real.exp (H x)*D x ∂ν| ≤ c*(∫ x, Real.exp (H x) ∂ν) := by
calc
_ ≤ ∫ x, |Real.exp (H x)*D x| ∂ν := abs_integral_le_integral_abs
_ ≤ ∫ x, c*Real.exp (H x) ∂ν := by
apply integral_mono hi.abs (he.const_mul c)
intro x
dsimp only
rw [abs_mul,abs_of_pos (Real.exp_pos _)]
nlinarith [mul_le_mul_of_nonneg_left (hD x) (Real.exp_pos (H x)).le]
_ = _ := integral_const_mul _ _
have hz : 0 ≤ ∫ x, Real.exp (H x) ∂ν := integral_nonneg (fun _ => (Real.exp_pos _).le)
rcases hz.eq_or_lt with hz | hz
· simp only [← hz,div_zero,abs_zero]
exact hc
· rw [abs_div,abs_of_pos hz]
exact (div_le_iff₀ hz).mpr hb
theorem gaussian_bounded_restriction_expectation_tendsto {Ω X : Type*}
[MeasurableSpace Ω] [MeasurableSpace X]
{μ : Measure Ω} {ν : Measure X} [IsProbabilityMeasure μ] [IsProbabilityMeasure ν]
{H D : Ω × X → ℝ} (hmH : Measurable H) (hmD : Measurable D)
{c : ℝ} (hc : 0 ≤ c) (hD : ∀ z, |D z| ≤ c)
{v : X → NNReal} {K : ℝ}
(hgH : ∀ x, μ.map (fun ω => H (ω,x)) = gaussianReal 0 (v x))
(hv : ∀ x, (v x : ℝ) ≤ K)
{A : ℕ → Set X} (hAm : ∀ n, MeasurableSet (A n))
(hA : ∀ x, ∀ᶠ n in atTop, x ∈ A n) (hpos : ∀ n, ν (A n) ≠ 0) :
Tendsto (fun n => ∫ ω, (∫ x, Real.exp (H (ω,x))*D (ω,x)
∂normalizedRestriction ν (A n))/(∫ x, Real.exp (H (ω,x))
∂normalizedRestriction ν (A n)) ∂μ) atTop
(𝓝 (∫ ω, (∫ x, Real.exp (H (ω,x))*D (ω,x) ∂ν)/
(∫ x, Real.exp (H (ω,x)) ∂ν) ∂μ)) := by
let νn := fun n => normalizedRestriction ν (A n)
have : ∀ n, IsProbabilityMeasure (νn n) := fun n => normalizedRestriction_probability (hpos n)
have hmB (n) : Measurable (fun ω => (∫ x, Real.exp (H (ω,x))*D (ω,x) ∂νn n)/
(∫ x, Real.exp (H (ω,x)) ∂νn n)) :=
(hmH.exp.mul hmD).stronglyMeasurable.integral_prod_right'.measurable.div
hmH.exp.stronglyMeasurable.integral_prod_right'.measurable
apply tendsto_integral_of_dominated_convergence (fun _ => c)
· exact fun n => (hmB n).aestronglyMeasurable
· exact integrable_const _
· intro n
have he := (gaussian_field_exp_integrable (ν := νn n) hmH hgH hv 1).1
simp only [one_mul] at he
filter_upwards [he.prod_right_ae] with ω heω
rw [Real.norm_eq_abs]
exact abs_bounded_gibbs_test_le heω (hmD.comp (measurable_const.prodMk measurable_id))
hc (fun x => hD (ω,x))
· have he := (gaussian_field_exp_integrable (ν := ν) hmH hgH hv 1).1
simp only [one_mul] at he
have hH := gaussian_field_integrable (ν := ν) hmH hgH hv
have hB : Integrable (fun z => Real.exp (H z)*D z) (μ.prod ν) :=
he.mul_bdd hmD.aestronglyMeasurable
(Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs] using hD z))
filter_upwards [he.prod_right_ae,hH.prod_right_ae,hB.prod_right_ae] with ω heω hHω hBω
have hz : 0 < ∫ x, Real.exp (H (ω,x)) ∂ν :=
(Real.exp_pos _).trans_le (exp_integral_le_partition hHω heω)
exact (normalized_restriction_integral_tendsto hAm hA hBω).div
(normalized_restriction_integral_tendsto hAm hA heω) hz.ne'
end IsingPerceptron
end
end OAI