Pocklington's primality test, cube-root variant #
The classic Pocklington test requires factoring a divisor F > √N of N - 1.
This variant (due to Brillhart–Lehmer–Selfridge) only needs F > N^(1/3), at the cost of
an additional divisibility sieve up to a small bound m and a non-square check on r² - 8s
(where R = (N-1)/F and R = 2·F·s + r).
The non-square certificate: one of three conditions that rule out r² - 8s being a
perfect square, which is needed to exclude composite factorisations.
Instances For
theorem
PrimeCert.pocklington3_test
(N F R m r s : ℕ)
(R_def : F * R + 1 = N)
(r_def : R % (2 * F) = r)
(s_def : R / (2 * F) = s)
(h2n : 2 ≤ N)
(odd_n : Odd N)
(odd_R : Odd R)
(primitive : ∀ p ∈ F.primeFactors, ∃ (a : ℕ), a ^ (N - 1) ≡ 1 [MOD N] ∧ (a ^ ((N - 1) / p) - 1).gcd N = 1)
(divisors : ∀ (l : ℕ), 1 ≤ l → l < m → ¬l * F + 1 ∣ N)
(bound : N + (m * F + 1) * (m * F) < (m * F + 1) * (2 * F ^ 2 + r * F + 1))
(cert : s = 0 ∨ ¬IsSquare (r ^ 2 - 8 * s) ∨ r ^ 2 < 8 * s)
:
How to discharge the Pocklington3Cert obligation:
- zero : Pocklington3CertMode
- prime (p : ℕ) (hp : Nat.Prime p) : Pocklington3CertMode
- lt : Pocklington3CertMode
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
PrimeCert.Pocklington3CertMode.to_cert
(m : Pocklington3CertMode)
(r s : ℕ)
(h : m.calculate r s = true)
:
Pocklington3Cert r s
noncomputable def
PrimeCert.pocklington3_calculate
(N e root m : ℕ)
(F' : List PrimePow)
(mode : Pocklington3CertMode)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
PrimeCert.mem_primeFactors_prod_toNat
(L : List PrimePow)
(p : ℕ)
:
p ∈ (List.map PrimePow.toNat L).prod.primeFactors → ∃ pp ∈ L, pp.prime = p
theorem
PrimeCert.pocklington3_certKR
(N root m e : ℕ)
(F' : List PrimePow)
(mode : Pocklington3CertMode)
(cert : pocklington3_calculate N e root m F' mode = true)
:
Inputs (not all needed):
N: the number to be certified as primeF: an even divisor ofN-1, fully factored, to be given as a literalF': the odd part ofF, given in factorised forme: the exponent of2inF, so thatF = 2^e * F'R: the quotient(N-1)/F, odd, given as a literal.root: a pseudo-primitive root (forF)m: an arbitrary number (> 0), which should be small for better performance.s, r := divmod(R, 2*F), given as literals
Syntax for the non-square certificate mode in pock3:
- A numeric literal
0meanss = 0 - A numeric literal
p(prime,p > 2) meansr² - 8sis a quadratic non-residue modp <meansr² < 8s
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
PrimeCert.Meta.parsePock3Mode
(stx : Lean.TSyntax `PrimeCert.Meta.pock3_mode)
(dict : PrimeDict)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
Syntax for a pock3 certificate step: (N, root, m, mode, F).
N: the number to certify as primeroot: a pseudo-primitive root (for the factored part ofN - 1)m: sieve bound — alll * F + 1for1 ≤ l < mmust not divideN(smallerm= less sieve work but requires largerF)mode: how to discharge the non-square condition (seepock3_mode)F: the even, fully-factored divisor ofN - 1, written as2 ^ e * p₁ ^ e₁ * p₂ * ...(the power of 2 must come first)
-- Certify 73471: root 3, sieve bound 1, non-square witness 7, F = 2 * 31
pock3 (73471, 3, 1, 7, 2 * 31)
-- With higher power of 2 and multiple odd factors:
pock3 (32560621, 2, 1, 7, 2 ^ 2 * 3 * 29)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- (PrimeCert.Meta.PrimePow.prime p).base = p
- (PrimeCert.Meta.PrimePow.pow p e).base = p
Instances For
def
PrimeCert.Meta.parsePrimePow'
(stx : Lean.TSyntax `PrimeCert.Meta.prime_pow)
(dict : PrimeDict)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
PrimeCert.Meta.parseFactored'
(stx : Lean.TSyntax `PrimeCert.Meta.factored)
(dict : PrimeDict)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- PrimeCert.Meta.pock3 = { syntaxName := `PrimeCert.Meta.pock3_spec, methodName := `PrimeCert.Meta.parsePock3Spec }
Instances For
Equations
- step_groupPock3_ = Lean.ParserDescr.node `step_groupPock3_ 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "pock3") PrimeCert.Meta.pock3_spec)
Instances For
Equations
- One or more equations did not get rendered due to their size.