Download data/lean/OAI/Probability/IsingPerceptron/OrderedQuantile.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 31.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/OrderedQuantile.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/IsingPerceptron/OrderedQuantile.lean
-
curl -L -o OrderedQuantile.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/OrderedQuantile.lean
31.9 kB
| import Mathlib | |
| import OAI.Probability.IsingPerceptron.ArrayGeometry | |
| namespace OAI | |
| /-! Ordered Quantile. -/ | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal | |
| namespace IsingPerceptron | |
| lemma map_restrict_fst_rectangle (ΞΌ : Measure (β Γ β)) {S T : Set β} (hS : MeasurableSet S) : | |
| ((ΞΌ.restrict (univ ΓΛ’ T)).map Prod.fst) S = ΞΌ (S ΓΛ’ T) := by | |
| rw [Measure.map_apply measurable_fst hS,Measure.restrict_apply (hS.preimage measurable_fst)] | |
| congr 1 | |
| ext x | |
| simp | |
| lemma map_restrict_snd_rectangle (ΞΌ : Measure (β Γ β)) {S T : Set β} (hT : MeasurableSet T) : | |
| ((ΞΌ.restrict (S ΓΛ’ univ)).map Prod.snd) T = ΞΌ (S ΓΛ’ T) := by | |
| rw [Measure.map_apply measurable_snd hT,Measure.restrict_apply (hT.preimage measurable_snd)] | |
| congr 1 | |
| ext x | |
| simp [and_comm] | |
| lemma measure_pair_eq_of_lower_rectangles {ΞΌ Ξ½ : Measure (β Γ β)} [IsFiniteMeasure ΞΌ] | |
| (h : β a b : β, ΞΌ (Iic a ΓΛ’ Iic b) = Ξ½ (Iic a ΓΛ’ Iic b)) | |
| (hU : ΞΌ univ = Ξ½ univ) : ΞΌ = Ξ½ := by | |
| have hfirst (a : β) : (ΞΌ.restrict (Iic a ΓΛ’ univ)).map Prod.snd = | |
| (Ξ½.restrict (Iic a ΓΛ’ univ)).map Prod.snd := by | |
| apply Measure.ext_of_Iic | |
| intro b | |
| rw [map_restrict_snd_rectangle ΞΌ measurableSet_Iic,map_restrict_snd_rectangle Ξ½ measurableSet_Iic] | |
| exact h a b | |
| have hsecond (T : Set β) (hT : MeasurableSet T) : | |
| (ΞΌ.restrict (univ ΓΛ’ T)).map Prod.fst = (Ξ½.restrict (univ ΓΛ’ T)).map Prod.fst := by | |
| apply Measure.ext_of_Iic | |
| intro a | |
| rw [map_restrict_fst_rectangle ΞΌ measurableSet_Iic,map_restrict_fst_rectangle Ξ½ measurableSet_Iic] | |
| have he := congrArg (fun Ο : Measure β => Ο T) (hfirst a) | |
| simpa only [map_restrict_snd_rectangle ΞΌ hT,map_restrict_snd_rectangle Ξ½ hT] using he | |
| apply ext_of_generate_finite _ generateFrom_prod.symm isPiSystem_prod _ hU | |
| rintro _ β¨S,hS,T,hT,rflβ© | |
| have he := congrArg (fun Ο : Measure β => Ο S) (hsecond T hT) | |
| simpa only [map_restrict_fst_rectangle ΞΌ hS,map_restrict_fst_rectangle Ξ½ hS] using he | |
| lemma ordered_pair_cdf (ΞΌ : Measure (β Γ β)) | |
| (ho : β x β ΞΌ.support, β y β ΞΌ.support, x.1 < y.1 β x.2 β€ y.2) (a b : β) : | |
| ΞΌ (Iic a ΓΛ’ Iic b) = min (ΞΌ (Prod.fst β»ΒΉ' Iic a)) (ΞΌ (Prod.snd β»ΒΉ' Iic b)) := by | |
| let S : Set (β Γ β) := Prod.fst β»ΒΉ' Iic a | |
| let T : Set (β Γ β) := Prod.snd β»ΒΉ' Iic b | |
| have hrect : Iic a ΓΛ’ Iic b = S β© T := rfl | |
| rw [hrect] | |
| change ΞΌ (S β© T) = min (ΞΌ S) (ΞΌ T) | |
| have hsupport : βα΅ x βΞΌ, x β ΞΌ.support := ΞΌ.support_mem_ae | |
| by_cases h : β x β ΞΌ.support, x β S β x β T | |
| Β· have hst : S β€α΅[ΞΌ] T := hsupport.mono (fun x hx => h x hx) | |
| rw [min_eq_left (measure_mono_ae hst)] | |
| apply measure_congr | |
| filter_upwards [hst] with x hx | |
| exact propext β¨fun hh => hh.1,fun hh => β¨hh,hx hhβ©β© | |
| Β· push Not at h | |
| obtain β¨x,hx,hxs,hxtβ© := h | |
| have hts : T β€α΅[ΞΌ] S := by | |
| filter_upwards [hsupport] with y hy | |
| intro hyt | |
| change y.1 β€ a | |
| by_contra! hy' | |
| have hxy := ho x hx y hy (lt_of_le_of_lt hxs hy') | |
| exact hxt (hxy.trans hyt) | |
| rw [min_eq_right (measure_mono_ae hts)] | |
| apply measure_congr | |
| filter_upwards [hts] with y hy | |
| exact propext β¨fun hh => hh.2,fun hh => β¨hy hh,hhβ©β© | |
| lemma pair_quantile_cdf {ΞΌ Ξ½ : Measure β} [IsProbabilityMeasure ΞΌ] [IsProbabilityMeasure Ξ½] | |
| (hΞΌ : βα΅ x βΞΌ, x β Icc (0:β) 1) (hΞ½ : βα΅ x βΞ½, x β Icc (0:β) 1) (a b : β) : | |
| (unitUniform.map (fun u => (quantileFunction ΞΌ u,quantileFunction Ξ½ u))) (Iic a ΓΛ’ Iic b) = | |
| min (ΞΌ (Iic a)) (Ξ½ (Iic b)) := by | |
| rw [Measure.map_apply ((monotone_quantileFunction hΞΌ).measurable.prodMk (monotone_quantileFunction hΞ½).measurable) (measurableSet_Iic.prod measurableSet_Iic)] | |
| have he : (fun u => (quantileFunction ΞΌ u,quantileFunction Ξ½ u)) β»ΒΉ' (Iic a ΓΛ’ Iic b) =α΅[unitUniform] | |
| Iic (min (cdf ΞΌ a) (cdf Ξ½ b)) := by | |
| filter_upwards [quantile_preimage_Iic hΞΌ a,quantile_preimage_Iic hΞ½ b] with u hu hv | |
| change (quantileFunction ΞΌ u β€ a β§ quantileFunction Ξ½ u β€ b) = (u β€ min (cdf ΞΌ a) (cdf Ξ½ b)) | |
| rw [le_min_iff] | |
| exact congrArgβ And hu hv | |
| rw [measure_congr he,unitUniform_Iic β¨le_min (cdf_nonneg ΞΌ a) (cdf_nonneg Ξ½ b), | |
| (min_le_left _ _).trans (cdf_le_one ΞΌ a)β©,ENNReal.ofReal_min,ofReal_cdf,ofReal_cdf] | |
| theorem ordered_pair_quantile_law {Ο : Measure (β Γ β)} [IsProbabilityMeasure Ο] | |
| (ho : β x β Ο.support, β y β Ο.support, x.1 < y.1 β x.2 β€ y.2) | |
| (hs : βα΅ x βΟ, x.1 β Icc (0:β) 1 β§ x.2 β Icc (0:β) 1) : | |
| unitUniform.map (fun u => (quantileFunction (Ο.map Prod.fst) u,quantileFunction (Ο.map Prod.snd) u)) = Ο := by | |
| let : IsProbabilityMeasure (Ο.map Prod.fst) := | |
| (Measure.isProbabilityMeasure_map_iff measurable_fst.aemeasurable).mpr inferInstance | |
| let : IsProbabilityMeasure (Ο.map Prod.snd) := | |
| (Measure.isProbabilityMeasure_map_iff measurable_snd.aemeasurable).mpr inferInstance | |
| have hΞΌ : βα΅ x βΟ.map Prod.fst, x β Icc (0:β) 1 := | |
| (ae_map_iff measurable_fst.aemeasurable measurableSet_Icc).mpr (hs.mono (fun _ h => h.1)) | |
| have hΞ½ : βα΅ x βΟ.map Prod.snd, x β Icc (0:β) 1 := | |
| (ae_map_iff measurable_snd.aemeasurable measurableSet_Icc).mpr (hs.mono (fun _ h => h.2)) | |
| let : IsProbabilityMeasure (unitUniform.map (fun u => | |
| (quantileFunction (Ο.map Prod.fst) u,quantileFunction (Ο.map Prod.snd) u))) := | |
| (Measure.isProbabilityMeasure_map_iff ((monotone_quantileFunction hΞΌ).measurable.prodMk | |
| (monotone_quantileFunction hΞ½).measurable).aemeasurable).mpr inferInstance | |
| apply measure_pair_eq_of_lower_rectangles _ (by simp) | |
| intro a b | |
| rw [pair_quantile_cdf hΞΌ hΞ½,ordered_pair_cdf Ο ho, | |
| Measure.map_apply measurable_fst measurableSet_Iic,Measure.map_apply measurable_snd measurableSet_Iic] | |
| end IsingPerceptron | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal NNReal | |
| namespace IsingPerceptron | |
| def treeTail (n d : β) (t : β) : β := max 0 (min 1 (((n+1:β):β)*t-d)) | |
| lemma continuous_treeTail (n d : β) : Continuous (treeTail n d) := by | |
| unfold treeTail; fun_prop | |
| lemma treeTail_mem (n d : β) (t : β) : treeTail n d t β Icc (0:β) 1 := | |
| β¨le_max_left _ _, max_le zero_le_one (min_le_left _ _)β© | |
| lemma treeTail_level (n d j : β) : treeTail n d ((j:β)/(n+1:β)) = | |
| if d < j then 1 else 0 := by | |
| have hn : ((n+1:β):β) β 0 := by positivity | |
| simp only [treeTail,mul_div_cancelβ _ hn] | |
| split_ifs with h | |
| Β· have h' : (d:β)+1 β€ j := by exact_mod_cast h | |
| rw [min_eq_left (by linarith),max_eq_right zero_le_one] | |
| Β· have h' : (j:β) β€ d := by exact_mod_cast (Nat.le_of_not_gt h) | |
| rw [min_eq_right (by linarith),max_eq_left (by linarith)] | |
| lemma treeTail_overlap (n : β) (d : Fin n) (x y : LabeledLeaf n) : | |
| treeTail n d (treeOverlap n x y) = | |
| if (labeledAddress n x).take (d+1) = (labeledAddress n y).take (d+1) then 1 else 0 := by | |
| rw [treeOverlap,treeTail_level] | |
| simp only [labeled_prefix_eq_iff n x y (d := d+1) (by omega),Nat.add_one_le_iff] | |
| lemma enrichedArrayLaw_treeTail {N : β} (hN : 0 < N) (n : β) (b : β β β) | |
| (hb : CascadeExponents 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 β β} (hm : Measurable Ο) {K : β} (hK : 0 β€ K) | |
| (hΟ : β y x, |Ο y x| β€ K) (r : ββ₯0) (d : Fin n) : | |
| (β« x, treeTail n d (treeArray x 0 1) | |
| β(enrichedArrayLaw P r n b h u Ξ½ hm : Measure JointArray)) = 1-b d := by | |
| rw [enrichedArrayLaw_integral P r n b h u Ξ½ hm (fun x => treeTail n d (treeArray x 0 1)) | |
| ((continuous_treeTail n d).comp (by unfold treeArray; fun_prop)).measurable] | |
| let D : (Fin 2 β Spin N Γ LabeledLeaf n) β β := fun Ο => | |
| if (labeledAddress n (Ο 1).2).take (d+1) = (labeledAddress n (Ο 0).2).take (d+1) then 1 else 0 | |
| have hbD (Ο) : |D Ο| β€ 1 := by dsimp only [D]; split_ifs <;> norm_num | |
| have he := enrichedReplicaLaw_integral hN n b hh h0 u hu Ξ½ P hm hK hΟ r D hbD | |
| (fun i : Fin 2 => i.val) Fin.val_injective | |
| rw [β enriched_tilted_label_tail P r n b hb h u Ξ½ hm d] | |
| change _ = enrichedReplicaAverage P r n b h u Ξ½ Ο D | |
| rw [β he] | |
| apply integral_congr_ae | |
| apply ae_of_all | |
| intro Ο | |
| change treeTail n d (treeOverlap n (Ο 0).2 (Ο 1).2) = _ | |
| rw [treeTail_overlap] | |
| simp only [D,Fin.val_zero,Fin.val_one,eq_comm] | |
| def treeLevels (n : β) : Set β := range (fun j : Fin (n+1) => (j:β)/(n+1:β)) | |
| lemma isClosed_treeLevels (n : β) : IsClosed (treeLevels n) := (finite_range _).isClosed | |
| lemma treeOverlap_mem_levels (n : β) (x y : LabeledLeaf n) : treeOverlap n x y β treeLevels n := | |
| β¨β¨labeledCommonDepth n x y,by have := labeledCommonDepth_le n x y; omegaβ©,rflβ© | |
| lemma enrichedArrayLaw_treeLevels {N : β} {A : Type*} [MeasurableSpace A] | |
| (P : Measure A) [IsProbabilityMeasure P] (r : ββ₯0) (n : β) (b h : β β β) | |
| (u : Fin N β β) (Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½] | |
| {Ο : A β Spin N β β} (hm : Measurable Ο) : | |
| βα΅ x β(enrichedArrayLaw P r n b h u Ξ½ hm : Measure JointArray), treeArray x 0 1 β treeLevels n := by | |
| rw [enrichedArrayLaw] | |
| apply (ae_map_iff (measurable_sampledOverlapArray (enrichedJointEntry n)).aemeasurable | |
| ((isClosed_treeLevels n).measurableSet.preimage (by unfold treeArray; fun_prop))).mpr | |
| exact ae_of_all _ (fun Ο => treeOverlap_mem_levels n (Ο 0).2 (Ο 1).2) | |
| theorem enrichedArrayLaw_limit_tree | |
| (N : β β β) (hN : β k, 0 < N k) (n : β) (b : β β β) (hb : CascadeExponents n b) | |
| (h : β β β β β) (hh : β k, Monotone (h k)) (h0 : β k, 0 β€ h k 0) | |
| (u : (k : β) β Fin (N k) β β) (hu : β k j, |u k j| β€ 2) | |
| (Ξ½ : (k : β) β Measure (Spin (N k))) [β k, IsProbabilityMeasure (Ξ½ k)] | |
| (A : β β Type*) [β k, MeasurableSpace (A k)] | |
| (P : (k : β) β Measure (A k)) [β k, IsProbabilityMeasure (P k)] | |
| (Ο : (k : β) β A k β Spin (N k) β β) (hm : β k, Measurable (Ο k)) | |
| (K : β) (hK : 0 β€ K) (hΟ : β k y x, |Ο k y x| β€ K) | |
| (r : β β ββ₯0) (ΞΌ : ProbabilityMeasure JointArray) | |
| (hL : Tendsto (fun k => enrichedArrayLaw (P k) (r k) n b (h k) (u k) (Ξ½ k) (hm k)) atTop (π ΞΌ)) : | |
| (βα΅ x β(ΞΌ : Measure JointArray), treeArray x 0 1 β treeLevels n) β§ | |
| β d : Fin n, (β« x, treeTail n d (treeArray x 0 1) β(ΞΌ : Measure JointArray)) = 1-b d := by | |
| constructor | |
| Β· exact ae_closed_of_weak_limit hL ((isClosed_treeLevels n).preimage (by unfold treeArray; fun_prop)) | |
| (fun k => enrichedArrayLaw_treeLevels (P k) (r k) n b (h k) (u k) (Ξ½ k) (hm k)) | |
| Β· intro d | |
| have he := jointArray_tendsto_integral hL | |
| (hF := (continuous_treeTail n d).comp (by unfold treeArray; fun_prop : Continuous (fun x : JointArray => treeArray x 0 1))) | |
| have ha (k) := enrichedArrayLaw_treeTail (hN k) n b hb (hh k) (h0 k) (u k) (hu k) | |
| (Ξ½ k) (P k) (hm k) hK (hΟ k) (r k) d | |
| have he' := he.congr' (Eventually.of_forall ha) | |
| exact tendsto_nhds_unique he' tendsto_const_nhds | |
| end IsingPerceptron | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal NNReal | |
| namespace IsingPerceptron | |
| lemma treeTail_eq_level_indicator {n d : β} {t : β} (ht : t β treeLevels n) : | |
| treeTail n d t = if (d:β)/(n+1:β) < t then 1 else 0 := by | |
| obtain β¨j,rflβ© := ht | |
| rw [treeTail_level] | |
| simp only [div_lt_div_iff_of_pos_right (by positivity : (0:β) < (n+1:β)),Nat.cast_lt] | |
| lemma cdf_of_treeTail {Ο : Measure β} [IsProbabilityMeasure Ο] {n d : β} | |
| (hΟ : βα΅ t βΟ, t β treeLevels n) {b : β} | |
| (hb : (β« t, treeTail n d t βΟ) = 1-b) : cdf Ο ((d:β)/(n+1:β)) = b := by | |
| have hi : Integrable (treeTail n d) Ο := | |
| integrable_of_measurable_abs_le (continuous_treeTail n d).measurable | |
| (fun t => by rw [abs_of_nonneg (treeTail_mem n d t).1]; exact (treeTail_mem n d t).2) | |
| calc | |
| _ = β« t, (Iic ((d:β)/(n+1:β))).indicator (fun _ => (1:β)) t βΟ := by | |
| rw [integral_indicator_const _ measurableSet_Iic,cdf_eq_real,smul_eq_mul,mul_one] | |
| _ = β« t, 1-treeTail n d t βΟ := integral_congr_ae (hΟ.mono (fun t ht => by | |
| simp only [treeTail_eq_level_indicator (d := d) ht] | |
| by_cases h : (d:β)/(n+1:β) < t | |
| Β· simp only [Set.indicator,Set.mem_Iic,h,not_le.mpr h,ite_false,ite_true,sub_self] | |
| Β· simp only [Set.indicator,Set.mem_Iic,h,le_of_not_gt h,ite_false,ite_true,sub_zero])) | |
| _ = b := by rw [integral_sub (integrable_const _) hi,hb]; simp | |
| lemma quantile_treeTail {Ο : Measure β} [IsProbabilityMeasure Ο] {n d : β} | |
| (hs : βα΅ t βΟ, t β Icc (0:β) 1) | |
| (hΟ : βα΅ t βΟ, t β treeLevels n) {b : β} | |
| (hb : (β« t, treeTail n d t βΟ) = 1-b) : | |
| βα΅ u βunitUniform, treeTail n d (quantileFunction Ο u) = if b < u then 1 else 0 := by | |
| have hm := (monotone_quantileFunction hs).measurable | |
| have hl := quantileFunction_law hs | |
| have hlev : βα΅ u βunitUniform, quantileFunction Ο u β treeLevels n := by | |
| apply (ae_map_iff hm.aemeasurable (isClosed_treeLevels n).measurableSet).mp | |
| rw [hl] | |
| exact hΟ | |
| have hc := cdf_of_treeTail hΟ hb | |
| filter_upwards [hlev,ae_restrict_mem (ΞΌ := volume) measurableSet_Ioo] with u hu hu' | |
| rw [treeTail_eq_level_indicator hu] | |
| have he := quantileFunction_le_iff hs hu' (x := (d:β)/(n+1:β)) | |
| rw [hc] at he | |
| have he' : (d:β)/(n+1:β) < quantileFunction Ο u β b < u := by | |
| simpa only [not_le] using not_congr he | |
| simp only [he'] | |
| theorem ordered_pair_tree_tail_integral {Ο : Measure (β Γ β)} [IsProbabilityMeasure Ο] | |
| (ho : β x β Ο.support, β y β Ο.support, x.1 < y.1 β x.2 β€ y.2) | |
| (hs : βα΅ x βΟ, x.1 β Icc (0:β) 1 β§ x.2 β Icc (0:β) 1) | |
| {n d : β} (hl : βα΅ x βΟ, x.2 β treeLevels n) {b : β} | |
| (ht : (β« x, treeTail n d x.2 βΟ) = 1-b) : | |
| (β« x, x.1*treeTail n d x.2 βΟ) = | |
| β« u in Ioi b, quantileFunction (Ο.map Prod.fst) u βunitUniform := by | |
| let : IsProbabilityMeasure (Ο.map Prod.fst) := | |
| (Measure.isProbabilityMeasure_map_iff measurable_fst.aemeasurable).mpr inferInstance | |
| let : IsProbabilityMeasure (Ο.map Prod.snd) := | |
| (Measure.isProbabilityMeasure_map_iff measurable_snd.aemeasurable).mpr inferInstance | |
| have hr : βα΅ t βΟ.map Prod.fst, t β Icc (0:β) 1 := | |
| (ae_map_iff measurable_fst.aemeasurable measurableSet_Icc).mpr (hs.mono (fun _ h => h.1)) | |
| have hT : βα΅ t βΟ.map Prod.snd, t β Icc (0:β) 1 := | |
| (ae_map_iff measurable_snd.aemeasurable measurableSet_Icc).mpr (hs.mono (fun _ h => h.2)) | |
| have hlev : βα΅ t βΟ.map Prod.snd, t β treeLevels n := | |
| (ae_map_iff measurable_snd.aemeasurable (isClosed_treeLevels n).measurableSet).mpr hl | |
| have hti : (β« t, treeTail n d t βΟ.map Prod.snd) = 1-b := by | |
| rw [integral_map measurable_snd.aemeasurable (continuous_treeTail n d).measurable.aestronglyMeasurable] | |
| exact ht | |
| have hqt := quantile_treeTail hT hlev hti | |
| have hm := (monotone_quantileFunction hr).measurable.prodMk (monotone_quantileFunction hT).measurable | |
| have hF : Measurable (fun x : β Γ β => x.1*treeTail n d x.2) := | |
| measurable_fst.mul ((continuous_treeTail n d).measurable.comp measurable_snd) | |
| have hi := integral_map (ΞΌ := unitUniform) hm.aemeasurable hF.aestronglyMeasurable | |
| rw [ordered_pair_quantile_law ho hs] at hi | |
| rw [hi,β integral_indicator measurableSet_Ioi] | |
| apply integral_congr_ae | |
| filter_upwards [hqt] with u hu | |
| rw [hu] | |
| by_cases h : b < u <;> simp [h] | |
| end IsingPerceptron | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal NNReal | |
| namespace IsingPerceptron | |
| lemma enrichedMeanPressure_field_cost {N : β} (hN : 0 < N) (n : β) (b : β β β) | |
| (hb : CascadeExponents n b) {h l : β β β} | |
| (hh : Monotone h) (h0 : 0 β€ h 0) (hl : Monotone l) (l0 : 0 β€ l 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 β β} (hm : Measurable Ο) {K : β} (hK : 0 β€ K) | |
| (hΟ : β y x, |Ο y x| β€ K) (r : ββ₯0) : | |
| |enrichedMeanPressure P r n b (fun i => h i+l i) u Ξ½ Ο- | |
| enrichedMeanPressure P r n b h u Ξ½ Ο| β€ l n/2 := by | |
| have he := enrichedMeanPressure_field_insert hN n b hb hh h0 hl l0 u hu Ξ½ P hm hK hΟ r | |
| (a := 1) zero_le_one | |
| simp only [one_mul,Real.sqrt_one] at he | |
| have hc := random_cylinder_cgf_mean_bounds (P := enrichedCylinderLaw P r n b) | |
| (measurable_enrichedGibbsReference n h u Ξ½ hm) (externalFieldCoefficients n l) | |
| (fun s => (externalFieldCoefficients_variance n hl l0 s).le) 1 | |
| simp only [one_pow,one_mul] at hc | |
| have hn : (0:β)<N := by exact_mod_cast hN | |
| have hc' := (div_le_iffβ hn).mpr (show (β« z, cgf (fun x => cylinderField | |
| (externalFieldCoefficients n l x) z.2) (enrichedGibbsReference n h u Ξ½ Ο z.1) 1 | |
| β(enrichedCylinderLaw P r n b).prod gaussianCoordinates) β€ l n/2*(N:β) by nlinarith [hc.2]) | |
| have hc0 := div_nonneg hc.1 hn.le | |
| rw [he] | |
| apply abs_le.mpr | |
| constructor <;> nlinarith | |
| def finiteFieldPath {n : β} (a : Fin (n+1) β β) (i : β) : β := | |
| β j, if j.val β€ i then a j else 0 | |
| lemma finiteFieldPath_last {n : β} (a : Fin (n+1) β β) : finiteFieldPath a n = β j, a j := by | |
| simp only [finiteFieldPath,show β j : Fin (n+1), j.val β€ n from fun j => by omega,ite_true] | |
| lemma finiteFieldPath_nonneg {n : β} {a : Fin (n+1) β β} (ha : β j, 0 β€ a j) (i : β) : | |
| 0 β€ finiteFieldPath a i := Finset.sum_nonneg (fun j _ => by split_ifs; exact ha j; exact le_refl 0) | |
| lemma monotone_finiteFieldPath {n : β} {a : Fin (n+1) β β} (ha : β j, 0 β€ a j) : | |
| Monotone (finiteFieldPath a) := by | |
| intro i k hik | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| by_cases hj : j.val β€ i | |
| Β· simp [hj,hj.trans hik] | |
| Β· simp only [hj,ite_false] | |
| split_ifs; exact ha j; exact le_refl 0 | |
| lemma finiteFieldPath_add {n : β} (a c : Fin (n+1) β β) : | |
| finiteFieldPath (fun i => a i+c i) = fun i => finiteFieldPath a i+finiteFieldPath c i := by | |
| funext i | |
| simp only [finiteFieldPath,β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| split_ifs <;> simp | |
| lemma finiteFieldPath_sub {n : β} (a c : Fin (n+1) β β) : | |
| finiteFieldPath (fun i => a i-c i) = fun i => finiteFieldPath a i-finiteFieldPath c i := by | |
| funext i | |
| simp only [finiteFieldPath,β Finset.sum_sub_distrib] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| split_ifs <;> simp | |
| lemma enrichedMeanPressure_field_lipschitz {N : β} (hN : 0 < N) (n : β) (b : β β β) | |
| (hb : CascadeExponents n b) {a c : Fin (n+1) β β} | |
| (ha : β j, 0 β€ a j) (hc : β j, 0 β€ c j) | |
| (u : Fin N β β) (hu : β j, |u j| β€ 2) (Ξ½ : Measure (Spin N)) [IsProbabilityMeasure Ξ½] | |
| {A : Type*} [MeasurableSpace A] (P : Measure A) [IsProbabilityMeasure P] | |
| {Ο : A β Spin N β β} (hm : Measurable Ο) {K : β} (hK : 0 β€ K) | |
| (hΟ : β y x, |Ο y x| β€ K) (r : ββ₯0) : | |
| |enrichedMeanPressure P r n b (finiteFieldPath a) u Ξ½ Ο- | |
| enrichedMeanPressure P r n b (finiteFieldPath c) u Ξ½ Ο| β€ (β j, |a j-c j|)/2 := by | |
| let d : Fin (n+1) β β := fun j => min (a j) (c j) | |
| have hd : β j, 0 β€ d j := fun j => le_min (ha j) (hc j) | |
| have had : β j, 0 β€ a j-d j := fun j => sub_nonneg.mpr (min_le_left _ _) | |
| have hcd : β j, 0 β€ c j-d j := fun j => sub_nonneg.mpr (min_le_right _ _) | |
| have heA := enrichedMeanPressure_field_cost hN n b hb (monotone_finiteFieldPath hd) | |
| (finiteFieldPath_nonneg hd 0) (monotone_finiteFieldPath had) (finiteFieldPath_nonneg had 0) | |
| u hu Ξ½ P hm hK hΟ r | |
| have heC := enrichedMeanPressure_field_cost hN n b hb (monotone_finiteFieldPath hd) | |
| (finiteFieldPath_nonneg hd 0) (monotone_finiteFieldPath hcd) (finiteFieldPath_nonneg hcd 0) | |
| u hu Ξ½ P hm hK hΟ r | |
| simp only [finiteFieldPath_sub,add_sub_cancel] at heA heC | |
| have hs : finiteFieldPath a n-finiteFieldPath d n + (finiteFieldPath c n-finiteFieldPath d n) = | |
| β j, |a j-c j| := by | |
| simp only [finiteFieldPath_last,β Finset.sum_sub_distrib,β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| dsimp only [d] | |
| rcases le_total (a j) (c j) with h | h | |
| Β· rw [min_eq_left h,abs_of_nonpos (sub_nonpos.mpr h)]; ring | |
| Β· rw [min_eq_right h,abs_of_nonneg (sub_nonneg.mpr h)]; ring | |
| have ht := abs_sub_le (enrichedMeanPressure P r n b (finiteFieldPath a) u Ξ½ Ο) | |
| (enrichedMeanPressure P r n b (finiteFieldPath d) u Ξ½ Ο) | |
| (enrichedMeanPressure P r n b (finiteFieldPath c) u Ξ½ Ο) | |
| rw [abs_sub_comm (enrichedMeanPressure P r n b (finiteFieldPath d) u Ξ½ Ο)] at ht | |
| linarith | |
| end IsingPerceptron | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators NNReal ENNReal | |
| namespace IsingPerceptron | |
| open Set Filter | |
| open scoped Topology | |
| lemma factorial_successor_term (n : β) (x : β) : | |
| (n+1 : β) * x^(n+1) / (n+1).factorial = x * (x^n / n.factorial) := by | |
| rw [Nat.factorial_succ,Nat.cast_mul,Nat.cast_add,Nat.cast_one,pow_succ] | |
| have hn : (n.factorial : β) β 0 := by positivity | |
| have hn1 : (n : β)+1 β 0 := by positivity | |
| field_simp | |
| lemma summable_count_pow_div_factorial (x : β) : | |
| Summable (fun n : β => (n : β)*x^n/n.factorial) := by | |
| apply (summable_nat_add_iff 1).mp | |
| simpa only [Nat.cast_add,Nat.cast_one,factorial_successor_term] using | |
| (Real.summable_pow_div_factorial x).mul_left x | |
| lemma summable_linear_pow_div_factorial (C K x : β) : | |
| Summable (fun n : β => (C+K*n)*x^n/n.factorial) := by | |
| have hs := ((Real.summable_pow_div_factorial x).mul_left C).add | |
| ((summable_count_pow_div_factorial x).mul_left K) | |
| apply hs.congr | |
| intro n | |
| ring | |
| lemma summable_growth_exponentialSeries {a : β β β} {C K : β} | |
| (_hC : 0 β€ C) (_hK : 0 β€ K) (ha : β n, |a n| β€ C+K*n) (x : β) : | |
| Summable (fun n : β => a n*x^n/n.factorial) := by | |
| apply Summable.of_norm_bounded (summable_linear_pow_div_factorial C K |x|) | |
| intro n | |
| simp only [Real.norm_eq_abs,abs_div,abs_mul,abs_pow,Nat.abs_cast] | |
| gcongr | |
| exact ha n | |
| lemma hasDerivAt_exponentialSeries {a : β β β} {C K : β} | |
| (hC : 0 β€ C) (hK : 0 β€ K) (ha : β n, |a n| β€ C+K*n) (x : β) : | |
| HasDerivAt (fun y => β' n : β, a n*y^n/n.factorial) | |
| (β' n : β, a (n+1)*x^n/n.factorial) x := by | |
| let B := |x|+1 | |
| have hB : 0 < B := by dsimp [B]; positivity | |
| have hshift n : |a (n+1)| β€ (C+K)+K*n := by | |
| have H := ha (n+1) | |
| push_cast at H | |
| linarith | |
| have hu := summable_linear_pow_div_factorial (C+K) K B | |
| have hg (n : β) (y : β) : | |
| HasDerivAt (fun y : β => a (n+1)*y^(n+1)/(n+1).factorial) | |
| (a (n+1)*y^n/n.factorial) y := by | |
| convert (((hasDerivAt_id y).pow (n+1)).const_mul (a (n+1))).div_const ((n+1).factorial : β) using 1 <;> try rfl | |
| simp only [id_eq,Nat.add_sub_cancel,Nat.cast_add,Nat.cast_one,mul_one,Nat.factorial_succ,Nat.cast_mul] | |
| have hn : (n.factorial : β) β 0 := by positivity | |
| have hn1 : (n : β)+1 β 0 := by positivity | |
| field_simp | |
| have hbound (n : β) (y : β) (hy : y β Ioo (-B) B) : | |
| βa (n+1)*y^n/n.factorialβ β€ ((C+K)+K*n)*B^n/n.factorial := by | |
| have hab : |y| β€ B := le_of_lt (abs_lt.mpr hy) | |
| simp only [Real.norm_eq_abs,abs_div,abs_mul,abs_pow,Nat.abs_cast] | |
| gcongr | |
| exact hshift n | |
| have hzero : Summable (fun n : β => a (n+1)*(0:β)^(n+1)/(n+1).factorial) := by simp | |
| have hs := hasDerivAt_tsum_of_isPreconnected hu isOpen_Ioo (convex_Ioo (-B) B).isPreconnected | |
| (fun n y _ => hg n y) hbound (show (0:β) β Ioo (-B) B from β¨by linarith, hBβ©) hzero | |
| (show x β Ioo (-B) B from abs_lt.mp (by dsimp [B]; linarith)) | |
| have he (y : β) : (β' n : β, a n*y^n/n.factorial) = | |
| a 0 + β' n : β, a (n+1)*y^(n+1)/(n+1).factorial := by | |
| rw [β (summable_growth_exponentialSeries hC hK ha y).sum_add_tsum_nat_add 1] | |
| simp | |
| simpa only [β he] using hs.const_add (a 0) | |
| def poissonMean (a : β β β) (t : β) : β := | |
| Real.exp (-t) * β' n : β, a n*t^n/n.factorial | |
| lemma poissonMean_eq_integral (a : β β β) (r : ββ₯0) : | |
| poissonMean a r = β« n, a n βpoissonMeasure r := by | |
| rw [poissonMean,integral_poissonMeasure,β tsum_mul_left] | |
| apply tsum_congr | |
| intro n | |
| ring | |
| lemma hasDerivAt_poissonMean {a : β β β} {C K : β} | |
| (hC : 0 β€ C) (hK : 0 β€ K) (ha : β n, |a n| β€ C+K*n) (t : β) : | |
| HasDerivAt (poissonMean a) (poissonMean (fun n => a (n+1)-a n) t) t := by | |
| have hshift n : |a (n+1)| β€ (C+K)+K*n := by | |
| have H := ha (n+1) | |
| push_cast at H | |
| linarith | |
| have hd := (((hasDerivAt_id t).neg.exp).mul (hasDerivAt_exponentialSeries hC hK ha t)) | |
| have he : (β' n : β, (a (n+1)-a n)*t^n/n.factorial) = | |
| (β' n : β, a (n+1)*t^n/n.factorial) - β' n : β, a n*t^n/n.factorial := by | |
| rw [β (summable_growth_exponentialSeries (add_nonneg hC hK) hK hshift t).tsum_sub | |
| (summable_growth_exponentialSeries hC hK ha t)] | |
| apply tsum_congr | |
| intro n | |
| ring | |
| convert hd using 1 <;> try rfl | |
| change Real.exp (-t) * (β' n : β, (a (n+1)-a n)*t^n/n.factorial) = | |
| Real.exp (-t) * (-1) * (β' n : β, a n*t^n/n.factorial) + | |
| Real.exp (-t) * (β' n : β, a (n+1)*t^n/n.factorial) | |
| rw [he] | |
| ring | |
| lemma poissonMean_derivative_bound {a : β β β} {K : β} (_hK : 0 β€ K) | |
| (ha : β n, |a (n+1)-a n| β€ K) (r : ββ₯0) : | |
| |poissonMean (fun n => a (n+1)-a n) r| β€ K := by | |
| rw [poissonMean_eq_integral] | |
| exact (abs_integral_le_integral_abs).trans (by | |
| have hi : Integrable (fun n => |a (n+1)-a n|) (poissonMeasure r) := | |
| Integrable.of_bound Measurable.of_discrete.aestronglyMeasurable K | |
| (ae_of_all _ (fun n => by simpa only [Real.norm_eq_abs,abs_abs] using ha n)) | |
| simpa using integral_mono hi (integrable_const K) ha) | |
| theorem poisson_count_derivative {a : β β β} {K : β} (hK : 0 β€ K) | |
| (ha : β n, |a (n+1)-a n| β€ K) (t : β) : | |
| HasDerivAt (poissonMean a) (poissonMean (fun n => a (n+1)-a n) t) t := by | |
| have hg : β n, |a n| β€ |a 0|+K*n := by | |
| intro n | |
| induction n with | |
| | zero => simp | |
| | succ n ih => | |
| have hh : |a (n+1)| β€ |a n|+K := by | |
| calc | |
| _ = |a n+(a (n+1)-a n)| := by congr 1; ring | |
| _ β€ |a n|+|a (n+1)-a n| := abs_add_le _ _ | |
| _ β€ _ := add_le_add_right (ha n) _ | |
| push_cast | |
| linarith | |
| exact hasDerivAt_poissonMean (abs_nonneg _) hK hg t | |
| end IsingPerceptron | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal NNReal | |
| namespace IsingPerceptron | |
| abbrev EnrichedFixedData (n : β) (A : Type*) := ((β β A) Γ LabeledTree n) Γ (β β β) | |
| def enrichedFixedLaw {A : Type*} [MeasurableSpace A] (P : Measure A) | |
| (n : β) (b : β β β) : Measure (EnrichedFixedData n A) := | |
| ((Measure.infinitePi (fun _ : β => P)).prod (labeledCascadeLaw n b)).prod gaussianCoordinates | |
| instance enrichedFixedLaw_probability {A : Type*} [MeasurableSpace A] (P : Measure A) | |
| [IsProbabilityMeasure P] (n : β) (b : β β β) : IsProbabilityMeasure (enrichedFixedLaw P n b) := by | |
| unfold enrichedFixedLaw | |
| infer_instance | |
| def enrichedCountJoin {n : β} {A : Type*} (z : β Γ EnrichedFixedData n A) : EnrichedCylinderData n A := | |
| (((z.1,z.2.1.1),z.2.1.2),z.2.2) | |
| lemma enrichedCountJoin_preserving {A : Type*} [MeasurableSpace A] (P : Measure A) | |
| [IsProbabilityMeasure P] (r : ββ₯0) (n : β) (b : β β β) : | |
| MeasurePreserving (enrichedCountJoin (n := n) (A := A)) | |
| ((poissonMeasure r).prod (enrichedFixedLaw P n b)) (enrichedCylinderLaw P r n b) := by | |
| let ΞΌ := poissonMeasure r | |
| let Ξ½ := Measure.infinitePi (fun _ : β => P) | |
| let Ο := (labeledCascadeLaw n b : Measure (LabeledTree n)) | |
| let Ο := gaussianCoordinates | |
| have h1 := (measurePreserving_prodAssoc ΞΌ (Ξ½.prod Ο) Ο).symm MeasurableEquiv.prodAssoc | |
| have h2 := ((measurePreserving_prodAssoc ΞΌ Ξ½ Ο).symm MeasurableEquiv.prodAssoc).prod | |
| (MeasurePreserving.id Ο) | |
| exact h2.comp h1 | |
| lemma poisson_ae_all {p : β β Prop} {r : ββ₯0} (hr : 0 < r) (hp : βα΅ m βpoissonMeasure r, p m) : | |
| β m, p m := by | |
| intro m | |
| apply ae_iff_of_countable.mp hp m | |
| rw [poissonMeasure_singleton] | |
| apply ne_of_gt | |
| apply ENNReal.ofReal_pos.mpr | |
| positivity | |
| lemma enrichedFixed_pressure_integrable {N : β} (hN : 0 < N) (n : β) (b : β β β) | |
| (hb : CascadeExponents 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 β β} (hm : Measurable Ο) {K : β} (hK : 0 β€ K) | |
| (hΟ : β y x, |Ο y x| β€ K) (m : β) : | |
| Integrable (fun z => enrichedCylinderPressure n h u Ξ½ Ο (enrichedCountJoin (m,z))) (enrichedFixedLaw P n b) := by | |
| have hn : (N:β) β 0 := by exact_mod_cast hN.ne' | |
| have hi := (enrichedCylinderPressure_field_cap hN n b hb hh h0 (le_refl (h n)) u hu Ξ½ P hm hK hΟ | |
| (1:ββ₯0) (Ξ± := 1/N) (by simp [hn])).1 | |
| have hi' := (hi.comp_measurePreserving (enrichedCountJoin_preserving P 1 n b)).integrable (by norm_num) | |
| exact poisson_ae_all (by norm_num : (0:ββ₯0)<1) hi'.prod_right_ae m | |
| lemma enrichedFixed_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) (m : β) : | |
| βα΅ z βenrichedFixedLaw P n b, | |
| Integrable (fun s => Real.exp (enrichedHamiltonian n h u Ο (enrichedCountJoin (m,z)) s)) | |
| (labeledSpinReference n Ξ½ z.1.2) := by | |
| have he := (enrichedCountJoin_preserving P 1 n b).quasiMeasurePreserving.ae | |
| (enrichedCylinder_exp_ae hN n b hh h0 u hu Ξ½ P hK hΟ (1:ββ₯0)) | |
| exact poisson_ae_all (by norm_num : (0:ββ₯0)<1) (Measure.ae_ae_of_ae_prod he) m | |
| lemma abs_cgf_one_le {X : Type*} [MeasurableSpace X] (Ξ½ : Measure X) [IsProbabilityMeasure Ξ½] | |
| {Y : X β β} (hY : Measurable Y) {K : β} (hYb : β x, |Y x| β€ K) : | |
| |cgf Y Ξ½ 1| β€ K := by | |
| have hi : Integrable (fun x => Real.exp (Y x)) Ξ½ := Integrable.of_bound | |
| hY.exp.aestronglyMeasurable (Real.exp K) (ae_of_all _ (fun x => by | |
| simpa only [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] using | |
| Real.exp_le_exp.mpr (le_trans (le_abs_self _) (hYb x)))) | |
| have hp : 0 < β« x, Real.exp (Y x) βΞ½ := MeasureTheory.integral_exp_pos hi | |
| have hu : (β« x, Real.exp (Y x) βΞ½) β€ Real.exp K := by | |
| simpa using integral_mono hi (integrable_const (Real.exp K)) | |
| (fun x => Real.exp_le_exp.mpr (le_trans (le_abs_self _) (hYb x))) | |
| have hl : Real.exp (-K) β€ β« x, Real.exp (Y x) βΞ½ := by | |
| simpa using integral_mono (integrable_const (Real.exp (-K))) hi | |
| (fun x => Real.exp_le_exp.mpr (neg_le.mp (le_trans (neg_le_abs _) (hYb x)))) | |
| unfold cgf mgf | |
| simp only [one_mul] | |
| apply abs_le.mpr | |
| exact β¨by simpa using Real.log_le_log (Real.exp_pos (-K)) hl, | |
| by simpa using Real.log_le_log hp huβ© | |
| end IsingPerceptron | |
| end | |
| end OAI | |