Complete concrete prime selection within the assembled solver #
The whole160-register selector, including actual primality tests and cyclic-Strassen calls, executes on the original matrices. The saved magnitude and all computed parameters survive. Admission here is the existing original-scalar numerical stage admission, not a counting or execution contract; the complete caller derives it from its original-input threshold.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.ParameterSelecting.exec_selectPrime {w W n D b ap bp cp F : ℕ} (x : WordRAM.Data 640) (u v z : ℕ → ℤ) (hD : 16 ≤ D) (hn : x.regs (selectorBank PrimeSelection.Reg.side) = n) (hd : x.regs (selectorBank PrimeSelection.Reg.window) = D) (ha : x.regs (selectorBank PrimeSelection.Reg.inputAB) = ap) (hb : x.regs (selectorBank PrimeSelection.Reg.inputBC) = bp) (hc : x.regs (selectorBank PrimeSelection.Reg.inputAC) = cp) (hs : x.regs (selectorBank PrimeSelection.Reg.scratch) = b) (haEnd : ap + n * n ≤ b) (hbEnd : bp + n * n ≤ b) (hcEnd : cp + n * n ≤ b) (hu : ∀ i < n * n, (u i).natAbs ≤ F) (hv : ∀ i < n * n, (v i).natAbs ≤ F) (hz : ∀ i < n * n, (z i).natAbs ≤ F) (hinU : ∀ i < n * n, x.mem (ap + i) = WordRAM.Signed.encode (u i)) (hinV : ∀ i < n * n, x.mem (bp + i) = WordRAM.Signed.encode (v i)) (hinZ : ∀ i < n * n, x.mem (cp + i) = WordRAM.Signed.encode (z i)) (hmag : GenericRAM.Signed.Fits w ↑(CountPrime.magnitudeBudget D.sqrt (Nat.clog 2 n) F)) (hw : WordRAM.Fits (w + 2) (CountPrime.addressBudget n D.sqrt (Nat.clog 2 n) b ap bp cp)) (hwidth : w + 2 ≤ W) (hctrl : WordRAM.Fits W (4 * (D + 2) * (D + 2) + 4)) :
∃ (y : WordRAM.Data 640),
WordRAM.ExecWithin W selectPrime x y (PrimeSelection.timeBound n D) ∧ ExactTriangle.IsSelectedPrime (fun (i j : Fin n) => u (↑i * n + ↑j)) (fun (i j : Fin n) => v (↑i * n + ↑j))
(fun (i j : Fin n) => z (↑i * n + ↑j)) D (y.regs (selectorBank PrimeSelection.Reg.best)) ∧ y.regs (selectorBank PrimeSelection.Reg.bestCount) = ExactTriangle.countZeroMod (fun (i j : Fin n) => u (↑i * n + ↑j)) (fun (i j : Fin n) => v (↑i * n + ↑j))
(fun (i j : Fin n) => z (↑i * n + ↑j)) (y.regs (selectorBank PrimeSelection.Reg.best)) ∧ (∀ (q : ℕ), q < b ∨ CountPrime.memoryEnd n D.sqrt (Nat.clog 2 n) b ≤ q → y.mem q = x.mem q) ∧ ∀ (j : Fin 640), 143 ≤ ↑j → y.regs j = x.regs j
Execute actual counting-based selection and retain all saved original/parameter registers.