# Documentation

Std.Lean.Meta.Basic

Set the kind of a LocalDecl.

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

Set the kind of the given fvar.

Equations

Sort the given FVarIds by the order in which they appear in lctx. If any of the FVarIds do not appear in lctx, the result is unspecified.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Meta.sortFVarsByContextOrder {m : } [inst : ] [inst : ] (hyps : ) :
m ()

Sort the given FVarIds by the order in which they appear in the current local context. If any of the FVarIds do not appear in the current local context, the result is unspecified.

Equations
def Lean.MetavarContext.getExprMVarDecl {m : } [inst : ] [inst : ] (mctx : Lean.MetavarContext) (mvarId : Lean.MVarId) :

Get the MetavarDecl of mvarId. If mvarId is not a declared metavariable in the given MetavarContext, throw an error.

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

Declare a metavariable. You must make sure that the metavariable is not already declared.

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

Check whether a metavariable is assigned or delayed-assigned. A delayed-assigned metavariable is already 'solved' but the solution cannot be substituted yet because we have to wait for some other metavariables to be assigned first. So in most situations you want to treat a delayed-assigned metavariable as assigned.

Equations

Check whether a metavariable is declared in the given MetavarContext.

Equations

Add a delayed assignment for the given metavariable. You must make sure that the metavariable is not already assigned or delayed-assigned.

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

Erase any assignment or delayed assignment of the given metavariable.

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

Modify the declaration of a metavariable. If the metavariable is not declared, the MetavarContext is returned unchanged.

You must ensure that the modification is legal. In particular, expressions may only be replaced with defeq expressions.

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

Modify the local context of a metavariable. If the metavariable is not declared, the MetavarContext is returned unchanged.

You must ensure that the modification is legal. In particular, expressions may only be replaced with defeq expressions.

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

Set the kind of an fvar. If the given metavariable is not declared or the given fvar doesn't exist in its context, the MetavarContext is returned unchanged.

Equations

Set the BinderInfo of an fvar. If the given metavariable is not declared or the given fvar doesn't exist in its context, the MetavarContext is returned unchanged.

Equations

Obtain all unassigned metavariables from the given MetavarContext. If includeDelayed is true, delayed-assigned metavariables are considered unassigned.

Equations
• One or more equations did not get rendered due to their size.
def Lean.MVarId.isAssignedOrDelayedAssigned {m : } [inst : ] [inst : ] (mvarId : Lean.MVarId) :

Check whether a metavariable is assigned or delayed-assigned. A delayed-assigned metavariable is already 'solved' but the solution cannot be substituted yet because we have to wait for some other metavariables to be assigned first. So in most situations you want to treat a delayed-assigned metavariable as assigned.

Equations
def Lean.MVarId.isDeclared {m : } [inst : ] [inst : ] (mvarId : Lean.MVarId) :

Check whether a metavariable is declared.

Equations
def Lean.MVarId.delayedAssign {m : } [inst : ] (mvarId : Lean.MVarId) :

Add a delayed assignment for the given metavariable. You must make sure that the metavariable is not already assigned or delayed-assigned.

Equations
def Lean.MVarId.eraseAssignment {m : } [inst : ] (mvarId : Lean.MVarId) :

Erase any assignment or delayed assignment of the given metavariable.

Equations
def Lean.MVarId.modifyDecl {m : } [inst : ] (mvarId : Lean.MVarId) (f : ) :

Modify the declaration of a metavariable. If the metavariable is not declared, nothing happens.

You must ensure that the modification is legal. In particular, expressions may only be replaced with defeq expressions.

Equations
def Lean.MVarId.modifyLCtx {m : } [inst : ] (mvarId : Lean.MVarId) :

Modify the local context of a metavariable. If the metavariable is not declared, nothing happens.

You must ensure that the modification is legal. In particular, expressions may only be replaced with defeq expressions.

Equations
def Lean.MVarId.setFVarKind {m : } [inst : ] (mvarId : Lean.MVarId) (fvarId : Lean.FVarId) (kind : Lean.LocalDeclKind) :

Set the kind of an fvar. If the given metavariable is not declared or the given fvar doesn't exist in its context, nothing happens.

Equations
def Lean.MVarId.setFVarBinderInfo {m : } [inst : ] (mvarId : Lean.MVarId) (fvarId : Lean.FVarId) (bi : Lean.BinderInfo) :

Set the BinderInfo of an fvar. If the given metavariable is not declared or the given fvar doesn't exist in its context, nothing happens.

Equations
def Lean.MVarId.getMVarDependencies (mvarId : Lean.MVarId) (includeDelayed : ) :

Collect the metavariables which mvarId depends on. These are the metavariables which appear in the type and local context of mvarId, as well as the metavariables which those metavariables depend on, etc.

Equations
partial def Lean.MVarId.getMVarDependencies.addMVars (includeDelayed : ) (e : Lean.Expr) :

Auxiliary definition for getMVarDependencies.

partial def Lean.MVarId.getMVarDependencies.go (includeDelayed : ) (mvarId : Lean.MVarId) :

Auxiliary definition for getMVarDependencies.

def Lean.Meta.getUnassignedExprMVars {m : } [inst : ] [inst : ] (includeDelayed : ) :
m ()

Obtain all unassigned metavariables. If includeDelayed is true, delayed-assigned metavariables are considered unassigned.

Equations
def Lean.Meta.unhygienic {m : } {α : Type} [inst : ] (x : m α) :
m α

Run a computation with hygiene turned off.

Equations
def Lean.Meta.mkFreshIdWithPrefix {m : } [inst : ] [inst : ] (prefix : Lean.Name) :

A variant of mkFreshId which generates names with a particular prefix. The generated names are unique and have the form . where N is a natural number. They are not suitable as user-facing names.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Meta.repeat' {m : } [inst : ] [inst : ] [inst : ] (f : ) (gs : ) (maxIters : optParam Nat 100000) :
m ()

repeat' f runs f on all of the goals to produce a new list of goals, then runs f again on all of those goals, and repeats until f fails on all remaining goals, or until maxIters total calls to f have occurred.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Meta.repeat'.go {m : } [inst : ] [inst : ] [inst : ] (f : ) :
Nat

Auxiliary for repeat'. repeat'.go f maxIters gs stk acc evaluates to essentially acc.toList ++ repeat' f (gs::stk).join maxIters: that is, acc are goals we will not revisit, and (gs::stk).join is the accumulated todo list of subgoals.

Equations
def Lean.Meta.saturate1 {m : } [inst : ] [inst : ] [inst : ] [inst : ] (goal : Lean.MVarId) (tac : Lean.MVarIdm ()) :
m ()

saturate1 goal tac runs tac on goal, then on the resulting goals, etc., until tac does not apply to any goal any more (i.e. it returns none). The order of applications is depth-first, so if tac generates goals [g₁, g₂, ⋯]⋯], we apply tac to g₁ and recursively to all its subgoals before visiting g₂. If tac does not apply to goal, saturate1 returns none. Otherwise it returns the generated subgoals to which tac did not apply. saturate1 respects the MonadRecDepth recursion limit.

Equations
• One or more equations did not get rendered due to their size.
partial def Lean.Meta.saturate1.go {m : } [inst : ] [inst : ] [inst : ] [inst : ] (tac : Lean.MVarIdm ()) (acc : ) (goal : Lean.MVarId) :

Auxiliary definition for saturate1.