pub struct Formula { /* private fields */ }
Expand description
A parsed formula, in a tree format which is convenient to perform unifications
Implementations§
Source§impl Formula
impl Formula
Sourcepub fn from_float(label: Label, typecode: TypeCode) -> Self
pub fn from_float(label: Label, typecode: TypeCode) -> Self
Creates a formula with just a variable
Sourcepub const fn labels_iter(&self) -> LabelIter<'_> ⓘ
pub const fn labels_iter(&self) -> LabelIter<'_> ⓘ
Iterates through the labels of a formula, depth-first, pre-order. Items are the label, and a boolean indicating whether the current label is a variable or not.
Sourcepub const fn as_ref<'a>(&'a self, db: &'a Database) -> FormulaRef<'a>
pub const fn as_ref<'a>(&'a self, db: &'a Database) -> FormulaRef<'a>
Augment a formula with a database reference, to produce a FormulaRef
.
The resulting object implements Display
, Debug
, and IntoIterator
.
Sourcepub const fn get_typecode(&self) -> TypeCode
pub const fn get_typecode(&self) -> TypeCode
Returns the typecode of this formula
Sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Returns whether this formula consists in a single token.
Sourcepub fn get_by_path(&self, path: &[usize]) -> Option<Label>
pub fn get_by_path(&self, path: &[usize]) -> Option<Label>
Returns the label obtained when following the given path. Each element of the path gives the index of the child to retrieve. For example, the empty
Sourcepub fn unify(
&self,
other: &Formula,
substitutions: &mut Substitutions,
) -> Result<(), UnificationError>
pub fn unify( &self, other: &Formula, substitutions: &mut Substitutions, ) -> Result<(), UnificationError>
Unify this formula with the given formula model
If successful, the provided substitutions
are completed
with the substitutions which needs to be made in
other
in order to match this formula.
Sourcepub fn substitute(&self, substitutions: &Substitutions) -> Formula
pub fn substitute(&self, substitutions: &Substitutions) -> Formula
Perform substitutions
This returns a new Formula
object, built from this formula,
where all instances of the variables specified in the substitutions are
replaced by the corresponding formulas.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Formula
impl RefUnwindSafe for Formula
impl Send for Formula
impl Sync for Formula
impl Unpin for Formula
impl UnwindSafe for Formula
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
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>
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>
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