Skip to content

Commit

Permalink
#4532 - arithmetic using SAT for interpreted atoms such as (< 0 0)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Jul 8, 2020
1 parent e1a0a2e commit ec3066c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/sat/tactic/goal2sat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct goal2sat::imp {
sat::bool_var v = m_solver.add_var(ext);
m_map.insert(t, v);
l = sat::literal(v, sign);
TRACE("sat", tout << "new_var: " << v << ": " << mk_bounded_pp(t, m, 2) << "\n";);
TRACE("sat", tout << "new_var: " << v << ": " << mk_bounded_pp(t, m, 2) << " " << is_uninterp_const(t) << "\n";);
if (!is_uninterp_const(t)) {
m_interpreted_atoms.push_back(t);
}
Expand Down Expand Up @@ -953,6 +953,11 @@ void goal2sat::get_interpreted_atoms(expr_ref_vector& atoms) {
}
}

bool goal2sat::has_interpreted_atoms() const {
return m_interpreted_atoms && !m_interpreted_atoms->empty();
}



sat2goal::mc::mc(ast_manager& m): m(m), m_var2expr(m) {}

Expand Down Expand Up @@ -982,7 +987,10 @@ void sat2goal::mc::flush_gmc() {
lit0.neg();
def = m.mk_not(def);
}
m_gmc->add(lit2expr(lit0), def);
expr_ref e = lit2expr(lit0);
expr* r = nullptr;
if (is_uninterp_const(e) || (m.is_not(e, r) && is_uninterp_const(r)))
m_gmc->add(e, def);
clause.reset();
tail.reset();
}
Expand Down Expand Up @@ -1199,7 +1207,7 @@ struct sat2goal::imp {
// collect units
unsigned trail_sz = s.init_trail_size();
for (unsigned i = 0; i < trail_sz; ++i) {
checkpoint();
checkpoint();
r.assert_expr(lit2expr(mc, s.trail_literal(i)));
}

Expand Down
2 changes: 2 additions & 0 deletions src/sat/tactic/goal2sat.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class goal2sat {

void get_interpreted_atoms(expr_ref_vector& atoms);

bool has_interpreted_atoms() const;

};


Expand Down
6 changes: 3 additions & 3 deletions src/sat/tactic/sat_tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class sat_tactic : public tactic {
obj_map<expr, sat::literal> dep2asm;
sat::literal_vector assumptions;
m_goal2sat(*g, m_params, *m_solver, map, dep2asm);
TRACE("sat_solver_unknown", tout << "interpreted_atoms: " << map.interpreted_atoms() << "\n";
TRACE("sat", tout << "interpreted_atoms: " << map.interpreted_atoms() << "\n";
for (auto const& kv : map) {
if (!is_uninterp_const(kv.m_key))
tout << mk_ismt2_pp(kv.m_key, m) << "\n";
Expand Down Expand Up @@ -112,8 +112,8 @@ class sat_tactic : public tactic {
ref<sat2goal::mc> mc;
m_sat2goal(*m_solver, map, m_params, *(g.get()), mc);
g->add(mc.get());
if (produce_core) {
// sat2goal does not preseve assumptions
if (produce_core || m_goal2sat.has_interpreted_atoms()) {
// sat2goal does not preseve assumptions or assignments to interpreted atoms
g->updt_prec(goal::OVER);
}
}
Expand Down

0 comments on commit ec3066c

Please sign in to comment.