Commit 21289bf0 by Alan Mishchenko

Renaming several Satoko APIs to avoid collision with MiniSAT.

parent 0d307b1c
...@@ -21,7 +21,7 @@ static inline void clause_act_rescale(solver_t *s) ...@@ -21,7 +21,7 @@ static inline void clause_act_rescale(solver_t *s)
struct clause *clause; struct clause *clause;
vec_uint_foreach(s->learnts, cref, i) { vec_uint_foreach(s->learnts, cref, i) {
clause = clause_read(s, cref); clause = clause_fetch(s, cref);
clause->data[clause->size].act >>= 10; clause->data[clause->size].act >>= 10;
} }
s->clause_act_inc = stk_uint_max((s->clause_act_inc >> 10), (1 << 11)); s->clause_act_inc = stk_uint_max((s->clause_act_inc >> 10), (1 << 11));
......
...@@ -39,7 +39,7 @@ static inline int lit_is_removable(solver_t* s, unsigned lit, unsigned min_level ...@@ -39,7 +39,7 @@ static inline int lit_is_removable(solver_t* s, unsigned lit, unsigned min_level
while (vec_uint_size(s->stack)) { while (vec_uint_size(s->stack)) {
unsigned i; unsigned i;
unsigned var = vec_uint_pop_back(s->stack); unsigned var = vec_uint_pop_back(s->stack);
struct clause *c = clause_read(s, var_reason(s, var)); struct clause *c = clause_fetch(s, var_reason(s, var));
unsigned *lits = &(c->data[0].lit); unsigned *lits = &(c->data[0].lit);
assert(var_reason(s, var) != UNDEF); assert(var_reason(s, var) != UNDEF);
...@@ -106,7 +106,7 @@ static inline void clause_bin_resolution(solver_t *s, vec_uint_t *clause_lits) ...@@ -106,7 +106,7 @@ static inline void clause_bin_resolution(solver_t *s, vec_uint_t *clause_lits)
unsigned *lits = vec_uint_data(clause_lits); unsigned *lits = vec_uint_data(clause_lits);
unsigned counter, sz, i; unsigned counter, sz, i;
unsigned lit; unsigned lit;
unsigned neg_lit = lit_neg(lits[0]); unsigned neg_lit = lit_compl(lits[0]);
struct watcher *w; struct watcher *w;
s->cur_stamp++; s->cur_stamp++;
...@@ -267,7 +267,7 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt ...@@ -267,7 +267,7 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt
unsigned j; unsigned j;
assert(cref != UNDEF); assert(cref != UNDEF);
clause = clause_read(s, cref); clause = clause_fetch(s, cref);
lits = &(clause->data[0].lit); lits = &(clause->data[0].lit);
if (p != UNDEF && clause->size == 2 && lit_value(s, lits[0]) == LIT_FALSE) { if (p != UNDEF && clause->size == 2 && lit_value(s, lits[0]) == LIT_FALSE) {
...@@ -295,7 +295,7 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt ...@@ -295,7 +295,7 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt
var_act_bump(s, var); var_act_bump(s, var);
if (var_dlevel(s, var) == solver_dlevel(s)) { if (var_dlevel(s, var) == solver_dlevel(s)) {
n_paths++; n_paths++;
if (var_reason(s, var) != UNDEF && clause_read(s, var_reason(s, var))->f_learnt) if (var_reason(s, var) != UNDEF && clause_fetch(s, var_reason(s, var))->f_learnt)
vec_uint_push_back(s->last_dlevel, var); vec_uint_push_back(s->last_dlevel, var);
} else } else
vec_uint_push_back(learnt, lits[j]); vec_uint_push_back(learnt, lits[j]);
...@@ -309,14 +309,14 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt ...@@ -309,14 +309,14 @@ static inline void solver_analyze(solver_t *s, unsigned cref, vec_uint_t *learnt
n_paths--; n_paths--;
} while (n_paths > 0); } while (n_paths > 0);
vec_uint_data(learnt)[0] = lit_neg(p); vec_uint_data(learnt)[0] = lit_compl(p);
clause_minimize(s, learnt); clause_minimize(s, learnt);
*bt_level = solver_calc_bt_level(s, learnt); *bt_level = solver_calc_bt_level(s, learnt);
*lbd = clause_clac_lbd(s, vec_uint_data(learnt), vec_uint_size(learnt)); *lbd = clause_clac_lbd(s, vec_uint_data(learnt), vec_uint_size(learnt));
if (vec_uint_size(s->last_dlevel) > 0) { if (vec_uint_size(s->last_dlevel) > 0) {
vec_uint_foreach(s->last_dlevel, var, i) { vec_uint_foreach(s->last_dlevel, var, i) {
if (clause_read(s, var_reason(s, var))->lbd < *lbd) if (clause_fetch(s, var_reason(s, var))->lbd < *lbd)
var_act_bump(s, var); var_act_bump(s, var);
} }
vec_uint_clear(s->last_dlevel); vec_uint_clear(s->last_dlevel);
...@@ -376,10 +376,10 @@ static inline void solver_analyze_final(solver_t *s, unsigned lit) ...@@ -376,10 +376,10 @@ static inline void solver_analyze_final(solver_t *s, unsigned lit)
unsigned reason = var_reason(s, var); unsigned reason = var_reason(s, var);
if (reason == UNDEF) { if (reason == UNDEF) {
assert(var_dlevel(s, var) > 0); assert(var_dlevel(s, var) > 0);
vec_uint_push_back(s->final_conflict, lit_neg(vec_uint_at(s->trail, i))); vec_uint_push_back(s->final_conflict, lit_compl(vec_uint_at(s->trail, i)));
} else { } else {
unsigned j; unsigned j;
struct clause *clause = clause_read(s, reason); struct clause *clause = clause_fetch(s, reason);
for (j = (clause->size == 2 ? 0 : 1); j < clause->size; j++) { for (j = (clause->size == 2 ? 0 : 1); j < clause->size; j++) {
if (lit_dlevel(s, clause->data[j].lit) > 0) if (lit_dlevel(s, clause->data[j].lit) > 0)
vec_char_assign(s->seen, lit2var(clause->data[j].lit), 1); vec_char_assign(s->seen, lit2var(clause->data[j].lit), 1);
...@@ -433,7 +433,7 @@ static inline void solver_reduce_cdb(solver_t *s) ...@@ -433,7 +433,7 @@ static inline void solver_reduce_cdb(solver_t *s)
learnts_cls = satoko_alloc(struct clause *, n_learnts); learnts_cls = satoko_alloc(struct clause *, n_learnts);
vec_uint_foreach_start(s->learnts, cref, i, s->book_cl_lrnt) vec_uint_foreach_start(s->learnts, cref, i, s->book_cl_lrnt)
learnts_cls[i] = clause_read(s, cref); learnts_cls[i] = clause_fetch(s, cref);
limit = (unsigned)(n_learnts * s->opts.learnt_ratio); limit = (unsigned)(n_learnts * s->opts.learnt_ratio);
...@@ -488,7 +488,7 @@ unsigned solver_clause_create(solver_t *s, vec_uint_t *lits, unsigned f_learnt) ...@@ -488,7 +488,7 @@ unsigned solver_clause_create(solver_t *s, vec_uint_t *lits, unsigned f_learnt)
n_words = 3 + f_learnt + vec_uint_size(lits); n_words = 3 + f_learnt + vec_uint_size(lits);
cref = cdb_append(s->all_clauses, n_words); cref = cdb_append(s->all_clauses, n_words);
clause = clause_read(s, cref); clause = clause_fetch(s, cref);
clause->f_learnt = f_learnt; clause->f_learnt = f_learnt;
clause->f_mark = 0; clause->f_mark = 0;
clause->f_reallocd = 0; clause->f_reallocd = 0;
...@@ -569,11 +569,11 @@ unsigned solver_propagate(solver_t *s) ...@@ -569,11 +569,11 @@ unsigned solver_propagate(solver_t *s)
continue; continue;
} }
clause = clause_read(s, i->cref); clause = clause_fetch(s, i->cref);
lits = &(clause->data[0].lit); lits = &(clause->data[0].lit);
// Make sure the false literal is data[1]: // Make sure the false literal is data[1]:
neg_lit = lit_neg(p); neg_lit = lit_compl(p);
if (lits[0] == neg_lit) if (lits[0] == neg_lit)
stk_swap(unsigned, lits[0], lits[1]); stk_swap(unsigned, lits[0], lits[1]);
assert(lits[1] == neg_lit); assert(lits[1] == neg_lit);
...@@ -591,7 +591,7 @@ unsigned solver_propagate(solver_t *s) ...@@ -591,7 +591,7 @@ unsigned solver_propagate(solver_t *s)
if (lit_value(s, lits[k]) != LIT_FALSE) { if (lit_value(s, lits[k]) != LIT_FALSE) {
lits[1] = lits[k]; lits[1] = lits[k];
lits[k] = neg_lit; lits[k] = neg_lit;
watch_list_push(vec_wl_at(s->watches, lit_neg(lits[1])), w, 0); watch_list_push(vec_wl_at(s->watches, lit_compl(lits[1])), w, 0);
goto next; goto next;
} }
} }
...@@ -663,7 +663,7 @@ char solver_search(solver_t *s) ...@@ -663,7 +663,7 @@ char solver_search(solver_t *s)
if (lit_value(s, lit) == LIT_TRUE) { if (lit_value(s, lit) == LIT_TRUE) {
vec_uint_push_back(s->trail_lim, vec_uint_size(s->trail)); vec_uint_push_back(s->trail_lim, vec_uint_size(s->trail));
} else if (lit_value(s, lit) == LIT_FALSE) { } else if (lit_value(s, lit) == LIT_FALSE) {
solver_analyze_final(s, lit_neg(lit)); solver_analyze_final(s, lit_compl(lit));
return SATOKO_UNSAT; return SATOKO_UNSAT;
} else { } else {
next_lit = lit; next_lit = lit;
...@@ -693,7 +693,7 @@ void solver_debug_check(solver_t *s, int result) ...@@ -693,7 +693,7 @@ void solver_debug_check(solver_t *s, int result)
printf("Checking for trail(%u) inconsistencies...", vec_uint_size(s->trail)); printf("Checking for trail(%u) inconsistencies...", vec_uint_size(s->trail));
array = vec_uint_data(s->trail); array = vec_uint_data(s->trail);
for (i = 1; i < vec_uint_size(s->trail); i++) for (i = 1; i < vec_uint_size(s->trail); i++)
if (array[i - 1] == lit_neg(array[i])) { if (array[i - 1] == lit_compl(array[i])) {
printf("Inconsistent trail: %u %u\n", array[i - 1], array[i]); printf("Inconsistent trail: %u %u\n", array[i - 1], array[i]);
return; return;
} }
...@@ -702,7 +702,7 @@ void solver_debug_check(solver_t *s, int result) ...@@ -702,7 +702,7 @@ void solver_debug_check(solver_t *s, int result)
printf("Checking clauses... \n"); printf("Checking clauses... \n");
vec_uint_foreach(s->originals, cref, i) { vec_uint_foreach(s->originals, cref, i) {
unsigned j; unsigned j;
struct clause *clause = clause_read(s, cref); struct clause *clause = clause_fetch(s, cref);
for (j = 0; j < clause->size; j++) { for (j = 0; j < clause->size; j++) {
if (vec_uint_find(s->trail, clause->data[j].lit)) { if (vec_uint_find(s->trail, clause->data[j].lit)) {
break; break;
......
...@@ -166,7 +166,7 @@ static inline void var_clean_mark(solver_t *s, unsigned var) ...@@ -166,7 +166,7 @@ static inline void var_clean_mark(solver_t *s, unsigned var)
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
// Inline lit functions // Inline lit functions
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
static inline unsigned lit_neg(unsigned lit) static inline unsigned lit_compl(unsigned lit)
{ {
return lit ^ 1; return lit ^ 1;
} }
...@@ -238,7 +238,7 @@ static inline void solver_set_stop(solver_t *s, int * pstop) ...@@ -238,7 +238,7 @@ static inline void solver_set_stop(solver_t *s, int * pstop)
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
// Inline clause functions // Inline clause functions
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
static inline struct clause *clause_read(solver_t *s, unsigned cref) static inline struct clause *clause_fetch(solver_t *s, unsigned cref)
{ {
return cdb_handler(s->all_clauses, cref); return cdb_handler(s->all_clauses, cref);
} }
...@@ -253,15 +253,15 @@ static inline void clause_watch(solver_t *s, unsigned cref) ...@@ -253,15 +253,15 @@ static inline void clause_watch(solver_t *s, unsigned cref)
w2.cref = cref; w2.cref = cref;
w1.blocker = clause->data[1].lit; w1.blocker = clause->data[1].lit;
w2.blocker = clause->data[0].lit; w2.blocker = clause->data[0].lit;
watch_list_push(vec_wl_at(s->watches, lit_neg(clause->data[0].lit)), w1, (clause->size == 2)); watch_list_push(vec_wl_at(s->watches, lit_compl(clause->data[0].lit)), w1, (clause->size == 2));
watch_list_push(vec_wl_at(s->watches, lit_neg(clause->data[1].lit)), w2, (clause->size == 2)); watch_list_push(vec_wl_at(s->watches, lit_compl(clause->data[1].lit)), w2, (clause->size == 2));
} }
static inline void clause_unwatch(solver_t *s, unsigned cref) static inline void clause_unwatch(solver_t *s, unsigned cref)
{ {
struct clause *clause = cdb_handler(s->all_clauses, cref); struct clause *clause = cdb_handler(s->all_clauses, cref);
watch_list_remove(vec_wl_at(s->watches, lit_neg(clause->data[0].lit)), cref, (clause->size == 2)); watch_list_remove(vec_wl_at(s->watches, lit_compl(clause->data[0].lit)), cref, (clause->size == 2));
watch_list_remove(vec_wl_at(s->watches, lit_neg(clause->data[1].lit)), cref, (clause->size == 2)); watch_list_remove(vec_wl_at(s->watches, lit_compl(clause->data[1].lit)), cref, (clause->size == 2));
} }
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -202,7 +202,7 @@ int satoko_simplify(solver_t * s) ...@@ -202,7 +202,7 @@ int satoko_simplify(solver_t * s)
return SATOKO_OK; return SATOKO_OK;
vec_uint_foreach(s->originals, cref, i) { vec_uint_foreach(s->originals, cref, i) {
struct clause *clause = clause_read(s, cref); struct clause *clause = clause_fetch(s, cref);
if (clause_is_satisfied(s, clause)) { if (clause_is_satisfied(s, clause)) {
clause->f_mark = 1; clause->f_mark = 1;
...@@ -252,7 +252,7 @@ int satoko_add_clause(solver_t *s, int *lits, int size) ...@@ -252,7 +252,7 @@ int satoko_add_clause(solver_t *s, int *lits, int size)
j = 0; j = 0;
prev_lit = UNDEF; prev_lit = UNDEF;
for (i = 0; i < (unsigned)size; i++) { for (i = 0; i < (unsigned)size; i++) {
if ((unsigned)lits[i] == lit_neg(prev_lit) || lit_value(s, lits[i]) == LIT_TRUE) if ((unsigned)lits[i] == lit_compl(prev_lit) || lit_value(s, lits[i]) == LIT_TRUE)
return SATOKO_OK; return SATOKO_OK;
else if ((unsigned)lits[i] != prev_lit && var_value(s, lit2var(lits[i])) == VAR_UNASSING) { else if ((unsigned)lits[i] != prev_lit && var_value(s, lit2var(lits[i])) == VAR_UNASSING) {
prev_lit = lits[i]; prev_lit = lits[i];
...@@ -404,9 +404,9 @@ void satoko_rollback(satoko_t *s) ...@@ -404,9 +404,9 @@ void satoko_rollback(satoko_t *s)
cl_to_remove = satoko_alloc(struct clause *, n_originals + n_learnts); cl_to_remove = satoko_alloc(struct clause *, n_originals + n_learnts);
/* Mark clauses */ /* Mark clauses */
vec_uint_foreach_start(s->originals, cref, i, s->book_cl_orig) vec_uint_foreach_start(s->originals, cref, i, s->book_cl_orig)
cl_to_remove[i] = clause_read(s, cref); cl_to_remove[i] = clause_fetch(s, cref);
vec_uint_foreach_start(s->learnts, cref, i, s->book_cl_lrnt) vec_uint_foreach_start(s->learnts, cref, i, s->book_cl_lrnt)
cl_to_remove[n_originals + i] = clause_read(s, cref); cl_to_remove[n_originals + i] = clause_fetch(s, cref);
for (i = 0; i < n_originals + n_learnts; i++) { for (i = 0; i < n_originals + n_learnts; i++) {
clause_unwatch(s, cdb_cref(s->all_clauses, (unsigned *)cl_to_remove[i])); clause_unwatch(s, cdb_cref(s->all_clauses, (unsigned *)cl_to_remove[i]));
cl_to_remove[i]->f_mark = 1; cl_to_remove[i]->f_mark = 1;
...@@ -487,12 +487,12 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var) ...@@ -487,12 +487,12 @@ void satoko_write_dimacs(satoko_t *s, char *fname, int wrt_lrnt, int zero_var)
array = vec_uint_data(s->originals); array = vec_uint_data(s->originals);
for (i = 0; i < vec_uint_size(s->originals); i++) for (i = 0; i < vec_uint_size(s->originals); i++)
clause_dump(file, clause_read(s, array[i]), !zero_var); clause_dump(file, clause_fetch(s, array[i]), !zero_var);
if (wrt_lrnt) { if (wrt_lrnt) {
array = vec_uint_data(s->learnts); array = vec_uint_data(s->learnts);
for (i = 0; i < n_lrnts; i++) for (i = 0; i < n_lrnts; i++)
clause_dump(file, clause_read(s, array[i]), !zero_var); clause_dump(file, clause_fetch(s, array[i]), !zero_var);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment