Download data/lean/OAI/Probability/IsingPerceptron/NamespaceSplit.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 27.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/NamespaceSplit.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/IsingPerceptron/NamespaceSplit.lean
-
curl -L -o NamespaceSplit.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/NamespaceSplit.lean
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 | |