Skip to content

Commit 4c0db00

Browse files
fix push/pop bug for ite-elimination, thanks to Nao Hirokawa for reporting it
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent de43e05 commit 4c0db00

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

src/model/model_core.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Revision History:
1717
1818
--*/
1919
#include "model/model_core.h"
20+
#include "ast/ast_pp.h"
2021

2122
model_core::~model_core() {
2223
for (auto & kv : m_interp) {
@@ -47,7 +48,9 @@ bool model_core::eval(func_decl* f, expr_ref & r) const {
4748

4849
void model_core::register_decl(func_decl * d, expr * v) {
4950
SASSERT(d->get_arity() == 0);
50-
TRACE("model", tout << "register " << d->get_name() << "\n";);
51+
TRACE("model", tout << "register " << d->get_name() << "\n";
52+
if (v) tout << mk_pp(v, m) << "\n";
53+
);
5154
decl2expr::obj_map_entry * entry = m_interp.insert_if_not_there2(d, nullptr);
5255
if (entry->get_data().m_value == nullptr) {
5356
// new entry

src/smt/asserted_formulas.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ void asserted_formulas::push_scope() {
184184
SASSERT(inconsistent() || s.m_formulas_lim == m_qhead || m.canceled());
185185
s.m_inconsistent_old = m_inconsistent;
186186
m_defined_names.push();
187+
m_elim_term_ite.push();
187188
m_bv_sharing.push_scope();
188189
m_macro_manager.push_scope();
189190
commit();
@@ -198,6 +199,7 @@ void asserted_formulas::pop_scope(unsigned num_scopes) {
198199
scope & s = m_scopes[new_lvl];
199200
m_inconsistent = s.m_inconsistent_old;
200201
m_defined_names.pop(num_scopes);
202+
m_elim_term_ite.pop(num_scopes);
201203
m_scoped_substitution.pop(num_scopes);
202204
m_formulas.shrink(s.m_formulas_lim);
203205
m_qhead = s.m_formulas_lim;

src/smt/asserted_formulas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ class asserted_formulas {
156156
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_elim(j.get_fml(), n, p); }
157157
bool should_apply() const override { return af.m_smt_params.m_eliminate_term_ite && af.m_smt_params.m_lift_ite != LI_FULL; }
158158
void post_op() override { af.m_formulas.append(m_elim.new_defs()); af.reduce_and_solve(); m_elim.reset(); }
159+
void push() { m_elim.push(); }
160+
void pop(unsigned n) { m_elim.pop(n); }
159161
};
160162

161163
#define MK_SIMPLIFIERA(NAME, FUNCTOR, MSG, APP, ARG, REDUCE) \

src/smt/elim_term_ite.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ class elim_term_ite_cfg : public default_rewriter_cfg {
2727
ast_manager& m;
2828
defined_names & m_defined_names;
2929
vector<justified_expr> m_new_defs;
30+
unsigned_vector m_lim;
3031
public:
3132
elim_term_ite_cfg(ast_manager & m, defined_names & d): m(m), m_defined_names(d) {
3233
// TBD enable_ac_support(false);
3334
}
3435
virtual ~elim_term_ite_cfg() {}
3536
vector<justified_expr> const& new_defs() const { return m_new_defs; }
36-
void reset() { m_new_defs.reset(); }
3737
br_status reduce_app(func_decl* f, unsigned n, expr *const* args, expr_ref& result, proof_ref& result_pr);
38+
void push() { m_lim.push_back(m_new_defs.size()); }
39+
void pop(unsigned n) {if (n > 0) { m_new_defs.shrink(m_lim[m_lim.size() - n]); m_lim.shrink(m_lim.size() - n); } }
3840
};
3941

4042
class elim_term_ite_rw : public rewriter_tpl<elim_term_ite_cfg> {
@@ -45,7 +47,8 @@ class elim_term_ite_rw : public rewriter_tpl<elim_term_ite_cfg> {
4547
m_cfg(m, dn)
4648
{}
4749
vector<justified_expr> const& new_defs() const { return m_cfg.new_defs(); }
48-
void reset() { m_cfg.reset(); }
50+
void push() { m_cfg.push(); }
51+
void pop(unsigned n) { m_cfg.pop(n); }
4952
};
5053

5154

0 commit comments

Comments
 (0)