46 # include <sys/types.h>
49 # include <sys/time.h>
51 #if HAVE_SYS_RESOURCE_H
52 # include <sys/resource.h>
80 #define CAL_BDD_TYPE_NONTERMINAL 0
81 #define CAL_BDD_TYPE_ZERO 1
82 #define CAL_BDD_TYPE_ONE 2
83 #define CAL_BDD_TYPE_POSVAR 3
84 #define CAL_BDD_TYPE_NEGVAR 4
85 #define CAL_BDD_TYPE_OVERFLOW 5
86 #define CAL_BDD_TYPE_CONSTANT 6
88 #define CAL_BDD_UNDUMP_FORMAT 1
89 #define CAL_BDD_UNDUMP_OVERFLOW 2
90 #define CAL_BDD_UNDUMP_IOERROR 3
91 #define CAL_BDD_UNDUMP_EOF 4
93 #define CAL_REORDER_NONE 0
94 #define CAL_REORDER_SIFT 1
95 #define CAL_REORDER_WINDOW 2
96 #define CAL_REORDER_METHOD_BF 0
97 #define CAL_REORDER_METHOD_DF 1
107 typedef struct Cal_BddManagerStruct *Cal_BddManager;
108 typedef struct Cal_BddManagerStruct Cal_BddManager_t;
109 typedef struct CalBddNodeStruct *Cal_Bdd;
110 typedef unsigned short int Cal_BddId_t;
111 typedef unsigned short int Cal_BddIndex_t;
112 typedef char * (*Cal_VarNamingFn_t)(Cal_BddManager, Cal_Bdd, Cal_Pointer_t);
113 typedef char * (*Cal_TerminalIdFn_t)(Cal_BddManager, Cal_Address_t, Cal_Address_t, Cal_Pointer_t);
114 typedef struct Cal_BlockStruct *Cal_Block;
124 enum Cal_BddOpEnum {CAL_AND, CAL_OR, CAL_XOR};
125 typedef enum Cal_BddOpEnum Cal_BddOp_t;
135 #define EXTERN extern
141 #define Cal_BddNamingFnNone ((char *(*)(Cal_BddManager, Cal_Bdd, Cal_Pointer_t))0)
146 #define Cal_BddTerminalIdFnNone ((char *(*)(Cal_BddManager, Cal_Address_t, Cal_Address_t, Cal_Pointer_t))0)
148 #define Cal_Assert(valid) assert(valid)
221 long reorderingThreshold,
222 long maxForwardedNodes,
223 double repackAfterGCThreshold,
224 double tableRepackThreshold);
375 Cal_Bdd *associationInfoUserBdds,
409 Cal_Bdd *associationInfoUserBdds,
418 Cal_Bdd *associationInfoUserBdds,
491 EXTERN
void Cal_BddFree(Cal_BddManager bddManager, Cal_Bdd userBdd);
559 Cal_BddIndex_t index);
635 Cal_Bdd *fUserBddArray,
665 Cal_Bdd *fUserBddArray,
715 Cal_VarNamingFn_t VarNamingFn,
716 Cal_TerminalIdFn_t TerminalIdFn,
731 Cal_VarNamingFn_t varNamingProc,
744 Cal_VarNamingFn_t varNamingProc,
756 Cal_VarNamingFn_t varNamingProc,
769 Cal_VarNamingFn_t varNamingProc,
806 EXTERN Cal_Bdd
Cal_BddNot(Cal_BddManager bddManager, Cal_Bdd userBdd);
864 Cal_Bdd *userBddArray);
888 Cal_Bdd *userBddArray);
912 Cal_Bdd *userBddArray);
933 Cal_Bdd *userBddArray);
945 Cal_Bdd *userBddArray);
957 Cal_Bdd *userBddArray);
1069 Cal_Bdd fMinUserBdd,
1070 Cal_Bdd fMaxUserBdd);
1138 EXTERN Cal_Bdd
Cal_BddIf(Cal_BddManager bddManager, Cal_Bdd userBdd);
1146 EXTERN Cal_Bdd
Cal_BddThen(Cal_BddManager bddManager, Cal_Bdd userBdd);
1154 EXTERN Cal_Bdd
Cal_BddElse(Cal_BddManager bddManager, Cal_Bdd userBdd);
1227 Cal_Bdd provisionalBdd);
EXTERN Cal_Bdd Cal_BddElse(Cal_BddManager bddManager, Cal_Bdd userBdd)
The negative cofactor of the argument BDD with respect to its top variable.
EXTERN void Cal_BddUnFree(Cal_BddManager bddManager, Cal_Bdd userBdd)
Unfrees the argument BDD.
EXTERN double Cal_BddSatisfyingFraction(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Fraction of valuations which make f true.
EXTERN void Cal_BddStats(Cal_BddManager bddManager, FILE *fp)
Prints miscellaneous BDD statistics.
EXTERN Cal_BddId_t Cal_BddGetIfId(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns the id of the top variable of the argument BDD.
EXTERN int Cal_PipelineExecute(Cal_BddManager bddManager)
Executes a pipeline.
EXTERN Cal_Bdd Cal_BddManagerGetVarWithIndex(Cal_BddManager bddManager, Cal_BddIndex_t index)
The variable with the specified index, null if no such variable exists.
EXTERN Cal_Bdd * Cal_BddPairwiseXor(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical XOR of BDD pairs in argument null-termiinated array of BDDs.
EXTERN int Cal_BddIsBddConst(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns 1 if the argument BDD is either constant one or constant zero, otherwise returns 0.
EXTERN Cal_Bdd Cal_BddSatisfySupport(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Returns a special cube contained in f.
EXTERN int Cal_BddManagerGC(Cal_BddManager bddManager)
Invokes the garbage collection at the manager level.
EXTERN Cal_Bdd Cal_BddXor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical XOR of argument BDDs.
EXTERN Cal_Bdd * Cal_BddPairwiseAnd(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical AND of BDD pairs in argument null-termiinated array of BDDs.
EXTERN void Cal_BddFree(Cal_BddManager bddManager, Cal_Bdd userBdd)
Frees the argument BDD.
EXTERN Cal_Bdd Cal_PipelineCreateProvisionalBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Create a provisional BDD in the pipeline.
EXTERN void Cal_PipelineSetDepth(Cal_BddManager bddManager, int depth)
Set depth of a BDD pipeline.
EXTERN long Cal_BddSizeMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, int negout)
Similar to Cal_BddSize for a null-terminated array of BDDs and accounting for sharing of nodes.
EXTERN int Cal_BddIsEqual(Cal_BddManager bddManager, Cal_Bdd userBdd1, Cal_Bdd userBdd2)
Returns 1 if argument BDDs are equal, 0 otherwise.
EXTERN Cal_Bdd Cal_BddCompose(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd)
Substitute a BDD variable by a function.
EXTERN int Cal_BddIsProvisional(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns 1, if the given user BDD is a provisional BDD node.
EXTERN Cal_Bdd Cal_BddIdentity(Cal_BddManager bddManager, Cal_Bdd userBdd)
Duplicate of the argument BDD.
EXTERN void Cal_BddPrintFunctionProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *userBdds, Cal_VarNamingFn_t varNamingProc, char *env, int lineLength, FILE *fp)
Similar to Cal_BddPrintFunctionProfile but displays a function profile for a set of BDDs.
EXTERN void Cal_TempAssociationQuit(Cal_BddManager bddManager)
Cleans up temporary association.
EXTERN void Cal_BddFunctionProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, long *funcCounts)
The number of subfunctions of f which may be obtained by restricting variables with an index lower th...
EXTERN int Cal_AssociationInit(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs)
Creates or finds a variable association.
EXTERN Cal_Bdd Cal_BddMultiwayXor(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical XOR of BDDs in argument null-terminated array of BDDs.
EXTERN void Cal_BddPrintBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_VarNamingFn_t VarNamingFn, Cal_TerminalIdFn_t TerminalIdFn, Cal_Pointer_t env, FILE *fp)
Prints a BDD in the human readable form.
EXTERN Cal_Bdd Cal_BddCofactor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd cUserBdd)
Generalized cofactor of f with respect to c.
EXTERN void Cal_BddProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, long *levelCounts, int negout)
Similar to Cal_BddProfile for a null-terminated array of BDDs and accounting for sharing of nodes.
EXTERN Cal_Bdd Cal_BddMultiwayAnd(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical AND of BDDs in argument null-terminated array of BDDs.
EXTERN void Cal_BddVarBlockReorderable(Cal_BddManager bddManager, Cal_Block block, int reorderable)
Sets the reoderability of a particular block.
EXTERN Cal_Bdd Cal_BddVarSubstitute(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Substitute a set of variables by set of another variables.
EXTERN Cal_Bdd Cal_BddSubstitute(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Substitute a set of variables by functions.
EXTERN void Cal_BddDynamicReordering(Cal_BddManager bddManager, int technique, int method)
Specify dynamic reordering technique and method.
EXTERN long Cal_BddNodeLimit(Cal_BddManager bddManager, long newLimit)
Sets the node limit to new_limit and returns the old limit.
EXTERN Cal_Bdd Cal_BddManagerCreateNewVarLast(Cal_BddManager bddManager)
Create and obtain a new variable at the end of the variable order.
EXTERN void Cal_BddPrintFunctionProfile(Cal_BddManager bddManager, Cal_Bdd f, Cal_VarNamingFn_t varNamingProc, char *env, int lineLength, FILE *fp)
Similar to Cal_BddPrintProfile but displays a function profile for f.
EXTERN Cal_Bdd Cal_BddManagerGetVarWithId(Cal_BddManager bddManager, Cal_BddId_t id)
The variable with the specified id, null if no such variable exists.
EXTERN void Cal_TempAssociationInit(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs)
Sets the temporary variable association.
EXTERN void Cal_BddFunctionPrint(Cal_BddManager bddManager, Cal_Bdd userBdd, char *name)
Prints the function implemented by the argument BDD.
EXTERN Cal_Bdd Cal_BddManagerCreateNewVarAfter(Cal_BddManager bddManager, Cal_Bdd userBdd)
Create and obtain a new variable after the specified one in the variable order.
EXTERN Cal_Bdd Cal_BddNand(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical NAND of argument BDDs.
EXTERN Cal_Bdd Cal_BddOne(Cal_BddManager bddManager)
The BDD for the constant one.
EXTERN int Cal_BddDumpBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd *userVars, FILE *fp)
Write a BDD to a file.
EXTERN void Cal_BddManagerSetGCLimit(Cal_BddManager manager)
Sets the limit of the garbage collection.
EXTERN Cal_Bdd Cal_BddUndumpBdd(Cal_BddManager bddManager, Cal_Bdd *userVars, FILE *fp, int *error)
Reads a BDD from a file.
EXTERN Cal_BddId_t Cal_BddGetIfIndex(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns the index of the top variable of the argument BDD.
EXTERN Cal_Bdd Cal_BddExists(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Existentially quantification of some variables from the given BDD.
EXTERN Cal_Bdd Cal_BddNot(Cal_BddManager bddManager, Cal_Bdd userBdd)
Complement of the argument BDD.
EXTERN int Cal_BddIsBddOne(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns 1 if the argument BDD is constant one, 0 otherwise.
EXTERN Cal_Bdd Cal_BddIntersects(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Computes a BDD that implies conjunction of f and g.
EXTERN void Cal_BddProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, long *levelCounts, int negout)
The number of nodes at each level in f.
EXTERN int Cal_BddOverflow(Cal_BddManager bddManager)
Returns 1 if the node limit has been exceeded, 0 otherwise.
EXTERN void Cal_BddPrintProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_VarNamingFn_t varNamingProc, char *env, int lineLength, FILE *fp)
Displays the node profile for f on fp.
EXTERN unsigned long Cal_BddTotalSize(Cal_BddManager bddManager)
Returns the number of nodes in the Unique table.
EXTERN Cal_Bdd Cal_BddManagerCreateNewVarBefore(Cal_BddManager bddManager, Cal_Bdd userBdd)
Create and obtain a new variable before the specified one in the variable order.
EXTERN long Cal_BddSize(Cal_BddManager bddManager, Cal_Bdd fUserBdd, int negout)
BDD size of fUserBdd.
EXTERN void Cal_BddPrintProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *userBdds, Cal_VarNamingFn_t varNamingProc, char *env, int lineLength, FILE *fp)
Similar to Cal_BddPrintProfile but displays the profile for a set of BDDs.
EXTERN Cal_Bdd * Cal_BddPairwiseOr(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical OR of BDD pairs in argument null-termiinated array of BDDs.
EXTERN int Cal_PipelineInit(Cal_BddManager bddManager, Cal_BddOp_t bddOp)
Initialize a BDD pipeline.
EXTERN Cal_Bdd Cal_BddIf(Cal_BddManager bddManager, Cal_Bdd userBdd)
A BDD corresponding to the top variable of the given BDD.
EXTERN Cal_Bdd Cal_BddZero(Cal_BddManager bddManager)
The BDD for the constant zero.
EXTERN unsigned long Cal_BddManagerGetNumNodes(Cal_BddManager bddManager)
Returns the number of BDD nodes.
EXTERN Cal_Bdd Cal_BddManagerCreateNewVarFirst(Cal_BddManager bddManager)
Create and obtain a new variable at the start of the variable order.
EXTERN Cal_Block Cal_BddNewVarBlock(Cal_BddManager bddManager, Cal_Bdd variable, long length)
Creates and returns a variable block used for controlling dynamic reordering.
EXTERN Cal_Bdd Cal_BddReduce(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd cUserBdd)
A function that agrees with f for all valuations which satisfy c.
EXTERN Cal_BddManager Cal_BddManagerInit()
Creates and initializes a new BDD manager.
EXTERN Cal_Bdd Cal_BddSatisfy(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
A satisfying assignment of f.
EXTERN void Cal_AssociationQuit(Cal_BddManager bddManager, int associationId)
Deletes the variable association given by id.
EXTERN Cal_Bdd Cal_BddBetween(Cal_BddManager bddManager, Cal_Bdd fMinUserBdd, Cal_Bdd fMaxUserBdd)
A function that contains fMin and is contained in fMax.
EXTERN int Cal_BddType(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
The type of the given BDD (0, 1, +var, -var, overflow, nonterminal).
EXTERN Cal_Bdd Cal_BddGetRegular(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns a BDD with positive from a given BDD with arbitrary phase.
EXTERN int Cal_AssociationSetCurrent(Cal_BddManager bddManager, int associationId)
Sets the current variable association to the one given.
EXTERN Cal_Bdd Cal_PipelineUpdateProvisionalBdd(Cal_BddManager bddManager, Cal_Bdd provisionalBdd)
Update a provisional BDD obtained during pipelining.
EXTERN long Cal_BddVars(Cal_BddManager bddManager)
Returns the number of BDD variables.
EXTERN void Cal_BddSupport(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd *support)
Returns the support of f as a null-terminated array of variables.
EXTERN Cal_Bdd Cal_BddXnor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical XNOR of argument BDDs.
EXTERN void Cal_BddSetGCMode(Cal_BddManager bddManager, int gcMode)
Sets the garbage collection mode.
EXTERN void Cal_BddFunctionProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, long *funcCounts)
Similar to Cal_BddFunctionProfile for a null-terminated array of BDDs and accounting for sharing of n...
EXTERN Cal_Bdd Cal_BddITE(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd)
Logical If-Then-Else.
EXTERN void Cal_BddReorder(Cal_BddManager bddManager)
Invoke the current dynamic reodering method.
EXTERN int Cal_BddIsBddZero(Cal_BddManager bddManager, Cal_Bdd userBdd)
Returns 1 if the argument BDD is constant zero, 0 otherwise.
EXTERN Cal_Bdd Cal_BddRelProd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical AND of the argument BDDs and existentially quantifying some variables from the product.
EXTERN Cal_Bdd Cal_BddThen(Cal_BddManager bddManager, Cal_Bdd userBdd)
The positive cofactor of the argument BDD with respect to its top variable.
EXTERN int Cal_BddDependsOn(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd varUserBdd)
Returns 1 if f depends on var and returns 0 otherwise.
EXTERN int Cal_BddIsCube(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Returns 1 if the argument BDD is a cube, 0 otherwise.
EXTERN void * Cal_BddManagerGetHooks(Cal_BddManager bddManager)
Returns the hooks field of the manager.
EXTERN void Cal_PipelineQuit(Cal_BddManager bddManager)
Resets the pipeline freeing all resources.
EXTERN int Cal_BddManagerQuit(Cal_BddManager bddManager)
Frees the BDD manager and all the associated allocations.
EXTERN void Cal_TempAssociationAugment(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs)
Adds to the temporary variable association.
EXTERN Cal_Bdd Cal_BddForAll(Cal_BddManager bddManager, Cal_Bdd fUserBdd)
Universal quantification of some variables from the given BDD.
EXTERN Cal_Bdd Cal_BddNor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical NOR of argument BDDs.
EXTERN Cal_Bdd Cal_BddImplies(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Computes a BDD that implies conjunction of f and Cal_BddNot(g).
EXTERN Cal_Bdd Cal_BddOr(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical Or of argument BDDs.
EXTERN Cal_Bdd Cal_BddMultiwayOr(Cal_BddManager bddManager, Cal_Bdd *userBddArray)
Logical OR of BDDs in argument null-terminated array of BDDs.
EXTERN Cal_Bdd Cal_BddNull(Cal_BddManager bddManager)
Returns the NULL BDD.
EXTERN int Cal_BddIsBddNull(Cal_BddManager bddManager, Cal_Bdd userBdd)
1 if the argument BDD is NULL, 0 otherwise.
EXTERN Cal_Bdd Cal_BddSwapVars(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd)
The function obtained by swapping two variables.
EXTERN Cal_Bdd Cal_BddAnd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd)
Logical AND of argument BDDs.
EXTERN void Cal_BddManagerSetHooks(Cal_BddManager bddManager, void *hooks)
Sets the hooks field of the manager.
EXTERN void Cal_BddManagerSetParameters(Cal_BddManager bddManager, long reorderingThreshold, long maxForwardedNodes, double repackAfterGCThreshold, double tableRepackThreshold)
Sets appropriate fields of BDD Manager.