Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Jul 31, 2021
1 parent e5401a4 commit 6a9241f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
14 changes: 14 additions & 0 deletions src/ast/ast_pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct mk_pp : public mk_ismt2_pp {
}
};


//<! print vector of ASTs
class mk_pp_vec {
ast_manager & m;
Expand All @@ -54,3 +55,16 @@ inline std::ostream& operator<<(std::ostream & out, mk_pp_vec const & pp) {
}


inline std::string operator+(char const* s, mk_pp const& pp) {
std::ostringstream strm;
strm << s << pp;
return strm.str();
}

inline std::string operator+(std::string const& s, mk_pp const& pp) {
std::ostringstream strm;
strm << s << pp;
return strm.str();
}


1 change: 0 additions & 1 deletion src/sat/sat_drat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ namespace sat {

unsigned len = 0;


if (st.is_deleted()) {
buffer[len++] = 'd';
buffer[len++] = ' ';
Expand Down
23 changes: 8 additions & 15 deletions src/sat/smt/euf_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,23 @@ namespace euf {
drat_log_decl(a->get_decl());
std::stringstream strm;
strm << mk_ismt2_func(a->get_decl(), m);
if (a->get_num_parameters() == 0)
get_drat().def_begin('e', e->get_id(), strm.str());
else {
get_drat().def_begin('e', e->get_id(), strm.str());
}
get_drat().def_begin('e', e->get_id(), strm.str());
for (expr* arg : *a)
get_drat().def_add_arg(arg->get_id());
get_drat().def_end();
}
else if (is_var(e)) {
var* v = to_var(e);
std::stringstream strm;
strm << mk_pp(e->get_sort(), m);
get_drat().def_begin('v', v->get_id(), strm.str());
get_drat().def_begin('v', v->get_id(), "" + mk_pp(e->get_sort(), m));
get_drat().def_add_arg(v->get_idx());
get_drat().def_end();
}
else if (is_quantifier(e)) {
quantifier* q = to_quantifier(e);
std::stringstream strm;
strm << "(";
strm << (is_forall(q) ? "forall" : (is_exists(q) ? "exists" : "lambda"));
for (unsigned i = 0; i < q->get_num_decls(); ++i) {
strm << " (" << q->get_decl_name(i) << " " << mk_pp(q->get_decl_sort(i), m) << ")";
}
std::stringstream strm;
strm << "(" << (is_forall(q) ? "forall" : (is_exists(q) ? "exists" : "lambda"));
for (unsigned i = 0; i < q->get_num_decls(); ++i)
strm << " (" << q->get_decl_name(i) << " " << mk_pp(q->get_decl_sort(i), m) << ")";
strm << ")";
get_drat().def_begin('q', q->get_id(), strm.str());
get_drat().def_add_arg(q->get_expr()->get_id());
Expand Down Expand Up @@ -88,7 +80,8 @@ namespace euf {
}
if (m_drat_todo.size() != sz)
continue;
drat_log_expr1(e);
if (!m_drat_asts.contains(e))
drat_log_expr1(e);
m_drat_todo.pop_back();
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/sat/tactic/goal2sat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,17 @@ struct goal2sat::imp : public sat::sat_internalizer {
}

void convert_iff(app * t, bool root, bool sign) {
if (t->get_num_args() != 2)
throw default_exception("unexpected number of arguments to xor");
if (t->get_num_args() != 2)
throw default_exception("unexpected number of arguments to " + mk_pp(t, m));
SASSERT(t->get_num_args() == 2);
unsigned sz = m_result_stack.size();
SASSERT(sz >= 2);
sat::literal l1 = m_result_stack[sz-1];
sat::literal l2 = m_result_stack[sz-2];
m_result_stack.shrink(sz - 2);
if (root) {
if (m.is_xor(t))
sign = !sign;
SASSERT(sz == 2);
if (sign) {
mk_root_clause(l1, l2);
Expand All @@ -616,17 +618,20 @@ struct goal2sat::imp : public sat::sat_internalizer {
else {
mk_root_clause(l1, ~l2);
mk_root_clause(~l1, l2);
}
}
}
else {
sat::bool_var k = add_var(false, t);
sat::literal l(k, false);
if (m.is_xor(t))
l1.neg();
mk_clause(~l, l1, ~l2);
mk_clause(~l, ~l1, l2);
mk_clause(l, l1, l2);
mk_clause(l, l1, l2);
mk_clause(l, ~l1, ~l2);
if (aig()) aig()->add_iff(l, l1, l2);
cache(t, m.is_xor(t) ? ~l : l);
if (aig()) aig()->add_iff(l, l1, l2);

cache(t, l);
if (sign)
l.neg();
m_result_stack.push_back(l);
Expand Down Expand Up @@ -720,7 +725,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
convert_iff(t, root, sign);
break;
case OP_XOR:
convert_iff(t, root, !sign);
convert_iff(t, root, sign);
break;
case OP_IMPLIES:
convert_implies(t, root, sign);
Expand Down Expand Up @@ -828,6 +833,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
process(n, false, redundant);
SASSERT(m_result_stack.size() == sz + 1);
sat::literal result = m_result_stack.back();
TRACE("goal2sat", tout << "done internalize " << result << " " << mk_bounded_pp(n, m, 2) << "\n";);
m_result_stack.pop_back();
if (!result.sign() && m_map.to_bool_var(n) == sat::null_bool_var) {
force_push();
Expand Down
13 changes: 9 additions & 4 deletions src/shell/drat_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@ class smt_checker {
m_input_solver->assert_expr(lit2expr(~lit));
lbool is_sat = m_input_solver->check_sat();
if (is_sat != l_false) {
std::cout << "did not verify: " << lits << "\n";
for (sat::literal lit : lits) {
std::cout << lit2expr(lit) << "\n";
}
std::cout << "did not verify: " << is_sat << " " << lits << "\n";
for (sat::literal lit : lits)
std::cout << lit2expr(lit) << "\n";
std::cout << "\n";
m_input_solver->display(std::cout);
if (is_sat == l_true) {
model_ref mdl;
m_input_solver->get_model(mdl);
std::cout << *mdl << "\n";
}

exit(0);
}
m_input_solver->pop(1);
Expand Down

0 comments on commit 6a9241f

Please sign in to comment.