ElementConst *This = (ElementConst *)ourmalloc(sizeof(ElementConst));
GETELEMENTTYPE(This) = ELEMCONST;
This->value = value;
- This->set = allocSet(type, (uint64_t[]) {value}, 1);
+ uint64_t array[]={value};
+ This->set = allocSet(type, array, 1);
initDefVectorASTNode(GETELEMENTPARENTS(This));
initElementEncoding(&This->encoding, (Element *) This);
return &This->base;
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;
+ uint initindex = 0;
while (initindex < numEdges && equalsEdge(edges[initindex], E_True))
initindex++;
if (equalsEdge(cond, E_True)) {
result = thenedge;
} else if (equalsEdge(thenedge, E_True) || equalsEdge(cond, thenedge)) {
- result = constraintOR(cnf, 2, (Edge[]) {cond, elseedge});
+ Edge array[] = {cond, elseedge};
+ result = constraintOR(cnf, 2, array);
} else if (equalsEdge(elseedge, E_True) || sameNodeOppSign(cond, elseedge)) {
result = constraintIMPLIES(cnf, cond, thenedge);
} else if (equalsEdge(thenedge, E_False) || equalsEdge(cond, elseedge)) {
- result = constraintAND(cnf, 2, (Edge[]) {cond, thenedge});
+ Edge array[] = {cond, thenedge};
+ result = constraintAND(cnf, 2, array);
} else if (equalsEdge(thenedge, elseedge)) {
result = thenedge;
} else if (sameNodeOppSign(thenedge, elseedge)) {
if (ltEdge(cond, thenedge)) {
- result = createNode(cnf, NodeType_IFF, 2, (Edge[]) {cond, thenedge});
+ Edge array[] = {cond, thenedge};
+ result = createNode(cnf, NodeType_IFF, 2, array);
} else {
- result = createNode(cnf, NodeType_IFF, 2, (Edge[]) {thenedge, cond});
+ Edge array[] = {thenedge, cond};
+ result = createNode(cnf, NodeType_IFF, 2, array);
}
} else {
Edge edges[] = {cond, thenedge, elseedge};
int *buffer;
int *solution;
int solutionsize;
- int offset;
+ uint offset;
pid_t solver_pid;
int to_solver_fd;
int from_solver_fd;
uint i = 0;
while (hasNextTableEntry(iterator)) {
TableEntry *entry = nextTableEntry(iterator);
- if (generateNegation == entry->output && undefStatus == IGNOREBEHAVIOR) {
+ if (generateNegation == (entry->output != 0) && undefStatus == IGNOREBEHAVIOR) {
//Skip the irrelevant entries
continue;
}
break;
case FLAGFORCEUNDEFINED: {
addConstraintCNF(This->cnf, constraintIMPLIES(This->cnf,constraintAND(This->cnf, inputNum, carray), constraintNegate(undefConst)));
- if (generateNegation == entry->output) {
+ if (generateNegation == (entry->output != 0)) {
continue;
}
row = constraintAND(This->cnf, inputNum, carray);
setElementEncodingType(encoding, BINARYINDEX);
encodingArrayInitialization(encoding);
}
- Predicate *predicate =allocPredicateOperator(LT, (Set*[]){order->set, order->set}, 2);
- Boolean * boolean=allocBooleanPredicate(predicate, (Element *[]){elem1,elem2}, 2, NULL);
+ Set * sarray[]={order->set, order->set};
+ Predicate *predicate =allocPredicateOperator(LT, sarray, 2);
+ Element * parray[]={elem1, elem2};
+ Boolean * boolean=allocBooleanPredicate(predicate, parray, 2, NULL);
setFunctionEncodingType(getPredicateFunctionEncoding((BooleanPredicate*)boolean), CIRCUIT);
{//Adding new elements and boolean/predicate to solver regarding memory management
pushVectorBoolean(This->solver->allBooleans, boolean);
//Compute in set for entire SCC
uint rSize = getSizeVectorOrderNode(&sccNodes);
- for (int j = 0; j < rSize; j++) {
+ for (uint j = 0; j < rSize; j++) {
OrderNode *rnode = getVectorOrderNode(&sccNodes, j);
//Compute source sets
HSIteratorOrderEdge *iterator = iteratorOrderEdge(rnode->inEdges);
}
deleteIterOrderEdge(iterator);
}
- for (int j=0; j < rSize; j++) {
+ for (uint j=0; j < rSize; j++) {
//Copy in set of entire SCC
OrderNode *rnode = getVectorOrderNode(&sccNodes, j);
HashSetOrderNode * set = (j==0) ? sources : copyHashSetOrderNode(sources);
Boolean *b3 = getBooleanVar(solver, 0);
Boolean *b4 = getBooleanVar(solver, 0);
//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 * barray1[]={b1,b2};
+ Boolean *andb1b2 = applyLogicalOperation(solver, L_AND, barray1, 2);
+ Boolean * barray2[]={andb1b2, b3};
+ Boolean *imply = applyLogicalOperation(solver, L_IMPLIES, barray2, 2);
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));
+ Boolean * barray3[] ={b3};
+ Boolean *notb3 = applyLogicalOperation(solver, L_NOT, barray3, 1);
+ Boolean * barray4[] ={notb3, b4};
+ addConstraint(solver, applyLogicalOperation(solver, L_OR, barray4, 2));
+ Boolean * barray5[] ={b1, b4};
+ addConstraint(solver, applyLogicalOperation(solver, L_XOR, barray5, 2));
if (startEncoding(solver) == 1)
printf("b1=%d b2=%d b3=%d b4=%d\n",
getBooleanValue(solver,b1), getBooleanValue(solver, b2),
else
printf("UNSAT\n");
deleteSolver(solver);
-}
\ No newline at end of file
+}
Boolean *o58 = orderConstraint(solver, order, 5, 8);
Boolean *o81 = orderConstraint(solver, order, 8, 1);
+ /*
addConstraint(solver, applyLogicalOperation(solver, L_OR,(Boolean *[]) {o12, o13, o24, o34}, 4) );
Boolean *b1 = applyLogicalOperation(solver, L_XOR, (Boolean *[]) {o41, o57}, 2);
Boolean *o34n = applyLogicalOperation(solver, L_NOT, (Boolean *[]) {o34}, 1);
if (startEncoding(solver) == 1)
printf("SAT\n");
else
- printf("UNSAT\n");
+ printf("UNSAT\n");*/
deleteSolver(solver);
-}
\ No newline at end of file
+}
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);
+ Element * tmparray[]={e1, e2};
+ Element *e3 = applyFunction(solver, f1, tmparray, 2, overflow);
Set *deq[] = {s3,s2};
Predicate *lte = createPredicateOperator(solver, LTE, deq, 2);
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);
+ Element * tmparray[] = {e1, e2, e3};
+ Boolean *b1 = applyPredicateTable(solver, p1, tmparray, 3, undef);
addConstraint(solver, b1);
Set *deq[] = {s3,s2};
Set *d1[] = {s1, s2};
Predicate *eq = createPredicateOperator(solver, EQUALS, d1, 2);
- Boolean *pred2 = applyPredicate(solver, eq,(Element *[]) {e1, e2}, 2);
+ Element * tmparray2[] = {e1, e2};
+ Boolean *pred2 = applyPredicate(solver, eq, tmparray2, 2);
addConstraint(solver, pred2);
if (startEncoding(solver) == 1)
encodeAllSATEncoder(This, satEncoder);
int result = solveCNF(satEncoder->cnf);
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 (int i = 1; i <= satEncoder->cnf->solver->solutionsize; i++) {
model_print("%d, ", satEncoder->cnf->solver->solution[i]);
}
model_print("\n");