Exact Lean source
PCTJointGaussianWhitening
formalization/Cloning/PCTJointGaussianWhitening.lean
Source hash: af7c34c1c0b75186cbf5697492f2d4dba85c47f8fdb8d78f38cf4571e424e7b6
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
definition
Cloning.PCTJointGaussianWhitening.sqrtSpectrumtheorem Cloning.PCTJointGaussianWhitening.sqrtSpectrum_normtheorem Cloning.PCTJointGaussianWhitening.exists_whitening_framedefinition Cloning.PCTJointGaussianWhitening.whitentheorem Cloning.PCTJointGaussianWhitening.continuous_whitendefinition Cloning.PCTJointGaussianWhitening.whiteningVectordefinition Cloning.PCTJointGaussianWhitening.whiteningTesttheorem Cloning.PCTJointGaussianWhitening.whiten_dualtheorem Cloning.PCTJointGaussianWhitening.whiteningVector_orthogonaltheorem Cloning.PCTJointGaussianWhitening.whiteningVector_norm_sqtheorem Cloning.PCTJointGaussianWhitening.whiteningTest_referencetheorem Cloning.PCTJointGaussianWhitening.whiteningTest_quadratictheorem Cloning.PCTJointGaussianWhitening.whitenedClassical_characteristic1import Cloning.PCTGaussianCovarianceClassical
2import Mathlib.Analysis.InnerProductSpace.PiL2
3
4/-! An explicit whitening chart for the classical purification differential.
5The real frame is constructed through the normalized square-root spectrum;
6no Gaussian-law or independence assumption is involved. -/
7noncomputable section
8open MeasureTheory
9open scoped InnerProductSpace Topology BigOperators
10namespace Cloning.PCTJointGaussianWhitening
11open Cloning.PCT Cloning.PCTReducedGaussian Cloning.PCTGaussianCovariance
12open Cloning.MultimodeCoherentGaussianMixture
13set_option backward.isDefEq.respectTransparency false
14set_option maxHeartbeats 1000000
15variable {A : Type*} [Fintype A] [DecidableEq A] {k s : ℕ}
16
17def sqrtSpectrum (p : A → ℝ) : EuclideanSpace ℝ A := WithLp.toLp 2 (fun a => Real.sqrt (p a))
18
19theorem sqrtSpectrum_norm (p : A → ℝ) (hp : ∀ a, 0 ≤ p a) (hs : ∑ a, p a = 1) :
20 ‖sqrtSpectrum p‖ = 1 := by
21 have h : ‖sqrtSpectrum p‖ ^ 2 = 1 := by
22 rw [EuclideanSpace.real_norm_sq_eq]
23 simpa only [sqrtSpectrum, WithLp.ofLp_toLp, Real.sq_sqrt (hp _)] using hs
24 nlinarith [norm_nonneg (sqrtSpectrum p)]
25
26theorem exists_whitening_frame (hcard : Fintype.card A = k + 1)
27 (p : A → ℝ) (hp : ∀ a, 0 ≤ p a) (hs : ∑ a, p a = 1) :
28 ∃ b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A), b 0 = sqrtSpectrum p := by
29 classical
30 have hc : Module.finrank ℝ (EuclideanSpace ℝ A) = Fintype.card (Fin (k+1)) := by
31 simpa using hcard
32 let v : Fin (k + 1) → EuclideanSpace ℝ A := fun _ => sqrtSpectrum p
33 have hv : Orthonormal ℝ (({0} : Set (Fin (k + 1))).restrict v) := by
34 rw [orthonormal_iff_ite]
35 intro i j
36 have hi : i = j := Subtype.ext (i.property.trans j.property.symm)
37 simp only [hi, ite_true, Set.restrict_apply, v, real_inner_self_eq_norm_sq,
38 sqrtSpectrum_norm p hp hs, one_pow]
39 obtain ⟨b, hb⟩ := hv.exists_orthonormalBasis_extension_of_card_eq hc
40 exact ⟨b, hb 0 (Set.mem_singleton 0)⟩
41
42def whiten (p : A → ℝ) (b : Fin (k + 1) → EuclideanSpace ℝ A) (h : A → ℝ) : Fin k → ℝ :=
43 fun i => ∑ a, b i.succ a * h a / Real.sqrt (p a)
44
45theorem continuous_whiten (p : A → ℝ) (b : Fin (k + 1) → EuclideanSpace ℝ A) :
46 Continuous (whiten p b) := by
47 unfold whiten
48 fun_prop
49
50def whiteningVector (b : Fin (k + 1) → EuclideanSpace ℝ A) (t : Fin k → ℝ) :
51 EuclideanSpace ℝ A := ∑ i, t i • b i.succ
52
53def whiteningTest (p : A → ℝ) (b : Fin (k + 1) → EuclideanSpace ℝ A) (t : Fin k → ℝ) : A → ℝ :=
54 fun a => whiteningVector b t a / Real.sqrt (p a)
55
56theorem whiten_dual (p : A → ℝ) (b : Fin (k + 1) → EuclideanSpace ℝ A)
57 (t : Fin k → ℝ) (h : A → ℝ) :
58 ∑ i, t i * whiten p b h i = ∑ a, whiteningTest p b t a * h a := by
59 simp only [whiten, whiteningTest, whiteningVector, Finset.mul_sum,
60 WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, smul_eq_mul,
61 Finset.sum_div, Finset.sum_mul]
62 rw [Finset.sum_comm]
63 apply Finset.sum_congr rfl
64 intro a _
65 apply Finset.sum_congr rfl
66 intro i _
67 ring
68
69theorem whiteningVector_orthogonal
70 (b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A)) (t : Fin k → ℝ) :
71 ⟪b 0, whiteningVector b t⟫_ℝ = 0 := by
72 simp only [whiteningVector, inner_sum, inner_smul_right]
73 apply Finset.sum_eq_zero
74 intro i _
75 rw [b.orthonormal.inner_eq_zero (Fin.succ_ne_zero i).symm]
76 simp
77
78theorem whiteningVector_norm_sq
79 (b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A)) (t : Fin k → ℝ) :
80 ‖whiteningVector b t‖ ^ 2 = ∑ i, (t i) ^ 2 := by
81 have h := (b.orthonormal.comp _ (Fin.succ_injective _)).inner_sum t t Finset.univ
82 simpa [whiteningVector, real_inner_self_eq_norm_sq, Function.comp_def, pow_two] using h
83
84theorem whiteningTest_reference (p : A → ℝ) (hp : ∀ a, 0 < p a)
85 (b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A))
86 (hb : b 0 = sqrtSpectrum p) (t : Fin k → ℝ) :
87 ∑ a, p a * whiteningTest p b t a = 0 := by
88 have h := whiteningVector_orthogonal b t
89 rw [hb, EuclideanSpace.inner_eq_star_dotProduct] at h
90 have h' : (∑ a, Real.sqrt (p a) * whiteningVector b t a) = 0 := by
91 simpa [dotProduct, sqrtSpectrum, mul_comm] using h
92 rw [← h']
93 apply Finset.sum_congr rfl
94 intro a _
95 unfold whiteningTest
96 have hs := Real.sq_sqrt (hp a).le
97 have hn := (Real.sqrt_pos.mpr (hp a)).ne'
98 field_simp [hn]
99 rw [hs]
100 ring
101
102theorem whiteningTest_quadratic (p : A → ℝ) (hp : ∀ a, 0 < p a)
103 (b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A))
104 (hb : b 0 = sqrtSpectrum p) (t : Fin k → ℝ) :
105 (∑ a, p a * (whiteningTest p b t a) ^ 2) -
106 (∑ a, p a * whiteningTest p b t a) ^ 2 = ∑ i, (t i) ^ 2 := by
107 rw [whiteningTest_reference p hp b hb, zero_pow (by omega : 2 ≠ 0), sub_zero,
108 ← whiteningVector_norm_sq b t, EuclideanSpace.real_norm_sq_eq]
109 apply Finset.sum_congr rfl
110 intro a _
111 unfold whiteningTest
112 rw [div_pow, Real.sq_sqrt (hp a).le]
113 field_simp [(hp a).ne']
114
115/-- Whitening the actual score yields covariance `2v I`, with the factor two
116fixed by the characteristic exponent. -/
117theorem whitenedClassical_characteristic
118 (u : OrthonormalBasis (Fin (s + 1)) ℂ (Register (A × A)))
119 (p : A → ℝ) (hp : ∀ a, 0 < p a)
120 (hu : u 0 = coefficientVector (schmidtCoefficients p))
121 (b : OrthonormalBasis (Fin (k + 1)) ℝ (EuclideanSpace ℝ A))
122 (hb : b 0 = sqrtSpectrum p) {v : ℝ} (hv : 0 < v) (t : Fin k → ℝ) :
123 (∫ z, Complex.exp (Complex.I * ((∑ i, t i *
124 whiten p b (classicalCoordinate p (frameTangentMatrix u z)) i : ℝ) : ℂ))
125 ∂gaussianProductMeasure (fun _ : Fin s => v)) =
126 Complex.exp (-((v * (∑ i, (t i) ^ 2) : ℝ) : ℂ)) := by
127 simp_rw [whiten_dual]
128 rw [classicalCoordinate_characteristic u p (fun a => (hp a).le) hu hv,
129 whiteningTest_quadratic p hp b hb]
130
131end Cloning.PCTJointGaussianWhitening