Exact Lean source
YoungHyperplane
formalization/Cloning/YoungHyperplane.lean
Source hash: 2939f43d6e34f877ce6c253cd0d76fb208851dfff1460a139c219778a252f7e2
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.YoungHyperplane.rootSpacedefinition Cloning.YoungHyperplane.coordinatestheorem Cloning.YoungHyperplane.coordinates_headtheorem Cloning.YoungHyperplane.coordinates_lasttheorem Cloning.YoungHyperplane.coordinates_symm_applydefinition Cloning.YoungHyperplane.coordinatesContinuousdefinition Cloning.YoungHyperplane.coordinateMeasuretheorem Cloning.YoungHyperplane.coordinates_measurePreservingdefinition Cloning.YoungHyperplane.Latticedefinition Cloning.YoungHyperplane.latticeCoordinatestheorem Cloning.YoungHyperplane.latticeCoordinates_headtheorem Cloning.YoungHyperplane.latticeCoordinates_sumdefinition Cloning.YoungHyperplane.celltheorem Cloning.YoungHyperplane.measurableSet_celltheorem Cloning.YoungHyperplane.cells_covertheorem Cloning.YoungHyperplane.cells_disjointtheorem Cloning.YoungHyperplane.coordinateMeasure_celltheorem Cloning.YoungHyperplane.integral_coordinatesdefinition Cloning.YoungHyperplane.latticePMFtheorem Cloning.YoungHyperplane.latticePMF_applydefinition Cloning.YoungHyperplane.latticeRoundingPMFtheorem Cloning.YoungHyperplane.latticeRoundingPMF_applydefinition Cloning.YoungHyperplane.interpolatetheorem Cloning.YoungHyperplane.interpolate_integraltheorem Cloning.YoungHyperplane.interpolate_l1_isometrytheorem Cloning.YoungHyperplane.affineDensity_affinitytheorem Cloning.YoungHyperplane.interpolate_affinity1import Cloning.YoungCompatibilityFallback
2import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace
3import Mathlib.LinearAlgebra.Matrix.SchurComplement
4
5/-!
6# The root hyperplane and its actual coordinate transport
7
8The affine lattice and the real sum-zero hyperplane are constructed as
9subtypes, with explicit coordinate equivalences. Probability distributions,
10cells and densities are transported along those equivalences. This exposes
11the dependent last coordinate rather than dropping it from the state space.
12-/
13
14set_option maxHeartbeats 800000
15noncomputable section
16open scoped BigOperators Topology Classical
17open MeasureTheory
18
19namespace Cloning.YoungHyperplane
20
21/-- The actual root hyperplane, with the metric and inner product induced
22from the ambient Euclidean space of `d+1` coordinates. -/
23abbrev rootSpace (d : ℕ) : Submodule ℝ (EuclideanSpace ℝ (Fin (d + 1))) where
24 carrier := {x | ∑ i, x i = 0}
25 zero_mem' := by simp
26 add_mem' := by
27 intro x y hx hy
28 change (∑ i, (x + y) i) = 0
29 change (∑ i, x i) = 0 at hx
30 change (∑ i, y i) = 0 at hy
31 simp only [PiLp.add_apply, Finset.sum_add_distrib, hx, hy, add_zero]
32 smul_mem' := by
33 intro c x hx
34 change (∑ i, (c • x) i) = 0
35 change (∑ i, x i) = 0 at hx
36 simp only [PiLp.smul_apply, smul_eq_mul, ← Finset.mul_sum, hx, mul_zero]
37
38/-- Coordinates along `e_i-e_last` as an explicit linear equivalence. -/
39def coordinates (d : ℕ) : (Fin d → ℝ) ≃ₗ[ℝ] rootSpace d where
40 toFun x := ⟨WithLp.toLp 2 (Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) x (-∑ i, x i)), by
41 change (∑ i, Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) x (-∑ j, x j) i) = 0
42 rw [Fin.sum_univ_castSucc]
43 simp⟩
44 invFun x i := x.1 i.castSucc
45 left_inv x := by ext i; simp
46 right_inv x := by
47 apply Subtype.ext
48 ext i
49 change Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) (fun j : Fin d ↦ x.1 j.castSucc) (-∑ j : Fin d, x.1 j.castSucc) i = x.1 i
50 refine Fin.lastCases ?_ (fun j ↦ ?_) i
51 · rw [Fin.snoc_last]
52 have hx := x.2
53 change (∑ i, x.1 i) = 0 at hx
54 rw [Fin.sum_univ_castSucc] at hx
55 linarith
56 · simp
57 map_add' x y := by
58 apply Subtype.ext
59 ext i
60 change Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) (x + y) (-∑ j, (x + y) j) i =
61 Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) x (-∑ j, x j) i + Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) y (-∑ j, y j) i
62 refine Fin.lastCases ?_ (fun j ↦ ?_) i
63 · simp [Finset.sum_add_distrib, add_comm]
64 · simp
65 map_smul' c x := by
66 apply Subtype.ext
67 ext i
68 change Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) (c • x) (-∑ j, (c • x) j) i = c * Fin.snoc (α := fun _ : Fin (d + 1) ↦ ℝ) x (-∑ j, x j) i
69 refine Fin.lastCases ?_ (fun j ↦ ?_) i
70 · simp [← Finset.mul_sum]
71 · simp
72
73@[simp] theorem coordinates_head (d : ℕ) (x : Fin d → ℝ) (i : Fin d) :
74 (coordinates d x).1 i.castSucc = x i := by simp [coordinates]
75
76@[simp] theorem coordinates_last (d : ℕ) (x : Fin d → ℝ) :
77 (coordinates d x).1 (Fin.last d) = -∑ i, x i := by simp [coordinates]
78
79@[simp] theorem coordinates_symm_apply (d : ℕ) (x : rootSpace d) (i : Fin d) :
80 (coordinates d).symm x i = x.1 i.castSucc := rfl
81
82def coordinatesContinuous (d : ℕ) : (Fin d → ℝ) ≃L[ℝ] rootSpace d :=
83 (coordinates d).toContinuousLinearEquiv
84
85/-- The induced coordinate volume. Its relation to canonical Euclidean
86hyperplane volume is a separate normalization identity. -/
87def coordinateMeasure (d : ℕ) : Measure (rootSpace d) :=
88 Measure.map (coordinatesContinuous d) volume
89
90theorem coordinates_measurePreserving (d : ℕ) :
91 MeasurePreserving (coordinatesContinuous d) volume (coordinateMeasure d) :=
92 ⟨(coordinatesContinuous d).continuous.measurable, rfl⟩
93
94/-- The affine integer lattice with the exact required total mass. -/
95def Lattice (d : ℕ) (n : ℤ) := {μ : Fin (d + 1) → ℤ // ∑ i, μ i = n}
96
97/-- Every affine label is uniquely determined by its first `d` coordinates. -/
98def latticeCoordinates (d : ℕ) (n : ℤ) : (Fin d → ℤ) ≃ Lattice d n where
99 toFun z := ⟨YoungCompatibility.complete n z, YoungCompatibility.complete_sum n z⟩
100 invFun μ i := μ.1 i.castSucc
101 left_inv z := by ext i; simp
102 right_inv μ := by
103 apply Subtype.ext
104 ext i
105 refine Fin.lastCases ?_ (fun j ↦ ?_) i
106 · change YoungCompatibility.complete n (fun j ↦ μ.1 j.castSucc) (Fin.last d) = μ.1 (Fin.last d)
107 rw [YoungCompatibility.complete_last]
108 unfold Rounding.completeLast
109 have hμ := μ.2
110 rw [Fin.sum_univ_castSucc] at hμ
111 change n - (∑ j : Fin d, μ.1 j.castSucc) = μ.1 (Fin.last d)
112 omega
113 · simp
114
115@[simp] theorem latticeCoordinates_head (d : ℕ) (n : ℤ) (z : Fin d → ℤ) (i : Fin d) :
116 (latticeCoordinates d n z).1 i.castSucc = z i := by simp [latticeCoordinates]
117
118@[simp] theorem latticeCoordinates_sum (d : ℕ) (n : ℤ) (μ : Lattice d n) :
119 ∑ i, μ.1 i = n := μ.2
120
121/-- A literal fundamental cell in the Euclidean root hyperplane. -/
122def cell (d : ℕ) (z : Fin d → ℤ) : Set (rootSpace d) :=
123 (coordinates d).symm ⁻¹' YoungRounding.cell z
124
125theorem measurableSet_cell (d : ℕ) (z : Fin d → ℤ) : MeasurableSet (cell d z) :=
126 (coordinatesContinuous d).symm.continuous.measurable (YoungRounding.measurableSet_cell z)
127
128theorem cells_cover (d : ℕ) : (⋃ z : Fin d → ℤ, cell d z) = Set.univ := by
129 apply Set.eq_univ_of_forall
130 intro x
131 refine Set.mem_iUnion.mpr ⟨YoungRounding.round ((coordinates d).symm x), ?_⟩
132 exact (YoungRounding.round_eq_iff _ _).mp rfl
133
134theorem cells_disjoint (d : ℕ) : Pairwise fun z w : Fin d → ℤ ↦ Disjoint (cell d z) (cell d w) := by
135 intro z w hzw
136 exact (YoungRounding.cells_disjoint hzw).preimage _
137
138theorem coordinateMeasure_cell (d : ℕ) (z : Fin d → ℤ) :
139 coordinateMeasure d (cell d z) = 1 := by
140 rw [coordinateMeasure, Measure.map_apply (coordinatesContinuous d).continuous.measurable
141 (measurableSet_cell d z)]
142 have heq : (coordinatesContinuous d) ⁻¹' cell d z = YoungRounding.cell z := by
143 ext x
144 change (coordinates d).symm (coordinates d x) ∈ YoungRounding.cell z ↔ _
145 rw [LinearEquiv.symm_apply_apply]
146 rw [heq, YoungRounding.volume_cell]
147
148/-- Integration is transported to the actual hyperplane, rather than merely
149asserting an unspecified Jacobian cancellation. -/
150theorem integral_coordinates (d : ℕ) (f : (Fin d → ℝ) → ℝ) :
151 (∫ x : rootSpace d, f ((coordinates d).symm x) ∂coordinateMeasure d) = ∫ x, f x := by
152 have h := (coordinates_measurePreserving d).integral_comp
153 (coordinatesContinuous d).toHomeomorph.measurableEmbedding
154 (fun x ↦ f ((coordinates d).symm x))
155 have heq (x : Fin d → ℝ) : (coordinates d).symm (coordinatesContinuous d x) = x :=
156 (coordinates d).symm_apply_apply x
157 simpa only [heq] using h.symm
158
159/-- The actual affine-label PMF, constructed by pushing forward a head law. -/
160def latticePMF (d : ℕ) (n : ℤ) (P : PMF (Fin d → ℤ)) : PMF (Lattice d n) :=
161 P.map (latticeCoordinates d n)
162
163theorem latticePMF_apply (d : ℕ) (n : ℤ) (P : PMF (Fin d → ℤ)) (z : Fin d → ℤ) :
164 latticePMF d n P (latticeCoordinates d n z) = P z := by
165 unfold latticePMF
166 rw [PMF.map_apply]
167 simp only [(latticeCoordinates d n).injective.eq_iff]
168 exact tsum_eq_single z (fun b hb ↦ if_neg (Ne.symm hb)) |>.trans (if_pos rfl)
169
170/-- Transport the actual dither kernel to the full affine lattice. -/
171def latticeRoundingPMF (d : ℕ) (n m : ℤ) (γ : ℝ) (μ : Lattice d n) : PMF (Lattice d m) :=
172 latticePMF d m (YoungRounding.roundingPMF γ (fun i : Fin d ↦ (μ.1 i.castSucc : ℝ)))
173
174theorem latticeRoundingPMF_apply (d : ℕ) (n m : ℤ) (γ : ℝ) (μ : Lattice d n) (z : Fin d → ℤ) :
175 latticeRoundingPMF d n m γ μ (latticeCoordinates d m z) =
176 YoungRounding.roundingPMF γ (fun i : Fin d ↦ (μ.1 i.castSucc : ℝ)) z :=
177 latticePMF_apply d m _ z
178
179/-- Scaled and translated interpolation on the full root hyperplane. The law
180is indexed by the actual affine lattice; `a` is the recentering displacement
181in the hyperplane and `h>0` is the cell scale. -/
182def interpolate (d : ℕ) (n : ℤ) (h : ℝ) (a : rootSpace d)
183 (P : Lattice d n → ℝ) (x : rootSpace d) : ℝ :=
184 YoungRounding.affineDensity h ((coordinates d).symm a)
185 (YoungRounding.interpolate (fun z ↦ P (latticeCoordinates d n z))) ((coordinates d).symm x)
186
187theorem interpolate_integral (d : ℕ) (n : ℤ) (h : ℝ) (hh : 0 < h) (a : rootSpace d)
188 (P : Lattice d n → ℝ) (hP : Summable P) :
189 (∫ x, interpolate d n h a P x ∂coordinateMeasure d) = ∑' μ, P μ := by
190 have hp : Summable (fun z ↦ P (latticeCoordinates d n z)) :=
191 (latticeCoordinates d n).summable_iff.mpr hP
192 unfold interpolate
193 rw [integral_coordinates, YoungRounding.integral_affineDensity h hh,
194 YoungRounding.integral_interpolate hp]
195 exact (latticeCoordinates d n).tsum_eq P
196
197/-- Exact `ℓ¹` preservation on the full affine lattice and root hyperplane. -/
198theorem interpolate_l1_isometry (d : ℕ) (n : ℤ) (h : ℝ) (hh : 0 < h) (a : rootSpace d)
199 (P Q : Lattice d n → ℝ) (hP : Summable P) (hQ : Summable Q) :
200 (∫ x, |interpolate d n h a P x - interpolate d n h a Q x| ∂coordinateMeasure d) =
201 ∑' μ, |P μ - Q μ| := by
202 have hp : Summable (fun z ↦ P (latticeCoordinates d n z)) :=
203 (latticeCoordinates d n).summable_iff.mpr hP
204 have hq : Summable (fun z ↦ Q (latticeCoordinates d n z)) :=
205 (latticeCoordinates d n).summable_iff.mpr hQ
206 unfold interpolate
207 rw [integral_coordinates d (fun y ↦
208 |YoungRounding.affineDensity h ((coordinates d).symm a)
209 (YoungRounding.interpolate (fun z ↦ P (latticeCoordinates d n z))) y -
210 YoungRounding.affineDensity h ((coordinates d).symm a)
211 (YoungRounding.interpolate (fun z ↦ Q (latticeCoordinates d n z))) y|),
212 YoungRounding.affineDensity_l1_isometry h hh,
213 YoungRounding.interpolate_l1_isometry hp hq]
214 exact (latticeCoordinates d n).tsum_eq (fun μ ↦ |P μ - Q μ|)
215
216/-- Positive affine density transport preserves Hellinger affinity exactly,
217including its Jacobian on the density, at every positive scale. -/
218theorem affineDensity_affinity (d : ℕ) (h : ℝ) (hh : 0 < h) (a : Fin d → ℝ)
219 (f g : (Fin d → ℝ) → ℝ) :
220 (∫ x, Real.sqrt (YoungRounding.affineDensity h a f x) *
221 Real.sqrt (YoungRounding.affineDensity h a g x)) = ∫ x, Real.sqrt (f x) * Real.sqrt (g x) := by
222 have hscale : 0 ≤ (h ^ Fintype.card (Fin d))⁻¹ := inv_nonneg.mpr (pow_nonneg hh.le _)
223 have heq : (fun x ↦ Real.sqrt (YoungRounding.affineDensity h a f x) *
224 Real.sqrt (YoungRounding.affineDensity h a g x)) =
225 YoungRounding.affineDensity h a (fun x ↦ Real.sqrt (f x) * Real.sqrt (g x)) := by
226 funext x
227 simp only [YoungRounding.affineDensity, Real.sqrt_mul hscale]
228 rw [show Real.sqrt (h ^ Fintype.card (Fin d))⁻¹ * Real.sqrt (f (h⁻¹ • (x - a))) *
229 (Real.sqrt (h ^ Fintype.card (Fin d))⁻¹ * Real.sqrt (g (h⁻¹ • (x - a)))) =
230 (Real.sqrt (h ^ Fintype.card (Fin d))⁻¹) ^ 2 *
231 (Real.sqrt (f (h⁻¹ • (x - a))) * Real.sqrt (g (h⁻¹ • (x - a)))) by ring]
232 rw [Real.sq_sqrt hscale]
233 rw [heq, YoungRounding.integral_affineDensity h hh]
234
235/-- Exact Hellinger-affinity preservation on the actual affine lattice. -/
236theorem interpolate_affinity (d : ℕ) (n : ℤ) (h : ℝ) (hh : 0 < h) (a : rootSpace d)
237 (P Q : Lattice d n → ℝ) (hP0 : ∀ μ, 0 ≤ P μ) (hQ0 : ∀ μ, 0 ≤ Q μ)
238 (hP : Summable P) (hQ : Summable Q) :
239 (∫ x, Real.sqrt (interpolate d n h a P x) * Real.sqrt (interpolate d n h a Q x)
240 ∂coordinateMeasure d) = ∑' μ, Real.sqrt (P μ) * Real.sqrt (Q μ) := by
241 have hp : Summable (fun z ↦ P (latticeCoordinates d n z)) :=
242 (latticeCoordinates d n).summable_iff.mpr hP
243 have hq : Summable (fun z ↦ Q (latticeCoordinates d n z)) :=
244 (latticeCoordinates d n).summable_iff.mpr hQ
245 unfold interpolate
246 rw [integral_coordinates d (fun y ↦
247 Real.sqrt (YoungRounding.affineDensity h ((coordinates d).symm a)
248 (YoungRounding.interpolate (fun z ↦ P (latticeCoordinates d n z))) y) *
249 Real.sqrt (YoungRounding.affineDensity h ((coordinates d).symm a)
250 (YoungRounding.interpolate (fun z ↦ Q (latticeCoordinates d n z))) y)),
251 affineDensity_affinity d h hh,
252 YoungRounding.interpolate_affinity (fun z ↦ hP0 _) (fun z ↦ hQ0 _) hp hq]
253 exact (latticeCoordinates d n).tsum_eq (fun μ ↦ Real.sqrt (P μ) * Real.sqrt (Q μ))
254
255end Cloning.YoungHyperplane