pub enum Expr {
Var(Variable),
Not(Box<Expr>),
And(Box<Expr>, Box<Expr>),
Or(Box<Expr>, Box<Expr>),
Val(bool),
}Expand description
Represents a boolean expression.
Expressions can be:
- A
Var(Variable): A propositional variable. - A
Not(Box<Expr>): The logical negation of an expression. - An
And(Box<Expr>, Box<Expr>): The logical conjunction of two expressions. - An
Or(Box<Expr>, Box<Expr>): The logical disjunction of two expressions. - A
Val(bool): A constant boolean value (trueorfalse).
Variants§
Var(Variable)
A propositional variable, identified by Variable.
Not(Box<Expr>)
Logical negation of an inner expression.
And(Box<Expr>, Box<Expr>)
Logical conjunction (AND) of two inner expressions.
Or(Box<Expr>, Box<Expr>)
Logical disjunction (OR) of two inner expressions.
Val(bool)
A constant boolean value (true or false).
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn unwrap_val(&self) -> bool
pub fn unwrap_val(&self) -> bool
Unwraps the boolean value if the expression is a Val variant.
§Panics
Panics if the expression is not Expr::Val(_).
Sourcepub fn unwrap_var(&self) -> Variable
pub fn unwrap_var(&self) -> Variable
Unwraps the variable identifier if the expression is a Var variant.
§Panics
Panics if the expression is not Expr::Var(_).
Sourcepub fn ors(expressions: &[Self]) -> Self
pub fn ors(expressions: &[Self]) -> Self
Creates a new expression representing the disjunction (OR) of all expressions in the slice e.
e_1 OR e_2 OR ... OR e_n.
The fold starts with Expr::Val(false) as the identity for OR (x OR false == x).
If e is empty, Expr::Val(false) is returned.
§Arguments
e: A slice ofExprto be OR-ed together.
§Returns
A new Expr representing the OR of all expressions in e.
§Panics
Panics if e is empty, as the OR of no elements is not defined.
Sourcepub fn ands(expressions: &[Self]) -> Self
pub fn ands(expressions: &[Self]) -> Self
Creates a new expression representing the conjunction (AND) of all expressions in the slice e.
e_1 AND e_2 AND ... AND e_n.
The fold starts with Expr::Val(true) as the identity for AND (x AND true == x).
If e is empty, Expr::Val(true) is returned.
§Arguments
e: A slice ofExprto be AND-ed together.
§Returns
A new Expr representing the AND of all expressions in e.
§Panics
Should not panic, but if e is empty, it returns Expr::Val(true).
Trait Implementations§
Source§impl Ord for Expr
impl Ord for Expr
Source§impl PartialOrd for Expr
impl PartialOrd for Expr
Source§impl<T: Literal, S: LiteralStorage<T>> TryFrom<Cnf<T, S>> for Expr
impl<T: Literal, S: LiteralStorage<T>> TryFrom<Cnf<T, S>> for Expr
impl Eq for Expr
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more