pub enum LogicalSExpr {
True,
False,
Var(String),
Not(Box<LogicalSExpr>),
Or(Box<LogicalSExpr>, Box<LogicalSExpr>),
And(Box<LogicalSExpr>, Box<LogicalSExpr>),
Iff(Box<LogicalSExpr>, Box<LogicalSExpr>),
Xor(Box<LogicalSExpr>, Box<LogicalSExpr>),
Ite(Box<LogicalSExpr>, Box<LogicalSExpr>, Box<LogicalSExpr>),
}
Variants§
True
False
Var(String)
Not(Box<LogicalSExpr>)
Or(Box<LogicalSExpr>, Box<LogicalSExpr>)
And(Box<LogicalSExpr>, Box<LogicalSExpr>)
Iff(Box<LogicalSExpr>, Box<LogicalSExpr>)
Xor(Box<LogicalSExpr>, Box<LogicalSExpr>)
Ite(Box<LogicalSExpr>, Box<LogicalSExpr>, Box<LogicalSExpr>)
Implementations§
Source§impl LogicalSExpr
impl LogicalSExpr
Sourcepub fn unique_variables(&self) -> HashSet<&String>
pub fn unique_variables(&self) -> HashSet<&String>
use rsdd::serialize::LogicalSExpr;
let expr =
serde_sexpr::from_str::<LogicalSExpr>("(Or (Var X) (Or (Not (Var X)) (Var Y)))").unwrap();
let vars = expr.unique_variables();
assert!(vars.len() == 2);
assert!(vars.contains(&String::from("X")));
assert!(vars.contains(&String::from("Y")));
Sourcepub fn variable_mapping(&self) -> HashMap<&String, usize>
pub fn variable_mapping(&self) -> HashMap<&String, usize>
use rsdd::serialize::LogicalSExpr;
let expr =
serde_sexpr::from_str::<LogicalSExpr>("(Or (Var X) (Or (Not (Var X)) (Var Y)))").unwrap();
let vars = expr.unique_variables();
let mapping = expr.variable_mapping();
assert_eq!(*mapping.get(&String::from("X")).unwrap(), 0);
assert_eq!(*mapping.get(&String::from("Y")).unwrap(), 1);
assert_eq!(mapping.get(&String::from("Z")), None);
Trait Implementations§
Source§impl Debug for LogicalSExpr
impl Debug for LogicalSExpr
Source§impl<'de> Deserialize<'de> for LogicalSExpr
impl<'de> Deserialize<'de> for LogicalSExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for LogicalSExpr
impl PartialEq for LogicalSExpr
Source§impl Serialize for LogicalSExpr
impl Serialize for LogicalSExpr
impl StructuralPartialEq for LogicalSExpr
Auto Trait Implementations§
impl Freeze for LogicalSExpr
impl RefUnwindSafe for LogicalSExpr
impl Send for LogicalSExpr
impl Sync for LogicalSExpr
impl Unpin for LogicalSExpr
impl UnwindSafe for LogicalSExpr
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