Design Note: Symbol Priorities and Extension State #
We considered including SymbolPriorities in ExtensionState to allow each grind attribute/extension
to define its own symbol priorities. However, this design was rejected because E-match patterns are selected
with respect to symbol priorities. When using multiple grind attributes simultaneously
(e.g., grind only [attr_1, attr_2]), patterns would need to be re-selected using the union of all
symbol priorities and then re-normalized using the union of all normalizers, an expensive operation we want to avoid.
Instead, we use a single global SymbolPriorities set shared across all grind attributes.
See also: the related note in Extension.lean regarding normalization.
Equations
Instances For
Equations
Removes the given declaration from s.
Equations
Instances For
Sets declName priority to be used during E-matching pattern inference
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Set of E-matching theorems.
Equations
Instances For
A collection of sets of E-matching theorems.
Equations
Instances For
Returns true if there is a theorem with exactly the same pattern and constraints is already in s
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Auxiliary function to expand a pattern containing forbidden application symbols into a multi-pattern.
This function enhances the usability of the [grind =] attribute by automatically handling
forbidden pattern symbols. For example, consider the following theorem tagged with this attribute:
getLast?_eq_some_iff {xs : List α} {a : α} : xs.getLast? = some a ↔ ∃ ys, xs = ys ++ [a]
Here, the selected pattern is xs.getLast? = some a, but Eq is a forbidden pattern symbol.
Instead of producing an error, this function converts the pattern into a multi-pattern,
allowing the attribute to be used conveniently.
The function recursively expands patterns with forbidden symbols by splitting them into their sub-components. If the pattern does not contain forbidden symbols, it is returned as-is.
- symbolSet : Std.HashSet HeadIndex
- bvarsFound : Std.HashSet Nat
Instances For
- relevant : PatternArgKind
Argument is relevant for E-matching.
- instImplicit : PatternArgKind
Instance implicit arguments are considered support and handled using
isDefEq. - proof : PatternArgKind
Proofs are ignored during E-matching. Lean is proof irrelevant.
- typeFormer : PatternArgKind
Types and type formers are mostly ignored during E-matching, and processed using
isDefEq. However, if the argument is of the formC ..whereCis inductive type we process it as part of the pattern. Suppose we haveas bs : List α, and a pattern candidate expressionas ++ bs, i.e.,@HAppend.hAppend (List α) (List α) (List α) inst as bs. If we completely ignore the types, the pattern will just be@HAppend.hAppend _ _ _ _ #1 #0This is not ideal because the E-matcher will try it in any goal that contains
++, even if it does not even mention lists.
Instances For
Equations
Instances For
Equations
Equations
Instances For
Returns an array kinds s.ts kinds[i] is the kind of the corresponding argument.
- a type (that is not a proposition) or type former (which has forward dependencies) or
- a proof, or
- an instance implicit argument
When kinds[i].isSupport is true, we say the corresponding argument is a "support" argument.
Equations
Instances For
Equations
Instances For
Auxiliary type for the checkCoverage function.
- ok : CheckCoverageResult
checkCoveragesucceeded - missing
(pos : List Nat)
: CheckCoverageResult
checkCoveragefailed because some of the theorem parameters are missing,poscontains their positions
Instances For
Creates an E-matching theorem for a theorem with proof proof, numParams parameters, and the given set of patterns.
Pattern variables are represented using de Bruijn indices.
Equations
Instances For
Creates an E-matching theorem for declName with numParams parameters, and the given set of patterns.
Pattern variables are represented using de Bruijn indices.
Equations
Instances For
Given a theorem with proof proof and type of the form ∀ (a_1 ... a_n), lhs = rhs,
creates an E-matching pattern for it using addEMatchTheorem n [lhs]
If normalizePattern is true, it applies the grind simplification theorems and simprocs to the pattern.
Equations
Instances For
Equations
Instances For
Returns the scoped E-matching theorems declared in the given namespace.
Equations
Instances For
Given theorem with name declName and type of the form ∀ (a_1 ... a_n), lhs = rhs,
creates an E-matching pattern for it using addEMatchTheorem n [lhs]
If normalizePattern is true, it applies the grind simplification theorems and simprocs to the
pattern.
Equations
Instances For
Adds an E-matching theorem to the environment.
See mkEMatchTheorem.
Equations
Instances For
Adds an E-matching equality theorem to the environment.
See mkEMatchEqTheorem.
Equations
Instances For
Collects all singleton patterns in the type of the given proof.
We use this function to implement local forall expressions in a grind goal.
Equations
Instances For
Creates an E-match theorem using the given proof and kind.
If groundPatterns is true, it accepts patterns without pattern variables. This is useful for
theorems such as theorem evenZ : Even 0. For local theorems, we use groundPatterns := false
since the theorem is already in the grind state and there is nothing to be instantiated.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Helper type for generating suggestions for grind parameters
- yes : MinIndexableMode
minIndexable := true - no : MinIndexableMode
minIndexable := false - both : MinIndexableMode
Tries with and without the minimal indexable subexpression condition, if both produce the same pattern, use the one
minIndexable := falsesince it is more compact.
Instances For
Tries different modifiers, logs info messages with modifiers that worked, but returns just the first one that worked.
Equations
Instances For
Tries different modifiers, logs info messages with modifiers that worked, but stores just the first one that worked.
Remark: if backward.grind.inferPattern is true, then .default false is used.
The parameter showInfo is only taken into account when backward.grind.inferPattern is true.