Documentation

Mathlib.Tactic.Core

Generally useful tactics. #

def Lean.toModifiers (nm : Name) (newDoc : Option (TSyntax `Lean.Parser.Command.docComment) := none) :
CoreM Elab.Modifiers

Return the modifiers of declaration nm with (optional) docstring newDoc. Currently, recursive or partial definitions are not supported, and no attributes are provided.

Instances For
    def Lean.toPreDefinition (nm newNm : Name) (newType newValue : Expr) (newDoc : Option (TSyntax `Lean.Parser.Command.docComment) := none) :
    CoreM Elab.PreDefinition

    Make a PreDefinition taking some metadata from declaration nm. You can provide a new type, value and (optional) docstring, but the remaining information is taken from nm. Currently only implemented for definitions and theorems. Also see docstring of toModifiers

    Instances For
      def Lean.setProtected {m : Type → Type} [MonadEnv m] (nm : Name) :
      m Unit

      Make nm protected.

      Instances For
        def Lean.MVarId.introsWithBinderIdents (g : MVarId) (ids : List (TSyntax `Lean.binderIdent)) (maxIntros? : Option â„• := none) :
        MetaM (List (TSyntax `Lean.binderIdent) × Array FVarId × MVarId)

        Introduce variables, giving them names from a specified list.

        Instances For
          def Mathlib.Tactic.withArgs :
          Lean.ParserDescr
          Instances For
            def Mathlib.Tactic.usingArg :
            Lean.ParserDescr
            Instances For
              def Mathlib.Tactic.getSimpArgs :
              Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)

              Extract the arguments from a simpArgs syntax as an array of syntaxes

              Instances For
                def Mathlib.Tactic.getDSimpArgs :
                Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)

                Extract the arguments from a dsimpArgs syntax as an array of syntaxes

                Instances For
                  def Mathlib.Tactic.getWithArgs :
                  Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)

                  Extract the arguments from a withArgs syntax as an array of syntaxes

                  Instances For
                    def Mathlib.Tactic.getUsingArg :
                    Lean.Syntax → Lean.Elab.Tactic.TacticM Lean.Syntax

                    Extract the argument from a usingArg syntax as a syntax term

                    Instances For
                      def Mathlib.Tactic.tacticRepeat1_ :
                      Lean.ParserDescr

                      repeat1 tac applies tac to main goal at least once. If the application succeeds, the tactic is applied recursively to the generated subgoals until it eventually fails.

                      Instances For
                        def Lean.Elab.Tactic.filterOutImplementationDetails (lctx : LocalContext) (fvarIds : Array FVarId) :
                        Array FVarId

                        Given a local context and an array of FVarIds assumed to be in that local context, remove all implementation details.

                        Instances For
                          def Lean.Elab.Tactic.getFVarIdAt (goal : MVarId) (id : Syntax) :
                          TacticM FVarId

                          Elaborate syntax for an FVarId in the local context of the given goal.

                          Instances For
                            def Lean.Elab.Tactic.getFVarIdsAt (goal : MVarId) (ids : Option (Array Syntax) := none) (includeImplementationDetails : Bool := false) :
                            TacticM (Array FVarId)

                            Get the array of FVarIds in the local context of the given goal.

                            If ids is specified, elaborate them in the local context of the given goal to obtain the array of FVarIds.

                            If includeImplementationDetails is false (the default), we filter out implementation details (implDecls and auxDecls) from the resulting list of FVarIds.

                            Instances For
                              def Lean.Elab.Tactic.allGoals (tac : TacticM Unit) :
                              TacticM Unit

                              Run a tactic on all goals, and always succeeds.

                              (This is parallel to Lean.Elab.Tactic.evalAllGoals in core, which takes a Syntax rather than TacticM Unit. This function could be moved to core and evalAllGoals refactored to use it.)

                              Instances For
                                def Lean.Elab.Tactic.andThenOnSubgoals (tac1 tac2 : TacticM Unit) :
                                TacticM Unit

                                Simulates the <;> tactic combinator. First runs tac1 and then runs tac2 on all newly-generated subgoals.

                                Instances For
                                  def Lean.Elab.Tactic.iterateAtMost {m : Type → Type u} [Monad m] [MonadExcept Exception m] :
                                  ℕ → m Unit → m Unit

                                  Repeats a tactic at most n times, stopping sooner if the tactic fails. Always succeeds.

                                  Instances For
                                    def Lean.Elab.Tactic.iterateExactly' {m : Type → Type u} [Monad m] :
                                    ℕ → m Unit → m Unit

                                    iterateExactly' n t executes t n times. If any iteration fails, the whole tactic fails.

                                    Instances For
                                      def Lean.Elab.Tactic.iterateRange {m : Type → Type u} [Monad m] [MonadExcept Exception m] :
                                      ℕ → ℕ → m Unit → m Unit

                                      iterateRange m n t: Repeat the given tactic at least m times and at most n times or until t fails. Fails if t does not run at least m times.

                                      Instances For
                                        partial def Lean.Elab.Tactic.iterateUntilFailure {m : Type → Type u} [Monad m] [MonadExcept Exception m] (tac : m Unit) :
                                        m Unit

                                        Repeats a tactic until it fails. Always succeeds.

                                        partial def Lean.Elab.Tactic.iterateUntilFailureWithResults {m : Type → Type u} [Monad m] [MonadExcept Exception m] {α : Type} (tac : m α) :
                                        m (List α)

                                        iterateUntilFailureWithResults is a helper tactic which accumulates the list of results obtained from iterating tac until it fails. Always succeeds.

                                        def Lean.Elab.Tactic.iterateUntilFailureCount {m : Type → Type u} [Monad m] [MonadExcept Exception m] {α : Type} (tac : m α) :
                                        m â„•

                                        iterateUntilFailureCount is similar to iterateUntilFailure except it counts the number of successful calls to tac. Always succeeds.

                                        Instances For
                                          def Mathlib.getPackageDir (pkg : String) :
                                          IO System.FilePath

                                          Returns the root directory which contains the package root file, e.g. Mathlib.lean.

                                          Instances For
                                            def Mathlib.getMathlibDir :
                                            IO System.FilePath

                                            Returns the mathlib root directory.

                                            Instances For