Documentation

Lean.LocalContext

inductive Lean.LocalDecl:
Type

A declaration for a LocalContext. This is used to register which free variables are in scope. Each declaration comes with

  • index the position of the decl in the local context
  • fvarId the unique id of the free variables
  • userName the pretty-printable name of the variable
  • type the type. A cdecl is a local variable, a ldecl is a let-bound free variable with a value : Expr.
Equations
@[export lean_mk_local_decl]
def Lean.mkLocalDeclEx (index : Nat) (fvarId : Lean.FVarId) (userName : Lean.Name) (type : Lean.Expr) (bi : Lean.BinderInfo) :
Equations
@[export lean_mk_let_decl]
def Lean.mkLetDeclEx (index : Nat) (fvarId : Lean.FVarId) (userName : Lean.Name) (type : Lean.Expr) (val : Lean.Expr) :
Equations
@[export lean_local_decl_binder_info]
Equations
Equations
Equations
Equations
  • One or more equations did not get rendered due to their size.
Equations
Equations
Equations
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
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
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.
structure Lean.LocalContext:
Type

A LocalContext is an ordered set of local variable declarations. It is used to store the free variables (also known as local constants) that are in scope.

When inspecting a goal or expected type in the infoview, the local context is all of the variables above the symbol.

Equations
@[export lean_mk_empty_local_ctx]
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.
@[export lean_local_ctx_is_empty]
Equations
@[export lean_local_ctx_mk_local_decl]

Low level API for creating local declarations. It is used to implement actions in the monads Elab and Tactic. It should not be used directly since the argument (fvarId : FVarId) is assumed to be unique. You can create a unique fvarId with mkFreshFVarId.

Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_mk_let_decl]

Low level API for let declarations. Do not use directly.

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

Low level API for adding a local declaration. Do not use directly.

Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_find]
Equations
Equations
  • One or more equations did not get rendered due to their size.

Gets the declaration for expression e in the local context. If e is not a free variable or not present then panics.

Equations

Returns true when the lctx contains the free variable e. Panics if e is not an fvar.

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

Return all of the free variables in the given context.

Equations
@[export lean_local_ctx_erase]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_pop]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_find_from_user_name]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_uses_user_name]
Equations
@[export lean_local_ctx_get_unused_name]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_last_decl]
Equations
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_rename_user_name]
Equations
  • One or more equations did not get rendered due to their size.
@[inline]

Low-level function for updating the local context. Assumptions about f, the resulting nested expressions must be definitionally equal to their original values, the index nor fvarId are modified.

Equations
  • One or more equations did not get rendered due to their size.
@[export lean_local_ctx_num_indices]
Equations
@[export lean_local_ctx_get]
Equations
@[specialize]
def Lean.LocalContext.foldlM {m : Type u_1Type u_2} {β : Type u_1} [inst : Monad m] (lctx : Lean.LocalContext) (f : βLean.LocalDeclm β) (init : β) (start : optParam Nat 0) :
m β
Equations
  • One or more equations did not get rendered due to their size.
@[specialize]
def Lean.LocalContext.foldrM {m : Type u_1Type u_2} {β : Type u_1} [inst : Monad m] (lctx : Lean.LocalContext) (f : Lean.LocalDeclβm β) (init : β) :
m β
Equations
@[specialize]
def Lean.LocalContext.forM {m : Type u_1Type u_2} [inst : Monad m] (lctx : Lean.LocalContext) (f : Lean.LocalDeclm PUnit) :
Equations
@[specialize]
def Lean.LocalContext.findDeclM? {m : Type u_1Type u_2} {β : Type u_1} [inst : Monad m] (lctx : Lean.LocalContext) (f : Lean.LocalDeclm (Option β)) :
m (Option β)
Equations
@[specialize]
def Lean.LocalContext.findDeclRevM? {m : Type u_1Type u_2} {β : Type u_1} [inst : Monad m] (lctx : Lean.LocalContext) (f : Lean.LocalDeclm (Option β)) :
m (Option β)
Equations
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
def Lean.LocalContext.foldl {β : Type u_1} (lctx : Lean.LocalContext) (f : βLean.LocalDeclβ) (init : β) (start : optParam Nat 0) :
β
Equations
@[inline]
def Lean.LocalContext.foldr {β : Type u_1} (lctx : Lean.LocalContext) (f : Lean.LocalDeclββ) (init : β) :
β
Equations
Equations
@[inline]
Equations
  • One or more equations did not get rendered due to their size.

Creates the expression fun x₁ .. xₙ => b for free variables xs = #[x₁, .., xₙ], suitably abstracting b and the types for each of the xᵢ.

Equations

Creates the expression (x₁:α₁) → .. → (xₙ:αₙ) → b for free variables xs = #[x₁, .., xₙ], suitably abstracting b and the types for each of the xᵢ, αᵢ.

Equations
@[inline]
def Lean.LocalContext.anyM {m : TypeType u_1} [inst : Monad m] (lctx : Lean.LocalContext) (p : Lean.LocalDeclm Bool) :
Equations
@[inline]
def Lean.LocalContext.allM {m : TypeType u_1} [inst : Monad m] (lctx : Lean.LocalContext) (p : Lean.LocalDeclm Bool) :
Equations
Equations
  • One or more equations did not get rendered due to their size.
class Lean.MonadLCtx (m : TypeType) :
Type

Class used to denote that m has a local context.

Instances
instance Lean.instMonadLCtx {m : TypeType} {n : TypeType} [inst : MonadLift m n] [inst : Lean.MonadLCtx m] :
Equations
  • Lean.instMonadLCtx = { getLCtx := liftM Lean.getLCtx }
Equations
  • One or more equations did not get rendered due to their size.