void process_initial_clause(Mclause c, Mstate state) { process_clause(c, state); /* handles empty clause and nonsubsumed units */ if (state->ok && state->first_job != NULL) propagate(state); /* Process_clause pushed a job, so we propagate it. */ } /* process_initial_clause */
void z3_propt::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; if (new_bv.size()==0) return; Z3_ast lor_var, args[new_bv.size()]; unsigned int i=0; for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++, i++) args[i] = z3_literal(*it); if (i>1) { lor_var = Z3_mk_or(z3_ctx, i, args); Z3_assert_cnstr(z3_ctx, lor_var); } else { Z3_assert_cnstr(z3_ctx, args[0]); } }
void boolector_propt::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; BtorExp *lor_var, *args[new_bv.size()]; unsigned int i=0, j=0; for(bvt::const_iterator it=new_bv.begin(); it!=new_bv.end(); it++, i++) args[i] = boolector_literal(*it); if (i>1) { lor_var = boolector_or(boolector_ctx, args[0], args[1]); for(j=2; j<i; j++) lor_var = boolector_or(boolector_ctx, args[j], lor_var); boolector_assert(boolector_ctx, lor_var); } else if (i==1) { boolector_assert(boolector_ctx, args[0]); } }
void qbf_squolem_coret::lcnf(const bvt &bv) { if(early_decision) return; // we don't need no more... bvt new_bv; if(process_clause(bv, new_bv)) return; if(new_bv.empty()) { early_decision=true; return; } std::vector<Literal> buffer(new_bv.size()); unsigned long i=0; do { buffer[i]=new_bv[i].dimacs(); i++; } while (i<new_bv.size()); if(!squolem->addClause(buffer)) early_decision=true; }
void satcheck_minisat1_baset::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; // Minisat can't do empty clauses if(new_bv.empty()) { empty_clause_added=true; return; } add_variables(); vec<Lit> c; convert(new_bv, c); for(unsigned i=0; i<new_bv.size(); i++) assert(new_bv[i].var_no()<(unsigned)solver->nVars()); solver->addClause(c); clause_counter++; }
void cnf_clause_listt::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; clauses.push_back(new_bv); }
void satcheck_precosatt::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; forall_literals(it, new_bv) solver->add(precosat_lit(*it)); solver->add(0); clause_counter++; }
void satcheck_lingelingt::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; forall_literals(it, new_bv) lgladd(solver, it->dimacs()); lgladd(solver, 0); clause_counter++; }
void satcheck_booleforce_baset::lcnf(const bvt &bv) { bvt tmp; if(process_clause(bv, tmp)) return; for(unsigned j=0; j<tmp.size(); j++) booleforce_add(tmp[j].dimacs()); // zero-terminated booleforce_add(0); clause_counter++; }
UniversalInstantiator::UniversalInstantiator(CNode* node, bool * success) { cur_varindex = 0; new_conn = process_clause(node); if(new_conn == NULL) { error(); return; } this->success = success; if(this->success != NULL) *this->success = true; /*assert(node->get_type() == OR); cur_varindex = 0; Connective *outer = (Connective*) node; const set<CNode*> & elems = outer->get_operands(); set<CNode*> operands; set<CNode*>::iterator it = elems.begin(); for(; it!= elems.end(); it++){ CNode* cur = process_clause(*it); if(cur == NULL) { error(); new_conn = NULL; return; } operands.insert(cur); } new_conn = Connective::make_or(operands); this->success = success; if(this->success != NULL) *this->success = true;*/ if(DEBUG) { cout << "***Final instantiated constraint****" << endl; cout << new_conn->to_string() << endl; } }
void satcheck_smvsatt::lcnf(const bvt &bv) { bvt tmp; if(process_clause(bv, tmp)) return; int lits[tmp.size()+1]; for(unsigned i=0; i<tmp.size(); i++) lits[i]=tmp[i].dimacs(); // zero-terminated lits[tmp.size()]=0; sat_instance_add_clause(satsolver, lits); clause_counter++; }
void qbf_bdd_coret::lcnf(const bvt &bv) { bvt new_bv; if(process_clause(bv, new_bv)) return; BDD clause(bdd_manager->bddZero()); for(unsigned long i=0; i<new_bv.size(); i++) { literalt l=new_bv[i]; BDD v(*bdd_variable_map[l.var_no()]); if(l.sign()) v = ~v; clause |= v; } *matrix &= clause; }
void satcheck_smvsat_interpolatort::lcnf(const bvt &bv) { bvt tmp; if(process_clause(bv, tmp)) return; int lits[tmp.size()+1]; for(unsigned i=0; i<tmp.size(); i++) lits[i]=tmp[i].dimacs(); // zero-terminated lits[tmp.size()]=0; unsigned clause_id=sat_instance_add_clause(satsolver, lits); if(partition_numbers.size()<=clause_id) partition_numbers.resize(clause_id+1, -1); partition_numbers[clause_id]=partition_no; }
static void propagate_positive(int id, Mstate state) { Term t; #if 0 printf("propagage_positive: "); p_term(Cells[id].eterm); #endif for (t = Cells[id].occurrences; t != NULL; t = t->u.vp) { /* foreach term the rule applies to */ Term curr = t; Mclause clause_to_process; BOOL index_it; /* The following loop iterates up toward the root of the clause, rewriting terms. We stop when we get to a literal, an eterm that cannot be rewritten (we then index the eterm in this case), or when we get to a non-eterm. */ #if 0 printf("rewriting: "); p_mclause(containing_mclause(curr)); #endif while (!LITERAL(curr) && /* stop if literal */ !arith_op_term(curr) && /* stop if arithmetic term */ eterm(curr, &id) && /* stop if not eterm */ Cells[id].value != NULL) { /* stop if eterm not evaluable*/ Term result = Cells[id].value; Term parent = curr->container; int pos = arg_position(parent, curr); state->stack = update_and_push((void **) &(ARG(parent,pos)), result, state->stack); Mstats.rewrite_terms++; curr = parent; } /* while rewriting upward */ #if 0 printf("done: "); p_mclause(containing_mclause(curr)); #endif clause_to_process = NULL; /* set to possible new rule */ index_it = FALSE; /* should curr be indexed? */ if (arith_rel_term(curr) || arith_op_term(curr)) { Term parent_lit = containing_mliteral(curr); Mclause parent_clause = parent_lit->container; if (!parent_clause->subsumed) { BOOL evaluated; int b = arith_eval(parent_lit, &evaluated); if (evaluated) { Term result; if (b != 0 && b != 1) fatal_error("propagate_positive, arith_eval should be Boolean"); result = (b ? Domain[1] : Domain[0]); clause_to_process = handle_literal(parent_lit, result, state); } else if (EQ_TERM(curr)) clause_to_process = parent_clause; } } else if (!LITERAL(curr)) { /* curr is a term */ Term parent = curr->container; if (id != -1) index_it = TRUE; /* curr is a non-evaluable eterm */ /* If curr is 1 or 2 steps away from a literal, process it. */ if (LITERAL(parent)) clause_to_process = parent->container; else { parent = parent->container; if (LITERAL(parent)) clause_to_process = parent->container; } } else { /* curr is a literal (equality or nonquality, positive or negative) */ Mclause parent_clause = curr->container; if (!eterm(curr, &id)) /* non-eterm literal */ clause_to_process = parent_clause; else if (Cells[id].value == NULL) { /* non-evaluable eterm literal */ index_it = TRUE; clause_to_process = parent_clause; } else if (!parent_clause->subsumed) { clause_to_process = handle_literal(curr, Cells[id].value, state); } } /* literal */ if (index_it) { /* curr is an evaluable term or literal, e.g., f(1,2), but there is no rule for it. Therefore, we index it so that it can be found in case a rule appears later. */ Mstats.indexes++; state->stack = update_and_push((void **) &(curr->u.vp), Cells[id].occurrences, state->stack); state->stack = update_and_push((void **) &(Cells[id].occurrences), curr, state->stack); } if (clause_to_process != NULL) { process_clause(clause_to_process, state); if (!state->ok) return; } } /* foreach occurrence (container) of the cell just assigned */ } /* propagate_positive */