27.09.2013 Views

a modern C++ library for the manipulation of Boolean functions

a modern C++ library for the manipulation of Boolean functions

a modern C++ library for the manipulation of Boolean functions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3 Algorithms in CORAL<br />

3.1 Basic data structures<br />

3.1.1 Sets <strong>of</strong> <strong>Boolean</strong> variables<br />

The type <strong>of</strong> variable indexes is index_type. A single <strong>Boolean</strong> variable in CORAL is<br />

represented by an object <strong>of</strong> class Variable; it is a very simple class whose objects can<br />

be built using a constructor that takes an index_type which represents <strong>the</strong> index <strong>of</strong><br />

<strong>the</strong> variable. To represent (finite) sets <strong>of</strong> variables we use <strong>the</strong> Bit_Set class, which in<br />

turn represents a set using a bitmap as its private data member: a specific variable vi<br />

is contained in <strong>the</strong> set if and only if <strong>the</strong> bit in <strong>the</strong> position i <strong>of</strong> <strong>the</strong> bitmap exists and<br />

is set to 1. The type <strong>of</strong> this bitmap is mpz_t, which is provided by <strong>the</strong> GMP <strong>library</strong>;<br />

using bitmaps allows us to implement <strong>the</strong> common operations on sets such as union,<br />

intersection, difference and inclusion tests efficiently. The end user in fact utilizes class<br />

Variables_Set instead, which is a simple wrapper <strong>for</strong> Bit_Set that is a bit closer to<br />

<strong>the</strong> concept <strong>of</strong> variable.<br />

3.1.2 Equivalence relations<br />

An object <strong>of</strong> class Equivalence_Relation represents an equivalence relation L ∈ L.<br />

The internal representation consists <strong>of</strong> a vector <strong>of</strong> elements <strong>of</strong> type index_type. Each<br />

element <strong>of</strong> <strong>the</strong> vector in position i is set to value l if vl is <strong>the</strong> leader <strong>of</strong> vi <strong>for</strong> <strong>the</strong> relation,<br />

or to <strong>the</strong> special value NOT_IN_DOMAIN if vi /∈ dom(L). CORAL provides some <strong>functions</strong><br />

to per<strong>for</strong>m basic computations on <strong>Boolean</strong> function such as <strong>the</strong> intersection ∨ and <strong>the</strong><br />

transitive closure <strong>of</strong> <strong>the</strong> union ∧.<br />

3.1.3 Hash table<br />

An hash table hash_table is used to ensure that <strong>the</strong>re are no duplicate ROBDD nodes,<br />

as described in Subsection 2.3.1. Its method find_or_insert per<strong>for</strong>ms a lookup taking<br />

<strong>the</strong> three components <strong>of</strong> <strong>the</strong> key (<strong>the</strong> variable by which <strong>the</strong> root <strong>of</strong> <strong>the</strong> ROBDD is labeled,<br />

a pointer to <strong>the</strong> true successor and a pointer to <strong>the</strong> false successor) as its arguments: if<br />

an entry is found <strong>the</strong>n <strong>the</strong> <strong>the</strong> return value is a pointer to <strong>the</strong> ROBDD that has already<br />

been constructed, o<strong>the</strong>rwise a new node is allocated, a cache entry <strong>for</strong> it is added and <strong>the</strong><br />

return value is a pointer to this new node. This method also handles <strong>the</strong> particular case<br />

where <strong>the</strong> two pointer arguments are in fact <strong>the</strong> same pointer simply by returning this<br />

pointer, in order to respect <strong>the</strong> third reduction rule. The static method make_node <strong>of</strong><br />

class ROBDD is simply a wrapper <strong>for</strong> find_or_insert that takes <strong>the</strong> same arguments<br />

and returns <strong>the</strong> same pointer. From now on, whenever we are describing a ROBDD

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!