Download data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorFlatMean.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 12.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorFlatMean.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorFlatMean.lean
-
curl -L -o NSpinTensorFlatMean.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Arrays/NSpinTensorFlatMean.lean
12.9 kB
| import OAI.Probability.InvariantIsing.Arrays.NSpinTensorGaussianLaw | |
| import OAI.Probability.InvariantIsing.Gaussian.BaseGaussianVariance | |
| import OAI.Probability.IsingPerceptron.NamespaceSplit | |
| namespace OAI | |
| /-! The flat Gaussian spin/leaf pressure has the actual cascade mean. -/ | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory IsingPerceptron | |
| open scoped BigOperators NNReal | |
| namespace InvariantIsing | |
| def tensorFlatLog {N m k : β} (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (v : β β SpinTensorIndex I degree β ββ₯0) (p : LabeledTree n Γ (β β β)) : β := | |
| Real.log (β« x : Spin N Γ LabeledLeaf n, Real.exp (rotatedEnergy eig U x.1 + fieldEnergy c x.1 + | |
| cylinderField (tensorLeafCoefficients U I degree amplitude n (fun i => v i) x) p.2) | |
| βlabeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) p.1) | |
| lemma measurable_tensorFlatLog {N m k : β} (eig : Fin N β β) (U : Rotation N) (c : Fin N β β) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (v : β β SpinTensorIndex I degree β ββ₯0) : | |
| Measurable (tensorFlatLog eig U c I degree amplitude n v) := by | |
| have hE : Measurable (fun p : (LabeledTree n Γ (β β β)) Γ (Spin N Γ LabeledLeaf n) => | |
| rotatedEnergy eig U p.2.1 + fieldEnergy c p.2.1 + | |
| cylinderField (tensorLeafCoefficients U I degree amplitude n (fun i => v i) p.2) p.1.2) := by | |
| apply measurable_from_prod_countable_left | |
| intro x | |
| have hc : Measurable (fun _ : LabeledTree n Γ (β β β) => | |
| rotatedEnergy eig U x.1 + fieldEnergy c x.1) := measurable_const | |
| exact hc.add ((measurable_cylinderField | |
| (tensorLeafCoefficients U I degree amplitude n (fun i => v i) x)).comp measurable_snd) | |
| have : β p : LabeledTree n Γ (β β β), IsProbabilityMeasure | |
| ((labeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) β Prod.fst) p) := | |
| fun p => by | |
| change IsProbabilityMeasure (labeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) p.1) | |
| infer_instance | |
| exact (measurable_random_referencePartition | |
| ((measurable_labeledSpinReference_general n (uniformSpinPrior N : Measure (Spin N))).comp measurable_fst) hE).log | |
| private lemma tensorLeafCoefficients_finite_bound {N m k : β} (U : Rotation N) | |
| (I : Fin m β Finset (Fin N)) (degree : Fin k β Fin m β β) (amplitude : Fin k β β) | |
| (n : β) (v : β β SpinTensorIndex I degree β ββ₯0) : | |
| β B : β, β x : Spin N Γ LabeledLeaf n, | |
| (tensorLeafCoefficients U I degree amplitude n (fun i => v i) x).sum (fun _ c => c ^ 2) β€ B := by | |
| classical | |
| let Q : Spin N β β := fun Ο => β i : Fin (n + 1), β j : SpinTensorIndex I degree, | |
| (v i j : β) * spinTensorFeature U I degree amplitude Ο j ^ 2 | |
| refine β¨β Ο, Q Ο, fun x => ?_β© | |
| rw [β cylinderCross_self, tensorLeafCoefficients_cross] | |
| simp only [labeledCommonDepth_self, | |
| show β i : Fin (n + 1), i.1 β€ n from fun i => Nat.le_of_lt_succ i.isLt, ite_true] | |
| calc | |
| _ = Q x.1 := by | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| ring | |
| _ β€ β Ο, Q Ο := Finset.single_le_sum (f := Q) | |
| (fun _ _ => Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => | |
| mul_nonneg (NNReal.coe_nonneg _) (sq_nonneg _)) (Finset.mem_univ x.1) | |
| private lemma tensorFlat_base_exp_integrable {N : β} (eig : Fin N β β) (U : Rotation N) | |
| (c : Fin N β β) (n : β) (T : LabeledTree n) : | |
| Integrable (fun x : Spin N Γ LabeledLeaf n => Real.exp (rotatedEnergy eig U x.1 + fieldEnergy c x.1)) | |
| (labeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) T) := | |
| (Integrable.of_finite : Integrable | |
| (fun Ο : Spin N => Real.exp (rotatedEnergy eig U Ο + fieldEnergy c Ο)) | |
| (uniformSpinPrior N : Measure (Spin N))).comp_fst (labeledLeafLaw n T) | |
| private lemma tensorFlat_base_log {N : β} (eig : Fin N β β) (U : Rotation N) | |
| (c : Fin N β β) (n : β) (T : LabeledTree n) : | |
| Real.log (β« x : Spin N Γ LabeledLeaf n, Real.exp (rotatedEnergy eig U x.1 + fieldEnergy c x.1) | |
| βlabeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) T) = | |
| logPartition (fun Ο => rotatedEnergy eig U Ο + fieldEnergy c Ο) := by | |
| unfold labeledSpinReference | |
| change Real.log (β« x : Spin N Γ LabeledLeaf n, | |
| (fun Ο : Spin N => Real.exp (rotatedEnergy eig U Ο + fieldEnergy c Ο)) x.1 | |
| β(uniformSpinPrior N : Measure (Spin N)).prod (labeledLeafLaw n T)) = _ | |
| rw [integral_fun_fst (ΞΌ := (uniformSpinPrior N : Measure (Spin N))) | |
| (Ξ½ := labeledLeafLaw n T) (fun Ο : Spin N => Real.exp (rotatedEnergy eig U Ο + fieldEnergy c Ο))] | |
| simp only [probReal_univ, one_smul] | |
| exact finiteLogIntegral_uniformSpinPrior _ | |
| private lemma random_cylinder_log_integrable {Ξ© X : Type*} | |
| [MeasurableSpace Ξ©] [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X] | |
| {P : Measure Ξ©} [IsProbabilityMeasure P] {Ξ½ : Ξ© β Measure X} | |
| (hΞ½ : Measurable Ξ½) [β Ο, IsProbabilityMeasure (Ξ½ Ο)] | |
| (H : X β β) (hH : β Ο, Integrable (fun x => Real.exp (H x)) (Ξ½ Ο)) | |
| (C : β) (hC : β Ο, Real.log (β« x, Real.exp (H x) βΞ½ Ο) = C) | |
| (A : X β β ββ β) {B : β} (hA : β x, (A x).sum (fun _ c => c ^ 2) β€ B) : | |
| Integrable (fun p : Ξ© Γ (β β β) => Real.log | |
| (β« x, Real.exp (H x + cylinderField (A x) p.2) βΞ½ p.1)) (P.prod gaussianCoordinates) := by | |
| have : β Ο, IsProbabilityMeasure ((Ξ½ Ο).tilted H) := fun Ο => isProbabilityMeasure_tilted (hH Ο) | |
| have hHH : Measurable (fun p : Ξ© Γ X => H p.2) := | |
| (measurable_of_countable H).comp measurable_snd | |
| have htilt : Measurable (fun Ο => (Ξ½ Ο).tilted H) := | |
| measurable_random_tilted_measure (H := fun p : Ξ© Γ X => H p.2) hΞ½ hHH | |
| let G := fun p : Ξ© Γ (β β β) => cgf (fun x => cylinderField (A x) p.2) ((Ξ½ p.1).tilted H) 1 | |
| have hmG : Measurable G := measurable_random_cylinder_cgf htilt A 1 | |
| have hiG : Integrable G (P.prod gaussianCoordinates) := integrable_random_cylinder_cgf htilt A hA 1 | |
| have : β p : Ξ© Γ (β β β), IsProbabilityMeasure ((fun p : Ξ© Γ (β β β) => Ξ½ p.1) p) := | |
| fun p => by change IsProbabilityMeasure (Ξ½ p.1); infer_instance | |
| have hE : Measurable (fun p : (Ξ© Γ (β β β)) Γ X => H p.2 + cylinderField (A p.2) p.1.2) := by | |
| apply measurable_from_prod_countable_left | |
| intro x | |
| have hc : Measurable (fun _ : Ξ© Γ (β β β) => H x) := measurable_const | |
| exact hc.add ((measurable_cylinderField (A x)).comp measurable_snd) | |
| have hm : Measurable (fun p : Ξ© Γ (β β β) => Real.log | |
| (β« x, Real.exp (H x + cylinderField (A x) p.2) βΞ½ p.1)) := | |
| (measurable_random_referencePartition (Ξ½ := fun p : Ξ© Γ (β β β) => Ξ½ p.1) | |
| (hΞ½.comp measurable_fst) hE).log | |
| have heq : (fun p : Ξ© Γ (β β β) => Real.log | |
| (β« x, Real.exp (H x + cylinderField (A x) p.2) βΞ½ p.1)) =α΅[P.prod gaussianCoordinates] | |
| (fun p => C + G p) := by | |
| apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun hm (measurable_const.add hmG))).mpr | |
| exact ae_of_all _ fun Ο => by | |
| have he := cylinder_log_partition_base (Ξ½ Ο) H (hH Ο) A hA 1 | |
| filter_upwards [he] with g hg | |
| dsimp only [G, Pi.add_apply] | |
| simpa only [one_mul, hC Ο] using hg | |
| exact ((integrable_const C).add hiG).congr (Filter.EventuallyEq.symm heq) | |
| /-- Joint integrability over the actual cascade branching and flat | |
| Gaussian coordinates, without a variance or pressure-limit hypothesis. -/ | |
| theorem tensorFlatLog_integrable {N m k : β} (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) : | |
| Integrable (tensorFlatLog eig U c I degree amplitude n v) | |
| ((labeledCascadeLaw n b : Measure (LabeledTree n)).prod gaussianCoordinates) := by | |
| let Ξ½ := fun T : LabeledTree n => labeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) T | |
| have : β T, IsProbabilityMeasure (Ξ½ T) := fun T => by | |
| change IsProbabilityMeasure (labeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) T) | |
| infer_instance | |
| obtain β¨B, hcapβ© := tensorLeafCoefficients_finite_bound U I degree amplitude n v | |
| exact random_cylinder_log_integrable | |
| (Ξ½ := Ξ½) (P := (labeledCascadeLaw n b : Measure (LabeledTree n))) | |
| (measurable_labeledSpinReference_general n (uniformSpinPrior N : Measure (Spin N))) | |
| (fun x => rotatedEnergy eig U x.1 + fieldEnergy c x.1) | |
| (tensorFlat_base_exp_integrable eig U c n) | |
| (logPartition (fun Ο => rotatedEnergy eig U Ο + fieldEnergy c Ο)) | |
| (tensorFlat_base_log eig U c n) | |
| (tensorLeafCoefficients U I degree amplitude n (fun i => v i)) hcap | |
| /-- The flat spin/leaf log partition has exactly the same mean as the | |
| root-averaged tensor cascade recursion. -/ | |
| theorem tensorFlatLog_mean {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 : CascadeExponents n b) : | |
| (β« p, tensorFlatLog eig U c I degree amplitude n v p | |
| β(labeledCascadeLaw n b : Measure (LabeledTree n)).prod gaussianCoordinates) = | |
| β« z, tensorCascadeValue eig U c I degree amplitude n b (fun i => v (i + 1)) z | |
| β(tensorGaussianLaw I degree (v 0) : Measure (SpinTensorIndex I degree β β)) := by | |
| let G := fun q : (SpinTensorIndex I degree β β) Γ TensorLabeledData N n => | |
| Real.log (β« x, Real.exp (tensorLabeledEnergy eig U c I degree amplitude n q.1 q.2 x) | |
| βtensorLabeledReference N n q.2) | |
| have : β q : (SpinTensorIndex I degree β β) Γ TensorLabeledData N n, | |
| IsProbabilityMeasure ((tensorLabeledReference N n β Prod.snd) q) := fun q => by | |
| change IsProbabilityMeasure (tensorLabeledReference N n q.2) | |
| infer_instance | |
| have hmG : Measurable G := (measurable_random_referencePartition | |
| ((measurable_tensorLabeledReference N n).comp measurable_snd) | |
| (measurable_tensorLabeledEnergy_root eig U c I degree amplitude n)).log | |
| have hp := tensorFlatToLabeled_measurePreserving U I degree amplitude n b v | |
| have he : G β tensorFlatToLabeled U I degree amplitude n v = | |
| tensorFlatLog eig U c I degree amplitude n v := by | |
| funext p | |
| apply congrArg Real.log | |
| change (β« x, Real.exp (tensorLabeledEnergy eig U c I degree amplitude n | |
| (tensorFlatToLabeled U I degree amplitude n v p).1 | |
| (tensorFlatToLabeled U I degree amplitude n v p).2 x) | |
| βlabeledSpinReference n (uniformSpinPrior N : Measure (Spin N)) p.1) = _ | |
| apply integral_congr_ae | |
| refine ae_of_all _ fun x => ?_ | |
| exact congrArg Real.exp (tensorLabeledEnergy_flat_eq eig U c I degree amplitude n v p x) | |
| have hi : Integrable (G β tensorFlatToLabeled U I degree amplitude n v) | |
| ((labeledCascadeLaw n b : Measure (LabeledTree n)).prod gaussianCoordinates) := by | |
| rw [he] | |
| exact tensorFlatLog_integrable eig U c I degree amplitude n b v | |
| have hiG : Integrable G | |
| ((tensorGaussianLaw I degree (v 0) : Measure (SpinTensorIndex I degree β β)).prod | |
| (tensorLabeledLaw U I degree amplitude n b (fun i => v (i + 1)))) := by | |
| rw [β hp.map_eq] | |
| exact (integrable_map_measure hmG.aestronglyMeasurable hp.aemeasurable).mpr hi | |
| rw [β he] | |
| change (β« p, G (tensorFlatToLabeled U I degree amplitude n v p) | |
| β(labeledCascadeLaw n b : Measure (LabeledTree n)).prod gaussianCoordinates) = _ | |
| rw [integral_comp_preserving_ae hp hmG.aestronglyMeasurable, integral_prod _ hiG] | |
| apply integral_congr_ae | |
| exact ae_of_all _ fun z => | |
| (tensorLabeledLog_mean hN eig U c I degree amplitude n b (fun i => v (i + 1)) hb z).2 | |
| theorem tensorEnrichedPressure_eq_flat_mean {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 : CascadeExponents n b) : | |
| tensorEnrichedPressure eig U c I degree amplitude n b (fun i => v (i + 1)) (v 0) = | |
| (N : β)β»ΒΉ * β« T, (β« g : β β β, tensorFlatLog eig U c I degree amplitude n v (T, g) | |
| βgaussianCoordinates) β(labeledCascadeLaw n b : Measure (LabeledTree n)) := by | |
| rw [tensorEnrichedPressure, β tensorFlatLog_mean hN eig U c I degree amplitude n b v hb, | |
| integral_prod _ (tensorFlatLog_integrable eig U c I degree amplitude n b v)] | |
| end InvariantIsing | |
| end | |
| end OAI | |