Offline · exact source
Exact Lean source

GaussianWitness

formalization/Cloning/GaussianWitness.lean

Source hash: 7ca44c0a6c2f298069a697b8f611124c9fd8b9a7e2ebc0690c18aa2c5f772be3

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.GaussianAffinity
2import Mathlib.MeasureTheory.Measure.Lebesgue.Integral
3 
4/-!
5# Concrete classical Gaussian witnesses
6 
7The density-ratio witness in the hybrid converse is an actual bounded positive
8function. Its inverse moment and its translated Gaussian moment are evaluated
9by Lebesgue integration, rather than imposed as model assumptions.
10-/
11 
12noncomputable section
13open MeasureTheory Real
14open scoped BigOperators
15namespace Cloning.GaussianAffinity
16 
17theorem density_pos {a : ℝ} (ha : 0 < a) (x : ℝ) : 0 < density a x := by
18  unfold density
19  positivity
20 
21theorem continuous_density (a : ℝ) : Continuous (density a) := by
22  unfold density
23  fun_prop
24 
25/-- Square root of the ratio of the narrow and broad Gaussian densities. -/
26def witness (a b x : ℝ) : ℝ := Real.sqrt (density a x) / Real.sqrt (density b x)
27 
28theorem witness_pos {a b : ℝ} (ha : 0 < a) (hb : 0 < b) (x : ℝ) :
29    0 < witness a b x :=
30  div_pos (Real.sqrt_pos.mpr (density_pos ha x)) (Real.sqrt_pos.mpr (density_pos hb x))
31 
32theorem continuous_witness {a b : ℝ} (ha : 0 < a) (hb : 0 < b) :
33    Continuous (witness a b) :=
34  (continuous_density a).sqrt.div (continuous_density b).sqrt
35    (fun x => (Real.sqrt_pos.mpr (density_pos hb x)).ne')
36 
37theorem witness_closed {a b : ℝ} (ha : 0 < a) (hb : 0 < b) (x : ℝ) :
38    witness a b x = Real.sqrt (Real.sqrt a / Real.sqrt b) *
39      Real.exp (-((a - b) / 2) * x ^ 2) := by
40  unfold witness
41  rw [sqrt_density, sqrt_density, mul_div_mul_comm,
42    ← Real.sqrt_div (by positivity : 0 ≤ Real.sqrt a / Real.sqrt Real.pi),
43    ← Real.exp_sub]
44  have hp : Real.sqrt Real.pi ≠ 0 := (Real.sqrt_pos.mpr Real.pi_pos).ne'
45  have hratio : (Real.sqrt a / Real.sqrt Real.pi) /
46      (Real.sqrt b / Real.sqrt Real.pi) = Real.sqrt a / Real.sqrt b := by
47    field_simp
48  rw [hratio]
49  congr 2
50  ring
51 
52theorem witness_le {a b : ℝ} (ha : 0 < a) (hb : 0 < b) (hba : b ≤ a) (x : ℝ) :
53    witness a b x ≤ Real.sqrt (Real.sqrt a / Real.sqrt b) := by
54  rw [witness_closed ha hb]
55  apply mul_le_of_le_one_right (Real.sqrt_nonneg _)
56  exact Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (by linarith) (sq_nonneg x))
57 
58theorem density_div_witness {a b : ℝ} (ha : 0 < a) (hb : 0 < b) (x : ℝ) :
59    density a x / witness a b x =
60      Real.sqrt (density a x) * Real.sqrt (density b x) := by
61  unfold witness
62  have hsa : Real.sqrt (density a x) ≠ 0 := (Real.sqrt_pos.mpr (density_pos ha x)).ne'
63  have hsb : Real.sqrt (density b x) ≠ 0 := (Real.sqrt_pos.mpr (density_pos hb x)).ne'
64  field_simp
65  rw [Real.sq_sqrt (density_nonneg a x)]
66 
67theorem integrable_affinity {a b : ℝ} (ha : 0 < a) (hb : 0 < b) :
68    Integrable (fun x => Real.sqrt (density a x) * Real.sqrt (density b x)) := by
69  have heq (x : ℝ) : Real.sqrt (density a x) * Real.sqrt (density b x) =
70      (Real.sqrt (Real.sqrt a / Real.sqrt Real.pi) *
71        Real.sqrt (Real.sqrt b / Real.sqrt Real.pi)) *
72        Real.exp (-((a + b) / 2) * x ^ 2) := by
73    rw [sqrt_density, sqrt_density, mul_mul_mul_comm, ← Real.exp_add]
74    congr 2
75    ring
76  simp_rw [heq]
77  exact (integrable_exp_neg_mul_sq (by positivity : 0 < (a + b) / 2)).const_mul _
78 
79theorem integrable_density_div_witness {a b : ℝ} (ha : 0 < a) (hb : 0 < b) :
80    Integrable (fun x => density a x / witness a b x) := by
81  simp_rw [density_div_witness ha hb]
82  exact integrable_affinity ha hb
83 
84theorem integral_density_div_witness {a b : ℝ} (ha : 0 < a) (hb : 0 < b) :
85    (∫ x, density a x / witness a b x) =
86      Real.sqrt (2 * Real.sqrt a * Real.sqrt b / (a + b)) := by
87  simp_rw [density_div_witness ha hb]
88  exact integral_sqrt_density_mul ha hb
89 
90/-- Completing the square with an arbitrary translation and linear gain. -/
91theorem integral_gaussian_translate {a c r v : ℝ} (ha : 0 < a) (hc : 0 ≤ c) :
92    (∫ h : ℝ, Real.exp (-a * h ^ 2 - c * (v + r * h) ^ 2)) =
93      Real.exp (-(a * c / (a + c * r ^ 2)) * v ^ 2) *
94        Real.sqrt (Real.pi / (a + c * r ^ 2)) := by
95  have hA : 0 < a + c * r ^ 2 := add_pos_of_pos_of_nonneg ha (mul_nonneg hc (sq_nonneg r))
96  have heq (h : ℝ) : -a * h ^ 2 - c * (v + r * h) ^ 2 =
97      -(a * c / (a + c * r ^ 2)) * v ^ 2 +
98        -(a + c * r ^ 2) * (h + c * r * v / (a + c * r ^ 2)) ^ 2 := by
99    field_simp
100    <;> ring
101  simp_rw [heq, Real.exp_add]
102  rw [integral_const_mul,
103    integral_add_right_eq_self (fun h : ℝ => Real.exp (-(a + c * r ^ 2) * h ^ 2)),
104    integral_gaussian]
105 
106theorem witness_dilation_closed {a g : ℝ} (ha : 0 < a) (hg : 0 < g) (x : ℝ) :
107    witness a (a / g) x = Real.sqrt (Real.sqrt g) *
108      Real.exp (-((a - a / g) / 2) * x ^ 2) := by
109  rw [witness_closed ha (div_pos ha hg), Real.sqrt_div ha.le]
110  have hs : Real.sqrt a ≠ 0 := (Real.sqrt_pos.mpr ha).ne'
111  have hr : Real.sqrt a / (Real.sqrt a / Real.sqrt g) = Real.sqrt g := by
112    field_simp
113  rw [hr]
114 
115theorem dilation_prefactor {a g : ℝ} (ha : 0 < a) (hg : 1 ≤ g) :
116    Real.sqrt (Real.sqrt g) * (Real.sqrt a / Real.sqrt Real.pi) *
117      Real.sqrt (Real.pi / (a + (a - a / g) / 2 * (Real.sqrt g) ^ 2)) =
118      Real.sqrt (Cloning.Thermal.classicalBase g) := by
119  have hg0 : 0 < g := lt_of_lt_of_le zero_lt_one hg
120  have hc : 0 ≤ (a - a / g) / 2 := by
121    have : a / g ≤ a := (div_le_iff₀ hg0).mpr (by nlinarith)
122    linarith
123  have hA : 0 < a + (a - a / g) / 2 * (Real.sqrt g) ^ 2 := by positivity
124  have hpi : Real.sqrt Real.pi ≠ 0 := (Real.sqrt_pos.mpr Real.pi_pos).ne'
125  have heq : a + (a - a / g) / 2 * (Real.sqrt g) ^ 2 = a * (1 + g) / 2 := by
126    rw [Real.sq_sqrt hg0.le]
127    field_simp
128    <;> ring
129  apply (sq_eq_sq₀ (by positivity) (Real.sqrt_nonneg _)).mp
130  rw [mul_pow, mul_pow, div_pow, Real.sq_sqrt (Real.sqrt_nonneg g),
131    Real.sq_sqrt ha.le, Real.sq_sqrt Real.pi_pos.le,
132    Real.sq_sqrt (div_pos Real.pi_pos hA).le,
133    Real.sq_sqrt (Cloning.Thermal.classicalBase_pos hg0).le, heq]
134  unfold Cloning.Thermal.classicalBase
135  field_simp
136  <;> ring
137 
138/-- The classical translation identity used to bound the weighted output mass. -/
139theorem integral_density_translated_witness {a g : ℝ}
140    (ha : 0 < a) (hg : 1 ≤ g) (v : ℝ) :
141    (∫ h : ℝ, density a h * witness a (a / g) (v + Real.sqrt g * h)) =
142      Real.sqrt (Cloning.Thermal.classicalBase g) *
143        Real.exp (-(a * (g - 1) / (g * (1 + g))) * v ^ 2) := by
144  have hg0 : 0 < g := lt_of_lt_of_le zero_lt_one hg
145  have hc : 0 ≤ (a - a / g) / 2 := by
146    have : a / g ≤ a := (div_le_iff₀ hg0).mpr (by nlinarith)
147    linarith
148  have heq (h : ℝ) : density a h * witness a (a / g) (v + Real.sqrt g * h) =
149      (Real.sqrt (Real.sqrt g) * (Real.sqrt a / Real.sqrt Real.pi)) *
150      Real.exp (-a * h ^ 2 - (a - a / g) / 2 * (v + Real.sqrt g * h) ^ 2) := by
151    rw [witness_dilation_closed ha hg0, density]
152    rw [mul_mul_mul_comm, ← Real.exp_add]
153    ring_nf
154  simp_rw [heq]
155  rw [integral_const_mul, integral_gaussian_translate ha hc]
156  rw [← mul_assoc, mul_right_comm _ (Real.exp _), dilation_prefactor ha hg]
157  congr 2
158  rw [Real.sq_sqrt hg0.le]
159  have hA : a + (a - a / g) / 2 * g = a * (1 + g) / 2 := by
160    field_simp
161    <;> ring
162  rw [hA]
163  field_simp
164  <;> ring
165 
166theorem integral_density_translated_witness_le {a g : ℝ}
167    (ha : 0 < a) (hg : 1 ≤ g) (v : ℝ) :
168    (∫ h : ℝ, density a h * witness a (a / g) (v + Real.sqrt g * h)) ≤
169      Real.sqrt (Cloning.Thermal.classicalBase g) := by
170  rw [integral_density_translated_witness ha hg]
171  apply mul_le_of_le_one_right (Real.sqrt_nonneg _)
172  apply Real.exp_le_one_iff.mpr
173  have hg0 : 0 < g := lt_of_lt_of_le zero_lt_one hg
174  exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr
175    (div_nonneg (mul_nonneg ha.le (sub_nonneg.mpr hg)) (by positivity))) (sq_nonneg v)
176 
177variable {ι : Type*} [Fintype ι]
178 
179def productWitness (a b : ι → ℝ) (x : ι → ℝ) : ℝ := ∏ i, witness (a i) (b i) (x i)
180 
181theorem integrable_productDensity (a : ι → ℝ) (ha : ∀ i, 0 < a i) :
182    Integrable (productDensity a) :=
183  Integrable.fintype_prod (fun i => integrable_density (ha i))
184 
185theorem productWitness_pos (a b : ι → ℝ) (ha : ∀ i, 0 < a i) (hb : ∀ i, 0 < b i)
186    (x : ι → ℝ) : 0 < productWitness a b x :=
187  Finset.prod_pos (fun i _ => witness_pos (ha i) (hb i) (x i))
188 
189theorem continuous_productWitness (a b : ι → ℝ)
190    (ha : ∀ i, 0 < a i) (hb : ∀ i, 0 < b i) : Continuous (productWitness a b) := by
191  unfold productWitness
192  exact continuous_finset_prod _ (fun i _ => (continuous_witness (ha i) (hb i)).comp
193    (continuous_apply i))
194 
195theorem productWitness_le (a b : ι → ℝ) (ha : ∀ i, 0 < a i) (hb : ∀ i, 0 < b i)
196    (hba : ∀ i, b i ≤ a i) (x : ι → ℝ) :
197    productWitness a b x ≤ ∏ i, Real.sqrt (Real.sqrt (a i) / Real.sqrt (b i)) :=
198  Finset.prod_le_prod (fun i _ => (witness_pos (ha i) (hb i) (x i)).le)
199    (fun i _ => witness_le (ha i) (hb i) (hba i) (x i))
200 
201theorem integrable_productDensity_div_witness (a b : ι → ℝ)
202    (ha : ∀ i, 0 < a i) (hb : ∀ i, 0 < b i) :
203    Integrable (fun x => productDensity a x / productWitness a b x) := by
204  simp_rw [productDensity, productWitness, ← Finset.prod_div_distrib]
205  exact Integrable.fintype_prod (fun i => integrable_density_div_witness (ha i) (hb i))
206 
207theorem integral_productDensity_div_witness (a : ι → ℝ) (ha : ∀ i, 0 < a i)
208    {g : ℝ} (hg : 0 < g) :
209    (∫ x, productDensity a x / productWitness a (fun i => a i / g) x) =
210      Cloning.Thermal.classicalBase g ^ ((Fintype.card ι : ℝ) / 2) := by
211  have heq (x : ι → ℝ) :
212      productDensity a x / productWitness a (fun i => a i / g) x =
213      Real.sqrt (productDensity a x) * Real.sqrt (productDensity (fun i => a i / g) x) := by
214    simp only [productDensity, productWitness, ← Finset.prod_div_distrib]
215    simp_rw [density_div_witness (ha _) (div_pos (ha _) hg)]
216    rw [Finset.prod_mul_distrib, Real.sqrt_prod _ (fun i _ => density_nonneg _ _),
217      Real.sqrt_prod _ (fun i _ => density_nonneg _ _)]
218  simp_rw [heq]
219  exact integral_product_dilation a ha hg
220 
221theorem integrable_translated_witness {a g : ℝ}
222    (ha : 0 < a) (hg : 1 ≤ g) (v : ℝ) :
223    Integrable (fun h : ℝ => density a h * witness a (a / g) (v + Real.sqrt g * h)) := by
224  have hg0 : 0 < g := lt_of_lt_of_le zero_lt_one hg
225  have hba : a / g ≤ a := (div_le_iff₀ hg0).mpr (by nlinarith)
226  apply (integrable_density ha).mul_bdd
227    (((continuous_witness ha (div_pos ha hg0)).comp (by fun_prop)).aestronglyMeasurable)
228  exact Filter.Eventually.of_forall fun h => by
229    dsimp only [Function.comp_apply]
230    rw [Real.norm_eq_abs, abs_of_pos (witness_pos ha (div_pos ha hg0) _)]
231    exact witness_le ha (div_pos ha hg0) hba _
232 
233theorem integrable_product_translated_witness (a : ι → ℝ) (ha : ∀ i, 0 < a i)
234    {g : ℝ} (hg : 1 ≤ g) (v : ι → ℝ) :
235    Integrable (fun h : ι → ℝ => productDensity a h *
236      productWitness a (fun i => a i / g) (fun i => v i + Real.sqrt g * h i)) := by
237  simp only [productDensity, productWitness, ← Finset.prod_mul_distrib]
238  exact Integrable.fintype_prod (fun i => integrable_translated_witness (ha i) hg (v i))
239 
240/-- The sharp Gaussian translation bound in every finite classical dimension,
241including the zero-dimensional register. -/
242theorem integral_product_translated_witness_le (a : ι → ℝ) (ha : ∀ i, 0 < a i)
243    {g : ℝ} (hg : 1 ≤ g) (v : ι → ℝ) :
244    (∫ h : ι → ℝ, productDensity a h *
245      productWitness a (fun i => a i / g) (fun i => v i + Real.sqrt g * h i)) ≤
246      Cloning.Thermal.classicalBase g ^ ((Fintype.card ι : ℝ) / 2) := by
247  simp only [productDensity, productWitness, ← Finset.prod_mul_distrib]
248  rw [integral_fintype_prod_volume_eq_prod
249    (fun i t => density (a i) t * witness (a i) (a i / g) (v i + Real.sqrt g * t))]
250  calc
251    _ ≤ ∏ _i : ι, Real.sqrt (Cloning.Thermal.classicalBase g) := by
252      apply Finset.prod_le_prod
253      · intro i _
254        exact integral_nonneg fun h => mul_nonneg (density_nonneg _ _)
255          (witness_pos (ha i) (div_pos (ha i) (lt_of_lt_of_le zero_lt_one hg)) _).le
256      · intro i _
257        exact integral_density_translated_witness_le (ha i) hg (v i)
258    _ = _ := by
259      rw [Finset.prod_const, Finset.card_univ, Real.sqrt_eq_rpow,
260        ← Real.rpow_mul_natCast (Cloning.Thermal.classicalBase_pos
261          (lt_of_lt_of_le zero_lt_one hg)).le]
262      congr 1
263      ring
264 
265end Cloning.GaussianAffinity