pub struct BddVariableSet { /* private fields */ }
Expand description

Maintains the set of variables that can appear in a Bdd. Used to create new Bdds for basic formulas.

Implementations§

source§

impl BddVariableSet

Methods for evaluating boolean expressions.

source

pub fn safe_eval_expression( &self, expression: &BooleanExpression ) -> Option<Bdd>

Evaluate the given BooleanExpression in the context of this BddVariableSet. Return None if some variables are unknown.

source

pub fn eval_expression(&self, expression: &BooleanExpression) -> Bdd

Evaluate the given BooleanExpression in the context of this BddVariableSet. Panic if some variables are unknown.

source

pub fn eval_expression_string(&self, expression: &str) -> Bdd

Evaluate the given String as a BooleanExpression in the context of this BddVariableSet.

Panics if the expression cannot be parsed or contains unknown variables.

source§

impl BddVariableSet

source

pub fn new_anonymous(num_vars: u16) -> BddVariableSet

Create a new BddVariableSet with anonymous variables $(x_0, \ldots, x_n)$ where $n$ is the num_vars parameter.

source

pub fn new(vars: &[&str]) -> BddVariableSet

Create a new BddVariableSet with the given named variables. Same as using the BddVariablesBuilder with this name vector, but no BddVariable objects are returned.

Panics: vars must contain unique names which are allowed as variable names.

source

pub fn num_vars(&self) -> u16

Return the number of variables in this set.

source

pub fn var_by_name(&self, name: &str) -> Option<BddVariable>

Create a BddVariable based on a variable name. If the name does not appear in this set, return None.

source

pub fn variables(&self) -> Vec<BddVariable>

Provides a vector of all BddVariables in this set.

source

pub fn name_of(&self, variable: BddVariable) -> String

Obtain the name of a specific BddVariable.

source

pub fn mk_true(&self) -> Bdd

Create a Bdd corresponding to the true formula.

source

pub fn mk_false(&self) -> Bdd

Create a Bdd corresponding to the false formula.

source

pub fn mk_var(&self, var: BddVariable) -> Bdd

Create a Bdd corresponding to the $v$ formula where v is a specific variable in this set.

Panics: var must be a valid variable in this set.

source

pub fn mk_not_var(&self, var: BddVariable) -> Bdd

Create a BDD corresponding to the $\neg v$ formula where v is a specific variable in this set.

Panics: var must be a valid variable in this set.

source

pub fn mk_literal(&self, var: BddVariable, value: bool) -> Bdd

Create a BDD corresponding to the $v <=> \texttt{value}$ formula.

Panics: var must be a valid variable in this set.

source

pub fn mk_var_by_name(&self, var: &str) -> Bdd

Create a BDD corresponding to the $v$ formula where v is a variable in this set.

Panics: var must be a name of a valid variable in this set.

source

pub fn mk_not_var_by_name(&self, var: &str) -> Bdd

Create a BDD corresponding to the $\neg v$ formula where v is a variable in this set.

Panics: var must be a name of a valid variable in this set.

source

pub fn mk_conjunctive_clause(&self, clause: &BddPartialValuation) -> Bdd

Create a Bdd corresponding to the conjunction of literals in the given BddPartialValuation.

For example, given a valuation x = true, y = false and z = true, create a Bdd for the formula x & !y & z. An empty valuation evaluates to true.

Panics: All variables in the partial valuation must belong into this set.

source

pub fn mk_disjunctive_clause(&self, clause: &BddPartialValuation) -> Bdd

Create a Bdd corresponding to the disjunction of literals in the given BddPartialValuation.

For example, given a valuation x = true, y = false and z = true, create a Bdd for the formula x | !y | z. An empty valuation evaluates to false.

Panics: All variables in the valuation must belong into this set.

source

pub fn mk_cnf(&self, cnf: &[BddPartialValuation]) -> Bdd

Interpret each BddPartialValuation in cnf as a disjunctive clause, and produce a conjunction of such clauses. Effectively, this constructs a formula based on its conjunctive normal form.

source

pub fn mk_dnf(&self, dnf: &[BddPartialValuation]) -> Bdd

Interpret each BddPartialValuation in dnf as a conjunctive clause, and produce a disjunction of such clauses. Effectively, this constructs a formula based on its disjunctive normal form.

source

pub fn mk_sat_up_to_k(&self, k: usize, variables: &[BddVariable]) -> Bdd

Build a BDD that is satisfied by all valuations where up to $k$ variables are true.

Intuitively, this implements a “threshold function” $f(x) = (\sum_{i} x_i \leq k)$ over the given variables.

source

pub fn mk_sat_exactly_k(&self, k: usize, variables: &[BddVariable]) -> Bdd

Build a BDD that is satisfied by all valuations where exactly $k$ variables are true.

Intuitively, this implements an “equality function” $f(x) = (\sum_{i} x_i = k)$ over the given variables.

source

pub fn transfer_from(&self, bdd: &Bdd, ctx: &BddVariableSet) -> Option<Bdd>

This function takes a Bdd bdd together with its BddVariableSet ctx and attempts to translate this bdd using the variables of this BddVariableSet.

In other words, the source and the output Bdd are logically equivalent, but each is valid in its respective BddVariableSet.

§Limitations

Currently, this method is implemented through “unsafe” variable renaming. I.e. it will not actually modify the structure of the Bdd in any way. As such, the method can fail (return None) when:

  • The bdd contains variables that are not present in this BddVariableSet (matching is performed based on variable names and the support set of bdd).
  • The variables used in bdd are ordered in a way that is not compatible with this BddVariableSet.

Trait Implementations§

source§

impl Clone for BddVariableSet

source§

fn clone(&self) -> BddVariableSet

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<Vec<&str>> for BddVariableSet

source§

fn from(value: Vec<&str>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<String>> for BddVariableSet

source§

fn from(value: Vec<String>) -> Self

Converts to this type from the input type.
source§

impl FromIterator<String> for BddVariableSet

source§

fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self

Creates a value from an iterator. Read more

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V