Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.PrimeSelection.CounterCall

Actual modular counting inside the selector register bank #

Six real copies deliver the original side, current prime, matrix pointers and workspace to the complete native counter. The entire counter runs in its low 128-register bank. This rule composes its actual execution and memory frame; it assumes no counter answer, run, layout, multiplication or time contract.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.exec_count {w n p scratch a b c A : ℕ} (x : WordRAM.Data 160) (u v z : ℕ → ℤ) (hp0 : 0 < p) (hn : x.regs Reg.side = n) (hp : x.regs Reg.cursor = p) (hAB : x.regs Reg.inputAB = a) (hBC : x.regs Reg.inputBC = b) (hAC : x.regs Reg.inputAC = c) (hs : x.regs Reg.scratch = scratch) (ha : a + n * n ≤ scratch) (hb : b + n * n ≤ scratch) (hc : c + n * n ≤ scratch) (hu : ∀ i < n * n, (u i).natAbs ≤ A) (hv : ∀ i < n * n, (v i).natAbs ≤ A) (hz : ∀ i < n * n, (z i).natAbs ≤ A) (hinU : ∀ i < n * n, x.mem (a + i) = WordRAM.Signed.encode (u i)) (hinV : ∀ i < n * n, x.mem (b + i) = WordRAM.Signed.encode (v i)) (hinZ : ∀ i < n * n, x.mem (c + i) = WordRAM.Signed.encode (z i)) (hmag : GenericRAM.Signed.Fits w ↑(CountPrime.magnitudeBudget p (Nat.clog 2 n) A)) (hw : WordRAM.Fits (w + 2) (CountPrime.addressBudget n p (Nat.clog 2 n) scratch a b c)) :
∃ (y : WordRAM.Data 160), WordRAM.ExecWithin (w + 2) (count CountPrime.program) x y (CountPrime.cost n p + 6) ∧ y.regs Reg.countResult = ExactTriangle.countZeroMod (fun (α β : Fin n) => u (↑α * n + ↑β)) (fun (α β : Fin n) => v (↑α * n + ↑β)) (fun (α β : Fin n) => z (↑α * n + ↑β)) p ∧ ∀ (d : ℕ), d < scratch ∨ CountPrime.memoryEnd n p (Nat.clog 2 n) scratch ≤ d → y.mem d = x.mem d

Execute the real counter, including argument delivery, from original signed arrays and numerical admission. Sources may alias below scratch; the scratch region may be dirty. Selector metadata is outside the low counter bank.