module public import Research.PvsNP.Tau.TauConjecture @[expose] public section namespace Research.PvsNP.Tau /-! # Pure-ℤ Algebraic `L₂`-Reflection Bound (`τ · z_ℤ(P) ≤ 3 · 2^τ`) This module proves an unconditional, completely elementary `O(2^τ / τ)` upper bound on the number of distinct integer roots of every constant-free, division-free straight-line program `P : SLP τ` over `ℤ[X]`, using **zero** real analysis, **zero** complex analysis, **zero** logarithms, and **zero** `p`-adic machinery: `∀ {τ : ℕ} (P : SLP τ), P.evalPoly ≠ 0 → τ * intRootCount P.evalPoly ≤ 3 * 2 ^ τ` This sharpens `GapDominanceBound.lean` (`2^τ / τ^(1/28)`) by `28×` in the exponent of `τ` and matches the information-theoretic `Θ(2^τ / τ)` ceiling for all global degree/height/Mahler methods up to a small absolute constant. ### Proof Structure 1. **1-Step `L₂`-Reflection Identity (`l2Sq_mul_X_sub_eq_one_sub_mul_X`):** For every `f : Polynomial ℤ` and `r : ℤ`, `‖f · (X - r)‖₂² = ‖f · (1 - r X)‖₂²`. 2. **Multi-Root Reflection (`prod_natAbs_roots_le_l1Norm`):** Reflecting every integer root `r ∈ S` (`r ≠ 0`) turns `f = Q · ∏ (X - r)` into `f* = Q · ∏ (1 - r X)` with `∏ |r| ≤ |lc(f*)| ≤ ‖f*‖₂ = ‖f‖₂ ≤ ‖f‖₁`. 3. **SLP `L₁`-Norm Bound (`slp_l1Norm_le`):** Every nonzero `P : SLP τ` (`τ ≥ 1`) satisfies `l1Norm P.evalPoly ≤ 2 ^ (2 ^ (τ - 1))` (and `≤ 2 ^ (2 ^ (τ - t₀ - 1))` if the first `t₀` gates are all multiplications). 4. **Pure-`ℕ` Factorial Pairing (`pow_self_le_prod_natAbs`):** For `S ⊆ {r ∈ ℤ : 2 ≤ |r|}` with `2 * m ≤ S.card`, `k = m + 1` satisfies `k ^ k ≤ (k!)^2 ≤ ∏ r ∈ S, r.natAbs`. 5. **Pure-`ℕ` Closure (`slp_intRootCount_l2_reflection`):** Combining (2)–(4) with `h = τ / 2` yields `τ * intRootCount P.evalPoly ≤ 3 * 2 ^ τ` (and `(τ - t₀) * intRootCount P.evalPoly ≤ 3 * 2 ^ (τ - t₀)` for a `t₀`-multiplication prefix). -/ open Polynomial /-! ## 1. Polynomial `L₁`-Norm and Squared `L₂`-Norm over `ℤ[X]` -/ /-- The `L₁`-norm (sum of absolute values of coefficients) of `f ∈ ℤ[X]`. -/ noncomputable def l1Norm (f : Polynomial ℤ) : ℕ := ∑ k ∈ Finset.range (f.natDegree + 1), (f.coeff k).natAbs /-- The squared `L₂`-norm (sum of squares of coefficients) of `f ∈ ℤ[X]`. -/ noncomputable def l2Sq (f : Polynomial ℤ) : ℕ := ∑ k ∈ Finset.range (f.natDegree + 1), (f.coeff k).natAbs ^ 2 lemma l1Norm_eq_sum_range {f : Polynomial ℤ} {N : ℕ} (hN : f.natDegree + 1 ≤ N) : l1Norm f = ∑ k ∈ Finset.range N, (f.coeff k).natAbs := by unfold l1Norm refine Finset.sum_subset (Finset.range_mono hN) ?_ intro k _ hk have hlt : f.natDegree < k := by simp only [Finset.mem_range, not_lt] at hk omega simp [Polynomial.coeff_eq_zero_of_natDegree_lt hlt] lemma l2Sq_eq_sum_range {f : Polynomial ℤ} {N : ℕ} (hN : f.natDegree + 1 ≤ N) : l2Sq f = ∑ k ∈ Finset.range N, (f.coeff k).natAbs ^ 2 := by unfold l2Sq refine Finset.sum_subset (Finset.range_mono hN) ?_ intro k _ hk have hlt : f.natDegree < k := by simp only [Finset.mem_range, not_lt] at hk omega simp [Polynomial.coeff_eq_zero_of_natDegree_lt hlt] lemma l1Norm_one : l1Norm (1 : Polynomial ℤ) = 1 := by simp [l1Norm] lemma l1Norm_X : l1Norm (Polynomial.X : Polynomial ℤ) = 1 := by simp [l1Norm, Finset.sum_range_succ] lemma l1Norm_add_le (f g : Polynomial ℤ) : l1Norm (f + g) ≤ l1Norm f + l1Norm g := by let N := max f.natDegree g.natDegree + 1 have hfg : (f + g).natDegree + 1 ≤ N := by have := Polynomial.natDegree_add_le f g; omega have hf : f.natDegree + 1 ≤ N := by omega have hg : g.natDegree + 1 ≤ N := by omega rw [l1Norm_eq_sum_range hfg, l1Norm_eq_sum_range hf, l1Norm_eq_sum_range hg, ← Finset.sum_add_distrib] refine Finset.sum_le_sum fun k _ => ?_ rw [Polynomial.coeff_add] exact Int.natAbs_add_le _ _ lemma l1Norm_sub_le (f g : Polynomial ℤ) : l1Norm (f - g) ≤ l1Norm f + l1Norm g := by let N := max f.natDegree g.natDegree + 1 have hfg : (f - g).natDegree + 1 ≤ N := by have := Polynomial.natDegree_sub_le f g; omega have hf : f.natDegree + 1 ≤ N := by omega have hg : g.natDegree + 1 ≤ N := by omega rw [l1Norm_eq_sum_range hfg, l1Norm_eq_sum_range hf, l1Norm_eq_sum_range hg, ← Finset.sum_add_distrib] refine Finset.sum_le_sum fun k _ => ?_ rw [Polynomial.coeff_sub, sub_eq_add_neg] calc (f.coeff k + -(g.coeff k)).natAbs ≤ (f.coeff k).natAbs + (-(g.coeff k)).natAbs := Int.natAbs_add_le _ _ _ = (f.coeff k).natAbs + (g.coeff k).natAbs := by rw [Int.natAbs_neg] lemma natAbs_sum_le {ι : Type*} (s : Finset ι) (f : ι → ℤ) : (∑ i ∈ s, f i).natAbs ≤ ∑ i ∈ s, (f i).natAbs := by classical induction s using Finset.induction_on with | empty => simp | @insert a s ha ih => rw [Finset.sum_insert ha, Finset.sum_insert ha] exact le_trans (Int.natAbs_add_le _ _) (Nat.add_le_add_left ih _) lemma l1Norm_mul_le (f g : Polynomial ℤ) : l1Norm (f * g) ≤ l1Norm f * l1Norm g := by let Nf := f.natDegree + 1 let Ng := g.natDegree + 1 have hfg : (f * g).natDegree + 1 ≤ Nf + Ng := by have := Polynomial.natDegree_mul_le (p := f) (q := g); omega rw [l1Norm_eq_sum_range hfg] unfold l1Norm rw [Finset.sum_mul] simp_rw [Finset.mul_sum] calc ∑ k ∈ Finset.range (Nf + Ng), ((f * g).coeff k).natAbs ≤ ∑ k ∈ Finset.range (Nf + Ng), ∑ ij ∈ Finset.antidiagonal k, (f.coeff ij.1).natAbs * (g.coeff ij.2).natAbs := by refine Finset.sum_le_sum fun k _ => ?_ rw [Polynomial.coeff_mul] calc (∑ ij ∈ Finset.antidiagonal k, f.coeff ij.1 * g.coeff ij.2).natAbs ≤ ∑ ij ∈ Finset.antidiagonal k, (f.coeff ij.1 * g.coeff ij.2).natAbs := natAbs_sum_le _ _ _ = ∑ ij ∈ Finset.antidiagonal k, (f.coeff ij.1).natAbs * (g.coeff ij.2).natAbs := by refine Finset.sum_congr rfl fun ij _ => Int.natAbs_mul _ _ _ = ∑ k ∈ Finset.range (Nf + Ng), ∑ ij ∈ (Finset.antidiagonal k).filter (fun ij => ij.1 < Nf ∧ ij.2 < Ng), (f.coeff ij.1).natAbs * (g.coeff ij.2).natAbs := by refine Finset.sum_congr rfl fun k _ => ?_ symm refine Finset.sum_subset (Finset.filter_subset _ _) ?_ intro ij hij hnot simp only [Finset.mem_filter, hij, true_and, not_and_or, not_lt] at hnot rcases hnot with h1 | h2 · have : f.natDegree < ij.1 := by omega simp [Polynomial.coeff_eq_zero_of_natDegree_lt this] · have : g.natDegree < ij.2 := by omega simp [Polynomial.coeff_eq_zero_of_natDegree_lt this] _ = ∑ i ∈ Finset.range Nf, ∑ j ∈ Finset.range Ng, (f.coeff i).natAbs * (g.coeff j).natAbs := by rw [show (∑ k ∈ Finset.range (Nf + Ng), ∑ ij ∈ (Finset.antidiagonal k).filter (fun ij => ij.1 < Nf ∧ ij.2 < Ng), (f.coeff ij.1).natAbs * (g.coeff ij.2).natAbs) = ∑ x ∈ (Finset.range (Nf + Ng)).sigma (fun k => (Finset.antidiagonal k).filter (fun ij => ij.1 < Nf ∧ ij.2 < Ng)), (f.coeff x.2.1).natAbs * (g.coeff x.2.2).natAbs from (Finset.sum_sigma (Finset.range (Nf + Ng)) (fun k => (Finset.antidiagonal k).filter (fun ij => ij.1 < Nf ∧ ij.2 < Ng)) (fun x => (f.coeff x.2.1).natAbs * (g.coeff x.2.2).natAbs)).symm, show (∑ i ∈ Finset.range Nf, ∑ j ∈ Finset.range Ng, (f.coeff i).natAbs * (g.coeff j).natAbs) = ∑ p ∈ Finset.range Nf ×ˢ Finset.range Ng, (f.coeff p.1).natAbs * (g.coeff p.2).natAbs from (Finset.sum_product (Finset.range Nf) (Finset.range Ng) (fun p => (f.coeff p.1).natAbs * (g.coeff p.2).natAbs)).symm] refine Finset.sum_bij (fun (x : Σ _ : ℕ, ℕ × ℕ) _ => x.2) ?_ ?_ ?_ ?_ · intro x hx simp only [Finset.mem_sigma, Finset.mem_range, Finset.mem_filter, Finset.mem_product] at hx ⊢ exact hx.2.2 · intro x₁ hx₁ x₂ hx₂ heq simp only [Finset.mem_sigma, Finset.mem_filter, Finset.mem_antidiagonal] at hx₁ hx₂ have hfst : x₁.1 = x₂.1 := by rw [← hx₁.2.1, ← hx₂.2.1, heq] exact Sigma.ext hfst (by simp [heq]) · intro p hp simp only [Finset.mem_product, Finset.mem_range] at hp refine ⟨⟨p.1 + p.2, p⟩, ?_, rfl⟩ simp only [Finset.mem_sigma, Finset.mem_range, Finset.mem_filter, Finset.mem_antidiagonal] exact ⟨by omega, trivial, hp.1, hp.2⟩ · intro _ _; rfl lemma sum_sq_le_sq_sum (s : Finset ℕ) (a : ℕ → ℕ) : ∑ k ∈ s, (a k) ^ 2 ≤ (∑ k ∈ s, a k) ^ 2 := by classical induction s using Finset.induction_on with | empty => simp | @insert x s hx ih => rw [Finset.sum_insert hx, Finset.sum_insert hx, add_sq] omega lemma l2Sq_le_l1Norm_sq (f : Polynomial ℤ) : l2Sq f ≤ (l1Norm f) ^ 2 := sum_sq_le_sq_sum _ _ lemma natAbs_leadingCoeff_sq_le_l2Sq (f : Polynomial ℤ) : f.leadingCoeff.natAbs ^ 2 ≤ l2Sq f := by unfold l2Sq rw [Polynomial.leadingCoeff] exact Finset.single_le_sum (f := fun k => (f.coeff k).natAbs ^ 2) (fun _ _ => Nat.zero_le _) (Finset.mem_range.mpr (Nat.lt_succ_self _)) /-! ## 2. Exact 1-Step `L₂`-Reflection Identity over `ℤ[X]` -/ /-- **1-Step `L₂`-Reflection Identity:** For every `f ∈ ℤ[X]` and every `r ∈ ℤ`, `‖f · (X - r)‖₂² = ‖f · (1 - r X)‖₂²`. -/ theorem l2Sq_mul_X_sub_eq_one_sub_mul_X (f : Polynomial ℤ) (r : ℤ) : l2Sq (f * (Polynomial.X - Polynomial.C r)) = l2Sq (f * (1 - Polynomial.C r * Polynomial.X)) := by have hdeg1 : (f * (Polynomial.X - Polynomial.C r)).natDegree + 1 ≤ f.natDegree + 2 := by have h1 := Polynomial.natDegree_mul_le (p := f) (q := Polynomial.X - Polynomial.C r) have h2 : (Polynomial.X - Polynomial.C r).natDegree ≤ 1 := by calc (Polynomial.X - Polynomial.C r).natDegree ≤ max Polynomial.X.natDegree (Polynomial.C r).natDegree := Polynomial.natDegree_sub_le _ _ _ ≤ 1 := by simp omega have hdeg2 : (f * (1 - Polynomial.C r * Polynomial.X)).natDegree + 1 ≤ f.natDegree + 2 := by have h1 := Polynomial.natDegree_mul_le (p := f) (q := 1 - Polynomial.C r * Polynomial.X) have h2 : (1 - Polynomial.C r * Polynomial.X).natDegree ≤ 1 := by calc (1 - Polynomial.C r * Polynomial.X).natDegree ≤ max (1 : Polynomial ℤ).natDegree (Polynomial.C r * Polynomial.X).natDegree := Polynomial.natDegree_sub_le _ _ _ ≤ 1 := by have h1' : (1 : Polynomial ℤ).natDegree = 0 := Polynomial.natDegree_one have h2' := Polynomial.natDegree_mul_le (p := Polynomial.C r) (q := Polynomial.X) have hC : (Polynomial.C r).natDegree = 0 := Polynomial.natDegree_C r have hX : (Polynomial.X : Polynomial ℤ).natDegree = 1 := Polynomial.natDegree_X omega omega rw [l2Sq_eq_sum_range hdeg1, l2Sq_eq_sum_range hdeg2] -- Cast to ℤ where (a.natAbs : ℤ)^2 = a^2 so `ring` closes the algebraic identity! apply (Nat.cast_inj (R := ℤ)).mp simp only [Nat.cast_sum, Nat.cast_pow, Int.natAbs_sq] have hcoeff1_zero : (f * (Polynomial.X - Polynomial.C r)).coeff 0 = -(r * f.coeff 0) := by rw [mul_sub, Polynomial.coeff_sub, Polynomial.coeff_mul_X_zero, Polynomial.coeff_mul_C]; ring have hcoeff1_succ : ∀ k : ℕ, (f * (Polynomial.X - Polynomial.C r)).coeff (k + 1) = f.coeff k - r * f.coeff (k + 1) := by intro k rw [mul_sub, Polynomial.coeff_sub, Polynomial.coeff_mul_X, Polynomial.coeff_mul_C] ring have hcoeff2_zero : (f * (1 - Polynomial.C r * Polynomial.X)).coeff 0 = f.coeff 0 := by rw [mul_sub, mul_one, ← mul_assoc, Polynomial.coeff_sub, Polynomial.coeff_mul_X_zero, sub_zero] have hcoeff2_succ : ∀ k : ℕ, (f * (1 - Polynomial.C r * Polynomial.X)).coeff (k + 1) = f.coeff (k + 1) - r * f.coeff k := by intro k rw [mul_sub, mul_one, ← mul_assoc, Polynomial.coeff_sub, Polynomial.coeff_mul_X, Polynomial.coeff_mul_C] ring have htop : f.coeff (f.natDegree + 1) = 0 := Polynomial.coeff_eq_zero_of_natDegree_lt (Nat.lt_succ_self _) -- Split off k = 0 on both sides using `Finset.sum_range_succ'` conv_lhs => rw [Finset.sum_range_succ'] conv_rhs => rw [Finset.sum_range_succ'] rw [hcoeff1_zero, hcoeff2_zero] simp_rw [hcoeff1_succ, hcoeff2_succ] -- Expand squares and compare term-by-term! have hexp1 : ∑ k ∈ Finset.range (f.natDegree + 1), (f.coeff k - r * f.coeff (k + 1)) ^ 2 = (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff k ^ 2) + r ^ 2 * (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff (k + 1) ^ 2) - 2 * r * (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff k * f.coeff (k + 1)) := by rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun k _ => by ring have hexp2 : ∑ k ∈ Finset.range (f.natDegree + 1), (f.coeff (k + 1) - r * f.coeff k) ^ 2 = (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff (k + 1) ^ 2) + r ^ 2 * (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff k ^ 2) - 2 * r * (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff k * f.coeff (k + 1)) := by rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun k _ => by ring have hshift : (∑ k ∈ Finset.range (f.natDegree + 1), f.coeff (k + 1) ^ 2) + f.coeff 0 ^ 2 = ∑ k ∈ Finset.range (f.natDegree + 1), f.coeff k ^ 2 := by have h1 := Finset.sum_range_succ' (fun k => f.coeff k ^ 2) (f.natDegree + 1) have h2 := Finset.sum_range_succ (fun k => f.coeff k ^ 2) (f.natDegree + 1) rw [htop] at h2 linarith rw [hexp1, hexp2, ← hshift] ring /-! ## 3. Multi-Root Reflection & Product of Nonzero Roots Bound -/ lemma l2Sq_mul_prod_X_sub_eq_reflected (Q : Polynomial ℤ) (S : Finset ℤ) : l2Sq (Q * ∏ r ∈ S, (Polynomial.X - Polynomial.C r)) = l2Sq (Q * ∏ r ∈ S, (1 - Polynomial.C r * Polynomial.X)) := by classical induction S using Finset.induction_on generalizing Q with | empty => simp | @insert a s ha ih => rw [Finset.prod_insert ha, Finset.prod_insert ha] have h1 : Q * ((Polynomial.X - Polynomial.C a) * ∏ r ∈ s, (Polynomial.X - Polynomial.C r)) = (Q * (Polynomial.X - Polynomial.C a)) * ∏ r ∈ s, (Polynomial.X - Polynomial.C r) := by ring have h2 : Q * ((1 - Polynomial.C a * Polynomial.X) * ∏ r ∈ s, (1 - Polynomial.C r * Polynomial.X)) = (Q * ∏ r ∈ s, (1 - Polynomial.C r * Polynomial.X)) * (1 - Polynomial.C a * Polynomial.X) := by ring rw [h1, ih (Q * (Polynomial.X - Polynomial.C a))] have h3 : (Q * (Polynomial.X - Polynomial.C a)) * ∏ r ∈ s, (1 - Polynomial.C r * Polynomial.X) = (Q * ∏ r ∈ s, (1 - Polynomial.C r * Polynomial.X)) * (Polynomial.X - Polynomial.C a) := by ring rw [h3, l2Sq_mul_X_sub_eq_one_sub_mul_X, ← h2] lemma exists_mul_prod_X_sub_of_roots (f : Polynomial ℤ) (hf : f ≠ 0) (S : Finset ℤ) (hS : ∀ r ∈ S, f.IsRoot r) : ∃ Q : Polynomial ℤ, Q ≠ 0 ∧ f = Q * ∏ r ∈ S, (Polynomial.X - Polynomial.C r) := by classical induction S using Finset.induction_on generalizing f with | empty => exact ⟨f, hf, by simp⟩ | @insert a s ha ih => have ha_root : f.IsRoot a := hS a (Finset.mem_insert_self a s) rcases Polynomial.dvd_iff_isRoot.mpr ha_root with ⟨g, hg⟩ have hg_ne : g ≠ 0 := by intro h0; rw [h0, mul_zero] at hg; exact hf hg have hs_root : ∀ r ∈ s, g.IsRoot r := by intro r hr have hfr : f.eval r = 0 := hS r (Finset.mem_insert_of_mem hr) rw [hg, Polynomial.eval_mul, Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C] at hfr have hne : r - a ≠ 0 := sub_ne_zero.mpr (fun h => ha (h ▸ hr)) exact (mul_eq_zero.mp hfr).resolve_left hne rcases ih g hg_ne hs_root with ⟨Q, hQ_ne, hQ⟩ refine ⟨Q, hQ_ne, ?_⟩ rw [Finset.prod_insert ha, hg, hQ] ring lemma leadingCoeff_one_sub_C_mul_X {r : ℤ} (hr : r ≠ 0) : (1 - Polynomial.C r * Polynomial.X).leadingCoeff = -r := by have hcoeff1 : (1 - Polynomial.C r * Polynomial.X).coeff 1 = -r := by rw [Polynomial.coeff_sub, Polynomial.coeff_one, Polynomial.coeff_C_mul_X] simp have hdeg_le : (1 - Polynomial.C r * Polynomial.X).natDegree ≤ 1 := by have hsub := Polynomial.natDegree_sub_le (1 : Polynomial ℤ) (Polynomial.C r * Polynomial.X) have hmul := Polynomial.natDegree_mul_le (p := Polynomial.C r) (q := Polynomial.X) have h1' : (1 : Polynomial ℤ).natDegree = 0 := Polynomial.natDegree_one have hC : (Polynomial.C r).natDegree = 0 := Polynomial.natDegree_C r have hX : (Polynomial.X : Polynomial ℤ).natDegree = 1 := Polynomial.natDegree_X omega have hdeg_ge : 1 ≤ (1 - Polynomial.C r * Polynomial.X).natDegree := Polynomial.le_natDegree_of_ne_zero (by rw [hcoeff1]; exact neg_ne_zero.mpr hr) have hdeg : (1 - Polynomial.C r * Polynomial.X).natDegree = 1 := le_antisymm hdeg_le hdeg_ge rw [Polynomial.leadingCoeff, hdeg, hcoeff1] lemma natAbs_prod_neg (S : Finset ℤ) : (∏ r ∈ S, (-r : ℤ)).natAbs = ∏ r ∈ S, r.natAbs := by classical induction S using Finset.induction_on with | empty => simp | @insert a s ha ih => rw [Finset.prod_insert ha, Finset.prod_insert ha, Int.natAbs_mul, Int.natAbs_neg, ih] /-- **Multi-Root `L₁`-Norm Bound:** For every nonzero `f ∈ ℤ[X]` and any finite set `S` of nonzero integer roots of `f`, `∏ r ∈ S, r.natAbs ≤ l1Norm f`. -/ theorem prod_natAbs_roots_le_l1Norm {f : Polynomial ℤ} (hf : f ≠ 0) (S : Finset ℤ) (hS : ∀ r ∈ S, f.IsRoot r) (hne : ∀ r ∈ S, r ≠ 0) : ∏ r ∈ S, r.natAbs ≤ l1Norm f := by rcases exists_mul_prod_X_sub_of_roots f hf S hS with ⟨Q, hQ_ne, hQ⟩ let Pstar := Q * ∏ r ∈ S, (1 - Polynomial.C r * Polynomial.X) have hlc : Pstar.leadingCoeff = Q.leadingCoeff * ∏ r ∈ S, (-r) := by dsimp [Pstar] rw [Polynomial.leadingCoeff_mul, Polynomial.leadingCoeff_prod] congr 1 refine Finset.prod_congr rfl fun r hr => leadingCoeff_one_sub_C_mul_X (hne r hr) have hQ_pos : 1 ≤ Q.leadingCoeff.natAbs := by have hlc_ne : Q.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hQ_ne exact Nat.pos_of_ne_zero (Int.natAbs_ne_zero.mpr hlc_ne) have hprod_le : ∏ r ∈ S, r.natAbs ≤ Pstar.leadingCoeff.natAbs := by rw [hlc, Int.natAbs_mul, natAbs_prod_neg] exact Nat.le_mul_of_pos_left _ hQ_pos have hsq : (∏ r ∈ S, r.natAbs) ^ 2 ≤ (l1Norm f) ^ 2 := by calc (∏ r ∈ S, r.natAbs) ^ 2 ≤ Pstar.leadingCoeff.natAbs ^ 2 := Nat.pow_le_pow_left hprod_le 2 _ ≤ l2Sq Pstar := natAbs_leadingCoeff_sq_le_l2Sq Pstar _ = l2Sq f := by rw [hQ, l2Sq_mul_prod_X_sub_eq_reflected] _ ≤ (l1Norm f) ^ 2 := l2Sq_le_l1Norm_sq f nlinarith /-! ## 4. SLP `L₁`-Norm Upper Bound -/ /-- For `τ ≥ 1`, every wire of `P : SLP τ` has `l1Norm ≤ 2 ^ (2 ^ (τ - 1))`. -/ lemma slp_evalWire_l1Norm_le : ∀ {τ : ℕ} (P : SLP τ) (k : Fin (τ + 2)), l1Norm (P.evalWire k) ≤ if τ = 0 then 1 else 2 ^ (2 ^ (τ - 1)) | 0, .nil, k => by simp only [SLP.evalWire, ↓reduceIte] split_ifs · simp [l1Norm_one] · simp [l1Norm_X] | τ + 1, .snoc P op i j, k => by simp only [Nat.succ_ne_zero, ↓reduceIte, Nat.add_sub_cancel] simp only [SLP.evalWire] split_ifs with hk · have ih := slp_evalWire_l1Norm_le P ⟨k.val, hk⟩ cases τ with | zero => simp only [↓reduceIte] at ih exact le_trans ih (by norm_num) | succ m => simp only [Nat.succ_ne_zero, ↓reduceIte, Nat.add_sub_cancel] at ih refine le_trans ih (Nat.pow_le_pow_right (by norm_num) ?_) exact Nat.pow_le_pow_right (by norm_num) (Nat.le_succ m) · have ihi := slp_evalWire_l1Norm_le P i have ihj := slp_evalWire_l1Norm_le P j cases τ with | zero => simp only [↓reduceIte] at ihi ihj cases op with | add => calc l1Norm (P.evalWire i + P.evalWire j) ≤ l1Norm (P.evalWire i) + l1Norm (P.evalWire j) := l1Norm_add_le _ _ _ ≤ 1 + 1 := Nat.add_le_add ihi ihj _ = 2 ^ (2 ^ 0) := by norm_num | sub => calc l1Norm (P.evalWire i - P.evalWire j) ≤ l1Norm (P.evalWire i) + l1Norm (P.evalWire j) := l1Norm_sub_le _ _ _ ≤ 1 + 1 := Nat.add_le_add ihi ihj _ = 2 ^ (2 ^ 0) := by norm_num | mul => calc l1Norm (P.evalWire i * P.evalWire j) ≤ l1Norm (P.evalWire i) * l1Norm (P.evalWire j) := l1Norm_mul_le _ _ _ ≤ 1 * 1 := Nat.mul_le_mul ihi ihj _ ≤ 2 ^ (2 ^ 0) := by norm_num | succ m => simp only [Nat.succ_ne_zero, ↓reduceIte, Nat.add_sub_cancel] at ihi ihj set B := 2 ^ (2 ^ m) with hB_def have hB2 : 2 ≤ B := by rw [hB_def] have : 1 ≤ 2 ^ m := Nat.one_le_two_pow calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ (2 ^ m) := Nat.pow_le_pow_right (by norm_num) this have hBsq : B * B = 2 ^ (2 ^ (m + 1)) := by rw [hB_def, ← pow_add, pow_succ, mul_two] cases op with | add => calc l1Norm (P.evalWire i + P.evalWire j) ≤ l1Norm (P.evalWire i) + l1Norm (P.evalWire j) := l1Norm_add_le _ _ _ ≤ B + B := Nat.add_le_add ihi ihj _ = 2 * B := by ring _ ≤ B * B := Nat.mul_le_mul_right B hB2 _ = 2 ^ (2 ^ (m + 1)) := hBsq | sub => calc l1Norm (P.evalWire i - P.evalWire j) ≤ l1Norm (P.evalWire i) + l1Norm (P.evalWire j) := l1Norm_sub_le _ _ _ ≤ B + B := Nat.add_le_add ihi ihj _ = 2 * B := by ring _ ≤ B * B := Nat.mul_le_mul_right B hB2 _ = 2 ^ (2 ^ (m + 1)) := hBsq | mul => calc l1Norm (P.evalWire i * P.evalWire j) ≤ l1Norm (P.evalWire i) * l1Norm (P.evalWire j) := l1Norm_mul_le _ _ _ ≤ B * B := Nat.mul_le_mul ihi ihj _ = 2 ^ (2 ^ (m + 1)) := hBsq /-- Every constant-free `P : SLP τ` (`τ ≥ 1`) satisfies `l1Norm P.evalPoly ≤ 2 ^ (2 ^ (τ - 1))`. -/ theorem slp_l1Norm_le {τ : ℕ} (hτ : 1 ≤ τ) (P : SLP τ) : l1Norm P.evalPoly ≤ 2 ^ (2 ^ (τ - 1)) := by have h := slp_evalWire_l1Norm_le P ⟨τ + 1, Nat.lt_succ_self _⟩ have hne : τ ≠ 0 := by omega simpa [SLP.evalPoly, hne] using h /-- Count of leading `.mul` gates before the first `.add`/`.sub` gate (i.e. `t₀`). -/ def SLP.mulPrefixLen : {τ : ℕ} → SLP τ → ℕ | 0, .nil => 0 | τ + 1, .snoc P op _ _ => if P.mulPrefixLen = τ ∧ op = .mul then τ + 1 else P.mulPrefixLen lemma SLP.mulPrefixLen_le : ∀ {τ : ℕ} (P : SLP τ), P.mulPrefixLen ≤ τ | 0, .nil => le_rfl | τ + 1, .snoc P op _ _ => by have ih := P.mulPrefixLen_le change (if P.mulPrefixLen = τ ∧ op = .mul then τ + 1 else P.mulPrefixLen) ≤ τ + 1 split_ifs <;> omega /-- Refined `L₁`-norm bound accounting for a leading multiplication prefix of length `t₀`: every wire of `P : SLP τ` has `l1Norm ≤ 1` if `t₀ = τ`, else `≤ 2 ^ (2 ^ (τ - t₀ - 1))`. -/ lemma slp_evalWire_l1Norm_le_shifted : ∀ {τ : ℕ} (P : SLP τ) (k : Fin (τ + 2)), l1Norm (P.evalWire k) ≤ if P.mulPrefixLen = τ then 1 else 2 ^ (2 ^ (τ - P.mulPrefixLen - 1)) | 0, .nil, k => by simp only [SLP.mulPrefixLen, ↓reduceIte, SLP.evalWire] split_ifs · simp [l1Norm_one] · simp [l1Norm_X] | τ + 1, .snoc P op i j, k => by have hple := P.mulPrefixLen_le by_cases hall : P.mulPrefixLen = τ ∧ op = .mul · rcases hall with ⟨hpt, hop⟩ have hpref : (SLP.snoc P op i j).mulPrefixLen = τ + 1 := by simp [SLP.mulPrefixLen, hpt, hop] rw [hpref]; simp only [↓reduceIte, SLP.evalWire] split_ifs with hk · have ih := slp_evalWire_l1Norm_le_shifted P ⟨k.val, hk⟩ simpa [hpt] using ih · have ihi := slp_evalWire_l1Norm_le_shifted P i have ihj := slp_evalWire_l1Norm_le_shifted P j simp only [hpt, ↓reduceIte] at ihi ihj rw [hop] calc l1Norm (P.evalWire i * P.evalWire j) ≤ l1Norm (P.evalWire i) * l1Norm (P.evalWire j) := l1Norm_mul_le _ _ _ ≤ 1 * 1 := Nat.mul_le_mul ihi ihj _ = 1 := one_mul 1 · have hpref : (SLP.snoc P op i j).mulPrefixLen = P.mulPrefixLen := by simp [SLP.mulPrefixLen, hall] have hne : P.mulPrefixLen ≠ τ + 1 := by omega rw [hpref]; simp only [hne, ↓reduceIte, SLP.evalWire] by_cases hpt : P.mulPrefixLen = τ · have hsub : τ + 1 - P.mulPrefixLen - 1 = 0 := by omega rw [hsub] split_ifs with hk · have ih := slp_evalWire_l1Norm_le_shifted P ⟨k.val, hk⟩ simp only [hpt, ↓reduceIte] at ih exact le_trans ih (by norm_num) · have ihi := slp_evalWire_l1Norm_le_shifted P i have ihj := slp_evalWire_l1Norm_le_shifted P j simp only [hpt, ↓reduceIte] at ihi ihj cases op with | add => exact le_trans (l1Norm_add_le _ _) (by omega) | sub => exact le_trans (l1Norm_sub_le _ _) (by omega) | mul => exact False.elim (hall ⟨hpt, rfl⟩) · set e := τ - P.mulPrefixLen - 1 with he_def have hsub : τ + 1 - P.mulPrefixLen - 1 = e + 1 := by omega rw [hsub] set B := 2 ^ (2 ^ e) with hB_def have hB2 : 2 ≤ B := by rw [hB_def] have : 1 ≤ 2 ^ e := Nat.one_le_two_pow calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ (2 ^ e) := Nat.pow_le_pow_right (by norm_num) this have hBsq : B * B = 2 ^ (2 ^ (e + 1)) := by rw [hB_def, ← pow_add, pow_succ, mul_two] split_ifs with hk · have ih := slp_evalWire_l1Norm_le_shifted P ⟨k.val, hk⟩ simp only [hpt, ↓reduceIte] at ih rw [← he_def] at ih exact le_trans ih (by rw [← hBsq]; exact Nat.le_mul_of_pos_right B (by omega)) · have ihi := slp_evalWire_l1Norm_le_shifted P i have ihj := slp_evalWire_l1Norm_le_shifted P j simp only [hpt, ↓reduceIte] at ihi ihj rw [← he_def] at ihi ihj cases op with | add => calc l1Norm (P.evalWire i + P.evalWire j) ≤ B + B := le_trans (l1Norm_add_le _ _) (Nat.add_le_add ihi ihj) _ = 2 * B := by ring _ ≤ B * B := Nat.mul_le_mul_right B hB2 _ = 2 ^ (2 ^ (e + 1)) := hBsq | sub => calc l1Norm (P.evalWire i - P.evalWire j) ≤ B + B := le_trans (l1Norm_sub_le _ _) (Nat.add_le_add ihi ihj) _ = 2 * B := by ring _ ≤ B * B := Nat.mul_le_mul_right B hB2 _ = 2 ^ (2 ^ (e + 1)) := hBsq | mul => calc l1Norm (P.evalWire i * P.evalWire j) ≤ B * B := le_trans (l1Norm_mul_le _ _) (Nat.mul_le_mul ihi ihj) _ = 2 ^ (2 ^ (e + 1)) := hBsq /-! ## 5. Pure-`ℕ` Factorial Pairing Bound -/ /-- At most `2 * m` integers satisfy `2 ≤ r.natAbs ∧ r.natAbs ≤ m + 1`. -/ lemma card_filter_natAbs_between_le (S : Finset ℤ) (m : ℕ) : (S.filter (fun r => 2 ≤ r.natAbs ∧ r.natAbs ≤ m + 1)).card ≤ 2 * m := by let posSet : Finset ℤ := (Finset.Icc 2 (m + 1)).image (fun n : ℕ => (n : ℤ)) let negSet : Finset ℤ := (Finset.Icc 2 (m + 1)).image (fun n : ℕ => -(n : ℤ)) have hsub : S.filter (fun r => 2 ≤ r.natAbs ∧ r.natAbs ≤ m + 1) ⊆ posSet ∪ negSet := by intro r hr simp only [Finset.mem_filter] at hr rcases hr.2 with ⟨h2, hm⟩ rw [Finset.mem_union] rcases Int.natAbs_eq r with hpos | hneg · left exact Finset.mem_image.mpr ⟨r.natAbs, Finset.mem_Icc.mpr ⟨h2, hm⟩, hpos.symm⟩ · right exact Finset.mem_image.mpr ⟨r.natAbs, Finset.mem_Icc.mpr ⟨h2, hm⟩, by omega⟩ calc (S.filter (fun r => 2 ≤ r.natAbs ∧ r.natAbs ≤ m + 1)).card ≤ (posSet ∪ negSet).card := Finset.card_le_card hsub _ ≤ posSet.card + negSet.card := Finset.card_union_le _ _ _ ≤ (Finset.Icc 2 (m + 1)).card + (Finset.Icc 2 (m + 1)).card := Nat.add_le_add Finset.card_image_le Finset.card_image_le _ = 2 * m := by rw [Nat.card_Icc]; omega /-- For any `S : Finset ℤ` with `∀ r ∈ S, 2 ≤ r.natAbs` and `2 * m ≤ S.card`, `((m + 1)!)^2 ≤ ∏ r ∈ S, r.natAbs`. -/ lemma factorial_sq_le_prod_natAbs : ∀ (m : ℕ) (S : Finset ℤ), (∀ r ∈ S, 2 ≤ r.natAbs) → 2 * m ≤ S.card → ((m + 1).factorial) ^ 2 ≤ ∏ r ∈ S, r.natAbs | 0, S, hge, _ => by simp only [zero_add, Nat.factorial_one, one_pow] exact Finset.one_le_prod fun r hr => by have := hge r hr; omega | m + 1, S, hge, hcard => by let Ssmall := S.filter (fun r => r.natAbs ≤ m + 1) let Sbig := S.filter (fun r => ¬ r.natAbs ≤ m + 1) have hsmall_eq : Ssmall = S.filter (fun r => 2 ≤ r.natAbs ∧ r.natAbs ≤ m + 1) := by ext r; simp only [Ssmall, Finset.mem_filter] exact ⟨fun ⟨hr, hle⟩ => ⟨hr, hge r hr, hle⟩, fun ⟨hr, _, hle⟩ => ⟨hr, hle⟩⟩ have hsmall_le : Ssmall.card ≤ 2 * m := by rw [hsmall_eq]; exact card_filter_natAbs_between_le S m have hpart : Ssmall.card + Sbig.card = S.card := Finset.card_filter_add_card_filter_not (s := S) (fun r : ℤ => r.natAbs ≤ m + 1) have hbig_ge : 2 ≤ Sbig.card := by omega rcases Finset.one_lt_card.mp (by omega : 1 < Sbig.card) with ⟨a, ha, b, hb, hab⟩ have haS : a ∈ S := (Finset.mem_filter.mp ha).1 have hbS : b ∈ S := (Finset.mem_filter.mp hb).1 have ha_ge : m + 2 ≤ a.natAbs := by have := (Finset.mem_filter.mp ha).2; omega have hb_ge : m + 2 ≤ b.natAbs := by have := (Finset.mem_filter.mp hb).2; omega let S' := (S.erase a).erase b have hb_er : b ∈ S.erase a := Finset.mem_erase.mpr ⟨hab.symm, hbS⟩ have hcard' : 2 * m ≤ S'.card := by rw [Finset.card_erase_of_mem hb_er, Finset.card_erase_of_mem haS] omega have hge' : ∀ r ∈ S', 2 ≤ r.natAbs := fun r hr => hge r (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hr)) have ih := factorial_sq_le_prod_natAbs m S' hge' hcard' have hprod : ∏ r ∈ S, r.natAbs = a.natAbs * (b.natAbs * ∏ r ∈ S', r.natAbs) := by rw [← Finset.mul_prod_erase S _ haS] congr 1 exact (Finset.mul_prod_erase (S.erase a) _ hb_er).symm rw [hprod, Nat.factorial_succ, mul_pow] have hab_mul : (m + 2) ^ 2 ≤ a.natAbs * b.natAbs := by nlinarith calc (m + 1 + 1) ^ 2 * (m + 1).factorial ^ 2 ≤ (a.natAbs * b.natAbs) * ∏ r ∈ S', r.natAbs := Nat.mul_le_mul hab_mul ih _ = a.natAbs * (b.natAbs * ∏ r ∈ S', r.natAbs) := by ring /-- Pure-`ℕ` pairing inequality: `k ^ k ≤ (k!) ^ 2` for every `k : ℕ`. -/ lemma pow_self_le_factorial_sq (k : ℕ) : k ^ k ≤ (k.factorial) ^ 2 := by have hprod_fact : ∏ i ∈ Finset.range k, (i + 1) = k.factorial := by induction k with | zero => simp | succ n ih => rw [Finset.prod_range_succ, ih, Nat.factorial_succ, mul_comm] have hprod_rev : ∏ i ∈ Finset.range k, (k - i) = k.factorial := by rw [← hprod_fact] refine Finset.prod_bij (fun i _ => k - 1 - i) ?_ ?_ ?_ ?_ · intro i hi; simp only [Finset.mem_range] at hi ⊢; omega · intro i hi j hj hij; simp only [Finset.mem_range] at hi hj; omega · intro j hj; simp only [Finset.mem_range] at hj exact ⟨k - 1 - j, Finset.mem_range.mpr (by omega), by omega⟩ · intro i hi; simp only [Finset.mem_range] at hi; omega calc k ^ k = ∏ _i ∈ Finset.range k, k := by simp _ ≤ ∏ i ∈ Finset.range k, ((i + 1) * (k - i)) := by refine Finset.prod_le_prod fun i hi => ?_ have hi' : i < k := Finset.mem_range.mp hi have h1 : (i + 1) * (k - i) = k + i * (k - 1 - i) := by zify [show i ≤ k by omega, show i ≤ k - 1 by omega, show 1 ≤ k by omega]; ring omega _ = (∏ i ∈ Finset.range k, (i + 1)) * (∏ i ∈ Finset.range k, (k - i)) := Finset.prod_mul_distrib _ = (k.factorial) ^ 2 := by rw [hprod_fact, hprod_rev, sq] /-- At most `3` integers have `r.natAbs < 2` (namely `-1, 0, 1`). -/ lemma card_filter_natAbs_lt_two_le (T : Finset ℤ) : (T.filter (fun r => r.natAbs < 2)).card ≤ 3 := by have hsub : T.filter (fun r => r.natAbs < 2) ⊆ ({-1, 0, 1} : Finset ℤ) := by intro r hr have hlt := (Finset.mem_filter.mp hr).2 simp only [Finset.mem_insert, Finset.mem_singleton] omega exact le_trans (Finset.card_le_card hsub) (by decide) /-! ## 6. Main Unconditional Elementary `O(2^τ / τ)` Theorems -/ /-- Pure-`ℕ` arithmetic closure: if `k ^ k ≤ 2 ^ (2 ^ (n - 1))` and `z ≤ 2 * k + 2` and `z ≤ 2 ^ n`, then `n * z ≤ 3 * 2 ^ n`. -/ lemma nat_l2_closure {n z k : ℕ} (hz_deg : z ≤ 2 ^ n) (hz_k : z ≤ 2 * k + 2) (hkk : n ≥ 1 → k ^ k ≤ 2 ^ (2 ^ (n - 1))) : n * z ≤ 3 * 2 ^ n := by by_cases hn3 : n ≤ 3 · exact le_trans (Nat.mul_le_mul_right z hn3) (Nat.mul_le_mul_left 3 hz_deg) · push Not at hn3 -- Now n ≥ 4! by_contra hgt push Not at hgt have hn1 : 1 ≤ n := by omega have hkk' := hkk hn1 set h := n / 2 with hh_def have hh2 : 2 ≤ h := by omega -- Step A: show 2 ^ (n - 1) < h * k have h_two_n_ge : 2 * n ≤ 2 ^ (n - 1) + 2 := by -- For n ≥ 4: 2*4 = 8 ≤ 8 + 2 = 10; induction step doubles RHS have hind : ∀ m : ℕ, 4 ≤ m → 2 * m ≤ 2 ^ (m - 1) + 2 := by intro m hm induction m with | zero => omega | succ r ih => by_cases hr : r = 3 · subst hr; norm_num · have hr4 : 4 ≤ r := by omega have ihr := ih hr4 have hpow : 2 ^ r = 2 * 2 ^ (r - 1) := by conv_lhs => rw [← Nat.sub_add_cancel (by omega : 1 ≤ r), pow_succ, mul_comm] simp only [Nat.add_sub_cancel] at ihr ⊢ omega exact hind n hn3 have h_hk_gt : 2 ^ (n - 1) < h * k := by have hpow_n : 2 ^ n = 2 * 2 ^ (n - 1) := by conv_lhs => rw [← Nat.sub_add_cancel hn1, pow_succ, mul_comm] have hn_le : n ≤ 2 * h + 1 := by omega -- 6 * 2^(n-1) = 3 * 2^n < n * z ≤ n * (2k + 2) = 2*n*k + 2*n -- And 2*n*k ≤ (4*h + 2)*k ≤ 5*h*k (since h ≥ 2 => 2 ≤ h) -- Wait: at n = 4 (h = 2): 3*16 = 48 < 4*z => z ≥ 13 => k ≥ 6 => h*k = 12 > 8 = 2^3! by_cases hn4 : n = 4 · subst hn4 have : 13 ≤ z := by omega have : 6 ≤ k := by omega norm_num [h] at *; omega · have hn5 : 5 ≤ n := by omega have h2n_le : 2 * n ≤ 2 ^ (n - 1) := by have hind : ∀ m : ℕ, 5 ≤ m → 2 * m ≤ 2 ^ (m - 1) := by intro m hm induction m with | zero => omega | succ r ih => by_cases hr : r = 4 · subst hr; norm_num · have ihr := ih (by omega) have hpow : 2 ^ r = 2 * 2 ^ (r - 1) := by conv_lhs => rw [← Nat.sub_add_cancel (by omega : 1 ≤ r), pow_succ, mul_comm] simp only [Nat.add_sub_cancel] at ihr ⊢ omega exact hind n hn5 have h1 : 6 * 2 ^ (n - 1) < n * (2 * k + 2) := by calc 6 * 2 ^ (n - 1) = 3 * 2 ^ n := by rw [hpow_n]; ring _ < n * z := hgt _ ≤ n * (2 * k + 2) := Nat.mul_le_mul_left n hz_k have h2 : n * (2 * k + 2) ≤ 5 * (h * k) + 2 ^ (n - 1) := by have hnk : 2 * n * k ≤ 5 * (h * k) := by have : 2 * n ≤ 5 * h := by omega calc 2 * n * k ≤ (5 * h) * k := Nat.mul_le_mul_right k this _ = 5 * (h * k) := by ring nlinarith omega -- Step B: show 2 ^ h ≤ k (since h ≤ 2 ^ (h - 1) ≤ 2 ^ (n - 1 - h)) have h_le_pow : h ≤ 2 ^ (n - 1 - h) := by have h1 : ∀ m : ℕ, 2 ≤ m → m ≤ 2 ^ (m - 1) := by intro m hm induction m with | zero => omega | succ r ih => by_cases hr : r = 1 · subst hr; norm_num · have ihr := ih (by omega) have hpow : 2 ^ r = 2 * 2 ^ (r - 1) := by conv_lhs => rw [← Nat.sub_add_cancel (by omega : 1 ≤ r), pow_succ, mul_comm] simp only [Nat.add_sub_cancel] at ihr ⊢ omega have h2 : h - 1 ≤ n - 1 - h := by omega exact le_trans (h1 h hh2) (Nat.pow_le_pow_right (by norm_num) h2) have h2h_le_k : 2 ^ h ≤ k := by by_contra hlt push Not at hlt have hmul : h * k ≤ 2 ^ (n - 1) := by calc h * k ≤ 2 ^ (n - 1 - h) * 2 ^ h := Nat.mul_le_mul h_le_pow (le_of_lt hlt) _ = 2 ^ (n - 1 - h + h) := (pow_add 2 _ _).symm _ = 2 ^ (n - 1) := by congr 1; omega omega -- Step C: Contradiction: 2^(2^(n-1)) < 2^(h*k) = (2^h)^k ≤ k^k ≤ 2^(2^(n-1))! have hcontra : 2 ^ (2 ^ (n - 1)) < k ^ k := by calc 2 ^ (2 ^ (n - 1)) < 2 ^ (h * k) := Nat.pow_lt_pow_right (by norm_num) h_hk_gt _ = (2 ^ h) ^ k := pow_mul 2 h k _ ≤ k ^ k := Nat.pow_le_pow_left h2h_le_k k omega /-- **Unconditional Pure-`ℤ` `L₂`-Reflection Theorem (`τ · z_ℤ(P) ≤ 3 · 2^τ`):** For every `τ : ℕ` and every constant-free straight-line program `P : SLP τ` with `P.evalPoly ≠ 0`: `τ * intRootCount P.evalPoly ≤ 3 * 2 ^ τ`. -/ theorem slp_intRootCount_l2_reflection {τ : ℕ} (P : SLP τ) (hP : P.evalPoly ≠ 0) : τ * intRootCount P.evalPoly ≤ 3 * 2 ^ τ := by let S := (intRootSet P.evalPoly).filter (fun r => 2 ≤ r.natAbs) have hpart : ((intRootSet P.evalPoly).filter (fun r => r.natAbs < 2)).card + S.card = intRootCount P.evalPoly := by have h := Finset.card_filter_add_card_filter_not (s := intRootSet P.evalPoly) (p := fun r => r.natAbs < 2) have hS_eq : S = (intRootSet P.evalPoly).filter (fun r => ¬ r.natAbs < 2) := by ext r; simp only [S, Finset.mem_filter, not_lt] rw [hS_eq]; exact h have hsmall := card_filter_natAbs_lt_two_le (intRootSet P.evalPoly) let m := S.card / 2 let k := m + 1 have hz_k : intRootCount P.evalPoly ≤ 2 * k + 2 := by omega have hz_deg : intRootCount P.evalPoly ≤ 2 ^ τ := slp_intRootCount_le_two_pow P hP refine nat_l2_closure hz_deg hz_k fun hτ => ?_ have hS_roots : ∀ r ∈ S, P.evalPoly.IsRoot r := fun r hr => (mem_intRootSet_iff.mp (Finset.mem_filter.mp hr).1).2 have hS_ge2 : ∀ r ∈ S, 2 ≤ r.natAbs := fun r hr => (Finset.mem_filter.mp hr).2 have hS_ne0 : ∀ r ∈ S, r ≠ 0 := fun r hr => by have := hS_ge2 r hr; omega calc k ^ k ≤ k.factorial ^ 2 := pow_self_le_factorial_sq k _ ≤ ∏ r ∈ S, r.natAbs := factorial_sq_le_prod_natAbs m S hS_ge2 (by omega) _ ≤ l1Norm P.evalPoly := prod_natAbs_roots_le_l1Norm hP S hS_roots hS_ne0 _ ≤ 2 ^ (2 ^ (τ - 1)) := slp_l1Norm_le hτ P /-- **Multiplication-Prefix Shifted `L₂`-Reflection Theorem:** If `t₀ = P.mulPrefixLen` is the length of the leading all-multiplication prefix of `P : SLP τ`, then `(τ - t₀) * intRootCount P.evalPoly ≤ 3 * 2 ^ (τ - t₀)`. -/ theorem slp_intRootCount_l2_reflection_shifted {τ : ℕ} (P : SLP τ) (hP : P.evalPoly ≠ 0) : (τ - P.mulPrefixLen) * intRootCount P.evalPoly ≤ 3 * 2 ^ (τ - P.mulPrefixLen) := by by_cases hall : P.mulPrefixLen = τ · rw [hall, Nat.sub_self, zero_mul]; exact Nat.zero_le _ · have hple := P.mulPrefixLen_le set n := τ - P.mulPrefixLen with hn_def have hn1 : 1 ≤ n := by omega let S := (intRootSet P.evalPoly).filter (fun r => 2 ≤ r.natAbs) have hpart : ((intRootSet P.evalPoly).filter (fun r => r.natAbs < 2)).card + S.card = intRootCount P.evalPoly := by have h := Finset.card_filter_add_card_filter_not (s := intRootSet P.evalPoly) (p := fun r => r.natAbs < 2) have hS_eq : S = (intRootSet P.evalPoly).filter (fun r => ¬ r.natAbs < 2) := by ext r; simp only [S, Finset.mem_filter, not_lt] rw [hS_eq]; exact h have hsmall := card_filter_natAbs_lt_two_le (intRootSet P.evalPoly) let m := S.card / 2 let k := m + 1 have hz_k : intRootCount P.evalPoly ≤ 2 * k + 2 := by omega have hkk : k ^ k ≤ 2 ^ (2 ^ (n - 1)) := by have hS_roots : ∀ r ∈ S, P.evalPoly.IsRoot r := fun r hr => (mem_intRootSet_iff.mp (Finset.mem_filter.mp hr).1).2 have hS_ge2 : ∀ r ∈ S, 2 ≤ r.natAbs := fun r hr => (Finset.mem_filter.mp hr).2 have hS_ne0 : ∀ r ∈ S, r ≠ 0 := fun r hr => by have := hS_ge2 r hr; omega have hl1 : l1Norm P.evalPoly ≤ 2 ^ (2 ^ (n - 1)) := by have h := slp_evalWire_l1Norm_le_shifted P ⟨τ + 1, Nat.lt_succ_self _⟩ simpa [SLP.evalPoly, hall, ← hn_def] using h calc k ^ k ≤ k.factorial ^ 2 := pow_self_le_factorial_sq k _ ≤ ∏ r ∈ S, r.natAbs := factorial_sq_le_prod_natAbs m S hS_ge2 (by omega) _ ≤ l1Norm P.evalPoly := prod_natAbs_roots_le_l1Norm hP S hS_roots hS_ne0 _ ≤ 2 ^ (2 ^ (n - 1)) := hl1 by_cases hn3 : n ≤ 3 · by_cases hn1' : n = 1 · rw [hn1'] at hkk ⊢ have : k ≤ 1 := by by_contra h2; push Not at h2 have : 4 ≤ k ^ k := calc 4 = 2 ^ 2 := by norm_num _ ≤ k ^ 2 := Nat.pow_le_pow_left h2 2 _ ≤ k ^ k := Nat.pow_le_pow_right (by omega) h2 norm_num at hkk; omega omega · by_cases hn2' : n = 2 · rw [hn2'] at hkk ⊢ have : k ≤ 2 := by by_contra h3; push Not at h3 have : 27 ≤ k ^ k := calc 27 = 3 ^ 3 := by norm_num _ ≤ k ^ 3 := Nat.pow_le_pow_left h3 3 _ ≤ k ^ k := Nat.pow_le_pow_right (by omega) h3 norm_num at hkk; omega omega · have hn3' : n = 3 := by omega rw [hn3'] at hkk ⊢ have : k ≤ 2 := by by_contra h3; push Not at h3 have : 27 ≤ k ^ k := calc 27 = 3 ^ 3 := by norm_num _ ≤ k ^ 3 := Nat.pow_le_pow_left h3 3 _ ≤ k ^ k := Nat.pow_le_pow_right (by omega) h3 norm_num at hkk; omega omega · have hn4 : 4 ≤ n := by omega exact nat_l2_closure (n := n) (z := intRootCount P.evalPoly) (k := k) (by by_contra hgt; push Not at hgt have hk_ge : 2 ^ (n - 1) ≤ k := by have : 2 ^ n = 2 * 2 ^ (n - 1) := by conv_lhs => rw [← Nat.sub_add_cancel hn1, pow_succ, mul_comm] omega have hpow_ge : 2 ^ (n - 1) ≥ 8 := by have : 3 ≤ n - 1 := by omega calc 8 = 2 ^ 3 := by norm_num _ ≤ 2 ^ (n - 1) := Nat.pow_le_pow_right (by norm_num) this have : 2 ^ (2 ^ (n - 1)) < k ^ k := by calc 2 ^ (2 ^ (n - 1)) < 4 ^ (2 ^ (n - 1)) := Nat.pow_lt_pow_left (by norm_num) (by omega) _ ≤ (2 ^ (n - 1)) ^ (2 ^ (n - 1)) := Nat.pow_le_pow_left (by omega) _ _ ≤ k ^ (2 ^ (n - 1)) := Nat.pow_le_pow_left hk_ge _ _ ≤ k ^ k := Nat.pow_le_pow_right (by omega) hk_ge omega) hz_k (fun _ => hkk) end Research.PvsNP.Tau