Offline · exact source
Exact Lean source

YoungGeneralConcentration

formalization/Cloning/YoungGeneralConcentration.lean

Source hash: 18aae55b3109430619c2482ac3a44948d5439cc4dabe687a1b94449946e7ff80

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 Mathlib.Analysis.SpecialFunctions.Exp
2import Mathlib.Algebra.BigOperators.Ring.Finset
3import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
4 
5/-!
6# Finite-alphabet concentration, with an explicit finite sum
7 
8The probability space consists of actual words over a finite alphabet.  The
9proof calculates their exponential moment and applies a pointwise exponential
10bound; no concentration estimate is supplied as an assumption.  This is the
11analytic input for the tableau formula for the general Young law.
12-/
13 
14noncomputable section
15open scoped BigOperators Topology
16open Filter
17 
18namespace Cloning.YoungGeneral
19 
20def wordWeight {d N : ℕ} (p : Fin d → ℝ) (w : Fin N → Fin d) : ℝ :=
21  ∏ k, p (w k)
22 
23def rowCount {d N : ℕ} (w : Fin N → Fin d) (i : Fin d) : ℕ :=
24  (Finset.univ.filter (fun k ↦ w k = i)).card
25 
26theorem wordWeight_nonneg {d N : ℕ} (p : Fin d → ℝ)
27    (hp : ∀ i, 0 ≤ p i) (w : Fin N → Fin d) : 0 ≤ wordWeight p w :=
28  Finset.prod_nonneg (fun k _ ↦ hp (w k))
29 
30theorem wordWeight_sum {d N : ℕ} (p : Fin d → ℝ) (hp : ∑ i, p i = 1) :
31    (∑ w : Fin N → Fin d, wordWeight p w) = 1 := by
32  simp only [wordWeight]
33  rw [← Fintype.sum_pow, hp, one_pow]
34 
35theorem wordWeight_eq_row_product {d N : ℕ} (p : Fin d → ℝ)
36    (w : Fin N → Fin d) : wordWeight p w = ∏ i, p i ^ rowCount w i := by
37  classical
38  simpa [wordWeight, rowCount, Fintype.card_subtype] using (Fintype.prod_fiberwise' w p).symm
39 
40theorem sum_rowCount {d N : ℕ} (w : Fin N → Fin d) : ∑ i, rowCount w i = N := by
41  classical
42  simpa [rowCount, Fintype.card_subtype] using (Fintype.sum_fiberwise w (fun _ ↦ (1 : ℕ)))
43 
44private theorem exp_le_quadratic {x : ℝ} (hx : |x| ≤ 1) :
45    Real.exp x ≤ 1 + x + x ^ 2 := by
46  have h := Real.norm_exp_sub_one_sub_id_le (show ‖x‖ ≤ 1 by simpa using hx)
47  rw [Real.norm_eq_abs, Real.norm_eq_abs, sq_abs] at h
48  have := (abs_le.mp h).2
49  linarith
50 
51/-- A finite centered variable in `[-1,1]` has this elementary MGF bound
52for parameters of absolute value at most one. -/
53theorem finite_mgf_le {d : ℕ} (p x : Fin d → ℝ)
54    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1)
55    (hx : ∀ i, |x i| ≤ 1) (hm : ∑ i, p i * x i = 0)
56    (t : ℝ) (ht : |t| ≤ 1) :
57    (∑ i, p i * Real.exp (t * x i)) ≤ Real.exp (t ^ 2) := by
58  have hb i : Real.exp (t * x i) ≤ 1 + t * x i + t ^ 2 := by
59    have htx : |t * x i| ≤ 1 := by
60      rw [abs_mul]
61      exact (mul_le_mul ht (hx i) (abs_nonneg _) (by norm_num)).trans_eq (by norm_num)
62    have hsqi : (x i) ^ 2 ≤ 1 := by nlinarith [(abs_le.mp (hx i)).1, (abs_le.mp (hx i)).2]
63    have := mul_le_mul_of_nonneg_left hsqi (sq_nonneg t)
64    nlinarith [exp_le_quadratic htx]
65  calc
66    _ ≤ ∑ i, p i * (1 + t * x i + t ^ 2) :=
67      Finset.sum_le_sum (fun i _ ↦ mul_le_mul_of_nonneg_left (hb i) (hp i))
68    _ = 1 + t ^ 2 := by
69      simp_rw [mul_add, mul_one, show ∀ i, p i * (t * x i) = t * (p i * x i) by intro i; ring]
70      rw [Finset.sum_add_distrib, Finset.sum_add_distrib, ← Finset.mul_sum,
71        ← Finset.sum_mul, hs, hm]
72      ring
73    _ ≤ _ := by simpa [add_comm] using Real.add_one_le_exp (t ^ 2)
74 
75/-- Exact independent-product generating function. -/
76theorem word_mgf_eq {d N : ℕ} (p x : Fin d → ℝ) (t : ℝ) :
77    (∑ w : Fin N → Fin d, wordWeight p w * Real.exp (t * ∑ k, x (w k))) =
78      (∑ i, p i * Real.exp (t * x i)) ^ N := by
79  rw [Fintype.sum_pow]
80  apply Finset.sum_congr rfl
81  intro w _
82  rw [wordWeight, Finset.prod_mul_distrib, ← Real.exp_sum, Finset.mul_sum]
83 
84theorem word_mgf_le {d N : ℕ} (p x : Fin d → ℝ)
85    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1)
86    (hx : ∀ i, |x i| ≤ 1) (hm : ∑ i, p i * x i = 0)
87    (t : ℝ) (ht : |t| ≤ 1) :
88    (∑ w : Fin N → Fin d, wordWeight p w * Real.exp (t * ∑ k, x (w k))) ≤
89      Real.exp ((N : ℝ) * t ^ 2) := by
90  rw [word_mgf_eq]
91  calc
92    _ ≤ Real.exp (t ^ 2) ^ N := pow_le_pow_left₀
93      (Finset.sum_nonneg (fun i _ ↦ mul_nonneg (hp i) (Real.exp_pos _).le))
94      (finite_mgf_le p x hp hs hx hm t ht) N
95    _ = _ := by rw [← Real.exp_nat_mul]
96 
97/-- A one-sided bound valid uniformly in the alphabet probabilities. -/
98theorem word_tail_le {d N : ℕ} (p x : Fin d → ℝ)
99    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1)
100    (hx : ∀ i, |x i| ≤ 1) (hm : ∑ i, p i * x i = 0)
101    (ε : ℝ) (hε : 0 ≤ ε) (hε2 : ε ≤ 2) :
102    (∑ w : Fin N → Fin d,
103      if (N : ℝ) * ε ≤ ∑ k, x (w k) then wordWeight p w else 0) ≤
104      Real.exp (-(N : ℝ) * ε ^ 2 / 4) := by
105  classical
106  let t := ε / 2
107  have ht : |t| ≤ 1 := by dsimp [t]; rw [abs_of_nonneg (by positivity)]; linarith
108  have hpoint (w : Fin N → Fin d) :
109      (if (N : ℝ) * ε ≤ ∑ k, x (w k) then wordWeight p w else 0) ≤
110        Real.exp (-t * (N : ℝ) * ε) *
111          (wordWeight p w * Real.exp (t * ∑ k, x (w k))) := by
112    split_ifs with h
113    · have hexp : (1 : ℝ) ≤ Real.exp (-t * (N : ℝ) * ε + t * ∑ k, x (w k)) := by
114        apply Real.one_le_exp_iff.mpr
115        have := mul_le_mul_of_nonneg_left h (show 0 ≤ t by dsimp [t]; positivity)
116        linarith
117      have hb := mul_le_mul_of_nonneg_left hexp (wordWeight_nonneg p hp w)
118      rw [Real.exp_add] at hb
119      nlinarith
120    · exact mul_nonneg (Real.exp_pos _).le
121        (mul_nonneg (wordWeight_nonneg p hp w) (Real.exp_pos _).le)
122  calc
123    _ ≤ ∑ w : Fin N → Fin d, Real.exp (-t * (N : ℝ) * ε) *
124        (wordWeight p w * Real.exp (t * ∑ k, x (w k))) :=
125      Finset.sum_le_sum (fun w _ ↦ hpoint w)
126    _ = Real.exp (-t * (N : ℝ) * ε) *
127        (∑ w : Fin N → Fin d, wordWeight p w * Real.exp (t * ∑ k, x (w k))) :=
128      (Finset.mul_sum ..).symm
129    _ ≤ Real.exp (-t * (N : ℝ) * ε) * Real.exp ((N : ℝ) * t ^ 2) :=
130      mul_le_mul_of_nonneg_left (word_mgf_le p x hp hs hx hm t ht) (Real.exp_pos _).le
131    _ = _ := by rw [← Real.exp_add]; congr 1; dsimp [t]; ring
132 
133/-- Centered occupation indicator for one letter. -/
134def centeredIndicator {d : ℕ} (p : Fin d → ℝ) (i j : Fin d) : ℝ :=
135  (if j = i then 1 else 0) - p i
136 
137theorem probability_le_one {d : ℕ} (p : Fin d → ℝ)
138    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1) (i : Fin d) : p i ≤ 1 := by
139  rw [← hs]
140  exact Finset.single_le_sum (fun j _ ↦ hp j) (Finset.mem_univ i)
141 
142theorem centeredIndicator_abs_le {d : ℕ} (p : Fin d → ℝ)
143    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1) (i j : Fin d) :
144    |centeredIndicator p i j| ≤ 1 := by
145  have h := probability_le_one p hp hs i
146  have h0 := hp i
147  unfold centeredIndicator
148  split_ifs <;> rw [abs_le] <;> constructor <;> linarith
149 
150theorem centeredIndicator_mean {d : ℕ} (p : Fin d → ℝ)
151    (hs : ∑ i, p i = 1) (i : Fin d) :
152    ∑ j, p j * centeredIndicator p i j = 0 := by
153  classical
154  simp only [centeredIndicator, mul_sub, Finset.sum_sub_distrib]
155  rw [← Finset.sum_mul, hs]
156  simp
157 
158theorem centeredIndicator_sum {d N : ℕ} (p : Fin d → ℝ)
159    (i : Fin d) (w : Fin N → Fin d) :
160    (∑ k, centeredIndicator p i (w k)) = (rowCount w i : ℝ) - N * p i := by
161  classical
162  simp [centeredIndicator, rowCount, Finset.sum_sub_distrib, Finset.sum_boole]
163 
164/-- Two-sided deviation of one empirical frequency. -/
165theorem rowCount_tail_le {d N : ℕ} (p : Fin d → ℝ)
166    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1)
167    (ε : ℝ) (hε : 0 ≤ ε) (hε2 : ε ≤ 2) (i : Fin d) :
168    (∑ w : Fin N → Fin d,
169      if (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0) ≤
170      2 * Real.exp (-(N : ℝ) * ε ^ 2 / 4) := by
171  classical
172  let x := centeredIndicator p i
173  have hp1 := word_tail_le (N := N) p x hp hs
174    (centeredIndicator_abs_le p hp hs i) (centeredIndicator_mean p hs i) ε hε hε2
175  have hn1 := word_tail_le (N := N) p (fun j ↦ -x j) hp hs
176    (fun j ↦ by simpa using centeredIndicator_abs_le p hp hs i j)
177    (by simp only [mul_neg, Finset.sum_neg_distrib, centeredIndicator_mean p hs i, neg_zero, x])
178    ε hε hε2
179  have hpoint (w : Fin N → Fin d) :
180      (if (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0) ≤
181      (if (N : ℝ) * ε ≤ ∑ k, x (w k) then wordWeight p w else 0) +
182      (if (N : ℝ) * ε ≤ ∑ k, -x (w k) then wordWeight p w else 0) := by
183    simp only [x, centeredIndicator_sum, Finset.sum_neg_distrib]
184    have hw := wordWeight_nonneg p hp w
185    split_ifs <;> simp_all only [not_le, le_abs, neg_sub, false_or] <;> first | contradiction | linarith
186  have hsum := Finset.sum_le_sum (fun w (_ : w ∈ (Finset.univ : Finset (Fin N → Fin d))) ↦ hpoint w)
187  rw [Finset.sum_add_distrib] at hsum
188  linarith
189 
190/-- The sup-coordinate tail for the genuine IID word law, uniformly in `p`. -/
191theorem max_rowCount_tail_le {d N : ℕ} (p : Fin d → ℝ)
192    (hp : ∀ i, 0 ≤ p i) (hs : ∑ i, p i = 1)
193    (ε : ℝ) (hε : 0 ≤ ε) (hε2 : ε ≤ 2) :
194    (∑ w : Fin N → Fin d,
195      if ∃ i, (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0) ≤
196      2 * d * Real.exp (-(N : ℝ) * ε ^ 2 / 4) := by
197  classical
198  have hpoint (w : Fin N → Fin d) :
199      (if ∃ i, (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0) ≤
200      ∑ i, if (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0 := by
201    split_ifs with h
202    · obtain ⟨i, hi⟩ := h
203      have hh := Finset.single_le_sum (s := (Finset.univ : Finset (Fin d)))
204        (f := fun j ↦ if (N : ℝ) * ε ≤ |(rowCount w j : ℝ) - N * p j| then wordWeight p w else 0)
205        (fun j _ ↦ by have := wordWeight_nonneg p hp w; positivity)
206        (Finset.mem_univ i)
207      simpa only [if_pos hi] using hh
208    · exact Finset.sum_nonneg (fun i _ ↦ by have := wordWeight_nonneg p hp w; positivity)
209  calc
210    _ ≤ ∑ w : Fin N → Fin d, ∑ i,
211        if (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0 :=
212      Finset.sum_le_sum (fun w _ ↦ hpoint w)
213    _ = ∑ i, ∑ w : Fin N → Fin d,
214        if (N : ℝ) * ε ≤ |(rowCount w i : ℝ) - N * p i| then wordWeight p w else 0 :=
215      Finset.sum_comm
216    _ ≤ ∑ _i : Fin d, 2 * Real.exp (-(N : ℝ) * ε ^ 2 / 4) :=
217      Finset.sum_le_sum (fun i _ ↦ rowCount_tail_le p hp hs ε hε hε2 i)
218    _ = _ := by simp; ring
219 
220end Cloning.YoungGeneral