Documentation

Mathlib.Tactic.NormNum.Prime

norm_num extensions on natural numbers #

This file provides a norm_num extension to prove that natural numbers are prime and compute its minimal factor. Todo: compute the list of all factors.

Implementation Notes #

For numbers larger than 25 bits, the primality proof produced by norm_num is an expression that is thousands of levels deep, and the Lean kernel seems to raise a stack overflow when type-checking that proof. If we want an implementation that works for larger primes, we should generate a proof that has a smaller depth.

Note: evalMinFac.aux does not raise a stack overflow, which can be checked by replacing the prf' in the recursive call by something like (.sort .zero)

theorem Mathlib.Meta.NormNum.not_prime_mul_of_ble (a b n : β„•) (h : a * b = n) (h₁ : a.ble 1 = false) (hβ‚‚ : b.ble 1 = false) :
Β¬Nat.Prime n
def Mathlib.Meta.NormNum.deriveNotPrime (n d : β„•) (en : Q(β„•)) :
Q(Β¬Nat.Prime Β«$enΒ»)

Produce a proof that n is not prime from a factor 1 < d < n. en should be the expression that is the natural number literal n.

Instances For

    A predicate representing partial progress in a proof of minFac.

    Instances For
      theorem Mathlib.Meta.NormNum.MinFacHelper.one_lt {n k : β„•} (h : MinFacHelper n k) :
      1 < n
      theorem Mathlib.Meta.NormNum.minFacHelper_0 (n : β„•) (h1 : Nat.ble 2 n = true) (h2 : 1 = n % 2) :
      theorem Mathlib.Meta.NormNum.minFacHelper_1 {n k k' : β„•} (e : k + 2 = k') (h : MinFacHelper n k) (np : n.minFac β‰  k) :
      theorem Mathlib.Meta.NormNum.minFacHelper_2 {n k k' : β„•} (e : k + 2 = k') (nk : Β¬Nat.Prime k) (h : MinFacHelper n k) :
      theorem Mathlib.Meta.NormNum.minFacHelper_3 {n k k' : β„•} (e : k + 2 = k') (nk : (n % k).beq 0 = false) (h : MinFacHelper n k) :
      theorem Mathlib.Meta.NormNum.isNat_minFac_2 {a a' : β„•} :
      IsNat a a' β†’ a' % 2 = 0 β†’ IsNat a.minFac 2
      theorem Mathlib.Meta.NormNum.isNat_minFac_3 {n n' : β„•} (k : β„•) :
      IsNat n n' β†’ MinFacHelper n' k β†’ 0 = n' % k β†’ IsNat n.minFac k
      theorem Mathlib.Meta.NormNum.isNat_minFac_4 {n n' k : β„•} :
      IsNat n n' β†’ MinFacHelper n' k β†’ (k * k).ble n' = false β†’ IsNat n.minFac n'

      The norm_num extension which identifies expressions of the form minFac n.

      Instances For
        theorem Mathlib.Meta.NormNum.isNat_prime_2 {n n' : β„•} :
        IsNat n n' β†’ Nat.ble 2 n' = true β†’ IsNat n'.minFac n' β†’ Nat.Prime n
        theorem Mathlib.Meta.NormNum.isNat_not_prime {n n' : β„•} (h : IsNat n n') :
        Β¬Nat.Prime n' β†’ Β¬Nat.Prime n

        The norm_num extension which identifies expressions of the form Nat.Prime n.

        Instances For