Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.CountPrime.Input

Initialized native modular counting #

The ordinary input is raw (n,p) followed by three canonical signed, row-major matrices. The real nine-instruction header computes every original pointer and workspace start. The complete counter then constructs and counts its actual cyclic product. No table, padding parameter or intermediate fit certificate occurs in the input.

Raw (n,p) followed by canonical signed AB, BC and AC payloads in row-major order.

The exact original payload word, including the common zero default beyond the input.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.input_word_add {r : ℕ} (n p : ℕ) (values : List ℤ) (k q : ℕ) :
(WordRAM.Data.init (inputWords n p values)).mem (3 + k + q) = WordRAM.Signed.encode (values.getD (k + q) 0)

Read a payload word from an offset slice (3 + k) + q at any caller register count.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_header {W n p : ℕ} (x : WordRAM.Data 128) (hn : x.mem 1 = n) (hp : x.mem 2 = p) (hw : WordRAM.Fits W (3 + 3 * (n * n) + 8)) :

The actual header reads only the two original scalar words and computes all array bases.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_input_at {w n p A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hp : 0 < p) (hv : ∀ z ∈ values, z.natAbs ≤ A) (hmag : GenericRAM.Signed.Fits w ↑(magnitudeBudget p (Nat.clog 2 n) A)) (hw : WordRAM.Fits (w + 2) (addressBudget n p (Nat.clog 2 n) (3 + 3 * (n * n)) 3 (3 + n * n) (3 + 2 * (n * n)))) :
WordRAM.InputFits (w + 2) (inputWords n p values) ∧ ∃ (y : WordRAM.Data 128), WordRAM.ExecWithin (w + 2) entryProgram (WordRAM.Data.init (inputWords n p values)) y (cost n p + 9) ∧ y.regs Reg.result = ExactTriangle.countZeroMod (fun (α β : Fin n) => values.getD (↑α * n + ↑β) 0) (fun (α β : Fin n) => values.getD (n * n + ↑α * n + ↑β) 0) (fun (α β : Fin n) => values.getD (2 * (n * n) + ↑α * n + ↑β) 0) p ∧ WordRAM.Data.Bounded (w + 2) y ∧ ∀ (d : ℕ), d < 3 + 3 * (n * n) ∨ memoryEnd n p (Nat.clog 2 n) (3 + 3 * (n * n)) ≤ d → y.mem d = (WordRAM.Data.init (inputWords n p values)).mem d

Initialized actual structured execution with original-parameter numerical admission. Setup, all real computation and the input header are charged; the final halt is excluded.