boofun.core.representations.bdd
Binary Decision Diagram (BDD) representation for Boolean functions.
This module implements Reduced Ordered Binary Decision Diagrams (ROBDDs) for efficient representation and manipulation of Boolean functions.
Classes
|
Reduced Ordered Binary Decision Diagram. |
|
Node in a Binary Decision Diagram. |
BDD representation for Boolean functions. |
- class boofun.core.representations.bdd.BDDNode(var: int | None = None, low: BDDNode | None = None, high: BDDNode | None = None, value: bool | None = None)[source]
Node in a Binary Decision Diagram.
- var
Variable index (None for terminal nodes)
- low
Low branch (False branch)
- high
High branch (True branch)
- is_terminal
Whether this is a terminal node
- value
Terminal value (only for terminal nodes)
- class boofun.core.representations.bdd.BDD(n_vars: int)[source]
Reduced Ordered Binary Decision Diagram.
Implements a canonical representation of Boolean functions with efficient operations for evaluation, manipulation, and analysis.
- create_node(var: int, low: BDDNode, high: BDDNode) BDDNode[source]
Create or retrieve BDD node (with reduction).
- Parameters:
var – Variable index
low – Low branch
high – High branch
- Returns:
BDD node
- class boofun.core.representations.bdd.BDDRepresentation[source]
BDD representation for Boolean functions.
- evaluate(inputs: ndarray, data: BDD, space: Space, n_vars: int) bool | ndarray[source]
Evaluate BDD representation.
- Parameters:
inputs – Input values (integer indices or binary vectors)
data – BDD
space – Evaluation space
n_vars – Number of variables
- Returns:
Boolean result(s)
- convert_from(source_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) BDD[source]
Convert from another representation to BDD.
Uses truth table to build BDD.
- convert_to(target_repr: BooleanFunctionRepresentation, source_data: Any, space: Space, n_vars: int, **kwargs) ndarray[source]
Convert BDD to another representation.