Documentation

Lean.Meta.Tactic.Grind.Types

We use this auxiliary constant to mark delayed congruence proofs.

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.

    Instances For

      Returns true if e is True, False, or a literal value. See Lean.Meta.LitValues for supported literals.

      Instances For

        Anchors are used to reference terms, local theorems, and case-splits in the grind state. We also use anchors to prune the search space when they are provided as grind parameters and the finish tactic.

        Instances For

          Opaque solver extension state.

          Case-split source. That is, where it came from. We store the current source in the grind context.

          Instances For

            Context for GrindM monad.

            • simpMethods : Simp.Methods
            • config : Grind.Config
            • anchorRefs? : Option (Array AnchorRef)

              If anchorRefs? := some anchorRefs, then only local instances and case-splits in anchorRefs are considered.

            • cheapCases : Bool

              If cheapCases is true, grind only applies cases to types that contain at most one minor premise. Recall that grind applies cases when introducing types tagged with [grind cases eager], and at Split.lean Remark: We add this option to implement the lookahead feature, we don't want to create several subgoals when performing lookahead.

            • reportMVarIssue : Bool
            • splitSource : SplitSource

              Current source of case-splits.

            • symPrios : SymbolPriorities

              Symbol priorities for inferring E-matching patterns

            • extensions : ExtensionStateArray
            • debug : Bool
            Instances For

              Key for the congruence theorem cache.

              Instances For
                • Number of times E-match theorem has been instantiated.

                • Number of times a cases has been performed on an inductive type/predicate

                • Number of applications per function symbol. This information is only collected if set_option diagnostics true

                Instances For

                  Case-split diagnostic information

                  Instances For

                    State for the GrindM monad.

                    • 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
                    • lastTag : Name

                      Used to generate trace messages of the for [grind] working on <tag>, and implement the macro trace_goal.

                    • issues : List MessageData

                      Issues found during the proof search. These issues are reported to users when grind fails.

                    • counters : Counters

                      Performance counters

                    • splitDiags : PArray SplitDiagInfo

                      Split diagnostic information. This information is only collected when set_option diagnostics true

                    • lawfulEqCmpMap : PHashMap ExprPtr (Option Expr)

                      Mapping from binary functions f to a theorem thm : ∀ a b, f a b = .eq → a = b if it implements the LawfulEqCmp type class.

                    • reflCmpMap : PHashMap ExprPtr (Option Expr)

                      Mapping from binary functions f to a theorem thm : ∀ a, f a a = .eq if it implements the ReflCmp type class.

                    • Cached anchors (aka stable hash codes) for terms in the grind state.

                    Instances For
                      @[reducible, inline]
                      Instances For
                        @[inline]
                        def Lean.Meta.Grind.mapGrindM {m : TypeType u_1} [MonadControlT GrindM m] [Monad m] (f : {α : Type} → GrindM αGrindM α) {α : Type} (x : m α) :
                        m α
                        Instances For
                          @[inline]

                          Returns true if grind.debug is set

                          Instances For

                            Backtrackable state for the GrindM monad.

                            Instances For

                              Restore backtrackable parts of the state.

                              Instances For
                                def Lean.Meta.Grind.withoutReportingMVarIssues {m : TypeType u_1} {α : Type} [MonadControlT GrindM m] [Monad m] :
                                m αm α

                                withoutReportingMVarIssues x executes x without reporting metavariables found during internalization. See comment at Grind.Context.reportMVarIssue for additional details.

                                Instances For
                                  def Lean.Meta.Grind.withSplitSource {m : TypeType u_1} {α : Type} [MonadControlT GrindM m] [Monad m] (splitSource : SplitSource) :
                                  m αm α

                                  withSplitSource s x executes x and uses s as the split source for any case-split registered.

                                  Instances For

                                    Returns the user-defined configuration options

                                    Instances For

                                      Returns extension states associate with grind attributes in use

                                      Instances For
                                        @[reducible, inline]
                                        abbrev Lean.Meta.Grind.withGTransparency {n : TypeType u_1} {α : Type} [MonadControlT MetaM n] [MonadLiftT GrindM n] [Monad n] (k : n α) :
                                        n α

                                        Runs k with the transparency setting specified by Config.reducible. Uses reducible transparency if reducible is true, otherwise default transparency.

                                        Instances For

                                          Returns the anchor references (if any) being used to restrict the search.

                                          Instances For
                                            Instances For

                                              Returns symbol priorities for inferring E-matching patterns.

                                              Instances For

                                                Returns true if we declName is tagged with funCC modifier.

                                                Instances For
                                                  Instances For
                                                    Instances For
                                                      Instances For

                                                        Returns true if declName is the name of a match equation or a match congruence equation.

                                                        Instances For
                                                          Instances For
                                                            def Lean.Meta.Grind.saveSplitDiagInfo (c : Expr) (gen numCases : Nat) (splitSource : SplitSource) :
                                                            Instances For

                                                              Returns maximum term generation that is considered during ematching.

                                                              Instances For

                                                                Abstracts nested proofs in e. This is a preprocessing step performed before internalization.

                                                                Instances For

                                                                  Creates a congruence theorem for a f-applications with numArgs arguments.

                                                                  Instances For

                                                                    Similar to expandReportIssueMacro, but only reports issue if grind.debug is set to true

                                                                    Instances For

                                                                      Similar to reportIssue!, but only reports issue if grind.debug is set to true

                                                                      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.

                                                                        "Solver terms" are referenced as "theory variables" in the SMT literature. The SMT solver Z3 uses a similar representation.

                                                                        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

                                                                            congr is the term self is congruent to. We say self is the congruence class root if isSameExpr congr self. This field is initialized to self even if e is not an application.

                                                                          • target? : Option Expr

                                                                            When e was added to this equivalence class because of an equality h : e = target, then we store target here, and h at proof?.

                                                                          • proof? : Option 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 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

                                                                            If funCC := true, then the expression associated with this entry is an application, and function congruence closure is enabled for it. See Grind.Config.funCC for additional details.

                                                                          Instances For
                                                                            @[implicit_reducible]

                                                                            New equalities and facts to be processed.

                                                                            Instances For
                                                                              structure Lean.Meta.Grind.CongrKey (enodes : ENodeMap) :

                                                                              Key for the congruence table. We need access to the enodes to be able to retrieve the equivalence class roots.

                                                                              Instances For
                                                                                @[implicit_reducible]
                                                                                @[implicit_reducible]
                                                                                instance Lean.Meta.Grind.instBEqCongrKey {enodeMap : ENodeMap} :
                                                                                BEq (CongrKey enodeMap)
                                                                                @[reducible, inline]
                                                                                Instances For
                                                                                  Instances For
                                                                                    @[reducible, inline]
                                                                                    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.

                                                                                      Instances For
                                                                                        @[reducible, inline]
                                                                                        Instances For

                                                                                          New raw fact to be preprocessed, and then asserted.

                                                                                          Instances For
                                                                                            Instances For

                                                                                              Canonicalizer state. See Canon.lean for additional details.

                                                                                              Instances For

                                                                                                Trace information for a case split.

                                                                                                Instances For

                                                                                                  Users can attach guards to grind_patterns. A guard ensures that a theorem is instantiated only when the guard expression becomes provably true.

                                                                                                  If check is true, then grind attempts to prove e by asserting its negation and checking whether this leads to a contradiction.

                                                                                                  Instances For

                                                                                                    A delayed theorem instantiation is an instantiation that includes one or more guards. See TheoremGuard.

                                                                                                    Instances For

                                                                                                      E-matching related fields for the grind goal.

                                                                                                      • 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.

                                                                                                      • Active theorems that we have performed ematching at least once.

                                                                                                      • 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.

                                                                                                      • matchEqNames : PHashSet Name

                                                                                                        match auxiliary functions whose equations have already been created and activated.

                                                                                                      • Delayed instantiations is a mapping from guards to theorems that are waiting them to become True.

                                                                                                      Instances For

                                                                                                        Case-split information.

                                                                                                        • default (e : Expr) (source : SplitSource) : SplitInfo

                                                                                                          Term e may be an inductive predicate, match-expression, if-expression, implication, etc.

                                                                                                        • imp (e : Expr) (h : e.isForall = true) (source : SplitSource) : SplitInfo

                                                                                                          e is an implication and we want to split on its antecedent.

                                                                                                        • arg (a b : Expr) (i : Nat) (eq : Expr) (source : SplitSource) : SplitInfo

                                                                                                          Given applications a and b, case-split on whether the corresponding i-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
                                                                                                          @[implicit_reducible]

                                                                                                          Argument arg : type of an application app in SplitInfo.

                                                                                                          Instances For

                                                                                                            Case splitting related fields for the grind goal.

                                                                                                            • num : Nat

                                                                                                              Number of splits performed to get to this goal.

                                                                                                            • candidates : List SplitInfo

                                                                                                              Case-split candidates.

                                                                                                            • Case-splits that have been inserted at candidates at some point.

                                                                                                            • resolved : PHashSet ExprPtr

                                                                                                              Case-splits that have already been performed, or that do not have to be performed anymore.

                                                                                                            • trace : List CaseTrace

                                                                                                              Sequence of cases steps that generated this goal. We only use this information for diagnostics. Remark: casesTrace.length ≥ numSplits because we don't increase the counter for cases applications that generated only 1 subgoal.

                                                                                                            • lookaheads : List SplitInfo

                                                                                                              Lookahead "case-splits".

                                                                                                            • argPosMap : Std.HashMap (Expr × Expr) (List Nat)

                                                                                                              A mapping (a, b) ↦ is s.t. for each SplitInfo.arg a b i eq in candidates or lookaheads we have i ∈ is. We use this information to decide whether the split/lookahead is "ready" to be tried or not.

                                                                                                            • Mapping from pairs (f, i) to a list of arguments. Each argument occurs as the i-th of an f-application. We use this information to add splits/lookaheads for triggering extensionality theorems and model-based theory combination. See addSplitCandidatesForExt.

                                                                                                            Instances For

                                                                                                              Clean name generator.

                                                                                                              Instances For

                                                                                                                Cache for Unit-like types. It maps the type to its element. We say a type is Unit-like if it is a subsingleton and is inhabited.

                                                                                                                Instances For
                                                                                                                  • us : List Level
                                                                                                                  • α : Expr
                                                                                                                  • β : Expr
                                                                                                                  • h : Expr
                                                                                                                  • inv? : Option (Expr × Expr)

                                                                                                                    Inverse function and a proof that ∀ a, inv (f a) = a Note: The following two fields are none if no f-application has been found yet.

                                                                                                                  Instances For

                                                                                                                    State for injective theorem support.

                                                                                                                    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.

                                                                                                                      Instances For
                                                                                                                        Instances For
                                                                                                                          Instances For
                                                                                                                            Instances For
                                                                                                                              @[reducible, inline]
                                                                                                                              Instances For
                                                                                                                                @[inline]
                                                                                                                                def Lean.Meta.Grind.GoalM.runCore {α : Type} (goal : Goal) (x : GoalM α) :
                                                                                                                                Instances For
                                                                                                                                  @[inline]
                                                                                                                                  def Lean.Meta.Grind.GoalM.run {α : Type} (goal : Goal) (x : GoalM α) :
                                                                                                                                  Instances For
                                                                                                                                    @[inline]
                                                                                                                                    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.

                                                                                                                                      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.

                                                                                                                                        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.

                                                                                                                                          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.

                                                                                                                                            Instances For
                                                                                                                                              def Lean.Meta.Grind.addNewRawFact (proof prop : Expr) (generation : Nat) (splitSource : SplitSource) :

                                                                                                                                              Adds a new fact prop with proof proof to the queue for preprocessing and the assertion.

                                                                                                                                              Instances For

                                                                                                                                                Returns the number of theorem instances generated so far.

                                                                                                                                                Instances For

                                                                                                                                                  Returns true if the maximum number of instances has been reached.

                                                                                                                                                  Instances For

                                                                                                                                                    Returns true if the maximum number of case-splits has been reached.

                                                                                                                                                    Instances For

                                                                                                                                                      Returns true if the maximum number of E-matching rounds has been reached.

                                                                                                                                                      Instances For

                                                                                                                                                        Returns some n if e has already been "internalized" into the Otherwise, returns nones.

                                                                                                                                                        Instances For
                                                                                                                                                          @[inline]

                                                                                                                                                          Returns some n if e has already been "internalized" into the Otherwise, returns nones.

                                                                                                                                                          Instances For

                                                                                                                                                            Returns node associated with e. It assumes e has already been internalized.

                                                                                                                                                            Instances For
                                                                                                                                                              @[inline]

                                                                                                                                                              Returns node associated with e. It assumes e has already been internalized.

                                                                                                                                                              Instances For
                                                                                                                                                                Instances For

                                                                                                                                                                  Returns the generation of the given term. Is assumes it has been internalized

                                                                                                                                                                  Instances For

                                                                                                                                                                    Returns true if e is in the equivalence class of True.

                                                                                                                                                                    Instances For

                                                                                                                                                                      Returns true if e is in the equivalence class of False.

                                                                                                                                                                      Instances For

                                                                                                                                                                        Returns true if e is in the equivalence class of Bool.true.

                                                                                                                                                                        Instances For

                                                                                                                                                                          Returns true if e is in the equivalence class of Bool.false.

                                                                                                                                                                          Instances For

                                                                                                                                                                            Returns true if a and b are in the same equivalence class.

                                                                                                                                                                            Instances For

                                                                                                                                                                              Returns true if the root of its equivalence class.

                                                                                                                                                                              Instances For

                                                                                                                                                                                Returns the root element in the equivalence class of e IF e has been internalized.

                                                                                                                                                                                Instances For
                                                                                                                                                                                  @[inline]

                                                                                                                                                                                  Returns the root element in the equivalence class of e IF e has been internalized.

                                                                                                                                                                                  Instances For

                                                                                                                                                                                    Returns the root element in the equivalence class of e.

                                                                                                                                                                                    Instances For
                                                                                                                                                                                      @[inline]

                                                                                                                                                                                      Returns the root element in the equivalence class of e.

                                                                                                                                                                                      Instances For

                                                                                                                                                                                        Returns the root enode in the equivalence class of e.

                                                                                                                                                                                        Instances For

                                                                                                                                                                                          Returns the root enode in the equivalence class of e if it is in an equivalence class.

                                                                                                                                                                                          Instances For

                                                                                                                                                                                            Returns true if the ENode associate with e has support for function equality congruence closure. See Grind.Config.funCC for additional details.

                                                                                                                                                                                            Instances For

                                                                                                                                                                                              Returns the next element in the equivalence class of e if e has been internalized in the given goal.

                                                                                                                                                                                              Instances For

                                                                                                                                                                                                Returns the next element in the equivalence class of e.

                                                                                                                                                                                                Instances For
                                                                                                                                                                                                  @[inline]

                                                                                                                                                                                                  Returns the root element in the equivalence class of e.

                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                    Returns true if e has already been internalized.

                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                        @[inline]
                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                          def Lean.Meta.Grind.pushEqCore (lhs rhs proof : Expr) (isHEq : Bool) :

                                                                                                                                                                                                          If isHEq is false, it pushes lhs = rhs with proof to newEqs. Otherwise, it pushes lhs ≍ rhs.

                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                            Return true if a and b have the same type.

                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                              def Lean.Meta.Grind.pushEqHEq (lhs rhs proof : Expr) :
                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                @[inline]
                                                                                                                                                                                                                def Lean.Meta.Grind.pushEq (lhs rhs proof : Expr) :

                                                                                                                                                                                                                Pushes lhs = rhs with proof to newEqs.

                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                  def Lean.Meta.Grind.pushHEq (lhs rhs proof : Expr) :

                                                                                                                                                                                                                  Pushes lhs ≍ rhs with proof to newEqs.

                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                    Pushes a = True with proof to newEqs.

                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                      Pushes a = False with proof to newEqs.

                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                        Pushes a = Bool.true with proof to newEqs.

                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                          Pushes a = Bool.false with proof to newEqs.

                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                            Records that parent is a parent of child. This function actually stores the information in the root (aka canonical representative) of child.

                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                              Returns the set of expressions e is a child of, or an expression in es 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.

                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                Removes the entry eparents from the parent map.

                                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                                  Copy parents to the parents of root. root must be the root of its equivalence class.

                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                    def Lean.Meta.Grind.mkENodeCore (e : Expr) (interpreted ctor : Bool) (generation : Nat) (funCC : Bool) :
                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                      def Lean.Meta.Grind.mkENode (e : Expr) (generation : Nat) (funCC : Bool := false) :

                                                                                                                                                                                                                                      Creates an ENode for e if one does not already exist. This method assumes e has been hash-consed.

                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                          Returns true if type of t is definitionally equal to α

                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                            @[inline]

                                                                                                                                                                                                                                            For each equality b = c in parents, executes k b c IF

                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                              Returns true is e is the root of its congruence class.

                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                Returns the root of the congruence class containing e.

                                                                                                                                                                                                                                                Return true if the goal is inconsistent.

                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                  @[extern lean_grind_mk_eq_proof]

                                                                                                                                                                                                                                                  Returns a proof that a = b. It assumes a and b are in the same equivalence class, and have the same type.

                                                                                                                                                                                                                                                  @[extern lean_grind_mk_heq_proof]

                                                                                                                                                                                                                                                  Returns a proof that a ≍ b. It assumes a and b are in the same equivalence class.

                                                                                                                                                                                                                                                  @[extern lean_grind_process_new_facts]
                                                                                                                                                                                                                                                  @[extern lean_grind_internalize]
                                                                                                                                                                                                                                                  opaque Lean.Meta.Grind.internalize (e : Expr) (generation : Nat) (parent? : Option Expr := none) :
                                                                                                                                                                                                                                                  @[extern lean_grind_preprocess]

                                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                      Returns a proof that a = True. It assumes a and True are in the same equivalence class.

                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                        Returns a proof that a = False. It assumes a and False are in the same equivalence class.

                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                          Returns a proof that a = Bool.true. It assumes a and Bool.true are in the same equivalence class.

                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                            Returns a proof that a = Bool.false. It assumes a and Bool.false are in the same equivalence class.

                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                              Marks current goal as inconsistent without assigning mvarId.

                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                def Lean.MVarId.assignFalseProof (mvarId : MVarId) (falseProof : Expr) :

                                                                                                                                                                                                                                                                Assign the mvarId using the given proof of False. If type of mvarId is not False, then use False.elim.

                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                  @[inline]
                                                                                                                                                                                                                                                                  def Lean.Meta.Grind.Goal.withContext {m : TypeType u_1} {α : Type} [MonadControlT MetaM m] [Monad m] (goal : Goal) :
                                                                                                                                                                                                                                                                  m αm α

                                                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                      Closes the current goal using the given proof of False and marks it as inconsistent if it is not already marked so.

                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                        Returns all enodes in the goal

                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                          @[inline]

                                                                                                                                                                                                                                                                          Executes f to each term in the equivalence class containing e

                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                            @[inline]

                                                                                                                                                                                                                                                                            Executes f to each term in the equivalence class containing e, and stops as soon as f returns true.

                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                              @[inline]
                                                                                                                                                                                                                                                                              def Lean.Meta.Grind.foldEqc {α : Type} (e : Expr) (init : α) (f : ENodeαGoalM α) :

                                                                                                                                                                                                                                                                              Folds using f and init over the equivalence class containing e

                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                @[reducible, inline]
                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                  @[reducible, inline]
                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                      @[inline]
                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                        def Lean.Meta.Grind.evalTactic (goal : Goal) (stx : TSyntax `grind) :
                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                          def Lean.Meta.Grind.Goal.getEqc (goal : Goal) (e : Expr) (sort : Bool := false) :

                                                                                                                                                                                                                                                                                          Returns expressions in the given expression equivalence class.

                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                            @[inline]

                                                                                                                                                                                                                                                                                            Returns expressions in the given expression equivalence class.

                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                              Returns all equivalence classes in the current goal.

                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                @[inline]

                                                                                                                                                                                                                                                                                                Returns all equivalence classes in the current goal.

                                                                                                                                                                                                                                                                                                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.

                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                    Returns true if e is a case-split that does not need to be performed anymore.

                                                                                                                                                                                                                                                                                                    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.

                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                        Inserts e into the list of case-split candidates if it was not inserted before.

                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                          def Lean.Meta.Grind.addTheoremInstance (thm : EMatchTheorem) (proof prop : Expr) (generation : Nat) (guards : List TheoremGuard) :

                                                                                                                                                                                                                                                                                                          Adds a new theorem instance produced using E-matching.

                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                            Returns extensionality theorems for the given type if available. If Config.ext is false, the result is #[].

                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                              Add a new lookahead candidate.

                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                Helper function for executing x with a fresh newFacts and without modifying the goal state.

                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                  @[extern lean_grind_canon]

                                                                                                                                                                                                                                                                                                                  Canonicalizes nested types, type formers, and instances in e.

                                                                                                                                                                                                                                                                                                                  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.

                                                                                                                                                                                                                                                                                                                  @[reducible, inline]
                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                    Result type for a grind Action

                                                                                                                                                                                                                                                                                                                    • closed (seq : List TGrind) : ActionResult

                                                                                                                                                                                                                                                                                                                      The goal has been closed, and you can use seq to close the goal efficiently.

                                                                                                                                                                                                                                                                                                                    • stuck (gs : List Goal) : ActionResult

                                                                                                                                                                                                                                                                                                                      The action could not make further progress. gs are subgoals that could not be closed. They are used for producing error messages.

                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                      @[reducible, inline]
                                                                                                                                                                                                                                                                                                                      Instances For
                                                                                                                                                                                                                                                                                                                        @[reducible, inline]
                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                          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.

                                                                                                                                                                                                                                                                                                                          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.

                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                              def Lean.Meta.Grind.SolverExtension.setMethods {σ : Type} (ext : SolverExtension σ) (internalize : ExprOption ExprGoalM Unit := fun (x : Expr) (x_1 : Option Expr) => pure ()) (newEq newDiseq : ExprExprGoalM Unit := fun (x x_1 : Expr) => pure ()) (mbtc : GoalM Bool := pure false) (action : Action := Action.notApplicable) (check : GoalM Bool := pure false) (checkInv : GoalM Unit := pure ()) :

                                                                                                                                                                                                                                                                                                                              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.

                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                Returns initial state for registered solvers.

                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  @[implicit_reducible]
                                                                                                                                                                                                                                                                                                                                  @[implemented_by _private.Lean.Meta.Tactic.Grind.Types.0.Lean.Meta.Grind.SolverExtension.modifyStateImpl]
                                                                                                                                                                                                                                                                                                                                  @[implemented_by _private.Lean.Meta.Tactic.Grind.Types.0.Lean.Meta.Grind.SolverExtension.getStateCoreImpl]

                                                                                                                                                                                                                                                                                                                                  Internalizes given expression in all registered solvers.

                                                                                                                                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                                                                                                                                    Checks invariants of all registered solvers.

                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                      Performs (expensive) satisfiability checks in all registered solvers, and returns the solver ids that made progress.

                                                                                                                                                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                                                                                                                                                        Invokes model-based theory combination extensions in all registered solvers.

                                                                                                                                                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                                                                                                                                                          Sequential conjunction: executes both x and y.

                                                                                                                                                                                                                                                                                                                                          • Runs x and always runs y afterward, regardless of whether x made progress.
                                                                                                                                                                                                                                                                                                                                          • It is not applicable only if both x and y are not applicable.
                                                                                                                                                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                                                                                                                                                            Given a new disequality lhs ≠ rhs, propagates it to relevant theories.

                                                                                                                                                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                                                                                                                                                              Returns some t if t is the solver term for ext associated with e.

                                                                                                                                                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                                                                                                                                                Returns true if the root of es equivalence class is already attached to a term of the given solver.

                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                  def Lean.Meta.Grind.anchorPrefixToString (numDigits : Nat) (anchorPrefix : UInt64) :
                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                    def Lean.Meta.Grind.anchorToString (numDigits : Nat) (anchor : UInt64) :
                                                                                                                                                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                                                                                                                                                      Returns activated match-declaration equations. Recall that in tactics such as instantiate only [...], match-declarations are always instantiated.

                                                                                                                                                                                                                                                                                                                                                      Instances For