Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.PrimeSelection.Exec

Concrete native minimum-count prime selection #

The selector calls the complete cyclic-Strassen counter on actual original signed arrays for every eligible prime. It derives the counting-call law from that program, retains a prime satisfying the existing IsSelectedPrime, and preserves the original arrays and caller memory outside one modulus-uniform workspace. No counting, execution, prime list, layout or running-time oracle is a hypothesis.

The caller supplies ordinary runtime scalar/pointer arguments, original weight bounds and explicit numerical word admission. Initialized input, derived logarithmic admission and width-independent prefix/support bounds are exported by the main prime-selection module.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.exec {w W n D scratch a b c A : ℕ} (x : WordRAM.Data 160) (u v z : ℕ → ℤ) (hD : 16 ≤ D) (hn : x.regs Reg.side = n) (hwindow : x.regs Reg.window = D) (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 D.sqrt (Nat.clog 2 n) A)) (hw : WordRAM.Fits (w + 2) (CountPrime.addressBudget n D.sqrt (Nat.clog 2 n) scratch a b c)) (hwidth : w + 2 ≤ W) (hctrl : WordRAM.Fits W (4 * (D + 2) * (D + 2) + 4)) :
∃ (y : WordRAM.Data 160), WordRAM.ExecWithin W (program CountPrime.program) x y (timeBound n D) ∧ y.regs Reg.found = 1 ∧ ExactTriangle.IsSelectedPrime (fun (α β : Fin n) => u (↑α * n + ↑β)) (fun (α β : Fin n) => v (↑α * n + ↑β)) (fun (α β : Fin n) => z (↑α * n + ↑β)) D (y.regs Reg.best) ∧ y.regs Reg.bestCount = ExactTriangle.countZeroMod (fun (α β : Fin n) => u (↑α * n + ↑β)) (fun (α β : Fin n) => v (↑α * n + ↑β)) (fun (α β : Fin n) => z (↑α * n + ↑β)) (y.regs Reg.best) ∧ (∀ (d : ℕ), d < scratch ∨ CountPrime.memoryEnd n D.sqrt (Nat.clog 2 n) scratch ≤ d → y.mem d = x.mem d) ∧ ∀ (i : Fin 160), 131 ≤ ↑i ∧ ↑i ≤ 136 ∨ 143 ≤ ↑i → y.regs i = x.regs i

Execute the actual trial-division/minimum controller with the real modular counter. Every original-array read, argument copy and counter instruction is charged. The common admission and memory envelope use the largest possible prime; no intermediate state or execution certificate is supplied. The final halt is excluded from this caller rule.