The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.Basic

16 declarations. Mathlib docs · Source

Basic tactics and utilities for tactic writing

This file defines some basic utilities for tactic writing, and also

  • a dummy variables macro (which warns that the Lean 4 name is variable)
  • the introv tactic, which allows the user to automatically introduce the variables of a theorem and explicitly name the non-dependent hypotheses,
  • an assumption macro, calling the assumption tactic on all goals
  • the tactics match_target and clear_aux_decl (clearing all auxiliary declarations from the context).

def Mathlib.Tactic.withResetServerInfo.Result.ctorIdx E1 #

{α : Type} → Mathlib.Tactic.withResetServerInfo.Result α → ℕ

theorem Mathlib.Tactic.withResetServerInfo.Result.mk.inj E1 #

∀ {α : Type} {result? : Option α} {msgs : Lean.MessageLog} {trees : Lean.PersistentArray Lean.Elab.InfoTree}
  {result?_1 : Option α} {msgs_1 : Lean.MessageLog} {trees_1 : Lean.PersistentArray Lean.Elab.InfoTree},
  { result? := result?, msgs := msgs, trees := trees } = { result? := result?_1, msgs := msgs_1, trees := trees_1 } →
    result? = result?_1 ∧ msgs = msgs_1 ∧ trees = trees_1

theorem Mathlib.Tactic.withResetServerInfo.Result.mk.injEq E0 #

∀ {α : Type} (result? : Option α) (msgs : Lean.MessageLog) (trees : Lean.PersistentArray Lean.Elab.InfoTree)
  (result?_1 : Option α) (msgs_1 : Lean.MessageLog) (trees_1 : Lean.PersistentArray Lean.Elab.InfoTree),
  ({ result? := result?, msgs := msgs, trees := trees } = { result? := result?_1, msgs := msgs_1, trees := trees_1 }) =
    (result? = result?_1 ∧ msgs = msgs_1 ∧ trees = trees_1)

def Mathlib.Tactic.variables E1 #

Lean.ParserDescr

Syntax for the variables command: this command is just a stub, and merely warns that it has been renamed to variable in Lean 4.

def Mathlib.Tactic.elabVariables E1 #

Lean.Elab.Command.CommandElab

The variables command: this is just a stub, and merely warns that it has been renamed to variable in Lean 4.

def Mathlib.Tactic.pushFVarAliasInfo E1 #

{m : Type → Type} →
  [Monad m] → [Lean.Elab.MonadInfoTree m] → Array Lean.FVarId → Array Lean.FVarId → Lean.LocalContext → m Unit

Given two arrays of FVarIds, one from an old local context and the other from a new local context, pushes FVarAliasInfos into the info tree for corresponding pairs of FVarIds. Recall that variables linked this way should be considered to be semantically identical.

The effect of this is, for example, the unused variable linter will see that variables from the first array are used if corresponding variables in the second array are used.

def Mathlib.Tactic.introv E1 #

Lean.ParserDescr

introv introduces the parameters to a dependent function according to their parameter name. If the first parameter is not depended on by the rest of the function type, introv with no (remaining) arguments does nothing.

  • introv h₁ h₂ ... introduces non-depended-on parameters in between sequences of depended-on parameters, using the names h₁, h₂, ... in turn. Use _ to anonymize a specific hypothesis.

Examples:

example : ∀ a b : Nat, a = b → b = a := by
  introv h
  /-
  The goal state is:
  a b : ℕ,
  h : a = b
  ⊢ b = a
  -/
  exact h.symm
example : ∀ a b : Nat, a = b → ∀ c, b = c → a = c := by
  introv h₁ h₂
  /-
  The goal state is:
  a b : ℕ,
  h₁ : a = b,
  c : ℕ,
  h₂ : b = c
  ⊢ a = c
  -/
  exact h₁.trans h₂

def Mathlib.Tactic.evalIntrov E1 #

Lean.Elab.Tactic.Tactic

def Mathlib.Tactic.tacticAssumption' E1 #

Lean.ParserDescr

Try calling assumption on all goals; succeeds if it closes at least one goal.

def Mathlib.Tactic.clearAuxDecl E1 #

Lean.ParserDescr

This tactic clears all auxiliary declarations from the context.

structure Mathlib.Tactic.withResetServerInfo.Result E1 #

Type → Type

Result of withResetServerInfo.

ctor Mathlib.Tactic.withResetServerInfo.Result.mk E0 #

{α : Type} →
  Option α → Lean.MessageLog → Lean.PersistentArray Lean.Elab.InfoTree → Mathlib.Tactic.withResetServerInfo.Result α

abbrev Mathlib.Tactic.withResetServerInfo.Result.result? E1 #

{α : Type} → Mathlib.Tactic.withResetServerInfo.Result α → Option α

Return value of the executed tactic.

abbrev Mathlib.Tactic.withResetServerInfo.Result.msgs E1 #

{α : Type} → Mathlib.Tactic.withResetServerInfo.Result α → Lean.MessageLog

Messages produced by the executed tactic.

abbrev Mathlib.Tactic.withResetServerInfo.Result.trees E1 #

{α : Type} → Mathlib.Tactic.withResetServerInfo.Result α → Lean.PersistentArray Lean.Elab.InfoTree

Info trees produced by the executed tactic, wrapped in CommandContextInfo.save.

def Mathlib.Tactic.withResetServerInfo E1 #

{α : Type} → Lean.Elab.Tactic.TacticM α → Lean.Elab.Tactic.TacticM (Mathlib.Tactic.withResetServerInfo.Result α)

Runs a tactic, returning any new messages and info trees rather than adding them to the state.