Complete native modular counter from original caller data #
The fixed 128-register program computes its logarithm, padding, layout, residues, table, coefficient matrices, real seven-product recursion and selected count. No intermediate layout, table, matrix, execution or time certificate is an argument. Original signed arrays may alias each other below the dirty workspace. Its outside memory and persistent original parameters are preserved. Bounds refer solely to the original scalars, pointers and weights.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec {w n p scratch a b c A : ℕ} (x : WordRAM.Data 128) (u v z : ℕ → ℤ) (hp0 : 0 < p) (hn : x.regs Reg.side = n) (hp : x.regs Reg.modulus = 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 ↑(magnitudeBudget p (Nat.clog 2 n) A)) (hw : WordRAM.Fits (w + 2) (addressBudget n p (Nat.clog 2 n) scratch a b c)) :
∃ (y : WordRAM.Data 128),
WordRAM.ExecWithin (w + 2) program x y (cost n p) ∧ CounterRegisters n p (Nat.clog 2 n) scratch a b c y ∧ y.regs Reg.result = ExactTriangle.countZeroMod (fun (α β : Fin n) => u (↑α * n + ↑β)) (fun (α β : Fin n) => v (↑α * n + ↑β))
(fun (α β : Fin n) => z (↑α * n + ↑β)) p ∧ ∀ (d : ℕ), d < scratch ∨ memoryEnd n p (Nat.clog 2 n) scratch ≤ d → y.mem d = x.mem d
Complete actual caller execution from ordinary runtime arguments and original signed array words, with raw count, computed metadata, dirty-workspace frame and all native costs. The final halt is excluded here and is charged by initialized flat clients.