Exact Lean source
ClassicalFidelity
formalization/Cloning/ClassicalFidelity.lean
Source hash: 050567a44cff34599be9963a89d434601727e0109f2f459438e559502b043569
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
theorem
Cloning.ClassicalFidelity.sqrt_difference_boundtheorem Cloning.ClassicalFidelity.affinity_l1_continuitytheorem Cloning.ClassicalFidelity.affinity_l1_continuity_two_sidedtheorem Cloning.ClassicalFidelity.sqrt_kernel_identitytheorem Cloning.ClassicalFidelity.affinity_data_processingtheorem Cloning.ClassicalFidelity.affinity_perturbation_tendstotheorem Cloning.ClassicalFidelity.affinity_limit_transfertheorem Cloning.ClassicalFidelity.affinity_uniform_perturbationtheorem Cloning.ClassicalFidelity.fallback_l1_tendsto_dependenttheorem Cloning.ClassicalFidelity.fallback_affinity_tendsto1import Cloning.Rounding
2import Cloning.BlockFidelity
3
4/-!
5# Classical Hellinger affinity under perturbation and stochastic kernels
6
7These proofs establish the finite classical instances of the continuity and
8data-processing arguments used for Young-label laws. The limit theorems allow
9the input and output label types to change with the sample size. They do not
10formalize the continuous Gaussian density calculations.
11-/
12
13noncomputable section
14open scoped BigOperators
15open Filter Cloning.Rounding Cloning.BlockFidelity
16
17namespace Cloning.ClassicalFidelity
18
19theorem sqrt_difference_bound (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) :
20 |Real.sqrt x - Real.sqrt y| ≤ Real.sqrt |x - y| := by
21 rcases le_total y x with h | h
22 · rw [abs_of_nonneg (sub_nonneg.mpr (Real.sqrt_le_sqrt h)),
23 abs_of_nonneg (sub_nonneg.mpr h)]
24 exact sqrt_sub_sqrt_le_sqrt_sub hy h
25 · rw [abs_sub_comm, abs_sub_comm x y,
26 abs_of_nonneg (sub_nonneg.mpr (Real.sqrt_le_sqrt h)),
27 abs_of_nonneg (sub_nonneg.mpr h)]
28 exact sqrt_sub_sqrt_le_sqrt_sub hx h
29
30variable {ι κ : Type*} [Fintype ι] [Fintype κ]
31
32/-- Dimension-independent one-sided Hellinger continuity. Only the target
33distribution needs normalization; the perturbed measures may have any mass. -/
34theorem affinity_l1_continuity (p q r : ι → ℝ)
35 (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (hr : ∀ i, 0 ≤ r i)
36 (hrsum : ∑ i, r i = 1) :
37 |classicalAffinity p r - classicalAffinity q r| ≤ Real.sqrt (l1Distance p q) := by
38 calc
39 |classicalAffinity p r - classicalAffinity q r| =
40 |∑ i, (Real.sqrt (p i) - Real.sqrt (q i)) * Real.sqrt (r i)| := by
41 simp [classicalAffinity, Finset.sum_sub_distrib, sub_mul]
42 _ ≤ ∑ i, |(Real.sqrt (p i) - Real.sqrt (q i)) * Real.sqrt (r i)| :=
43 Finset.abs_sum_le_sum_abs _ _
44 _ ≤ ∑ i, Real.sqrt |p i - q i| * Real.sqrt (r i) := by
45 apply Finset.sum_le_sum
46 intro i _
47 rw [abs_mul, abs_of_nonneg (Real.sqrt_nonneg _)]
48 exact mul_le_mul_of_nonneg_right
49 (sqrt_difference_bound _ _ (hp i) (hq i)) (Real.sqrt_nonneg _)
50 _ ≤ Real.sqrt (∑ i, |p i - q i|) * Real.sqrt (∑ i, r i) :=
51 Real.sum_sqrt_mul_sqrt_le Finset.univ (fun i ↦ abs_nonneg _) hr
52 _ = Real.sqrt (l1Distance p q) := by rw [hrsum, Real.sqrt_one, mul_one]; rfl
53
54/-- Varying both distributions costs the sum of the two square-root errors. -/
55theorem affinity_l1_continuity_two_sided (p q p' q' : ι → ℝ)
56 (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i)
57 (hp' : ∀ i, 0 ≤ p' i) (hq' : ∀ i, 0 ≤ q' i)
58 (hp'sum : ∑ i, p' i = 1) (hqsum : ∑ i, q i = 1) :
59 |classicalAffinity p q - classicalAffinity p' q'| ≤
60 Real.sqrt (l1Distance p p') + Real.sqrt (l1Distance q q') := by
61 calc
62 |classicalAffinity p q - classicalAffinity p' q'| ≤
63 |classicalAffinity p q - classicalAffinity p' q| +
64 |classicalAffinity p' q - classicalAffinity p' q'| := abs_sub_le _ _ _
65 _ ≤ Real.sqrt (l1Distance p p') + Real.sqrt (l1Distance q q') := by
66 apply add_le_add (affinity_l1_continuity _ _ _ hp hp' hq hqsum)
67 rw [classicalAffinity_comm p' q, classicalAffinity_comm p' q']
68 exact affinity_l1_continuity _ _ _ hq hq' hp' hp'sum
69
70theorem sqrt_kernel_identity (p q k : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) (hk : 0 ≤ k) :
71 Real.sqrt (p * k) * Real.sqrt (q * k) = Real.sqrt p * Real.sqrt q * k := by
72 rw [Real.sqrt_mul hp, Real.sqrt_mul hq]
73 calc
74 (Real.sqrt p * Real.sqrt k) * (Real.sqrt q * Real.sqrt k) =
75 Real.sqrt p * Real.sqrt q * (Real.sqrt k * Real.sqrt k) := by ring
76 _ = Real.sqrt p * Real.sqrt q * k := by rw [Real.mul_self_sqrt hk]
77
78/-- Classical fidelity cannot decrease under a stochastic kernel. -/
79theorem affinity_data_processing (K : StochasticKernel ι κ) (p q : ι → ℝ)
80 (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) :
81 classicalAffinity p q ≤ classicalAffinity (transport K p) (transport K q) := by
82 have hcolumn (j : κ) :
83 (∑ i, Real.sqrt (p i) * Real.sqrt (q i) * K.value i j) ≤
84 Real.sqrt (transport K p j) * Real.sqrt (transport K q j) := by
85 calc
86 (∑ i, Real.sqrt (p i) * Real.sqrt (q i) * K.value i j) =
87 ∑ i, Real.sqrt (p i * K.value i j) * Real.sqrt (q i * K.value i j) := by
88 apply Finset.sum_congr rfl
89 intro i _
90 exact (sqrt_kernel_identity _ _ _ (hp i) (hq i) (K.nonneg i j)).symm
91 _ ≤ Real.sqrt (transport K p j) * Real.sqrt (transport K q j) :=
92 Real.sum_sqrt_mul_sqrt_le Finset.univ
93 (fun i ↦ mul_nonneg (hp i) (K.nonneg i j))
94 (fun i ↦ mul_nonneg (hq i) (K.nonneg i j))
95 calc
96 classicalAffinity p q = ∑ j, ∑ i, Real.sqrt (p i) * Real.sqrt (q i) * K.value i j := by
97 rw [Finset.sum_comm]
98 simp only [← Finset.mul_sum, K.row_sum, mul_one, classicalAffinity]
99 _ ≤ classicalAffinity (transport K p) (transport K q) :=
100 Finset.sum_le_sum fun j _ ↦ hcolumn j
101
102/-- Continuity remains valid when the finite label alphabet grows with `n`. -/
103theorem affinity_perturbation_tendsto {I : ℕ → Type*} [∀ n, Fintype (I n)]
104 (p q r : (n : ℕ) → I n → ℝ)
105 (hp : ∀ n i, 0 ≤ p n i) (hq : ∀ n i, 0 ≤ q n i) (hr : ∀ n i, 0 ≤ r n i)
106 (hrsum : ∀ n, ∑ i, r n i = 1)
107 (hl1 : Tendsto (fun n ↦ l1Distance (p n) (q n)) atTop (nhds 0)) :
108 Tendsto (fun n ↦ |classicalAffinity (p n) (r n) - classicalAffinity (q n) (r n)|)
109 atTop (nhds 0) := by
110 apply squeeze_zero (fun n ↦ abs_nonneg _)
111 (fun n ↦ affinity_l1_continuity _ _ _ (hp n) (hq n) (hr n) (hrsum n))
112 simpa using (Real.continuous_sqrt.tendsto 0).comp hl1
113
114/-- An `L¹`-small change of labels preserves an already established affinity limit. -/
115theorem affinity_limit_transfer {I : ℕ → Type*} [∀ n, Fintype (I n)]
116 (p q r : (n : ℕ) → I n → ℝ) (c : ℝ)
117 (hp : ∀ n i, 0 ≤ p n i) (hq : ∀ n i, 0 ≤ q n i) (hr : ∀ n i, 0 ≤ r n i)
118 (hrsum : ∀ n, ∑ i, r n i = 1)
119 (hl1 : Tendsto (fun n ↦ l1Distance (p n) (q n)) atTop (nhds 0))
120 (hlimit : Tendsto (fun n ↦ classicalAffinity (q n) (r n)) atTop (nhds c)) :
121 Tendsto (fun n ↦ classicalAffinity (p n) (r n)) atTop (nhds c) := by
122 have herr := affinity_perturbation_tendsto p q r hp hq hr hrsum hl1
123 rw [tendsto_iff_dist_tendsto_zero] at hlimit ⊢
124 simp only [Real.dist_eq] at hlimit ⊢
125 apply squeeze_zero (fun n ↦ abs_nonneg _)
126 (fun n ↦ abs_sub_le (classicalAffinity (p n) (r n))
127 (classicalAffinity (q n) (r n)) c)
128 simpa using herr.add hlimit
129
130/-- Uniform continuity for families of distributions on growing alphabets. -/
131theorem affinity_uniform_perturbation {I : ℕ → Type*} [∀ n, Fintype (I n)]
132 {P : Type*} (S : Set P) (p q r : (n : ℕ) → P → I n → ℝ) (e : ℕ → ℝ)
133 (hp : ∀ n s i, 0 ≤ p n s i) (hq : ∀ n s i, 0 ≤ q n s i)
134 (hr : ∀ n s i, 0 ≤ r n s i) (hrsum : ∀ n s, ∑ i, r n s i = 1)
135 (hl1 : ∀ n s, s ∈ S → l1Distance (p n s) (q n s) ≤ e n)
136 (he : Tendsto e atTop (nhds 0)) :
137 ∀ ε > 0, ∀ᶠ n in atTop, ∀ s ∈ S,
138 |classicalAffinity (p n s) (r n s) - classicalAffinity (q n s) (r n s)| < ε := by
139 have hroot : Tendsto (fun n ↦ Real.sqrt (e n)) atTop (nhds 0) := by
140 simpa using (Real.continuous_sqrt.tendsto 0).comp he
141 intro ε hε
142 refine (hroot.eventually (gt_mem_nhds hε)).mono ?_
143 intro n hn s hs
144 calc
145 |classicalAffinity (p n s) (r n s) - classicalAffinity (q n s) (r n s)| ≤
146 Real.sqrt (l1Distance (p n s) (q n s)) :=
147 affinity_l1_continuity _ _ _ (hp n s) (hq n s) (hr n s) (hrsum n s)
148 _ ≤ Real.sqrt (e n) := Real.sqrt_le_sqrt (hl1 n s hs)
149 _ < ε := hn
150
151/-- The fallback `L¹` limit with sample-size-dependent input and output alphabets. -/
152theorem fallback_l1_tendsto_dependent
153 {I J : ℕ → Type*} [∀ n, Fintype (I n)] [∀ n, Fintype (J n)]
154 (K L : (n : ℕ) → StochasticKernel (I n) (J n))
155 (p : (n : ℕ) → I n → ℝ) (hp : ∀ n i, 0 ≤ p n i)
156 (good : (n : ℕ) → I n → Prop) [∀ n, DecidablePred (good n)]
157 (hsame : ∀ n i, good n i → ∀ j, (K n).value i j = (L n).value i j)
158 (hbad : Tendsto (fun n ↦ ∑ i, if good n i then 0 else p n i) atTop (nhds 0)) :
159 Tendsto (fun n ↦ l1Distance (transport (K n) (p n)) (transport (L n) (p n)))
160 atTop (nhds 0) := by
161 apply squeeze_zero
162 (fun n ↦ Finset.sum_nonneg fun i _ ↦ abs_nonneg _)
163 (fun n ↦ fallback_l1_bound (K n) (L n) (p n) (hp n) (good n) (hsame n))
164 simpa [two_mul] using hbad.add hbad
165
166/-- A fallback confined to asymptotically negligible inputs leaves the
167label affinity unchanged, even for growing label alphabets. -/
168theorem fallback_affinity_tendsto
169 {I J : ℕ → Type*} [∀ n, Fintype (I n)] [∀ n, Fintype (J n)]
170 (K L : (n : ℕ) → StochasticKernel (I n) (J n))
171 (p : (n : ℕ) → I n → ℝ) (r : (n : ℕ) → J n → ℝ)
172 (hp : ∀ n i, 0 ≤ p n i) (hr : ∀ n j, 0 ≤ r n j)
173 (hrsum : ∀ n, ∑ j, r n j = 1)
174 (good : (n : ℕ) → I n → Prop) [∀ n, DecidablePred (good n)]
175 (hsame : ∀ n i, good n i → ∀ j, (K n).value i j = (L n).value i j)
176 (hbad : Tendsto (fun n ↦ ∑ i, if good n i then 0 else p n i) atTop (nhds 0)) :
177 Tendsto (fun n ↦
178 |classicalAffinity (transport (K n) (p n)) (r n) -
179 classicalAffinity (transport (L n) (p n)) (r n)|) atTop (nhds 0) := by
180 apply affinity_perturbation_tendsto
181 (fun n ↦ transport (K n) (p n)) (fun n ↦ transport (L n) (p n)) r
182 (fun n ↦ transport_nonneg (K n) (p n) (hp n))
183 (fun n ↦ transport_nonneg (L n) (p n) (hp n)) hr hrsum
184 exact fallback_l1_tendsto_dependent K L p hp good hsame hbad
185
186end Cloning.ClassicalFidelity