Averest


BDD Module

This module implements a simple BDD package where nodes of the BDD directly refer to boolean Quartz expressions. For using the package, one first has to initialize the BDD manager which is done by the function Initialize. To this end, the maximal number of available nodes has to be specified as well as a list of boolean Quartz expressions that are mapped in the given order to BDD variables (of type BDDIndex). After that, one may use the typical BDD functions that will then create new nodes when necessary (unless the desired node does not yet exist). The user should invoke from time to time function GarbageCollect to allow the BDD package to reuse nodes that are no longer variable needed. The ordering is stored in Index2BoolExpr and can be modified with function SwapVar.

Types

Type Description

AtomIndex

AtomIndex is used to label the Bdd nodes (and map them to expressions)

BddAdr

BddAdr is used to map Bdd addresses to BddNodes (found in the local Bdd memory)

BddNode

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]

BinBoolOps

Allowed boolean operations for the Apply operation. Thus, "Apply CONJ" computes the conjunction of two BDDs, etc.

Functions and values

Function or value Description

AllSat bddAdr

Full Usage: AllSat bddAdr

Parameters:
Returns: Map<AtomIndex, bool> list

AllSat computes the list of all models of a BDD by enumerating all paths from the root to the true-leaf as truth assignments to indices.

bddAdr : BddAdr
Returns: Map<AtomIndex, bool> list

Apply oper bddAdr1 bddAdr2

Full Usage: Apply oper bddAdr1 bddAdr2

Parameters:
Returns: BddAdr

Apply a binary boolean operator to two given BDDs.

oper : BinBoolOps
bddAdr1 : BddAdr
bddAdr2 : BddAdr
Returns: BddAdr

AtomsOfBoolExpr e

Full Usage: AtomsOfBoolExpr e

Parameters:
Returns: BoolExpr list

compute atoms of a BoolExpr in some random order (which can be used to initialize the BDD package)

e : BoolExpr
Returns: BoolExpr list

BoolExpr2Bdd e

Full Usage: BoolExpr2Bdd e

Parameters:
Returns: BddAdr

convert a BoolExpr to a Bdd (it is assumed that the atoms of e are at least a subset of the atom set used with Initialize) and that there are no nested BoolNext operators in the formula

e : BoolExpr
Returns: BddAdr

BoolExpr2Index

Full Usage: BoolExpr2Index

Returns: Map<BoolExpr, AtomIndex>

BoolExpr2Index maps a boolean atom to an AtomIndex. It is the reverse function of Index2BoolExpr.

Returns: Map<BoolExpr, AtomIndex>

CheckImplies bddAdr1 bddAdr0

Full Usage: CheckImplies bddAdr1 bddAdr0

Parameters:
Returns: bool

Check whether bddAdr1 implies bddAdr0. This is done without constructing the Bdd for the implication and therefore usually faster and produces no garbage nodes.

bddAdr1 : BddAdr
bddAdr0 : BddAdr
Returns: bool

Compose vi bddAdrA bddAdrB

Full Usage: Compose vi bddAdrA bddAdrB

Parameters:
Returns: BddAdr

Compose replaces nodes labeled with vi by bddAdrA in bddAdrB.

vi : AtomIndex
bddAdrA : BddAdr
bddAdrB : BddAdr
Returns: BddAdr

Constrain careAdr bddAdr

Full Usage: Constrain careAdr bddAdr

Parameters:
Returns: BddAdr

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.

careAdr : BddAdr
bddAdr : BddAdr
Returns: BddAdr

CraigInterpolant bddAdr1 bddAdr2

Full Usage: CraigInterpolant bddAdr1 bddAdr2

Parameters:
Returns: BddAdr

Computing a Craig interpolant of two BDDs

bddAdr1 : BddAdr
bddAdr2 : BddAdr
Returns: BddAdr

CubeCount bddAdr

Full Usage: CubeCount bddAdr

Parameters:
Returns: BigInteger

Compute the number of satisfying cubes.

bddAdr : BddAdr
Returns: BigInteger

EnumPermutationsBySwapSequence n

Full Usage: EnumPermutationsBySwapSequence n

Parameters:
    n : 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.

n : int
Returns: int list

EnumerateAllBDDs eL

Full Usage: EnumerateAllBDDs eL

Parameters:
Returns: BddAdr list

This function enumerates all BDDs for all the Boolean functions over the atoms listed in eL (which were used to Initialize the BDD package).

eL : BoolExpr list
Returns: BddAdr list

Exists varBddAdr quanBddAdr

Full Usage: Exists varBddAdr quanBddAdr

Parameters:
Returns: BddAdr

Existential quantification: The set of variables that are existentially quantified is provided as a conjunction of these variables as a BDD varBddAdr (thus the negative cofactors of varBddAdr are all false).

varBddAdr : BddAdr
quanBddAdr : BddAdr
Returns: BddAdr

ExistsAnd eBddAdr rBddAdr qBddAdr

Full Usage: ExistsAnd eBddAdr rBddAdr qBddAdr

Parameters:
Returns: int

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

eBddAdr : BddAdr
rBddAdr : BddAdr
qBddAdr : BddAdr
Returns: int

Forall varBddAdr quanBddAdr

Full Usage: Forall varBddAdr quanBddAdr

Parameters:
Returns: BddAdr

Universal quantification: The set of variables that are universally quantified is provided as a conjunction of these variables as a BDD varBddAdr (thus the negative cofactors of varBddAdr are all false).

varBddAdr : BddAdr
quanBddAdr : BddAdr
Returns: BddAdr

GarbageCollect bddAdrL

Full Usage: GarbageCollect bddAdrL

Parameters:

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.

bddAdrL : BddAdr list

ITE bddAdrC bddAdr1 bddAdr0

Full Usage: ITE bddAdrC bddAdr1 bddAdr0

Parameters:
Returns: BddAdr

Compute the if-then-else operation of given BDDs bddCond, bdd1 and bdd0.

bddAdrC : BddAdr
bddAdr1 : BddAdr
bddAdr0 : BddAdr
Returns: BddAdr

Index2BoolExpr

Full Usage: Index2BoolExpr

Returns: BoolExpr[]

Index2BoolExpr maps an index to the corresponding boolean expression. It is the reverse to function BoolExpr2Index.

Returns: BoolExpr[]

IndexHead

Full Usage: IndexHead

Returns: BddAdr option[]

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

Returns: BddAdr option[]

Initialize eL

Full Usage: Initialize eL

Parameters:

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.

eL : seq<BoolExpr>

IsFalseLeaf bddAdr

Full Usage: IsFalseLeaf bddAdr

Parameters:
Returns: bool

check whether the BDD is the False leaf

bddAdr : BddAdr
Returns: bool

IsTrueLeaf bddAdr

Full Usage: IsTrueLeaf bddAdr

Parameters:
Returns: bool

check whether the BDD is the True leaf

bddAdr : BddAdr
Returns: bool

MemoBdd

Full Usage: MemoBdd

Returns: BddNode[]

the BDD memory that maps BddAdrs to BddNodes

Returns: BddNode[]

MkBddNode (vi, ps, ng)

Full Usage: MkBddNode (vi, ps, ng)

Parameters:
Returns: BddAdr

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.

vi : AtomIndex
ps : BddAdr
ng : BddAdr
Returns: BddAdr

MkListConj bddAdrL

Full Usage: MkListConj bddAdrL

Parameters:
Returns: BddAdr

This function implements a generic conjunction which produces less garbage than repeated calls to Apply CONJ.

bddAdrL : BddAdr list
Returns: BddAdr

MkListDisj bddAdrL

Full Usage: MkListDisj bddAdrL

Parameters:
Returns: BddAdr

This function implements a generic disjunction which produces less garbage than repeated calls to Apply CONJ.

bddAdrL : BddAdr list
Returns: BddAdr

Negate bddAdr

Full Usage: Negate bddAdr

Parameters:
Returns: BddAdr

Compute the negation of a BDD.

bddAdr : BddAdr
Returns: BddAdr

NextSat model0 bddAdr

Full Usage: NextSat model0 bddAdr

Parameters:
Returns: bool * Map<AtomIndex, bool>

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.

model0 : Map<AtomIndex, bool>
bddAdr : BddAdr
Returns: bool * Map<AtomIndex, bool>

NodeCount bddAdrL

Full Usage: NodeCount bddAdrL

Parameters:
Returns: int

Count the number of internal nodes of a list of BDDs (shared nodes are only counted once).

bddAdrL : BddAdr list
Returns: int

OneSat bddAdr

Full Usage: OneSat bddAdr

Parameters:
Returns: Map<AtomIndex, bool>

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.

bddAdr : BddAdr
Returns: Map<AtomIndex, bool>

OptimalVarOrder bddL

Full Usage: OptimalVarOrder bddL

Parameters:
Returns: string[] * int * (string[] * 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.

bddL : BddAdr list
Returns: string[] * int * (string[] * int) list

PrintCube m

Full Usage: PrintCube m

Parameters:

Print a truth assignment to the atoms. The map maps AtomIndices to a boolean value, however, the map may be partial, so that AtomIndices are don't cares.

m : Map<AtomIndex, bool>

Relabel rho bddAdr

Full Usage: Relabel rho bddAdr

Parameters:
Returns: BddAdr

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.

rho : Map<AtomIndex, AtomIndex>
bddAdr : BddAdr
Returns: BddAdr

Restrict careAdr bddAdr

Full Usage: Restrict careAdr bddAdr

Parameters:
Returns: BddAdr

Restrict careAdr bddAdr computes a BDD that is equivalent to bddAdr on the care set "careAdr", but possibly different if careAdr is false. In contrast to Constrain, the BDD computed by Restrict will never depend on new variables.

careAdr : BddAdr
bddAdr : BddAdr
Returns: BddAdr

SatCount bddAdr

Full Usage: SatCount bddAdr

Parameters:
Returns: BigInteger

Compute the number of satisfying assignments.

bddAdr : BddAdr
Returns: BigInteger

SetAllocNodes n

Full Usage: SetAllocNodes n

Parameters:
    n : 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.

n : int

SetOfNodes bddAdrL

Full Usage: SetOfNodes bddAdrL

Parameters:
Returns: Set<BddAdr>

Compute the set of internal nodes that belong to one of the given BDDs.

bddAdrL : BddAdr list
Returns: Set<BddAdr>

Sifting printFlag bddL

Full Usage: Sifting printFlag bddL

Parameters:
    printFlag : bool
    bddL : BddAdr list

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.

printFlag : bool
bddL : BddAdr list

SwapSequence varOrder1 varOrder2

Full Usage: SwapSequence varOrder1 varOrder2

Parameters:
Returns: (int * int) list

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

varOrder1 : BoolExpr[]
varOrder2 : BoolExpr[]
Returns: (int * int) list

SwapVar vi

Full Usage: SwapVar vi

Parameters:

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.

vi : AtomIndex

WriteBddList2DotFile writeLF writeNxt bddAdrL outStr

Full Usage: WriteBddList2DotFile writeLF writeNxt bddAdrL outStr

Parameters:

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.

writeLF : bool
writeNxt : bool
bddAdrL : BddAdr list
outStr : TextWriter

WriteGlobalDotFile writeLF writeNxt outStr

Full Usage: WriteGlobalDotFile writeLF writeNxt outStr

Parameters:
    writeLF : 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.

writeLF : bool
writeNxt : bool
outStr : TextWriter