A primality certificate. One inductive rather than two mutually
recursive declarations, because a structure referring forward to PrimeCert
while PrimeCert refers back to it does not elaborate.
Each factor entry is a base a, an exponent e (stored off by one, so the
exponent e + 1 is positive by construction), and the child certificate for
a prime q, read off as the child's subject. Factor lists in both Pocklington
constructors must be in strictly ascending child-subject order for the checker
to accept them.
Constructors
Hex.Nat.PrimeCert.small (n : ℕ) : Hex.Nat.PrimeCert
n is an entry of the stored table.
Hex.Nat.PrimeCert.pock (n : ℕ) (factors : List (ℕ × ℕ × Hex.Nat.PrimeCert)) : Hex.Nat.PrimeCert
Pocklington: factors partially factors n - 1 past its square
root.
Hex.Nat.PrimeCert.pock3 (n r s w : ℕ) (factors : List (ℕ × ℕ × Hex.Nat.PrimeCert)) : Hex.Nat.PrimeCert
The cube-root Brillhart-Lehmer-Selfridge variant, with the cofactor
decomposition R = 2 F s + r and the integer-square-root witness w for
the discriminant test (Nat.sqrt is well-founded recursion and does not
kernel-reduce, so the checker verifies w instead of computing a root).