[−][src]Enum lalrpop_lambda::Expression
A mutually recursive definition for all lambda expressions
let parser = lalrpop_lambda::parse::ExpressionParser::new(); assert!(parser.parse("λx.(x x)").is_ok());
Variants
Var(Variable)
Abs(Abstraction)
App(Application)
Methods
impl Expression
[src]
pub fn rename(&self, old: &Variable, new: &Variable) -> Self
[src]
α-conversion
pub fn apply(&self, η: bool) -> Self
[src]
β-reduction small-step semantics.
η: Local completeness in natural deduction.
Local reducibility in natural deduction.
pub fn normalize(&self, η: bool) -> Self
[src]
Big-step natural semantics.
η: Global completeness in natural deduction.
Global reducibility in natural deduction.
let parser = lalrpop_lambda::parse::ExpressionParser::new(); let expression = parser.parse("((λx.(λy.x y) b) a)").unwrap(); let normal = parser.parse("a b").unwrap(); assert_eq!(normal, expression.normalize(false));
pub fn variables(&self) -> HashSet<Variable>
[src]
pub fn free_variables(&self) -> HashSet<Variable>
[src]
FV(M) is the set of variables in M, not closed by a λ term.
use std::collections::HashSet; use lalrpop_lambda::Variable; let parser = lalrpop_lambda::parse::ExpressionParser::new(); let mut free = HashSet::new(); free.insert(Variable("y".into())); let expression = parser.parse("λx.(x y)").unwrap(); assert_eq!(free, expression.free_variables());
pub fn resolve<T: From<Expression>>(
&self,
env: &HashMap<Variable, Expression>
) -> Option<T> where
Expression: From<T>,
[src]
&self,
env: &HashMap<Variable, Expression>
) -> Option<T> where
Expression: From<T>,
let env = map! { variable!(id) => abs!{x.x}, // variable!(a) => app!(id,"a".into()), variable!(x) => 1.into(), }; assert_eq!(None, var!(q).resolve::<u64>(&env)); assert_eq!(Some(1), var!(x).resolve::<u64>(&env)); // assert_eq!(Some("a"), var!(a).resolve::<String>(&env)); // assert_eq!(Some((1,2)), var!(id).resolve::<(u64,u64)>(&env)(1,2)); // assert_eq!(None, abs!{x.x}.resolve::<Fn()>(&env));
Trait Implementations
impl Eq for Expression
[src]
impl PartialEq<Expression> for Expression
[src]
fn eq(&self, other: &Expression) -> bool
[src]
fn ne(&self, other: &Expression) -> bool
[src]
impl Clone for Expression
[src]
fn clone(&self) -> Expression
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> FnOnce(T) for Expression where
T: Into<Expression> + From<Expression>,
[src]
T: Into<Expression> + From<Expression>,
Function call support for an Expression
.
assert_eq!(0u64, λ!{x.x}(0).into()); assert_eq!(γ!(γ!(a,b),0), γ!(a,b)(0));
type Output = Expression
The returned type after the call operator is used.
extern "rust-call" fn call_once(self, t: (T,)) -> Expression
[src]
impl From<u64> for Expression
[src]
Church encoded natural numbers
assert_eq!(0, u64::from(λ!{f.λ!{x.x}})); assert_eq!(1, u64::from(λ!{f.λ!{x.γ!(f,x)}})); assert_eq!(3, u64::from(λ!{f.λ!{x.γ!(f,γ!(f,γ!(f,x)))}}));
impl From<Expression> for u64
[src]
Convert λ term back to native Rust type
assert_eq!(0, u64::from(λ!{f.λ!{x.x}})); assert_eq!(1, u64::from(λ!{f.λ!{x.γ!(f,x)}})); assert_eq!(3, u64::from(λ!{f.λ!{x.γ!(f,γ!(f,γ!(f,x)))}}));
fn from(e: Expression) -> u64
[src]
impl Debug for Expression
[src]
impl Display for Expression
[src]
impl Add<Expression> for Expression
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self
[src]
impl Mul<Expression> for Expression
[src]
Auto Trait Implementations
impl Send for Expression
impl Sync for Expression
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<A, F> FnBox<A> for F where
F: FnOnce<A>,
[src]
F: FnOnce<A>,