math / data /lean /OAI /Probability /InvariantIsing /Arrays /NSpinTensorRootVariance.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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