pub enum Term {
Var {
variable: V,
},
Const {
constant: C,
},
App {
function: F,
terms: Vec<Term>,
},
}Expand description
Represents a first-order term and consists of variables, constants and function applications.
Variants§
Var
Is a variable term, wrapping a variable symbol.
Const
Is a constant term, wrapping a constant symbol.
App
Is a composite term, made by applying a function on a list of terms.
Implementations§
Source§impl Term
impl Term
Sourcepub fn free_vars(&self) -> Vec<&V>
pub fn free_vars(&self) -> Vec<&V>
Returns a list of all free variable symbols in the term.
Note: In the list of free variables, each variable symbol appears only once even if it is present at multiple positions of the receiver term.
Example:
// `x_sym` and `y_sym` are variable symbols:
let x_sym = V::from("x");
let y_sym = V::from("y");
// `c_sym` is a constant symbol:
let c_sym = C::from("c");
// `x` and `y` are variable terms:
let x = Term::from(x_sym.clone());
let y = Term::from(y_sym.clone());
// `c` is a constant term:
let c = Term::from(c_sym.clone());
// `f` and `g` are function
let f = F::from("f");
let g = F::from("g");
// f(x, g(y, c, x)):
let t = f.app2(x.clone(), g.app3(y, c, x.clone()));
// comparing the two (unordered) lists:
assert_eq!(vec![&x_sym, &y_sym].iter().sorted(), t.free_vars().iter().sorted())Trait Implementations§
Source§impl Ord for Term
impl Ord for Term
Source§impl PartialOrd for Term
impl PartialOrd for Term
Source§impl TermBased for Term
impl TermBased for Term
Source§fn transform(&self, f: &impl Fn(&Term) -> Term) -> Self
fn transform(&self, f: &impl Fn(&Term) -> Term) -> Self
Applies a transformation function
f on the Terms of the receiver.Source§fn rename_vars(&self, renaming: &impl VariableRenaming) -> Self
fn rename_vars(&self, renaming: &impl VariableRenaming) -> Self
Applies a
VariableRenaming on the variable sub-terms of the receiver. Read moreSource§fn substitute(&self, sub: &impl Substitution) -> Self
fn substitute(&self, sub: &impl Substitution) -> Self
Applies a
Substitution on the variable sub-terms of the receiver. Read moreimpl 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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