Actual initialized halting modular counter and every-wide-width prefixes #
The fixed standard-native program starts from the original header and signed matrix words. Its prefix witness, raw count and charged halt refer to the same actual final memory. Every wider admitted prefix agrees with a minimum-admission execution; the resulting word/support bounds depend only on original inputs and not on the chosen physical width.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.runs_input {W n p A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hp : 0 < p) (hv : ∀ z ∈ values, z.natAbs ≤ A) (hW : admissionWidth n p A ≤ W) :
WordRAM.InputFits W (inputWords n p values) ∧ ∃ (y : WordRAM.Data 128) (t : ℕ),
t + 1 ≤ cost n p + 10 ∧ WordRAM.Runs W (entryProgram.program Reg.result) (WordRAM.State.init (inputWords n p values))
{ pc := entryProgram.size, data := y } t ∧ WordRAM.Executes W (entryProgram.program Reg.result) (WordRAM.State.init (inputWords n p values))
(y.regs Reg.result) (t + 1) ∧ 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 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
Complete initialized flat execution, exact raw count and all setup/recursion/halt charges.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.bounded_reachable {W n p A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hp : 0 < p) (hv : ∀ z ∈ values, z.natAbs ≤ A) (hW : admissionWidth n p A ≤ W) (s : WordRAM.State 128) (steps : ℕ) (hr : WordRAM.Runs W (entryProgram.program Reg.result) (WordRAM.State.init (inputWords n p values)) s steps) :
Every successful prefix has original-input bounded words and zero memory beyond the same width-independent support envelope. The premise is an actual program prefix, not a supplied execution/correctness certificate used by the algorithm.