We use this auxiliary constant to mark delayed congruence proofs.
Equations
- Lean.Meta.Grind.congrPlaceholderProof = Lean.mkConst (Lean.Name.mkSimple "[congruence]")
Instances For
We use this auxiliary constant to mark delayed symmetric congruence proofs.
Example: a = b is symmetrically congruent to c = d if a = d and b = c.
Note: We previously used congrPlaceholderProof for this case, but it
caused non-termination during proof term construction when a = b = c = d.
The issue was that we did not have enough information to determine how
a = b and c = d became congruent. The new marker resolves this issue.
If congrPlaceholderProof is used, then a = b became congruent to c = d
because a = c and b = d.
If eqCongrSymmPlaceholderProof is used, then it was because a = d and b = c.
Example: suppose we have the following equivalence class:
{p, q, p = q, q = p, True}
Recall that True is always the root of its equivalence class.
Assume we also have the following two paths in the class:
1. p -> p = q -> q = p -> True
2. q -> True
Now suppose we try to build a proof for p = True.
We must construct a proof for (p = q) = (q = p).
These equalities are congruent, but if we try to prove p = q and q = p
using the facts p = True and q = True, we end up trying to prove p = True again.
In other words, we are missing the information that p = q became congruent to q = p
because of the symmetric case. By using eqCongrSymmPlaceholderProof, we retain this information.
Equations
- Lean.Meta.Grind.eqCongrSymmPlaceholderProof = Lean.mkConst (Lean.Name.mkSimple "[eq_congr_symm]")
Instances For
Literal applications that internalize handles specially.
- notLit : LitKind
- nonParametric : LitKind
- ofNatFinBitVec : LitKind
An
OfNat.ofNatliteral of typeBitVec _orFin _.
Instances For
Classifies the application e. For example, BitVec and Fin are parametric literals, but Nat is not.
The types of nonparametric literals are reduced using whnfD, but BitVec and Fin must occur syntactically.
The type of a negative literal -n must also occur syntactically because internalize does not visit n:
the ring normalizer, used for Int, Int8, Int16, Int32, and Int64, treats -n as a constant, but
linarith reifies -n : α for def α := Int as the negation of the variable n.
internalize does not add literal applications to the congruence table.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if e is True, False, or a literal value.
See Lean.Meta.LitValues for supported literals.
grind assumes distinct interpreted terms denote distinct values, so a literal is interpreted
only if it is in normal form, and in particular its type must be structurally a supported
builtin type, with a numeral parameter for Fin/BitVec.
LitValues recognizes literals up to whnfD on their types, e.g.
(1 : BitVec w) for def w := 32, but the canonicalizer does not unfold w, and
(1 : BitVec w) and (1 : BitVec 32) would be distinct interpreted terms denoting the same value.
The type of a literal is read from e itself. For negated literals, both the outer and inner
types must be the same normal type. Rat, Float, and Float32 literals are never interpreted.
A literal of a signed fixed-width type is interpreted only in the form produced by its ToExpr
instance, i.e., when it is in range: the canonicalizer reduces OfNat numerals modulo 2^w, but
(200 : Int8) and (-56 : Int8) still denote the same value, as do -0 and 0.
Assumes e has no assigned metavariables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The following options deliberately break the suggestions produced by grind?. They are for
debugging and testing only, e.g., for testing that grind? reports suggestions that fail.
Opaque solver extension state.
Case-split source. That is, where it came from.
We store the current source in the grind context.
- ematch (origin : Origin) : SplitSource
Generated while instantiating a theorem using E-matching.
- ext (declName : Name) : SplitSource
Generated while instantiating an extensionality theorem with name
declName - mbtc (a b : Expr) (i : Nat) : SplitSource
Model-based theory combination equality coming from the i-th argument of applications
aandb - beta (e : Expr) : SplitSource
Beta-reduction.
- forallProp (e : Expr) : SplitSource
Forall-propagator.
- existsProp (e : Expr) : SplitSource
Exists-propagator.
- input : SplitSource
Input goal
- inj (origin : Origin) : SplitSource
Injectivity theorem.
- guard (origin : Origin) : SplitSource
grind_patternguard
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
- (Lean.Meta.Grind.SplitSource.ematch origin).toMessageData = Lean.toMessageData "E-matching `" ++ Lean.toMessageData origin.pp ++ Lean.toMessageData "`"
- (Lean.Meta.Grind.SplitSource.guard origin).toMessageData = Lean.toMessageData "Theorem instantiation guard for `" ++ Lean.toMessageData origin.pp ++ Lean.toMessageData "`"
- (Lean.Meta.Grind.SplitSource.ext declName).toMessageData = Lean.toMessageData "Extensionality `" ++ Lean.toMessageData declName ++ Lean.toMessageData "`"
- (Lean.Meta.Grind.SplitSource.beta e).toMessageData = Lean.toMessageData "Beta-reduction of" ++ Lean.toMessageData (Lean.indentExpr e)
- (Lean.Meta.Grind.SplitSource.forallProp e).toMessageData = Lean.toMessageData "Forall propagation at" ++ Lean.toMessageData (Lean.indentExpr e)
- (Lean.Meta.Grind.SplitSource.existsProp e).toMessageData = Lean.toMessageData "Exists propagation at" ++ Lean.toMessageData (Lean.indentExpr e)
- Lean.Meta.Grind.SplitSource.input.toMessageData = (Lean.MessageData.ofFormat ∘ Std.format) "Initial goal"
- (Lean.Meta.Grind.SplitSource.inj origin).toMessageData = Lean.toMessageData "Injectivity `" ++ Lean.toMessageData origin.pp ++ Lean.toMessageData "`"
Instances For
Auxiliary type used to implement grind.ematch.instance.
- ematch (origin : Origin) (inst : Expr) : EMatchDiagSource
- other : EMatchDiagSource
Instances For
Context for GrindM monad.
- simp : Simp.Context
- simpMethods : Simp.Methods
- symSimpMethods : Sym.Simp.Methods
Methods of the
Sym.simp-based normalizer. Unused whenbackward.grind.normalizeris set. - symDSimpMethods : Sym.DSimp.Methods
Methods of the
Sym.dsimp-based normalizer. Unused whenbackward.grind.normalizeris set. - config : Grind.Config
- identity : Name
Name of the tactic running
grind, e.g.,liaorgrind_order. Each tactic sets it at startup. Ids of the solver extensions that
configenables, seeSolverExtension.enabled.If
anchorRefs? := some anchorRefs, then only local instances and case-splits inanchorRefsare considered.- anchors : Bool
anchors := trueif anchors may be observed in this run: when generating tactic scripts, restricting the search usinganchorRefs?, or in interactive mode. Otherwise,getAnchorreturns0and local variable anchors are not assigned. It must not change during a run, since local variable anchors are assigned when the variables are introduced. - cheapCases : Bool
If
cheapCasesistrue,grindonly appliescasesto types that contain at most one minor premise. Recall thatgrindappliescaseswhen introducing types tagged with[grind cases eager], and atSplit.leanRemark: We add this option to implement thelookaheadfeature, we don't want to create several subgoals when performing lookahead. - reportMVarIssue : Bool
- splitSource : SplitSource
Current source of case-splits.
- ematchDiagSource : EMatchDiagSource
Current source of tracking E-matching theorem instantiation (see
grind.ematch.instances). - symPrios : SymbolPriorities
Symbol priorities for inferring E-matching patterns
- extensions : ExtensionStateArray
- debug : Bool
- ematchDiag : Bool
Instances For
Key for the congruence theorem cache.
Instances For
Equations
- Lean.Meta.Grind.instBEqCongrTheoremCacheKey = { beq := fun (a b : Lean.Meta.Grind.CongrTheoremCacheKey) => Lean.Meta.Sym.isSameExpr a.f b.f && a.numArgs == b.numArgs }
Equations
- Lean.Meta.Grind.instHashableCongrTheoremCacheKey = { hash := fun (a : Lean.Meta.Grind.CongrTheoremCacheKey) => mixHash (Lean.Meta.Sym.hashPtrExpr a.f) (hash a.numArgs) }
Number of times E-match theorem has been instantiated.
User names for theorem origins that are
.fvars. We need to store this information because subgoals are created while we are solving subgoals.Number of times a
caseshas been performed on an inductive type/predicateNumber of applications per function symbol. This information is only collected if
set_option diagnostics true
Instances For
Equations
Case-split diagnostic information
- lctx : LocalContext
- c : Expr
- gen : Nat
- numCases : Nat
- splitSource : SplitSource
Instances For
A node in the E-matching diagnostics hyper-graph.
Instances For
Equations
Instances For
Equations
Instances For
An entry {thm_1, ..., thm_n} => {thm}. Each thm_i and thm is the proof of a theorem instance.
It means terms created while instantiating thm_i were used to create theorem thm.
- lctx : LocalContext
- sources : List EMatchDiagNode
- target : EMatchDiagNode
Instances For
A declaration hoisted to the goal of a case split, see hoistDecl: the proof of a fact, or a value
such as the variable context of a solver. The subgoals of the split refer to it using fvarId, and
mkHoistedDecls declares it in the proof of the split.
- fvarId : FVarId
- name : Name
Binder name of the declaration.
- type : Expr
nonewhile the value is postponed, seereserveHoistedDecl.- nondep : Bool
falsefor aletwhose value must be visible to the kernel, e.g., the variable context of a solver.
Instances For
Identifies a hoisted declaration, so that it is created only once and shared by all subgoals of a
case split, see hoistDecl.
- ptr (obj : Sym.ObjectPtr) : HoistKey
A solver object, compared by address. The subgoals of a case split share the objects created before it, so they also share the declaration associated with the object.
- ctx (atoms : Array Expr) : HoistKey
The variable context of a solver with the given atoms, e.g., a cutsat
RArray. Proofs that use equal contexts share oneletdeclaration, which keeps the kernel from checking copies of it.
Instances For
Equations
Instances For
Equations
Equations
Instances For
Equations
The declarations hoisted to the goal of a case split in progress, see Action.splitCore.
They are shared by all subgoals of the split, and declared in the order front.reverse ++ decls.
- front : Array HoistedDecl
Declarations added at the front, see
hoistDecl. The last one is declared first. - decls : Array HoistedDecl
Declarations in creation order.
- keys : Std.HashMap HoistKey FVarId
Instances For
Summary of the instantiation of a proof, see getProofInfo: its free variables, and whether it
contains a synthetic sorry.
- fvars : FVarIdSet
- hasSorry : Bool
- hasUnassigned : Bool
Whether the proof contains an unassigned metavariable of
grind's depth, e.g., the goal of a subgoal that is still open. Assigning it may change the summary.
Instances For
Equations
State for the GrindM monad.
- congrThms : PHashMap CongrTheoremCacheKey CongrTheorem
Congruence theorems generated so far. Recall that for constant symbols we rely on the reserved name feature (i.e.,
mkHCongrWithArityForConst?). Remark: we currently do not reuse congruence theorems - simp : Simp.State
- symSimp : Sym.Simp.State
State (cache) of the
Sym.simp-based normalizer. - symDSimp : Sym.DSimp.State
State (cache) of the
Sym.dsimp-based normalizer. - lastTag : Name
Used to generate trace messages of the for
[grind] working on <tag>, and implement the macrotrace_goal. - counters : Counters
Performance counters
- splitDiags : PArray SplitDiagInfo
Split diagnostic information. This information is only collected when
set_option diagnostics true - ematchDiags : PArray EMatchDiagInfo
E-matching theorem instantiation diagnostics
Cached anchors (aka stable hash codes) for terms in the
grindstate.Anchors of the local variables introduced by
grind. They are based on how each variable was introduced instead of its name or position. SeeregisterFVarAnchor.- instanceMap : Std.HashMap Name EMatchTheorem
Accumulated E-matching instance map for precise unused lemma tracking. Only populated when
config.markInstancesistrue. - hoistedDecls : Std.HashMap MVarId HoistedDecls
Declarations hoisted to the case splits in progress, indexed by the metavariable of the goal being split.
- proofInfos : Std.HashMap MVarId (Expr × ProofInfo)
Cache for
getProofInfo: maps a metavariable to its assignment and the summary of the assignment's instantiation. An entry is only valid while the metavariable is assigned to the same expression. - numBranches : Nat
Number of branches created by the case-splits performed so far, including the cases that have not been explored yet, but not the ones skipped by non-chronological backtracking. See
Grind.Config.branchesandAction.splitCore.
Instances For
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.mapGrindM f x = controlAt Lean.Meta.Grind.GrindM fun (runInBase : {β : Type} → m β → Lean.Meta.Grind.GrindM (stM Lean.Meta.Grind.GrindM m β)) => f (runInBase x)
Instances For
Returns true if grind.debug is set
Equations
- Lean.Meta.Grind.isDebugEnabled = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.debug
Instances For
Returns true if grind.ematch.diagnostics is set
Equations
- Lean.Meta.Grind.isEmatchDiagEnabled = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.ematchDiag
Instances For
Equations
- Lean.Meta.Grind.saveState = do let __do_lift ← liftM Lean.Meta.saveState let __do_lift_1 ← get pure { «meta» := __do_lift, grind := __do_lift_1 }
Instances For
Equations
- Lean.Meta.Grind.instMonadBacktrackSavedStateGrindM = { saveState := Lean.Meta.Grind.saveState, restoreState := fun (s : Lean.Meta.Grind.SavedState) => s.restore }
withoutReportingMVarIssues x executes x without reporting metavariables found during internalization.
See comment at Grind.Context.reportMVarIssue for additional details.
Equations
- One or more equations did not get rendered due to their size.
Instances For
withSplitSource s x executes x and uses s as the split source for any case-split
registered.
Equations
- One or more equations did not get rendered due to their size.
Instances For
withEmatchDiagSource s x executes x and uses s as the E-matching diagnostics source for any
term created.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the user-defined configuration options
Equations
- Lean.Meta.Grind.getConfig = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.config
Instances For
Returns the name of the tactic running grind. See Context.identity.
Equations
- Lean.Meta.Grind.getIdentity = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.identity
Instances For
Returns extension states associate with grind attributes in use
Equations
- Lean.Meta.Grind.getExtensions = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.extensions
Instances For
Runs k with the transparency setting specified by Config.reducible.
Uses reducible transparency if reducible is true, otherwise default transparency.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the anchor references (if any) being used to restrict the search.
Equations
- Lean.Meta.Grind.getAnchorRefs = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.anchorRefs?
Instances For
See Context.anchors.
Equations
- Lean.Meta.Grind.anchorsEnabled = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.anchors
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.cheapCasesOnly = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.cheapCases
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.reportMVarInternalization = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.reportMVarIssue
Instances For
Returns symbol priorities for inferring E-matching patterns.
Equations
- Lean.Meta.Grind.getSymbolPriorities = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.symPrios
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if declName is the name of a match equation or a match congruence equation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.getEMatchTheoremNumInstances thm = do let __do_lift ← get pure ((Lean.PersistentHashMap.find? __do_lift.counters.thm thm.origin).getD 0)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Returns maximum term generation that is considered during ematching.
Equations
- Lean.Meta.Grind.getMaxGeneration = do let __do_lift ← Lean.Meta.Grind.getConfig pure __do_lift.gen
Instances For
Abstracts nested proofs in e. This is a preprocessing step performed before internalization.
Equations
Instances For
Each E-node may have "solver terms" attached to them.
Each term is an element of the equivalence class that the
solver cares about. Each solver is responsible for marking the terms they care about.
The grind core propagates equalities and disequalities to the theory solvers
using these "marked" terms. The root of the equivalence class
contains a list of representatives sorted by solver id. Note that many E-nodes
do not have any solver terms attached to them.
A solver has one representative per type in the equivalence class. A class contains
terms of different types (e.g., Fin n and Fin m) only if it was merged via HEq
(see ENode.heqProofs). Thus, the solvers are only notified about equalities and
disequalities between terms of the same type.
"Solver terms" are referenced as "theory variables" in the SMT literature. The SMT solver Z3 uses a similar representation.
- nil : SolverTerms
- next (solverId : Nat) (e : Expr) (rest : SolverTerms) : SolverTerms
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stores information for a node in the E-graph.
Each internalized expression e has an ENode associated with it.
- self : Expr
Node represented by this ENode.
- next : Expr
Next element in the equivalence class.
- root : Expr
Root (aka canonical representative) of the equivalence class
- congr : Expr
- flipped : Bool
Proof has been flipped.
- size : Nat
Number of elements in the equivalence class, this field is meaningless if node is not the root.
- interpreted : Bool
interpreted := trueif node should be viewed as an abstract value. - ctor : Bool
ctor := trueif the head symbol is a constructor application. - hasLambdas : Bool
hasLambdas := trueif the equivalence class contains lambda expressions. - heqProofs : Bool
If
heqProofs := true, then some proofs in the equivalence class are based on heterogeneous equality. - idx : Nat
Unique index used for pretty printing and debugging purposes.
- generation : Nat
The generation in which this enode was created.
- mt : Nat
Modification time
- sTerms : SolverTerms
Solver terms attached to this E-node.
- funCC : Bool
- ematchDiagSource : EMatchDiagSource
Auxiliary field used to implement
grind.ematch.diagnostics
Instances For
Equations
Equations
- n.isRoot = Lean.Meta.Sym.isSameExpr n.self n.root
Instances For
Equations
Instances For
Work queued for processToDo: equalities and facts to assert, and terms to propagate.
- eq (lhs rhs proof : Expr) (isHEq : Bool) : ToProcessElement
- fact (prop proof : Expr) (generation : Nat) : ToProcessElement
- propagateUp (e : Expr) : ToProcessElement
Run the upward propagators of
e. Internalization queues this instead of propagating eagerly: a propagator may internalize terms, and must not do so while the arguments of an enclosing application are still being internalized. - internalizeRhsAddEq (lhs rhs proof : Expr) (generation : Nat) : ToProcessElement
Internalize only
rhs(lhsmust already be internalized), and then addlhs = rhs. Internalization queues this whenrhsmay contain an application whose arguments are still being internalized. - solverEq (solverId : Nat) (lhs rhs : Expr) : ToProcessElement
Run the
newEqcallback of the solversolverIdon its termslhsandrhs.SolverExtension.markTermqueues this instead of running the callback eagerly.markTermruns inside theinternalizehook of a solver, that is, while the enclosing applications of the term being internalized may still have unvisited arguments. The callback may internalize new terms containing such an application. SeeGoalState.internalizing. - solverDiseq (solverId : Nat) (lhs rhs : Expr) : ToProcessElement
Instances For
Instances For
Equations
Key for the congruence table.
We need access to the enodes to be able to retrieve the equivalence class roots.
- e : Expr
Instances For
Note: congrHash and isCongruent must satisfy the BEq/Hashable invariant for
PHashSet: if isCongruent e₁ e₂ returns true, then congrHash e₁ == congrHash e₂.
When funCC = true, congrHash hashes only the immediate function and argument:
mixHash (hashRoot f) (hashRoot a). When funCC = false, it recursively decomposes all
application layers. These produce fundamentally different hash values, so isCongruent must
require matching funCC flags. Here is the scenario that leads to a nondeterministic crash
if mismatched flags are allowed:
e₁(withfunCC = true) is inserted into the congruence table.e₂(withfunCC = false) is inserted. Its hash is computed using the non-funCCpath.- Because
hashRootuses pointer addresses (ptrAddrUnsafe), the two different hash computations can accidentally collide, placinge₂in the same bucket ase₁. isCongruent e₁ e₂is called. If it used onlye₁'sfunCCflag (the old behavior), thefunCCcomparison path could declare them congruent even when they have different numbers of top-level arguments.addCongrTablecallspushEqHEq e₂ e₁ congrPlaceholderProof, wheree₂is the new node withfunCC = false.- During proof reconstruction,
mkCongrProof e₂ e₁checksuseFunCC e₂ = false, enters the standard (non-funCC) proof path, and hitsassert! rhs.getAppNumArgs == numArgsbecausee₁ande₂have different argument counts.
This was observed as a nondeterministic crash in Mathlib (e.g., at Analysis/ODE/PicardLindelof.lean).
Equations
- Lean.Meta.Grind.instHashableCongrKey = { hash := fun (k : Lean.Meta.Grind.CongrKey enodeMap) => Lean.Meta.Grind.instHashableCongrKey._private_1 k }
Equations
- Lean.Meta.Grind.instBEqCongrKey = { beq := fun (k1 k2 : Lean.Meta.Grind.CongrKey enodeMap) => Lean.Meta.Grind.instBEqCongrKey._private_1 k1 k2 }
Equations
- Lean.Meta.Grind.CongrTable enodeMap = Lean.PHashSet (Lean.Meta.Grind.CongrKey enodeMap)
Instances For
Equations
Instances For
The E-matching module instantiates theorems using the EMatchTheorem proof and a (partial) assignment.
We want to avoid instantiating the same theorem with the same assignment more than once.
Therefore, we store the (pre-)instance information in set.
Recall that the proofs of activated theorems have been hash-consed.
The assignment contains internalized expressions, which have also been hash-consed.
Note: We used to use pointer equality to implement PreInstanceSet. However,
this low-level trick was incorrect in interactive mode because we add new
EMatchTheorem objects using instantiate [...]. For example, suppose we write
instantiate [thm_1]; instantiate [thm_1]
The EMatchTheorem object thm_1 is created twice. Using pointer equality will
miss instances created using the two different objects. Recall we do not use
hash-consing on proof objects. If we hash-cons the proof objects, it would be ok
to use pointer equality.
- proof : Expr
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Instances For
New raw fact to be preprocessed, and then asserted.
- proof : Expr
- prop : Expr
- generation : Nat
- splitSource : SplitSource
splitSourceto use when internalizing this fact. - ematchDiagSource : EMatchDiagSource
`ematch
Instances For
Equations
Equations
Equations
Instances For
Equations
Instances For
Equations
Equations
A delayed theorem instantiation is an instantiation that includes one or more guards.
See TheoremGuard.
- thm : EMatchTheorem
- proof : Expr
- prop : Expr
- generation : Nat
- guards : List TheoremGuard
- sources : List EMatchDiagNode
Sources for
grind.ematch.diagnosticsthat generated this instance.
Instances For
E-matching related fields for the grind goal.
- thmMap : EMatchTheoremsArray
Inactive global theorems. As we internalize terms, we activate theorems as we find their symbols. Local theorem provided by users are added directly into
newThms. - gmt : Nat
Goal modification time.
- thms : PArray EMatchTheorem
Active theorems that we have performed ematching at least once.
- newThms : PArray EMatchTheorem
Active theorems that we have not performed any round of ematching yet.
- numInstances : Nat
Number of theorem instances generated so far.
- numDelayedInstances : Nat
Number of delayed theorem instances generated so far. We track them to decide whether E-match made progress or not.
- num : Nat
Number of E-matching rounds performed in this goal since the last case-split.
- preInstances : PreInstanceSet
(pre-)instances found so far. It includes instances that failed to be instantiated.
- nextThmIdx : Nat
Next local E-match theorem idx.
matchauxiliary functions whose equations have already been created and activated.- delayedThmInsts : PHashMap ExprPtr (List DelayedTheoremInstance)
Delayed instantiations is a mapping from guards to theorems that are waiting them to become
True.
Instances For
Equations
Case-split information.
- default (e : Expr) (source : SplitSource) : SplitInfo
Term
emay be an inductive predicate,match-expression,if-expression, implication, etc. - imp (e : Expr) (h : e.isForall = true) (source : SplitSource) : SplitInfo
eis an implication and we want to split on its antecedent. - arg (a b : Expr) (i : Nat) (eq : Expr) (source : SplitSource) : SplitInfo
Given applications
aandb, case-split on whether the correspondingi-th arguments are equal or not. The split is only performed if all other arguments are already known to be equal or are also tagged as split candidates.
Instances For
Equations
Equations
- (Lean.Meta.Grind.SplitInfo.default e source).hash = hash e
- (Lean.Meta.Grind.SplitInfo.imp e h source).hash = hash e
- (Lean.Meta.Grind.SplitInfo.arg a b i e source).hash = hash e
Instances For
Equations
Equations
- (Lean.Meta.Grind.SplitInfo.default e₁ source).beq (Lean.Meta.Grind.SplitInfo.default e₂ source_1) = (e₁ == e₂)
- (Lean.Meta.Grind.SplitInfo.imp e₁ h source).beq (Lean.Meta.Grind.SplitInfo.imp e₂ h_1 source_1) = (e₁ == e₂)
- (Lean.Meta.Grind.SplitInfo.arg a₁ b₁ i₁ eq₁ source).beq (Lean.Meta.Grind.SplitInfo.arg a₂ b₂ i₂ eq₂ source_1) = (a₁ == a₂ && b₁ == b₂ && i₁ == i₂ && eq₁ == eq₂)
- x✝¹.beq x✝ = false
Instances For
Equations
Equations
- (Lean.Meta.Grind.SplitInfo.default e source).getExpr = e
- (Lean.Meta.Grind.SplitInfo.imp e h source).getExpr = e.forallDomain h
- (Lean.Meta.Grind.SplitInfo.arg a b i e source).getExpr = e
Instances For
Equations
- (Lean.Meta.Grind.SplitInfo.default e source).source = source
- (Lean.Meta.Grind.SplitInfo.imp e h source).source = source
- (Lean.Meta.Grind.SplitInfo.arg a b i e source).source = source
Instances For
Equations
- (Lean.Meta.Grind.SplitInfo.default e₁ source).lt (Lean.Meta.Grind.SplitInfo.default e₂ source_1) = e₁.lt e₂
- (Lean.Meta.Grind.SplitInfo.imp e₁ h source).lt (Lean.Meta.Grind.SplitInfo.imp e₂ h_1 source_1) = e₁.lt e₂
- (Lean.Meta.Grind.SplitInfo.arg a b i e₁ source).lt (Lean.Meta.Grind.SplitInfo.arg a_1 b_1 i_1 e₂ source_1) = e₁.lt e₂
- (Lean.Meta.Grind.SplitInfo.default e source).lt x✝ = true
- (Lean.Meta.Grind.SplitInfo.imp e h source).lt x✝ = true
- x✝¹.lt x✝ = false
Instances For
Case splitting related fields for the grind goal.
Case-split candidates.
- added : Std.HashSet SplitInfo
Case-splits that have been inserted at
candidatesat some point. Case-splits that have already been performed, or that do not have to be performed anymore.
Sequence of cases steps that generated this goal. We only use this information for diagnostics.
Lookahead "case-splits".
A mapping
(a, b) ↦ iss.t. for eachSplitInfo.arg a b i eqincandidatesorlookaheadswe havei ∈ is. We use this information to decide whether the split/lookahead is "ready" to be tried or not.
Instances For
Equations
Equations
Equations
State for injective theorem support.
- thms : InjectiveTheoremsArray
- fns : PHashMap ExprPtr InjectiveInfo
Instances For
The grind state for a goal, excluding the metavariable.
This separation from Goal allows multiple goals with different metavariables to share
the same GoalState. This is useful for automation such as symbolic simulation, where applying
theorems create multiple goals that inherit the same E-graph, congruence closure state, and other
accumulated facts.
- nextDeclIdx : Nat
Next local declaration index to process.
- enodeMap : ENodeMap
- parents : ParentMap
- congrTable : CongrTable self.enodeMap
A mapping from each function application index (
HeadIndex) to a list of applications with that index. Recall that theHeadIndexfor a constant is its constant name, and for a free variable, it is its unique id.- toProcess : Array ToProcessElement
Pending work for
processToDo: equalities, facts, upward propagations, and solver callbacks. Applications whose
ENodeexists but whose arguments are still being visited, outermost first. Maintained only whenisDebugEnabledholds, and empty whenever no internalization is in progress. The internalizer uses it to check that solver code never internalizes one of these applications; see the section on re-entrant internalization inLean.Meta.Tactic.Grind.Internalize.- inconsistent : Bool
inconsistent := trueifENodes forTrueandFalseare in the same equivalence class. - nextIdx : Nat
Next unique index for creating ENodes
- newRawFacts : Std.Queue NewRawFact
new facts to be preprocessed and then asserted.
Asserted facts
- extThms : PHashMap ExprPtr (Array Ext.ExtTheorem)
Cached extensionality theorems for types.
- ematch : EMatch.State
State of the E-matching module.
- inj : Injective.State
State of the injective function procedure.
- split : Split.State
State of the case-splitting module.
- clean : Clean.State
State of the clean name generator.
- sstates : Array SolverExtensionState
Solver states.
Goals of the enclosing case splits in progress, outermost first. Its size is the split depth of the goal. See
hoistDecl. Remark: each case split copies the array when pushing its goal, but the split depth is small, and hoisting needs constant-time access by depth.- introBase : UInt64
Provenance of the local variables introduced next: the
numIntros-th one gets anchormixHash introBase (hash numIntros). Steps that introduce variables, such as case-splits, reset it. SeeregisterFVarAnchor. - numIntros : Nat
Instances For
Equations
A grind goal, combining shared state with a specific metavariable.
See GoalState for details on why the state is factored out.
Note: The Goal internal representation is just a pair GoalState and MVarId.
- congrTable : CongrTable self.enodeMap
- mvarId : MVarId
Instances For
Equations
Equations
- g.hasSameRoot a b = Lean.Meta.Grind.hasSameRoot✝ g.enodeMap a b
Instances For
Equations
- g.isCongruent a b = Lean.Meta.Grind.isCongruent✝ g.enodeMap a b
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.GoalM.run goal x = goal.mvarId.withContext (Lean.Meta.Grind.GoalM.runCore goal x)
Instances For
Equations
- Lean.Meta.Grind.GoalM.run' goal x = goal.mvarId.withContext ((x *> get).run' goal)
Instances For
Returns the number of enclosing case splits.
Instances For
Returns the goal at split depth depth: the goal of the enclosing case split at depth, or the current
goal if depth is its split depth.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the free variable of the declaration registered for key in the goal of the enclosing case
split at depth, if any.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the free variable of the declaration name : type := value hoisted to the goal of the enclosing
case split at depth. value is only executed if no declaration has been registered for key yet,
and it must be valid in that goal.
As with local declarations, hoisted declarations must be created in the right order: the value of a
declaration may only use declarations created before it. If front := true, the declaration is
added before the existing ones, and its value may only use declarations of enclosing case splits.
This is useful for values that are known only after the declarations that use them are created,
e.g., the variable context of a solver.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Similar to hoistDecl, but postpones the value. Returns the free variable of a new declaration of type
type hoisted to the goal of the enclosing case split at depth, and its index in HoistedDecls.decls.
No declaration may be registered for key yet (see findHoistedDecl?). The value must be provided with
setHoistedDeclValue before the case split completes, and it may only use declarations created before
this one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sets the value of the postponed declaration at index idx of HoistedDecls.decls in the goal of the
enclosing case split at depth, see reserveHoistedDecl.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the declarations hoisted to goal, see withHoistedDecls.
Equations
- Lean.Meta.Grind.getHoistedDecls goal = do let __do_lift ← get pure (__do_lift.hoistedDecls.getD goal.mvarId { })
Instances For
Similar to instantiateMVars, but also resolves the delayed assignments ?m #[xs] := ?pending
created inside the current withNewMCtxDepth block, which is entered by grind during its startup.
instantiateMVars only resolves a delayed assignment when ?pending's assignment val is ground
(no unassigned expression metavariables). This ground restriction exists because val may contain
metavariables that have xs in their scope. For example, if xs = #[x] and val = ?n + x where x
is in the scope of ?n, then mkLambda creates fun x => ?n + x. If ?n is later assigned to
f x, the term becomes ill-formed with a dangling free variable.
This scenario cannot occur here: in a grind proof, val only contains metavariables created
before withNewMCtxDepth, and they cannot contain free variables created by grind, so the
conversion is safe. Delayed assignments created before withNewMCtxDepth are left untouched,
as they are meant to be resolved by other tactics.
Returns a ProofInfo summary of e by following metavariable assignments without constructing
the instantiated expression. Collects free variables and synthetic sorry occurrences, and
reports whether the traversal encounters an unassigned metavariable at the current depth.
For an ordinary metavariable application ?m as, combines the summary of ?m's assignment,
if any, with the summaries of all arguments as, including arguments the assignment ignores.
For a delayed assignment ?d #[xs] := ?p, summarizes ?p's assignment, removes xs from its
free variables, and combines the result with the summaries of all arguments to ?d.
The local declarations of xs are not traversed, so dependencies in binder types that would
remain after resolving a partially applied delayed assignment are not included.
Unassigned metavariables contribute no free variables or synthetic sorry occurrences.
Only those at the current depth set hasUnassigned. During grind's protected
withNewMCtxDepth block, outer-depth metavariables cannot be assigned, and their local contexts
cannot contain free variables introduced by grind. Their eventual assignments may change
the summary after the protected computation ends.
Summaries of assigned metavariables with hasUnassigned = false are cached in State.proofInfos.
A cached summary is reused only while the metavariable's assignment is the same expression.
This avoids repeatedly traversing shared assignments, such as proofs used by nested case splits.
Wraps e : type in let bindings for selected hoisted declarations. The proof may refer to
hoisted free variables, directly or through metavariable assignments, even when those variables
are absent from the current local context.
Declarations are ordered as decls.front.reverse ++ decls.decls. Using getProofInfo, selects
declarations referenced by e and recursively by the values of selected declarations. Each value
may depend only on earlier declarations in this order. If the summary of e has hasUnassigned,
keeps all declarations; if the summary of a selected value has hasUnassigned, keeps all earlier
declarations, since later assignments may introduce dependencies on them.
Dependency selection does not inspect type or declaration types. Declaration types are copied
unchanged into the let bindings, so they must not refer to the hoisted free variables being bound.
Every selected declaration must have a value; otherwise, throws an internal error.
The body of the let bindings is an application of a fresh delayed-assigned metavariable whose
pending metavariable is assigned e. This postpones abstraction of the selected free variables
in e until the delayed assignment is resolved, without instantiating e here.
Returns e unchanged if no declarations are selected.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sets nextDeclIdx to point past the last local declaration in the local context.
This marks all existing local declarations as already processed by grind. Use this when
initializing a goal whose hypotheses should not be processed or after internalizing all of them.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if the goal has local declarations that have not yet been processed by grind.
A local declaration is "pending" if its index is greater than or equal to nextDeclIdx.
This is used to determine whether grind needs to internalize new hypotheses.
Equations
Instances For
Sets the provenance of the local variables introduced next in goal. See GoalState.introBase.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Assigns the anchor of a local variable just introduced in the current goal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Assigns the anchors of the local variables in the initial local context of a goal. Variables are
distinguished by their name and their rank among the variables with the same base name
(i.e., without macro scopes), e.g., a hidden x✝ or a shadowed x. Variables that already have
an anchor keep it, since goals may be created during a run (e.g., by vcgen).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Macro similar to trace[...], but it includes the trace message trace[grind] "working on <current goal>"
if the tag has changed since the last trace message.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A helper function used to mark a theorem instance found by the E-matching module.
It returns true if it is a new instance and false otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adds a new fact prop with proof proof to the queue for preprocessing and the assertion.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the number of theorem instances generated so far.
Equations
- Lean.Meta.Grind.getNumTheoremInstances = do let __do_lift ← get pure __do_lift.ematch.numInstances
Instances For
Returns true if the maximum number of instances has been reached.
Equations
- Lean.Meta.Grind.checkMaxInstancesExceeded = do let __do_lift ← get let __do_lift_1 ← liftM Lean.Meta.Grind.getConfig pure (decide (__do_lift.ematch.numInstances ≥ __do_lift_1.instances))
Instances For
Returns true if the maximum number of branches has been reached.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if the maximum number of E-matching rounds has been reached.
Equations
Instances For
Equations
- Lean.Meta.Grind.throwNonInternalizedExpr e = Lean.throwError (Lean.toMessageData "internal `grind` error, term has not been internalized" ++ Lean.toMessageData (Lean.indentExpr e))
Instances For
Equations
- goal.getGeneration e = match goal.getENode? e with | some n => n.generation | x => 0
Instances For
Equations
- Lean.Meta.Grind.SplitInfo.getGenerationCore goal (Lean.Meta.Grind.SplitInfo.default e source) = goal.getGeneration e
- Lean.Meta.Grind.SplitInfo.getGenerationCore goal (Lean.Meta.Grind.SplitInfo.imp e h source) = goal.getGeneration (e.forallDomain h)
- Lean.Meta.Grind.SplitInfo.getGenerationCore goal (Lean.Meta.Grind.SplitInfo.arg a b i e source) = max (goal.getGeneration a) (goal.getGeneration b)
Instances For
Equations
- s.getGeneration = do let __do_lift ← get pure (Lean.Meta.Grind.SplitInfo.getGenerationCore __do_lift s)
Instances For
Returns the generation of the given term. Is assumes it has been internalized
Equations
- Lean.Meta.Grind.getGeneration e = do let __do_lift ← get pure (__do_lift.getGeneration e)
Instances For
Returns true if e is in the equivalence class of True.
Equations
- Lean.Meta.Grind.isEqTrue e = do let __do_lift ← Lean.Meta.Grind.getENode e liftM (Lean.Meta.Sym.isTrueExpr __do_lift.root)
Instances For
Returns true if e is in the equivalence class of False.
Equations
- Lean.Meta.Grind.isEqFalse e = do let __do_lift ← Lean.Meta.Grind.getENode e liftM (Lean.Meta.Sym.isFalseExpr __do_lift.root)
Instances For
Returns true if e is in the equivalence class of Bool.true.
Equations
- Lean.Meta.Grind.isEqBoolTrue e = do let __do_lift ← Lean.Meta.Grind.getENode e let __do_lift_1 ← liftM Lean.Meta.Sym.getBoolTrueExpr pure (Lean.Meta.Sym.isSameExpr __do_lift.root __do_lift_1)
Instances For
Returns true if e is in the equivalence class of Bool.false.
Equations
- Lean.Meta.Grind.isEqBoolFalse e = do let __do_lift ← Lean.Meta.Grind.getENode e let __do_lift_1 ← liftM Lean.Meta.Sym.getBoolFalseExpr pure (Lean.Meta.Sym.isSameExpr __do_lift.root __do_lift_1)
Instances For
Returns true if a and b are in the same equivalence class.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if the root of its equivalence class.
Equations
- Lean.Meta.Grind.isRoot e = do let __x ← Lean.Meta.Grind.getENode? e match __x with | some n => pure (Lean.Meta.Sym.isSameExpr n.root e) | x => pure false
Instances For
Returns the root enode in the equivalence class of e.
Equations
- Lean.Meta.Grind.getRootENode e = do let __do_lift ← Lean.Meta.Grind.getRoot e Lean.Meta.Grind.getENode __do_lift
Instances For
Returns the root enode in the equivalence class of e if it is in an equivalence class.
Equations
- Lean.Meta.Grind.getRootENode? e = do let __x ← Lean.Meta.Grind.getENode? e match __x with | some n => Lean.Meta.Grind.getENode? n.root | x => pure none
Instances For
Returns true if the ENode associate with e has support for function equality
congruence closure. See Grind.Config.funCC for additional details.
Equations
- Lean.Meta.Grind.useFunCC e = do let __do_lift ← Lean.Meta.Grind.getENode e pure __do_lift.funCC
Instances For
Returns true if e has already been internalized.
Equations
- Lean.Meta.Grind.alreadyInternalized e = do let __do_lift ← get pure (Lean.PersistentHashMap.contains __do_lift.enodeMap { expr := e })
Instances For
Equations
- Lean.Meta.Grind.getTarget? e = do let __do_lift ← get pure (__do_lift.getTarget? e)
Instances For
Return true if a and b have the same type.
Equations
- Lean.Meta.Grind.hasSameType a b = do let __do_lift ← Lean.Meta.inferType a let __do_lift_1 ← Lean.Meta.inferType b Lean.Meta.isDefEqD __do_lift __do_lift_1
Instances For
Similar to hasSameType, but uses instances transparency. hasSameType may be exponential when
the types are equal only modulo the E-graph, e.g., Fin (a.set! i v).size and Fin a.size. Use
hasSameTypeI where a false answer is acceptable, e.g., using HEq, missing a congruence, or
not propagating an equality to a solver.
Equations
- Lean.Meta.Grind.hasSameTypeI a b = do let __do_lift ← Lean.Meta.inferType a let __do_lift_1 ← Lean.Meta.inferType b Lean.Meta.isDefEqI __do_lift __do_lift_1
Instances For
Pushes lhs = rhs if hasSameTypeI lhs rhs, and lhs ≍ rhs otherwise. If the types are
definitionally equal only with default transparency, we push lhs ≍ rhs. This is valid, but
marks the equivalence class with heqProofs: its proofs use HEq, E-matching visits all its terms,
and solvers only receive equalities between its terms whose types pass hasSameTypeI.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pushes lhs = rhs with proof to newEqs.
Equations
- Lean.Meta.Grind.pushEq lhs rhs proof = Lean.Meta.Grind.pushEqCore lhs rhs proof false
Instances For
Queues the upward propagation of e. See ToProcessElement.propagateUp.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Queues the internalization of rhs and the equality lhs = rhs. See ToProcessElement.internalizeRhsAddEq.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Queues the fact prop with the given proof, without preprocessing it. prop is internalized
when the fact is processed, so this is the way to assert a fact about a term that must not be
internalized yet. See GoalState.internalizing.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pushes lhs ≍ rhs with proof to newEqs.
Equations
- Lean.Meta.Grind.pushHEq lhs rhs proof = Lean.Meta.Grind.pushEqCore lhs rhs proof true
Instances For
Pushes a = True with proof to newEqs.
Equations
- Lean.Meta.Grind.pushEqTrue a proof = do let __do_lift ← liftM Lean.Meta.Sym.getTrueExpr Lean.Meta.Grind.pushEq a __do_lift proof
Instances For
Pushes a = False with proof to newEqs.
Equations
- Lean.Meta.Grind.pushEqFalse a proof = do let __do_lift ← liftM Lean.Meta.Sym.getFalseExpr Lean.Meta.Grind.pushEq a __do_lift proof
Instances For
Pushes a = Bool.true with proof to newEqs.
Equations
- Lean.Meta.Grind.pushEqBoolTrue a proof = do let __do_lift ← liftM Lean.Meta.Sym.getBoolTrueExpr Lean.Meta.Grind.pushEq a __do_lift proof
Instances For
Pushes a = Bool.false with proof to newEqs.
Equations
- Lean.Meta.Grind.pushEqBoolFalse a proof = do let __do_lift ← liftM Lean.Meta.Sym.getBoolFalseExpr Lean.Meta.Grind.pushEq a __do_lift proof
Instances For
Records that parent is a parent of child. This function actually stores the
information in the root (aka canonical representative) of child.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if type of t is definitionally equal to α
Equations
- Lean.Meta.Grind.hasType t α = do let __do_lift ← Lean.Meta.inferType t Lean.Meta.isDefEqD __do_lift α
Instances For
Returns true is e is the root of its congruence class.
Equations
- Lean.Meta.Grind.isCongrRoot e = do let __do_lift ← Lean.Meta.Grind.getENode e pure __do_lift.isCongrRoot
Instances For
Return true if the goal is inconsistent.
Equations
- Lean.Meta.Grind.isInconsistent = do let __do_lift ← get pure __do_lift.inconsistent
Instances For
Returns a proof that a = b.
It assumes a and b are in the same equivalence class, and have the same type.
Returns a proof that a ≍ b.
It assumes a and b are in the same equivalence class.
Internalizes a local declaration which is not a proposition. Note: We must internalize local variables because their types may be empty, and may not be referenced anywhere else. Example:
example (a : { x : Int // x < 0 ∧ x > 0 }) : False := by grind
etaStruct may also be applicable.
Equations
- Lean.Meta.Grind.internalizeLocalDecl localDecl = do let e ← liftM (Lean.Meta.Sym.shareCommon localDecl.toExpr) Lean.Meta.Grind.internalize e 0 Lean.Meta.Grind.processToDo
Instances For
Returns a proof that a = b if they have the same type. Otherwise, returns a proof of a ≍ b.
It assumes a and b are in the same equivalence class.
Equations
- Lean.Meta.Grind.mkEqHEqProof a b = do let __do_lift ← liftM (Lean.Meta.Grind.hasSameType a b) if __do_lift = true then Lean.Meta.Grind.mkEqProof a b else Lean.Meta.Grind.mkHEqProof a b
Instances For
Returns a proof that a = True.
It assumes a and True are in the same equivalence class.
Equations
- Lean.Meta.Grind.mkEqTrueProof a = do let __do_lift ← liftM Lean.Meta.Sym.getTrueExpr Lean.Meta.Grind.mkEqProof a __do_lift
Instances For
Returns a proof that a = False.
It assumes a and False are in the same equivalence class.
Equations
- Lean.Meta.Grind.mkEqFalseProof a = do let __do_lift ← liftM Lean.Meta.Sym.getFalseExpr Lean.Meta.Grind.mkEqProof a __do_lift
Instances For
Returns a proof that a = Bool.true.
It assumes a and Bool.true are in the same equivalence class.
Equations
- Lean.Meta.Grind.mkEqBoolTrueProof a = do let __do_lift ← liftM Lean.Meta.Sym.getBoolTrueExpr Lean.Meta.Grind.mkEqProof a __do_lift
Instances For
Returns a proof that a = Bool.false.
It assumes a and Bool.false are in the same equivalence class.
Equations
- Lean.Meta.Grind.mkEqBoolFalseProof a = do let __do_lift ← liftM Lean.Meta.Sym.getBoolFalseExpr Lean.Meta.Grind.mkEqProof a __do_lift
Instances For
Marks current goal as inconsistent without assigning mvarId.
Equations
- One or more equations did not get rendered due to their size.
Instances For
goal.withContext x executes x using the given metavariable LocalContext and LocalInstances.
The type class resolution cache is flushed when executing x if its LocalInstances are
different from the current ones.
Equations
- goal.withContext = goal.mvarId.withContext
Instances For
Creates an auxiliary metavariable with the same type and context of goal.mvarId.
We use this function to perform cases on the current goal without eagerly assigning it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns all enodes in the goal
Equations
- Lean.Meta.Grind.getExprs = do let __do_lift ← get pure __do_lift.exprs
Instances For
Equations
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.EvalTactic.skip goal x✝ = pure [goal]
Instances For
- propagateUp : Propagator
- propagateDown : Propagator
- evalTactic : EvalTactic
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.getMethods = do let __do_lift ← Lean.Meta.Grind.getMethodsRef pure (Lean.Meta.Grind.MethodsRef.toMethods✝ __do_lift)
Instances For
Equations
- Lean.Meta.Grind.propagateUp e = do let __do_lift ← liftM Lean.Meta.Grind.getMethods __do_lift.propagateUp e
Instances For
Equations
- Lean.Meta.Grind.propagateDown e = do let __do_lift ← liftM Lean.Meta.Grind.getMethods __do_lift.propagateDown e
Instances For
Equations
- Lean.Meta.Grind.evalTactic goal stx = do let __do_lift ← Lean.Meta.Grind.getMethods __do_lift.evalTactic goal stx
Instances For
Returns true if s has been already added to the case-split list at one point.
Remark: this function returns true even if the split has already been resolved
and is not in the list anymore.
Equations
Instances For
Returns true if e is a case-split that does not need to be performed anymore.
Equations
- Lean.Meta.Grind.isResolvedCaseSplit e = do let __do_lift ← get pure (Lean.PersistentHashSet.contains __do_lift.split.resolved { expr := e })
Instances For
Marks e as a case-split that does not need to be performed anymore.
Remark: we currently use this feature to disable match-case-splits.
Remark: we also use this feature to record the case-splits that have already been performed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
- ready : ActivateNextGuardResult
- next (guard : Expr) (pending : List TheoremGuard) : ActivateNextGuardResult
Instances For
Equations
- Lean.Meta.Grind.activateNextGuard thm guards generation = Lean.Meta.Grind.activateNextGuard.go✝ thm generation guards
Instances For
Adds a new theorem instance produced using E-matching.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- delayed.check = Lean.Meta.Grind.addTheoremInstance delayed.thm delayed.proof delayed.prop delayed.generation delayed.guards delayed.sources
Instances For
Returns extensionality theorems for the given type if available.
If Config.ext is false, the result is #[].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add a new lookahead candidate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Action is the control interface for grind’s search steps. It is defined in
Continuation-Passing Style (CPS).
See Grind/Action.lean for additional details.
Result type for a grind Action
- closed (seq : List TGrind) : ActionResult
The goal has been closed, and you can use
seqto close the goal efficiently. - stuck (gs : List Goal) : ActionResult
The action could not make further progress.
gsare subgoals that could not be closed. They are used for producing error messages.
Instances For
Equations
Equations
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.Action.notApplicable goal kna x✝ = kna goal
Instances For
Equations
Solver Extensions
Solver extension, can only be generated by registerSolverExtension that allocates a unique index
for this extension into each goal's extension state's array.
- id : Nat
- mkInitial : IO σ
- enabled : Grind.Config → Bool
Returns
trueif the configuration enables the solver.grindonly invokes the methods of enabled solvers. Every solver has a state, since other solvers may read it. - action : Action
Instances For
Registers a new solver extension for grind.
Solver extensions can only be registered during initialization.
Reason: We do not use any synchronization primitive to access solverExtensionsRef.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sets methods/handlers for solver extension ext.
Solver extension methods can only be registered during initialization.
Reason: We do not use any synchronization primitive to access solverExtensionsRef.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns initial state for registered solvers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the ids of the solver extensions that config enables.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.instInhabitedGoalM = { default := Lean.throwError (Lean.toMessageData "<GoalM action default value>") }
Equations
- ext.getState = do let __do_lift ← get liftM (ext.getStateCore __do_lift)
Instances For
Checks invariants of all active solvers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.Solvers.check = do let __do_lift ← Lean.Meta.Grind.Solvers.check? pure !__do_lift.isNone
Instances For
Invokes model-based theory combination extensions in all active solvers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sequential conjunction: executes both x and y.
- Runs
xand always runsyafterward, regardless of whetherxmade progress. - It is not applicable only if both
xandyare not applicable.
Equations
- x.andAlso y goal kna kp = x goal (fun (goal : Lean.Meta.Grind.Goal) => y goal kna kp) fun (goal : Lean.Meta.Grind.Goal) => y goal kp kp
Instances For
Combines the active solver extensions into a single action using Action.andAlso.
Does not drain newRawFacts; use Solvers.mkAction (defined in Intro.lean) which
wraps this with assertAll.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a new disequality lhs ≠ rhs, propagates it to relevant theories.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Runs the queued newEq callback. See ToProcessElement.solverEq.
Equations
- Lean.Meta.Grind.Solvers.newEq solverId lhs rhs = do let __do_lift ← ST.Ref.get Lean.Meta.Grind.solverExtensionsRef✝ __do_lift[solverId]!.newEq lhs rhs
Instances For
Runs the queued newDiseq callback. See ToProcessElement.solverDiseq.
Equations
- Lean.Meta.Grind.Solvers.newDiseq solverId lhs rhs = do let __do_lift ← ST.Ref.get Lean.Meta.Grind.solverExtensionsRef✝ __do_lift[solverId]!.newDiseq lhs rhs
Instances For
Equations
Instances For
Registers e as a term of the solver ext. If the equivalence class of e already has a term
e' of this solver with the same type, the solver learns e = e'. Otherwise, e becomes a
representative of the class, and if a class disequal to it has a term of this solver, the solver
learns that disequality. These callbacks are queued, not run here: markTerm
is called from internalize hooks, where the callbacks must not internalize new terms yet.
See ToProcessElement.solverEq and GoalState.internalizing.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns some t if t is the solver term for ext associated with e.
If the equivalence class of e contains terms of different types, t is one of
the representatives of ext.
Equations
- ext.getTerm e = Lean.Meta.Grind.SolverExtension.getTerm.go✝ ext.id e.sTerms
Instances For
Returns true if the root of es equivalence class is already attached to a term
of the given solver.
Equations
- ext.hasTermAtRoot e = do let __do_lift ← Lean.Meta.Grind.getRootENode e pure (Lean.Meta.Grind.SolverExtension.hasTermAtRoot.go✝ ext.id __do_lift.sTerms)
Instances For
Instances For
Merges the solver terms of lhsRoot into rhsRoot, the root of the merged class.
heqProofs := true if the merged class contains heterogeneous equalities.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Meta.Grind.anchorToString numDigits anchor = Lean.Meta.Grind.anchorPrefixToString numDigits (anchor >>> (64 - 4 * numDigits.toUInt64))
Instances For
Equations
- anchorRef.toString = Lean.Meta.Grind.anchorPrefixToString anchorRef.numDigits anchorRef.anchorPrefix
Instances For
Equations
Returns activated match-declaration equations.
Recall that in tactics such as instantiate only [...], match-declarations are always instantiated.
Equations
- One or more equations did not get rendered due to their size.