Skip to content

Commit

Permalink
fix push/pop bug for ite-elimination, thanks to Nao Hirokawa for repo…
Browse files Browse the repository at this point in the history
…rting it

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Aug 30, 2019
1 parent de43e05 commit 4c0db00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/model/model_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Revision History:
--*/
#include "model/model_core.h"
#include "ast/ast_pp.h"

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

void model_core::register_decl(func_decl * d, expr * v) {
SASSERT(d->get_arity() == 0);
TRACE("model", tout << "register " << d->get_name() << "\n";);
TRACE("model", tout << "register " << d->get_name() << "\n";
if (v) tout << mk_pp(v, m) << "\n";
);
decl2expr::obj_map_entry * entry = m_interp.insert_if_not_there2(d, nullptr);
if (entry->get_data().m_value == nullptr) {
// new entry
Expand Down
2 changes: 2 additions & 0 deletions src/smt/asserted_formulas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ void asserted_formulas::push_scope() {
SASSERT(inconsistent() || s.m_formulas_lim == m_qhead || m.canceled());
s.m_inconsistent_old = m_inconsistent;
m_defined_names.push();
m_elim_term_ite.push();
m_bv_sharing.push_scope();
m_macro_manager.push_scope();
commit();
Expand All @@ -198,6 +199,7 @@ void asserted_formulas::pop_scope(unsigned num_scopes) {
scope & s = m_scopes[new_lvl];
m_inconsistent = s.m_inconsistent_old;
m_defined_names.pop(num_scopes);
m_elim_term_ite.pop(num_scopes);
m_scoped_substitution.pop(num_scopes);
m_formulas.shrink(s.m_formulas_lim);
m_qhead = s.m_formulas_lim;
Expand Down
2 changes: 2 additions & 0 deletions src/smt/asserted_formulas.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class asserted_formulas {
void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_elim(j.get_fml(), n, p); }
bool should_apply() const override { return af.m_smt_params.m_eliminate_term_ite && af.m_smt_params.m_lift_ite != LI_FULL; }
void post_op() override { af.m_formulas.append(m_elim.new_defs()); af.reduce_and_solve(); m_elim.reset(); }
void push() { m_elim.push(); }
void pop(unsigned n) { m_elim.pop(n); }
};

#define MK_SIMPLIFIERA(NAME, FUNCTOR, MSG, APP, ARG, REDUCE) \
Expand Down
7 changes: 5 additions & 2 deletions src/smt/elim_term_ite.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ class elim_term_ite_cfg : public default_rewriter_cfg {
ast_manager& m;
defined_names & m_defined_names;
vector<justified_expr> m_new_defs;
unsigned_vector m_lim;
public:
elim_term_ite_cfg(ast_manager & m, defined_names & d): m(m), m_defined_names(d) {
// TBD enable_ac_support(false);
}
virtual ~elim_term_ite_cfg() {}
vector<justified_expr> const& new_defs() const { return m_new_defs; }
void reset() { m_new_defs.reset(); }
br_status reduce_app(func_decl* f, unsigned n, expr *const* args, expr_ref& result, proof_ref& result_pr);
void push() { m_lim.push_back(m_new_defs.size()); }
void pop(unsigned n) {if (n > 0) { m_new_defs.shrink(m_lim[m_lim.size() - n]); m_lim.shrink(m_lim.size() - n); } }
};

class elim_term_ite_rw : public rewriter_tpl<elim_term_ite_cfg> {
Expand All @@ -45,7 +47,8 @@ class elim_term_ite_rw : public rewriter_tpl<elim_term_ite_cfg> {
m_cfg(m, dn)
{}
vector<justified_expr> const& new_defs() const { return m_cfg.new_defs(); }
void reset() { m_cfg.reset(); }
void push() { m_cfg.push(); }
void pop(unsigned n) { m_cfg.pop(n); }
};


Expand Down

0 comments on commit 4c0db00

Please sign in to comment.