Struct FormulaRef

Source
pub struct FormulaRef<'a> { /* private fields */ }
Expand description

A Formula reference in the context of a Database. This allows the values in the Formula to be resolved,

Implementations§

Source§

impl<'a> FormulaRef<'a>

Source

pub fn as_sexpr(&self) -> String

Convert this formula into an s-expression string.

Source

pub fn write_sexpr(&self, w: &mut impl Write) -> Result

Write this formula as an s-expression to the given writer.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn dump(&self, nset: &Nameset)

Debug only, dumps the internal structure of the formula.

Source

pub fn get_typecode(&self) -> TypeCode

Returns the typecode of this formula

Source

pub fn is_singleton(&self) -> bool

Returns whether this formula consists in a single token.

Source

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

Source

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.

Source

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.

Source

pub fn replace(&self, old_sub_fmla: &Formula, new_sub_fmla: &Formula) -> Formula

Replace all instances of old_sub_fmla in this formula by new_sub_fmla. Where substitute works on variables only, this

Trait Implementations§

Source§

impl<'a> Clone for FormulaRef<'a>

Source§

fn clone(&self) -> FormulaRef<'a>

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<'a> Debug for FormulaRef<'a>

Source§

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

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

impl<'a> Deref for FormulaRef<'a>

Source§

type Target = Formula

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> Display for FormulaRef<'a>

Source§

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

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

impl<'a> IntoIterator for FormulaRef<'a>

Source§

type Item = Atom

The type of the elements being iterated over.
Source§

type IntoIter = Flatten<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Flatten<'a>

Creates an iterator from a value. Read more
Source§

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

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.