Skip to content

Commit

Permalink
simplify some verbose trace-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Jul 11, 2021
1 parent bc2e6ce commit 5fac396
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
12 changes: 12 additions & 0 deletions src/smt/smt_theory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ namespace smt {
log_axiom_instantiation(mk_or(fmls));
}


void theory::log_axiom_instantiation(literal_buffer const& ls) {
ast_manager& m = get_manager();
expr_ref_vector fmls(m);
expr_ref tmp(m);
for (literal l : ls) {
ctx.literal2expr(l, tmp);
fmls.push_back(tmp);
}
log_axiom_instantiation(mk_or(fmls));
}

void theory::log_axiom_instantiation(app * r, unsigned axiom_id, unsigned num_bindings, app * const * bindings, unsigned pattern_id, const vector<std::tuple<enode *, enode *>> & used_enodes) {
ast_manager & m = get_manager();
app_ref _r(r, m);
Expand Down
8 changes: 8 additions & 0 deletions src/smt/smt_theory.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ namespace smt {
}
}

scoped_trace_stream(theory& th, literal_buffer const& lits) : m(th.get_manager()) {
if (m.has_trace_stream()) {
th.log_axiom_instantiation(lits);
}
}

scoped_trace_stream(theory& th, literal lit): m(th.get_manager()) {
if (m.has_trace_stream()) {
literal_vector lits;
Expand Down Expand Up @@ -464,6 +470,8 @@ namespace smt {

void log_axiom_instantiation(literal_vector const& ls);

void log_axiom_instantiation(literal_buffer const& ls);

void log_axiom_instantiation(app * r, unsigned num_blamed_enodes, enode ** blamed_enodes) {
vector<std::tuple<enode *, enode *>> used_enodes;
for (unsigned i = 0; i < num_blamed_enodes; ++i) {
Expand Down
25 changes: 7 additions & 18 deletions src/smt/theory_lra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,13 +1321,8 @@ class theory_lra::imp {
exprs.push_back(c.bool_var2expr(mod_j.var()));
ctx().mark_as_relevant(mod_j);
}
if (m.has_trace_stream()) {
app_ref body(m);
body = m.mk_or(exprs.size(), exprs.data());
th.log_axiom_instantiation(body);
}
scoped_trace_stream _st(th, lits);
ctx().mk_th_axiom(get_id(), lits.size(), lits.begin());
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
}
}

Expand Down Expand Up @@ -1750,20 +1745,14 @@ class theory_lra::imp {
literal p_ge_r1 = mk_literal(a.mk_ge(p, a.mk_numeral(lo, true)));
literal n_le_div = mk_literal(a.mk_le(n, a.mk_numeral(div_r, true)));
literal n_ge_div = mk_literal(a.mk_ge(n, a.mk_numeral(div_r, true)));
if (m.has_trace_stream()) {
app_ref body(m);
body = m.mk_implies(ctx().bool_var2expr(p_le_r1.var()), ctx().bool_var2expr(n_le_div.var()));
th.log_axiom_instantiation(body);
{
scoped_trace_stream _sts(th, ~p_le_r1, n_le_div);
mk_axiom(~p_le_r1, n_le_div);
}
mk_axiom(~p_le_r1, n_le_div);
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
if (m.has_trace_stream()) {
app_ref body(m);
body = m.mk_implies(ctx().bool_var2expr(p_ge_r1.var()), ctx().bool_var2expr(n_ge_div.var()));
th.log_axiom_instantiation(body);
{
scoped_trace_stream _sts(th, ~p_ge_r1, n_ge_div);
mk_axiom(~p_ge_r1, n_ge_div);
}
mk_axiom(~p_ge_r1, n_ge_div);
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";

all_divs_valid = false;

Expand Down

0 comments on commit 5fac396

Please sign in to comment.