Download data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorRootVariance.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorRootVariance.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorRootVariance.lean
-
curl -L -o NSpinTensorRootVariance.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorRootVariance.lean
14.1 kB
| import OAI.Probability.InvariantIsing.Arrays.NSpinTensorCascade | |
| import OAI.Probability.InvariantIsing.Core.FiniteGaussianVariance | |
| namespace OAI | |
| /-! The root Gaussian contribution for the finite spectral-tensor model. -/ | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators NNReal InnerProductSpace | |
| namespace InvariantIsing | |
| abbrev TensorGaussianSpace {N m k : β} (I : Fin m β Finset (Fin N)) | |
| (degree : Fin k β Fin m β β) := | |
| EuclideanSpace β (Fin (Fintype.card (SpinTensorIndex I degree))) | |
| /-- Reindex independent standard Euclidean coordinates, then apply the | |
| coordinate square roots of the prescribed root variances. -/ | |
| def tensorRootMark {N m k : β} (I : Fin m β Finset (Fin N)) | |
| (degree : Fin k β Fin m β β) (root : SpinTensorIndex I degree β ββ₯0) | |
| (g : TensorGaussianSpace I degree) : SpinTensorIndex I degree β β := | |
| fun i => (NNReal.sqrt (root i) : β) * g (Fintype.equivFin (SpinTensorIndex I degree) i) | |
| lemma measurable_tensorRootMark {N m k : β} (I : Fin m β Finset (Fin N)) | |
| (degree : Fin k β Fin m β β) (root : SpinTensorIndex I degree β ββ₯0) : | |
| Measurable (tensorRootMark I degree root) := by | |
| unfold tensorRootMark | |
| fun_prop | |
| theorem tensorRootMark_measurePreserving {N m k : β} | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) | |
| (root : SpinTensorIndex I degree β ββ₯0) : | |
| MeasurePreserving (tensorRootMark I degree root) | |
| (stdGaussian (TensorGaussianSpace I degree)) | |
| (tensorGaussianLaw I degree root : Measure (SpinTensorIndex I degree β β)) := by | |
| let J := SpinTensorIndex I degree | |
| let d := Fintype.card J | |
| have hto : MeasurePreserving (MeasurableEquiv.toLp 2 (Fin d β β)) | |
| (Measure.pi (fun _ : Fin d => gaussianReal 0 1)) | |
| (stdGaussian (EuclideanSpace β (Fin d))) := | |
| β¨by fun_prop, map_pi_eq_stdGaussianβ© | |
| have hfrom := MeasurePreserving.symm (MeasurableEquiv.toLp 2 (Fin d β β)) hto | |
| have hindex := measurePreserving_piCongrLeft | |
| (Ξ± := fun _ : J => β) (fun _ : J => gaussianReal 0 1) (Fintype.equivFin J).symm | |
| have hscale : MeasurePreserving (fun z : J β β => fun i => (NNReal.sqrt (root i) : β) * z i) | |
| (Measure.pi (fun _ : J => gaussianReal 0 1)) | |
| (Measure.pi (fun i : J => gaussianReal 0 (root i))) := by | |
| apply measurePreserving_pi | |
| intro i | |
| refine β¨by fun_prop, ?_β© | |
| have hs : NNReal.mk ((NNReal.sqrt (root i) : β) ^ 2) (sq_nonneg _) = root i := by | |
| apply Subtype.ext | |
| change (NNReal.sqrt (root i) : β) ^ 2 = (root i : β) | |
| exact_mod_cast NNReal.sq_sqrt (root i) | |
| simpa only [hs, mul_zero, mul_one] using | |
| gaussianReal_map_const_mul (ΞΌ := 0) (v := 1) (NNReal.sqrt (root i) : β) | |
| convert hscale.comp (hindex.comp hfrom) using 1 | |
| Β· ext g i | |
| simp [tensorRootMark, Function.comp_def, MeasurableEquiv.coe_piCongrLeft, | |
| Equiv.piCongrLeft, J] | |
| Β· rfl | |
| def tensorRootCoefficient {N m k : β} (U : Rotation N) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (root : SpinTensorIndex I degree β ββ₯0) (Ο : Spin N) : TensorGaussianSpace I degree := | |
| WithLp.toLp 2 (fun j => | |
| (NNReal.sqrt (root ((Fintype.equivFin (SpinTensorIndex I degree)).symm j)) : β) * | |
| spinTensorFeature U I degree amplitude Ο ((Fintype.equivFin (SpinTensorIndex I degree)).symm j)) | |
| lemma spinTensorEnergy_tensorRootMark {N m k : β} (U : Rotation N) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (root : SpinTensorIndex I degree β ββ₯0) (Ο : Spin N) (g : TensorGaussianSpace I degree) : | |
| spinTensorEnergy U I degree amplitude (tensorRootMark I degree root g) Ο = | |
| βͺtensorRootCoefficient U I degree amplitude root Ο, gβ«_β := by | |
| classical | |
| unfold spinTensorEnergy tensorRootMark tensorRootCoefficient | |
| rw [PiLp.inner_apply] | |
| simp only [RCLike.inner_apply', conj_trivial] | |
| rw [β (Fintype.equivFin (SpinTensorIndex I degree)).symm.sum_comp | |
| (fun i => (NNReal.sqrt (root i) : β) * | |
| g (Fintype.equivFin (SpinTensorIndex I degree) i) * spinTensorFeature U I degree amplitude Ο i)] | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| simp only [Equiv.apply_symm_apply] | |
| ring | |
| lemma tensorRootCoefficient_norm_sq_le {N m k : β} (U : Rotation N) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (site : ββ₯0) (monomial : Fin k β ββ₯0) (Ο : Spin N) : | |
| βtensorRootCoefficient U I degree amplitude (tensorVarianceProfile I degree site monomial) Οβ ^ 2 β€ | |
| (site : β) * N + β j, (monomial j : β) * amplitude j ^ 2 := by | |
| classical | |
| rw [EuclideanSpace.real_norm_sq_eq] | |
| change (β j, ((NNReal.sqrt (tensorVarianceProfile I degree site monomial | |
| ((Fintype.equivFin (SpinTensorIndex I degree)).symm j)) : β) * | |
| spinTensorFeature U I degree amplitude Ο ((Fintype.equivFin (SpinTensorIndex I degree)).symm j)) ^ 2) β€ _ | |
| have hs (i : SpinTensorIndex I degree) : | |
| (NNReal.sqrt (tensorVarianceProfile I degree site monomial i) : β) ^ 2 = | |
| tensorVarianceProfile I degree site monomial i := by | |
| exact_mod_cast NNReal.sq_sqrt (tensorVarianceProfile I degree site monomial i) | |
| simp only [mul_pow, hs] | |
| rw [(Fintype.equivFin (SpinTensorIndex I degree)).symm.sum_comp | |
| (fun i => (tensorVarianceProfile I degree site monomial i : β) * | |
| spinTensorFeature U I degree amplitude Ο i ^ 2)] | |
| exact spinTensorFeature_variance_le U I degree amplitude site monomial Ο | |
| private theorem tensorCascade_shift_comparison {N m k : β} (hN : 0 < N) | |
| (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (b : β β β) (v : β β SpinTensorIndex I degree β ββ₯0) | |
| (hb : β i < n, 0 < b i) (x y : SpinTensorIndex I degree β β) {C : β} | |
| (hxy : β z, |spinTensorTerminal eig U c I degree amplitude (x + z) - | |
| spinTensorTerminal eig U c I degree amplitude (y + z)| β€ C) : | |
| |tensorCascadeValue eig U c I degree amplitude n b v x - | |
| tensorCascadeValue eig U c I degree amplitude n b v y| β€ C := by | |
| induction n generalizing b v x y with | |
| | zero => simpa only [tensorCascadeValue, IsingPerceptron.cascadeRecursion, add_zero] using hxy 0 | |
| | succ n ih => | |
| let bs := fun i => b (i + 1) | |
| let vs := fun i => v (i + 1) | |
| let G := tensorCascadeValue eig U c I degree amplitude n bs vs | |
| have hbs : β i < n, 0 < bs i := fun i hi => hb (i + 1) (by omega) | |
| have hm : Measurable G := IsingPerceptron.measurable_cascadeRecursion n bs | |
| (fun i => tensorGaussianLaw I degree (vs i)) (fun _ => measurable_fst.add measurable_snd) | |
| (measurable_spinTensorTerminal eig U c I degree amplitude) | |
| have hg : IsingPerceptron.HasLinearGrowth G := | |
| IsingPerceptron.cascadeRecursion_linearGrowth n bs (fun i => tensorGaussianLaw I degree (vs i)) | |
| (fun i _ => tensorGaussianLaw_moments hN I degree (vs i)) | |
| (measurable_spinTensorTerminal eig U c I degree amplitude) | |
| (spinTensorTerminal_linearGrowth eig U c I degree amplitude) hbs | |
| have hi (z : SpinTensorIndex I degree β β) : Integrable (fun a => Real.exp (b 0 * G (z + a))) | |
| (tensorGaussianLaw I degree (v 0) : Measure (SpinTensorIndex I degree β β)) := | |
| IsingPerceptron.integrable_exp_of_linearGrowth _ (tensorGaussianLaw_moments hN I degree (v 0)) | |
| (hm.comp (measurable_const.add measurable_id)) (hg.add_left z) (b 0) | |
| apply IsingPerceptron.logMean_abs_sub_le _ (hb 0 (by omega)) (hi x) (hi y) | |
| intro a | |
| exact ih bs vs hbs (x + a) (y + a) (fun z => by simpa only [add_assoc] using hxy (a + z)) | |
| lemma spinTensorEnergy_add {N m k : β} (U : Rotation N) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (x y : SpinTensorIndex I degree β β) (Ο : Spin N) : | |
| spinTensorEnergy U I degree amplitude (x + y) Ο = | |
| spinTensorEnergy U I degree amplitude x Ο + spinTensorEnergy U I degree amplitude y Ο := by | |
| simp only [spinTensorEnergy, Pi.add_apply, add_mul, Finset.sum_add_distrib] | |
| /-- The actual backward cascade recursion remains Lipschitz in the common | |
| root Gaussian mark, with the Euclidean coefficient bound of the model. -/ | |
| theorem tensorCascadeValue_root_lipschitz {N m k : β} (hN : 0 < N) | |
| (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (b : β β β) (v : β β SpinTensorIndex I degree β ββ₯0) | |
| (hb : IsingPerceptron.CascadeExponents n b) (site : ββ₯0) (monomial : Fin k β ββ₯0) | |
| (z : SpinTensorIndex I degree β β) : | |
| let B : ββ₯0 := β¨(site : β) * N + β j, (monomial j : β) * amplitude j ^ 2, | |
| add_nonneg (mul_nonneg (NNReal.coe_nonneg _) (Nat.cast_nonneg _)) | |
| (Finset.sum_nonneg fun _j _ => mul_nonneg (NNReal.coe_nonneg _) (sq_nonneg _))β© | |
| LipschitzWith (NNReal.sqrt B) | |
| (fun g => tensorCascadeValue eig U c I degree amplitude n b v | |
| (z + tensorRootMark I degree (tensorVarianceProfile I degree site monomial) g)) := by | |
| intro B | |
| have hs : ((NNReal.sqrt B : ββ₯0) : β) ^ 2 = B := by exact_mod_cast NNReal.sq_sqrt B | |
| have hn (Ο : Spin N) : | |
| βtensorRootCoefficient U I degree amplitude (tensorVarianceProfile I degree site monomial) Οβ β€ | |
| (NNReal.sqrt B : β) := by | |
| have hcap := tensorRootCoefficient_norm_sq_le U I degree amplitude site monomial Ο | |
| change βtensorRootCoefficient U I degree amplitude (tensorVarianceProfile I degree site monomial) Οβ ^ 2 β€ (B : β) at hcap | |
| nlinarith [norm_nonneg (tensorRootCoefficient U I degree amplitude (tensorVarianceProfile I degree site monomial) Ο), | |
| NNReal.coe_nonneg (NNReal.sqrt B)] | |
| apply LipschitzWith.of_dist_le_mul | |
| intro g h | |
| simp only [dist_eq_norm] | |
| apply tensorCascade_shift_comparison hN eig U c I degree amplitude n b v | |
| (fun i hi => (hb.1 i hi).1) | |
| intro a | |
| apply abs_logPartition_sub_le | |
| intro Ο | |
| have he : (rotatedEnergy eig U Ο + fieldEnergy c Ο + | |
| spinTensorEnergy U I degree amplitude ((z + tensorRootMark I degree | |
| (tensorVarianceProfile I degree site monomial) g) + a) Ο) - | |
| (rotatedEnergy eig U Ο + fieldEnergy c Ο + | |
| spinTensorEnergy U I degree amplitude ((z + tensorRootMark I degree | |
| (tensorVarianceProfile I degree site monomial) h) + a) Ο) = | |
| βͺtensorRootCoefficient U I degree amplitude (tensorVarianceProfile I degree site monomial) Ο, g - hβ«_β := by | |
| rw [spinTensorEnergy_add, spinTensorEnergy_add, spinTensorEnergy_add, spinTensorEnergy_add, | |
| spinTensorEnergy_tensorRootMark, spinTensorEnergy_tensorRootMark, inner_sub_right] | |
| ring | |
| rw [he] | |
| exact (abs_real_inner_le_norm _ _).trans | |
| (mul_le_mul_of_nonneg_right (hn Ο) (norm_nonneg _)) | |
| /-- Root Gaussian variance of the existing tensor recursion. This is | |
| conditional only on the explicitly cited finite Gaussian PoincarΓ© input. -/ | |
| theorem tensorCascadeValue_root_variance_le (hpub : GaussianLipschitzVarianceInput) | |
| {N m k : β} (hN : 0 < N) (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (b : β β β) (v : β β SpinTensorIndex I degree β ββ₯0) | |
| (hb : IsingPerceptron.CascadeExponents n b) (site : ββ₯0) (monomial : Fin k β ββ₯0) : | |
| variance (tensorCascadeValue eig U c I degree amplitude n b v) | |
| (tensorGaussianLaw I degree (tensorVarianceProfile I degree site monomial) : | |
| Measure (SpinTensorIndex I degree β β)) β€ | |
| (site : β) * N + β j, (monomial j : β) * amplitude j ^ 2 := by | |
| let B : ββ₯0 := β¨(site : β) * N + β j, (monomial j : β) * amplitude j ^ 2, | |
| add_nonneg (mul_nonneg (NNReal.coe_nonneg _) (Nat.cast_nonneg _)) | |
| (Finset.sum_nonneg fun j _ => mul_nonneg (NNReal.coe_nonneg _) (sq_nonneg _))β© | |
| have hLip := tensorCascadeValue_root_lipschitz hN eig U c I degree amplitude n b v hb site monomial 0 | |
| simp only [zero_add] at hLip | |
| have hm : Measurable (tensorCascadeValue eig U c I degree amplitude n b v) := | |
| IsingPerceptron.measurable_cascadeRecursion n b (fun i => tensorGaussianLaw I degree (v i)) | |
| (fun _ => measurable_fst.add measurable_snd) (measurable_spinTensorTerminal eig U c I degree amplitude) | |
| have hv := hpub (Fintype.card (SpinTensorIndex I degree)) (NNReal.sqrt B) _ hLip | |
| rw [(tensorRootMark_measurePreserving I degree (tensorVarianceProfile I degree site monomial)).variance_fun_comp | |
| hm.aemeasurable] at hv | |
| have hs : ((NNReal.sqrt B : ββ₯0) : β) ^ 2 = B := by exact_mod_cast NNReal.sq_sqrt B | |
| exact hv.trans_eq hs | |
| theorem normalized_tensorCascadeValue_root_variance_le (hpub : GaussianLipschitzVarianceInput) | |
| {N m k : β} (hN : 0 < N) (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (b : β β β) (v : β β SpinTensorIndex I degree β ββ₯0) | |
| (hb : IsingPerceptron.CascadeExponents n b) (site : ββ₯0) (monomial : Fin k β ββ₯0) : | |
| variance (fun z => (N : β)β»ΒΉ * tensorCascadeValue eig U c I degree amplitude n b v z) | |
| (tensorGaussianLaw I degree (tensorVarianceProfile I degree site monomial) : | |
| Measure (SpinTensorIndex I degree β β)) β€ | |
| ((site : β) * N + β j, (monomial j : β) * amplitude j ^ 2) / (N : β) ^ 2 := by | |
| rw [variance_const_mul] | |
| have hv := tensorCascadeValue_root_variance_le hpub hN eig U c I degree amplitude n b v hb site monomial | |
| have he : (N : β)β»ΒΉ ^ 2 * ((site : β) * N + β j, (monomial j : β) * amplitude j ^ 2) = | |
| ((site : β) * N + β j, (monomial j : β) * amplitude j ^ 2) / (N : β) ^ 2 := by | |
| ring | |
| exact (mul_le_mul_of_nonneg_left hv (sq_nonneg _)).trans_eq he | |
| end InvariantIsing | |
| end | |
| end OAI | |