pub enum NnfFormula {
Atom(usize),
NegAtom(usize),
And(Box<NnfFormula>, Box<NnfFormula>),
Or(Box<NnfFormula>, Box<NnfFormula>),
Top,
Bot,
}Expand description
A propositional formula in NNF (Negation Normal Form).
In NNF, negations appear only at atoms (literals). This simplifies many proof-theoretic manipulations.
Variants§
Atom(usize)
A positive atom (propositional variable index).
NegAtom(usize)
A negated atom.
And(Box<NnfFormula>, Box<NnfFormula>)
Conjunction.
Or(Box<NnfFormula>, Box<NnfFormula>)
Disjunction.
Top
The constant True.
Bot
The constant False.
Implementations§
Source§impl NnfFormula
impl NnfFormula
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Check if the formula is a literal (atom or negated atom).
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Count the number of atoms in the formula.
Sourcepub fn connective_count(&self) -> usize
pub fn connective_count(&self) -> usize
Count the number of connectives in the formula.
Sourcepub fn eval(&self, assignment: &[bool]) -> bool
pub fn eval(&self, assignment: &[bool]) -> bool
Evaluate the formula under a truth assignment (variable index → bool).
Sourcepub fn simplify(self) -> NnfFormula
pub fn simplify(self) -> NnfFormula
Simplify by eliminating Top/Bot.
Trait Implementations§
Source§impl Clone for NnfFormula
impl Clone for NnfFormula
Source§fn clone(&self) -> NnfFormula
fn clone(&self) -> NnfFormula
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NnfFormula
impl Debug for NnfFormula
Source§impl PartialEq for NnfFormula
impl PartialEq for NnfFormula
impl Eq for NnfFormula
impl StructuralPartialEq for NnfFormula
Auto Trait Implementations§
impl Freeze for NnfFormula
impl RefUnwindSafe for NnfFormula
impl Send for NnfFormula
impl Sync for NnfFormula
impl Unpin for NnfFormula
impl UnsafeUnpin for NnfFormula
impl UnwindSafe for NnfFormula
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
Mutably borrows from an owned value. Read more