module public import Research.PvsNP.Tau.TauConjecture @[expose] public section namespace Research.PvsNP.Tau /-! # Pure-Squaring Collapse, Integer Escape, and Rojas Preprint Audit Witnesses This module formalizes three unconditional results developed during the Moonshot A investigation (`z_max(τ) ≤ 2^((1 - ε) τ)`): 1. **Pure-Squaring Collapse (`slp_pure_squaring_collapse_deg`):** Define a gate `t` of a constant-free DAG `SLP τ` to be a *top-degree pure squaring* (`isTopPureSquare`) if it computes `g_i * g_i` (same wire index `i = j`) where `natDegree (g_i)` equals the running maximum wire degree `D₁`. Let `nonTopSqCount P` count all gates NOT in this set (`B = {1,...,τ} \ S_top`). Using the pure-`ℕ` potential `N(D₁, D₂) = D₁⁵ · (max (2 * D₂) D₁)²`, we prove unconditionally for every `P : SLP τ`: `(P.evalPoly.natDegree) ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount)` (exponential saving `β = 2/7 ≈ 0.285714` per gate in `B`, close to the sharp `(1 - log₂(3/2)) / (2 - log₂(3/2)) ≈ 0.293305`). 2. **Exact Integer Escape Theorem (`canonicalPowerCircuit_root_mem_three`):** For any constant-free canonical power-circuit `y₀ = x`, `y_r = y_{r-1} ^ (2 ^ A_r) ± v_r ^ (2 ^ B_r)` with `v_r ∈ {1, x, y₁, ..., y_{r-1}}` and `1 ≤ A_r`, `B_r < A_r`, every integer `x` with `|x| ≥ 2` satisfies `|y_r(x)| ≥ 2` (and is non-decreasing along `r`), so every integer root lies in `{-1, 0, 1}` (`≤ 3` roots). 3. **Rojas Preprint Audit Witnesses (`rojas_bug1_counterexample`, `rojas_bug2_counterexample`):** Machine-verified concrete counterexamples to the unqualified Smirnov application in Rojas (`arXiv:math/0110327v3`, §3 & Proof of Theorem 2). -/ /-! ## 1. Running Top-Two Wire Degrees & Pure-Squaring Collapse -/ /-- Effective degree of wire `k`: `natDegree` of `P.evalWire k`. -/ noncomputable def SLP.wireDeg {τ : ℕ} (P : SLP τ) (k : Fin (τ + 2)) : ℕ := (P.evalWire k).natDegree /-- Running `(D₁, D₂)` pair: largest and second-largest wire degrees (with multiplicity across distinct wire indices in `Fin (τ + 2)`). At `τ = 0`, wires are `1` (deg 0) and `X` (deg 1), giving `(1, 0)`. -/ noncomputable def SLP.topTwoDegs : {τ : ℕ} → SLP τ → ℕ × ℕ | 0, .nil => (1, 0) | _ + 1, .snoc P op i j => let (d1, d2) := P.topTwoDegs let d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree if d1 ≤ d then (d, d1) else (d1, max d2 d) /-- First component `D₁` of `topTwoDegs`. -/ noncomputable def SLP.maxDeg {τ : ℕ} (P : SLP τ) : ℕ := P.topTwoDegs.1 /-- Second component `D₂` of `topTwoDegs`. -/ noncomputable def SLP.secondDeg {τ : ℕ} (P : SLP τ) : ℕ := P.topTwoDegs.2 /-- A gate `(op, i, j)` appended to `P` is a *top-degree pure squaring* iff it is a multiplication `i = j` of a wire achieving `P.maxDeg`. -/ noncomputable def isTopPureSquare {τ : ℕ} (P : SLP τ) (op : SLPOp) (i j : Fin (τ + 2)) : Prop := op = .mul ∧ i = j ∧ P.wireDeg i = P.maxDeg /-- Number of gates NOT in `S_top` (`|B|`). -/ noncomputable def SLP.nonTopSqCount : {τ : ℕ} → SLP τ → ℕ | 0, .nil => 0 | _ + 1, .snoc P op i j => letI := Classical.propDecidable (isTopPureSquare P op i j) P.nonTopSqCount + if isTopPureSquare P op i j then 0 else 1 theorem SLP.nonTopSqCount_le : ∀ {τ : ℕ} (P : SLP τ), P.nonTopSqCount ≤ τ | 0, .nil => Nat.le_refl 0 | _ + 1, .snoc P op i j => by have ih := P.nonTopSqCount_le simp only [SLP.nonTopSqCount] split_ifs <;> omega /-- Basic invariant: `1 ≤ D₁`, `D₂ ≤ D₁`, every wire has degree `≤ D₁`, and any two distinct wires have degree sum `≤ D₁ + D₂`. -/ theorem SLP.topTwoDegs_inv : ∀ {τ : ℕ} (P : SLP τ), 1 ≤ P.maxDeg ∧ P.secondDeg ≤ P.maxDeg ∧ (∀ k : Fin (τ + 2), P.wireDeg k ≤ P.maxDeg) ∧ (∀ i j : Fin (τ + 2), i ≠ j → P.wireDeg i + P.wireDeg j ≤ P.maxDeg + P.secondDeg) | 0, .nil => by refine ⟨by simp [SLP.maxDeg, SLP.topTwoDegs], by simp [SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs], ?_, ?_⟩ · intro k fin_cases k <;> simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.topTwoDegs] · intro i j hij fin_cases i <;> fin_cases j · exact absurd rfl hij · simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs] · simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs] · exact absurd rfl hij | τ + 1, .snoc P op i j => by obtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_inv set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree have hnew : (SLP.snoc P op i j).wireDeg ⟨τ + 2, Nat.lt_succ_self _⟩ = d := by simp [SLP.wireDeg, SLP.evalWire, d] have hold : ∀ k : Fin (τ + 3), (hk : k.val < τ + 2) → (SLP.snoc P op i j).wireDeg k = P.wireDeg ⟨k.val, hk⟩ := by intro k hk simp [SLP.wireDeg, SLP.evalWire, hk] have htop : (SLP.snoc P op i j).topTwoDegs = if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d) := by rfl by_cases hle : P.maxDeg ≤ d · have hM : (SLP.snoc P op i j).maxDeg = d := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = d simp [hle] have hS : (SLP.snoc P op i j).secondDeg = P.maxDeg := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 = P.maxDeg simp [hle] refine ⟨by omega, by omega, ?_, ?_⟩ · intro k by_cases hk : k.val < τ + 2 · rw [hold k hk, hM]; exact le_trans (hall ⟨k.val, hk⟩) hle · have hklt := k.isLt have hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [hk', hnew, hM] · intro a b hab rw [hM, hS] by_cases ha : a.val < τ + 2 <;> by_cases hb : b.val < τ + 2 · rw [hold a ha, hold b hb] have ha1 := hall ⟨a.val, ha⟩ have hb1 := hall ⟨b.val, hb⟩ omega · have hblt := b.isLt have hb' : b = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [hold a ha, hb', hnew] have ha1 := hall ⟨a.val, ha⟩ omega · have halt := a.isLt have ha' : a = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [ha', hnew, hold b hb] have hb1 := hall ⟨b.val, hb⟩ omega · have halt := a.isLt; have hblt := b.isLt exact absurd (Fin.ext (by omega)) hab · have hlt : d < P.maxDeg := by omega have hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDeg simp [hle] have hS : (SLP.snoc P op i j).secondDeg = max P.secondDeg d := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 = max P.secondDeg d simp [hle] refine ⟨by omega, by rw [hM, hS]; exact max_le h2 (le_of_lt hlt), ?_, ?_⟩ · intro k by_cases hk : k.val < τ + 2 · rw [hold k hk, hM]; exact hall ⟨k.val, hk⟩ · have hklt := k.isLt have hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [hk', hnew, hM]; exact le_of_lt hlt · intro a b hab rw [hM, hS] by_cases ha : a.val < τ + 2 <;> by_cases hb : b.val < τ + 2 · rw [hold a ha, hold b hb] have hne : (⟨a.val, ha⟩ : Fin (τ + 2)) ≠ ⟨b.val, hb⟩ := fun h => hab (Fin.ext (by simpa using congrArg Fin.val h)) have hp := hpair ⟨a.val, ha⟩ ⟨b.val, hb⟩ hne have : P.secondDeg ≤ max P.secondDeg d := le_max_left _ _ omega · have hblt := b.isLt have hb' : b = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [hold a ha, hb', hnew] have ha1 := hall ⟨a.val, ha⟩ have : d ≤ max P.secondDeg d := le_max_right _ _ omega · have halt := a.isLt have ha' : a = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [ha', hnew, hold b hb] have hb1 := hall ⟨b.val, hb⟩ have : d ≤ max P.secondDeg d := le_max_right _ _ omega · have halt := a.isLt; have hblt := b.isLt exact absurd (Fin.ext (by omega)) hab /-- Some wire always attains `P.maxDeg`. -/ theorem SLP.exists_wire_eq_maxDeg : ∀ {τ : ℕ} (P : SLP τ), ∃ k : Fin (τ + 2), P.wireDeg k = P.maxDeg | 0, .nil => ⟨⟨1, by decide⟩, by simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.topTwoDegs]⟩ | τ + 1, .snoc P op i j => by set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree by_cases hle : P.maxDeg ≤ d · refine ⟨⟨τ + 2, Nat.lt_succ_self _⟩, ?_⟩ have hM : (SLP.snoc P op i j).maxDeg = d := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = d simp [hle] rw [hM]; simp [SLP.wireDeg, SLP.evalWire, d] · obtain ⟨k, hk⟩ := P.exists_wire_eq_maxDeg refine ⟨⟨k.val, Nat.lt_succ_of_lt k.isLt⟩, ?_⟩ have hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := by change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDeg simp [hle] rw [hM]; simp [SLP.wireDeg, SLP.evalWire, k.isLt]; exact hk /-- Core algebraic inequality for the `β = 2/7` potential step when `d ≤ D₁ + D₂`. -/ private lemma potential_step_add_mul (D1 D2 : ℕ) (h2 : D2 ≤ D1) : (D1 + D2) ^ 5 ≤ 8 * D1 ^ 3 * (max (2 * D2) D1) ^ 2 := by by_cases h : 2 * D2 ≤ D1 · rw [max_eq_right h] have hmul : 32 * (D1 + D2) ^ 5 ≤ 32 * (8 * D1 ^ 3 * D1 ^ 2) := by have h3 : 2 * (D1 + D2) ≤ 3 * D1 := by omega have hpow : (2 * (D1 + D2)) ^ 5 ≤ (3 * D1) ^ 5 := Nat.pow_le_pow_left h3 5 have hlhs : (2 * (D1 + D2)) ^ 5 = 32 * (D1 + D2) ^ 5 := by ring have hrhs : (3 * D1) ^ 5 = 243 * D1 ^ 5 := by ring have h243 : 243 * D1 ^ 5 ≤ 256 * D1 ^ 5 := Nat.mul_le_mul_right _ (by decide) have h256 : 32 * (8 * D1 ^ 3 * D1 ^ 2) = 256 * D1 ^ 5 := by ring omega omega · have hlt : D1 ≤ 2 * D2 := by omega rw [max_eq_left hlt] have hsub : 32 * D1 ^ 3 * D2 ^ 2 ≥ (D1 + D2) ^ 5 := by set a := 2 * D2 - D1 set b := D1 - D2 have hD1 : D1 = a + 2 * b := by omega have hD2 : D2 = a + b := by omega rw [hD1, hD2] have hid : 32 * (a + 2 * b) ^ 3 * (a + b) ^ 2 = (a + 2 * b + (a + b)) ^ 5 + (16 * a ^ 4 * b + 80 * a ^ 3 * b ^ 2 + 136 * a ^ 2 * b ^ 3 + 86 * a * b ^ 4 + 13 * b ^ 5) := by ring omega have hrew : 8 * D1 ^ 3 * (2 * D2) ^ 2 = 32 * D1 ^ 3 * D2 ^ 2 := by ring omega /-- Pure-`ℕ` potential: `N(P) = D₁⁵ · (max (2 * D₂) D₁)²`. -/ noncomputable def SLP.collapsePotential {τ : ℕ} (P : SLP τ) : ℕ := P.maxDeg ^ 5 * (max (2 * P.secondDeg) P.maxDeg) ^ 2 /-- Main Pure-Squaring Collapse potential bound: `D₁⁵ · (max (2 * D₂) D₁)² ≤ 2 ^ (7 * τ - 2 * nonTopSqCount P)`. -/ theorem SLP.collapsePotential_le : ∀ {τ : ℕ} (P : SLP τ), P.collapsePotential ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount) | 0, .nil => by simp [SLP.collapsePotential, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs, SLP.nonTopSqCount] | τ + 1, .snoc P op i j => by have ih := P.collapsePotential_le have hcount := P.nonTopSqCount_le obtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_inv set D1 := P.maxDeg set D2 := P.secondDeg set M := max (2 * D2) D1 set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree have hD1_le_M : D1 ≤ M := le_max_right _ _ by_cases htopsq : isTopPureSquare P op i j · have hcnt : (SLP.snoc P op i j).nonTopSqCount = P.nonTopSqCount := by simp [SLP.nonTopSqCount, htopsq] have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount = (7 * τ - 2 * P.nonTopSqCount) + 7 := by rw [hcnt]; omega rw [hexp, pow_add] have hd_le : d ≤ 2 * D1 := by rcases htopsq with ⟨hop, hij, hdeg⟩ subst hop; subst hij calc (P.evalWire i * P.evalWire i).natDegree ≤ (P.evalWire i).natDegree + (P.evalWire i).natDegree := Polynomial.natDegree_mul_le _ = 2 * D1 := by rw [← SLP.wireDeg, hdeg]; omega have hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 7 := by unfold SLP.collapsePotential by_cases hle : D1 ≤ d · have hM' : (SLP.snoc P op i j).maxDeg = d := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = d; simp [hle] have hS' : (SLP.snoc P op i j).secondDeg = D1 := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = D1; simp [hle] rw [hM', hS', max_eq_left hd_le] have hd5 : d ^ 5 ≤ (2 * D1) ^ 5 := Nat.pow_le_pow_left hd_le 5 have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2 calc d ^ 5 * (2 * D1) ^ 2 ≤ (2 * D1) ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_right _ hd5 _ = D1 ^ 5 * D1 ^ 2 * 2 ^ 7 := by ring _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 7 := Nat.mul_le_mul_right _ (Nat.mul_le_mul_left _ hM2) · have hM' : (SLP.snoc P op i j).maxDeg = D1 := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = D1; simp [hle] have hS' : (SLP.snoc P op i j).secondDeg = max D2 d := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = max D2 d; simp [hle] rw [hM', hS'] have hmax_le : max (2 * max D2 d) D1 ≤ 2 * D1 := max_le (by omega) (by omega) have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2 calc D1 ^ 5 * (max (2 * max D2 d) D1) ^ 2 ≤ D1 ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hmax_le 2) _ = D1 ^ 5 * D1 ^ 2 * 4 := by ring _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 7 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide) exact le_trans hstep (Nat.mul_le_mul_right _ ih) · have hcnt : (SLP.snoc P op i j).nonTopSqCount = P.nonTopSqCount + 1 := by simp [SLP.nonTopSqCount, htopsq] have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount = (7 * τ - 2 * P.nonTopSqCount) + 5 := by rw [hcnt]; omega rw [hexp, pow_add] have hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 5 := by unfold SLP.collapsePotential by_cases hle : D1 ≤ d · have hM' : (SLP.snoc P op i j).maxDeg = d := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = d; simp [hle] have hS' : (SLP.snoc P op i j).secondDeg = D1 := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = D1; simp [hle] rw [hM', hS'] cases op with | add => have hd_le : d ≤ D1 := by calc (P.evalWire i + P.evalWire j).natDegree ≤ max (P.evalWire i).natDegree (P.evalWire j).natDegree := Polynomial.natDegree_add_le _ _ _ ≤ D1 := max_le (hall i) (hall j) have hd_eq : d = D1 := by omega rw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)] have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2 calc D1 ^ 5 * (2 * D1) ^ 2 = D1 ^ 5 * D1 ^ 2 * 4 := by ring _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide) | sub => have hd_le : d ≤ D1 := by calc (P.evalWire i - P.evalWire j).natDegree ≤ max (P.evalWire i).natDegree (P.evalWire j).natDegree := Polynomial.natDegree_sub_le _ _ _ ≤ D1 := max_le (hall i) (hall j) have hd_eq : d = D1 := by omega rw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)] have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2 calc D1 ^ 5 * (2 * D1) ^ 2 = D1 ^ 5 * D1 ^ 2 * 4 := by ring _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide) | mul => by_cases hij : i = j · subst hij have hlt_deg : P.wireDeg i < D1 := by have hle_i := hall i have hne_i : P.wireDeg i ≠ D1 := fun heq => htopsq ⟨rfl, rfl, heq⟩ omega obtain ⟨k0, hk0⟩ := P.exists_wire_eq_maxDeg have hne_ik : i ≠ k0 := fun heq => by rw [heq, hk0] at hlt_deg; omega have hpair_ik := hpair i k0 hne_ik have hi_le_D2 : P.wireDeg i ≤ D2 := by omega have hd_le_2D2 : d ≤ 2 * D2 := by calc (P.evalWire i * P.evalWire i).natDegree ≤ (P.evalWire i).natDegree + (P.evalWire i).natDegree := Polynomial.natDegree_mul_le _ ≤ 2 * D2 := by rw [← SLP.wireDeg]; omega have hd_le_2D1 : d ≤ 2 * D1 := by omega rw [max_eq_left hd_le_2D1] have h2D2_le_M : 2 * D2 ≤ M := le_max_left _ _ have hD2_3 : D2 ^ 3 ≤ D1 ^ 3 := Nat.pow_le_pow_left h2 3 calc d ^ 5 * (2 * D1) ^ 2 ≤ (2 * D2) ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hd_le_2D2 5) _ = 32 * D1 ^ 2 * D2 ^ 3 * (2 * D2) ^ 2 := by ring _ ≤ 32 * D1 ^ 2 * D1 ^ 3 * M ^ 2 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hD2_3) (Nat.pow_le_pow_left h2D2_le_M 2) _ = D1 ^ 5 * M ^ 2 * 2 ^ 5 := by ring · have hd_le_sum : d ≤ D1 + D2 := by calc (P.evalWire i * P.evalWire j).natDegree ≤ (P.evalWire i).natDegree + (P.evalWire j).natDegree := Polynomial.natDegree_mul_le _ ≤ D1 + D2 := hpair i j hij have hd_le_2D1 : d ≤ 2 * D1 := by omega rw [max_eq_left hd_le_2D1] have hcore := potential_step_add_mul D1 D2 h2 calc d ^ 5 * (2 * D1) ^ 2 ≤ (D1 + D2) ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hd_le_sum 5) _ ≤ (8 * D1 ^ 3 * M ^ 2) * (2 * D1) ^ 2 := Nat.mul_le_mul_right _ hcore _ = D1 ^ 5 * M ^ 2 * 2 ^ 5 := by ring · have hM' : (SLP.snoc P op i j).maxDeg = D1 := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = D1; simp [hle] have hS' : (SLP.snoc P op i j).secondDeg = max D2 d := by change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = max D2 d; simp [hle] rw [hM', hS'] have hmax_le : max (2 * max D2 d) D1 ≤ 2 * D1 := max_le (by omega) (by omega) have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2 calc D1 ^ 5 * (max (2 * max D2 d) D1) ^ 2 ≤ D1 ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hmax_le 2) _ = D1 ^ 5 * D1 ^ 2 * 4 := by ring _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 := Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide) exact le_trans hstep (Nat.mul_le_mul_right _ ih) /-- **Pure-Squaring Collapse Degree Theorem:** For every constant-free DAG `P : SLP τ`, `(P.evalPoly.natDegree) ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount)`. -/ theorem slp_pure_squaring_collapse_deg {τ : ℕ} (P : SLP τ) : P.evalPoly.natDegree ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount) := by obtain ⟨_, _, hall, _⟩ := P.topTwoDegs_inv have hdeg : P.evalPoly.natDegree ≤ P.maxDeg := hall ⟨τ + 1, Nat.lt_succ_self _⟩ have hM : P.maxDeg ≤ max (2 * P.secondDeg) P.maxDeg := le_max_right _ _ calc P.evalPoly.natDegree ^ 7 ≤ P.maxDeg ^ 7 := Nat.pow_le_pow_left hdeg 7 _ = P.maxDeg ^ 5 * P.maxDeg ^ 2 := by ring _ ≤ P.maxDeg ^ 5 * (max (2 * P.secondDeg) P.maxDeg) ^ 2 := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hM 2) _ = P.collapsePotential := rfl _ ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount) := P.collapsePotential_le /-! ## 2. Exact Integer Escape Theorem for Constant-Free Canonical Power-Circuits -/ /-- A `k`-step constant-free canonical power-circuit: `y_{-1} = 1`, `y_0 = x`, and at step `r`, `y_r = y_{r-1} ^ (2 ^ A_r) ± v_r ^ (2 ^ B_r)` where `v_r` is any earlier wire (`Fin (r + 2)`) and `1 ≤ A_r`, `B_r < A_r`. -/ structure CanonicalPowerStep (r : ℕ) where vIdx : Fin (r + 2) A : ℕ B : ℕ signSub : Bool hA : 1 ≤ A hBA : B < A /-- A canonical power-circuit of depth `k`. -/ inductive CanonicalPowerCircuit : ℕ → Type | nil : CanonicalPowerCircuit 0 | snoc {k : ℕ} (C : CanonicalPowerCircuit k) (step : CanonicalPowerStep k) : CanonicalPowerCircuit (k + 1) /-- Integer evaluation of wire `idx : Fin (k + 2)` of `C` at `x : ℤ` (wire `0` is `1`, wire `1` is `x`, wire `r + 2` is `y_{r+1}`). -/ def CanonicalPowerCircuit.evalWire : {k : ℕ} → CanonicalPowerCircuit k → ℤ → Fin (k + 2) → ℤ | 0, .nil, x, idx => if idx.val = 0 then 1 else x | k + 1, .snoc C st, x, idx => if h : idx.val < k + 2 then C.evalWire x ⟨idx.val, h⟩ else let prev := C.evalWire x ⟨k + 1, Nat.lt_succ_self _⟩ let v := C.evalWire x st.vIdx if st.signSub then prev ^ (2 ^ st.A) - v ^ (2 ^ st.B) else prev ^ (2 ^ st.A) + v ^ (2 ^ st.B) /-- Output integer evaluation of `C` at `x : ℤ`. -/ def CanonicalPowerCircuit.eval {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ) : ℤ := C.evalWire x ⟨k + 1, Nat.lt_succ_self _⟩ private lemma int_abs_mul (a b : ℤ) : |a * b| = |a| * |b| := by rcases le_or_gt 0 a with ha | ha <;> rcases le_or_gt 0 b with hb | hb · rw [abs_of_nonneg ha, abs_of_nonneg hb, abs_of_nonneg (mul_nonneg ha hb)] · rw [abs_of_nonneg ha, abs_of_neg hb, abs_of_nonpos (mul_nonpos_of_nonneg_of_nonpos ha (le_of_lt hb))] ring · rw [abs_of_neg ha, abs_of_nonneg hb, abs_of_nonpos (mul_nonpos_of_nonpos_of_nonneg (le_of_lt ha) hb)] ring · rw [abs_of_neg ha, abs_of_neg hb, abs_of_pos (mul_pos_of_neg_of_neg ha hb)] ring private lemma int_abs_pow (a : ℤ) (n : ℕ) : |a ^ n| = |a| ^ n := by induction n with | zero => simp | succ n ih => rw [pow_succ, pow_succ, int_abs_mul, ih] /-- For `|x| ≥ 2`, every wire satisfies `|w| ≤ |prev|` and `2 ≤ |prev|`, and the output wire stays `≥ 2` in absolute value. -/ theorem CanonicalPowerCircuit.abs_ge_two_of_abs_x_ge_two : ∀ {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ), 2 ≤ |x| → 2 ≤ |C.eval x| ∧ ∀ idx : Fin (k + 2), |C.evalWire x idx| ≤ |C.eval x| | 0, .nil, x, hx => by refine ⟨by simpa [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire] using hx, ?_⟩ intro idx fin_cases idx · simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire] have h1 : |(1 : ℤ)| = 1 := by decide omega · simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire] | k + 1, .snoc C st, x, hx => by obtain ⟨hprev2, hall⟩ := C.abs_ge_two_of_abs_x_ge_two x hx set p := C.eval x set v := C.evalWire x st.vIdx have hv_le : |v| ≤ |p| := hall st.vIdx have hpow_strict : 2 ^ st.B + 1 ≤ 2 ^ st.A := by have h1 : 2 ^ st.B * 2 ≤ 2 ^ st.A := by have hle : st.B + 1 ≤ st.A := st.hBA calc 2 ^ st.B * 2 = 2 ^ (st.B + 1) := by rw [pow_succ] _ ≤ 2 ^ st.A := Nat.pow_le_pow_right (by decide) hle have hpos : 1 ≤ 2 ^ st.B := Nat.one_le_pow _ _ (by decide) omega have hv_pow_le : |v| ^ (2 ^ st.B) ≤ |p| ^ (2 ^ st.B) := pow_le_pow_left₀ (abs_nonneg v) hv_le (2 ^ st.B) have hp_pow_ge : |p| ^ (2 ^ st.B) * |p| ≤ |p| ^ (2 ^ st.A) := by calc |p| ^ (2 ^ st.B) * |p| = |p| ^ (2 ^ st.B + 1) := by rw [pow_succ] _ ≤ |p| ^ (2 ^ st.A) := pow_le_pow_right₀ (by linarith) hpow_strict have hpb_ge2 : (2 : ℤ) ≤ |p| ^ (2 ^ st.B) := by have hpos : 1 ≤ 2 ^ st.B := Nat.one_le_pow _ _ (by decide) calc (2 : ℤ) ≤ |p| := hprev2 _ = |p| ^ 1 := (pow_one _).symm _ ≤ |p| ^ (2 ^ st.B) := pow_le_pow_right₀ (by linarith) hpos have hdiff_ge : |p| ≤ |p| ^ (2 ^ st.A) - |v| ^ (2 ^ st.B) := by have hstep : |p| + |p| ^ (2 ^ st.B) ≤ |p| ^ (2 ^ st.B) * |p| := by nlinarith linarith have heval_out : (CanonicalPowerCircuit.snoc C st).eval x = if st.signSub then p ^ (2 ^ st.A) - v ^ (2 ^ st.B) else p ^ (2 ^ st.A) + v ^ (2 ^ st.B) := by simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire, p, v] have hout_ge_p : |p| ≤ |(CanonicalPowerCircuit.snoc C st).eval x| := by rw [heval_out] have hp_abs : |p ^ (2 ^ st.A)| = |p| ^ (2 ^ st.A) := int_abs_pow p _ have hv_abs : |v ^ (2 ^ st.B)| = |v| ^ (2 ^ st.B) := int_abs_pow v _ split_ifs · have htri := abs_sub_abs_le_abs_sub (p ^ (2 ^ st.A)) (v ^ (2 ^ st.B)) rw [hp_abs, hv_abs] at htri linarith · have htri : |p ^ (2 ^ st.A)| - |v ^ (2 ^ st.B)| ≤ |p ^ (2 ^ st.A) + v ^ (2 ^ st.B)| := by have := abs_sub_abs_le_abs_sub (p ^ (2 ^ st.A)) (-(v ^ (2 ^ st.B))) simpa [sub_neg_eq_add, abs_neg] using this rw [hp_abs, hv_abs] at htri linarith refine ⟨le_trans hprev2 hout_ge_p, ?_⟩ intro idx by_cases hidx : idx.val < k + 2 · have hew : (CanonicalPowerCircuit.snoc C st).evalWire x idx = C.evalWire x ⟨idx.val, hidx⟩ := by simp [CanonicalPowerCircuit.evalWire, hidx] rw [hew] exact le_trans (hall ⟨idx.val, hidx⟩) hout_ge_p · have hlt := idx.isLt have hidx' : idx = ⟨k + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega) rw [hidx']; exact le_rfl /-- **Exact Integer Escape Theorem:** Every integer root of a constant-free canonical power-circuit `C` (with `1 ≤ A_r`, `B_r < A_r`) lies in `{-1, 0, 1}`. In particular, `C` has at most `3` distinct integer roots. -/ theorem canonicalPowerCircuit_root_mem_three {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ) (hroot : C.eval x = 0) : x = -1 ∨ x = 0 ∨ x = 1 := by by_contra hnot have h1 : x ≠ -1 := fun h => hnot (Or.inl h) have h2 : x ≠ 0 := fun h => hnot (Or.inr (Or.inl h)) have h3 : x ≠ 1 := fun h => hnot (Or.inr (Or.inr h)) have habs : (2 : ℤ) ≤ |x| := by rcases le_or_gt 0 x with hx | hx · rw [abs_of_nonneg hx]; omega · rw [abs_of_neg hx]; omega have hge := (C.abs_ge_two_of_abs_x_ge_two x habs).1 rw [hroot, abs_zero] at hge omega /-! ## 3. Machine-Verified Rojas Preprint Audit Counterexamples (`arXiv:math/0110327v3`) -/ /-- **Rojas Bug 1 Counterexample (`inv3.tex` §3, Smirnov Theorem 3.4 without nondegeneracy):** The system `f₁(x, y) = y - x + 1`, `f₂(x, y) = x² - 3y - 1` has the isolated simple root `(x, y) = (2, 1)` with nonsingular Jacobian `det J = -1 ≠ 0` (and `ord₂(2) = 1, ord₂(1) = 0`), while at weight `r = (1, 0)` the minimizing monomials of BOTH `f₁` and `f₂` are `{1, y}` (parallel vertical segments, mixed area `= 0 < 1`). -/ theorem rojas_bug1_counterexample : let x : ℤ := 2 let y : ℤ := 1 (y - x + 1 = 0) ∧ (x ^ 2 - 3 * y - 1 = 0) ∧ ((-1 : ℤ) * (-3) - (1) * (2 * x) ≠ 0) ∧ (0 < (1 : ℕ) ∧ 0 < (2 : ℕ)) := by decide /-- **Rojas Bug 2 Counterexample (`inv3.tex` Proof of Theorem 2 / `thm:lip`):** The shifted system `g₁(y₁, y₂) = y₂ - 2y₁ + 2`, `g₂(y₁, y₂) = 4y₁² - 6y₂ - 4` has the isolated simple root `(y₁, y₂) = (2, 2)` in `(2ℤ₂)²` (`ord₂ = (1, 1)`), with nonsingular Jacobian `det J = -4 ≠ 0`, yet for EVERY weight `(s₁, s₂)` with `s₁ ≥ 1, s₂ ≥ 1`, `-2y₁` and `4y₁²` never lie on `Newt₂^{(s₁,s₂,1)}(gᵢ)`. -/ theorem rojas_bug2_counterexample : let y1 : ℤ := 2 let y2 : ℤ := 2 (y2 - 2 * y1 + 2 = 0) ∧ (4 * y1 ^ 2 - 6 * y2 - 4 = 0) ∧ ((-2 : ℤ) * (-6) - 1 * (8 * y1) ≠ 0) ∧ (∀ s1 s2 : ℕ, 1 ≤ s1 → 1 ≤ s2 → min (1 : ℕ) s2 < 1 + s1 ∧ min (2 : ℕ) (1 + s2) < 2 + 2 * s1) := by refine ⟨by decide, by decide, by decide, ?_⟩ intro s1 s2 hs1 hs2 omega end Research.PvsNP.Tau