pub struct FormulaRef<'a> { /* private fields */ }
Expand description
Implementations§
Source§impl<'a> FormulaRef<'a>
impl<'a> FormulaRef<'a>
Sourcepub fn write_sexpr(&self, w: &mut impl Write) -> Result
pub fn write_sexpr(&self, w: &mut impl Write) -> Result
Write this formula as an s-expression to the given writer.
Sourcepub fn complete_substitutions<E>(
&self,
substitutions: &mut Substitutions,
wvp: &mut impl WorkVariableProvider<E>,
) -> Result<(), E>
pub fn complete_substitutions<E>( &self, substitutions: &mut Substitutions, wvp: &mut impl WorkVariableProvider<E>, ) -> Result<(), E>
Handles the variables present in the formula but not in the substitution list
The function f
provided can modify on the fly the substitution list, adding any missing one.
Sourcepub fn append_to_stack_buffer(self, stack_buffer: &mut Vec<u8>) -> Range<usize>
pub fn append_to_stack_buffer(self, stack_buffer: &mut Vec<u8>) -> Range<usize>
Appends this formula to the provided stack buffer.
The ProofBuilder
structure uses a dense representation of formulas as byte strings,
using the high bit to mark the end of each token.
This function creates such a byte string, stores it in the provided buffer,
and returns the range the newly added string occupies on the buffer.
See crate::verify
for more about this format.
Sourcepub fn build_syntax_proof<I: Copy, A: Default + FromIterator<I>>(
self,
stack_buffer: &mut Vec<u8>,
arr: &mut dyn ProofBuilder<Item = I, Accum = A>,
) -> I
pub fn build_syntax_proof<I: Copy, A: Default + FromIterator<I>>( self, stack_buffer: &mut Vec<u8>, arr: &mut dyn ProofBuilder<Item = I, Accum = A>, ) -> I
Builds the syntax proof for this formula.
In Metamath, it is possible to write proofs that a given formula is a well-formed formula.
This method builds such a syntax proof for the formula into a crate::proof::ProofTree
,
stores that proof tree in the provided ProofBuilder
arr
,
and returns the index of that ProofTree
within arr
.
Methods from Deref<Target = Formula>§
Sourcepub fn labels_iter(&self) -> LabelIter<'_> ⓘ
pub 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 fn as_ref<'a>(&'a self, db: &'a Database) -> FormulaRef<'a>
pub 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 fn get_typecode(&self) -> TypeCode
pub 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§
Source§impl<'a> Clone for FormulaRef<'a>
impl<'a> Clone for FormulaRef<'a>
Source§fn clone(&self) -> FormulaRef<'a>
fn clone(&self) -> FormulaRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for FormulaRef<'a>
impl<'a> Debug for FormulaRef<'a>
Source§impl<'a> Deref for FormulaRef<'a>
impl<'a> Deref for FormulaRef<'a>
Source§impl<'a> Display for FormulaRef<'a>
impl<'a> Display for FormulaRef<'a>
Source§impl<'a> IntoIterator for FormulaRef<'a>
impl<'a> IntoIterator for FormulaRef<'a>
impl<'a> Copy for FormulaRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for FormulaRef<'a>
impl<'a> RefUnwindSafe for FormulaRef<'a>
impl<'a> Send for FormulaRef<'a>
impl<'a> Sync for FormulaRef<'a>
impl<'a> Unpin for FormulaRef<'a>
impl<'a> UnwindSafe for FormulaRef<'a>
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