Equations
Instances For
We use this auxiliary constant to mark delayed congruence proofs.
Equations
- Lean.Meta.Grind.congrPlaceholderProof = Lean.mkConst (Lean.Name.mkSimple "[congruence]")
Instances For
Returns true
if e
is True
, False
, or a literal value.
See LitValues
for supported literals.
Equations
- Lean.Meta.Grind.isInterpreted e = if (e.isTrue || e.isFalse) = true then pure true else do let y ← pure PUnit.unit (fun (y : PUnit) => Lean.Meta.isLitValue e) y
Instances For
Context for GrindM
monad.
- simp : Lean.Meta.Simp.Context
- simprocs : Array Lean.Meta.Simprocs
- mainDeclName : Lean.Name
- config : Lean.Grind.Config
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.Grind.isSameExpr a.f b.f && a.numArgs == b.numArgs }
Equations
- One or more equations did not get rendered due to their size.
State for the GrindM
monad.
- canon : Lean.Meta.Grind.Canon.State
ShareCommon
(akaHashconsing
) state.- nextThmIdx : Nat
Next index for creating auxiliary theorems.
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- simpStats : Lean.Meta.Simp.Stats
- trueExpr : Lean.Expr
- falseExpr : Lean.Expr
Instances For
Equations
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 internalized True
constant.
Equations
- Lean.Meta.Grind.getTrueExpr = do let __do_lift ← get pure __do_lift.trueExpr
Instances For
Returns the internalized False
constant.
Equations
- Lean.Meta.Grind.getFalseExpr = do let __do_lift ← get pure __do_lift.falseExpr
Instances For
Equations
- Lean.Meta.Grind.getMainDeclName = do let __do_lift ← readThe Lean.Meta.Grind.Context pure __do_lift.mainDeclName
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
Abtracts nested proofs in e
. This is a preprocessing step performed before internalization.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Canonicalizes nested types, type formers, and instances in e
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true
if e
is the internalized True
expression.
Equations
- Lean.Meta.Grind.isTrueExpr e = do let __do_lift ← Lean.Meta.Grind.getTrueExpr pure (Lean.Meta.Grind.isSameExpr e __do_lift)
Instances For
Returns true
if e
is the internalized False
expression.
Equations
- Lean.Meta.Grind.isFalseExpr e = do let __do_lift ← Lean.Meta.Grind.getFalseExpr pure (Lean.Meta.Grind.isSameExpr e __do_lift)
Instances For
Creates a congruence theorem for a f
-applications with numArgs
arguments.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stores information for a node in the egraph.
Each internalized expression e
has an ENode
associated with it.
- self : Lean.Expr
Node represented by this ENode.
- next : Lean.Expr
Next element in the equivalence class.
- root : Lean.Expr
Root (aka canonical representative) of the equivalence class
- congr : Lean.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 := true
if node should be viewed as an abstract value. - ctor : Bool
ctor := true
if the head symbol is a constructor application. - hasLambdas : Bool
hasLambdas := true
if 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
- mt : Nat
Modification time
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.Grind.instReprENode = { reprPrec := Lean.Meta.Grind.reprENode✝ }
Equations
- n.isCongrRoot = Lean.Meta.Grind.isSameExpr n.self n.congr
Instances For
Equations
- Lean.Meta.Grind.instHashableENodeKey = { hash := fun (k : Lean.Meta.Grind.ENodeKey✝) => Lean.Meta.Grind.instHashableENodeKey.unsafe_impl_1 k }
Equations
- Lean.Meta.Grind.instBEqENodeKey = { beq := fun (k₁ k₂ : Lean.Meta.Grind.ENodeKey✝) => Lean.Meta.Grind.isSameExpr k₁.expr k₂.expr }
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
- Lean.Meta.Grind.congrHash.go enodes (f.app a) r = Lean.Meta.Grind.congrHash.go enodes f (mixHash r (Lean.Meta.Grind.hashRoot✝ enodes a))
- Lean.Meta.Grind.congrHash.go enodes e r = mixHash r (Lean.Meta.Grind.hashRoot✝ enodes e)
Instances For
Returns true
if a
and b
are congruent modulo the equivalence classes in enodes
.
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.instHashableCongrKey = { hash := fun (k : Lean.Meta.Grind.CongrKey enodes) => Lean.Meta.Grind.congrHash enodes k.e }
Equations
- Lean.Meta.Grind.instBEqCongrKey = { beq := fun (k1 k2 : Lean.Meta.Grind.CongrKey enodes) => Lean.Meta.Grind.isCongruent enodes k1.e k2.e }
Equations
- Lean.Meta.Grind.CongrTable enodes = Lean.PHashSet (Lean.Meta.Grind.CongrKey enodes)
Instances For
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.
- proof : Lean.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
Equations
- Lean.Meta.Grind.instInhabitedNewFact = { default := { proof := default, prop := default, generation := default } }
- mvarId : Lean.MVarId
- enodes : Lean.Meta.Grind.ENodeMap
- parents : Lean.Meta.Grind.ParentMap
- congrTable : Lean.Meta.Grind.CongrTable self.enodes
- appMap : Lean.PHashMap Lean.HeadIndex (List Lean.Expr)
A mapping from each function application index (
HeadIndex
) to a list of applications with that index. Recall that theHeadIndex
for a constant is its constant name, and for a free variable, it is its unique id. - newEqs : Array Lean.Meta.Grind.NewEq
Equations to be processed.
- inconsistent : Bool
inconsistent := true
ifENode
s forTrue
andFalse
are in the same equivalence class. - gmt : Nat
Goal modification time.
- nextIdx : Nat
Next unique index for creating ENodes
Active theorems that we have performed ematching at least once.
- newThms : Lean.PArray Lean.Meta.Grind.EMatchTheorem
Active theorems that we have not performed any round of ematching yet.
- thmMap : Lean.Meta.Grind.EMatchTheorems
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
. - numInstances : Nat
Number of theorem instances generated so far
- preInstances : Lean.Meta.Grind.PreInstanceSet
(pre-)instances found so far. It includes instances that failed to be instantiated.
- newFacts : Std.Queue Lean.Meta.Grind.NewFact
new facts to be processed.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- goal.admit = goal.mvarId.admit
Instances For
Equations
Instances For
Equations
- Lean.Meta.Grind.GoalM.run goal x = goal.mvarId.withContext (StateRefT'.run x goal)
Instances For
Equations
- Lean.Meta.Grind.GoalM.run' goal x = goal.mvarId.withContext ((x *> get).run' goal)
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 processing.
Equations
- One or more equations did not get rendered due to their size.
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
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.numInstances ≥ __do_lift_1.instances))
Instances For
Returns some n
if e
has already been "internalized" into the
Otherwise, returns none
s.
Equations
- Lean.Meta.Grind.getENode? e = do let __do_lift ← get pure (Lean.PersistentHashMap.find? __do_lift.enodes { expr := e })
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 ← Lean.Meta.Grind.getENode e pure __do_lift.generation
Instances For
Returns true
if e
is in the equivalence class of True
.
Equations
- Lean.Meta.Grind.isEqTrue e = do let n ← Lean.Meta.Grind.getENode e let __do_lift ← liftM Lean.Meta.Grind.getTrueExpr pure (Lean.Meta.Grind.isSameExpr n.root __do_lift)
Instances For
Returns true
if e
is in the equivalence class of False
.
Equations
- Lean.Meta.Grind.isEqFalse e = do let n ← Lean.Meta.Grind.getENode e let __do_lift ← liftM Lean.Meta.Grind.getFalseExpr pure (Lean.Meta.Grind.isSameExpr n.root __do_lift)
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 __discr ← Lean.Meta.Grind.getENode? e match __discr with | some n => pure (Lean.Meta.Grind.isSameExpr n.root e) | x => pure false
Instances For
Returns the root element in the equivalence class of e
IF e
has been internalized.
Equations
- Lean.Meta.Grind.getRoot? e = do let __discr ← Lean.Meta.Grind.getENode? e match __discr with | some n => pure (some n.root) | x => pure none
Instances For
Returns the root element in the equivalence class of e
.
Equations
- Lean.Meta.Grind.getRoot e = do let __do_lift ← Lean.Meta.Grind.getENode e pure __do_lift.root
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 next element in the equivalence class of e
.
Equations
- Lean.Meta.Grind.getNext e = do let __do_lift ← Lean.Meta.Grind.getENode e pure __do_lift.next
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.enodes { expr := e })
Instances For
Equations
- Lean.Meta.Grind.getTarget? e = do let __discr ← Lean.Meta.Grind.getENode? e match __discr with | some n => pure n.target? | x => pure none
Instances For
Return true
if a
and b
have the same type.
Equations
- Lean.Meta.Grind.hasSameType a b = Lean.Meta.withDefault do let __do_lift ← Lean.Meta.inferType a let __do_lift_1 ← Lean.Meta.inferType b Lean.Meta.isDefEq __do_lift __do_lift_1
Instances For
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
Pushes HEq 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.Grind.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.Grind.getFalseExpr 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 the set of expressions e
is a child of, or an expression in
e
s equivalence class is a child of.
The information is only up to date if e
is the root (aka canonical representative) of the equivalence class.
Equations
- Lean.Meta.Grind.getParents e = do let __do_lift ← get match Lean.PersistentHashMap.find? __do_lift.parents { expr := e } with | some parents => pure parents | x => pure ∅
Instances For
Similar to getParents
, but also removes the entry e ↦ parents
from the parent map.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Copy parents
to the parents of root
.
root
must be the root of its equivalence class.
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
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
Returns the root of the congruence class containing e
.
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 HEq a b
.
It assumes a
and b
are in the same equivalence class.
Returns a proof that a = b
if they have the same type. Otherwise, returns a proof of HEq 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.Grind.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.Grind.getFalseExpr 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
Closes the current goal using the given proof of False
and
marks it as inconsistent if it is not already marked so.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns all enodes in the goal
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
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Instances For
- propagateUp : Lean.Meta.Grind.Propagator
- propagateDown : Lean.Meta.Grind.Propagator
- fallback : Lean.Meta.Grind.Fallback
Instances For
Equations
- Lean.Meta.Grind.instInhabitedMethods = { default := { propagateUp := default, propagateDown := default, fallback := default } }
Equations
- m.toMethodsRef = Lean.Meta.Grind.Methods.toMethodsRef.unsafe_impl_1 m
Instances For
Equations
- Lean.Meta.Grind.getMethods = do let __do_lift ← Lean.Meta.Grind.getMethodsRef pure __do_lift.toMethods
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.applyFallback = do let __do_lift ← liftM Lean.Meta.Grind.getMethods let fallback : Lean.Meta.Grind.GoalM Unit := __do_lift.fallback fallback
Instances For
Returns expressions in the given expression equivalence class.
Equations
Instances For
Returns all equivalence classes in the current goal.
Equations
- One or more equations did not get rendered due to their size.