Exact Lean source
Nonadditivity.StructuredCostBounds
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.QuantitativeMathlib.Analysis.SpecialFunctions.Log.BasedependencyMathlib.Algebra.Order.Floor.Divdependency
Imported by project modules
2 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
54 project constants, including generated, internal and private declarations.
54 declarations
Nonadditivity.StructuredCostBounds.clog_le_logNonadditivity.StructuredCostBounds.coefficientBoundNonadditivity.StructuredCostBounds.coefficientBound_logNonadditivity.StructuredCostBounds.coefficientBound_log._proof_1_1internal/detail/privateNonadditivity.StructuredCostBounds.coefficientBound_log._proof_1_2internal/detail/privateNonadditivity.StructuredCostBounds.coefficientBound_log_boundNonadditivity.StructuredCostBounds.dyadicCeilNonadditivity.StructuredCostBounds.dyadicCeil._proof_1internal/detail/privateNonadditivity.StructuredCostBounds.dyadicCeil_eq_divNonadditivity.StructuredCostBounds.dyadicCeil_leNonadditivity.StructuredCostBounds.errorProductNonadditivity.StructuredCostBounds.errorProduct._proof_1internal/detail/privateNonadditivity.StructuredCostBounds.errorProduct_boundNonadditivity.StructuredCostBounds.geometric_sum_leNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_1internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_2internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_3internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_4internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_5internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_6internal/detail/privateNonadditivity.StructuredCostBounds.geometric_sum_le._simp_1_7internal/detail/privateNonadditivity.StructuredCostBounds.initialFactorNonadditivity.StructuredCostBounds.initialFactor._proof_1internal/detail/privateNonadditivity.StructuredCostBounds.initialFactor_log_boundNonadditivity.StructuredCostBounds.initialFactor_posNonadditivity.StructuredCostBounds.log_six_ltNonadditivity.StructuredCostBounds.log_supportProductNonadditivity.StructuredCostBounds.log_tensorSupportBound_leNonadditivity.StructuredCostBounds.log_tensorSupportBound_le._proof_1_1internal/detail/privateNonadditivity.StructuredCostBounds.log_tensorSupportBound_le._proof_1_2internal/detail/privateNonadditivity.StructuredCostBounds.log_three_ltNonadditivity.StructuredCostBounds.netCardBoundNonadditivity.StructuredCostBounds.netCardBound_posNonadditivity.StructuredCostBounds.step_boundsNonadditivity.StructuredCostBounds.sum_dyadicCeil_leNonadditivity.StructuredCostBounds.sum_linear_indicesNonadditivity.StructuredCostBounds.supportProductNonadditivity.StructuredCostBounds.supportProduct_dimension_log_boundNonadditivity.StructuredCostBounds.supportProduct_posNonadditivity.StructuredCostBounds.tensorStepsNonadditivity.StructuredCostBounds.tensorSupportBoundNonadditivity.StructuredCostBounds.tensorSupportBound_posNonadditivity.StructuredCostBounds.tensor_sum_log_boundNonadditivity.StructuredCostBounds.tensor_sum_log_bound._proof_1_1internal/detail/privateNonadditivity.StructuredCostBounds.tensor_sum_log_coarseNonadditivity.StructuredCostBounds.tensor_sum_log_coarse._proof_1_1internal/detail/privateNonadditivity.StructuredCostBounds.wordLengthNonadditivity.StructuredCostBounds.wordLength_leNonadditivity.StructuredCostBounds.wordLength_le._proof_1_1internal/detail/privateNonadditivity.StructuredCostBounds.wordStepsNonadditivity.StructuredCostBounds.wordSupportBoundNonadditivity.StructuredCostBounds.wordSupportBound.eq_1internal/detail/privateNonadditivity.StructuredCostBounds.wordSupportBound_posNonadditivity.StructuredCostBounds.word_sum_log_bound
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.Quantitative7import Mathlib.Analysis.SpecialFunctions.Log.Base8import Mathlib.Algebra.Order.Floor.Div910/-! Exact products of the structured tensor and word support budgets. -/1112namespace Nonadditivity.StructuredCostBounds1314noncomputable section1516open scoped BigOperators1718set_option maxHeartbeats 8000001920def dyadicCeil (m j : ℕ) : ℕ := ⌈(m : ℝ) / 2 ^ j⌉₊21def tensorSteps (n : ℕ) : ℕ := Nat.clog 2 n22def wordLength (K : ℕ) : ℕ := 2 * Nat.log2 (K - 1) + 123def wordSteps (K : ℕ) : ℕ := Nat.clog 2 (wordLength K)24def tensorSupportBound (K n j : ℕ) : ℕ := 1 + 2 ^ (j + 1) * K ^ dyadicCeil n j25def wordSupportBound (K n i : ℕ) : ℕ := 2 * n * 3 ^ dyadicCeil (wordLength K) i2627theorem dyadicCeil_le (m j : ℕ) :28(dyadicCeil m j : ℝ) ≤ (m : ℝ) / 2 ^ j + 1 := by29exact (Nat.ceil_lt_add_one (by positivity : 0 ≤ (m : ℝ) / 2 ^ j)).le3031theorem geometric_sum_le (m q : ℕ) :32∑ j ∈ Finset.range q, (m : ℝ) / 2 ^ (j + 1) ≤ m := by33have h : ∑ j ∈ Finset.range q, (m : ℝ) / 2 ^ (j + 1) =34m - (m : ℝ) / 2 ^ q := by35induction q with36| zero => simp37| succ q ih =>38rw [Finset.sum_range_succ, ih, pow_succ]39field_simp40ring41rw [h]42exact sub_le_self _ (by positivity)4344theorem sum_dyadicCeil_le (m q : ℕ) :45∑ j ∈ Finset.range q, (dyadicCeil m (j + 1) : ℝ) ≤ (m : ℝ) + (q : ℝ) := by46calc47_ ≤ ∑ j ∈ Finset.range q, ((m : ℝ) / 2 ^ (j + 1) + 1) :=48Finset.sum_le_sum fun j _ => dyadicCeil_le m (j + 1)49_ = (∑ j ∈ Finset.range q, (m : ℝ) / 2 ^ (j + 1)) + (q : ℝ) := by simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul, mul_one]50_ ≤ (m : ℝ) + (q : ℝ) := by linarith [geometric_sum_le m q]5152theorem clog_le_log (m : ℕ) :53(Nat.clog 2 m : ℝ) ≤ 1 + Real.log (m : ℝ) / Real.log 2 := by54rw [← Real.natCeil_logb_natCast]55have hnonneg : 0 ≤ Real.logb 2 (m : ℝ) := by56by_cases hm : m = 057· simp [hm]58· exact Real.logb_nonneg (by norm_num) (by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hm)59simpa [Real.logb, add_comm] using (Nat.ceil_lt_add_one hnonneg).le6061theorem wordLength_le {K : ℕ} (hK : 2 ≤ K) :62(wordLength K : ℝ) ≤ 3 * (1 + Real.log (K : ℝ)) := by63have hKr : (2 : ℝ) ≤ K := by exact_mod_cast hK64have hKm : (0 : ℝ) < (K : ℝ) - 1 := by linarith65have hcast : ((K - 1 : ℕ) : ℝ) = (K : ℝ) - 1 := by rw [Nat.cast_sub (by omega : 1 ≤ K)]; norm_num66have hm := Real.log2_le_logb (K - 1)67rw [Real.logb, hcast] at hm68have hl := Real.log_le_log hKm (show (K : ℝ) - 1 ≤ K by linarith)69have h2 : 0 < Real.log 2 := by linarith [Real.log_two_gt_d9]70have hh0 : 0 ≤ Real.log (K : ℝ) := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ K))71have hd : Real.log (K : ℝ) / Real.log 2 ≤ 3 / 2 * Real.log (K : ℝ) := by72apply (div_le_iff₀ h2).273nlinarith [mul_nonneg hh0 (show 0 ≤ Real.log 2 - 2 / 3 by linarith [Real.log_two_gt_d9])]74have hm' := hm.trans ((div_le_div_iff_of_pos_right h2).2 hl)75dsimp [wordLength]76push_cast77linarith7879theorem log_three_lt : Real.log 3 < (4 : ℝ) / 3 := by80apply (Real.log_lt_iff_lt_exp (by norm_num)).281have h := Real.sum_le_exp_of_nonneg (by norm_num : (0 : ℝ) ≤ 4 / 3) 382norm_num [Finset.sum_range_succ] at h83linarith8485theorem log_six_lt : Real.log 6 < (2 : ℝ) := by86apply (Real.log_lt_iff_lt_exp (by norm_num)).287have h := Real.sum_le_exp_of_nonneg (by norm_num : (0 : ℝ) ≤ 2) 488norm_num [Finset.sum_range_succ] at h89linarith9091theorem step_bounds {K n : ℕ} (hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :92(tensorSteps n : ℝ) ≤ 3 / 2 * (1 + Real.log K + Real.log n) ∧93(wordSteps K : ℝ) ≤ 1 + Real.log K + Real.log n ∧94Real.log (2 * (n : ℝ)) ≤ 1 + Real.log K + Real.log n := by95obtain ⟨hh, hn64, hu, _⟩ := Quantitative.threshold_consequences hK hn96have hn0 : (0 : ℝ) < n := by linarith97have hv : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg (by linarith)98have h2 : 0 < Real.log 2 := by linarith [Real.log_two_gt_d9]99have h2lower : (2 : ℝ) / 3 ≤ Real.log 2 := by linarith [Real.log_two_gt_d9]100have h2upper : Real.log 2 ≤ (7 : ℝ) / 10 := by linarith [Real.log_two_lt_d9]101have hlogK : (2 : ℝ) / 3 ≤ Real.log (K : ℝ) := by102have hk := Real.log_le_log (by norm_num : (0 : ℝ) < 2) (show (2 : ℝ) ≤ (K : ℝ) by exact_mod_cast hK)103linarith104have hq := clog_le_log n105have hd : Real.log (n : ℝ) / Real.log 2 ≤ 3 / 2 * Real.log n := by106apply (div_le_iff₀ h2).2107nlinarith [mul_nonneg hv (sub_nonneg.mpr h2lower)]108refine ⟨by dsimp [tensorSteps]; linarith, ?_, ?_⟩109· have hy : 0 < 1 + Real.log (K : ℝ) := by linarith110have hlpos : (0 : ℝ) < wordLength K := by dsimp [wordLength]; positivity111have hle := Real.log_le_log hlpos (wordLength_le hK)112rw [Real.log_mul (by norm_num) hy.ne'] at hle113have hylog := Real.log_le_sub_one_of_pos (div_pos hy (by norm_num : (0 : ℝ) < 2))114rw [Real.log_div hy.ne' (by norm_num)] at hylog115have hlogl : 0 ≤ Real.log (wordLength K : ℝ) :=116Real.log_nonneg (by dsimp [wordLength]; push_cast; linarith [(Nat.cast_nonneg (Nat.log2 (K - 1)) : (0 : ℝ) ≤ (Nat.log2 (K - 1) : ℝ))])117have hld : Real.log (wordLength K : ℝ) / Real.log 2 ≤1183 / 2 * Real.log (wordLength K : ℝ) := by119apply (div_le_iff₀ h2).2120nlinarith [mul_nonneg hlogl (sub_nonneg.mpr h2lower)]121have hs := clog_le_log (wordLength K)122have hv6 : 6 ≤ Real.log (n : ℝ) := by123have hbase : 256 * (1 + Real.log (K : ℝ)) ^ 2 ≤ (n : ℝ) :=124(Nat.le_ceil _).trans (by exact_mod_cast hn)125have hn512 : (512 : ℝ) ≤ n := by nlinarith [sq_nonneg (1 + Real.log (K : ℝ) - 5 / 3)]126have hl := Real.log_le_log (by norm_num : (0 : ℝ) < 512) hn512127have he : Real.log (512 : ℝ) = 9 * Real.log 2 := by128rw [show (512 : ℝ) = 2 ^ (9 : ℕ) by norm_num, Real.log_pow]; norm_num129rw [he] at hl130linarith131dsimp [wordSteps]132linarith [log_three_lt]133· rw [Real.log_mul (by norm_num) hn0.ne']134linarith135136theorem dyadicCeil_eq_div (m j : ℕ) :137dyadicCeil m j = (m + 2 ^ j - 1) / 2 ^ j := by138change dyadicCeil m j = m ⌈/⌉ (2 ^ j)139apply eq_of_forall_ge_iff140intro a141rw [ceilDiv_le_iff_le_mul (by positivity : 0 < (2 : ℕ) ^ j)]142dsimp [dyadicCeil]143rw [Nat.ceil_le, div_le_iff₀ (by positivity : (0 : ℝ) < 2 ^ j)]144norm_cast145rw [Nat.mul_comm]146147theorem tensorSupportBound_pos (K n j : ℕ) : 0 < tensorSupportBound K n j := by148dsimp [tensorSupportBound]; positivity149150theorem wordSupportBound_pos {n : ℕ} (hn : 0 < n) (K i : ℕ) :1510 < wordSupportBound K n i := by152dsimp [wordSupportBound]; positivity153154theorem log_tensorSupportBound_le {K : ℕ} (hK : 1 ≤ K) (n j : ℕ) :155Real.log (tensorSupportBound K n j : ℝ) ≤156(j + 2 : ℕ) * Real.log 2 + (dyadicCeil n j : ℝ) * Real.log K := by157have hK0 : (0 : ℝ) < K := by exact_mod_cast (by omega : 0 < K)158have hpow : (1 : ℝ) ≤ (K : ℝ) ^ dyadicCeil n j :=159one_le_pow₀ (by exact_mod_cast hK)160have htwo : (1 : ℝ) ≤ (2 : ℝ) ^ (j + 1) := one_le_pow₀ (by norm_num)161have hprod : (1 : ℝ) ≤ 2 ^ (j + 1) * (K : ℝ) ^ dyadicCeil n j :=162one_le_mul_of_one_le_of_one_le htwo hpow163have hb : (tensorSupportBound K n j : ℝ) ≤1642 ^ (j + 2) * (K : ℝ) ^ dyadicCeil n j := by165dsimp [tensorSupportBound]166push_cast167simp only [show j + 2 = (j + 1) + 1 by omega, pow_succ] at hprod ⊢168nlinarith169have hl := Real.log_le_log (by exact_mod_cast tensorSupportBound_pos K n j) hb170rw [Real.log_mul (by positivity) (by positivity), Real.log_pow, Real.log_pow] at hl171exact hl172173theorem sum_linear_indices (q : ℕ) :174∑ j ∈ Finset.range q, ((j : ℝ) + 3) = (q : ℝ) * (q + 5) / 2 := by175induction q with176| zero => simp177| succ q ih =>178rw [Finset.sum_range_succ, ih]179push_cast180ring181182theorem tensor_sum_log_coarse {K : ℕ} (hK : 2 ≤ K) (n q : ℕ) :183(∑ j ∈ Finset.range q, Real.log (tensorSupportBound K n (j + 1) : ℝ)) ≤184(n : ℝ) * Real.log K + q * Real.log K +185(q : ℝ) * (q + 5) / 2 * Real.log 2 := by186have hh : 0 ≤ Real.log (K : ℝ) := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ K))187calc188_ ≤ ∑ j ∈ Finset.range q,189(((j : ℝ) + 3) * Real.log 2 + (dyadicCeil n (j + 1) : ℝ) * Real.log K) := by190apply Finset.sum_le_sum191intro j _192simpa only [Nat.cast_add, Nat.cast_one, Nat.cast_ofNat, add_assoc, show (1 : ℝ) + 2 = 3 by norm_num] using193log_tensorSupportBound_le (by omega : 1 ≤ K) n (j + 1)194_ = ((q : ℝ) * (q + 5) / 2) * Real.log 2 +195(∑ j ∈ Finset.range q, (dyadicCeil n (j + 1) : ℝ)) * Real.log K := by196rw [Finset.sum_add_distrib, ← Finset.sum_mul, ← Finset.sum_mul, sum_linear_indices]197_ ≤ _ := by nlinarith [mul_le_mul_of_nonneg_right (sum_dyadicCeil_le n q) hh]198199theorem tensor_sum_log_bound {K n : ℕ} (hK : 2 ≤ K) :200(∑ j ∈ Finset.range (tensorSteps n),201Real.log (tensorSupportBound K n (j + 1) : ℝ)) ≤202(n : ℝ) * Real.log K + 3 / 4 * (1 + Real.log K + Real.log n) ^ 2 +2032 * (1 + Real.log K + Real.log n) := by204have hh : 0 ≤ Real.log (K : ℝ) := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ K))205have hv : 0 ≤ Real.log (n : ℝ) := by206by_cases hn : n = 0207· simp [hn]208· exact Real.log_nonneg (by exact_mod_cast Nat.one_le_iff_ne_zero.mpr hn)209have h2 : 0 < Real.log 2 := by linarith [Real.log_two_gt_d9]210have h2lo : (2 : ℝ) / 3 ≤ Real.log 2 := by linarith [Real.log_two_gt_d9]211have h2hi : Real.log 2 ≤ (7 : ℝ) / 10 := by linarith [Real.log_two_lt_d9]212have hq := clog_le_log n213change (tensorSteps n : ℝ) ≤ 1 + Real.log (n : ℝ) / Real.log 2 at hq214have hqd : (tensorSteps n : ℝ) * Real.log 2 ≤ Real.log 2 + Real.log n := by215have h := (le_div_iff₀ h2).1 (show (tensorSteps n : ℝ) - 1 ≤ Real.log n / Real.log 2 by linarith)216nlinarith217have hq0 : (0 : ℝ) ≤ tensorSteps n := by positivity218have hqlo : (tensorSteps n : ℝ) ≤ 1 + 3 / 2 * Real.log n := by219nlinarith [mul_nonneg hq0 (sub_nonneg.mpr h2lo)]220have hqh := mul_le_mul_of_nonneg_right hqlo hh221have hqv := mul_le_mul_of_nonneg_right hqlo hv222have hqq := mul_le_mul_of_nonneg_left hqd hq0223have hq2 : (tensorSteps n : ℝ) ^ 2 * Real.log 2 ≤2243 / 2 * Real.log (n : ℝ) ^ 2 + 2 * Real.log n + Real.log 2 := by225nlinarith226have hcoarse := tensor_sum_log_coarse hK n (tensorSteps n)227have hhsq := sq_nonneg (Real.log (K : ℝ) - 1)228nlinarith229230theorem word_sum_log_bound {K n : ℕ} (hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :231(∑ i ∈ Finset.range (wordSteps K),232Real.log (wordSupportBound K n (i + 1) : ℝ)) ≤233(1 + Real.log K + Real.log n) ^ 2 + 6 * (1 + Real.log K + Real.log n) := by234obtain ⟨hh, hn64, hu, _⟩ := Quantitative.threshold_consequences hK hn235obtain ⟨_, hs, hlog2n⟩ := step_bounds hK hn236have hn0 : (0 : ℝ) < n := by linarith237have hlog3 : 0 ≤ Real.log 3 := Real.log_nonneg (by norm_num)238have hlog2n0 : 0 ≤ Real.log (2 * (n : ℝ)) := Real.log_nonneg (by linarith)239have hs0 : (0 : ℝ) ≤ wordSteps K := by positivity240have hu0 : 0 ≤ 1 + Real.log (K : ℝ) + Real.log n := by linarith241have heq : (∑ i ∈ Finset.range (wordSteps K),242Real.log (wordSupportBound K n (i + 1) : ℝ)) =243(wordSteps K : ℝ) * Real.log (2 * (n : ℝ)) +244(∑ i ∈ Finset.range (wordSteps K), (dyadicCeil (wordLength K) (i + 1) : ℝ)) * Real.log 3 := by245simp only [wordSupportBound, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_pow,246Real.log_mul (by positivity : (2 : ℝ) * n ≠ 0) (by positivity : (3 : ℝ) ^ _ ≠ 0),247Real.log_pow, Finset.sum_add_distrib, Finset.sum_const, Finset.card_range,248nsmul_eq_mul, Finset.sum_mul]249rw [heq]250have hsum := mul_le_mul_of_nonneg_right (sum_dyadicCeil_le (wordLength K) (wordSteps K)) hlog3251have hsmul := mul_le_mul hs hlog2n hlog2n0 hu0252have hl := wordLength_le hK253have hv : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg (by linarith)254have hsumfactor : (wordLength K : ℝ) + wordSteps K ≤2554 * (1 + Real.log K + Real.log n) := by linarith256have hsumfactor0 : (0 : ℝ) ≤ (wordLength K : ℝ) + wordSteps K := by positivity257have hb := mul_le_mul hsumfactor (show Real.log 3 ≤ (3 : ℝ) / 2 by linarith [log_three_lt])258hlog3 (by linarith : 0 ≤ 4 * (1 + Real.log (K : ℝ) + Real.log n))259nlinarith260261/-- Product of all tensor and word support budgets, including each stage's262multiplicative overhead. Use `a=6` for errors and `a=2` for dimensions. -/263def supportProduct (K n : ℕ) (a : ℝ) : ℝ :=264(∏ j ∈ Finset.range (tensorSteps n), a * (tensorSupportBound K n (j + 1) : ℝ)) *265(∏ i ∈ Finset.range (wordSteps K), a * (wordSupportBound K n (i + 1) : ℝ))266267theorem supportProduct_pos {K n : ℕ} {a : ℝ} (hn : 0 < n) (ha : 0 < a) :2680 < supportProduct K n a := by269apply mul_pos270· exact Finset.prod_pos fun j _ => mul_pos ha (by exact_mod_cast tensorSupportBound_pos K n (j + 1))271· exact Finset.prod_pos fun i _ => mul_pos ha (by exact_mod_cast wordSupportBound_pos hn K (i + 1))272273theorem log_supportProduct {K n : ℕ} {a : ℝ} (hn : 0 < n) (ha : 0 < a) :274Real.log (supportProduct K n a) =275((tensorSteps n : ℝ) + wordSteps K) * Real.log a +276(∑ j ∈ Finset.range (tensorSteps n), Real.log (tensorSupportBound K n (j + 1) : ℝ)) +277(∑ i ∈ Finset.range (wordSteps K), Real.log (wordSupportBound K n (i + 1) : ℝ)) := by278have ht : ∀ j, (tensorSupportBound K n (j + 1) : ℝ) ≠ 0 := fun j => by279exact_mod_cast (tensorSupportBound_pos K n (j + 1)).ne'280have hw : ∀ i, (wordSupportBound K n (i + 1) : ℝ) ≠ 0 := fun i => by281exact_mod_cast (wordSupportBound_pos hn K (i + 1)).ne'282dsimp [supportProduct]283rw [Real.log_mul (Finset.prod_ne_zero_iff.mpr fun j _ => mul_ne_zero ha.ne' (ht j))284(Finset.prod_ne_zero_iff.mpr fun i _ => mul_ne_zero ha.ne' (hw i))]285rw [Real.log_prod (fun j _ => mul_ne_zero ha.ne' (ht j)),286Real.log_prod (fun i _ => mul_ne_zero ha.ne' (hw i))]287simp_rw [Real.log_mul ha.ne' (ht _), Real.log_mul ha.ne' (hw _)]288simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_range, nsmul_eq_mul]289ring290291theorem supportProduct_dimension_log_bound {K n : ℕ}292(hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :293Real.log (supportProduct K n 2) < (n : ℝ) * Real.log K + n / 3 := by294obtain ⟨_, hn64, hu, hthreshold⟩ := Quantitative.threshold_consequences hK hn295have hn0 : 0 < n := by exact_mod_cast (show (0 : ℝ) < n by linarith)296obtain ⟨hq, hs, _⟩ := step_bounds hK hn297have hsteps : (0 : ℝ) ≤ (tensorSteps n : ℝ) + wordSteps K := by positivity298have hov : ((tensorSteps n : ℝ) + wordSteps K) * Real.log 2 ≤2995 / 2 * (1 + Real.log K + Real.log n) := by300have hm := mul_le_mul_of_nonneg_left (show Real.log 2 ≤ 1 by linarith [Real.log_two_lt_d9]) hsteps301nlinarith302rw [log_supportProduct hn0 (by norm_num)]303exact Quantitative.reduction_coefficient_log_bound hu hthreshold hov304(tensor_sum_log_bound hK) (word_sum_log_bound hK hn)305306/-- Upper bound for the initial shifted-dilation error factor from the307prescribed witness's lower norm. -/308def initialFactor (K n : ℕ) : ℝ :=3093 * (1 + Real.exp (((n : ℝ) + 1) * Real.log K / 2) / Real.sqrt 2)310311theorem initialFactor_pos (K n : ℕ) : 0 < initialFactor K n := by312dsimp [initialFactor]; positivity313314theorem initialFactor_log_bound {K n : ℕ}315(hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :316Real.log (initialFactor K n) ≤317(n : ℝ) * Real.log K / 2 + (1 + Real.log K + Real.log n) := by318obtain ⟨hh, hn64, _, _⟩ := Quantitative.threshold_consequences hK hn319have hn0 : (0 : ℝ) < n := by linarith320have hx0 : 0 ≤ ((n : ℝ) + 1) * Real.log K / 2 := by positivity321have he : 1 ≤ Real.exp (((n : ℝ) + 1) * Real.log K / 2) := Real.one_le_exp_iff.mpr hx0322have hs : (1 : ℝ) ≤ Real.sqrt 2 := (Real.le_sqrt (by norm_num) (by norm_num)).2 (by norm_num)323have hd : Real.exp (((n : ℝ) + 1) * Real.log K / 2) / Real.sqrt 2 ≤324Real.exp (((n : ℝ) + 1) * Real.log K / 2) := div_le_self (by positivity) hs325have hi : initialFactor K n ≤ 6 * Real.exp (((n : ℝ) + 1) * Real.log K / 2) := by326dsimp [initialFactor]; linarith327have hl := Real.log_le_log (initialFactor_pos K n) hi328rw [Real.log_mul (by norm_num) (by positivity), Real.log_exp] at hl329have hv : 1 ≤ Real.log (n : ℝ) := by330apply (Real.le_log_iff_exp_le hn0).2331linarith [Real.exp_one_lt_three]332linarith [log_six_lt]333334/-- The full relative-error amplification budget, as an actual product. -/335def errorProduct (K n : ℕ) : ℝ := initialFactor K n * supportProduct K n 6336337theorem errorProduct_bound {K n : ℕ} (hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :338errorProduct K n ≤ Real.exp (Quantitative.gamma (Real.log K) * n) := by339obtain ⟨_, hn64, hu, hthreshold⟩ := Quantitative.threshold_consequences hK hn340have hn0 : 0 < n := by exact_mod_cast (show (0 : ℝ) < n by linarith)341obtain ⟨hq, hs, _⟩ := step_bounds hK hn342have hsteps : (0 : ℝ) ≤ (tensorSteps n : ℝ) + wordSteps K := by positivity343have hov : ((tensorSteps n : ℝ) + wordSteps K) * Real.log 6 ≤3445 * (1 + Real.log K + Real.log n) := by345have hm := mul_le_mul_of_nonneg_left log_six_lt.le hsteps346nlinarith347have hb := Quantitative.reduction_error_log_bound hu hthreshold348(initialFactor_log_bound hK hn) hov (tensor_sum_log_bound hK) (word_sum_log_bound hK hn)349have hepos : 0 < errorProduct K n := mul_pos (initialFactor_pos K n)350(supportProduct_pos hn0 (by norm_num))351apply (Real.log_le_iff_le_exp hepos).mp352dsimp [errorProduct]353rw [Real.log_mul (initialFactor_pos K n).ne' (supportProduct_pos hn0 (by norm_num)).ne',354log_supportProduct hn0 (by norm_num)]355linarith356357/-- Largest permitted test net size in the traceless Hermitian sphere. -/358def netCardBound (K n : ℕ) : ℕ := (1 + 2 * n) ^ (K ^ (2 * n) - 1)359360/-- The actual coefficient budget including the initial `2 J K^n` and all361subsequent structured support factors. -/362def coefficientBound (K n : ℕ) : ℝ :=3632 * netCardBound K n * (K : ℝ) ^ n * supportProduct K n 2364365theorem netCardBound_pos (K n : ℕ) : 0 < netCardBound K n := by366dsimp [netCardBound]; positivity367368theorem coefficientBound_log {K n : ℕ} (hK : 2 ≤ K) (hn : 0 < n) :369Real.log (2 * coefficientBound K n) =370Real.log 4 + (K ^ (2 * n) - 1 : ℝ) * Real.log (1 + 2 * (n : ℝ)) +371(n : ℝ) * Real.log K + Real.log (supportProduct K n 2) := by372have hKpos : 0 < K := by omega373have hKreal : (0 : ℝ) < K := by exact_mod_cast hKpos374have hj : (0 : ℝ) < netCardBound K n := by exact_mod_cast netCardBound_pos K n375have he : 2 * coefficientBound K n =3764 * (netCardBound K n : ℝ) * (K : ℝ) ^ n * supportProduct K n 2 := by377dsimp [coefficientBound]; ring378rw [he, Real.log_mul (by positivity) (supportProduct_pos hn (by norm_num)).ne',379Real.log_mul (by positivity) (by positivity), Real.log_mul (by norm_num) hj.ne', Real.log_pow]380have hjlog : Real.log (netCardBound K n : ℝ) =381((K : ℝ) ^ (2 * n) - 1) * Real.log (1 + 2 * (n : ℝ)) := by382dsimp [netCardBound]383rw [Nat.cast_pow, Real.log_pow]384congr 1385· rw [Nat.cast_sub (by exact Nat.one_le_iff_ne_zero.mpr (pow_ne_zero _ (by omega))), Nat.cast_pow, Nat.cast_one]386· push_cast; rfl387rw [hjlog]388389theorem coefficientBound_log_bound {K n : ℕ}390(hK : 2 ≤ K) (hn : Quantitative.n₀ K ≤ n) :391Real.log (2 * coefficientBound K n) ≤3922 * (K : ℝ) ^ (2 * n) * Real.log (1 + 2 * (n : ℝ)) := by393obtain ⟨_, hn64, _, _⟩ := Quantitative.threshold_consequences hK hn394have hn0 : 0 < n := by exact_mod_cast (show (0 : ℝ) < n by linarith)395have hKr : (2 : ℝ) ≤ K := by exact_mod_cast hK396have hKr0 : (0 : ℝ) < K := by linarith397have hh : (2 : ℝ) / 3 ≤ Real.log (K : ℝ) := by398have h := Real.log_le_log (by norm_num : (0 : ℝ) < 2) hKr399linarith [Real.log_two_gt_d9]400have hexp : Real.exp (2 * (n : ℝ) * Real.log K) = (K : ℝ) ^ (2 * n) := by401rw [show 2 * (n : ℝ) * Real.log K = (2 * n : ℕ) * Real.log K by push_cast; ring,402Real.exp_nat_mul, Real.exp_log hKr0]403rw [coefficientBound_log hK hn0]404have h := Quantitative.final_coefficient_size hh (show (2 : ℝ) ≤ n by linarith)405(J := ((K : ℝ) ^ (2 * n) - 1) * Real.log (1 + 2 * (n : ℝ)))406(by rw [hexp]) (supportProduct_dimension_log_bound hK hn).le (le_refl _)407simpa only [hexp] using h408409end410end Nonadditivity.StructuredCostBounds