Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.PrimeSelection.Loop

Native selection loop composed with a finite counting call #

exec_of_count is a component composition rule. It derives actual selection execution, minimum correctness, a complete controller bound and register preservation from the explicitly stated execution law for the supplied finite counting code. The law also preserves a memory predicate, allowing original matrices and a caller frame to persist across dirty workspace reuse. PrimeSelection.Exec discharges that law using the actual modular counter; this component rule alone does not assume a completed algorithm or complexity result.

The invariant BestBefore of PrimeSelection.Minimum and the step rule exec_candidate_bestBefore of PrimeSelection.Step are private proof plumbing of the selector; this module reads both through import all of PrimeSelection.Step, which itself reads PrimeSelection.Minimum through import all.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.exec_of_count {w D T : ℕ} (counter : WordRAM.Code WordRAM.Basis.standard 128) (score : ℕ → ℕ) (Source : (ℕ → ℕ) → Prop) (x : WordRAM.Data 160) (hD : 4 ≤ D) (hne : D.sqrtPrimeWindow.Nonempty) (hxD : x.regs Reg.window = D) (hfit : WordRAM.Fits w (4 * (D + 2) * (D + 2) + 4)) (hx : Source x.mem) (hcount : ∀ (z : WordRAM.Data 160), Source z.mem → (∀ (i : Fin 160), 131 ≤ ↑i ∧ ↑i ≤ 136 → z.regs i = x.regs i) → z.regs Reg.cursor ∈ D.sqrtPrimeWindow → ∃ (a : WordRAM.Data 160), WordRAM.ExecWithin w (count counter) z a T ∧ a.regs Reg.countResult = score (z.regs Reg.cursor) ∧ Source a.mem) :
∃ (y : WordRAM.Data 160), WordRAM.ExecWithin w (program counter) x y ((D.sqrt + 1) * (T + 7 * D.sqrt + 20) + 10) ∧ y.regs Reg.found = 1 ∧ y.regs Reg.best ∈ D.sqrtPrimeWindow ∧ y.regs Reg.bestCount = score (y.regs Reg.best) ∧ (∀ p ∈ D.sqrtPrimeWindow, score (y.regs Reg.best) ≤ score p) ∧ Source y.mem ∧ ∀ (i : Fin 160), 131 ≤ ↑i ∧ ↑i ≤ 136 ∨ 143 ≤ ↑i → y.regs i = x.regs i

Compose the real selector with an explicitly certified finite counting call. T bounds that call including its six argument copies. There is no supplied prime list. The concrete-counter instantiation is proved separately in PrimeSelection.Exec.