3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-11 13:40:52 +00:00
This commit is contained in:
Nikolaj Bjorner 2021-06-16 19:12:50 -05:00
parent 3311bd074f
commit df9084ba23
3 changed files with 19 additions and 8 deletions

View file

@ -17,6 +17,7 @@ Notes:
--*/
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "ast/ast_ll_pp.h"
#include "ast/ast_pp.h"
#include "ast/ast_smt2_pp.h"
@ -24,7 +25,8 @@ Notes:
#include "ast/for_each_expr.h"
expr_ref var_subst::operator()(expr * n, unsigned num_args, expr * const * args) {
expr_ref result(m_reducer.m());
ast_manager& m = m_reducer.m();
expr_ref result(m);
if (is_ground(n) || num_args == 0) {
result = n;
//application does not have free variables or nested quantifiers.
@ -40,6 +42,13 @@ expr_ref var_subst::operator()(expr * n, unsigned num_args, expr * const * args)
return result;
}
if (has_quantifiers(n)) {
expr_safe_replace rep(m);
for (unsigned k = 0; k < num_args; ++k)
rep.insert(m.mk_var(m_std_order ? num_args - k - 1 : k, args[k]->get_sort()), args[k]);
rep(n, result);
return result;
}
SASSERT(is_well_sorted(result.m(), n));
m_reducer.reset();
if (m_std_order)
@ -47,10 +56,10 @@ expr_ref var_subst::operator()(expr * n, unsigned num_args, expr * const * args)
else
m_reducer.set_bindings(num_args, args);
m_reducer(n, result);
SASSERT(is_well_sorted(m_reducer.m(), result));
SASSERT(is_well_sorted(m, result));
TRACE("var_subst_bug",
tout << "m_std_order: " << m_std_order << "\n" << mk_ismt2_pp(n, m_reducer.m()) << "\nusing\n";
for (unsigned i = 0; i < num_args; i++) tout << mk_ismt2_pp(args[i], m_reducer.m()) << "\n";
tout << "m_std_order: " << m_std_order << "\n" << mk_ismt2_pp(n, m) << "\nusing\n";
for (unsigned i = 0; i < num_args; i++) tout << mk_ismt2_pp(args[i], m) << "\n";
tout << "\n------>\n";
tout << result << "\n";);
return result;