Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.Quantitative

Download original .lean · View on GitHub · Jump to source

Direct imports

  • Mathlib.Analysis.Complex.ExponentialBounds dependency
  • Mathlib.Analysis.SpecialFunctions.Pow.Real dependency
  • Mathlib.Tactic.Linarith dependency
  • Mathlib.Tactic.NormNum dependency
  • Mathlib.Tactic.FieldSimp dependency
  • Mathlib.Tactic.Ring dependency
  • Mathlib.Tactic.Positivity dependency

Imported by project modules

4 direct reverse imports

Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.

Declarations in this module

80 project constants, including generated, internal and private declarations.

80 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Mathlib.Analysis.Complex.ExponentialBounds7import Mathlib.Analysis.SpecialFunctions.Pow.Real8import Mathlib.Tactic.Linarith9import Mathlib.Tactic.NormNum10import Mathlib.Tactic.FieldSimp11import Mathlib.Tactic.Ring12import Mathlib.Tactic.Positivity1314/-!15# Exact scalar estimates in the quantitative approximation argument1617This file proves scalar estimates from the appendix of `nonadditivity.tex`.18All constants and inequalities below are checked by Lean.  Operator-algebraic19and random-matrix input is deliberately kept separate from these estimates.20-/2122namespace Nonadditivity.Quantitative2324noncomputable section2526open Real2728/-- A degree twelve Taylor term suffices to control every exponential tail29used in the appendix.  This avoids using unformalized derivative arguments. -/30theorem exp_dominates_power {x b C : ℝ} (k : ℕ) (hk : k ≤ 12)31    (hx : 64 ≤ x) (hb : 0 ≤ b)32    (hC : 64 * C * (Nat.factorial 12 : ℝ) ≤ b ^ 12 * 64 ^ (12 - k)) :33    64 * C * x ^ k ≤ Real.exp (b * x) := by34  have hx0 : 0 ≤ x := by linarith35  have hpower : (64 : ℝ) ^ (12 - k) ≤ x ^ (12 - k) :=36    pow_le_pow_left₀ (by norm_num) hx _37  have hcoeff : 64 * C * (Nat.factorial 12 : ℝ) ≤ b ^ 12 * x ^ (12 - k) :=38    hC.trans (mul_le_mul_of_nonneg_left hpower (pow_nonneg hb _))39  have hmul := mul_le_mul_of_nonneg_right hcoeff (pow_nonneg hx0 k)40  have hp : x ^ (12 - k) * x ^ k = x ^ 12 := by41    rw [← pow_add, Nat.sub_add_cancel hk]42  have hf : (0 : ℝ) < Nat.factorial 12 := by norm_num43  calc44    64 * C * x ^ k ≤ (b * x) ^ 12 / (Nat.factorial 12 : ℝ) := by45      apply (le_div_iff₀ hf).246      calc47        64 * C * x ^ k * (Nat.factorial 12 : ℝ) =48            64 * C * (Nat.factorial 12 : ℝ) * x ^ k := by ring49        _ ≤ b ^ 12 * x ^ (12 - k) * x ^ k := hmul50        _ = (b * x) ^ 12 := by rw [mul_assoc, hp, mul_pow]51    _ ≤ Real.exp (b * x) :=52      Real.pow_div_factorial_le_exp (b * x) (mul_nonneg hb hx0) 125354theorem exponential_tail_le {x b C : ℝ} (k : ℕ) (hk : k ≤ 12)55    (hx : 64 ≤ x) (hb : 0 ≤ b)56    (hC : 64 * C * (Nat.factorial 12 : ℝ) ≤ b ^ 12 * 64 ^ (12 - k)) :57    C * x ^ k * Real.exp (-(b * x)) ≤ (1 : ℝ) / 64 := by58  have h := exp_dominates_power k hk hx hb hC59  rw [Real.exp_neg, ← div_eq_mul_inv]60  apply (div_le_iff₀ (Real.exp_pos _)).261  linarith6263/-- The precise three-tail expression occurring in the final norm error. -/64def tailBound (n : ℝ) : ℝ :=65  12 * n ^ 3 * Real.exp (-n / 2) +66    1494 * n ^ 4 * Real.exp (-3 * n / 2) + n ^ 2 * Real.exp (-n)6768theorem final_three_tails_lt {n : ℝ} (hn : 64 ≤ n) : tailBound n < 1 / 16 := by69  have h₁ := exponential_tail_le (x := n) (b := (1 : ℝ) / 2)70    (C := 12) 3 (by norm_num) hn (by norm_num) (by norm_num)71  have h₂ := exponential_tail_le (x := n) (b := (3 : ℝ) / 2)72    (C := 1494) 4 (by norm_num) hn (by norm_num) (by norm_num)73  have h₃ := exponential_tail_le (x := n) (b := (1 : ℝ))74    (C := 1) 2 (by norm_num) hn (by norm_num) (by norm_num)75  have he₁ : -((1 : ℝ) / 2 * n) = -n / 2 := by ring76  have he₂ : -((3 : ℝ) / 2 * n) = -3 * n / 2 := by ring77  simp only [he₁] at h₁78  simp only [he₂] at h₂79  simp only [one_mul] at h₃80  dsimp [tailBound]81  linarith8283def gamma (h : ℝ) : ℝ := 3 / 2 * h + 1 / 284def zeta (h : ℝ) : ℝ := 2 * h + 1 / 285def dimensionExponent (h : ℝ) : ℝ := 40 * (7 * h + 2)86def tolerance (h n : ℝ) : ℝ := Real.exp (-(gamma h * n)) / n87def dimensionChoice (h n : ℝ) : ℕ := ⌈Real.exp (dimensionExponent h * n)⌉₊88def momentChoice (t : ℝ) : ℕ := 2 * ⌊t / 4⌋₊8990theorem parameter_alignment (h : ℝ) :91    dimensionExponent h / 80 = gamma h + zeta h := by92  dsimp [dimensionExponent, gamma, zeta]93  ring9495theorem dimensionExponent_le {h : ℝ} (hh : 0 ≤ h) :96    dimensionExponent h ≤ 160 * zeta h := by97  dsimp [dimensionExponent, zeta]98  linarith99100theorem coefficient_exponent_alignment (h : ℝ) :101    2 * h + gamma h - dimensionExponent h / 80 = -(1 / 2 : ℝ) := by102  dsimp [dimensionExponent, gamma]103  ring104105theorem remainder_exponent_gap {h : ℝ} (hh : 0 ≤ h) :106    1 ≤ dimensionExponent h / 2 - gamma h := by107  dsimp [dimensionExponent, gamma]108  linarith109110theorem dimension_choice_bounds {h n : ℝ} (hh : 0 ≤ h) (hn : 0 ≤ n) :111    Real.exp (dimensionExponent h * n) ≤ (dimensionChoice h n : ℝ) ∧112    (dimensionChoice h n : ℝ) ≤ 2 * Real.exp (dimensionExponent h * n) := by113  have hb : 0 ≤ dimensionExponent h := by dsimp [dimensionExponent]; positivity114  have he : 1 ≤ Real.exp (dimensionExponent h * n) :=115    Real.one_le_exp_iff.mpr (mul_nonneg hb hn)116  refine ⟨Nat.le_ceil _, ?_⟩117  have hc := Nat.ceil_lt_add_one (Real.exp_pos (dimensionExponent h * n)).le118  dsimp [dimensionChoice]119  linarith120121theorem dimension_choice_log_bounds {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)122    (hn : 2 ≤ n) :123    dimensionExponent h * n ≤ Real.log (dimensionChoice h n : ℝ) ∧124    Real.log (dimensionChoice h n : ℝ) ≤ 2 * dimensionExponent h * n := by125  have hh0 : 0 ≤ h := by linarith126  have hn0 : 0 ≤ n := by linarith127  obtain ⟨hlo, hhi⟩ := dimension_choice_bounds hh0 hn0128  have hNpos : 0 < (dimensionChoice h n : ℝ) := (Real.exp_pos _).trans_le hlo129  have hl := Real.log_le_log (Real.exp_pos _) hlo130  rw [Real.log_exp] at hl131  have hu := Real.log_le_log hNpos hhi132  rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] at hu133  have hb : 80 ≤ dimensionExponent h := by dsimp [dimensionExponent]; linarith134  have hbn : 160 ≤ dimensionExponent h * n := by135    nlinarith [mul_nonneg (show 0 ≤ dimensionExponent h - 80 by linarith) hn0]136  refine ⟨hl, ?_⟩137  linarith [Real.log_two_lt_d9]138139theorem dimension_choice_log_upper {h n : ℝ} (hh : 0 ≤ h) (hn : 0 ≤ n) :140    Real.log (dimensionChoice h n : ℝ) ≤ dimensionExponent h * n + Real.log 2 := by141  obtain ⟨hlo, hhi⟩ := dimension_choice_bounds hh hn142  have hNpos : 0 < (dimensionChoice h n : ℝ) := (Real.exp_pos _).trans_le hlo143  have hu := Real.log_le_log hNpos hhi144  rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] at hu145  linarith146147theorem moment_choice_bounds {t : ℝ} (ht : 8 ≤ t) :148    Even (momentChoice t) ∧ 2 ≤ momentChoice t ∧149    t / 4 ≤ (momentChoice t : ℝ) ∧ (momentChoice t : ℝ) ≤ t / 2 := by150  have ht0 : 0 ≤ t / 4 := by linarith151  have hf := Nat.floor_le ht0152  have hg := Nat.sub_one_lt_floor (t / 4)153  have hn : 1 ≤ ⌊t / 4⌋₊ := (Nat.one_le_floor_iff _).2 (by linarith)154  dsimp [momentChoice]155  refine ⟨even_two_mul _, by omega, ?_, ?_⟩ <;>156    simp only [Nat.cast_mul, Nat.cast_ofNat] <;> linarith157158/-- `exp (log N / 80)` is exactly `N^(1/80)` for positive `N`. -/159def momentParameter (h n : ℝ) : ℕ :=160  momentChoice (Real.exp (Real.log (dimensionChoice h n : ℝ) / 80))161162theorem moment_parameter_bounds {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)163    (hn : 2 ≤ n) :164    Even (momentParameter h n) ∧ 2 ≤ momentParameter h n ∧165    (Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) / 4 ≤166      (momentParameter h n : ℝ)) ∧167    ((momentParameter h n : ℝ) ≤168      Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) / 2) := by169  obtain ⟨hN, _⟩ := dimension_choice_log_bounds hh hn170  have hb : 80 * (10 : ℝ) / 3 ≤ dimensionExponent h := by171    dsimp [dimensionExponent]172    linarith173  have hn0 : 0 ≤ n := by linarith174  have hbig : 6 ≤ Real.log (dimensionChoice h n : ℝ) / 80 := by175    have hm := mul_le_mul_of_nonneg_right hb hn0176    nlinarith177  have he : Real.exp 6 ≤ Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) :=178    Real.exp_le_exp.mpr hbig179  have h6 := Real.pow_div_factorial_le_exp (6 : ℝ) (by norm_num) 2180  norm_num at h6181  have ht : 8 ≤ Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) := by linarith182  exact moment_choice_bounds ht183184theorem moment_parameter_inverse_bound {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)185    (hn : 2 ≤ n) :186    1 / (momentParameter h n : ℝ) ≤187      4 * Real.exp (-(dimensionExponent h * n / 80)) := by188  obtain ⟨_, hp, hlo, _⟩ := moment_parameter_bounds hh hn189  have hp0 : (0 : ℝ) < momentParameter h n := by exact_mod_cast (by omega : 0 < momentParameter h n)190  obtain ⟨hN, _⟩ := dimension_choice_log_bounds hh hn191  have he := Real.exp_le_exp.mpr (show dimensionExponent h * n / 80 ≤192    Real.log (dimensionChoice h n : ℝ) / 80 by linarith)193  have hlow : Real.exp (dimensionExponent h * n / 80) / 4 ≤194      (momentParameter h n : ℝ) := (div_le_div_of_nonneg_right he (by norm_num)).trans hlo195  have hbound : 1 / (momentParameter h n : ℝ) ≤196      1 / (Real.exp (dimensionExponent h * n / 80) / 4) :=197    one_div_le_one_div_of_le (by positivity) hlow198  rw [Real.exp_neg]199  convert hbound using 1200  field_simp201202theorem moment_parameter_log_bound {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)203    (hn : 2 ≤ n) :204    Real.log (momentParameter h n : ℝ) ≤205      Real.log (dimensionChoice h n : ℝ) / 80 := by206  obtain ⟨_, hp, _, hhi⟩ := moment_parameter_bounds hh hn207  have hp0 : (0 : ℝ) < momentParameter h n := by exact_mod_cast (by omega : 0 < momentParameter h n)208  have he := Real.exp_pos (Real.log (dimensionChoice h n : ℝ) / 80)209  have hle : (momentParameter h n : ℝ) ≤210      Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) := by linarith211  have hl := Real.log_le_log hp0 hle212  simpa only [Real.log_exp] using hl213214theorem remainder_log_bound {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)215    (hn : 2 ≤ n) :216    Real.log (1 + Real.exp (-(Real.log (dimensionChoice h n : ℝ) / 2))) ≤217      Real.exp (-(dimensionExponent h * n / 2)) := by218  have he := Real.exp_pos (-(Real.log (dimensionChoice h n : ℝ) / 2))219  have hl := Real.log_le_sub_one_of_pos (show 0 < 1 +220    Real.exp (-(Real.log (dimensionChoice h n : ℝ) / 2)) by linarith)221  obtain ⟨hN, _⟩ := dimension_choice_log_bounds hh hn222  have hm := Real.exp_le_exp.mpr (show223    -(Real.log (dimensionChoice h n : ℝ) / 2) ≤ -(dimensionExponent h * n / 2) by linarith)224  linarith225226theorem dimension_rpow_eq_exp (h n : ℝ) :227    (dimensionChoice h n : ℝ) ^ (1 / 80 : ℝ) =228      Real.exp (Real.log (dimensionChoice h n : ℝ) / 80) := by229  have hp : 0 < (dimensionChoice h n : ℝ) :=230    (Real.exp_pos _).trans_le (Nat.le_ceil _)231  rw [Real.rpow_def_of_pos hp]232  congr 1233  ring234235theorem moment_parameter_eq_original (h n : ℝ) :236    momentParameter h n =237      2 * ⌊((dimensionChoice h n : ℝ) ^ (1 / 80 : ℝ)) / 4⌋₊ := by238  rw [dimension_rpow_eq_exp]239  rfl240241theorem moment_parameter_haar_range {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)242    (hn : 2 ≤ n) :243    Even (momentParameter h n) ∧ 2 ≤ momentParameter h n ∧244    (momentParameter h n : ℝ) ≤245      (2 : ℝ) ^ (-(2 / 5 : ℝ)) * (dimensionChoice h n : ℝ) ^ (1 / 80 : ℝ) := by246  obtain ⟨heven, hp, _, hhi⟩ := moment_parameter_bounds hh hn247  have hhalf : (1 : ℝ) / 2 ≤ (2 : ℝ) ^ (-(2 / 5 : ℝ)) := by248    have he := Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 2)249      (by norm_num : (-1 : ℝ) ≤ -(2 / 5 : ℝ))250    simpa only [Real.rpow_neg_one, one_div] using he251  have hm := mul_le_mul_of_nonneg_right hhalf252    (Real.exp_pos (Real.log (dimensionChoice h n : ℝ) / 80)).le253  rw [dimension_rpow_eq_exp]254  refine ⟨heven, hp, ?_⟩255  linarith256257theorem tolerance_pos {h n : ℝ} (hn : 0 < n) : 0 < tolerance h n :=258  div_pos (Real.exp_pos _) hn259260theorem tolerance_lt_one {h n : ℝ} (hh : 0 ≤ h) (hn : 2 ≤ n) :261    tolerance h n < 1 := by262  have hn0 : 0 < n := by linarith263  have hg : 0 ≤ gamma h := by dsimp [gamma]; linarith264  have he : Real.exp (-(gamma h * n)) ≤ 1 :=265    (Real.exp_le_one_iff).2 (neg_nonpos.mpr (mul_nonneg hg hn0.le))266  dsimp [tolerance]267  apply (div_lt_iff₀ hn0).2268  linarith269270/-- Tangency of the logarithm, applied to the square root. -/271theorem log_le_twice_sqrt_sub_one {t : ℝ} (ht : 0 < t) :272    Real.log t ≤ 2 * (Real.sqrt t - 1) := by273  have hs := Real.sqrt_pos.2 ht274  have hl := Real.log_le_sub_one_of_pos hs275  calc276    Real.log t = Real.log (Real.sqrt t ^ 2) :=277      congrArg Real.log (Real.sq_sqrt ht.le).symm278    _ = 2 * Real.log (Real.sqrt t) := by rw [Real.log_pow]; norm_num279    _ ≤ 2 * (Real.sqrt t - 1) := by linarith280281theorem threshold_base_log {y : ℝ} (hy : (5 : ℝ) / 3 ≤ y) :282    y + Real.log (256 * y ^ 2) ≤ 5 * y := by283  have hy0 : 0 < y := by linarith284  have hl := Real.log_le_sub_one_of_pos (div_pos hy0 (by norm_num : (0 : ℝ) < 2))285  rw [Real.log_div hy0.ne' (by norm_num)] at hl286  have h2 : Real.log 2 < (7 : ℝ) / 10 :=287    Real.log_two_lt_d9.trans (by norm_num)288  have h256 : Real.log (256 : ℝ) = 8 * Real.log 2 := by289    have he : (256 : ℝ) = 2 ^ (8 : ℕ) := by norm_num290    rw [he, Real.log_pow]291    norm_num292  rw [Real.log_mul (by norm_num) (pow_ne_zero _ hy0.ne'), h256, Real.log_pow]293  norm_num294  linarith295296/-- The threshold absorption estimate (equation `threshold-absorption`).297The proof uses an elementary logarithm inequality in place of monotonicity298of `x / (y + log x)^2`. -/299theorem threshold_absorption {y n : ℝ} (hy : (5 : ℝ) / 3 ≤ y)300    (hn : 256 * y ^ 2 ≤ n) :301    (y + Real.log n) ^ 2 ≤ (25 : ℝ) / 256 * n := by302  have hy0 : 0 < y := by linarith303  have hx0 : 0 < 256 * y ^ 2 := by positivity304  have hn0 : 0 < n := hx0.trans_le hn305  have hr : 1 ≤ n / (256 * y ^ 2) := by306    apply (le_div_iff₀ hx0).2307    simpa using hn308  have hr0 : 0 < n / (256 * y ^ 2) := by linarith309  have hs1 : 1 ≤ Real.sqrt (n / (256 * y ^ 2)) := by310    exact (Real.le_sqrt (by norm_num) hr0.le).2 (by simpa using hr)311  have hlog := log_le_twice_sqrt_sub_one hr0312  rw [Real.log_div hn0.ne' hx0.ne'] at hlog313  have hbase := threshold_base_log hy314  have hprod : 0 ≤ (5 * y - 2) * (Real.sqrt (n / (256 * y ^ 2)) - 1) :=315    mul_nonneg (by linarith) (by linarith)316  have hub : y + Real.log n ≤ 5 * y * Real.sqrt (n / (256 * y ^ 2)) := by317    nlinarith318  have hn1 : 1 ≤ n := by nlinarith [sq_nonneg (y - 5 / 3)]319  have hu0 : 0 ≤ y + Real.log n := add_nonneg hy0.le (Real.log_nonneg hn1)320  have hsq := sq_le_sq₀ hu0 (by positivity : 0 ≤ 5 * y * Real.sqrt (n / (256 * y ^ 2)))321  have hsquare : (5 * y * Real.sqrt (n / (256 * y ^ 2))) ^ 2 =322      (25 : ℝ) / 256 * n := by323    rw [mul_pow, Real.sq_sqrt hr0.le]324    field_simp325    ring326  rw [← hsquare]327  exact hsq.2 hub328329/-- The two numerical absorptions used for the total error factor and330matrix coefficient cost, with the manuscript's exact constants. -/331theorem error_cost_absorption {u n : ℝ} (hu : (15 : ℝ) / 2 ≤ u)332    (hn : u ^ 2 ≤ (25 : ℝ) / 256 * n) :333    7 / 4 * u ^ 2 + 14 * u < n / 2 := by334  have hquad : 14 * u ≤ (28 : ℝ) / 15 * u ^ 2 := by335    nlinarith336  have hn0 : 0 < n := by nlinarith337  nlinarith338339theorem coefficient_cost_absorption {u n : ℝ} (hu : (15 : ℝ) / 2 ≤ u)340    (hn : u ^ 2 ≤ (25 : ℝ) / 256 * n) :341    7 / 4 * u ^ 2 + 21 / 2 * u < n / 3 := by342  have hquad : 21 / 2 * u ≤ (7 : ℝ) / 5 * u ^ 2 := by343    nlinarith344  have hn0 : 0 < n := by nlinarith345  nlinarith346347/-- The paper's explicit integer threshold, with natural-number ceiling. -/348def n₀ (K : ℕ) : ℕ := ⌈256 * (1 + Real.log (K : ℝ)) ^ 2⌉₊349350theorem threshold_consequences {K n : ℕ} (hK : 2 ≤ K) (hn : n₀ K ≤ n) :351    (0 ≤ Real.log (K : ℝ)) ∧352    ((64 : ℝ) ≤ n) ∧353    ((15 : ℝ) / 2 ≤ 1 + Real.log (K : ℝ) + Real.log (n : ℝ)) ∧354    ((1 + Real.log (K : ℝ) + Real.log (n : ℝ)) ^ 2 ≤355      (25 : ℝ) / 256 * n) := by356  have hKreal : (2 : ℝ) ≤ K := by exact_mod_cast hK357  have hlogK := Real.log_le_log (by norm_num : (0 : ℝ) < 2) hKreal358  have hh : (2 : ℝ) / 3 ≤ Real.log (K : ℝ) := by359    linarith [Real.log_two_gt_d9]360  have hy : (5 : ℝ) / 3 ≤ 1 + Real.log (K : ℝ) := by linarith361  have hbase : 256 * (1 + Real.log (K : ℝ)) ^ 2 ≤ (n : ℝ) := by362    exact (Nat.le_ceil _).trans (by exact_mod_cast hn)363  have hn512 : (512 : ℝ) ≤ n := by364    nlinarith [sq_nonneg (1 + Real.log (K : ℝ) - 5 / 3)]365  have hv0 := Real.log_le_log (by norm_num : (0 : ℝ) < 512) hn512366  have h512 : Real.log (512 : ℝ) = 9 * Real.log 2 := by367    have he : (512 : ℝ) = 2 ^ (9 : ℕ) := by norm_num368    rw [he, Real.log_pow]369    norm_num370  rw [h512] at hv0371  have hv : 6 ≤ Real.log (n : ℝ) := by linarith [Real.log_two_gt_d9]372  refine ⟨by linarith, by linarith, by linarith, ?_⟩373  exact threshold_absorption hy hbase374375/-- Summed support estimates imply the total relative-error logarithm376bound.  The premises are the distinct elementary support/counting estimates,377not the desired final error estimate. -/378theorem reduction_error_log_bound {h n u initial overhead tensor shortening : ℝ}379    (hu : (15 : ℝ) / 2 ≤ u)380    (hthreshold : u ^ 2 ≤ (25 : ℝ) / 256 * n)381    (hinitial : initial ≤ n * h / 2 + u)382    (hoverhead : overhead ≤ 5 * u)383    (htensor : tensor ≤ n * h + 3 / 4 * u ^ 2 + 2 * u)384    (hshortening : shortening ≤ u ^ 2 + 6 * u) :385    initial + overhead + tensor + shortening < gamma h * n := by386  have ha := error_cost_absorption hu hthreshold387  dsimp [gamma]388  nlinarith389390theorem reduction_coefficient_log_bound {h n u overhead tensor shortening : ℝ}391    (hu : (15 : ℝ) / 2 ≤ u)392    (hthreshold : u ^ 2 ≤ (25 : ℝ) / 256 * n)393    (hoverhead : overhead ≤ 5 / 2 * u)394    (htensor : tensor ≤ n * h + 3 / 4 * u ^ 2 + 2 * u)395    (hshortening : shortening ≤ u ^ 2 + 6 * u) :396    overhead + tensor + shortening < n * h + n / 3 := by397  have ha := coefficient_cost_absorption hu hthreshold398  nlinarith399400theorem log_one_add_two_mul_le {n : ℝ} (hn : 2 ≤ n) :401    Real.log (1 + 2 * n) ≤ n := by402  have hn0 : 0 ≤ n := by linarith403  have hs := Real.sum_le_exp_of_nonneg hn0 3404  simp only [Finset.sum_range_succ, Finset.sum_range_zero, zero_add, pow_zero,405    pow_one] at hs406  norm_num at hs407  have he : 1 + 2 * n ≤ Real.exp n := by nlinarith408  exact (Real.log_le_iff_le_exp (by linarith : 0 < 1 + 2 * n)).2 he409410/-- Exact scalar replacement for the manuscript's monotonicity argument for411`t ↦ t * exp (-n*t)`. -/412theorem zeta_exponential_comparison {n z : ℝ} (hn : 2 ≤ n)413    (hz : (3 : ℝ) / 2 ≤ z) :414    z * Real.exp (-(z * n)) ≤415      (3 : ℝ) / 2 * Real.exp (-(3 / 2 * n)) := by416  have hd : 0 ≤ z - 3 / 2 := by linarith417  have he := Real.add_one_le_exp (n * (z - 3 / 2))418  have hm : z ≤ 3 / 2 * Real.exp (n * (z - 3 / 2)) := by419    nlinarith [mul_nonneg (show 0 ≤ n - 2 by linarith) hd]420  have hmul := mul_le_mul_of_nonneg_right hm (Real.exp_pos (-(z * n))).le421  have heq : Real.exp (n * (z - 3 / 2)) * Real.exp (-(z * n)) =422      Real.exp (-(3 / 2 * n)) := by423    rw [← Real.exp_add]424    congr 1425    ring426  simpa only [mul_assoc, heq] using hmul427428/-- The three separate bounds obtained from the Haar estimate imply the429final scalar error estimate.  These hypotheses expose the precise analytic430inputs needed from the operator/random-matrix argument. -/431theorem final_error_from_contributions {n h ε A D R : ℝ}432    (hn : 64 ≤ n) (hh : (2 : ℝ) / 3 ≤ h) (hε : 0 < ε)433    (hA : A / ε ≤ 8 * n * (n + 1) * Real.log (1 + 2 * n) * Real.exp (-n / 2))434    (hD : D / ε ≤ 664 * zeta h * n ^ 3 * (n + 1) * Real.exp (-(zeta h * n)))435    (hR : R / ε ≤ n ^ 2 * Real.exp (-n)) :436    A + D + R ≤ ε / 16 := by437  have hn0 : 0 ≤ n := by linarith438  have hntwo : 2 ≤ n := by linarith439  have hn1 : n + 1 ≤ 3 / 2 * n := by linarith440  have hlog := log_one_add_two_mul_le hntwo441  have hlog0 : 0 ≤ Real.log (1 + 2 * n) := Real.log_nonneg (by linarith)442  have hz : (3 : ℝ) / 2 ≤ zeta h := by dsimp [zeta]; linarith443  have hz0 : 0 ≤ zeta h := by linarith444  have hzexp := zeta_exponential_comparison hntwo hz445  have hA' : A / ε ≤ 12 * n ^ 3 * Real.exp (-n / 2) := by446    have h₁ := mul_le_mul_of_nonneg_left hn1 (show 0 ≤ 8 * n by positivity)447    have h₂ := mul_le_mul h₁ hlog hlog0 (by positivity : 0 ≤ 8 * n * (3 / 2 * n))448    have h₃ := mul_le_mul_of_nonneg_right h₂ (Real.exp_pos (-n / 2)).le449    nlinarith450  have hD' : D / ε ≤ 1494 * n ^ 4 * Real.exp (-3 * n / 2) := by451    have h₁ := mul_le_mul_of_nonneg_left hn1 (show 0 ≤ 664 * n ^ 3 by positivity)452    have h₂ := mul_le_mul h₁ hzexp453      (by positivity : 0 ≤ zeta h * Real.exp (-(zeta h * n)))454      (by positivity : 0 ≤ 664 * n ^ 3 * (3 / 2 * n))455    have heq : -(3 / 2 * n) = -3 * n / 2 := by ring456    rw [heq] at h₂457    nlinarith458  have ht := final_three_tails_lt hn459  dsimp [tailBound] at ht460  have htotal : (A + D + R) / ε < 1 / 16 := by461    rw [add_div, add_div]462    linarith463  have h := (div_lt_iff₀ hε).1 htotal464  linarith465466theorem exp_dominates_linear {x : ℝ} (hx : 0 ≤ x) :467    (9 : ℝ) / 2 * x ≤ Real.exp (2 * x) := by468  have he := Real.add_one_le_exp (2 * x - 1)469  have hm := mul_le_mul_of_nonneg_left he (Real.exp_pos 1).le470  have heq : Real.exp 1 * Real.exp (2 * x - 1) = Real.exp (2 * x) := by471    rw [← Real.exp_add]472    congr 1473    ring474  rw [heq] at hm475  have hconst := Real.exp_one_gt_d9476  nlinarith477478theorem coefficient_remainder_absorption {h n : ℝ} (hh : (2 : ℝ) / 3 ≤ h)479    (hn : 2 ≤ n) :480    Real.log 4 + 2 * n * h + n / 3 ≤481      Real.exp (2 * n * h) * Real.log (1 + 2 * n) := by482  have hn0 : 0 ≤ n := by linarith483  have hh0 : 0 ≤ h := by linarith484  have hnh : (4 : ℝ) / 3 ≤ n * h := by485    nlinarith [mul_nonneg (show 0 ≤ n - 2 by linarith) hh0]486  have hlog4 : Real.log 4 < (7 : ℝ) / 5 := by487    have he : (4 : ℝ) = 2 ^ (2 : ℕ) := by norm_num488    rw [he, Real.log_pow]489    norm_num490    linarith [Real.log_two_lt_d9]491  have hlog : 1 ≤ Real.log (1 + 2 * n) := by492    apply (Real.le_log_iff_exp_le (by linarith : 0 < 1 + 2 * n)).2493    linarith [Real.exp_one_lt_three]494  have habsorb : Real.log 4 + 2 * n * h + n / 3 ≤ 9 / 2 * (n * h) := by495    nlinarith496  have he := exp_dominates_linear (mul_nonneg hn0 hh0)497  have he' : Real.exp (2 * (n * h)) = Real.exp (2 * n * h) := by congr 1; ring498  rw [he'] at he499  have hm := mul_le_mul_of_nonneg_left hlog (Real.exp_pos (2 * n * h)).le500  nlinarith501502theorem final_coefficient_size {h n J reductions L : ℝ}503    (hh : (2 : ℝ) / 3 ≤ h) (hn : 2 ≤ n)504    (hJ : J ≤ (Real.exp (2 * n * h) - 1) * Real.log (1 + 2 * n))505    (hred : reductions ≤ n * h + n / 3)506    (hL : L ≤ Real.log 4 + J + n * h + reductions) :507    L ≤ 2 * Real.exp (2 * n * h) * Real.log (1 + 2 * n) := by508  have hr := coefficient_remainder_absorption hh hn509  have hlog0 : 0 ≤ Real.log (1 + 2 * n) := Real.log_nonneg (by linarith)510  nlinarith511512theorem tolerance_times_error_factor {h n T : ℝ} (hn : 0 < n)513    (hT : T ≤ Real.exp (gamma h * n)) :514    T * tolerance h n ≤ 1 / n := by515  have he := mul_le_mul_of_nonneg_right hT (tolerance_pos (h := h) hn).le516  have heq : Real.exp (gamma h * n) * tolerance h n = 1 / n := by517    dsimp [tolerance]518    rw [← mul_div_assoc, ← Real.exp_add]519    simp520  exact heq ▸ he521522theorem coefficient_error_contribution {h n L invp : ℝ}523    (hn : 0 < n) (_hL0 : 0 ≤ L) (hip0 : 0 ≤ invp)524    (hL : L ≤ 2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n))525    (hip : invp ≤ 4 * Real.exp (-(dimensionExponent h * n / 80))) :526    ((n + 1) * L * invp) / tolerance h n ≤527      8 * n * (n + 1) * Real.log (1 + 2 * n) * Real.exp (-n / 2) := by528  have hlog0 : 0 ≤ Real.log (1 + 2 * n) := Real.log_nonneg (by linarith)529  have hm := mul_le_mul hL hip hip0 (by positivity :530    0 ≤ 2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n))531  have hm' := mul_le_mul_of_nonneg_left hm (show 0 ≤ n + 1 by linarith)532  have hexp : Real.exp (2 * h * n) *533      Real.exp (-(dimensionExponent h * n / 80)) =534      Real.exp (-(gamma h * n)) * Real.exp (-n / 2) := by535    rw [← Real.exp_add, ← Real.exp_add]536    congr 1537    dsimp [gamma, dimensionExponent]538    ring539  apply (div_le_iff₀ (tolerance_pos hn)).2540  calc541    (n + 1) * L * invp ≤ (n + 1) *542      (2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n) *543        (4 * Real.exp (-(dimensionExponent h * n / 80)))) := by544      simpa only [mul_assoc] using hm'545    _ = 8 * (n + 1) * Real.log (1 + 2 * n) *546      (Real.exp (2 * h * n) * Real.exp (-(dimensionExponent h * n / 80))) := by ring547    _ = (8 * n * (n + 1) * Real.log (1 + 2 * n) * Real.exp (-n / 2)) *548      tolerance h n := by549      rw [hexp]550      dsimp [tolerance]551      field_simp552553theorem dimension_error_contribution {h n logN logp invp : ℝ}554    (hh : 0 ≤ h) (hn : 0 < n)555    (_hN0 : 0 ≤ logN) (_hp0 : 0 ≤ logp) (hip0 : 0 ≤ invp)556    (hN : logN ≤ 2 * dimensionExponent h * n)557    (hp : logp ≤ logN / 80)558    (hip : invp ≤ 4 * Real.exp (-(dimensionExponent h * n / 80))) :559    ((n * (n + 1) / 2) * (logN + 3 * logp) * invp) / tolerance h n ≤560      664 * zeta h * n ^ 3 * (n + 1) * Real.exp (-(zeta h * n)) := by561  have hlog : logN + 3 * logp ≤ (83 : ℝ) / 40 * dimensionExponent h * n := by562    linarith563  have hblog : 0 ≤ (83 : ℝ) / 40 * dimensionExponent h * n := by564    dsimp [dimensionExponent]565    positivity566  have hm := mul_le_mul hlog hip hip0 hblog567  have hfactor : 0 ≤ n * (n + 1) / 2 := by positivity568  have hm' := mul_le_mul_of_nonneg_left hm hfactor569  have hb := dimensionExponent_le hh570  have hz0 : 0 ≤ zeta h := by dsimp [zeta]; positivity571  have hexp : Real.exp (-(dimensionExponent h * n / 80)) =572      Real.exp (-(gamma h * n)) * Real.exp (-(zeta h * n)) := by573    rw [← Real.exp_add]574    congr 1575    dsimp [dimensionExponent, gamma, zeta]576    ring577  apply (div_le_iff₀ (tolerance_pos hn)).2578  calc579    n * (n + 1) / 2 * (logN + 3 * logp) * invp ≤580      n * (n + 1) / 2 * ((83 : ℝ) / 40 * dimensionExponent h * n *581        (4 * Real.exp (-(dimensionExponent h * n / 80)))) := by582      simpa only [mul_assoc] using hm'583    _ = (83 : ℝ) / 20 * dimensionExponent h * n ^ 2 * (n + 1) *584      Real.exp (-(dimensionExponent h * n / 80)) := by ring585    _ ≤ 664 * zeta h * n ^ 2 * (n + 1) *586      Real.exp (-(dimensionExponent h * n / 80)) := by587      have hm'' := mul_le_mul_of_nonneg_right hb (show 0 ≤588        (83 : ℝ) / 20 * n ^ 2 * (n + 1) *589          Real.exp (-(dimensionExponent h * n / 80)) by positivity)590      nlinarith591    _ = (664 * zeta h * n ^ 3 * (n + 1) * Real.exp (-(zeta h * n))) *592      tolerance h n := by593      rw [hexp]594      dsimp [tolerance]595      field_simp596597theorem remainder_error_contribution {h n remainderLog : ℝ}598    (hh : 0 ≤ h) (hn : 0 < n)599    (hR : remainderLog ≤ Real.exp (-(dimensionExponent h * n / 2))) :600    (n * remainderLog) / tolerance h n ≤ n ^ 2 * Real.exp (-n) := by601  have hgap := remainder_exponent_gap hh602  have hgap' := mul_le_mul_of_nonneg_right hgap hn.le603  have he : Real.exp (-(dimensionExponent h * n / 2)) ≤604      Real.exp (-(gamma h * n) - n) := by605    apply Real.exp_le_exp.mpr606    nlinarith607  have hr := hR.trans he608  have hm := mul_le_mul_of_nonneg_left hr hn.le609  apply (div_le_iff₀ (tolerance_pos hn)).2610  calc611    n * remainderLog ≤ n * Real.exp (-(gamma h * n) - n) := hm612    _ = (n ^ 2 * Real.exp (-n)) * tolerance h n := by613      rw [sub_eq_add_neg, Real.exp_add]614      dsimp [tolerance]615      field_simp616617/-- Scalar validation of the complete logarithmic Haar multiplier.  The618premises are the separately stated coefficient-size, moment-size and619dimension estimates derived in the paper. -/620theorem haar_error_bound {h n L logN logp invp remainderLog : ℝ}621    (hh : (2 : ℝ) / 3 ≤ h) (hn : 64 ≤ n)622    (hL0 : 0 ≤ L) (hN0 : 0 ≤ logN) (hp0 : 0 ≤ logp) (hip0 : 0 ≤ invp)623    (hL : L ≤ 2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n))624    (hN : logN ≤ 2 * dimensionExponent h * n)625    (hp : logp ≤ logN / 80)626    (hip : invp ≤ 4 * Real.exp (-(dimensionExponent h * n / 80)))627    (hR : remainderLog ≤ Real.exp (-(dimensionExponent h * n / 2))) :628    (n + 1) * L * invp + (n * (n + 1) / 2) * (logN + 3 * logp) * invp +629        n * remainderLog ≤ tolerance h n / 16 := by630  have hn0 : 0 < n := by linarith631  have hh0 : 0 ≤ h := by linarith632  exact final_error_from_contributions hn hh (tolerance_pos hn0)633    (coefficient_error_contribution hn0 hL0 hip0 hL hip)634    (dimension_error_contribution hh0 hn0 hN0 hp0 hip0 hN hp hip)635    (remainder_error_contribution hh0 hn0 hR)636637/-- The logarithm of the multiplicative factor in equation `haar`, with the638paper's explicit choices of `N` and the even moment order `p`. -/639def haarLogMultiplier (h n L : ℝ) : ℝ :=640  (n + 1) * L / (momentParameter h n : ℝ) +641    n * (n + 1) * Real.log (dimensionChoice h n : ℝ) /642      (2 * (momentParameter h n : ℝ)) +643    3 * n * (n + 1) * Real.log (momentParameter h n : ℝ) /644      (2 * (momentParameter h n : ℝ)) +645    n * Real.log (1 + Real.exp (-(Real.log (dimensionChoice h n : ℝ) / 2)))646647/-- With explicit ceiling/floor parameters, only the separately proved648coefficient-size estimate remains a premise of the scalar Haar error bound. -/649theorem explicit_haar_error_bound {h n L : ℝ} (hh : (2 : ℝ) / 3 ≤ h)650    (hn : 64 ≤ n) (hL0 : 0 ≤ L)651    (hL : L ≤ 2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n)) :652    haarLogMultiplier h n L ≤ tolerance h n / 16 := by653  have hn2 : 2 ≤ n := by linarith654  obtain ⟨_, hp, _, _⟩ := moment_parameter_bounds hh hn2655  have hp1 : (1 : ℝ) ≤ momentParameter h n := by exact_mod_cast (by omega : 1 ≤ momentParameter h n)656  have hp0 : (0 : ℝ) ≤ momentParameter h n := hp1.trans' (by norm_num)657  obtain ⟨hNlo, hNhi⟩ := dimension_choice_log_bounds hh hn2658  have hh0 : 0 ≤ h := by linarith659  have hn0 : 0 ≤ n := by linarith660  have hbn0 : 0 ≤ dimensionExponent h * n := by dsimp [dimensionExponent]; positivity661  have hN0 : 0 ≤ Real.log (dimensionChoice h n : ℝ) := hbn0.trans hNlo662  have hpLog0 : 0 ≤ Real.log (momentParameter h n : ℝ) := Real.log_nonneg hp1663  have hb := haar_error_bound hh hn hL0 hN0 hpLog0 (by positivity :664    (0 : ℝ) ≤ 1 / (momentParameter h n : ℝ)) hL hNhi665    (moment_parameter_log_bound hh hn2)666    (moment_parameter_inverse_bound hh hn2)667    (remainder_log_bound hh hn2)668  convert hb using 1669  dsimp [haarLogMultiplier]670  ring671672/-- The final conversion from an additive logarithmic error to the target673multiplicative norm tolerance. -/674theorem final_log_comparison {ε E : ℝ} (hε : 0 < ε) (hε1 : ε < 1)675    (hE : E ≤ ε / 16) : E < Real.log (1 + ε / 2) := by676  have hp : 0 < 1 + ε / 2 := by linarith677  have hlog := Real.one_sub_inv_le_log_of_pos hp678  have hrewrite : 1 - (1 + ε / 2)⁻¹ = ε / (2 + ε) := by679    field_simp680    ring681  rw [hrewrite] at hlog682  have hdiv : ε / 3 < ε / (2 + ε) := by683    apply (div_lt_div_iff_of_pos_left hε (by norm_num) (by linarith)).2684    linarith685  linarith686687theorem explicit_haar_log_comparison {h n L : ℝ} (hh : (2 : ℝ) / 3 ≤ h)688    (hn : 64 ≤ n) (hL0 : 0 ≤ L)689    (hL : L ≤ 2 * Real.exp (2 * h * n) * Real.log (1 + 2 * n)) :690    haarLogMultiplier h n L < Real.log (1 + tolerance h n / 2) := by691  have hn0 : 0 < n := by linarith692  have hn2 : 2 ≤ n := by linarith693  have hh0 : 0 ≤ h := by linarith694  exact final_log_comparison (tolerance_pos hn0) (tolerance_lt_one hh0 hn2)695    (explicit_haar_error_bound hh hn hL0 hL)696697/-- The numerical appendix at the paper's stated integer threshold.  Here698`L` denotes `log (2*m_n)`; its displayed bound is the coefficient-size699certificate obtained from the separately formalized reduction arithmetic. -/700theorem quantitative_certificate {K n : ℕ} {L : ℝ} (hK : 2 ≤ K)701    (hn : n₀ K ≤ n) (hL0 : 0 ≤ L)702    (hL : L ≤ 2 * (K : ℝ) ^ (2 * n) * Real.log (1 + 2 * (n : ℝ))) :703    Even (momentParameter (Real.log (K : ℝ)) n) ∧704    2 ≤ momentParameter (Real.log (K : ℝ)) n ∧705    haarLogMultiplier (Real.log (K : ℝ)) n L ≤706      tolerance (Real.log (K : ℝ)) n / 16 ∧707    haarLogMultiplier (Real.log (K : ℝ)) n L <708      Real.log (1 + tolerance (Real.log (K : ℝ)) n / 2) := by709  obtain ⟨_, hn64, _, _⟩ := threshold_consequences hK hn710  have hKreal : (2 : ℝ) ≤ K := by exact_mod_cast hK711  have hlogK := Real.log_le_log (by norm_num : (0 : ℝ) < 2) hKreal712  have hh : (2 : ℝ) / 3 ≤ Real.log (K : ℝ) := by linarith [Real.log_two_gt_d9]713  have hK0 : (0 : ℝ) < K := by linarith714  have hexp : Real.exp (2 * Real.log (K : ℝ) * (n : ℝ)) = (K : ℝ) ^ (2 * n) := by715    have he : 2 * Real.log (K : ℝ) * (n : ℝ) = (2 * n : ℕ) * Real.log (K : ℝ) := by716      push_cast717      ring718    rw [he, Real.exp_nat_mul, Real.exp_log hK0]719  have hL' : L ≤ 2 * Real.exp (2 * Real.log (K : ℝ) * (n : ℝ)) *720      Real.log (1 + 2 * (n : ℝ)) := by simpa only [hexp] using hL721  have hn2 : (2 : ℝ) ≤ n := by linarith722  obtain ⟨heven, hp, _, _⟩ := moment_parameter_bounds hh hn2723  exact ⟨heven, hp, explicit_haar_error_bound hh hn64 hL0 hL',724    explicit_haar_log_comparison hh hn64 hL0 hL'⟩725726end727728end Nonadditivity.Quantitative