Offline · exact source
Exact Lean source

Thermal

formalization/Cloning/Thermal.lean

Source hash: d3dc50c83b60b9e7a734b11aed79064d33bbdf3b44b9b210f093f1c94e0b9a91

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: Physical problem

Declarations in this module
definition Cloning.Thermal.geometricdefinition Cloning.Thermal.fidelitydefinition Cloning.Thermal.amplifieddefinition Cloning.Thermal.pctdefinition Cloning.Thermal.photonMeantheorem Cloning.Thermal.geometric_nonnegtheorem Cloning.Thermal.geometric_hasSumtheorem Cloning.Thermal.sqrt_nat_powtheorem Cloning.Thermal.affinity_termtheorem Cloning.Thermal.affinity_hasSumtheorem Cloning.Thermal.affinity_tsumtheorem Cloning.Thermal.fidelity_postheorem Cloning.Thermal.fidelity_sqtheorem Cloning.Thermal.fidelity_le_onetheorem Cloning.Thermal.fidelity_sq_strict_auxtheorem Cloning.Thermal.fidelity_strictAnti_righttheorem Cloning.Thermal.amplified_eqtheorem Cloning.Thermal.lt_amplifiedtheorem Cloning.Thermal.amplified_lt_onetheorem Cloning.Thermal.amplified_nonnegtheorem Cloning.Thermal.pct_denominator_postheorem Cloning.Thermal.amplified_lt_pcttheorem Cloning.Thermal.pct_lt_onetheorem Cloning.Thermal.amplified_photonMeantheorem Cloning.Thermal.pct_photonMeantheorem Cloning.Thermal.pct_excess_photonMeantheorem Cloning.Thermal.pct_fidelity_lt_amplifieddefinition Cloning.Thermal.modeFactortheorem Cloning.Thermal.fidelity_amplified_unrationalizedtheorem Cloning.Thermal.fidelity_amplified_eq_modeFactortheorem Cloning.Thermal.modeFactor_postheorem Cloning.Thermal.modeFactor_le_onetheorem Cloning.Thermal.modeFactor_continuousAttheorem Cloning.Thermal.pct_fidelity_lt_modeFactordefinition Cloning.Thermal.classicalBasetheorem Cloning.Thermal.classicalBase_postheorem Cloning.Thermal.classicalBase_le_onetheorem Cloning.Thermal.classicalBase_lt_onetheorem Cloning.Thermal.classicalBase_strictAntitheorem Cloning.Thermal.pct_classicalBase_ltdefinition Cloning.Thermal.witnesstheorem Cloning.Thermal.geometric_postheorem Cloning.Thermal.witness_postheorem Cloning.Thermal.witness_closedtheorem Cloning.Thermal.witness_strictAntitheorem Cloning.Thermal.witness_boundedtheorem Cloning.Thermal.witness_tendsto_zerotheorem Cloning.Thermal.witness_weighted_termtheorem Cloning.Thermal.witness_inverse_termtheorem Cloning.Thermal.witness_moment_hasSumtheorem Cloning.Thermal.witness_inverse_moment_hasSumtheorem Cloning.Thermal.hasSum_fin_producttheorem Cloning.Thermal.multimode_geometric_hasSumtheorem Cloning.Thermal.multimode_affinity_hasSumtheorem Cloning.Thermal.multimode_affinity_of_product_lawstheorem Cloning.Thermal.multimode_witness_envelopetheorem Cloning.Thermal.multimode_witness_tendsto_zerotheorem Cloning.Thermal.multimode_witness_moment_hasSum
1import Mathlib.Analysis.SpecificLimits.Basic
2import Mathlib.Analysis.Normed.Ring.InfiniteSum
3import Mathlib.Algebra.BigOperators.Fin
4import Mathlib.Data.Real.Sqrt
5import Mathlib.Tactic.FieldSimp
6import Mathlib.Tactic.Linarith
7import Mathlib.Tactic.Ring
8import Mathlib.Tactic.Positivity
9 
10/-!
11# Thermal scalar calculations from `cloning.tex`
12 
13These are statements about geometric probability distributions and real scalar
14formulas.  Identification with diagonal quantum states is not claimed here.
15-/
16 
17noncomputable section
18 
19namespace Cloning.Thermal
20 
21/-- Number probabilities of a one-mode thermal state. -/
22def geometric (q : ℝ) (n : ℕ) : ℝ := (1 - q) * q ^ n
23 
24/-- Root fidelity of two geometric distributions in closed form. -/
25def fidelity (q x : ℝ) : ℝ :=
26  Real.sqrt ((1 - q) * (1 - x)) / (1 - Real.sqrt (q * x))
27 
28/-- Thermal parameter after quantum-limited amplification. -/
29def amplified (g q : ℝ) : ℝ := 1 - (1 - q) / g
30 
31/-- Thermal parameter in the purify-clone-trace limit. -/
32def pct (g q : ℝ) : ℝ := (g - 1 + g * q) / (g + (g - 1) * q)
33 
34/-- Mean photon number of a geometric distribution. -/
35def photonMean (q : ℝ) : ℝ := q / (1 - q)
36 
37theorem geometric_nonneg {q : ℝ} (hq0 : 0 ≤ q) (hq1 : q ≤ 1) (n : ℕ) :
38    0 ≤ geometric q n := mul_nonneg (sub_nonneg.mpr hq1) (pow_nonneg hq0 n)
39 
40theorem geometric_hasSum {q : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1) :
41    HasSum (geometric q) 1 := by
42  simpa [geometric, ne_of_gt (sub_pos.mpr hq1)] using
43    (hasSum_geometric_of_lt_one hq0 hq1).mul_left (1 - q)
44 
45theorem sqrt_nat_pow {q : ℝ} (hq : 0 ≤ q) (n : ℕ) :
46    Real.sqrt (q ^ n) = Real.sqrt q ^ n := by
47  induction n with
48  | zero => simp
49  | succ n ih => rw [pow_succ, Real.sqrt_mul (pow_nonneg hq n), ih, pow_succ]
50 
51theorem affinity_term {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
52    (hx0 : 0 ≤ x) (hx1 : x < 1) (n : ℕ) :
53    Real.sqrt (geometric q n * geometric x n) =
54      Real.sqrt ((1 - q) * (1 - x)) * Real.sqrt (q * x) ^ n := by
55  have he : geometric q n * geometric x n = (1 - q) * (1 - x) * (q * x) ^ n := by
56    simp only [geometric, mul_pow]
57    ring
58  rw [he, Real.sqrt_mul (mul_nonneg (sub_nonneg.mpr hq1.le) (sub_nonneg.mpr hx1.le)), sqrt_nat_pow (mul_nonneg hq0 hx0)]
59 
60theorem affinity_hasSum {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
61    (hx0 : 0 ≤ x) (hx1 : x < 1) :
62    HasSum (fun n => Real.sqrt (geometric q n * geometric x n)) (fidelity q x) := by
63  have hqx : q * x < 1 := mul_lt_one_of_nonneg_of_lt_one_right hq1.le hx0 hx1
64  have hs : Real.sqrt (q * x) < 1 := by
65    rw [Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]
66    simpa using hqx
67  simp_rw [affinity_term hq0 hq1 hx0 hx1]
68  simpa [fidelity, div_eq_mul_inv] using
69    (hasSum_geometric_of_lt_one (Real.sqrt_nonneg _) hs).mul_left
70      (Real.sqrt ((1 - q) * (1 - x)))
71 
72theorem affinity_tsum {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
73    (hx0 : 0 ≤ x) (hx1 : x < 1) :
74    (∑' n, Real.sqrt (geometric q n * geometric x n)) = fidelity q x :=
75  (affinity_hasSum hq0 hq1 hx0 hx1).tsum_eq
76 
77theorem fidelity_pos {q x : ℝ} (_hq0 : 0 ≤ q) (hq1 : q < 1)
78    (hx0 : 0 ≤ x) (hx1 : x < 1) : 0 < fidelity q x := by
79  have hqx : q * x < 1 := mul_lt_one_of_nonneg_of_lt_one_right hq1.le hx0 hx1
80  have hs : Real.sqrt (q * x) < 1 := by
81    rw [Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]
82    simpa using hqx
83  unfold fidelity
84  exact div_pos (Real.sqrt_pos.2 (mul_pos (sub_pos.mpr hq1) (sub_pos.mpr hx1)))
85    (sub_pos.mpr hs)
86 
87theorem fidelity_sq {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
88    (_hx0 : 0 ≤ x) (hx1 : x < 1) :
89    fidelity q x ^ 2 = (1 - q) * (1 - x) / (1 - Real.sqrt q * Real.sqrt x) ^ 2 := by
90  unfold fidelity
91  rw [div_pow, Real.sq_sqrt (mul_nonneg (sub_nonneg.mpr hq1.le) (sub_nonneg.mpr hx1.le)), Real.sqrt_mul hq0]
92 
93theorem fidelity_le_one {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
94    (hx0 : 0 ≤ x) (hx1 : x < 1) : fidelity q x ≤ 1 := by
95  have hprod : q * x < 1 := mul_lt_one_of_nonneg_of_lt_one_right hq1.le hx0 hx1
96  have hsqrt : Real.sqrt q * Real.sqrt x < 1 := by
97    rw [← Real.sqrt_mul hq0, Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]
98    simpa using hprod
99  have hsq : (Real.sqrt q * Real.sqrt x) ^ 2 = q * x := by
100    rw [mul_pow, Real.sq_sqrt hq0, Real.sq_sqrt hx0]
101  have hnum : (1 - q) * (1 - x) ≤ (1 - Real.sqrt q * Real.sqrt x) ^ 2 := by
102    nlinarith [Real.sq_sqrt hq0, Real.sq_sqrt hx0,
103      sq_nonneg (Real.sqrt q - Real.sqrt x)]
104  have hf : fidelity q x ^ 2 ≤ 1 := by
105    rw [fidelity_sq hq0 hq1 hx0 hx1]
106    exact (div_le_one (sq_pos_of_pos (sub_pos.mpr hsqrt))).mpr hnum
107  nlinarith
108 
109/-- Algebra behind strict decrease of thermal fidelity beyond its maximum. -/
110theorem fidelity_sq_strict_aux {a b c : ℝ} (ha : 0 ≤ a) (hab : a < b)
111    (hbc : b < c) (hc : c < 1) :
112    (1 - a ^ 2) * (1 - c ^ 2) / (1 - a * c) ^ 2 <
113      (1 - a ^ 2) * (1 - b ^ 2) / (1 - a * b) ^ 2 := by
114  have hb : 0 ≤ b := le_trans ha hab.le
115  have hc0 : 0 ≤ c := le_trans hb hbc.le
116  have ha1 : a < 1 := lt_trans hab (lt_trans hbc hc)
117  have hab1 : a * b < 1 := mul_lt_one_of_nonneg_of_lt_one_right ha1.le hb (lt_trans hbc hc)
118  have hac1 : a * c < 1 := mul_lt_one_of_nonneg_of_lt_one_right ha1.le hc0 hc
119  have ha2 : 0 < 1 - a ^ 2 := by nlinarith
120  apply (div_lt_div_iff₀ (sq_pos_of_pos (sub_pos.mpr hac1))
121    (sq_pos_of_pos (sub_pos.mpr hab1))).mpr
122  have hid :
123      (1 - a ^ 2) * (1 - b ^ 2) * (1 - a * c) ^ 2 -
124        (1 - a ^ 2) * (1 - c ^ 2) * (1 - a * b) ^ 2 =
125      (1 - a ^ 2) * (c - b) *
126        ((b - a) * (1 - a * c) + (c - a) * (1 - a * b)) := by ring
127  have hp : 0 < (1 - a ^ 2) * (c - b) *
128      ((b - a) * (1 - a * c) + (c - a) * (1 - a * b)) := by
129    apply mul_pos (mul_pos ha2 (sub_pos.mpr hbc))
130    exact add_pos (mul_pos (sub_pos.mpr hab) (sub_pos.mpr hac1))
131      (mul_pos (sub_pos.mpr (lt_trans hab hbc)) (sub_pos.mpr hab1))
132  linarith
133 
134theorem fidelity_strictAnti_right {q x y : ℝ} (hq0 : 0 ≤ q)
135    (hqx : q < x) (hxy : x < y) (hy1 : y < 1) :
136    fidelity q y < fidelity q x := by
137  have hx0 : 0 ≤ x := le_trans hq0 hqx.le
138  have hy0 : 0 ≤ y := le_trans hx0 hxy.le
139  have hx1 : x < 1 := lt_trans hxy hy1
140  have hq1 : q < 1 := lt_trans hqx hx1
141  have hs := fidelity_sq_strict_aux (Real.sqrt_nonneg q)
142    (Real.sqrt_lt_sqrt hq0 hqx) (Real.sqrt_lt_sqrt hx0 hxy)
143    (show Real.sqrt y < 1 by rw [Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]; simpa)
144  rw [Real.sq_sqrt hq0, Real.sq_sqrt hx0, Real.sq_sqrt hy0] at hs
145  rw [← fidelity_sq hq0 hq1 hy0 hy1, ← fidelity_sq hq0 hq1 hx0 hx1] at hs
146  have hp := fidelity_pos hq0 hq1 hy0 hy1
147  have hp' := fidelity_pos hq0 hq1 hx0 hx1
148  nlinarith
149 
150theorem amplified_eq {g q : ℝ} (hg : g ≠ 0) :
151    amplified g q = (g - 1 + q) / g := by
152  unfold amplified
153  field_simp
154  ring
155 
156theorem lt_amplified {g q : ℝ} (hg : 1 < g) (hq : q < 1) :
157    q < amplified g q := by
158  rw [amplified_eq (by linarith)]
159  apply (lt_div_iff₀ (by linarith : 0 < g)).mpr
160  nlinarith [mul_pos (by linarith : 0 < g - 1) (by linarith : 0 < 1 - q)]
161 
162theorem amplified_lt_one {g q : ℝ} (hg : 0 < g) (hq : q < 1) :
163    amplified g q < 1 := by
164  unfold amplified
165  have := div_pos (sub_pos.mpr hq) hg
166  linarith
167 
168theorem amplified_nonneg {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
169    0 ≤ amplified g q := le_trans hq0 (lt_amplified hg hq1).le
170 
171theorem pct_denominator_pos {g q : ℝ} (hg : 1 < g) (hq : 0 ≤ q) :
172    0 < g + (g - 1) * q :=
173  add_pos_of_pos_of_nonneg (by linarith) (mul_nonneg (by linarith) hq)
174 
175theorem amplified_lt_pct {g q : ℝ} (hg : 1 < g) (hq0 : 0 < q) (hq1 : q < 1) :
176    amplified g q < pct g q := by
177  rw [amplified_eq (by linarith)]
178  unfold pct
179  apply (div_lt_div_iff₀ (by linarith : 0 < g) (pct_denominator_pos hg hq0.le)).mpr
180  have h := mul_pos (mul_pos (by linarith : 0 < g - 1) hq0) (sub_pos.mpr hq1)
181  nlinarith
182 
183theorem pct_lt_one {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
184    pct g q < 1 := by
185  unfold pct
186  rw [div_lt_one (pct_denominator_pos hg hq0)]
187  nlinarith
188 
189theorem amplified_photonMean {g q : ℝ} (hg : 0 < g) (hq : q < 1) :
190    photonMean (amplified g q) = g * q / (1 - q) + g - 1 := by
191  have hg0 : g ≠ 0 := ne_of_gt hg
192  have hq0 : 1 - q ≠ 0 := ne_of_gt (sub_pos.mpr hq)
193  unfold photonMean amplified
194  field_simp [hg0, hq0]
195  ring
196 
197theorem pct_photonMean {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
198    photonMean (pct g q) = (g - 1 + g * q) / (1 - q) := by
199  have hd := ne_of_gt (pct_denominator_pos hg hq0)
200  have hq := ne_of_gt (sub_pos.mpr hq1)
201  unfold photonMean
202  apply (div_eq_iff (ne_of_gt (sub_pos.mpr (pct_lt_one hg hq0 hq1)))).mpr
203  unfold pct
204  field_simp [hd, hq]
205  ring
206 
207theorem pct_excess_photonMean {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
208    photonMean (pct g q) - photonMean (amplified g q) =
209      (g - 1) * q / (1 - q) := by
210  rw [pct_photonMean hg hq0 hq1, amplified_photonMean (by linarith) hq1]
211  field_simp [ne_of_gt (sub_pos.mpr hq1)]
212  ring
213 
214theorem pct_fidelity_lt_amplified {g q : ℝ} (hg : 1 < g) (hq0 : 0 < q)
215    (hq1 : q < 1) : fidelity q (pct g q) < fidelity q (amplified g q) :=
216  fidelity_strictAnti_right hq0.le (lt_amplified hg hq1)
217    (amplified_lt_pct hg hq0 hq1) (pct_lt_one hg hq0.le hq1)
218 
219/-- The manuscript's rationalized one-mode factor `f_γ(q)`. -/
220def modeFactor (g q : ℝ) : ℝ :=
221  (Real.sqrt g + Real.sqrt (q * (g - 1 + q))) / (g + q)
222 
223theorem fidelity_amplified_unrationalized {g q : ℝ} (hg : 1 < g)
224    (hq0 : 0 ≤ q) (hq1 : q < 1) :
225    fidelity q (amplified g q) =
226      (1 - q) / (Real.sqrt g - Real.sqrt (q * (g - 1 + q))) := by
227  have hg0 : g ≠ 0 := by linarith
228  have hs : Real.sqrt g ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by linarith))
229  have ht : 0 ≤ 1 - q := sub_nonneg.mpr hq1.le
230  have hn : Real.sqrt ((1 - q) * (1 - amplified g q)) = (1 - q) / Real.sqrt g := by
231    have he : (1 - q) * (1 - amplified g q) = (1 - q) ^ 2 / g := by
232      unfold amplified
233      ring
234    rw [he, Real.sqrt_div (sq_nonneg _), Real.sqrt_sq ht]
235  have hr : Real.sqrt (q * amplified g q) =
236      Real.sqrt (q * (g - 1 + q)) / Real.sqrt g := by
237    rw [amplified_eq hg0, ← mul_div_assoc,
238      Real.sqrt_div (mul_nonneg hq0 (by linarith))]
239  unfold fidelity
240  rw [hn, hr]
241  field_simp [hs]
242 
243theorem fidelity_amplified_eq_modeFactor {g q : ℝ} (hg : 1 < g)
244    (hq0 : 0 ≤ q) (hq1 : q < 1) :
245    fidelity q (amplified g q) = modeFactor g q := by
246  have hg0 : 0 < g := by linarith
247  have hsum : 0 < g + q := by linarith
248  have hrad : 0 ≤ q * (g - 1 + q) := mul_nonneg hq0 (by linarith)
249  have hradlt : q * (g - 1 + q) < g := by
250    have hp := mul_pos (sub_pos.mpr hq1) hsum
251    nlinarith
252  have hd : 0 < Real.sqrt g - Real.sqrt (q * (g - 1 + q)) :=
253    sub_pos.mpr (Real.sqrt_lt_sqrt hrad hradlt)
254  rw [fidelity_amplified_unrationalized hg hq0 hq1]
255  unfold modeFactor
256  apply (div_eq_div_iff (ne_of_gt hd) (ne_of_gt hsum)).mpr
257  nlinarith [Real.sq_sqrt hg0.le, Real.sq_sqrt hrad]
258 
259theorem modeFactor_pos {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
260    0 < modeFactor g q := by
261  rw [← fidelity_amplified_eq_modeFactor hg hq0 hq1]
262  exact fidelity_pos hq0 hq1 (amplified_nonneg hg hq0 hq1)
263    (amplified_lt_one (by linarith) hq1)
264 
265theorem modeFactor_le_one {g q : ℝ} (hg : 1 < g) (hq0 : 0 ≤ q) (hq1 : q < 1) :
266    modeFactor g q ≤ 1 := by
267  rw [← fidelity_amplified_eq_modeFactor hg hq0 hq1]
268  exact fidelity_le_one hq0 hq1 (amplified_nonneg hg hq0 hq1)
269    (amplified_lt_one (by linarith) hq1)
270 
271theorem modeFactor_continuousAt {g q : ℝ} (hden : g + q ≠ 0) :
272    ContinuousAt (fun z : ℝ × ℝ => modeFactor z.1 z.2) (g, q) := by
273  unfold modeFactor
274  apply ContinuousAt.div
275  · fun_prop
276  · fun_prop
277  · exact hden
278 
279theorem pct_fidelity_lt_modeFactor {g q : ℝ} (hg : 1 < g) (hq0 : 0 < q)
280    (hq1 : q < 1) : fidelity q (pct g q) < modeFactor g q := by
281  rw [← fidelity_amplified_eq_modeFactor hg hq0.le hq1]
282  exact pct_fidelity_lt_amplified hg hq0 hq1
283 
284/-- Base of the equal-mean Gaussian Hellinger affinity. -/
285def classicalBase (c : ℝ) : ℝ := 2 * Real.sqrt c / (1 + c)
286 
287theorem classicalBase_pos {c : ℝ} (hc : 0 < c) : 0 < classicalBase c := by
288  unfold classicalBase
289  positivity
290 
291theorem classicalBase_le_one {c : ℝ} (hc : 0 ≤ c) : classicalBase c ≤ 1 := by
292  unfold classicalBase
293  apply (div_le_one (by linarith : 0 < 1 + c)).mpr
294  nlinarith [Real.sq_sqrt hc, sq_nonneg (Real.sqrt c - 1)]
295 
296theorem classicalBase_lt_one {c : ℝ} (hc : 1 < c) : classicalBase c < 1 := by
297  have hc0 : 0 ≤ c := by linarith
298  have hs : 1 < Real.sqrt c := by
299    simpa using Real.sqrt_lt_sqrt (by norm_num : (0 : ℝ) ≤ 1) hc
300  unfold classicalBase
301  apply (div_lt_one (by linarith : 0 < 1 + c)).mpr
302  nlinarith [Real.sq_sqrt hc0, sq_pos_of_pos (sub_pos.mpr hs)]
303 
304theorem classicalBase_strictAnti {x y : ℝ} (hx : 1 < x) (hxy : x < y) :
305    classicalBase y < classicalBase x := by
306  have hx0 : 0 ≤ x := by linarith
307  have hy0 : 0 ≤ y := by linarith
308  have ha : 1 < Real.sqrt x := by
309    simpa using Real.sqrt_lt_sqrt (by norm_num : (0 : ℝ) ≤ 1) hx
310  have hab : Real.sqrt x < Real.sqrt y := Real.sqrt_lt_sqrt hx0 hxy
311  have hp : 0 < (Real.sqrt y - Real.sqrt x) * (Real.sqrt x * Real.sqrt y - 1) := by
312    apply mul_pos (sub_pos.mpr hab)
313    nlinarith
314  unfold classicalBase
315  apply (div_lt_div_iff₀ (by linarith : 0 < 1 + y) (by linarith : 0 < 1 + x)).mpr
316  nlinarith [Real.sq_sqrt hx0, Real.sq_sqrt hy0]
317 
318theorem pct_classicalBase_lt {g : ℝ} (hg : 1 < g) :
319    classicalBase (2 * g - 1) < classicalBase g :=
320  classicalBase_strictAnti hg (by linarith)
321 
322/-- Eigenvalues of the diagonal fidelity witness. -/
323def witness (q x : ℝ) (n : ℕ) : ℝ :=
324  Real.sqrt (geometric q n) / Real.sqrt (geometric x n)
325 
326theorem geometric_pos {q : ℝ} (hq0 : 0 < q) (hq1 : q < 1) (n : ℕ) :
327    0 < geometric q n := mul_pos (sub_pos.mpr hq1) (pow_pos hq0 n)
328 
329theorem witness_pos {q x : ℝ} (hq0 : 0 < q) (hq1 : q < 1)
330    (hx0 : 0 < x) (hx1 : x < 1) (n : ℕ) : 0 < witness q x n :=
331  div_pos (Real.sqrt_pos.2 (geometric_pos hq0 hq1 n))
332    (Real.sqrt_pos.2 (geometric_pos hx0 hx1 n))
333 
334theorem witness_closed {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
335    (hx0 : 0 ≤ x) (hx1 : x < 1) (n : ℕ) :
336    witness q x n = Real.sqrt ((1 - q) / (1 - x)) * Real.sqrt (q / x) ^ n := by
337  unfold witness geometric
338  rw [Real.sqrt_mul (sub_nonneg.mpr hq1.le), Real.sqrt_mul (sub_nonneg.mpr hx1.le),
339    sqrt_nat_pow hq0, sqrt_nat_pow hx0, Real.sqrt_div (sub_nonneg.mpr hq1.le),
340    Real.sqrt_div hq0, div_pow]
341  ring
342 
343theorem witness_strictAnti {q x : ℝ} (hq0 : 0 < q) (hqx : q < x) (hx1 : x < 1) :
344    StrictAnti (witness q x) := by
345  have hx0 : 0 < x := lt_trans hq0 hqx
346  have hq1 : q < 1 := lt_trans hqx hx1
347  have hr0 : 0 < Real.sqrt (q / x) := Real.sqrt_pos.2 (div_pos hq0 hx0)
348  have hr1 : Real.sqrt (q / x) < 1 := by
349    rw [Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]
350    simpa using (div_lt_one hx0).mpr hqx
351  intro m n hmn
352  rw [witness_closed hq0.le hq1 hx0.le hx1, witness_closed hq0.le hq1 hx0.le hx1]
353  apply mul_lt_mul_of_pos_left (pow_right_strictAnti₀ hr0 hr1 hmn)
354  exact Real.sqrt_pos.2 (div_pos (sub_pos.mpr hq1) (sub_pos.mpr hx1))
355 
356theorem witness_bounded {q x : ℝ} (hq0 : 0 < q) (hqx : q < x) (hx1 : x < 1)
357    (n : ℕ) : witness q x n ≤ Real.sqrt ((1 - q) / (1 - x)) := by
358  have h := (witness_strictAnti hq0 hqx hx1).antitone (Nat.zero_le n)
359  simpa [witness_closed hq0.le (lt_trans hqx hx1) (lt_trans hq0 hqx).le hx1] using h
360 
361theorem witness_tendsto_zero {q x : ℝ} (hq0 : 0 < q) (hqx : q < x) (hx1 : x < 1) :
362    Filter.Tendsto (witness q x) Filter.atTop (nhds 0) := by
363  have hx0 : 0 < x := lt_trans hq0 hqx
364  have hq1 : q < 1 := lt_trans hqx hx1
365  have hr1 : Real.sqrt (q / x) < 1 := by
366    rw [Real.sqrt_lt' (by norm_num : (0 : ℝ) < 1)]
367    simpa using (div_lt_one hx0).mpr hqx
368  have he : witness q x =
369      fun n => Real.sqrt ((1 - q) / (1 - x)) * Real.sqrt (q / x) ^ n := by
370    funext n
371    exact witness_closed hq0.le hq1 hx0.le hx1 n
372  rw [he]
373  simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one (Real.sqrt_nonneg (q / x)) hr1).const_mul
374    (Real.sqrt ((1 - q) / (1 - x)))
375 
376theorem witness_weighted_term {q x : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1)
377    (hx0 : 0 < x) (hx1 : x < 1) (n : ℕ) :
378    geometric x n * witness q x n = Real.sqrt (geometric q n * geometric x n) := by
379  have hp := geometric_pos hx0 hx1 n
380  have hs : Real.sqrt (geometric x n) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 hp)
381  unfold witness
382  rw [Real.sqrt_mul (geometric_nonneg hq0 hq1.le n)]
383  rw [← mul_div_assoc]
384  apply (div_eq_iff hs).mpr
385  calc
386    geometric x n * Real.sqrt (geometric q n) =
387        Real.sqrt (geometric x n) ^ 2 * Real.sqrt (geometric q n) := by
388      rw [Real.sq_sqrt hp.le]
389    _ = _ := by ring
390 
391theorem witness_inverse_term {q x : ℝ} (hq0 : 0 < q) (hq1 : q < 1)
392    (_hx0 : 0 < x) (_hx1 : x < 1) (n : ℕ) :
393    geometric q n / witness q x n = Real.sqrt (geometric q n * geometric x n) := by
394  have hp := geometric_pos hq0 hq1 n
395  have hs : Real.sqrt (geometric q n) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 hp)
396  unfold witness
397  rw [Real.sqrt_mul hp.le, div_div_eq_mul_div]
398  apply (div_eq_iff hs).mpr
399  calc
400    geometric q n * Real.sqrt (geometric x n) =
401        Real.sqrt (geometric q n) ^ 2 * Real.sqrt (geometric x n) := by
402      rw [Real.sq_sqrt hp.le]
403    _ = _ := by ring
404 
405theorem witness_moment_hasSum {q x : ℝ} (hq0 : 0 < q) (hq1 : q < 1)
406    (hx0 : 0 < x) (hx1 : x < 1) :
407    HasSum (fun n => geometric x n * witness q x n) (fidelity q x) := by
408  simp_rw [witness_weighted_term hq0.le hq1 hx0 hx1]
409  exact affinity_hasSum hq0.le hq1 hx0.le hx1
410 
411theorem witness_inverse_moment_hasSum {q x : ℝ} (hq0 : 0 < q) (hq1 : q < 1)
412    (hx0 : 0 < x) (hx1 : x < 1) :
413    HasSum (fun n => geometric q n / witness q x n) (fidelity q x) := by
414  simp_rw [witness_inverse_term hq0 hq1 hx0 hx1]
415  exact affinity_hasSum hq0.le hq1 hx0.le hx1
416 
417/-- An absolutely convergent product-distribution identity, including zero modes. -/
418theorem hasSum_fin_product (s : ℕ) (f : Fin s → ℕ → ℝ) (a : Fin s → ℝ)
419    (hn : ∀ i n, 0 ≤ f i n) (hs : ∀ i, HasSum (f i) (a i)) :
420    HasSum (fun k : Fin s → ℕ => ∏ i, f i (k i)) (∏ i, a i) := by
421  induction s with
422  | zero =>
423    simpa using hasSum_fintype (fun k : Fin 0 → ℕ => ∏ i, f i (k i))
424  | succ s ih =>
425    have ht : HasSum (fun k : Fin s → ℕ => ∏ i : Fin s, f i.succ (k i))
426        (∏ i : Fin s, a i.succ) := ih (fun i => f i.succ) (fun i => a i.succ)
427      (fun i n => hn i.succ n) (fun i => hs i.succ)
428    have hn' : ∀ k : Fin s → ℕ, 0 ≤ ∏ i : Fin s, f i.succ (k i) :=
429      fun k => Finset.prod_nonneg (fun i _ => hn i.succ (k i))
430    have hsum : Summable (fun k : ℕ × (Fin s → ℕ) =>
431        f 0 k.1 * ∏ i : Fin s, f i.succ (k.2 i)) := by
432      apply (summable_prod_of_nonneg (fun k => mul_nonneg (hn 0 k.1) (hn' k.2))).mpr
433      constructor
434      · intro n
435        exact ht.summable.mul_left (f 0 n)
436      · have he : (fun n : ℕ => ∑' k : Fin s → ℕ, f 0 n * ∏ i : Fin s, f i.succ (k i)) =
437            fun n => f 0 n * ∏ i : Fin s, a i.succ := by
438          funext n
439          rw [tsum_mul_left, ht.tsum_eq]
440        rw [he]
441        exact (hs 0).summable.mul_right (∏ i : Fin s, a i.succ)
442    have hm : HasSum (fun k : ℕ × (Fin s → ℕ) =>
443        f 0 k.1 * ∏ i : Fin s, f i.succ (k.2 i)) (a 0 * ∏ i : Fin s, a i.succ) :=
444      HasSum.mul (f := f 0) (g := fun k : Fin s → ℕ => ∏ i : Fin s, f i.succ (k i))
445        (s := a 0) (t := ∏ i : Fin s, a i.succ) (hs 0) ht hsum
446    rw [← (Fin.consEquiv (fun _ : Fin (s + 1) => ℕ)).hasSum_iff]
447    simpa [Fin.prod_univ_succ, Fin.consEquiv, Function.comp_def] using hm
448 
449/-- The product geometric law is a probability distribution. -/
450theorem multimode_geometric_hasSum {s : ℕ} {q : Fin s → ℝ}
451    (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i < 1) :
452    HasSum (fun k : Fin s → ℕ => ∏ i, geometric (q i) (k i)) 1 := by
453  simpa using hasSum_fin_product s (fun i => geometric (q i)) (fun _ => 1)
454    (fun i n => geometric_nonneg (hq0 i) (hq1 i).le n)
455    (fun i => geometric_hasSum (hq0 i) (hq1 i))
456 
457/-- Multiplicativity of thermal affinity, as a convergent series over number tuples. -/
458theorem multimode_affinity_hasSum {s : ℕ} {q x : Fin s → ℝ}
459    (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i < 1)
460    (hx0 : ∀ i, 0 ≤ x i) (hx1 : ∀ i, x i < 1) :
461    HasSum (fun k : Fin s → ℕ =>
462      ∏ i, Real.sqrt (geometric (q i) (k i) * geometric (x i) (k i)))
463      (∏ i, fidelity (q i) (x i)) :=
464  hasSum_fin_product s
465    (fun i n => Real.sqrt (geometric (q i) n * geometric (x i) n))
466    (fun i => fidelity (q i) (x i)) (fun _ _ => Real.sqrt_nonneg _)
467    (fun i => affinity_hasSum (hq0 i) (hq1 i) (hx0 i) (hx1 i))
468 
469theorem multimode_affinity_of_product_laws {s : ℕ} {q x : Fin s → ℝ}
470    (hq0 : ∀ i, 0 ≤ q i) (hq1 : ∀ i, q i < 1)
471    (hx0 : ∀ i, 0 ≤ x i) (hx1 : ∀ i, x i < 1) :
472    HasSum (fun k : Fin s → ℕ => Real.sqrt
473      ((∏ i, geometric (q i) (k i)) * (∏ i, geometric (x i) (k i))))
474      (∏ i, fidelity (q i) (x i)) := by
475  have he : (fun k : Fin s → ℕ => Real.sqrt
476      ((∏ i, geometric (q i) (k i)) * (∏ i, geometric (x i) (k i)))) =
477      fun k => ∏ i, Real.sqrt (geometric (q i) (k i) * geometric (x i) (k i)) := by
478    funext k
479    rw [← Finset.prod_mul_distrib]
480    exact Real.sqrt_prod _ (fun i _ => mul_nonneg
481      (geometric_nonneg (hq0 i) (hq1 i).le (k i))
482      (geometric_nonneg (hx0 i) (hx1 i).le (k i)))
483  rw [he]
484  exact multimode_affinity_hasSum hq0 hq1 hx0 hx1
485 
486/-- A common geometric envelope controls the witness by total occupation. -/
487theorem multimode_witness_envelope {s : ℕ} {q x : Fin s → ℝ} {r : ℝ}
488    (hq0 : ∀ i, 0 < q i) (hqx : ∀ i, q i < x i) (hx1 : ∀ i, x i < 1)
489    (hr : ∀ i, Real.sqrt (q i / x i) ≤ r) (k : Fin s → ℕ) :
490    (∏ i, witness (q i) (x i) (k i)) ≤
491      (∏ i, Real.sqrt ((1 - q i) / (1 - x i))) * r ^ (∑ i, k i) := by
492  calc
493    (∏ i, witness (q i) (x i) (k i)) ≤
494        ∏ i, Real.sqrt ((1 - q i) / (1 - x i)) * r ^ k i := by
495      apply Finset.prod_le_prod
496      · intro i _
497        exact (witness_pos (hq0 i) (lt_trans (hqx i) (hx1 i))
498          (lt_trans (hq0 i) (hqx i)) (hx1 i) (k i)).le
499      · intro i _
500        rw [witness_closed (hq0 i).le (lt_trans (hqx i) (hx1 i))
501          (lt_trans (hq0 i) (hqx i)).le (hx1 i)]
502        exact mul_le_mul_of_nonneg_left
503          (pow_le_pow_left₀ (Real.sqrt_nonneg _) (hr i) (k i)) (Real.sqrt_nonneg _)
504    _ = _ := by rw [Finset.prod_mul_distrib, Finset.prod_pow_eq_pow_sum]
505 
506/-- Along any family escaping in total occupation, a common ratio bound gives
507the vanishing-eigenvalue conclusion needed for compactness of the witness. -/
508theorem multimode_witness_tendsto_zero {s : ℕ} {q x : Fin s → ℝ} {r : ℝ}
509    (hq0 : ∀ i, 0 < q i) (hqx : ∀ i, q i < x i) (hx1 : ∀ i, x i < 1)
510    (hr0 : 0 ≤ r) (hr1 : r < 1) (hr : ∀ i, Real.sqrt (q i / x i) ≤ r)
511    (k : ℕ → Fin s → ℕ)
512    (hk : Filter.Tendsto (fun n => ∑ i, k n i) Filter.atTop Filter.atTop) :
513    Filter.Tendsto (fun n => ∏ i, witness (q i) (x i) (k n i)) Filter.atTop (nhds 0) := by
514  have he := (tendsto_pow_atTop_nhds_zero_of_lt_one hr0 hr1).comp hk
515  have hb : Filter.Tendsto
516      (fun n => (∏ i, Real.sqrt ((1 - q i) / (1 - x i))) * r ^ (∑ i, k n i))
517      Filter.atTop (nhds 0) := by
518    simpa using he.const_mul (∏ i, Real.sqrt ((1 - q i) / (1 - x i)))
519  apply squeeze_zero
520    (fun n => Finset.prod_nonneg (fun i _ =>
521      (witness_pos (hq0 i) (lt_trans (hqx i) (hx1 i))
522        (lt_trans (hq0 i) (hqx i)) (hx1 i) (k n i)).le))
523    (fun n => multimode_witness_envelope hq0 hqx hx1 hr (k n)) hb
524 
525/-- The witness moment identity for any finite number of oscillator modes. -/
526theorem multimode_witness_moment_hasSum {s : ℕ} {q x : Fin s → ℝ}
527    (hq0 : ∀ i, 0 < q i) (hq1 : ∀ i, q i < 1)
528    (hx0 : ∀ i, 0 < x i) (hx1 : ∀ i, x i < 1) :
529    HasSum (fun k : Fin s → ℕ =>
530      ∏ i, geometric (x i) (k i) * witness (q i) (x i) (k i))
531      (∏ i, fidelity (q i) (x i)) := by
532  simp_rw [witness_weighted_term (hq0 _).le (hq1 _) (hx0 _) (hx1 _)]
533  exact multimode_affinity_hasSum (fun i => (hq0 i).le) hq1 (fun i => (hx0 i).le) hx1
534 
535end Cloning.Thermal