Actual selected-product scan yields the existing modular triangle count #
The signed original weights determine the residue keys and the actual seven-product coefficient array. Nonnegative coefficient bounds justify native unsigned decoding and every prefix sum. The caller counter constructs these arrays with its proved native stages; they are not additional algorithm inputs or an assumed multiplication/counting implementation.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_count_coefficients {w n p k : ℕ} (x : WordRAM.Data 128) (wAB wBC wAC : Fin n → Fin n → ℤ) (hpositive : 0 < p) (hpadding : n ≤ 2 ^ k) (hn : x.regs Reg.side = n) (hp : x.regs Reg.modulus = p) (hc : x.regs Reg.cells = n * n) (hresidue : ∀ (a b : Fin n), x.mem (x.regs Reg.residueAB + ↑a * n + ↑b) = (wAB a b % ↑p).toNat) (hproduct :
∀ i < 4 ^ k * p,
x.mem (x.regs Reg.matrixR + i) = WordRAM.Signed.encode
(MatrixMultiplication.Strassen.multiply p k (ExactTriangle.CountPrime.pCoefficients p wAC)
(ExactTriangle.CountPrime.qCoefficients p wBC) i)) (h0 : x.regs Reg.zero = 0) (h1 : x.regs Reg.one = 1) (h2 : x.regs Reg.two = 2) (htable : ∀ j < 2 ^ k, x.mem (x.regs Reg.spread + j) = Nat.Morton.spread j) (hw :
WordRAM.Fits w
(x.regs Reg.spread + x.regs Reg.residueAB + x.regs Reg.matrixR + 4 ^ k * p + 4 ^ k + 2 ^ k + n * n * n + n * n + p + 16)) :
Scan actual computed residue/product readback and obtain precisely the existing modular triangle count, with original row-major coordinates, zero padding and both residue branches.