Skip to content

Commit

Permalink
move it into substitution to handle dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Dec 4, 2022
1 parent 3d7bd40 commit 9acbfa3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/ast/rewriter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ z3_add_component(rewriter
cached_var_subst.cpp
char_rewriter.cpp
datatype_rewriter.cpp
demodulator_rewriter.cpp
der.cpp
distribute_forall.cpp
dl_rewriter.cpp
Expand Down
1 change: 1 addition & 0 deletions src/ast/substitution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
z3_add_component(substitution
SOURCES
demodulator_rewriter.cpp
matcher.cpp
substitution.cpp
substitution_tree.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Revision History:
#include "ast/ast_pp.h"
#include "ast/for_each_expr.h"
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/demodulator_rewriter.h"
#include "ast/substitution/demodulator_rewriter.h"

demodulator_rewriter::demodulator_rewriter(ast_manager & m):
m(m),
Expand Down Expand Up @@ -284,34 +284,31 @@ bool demodulator_rewriter::rewrite1(func_decl * f, expr_ref_vector const & args,
}

bool demodulator_rewriter::rewrite_visit_children(app * a) {
bool res=true;
unsigned j = a->get_num_args();
while (j > 0) {
expr * e = a->get_arg(--j);
if (!m_rewrite_cache.contains(e) || !m_rewrite_cache.get(e).second) {
bool recursive = false;
unsigned sz = m_rewrite_todo.size();
expr * v = e;
if (m_rewrite_cache.contains(e)) {
expr_bool_pair const & ebp = m_rewrite_cache.get(e);
if (ebp.second) {
v = ebp.first;
}
}
for (unsigned i = sz; i-- > 0;) {
if (m_rewrite_todo[i] == v) {
recursive = true;
TRACE("demodulator", tout << "Detected demodulator cycle: " <<
mk_pp(a, m) << " --> " << mk_pp(v, m) << std::endl;);
rewrite_cache(e, v, true);
break;
}
}
if (!recursive) {
m_rewrite_todo.push_back(e);
res = false;
bool res = true;
for (expr* e : *a) {
if (m_rewrite_cache.contains(e) && m_rewrite_cache.get(e).second)
continue;
bool recursive = false;
unsigned sz = m_rewrite_todo.size();
expr * v = e;
if (m_rewrite_cache.contains(e)) {
expr_bool_pair const & ebp = m_rewrite_cache.get(e);
if (ebp.second)
v = ebp.first;
}
for (unsigned i = sz; i-- > 0;) {
if (m_rewrite_todo[i] == v) {
recursive = true;
TRACE("demodulator", tout << "Detected demodulator cycle: " <<
mk_pp(a, m) << " --> " << mk_pp(v, m) << std::endl;);
rewrite_cache(e, v, true);
break;
}
}
if (!recursive) {
m_rewrite_todo.push_back(e);
res = false;
}
}
return res;
}
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/tactic/ufbv/ufbv_rewriter_tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Module Name:
--*/
#include "tactic/tactical.h"
#include "ast/rewriter/demodulator_rewriter.h"
#include "ast/substitution/demodulator_rewriter.h"
#include "tactic/ufbv/ufbv_rewriter_tactic.h"

class demodulator_rewriter_tactic : public tactic {
Expand All @@ -28,7 +28,7 @@ class demodulator_rewriter_tactic : public tactic {
demodulator_rewriter_tactic(ast_manager & m, params_ref const & p):
m_manager(m), m_params(p) {}

char const* name() const override { return "ufbv"; }
char const* name() const override { return "ufbv-rewriter"; }

tactic * translate(ast_manager & m) override {
return alloc(demodulator_rewriter_tactic, m, m_params);
Expand Down Expand Up @@ -63,8 +63,8 @@ class demodulator_rewriter_tactic : public tactic {
dem(forms, new_forms);

g->reset();
for (unsigned i = 0; i < new_forms.size(); i++)
g->assert_expr(new_forms.get(i), nullptr, nullptr);
for (expr* fml : new_forms)
g->assert_expr(fml, nullptr, nullptr);

// CMW: Remark: The demodulator could potentially
// remove all references to a variable.
Expand Down

0 comments on commit 9acbfa3

Please sign in to comment.