pub struct Environment { /* private fields */ }Expand description
The global environment containing all checked declarations.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn add_quot(&mut self) -> Result<(), EnvError>
pub fn add_quot(&mut self) -> Result<(), EnvError>
Install the four #QUOT primitives (Quot, Quot.mk, Quot.lift,
Quot.ind) with their canonical, kernel-constructed types.
This is the trusted #QUOT entry point, mirroring Lean’s
add_quot in src/kernel/quot.cpp:
- Precondition:
Eqmust already exist as an inductive of the expected shape (one constructorEq.refl), becauseQuot.lift’s soundness hypothesis mentionsEq. A typed error is returned otherwise. - All four types are constructed in-kernel (universe-polymorphic in
u, plusvforQuot.lift); the caller never supplies them. - The four constants are added atomically. If any name already exists, nothing is installed.
- A once-only
Environment::quot_initializedflag is set; a secondadd_quotis a typed error, and any otherConstantInfo::Quotientaddition is rejected byEnvironment::add_constant.
Source§impl Environment
impl Environment
Sourcepub fn add(&mut self, decl: Declaration) -> Result<(), EnvError>
pub fn add(&mut self, decl: Declaration) -> Result<(), EnvError>
Add a legacy declaration to the environment.
Returns an error if a declaration with the same name already exists.
Sourcepub fn add_constant(&mut self, ci: ConstantInfo) -> Result<(), EnvError>
pub fn add_constant(&mut self, ci: ConstantInfo) -> Result<(), EnvError>
Add a ConstantInfo to the environment.
Quotient constants (ConstantInfo::Quotient) are rejected here: the four
#QUOT primitives may only be installed atomically through
Environment::add_quot, which constructs their canonical types
in-kernel. This prevents a caller from smuggling a Quotient entry with
an arbitrary (possibly unsound) type past the checker.
Sourcepub fn quot_initialized(&self) -> bool
pub fn quot_initialized(&self) -> bool
Whether the four #QUOT primitives have been installed.
Sourcepub fn get(&self, name: &Name) -> Option<&Declaration>
pub fn get(&self, name: &Name) -> Option<&Declaration>
Look up a legacy declaration by name.
Sourcepub fn find(&self, name: &Name) -> Option<&ConstantInfo>
pub fn find(&self, name: &Name) -> Option<&ConstantInfo>
Look up a constant info by name.
Sourcepub fn get_defn(&self, name: &Name) -> Option<(Expr, ReducibilityHint)>
pub fn get_defn(&self, name: &Name) -> Option<(Expr, ReducibilityHint)>
Get a definition’s value and hint (for reduction).
Sourcepub fn is_inductive(&self, name: &Name) -> bool
pub fn is_inductive(&self, name: &Name) -> bool
Check if a name refers to an inductive type.
Sourcepub fn is_constructor(&self, name: &Name) -> bool
pub fn is_constructor(&self, name: &Name) -> bool
Check if a name refers to a constructor.
Sourcepub fn is_recursor(&self, name: &Name) -> bool
pub fn is_recursor(&self, name: &Name) -> bool
Check if a name refers to a recursor.
Sourcepub fn is_quotient(&self, name: &Name) -> bool
pub fn is_quotient(&self, name: &Name) -> bool
Check if a name refers to a quotient.
Sourcepub fn is_structure_like(&self, name: &Name) -> bool
pub fn is_structure_like(&self, name: &Name) -> bool
Check if a name refers to a structure-like inductive.
Sourcepub fn get_inductive_val(&self, name: &Name) -> Option<&InductiveVal>
pub fn get_inductive_val(&self, name: &Name) -> Option<&InductiveVal>
Get the inductive type info for a name.
Sourcepub fn get_constructor_val(&self, name: &Name) -> Option<&ConstructorVal>
pub fn get_constructor_val(&self, name: &Name) -> Option<&ConstructorVal>
Get the constructor info for a name.
Sourcepub fn get_recursor_val(&self, name: &Name) -> Option<&RecursorVal>
pub fn get_recursor_val(&self, name: &Name) -> Option<&RecursorVal>
Get the recursor info for a name.
Sourcepub fn get_quotient_val(&self, name: &Name) -> Option<&QuotVal>
pub fn get_quotient_val(&self, name: &Name) -> Option<&QuotVal>
Get the quotient info for a name.
Sourcepub fn get_type(&self, name: &Name) -> Option<&Expr>
pub fn get_type(&self, name: &Name) -> Option<&Expr>
Get the type of a constant (from ConstantInfo).
Sourcepub fn get_level_params(&self, name: &Name) -> Option<&[Name]>
pub fn get_level_params(&self, name: &Name) -> Option<&[Name]>
Get the universe level parameters for a constant.
Sourcepub fn instantiate_const_type(
&self,
name: &Name,
levels: &[Level],
) -> Option<Expr>
pub fn instantiate_const_type( &self, name: &Name, levels: &[Level], ) -> Option<Expr>
Instantiate a constant’s type with universe levels.
Sourcepub fn constant_names(&self) -> impl Iterator<Item = &Name>
pub fn constant_names(&self) -> impl Iterator<Item = &Name>
Iterate over all constant names.
Sourcepub fn constant_infos(&self) -> impl Iterator<Item = (&Name, &ConstantInfo)>
pub fn constant_infos(&self) -> impl Iterator<Item = (&Name, &ConstantInfo)>
Iterate over all constant infos.