Struct CoreBinder

Source
pub struct CoreBinder<L: Language, T> { /* private fields */ }

Implementations§

Source§

impl<L: Language, T: CoreFold<L>> CoreBinder<L, T>

Source

pub fn open(&self) -> (Vec<CoreBoundVar<L>>, T)

Accesses the contents of the binder.

The variables inside will be renamed to fresh var indices that do not alias any other indices seen during this computation.

The expectation is that you will create a term and use Binder::new.

Source

pub fn dummy(term: T) -> Self

Source

pub fn new(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self

Given a set of variables (X, Y, Z) and a term referecing some subset of them, create a binder where exactly those variables are bound (even the ones not used).

Source

pub fn mentioned(variables: impl Upcast<Vec<CoreVariable<L>>>, term: T) -> Self

Given a set of variables (X, Y, Z) and a term referecing some subset of them, create a binder for just those variables that are mentioned.

Source

pub fn into<U>(self) -> CoreBinder<L, U>
where T: Into<U>,

Source

pub fn len(&self) -> usize

Number of variables bound by this binder

Source

pub fn is_empty(&self) -> bool

Source

pub fn instantiate_with( &self, parameters: &[impl Upcast<CoreParameter<L>>], ) -> Fallible<T>

Instantiate the binder with the given parameters, returning an err if the parameters are the wrong number or ill-kinded.

Source

pub fn instantiate( &self, op: impl FnMut(CoreKind<L>, VarIndex) -> CoreParameter<L>, ) -> T

Instantiate the term, replacing each bound variable with op(i).

Source

pub fn peek(&self) -> &T

Accesses the data inside the binder. Use this for simple tests that extract data that is independent of the bound variables. If that’s not the case, use open.

Source

pub fn kinds(&self) -> &[CoreKind<L>]

Returns the kinds of each variable bound by this binder

Source

pub fn map<U: CoreFold<L>>(&self, op: impl FnOnce(T) -> U) -> CoreBinder<L, U>

Trait Implementations§

Source§

impl<L: Clone + Language, T: Clone> Clone for CoreBinder<L, T>

Source§

fn clone(&self) -> CoreBinder<L, T>

Returns a copy 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<L: Language, T: CoreFold<L>> CoreFold<L> for CoreBinder<L, T>

Source§

fn substitute(&self, substitution_fn: SubstitutionFn<'_, L>) -> Self

Replace uses of variables with values from the substitution.
Source§

fn shift_in(&self) -> Self

Produce a version of this term where any debruijn indices which appear free are incremented by one.
Source§

fn replace_free_var( &self, v: impl Upcast<CoreVariable<L>>, p: impl Upcast<CoreParameter<L>>, ) -> Self

Replace all appearances of free variable v with p.
Source§

impl<L, T> CoreParse<L> for CoreBinder<L, T>
where L: Language, T: CoreTerm<L>,

Parse a binder: find the names in scope, parse the contents, and then replace names with debruijn indices.

Source§

fn parse<'t>(scope: &Scope<L>, text: &'t str) -> ParseResult<'t, Self>

Parse a single instance of this type, returning an error if no such instance is present.
Source§

fn parse_many<'t>( scope: &Scope<L>, text: &'t str, close_char: char, ) -> ParseResult<'t, Vec<Self>>

Parse many instances of self, expecting close_char to appear after the last instance (close_char is not consumed).
Source§

fn parse_comma<'t>( scope: &Scope<L>, text: &'t str, close_char: char, ) -> ParseResult<'t, Vec<Self>>

Comma separated list with optional trailing comma.
Source§

impl<L: Language, T: CoreVisit<L>> CoreVisit<L> for CoreBinder<L, T>

Source§

fn free_variables(&self) -> Vec<CoreVariable<L>>

Extract the list of free variables (for the purposes of this function, defined by Variable::is_free). The list may contain duplicates and must be in a determinstic order (though the order itself isn’t important).
Source§

fn size(&self) -> usize

Measures the overall size of the term by counting constructors etc. Used to determine overflow.
Source§

fn assert_valid(&self)

Asserts various validity constraints and panics if they are not held. These validition constraints should never fail unless there is a bug in our logic. This is to aid with fuzzing and bug detection.
Source§

fn references_only_universal_variables(&self) -> bool

True if this term references only universal variables. This means that it contains no existential variables. If this is a goal, then when we prove it true, we don’t expect any substitution. This is similar, but not identical, to the commonly used term “ground term”, which in Prolog refers to a term that contains no variables. The difference here is that the term may contain variables, but only those instantiated universally (∀).
Source§

impl<L: Language, T> Debug for CoreBinder<L, T>
where T: Debug,

Source§

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

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

impl<L: Default + Language, T: Default> Default for CoreBinder<L, T>

Source§

fn default() -> CoreBinder<L, T>

Returns the “default value” for a type. Read more
Source§

impl<L: Language, T, U> DowncastTo<CoreBinder<L, T>> for CoreBinder<L, U>
where T: DowncastFrom<U>,

Source§

impl<L: Hash + Language, T: Hash> Hash for CoreBinder<L, 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<L: Ord + Language, T: Ord> Ord for CoreBinder<L, T>

Source§

fn cmp(&self, other: &CoreBinder<L, T>) -> 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<L: PartialEq + Language, T: PartialEq> PartialEq for CoreBinder<L, T>

Source§

fn eq(&self, other: &CoreBinder<L, T>) -> 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<L: PartialOrd + Language, T: PartialOrd> PartialOrd for CoreBinder<L, T>

Source§

fn partial_cmp(&self, other: &CoreBinder<L, T>) -> 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<L: Language, T, U> UpcastFrom<CoreBinder<L, T>> for CoreBinder<L, U>
where T: Clone + Upcast<U>, U: Clone,

Source§

fn upcast_from(term: CoreBinder<L, T>) -> Self

Source§

impl<L: Language, T: CoreTerm<L>> CoreTerm<L> for CoreBinder<L, T>

Source§

impl<L: Eq + Language, T: Eq> Eq for CoreBinder<L, T>

Source§

impl<L: Language, T> StructuralPartialEq for CoreBinder<L, T>

Auto Trait Implementations§

§

impl<L, T> Freeze for CoreBinder<L, T>
where T: Freeze,

§

impl<L, T> RefUnwindSafe for CoreBinder<L, T>

§

impl<L, T> Send for CoreBinder<L, T>
where T: Send, <L as Language>::Kind: Send,

§

impl<L, T> Sync for CoreBinder<L, T>
where T: Sync, <L as Language>::Kind: Sync,

§

impl<L, T> Unpin for CoreBinder<L, T>
where T: Unpin, <L as Language>::Kind: Unpin,

§

impl<L, T> UnwindSafe for CoreBinder<L, T>
where T: UnwindSafe, <L as Language>::Kind: 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
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
Source§

impl<U> Downcast for U

Source§

fn downcast<T>(&self) -> Option<T>
where T: DowncastFrom<U>,

Source§

fn is_a<T>(&self) -> bool
where T: DowncastFrom<Self>,

Source§

impl<T, U> DowncastFrom<T> for U
where T: DowncastTo<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<A> To for A

Source§

fn to<T>(&self) -> T
where A: Upcast<T>,

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.
Source§

impl<T, U> Upcast<U> for T
where T: Clone, U: UpcastFrom<T>,

Source§

fn upcast(self) -> U

Source§

impl<T, U> UpcastFrom<&T> for U
where T: Clone + Upcast<U>,

Source§

fn upcast_from(term: &T) -> U

Source§

impl<T> UpcastFrom<()> for T
where T: Default,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Value for T
where T: Clone + Eq + Debug + Hash + 'static,