int* s_contr (solver* s) { delete [] s->contr; s->contr = new int[s->conflict.size()+1]; for (int i = 0; i < s->conflict.size(); i++) s->contr[i] = toDimacs(s->conflict[i]); s->contr[s->conflict.size()] = 0; return s->contr; }
void SimpSMTSolver::toDimacs(const char* file) { assert(decisionLevel() == 0); FILE* f = fopen(file, "wr"); if (f != NULL){ // Cannot use removeClauses here because it is not safe // to deallocate them at this point. Could be improved. int cnt = 0; for (int i = 0; i < clauses.size(); i++) if (!satisfied(*clauses[i])) cnt++; fprintf(f, "p cnf %d %d\n", nVars(), cnt); for (int i = 0; i < clauses.size(); i++) toDimacs(f, *clauses[i]); fprintf(stderr, "Wrote %d clauses...\n", clauses.size()); }else fprintf(stderr, "could not open file %s\n", file); }
int s_newlit (solver* s) { return toDimacs(s->mkLit()); }
// reading the value of a predicate (location) int solver_lit_read (solver* w) { // creates variables if they don't exists!! (fix?) int lit = toDimacs(Lit(w->loc->get(*w, w->args, w->dummy), !w->sig)); return lit; }
void s_add (solver* s, int a, int b, int c, int* carry, int* sum){ Lit _carry, _sum; s->mkAdd(fromDimacs(a), fromDimacs(b), fromDimacs(c),_carry,_sum); *carry = toDimacs(_carry); *sum = toDimacs(_sum); }
int s_ite (solver* s, int c, int t, int f) { return toDimacs(s->mkIte(fromDimacs(c), fromDimacs(t), fromDimacs(f))); }
int s_xor (solver* s, int x, int y) { return toDimacs(s->mkXor(fromDimacs(x), fromDimacs(y))); }
int s_equ (solver* s, int x, int y) { return toDimacs(s->mkEqu(fromDimacs(x), fromDimacs(y))); }
int s_and (solver* s, int x, int y) { return toDimacs(s->mkAnd(fromDimacs(x), fromDimacs(y))); }