Basic Definitions for RefinedDiscrTree
#
We define
Discrimination tree key.
- star : Key
A metavariable. This key matches with anything.
- labelledStar
(id : Nat)
: Key
A metavariable. This key matches with anything. It stores an identifier.
- opaque : Key
An opaque variable. This key only matches with
Key.star
. - const
(declName : Name)
(nargs : Nat)
: Key
A constant. It stores the name and the arity.
- fvar
(fvarId : FVarId)
(nargs : Nat)
: Key
A free variable. It stores the
FVarId
and the arity. - bvar
(deBruijnIndex nargs : Nat)
: Key
A bound variable, from a lambda or forall binder. It stores the De Bruijn index and the arity.
- lit
(v : Literal)
: Key
A literal.
- sort : Key
A sort. Universe levels are ignored.
- lam : Key
A lambda function.
- forall : Key
A dependent arrow.
- proj
(typeName : Name)
(idx nargs : Nat)
: Key
A projection. It stores the structure name, the projection index and the arity.
Instances For
Equations
Equations
Converts an entry (i.e., List Key
) to the discrimination tree into
MessageData
that is more user-friendly.
This is a copy of Lean.Meta.DiscrTree.keysAsPattern
Equations
- One or more equations did not get rendered due to their size.
Instances For
Get the next key.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Format the application f args
.
Format the next expression.
Add parentheses if paren == true
.
Equations
Instances For
Return the number of arguments that the Key
takes.
Equations
- (Lean.Meta.RefinedDiscrTree.Key.const declName nargs).arity = nargs
- (Lean.Meta.RefinedDiscrTree.Key.fvar fvarId nargs).arity = nargs
- (Lean.Meta.RefinedDiscrTree.Key.bvar deBruijnIndex nargs).arity = nargs
- Lean.Meta.RefinedDiscrTree.Key.lam.arity = 1
- Lean.Meta.RefinedDiscrTree.Key.forall.arity = 2
- (Lean.Meta.RefinedDiscrTree.Key.proj typeName idx nargs).arity = nargs + 1
- x✝.arity = 0
Instances For
The information for computing the keys of a subexpression.
- expr : Expr
The expression
Variables that come from a lambda or forall binder. The list index gives the De Bruijn index.
- lctx : LocalContext
The local context, which contains the introduced bound variables.
- localInsts : LocalInstances
The local instances, which may contain the introduced bound variables.
- cfg : Config
The
Meta.Config
used by this entry. - transparency : TransparencyMode
The current transparency level. Recall that unification uses the
default
transparency level when unifying implicit arguments. So we index implicit arguments
Instances For
The possible values that can appear in the stack
- star : StackEntry
.star
is an expression that will not be explicitly indexed. - expr
(info : ExprInfo)
: StackEntry
.expr
is an expression that will be indexed.
Instances For
A LazyEntry
represents a snapshot of the computation of encoding an Expr
as Array Key
.
This is used for computing the keys one by one.
If an expression creates more entries in the stack, for example because it is an application, then instead of pushing to the stack greedily, we only extend the stack once we need to. So, the field
previous
is used to extend thestack
before looking in thestack
.For example in
10.add (20.add 30)
, after computing the key⟨Nat.add, 2⟩
, the stack is still empty, andprevious
will be10.add (20.add 30)
.- stack : List StackEntry
The stack, used to emulate recursion. It contains the list of all expressions for which the keys still need to be computed, in that order.
For example in
10.add (20.add 30)
, after computing the keys⟨Nat.add, 2⟩
and10
, the stack will be a list of length 1 containing the expression20.add 30
. - mctx : MetavarContext
The metavariable context, which may contain variables appearing in this entry.
MVarId
s corresponding to the.labelledStar
labels. The index in the array is the label. It isnone
if we use.star
instead oflabelledStar
, for example when encoding the lookup expression.
Instances For
Array index of a Trie α
in the tries
of a RefinedDiscrTree
.
Equations
Instances For
Discrimination tree trie. See RefinedDiscrTree
.
A Trie
will normally have exactly one of the following
- nonempty
values
- nonempty
stars
,labelledStars
and/orchildren
- nonempty
pending
But defining it as a structure that can have all at the same time turns out to be easier.
- node :: (
- values : Array α
Return values, at a leaf
- labelledStars : Std.HashMap Nat TrieIndex
Following
Trie
s based on aKey.labelledStar
. - children : Std.HashMap Key TrieIndex
Lazy entries that still have to be evaluated.
- )
Instances For
Lazy refined discrimination tree. It is an index from expressions to values of type α
.
We store all of the nodes in one Array
, tries
, instead of using a 'normal' inductive type.
This is so that we can modify the tree globally, which is very useful when evaluating lazy
entries and saving the result globally.
- root : Std.HashMap Key TrieIndex
Array of trie entries. Should be owned by this trie.