Documentation

Lean.Environment

structure Lean.Import:
Type
Equations

A compacted region holds multiple Lean objects in a contiguous memory region, which can be read/written to/from disk. Objects inside the region do not have reference counters and cannot be freed individually. The contents of .olean files are compacted regions.

Equations
@[extern lean_compacted_region_is_memory_mapped]
@[extern lean_compacted_region_free]

Free a compacted region and its contents. No live references to the contents may exist at the time of invocation.

Equations
structure Lean.EnvironmentHeader:
Type
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.
@[export lean_environment_find]
Equations
@[export lean_environment_set_main_module]
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_environment_main_module]
Equations
Equations
Equations
Equations
  • One or more equations did not get rendered due to their size.
structure Lean.EnvExtensionInterfaceUnsafe.Ext (σ : Type) :
Type
  • idx : Nat
  • mkInitial : IO σ
Equations
  • Lean.EnvExtensionInterfaceUnsafe.instInhabitedExt = { default := { idx := default, mkInitial := default } }

User-defined environment extensions are declared using the initialize command. This command is just syntax sugar for the init attribute. When we import lean modules, the vector stored at envExtensionsRef may increase in size because of user-defined environment extensions. When this happens, we must adjust the size of the env.extensions. This method is invoked when processing imports.

Equations
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
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.
@[implementedBy Lean.EnvExtensionInterfaceUnsafe.imp]
@[export lean_mk_empty_environment]
Equations
  • One or more equations did not get rendered due to their size.
structure Lean.PersistentEnvExtensionState (α : Type) (σ : Type) :
Type
@[inline]
abbrev Lean.ImportM (α : Type) :
Type
Equations
structure Lean.PersistentEnvExtension (α : Type) (β : Type) (σ : Type) :
Type
Equations
  • Lean.instInhabitedPersistentEnvExtensionState = { default := { importedEntries := #[], state := default } }
instance Lean.instInhabitedPersistentEnvExtension {α : Type} {β : Type} {σ : Type} [inst : Inhabited σ] :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.PersistentEnvExtension.getModuleEntries {α : Type} {β : Type} {σ : Type} [inst : Inhabited σ] (ext : Lean.PersistentEnvExtension α β σ) (env : Lean.Environment) (m : Lean.ModuleIdx) :
Equations
def Lean.PersistentEnvExtension.addEntry {α : Type} {β : Type} {σ : Type} (ext : Lean.PersistentEnvExtension α β σ) (env : Lean.Environment) (b : β) :
Equations
  • One or more equations did not get rendered due to their size.
def Lean.PersistentEnvExtension.getState {α : Type} {β : Type} {σ : Type} [inst : Inhabited σ] (ext : Lean.PersistentEnvExtension α β σ) (env : Lean.Environment) :
σ
Equations
def Lean.PersistentEnvExtension.setState {α : Type} {β : Type} {σ : Type} (ext : Lean.PersistentEnvExtension α β σ) (env : Lean.Environment) (s : σ) :
Equations
def Lean.PersistentEnvExtension.modifyState {α : Type} {β : Type} {σ : Type} (ext : Lean.PersistentEnvExtension α β σ) (env : Lean.Environment) (f : σσ) :
Equations
structure Lean.PersistentEnvExtensionDescr (α : Type) (β : Type) (σ : Type) :
Type
unsafe def Lean.registerPersistentEnvExtensionUnsafe {α : Type} {β : Type} {σ : Type} [inst : Inhabited σ] (descr : Lean.PersistentEnvExtensionDescr α β σ) :
Equations
  • One or more equations did not get rendered due to their size.
@[implementedBy Lean.registerPersistentEnvExtensionUnsafe]
opaque Lean.registerPersistentEnvExtension {α : Type} {β : Type} {σ : Type} [inst : Inhabited σ] (descr : Lean.PersistentEnvExtensionDescr α β σ) :
@[specialize]
def Lean.mkStateFromImportedEntries {α : Type} {σ : Type} (addEntryFn : σασ) (initState : σ) (as : Array (Array α)) :
σ
Equations
structure Lean.SimplePersistentEnvExtensionDescr (α : Type) (σ : Type) :
Type
Equations
  • One or more equations did not get rendered due to their size.
Equations
Equations
Equations

Environment extension for tagging declarations. Declarations must only be tagged in the module where they were declared.

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.
def Lean.MapDeclarationExtension (α : Type) :
Type

Environment extension for mapping declarations to values. Declarations must only be inserted into the mapping in the module where they were declared.

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.
def Lean.MapDeclarationExtension.find? {α : Type} [inst : Inhabited α] (ext : Lean.MapDeclarationExtension α) (env : Lean.Environment) (declName : Lean.Name) :
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.
@[extern lean_save_module_data]
@[extern lean_read_module_data]
@[noinline, export lean_environment_free_regions]

Free compacted regions of imports. No live references to imported objects may exist at the time of invocation; in particular, env should be the last reference to any Environment derived from these imports.

Equations
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_write_module]
Equations
@[extern 2 lean_update_env_attributes]

"Forward declaration" needed for updating the attribute table with user-defined attributes. User-defined attributes are declared using the initialize command. The initialize command is just syntax sugar for the init attribute. The init attribute is initialized after the attributeExtension is initialized. We cannot change the order since the init attribute is an attribute, and requires this extension. The attributeExtension initializer uses attributeMapRef to initialize the attribute mapping. When we a new user-defined attribute declaration is imported, attributeMapRef is updated. Later, we set this method with code that adds the user-defined attributes that were imported after we initialized attributeExtension.

@[extern 1 lean_get_num_attributes]

"Forward declaration" for retrieving the number of builtin attributes.

structure Lean.ImportState:
Type
@[export lean_import_modules]
Equations
  • One or more equations did not get rendered due to their size.
unsafe def Lean.withImportModules {α : Type} (imports : List Lean.Import) (opts : Lean.Options) (trustLevel : optParam UInt32 0) (x : Lean.EnvironmentIO α) :
IO α

Create environment object from imports and free compacted regions after calling act. No live references to the environment object or imported objects may exist after act finishes.

Equations
Equations
  • One or more equations did not get rendered due to their size.
@[export lean_display_stats]
Equations
  • One or more equations did not get rendered due to their size.
@[extern lean_eval_const]
unsafe opaque Lean.Environment.evalConst (α : Type u_1) (env : Lean.Environment) (opts : Lean.Options) (constName : Lean.Name) :

Evaluate the given declaration under the given environment to a value of the given type. This function is only safe to use if the type matches the declaration's type in the environment and if enableInitializersExecution has been used before importing any modules.

unsafe def Lean.Environment.evalConstCheck (α : Type) (env : Lean.Environment) (opts : Lean.Options) (typeName : Lean.Name) (constName : Lean.Name) :

Like evalConst, but first check that constName indeed is a declaration of type typeName. Note that this function cannot guarantee that typeName is in fact the name of the type α.

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.
@[extern lean_kernel_is_def_eq]

Kernel isDefEq predicate. We use it mainly for debugging purposes. Recall that the Kernel type checker does not support metavariables. When implementing automation, consider using the MetaM methods.

@[extern lean_kernel_whnf]

Kernel WHNF function. We use it mainly for debugging purposes. Recall that the Kernel type checker does not support metavariables. When implementing automation, consider using the MetaM methods.

instance Lean.instMonadEnv (m : TypeType) (n : TypeType) [inst : MonadLift m n] [inst : Lean.MonadEnv m] :
Equations