Skip to main content

StructureEta

Struct StructureEta 

Source
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>

Source

pub fn new(env: &'a Environment) -> Self

Create a new StructureEta helper bound to the given environment.

Source

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).

Source

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.

Source

pub fn make_proj_chain( &self, expr: &Expr, struct_name: &Name, num_fields: usize, ) -> Vec<Expr>

Build a Vec of projection expressions Proj(struct_name, i, expr) for i in 0..num_fields.

Source

pub fn eta_expand_struct(&self, expr: &Expr, ty: &Expr) -> Option<Expr>

η-expand expr at type ty.

If ty is a structure type, returns App(… App(S.mk, proj_0(expr)) …, proj_{n-1}(expr)). Returns None when ty is not a known structure type.

Auto Trait Implementations§

§

impl<'a> Freeze for StructureEta<'a>

§

impl<'a> RefUnwindSafe for StructureEta<'a>

§

impl<'a> Send for StructureEta<'a>

§

impl<'a> Sync for StructureEta<'a>

§

impl<'a> Unpin for StructureEta<'a>

§

impl<'a> UnsafeUnpin for StructureEta<'a>

§

impl<'a> UnwindSafe for StructureEta<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.