# Documentation

Lean.Elab.Tactic.ElabTerm

# elabTerm for Tactics and basic tactics that use it. #

def Lean.Elab.Tactic.runTermElab {α : Type} (k : ) (mayPostpone : ) :

Runs a term elaborator inside a tactic.

This function ensures that term elaboration fails when backtracking, i.e., in first| tac term | other.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.runTermElab.go {α : Type} (k : ) (mayPostpone : ) :
Equations
def Lean.Elab.Tactic.elabTerm (stx : Lean.Syntax) (expectedType? : ) (mayPostpone : ) :

Elaborate stx in the current MVarContext. If given, the expectedType will be used to help elaboration but not enforced (use elabTermEnsuringType to enforce an expected type).

Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.elabTermEnsuringType (stx : Lean.Syntax) (expectedType? : ) (mayPostpone : ) :

Elaborate stx in the current MVarContext. If given, the expectedType will be used to help elaboration and then a TypeMismatchError will be thrown if the elaborated type doesn't match.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.closeMainGoalUsing (checkUnassigned : ) :

Try to close main goal using x target, where target is the type of the main goal.

Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.filterOldMVars (mvarIds : ) (mvarCounterSaved : Nat) :
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.sortMVarIdArrayByIndex {m : } [inst : ] [inst : ] (mvarIds : ) :
m ()
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.sortMVarIdsByIndex {m : } [inst : ] [inst : ] (mvarIds : ) :
m ()
Equations
def Lean.Elab.Tactic.withCollectingNewGoalsFrom (tagSuffix : Lean.Name) (allowNaturalHoles : ) :

Execute k, and collect new "holes" in the resulting expression.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.withCollectingNewGoalsFrom.go (tagSuffix : Lean.Name) (allowNaturalHoles : ) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.elabTermWithHoles (stx : Lean.Syntax) (expectedType? : ) (tagSuffix : Lean.Name) (allowNaturalHoles : ) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.refineCore (stx : Lean.Syntax) (tagSuffix : Lean.Name) (allowNaturalHoles : Bool) :

If allowNaturalHoles == true, then we allow the resultant expression to contain unassigned "natural" metavariables. Recall that "natutal" metavariables are created for explicit holes _ and implicit arguments. They are meant to be filled by typing constraints. "Synthetic" metavariables are meant to be filled by tactics and are usually created using the synthetic hole notation ?.

Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.elabTermForApply (stx : Lean.Syntax) (mayPostpone : ) :

Given a tactic

apply f


we want the apply tactic to create all metavariables. The following definition will return @f for f. That is, it will not create metavariables for implicit arguments. A similar method is also used in Lean 3. This method is useful when applying lemmas such as:

theorem infLeRight {s t : Set α} : s ⊓ t ≤ t
⊓ t ≤ t
≤ t


where s ≤ t≤ t here is defined as

∀ {x : α}, x ∈ s → x ∈ t
∀ {x : α}, x ∈ s → x ∈ t
∈ s → x ∈ t
→ x ∈ t
∈ t

Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.Tactic.elabAsFVar (stx : Lean.Syntax) (userName? : optParam () none) :

Elaborate stx. If it a free variable, return it. Otherwise, assert it, and return the free variable. Note that, the main goal is updated when Meta.assert is used in the second case.

Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.