pub struct Lit { /* private fields */ }Expand description
Type representing literals, possibly negated boolean variables.
Implementations§
source§impl Lit
impl Lit
sourcepub fn new(idx: u32, negated: bool) -> Lit
pub fn new(idx: u32, negated: bool) -> Lit
Creates a new (negated or not) literal with a given index.
Panics if idx > Var::MAX_IDX.
sourcepub fn new_with_error(idx: u32, negated: bool) -> Result<Lit, TypeError>
pub fn new_with_error(idx: u32, negated: bool) -> Result<Lit, TypeError>
Creates a new (negated or not) literal with a given index.
Returns Err(TypeError::IdxTooHigh(idx, Var::MAX_IDX) if
idx > Var::MAX_IDX.
sourcepub fn new_unchecked(idx: u32, negated: bool) -> Lit
pub fn new_unchecked(idx: u32, negated: bool) -> Lit
Creates a new (negated or not) literal with a given index.
Does not perform any check on the index, therefore might produce an inconsistent variable.
Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.
sourcepub fn positive(idx: u32) -> Lit
pub fn positive(idx: u32) -> Lit
Creates a new positive literal with a given index.
Panics if idx > Var::MAX_IDX.
sourcepub fn negative(idx: u32) -> Lit
pub fn negative(idx: u32) -> Lit
Creates a new negated literal with a given index.
Panics if idx > Var::MAX_IDX.
sourcepub fn positive_with_error(idx: u32) -> Result<Lit, TypeError>
pub fn positive_with_error(idx: u32) -> Result<Lit, TypeError>
Creates a new positive literal with a given index.
Panics if idx > Var::MAX_IDX.
sourcepub fn negative_with_error(idx: u32) -> Result<Lit, TypeError>
pub fn negative_with_error(idx: u32) -> Result<Lit, TypeError>
Creates a new negated literal with a given index.
Panics if idx > Var::MAX_IDX.
sourcepub fn positive_unchecked(idx: u32) -> Lit
pub fn positive_unchecked(idx: u32) -> Lit
Creates a new positive literal with a given index.
Does not perform any check on the index, therefore might produce an inconsistent variable.
Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.
sourcepub fn negative_unchecked(idx: u32) -> Lit
pub fn negative_unchecked(idx: u32) -> Lit
Creates a new negated literal with a given index.
Does not perform any check on the index, therefore might produce an inconsistent variable.
Only use this for performance reasons if you are sure that idx <= Var::MAX_IDX.
sourcepub fn from_ipasir(val: c_int) -> Result<Lit, TypeError>
pub fn from_ipasir(val: c_int) -> Result<Lit, TypeError>
Create a literal from an IPASIR integer value. Returns an error if the value is zero or the index too high.
sourcepub fn var(&self) -> Var
pub fn var(&self) -> Var
Gets the variables that the literal corresponds to.
§Examples
let var = Var::new(5);
let lit = Lit::negative(5);
assert_eq!(var, lit.var());sourcepub fn to_ipasir(self) -> c_int
pub fn to_ipasir(self) -> c_int
Converts the literal to an integer as accepted by the IPASIR API and
similar. The IPASIR literal will have idx+1 and be negative if the
literal is negated. Panics if the literal does not fit into a c_int.
sourcepub fn to_ipasir_with_error(self) -> Result<c_int, TypeError>
pub fn to_ipasir_with_error(self) -> Result<c_int, TypeError>
Converts the literal to an integer as accepted by the IPASIR API and
similar. The IPASIR literal will have idx+1 and be negative if the
literal is negated. Returns Err(TypeError::IdxTooHigh(_, _)) if the
literal does not fit into a c_int.
Trait Implementations§
source§impl Extend<Lit> for Clause
impl Extend<Lit> for Clause
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl Extend<Lit> for DbTotalizer
impl Extend<Lit> for DbTotalizer
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl<UBE, LBE> Extend<Lit> for Double<UBE, LBE>
impl<UBE, LBE> Extend<Lit> for Double<UBE, LBE>
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl<CE> Extend<Lit> for Inverted<CE>
impl<CE> Extend<Lit> for Inverted<CE>
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl Extend<Lit> for Pairwise
impl Extend<Lit> for Pairwise
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl Extend<Lit> for Totalizer
impl Extend<Lit> for Totalizer
source§fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl FromIterator<Lit> for Assignment
impl FromIterator<Lit> for Assignment
source§impl FromIterator<Lit> for Clause
impl FromIterator<Lit> for Clause
source§impl FromIterator<Lit> for DbTotalizer
impl FromIterator<Lit> for DbTotalizer
source§impl<UBE, LBE> FromIterator<Lit> for Double<UBE, LBE>
impl<UBE, LBE> FromIterator<Lit> for Double<UBE, LBE>
source§impl<CE> FromIterator<Lit> for Inverted<CE>
impl<CE> FromIterator<Lit> for Inverted<CE>
source§impl FromIterator<Lit> for Pairwise
impl FromIterator<Lit> for Pairwise
source§impl FromIterator<Lit> for Totalizer
impl FromIterator<Lit> for Totalizer
source§impl Neg for Lit
impl Neg for Lit
Trait implementation allowing for negating literals with the unary - operator.
source§impl Ord for Lit
impl Ord for Lit
source§impl PartialOrd for Lit
impl PartialOrd for Lit
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more