Skip to main content

BddManager

Struct BddManager 

Source
pub struct BddManager { /* private fields */ }
Expand description

A Binary Decision Diagram manager. Maintains a unique table to ensure node sharing and canonical representation.

Implementations§

Source§

impl BddManager

Source

pub fn new() -> Self

Creates a new BDD manager.

Source

pub fn constant_false(&self) -> NodeId

Returns the FALSE constant.

Source

pub fn constant_true(&self) -> NodeId

Returns the TRUE constant.

Source

pub fn variable(&mut self, var: VarId) -> NodeId

Creates a BDD for a single variable.

Source

pub fn not(&mut self, node: NodeId) -> NodeId

Negates a BDD node.

Runs on an explicit work-stack with a computed table (not_cache), rather than the tree recursion this replaces. Two defects are fixed:

  • The recursion had no computed table, so every shared node was re-expanded. not on a 40-variable parity BDD — O(n) nodes, 2ⁿ tree unfoldings — never returned.
  • Recursion depth was the BDD height, i.e. the variable count, with no guard. The return type is NodeId, so a depth cap could only have produced a silently wrong diagram.
Source

pub fn and(&mut self, left: NodeId, right: NodeId) -> NodeId

Computes the AND of two BDD nodes.

Source

pub fn or(&mut self, left: NodeId, right: NodeId) -> NodeId

Computes the OR of two BDD nodes.

Source

pub fn xor(&mut self, left: NodeId, right: NodeId) -> NodeId

Computes the XOR of two BDD nodes.

Source

pub fn implies(&mut self, left: NodeId, right: NodeId) -> NodeId

Computes the implication: left => right (equivalent to !left | right)

Source

pub fn iff(&mut self, left: NodeId, right: NodeId) -> NodeId

Computes the equivalence: left <=> right

Source

pub fn ite( &mut self, cond: NodeId, then_node: NodeId, else_node: NodeId, ) -> NodeId

If-then-else operation: if cond then then_node else else_node.

Runs on an explicit work-stack with the standard ITE computed table keyed on the (cond, then, else) triple. The recursion this replaces had neither: with triple fan-out and no memo, shared cofactors of the hash-consed diagram were re-expanded exponentially, and the depth was the (unguarded) variable count. NodeId has no error channel, so a depth cap could only have returned a silently wrong diagram.

Source

pub fn eval(&self, node: NodeId, assignment: &FxHashMap<VarId, bool>) -> bool

Evaluates a BDD with a given variable assignment.

Source

pub fn sat_count(&self, node: NodeId, num_vars: u32) -> u64

Counts the number of satisfying assignments for a BDD.

Source

pub fn node_count(&self) -> usize

Returns the number of nodes in the manager.

Source

pub fn clear_cache(&mut self)

Clears the operation caches (useful for memory management).

Trait Implementations§

Source§

impl Clone for BddManager

Source§

fn clone(&self) -> BddManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BddManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BddManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for BddManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.