Offline · exact source
Exact Lean source

YoungDimensionSecondOrder

formalization/Cloning/YoungDimensionSecondOrder.lean

Source hash: a05357279e910c83c8ef63762fa8bdde50416daf29998a96c1d724b1b7c23b4a

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.YoungDimensionRatio
2import Mathlib.Algebra.Order.BigOperators.Ring.Finset
3import Mathlib.Analysis.Asymptotics.Defs
4 
5/-!
6# Second-order cancellation in Weyl dimension products
7 
8The finite-product estimate below separates the linear term from a genuinely
9quadratic remainder. This is the analytic mechanism behind the cancellation
10of centered row fluctuations in the flat-spectrum dimension ratio.
11-/
12 
13noncomputable section
14open scoped BigOperators Topology
15open Filter
16 
17namespace Cloning.YoungDimensionRatio
18 
19/-- A direct finite-product Taylor estimate. No differentiability or
20asymptotic expansion is assumed: the remainder bound follows by induction. -/
21theorem product_quadratic_remainder {ι : Type*} (S : Finset ι) (x : ι → ℝ)
22    (hx : ∀ i ∈ S, |x i| ≤ 1) :
23    |(∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i| ≤
24      (2 : ℝ) ^ S.card * (∑ i ∈ S, |x i|) ^ 2 := by
25  classical
26  induction S using Finset.induction_on with
27  | empty => simp
28  | @insert a S ha ih =>
29    have hxa := hx a (Finset.mem_insert_self a S)
30    have hxS : ∀ i ∈ S, |x i| ≤ 1 := fun i hi => hx i (Finset.mem_insert_of_mem hi)
31    have hrest := ih hxS
32    have hsum : |∑ i ∈ S, x i| ≤ ∑ i ∈ S, |x i| := Finset.abs_sum_le_sum_abs _ _
33    have hsum0 : 0 ≤ ∑ i ∈ S, |x i| := Finset.sum_nonneg (fun _ _ => abs_nonneg _)
34    have hcoef : 1 ≤ (2 : ℝ) ^ S.card := one_le_pow₀ (by norm_num)
35    have hfac : |1 + x a| ≤ 2 := by
36      calc
37        _ ≤ |(1 : ℝ)| + |x a| := abs_add_le _ _
38        _ ≤ 2 := by norm_num only [abs_one]; linarith
39    simp only [Finset.prod_insert ha, Finset.sum_insert ha, Finset.card_insert_of_notMem ha,
40      pow_succ]
41    have halg : (1 + x a) * (∏ i ∈ S, (1 + x i)) - 1 - (x a + ∑ i ∈ S, x i) =
42        (1 + x a) * ((∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i) +
43          x a * (∑ i ∈ S, x i) := by ring
44    rw [halg]
45    calc
46      _ ≤ |1 + x a| * |(∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i| +
47          |x a| * |∑ i ∈ S, x i| := by
48        simpa only [abs_mul] using abs_add_le
49          ((1 + x a) * ((∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i))
50          (x a * (∑ i ∈ S, x i))
51      _ ≤ 2 * ((2 : ℝ) ^ S.card * (∑ i ∈ S, |x i|) ^ 2) +
52          |x a| * (∑ i ∈ S, |x i|) := by
53        exact add_le_add (mul_le_mul hfac hrest (abs_nonneg _) (by norm_num))
54          (mul_le_mul_of_nonneg_left hsum (abs_nonneg _))
55      _ ≤ _ := by
56        have hcross := mul_nonneg (show 0 ≤ 4 * (2 : ℝ) ^ S.card - 1 by linarith)
57          (mul_nonneg (abs_nonneg (x a)) hsum0)
58        have hsquare := mul_nonneg (le_trans zero_le_one hcoef) (sq_nonneg |x a|)
59        nlinarith
60 
61/-- The quadratic remainder can be bounded by the Euclidean square sum. -/
62theorem product_error_le_linear_add_square_sum {ι : Type*} (S : Finset ι)
63    (x : ι → ℝ) (hx : ∀ i ∈ S, |x i| ≤ 1) :
64    |(∏ i ∈ S, (1 + x i)) - 1| ≤
65      |∑ i ∈ S, x i| + ((2 : ℝ) ^ S.card * S.card) * (∑ i ∈ S, (x i) ^ 2) := by
66  have hrem := product_quadratic_remainder S x hx
67  have hcs := Finset.sum_mul_sq_le_sq_mul_sq S (fun i => |x i|) (fun _ => (1 : ℝ))
68  simp only [mul_one, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one, sq_abs] at hcs
69  have hsplit : (∏ i ∈ S, (1 + x i)) - 1 =
70      ((∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i) + (∑ i ∈ S, x i) := by ring
71  rw [hsplit]
72  calc
73    _ ≤ |(∏ i ∈ S, (1 + x i)) - 1 - ∑ i ∈ S, x i| + |∑ i ∈ S, x i| := abs_add_le _ _
74    _ ≤ (2 : ℝ) ^ S.card * (∑ i ∈ S, |x i|) ^ 2 + |∑ i ∈ S, x i| :=
75      add_le_add hrem le_rfl
76    _ ≤ (2 : ℝ) ^ S.card * ((∑ i ∈ S, (x i) ^ 2) * S.card) + |∑ i ∈ S, x i| := by
77      exact add_le_add (mul_le_mul_of_nonneg_left hcs
78        (pow_nonneg (show (0 : ℝ) ≤ 2 by norm_num) S.card)) le_rfl
79    _ = _ := by ring
80 
81/-- Repeating a row quantity over all crossing roots multiplies its sum by
82the number of columns beyond the rank boundary. -/
83theorem sum_crossing_fst (r k : ℕ) (f : Fin r → ℝ) :
84    (∑ a : Fin r × Fin k, f a.1) = (k : ℝ) * ∑ i, f i := by
85  simp only [Fintype.sum_prod_type, Finset.sum_const, Finset.card_univ,
86    Fintype.card_fin, nsmul_eq_mul, ← Finset.mul_sum]
87 
88/-- The cancellation used below is proved from the total number of boxes. -/
89theorem sum_centered_rows (r : ℕ) (row : Fin r → ℝ) (N : ℝ)
90    (hr : 0 < r) (hboxes : ∑ i, row i = N) :
91    (∑ i, (row i - N / (r : ℝ))) = 0 := by
92  rw [Finset.sum_sub_distrib, hboxes]
93  simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]
94  have hr' : (r : ℝ) ≠ 0 := (Nat.cast_pos.mpr hr).ne'
95  field_simp
96  ring
97 
98/-- The sum of rescaled factor errors contains no centered row term. -/
99theorem crossing_error_sum (r k : ℕ) (row : Fin r → ℝ) (N : ℝ)
100    (hr : 0 < r) (hN : 0 < N) (hboxes : ∑ i, row i = N) :
101    (∑ a : Fin r × Fin k, ((r : ℝ) * (row a.1 + crossingGap a) / N - 1)) =
102      (r : ℝ) / N * ∑ a : Fin r × Fin k, crossingGap a := by
103  have hr' : (r : ℝ) ≠ 0 := (Nat.cast_pos.mpr hr).ne'
104  have heq (a : Fin r × Fin k) :
105      (r : ℝ) * (row a.1 + crossingGap a) / N - 1 =
106        (r : ℝ) / N * ((row a.1 - N / r) + crossingGap a) := by
107    field_simp
108    ring
109  simp_rw [heq]
110  rw [← Finset.mul_sum, Finset.sum_add_distrib,
111    sum_crossing_fst r k (fun i => row i - N / r),
112    sum_centered_rows r row N hr hboxes]
113  ring
114 
115theorem crossing_error_sum_bound (r k : ℕ) (row : Fin r → ℝ) (N : ℝ)
116    (hr : 0 < r) (hN : 0 < N) (hboxes : ∑ i, row i = N) :
117    |∑ a : Fin r × Fin k, ((r : ℝ) * (row a.1 + crossingGap a) / N - 1)| ≤
118      (r : ℝ) * (r * k : ℕ) * ((r : ℝ) + k) / N := by
119  rw [crossing_error_sum r k row N hr hN hboxes]
120  have hg0 : 0 ≤ ∑ a : Fin r × Fin k, crossingGap a :=
121    Finset.sum_nonneg (fun a _ => (crossingGap_pos a).le)
122  rw [abs_of_nonneg (mul_nonneg (div_nonneg (Nat.cast_nonneg _) hN.le) hg0)]
123  have hg : (∑ a : Fin r × Fin k, crossingGap a) ≤
124      (r * k : ℕ) * ((r : ℝ) + k) := by
125    calc
126      _ ≤ ∑ _a : Fin r × Fin k, ((r : ℝ) + k) :=
127        Finset.sum_le_sum (fun a _ => crossingGap_le a)
128      _ = _ := by simp [Fintype.card_prod]; ring
129  calc
130    _ ≤ (r : ℝ) / N * ((r * k : ℕ) * ((r : ℝ) + k)) :=
131      mul_le_mul_of_nonneg_left hg (div_nonneg (Nat.cast_nonneg _) hN.le)
132    _ = _ := by ring
133 
134/-- A bound on the second moment of all rescaled factors, in terms of the
135actual squared row fluctuations. -/
136theorem crossing_error_square_sum_bound (r k : ℕ) (row : Fin r → ℝ) (N : ℝ)
137    (hr : 0 < r) (hN : 0 < N) :
138    (∑ a : Fin r × Fin k, ((r : ℝ) * (row a.1 + crossingGap a) / N - 1) ^ 2) ≤
139      2 * (r : ℝ) ^ 2 / N ^ 2 *
140        ((k : ℝ) * (∑ i, (row i - N / r) ^ 2) +
141          (r * k : ℕ) * ((r : ℝ) + k) ^ 2) := by
142  have hr' : (r : ℝ) ≠ 0 := (Nat.cast_pos.mpr hr).ne'
143  have hb (a : Fin r × Fin k) :
144      ((r : ℝ) * (row a.1 + crossingGap a) / N - 1) ^ 2 ≤
145        2 * (r : ℝ) ^ 2 / N ^ 2 *
146          ((row a.1 - N / r) ^ 2 + ((r : ℝ) + k) ^ 2) := by
147    have hg := crossingGap_le a
148    have hg0 := (crossingGap_pos a).le
149    have hd0 : 0 ≤ (r : ℝ) + k := add_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)
150    have hg2 : crossingGap a ^ 2 ≤ ((r : ℝ) + k) ^ 2 :=
151      sq_le_sq₀ hg0 hd0 |>.mpr hg
152    have hab : ((row a.1 - N / r) + crossingGap a) ^ 2 ≤
153        2 * ((row a.1 - N / r) ^ 2 + ((r : ℝ) + k) ^ 2) := by
154      nlinarith [sq_nonneg ((row a.1 - N / r) - crossingGap a)]
155    have heq : ((r : ℝ) * (row a.1 + crossingGap a) / N - 1) ^ 2 =
156        ((r : ℝ) ^ 2 / N ^ 2) * ((row a.1 - N / r) + crossingGap a) ^ 2 := by
157      field_simp
158      ring
159    rw [heq]
160    calc
161      _ ≤ ((r : ℝ) ^ 2 / N ^ 2) *
162          (2 * ((row a.1 - N / r) ^ 2 + ((r : ℝ) + k) ^ 2)) :=
163        mul_le_mul_of_nonneg_left hab (div_nonneg (sq_nonneg _) (sq_nonneg _))
164      _ = _ := by ring
165  calc
166    _ ≤ ∑ a : Fin r × Fin k, 2 * (r : ℝ) ^ 2 / N ^ 2 *
167        ((row a.1 - N / r) ^ 2 + ((r : ℝ) + k) ^ 2) :=
168      Finset.sum_le_sum (fun a _ => hb a)
169    _ = _ := by
170      rw [← Finset.mul_sum, Finset.sum_add_distrib,
171        sum_crossing_fst r k (fun i => (row i - N / r) ^ 2)]
172      simp [Fintype.card_prod]
173 
174/-- The manuscript's second-order expansion, with explicit uniform constants.
175The only cancellation hypothesis is the actual box count `∑ row = N`.
176The proximity assumptions only ensure that every factor error is at most one. -/
177theorem dimensionRatio_second_order_error (r k : ℕ) (row : Fin r → ℝ) (N δ : ℝ)
178    (hr : 0 < r) (hN : 0 < N) (hboxes : ∑ i, row i = N)
179    (hclose : ∀ i, |row i / N - 1 / (r : ℝ)| ≤ δ)
180    (hsmall : (r : ℝ) * δ + (r : ℝ) * ((r : ℝ) + k) / N ≤ 1) :
181    |dimensionRatio r k row / (leadingConstant r k * N ^ (r * k)) - 1| ≤
182      (r : ℝ) * (r * k : ℕ) * ((r : ℝ) + k) / N +
183      ((2 : ℝ) ^ (r * k) * (r * k : ℕ)) *
184        (2 * (r : ℝ) ^ 2 / N ^ 2 *
185          ((k : ℝ) * (∑ i, (row i - N / r) ^ 2) +
186            (r * k : ℕ) * ((r : ℝ) + k) ^ 2)) := by
187  let x : Fin r × Fin k → ℝ :=
188    fun a => (r : ℝ) * (row a.1 + crossingGap a) / N - 1
189  have hx : ∀ a ∈ Finset.univ, |x a| ≤ 1 := by
190    intro a _
191    exact (rescaled_factor_error r k row N δ hr hN hclose a).trans hsmall
192  have hp := product_error_le_linear_add_square_sum Finset.univ x hx
193  have hden : leadingConstant r k * N ^ (r * k) ≠ 0 :=
194    (mul_pos (leadingConstant_pos r k hr) (pow_pos hN _)).ne'
195  have hx1 (a : Fin r × Fin k) : 1 + x a =
196      (r : ℝ) * (row a.1 + crossingGap a) / N := by dsimp [x]; ring
197  simp only [Finset.card_univ, Fintype.card_prod, Fintype.card_fin, hx1] at hp
198  rw [dimensionRatio_factorization r k row N hr hN, mul_div_cancel_left₀ _ hden]
199  exact hp.trans (add_le_add (crossing_error_sum_bound r k row N hr hN hboxes)
200    (mul_le_mul_of_nonneg_left (crossing_error_square_sum_bound r k row N hr hN)
201      (mul_nonneg (pow_nonneg (by norm_num) _) (Nat.cast_nonneg _))))
202 
203private theorem second_order_envelope_le (A B C V N : ℝ)
204    (hA : 0 ≤ A) (hB : 0 ≤ B) (hC : 0 ≤ C) (hV : 0 ≤ V) (hN : 1 ≤ N) :
205    A / N + B * V / N ^ 2 + C / N ^ 2 ≤
206      (A + B + C) * (1 / N + V / N ^ 2) := by
207  have hN0 : 0 < N := lt_of_lt_of_le zero_lt_one hN
208  have hNN : N ≤ N ^ 2 := by nlinarith
209  have hinv : 1 / N ^ 2 ≤ 1 / N := one_div_le_one_div_of_le hN0 hNN
210  have hCdiv : C / N ^ 2 ≤ C / N := by
211    simpa only [mul_one_div] using mul_le_mul_of_nonneg_left hinv hC
212  calc
213    _ ≤ A / N + B * V / N ^ 2 + C / N := add_le_add le_rfl hCdiv
214    _ = (A + C) * (1 / N) + B * (V / N ^ 2) := by ring
215    _ ≤ (A + B + C) * (1 / N) + (A + B + C) * (V / N ^ 2) := by
216      exact add_le_add
217        (mul_le_mul_of_nonneg_right (by linarith) (one_div_nonneg.mpr hN0.le))
218        (mul_le_mul_of_nonneg_right (by linarith) (div_nonneg hV (sq_nonneg _)))
219    _ = _ := by ring
220 
221/-- An explicit constant depending only on rank and ambient dimension. -/
222def secondOrderConstant (r k : ℕ) : ℝ :=
223  (r : ℝ) * (r * k : ℕ) * ((r : ℝ) + k) +
224    (2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 * k +
225    (2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 *
226      (r * k : ℕ) * ((r : ℝ) + k) ^ 2
227 
228theorem secondOrderConstant_nonneg (r k : ℕ) : 0 ≤ secondOrderConstant r k := by
229  unfold secondOrderConstant
230  positivity
231 
232/-- The precise manuscript rate `O(1/N + ‖u‖²/N²)`, as a uniform explicit
233inequality. Here `uᵢ = rowᵢ - N/r` and the constant depends only on `r,k`.
234No representation-dimension identification is asserted by this analytic result. -/
235theorem dimensionRatio_second_order_rate (r k : ℕ) (row : Fin r → ℝ) (N δ : ℝ)
236    (hr : 0 < r) (hN : 1 ≤ N) (hboxes : ∑ i, row i = N)
237    (hclose : ∀ i, |row i / N - 1 / (r : ℝ)| ≤ δ)
238    (hsmall : (r : ℝ) * δ + (r : ℝ) * ((r : ℝ) + k) / N ≤ 1) :
239    |dimensionRatio r k row / (leadingConstant r k * N ^ (r * k)) - 1| ≤
240      secondOrderConstant r k *
241        (1 / N + (∑ i, (row i - N / r) ^ 2) / N ^ 2) := by
242  have hN0 : 0 < N := lt_of_lt_of_le zero_lt_one hN
243  have hbound := dimensionRatio_second_order_error r k row N δ hr hN0 hboxes hclose hsmall
244  have henv := second_order_envelope_le
245    ((r : ℝ) * (r * k : ℕ) * ((r : ℝ) + k))
246    ((2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 * k)
247    ((2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 *
248      (r * k : ℕ) * ((r : ℝ) + k) ^ 2)
249    (∑ i, (row i - N / r) ^ 2) N
250    (by positivity) (by positivity) (by positivity)
251    (Finset.sum_nonneg (fun i _ => sq_nonneg _)) hN
252  apply hbound.trans
253  calc
254    _ = (r : ℝ) * (r * k : ℕ) * ((r : ℝ) + k) / N +
255        ((2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 * k) *
256          (∑ i, (row i - N / r) ^ 2) / N ^ 2 +
257        ((2 : ℝ) ^ (r * k) * (r * k : ℕ) * 2 * (r : ℝ) ^ 2 *
258          (r * k : ℕ) * ((r : ℝ) + k) ^ 2) / N ^ 2 := by ring
259    _ ≤ _ := henv
260 
261/-- The same estimate in Landau notation. The small-factor condition is now
262derived, rather than assumed, from convergence of the actual row proportions. -/
263theorem dimensionRatio_second_order_isBigO (r k : ℕ) (hr : 0 < r)
264    (row : ℕ → Fin r → ℝ) (N δ : ℕ → ℝ)
265    (hN : Tendsto N atTop atTop) (hδ : Tendsto δ atTop (𝓝 0))
266    (hboxes : ∀ n, ∑ i, row n i = N n)
267    (hclose : ∀ n i, |row n i / N n - 1 / (r : ℝ)| ≤ δ n) :
268    Asymptotics.IsBigO atTop
269      (fun n => dimensionRatio r k (row n) /
270        (leadingConstant r k * (N n) ^ (r * k)) - 1)
271      (fun n => 1 / N n + (∑ i, (row n i - N n / r) ^ 2) / (N n) ^ 2) := by
272  have hinv : Tendsto (fun n => (N n)⁻¹) atTop (𝓝 (0 : ℝ)) :=
273    tendsto_inv_atTop_zero.comp hN
274  have harg : Tendsto
275      (fun n => (r : ℝ) * δ n + (r : ℝ) * ((r : ℝ) + k) / N n)
276      atTop (𝓝 (0 : ℝ)) := by
277    simpa only [div_eq_mul_inv, mul_zero, add_zero] using
278      (((tendsto_const_nhds (x := (r : ℝ))).mul hδ).add
279        ((tendsto_const_nhds (x := (r : ℝ) * ((r : ℝ) + k))).mul hinv))
280  have hsmall : ∀ᶠ n in atTop,
281      (r : ℝ) * δ n + (r : ℝ) * ((r : ℝ) + k) / N n < 1 :=
282    harg.eventually (eventually_lt_nhds zero_lt_one)
283  have hNlarge : ∀ᶠ n in atTop, 1 ≤ N n := hN.eventually (eventually_ge_atTop 1)
284  apply Asymptotics.IsBigO.of_bound (secondOrderConstant r k)
285  filter_upwards [hNlarge, hsmall] with n hn hs
286  have hrate := dimensionRatio_second_order_rate r k (row n) (N n) (δ n)
287    hr hn (hboxes n) (hclose n) hs.le
288  have hnonneg : 0 ≤ 1 / N n + (∑ i, (row n i - N n / r) ^ 2) / (N n) ^ 2 :=
289    add_nonneg (one_div_nonneg.mpr (le_trans zero_le_one hn))
290      (div_nonneg (Finset.sum_nonneg (fun i _ => sq_nonneg _)) (sq_nonneg _))
291  simpa only [Real.norm_eq_abs, abs_of_nonneg hnonneg] using hrate
292 
293end Cloning.YoungDimensionRatio