Exact Lean source
YoungRounding
formalization/Cloning/YoungRounding.lean
Source hash: 80672c98d9780b762aa2d119cc109731d3193df847dbc467bfd2a9ad194dedd2
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.YoungRounding.celldefinition Cloning.YoungRounding.roundtheorem Cloning.YoungRounding.measurable_roundtheorem Cloning.YoungRounding.round_eq_ifftheorem Cloning.YoungRounding.cell_eq_fibertheorem Cloning.YoungRounding.measurableSet_celltheorem Cloning.YoungRounding.cells_disjointtheorem Cloning.YoungRounding.cells_covertheorem Cloning.YoungRounding.volume_celldefinition Cloning.YoungRounding.ditherMeasuredefinition Cloning.YoungRounding.dilatedRoundtheorem Cloning.YoungRounding.measurable_dilatedRounddefinition Cloning.YoungRounding.roundingPMFtheorem Cloning.YoungRounding.roundingPMF_sumtheorem Cloning.YoungRounding.roundingPMF_eq_overlaptheorem Cloning.YoungRounding.roundingPMF_supportdefinition Cloning.YoungRounding.transporttheorem Cloning.YoungRounding.transport_applydefinition Cloning.YoungRounding.binMasstheorem Cloning.YoungRounding.hasSum_binMasstheorem Cloning.YoungRounding.binMass_nonnegtheorem Cloning.YoungRounding.binMass_l1_contractiontheorem Cloning.YoungRounding.density_l1_local_tailtheorem Cloning.YoungRounding.density_l1_local_uniform_tailtheorem Cloning.YoungRounding.binMass_l1_local_uniform_tailtheorem Cloning.YoungRounding.density_l1_uniform_of_local_and_tailstheorem Cloning.YoungRounding.binMass_l1_uniform_of_local_and_tailsdefinition Cloning.YoungRounding.interpolatetheorem Cloning.YoungRounding.interpolate_eq_on_celltheorem Cloning.YoungRounding.integrableOn_interpolatetheorem Cloning.YoungRounding.integral_interpolate_celltheorem Cloning.YoungRounding.integral_norm_interpolate_celltheorem Cloning.YoungRounding.integrable_interpolatetheorem Cloning.YoungRounding.integral_interpolatetheorem Cloning.YoungRounding.interpolate_l1_isometrytheorem Cloning.YoungRounding.interpolate_affinitydefinition Cloning.YoungRounding.cellAveragetheorem Cloning.YoungRounding.integrable_cellAveragetheorem Cloning.YoungRounding.integral_cellAveragetheorem Cloning.YoungRounding.cellAverage_l1_contractiontheorem Cloning.YoungRounding.cellAverage_interpolatedefinition Cloning.YoungRounding.affineDensitytheorem Cloning.YoungRounding.integral_affineDensitytheorem Cloning.YoungRounding.integrable_affineDensitytheorem Cloning.YoungRounding.affineDensity_l1_isometrydefinition Cloning.YoungRounding.affinePulltheorem Cloning.YoungRounding.affinePull_eq_affineDensitytheorem Cloning.YoungRounding.integral_affinePulltheorem Cloning.YoungRounding.integrable_affinePulltheorem Cloning.YoungRounding.affineDensity_affinePulldefinition Cloning.YoungRounding.scaledCellAveragetheorem Cloning.YoungRounding.integrable_scaledCellAveragetheorem Cloning.YoungRounding.integral_scaledCellAveragetheorem Cloning.YoungRounding.scaledCellAverage_l1_contractiontheorem Cloning.YoungRounding.scaledCellAverage_eq_integraltheorem Cloning.YoungRounding.scaledCellAverage_nonnegtheorem Cloning.YoungRounding.same_scaled_cell_dist_letheorem Cloning.YoungRounding.scaledCellAverage_error_letheorem Cloning.YoungRounding.integral_compl_closedBall_tendsto_zerotheorem Cloning.YoungRounding.scaledCellAverage_l1_tendsto_uniform_translationtheorem Cloning.YoungRounding.cast_add_mem_cell_ifftheorem Cloning.YoungRounding.roundingPMF_eq_cell_overlaptheorem Cloning.YoungRounding.binMass_affineDensity_zerotheorem Cloning.YoungRounding.binMass_dilated_interpolatetheorem Cloning.YoungRounding.transport_toRealtheorem Cloning.YoungRounding.rounding_intertwiningtheorem Cloning.YoungRounding.affinePull_affineDensitydefinition Cloning.YoungRounding.preRoundedDensitydefinition Cloning.YoungRounding.roundedDensitytheorem Cloning.YoungRounding.rounding_intertwining_scaledtheorem Cloning.YoungRounding.integrable_preRoundedDensitytheorem Cloning.YoungRounding.preRoundedDensity_nonnegtheorem Cloning.YoungRounding.integral_preRoundedDensitytheorem Cloning.YoungRounding.roundedDensity_l1_comparisontheorem Cloning.YoungRounding.roundedDensity_l1_of_local_limit1import Cloning.Rounding
2import Cloning.CountableScheffe
3import Mathlib.MeasureTheory.Function.Floor
4import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
5import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
6import Mathlib.MeasureTheory.Group.Integral
7import Mathlib.Topology.UniformSpace.HeineCantor
8import Mathlib.MeasureTheory.Integral.Bochner.Set
9import Mathlib.Probability.ProbabilityMassFunction.Monad
10
11/-!
12# Actual lattice cells and randomized rounding
13
14The coordinate space here is `ι → ℝ`, where `ι` indexes the first `d-1`
15coordinates of the manuscript's affine lattice. The last coordinate is
16recovered by `Cloning.Rounding.completeLast`. Lebesgue measure in these
17coordinates gives the unit cell volume one; the common Jacobian `√d` for
18the induced hyperplane volume cancels from all probabilities.
19
20The rounding distribution is constructed by pushing forward restricted
21Lebesgue measure, rather than by supplying a row-sum assumption.
22-/
23
24noncomputable section
25open MeasureTheory Set Filter
26open scoped BigOperators ENNReal Topology
27
28namespace Cloning.YoungRounding
29
30variable {ι : Type*} [Fintype ι]
31
32def cell (z : ι → ℤ) : Set (ι → ℝ) :=
33 Set.pi Set.univ fun i ↦ Set.Ico ((z i : ℝ) - 1 / 2) ((z i : ℝ) + 1 / 2)
34
35def round (x : ι → ℝ) : ι → ℤ := fun i ↦ Rounding.nearest (x i)
36
37omit [Fintype ι] in
38theorem measurable_round : Measurable (round (ι := ι)) := by
39 apply measurable_pi_lambda
40 intro i
41 exact Int.measurable_floor.comp ((measurable_pi_apply i).add_const (1 / 2))
42
43omit [Fintype ι] in
44theorem round_eq_iff (x : ι → ℝ) (z : ι → ℤ) : round x = z ↔ x ∈ cell z := by
45 simp only [funext_iff, round, cell, Set.mem_pi, Set.mem_univ, true_implies,
46 Set.mem_Ico, Rounding.nearest_eq_iff]
47
48omit [Fintype ι] in
49theorem cell_eq_fiber (z : ι → ℤ) : cell z = round ⁻¹' {z} := by
50 ext x
51 exact (round_eq_iff x z).symm
52
53theorem measurableSet_cell (z : ι → ℤ) : MeasurableSet (cell z) := by
54 rw [cell_eq_fiber]
55 exact measurable_round (measurableSet_singleton z)
56
57omit [Fintype ι] in
58theorem cells_disjoint : Pairwise fun z w : ι → ℤ ↦ Disjoint (cell z) (cell w) := by
59 intro z w hzw
60 rw [Set.disjoint_left]
61 intro x hx hw
62 exact hzw ((round_eq_iff x z).mpr hx |>.symm.trans ((round_eq_iff x w).mpr hw))
63
64omit [Fintype ι] in
65theorem cells_cover : (⋃ z : ι → ℤ, cell z) = Set.univ := by
66 apply Set.eq_univ_of_forall
67 intro x
68 exact Set.mem_iUnion.mpr ⟨round x, (round_eq_iff x (round x)).mp rfl⟩
69
70theorem volume_cell (z : ι → ℤ) : volume (cell z) = 1 := by
71 rw [cell, Real.volume_pi_Ico]
72 simp only [show ∀ i, (z i : ℝ) + 1 / 2 - ((z i : ℝ) - 1 / 2) = 1 by
73 intro i; ring, ENNReal.ofReal_one, Finset.prod_const_one]
74
75def ditherMeasure : Measure (ι → ℝ) := volume.restrict (cell 0)
76
77instance ditherMeasure_isProbabilityMeasure :
78 IsProbabilityMeasure (ditherMeasure (ι := ι)) := by
79 constructor
80 simp [ditherMeasure, volume_cell]
81
82def dilatedRound (γ : ℝ) (μ : ι → ℝ) (y : ι → ℝ) : ι → ℤ :=
83 round (fun i ↦ γ * (μ i + y i))
84
85omit [Fintype ι] in
86theorem measurable_dilatedRound (γ : ℝ) (μ : ι → ℝ) :
87 Measurable (dilatedRound γ μ) := by
88 apply measurable_round.comp
89 exact measurable_pi_lambda _ fun i ↦
90 measurable_const.mul (measurable_const.add (measurable_pi_apply i))
91
92/-- The actual uniform-dither rounding law, including all lattice labels. -/
93def roundingPMF (γ : ℝ) (μ : ι → ℝ) : PMF (ι → ℤ) := by
94 let ν := (ditherMeasure (ι := ι)).map (dilatedRound γ μ)
95 haveI : IsProbabilityMeasure ν :=
96 Measure.isProbabilityMeasure_map (measurable_dilatedRound γ μ).aemeasurable
97 exact ν.toPMF
98
99/-- Normalization follows from the pushforward probability measure. -/
100theorem roundingPMF_sum (γ : ℝ) (μ : ι → ℝ) :
101 ∑' z, roundingPMF γ μ z = 1 := (roundingPMF γ μ).tsum_coe
102
103/-- The source-coordinate overlap formula; it is valid even when `γ = 0`.
104For positive `γ`, change of variables gives the manuscript's ratio of the
105dilated overlap volume to `γ ^ card ι`.
106-/
107theorem roundingPMF_eq_overlap (γ : ℝ) (μ : ι → ℝ) (z : ι → ℤ) :
108 roundingPMF γ μ z =
109 volume ((fun y : ι → ℝ ↦ fun i ↦ γ * (μ i + y i)) ⁻¹' cell z ∩ cell 0) := by
110 rw [roundingPMF, Measure.toPMF_apply,
111 Measure.map_apply (measurable_dilatedRound γ μ) (measurableSet_singleton z),
112 ditherMeasure, Measure.restrict_apply
113 ((measurable_dilatedRound γ μ) (measurableSet_singleton z))]
114 congr 1
115 ext y
116 simp only [Set.mem_inter_iff, Set.mem_preimage, Set.mem_singleton_iff,
117 dilatedRound, round_eq_iff]
118
119/-- A positive-mass output satisfies each of the manuscript's coordinate
120rounding bounds. No support or partition hypothesis is supplied.
121-/
122theorem roundingPMF_support (γ : ℝ) (hγ : 0 ≤ γ) (μ : ι → ℝ) (z : ι → ℤ)
123 (hz : roundingPMF γ μ z ≠ 0) (i : ι) :
124 |(z i : ℝ) - γ * μ i| ≤ (γ + 1) / 2 := by
125 rw [roundingPMF_eq_overlap] at hz
126 have hne : ((fun y : ι → ℝ ↦ fun j ↦ γ * (μ j + y j)) ⁻¹' cell z ∩ cell 0) ≠ ∅ :=
127 fun hempty ↦ hz (by rw [hempty, measure_empty])
128 obtain ⟨y, hy, hy0⟩ := Set.nonempty_iff_ne_empty.mpr hne
129 have hround := (round_eq_iff (fun j ↦ γ * (μ j + y j)) z).mpr hy
130 have hyi : -(1 / 2 : ℝ) ≤ y i ∧ y i < 1 / 2 := by
131 simpa [cell] using hy0 i (Set.mem_univ i)
132 have hi : Rounding.nearest (γ * (μ i + y i)) = z i := congrFun hround i
133 rw [← hi]
134 exact Rounding.dither_error γ (μ i) (y i) hγ hyi
135
136/-- A random input label followed by the concrete cell kernel is an actual
137normalized countable law, with the usual sum-of-transition-probabilities formula. -/
138def transport (γ : ℝ) (p : PMF (ι → ℤ)) : PMF (ι → ℤ) :=
139 p.bind fun z ↦ roundingPMF γ (fun i ↦ (z i : ℝ))
140
141theorem transport_apply (γ : ℝ) (p : PMF (ι → ℤ)) (w : ι → ℤ) :
142 transport γ p w = ∑' z, p z * roundingPMF γ (fun i ↦ (z i : ℝ)) w := rfl
143
144section MeasurableDiscretization
145
146variable {X Z : Type*} [MeasurableSpace X] [MeasurableSpace Z]
147 [MeasurableSingletonClass Z] [Countable Z]
148
149/-- Actual density mass in each fiber of a measurable rounding map. -/
150def binMass (μ : Measure X) (r : X → Z) (f : X → ℝ) (z : Z) : ℝ :=
151 ∫ x in r ⁻¹' {z}, f x ∂μ
152
153theorem hasSum_binMass (μ : Measure X) {r : X → Z} (hr : Measurable r)
154 {f : X → ℝ} (hf : Integrable f μ) :
155 HasSum (binMass μ r f) (∫ x, f x ∂μ) := by
156 have hcover : (⋃ z : Z, r ⁻¹' {z}) = Set.univ := by
157 ext x
158 simp
159 have hd : Pairwise fun z w : Z ↦ Disjoint (r ⁻¹' {z}) (r ⁻¹' {w}) := by
160 intro z w hzw
161 exact Set.disjoint_left.mpr fun x hx hw ↦ hzw (hx.symm.trans hw)
162 have h := hasSum_integral_iUnion
163 (fun z ↦ hr (measurableSet_singleton z)) hd
164 (show IntegrableOn f (⋃ z : Z, r ⁻¹' {z}) μ by simpa [hcover] using hf)
165 simpa only [binMass, hcover, setIntegral_univ] using h
166
167omit [MeasurableSpace Z] [MeasurableSingletonClass Z] [Countable Z] in
168theorem binMass_nonneg (μ : Measure X) (r : X → Z) {f : X → ℝ}
169 (hf : ∀ x, 0 ≤ f x) (z : Z) : 0 ≤ binMass μ r f z :=
170 integral_nonneg hf
171
172/-- Discretization by any measurable countable partition contracts the actual
173`L¹` distance. The proof uses the fiber partition, not an assumed kernel law. -/
174theorem binMass_l1_contraction (μ : Measure X) {r : X → Z} (hr : Measurable r)
175 {f g : X → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) :
176 (∑' z, |binMass μ r f z - binMass μ r g z|) ≤ ∫ x, |f x - g x| ∂μ := by
177 have hsum := hasSum_binMass μ hr (hf.sub hg).abs
178 have hbound (z : Z) :
179 |binMass μ r f z - binMass μ r g z| ≤ binMass μ r (fun x ↦ |f x - g x|) z := by
180 unfold binMass
181 rw [← integral_sub hf.integrableOn hg.integrableOn]
182 simpa only [Real.norm_eq_abs] using
183 norm_integral_le_integral_norm (f := fun x ↦ f x - g x) (μ := μ.restrict (r ⁻¹' {z}))
184 have hs : Summable (fun z ↦ |binMass μ r f z - binMass μ r g z|) :=
185 hsum.summable.of_nonneg_of_le (fun _ ↦ abs_nonneg _) hbound
186 exact (hs.tsum_le_tsum hbound hsum.summable).trans_eq hsum.tsum_eq
187
188/-- The normalized-density estimate used in the manuscript's local-limit
189argument. Only the reference density's tail is needed. -/
190theorem density_l1_local_tail (μ : Measure X) {f g : X → ℝ}
191 (hf : Integrable f μ) (hg : Integrable g μ)
192 (hf0 : ∀ x, 0 ≤ f x) (hg0 : ∀ x, 0 ≤ g x)
193 (hmass : (∫ x, f x ∂μ) = ∫ x, g x ∂μ)
194 {s : Set X} (hs : MeasurableSet s) :
195 (∫ x, |f x - g x| ∂μ) ≤
196 2 * (∫ x in s, |f x - g x| ∂μ) + 2 * (∫ x in sᶜ, g x ∂μ) := by
197 have hsplit : (∫ x in s, |f x - g x| ∂μ) + (∫ x in sᶜ, |f x - g x| ∂μ) =
198 ∫ x, |f x - g x| ∂μ := integral_add_compl hs (hf.sub hg).abs
199 have hsplitf := integral_add_compl hs hf
200 have hsplitg := integral_add_compl hs hg
201 have hlocal : (∫ x in s, g x ∂μ) - (∫ x in s, f x ∂μ) ≤
202 ∫ x in s, |f x - g x| ∂μ := by
203 rw [← integral_sub hg.integrableOn hf.integrableOn]
204 apply integral_mono (hg.sub hf).integrableOn (hf.sub hg).abs.integrableOn
205 intro x
206 simpa only [neg_sub] using neg_le_abs (f x - g x)
207 have htail : (∫ x in sᶜ, |f x - g x| ∂μ) ≤
208 (∫ x in sᶜ, f x ∂μ) + ∫ x in sᶜ, g x ∂μ := by
209 rw [← integral_add hf.integrableOn hg.integrableOn]
210 apply integral_mono (hf.sub hg).abs.integrableOn (hf.add hg).integrableOn
211 intro x
212 simpa only [abs_of_nonneg (hf0 x), abs_of_nonneg (hg0 x), Pi.add_apply] using
213 abs_sub (f x) (g x)
214 linarith
215
216/-- A uniform density error on a finite-volume set gives an explicit global
217`L¹` bound, without a separate concentration assumption for `f`. -/
218theorem density_l1_local_uniform_tail (μ : Measure X) {f g : X → ℝ}
219 (hf : Integrable f μ) (hg : Integrable g μ)
220 (hf0 : ∀ x, 0 ≤ f x) (hg0 : ∀ x, 0 ≤ g x)
221 (hmass : (∫ x, f x ∂μ) = ∫ x, g x ∂μ)
222 {s : Set X} (hs : MeasurableSet s) (hsfin : μ s ≠ ∞)
223 {ε : ℝ} (hlocal : ∀ x ∈ s, |f x - g x| ≤ ε) :
224 (∫ x, |f x - g x| ∂μ) ≤
225 2 * (μ s).toReal * ε + 2 * (∫ x in sᶜ, g x ∂μ) := by
226 have hbound : (∫ x in s, |f x - g x| ∂μ) ≤ (μ s).toReal * ε := by
227 have hn := norm_setIntegral_le_of_norm_le_const (lt_top_iff_ne_top.mpr hsfin)
228 (f := fun x ↦ |f x - g x|)
229 (fun x hx ↦ by simpa only [Real.norm_eq_abs, abs_abs] using hlocal x hx)
230 exact (le_abs_self _).trans
231 (by simpa only [Real.norm_eq_abs, Measure.real, mul_comm] using hn)
232 have h := density_l1_local_tail μ hf hg hf0 hg0 hmass hs
233 nlinarith
234
235/-- The same explicit local-error/tail bound holds after rounding the two
236densities to the lattice, for any measurable choice of scaled cells. -/
237theorem binMass_l1_local_uniform_tail (μ : Measure X) {r : X → Z} (hr : Measurable r)
238 {f g : X → ℝ} (hf : Integrable f μ) (hg : Integrable g μ)
239 (hf0 : ∀ x, 0 ≤ f x) (hg0 : ∀ x, 0 ≤ g x)
240 (hmass : (∫ x, f x ∂μ) = ∫ x, g x ∂μ)
241 {s : Set X} (hs : MeasurableSet s) (hsfin : μ s ≠ ∞)
242 {ε : ℝ} (hlocal : ∀ x ∈ s, |f x - g x| ≤ ε) :
243 (∑' z, |binMass μ r f z - binMass μ r g z|) ≤
244 2 * (μ s).toReal * ε + 2 * (∫ x in sᶜ, g x ∂μ) :=
245 (binMass_l1_contraction μ hr hf hg).trans
246 (density_l1_local_uniform_tail μ hf hg hf0 hg0 hmass hs hsfin hlocal)
247
248/-- Uniform local density convergence plus uniform tails of the normalized
249reference family implies uniform global `L¹` convergence. The parameter type
250can be a compact set of spectra; no compactness or local limit is assumed
251implicitly in this statement. -/
252theorem density_l1_uniform_of_local_and_tails {P : Type*}
253 (μ : Measure X) (f : ℕ → P → X → ℝ) (g : P → X → ℝ)
254 (hf : ∀ n p, Integrable (f n p) μ) (hg : ∀ p, Integrable (g p) μ)
255 (hf0 : ∀ n p x, 0 ≤ f n p x) (hg0 : ∀ p x, 0 ≤ g p x)
256 (hmass : ∀ n p, (∫ x, f n p x ∂μ) = ∫ x, g p x ∂μ)
257 (s : ℕ → Set X) (hs : ∀ k, MeasurableSet (s k)) (hsfin : ∀ k, μ (s k) ≠ ∞)
258 (hlocal : ∀ k δ, 0 < δ → ∀ᶠ n in atTop, ∀ p x, x ∈ s k →
259 |f n p x - g p x| ≤ δ)
260 (htail : ∀ δ, 0 < δ → ∃ k, ∀ p, (∫ x in (s k)ᶜ, g p x ∂μ) ≤ δ) :
261 ∀ ε, 0 < ε → ∀ᶠ n in atTop, ∀ p, (∫ x, |f n p x - g p x| ∂μ) < ε := by
262 intro ε hε
263 obtain ⟨k, hk⟩ := htail (ε / 4) (by positivity)
264 let V := (μ (s k)).toReal
265 have hV : 0 ≤ V := ENNReal.toReal_nonneg
266 let δ := ε / (4 * (V + 1))
267 have hδ : 0 < δ := div_pos hε (by positivity)
268 have hδeq : 4 * (V + 1) * δ = ε := by
269 dsimp [δ]
270 field_simp
271 filter_upwards [hlocal k δ hδ] with n hn
272 intro p
273 have hb := density_l1_local_uniform_tail μ (hf n p) (hg p) (hf0 n p) (hg0 p)
274 (hmass n p) (hs k) (hsfin k) (hn p)
275 change (∫ x, |f n p x - g p x| ∂μ) ≤
276 2 * V * δ + 2 * (∫ x in (s k)ᶜ, g p x ∂μ) at hb
277 have hkp := hk p
278 nlinarith
279
280/-- The uniform comparison survives arbitrary varying measurable lattice
281rounding maps, including changing sample sizes and translated cells. -/
282theorem binMass_l1_uniform_of_local_and_tails {P : Type*}
283 (μ : Measure X) (r : ℕ → P → X → Z) (hr : ∀ n p, Measurable (r n p))
284 (f : ℕ → P → X → ℝ) (g : P → X → ℝ)
285 (hf : ∀ n p, Integrable (f n p) μ) (hg : ∀ p, Integrable (g p) μ)
286 (hf0 : ∀ n p x, 0 ≤ f n p x) (hg0 : ∀ p x, 0 ≤ g p x)
287 (hmass : ∀ n p, (∫ x, f n p x ∂μ) = ∫ x, g p x ∂μ)
288 (s : ℕ → Set X) (hs : ∀ k, MeasurableSet (s k)) (hsfin : ∀ k, μ (s k) ≠ ∞)
289 (hlocal : ∀ k δ, 0 < δ → ∀ᶠ n in atTop, ∀ p x, x ∈ s k →
290 |f n p x - g p x| ≤ δ)
291 (htail : ∀ δ, 0 < δ → ∃ k, ∀ p, (∫ x in (s k)ᶜ, g p x ∂μ) ≤ δ) :
292 ∀ ε, 0 < ε → ∀ᶠ n in atTop, ∀ p,
293 (∑' z, |binMass μ (r n p) (f n p) z - binMass μ (r n p) (g p) z|) < ε := by
294 intro ε hε
295 filter_upwards [density_l1_uniform_of_local_and_tails μ f g hf hg hf0 hg0 hmass
296 s hs hsfin hlocal htail ε hε] with n hn
297 exact fun p ↦ (binMass_l1_contraction μ (hr n p) (hf n p) (hg p)).trans_lt (hn p)
298
299end MeasurableDiscretization
300
301/-- Piecewise-constant interpolation on the exact unit lattice cells. -/
302def interpolate (p : (ι → ℤ) → ℝ) (x : ι → ℝ) : ℝ := p (round x)
303
304omit [Fintype ι] in
305theorem interpolate_eq_on_cell (p : (ι → ℤ) → ℝ) (z : ι → ℤ)
306 {x : ι → ℝ} (hx : x ∈ cell z) : interpolate p x = p z := by
307 rw [interpolate, (round_eq_iff x z).mpr hx]
308
309theorem integrableOn_interpolate (p : (ι → ℤ) → ℝ) (z : ι → ℤ) :
310 IntegrableOn (interpolate p) (cell z) := by
311 have hc : IntegrableOn (fun _ : ι → ℝ ↦ p z) (cell z) :=
312 integrableOn_const (by rw [volume_cell]; exact ENNReal.one_ne_top)
313 apply hc.congr
314 exact (ae_restrict_iff' (measurableSet_cell z)).mpr (Filter.Eventually.of_forall
315 fun x hx ↦ (interpolate_eq_on_cell p z hx).symm)
316
317theorem integral_interpolate_cell (p : (ι → ℤ) → ℝ) (z : ι → ℤ) :
318 (∫ x in cell z, interpolate p x) = p z := by
319 rw [setIntegral_congr_fun (measurableSet_cell z)
320 (fun x hx ↦ interpolate_eq_on_cell p z hx), setIntegral_const]
321 simp [Measure.real, volume_cell]
322
323theorem integral_norm_interpolate_cell (p : (ι → ℤ) → ℝ) (z : ι → ℤ) :
324 (∫ x in cell z, ‖interpolate p x‖) = |p z| := by
325 have heq : (fun x ↦ ‖interpolate p x‖) = interpolate (fun w ↦ |p w|) := by
326 funext x
327 simp only [interpolate, Real.norm_eq_abs]
328 rw [heq, integral_interpolate_cell]
329
330theorem integrable_interpolate {p : (ι → ℤ) → ℝ} (hp : Summable p) :
331 Integrable (interpolate p) := by
332 have h := integrableOn_iUnion_of_summable_integral_norm
333 (integrableOn_interpolate p)
334 (show Summable (fun z ↦ ∫ x in cell z, ‖interpolate p x‖) by
335 simpa only [integral_norm_interpolate_cell] using hp.abs)
336 simpa only [cells_cover, integrableOn_univ] using h
337
338theorem integral_interpolate {p : (ι → ℤ) → ℝ} (hp : Summable p) :
339 (∫ x, interpolate p x) = ∑' z, p z := by
340 have h := hasSum_integral_iUnion measurableSet_cell cells_disjoint
341 (show IntegrableOn (interpolate p) (⋃ z, cell z) by
342 simpa only [cells_cover, integrableOn_univ] using integrable_interpolate hp)
343 simpa only [cells_cover, setIntegral_univ, integral_interpolate_cell] using h.tsum_eq.symm
344
345/-- The actual Lebesgue interpolation preserves the countable `ℓ¹` distance. -/
346theorem interpolate_l1_isometry {p q : (ι → ℤ) → ℝ}
347 (hp : Summable p) (hq : Summable q) :
348 (∫ x, |interpolate p x - interpolate q x|) = ∑' z, |p z - q z| :=
349 integral_interpolate (hp.sub hq).abs
350
351/-- Hellinger affinity is also preserved, with countably many cells. -/
352theorem interpolate_affinity {p q : (ι → ℤ) → ℝ}
353 (hp0 : ∀ z, 0 ≤ p z) (hq0 : ∀ z, 0 ≤ q z)
354 (hp : Summable p) (hq : Summable q) :
355 (∫ x, Real.sqrt (interpolate p x) * Real.sqrt (interpolate q x)) =
356 ∑' z, Real.sqrt (p z) * Real.sqrt (q z) :=
357 integral_interpolate (CountableScheffe.affinity_summable p q hp0 hq0 hp hq)
358
359/-- Lebesgue cell averaging, constructed from the actual fiber integrals. -/
360def cellAverage (f : (ι → ℝ) → ℝ) : (ι → ℝ) → ℝ :=
361 interpolate (binMass volume round f)
362
363theorem integrable_cellAverage {f : (ι → ℝ) → ℝ} (hf : Integrable f) :
364 Integrable (cellAverage f) :=
365 integrable_interpolate (hasSum_binMass volume measurable_round hf).summable
366
367theorem integral_cellAverage {f : (ι → ℝ) → ℝ} (hf : Integrable f) :
368 (∫ x, cellAverage f x) = ∫ x, f x := by
369 rw [cellAverage, integral_interpolate (hasSum_binMass volume measurable_round hf).summable]
370 exact (hasSum_binMass volume measurable_round hf).tsum_eq
371
372theorem cellAverage_l1_contraction {f g : (ι → ℝ) → ℝ}
373 (hf : Integrable f) (hg : Integrable g) :
374 (∫ x, |cellAverage f x - cellAverage g x|) ≤ ∫ x, |f x - g x| := by
375 rw [cellAverage, cellAverage, interpolate_l1_isometry
376 (hasSum_binMass volume measurable_round hf).summable
377 (hasSum_binMass volume measurable_round hg).summable]
378 exact binMass_l1_contraction volume measurable_round hf hg
379
380theorem cellAverage_interpolate (p : (ι → ℤ) → ℝ) :
381 cellAverage (interpolate p) = interpolate p := by
382 have heq : binMass volume round (interpolate p) = p := by
383 funext z
384 rw [binMass, ← cell_eq_fiber, integral_interpolate_cell]
385 rw [cellAverage, heq]
386
387/-- Translation and positive scalar dilation of a density, including its
388Jacobian. The manuscript uses `h = 1 / sqrt N` for interpolation and
389`h = sqrt γ` for dilation of a recentered density. -/
390def affineDensity (h : ℝ) (a : ι → ℝ) (f : (ι → ℝ) → ℝ) (x : ι → ℝ) : ℝ :=
391 (h ^ Fintype.card ι)⁻¹ * f (h⁻¹ • (x - a))
392
393theorem integral_affineDensity (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
394 (f : (ι → ℝ) → ℝ) : (∫ x, affineDensity h a f x) = ∫ x, f x := by
395 unfold affineDensity
396 rw [integral_const_mul]
397 have ht : (∫ x : ι → ℝ, f (h⁻¹ • (x - a))) = ∫ x : ι → ℝ, f (h⁻¹ • x) := by
398 simpa only [sub_eq_add_neg] using
399 integral_add_right_eq_self (fun x : ι → ℝ ↦ f (h⁻¹ • x)) (-a)
400 rw [ht, Measure.integral_comp_inv_smul_of_nonneg volume f hh.le]
401 simp only [Module.finrank_pi, smul_eq_mul]
402 rw [← mul_assoc, inv_mul_cancel₀ (pow_ne_zero _ hh.ne'), one_mul]
403
404theorem integrable_affineDensity (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
405 {f : (ι → ℝ) → ℝ} (hf : Integrable f) : Integrable (affineDensity h a f) := by
406 have hd := hf.comp_smul (inv_ne_zero hh.ne')
407 have ht := (measurePreserving_add_right (volume : Measure (ι → ℝ)) (-a)).integrable_comp_of_integrable hd
408 simpa only [Function.comp_def, sub_eq_add_neg, affineDensity] using
409 ht.const_mul ((h ^ Fintype.card ι)⁻¹)
410
411theorem affineDensity_l1_isometry (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
412 (f g : (ι → ℝ) → ℝ) :
413 (∫ x, |affineDensity h a f x - affineDensity h a g x|) = ∫ x, |f x - g x| := by
414 have heq : (fun x ↦ |affineDensity h a f x - affineDensity h a g x|) =
415 affineDensity h a (fun x ↦ |f x - g x|) := by
416 funext x
417 simp only [affineDensity, ← mul_sub, abs_mul,
418 abs_of_nonneg (inv_nonneg.mpr (pow_nonneg hh.le _))]
419 rw [heq, integral_affineDensity h hh a]
420
421/-- Pulling a density back to unit-cell coordinates is the inverse density
422transformation, with the inverse Jacobian. -/
423def affinePull (h : ℝ) (a : ι → ℝ) (f : (ι → ℝ) → ℝ) (x : ι → ℝ) : ℝ :=
424 h ^ Fintype.card ι * f (a + h • x)
425
426theorem affinePull_eq_affineDensity (h : ℝ) (hh : h ≠ 0) (a : ι → ℝ)
427 (f : (ι → ℝ) → ℝ) :
428 affinePull h a f = affineDensity h⁻¹ (-(h⁻¹ • a)) f := by
429 funext x
430 simp only [affinePull, affineDensity, inv_pow, inv_inv, sub_neg_eq_add,
431 smul_add, smul_smul, mul_inv_cancel₀ hh, one_smul, add_comm]
432
433theorem integral_affinePull (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
434 (f : (ι → ℝ) → ℝ) : (∫ x, affinePull h a f x) = ∫ x, f x := by
435 rw [affinePull_eq_affineDensity h hh.ne' a f]
436 exact integral_affineDensity h⁻¹ (inv_pos.mpr hh) _ f
437
438theorem integrable_affinePull (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
439 {f : (ι → ℝ) → ℝ} (hf : Integrable f) : Integrable (affinePull h a f) := by
440 rw [affinePull_eq_affineDensity h hh.ne' a f]
441 exact integrable_affineDensity h⁻¹ (inv_pos.mpr hh) _ hf
442
443theorem affineDensity_affinePull (h : ℝ) (hh : h ≠ 0) (a : ι → ℝ)
444 (f : (ι → ℝ) → ℝ) : affineDensity h a (affinePull h a f) = f := by
445 funext x
446 simp only [affineDensity, affinePull, smul_smul, mul_inv_cancel₀ hh, one_smul,
447 add_sub_cancel, ← mul_assoc, inv_mul_cancel₀ (pow_ne_zero _ hh), one_mul]
448
449/-- Averaging over translated cells of side length `h`, defined concretely
450by integration in unit-cell coordinates. -/
451def scaledCellAverage (h : ℝ) (a : ι → ℝ) (f : (ι → ℝ) → ℝ) : (ι → ℝ) → ℝ :=
452 affineDensity h a (cellAverage (affinePull h a f))
453
454theorem integrable_scaledCellAverage (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
455 {f : (ι → ℝ) → ℝ} (hf : Integrable f) : Integrable (scaledCellAverage h a f) :=
456 integrable_affineDensity h hh a (integrable_cellAverage (integrable_affinePull h hh a hf))
457
458theorem integral_scaledCellAverage (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
459 {f : (ι → ℝ) → ℝ} (hf : Integrable f) :
460 (∫ x, scaledCellAverage h a f x) = ∫ x, f x := by
461 rw [scaledCellAverage, integral_affineDensity h hh a,
462 integral_cellAverage (integrable_affinePull h hh a hf), integral_affinePull h hh a]
463
464theorem scaledCellAverage_l1_contraction (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
465 {f g : (ι → ℝ) → ℝ} (hf : Integrable f) (hg : Integrable g) :
466 (∫ x, |scaledCellAverage h a f x - scaledCellAverage h a g x|) ≤
467 ∫ x, |f x - g x| := by
468 rw [scaledCellAverage, scaledCellAverage, affineDensity_l1_isometry h hh a]
469 have hb := cellAverage_l1_contraction (integrable_affinePull h hh a hf)
470 (integrable_affinePull h hh a hg)
471 rw [affinePull_eq_affineDensity h hh.ne' a f,
472 affinePull_eq_affineDensity h hh.ne' a g,
473 affineDensity_l1_isometry h⁻¹ (inv_pos.mpr hh)] at hb
474 simpa only [affinePull_eq_affineDensity h hh.ne' a f,
475 affinePull_eq_affineDensity h hh.ne' a g] using hb
476
477theorem scaledCellAverage_eq_integral (h : ℝ) (hh : h ≠ 0) (a : ι → ℝ)
478 (f : (ι → ℝ) → ℝ) (x : ι → ℝ) :
479 scaledCellAverage h a f x =
480 ∫ y in cell (round (h⁻¹ • (x - a))), f (a + h • y) := by
481 simp only [scaledCellAverage, affineDensity, cellAverage, interpolate, binMass,
482 ← cell_eq_fiber, affinePull, integral_const_mul]
483 rw [← mul_assoc, inv_mul_cancel₀ (pow_ne_zero _ hh), one_mul]
484
485theorem scaledCellAverage_nonneg (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
486 {f : (ι → ℝ) → ℝ} (hf0 : ∀ x, 0 ≤ f x) (x : ι → ℝ) :
487 0 ≤ scaledCellAverage h a f x := by
488 rw [scaledCellAverage_eq_integral h hh.ne']
489 exact integral_nonneg fun y ↦ hf0 (a + h • y)
490
491theorem same_scaled_cell_dist_le (h : ℝ) (hh : 0 < h) (a x y : ι → ℝ)
492 (hy : y ∈ cell (round (h⁻¹ • (x - a)))) : dist (a + h • y) x ≤ h := by
493 let u := h⁻¹ • (x - a)
494 have hu : u ∈ cell (round u) := (round_eq_iff u (round u)).mp rfl
495 have hnorm : ‖y - u‖ ≤ 1 := by
496 apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr
497 intro i
498 have hyi := hy i (Set.mem_univ i)
499 have hui := hu i (Set.mem_univ i)
500 change (round u i : ℝ) - 1 / 2 ≤ y i ∧ y i < (round u i : ℝ) + 1 / 2 at hyi
501 change (round u i : ℝ) - 1 / 2 ≤ u i ∧ u i < (round u i : ℝ) + 1 / 2 at hui
502 rw [Real.norm_eq_abs, abs_le]
503 change -1 ≤ y i - u i ∧ y i - u i ≤ 1
504 constructor <;> linarith
505 have heq : a + h • y - x = h • (y - u) := by
506 dsimp [u]
507 rw [smul_sub, smul_smul, mul_inv_cancel₀ hh.ne', one_smul]
508 abel
509 rw [dist_eq_norm, heq, norm_smul, Real.norm_eq_abs, abs_of_pos hh]
510 nlinarith
511
512/-- The cell-averaging error is controlled by the actual oscillation on one
513cell. Cells have diameter at most `h` in the coordinate supremum norm. -/
514theorem scaledCellAverage_error_le (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
515 {f : (ι → ℝ) → ℝ} (hf : Integrable f) (x : ι → ℝ) (ε : ℝ)
516 (hosc : ∀ y, dist y x ≤ h → |f y - f x| ≤ ε) :
517 |scaledCellAverage h a f x - f x| ≤ ε := by
518 let z := round (h⁻¹ • (x - a))
519 have hi : Integrable (fun y : ι → ℝ ↦ f (a + h • y)) := by
520 exact ((measurePreserving_add_left (volume : Measure (ι → ℝ)) a).integrable_comp_of_integrable hf).comp_smul hh.ne'
521 have hc : IntegrableOn (fun _ : ι → ℝ ↦ f x) (cell z) :=
522 integrableOn_const (by rw [volume_cell]; exact ENNReal.one_ne_top)
523 have hconst : (∫ _y in cell z, f x) = f x := by
524 simp [Measure.real, volume_cell]
525 rw [scaledCellAverage_eq_integral h hh.ne']
526 change |(∫ y in cell z, f (a + h • y)) - f x| ≤ ε
527 rw [← hconst, ← integral_sub hi.integrableOn hc]
528 have hb := norm_setIntegral_le_of_norm_le_const
529 (show volume (cell z) < ∞ by rw [volume_cell]; exact ENNReal.one_lt_top)
530 (f := fun y : ι → ℝ ↦ f (a + h • y) - f x)
531 (fun y hy ↦ by
532 simpa only [Real.norm_eq_abs] using hosc (a + h • y)
533 (same_scaled_cell_dist_le h hh a x y hy))
534 simpa only [Real.norm_eq_abs, Measure.real, volume_cell, ENNReal.toReal_one, mul_one] using hb
535
536/-- Ordinary integrability supplies the reference tails used above. -/
537theorem integral_compl_closedBall_tendsto_zero {f : (ι → ℝ) → ℝ} (hf : Integrable f) :
538 Tendsto (fun n : ℕ ↦ ∫ x in (Metric.closedBall 0 (n : ℝ))ᶜ, f x) atTop (𝓝 0) := by
539 have ht := tendsto_setIntegral_of_antitone
540 (fun n : ℕ ↦ (Metric.isClosed_closedBall (x := (0 : ι → ℝ)) (ε := (n : ℝ))).measurableSet.compl)
541 (show Antitone (fun n : ℕ ↦ (Metric.closedBall (0 : ι → ℝ) (n : ℝ))ᶜ) by
542 intro m n hmn
543 exact Set.compl_subset_compl.mpr (Metric.closedBall_subset_closedBall (by exact_mod_cast hmn)))
544 ⟨0, hf.integrableOn⟩
545 have hempty : (⋂ n : ℕ, (Metric.closedBall (0 : ι → ℝ) (n : ℝ))ᶜ) = ∅ := by
546 rw [← Set.compl_iUnion, Metric.iUnion_closedBall_nat, Set.compl_univ]
547 simpa only [hempty, setIntegral_empty] using ht
548
549/-- Shrinking-cell averaging converges in `L¹` for every continuous,
550nonnegative integrable density, uniformly over every translation of the
551lattice. No Poincaré estimate or averaging-limit premise is required. -/
552theorem scaledCellAverage_l1_tendsto_uniform_translation
553 {f : (ι → ℝ) → ℝ} (hf : Integrable f) (hf0 : ∀ x, 0 ≤ f x) (hfc : Continuous f)
554 (h : ℕ → ℝ) (hh : ∀ n, 0 < h n) (hlim : Tendsto h atTop (𝓝 0)) :
555 ∀ ε, 0 < ε → ∀ᶠ n in atTop, ∀ a : ι → ℝ,
556 (∫ x, |scaledCellAverage (h n) a f x - f x|) < ε := by
557 apply density_l1_uniform_of_local_and_tails volume
558 (fun n a ↦ scaledCellAverage (h n) a f) (fun _ : ι → ℝ ↦ f)
559 (fun n a ↦ integrable_scaledCellAverage (h n) (hh n) a hf) (fun _ ↦ hf)
560 (fun n a ↦ scaledCellAverage_nonneg (h n) (hh n) a hf0) (fun _ ↦ hf0)
561 (fun n a ↦ integral_scaledCellAverage (h n) (hh n) a hf)
562 (fun k : ℕ ↦ Metric.closedBall 0 (k : ℝ))
563 (fun _ ↦ Metric.isClosed_closedBall.measurableSet)
564 (fun k ↦ (isCompact_closedBall (0 : ι → ℝ) (k : ℝ)).measure_ne_top)
565 · intro k ε hε
566 obtain ⟨δ, hδ, hosc⟩ := Metric.uniformContinuousOn_iff.mp
567 ((isCompact_closedBall (0 : ι → ℝ) ((k : ℝ) + 1)).uniformContinuousOn_of_continuous hfc.continuousOn) ε hε
568 filter_upwards [hlim.eventually (gt_mem_nhds hδ), hlim.eventually (gt_mem_nhds zero_lt_one)] with n hn hn1
569 intro a x hx
570 apply scaledCellAverage_error_le (h n) (hh n) a hf x ε
571 intro y hy
572 have hx' : x ∈ Metric.closedBall (0 : ι → ℝ) ((k : ℝ) + 1) :=
573 Metric.closedBall_subset_closedBall (by linarith) hx
574 have hy' : y ∈ Metric.closedBall (0 : ι → ℝ) ((k : ℝ) + 1) := by
575 have hb := dist_triangle y x (0 : ι → ℝ)
576 rw [Metric.mem_closedBall] at hx ⊢
577 linarith
578 simpa only [Real.dist_eq] using (hosc y hy' x hx' (hy.trans_lt hn)).le
579 · intro ε hε
580 have he := (integral_compl_closedBall_tendsto_zero hf).eventually (gt_mem_nhds hε)
581 obtain ⟨k, hk⟩ := he.exists
582 exact ⟨k, fun _ ↦ hk.le⟩
583
584omit [Fintype ι] in
585theorem cast_add_mem_cell_iff (z : ι → ℤ) (y : ι → ℝ) :
586 (fun i ↦ (z i : ℝ) + y i) ∈ cell z ↔ y ∈ cell 0 := by
587 simp only [cell, Set.mem_pi, Set.mem_univ, true_implies, Set.mem_Ico,
588 Pi.zero_apply, Int.cast_zero, zero_sub, zero_add]
589 constructor
590 · intro h i
591 have hi := h i
592 constructor <;> linarith
593 · intro h i
594 have hi := h i
595 constructor <;> linarith
596
597/-- The same cell kernel in the original, undithered lattice coordinates. -/
598theorem roundingPMF_eq_cell_overlap (γ : ℝ) (z w : ι → ℤ) :
599 roundingPMF γ (fun i ↦ (z i : ℝ)) w =
600 volume (((fun x : ι → ℝ ↦ γ • x) ⁻¹' cell w) ∩ cell z) := by
601 rw [roundingPMF_eq_overlap]
602 let a : ι → ℝ := fun i ↦ (z i : ℝ)
603 have heq : ((fun y : ι → ℝ ↦ fun i ↦ γ * ((z i : ℝ) + y i)) ⁻¹' cell w ∩ cell 0) =
604 (fun y : ι → ℝ ↦ a + y) ⁻¹' (((fun x : ι → ℝ ↦ γ • x) ⁻¹' cell w) ∩ cell z) := by
605 ext y
606 change (_ ∧ y ∈ cell 0) ↔ (_ ∧ (fun i ↦ (z i : ℝ) + y i) ∈ cell z)
607 rw [cast_add_mem_cell_iff]
608 rfl
609 rw [heq, measure_preimage_add]
610
611/-- Change of variables for a density restricted to one rounded output cell. -/
612theorem binMass_affineDensity_zero (γ : ℝ) (hγ : 0 < γ)
613 (f : (ι → ℝ) → ℝ) (w : ι → ℤ) :
614 binMass volume round (affineDensity γ 0 f) w =
615 ∫ y in (fun x : ι → ℝ ↦ γ • x) ⁻¹' cell w, f y := by
616 classical
617 let S := (fun x : ι → ℝ ↦ γ • x) ⁻¹' cell w
618 have hS : MeasurableSet S := (measurable_const_smul γ) (measurableSet_cell w)
619 have heq : (cell w).indicator (affineDensity γ 0 f) =
620 affineDensity γ 0 (S.indicator f) := by
621 funext x
622 have hm : γ⁻¹ • x ∈ S ↔ x ∈ cell w := by
623 simp only [S, Set.mem_preimage, smul_smul, mul_inv_cancel₀ hγ.ne', one_smul]
624 by_cases hx : x ∈ cell w
625 · simp only [Set.indicator_of_mem hx, affineDensity, sub_zero,
626 Set.indicator_of_mem (hm.mpr hx)]
627 · simp only [Set.indicator_of_notMem hx, affineDensity, sub_zero,
628 Set.indicator_of_notMem (mt hm.mp hx), mul_zero]
629 rw [binMass, ← cell_eq_fiber, ← integral_indicator (measurableSet_cell w), heq,
630 integral_affineDensity γ hγ 0, integral_indicator hS]
631
632/-- Exact intertwining for arbitrary absolutely summable real label weights:
633the mass of the dilated interpolation in an output cell is the sum of the
634actual randomized transition masses. -/
635theorem binMass_dilated_interpolate (γ : ℝ) (hγ : 0 < γ)
636 {p : (ι → ℤ) → ℝ} (hp : Summable p) (w : ι → ℤ) :
637 binMass volume round (affineDensity γ 0 (interpolate p)) w =
638 ∑' z, p z * (roundingPMF γ (fun i ↦ (z i : ℝ)) w).toReal := by
639 rw [binMass_affineDensity_zero γ hγ]
640 let S := (fun x : ι → ℝ ↦ γ • x) ⁻¹' cell w
641 have hi : Integrable (interpolate p) (volume.restrict S) :=
642 (integrable_interpolate hp).integrableOn
643 have hs := hasSum_integral_iUnion (μ := volume.restrict S) measurableSet_cell cells_disjoint
644 (show IntegrableOn (interpolate p) (⋃ z, cell z) (volume.restrict S) by
645 simpa only [cells_cover, integrableOn_univ] using hi)
646 have heach (z : ι → ℤ) :
647 (∫ x in cell z, interpolate p x ∂volume.restrict S) =
648 p z * (roundingPMF γ (fun i ↦ (z i : ℝ)) w).toReal := by
649 rw [setIntegral_congr_fun (measurableSet_cell z)
650 (fun x hx ↦ interpolate_eq_on_cell p z hx), setIntegral_const,
651 roundingPMF_eq_cell_overlap]
652 simp only [Measure.real, Measure.restrict_apply (measurableSet_cell z), smul_eq_mul,
653 Set.inter_comm, mul_comm, S]
654 simpa only [cells_cover, setIntegral_univ, heach] using hs.tsum_eq.symm
655
656theorem transport_toReal (γ : ℝ) (p : PMF (ι → ℤ)) (w : ι → ℤ) :
657 (transport γ p w).toReal =
658 ∑' z, (p z).toReal * (roundingPMF γ (fun i ↦ (z i : ℝ)) w).toReal := by
659 rw [transport_apply, ENNReal.tsum_toReal_eq
660 (fun z ↦ ENNReal.mul_ne_top (p.apply_ne_top z)
661 ((roundingPMF γ (fun i ↦ (z i : ℝ))).apply_ne_top w))]
662 simp only [ENNReal.toReal_mul]
663
664/-- The manuscript's dilation/averaging identity for the actual randomized
665kernel, before fallback: no supplied Markov law or intertwining premise. -/
666theorem rounding_intertwining (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ)) :
667 cellAverage (affineDensity γ 0 (interpolate (fun z ↦ (p z).toReal))) =
668 interpolate (fun w ↦ (transport γ p w).toReal) := by
669 have hp : Summable (fun z ↦ (p z).toReal) := ENNReal.summable_toReal p.tsum_coe_ne_top
670 have heq : binMass volume round (affineDensity γ 0 (interpolate (fun z ↦ (p z).toReal))) =
671 fun w ↦ (transport γ p w).toReal := by
672 funext w
673 rw [binMass_dilated_interpolate γ hγ hp, transport_toReal]
674 rw [cellAverage, heq]
675
676theorem affinePull_affineDensity (h : ℝ) (hh : h ≠ 0) (a : ι → ℝ)
677 (f : (ι → ℝ) → ℝ) : affinePull h a (affineDensity h a f) = f := by
678 funext x
679 simp only [affinePull, affineDensity, add_sub_cancel_left, smul_smul,
680 inv_mul_cancel₀ hh, one_smul, ← mul_assoc, mul_inv_cancel₀ (pow_ne_zero _ hh), one_mul]
681
682/-- The dilated continuous law, put into the chosen output coordinates. -/
683def preRoundedDensity (h : ℝ) (a : ι → ℝ) (γ : ℝ) (p : PMF (ι → ℤ)) :
684 (ι → ℝ) → ℝ :=
685 affineDensity h a (affineDensity γ 0 (interpolate (fun z ↦ (p z).toReal)))
686
687/-- The actual randomized output law interpolated in the chosen coordinates. -/
688def roundedDensity (h : ℝ) (a : ι → ℝ) (γ : ℝ) (p : PMF (ι → ℤ)) :
689 (ι → ℝ) → ℝ :=
690 affineDensity h a (interpolate (fun z ↦ (transport γ p z).toReal))
691
692theorem rounding_intertwining_scaled (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
693 (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ)) :
694 roundedDensity h a γ p = scaledCellAverage h a (preRoundedDensity h a γ p) := by
695 rw [roundedDensity, ← rounding_intertwining γ hγ, scaledCellAverage,
696 preRoundedDensity, affinePull_affineDensity h hh.ne']
697
698theorem integrable_preRoundedDensity (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
699 (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ)) :
700 Integrable (preRoundedDensity h a γ p) :=
701 integrable_affineDensity h hh a (integrable_affineDensity γ hγ 0
702 (integrable_interpolate (ENNReal.summable_toReal p.tsum_coe_ne_top)))
703
704theorem preRoundedDensity_nonneg (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
705 (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ)) (x : ι → ℝ) :
706 0 ≤ preRoundedDensity h a γ p x := by
707 unfold preRoundedDensity affineDensity interpolate
708 exact mul_nonneg (inv_nonneg.mpr (pow_nonneg hh.le _))
709 (mul_nonneg (inv_nonneg.mpr (pow_nonneg hγ.le _)) ENNReal.toReal_nonneg)
710
711theorem integral_preRoundedDensity (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
712 (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ)) :
713 (∫ x, preRoundedDensity h a γ p x) = 1 := by
714 rw [preRoundedDensity, integral_affineDensity h hh a, integral_affineDensity γ hγ 0,
715 integral_interpolate (ENNReal.summable_toReal p.tsum_coe_ne_top),
716 ← ENNReal.tsum_toReal_eq p.apply_ne_top, p.tsum_coe, ENNReal.toReal_one]
717
718/-- Concrete two-error bound for the actual rounded output. -/
719theorem roundedDensity_l1_comparison (h : ℝ) (hh : 0 < h) (a : ι → ℝ)
720 (γ : ℝ) (hγ : 0 < γ) (p : PMF (ι → ℤ))
721 {g : (ι → ℝ) → ℝ} (hg : Integrable g) :
722 (∫ x, |roundedDensity h a γ p x - g x|) ≤
723 (∫ x, |preRoundedDensity h a γ p x - g x|) +
724 ∫ x, |scaledCellAverage h a g x - g x| := by
725 rw [rounding_intertwining_scaled h hh a γ hγ]
726 have hi := integrable_preRoundedDensity h hh a γ hγ p
727 have hAi := integrable_scaledCellAverage h hh a hi
728 have hAg := integrable_scaledCellAverage h hh a hg
729 have htri : (∫ x, |scaledCellAverage h a (preRoundedDensity h a γ p) x - g x|) ≤
730 (∫ x, |scaledCellAverage h a (preRoundedDensity h a γ p) x - scaledCellAverage h a g x|) +
731 ∫ x, |scaledCellAverage h a g x - g x| := by
732 have hadd := integral_add (hAi.sub hAg).abs (hAg.sub hg).abs
733 simp only [Pi.sub_apply] at hadd
734 rw [← hadd]
735 apply integral_mono (hAi.sub hg).abs ((hAi.sub hAg).abs.add (hAg.sub hg).abs)
736 intro x
737 exact abs_sub_le _ _ _
738 have hc := scaledCellAverage_l1_contraction h hh a hi hg
739 linarith
740
741/-- Gaussian comparison from a continuous normalized reference density and
742an explicit local limit for the dilated input interpolation. In particular,
743there is no Markov-kernel bridge, cell-averaging limit, or output tightness
744hypothesis. The genuinely paper-specific local estimate is `hlocal`.
745
746For the manuscript one takes output mesh `1 / sqrt m`, output translation
747`-sqrt m * p`, raw label dilation `γ = m/n`, and the corresponding dilated
748Gaussian reference density. -/
749theorem roundedDensity_l1_of_local_limit
750 (h γ : ℕ → ℝ) (a : ℕ → ι → ℝ) (p : ℕ → PMF (ι → ℤ))
751 (hh : ∀ n, 0 < h n) (hγ : ∀ n, 0 < γ n) (hlim : Tendsto h atTop (𝓝 0))
752 {g : (ι → ℝ) → ℝ} (hg : Integrable g) (hg0 : ∀ x, 0 ≤ g x)
753 (hgc : Continuous g) (hgmass : (∫ x, g x) = 1)
754 (hlocal : ∀ k δ, 0 < δ → ∀ᶠ n in atTop, ∀ x ∈ Metric.closedBall 0 (k : ℝ),
755 |preRoundedDensity (h n) (a n) (γ n) (p n) x - g x| ≤ δ) :
756 ∀ ε, 0 < ε → ∀ᶠ n in atTop,
757 (∫ x, |roundedDensity (h n) (a n) (γ n) (p n) x - g x|) < ε := by
758 have hsource : ∀ ε, 0 < ε → ∀ᶠ n in atTop,
759 (∫ x, |preRoundedDensity (h n) (a n) (γ n) (p n) x - g x|) < ε := by
760 have hu := density_l1_uniform_of_local_and_tails volume
761 (fun n (_ : Unit) ↦ preRoundedDensity (h n) (a n) (γ n) (p n)) (fun _ : Unit ↦ g)
762 (fun n _ ↦ integrable_preRoundedDensity (h n) (hh n) (a n) (γ n) (hγ n) (p n))
763 (fun _ ↦ hg)
764 (fun n _ ↦ preRoundedDensity_nonneg (h n) (hh n) (a n) (γ n) (hγ n) (p n))
765 (fun _ ↦ hg0)
766 (fun n _ ↦ (integral_preRoundedDensity (h n) (hh n) (a n) (γ n) (hγ n) (p n)).trans hgmass.symm)
767 (fun k : ℕ ↦ Metric.closedBall 0 (k : ℝ))
768 (fun _ ↦ Metric.isClosed_closedBall.measurableSet)
769 (fun k ↦ (isCompact_closedBall (0 : ι → ℝ) (k : ℝ)).measure_ne_top)
770 (fun k δ hδ ↦ (hlocal k δ hδ).mono fun n hn _ ↦ hn)
771 (by
772 intro δ hδ
773 obtain ⟨k, hk⟩ := ((integral_compl_closedBall_tendsto_zero hg).eventually (gt_mem_nhds hδ)).exists
774 exact ⟨k, fun _ ↦ hk.le⟩)
775 intro ε hε
776 exact (hu ε hε).mono fun n hn ↦ hn ()
777 intro ε hε
778 filter_upwards [hsource (ε / 2) (by positivity),
779 scaledCellAverage_l1_tendsto_uniform_translation hg hg0 hgc h hh hlim (ε / 2) (by positivity)] with n hn hnav
780 have hb := roundedDensity_l1_comparison (h n) (hh n) (a n) (γ n) (hγ n) (p n) hg
781 have ha := hnav (a n)
782 linarith
783
784end Cloning.YoungRounding