Download data/lean/OAI/Probability/IsingPerceptron/EnrichedFieldCap.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 32.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/EnrichedFieldCap.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/IsingPerceptron/EnrichedFieldCap.lean
-
curl -L -o EnrichedFieldCap.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/IsingPerceptron/EnrichedFieldCap.lean
32.3 kB
| import Mathlib | |
| import OAI.Probability.IsingPerceptron.MonomialGgAtMinimum | |
| namespace OAI | |
| /-! Enriched Field Cap. -/ | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Filter Set | |
| open scoped BigOperators Topology ENNReal NNReal BoundedContinuousFunction | |
| namespace IsingPerceptron | |
| variable {I : Type*} [Fintype I] [MeasurableSpace I] [MeasurableSingletonClass I] | |
| def finiteLogIntegral (Ξ½ : Measure I) (H : I β β) : β := Real.log (β« x, Real.exp (H x) βΞ½) | |
| omit [Fintype I] [MeasurableSingletonClass I] in | |
| lemma finiteLogIntegral_eq_logMean (Ξ½ : Measure I) (H : I β β) : | |
| finiteLogIntegral Ξ½ H = logMean 1 Ξ½ H := by simp [finiteLogIntegral,logMean] | |
| lemma measurable_finiteLogIntegral (Ξ½ : Measure I) : Measurable (finiteLogIntegral Ξ½) := by | |
| unfold finiteLogIntegral | |
| have hm : Measurable (fun p : (I β β) Γ I => Real.exp (p.1 p.2)) := | |
| measurable_from_prod_countable_left (fun i => (measurable_pi_apply i).exp) | |
| exact hm.stronglyMeasurable.integral_prod_right.measurable.log | |
| lemma finiteLogIntegral_lipschitz (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] (H G : I β β) : | |
| |finiteLogIntegral Ξ½ H-finiteLogIntegral Ξ½ G| β€ βH-Gβ := by | |
| rw [finiteLogIntegral_eq_logMean,finiteLogIntegral_eq_logMean] | |
| apply logMean_abs_sub_le Ξ½ (by norm_num) | |
| (show Integrable (fun x => Real.exp (1*H x)) Ξ½ from Integrable.of_finite) | |
| (show Integrable (fun x => Real.exp (1*G x)) Ξ½ from Integrable.of_finite) | |
| intro x | |
| simpa only [Pi.sub_apply,Real.norm_eq_abs] using norm_le_pi_norm (H-G) x | |
| lemma finiteLogIntegral_linearGrowth (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] : | |
| HasLinearGrowth (finiteLogIntegral Ξ½) := by | |
| refine β¨0,1,le_rfl,zero_le_one,fun H => ?_β© | |
| simpa only [finiteLogIntegral,Pi.zero_apply,Real.exp_zero,integral_const,probReal_univ, | |
| one_smul,Real.log_one,sub_zero,one_mul,zero_add] using finiteLogIntegral_lipschitz Ξ½ H 0 | |
| lemma finiteLogIntegral_add_const (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] (H : I β β) (c : β) : | |
| finiteLogIntegral Ξ½ (fun x => c+H x) = c+finiteLogIntegral Ξ½ H := by | |
| simp_rw [finiteLogIntegral_eq_logMean] | |
| exact logMean_const_add Ξ½ one_ne_zero (by simpa only [one_mul] using | |
| (Integrable.of_finite : Integrable (fun x => Real.exp (H x)) Ξ½)) c | |
| def energyRecursion (n : β) (b : β β β) (ΞΌ : β β ProbabilityMeasure (I β β)) | |
| (Ξ½ : Measure I) (H : I β β) : β := | |
| cascadeRecursion n b ΞΌ (fun _ p => p.1+p.2) (finiteLogIntegral Ξ½) H | |
| lemma measurable_energyRecursion (n : β) (b : β β β) | |
| (ΞΌ : β β ProbabilityMeasure (I β β)) (Ξ½ : Measure I) : | |
| Measurable (energyRecursion n b ΞΌ Ξ½) := | |
| measurable_cascadeRecursion n b ΞΌ (fun _ => measurable_fst.add measurable_snd) | |
| (measurable_finiteLogIntegral Ξ½) | |
| lemma energyRecursion_lipschitz (n : β) (b : β β β) | |
| (ΞΌ : β β ProbabilityMeasure (I β β)) (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] | |
| (hΞΌ : β i < n, ExponentialNormMoments (ΞΌ i : Measure (I β β))) | |
| (hb : β i < n, 0 < b i) (H G : I β β) : | |
| |energyRecursion n b ΞΌ Ξ½ H-energyRecursion n b ΞΌ Ξ½ G| β€ βH-Gβ := by | |
| simpa only [one_mul,energyRecursion] using cascadeRecursion_lipschitz n b ΞΌ hΞΌ | |
| (measurable_finiteLogIntegral Ξ½) (finiteLogIntegral_linearGrowth Ξ½) | |
| (L := 1) (fun H G => by simpa only [one_mul] using finiteLogIntegral_lipschitz Ξ½ H G) hb H G | |
| lemma energyRecursion_linearGrowth (n : β) (b : β β β) | |
| (ΞΌ : β β ProbabilityMeasure (I β β)) (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] | |
| (hΞΌ : β i < n, ExponentialNormMoments (ΞΌ i : Measure (I β β))) | |
| (hb : β i < n, 0 < b i) : HasLinearGrowth (energyRecursion n b ΞΌ Ξ½) := | |
| cascadeRecursion_linearGrowth n b ΞΌ hΞΌ (measurable_finiteLogIntegral Ξ½) | |
| (finiteLogIntegral_linearGrowth Ξ½) hb | |
| omit [MeasurableSpace I] [MeasurableSingletonClass I] in | |
| lemma finite_gaussian_exponentialNormMoments [Nonempty I] {Ξ© : Type*} [MeasurableSpace Ξ©] | |
| {P : Measure Ξ©} [IsProbabilityMeasure P] {X : Ξ© β I β β} | |
| (hX : Measurable X) (m : I β β) (v : I β ββ₯0) | |
| (hlaw : β i, P.map (fun Ο => X Ο i) = gaussianReal (m i) (v i)) : | |
| ExponentialNormMoments (P.map X) := by | |
| intro a | |
| have hi (i : I) : Integrable (fun Ο => Real.exp (|a| * |X Ο i|)) P := by | |
| have hh := gaussianReal_exponentialNormMoments (m i) (v i) (|a|) | |
| rw [β hlaw i] at hh | |
| have hm : Measurable (fun Ο => X Ο i) := (measurable_pi_apply i).comp hX | |
| simpa only [Function.comp_def,Real.norm_eq_abs] using | |
| (integrable_map_measure (by fun_prop) hm.aemeasurable).mp hh | |
| apply (integrable_map_measure (by fun_prop) hX.aemeasurable).mpr | |
| apply (integrable_finsetSum Finset.univ (fun i _ => hi i)).mono' | |
| Β· fun_prop | |
| Β· apply ae_of_all | |
| intro Ο | |
| obtain β¨i,_,hiβ© := Finset.exists_max_image Finset.univ (fun i : I => |X Ο i|) Finset.univ_nonempty | |
| have hn : βX Οβ β€ |X Ο i| := (pi_norm_le_iff_of_nonneg (abs_nonneg _)).mpr | |
| (fun j => by simpa only [Real.norm_eq_abs] using hi j (Finset.mem_univ _)) | |
| change |Real.exp (a * βX Οβ)| β€ _ | |
| rw [abs_of_pos (Real.exp_pos _)] | |
| calc | |
| _ β€ Real.exp (|a| * |X Ο i|) := Real.exp_le_exp.mpr | |
| (le_trans (mul_le_mul_of_nonneg_right (le_abs_self a) (norm_nonneg _)) | |
| (mul_le_mul_of_nonneg_left hn (abs_nonneg a))) | |
| _ β€ β j : I, Real.exp (|a| * |X Ο j|) := | |
| Finset.single_le_sum (f := fun j : I => Real.exp (|a| * |X Ο j|)) (fun j _ => (Real.exp_pos _).le) (Finset.mem_univ i) | |
| end IsingPerceptron | |
| namespace IsingPerceptron | |
| theorem variance_of_conditional_center {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] | |
| (ΞΌ : Measure A) (Ξ½ : Measure B) [IsProbabilityMeasure ΞΌ] [IsProbabilityMeasure Ξ½] | |
| {F : A Γ B β β} {X : A β β} (hF : Measurable F) (hX : MemLp X 2 ΞΌ) | |
| (hi : β a, Integrable (fun b => (F (a,b)-X a)^2) Ξ½) | |
| (hc : β a, β« b, F (a,b) βΞ½ = X a) {C : β} | |
| (hb : β a, (β« b, (F (a,b)-X a)^2 βΞ½) β€ C) : | |
| MemLp F 2 (ΞΌ.prod Ξ½) β§ Var[F; ΞΌ.prod Ξ½] β€ C+Var[X; ΞΌ] := by | |
| let D : A Γ B β β := fun p => F p-X p.1 | |
| have hd : AEStronglyMeasurable D (ΞΌ.prod Ξ½) := | |
| hF.aestronglyMeasurable.sub (hX.aestronglyMeasurable.comp_measurePreserving | |
| (measurePreserving_fst (ΞΌ := ΞΌ) (Ξ½ := Ξ½))) | |
| have hdi : Integrable (fun p => (D p)^2) (ΞΌ.prod Ξ½) := by | |
| apply (integrable_prod_iff (hd.pow 2)).mpr | |
| refine β¨ae_of_all _ hi, ?_β© | |
| have hnorm : (fun a => β« b, β(D (a,b))^2β βΞ½) = | |
| fun a => β« b, (D (a,b))^2 βΞ½ := by | |
| ext a | |
| apply integral_congr_ae | |
| apply ae_of_all | |
| intro b | |
| exact Real.norm_of_nonneg (sq_nonneg _) | |
| change Integrable (fun a => β« b, β(D (a,b))^2β βΞ½) ΞΌ | |
| rw [hnorm] | |
| apply Integrable.of_bound (hd.pow 2).integral_prod_right' C | |
| apply ae_of_all | |
| intro a | |
| change ββ« b, (D (a,b))^2 βΞ½β β€ C | |
| rw [Real.norm_of_nonneg (integral_nonneg (fun b => sq_nonneg (D (a,b))))] | |
| exact hb a | |
| have hDLp : MemLp D 2 (ΞΌ.prod Ξ½) := (memLp_two_iff_integrable_sq hd).mpr hdi | |
| have hfLp : MemLp F 2 (ΞΌ.prod Ξ½) := by | |
| convert hDLp.add (hX.comp_measurePreserving (measurePreserving_fst (ΞΌ := ΞΌ) (Ξ½ := Ξ½))) using 1 | |
| ext p | |
| simp [D] | |
| refine β¨hfLp, ?_β© | |
| have hsecLp (a : A) : MemLp (fun b => F (a,b)) 2 Ξ½ := by | |
| have hdm : Measurable (fun b => F (a,b)-X a) := | |
| (hF.comp (measurable_const.prodMk measurable_id)).sub measurable_const | |
| have hL := (memLp_two_iff_integrable_sq hdm.aestronglyMeasurable).mpr (hi a) | |
| convert hL.add (memLp_const (X a)) using 1 | |
| ext b | |
| simp | |
| have hsec (a : A) : (β« b, F (a,b)^2 βΞ½) β€ C+(X a)^2 := by | |
| have hv := hb a | |
| have he := variance_eq_integral (hsecLp a).aemeasurable | |
| rw [hc a] at he | |
| rw [β he, variance_eq_sub (hsecLp a)] at hv | |
| simp only [Pi.pow_apply,hc a] at hv | |
| linarith | |
| have hh := integral_mono hfLp.integrable_sq.integral_prod_left | |
| ((integrable_const C).add hX.integrable_sq) hsec | |
| simp only [Pi.add_apply] at hh | |
| rw [integral_add (integrable_const _) hX.integrable_sq,integral_const, | |
| probReal_univ,one_smul] at hh | |
| rw [variance_eq_sub hfLp,variance_eq_sub hX] | |
| simp only [Pi.pow_apply] | |
| rw [integral_prod _ hfLp.integrable_sq, | |
| integral_prod _ (hfLp.integrable (by norm_num))] | |
| simp_rw [hc] | |
| linarith | |
| variable {I : Type} [Fintype I] [MeasurableSpace I] [MeasurableSingletonClass I] | |
| def cascadeEnergyLog (n : β) (b : β β β) (ΞΌ : β β ProbabilityMeasure (I β β)) | |
| (Ξ½ : Measure I) (H : I β β) (T : NoiseTree (I β β) n) : β := | |
| Real.log ((terminalTreeFactor n b ΞΌ (fun _ p => p.1+p.2) (finiteLogIntegral Ξ½) H T).toReal / | |
| (noiseTreeTotal (I β β) n T).toReal) | |
| lemma measurable_cascadeEnergyLog (n : β) (b : β β β) (ΞΌ : β β ProbabilityMeasure (I β β)) | |
| (Ξ½ : Measure I) : Measurable (fun p : (I β β) Γ NoiseTree (I β β) n => | |
| cascadeEnergyLog n b ΞΌ Ξ½ p.1 p.2) := by | |
| have hm := measurable_noiseTreeFactor n b ΞΌ | |
| (fun _ => measurable_finiteLogIntegral Ξ½) (fun _ => measurable_fst.add measurable_snd) | |
| simp only [noiseTreeFactor_terminal] at hm | |
| exact hm.ennreal_toReal.div | |
| (((measurable_noiseTreeTotal (I β β) n).comp measurable_snd).ennreal_toReal) |>.log | |
| theorem cascadeEnergyLog_conditional (n : β) (b : β β β) (hb : CascadeExponents n b) | |
| (ΞΌ : β β ProbabilityMeasure (I β β)) (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] | |
| (hΞΌ : β i < n, ExponentialNormMoments (ΞΌ i : Measure (I β β))) (H : I β β) : | |
| let P := (noiseCascadeLaw (I β β) n b ΞΌ : Measure (NoiseTree (I β β) n)) | |
| Integrable (cascadeEnergyLog n b ΞΌ Ξ½ H) P β§ | |
| (β« T, cascadeEnergyLog n b ΞΌ Ξ½ H T βP) = energyRecursion n b ΞΌ Ξ½ H β§ | |
| Integrable (fun T => (cascadeEnergyLog n b ΞΌ Ξ½ H T-energyRecursion n b ΞΌ Ξ½ H)^2) P β§ | |
| (β« T, (cascadeEnergyLog n b ΞΌ Ξ½ H T-energyRecursion n b ΞΌ Ξ½ H)^2 βP) β€ | |
| 4*β« T, (Real.log (rawTreeTotal n T).toReal)^2 β(rawCascadeLaw n b : Measure (RawTree n)) := by | |
| exact (linearGrowth_noiseCascade_recursion n b hb ΞΌ hΞΌ | |
| (measurable_finiteLogIntegral Ξ½) (finiteLogIntegral_linearGrowth Ξ½) H).2 | |
| theorem cascadeEnergyLog_variance {Ξ© : Type*} [MeasurableSpace Ξ©] | |
| (P : Measure Ξ©) [IsProbabilityMeasure P] (n : β) (b : β β β) (hb : CascadeExponents n b) | |
| (ΞΌ : β β ProbabilityMeasure (I β β)) (Ξ½ : Measure I) [IsProbabilityMeasure Ξ½] | |
| (hΞΌ : β i < n, ExponentialNormMoments (ΞΌ i : Measure (I β β))) | |
| {H : Ξ© β I β β} (hH : Measurable H) (hL : MemLp (fun Ο => energyRecursion n b ΞΌ Ξ½ (H Ο)) 2 P) : | |
| MemLp (fun p : Ξ© Γ NoiseTree (I β β) n => cascadeEnergyLog n b ΞΌ Ξ½ (H p.1) p.2) 2 | |
| (P.prod (noiseCascadeLaw (I β β) n b ΞΌ : Measure (NoiseTree (I β β) n))) β§ | |
| Var[(fun p : Ξ© Γ NoiseTree (I β β) n => cascadeEnergyLog n b ΞΌ Ξ½ (H p.1) p.2); | |
| P.prod (noiseCascadeLaw (I β β) n b ΞΌ : Measure (NoiseTree (I β β) n))] β€ | |
| 4*β« T, (Real.log (rawTreeTotal n T).toReal)^2 β(rawCascadeLaw n b : Measure (RawTree n)) | |
| +Var[(fun Ο => energyRecursion n b ΞΌ Ξ½ (H Ο)); P] := by | |
| exact variance_of_conditional_center P _ | |
| ((measurable_cascadeEnergyLog n b ΞΌ Ξ½).comp ((hH.comp measurable_fst).prodMk measurable_snd)) hL | |
| (fun Ο => (cascadeEnergyLog_conditional n b hb ΞΌ Ξ½ hΞΌ (H Ο)).2.2.1) | |
| (fun Ο => (cascadeEnergyLog_conditional n b hb ΞΌ Ξ½ hΞΌ (H Ο)).2.1) | |
| (fun Ο => (cascadeEnergyLog_conditional n b hb ΞΌ Ξ½ hΞΌ (H Ο)).2.2.2) | |
| end IsingPerceptron | |
| namespace IsingPerceptron | |
| def tagCoefficients (j : β) (a : β ββ β) : β ββ β := Finsupp.mapDomain (Nat.pair j) a | |
| lemma pair_left_injective (j : β) : Function.Injective (Nat.pair j) := by | |
| intro a b h | |
| have := congrArg Nat.unpair h | |
| simpa only [Nat.unpair_pair,Prod.mk.injEq,true_and] using this | |
| lemma tagCoefficients_apply (j : β) (a : β ββ β) (i : β) : | |
| tagCoefficients j a (Nat.pair j i) = a i := | |
| Finsupp.mapDomain_apply_of_injective (pair_left_injective j) a i | |
| lemma tagCoefficients_other {j k : β} (hjk : j β k) (a : β ββ β) (i : β) : | |
| tagCoefficients j a (Nat.pair k i) = 0 := by | |
| apply Finsupp.mapDomain_of_notMem_range | |
| rintro β¨v,hvβ© | |
| have := congrArg Nat.unpair hv | |
| simp only [Nat.unpair_pair,Prod.mk.injEq] at this | |
| exact hjk this.1 | |
| lemma cylinderCross_tag (j k : β) (a b : β ββ β) : | |
| cylinderCross (tagCoefficients j a) (tagCoefficients k b) = | |
| if j = k then cylinderCross a b else 0 := by | |
| classical | |
| unfold cylinderCross tagCoefficients | |
| rw [Finsupp.sum_mapDomain_index_inj (pair_left_injective j)] | |
| by_cases h : j = k | |
| Β· subst k | |
| simp only [ite_true,Finsupp.mapDomain_apply_of_injective (pair_left_injective j)] | |
| Β· simp only [h,ite_false] | |
| change a.sum (fun i c => c*tagCoefficients k b (Nat.pair j i)) = 0 | |
| simp only [tagCoefficients_other (Ne.symm h),mul_zero] | |
| simp [Finsupp.sum] | |
| lemma cylinderCross_smul (r t : β) (a b : β ββ β) : | |
| cylinderCross (r β’ a) (t β’ b) = r*t*cylinderCross a b := by | |
| unfold cylinderCross | |
| rw [Finsupp.sum_smul_index (fun _ => zero_mul _)] | |
| simp only [Finsupp.smul_apply,smul_eq_mul,Finsupp.sum] | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| ring | |
| lemma cylinderCross_sum_right {ΞΉ : Type*} (s : Finset ΞΉ) (a : β ββ β) (b : ΞΉ β β ββ β) : | |
| cylinderCross a (β i β s, b i) = β i β s, cylinderCross a (b i) := by | |
| classical | |
| simp only [cylinderCross,Finsupp.finsetSum_apply,Finsupp.sum,Finset.mul_sum] | |
| exact Finset.sum_comm | |
| lemma cylinderCross_tagged_sum {m : β} (a b : Fin m β β ββ β) : | |
| cylinderCross (β i : Fin m, tagCoefficients i (a i)) (β i : Fin m, tagCoefficients i (b i)) = | |
| β i, cylinderCross (a i) (b i) := by | |
| classical | |
| rw [cylinderCross_finset_left] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| rw [cylinderCross_sum_right] | |
| simp only [cylinderCross_tag,Fin.val_inj] | |
| simp | |
| def monomialIndex (j : β) : β Γ β := Nat.unpair (j+1) | |
| lemma monomialIndex_nonzero (j : β) : monomialIndex j β (0,0) := by | |
| intro h | |
| have hp := congrArg (fun z : β Γ β => Nat.pair z.1 z.2) h | |
| simp only [monomialIndex,Nat.pair_unpair] at hp | |
| norm_num [Nat.pair] at hp | |
| lemma monomialIndex_surjective (p d : β) (h : p+d β₯ 1) : | |
| β j, monomialIndex j = (p,d) := by | |
| have hn : Nat.pair p d β 0 := by | |
| intro he | |
| have : (p,d) = (0,0) := by simpa using congrArg Nat.unpair he | |
| have hp := congrArg Prod.fst this | |
| have hd := congrArg Prod.snd this | |
| omega | |
| refine β¨Nat.pair p d-1,?_β© | |
| simp only [monomialIndex,Nat.sub_add_cancel (Nat.one_le_iff_ne_zero.mpr hn),Nat.unpair_pair] | |
| def perturbationScale (N : β) : β := (N : β)^(-1/16 : β) | |
| def perturbationWeight (j : β) : β := (1/2 : β)^(j+1) | |
| def externalFieldCoefficients {N : β} (n : β) (h : β β β) | |
| (s : Spin N Γ LabeledLeaf n) : β ββ β := | |
| treeFieldCoefficients n s.2 (fun i => pathAmplitude h i) (fun i => spinValue (s.1 i)) | |
| lemma externalFieldCoefficients_variance {N : β} (n : β) {h : β β β} | |
| (hh : Monotone h) (h0 : 0 β€ h 0) (s : Spin N Γ LabeledLeaf n) : | |
| (externalFieldCoefficients n h s).sum (fun _ c => c^2) = N*h n := by | |
| rw [β cylinderCross_self,externalFieldCoefficients,treeField_path_cross n _ _ hh h0, | |
| labeledCommonDepth_self] | |
| simp only [β pow_two,spinValue_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_one] | |
| ring | |
| def enrichedCoefficients {N : β} (n : β) (h : β β β) (u : Fin N β β) | |
| (s : Spin N Γ LabeledLeaf n) : β ββ β := | |
| β i : Fin (N+1), tagCoefficients i | |
| (Fin.cases (externalFieldCoefficients n h s) | |
| (fun j => (Real.sqrt N*perturbationScale N*perturbationWeight j*u j) β’ | |
| monomialCoefficients n (monomialIndex j).1 (monomialIndex j).2 s) i) | |
| lemma perturbationWeight_sum (N : β) : | |
| (β j : Fin N, perturbationWeight j) = 1-(1/2 : β)^N := by | |
| rw [Fin.sum_univ_eq_sum_range] | |
| induction N with | |
| | zero => simp | |
| | succ N ih => | |
| rw [Finset.sum_range_succ,ih] | |
| simp only [perturbationWeight,pow_succ] | |
| ring | |
| lemma perturbationWeight_nonneg (j : β) : 0 β€ perturbationWeight j := by | |
| exact pow_nonneg (by norm_num) _ | |
| lemma perturbationWeight_le_one (j : β) : perturbationWeight j β€ 1 := by | |
| exact pow_le_oneβ (by norm_num) (by norm_num) | |
| lemma enrichedCoefficients_variance_le {N : β} (hN : 0 < N) (n : β) | |
| {h : β β β} (hh : Monotone h) (h0 : 0 β€ h 0) (u : Fin N β β) | |
| (hu : β j, |u j| β€ 2) (s : Spin N Γ LabeledLeaf n) : | |
| (enrichedCoefficients n h u s).sum (fun _ c => c^2) β€ | |
| N*h n+4*N*(perturbationScale N)^2 := by | |
| rw [β cylinderCross_self,enrichedCoefficients,cylinderCross_tagged_sum,Fin.sum_univ_succ] | |
| simp only [Fin.cases_zero,Fin.cases_succ] | |
| simp_rw [cylinderCross_smul] | |
| simp_rw [cylinderCross_self] | |
| rw [externalFieldCoefficients_variance n hh h0] | |
| apply add_le_add_right | |
| calc | |
| _ β€ β j : Fin N, (4*N*(perturbationScale N)^2)*perturbationWeight j := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| have hv := monomialCoefficients_variance_le hN n (monomialIndex j).1 (monomialIndex j).2 s | |
| have hw := perturbationWeight_nonneg j | |
| have hw1 := perturbationWeight_le_one j | |
| have hu2 : (u j)^2 β€ 4 := by | |
| have hab := abs_le.mp (hu j) | |
| nlinarith | |
| have hs : (Real.sqrt N)^2 = (N : β) := Real.sq_sqrt (Nat.cast_nonneg N) | |
| have ho : (Real.sqrt N*perturbationScale N*perturbationWeight j*u j) * | |
| (Real.sqrt N*perturbationScale N*perturbationWeight j*u j) = | |
| N*(perturbationScale N)^2*(perturbationWeight j)^2*(u j)^2 := by | |
| calc | |
| _ = (Real.sqrt N)^2*(perturbationScale N)^2*(perturbationWeight j)^2*(u j)^2 := by ring | |
| _ = _ := by rw [hs] | |
| rw [ho] | |
| calc | |
| _ β€ N*(perturbationScale N)^2*(perturbationWeight j)^2*(u j)^2 := | |
| mul_le_of_le_one_right (by positivity) hv | |
| _ β€ N*(perturbationScale N)^2*(perturbationWeight j)^2*4 := | |
| mul_le_mul_of_nonneg_left hu2 (by positivity) | |
| _ β€ (4*N*(perturbationScale N)^2)*perturbationWeight j := by | |
| have hww : (perturbationWeight j)^2 β€ perturbationWeight j := by nlinarith | |
| nlinarith [mul_le_mul_of_nonneg_left hww (show 0 β€ 4*N*(perturbationScale N)^2 by positivity)] | |
| _ = (4*N*(perturbationScale N)^2)*(1-(1/2 : β)^N) := by | |
| rw [β Finset.mul_sum,perturbationWeight_sum] | |
| _ β€ _ := mul_le_of_le_one_right (by positivity) (by linarith [pow_nonneg (show (0 : β) β€ 1/2 by norm_num) N]) | |
| abbrev EnrichedBlock (N : β) := Fin N β (Ξ£ j : Fin N, Fin (monomialIndex j).1 β Fin N) | |
| def enrichedLevelCoefficient {N : β} (n : β) (h : β β β) (u : Fin N β β) | |
| (i : β) (x : Spin N) : EnrichedBlock N β β | |
| | .inl a => pathAmplitude h i * spinValue (x a) | |
| | .inr β¨j,tβ© => (Real.sqrt N*perturbationScale N*perturbationWeight j*u j) * | |
| pathAmplitude (monomialPath n (monomialIndex j).2) i * | |
| tensorFeature (monomialIndex j).1 (spinCoordinate x) t | |
| lemma spinValue_abs (x : Fin 2) : |spinValue x| = 1 := by | |
| simp only [spinValue] | |
| split_ifs <;> norm_num | |
| lemma spinCoordinate_abs {N : β} (x : Spin N) (i : Fin N) : | |
| |spinCoordinate x i| = 1/Real.sqrt N := by | |
| simp only [spinCoordinate,abs_div,spinValue_abs,abs_of_nonneg (Real.sqrt_nonneg _)] | |
| lemma tensorFeature_spin_abs {N p : β} (x : Spin N) (i : Fin p β Fin N) : | |
| |tensorFeature p (spinCoordinate x) i| = (1/Real.sqrt N)^p := by | |
| simp only [tensorFeature,Finset.abs_prod,spinCoordinate_abs,Finset.prod_const, | |
| Finset.card_univ,Fintype.card_fin] | |
| lemma enrichedLevelCoefficient_abs {N : β} (n : β) (h : β β β) (u : Fin N β β) | |
| (i : β) (x y : Spin N) (j : EnrichedBlock N) : | |
| |enrichedLevelCoefficient n h u i x j| = |enrichedLevelCoefficient n h u i y j| := by | |
| rcases j with j | β¨j,tβ© | |
| Β· simp only [enrichedLevelCoefficient,abs_mul,spinValue_abs] | |
| Β· simp only [enrichedLevelCoefficient,abs_mul,tensorFeature_spin_abs] | |
| lemma sum_scaled_cross {J : Type*} [Fintype J] (c : β) (v w : J β β) : | |
| (β j, (c*v j)*(c*w j)) = c^2*(β j, v j*w j) := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| ring | |
| lemma enrichedLevelCoefficient_cross {N : β} (hN : 0 < N) (n : β) {h : β β β} | |
| (hh : Monotone h) (h0 : 0 β€ h 0) (u : Fin N β β) (i : β) (x y : Spin N) : | |
| (β j : EnrichedBlock N, enrichedLevelCoefficient n h u i x j * enrichedLevelCoefficient n h u i y j) = | |
| N*pathIncrement h i*spinOverlap x y + | |
| β j : Fin N, (Real.sqrt N*perturbationScale N*perturbationWeight j*u j)^2 * | |
| pathIncrement (monomialPath n (monomialIndex j).2) i * (spinOverlap x y)^(monomialIndex j).1 := by | |
| classical | |
| rw [Fintype.sum_sum_type,Fintype.sum_sigma] | |
| simp only [enrichedLevelCoefficient] | |
| rw [sum_scaled_cross,pathAmplitude_sq hh h0] | |
| have he : (β j : Fin N, spinValue (x j)*spinValue (y j)) = N*spinOverlap x y := by | |
| rw [spinOverlap,mul_div_cancelβ _ (Nat.cast_ne_zero.mpr hN.ne')] | |
| rw [he] | |
| congr 1 | |
| Β· ring | |
| Β· apply Finset.sum_congr rfl | |
| intro j _ | |
| rw [sum_scaled_cross,tensorFeature_cross,spinCoordinate_cross,mul_pow, | |
| pathAmplitude_sq (monomialPath_monotone n _) (monomialPath_nonneg n _ 0)] | |
| lemma enrichedLevelCoefficient_variance {N : β} (hN : 0 < N) (n : β) {h : β β β} | |
| (hh : Monotone h) (h0 : 0 β€ h 0) (u : Fin N β β) (i : β) (x : Spin N) : | |
| (β j : EnrichedBlock N, (enrichedLevelCoefficient n h u i x j)^2) = | |
| N*pathIncrement h i + | |
| β j : Fin N, (Real.sqrt N*perturbationScale N*perturbationWeight j*u j)^2 * | |
| pathIncrement (monomialPath n (monomialIndex j).2) i := by | |
| simpa only [β pow_two,spinOverlap_self hN,one_pow,mul_one] using | |
| enrichedLevelCoefficient_cross hN n hh h0 u i x x | |
| lemma enrichedRoot_envelope_sq {N : β} (hN : 0 < N) (n : β) {h : β β β} | |
| (hh : Monotone h) (h0 : 0 β€ h 0) (u : Fin N β β) (hu : β j, |u j| β€ 2) (x : Spin N) : | |
| (β j : EnrichedBlock N, |enrichedLevelCoefficient n h u 0 x j|^2) β€ N*h 0+4*N*(perturbationScale N)^2 := by | |
| simp only [sq_abs,enrichedLevelCoefficient_variance hN n hh h0 u 0 x,pathIncrement] | |
| apply add_le_add_right | |
| calc | |
| _ β€ β j : Fin N, (4*N*(perturbationScale N)^2)*perturbationWeight j := by | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| have hv : monomialPath n (monomialIndex j).2 0 β€ 1 := | |
| (monomialPath_monotone n (monomialIndex j).2 (Nat.zero_le n)).trans | |
| (monomialPath_diag_le_one n (monomialIndex j).2) | |
| have hw := perturbationWeight_nonneg j | |
| have hw1 := perturbationWeight_le_one j | |
| have hu2 : (u j)^2 β€ 4 := by | |
| have hab := abs_le.mp (hu j) | |
| nlinarith | |
| have he : (Real.sqrt N*perturbationScale N*perturbationWeight j*u j)^2 = | |
| N*(perturbationScale N)^2*(perturbationWeight j)^2*(u j)^2 := by | |
| simp only [mul_pow,Real.sq_sqrt (Nat.cast_nonneg N)] | |
| rw [he] | |
| calc | |
| _ β€ N*(perturbationScale N)^2*(perturbationWeight j)^2*(u j)^2 := | |
| mul_le_of_le_one_right (by positivity) hv | |
| _ β€ N*(perturbationScale N)^2*(perturbationWeight j)^2*4 := | |
| mul_le_mul_of_nonneg_left hu2 (by positivity) | |
| _ β€ (4*N*(perturbationScale N)^2)*perturbationWeight j := by | |
| have hww : (perturbationWeight j)^2 β€ perturbationWeight j := by nlinarith | |
| nlinarith [mul_le_mul_of_nonneg_left hww (show 0 β€ 4*N*(perturbationScale N)^2 by positivity)] | |
| _ = (4*N*(perturbationScale N)^2)*(1-(1/2 : β)^N) := by | |
| rw [β Finset.mul_sum,perturbationWeight_sum] | |
| _ β€ _ := mul_le_of_le_one_right (by positivity) | |
| (by linarith [pow_nonneg (show (0 : β) β€ 1/2 by norm_num) N]) | |
| lemma variance_le_square_about_const {Ξ© : Type*} [MeasurableSpace Ξ©] | |
| {ΞΌ : Measure Ξ©} [IsProbabilityMeasure ΞΌ] {F : Ξ© β β} (hF : MemLp F 2 ΞΌ) (a : β) : | |
| Var[F; ΞΌ] β€ β« x, (F x-a)^2 βΞΌ := by | |
| have hs := variance_eq_sub (hF.sub (memLp_const a)) | |
| simp only [Pi.sub_apply, Pi.pow_apply] at hs | |
| change Var[fun x => F x-a; ΞΌ] = _ at hs | |
| rw [variance_sub_const hF.aestronglyMeasurable a] at hs | |
| linarith [sq_nonneg (β« x, F x-a βΞΌ)] | |
| lemma gaussian_coord_memLp {n : β} {F : (Fin n β β) β β} {c : Fin n β β} | |
| (hm : Measurable F) | |
| (hl : β x y, |F x-F y| β€ β i, c i*|x i-y i|) (p : ββ₯0) : | |
| MemLp F p (Measure.pi (fun _ : Fin n => gaussianReal 0 1)) := by | |
| have hcoord (i : Fin n) : MemLp (fun x : Fin n β β => c i*|x i|) p | |
| (Measure.pi (fun _ : Fin n => gaussianReal 0 1)) := by | |
| have h := (memLp_id_gaussianReal p).comp_measurePreserving | |
| (measurePreserving_eval (fun _ : Fin n => gaussianReal 0 1) i) | |
| simpa only [Function.comp_def, id_eq, Pi.abs_apply] using h.abs.const_mul (c i) | |
| have hb := (memLp_const |F 0|).add (memLp_finsetSum Finset.univ (fun i _ => hcoord i)) | |
| apply hb.mono' hm.aestronglyMeasurable | |
| refine Eventually.of_forall fun x => ?_ | |
| have hx := hl x 0 | |
| simp only [Pi.zero_apply, sub_zero] at hx | |
| simp only [Pi.add_apply, Real.norm_eq_abs] | |
| linarith [abs_sub_abs_le_abs_sub (F x) (F 0)] | |
| lemma gaussian_variance_of_slope {F : β β β} (hm : Measurable F) {c : β} | |
| (hl : β x y, |F x-F y| β€ c*|x-y|) : Var[F; gaussianReal 0 1] β€ c^2 := by | |
| have hLp : MemLp F 2 (gaussianReal 0 1) := by | |
| apply ((memLp_const |F 0|).add ((memLp_id_gaussianReal 2).abs.const_mul c)).mono' | |
| hm.aestronglyMeasurable | |
| refine Eventually.of_forall fun x => ?_ | |
| have hx := hl x 0 | |
| simp only [sub_zero] at hx | |
| simp only [Real.norm_eq_abs, Pi.add_apply, Pi.abs_apply, id_eq] | |
| linarith [abs_sub_abs_le_abs_sub (F x) (F 0)] | |
| have hsq : (β« x : β, x^2 βgaussianReal 0 1) = 1 := by | |
| have h := variance_eq_sub (memLp_id_gaussianReal (ΞΌ := 0) (v := 1) 2) | |
| simpa only [variance_id_gaussianReal, NNReal.coe_one, integral_id_gaussianReal, | |
| sq, mul_zero, sub_zero, Pi.pow_apply, id_eq] using h.symm | |
| calc | |
| _ β€ β« x, (F x-F 0)^2 βgaussianReal 0 1 := variance_le_square_about_const hLp _ | |
| _ β€ β« x : β, c^2*x^2 βgaussianReal 0 1 := by | |
| apply integral_mono (hLp.sub (memLp_const _)).integrable_sq | |
| ((memLp_id_gaussianReal 2).integrable_sq.const_mul _) | |
| intro x | |
| have hx := hl x 0 | |
| simp only [sub_zero] at hx | |
| have hh := pow_le_pow_leftβ (abs_nonneg (F x-F 0)) hx 2 | |
| simpa only [sq_abs, mul_pow, Pi.sub_apply, id_eq] using hh | |
| _ = c^2 := by rw [integral_const_mul, hsq, mul_one] | |
| lemma gaussian_slope_memLp {F : β β β} (hm : Measurable F) {c : β} | |
| (hl : β x y, |F x-F y| β€ c*|x-y|) (p : ββ₯0) : | |
| MemLp F p (gaussianReal 0 1) := by | |
| apply ((memLp_const |F 0|).add ((memLp_id_gaussianReal p).abs.const_mul c)).mono' | |
| hm.aestronglyMeasurable | |
| refine Eventually.of_forall fun x => ?_ | |
| have hx := hl x 0 | |
| simp only [sub_zero] at hx | |
| simp only [Real.norm_eq_abs, Pi.add_apply, Pi.abs_apply, id_eq] | |
| linarith [abs_sub_abs_le_abs_sub (F x) (F 0)] | |
| lemma variance_prod_le_fiber {A B : Type*} [MeasurableSpace A] [MeasurableSpace B] | |
| {ΞΌ : Measure A} {Ξ½ : Measure B} [IsProbabilityMeasure ΞΌ] [IsProbabilityMeasure Ξ½] | |
| {F : A Γ B β β} (hLp : MemLp F 2 (ΞΌ.prod Ξ½)) | |
| (hsecLp : β b, MemLp (fun a => F (a,b)) 2 ΞΌ) | |
| (hGLp : MemLp (fun b => β« a, F (a,b) βΞΌ) 2 Ξ½) {C : β} | |
| (hvar : β b, Var[fun a => F (a,b); ΞΌ] β€ C) : | |
| Var[F; ΞΌ.prod Ξ½] β€ C + Var[fun b => β« a, F (a,b) βΞΌ; Ξ½] := by | |
| have hsec : β b, (β« a, F (a,b)^2 βΞΌ) β€ C + (β« a, F (a,b) βΞΌ)^2 := by | |
| intro b | |
| have h := hvar b | |
| rw [variance_eq_sub (hsecLp b)] at h | |
| simp only [Pi.pow_apply] at h | |
| linarith | |
| have hs := integral_mono hLp.integrable_sq.integral_prod_right | |
| ((integrable_const C).add hGLp.integrable_sq) hsec | |
| simp only [Pi.add_apply] at hs | |
| rw [integral_add (integrable_const _) hGLp.integrable_sq, integral_const, | |
| probReal_univ, one_smul] at hs | |
| rw [variance_eq_sub hLp, variance_eq_sub hGLp] | |
| simp only [Pi.pow_apply] | |
| rw [integral_prod_symm _ hLp.integrable_sq, | |
| integral_prod_symm _ (hLp.integrable (by norm_num))] | |
| linarith | |
| theorem gaussian_variance_coordinate_bound (n : β) {F : (Fin n β β) β β} | |
| (hm : Measurable F) {c : Fin n β β} | |
| (hl : β x y, |F x-F y| β€ β i, c i*|x i-y i|) : | |
| Var[F; Measure.pi (fun _ : Fin n => gaussianReal 0 1)] β€ β i, (c i)^2 := by | |
| induction n with | |
| | zero => | |
| have hF : F = fun _ => F (fun i : Fin 0 => i.elim0) := by | |
| funext x | |
| congr 1 | |
| funext i | |
| exact i.elim0 | |
| rw [hF, variance_eq_integral measurable_const.aemeasurable] | |
| simp | |
| | succ n ih => | |
| let ΞΌ := gaussianReal (0 : β) (1 : ββ₯0) | |
| let Ξ½ := Measure.pi (fun _ : Fin n => ΞΌ) | |
| have hcons : Measurable (fun z : β Γ (Fin n β β) => (Fin.cons z.1 z.2 : Fin (n+1) β β)) := by | |
| apply Measurable.of_eval | |
| intro i | |
| refine Fin.cases ?_ (fun j => ?_) i | |
| Β· simpa only [Fin.cons_zero] using | |
| (measurable_fst : Measurable (Prod.fst : β Γ (Fin n β β) β β)) | |
| Β· simpa only [Fin.cons_succ, Function.comp_def] using (measurable_pi_apply j).comp | |
| (measurable_snd : Measurable (Prod.snd : β Γ (Fin n β β) β (Fin n β β))) | |
| have hFm : Measurable (fun z : β Γ (Fin n β β) => F (Fin.cons z.1 z.2)) := hm.comp hcons | |
| have hsm (x : Fin n β β) : Measurable (fun a => F (Fin.cons a x)) := | |
| hFm.comp (measurable_id.prodMk measurable_const) | |
| have hsl (x : Fin n β β) : β a b, | |
| |F (Fin.cons a x)-F (Fin.cons b x)| β€ c 0*|a-b| := by | |
| intro a b | |
| simpa only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, | |
| sub_self, abs_zero, mul_zero, Finset.sum_const_zero, add_zero] using | |
| hl (Fin.cons a x) (Fin.cons b x) | |
| have hsi (x : Fin n β β) : Integrable (fun a => F (Fin.cons a x)) ΞΌ := | |
| (gaussian_slope_memLp (hsm x) (hsl x) 1).integrable (by norm_num) | |
| have hGm : Measurable (fun x => β« a, F (Fin.cons a x) βΞΌ) := | |
| hFm.stronglyMeasurable.integral_prod_left'.measurable | |
| have hGl : β x y, |(β« a, F (Fin.cons a x) βΞΌ)-(β« a, F (Fin.cons a y) βΞΌ)| β€ | |
| β i : Fin n, c i.succ*|x i-y i| := by | |
| intro x y | |
| rw [β integral_sub (hsi x) (hsi y)] | |
| have hB (a : β) : |F (Fin.cons a x)-F (Fin.cons a y)| β€ | |
| β i : Fin n, c i.succ*|x i-y i| := by | |
| simpa only [Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, | |
| sub_self, abs_zero, mul_zero, zero_add] using hl (Fin.cons a x) (Fin.cons a y) | |
| simpa only [Real.norm_eq_abs, probReal_univ, mul_one] using | |
| (norm_integral_le_of_norm_le_const (ΞΌ := ΞΌ) | |
| (f := fun a => F (Fin.cons a x)-F (Fin.cons a y)) | |
| (Eventually.of_forall (fun a => by simpa only [Real.norm_eq_abs] using hB a))) | |
| have hGLp := gaussian_coord_memLp hGm hGl 2 | |
| have hpres := (measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) => ΞΌ) 0).symm | |
| have hLp : MemLp (fun z : β Γ (Fin n β β) => F (Fin.cons z.1 z.2)) 2 (ΞΌ.prod Ξ½) := by | |
| have h := (gaussian_coord_memLp hm hl 2).comp_measurePreserving hpres | |
| simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, | |
| Fin.insertNthEquiv, Fin.insertNth_zero, Equiv.coe_fn_mk, Fin.zero_succAbove, | |
| cast_eq, ENNReal.coe_ofNat, Ξ½] using h | |
| have hprod := variance_prod_le_fiber hLp | |
| (fun x => gaussian_slope_memLp (hsm x) (hsl x) 2) hGLp | |
| (fun x => gaussian_variance_of_slope (hsm x) (hsl x)) | |
| have heq : Var[fun z : β Γ (Fin n β β) => F (Fin.cons z.1 z.2); ΞΌ.prod Ξ½] = | |
| Var[F; Measure.pi (fun _ : Fin (n+1) => ΞΌ)] := by | |
| have h := hpres.variance_fun_comp hm.aemeasurable | |
| simpa only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, | |
| Fin.insertNth_zero, Equiv.coe_fn_mk, Fin.zero_succAbove, cast_eq] using h | |
| rw [heq] at hprod | |
| have ht := ih hGm hGl | |
| rw [Fin.sum_univ_succ] | |
| change _ β€ c 0 ^ 2 + Var[(fun b => β« a, F (Fin.cons a b) βΞΌ); Ξ½] at hprod | |
| dsimp only [Ξ½, ΞΌ] at hprod ht β’ | |
| linarith | |
| end IsingPerceptron | |
| end | |
| end OAI | |