The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Inclusion.Core.DiscrTreeExt
16 declarations. Mathlib docs · Source
Discrimination-tree-indexed environment extensions
This file provides an API for scoped environment extensions whose declarations are indexed by
elaborated expression patterns in a DiscrTree.
Implementation notes
The inclusion tactic uses two separate types of DiscrTree indexed environment extensions. These
have nearly identical APIs except the stored values are different types (one is InclusionExts
and the other is HypothesisExts). This file essentially generalizes the DiscrTree valued
environment extension API from the implementation for the norm_num tactic so that it can take
arbitrary values.
TODO
Investigate the possibility of using this API for other tactics in Mathlib with DiscrTree
indexed environment extensions such as norm_num and positivity. This should perhaps be
part of a wider investigation into whether more API from the environment extensions of various
Mathlib tactics could be unified.
def DiscrTreeExt.instInhabitedState.default E1 #
{α : Type} → DiscrTreeExt.State α
theorem DiscrTreeExt.State.mk.injEq E0 #
∀ {α : Type} (tree tree_1 : Lean.Meta.DiscrTree α), ({ tree := tree } = { tree := tree_1 }) = (tree = tree_1)
def DiscrTreeExt.State.ctorIdx E1 #
{α : Type} → DiscrTreeExt.State α → ℕ
theorem DiscrTreeExt.State.mk.inj E1 #
∀ {α : Type} {tree tree_1 : Lean.Meta.DiscrTree α}, { tree := tree } = { tree := tree_1 } → tree = tree_1
def DiscrTreeExt.evalDecl E1 #
(α : Type) → Lean.Name → Lean.Name → Lean.ImportM α
Evaluate declName as a value of type α, checking that its Lean type is typeName.
abbrev DiscrTreeExt.Entry E1 #
Type
The discrimination-tree paths and declaration name stored in an .olean entry.
structure DiscrTreeExt.State E1 #
Type → Type
The state of a discrimination-tree environment extension.
ctor DiscrTreeExt.State.mk E0 #
{α : Type} → Lean.Meta.DiscrTree α → DiscrTreeExt.State α
abbrev DiscrTreeExt.State.tree E1 #
{α : Type} → DiscrTreeExt.State α → Lean.Meta.DiscrTree α
The discrimination tree of the extension.
instance DiscrTreeExt.instInhabitedState E0 #
{a : Type} → Inhabited (DiscrTreeExt.State a)
abbrev DiscrTreeExt.EnvExt E1 #
Type → Type
A scoped environment extension containing declaration values indexed by expression patterns.
def DiscrTreeExt.State.getMatch E1 #
{α : Type} → DiscrTreeExt.State α → Lean.Expr → Lean.MetaM (Array α)
Return the declaration values whose DiscrTree keys match e.
def DiscrTreeExt.recordRegisteringModule E1 #
Lean.AttributeKind → Lean.CoreM Unit
When the current module registers an attribute, record for shake that modules importing
the current one should continue to do so.
kind indicates the scope at which the attribute is registered.
TODO: This is an overly conservative approximation: better would be to record at the use site which tagged declarations are actually used.
def DiscrTreeExt.initializeEnvExt E1 #
{α : Type} → Lean.Name → autoParam Lean.Name DiscrTreeExt.initializeEnvExt._auto_1 → IO (DiscrTreeExt.EnvExt α)
Create a scoped environment extension whose declarations have type typeName. By default, the
environment extension is named after the declaration in which this function is called.
def DiscrTreeExt.EnvExt.register E1 #
{α : Type} → DiscrTreeExt.EnvExt α → DiscrTreeExt.Entry × α → Lean.AttributeKind → Lean.CoreM Unit
Register entry in ext, recording the current module as one shake should preserve.
Prefer this over ScopedEnvExtension.add when adding an entry from an attribute handler, so that
the registration and the shake bookkeeping cannot drift apart.
def DiscrTreeExt.elabExtKeys E1 #
Array Lean.Syntax → Lean.CoreM (Array (Array Lean.Meta.DiscrTree.Key))
Elaborate expression patterns into DiscrTree paths.