Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.CountPrime.ScanCell

Actual selected-coefficient read and accumulation #

This internal stage reads the computed AB residue, computes its additive inverse modulo p, loads the actual cyclic-product coefficient and decodes its nonnegative canonical word. The complete counter derives this readback from its real residue and Strassen executions. No instruction performs a free coefficient lookup, signed decoding or summation.

The scan modifies only its result and the shared coordinate/address temporaries.

Instances For
    theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_countStep {w n p k i r value total : ℕ} (x : WordRAM.Data 128) (hn : x.regs Reg.side = n) (hp : x.regs Reg.modulus = p) (hi : x.regs Reg.index = i) (hlt : i < n * n) (hpadding : n ≤ 2 ^ k) (hr : x.mem (x.regs Reg.residueAB + i) = r) (hrlt : r < p) (hvalue : x.mem (x.regs Reg.matrixR + Nat.Morton.index (i / n) (i % n) * p + if r = 0 then 0 else p - r) = WordRAM.Signed.encode ↑value) (hbound : value ≤ n) (hresult : x.regs Reg.result = total) (htotal : total ≤ i * n) (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)) :
    ∃ (y : WordRAM.Data 128), WordRAM.ExecWithin w countStep x y 20 ∧ y.mem = x.mem ∧ y.regs Reg.index = i + 1 ∧ y.regs Reg.result = total + value ∧ ∀ (j : Fin 128), ¬ScanLocal j → y.regs j = x.regs j

    One actual selected coefficient, including the real zero/nonzero residue branch and signed-to-unsigned division. The sum and all addresses fit by the displayed numerical bound.