Native CountPrime matrices agree with the existing coefficient specification #
Actual residue readback and the preceding native table construction feed the real padded matrix loop. Every resulting word is the canonical encoding of the existing P/Q coefficient at that exact Morton/coefficient index. No alternative matrix or triangle definition is introduced. Both padding and the actual BC transpose are included.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_matrix_coefficients {w n p k source destination table : ℕ} (src dst : Fin 128) (transpose : Bool) (x : WordRAM.Data 128) (weights : Fin n → Fin n → ℤ) (hpositive : 0 < p) (hdstReg : dst ≠ Reg.residueSource) (hn : x.regs Reg.side = n) (hp : x.regs Reg.modulus = p) (hN : x.regs Reg.paddedSide = 2 ^ k) (harea : x.regs Reg.paddedCells = 4 ^ k) (hsrc : x.regs src = source) (hdst : x.regs dst = destination) (ht : x.regs Reg.spread = table) (h0 : x.regs Reg.zero = 0) (h1 : x.regs Reg.one = 1) (h2 : x.regs Reg.two = 2) (hsourceBefore : source + n * n ≤ destination) (htableBefore : table + 2 ^ k ≤ destination) (htable : ∀ j < 2 ^ k, x.mem (table + j) = Nat.Morton.spread j) (hresidue : ∀ (a b : Fin n), x.mem (source + ↑a * n + ↑b) = (weights a b % ↑p).toNat) (hw : WordRAM.Fits w (destination + 4 ^ k * p + table + 4 ^ k + 2 ^ k + source + n * n + p + 16)) :
∃ (y : WordRAM.Data 128),
WordRAM.ExecWithin w (matrix src dst transpose) x y ((7 * p + 24) * 4 ^ k + 5) ∧ (∀ i < 4 ^ k * p,
y.mem (destination + i) = WordRAM.Signed.encode
(if transpose = true then ExactTriangle.CountPrime.qCoefficients p weights i
else ExactTriangle.CountPrime.pCoefficients p weights i)) ∧ (∀ (d : ℕ), d < destination ∨ destination + 4 ^ k * p ≤ d → y.mem d = x.mem d) ∧ ∀ (r : Fin 128), ¬MatrixLocal r → r ≠ Reg.residueSource → r ≠ Reg.destination → y.regs r = x.regs r
The complete computed native matrix agrees with existing P coefficients, or Q coefficients for the real transposed branch, at every occupied coefficient index.