Offline · exact source
Exact Lean source

YoungCompatibilityPMF

formalization/Cloning/YoungCompatibilityPMF.lean

Source hash: e62a8b60979f7befeb4d1422d926dc096dab5160dfc5ca678a231f0b1e649350

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.CountableScheffe
2import Mathlib.Probability.ProbabilityMassFunction.Constructions
3 
4/-!
5# Countable-PMF fallback bounds
6 
7Actual normalized PMFs are used throughout.  Replacing transition rows only off
8a set of good inputs costs at most twice its probability mass in `ℓ¹`, even
9when the input and output lattices are countably infinite.  The Hellinger
10bound follows from the already proved countable affinity continuity theorem.
11-/
12 
13set_option maxHeartbeats 1000000
14 
15noncomputable section
16open scoped BigOperators Topology Classical
17open Filter
18 
19namespace Cloning.YoungCompatibility
20 
21variable {A B : Type*}
22 
23def probability (p : PMF A) (a : A) : ℝ := (p a).toReal
24 
25theorem probability_nonneg (p : PMF A) (a : A) : 0 ≤ probability p a :=
26  ENNReal.toReal_nonneg
27 
28theorem hasSum_probability (p : PMF A) : HasSum (probability p) 1 := by
29  have h := ENNReal.hasSum_toReal p.tsum_coe_ne_top
30  have hsum : (∑' a, (p a).toReal) = 1 := by
31    rw [← ENNReal.tsum_toReal_eq p.apply_ne_top, p.tsum_coe]
32    simp
33  simpa only [probability, hsum] using h
34 
35@[simp] theorem tsum_probability (p : PMF A) : ∑' a, probability p a = 1 :=
36  (hasSum_probability p).tsum_eq
37 
38theorem probability_bind (p : PMF A) (K : A → PMF B) (b : B) :
39    probability (p.bind K) b = ∑' a, probability p a * probability (K a) b := by
40  unfold probability
41  rw [PMF.bind_apply, ENNReal.tsum_toReal_eq (fun a ↦ ENNReal.mul_ne_top
42    (p.apply_ne_top a) ((K a).apply_ne_top b))]
43  simp only [ENNReal.toReal_mul]
44 
45theorem summable_kernel_joint (p : PMF A) (K : A → PMF B) :
46    Summable (fun ab : A × B ↦ probability p ab.1 * probability (K ab.1) ab.2) := by
47  rw [summable_prod_of_nonneg (fun ab ↦ mul_nonneg
48    (probability_nonneg p ab.1) (probability_nonneg (K ab.1) ab.2))]
49  constructor
50  · intro a
51    change Summable (fun b : B ↦ probability p a * probability (K a) b)
52    exact (hasSum_probability (K a)).summable.mul_left (probability p a)
53  change Summable (fun a : A ↦ ∑' b : B, probability p a * probability (K a) b)
54  simpa only [tsum_mul_left, tsum_probability, mul_one] using (hasSum_probability p).summable
55 
56theorem summable_kernel_error (p : PMF A) (K L : A → PMF B) :
57    Summable (fun ab : A × B ↦ probability p ab.1 *
58      |probability (K ab.1) ab.2 - probability (L ab.1) ab.2|) := by
59  apply ((summable_kernel_joint p K).add (summable_kernel_joint p L)).of_nonneg_of_le
60  · intro ab
61    exact mul_nonneg (probability_nonneg p ab.1) (abs_nonneg _)
62  · intro ab
63    have h := abs_sub (probability (K ab.1) ab.2) (probability (L ab.1) ab.2)
64    rw [abs_of_nonneg (probability_nonneg _ _), abs_of_nonneg (probability_nonneg _ _)] at h
65    simpa only [mul_add] using mul_le_mul_of_nonneg_left h (probability_nonneg p ab.1)
66 
67theorem kernel_row_l1_le_two (K L : PMF B) :
68    CountableScheffe.l1Distance (probability K) (probability L) ≤ 2 := by
69  unfold CountableScheffe.l1Distance
70  calc
71    (∑' b, |probability K b - probability L b|) ≤
72        ∑' b, (probability K b + probability L b) := by
73      apply ((hasSum_probability K).summable.sub (hasSum_probability L).summable).abs.tsum_le_tsum
74      · intro b
75        simpa only [abs_of_nonneg (probability_nonneg K b),
76          abs_of_nonneg (probability_nonneg L b)] using abs_sub (probability K b) (probability L b)
77      · exact (hasSum_probability K).summable.add (hasSum_probability L).summable
78    _ = 2 := by rw [(hasSum_probability K).summable.tsum_add (hasSum_probability L).summable]; norm_num [tsum_probability]
79 
80/-- Countable stochastic transport inequality, proved by absolutely summable
81Fubini for the actual transition probabilities. -/
82theorem bind_l1_kernel_bound (p : PMF A) (K L : A → PMF B) :
83    CountableScheffe.l1Distance (probability (p.bind K)) (probability (p.bind L)) ≤
84      ∑' a, probability p a * CountableScheffe.l1Distance (probability (K a)) (probability (L a)) := by
85  have hK := summable_kernel_joint p K
86  have hL := summable_kernel_joint p L
87  have hE := summable_kernel_error p K L
88  unfold CountableScheffe.l1Distance
89  have hb (b : B) : |probability (p.bind K) b - probability (p.bind L) b| ≤
90      ∑' a, probability p a * |probability (K a) b - probability (L a) b| := by
91    have hKb : Summable (fun a : A ↦ probability p a * probability (K a) b) := hK.prod_symm.prod_factor b
92    have hLb : Summable (fun a : A ↦ probability p a * probability (L a) b) := hL.prod_symm.prod_factor b
93    rw [probability_bind, probability_bind, ← hKb.tsum_sub hLb]
94    calc
95      _ ≤ ∑' a, |probability p a * probability (K a) b - probability p a * probability (L a) b| := by
96        have hnorm : Summable (fun a : A ↦ ‖probability p a * probability (K a) b -
97            probability p a * probability (L a) b‖) := by
98          simpa only [Real.norm_eq_abs] using (hKb.sub hLb).abs
99        simpa only [Real.norm_eq_abs] using norm_tsum_le_tsum_norm hnorm
100      _ = _ := by
101        apply tsum_congr
102        intro a
103        rw [← mul_sub, abs_mul, abs_of_nonneg (probability_nonneg p a)]
104  calc
105    _ ≤ ∑' b, ∑' a, probability p a * |probability (K a) b - probability (L a) b| := by
106      exact ((hasSum_probability (p.bind K)).summable.sub
107        (hasSum_probability (p.bind L)).summable).abs.tsum_le_tsum hb hE.prod_symm.prod
108    _ = ∑' a, ∑' b, probability p a * |probability (K a) b - probability (L a) b| := hE.tsum_comm
109    _ = _ := by simp only [tsum_mul_left]
110 
111/-- The bad-input probability, represented as an ordinary convergent real sum. -/
112def badMass (p : PMF A) (good : A → Prop) : ℝ :=
113  ∑' a, if good a then 0 else probability p a
114 
115theorem badMass_nonneg (p : PMF A) (good : A → Prop) : 0 ≤ badMass p good := by
116  classical
117  apply tsum_nonneg
118  intro a
119  split_ifs
120  · exact le_rfl
121  · exact probability_nonneg p a
122 
123theorem summable_badMass (p : PMF A) (good : A → Prop) :
124    Summable (fun a ↦ if good a then 0 else probability p a) := by
125  classical
126  apply (hasSum_probability p).summable.of_nonneg_of_le
127  · intro a
128    split_ifs
129    · exact le_rfl
130    · exact probability_nonneg p a
131  · intro a
132    split_ifs <;> simp [probability_nonneg]
133 
134/-- Actual PMF fallback has dimension-independent cost.  The equality hypothesis
135is a row identity on the good inputs; the concrete Young-label file derives it
136from strict spectral gaps and the actual rounding support. -/
137theorem bind_fallback_l1_bound (p : PMF A) (K L : A → PMF B)
138    (good : A → Prop) (hsame : ∀ a, good a → K a = L a) :
139    CountableScheffe.l1Distance (probability (p.bind K)) (probability (p.bind L)) ≤
140      2 * badMass p good := by
141  classical
142  apply (bind_l1_kernel_bound p K L).trans
143  have hs : Summable (fun a ↦ probability p a *
144      CountableScheffe.l1Distance (probability (K a)) (probability (L a))) := by
145    simpa only [CountableScheffe.l1Distance, tsum_mul_left] using (summable_kernel_error p K L).prod
146  calc
147    _ ≤ ∑' a, 2 * (if good a then 0 else probability p a) := by
148      apply hs.tsum_le_tsum _ ((summable_badMass p good).mul_left 2)
149      intro a
150      by_cases ha : good a
151      · simp [ha, hsame a ha, CountableScheffe.l1Distance]
152      · simp only [ha, ↓reduceIte]
153        calc
154          _ ≤ probability p a * 2 := mul_le_mul_of_nonneg_left
155            (kernel_row_l1_le_two (K a) (L a)) (probability_nonneg p a)
156          _ = _ := mul_comm _ _
157    _ = _ := by rw [tsum_mul_left]; rfl
158 
159theorem bind_fallback_affinity_bound (p : PMF A) (K L : A → PMF B)
160    (good : A → Prop) (hsame : ∀ a, good a → K a = L a) (q : PMF B) :
161    |CountableScheffe.affinity (probability (p.bind K)) (probability q) -
162      CountableScheffe.affinity (probability (p.bind L)) (probability q)| ≤
163      Real.sqrt (2 * badMass p good) :=
164  (CountableScheffe.affinity_l1_continuity _ _ _
165    (probability_nonneg _) (probability_nonneg _) (probability_nonneg _)
166    (hasSum_probability _).summable (hasSum_probability _).summable
167    (hasSum_probability _)).trans
168    (Real.sqrt_le_sqrt (bind_fallback_l1_bound p K L good hsame))
169 
170end Cloning.YoungCompatibility