Charged strict-minimum updates #
The selector's actual comparison code retains its first minimum, including ties. This local execution rule does not assume that the input count was computed by a counter; that separate composition obligation belongs to the full prime-selection controller.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.exec_nop {w : ℕ} (x : WordRAM.Data 160) :
WordRAM.ExecWithin w nop x x 1
The ineligible branch executes one actual copy and leaves the complete state unchanged.
theorem Cslib.Algorithms.WordRAM.ExactTriangle.PrimeSelection.exec_keep {w : ℕ} (x : WordRAM.Data 160) (hz : x.regs Reg.zero = 0) (ho : x.regs Reg.one = 1) (hf : x.regs Reg.found = 0 ∨ x.regs Reg.found = 1) :
∃ (y : WordRAM.Data 160),
WordRAM.ExecWithin w keep x y 5 ∧ (y.regs Reg.best = if x.regs Reg.found = 0 ∨ x.regs Reg.countResult < x.regs Reg.bestCount then x.regs Reg.cursor
else x.regs Reg.best) ∧ (y.regs Reg.bestCount = if x.regs Reg.found = 0 ∨ x.regs Reg.countResult < x.regs Reg.bestCount then x.regs Reg.countResult
else x.regs Reg.bestCount) ∧ y.regs Reg.found = 1 ∧ y.mem = x.mem ∧ ∀ (i : Fin 160), i ≠ Reg.best → i ≠ Reg.bestCount → i ≠ Reg.found → y.regs i = x.regs i
Update a first strict minimum in at most five actual instructions, without touching memory
or any register outside the three result registers. The found input is a Boolean word.