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.
Attribute for identifying norm_num
extensions.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- pre : Bool
The extension should be run in the
pre
phase when used as simp plugin. - post : Bool
The extension should be run in the
post
phase when used as simp plugin. - eval : {u : Lean.Level} → {α : Q(Type u)} → (e : Q(«$α»)) → Lean.MetaM (Mathlib.Meta.NormNum.Result e)
Attempts to prove an expression is equal to some explicit number of the relevant type.
- name : Lean.Name
The name of the
norm_num
extension.
An extension for norm_num
.
Instances For
Read a norm_num
extension from a declaration of the right type.
Equations
- Mathlib.Meta.NormNum.mkNormNumExt n = do let __discr ← read match __discr with | { env := env, opts := opts } => liftM (IO.ofExcept (Mathlib.Meta.NormNum.mkNormNumExt.impl✝ n env opts))
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 tree of
norm_num
extensions.- erased : Lean.PHashSet Lean.Name
Erased
norm_num
s.
The state of the norm_num
extension environment
Instances For
Equations
- Mathlib.Meta.NormNum.instInhabitedNormNums = { default := { tree := default, erased := default } }
Environment extensions for norm_num
declarations
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
Erases a name marked norm_num
by adding it to the state's erased
field and
removing it from the state's list of Entry
s.
Equations
- Mathlib.Meta.NormNum.NormNums.eraseCore d declName = { tree := d.tree, erased := Lean.PersistentHashSet.insert d.erased declName }
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.
The core of norm_num
as a tactic in MetaM
.
g
: The goal to simplifyctx
: The simp context, constructed bymkSimpContext
and containing any additional simp rules we want to usefvarIdsToSimp
: The selected set of hypotheses used in the location argumentsimplifyTarget
: true if the target is selected in the location argumentuseSimp
: true if we usednorm_num
instead ofnorm_num1
Equations
- One or more equations did not get rendered due to their size.
Instances For
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 ifonly
was used innorm_num
useSimp
: false ifnorm_num1
was used, in which case only the structural parts ofsimp
will be used, not any of the post-processing thatsimp only
does without lemmas
Equations
- One or more equations did not get rendered due to their size.
Instances For
Normalize numerical expressions. Supports the operations +
-
*
/
⁻¹
^
and %
over numerical types such as ℕ
, ℤ
, ℚ
, ℝ
, ℂ
and some general algebraic types,
and can prove goals of the form A = B
, A ≠ B
, A < B
and A ≤ B
, where A
and B
are
numerical expressions. It also has a relatively simple primality prover.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Basic version of norm_num
that does not call simp
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Basic version of norm_num
that does not call simp
.
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
Normalize numerical expressions. Supports the operations +
-
*
/
⁻¹
^
and %
over numerical types such as ℕ
, ℤ
, ℚ
, ℝ
, ℂ
and some general algebraic types,
and can prove goals of the form A = B
, A ≠ B
, A < B
and A ≤ B
, where A
and B
are
numerical expressions. It also has a relatively simple primality prover.
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
The basic usage is #norm_num e
, where e
is an expression,
which will print the norm_num
form of e
.
Syntax: #norm_num
(only
)? ([
simp lemma list ]
)? :
? expression
This accepts the same options as the #simp
command.
You can specify additional simp lemmas as usual, for example using #norm_num [f, g] : e
.
(The colon is optional but helpful for the parser.)
The only
restricts norm_num
to using only the provided lemmas, and so
#norm_num only : e
behaves similarly to norm_num1
.
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.
Equations
- One or more equations did not get rendered due to their size.