Initialized halting minimum-count prime selection #
The prefix, selected prime, raw modular count and charged halt all refer to the same actual final machine state. Every successful prefix at a larger admitted physical width agrees with the minimum-admission execution; prefix bounds therefore need not depend on physical width.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.runs_input {W n D A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hD : 16 ≤ D) (hv : ∀ z ∈ values, z.natAbs ≤ A) (hW : admissionWidth n D A ≤ W) :
WordRAM.InputFits W (CountPrime.inputWords n D values) ∧ ∃ (y : WordRAM.Data 160) (t : ℕ),
t + 1 ≤ timeBound n D + 16 ∧ WordRAM.Runs W (entryProgram.program Reg.best) (WordRAM.State.init (CountPrime.inputWords n D values))
{ pc := entryProgram.size, data := y } t ∧ WordRAM.Executes W (entryProgram.program Reg.best) (WordRAM.State.init (CountPrime.inputWords n D values))
(y.regs Reg.best) (t + 1) ∧ y.regs Reg.found = 1 ∧ ExactTriangle.IsSelectedPrime (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) D (y.regs Reg.best) ∧ y.regs Reg.bestCount = 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) (y.regs Reg.best) ∧ WordRAM.Data.Bounded W y ∧ ∀ (d : ℕ),
d < 3 + 3 * (n * n) ∨ CountPrime.memoryEnd n D.sqrt (Nat.clog 2 n) (3 + 3 * (n * n)) ≤ d →
y.mem d = (WordRAM.Data.init (CountPrime.inputWords n D values)).mem d
Actual original-input prefix and charged halt, with a selected minimum-count prime and the exact associated modular count in the same final state.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.bounded_reachable {W n D A : ℕ} (values : List ℤ) (hlen : values.length = 3 * (n * n)) (hD : 16 ≤ D) (hv : ∀ z ∈ values, z.natAbs ≤ A) (hW : admissionWidth n D A ≤ W) (s : WordRAM.State 160) (steps : ℕ) (hr : WordRAM.Runs W (entryProgram.program Reg.best) (WordRAM.State.init (CountPrime.inputWords n D values)) s steps) :
All words and support of any successful wider prefix are bounded by the original-input minimum width, not by the chosen physical width.