Offline · exact source
Exact Lean source

YoungUniformLocalGaussian

formalization/Cloning/YoungUniformLocalGaussian.lean

Source hash: cd5e4cc1103f1dcd2d2186f00e82552037e1924412c86b6ee66c074e62fbf25c

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.YoungHyperplaneCovariance
2import Cloning.GaussianAffinity
3import Mathlib.Analysis.InnerProductSpace.Spectrum
4 
5/-!
6# The normalized Gaussian on the actual Young root hyperplane
7 
8The density is constructed in an orthonormal eigenbasis of the proved
9positive covariance. Its normalization uses actual Euclidean volume.
10-/
11 
12set_option backward.isDefEq.respectTransparency false
13set_option maxHeartbeats 800000
14noncomputable section
15open scoped BigOperators Topology Classical
16open MeasureTheory
17namespace Cloning.YoungHyperplane
18 
19variable (d : ℕ) (p : Fin (d + 1) → ℝ) (hp : ∑ i, p i = 1)
20 
21def covarianceEigenbasis : OrthonormalBasis (Fin d) ℝ (rootSpace d) :=
22  (rootCovariance_isSymmetric d p hp).eigenvectorBasis (rootSpace_finrank d)
23 
24def covarianceEigenvalues : Fin d → ℝ :=
25  (rootCovariance_isSymmetric d p hp).eigenvalues (rootSpace_finrank d)
26 
27theorem covariance_eigenvector (i : Fin d) :
28    rootCovariance d p (covarianceEigenbasis d p hp i) =
29      covarianceEigenvalues d p hp i • covarianceEigenbasis d p hp i :=
30  (rootCovariance_isSymmetric d p hp).apply_eigenvectorBasis (rootSpace_finrank d) i
31 
32theorem covarianceEigenvalues_pos (hp0 : ∀ i, 0 < p i) (i : Fin d) :
33    0 < covarianceEigenvalues d p hp i := by
34  have hv : covarianceEigenbasis d p hp i ≠ 0 :=
35    (covarianceEigenbasis d p hp).orthonormal.ne_zero i
36  have h := rootCovariance_quadratic_pos d p hp hp0 _ hv
37  rw [covariance_eigenvector, real_inner_smul_right] at h
38  simpa using h
39 
40theorem covariance_eigen_coordinates (x : rootSpace d) (i : Fin d) :
41    (covarianceEigenbasis d p hp).repr (rootCovariance d p x) i =
42      covarianceEigenvalues d p hp i * (covarianceEigenbasis d p hp).repr x i :=
43  (rootCovariance_isSymmetric d p hp).eigenvectorBasis_apply_self_apply
44    (rootSpace_finrank d) x i
45 
46theorem covariance_eigenvalue_product :
47    (∏ i, covarianceEigenvalues d p hp i) = ((d : ℝ) + 1) * ∏ i, p i := by
48  let b := covarianceEigenbasis d p hp
49  have hm : LinearMap.toMatrix b.toBasis b.toBasis (rootCovariance d p) =
50      Matrix.diagonal (covarianceEigenvalues d p hp) := by
51    ext i j
52    rw [LinearMap.toMatrix_apply]
53    change (b.repr (rootCovariance d p (b j))) i = _
54    rw [covariance_eigen_coordinates]
55    simp only [b, OrthonormalBasis.repr_self, EuclideanSpace.single_apply,
56      Matrix.diagonal_apply]
57    by_cases hij : i = j
58    · subst j; simp
59    · simp [hij, Ne.symm hij]
60  have hd := congrArg Matrix.det hm
61  rw [LinearMap.det_toMatrix, Matrix.det_diagonal, rootCovariance_det d p hp] at hd
62  exact hd.symm
63 
64/-- The reciprocal covariance quadratic form in orthonormal eigen-coordinates. -/
65theorem covariance_inverse_quadratic_eigen (hp0 : ∀ i, 0 < p i) (x : rootSpace d) :
66    (∑ i, ((covarianceEigenbasis d p hp).repr x i) ^ 2 /
67      covarianceEigenvalues d p hp i) = ∑ i, (x.1 i) ^ 2 / p i := by
68  let b := covarianceEigenbasis d p hp
69  let y := inverseCovarianceVector d p x
70  have hy i : b.repr y i = b.repr x i / covarianceEigenvalues d p hp i := by
71    have h := covariance_eigen_coordinates d p hp y i
72    rw [rootCovariance_inverseVector d p hp (fun i ↦ (hp0 i).ne') x] at h
73    change b.repr x i = covarianceEigenvalues d p hp i * b.repr y i at h
74    exact (eq_div_iff (covarianceEigenvalues_pos d p hp hp0 i).ne').mpr (by linarith)
75  have hi := b.repr.inner_map_map x y
76  rw [EuclideanSpace.inner_eq_star_dotProduct] at hi
77  simp only [dotProduct, Pi.star_apply, star_trivial, hy] at hi
78  rw [← inverseCovariance_quadratic d p x]
79  change _ = inner ℝ x y
80  rw [← hi]
81  apply Finset.sum_congr rfl
82  intro i _
83  ring
84 
85/-- Positive normalized covariance Gaussian, on induced hyperplane volume. -/
86def covarianceGaussian (x : rootSpace d) : ℝ :=
87  GaussianAffinity.productDensity (fun i ↦ 1 / (2 * covarianceEigenvalues d p hp i))
88    (fun i ↦ (covarianceEigenbasis d p hp).repr x i)
89 
90theorem covarianceGaussian_nonneg (x : rootSpace d) :
91    0 ≤ covarianceGaussian d p hp x :=
92  GaussianAffinity.productDensity_nonneg _ _
93 
94theorem integrable_covarianceGaussian (hp0 : ∀ i, 0 < p i) :
95    Integrable (covarianceGaussian d p hp) volume := by
96  let b := covarianceEigenbasis d p hp
97  have hprec i : 0 < 1 / (2 * covarianceEigenvalues d p hp i) := by
98    positivity [covarianceEigenvalues_pos d p hp hp0 i]
99  have hi : Integrable (GaussianAffinity.productDensity
100      (fun i ↦ 1 / (2 * covarianceEigenvalues d p hp i))) :=
101    Integrable.fintype_prod fun i ↦ GaussianAffinity.integrable_density (hprec i)
102  have he := (PiLp.volume_preserving_toLp (Fin d)).symm (MeasurableEquiv.toLp 2 (Fin d → ℝ))
103  have hb := b.repr.measurePreserving
104  exact ((he.comp hb).integrable_comp_emb
105    ((MeasurableEquiv.toLp 2 _).symm.measurableEmbedding.comp b.repr.toHomeomorph.measurableEmbedding)).mpr hi
106 
107theorem integral_covarianceGaussian (hp0 : ∀ i, 0 < p i) :
108    (∫ x, covarianceGaussian d p hp x ∂volume) = 1 := by
109  let b := covarianceEigenbasis d p hp
110  have hprec i : 0 < 1 / (2 * covarianceEigenvalues d p hp i) := by
111    positivity [covarianceEigenvalues_pos d p hp hp0 i]
112  have he := (PiLp.volume_preserving_toLp (Fin d)).symm (MeasurableEquiv.toLp 2 (Fin d → ℝ))
113  have hb := b.repr.measurePreserving
114  have h := (he.comp hb).integral_comp
115    ((MeasurableEquiv.toLp 2 _).symm.measurableEmbedding.comp b.repr.toHomeomorph.measurableEmbedding)
116    (GaussianAffinity.productDensity (fun i ↦ 1 / (2 * covarianceEigenvalues d p hp i)))
117  exact h.trans (GaussianAffinity.integral_productDensity _ hprec)
118 
119 
120theorem covarianceGaussian_pos (hp0 : ∀ i, 0 < p i) (x : rootSpace d) :
121    0 < covarianceGaussian d p hp x := by
122  unfold covarianceGaussian GaussianAffinity.productDensity
123  apply Finset.prod_pos
124  intro i _
125  have hi := covarianceEigenvalues_pos d p hp hp0 i
126  unfold GaussianAffinity.density
127  positivity
128 
129private theorem log_density_reciprocal {v : ℝ} (hv : 0 < v) (y : ℝ) :
130    Real.log (GaussianAffinity.density (1 / (2 * v)) y) =
131      -(1 / 2) * Real.log (2 * Real.pi) - 1 / 2 * Real.log v - y ^ 2 / (2 * v) := by
132  unfold GaussianAffinity.density
133  rw [Real.log_mul (by positivity) (Real.exp_ne_zero _), Real.log_exp,
134    Real.log_div (by positivity) (by positivity),
135    Real.log_sqrt (by positivity), Real.log_sqrt Real.pi_pos.le,
136    Real.log_div (by norm_num : (1 : ℝ) ≠ 0) (by positivity), Real.log_one,
137    Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hv.ne',
138    Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) Real.pi_ne_zero]
139  ring
140 
141/-- Explicit logarithm, including the root-space determinant `d+1`. -/
142theorem log_covarianceGaussian (hp0 : ∀ i, 0 < p i) (x : rootSpace d) :
143    Real.log (covarianceGaussian d p hp x) =
144      -(d : ℝ) / 2 * Real.log (2 * Real.pi) - 1 / 2 * Real.log ((d : ℝ) + 1) -
145      1 / 2 * (∑ i, Real.log (p i)) - 1 / 2 * (∑ i, (x.1 i) ^ 2 / p i) := by
146  have hprod : (∑ i, Real.log (covarianceEigenvalues d p hp i)) =
147      Real.log ((d : ℝ) + 1) + ∑ i, Real.log (p i) := by
148    rw [← Real.log_prod (fun i _ ↦ (covarianceEigenvalues_pos d p hp hp0 i).ne'),
149      covariance_eigenvalue_product d p hp,
150      Real.log_mul (by positivity) (Finset.prod_ne_zero_iff.mpr (fun i _ ↦ (hp0 i).ne')),
151      Real.log_prod (fun i _ ↦ (hp0 i).ne')]
152  have hquad : (∑ i, ((covarianceEigenbasis d p hp).repr x i) ^ 2 /
153      (2 * covarianceEigenvalues d p hp i)) = 1 / 2 * ∑ i, (x.1 i) ^ 2 / p i := by
154    rw [← covariance_inverse_quadratic_eigen d p hp hp0 x, Finset.mul_sum]
155    apply Finset.sum_congr rfl
156    intro i _
157    ring
158  unfold covarianceGaussian GaussianAffinity.productDensity
159  rw [Real.log_prod (fun i _ ↦ by
160    have hi := covarianceEigenvalues_pos d p hp hp0 i
161    unfold GaussianAffinity.density
162    positivity)]
163  simp_rw [log_density_reciprocal (covarianceEigenvalues_pos d p hp hp0 _)]
164  simp only [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ,
165    Fintype.card_fin, nsmul_eq_mul, ← Finset.mul_sum, hprod, hquad]
166  ring
167 
168/-- The normalized Gaussian has exactly the covariance density required by
169Stirling's central-window formula on the induced Euclidean hyperplane. -/
170theorem covarianceGaussian_eq_exp (hp0 : ∀ i, 0 < p i) (x : rootSpace d) :
171    covarianceGaussian d p hp x = Real.exp
172      (-(d : ℝ) / 2 * Real.log (2 * Real.pi) - 1 / 2 * Real.log ((d : ℝ) + 1) -
173      1 / 2 * (∑ i, Real.log (p i)) - 1 / 2 * (∑ i, (x.1 i) ^ 2 / p i)) := by
174  rw [← log_covarianceGaussian d p hp hp0 x, Real.exp_log (covarianceGaussian_pos d p hp hp0 x)]
175 
176end Cloning.YoungHyperplane