Offline · exact source
Exact Lean source

YoungFlatFidelityBounds

formalization/Cloning/YoungFlatFidelityBounds.lean

Source hash: 4e3c1477c1209ba4c8793f423d6ef7f4e27494353e0fdbca3bfb88990d3ec0f5

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.ClassicalFidelity
2import Mathlib.Probability.ProbabilityMassFunction.Integrals
3 
4/-! Scalar square-root product estimates valid for every finite coupling. -/
5noncomputable section
6open scoped BigOperators Topology Classical
7open MeasureTheory Filter
8namespace Cloning.YoungFlat
9set_option backward.isDefEq.respectTransparency false
10set_option maxHeartbeats 1000000
11variable {ι : Type*} [Fintype ι]
12 
13theorem weighted_sqrt_le (p f : ι → ℝ) (hp : ∀ i, 0 ≤ p i)
14    (hs : ∑ i, p i=1) (hf : ∀ i, 0 ≤ f i) :
15    (∑ i, p i*Real.sqrt (f i)) ≤ Real.sqrt (∑ i, p i*f i) := by
16  have hh := Real.sum_sqrt_mul_sqrt_le Finset.univ hp (fun i ↦ mul_nonneg (hp i) (hf i))
17  have he i : Real.sqrt (p i)*Real.sqrt (p i*f i)=p i*Real.sqrt (f i) := by
18    rw [Real.sqrt_mul (hp i), ← mul_assoc, Real.mul_self_sqrt (hp i)]
19  simpa only [he, hs, Real.sqrt_one, one_mul] using hh
20 
21theorem weighted_sqrt_product_error (p A B : ι → ℝ) (hp : ∀ i, 0 ≤ p i)
22    (hs : ∑ i, p i=1) (hA : ∀ i, 0 ≤ A i) (hB : ∀ i, 0 ≤ B i)
23    (C : ℝ) (hAC : ∀ i, A i ≤ C) :
24    (∑ i, p i*|Real.sqrt (A i*B i)-1|) ≤
25      Real.sqrt (C*(∑ i, p i*|B i-1|)+(∑ i, p i*|A i-1|)) := by
26  have hpoint i : |A i*B i-1| ≤ C*|B i-1|+|A i-1| := by
27    calc
28      _ = |A i*(B i-1)+(A i-1)| := by congr 1; ring
29      _ ≤ |A i*(B i-1)|+|A i-1| := abs_add_le _ _
30      _ = A i*|B i-1|+|A i-1| := by rw [abs_mul, abs_of_nonneg (hA i)]
31      _ ≤ _ := add_le_add (mul_le_mul_of_nonneg_right (hAC i) (abs_nonneg _)) le_rfl
32  calc
33    _ ≤ ∑ i, p i*Real.sqrt |A i*B i-1| := by
34      apply Finset.sum_le_sum
35      intro i _
36      apply mul_le_mul_of_nonneg_left _ (hp i)
37      simpa only [Real.sqrt_one] using Cloning.ClassicalFidelity.sqrt_difference_bound
38        (A i*B i) 1 (mul_nonneg (hA i) (hB i)) zero_le_one
39    _ ≤ Real.sqrt (∑ i, p i*|A i*B i-1|) :=
40      weighted_sqrt_le p _ hp hs (fun _ ↦ abs_nonneg _)
41    _ ≤ _ := by
42      apply Real.sqrt_le_sqrt
43      calc
44        _ ≤ ∑ i, p i*(C*|B i-1|+|A i-1|) :=
45          Finset.sum_le_sum fun i _ ↦ mul_le_mul_of_nonneg_left (hpoint i) (hp i)
46        _ = _ := by
47          simp only [mul_add, Finset.sum_add_distrib, Finset.mul_sum]
48          congr 1
49          apply Finset.sum_congr rfl
50          intro i _
51          ring
52 
53/-- Deleting any bad set costs its probability mass times the reference scalar. -/
54theorem weighted_truncated_sqrt_error (p A B : ι → ℝ) (hp : ∀ i, 0 ≤ p i)
55    (hs : ∑ i, p i=1) (hA : ∀ i, 0 ≤ A i) (hB : ∀ i, 0 ≤ B i)
56    (C : ℝ) (hAC : ∀ i, A i ≤ C) (q : ℝ) (hq : 0 ≤ q) (good : ι → Prop) :
57    |(∑ i, p i*(if good i then q*Real.sqrt (A i*B i) else 0))-q| ≤
58      q*(Real.sqrt (C*(∑ i, p i*|B i-1|)+(∑ i, p i*|A i-1|))+
59        ∑ i, if good i then 0 else p i) := by
60  have he : (∑ i, p i*(if good i then q*Real.sqrt (A i*B i) else 0))-q =
61      ∑ i, p i*((if good i then q*Real.sqrt (A i*B i) else 0)-q) := by
62    simp only [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul, hs, one_mul]
63  rw [he]
64  calc
65    _ ≤ ∑ i, |p i*((if good i then q*Real.sqrt (A i*B i) else 0)-q)| :=
66      Finset.abs_sum_le_sum_abs _ _
67    _ ≤ ∑ i, (p i*(q*|Real.sqrt (A i*B i)-1|)+(if good i then 0 else q*p i)) := by
68      apply Finset.sum_le_sum
69      intro i _
70      rw [abs_mul, abs_of_nonneg (hp i)]
71      by_cases hi : good i
72      · simp only [if_pos hi, add_zero]
73        have heq : q*Real.sqrt (A i*B i)-q=q*(Real.sqrt (A i*B i)-1) := by ring
74        rw [heq, abs_mul, abs_of_nonneg hq]
75      · simp only [if_neg hi, zero_sub, abs_neg, abs_of_nonneg hq]
76        nlinarith [mul_nonneg (hp i) (mul_nonneg hq (abs_nonneg (Real.sqrt (A i*B i)-1)))]
77    _ = q*(∑ i, p i*|Real.sqrt (A i*B i)-1|)+q*(∑ i, if good i then 0 else p i) := by
78      rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.mul_sum]
79      congr 1
80      · apply Finset.sum_congr rfl; intro i _; ring
81      · apply Finset.sum_congr rfl; intro i _; split_ifs <;> ring
82    _ ≤ _ := by
83      nlinarith [weighted_sqrt_product_error p A B hp hs hA hB C hAC]
84 
85/-- The finite PMF change-of-variables formula in real weights. -/
86theorem pmf_sum_map {α β : Type*} [Fintype α] [Fintype β]
87    (P : PMF α) (f : α → β) (g : β → ℝ) :
88    (∑ a, (P a).toReal*g (f a)) = ∑ b, (P.map f b).toReal*g b := by
89  letI : MeasurableSpace α := ⊤
90  letI : MeasurableSpace β := ⊤
91  have hf : Measurable f := measurable_of_countable f
92  have hg : AEStronglyMeasurable g ((P.map f).toMeasure) :=
93    (measurable_of_countable g).aestronglyMeasurable
94  rw [← PMF.toMeasure_map f P hf] at hg
95  have he := integral_map hf.aemeasurable hg
96  rw [PMF.toMeasure_map f P hf] at he
97  simpa only [PMF.integral_eq_sum, smul_eq_mul] using he.symm
98 
99end Cloning.YoungFlat