Big Tabbing Change
authorbdemsky <bdemsky@uci.edu>
Thu, 17 Aug 2017 01:11:51 +0000 (18:11 -0700)
committerbdemsky <bdemsky@uci.edu>
Thu, 17 Aug 2017 01:11:51 +0000 (18:11 -0700)
78 files changed:
src/AST/boolean.c
src/AST/boolean.h
src/AST/element.c
src/AST/element.h
src/AST/function.c
src/AST/function.h
src/AST/mutableset.c
src/AST/mutableset.h
src/AST/order.c
src/AST/order.h
src/AST/predicate.c
src/AST/predicate.h
src/AST/rewriter.c
src/AST/rewriter.h
src/AST/set.c
src/AST/set.h
src/AST/table.c
src/AST/table.h
src/AST/tableentry.c
src/AST/tableentry.h
src/Backend/cnfexpr.c
src/Backend/cnfexpr.h
src/Backend/constraint.c
src/Backend/constraint.h
src/Backend/inc_solver.c
src/Backend/inc_solver.h
src/Backend/orderpair.c
src/Backend/orderpair.h
src/Backend/satelemencoder.c
src/Backend/satelemencoder.h
src/Backend/satencoder.c
src/Backend/satencoder.h
src/Backend/satfuncopencoder.c
src/Backend/satfuncopencoder.h
src/Backend/satfunctableencoder.c
src/Backend/satfunctableencoder.h
src/Backend/satorderencoder.c
src/Backend/satorderencoder.h
src/Backend/sattranslator.c
src/Backend/sattranslator.h
src/Collections/array.h
src/Collections/hashset.h
src/Collections/hashtable.h
src/Collections/structs.c
src/Collections/structs.h
src/Collections/vector.h
src/Encoders/elementencoding.c
src/Encoders/elementencoding.h
src/Encoders/functionencoding.c
src/Encoders/functionencoding.h
src/Encoders/naiveencoder.c
src/Encoders/naiveencoder.h
src/Encoders/orderedge.c
src/Encoders/orderedge.h
src/Encoders/orderencoder.c
src/Encoders/orderencoder.h
src/Encoders/orderencoding.c
src/Encoders/orderencoding.h
src/Encoders/ordergraph.c
src/Encoders/ordergraph.h
src/Encoders/ordernode.c
src/Encoders/ordernode.h
src/Encoders/polarityassignment.c
src/Encoders/polarityassignment.h
src/Test/buildconstraintstest.c
src/Test/cnftest.c
src/Test/elemequalsattest.c
src/Test/elemequalunsattest.c
src/Test/funcencodingtest.c
src/Test/logicopstest.c
src/Test/ltelemconsttest.c
src/Test/ordertest.c
src/Test/tablefuncencodetest.c
src/Test/tablepredicencodetest.c
src/common.h
src/csolver.c
src/csolver.h
src/mymemory.h

index 3ce75e4ad432bc071ebca41adde714877c99656c..2987217e2e08cfc4aa24fe1ca7cbaa12214b5cde 100644 (file)
@@ -4,49 +4,49 @@
 #include "element.h"
 #include "order.h"
 
 #include "element.h"
 #include "order.h"
 
-BooleanallocBooleanVar(VarType t) {
-       BooleanVar* This=(BooleanVar *) ourmalloc(sizeof (BooleanVar));
-       GETBOOLEANTYPE(This)=BOOLEANVAR;
+Boolean *allocBooleanVar(VarType t) {
+       BooleanVar *This = (BooleanVar *) ourmalloc(sizeof (BooleanVar));
+       GETBOOLEANTYPE(This) = BOOLEANVAR;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
-       This->vtype=t;
-       This->var=E_NULL;
+       This->vtype = t;
+       This->var = E_NULL;
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
-       return & This->base;
+       return &This->base;
 }
 
 }
 
-Boolean* allocBooleanOrder(Order* order, uint64_t first, uint64_t second) {
-       BooleanOrder* This=(BooleanOrder *) ourmalloc(sizeof (BooleanOrder));
-       GETBOOLEANTYPE(This)=ORDERCONST;
+Boolean *allocBooleanOrder(Order *order, uint64_t first, uint64_t second) {
+       BooleanOrder *This = (BooleanOrder *) ourmalloc(sizeof (BooleanOrder));
+       GETBOOLEANTYPE(This) = ORDERCONST;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
-       This->order=order;
-       This->first=first;
-       This->second=second;
+       This->order = order;
+       This->first = first;
+       This->second = second;
        pushVectorBooleanOrder(&order->constraints, This);
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
        pushVectorBooleanOrder(&order->constraints, This);
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
-       return & This -> base;
+       return &This->base;
 }
 
 }
 
-Boolean * allocBooleanPredicate(Predicate * predicate, Element ** inputs, uint numInputs, Boolean* undefinedStatus){
-       BooleanPredicate* This = (BooleanPredicate*) ourmalloc(sizeof(BooleanPredicate));
-       GETBOOLEANTYPE(This)= PREDICATEOP;
+Boolean *allocBooleanPredicate(Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus) {
+       BooleanPredicate *This = (BooleanPredicate *) ourmalloc(sizeof(BooleanPredicate));
+       GETBOOLEANTYPE(This) = PREDICATEOP;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
-       This->predicate=predicate;
+       This->predicate = predicate;
        initArrayInitElement(&This->inputs, inputs, numInputs);
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
 
        initArrayInitElement(&This->inputs, inputs, numInputs);
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
 
-       for(uint i=0;i<numInputs;i++) {
+       for (uint i = 0; i < numInputs; i++) {
                pushVectorASTNode(GETELEMENTPARENTS(inputs[i]), (ASTNode *)This);
        }
        initPredicateEncoding(&This->encoding, (Boolean *) This);
        This->undefStatus = undefinedStatus;
                pushVectorASTNode(GETELEMENTPARENTS(inputs[i]), (ASTNode *)This);
        }
        initPredicateEncoding(&This->encoding, (Boolean *) This);
        This->undefStatus = undefinedStatus;
-       return & This->base;
+       return &This->base;
 }
 
 }
 
-Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array, uint asize){
-       BooleanLogic * This = ourmalloc(sizeof(BooleanLogic));
+Boolean *allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean **array, uint asize) {
+       BooleanLogic *This = ourmalloc(sizeof(BooleanLogic));
        GETBOOLEANTYPE(This) = LOGICOP;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
        GETBOOLEANTYPE(This) = LOGICOP;
        GETBOOLEANVALUE(This) = BV_UNDEFINED;
        GETBOOLEANPOLARITY(This) = P_UNDEFINED;
@@ -54,24 +54,24 @@ Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array,
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
        initArrayInitBoolean(&This->inputs, array, asize);
        pushVectorBoolean(solver->allBooleans, (Boolean *) This);
        initDefVectorBoolean(GETBOOLEANPARENTS(This));
        initArrayInitBoolean(&This->inputs, array, asize);
        pushVectorBoolean(solver->allBooleans, (Boolean *) This);
-       return & This->base;
+       return &This->base;
 }
 
 }
 
-void deleteBoolean(Boolean * This) {
-       switch(GETBOOLEANTYPE(This)){
-               case PREDICATEOP:{
-                       BooleanPredicate *bp=(BooleanPredicate *)This;
-                       deleteInlineArrayElement(& bp->inputs );
-                       deleteFunctionEncoding(& bp->encoding);
-                       break;
-               }
-               case LOGICOP:{
-                       BooleanLogic* bl = (BooleanLogic*) This;
-                       deleteInlineArrayBoolean(&bl->inputs);
-                       break;
-               }
-               default:
-                       break;
+void deleteBoolean(Boolean *This) {
+       switch (GETBOOLEANTYPE(This)) {
+       case PREDICATEOP: {
+               BooleanPredicate *bp = (BooleanPredicate *)This;
+               deleteInlineArrayElement(&bp->inputs );
+               deleteFunctionEncoding(&bp->encoding);
+               break;
+       }
+       case LOGICOP: {
+               BooleanLogic *bl = (BooleanLogic *) This;
+               deleteInlineArrayBoolean(&bl->inputs);
+               break;
+       }
+       default:
+               break;
        }
        deleteVectorArrayBoolean(GETBOOLEANPARENTS(This));
        ourfree(This);
        }
        deleteVectorArrayBoolean(GETBOOLEANPARENTS(This));
        ourfree(This);
index 2a80d390820ac986f3c5918bb48932ec3e87a3b9..cdc05a6be55487fd5fcc5db483be2067fc920562 100644 (file)
@@ -14,8 +14,8 @@
 
 #define GETBOOLEANTYPE(o) GETASTNODETYPE(o)
 #define GETBOOLEANPARENTS(o) (&((Boolean *)(o))->parents)
 
 #define GETBOOLEANTYPE(o) GETASTNODETYPE(o)
 #define GETBOOLEANPARENTS(o) (&((Boolean *)(o))->parents)
-#define GETBOOLEANPOLARITY(b) (((Boolean*)b)->polarity)
-#define GETBOOLEANVALUE(b) (((Boolean*)b)->boolVal)
+#define GETBOOLEANPOLARITY(b) (((Boolean *)b)->polarity)
+#define GETBOOLEANVALUE(b) (((Boolean *)b)->boolVal)
 
 struct Boolean {
        ASTNode base;
 
 struct Boolean {
        ASTNode base;
@@ -26,7 +26,7 @@ struct Boolean {
 
 struct BooleanOrder {
        Boolean base;
 
 struct BooleanOrder {
        Boolean base;
-       Orderorder;
+       Order *order;
        uint64_t first;
        uint64_t second;
 };
        uint64_t first;
        uint64_t second;
 };
@@ -45,18 +45,18 @@ struct BooleanLogic {
 
 struct BooleanPredicate {
        Boolean base;
 
 struct BooleanPredicate {
        Boolean base;
-       Predicate * predicate;
+       Predicate *predicate;
        FunctionEncoding encoding;
        ArrayElement inputs;
        FunctionEncoding encoding;
        ArrayElement inputs;
-       BooleanundefStatus;
+       Boolean *undefStatus;
 };
 
 };
 
-Boolean * allocBooleanVar(VarType t);
-Boolean * allocBooleanOrder(Order * order, uint64_t first, uint64_t second);
-Boolean * allocBooleanPredicate(Predicate * predicate, Element ** inputs, uint numInputs, Boolean* undefinedStatus);
-Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array, uint asize);
-void deleteBoolean(Boolean * This);
-static inline FunctionEncoding* getPredicateFunctionEncoding(BooleanPredicate* func){
+Boolean *allocBooleanVar(VarType t);
+Boolean *allocBooleanOrder(Order *order, uint64_t first, uint64_t second);
+Boolean *allocBooleanPredicate(Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus);
+Boolean *allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean **array, uint asize);
+void deleteBoolean(Boolean *This);
+static inline FunctionEncoding *getPredicateFunctionEncoding(BooleanPredicate *func) {
        return &func->encoding;
 }
 
        return &func->encoding;
 }
 
index 8a7d28f4cd0cad81bbe1ed4254f1e80f015ac743..5d126c7637cd1e74af13d0dd0b93508577c2fa6a 100644 (file)
@@ -5,53 +5,53 @@
 #include "function.h"
 #include "table.h"
 
 #include "function.h"
 #include "table.h"
 
-Element *allocElementSet(Set * s) {
-       ElementSet * This=(ElementSet *)ourmalloc(sizeof(ElementSet));
-       GETELEMENTTYPE(This)= ELEMSET;
-       This->set=s;
+Element *allocElementSet(Set *s) {
+       ElementSet *This = (ElementSet *)ourmalloc(sizeof(ElementSet));
+       GETELEMENTTYPE(This) = ELEMSET;
+       This->set = s;
        initDefVectorASTNode(GETELEMENTPARENTS(This));
        initElementEncoding(&This->encoding, (Element *) This);
        return &This->base;
 }
 
        initDefVectorASTNode(GETELEMENTPARENTS(This));
        initElementEncoding(&This->encoding, (Element *) This);
        return &This->base;
 }
 
-Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus){
-       ElementFunction* This = (ElementFunction*) ourmalloc(sizeof(ElementFunction));
-       GETELEMENTTYPE(This)= ELEMFUNCRETURN;
-       This->function=function;
+Element *allocElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus) {
+       ElementFunction *This = (ElementFunction *) ourmalloc(sizeof(ElementFunction));
+       GETELEMENTTYPE(This) = ELEMFUNCRETURN;
+       This->function = function;
        ASSERT(GETBOOLEANTYPE(overflowstatus) == BOOLEANVAR);
        This->overflowstatus = overflowstatus;
        initArrayInitElement(&This->inputs, array, numArrays);
        initDefVectorASTNode(GETELEMENTPARENTS(This));
        ASSERT(GETBOOLEANTYPE(overflowstatus) == BOOLEANVAR);
        This->overflowstatus = overflowstatus;
        initArrayInitElement(&This->inputs, array, numArrays);
        initDefVectorASTNode(GETELEMENTPARENTS(This));
-       for(uint i=0;i<numArrays;i++)
+       for (uint i = 0; i < numArrays; i++)
                pushVectorASTNode(GETELEMENTPARENTS(array[i]), (ASTNode *) This);
        initElementEncoding(&This->rangeencoding, (Element *) This);
        initFunctionEncoding(&This->functionencoding, (Element *) This);
        return &This->base;
 }
 
                pushVectorASTNode(GETELEMENTPARENTS(array[i]), (ASTNode *) This);
        initElementEncoding(&This->rangeencoding, (Element *) This);
        initFunctionEncoding(&This->functionencoding, (Element *) This);
        return &This->base;
 }
 
-Element * allocElementConst(uint64_t value, VarType type) {
-       ElementConst * This=(ElementConst *)ourmalloc(sizeof(ElementConst));
-       GETELEMENTTYPE(This)= ELEMCONST;
-       This->value=value;
-       This->set=allocSet(type, (uint64_t[]){value}, 1);
+Element *allocElementConst(uint64_t value, VarType type) {
+       ElementConst *This = (ElementConst *)ourmalloc(sizeof(ElementConst));
+       GETELEMENTTYPE(This) = ELEMCONST;
+       This->value = value;
+       This->set = allocSet(type, (uint64_t[]) {value}, 1);
        initDefVectorASTNode(GETELEMENTPARENTS(This));
        initElementEncoding(&This->encoding, (Element *) This);
        return &This->base;
 }
 
        initDefVectorASTNode(GETELEMENTPARENTS(This));
        initElementEncoding(&This->encoding, (Element *) This);
        return &This->base;
 }
 
-Set* getElementSet(Element* This){
-       switch(GETELEMENTTYPE(This)){
+Set *getElementSet(Element *This) {
+       switch (GETELEMENTTYPE(This)) {
        case ELEMSET:
        case ELEMSET:
-               return ((ElementSet*)This)->set;
+               return ((ElementSet *)This)->set;
        case ELEMCONST:
        case ELEMCONST:
-               return ((ElementConst*)This)->set;
+               return ((ElementConst *)This)->set;
        case ELEMFUNCRETURN: {
        case ELEMFUNCRETURN: {
-               Function* func = ((ElementFunction*)This)->function;
-               switch(GETFUNCTIONTYPE(func)){
+               Function *func = ((ElementFunction *)This)->function;
+               switch (GETFUNCTIONTYPE(func)) {
                case TABLEFUNC:
                case TABLEFUNC:
-                       return ((FunctionTable*)func)->table->range;
+                       return ((FunctionTable *)func)->table->range;
                case OPERATORFUNC:
                case OPERATORFUNC:
-                       return ((FunctionOperator*)func)->range;
+                       return ((FunctionOperator *)func)->range;
                default:
                        ASSERT(0);
                }
                default:
                        ASSERT(0);
                }
@@ -64,7 +64,7 @@ Set* getElementSet(Element* This){
 }
 
 void deleteElement(Element *This) {
 }
 
 void deleteElement(Element *This) {
-       switch(GETELEMENTTYPE(This)) {
+       switch (GETELEMENTTYPE(This)) {
        case ELEMFUNCRETURN: {
                ElementFunction *ef = (ElementFunction *) This;
                deleteInlineArrayElement(&ef->inputs);
        case ELEMFUNCRETURN: {
                ElementFunction *ef = (ElementFunction *) This;
                deleteInlineArrayElement(&ef->inputs);
index 23e016cb0cc2a902a35d7c97b128fd1733031637..8640a47bec2b36c7a1cd6730162ebbeeec2119fd 100644 (file)
@@ -9,7 +9,7 @@
 #include "boolean.h"
 
 #define GETELEMENTTYPE(o) GETASTNODETYPE(o)
 #include "boolean.h"
 
 #define GETELEMENTTYPE(o) GETASTNODETYPE(o)
-#define GETELEMENTPARENTS(o) (&((Element*)o)->parents)         
+#define GETELEMENTPARENTS(o) (&((Element *)o)->parents)
 struct Element {
        ASTNode base;
        VectorASTNode parents;
 struct Element {
        ASTNode base;
        VectorASTNode parents;
@@ -17,47 +17,47 @@ struct Element {
 
 struct ElementConst {
        Element base;
 
 struct ElementConst {
        Element base;
-       Set * set;
+       Set *set;
        uint64_t value;
        ElementEncoding encoding;
 };
 
 struct ElementSet {
        Element base;
        uint64_t value;
        ElementEncoding encoding;
 };
 
 struct ElementSet {
        Element base;
-       Set * set;
+       Set *set;
        ElementEncoding encoding;
 };
 
 struct ElementFunction {
        Element base;
        ElementEncoding encoding;
 };
 
 struct ElementFunction {
        Element base;
-       Function * function;
+       Function *function;
        ArrayElement inputs;
        ArrayElement inputs;
-       Boolean * overflowstatus;
+       Boolean *overflowstatus;
        FunctionEncoding functionencoding;
        ElementEncoding rangeencoding;
 };
 
        FunctionEncoding functionencoding;
        ElementEncoding rangeencoding;
 };
 
-Element * allocElementConst(uint64_t value, VarType type);
-Element * allocElementSet(Set *s);
-Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
+Element *allocElementConst(uint64_t value, VarType type);
+Element *allocElementSet(Set *s);
+Element *allocElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
 void deleteElement(Element *This);
 void deleteElement(Element *This);
-Set* getElementSet(Element* This);
+Set *getElementSet(Element *This);
 
 
-static inline ElementEncoding* getElementEncoding(Element* This){
-       switch(GETELEMENTTYPE(This)){
-               case ELEMSET:
-                       return &((ElementSet*)This)->encoding;
-               case ELEMFUNCRETURN:            
-                       return &((ElementFunction*)This)->rangeencoding;
-               case ELEMCONST:
-                       return &((ElementConst*)This)->encoding;
-               default:
-                       ASSERT(0);
+static inline ElementEncoding *getElementEncoding(Element *This) {
+       switch (GETELEMENTTYPE(This)) {
+       case ELEMSET:
+               return &((ElementSet *)This)->encoding;
+       case ELEMFUNCRETURN:
+               return &((ElementFunction *)This)->rangeencoding;
+       case ELEMCONST:
+               return &((ElementConst *)This)->encoding;
+       default:
+               ASSERT(0);
        }
        return NULL;
 }
 
        }
        return NULL;
 }
 
-static inline FunctionEncoding* getElementFunctionEncoding(ElementFunction* func){
+static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
        return &func->functionencoding;
 }
 #endif
        return &func->functionencoding;
 }
 #endif
index a67fe291bfa4372d26d8b833fbc0707071f0dd77..3a32139a03f1edb5acc1ab8fd8e4252968291d7f 100644 (file)
@@ -3,35 +3,35 @@
 #include "set.h"
 
 
 #include "set.h"
 
 
-Function* allocFunctionOperator(ArithOp op, Set ** domain, uint numDomain, Set * range, OverFlowBehavior overflowbehavior) {
-       FunctionOperator* This = (FunctionOperator*) ourmalloc(sizeof(FunctionOperator));
-       GETFUNCTIONTYPE(This)=OPERATORFUNC;
+Function *allocFunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior) {
+       FunctionOperator *This = (FunctionOperator *) ourmalloc(sizeof(FunctionOperator));
+       GETFUNCTIONTYPE(This) = OPERATORFUNC;
        initArrayInitSet(&This->domains, domain, numDomain);
        initArrayInitSet(&This->domains, domain, numDomain);
-       This->op=op;
+       This->op = op;
        This->overflowbehavior = overflowbehavior;
        This->overflowbehavior = overflowbehavior;
-       This->range=range;
+       This->range = range;
        return &This->base;
 }
 
        return &This->base;
 }
 
-Function* allocFunctionTable (Table* table, UndefinedBehavior undefBehavior){
-       FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable));
-       GETFUNCTIONTYPE(This)=TABLEFUNC;
+Function *allocFunctionTable (Table *table, UndefinedBehavior undefBehavior) {
+       FunctionTable *This = (FunctionTable *) ourmalloc(sizeof(FunctionTable));
+       GETFUNCTIONTYPE(This) = TABLEFUNC;
        This->table = table;
        This->undefBehavior = undefBehavior;
        return &This->base;
 }
 
        This->table = table;
        This->undefBehavior = undefBehavior;
        return &This->base;
 }
 
-uint64_t applyFunctionOperator(FunctionOperator* This, uint numVals, uint64_t * values) {
+uint64_t applyFunctionOperator(FunctionOperator *This, uint numVals, uint64_t *values) {
        ASSERT(numVals == 2);
        ASSERT(numVals == 2);
-       switch(This->op){
-               case ADD:
-                       return values[0] + values[1];
-                       break;
-               case SUB:
-                       return values[0] - values[1];
-                       break;
-               default:
-                       ASSERT(0);
+       switch (This->op) {
+       case ADD:
+               return values[0] + values[1];
+               break;
+       case SUB:
+               return values[0] - values[1];
+               break;
+       default:
+               ASSERT(0);
        }
 }
 
        }
 }
 
@@ -39,12 +39,12 @@ bool isInRangeFunction(FunctionOperator *This, uint64_t val) {
        return existsInSet(This->range, val);
 }
 
        return existsInSet(This->range, val);
 }
 
-void deleteFunction(Function* This){
-       switch(GETFUNCTIONTYPE(This)){
+void deleteFunction(Function *This) {
+       switch (GETFUNCTIONTYPE(This)) {
        case TABLEFUNC:
                break;
        case OPERATORFUNC:
        case TABLEFUNC:
                break;
        case OPERATORFUNC:
-               deleteInlineArraySet(&((FunctionOperator*) This)->domains);
+               deleteInlineArraySet(&((FunctionOperator *) This)->domains);
                break;
        default:
                ASSERT(0);
                break;
        default:
                ASSERT(0);
index 562d3e9e06f096ab89155aa3621418b94e333e52..37e13762c512076905270524a37b533470bc48d0 100644 (file)
@@ -5,7 +5,7 @@
 #include "ops.h"
 #include "structs.h"
 
 #include "ops.h"
 #include "structs.h"
 
-#define GETFUNCTIONTYPE(o) (((Function*)o)->type)
+#define GETFUNCTIONTYPE(o) (((Function *)o)->type)
 
 struct Function {
        FunctionType type;
 
 struct Function {
        FunctionType type;
@@ -15,20 +15,20 @@ struct FunctionOperator {
        Function base;
        ArithOp op;
        ArraySet domains;
        Function base;
        ArithOp op;
        ArraySet domains;
-       Set * range;
+       Set *range;
        OverFlowBehavior overflowbehavior;
 };
 
 struct FunctionTable {
        Function base;
        OverFlowBehavior overflowbehavior;
 };
 
 struct FunctionTable {
        Function base;
-       Tabletable;
+       Table *table;
        UndefinedBehavior undefBehavior;
 };
 
        UndefinedBehavior undefBehavior;
 };
 
-Function* allocFunctionOperator(ArithOp op, Set ** domain, uint numDomain, Set * range, OverFlowBehavior overflowbehavior);
-Function* allocFunctionTable (Table* table, UndefinedBehavior behavior);
-uint64_t applyFunctionOperator(FunctionOperator* This, uint numVals, uint64_t * values);
+Function *allocFunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
+Function *allocFunctionTable (Table *table, UndefinedBehavior behavior);
+uint64_t applyFunctionOperator(FunctionOperator *This, uint numVals, uint64_t *values);
 bool isInRangeFunction(FunctionOperator *This, uint64_t val);
 bool isInRangeFunction(FunctionOperator *This, uint64_t val);
-void deleteFunction(FunctionThis);
+void deleteFunction(Function *This);
 
 #endif
 
 #endif
index 1c893a394aa9a83b1b46277232969de0fc6bab90..19552f6cfa01359010cb1fbf77bd6c3ba75258b8 100644 (file)
@@ -1,15 +1,15 @@
 #include "mutableset.h"
 
 #include "mutableset.h"
 
-MutableSet * allocMutableSet(VarType t) {
-       MutableSet * This=(MutableSet *)ourmalloc(sizeof(MutableSet));
-       This->type=t;
-       This->isRange=false;
-       This->low=0;
-       This->high=0;
-       This->members=allocDefVectorInt();
+MutableSet *allocMutableSet(VarType t) {
+       MutableSet *This = (MutableSet *)ourmalloc(sizeof(MutableSet));
+       This->type = t;
+       This->isRange = false;
+       This->low = 0;
+       This->high = 0;
+       This->members = allocDefVectorInt();
        return This;
 }
 
        return This;
 }
 
-void addElementMSet(MutableSet * set, uint64_t element) {
+void addElementMSet(MutableSet *set, uint64_t element) {
        pushVectorInt(set->members, element);
 }
        pushVectorInt(set->members, element);
 }
index fe089f4c86a99ab282e2e4703e8d352baa371ee8..754d39586dbca1db842f1cbf3030ce8830867cec 100644 (file)
@@ -2,6 +2,6 @@
 #define MUTABLESET_H
 #include "set.h"
 
 #define MUTABLESET_H
 #include "set.h"
 
-MutableSet * allocMutableSet(VarType t);
-void addElementMSet(MutableSet * set, uint64_t element);
+MutableSet *allocMutableSet(VarType t);
+void addElementMSet(MutableSet *set, uint64_t element);
 #endif
 #endif
index 054de91ce833b9247a9b6fab80f74fcd2469dbaf..fde8c1f05f7256d35527d6cf074bc7a79211f1f5 100644 (file)
@@ -3,32 +3,32 @@
 #include "set.h"
 #include "boolean.h"
 
 #include "set.h"
 #include "boolean.h"
 
-Order* allocOrder(OrderType type, Set * set){
-       Order* This = (Order*)ourmalloc(sizeof(Order));
-       This->set=set;
-       initDefVectorBooleanOrder(& This->constraints);
-       This->type=type;
-       initOrderEncoding(& This->order, This);
+Order *allocOrder(OrderType type, Set *set) {
+       Order *This = (Order *)ourmalloc(sizeof(Order));
+       This->set = set;
+       initDefVectorBooleanOrder(&This->constraints);
+       This->type = type;
+       initOrderEncoding(&This->order, This);
        This->orderPairTable = NULL;
        return This;
 }
 
        This->orderPairTable = NULL;
        return This;
 }
 
-void initializeOrderHashTable(Order* This){
-       This->orderPairTable=allocHashTableOrderPair(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
+void initializeOrderHashTable(Order *This) {
+       This->orderPairTable = allocHashTableOrderPair(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
 }
 
 }
 
-void addOrderConstraint(Order* This, BooleanOrder* constraint){
+void addOrderConstraint(Order *This, BooleanOrder *constraint) {
        pushVectorBooleanOrder( &This->constraints, constraint);
 }
 
        pushVectorBooleanOrder( &This->constraints, constraint);
 }
 
-void setOrderEncodingType(Order* This, OrderEncodingType type){
+void setOrderEncodingType(Order *This, OrderEncodingType type) {
        This->order.type = type;
 }
 
        This->order.type = type;
 }
 
-void deleteOrder(Order* This){
-       deleteVectorArrayBooleanOrder(& This->constraints);
-       deleteOrderEncoding(& This->order);
-       if(This->orderPairTable != NULL) {
+void deleteOrder(Order *This) {
+       deleteVectorArrayBooleanOrder(&This->constraints);
+       deleteOrderEncoding(&This->order);
+       if (This->orderPairTable != NULL) {
                resetAndDeleteHashTableOrderPair(This->orderPairTable);
                deleteHashTableOrderPair(This->orderPairTable);
        }
                resetAndDeleteHashTableOrderPair(This->orderPairTable);
                deleteHashTableOrderPair(This->orderPairTable);
        }
index 7a173b90f2bf73c26b106792683ac6641be0b8e9..53bf878f063a71a4c8ec11c626dcb673d6857f6f 100644 (file)
@@ -9,15 +9,15 @@
 
 struct Order {
        OrderType type;
 
 struct Order {
        OrderType type;
-       Set * set;
-       HashTableOrderPair * orderPairTable;
+       Set *set;
+       HashTableOrderPair *orderPairTable;
        VectorBooleanOrder constraints;
        OrderEncoding order;
 };
 
        VectorBooleanOrder constraints;
        OrderEncoding order;
 };
 
-Order* allocOrder(OrderType type, Set * set);
-void initializeOrderHashTable(Order * This);
-void addOrderConstraint(Order * This, BooleanOrder * constraint);
-void setOrderEncodingType(Order * This, OrderEncodingType type);
-void deleteOrder(Order * This);
+Order *allocOrder(OrderType type, Set *set);
+void initializeOrderHashTable(Order *This);
+void addOrderConstraint(Order *This, BooleanOrder *constraint);
+void setOrderEncodingType(Order *This, OrderEncodingType type);
+void deleteOrder(Order *This);
 #endif
 #endif
index 24d1f3452ba52e04bdde2fd409c4c90d3d993f40..0e0238af2c1b04a12e06ab87baafbcbd8856df9f 100644 (file)
@@ -3,27 +3,27 @@
 #include "set.h"
 #include "table.h"
 
 #include "set.h"
 #include "table.h"
 
-Predicate* allocPredicateOperator(CompOp op, Set ** domain, uint numDomain){
-       PredicateOperatorThis = ourmalloc(sizeof(PredicateOperator));
-       GETPREDICATETYPE(This)=OPERATORPRED;
+Predicate *allocPredicateOperator(CompOp op, Set **domain, uint numDomain) {
+       PredicateOperator *This = ourmalloc(sizeof(PredicateOperator));
+       GETPREDICATETYPE(This) = OPERATORPRED;
        initArrayInitSet(&This->domains, domain, numDomain);
        initArrayInitSet(&This->domains, domain, numDomain);
-       This->op=op;
+       This->op = op;
        return &This->base;
 }
 
        return &This->base;
 }
 
-Predicate* allocPredicateTable(Table* table, UndefinedBehavior undefBehavior){
+Predicate *allocPredicateTable(Table *table, UndefinedBehavior undefBehavior) {
        ASSERT(table->range == NULL);
        ASSERT(table->range == NULL);
-       PredicateTableThis = ourmalloc(sizeof(PredicateTable));
+       PredicateTable *This = ourmalloc(sizeof(PredicateTable));
        GETPREDICATETYPE(This) = TABLEPRED;
        GETPREDICATETYPE(This) = TABLEPRED;
-       This->table=table;
-       This->undefinedbehavior=undefBehavior;
+       This->table = table;
+       This->undefinedbehavior = undefBehavior;
        return &This->base;
 }
 
        return &This->base;
 }
 
-void deletePredicate(Predicate* This){
-       switch(GETPREDICATETYPE(This)) {
+void deletePredicate(Predicate *This) {
+       switch (GETPREDICATETYPE(This)) {
        case OPERATORPRED: {
        case OPERATORPRED: {
-               PredicateOperator * operpred=(PredicateOperator *) This;
+               PredicateOperator *operpred = (PredicateOperator *) This;
                deleteInlineArraySet(&operpred->domains);
                break;
        }
                deleteInlineArraySet(&operpred->domains);
                break;
        }
@@ -35,18 +35,18 @@ void deletePredicate(Predicate* This){
        ourfree(This);
 }
 
        ourfree(This);
 }
 
-bool evalPredicateOperator(PredicateOperator * This, uint64_t * inputs) {
-       switch(This->op) {
+bool evalPredicateOperator(PredicateOperator *This, uint64_t *inputs) {
+       switch (This->op) {
        case EQUALS:
        case EQUALS:
-               return inputs[0]==inputs[1];
+               return inputs[0] == inputs[1];
        case LT:
        case LT:
-               return inputs[0]<inputs[1];
+               return inputs[0] < inputs[1];
        case GT:
        case GT:
-               return inputs[0]>inputs[1];
+               return inputs[0] > inputs[1];
        case LTE:
        case LTE:
-               return inputs[0]<=inputs[1];
+               return inputs[0] <= inputs[1];
        case GTE:
        case GTE:
-               return inputs[0]>=inputs[1];
+               return inputs[0] >= inputs[1];
        }
        ASSERT(0);
        return false;
        }
        ASSERT(0);
        return false;
index 105e91bd315be90f56bf366ac8042b493377ffea..ff4ee8ce48e9abb1bc179c9eb4c2dbcc5992f0e0 100644 (file)
@@ -19,12 +19,12 @@ struct PredicateOperator {
 
 struct PredicateTable {
        Predicate base;
 
 struct PredicateTable {
        Predicate base;
-       Tabletable;
+       Table *table;
        UndefinedBehavior undefinedbehavior;
 };
 
        UndefinedBehavior undefinedbehavior;
 };
 
-Predicate* allocPredicateOperator(CompOp op, Set ** domain, uint numDomain);
-Predicate* allocPredicateTable(Table* table, UndefinedBehavior undefBehavior);
-bool evalPredicateOperator(PredicateOperator * This, uint64_t * inputs);
-void deletePredicate(PredicateThis);
+Predicate *allocPredicateOperator(CompOp op, Set **domain, uint numDomain);
+Predicate *allocPredicateTable(Table *table, UndefinedBehavior undefBehavior);
+bool evalPredicateOperator(PredicateOperator *This, uint64_t *inputs);
+void deletePredicate(Predicate *This);
 #endif
 #endif
index 1ff40a3334173de8836010538904e7e7ee44baea..0c5d6a4de6c50926f2b927103fd2f68a7e0236d1 100644 (file)
@@ -1,12 +1,12 @@
 #include "rewriter.h"
 #include "boolean.h"
 
 #include "rewriter.h"
 #include "boolean.h"
 
-void replaceBooleanWithTrue(Boolean * This) {
-       uint size=getSizeVectorBoolean(&This->parents);
-       for(uint i=0;i<size;i++) {
-               Boolean * parent=getVectorBoolean(&This->parents, i);
-               BooleanLogic * logicop=(BooleanLogic*) parent;
-               switch(logicop->op) {
+void replaceBooleanWithTrue(Boolean *This) {
+       uint size = getSizeVectorBoolean(&This->parents);
+       for (uint i = 0; i < size; i++) {
+               Boolean *parent = getVectorBoolean(&This->parents, i);
+               BooleanLogic *logicop = (BooleanLogic *) parent;
+               switch (logicop->op) {
                case L_AND:
                        handleANDTrue(logicop, This);
                        break;
                case L_AND:
                        handleANDTrue(logicop, This);
                        break;
@@ -27,16 +27,16 @@ void replaceBooleanWithTrue(Boolean * This) {
 }
 
 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb) {
 }
 
 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb) {
-       uint size=getSizeVectorBoolean(&oldb->parents);
-       for(uint i=0;i<size;i++) {
-               Boolean * parent=getVectorBoolean(&oldb->parents, i);
-               BooleanLogic * logicop=(BooleanLogic*) parent;
-
-               uint parentsize=getSizeArrayBoolean(&logicop->inputs);
-               
-               for(uint j=0;j<parentsize;j++) {
-                       Boolean *b=getArrayBoolean(&logicop->inputs, i);
-                       if (b==oldb) {
+       uint size = getSizeVectorBoolean(&oldb->parents);
+       for (uint i = 0; i < size; i++) {
+               Boolean *parent = getVectorBoolean(&oldb->parents, i);
+               BooleanLogic *logicop = (BooleanLogic *) parent;
+
+               uint parentsize = getSizeArrayBoolean(&logicop->inputs);
+
+               for (uint j = 0; j < parentsize; j++) {
+                       Boolean *b = getArrayBoolean(&logicop->inputs, i);
+                       if (b == oldb) {
                                setArrayBoolean(&logicop->inputs, i, newb);
                                pushVectorBoolean(&newb->parents, parent);
                        }
                                setArrayBoolean(&logicop->inputs, i, newb);
                                pushVectorBoolean(&newb->parents, parent);
                        }
@@ -45,24 +45,24 @@ void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb) {
 }
 
 void handleXORTrue(BooleanLogic *This, Boolean *child) {
 }
 
 void handleXORTrue(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
-       Boolean *b=getArrayBoolean(&This->inputs, 0);
-       uint otherindex=(b==child)?1:0;
+       uint size = getSizeArrayBoolean(&This->inputs);
+       Boolean *b = getArrayBoolean(&This->inputs, 0);
+       uint otherindex = (b == child) ? 1 : 0;
        removeElementArrayBoolean(&This->inputs, otherindex);
        removeElementArrayBoolean(&This->inputs, otherindex);
-       This->op=L_NOT;
+       This->op = L_NOT;
 }
 
 void handleXORFalse(BooleanLogic *This, Boolean *child) {
 }
 
 void handleXORFalse(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
-       Boolean *b=getArrayBoolean(&This->inputs, 0);
-       uint otherindex=(b==child)?1:0;
+       uint size = getSizeArrayBoolean(&This->inputs);
+       Boolean *b = getArrayBoolean(&This->inputs, 0);
+       uint otherindex = (b == child) ? 1 : 0;
        replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, otherindex));
 }
 
 void handleIMPLIESTrue(BooleanLogic *This, Boolean *child) {
        replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, otherindex));
 }
 
 void handleIMPLIESTrue(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
-       Boolean *b=getArrayBoolean(&This->inputs, 0);
-       if (b==child) {
+       uint size = getSizeArrayBoolean(&This->inputs);
+       Boolean *b = getArrayBoolean(&This->inputs, 0);
+       if (b == child) {
                //Replace with other term
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 1));
        } else {
                //Replace with other term
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 1));
        } else {
@@ -72,63 +72,63 @@ void handleIMPLIESTrue(BooleanLogic *This, Boolean *child) {
 }
 
 void handleIMPLIESFalse(BooleanLogic *This, Boolean *child) {
 }
 
 void handleIMPLIESFalse(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
-       Boolean *b=getArrayBoolean(&This->inputs, 0);
-       if (b==child) {
+       uint size = getSizeArrayBoolean(&This->inputs);
+       Boolean *b = getArrayBoolean(&This->inputs, 0);
+       if (b == child) {
                //Statement is true...
                replaceBooleanWithTrue((Boolean *)This);
        } else {
                //Make into negation of first term
                removeElementArrayBoolean(&This->inputs, 1);
                //Statement is true...
                replaceBooleanWithTrue((Boolean *)This);
        } else {
                //Make into negation of first term
                removeElementArrayBoolean(&This->inputs, 1);
-               This->op=L_NOT;
+               This->op = L_NOT;
        }
 }
 
 void handleANDTrue(BooleanLogic *This, Boolean *child) {
        }
 }
 
 void handleANDTrue(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
+       uint size = getSizeArrayBoolean(&This->inputs);
 
 
-       if (size==1) {
+       if (size == 1) {
                replaceBooleanWithTrue((Boolean *)This);
                return;
        }
                replaceBooleanWithTrue((Boolean *)This);
                return;
        }
-       
-       for(uint i=0;i<size;i++) {
-               Boolean *b=getArrayBoolean(&This->inputs, i);
-               if (b==child) {
+
+       for (uint i = 0; i < size; i++) {
+               Boolean *b = getArrayBoolean(&This->inputs, i);
+               if (b == child) {
                        removeElementArrayBoolean(&This->inputs, i);
                }
        }
                        removeElementArrayBoolean(&This->inputs, i);
                }
        }
-       
-       if (size==2) {
+
+       if (size == 2) {
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
        }
 }
 
 void handleORFalse(BooleanLogic *This, Boolean *child) {
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
        }
 }
 
 void handleORFalse(BooleanLogic *This, Boolean *child) {
-       uint size=getSizeArrayBoolean(&This->inputs);
+       uint size = getSizeArrayBoolean(&This->inputs);
 
 
-       if (size==1) {
-               replaceBooleanWithFalse((Boolean*) This);
+       if (size == 1) {
+               replaceBooleanWithFalse((Boolean *) This);
        }
        }
-               
-       for(uint i=0;i<size;i++) {
-               Boolean *b=getArrayBoolean(&This->inputs, i);
-               if (b==child) {
+
+       for (uint i = 0; i < size; i++) {
+               Boolean *b = getArrayBoolean(&This->inputs, i);
+               if (b == child) {
                        removeElementArrayBoolean(&This->inputs, i);
                }
        }
 
                        removeElementArrayBoolean(&This->inputs, i);
                }
        }
 
-       if (size==2) {
+       if (size == 2) {
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
        }
 }
 
                replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
        }
 }
 
-void replaceBooleanWithFalse(Boolean * This) {
-       uint size=getSizeVectorBoolean(&This->parents);
-       for(uint i=0;i<size;i++) {
-               Boolean * parent=getVectorBoolean(&This->parents, i);
-               BooleanLogic * logicop=(BooleanLogic*) parent;
-               switch(logicop->op) {
+void replaceBooleanWithFalse(Boolean *This) {
+       uint size = getSizeVectorBoolean(&This->parents);
+       for (uint i = 0; i < size; i++) {
+               Boolean *parent = getVectorBoolean(&This->parents, i);
+               BooleanLogic *logicop = (BooleanLogic *) parent;
+               switch (logicop->op) {
                case L_AND:
                        replaceBooleanWithFalse(parent);
                        break;
                case L_AND:
                        replaceBooleanWithFalse(parent);
                        break;
@@ -145,5 +145,5 @@ void replaceBooleanWithFalse(Boolean * This) {
                        handleIMPLIESFalse(logicop, This);
                        break;
                }
                        handleIMPLIESFalse(logicop, This);
                        break;
                }
-       }       
+       }
 }
 }
index 9050b73815ffa3c08a27bc8dc2254b364e517f1c..83c5043a23468996bc9e5d45b4e0f4f85d5591c3 100644 (file)
@@ -2,8 +2,8 @@
 #define REWRITER_H
 #include "classlist.h"
 
 #define REWRITER_H
 #include "classlist.h"
 
-void replaceBooleanWithTrue(Boolean * This);
-void replaceBooleanWithFalse(Boolean * This);
+void replaceBooleanWithTrue(Boolean *This);
+void replaceBooleanWithFalse(Boolean *This);
 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb);
 void handleXORTrue(BooleanLogic *This, Boolean *child);
 void handleXORFalse(BooleanLogic *This, Boolean *child);
 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb);
 void handleXORTrue(BooleanLogic *This, Boolean *child);
 void handleXORFalse(BooleanLogic *This, Boolean *child);
index 2569ed28b6c140e9868f4df5f2e7087370f2c72b..003379e003edb9ed64bb9aea0a4840f87a8e70ea 100644 (file)
@@ -1,55 +1,55 @@
 #include "set.h"
 #include <stddef.h>
 
 #include "set.h"
 #include <stddef.h>
 
-Set * allocSet(VarType t, uint64_t* elements, uint num) {
-       Set * This=(Set *)ourmalloc(sizeof(Set));
-       This->type=t;
-       This->isRange=false;
-       This->low=0;
-       This->high=0;
-       This->members=allocVectorArrayInt(num, elements);
+Set *allocSet(VarType t, uint64_t *elements, uint num) {
+       Set *This = (Set *)ourmalloc(sizeof(Set));
+       This->type = t;
+       This->isRange = false;
+       This->low = 0;
+       This->high = 0;
+       This->members = allocVectorArrayInt(num, elements);
        return This;
 }
 
        return This;
 }
 
-Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange) {
-       Set * This=(Set *)ourmalloc(sizeof(Set));
-       This->type=t;
-       This->isRange=true;
-       This->low=lowrange;
-       This->high=highrange;
-       This->members=NULL;
+Set *allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange) {
+       Set *This = (Set *)ourmalloc(sizeof(Set));
+       This->type = t;
+       This->isRange = true;
+       This->low = lowrange;
+       This->high = highrange;
+       This->members = NULL;
        return This;
 }
 
        return This;
 }
 
-bool existsInSet(Set* This, uint64_t element){
-       if(This->isRange){
+bool existsInSet(Set *This, uint64_t element) {
+       if (This->isRange) {
                return element >= This->low && element <= This->high;
        } else {
                uint size = getSizeVectorInt(This->members);
                return element >= This->low && element <= This->high;
        } else {
                uint size = getSizeVectorInt(This->members);
-               for(uint i=0; i< size; i++){
-                       if(element == getVectorInt(This->members, i))
+               for (uint i = 0; i < size; i++) {
+                       if (element == getVectorInt(This->members, i))
                                return true;
                }
                return false;
        }
 }
 
                                return true;
                }
                return false;
        }
 }
 
-uint64_t getSetElement(Set * This, uint index) {
+uint64_t getSetElement(Set *This, uint index) {
        if (This->isRange)
        if (This->isRange)
-               return This->low+index;
+               return This->low + index;
        else
                return getVectorInt(This->members, index);
 }
 
        else
                return getVectorInt(This->members, index);
 }
 
-uint getSetSize(Set* This){
-       if(This->isRange){
-               return This->high - This->low+1;
-       }else{
+uint getSetSize(Set *This) {
+       if (This->isRange) {
+               return This->high - This->low + 1;
+       } else {
                return getSizeVectorInt(This->members);
        }
 }
 
                return getSizeVectorInt(This->members);
        }
 }
 
-void deleteSet(Set * This) {
+void deleteSet(Set *This) {
        if (!This->isRange)
                deleteVectorInt(This->members);
        ourfree(This);
        if (!This->isRange)
                deleteVectorInt(This->members);
        ourfree(This);
index 1555ae9650dc1169795fbd61174c5635461851d3..16fde20057370fc70cf9f4e5e265bb83f474971c 100644 (file)
@@ -17,14 +17,14 @@ struct Set {
        bool isRange;
        uint64_t low;//also used to count unique items
        uint64_t high;
        bool isRange;
        uint64_t low;//also used to count unique items
        uint64_t high;
-       VectorInt * members;
+       VectorInt *members;
 };
 
 };
 
-Set * allocSet(VarType t, uint64_t * elements, uint num);
-Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange);
-bool existsInSet(Set * This, uint64_t element);
-uint getSetSize(Set * This);
-uint64_t getSetElement(Set * This, uint index);
-void deleteSet(Set * This);
+Set *allocSet(VarType t, uint64_t *elements, uint num);
+Set *allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange);
+bool existsInSet(Set *This, uint64_t element);
+uint getSetSize(Set *This);
+uint64_t getSetElement(Set *This, uint index);
+void deleteSet(Set *This);
 #endif/* SET_H */
 
 #endif/* SET_H */
 
index 6b3863e5893ef9919d32c30b803bb358cab4af3a..b903744dac3b9062495c224a7f2b1b80607d1bfb 100644 (file)
@@ -5,41 +5,41 @@
 #include "set.h"
 #include "mutableset.h"
 
 #include "set.h"
 #include "mutableset.h"
 
-Table * allocTable(Set **domains, uint numDomain, Set * range){
-       Table* This = (Table*) ourmalloc(sizeof(Table));
+Table *allocTable(Set **domains, uint numDomain, Set *range) {
+       Table *This = (Table *) ourmalloc(sizeof(Table));
        initArrayInitSet(&This->domains, domains, numDomain);
        initArrayInitSet(&This->domains, domains, numDomain);
-       This->entries= allocHashSetTableEntry(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
-       This->range =range;
+       This->entries = allocHashSetTableEntry(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
+       This->range = range;
        return This;
 }
 
        return This;
 }
 
-void addNewTableEntry(Table* This, uint64_t* inputs, uint inputSize, uint64_t result){
+void addNewTableEntry(Table *This, uint64_t *inputs, uint inputSize, uint64_t result) {
        ASSERT(getSizeArraySet( &This->domains) == inputSize);
 #ifdef CONFIG_ASSERT
        ASSERT(getSizeArraySet( &This->domains) == inputSize);
 #ifdef CONFIG_ASSERT
-       if(This->range==NULL)
+       if (This->range == NULL)
                ASSERT(result == true || result == false);
 #endif
                ASSERT(result == true || result == false);
 #endif
-       TableEntrytb = allocTableEntry(inputs, inputSize, result);
+       TableEntry *tb = allocTableEntry(inputs, inputSize, result);
        ASSERT(!containsHashSetTableEntry(This->entries, tb));
        ASSERT(!containsHashSetTableEntry(This->entries, tb));
-       bool status= addHashSetTableEntry(This->entries, tb);
+       bool status = addHashSetTableEntry(This->entries, tb);
        ASSERT(status);
 }
 
        ASSERT(status);
 }
 
-TableEntry* getTableEntryFromTable(Table* table, uint64_t* inputs, uint inputSize){
-       TableEntrytemp = allocTableEntry(inputs, inputSize, -1);
-       TableEntry* result= getHashSetTableEntry(table->entries, temp);
+TableEntry *getTableEntryFromTable(Table *table, uint64_t *inputs, uint inputSize) {
+       TableEntry *temp = allocTableEntry(inputs, inputSize, -1);
+       TableEntry *result = getHashSetTableEntry(table->entries, temp);
        deleteTableEntry(temp);
        return result;
 }
 
        deleteTableEntry(temp);
        return result;
 }
 
-void deleteTable(Table* This){
-  deleteInlineArraySet(&This->domains);
-  HSIteratorTableEntry* iterator = iteratorTableEntry(This->entries);
-  while(hasNextTableEntry(iterator)){
-         deleteTableEntry( nextTableEntry(iterator) );
-  }
-  deleteIterTableEntry(iterator);
-  deleteHashSetTableEntry(This->entries);
-  ourfree(This);
+void deleteTable(Table *This) {
+       deleteInlineArraySet(&This->domains);
+       HSIteratorTableEntry *iterator = iteratorTableEntry(This->entries);
+       while (hasNextTableEntry(iterator)) {
+               deleteTableEntry( nextTableEntry(iterator) );
+       }
+       deleteIterTableEntry(iterator);
+       deleteHashSetTableEntry(This->entries);
+       ourfree(This);
 }
 
 }
 
index 970882a1cec43266d2b19db0b83d168dc39098d4..d9a0c185f32d685d316f796f8306740d788dc36c 100644 (file)
@@ -6,12 +6,12 @@
 
 struct Table {
        ArraySet domains;
 
 struct Table {
        ArraySet domains;
-       Set * range;
-       HashSetTableEntryentries;
+       Set *range;
+       HashSetTableEntry *entries;
 };
 
 };
 
-Table * allocTable(Set ** domains, uint numDomain, Set * range);
-void addNewTableEntry(Table * This, uint64_t * inputs, uint inputSize, uint64_t result);
-TableEntry* getTableEntryFromTable(Table* table, uint64_t* inputs, uint inputSize);
-void deleteTable(Table * This);
+Table *allocTable(Set **domains, uint numDomain, Set *range);
+void addNewTableEntry(Table *This, uint64_t *inputs, uint inputSize, uint64_t result);
+TableEntry *getTableEntryFromTable(Table *table, uint64_t *inputs, uint inputSize);
+void deleteTable(Table *This);
 #endif
 #endif
index 4fb74a5e0cef5ae198913936b4e540f5b1cd0f0e..64aae20ffd5b2b2080a9a272563ffddace5e8abf 100644 (file)
@@ -1,14 +1,14 @@
 #include "tableentry.h"
 #include <string.h>
 
 #include "tableentry.h"
 #include <string.h>
 
-TableEntry* allocTableEntry(uint64_t* inputs, uint inputSize, uint64_t result){
-       TableEntry* te = (TableEntry*) ourmalloc(sizeof(TableEntry)+inputSize*sizeof(uint64_t));
-       te->output=result;
-       te->inputSize=inputSize;
+TableEntry *allocTableEntry(uint64_t *inputs, uint inputSize, uint64_t result) {
+       TableEntry *te = (TableEntry *) ourmalloc(sizeof(TableEntry) + inputSize * sizeof(uint64_t));
+       te->output = result;
+       te->inputSize = inputSize;
        memcpy(te->inputs, inputs, inputSize * sizeof(uint64_t));
        return te;
 }
 
        memcpy(te->inputs, inputs, inputSize * sizeof(uint64_t));
        return te;
 }
 
-void deleteTableEntry(TableEntry* tableEntry){
+void deleteTableEntry(TableEntry *tableEntry) {
        ourfree(tableEntry);
 }
        ourfree(tableEntry);
 }
index 1901e536af8cc590937ad0b34801dd2326199956..c85255f818e6926cf82727d957ed19df120276e4 100644 (file)
@@ -22,8 +22,8 @@ struct TableEntry {
        uint64_t inputs[];
 };
 
        uint64_t inputs[];
 };
 
-TableEntry* allocTableEntry(uint64_t* inputs, uint inputSize, uint64_t result);
-void deleteTableEntry(TableEntrytableEntry);
+TableEntry *allocTableEntry(uint64_t *inputs, uint inputSize, uint64_t result);
+void deleteTableEntry(TableEntry *tableEntry);
 
 #endif/* TABLEENTRY_H */
 
 
 #endif/* TABLEENTRY_H */
 
index c2a5bc9f9d3769c8592419e7069c358ab1f6e2db..ae1104fc9bfaab6155c450d04a3e9f85fedc3f0b 100644 (file)
@@ -1,70 +1,70 @@
 #include "cnfexpr.h"
 #include <stdio.h>
 #include "cnfexpr.h"
 #include <stdio.h>
-/* 
-V2 Copyright (c) 2014 Ben Chambers, Eugene Goldberg, Pete Manolios,
-Vasilis Papavasileiou, Sudarshan Srinivasan, and Daron Vroon.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.  If
-you download or use the software, send email to Pete Manolios
-(pete@ccs.neu.edu) with your name, contact information, and a short
-note describing what you want to use BAT for.  For any reuse or
-distribution, you must make clear to others the license terms of this
-work.
-
-Contact Pete Manolios if you want any of these conditions waived.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-/* 
-C port of CNF SAT Conversion Copyright Brian Demsky 2017. 
-*/
+/*
+   V2 Copyright (c) 2014 Ben Chambers, Eugene Goldberg, Pete Manolios,
+   Vasilis Papavasileiou, Sudarshan Srinivasan, and Daron Vroon.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   "Software"), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.  If
+   you download or use the software, send email to Pete Manolios
+   (pete@ccs.neu.edu) with your name, contact information, and a short
+   note describing what you want to use BAT for.  For any reuse or
+   distribution, you must make clear to others the license terms of this
+   work.
+
+   Contact Pete Manolios if you want any of these conditions waived.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+   C port of CNF SAT Conversion Copyright Brian Demsky 2017.
+ */
 
 #define LITCAPACITY 4
 #define MERGESIZE 5
 
 VectorImpl(LitVector, LitVector *, 4)
 
 
 #define LITCAPACITY 4
 #define MERGESIZE 5
 
 VectorImpl(LitVector, LitVector *, 4)
 
-static inline uint boundedSize(uint x) { return (x > MERGESIZE)?MERGESIZE:x; }
+static inline uint boundedSize(uint x) { return (x > MERGESIZE) ? MERGESIZE : x; }
 
 
-LitVector * allocLitVector() {
-       LitVector *This=ourmalloc(sizeof(LitVector));
+LitVector *allocLitVector() {
+       LitVector *This = ourmalloc(sizeof(LitVector));
        initLitVector(This);
        return This;
 }
 
 void initLitVector(LitVector *This) {
        initLitVector(This);
        return This;
 }
 
 void initLitVector(LitVector *This) {
-       This->size=0;
-       This->capacity=LITCAPACITY;
-       This->literals=ourmalloc(This->capacity * sizeof(Literal));
+       This->size = 0;
+       This->capacity = LITCAPACITY;
+       This->literals = ourmalloc(This->capacity * sizeof(Literal));
 }
 
 LitVector *cloneLitVector(LitVector *orig) {
 }
 
 LitVector *cloneLitVector(LitVector *orig) {
-       LitVector *This=ourmalloc(sizeof(LitVector));
-       This->size=orig->size;
-       This->capacity=orig->capacity;
-       This->literals=ourmalloc(This->capacity * sizeof(Literal));
+       LitVector *This = ourmalloc(sizeof(LitVector));
+       This->size = orig->size;
+       This->capacity = orig->capacity;
+       This->literals = ourmalloc(This->capacity * sizeof(Literal));
        memcpy(This->literals, orig->literals, sizeof(Literal) * This->size);
        return This;
 }
 
 void clearLitVector(LitVector *This) {
        memcpy(This->literals, orig->literals, sizeof(Literal) * This->size);
        return This;
 }
 
 void clearLitVector(LitVector *This) {
-       This->size=0;
+       This->size = 0;
 }
 
 void freeLitVector(LitVector *This) {
 }
 
 void freeLitVector(LitVector *This) {
@@ -81,14 +81,14 @@ Literal getLiteralLitVector(LitVector *This, uint index) {
 }
 
 void setLiteralLitVector(LitVector *This, uint index, Literal l) {
 }
 
 void setLiteralLitVector(LitVector *This, uint index, Literal l) {
-       This->literals[index]=l;
+       This->literals[index] = l;
 }
 
 void addLiteralLitVector(LitVector *This, Literal l) {
        Literal labs = abs(l);
 }
 
 void addLiteralLitVector(LitVector *This, Literal l) {
        Literal labs = abs(l);
-       uint vec_size=This->size;
-       uint searchsize=boundedSize(vec_size);
-       uint i=0;
+       uint vec_size = This->size;
+       uint searchsize = boundedSize(vec_size);
+       uint i = 0;
        for (; i < searchsize; i++) {
                Literal curr = This->literals[i];
                Literal currabs = abs(curr);
        for (; i < searchsize; i++) {
                Literal curr = This->literals[i];
                Literal currabs = abs(curr);
@@ -96,36 +96,36 @@ void addLiteralLitVector(LitVector *This, Literal l) {
                        break;
                if (currabs == labs) {
                        if (curr == -l)
                        break;
                if (currabs == labs) {
                        if (curr == -l)
-                               This->size = 0; //either true or false now depending on whether this is a conj or disj
+                               This->size = 0; //either true or false now depending on whether this is a conj or disj
                        return;
                }
        }
        if ((++This->size) >= This->capacity) {
                This->capacity <<= 1;
                        return;
                }
        }
        if ((++This->size) >= This->capacity) {
                This->capacity <<= 1;
-               This->literals=ourrealloc(This->literals, This->capacity * sizeof(Literal));
+               This->literals = ourrealloc(This->literals, This->capacity * sizeof(Literal));
        }
        }
-       
+
        if (vec_size < MERGESIZE) {
        if (vec_size < MERGESIZE) {
-               memmove(&This->literals[i+1], &This->literals[i], (vec_size-i) * sizeof(Literal));
-               This->literals[i]=l;
+               memmove(&This->literals[i + 1], &This->literals[i], (vec_size - i) * sizeof(Literal));
+               This->literals[i] = l;
        } else {
        } else {
-               This->literals[vec_size]=l;
+               This->literals[vec_size] = l;
        }
 }
 
        }
 }
 
-CNFExpr * allocCNFExprBool(bool isTrue) {
-       CNFExpr *This=ourmalloc(sizeof(CNFExpr));
-       This->litSize=0;
-       This->isTrue=isTrue;
+CNFExpr *allocCNFExprBool(bool isTrue) {
+       CNFExpr *This = ourmalloc(sizeof(CNFExpr));
+       This->litSize = 0;
+       This->isTrue = isTrue;
        initVectorLitVector(&This->clauses, 2);
        initLitVector(&This->singletons);
        return This;
 }
 
        initVectorLitVector(&This->clauses, 2);
        initLitVector(&This->singletons);
        return This;
 }
 
-CNFExpr * allocCNFExprLiteral(Literal l) {
-       CNFExpr *This=ourmalloc(sizeof(CNFExpr));
-       This->litSize=1;
-       This->isTrue=false;
+CNFExpr *allocCNFExprLiteral(Literal l) {
+       CNFExpr *This = ourmalloc(sizeof(CNFExpr));
+       This->litSize = 1;
+       This->isTrue = false;
        initVectorLitVector(&This->clauses, 2);
        initLitVector(&This->singletons);
        addLiteralLitVector(&This->singletons, l);
        initVectorLitVector(&This->clauses, 2);
        initLitVector(&This->singletons);
        addLiteralLitVector(&This->singletons, l);
@@ -133,17 +133,17 @@ CNFExpr * allocCNFExprLiteral(Literal l) {
 }
 
 void clearCNFExpr(CNFExpr *This, bool isTrue) {
 }
 
 void clearCNFExpr(CNFExpr *This, bool isTrue) {
-       for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
+       for (uint i = 0; i < getSizeVectorLitVector(&This->clauses); i++) {
                deleteLitVector(getVectorLitVector(&This->clauses, i));
        }
        clearVectorLitVector(&This->clauses);
        clearLitVector(&This->singletons);
                deleteLitVector(getVectorLitVector(&This->clauses, i));
        }
        clearVectorLitVector(&This->clauses);
        clearLitVector(&This->singletons);
-       This->litSize=0;
-       This->isTrue=isTrue;
+       This->litSize = 0;
+       This->isTrue = isTrue;
 }
 
 void deleteCNFExpr(CNFExpr *This) {
 }
 
 void deleteCNFExpr(CNFExpr *This) {
-       for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
+       for (uint i = 0; i < getSizeVectorLitVector(&This->clauses); i++) {
                deleteLitVector(getVectorLitVector(&This->clauses, i));
        }
        deleteVectorArrayLitVector(&This->clauses);
                deleteLitVector(getVectorLitVector(&This->clauses, i));
        }
        deleteVectorArrayLitVector(&This->clauses);
@@ -152,44 +152,44 @@ void deleteCNFExpr(CNFExpr *This) {
 }
 
 void conjoinCNFLit(CNFExpr *This, Literal l) {
 }
 
 void conjoinCNFLit(CNFExpr *This, Literal l) {
-       if (This->litSize==0 && !This->isTrue) //Handle False
+       if (This->litSize == 0 && !This->isTrue)//Handle False
                return;
                return;
-       
-       This->litSize-=getSizeLitVector(&This->singletons);
+
+       This->litSize -= getSizeLitVector(&This->singletons);
        addLiteralLitVector(&This->singletons, l);
        addLiteralLitVector(&This->singletons, l);
-       uint newsize=getSizeLitVector(&This->singletons);
-       if (newsize==0)
-               clearCNFExpr(This, false); //We found a conflict
+       uint newsize = getSizeLitVector(&This->singletons);
+       if (newsize == 0)
+               clearCNFExpr(This, false);//We found a conflict
        else
        else
-               This->litSize+=getSizeLitVector(&This->singletons);
+               This->litSize += getSizeLitVector(&This->singletons);
 }
 
 void copyCNF(CNFExpr *This, CNFExpr *expr, bool destroy) {
        if (destroy) {
                ourfree(This->singletons.literals);
                ourfree(This->clauses.array);
 }
 
 void copyCNF(CNFExpr *This, CNFExpr *expr, bool destroy) {
        if (destroy) {
                ourfree(This->singletons.literals);
                ourfree(This->clauses.array);
-               This->litSize=expr->litSize;
-               This->singletons.literals=expr->singletons.literals;
-               This->singletons.capacity=expr->singletons.capacity;
-               This->clauses.size=expr->clauses.size;
-               This->clauses.array=expr->clauses.array;
-               This->clauses.capacity=expr->clauses.capacity;
+               This->litSize = expr->litSize;
+               This->singletons.literals = expr->singletons.literals;
+               This->singletons.capacity = expr->singletons.capacity;
+               This->clauses.size = expr->clauses.size;
+               This->clauses.array = expr->clauses.array;
+               This->clauses.capacity = expr->clauses.capacity;
                ourfree(expr);
        } else {
                ourfree(expr);
        } else {
-               for(uint i=0;i<getSizeLitVector(&expr->singletons);i++) {
-                       Literal l=getLiteralLitVector(&expr->singletons,i);
+               for (uint i = 0; i < getSizeLitVector(&expr->singletons); i++) {
+                       Literal l = getLiteralLitVector(&expr->singletons,i);
                        addLiteralLitVector(&This->singletons, l);
                }
                        addLiteralLitVector(&This->singletons, l);
                }
-               for(uint i=0;i<getSizeVectorLitVector(&expr->clauses);i++) {
-                       LitVector *lv=getVectorLitVector(&expr->clauses,i);
+               for (uint i = 0; i < getSizeVectorLitVector(&expr->clauses); i++) {
+                       LitVector *lv = getVectorLitVector(&expr->clauses,i);
                        pushVectorLitVector(&This->clauses, cloneLitVector(lv));
                }
                        pushVectorLitVector(&This->clauses, cloneLitVector(lv));
                }
-               This->litSize=expr->litSize;
+               This->litSize = expr->litSize;
        }
 }
 
 void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
        }
 }
 
 void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
-       if (expr->litSize==0) {
+       if (expr->litSize == 0) {
                if (!This->isTrue) {
                        clearCNFExpr(This, false);
                }
                if (!This->isTrue) {
                        clearCNFExpr(This, false);
                }
@@ -198,7 +198,7 @@ void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
                }
                return;
        }
                }
                return;
        }
-       if (This->litSize==0) {
+       if (This->litSize == 0) {
                if (This->isTrue) {
                        copyCNF(This, expr, destroy);
                } else if (destroy) {
                if (This->isTrue) {
                        copyCNF(This, expr, destroy);
                } else if (destroy) {
@@ -206,12 +206,12 @@ void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
                }
                return;
        }
                }
                return;
        }
-       uint litSize=This->litSize;
-       litSize-=getSizeLitVector(&expr->singletons);
-       for(uint i=0;i<getSizeLitVector(&expr->singletons);i++) {
-               Literal l=getLiteralLitVector(&expr->singletons,i);
+       uint litSize = This->litSize;
+       litSize -= getSizeLitVector(&expr->singletons);
+       for (uint i = 0; i < getSizeLitVector(&expr->singletons); i++) {
+               Literal l = getLiteralLitVector(&expr->singletons,i);
                addLiteralLitVector(&This->singletons, l);
                addLiteralLitVector(&This->singletons, l);
-               if (getSizeLitVector(&This->singletons)==0) {
+               if (getSizeLitVector(&This->singletons) == 0) {
                        //Found conflict...
                        clearCNFExpr(This, false);
                        if (destroy) {
                        //Found conflict...
                        clearCNFExpr(This, false);
                        if (destroy) {
@@ -220,27 +220,27 @@ void conjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
                        return;
                }
        }
                        return;
                }
        }
-       litSize+=getSizeLitVector(&expr->singletons);
+       litSize += getSizeLitVector(&expr->singletons);
        if (destroy) {
        if (destroy) {
-               for(uint i=0;i<getSizeVectorLitVector(&expr->clauses);i++) {
-                       LitVector *lv=getVectorLitVector(&expr->clauses,i);
-                       litSize+=getSizeLitVector(lv);
+               for (uint i = 0; i < getSizeVectorLitVector(&expr->clauses); i++) {
+                       LitVector *lv = getVectorLitVector(&expr->clauses,i);
+                       litSize += getSizeLitVector(lv);
                        pushVectorLitVector(&This->clauses, lv);
                }
                clearVectorLitVector(&expr->clauses);
                deleteCNFExpr(expr);
        } else {
                        pushVectorLitVector(&This->clauses, lv);
                }
                clearVectorLitVector(&expr->clauses);
                deleteCNFExpr(expr);
        } else {
-               for(uint i=0;i<getSizeVectorLitVector(&expr->clauses);i++) {
-                       LitVector *lv=getVectorLitVector(&expr->clauses,i);
-                       litSize+=getSizeLitVector(lv);
+               for (uint i = 0; i < getSizeVectorLitVector(&expr->clauses); i++) {
+                       LitVector *lv = getVectorLitVector(&expr->clauses,i);
+                       litSize += getSizeLitVector(lv);
                        pushVectorLitVector(&This->clauses, cloneLitVector(lv));
                }
        }
                        pushVectorLitVector(&This->clauses, cloneLitVector(lv));
                }
        }
-       This->litSize=litSize;
+       This->litSize = litSize;
 }
 
 void disjoinCNFLit(CNFExpr *This, Literal l) {
 }
 
 void disjoinCNFLit(CNFExpr *This, Literal l) {
-       if (This->litSize==0) {
+       if (This->litSize == 0) {
                if (!This->isTrue) {
                        This->litSize++;
                        addLiteralLitVector(&This->singletons, l);
                if (!This->isTrue) {
                        This->litSize++;
                        addLiteralLitVector(&This->singletons, l);
@@ -248,32 +248,32 @@ void disjoinCNFLit(CNFExpr *This, Literal l) {
                return;
        }
 
                return;
        }
 
-       uint litSize=0;
-       uint newindex=0;
-       for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
-               LitVector * lv=getVectorLitVector(&This->clauses, i);
+       uint litSize = 0;
+       uint newindex = 0;
+       for (uint i = 0; i < getSizeVectorLitVector(&This->clauses); i++) {
+               LitVector *lv = getVectorLitVector(&This->clauses, i);
                addLiteralLitVector(lv, l);
                addLiteralLitVector(lv, l);
-               uint newSize=getSizeLitVector(lv);
-               if (newSize!=0) {
+               uint newSize = getSizeLitVector(lv);
+               if (newSize != 0) {
                        setVectorLitVector(&This->clauses, newindex++, lv);
                } else {
                        deleteLitVector(lv);
                }
                        setVectorLitVector(&This->clauses, newindex++, lv);
                } else {
                        deleteLitVector(lv);
                }
-               litSize+=newSize;
+               litSize += newSize;
        }
        setSizeVectorLitVector(&This->clauses, newindex);
 
        }
        setSizeVectorLitVector(&This->clauses, newindex);
 
-       bool hasSameSingleton=false;
-       for(uint i=0;i<getSizeLitVector(&This->singletons);i++) {
-               Literal lsing=getLiteralLitVector(&This->singletons, i);
+       bool hasSameSingleton = false;
+       for (uint i = 0; i < getSizeLitVector(&This->singletons); i++) {
+               Literal lsing = getLiteralLitVector(&This->singletons, i);
                if (lsing == l) {
                if (lsing == l) {
-                       hasSameSingleton=true;
+                       hasSameSingleton = true;
                } else if (lsing != -l) {
                        //Create new LitVector with both l and lsing
                } else if (lsing != -l) {
                        //Create new LitVector with both l and lsing
-                       LitVector *newlitvec=allocLitVector();
+                       LitVector *newlitvec = allocLitVector();
                        addLiteralLitVector(newlitvec, l);
                        addLiteralLitVector(newlitvec, lsing);
                        addLiteralLitVector(newlitvec, l);
                        addLiteralLitVector(newlitvec, lsing);
-                       litSize+=2;
+                       litSize += 2;
                        pushVectorLitVector(&This->clauses, newlitvec);
                }
        }
                        pushVectorLitVector(&This->clauses, newlitvec);
                }
        }
@@ -281,60 +281,60 @@ void disjoinCNFLit(CNFExpr *This, Literal l) {
        if (hasSameSingleton) {
                addLiteralLitVector(&This->singletons, l);
                litSize++;
        if (hasSameSingleton) {
                addLiteralLitVector(&This->singletons, l);
                litSize++;
-       } else if (litSize==0) {
-               This->isTrue=true;//we are true
+       } else if (litSize == 0) {
+               This->isTrue = true;//we are true
        }
        }
-       This->litSize=litSize;
+       This->litSize = litSize;
 }
 
 #define MERGETHRESHOLD 2
 }
 
 #define MERGETHRESHOLD 2
-LitVector * mergeLitVectors(LitVector *This, LitVector *expr) {
-       uint maxsize=This->size+expr->size+MERGETHRESHOLD;
-       LitVector *merged=ourmalloc(sizeof(LitVector));
-       merged->literals=ourmalloc(sizeof(Literal)*maxsize);
-       merged->capacity=maxsize;
-       uint thisSize=boundedSize(This->size);
-       uint exprSize=boundedSize(expr->size);
-       uint iThis=0, iExpr=0, iMerge=0;
-       Literal lThis=This->literals[iThis];
-       Literal lExpr=expr->literals[iExpr];
-       Literal thisAbs=abs(lThis);
-       Literal exprAbs=abs(lExpr);
-
-       while(iThis<thisSize && iExpr<exprSize) {
-               if (thisAbs<exprAbs) {
-                       merged->literals[iMerge++]=lThis;
-                       lThis=This->literals[++iThis];
-                       thisAbs=abs(lThis);
-               } else if(thisAbs>exprAbs) {
-                       merged->literals[iMerge++]=lExpr;
-                       lExpr=expr->literals[++iExpr];
-                       exprAbs=abs(lExpr);
-               } else if(lThis==lExpr) {
-                       merged->literals[iMerge++]=lExpr;
-                       lExpr=expr->literals[++iExpr];
-                       exprAbs=abs(lExpr);
-                       lThis=This->literals[++iThis];
-                       thisAbs=abs(lThis);
-               } else if(lThis==-lExpr) {
-                       merged->size=0;
+LitVector *mergeLitVectors(LitVector *This, LitVector *expr) {
+       uint maxsize = This->size + expr->size + MERGETHRESHOLD;
+       LitVector *merged = ourmalloc(sizeof(LitVector));
+       merged->literals = ourmalloc(sizeof(Literal) * maxsize);
+       merged->capacity = maxsize;
+       uint thisSize = boundedSize(This->size);
+       uint exprSize = boundedSize(expr->size);
+       uint iThis = 0, iExpr = 0, iMerge = 0;
+       Literal lThis = This->literals[iThis];
+       Literal lExpr = expr->literals[iExpr];
+       Literal thisAbs = abs(lThis);
+       Literal exprAbs = abs(lExpr);
+
+       while (iThis < thisSize && iExpr < exprSize) {
+               if (thisAbs < exprAbs) {
+                       merged->literals[iMerge++] = lThis;
+                       lThis = This->literals[++iThis];
+                       thisAbs = abs(lThis);
+               } else if (thisAbs > exprAbs) {
+                       merged->literals[iMerge++] = lExpr;
+                       lExpr = expr->literals[++iExpr];
+                       exprAbs = abs(lExpr);
+               } else if (lThis == lExpr) {
+                       merged->literals[iMerge++] = lExpr;
+                       lExpr = expr->literals[++iExpr];
+                       exprAbs = abs(lExpr);
+                       lThis = This->literals[++iThis];
+                       thisAbs = abs(lThis);
+               } else if (lThis == -lExpr) {
+                       merged->size = 0;
                        return merged;
                }
        }
        if (iThis < thisSize) {
                        return merged;
                }
        }
        if (iThis < thisSize) {
-               memcpy(&merged->literals[iMerge], &This->literals[iThis], (thisSize-iThis) * sizeof(Literal));
-               iMerge += (thisSize-iThis);
+               memcpy(&merged->literals[iMerge], &This->literals[iThis], (thisSize - iThis) * sizeof(Literal));
+               iMerge += (thisSize - iThis);
        }
        if (iExpr < exprSize) {
        }
        if (iExpr < exprSize) {
-               memcpy(&merged->literals[iMerge], &expr->literals[iExpr], (exprSize-iExpr) * sizeof(Literal));
-               iMerge += (exprSize-iExpr);
+               memcpy(&merged->literals[iMerge], &expr->literals[iExpr], (exprSize - iExpr) * sizeof(Literal));
+               iMerge += (exprSize - iExpr);
        }
        }
-       merged->size=iMerge;
+       merged->size = iMerge;
        return merged;
 }
 
        return merged;
 }
 
-LitVector * mergeLitVectorLiteral(LitVector *This, Literal l) {
-       LitVector *copy=cloneLitVector(This);
+LitVector *mergeLitVectorLiteral(LitVector *This, Literal l) {
+       LitVector *copy = cloneLitVector(This);
        addLiteralLitVector(copy, l);
        return copy;
 }
        addLiteralLitVector(copy, l);
        return copy;
 }
@@ -363,100 +363,100 @@ void disjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy) {
                }
                return;
        } else if (destroy && This->litSize == 1) {
                }
                return;
        } else if (destroy && This->litSize == 1) {
-               Literal l=getLiteralLitVector(&This->singletons,0);
+               Literal l = getLiteralLitVector(&This->singletons,0);
                copyCNF(This, expr, true);
                disjoinCNFLit(This, l);
                return;
        }
                copyCNF(This, expr, true);
                disjoinCNFLit(This, l);
                return;
        }
-       
+
        /** Handle the full cross product */
        /** Handle the full cross product */
-       uint mergeIndex=0;
-       uint newCapacity=getClauseSizeCNF(This)*getClauseSizeCNF(expr);
-       LitVector ** mergeArray=ourmalloc(newCapacity*sizeof(LitVector*));
-       uint singleIndex=0;
+       uint mergeIndex = 0;
+       uint newCapacity = getClauseSizeCNF(This) * getClauseSizeCNF(expr);
+       LitVector **mergeArray = ourmalloc(newCapacity * sizeof(LitVector *));
+       uint singleIndex = 0;
        /** First do the singleton, clause pairs */
        /** First do the singleton, clause pairs */
-       for(uint i=0;i<getSizeLitVector(&This->singletons);i++) {
-               Literal lThis=getLiteralLitVector(&This->singletons, i);
-               for(uint j=0;j<getSizeVectorLitVector(&expr->clauses);j++) {
-                       LitVector * lExpr=getVectorLitVector(&expr->clauses, j);
-                       LitVector * copy=cloneLitVector(lExpr);
+       for (uint i = 0; i < getSizeLitVector(&This->singletons); i++) {
+               Literal lThis = getLiteralLitVector(&This->singletons, i);
+               for (uint j = 0; j < getSizeVectorLitVector(&expr->clauses); j++) {
+                       LitVector *lExpr = getVectorLitVector(&expr->clauses, j);
+                       LitVector *copy = cloneLitVector(lExpr);
                        addLiteralLitVector(copy, lThis);
                        addLiteralLitVector(copy, lThis);
-                       if (getSizeLitVector(copy)==0) {
+                       if (getSizeLitVector(copy) == 0) {
                                deleteLitVector(copy);
                        } else {
                                deleteLitVector(copy);
                        } else {
-                               mergeArray[mergeIndex++]=copy;
+                               mergeArray[mergeIndex++] = copy;
                        }
                }
        }
 
        /** Next do the clause, singleton pairs */
                        }
                }
        }
 
        /** Next do the clause, singleton pairs */
-       for(uint i=0;i<getSizeLitVector(&expr->singletons);i++) {
-               Literal lExpr=getLiteralLitVector(&expr->singletons, i);
-               for(uint j=0;j<getSizeVectorLitVector(&This->clauses);j++) {
-                       LitVector * lThis=getVectorLitVector(&This->clauses, j);
-                       LitVector * copy=cloneLitVector(lThis);
+       for (uint i = 0; i < getSizeLitVector(&expr->singletons); i++) {
+               Literal lExpr = getLiteralLitVector(&expr->singletons, i);
+               for (uint j = 0; j < getSizeVectorLitVector(&This->clauses); j++) {
+                       LitVector *lThis = getVectorLitVector(&This->clauses, j);
+                       LitVector *copy = cloneLitVector(lThis);
                        addLiteralLitVector(copy, lExpr);
                        addLiteralLitVector(copy, lExpr);
-                       if (getSizeLitVector(copy)==0) {
+                       if (getSizeLitVector(copy) == 0) {
                                deleteLitVector(copy);
                        } else {
                                deleteLitVector(copy);
                        } else {
-                               mergeArray[mergeIndex++]=copy;
+                               mergeArray[mergeIndex++] = copy;
                        }
                }
        }
 
        /** Next do the clause, clause pairs */
                        }
                }
        }
 
        /** Next do the clause, clause pairs */
-       for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
-               LitVector * lThis=getVectorLitVector(&This->clauses, i);
-               for(uint j=0;j<getSizeVectorLitVector(&expr->clauses);j++) {
-                       LitVector * lExpr=getVectorLitVector(&expr->clauses, j);
-                       LitVector * merge=mergeLitVectors(lThis, lExpr);
-                       if (getSizeLitVector(merge)==0) {
+       for (uint i = 0; i < getSizeVectorLitVector(&This->clauses); i++) {
+               LitVector *lThis = getVectorLitVector(&This->clauses, i);
+               for (uint j = 0; j < getSizeVectorLitVector(&expr->clauses); j++) {
+                       LitVector *lExpr = getVectorLitVector(&expr->clauses, j);
+                       LitVector *merge = mergeLitVectors(lThis, lExpr);
+                       if (getSizeLitVector(merge) == 0) {
                                deleteLitVector(merge);
                        } else {
                                deleteLitVector(merge);
                        } else {
-                               mergeArray[mergeIndex++]=merge;
+                               mergeArray[mergeIndex++] = merge;
                        }
                }
                deleteLitVector(lThis);//Done with this litVector
        }
                        }
                }
                deleteLitVector(lThis);//Done with this litVector
        }
-       
+
        /** Finally do the singleton, singleton pairs */
        /** Finally do the singleton, singleton pairs */
-       for(uint i=0;i<getSizeLitVector(&This->singletons);i++) {
-               Literal lThis=getLiteralLitVector(&This->singletons, i);
-                       for(uint j=0;j<getSizeLitVector(&expr->singletons);j++) {
-                               Literal lExpr=getLiteralLitVector(&expr->singletons, j);
-                               if (lThis==lExpr) {
-                                       //We have a singleton still in the final result
-                                       setLiteralLitVector(&This->singletons, singleIndex++, lThis);
-                               } else if (lThis!=-lExpr) {
-                                       LitVector *mergeLV=allocLitVector();
-                                       addLiteralLitVector(mergeLV, lThis);
-                                       addLiteralLitVector(mergeLV, lExpr);
-                                       mergeArray[mergeIndex++]=mergeLV;
-                               }
+       for (uint i = 0; i < getSizeLitVector(&This->singletons); i++) {
+               Literal lThis = getLiteralLitVector(&This->singletons, i);
+               for (uint j = 0; j < getSizeLitVector(&expr->singletons); j++) {
+                       Literal lExpr = getLiteralLitVector(&expr->singletons, j);
+                       if (lThis == lExpr) {
+                               //We have a singleton still in the final result
+                               setLiteralLitVector(&This->singletons, singleIndex++, lThis);
+                       } else if (lThis != -lExpr) {
+                               LitVector *mergeLV = allocLitVector();
+                               addLiteralLitVector(mergeLV, lThis);
+                               addLiteralLitVector(mergeLV, lExpr);
+                               mergeArray[mergeIndex++] = mergeLV;
                        }
                        }
+               }
        }
        }
-       
+
        ourfree(This->clauses.array);
        setSizeLitVector(&This->singletons, singleIndex);
        ourfree(This->clauses.array);
        setSizeLitVector(&This->singletons, singleIndex);
-       This->clauses.capacity=newCapacity;
-       This->clauses.array=mergeArray;
-       This->clauses.size=mergeIndex;
+       This->clauses.capacity = newCapacity;
+       This->clauses.array = mergeArray;
+       This->clauses.size = mergeIndex;
        if (destroy)
                deleteCNFExpr(expr);
 }
 
 void printCNFExpr(CNFExpr *This) {
        if (destroy)
                deleteCNFExpr(expr);
 }
 
 void printCNFExpr(CNFExpr *This) {
-       for(uint i=0;i<getSizeLitVector(&This->singletons);i++) {
-               if (i!=0)
+       for (uint i = 0; i < getSizeLitVector(&This->singletons); i++) {
+               if (i != 0)
                        printf(" ^ ");
                        printf(" ^ ");
-               Literal l=getLiteralLitVector(&This->singletons,i);
+               Literal l = getLiteralLitVector(&This->singletons,i);
                printf ("%d",l);
        }
                printf ("%d",l);
        }
-       for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
-               LitVector *lv=getVectorLitVector(&This->clauses,i);
+       for (uint i = 0; i < getSizeVectorLitVector(&This->clauses); i++) {
+               LitVector *lv = getVectorLitVector(&This->clauses,i);
                printf(" ^ (");
                printf(" ^ (");
-               for(uint j=0;j<getSizeLitVector(lv);j++) {
-                       if (j!=0)
+               for (uint j = 0; j < getSizeLitVector(lv); j++) {
+                       if (j != 0)
                                printf(" v ");
                        printf("%d", getLiteralLitVector(lv, j));
                }
                                printf(" v ");
                        printf("%d", getLiteralLitVector(lv, j));
                }
index 1b64528d87b787ccc5e8f1f3a0bfba9108ffd34e..0b832c19ef738201a8e32da3ee2c9e348cf808c7 100644 (file)
@@ -24,7 +24,7 @@ struct CNFExpr {
 
 typedef struct CNFExpr CNFExpr;
 
 
 typedef struct CNFExpr CNFExpr;
 
-LitVector * allocLitVector();
+LitVector *allocLitVector();
 void initLitVector(LitVector *This);
 void clearLitVector(LitVector *This);
 void freeLitVector(LitVector *This);
 void initLitVector(LitVector *This);
 void clearLitVector(LitVector *This);
 void freeLitVector(LitVector *This);
@@ -33,23 +33,23 @@ void deleteLitVector(LitVector *This);
 void addLiteralLitVector(LitVector *This, Literal l);
 Literal getLiteralLitVector(LitVector *This, uint index);
 void setLiteralLitVector(LitVector *This, uint index, Literal l);
 void addLiteralLitVector(LitVector *This, Literal l);
 Literal getLiteralLitVector(LitVector *This, uint index);
 void setLiteralLitVector(LitVector *This, uint index, Literal l);
-LitVector * mergeLitVectorLiteral(LitVector *This, Literal l);
-LitVector * mergeLitVectors(LitVector *This, LitVector *expr);
+LitVector *mergeLitVectorLiteral(LitVector *This, Literal l);
+LitVector *mergeLitVectors(LitVector *This, LitVector *expr);
 
 static inline uint getSizeLitVector(LitVector *This) {return This->size;}
 
 static inline uint getSizeLitVector(LitVector *This) {return This->size;}
-static inline void setSizeLitVector(LitVector *This, uint size) {This->size=size;}
+static inline void setSizeLitVector(LitVector *This, uint size) {This->size = size;}
 
 
-CNFExpr * allocCNFExprBool(bool isTrue);
-CNFExpr * allocCNFExprLiteral(Literal l);
+CNFExpr *allocCNFExprBool(bool isTrue);
+CNFExpr *allocCNFExprLiteral(Literal l);
 void deleteCNFExpr(CNFExpr *This);
 void clearCNFExpr(CNFExpr *This, bool isTrue);
 void printCNFExpr(CNFExpr *This);
 
 void copyCNF(CNFExpr *This, CNFExpr *expr, bool destroy);
 void deleteCNFExpr(CNFExpr *This);
 void clearCNFExpr(CNFExpr *This, bool isTrue);
 void printCNFExpr(CNFExpr *This);
 
 void copyCNF(CNFExpr *This, CNFExpr *expr, bool destroy);
-static inline bool alwaysTrueCNF(CNFExpr * This) {return (This->litSize==0) && This->isTrue;}
-static inline bool alwaysFalseCNF(CNFExpr * This) {return (This->litSize==0) && !This->isTrue;}
-static inline uint getLitSizeCNF(CNFExpr * This) {return This->litSize;}
-static inline uint getClauseSizeCNF(CNFExpr * This) {return getSizeLitVector(&This->singletons) + getSizeVectorLitVector(&This->clauses);}
+static inline bool alwaysTrueCNF(CNFExpr *This) {return (This->litSize == 0) && This->isTrue;}
+static inline bool alwaysFalseCNF(CNFExpr *This) {return (This->litSize == 0) && !This->isTrue;}
+static inline uint getLitSizeCNF(CNFExpr *This) {return This->litSize;}
+static inline uint getClauseSizeCNF(CNFExpr *This) {return getSizeLitVector(&This->singletons) + getSizeVectorLitVector(&This->clauses);}
 void conjoinCNFLit(CNFExpr *This, Literal l);
 void disjoinCNFLit(CNFExpr *This, Literal l);
 void disjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy);
 void conjoinCNFLit(CNFExpr *This, Literal l);
 void disjoinCNFLit(CNFExpr *This, Literal l);
 void disjoinCNFExpr(CNFExpr *This, CNFExpr *expr, bool destroy);
index 92a47fd22b03c9c40fd2838bfbae96fceff039e4..62c3c81b6c603b8534a4e11d565f72f0f8658e17 100644 (file)
 #include "inc_solver.h"
 #include "cnfexpr.h"
 #include "common.h"
 #include "inc_solver.h"
 #include "cnfexpr.h"
 #include "common.h"
-/* 
-V2 Copyright (c) 2014 Ben Chambers, Eugene Goldberg, Pete Manolios,
-Vasilis Papavasileiou, Sudarshan Srinivasan, and Daron Vroon.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.  If
-you download or use the software, send email to Pete Manolios
-(pete@ccs.neu.edu) with your name, contact information, and a short
-note describing what you want to use BAT for.  For any reuse or
-distribution, you must make clear to others the license terms of this
-work.
-
-Contact Pete Manolios if you want any of these conditions waived.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-/* 
-C port of CNF SAT Conversion Copyright Brian Demsky 2017. 
-*/
+/*
+   V2 Copyright (c) 2014 Ben Chambers, Eugene Goldberg, Pete Manolios,
+   Vasilis Papavasileiou, Sudarshan Srinivasan, and Daron Vroon.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   "Software"), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.  If
+   you download or use the software, send email to Pete Manolios
+   (pete@ccs.neu.edu) with your name, contact information, and a short
+   note describing what you want to use BAT for.  For any reuse or
+   distribution, you must make clear to others the license terms of this
+   work.
+
+   Contact Pete Manolios if you want any of these conditions waived.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+   C port of CNF SAT Conversion Copyright Brian Demsky 2017.
+ */
 
 
 VectorImpl(Edge, Edge, 16)
 
 
 VectorImpl(Edge, Edge, 16)
-Edge E_True={(Node *)(uintptr_t) EDGE_IS_VAR_CONSTANT};
-Edge E_False={(Node *)(uintptr_t) (EDGE_IS_VAR_CONSTANT | NEGATE_EDGE)};
-Edge E_BOGUS={(Node *)0x12345673};
-Edge E_NULL={(Node *)NULL};
-
-
-CNF * createCNF() {
-       CNF * cnf=ourmalloc(sizeof(CNF));
-       cnf->varcount=1;
-       cnf->capacity=DEFAULT_CNF_ARRAY_SIZE;
-       cnf->mask=cnf->capacity-1;
-       cnf->node_array=ourcalloc(1, sizeof(Node *)*cnf->capacity);
-       cnf->size=0;
-       cnf->maxsize=(uint)(((double)cnf->capacity)*LOAD_FACTOR);
-       cnf->enableMatching=true;
-       initDefVectorEdge(& cnf->constraints);
-       initDefVectorEdge(& cnf->args);
-       cnf->solver=allocIncrementalSolver();
+Edge E_True = {(Node *)(uintptr_t) EDGE_IS_VAR_CONSTANT};
+Edge E_False = {(Node *)(uintptr_t) (EDGE_IS_VAR_CONSTANT | NEGATE_EDGE)};
+Edge E_BOGUS = {(Node *)0x12345673};
+Edge E_NULL = {(Node *)NULL};
+
+
+CNF *createCNF() {
+       CNF *cnf = ourmalloc(sizeof(CNF));
+       cnf->varcount = 1;
+       cnf->capacity = DEFAULT_CNF_ARRAY_SIZE;
+       cnf->mask = cnf->capacity - 1;
+       cnf->node_array = ourcalloc(1, sizeof(Node *) * cnf->capacity);
+       cnf->size = 0;
+       cnf->maxsize = (uint)(((double)cnf->capacity) * LOAD_FACTOR);
+       cnf->enableMatching = true;
+       initDefVectorEdge(&cnf->constraints);
+       initDefVectorEdge(&cnf->args);
+       cnf->solver = allocIncrementalSolver();
        return cnf;
 }
 
        return cnf;
 }
 
-void deleteCNF(CNF * cnf) {
-       for(uint i=0;i<cnf->capacity;i++) {
-               Node *n=cnf->node_array[i];
-               if (n!=NULL)
+void deleteCNF(CNF *cnf) {
+       for (uint i = 0; i < cnf->capacity; i++) {
+               Node *n = cnf->node_array[i];
+               if (n != NULL)
                        ourfree(n);
        }
                        ourfree(n);
        }
-       deleteVectorArrayEdge(& cnf->constraints);
-       deleteVectorArrayEdge(& cnf->args);
+       deleteVectorArrayEdge(&cnf->constraints);
+       deleteVectorArrayEdge(&cnf->args);
        deleteIncrementalSolver(cnf->solver);
        ourfree(cnf->node_array);
        ourfree(cnf);
 }
 
 void resizeCNF(CNF *cnf, uint newCapacity) {
        deleteIncrementalSolver(cnf->solver);
        ourfree(cnf->node_array);
        ourfree(cnf);
 }
 
 void resizeCNF(CNF *cnf, uint newCapacity) {
-       Node **old_array=cnf->node_array;
-       Node **new_array=ourcalloc(1, sizeof(Node *)*newCapacity);
-       uint oldCapacity=cnf->capacity;
-       uint newMask=newCapacity-1;
-       for(uint i=0;i<oldCapacity;i++) {
-               Node *n=old_array[i];
-               uint hashCode=n->hashCode;
-               uint newindex=hashCode & newMask;
-               for(;;newindex=(newindex+1) & newMask) {
+       Node **old_array = cnf->node_array;
+       Node **new_array = ourcalloc(1, sizeof(Node *) * newCapacity);
+       uint oldCapacity = cnf->capacity;
+       uint newMask = newCapacity - 1;
+       for (uint i = 0; i < oldCapacity; i++) {
+               Node *n = old_array[i];
+               uint hashCode = n->hashCode;
+               uint newindex = hashCode & newMask;
+               for (;; newindex = (newindex + 1) & newMask) {
                        if (new_array[newindex] == NULL) {
                        if (new_array[newindex] == NULL) {
-                               new_array[newindex]=n;
+                               new_array[newindex] = n;
                                break;
                        }
                }
        }
        ourfree(old_array);
                                break;
                        }
                }
        }
        ourfree(old_array);
-       cnf->node_array=new_array;
-       cnf->capacity=newCapacity;
-       cnf->maxsize=(uint)(((double)cnf->capacity)*LOAD_FACTOR);
-       cnf->mask=newMask;
-}
-
-Node * allocNode(NodeType type, uint numEdges, Edge * edges, uint hashcode) {
-       Node *n=(Node *)ourmalloc(sizeof(Node)+sizeof(Edge)*numEdges);
-       memcpy(n->edges, edges, sizeof(Edge)*numEdges);
-       n->flags.type=type;
-       n->flags.wasExpanded=0;
-       n->flags.cnfVisitedDown=0;
-       n->flags.cnfVisitedUp=0;
-       n->flags.varForced=0;
-       n->numEdges=numEdges;
-       n->hashCode=hashcode;
-       n->intAnnot[0]=0;n->intAnnot[1]=0;
-       n->ptrAnnot[0]=NULL;n->ptrAnnot[1]=NULL;
+       cnf->node_array = new_array;
+       cnf->capacity = newCapacity;
+       cnf->maxsize = (uint)(((double)cnf->capacity) * LOAD_FACTOR);
+       cnf->mask = newMask;
+}
+
+Node *allocNode(NodeType type, uint numEdges, Edge *edges, uint hashcode) {
+       Node *n = (Node *)ourmalloc(sizeof(Node) + sizeof(Edge) * numEdges);
+       memcpy(n->edges, edges, sizeof(Edge) * numEdges);
+       n->flags.type = type;
+       n->flags.wasExpanded = 0;
+       n->flags.cnfVisitedDown = 0;
+       n->flags.cnfVisitedUp = 0;
+       n->flags.varForced = 0;
+       n->numEdges = numEdges;
+       n->hashCode = hashcode;
+       n->intAnnot[0] = 0;n->intAnnot[1] = 0;
+       n->ptrAnnot[0] = NULL;n->ptrAnnot[1] = NULL;
        return n;
 }
 
        return n;
 }
 
-Edge createNode(CNF *cnf, NodeType type, uint numEdges, Edge * edges) {
+Edge createNode(CNF *cnf, NodeType type, uint numEdges, Edge *edges) {
        if (cnf->size > cnf->maxsize) {
                resizeCNF(cnf, cnf->capacity << 1);
        }
        if (cnf->size > cnf->maxsize) {
                resizeCNF(cnf, cnf->capacity << 1);
        }
-       uint hashvalue=hashNode(type, numEdges, edges);
-       uint mask=cnf->mask;
-       uint index=hashvalue & mask;
+       uint hashvalue = hashNode(type, numEdges, edges);
+       uint mask = cnf->mask;
+       uint index = hashvalue & mask;
        Node **n_ptr;
        Node **n_ptr;
-       for(;;index=(index+1)&mask) {
-               n_ptr=&cnf->node_array[index];
-               if (*n_ptr!=NULL) {
-                       if ((*n_ptr)->hashCode==hashvalue) {
+       for (;; index = (index + 1) & mask) {
+               n_ptr = &cnf->node_array[index];
+               if (*n_ptr != NULL) {
+                       if ((*n_ptr)->hashCode == hashvalue) {
                                if (compareNodes(*n_ptr, type, numEdges, edges)) {
                                if (compareNodes(*n_ptr, type, numEdges, edges)) {
-                                       Edge e={*n_ptr};
+                                       Edge e = {*n_ptr};
                                        return e;
                                }
                        }
                                        return e;
                                }
                        }
@@ -134,60 +134,60 @@ Edge createNode(CNF *cnf, NodeType type, uint numEdges, Edge * edges) {
                        break;
                }
        }
                        break;
                }
        }
-       *n_ptr=allocNode(type, numEdges, edges, hashvalue);
-       Edge e={*n_ptr};
+       *n_ptr = allocNode(type, numEdges, edges, hashvalue);
+       Edge e = {*n_ptr};
        return e;
 }
 
        return e;
 }
 
-uint hashNode(NodeType type, uint numEdges, Edge * edges) {
-       uint hashvalue=type ^ numEdges;
-       for(uint i=0;i<numEdges;i++) {
+uint hashNode(NodeType type, uint numEdges, Edge *edges) {
+       uint hashvalue = type ^ numEdges;
+       for (uint i = 0; i < numEdges; i++) {
                hashvalue ^= (uint) ((uintptr_t) edges[i].node_ptr);
                hashvalue ^= (uint) ((uintptr_t) edges[i].node_ptr);
-               hashvalue = (hashvalue << 3) | (hashvalue >> 29); //rotate left by 3 bits
+               hashvalue = (hashvalue << 3) | (hashvalue >> 29);       //rotate left by 3 bits
        }
        return (uint) hashvalue;
 }
 
        }
        return (uint) hashvalue;
 }
 
-bool compareNodes(Node * node, NodeType type, uint numEdges, Edge *edges) {
-       if (node->flags.type!=type || node->numEdges != numEdges)
+bool compareNodes(Node *node, NodeType type, uint numEdges, Edge *edges) {
+       if (node->flags.type != type || node->numEdges != numEdges)
                return false;
                return false;
-       Edge *nodeedges=node->edges;
-       for(uint i=0;i<numEdges;i++) {
+       Edge *nodeedges = node->edges;
+       for (uint i = 0; i < numEdges; i++) {
                if (!equalsEdge(nodeedges[i], edges[i]))
                        return false;
        }
        return true;
 }
 
                if (!equalsEdge(nodeedges[i], edges[i]))
                        return false;
        }
        return true;
 }
 
-Edge constraintOR(CNF * cnf, uint numEdges, Edge *edges) {
+Edge constraintOR(CNF *cnf, uint numEdges, Edge *edges) {
        Edge edgearray[numEdges];
        Edge edgearray[numEdges];
-       
-       for(uint i=0; i<numEdges; i++) {
-               edgearray[i]=constraintNegate(edges[i]);
+
+       for (uint i = 0; i < numEdges; i++) {
+               edgearray[i] = constraintNegate(edges[i]);
        }
        }
-       Edge eand=constraintAND(cnf, numEdges, edgearray);
+       Edge eand = constraintAND(cnf, numEdges, edgearray);
        return constraintNegate(eand);
 }
 
        return constraintNegate(eand);
 }
 
-Edge constraintOR2(CNF * cnf, Edge left, Edge right) {
-       Edge lneg=constraintNegate(left);
-       Edge rneg=constraintNegate(right);
-       Edge eand=constraintAND2(cnf, lneg, rneg);
+Edge constraintOR2(CNF *cnf, Edge left, Edge right) {
+       Edge lneg = constraintNegate(left);
+       Edge rneg = constraintNegate(right);
+       Edge eand = constraintAND2(cnf, lneg, rneg);
        return constraintNegate(eand);
 }
 
        return constraintNegate(eand);
 }
 
-int comparefunction(const Edge * e1, const Edge * e2) {
-       return ((uintptr_t)e1->node_ptr)-((uintptr_t)e2->node_ptr);
+int comparefunction(const Edge *e1, const Edge *e2) {
+       return ((uintptr_t)e1->node_ptr) - ((uintptr_t)e2->node_ptr);
 }
 
 }
 
-Edge constraintAND(CNF * cnf, uint numEdges, Edge * edges) {
-       ASSERT(numEdges!=0);
-       qsort(edges, numEdges, sizeof(Edge), (int (*)(const void *, const void *)) comparefunction);
-       int initindex=0;
-       while(initindex<numEdges && equalsEdge(edges[initindex], E_True))
+Edge constraintAND(CNF *cnf, uint numEdges, Edge *edges) {
+       ASSERT(numEdges != 0);
+       qsort(edges, numEdges, sizeof(Edge), (int (*)(const void *, const void *))comparefunction);
+       int initindex = 0;
+       while (initindex < numEdges && equalsEdge(edges[initindex], E_True))
                initindex++;
 
                initindex++;
 
-       uint remainSize=numEdges-initindex;
+       uint remainSize = numEdges - initindex;
 
        if (remainSize == 0)
                return E_True;
 
        if (remainSize == 0)
                return E_True;
@@ -197,32 +197,32 @@ Edge constraintAND(CNF * cnf, uint numEdges, Edge * edges) {
                return E_False;
 
        /** De-duplicate array */
                return E_False;
 
        /** De-duplicate array */
-       uint lowindex=0;
-       edges[lowindex]=edges[initindex++];
+       uint lowindex = 0;
+       edges[lowindex] = edges[initindex++];
 
 
-       for(;initindex<numEdges;initindex++) {
-               Edge e1=edges[lowindex];
-               Edge e2=edges[initindex];
+       for (; initindex < numEdges; initindex++) {
+               Edge e1 = edges[lowindex];
+               Edge e2 = edges[initindex];
                if (sameNodeVarEdge(e1, e2)) {
                        if (!sameSignEdge(e1, e2)) {
                                return E_False;
                        }
                } else
                if (sameNodeVarEdge(e1, e2)) {
                        if (!sameSignEdge(e1, e2)) {
                                return E_False;
                        }
                } else
-                       edges[++lowindex]=edges[initindex];
+                       edges[++lowindex] = edges[initindex];
        }
        }
-       lowindex++; //Make lowindex look like size
+       lowindex++;     //Make lowindex look like size
 
 
-       if (lowindex==1)
+       if (lowindex == 1)
                return edges[0];
 
                return edges[0];
 
-       if (cnf->enableMatching && lowindex==2 &&
+       if (cnf->enableMatching && lowindex == 2 &&
                        isNegNodeEdge(edges[0]) && isNegNodeEdge(edges[1]) &&
                        getNodeType(edges[0]) == NodeType_AND &&
                        getNodeType(edges[1]) == NodeType_AND &&
                        getNodeSize(edges[0]) == 2 &&
                        getNodeSize(edges[1]) == 2) {
                        isNegNodeEdge(edges[0]) && isNegNodeEdge(edges[1]) &&
                        getNodeType(edges[0]) == NodeType_AND &&
                        getNodeType(edges[1]) == NodeType_AND &&
                        getNodeSize(edges[0]) == 2 &&
                        getNodeSize(edges[1]) == 2) {
-               Edge * e0edges=getEdgeArray(edges[0]);
-               Edge * e1edges=getEdgeArray(edges[1]);
+               Edge *e0edges = getEdgeArray(edges[0]);
+               Edge *e1edges = getEdgeArray(edges[1]);
                if (sameNodeOppSign(e0edges[0], e1edges[0])) {
                        return constraintNegate(constraintITE(cnf, e0edges[0], e0edges[1], e1edges[1]));
                } else if (sameNodeOppSign(e0edges[0], e1edges[1])) {
                if (sameNodeOppSign(e0edges[0], e1edges[0])) {
                        return constraintNegate(constraintITE(cnf, e0edges[0], e0edges[1], e1edges[1]));
                } else if (sameNodeOppSign(e0edges[0], e1edges[1])) {
@@ -237,76 +237,76 @@ Edge constraintAND(CNF * cnf, uint numEdges, Edge * edges) {
        return createNode(cnf, NodeType_AND, lowindex, edges);
 }
 
        return createNode(cnf, NodeType_AND, lowindex, edges);
 }
 
-Edge constraintAND2(CNF * cnf, Edge left, Edge right) {
-       Edge edges[2]={left, right};
+Edge constraintAND2(CNF *cnf, Edge left, Edge right) {
+       Edge edges[2] = {left, right};
        return constraintAND(cnf, 2, edges);
 }
 
        return constraintAND(cnf, 2, edges);
 }
 
-Edge constraintIMPLIES(CNF * cnf, Edge left, Edge right) {
+Edge constraintIMPLIES(CNF *cnf, Edge left, Edge right) {
        Edge array[2];
        Edge array[2];
-       array[0]=left;
-       array[1]=constraintNegate(right);
-       Edge eand=constraintAND(cnf, 2, array);
+       array[0] = left;
+       array[1] = constraintNegate(right);
+       Edge eand = constraintAND(cnf, 2, array);
        return constraintNegate(eand);
 }
 
        return constraintNegate(eand);
 }
 
-Edge constraintIFF(CNF * cnf, Edge left, Edge right) {
-       bool negate=!sameSignEdge(left, right);
-       Edge lpos=getNonNeg(left);
-       Edge rpos=getNonNeg(right);
+Edge constraintIFF(CNF *cnf, Edge left, Edge right) {
+       bool negate = !sameSignEdge(left, right);
+       Edge lpos = getNonNeg(left);
+       Edge rpos = getNonNeg(right);
 
        Edge e;
        if (equalsEdge(lpos, rpos)) {
 
        Edge e;
        if (equalsEdge(lpos, rpos)) {
-               e=E_True;
+               e = E_True;
        } else if (ltEdge(lpos, rpos)) {
        } else if (ltEdge(lpos, rpos)) {
-               Edge edges[]={lpos, rpos};
-               e=(edgeIsConst(lpos)) ? rpos : createNode(cnf, NodeType_IFF, 2, edges);
+               Edge edges[] = {lpos, rpos};
+               e = (edgeIsConst(lpos)) ? rpos : createNode(cnf, NodeType_IFF, 2, edges);
        } else {
        } else {
-               Edge edges[]={rpos, lpos};
-               e=(edgeIsConst(rpos)) ? lpos : createNode(cnf, NodeType_IFF, 2, edges);
+               Edge edges[] = {rpos, lpos};
+               e = (edgeIsConst(rpos)) ? lpos : createNode(cnf, NodeType_IFF, 2, edges);
        }
        if (negate)
        }
        if (negate)
-               e=constraintNegate(e);
+               e = constraintNegate(e);
        return e;
 }
 
        return e;
 }
 
-Edge constraintITE(CNF * cnf, Edge cond, Edge thenedge, Edge elseedge) {
+Edge constraintITE(CNF *cnf, Edge cond, Edge thenedge, Edge elseedge) {
        if (isNegEdge(cond)) {
        if (isNegEdge(cond)) {
-               cond=constraintNegate(cond);
-               Edge tmp=thenedge;
-               thenedge=elseedge;
-               elseedge=tmp;
+               cond = constraintNegate(cond);
+               Edge tmp = thenedge;
+               thenedge = elseedge;
+               elseedge = tmp;
        }
        }
-       
+
        bool negate = isNegEdge(thenedge);
        if (negate) {
        bool negate = isNegEdge(thenedge);
        if (negate) {
-               thenedge=constraintNegate(thenedge);
-               elseedge=constraintNegate(elseedge);
+               thenedge = constraintNegate(thenedge);
+               elseedge = constraintNegate(elseedge);
        }
 
        Edge result;
        if (equalsEdge(cond, E_True)) {
        }
 
        Edge result;
        if (equalsEdge(cond, E_True)) {
-               result=thenedge;
+               result = thenedge;
        } else if (equalsEdge(thenedge, E_True) || equalsEdge(cond, thenedge)) {
        } else if (equalsEdge(thenedge, E_True) || equalsEdge(cond, thenedge)) {
-               result=constraintOR(cnf,  2, (Edge[]) {cond, elseedge});
-       }       else if (equalsEdge(elseedge, E_True) || sameNodeOppSign(cond, elseedge)) {
-               result=constraintIMPLIES(cnf, cond, thenedge);
+               result = constraintOR(cnf,  2, (Edge[]) {cond, elseedge});
+       } else if (equalsEdge(elseedge, E_True) || sameNodeOppSign(cond, elseedge)) {
+               result = constraintIMPLIES(cnf, cond, thenedge);
        } else if (equalsEdge(thenedge, E_False) || equalsEdge(cond, elseedge)) {
        } else if (equalsEdge(thenedge, E_False) || equalsEdge(cond, elseedge)) {
-               result=constraintAND(cnf, 2, (Edge[]) {cond, thenedge});
+               result = constraintAND(cnf, 2, (Edge[]) {cond, thenedge});
        } else if (equalsEdge(thenedge, elseedge)) {
        } else if (equalsEdge(thenedge, elseedge)) {
-               result=thenedge;
+               result = thenedge;
        } else if (sameNodeOppSign(thenedge, elseedge)) {
                if (ltEdge(cond, thenedge)) {
        } else if (sameNodeOppSign(thenedge, elseedge)) {
                if (ltEdge(cond, thenedge)) {
-                       result=createNode(cnf, NodeType_IFF, 2, (Edge[]) {cond, thenedge});
+                       result = createNode(cnf, NodeType_IFF, 2, (Edge[]) {cond, thenedge});
                } else {
                } else {
-                       result=createNode(cnf, NodeType_IFF, 2, (Edge[]) {thenedge, cond});
+                       result = createNode(cnf, NodeType_IFF, 2, (Edge[]) {thenedge, cond});
                }
        } else {
                }
        } else {
-               Edge edges[]={cond, thenedge, elseedge};
-               result=createNode(cnf, NodeType_ITE, 3, edges);
+               Edge edges[] = {cond, thenedge, elseedge};
+               result = createNode(cnf, NodeType_ITE, 3, edges);
        }
        if (negate)
        }
        if (negate)
-               result=constraintNegate(result);
+               result = constraintNegate(result);
        return result;
 }
 
        return result;
 }
 
@@ -318,8 +318,8 @@ void addConstraintCNF(CNF *cnf, Edge constraint) {
 }
 
 Edge constraintNewVar(CNF *cnf) {
 }
 
 Edge constraintNewVar(CNF *cnf) {
-       uint varnum=cnf->varcount++;
-       Edge e={(Node *) ((((uintptr_t)varnum) << VAR_SHIFT) | EDGE_IS_VAR_CONSTANT) };
+       uint varnum = cnf->varcount++;
+       Edge e = {(Node *) ((((uintptr_t)varnum) << VAR_SHIFT) | EDGE_IS_VAR_CONSTANT) };
        return e;
 }
 
        return e;
 }
 
@@ -331,16 +331,16 @@ int solveCNF(CNF *cnf) {
 }
 
 bool getValueCNF(CNF *cnf, Edge var) {
 }
 
 bool getValueCNF(CNF *cnf, Edge var) {
-       Literal l=getEdgeVar(var);
-       bool isneg=(l<0);
-       l=abs(l);
+       Literal l = getEdgeVar(var);
+       bool isneg = (l < 0);
+       l = abs(l);
        return isneg ^ getValueSolver(cnf->solver, l);
 }
 
 void countPass(CNF *cnf) {
        return isneg ^ getValueSolver(cnf->solver, l);
 }
 
 void countPass(CNF *cnf) {
-       uint numConstraints=getSizeVectorEdge(&cnf->constraints);
-       VectorEdge *ve=allocDefVectorEdge();
-       for(uint i=0; i<numConstraints;i++) {
+       uint numConstraints = getSizeVectorEdge(&cnf->constraints);
+       VectorEdge *ve = allocDefVectorEdge();
+       for (uint i = 0; i < numConstraints; i++) {
                countConstraint(cnf, ve, getVectorEdge(&cnf->constraints, i));
        }
        deleteVectorEdge(ve);
                countConstraint(cnf, ve, getVectorEdge(&cnf->constraints, i));
        }
        deleteVectorEdge(ve);
@@ -353,16 +353,16 @@ void countConstraint(CNF *cnf, VectorEdge *stack, Edge eroot) {
 
        clearVectorEdge(stack);pushVectorEdge(stack, eroot);
 
 
        clearVectorEdge(stack);pushVectorEdge(stack, eroot);
 
-       bool isMatching=cnf->enableMatching;
-       
-       while(getSizeVectorEdge(stack) != 0) {
-               Edge e=lastVectorEdge(stack); popVectorEdge(stack);
-               bool polarity=isNegEdge(e);
-               Node *n=getNodePtrFromEdge(e);
+       bool isMatching = cnf->enableMatching;
+
+       while (getSizeVectorEdge(stack) != 0) {
+               Edge e = lastVectorEdge(stack); popVectorEdge(stack);
+               bool polarity = isNegEdge(e);
+               Node *n = getNodePtrFromEdge(e);
                if (getExpanded(n,  polarity)) {
                        if (n->flags.type == NodeType_IFF ||
                                        n->flags.type == NodeType_ITE) {
                if (getExpanded(n,  polarity)) {
                        if (n->flags.type == NodeType_IFF ||
                                        n->flags.type == NodeType_ITE) {
-                               Edge pExp={n->ptrAnnot[polarity]};
+                               Edge pExp = {n->ptrAnnot[polarity]};
                                getNodePtrFromEdge(pExp)->intAnnot[0]++;
                        } else {
                                n->intAnnot[polarity]++;
                                getNodePtrFromEdge(pExp)->intAnnot[0]++;
                        } else {
                                n->intAnnot[polarity]++;
@@ -370,39 +370,39 @@ void countConstraint(CNF *cnf, VectorEdge *stack, Edge eroot) {
                } else {
                        setExpanded(n, polarity);
 
                } else {
                        setExpanded(n, polarity);
 
-                       if (n->flags.type == NodeType_ITE||
+                       if (n->flags.type == NodeType_ITE ||
                                        n->flags.type == NodeType_IFF) {
                                        n->flags.type == NodeType_IFF) {
-                               n->intAnnot[polarity]=0;
-                               Edge cond=n->edges[0];
-                               Edge thenedge=n->edges[1];
-                               Edge elseedge=n->flags.type == NodeType_IFF? constraintNegate(thenedge): n->edges[2];
-                               thenedge=constraintNegateIf(thenedge, !polarity);
-                               elseedge=constraintNegateIf(elseedge, !polarity);
-                               thenedge=constraintAND2(cnf, cond, thenedge);
-                               cond=constraintNegate(cond);
-                               elseedge=constraintAND2(cnf, cond, elseedge);
-                               thenedge=constraintNegate(thenedge);
-                               elseedge=constraintNegate(elseedge);
-                               cnf->enableMatching=false;
-                               Edge succ1=constraintAND2(cnf, thenedge, elseedge);
-                               n->ptrAnnot[polarity]=succ1.node_ptr;
-                               cnf->enableMatching=isMatching;
+                               n->intAnnot[polarity] = 0;
+                               Edge cond = n->edges[0];
+                               Edge thenedge = n->edges[1];
+                               Edge elseedge = n->flags.type == NodeType_IFF ? constraintNegate(thenedge) : n->edges[2];
+                               thenedge = constraintNegateIf(thenedge, !polarity);
+                               elseedge = constraintNegateIf(elseedge, !polarity);
+                               thenedge = constraintAND2(cnf, cond, thenedge);
+                               cond = constraintNegate(cond);
+                               elseedge = constraintAND2(cnf, cond, elseedge);
+                               thenedge = constraintNegate(thenedge);
+                               elseedge = constraintNegate(elseedge);
+                               cnf->enableMatching = false;
+                               Edge succ1 = constraintAND2(cnf, thenedge, elseedge);
+                               n->ptrAnnot[polarity] = succ1.node_ptr;
+                               cnf->enableMatching = isMatching;
                                pushVectorEdge(stack, succ1);
                                if (getExpanded(n, !polarity)) {
                                pushVectorEdge(stack, succ1);
                                if (getExpanded(n, !polarity)) {
-                                       Edge succ2={(Node *)n->ptrAnnot[!polarity]};
-                                       Node *n1=getNodePtrFromEdge(succ1);
-                                       Node *n2=getNodePtrFromEdge(succ2);
-                                       n1->ptrAnnot[0]=succ2.node_ptr;
-                                       n2->ptrAnnot[0]=succ1.node_ptr;
-                                       n1->ptrAnnot[1]=succ2.node_ptr;
-                                       n2->ptrAnnot[1]=succ1.node_ptr;
-                               } 
+                                       Edge succ2 = {(Node *)n->ptrAnnot[!polarity]};
+                                       Node *n1 = getNodePtrFromEdge(succ1);
+                                       Node *n2 = getNodePtrFromEdge(succ2);
+                                       n1->ptrAnnot[0] = succ2.node_ptr;
+                                       n2->ptrAnnot[0] = succ1.node_ptr;
+                                       n1->ptrAnnot[1] = succ2.node_ptr;
+                                       n2->ptrAnnot[1] = succ1.node_ptr;
+                               }
                        } else {
                        } else {
-                               n->intAnnot[polarity]=1;
-                               for (uint i=0;i<n->numEdges;i++) {
-                                       Edge succ=n->edges[i];
-                                       if(!edgeIsVarConst(succ)) {
-                                               succ=constraintNegateIf(succ, polarity);
+                               n->intAnnot[polarity] = 1;
+                               for (uint i = 0; i < n->numEdges; i++) {
+                                       Edge succ = n->edges[i];
+                                       if (!edgeIsVarConst(succ)) {
+                                               succ = constraintNegateIf(succ, polarity);
                                                pushVectorEdge(stack, succ);
                                        }
                                }
                                                pushVectorEdge(stack, succ);
                                        }
                                }
@@ -412,17 +412,17 @@ void countConstraint(CNF *cnf, VectorEdge *stack, Edge eroot) {
 }
 
 void convertPass(CNF *cnf, bool backtrackLit) {
 }
 
 void convertPass(CNF *cnf, bool backtrackLit) {
-       uint numConstraints=getSizeVectorEdge(&cnf->constraints);
-       VectorEdge *ve=allocDefVectorEdge();
-       for(uint i=0; i<numConstraints;i++) {
+       uint numConstraints = getSizeVectorEdge(&cnf->constraints);
+       VectorEdge *ve = allocDefVectorEdge();
+       for (uint i = 0; i < numConstraints; i++) {
                convertConstraint(cnf, ve, getVectorEdge(&cnf->constraints, i), backtrackLit);
        }
        deleteVectorEdge(ve);
 }
 
 void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit) {
                convertConstraint(cnf, ve, getVectorEdge(&cnf->constraints, i), backtrackLit);
        }
        deleteVectorEdge(ve);
 }
 
 void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit) {
-       Node *nroot=getNodePtrFromEdge(root);
-       
+       Node *nroot = getNodePtrFromEdge(root);
+
        if (isNodeEdge(root) && (nroot->flags.type == NodeType_ITE || nroot->flags.type == NodeType_IFF)) {
                nroot = (Node *) nroot->ptrAnnot[isNegEdge(root)];
                root = (Edge) { nroot };
        if (isNodeEdge(root) && (nroot->flags.type == NodeType_ITE || nroot->flags.type == NodeType_IFF)) {
                nroot = (Node *) nroot->ptrAnnot[isNegEdge(root)];
                root = (Edge) { nroot };
@@ -430,11 +430,11 @@ void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit
        if (edgeIsConst(root)) {
                if (isNegEdge(root)) {
                        //trivally unsat
        if (edgeIsConst(root)) {
                if (isNegEdge(root)) {
                        //trivally unsat
-                       Edge newvar=constraintNewVar(cnf);
-                       Literal var=getEdgeVar(newvar);
+                       Edge newvar = constraintNewVar(cnf);
+                       Literal var = getEdgeVar(newvar);
                        Literal clause[] = {var};
                        addArrayClauseLiteral(cnf->solver, 1, clause);
                        Literal clause[] = {var};
                        addArrayClauseLiteral(cnf->solver, 1, clause);
-                       clause[0]=-var;
+                       clause[0] = -var;
                        addArrayClauseLiteral(cnf->solver, 1, clause);
                        return;
                } else {
                        addArrayClauseLiteral(cnf->solver, 1, clause);
                        return;
                } else {
@@ -446,21 +446,21 @@ void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit
                addArrayClauseLiteral(cnf->solver, 1, clause);
                return;
        }
                addArrayClauseLiteral(cnf->solver, 1, clause);
                return;
        }
-       
+
        clearVectorEdge(stack);pushVectorEdge(stack, root);
        clearVectorEdge(stack);pushVectorEdge(stack, root);
-       while(getSizeVectorEdge(stack)!=0) {
-               Edge e=lastVectorEdge(stack);
-               Node *n=getNodePtrFromEdge(e);
+       while (getSizeVectorEdge(stack) != 0) {
+               Edge e = lastVectorEdge(stack);
+               Node *n = getNodePtrFromEdge(e);
 
                if (edgeIsVarConst(e)) {
                        popVectorEdge(stack);
                        continue;
 
                if (edgeIsVarConst(e)) {
                        popVectorEdge(stack);
                        continue;
-               } else if (n->flags.type==NodeType_ITE ||
-                                                        n->flags.type==NodeType_IFF) {
+               } else if (n->flags.type == NodeType_ITE ||
+                                                        n->flags.type == NodeType_IFF) {
                        popVectorEdge(stack);
                        popVectorEdge(stack);
-                       if (n->ptrAnnot[0]!=NULL)
+                       if (n->ptrAnnot[0] != NULL)
                                pushVectorEdge(stack, (Edge) {(Node *)n->ptrAnnot[0]});
                                pushVectorEdge(stack, (Edge) {(Node *)n->ptrAnnot[0]});
-                       if (n->ptrAnnot[1]!=NULL)
+                       if (n->ptrAnnot[1] != NULL)
                                pushVectorEdge(stack, (Edge) {(Node *)n->ptrAnnot[1]});
                        continue;
                }
                                pushVectorEdge(stack, (Edge) {(Node *)n->ptrAnnot[1]});
                        continue;
                }
@@ -473,27 +473,27 @@ void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit
                } else if ((needPos && !(n->flags.cnfVisitedDown & 1)) ||
                                                         (needNeg && !(n->flags.cnfVisitedDown & 2))) {
                        if (needPos)
                } else if ((needPos && !(n->flags.cnfVisitedDown & 1)) ||
                                                         (needNeg && !(n->flags.cnfVisitedDown & 2))) {
                        if (needPos)
-                               n->flags.cnfVisitedDown|=1;
+                               n->flags.cnfVisitedDown |= 1;
                        if (needNeg)
                        if (needNeg)
-                               n->flags.cnfVisitedDown|=2;
-                       for(uint i=0; i<n->numEdges; i++) {
-                               Edge arg=n->edges[i];
-                               arg=constraintNegateIf(arg, isNegEdge(e));
-                               pushVectorEdge(stack, arg); //WARNING, THIS LOOKS LIKE A BUG IN THE ORIGINAL CODE
+                               n->flags.cnfVisitedDown |= 2;
+                       for (uint i = 0; i < n->numEdges; i++) {
+                               Edge arg = n->edges[i];
+                               arg = constraintNegateIf(arg, isNegEdge(e));
+                               pushVectorEdge(stack, arg);     //WARNING, THIS LOOKS LIKE A BUG IN THE ORIGINAL CODE
                        }
                } else {
                        popVectorEdge(stack);
                        produceCNF(cnf, e);
                }
        }
                        }
                } else {
                        popVectorEdge(stack);
                        produceCNF(cnf, e);
                }
        }
-       CNFExpr * cnfExp = (CNFExpr *) nroot->ptrAnnot[isNegEdge(root)];
-       ASSERT(cnfExp!=NULL);
+       CNFExpr *cnfExp = (CNFExpr *) nroot->ptrAnnot[isNegEdge(root)];
+       ASSERT(cnfExp != NULL);
        if (isProxy(cnfExp)) {
        if (isProxy(cnfExp)) {
-               Literal l=getProxy(cnfExp);
+               Literal l = getProxy(cnfExp);
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        } else if (backtrackLit) {
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        } else if (backtrackLit) {
-               Literal l=introProxy(cnf, root, cnfExp, isNegEdge(root));
+               Literal l = introProxy(cnf, root, cnfExp, isNegEdge(root));
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        } else {
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        } else {
@@ -507,30 +507,30 @@ void convertConstraint(CNF *cnf, VectorEdge *stack, Edge root, bool backtrackLit
 }
 
 
 }
 
 
-Literal introProxy(CNF * cnf, Edge e, CNFExpr* exp, bool isNeg) {
+Literal introProxy(CNF *cnf, Edge e, CNFExpr *exp, bool isNeg) {
        Literal l = 0;
        Literal l = 0;
-       Node * n = getNodePtrFromEdge(e);
-       
-       if (n->flags.cnfVisitedUp & (1<<!isNeg)) {
-               CNFExpr* otherExp = (CNFExpr*) n->ptrAnnot[!isNeg];
+       Node *n = getNodePtrFromEdge(e);
+
+       if (n->flags.cnfVisitedUp & (1 << !isNeg)) {
+               CNFExpr *otherExp = (CNFExpr *) n->ptrAnnot[!isNeg];
                if (isProxy(otherExp))
                        l = -getProxy(otherExp);
        } else {
                if (isProxy(otherExp))
                        l = -getProxy(otherExp);
        } else {
-               Edge semNeg={(Node *) n->ptrAnnot[isNeg]};
-               Node * nsemNeg=getNodePtrFromEdge(semNeg);
+               Edge semNeg = {(Node *) n->ptrAnnot[isNeg]};
+               Node *nsemNeg = getNodePtrFromEdge(semNeg);
                if (nsemNeg != NULL) {
                        if (nsemNeg->flags.cnfVisitedUp & (1 << isNeg)) {
                if (nsemNeg != NULL) {
                        if (nsemNeg->flags.cnfVisitedUp & (1 << isNeg)) {
-                               CNFExpr* otherExp = (CNFExpr*) nsemNeg->ptrAnnot[isNeg];
+                               CNFExpr *otherExp = (CNFExpr *) nsemNeg->ptrAnnot[isNeg];
                                if (isProxy(otherExp))
                                        l = -getProxy(otherExp);
                                if (isProxy(otherExp))
                                        l = -getProxy(otherExp);
-                       } else if (nsemNeg->flags.cnfVisitedUp & (1<< !isNeg)) {
-                               CNFExpr* otherExp = (CNFExpr*) nsemNeg->ptrAnnot[!isNeg];
+                       } else if (nsemNeg->flags.cnfVisitedUp & (1 << !isNeg)) {
+                               CNFExpr *otherExp = (CNFExpr *) nsemNeg->ptrAnnot[!isNeg];
                                if (isProxy(otherExp))
                                        l = getProxy(otherExp);
                        }
                }
        }
                                if (isProxy(otherExp))
                                        l = getProxy(otherExp);
                        }
                }
        }
-       
+
        if (l == 0) {
                Edge newvar = constraintNewVar(cnf);
                l = getEdgeVar(newvar);
        if (l == 0) {
                Edge newvar = constraintNewVar(cnf);
                l = getEdgeVar(newvar);
@@ -538,17 +538,17 @@ Literal introProxy(CNF * cnf, Edge e, CNFExpr* exp, bool isNeg) {
        // Output the constraints on the auxiliary variable
        constrainCNF(cnf, l, exp);
        deleteCNFExpr(exp);
        // Output the constraints on the auxiliary variable
        constrainCNF(cnf, l, exp);
        deleteCNFExpr(exp);
-  
-       n->ptrAnnot[isNeg] = (void*) ((intptr_t) (l << 1) | 1);
-       
+
+       n->ptrAnnot[isNeg] = (void *) ((intptr_t) (l << 1) | 1);
+
        return l;
 }
 
        return l;
 }
 
-void produceCNF(CNF * cnf, Edge e) {
-       CNFExprexpPos = NULL;
-       CNFExprexpNeg = NULL;
+void produceCNF(CNF *cnf, Edge e) {
+       CNFExpr *expPos = NULL;
+       CNFExpr *expNeg = NULL;
        Node *n = getNodePtrFromEdge(e);
        Node *n = getNodePtrFromEdge(e);
-       
+
        if (n->intAnnot[0] > 0) {
                expPos = produceConjunction(cnf, e);
        }
        if (n->intAnnot[0] > 0) {
                expPos = produceConjunction(cnf, e);
        }
@@ -564,11 +564,11 @@ void produceCNF(CNF * cnf, Edge e) {
        /// produced for them at the right point
        ///
        /// propagate(solver, expPos, snPos, false) || propagate(solver, expNeg, snNeg, false)
        /// produced for them at the right point
        ///
        /// propagate(solver, expPos, snPos, false) || propagate(solver, expNeg, snNeg, false)
-       
+
        // propagate from positive to negative, negative to positive
        // propagate from positive to negative, negative to positive
-       if (!propagate(cnf, & expPos, expNeg, true))
-               propagate(cnf, & expNeg, expPos, true);
-       
+       if (!propagate(cnf, &expPos, expNeg, true))
+               propagate(cnf, &expNeg, expPos, true);
+
        // The polarity heuristic entails visiting the discovery polarity first
        if (isPosEdge(e)) {
                saveCNF(cnf, expPos, e, false);
        // The polarity heuristic entails visiting the discovery polarity first
        if (isPosEdge(e)) {
                saveCNF(cnf, expPos, e, false);
@@ -579,7 +579,7 @@ void produceCNF(CNF * cnf, Edge e) {
        }
 }
 
        }
 }
 
-bool propagate(CNF *cnf, CNFExpr ** dest, CNFExpr * src, bool negate) {
+bool propagate(CNF *cnf, CNFExpr **dest, CNFExpr *src, bool negate) {
        if (src != NULL && !isProxy(src) && getLitSizeCNF(src) == 0) {
                if (*dest == NULL) {
                        *dest = allocCNFExprBool(negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
        if (src != NULL && !isProxy(src) && getLitSizeCNF(src) == 0) {
                if (*dest == NULL) {
                        *dest = allocCNFExprBool(negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
@@ -592,7 +592,7 @@ bool propagate(CNF *cnf, CNFExpr ** dest, CNFExpr * src, bool negate) {
                                Literal clause[] = {-getProxy(*dest)};
                                addArrayClauseLiteral(cnf->solver, 1, clause);
                        }
                                Literal clause[] = {-getProxy(*dest)};
                                addArrayClauseLiteral(cnf->solver, 1, clause);
                        }
-                       
+
                        *dest = allocCNFExprBool(negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
                } else {
                        clearCNFExpr(*dest, negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
                        *dest = allocCNFExprBool(negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
                } else {
                        clearCNFExpr(*dest, negate ? alwaysFalseCNF(src) : alwaysTrueCNF(src));
@@ -602,15 +602,15 @@ bool propagate(CNF *cnf, CNFExpr ** dest, CNFExpr * src, bool negate) {
        return false;
 }
 
        return false;
 }
 
-void saveCNF(CNF *cnf, CNFExprexp, Edge e, bool sign) {
-       Node *n=getNodePtrFromEdge(e);
+void saveCNF(CNF *cnf, CNFExpr *exp, Edge e, bool sign) {
+       Node *n = getNodePtrFromEdge(e);
        n->flags.cnfVisitedUp |= (1 << sign);
        if (exp == NULL || isProxy(exp)) return;
        n->flags.cnfVisitedUp |= (1 << sign);
        if (exp == NULL || isProxy(exp)) return;
-  
+
        if (exp->litSize == 1) {
                Literal l = getLiteralLitVector(&exp->singletons, 0);
                deleteCNFExpr(exp);
        if (exp->litSize == 1) {
                Literal l = getLiteralLitVector(&exp->singletons, 0);
                deleteCNFExpr(exp);
-               n->ptrAnnot[sign] = (void*) ((((intptr_t) l) << 1) | 1);
+               n->ptrAnnot[sign] = (void *) ((((intptr_t) l) << 1) | 1);
        } else if (exp->litSize != 0 && (n->intAnnot[sign] > 1 || n->flags.varForced)) {
                introProxy(cnf, e, exp, sign);
        } else {
        } else if (exp->litSize != 0 && (n->intAnnot[sign] > 1 || n->flags.varForced)) {
                introProxy(cnf, e, exp, sign);
        } else {
@@ -618,7 +618,7 @@ void saveCNF(CNF *cnf, CNFExpr* exp, Edge e, bool sign) {
        }
 }
 
        }
 }
 
-void constrainCNF(CNF * cnf, Literal lcond, CNFExpr *expr) {
+void constrainCNF(CNF *cnf, Literal lcond, CNFExpr *expr) {
        if (alwaysTrueCNF(expr)) {
                return;
        } else if (alwaysFalseCNF(expr)) {
        if (alwaysTrueCNF(expr)) {
                return;
        } else if (alwaysFalseCNF(expr)) {
@@ -626,85 +626,85 @@ void constrainCNF(CNF * cnf, Literal lcond, CNFExpr *expr) {
                addArrayClauseLiteral(cnf->solver, 1, clause);
                return;
        }
                addArrayClauseLiteral(cnf->solver, 1, clause);
                return;
        }
-       
-       for(uint i=0;i<getSizeLitVector(&expr->singletons);i++) {
-               Literal l=getLiteralLitVector(&expr->singletons,i);
+
+       for (uint i = 0; i < getSizeLitVector(&expr->singletons); i++) {
+               Literal l = getLiteralLitVector(&expr->singletons,i);
                Literal clause[] = {-lcond, l};
                addArrayClauseLiteral(cnf->solver, 2, clause);
        }
                Literal clause[] = {-lcond, l};
                addArrayClauseLiteral(cnf->solver, 2, clause);
        }
-       for(uint i=0;i<getSizeVectorLitVector(&expr->clauses);i++) {
-               LitVector *lv=getVectorLitVector(&expr->clauses,i);
-               addClauseLiteral(cnf->solver, -lcond); //Add first literal
-               addArrayClauseLiteral(cnf->solver, getSizeLitVector(lv), lv->literals); //Add rest
+       for (uint i = 0; i < getSizeVectorLitVector(&expr->clauses); i++) {
+               LitVector *lv = getVectorLitVector(&expr->clauses,i);
+               addClauseLiteral(cnf->solver, -lcond);//Add first literal
+               addArrayClauseLiteral(cnf->solver, getSizeLitVector(lv), lv->literals); //Add rest
        }
 }
 
 void outputCNF(CNF *cnf, CNFExpr *expr) {
        }
 }
 
 void outputCNF(CNF *cnf, CNFExpr *expr) {
-       for(uint i=0;i<getSizeLitVector(&expr->singletons);i++) {
-               Literal l=getLiteralLitVector(&expr->singletons,i);
+       for (uint i = 0; i < getSizeLitVector(&expr->singletons); i++) {
+               Literal l = getLiteralLitVector(&expr->singletons,i);
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        }
                Literal clause[] = {l};
                addArrayClauseLiteral(cnf->solver, 1, clause);
        }
-       for(uint i=0;i<getSizeVectorLitVector(&expr->clauses);i++) {
-               LitVector *lv=getVectorLitVector(&expr->clauses,i);
+       for (uint i = 0; i < getSizeVectorLitVector(&expr->clauses); i++) {
+               LitVector *lv = getVectorLitVector(&expr->clauses,i);
                addArrayClauseLiteral(cnf->solver, getSizeLitVector(lv), lv->literals);
        }
 }
 
                addArrayClauseLiteral(cnf->solver, getSizeLitVector(lv), lv->literals);
        }
 }
 
-CNFExpr* fillArgs(CNF *cnf, Edge e, bool isNeg, Edge * largestEdge) {
+CNFExpr *fillArgs(CNF *cnf, Edge e, bool isNeg, Edge *largestEdge) {
        clearVectorEdge(&cnf->args);
 
        clearVectorEdge(&cnf->args);
 
-       *largestEdge = (Edge) {(Node*) NULL};
-       CNFExprlargest = NULL;
-       Node *n=getNodePtrFromEdge(e);
+       *largestEdge = (Edge) {(Node *) NULL};
+       CNFExpr *largest = NULL;
+       Node *n = getNodePtrFromEdge(e);
        int i = n->numEdges;
        while (i != 0) {
                Edge arg = n->edges[--i];
        int i = n->numEdges;
        while (i != 0) {
                Edge arg = n->edges[--i];
-               arg=constraintNegateIf(arg, isNeg);
-               Node * narg = getNodePtrFromEdge(arg);
-               
+               arg = constraintNegateIf(arg, isNeg);
+               Node *narg = getNodePtrFromEdge(arg);
+
                if (edgeIsVarConst(arg)) {
                        pushVectorEdge(&cnf->args, arg);
                        continue;
                }
                if (edgeIsVarConst(arg)) {
                        pushVectorEdge(&cnf->args, arg);
                        continue;
                }
-               
+
                if (narg->flags.type == NodeType_ITE || narg->flags.type == NodeType_IFF) {
                        arg = (Edge) {(Node *) narg->ptrAnnot[isNegEdge(arg)]};
                }
                if (narg->flags.type == NodeType_ITE || narg->flags.type == NodeType_IFF) {
                        arg = (Edge) {(Node *) narg->ptrAnnot[isNegEdge(arg)]};
                }
-    
+
                if (narg->intAnnot[isNegEdge(arg)] == 1) {
                if (narg->intAnnot[isNegEdge(arg)] == 1) {
-                       CNFExpr* argExp = (CNFExpr*) narg->ptrAnnot[isNegEdge(arg)];
+                       CNFExpr *argExp = (CNFExpr *) narg->ptrAnnot[isNegEdge(arg)];
                        if (!isProxy(argExp)) {
                                if (largest == NULL) {
                                        largest = argExp;
                        if (!isProxy(argExp)) {
                                if (largest == NULL) {
                                        largest = argExp;
-                                       * largestEdge = arg;
+                                       *largestEdge = arg;
                                        continue;
                                } else if (argExp->litSize > largest->litSize) {
                                        pushVectorEdge(&cnf->args, *largestEdge);
                                        largest = argExp;
                                        continue;
                                } else if (argExp->litSize > largest->litSize) {
                                        pushVectorEdge(&cnf->args, *largestEdge);
                                        largest = argExp;
-                                       * largestEdge = arg;
+                                       *largestEdge = arg;
                                        continue;
                                }
                        }
                }
                pushVectorEdge(&cnf->args, arg);
        }
                                        continue;
                                }
                        }
                }
                pushVectorEdge(&cnf->args, arg);
        }
-       
+
        if (largest != NULL) {
        if (largest != NULL) {
-               Node *nlargestEdge=getNodePtrFromEdge(*largestEdge);
+               Node *nlargestEdge = getNodePtrFromEdge(*largestEdge);
                nlargestEdge->ptrAnnot[isNegEdge(*largestEdge)] = NULL;
        }
                nlargestEdge->ptrAnnot[isNegEdge(*largestEdge)] = NULL;
        }
-       
+
        return largest;
 }
 
 void printCNF(Edge e) {
        if (edgeIsVarConst(e)) {
        return largest;
 }
 
 void printCNF(Edge e) {
        if (edgeIsVarConst(e)) {
-               Literal l=getEdgeVar(e);
+               Literal l = getEdgeVar(e);
                model_print ("%d", l);
                return;
        }
                model_print ("%d", l);
                return;
        }
-       bool isNeg=isNegEdge(e);
+       bool isNeg = isNegEdge(e);
        if (edgeIsConst(e)) {
                if (isNeg)
                        model_print("T");
        if (edgeIsConst(e)) {
                if (isNeg)
                        model_print("T");
@@ -712,14 +712,14 @@ void printCNF(Edge e) {
                        model_print("F");
                return;
        }
                        model_print("F");
                return;
        }
-       Node *n=getNodePtrFromEdge(e);
+       Node *n = getNodePtrFromEdge(e);
        if (isNeg) {
                //Pretty print things that are equivalent to OR's
        if (isNeg) {
                //Pretty print things that are equivalent to OR's
-               if (getNodeType(e)==NodeType_AND) {
+               if (getNodeType(e) == NodeType_AND) {
                        model_print("or(");
                        model_print("or(");
-                       for(uint i=0;i<n->numEdges;i++) {
-                               Edge e=n->edges[i];
-                               if (i!=0)
+                       for (uint i = 0; i < n->numEdges; i++) {
+                               Edge e = n->edges[i];
+                               if (i != 0)
                                        model_print(" ");
                                printCNF(constraintNegate(e));
                        }
                                        model_print(" ");
                                printCNF(constraintNegate(e));
                        }
@@ -729,7 +729,7 @@ void printCNF(Edge e) {
 
                model_print("!");
        }
 
                model_print("!");
        }
-       switch(getNodeType(e)) {
+       switch (getNodeType(e)) {
        case NodeType_AND:
                model_print("and");
                break;
        case NodeType_AND:
                model_print("and");
                break;
@@ -741,33 +741,33 @@ void printCNF(Edge e) {
                break;
        }
        model_print("(");
                break;
        }
        model_print("(");
-       for(uint i=0;i<n->numEdges;i++) {
-               Edge e=n->edges[i];
-               if (i!=0)
+       for (uint i = 0; i < n->numEdges; i++) {
+               Edge e = n->edges[i];
+               if (i != 0)
                        model_print(" ");
                printCNF(e);
        }
        model_print(")");
 }
 
                        model_print(" ");
                printCNF(e);
        }
        model_print(")");
 }
 
-CNFExpr * produceConjunction(CNF * cnf, Edge e) {
+CNFExpr *produceConjunction(CNF *cnf, Edge e) {
        Edge largestEdge;
        Edge largestEdge;
-       
-       CNFExpraccum = fillArgs(cnf, e, false, &largestEdge);
+
+       CNFExpr *accum = fillArgs(cnf, e, false, &largestEdge);
        if (accum == NULL)
                accum = allocCNFExprBool(true);
        if (accum == NULL)
                accum = allocCNFExprBool(true);
-       
+
        int i = getSizeVectorEdge(&cnf->args);
        while (i != 0) {
                Edge arg = getVectorEdge(&cnf->args, --i);
                if (edgeIsVarConst(arg)) {
                        conjoinCNFLit(accum, getEdgeVar(arg));
                } else {
        int i = getSizeVectorEdge(&cnf->args);
        while (i != 0) {
                Edge arg = getVectorEdge(&cnf->args, --i);
                if (edgeIsVarConst(arg)) {
                        conjoinCNFLit(accum, getEdgeVar(arg));
                } else {
-                       Node *narg=getNodePtrFromEdge(arg);
-                       CNFExpr* argExp = (CNFExpr*) narg->ptrAnnot[isNegEdge(arg)];
-      
+                       Node *narg = getNodePtrFromEdge(arg);
+                       CNFExpr *argExp = (CNFExpr *) narg->ptrAnnot[isNegEdge(arg)];
+
                        bool destroy = (--narg->intAnnot[isNegEdge(arg)] == 0);
                        bool destroy = (--narg->intAnnot[isNegEdge(arg)] == 0);
-                       if (isProxy(argExp)) { // variable has been introduced
+                       if (isProxy(argExp)) {// variable has been introduced
                                conjoinCNFLit(accum, getProxy(argExp));
                        } else {
                                conjoinCNFExpr(accum, argExp, destroy);
                                conjoinCNFLit(accum, getProxy(argExp));
                        } else {
                                conjoinCNFExpr(accum, argExp, destroy);
@@ -776,53 +776,53 @@ CNFExpr * produceConjunction(CNF * cnf, Edge e) {
                        }
                }
        }
                        }
                }
        }
-       
+
        return accum;
 }
 
 #define CLAUSE_MAX 3
 
        return accum;
 }
 
 #define CLAUSE_MAX 3
 
-CNFExprproduceDisjunction(CNF *cnf, Edge e) {
+CNFExpr *produceDisjunction(CNF *cnf, Edge e) {
        Edge largestEdge;
        Edge largestEdge;
-       CNFExpraccum = fillArgs(cnf, e, true, &largestEdge);
+       CNFExpr *accum = fillArgs(cnf, e, true, &largestEdge);
        if (accum == NULL)
                accum = allocCNFExprBool(false);
        if (accum == NULL)
                accum = allocCNFExprBool(false);
-       
+
        // This is necessary to check to make sure that we don't start out
        // with an accumulator that is "too large".
        // This is necessary to check to make sure that we don't start out
        // with an accumulator that is "too large".
-       
+
        /// @todo Strictly speaking, introProxy doesn't *need* to free
        /// memory, then this wouldn't have to reallocate CNFExpr
        /// @todo Strictly speaking, introProxy doesn't *need* to free
        /// memory, then this wouldn't have to reallocate CNFExpr
-       
+
        /// @todo When this call to introProxy is made, the semantic
        /// negation pointer will have been destroyed.  Thus, it will not
        /// be possible to use the correct proxy.  That should be fixed.
        /// @todo When this call to introProxy is made, the semantic
        /// negation pointer will have been destroyed.  Thus, it will not
        /// be possible to use the correct proxy.  That should be fixed.
-       
+
        // at this point, we will either have NULL, or a destructible expression
        if (getClauseSizeCNF(accum) > CLAUSE_MAX)
                accum = allocCNFExprLiteral(introProxy(cnf, largestEdge, accum, isNegEdge(largestEdge)));
        // at this point, we will either have NULL, or a destructible expression
        if (getClauseSizeCNF(accum) > CLAUSE_MAX)
                accum = allocCNFExprLiteral(introProxy(cnf, largestEdge, accum, isNegEdge(largestEdge)));
-       
+
        int i = getSizeVectorEdge(&cnf->args);
        while (i != 0) {
        int i = getSizeVectorEdge(&cnf->args);
        while (i != 0) {
-               Edge arg=getVectorEdge(&cnf->args, --i);
-               Node *narg=getNodePtrFromEdge(arg);
+               Edge arg = getVectorEdge(&cnf->args, --i);
+               Node *narg = getNodePtrFromEdge(arg);
                if (edgeIsVarConst(arg)) {
                        disjoinCNFLit(accum, getEdgeVar(arg));
                } else {
                if (edgeIsVarConst(arg)) {
                        disjoinCNFLit(accum, getEdgeVar(arg));
                } else {
-                       CNFExpr* argExp = (CNFExpr*) narg->ptrAnnot[isNegEdge(arg)];
-                       
+                       CNFExpr *argExp = (CNFExpr *) narg->ptrAnnot[isNegEdge(arg)];
+
                        bool destroy = (--narg->intAnnot[isNegEdge(arg)] == 0);
                        bool destroy = (--narg->intAnnot[isNegEdge(arg)] == 0);
-                       if (isProxy(argExp)) { // variable has been introduced
+                       if (isProxy(argExp)) {// variable has been introduced
                                disjoinCNFLit(accum, getProxy(argExp));
                        } else if (argExp->litSize == 0) {
                                disjoinCNFExpr(accum, argExp, destroy);
                        } else {
                                // check to see if we should introduce a proxy
                                disjoinCNFLit(accum, getProxy(argExp));
                        } else if (argExp->litSize == 0) {
                                disjoinCNFExpr(accum, argExp, destroy);
                        } else {
                                // check to see if we should introduce a proxy
-                               int aL = accum->litSize;      // lits in accum
-                               int eL = argExp->litSize;     // lits in argument
-                               int aC = getClauseSizeCNF(accum);   // clauses in accum
-                               int eC = getClauseSizeCNF(argExp);  // clauses in argument
-                               
+                               int aL = accum->litSize;                        // lits in accum
+                               int eL = argExp->litSize;                       // lits in argument
+                               int aC = getClauseSizeCNF(accum);               // clauses in accum
+                               int eC = getClauseSizeCNF(argExp);      // clauses in argument
+
                                if (eC > CLAUSE_MAX || (eL * aC + aL * eC > eL + aC + aL + aC)) {
                                        disjoinCNFLit(accum, introProxy(cnf, arg, argExp, isNegEdge(arg)));
                                } else {
                                if (eC > CLAUSE_MAX || (eL * aC + aL * eC > eL + aC + aL + aC)) {
                                        disjoinCNFLit(accum, introProxy(cnf, arg, argExp, isNegEdge(arg)));
                                } else {
@@ -832,51 +832,51 @@ CNFExpr* produceDisjunction(CNF *cnf, Edge e) {
                        }
                }
        }
                        }
                }
        }
-  
+
        return accum;
 }
 
        return accum;
 }
 
-Edge generateBinaryConstraint(CNF *cnf, uint numvars, Edge * vars, uint value) {
+Edge generateBinaryConstraint(CNF *cnf, uint numvars, Edge *vars, uint value) {
        Edge carray[numvars];
        Edge carray[numvars];
-       for(uint j=0;j<numvars;j++) {
-               carray[j]=((value&1)==1) ? vars[j] : constraintNegate(vars[j]);
-               value=value>>1;
+       for (uint j = 0; j < numvars; j++) {
+               carray[j] = ((value & 1) == 1) ? vars[j] : constraintNegate(vars[j]);
+               value = value >> 1;
        }
        }
-       
+
        return constraintAND(cnf, numvars, carray);
 }
        return constraintAND(cnf, numvars, carray);
 }
+
 /** Generates a constraint to ensure that all encodings are less than value */
 /** Generates a constraint to ensure that all encodings are less than value */
-Edge generateLTConstraint(CNF *cnf, uint numvars, Edge * vars, uint value) {
+Edge generateLTConstraint(CNF *cnf, uint numvars, Edge *vars, uint value) {
        Edge orarray[numvars];
        Edge andarray[numvars];
        Edge orarray[numvars];
        Edge andarray[numvars];
-       uint andi=0;
-  
-       while(true) {
-               uint val=value;
-               uint ori=0;
-               for(uint j=0;j<numvars;j++) {
-                       if ((val&1)==1)
-                               orarray[ori++]=constraintNegate(vars[j]);
-                       val=val>>1;
+       uint andi = 0;
+
+       while (true) {
+               uint val = value;
+               uint ori = 0;
+               for (uint j = 0; j < numvars; j++) {
+                       if ((val & 1) == 1)
+                               orarray[ori++] = constraintNegate(vars[j]);
+                       val = val >> 1;
                }
                //no ones to flip, so bail now...
                }
                //no ones to flip, so bail now...
-               if (ori==0) {
+               if (ori == 0) {
                        return constraintAND(cnf, andi, andarray);
                }
                        return constraintAND(cnf, andi, andarray);
                }
-               andarray[andi++]=constraintOR(cnf, ori, orarray);
-               
-               value=value+(1<<(__builtin_ctz(value)));
+               andarray[andi++] = constraintOR(cnf, ori, orarray);
+
+               value = value + (1 << (__builtin_ctz(value)));
                //flip the last one
        }
 }
                //flip the last one
        }
 }
-  
+
 Edge generateEquivNVConstraint(CNF *cnf, uint numvars, Edge *var1, Edge *var2) {
 Edge generateEquivNVConstraint(CNF *cnf, uint numvars, Edge *var1, Edge *var2) {
-       if (numvars==0)
+       if (numvars == 0)
                return E_True;
        Edge array[numvars];
                return E_True;
        Edge array[numvars];
-       for(uint i=0;i<numvars;i++) {
-               array[i]=constraintIFF(cnf, var1[i], var2[i]);
+       for (uint i = 0; i < numvars; i++) {
+               array[i] = constraintIFF(cnf, var1[i], var2[i]);
        }
        return constraintAND(cnf, numvars, array);
 }
        }
        return constraintAND(cnf, numvars, array);
 }
index 2693455a0ba0f85da0c731709482c5b2de67d152..b2488178134bc82bc50ee5680dd9622154dca1ad 100644 (file)
@@ -17,7 +17,7 @@ struct Node;
 typedef struct Node Node;
 
 struct Edge {
 typedef struct Node Node;
 
 struct Edge {
-       Node * node_ptr;
+       Node *node_ptr;
 };
 
 VectorDef(Edge, Edge)
 };
 
 VectorDef(Edge, Edge)
@@ -31,11 +31,11 @@ enum NodeType {
 typedef enum NodeType NodeType;
 
 struct NodeFlags {
 typedef enum NodeType NodeType;
 
 struct NodeFlags {
-       NodeType type:2;
-       int varForced:1;
-       int wasExpanded:2;
-       int cnfVisitedDown:2;
-       int cnfVisitedUp:2;
+       NodeType type : 2;
+       int varForced : 1;
+       int wasExpanded : 2;
+       int cnfVisitedDown : 2;
+       int cnfVisitedUp : 2;
 };
 
 typedef struct NodeFlags NodeFlags;
 };
 
 typedef struct NodeFlags NodeFlags;
@@ -45,7 +45,7 @@ struct Node {
        uint numEdges;
        uint hashCode;
        uint intAnnot[2];
        uint numEdges;
        uint hashCode;
        uint intAnnot[2];
-       void * ptrAnnot[2];
+       void *ptrAnnot[2];
        Edge edges[];
 };
 
        Edge edges[];
 };
 
@@ -59,8 +59,8 @@ struct CNF {
        uint mask;
        uint maxsize;
        bool enableMatching;
        uint mask;
        uint maxsize;
        bool enableMatching;
-       Node ** node_array;
-       IncrementalSolver * solver;
+       Node **node_array;
+       IncrementalSolver *solver;
        VectorEdge constraints;
        VectorEdge args;
 };
        VectorEdge constraints;
        VectorEdge args;
 };
@@ -71,11 +71,11 @@ struct CNFExpr;
 typedef struct CNFExpr CNFExpr;
 
 static inline bool getExpanded(Node *n, int isNegated) {
 typedef struct CNFExpr CNFExpr;
 
 static inline bool getExpanded(Node *n, int isNegated) {
-       return n->flags.wasExpanded & (1<<isNegated);
+       return n->flags.wasExpanded & (1 << isNegated);
 }
 
 static inline void setExpanded(Node *n, int isNegated) {
 }
 
 static inline void setExpanded(Node *n, int isNegated) {
-       n->flags.wasExpanded |= (1<<isNegated);
+       n->flags.wasExpanded |= (1 << isNegated);
 }
 
 static inline Edge constraintNegate(Edge e) {
 }
 
 static inline Edge constraintNegate(Edge e) {
@@ -84,7 +84,7 @@ static inline Edge constraintNegate(Edge e) {
 }
 
 static inline bool sameNodeVarEdge(Edge e1, Edge e2) {
 }
 
 static inline bool sameNodeVarEdge(Edge e1, Edge e2) {
-       return ! (((uintptr_t) e1.node_ptr ^ (uintptr_t) e2.node_ptr) & (~ (uintptr_t) NEGATE_EDGE));
+       return !(((uintptr_t) e1.node_ptr ^ (uintptr_t) e2.node_ptr) & (~(uintptr_t) NEGATE_EDGE));
 }
 
 static inline bool sameSignEdge(Edge e1, Edge e2) {
 }
 
 static inline bool sameSignEdge(Edge e1, Edge e2) {
@@ -111,12 +111,12 @@ static inline bool isNegNodeEdge(Edge e) {
        return (((uintptr_t) e.node_ptr) & (NEGATE_EDGE | EDGE_IS_VAR_CONSTANT)) == NEGATE_EDGE;
 }
 
        return (((uintptr_t) e.node_ptr) & (NEGATE_EDGE | EDGE_IS_VAR_CONSTANT)) == NEGATE_EDGE;
 }
 
-static inline Node * getNodePtrFromEdge(Edge e) {
+static inline Node *getNodePtrFromEdge(Edge e) {
        return (Node *) (((uintptr_t) e.node_ptr) & ~((uintptr_t) EDGE_MASK));
 }
 
 static inline NodeType getNodeType(Edge e) {
        return (Node *) (((uintptr_t) e.node_ptr) & ~((uintptr_t) EDGE_MASK));
 }
 
 static inline NodeType getNodeType(Edge e) {
-       Node * n=getNodePtrFromEdge(e);
+       Node *n = getNodePtrFromEdge(e);
        return n->flags.type;
 }
 
        return n->flags.type;
 }
 
@@ -129,17 +129,17 @@ static inline bool ltEdge(Edge e1, Edge e2) {
 }
 
 static inline uint getNodeSize(Edge e) {
 }
 
 static inline uint getNodeSize(Edge e) {
-       Node * n=getNodePtrFromEdge(e);
+       Node *n = getNodePtrFromEdge(e);
        return n->numEdges;
 }
 
        return n->numEdges;
 }
 
-static inline Edge * getEdgeArray(Edge e) {
-       Node * n=getNodePtrFromEdge(e);
+static inline Edge *getEdgeArray(Edge e) {
+       Node *n = getNodePtrFromEdge(e);
        return n->edges;
 }
 
 static inline Edge getNonNeg(Edge e) {
        return n->edges;
 }
 
 static inline Edge getNonNeg(Edge e) {
-       Edge enew={(Node *)(((uintptr_t)e.node_ptr)&(~((uintptr_t)NEGATE_EDGE)))};
+       Edge enew = {(Node *)(((uintptr_t)e.node_ptr) & (~((uintptr_t)NEGATE_EDGE)))};
        return enew;
 }
 
        return enew;
 }
 
@@ -156,7 +156,7 @@ static inline bool edgeIsVarConst(Edge e) {
 }
 
 static inline Edge constraintNegateIf(Edge e, bool negate) {
 }
 
 static inline Edge constraintNegateIf(Edge e, bool negate) {
-       Edge eret={(Node *)(((uintptr_t)e.node_ptr) ^ negate)};
+       Edge eret = {(Node *)(((uintptr_t)e.node_ptr) ^ negate)};
        return eret;
 }
 
        return eret;
 }
 
@@ -173,24 +173,24 @@ static inline Literal getProxy(CNFExpr *expr) {
        return (Literal) (((intptr_t) expr) >> 1);
 }
 
        return (Literal) (((intptr_t) expr) >> 1);
 }
 
-CNF * createCNF();
-void deleteCNF(CNF * cnf);
+CNF *createCNF();
+void deleteCNF(CNF *cnf);
 
 
-uint hashNode(NodeType type, uint numEdges, Edge * edges);
-Node * allocNode(NodeType type, uint numEdges, Edge * edges, uint hashCode);
-bool compareNodes(Node * node, NodeType type, uint numEdges, Edge *edges);
-Edge create(CNF *cnf, NodeType type, uint numEdges, Edge * edges);
-Edge constraintOR(CNF * cnf, uint numEdges, Edge *edges);
-Edge constraintAND(CNF * cnf, uint numEdges, Edge * edges);
-Edge constraintOR2(CNF * cnf, Edge left, Edge right);
-Edge constraintAND2(CNF * cnf, Edge left, Edge right);
-Edge constraintIMPLIES(CNF * cnf, Edge left, Edge right);
-Edge constraintIFF(CNF * cnf, Edge left, Edge right);
+uint hashNode(NodeType type, uint numEdges, Edge *edges);
+Node *allocNode(NodeType type, uint numEdges, Edge *edges, uint hashCode);
+bool compareNodes(Node *node, NodeType type, uint numEdges, Edge *edges);
+Edge create(CNF *cnf, NodeType type, uint numEdges, Edge *edges);
+Edge constraintOR(CNF *cnf, uint numEdges, Edge *edges);
+Edge constraintAND(CNF *cnf, uint numEdges, Edge *edges);
+Edge constraintOR2(CNF *cnf, Edge left, Edge right);
+Edge constraintAND2(CNF *cnf, Edge left, Edge right);
+Edge constraintIMPLIES(CNF *cnf, Edge left, Edge right);
+Edge constraintIFF(CNF *cnf, Edge left, Edge right);
 static inline Edge constraintXOR(CNF *cnf, Edge left, Edge right) {return constraintNegate(constraintIFF(cnf, left,right));}
 static inline Edge constraintXOR(CNF *cnf, Edge left, Edge right) {return constraintNegate(constraintIFF(cnf, left,right));}
-Edge constraintITE(CNF * cnf, Edge cond, Edge thenedge, Edge elseedge);
+Edge constraintITE(CNF *cnf, Edge cond, Edge thenedge, Edge elseedge);
 Edge constraintNewVar(CNF *cnf);
 void countPass(CNF *cnf);
 Edge constraintNewVar(CNF *cnf);
 void countPass(CNF *cnf);
-void countConstraint(CNF *cnf, VectorEdge * stack, Edge e);
+void countConstraint(CNF *cnf, VectorEdge *stack, Edge e);
 void addConstraintCNF(CNF *cnf, Edge constraint);
 int solveCNF(CNF *cnf);
 bool getValueCNF(CNF *cnf, Edge var);
 void addConstraintCNF(CNF *cnf, Edge constraint);
 int solveCNF(CNF *cnf);
 bool getValueCNF(CNF *cnf, Edge var);
@@ -198,18 +198,18 @@ void printCNF(Edge e);
 
 void convertPass(CNF *cnf, bool backtrackLit);
 void convertConstraint(CNF *cnf, VectorEdge *stack, Edge e, bool backtrackLit);
 
 void convertPass(CNF *cnf, bool backtrackLit);
 void convertConstraint(CNF *cnf, VectorEdge *stack, Edge e, bool backtrackLit);
-void constrainCNF(CNF * cnf, Literal l, CNFExpr *exp);
-void produceCNF(CNF * cnf, Edge e);
-CNFExpr * produceConjunction(CNF * cnf, Edge e);
-CNFExprproduceDisjunction(CNF *cnf, Edge e);
-bool propagate(CNF *cnf, CNFExpr ** dest, CNFExpr * src, bool negate);
-void saveCNF(CNF *cnf, CNFExprexp, Edge e, bool sign);
-CNFExpr* fillArgs(CNF * cnf, Edge e, bool isNeg, Edge * largestEdge);
-Literal introProxy(CNF * cnf, Edge e, CNFExpr* exp, bool isNeg);
+void constrainCNF(CNF *cnf, Literal l, CNFExpr *exp);
+void produceCNF(CNF *cnf, Edge e);
+CNFExpr *produceConjunction(CNF *cnf, Edge e);
+CNFExpr *produceDisjunction(CNF *cnf, Edge e);
+bool propagate(CNF *cnf, CNFExpr **dest, CNFExpr *src, bool negate);
+void saveCNF(CNF *cnf, CNFExpr *exp, Edge e, bool sign);
+CNFExpr *fillArgs(CNF *cnf, Edge e, bool isNeg, Edge *largestEdge);
+Literal introProxy(CNF *cnf, Edge e, CNFExpr *exp, bool isNeg);
 void outputCNF(CNF *cnf, CNFExpr *expr);
 
 void outputCNF(CNF *cnf, CNFExpr *expr);
 
-Edge generateBinaryConstraint(CNF *cnf, uint numvars, Edge * vars, uint value);
-Edge generateLTConstraint(CNF *cnf, uint numvars, Edge * vars, uint value);
+Edge generateBinaryConstraint(CNF *cnf, uint numvars, Edge *vars, uint value);
+Edge generateLTConstraint(CNF *cnf, uint numvars, Edge *vars, uint value);
 Edge generateEquivNVConstraint(CNF *cnf, uint numvars, Edge *var1, Edge *var2);
 
 extern Edge E_True;
 Edge generateEquivNVConstraint(CNF *cnf, uint numvars, Edge *var1, Edge *var2);
 
 extern Edge E_True;
index 8a37343935e4df02cefcb38c35bbece9bd940c8b..85528dc2c73d4a2d6a18ce12e86d236089f7a277 100644 (file)
 #include "common.h"
 #include <string.h>
 
 #include "common.h"
 #include <string.h>
 
-IncrementalSolver * allocIncrementalSolver() {
-       IncrementalSolver *This=(IncrementalSolver *)ourmalloc(sizeof(IncrementalSolver));
-       This->buffer=((int *)ourmalloc(sizeof(int)*IS_BUFFERSIZE));
-       This->solution=NULL;
-       This->solutionsize=0;
-       This->offset=0;
+IncrementalSolver *allocIncrementalSolver() {
+       IncrementalSolver *This = (IncrementalSolver *)ourmalloc(sizeof(IncrementalSolver));
+       This->buffer = ((int *)ourmalloc(sizeof(int) * IS_BUFFERSIZE));
+       This->solution = NULL;
+       This->solutionsize = 0;
+       This->offset = 0;
        createSolver(This);
        return This;
 }
 
        createSolver(This);
        return This;
 }
 
-void deleteIncrementalSolver(IncrementalSolver * This) {
+void deleteIncrementalSolver(IncrementalSolver *This) {
        killSolver(This);
        ourfree(This->buffer);
        if (This->solution != NULL)
        killSolver(This);
        ourfree(This->buffer);
        if (This->solution != NULL)
@@ -31,51 +31,51 @@ void deleteIncrementalSolver(IncrementalSolver * This) {
        ourfree(This);
 }
 
        ourfree(This);
 }
 
-void resetSolver(IncrementalSolver * This) {
+void resetSolver(IncrementalSolver *This) {
        killSolver(This);
        This->offset = 0;
        createSolver(This);
 }
 
        killSolver(This);
        This->offset = 0;
        createSolver(This);
 }
 
-void addClauseLiteral(IncrementalSolver * This, int literal) {
-       This->buffer[This->offset++]=literal;
-       if (This->offset==IS_BUFFERSIZE) {
+void addClauseLiteral(IncrementalSolver *This, int literal) {
+       This->buffer[This->offset++] = literal;
+       if (This->offset == IS_BUFFERSIZE) {
                flushBufferSolver(This);
        }
 }
 
                flushBufferSolver(This);
        }
 }
 
-void addArrayClauseLiteral(IncrementalSolver * This, uint numliterals, int * literals) {
-       uint index=0;
-       while(true) {
-               uint bufferspace=IS_BUFFERSIZE-This->offset;
-               uint numtowrite=numliterals-index;
+void addArrayClauseLiteral(IncrementalSolver *This, uint numliterals, int *literals) {
+       uint index = 0;
+       while (true) {
+               uint bufferspace = IS_BUFFERSIZE - This->offset;
+               uint numtowrite = numliterals - index;
                if (bufferspace > numtowrite) {
                if (bufferspace > numtowrite) {
-                       memcpy(&This->buffer[This->offset], &literals[index], numtowrite*sizeof(int));
-                       This->offset+=numtowrite;
-                       This->buffer[This->offset++]=0; //have one extra spot always
-                       if (This->offset==IS_BUFFERSIZE) {//Check if full
+                       memcpy(&This->buffer[This->offset], &literals[index], numtowrite * sizeof(int));
+                       This->offset += numtowrite;
+                       This->buffer[This->offset++] = 0;       //have one extra spot always
+                       if (This->offset == IS_BUFFERSIZE) {//Check if full
                                flushBufferSolver(This);
                        }
                        return;
                } else {
                                flushBufferSolver(This);
                        }
                        return;
                } else {
-                       memcpy(&This->buffer[This->offset], &literals[index], bufferspace*sizeof(int));
-                       This->offset+=bufferspace;
-                       index+=bufferspace;
+                       memcpy(&This->buffer[This->offset], &literals[index], bufferspace * sizeof(int));
+                       This->offset += bufferspace;
+                       index += bufferspace;
                        flushBufferSolver(This);
                }
        }
 }
 
                        flushBufferSolver(This);
                }
        }
 }
 
-void finishedClauses(IncrementalSolver * This) {
+void finishedClauses(IncrementalSolver *This) {
        addClauseLiteral(This, 0);
 }
 
        addClauseLiteral(This, 0);
 }
 
-void freeze(IncrementalSolver * This, int variable) {
+void freeze(IncrementalSolver *This, int variable) {
        addClauseLiteral(This, IS_FREEZE);
        addClauseLiteral(This, variable);
 }
 
        addClauseLiteral(This, IS_FREEZE);
        addClauseLiteral(This, variable);
 }
 
-int solve(IncrementalSolver * This) {
+int solve(IncrementalSolver *This) {
        //add an empty clause
        startSolve(This);
        return getSolution(This);
        //add an empty clause
        startSolve(This);
        return getSolution(This);
@@ -86,14 +86,14 @@ void startSolve(IncrementalSolver *This) {
        flushBufferSolver(This);
 }
 
        flushBufferSolver(This);
 }
 
-int getSolution(IncrementalSolver * This) {
-       int result=readIntSolver(This);
+int getSolution(IncrementalSolver *This) {
+       int result = readIntSolver(This);
        if (result == IS_SAT) {
        if (result == IS_SAT) {
-               int numVars=readIntSolver(This);
+               int numVars = readIntSolver(This);
                if (numVars > This->solutionsize) {
                        if (This->solution != NULL)
                                ourfree(This->solution);
                if (numVars > This->solutionsize) {
                        if (This->solution != NULL)
                                ourfree(This->solution);
-                       This->solution = (int *) ourmalloc((numVars+1)*sizeof(int));
+                       This->solution = (int *) ourmalloc((numVars + 1) * sizeof(int));
                        This->solution[0] = 0;
                }
                readSolver(This, &This->solution[1], numVars * sizeof(int));
                        This->solution[0] = 0;
                }
                readSolver(This, &This->solution[1], numVars * sizeof(int));
@@ -102,32 +102,32 @@ int getSolution(IncrementalSolver * This) {
        return result;
 }
 
        return result;
 }
 
-int readIntSolver(IncrementalSolver * This) {
+int readIntSolver(IncrementalSolver *This) {
        int value;
        readSolver(This, &value, 4);
        return value;
 }
 
        int value;
        readSolver(This, &value, 4);
        return value;
 }
 
-void readSolver(IncrementalSolver * This, void * tmp, ssize_t size) {
+void readSolver(IncrementalSolver *This, void *tmp, ssize_t size) {
        char *result = (char *) tmp;
        char *result = (char *) tmp;
-       ssize_t bytestoread=size;
-       ssize_t bytesread=0;
+       ssize_t bytestoread = size;
+       ssize_t bytesread = 0;
        do {
        do {
-               ssize_t n=read(This->from_solver_fd, &((char *)result)[bytesread], bytestoread);
+               ssize_t n = read(This->from_solver_fd, &((char *)result)[bytesread], bytestoread);
                if (n == -1) {
                        model_print("Read failure\n");
                        exit(-1);
                }
                bytestoread -= n;
                bytesread += n;
                if (n == -1) {
                        model_print("Read failure\n");
                        exit(-1);
                }
                bytestoread -= n;
                bytesread += n;
-       } while(bytestoread != 0);
+       } while (bytestoread != 0);
 }
 
 }
 
-bool getValueSolver(IncrementalSolver * This, int variable) {
+bool getValueSolver(IncrementalSolver *This, int variable) {
        return This->solution[variable];
 }
 
        return This->solution[variable];
 }
 
-void createSolver(IncrementalSolver * This) {
+void createSolver(IncrementalSolver *This) {
        int to_pipe[2];
        int from_pipe[2];
        if (pipe(to_pipe) || pipe(from_pipe)) {
        int to_pipe[2];
        int from_pipe[2];
        if (pipe(to_pipe) || pipe(from_pipe)) {
@@ -142,7 +142,7 @@ void createSolver(IncrementalSolver * This) {
                //Solver process
                close(to_pipe[1]);
                close(from_pipe[0]);
                //Solver process
                close(to_pipe[1]);
                close(from_pipe[0]);
-               int fd=open("log_file", O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
+               int fd = open("log_file", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
 
                if ((dup2(to_pipe[0], 0) == -1) ||
                                (dup2(from_pipe[1], IS_OUT_FD) == -1) ||
 
                if ((dup2(to_pipe[0], 0) == -1) ||
                                (dup2(from_pipe[1], IS_OUT_FD) == -1) ||
@@ -162,7 +162,7 @@ void createSolver(IncrementalSolver * This) {
        }
 }
 
        }
 }
 
-void killSolver(IncrementalSolver * This) {
+void killSolver(IncrementalSolver *This) {
        close(This->to_solver_fd);
        close(This->from_solver_fd);
        //Stop the solver
        close(This->to_solver_fd);
        close(This->from_solver_fd);
        //Stop the solver
@@ -174,29 +174,29 @@ void killSolver(IncrementalSolver * This) {
 }
 
 //DEBUGGING CODE STARTS
 }
 
 //DEBUGGING CODE STARTS
-bool first=true;
+bool first = true;
 //DEBUGGING CODE ENDS
 
 //DEBUGGING CODE ENDS
 
-void flushBufferSolver(IncrementalSolver * This) {
-       ssize_t bytestowrite=sizeof(int)*This->offset;
-       ssize_t byteswritten=0;
+void flushBufferSolver(IncrementalSolver *This) {
+       ssize_t bytestowrite = sizeof(int) * This->offset;
+       ssize_t byteswritten = 0;
        //DEBUGGING CODE STARTS
        //DEBUGGING CODE STARTS
-       for(uint i=0;i<This->offset;i++) {
+       for (uint i = 0; i < This->offset; i++) {
                if (first)
                        printf("(");
                if (first)
                        printf("(");
-               if (This->buffer[i]==0) {
+               if (This->buffer[i] == 0) {
                        printf(")\n");
                        printf(")\n");
-                       first=true;
+                       first = true;
                } else {
                        if (!first)
                                printf(" + ");
                } else {
                        if (!first)
                                printf(" + ");
-                       first=false;
+                       first = false;
                        printf("%d", This->buffer[i]);
                }
        }
        //DEBUGGING CODE ENDS
        do {
                        printf("%d", This->buffer[i]);
                }
        }
        //DEBUGGING CODE ENDS
        do {
-               ssize_t n=write(This->to_solver_fd, &((char *)This->buffer)[byteswritten], bytestowrite);
+               ssize_t n = write(This->to_solver_fd, &((char *)This->buffer)[byteswritten], bytestowrite);
                if (n == -1) {
                        perror("Write failure\n");
                        model_print("to_solver_fd=%d\n",This->to_solver_fd);
                if (n == -1) {
                        perror("Write failure\n");
                        model_print("to_solver_fd=%d\n",This->to_solver_fd);
@@ -204,6 +204,6 @@ void flushBufferSolver(IncrementalSolver * This) {
                }
                bytestowrite -= n;
                byteswritten += n;
                }
                bytestowrite -= n;
                byteswritten += n;
-       } while(bytestowrite != 0);
+       } while (bytestowrite != 0);
        This->offset = 0;
 }
        This->offset = 0;
 }
index 9b3e2ab55cc61f6ee503bcd81288e66974a5e538..9e9424e4cbdee9f8dd4eeb085aa771302cce0dc2 100644 (file)
@@ -19,8 +19,8 @@
 #include "classlist.h"
 
 struct IncrementalSolver {
 #include "classlist.h"
 
 struct IncrementalSolver {
-       int * buffer;
-       int * solution;
+       int *buffer;
+       int *solution;
        int solutionsize;
        int offset;
        pid_t solver_pid;
        int solutionsize;
        int offset;
        pid_t solver_pid;
@@ -28,20 +28,20 @@ struct IncrementalSolver {
        int from_solver_fd;
 };
 
        int from_solver_fd;
 };
 
-IncrementalSolver * allocIncrementalSolver();
-void deleteIncrementalSolver(IncrementalSolver * This);
-void addClauseLiteral(IncrementalSolver * This, int literal);
-void addArrayClauseLiteral(IncrementalSolver * This, uint numliterals, int * literals);
-void finishedClauses(IncrementalSolver * This);
-void freeze(IncrementalSolver * This, int variable);
-int solve(IncrementalSolver * This);
-void startSolve(IncrementalSolver * This);
-int getSolution(IncrementalSolver * This);
-bool getValueSolver(IncrementalSolver * This, int variable);
-void resetSolver(IncrementalSolver * This);
-void createSolver(IncrementalSolver * This);
-void killSolver(IncrementalSolver * This);
-void flushBufferSolver(IncrementalSolver * This);
-int readIntSolver(IncrementalSolver * This);
-void readSolver(IncrementalSolver * This, void * buffer, ssize_t size);
+IncrementalSolver *allocIncrementalSolver();
+void deleteIncrementalSolver(IncrementalSolver *This);
+void addClauseLiteral(IncrementalSolver *This, int literal);
+void addArrayClauseLiteral(IncrementalSolver *This, uint numliterals, int *literals);
+void finishedClauses(IncrementalSolver *This);
+void freeze(IncrementalSolver *This, int variable);
+int solve(IncrementalSolver *This);
+void startSolve(IncrementalSolver *This);
+int getSolution(IncrementalSolver *This);
+bool getValueSolver(IncrementalSolver *This, int variable);
+void resetSolver(IncrementalSolver *This);
+void createSolver(IncrementalSolver *This);
+void killSolver(IncrementalSolver *This);
+void flushBufferSolver(IncrementalSolver *This);
+int readIntSolver(IncrementalSolver *This);
+void readSolver(IncrementalSolver *This, void *buffer, ssize_t size);
 #endif
 #endif
index 4db56caa10259faef484c472caf684907818e769..9501af5dcc437f232c686395765e4be271a2820c 100644 (file)
@@ -1,14 +1,14 @@
 #include "orderpair.h"
 
 
 #include "orderpair.h"
 
 
-OrderPair* allocOrderPair(uint64_t first, uint64_t second, Edge constraint){
-       OrderPair* pair = (OrderPair*) ourmalloc(sizeof(OrderPair));
+OrderPair *allocOrderPair(uint64_t first, uint64_t second, Edge constraint) {
+       OrderPair *pair = (OrderPair *) ourmalloc(sizeof(OrderPair));
        pair->first = first;
        pair->second = second;
        pair->constraint = constraint;
        return pair;
 }
 
        pair->first = first;
        pair->second = second;
        pair->constraint = constraint;
        return pair;
 }
 
-void deleteOrderPair(OrderPair* pair){
+void deleteOrderPair(OrderPair *pair) {
        ourfree(pair);
 }
        ourfree(pair);
 }
index 05c8ffa06034f9cfb02552aad3a116948fdd3105..57b96b4cc409da775b3647fa93da3a60bc50d7c6 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   orderpair.h
  * Author: hamed
  *
  * File:   orderpair.h
  * Author: hamed
  *
 #include "mymemory.h"
 #include "constraint.h"
 
 #include "mymemory.h"
 #include "constraint.h"
 
-struct OrderPair{
+struct OrderPair {
        uint64_t first;
        uint64_t second;
        Edge constraint;
        uint64_t first;
        uint64_t second;
        Edge constraint;
-}; 
+};
 
 
-OrderPairallocOrderPair(uint64_t first, uint64_t second, Edge constraint);
-void deleteOrderPair(OrderPairpair);
+OrderPair *allocOrderPair(uint64_t first, uint64_t second, Edge constraint);
+void deleteOrderPair(OrderPair *pair);
 
 
-#endif /* ORDERPAIR_H */
+#endif/* ORDERPAIR_H */
 
 
index ca71c6e9f1905f0c03780bf12273282db70fbc55..5beae4fa0dd665bcbb04ea340c1e120fc148f94d 100644 (file)
@@ -5,74 +5,74 @@
 #include "element.h"
 #include "set.h"
 
 #include "element.h"
 #include "set.h"
 
-Edge getElementValueConstraint(SATEncoder* This, Element* elem, uint64_t value) { 
-       switch(getElementEncoding(elem)->type){
-               case ONEHOT:
-                       return getElementValueOneHotConstraint(This, elem, value);
-               case UNARY:
-                       return getElementValueUnaryConstraint(This, elem, value);
-               case BINARYINDEX:
-                       return getElementValueBinaryIndexConstraint(This, elem, value);
-               case ONEHOTBINARY:
-                       ASSERT(0);
-                       break;
-               case BINARYVAL:
-                       return getElementValueBinaryValueConstraint(This, elem, value);
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
+Edge getElementValueConstraint(SATEncoder *This, Element *elem, uint64_t value) {
+       switch (getElementEncoding(elem)->type) {
+       case ONEHOT:
+               return getElementValueOneHotConstraint(This, elem, value);
+       case UNARY:
+               return getElementValueUnaryConstraint(This, elem, value);
+       case BINARYINDEX:
+               return getElementValueBinaryIndexConstraint(This, elem, value);
+       case ONEHOTBINARY:
+               ASSERT(0);
+               break;
+       case BINARYVAL:
+               return getElementValueBinaryValueConstraint(This, elem, value);
+               break;
+       default:
+               ASSERT(0);
+               break;
        }
        return E_BOGUS;
 }
 
        }
        return E_BOGUS;
 }
 
-Edge getElementValueBinaryIndexConstraint(SATEncoder * This, Element* elem, uint64_t value) {
+Edge getElementValueBinaryIndexConstraint(SATEncoder *This, Element *elem, uint64_t value) {
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
-       ElementEncodingelemEnc = getElementEncoding(elem);
-       for(uint i=0; i<elemEnc->encArraySize; i++){
-               if(isinUseElement(elemEnc, i) && elemEnc->encodingArray[i]==value) {
-                       return (elemEnc->numVars == 0) ? E_True: generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, i);
+       ElementEncoding *elemEnc = getElementEncoding(elem);
+       for (uint i = 0; i < elemEnc->encArraySize; i++) {
+               if (isinUseElement(elemEnc, i) && elemEnc->encodingArray[i] == value) {
+                       return (elemEnc->numVars == 0) ? E_True : generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, i);
                }
        }
        return E_False;
 }
 
                }
        }
        return E_False;
 }
 
-Edge getElementValueOneHotConstraint(SATEncoder * This, Element* elem, uint64_t value) {
+Edge getElementValueOneHotConstraint(SATEncoder *This, Element *elem, uint64_t value) {
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
-       ElementEncodingelemEnc = getElementEncoding(elem);
-       for(uint i=0; i<elemEnc->encArraySize; i++){
-               if (isinUseElement(elemEnc, i) && elemEnc->encodingArray[i]==value) {
-                       return (elemEnc->numVars == 0) ? E_True: elemEnc->variables[i];
+       ElementEncoding *elemEnc = getElementEncoding(elem);
+       for (uint i = 0; i < elemEnc->encArraySize; i++) {
+               if (isinUseElement(elemEnc, i) && elemEnc->encodingArray[i] == value) {
+                       return (elemEnc->numVars == 0) ? E_True : elemEnc->variables[i];
                }
        }
        return E_False;
 }
 
                }
        }
        return E_False;
 }
 
-Edge getElementValueUnaryConstraint(SATEncoder * This, Element* elem, uint64_t value) {
+Edge getElementValueUnaryConstraint(SATEncoder *This, Element *elem, uint64_t value) {
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
        ASTNodeType type = GETELEMENTTYPE(elem);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
-       ElementEncodingelemEnc = getElementEncoding(elem);
-       for(uint i=0; i<elemEnc->encArraySize; i++){
-               if (isinUseElement(elemEnc, i) && elemEnc->encodingArray[i]==value) {
-                       if(elemEnc->numVars == 0)
+       ElementEncoding *elemEnc = getElementEncoding(elem);
+       for (uint i = 0; i < elemEnc->encArraySize; i++) {
+               if (isinUseElement(elemEnc, i) && elemEnc->encodingArray[i] == value) {
+                       if (elemEnc->numVars == 0)
                                return E_True;
                                return E_True;
-                       if (i==0)
+                       if (i == 0)
                                return constraintNegate(elemEnc->variables[0]);
                                return constraintNegate(elemEnc->variables[0]);
-                       else if ((i+1)==elemEnc->encArraySize)
-                               return elemEnc->variables[i-1];
+                       else if ((i + 1) == elemEnc->encArraySize)
+                               return elemEnc->variables[i - 1];
                        else
                        else
-                               return constraintAND2(This->cnf, elemEnc->variables[i-1], constraintNegate(elemEnc->variables[i]));
+                               return constraintAND2(This->cnf, elemEnc->variables[i - 1], constraintNegate(elemEnc->variables[i]));
                }
        }
        return E_False;
 }
 
                }
        }
        return E_False;
 }
 
-Edge getElementValueBinaryValueConstraint(SATEncoder * This, Element* element, uint64_t value){
+Edge getElementValueBinaryValueConstraint(SATEncoder *This, Element *element, uint64_t value) {
        ASTNodeType type = GETELEMENTTYPE(element);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN);
        ASTNodeType type = GETELEMENTTYPE(element);
        ASSERT(type == ELEMSET || type == ELEMFUNCRETURN);
-       ElementEncodingelemEnc = getElementEncoding(element);
+       ElementEncoding *elemEnc = getElementEncoding(element);
        if (elemEnc->low <= elemEnc->high) {
                if (value < elemEnc->low || value > elemEnc->high)
                        return E_False;
        if (elemEnc->low <= elemEnc->high) {
                if (value < elemEnc->low || value > elemEnc->high)
                        return E_False;
@@ -81,33 +81,33 @@ Edge getElementValueBinaryValueConstraint(SATEncoder * This, Element* element, u
                if (value < elemEnc->low && value > elemEnc->high)
                        return E_False;
        }
                if (value < elemEnc->low && value > elemEnc->high)
                        return E_False;
        }
-       
-       uint64_t valueminusoffset=value-elemEnc->offset;
+
+       uint64_t valueminusoffset = value - elemEnc->offset;
        return generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, valueminusoffset);
 }
 
        return generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, valueminusoffset);
 }
 
-void allocElementConstraintVariables(ElementEncodingThis, uint numVars) {
+void allocElementConstraintVariables(ElementEncoding *This, uint numVars) {
        This->numVars = numVars;
        This->variables = ourmalloc(sizeof(Edge) * numVars);
 }
 
        This->numVars = numVars;
        This->variables = ourmalloc(sizeof(Edge) * numVars);
 }
 
-void generateBinaryValueEncodingVars(SATEncoder* This, ElementEncoding* encoding){
-       ASSERT(encoding->type==BINARYVAL);
+void generateBinaryValueEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
+       ASSERT(encoding->type == BINARYVAL);
        allocElementConstraintVariables(encoding, encoding->numBits);
        getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
 }
 
 void generateBinaryIndexEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
        allocElementConstraintVariables(encoding, encoding->numBits);
        getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
 }
 
 void generateBinaryIndexEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
-       ASSERT(encoding->type==BINARYINDEX);
-       allocElementConstraintVariables(encoding, NUMBITS(encoding->encArraySize-1));
+       ASSERT(encoding->type == BINARYINDEX);
+       allocElementConstraintVariables(encoding, NUMBITS(encoding->encArraySize - 1));
        getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
 }
 
 void generateOneHotEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
        allocElementConstraintVariables(encoding, encoding->encArraySize);
        getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
 }
 
 void generateOneHotEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
        allocElementConstraintVariables(encoding, encoding->encArraySize);
-       getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);        
-       for(uint i=0;i<encoding->numVars;i++) {
-               for(uint j=i+1;j<encoding->numVars;j++) {
+       getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
+       for (uint i = 0; i < encoding->numVars; i++) {
+               for (uint j = i + 1; j < encoding->numVars; j++) {
                        addConstraintCNF(This->cnf, constraintNegate(constraintAND2(This->cnf, encoding->variables[i], encoding->variables[j])));
                }
        }
                        addConstraintCNF(This->cnf, constraintNegate(constraintAND2(This->cnf, encoding->variables[i], encoding->variables[j])));
                }
        }
@@ -115,20 +115,20 @@ void generateOneHotEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
 }
 
 void generateUnaryEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
 }
 
 void generateUnaryEncodingVars(SATEncoder *This, ElementEncoding *encoding) {
-       allocElementConstraintVariables(encoding, encoding->encArraySize-1);
-       getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);        
+       allocElementConstraintVariables(encoding, encoding->encArraySize - 1);
+       getArrayNewVarsSATEncoder(This, encoding->numVars, encoding->variables);
        //Add unary constraint
        //Add unary constraint
-       for(uint i=1;i<encoding->numVars;i++) {
-               addConstraintCNF(This->cnf, constraintOR2(This->cnf, encoding->variables[i-1], constraintNegate(encoding->variables[i])));
+       for (uint i = 1; i < encoding->numVars; i++) {
+               addConstraintCNF(This->cnf, constraintOR2(This->cnf, encoding->variables[i - 1], constraintNegate(encoding->variables[i])));
        }
 }
 
        }
 }
 
-void generateElementEncoding(SATEncoder* This, Element * element) {
-       ElementEncodingencoding = getElementEncoding(element);
-       ASSERT(encoding->type!=ELEM_UNASSIGNED);
-       if(encoding->variables!=NULL)
+void generateElementEncoding(SATEncoder *This, Element *element) {
+       ElementEncoding *encoding = getElementEncoding(element);
+       ASSERT(encoding->type != ELEM_UNASSIGNED);
+       if (encoding->variables != NULL)
                return;
                return;
-       switch(encoding->type) {
+       switch (encoding->type) {
        case ONEHOT:
                generateOneHotEncodingVars(This, encoding);
                return;
        case ONEHOT:
                generateOneHotEncodingVars(This, encoding);
                return;
index 7ba81cdc2ee4fec060c838cb9df32f177c7443f1..d75f2f86df9d987bd3be0863ed8a7067662cdab7 100644 (file)
@@ -1,15 +1,15 @@
 #ifndef SATELEMENTENCODER_H
 #define SATELEMENTENCODER_H
 
 #ifndef SATELEMENTENCODER_H
 #define SATELEMENTENCODER_H
 
-Edge getElementValueOneHotConstraint(SATEncoder * This, Element* elem, uint64_t value);
-Edge getElementValueUnaryConstraint(SATEncoder * This, Element* elem, uint64_t value);
-Edge getElementValueBinaryIndexConstraint(SATEncoder * This, Element* element, uint64_t value);
-Edge getElementValueBinaryValueConstraint(SATEncoder * This, Element* element, uint64_t value);
-Edge getElementValueConstraint(SATEncoder* encoder, Element* This, uint64_t value);
-void allocElementConstraintVariables(ElementEncodingThis, uint numVars);
+Edge getElementValueOneHotConstraint(SATEncoder *This, Element *elem, uint64_t value);
+Edge getElementValueUnaryConstraint(SATEncoder *This, Element *elem, uint64_t value);
+Edge getElementValueBinaryIndexConstraint(SATEncoder *This, Element *element, uint64_t value);
+Edge getElementValueBinaryValueConstraint(SATEncoder *This, Element *element, uint64_t value);
+Edge getElementValueConstraint(SATEncoder *encoder, Element *This, uint64_t value);
+void allocElementConstraintVariables(ElementEncoding *This, uint numVars);
 void generateOneHotEncodingVars(SATEncoder *This, ElementEncoding *encoding);
 void generateUnaryEncodingVars(SATEncoder *This, ElementEncoding *encoding);
 void generateOneHotEncodingVars(SATEncoder *This, ElementEncoding *encoding);
 void generateUnaryEncodingVars(SATEncoder *This, ElementEncoding *encoding);
-void generateBinaryIndexEncodingVars(SATEncoder* This, ElementEncoding* encoding);
-void generateBinaryValueEncodingVars(SATEncoder* This, ElementEncoding* encoding);
-void generateElementEncoding(SATEncoder* This, Element* element);
+void generateBinaryIndexEncodingVars(SATEncoder *This, ElementEncoding *encoding);
+void generateBinaryValueEncodingVars(SATEncoder *This, ElementEncoding *encoding);
+void generateElementEncoding(SATEncoder *This, Element *element);
 #endif
 #endif
index 885aab8ea5dafc853ae97db45efffc17c219719d..9717886709374cc5a80a0e85bf46c1665d9a03b6 100644 (file)
 
 //TODO: Should handle sharing of AST Nodes without recoding them a second time
 
 
 //TODO: Should handle sharing of AST Nodes without recoding them a second time
 
-SATEncoder * allocSATEncoder() {
-       SATEncoder *This=ourmalloc(sizeof (SATEncoder));
-       This->varcount=1;
-       This->cnf=createCNF();
+SATEncoder *allocSATEncoder() {
+       SATEncoder *This = ourmalloc(sizeof (SATEncoder));
+       This->varcount = 1;
+       This->cnf = createCNF();
        return This;
 }
 
        return This;
 }
 
@@ -27,20 +27,20 @@ void deleteSATEncoder(SATEncoder *This) {
        ourfree(This);
 }
 
        ourfree(This);
 }
 
-void encodeAllSATEncoder(CSolver *csolver, SATEncoder * This) {
-       VectorBoolean *constraints=csolver->constraints;
-       uint size=getSizeVectorBoolean(constraints);
-       for(uint i=0;i<size;i++) {
+void encodeAllSATEncoder(CSolver *csolver, SATEncoder *This) {
+       VectorBoolean *constraints = csolver->constraints;
+       uint size = getSizeVectorBoolean(constraints);
+       for (uint i = 0; i < size; i++) {
                model_print("Encoding All ...\n\n");
                model_print("Encoding All ...\n\n");
-               Boolean *constraint=getVectorBoolean(constraints, i);
-               Edge c= encodeConstraintSATEncoder(This, constraint);
+               Boolean *constraint = getVectorBoolean(constraints, i);
+               Edge c = encodeConstraintSATEncoder(This, constraint);
                model_print("Returned Constraint in EncodingAll:\n");
                addConstraintCNF(This->cnf, c);
        }
 }
 
 Edge encodeConstraintSATEncoder(SATEncoder *This, Boolean *constraint) {
                model_print("Returned Constraint in EncodingAll:\n");
                addConstraintCNF(This->cnf, c);
        }
 }
 
 Edge encodeConstraintSATEncoder(SATEncoder *This, Boolean *constraint) {
-       switch(GETBOOLEANTYPE(constraint)) {
+       switch (GETBOOLEANTYPE(constraint)) {
        case ORDERCONST:
                return encodeOrderSATEncoder(This, (BooleanOrder *) constraint);
        case BOOLEANVAR:
        case ORDERCONST:
                return encodeOrderSATEncoder(This, (BooleanOrder *) constraint);
        case BOOLEANVAR:
@@ -55,40 +55,40 @@ Edge encodeConstraintSATEncoder(SATEncoder *This, Boolean *constraint) {
        }
 }
 
        }
 }
 
-void getArrayNewVarsSATEncoder(SATEncoder* encoder, uint num, Edge * carray) {
-       for(uint i=0;i<num;i++)
-               carray[i]=getNewVarSATEncoder(encoder);
+void getArrayNewVarsSATEncoder(SATEncoder *encoder, uint num, Edge *carray) {
+       for (uint i = 0; i < num; i++)
+               carray[i] = getNewVarSATEncoder(encoder);
 }
 
 Edge getNewVarSATEncoder(SATEncoder *This) {
        return constraintNewVar(This->cnf);
 }
 
 }
 
 Edge getNewVarSATEncoder(SATEncoder *This) {
        return constraintNewVar(This->cnf);
 }
 
-Edge encodeVarSATEncoder(SATEncoder *This, BooleanVar * constraint) {
+Edge encodeVarSATEncoder(SATEncoder *This, BooleanVar *constraint) {
        if (edgeIsNull(constraint->var)) {
        if (edgeIsNull(constraint->var)) {
-               constraint->var=getNewVarSATEncoder(This);
+               constraint->var = getNewVarSATEncoder(This);
        }
        return constraint->var;
 }
 
        }
        return constraint->var;
 }
 
-Edge encodeLogicSATEncoder(SATEncoder *This, BooleanLogic * constraint) {
+Edge encodeLogicSATEncoder(SATEncoder *This, BooleanLogic *constraint) {
        Edge array[getSizeArrayBoolean(&constraint->inputs)];
        Edge array[getSizeArrayBoolean(&constraint->inputs)];
-       for(uint i=0;i<getSizeArrayBoolean(&constraint->inputs);i++)
-               array[i]=encodeConstraintSATEncoder(This, getArrayBoolean(&constraint->inputs, i));
+       for (uint i = 0; i < getSizeArrayBoolean(&constraint->inputs); i++)
+               array[i] = encodeConstraintSATEncoder(This, getArrayBoolean(&constraint->inputs, i));
 
 
-       switch(constraint->op) {
+       switch (constraint->op) {
        case L_AND:
                return constraintAND(This->cnf, getSizeArrayBoolean(&constraint->inputs), array);
        case L_OR:
                return constraintOR(This->cnf, getSizeArrayBoolean(&constraint->inputs), array);
        case L_NOT:
        case L_AND:
                return constraintAND(This->cnf, getSizeArrayBoolean(&constraint->inputs), array);
        case L_OR:
                return constraintOR(This->cnf, getSizeArrayBoolean(&constraint->inputs), array);
        case L_NOT:
-               ASSERT( getSizeArrayBoolean(&constraint->inputs)==1);
+               ASSERT( getSizeArrayBoolean(&constraint->inputs) == 1);
                return constraintNegate(array[0]);
        case L_XOR:
                return constraintNegate(array[0]);
        case L_XOR:
-               ASSERT( getSizeArrayBoolean(&constraint->inputs)==2);
+               ASSERT( getSizeArrayBoolean(&constraint->inputs) == 2);
                return constraintXOR(This->cnf, array[0], array[1]);
        case L_IMPLIES:
                return constraintXOR(This->cnf, array[0], array[1]);
        case L_IMPLIES:
-               ASSERT( getSizeArrayBoolean( &constraint->inputs)==2);
+               ASSERT( getSizeArrayBoolean( &constraint->inputs) == 2);
                return constraintIMPLIES(This->cnf, array[0], array[1]);
        default:
                model_print("Unhandled case in encodeLogicSATEncoder %u", constraint->op);
                return constraintIMPLIES(This->cnf, array[0], array[1]);
        default:
                model_print("Unhandled case in encodeLogicSATEncoder %u", constraint->op);
@@ -96,70 +96,70 @@ Edge encodeLogicSATEncoder(SATEncoder *This, BooleanLogic * constraint) {
        }
 }
 
        }
 }
 
-Edge encodePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint) {
-       switch(GETPREDICATETYPE(constraint->predicate) ){
-               case TABLEPRED:
-                       return encodeTablePredicateSATEncoder(This, constraint);
-               case OPERATORPRED:
-                       return encodeOperatorPredicateSATEncoder(This, constraint);
-               default:
-                       ASSERT(0);
+Edge encodePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
+       switch (GETPREDICATETYPE(constraint->predicate) ) {
+       case TABLEPRED:
+               return encodeTablePredicateSATEncoder(This, constraint);
+       case OPERATORPRED:
+               return encodeOperatorPredicateSATEncoder(This, constraint);
+       default:
+               ASSERT(0);
        }
        return E_BOGUS;
 }
 
        }
        return E_BOGUS;
 }
 
-Edge encodeTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint){
-       switch(constraint->encoding.type){
-               case ENUMERATEIMPLICATIONS:
-               case ENUMERATEIMPLICATIONSNEGATE:
-                       return encodeEnumTablePredicateSATEncoder(This, constraint);
-               case CIRCUIT:
-                       ASSERT(0);
-                       break;
-               default:
-                       ASSERT(0);
+Edge encodeTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
+       switch (constraint->encoding.type) {
+       case ENUMERATEIMPLICATIONS:
+       case ENUMERATEIMPLICATIONSNEGATE:
+               return encodeEnumTablePredicateSATEncoder(This, constraint);
+       case CIRCUIT:
+               ASSERT(0);
+               break;
+       default:
+               ASSERT(0);
        }
        return E_BOGUS;
 }
 
        }
        return E_BOGUS;
 }
 
-void encodeElementSATEncoder(SATEncoder* encoder, Element *This){
-       switch( GETELEMENTTYPE(This) ){
-               case ELEMFUNCRETURN:
-                       generateElementEncoding(encoder, This);
-                       encodeElementFunctionSATEncoder(encoder, (ElementFunction*) This);
-                       break;
-               case ELEMSET:
-                       generateElementEncoding(encoder, This);
-                       return;
-               case ELEMCONST:
-                       return;
-               default:
-                       ASSERT(0);
+void encodeElementSATEncoder(SATEncoder *encoder, Element *This) {
+       switch ( GETELEMENTTYPE(This) ) {
+       case ELEMFUNCRETURN:
+               generateElementEncoding(encoder, This);
+               encodeElementFunctionSATEncoder(encoder, (ElementFunction *) This);
+               break;
+       case ELEMSET:
+               generateElementEncoding(encoder, This);
+               return;
+       case ELEMCONST:
+               return;
+       default:
+               ASSERT(0);
        }
 }
 
        }
 }
 
-void encodeElementFunctionSATEncoder(SATEncoder* encoder, ElementFunction *This){
-       switch(GETFUNCTIONTYPE(This->function)){
-               case TABLEFUNC:
-                       encodeTableElementFunctionSATEncoder(encoder, This);
-                       break;
-               case OPERATORFUNC:
-                       encodeOperatorElementFunctionSATEncoder(encoder, This);
-                       break;
-               default:
-                       ASSERT(0);
+void encodeElementFunctionSATEncoder(SATEncoder *encoder, ElementFunction *This) {
+       switch (GETFUNCTIONTYPE(This->function)) {
+       case TABLEFUNC:
+               encodeTableElementFunctionSATEncoder(encoder, This);
+               break;
+       case OPERATORFUNC:
+               encodeOperatorElementFunctionSATEncoder(encoder, This);
+               break;
+       default:
+               ASSERT(0);
        }
 }
 
        }
 }
 
-void encodeTableElementFunctionSATEncoder(SATEncoder* encoder, ElementFunction* This){
-       switch(getElementFunctionEncoding(This)->type){
-               case ENUMERATEIMPLICATIONS:
-                       encodeEnumTableElemFunctionSATEncoder(encoder, This);
-                       break;
-               case CIRCUIT:
-                       ASSERT(0);
-                       break;
-               default:
-                       ASSERT(0);
+void encodeTableElementFunctionSATEncoder(SATEncoder *encoder, ElementFunction *This) {
+       switch (getElementFunctionEncoding(This)->type) {
+       case ENUMERATEIMPLICATIONS:
+               encodeEnumTableElemFunctionSATEncoder(encoder, This);
+               break;
+       case CIRCUIT:
+               ASSERT(0);
+               break;
+       default:
+               ASSERT(0);
        }
 }
        }
 }
index aceb2714f6b90e823f8f7ec88f3f0c73067ad415..8db6239bff6ae5e9033a3fabd8030dc14bafd223 100644 (file)
@@ -8,28 +8,28 @@
 
 struct SATEncoder {
        uint varcount;
 
 struct SATEncoder {
        uint varcount;
-       CNF * cnf;
+       CNF *cnf;
 };
 
 #include "satelemencoder.h"
 #include "satorderencoder.h"
 #include "satfunctableencoder.h"
 
 };
 
 #include "satelemencoder.h"
 #include "satorderencoder.h"
 #include "satfunctableencoder.h"
 
-SATEncoder * allocSATEncoder();
+SATEncoder *allocSATEncoder();
 void deleteSATEncoder(SATEncoder *This);
 void encodeAllSATEncoder(CSolver *csolver, SATEncoder *This);
 Edge getNewVarSATEncoder(SATEncoder *This);
 void deleteSATEncoder(SATEncoder *This);
 void encodeAllSATEncoder(CSolver *csolver, SATEncoder *This);
 Edge getNewVarSATEncoder(SATEncoder *This);
-void getArrayNewVarsSATEncoder(SATEncoder* encoder, uint num, Edge*carray);
+void getArrayNewVarsSATEncoder(SATEncoder *encoder, uint num, Edge *carray);
 Edge encodeConstraintSATEncoder(SATEncoder *This, Boolean *constraint);
 Edge encodeConstraintSATEncoder(SATEncoder *This, Boolean *constraint);
-Edge encodeVarSATEncoder(SATEncoder *This, BooleanVar * constraint);
-Edge encodeLogicSATEncoder(SATEncoder *This, BooleanLogic * constraint);
-Edge encodePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
-Edge encodeTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
+Edge encodeVarSATEncoder(SATEncoder *This, BooleanVar *constraint);
+Edge encodeLogicSATEncoder(SATEncoder *This, BooleanLogic *constraint);
+Edge encodePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
+Edge encodeTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
 
 
 
 
 
 
-void encodeElementSATEncoder(SATEncoderencoder, Element *This);
-void encodeElementFunctionSATEncoder(SATEncoderencoder, ElementFunction *This);
-void encodeTableElementFunctionSATEncoder(SATEncoder* encoder, ElementFunction* This);
+void encodeElementSATEncoder(SATEncoder *encoder, Element *This);
+void encodeElementFunctionSATEncoder(SATEncoder *encoder, ElementFunction *This);
+void encodeTableElementFunctionSATEncoder(SATEncoder *encoder, ElementFunction *This);
 
 #endif
 
 #endif
index 1df9c61de5477ad77c992495845b010e3ffda63c..b8a814d54d46f43f3c33191cbc6818c70c274c54 100644 (file)
 #include "common.h"
 #include "satfuncopencoder.h"
 
 #include "common.h"
 #include "satfuncopencoder.h"
 
-Edge encodeOperatorPredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint) {
-       switch(constraint->encoding.type){
-               case ENUMERATEIMPLICATIONS:
-                       return encodeEnumOperatorPredicateSATEncoder(This, constraint);
-               case CIRCUIT:
-                       return encodeCircuitOperatorPredicateEncoder(This, constraint);
-               default:
-                       ASSERT(0);
+Edge encodeOperatorPredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
+       switch (constraint->encoding.type) {
+       case ENUMERATEIMPLICATIONS:
+               return encodeEnumOperatorPredicateSATEncoder(This, constraint);
+       case CIRCUIT:
+               return encodeCircuitOperatorPredicateEncoder(This, constraint);
+       default:
+               ASSERT(0);
        }
        exit(-1);
 }
 
        }
        exit(-1);
 }
 
-Edge encodeEnumOperatorPredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint) {
-       PredicateOperator* predicate = (PredicateOperator*)constraint->predicate;
-       uint numDomains=getSizeArraySet(&predicate->domains);
+Edge encodeEnumOperatorPredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
+       PredicateOperator *predicate = (PredicateOperator *)constraint->predicate;
+       uint numDomains = getSizeArraySet(&predicate->domains);
 
        FunctionEncodingType encType = constraint->encoding.type;
        bool generateNegation = encType == ENUMERATEIMPLICATIONSNEGATE;
 
        /* Call base encoders for children */
 
        FunctionEncodingType encType = constraint->encoding.type;
        bool generateNegation = encType == ENUMERATEIMPLICATIONSNEGATE;
 
        /* Call base encoders for children */
-       for(uint i=0;i<numDomains;i++) {
+       for (uint i = 0; i < numDomains; i++) {
                Element *elem = getArrayElement( &constraint->inputs, i);
                encodeElementSATEncoder(This, elem);
        }
                Element *elem = getArrayElement( &constraint->inputs, i);
                encodeElementSATEncoder(This, elem);
        }
-       VectorEdge * clauses=allocDefVectorEdge(); // Setup array of clauses
-       
-       uint indices[numDomains]; //setup indices
-       bzero(indices, sizeof(uint)*numDomains);
-       
-       uint64_t vals[numDomains]; //setup value array
-       for(uint i=0;i<numDomains; i++) {
-               Set * set=getArraySet(&predicate->domains, i);
-               vals[i]=getSetElement(set, indices[i]);
+       VectorEdge *clauses = allocDefVectorEdge();     // Setup array of clauses
+
+       uint indices[numDomains];       //setup indices
+       bzero(indices, sizeof(uint) * numDomains);
+
+       uint64_t vals[numDomains];//setup value array
+       for (uint i = 0; i < numDomains; i++) {
+               Set *set = getArraySet(&predicate->domains, i);
+               vals[i] = getSetElement(set, indices[i]);
        }
        }
-       
-       bool notfinished=true;
-       while(notfinished) {
+
+       bool notfinished = true;
+       while (notfinished) {
                Edge carray[numDomains];
 
                if (evalPredicateOperator(predicate, vals) ^ generateNegation) {
                        //Include this in the set of terms
                Edge carray[numDomains];
 
                if (evalPredicateOperator(predicate, vals) ^ generateNegation) {
                        //Include this in the set of terms
-                       for(uint i=0;i<numDomains;i++) {
-                               Element * elem = getArrayElement(&constraint->inputs, i);
+                       for (uint i = 0; i < numDomains; i++) {
+                               Element *elem = getArrayElement(&constraint->inputs, i);
                                carray[i] = getElementValueConstraint(This, elem, vals[i]);
                        }
                                carray[i] = getElementValueConstraint(This, elem, vals[i]);
                        }
-                       Edge term=constraintAND(This->cnf, numDomains, carray);
+                       Edge term = constraintAND(This->cnf, numDomains, carray);
                        pushVectorEdge(clauses, term);
                }
                        pushVectorEdge(clauses, term);
                }
-               
-               notfinished=false;
-               for(uint i=0;i<numDomains; i++) {
-                       uint index=++indices[i];
-                       Set * set=getArraySet(&predicate->domains, i);
+
+               notfinished = false;
+               for (uint i = 0; i < numDomains; i++) {
+                       uint index = ++indices[i];
+                       Set *set = getArraySet(&predicate->domains, i);
 
                        if (index < getSetSize(set)) {
 
                        if (index < getSetSize(set)) {
-                               vals[i]=getSetElement(set, index);
-                               notfinished=true;
+                               vals[i] = getSetElement(set, index);
+                               notfinished = true;
                                break;
                        } else {
                                break;
                        } else {
-                               indices[i]=0;
-                               vals[i]=getSetElement(set, 0);
+                               indices[i] = 0;
+                               vals[i] = getSetElement(set, 0);
                        }
                }
        }
                        }
                }
        }
-       if(getSizeVectorEdge(clauses) == 0) {
+       if (getSizeVectorEdge(clauses) == 0) {
                deleteVectorEdge(clauses);
                return E_False;
        }
                deleteVectorEdge(clauses);
                return E_False;
        }
-       Edge cor=constraintOR(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
+       Edge cor = constraintOR(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
        deleteVectorEdge(clauses);
        return generateNegation ? constraintNegate(cor) : cor;
 }
 
 
        deleteVectorEdge(clauses);
        return generateNegation ? constraintNegate(cor) : cor;
 }
 
 
-void encodeOperatorElementFunctionSATEncoder(SATEncoder* This, ElementFunction* func) {
+void encodeOperatorElementFunctionSATEncoder(SATEncoder *This, ElementFunction *func) {
 #ifdef TRACE_DEBUG
        model_print("Operator Function ...\n");
 #endif
 #ifdef TRACE_DEBUG
        model_print("Operator Function ...\n");
 #endif
-       FunctionOperator * function = (FunctionOperator *) func->function;
-       uint numDomains=getSizeArrayElement(&func->inputs);
+       FunctionOperator *function = (FunctionOperator *) func->function;
+       uint numDomains = getSizeArrayElement(&func->inputs);
 
        /* Call base encoders for children */
 
        /* Call base encoders for children */
-       for(uint i=0;i<numDomains;i++) {
+       for (uint i = 0; i < numDomains; i++) {
                Element *elem = getArrayElement( &func->inputs, i);
                encodeElementSATEncoder(This, elem);
        }
 
                Element *elem = getArrayElement( &func->inputs, i);
                encodeElementSATEncoder(This, elem);
        }
 
-       VectorEdge * clauses=allocDefVectorEdge(); // Setup array of clauses
-       
-       uint indices[numDomains]; //setup indices
-       bzero(indices, sizeof(uint)*numDomains);
-       
-       uint64_t vals[numDomains]; //setup value array
-       for(uint i=0;i<numDomains; i++) {
-               Set * set=getElementSet(getArrayElement(&func->inputs, i));
-               vals[i]=getSetElement(set, indices[i]);
+       VectorEdge *clauses = allocDefVectorEdge();     // Setup array of clauses
+
+       uint indices[numDomains];       //setup indices
+       bzero(indices, sizeof(uint) * numDomains);
+
+       uint64_t vals[numDomains];//setup value array
+       for (uint i = 0; i < numDomains; i++) {
+               Set *set = getElementSet(getArrayElement(&func->inputs, i));
+               vals[i] = getSetElement(set, indices[i]);
        }
 
        }
 
-       Edge overFlowConstraint = ((BooleanVar*) func->overflowstatus)->var;
-       
-       bool notfinished=true;
-       while(notfinished) {
-               Edge carray[numDomains+1];
+       Edge overFlowConstraint = ((BooleanVar *) func->overflowstatus)->var;
+
+       bool notfinished = true;
+       while (notfinished) {
+               Edge carray[numDomains + 1];
 
 
-               uint64_t result=applyFunctionOperator(function, numDomains, vals);
-               bool isInRange = isInRangeFunction((FunctionOperator*)func->function, result);
+               uint64_t result = applyFunctionOperator(function, numDomains, vals);
+               bool isInRange = isInRangeFunction((FunctionOperator *)func->function, result);
                bool needClause = isInRange;
                if (function->overflowbehavior == OVERFLOWSETSFLAG || function->overflowbehavior == FLAGIFFOVERFLOW) {
                bool needClause = isInRange;
                if (function->overflowbehavior == OVERFLOWSETSFLAG || function->overflowbehavior == FLAGIFFOVERFLOW) {
-                       needClause=true;
+                       needClause = true;
                }
                }
-               
+
                if (needClause) {
                        //Include this in the set of terms
                if (needClause) {
                        //Include this in the set of terms
-                       for(uint i=0;i<numDomains;i++) {
-                               Element * elem = getArrayElement(&func->inputs, i);
+                       for (uint i = 0; i < numDomains; i++) {
+                               Element *elem = getArrayElement(&func->inputs, i);
                                carray[i] = getElementValueConstraint(This, elem, vals[i]);
                        }
                        if (isInRange) {
                                carray[i] = getElementValueConstraint(This, elem, vals[i]);
                        }
                        if (isInRange) {
@@ -133,30 +133,30 @@ void encodeOperatorElementFunctionSATEncoder(SATEncoder* This, ElementFunction*
                        }
 
                        Edge clause;
                        }
 
                        Edge clause;
-                       switch(function->overflowbehavior) {
+                       switch (function->overflowbehavior) {
                        case IGNORE:
                        case NOOVERFLOW:
                        case WRAPAROUND: {
                        case IGNORE:
                        case NOOVERFLOW:
                        case WRAPAROUND: {
-                               clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
+                               clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
                                break;
                        }
                        case FLAGFORCESOVERFLOW: {
                                break;
                        }
                        case FLAGFORCESOVERFLOW: {
-                               clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintAND2(This->cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
+                               clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintAND2(This->cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
                                break;
                        }
                        case OVERFLOWSETSFLAG: {
                                if (isInRange) {
                                break;
                        }
                        case OVERFLOWSETSFLAG: {
                                if (isInRange) {
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
+                                       clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
                                } else {
                                } else {
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), overFlowConstraint);
+                                       clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), overFlowConstraint);
                                }
                                break;
                        }
                        case FLAGIFFOVERFLOW: {
                                if (isInRange) {
                                }
                                break;
                        }
                        case FLAGIFFOVERFLOW: {
                                if (isInRange) {
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintAND2(This->cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
+                                       clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintAND2(This->cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
                                } else {
                                } else {
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), overFlowConstraint);
+                                       clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), overFlowConstraint);
                                }
                                break;
                        }
                                }
                                break;
                        }
@@ -170,35 +170,35 @@ void encodeOperatorElementFunctionSATEncoder(SATEncoder* This, ElementFunction*
 #endif
                        pushVectorEdge(clauses, clause);
                }
 #endif
                        pushVectorEdge(clauses, clause);
                }
-               
-               notfinished=false;
-               for(uint i=0;i<numDomains; i++) {
-                       uint index=++indices[i];
-                       Set * set=getElementSet(getArrayElement(&func->inputs, i));
+
+               notfinished = false;
+               for (uint i = 0; i < numDomains; i++) {
+                       uint index = ++indices[i];
+                       Set *set = getElementSet(getArrayElement(&func->inputs, i));
 
                        if (index < getSetSize(set)) {
 
                        if (index < getSetSize(set)) {
-                               vals[i]=getSetElement(set, index);
-                               notfinished=true;
+                               vals[i] = getSetElement(set, index);
+                               notfinished = true;
                                break;
                        } else {
                                break;
                        } else {
-                               indices[i]=0;
-                               vals[i]=getSetElement(set, 0);
+                               indices[i] = 0;
+                               vals[i] = getSetElement(set, 0);
                        }
                }
        }
                        }
                }
        }
-       if(getSizeVectorEdge(clauses) == 0){
+       if (getSizeVectorEdge(clauses) == 0) {
                deleteVectorEdge(clauses);
                return;
        }
                deleteVectorEdge(clauses);
                return;
        }
-       Edge cor=constraintAND(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
+       Edge cor = constraintAND(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
        addConstraintCNF(This->cnf, cor);
        deleteVectorEdge(clauses);
 }
 
        addConstraintCNF(This->cnf, cor);
        deleteVectorEdge(clauses);
 }
 
-Edge encodeCircuitOperatorPredicateEncoder(SATEncoder *This, BooleanPredicate * constraint) {
-       PredicateOperator * predicate = (PredicateOperator*) constraint->predicate;
-       
-       switch(predicate->op) {
+Edge encodeCircuitOperatorPredicateEncoder(SATEncoder *This, BooleanPredicate *constraint) {
+       PredicateOperator *predicate = (PredicateOperator *) constraint->predicate;
+
+       switch (predicate->op) {
        case EQUALS: {
                return encodeCircuitEquals(This, constraint);
        }
        case EQUALS: {
                return encodeCircuitEquals(This, constraint);
        }
@@ -208,21 +208,21 @@ Edge encodeCircuitOperatorPredicateEncoder(SATEncoder *This, BooleanPredicate *
        exit(-1);
 }
 
        exit(-1);
 }
 
-Edge encodeCircuitEquals(SATEncoder * This, BooleanPredicate * constraint) {
-       PredicateOperator * predicate = (PredicateOperator*) constraint->predicate;
+Edge encodeCircuitEquals(SATEncoder *This, BooleanPredicate *constraint) {
+       PredicateOperator *predicate = (PredicateOperator *) constraint->predicate;
        ASSERT(getSizeArraySet(&predicate->domains) == 2);
        Element *elem0 = getArrayElement( &constraint->inputs, 0);
        encodeElementSATEncoder(This, elem0);
        Element *elem1 = getArrayElement( &constraint->inputs, 1);
        encodeElementSATEncoder(This, elem1);
        ASSERT(getSizeArraySet(&predicate->domains) == 2);
        Element *elem0 = getArrayElement( &constraint->inputs, 0);
        encodeElementSATEncoder(This, elem0);
        Element *elem1 = getArrayElement( &constraint->inputs, 1);
        encodeElementSATEncoder(This, elem1);
-       ElementEncoding *ee0=getElementEncoding(elem0);
-       ElementEncoding *ee1=getElementEncoding(elem1);
-       ASSERT(ee0->numVars==ee1->numVars);
-       uint numVars=ee0->numVars;
+       ElementEncoding *ee0 = getElementEncoding(elem0);
+       ElementEncoding *ee1 = getElementEncoding(elem1);
+       ASSERT(ee0->numVars == ee1->numVars);
+       uint numVars = ee0->numVars;
        ASSERT(numVars != 0);
        Edge carray[numVars];
        ASSERT(numVars != 0);
        Edge carray[numVars];
-       for (uint i=0; i<numVars; i++) {
-               carray[i]=constraintIFF(This->cnf, ee0->variables[i], ee1->variables[i]);
+       for (uint i = 0; i < numVars; i++) {
+               carray[i] = constraintIFF(This->cnf, ee0->variables[i], ee1->variables[i]);
        }
        return constraintAND(This->cnf, numVars, carray);
 }
        }
        return constraintAND(This->cnf, numVars, carray);
 }
index 0bfca3dc2054c3a8ece05561a1cc3402327fddc0..8b39194026bdcba11fa6767e15fee70d228fa44b 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef SATFUNCOPENCODER_H
 #define SATFUNCOPENCODER_H
 
 #ifndef SATFUNCOPENCODER_H
 #define SATFUNCOPENCODER_H
 
-Edge encodeOperatorPredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
-Edge encodeEnumOperatorPredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
-void encodeOperatorElementFunctionSATEncoder(SATEncoder* encoder,ElementFunction* This);
-Edge encodeCircuitOperatorPredicateEncoder(SATEncoder *This, BooleanPredicate * constraint);
-Edge encodeCircuitEquals(SATEncoder * This, BooleanPredicate * constraint);
+Edge encodeOperatorPredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
+Edge encodeEnumOperatorPredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
+void encodeOperatorElementFunctionSATEncoder(SATEncoder *encoder,ElementFunction *This);
+Edge encodeCircuitOperatorPredicateEncoder(SATEncoder *This, BooleanPredicate *constraint);
+Edge encodeCircuitEquals(SATEncoder *This, BooleanPredicate *constraint);
 
 #endif
 
 #endif
index 7e81dfdda8fbf2a407438ec6f05a8f1846a6ce48..d37e6dc96bce777ee87caf8964925550983400f9 100644 (file)
 #include "element.h"
 #include "common.h"
 
 #include "element.h"
 #include "common.h"
 
-Edge encodeEnumEntriesTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint){
+Edge encodeEnumEntriesTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
        ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
        ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
-       UndefinedBehavior undefStatus = ((PredicateTable*)constraint->predicate)->undefinedbehavior;
+       UndefinedBehavior undefStatus = ((PredicateTable *)constraint->predicate)->undefinedbehavior;
        ASSERT(undefStatus == IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
        ASSERT(undefStatus == IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
-       Table* table = ((PredicateTable*)constraint->predicate)->table;
+       Table *table = ((PredicateTable *)constraint->predicate)->table;
        FunctionEncodingType encType = constraint->encoding.type;
        FunctionEncodingType encType = constraint->encoding.type;
-       ArrayElementinputs = &constraint->inputs;
-       uint inputNum =getSizeArrayElement(inputs);
+       ArrayElement *inputs = &constraint->inputs;
+       uint inputNum = getSizeArrayElement(inputs);
        uint size = getSizeHashSetTableEntry(table->entries);
        bool generateNegation = encType == ENUMERATEIMPLICATIONSNEGATE;
        Edge constraints[size];
        Edge undefConst = encodeConstraintSATEncoder(This, constraint->undefStatus);
        printCNF(undefConst);
        model_print("**\n");
        uint size = getSizeHashSetTableEntry(table->entries);
        bool generateNegation = encType == ENUMERATEIMPLICATIONSNEGATE;
        Edge constraints[size];
        Edge undefConst = encodeConstraintSATEncoder(This, constraint->undefStatus);
        printCNF(undefConst);
        model_print("**\n");
-       HSIteratorTableEntryiterator = iteratorTableEntry(table->entries);
-       uint i=0;
-       while(hasNextTableEntry(iterator)){
-               TableEntryentry = nextTableEntry(iterator);
-               if(generateNegation == entry->output && undefStatus == IGNOREBEHAVIOR) {
+       HSIteratorTableEntry *iterator = iteratorTableEntry(table->entries);
+       uint i = 0;
+       while (hasNextTableEntry(iterator)) {
+               TableEntry *entry = nextTableEntry(iterator);
+               if (generateNegation == entry->output && undefStatus == IGNOREBEHAVIOR) {
                        //Skip the irrelevant entries
                        continue;
                }
                Edge carray[inputNum];
                        //Skip the irrelevant entries
                        continue;
                }
                Edge carray[inputNum];
-               for(uint j=0; j<inputNum; j++){
-                       Elementel = getArrayElement(inputs, j);
+               for (uint j = 0; j < inputNum; j++) {
+                       Element *el = getArrayElement(inputs, j);
                        carray[j] = getElementValueConstraint(This, el, entry->inputs[j]);
                        printCNF(carray[j]);
                        model_print("\n");
                }
                Edge row;
                        carray[j] = getElementValueConstraint(This, el, entry->inputs[j]);
                        printCNF(carray[j]);
                        model_print("\n");
                }
                Edge row;
-               switch(undefStatus){
-                       case IGNOREBEHAVIOR:
-                               row=constraintAND(This->cnf, inputNum, carray);
-                               break;
-                       case FLAGFORCEUNDEFINED:{
-                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray),  constraintNegate(undefConst)));
-                               if(generateNegation == entry->output){
-                                       continue;
-                               }
-                               row=constraintAND(This->cnf, inputNum, carray);
-                               break;
+               switch (undefStatus) {
+               case IGNOREBEHAVIOR:
+                       row = constraintAND(This->cnf, inputNum, carray);
+                       break;
+               case FLAGFORCEUNDEFINED: {
+                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray),  constraintNegate(undefConst)));
+                       if (generateNegation == entry->output) {
+                               continue;
                        }
                        }
-                       default:
-                               ASSERT(0);
+                       row = constraintAND(This->cnf, inputNum, carray);
+                       break;
+               }
+               default:
+                       ASSERT(0);
                }
                constraints[i++] = row;
                printCNF(row);
                }
                constraints[i++] = row;
                printCNF(row);
-               
+
                model_print("\n\n");
        }
        deleteIterTableEntry(iterator);
                model_print("\n\n");
        }
        deleteIterTableEntry(iterator);
-       ASSERT(i!=0);
-       Edge result= generateNegation?constraintNegate(constraintOR(This->cnf, i, constraints))
-               :constraintOR(This->cnf, i, constraints);
+       ASSERT(i != 0);
+       Edge result = generateNegation ? constraintNegate(constraintOR(This->cnf, i, constraints))
+                                                               : constraintOR(This->cnf, i, constraints);
        printCNF(result);
        return result;
 }
        printCNF(result);
        return result;
 }
-Edge encodeEnumTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint){
+Edge encodeEnumTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint) {
 #ifdef TRACE_DEBUG
        model_print("Enumeration Table Predicate ...\n");
 #endif
        ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
        //First encode children
 #ifdef TRACE_DEBUG
        model_print("Enumeration Table Predicate ...\n");
 #endif
        ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
        //First encode children
-       ArrayElementinputs = &constraint->inputs;
-       uint inputNum =getSizeArrayElement(inputs);
+       ArrayElement *inputs = &constraint->inputs;
+       uint inputNum = getSizeArrayElement(inputs);
        //Encode all the inputs first ...
        //Encode all the inputs first ...
-       for(uint i=0; i<inputNum; i++){
+       for (uint i = 0; i < inputNum; i++) {
                encodeElementSATEncoder(This, getArrayElement(inputs, i));
        }
                encodeElementSATEncoder(This, getArrayElement(inputs, i));
        }
-       PredicateTable* predicate = (PredicateTable*)constraint->predicate;
-       switch(predicate->undefinedbehavior){
-               case IGNOREBEHAVIOR:
-               case FLAGFORCEUNDEFINED:
-                       return encodeEnumEntriesTablePredicateSATEncoder(This, constraint);
-               default:
-                       break;
+       PredicateTable *predicate = (PredicateTable *)constraint->predicate;
+       switch (predicate->undefinedbehavior) {
+       case IGNOREBEHAVIOR:
+       case FLAGFORCEUNDEFINED:
+               return encodeEnumEntriesTablePredicateSATEncoder(This, constraint);
+       default:
+               break;
        }
        bool generateNegation = constraint->encoding.type == ENUMERATEIMPLICATIONSNEGATE;
        }
        bool generateNegation = constraint->encoding.type == ENUMERATEIMPLICATIONSNEGATE;
-       uint numDomains=getSizeArraySet(&predicate->table->domains);
+       uint numDomains = getSizeArraySet(&predicate->table->domains);
 
 
-       VectorEdge * clauses=allocDefVectorEdge();
-       
-       uint indices[numDomains]; //setup indices
-       bzero(indices, sizeof(uint)*numDomains);
-       
-       uint64_t vals[numDomains]; //setup value array
-       for(uint i=0;i<numDomains; i++) {
-               Set * set=getArraySet(&predicate->table->domains, i);
-               vals[i]=getSetElement(set, indices[i]);
+       VectorEdge *clauses = allocDefVectorEdge();
+
+       uint indices[numDomains];       //setup indices
+       bzero(indices, sizeof(uint) * numDomains);
+
+       uint64_t vals[numDomains];//setup value array
+       for (uint i = 0; i < numDomains; i++) {
+               Set *set = getArraySet(&predicate->table->domains, i);
+               vals[i] = getSetElement(set, indices[i]);
        }
        bool hasOverflow = false;
        Edge undefConstraint = encodeConstraintSATEncoder (This, constraint->undefStatus);
        printCNF(undefConstraint);
        }
        bool hasOverflow = false;
        Edge undefConstraint = encodeConstraintSATEncoder (This, constraint->undefStatus);
        printCNF(undefConstraint);
-       bool notfinished=true;
-       while(notfinished) {
+       bool notfinished = true;
+       while (notfinished) {
                Edge carray[numDomains];
                Edge carray[numDomains];
-               TableEntrytableEntry = getTableEntryFromTable(predicate->table, vals, numDomains);
-               bool isInRange = tableEntry!=NULL;
-               if(!isInRange && !hasOverflow){
-                       hasOverflow=true;
+               TableEntry *tableEntry = getTableEntryFromTable(predicate->table, vals, numDomains);
+               bool isInRange = tableEntry != NULL;
+               if (!isInRange && !hasOverflow) {
+                       hasOverflow = true;
                }
                Edge clause;
                }
                Edge clause;
-               for(uint i=0;i<numDomains;i++) {
-                               Element * elem = getArrayElement(&constraint->inputs, i);
-                               carray[i] = getElementValueConstraint(This, elem, vals[i]);
+               for (uint i = 0; i < numDomains; i++) {
+                       Element *elem = getArrayElement(&constraint->inputs, i);
+                       carray[i] = getElementValueConstraint(This, elem, vals[i]);
                }
                }
-       
-               switch(predicate->undefinedbehavior) {
-                       case UNDEFINEDSETSFLAG:
-                               if(isInRange){
-                                       clause=constraintAND(This->cnf, numDomains, carray);
-                               }else{
-                                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint) );
-                               }
-                               break;
-                       case FLAGIFFUNDEFINED:
-                               if(isInRange){
-                                       clause=constraintAND(This->cnf, numDomains, carray);
-                                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintNegate(undefConstraint)));
-                               }else{
-                                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint) );
-                               }
-                               break;
 
 
-                       default:
-                               ASSERT(0);
+               switch (predicate->undefinedbehavior) {
+               case UNDEFINEDSETSFLAG:
+                       if (isInRange) {
+                               clause = constraintAND(This->cnf, numDomains, carray);
+                       } else {
+                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint) );
+                       }
+                       break;
+               case FLAGIFFUNDEFINED:
+                       if (isInRange) {
+                               clause = constraintAND(This->cnf, numDomains, carray);
+                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), constraintNegate(undefConstraint)));
+                       } else {
+                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint) );
+                       }
+                       break;
+
+               default:
+                       ASSERT(0);
                }
                }
-               
-               if(isInRange){
+
+               if (isInRange) {
 #ifdef TRACE_DEBUG
                        model_print("added clause in predicate table enumeration ...\n");
                        printCNF(clause);
 #ifdef TRACE_DEBUG
                        model_print("added clause in predicate table enumeration ...\n");
                        printCNF(clause);
@@ -146,29 +146,29 @@ Edge encodeEnumTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * co
 #endif
                        pushVectorEdge(clauses, clause);
                }
 #endif
                        pushVectorEdge(clauses, clause);
                }
-               
-               notfinished=false;
-               for(uint i=0;i<numDomains; i++) {
-                       uint index=++indices[i];
-                       Set * set=getArraySet(&predicate->table->domains, i);
+
+               notfinished = false;
+               for (uint i = 0; i < numDomains; i++) {
+                       uint index = ++indices[i];
+                       Set *set = getArraySet(&predicate->table->domains, i);
 
                        if (index < getSetSize(set)) {
 
                        if (index < getSetSize(set)) {
-                               vals[i]=getSetElement(set, index);
-                               notfinished=true;
+                               vals[i] = getSetElement(set, index);
+                               notfinished = true;
                                break;
                        } else {
                                break;
                        } else {
-                               indices[i]=0;
-                               vals[i]=getSetElement(set, 0);
+                               indices[i] = 0;
+                               vals[i] = getSetElement(set, 0);
                        }
                }
        }
        Edge result = E_NULL;
        ASSERT(getSizeVectorEdge(clauses) != 0);
                        }
                }
        }
        Edge result = E_NULL;
        ASSERT(getSizeVectorEdge(clauses) != 0);
-       result=constraintOR(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
-       if(hasOverflow){
+       result = constraintOR(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
+       if (hasOverflow) {
                result = constraintOR2(This->cnf, result, undefConstraint);
        }
                result = constraintOR2(This->cnf, result, undefConstraint);
        }
-       if(generateNegation){
+       if (generateNegation) {
                ASSERT(!hasOverflow);
                result = constraintNegate(result);
        }
                ASSERT(!hasOverflow);
                result = constraintNegate(result);
        }
@@ -176,119 +176,119 @@ Edge encodeEnumTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * co
        return result;
 }
 
        return result;
 }
 
-void encodeEnumEntriesTableElemFuncSATEncoder(SATEncoder* This, ElementFunction* func){
-       UndefinedBehavior undefStatus = ((FunctionTable*) func->function)->undefBehavior;
+void encodeEnumEntriesTableElemFuncSATEncoder(SATEncoder *This, ElementFunction *func) {
+       UndefinedBehavior undefStatus = ((FunctionTable *) func->function)->undefBehavior;
        ASSERT(undefStatus == IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
        ASSERT(undefStatus == IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
-       ArrayElement* elements= &func->inputs;
-       Table* table = ((FunctionTable*) (func->function))->table;
+       ArrayElement *elements = &func->inputs;
+       Table *table = ((FunctionTable *) (func->function))->table;
        uint size = getSizeHashSetTableEntry(table->entries);
        Edge constraints[size];
        uint size = getSizeHashSetTableEntry(table->entries);
        Edge constraints[size];
-       HSIteratorTableEntryiterator = iteratorTableEntry(table->entries);
-       uint i=0;
-       while(hasNextTableEntry(iterator)) {
-               TableEntryentry = nextTableEntry(iterator);
-               ASSERT(entry!=NULL);
+       HSIteratorTableEntry *iterator = iteratorTableEntry(table->entries);
+       uint i = 0;
+       while (hasNextTableEntry(iterator)) {
+               TableEntry *entry = nextTableEntry(iterator);
+               ASSERT(entry != NULL);
                uint inputNum = getSizeArrayElement(elements);
                Edge carray[inputNum];
                uint inputNum = getSizeArrayElement(elements);
                Edge carray[inputNum];
-               for(uint j=0; j<inputNum; j++){
-                       Element* el= getArrayElement(elements, j);
+               for (uint j = 0; j < inputNum; j++) {
+                       Element *el = getArrayElement(elements, j);
                        carray[j] = getElementValueConstraint(This, el, entry->inputs[j]);
                }
                        carray[j] = getElementValueConstraint(This, el, entry->inputs[j]);
                }
-               Edge output = getElementValueConstraint(This, (Element*)func, entry->output);
+               Edge output = getElementValueConstraint(This, (Element *)func, entry->output);
                Edge row;
                Edge row;
-               switch(undefStatus ){
-                       case IGNOREBEHAVIOR: {
-                               row=constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray), output);
-                               break;
-                       }
-                       case FLAGFORCEUNDEFINED: {
-                               Edge undefConst = encodeConstraintSATEncoder(This, func->overflowstatus);
-                               row=constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray), constraintAND2(This->cnf, output, constraintNegate(undefConst)));
-                               break;
-                       }
-                       default:
-                               ASSERT(0);
-               
+               switch (undefStatus ) {
+               case IGNOREBEHAVIOR: {
+                       row = constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray), output);
+                       break;
+               }
+               case FLAGFORCEUNDEFINED: {
+                       Edge undefConst = encodeConstraintSATEncoder(This, func->overflowstatus);
+                       row = constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray), constraintAND2(This->cnf, output, constraintNegate(undefConst)));
+                       break;
+               }
+               default:
+                       ASSERT(0);
+
                }
                }
-               constraints[i++]=row;
+               constraints[i++] = row;
        }
        deleteIterTableEntry(iterator);
        addConstraintCNF(This->cnf, constraintAND(This->cnf, size, constraints));
 }
 
        }
        deleteIterTableEntry(iterator);
        addConstraintCNF(This->cnf, constraintAND(This->cnf, size, constraints));
 }
 
-void encodeEnumTableElemFunctionSATEncoder(SATEncoder* This, ElementFunction* elemFunc){
+void encodeEnumTableElemFunctionSATEncoder(SATEncoder *This, ElementFunction *elemFunc) {
 #ifdef TRACE_DEBUG
        model_print("Enumeration Table functions ...\n");
 #endif
 #ifdef TRACE_DEBUG
        model_print("Enumeration Table functions ...\n");
 #endif
-       ASSERT(GETFUNCTIONTYPE(elemFunc->function)==TABLEFUNC);
+       ASSERT(GETFUNCTIONTYPE(elemFunc->function) == TABLEFUNC);
        //First encode children
        //First encode children
-       ArrayElement* elements= &elemFunc->inputs;
-       for(uint i=0; i<getSizeArrayElement(elements); i++){
+       ArrayElement *elements = &elemFunc->inputs;
+       for (uint i = 0; i < getSizeArrayElement(elements); i++) {
                Element *elem = getArrayElement( elements, i);
                encodeElementSATEncoder(This, elem);
        }
 
                Element *elem = getArrayElement( elements, i);
                encodeElementSATEncoder(This, elem);
        }
 
-       FunctionTable* function =(FunctionTable*)elemFunc->function;
-       switch(function->undefBehavior){
-               case IGNOREBEHAVIOR:
-               case FLAGFORCEUNDEFINED:
-                       return encodeEnumEntriesTableElemFuncSATEncoder(This, elemFunc);
-               default:
-                       break;
+       FunctionTable *function = (FunctionTable *)elemFunc->function;
+       switch (function->undefBehavior) {
+       case IGNOREBEHAVIOR:
+       case FLAGFORCEUNDEFINED:
+               return encodeEnumEntriesTableElemFuncSATEncoder(This, elemFunc);
+       default:
+               break;
        }
        }
-       
-       uint numDomains=getSizeArraySet(&function->table->domains);
 
 
-       VectorEdge * clauses=allocDefVectorEdge(); // Setup array of clauses
-       
-       uint indices[numDomains]; //setup indices
-       bzero(indices, sizeof(uint)*numDomains);
-       
-       uint64_t vals[numDomains]; //setup value array
-       for(uint i=0;i<numDomains; i++) {
-               Set * set=getArraySet(&function->table->domains, i);
-               vals[i]=getSetElement(set, indices[i]);
+       uint numDomains = getSizeArraySet(&function->table->domains);
+
+       VectorEdge *clauses = allocDefVectorEdge();     // Setup array of clauses
+
+       uint indices[numDomains];       //setup indices
+       bzero(indices, sizeof(uint) * numDomains);
+
+       uint64_t vals[numDomains];//setup value array
+       for (uint i = 0; i < numDomains; i++) {
+               Set *set = getArraySet(&function->table->domains, i);
+               vals[i] = getSetElement(set, indices[i]);
        }
 
        Edge undefConstraint = encodeConstraintSATEncoder(This, elemFunc->overflowstatus);
        }
 
        Edge undefConstraint = encodeConstraintSATEncoder(This, elemFunc->overflowstatus);
-       bool notfinished=true;
-       while(notfinished) {
-               Edge carray[numDomains+1];
-               TableEntrytableEntry = getTableEntryFromTable(function->table, vals, numDomains);
-               bool isInRange = tableEntry!=NULL;
+       bool notfinished = true;
+       while (notfinished) {
+               Edge carray[numDomains + 1];
+               TableEntry *tableEntry = getTableEntryFromTable(function->table, vals, numDomains);
+               bool isInRange = tableEntry != NULL;
                ASSERT(function->undefBehavior == UNDEFINEDSETSFLAG || function->undefBehavior == FLAGIFFUNDEFINED);
                ASSERT(function->undefBehavior == UNDEFINEDSETSFLAG || function->undefBehavior == FLAGIFFUNDEFINED);
-               for(uint i=0;i<numDomains;i++) {
-                       Element * elem = getArrayElement(&elemFunc->inputs, i);
+               for (uint i = 0; i < numDomains; i++) {
+                       Element *elem = getArrayElement(&elemFunc->inputs, i);
                        carray[i] = getElementValueConstraint(This, elem, vals[i]);
                }
                if (isInRange) {
                        carray[i] = getElementValueConstraint(This, elem, vals[i]);
                }
                if (isInRange) {
-                       carray[numDomains] = getElementValueConstraint(This, (Element*)elemFunc, tableEntry->output);
+                       carray[numDomains] = getElementValueConstraint(This, (Element *)elemFunc, tableEntry->output);
                }
 
                Edge clause;
                }
 
                Edge clause;
-               switch(function->undefBehavior) {
-                       case UNDEFINEDSETSFLAG: {
-                               if (isInRange) {
-                                       //FIXME: Talk to Brian, It should be IFF not only IMPLY. --HG
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
-                               } else {
-                                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint));
-                               }
-                               break;
+               switch (function->undefBehavior) {
+               case UNDEFINEDSETSFLAG: {
+                       if (isInRange) {
+                               //FIXME: Talk to Brian, It should be IFF not only IMPLY. --HG
+                               clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
+                       } else {
+                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), undefConstraint));
                        }
                        }
-                       case FLAGIFFUNDEFINED: {
-                               if (isInRange) {
-                                       clause=constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
-                                       addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf, constraintAND(This->cnf, numDomains, carray), constraintNegate(undefConstraint) ));
-                               } else {
-                                       addConstraintCNF(This->cnf,constraintIMPLIES(This->cnf, constraintAND(This->cnf, numDomains, carray), undefConstraint));
-                               }
-                               break;
+                       break;
+               }
+               case FLAGIFFUNDEFINED: {
+                       if (isInRange) {
+                               clause = constraintIMPLIES(This->cnf,constraintAND(This->cnf, numDomains, carray), carray[numDomains]);
+                               addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf, constraintAND(This->cnf, numDomains, carray), constraintNegate(undefConstraint) ));
+                       } else {
+                               addConstraintCNF(This->cnf,constraintIMPLIES(This->cnf, constraintAND(This->cnf, numDomains, carray), undefConstraint));
                        }
                        }
-                       default:
-                               ASSERT(0);
+                       break;
+               }
+               default:
+                       ASSERT(0);
                }
                }
-               if(isInRange){
+               if (isInRange) {
 #ifdef TRACE_DEBUG
                        model_print("added clause in function table enumeration ...\n");
                        printCNF(clause);
 #ifdef TRACE_DEBUG
                        model_print("added clause in function table enumeration ...\n");
                        printCNF(clause);
@@ -296,28 +296,28 @@ void encodeEnumTableElemFunctionSATEncoder(SATEncoder* This, ElementFunction* el
 #endif
                        pushVectorEdge(clauses, clause);
                }
 #endif
                        pushVectorEdge(clauses, clause);
                }
-               
-               notfinished=false;
-               for(uint i=0;i<numDomains; i++) {
-                       uint index=++indices[i];
-                       Set * set=getArraySet(&function->table->domains, i);
+
+               notfinished = false;
+               for (uint i = 0; i < numDomains; i++) {
+                       uint index = ++indices[i];
+                       Set *set = getArraySet(&function->table->domains, i);
 
                        if (index < getSetSize(set)) {
 
                        if (index < getSetSize(set)) {
-                               vals[i]=getSetElement(set, index);
-                               notfinished=true;
+                               vals[i] = getSetElement(set, index);
+                               notfinished = true;
                                break;
                        } else {
                                break;
                        } else {
-                               indices[i]=0;
-                               vals[i]=getSetElement(set, 0);
+                               indices[i] = 0;
+                               vals[i] = getSetElement(set, 0);
                        }
                }
        }
                        }
                }
        }
-       if(getSizeVectorEdge(clauses) == 0){
+       if (getSizeVectorEdge(clauses) == 0) {
                deleteVectorEdge(clauses);
                return;
        }
                deleteVectorEdge(clauses);
                return;
        }
-       Edge cor=constraintAND(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
+       Edge cor = constraintAND(This->cnf, getSizeVectorEdge(clauses), exposeArrayEdge(clauses));
        addConstraintCNF(This->cnf, cor);
        deleteVectorEdge(clauses);
        addConstraintCNF(This->cnf, cor);
        deleteVectorEdge(clauses);
-       
+
 }
 }
index 6ac111c2c3aba878a60a0438d9f4df4ed8016487..ad11a1cc5bfef065b26fe73da26bb7d0b19f94fe 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef SATFUNCTABLEENCODER_H
 #define SATFUNCTABLEENCODER_H
 
 #ifndef SATFUNCTABLEENCODER_H
 #define SATFUNCTABLEENCODER_H
 
-Edge encodeEnumEntriesTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
-Edge encodeEnumTablePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint);
-void encodeEnumTableElemFunctionSATEncoder(SATEncoder* encoder, ElementFunction* This);
-void encodeEnumEntriesTableElemFuncSATEncoder(SATEncoder* encoder, ElementFunction* This);
+Edge encodeEnumEntriesTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
+Edge encodeEnumTablePredicateSATEncoder(SATEncoder *This, BooleanPredicate *constraint);
+void encodeEnumTableElemFunctionSATEncoder(SATEncoder *encoder, ElementFunction *This);
+void encodeEnumEntriesTableElemFuncSATEncoder(SATEncoder *encoder, ElementFunction *This);
 
 #endif
 
 #endif
index e8a7f3d6b388c9dd359e1bfc489dcd66506e3c06..0b2622d0d96d66246bfbf9bc5e3709cd917d230a 100644 (file)
@@ -5,31 +5,31 @@
 #include "orderpair.h"
 #include "set.h"
 
 #include "orderpair.h"
 #include "set.h"
 
-Edge encodeOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint) {
-       switch( constraint->order->type){
-               case PARTIAL:
-                       return encodePartialOrderSATEncoder(This, constraint);
-               case TOTAL:
-                       return encodeTotalOrderSATEncoder(This, constraint);
-               default:
-                       ASSERT(0);
+Edge encodeOrderSATEncoder(SATEncoder *This, BooleanOrder *constraint) {
+       switch ( constraint->order->type) {
+       case PARTIAL:
+               return encodePartialOrderSATEncoder(This, constraint);
+       case TOTAL:
+               return encodeTotalOrderSATEncoder(This, constraint);
+       default:
+               ASSERT(0);
        }
        return E_BOGUS;
 }
 
        }
        return E_BOGUS;
 }
 
-Edge getPairConstraint(SATEncoder *This, HashTableOrderPair * table, OrderPair * pair) {
+Edge getPairConstraint(SATEncoder *This, HashTableOrderPair *table, OrderPair *pair) {
        bool negate = false;
        OrderPair flipped;
        if (pair->first < pair->second) {
        bool negate = false;
        OrderPair flipped;
        if (pair->first < pair->second) {
-               negate=true;
-               flipped.first=pair->second;
-               flipped.second=pair->first;
+               negate = true;
+               flipped.first = pair->second;
+               flipped.second = pair->first;
                pair = &flipped;
        }
        Edge constraint;
        if (!containsOrderPair(table, pair)) {
                constraint = getNewVarSATEncoder(This);
                pair = &flipped;
        }
        Edge constraint;
        if (!containsOrderPair(table, pair)) {
                constraint = getNewVarSATEncoder(This);
-               OrderPair * paircopy = allocOrderPair(pair->first, pair->second, constraint);
+               OrderPair *paircopy = allocOrderPair(pair->first, pair->second, constraint);
                putOrderPair(table, paircopy, paircopy);
        } else
                constraint = getOrderPair(table, pair)->constraint;
                putOrderPair(table, paircopy, paircopy);
        } else
                constraint = getOrderPair(table, pair)->constraint;
@@ -37,72 +37,72 @@ Edge getPairConstraint(SATEncoder *This, HashTableOrderPair * table, OrderPair *
        return negate ? constraintNegate(constraint) : constraint;
 }
 
        return negate ? constraintNegate(constraint) : constraint;
 }
 
-Edge encodeTotalOrderSATEncoder(SATEncoder *This, BooleanOrder * boolOrder) {
+Edge encodeTotalOrderSATEncoder(SATEncoder *This, BooleanOrder *boolOrder) {
        ASSERT(boolOrder->order->type == TOTAL);
        ASSERT(boolOrder->order->type == TOTAL);
-       if(boolOrder->order->orderPairTable == NULL) {
+       if (boolOrder->order->orderPairTable == NULL) {
                initializeOrderHashTable(boolOrder->order);
                createAllTotalOrderConstraintsSATEncoder(This, boolOrder->order);
        }
                initializeOrderHashTable(boolOrder->order);
                createAllTotalOrderConstraintsSATEncoder(This, boolOrder->order);
        }
-       HashTableOrderPairorderPairTable = boolOrder->order->orderPairTable;
-       OrderPair pair={boolOrder->first, boolOrder->second, E_NULL};
-       Edge constraint = getPairConstraint(This, orderPairTable, & pair);
+       HashTableOrderPair *orderPairTable = boolOrder->order->orderPairTable;
+       OrderPair pair = {boolOrder->first, boolOrder->second, E_NULL};
+       Edge constraint = getPairConstraint(This, orderPairTable, &pair);
        return constraint;
 }
 
 
        return constraint;
 }
 
 
-void createAllTotalOrderConstraintsSATEncoder(SATEncoder* This, Order* order){
+void createAllTotalOrderConstraintsSATEncoder(SATEncoder *This, Order *order) {
 #ifdef TRACE_DEBUG
        model_print("in total order ...\n");
 #ifdef TRACE_DEBUG
        model_print("in total order ...\n");
-#endif 
+#endif
        ASSERT(order->type == TOTAL);
        ASSERT(order->type == TOTAL);
-       VectorIntmems = order->set->members;
-       HashTableOrderPairtable = order->orderPairTable;
+       VectorInt *mems = order->set->members;
+       HashTableOrderPair *table = order->orderPairTable;
        uint size = getSizeVectorInt(mems);
        uint size = getSizeVectorInt(mems);
-       for(uint i=0; i<size; i++){
+       for (uint i = 0; i < size; i++) {
                uint64_t valueI = getVectorInt(mems, i);
                uint64_t valueI = getVectorInt(mems, i);
-               for(uint j=i+1; j<size;j++){
+               for (uint j = i + 1; j < size; j++) {
                        uint64_t valueJ = getVectorInt(mems, j);
                        OrderPair pairIJ = {valueI, valueJ};
                        uint64_t valueJ = getVectorInt(mems, j);
                        OrderPair pairIJ = {valueI, valueJ};
-                       Edge constIJ=getPairConstraint(This, table, & pairIJ);
-                       for(uint k=j+1; k<size; k++){
+                       Edge constIJ = getPairConstraint(This, table, &pairIJ);
+                       for (uint k = j + 1; k < size; k++) {
                                uint64_t valueK = getVectorInt(mems, k);
                                OrderPair pairJK = {valueJ, valueK};
                                OrderPair pairIK = {valueI, valueK};
                                uint64_t valueK = getVectorInt(mems, k);
                                OrderPair pairJK = {valueJ, valueK};
                                OrderPair pairIK = {valueI, valueK};
-                               Edge constIK = getPairConstraint(This, table, & pairIK);
-                               Edge constJK = getPairConstraint(This, table, & pairJK);
-                               addConstraintCNF(This->cnf, generateTransOrderConstraintSATEncoder(This, constIJ, constJK, constIK)); 
+                               Edge constIK = getPairConstraint(This, table, &pairIK);
+                               Edge constJK = getPairConstraint(This, table, &pairJK);
+                               addConstraintCNF(This->cnf, generateTransOrderConstraintSATEncoder(This, constIJ, constJK, constIK));
                        }
                }
        }
 }
 
                        }
                }
        }
 }
 
-Edge getOrderConstraint(HashTableOrderPair *table, OrderPair *pair){
-       ASSERT(pair->first!= pair->second);
+Edge getOrderConstraint(HashTableOrderPair *table, OrderPair *pair) {
+       ASSERT(pair->first != pair->second);
        bool negate = false;
        OrderPair flipped;
        if (pair->first < pair->second) {
        bool negate = false;
        OrderPair flipped;
        if (pair->first < pair->second) {
-               negate=true;
-               flipped.first=pair->second;
-               flipped.second=pair->first;
+               negate = true;
+               flipped.first = pair->second;
+               flipped.second = pair->first;
                pair = &flipped;
        }
        if (!containsOrderPair(table, pair)) {
                return E_NULL;
        }
                pair = &flipped;
        }
        if (!containsOrderPair(table, pair)) {
                return E_NULL;
        }
-       Edge constraint= getOrderPair(table, pair)->constraint;
+       Edge constraint = getOrderPair(table, pair)->constraint;
        ASSERT(!edgeIsNull(constraint));
        return negate ? constraintNegate(constraint) : constraint;
 }
 
        ASSERT(!edgeIsNull(constraint));
        return negate ? constraintNegate(constraint) : constraint;
 }
 
-Edge generateTransOrderConstraintSATEncoder(SATEncoder *This, Edge constIJ,Edge constJK,Edge constIK){
+Edge generateTransOrderConstraintSATEncoder(SATEncoder *This, Edge constIJ,Edge constJK,Edge constIK) {
        Edge carray[] = {constIJ, constJK, constraintNegate(constIK)};
        Edge carray[] = {constIJ, constJK, constraintNegate(constIK)};
-       Edge loop1= constraintOR(This->cnf, 3, carray);
+       Edge loop1 = constraintOR(This->cnf, 3, carray);
        Edge carray2[] = {constraintNegate(constIJ), constraintNegate(constJK), constIK};
        Edge carray2[] = {constraintNegate(constIJ), constraintNegate(constJK), constIK};
-       Edge loop2= constraintOR(This->cnf, 3, carray2 );
+       Edge loop2 = constraintOR(This->cnf, 3, carray2 );
        return constraintAND2(This->cnf, loop1, loop2);
 }
 
        return constraintAND2(This->cnf, loop1, loop2);
 }
 
-Edge encodePartialOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint){
+Edge encodePartialOrderSATEncoder(SATEncoder *This, BooleanOrder *constraint) {
        ASSERT(constraint->order->type == PARTIAL);
        return E_BOGUS;
 }
        ASSERT(constraint->order->type == PARTIAL);
        return E_BOGUS;
 }
index c26e66852e96e86f73d8c789eb12a02910e41ee2..53d741563b164a1fcc269a2c024e41c6266b7870 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef SATORDERENCODER_H
 #define SATORDERENCODER_H
 
 #ifndef SATORDERENCODER_H
 #define SATORDERENCODER_H
 
-Edge encodeOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint);
+Edge encodeOrderSATEncoder(SATEncoder *This, BooleanOrder *constraint);
 Edge getPairConstraint(SATEncoder *This, HashTableOrderPair *table, OrderPair *pair);
 Edge getPairConstraint(SATEncoder *This, HashTableOrderPair *table, OrderPair *pair);
-Edge encodeTotalOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint);
-Edge encodePartialOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint);
-void createAllTotalOrderConstraintsSATEncoder(SATEncoder* This, Order* order);
+Edge encodeTotalOrderSATEncoder(SATEncoder *This, BooleanOrder *constraint);
+Edge encodePartialOrderSATEncoder(SATEncoder *This, BooleanOrder *constraint);
+void createAllTotalOrderConstraintsSATEncoder(SATEncoder *This, Order *order);
 Edge getOrderConstraint(HashTableOrderPair *table, OrderPair *pair);
 Edge generateTransOrderConstraintSATEncoder(SATEncoder *This, Edge constIJ, Edge constJK, Edge constIK);
 #endif
 Edge getOrderConstraint(HashTableOrderPair *table, OrderPair *pair);
 Edge generateTransOrderConstraintSATEncoder(SATEncoder *This, Edge constIJ, Edge constJK, Edge constIK);
 #endif
index 7736f941a0acb29fdb53834fefe609d9174aa02d..ca0fdaeccda4aeb69dcc1c5bfaa2f43b92832304 100644 (file)
@@ -6,49 +6,49 @@
 #include "order.h"
 #include "orderpair.h"
 
 #include "order.h"
 #include "orderpair.h"
 
-uint64_t getElementValueBinaryIndexSATTranslator(CSolver* This, ElementEncoding* elemEnc){
-       uint index=0;
-       for(int i=elemEnc->numVars-1;i>=0;i--) {
-               index=index<<1;
+uint64_t getElementValueBinaryIndexSATTranslator(CSolver *This, ElementEncoding *elemEnc) {
+       uint index = 0;
+       for (int i = elemEnc->numVars - 1; i >= 0; i--) {
+               index = index << 1;
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )))
                        index |= 1;
        }
        model_print("index:%u\tencArraySize:%u\tisInUseElement:%u\n", index, elemEnc->encArraySize, isinUseElement(elemEnc, index));
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )))
                        index |= 1;
        }
        model_print("index:%u\tencArraySize:%u\tisInUseElement:%u\n", index, elemEnc->encArraySize, isinUseElement(elemEnc, index));
-       ASSERT(elemEnc->encArraySize >index && isinUseElement(elemEnc, index));
+       ASSERT(elemEnc->encArraySize > index && isinUseElement(elemEnc, index));
        return elemEnc->encodingArray[index];
 }
 
        return elemEnc->encodingArray[index];
 }
 
-uint64_t getElementValueBinaryValueSATTranslator(CSolver* This, ElementEncoding* elemEnc){
-       uint64_t value=0;
-       for(int i=elemEnc->numVars-1;i>=0;i--) {
-               value=value<<1;
+uint64_t getElementValueBinaryValueSATTranslator(CSolver *This, ElementEncoding *elemEnc) {
+       uint64_t value = 0;
+       for (int i = elemEnc->numVars - 1; i >= 0; i--) {
+               value = value << 1;
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )) )
                        value |= 1;
        }
        if (elemEnc->isBinaryValSigned &&
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )) )
                        value |= 1;
        }
        if (elemEnc->isBinaryValSigned &&
-                       This->satEncoder->cnf->solver->solution[ getEdgeVar( elemEnc->variables[elemEnc->numVars-1])]) {
+                       This->satEncoder->cnf->solver->solution[ getEdgeVar( elemEnc->variables[elemEnc->numVars - 1])]) {
                //Do sign extension of negative number
                //Do sign extension of negative number
-               uint64_t highbits=0xffffffffffffffff - ((1 << (elemEnc->numVars)) - 1);
-               value+=highbits;
+               uint64_t highbits = 0xffffffffffffffff - ((1 << (elemEnc->numVars)) - 1);
+               value += highbits;
        }
        }
-       value+=elemEnc->offset;
+       value += elemEnc->offset;
        return value;
 }
 
        return value;
 }
 
-uint64_t getElementValueOneHotSATTranslator(CSolver* This, ElementEncoding* elemEnc){
-       uint index=0;
-       for(uint i=0; i< elemEnc->numVars; i++) {
+uint64_t getElementValueOneHotSATTranslator(CSolver *This, ElementEncoding *elemEnc) {
+       uint index = 0;
+       for (uint i = 0; i < elemEnc->numVars; i++) {
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )))
                        index = i;
        }
                if (getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )))
                        index = i;
        }
-       ASSERT(elemEnc->encArraySize >index && isinUseElement(elemEnc, index));
+       ASSERT(elemEnc->encArraySize > index && isinUseElement(elemEnc, index));
        return elemEnc->encodingArray[index];
 }
 
        return elemEnc->encodingArray[index];
 }
 
-uint64_t getElementValueUnarySATTranslator(CSolver* This, ElementEncoding* elemEnc){
+uint64_t getElementValueUnarySATTranslator(CSolver *This, ElementEncoding *elemEnc) {
        uint i;
        uint i;
-       for(i=0;i<elemEnc->numVars;i++) {
-               if (! getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )) ) {
+       for (i = 0; i < elemEnc->numVars; i++) {
+               if (!getValueSolver(This->satEncoder->cnf->solver, getEdgeVar( elemEnc->variables[i] )) ) {
                        break;
                }
        }
                        break;
                }
        }
@@ -56,41 +56,41 @@ uint64_t getElementValueUnarySATTranslator(CSolver* This, ElementEncoding* elemE
        return elemEnc->encodingArray[i];
 }
 
        return elemEnc->encodingArray[i];
 }
 
-uint64_t getElementValueSATTranslator(CSolver* This, Element* element){
-       ElementEncodingelemEnc = getElementEncoding(element);
-       if(elemEnc->numVars == 0)       //case when the set has only one item
+uint64_t getElementValueSATTranslator(CSolver *This, Element *element) {
+       ElementEncoding *elemEnc = getElementEncoding(element);
+       if (elemEnc->numVars == 0)//case when the set has only one item
                return getSetElement(getElementSet(element), 0);
                return getSetElement(getElementSet(element), 0);
-       switch(elemEnc->type){
-               case ONEHOT:
-                       return getElementValueOneHotSATTranslator(This, elemEnc);
-               case UNARY:
-                       return getElementValueUnarySATTranslator(This, elemEnc);
-               case BINARYINDEX:
-                       return getElementValueBinaryIndexSATTranslator(This, elemEnc);
-               case ONEHOTBINARY:
-                       ASSERT(0);
-                       break;
-               case BINARYVAL:
-                       ASSERT(0);
-                       break;
-               default:
-                       ASSERT(0);
-                       break;
+       switch (elemEnc->type) {
+       case ONEHOT:
+               return getElementValueOneHotSATTranslator(This, elemEnc);
+       case UNARY:
+               return getElementValueUnarySATTranslator(This, elemEnc);
+       case BINARYINDEX:
+               return getElementValueBinaryIndexSATTranslator(This, elemEnc);
+       case ONEHOTBINARY:
+               ASSERT(0);
+               break;
+       case BINARYVAL:
+               ASSERT(0);
+               break;
+       default:
+               ASSERT(0);
+               break;
        }
        return -1;
 }
 
        }
        return -1;
 }
 
-bool getBooleanVariableValueSATTranslator( CSolver* This , Boolean* boolean){
-       int index = getEdgeVar( ((BooleanVar*) boolean)->var );
+bool getBooleanVariableValueSATTranslator( CSolver *This, Boolean *boolean) {
+       int index = getEdgeVar( ((BooleanVar *) boolean)->var );
        return getValueSolver(This->satEncoder->cnf->solver, index);
 }
 
        return getValueSolver(This->satEncoder->cnf->solver, index);
 }
 
-HappenedBefore getOrderConstraintValueSATTranslator(CSolver* This, Order * order, uint64_t first, uint64_t second){
-       ASSERT(order->orderPairTable!= NULL);
-       OrderPair pair={first, second, E_NULL};
-       Edge var = getOrderConstraint(order->orderPairTable, &pair); 
-       if(edgeIsNull(var))
+HappenedBefore getOrderConstraintValueSATTranslator(CSolver *This, Order *order, uint64_t first, uint64_t second) {
+       ASSERT(order->orderPairTable != NULL);
+       OrderPair pair = {first, second, E_NULL};
+       Edge var = getOrderConstraint(order->orderPairTable, &pair);
+       if (edgeIsNull(var))
                return UNORDERED;
                return UNORDERED;
-       return getValueCNF(This->satEncoder->cnf, var)? FIRST: SECOND;
+       return getValueCNF(This->satEncoder->cnf, var) ? FIRST : SECOND;
 }
 
 }
 
index 0b1a996346654721664101bb53942281aaa783d1..ad204f39832c4eabe2e4e7b0a8838315969c6c89 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   sattranslator.h
  * Author: hamed
  *
  * File:   sattranslator.h
  * Author: hamed
  *
 #include "ops.h"
 
 
 #include "ops.h"
 
 
-bool getBooleanVariableValueSATTranslator( CSolver* This , Boolean* boolean);
-HappenedBefore getOrderConstraintValueSATTranslator(CSolver* This, Order * order, uint64_t first, uint64_t second);
-uint64_t getElementValueBinaryIndexSATTranslator(CSolver* This, ElementEncoding* elemEnc);
-uint64_t getElementValueBinaryValueSATTranslator(CSolver* This, ElementEncoding* elemEnc);
-uint64_t getElementValueOneHotSATTranslator(CSolver* This, ElementEncoding* elemEnc);
-uint64_t getElementValueUnarySATTranslator(CSolver* This, ElementEncoding* elemEnc);
-uint64_t getElementValueSATTranslator(CSolver* This, Element* element);
+bool getBooleanVariableValueSATTranslator( CSolver *This, Boolean *boolean);
+HappenedBefore getOrderConstraintValueSATTranslator(CSolver *This, Order *order, uint64_t first, uint64_t second);
+uint64_t getElementValueBinaryIndexSATTranslator(CSolver *This, ElementEncoding *elemEnc);
+uint64_t getElementValueBinaryValueSATTranslator(CSolver *This, ElementEncoding *elemEnc);
+uint64_t getElementValueOneHotSATTranslator(CSolver *This, ElementEncoding *elemEnc);
+uint64_t getElementValueUnarySATTranslator(CSolver *This, ElementEncoding *elemEnc);
+uint64_t getElementValueSATTranslator(CSolver *This, Element *element);
 
 
-#endif /* SATTRANSLATOR_H */
+#endif/* SATTRANSLATOR_H */
 
 
index f823d8c43119014f513e23a03b94acf9ba5a0377..d211759470591a2f84990db2d02ac4f7a4716c11 100644 (file)
@@ -1,55 +1,55 @@
 #ifndef ARRAY_H
 #define ARRAY_H
 
 #ifndef ARRAY_H
 #define ARRAY_H
 
-#define ArrayDef(name, type)                                                                                                                                                                           \
-       struct Array ## name {                                                                                                                                                                                          \
-               type * array;                                                       \
-               uint size;                                                                                                                                                                                                                                      \
+#define ArrayDef(name, type)                                            \
+       struct Array ## name {                                                \
+               type *array;                                                       \
+               uint size;                                                          \
        };                                                                    \
        };                                                                    \
-       typedef struct Array ## name Array ## name;                                                                                                             \
-       static inline Array ## name * allocArray ## name(uint size) {                                                           \
-               Array ## name * tmp = (Array ## name *)ourmalloc(sizeof(type));                 \
-               tmp->size = size;                                                                                                                                                                                                               \
-               tmp->array = (type *) ourcalloc(1, sizeof(type) * size);                                                \
+       typedef struct Array ## name Array ## name;                           \
+       static inline Array ## name *allocArray ## name(uint size) {               \
+               Array ## name * tmp = (Array ## name *)ourmalloc(sizeof(type));     \
+               tmp->size = size;                                                   \
+               tmp->array = (type *) ourcalloc(1, sizeof(type) * size);            \
                return tmp;                                                         \
        }                                                                     \
                return tmp;                                                         \
        }                                                                     \
-       static inline Array ## name * allocArrayInit ## name(type * array, uint size)  { \
-               Array ## name * tmp = allocArray ## name(size);                                                                                 \
-               memcpy(tmp->array, array, size * sizeof(type));                                                                                 \
+       static inline Array ## name *allocArrayInit ## name(type * array, uint size)  { \
+               Array ## name * tmp = allocArray ## name(size);                     \
+               memcpy(tmp->array, array, size * sizeof(type));                     \
                return tmp;                                                         \
        }                                                                     \
        static inline void removeElementArray ## name(Array ## name * This, uint index) { \
                return tmp;                                                         \
        }                                                                     \
        static inline void removeElementArray ## name(Array ## name * This, uint index) { \
-               This->size--;                                                                                                                                                                                                                           \
-               for(;index<This->size;index++) {                                                                                                                                                \
-                       This->array[index]=This->array[index+1];                                                                                                        \
-               }                                                                                                                                                                                                                                                                               \
-       }                                                                                                                                                                                                                                                                                       \
-       static inline type getArray ## name(Array ## name * This, uint index) { \
-               return This->array[index];                                                                                                                                                                      \
-       }                                                                     \
-       static inline void setArray ## name(Array ## name * This, uint index, type item) {      \
-               This->array[index]=item;                                                                                                                                                                                \
-       }                                                                     \
-       static inline uint getSizeArray ## name(Array ## name *This) {                                                          \
-               return This->size;                                                                                                                                                                                                      \
-       }                                                                     \
-       static inline void deleteArray ## name(Array ## name *This) {                                                           \
-               ourfree(This->array);                                                                                                                                                                                           \
-               ourfree(This);                                                                                                                                                                                                                  \
-       }                                                                     \
-       static inline type * exposeCArray ## name(Array ## name * This) {                                                       \
-               return This->array;                                                                                                                                                                                                     \
-       }                                                                                                                                                                                                                                                                                       \
-       static inline void deleteInlineArray ## name(Array ## name *This) {                                     \
-               ourfree(This->array);                                                                                                                                                                                           \
-       }                                                                                                                                                                                                                                                                                       \
-       static inline void initArray ## name(Array ## name * This, uint size) {                 \
-               This->size = size;                                                                                                                                                                                                      \
-               This->array = (type *) ourcalloc(1, sizeof(type) * size);                                               \
-       }                                                                                                                                                                                                                                                                                       \
-       static inline void initArrayInit ## name(Array ## name * This, type *array, uint size) { \
-               initArray ##name(This, size);                                                                                                                                                           \
-               memcpy(This->array, array, size * sizeof(type));                                                                                \
+               This->size--;                                                       \
+               for (; index < This->size; index++) {                                    \
+                       This->array[index] = This->array[index + 1];                          \
+               }                                                                   \
+       }                                                                     \
+       static inline type getArray ## name(Array ## name * This, uint index) { \
+               return This->array[index];                                          \
+       }                                                                     \
+       static inline void setArray ## name(Array ## name * This, uint index, type item) {  \
+               This->array[index] = item;                                            \
+       }                                                                     \
+       static inline uint getSizeArray ## name(Array ## name * This) {                \
+               return This->size;                                                  \
+       }                                                                     \
+       static inline void deleteArray ## name(Array ## name * This) {               \
+               ourfree(This->array);                                               \
+               ourfree(This);                                                      \
+       }                                                                     \
+       static inline type *exposeCArray ## name(Array ## name * This) {             \
+               return This->array;                                                 \
+       }                                                                     \
+       static inline void deleteInlineArray ## name(Array ## name * This) {         \
+               ourfree(This->array);                                               \
+       }                                                                     \
+       static inline void initArray ## name(Array ## name * This, uint size) {     \
+               This->size = size;                                                  \
+               This->array = (type *) ourcalloc(1, sizeof(type) * size);           \
+       }                                                                     \
+       static inline void initArrayInit ## name(Array ## name * This, type * array, uint size) { \
+               initArray ## name(This, size);                                       \
+               memcpy(This->array, array, size * sizeof(type));                    \
        }
 
 #endif
        }
 
 #endif
index f647c388711a583f49233dbbc8334a66836f61c9..c9656a69444a676e2f9f22843a3467b30766b638 100644 (file)
@@ -11,7 +11,7 @@
 #define HASH_SET_H
 #include "hashtable.h"
 
 #define HASH_SET_H
 #include "hashtable.h"
 
-#define HashSetDef(Name, _Key)                                                                                                                                                                 \
+#define HashSetDef(Name, _Key)                                          \
        struct LinkNode ## Name {                                             \
                _Key key;                                                           \
                struct LinkNode ## Name *prev;                                      \
        struct LinkNode ## Name {                                             \
                _Key key;                                                           \
                struct LinkNode ## Name *prev;                                      \
        struct HashSet ## Name;                                               \
        typedef struct HashSet ## Name HashSet ## Name;                       \
        struct HSIterator ## Name {                                           \
        struct HashSet ## Name;                                               \
        typedef struct HashSet ## Name HashSet ## Name;                       \
        struct HSIterator ## Name {                                           \
-               LinkNode ## Name *curr;                                             \
-               LinkNode ## Name *last;                                             \
+               LinkNode ## Name * curr;                                             \
+               LinkNode ## Name * last;                                             \
                HashSet ## Name * set;                                              \
        };                                                                    \
        typedef struct HSIterator ## Name HSIterator ## Name;                 \
                HashSet ## Name * set;                                              \
        };                                                                    \
        typedef struct HSIterator ## Name HSIterator ## Name;                 \
-       HashTableDef(Name ## Set, _Key, LinkNode ## Name *);                                                                    \
-       HSIterator ## Name * allocHSIterator ## Name(LinkNode ## Name *_curr, HashSet ## Name * _set); \
-       void deleteIter ## Name(HSIterator ## Name *hsit);                      \
-       bool hasNext ## Name(HSIterator ## Name *hsit);                       \
-       _Key next ## Name(HSIterator ## Name *hsit);                          \
-       _Key currKey ## Name(HSIterator ## Name *hsit);                       \
-       void removeIter ## Name(HSIterator ## Name *hsit);                        \
+       HashTableDef(Name ## Set, _Key, LinkNode ## Name *);                  \
+       HSIterator ## Name * allocHSIterator ## Name(LinkNode ## Name * _curr, HashSet ## Name * _set); \
+       void deleteIter ## Name(HSIterator ## Name * hsit);                      \
+       bool hasNext ## Name(HSIterator ## Name * hsit);                       \
+       _Key next ## Name(HSIterator ## Name * hsit);                          \
+       _Key currKey ## Name(HSIterator ## Name * hsit);                       \
+       void removeIter ## Name(HSIterator ## Name * hsit);                        \
        struct HashSet ## Name {                                              \
                HashTable ## Name ## Set * table;                                   \
        struct HashSet ## Name {                                              \
                HashTable ## Name ## Set * table;                                   \
-               LinkNode ## Name *list;                                             \
-               LinkNode ## Name *tail;                                             \
+               LinkNode ## Name * list;                                             \
+               LinkNode ## Name * tail;                                             \
        };                                                                    \
        typedef struct HashSet ## Name HashSet ## Name;                       \
                                                                         \
        HashSet ## Name * allocHashSet ## Name (unsigned int initialcapacity, double factor); \
        };                                                                    \
        typedef struct HashSet ## Name HashSet ## Name;                       \
                                                                         \
        HashSet ## Name * allocHashSet ## Name (unsigned int initialcapacity, double factor); \
-       void deleteHashSet ## Name(struct HashSet ## Name * set);               \
+       void deleteHashSet ## Name(struct HashSet ## Name *set);               \
        HashSet ## Name * copyHashSet ## Name(HashSet ## Name * set);                \
        void resetHashSet ## Name(HashSet ## Name * set);                         \
        bool addHashSet ## Name(HashSet ## Name * set,_Key key);                     \
        HashSet ## Name * copyHashSet ## Name(HashSet ## Name * set);                \
        void resetHashSet ## Name(HashSet ## Name * set);                         \
        bool addHashSet ## Name(HashSet ## Name * set,_Key key);                     \
 
 #define HashSetImpl(Name, _Key, hash_function, equals)                  \
        HashTableImpl(Name ## Set, _Key, LinkNode ## Name *, hash_function, equals, ourfree); \
 
 #define HashSetImpl(Name, _Key, hash_function, equals)                  \
        HashTableImpl(Name ## Set, _Key, LinkNode ## Name *, hash_function, equals, ourfree); \
-       HSIterator ## Name * allocHSIterator ## Name(LinkNode ## Name *_curr, HashSet ## Name * _set) { \
+       HSIterator ## Name * allocHSIterator ## Name(LinkNode ## Name * _curr, HashSet ## Name * _set) { \
                HSIterator ## Name * hsit = (HSIterator ## Name *)ourmalloc(sizeof(HSIterator ## Name)); \
                HSIterator ## Name * hsit = (HSIterator ## Name *)ourmalloc(sizeof(HSIterator ## Name)); \
-               hsit->curr=_curr;                                                   \
-               hsit->set=_set;                                                     \
+               hsit->curr = _curr;                                                   \
+               hsit->set = _set;                                                     \
                return hsit;                                                        \
        }                                                                     \
                                                                         \
                return hsit;                                                        \
        }                                                                     \
                                                                         \
-       void deleteIter ## Name(HSIterator ## Name *hsit) {                   \
+       void deleteIter ## Name(HSIterator ## Name * hsit) {                   \
                ourfree(hsit);                                                      \
        }                                                                     \
                                                                         \
                ourfree(hsit);                                                      \
        }                                                                     \
                                                                         \
-       bool hasNext ## Name(HSIterator ## Name *hsit) {                      \
-               return hsit->curr!=NULL;                                            \
+       bool hasNext ## Name(HSIterator ## Name * hsit) {                      \
+               return hsit->curr != NULL;                                            \
        }                                                                     \
                                                                         \
        }                                                                     \
                                                                         \
-       _Key next ## Name(HSIterator ## Name *hsit) {                         \
-               _Key k=hsit->curr->key;                                             \
-               hsit->last=hsit->curr;                                              \
-               hsit->curr=hsit->curr->next;                                        \
+       _Key next ## Name(HSIterator ## Name * hsit) {                         \
+               _Key k = hsit->curr->key;                                             \
+               hsit->last = hsit->curr;                                              \
+               hsit->curr = hsit->curr->next;                                        \
                return k;                                                           \
        }                                                                     \
                                                                         \
                return k;                                                           \
        }                                                                     \
                                                                         \
-       _Key currKey ## Name(HSIterator ## Name *hsit) {                      \
+       _Key currKey ## Name(HSIterator ## Name * hsit) {                      \
                return hsit->last->key;                                             \
        }                                                                     \
                                                                         \
                return hsit->last->key;                                             \
        }                                                                     \
                                                                         \
-       void removeIter ## Name(HSIterator ## Name *hsit) {                   \
-               _Key k=hsit->last->key;                                             \
+       void removeIter ## Name(HSIterator ## Name * hsit) {                   \
+               _Key k = hsit->last->key;                                             \
                removeHashSet ## Name(hsit->set, k);                                    \
        }                                                                     \
                                                                         \
        HashSet ## Name * allocHashSet ## Name (unsigned int initialcapacity, double factor) { \
                HashSet ## Name * set = (HashSet ## Name *)ourmalloc(sizeof(struct HashSet ## Name));  \
                removeHashSet ## Name(hsit->set, k);                                    \
        }                                                                     \
                                                                         \
        HashSet ## Name * allocHashSet ## Name (unsigned int initialcapacity, double factor) { \
                HashSet ## Name * set = (HashSet ## Name *)ourmalloc(sizeof(struct HashSet ## Name));  \
-               set->table=allocHashTable ## Name ## Set(initialcapacity, factor);          \
-               set->list=NULL;                                                     \
-               set->tail=NULL;                                                     \
+               set->table = allocHashTable ## Name ## Set(initialcapacity, factor);          \
+               set->list = NULL;                                                     \
+               set->tail = NULL;                                                     \
                return set;                                                         \
        }                                                                       \
                                                                         \
                return set;                                                         \
        }                                                                       \
                                                                         \
-       void deleteHashSet ## Name(struct HashSet ## Name * set) {            \
-               LinkNode ## Name *tmp=set->list;                                    \
-               while(tmp!=NULL) {                                                  \
-                       LinkNode ## Name *tmpnext=tmp->next;                              \
+       void deleteHashSet ## Name(struct HashSet ## Name *set) {            \
+               LinkNode ## Name *tmp = set->list;                                    \
+               while (tmp != NULL) {                                                  \
+                       LinkNode ## Name * tmpnext = tmp->next;                              \
                        ourfree(tmp);                                                     \
                        ourfree(tmp);                                                     \
-                       tmp=tmpnext;                                                      \
+                       tmp = tmpnext;                                                      \
                }                                                                   \
                deleteHashTable ## Name ## Set(set->table);                         \
                ourfree(set);                                                       \
        }                                                                     \
                                                                         \
        HashSet ## Name * copyHashSet ## Name(HashSet ## Name * set) {               \
                }                                                                   \
                deleteHashTable ## Name ## Set(set->table);                         \
                ourfree(set);                                                       \
        }                                                                     \
                                                                         \
        HashSet ## Name * copyHashSet ## Name(HashSet ## Name * set) {               \
-               HashSet ## Name *copy=allocHashSet ## Name(getCapacity ## Name ## Set(set->table), getLoadFactor ## Name ## Set(set->table)); \
-               HSIterator ## Name * it=iterator ## Name(set);                      \
-               while(hasNext ## Name(it))                                          \
+               HashSet ## Name * copy = allocHashSet ## Name(getCapacity ## Name ## Set(set->table), getLoadFactor ## Name ## Set(set->table)); \
+               HSIterator ## Name * it = iterator ## Name(set);                      \
+               while (hasNext ## Name(it))                                          \
                        addHashSet ## Name(copy, next ## Name(it));                              \
                deleteIter ## Name(it);                                             \
                return copy;                                                        \
        }                                                                     \
                                                                         \
        void resetHashSet ## Name(HashSet ## Name * set) {                        \
                        addHashSet ## Name(copy, next ## Name(it));                              \
                deleteIter ## Name(it);                                             \
                return copy;                                                        \
        }                                                                     \
                                                                         \
        void resetHashSet ## Name(HashSet ## Name * set) {                        \
-               LinkNode ## Name *tmp=set->list;                                    \
-               while(tmp!=NULL) {                                                  \
-                       LinkNode ## Name *tmpnext=tmp->next;                              \
+               LinkNode ## Name * tmp = set->list;                                    \
+               while (tmp != NULL) {                                                  \
+                       LinkNode ## Name * tmpnext = tmp->next;                              \
                        ourfree(tmp);                                                     \
                        ourfree(tmp);                                                     \
-                       tmp=tmpnext;                                                      \
+                       tmp = tmpnext;                                                      \
                }                                                                   \
                }                                                                   \
-               set->list=set->tail=NULL;                                           \
+               set->list = set->tail = NULL;                                           \
                reset ## Name ## Set(set->table);                                   \
        }                                                                     \
                                                                         \
        bool addHashSet ## Name(HashSet ## Name * set,_Key key) {                    \
                reset ## Name ## Set(set->table);                                   \
        }                                                                     \
                                                                         \
        bool addHashSet ## Name(HashSet ## Name * set,_Key key) {                    \
-               LinkNode ## Name * val=get ## Name ## Set(set->table, key);         \
-               if (val==NULL) {                                                    \
-                       LinkNode ## Name * newnode=(LinkNode ## Name *)ourmalloc(sizeof(struct LinkNode ## Name)); \
-                       newnode->prev=set->tail;                                          \
-                       newnode->next=NULL;                                               \
-                       newnode->key=key;                                                 \
-                       if (set->tail!=NULL)                                              \
-                               set->tail->next=newnode;                                        \
+               LinkNode ## Name * val = get ## Name ## Set(set->table, key);         \
+               if (val == NULL) {                                                    \
+                       LinkNode ## Name * newnode = (LinkNode ## Name *)ourmalloc(sizeof(struct LinkNode ## Name)); \
+                       newnode->prev = set->tail;                                          \
+                       newnode->next = NULL;                                               \
+                       newnode->key = key;                                                 \
+                       if (set->tail != NULL)                                              \
+                               set->tail->next = newnode;                                        \
                        else                                                              \
                        else                                                              \
-                               set->list=newnode;                                              \
-                       set->tail=newnode;                                                \
+                               set->list = newnode;                                              \
+                       set->tail = newnode;                                                \
                        put ## Name ## Set(set->table, key, newnode);                     \
                        return true;                                                      \
                } else                                                              \
                        put ## Name ## Set(set->table, key, newnode);                     \
                        return true;                                                      \
                } else                                                              \
        }                                                                     \
                                                                         \
        _Key getHashSet ## Name(HashSet ## Name * set,_Key key) {                 \
        }                                                                     \
                                                                         \
        _Key getHashSet ## Name(HashSet ## Name * set,_Key key) {                 \
-               LinkNode ## Name * val=get ## Name ## Set(set->table, key);         \
-               if (val!=NULL)                                                      \
+               LinkNode ## Name * val = get ## Name ## Set(set->table, key);         \
+               if (val != NULL)                                                      \
                        return val->key;                                                  \
                else                                                                \
                        return NULL;                                                      \
                        return val->key;                                                  \
                else                                                                \
                        return NULL;                                                      \
        }                                                                     \
                                                                         \
        bool containsHashSet ## Name(HashSet ## Name * set,_Key key) {            \
        }                                                                     \
                                                                         \
        bool containsHashSet ## Name(HashSet ## Name * set,_Key key) {            \
-               return get ## Name ## Set(set->table, key)!=NULL;                   \
+               return get ## Name ## Set(set->table, key) != NULL;                   \
        }                                                                     \
                                                                         \
        bool removeHashSet ## Name(HashSet ## Name * set,_Key key) {              \
                LinkNode ## Name * oldlinknode;                                     \
        }                                                                     \
                                                                         \
        bool removeHashSet ## Name(HashSet ## Name * set,_Key key) {              \
                LinkNode ## Name * oldlinknode;                                     \
-               oldlinknode=get ## Name ## Set(set->table, key);                    \
-               if (oldlinknode==NULL) {                                            \
+               oldlinknode = get ## Name ## Set(set->table, key);                    \
+               if (oldlinknode == NULL) {                                            \
                        return false;                                                     \
                }                                                                   \
                remove ## Name ## Set(set->table, key);                             \
                                                                         \
                        return false;                                                     \
                }                                                                   \
                remove ## Name ## Set(set->table, key);                             \
                                                                         \
-               if (oldlinknode->prev==NULL)                                        \
-                       set->list=oldlinknode->next;                                      \
+               if (oldlinknode->prev == NULL)                                        \
+                       set->list = oldlinknode->next;                                      \
                else                                                                \
                else                                                                \
-                       oldlinknode->prev->next=oldlinknode->next;                        \
-               if (oldlinknode->next!=NULL)                                        \
-                       oldlinknode->next->prev=oldlinknode->prev;                        \
+                       oldlinknode->prev->next = oldlinknode->next;                        \
+               if (oldlinknode->next != NULL)                                        \
+                       oldlinknode->next->prev = oldlinknode->prev;                        \
                else                                                                \
                else                                                                \
-                       set->tail=oldlinknode->prev;                                      \
+                       set->tail = oldlinknode->prev;                                      \
                ourfree(oldlinknode);                                               \
                return true;                                                        \
        }                                                                     \
                ourfree(oldlinknode);                                               \
                return true;                                                        \
        }                                                                     \
        }                                                                     \
                                                                         \
        bool isEmptyHashSet ## Name(HashSet ## Name * set) {                         \
        }                                                                     \
                                                                         \
        bool isEmptyHashSet ## Name(HashSet ## Name * set) {                         \
-               return getSizeHashSet ## Name(set)==0;                                  \
+               return getSizeHashSet ## Name(set) == 0;                                  \
        }                                                                     \
                                                                         \
        HSIterator ## Name * iterator ## Name(HashSet ## Name * set) {        \
        }                                                                     \
                                                                         \
        HSIterator ## Name * iterator ## Name(HashSet ## Name * set) {        \
index dbf61f91110a4ade864d02c89cf4c902cdf0460e..15f69af6b330dc05090f1c31c0e6283fd6bcd3ac 100644 (file)
@@ -62,7 +62,7 @@
        bool contains ## Name(const HashTable ## Name * tab, _Key key);       \
        void resize ## Name(HashTable ## Name * tab, unsigned int newsize);   \
        double getLoadFactor ## Name(HashTable ## Name * tab);                \
        bool contains ## Name(const HashTable ## Name * tab, _Key key);       \
        void resize ## Name(HashTable ## Name * tab, unsigned int newsize);   \
        double getLoadFactor ## Name(HashTable ## Name * tab);                \
-       unsigned int getCapacity ## Name(HashTable ## Name * tab);                                              \
+       unsigned int getCapacity ## Name(HashTable ## Name * tab);            \
        void resetAndDeleteHashTable ## Name(HashTable ## Name * tab);
 
 #define HashTableImpl(Name, _Key, _Val, hash_function, equals, freefunction) \
        void resetAndDeleteHashTable ## Name(HashTable ## Name * tab);
 
 #define HashTableImpl(Name, _Key, _Val, hash_function, equals, freefunction) \
                tab->size = 0;                                                      \
                return tab;                                                         \
        }                                                                     \
                tab->size = 0;                                                      \
                return tab;                                                         \
        }                                                                     \
-                                                                                                                                                                                                                                                                                               \
-       void deleteHashTable ## Name(HashTable ## Name * tab) {                                                         \
+                                                                        \
+       void deleteHashTable ## Name(HashTable ## Name * tab) {               \
                ourfree(tab->table);                                                \
                if (tab->zero)                                                      \
                        ourfree(tab->zero);                                               \
                ourfree(tab);                                                       \
        }                                                                     \
                ourfree(tab->table);                                                \
                if (tab->zero)                                                      \
                        ourfree(tab->zero);                                               \
                ourfree(tab);                                                       \
        }                                                                     \
-                                                                                                                                                                                                                                                                                               \
-       void resetAndDeleteHashTable ## Name(HashTable ## Name * tab) {                         \
-               for(uint i=0;i<tab->capacity;i++) {                                                                                                                                     \
-                       struct hashlistnode ## Name * bin=&tab->table[i];                                                                       \
-                       if (bin->key!=NULL) {                                                                                                                                                                                   \
-                               bin->key=NULL;                                                                                                                                                                                                  \
-                               if (bin->val!=NULL) {                                                                                                                                                                           \
-                                       freefunction(bin->val);                                                                                                                                                         \
-                                       bin->val=NULL;                                                                                                                                                                                          \
-                               }                                                                                                                                                                                                                                                               \
-                       }                                                                                                                                                                                                                                                                       \
-               }                                                                                                                                                                                                                                                                               \
-               if (tab->zero)  {                                                                                                                                                                                                               \
-                       if (tab->zero->val != NULL)                                                                                                                                                             \
-                               freefunction(tab->zero->val);                                                                                                                                           \
-                       ourfree(tab->zero);                                                                                                                                                                                             \
-                       tab->zero=NULL;                                                                                                                                                                                                         \
-               }                                                                                                                                                                                                                                                                               \
-               tab->size=0;                                                                                                                                                                                                                            \
-       }                                                                                                                                                                                                                                                                                       \
-                                                                                                                                                                                                                                                                                               \
+                                                                        \
+       void resetAndDeleteHashTable ## Name(HashTable ## Name * tab) {       \
+               for (uint i = 0; i < tab->capacity; i++) {                                 \
+                       struct hashlistnode ## Name *bin = &tab->table[i];                 \
+                       if (bin->key != NULL) {                                             \
+                               bin->key = NULL;                                                  \
+                               if (bin->val != NULL) {                                           \
+                                       freefunction(bin->val);                                       \
+                                       bin->val = NULL;                                                \
+                               }                                                               \
+                       }                                                                 \
+               }                                                                   \
+               if (tab->zero)  {                                                   \
+                       if (tab->zero->val != NULL)                                       \
+                               freefunction(tab->zero->val);                                   \
+                       ourfree(tab->zero);                                               \
+                       tab->zero = NULL;                                                   \
+               }                                                                   \
+               tab->size = 0;                                                        \
+       }                                                                     \
+                                                                        \
        void reset ## Name(HashTable ## Name * tab) {                         \
                memset(tab->table, 0, tab->capacity * sizeof(struct hashlistnode ## Name)); \
                if (tab->zero) {                                                    \
        void reset ## Name(HashTable ## Name * tab) {                         \
                memset(tab->table, 0, tab->capacity * sizeof(struct hashlistnode ## Name)); \
                if (tab->zero) {                                                    \
        }                                                                     \
                                                                         \
        void resetandfree ## Name(HashTable ## Name * tab) {                  \
        }                                                                     \
                                                                         \
        void resetandfree ## Name(HashTable ## Name * tab) {                  \
-               for(unsigned int i=0;i<tab->capacity;i++) {                         \
+               for (unsigned int i = 0; i < tab->capacity; i++) {                         \
                        struct hashlistnode ## Name *bin = &tab->table[i];                \
                        if (bin->key != NULL) {                                           \
                                bin->key = NULL;                                                \
                        struct hashlistnode ## Name *bin = &tab->table[i];                \
                        if (bin->key != NULL) {                                           \
                                bin->key = NULL;                                                \
        void put ## Name(HashTable ## Name * tab, _Key key, _Val val) {       \
                if (!key) {                                                         \
                        if (!tab->zero) {                                                 \
        void put ## Name(HashTable ## Name * tab, _Key key, _Val val) {       \
                if (!key) {                                                         \
                        if (!tab->zero) {                                                 \
-                               tab->zero=(struct hashlistnode ## Name *)ourmalloc(sizeof(struct hashlistnode ## Name)); \
+                               tab->zero = (struct hashlistnode ## Name *)ourmalloc(sizeof(struct hashlistnode ## Name)); \
                                tab->size++;                                                    \
                        }                                                                 \
                                tab->size++;                                                    \
                        }                                                                 \
-                       tab->zero->key=key;                                               \
-                       tab->zero->val=val;                                               \
+                       tab->zero->key = key;                                               \
+                       tab->zero->val = val;                                               \
                        return;                                                           \
                }                                                                   \
                                                                         \
                        return;                                                           \
                }                                                                   \
                                                                         \
                }                                                                   \
                                                                         \
                unsigned int oindex = hash_function(key) & tab->capacitymask;       \
                }                                                                   \
                                                                         \
                unsigned int oindex = hash_function(key) & tab->capacitymask;       \
-               unsigned int index=oindex;                                          \
+               unsigned int index = oindex;                                          \
                do {                                                                \
                        search = &tab->table[index];                                      \
                        if (!search->key) {                                               \
                do {                                                                \
                        search = &tab->table[index];                                      \
                        if (!search->key) {                                               \
                                return search->val;                                           \
                        index++;                                                          \
                        index &= tab->capacitymask;                                       \
                                return search->val;                                           \
                        index++;                                                          \
                        index &= tab->capacitymask;                                       \
-                       if (index==oindex)                                                \
+                       if (index == oindex)                                                \
                                break;                                                          \
                } while (true);                                                     \
                return (_Val)0;                                                     \
                                break;                                                          \
                } while (true);                                                     \
                return (_Val)0;                                                     \
                        if (!tab->zero) {                                                 \
                                return (_Val)0;                                                 \
                        } else {                                                          \
                        if (!tab->zero) {                                                 \
                                return (_Val)0;                                                 \
                        } else {                                                          \
-                               _Val v=tab->zero->val;                                          \
+                               _Val v = tab->zero->val;                                          \
                                ourfree(tab->zero);                                             \
                                ourfree(tab->zero);                                             \
-                               tab->zero=NULL;                                                 \
+                               tab->zero = NULL;                                                 \
                                tab->size--;                                                    \
                                return v;                                                       \
                        }                                                                 \
                                tab->size--;                                                    \
                                return v;                                                       \
                        }                                                                 \
                                        break;                                                        \
                        } else                                                            \
                        if (equals(search->key, key)) {                                 \
                                        break;                                                        \
                        } else                                                            \
                        if (equals(search->key, key)) {                                 \
-                               _Val v=search->val;                                           \
-                               search->val=(_Val) 1;                                         \
-                               search->key=0;                                                \
+                               _Val v = search->val;                                           \
+                               search->val = (_Val) 1;                                         \
+                               search->key = 0;                                                \
                                tab->size--;                                                  \
                                return v;                                                     \
                        }                                                               \
                                tab->size--;                                                  \
                                return v;                                                     \
                        }                                                               \
        bool contains ## Name(const HashTable ## Name * tab, _Key key) {      \
                struct hashlistnode ## Name *search;                                \
                if (!key) {                                                         \
        bool contains ## Name(const HashTable ## Name * tab, _Key key) {      \
                struct hashlistnode ## Name *search;                                \
                if (!key) {                                                         \
-                       return tab->zero!=NULL;                                           \
+                       return tab->zero != NULL;                                           \
                }                                                                   \
                unsigned int index = hash_function(key);                            \
                do {                                                                \
                }                                                                   \
                unsigned int index = hash_function(key);                            \
                do {                                                                \
                                                                         \
                struct hashlistnode ## Name *bin = &oldtable[0];                    \
                struct hashlistnode ## Name *lastbin = &oldtable[oldcapacity];      \
                                                                         \
                struct hashlistnode ## Name *bin = &oldtable[0];                    \
                struct hashlistnode ## Name *lastbin = &oldtable[oldcapacity];      \
-               for (;bin < lastbin;bin++) {                                        \
+               for (; bin < lastbin; bin++) {                                        \
                        _Key key = bin->key;                                              \
                                                                         \
                        struct hashlistnode ## Name *search;                              \
                        _Key key = bin->key;                                              \
                                                                         \
                        struct hashlistnode ## Name *search;                              \
index 459edd1498d6fe2416b957e5c894686893a0dc33..b41a0b539510e94597fda745ee6f1b57be820cf8 100644 (file)
@@ -17,63 +17,63 @@ VectorImpl(Order, Order *, 4);
 VectorImpl(TableEntry, TableEntry *, 4);
 VectorImpl(ASTNode, ASTNode *, 4);
 VectorImpl(Int, uint64_t, 4);
 VectorImpl(TableEntry, TableEntry *, 4);
 VectorImpl(ASTNode, ASTNode *, 4);
 VectorImpl(Int, uint64_t, 4);
-VectorImpl(OrderNode, OrderNode*, 4);
-VectorImpl(OrderGraph, OrderGraph*, 4);
+VectorImpl(OrderNode, OrderNode *, 4);
+VectorImpl(OrderGraph, OrderGraph *, 4);
 
 
-inline unsigned int Ptr_hash_function(void * hash) {
+inline unsigned int Ptr_hash_function(void *hash) {
        return (unsigned int)((int64)hash >> 4);
 }
 
        return (unsigned int)((int64)hash >> 4);
 }
 
-inline bool Ptr_equals(void * key1, void * key2) {
+inline bool Ptr_equals(void *key1, void *key2) {
        return key1 == key2;
 }
 
        return key1 == key2;
 }
 
-static inline unsigned int order_pair_hash_Function(OrderPair* This){
+static inline unsigned int order_pair_hash_Function(OrderPair *This) {
        return (uint) (This->first << 2) ^ This->second;
 }
 
        return (uint) (This->first << 2) ^ This->second;
 }
 
-static inline unsigned int order_pair_equals(OrderPair* key1, OrderPair* key2){
-       return key1->first== key2->first && key1->second == key2->second;
+static inline unsigned int order_pair_equals(OrderPair *key1, OrderPair *key2) {
+       return key1->first == key2->first && key1->second == key2->second;
 }
 
 }
 
-static inline unsigned int table_entry_hash_Function(TableEntry* This){
+static inline unsigned int table_entry_hash_Function(TableEntry *This) {
        unsigned int h = 0;
        unsigned int h = 0;
-       for(uint i=0; i<This->inputSize; i++){
+       for (uint i = 0; i < This->inputSize; i++) {
                h += This->inputs[i];
                h *= 31;
        }
        return h;
 }
 
                h += This->inputs[i];
                h *= 31;
        }
        return h;
 }
 
-static inline bool table_entry_equals(TableEntry* key1, TableEntry* key2){
-       if(key1->inputSize != key2->inputSize)
+static inline bool table_entry_equals(TableEntry *key1, TableEntry *key2) {
+       if (key1->inputSize != key2->inputSize)
                return false;
                return false;
-       for(uint i=0; i<key1->inputSize; i++)
-               if(key1->inputs[i]!=key2->inputs[i])
+       for (uint i = 0; i < key1->inputSize; i++)
+               if (key1->inputs[i] != key2->inputs[i])
                        return false;
        return true;
 }
 
                        return false;
        return true;
 }
 
-static inline unsigned int order_node_hash_Function(OrderNode* This){
+static inline unsigned int order_node_hash_Function(OrderNode *This) {
        return (uint) This->id;
        return (uint) This->id;
-       
+
 }
 
 }
 
-static inline bool order_node_equals(OrderNode* key1, OrderNode* key2){
+static inline bool order_node_equals(OrderNode *key1, OrderNode *key2) {
        return key1->id == key2->id;
 }
 
        return key1->id == key2->id;
 }
 
-static inline unsigned int order_edge_hash_Function(OrderEdge* This){
-       return (uint) (( (uintptr_t)This->sink)^((uintptr_t)This->source << 4) );
+static inline unsigned int order_edge_hash_Function(OrderEdge *This) {
+       return (uint) (((uintptr_t)This->sink) ^ ((uintptr_t)This->source << 4));
 }
 
 }
 
-static inline bool order_edge_equals(OrderEdge* key1, OrderEdge* key2){
+static inline bool order_edge_equals(OrderEdge *key1, OrderEdge *key2) {
        return key1->sink == key2->sink && key1->source == key2->source;
 }
 
 HashTableImpl(OrderPair, OrderPair *, OrderPair *, order_pair_hash_Function, order_pair_equals, ourfree);
 
        return key1->sink == key2->sink && key1->source == key2->source;
 }
 
 HashTableImpl(OrderPair, OrderPair *, OrderPair *, order_pair_hash_Function, order_pair_equals, ourfree);
 
-HashSetImpl(TableEntry, TableEntry*, table_entry_hash_Function, table_entry_equals);
-HashSetImpl(OrderNode, OrderNode*, order_node_hash_Function, order_node_equals);
-HashSetImpl(OrderEdge, OrderEdge*, order_edge_hash_Function, order_edge_equals);
+HashSetImpl(TableEntry, TableEntry *, table_entry_hash_Function, table_entry_equals);
+HashSetImpl(OrderNode, OrderNode *, order_node_hash_Function, order_node_equals);
+HashSetImpl(OrderEdge, OrderEdge *, order_edge_hash_Function, order_edge_equals);
 
 
index 5713e89178749aeabfb5232ce54a0dcd093a520e..36ba052319f625e5c69a5f3c19726084c936d48e 100644 (file)
@@ -21,14 +21,14 @@ VectorDef(Order, Order *);
 VectorDef(TableEntry, TableEntry *);
 VectorDef(ASTNode, ASTNode *);
 VectorDef(Int, uint64_t);
 VectorDef(TableEntry, TableEntry *);
 VectorDef(ASTNode, ASTNode *);
 VectorDef(Int, uint64_t);
-VectorDef(OrderNode, OrderNode*);
-VectorDef(OrderGraph, OrderGraph*);
+VectorDef(OrderNode, OrderNode *);
+VectorDef(OrderGraph, OrderGraph *);
 
 HashTableDef(Void, void *, void *);
 HashTableDef(OrderPair, OrderPair *, OrderPair *);
 
 HashSetDef(Void, void *);
 
 HashTableDef(Void, void *, void *);
 HashTableDef(OrderPair, OrderPair *, OrderPair *);
 
 HashSetDef(Void, void *);
-HashSetDef(TableEntry, TableEntry*);
-HashSetDef(OrderNode, OrderNode*);
-HashSetDef(OrderEdge, OrderEdge*);
+HashSetDef(TableEntry, TableEntry *);
+HashSetDef(OrderNode, OrderNode *);
+HashSetDef(OrderEdge, OrderEdge *);
 #endif
 #endif
index 650f33dc8352b3cea81983de89eb53af0a0054e7..f140fac7937055a92790ebdfef3594fc6a0a0cb9 100644 (file)
@@ -2,29 +2,29 @@
 #define VECTOR_H
 #include <string.h>
 
 #define VECTOR_H
 #include <string.h>
 
-#define VectorDef(name, type)                                                                                                                                                                          \
+#define VectorDef(name, type)                                           \
        struct Vector ## name {                                               \
                uint size;                                                          \
                uint capacity;                                                      \
        struct Vector ## name {                                               \
                uint size;                                                          \
                uint capacity;                                                      \
-               type * array;                                                       \
+               type *array;                                                       \
        };                                                                    \
        typedef struct Vector ## name Vector ## name;                         \
        Vector ## name * allocVector ## name(uint capacity);                  \
        Vector ## name * allocDefVector ## name();                            \
        Vector ## name * allocVectorArray ## name(uint capacity, type * array); \
        };                                                                    \
        typedef struct Vector ## name Vector ## name;                         \
        Vector ## name * allocVector ## name(uint capacity);                  \
        Vector ## name * allocDefVector ## name();                            \
        Vector ## name * allocVectorArray ## name(uint capacity, type * array); \
-       void pushVector ## name(Vector ## name *vector, type item);           \
-       type lastVector ## name(Vector ## name *vector);                                                                                        \
-       void popVector ## name(Vector ## name *vector);                                                                                         \
-       type getVector ## name(Vector ## name *vector, uint index);                                             \
-       void setVector ## name(Vector ## name *vector, uint index, type item); \
-       uint getSizeVector ## name(Vector ## name *vector);                   \
-       void setSizeVector ## name(Vector ## name *vector, uint size);                          \
-       void deleteVector ## name(Vector ## name *vector);                    \
-       void clearVector ## name(Vector ## name *vector);                     \
-       void deleteVectorArray ## name(Vector ## name *vector);                                                         \
-       type * exposeArray ## name(Vector ## name * vector);                                                                    \
+       void pushVector ## name(Vector ## name * vector, type item);           \
+       type lastVector ## name(Vector ## name * vector);                      \
+       void popVector ## name(Vector ## name * vector);                       \
+       type getVector ## name(Vector ## name * vector, uint index);           \
+       void setVector ## name(Vector ## name * vector, uint index, type item); \
+       uint getSizeVector ## name(Vector ## name * vector);                   \
+       void setSizeVector ## name(Vector ## name * vector, uint size);        \
+       void deleteVector ## name(Vector ## name * vector);                    \
+       void clearVector ## name(Vector ## name * vector);                     \
+       void deleteVectorArray ## name(Vector ## name * vector);               \
+       type *exposeArray ## name(Vector ## name * vector);                  \
        void initVector ## name(Vector ## name * vector, uint capacity); \
        void initVector ## name(Vector ## name * vector, uint capacity); \
-       void initDefVector ## name(Vector ## name * vector);                                            \
+       void initDefVector ## name(Vector ## name * vector);            \
        void initVectorArray ## name(Vector ## name * vector, uint capacity, type * array);
 
 #define VectorImpl(name, type, defcap)                                  \
        void initVectorArray ## name(Vector ## name * vector, uint capacity, type * array);
 
 #define VectorImpl(name, type, defcap)                                  \
                Vector ## name * tmp = (Vector ## name *)ourmalloc(sizeof(Vector ## name));  \
                tmp->size = 0;                                                      \
                tmp->capacity = capacity;                                           \
                Vector ## name * tmp = (Vector ## name *)ourmalloc(sizeof(Vector ## name));  \
                tmp->size = 0;                                                      \
                tmp->capacity = capacity;                                           \
-               tmp->array = (type *) ourmalloc(sizeof(type) * capacity);                                               \
+               tmp->array = (type *) ourmalloc(sizeof(type) * capacity);           \
                return tmp;                                                         \
        }                                                                     \
        Vector ## name * allocVectorArray ## name(uint capacity, type * array)  { \
                Vector ## name * tmp = allocVector ## name(capacity);               \
                return tmp;                                                         \
        }                                                                     \
        Vector ## name * allocVectorArray ## name(uint capacity, type * array)  { \
                Vector ## name * tmp = allocVector ## name(capacity);               \
-               tmp->size=capacity;                                                                                                                                                                                                     \
-               memcpy(tmp->array, array, capacity * sizeof(type));                                                                     \
+               tmp->size = capacity;                                                 \
+               memcpy(tmp->array, array, capacity * sizeof(type));                 \
                return tmp;                                                         \
        }                                                                     \
                return tmp;                                                         \
        }                                                                     \
-       void popVector ## name(Vector ## name *vector) {                                                                                        \
-               vector->size--;                                                                                                                                                                                                                 \
-       }                                                                                                                                                                                                                                                                                       \
-       type lastVector ## name(Vector ## name *vector) {                                                                                       \
-               return vector->array[vector->size-1];                                                                                                                           \
-       }                                                                                                                                                                                                                                                                                       \
-       void setSizeVector ## name(Vector ## name *vector, uint size) {                         \
-               if (size <= vector->size) {                                                                                                                                                                     \
-                       vector->size=size;                                                                                                                                                                                              \
-                       return;                                                                                                                                                                                                                                         \
-               } else if (size > vector->capacity) {                                                                                                                           \
-                       vector->array=(type *)ourrealloc(vector->array, size * sizeof(type));   \
-                       vector->capacity=size;                                                                                                                                                                          \
-               }                                                                                                                                                                                                                                                                               \
-               bzero(&vector->array[vector->size], (size-vector->size)*sizeof(type)); \
-               vector->size=size;                                                                                                                                                                                                      \
-       }                                                                                                                                                                                                                                                                                       \
-       void pushVector ## name(Vector ## name *vector, type item) {                                    \
-               if (vector->size >= vector->capacity) {                                                                                                                 \
-                       uint newcap=vector->capacity << 1;                                                                                                                              \
-                       vector->array=(type *)ourrealloc(vector->array, newcap * sizeof(type)); \
-                       vector->capacity=newcap;                                                                                                                                                                        \
+       void popVector ## name(Vector ## name * vector) {                      \
+               vector->size--;                                                     \
+       }                                                                     \
+       type lastVector ## name(Vector ## name * vector) {                     \
+               return vector->array[vector->size - 1];                               \
+       }                                                                     \
+       void setSizeVector ## name(Vector ## name * vector, uint size) {       \
+               if (size <= vector->size) {                                         \
+                       vector->size = size;                                                \
+                       return;                                                           \
+               } else if (size > vector->capacity) {                               \
+                       vector->array = (type *)ourrealloc(vector->array, size * sizeof(type)); \
+                       vector->capacity = size;                                            \
+               }                                                                   \
+               bzero(&vector->array[vector->size], (size - vector->size) * sizeof(type)); \
+               vector->size = size;                                                  \
+       }                                                                     \
+       void pushVector ## name(Vector ## name * vector, type item) {          \
+               if (vector->size >= vector->capacity) {                             \
+                       uint newcap = vector->capacity << 1;                                \
+                       vector->array = (type *)ourrealloc(vector->array, newcap * sizeof(type)); \
+                       vector->capacity = newcap;                                          \
                }                                                                   \
                vector->array[vector->size++] = item;                               \
        }                                                                     \
                }                                                                   \
                vector->array[vector->size++] = item;                               \
        }                                                                     \
                return vector->array[index];                                        \
        }                                                                     \
        void setVector ## name(Vector ## name * vector, uint index, type item) { \
                return vector->array[index];                                        \
        }                                                                     \
        void setVector ## name(Vector ## name * vector, uint index, type item) { \
-               vector->array[index]=item;                                          \
+               vector->array[index] = item;                                          \
        }                                                                     \
        }                                                                     \
-       uint getSizeVector ## name(Vector ## name *vector) {                  \
+       uint getSizeVector ## name(Vector ## name * vector) {                  \
                return vector->size;                                                \
        }                                                                     \
                return vector->size;                                                \
        }                                                                     \
-       void deleteVector ## name(Vector ## name *vector) {                     \
+       void deleteVector ## name(Vector ## name * vector) {                     \
                ourfree(vector->array);                                             \
                ourfree(vector);                                                    \
        }                                                                     \
                ourfree(vector->array);                                             \
                ourfree(vector);                                                    \
        }                                                                     \
-       void clearVector ## name(Vector ## name *vector) {                     \
-               vector->size=0;                                                     \
+       void clearVector ## name(Vector ## name * vector) {                     \
+               vector->size = 0;                                                     \
        }                                                                     \
        }                                                                     \
-       type * exposeArray ## name(Vector ## name * vector) {                 \
+       type *exposeArray ## name(Vector ## name * vector) {                 \
                return vector->array;                                               \
                return vector->array;                                               \
-       }                                                                                                                                                                                                                                                                                       \
-       void deleteVectorArray ## name(Vector ## name *vector) {                                                        \
+       }                                                                     \
+       void deleteVectorArray ## name(Vector ## name * vector) {              \
                ourfree(vector->array);                                             \
                ourfree(vector->array);                                             \
-       }                                                                                                                                                                                                                                                                                       \
+       }                                                                     \
        void initVector ## name(Vector ## name * vector, uint capacity) { \
                vector->size = 0;                                                      \
        void initVector ## name(Vector ## name * vector, uint capacity) { \
                vector->size = 0;                                                      \
-               vector->capacity = capacity;                                                                                                                                                                                    \
-               vector->array = (type *) ourmalloc(sizeof(type) * capacity);                            \
-       }                                                                                                                                                                                                                                                                                       \
-       void initDefVector ## name(Vector ## name * vector) {                                   \
-               initVector ## name(vector, defcap);                                                                                                     \
-       }                                                                                                                                                                                                                                                                                       \
-       void initVectorArray ## name(Vector ## name * vector, uint capacity, type * array) {    \
-               initVector ##name(vector, capacity);                                                                                                    \
-               vector->size=capacity;                                                                                                                                                                                  \
-               memcpy(vector->array, array, capacity * sizeof(type));  \
+               vector->capacity = capacity;                                              \
+               vector->array = (type *) ourmalloc(sizeof(type) * capacity);        \
+       }                                                                     \
+       void initDefVector ## name(Vector ## name * vector) {         \
+               initVector ## name(vector, defcap);                         \
+       }                                                                     \
+       void initVectorArray ## name(Vector ## name * vector, uint capacity, type * array) {  \
+               initVector ## name(vector, capacity);                          \
+               vector->size = capacity;                                              \
+               memcpy(vector->array, array, capacity * sizeof(type));  \
        }
 #endif
        }
 #endif
index 47c6ea0fef0f52f917ce7b69e4e09786b3d92e92..1b0c6b851cd3693463c57924827daf4d72a1c227 100644 (file)
@@ -4,36 +4,36 @@
 #include "element.h"
 #include "satencoder.h"
 
 #include "element.h"
 #include "satencoder.h"
 
-void initElementEncoding(ElementEncoding * This, Element *element) {
-       This->element=element;
-       This->type=ELEM_UNASSIGNED;
-       This->variables=NULL;
-       This->encodingArray=NULL;
-       This->inUseArray=NULL;
-       This->numVars=0;
-       This->encArraySize=0;
+void initElementEncoding(ElementEncoding *This, Element *element) {
+       This->element = element;
+       This->type = ELEM_UNASSIGNED;
+       This->variables = NULL;
+       This->encodingArray = NULL;
+       This->inUseArray = NULL;
+       This->numVars = 0;
+       This->encArraySize = 0;
 }
 
 void deleteElementEncoding(ElementEncoding *This) {
 }
 
 void deleteElementEncoding(ElementEncoding *This) {
-       if (This->variables!=NULL)
+       if (This->variables != NULL)
                ourfree(This->variables);
                ourfree(This->variables);
-       if (This->encodingArray!=NULL)
+       if (This->encodingArray != NULL)
                ourfree(This->encodingArray);
                ourfree(This->encodingArray);
-       if (This->inUseArray!=NULL)
+       if (This->inUseArray != NULL)
                ourfree(This->inUseArray);
 }
 
 void allocEncodingArrayElement(ElementEncoding *This, uint size) {
                ourfree(This->inUseArray);
 }
 
 void allocEncodingArrayElement(ElementEncoding *This, uint size) {
-       This->encodingArray=ourcalloc(1, sizeof(uint64_t)*size);
-       This->encArraySize=size;
+       This->encodingArray = ourcalloc(1, sizeof(uint64_t) * size);
+       This->encArraySize = size;
 }
 
 void allocInUseArrayElement(ElementEncoding *This, uint size) {
 }
 
 void allocInUseArrayElement(ElementEncoding *This, uint size) {
-       uint bytes = ((size + ((1 << 9)-1)) >> 6)&~7;//Depends on size of inUseArray
-       This->inUseArray=ourcalloc(1, bytes);
+       uint bytes = ((size + ((1 << 9) - 1)) >> 6) & ~7;//Depends on size of inUseArray
+       This->inUseArray = ourcalloc(1, bytes);
 }
 
 }
 
-void setElementEncodingType(ElementEncoding* This, ElementEncodingType type){
+void setElementEncodingType(ElementEncoding *This, ElementEncodingType type) {
        This->type = type;
 }
 
        This->type = type;
 }
 
index 61bdb3e88af8dfb783bcdf5c94f4b0e8ee213ded..c0f0d2d9e774270d30ee4c934fad0d23e91aa627 100644 (file)
@@ -12,12 +12,12 @@ typedef enum ElementEncodingType ElementEncodingType;
 
 struct ElementEncoding {
        ElementEncodingType type;
 
 struct ElementEncoding {
        ElementEncodingType type;
-       Element * element;
-       Edge * variables;/* List Variables Used To Encode Element */
+       Element *element;
+       Edge *variables;/* List Variables Used To Encode Element */
        union {
                struct {
        union {
                struct {
-                       uint64_t * encodingArray;       /* List the Variables in the appropriate order */
-                       uint64_t * inUseArray;/* Bitmap to track variables in use */
+                       uint64_t *encodingArray;        /* List the Variables in the appropriate order */
+                       uint64_t *inUseArray;   /* Bitmap to track variables in use */
                        uint encArraySize;
                };
                struct {
                        uint encArraySize;
                };
                struct {
@@ -32,19 +32,19 @@ struct ElementEncoding {
 };
 
 void initElementEncoding(ElementEncoding *This, Element *element);
 };
 
 void initElementEncoding(ElementEncoding *This, Element *element);
-static inline ElementEncodingType getElementEncodingType(ElementEncoding * This) {return This->type;}
-void setElementEncodingType(ElementEncodingThis, ElementEncodingType type);
+static inline ElementEncodingType getElementEncodingType(ElementEncoding *This) {return This->type;}
+void setElementEncodingType(ElementEncoding *This, ElementEncodingType type);
 void deleteElementEncoding(ElementEncoding *This);
 void allocEncodingArrayElement(ElementEncoding *This, uint size);
 void allocInUseArrayElement(ElementEncoding *This, uint size);
 static inline uint numEncodingVars(ElementEncoding *This) {return This->numVars;}
 
 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
 void deleteElementEncoding(ElementEncoding *This);
 void allocEncodingArrayElement(ElementEncoding *This, uint size);
 void allocInUseArrayElement(ElementEncoding *This, uint size);
 static inline uint numEncodingVars(ElementEncoding *This) {return This->numVars;}
 
 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
-       return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
+       return (This->inUseArray[(offset >> 6)] >> (offset & 63)) & 0x1;
 }
 
 static inline void setInUseElement(ElementEncoding *This, uint offset) {
 }
 
 static inline void setInUseElement(ElementEncoding *This, uint offset) {
-       This->inUseArray[(offset>>6)] |= 1 << (offset & 63);
+       This->inUseArray[(offset >> 6)] |= 1 << (offset & 63);
 }
 
 #endif
 }
 
 #endif
index 74cfb7685abc3d017b41d7e7d7edb6920525a55e..75910cfe307c3a3648f6358748f9de64fdafe592 100644 (file)
@@ -1,18 +1,18 @@
 #include "functionencoding.h"
 
 void initFunctionEncoding(FunctionEncoding *This, Element *function) {
 #include "functionencoding.h"
 
 void initFunctionEncoding(FunctionEncoding *This, Element *function) {
-       This->op.function=function;
-       This->type=FUNC_UNASSIGNED;
+       This->op.function = function;
+       This->type = FUNC_UNASSIGNED;
 }
 
 void initPredicateEncoding(FunctionEncoding *This,  Boolean *predicate) {
 }
 
 void initPredicateEncoding(FunctionEncoding *This,  Boolean *predicate) {
-       This->op.predicate=predicate;
-       This->type=FUNC_UNASSIGNED;
+       This->op.predicate = predicate;
+       This->type = FUNC_UNASSIGNED;
 }
 
 void deleteFunctionEncoding(FunctionEncoding *This) {
 }
 
 }
 
 void deleteFunctionEncoding(FunctionEncoding *This) {
 }
 
-void setFunctionEncodingType(FunctionEncoding* encoding, FunctionEncodingType type){
-       encoding->type=type;
+void setFunctionEncodingType(FunctionEncoding *encoding, FunctionEncodingType type) {
+       encoding->type = type;
 }
 }
index fa8729e086ef1ebde07ef1aaa6e088f020401cc0..bc98cd3be44fcc7891b6c15b3d5a9358e4af9986 100644 (file)
@@ -9,8 +9,8 @@ enum FunctionEncodingType {
 typedef enum FunctionEncodingType FunctionEncodingType;
 
 union ElementPredicate {
 typedef enum FunctionEncodingType FunctionEncodingType;
 
 union ElementPredicate {
-       Element * function;
-       Boolean * predicate;
+       Element *function;
+       Boolean *predicate;
 };
 
 typedef union ElementPredicate ElementPredicate;
 };
 
 typedef union ElementPredicate ElementPredicate;
@@ -23,8 +23,8 @@ struct FunctionEncoding {
 
 void initFunctionEncoding(FunctionEncoding *encoding, Element *function);
 void initPredicateEncoding(FunctionEncoding *encoding, Boolean *predicate);
 
 void initFunctionEncoding(FunctionEncoding *encoding, Element *function);
 void initPredicateEncoding(FunctionEncoding *encoding, Boolean *predicate);
-void setFunctionEncodingType(FunctionEncodingencoding, FunctionEncodingType type);
-static inline FunctionEncodingType getFunctionEncodingType(FunctionEncodingThis) {return This->type;}
+void setFunctionEncodingType(FunctionEncoding *encoding, FunctionEncodingType type);
+static inline FunctionEncodingType getFunctionEncodingType(FunctionEncoding *This) {return This->type;}
 void deleteFunctionEncoding(FunctionEncoding *This);
 
 #endif
 void deleteFunctionEncoding(FunctionEncoding *This);
 
 #endif
index bc64cc44f3a25777492142befd7570e44aec49fb..a7941a6405812d8ff8f599ce10dd1926ba03f344 100644 (file)
 #include "order.h"
 #include <strings.h>
 
 #include "order.h"
 #include <strings.h>
 
-void naiveEncodingDecision(CSolverThis) {
-       for (uint i=0; i < getSizeVectorBoolean(This->constraints); i++) {
-               Booleanboolean = getVectorBoolean(This->constraints, i);
+void naiveEncodingDecision(CSolver *This) {
+       for (uint i = 0; i < getSizeVectorBoolean(This->constraints); i++) {
+               Boolean *boolean = getVectorBoolean(This->constraints, i);
                naiveEncodingConstraint(boolean);
        }
 }
 
                naiveEncodingConstraint(boolean);
        }
 }
 
-void naiveEncodingConstraint(Boolean * This) {
-       switch(GETBOOLEANTYPE(This)) {
+void naiveEncodingConstraint(Boolean *This) {
+       switch (GETBOOLEANTYPE(This)) {
        case BOOLEANVAR: {
                return;
        }
        case ORDERCONST: {
        case BOOLEANVAR: {
                return;
        }
        case ORDERCONST: {
-               setOrderEncodingType( ((BooleanOrder*)This)->order, PAIRWISE );
+               setOrderEncodingType( ((BooleanOrder *)This)->order, PAIRWISE );
                return;
        }
        case LOGICOP: {
                return;
        }
        case LOGICOP: {
@@ -42,34 +42,34 @@ void naiveEncodingConstraint(Boolean * This) {
        }
 }
 
        }
 }
 
-void naiveEncodingLogicOp(BooleanLogic * This) {
-       for(uint i=0; i < getSizeArrayBoolean(&This->inputs); i++) {
+void naiveEncodingLogicOp(BooleanLogic *This) {
+       for (uint i = 0; i < getSizeArrayBoolean(&This->inputs); i++) {
                naiveEncodingConstraint(getArrayBoolean(&This->inputs, i));
        }
 }
 
                naiveEncodingConstraint(getArrayBoolean(&This->inputs, i));
        }
 }
 
-void naiveEncodingPredicate(BooleanPredicate * This) {
+void naiveEncodingPredicate(BooleanPredicate *This) {
        FunctionEncoding *encoding = getPredicateFunctionEncoding(This);
        if (getFunctionEncodingType(encoding) == FUNC_UNASSIGNED)
                setFunctionEncodingType(getPredicateFunctionEncoding(This), ENUMERATEIMPLICATIONS);
 
        FunctionEncoding *encoding = getPredicateFunctionEncoding(This);
        if (getFunctionEncodingType(encoding) == FUNC_UNASSIGNED)
                setFunctionEncodingType(getPredicateFunctionEncoding(This), ENUMERATEIMPLICATIONS);
 
-       for(uint i=0; i < getSizeArrayElement(&This->inputs); i++) {
-               Element *element=getArrayElement(&This->inputs, i);
+       for (uint i = 0; i < getSizeArrayElement(&This->inputs); i++) {
+               Element *element = getArrayElement(&This->inputs, i);
                naiveEncodingElement(element);
        }
 }
 
                naiveEncodingElement(element);
        }
 }
 
-void naiveEncodingElement(Element * This) {
-       ElementEncoding * encoding = getElementEncoding(This);
+void naiveEncodingElement(Element *This) {
+       ElementEncoding *encoding = getElementEncoding(This);
        if (getElementEncodingType(encoding) == ELEM_UNASSIGNED) {
                setElementEncodingType(encoding, BINARYINDEX);
                encodingArrayInitialization(encoding);
        }
        if (getElementEncodingType(encoding) == ELEM_UNASSIGNED) {
                setElementEncodingType(encoding, BINARYINDEX);
                encodingArrayInitialization(encoding);
        }
-       
-       if(GETELEMENTTYPE(This) == ELEMFUNCRETURN) {
-               ElementFunction *function=(ElementFunction *) This;
-               for(uint i=0; i < getSizeArrayElement(&function->inputs); i++) {
-                       Element * element=getArrayElement(&function->inputs, i);
+
+       if (GETELEMENTTYPE(This) == ELEMFUNCRETURN) {
+               ElementFunction *function = (ElementFunction *) This;
+               for (uint i = 0; i < getSizeArrayElement(&function->inputs); i++) {
+                       Element *element = getArrayElement(&function->inputs, i);
                        naiveEncodingElement(element);
                }
                FunctionEncoding *encoding = getElementFunctionEncoding(function);
                        naiveEncodingElement(element);
                }
                FunctionEncoding *encoding = getElementFunctionEncoding(function);
@@ -78,29 +78,29 @@ void naiveEncodingElement(Element * This) {
        }
 }
 
        }
 }
 
-uint getSizeEncodingArray(ElementEncoding *This, uint setSize){
-       switch(This->type){
-               case BINARYINDEX:
-                       return NEXTPOW2(setSize);
-               case ONEHOT:
-               case UNARY:
-                       return setSize;
-               default:
-                       ASSERT(0);
+uint getSizeEncodingArray(ElementEncoding *This, uint setSize) {
+       switch (This->type) {
+       case BINARYINDEX:
+               return NEXTPOW2(setSize);
+       case ONEHOT:
+       case UNARY:
+               return setSize;
+       default:
+               ASSERT(0);
        }
        return -1;
 }
 
 void encodingArrayInitialization(ElementEncoding *This) {
        }
        return -1;
 }
 
 void encodingArrayInitialization(ElementEncoding *This) {
-       Element * element=This->element;
-       Set * set= getElementSet(element);
-       ASSERT(set->isRange==false);
-       uint size=getSizeVectorInt(set->members);
-       uint encSize=getSizeEncodingArray(This, size);
+       Element *element = This->element;
+       Set *set = getElementSet(element);
+       ASSERT(set->isRange == false);
+       uint size = getSizeVectorInt(set->members);
+       uint encSize = getSizeEncodingArray(This, size);
        allocEncodingArrayElement(This, encSize);
        allocInUseArrayElement(This, encSize);
        allocEncodingArrayElement(This, encSize);
        allocInUseArrayElement(This, encSize);
-       for(uint i=0;i<size;i++) {
-               This->encodingArray[i]=getVectorInt(set->members, i);
+       for (uint i = 0; i < size; i++) {
+               This->encodingArray[i] = getVectorInt(set->members, i);
                setInUseElement(This, i);
        }
 }
                setInUseElement(This, i);
        }
 }
index a4b9ec176b07f117d91774ef81f0ca4f5b163f5c..c3260a050e92a99a0809c25a048b6395b5f54a6d 100644 (file)
@@ -9,11 +9,11 @@
  * @param encoder
  */
 
  * @param encoder
  */
 
-void naiveEncodingDecision(CSolvercsolver);
-void naiveEncodingConstraint(Boolean * This);
-void naiveEncodingLogicOp(BooleanLogic * This);
-void naiveEncodingPredicate(BooleanPredicate * This);
-void naiveEncodingElement(Element * This);
+void naiveEncodingDecision(CSolver *csolver);
+void naiveEncodingConstraint(Boolean *This);
+void naiveEncodingLogicOp(BooleanLogic *This);
+void naiveEncodingPredicate(BooleanPredicate *This);
+void naiveEncodingElement(Element *This);
 void encodingArrayInitialization(ElementEncoding *This);
 uint getSizeEncodingArray(ElementEncoding *, uint setSize);
 
 void encodingArrayInitialization(ElementEncoding *This);
 uint getSizeEncodingArray(ElementEncoding *, uint setSize);
 
index bc22a83bb14557f8603a75d24bdfdd146ad734f2..c4632dafcc376abc1a78f379ce0f65c22935867b 100644 (file)
@@ -1,8 +1,8 @@
 #include "orderedge.h"
 #include "ordergraph.h"
 
 #include "orderedge.h"
 #include "ordergraph.h"
 
-OrderEdge* allocOrderEdge(OrderNode* source, OrderNode* sink) {
-       OrderEdge* This = (OrderEdge*) ourmalloc(sizeof(OrderEdge));
+OrderEdge *allocOrderEdge(OrderNode *source, OrderNode *sink) {
+       OrderEdge *This = (OrderEdge *) ourmalloc(sizeof(OrderEdge));
        This->source = source;
        This->sink = sink;
        This->polPos = false;
        This->source = source;
        This->sink = sink;
        This->polPos = false;
@@ -13,7 +13,7 @@ OrderEdge* allocOrderEdge(OrderNode* source, OrderNode* sink) {
        return This;
 }
 
        return This;
 }
 
-void deleteOrderEdge(OrderEdgeThis) {
+void deleteOrderEdge(OrderEdge *This) {
        ourfree(This);
 }
 
        ourfree(This);
 }
 
index a34e3d26604dcf2c2e8292c4c0fb90935566d756..21fa9034fb8d061e5f6f3bf8fd77dabe6c2b91ec 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   orderedge.h
  * Author: hamed
  *
  * File:   orderedge.h
  * Author: hamed
  *
 #include "mymemory.h"
 
 struct OrderEdge {
 #include "mymemory.h"
 
 struct OrderEdge {
-       OrderNodesource;
-       OrderNodesink;
-       unsigned int polPos:1;
-       unsigned int polNeg:1;
-       unsigned int mustPos:1;
-       unsigned int mustNeg:1;
-       unsigned int pseudoPos:1;
+       OrderNode *source;
+       OrderNode *sink;
+       unsigned int polPos : 1;
+       unsigned int polNeg : 1;
+       unsigned int mustPos : 1;
+       unsigned int mustNeg : 1;
+       unsigned int pseudoPos : 1;
 };
 
 };
 
-OrderEdge* allocOrderEdge(OrderNode* begin, OrderNode* end);
-void deleteOrderEdge(OrderEdgeThis);
-void setPseudoPos(OrderGraph *graph, OrderEdgeedge);
+OrderEdge *allocOrderEdge(OrderNode *begin, OrderNode *end);
+void deleteOrderEdge(OrderEdge *This);
+void setPseudoPos(OrderGraph *graph, OrderEdge *edge);
 void setMustPos(OrderGraph *graph, OrderEdge *edge);
 void setMustNeg(OrderGraph *graph, OrderEdge *edge);
 void setPolPos(OrderGraph *graph, OrderEdge *edge);
 void setPolNeg(OrderGraph *graph, OrderEdge *edge);
 
 void setMustPos(OrderGraph *graph, OrderEdge *edge);
 void setMustNeg(OrderGraph *graph, OrderEdge *edge);
 void setPolPos(OrderGraph *graph, OrderEdge *edge);
 void setPolNeg(OrderGraph *graph, OrderEdge *edge);
 
-#endif /* ORDEREDGE_H */
+#endif/* ORDEREDGE_H */
 
 
index ee3480d9c2c4159769217dde510a9f686d0201d3..103b96204bbabefabcf6a4dda160fd5711ca93ca 100644 (file)
@@ -7,20 +7,20 @@
 #include "ordernode.h"
 #include "rewriter.h"
 
 #include "ordernode.h"
 #include "rewriter.h"
 
-OrderGraphbuildOrderGraph(Order *order) {
-       OrderGraphorderGraph = allocOrderGraph(order);
+OrderGraph *buildOrderGraph(Order *order) {
+       OrderGraph *orderGraph = allocOrderGraph(order);
        uint constrSize = getSizeVectorBooleanOrder(&order->constraints);
        uint constrSize = getSizeVectorBooleanOrder(&order->constraints);
-       for(uint j=0; j<constrSize; j++){
+       for (uint j = 0; j < constrSize; j++) {
                addOrderConstraintToOrderGraph(orderGraph, getVectorBooleanOrder(&order->constraints, j));
        }
        return orderGraph;
 }
 
                addOrderConstraintToOrderGraph(orderGraph, getVectorBooleanOrder(&order->constraints, j));
        }
        return orderGraph;
 }
 
-void DFS(OrderGraph* graph, VectorOrderNode* finishNodes) {
-       HSIteratorOrderNodeiterator = iteratorOrderNode(graph->nodes);
-       while(hasNextOrderNode(iterator)){
-               OrderNodenode = nextOrderNode(iterator);
-               if(node->status == NOTVISITED){
+void DFS(OrderGraph *graph, VectorOrderNode *finishNodes) {
+       HSIteratorOrderNode *iterator = iteratorOrderNode(graph->nodes);
+       while (hasNextOrderNode(iterator)) {
+               OrderNode *node = nextOrderNode(iterator);
+               if (node->status == NOTVISITED) {
                        node->status = VISITED;
                        DFSNodeVisit(node, finishNodes, false, 0);
                        node->status = FINISHED;
                        node->status = VISITED;
                        DFSNodeVisit(node, finishNodes, false, 0);
                        node->status = FINISHED;
@@ -30,12 +30,12 @@ void DFS(OrderGraph* graph, VectorOrderNode* finishNodes) {
        deleteIterOrderNode(iterator);
 }
 
        deleteIterOrderNode(iterator);
 }
 
-void DFSReverse(OrderGraph* graph, VectorOrderNode* finishNodes) {
+void DFSReverse(OrderGraph *graph, VectorOrderNode *finishNodes) {
        uint size = getSizeVectorOrderNode(finishNodes);
        uint size = getSizeVectorOrderNode(finishNodes);
-       uint sccNum=1;
-       for(int i=size-1; i>=0; i--){
-               OrderNodenode = getVectorOrderNode(finishNodes, i);
-               if(node->status == NOTVISITED){
+       uint sccNum = 1;
+       for (int i = size - 1; i >= 0; i--) {
+               OrderNode *node = getVectorOrderNode(finishNodes, i);
+               if (node->status == NOTVISITED) {
                        node->status = VISITED;
                        DFSNodeVisit(node, NULL, true, sccNum);
                        node->sccNum = sccNum;
                        node->status = VISITED;
                        DFSNodeVisit(node, NULL, true, sccNum);
                        node->sccNum = sccNum;
@@ -45,21 +45,21 @@ void DFSReverse(OrderGraph* graph, VectorOrderNode* finishNodes) {
        }
 }
 
        }
 }
 
-void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse, uint sccNum) {
-       HSIteratorOrderEdge* iterator = isReverse?iteratorOrderEdge(node->inEdges):iteratorOrderEdge(node->outEdges);
-       while(hasNextOrderEdge(iterator)){
-               OrderEdgeedge = nextOrderEdge(iterator);
-               if (!edge->polPos && !edge->pseudoPos) //Ignore edges that do not have positive polarity
+void DFSNodeVisit(OrderNode *node, VectorOrderNode *finishNodes, bool isReverse, uint sccNum) {
+       HSIteratorOrderEdge *iterator = isReverse ? iteratorOrderEdge(node->inEdges) : iteratorOrderEdge(node->outEdges);
+       while (hasNextOrderEdge(iterator)) {
+               OrderEdge *edge = nextOrderEdge(iterator);
+               if (!edge->polPos && !edge->pseudoPos)//Ignore edges that do not have positive polarity
                        continue;
                        continue;
-               
-               OrderNode* child = isReverse? edge->source: edge->sink;
 
 
-               if(child->status == NOTVISITED) {
+               OrderNode *child = isReverse ? edge->source : edge->sink;
+
+               if (child->status == NOTVISITED) {
                        child->status = VISITED;
                        DFSNodeVisit(child, finishNodes, isReverse, sccNum);
                        child->status = FINISHED;
                        child->status = VISITED;
                        DFSNodeVisit(child, finishNodes, isReverse, sccNum);
                        child->status = FINISHED;
-                       if(!isReverse)
-                               pushVectorOrderNode(finishNodes, child); 
+                       if (!isReverse)
+                               pushVectorOrderNode(finishNodes, child);
                        else
                                child->sccNum = sccNum;
                }
                        else
                                child->sccNum = sccNum;
                }
@@ -67,17 +67,17 @@ void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse,
        deleteIterOrderEdge(iterator);
 }
 
        deleteIterOrderEdge(iterator);
 }
 
-void resetNodeInfoStatusSCC(OrderGraphgraph) {
-       HSIteratorOrderNodeiterator = iteratorOrderNode(graph->nodes);
-       while(hasNextOrderNode(iterator)){
+void resetNodeInfoStatusSCC(OrderGraph *graph) {
+       HSIteratorOrderNode *iterator = iteratorOrderNode(graph->nodes);
+       while (hasNextOrderNode(iterator)) {
                nextOrderNode(iterator)->status = NOTVISITED;
        }
        deleteIterOrderNode(iterator);
 }
 
                nextOrderNode(iterator)->status = NOTVISITED;
        }
        deleteIterOrderNode(iterator);
 }
 
-void computeStronglyConnectedComponentGraph(OrderGraphgraph) {
+void computeStronglyConnectedComponentGraph(OrderGraph *graph) {
        VectorOrderNode finishNodes;
        VectorOrderNode finishNodes;
-       initDefVectorOrderNode(& finishNodes);
+       initDefVectorOrderNode(&finishNodes);
        DFS(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
        DFSReverse(graph, &finishNodes);
        DFS(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
        DFSReverse(graph, &finishNodes);
@@ -85,32 +85,32 @@ void computeStronglyConnectedComponentGraph(OrderGraph* graph) {
        deleteVectorArrayOrderNode(&finishNodes);
 }
 
        deleteVectorArrayOrderNode(&finishNodes);
 }
 
-void removeMustBeTrueNodes(OrderGraphgraph) {
+void removeMustBeTrueNodes(OrderGraph *graph) {
        //TODO: Nodes that all the incoming/outgoing edges are MUST_BE_TRUE
 }
 
        //TODO: Nodes that all the incoming/outgoing edges are MUST_BE_TRUE
 }
 
-void DFSPseudoNodeVisit(OrderGraph *graph, OrderNodenode) {
-       HSIteratorOrderEdgeiterator = iteratorOrderEdge(node->inEdges);
-       while(hasNextOrderEdge(iterator)){
-               OrderEdgeinEdge = nextOrderEdge(iterator);
+void DFSPseudoNodeVisit(OrderGraph *graph, OrderNode *node) {
+       HSIteratorOrderEdge *iterator = iteratorOrderEdge(node->inEdges);
+       while (hasNextOrderEdge(iterator)) {
+               OrderEdge *inEdge = nextOrderEdge(iterator);
                if (inEdge->polNeg) {
                if (inEdge->polNeg) {
-                       OrderNodesrc = inEdge->source;
-                       if (src->status==VISITED) {
+                       OrderNode *src = inEdge->source;
+                       if (src->status == VISITED) {
                                //Make a pseudoEdge to point backwards
                                //Make a pseudoEdge to point backwards
-                               OrderEdge * newedge = getOrderEdgeFromOrderGraph(graph, inEdge->sink, inEdge->source);
+                               OrderEdge *newedge = getOrderEdgeFromOrderGraph(graph, inEdge->sink, inEdge->source);
                                newedge->pseudoPos = true;
                        }
                }
        }
        deleteIterOrderEdge(iterator);
        iterator = iteratorOrderEdge(node->outEdges);
                                newedge->pseudoPos = true;
                        }
                }
        }
        deleteIterOrderEdge(iterator);
        iterator = iteratorOrderEdge(node->outEdges);
-       while(hasNextOrderEdge(iterator)){
-               OrderEdgeedge = nextOrderEdge(iterator);
-               if (!edge->polPos) //Ignore edges that do not have positive polarity
+       while (hasNextOrderEdge(iterator)) {
+               OrderEdge *edge = nextOrderEdge(iterator);
+               if (!edge->polPos)//Ignore edges that do not have positive polarity
                        continue;
                        continue;
-               
-               OrderNodechild = edge->sink;
-               if(child->status == NOTVISITED){
+
+               OrderNode *child = edge->sink;
+               if (child->status == NOTVISITED) {
                        child->status = VISITED;
                        DFSPseudoNodeVisit(graph, child);
                        child->status = FINISHED;
                        child->status = VISITED;
                        DFSPseudoNodeVisit(graph, child);
                        child->status = FINISHED;
@@ -119,16 +119,16 @@ void DFSPseudoNodeVisit(OrderGraph *graph, OrderNode* node) {
        deleteIterOrderEdge(iterator);
 }
 
        deleteIterOrderEdge(iterator);
 }
 
-void completePartialOrderGraph(OrderGraphgraph) {
+void completePartialOrderGraph(OrderGraph *graph) {
        VectorOrderNode finishNodes;
        VectorOrderNode finishNodes;
-       initDefVectorOrderNode(& finishNodes);
+       initDefVectorOrderNode(&finishNodes);
        DFS(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
 
        uint size = getSizeVectorOrderNode(&finishNodes);
        DFS(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
 
        uint size = getSizeVectorOrderNode(&finishNodes);
-       for(int i=size-1; i>=0; i--){
-               OrderNodenode = getVectorOrderNode(&finishNodes, i);
-               if(node->status == NOTVISITED){
+       for (int i = size - 1; i >= 0; i--) {
+               OrderNode *node = getVectorOrderNode(&finishNodes, i);
+               if (node->status == NOTVISITED) {
                        node->status = VISITED;
                        DFSPseudoNodeVisit(graph, node);
                        node->status = FINISHED;
                        node->status = VISITED;
                        DFSPseudoNodeVisit(graph, node);
                        node->status = FINISHED;
@@ -139,11 +139,11 @@ void completePartialOrderGraph(OrderGraph* graph) {
        deleteVectorArrayOrderNode(&finishNodes);
 }
 
        deleteVectorArrayOrderNode(&finishNodes);
 }
 
-void DFSMust(OrderGraph* graph, VectorOrderNode* finishNodes) {
-       HSIteratorOrderNodeiterator = iteratorOrderNode(graph->nodes);
-       while(hasNextOrderNode(iterator)){
-               OrderNodenode = nextOrderNode(iterator);
-               if(node->status == NOTVISITED){
+void DFSMust(OrderGraph *graph, VectorOrderNode *finishNodes) {
+       HSIteratorOrderNode *iterator = iteratorOrderNode(graph->nodes);
+       while (hasNextOrderNode(iterator)) {
+               OrderNode *node = nextOrderNode(iterator);
+               if (node->status == NOTVISITED) {
                        node->status = VISITED;
                        DFSMustNodeVisit(node, finishNodes, false);
                        node->status = FINISHED;
                        node->status = VISITED;
                        DFSMustNodeVisit(node, finishNodes, false);
                        node->status = FINISHED;
@@ -153,12 +153,12 @@ void DFSMust(OrderGraph* graph, VectorOrderNode* finishNodes) {
        deleteIterOrderNode(iterator);
 }
 
        deleteIterOrderNode(iterator);
 }
 
-void DFSMustNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool clearBackEdges) {
+void DFSMustNodeVisit(OrderNode *node, VectorOrderNode *finishNodes, bool clearBackEdges) {
        //First compute implication of transitive closure on must pos edges
        //First compute implication of transitive closure on must pos edges
-       HSIteratorOrderEdgeiterator = iteratorOrderEdge(node->outEdges);
-       while(hasNextOrderEdge(iterator)){
-               OrderEdgeedge = nextOrderEdge(iterator);
-               OrderNodeparent = edge->source;
+       HSIteratorOrderEdge *iterator = iteratorOrderEdge(node->outEdges);
+       while (hasNextOrderEdge(iterator)) {
+               OrderEdge *edge = nextOrderEdge(iterator);
+               OrderNode *parent = edge->source;
                if (parent->status == VISITED) {
                        edge->mustPos = true;
                }
                if (parent->status == VISITED) {
                        edge->mustPos = true;
                }
@@ -167,33 +167,33 @@ void DFSMustNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool clearB
 
        //Next compute implication of transitive closure on must neg edges
        iterator = iteratorOrderEdge(node->outEdges);
 
        //Next compute implication of transitive closure on must neg edges
        iterator = iteratorOrderEdge(node->outEdges);
-       while(hasNextOrderEdge(iterator)){
-               OrderEdgeedge = nextOrderEdge(iterator);
-               OrderNodechild = edge->sink;
-               
-               if (clearBackEdges && child->status==VISITED) {
+       while (hasNextOrderEdge(iterator)) {
+               OrderEdge *edge = nextOrderEdge(iterator);
+               OrderNode *child = edge->sink;
+
+               if (clearBackEdges && child->status == VISITED) {
                        //We have a backedge, so note that this edge must be negative
                        edge->mustNeg = true;
                }
 
                        //We have a backedge, so note that this edge must be negative
                        edge->mustNeg = true;
                }
 
-               if (!edge->mustPos) //Ignore edges that are not must Positive edges
+               if (!edge->mustPos)     //Ignore edges that are not must Positive edges
                        continue;
 
                        continue;
 
-               if(child->status == NOTVISITED){
+               if (child->status == NOTVISITED) {
                        child->status = VISITED;
                        DFSMustNodeVisit(child, finishNodes, clearBackEdges);
                        child->status = FINISHED;
                        child->status = VISITED;
                        DFSMustNodeVisit(child, finishNodes, clearBackEdges);
                        child->status = FINISHED;
-                       pushVectorOrderNode(finishNodes, child); 
+                       pushVectorOrderNode(finishNodes, child);
                }
        }
        deleteIterOrderEdge(iterator);
 }
 
                }
        }
        deleteIterOrderEdge(iterator);
 }
 
-void DFSClearContradictions(OrderGraph* graph, VectorOrderNode* finishNodes) {
-       uint size=getSizeVectorOrderNode(finishNodes);
-       for(int i=size-1; i>=0; i--){
-               OrderNode* node=getVectorOrderNode(finishNodes, i);
-               if(node->status == NOTVISITED){
+void DFSClearContradictions(OrderGraph *graph, VectorOrderNode *finishNodes) {
+       uint size = getSizeVectorOrderNode(finishNodes);
+       for (int i = size - 1; i >= 0; i--) {
+               OrderNode *node = getVectorOrderNode(finishNodes, i);
+               if (node->status == NOTVISITED) {
                        node->status = VISITED;
                        DFSMustNodeVisit(node, NULL, true);
                        node->status = FINISHED;
                        node->status = VISITED;
                        DFSMustNodeVisit(node, NULL, true);
                        node->status = FINISHED;
@@ -202,13 +202,13 @@ void DFSClearContradictions(OrderGraph* graph, VectorOrderNode* finishNodes) {
 }
 
 /* This function finds edges that would form a cycle with must edges
 }
 
 /* This function finds edges that would form a cycle with must edges
-        and forces them to be mustNeg.  It also decides whether an edge
-        must be true because of transitivity from other must be true
-        edges. */
+   and forces them to be mustNeg.  It also decides whether an edge
+   must be true because of transitivity from other must be true
+   edges. */
 
 void reachMustAnalysis(OrderGraph *graph) {
        VectorOrderNode finishNodes;
 
 void reachMustAnalysis(OrderGraph *graph) {
        VectorOrderNode finishNodes;
-       initDefVectorOrderNode(& finishNodes);
+       initDefVectorOrderNode(&finishNodes);
        //Topologically sort the mustPos edge graph
        DFSMust(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
        //Topologically sort the mustPos edge graph
        DFSMust(graph, &finishNodes);
        resetNodeInfoStatusSCC(graph);
@@ -220,16 +220,16 @@ void reachMustAnalysis(OrderGraph *graph) {
 }
 
 /* This function finds edges that must be positive and forces the
 }
 
 /* This function finds edges that must be positive and forces the
-        inverse edge to be negative (and clears its positive polarity if it
-        had one). */
+   inverse edge to be negative (and clears its positive polarity if it
+   had one). */
 
 void localMustAnalysisTotal(OrderGraph *graph) {
 
 void localMustAnalysisTotal(OrderGraph *graph) {
-       HSIteratorOrderEdgeiterator = iteratorOrderEdge(graph->edges);
-       while(hasNextOrderEdge(iterator)) {
+       HSIteratorOrderEdge *iterator = iteratorOrderEdge(graph->edges);
+       while (hasNextOrderEdge(iterator)) {
                OrderEdge *edge = nextOrderEdge(iterator);
                OrderEdge *edge = nextOrderEdge(iterator);
-               if (edge -> mustPos) {
-                       OrderEdge *invEdge=getInverseOrderEdge(graph, edge);
-                       if (invEdge!= NULL && !invEdge -> mustPos && invEdge->polPos) {
+               if (edge->mustPos) {
+                       OrderEdge *invEdge = getInverseOrderEdge(graph, edge);
+                       if (invEdge != NULL && !invEdge->mustPos && invEdge->polPos) {
                                invEdge->polPos = false;
                        }
                        invEdge->mustNeg = true;
                                invEdge->polPos = false;
                        }
                        invEdge->mustNeg = true;
@@ -239,20 +239,20 @@ void localMustAnalysisTotal(OrderGraph *graph) {
 }
 
 /** This finds edges that must be positive and forces the inverse edge
 }
 
 /** This finds edges that must be positive and forces the inverse edge
-               to be negative.  It also clears the negative flag of this edge.
-               It also finds edges that must be negative and clears the positive
-               polarity. */
+    to be negative.  It also clears the negative flag of this edge.
+    It also finds edges that must be negative and clears the positive
+    polarity. */
 
 void localMustAnalysisPartial(OrderGraph *graph) {
 
 void localMustAnalysisPartial(OrderGraph *graph) {
-       HSIteratorOrderEdgeiterator = iteratorOrderEdge(graph->edges);
-       while(hasNextOrderEdge(iterator)) {
+       HSIteratorOrderEdge *iterator = iteratorOrderEdge(graph->edges);
+       while (hasNextOrderEdge(iterator)) {
                OrderEdge *edge = nextOrderEdge(iterator);
                OrderEdge *edge = nextOrderEdge(iterator);
-               if (edge -> mustPos) {
+               if (edge->mustPos) {
                        if (edge->polNeg && !edge->mustNeg) {
                                edge->polNeg = false;
                        }
                        if (edge->polNeg && !edge->mustNeg) {
                                edge->polNeg = false;
                        }
-                       OrderEdge *invEdge=getInverseOrderEdge(graph, edge);
-                       if (invEdge != NULL && !invEdge -> mustPos) {
+                       OrderEdge *invEdge = getInverseOrderEdge(graph, edge);
+                       if (invEdge != NULL && !invEdge->mustPos) {
                                invEdge->polPos = false;
                        }
                        invEdge->mustNeg = true;
                                invEdge->polPos = false;
                        }
                        invEdge->mustNeg = true;
@@ -265,12 +265,12 @@ void localMustAnalysisPartial(OrderGraph *graph) {
 }
 
 void decomposeOrder(Order *order, OrderGraph *graph) {
 }
 
 void decomposeOrder(Order *order, OrderGraph *graph) {
-       uint size=getSizeVectorBooleanOrder(&order->constraints);
-       for(uint i=0;i<size;i++) {
-               BooleanOrder *orderconstraint=getVectorBooleanOrder(&order->constraints, i);
-               OrderNode *from=getOrderNodeFromOrderGraph(graph, orderconstraint->first);
-               OrderNode *to=getOrderNodeFromOrderGraph(graph, orderconstraint->second);
-               OrderEdge* edge=getOrderEdgeFromOrderGraph(graph, from, to);
+       uint size = getSizeVectorBooleanOrder(&order->constraints);
+       for (uint i = 0; i < size; i++) {
+               BooleanOrder *orderconstraint = getVectorBooleanOrder(&order->constraints, i);
+               OrderNode *from = getOrderNodeFromOrderGraph(graph, orderconstraint->first);
+               OrderNode *to = getOrderNodeFromOrderGraph(graph, orderconstraint->second);
+               OrderEdge *edge = getOrderEdgeFromOrderGraph(graph, from, to);
                if (from->sccNum < to->sccNum) {
                        //replace with true
                        replaceBooleanWithTrue((Boolean *)orderconstraint);
                if (from->sccNum < to->sccNum) {
                        //replace with true
                        replaceBooleanWithTrue((Boolean *)orderconstraint);
@@ -284,12 +284,12 @@ void decomposeOrder(Order *order, OrderGraph *graph) {
        }
 }
 
        }
 }
 
-void orderAnalysis(CSolverThis) {
+void orderAnalysis(CSolver *This) {
        uint size = getSizeVectorOrder(This->allOrders);
        uint size = getSizeVectorOrder(This->allOrders);
-       for(uint i=0; i<size; i++){
-               Orderorder = getVectorOrder(This->allOrders, i);
-               OrderGraphgraph = buildOrderGraph(order);
-               if (order->type==PARTIAL) {
+       for (uint i = 0; i < size; i++) {
+               Order *order = getVectorOrder(This->allOrders, i);
+               OrderGraph *graph = buildOrderGraph(order);
+               if (order->type == PARTIAL) {
                        //Required to do SCC analysis for partial order graphs.  It
                        //makes sure we don't incorrectly optimize graphs with negative
                        //polarity edges
                        //Required to do SCC analysis for partial order graphs.  It
                        //makes sure we don't incorrectly optimize graphs with negative
                        //polarity edges
@@ -298,9 +298,9 @@ void orderAnalysis(CSolver* This) {
 
                //This analysis is completely optional
                reachMustAnalysis(graph);
 
                //This analysis is completely optional
                reachMustAnalysis(graph);
-               
+
                //This pair of analysis is also optional
                //This pair of analysis is also optional
-               if (order->type==PARTIAL) {
+               if (order->type == PARTIAL) {
                        localMustAnalysisPartial(graph);
                } else {
                        localMustAnalysisTotal(graph);
                        localMustAnalysisPartial(graph);
                } else {
                        localMustAnalysisTotal(graph);
@@ -313,7 +313,7 @@ void orderAnalysis(CSolver* This) {
                computeStronglyConnectedComponentGraph(graph);
 
                decomposeOrder(order, graph);
                computeStronglyConnectedComponentGraph(graph);
 
                decomposeOrder(order, graph);
-                       
+
                deleteOrderGraph(graph);
        }
 }
                deleteOrderGraph(graph);
        }
 }
index e25ee42994973bb46b6ec8f9f1e38b974ec62185..c48a0f7d3e6e50e841ab4ce596d986f7c0077a6e 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   orderencoder.h
  * Author: hamed
  *
  * File:   orderencoder.h
  * Author: hamed
  *
 #include "structs.h"
 #include "mymemory.h"
 
 #include "structs.h"
 #include "mymemory.h"
 
-OrderGraphbuildOrderGraph(Order *order);
-void computeStronglyConnectedComponentGraph(OrderGraphgraph);
-void orderAnalysis(CSolversolver);
-void initializeNodeInfoSCC(OrderGraphgraph);
-void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse, uint sccNum);
-void DFS(OrderGraph* graph, VectorOrderNode* finishNodes);
-void DFSReverse(OrderGraph* graph, VectorOrderNode* finishNodes);
-void completePartialOrderGraph(OrderGraphgraph);
-void resetNodeInfoStatusSCC(OrderGraphgraph);
-void removeMustBeTrueNodes(OrderGraphgraph);
-void DFSPseudoNodeVisit(OrderGraph *graph, OrderNodenode);
-void completePartialOrderGraph(OrderGraphgraph);
-void DFSMust(OrderGraph* graph, VectorOrderNode* finishNodes);
-void DFSMustNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool clearBackEdges);
-void DFSClearContradictions(OrderGraph* graph, VectorOrderNode* finishNodes);
+OrderGraph *buildOrderGraph(Order *order);
+void computeStronglyConnectedComponentGraph(OrderGraph *graph);
+void orderAnalysis(CSolver *solver);
+void initializeNodeInfoSCC(OrderGraph *graph);
+void DFSNodeVisit(OrderNode *node, VectorOrderNode *finishNodes, bool isReverse, uint sccNum);
+void DFS(OrderGraph *graph, VectorOrderNode *finishNodes);
+void DFSReverse(OrderGraph *graph, VectorOrderNode *finishNodes);
+void completePartialOrderGraph(OrderGraph *graph);
+void resetNodeInfoStatusSCC(OrderGraph *graph);
+void removeMustBeTrueNodes(OrderGraph *graph);
+void DFSPseudoNodeVisit(OrderGraph *graph, OrderNode *node);
+void completePartialOrderGraph(OrderGraph *graph);
+void DFSMust(OrderGraph *graph, VectorOrderNode *finishNodes);
+void DFSMustNodeVisit(OrderNode *node, VectorOrderNode *finishNodes, bool clearBackEdges);
+void DFSClearContradictions(OrderGraph *graph, VectorOrderNode *finishNodes);
 void reachMustAnalysis(OrderGraph *graph);
 void localMustAnalysisTotal(OrderGraph *graph);
 void localMustAnalysisPartial(OrderGraph *graph);
 void reachMustAnalysis(OrderGraph *graph);
 void localMustAnalysisTotal(OrderGraph *graph);
 void localMustAnalysisPartial(OrderGraph *graph);
-void orderAnalysis(CSolverThis);
+void orderAnalysis(CSolver *This);
 void decomposeOrder(Order *order, OrderGraph *graph);
 
 void decomposeOrder(Order *order, OrderGraph *graph);
 
-#endif /* ORDERGRAPHBUILDER_H */
+#endif/* ORDERGRAPHBUILDER_H */
 
 
index 1f1d93f514b8bc133f7ef12a855449a809fba402..51dddccc52b4263a7e1ea1bd9fc3b12b63a8b7df 100644 (file)
@@ -1,8 +1,8 @@
 #include "orderencoding.h"
 
 #include "orderencoding.h"
 
-void initOrderEncoding(OrderEncoding * This, Order *order) {
-       This->type=ORDER_UNASSIGNED;
-       This->order=order;
+void initOrderEncoding(OrderEncoding *This, Order *order) {
+       This->type = ORDER_UNASSIGNED;
+       This->order = order;
 }
 
 void deleteOrderEncoding(OrderEncoding *This) {
 }
 
 void deleteOrderEncoding(OrderEncoding *This) {
index f408d665dd405b208ff0f3be4e4e39e2b6e30fcc..3b7b4f7cf0eb7bf94abb081e267caf6dece66786 100644 (file)
@@ -13,7 +13,7 @@ struct OrderEncoding {
        Order *order;
 };
 
        Order *order;
 };
 
-void initOrderEncoding(OrderEncoding * This, Order *order);
+void initOrderEncoding(OrderEncoding *This, Order *order);
 void deleteOrderEncoding(OrderEncoding *This);
 
 #endif
 void deleteOrderEncoding(OrderEncoding *This);
 
 #endif
index e6cb64e1ba3016dc3a4bd7ffd4ec5ca3a258fd39..a9ab298447387532e7368f54e819bc400c49e81c 100644 (file)
@@ -5,40 +5,40 @@
 #include "ordergraph.h"
 #include "order.h"
 
 #include "ordergraph.h"
 #include "order.h"
 
-OrderGraphallocOrderGraph(Order *order) {
-       OrderGraph* This = (OrderGraph*) ourmalloc(sizeof(OrderGraph));
+OrderGraph *allocOrderGraph(Order *order) {
+       OrderGraph *This = (OrderGraph *) ourmalloc(sizeof(OrderGraph));
        This->nodes = allocHashSetOrderNode(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
        This->order = order;
        return This;
 }
 
        This->nodes = allocHashSetOrderNode(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
        This->order = order;
        return This;
 }
 
-void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, BooleanOrder* constr) {
-       Polarity polarity=constr->base.polarity;
-       BooleanValue mustval=constr->base.boolVal;
-       Order* order=graph->order;
-       switch(polarity) {
+void addOrderEdge(OrderGraph *graph, OrderNode *node1, OrderNode *node2, BooleanOrder *constr) {
+       Polarity polarity = constr->base.polarity;
+       BooleanValue mustval = constr->base.boolVal;
+       Order *order = graph->order;
+       switch (polarity) {
        case P_BOTHTRUEFALSE:
        case P_BOTHTRUEFALSE:
-       case P_TRUE:{
-               OrderEdge_1to2 = getOrderEdgeFromOrderGraph(graph, node1, node2);
-               if (mustval==BV_MUSTBETRUE || mustval == BV_UNSAT)
+       case P_TRUE: {
+               OrderEdge *_1to2 = getOrderEdgeFromOrderGraph(graph, node1, node2);
+               if (mustval == BV_MUSTBETRUE || mustval == BV_UNSAT)
                        _1to2->mustPos = true;
                _1to2->polPos = true;
                addNewOutgoingEdge(node1, _1to2);
                addNewIncomingEdge(node2, _1to2);
                        _1to2->mustPos = true;
                _1to2->polPos = true;
                addNewOutgoingEdge(node1, _1to2);
                addNewIncomingEdge(node2, _1to2);
-               if(constr->base.polarity == P_TRUE)
+               if (constr->base.polarity == P_TRUE)
                        break;
        }
                        break;
        }
-       case P_FALSE:{
-               if (order->type==TOTAL) {
-                       OrderEdge_2to1 = getOrderEdgeFromOrderGraph(graph, node2, node1);
-                       if (mustval==BV_MUSTBEFALSE || mustval == BV_UNSAT)
+       case P_FALSE: {
+               if (order->type == TOTAL) {
+                       OrderEdge *_2to1 = getOrderEdgeFromOrderGraph(graph, node2, node1);
+                       if (mustval == BV_MUSTBEFALSE || mustval == BV_UNSAT)
                                _2to1->mustPos = true;
                        _2to1->polPos = true;
                        addNewOutgoingEdge(node2, _2to1);
                        addNewIncomingEdge(node1, _2to1);
                } else {
                                _2to1->mustPos = true;
                        _2to1->polPos = true;
                        addNewOutgoingEdge(node2, _2to1);
                        addNewIncomingEdge(node1, _2to1);
                } else {
-                       OrderEdge_1to2 = getOrderEdgeFromOrderGraph(graph, node1, node2);
-                       if (mustval==BV_MUSTBEFALSE || mustval == BV_UNSAT)
+                       OrderEdge *_1to2 = getOrderEdgeFromOrderGraph(graph, node1, node2);
+                       if (mustval == BV_MUSTBEFALSE || mustval == BV_UNSAT)
                                _1to2->mustNeg = true;
                        _1to2->polNeg = true;
                        addNewOutgoingEdge(node1, _1to2);
                                _1to2->mustNeg = true;
                        _1to2->polNeg = true;
                        addNewOutgoingEdge(node1, _1to2);
@@ -52,10 +52,10 @@ void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, Boolean
        }
 }
 
        }
 }
 
-OrderNode* getOrderNodeFromOrderGraph(OrderGraph* graph, uint64_t id) {
-       OrderNodenode = allocOrderNode(id);
-       OrderNodetmp = getHashSetOrderNode(graph->nodes, node);
-       if( tmp != NULL){
+OrderNode *getOrderNodeFromOrderGraph(OrderGraph *graph, uint64_t id) {
+       OrderNode *node = allocOrderNode(id);
+       OrderNode *tmp = getHashSetOrderNode(graph->nodes, node);
+       if ( tmp != NULL) {
                deleteOrderNode(node);
                node = tmp;
        } else {
                deleteOrderNode(node);
                node = tmp;
        } else {
@@ -64,10 +64,10 @@ OrderNode* getOrderNodeFromOrderGraph(OrderGraph* graph, uint64_t id) {
        return node;
 }
 
        return node;
 }
 
-OrderEdge* getOrderEdgeFromOrderGraph(OrderGraph* graph, OrderNode* begin, OrderNode* end) {
-       OrderEdgeedge = allocOrderEdge(begin, end);
-       OrderEdgetmp = getHashSetOrderEdge(graph->edges, edge);
-       if ( tmp!= NULL ) {
+OrderEdge *getOrderEdgeFromOrderGraph(OrderGraph *graph, OrderNode *begin, OrderNode *end) {
+       OrderEdge *edge = allocOrderEdge(begin, end);
+       OrderEdge *tmp = getHashSetOrderEdge(graph->edges, edge);
+       if ( tmp != NULL ) {
                deleteOrderEdge(edge);
                edge = tmp;
        } else {
                deleteOrderEdge(edge);
                edge = tmp;
        } else {
@@ -76,29 +76,29 @@ OrderEdge* getOrderEdgeFromOrderGraph(OrderGraph* graph, OrderNode* begin, Order
        return edge;
 }
 
        return edge;
 }
 
-OrderEdge* getInverseOrderEdge(OrderGraph* graph, OrderEdge *edge) {
-       OrderEdge inverseedge={edge->sink, edge->source, false, false, false, false, false};
-       OrderEdge * tmp=getHashSetOrderEdge(graph->edges, &inverseedge);
+OrderEdge *getInverseOrderEdge(OrderGraph *graph, OrderEdge *edge) {
+       OrderEdge inverseedge = {edge->sink, edge->source, false, false, false, false, false};
+       OrderEdge *tmp = getHashSetOrderEdge(graph->edges, &inverseedge);
        return tmp;
 }
 
        return tmp;
 }
 
-void addOrderConstraintToOrderGraph(OrderGraph* graph, BooleanOrder* bOrder) {
-       OrderNodefrom = getOrderNodeFromOrderGraph(graph, bOrder->first);
-       OrderNodeto = getOrderNodeFromOrderGraph(graph, bOrder->second);
+void addOrderConstraintToOrderGraph(OrderGraph *graph, BooleanOrder *bOrder) {
+       OrderNode *from = getOrderNodeFromOrderGraph(graph, bOrder->first);
+       OrderNode *to = getOrderNodeFromOrderGraph(graph, bOrder->second);
        addOrderEdge(graph, from, to, bOrder);
 }
 
        addOrderEdge(graph, from, to, bOrder);
 }
 
-void deleteOrderGraph(OrderGraph* graph){
-       HSIteratorOrderNodeiterator = iteratorOrderNode(graph->nodes);
-       while(hasNextOrderNode(iterator)){
-               OrderNodenode = nextOrderNode(iterator);
+void deleteOrderGraph(OrderGraph *graph) {
+       HSIteratorOrderNode *iterator = iteratorOrderNode(graph->nodes);
+       while (hasNextOrderNode(iterator)) {
+               OrderNode *node = nextOrderNode(iterator);
                deleteOrderNode(node);
        }
        deleteIterOrderNode(iterator);
                deleteOrderNode(node);
        }
        deleteIterOrderNode(iterator);
-       
-       HSIteratorOrderEdgeeiterator = iteratorOrderEdge(graph->edges);
-       while(hasNextOrderEdge(eiterator)){
-               OrderEdgeedge = nextOrderEdge(eiterator);
+
+       HSIteratorOrderEdge *eiterator = iteratorOrderEdge(graph->edges);
+       while (hasNextOrderEdge(eiterator)) {
+               OrderEdge *edge = nextOrderEdge(eiterator);
                deleteOrderEdge(edge);
        }
        deleteIterOrderEdge(eiterator);
                deleteOrderEdge(edge);
        }
        deleteIterOrderEdge(eiterator);
index a30c9f94d302981874987d95a061e572202173ca..5540d73ddc266eb79865011c19a8f666a8026ca9 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   ordergraph.h
  * Author: hamed
  *
  * File:   ordergraph.h
  * Author: hamed
  *
 #include "mymemory.h"
 
 struct OrderGraph {
 #include "mymemory.h"
 
 struct OrderGraph {
-       HashSetOrderNodenodes;
-       HashSetOrderEdgeedges;
-       Orderorder;
+       HashSetOrderNode *nodes;
+       HashSetOrderEdge *edges;
+       Order *order;
 };
 
 };
 
-OrderGraphallocOrderGraph(Order *order);
-void addOrderConstraintToOrderGraph(OrderGraph* graph, BooleanOrder* bOrder);
-OrderNode* getOrderNodeFromOrderGraph(OrderGraph* graph, uint64_t id);
-OrderEdge* getOrderEdgeFromOrderGraph(OrderGraph* graph, OrderNode* begin, OrderNode* end);
-void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, BooleanOrder* constr);
-void deleteOrderGraph(OrderGraphgraph);
-OrderEdge* getInverseOrderEdge(OrderGraph* graph, OrderEdge *edge);
-#endif /* ORDERGRAPH_H */
+OrderGraph *allocOrderGraph(Order *order);
+void addOrderConstraintToOrderGraph(OrderGraph *graph, BooleanOrder *bOrder);
+OrderNode *getOrderNodeFromOrderGraph(OrderGraph *graph, uint64_t id);
+OrderEdge *getOrderEdgeFromOrderGraph(OrderGraph *graph, OrderNode *begin, OrderNode *end);
+void addOrderEdge(OrderGraph *graph, OrderNode *node1, OrderNode *node2, BooleanOrder *constr);
+void deleteOrderGraph(OrderGraph *graph);
+OrderEdge *getInverseOrderEdge(OrderGraph *graph, OrderEdge *edge);
+#endif/* ORDERGRAPH_H */
 
 
index 072e54c150a6b56fd284b7d64758807a2a5a4ff4..c0bd096bb9b03072d3095dd2070ee302f0a9c347 100644 (file)
@@ -1,27 +1,27 @@
 #include "ordernode.h"
 #include "orderedge.h"
 
 #include "ordernode.h"
 #include "orderedge.h"
 
-OrderNodeallocOrderNode(uint64_t id) {
-       OrderNode* This = (OrderNode*) ourmalloc(sizeof(OrderNode));
+OrderNode *allocOrderNode(uint64_t id) {
+       OrderNode *This = (OrderNode *) ourmalloc(sizeof(OrderNode));
        This->id = id;
        This->inEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
        This->outEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
        This->id = id;
        This->inEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
        This->outEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
-       This->status=NOTVISITED;
-       This->sccNum=0;
+       This->status = NOTVISITED;
+       This->sccNum = 0;
        return This;
 }
 
        return This;
 }
 
-void addNewIncomingEdge(OrderNode* node, OrderEdge* edge){
-       ASSERT(!containsHashSetOrderEdge(node->inEdges, edge)); // Only for testing ... Should be removed after testing
+void addNewIncomingEdge(OrderNode *node, OrderEdge *edge) {
+       ASSERT(!containsHashSetOrderEdge(node->inEdges, edge)); // Only for testing ... Should be removed after testing
        addHashSetOrderEdge(node->inEdges, edge);
 }
 
        addHashSetOrderEdge(node->inEdges, edge);
 }
 
-void addNewOutgoingEdge(OrderNode* node, OrderEdge* edge){
+void addNewOutgoingEdge(OrderNode *node, OrderEdge *edge) {
        ASSERT(!containsHashSetOrderEdge(node->outEdges, edge));
        addHashSetOrderEdge(node->outEdges, edge);
 }
 
        ASSERT(!containsHashSetOrderEdge(node->outEdges, edge));
        addHashSetOrderEdge(node->outEdges, edge);
 }
 
-void deleteOrderNode(OrderNode* node){
+void deleteOrderNode(OrderNode *node) {
        deleteHashSetOrderEdge(node->inEdges);
        deleteHashSetOrderEdge(node->outEdges);
        ourfree(node);
        deleteHashSetOrderEdge(node->inEdges);
        deleteHashSetOrderEdge(node->outEdges);
        ourfree(node);
index 359b5bfee8f934f30eb6caf52866cfa8a9231fd0..a6eb4db84145251a863ddf21a237bb3225db5a1d 100644 (file)
@@ -1,5 +1,5 @@
 
 
-/* 
+/*
  * File:   ordernode.h
  * Author: hamed
  *
  * File:   ordernode.h
  * Author: hamed
  *
@@ -19,16 +19,16 @@ typedef enum NodeStatus NodeStatus;
 
 struct OrderNode {
        uint64_t id;
 
 struct OrderNode {
        uint64_t id;
-       HashSetOrderEdgeinEdges;
-       HashSetOrderEdgeoutEdges;
+       HashSetOrderEdge *inEdges;
+       HashSetOrderEdge *outEdges;
        NodeStatus status;
        uint sccNum;
 };
 
        NodeStatus status;
        uint sccNum;
 };
 
-OrderNodeallocOrderNode(uint64_t id);
-void addNewIncomingEdge(OrderNode* node, OrderEdge* edge);
-void addNewOutgoingEdge(OrderNode* node, OrderEdge* edge);
-void deleteOrderNode(OrderNodenode);
+OrderNode *allocOrderNode(uint64_t id);
+void addNewIncomingEdge(OrderNode *node, OrderEdge *edge);
+void addNewOutgoingEdge(OrderNode *node, OrderEdge *edge);
+void deleteOrderNode(OrderNode *node);
 
 
-#endif /* ORDERNODE_H */
+#endif/* ORDERNODE_H */
 
 
index 0ad5f8839415162ae53f756b837077253d122455..416da2a96f7efe5567b8013bef5e405dbac00359 100644 (file)
@@ -1,9 +1,9 @@
 #include "polarityassignment.h"
 #include "csolver.h"
 
 #include "polarityassignment.h"
 #include "csolver.h"
 
-void computePolarities(CSolverThis) {
-       for (uint i=0; i < getSizeVectorBoolean(This->constraints); i++) {
-               Booleanboolean = getVectorBoolean(This->constraints, i);
+void computePolarities(CSolver *This) {
+       for (uint i = 0; i < getSizeVectorBoolean(This->constraints); i++) {
+               Boolean *boolean = getVectorBoolean(This->constraints, i);
                updatePolarity(boolean, P_TRUE);
                updateMustValue(boolean, BV_MUSTBETRUE);
                computePolarityAndBooleanValue(boolean);
                updatePolarity(boolean, P_TRUE);
                updateMustValue(boolean, BV_MUSTBETRUE);
                computePolarityAndBooleanValue(boolean);
@@ -18,76 +18,76 @@ void updateMustValue(Boolean *This, BooleanValue value) {
        This->boolVal |= value;
 }
 
        This->boolVal |= value;
 }
 
-void computePolarityAndBooleanValue(BooleanThis) {
-       switch(GETBOOLEANTYPE(This)){
-               case BOOLEANVAR:
-               case ORDERCONST:
-                       return;
-               case PREDICATEOP:
-                       return computePredicatePolarityAndBooleanValue((BooleanPredicate*)This);
-               case LOGICOP:
-                       return computeLogicOpPolarityAndBooleanValue((BooleanLogic*)This);
-               default:
-                       ASSERT(0);
+void computePolarityAndBooleanValue(Boolean *This) {
+       switch (GETBOOLEANTYPE(This)) {
+       case BOOLEANVAR:
+       case ORDERCONST:
+               return;
+       case PREDICATEOP:
+               return computePredicatePolarityAndBooleanValue((BooleanPredicate *)This);
+       case LOGICOP:
+               return computeLogicOpPolarityAndBooleanValue((BooleanLogic *)This);
+       default:
+               ASSERT(0);
        }
 }
 
        }
 }
 
-void computePredicatePolarityAndBooleanValue(BooleanPredicate* This){
+void computePredicatePolarityAndBooleanValue(BooleanPredicate *This) {
        updatePolarity(This->undefStatus, P_BOTHTRUEFALSE);
        computePolarityAndBooleanValue(This->undefStatus);
 }
 
        updatePolarity(This->undefStatus, P_BOTHTRUEFALSE);
        computePolarityAndBooleanValue(This->undefStatus);
 }
 
-void computeLogicOpPolarityAndBooleanValue(BooleanLogicThis) {
+void computeLogicOpPolarityAndBooleanValue(BooleanLogic *This) {
        computeLogicOpBooleanValue(This);
        computeLogicOpPolarity(This);
        uint size = getSizeArrayBoolean(&This->inputs);
        computeLogicOpBooleanValue(This);
        computeLogicOpPolarity(This);
        uint size = getSizeArrayBoolean(&This->inputs);
-       for(uint i=0; i<size; i++) {
+       for (uint i = 0; i < size; i++) {
                computePolarityAndBooleanValue(getArrayBoolean(&This->inputs, i));
        }
 }
 
 Polarity negatePolarity(Polarity This) {
                computePolarityAndBooleanValue(getArrayBoolean(&This->inputs, i));
        }
 }
 
 Polarity negatePolarity(Polarity This) {
-       switch(This){
-               case P_UNDEFINED:
-               case P_BOTHTRUEFALSE:
-                       return This;
-               case P_TRUE:
-                       return P_FALSE;
-               case P_FALSE:
-                       return P_TRUE;
-               default:
-                       ASSERT(0);
+       switch (This) {
+       case P_UNDEFINED:
+       case P_BOTHTRUEFALSE:
+               return This;
+       case P_TRUE:
+               return P_FALSE;
+       case P_FALSE:
+               return P_TRUE;
+       default:
+               ASSERT(0);
        }
 }
 
 BooleanValue negateBooleanValue(BooleanValue This) {
        }
 }
 
 BooleanValue negateBooleanValue(BooleanValue This) {
-       switch(This){
-               case BV_UNDEFINED:
-               case BV_UNSAT:
-                       return This;
-               case BV_MUSTBETRUE:
-                       return BV_MUSTBEFALSE;
-               case BV_MUSTBEFALSE:
-                       return BV_MUSTBETRUE;
-               default:
-                       ASSERT(0);
+       switch (This) {
+       case BV_UNDEFINED:
+       case BV_UNSAT:
+               return This;
+       case BV_MUSTBETRUE:
+               return BV_MUSTBEFALSE;
+       case BV_MUSTBEFALSE:
+               return BV_MUSTBETRUE;
+       default:
+               ASSERT(0);
        }
 }
 
        }
 }
 
-void computeLogicOpPolarity(BooleanLogicThis) {
-       Polarity parentpolarity=GETBOOLEANPOLARITY(This);
-       switch(This->op){
+void computeLogicOpPolarity(BooleanLogic *This) {
+       Polarity parentpolarity = GETBOOLEANPOLARITY(This);
+       switch (This->op) {
        case L_AND:
        case L_AND:
-       case L_OR:{
-               uint size = getSizeArrayBoolean(& This->inputs);
-               for(uint i=0; i<size; i++){
-                       Boolean* tmp= getArrayBoolean(&This->inputs, i);
+       case L_OR: {
+               uint size = getSizeArrayBoolean(&This->inputs);
+               for (uint i = 0; i < size; i++) {
+                       Boolean *tmp = getArrayBoolean(&This->inputs, i);
                        updatePolarity(tmp, parentpolarity);
                }
                break;
        }
                        updatePolarity(tmp, parentpolarity);
                }
                break;
        }
-       case L_NOT:{
-               Boolean* tmp =getArrayBoolean(&This->inputs, 0);
+       case L_NOT: {
+               Boolean *tmp = getArrayBoolean(&This->inputs, 0);
                updatePolarity(tmp, negatePolarity(parentpolarity));
                break;
        }
                updatePolarity(tmp, negatePolarity(parentpolarity));
                break;
        }
@@ -96,10 +96,10 @@ void computeLogicOpPolarity(BooleanLogic* This) {
                updatePolarity(getArrayBoolean(&This->inputs, 1), P_BOTHTRUEFALSE);
                break;
        }
                updatePolarity(getArrayBoolean(&This->inputs, 1), P_BOTHTRUEFALSE);
                break;
        }
-       case L_IMPLIES:{
-               Booleanleft = getArrayBoolean(&This->inputs, 0);
+       case L_IMPLIES: {
+               Boolean *left = getArrayBoolean(&This->inputs, 0);
                updatePolarity(left, negatePolarity( parentpolarity));
                updatePolarity(left, negatePolarity( parentpolarity));
-               Boolean *right = getArrayBoolean(&This->inputs, 1);  
+               Boolean *right = getArrayBoolean(&This->inputs, 1);
                updatePolarity(right, parentpolarity);
                break;
        }
                updatePolarity(right, parentpolarity);
                break;
        }
@@ -108,22 +108,22 @@ void computeLogicOpPolarity(BooleanLogic* This) {
        }
 }
 
        }
 }
 
-void computeLogicOpBooleanValue(BooleanLogicThis) {
+void computeLogicOpBooleanValue(BooleanLogic *This) {
        BooleanValue parentbv = GETBOOLEANVALUE(This);
        BooleanValue parentbv = GETBOOLEANVALUE(This);
-       switch(This->op){
+       switch (This->op) {
        case L_AND: {
        case L_AND: {
-               if (parentbv==BV_MUSTBETRUE || parentbv==BV_UNSAT) {
-                       uint size = getSizeArrayBoolean(& This->inputs);
-                       for(uint i=0; i<size; i++) {
+               if (parentbv == BV_MUSTBETRUE || parentbv == BV_UNSAT) {
+                       uint size = getSizeArrayBoolean(&This->inputs);
+                       for (uint i = 0; i < size; i++) {
                                updateMustValue(getArrayBoolean(&This->inputs, i), parentbv);
                        }
                }
                return;
        }
        case L_OR: {
                                updateMustValue(getArrayBoolean(&This->inputs, i), parentbv);
                        }
                }
                return;
        }
        case L_OR: {
-               if (parentbv==BV_MUSTBEFALSE || parentbv==BV_UNSAT) {
-                       uint size = getSizeArrayBoolean(& This->inputs);
-                       for(uint i=0; i<size; i++) {
+               if (parentbv == BV_MUSTBEFALSE || parentbv == BV_UNSAT) {
+                       uint size = getSizeArrayBoolean(&This->inputs);
+                       for (uint i = 0; i < size; i++) {
                                updateMustValue(getArrayBoolean(&This->inputs, i), parentbv);
                        }
                }
                                updateMustValue(getArrayBoolean(&This->inputs, i), parentbv);
                        }
                }
@@ -134,8 +134,8 @@ void computeLogicOpBooleanValue(BooleanLogic* This) {
                return;
        case L_IMPLIES:
                //implies is really an or with the first term negated
                return;
        case L_IMPLIES:
                //implies is really an or with the first term negated
-               if (parentbv==BV_MUSTBEFALSE || parentbv==BV_UNSAT) {
-                       uint size = getSizeArrayBoolean(& This->inputs);
+               if (parentbv == BV_MUSTBEFALSE || parentbv == BV_UNSAT) {
+                       uint size = getSizeArrayBoolean(&This->inputs);
                        updateMustValue(getArrayBoolean(&This->inputs, 0), negateBooleanValue(parentbv));
                        updateMustValue(getArrayBoolean(&This->inputs, 1), parentbv);
                }
                        updateMustValue(getArrayBoolean(&This->inputs, 0), negateBooleanValue(parentbv));
                        updateMustValue(getArrayBoolean(&This->inputs, 1), parentbv);
                }
index 5acbd9ba117fb628727b359d453c25a88f2919f2..6621d773617b228b1c0a39afb71b4662bde54364 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * File:   polarityassignment.h
  * Author: hamed
  *
  * File:   polarityassignment.h
  * Author: hamed
  *
 #include "ops.h"
 #include "boolean.h"
 
 #include "ops.h"
 #include "boolean.h"
 
-void computePolarities(CSolverThis);
+void computePolarities(CSolver *This);
 void updatePolarity(Boolean *This, Polarity polarity);
 void updateMustValue(Boolean *This, BooleanValue value);
 void updatePolarity(Boolean *This, Polarity polarity);
 void updateMustValue(Boolean *This, BooleanValue value);
-void computePolarityAndBooleanValue(Booleanboolean);
-void computePredicatePolarityAndBooleanValue(BooleanPredicateThis);
-void computeLogicOpPolarityAndBooleanValue(BooleanLogicboolean);
+void computePolarityAndBooleanValue(Boolean *boolean);
+void computePredicatePolarityAndBooleanValue(BooleanPredicate *This);
+void computeLogicOpPolarityAndBooleanValue(BooleanLogic *boolean);
 Polarity negatePolarity(Polarity This);
 BooleanValue negateBooleanValue(BooleanValue This);
 Polarity negatePolarity(Polarity This);
 BooleanValue negateBooleanValue(BooleanValue This);
-void computeLogicOpPolarity(BooleanLogicboolean);
-void computeLogicOpBooleanValue(BooleanLogicboolean);
+void computeLogicOpPolarity(BooleanLogic *boolean);
+void computeLogicOpBooleanValue(BooleanLogic *boolean);
 
 
-#endif /* POLARITYASSIGNMENT_H */
+#endif/* POLARITYASSIGNMENT_H */
index e7fffe6e4eec37d464507c450087661914124bf6..71dbafd8581fecf4704595d3e68aa268c0352035 100644 (file)
  * e3 == e4
  * Result: UNSAT!
  */
  * e3 == e4
  * Result: UNSAT!
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={0, 1, 2};
-       uint64_t setbigarray[]={0, 1, 2, 3, 4};
-       
-       Set * s=createSet(solver, 0, set1, 3);
-       Set * setbig=createSet(solver, 0, setbigarray, 5);
-       Element * e1=getElementVar(solver, s);
-       Element * e2=getElementVar(solver, s);
-       Set * domain[]={s, s};
-       Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2);
-       Element * inputs[]={e1, e2};
-       Boolean * b=applyPredicate(solver, equals, inputs, 2);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {0, 1, 2};
+       uint64_t setbigarray[] = {0, 1, 2, 3, 4};
+
+       Set *s = createSet(solver, 0, set1, 3);
+       Set *setbig = createSet(solver, 0, setbigarray, 5);
+       Element *e1 = getElementVar(solver, s);
+       Element *e2 = getElementVar(solver, s);
+       Set *domain[] = {s, s};
+       Predicate *equals = createPredicateOperator(solver, EQUALS, domain, 2);
+       Element *inputs[] = {e1, e2};
+       Boolean *b = applyPredicate(solver, equals, inputs, 2);
        addConstraint(solver, b);
 
        uint64_t set2[] = {2, 3};
        addConstraint(solver, b);
 
        uint64_t set2[] = {2, 3};
-       Setrangef1 = createSet(solver, 1, set2, 2);
-       Function * f1 = createFunctionOperator(solver, ADD, domain, 2, setbig, IGNORE);
-       
-       Tabletable = createTable(solver, domain, 2, s);
+       Set *rangef1 = createSet(solver, 1, set2, 2);
+       Function *f1 = createFunctionOperator(solver, ADD, domain, 2, setbig, IGNORE);
+
+       Table *table = createTable(solver, domain, 2, s);
        uint64_t row1[] = {0, 1};
        uint64_t row2[] = {1, 1};
        uint64_t row3[] = {2, 1};
        uint64_t row1[] = {0, 1};
        uint64_t row2[] = {1, 1};
        uint64_t row3[] = {2, 1};
@@ -41,17 +41,17 @@ int main(int numargs, char ** argv) {
        addTableEntry(solver, table, row2, 2, 0);
        addTableEntry(solver, table, row3, 2, 2);
        addTableEntry(solver, table, row4, 2, 2);
        addTableEntry(solver, table, row2, 2, 0);
        addTableEntry(solver, table, row3, 2, 2);
        addTableEntry(solver, table, row4, 2, 2);
-       Function * f2 = completeTable(solver, table, IGNOREBEHAVIOR); //its range would be as same as s
-       Boolean* overflow = getBooleanVar(solver , 2);  
-       Element * e3 = applyFunction(solver, f1, inputs, 2, overflow);
-       Element * e4 = applyFunction(solver, f2, inputs, 2, overflow);
-       Setdomain2[] = {s,rangef1};
-       Predicateequal2 = createPredicateOperator(solver, EQUALS, domain2, 2);
-       Elementinputs2 [] = {e4, e3};
-       Booleanpred = applyPredicate(solver, equal2, inputs2, 2);
+       Function *f2 = completeTable(solver, table, IGNOREBEHAVIOR);    //its range would be as same as s
+       Boolean *overflow = getBooleanVar(solver, 2);
+       Element *e3 = applyFunction(solver, f1, inputs, 2, overflow);
+       Element *e4 = applyFunction(solver, f2, inputs, 2, overflow);
+       Set *domain2[] = {s,rangef1};
+       Predicate *equal2 = createPredicateOperator(solver, EQUALS, domain2, 2);
+       Element *inputs2 [] = {e4, e3};
+       Boolean *pred = applyPredicate(solver, equal2, inputs2, 2);
        addConstraint(solver, pred);
        addConstraint(solver, pred);
-       
-       if (startEncoding(solver)==1)
+
+       if (startEncoding(solver) == 1)
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
index 6740543ffaeef71821e83a5f0721310e1866295c..b76af263a5834fba872b60169d0478852d6c24c9 100644 (file)
@@ -1,32 +1,32 @@
 #include "constraint.h"
 #include <stdio.h>
 
 #include "constraint.h"
 #include <stdio.h>
 
-int main(int numargs, char ** argv) {
-       CNF *cnf=createCNF();
-       Edge v1=constraintNewVar(cnf);
-       Edge v2=constraintNewVar(cnf);
-       Edge v3=constraintNewVar(cnf);
-       Edge v4=constraintNewVar(cnf);
+int main(int numargs, char **argv) {
+       CNF *cnf = createCNF();
+       Edge v1 = constraintNewVar(cnf);
+       Edge v2 = constraintNewVar(cnf);
+       Edge v3 = constraintNewVar(cnf);
+       Edge v4 = constraintNewVar(cnf);
 
 
-       Edge nv1=constraintNegate(v1);
-       Edge nv2=constraintNegate(v2);
-       Edge nv3=constraintNegate(v3);
-       Edge nv4=constraintNegate(v4);
+       Edge nv1 = constraintNegate(v1);
+       Edge nv2 = constraintNegate(v2);
+       Edge nv3 = constraintNegate(v3);
+       Edge nv4 = constraintNegate(v4);
 
 
-       Edge c1=constraintAND2(cnf, v1, nv2);
-       Edge c2=constraintAND2(cnf, v3, nv4);
-       Edge c3=constraintAND2(cnf, nv1, v2);
-       Edge c4=constraintAND2(cnf, nv3, v4);
-       Edge cor=constraintOR2(cnf, constraintAND2(cnf, c1, c2), constraintAND2(cnf, c3, c4));
+       Edge c1 = constraintAND2(cnf, v1, nv2);
+       Edge c2 = constraintAND2(cnf, v3, nv4);
+       Edge c3 = constraintAND2(cnf, nv1, v2);
+       Edge c4 = constraintAND2(cnf, nv3, v4);
+       Edge cor = constraintOR2(cnf, constraintAND2(cnf, c1, c2), constraintAND2(cnf, c3, c4));
        printCNF(cor);
        printf("\n");
        addConstraintCNF(cnf, cor);
        printCNF(cor);
        printf("\n");
        addConstraintCNF(cnf, cor);
-       int value=solveCNF(cnf);
-       if (value==1) {
-               bool v1v=getValueCNF(cnf, v1);
-               bool v2v=getValueCNF(cnf, v2);
-               bool v3v=getValueCNF(cnf, v3);
-               bool v4v=getValueCNF(cnf, v4);
+       int value = solveCNF(cnf);
+       if (value == 1) {
+               bool v1v = getValueCNF(cnf, v1);
+               bool v2v = getValueCNF(cnf, v2);
+               bool v3v = getValueCNF(cnf, v3);
+               bool v4v = getValueCNF(cnf, v4);
                printf("%d %u %u %u %u\n", value, v1v, v2v, v3v, v4v);
        } else
                printf("%d\n",value);
                printf("%d %u %u %u %u\n", value, v1v, v2v, v3v, v4v);
        } else
                printf("%d\n",value);
index 718dc6714107d9d964c74f53a249d32f541dfbef..7841a70eda242ce46789730372c420fc2e2c847d 100644 (file)
@@ -3,29 +3,29 @@
  * e1 = {0, 1, 2}
  * e2 = {3, 1, 7}
  * e1 == e2
  * e1 = {0, 1, 2}
  * e2 = {3, 1, 7}
  * e1 == e2
- * 
+ *
  * Result (Enumeration):
  *     e1=1 e2=1
  * Result (circuit):
  * Result (Enumeration):
  *     e1=1 e2=1
  * Result (circuit):
- *     e1=0 e2=3 
- *     e1=1 e2=1 
- *     e1=2 e2=7 
+ *     e1=0 e2=3
+ *     e1=1 e2=1
+ *     e1=2 e2=7
  */
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={0, 1, 2};
-       uint64_t set2[]={3, 1, 7};
-       Set * s1=createSet(solver, 0, set1, 3);
-       Set * s2=createSet(solver, 0, set2, 3);
-       Element * e1=getElementVar(solver, s1);
-       Element * e2=getElementVar(solver, s2);
-       Set * domain[]={s1, s2};
-       Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2);
-       Element * inputs[]={e1, e2};
-       Boolean *b=applyPredicate(solver, equals, inputs, 2);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {0, 1, 2};
+       uint64_t set2[] = {3, 1, 7};
+       Set *s1 = createSet(solver, 0, set1, 3);
+       Set *s2 = createSet(solver, 0, set2, 3);
+       Element *e1 = getElementVar(solver, s1);
+       Element *e2 = getElementVar(solver, s2);
+       Set *domain[] = {s1, s2};
+       Predicate *equals = createPredicateOperator(solver, EQUALS, domain, 2);
+       Element *inputs[] = {e1, e2};
+       Boolean *b = applyPredicate(solver, equals, inputs, 2);
        addConstraint(solver, b);
        addConstraint(solver, b);
-       
-       if (startEncoding(solver)==1)
+
+       if (startEncoding(solver) == 1)
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
index bd38ed9183d1711c1c60a05ee4f27c0d80cfb9ee..5cbdd0460435a8cc52fa6b6b413c64b9d66082e4 100644 (file)
@@ -3,24 +3,24 @@
  * e1 = {0, 1, 2}
  * e2 = {3, 4}
  * e1 == e2
  * e1 = {0, 1, 2}
  * e2 = {3, 4}
  * e1 == e2
- * 
+ *
  * Result: UNSAT
  */
  * Result: UNSAT
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={0, 1, 2};
-       uint64_t set2[]={3, 4};
-       Set * s1=createSet(solver, 0, set1, 3);
-       Set * s2=createSet(solver, 0, set2, 2);
-       Element * e1=getElementVar(solver, s1);
-       Element * e2=getElementVar(solver, s2);
-       Set * domain[]={s1, s2};
-       Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2);
-       Element * inputs[]={e1, e2};
-       Boolean *b=applyPredicate(solver, equals, inputs, 2);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {0, 1, 2};
+       uint64_t set2[] = {3, 4};
+       Set *s1 = createSet(solver, 0, set1, 3);
+       Set *s2 = createSet(solver, 0, set2, 2);
+       Element *e1 = getElementVar(solver, s1);
+       Element *e2 = getElementVar(solver, s2);
+       Set *domain[] = {s1, s2};
+       Predicate *equals = createPredicateOperator(solver, EQUALS, domain, 2);
+       Element *inputs[] = {e1, e2};
+       Boolean *b = applyPredicate(solver, equals, inputs, 2);
        addConstraint(solver, b);
        addConstraint(solver, b);
-       
-       if (startEncoding(solver)==1)
+
+       if (startEncoding(solver) == 1)
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
index 4962f3f027fc48f593de5f31402b9fea557a4bd5..24b652f7aa25a9c06b51ad5687d91f6901611d0a 100644 (file)
@@ -3,7 +3,7 @@
  * e1 = {6}
  * e2={4, 2}
  * e3=Fsub(e1,e2) {4, 2}
  * e1 = {6}
  * e2={4, 2}
  * e3=Fsub(e1,e2) {4, 2}
- * e4= f(e1, e2) 
+ * e4= f(e1, e2)
  *     6 2 => 3
  *     6 4 => 1
  * e5 = f(e1)=>e1 {6}
  *     6 2 => 3
  *     6 4 => 1
  * e5 = f(e1)=>e1 {6}
  * e7 > e6
  * Result: e1=6, e2=4, e7=2
  */
  * e7 > e6
  * Result: e1=6, e2=4, e7=2
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={6};
-       uint64_t set2[]={4, 2};
-       uint64_t set3[]={3, 1};
-       uint64_t set4[]={2, 3, 1};
-       uint64_t set5[]={2, 1, 0};      
-       Set * s1=createSet(solver, 0, set1, 1);
-       Set * s2=createSet(solver, 0, set2, 2);
-       Set * s3=createSet(solver, 0, set3, 2);
-       Set * s4=createSet(solver, 0, set4, 3);
-       Set * s5=createSet(solver, 0, set5, 3);
-       Element * e1=getElementVar(solver, s1);
-       Element * e2=getElementVar(solver, s2);
-       Element * e7=getElementVar(solver, s5);
-       Boolean* overflow = getBooleanVar(solver , 2);
-       Set * d1[]={s1, s2};
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {6};
+       uint64_t set2[] = {4, 2};
+       uint64_t set3[] = {3, 1};
+       uint64_t set4[] = {2, 3, 1};
+       uint64_t set5[] = {2, 1, 0};
+       Set *s1 = createSet(solver, 0, set1, 1);
+       Set *s2 = createSet(solver, 0, set2, 2);
+       Set *s3 = createSet(solver, 0, set3, 2);
+       Set *s4 = createSet(solver, 0, set4, 3);
+       Set *s5 = createSet(solver, 0, set5, 3);
+       Element *e1 = getElementVar(solver, s1);
+       Element *e2 = getElementVar(solver, s2);
+       Element *e7 = getElementVar(solver, s5);
+       Boolean *overflow = getBooleanVar(solver, 2);
+       Set *d1[] = {s1, s2};
        //change the overflow flag
        //change the overflow flag
-       Function * f1 = createFunctionOperator(solver, SUB, d1, 2, s2, IGNORE);
-       Element * in1[]={e1, e2};
-       Element * e3 = applyFunction(solver, f1, in1, 2, overflow);
-       Tablet1 = createTable(solver, d1, 2, s3);
+       Function *f1 = createFunctionOperator(solver, SUB, d1, 2, s2, IGNORE);
+       Element *in1[] = {e1, e2};
+       Element *e3 = applyFunction(solver, f1, in1, 2, overflow);
+       Table *t1 = createTable(solver, d1, 2, s3);
        uint64_t row1[] = {6, 2};
        uint64_t row2[] = {6, 4};
        addTableEntry(solver, t1, row1, 2, 3);
        addTableEntry(solver, t1, row2, 2, 1);
        uint64_t row1[] = {6, 2};
        uint64_t row2[] = {6, 4};
        addTableEntry(solver, t1, row1, 2, 3);
        addTableEntry(solver, t1, row2, 2, 1);
-       Function * f2 = completeTable(solver, t1, IGNOREBEHAVIOR);      
-       Element * e4 = applyFunction(solver, f2, in1, 2, overflow);
-       
+       Function *f2 = completeTable(solver, t1, IGNOREBEHAVIOR);
+       Element *e4 = applyFunction(solver, f2, in1, 2, overflow);
+
        Set *d2[] = {s1};
        Set *d2[] = {s1};
-       Element *in2[]={e1};
-       Tablet2 = createTable(solver, d2, 1, s1);
+       Element *in2[] = {e1};
+       Table *t2 = createTable(solver, d2, 1, s1);
        uint64_t row3[] = {6};
        addTableEntry(solver, t2, row3, 1, 6);
        uint64_t row3[] = {6};
        addTableEntry(solver, t2, row3, 1, 6);
-       Function * f3 = completeTable(solver, t2, IGNOREBEHAVIOR);      
-       Element * e5 = applyFunction(solver, f3, in2, 1, overflow);
-       
+       Function *f3 = completeTable(solver, t2, IGNOREBEHAVIOR);
+       Element *e5 = applyFunction(solver, f3, in2, 1, overflow);
+
        Set *d3[] = {s2, s3, s1};
        Set *d3[] = {s2, s3, s1};
-       Element *in3[]={e3, e4, e5};
-       Tablet3 = createTable(solver, d3, 3, s4);
+       Element *in3[] = {e3, e4, e5};
+       Table *t3 = createTable(solver, d3, 3, s4);
        uint64_t row4[] = {4, 3, 6};
        uint64_t row5[] = {2, 1, 6};
        uint64_t row6[] = {2, 3, 6};
        uint64_t row4[] = {4, 3, 6};
        uint64_t row5[] = {2, 1, 6};
        uint64_t row6[] = {2, 3, 6};
@@ -64,18 +64,18 @@ int main(int numargs, char ** argv) {
        addTableEntry(solver, t3, row5, 3, 1);
        addTableEntry(solver, t3, row6, 3, 2);
        addTableEntry(solver, t3, row7, 3, 1);
        addTableEntry(solver, t3, row5, 3, 1);
        addTableEntry(solver, t3, row6, 3, 2);
        addTableEntry(solver, t3, row7, 3, 1);
-       Function * f4 = completeTable(solver, t3, IGNOREBEHAVIOR);      
-       Element * e6 = applyFunction(solver, f4, in3, 3, overflow);
-       
-       Setdeq[] = {s5,s4};
-       Predicategt = createPredicateOperator(solver, GT, deq, 2);
-       Elementinputs2 [] = {e7, e6};
-       Booleanpred = applyPredicate(solver, gt, inputs2, 2);
+       Function *f4 = completeTable(solver, t3, IGNOREBEHAVIOR);
+       Element *e6 = applyFunction(solver, f4, in3, 3, overflow);
+
+       Set *deq[] = {s5,s4};
+       Predicate *gt = createPredicateOperator(solver, GT, deq, 2);
+       Element *inputs2 [] = {e7, e6};
+       Boolean *pred = applyPredicate(solver, gt, inputs2, 2);
        addConstraint(solver, pred);
        addConstraint(solver, pred);
-       
-       if (startEncoding(solver)==1)
-               printf("e1=%llu e2=%llu e7=%llu\n", 
-                        getElementValue(solver,e1), getElementValue(solver, e2), getElementValue(solver, e7));
+
+       if (startEncoding(solver) == 1)
+               printf("e1=%llu e2=%llu e7=%llu\n",
+                                        getElementValue(solver,e1), getElementValue(solver, e2), getElementValue(solver, e7));
        else
                printf("UNSAT\n");
        deleteSolver(solver);
        else
                printf("UNSAT\n");
        deleteSolver(solver);
index a01a7f5642e37f4119e58c9e1273ae21527ece8a..9d12a057642b4a451fa1522175c2c203afb9d280 100644 (file)
@@ -4,25 +4,25 @@
  * b1 AND b2=>b3
  * !b3 OR b4
  * b1 XOR b4
  * b1 AND b2=>b3
  * !b3 OR b4
  * b1 XOR b4
- * Result: b1=1 b2=0 b3=0 b4=0 
+ * Result: b1=1 b2=0 b3=0 b4=0
  */
  */
-int main(int numargs, char** argv){
-       CSolver * solver=allocCSolver();
-       Boolean *b1= getBooleanVar(solver, 0);
-       Boolean *b2= getBooleanVar(solver, 0);
-       Boolean *b3= getBooleanVar(solver, 0);
-       Boolean *b4= getBooleanVar(solver, 0);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       Boolean *b1 = getBooleanVar(solver, 0);
+       Boolean *b2 = getBooleanVar(solver, 0);
+       Boolean *b3 = getBooleanVar(solver, 0);
+       Boolean *b4 = getBooleanVar(solver, 0);
        //L_AND, L_OR, L_NOT, L_XOR, L_IMPLIES
        //L_AND, L_OR, L_NOT, L_XOR, L_IMPLIES
-       Boolean *andb1b2= applyLogicalOperation(solver, L_AND,(Boolean*[]) {b1, b2}, 2);
-       Boolean * imply = applyLogicalOperation(solver, L_IMPLIES, (Boolean*[]) {andb1b2, b3}, 2);
+       Boolean *andb1b2 = applyLogicalOperation(solver, L_AND,(Boolean *[]) {b1, b2}, 2);
+       Boolean *imply = applyLogicalOperation(solver, L_IMPLIES, (Boolean *[]) {andb1b2, b3}, 2);
        addConstraint(solver, imply);
        addConstraint(solver, imply);
-       Boolean* notb3 = applyLogicalOperation(solver, L_NOT, (Boolean*[]) {b3}, 1); 
-       addConstraint(solver, applyLogicalOperation(solver, L_OR, (Boolean*[]){notb3, b4} , 2));
-       addConstraint(solver, applyLogicalOperation(solver, L_XOR, (Boolean* []) {b1, b4}, 2));
-       if (startEncoding(solver)==1)
-               printf("b1=%d b2=%d b3=%d b4=%d\n", 
-                       getBooleanValue(solver,b1), getBooleanValue(solver, b2),
-                       getBooleanValue(solver, b3), getBooleanValue(solver, b4));
+       Boolean *notb3 = applyLogicalOperation(solver, L_NOT, (Boolean *[]) {b3}, 1);
+       addConstraint(solver, applyLogicalOperation(solver, L_OR, (Boolean *[]) {notb3, b4}, 2));
+       addConstraint(solver, applyLogicalOperation(solver, L_XOR, (Boolean * []) {b1, b4}, 2));
+       if (startEncoding(solver) == 1)
+               printf("b1=%d b2=%d b3=%d b4=%d\n",
+                                        getBooleanValue(solver,b1), getBooleanValue(solver, b2),
+                                        getBooleanValue(solver, b3), getBooleanValue(solver, b4));
        else
                printf("UNSAT\n");
        deleteSolver(solver);
        else
                printf("UNSAT\n");
        deleteSolver(solver);
index 382394900345f7c13706915d199ad6cebe7223c6..4818f246e90cb1aff667d00a9d986993b909b182 100644 (file)
@@ -5,20 +5,20 @@
  * e1 < e2
  * Result: e1=5 e2=6
  */
  * e1 < e2
  * Result: e1=5 e2=6
  */
-int main(int numargs, char ** argv){
-       CSolver *solver=allocCSolver();
-       uint64_t set1[]={5};
-       uint64_t set3[]={1, 3, 4, 6};
-       Set * s1=createSet(solver, 0, set1, 3);
-       Set * s3=createSet(solver, 0, set3, 4);
-       Element * e1=getElementConst(solver, 4, 5);
-       Element * e2=getElementVar(solver, s3);
-       Set * domain2[]={s1, s3};
-       Predicate *lt=createPredicateOperator(solver, LT, domain2, 2);
-       Element * inputs2[]={e1, e2};
-       Boolean *b=applyPredicate(solver, lt, inputs2, 2);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {5};
+       uint64_t set3[] = {1, 3, 4, 6};
+       Set *s1 = createSet(solver, 0, set1, 3);
+       Set *s3 = createSet(solver, 0, set3, 4);
+       Element *e1 = getElementConst(solver, 4, 5);
+       Element *e2 = getElementVar(solver, s3);
+       Set *domain2[] = {s1, s3};
+       Predicate *lt = createPredicateOperator(solver, LT, domain2, 2);
+       Element *inputs2[] = {e1, e2};
+       Boolean *b = applyPredicate(solver, lt, inputs2, 2);
        addConstraint(solver, b);
        addConstraint(solver, b);
-       if (startEncoding(solver)==1)
+       if (startEncoding(solver) == 1)
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
                printf("e1=%llu e2=%llu\n", getElementValue(solver,e1), getElementValue(solver, e2));
        else
                printf("UNSAT\n");
index 2b8a98d0a1538d8be482d0aa792b803e28f2ea87..852df3456cfd0127bbe21a66ee05c48391b31600 100644 (file)
@@ -6,22 +6,22 @@
  * 1 => 4
  * Result: O(5,1)=0 O(1,4)=0 O(5,4)=0 O(1,5)=1 O(1111,5)=2
  */
  * 1 => 4
  * Result: O(5,1)=0 O(1,4)=0 O(5,4)=0 O(1,5)=1 O(1111,5)=2
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={5, 1, 4};
-       Set * s=createSet(solver, 0, set1, 3);
-       Orderorder = createOrder(solver, TOTAL, s);
-       Boolean* b1=  orderConstraint(solver, order, 5, 1);
-       Boolean* b2=  orderConstraint(solver, order, 1, 4);
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {5, 1, 4};
+       Set *s = createSet(solver, 0, set1, 3);
+       Order *order = createOrder(solver, TOTAL, s);
+       Boolean *b1 =  orderConstraint(solver, order, 5, 1);
+       Boolean *b2 =  orderConstraint(solver, order, 1, 4);
        addConstraint(solver, b1);
        addConstraint(solver, b2);
        addConstraint(solver, b1);
        addConstraint(solver, b2);
-       if (startEncoding(solver)==1)
-               printf("O(5,1)=%d O(1,4)=%d O(5,4)=%d O(1,5)=%d O(1111,5)=%d\n", 
-                       getOrderConstraintValue(solver, order, 5, 1), 
-                       getOrderConstraintValue(solver, order, 1, 4),
-                       getOrderConstraintValue(solver, order, 5, 4),
-                       getOrderConstraintValue(solver, order, 1, 5),
-                       getOrderConstraintValue(solver, order, 1111, 5));
+       if (startEncoding(solver) == 1)
+               printf("O(5,1)=%d O(1,4)=%d O(5,4)=%d O(1,5)=%d O(1111,5)=%d\n",
+                                        getOrderConstraintValue(solver, order, 5, 1),
+                                        getOrderConstraintValue(solver, order, 1, 4),
+                                        getOrderConstraintValue(solver, order, 5, 4),
+                                        getOrderConstraintValue(solver, order, 1, 5),
+                                        getOrderConstraintValue(solver, order, 1111, 5));
        else
                printf("UNSAT\n");
        deleteSolver(solver);
        else
                printf("UNSAT\n");
        deleteSolver(solver);
index 12a589e083f651466d089d0e17dd80d840660363..a7b9412a1b54e404c7b18abc4c37bdcba21c413f 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * e1 = {1, 2}
  * e2={3, 5, 7}
 /**
  * e1 = {1, 2}
  * e2={3, 5, 7}
- * e3= f(e1, e2) 
+ * e3= f(e1, e2)
  *     1 5 => 7
  *     2 3 => 5
  *     1 7 => 3
  *     1 5 => 7
  *     2 3 => 5
  *     1 7 => 3
  * e4 <= e3
  * Result: e1=1, e2=5, e3=7, e4=6, overflow=0
  */
  * e4 <= e3
  * Result: e1=1, e2=5, e3=7, e4=6, overflow=0
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={1, 2};
-       uint64_t set2[]={3, 5, 7};
-       uint64_t set3[]={6, 10, 19};
-       Set * s1=createSet(solver, 0, set1, 2);
-       Set * s2=createSet(solver, 0, set2, 3);
-       Set * s3=createSet(solver, 0, set3, 3);
-       Element * e1=getElementVar(solver, s1);
-       Element * e2=getElementVar(solver, s2);
-       Element * e4=getElementVar(solver, s3);
-       Boolean* overflow = getBooleanVar(solver , 2);
-       Set * d1[]={s1, s2};
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {1, 2};
+       uint64_t set2[] = {3, 5, 7};
+       uint64_t set3[] = {6, 10, 19};
+       Set *s1 = createSet(solver, 0, set1, 2);
+       Set *s2 = createSet(solver, 0, set2, 3);
+       Set *s3 = createSet(solver, 0, set3, 3);
+       Element *e1 = getElementVar(solver, s1);
+       Element *e2 = getElementVar(solver, s2);
+       Element *e4 = getElementVar(solver, s3);
+       Boolean *overflow = getBooleanVar(solver, 2);
+       Set *d1[] = {s1, s2};
        //change the overflow flag
        //change the overflow flag
-       Tablet1 = createTable(solver, d1, 2, s2);
+       Table *t1 = createTable(solver, d1, 2, s2);
        uint64_t row1[] = {1, 5};
        uint64_t row2[] = {2, 3};
        uint64_t row3[] = {1, 7};
        uint64_t row1[] = {1, 5};
        uint64_t row2[] = {2, 3};
        uint64_t row3[] = {1, 7};
@@ -40,19 +40,19 @@ int main(int numargs, char ** argv) {
        addTableEntry(solver, t1, row4, 2, 5);
        addTableEntry(solver, t1, row5, 2, 3);
        addTableEntry(solver, t1, row6, 2, 5);
        addTableEntry(solver, t1, row4, 2, 5);
        addTableEntry(solver, t1, row5, 2, 3);
        addTableEntry(solver, t1, row6, 2, 5);
-       Function * f1 = completeTable(solver, t1, FLAGIFFUNDEFINED);    
-       Element * e3 = applyFunction(solver, f1, (Element* []){e1,e2}, 2, overflow);
-       
-       Setdeq[] = {s3,s2};
-       Predicatelte = createPredicateOperator(solver, LTE, deq, 2);
-       Elementinputs2 [] = {e4, e3};
-       Booleanpred = applyPredicate(solver, lte, inputs2, 2);
+       Function *f1 = completeTable(solver, t1, FLAGIFFUNDEFINED);
+       Element *e3 = applyFunction(solver, f1, (Element * []) {e1,e2}, 2, overflow);
+
+       Set *deq[] = {s3,s2};
+       Predicate *lte = createPredicateOperator(solver, LTE, deq, 2);
+       Element *inputs2 [] = {e4, e3};
+       Boolean *pred = applyPredicate(solver, lte, inputs2, 2);
        addConstraint(solver, pred);
        addConstraint(solver, pred);
-       
-       if (startEncoding(solver)==1)
-               printf("e1=%llu e2=%llu e3=%llu e4=%llu overFlow:%d\n", 
-                       getElementValue(solver,e1), getElementValue(solver, e2), getElementValue(solver, e3),
-                       getElementValue(solver, e4), getBooleanValue(solver, overflow));
+
+       if (startEncoding(solver) == 1)
+               printf("e1=%llu e2=%llu e3=%llu e4=%llu overFlow:%d\n",
+                                        getElementValue(solver,e1), getElementValue(solver, e2), getElementValue(solver, e3),
+                                        getElementValue(solver, e4), getBooleanValue(solver, overflow));
        else
                printf("UNSAT\n");
        deleteSolver(solver);
        else
                printf("UNSAT\n");
        deleteSolver(solver);
index 536879e2b482d823805d38ab1ff4ac965529d66a..ee9094bfdb066d170cbfe9b53574772ea4232532 100644 (file)
@@ -3,7 +3,7 @@
  * e1 = {1, 2}
  * e2={1, 3, 5, 7}
  * e3 = {6, 10, 19}
  * e1 = {1, 2}
  * e2={1, 3, 5, 7}
  * e3 = {6, 10, 19}
- * e4= p(e1, e2, e3) 
+ * e4= p(e1, e2, e3)
  *     1 5 6 => T
  *     2 3 19 => T
  *     1 3 19 => F
  *     1 5 6 => T
  *     2 3 19 => T
  *     1 3 19 => F
  *     1 7 6 => F
  *     2 5 6 => T
  * e1 == e2
  *     1 7 6 => F
  *     2 5 6 => T
  * e1 == e2
- * e3 >= e2 
+ * e3 >= e2
  * Result: e1=1, e2=1, e3=6 OR 10 OR 19, overflow=1
  */
  * Result: e1=1, e2=1, e3=6 OR 10 OR 19, overflow=1
  */
-int main(int numargs, char ** argv) {
-       CSolver * solver=allocCSolver();
-       uint64_t set1[]={1, 2};
-       uint64_t set2[]={1, 3, 5, 7};
-       uint64_t set3[]={6, 10, 19};
-       Set * s1=createSet(solver, 0, set1, 2);
-       Set * s2=createSet(solver, 0, set2, 4);
-       Set * s3=createSet(solver, 0, set3, 3);
-       Element * e1=getElementVar(solver, s1);
-       Element * e2=getElementVar(solver, s2);
-       Element * e3=getElementVar(solver, s3);
-       Set * d2[]={s1, s2, s3};
+int main(int numargs, char **argv) {
+       CSolver *solver = allocCSolver();
+       uint64_t set1[] = {1, 2};
+       uint64_t set2[] = {1, 3, 5, 7};
+       uint64_t set3[] = {6, 10, 19};
+       Set *s1 = createSet(solver, 0, set1, 2);
+       Set *s2 = createSet(solver, 0, set2, 4);
+       Set *s3 = createSet(solver, 0, set3, 3);
+       Element *e1 = getElementVar(solver, s1);
+       Element *e2 = getElementVar(solver, s2);
+       Element *e3 = getElementVar(solver, s3);
+       Set *d2[] = {s1, s2, s3};
        //change the overflow flag
        //change the overflow flag
-       Tablet1 = createTableForPredicate(solver, d2, 3);
+       Table *t1 = createTableForPredicate(solver, d2, 3);
        uint64_t row1[] = {1, 5, 6};
        uint64_t row2[] = {2, 3, 19};
        uint64_t row3[] = {1, 3, 19};
        uint64_t row1[] = {1, 5, 6};
        uint64_t row2[] = {2, 3, 19};
        uint64_t row3[] = {1, 3, 19};
@@ -40,26 +40,26 @@ int main(int numargs, char ** argv) {
        addTableEntry(solver, t1, row4, 3, false);
        addTableEntry(solver, t1, row5, 3, false);
        addTableEntry(solver, t1, row6, 3, true);
        addTableEntry(solver, t1, row4, 3, false);
        addTableEntry(solver, t1, row5, 3, false);
        addTableEntry(solver, t1, row6, 3, true);
-       Predicate * p1 = createPredicateTable(solver, t1, FLAGIFFUNDEFINED);
-       Boolean* undef = getBooleanVar(solver , 2);
-       Boolean* b1 =applyPredicateTable(solver, p1, (Element* []){e1, e2, e3}, 3, undef);
+       Predicate *p1 = createPredicateTable(solver, t1, FLAGIFFUNDEFINED);
+       Boolean *undef = getBooleanVar(solver, 2);
+       Boolean *b1 = applyPredicateTable(solver, p1, (Element * []) {e1, e2, e3}, 3, undef);
        addConstraint(solver, b1);
        addConstraint(solver, b1);
-       
-       Setdeq[] = {s3,s2};
-       Predicategte = createPredicateOperator(solver, GTE, deq, 2);
-       Elementinputs2 [] = {e3, e2};
-       Booleanpred = applyPredicate(solver, gte, inputs2, 2);
+
+       Set *deq[] = {s3,s2};
+       Predicate *gte = createPredicateOperator(solver, GTE, deq, 2);
+       Element *inputs2 [] = {e3, e2};
+       Boolean *pred = applyPredicate(solver, gte, inputs2, 2);
        addConstraint(solver, pred);
        addConstraint(solver, pred);
-       
-       Set * d1[]={s1, s2};
-       Predicateeq = createPredicateOperator(solver, EQUALS, d1, 2);
-       Boolean* pred2 = applyPredicate(solver, eq,(Element*[]) {e1, e2}, 2);
+
+       Set *d1[] = {s1, s2};
+       Predicate *eq = createPredicateOperator(solver, EQUALS, d1, 2);
+       Boolean *pred2 = applyPredicate(solver, eq,(Element *[]) {e1, e2}, 2);
        addConstraint(solver, pred2);
        addConstraint(solver, pred2);
-       
-       if (startEncoding(solver)==1)
-               printf("e1=%llu e2=%llu e3=%llu undefFlag:%d\n", 
-                       getElementValue(solver,e1), getElementValue(solver, e2), 
-                       getElementValue(solver, e3), getBooleanValue(solver, undef));
+
+       if (startEncoding(solver) == 1)
+               printf("e1=%llu e2=%llu e3=%llu undefFlag:%d\n",
+                                        getElementValue(solver,e1), getElementValue(solver, e2),
+                                        getElementValue(solver, e3), getBooleanValue(solver, undef));
        else
                printf("UNSAT\n");
        deleteSolver(solver);
        else
                printf("UNSAT\n");
        deleteSolver(solver);
index a06dab21eb16ffc9a5a5ba8aad3304dcda457cb2..0ebb7ece4c73a9263613a02a3705616a5c10d778 100644 (file)
 #include "config.h"
 
 /*
 #include "config.h"
 
 /*
-extern int model_out;
-extern int model_err;
-extern int switch_alloc;
+   extern int model_out;
+   extern int model_err;
+   extern int switch_alloc;
 
 
-#define model_dprintf(fd, fmt, ...) do { switch_alloc = 1; dprintf(fd, fmt, ## __VA_ARGS__); switch_alloc = 0; } while (0)
+ #define model_dprintf(fd, fmt, ...) do { switch_alloc = 1; dprintf(fd, fmt, ## __VA_ARGS__); switch_alloc = 0; } while (0)
 
 
-#define model_print(fmt, ...) do { model_dprintf(model_out, fmt, ## __VA_ARGS__); } while (0)
+ #define model_print(fmt, ...) do { model_dprintf(model_out, fmt, ## __VA_ARGS__); } while (0)
 
 
-#define model_print_err(fmt, ...) do { model_dprintf(model_err, fmt, ## __VA_ARGS__); } while (0)
+ #define model_print_err(fmt, ...) do { model_dprintf(model_err, fmt, ## __VA_ARGS__); } while (0)
 
 
-*/
+ */
 
 #define model_print printf
 
 
 #define model_print printf
 
-#define NEXTPOW2(x) ((x==1) ? 1 : (1<<(sizeof(uint)*8-__builtin_clz(x-1))))
-#define NUMBITS(x) ((x==0) ? 0 : 8*sizeof(x)-__builtin_clz(x))
+#define NEXTPOW2(x) ((x == 1) ? 1 : (1 << (sizeof(uint) * 8 - __builtin_clz(x - 1))))
+#define NUMBITS(x) ((x == 0) ? 0 : 8 * sizeof(x) - __builtin_clz(x))
 
 #ifdef CONFIG_DEBUG
 #define DEBUG(fmt, ...) do { model_print("*** %15s:%-4d %25s() *** " fmt, __FILE__, __LINE__, __func__, ## __VA_ARGS__); } while (0)
 
 #ifdef CONFIG_DEBUG
 #define DEBUG(fmt, ...) do { model_print("*** %15s:%-4d %25s() *** " fmt, __FILE__, __LINE__, __func__, ## __VA_ARGS__); } while (0)
index d440aadc593c1d8ce9ec0b4e0b846cc6f8d976aa..683084bef397bf1b49d5c4ed074419ae514d32a2 100644 (file)
 #include "satencoder.h"
 #include "sattranslator.h"
 
 #include "satencoder.h"
 #include "sattranslator.h"
 
-CSolver * allocCSolver() {
-       CSolver * This=(CSolver *) ourmalloc(sizeof(CSolver));
-       This->constraints=allocDefVectorBoolean();
-       This->allBooleans=allocDefVectorBoolean();
-       This->allSets=allocDefVectorSet();
-       This->allElements=allocDefVectorElement();
+CSolver *allocCSolver() {
+       CSolver *This = (CSolver *) ourmalloc(sizeof(CSolver));
+       This->constraints = allocDefVectorBoolean();
+       This->allBooleans = allocDefVectorBoolean();
+       This->allSets = allocDefVectorSet();
+       This->allElements = allocDefVectorElement();
        This->allPredicates = allocDefVectorPredicate();
        This->allTables = allocDefVectorTable();
        This->allOrders = allocDefVectorOrder();
        This->allPredicates = allocDefVectorPredicate();
        This->allTables = allocDefVectorTable();
        This->allOrders = allocDefVectorOrder();
@@ -29,44 +29,44 @@ CSolver * allocCSolver() {
 void deleteSolver(CSolver *This) {
        deleteVectorBoolean(This->constraints);
 
 void deleteSolver(CSolver *This) {
        deleteVectorBoolean(This->constraints);
 
-       uint size=getSizeVectorBoolean(This->allBooleans);
-       for(uint i=0;i<size;i++) {
+       uint size = getSizeVectorBoolean(This->allBooleans);
+       for (uint i = 0; i < size; i++) {
                deleteBoolean(getVectorBoolean(This->allBooleans, i));
        }
        deleteVectorBoolean(This->allBooleans);
 
                deleteBoolean(getVectorBoolean(This->allBooleans, i));
        }
        deleteVectorBoolean(This->allBooleans);
 
-       size=getSizeVectorSet(This->allSets);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorSet(This->allSets);
+       for (uint i = 0; i < size; i++) {
                deleteSet(getVectorSet(This->allSets, i));
        }
        deleteVectorSet(This->allSets);
 
                deleteSet(getVectorSet(This->allSets, i));
        }
        deleteVectorSet(This->allSets);
 
-       size=getSizeVectorElement(This->allElements);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorElement(This->allElements);
+       for (uint i = 0; i < size; i++) {
                deleteElement(getVectorElement(This->allElements, i));
        }
        deleteVectorElement(This->allElements);
 
                deleteElement(getVectorElement(This->allElements, i));
        }
        deleteVectorElement(This->allElements);
 
-       size=getSizeVectorTable(This->allTables);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorTable(This->allTables);
+       for (uint i = 0; i < size; i++) {
                deleteTable(getVectorTable(This->allTables, i));
        }
        deleteVectorTable(This->allTables);
 
                deleteTable(getVectorTable(This->allTables, i));
        }
        deleteVectorTable(This->allTables);
 
-       size=getSizeVectorPredicate(This->allPredicates);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorPredicate(This->allPredicates);
+       for (uint i = 0; i < size; i++) {
                deletePredicate(getVectorPredicate(This->allPredicates, i));
        }
        deleteVectorPredicate(This->allPredicates);
 
                deletePredicate(getVectorPredicate(This->allPredicates, i));
        }
        deleteVectorPredicate(This->allPredicates);
 
-       size=getSizeVectorOrder(This->allOrders);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorOrder(This->allOrders);
+       for (uint i = 0; i < size; i++) {
                deleteOrder(getVectorOrder(This->allOrders, i));
        }
        deleteVectorOrder(This->allOrders);
 
                deleteOrder(getVectorOrder(This->allOrders, i));
        }
        deleteVectorOrder(This->allOrders);
 
-       size=getSizeVectorFunction(This->allFunctions);
-       for(uint i=0;i<size;i++) {
+       size = getSizeVectorFunction(This->allFunctions);
+       for (uint i = 0; i < size; i++) {
                deleteFunction(getVectorFunction(This->allFunctions, i));
        }
        deleteVectorFunction(This->allFunctions);
                deleteFunction(getVectorFunction(This->allFunctions, i));
        }
        deleteVectorFunction(This->allFunctions);
@@ -74,161 +74,161 @@ void deleteSolver(CSolver *This) {
        ourfree(This);
 }
 
        ourfree(This);
 }
 
-Set * createSet(CSolver * This, VarType type, uint64_t * elements, uint numelements) {
-       Set * set=allocSet(type, elements, numelements);
+Set *createSet(CSolver *This, VarType type, uint64_t *elements, uint numelements) {
+       Set *set = allocSet(type, elements, numelements);
        pushVectorSet(This->allSets, set);
        return set;
 }
 
        pushVectorSet(This->allSets, set);
        return set;
 }
 
-Set * createRangeSet(CSolver * This, VarType type, uint64_t lowrange, uint64_t highrange) {
-       Set * set=allocSetRange(type, lowrange, highrange);
+Set *createRangeSet(CSolver *This, VarType type, uint64_t lowrange, uint64_t highrange) {
+       Set *set = allocSetRange(type, lowrange, highrange);
        pushVectorSet(This->allSets, set);
        return set;
 }
 
        pushVectorSet(This->allSets, set);
        return set;
 }
 
-MutableSet * createMutableSet(CSolver * This, VarType type) {
-       MutableSet * set=allocMutableSet(type);
+MutableSet *createMutableSet(CSolver *This, VarType type) {
+       MutableSet *set = allocMutableSet(type);
        pushVectorSet(This->allSets, set);
        return set;
 }
 
        pushVectorSet(This->allSets, set);
        return set;
 }
 
-void addItem(CSolver *This, MutableSet * set, uint64_t element) {
+void addItem(CSolver *This, MutableSet *set, uint64_t element) {
        addElementMSet(set, element);
 }
 
        addElementMSet(set, element);
 }
 
-uint64_t createUniqueItem(CSolver *This, MutableSet * set) {
-       uint64_t element=set->low++;
+uint64_t createUniqueItem(CSolver *This, MutableSet *set) {
+       uint64_t element = set->low++;
        addElementMSet(set, element);
        return element;
 }
 
        addElementMSet(set, element);
        return element;
 }
 
-Element * getElementVar(CSolver *This, Set * set) {
-       Element * element=allocElementSet(set);
+Element *getElementVar(CSolver *This, Set *set) {
+       Element *element = allocElementSet(set);
        pushVectorElement(This->allElements, element);
        return element;
 }
 
        pushVectorElement(This->allElements, element);
        return element;
 }
 
-Element * getElementConst(CSolver *This, VarType type, uint64_t value) {
-       Element * element=allocElementConst(value, type);
+Element *getElementConst(CSolver *This, VarType type, uint64_t value) {
+       Element *element = allocElementConst(value, type);
        pushVectorElement(This->allElements, element);
        return element;
 }
 
        pushVectorElement(This->allElements, element);
        return element;
 }
 
-Boolean * getBooleanVar(CSolver *This, VarType type) {
-       Boolean* boolean= allocBooleanVar(type);
+Boolean *getBooleanVar(CSolver *This, VarType type) {
+       Boolean *boolean = allocBooleanVar(type);
        pushVectorBoolean(This->allBooleans, boolean);
        return boolean;
 }
 
        pushVectorBoolean(This->allBooleans, boolean);
        return boolean;
 }
 
-Function * createFunctionOperator(CSolver *This, ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior) {
-       Functionfunction = allocFunctionOperator(op, domain, numDomain, range, overflowbehavior);
+Function *createFunctionOperator(CSolver *This, ArithOp op, Set **domain, uint numDomain, Set *range,OverFlowBehavior overflowbehavior) {
+       Function *function = allocFunctionOperator(op, domain, numDomain, range, overflowbehavior);
        pushVectorFunction(This->allFunctions, function);
        return function;
 }
 
        pushVectorFunction(This->allFunctions, function);
        return function;
 }
 
-Predicate * createPredicateOperator(CSolver *This, CompOp op, Set ** domain, uint numDomain) {
-       Predicate* predicate= allocPredicateOperator(op, domain,numDomain);
+Predicate *createPredicateOperator(CSolver *This, CompOp op, Set **domain, uint numDomain) {
+       Predicate *predicate = allocPredicateOperator(op, domain,numDomain);
        pushVectorPredicate(This->allPredicates, predicate);
        return predicate;
 }
 
        pushVectorPredicate(This->allPredicates, predicate);
        return predicate;
 }
 
-Predicate * createPredicateTable(CSolver *This, Table* table, UndefinedBehavior behavior){
-       Predicatepredicate = allocPredicateTable(table, behavior);
+Predicate *createPredicateTable(CSolver *This, Table *table, UndefinedBehavior behavior) {
+       Predicate *predicate = allocPredicateTable(table, behavior);
        pushVectorPredicate(This->allPredicates, predicate);
        return predicate;
 }
 
        pushVectorPredicate(This->allPredicates, predicate);
        return predicate;
 }
 
-Table * createTable(CSolver *This, Set **domains, uint numDomain, Set * range) {
-       Table* table= allocTable(domains,numDomain,range);
+Table *createTable(CSolver *This, Set **domains, uint numDomain, Set *range) {
+       Table *table = allocTable(domains,numDomain,range);
        pushVectorTable(This->allTables, table);
        return table;
 }
 
        pushVectorTable(This->allTables, table);
        return table;
 }
 
-Table * createTableForPredicate(CSolver *solver, Set **domains, uint numDomain){
+Table *createTableForPredicate(CSolver *solver, Set **domains, uint numDomain) {
        return createTable(solver, domains, numDomain, NULL);
 }
 
        return createTable(solver, domains, numDomain, NULL);
 }
 
-void addTableEntry(CSolver *This, Table* table, uint64_t* inputs, uint inputSize, uint64_t result) {
+void addTableEntry(CSolver *This, Table *table, uint64_t *inputs, uint inputSize, uint64_t result) {
        addNewTableEntry(table,inputs, inputSize,result);
 }
 
        addNewTableEntry(table,inputs, inputSize,result);
 }
 
-Function * completeTable(CSolver *This, Table * table, UndefinedBehavior behavior) {
-       Functionfunction = allocFunctionTable(table, behavior);
+Function *completeTable(CSolver *This, Table *table, UndefinedBehavior behavior) {
+       Function *function = allocFunctionTable(table, behavior);
        pushVectorFunction(This->allFunctions,function);
        return function;
 }
 
        pushVectorFunction(This->allFunctions,function);
        return function;
 }
 
-Element * applyFunction(CSolver *This, Function * function, Element ** array, uint numArrays, Boolean * overflowstatus) {
-       Element* element= allocElementFunction(function,array,numArrays,overflowstatus);
+Element *applyFunction(CSolver *This, Function *function, Element **array, uint numArrays, Boolean *overflowstatus) {
+       Element *element = allocElementFunction(function,array,numArrays,overflowstatus);
        pushVectorElement(This->allElements, element);
        return element;
 }
 
        pushVectorElement(This->allElements, element);
        return element;
 }
 
-Boolean * applyPredicate(CSolver *This, Predicate * predicate, Element ** inputs, uint numInputs) {
+Boolean *applyPredicate(CSolver *This, Predicate *predicate, Element **inputs, uint numInputs) {
        return applyPredicateTable(This, predicate, inputs, numInputs, NULL);
 }
        return applyPredicateTable(This, predicate, inputs, numInputs, NULL);
 }
-Boolean * applyPredicateTable(CSolver *This, Predicate * predicate, Element ** inputs, uint numInputs, Boolean* undefinedStatus) {
-       Boolean* boolean= allocBooleanPredicate(predicate, inputs, numInputs, undefinedStatus);
+Boolean *applyPredicateTable(CSolver *This, Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus) {
+       Boolean *boolean = allocBooleanPredicate(predicate, inputs, numInputs, undefinedStatus);
        pushVectorBoolean(This->allBooleans, boolean);
        return boolean;
 }
 
        pushVectorBoolean(This->allBooleans, boolean);
        return boolean;
 }
 
-Boolean * applyLogicalOperation(CSolver *This, LogicOp op, Boolean ** array, uint asize) {
+Boolean *applyLogicalOperation(CSolver *This, LogicOp op, Boolean **array, uint asize) {
        return allocBooleanLogicArray(This, op, array, asize);
 }
 
        return allocBooleanLogicArray(This, op, array, asize);
 }
 
-void addConstraint(CSolver *This, Boolean * constraint) {
+void addConstraint(CSolver *This, Boolean *constraint) {
        pushVectorBoolean(This->constraints, constraint);
 }
 
        pushVectorBoolean(This->constraints, constraint);
 }
 
-Order * createOrder(CSolver *This, OrderType type, Set * set) {
-       Orderorder = allocOrder(type, set);
+Order *createOrder(CSolver *This, OrderType type, Set *set) {
+       Order *order = allocOrder(type, set);
        pushVectorOrder(This->allOrders, order);
        return order;
 }
 
        pushVectorOrder(This->allOrders, order);
        return order;
 }
 
-Boolean * orderConstraint(CSolver *This, Order * order, uint64_t first, uint64_t second) {
-       Booleanconstraint = allocBooleanOrder(order, first, second);
+Boolean *orderConstraint(CSolver *This, Order *order, uint64_t first, uint64_t second) {
+       Boolean *constraint = allocBooleanOrder(order, first, second);
        pushVectorBoolean(This->allBooleans,constraint);
        return constraint;
 }
 
        pushVectorBoolean(This->allBooleans,constraint);
        return constraint;
 }
 
-int startEncoding(CSolver* This){
+int startEncoding(CSolver *This) {
        naiveEncodingDecision(This);
        naiveEncodingDecision(This);
-       SATEncodersatEncoder = This->satEncoder;
+       SATEncoder *satEncoder = This->satEncoder;
        encodeAllSATEncoder(This, satEncoder);
        encodeAllSATEncoder(This, satEncoder);
-       int result= solveCNF(satEncoder->cnf);
+       int result = solveCNF(satEncoder->cnf);
        model_print("sat_solver's result:%d\tsolutionSize=%d\n", result, satEncoder->cnf->solver->solutionsize);
        model_print("sat_solver's result:%d\tsolutionSize=%d\n", result, satEncoder->cnf->solver->solutionsize);
-       for(uint i=1; i<=satEncoder->cnf->solver->solutionsize; i++){
+       for (uint i = 1; i <= satEncoder->cnf->solver->solutionsize; i++) {
                model_print("%d, ", satEncoder->cnf->solver->solution[i]);
        }
        model_print("\n");
        return result;
 }
 
                model_print("%d, ", satEncoder->cnf->solver->solution[i]);
        }
        model_print("\n");
        return result;
 }
 
-uint64_t getElementValue(CSolver* This, Element* element){
-       switch(GETELEMENTTYPE(element)){
-               case ELEMSET:
-               case ELEMCONST:
-               case ELEMFUNCRETURN:
-                       return getElementValueSATTranslator(This, element);
-               default:
-                       ASSERT(0);
+uint64_t getElementValue(CSolver *This, Element *element) {
+       switch (GETELEMENTTYPE(element)) {
+       case ELEMSET:
+       case ELEMCONST:
+       case ELEMFUNCRETURN:
+               return getElementValueSATTranslator(This, element);
+       default:
+               ASSERT(0);
        }
        exit(-1);
 }
 
        }
        exit(-1);
 }
 
-bool getBooleanValue( CSolver* This , Boolean* boolean){
-       switch(GETBOOLEANTYPE(boolean)){
-               case BOOLEANVAR:
-                       return getBooleanVariableValueSATTranslator(This, boolean);
-               default:
-                       ASSERT(0);
+bool getBooleanValue( CSolver *This, Boolean *boolean) {
+       switch (GETBOOLEANTYPE(boolean)) {
+       case BOOLEANVAR:
+               return getBooleanVariableValueSATTranslator(This, boolean);
+       default:
+               ASSERT(0);
        }
        exit(-1);
 }
 
        }
        exit(-1);
 }
 
-HappenedBefore getOrderConstraintValue(CSolver* This, Order * order, uint64_t first, uint64_t second){
+HappenedBefore getOrderConstraintValue(CSolver *This, Order *order, uint64_t first, uint64_t second) {
        return getOrderConstraintValueSATTranslator(This, order, first, second);
 }
 
        return getOrderConstraintValueSATTranslator(This, order, first, second);
 }
 
index b35f80100b278d6846b77eaefaa3e3aded85e134..cde6c64688b83ee6f670912338f6196a294c19b6 100644 (file)
 #include "structs.h"
 
 struct CSolver {
 #include "structs.h"
 
 struct CSolver {
-       SATEncodersatEncoder;
+       SATEncoder *satEncoder;
        /** This is a vector of constraints that must be satisfied. */
        /** This is a vector of constraints that must be satisfied. */
-       VectorBoolean * constraints;
+       VectorBoolean *constraints;
 
        /** This is a vector of all boolean structs that we have allocated. */
 
        /** This is a vector of all boolean structs that we have allocated. */
-       VectorBoolean * allBooleans;
+       VectorBoolean *allBooleans;
 
        /** This is a vector of all set structs that we have allocated. */
 
        /** This is a vector of all set structs that we have allocated. */
-       VectorSet * allSets;
+       VectorSet *allSets;
 
        /** This is a vector of all element structs that we have allocated. */
 
        /** This is a vector of all element structs that we have allocated. */
-       VectorElement * allElements;
+       VectorElement *allElements;
 
        /** This is a vector of all predicate structs that we have allocated. */
 
        /** This is a vector of all predicate structs that we have allocated. */
-       VectorPredicate * allPredicates;
+       VectorPredicate *allPredicates;
 
        /** This is a vector of all table structs that we have allocated. */
 
        /** This is a vector of all table structs that we have allocated. */
-       VectorTable * allTables;
+       VectorTable *allTables;
 
        /** This is a vector of all order structs that we have allocated. */
 
        /** This is a vector of all order structs that we have allocated. */
-       VectorOrder * allOrders;
+       VectorOrder *allOrders;
 
        /** This is a vector of all function structs that we have allocated. */
 
        /** This is a vector of all function structs that we have allocated. */
-       VectorFunctionallFunctions;
+       VectorFunction *allFunctions;
 };
 
 /** Create a new solver instance. */
 
 };
 
 /** Create a new solver instance. */
 
-CSolver * allocCSolver();
+CSolver *allocCSolver();
 
 /** Delete solver instance. */
 
 
 /** Delete solver instance. */
 
-void deleteSolver(CSolver * This);
+void deleteSolver(CSolver *This);
 
 /** This function creates a set containing the elements passed in the array. */
 
 
 /** This function creates a set containing the elements passed in the array. */
 
-Set * createSet(CSolver *, VarType type, uint64_t * elements, uint num);
+Set *createSet(CSolver *, VarType type, uint64_t *elements, uint num);
 
 /** This function creates a set from lowrange to highrange (inclusive). */
 
 
 /** This function creates a set from lowrange to highrange (inclusive). */
 
-Set * createRangeSet(CSolver *, VarType type, uint64_t lowrange, uint64_t highrange);
+Set *createRangeSet(CSolver *, VarType type, uint64_t lowrange, uint64_t highrange);
 
 /** This function creates a mutable set. */
 
 
 /** This function creates a mutable set. */
 
-MutableSet * createMutableSet(CSolver *, VarType type);
+MutableSet *createMutableSet(CSolver *, VarType type);
 
 /** This function adds a new item to a set. */
 
 
 /** This function adds a new item to a set. */
 
-void addItem(CSolver *, MutableSet * set, uint64_t element);
+void addItem(CSolver *, MutableSet *set, uint64_t element);
 
 /** This function adds a new unique item to the set and returns it.
     This function cannot be used in conjunction with manually adding
     items to the set. */
 
 
 /** This function adds a new unique item to the set and returns it.
     This function cannot be used in conjunction with manually adding
     items to the set. */
 
-uint64_t createUniqueItem(CSolver *, MutableSet * set);
+uint64_t createUniqueItem(CSolver *, MutableSet *set);
 
 /** This function creates an element variable over a set. */
 
 
 /** This function creates an element variable over a set. */
 
-Element * getElementVar(CSolver *, Set * set);
+Element *getElementVar(CSolver *, Set *set);
 
 /** This function creates an element constrant. */
 
 /** This function creates an element constrant. */
-Element * getElementConst(CSolver *, VarType type, uint64_t value);
+Element *getElementConst(CSolver *, VarType type, uint64_t value);
 
 /** This function creates a boolean variable. */
 
 
 /** This function creates a boolean variable. */
 
-Boolean * getBooleanVar(CSolver *, VarType type);
+Boolean *getBooleanVar(CSolver *, VarType type);
 
 /** This function creates a function operator. */
 
 
 /** This function creates a function operator. */
 
-Function * createFunctionOperator(CSolver *solver, ArithOp op, Set ** domain, uint numDomain, Set * range,
-                                                                                                                                       OverFlowBehavior overflowbehavior);
+Function *createFunctionOperator(CSolver *solver, ArithOp op, Set **domain, uint numDomain, Set *range,
+                                                                                                                                OverFlowBehavior overflowbehavior);
 
 /** This function creates a predicate operator. */
 
 
 /** This function creates a predicate operator. */
 
-Predicate * createPredicateOperator(CSolver *solver, CompOp op, Set ** domain, uint numDomain);
+Predicate *createPredicateOperator(CSolver *solver, CompOp op, Set **domain, uint numDomain);
 
 
-Predicate * createPredicateTable(CSolver *solver, Table* table, UndefinedBehavior behavior);
+Predicate *createPredicateTable(CSolver *solver, Table *table, UndefinedBehavior behavior);
 
 /** This function creates an empty instance table.*/
 
 
 /** This function creates an empty instance table.*/
 
-Table * createTable(CSolver *solver, Set **domains, uint numDomain, Set * range);
+Table *createTable(CSolver *solver, Set **domains, uint numDomain, Set *range);
 
 
-Table * createTableForPredicate(CSolver *solver, Set **domains, uint numDomain);
+Table *createTableForPredicate(CSolver *solver, Set **domains, uint numDomain);
 /** This function adds an input output relation to a table. */
 
 /** This function adds an input output relation to a table. */
 
-void addTableEntry(CSolver *solver, Table* table, uint64_t* inputs, uint inputSize, uint64_t result);
+void addTableEntry(CSolver *solver, Table *table, uint64_t *inputs, uint inputSize, uint64_t result);
 
 /** This function converts a completed table into a function. */
 
 
 /** This function converts a completed table into a function. */
 
-Function * completeTable(CSolver *, Table *, UndefinedBehavior behavior);
+Function *completeTable(CSolver *, Table *, UndefinedBehavior behavior);
 
 /** This function applies a function to the Elements in its input. */
 
 
 /** This function applies a function to the Elements in its input. */
 
-Element * applyFunction(CSolver *, Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
+Element *applyFunction(CSolver *, Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
 
 /** This function applies a predicate to the Elements in its input. */
 
 
 /** This function applies a predicate to the Elements in its input. */
 
-Boolean * applyPredicateTable(CSolver *, Predicate * predicate, Element ** inputs, uint numInputs, Boolean* undefinedStatus);
+Boolean *applyPredicateTable(CSolver *, Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus);
 
 
-Boolean * applyPredicate(CSolver *, Predicate * predicate, Element ** inputs, uint numInputs);
+Boolean *applyPredicate(CSolver *, Predicate *predicate, Element **inputs, uint numInputs);
 
 /** This function applies a logical operation to the Booleans in its input. */
 
 
 /** This function applies a logical operation to the Booleans in its input. */
 
-Boolean * applyLogicalOperation(CSolver *, LogicOp op, Boolean ** array, uint asize);
+Boolean *applyLogicalOperation(CSolver *, LogicOp op, Boolean **array, uint asize);
 
 /** This function adds a boolean constraint to the set of constraints
     to be satisfied */
 
 
 /** This function adds a boolean constraint to the set of constraints
     to be satisfied */
 
-void addConstraint(CSolver *, Boolean * constraint);
+void addConstraint(CSolver *, Boolean *constraint);
 
 /** This function instantiates an order of type type over the set set. */
 
 /** This function instantiates an order of type type over the set set. */
-Order * createOrder(CSolver *, OrderType type, Set * set);
+Order *createOrder(CSolver *, OrderType type, Set *set);
 
 /** This function instantiates a boolean on two items in an order. */
 
 /** This function instantiates a boolean on two items in an order. */
-Boolean * orderConstraint(CSolver *, Order * order, uint64_t first, uint64_t second);
+Boolean *orderConstraint(CSolver *, Order *order, uint64_t first, uint64_t second);
 
 /** When everything is done, the client calls this function and then csolver starts to encode*/
 
 /** When everything is done, the client calls this function and then csolver starts to encode*/
-int startEncoding(CSolver*);
+int startEncoding(CSolver *);
 
 /** After getting the solution from the SAT solver, client can get the value of an element via this function*/
 
 /** After getting the solution from the SAT solver, client can get the value of an element via this function*/
-uint64_t getElementValue(CSolver*, Element* element);
+uint64_t getElementValue(CSolver *, Element *element);
 
 /** After getting the solution from the SAT solver, client can get the value of a boolean via this function*/
 
 /** After getting the solution from the SAT solver, client can get the value of a boolean via this function*/
-bool getBooleanValue( CSolver* , Boolean* boolean);
+bool getBooleanValue( CSolver *, Boolean *boolean);
 
 
-HappenedBefore getOrderConstraintValue(CSolver*, Order * order, uint64_t first, uint64_t second);
+HappenedBefore getOrderConstraintValue(CSolver *, Order *order, uint64_t first, uint64_t second);
 
 #endif
 
 #endif
index 32dfa51b51e8807f6c906ff64d585f08ba099835..b778c48ae482aa383dc8d0ca6c506998bac77701 100644 (file)
 #include "config.h"
 
 /*
 #include "config.h"
 
 /*
-void * ourmalloc(size_t size);
-void ourfree(void *ptr);
-void * ourcalloc(size_t count, size_t size);
-void * ourrealloc(void *ptr, size_t size);
-*/
+   void * ourmalloc(size_t size);
+   void ourfree(void *ptr);
+   void * ourcalloc(size_t count, size_t size);
+   void * ourrealloc(void *ptr, size_t size);
+ */
 
 
-static inline void * ourmalloc(size_t size) { return malloc(size); }
+static inline void *ourmalloc(size_t size) { return malloc(size); }
 static inline void ourfree(void *ptr) { free(ptr); }
 static inline void ourfree(void *ptr) { free(ptr); }
-static inline void * ourcalloc(size_t count, size_t size) { return calloc(count, size); }
-static inline void * ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
+static inline void *ourcalloc(size_t count, size_t size) { return calloc(count, size); }
+static inline void *ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
 
 #endif/* _MY_MEMORY_H */
 
 #endif/* _MY_MEMORY_H */