pub struct StructureEta<'a> { /* private fields */ }Expand description
Performs η-expansion for structure (record) types.
For a structure type S with constructor S.mk and fields f₁, f₂, …, fₙ,
η-expanding an expression e : S yields:
S.mk (e.f₁) (e.f₂) … (e.fₙ)which is definitionally equal to e by the η-rule for structures.
Implementations§
Source§impl<'a> StructureEta<'a>
impl<'a> StructureEta<'a>
Sourcepub fn new(env: &'a Environment) -> Self
pub fn new(env: &'a Environment) -> Self
Create a new StructureEta helper bound to the given environment.
Sourcepub fn is_structure_type(&self, ty: &Expr) -> bool
pub fn is_structure_type(&self, ty: &Expr) -> bool
Return true if ty is a Const whose name resolves in the environment
to a structure-like inductive (exactly 1 constructor, 0 indices, non-recursive).
Sourcepub fn collect_field_types(&self, struct_name: &Name) -> Vec<(Name, Expr)>
pub fn collect_field_types(&self, struct_name: &Name) -> Vec<(Name, Expr)>
Collect (field_name, field_type) pairs for the structure struct_name.
This works by looking up the unique constructor in the environment and
counting num_fields from its ConstructorVal. The field types are
obtained from the constructor’s type by stripping the leading Pi-binders
that correspond to the inductive parameters, then collecting the remaining
domain types.
Returns an empty Vec when the structure is not found.