The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Core
24 declarations. Mathlib docs · Source
Generally useful tactics.
def Lean.toModifiers E1 #
Lean.Name → optParam (Option (Lean.TSyntax `Lean.Parser.Command.docComment)) none → Lean.CoreM Lean.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.
def Lean.toPreDefinition E1 #
Lean.Name →
Lean.Name →
Lean.Expr →
Lean.Expr →
optParam (Option (Lean.TSyntax `Lean.Parser.Command.docComment)) none → Lean.CoreM Lean.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
def Lean.setProtected E1 #
{m : Type → Type} → [Lean.MonadEnv m] → Lean.Name → m Unit
Make nm protected.
def Lean.MVarId.rintroWithPats E1 #
Lean.MVarId →
List (Lean.TSyntax `rintroPat) →
optParam (Option ℕ) none → Lean.MetaM (List Lean.MVarId × List (Lean.TSyntax `rintroPat))
Introduce variables, using rintro patterns from a specified list.
def Mathlib.Tactic.withArgs E1 #
Lean.ParserDescr
def Mathlib.Tactic.usingArg E1 #
Lean.ParserDescr
def Mathlib.Tactic.getSimpArgs E1 #
Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)
Extract the arguments from a simpArgs syntax as an array of syntaxes
def Mathlib.Tactic.getDSimpArgs E1 #
Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)
Extract the arguments from a dsimpArgs syntax as an array of syntaxes
def Mathlib.Tactic.getWithArgs E1 #
Lean.Syntax → Lean.Elab.Tactic.TacticM (Array Lean.Syntax)
Extract the arguments from a withArgs syntax as an array of syntaxes
def Mathlib.Tactic.getUsingArg E1 #
Lean.Syntax → Lean.Elab.Tactic.TacticM Lean.Syntax
Extract the argument from a usingArg syntax as a syntax term
def Mathlib.Tactic.tacticRepeat1_ E1 #
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.
def Lean.Elab.Tactic.filterOutImplementationDetails E1 #
Lean.LocalContext → Array Lean.FVarId → Array Lean.FVarId
Given a local context and an array of FVarIds assumed to be in that local context, remove all
implementation details.
def Lean.Elab.Tactic.getFVarIdAt E1 #
Lean.MVarId → Lean.Syntax → Lean.Elab.Tactic.TacticM Lean.FVarId
Elaborate syntax for an FVarId in the local context of the given goal.
def Lean.Elab.Tactic.getFVarIdsAt E1 #
Lean.MVarId →
optParam (Option (Array Lean.Syntax)) none → optParam Bool false → Lean.Elab.Tactic.TacticM (Array Lean.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.
def Lean.Elab.Tactic.allGoals E1 #
Lean.Elab.Tactic.TacticM Unit → Lean.Elab.Tactic.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.)
def Lean.Elab.Tactic.andThenOnSubgoals E1 #
Lean.Elab.Tactic.TacticM Unit → Lean.Elab.Tactic.TacticM Unit → Lean.Elab.Tactic.TacticM Unit
Simulates the <;> tactic combinator.
First runs tac1 and then runs tac2 on all newly-generated subgoals.
def Lean.Elab.Tactic.iterateAtMost E1 #
{m : Type → Type u} → [Monad m] → [MonadExcept Lean.Exception m] → ℕ → m Unit → m Unit
Repeats a tactic at most n times, stopping sooner if the
tactic fails. Always succeeds.
def Lean.Elab.Tactic.iterateExactly' E1 #
{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.
def Lean.Elab.Tactic.iterateRange E1 #
{m : Type → Type u} → [Monad m] → [MonadExcept Lean.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.
opaque Lean.Elab.Tactic.iterateUntilFailure E1 #
{m : Type → Type u} → [Monad m] → [MonadExcept Lean.Exception m] → m Unit → m Unit
Repeats a tactic until it fails. Always succeeds.
opaque Lean.Elab.Tactic.iterateUntilFailureWithResults E1 #
{m : Type → Type u} → [Monad m] → [MonadExcept Lean.Exception m] → {α : Type} → 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 E1 #
{m : Type → Type u} → [Monad m] → [MonadExcept Lean.Exception m] → {α : Type} → m α → m ℕ
iterateUntilFailureCount is similar to iterateUntilFailure except it counts
the number of successful calls to tac. Always succeeds.
def Mathlib.getPackageDir E1 #
String → IO System.FilePath
Returns the root directory which contains the package root file, e.g. Mathlib.lean.
def Mathlib.getMathlibDir E1 #
IO System.FilePath
Returns the mathlib root directory.