Skip to content

Commit 253f7d7

Browse files
fix non-termination bug in elim-unconstrained, add parameter validation to fix #7432
1 parent d18831c commit 253f7d7

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/ast/simplifiers/elim_unconstrained.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void elim_unconstrained::eliminate() {
8686
continue;
8787
}
8888
if (m_heap.contains(root(e))) {
89-
IF_VERBOSE(11, verbose_stream() << "already in heap " << mk_bounded_pp(e, m) << "\n");
89+
TRACE("elim_unconstrained", tout << "already in heap " << mk_bounded_pp(e, m) << "\n");
9090
continue;
9191
}
9292
app* t = to_app(e);
@@ -111,9 +111,9 @@ void elim_unconstrained::eliminate() {
111111
continue;
112112
}
113113

114-
IF_VERBOSE(11, verbose_stream() << "replace " << mk_pp(t, m) << " : " << rr << " -> " << r << "\n");
114+
IF_VERBOSE(11, verbose_stream() << "replace " << mk_pp(t, m) << " / " << rr << " -> " << r << "\n");
115115

116-
TRACE("elim_unconstrained", tout << mk_pp(t, m) << " : " << rr << " -> " << r << "\n");
116+
TRACE("elim_unconstrained", tout << mk_pp(t, m) << " / " << rr << " -> " << r << "\n");
117117
SASSERT(r->get_sort() == t->get_sort());
118118
m_stats.m_num_eliminated++;
119119
m_trail.push_back(r);
@@ -147,10 +147,10 @@ expr* elim_unconstrained::get_parent(unsigned n) const {
147147
}
148148

149149
void elim_unconstrained::invalidate_parents(expr* e) {
150-
ptr_vector<expr> todo;
150+
ptr_buffer<expr> todo;
151151
do {
152152
node& n = get_node(e);
153-
if (!n.m_dirty) {
153+
if (!n.m_dirty && e == n.m_term) {
154154
n.m_dirty = true;
155155
for (expr* e : n.m_parents)
156156
todo.push_back(e);
@@ -299,7 +299,7 @@ expr_ref elim_unconstrained::reconstruct_term(node& n0) {
299299
return expr_ref(t, m);
300300
if (!is_node(t))
301301
return expr_ref(t, m);
302-
ptr_vector<expr> todo;
302+
ptr_buffer<expr> todo;
303303
todo.push_back(t);
304304
while (!todo.empty()) {
305305
t = todo.back();
@@ -310,6 +310,7 @@ expr_ref elim_unconstrained::reconstruct_term(node& n0) {
310310
unsigned sz0 = todo.size();
311311
if (is_app(t)) {
312312
if (n.m_term != t) {
313+
n.m_dirty = false;
313314
todo.pop_back();
314315
continue;
315316
}

src/cmd_context/pdecl.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ class psort_app : public psort {
225225
sort * a = m_args[i]->instantiate(m, n, s);
226226
args_i.push_back(a);
227227
}
228-
r = m_decl->instantiate(m, args_i.size(), args_i.data());
228+
r = m_decl->instantiate(m, args_i.size(), args_i.data());
229+
if (m_num_params != n)
230+
throw default_exception("mismatch between number of declared and supplied sort parameters");
229231
cache(m, s, r);
230232
return r;
231233
}
@@ -771,6 +773,8 @@ bool pdatatypes_decl::commit(pdecl_manager& m) {
771773
for (unsigned i = 0; i < d->get_num_params(); ++i) {
772774
ps.push_back(m.m().mk_uninterpreted_sort(symbol(i), 0, nullptr));
773775
}
776+
verbose_stream() << ps.size() << " " << ps << "\n";
777+
774778
dts.m_buffer.push_back(d->instantiate_decl(m, ps.size(), ps.data()));
775779
}
776780
sort_ref_vector sorts(m.m());

src/sat/sat_ddfw.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ namespace sat {
262262
m_assumptions.append(sz, assumptions);
263263
add_assumptions();
264264
for (unsigned v = 0; v < num_vars(); ++v) {
265-
literal lit(v, false), nlit(v, true);
266265
value(v) = (m_rand() % 2) == 0; // m_use_list[lit.index()].size() >= m_use_list[nlit.index()].size();
267266
}
268267
init_clause_data();

0 commit comments

Comments
 (0)