math / data /lean /OAI /Probability /IsingPerceptron /NamespaceSplit.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
27.9 kB
import Mathlib
import OAI.Probability.IsingPerceptron.EnergyShift
namespace OAI
/-! Namespace Split. -/
noncomputable section
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology ENNReal NNReal
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology ENNReal NNReal
namespace IsingPerceptron
abbrev OtherNamespaces (j : β„•) := {k : β„• // k β‰  j} β†’ β„• β†’ ℝ
def otherNamespacesLaw (j : β„•) : Measure (OtherNamespaces j) :=
Measure.infinitePi (fun _ : {k : β„• // k β‰  j} => gaussianCoordinates)
instance otherNamespacesLaw_probability (j : β„•) : IsProbabilityMeasure (otherNamespacesLaw j) := by
unfold otherNamespacesLaw
infer_instance
def gaussianNamespaceSplit (j : β„•) (g : β„• β†’ ℝ) : (β„• β†’ ℝ) Γ— OtherNamespaces j :=
((fun i => g (Nat.pair j i)),fun k i => g (Nat.pair k i))
lemma measurable_gaussianNamespaceSplit (j : β„•) : Measurable (gaussianNamespaceSplit j) := by
unfold gaussianNamespaceSplit
fun_prop
lemma gaussianNamespaceSplit_law (j : β„•) :
gaussianCoordinates.map (gaussianNamespaceSplit j) =
gaussianCoordinates.prod (otherNamespacesLaw j) := by
let e := Equiv.optionSubtypeNe j
let t : Option {k : β„• // k β‰  j} Γ— β„• β†’ β„• := fun p => Nat.pair (e p.1) p.2
have ht : Function.Injective t := by
intro p q h
have he := Nat.pair_eq_pair.mp h
exact Prod.ext (e.injective he.1) he.2
have hp := gaussian_pullback_measurePreserving t ht
let F : (β„• β†’ ℝ) β†’ Option {k : β„• // k β‰  j} β†’ β„• β†’ ℝ := fun g k i => g (t (k,i))
have hmF : Measurable F := by unfold F; fun_prop
have hF : gaussianCoordinates.map F = Measure.infinitePi
(fun _ : Option {k : β„• // k β‰  j} => gaussianCoordinates) := by
change gaussianCoordinates.map
((MeasurableEquiv.curry (Option {k : β„• // k β‰  j}) β„• ℝ) ∘
(fun g => fun p => g (t p))) = _
rw [← Measure.map_map (MeasurableEquiv.curry _ _ _).measurable hp.measurable,hp.map_eq,
Measure.infinitePi_map_curry (fun (_ : Option {k : β„• // k β‰  j}) (_ : β„•) => gaussianReal 0 1)]
rfl
have hs := infinitePi_option_split gaussianCoordinates
(fun _ : {k : β„• // k β‰  j} => gaussianCoordinates)
have hc : (fun i : Option {k : β„• // k β‰  j} =>
i.elim gaussianCoordinates (fun _ => gaussianCoordinates)) = (fun _ => gaussianCoordinates) := by
funext i; cases i <;> rfl
rw [hc] at hs
have he : gaussianNamespaceSplit j =
(fun q : Option {k : β„• // k β‰  j} β†’ β„• β†’ ℝ => (q none,fun k => q (some k))) ∘ F := by
rfl
rw [he,← Measure.map_map (by fun_prop) hmF,hF]
exact hs
def gaussianNamespaceJoin (j : β„•) (p : (β„• β†’ ℝ) Γ— OtherNamespaces j) (i : β„•) : ℝ :=
if h : (Nat.unpair i).1 = j then p.1 (Nat.unpair i).2
else p.2 ⟨(Nat.unpair i).1,h⟩ (Nat.unpair i).2
lemma measurable_gaussianNamespaceJoin (j : β„•) : Measurable (gaussianNamespaceJoin j) := by
apply Measurable.of_eval
intro i
by_cases h : (Nat.unpair i).1 = j
Β· simp only [gaussianNamespaceJoin,dite_eq_left h]
fun_prop
Β· simp only [gaussianNamespaceJoin,dite_eq_right h]
fun_prop
lemma gaussianNamespaceJoin_split (j : β„•) (g : β„• β†’ ℝ) :
gaussianNamespaceJoin j (gaussianNamespaceSplit j g) = g := by
funext i
simp only [gaussianNamespaceJoin,gaussianNamespaceSplit]
split_ifs with h
Β· rw [← h,Nat.pair_unpair]
Β· rw [Nat.pair_unpair]
lemma gaussianNamespaceJoin_law (j : β„•) :
(gaussianCoordinates.prod (otherNamespacesLaw j)).map (gaussianNamespaceJoin j) =
gaussianCoordinates := by
rw [← gaussianNamespaceSplit_law,Measure.map_map
(measurable_gaussianNamespaceJoin j) (measurable_gaussianNamespaceSplit j)]
simp only [Function.comp_def,gaussianNamespaceJoin_split,Measure.map_id']
lemma gaussianNamespaceJoin_selected (j : β„•) (z : β„• β†’ ℝ) (g : OtherNamespaces j) (i : β„•) :
gaussianNamespaceJoin j (z,g) (Nat.pair j i) = z i := by
simp [gaussianNamespaceJoin,Nat.unpair_pair]
lemma gaussianNamespaceJoin_other (j : β„•) (z : β„• β†’ ℝ) (g : OtherNamespaces j)
(k : {k : β„• // k β‰  j}) (i : β„•) :
gaussianNamespaceJoin j (z,g) (Nat.pair k i) = g k i := by
simp [gaussianNamespaceJoin,Nat.unpair_pair,k.property]
theorem gaussianNamespaceJoin_preserving (j : β„•) :
MeasurePreserving (gaussianNamespaceJoin j)
(gaussianCoordinates.prod (otherNamespacesLaw j)) gaussianCoordinates :=
⟨measurable_gaussianNamespaceJoin j,gaussianNamespaceJoin_law j⟩
lemma cylinderField_enriched_expand {N : β„•} (n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ)
(s : Spin N Γ— LabeledLeaf n) (g : β„• β†’ ℝ) :
cylinderField (enrichedCoefficients n h u s) g =
cylinderField (externalFieldCoefficients n h s) (fun i => g (Nat.pair 0 i)) +
βˆ‘ j : Fin N, (Real.sqrt N*perturbationScale N*perturbationWeight j*u j) *
cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s)
(fun i => g (Nat.pair (j+1) i)) := by
rw [enrichedCoefficients,cylinderField_finset_sum,Fin.sum_univ_succ]
simp only [Fin.cases_zero,Fin.cases_succ,Fin.val_zero,Fin.val_succ,
cylinderField_tag,cylinderField_smul]
lemma cylinderField_enriched_update {N : β„•} (n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ)
(j : Fin N) (v : ℝ) (s : Spin N Γ— LabeledLeaf n) (g : β„• β†’ ℝ) :
cylinderField (enrichedCoefficients n h (Function.update u j v) s) g =
cylinderField (enrichedCoefficients n h (Function.update u j 0) s) g +
(Real.sqrt N*perturbationScale N*perturbationWeight j*v) *
cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s)
(fun i => g (Nat.pair (j+1) i)) := by
classical
let a : Fin N β†’ ℝ := fun k => Real.sqrt N*perturbationScale N*perturbationWeight k
let Y : Fin N β†’ ℝ := fun k =>
cylinderField (monomialCoefficients n (monomialIndex k).1 (monomialIndex k).2 s)
(fun i => g (Nat.pair (k+1) i))
have he (k : Fin N) : a k * Function.update u j v k * Y k =
a k * Function.update u j 0 k * Y k + if k = j then a j*v*Y j else 0 := by
by_cases hk : k = j
Β· subst k; simp
Β· simp [hk]
simp_rw [cylinderField_enriched_expand]
change _ + βˆ‘ k : Fin N, a k * Function.update u j v k * Y k = _
simp_rw [he]
rw [Finset.sum_add_distrib]
simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true]
exact (add_assoc (cylinderField (externalFieldCoefficients n h s)
(fun i => g (Nat.pair 0 i))) (βˆ‘ k, a k * Function.update u j 0 k * Y k)
(a j * v * Y j)).symm
lemma cylinderField_enriched_frozen {N : β„•} (n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ)
(j : Fin N) (s : Spin N Γ— LabeledLeaf n) (z : β„• β†’ ℝ)
(g : OtherNamespaces (j+1)) :
cylinderField (enrichedCoefficients n h (Function.update u j 0) s)
(gaussianNamespaceJoin (j+1) (z,g)) =
cylinderField (enrichedCoefficients n h (Function.update u j 0) s)
(gaussianNamespaceJoin (j+1) (0,g)) := by
classical
simp_rw [cylinderField_enriched_expand]
congr 1
Β· congr 1
funext i
exact (gaussianNamespaceJoin_other (j+1) z g ⟨0,by omega⟩ i).trans
(gaussianNamespaceJoin_other (j+1) 0 g ⟨0,by omega⟩ i).symm
Β· apply Finset.sum_congr rfl
intro k _
by_cases hk : k = j
Β· subst k
simp
Β· congr 1
congr 1
funext i
have hv : (k:β„•)+1 β‰  (j:β„•)+1 := by
intro he
apply hk
apply Fin.ext
omega
exact (gaussianNamespaceJoin_other (j+1) z g ⟨k+1,hv⟩ i).trans
(gaussianNamespaceJoin_other (j+1) 0 g ⟨k+1,hv⟩ i).symm
lemma cylinderField_enriched_insert {N : β„•} (n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ)
(j : Fin N) (v : ℝ) (s : Spin N Γ— LabeledLeaf n) (z : β„• β†’ ℝ)
(g : OtherNamespaces (j+1)) :
cylinderField (enrichedCoefficients n h (Function.update u j v) s)
(gaussianNamespaceJoin (j+1) (z,g)) =
cylinderField (enrichedCoefficients n h (Function.update u j 0) s)
(gaussianNamespaceJoin (j+1) (0,g)) +
(Real.sqrt N*perturbationScale N*perturbationWeight j*v) *
cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s) z := by
rw [cylinderField_enriched_update,cylinderField_enriched_frozen]
simp only [gaussianNamespaceJoin_selected]
lemma namespaceInsertion_preserving {Ξ© : Type*} [MeasurableSpace Ξ©]
(P : Measure Ξ©) [SFinite P] (j : β„•) :
MeasurePreserving (fun p : (Ξ© Γ— OtherNamespaces j) Γ— (β„• β†’ ℝ) =>
(p.1.1,gaussianNamespaceJoin j (p.2,p.1.2)))
((P.prod (otherNamespacesLaw j)).prod gaussianCoordinates)
(P.prod gaussianCoordinates) := by
have h1 := measurePreserving_prodAssoc P (otherNamespacesLaw j) gaussianCoordinates
have h2 := (MeasurePreserving.id P).prod
(gaussianNamespaceJoin_preserving j |>.comp Measure.measurePreserving_swap)
exact h2.comp h1
end IsingPerceptron
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal BigOperators
namespace IsingPerceptron
def gibbsProbability {X : Type*} [MeasurableSpace X] (Ξ½ : Measure X) (H : X β†’ ℝ) : Measure X :=
if referencePartition Ξ½ H = 0 then Ξ½ else Ξ½.tilted H
instance gibbsProbability_probability {X : Type*} [MeasurableSpace X]
(Ξ½ : Measure X) [IsProbabilityMeasure Ξ½] (H : X β†’ ℝ) :
IsProbabilityMeasure (gibbsProbability Ξ½ H) := by
unfold gibbsProbability
split_ifs with h
Β· infer_instance
Β· apply isProbabilityMeasure_tilted
by_contra he
exact h (integral_undef he)
lemma gibbsProbability_eq_tilted {X : Type*} [MeasurableSpace X]
(Ξ½ : Measure X) [IsProbabilityMeasure Ξ½] (H : X β†’ ℝ)
(he : Integrable (fun x => Real.exp (H x)) Ξ½) :
gibbsProbability Ξ½ H = Ξ½.tilted H := by
exact ite_eq_right (ne_of_gt (_root_.MeasureTheory.integral_exp_pos he))
lemma measurable_random_tilted_measure {Ξ© X : Type*}
[MeasurableSpace Ξ©] [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X]
{Ξ½ : Ξ© β†’ Measure X} (hΞ½ : Measurable Ξ½) [βˆ€ Ο‰, IsProbabilityMeasure (Ξ½ Ο‰)]
{H : Ξ© Γ— X β†’ ℝ} (hH : Measurable H) :
Measurable (fun Ο‰ => (Ξ½ Ο‰).tilted (fun x => H (Ο‰,x))) := by
apply Measure.measurable_of_measurable_coe
intro s hs
have he (Ο‰ : Ξ©) : (Ξ½ Ο‰).tilted (fun x => H (Ο‰,x)) s =
βˆ‘' x, s.indicator (fun x => (Ξ½ Ο‰).tilted (fun x => H (Ο‰,x)) {x}) x :=
(Measure.tsum_indicator_apply_singleton _ s hs).symm
simp_rw [he]
apply Measurable.tsum
intro x
by_cases hx : x ∈ s
Β· simp only [Set.indicator_of_mem hx,tilted_singleton]
exact (((hH.comp (measurable_id.prodMk measurable_const)).exp.div
(measurable_random_referencePartition hΞ½ hH)).ennreal_ofReal).mul
((Measure.measurable_coe (measurableSet_singleton x)).comp hΞ½)
Β· simp only [Set.indicator_of_notMem hx]
exact measurable_const
lemma measurable_gibbsProbability {Ξ© X : Type*}
[MeasurableSpace Ξ©] [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X]
{Ξ½ : Ξ© β†’ Measure X} (hΞ½ : Measurable Ξ½) [βˆ€ Ο‰, IsProbabilityMeasure (Ξ½ Ο‰)]
{H : Ξ© Γ— X β†’ ℝ} (hH : Measurable H) :
Measurable (fun Ο‰ => gibbsProbability (Ξ½ Ο‰) (fun x => H (Ο‰,x))) := by
exact Measurable.ite (measurableSet_eq_fun (measurable_random_referencePartition hΞ½ hH) measurable_const)
hΞ½ (measurable_random_tilted_measure hΞ½ hH)
lemma integrable_exp_bounded_add {X : Type*} [MeasurableSpace X]
{Ξ½ : Measure X} {H B : X β†’ ℝ} (he : Integrable (fun x => Real.exp (H x)) Ξ½)
(hB : Measurable B) {K : ℝ} (hbound : βˆ€ x, B x ≀ K) :
Integrable (fun x => Real.exp (B x+H x)) Ξ½ := by
have hm : AEStronglyMeasurable (fun x => Real.exp (H x)*Real.exp (B x)) Ξ½ :=
he.aestronglyMeasurable.mul hB.exp.aestronglyMeasurable
apply (he.const_mul (Real.exp K)).mono'
Β· simpa only [Real.exp_add,mul_comm,Pi.mul_apply] using hm
Β· exact ae_of_all _ (fun x => by
rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),Real.exp_add]
exact mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (hbound x)) (Real.exp_pos _).le)
lemma gibbsProbability_fold {X : Type*} [MeasurableSpace X]
(Ξ½ : Measure X) [IsProbabilityMeasure Ξ½] (H G : X β†’ ℝ)
(he : Integrable (fun x => Real.exp (H x)) Ξ½)
(heg : Integrable (fun x => Real.exp (H x+G x)) Ξ½) :
gibbsProbability (gibbsProbability Ξ½ H) G = gibbsProbability Ξ½ (fun x => H x+G x) := by
rw [gibbsProbability_eq_tilted Ξ½ H he]
have : IsProbabilityMeasure (Ξ½.tilted H) := isProbabilityMeasure_tilted he
have hg : Integrable (fun x => Real.exp (G x)) (Ξ½.tilted H) := by
rw [integrable_tilted_iff he]
simpa only [smul_eq_mul,← Real.exp_add] using heg
rw [gibbsProbability_eq_tilted _ G hg,gibbsProbability_eq_tilted _ _ heg,tilted_tilted he]
rfl
lemma cgf_fold {X : Type*} [MeasurableSpace X]
(Ξ½ : Measure X) [IsProbabilityMeasure Ξ½] (H Y : X β†’ ℝ) (t : ℝ)
(he : Integrable (fun x => Real.exp (H x)) Ξ½)
(het : Integrable (fun x => Real.exp (H x+t*Y x)) Ξ½) :
cgf Y (gibbsProbability Ξ½ H) t =
Real.log (referencePartition Ξ½ (fun x => H x+t*Y x)) - Real.log (referencePartition Ξ½ H) := by
rw [gibbsProbability_eq_tilted _ _ he]
unfold cgf mgf
rw [integral_exp_tilted]
simp only [Pi.add_apply]
rw [Real.log_div (ne_of_gt (_root_.MeasureTheory.integral_exp_pos het))
(ne_of_gt (_root_.MeasureTheory.integral_exp_pos he))]
rfl
lemma quadratic_minimum_subtract_constant {I : Set ℝ} {g : ℝ β†’ ℝ} {v c a b : ℝ}
(h : βˆ€ t ∈ I, -g v+c*(v-a)^2 ≀ -g t+c*(t-a)^2) :
βˆ€ t ∈ I, -(g v-b)+c*(v-a)^2 ≀ -(g t-b)+c*(t-a)^2 := by
intro t ht
linarith [h t ht]
lemma centered_sub_L1_bound {Ξ© : Type*} [MeasurableSpace Ξ©]
(P : Measure Ξ©) {F B : Ξ© β†’ ℝ} (hF : Integrable F P) (hB : Integrable B P)
{Ξ΄F Ξ΄B : ℝ}
(hcF : (∫ Ο‰, |F Ο‰-∫ Ο‰', F Ο‰' βˆ‚P| βˆ‚P) ≀ Ξ΄F)
(hcB : (∫ Ο‰, |B Ο‰-∫ Ο‰', B Ο‰' βˆ‚P| βˆ‚P) ≀ Ξ΄B) [IsFiniteMeasure P] :
(∫ Ο‰, |F Ο‰-B Ο‰-∫ Ο‰', (F Ο‰'-B Ο‰') βˆ‚P| βˆ‚P) ≀ Ξ΄F+Ξ΄B := by
rw [integral_sub hF hB]
have hiF : Integrable (fun Ο‰ => |F Ο‰-∫ Ο‰', F Ο‰' βˆ‚P|) P := (hF.sub (integrable_const _)).abs
have hiB : Integrable (fun Ο‰ => |B Ο‰-∫ Ο‰', B Ο‰' βˆ‚P|) P := (hB.sub (integrable_const _)).abs
calc
_ ≀ ∫ Ο‰, |F Ο‰-∫ Ο‰', F Ο‰' βˆ‚P|+|B Ο‰-∫ Ο‰', B Ο‰' βˆ‚P| βˆ‚P := by
apply integral_mono ((hF.sub hB).sub (integrable_const _)).abs (hiF.add hiB)
intro Ο‰
change |F Ο‰-B Ο‰-((∫ Ο‰', F Ο‰' βˆ‚P)-(∫ Ο‰', B Ο‰' βˆ‚P))| ≀ _
rw [show F Ο‰-B Ο‰-((∫ Ο‰', F Ο‰' βˆ‚P)-(∫ Ο‰', B Ο‰' βˆ‚P)) =
(F Ο‰-∫ Ο‰', F Ο‰' βˆ‚P)-(B Ο‰-∫ Ο‰', B Ο‰' βˆ‚P) by ring]
exact abs_sub _ _
_ = (∫ Ο‰, |F Ο‰-∫ Ο‰', F Ο‰' βˆ‚P| βˆ‚P)+(∫ Ο‰, |B Ο‰-∫ Ο‰', B Ο‰' βˆ‚P| βˆ‚P) :=
integral_add hiF hiB
_ ≀ _ := add_le_add hcF hcB
end IsingPerceptron
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology ENNReal NNReal
namespace IsingPerceptron
lemma measurable_labeledSpinReference {N : β„•} (n : β„•) (Ξ½ : Measure (Spin N))
[IsProbabilityMeasure Ξ½] : Measurable (labeledSpinReference n Ξ½) := by
let ΞΊ : Kernel (LabeledTree n) (LabeledLeaf n) :=
⟨labeledLeafLaw n,measurable_labeledLeafLaw n⟩
have : IsMarkovKernel κ := ⟨fun T => by
change IsProbabilityMeasure (labeledLeafLaw n T)
infer_instance⟩
have he : (fun T => ((Kernel.const (LabeledTree n) Ξ½).prod ΞΊ) T) =
labeledSpinReference n Ξ½ := by
funext T
rw [Kernel.prod_apply,Kernel.const_apply]
rfl
rw [← he]
exact ((Kernel.const (LabeledTree n) Ξ½).prod ΞΊ).measurable
abbrev EnrichedFrozenData (n : β„•) (j : β„•) (A : Type*) :=
EnrichedCylinderBase n A Γ— OtherNamespaces (j+1)
def enrichedFrozenLaw {A : Type*} [MeasurableSpace A] (P : Measure A)
(r : ℝβ‰₯0) (n : β„•) (b : β„• β†’ ℝ) (j : β„•) : Measure (EnrichedFrozenData n j A) :=
(enrichedCylinderBaseLaw P r n b).prod (otherNamespacesLaw (j+1))
instance enrichedFrozenLaw_probability {A : Type*} [MeasurableSpace A]
(P : Measure A) [IsProbabilityMeasure P] (r : ℝβ‰₯0) (n : β„•) (b : β„• β†’ ℝ) (j : β„•) :
IsProbabilityMeasure (enrichedFrozenLaw P r n b j) := by
unfold enrichedFrozenLaw
infer_instance
def enrichedInsert (n j : β„•) {A : Type*}
(p : EnrichedFrozenData n j A Γ— (β„• β†’ ℝ)) : EnrichedCylinderData n A :=
(p.1.1,gaussianNamespaceJoin (j+1) (p.2,p.1.2))
lemma enrichedInsert_preserving {A : Type*} [MeasurableSpace A]
(P : Measure A) [IsProbabilityMeasure P] (r : ℝβ‰₯0) (n : β„•) (b : β„• β†’ ℝ) (j : β„•) :
MeasurePreserving (enrichedInsert (A := A) n j)
((enrichedFrozenLaw P r n b j).prod gaussianCoordinates) (enrichedCylinderLaw P r n b) :=
namespaceInsertion_preserving (enrichedCylinderBaseLaw P r n b) (j+1)
def enrichedFrozenHamiltonian {N : β„•} {A : Type*} (n : β„•) (h : β„• β†’ ℝ)
(u : Fin N β†’ ℝ) (j : Fin N) (Ο† : A β†’ Spin N β†’ ℝ)
(Ο‰ : EnrichedFrozenData n j A) (s : Spin N Γ— LabeledLeaf n) : ℝ :=
patternBase Ο† (fun i : Fin Ο‰.1.1.1 => Ο‰.1.1.2 i) s.1 +
cylinderField (enrichedCoefficients n h (Function.update u j 0) s)
(gaussianNamespaceJoin (j+1) (0,Ο‰.2))
lemma measurable_patternBase_infinite {N : β„•} {A : Type*} [MeasurableSpace A]
{Ο† : A β†’ Spin N β†’ ℝ} (hm : Measurable Ο†) :
Measurable (fun p : (β„• Γ— (β„• β†’ A)) Γ— Spin N =>
patternBase Ο† (fun i : Fin p.1.1 => p.1.2 i) p.2) := by
have hφm : Measurable (fun p : A × Spin N => φ p.1 p.2) :=
measurable_from_prod_countable_left (fun x => (measurable_pi_apply x).comp hm)
let F : β„• Γ— ((β„• β†’ A) Γ— Spin N) β†’ ℝ := fun p =>
patternBase Ο† (fun i : Fin p.1 => p.2.1 i) p.2.2
have hF : Measurable F := by
apply measurable_from_prod_countable_right
intro M
change Measurable (fun p : (β„• β†’ A) Γ— Spin N => βˆ‘ i : Fin M, Ο† (p.1 i) p.2)
apply Finset.measurable_sum
intro i _
have hi : Measurable (fun p : (β„• β†’ A) Γ— Spin N => (p.1 (i:β„•),p.2)) := by fun_prop
exact hφm.comp hi
exact hF.comp (show Measurable (fun p : (β„• Γ— (β„• β†’ A)) Γ— Spin N =>
(p.1.1,(p.1.2,p.2))) from by fun_prop)
lemma measurable_enrichedFrozenHamiltonian {N : β„•} {A : Type*} [MeasurableSpace A]
(n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ) (j : Fin N)
{Ο† : A β†’ Spin N β†’ ℝ} (hm : Measurable Ο†) :
Measurable (fun p : EnrichedFrozenData n j A Γ— (Spin N Γ— LabeledLeaf n) =>
enrichedFrozenHamiltonian n h u j Ο† p.1 p.2) := by
apply measurable_from_prod_countable_left
intro s
unfold enrichedFrozenHamiltonian
apply Measurable.add
Β· have hg : Measurable (fun Ο‰ : EnrichedFrozenData n j A => (Ο‰.1.1,s.1)) :=
measurable_fst.fst.prodMk measurable_const
exact (measurable_patternBase_infinite hm).comp hg
Β· have hg : Measurable (fun p : EnrichedFrozenData n j A =>
gaussianNamespaceJoin (j+1) (0,p.2)) :=
(measurable_gaussianNamespaceJoin (j+1)).comp
(measurable_const.prodMk measurable_snd)
exact (measurable_cylinderField (enrichedCoefficients n h (Function.update u j 0) s)).comp hg
def enrichedFrozenReference {N : β„•} {A : Type*} (n : β„•) (h : β„• β†’ ℝ)
(u : Fin N β†’ ℝ) (j : Fin N) (Ξ½ : Measure (Spin N)) (Ο† : A β†’ Spin N β†’ ℝ)
(Ο‰ : EnrichedFrozenData n j A) : Measure (Spin N Γ— LabeledLeaf n) :=
gibbsProbability (labeledSpinReference n Ξ½ Ο‰.1.2) (enrichedFrozenHamiltonian n h u j Ο† Ο‰)
instance enrichedFrozenReference_probability {N : β„•} {A : Type*}
(n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ) (j : Fin N)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½] (Ο† : A β†’ Spin N β†’ ℝ)
(Ο‰ : EnrichedFrozenData n j A) :
IsProbabilityMeasure (enrichedFrozenReference n h u j Ξ½ Ο† Ο‰) := by
unfold enrichedFrozenReference
infer_instance
lemma measurable_enrichedFrozenReference {N : β„•} {A : Type*} [MeasurableSpace A]
(n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ) (j : Fin N)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½] {Ο† : A β†’ Spin N β†’ ℝ}
(hm : Measurable Ο†) : Measurable (enrichedFrozenReference n h u j Ξ½ Ο†) := by
exact measurable_gibbsProbability
(Ξ½ := fun Ο‰ : EnrichedFrozenData n j A => labeledSpinReference n Ξ½ Ο‰.1.2)
((measurable_labeledSpinReference n Ξ½).comp measurable_fst.snd)
(measurable_enrichedFrozenHamiltonian n h u j hm)
lemma update_abs_le_two {N : β„•} {u : Fin N β†’ ℝ} (hu : βˆ€ j, |u j| ≀ 2)
(j : Fin N) {v : ℝ} (hv : |v| ≀ 2) : βˆ€ k, |Function.update u j v k| ≀ 2 := by
intro k
by_cases hk : k = j
Β· subst k; simpa using hv
Β· simpa [hk] using hu k
lemma enrichedCylinder_exp_ae {N : β„•} (hN : 0 < N) (n : β„•) (b : β„• β†’ ℝ)
{h : β„• β†’ ℝ} (hh : Monotone h) (h0 : 0 ≀ h 0)
(u : Fin N β†’ ℝ) (hu : βˆ€ j, |u j| ≀ 2)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½]
{A : Type*} [MeasurableSpace A] (P : Measure A) [IsProbabilityMeasure P]
{Ο† : A β†’ Spin N β†’ ℝ} {K : ℝ} (hK : 0 ≀ K) (hΟ† : βˆ€ y x, |Ο† y x| ≀ K)
(r : ℝβ‰₯0) :
βˆ€α΅ p βˆ‚enrichedCylinderLaw P r n b,
Integrable (fun s => Real.exp
(patternBase Ο† (fun i : Fin p.1.1.1 => p.1.1.2 i) s.1 +
cylinderField (enrichedCoefficients n h u s) p.2)) (labeledSpinReference n Ξ½ p.1.2) := by
have he := random_cylinder_all_exp_ae (P := enrichedCylinderBaseLaw P r n b)
(Ξ½ := fun p : EnrichedCylinderBase n A => labeledSpinReference n Ξ½ p.2)
((measurable_labeledSpinReference n Ξ½).comp measurable_snd)
(enrichedCoefficients n h u) (enrichedCoefficients_variance_le hN n hh h0 u hu)
filter_upwards [he] with p hp
apply integrable_exp_bounded_add (by simpa using hp 1) (measurable_of_countable _)
(K := (p.1.1.1:ℝ)*K)
intro s
let y : Fin p.1.1.1 β†’ A := fun i => p.1.1.2 i
have hb : |patternBase Ο† y s.1| ≀ β€–patternBase Ο† yβ€– := by
simpa only [Real.norm_eq_abs] using norm_le_pi_norm (patternBase Ο† y) s.1
exact (le_abs_self _).trans (hb.trans (patternBase_bound hK hφ y))
def perturbationAmplitude (N j : β„•) : ℝ :=
Real.sqrt N*perturbationScale N*perturbationWeight j
lemma perturbationAmplitude_pos {N : β„•} (hN : 0 < N) (j : β„•) :
0 < perturbationAmplitude N j := by
unfold perturbationAmplitude perturbationScale perturbationWeight
positivity
lemma enrichedInsertedPressure_eq {N : β„•} {A : Type*}
(n : β„•) (h : β„• β†’ ℝ) (u : Fin N β†’ ℝ) (j : Fin N)
(Ξ½ : Measure (Spin N)) (Ο† : A β†’ Spin N β†’ ℝ) (v : ℝ)
(p : EnrichedFrozenData n j A Γ— (β„• β†’ ℝ)) :
enrichedCylinderPressure n h (Function.update u j v) Ξ½ Ο† (enrichedInsert n j p) =
(Real.log (referencePartition (labeledSpinReference n Ξ½ p.1.1.2)
(fun s => enrichedFrozenHamiltonian n h u j Ο† p.1 s +
(perturbationAmplitude N j*v)*
cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s) p.2)) -
N*h n/2)/N := by
unfold enrichedCylinderPressure enrichedInsert referencePartition
dsimp only
congr 3
apply integral_congr_ae
filter_upwards [] with s
congr 1
rw [cylinderField_enriched_insert]
unfold enrichedFrozenHamiltonian perturbationAmplitude
ring
lemma enrichedFrozen_exp_ae {N : β„•} (hN : 0 < N) (n : β„•) (b : β„• β†’ ℝ)
{h : β„• β†’ ℝ} (hh : Monotone h) (h0 : 0 ≀ h 0)
(u : Fin N β†’ ℝ) (hu : βˆ€ j, |u j| ≀ 2) (j : Fin N)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½]
{A : Type*} [MeasurableSpace A] (P : Measure A) [IsProbabilityMeasure P]
{Ο† : A β†’ Spin N β†’ ℝ} {K : ℝ} (hK : 0 ≀ K) (hΟ† : βˆ€ y x, |Ο† y x| ≀ K)
(r : ℝβ‰₯0) :
βˆ€α΅ Ο‰ βˆ‚enrichedFrozenLaw P r n b j,
Integrable (fun s => Real.exp (enrichedFrozenHamiltonian n h u j Ο† Ο‰ s))
(labeledSpinReference n Ξ½ Ο‰.1.2) := by
have hp := enrichedInsert_preserving P r n b j
have he := enrichedCylinder_exp_ae hN n b hh h0 (Function.update u j 0)
(update_abs_le_two hu j (by norm_num)) ν P hK hφ r
have he' := ae_of_ae_map hp.measurable.aemeasurable (hp.map_eq.symm β–Έ he)
have hg : βˆ€α΅ p βˆ‚(enrichedFrozenLaw P r n b j).prod gaussianCoordinates,
Integrable (fun s => Real.exp (enrichedFrozenHamiltonian n h u j Ο† p.1 s))
(labeledSpinReference n Ξ½ p.1.1.2) := by
filter_upwards [he'] with p hp'
apply hp'.congr
filter_upwards [] with s
change Real.exp (patternBase Ο† (fun i : Fin p.1.1.1.1 => p.1.1.1.2 i) s.1 +
cylinderField (enrichedCoefficients n h (Function.update u j 0) s)
(gaussianNamespaceJoin (j+1) (p.2,p.1.2))) = _
rw [cylinderField_enriched_insert]
simp only [mul_zero,zero_mul,add_zero,enrichedFrozenHamiltonian]
filter_upwards [Measure.ae_ae_of_ae_prod hg] with ω hω
obtain ⟨g,hg⟩ := hΟ‰.exists
exact hg
lemma enrichedInserted_exp_ae {N : β„•} (hN : 0 < N) (n : β„•) (b : β„• β†’ ℝ)
{h : β„• β†’ ℝ} (hh : Monotone h) (h0 : 0 ≀ h 0)
(u : Fin N β†’ ℝ) (hu : βˆ€ j, |u j| ≀ 2) (j : Fin N) {v : ℝ} (hv : |v| ≀ 2)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½]
{A : Type*} [MeasurableSpace A] (P : Measure A) [IsProbabilityMeasure P]
{Ο† : A β†’ Spin N β†’ ℝ} {K : ℝ} (hK : 0 ≀ K) (hΟ† : βˆ€ y x, |Ο† y x| ≀ K)
(r : ℝβ‰₯0) :
βˆ€α΅ p βˆ‚(enrichedFrozenLaw P r n b j).prod gaussianCoordinates,
Integrable (fun s => Real.exp (enrichedFrozenHamiltonian n h u j Ο† p.1 s +
(perturbationAmplitude N j*v)*
cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s) p.2))
(labeledSpinReference n Ξ½ p.1.1.2) := by
have hp := enrichedInsert_preserving P r n b j
have he := enrichedCylinder_exp_ae hN n b hh h0 (Function.update u j v)
(update_abs_le_two hu j hv) ν P hK hφ r
have he' := ae_of_ae_map hp.measurable.aemeasurable (hp.map_eq.symm β–Έ he)
filter_upwards [he'] with p hp'
apply hp'.congr
filter_upwards [] with s
change Real.exp (patternBase Ο† (fun i : Fin p.1.1.1.1 => p.1.1.1.2 i) s.1 +
cylinderField (enrichedCoefficients n h (Function.update u j v) s)
(gaussianNamespaceJoin (j+1) (p.2,p.1.2))) = _
rw [cylinderField_enriched_insert]
simp only [enrichedFrozenHamiltonian,perturbationAmplitude,add_assoc]
theorem enriched_cgf_eq_pressure_difference {N : β„•} (hN : 0 < N) (n : β„•) (b : β„• β†’ ℝ)
{h : β„• β†’ ℝ} (hh : Monotone h) (h0 : 0 ≀ h 0)
(u : Fin N β†’ ℝ) (hu : βˆ€ j, |u j| ≀ 2) (j : Fin N) {v : ℝ} (hv : |v| ≀ 2)
(Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½]
{A : Type*} [MeasurableSpace A] (P : Measure A) [IsProbabilityMeasure P]
{Ο† : A β†’ Spin N β†’ ℝ} {K : ℝ} (hK : 0 ≀ K) (hΟ† : βˆ€ y x, |Ο† y x| ≀ K)
(r : ℝβ‰₯0) :
βˆ€α΅ p βˆ‚(enrichedFrozenLaw P r n b j).prod gaussianCoordinates,
cgf (fun s => cylinderField (monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s) p.2)
(enrichedFrozenReference n h u j Ξ½ Ο† p.1) (perturbationAmplitude N j*v) =
N*(enrichedCylinderPressure n h (Function.update u j v) Ξ½ Ο† (enrichedInsert n j p) -
enrichedCylinderPressure n h (Function.update u j 0) Ξ½ Ο† (enrichedInsert n j p)) := by
have he0 := (Measure.quasiMeasurePreserving_fst
(ΞΌ := enrichedFrozenLaw P r n b j) (Ξ½ := gaussianCoordinates)).tendsto_ae.eventually
(enrichedFrozen_exp_ae hN n b hh h0 u hu j ν P hK hφ r)
have he := enrichedInserted_exp_ae hN n b hh h0 u hu j hv ν P hK hφ r
filter_upwards [he0,he] with p hp0 hp
rw [enrichedFrozenReference,cgf_fold _ _ _ _ hp0 hp]
rw [enrichedInsertedPressure_eq,enrichedInsertedPressure_eq]
simp only [mul_zero,zero_mul,add_zero]
have hn : (N:ℝ) β‰  0 := by exact_mod_cast Nat.ne_of_gt hN
field_simp
ring
end IsingPerceptron
end
end OAI