Offline · exact source
Exact Lean source

ScoreReferenceMeasure

formalization/Cloning/ScoreReferenceMeasure.lean

Source hash: ec239aa9bfa3cc7d000b265579fa0a9cc8c850814b312059db984a91ba4f6a33

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.

In the dependency map: Gaussian optimum

Declarations in this module
1import Cloning.PCTJointGaussianChart
2import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace
3import Mathlib.MeasureTheory.Measure.Haar.Unique
4 
5/-! Whitening changes the intrinsic Lebesgue measure of the score hyperplane
6by one strictly positive finite constant. That constant cancels exactly in
7every normalized flat integral, independently of the integrand and window. -/
8noncomputable section
9open MeasureTheory
10open scoped Topology BigOperators NNReal
11namespace Cloning.PCTJointGaussianWhitening
12set_option backward.isDefEq.respectTransparency false
13set_option maxHeartbeats 600000
14variable {A : Type*} [Fintype A] [LinearOrder A] {k : ℕ}
15 
16/-- The score hyperplane equipped with the ambient Euclidean inner product. -/
17def euclideanScoreHyperplane (A : Type*) [Fintype A] :
18    Submodule ℝ (EuclideanSpace ℝ A) :=
19  (scoreHyperplane A).comap (WithLp.linearEquiv 2 ℝ (A → ℝ)).toLinearMap
20 
21/-- The identity on coordinates between Euclidean scores and the existing
22score-space representation. -/
23def intrinsicScoreEquiv : euclideanScoreHyperplane A ≃L[ℝ] scoreHyperplane A :=
24  LinearEquiv.toContinuousLinearEquiv
25    { toFun := fun h => ⟨WithLp.ofLp h.1, h.2⟩
26      invFun := fun h => ⟨WithLp.toLp 2 h.1, h.2⟩
27      left_inv := fun _ => rfl
28      right_inv := fun _ => rfl
29      map_add' := fun _ _ => rfl
30      map_smul' := fun _ _ => rfl }
31 
32/-- Intrinsic Euclidean volume on the trace-zero hyperplane, expressed in
33the score coordinates used by the physical Gaussian experiment. -/
34def intrinsicScoreMeasure : Measure (scoreHyperplane A) :=
35  (volume : Measure (euclideanScoreHyperplane A)).map intrinsicScoreEquiv
36 
37instance intrinsicScoreMeasure_isAddHaarMeasure :
38    Measure.IsAddHaarMeasure (intrinsicScoreMeasure (A := A)) :=
39  (intrinsicScoreEquiv (A := A)).isAddHaarMeasure_map volume
40 
41instance scoreReferenceMeasure_isAddHaarMeasure (p : A → ℝ) (hp : ∀ a, 0 < p a)
42    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
43    (hb : b 0 = sqrtSpectrum p) :
44    Measure.IsAddHaarMeasure (scoreReferenceMeasure p hp b hb) :=
45  (whiteningContinuousEquiv p hp b hb).symm.isAddHaarMeasure_map volume
46 
47/-- The Jacobian is a finite nonnegative real, and the following theorem
48shows it is strictly positive. No Jacobian premise is supplied. -/
49def scoreVolumeFactor (p : A → ℝ) (hp : ∀ a, 0 < p a)
50    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
51    (hb : b 0 = sqrtSpectrum p) : ℝ≥0 :=
52  Measure.addHaarScalarFactor (scoreReferenceMeasure p hp b hb) (intrinsicScoreMeasure (A := A))
53 
54theorem scoreVolumeFactor_pos (p : A → ℝ) (hp : ∀ a, 0 < p a)
55    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
56    (hb : b 0 = sqrtSpectrum p) : 0 < scoreVolumeFactor p hp b hb :=
57  Measure.addHaarScalarFactor_pos_of_isAddHaarMeasure _ _
58 
59theorem scoreReferenceMeasure_eq_intrinsic (p : A → ℝ) (hp : ∀ a, 0 < p a)
60    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
61    (hb : b 0 = sqrtSpectrum p) :
62    scoreReferenceMeasure p hp b hb = scoreVolumeFactor p hp b hb • (intrinsicScoreMeasure (A := A)) :=
63  Measure.isAddLeftInvariant_eq_smul _ _
64 
65/-- The change from whitening volume to intrinsic hyperplane volume cancels
66exactly in normalized averages, even for a nonrectangular score window. -/
67theorem normalized_score_integral_eq_intrinsic (p : A → ℝ) (hp : ∀ a, 0 < p a)
68    (b : OrthonormalBasis (Fin (k+1)) ℝ (EuclideanSpace ℝ A))
69    (hb : b 0 = sqrtSpectrum p) (S : Set (scoreHyperplane A))
70    (f : scoreHyperplane A → ℝ) :
71    ((scoreReferenceMeasure p hp b hb).real S)⁻¹ *
72        (∫ h in S, f h ∂scoreReferenceMeasure p hp b hb) =
73      (intrinsicScoreMeasure.real S)⁻¹ * (∫ h in S, f h ∂intrinsicScoreMeasure) := by
74  rw [scoreReferenceMeasure_eq_intrinsic, measureReal_nnreal_smul_apply,
75    Measure.restrict_smul, integral_smul_nnreal_measure, NNReal.smul_def, smul_eq_mul, mul_inv_rev]
76  have hc : (scoreVolumeFactor p hp b hb : ℝ) ≠ 0 :=
77    ne_of_gt (show (0:ℝ) < scoreVolumeFactor p hp b hb from
78      scoreVolumeFactor_pos p hp b hb)
79  calc
80    _ = ((scoreVolumeFactor p hp b hb : ℝ)⁻¹ * scoreVolumeFactor p hp b hb) *
81        ((intrinsicScoreMeasure.real S)⁻¹ * ∫ h in S, f h ∂intrinsicScoreMeasure) := by ring
82    _ = _ := by rw [inv_mul_cancel₀ hc, one_mul]
83 
84end Cloning.PCTJointGaussianWhitening