norm_num
basic plugins #
This file adds norm_num
plugins for
- constructors and constants
Nat.cast
,Int.cast
, andmkRat
+
,-
,*
, and/
Nat.succ
,Nat.sub
,Nat.mod
, andNat.div
.
See other files in this directory for many more plugins.
Constructors and constants #
The norm_num
extension which identifies an expression OfNat.ofNat n
, returning n
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The norm_num
extension which identifies the expression Int.natAbs n
such that
norm_num
successfully recognizes n
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Casts #
Arithmetic #
Note: Many of the lemmas in this file use a function equality hypothesis like f = HAdd.hAdd
below. The reason for this is that when this is applied, to prove e.g. 100 + 200 = 300
, the
+
here is HAdd.hAdd
with an instance that may not be syntactically equal to the one supplied
by the AddMonoidWithOne
instance, and rather than attempting to prove the instances equal lean
will sometimes decide to evaluate 100 + 200
directly (into whatever +
is defined to do in this
ring), which is definitely not what we want; if the subterms are expensive to kernel-reduce then
this could cause a (kernel) deep recursion detected
error (see https://github.com/leanprover/lean4/issues/2171, https://github.com/leanprover-community/mathlib4/pull/4048).
By using an equality for the unapplied +
function and proving it by rfl
we take away the
opportunity for lean to unfold the numerals (and the instance defeq problem is usually comparatively
easy).
Instances For
If b
divides a
and a
is invertible, then b
is invertible.
Equations
Instances For
If b
divides a
and a
is invertible, then b
is invertible.
Equations
Instances For
Consider an Option
as an object in the MetaM
monad, by throwing an error on none
.
Equations
Instances For
The result of adding two norm_num results.
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.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The result of negating a norm_num result.
Equations
- One or more equations did not get rendered due to their size.
- Mathlib.Meta.NormNum.Result.neg (Mathlib.Meta.NormNum.Result'.isBool val proof) rα = failure
Instances For
The result of subtracting two norm_num results.
Equations
- One or more equations did not get rendered due to their size.
- Mathlib.Meta.NormNum.Result.sub (Mathlib.Meta.NormNum.Result'.isBool val proof) rb inst = failure
- ra.sub (Mathlib.Meta.NormNum.Result'.isBool val proof) inst = failure
Instances For
The result of multiplying two norm_num results.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper function to synthesize a typed DivisionSemiring α
expression.
Equations
- Mathlib.Meta.NormNum.inferDivisionSemiring α = do let __do_lift ← Qq.synthInstanceQ q(DivisionSemiring «$α») <|> Lean.throwError (Lean.toMessageData "not a division semiring") pure __do_lift
Instances For
Helper function to synthesize a typed DivisionRing α
expression.
Equations
- Mathlib.Meta.NormNum.inferDivisionRing α = do let __do_lift ← Qq.synthInstanceQ q(DivisionRing «$α») <|> Lean.throwError (Lean.toMessageData "not a division ring") pure __do_lift