Offline · exact source
Exact Lean source

BosonicNumberLaw

formalization/Cloning/BosonicNumberLaw.lean

Source hash: 7d30996110bc5994a1b5fcfba4c8a50b622fab0d766ca077dae36e687bdeb15b

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.BosonicNumberLaw.seededLawdefinition Cloning.BosonicNumberLaw.pgfBasetheorem Cloning.BosonicNumberLaw.seededLaw_nonnegtheorem Cloning.BosonicNumberLaw.seededLaw_pgf_hasSumtheorem Cloning.BosonicNumberLaw.seededLaw_hasSumtheorem Cloning.BosonicNumberLaw.seededLaw_zerotheorem Cloning.BosonicNumberLaw.pgfBase_nonnegtheorem Cloning.BosonicNumberLaw.pgfBase_le_onetheorem Cloning.BosonicNumberLaw.seededLaw_moment_ledefinition Cloning.BosonicNumberLaw.transitiondefinition Cloning.BosonicNumberLaw.thermalOutputtheorem Cloning.BosonicNumberLaw.thermalOutput_eqtheorem Cloning.BosonicNumberLaw.thermalOutput_eq_tsumtheorem Cloning.BosonicNumberLaw.thermalOutput_gaindefinition Cloning.BosonicNumberLaw.productLawdefinition Cloning.BosonicNumberLaw.productTesttheorem Cloning.BosonicNumberLaw.productLaw_nonnegtheorem Cloning.BosonicNumberLaw.productLaw_hasSumtheorem Cloning.BosonicNumberLaw.productLaw_pgf_hasSumtheorem Cloning.BosonicNumberLaw.productLaw_moment_letheorem Cloning.BosonicNumberLaw.productTest_nonnegtheorem Cloning.BosonicNumberLaw.productTest_le_onedefinition Cloning.BosonicNumberLaw.mixtureLawtheorem Cloning.BosonicNumberLaw.mixtureLaw_nonnegtheorem Cloning.BosonicNumberLaw.mixtureJoint_summabletheorem Cloning.BosonicNumberLaw.mixtureLaw_hasSumtheorem Cloning.BosonicNumberLaw.mixtureLaw_pgf_eqtheorem Cloning.BosonicNumberLaw.mixtureLaw_moment_letheorem Cloning.BosonicNumberLaw.seededLaw_witness_hasSumtheorem Cloning.BosonicNumberLaw.witness_pgfBase_eq_fidelitytheorem Cloning.BosonicNumberLaw.seededLaw_witness_moment_letheorem Cloning.BosonicNumberLaw.mixtureLaw_witness_moment_le
1import Cloning.Thermal
2import Mathlib.Analysis.SpecificLimits.Normed
3 
4/-!
5# Seeded bosonic number laws and thermal amplification
6 
7The negative-binomial coefficients are normalized and their generating
8function is evaluated as a convergent series. Finite binomial convolution
9identifies the amplified thermal input law. These are exact scalar formulas;
10the separate amplifier module supplies the operator realization.
11-/
12 
13noncomputable section
14open scoped BigOperators Topology
15 
16namespace Cloning.BosonicNumberLaw
17 
18set_option backward.isDefEq.respectTransparency false
19set_option maxHeartbeats 600000
20 
21/-- Number probabilities for vacuum signal and an idler seed of `l` quanta. -/
22def seededLaw (r : ℝ) (l k : ℕ) : ℝ :=
23  ((l + k).choose l : ℝ) * (1 - r) ^ (l + 1) * r ^ k
24 
25/-- The geometric probability generating function. -/
26def pgfBase (r z : ℝ) : ℝ := (1 - r) / (1 - r * z)
27 
28theorem seededLaw_nonneg {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) (l k : ℕ) :
29    0 ≤ seededLaw r l k := by
30  unfold seededLaw
31  exact mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg (by linarith) _))
32    (pow_nonneg hr0 _)
33 
34/-- Exact seeded number generating function, including `z=1` and zero noise. -/
35theorem seededLaw_pgf_hasSum {r z : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1)
36    (hz0 : 0 ≤ z) (hz1 : z ≤ 1) (l : ℕ) :
37    HasSum (fun k ↦ seededLaw r l k * z ^ k) (pgfBase r z ^ (l + 1)) := by
38  have hrz0 : 0 ≤ r * z := mul_nonneg hr0 hz0
39  have hrz1 : r * z < 1 := (mul_le_of_le_one_right hr0 hz1).trans_lt hr1
40  have hnorm : ‖r * z‖ < 1 := by simpa only [Real.norm_eq_abs, abs_of_nonneg hrz0]
41  have hs := (hasSum_choose_mul_geometric_of_norm_lt_one l hnorm).mul_left ((1 - r) ^ (l + 1))
42  convert hs using 1
43  · ext k
44    simp only [seededLaw, Nat.add_comm, mul_pow]
45    ring
46  · simp only [pgfBase, div_pow]
47    ring
48 
49theorem seededLaw_hasSum {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) (l : ℕ) :
50    HasSum (seededLaw r l) 1 := by
51  have hne : 1 - r ≠ 0 := by linarith
52  simpa only [one_pow, mul_one, pgfBase, div_self hne] using
53    seededLaw_pgf_hasSum hr0 hr1 (show (0 : ℝ) ≤ 1 by norm_num) le_rfl l
54 
55theorem seededLaw_zero (r : ℝ) (k : ℕ) :
56    seededLaw r 0 k = Cloning.Thermal.geometric r k := by
57  simp [seededLaw, Cloning.Thermal.geometric]
58 
59theorem pgfBase_nonneg {r z : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1)
60    (hz1 : z ≤ 1) : 0 ≤ pgfBase r z := by
61  unfold pgfBase
62  exact div_nonneg (by linarith) (by
63    have h := mul_le_of_le_one_right hr0 hz1
64    linarith)
65 
66theorem pgfBase_le_one {r z : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1)
67    (hz1 : z ≤ 1) : pgfBase r z ≤ 1 := by
68  have hmul := mul_le_of_le_one_right hr0 hz1
69  have hden : 0 < 1 - r * z := by linarith
70  exact (div_le_one hden).mpr (by linarith)
71 
72/-- Every seeded exponential moment is bounded by the vacuum-idler moment. -/
73theorem seededLaw_moment_le {r z : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1)
74    (hz0 : 0 ≤ z) (hz1 : z ≤ 1) (l : ℕ) :
75    (∑' k, seededLaw r l k * z ^ k) ≤ pgfBase r z := by
76  rw [(seededLaw_pgf_hasSum hr0 hr1 hz0 hz1 l).tsum_eq]
77  have h0 := pgfBase_nonneg hr0 hr1 hz1
78  have h1 := pgfBase_le_one hr0 hr1 hz1
79  induction l with
80  | zero => simp
81  | succ l ih =>
82      rw [pow_succ]
83      exact (mul_le_mul_of_nonneg_right ih h0).trans (mul_le_of_le_one_right h0 h1)
84 
85/-- The output number transition, padded by zero below the input number. -/
86def transition (r : ℝ) (n t : ℕ) : ℝ :=
87  if n ≤ t then seededLaw r n (t - n) else 0
88 
89def thermalOutput (r q : ℝ) (t : ℕ) : ℝ :=
90  ∑ n ∈ Finset.range (t + 1), Cloning.Thermal.geometric q n * seededLaw r n (t - n)
91 
92/-- Binomial convolution proves the actual thermal-input output probabilities. -/
93theorem thermalOutput_eq (r q : ℝ) (t : ℕ) :
94    thermalOutput r q t = Cloning.Thermal.geometric (r + (1 - r) * q) t := by
95  have he : 1 - (r + (1 - r) * q) = (1 - q) * (1 - r) := by ring
96  have hb : r + (1 - r) * q = q * (1 - r) + r := by ring
97  rw [thermalOutput, Cloning.Thermal.geometric, he, hb, add_pow, Finset.mul_sum]
98  apply Finset.sum_congr rfl
99  intro n hn
100  have hnt : n ≤ t := Nat.lt_succ_iff.mp (Finset.mem_range.mp hn)
101  rw [seededLaw, show n + (t - n) = t by omega, Cloning.Thermal.geometric,
102    pow_succ, mul_pow]
103  ring
104 
105theorem thermalOutput_eq_tsum (r q : ℝ) (t : ℕ) :
106    thermalOutput r q t = ∑' n, Cloning.Thermal.geometric q n * transition r n t := by
107  rw [tsum_eq_sum (s := Finset.range (t + 1))]
108  · apply Finset.sum_congr rfl
109    intro n hn
110    simp only [transition, if_pos (Nat.lt_succ_iff.mp (Finset.mem_range.mp hn))]
111  · intro n hn
112    have hnt : ¬ n ≤ t := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hn
113    simp only [transition, if_neg hnt, mul_zero]
114 
115/-- In gain notation the derived parameter is exactly the manuscript's
116`q ↦ 1-(1-q)/g`. -/
117theorem thermalOutput_gain (g q : ℝ) (t : ℕ) :
118    thermalOutput (1 - 1 / g) q t = Cloning.Thermal.geometric (Cloning.Thermal.amplified g q) t := by
119  rw [thermalOutput_eq]
120  congr 1
121  unfold Cloning.Thermal.amplified
122  ring
123 
124def productLaw {s : ℕ} (r : Fin s → ℝ) (l k : Fin s → ℕ) : ℝ :=
125  ∏ i, seededLaw (r i) (l i) (k i)
126 
127def productTest {s : ℕ} (z : Fin s → ℝ) (k : Fin s → ℕ) : ℝ := ∏ i, z i ^ k i
128 
129theorem productLaw_nonneg {s : ℕ} {r : Fin s → ℝ}
130    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1) (l k : Fin s → ℕ) :
131    0 ≤ productLaw r l k :=
132  Finset.prod_nonneg (fun i _ ↦ seededLaw_nonneg (hr0 i) (hr1 i) _ _)
133 
134theorem productLaw_hasSum {s : ℕ} {r : Fin s → ℝ}
135    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1) (l : Fin s → ℕ) :
136    HasSum (productLaw r l) 1 := by
137  simpa only [productLaw, Finset.prod_const_one] using
138    Cloning.Thermal.hasSum_fin_product s (fun i k ↦ seededLaw (r i) (l i) k)
139      (fun _ ↦ 1) (fun i k ↦ seededLaw_nonneg (hr0 i) (hr1 i) _ _)
140      (fun i ↦ seededLaw_hasSum (hr0 i) (hr1 i) _)
141 
142/-- Exact joint generating function for an arbitrary fixed idler number tuple. -/
143theorem productLaw_pgf_hasSum {s : ℕ} {r z : Fin s → ℝ}
144    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1)
145    (hz0 : ∀ i, 0 ≤ z i) (hz1 : ∀ i, z i ≤ 1) (l : Fin s → ℕ) :
146    HasSum (fun k ↦ productLaw r l k * productTest z k)
147      (∏ i, pgfBase (r i) (z i) ^ (l i + 1)) := by
148  simpa only [productLaw, productTest, Finset.prod_mul_distrib] using
149    Cloning.Thermal.hasSum_fin_product s
150      (fun i k ↦ seededLaw (r i) (l i) k * z i ^ k)
151      (fun i ↦ pgfBase (r i) (z i) ^ (l i + 1))
152      (fun i k ↦ mul_nonneg (seededLaw_nonneg (hr0 i) (hr1 i) _ _) (pow_nonneg (hz0 i) _))
153      (fun i ↦ seededLaw_pgf_hasSum (hr0 i) (hr1 i) (hz0 i) (hz1 i) _)
154 
155/-- Multimode least-noise exponential moment for every idler seed. -/
156theorem productLaw_moment_le {s : ℕ} {r z : Fin s → ℝ}
157    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1)
158    (hz0 : ∀ i, 0 ≤ z i) (hz1 : ∀ i, z i ≤ 1) (l : Fin s → ℕ) :
159    (∑' k, productLaw r l k * productTest z k) ≤ ∏ i, pgfBase (r i) (z i) := by
160  rw [(productLaw_pgf_hasSum hr0 hr1 hz0 hz1 l).tsum_eq]
161  apply Finset.prod_le_prod
162  · intro i hi
163    exact pow_nonneg (pgfBase_nonneg (hr0 i) (hr1 i) (hz1 i)) _
164  · intro i hi
165    rw [← (seededLaw_pgf_hasSum (hr0 i) (hr1 i) (hz0 i) (hz1 i) (l i)).tsum_eq]
166    exact seededLaw_moment_le (hr0 i) (hr1 i) (hz0 i) (hz1 i) (l i)
167 
168theorem productTest_nonneg {s : ℕ} {z : Fin s → ℝ} (hz0 : ∀ i, 0 ≤ z i)
169    (k : Fin s → ℕ) : 0 ≤ productTest z k :=
170  Finset.prod_nonneg (fun i _ ↦ pow_nonneg (hz0 i) _)
171 
172theorem productTest_le_one {s : ℕ} {z : Fin s → ℝ} (hz0 : ∀ i, 0 ≤ z i)
173    (hz1 : ∀ i, z i ≤ 1) (k : Fin s → ℕ) : productTest z k ≤ 1 := by
174  apply Finset.prod_le_one
175  · intro i hi; exact pow_nonneg (hz0 i) _
176  · intro i hi; exact pow_le_one₀ (hz0 i) (hz1 i)
177 
178/-- Arbitrarily correlated idler-number mixing; no product assumption on `a`. -/
179def mixtureLaw {s : ℕ} (r : Fin s → ℝ) (a : (Fin s → ℕ) → ℝ)
180    (k : Fin s → ℕ) : ℝ := ∑' l, a l * productLaw r l k
181 
182theorem mixtureLaw_nonneg {s : ℕ} {r : Fin s → ℝ} {a : (Fin s → ℕ) → ℝ}
183    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1) (ha0 : ∀ l, 0 ≤ a l)
184    (k : Fin s → ℕ) : 0 ≤ mixtureLaw r a k :=
185  tsum_nonneg (fun l ↦ mul_nonneg (ha0 l) (productLaw_nonneg hr0 hr1 l k))
186 
187theorem mixtureJoint_summable {s : ℕ} {r : Fin s → ℝ} {a : (Fin s → ℕ) → ℝ}
188    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1) (ha0 : ∀ l, 0 ≤ a l)
189    (ha : Summable a) :
190    Summable (fun lk : (Fin s → ℕ) × (Fin s → ℕ) ↦ a lk.1 * productLaw r lk.1 lk.2) := by
191  apply (summable_prod_of_nonneg (fun lk ↦
192    mul_nonneg (ha0 lk.1) (productLaw_nonneg hr0 hr1 _ _))).mpr
193  refine ⟨fun l ↦ (productLaw_hasSum hr0 hr1 l).summable.mul_left (a l), ?_⟩
194  convert ha using 1
195  ext l
196  change (∑' k, a l * productLaw r l k) = a l
197  rw [tsum_mul_left, (productLaw_hasSum hr0 hr1 l).tsum_eq, mul_one]
198 
199/-- The correlated output law has exactly the idler's total mass. -/
200theorem mixtureLaw_hasSum {s : ℕ} {r : Fin s → ℝ} {a : (Fin s → ℕ) → ℝ} {c : ℝ}
201    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1) (ha0 : ∀ l, 0 ≤ a l)
202    (ha : HasSum a c) : HasSum (mixtureLaw r a) c := by
203  have hs := mixtureJoint_summable hr0 hr1 ha0 ha.summable
204  have hcol : Summable (mixtureLaw r a) := hs.prod_symm.prod
205  have heq : (∑' k, mixtureLaw r a k) = c := by
206    unfold mixtureLaw
207    rw [hs.tsum_comm (f := fun l k ↦ a l * productLaw r l k)]
208    simp_rw [tsum_mul_left, (productLaw_hasSum hr0 hr1 _).tsum_eq, mul_one]
209    exact ha.tsum_eq
210  rw [← heq]
211  exact hcol.hasSum
212 
213/-- Exact correlated-mixture generating function, with Fubini justified by
214summability of the actual nonnegative joint law. -/
215theorem mixtureLaw_pgf_eq {s : ℕ} {r z : Fin s → ℝ} {a : (Fin s → ℕ) → ℝ}
216    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1)
217    (hz0 : ∀ i, 0 ≤ z i) (hz1 : ∀ i, z i ≤ 1)
218    (ha0 : ∀ l, 0 ≤ a l) (ha : Summable a) :
219    (∑' k, mixtureLaw r a k * productTest z k) =
220      ∑' l, a l * ∏ i, pgfBase (r i) (z i) ^ (l i + 1) := by
221  have hs := mixtureJoint_summable hr0 hr1 ha0 ha
222  have hw : Summable (fun lk : (Fin s → ℕ) × (Fin s → ℕ) ↦
223      a lk.1 * productLaw r lk.1 lk.2 * productTest z lk.2) := by
224    apply hs.of_norm_bounded
225    intro lk
226    have hp := mul_nonneg (ha0 lk.1) (productLaw_nonneg hr0 hr1 lk.1 lk.2)
227    rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hp (productTest_nonneg hz0 _))]
228    exact mul_le_of_le_one_right hp (productTest_le_one hz0 hz1 _)
229  unfold mixtureLaw
230  simp_rw [← tsum_mul_right]
231  rw [hw.tsum_comm (f := fun l k ↦ a l * productLaw r l k * productTest z k)]
232  simp_rw [mul_assoc, tsum_mul_left, (productLaw_pgf_hasSum hr0 hr1 hz0 hz1 _).tsum_eq]
233 
234/-- The least-noise exponential-moment inequality for any correlated idler
235mixing law, including deficient total mass `c`. -/
236theorem mixtureLaw_moment_le {s : ℕ} {r z : Fin s → ℝ}
237    {a : (Fin s → ℕ) → ℝ} {c : ℝ}
238    (hr0 : ∀ i, 0 ≤ r i) (hr1 : ∀ i, r i < 1)
239    (hz0 : ∀ i, 0 ≤ z i) (hz1 : ∀ i, z i ≤ 1)
240    (ha0 : ∀ l, 0 ≤ a l) (ha : HasSum a c) :
241    (∑' k, mixtureLaw r a k * productTest z k) ≤ c * ∏ i, pgfBase (r i) (z i) := by
242  rw [mixtureLaw_pgf_eq hr0 hr1 hz0 hz1 ha0 ha.summable]
243  have hM0 (l : Fin s → ℕ) : 0 ≤ ∏ i, pgfBase (r i) (z i) ^ (l i + 1) :=
244    Finset.prod_nonneg (fun i _ ↦ pow_nonneg (pgfBase_nonneg (hr0 i) (hr1 i) (hz1 i)) _)
245  have hM (l : Fin s → ℕ) : (∏ i, pgfBase (r i) (z i) ^ (l i + 1)) ≤
246      ∏ i, pgfBase (r i) (z i) := by
247    rw [← (productLaw_pgf_hasSum hr0 hr1 hz0 hz1 l).tsum_eq]
248    exact productLaw_moment_le hr0 hr1 hz0 hz1 l
249  have hmajor := ha.summable.mul_right (∏ i, pgfBase (r i) (z i))
250  have hminor : Summable (fun l ↦ a l * ∏ i, pgfBase (r i) (z i) ^ (l i + 1)) := by
251    apply hmajor.of_norm_bounded
252    intro l
253    rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (ha0 l) (hM0 l))]
254    exact mul_le_mul_of_nonneg_left (hM l) (ha0 l)
255  calc
256    _ ≤ ∑' l, a l * ∏ i, pgfBase (r i) (z i) :=
257      hminor.tsum_le_tsum (fun l ↦ mul_le_mul_of_nonneg_left (hM l) (ha0 l)) hmajor
258    _ = _ := by rw [tsum_mul_right, ha.tsum_eq]
259 
260/-- Exact seeded expectation of the thermal fidelity witness. -/
261theorem seededLaw_witness_hasSum {q x : ℝ} (hq0 : 0 < q) (hqx : q < x)
262    (hx1 : x < 1) (l : ℕ) :
263    HasSum (fun k ↦ seededLaw x l k * Cloning.Thermal.witness q x k)
264      (Real.sqrt ((1 - q) / (1 - x)) * pgfBase x (Real.sqrt (q / x)) ^ (l + 1)) := by
265  have hx0 : 0 < x := hq0.trans hqx
266  have hz1 : Real.sqrt (q / x) ≤ 1 :=
267    Real.sqrt_le_one.mpr ((div_le_one hx0).mpr hqx.le)
268  convert (seededLaw_pgf_hasSum hx0.le hx1 (Real.sqrt_nonneg _) hz1 l).mul_left
269    (Real.sqrt ((1 - q) / (1 - x))) using 1
270  ext k
271  rw [Cloning.Thermal.witness_closed hq0.le (hqx.trans hx1) hx0.le hx1]
272  ring
273 
274/-- The vacuum prefactor is identified by uniqueness of the two convergent
275series, avoiding an additional algebraic assumption about the witness. -/
276theorem witness_pgfBase_eq_fidelity {q x : ℝ} (hq0 : 0 < q) (hqx : q < x)
277    (hx1 : x < 1) :
278    Real.sqrt ((1 - q) / (1 - x)) * pgfBase x (Real.sqrt (q / x)) =
279      Cloning.Thermal.fidelity q x := by
280  have h := seededLaw_witness_hasSum hq0 hqx hx1 0
281  simp only [seededLaw_zero, zero_add, pow_one] at h
282  exact h.unique (Cloning.Thermal.witness_moment_hasSum hq0 (hqx.trans hx1)
283    (hq0.trans hqx) hx1)
284 
285theorem seededLaw_witness_moment_le {q x : ℝ} (hq0 : 0 < q) (hqx : q < x)
286    (hx1 : x < 1) (l : ℕ) :
287    (∑' k, seededLaw x l k * Cloning.Thermal.witness q x k) ≤
288      Cloning.Thermal.fidelity q x := by
289  have hx0 := hq0.trans hqx
290  have hz1 : Real.sqrt (q / x) ≤ 1 :=
291    Real.sqrt_le_one.mpr ((div_le_one hx0).mpr hqx.le)
292  rw [(seededLaw_witness_hasSum hq0 hqx hx1 l).tsum_eq,
293    ← witness_pgfBase_eq_fidelity hq0 hqx hx1]
294  apply mul_le_mul_of_nonneg_left _ (Real.sqrt_nonneg _)
295  rw [← (seededLaw_pgf_hasSum hx0.le hx1 (Real.sqrt_nonneg _) hz1 l).tsum_eq]
296  exact seededLaw_moment_le hx0.le hx1 (Real.sqrt_nonneg _) hz1 l
297 
298/-- The exact product thermal witness obeys the least-noise bound for every
299correlated countable idler law. Deficient mass is allowed. -/
300theorem mixtureLaw_witness_moment_le {s : ℕ} {q x : Fin s → ℝ}
301    {a : (Fin s → ℕ) → ℝ} {c : ℝ}
302    (hq0 : ∀ i, 0 < q i) (hqx : ∀ i, q i < x i) (hx1 : ∀ i, x i < 1)
303    (ha0 : ∀ l, 0 ≤ a l) (ha : HasSum a c) :
304    (∑' k, mixtureLaw x a k * ∏ i, Cloning.Thermal.witness (q i) (x i) (k i)) ≤
305      c * ∏ i, Cloning.Thermal.fidelity (q i) (x i) := by
306  let C : ℝ := ∏ i, Real.sqrt ((1 - q i) / (1 - x i))
307  let z : Fin s → ℝ := fun i ↦ Real.sqrt (q i / x i)
308  have hx0 (i) : 0 < x i := (hq0 i).trans (hqx i)
309  have hz0 (i) : 0 ≤ z i := Real.sqrt_nonneg _
310  have hz1 (i) : z i ≤ 1 :=
311    Real.sqrt_le_one.mpr ((div_le_one (hx0 i)).mpr (hqx i).le)
312  have hC : 0 ≤ C := Finset.prod_nonneg (fun i _ ↦ Real.sqrt_nonneg _)
313  have hterm (k : Fin s → ℕ) :
314      (∏ i, Cloning.Thermal.witness (q i) (x i) (k i)) = C * productTest z k := by
315    simp only [Cloning.Thermal.witness_closed (hq0 _).le ((hqx _).trans (hx1 _))
316      (hx0 _).le (hx1 _), Finset.prod_mul_distrib, C, productTest, z]
317  simp_rw [hterm, ← mul_assoc, mul_right_comm (mixtureLaw x a _) C]
318  rw [tsum_mul_right]
319  calc
320    _ ≤ (c * ∏ i, pgfBase (x i) (z i)) * C :=
321      mul_le_mul_of_nonneg_right
322        (mixtureLaw_moment_le (fun i ↦ (hx0 i).le) hx1 hz0 hz1 ha0 ha) hC
323    _ = _ := by
324      rw [mul_assoc, mul_comm (∏ i, pgfBase (x i) (z i)) C, ← Finset.prod_mul_distrib]
325      congr 1
326      apply Finset.prod_congr rfl
327      intro i hi
328      exact witness_pgfBase_eq_fidelity (hq0 i) (hqx i) (hx1 i)
329 
330end Cloning.BosonicNumberLaw