Equations
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
Free a compacted region and its contents. No live references to the contents may exist at the time of invocation.
- imports : Array Lean.Import
- constants : Array Lean.ConstantInfo
- entries : Array (Lean.Name × Array Lean.EnvExtensionEntry)
Equations
- Lean.instInhabitedModuleData = { default := { imports := default, constants := default, entries := default } }
- trustLevel : UInt32
- quotInit : Bool
- mainModule : Lean.Name
- imports : Array Lean.Import
- regions : Array Lean.CompactedRegion
- moduleData : Array Lean.ModuleData
Equations
- One or more equations did not get rendered due to their size.
- const2ModIdx : Std.HashMap Lean.Name Lean.ModuleIdx
- constants : Lean.ConstMap
- extensions : Array Lean.EnvExtensionState
- header : Lean.EnvironmentHeader
Equations
- Lean.instInhabitedEnvironment = { default := { const2ModIdx := default, constants := default, extensions := default, header := default } }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Environment.find? env n = Lean.SMap.find?' env.constants n
Equations
- Lean.Environment.contains env n = Lean.SMap.contains env.constants n
Equations
- Lean.Environment.imports env = env.header.imports
Equations
- Lean.Environment.allImportedModuleNames env = env.header.moduleNames
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Environment.mainModule env = env.header.mainModule
Equations
- Lean.Environment.getModuleIdxFor? env declName = Std.HashMap.find? env.const2ModIdx declName
Equations
- Lean.Environment.isConstructor env declName = match Lean.Environment.find? env declName with | some (Lean.ConstantInfo.ctorInfo val) => true | x => false
Equations
- Lean.Environment.getModuleIdx? env moduleName = Array.findIdx? env.header.moduleNames fun a => a == moduleName
- unknownConstant: Lean.Environment → Lean.Name → Lean.KernelException
- alreadyDeclared: Lean.Environment → Lean.Name → Lean.KernelException
- declTypeMismatch: Lean.Environment → Lean.Declaration → Lean.Expr → Lean.KernelException
- declHasMVars: Lean.Environment → Lean.Name → Lean.Expr → Lean.KernelException
- declHasFVars: Lean.Environment → Lean.Name → Lean.Expr → Lean.KernelException
- funExpected: Lean.Environment → Lean.LocalContext → Lean.Expr → Lean.KernelException
- typeExpected: Lean.Environment → Lean.LocalContext → Lean.Expr → Lean.KernelException
- letTypeMismatch: Lean.Environment → Lean.LocalContext → Lean.Name → Lean.Expr → Lean.Expr → Lean.KernelException
- exprTypeMismatch: Lean.Environment → Lean.LocalContext → Lean.Expr → Lean.Expr → Lean.KernelException
- appTypeMismatch: Lean.Environment → Lean.LocalContext → Lean.Expr → Lean.Expr → Lean.Expr → Lean.KernelException
- invalidProj: Lean.Environment → Lean.LocalContext → Lean.Expr → Lean.KernelException
- other: String → Lean.KernelException
Equations
- Lean.Environment.addAndCompile env opt decl = do let env ← Lean.Environment.addDecl env decl Lean.Environment.compileDecl env opt decl
- ext : Type → Type
- setState : {σ : Type} → ext σ → Lean.Environment → σ → Lean.Environment
- modifyState : {σ : Type} → ext σ → Lean.Environment → (σ → σ) → Lean.Environment
- getState : {σ : Type} → [inst : Inhabited σ] → ext σ → Lean.Environment → σ
- mkInitialExtStates : IO (Array Lean.EnvExtensionState)
- ensureExtensionsSize : Lean.Environment → IO Lean.Environment
Equations
- One or more equations did not get rendered due to their size.
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 import
s.
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.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.EnvExtensionInterfaceUnsafe.mkInitialExtStates = do let exts ← ST.Ref.get Lean.EnvExtensionInterfaceUnsafe.envExtensionsRef Array.mapM (fun ext => ext.mkInitial) exts
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.EnvExtension.instInhabitedEnvExtension = Lean.EnvExtensionInterface.inhabitedExt Lean.EnvExtensionInterfaceImp s
Equations
- Lean.EnvExtension.setState ext env s = Lean.EnvExtensionInterface.setState Lean.EnvExtensionInterfaceImp ext env s
Equations
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- state : σ
Equations
- toEnvExtension : Lean.EnvExtension (Lean.PersistentEnvExtensionState α σ)
- name : Lean.Name
- addImportedFn : Array (Array α) → Lean.ImportM σ
- addEntryFn : σ → β → σ
- exportEntriesFn : σ → Array α
- statsFn : σ → Lean.Format
Equations
- Lean.instInhabitedPersistentEnvExtensionState = { default := { importedEntries := #[], state := default } }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PersistentEnvExtension.getModuleEntries ext env m = Array.get! (Lean.EnvExtension.getState ext.toEnvExtension env).importedEntries m
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PersistentEnvExtension.getState ext env = (Lean.EnvExtension.getState ext.toEnvExtension env).state
Equations
- Lean.PersistentEnvExtension.setState ext env s = Lean.EnvExtension.modifyState ext.toEnvExtension env fun ps => { importedEntries := ps.importedEntries, state := s }
Equations
- Lean.PersistentEnvExtension.modifyState ext env f = Lean.EnvExtension.modifyState ext.toEnvExtension env fun ps => { importedEntries := ps.importedEntries, state := f ps.state }
- name : Lean.Name
- mkInitial : IO σ
- addImportedFn : Array (Array α) → Lean.ImportM σ
- addEntryFn : σ → β → σ
- exportEntriesFn : σ → Array α
- statsFn : σ → Lean.Format
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.SimplePersistentEnvExtension α σ = Lean.PersistentEnvExtension α α (List α × σ)
Equations
- Lean.mkStateFromImportedEntries addEntryFn initState as = Array.foldl (fun r es => Array.foldl (fun r e => addEntryFn r e) r es 0 (Array.size es)) initState as 0 (Array.size as)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.SimplePersistentEnvExtension.instInhabitedSimplePersistentEnvExtension = inferInstanceAs (Inhabited (Lean.PersistentEnvExtension α α (List α × σ)))
Equations
- Lean.SimplePersistentEnvExtension.getEntries ext env = (Lean.PersistentEnvExtension.getState ext env).fst
Equations
- Lean.SimplePersistentEnvExtension.getState ext env = (Lean.PersistentEnvExtension.getState ext env).snd
Equations
- Lean.SimplePersistentEnvExtension.setState ext env s = Lean.PersistentEnvExtension.modifyState ext env fun x => match x with | (entries, snd) => (entries, s)
Equations
- Lean.SimplePersistentEnvExtension.modifyState ext env f = Lean.PersistentEnvExtension.modifyState ext env fun x => match x with | (entries, s) => (entries, f s)
Environment extension for tagging declarations. Declarations must only be tagged in the module where they were declared.
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.
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
- Lean.MapDeclarationExtension.instInhabitedMapDeclarationExtension = inferInstanceAs (Inhabited (Lean.SimplePersistentEnvExtension (Lean.Name × α) (Lean.NameMap α)))
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.
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
- Lean.Environment.freeRegions env = Array.forM Lean.CompactedRegion.free env.header.regions 0 (Array.size env.header.regions)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.writeModule env fname = do let a ← Lean.mkModuleData env Lean.saveModuleData fname (Lean.Environment.mainModule env) a
"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
.
"Forward declaration" for retrieving the number of builtin attributes.
- moduleNameSet : Lean.NameSet
- moduleData : Array Lean.ModuleData
- regions : Array Lean.CompactedRegion
Equations
- One or more equations did not get rendered due to their size.
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
- Lean.withImportModules imports opts trustLevel x = do let env ← Lean.importModules imports opts trustLevel tryFinally (x env) (Lean.Environment.freeRegions env)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Environment.add env cinfo = let env := Lean.Environment.registerNamePrefixes env (Lean.ConstantInfo.name cinfo); Lean.Environment.addAux env cinfo
Equations
- One or more equations did not get rendered due to their size.
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.
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.
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.
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.
- getEnv : m Lean.Environment
- modifyEnv : (Lean.Environment → Lean.Environment) → m Unit
Equations
- Lean.instMonadEnv m n = { getEnv := liftM Lean.getEnv, modifyEnv := fun f => liftM (Lean.modifyEnv f) }