BDD Module
This module implements BDDs where nodes of the BDD refer directly to boolean expressions. To use the module, the local data structures must first be initialized with a sequence of boolean expressions using the Initialize function. The given sequence of boolean expressions determines the set of variables and the variable order by mapping the listed expressions to BDD variables (of type BDDIndex) in the given order. After that, the typical BDD functions can be used. From time to time, the user should call the GarbageCollect function to collect garbage nodes that can be reused later. Note that garbage collection resets the computed table, so garbage collection should not be called too often, otherwise performance will decrease. The order is stored in Index2BoolExpr and can be changed with the SwapVar function. If the variable order is changed, the computed table must be reset.
Types
Type | Description |
AtomIndex is used to label the Bdd nodes (and map them to expressions) |
|
BddAdr is used to map Bdd addresses to BddNodes (found in the local Bdd memory) |
|
BDD nodes consist of an index that is mapped via Index2BoolExpr to a boolean expression, two BDD addresses that are the addresses of the positive and negative cofactors, and an optional BDD address that is used to chain all BddNodes with the same indices (the head of this chain is given by IndexHead[this.idx] |
|
Allowed boolean operations for the Apply operation. Thus, "Apply CONJ" computes the conjunction of two BDDs, etc. |
Functions and values
Function or value | Description |
|
|
Full Usage:
Apply oper bddAdr1 bddAdr2
Parameters:
BinBoolOps
bddAdr1 : BddAdr
bddAdr2 : BddAdr
Returns: BddAdr
|
Apply a binary boolean operator to two given BDDs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Constrain careAdr bddAdr computes a BDD that is equivalent to bddAdr at least in those cases where BDD careAdr holds. If careAdr is false, the result may differ arbitrarily from bddAdr. Usually, the resulting BDD is smaller and thus, the values outside the care set are chosen for minimization of bddAdr.
|
|
|
|
|
Full Usage:
EnumPermutationsBySwapSequence n
Parameters:
int
Returns: int list
|
Enumerate all permutations by a sequence of swaps according to the Steinhaus-Johnson-Trotter algorithm. The resulting list is a list of integers where integer i denotes a swap(i,i-1) of a list of elements [0..n]. Note that the result list has size (n!-1) and can be used for determining the optimal variable ordering in that these swaps are used to enumerate all orderings. A better use is by heuristics like the WindowPermutation or Sifting.
|
|
|
|
|
|
Relation product: propositional formulas r(x,e) and q(e,y) over sets of variables x,e,y, we compute the propositional formula p(x,y) = exists e. r(x,e) & q(e,y). If r and q are interpreted as binary relations, this implements therefore the relation product. This is an important function for model checking to compute existential predecessor and successor states (up to renaming of old and new variables).
|
|
|
|
GarbageCollect removes all nodes except for those used by the given list of BDDs (their roots are given) from the internal data structures. The removed nodes are then reused by the MkBddNode.
|
|
|
|
Index2BoolExpr maps an index to the corresponding boolean expression. It is the reverse to function BoolExpr2Index.
|
IndexHead maps an index to the first BDDNode labeled by this index; the other nodes with this index are found by following the nxt pointers
|
|
|
This function is used to initialize the BDD module with a list of boolean atoms eL. Note that this defines the initial ordering as given in eL and that the list must not contain multiple occurrences of the same expression.
|
|
|
|
|
the BDD memory that maps BddAdrs to BddNodes
|
|
|
Function MkBddNode checks whether a node with the specified components already exists and if so returns its address; otherwise such a node is created and its address is returned. If there are nodes that are declared to be reusable by GarbageCollect, then these nodes are reused.
|
|
|
|
|
|
|
NextSat is used to compute the model of a BDD bddAdr that is the next one found in a neg-pos traversal over the BDD starting from the path determined by the given model. The function returns a pair (success,model) where success holds if another model has been found, and if so, model is that model. Otherwise, model is the empty map. |
|
|
Count the number of internal nodes of a list of BDDs (shared nodes are only counted once).
|
|
OneSat computes a satisfying truth assignment of a BDD. The result is a map that assigns some of the BDD indices a boolean truth values. If an index vi is not mapped to a boolean value, then vi is a don't care value in this assignment. Note that the result is only a model if bddAdr>0 holds.
|
Full Usage:
OptimalVarOrder bddL
Parameters:
BddAdr list
Returns: string array * int * (string array * int) list
|
OptimalVarOrder computes for a list of BDDs the optimal variable ordering by checking all permutations of the variable orders. It is of course a very expensive algorithm whose runtime depends on n! since we enumerate all orderings (in contrast to [FrSu87]). The function computes a triple (varOrd,numNodes,voL) where varOrd is one of the optimal variable orderings, numNodes is the number of nodes needed for it, and voL is the list of pairs (varOrd,numNodes) for all variable orderings.
|
|
|
Relabel works similar to Compose: It replaces all atoms in a given BDD with address bddAdr according to the substitution rho. Its use is in particular for replacing now- and next-variables in model-checking. It is assumed that rho maps all variables occurring in bddAdr to other atoms.
|
|
|
|
|
|
Full Usage:
SetAllocNodes n
Parameters:
int
|
SetAllocNodes determines the number of BDD nodes that are initially created, and that are added if that number should not be sufficient. The default value without calling this function is 1000000 nodes, and will be changed by this function.
|
|
|
|
Sifting is the well-known sifting algorithm to optimize the variable ordering with polynomially many swap operations. If printFlag is true then the swap operations and the numbers of nodes are printed. At the end, the BDDs have the best variable ordering found by sifting.
|
|
Solves a propositional logic formula phi by means of the BDD package. If there is no model, the result is None, otherwise, a model is returned as a mapping of BoolExpr to boolean truth values. Caution: This function initializes the BDD package with the atoms of the given expression.
|
|
SwapSequence computes for two arrays that contain the same elements, a list of swap operations to transform the first array into the second one. The swap sequence is computed by bubblesort like moves. To apply it on variable orderings, do not forget to add the leaf nodes like Array.append [|BoolConst false; BoolConst true|] varOrder
|
|
SwapVar is used as basic operation for optimizing variable orderings. The function swaps the assignment of the indices vi and vi-1 to boolean expressions so that the variable ordering is changed. Note that vi must be greater than 2 since BDD variables cannot be changed with leafs. Note that the indices are still kept in the order 0,1,2,... so that only Index2BoolExpr is changed together will all existing BDDs.
|
Full Usage:
WriteBddList2DotFile writeLF writeNxt bddAdrL outStr
Parameters:
bool
writeNxt : bool
bddAdrL : BddAdr seq
outStr : TextWriter
|
Write a list of BDDs in DOT format to an output stream. If writeLF holds, also the false leafs are drawn, otherwise only true leafs are shown and missing edges point to the not shown false-leaf. If writeNxt holds, also the next-pointers between nodes labeled with the same AtomIndex are drawn.
|
Full Usage:
WriteGlobalDotFile writeLF writeNxt outStr
Parameters:
bool
writeNxt : bool
outStr : TextWriter
|
Write all BDDs of the current manager in DOT format to an output stream. If writeLF holds, also the false leafs are drawn, otherwise only true leafs are shown and missing edges point to the not shown false-leaf. If writeNxt holds, also the next-pointers between nodes labeled with the same AtomIndex are drawn.
|