Prime numbers #
This file deals with prime numbers: natural numbers p ≥ 2 whose only divisors are p and 1.
Important declarations #
Nat.Prime: the predicate that expresses that a natural numberpis primeNat.Primes: the subtype of natural numbers that are primeNat.minFac n: the minimal prime factor of a natural numbern ≠ 1Nat.prime_iff:Nat.Primecoincides with the general definition ofPrimeNat.irreducible_iff_nat_prime: a non-unit natural number is only divisible by1iff it is prime
Nat.Prime p means that p is a prime number, that is, a natural number
at least 2 whose only divisors are p and 1.
The theorem Nat.prime_def witnesses this description of a prime number.
Equations
- Nat.Prime p = Irreducible p
Instances For
A copy of not_prime_zero stated in a way that works for aesop.
See https://github.com/leanprover-community/aesop/issues/197 for an explanation.
A copy of not_prime_one stated in a way that works for aesop.
See https://github.com/leanprover-community/aesop/issues/197 for an explanation.
This instance is set up to work in the kernel (by decide) for small values.
Below (decidablePrime') we will define a faster variant to be used by the compiler
(e.g. in #eval or by native_decide).
If you need to prove that a particular number is prime, in any case
you should not use by decide, but rather by norm_num, which is
much faster.
Equations
- p.decidablePrime = decidable_of_iff' (2 ≤ p ∧ ∀ (m : ℕ), 2 ≤ m → m < p → ¬m ∣ p) ⋯
If n < k * k, then minFacAux n k = n, if k | n, then minFacAux n k = k.
Otherwise, minFacAux n k = minFacAux n (k+2) using well-founded recursion.
If n is odd and 1 < n, then minFacAux n 3 is the smallest prime factor of n.
This definition is by well-founded recursion, so rfl or decide cannot be used.
One can use norm_num to prove Nat.prime n for small n.
Instances For
This definition is faster in the virtual machine than decidablePrime,
but slower in the kernel.
Equations
- p.decidablePrime' = decidable_of_iff' (2 ≤ p ∧ p.minFac = p) ⋯
Instances For
Alias of the forward direction of Nat.Prime.dvd_mul.
Alias of the reverse direction of Nat.prime_iff.
Alias of the forward direction of Nat.prime_iff.
Equations
Equations
Equations
- Nat.Primes.instRepr = { reprPrec := fun (p : Nat.Primes) (x : ℕ) => repr ↑p }
Equations
- Nat.Primes.inhabitedPrimes = { default := ⟨2, Nat.prime_two⟩ }
Equations
- Nat.monoid.primePow = { pow := fun (x : α) (p : Nat.Primes) => x ^ ↑p }