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)
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
.
Equations
- Mathlib.Meta.NormNum.deriveNotPrime n d en = (let d' := n / d; let prf := q(⋯); let r := q(⋯); let r' := q(⋯); pure q(⋯)).run
Instances For
The norm_num
extension which identifies expressions of the form minFac n
.
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
- One or more equations did not get rendered due to their size.
- Mathlib.Meta.NormNum.evalNatPrime.core n nn pn 0 = pure (Mathlib.Meta.NormNum.Result.isFalse q(⋯))
- Mathlib.Meta.NormNum.evalNatPrime.core n nn pn 1 = pure (Mathlib.Meta.NormNum.Result.isFalse q(⋯))