Struct cop::offset::Offset

source ·
pub struct Offset<T> { /* private fields */ }
Expand description

An object with an usize offset for variables.

For example, when we want to create a fresh clause copy, instead of creating a new clause by applying an offset to every variable (taking linear time), we simply wrap a clause pointer with an Offset (taking constant time). This approach (wrapping objects in an Offset) also avoids mixing up offsets for different objects or forgetting to consider an offset.

A principal design idea of this type is that we should not be able to obtain the original, non-offset object once it is offset. This is to prevent that the offset is “forgotten”.

Implementations§

source§

impl<'t, P, C> Offset<&'t Contrapositive<&'t Lit<P, C, usize>>>

source

pub fn lit(&self) -> OLit<'t, P, C>

The literal corresponding to the contrapositive.

source

pub fn rest(&self) -> Offset<&'t Clause<&'t Lit<P, C, usize>>>

The clause minus the literal corresponding to the contrapositive.

source§

impl<T> Offset<&T>

source

pub fn ptr_eq(self, other: Self) -> bool

Return true if the offsets and the pointers are equal.

source§

impl<T: Copy> Offset<&T>

source

pub fn copied(self) -> Offset<T>

Copy the contained object.

source§

impl<T> Offset<T>

source

pub fn new(o: usize, x: T) -> Offset<T>

Create a new offset object.

source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Offset<U>

Apply a function to the contained object.

source§

impl<'t, C> Offset<&'t Term<C, usize>>

source

pub fn whnf(self, sub: &Sub<'t, C>) -> Self

Substitute the head of the term until a fix point is reached.

let mut sub: Sub<&str> = Sub::default();
sub.set_dom_max(3);

let tm0: Term<&str, _> = Term::V(0);
let tm1: Term<&str, _> = Term::V(1);
let ot0 = OTerm::new(2, &tm0);
let ot1 = OTerm::new(0, &tm1);
sub.insert(2, ot1);

// 0+2 should be substituted to 1+0 and terminate there
assert!(ot0.whnf(&sub).ptr_eq(ot1))
source§

impl<'t, C: Eq> Offset<&'t Args<Term<C, usize>>>

source

pub fn eq_mod(self, sub: &Sub<'t, C>, other: Self) -> bool

Return true if two offset argument sequences are equal modulo substitution.

source

pub fn unify(self, sub: &mut Sub<'t, C>, other: Self) -> bool

Return true if two offset argument sequences can be unified under the substitution, updating the substitution.

source§

impl<'t, P, C> Offset<&'t App<P, Args<Term<C, usize>>>>

source

pub fn head(&self) -> &P

Head of the literal.

source

pub fn args(&self) -> OArgs<'t, C>

Offset arguments of the literal.

source§

impl<'t, P: Eq, C: Eq> Offset<&'t App<P, Args<Term<C, usize>>>>

source

pub fn eq_mod(&self, sub: &Sub<'t, C>, other: &Self) -> bool

Return true if two offset literals are equal modulo substitution.

source§

impl<'t, P: Eq + Neg<Output = P> + Clone, C: Eq> Offset<&'t App<P, Args<Term<C, usize>>>>

source

pub fn neg_eq_mod(&self, sub: &Sub<'t, C>, other: &Self) -> bool

Return true if the negation of an offset literals equals another offset literal, modulo substitution.

source§

impl<'t, L, M> Offset<&'t LitMat<L, M>>

source

pub fn transpose(self) -> LitMat<Offset<&'t L>, Offset<&'t M>>

Propagate the offset of a litmat to its contained literal/matrix.

Trait Implementations§

source§

impl<T: Clone> Clone for Offset<T>

source§

fn clone(&self) -> Offset<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<T: Debug> Debug for Offset<T>

source§

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

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

impl<'t, L> Display for Offset<&'t Clause<L>>where Offset<&'t L>: Display,

source§

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

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

impl<'t, P: Display, C: Display> Display for Offset<&'t Contrapositive<&'t Lit<P, C, usize>>>

source§

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

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

impl<'t, L: 't, M: 't> Display for Offset<&'t LitMat<L, M>>where Offset<&'t L>: Display, Offset<&'t M>: Display,

source§

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

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

impl<'t, C: 't> Display for Offset<&'t Matrix<C>>where Offset<&'t C>: Display,

source§

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

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

impl<'t, L: 't, V> Display for Offset<&'t VClause<L, V>>where Offset<&'t L>: Display,

source§

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

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

impl<T, I: IntoIterator<Item = T>> IntoIterator for Offset<I>

Convert an offset of a collection of Ts to a collection of offset Ts.

§

type Item = Offset<T>

The type of the elements being iterated over.
§

type IntoIter = Map<Zip<Repeat<usize>, <I as IntoIterator>::IntoIter>, fn(_: (usize, T)) -> Offset<T>>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: Copy> Copy for Offset<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Offset<T>where T: RefUnwindSafe,

§

impl<T> Send for Offset<T>where T: Send,

§

impl<T> Sync for Offset<T>where T: Sync,

§

impl<T> Unpin for Offset<T>where T: Unpin,

§

impl<T> UnwindSafe for Offset<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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, R> Rewind<PutRewind<T, R>> for Twhere T: Rewind<R>,

source§

fn rewind(&mut self, state: PutRewind<T, R>)

Rewind to some state.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.