norm_num core functionality #
This file sets up the norm_num tactic and the @[norm_num] attribute,
which allow for plugging in new normalization functionality around a simp-based driver.
The actual behavior is in @[norm_num]-tagged definitions in Tactic.NormNum.Basic
and elsewhere.
@[norm_num e], where e is an expression (optionally with _s) adds the tagged definition,
of type NormNumExt, to the set of normalization procedures used by the norm_num tactic, such
that it will fire on expressions matching the form e. Use holes in e to indicate arbitrary
subexpressions, for example @[norm_num _ + _] will match any addition.
@[norm_num e1, e2, ...]will match eithere1ore2or ...
Example:
@[norm_num -_] def evalNeg : NormNumExt where eval {u α} e := do
let .app (f : Q($α → $α)) (a : Q($α)) ← whnfR e | failure
let ra ← derive a
let rα ← inferRing α
ra.neg
Equations
- One or more equations did not get rendered due to their size.
Instances For
An extension for norm_num.
- pre : Bool
The extension should be run in the
prephase when used as simp plugin. - post : Bool
The extension should be run in the
postphase when used as simp plugin. Attempts to prove an expression is equal to some explicit number of the relevant type.
- name : Lean.Name
The name of the
norm_numextension.
Instances For
Read a norm_num extension from a declaration of the right type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Each norm_num extension is labelled with a collection of patterns
which determine the expressions to which it should be applied.
Equations
Instances For
The state of the norm_num extension environment
- tree : Lean.Meta.DiscrTree NormNumExt
The tree of
norm_numextensions. - erased : Lean.PHashSet Lean.Name
Erased
norm_nums.
Instances For
Equations
Instances For
Environment extensions for norm_num declarations
Run each registered norm_num extension on an expression, returning a NormNum.Result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run each registered norm_num extension on a typed expression e : α,
returning a typed expression lit : ℕ, and a proof of isNat e lit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run each registered norm_num extension on a typed expression e : α,
returning a typed expression lit : ℤ, and a proof of IsInt e lit in expression form.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run each registered norm_num extension on a typed expression e : α,
returning a rational number, typed expressions n : ℤ and d : ℕ for the numerator and
denominator, and a proof of IsRat e n d in expression form.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run each registered norm_num extension on a typed expression p : Prop,
and returning the truth or falsity of p' : Prop from an equivalence p ↔ p'.
Equations
- Mathlib.Meta.NormNum.deriveBool p = do let __discr ← Mathlib.Meta.NormNum.derive q(«$p») match __discr with | Mathlib.Meta.NormNum.Result'.isBool b prf => pure ⟨b, prf⟩ | x => failure
Instances For
Run each registered norm_num extension on a typed expression p : Prop,
and returning the truth or falsity of p' : Prop from an equivalence p ↔ p'.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run each registered norm_num extension on an expression,
returning a Simp.Result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Erase a name marked as a norm_num attribute.
Check that it does in fact have the norm_num attribute by making sure it names a NormNumExt
found somewhere in the state's tree, and is not erased.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A simp plugin which calls NormNum.eval.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A discharger which calls norm_num.
A Methods implementation which calls norm_num.
Traverses the given expression using simp and normalises any numbers it finds.
Constructs a simp context from the simp argument syntax.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Elaborates a call to norm_num only? [args] or norm_num1.
args: the(simpArgs)?syntax for simp argumentsloc: the(location)?syntax for the optional location argumentsimpOnly: true ifonlywas used innorm_numuseSimp: false ifnorm_num1was used, in which case only the structural parts ofsimpwill be used, not any of the post-processing thatsimp onlydoes without lemmas
Equations
- One or more equations did not get rendered due to their size.
Instances For
norm_num normalizes numerical expressions in the goal. By default, it supports the operations
+ - * / ⁻¹ ^ and % over types with (at least) an AddMonoidWithOne instance, such as
ℕ, ℤ, ℚ, ℝ, ℂ. In addition to evaluating numerical expressions, norm_num will use simp
to simplify the goal. If the goal has the form A = B, A ≠ B, A < B or A ≤ B, where A and
B are numerical expressions, norm_num will try to close it. It also has a relatively simple
primality prover.
This tactic is extensible. Extensions can allow norm_num to evaluate more kinds of expressions, or
to prove more kinds of propositions. See the @[norm_num] attribute for further information on
extending norm_num.
norm_num at lnormalizes at location(s)l.norm_num [h1, ...]adds the argumentsh1, ...to thesimpset in addition to the defaultsimpset. All options forsimparguments are supported, in particular←,↑and↓.norm_num onlydoes not use the defaultsimpset for simplification.norm_num only [h1, ...]uses only the argumentsh1, ...in addition to the routines tagged@[norm_num].norm_num onlystill performs post-processing steps, likesimp only, usenorm_num1if you exclusively want to normalize numerical expressions.norm_num (config := cfg)usescfgas configuration forsimpcalls (see thesimptactic for further details).
Examples:
example : 43 ≤ 74 + (33 : ℤ) := by norm_num
example : ¬ (7-2)/(2*3) ≥ (1:ℝ) + 2/(3^2) := by norm_num
Equations
- One or more equations did not get rendered due to their size.
Instances For
norm_num1 normalizes numerical expressions in the goal. It is a basic version of norm_num
that does not call simp.
By default, it supports the operations + - * / ⁻¹ ^ and % over types with (at least)
an AddMonoidWithOne instance, such as ℕ, ℤ, ℚ, ℝ, ℂ. If the goal has the form A = B,
A ≠ B, A < B or A ≤ B, where A and B are numerical expressions, norm_num1 will try to
close it. It also has a relatively simple primality prover.
:e
This tactic is extensible. Extensions can allow norm_num1 to evaluate more kinds of expressions,
or to prove more kinds of propositions. See the @[norm_num] attribute for further information on
extending norm_num1.
norm_num1 at lnormalizes at location(s)l.
Examples:
example : 43 ≤ 74 + (33 : ℤ) := by norm_num1
example : ¬ (7-2)/(2*3) ≥ (1:ℝ) + 2/(3^2) := by norm_num1
Equations
- One or more equations did not get rendered due to their size.
Instances For
norm_num1 normalizes numerical expressions in the goal. It is a basic version of norm_num
that does not call simp.
By default, it supports the operations + - * / ⁻¹ ^ and % over types with (at least)
an AddMonoidWithOne instance, such as ℕ, ℤ, ℚ, ℝ, ℂ. If the goal has the form A = B,
A ≠ B, A < B or A ≤ B, where A and B are numerical expressions, norm_num1 will try to
close it. It also has a relatively simple primality prover.
:e
This tactic is extensible. Extensions can allow norm_num1 to evaluate more kinds of expressions,
or to prove more kinds of propositions. See the @[norm_num] attribute for further information on
extending norm_num1.
norm_num1 at lnormalizes at location(s)l.
Examples:
example : 43 ≤ 74 + (33 : ℤ) := by norm_num1
example : ¬ (7-2)/(2*3) ≥ (1:ℝ) + 2/(3^2) := by norm_num1
Equations
- Mathlib.Tactic.normNum1Conv = Lean.ParserDescr.node `Mathlib.Tactic.normNum1Conv 1024 (Lean.ParserDescr.nonReservedSymbol "norm_num1" false)
Instances For
Elaborator for norm_num1 conv tactic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
norm_num normalizes numerical expressions in the goal. By default, it supports the operations
+ - * / ⁻¹ ^ and % over types with (at least) an AddMonoidWithOne instance, such as
ℕ, ℤ, ℚ, ℝ, ℂ. In addition to evaluating numerical expressions, norm_num will use simp
to simplify the goal. If the goal has the form A = B, A ≠ B, A < B or A ≤ B, where A and
B are numerical expressions, norm_num will try to close it. It also has a relatively simple
primality prover.
This tactic is extensible. Extensions can allow norm_num to evaluate more kinds of expressions, or
to prove more kinds of propositions. See the @[norm_num] attribute for further information on
extending norm_num.
norm_num at lnormalizes at location(s)l.norm_num [h1, ...]adds the argumentsh1, ...to thesimpset in addition to the defaultsimpset. All options forsimparguments are supported, in particular←,↑and↓.norm_num onlydoes not use the defaultsimpset for simplification.norm_num only [h1, ...]uses only the argumentsh1, ...in addition to the routines tagged@[norm_num].norm_num onlystill performs post-processing steps, likesimp only, usenorm_num1if you exclusively want to normalize numerical expressions.norm_num (config := cfg)usescfgas configuration forsimpcalls (see thesimptactic for further details).
Examples:
example : 43 ≤ 74 + (33 : ℤ) := by norm_num
example : ¬ (7-2)/(2*3) ≥ (1:ℝ) + 2/(3^2) := by norm_num
Equations
- One or more equations did not get rendered due to their size.
Instances For
Elaborator for norm_num conv tactic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
#norm_num e, where e is an expression, will print the norm_num form of e.
Unlike norm_num, this command does not fail when no simplifications are made.
#norm_num understands local variables, so you can use them to introduce parameters.
(In the variants below, the : is optional but helpful for the parser.)
#norm_num [h1, ...] : eadds the argumentsh1, ...to thesimpset in addition to the defaultsimpset. All options forsimparguments are supported, in particular←,↑and↓.#norm_num only : eand#norm_num only [h1, ...] : edo not use the defaultsimpset for simplification.#norm_num (config := cfg) : eusescfgas configuration forsimpcalls (see thesimptactic for further details).
Equations
- One or more equations did not get rendered due to their size.
Instances For
We register norm_num with the hint tactic.