The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.Primality.Lucas

15 declarations. Mathlib docs · Source

theorem Mathlib.Tactic.Primality.LucasWitness.mk.injEq E0 #

∀ (root : ℕ) (primeFactors : List ℕ) (root_1 : ℕ) (primeFactors_1 : List ℕ),
  ({ root := root, primeFactors := primeFactors } = { root := root_1, primeFactors := primeFactors_1 }) =
    (root = root_1 ∧ primeFactors = primeFactors_1)

theorem Mathlib.Tactic.Primality.LucasWitness.mk.inj E1 #

∀ {root : ℕ} {primeFactors : List ℕ} {root_1 : ℕ} {primeFactors_1 : List ℕ},
  { root := root, primeFactors := primeFactors } = { root := root_1, primeFactors := primeFactors_1 } →
    root = root_1 ∧ primeFactors = primeFactors_1

def Mathlib.Tactic.Primality.LucasWitness.ctorIdx E1 #

Mathlib.Tactic.Primality.LucasWitness → ℕ

theorem Mathlib.Tactic.Primality.powMod.induct_unfolding E1 #

∀ (b m : ℕ) (motive : ℕ → ℕ → Prop),
  motive 0 (1 % m) →
    (∀ (x : ℕ),
        ¬x = 0 →
          motive (x / 16) (Mathlib.Tactic.Primality.powMod b (x / 16) m) →
            motive x ((Mathlib.Tactic.Primality.powMod b (x / 16) m).pow 16 * b.pow (x % 16) % m)) →
      ∀ (e : ℕ), motive e (Mathlib.Tactic.Primality.powMod b e m)

def Mathlib.Tactic.Primality.powMod E1 #

ℕ → ℕ → ℕ → ℕ

A more kernel-efficient version of b ^ e % m, computed four bits of e at a time by Nat.pow. Replace with Nat.powMod once lean4#15167 is available.

theorem Mathlib.Tactic.Primality.powMod_def E0 #

∀ (b e m : ℕ), Mathlib.Tactic.Primality.powMod b e m = b ^ e % m

theorem Mathlib.Tactic.Primality.powMod_eq_natPowMod E1 #

Mathlib.Tactic.Primality.powMod = Nat.powMod

Compiled code runs core's Nat.powMod in place of powMod since it is faster there.

def Mathlib.Tactic.Primality.lucasCheck E1 #

ℕ → ℕ → List (ℕ × ℕ) → Bool

lucasCheck p a factorization checks that a ^ (p - 1) % p = 1 (via the powMod check for q = 2), that a ^ ((p - 1) / q) % p ≠ 1 for each (q, e) ∈ factorization, and that the q ^ e multiply to p - 1.

theorem Mathlib.Tactic.Primality.prime_of_lucasCheck E1 #

∀ {p a : ℕ} {factorization : List (ℕ × ℕ)},
  (∀ f ∈ factorization, Nat.Prime f.1) → Mathlib.Tactic.Primality.lucasCheck p a factorization = true → Nat.Prime p

structure Mathlib.Tactic.Primality.LucasWitness E1 #

Type

A candidate witness of a Lucas certificate for a p, which is not recorded in the type.

ctor Mathlib.Tactic.Primality.LucasWitness.mk E0 #

ℕ → List ℕ → Mathlib.Tactic.Primality.LucasWitness

abbrev Mathlib.Tactic.Primality.LucasWitness.root E1 #

Mathlib.Tactic.Primality.LucasWitness → ℕ

A primitive root of p.

abbrev Mathlib.Tactic.Primality.LucasWitness.primeFactors E1 #

Mathlib.Tactic.Primality.LucasWitness → List ℕ

The prime factors of p - 1.

def Mathlib.Tactic.Primality.LucasWitness.factorization? E1 #

Mathlib.Tactic.Primality.LucasWitness → ℕ → Option (List (ℕ × ℕ))

The factorization of p - 1 into the prime factors of w, if each of them divides p - 1 and lucasCheck passes with the root of w.

def Mathlib.Tactic.Primality.certifyLucas E1 #

(p : ℕ) → ℕ → List ((q : ℕ) × ℕ × Q(Nat.Prime «$q»)) → Q(Nat.Prime «$p»)

Proves Nat.Prime p from the primitive root root and the factorization of p - 1 in factorization, each prime factor with its exponent and proof of primality.