RootedLambdaPool

Struct RootedLambdaPool 

Source
pub struct RootedLambdaPool<'src, T: LambdaLanguageOfThought> { /* private fields */ }
Expand description

A lambda expression with its root defined.

Implementations§

Source§

impl<'src, T: LambdaLanguageOfThought> RootedLambdaPool<'src, T>

Source

pub fn new_free_variable( index: usize, t: LambdaType, ) -> RootedLambdaPool<'src, T>

Creates an anonymous free variable with [index] of type [t]

Source

pub fn free_variables( &self, ) -> impl Iterator<Item = (&FreeVar<'src>, &LambdaType)>

Gets all free variables that must be bound in order to evaluate this lambda expression

Source

pub fn len(&self) -> usize

Get the length of a lambda tree

Source§

impl<'src, T: LambdaLanguageOfThought + Clone> RootedLambdaPool<'src, T>

Source

pub fn cleanup(&mut self)

Clean up dangling references.

Source

pub fn get_type(&self) -> Result<LambdaType, TypeError>

The type of the lambda expression

Source

pub fn merge(self, other: Self) -> Option<Self>

Combine two lambda expressions by applying one to the other. Returns None if that is impossible.

Source

pub fn reduce(&mut self) -> Result<(), ReductionError>

Reduce a lambda expression

Source

pub fn into_pool(self) -> Result<T::Pool, T::ConversionError>

Convert a lambda expression to its executable version (should only be done if there are only LambdaExpr::LanguageOfThoughtExpr expressions.

Source

pub fn bind_free_variable( &mut self, fvar: FreeVar<'src>, replacement: RootedLambdaPool<'src, T>, ) -> Result<(), LambdaError>

Replace a free variable with a value.

Source

pub fn lambda_abstract_free_variable( &mut self, fvar: FreeVar<'src>, lambda_type: LambdaType, always_abstract: bool, ) -> Result<(), LambdaError>

Replace a free variable by lambda abstracting it. (e.g. $P(x_{free})$ to $\lambda x P(x)$).

Source

pub fn apply_new_free_variable( &mut self, fvar: FreeVar<'src>, ) -> Result<LambdaType, LambdaError>

Apply a free variable to a function.

Source§

impl<T: LambdaLanguageOfThought + Clone + Debug> RootedLambdaPool<'_, T>

Source

pub fn lift(&mut self) -> Result<(), TypeError>

Convert an expression phi of type x and convert it to lambda <x,t> P P(phi)

Source

pub fn stats(&self) -> LambdaSummaryStats

Get LambdaSummaryStats for an expression, e.g. how many context functions, size, etc.

Source§

impl<'a> RootedLambdaPool<'a, Expr<'a>>

Source

pub fn conjoin(self, other: Self) -> Result<Self, ConjoiningError>

Takes two lambda expressions, phi and psi of type <x, t> where x is any type and returns phi AND psi.

Source

pub fn raised_conjoin(self, other: Self) -> Result<Self, ConjoiningError>

Takes two lambda expressions, phi <x, <y,t>> and psi of type <y, t> where x and y is any type and returns phi AND psi.

This is a generalized kind of Event Identification from Kratzer (1996)

  • Kratzer, A. (1996). Severing the External Argument from its Verb. In J. Rooryck & L. Zaring (Eds.), Phrase Structure and the Lexicon (pp. 109–137). Springer Netherlands. https://doi.org/10.1007/978-94-015-8617-7_5
Source

pub fn parse(s: &'a str) -> Result<Self, LambdaParseError>

Create a RootedLambdaPool<Expr> from a string.

Source§

impl<'src, T: LambdaLanguageOfThought + Clone> RootedLambdaPool<'src, T>

Source

pub fn typeless_sampler( possible_expressions: PossibleExpressions<'src, T>, max_expr: usize, max_types: usize, ) -> TypeAgnosticSampler<'src, T>

Create a sampler which can sample arbitrary types.

Source§

impl<'src> RootedLambdaPool<'src, Expr<'src>>

Source

pub fn resample_from_expr<'a>( &mut self, possible_expressions: &'a PossibleExpressions<'src, Expr<'src>>, helpers: Option<&HashMap<LambdaType, Vec<RootedLambdaPool<'src, Expr<'src>>>>>, rng: &mut impl Rng, ) -> Result<(), LambdaError>

Create a LambdaSampler of a given type.

Source

pub fn enumerator_filter<'a, F: Fn(&Context) -> bool>( t: &LambdaType, filter: F, possible_expressions: &'a PossibleExpressions<'src, Expr<'src>>, ) -> LambdaEnumerator<'a, 'src, Expr<'src>, F>

Create a LambdaSampler of a given type with a filter

Source

pub fn enumerator<'a>( t: &LambdaType, possible_expressions: &'a PossibleExpressions<'src, Expr<'src>>, ) -> LambdaEnumerator<'a, 'src, Expr<'src>, impl Fn(&Context) -> bool>

Create a LambdaSampler of a given type.

Source

pub fn sampler( t: &LambdaType, possible_expressions: &PossibleExpressions<'src, Expr<'src>>, max_expr: usize, ) -> LambdaSampler<'src, Expr<'src>>

Creates a reusable random sampler by enumerating over the first max_expr expressions

Source

pub fn random_expr( t: &LambdaType, possible_expressions: &PossibleExpressions<'src, Expr<'src>>, rng: &mut impl Rng, ) -> RootedLambdaPool<'src, Expr<'src>>

Randomly generate a RootedLambdaPool of type t.

Source

pub fn random_expr_no_constant( t: &LambdaType, possible_expressions: &PossibleExpressions<'src, Expr<'src>>, rng: &mut impl Rng, ) -> Option<RootedLambdaPool<'src, Expr<'src>>>

Randomly generate a RootedLambdaPool of type t without constant functions.

Source§

impl<'src> RootedLambdaPool<'src, Expr<'src>>

Source

pub fn prune_quantifiers(&mut self)

Remove quantifiers which do not use their variable in their body.

Source

pub fn swap_expr( &mut self, possible_expressions: &PossibleExpressions<'src, Expr<'src>>, rng: &mut impl Rng, ) -> Result<(), TypeError>

Replace a random expression with something else of the same type.

Source

pub fn swap_subtree(&mut self, rng: &mut impl Rng) -> Result<(), TypeError>

Replace a random expression with something else of the same type from within the same expression.

Source§

impl<'src> RootedLambdaPool<'src, Expr<'src>>

Source

pub fn for_document(&self) -> MathModeExpression<'_>

Get a [MathModeExpression] to be serialized for documents.

Trait Implementations§

Source§

impl<'src, T: Clone + LambdaLanguageOfThought> Clone for RootedLambdaPool<'src, T>

Source§

fn clone(&self) -> RootedLambdaPool<'src, T>

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<'src, T: Debug + LambdaLanguageOfThought> Debug for RootedLambdaPool<'src, T>

Source§

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

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

impl<'de, 'a> Deserialize<'de> for RootedLambdaPool<'a, Expr<'a>>
where 'de: 'a,

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Display for RootedLambdaPool<'a, Expr<'a>>

Source§

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

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

impl<'src, T: LambdaLanguageOfThought + Clone> Distribution<RootedLambdaPool<'src, T>> for LambdaSampler<'src, T>

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> RootedLambdaPool<'src, T>

Generate a random value of T, using rng as the source of randomness.
§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl<'a> From<LanguageExpression<'a>> for RootedLambdaPool<'a, Expr<'a>>

Source§

fn from(value: LanguageExpression<'a>) -> Self

Converts to this type from the input type.
Source§

impl<T: LambdaLanguageOfThought + HashLambda> Hash for RootedLambdaPool<'_, T>

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<T: PartialEq + LambdaLanguageOfThought> PartialEq for RootedLambdaPool<'_, T>

Source§

fn eq(&self, other: &Self) -> 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<'src> Serialize for RootedLambdaPool<'src, Expr<'src>>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq + Eq + LambdaLanguageOfThought> Eq for RootedLambdaPool<'_, T>

Auto Trait Implementations§

§

impl<'src, T> Freeze for RootedLambdaPool<'src, T>

§

impl<'src, T> RefUnwindSafe for RootedLambdaPool<'src, T>
where T: RefUnwindSafe,

§

impl<'src, T> Send for RootedLambdaPool<'src, T>
where T: Send,

§

impl<'src, T> Sync for RootedLambdaPool<'src, T>
where T: Sync,

§

impl<'src, T> Unpin for RootedLambdaPool<'src, T>
where T: Unpin,

§

impl<'src, T> UnwindSafe for RootedLambdaPool<'src, T>
where T: UnwindSafe,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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