Charged native trial division #
This is a finite instruction program, not an invocation of Lean's primality decision procedure. The Chan–He prime table will call it only on candidates at least two.
Main definitions #
PrimeTrial.program: trial divisors from two up to the candidate.
Main results #
PrimeTrial.exec: native trial division with an explicit linear instruction bound.
@[reducible, inline]
Candidate, preserved.
@[reducible, inline]
Current trial divisor.
@[reducible, inline]
Remainder scratch.
Test one trial divisor and advance. The conditional also charges its control instructions.
Initialize and test every divisor strictly between one and the candidate.
theorem Cslib.Algorithms.WordRAM.PrimeTrial.exec {w : ℕ} (x : WordRAM.Data 6) (hp : 2 ≤ x.regs arg) (hfit : WordRAM.Fits w (x.regs arg + 2)) :
Test a candidate at least two in at most 7(p-2)+6 native instructions.
All divisors are actual register values; the native remainder instruction is charged.