Keywords: cuddIntro

Next: Basic ZDD Manipulation Up: User's Manual Previous: Basic BDD Manipulation

## Basic ADD Manipulation

The most common way to manipulate ADDs is via Cudd_addApply . This function can apply a wide variety of operators to a pair of ADDs. Among the available operators are addition, multiplication, division, minimum, maximum, and boolean operators that work on ADDs whose leaves are restricted to 0 and 1 (0-1 ADDs).

The following fragment of code illustrates how to build the ADD for the function .

            DdManager *manager;
            DdNode *f, *var, *tmp;
            int i;

            ...

            f = Cudd_addConst(manager,5);
            Cudd_Ref(f);
            for (i = 3; i >= 0; i--) {
                var = Cudd_addIthVar(manager,i);
                Cudd_Ref(var);
                tmp = Cudd_addApply(manager,Cudd_addTimes,var,f);
                Cudd_Ref(tmp);
                Cudd_RecursiveDeref(manager,f);
                Cudd_RecursiveDeref(manager,var);
                f = tmp;
            }

This example, contrasted to the example of BDD manipulation, illustrates the following points:

- The ADD projection function are not maintained by the manager. It is therefore necessary to reference and dereference them.
- The product of two ADDs is computed by calling Cudd_addApply with Cudd_addTimes as parameter. There is no ``apply'' function for BDDs, because Cudd_bddAnd and Cudd_bddXor plus complementation are sufficient to implement all two-argument boolean functions.