Skip to main content

BooleanDecisionDiagram

Struct BooleanDecisionDiagram 

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

Reduced ordered Boolean decision diagram with bounded construction work.

Implementations§

Source§

impl BooleanDecisionDiagram

Source

pub fn with_limits(limits: BooleanLimits) -> Self

Creates an empty diagram with explicit resource limits.

Source

pub fn limits(&self) -> BooleanLimits

Returns the configured resource limits.

Source

pub fn steps(&self) -> usize

Returns cumulative charged work.

Source

pub fn charge(&mut self, steps: usize) -> Result<(), BooleanResourceError>

Charge before traversal or allocation. Collection and cloning preserve consumed work; an error never stands in for a Boolean result. Cheap constant/cache returns do not consume steps. Callers must charge their own loops, including loops over constant Boolean expressions.

§Errors

Returns BooleanResourceError if charging steps exceeds the work limit.

Source

pub fn collect_garbage<'a>( &mut self, roots: impl IntoIterator<Item = &'a mut DecisionId>, ) -> usize

Rebuild the diagram from all live roots, removing dead intermediate functions and operation caches. Variable indices do not change.

Every surviving DecisionId must be passed here: ids are renumbered, and any unlisted external ids become invalid. Collect only at a boundary where the caller owns the complete root set.

Source

pub fn evaluate( &self, root: DecisionId, variable: impl FnMut(usize) -> bool, ) -> bool

Evaluate one Boolean function without traversing unrelated choices.

Source

pub fn witness(&self, root: DecisionId) -> Option<BTreeMap<usize, bool>>

One satisfying variable assignment; omitted variables are don’t-cares.

Source

pub fn conjunction_witness( &mut self, roots: &[DecisionId], ) -> Result<Option<BTreeMap<usize, bool>>, BooleanResourceError>

Finds one assignment satisfying every supplied decision.

§Errors

Returns BooleanResourceError if the search exceeds the work limit.

Source

pub fn variables(&self, root: DecisionId) -> BTreeSet<usize>

Returns every variable reachable from root.

Source

pub fn constrain( &mut self, root: DecisionId, care: DecisionId, ) -> Result<DecisionId, BooleanResourceError>

Simplify a function outside its care set. The returned function equals root wherever care holds; impossible selector combinations are free.

§Errors

Returns BooleanResourceError if construction exceeds configured limits.

§Panics

Panics if either decision does not belong to this diagram.

Source

pub fn nodes(&self) -> &[DecisionNode]

Returns the nonterminal nodes in decision-id order.

Source

pub fn make_node( &mut self, variable: usize, low: DecisionId, high: DecisionId, ) -> Result<DecisionId, BooleanResourceError>

Returns the reduced node for variable, low, and high.

§Errors

Returns BooleanResourceError if allocation exceeds configured limits.

Source

pub fn node(&self, id: DecisionId) -> Option<DecisionNode>

Returns the nonterminal node named by id, or None for a terminal.

§Panics

Panics if id names a nonterminal outside this diagram.

Source

pub fn cached_complement(&self, root: DecisionId) -> Option<DecisionId>

Returns an already known exact complement without constructing nodes. Constants always have known complements.

§Panics

Panics if root does not belong to this diagram.

Source

pub fn negate( &mut self, root: DecisionId, ) -> Result<DecisionId, BooleanResourceError>

Returns the logical negation of root.

§Errors

Returns BooleanResourceError if construction exceeds configured limits.

§Panics

Panics if root does not belong to this diagram.

Source

pub fn apply( &mut self, operator: BooleanOp, left: DecisionId, right: DecisionId, ) -> Result<DecisionId, BooleanResourceError>

Fold constants before visiting decision pairs. All operators commute.

§Errors

Returns BooleanResourceError if construction exceeds configured limits.

Source

pub fn values_up_to( &mut self, roots: &[DecisionId], limit: usize, ) -> Result<Vec<Vec<bool>>, BooleanResourceError>

Enumerate at most limit distinct output tuples, charging residual states and their coordinates before allocating them.

§Errors

Returns BooleanResourceError if enumeration exceeds the work limit.

Source§

impl BooleanDecisionDiagram

Source

pub fn start_witness_tape( &mut self, explicit_columns: impl IntoIterator<Item = usize>, max_operations: usize, ) -> Result<(), BooleanResourceError>

Start an owned tape for passive row coefficients. Every deferred row shares this explicit-column partition; keep every row-space constraint column explicit until all rows are expanded. Passive coordinates can be read with BooleanRow::probe_coefficients. Operation bounds include dead history, and construction/reconstruction spend the same work meter.

§Errors

Returns BooleanResourceError if indexing columns exceeds configured limits.

§Panics

Panics if a witness tape is already active.

Source

pub fn extend_witness_front( &mut self, columns: &[usize], rows: &mut [BooleanRow], ) -> Result<(), BooleanResourceError>

Promote coordinates into the shared explicit row front without expanding other coefficients. The caller must supply every surviving deferred row owned by this tape, including rows retained for later queries or replay. No deferred clone outside rows may be used after this boundary. Explicit rows may also be supplied and remain unchanged.

Raw coefficients, including off-activation values, are queried under the old partition. Row fronts and the partition change only after all work succeeds; a failure retains the tape and rows without refunding spent work. Activation and witness handles never change, and columns are never demoted. Fixed roots share one topological evaluation per new column; intermediate values for different columns are never stored together.

§Errors

Returns BooleanResourceError if querying or staging exceeds resource limits.

§Panics

Panics if no witness tape is active.

Source

pub fn witness_collection_work(&self) -> usize

Additional owned tape nodes and decision handles walked by collection. Charge this together with the arena and external roots before collecting.

Source

pub fn finish_witness_tape(&mut self)

Release the tape after every retained deferred row has been expanded.

Trait Implementations§

Source§

impl Clone for BooleanDecisionDiagram

Source§

fn clone(&self) -> BooleanDecisionDiagram

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 BooleanDecisionDiagram

Source§

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

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

impl Default for BooleanDecisionDiagram

Source§

fn default() -> BooleanDecisionDiagram

Returns the “default value” for a type. 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
§

impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
where T: BorrowMut<BorrowedSelf>, BorrowedSelf: BitwiseMut + ?Sized,

§

fn assign_index(&mut self, index: usize, to: bool)

§

fn negate_index(&mut self, index: usize)

§

fn clear_bits(&mut self)

§

fn assign_random( &mut self, bit_count: usize, random_number_generator: &mut impl RngExt, )
where BorrowedSelf: BitLength,

§

impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
where Bits: BorrowMut<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePairMut<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn assign(&mut self, other: &Other)

§

fn bitxor_assign(&mut self, other: &Other)

§

fn bitand_assign(&mut self, other: &Other)

§

fn bitor_assign(&mut self, other: &Other)

§

impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
where T: Borrow<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePair<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn dot(&self, other: &Other) -> bool

§

fn and_weight(&self, other: &Other) -> usize

§

fn or_weight(&self, other: &Other) -> usize

§

fn xor_weight(&self, other: &Other) -> usize

§

impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
where T: Borrow<BorrowedSelf>, BorrowedSelf: Bitwise + ?Sized,

§

fn index(&self, index: usize) -> bool

§

fn weight(&self) -> usize

§

fn parity(&self) -> bool

§

fn is_zero(&self) -> bool

§

fn is_unit(&self, index: usize) -> bool

§

fn support<'a>(&'a self) -> impl SortedIterator
where BorrowedSelf: 'a,

§

fn max_support(&self) -> Option<usize>

§

fn min_support(&self) -> Option<usize>

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