From ec3066c28a6a4650d228e55ff841c70d7386b884 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 7 Jul 2020 23:06:12 -0700 Subject: [PATCH] #4532 - arithmetic using SAT for interpreted atoms such as (< 0 0) Signed-off-by: Nikolaj Bjorner --- src/sat/tactic/goal2sat.cpp | 14 +++++++++++--- src/sat/tactic/goal2sat.h | 2 ++ src/sat/tactic/sat_tactic.cpp | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index 1662c9bcdc5..0255fcf501c 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -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); } @@ -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) {} @@ -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(); } @@ -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))); } diff --git a/src/sat/tactic/goal2sat.h b/src/sat/tactic/goal2sat.h index a226ed2ef27..a1ea6a78e34 100644 --- a/src/sat/tactic/goal2sat.h +++ b/src/sat/tactic/goal2sat.h @@ -65,6 +65,8 @@ class goal2sat { void get_interpreted_atoms(expr_ref_vector& atoms); + bool has_interpreted_atoms() const; + }; diff --git a/src/sat/tactic/sat_tactic.cpp b/src/sat/tactic/sat_tactic.cpp index dc90317be3b..be1cfec94ca 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -50,7 +50,7 @@ class sat_tactic : public tactic { obj_map 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"; @@ -112,8 +112,8 @@ class sat_tactic : public tactic { ref 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); } }