//sets the literal to true, and then runs unit resolution //returns a learned clause if unit resolution detected a contradiction, NULL otherwise // //if the current decision level is L in the beginning of the call, it should be updated //to L+1 so that the decision level of lit and all other literals implied by unit resolution is L+1 Clause* sat_decide_literal(Lit* lit, SatState* sat_state) { lit->implied = 1; vector_push(&sat_state->ds, lit); vector_push(&sat_state->s, lit); sat_literal_var(lit)->level = vector_size(&sat_state->ds) + 1; if (sat_unit_resolution(sat_state)) return NULL; return sat_state->ac; }
//sets the literal to true, and then runs unit resolution //returns a learned clause if unit resolution detected a contradiction, NULL otherwise // //if the current decision level is L in the beginning of the call, it should be updated //to L+1 so that the decision level of lit and all other literals implied by unit resolution is L+1 Clause* sat_decide_literal(Lit* lit, SatState* sat_state) { instantiate_literal(lit, ++sat_state->cur_level, NULL); sat_state->decided_literals[sat_state->num_decided_literals++] = lit; sat_state->unit_resolution_s = UNIT_RESOLUTION_AFTER_DECIDING_LITERAL; sat_unit_resolution(sat_state); return sat_state->asserted_clause; }
//adds clause to the set of learned clauses, and runs unit resolution //returns a learned clause if unit resolution finds a contradiction, NULL otherwise // //this function is called on a clause returned by sat_decide_literal() or sat_assert_clause() //moreover, it should be called only if sat_at_assertion_level() succeeds Clause* sat_assert_clause(Clause* clause, SatState* sat_state) { clause->index = sat_clause_count(sat_state) + sat_learned_clause_count(sat_state) + 1; for (c2dSize i = 0; i < sat_clause_size(clause); i++) { Lit* lit = vector_get(&clause->lits, i); Var* var = sat_literal_var(lit); if (vector_size(&var->mentions_lc) == 0 || vector_top(&var->mentions_lc) != clause) vector_push(&var->mentions_lc, clause); } vector_push(&sat_state->lc, clause); vector_push(&sat_state->q, clause); if (sat_unit_resolution(sat_state)) return NULL; return sat_state->ac; }
NnfManager* compile_vtree(VtreeManager* manager, SatState* sat_state) { NNF_NODE node; Clause* learned_clause = NULL; DVtree* vtree = manager->vtree; NnfManager* nnf_manager = nnf_manager_new(sat_state,UNIQUE_TABLE_CAPACITY); if(sat_unit_resolution(sat_state)) { //unit resolution succeeded compile_dispatcher(&node,&learned_clause,vtree,manager,nnf_manager,sat_state); if(learned_clause!=NULL) node = ZERO_NNF_NODE; //cnf is inconsistent } else node = ZERO_NNF_NODE; //cnf is inconsistent sat_undo_unit_resolution(sat_state); nnf_manager_set_root(node,nnf_manager); return nnf_manager; }
//adds clause to the set of learned clauses, and runs unit resolution //returns a learned clause if unit resolution finds a contradiction, NULL otherwise // //this function is called on a clause returned by sat_decide_literal() or sat_assert_clause() //moreover, it should be called only if sat_at_assertion_level() succeeds Clause* sat_assert_clause(Clause* clause, SatState* sat_state) { // Update the num_false and decision_level for (c2dSize i = 0; i < clause->size; i++) { if (clause->literals[i]->decision_level > 0) { if (clause->decision_level == 0 || clause->literals[i]->decision_level < clause->decision_level) clause->decision_level = clause->literals[i]->decision_level; } else if (clause->literals[i]->op_lit->decision_level > 0) { clause->num_false ++; } } // Push the clause to learned_clauses list and update the index clause_pointer_push(clause, &(sat_state->learned_clauses), &(sat_state->num_learned_clauses), &(sat_state->dyn_cap)); clause->index = sat_state->num_cnf_clauses + sat_state->num_learned_clauses; // Update the clauses mentioning list of the variables involing. push_clause_to_vars(clause); sat_state->unit_resolution_s = UNIT_RESOLUTION_AFTER_ASSERTING_CLAUSE; sat_unit_resolution(sat_state); return sat_state->asserted_clause; }