Expr

Enum Expr 

Source
pub enum Expr<'a> {
    Quantifier {
        quantifier: Quantifier,
        var_type: ActorOrEvent,
        restrictor: ExprRef,
        subformula: ExprRef,
    },
    Variable(Variable),
    Actor(Actor<'a>),
    Event(Event),
    Binary(BinOp, ExprRef, ExprRef),
    Unary(MonOp<'a>, ExprRef),
    Constant(Constant<'a>),
}
Expand description

The basic expression type of the language of thought. Note that it does not include free variables or any of the machinery of the lambda calculus which is handled elsewhere.

Variants§

§

Quantifier

A quantified expression. Variables are implemented with DeBruijn indices.

Fields

§quantifier: Quantifier

What kind of quantifier

§var_type: ActorOrEvent

The type of bound variable

§restrictor: ExprRef

An expression defining the restrictor of the quantifier.

§subformula: ExprRef

An expression defining the subformula of the quantifier.

§

Variable(Variable)

§

Actor(Actor<'a>)

See Actor. Written a_NAME

§

Event(Event)

See Event. Written e_N where N is an integer.

§

Binary(BinOp, ExprRef, ExprRef)

Any binary function.

§

Unary(MonOp<'a>, ExprRef)

Any unary function.

§

Constant(Constant<'a>)

All constants.

Trait Implementations§

Source§

impl<'a> Clone for Expr<'a>

Source§

fn clone(&self) -> Expr<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Expr<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Hash for Expr<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl HashLambda for Expr<'_>

Source§

fn hash_expr<H: Hasher>(&self, state: &mut H)

Hash the expression (without paying attention to subtrees which should be handled RootedLambdaPool’s hash implementation)
Source§

impl<'a> LambdaLanguageOfThought for Expr<'a>

Source§

type Pool = LanguageExpression<'a>

The type of the executable syntax tree
Source§

type ConversionError = LambdaConversionError

Source§

fn n_children(&self) -> usize

Get the number of children of an expression.
Source§

fn inc_depth(&self) -> bool

Returns true if this is somewhere that can bind variables (e.g. should we increment debruijn indices
Source§

fn var_type(&self) -> Option<&LambdaType>

Returns the type of the bound variable at an instruction
Source§

fn get_children(&self) -> impl Iterator<Item = LambdaExprRef>

Given an expression, get an iterator of its children
Source§

fn change_children(&mut self, new_children: impl Iterator<Item = LambdaExprRef>)

Given a list of new references for all children of an expr, change its children.
Source§

fn remap_refs(&mut self, remap: &[usize])

Update the references such that LambdaExprRef(0) is remapped to LambdaExprRef(remap[0]). (Used in garbage collection).
Source§

fn get_type(&self) -> &LambdaType

Get the return type of an expression.
Source§

fn same_expr(&self, other: &Self) -> bool

Checks if two expressions are the same, ignoring their subtrees (so different children shouldn’t matter)
Source§

fn to_pool( pool: RootedLambdaPool<'_, Self>, ) -> Result<Self::Pool, Self::ConversionError>

Convert from a RootedLambdaPool<T> to LambdaLanguageOfThought::Pool. May return an error if there are any lambda terms left in the RootedLambdaPool<T> (e.g. not fully reduced).
Source§

fn get_arguments(&self) -> impl Iterator<Item = LambdaType>

Get the type of all children in order.
Source§

fn commutative(&self) -> bool

Checks whether an expression is commutative
Source§

impl<'a> Ord for Expr<'a>

Source§

fn cmp(&self, other: &Expr<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq for Expr<'a>

Source§

fn eq(&self, other: &Expr<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd for Expr<'a>

Source§

fn partial_cmp(&self, other: &Expr<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Copy for Expr<'a>

Source§

impl<'a> Eq for Expr<'a>

Source§

impl<'a> StructuralPartialEq for Expr<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Expr<'a>

§

impl<'a> RefUnwindSafe for Expr<'a>

§

impl<'a> Send for Expr<'a>

§

impl<'a> Sync for Expr<'a>

§

impl<'a> Unpin for Expr<'a>

§

impl<'a> UnwindSafe for Expr<'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
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes [WrappingSpan::make_wrapped] to wrap an AST node in a span.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,