HornSatisfiability

Struct HornSatisfiability 

Source
pub struct HornSatisfiability {
    literals: Vec<Option<bool>>,
    clauses: Vec<(usize, usize, bool)>,
    idx: Vec<Vec<usize>>,
    satisfiable: bool,
    stack: Vec<usize>,
}
Expand description

Horn Satisfiability

$\wedge(\wedge_i v_{p_i}\rightarrow v_q = f)$

Fields§

§literals: Vec<Option<bool>>§clauses: Vec<(usize, usize, bool)>§idx: Vec<Vec<usize>>§satisfiable: bool§stack: Vec<usize>

Implementations§

Source§

impl HornSatisfiability

Source

pub fn new(size: usize) -> Self

Source

pub fn add_clause( &mut self, p: impl IntoIterator<Item = usize>, q: usize, f: bool, )

Source

pub fn is_satisfiable(&self) -> bool

Source

pub fn solve(&self) -> Option<Vec<bool>>

Source

fn resolve(&mut self)

Examples found in repository?
crates/competitive/src/algorithm/horn_satisfiability.rs (line 35)
23    pub fn add_clause(&mut self, p: impl IntoIterator<Item = usize>, q: usize, f: bool) {
24        let mut count = 0;
25        let id = self.clauses.len();
26        for p_i in p.into_iter() {
27            if self.literals[p_i] != Some(true) {
28                self.idx[p_i].push(id);
29                count += 1;
30            }
31        }
32        self.clauses.push((count, q, f));
33        if count == 0 {
34            self.stack.push(id);
35            self.resolve();
36        }
37    }

Auto Trait Implementations§

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