pub enum Term {
Var(usize),
Lam(Box<Term>),
App(Box<Term>, Box<Term>),
}Expand description
An untyped lambda calculus term using de Bruijn indices.
Variants§
Var(usize)
de Bruijn variable (0 = innermost binder).
Lam(Box<Term>)
Lambda abstraction: λ.body.
App(Box<Term>, Box<Term>)
Application: (f arg).
Implementations§
Source§impl Term
impl Term
Sourcepub fn shift(&self, d: isize, cutoff: usize) -> Term
pub fn shift(&self, d: isize, cutoff: usize) -> Term
Shift all free variables by d when entering a context of depth cutoff.
Sourcepub fn subst(&self, j: usize, sub: &Term) -> Term
pub fn subst(&self, j: usize, sub: &Term) -> Term
Substitute sub for de Bruijn index j in self.
Sourcepub fn beta_step_normal(&self) -> Option<Term>
pub fn beta_step_normal(&self) -> Option<Term>
Perform one step of β-reduction (normal order: leftmost-outermost).
Returns Some(reduced) if a redex was found, None if already normal.
Trait Implementations§
impl Eq for Term
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnsafeUnpin for Term
impl UnwindSafe for Term
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more