Actual cyclic Strassen product followed by native coefficient counting #
The actual seven-product program runs in the low bank and protects the computed residue and spread prefix. Its proved coefficient output feeds the real scan, which returns the existing modular triangle count. This internal composition theorem assumes the preceding producer's ordinary array meaning, never a multiplication, execution, count or time oracle.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_product_count {w n p k scratch a b c : ℕ} (x : WordRAM.Data 128) (wAB wBC wAC : Fin n → Fin n → ℤ) (hp : 0 < p) (hn : n ≤ 2 ^ k) (ready : CounterRegisters n p k scratch a b c x) (hAB : ∀ (u v : Fin n), x.mem (x.regs Reg.residueAB + ↑u * n + ↑v) = (wAB u v % ↑p).toNat) (htable : ∀ j < 2 ^ k, x.mem (x.regs Reg.spread + j) = Nat.Morton.spread j) (hleft :
∀ i < 4 ^ k * p,
x.mem (x.regs Reg.matrixP + i) = WordRAM.Signed.encode (ExactTriangle.CountPrime.pCoefficients p wAC i)) (hright :
∀ i < 4 ^ k * p,
x.mem (x.regs Reg.matrixQ + i) = WordRAM.Signed.encode (ExactTriangle.CountPrime.qCoefficients p wBC i)) (hmag : GenericRAM.Signed.Fits w ↑(2 * (p + 4) * 16 ^ k)) (hw : WordRAM.Fits (w + 2) (addressBudget n p k scratch a b c)) :
∃ (y : WordRAM.Data 128),
WordRAM.ExecWithin (w + 2) (product.seq count) x y (Strassen.traceBudget p k + 4 * k + 22 * (n * n) + 42) ∧ CounterRegisters n p k scratch a b c y ∧ y.regs Reg.result = ExactTriangle.countZeroMod wAB wBC wAC p ∧ ∀ (d : ℕ), d < x.regs Reg.matrixR ∨ x.regs Reg.productScratch + 4 ^ k * p + 7 * (k + 1) ≤ d → y.mem d = x.mem d
Invoke the concrete native Strassen controller and count its actual computed coefficients. The entire original/residue/table prefix and all memory beyond the explicit scratch/stack window survive; dirty product and scratch words require no clearing hypothesis.