Offline · exact source
Exact Lean source

PCTJointGaussianChart

formalization/Cloning/PCTJointGaussianChart.lean

Source hash: 056e13a23142173e25226ca06b4460bc731923344a50041d5e6cf2846979213b

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.PCTJointGaussianWhitenedLaw
2import Cloning.HybridCoordinateTransport
3import Mathlib.Topology.Algebra.Module.FiniteDimension
4 
5/-! A concrete equivalence between the trace-zero classical score hyperplane
6and whitening coordinates. Its reference measure is explicitly the pullback
7of coordinate Lebesgue measure; no unproved intrinsic-volume Jacobian is used. -/
8noncomputable section
9open MeasureTheory
10open scoped InnerProductSpace Topology BigOperators
11namespace Cloning.PCTJointGaussianWhitening
12open Cloning.PCT Cloning.PCTReducedGaussian Cloning.PCTGaussianCovariance
13open Cloning.PCTJointGaussianLaw
14set_option backward.isDefEq.respectTransparency false
15set_option maxHeartbeats 1200000
16variable {A : Type*} [Fintype A] [LinearOrder A] {k : ℕ}
17 
18def scoreHyperplane (A : Type*) [Fintype A] : Submodule ℝ (A → ℝ) where
19  carrier := {h | ∑ a, h a = 0}
20  zero_mem' := by simp
21  add_mem' := by
22    intro h j hh hj
23    change ∑ a, h a = 0 at hh
24    change ∑ a, j a = 0 at hj
25    change ∑ a, (h a + j a) = 0
26    simp [Finset.sum_add_distrib, hh, hj]
27  smul_mem' := by
28    intro c h hh
29    change ∑ a, h a = 0 at hh
30    change ∑ a, c * h a = 0
31    rw [← Finset.mul_sum, hh, mul_zero]
32 
33def normalizedScore (p : A → ℝ) (h : A → ℝ) : EuclideanSpace ℝ A :=
34  WithLp.toLp 2 (fun a => h a / Real.sqrt (p a))
35 
36def unwhiten (p : A → ℝ) (b : Fin (k+1) → EuclideanSpace ℝ A)
37    (x : Fin k → ℝ) : A → ℝ :=
38  fun a => Real.sqrt (p a) * whiteningVector b x a
39 
40theorem unwhiten_sum_zero (p : A → ℝ)
41    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
42    (hb : b 0 = sqrtSpectrum p) (x : Fin k → ℝ) :
43    ∑ a, unwhiten p b x a = 0 := by
44  have h := whiteningVector_orthogonal b x
45  rw [hb, EuclideanSpace.inner_eq_star_dotProduct] at h
46  simpa [dotProduct, sqrtSpectrum, unwhiten, mul_comm] using h
47 
48theorem whiten_eq_inner (p : A → ℝ)
49    (b : Fin (k+1) → EuclideanSpace ℝ A) (h : A → ℝ) (i : Fin k) :
50    whiten p b h i = ⟪b i.succ, normalizedScore p h⟫_ℝ := by
51  simp only [whiten, normalizedScore, EuclideanSpace.inner_eq_star_dotProduct,
52    dotProduct, star_trivial, WithLp.ofLp_toLp]
53  apply Finset.sum_congr rfl
54  intro a _
55  ring
56 
57theorem normalizedScore_unwhiten (p : A → ℝ) (hp : ∀ a, 0 < p a)
58    (b : Fin (k+1) → EuclideanSpace ℝ A) (x : Fin k → ℝ) :
59    normalizedScore p (unwhiten p b x) = whiteningVector b x := by
60  ext a
61  simp only [normalizedScore, WithLp.ofLp_toLp, unwhiten]
62  field_simp [(Real.sqrt_pos.mpr (hp a)).ne']
63 
64theorem whiten_unwhiten (p : A → ℝ) (hp : ∀ a, 0 < p a)
65    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A)) (x : Fin k → ℝ) :
66    whiten p b (unwhiten p b x) = x := by
67  funext i
68  rw [whiten_eq_inner, normalizedScore_unwhiten p hp]
69  simp [whiteningVector, inner_sum, inner_smul_right, orthonormal_iff_ite.mp b.orthonormal]
70 
71theorem normalizedScore_inner_zero (p : A → ℝ) (hp : ∀ a, 0 < p a)
72    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
73    (hb : b 0 = sqrtSpectrum p) (h : A → ℝ) :
74    ⟪b 0, normalizedScore p h⟫_ℝ = ∑ a, h a := by
75  rw [hb, EuclideanSpace.inner_eq_star_dotProduct]
76  simp only [dotProduct, star_trivial, sqrtSpectrum, normalizedScore, WithLp.ofLp_toLp]
77  apply Finset.sum_congr rfl
78  intro a _
79  field_simp [(Real.sqrt_pos.mpr (hp a)).ne']
80 
81theorem whiteningVector_whiten (p : A → ℝ) (hp : ∀ a, 0 < p a)
82    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
83    (hb : b 0 = sqrtSpectrum p) (h : A → ℝ) (hh : ∑ a, h a = 0) :
84    whiteningVector b (whiten p b h) = normalizedScore p h := by
85  have hs := b.sum_repr' (normalizedScore p h)
86  rw [Fin.sum_univ_succ, normalizedScore_inner_zero p hp b hb, hh, zero_smul, zero_add] at hs
87  simpa only [whiteningVector, whiten_eq_inner] using hs
88 
89theorem unwhiten_whiten (p : A → ℝ) (hp : ∀ a, 0 < p a)
90    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
91    (hb : b 0 = sqrtSpectrum p) (h : A → ℝ) (hh : ∑ a, h a = 0) :
92    unwhiten p b (whiten p b h) = h := by
93  funext a
94  rw [unwhiten, whiteningVector_whiten p hp b hb h hh]
95  simp only [normalizedScore, WithLp.ofLp_toLp]
96  field_simp [(Real.sqrt_pos.mpr (hp a)).ne']
97 
98/-- Explicit linear equivalence on the actual trace-zero score space. -/
99def whiteningEquiv (p : A → ℝ) (hp : ∀ a, 0 < p a)
100    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
101    (hb : b 0 = sqrtSpectrum p) : scoreHyperplane A ≃ₗ[ℝ] (Fin k → ℝ) where
102  toFun h := whiten p b h.1
103  invFun x := ⟨unwhiten p b x, unwhiten_sum_zero p b hb x⟩
104  left_inv h := Subtype.ext (unwhiten_whiten p hp b hb h.1 h.2)
105  right_inv := whiten_unwhiten p hp b
106  map_add' h j := by
107    funext i
108    simp [whiten, mul_add, add_div, Finset.sum_add_distrib]
109  map_smul' c h := by
110    funext i
111    simp [whiten, Finset.mul_sum, mul_div_assoc, mul_assoc, mul_left_comm]
112 
113def whiteningContinuousEquiv (p : A → ℝ) (hp : ∀ a, 0 < p a)
114    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
115    (hb : b 0 = sqrtSpectrum p) : scoreHyperplane A ≃L[ℝ] (Fin k → ℝ) :=
116  (whiteningEquiv p hp b hb).toContinuousLinearEquiv
117 
118def whiteningMeasurableEquiv (p : A → ℝ) (hp : ∀ a, 0 < p a)
119    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
120    (hb : b 0 = sqrtSpectrum p) : scoreHyperplane A ≃ᵐ (Fin k → ℝ) :=
121  (whiteningContinuousEquiv p hp b hb).toHomeomorph.toMeasurableEquiv
122 
123@[simp] theorem whiteningMeasurableEquiv_apply (p : A → ℝ) (hp : ∀ a, 0 < p a)
124    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
125    (hb : b 0 = sqrtSpectrum p) (h : scoreHyperplane A) :
126    whiteningMeasurableEquiv p hp b hb h = whiten p b h.1 := rfl
127 
128@[simp] theorem whiteningMeasurableEquiv_symm_apply (p : A → ℝ) (hp : ∀ a, 0 < p a)
129    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
130    (hb : b 0 = sqrtSpectrum p) (x : Fin k → ℝ) :
131    ((whiteningMeasurableEquiv p hp b hb).symm x).1 = unwhiten p b x := rfl
132 
133/-- The reference measure on physical scores associated to this chart. -/
134def scoreReferenceMeasure (p : A → ℝ) (hp : ∀ a, 0 < p a)
135    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
136    (hb : b 0 = sqrtSpectrum p) : Measure (scoreHyperplane A) :=
137  volume.map (whiteningMeasurableEquiv p hp b hb).symm
138 
139theorem whitening_measurePreserving (p : A → ℝ) (hp : ∀ a, 0 < p a)
140    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
141    (hb : b 0 = sqrtSpectrum p) :
142    MeasurePreserving (whiteningMeasurableEquiv p hp b hb)
143      (scoreReferenceMeasure p hp b hb) volume := by
144  refine ⟨(whiteningMeasurableEquiv p hp b hb).measurable, ?_⟩
145  exact (whiteningMeasurableEquiv p hp b hb).map_map_symm
146 
147/-- The concrete score chart transports every genuine hybrid competitor. -/
148def scoreChannelEquiv {H K : Type*}
149    [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H]
150    [NormedAddCommGroup K] [InnerProductSpace ℂ K] [CompleteSpace K]
151    (p : A → ℝ) (hp : ∀ a, 0 < p a)
152    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
153    (hb : b 0 = sqrtSpectrum p) :
154    Hybrid.Channel H K (scoreReferenceMeasure p hp b hb) ≃
155      Hybrid.Channel H K (volume : Measure (Fin k → ℝ)) :=
156  Hybrid.Channel.coordinateEquiv (whiteningMeasurableEquiv p hp b hb)
157    (whitening_measurePreserving p hp b hb)
158 
159theorem continuous_unwhiten (p : A → ℝ) (b : Fin (k+1) → EuclideanSpace ℝ A) :
160    Continuous (unwhiten p b) := by
161  unfold unwhiten whiteningVector
162  simp only [WithLp.ofLp_sum, Finset.sum_apply, PiLp.smul_apply, smul_eq_mul]
163  fun_prop
164 
165section PhysicalLaw
166variable {s : ℕ}
167open Cloning.MultimodeCoherentGaussianMixture Cloning.PCTJointGaussianReal
168 
169theorem tangentClassical_sum_zero
170    (u : OrthonormalBasis (Fin (s+1)) ℂ (Register (A × A)))
171    (p : A → ℝ) (hu : u 0 = coefficientVector (schmidtCoefficients p)) (z : Fin s → ℂ) :
172    ∑ a, tangentClassical u p z a = 0 := by
173  apply classicalCoordinate_sum_zero
174  rw [coefficientVector_frameTangentMatrix, ← hu]
175  exact frameTangent_orthogonal u.orthonormal z
176 
177/-- The singular physical classical law is the image of the nonsingular
178Gaussian under the explicit inverse chart, not a stipulated covariance law. -/
179theorem classicalTangentLaw_eq_unwhiten_map
180    (u : OrthonormalBasis (Fin (s+1)) ℂ (Register (A × A)))
181    (p : A → ℝ) (hp : ∀ a, 0 < p a)
182    (hu : u 0 = coefficientVector (schmidtCoefficients p))
183    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
184    (hb : b 0 = sqrtSpectrum p) {v : ℝ} (hv : 0 < v) :
185    classicalTangentLaw u p v =
186      (realProductMeasure (fun _ : Fin k => 1 / (4*v))).map (unwhiten p b) := by
187  rw [← classicalTangentLaw_map_whiten u p hp hu b hb hv]
188  unfold classicalTangentLaw
189  rw [Measure.map_map (continuous_whiten p b).measurable (continuous_tangentClassical u p).measurable,
190    Measure.map_map (continuous_unwhiten p b).measurable
191      ((continuous_whiten p b).comp (continuous_tangentClassical u p)).measurable]
192  congr 1
193  funext z
194  exact (unwhiten_whiten p hp b hb _ (tangentClassical_sum_zero u p hu z)).symm
195 
196end PhysicalLaw
197 
198end Cloning.PCTJointGaussianWhitening