Skip to content

Commit 8d4e7fa

Browse files
add diagnostics option to new arithmetic solver
1 parent 839b710 commit 8d4e7fa

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/sat/smt/arith_diagnostics.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Module Name:
1515
1616
--*/
1717

18+
#include "util/cancel_eh.h"
19+
#include "util/scoped_timer.h"
1820
#include "ast/ast_util.h"
1921
#include "ast/scoped_proof.h"
2022
#include "sat/smt/euf_solver.h"
@@ -242,4 +244,21 @@ namespace arith {
242244

243245
return m.mk_app(symbol(name), args.size(), args.data(), m.mk_proof_sort());
244246
}
247+
248+
bool solver::validate_conflict() {
249+
scoped_ptr<::solver> vs = mk_smt2_solver(m, ctx.s().params(), symbol::null);
250+
for (auto lit : m_core)
251+
vs->assert_expr(ctx.literal2expr(lit));
252+
253+
for (auto [a, b] : m_eqs)
254+
vs->assert_expr(m.mk_eq(a->get_expr(), b->get_expr()));
255+
256+
cancel_eh<reslimit> eh(m.limit());
257+
scoped_timer timer(1000, &eh);
258+
bool result = l_true != vs->check_sat();
259+
CTRACE("arith", !result, vs->display(tout));
260+
CTRACE("arith", !result, s().display(tout));
261+
SASSERT(result);
262+
return result;
263+
}
245264
}

src/sat/smt/arith_internalize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ namespace arith {
472472
bool _has_var = has_var(t);
473473
mk_enode(t);
474474
theory_var v = mk_evar(t);
475-
475+
476476
if (!_has_var) {
477477
svector<lpvar> vars;
478478
for (expr* n : *t) {

src/sat/smt/arith_solver.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,9 @@ namespace arith {
12511251
for (literal c : m_core) tout << c << ": " << literal2expr(c) << "\n";
12521252
for (auto p : m_eqs) tout << ctx.bpp(p.first) << " == " << ctx.bpp(p.second) << "\n";);
12531253

1254+
if (ctx.get_config().m_arith_validate)
1255+
VERIFY(validate_conflict());
1256+
12541257
if (is_conflict) {
12551258
DEBUG_CODE(
12561259
for (literal c : m_core) VERIFY(s().value(c) == l_true);

src/sat/smt/arith_solver.h

+1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ namespace arith {
483483
arith_proof_hint const* explain_conflict(hint_type ty, sat::literal_vector const& core, euf::enode_pair_vector const& eqs);
484484
void explain_assumptions(lp::explanation const& e);
485485

486+
bool validate_conflict();
486487

487488
public:
488489
solver(euf::solver& ctx, theory_id id);

0 commit comments

Comments
 (0)