Struct Theory

Source
pub struct Theory { /* private fields */ }
Expand description

A Theory is a set of alternative PropositionalFormulas.

It corresponds to one particular branch of the tableau tree.

Implementations§

Source§

impl Theory

Source

pub fn new() -> Self

Construct an empty theory.

Source

pub fn from_propositional_formula(formula: PropositionalFormula) -> Self

Construct a Theory from a given propositional formula.

Source

pub fn formulas(&self) -> impl Iterator<Item = &PropositionalFormula>

Get the formulas.

Source

pub fn add(&mut self, formula: PropositionalFormula)

Add a propositional formula to the theory iff the theory does not already contain the formula.

Source

pub fn is_fully_expanded(&self) -> bool

Checks if the Theory is fully expanded, i.e. each propositional_formula in the given Theory is a literal (e.g. p, -(p), a propositional variable or its negation).

Source

pub fn has_contradictions(&self) -> bool

Checks if a Theory contains contradictions. That is, if the Theory contains a literal p AND its negation -p.

§Space and Time Complexity

This function uses a HashMap (specifically, a map from some &str to the tuple (has_literal, has_negation): (bool, bool). As soon as we encounter the case where has_literal && has_negation then we have found a contradiction.

  • Worst-case time complexity: O(n) because we iterate through all of the formulas for the given theory.
  • Worst-case space complexity: O(k) for k propositional variables appearing in literals.
Source

pub fn get_non_literal_formula(&mut self) -> Option<PropositionalFormula>

Get a non-literal formula (not a propositional variable or its negation) from the current Theory.

Source

pub fn swap_formula( &mut self, existing: &PropositionalFormula, replacement: PropositionalFormula, )

Replace existing formula with a new formula.

Source

pub fn swap_formula2( &mut self, existing: &PropositionalFormula, replacements: (PropositionalFormula, PropositionalFormula), )

Replace existing formula with two new formulas.

Trait Implementations§

Source§

impl Clone for Theory

Source§

fn clone(&self) -> Theory

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 Debug for Theory

Source§

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

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

impl PartialEq for Theory

Source§

fn eq(&self, other: &Theory) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Theory

Auto Trait Implementations§

§

impl Freeze for Theory

§

impl RefUnwindSafe for Theory

§

impl Send for Theory

§

impl Sync for Theory

§

impl Unpin for Theory

§

impl UnwindSafe for Theory

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> 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, 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.