pub struct BooleanDecisionDiagram { /* private fields */ }Expand description
Reduced ordered Boolean decision diagram with bounded construction work.
Implementations§
Source§impl BooleanDecisionDiagram
impl BooleanDecisionDiagram
Sourcepub fn with_limits(limits: BooleanLimits) -> Self
pub fn with_limits(limits: BooleanLimits) -> Self
Creates an empty diagram with explicit resource limits.
Sourcepub fn limits(&self) -> BooleanLimits
pub fn limits(&self) -> BooleanLimits
Returns the configured resource limits.
Sourcepub fn charge(&mut self, steps: usize) -> Result<(), BooleanResourceError>
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.
Sourcepub fn collect_garbage<'a>(
&mut self,
roots: impl IntoIterator<Item = &'a mut DecisionId>,
) -> usize
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.
Sourcepub fn evaluate(
&self,
root: DecisionId,
variable: impl FnMut(usize) -> bool,
) -> bool
pub fn evaluate( &self, root: DecisionId, variable: impl FnMut(usize) -> bool, ) -> bool
Evaluate one Boolean function without traversing unrelated choices.
Sourcepub fn witness(&self, root: DecisionId) -> Option<BTreeMap<usize, bool>>
pub fn witness(&self, root: DecisionId) -> Option<BTreeMap<usize, bool>>
One satisfying variable assignment; omitted variables are don’t-cares.
Sourcepub fn conjunction_witness(
&mut self,
roots: &[DecisionId],
) -> Result<Option<BTreeMap<usize, bool>>, BooleanResourceError>
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.
Sourcepub fn variables(&self, root: DecisionId) -> BTreeSet<usize>
pub fn variables(&self, root: DecisionId) -> BTreeSet<usize>
Returns every variable reachable from root.
Sourcepub fn constrain(
&mut self,
root: DecisionId,
care: DecisionId,
) -> Result<DecisionId, BooleanResourceError>
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.
Sourcepub fn nodes(&self) -> &[DecisionNode]
pub fn nodes(&self) -> &[DecisionNode]
Returns the nonterminal nodes in decision-id order.
Sourcepub fn make_node(
&mut self,
variable: usize,
low: DecisionId,
high: DecisionId,
) -> Result<DecisionId, BooleanResourceError>
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.
Sourcepub fn node(&self, id: DecisionId) -> Option<DecisionNode>
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.
Sourcepub fn cached_complement(&self, root: DecisionId) -> Option<DecisionId>
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.
Sourcepub fn negate(
&mut self,
root: DecisionId,
) -> Result<DecisionId, BooleanResourceError>
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.
Sourcepub fn apply(
&mut self,
operator: BooleanOp,
left: DecisionId,
right: DecisionId,
) -> Result<DecisionId, BooleanResourceError>
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.
Sourcepub fn values_up_to(
&mut self,
roots: &[DecisionId],
limit: usize,
) -> Result<Vec<Vec<bool>>, BooleanResourceError>
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
impl BooleanDecisionDiagram
Sourcepub fn start_witness_tape(
&mut self,
explicit_columns: impl IntoIterator<Item = usize>,
max_operations: usize,
) -> Result<(), BooleanResourceError>
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.
Sourcepub fn extend_witness_front(
&mut self,
columns: &[usize],
rows: &mut [BooleanRow],
) -> Result<(), BooleanResourceError>
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.
Sourcepub fn witness_collection_work(&self) -> usize
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.
Sourcepub fn finish_witness_tape(&mut self)
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
impl Clone for BooleanDecisionDiagram
Source§fn clone(&self) -> BooleanDecisionDiagram
fn clone(&self) -> BooleanDecisionDiagram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more