Documentation

Lean.Elab.Tactic.Basic

def Lean.Elab.admitGoal (mvarId : MVarId) (synthetic : Bool := true) :

Assign mvarId := sorry

Equations
    Instances For
      Equations
        Instances For
          Equations
            Instances For
              • elaborator : Name

                Declaration name of the executing elaborator, used by mkTacticInfo to persist it in the info tree

              • recover : Bool

                If true, enable "error recovery" in some tactics. For example, cases tactic admits unsolved alternatives when recover == true. The combinator withoutRecover <tac> disables "error recovery" while executing <tac>. This is useful for tactics such as first | ... | ....

              Instances For
                @[reducible, inline]

                The tactic monad, which extends the term elaboration monad TermElabM with state that contains the current goals (Lean.Elab.Tactic.State, accessible via MonadStateOf) and local information about the current tactic's name and whether error recovery is enabled (Lean.Elab.Tactic.Context, accessible via MonadReaderOf).

                Equations
                  Instances For
                    @[reducible, inline]

                    A tactic is a function from syntax to an action in the tactic monad.

                    A given tactic syntax kind may have multiple Tactics associated with it, all of which will be attempted until one succeeds.

                    Equations
                      Instances For
                        @[always_inline]
                        Equations

                          Returns the list of goals. Goals may or may not already be assigned.

                          Equations
                            Instances For
                              Equations
                                Instances For
                                  Equations
                                    Instances For
                                      Equations
                                        Instances For
                                          @[specialize #[]]

                                          Like Meta.withRestoreOrSaveFull for TermElabM, but also takes a tacSnap? that

                                          • when running act, is set as Context.tacSnap?
                                          • otherwise (i.e. on restore) is used to update the new snapshot promise to the old task's value. This extra restore step is necessary because while reusableResult? can be used to replay any effects on State, Context.tacSnap? is not part of it but changed via an IO side effect, so it needs to be replayed separately.

                                          We use an explicit parameter instead of accessing Context.tacSnap? directly because this prevents withRestoreOrSaveFull and withReader from being used in the wrong order.

                                          Equations
                                            Instances For

                                              Registers a tactic elaborator for the given syntax node kind.

                                              A tactic elaborator should have type Lean.Elab.Tactic.Tactic (which is Lean.SyntaxLean.Elab.Tactic.TacticM Unit), i.e. should take syntax of the given syntax node kind as a parameter and alter the tactic state.

                                              The elab_rules and elab commands should usually be preferred over using this attribute directly.

                                              def Lean.Elab.Tactic.mkTacticInfo (mctxBefore : MetavarContext) (goalsBefore : List MVarId) (stx : Syntax) :
                                              Equations
                                                Instances For
                                                  @[inline]
                                                  Equations
                                                    Instances For

                                                      Important: we must define evalTactic before we define the instance MonadExcept for TacticM since it backtracks the state including error messages, and this is bad when rethrowing the exception at the catch block in these methods. We marked these places with a (*) in these methods.

                                                      Auxiliary datastructure for capturing exceptions at evalTactic.

                                                      Instances For
                                                        Equations
                                                          Instances For
                                                            Equations
                                                              Instances For
                                                                def Lean.Elab.Tactic.focus {α : Type} (x : TacticM α) :

                                                                Runs x with only the first unsolved goal as the goal. Fails if there are no goal to be solved.

                                                                Equations
                                                                  Instances For
                                                                    def Lean.Elab.Tactic.focusAndDone {α : Type} (tactic : TacticM α) :

                                                                    Runs tactic with only the first unsolved goal as the goal, and expects it leave no goals. Fails if there are no goal to be solved.

                                                                    Equations
                                                                      Instances For

                                                                        Close the main goal using the given tactic. If it fails, log the error and admit

                                                                        Equations
                                                                          Instances For
                                                                            @[inline]
                                                                            def Lean.Elab.Tactic.tryCatch {α : Type} (x : TacticM α) (h : ExceptionTacticM α) :

                                                                            Non-backtracking try/catch.

                                                                            Equations
                                                                              Instances For
                                                                                @[inline]

                                                                                Backtracking try/catch. This is used for the MonadExcept instance for TacticM.

                                                                                Equations
                                                                                  Instances For

                                                                                    Execute x with error recovery disabled

                                                                                    Equations
                                                                                      Instances For
                                                                                        @[inline]
                                                                                        def Lean.Elab.Tactic.orElse {α : Type} (x : TacticM α) (y : UnitTacticM α) :
                                                                                        Equations
                                                                                          Instances For

                                                                                            Save the current tactic state for a token stx. This method is a no-op if stx has no position information. We use this method to save the tactic state at punctuation such as ;

                                                                                            Equations
                                                                                              Instances For
                                                                                                @[inline]
                                                                                                def Lean.Elab.Tactic.withMacroExpansion {α : Type} (beforeStx afterStx : Syntax) (x : TacticM α) :

                                                                                                Elaborate x with stx on the macro stack

                                                                                                Equations
                                                                                                  Instances For

                                                                                                    Adapt a syntax transformation to a regular tactic evaluator.

                                                                                                    Equations
                                                                                                      Instances For

                                                                                                        Add the given goal to the front of the current list of goals.

                                                                                                        Equations
                                                                                                          Instances For

                                                                                                            Add the given goals to the front of the current list of goals.

                                                                                                            Equations
                                                                                                              Instances For

                                                                                                                Add the given goals at the end of the current list of goals.

                                                                                                                Equations
                                                                                                                  Instances For

                                                                                                                    Discard the first goal and replace it by the given list of goals, keeping the other goals. This is used in conjunction with getMainGoal.

                                                                                                                    Contract: between getMainGoal and replaceMainGoal, nothing manipulates the goal list.

                                                                                                                    See also Lean.Elab.Tactic.popMainGoal and Lean.Elab.Tactic.pushGoal/Lean.Elab.Tactic.pushGoal for another interface.

                                                                                                                    Equations
                                                                                                                      Instances For

                                                                                                                        Return the first goal.

                                                                                                                        Equations
                                                                                                                          Instances For

                                                                                                                            Return the first goal, and remove it from the goal list.

                                                                                                                            See also: Lean.Elab.Tactic.pushGoal and Lean.Elab.Tactic.pushGoals.

                                                                                                                            Equations
                                                                                                                              Instances For

                                                                                                                                Return the main goal metavariable declaration.

                                                                                                                                Equations
                                                                                                                                  Instances For

                                                                                                                                    Return the main goal tag.

                                                                                                                                    Equations
                                                                                                                                      Instances For

                                                                                                                                        Return expected type for the main goal.

                                                                                                                                        Equations
                                                                                                                                          Instances For

                                                                                                                                            Execute x using the main goal local context and instances

                                                                                                                                            Equations
                                                                                                                                              Instances For

                                                                                                                                                Evaluate tac at mvarId, and return the list of resulting subgoals.

                                                                                                                                                Equations
                                                                                                                                                  Instances For

                                                                                                                                                    Like evalTacticAt, but without restoring the goal list or pruning solved goals. Useful when these tasks are already being done in an outer loop.

                                                                                                                                                    Equations
                                                                                                                                                      Instances For
                                                                                                                                                        Equations
                                                                                                                                                          Instances For
                                                                                                                                                            def Lean.Elab.Tactic.closeMainGoal (tacName : Name) (val : Expr) (checkUnassigned : Bool := true) :

                                                                                                                                                            Closes main goal using the given expression. If checkUnassigned == true, then val must not contain unassigned metavariables. Returns true if val was successfully used to close the goal.

                                                                                                                                                            Equations
                                                                                                                                                              Instances For
                                                                                                                                                                @[inline]
                                                                                                                                                                Equations
                                                                                                                                                                  Instances For
                                                                                                                                                                    @[inline]
                                                                                                                                                                    Equations
                                                                                                                                                                      Instances For
                                                                                                                                                                        @[inline]

                                                                                                                                                                        Get the mvarid of the main goal, run the given tactic, then set the new goals to be the resulting goal list.

                                                                                                                                                                        Equations
                                                                                                                                                                          Instances For
                                                                                                                                                                            @[inline]
                                                                                                                                                                            Equations
                                                                                                                                                                              Instances For
                                                                                                                                                                                @[inline]

                                                                                                                                                                                Analogue of liftMetaTactic for tactics that do not return any goals.

                                                                                                                                                                                Equations
                                                                                                                                                                                  Instances For
                                                                                                                                                                                    def Lean.Elab.Tactic.tryTactic? {α : Type} (tactic : TacticM α) :
                                                                                                                                                                                    Equations
                                                                                                                                                                                      Instances For
                                                                                                                                                                                        Equations
                                                                                                                                                                                          Instances For
                                                                                                                                                                                            def Lean.Elab.Tactic.tagUntaggedGoals (parentTag newSuffix : Name) (newGoals : List MVarId) :

                                                                                                                                                                                            Use parentTag to tag untagged goals at newGoals. If there are multiple new untagged goals, they are named using <parentTag>.<newSuffix>_<idx> where idx > 0. If there is only one new untagged goal, then we just use parentTag

                                                                                                                                                                                            Equations
                                                                                                                                                                                              Instances For
                                                                                                                                                                                                Equations
                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                    def Lean.Elab.Tactic.withCaseRef {m : TypeType} {α : Type} [Monad m] [MonadRef m] (arrow body : Syntax) (x : m α) :
                                                                                                                                                                                                    m α

                                                                                                                                                                                                    Use position of => $body for error messages. If there is a line break before body, the message will be displayed on => only, but the "full range" for the info view will still include body.

                                                                                                                                                                                                    Equations
                                                                                                                                                                                                      Instances For