Lean / 0xOsprey/shub-smale-tau9 / PureSquaringCollapse.lean
Lean reader

Research/PvsNP/Tau/PureSquaringCollapse.lean

573 lines23 declarationsno sorry
  1. module
  2. public import Research.PvsNP.Tau.TauConjecture
  3. @[expose] public section
  4. namespace Research.PvsNP.Tau
  5. /-!
  6. # Pure-Squaring Collapse, Integer Escape, and Rojas Preprint Audit Witnesses
  7. This module formalizes three unconditional results developed during the Moonshot A
  8. investigation (`z_max(τ) ≤ 2^((1 - ε) τ)`):
  9. 1. **Pure-Squaring Collapse (`slp_pure_squaring_collapse_deg`):**
  10. Define a gate `t` of a constant-free DAG `SLP τ` to be a *top-degree pure squaring*
  11. (`isTopPureSquare`) if it computes `g_i * g_i` (same wire index `i = j`) where
  12. `natDegree (g_i)` equals the running maximum wire degree `D₁`. Let `nonTopSqCount P`
  13. count all gates NOT in this set (`B = {1,...,τ} \ S_top`). Using the pure-`ℕ` potential
  14. `N(D₁, D₂) = D₁⁵ · (max (2 * D₂) D₁)²`, we prove unconditionally for every `P : SLP τ`:
  15. `(P.evalPoly.natDegree) ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount)`
  16. (exponential saving `β = 2/7 ≈ 0.285714` per gate in `B`, close to the sharp
  17. `(1 - log₂(3/2)) / (2 - log₂(3/2)) ≈ 0.293305`).
  18. 2. **Exact Integer Escape Theorem (`canonicalPowerCircuit_root_mem_three`):**
  19. For any constant-free canonical power-circuit `y₀ = x`,
  20. `y_r = y_{r-1} ^ (2 ^ A_r) ± v_r ^ (2 ^ B_r)` with `v_r ∈ {1, x, y₁, ..., y_{r-1}}`
  21. and `1 ≤ A_r`, `B_r < A_r`, every integer `x` with `|x| ≥ 2` satisfies `|y_r(x)| ≥ 2`
  22. (and is non-decreasing along `r`), so every integer root lies in `{-1, 0, 1}` (`≤ 3` roots).
  23. 3. **Rojas Preprint Audit Witnesses (`rojas_bug1_counterexample`, `rojas_bug2_counterexample`):**
  24. Machine-verified concrete counterexamples to the unqualified Smirnov application in
  25. Rojas (`arXiv:math/0110327v3`, §3 & Proof of Theorem 2).
  26. -/
  27. /-! ## 1. Running Top-Two Wire Degrees & Pure-Squaring Collapse -/
  28. /-- Effective degree of wire `k`: `natDegree` of `P.evalWire k`. -/
  29. noncomputable def SLP.wireDeg {τ : ℕ} (P : SLP τ) (k : Fin (τ + 2)) : ℕ :=
  30. (P.evalWire k).natDegree
  31. /-- Running `(D₁, D₂)` pair: largest and second-largest wire degrees (with multiplicity
  32. across distinct wire indices in `Fin (τ + 2)`). At `τ = 0`, wires are `1` (deg 0) and
  33. `X` (deg 1), giving `(1, 0)`. -/
  34. noncomputable def SLP.topTwoDegs : {τ : ℕ} → SLP τ → ℕ × ℕ
  35. | 0, .nil => (1, 0)
  36. | _ + 1, .snoc P op i j =>
  37. let (d1, d2) := P.topTwoDegs
  38. let d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree
  39. if d1 ≤ d then (d, d1) else (d1, max d2 d)
  40. /-- First component `D₁` of `topTwoDegs`. -/
  41. noncomputable def SLP.maxDeg {τ : ℕ} (P : SLP τ) : ℕ := P.topTwoDegs.1
  42. /-- Second component `D₂` of `topTwoDegs`. -/
  43. noncomputable def SLP.secondDeg {τ : ℕ} (P : SLP τ) : ℕ := P.topTwoDegs.2
  44. /-- A gate `(op, i, j)` appended to `P` is a *top-degree pure squaring* iff it is a
  45. multiplication `i = j` of a wire achieving `P.maxDeg`. -/
  46. noncomputable def isTopPureSquare {τ : ℕ} (P : SLP τ) (op : SLPOp) (i j : Fin (τ + 2)) : Prop :=
  47. op = .mul ∧ i = j ∧ P.wireDeg i = P.maxDeg
  48. /-- Number of gates NOT in `S_top` (`|B|`). -/
  49. noncomputable def SLP.nonTopSqCount : {τ : ℕ} → SLP τ → ℕ
  50. | 0, .nil => 0
  51. | _ + 1, .snoc P op i j =>
  52. letI := Classical.propDecidable (isTopPureSquare P op i j)
  53. P.nonTopSqCount + if isTopPureSquare P op i j then 0 else 1
  54. theorem SLP.nonTopSqCount_le : ∀ {τ : ℕ} (P : SLP τ), P.nonTopSqCount ≤ τ
  55. | 0, .nil => Nat.le_refl 0
  56. | _ + 1, .snoc P op i j => by
  57. have ih := P.nonTopSqCount_le
  58. simp only [SLP.nonTopSqCount]
  59. split_ifs <;> omega
  60. /-- Basic invariant: `1 ≤ D₁`, `D₂ ≤ D₁`, every wire has degree `≤ D₁`, and any two
  61. distinct wires have degree sum `≤ D₁ + D₂`. -/
  62. theorem SLP.topTwoDegs_inv :
  63. ∀ {τ : ℕ} (P : SLP τ),
  64. 1 ≤ P.maxDeg ∧
  65. P.secondDeg ≤ P.maxDeg ∧
  66. (∀ k : Fin (τ + 2), P.wireDeg k ≤ P.maxDeg) ∧
  67. (∀ i j : Fin (τ + 2), i ≠ j → P.wireDeg i + P.wireDeg j ≤ P.maxDeg + P.secondDeg)
  68. | 0, .nil => by
  69. refine ⟨by simp [SLP.maxDeg, SLP.topTwoDegs],
  70. by simp [SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs], ?_, ?_⟩
  71. · intro k
  72. fin_cases k <;> simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.topTwoDegs]
  73. · intro i j hij
  74. fin_cases i <;> fin_cases j
  75. · exact absurd rfl hij
  76. · simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs]
  77. · simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs]
  78. · exact absurd rfl hij
  79. | τ + 1, .snoc P op i j => by
  80. obtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_inv
  81. set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree
  82. have hnew : (SLP.snoc P op i j).wireDeg ⟨τ + 2, Nat.lt_succ_self _⟩ = d := by
  83. simp [SLP.wireDeg, SLP.evalWire, d]
  84. have hold : ∀ k : Fin (τ + 3), (hk : k.val < τ + 2) →
  85. (SLP.snoc P op i j).wireDeg k = P.wireDeg ⟨k.val, hk⟩ := by
  86. intro k hk
  87. simp [SLP.wireDeg, SLP.evalWire, hk]
  88. have htop : (SLP.snoc P op i j).topTwoDegs =
  89. if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d) := by
  90. rfl
  91. by_cases hle : P.maxDeg ≤ d
  92. · have hM : (SLP.snoc P op i j).maxDeg = d := by
  93. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = d
  94. simp [hle]
  95. have hS : (SLP.snoc P op i j).secondDeg = P.maxDeg := by
  96. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 = P.maxDeg
  97. simp [hle]
  98. refine ⟨by omega, by omega, ?_, ?_⟩
  99. · intro k
  100. by_cases hk : k.val < τ + 2
  101. · rw [hold k hk, hM]; exact le_trans (hall ⟨k.val, hk⟩) hle
  102. · have hklt := k.isLt
  103. have hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  104. rw [hk', hnew, hM]
  105. · intro a b hab
  106. rw [hM, hS]
  107. by_cases ha : a.val < τ + 2 <;> by_cases hb : b.val < τ + 2
  108. · rw [hold a ha, hold b hb]
  109. have ha1 := hall ⟨a.val, ha⟩
  110. have hb1 := hall ⟨b.val, hb⟩
  111. omega
  112. · have hblt := b.isLt
  113. have hb' : b = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  114. rw [hold a ha, hb', hnew]
  115. have ha1 := hall ⟨a.val, ha⟩
  116. omega
  117. · have halt := a.isLt
  118. have ha' : a = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  119. rw [ha', hnew, hold b hb]
  120. have hb1 := hall ⟨b.val, hb⟩
  121. omega
  122. · have halt := a.isLt; have hblt := b.isLt
  123. exact absurd (Fin.ext (by omega)) hab
  124. · have hlt : d < P.maxDeg := by omega
  125. have hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := by
  126. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDeg
  127. simp [hle]
  128. have hS : (SLP.snoc P op i j).secondDeg = max P.secondDeg d := by
  129. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).2 =
  130. max P.secondDeg d
  131. simp [hle]
  132. refine ⟨by omega, by rw [hM, hS]; exact max_le h2 (le_of_lt hlt), ?_, ?_⟩
  133. · intro k
  134. by_cases hk : k.val < τ + 2
  135. · rw [hold k hk, hM]; exact hall ⟨k.val, hk⟩
  136. · have hklt := k.isLt
  137. have hk' : k = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  138. rw [hk', hnew, hM]; exact le_of_lt hlt
  139. · intro a b hab
  140. rw [hM, hS]
  141. by_cases ha : a.val < τ + 2 <;> by_cases hb : b.val < τ + 2
  142. · rw [hold a ha, hold b hb]
  143. have hne : (⟨a.val, ha⟩ : Fin (τ + 2)) ≠ ⟨b.val, hb⟩ := fun h =>
  144. hab (Fin.ext (by simpa using congrArg Fin.val h))
  145. have hp := hpair ⟨a.val, ha⟩ ⟨b.val, hb⟩ hne
  146. have : P.secondDeg ≤ max P.secondDeg d := le_max_left _ _
  147. omega
  148. · have hblt := b.isLt
  149. have hb' : b = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  150. rw [hold a ha, hb', hnew]
  151. have ha1 := hall ⟨a.val, ha⟩
  152. have : d ≤ max P.secondDeg d := le_max_right _ _
  153. omega
  154. · have halt := a.isLt
  155. have ha' : a = ⟨τ + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  156. rw [ha', hnew, hold b hb]
  157. have hb1 := hall ⟨b.val, hb⟩
  158. have : d ≤ max P.secondDeg d := le_max_right _ _
  159. omega
  160. · have halt := a.isLt; have hblt := b.isLt
  161. exact absurd (Fin.ext (by omega)) hab
  162. /-- Some wire always attains `P.maxDeg`. -/
  163. theorem SLP.exists_wire_eq_maxDeg :
  164. ∀ {τ : ℕ} (P : SLP τ), ∃ k : Fin (τ + 2), P.wireDeg k = P.maxDeg
  165. | 0, .nil =>
  166. ⟨⟨1, by decide⟩, by simp [SLP.wireDeg, SLP.evalWire, SLP.maxDeg, SLP.topTwoDegs]⟩
  167. | τ + 1, .snoc P op i j => by
  168. set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree
  169. by_cases hle : P.maxDeg ≤ d
  170. · refine ⟨⟨τ + 2, Nat.lt_succ_self _⟩, ?_⟩
  171. have hM : (SLP.snoc P op i j).maxDeg = d := by
  172. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = d
  173. simp [hle]
  174. rw [hM]; simp [SLP.wireDeg, SLP.evalWire, d]
  175. · obtain ⟨k, hk⟩ := P.exists_wire_eq_maxDeg
  176. refine ⟨⟨k.val, Nat.lt_succ_of_lt k.isLt⟩, ?_⟩
  177. have hM : (SLP.snoc P op i j).maxDeg = P.maxDeg := by
  178. change (if P.maxDeg ≤ d then (d, P.maxDeg) else (P.maxDeg, max P.secondDeg d)).1 = P.maxDeg
  179. simp [hle]
  180. rw [hM]; simp [SLP.wireDeg, SLP.evalWire, k.isLt]; exact hk
  181. /-- Core algebraic inequality for the `β = 2/7` potential step when `d ≤ D₁ + D₂`. -/
  182. private lemma potential_step_add_mul (D1 D2 : ℕ) (h2 : D2 ≤ D1) :
  183. (D1 + D2) ^ 5 ≤ 8 * D1 ^ 3 * (max (2 * D2) D1) ^ 2 := by
  184. by_cases h : 2 * D2 ≤ D1
  185. · rw [max_eq_right h]
  186. have hmul : 32 * (D1 + D2) ^ 5 ≤ 32 * (8 * D1 ^ 3 * D1 ^ 2) := by
  187. have h3 : 2 * (D1 + D2) ≤ 3 * D1 := by omega
  188. have hpow : (2 * (D1 + D2)) ^ 5 ≤ (3 * D1) ^ 5 := Nat.pow_le_pow_left h3 5
  189. have hlhs : (2 * (D1 + D2)) ^ 5 = 32 * (D1 + D2) ^ 5 := by ring
  190. have hrhs : (3 * D1) ^ 5 = 243 * D1 ^ 5 := by ring
  191. have h243 : 243 * D1 ^ 5 ≤ 256 * D1 ^ 5 := Nat.mul_le_mul_right _ (by decide)
  192. have h256 : 32 * (8 * D1 ^ 3 * D1 ^ 2) = 256 * D1 ^ 5 := by ring
  193. omega
  194. omega
  195. · have hlt : D1 ≤ 2 * D2 := by omega
  196. rw [max_eq_left hlt]
  197. have hsub : 32 * D1 ^ 3 * D2 ^ 2 ≥ (D1 + D2) ^ 5 := by
  198. set a := 2 * D2 - D1
  199. set b := D1 - D2
  200. have hD1 : D1 = a + 2 * b := by omega
  201. have hD2 : D2 = a + b := by omega
  202. rw [hD1, hD2]
  203. have hid : 32 * (a + 2 * b) ^ 3 * (a + b) ^ 2 =
  204. (a + 2 * b + (a + b)) ^ 5 +
  205. (16 * a ^ 4 * b + 80 * a ^ 3 * b ^ 2 + 136 * a ^ 2 * b ^ 3 +
  206. 86 * a * b ^ 4 + 13 * b ^ 5) := by ring
  207. omega
  208. have hrew : 8 * D1 ^ 3 * (2 * D2) ^ 2 = 32 * D1 ^ 3 * D2 ^ 2 := by ring
  209. omega
  210. /-- Pure-`ℕ` potential: `N(P) = D₁⁵ · (max (2 * D₂) D₁)²`. -/
  211. noncomputable def SLP.collapsePotential {τ : ℕ} (P : SLP τ) : ℕ :=
  212. P.maxDeg ^ 5 * (max (2 * P.secondDeg) P.maxDeg) ^ 2
  213. /-- Main Pure-Squaring Collapse potential bound:
  214. `D₁⁵ · (max (2 * D₂) D₁)² ≤ 2 ^ (7 * τ - 2 * nonTopSqCount P)`. -/
  215. theorem SLP.collapsePotential_le :
  216. ∀ {τ : ℕ} (P : SLP τ),
  217. P.collapsePotential ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount)
  218. | 0, .nil => by
  219. simp [SLP.collapsePotential, SLP.maxDeg, SLP.secondDeg, SLP.topTwoDegs, SLP.nonTopSqCount]
  220. | τ + 1, .snoc P op i j => by
  221. have ih := P.collapsePotential_le
  222. have hcount := P.nonTopSqCount_le
  223. obtain ⟨h1, h2, hall, hpair⟩ := P.topTwoDegs_inv
  224. set D1 := P.maxDeg
  225. set D2 := P.secondDeg
  226. set M := max (2 * D2) D1
  227. set d := (op.applyPoly (P.evalWire i) (P.evalWire j)).natDegree
  228. have hD1_le_M : D1 ≤ M := le_max_right _ _
  229. by_cases htopsq : isTopPureSquare P op i j
  230. · have hcnt : (SLP.snoc P op i j).nonTopSqCount = P.nonTopSqCount := by
  231. simp [SLP.nonTopSqCount, htopsq]
  232. have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount =
  233. (7 * τ - 2 * P.nonTopSqCount) + 7 := by rw [hcnt]; omega
  234. rw [hexp, pow_add]
  235. have hd_le : d ≤ 2 * D1 := by
  236. rcases htopsq with ⟨hop, hij, hdeg⟩
  237. subst hop; subst hij
  238. calc (P.evalWire i * P.evalWire i).natDegree
  239. ≤ (P.evalWire i).natDegree + (P.evalWire i).natDegree := Polynomial.natDegree_mul_le
  240. _ = 2 * D1 := by rw [← SLP.wireDeg, hdeg]; omega
  241. have hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 7 := by
  242. unfold SLP.collapsePotential
  243. by_cases hle : D1 ≤ d
  244. · have hM' : (SLP.snoc P op i j).maxDeg = d := by
  245. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = d; simp [hle]
  246. have hS' : (SLP.snoc P op i j).secondDeg = D1 := by
  247. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = D1; simp [hle]
  248. rw [hM', hS', max_eq_left hd_le]
  249. have hd5 : d ^ 5 ≤ (2 * D1) ^ 5 := Nat.pow_le_pow_left hd_le 5
  250. have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2
  251. calc d ^ 5 * (2 * D1) ^ 2
  252. ≤ (2 * D1) ^ 5 * (2 * D1) ^ 2 := Nat.mul_le_mul_right _ hd5
  253. _ = D1 ^ 5 * D1 ^ 2 * 2 ^ 7 := by ring
  254. _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 7 :=
  255. Nat.mul_le_mul_right _ (Nat.mul_le_mul_left _ hM2)
  256. · have hM' : (SLP.snoc P op i j).maxDeg = D1 := by
  257. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = D1; simp [hle]
  258. have hS' : (SLP.snoc P op i j).secondDeg = max D2 d := by
  259. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = max D2 d; simp [hle]
  260. rw [hM', hS']
  261. have hmax_le : max (2 * max D2 d) D1 ≤ 2 * D1 := max_le (by omega) (by omega)
  262. have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2
  263. calc D1 ^ 5 * (max (2 * max D2 d) D1) ^ 2
  264. ≤ D1 ^ 5 * (2 * D1) ^ 2 :=
  265. Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hmax_le 2)
  266. _ = D1 ^ 5 * D1 ^ 2 * 4 := by ring
  267. _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 7 :=
  268. Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide)
  269. exact le_trans hstep (Nat.mul_le_mul_right _ ih)
  270. · have hcnt : (SLP.snoc P op i j).nonTopSqCount = P.nonTopSqCount + 1 := by
  271. simp [SLP.nonTopSqCount, htopsq]
  272. have hexp : 7 * (τ + 1) - 2 * (SLP.snoc P op i j).nonTopSqCount =
  273. (7 * τ - 2 * P.nonTopSqCount) + 5 := by rw [hcnt]; omega
  274. rw [hexp, pow_add]
  275. have hstep : (SLP.snoc P op i j).collapsePotential ≤ P.collapsePotential * 2 ^ 5 := by
  276. unfold SLP.collapsePotential
  277. by_cases hle : D1 ≤ d
  278. · have hM' : (SLP.snoc P op i j).maxDeg = d := by
  279. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = d; simp [hle]
  280. have hS' : (SLP.snoc P op i j).secondDeg = D1 := by
  281. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = D1; simp [hle]
  282. rw [hM', hS']
  283. cases op with
  284. | add =>
  285. have hd_le : d ≤ D1 := by
  286. calc (P.evalWire i + P.evalWire j).natDegree
  287. ≤ max (P.evalWire i).natDegree (P.evalWire j).natDegree :=
  288. Polynomial.natDegree_add_le _ _
  289. _ ≤ D1 := max_le (hall i) (hall j)
  290. have hd_eq : d = D1 := by omega
  291. rw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)]
  292. have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2
  293. calc D1 ^ 5 * (2 * D1) ^ 2
  294. = D1 ^ 5 * D1 ^ 2 * 4 := by ring
  295. _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 :=
  296. Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide)
  297. | sub =>
  298. have hd_le : d ≤ D1 := by
  299. calc (P.evalWire i - P.evalWire j).natDegree
  300. ≤ max (P.evalWire i).natDegree (P.evalWire j).natDegree :=
  301. Polynomial.natDegree_sub_le _ _
  302. _ ≤ D1 := max_le (hall i) (hall j)
  303. have hd_eq : d = D1 := by omega
  304. rw [hd_eq, max_eq_left (by omega : D1 ≤ 2 * D1)]
  305. have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2
  306. calc D1 ^ 5 * (2 * D1) ^ 2
  307. = D1 ^ 5 * D1 ^ 2 * 4 := by ring
  308. _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 :=
  309. Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide)
  310. | mul =>
  311. by_cases hij : i = j
  312. · subst hij
  313. have hlt_deg : P.wireDeg i < D1 := by
  314. have hle_i := hall i
  315. have hne_i : P.wireDeg i ≠ D1 := fun heq => htopsq ⟨rfl, rfl, heq⟩
  316. omega
  317. obtain ⟨k0, hk0⟩ := P.exists_wire_eq_maxDeg
  318. have hne_ik : i ≠ k0 := fun heq => by rw [heq, hk0] at hlt_deg; omega
  319. have hpair_ik := hpair i k0 hne_ik
  320. have hi_le_D2 : P.wireDeg i ≤ D2 := by omega
  321. have hd_le_2D2 : d ≤ 2 * D2 := by
  322. calc (P.evalWire i * P.evalWire i).natDegree
  323. ≤ (P.evalWire i).natDegree + (P.evalWire i).natDegree :=
  324. Polynomial.natDegree_mul_le
  325. _ ≤ 2 * D2 := by rw [← SLP.wireDeg]; omega
  326. have hd_le_2D1 : d ≤ 2 * D1 := by omega
  327. rw [max_eq_left hd_le_2D1]
  328. have h2D2_le_M : 2 * D2 ≤ M := le_max_left _ _
  329. have hD2_3 : D2 ^ 3 ≤ D1 ^ 3 := Nat.pow_le_pow_left h2 3
  330. calc d ^ 5 * (2 * D1) ^ 2
  331. ≤ (2 * D2) ^ 5 * (2 * D1) ^ 2 :=
  332. Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hd_le_2D2 5)
  333. _ = 32 * D1 ^ 2 * D2 ^ 3 * (2 * D2) ^ 2 := by ring
  334. _ ≤ 32 * D1 ^ 2 * D1 ^ 3 * M ^ 2 :=
  335. Nat.mul_le_mul
  336. (Nat.mul_le_mul_left _ hD2_3)
  337. (Nat.pow_le_pow_left h2D2_le_M 2)
  338. _ = D1 ^ 5 * M ^ 2 * 2 ^ 5 := by ring
  339. · have hd_le_sum : d ≤ D1 + D2 := by
  340. calc (P.evalWire i * P.evalWire j).natDegree
  341. ≤ (P.evalWire i).natDegree + (P.evalWire j).natDegree :=
  342. Polynomial.natDegree_mul_le
  343. _ ≤ D1 + D2 := hpair i j hij
  344. have hd_le_2D1 : d ≤ 2 * D1 := by omega
  345. rw [max_eq_left hd_le_2D1]
  346. have hcore := potential_step_add_mul D1 D2 h2
  347. calc d ^ 5 * (2 * D1) ^ 2
  348. ≤ (D1 + D2) ^ 5 * (2 * D1) ^ 2 :=
  349. Nat.mul_le_mul_right _ (Nat.pow_le_pow_left hd_le_sum 5)
  350. _ ≤ (8 * D1 ^ 3 * M ^ 2) * (2 * D1) ^ 2 :=
  351. Nat.mul_le_mul_right _ hcore
  352. _ = D1 ^ 5 * M ^ 2 * 2 ^ 5 := by ring
  353. · have hM' : (SLP.snoc P op i j).maxDeg = D1 := by
  354. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).1 = D1; simp [hle]
  355. have hS' : (SLP.snoc P op i j).secondDeg = max D2 d := by
  356. change (if D1 ≤ d then (d, D1) else (D1, max D2 d)).2 = max D2 d; simp [hle]
  357. rw [hM', hS']
  358. have hmax_le : max (2 * max D2 d) D1 ≤ 2 * D1 := max_le (by omega) (by omega)
  359. have hM2 : D1 ^ 2 ≤ M ^ 2 := Nat.pow_le_pow_left hD1_le_M 2
  360. calc D1 ^ 5 * (max (2 * max D2 d) D1) ^ 2
  361. ≤ D1 ^ 5 * (2 * D1) ^ 2 :=
  362. Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hmax_le 2)
  363. _ = D1 ^ 5 * D1 ^ 2 * 4 := by ring
  364. _ ≤ D1 ^ 5 * M ^ 2 * 2 ^ 5 :=
  365. Nat.mul_le_mul (Nat.mul_le_mul_left _ hM2) (by decide)
  366. exact le_trans hstep (Nat.mul_le_mul_right _ ih)
  367. /-- **Pure-Squaring Collapse Degree Theorem:**
  368. For every constant-free DAG `P : SLP τ`,
  369. `(P.evalPoly.natDegree) ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount)`. -/
  370. theorem slp_pure_squaring_collapse_deg {τ : ℕ} (P : SLP τ) :
  371. P.evalPoly.natDegree ^ 7 ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount) := by
  372. obtain ⟨_, _, hall, _⟩ := P.topTwoDegs_inv
  373. have hdeg : P.evalPoly.natDegree ≤ P.maxDeg := hall ⟨τ + 1, Nat.lt_succ_self _⟩
  374. have hM : P.maxDeg ≤ max (2 * P.secondDeg) P.maxDeg := le_max_right _ _
  375. calc P.evalPoly.natDegree ^ 7
  376. ≤ P.maxDeg ^ 7 := Nat.pow_le_pow_left hdeg 7
  377. _ = P.maxDeg ^ 5 * P.maxDeg ^ 2 := by ring
  378. _ ≤ P.maxDeg ^ 5 * (max (2 * P.secondDeg) P.maxDeg) ^ 2 :=
  379. Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hM 2)
  380. _ = P.collapsePotential := rfl
  381. _ ≤ 2 ^ (7 * τ - 2 * P.nonTopSqCount) := P.collapsePotential_le
  382. /-! ## 2. Exact Integer Escape Theorem for Constant-Free Canonical Power-Circuits -/
  383. /-- A `k`-step constant-free canonical power-circuit:
  384. `y_{-1} = 1`, `y_0 = x`, and at step `r`, `y_r = y_{r-1} ^ (2 ^ A_r) ± v_r ^ (2 ^ B_r)`
  385. where `v_r` is any earlier wire (`Fin (r + 2)`) and `1 ≤ A_r`, `B_r < A_r`. -/
  386. structure CanonicalPowerStep (r : ℕ) where
  387. vIdx : Fin (r + 2)
  388. A : ℕ
  389. B : ℕ
  390. signSub : Bool
  391. hA : 1 ≤ A
  392. hBA : B < A
  393. /-- A canonical power-circuit of depth `k`. -/
  394. inductive CanonicalPowerCircuit : ℕ → Type
  395. | nil : CanonicalPowerCircuit 0
  396. | snoc {k : ℕ} (C : CanonicalPowerCircuit k) (step : CanonicalPowerStep k) :
  397. CanonicalPowerCircuit (k + 1)
  398. /-- Integer evaluation of wire `idx : Fin (k + 2)` of `C` at `x : ℤ`
  399. (wire `0` is `1`, wire `1` is `x`, wire `r + 2` is `y_{r+1}`). -/
  400. def CanonicalPowerCircuit.evalWire : {k : ℕ} → CanonicalPowerCircuit k → ℤ → Fin (k + 2) → ℤ
  401. | 0, .nil, x, idx => if idx.val = 0 then 1 else x
  402. | k + 1, .snoc C st, x, idx =>
  403. if h : idx.val < k + 2 then
  404. C.evalWire x ⟨idx.val, h⟩
  405. else
  406. let prev := C.evalWire x ⟨k + 1, Nat.lt_succ_self _⟩
  407. let v := C.evalWire x st.vIdx
  408. if st.signSub then prev ^ (2 ^ st.A) - v ^ (2 ^ st.B)
  409. else prev ^ (2 ^ st.A) + v ^ (2 ^ st.B)
  410. /-- Output integer evaluation of `C` at `x : ℤ`. -/
  411. def CanonicalPowerCircuit.eval {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ) : ℤ :=
  412. C.evalWire x ⟨k + 1, Nat.lt_succ_self _⟩
  413. private lemma int_abs_mul (a b : ℤ) : |a * b| = |a| * |b| := by
  414. rcases le_or_gt 0 a with ha | ha <;> rcases le_or_gt 0 b with hb | hb
  415. · rw [abs_of_nonneg ha, abs_of_nonneg hb, abs_of_nonneg (mul_nonneg ha hb)]
  416. · rw [abs_of_nonneg ha, abs_of_neg hb, abs_of_nonpos (mul_nonpos_of_nonneg_of_nonpos ha (le_of_lt hb))]
  417. ring
  418. · rw [abs_of_neg ha, abs_of_nonneg hb, abs_of_nonpos (mul_nonpos_of_nonpos_of_nonneg (le_of_lt ha) hb)]
  419. ring
  420. · rw [abs_of_neg ha, abs_of_neg hb, abs_of_pos (mul_pos_of_neg_of_neg ha hb)]
  421. ring
  422. private lemma int_abs_pow (a : ℤ) (n : ℕ) : |a ^ n| = |a| ^ n := by
  423. induction n with
  424. | zero => simp
  425. | succ n ih => rw [pow_succ, pow_succ, int_abs_mul, ih]
  426. /-- For `|x| ≥ 2`, every wire satisfies `|w| ≤ |prev|` and `2 ≤ |prev|`, and the output
  427. wire stays `≥ 2` in absolute value. -/
  428. theorem CanonicalPowerCircuit.abs_ge_two_of_abs_x_ge_two :
  429. ∀ {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ), 2 ≤ |x| →
  430. 2 ≤ |C.eval x| ∧ ∀ idx : Fin (k + 2), |C.evalWire x idx| ≤ |C.eval x|
  431. | 0, .nil, x, hx => by
  432. refine ⟨by simpa [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire] using hx, ?_⟩
  433. intro idx
  434. fin_cases idx
  435. · simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire]
  436. have h1 : |(1 : ℤ)| = 1 := by decide
  437. omega
  438. · simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire]
  439. | k + 1, .snoc C st, x, hx => by
  440. obtain ⟨hprev2, hall⟩ := C.abs_ge_two_of_abs_x_ge_two x hx
  441. set p := C.eval x
  442. set v := C.evalWire x st.vIdx
  443. have hv_le : |v| ≤ |p| := hall st.vIdx
  444. have hpow_strict : 2 ^ st.B + 1 ≤ 2 ^ st.A := by
  445. have h1 : 2 ^ st.B * 2 ≤ 2 ^ st.A := by
  446. have hle : st.B + 1 ≤ st.A := st.hBA
  447. calc 2 ^ st.B * 2 = 2 ^ (st.B + 1) := by rw [pow_succ]
  448. _ ≤ 2 ^ st.A := Nat.pow_le_pow_right (by decide) hle
  449. have hpos : 1 ≤ 2 ^ st.B := Nat.one_le_pow _ _ (by decide)
  450. omega
  451. have hv_pow_le : |v| ^ (2 ^ st.B) ≤ |p| ^ (2 ^ st.B) :=
  452. pow_le_pow_left₀ (abs_nonneg v) hv_le (2 ^ st.B)
  453. have hp_pow_ge : |p| ^ (2 ^ st.B) * |p| ≤ |p| ^ (2 ^ st.A) := by
  454. calc |p| ^ (2 ^ st.B) * |p| = |p| ^ (2 ^ st.B + 1) := by rw [pow_succ]
  455. _ ≤ |p| ^ (2 ^ st.A) := pow_le_pow_right₀ (by linarith) hpow_strict
  456. have hpb_ge2 : (2 : ℤ) ≤ |p| ^ (2 ^ st.B) := by
  457. have hpos : 1 ≤ 2 ^ st.B := Nat.one_le_pow _ _ (by decide)
  458. calc (2 : ℤ) ≤ |p| := hprev2
  459. _ = |p| ^ 1 := (pow_one _).symm
  460. _ ≤ |p| ^ (2 ^ st.B) := pow_le_pow_right₀ (by linarith) hpos
  461. have hdiff_ge : |p| ≤ |p| ^ (2 ^ st.A) - |v| ^ (2 ^ st.B) := by
  462. have hstep : |p| + |p| ^ (2 ^ st.B) ≤ |p| ^ (2 ^ st.B) * |p| := by nlinarith
  463. linarith
  464. have heval_out : (CanonicalPowerCircuit.snoc C st).eval x =
  465. if st.signSub then p ^ (2 ^ st.A) - v ^ (2 ^ st.B)
  466. else p ^ (2 ^ st.A) + v ^ (2 ^ st.B) := by
  467. simp [CanonicalPowerCircuit.eval, CanonicalPowerCircuit.evalWire, p, v]
  468. have hout_ge_p : |p| ≤ |(CanonicalPowerCircuit.snoc C st).eval x| := by
  469. rw [heval_out]
  470. have hp_abs : |p ^ (2 ^ st.A)| = |p| ^ (2 ^ st.A) := int_abs_pow p _
  471. have hv_abs : |v ^ (2 ^ st.B)| = |v| ^ (2 ^ st.B) := int_abs_pow v _
  472. split_ifs
  473. · have htri := abs_sub_abs_le_abs_sub (p ^ (2 ^ st.A)) (v ^ (2 ^ st.B))
  474. rw [hp_abs, hv_abs] at htri
  475. linarith
  476. · have htri : |p ^ (2 ^ st.A)| - |v ^ (2 ^ st.B)| ≤ |p ^ (2 ^ st.A) + v ^ (2 ^ st.B)| := by
  477. have := abs_sub_abs_le_abs_sub (p ^ (2 ^ st.A)) (-(v ^ (2 ^ st.B)))
  478. simpa [sub_neg_eq_add, abs_neg] using this
  479. rw [hp_abs, hv_abs] at htri
  480. linarith
  481. refine ⟨le_trans hprev2 hout_ge_p, ?_⟩
  482. intro idx
  483. by_cases hidx : idx.val < k + 2
  484. · have hew : (CanonicalPowerCircuit.snoc C st).evalWire x idx = C.evalWire x ⟨idx.val, hidx⟩ := by
  485. simp [CanonicalPowerCircuit.evalWire, hidx]
  486. rw [hew]
  487. exact le_trans (hall ⟨idx.val, hidx⟩) hout_ge_p
  488. · have hlt := idx.isLt
  489. have hidx' : idx = ⟨k + 2, Nat.lt_succ_self _⟩ := Fin.ext (by dsimp; omega)
  490. rw [hidx']; exact le_rfl
  491. /-- **Exact Integer Escape Theorem:**
  492. Every integer root of a constant-free canonical power-circuit `C` (with `1 ≤ A_r`, `B_r < A_r`)
  493. lies in `{-1, 0, 1}`. In particular, `C` has at most `3` distinct integer roots. -/
  494. theorem canonicalPowerCircuit_root_mem_three {k : ℕ} (C : CanonicalPowerCircuit k) (x : ℤ)
  495. (hroot : C.eval x = 0) : x = -1 ∨ x = 0 ∨ x = 1 := by
  496. by_contra hnot
  497. have h1 : x ≠ -1 := fun h => hnot (Or.inl h)
  498. have h2 : x ≠ 0 := fun h => hnot (Or.inr (Or.inl h))
  499. have h3 : x ≠ 1 := fun h => hnot (Or.inr (Or.inr h))
  500. have habs : (2 : ℤ) ≤ |x| := by
  501. rcases le_or_gt 0 x with hx | hx
  502. · rw [abs_of_nonneg hx]; omega
  503. · rw [abs_of_neg hx]; omega
  504. have hge := (C.abs_ge_two_of_abs_x_ge_two x habs).1
  505. rw [hroot, abs_zero] at hge
  506. omega
  507. /-! ## 3. Machine-Verified Rojas Preprint Audit Counterexamples (`arXiv:math/0110327v3`) -/
  508. /-- **Rojas Bug 1 Counterexample (`inv3.tex` §3, Smirnov Theorem 3.4 without nondegeneracy):**
  509. The system `f₁(x, y) = y - x + 1`, `f₂(x, y) = x² - 3y - 1` has the isolated simple root
  510. `(x, y) = (2, 1)` with nonsingular Jacobian `det J = -1 ≠ 0` (and `ord₂(2) = 1, ord₂(1) = 0`),
  511. while at weight `r = (1, 0)` the minimizing monomials of BOTH `f₁` and `f₂` are `{1, y}`
  512. (parallel vertical segments, mixed area `= 0 < 1`). -/
  513. theorem rojas_bug1_counterexample :
  514. let x : ℤ := 2
  515. let y : ℤ := 1
  516. (y - x + 1 = 0) ∧
  517. (x ^ 2 - 3 * y - 1 = 0) ∧
  518. ((-1 : ℤ) * (-3) - (1) * (2 * x) ≠ 0) ∧
  519. (0 < (1 : ℕ) ∧ 0 < (2 : ℕ)) := by
  520. decide
  521. /-- **Rojas Bug 2 Counterexample (`inv3.tex` Proof of Theorem 2 / `thm:lip`):**
  522. The shifted system `g₁(y₁, y₂) = y₂ - 2y₁ + 2`, `g₂(y₁, y₂) = 4y₁² - 6y₂ - 4`
  523. has the isolated simple root `(y₁, y₂) = (2, 2)` in `(2ℤ₂)²` (`ord₂ = (1, 1)`),
  524. with nonsingular Jacobian `det J = -4 ≠ 0`, yet for EVERY weight `(s₁, s₂)` with
  525. `s₁ ≥ 1, s₂ ≥ 1`, `-2y₁` and `4y₁²` never lie on `Newt₂^{(s₁,s₂,1)}(gᵢ)`. -/
  526. theorem rojas_bug2_counterexample :
  527. let y1 : ℤ := 2
  528. let y2 : ℤ := 2
  529. (y2 - 2 * y1 + 2 = 0) ∧
  530. (4 * y1 ^ 2 - 6 * y2 - 4 = 0) ∧
  531. ((-2 : ℤ) * (-6) - 1 * (8 * y1) ≠ 0) ∧
  532. (∀ s1 s2 : ℕ, 1 ≤ s1 → 1 ≤ s2 →
  533. min (1 : ℕ) s2 < 1 + s1 ∧ min (2 : ℕ) (1 + s2) < 2 + 2 * s1) := by
  534. refine ⟨by decide, by decide, by decide, ?_⟩
  535. intro s1 s2 hs1 hs2
  536. omega
  537. end Research.PvsNP.Tau