Actual canonical signed monomial writes #
Each of the p coefficients is stored, so dirty destination words do not become implicit
padding. An out-of-range key (in particular the native padding sentinel p) writes a zero
block. The raw unsigned word two is exactly Signed.encode 1; there is no extra conversion
or free ring-coefficient operation. This is an internal counter-stage execution API.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_writeCoefficients {w : ℕ} (x : WordRAM.Data 128) (h0 : x.regs Reg.zero = 0) (h1 : x.regs Reg.one = 1) (h2 : x.regs Reg.two = 2) (hw : WordRAM.Fits w (x.regs Reg.block + x.regs Reg.modulus + 4)) :
∃ (y : WordRAM.Data 128),
WordRAM.ExecWithin w writeCoefficients x y (7 * x.regs Reg.modulus + 3) ∧ (∀ j < x.regs Reg.modulus, y.mem (x.regs Reg.block + j) = if j = x.regs Reg.residue then 2 else 0) ∧ (∀ (a : ℕ), a < x.regs Reg.block ∨ x.regs Reg.block + x.regs Reg.modulus ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin 128), i ≠ Reg.coefficient → i ≠ Reg.address → y.regs i = x.regs i
A whole dirty p-word destination becomes the canonical coefficient block, with every test, address calculation and store charged. The key may be any unsigned word.