Skip to main content

SingletonKReducer

Struct SingletonKReducer 

Source
pub struct SingletonKReducer<'a> { /* private fields */ }
Expand description

Performs K-like reduction on singleton types.

A singleton type (in OxiLean’s sense) is an inductive type with

  • exactly 1 constructor, and
  • 0 non-parameter fields.

All elements of a singleton type are definitionally equal to the unique constructor (applied only to its uniform parameters). This enables a restricted form of the K axiom: pattern matching on self-equality can be simplified because any proof of a = a must equal rfl.

Implementations§

Source§

impl<'a> SingletonKReducer<'a>

Source

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

Create a new SingletonKReducer bound to the given environment.

Source

pub fn is_singleton_type(&self, ty: &Expr) -> bool

Return true when ty (looked up as a Const head) has exactly 1 constructor with 0 non-parameter fields.

Source

pub fn get_unique_ctor(&self, type_name: &Name) -> Option<Name>

Return the unique constructor name for type_name if it is a singleton.

Source

pub fn k_reduce(&self, _expr: &Expr, ty: &Expr) -> Option<Expr>

K-reduce expr : ty.

For a singleton type the canonical element is the unique zero-field constructor constant. Returns Some(canonical) when applicable, None otherwise.

Source

pub fn apply_k_reduction(motive: &Expr, proof: &Expr) -> Option<Expr>

Attempt to simplify Rec(motive, proof) on a singleton type.

When both motive and proof involve a singleton type, the match can be eliminated because proof must equal the canonical constructor. Returns Some(simplified) when a simplification is found.

Auto Trait Implementations§

§

impl<'a> Freeze for SingletonKReducer<'a>

§

impl<'a> RefUnwindSafe for SingletonKReducer<'a>

§

impl<'a> Send for SingletonKReducer<'a>

§

impl<'a> Sync for SingletonKReducer<'a>

§

impl<'a> Unpin for SingletonKReducer<'a>

§

impl<'a> UnsafeUnpin for SingletonKReducer<'a>

§

impl<'a> UnwindSafe for SingletonKReducer<'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.