Lean / 0xOsprey/shub-smale-tau9 / PureSquaringCollapse.lean
Lean readerResearch/PvsNP/Tau/PureSquaringCollapse.lean
modulepublic import Research.PvsNP.Tau.TauConjecture@[expose] public sectionnamespace Research.PvsNP.Tau/-!# Pure-Squaring Collapse, Integer Escape, and Rojas Preprint Audit WitnessesThis module formalizes three unconditional results developed during the Moonshot Ainvestigation (`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 inRojas (`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 multiplicityacross 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.topTwoDegslet d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegreeif 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 amultiplication `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 1theorem SLP.nonTopSqCount_le : ∀ {τ : ℕ} (P : SLP τ), P.nonTopSqCount ≤ τ| 0, .nil => Nat.le_refl 0| _ + 1, .snoc P op i j => byhave ih := P.nonTopSqCount_lesimp only [SLP.nonTopSqCount]split_ifs <;> omega/-- Basic invariant: `1 ≤ D₁`, `D₂ ≤ D₁`, every wire has degree `≤ D₁`, and any twodistinct 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 => byrefine ⟨by simp [SLP.maxDeg, SLP.topTwoDegs],by simp [SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs], ?_, ?_⟩· intro kfin_cases k <;> simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.topTwoDegs]· intro i j hijfin_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 => byobtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_invset d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegreehave hnew : (SLP.snoc P op i j).wireDeg ⟨τ + 2, Nat.lt_succ_self _⟩ = d := bysimp [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⟩ := byintro k hksimp [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) := byrflby_cases hle : P.maxDeg ≤ d· have hM : (SLP.snoc P op i j).maxDeg = d := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = dsimp [hle]have hS : (SLP.snoc P op i j).secondDeg = P.maxDeg := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 = P.maxDegsimp [hle]refine ⟨by omega, by omega, ?_, ?_⟩· intro kby_cases hk : k.val < τ + 2· rw [hold k hk, hM]; exact le_trans (hall ⟨k.val, hk⟩) hle· have hklt := k.isLthave hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)rw [hk', hnew, hM]· intro a b habrw [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.isLthave 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.isLthave 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.isLtexact absurd (Fin.ext (by omega)) hab· have hlt : d < P.maxDeg := by omegahave hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDegsimp [hle]have hS : (SLP.snoc P op i j).secondDeg = max P.secondDeg d := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 =max P.secondDeg dsimp [hle]refine ⟨by omega, by rw [hM, hS]; exact max_le h2 (le_of_lt hlt), ?_, ?_⟩· intro kby_cases hk : k.val < τ + 2· rw [hold k hk, hM]; exact hall ⟨k.val, hk⟩· have hklt := k.isLthave hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)rw [hk', hnew, hM]; exact le_of_lt hlt· intro a b habrw [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⟩ hnehave : P.secondDeg ≤ max P.secondDeg d := le_max_left _ _omega· have hblt := b.isLthave 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.isLthave 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.isLtexact 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 => byset d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegreeby_cases hle : P.maxDeg ≤ d· refine ⟨⟨τ + 2, Nat.lt_succ_self _⟩, ?_⟩have hM : (SLP.snoc P op i j).maxDeg = d := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = dsimp [hle]rw [hM]; simp [SLP.wireDeg, SLP.evalWire, d]· obtain ⟨k, hk⟩ := P.exists_wire_eq_maxDegrefine ⟨⟨k.val, Nat.lt_succ_of_lt k.isLt⟩, ?_⟩have hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := bychange (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDegsimp [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 := byby_cases h : 2 * D2 ≤ D1· rw [max_eq_right h]have hmul : 32 * (D1 + D2) ^ 5 ≤ 32 * (8 * D1 ^ 3 * D1 ^ 2) := byhave h3 : 2 * (D1 + D2) ≤ 3 * D1 := by omegahave hpow : (2 * (D1 + D2)) ^ 5 ≤ (3 * D1) ^ 5 := Nat.pow_le_pow_left h3 5have hlhs : (2 * (D1 + D2)) ^ 5 = 32 * (D1 + D2) ^ 5 := by ringhave hrhs : (3 * D1) ^ 5 = 243 * D1 ^ 5 := by ringhave 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 ringomegaomega· have hlt : D1 ≤ 2 * D2 := by omegarw [max_eq_left hlt]have hsub : 32 * D1 ^ 3 * D2 ^ 2 ≥ (D1 + D2) ^ 5 := byset a := 2 * D2 - D1set b := D1 - D2have hD1 : D1 = a + 2 * b := by omegahave hD2 : D2 = a + b := by omegarw [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 ringomegahave hrew : 8 * D1 ^ 3 * (2 * D2) ^ 2 = 32 * D1 ^ 3 * D2 ^ 2 := by ringomega/-- 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 => bysimp [SLP.collapsePotential, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs, SLP.nonTopSqCount]| τ + 1, .snoc P op i j => byhave ih := P.collapsePotential_lehave hcount := P.nonTopSqCount_leobtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_invset D1 := P.maxDegset D2 := P.secondDegset M := max (2 * D2) D1set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegreehave 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 := bysimp [SLP.nonTopSqCount, htopsq]have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount =(7 * τ - 2 * P.nonTopSqCount) + 7 := by rw [hcnt]; omegarw [hexp, pow_add]have hd_le : d ≤ 2 * D1 := byrcases htopsq with ⟨hop, hij, hdeg⟩subst hop; subst hijcalc (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]; omegahave hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 7 := byunfold SLP.collapsePotentialby_cases hle : D1 ≤ d· have hM' : (SLP.snoc P op i j).maxDeg = d := bychange (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 := bychange (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 5have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2calc 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 := bychange (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 := bychange (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 2calc 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 := bysimp [SLP.nonTopSqCount, htopsq]have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount =(7 * τ - 2 * P.nonTopSqCount) + 5 := by rw [hcnt]; omegarw [hexp, pow_add]have hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 5 := byunfold SLP.collapsePotentialby_cases hle : D1 ≤ d· have hM' : (SLP.snoc P op i j).maxDeg = d := bychange (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 := bychange (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 := bycalc (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 omegarw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)]have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2calc 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 := bycalc (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 omegarw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)]have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2calc 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 hijhave hlt_deg : P.wireDeg i < D1 := byhave hle_i := hall ihave hne_i : P.wireDeg i ≠ D1 := fun heq => htopsq ⟨rfl, rfl, heq⟩omegaobtain ⟨k0, hk0⟩ := P.exists_wire_eq_maxDeghave hne_ik : i ≠ k0 := fun heq => by rw [heq, hk0] at hlt_deg; omegahave hpair_ik := hpair i k0 hne_ikhave hi_le_D2 : P.wireDeg i ≤ D2 := by omegahave hd_le_2D2 : d ≤ 2 * D2 := bycalc (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]; omegahave hd_le_2D1 : d ≤ 2 * D1 := by omegarw [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 3calc 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 := bycalc (P.evalWire i * P.evalWire j).natDegree≤ (P.evalWire i).natDegree + (P.evalWire j).natDegree :=Polynomial.natDegree_mul_le_ ≤ D1 + D2 := hpair i j hijhave hd_le_2D1 : d ≤ 2 * D1 := by omegarw [max_eq_left hd_le_2D1]have hcore := potential_step_add_mul D1 D2 h2calc 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 := bychange (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 := bychange (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 2calc 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) := byobtain ⟨_, _, hall, _⟩ := P.topTwoDegs_invhave 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 : ℕ) wherevIdx : Fin (r + 2)A : ℕB : ℕsignSub : BoolhA : 1 ≤ AhBA : 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 thenC.evalWire x ⟨idx.val, h⟩elselet prev := C.evalWire x ⟨k + 1, Nat.lt_succ_self _⟩let v := C.evalWire x st.vIdxif 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| := byrcases 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)]ringprivate lemma int_abs_pow (a : ℤ) (n : ℕ) : |a ^ n| = |a| ^ n := byinduction 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 outputwire 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 => byrefine ⟨by simpa [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire] using hx, ?_⟩intro idxfin_cases idx· simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire]have h1 : |(1 : ℤ)| = 1 := by decideomega· simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire]| k + 1, .snoc C st, x, hx => byobtain ⟨hprev2, hall⟩ := C.abs_ge_two_of_abs_x_ge_two x hxset p := C.eval xset v := C.evalWire x st.vIdxhave hv_le : |v| ≤ |p| := hall st.vIdxhave hpow_strict : 2 ^ st.B + 1 ≤ 2 ^ st.A := byhave h1 : 2 ^ st.B * 2 ≤ 2 ^ st.A := byhave hle : st.B + 1 ≤ st.A := st.hBAcalc 2 ^ st.B * 2 = 2 ^ (st.B + 1) := by rw [pow_succ]_ ≤ 2 ^ st.A := Nat.pow_le_pow_right (by decide) hlehave hpos : 1 ≤ 2 ^ st.B := Nat.one_le_pow _ _ (by decide)omegahave 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) := bycalc |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_stricthave hpb_ge2 : (2 : ℤ) ≤ |p| ^ (2 ^ st.B) := byhave 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) hposhave hdiff_ge : |p| ≤ |p| ^ (2 ^ st.A) - |v| ^ (2 ^ st.B) := byhave hstep : |p| + |p| ^ (2 ^ st.B) ≤ |p| ^ (2 ^ st.B) * |p| := by nlinarithlinarithhave 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) := bysimp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire, p, v]have hout_ge_p : |p| ≤ |(CanonicalPowerCircuit.snoc C st).eval x| := byrw [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 htrilinarith· have htri : |p ^ (2 ^ st.A)| - |v ^ (2 ^ st.B)| ≤ |p ^ (2 ^ st.A) + v ^ (2 ^ st.B)| := byhave := abs_sub_abs_le_abs_sub (p ^ (2 ^ st.A)) (-(v ^ (2 ^ st.B)))simpa [sub_neg_eq_add, abs_neg] using thisrw [hp_abs, hv_abs] at htrilinarithrefine ⟨le_trans hprev2 hout_ge_p, ?_⟩intro idxby_cases hidx : idx.val < k + 2· have hew : (CanonicalPowerCircuit.snoc C st).evalWire x idx = C.evalWire x ⟨idx.val, hidx⟩ := bysimp [CanonicalPowerCircuit.evalWire, hidx]rw [hew]exact le_trans (hall ⟨idx.val, hidx⟩) hout_ge_p· have hlt := idx.isLthave 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 := byby_contra hnothave 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| := byrcases le_or_gt 0 x with hx | hx· rw [abs_of_nonneg hx]; omega· rw [abs_of_neg hx]; omegahave hge := (C.abs_ge_two_of_abs_x_ge_two x habs).1rw [hroot, abs_zero] at hgeomega/-! ## 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 : ℤ := 2let y : ℤ := 1(y - x + 1 = 0) ∧(x ^ 2 - 3 * y - 1 = 0) ∧((-1 : ℤ) * (-3) - (1) * (2 * x) ≠ 0) ∧(0 < (1 : ℕ) ∧ 0 < (2 : ℕ)) := bydecide/-- **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 : ℤ := 2let 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) := byrefine ⟨by decide, by decide, by decide, ?_⟩intro s1 s2 hs1 hs2omegaend Research.PvsNP.Tau