mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
move it into substitution to handle dependencies
This commit is contained in:
parent
3d7bd40a87
commit
9acbfa3923
5 changed files with 29 additions and 32 deletions
|
@ -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
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
z3_add_component(substitution
|
||||
SOURCES
|
||||
demodulator_rewriter.cpp
|
||||
matcher.cpp
|
||||
substitution.cpp
|
||||
substitution_tree.cpp
|
||||
|
|
|
@ -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),
|
||||
|
@ -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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue