Skip to content

Commit a17d4e6

Browse files
bugfix to elim_uncnstr to ensure nodes are created. Prepare smt_internalizer to replay unit literals
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 6ea4110 commit a17d4e6

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

src/ast/expr_substitution.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Module Name:
1919
#include "util/ref_util.h"
2020
#include "ast/expr_substitution.h"
2121
#include "ast/ast_pp.h"
22+
#include "ast/ast_ll_pp.h"
2223

2324
typedef obj_map<expr, proof*> expr2proof;
2425
typedef obj_map<expr, expr_dependency*> expr2expr_dependency;
@@ -58,8 +59,8 @@ expr_substitution::~expr_substitution() {
5859
}
5960

6061
std::ostream& expr_substitution::display(std::ostream& out) {
61-
for (auto & kv : m_subst) {
62-
out << mk_pp(kv.m_key, m()) << " |-> " << mk_pp(kv.m_value, m()) << "\n";
62+
for (auto & [k, v] : m_subst) {
63+
out << mk_bounded_pp(k, m()) << " |-> " << mk_bounded_pp(v, m()) << "\n";
6364
}
6465
return out;
6566
}

src/ast/simplifiers/elim_unconstrained.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ elim_unconstrained::~elim_unconstrained() {
131131
}
132132

133133
bool elim_unconstrained::is_var_lt(int v1, int v2) const {
134-
return get_node(v1).num_parents() < get_node(v2).num_parents();
134+
auto p1 = get_node(v1).num_parents();
135+
auto p2 = get_node(v2).num_parents();
136+
return p1 < p2;
135137
}
136138

137139
void elim_unconstrained::eliminate() {
@@ -287,8 +289,11 @@ void elim_unconstrained::init_nodes() {
287289

288290
for (expr* e : subterms_postorder::all(terms)) {
289291
SASSERT(get_node(e).is_root());
290-
if (is_uninterp_const(e))
292+
293+
if (is_uninterp_const(e)) {
294+
get_node(e); // ensure the node exists
291295
m_heap.insert(e->get_id());
296+
}
292297
}
293298

294299
// mark top level terms
@@ -390,7 +395,6 @@ void elim_unconstrained::update_model_trail(generic_model_converter& mc, vector<
390395
trail.hide(entry.m_f);
391396
break;
392397
case generic_model_converter::instruction::ADD:
393-
// trail.push(entry.m_f, entry.m_def, nullptr, old_fmls);
394398
break;
395399
}
396400
}

src/smt/smt_context.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2381,15 +2381,15 @@ namespace smt {
23812381
unsigned i = units_to_reassert_lim;
23822382
unsigned sz = m_units_to_reassert.size();
23832383
for (; i < sz; i++) {
2384-
auto& [unit, sign, is_relevant] = m_units_to_reassert[i];
2384+
auto [unit, sign, is_relevant] = m_units_to_reassert[i];
23852385
bool gate_ctx = true;
23862386
internalize(unit, gate_ctx);
23872387
bool_var v = get_bool_var(unit);
23882388
literal l(v, sign);
23892389
assign(l, b_justification::mk_axiom());
23902390
if (is_relevant)
23912391
mark_as_relevant(l);
2392-
TRACE("reassert_units", tout << "reasserting #" << unit->get_id() << " " << sign << " @ " << m_scope_lvl << "\n";);
2392+
TRACE("reassert_units", tout << "reasserting #" << unit->get_id() << " " << sign << " @ " << m_scope_lvl << "\n";);
23932393
}
23942394
if (at_base_level())
23952395
m_units_to_reassert.reset();

src/smt/smt_internalizer.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,7 @@ namespace smt {
13961396
DEBUG_CODE(for (literal lit : simp_lits) SASSERT(get_assignment(lit) == l_true););
13971397
if (!simp_lits.empty()) {
13981398
j = mk_justification(unit_resolution_justification(*this, j, simp_lits.size(), simp_lits.data()));
1399-
}
1400-
1399+
}
14011400
break;
14021401
}
14031402
case CLS_TH_LEMMA:
@@ -1423,6 +1422,7 @@ namespace smt {
14231422
unsigned activity = 1;
14241423
bool lemma = is_lemma(k);
14251424
m_stats.m_num_mk_lits += num_lits;
1425+
14261426
switch (num_lits) {
14271427
case 0:
14281428
if (j && !j->in_region())
@@ -1431,12 +1431,16 @@ namespace smt {
14311431
set_conflict(j == nullptr ? b_justification::mk_axiom() : b_justification(j));
14321432
SASSERT(inconsistent());
14331433
return nullptr;
1434-
case 1:
1434+
case 1: {
1435+
literal unit = lits[0];
1436+
expr* atom = m_bool_var2expr[unit.var()];
14351437
if (j && !j->in_region())
14361438
m_justifications.push_back(j);
1437-
assign(lits[0], j);
1438-
inc_ref(lits[0]);
1439+
assign(unit, j);
1440+
inc_ref(unit);
1441+
// m_units_to_reassert.push_back({ expr_ref(atom, m), unit.sign(), is_relevant(unit) });
14391442
return nullptr;
1443+
}
14401444
case 2:
14411445
if (use_binary_clause_opt(lits[0], lits[1], lemma)) {
14421446
literal l1 = lits[0];

0 commit comments

Comments
 (0)