3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 01:24:08 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-05-11 16:53:59 -07:00
parent 754bafc95e
commit 884a68251b
6 changed files with 27 additions and 15 deletions

View file

@ -1824,6 +1824,9 @@ ast * ast_manager::register_node_core(ast * n) {
n->m_id = is_decl(n) ? m_decl_id_gen.mk() : m_expr_id_gen.mk(); n->m_id = is_decl(n) ? m_decl_id_gen.mk() : m_expr_id_gen.mk();
if (n->m_id == 28 && is_lambda(n)) {
// SASSERT(false);
}
// track_id(*this, n, 254); // track_id(*this, n, 254);
TRACE("ast", tout << "Object " << n->m_id << " was created.\n";); TRACE("ast", tout << "Object " << n->m_id << " was created.\n";);

View file

@ -19,6 +19,7 @@ Notes:
#include "ast/rewriter/rewriter.h" #include "ast/rewriter/rewriter.h"
#include "ast/ast_smt2_pp.h" #include "ast/ast_smt2_pp.h"
#include "ast/ast_ll_pp.h" #include "ast/ast_ll_pp.h"
#include "ast/ast_pp.h"
template<typename Config> template<typename Config>
template<bool ProofGen> template<bool ProofGen>
@ -80,7 +81,6 @@ bool rewriter_tpl<Config>::process_const(app * t0) {
retry: retry:
SASSERT(t->get_num_args() == 0); SASSERT(t->get_num_args() == 0);
br_status st = m_cfg.reduce_app(t->get_decl(), 0, nullptr, m_r, m_pr); br_status st = m_cfg.reduce_app(t->get_decl(), 0, nullptr, m_r, m_pr);
SASSERT(st != BR_DONE || m().get_sort(m_r) == m().get_sort(t));
TRACE("reduce_app", TRACE("reduce_app",
tout << "t0:" << mk_bounded_pp(t0, m()) << "\n"; tout << "t0:" << mk_bounded_pp(t0, m()) << "\n";
if (t != t0) tout << "t: " << mk_bounded_pp(t, m()) << "\n"; if (t != t0) tout << "t: " << mk_bounded_pp(t, m()) << "\n";
@ -89,6 +89,11 @@ bool rewriter_tpl<Config>::process_const(app * t0) {
tout << "\n"; tout << "\n";
if (m_pr) tout << mk_bounded_pp(m_pr, m()) << "\n"; if (m_pr) tout << mk_bounded_pp(m_pr, m()) << "\n";
); );
CTRACE("reduce_app",
st != BR_FAILED && m().get_sort(m_r) != m().get_sort(t),
tout << mk_pp(m().get_sort(t), m()) << ": " << mk_pp(t, m()) << "\n";
tout << m_r->get_id() << " " << mk_pp(m().get_sort(m_r), m()) << ": " << m_r << "\n";);
SASSERT(st != BR_DONE || m().get_sort(m_r) == m().get_sort(t));
switch (st) { switch (st) {
case BR_FAILED: case BR_FAILED:
if (!retried) { if (!retried) {

View file

@ -357,14 +357,14 @@ expr * func_interp::get_interp_core() const {
return r; return r;
} }
expr* func_interp::get_array_interp_core(func_decl * f) const { expr_ref func_interp::get_array_interp_core_(func_decl * f) const {
if (m_else == nullptr) if (m_else == nullptr)
return nullptr; return expr_ref(m_manager);
ptr_vector<sort> domain; ptr_vector<sort> domain;
for (sort* s : *f) { for (sort* s : *f) {
domain.push_back(s); domain.push_back(s);
} }
expr* r; expr_ref r(m_manager);
bool ground = is_ground(m_else); bool ground = is_ground(m_else);
for (func_entry * curr : m_entries) { for (func_entry * curr : m_entries) {
@ -376,13 +376,17 @@ expr* func_interp::get_array_interp_core(func_decl * f) const {
if (!ground) { if (!ground) {
r = get_interp(); r = get_interp();
if (!r) return r; if (!r) return r;
sort_ref_vector vars(m_manager); sort_ref_vector sorts(m_manager);
expr_ref_vector vars(m_manager);
svector<symbol> var_names; svector<symbol> var_names;
var_subst sub(m_manager, false);
for (unsigned i = 0; i < m_arity; ++i) { for (unsigned i = 0; i < m_arity; ++i) {
var_names.push_back(symbol(i)); var_names.push_back(symbol(i));
vars.push_back(domain.get(m_arity - i - 1)); sorts.push_back(domain.get(i));
vars.push_back(m_manager.mk_var(m_arity - i - 1, sorts.back()));
} }
r = m_manager.mk_lambda(vars.size(), vars.c_ptr(), var_names.c_ptr(), r); r = sub(r, vars);
r = m_manager.mk_lambda(sorts.size(), sorts.c_ptr(), var_names.c_ptr(), r);
return r; return r;
} }
@ -419,11 +423,11 @@ expr * func_interp::get_interp() const {
return r; return r;
} }
expr * func_interp::get_array_interp(func_decl * f) const { expr_ref func_interp::get_array_interp_(func_decl * f) const {
if (m_array_interp != nullptr) if (m_array_interp != nullptr)
return m_array_interp; return expr_ref(m_array_interp, m_manager);
expr* r = get_array_interp_core(f); expr_ref r = get_array_interp_core_(f);
if (r != nullptr) { if (r) {
const_cast<func_interp*>(this)->m_array_interp = r; const_cast<func_interp*>(this)->m_array_interp = r;
m_manager.inc_ref(m_array_interp); m_manager.inc_ref(m_array_interp);
} }

View file

@ -79,7 +79,7 @@ class func_interp {
expr * get_interp_core() const; expr * get_interp_core() const;
expr * get_array_interp_core(func_decl * f) const; expr_ref get_array_interp_core_(func_decl * f) const;
public: public:
func_interp(ast_manager & m, unsigned arity); func_interp(ast_manager & m, unsigned arity);
@ -116,7 +116,7 @@ public:
expr * get_interp() const; expr * get_interp() const;
expr * get_array_interp(func_decl* f) const; expr_ref get_array_interp_(func_decl* f) const;
func_interp * translate(ast_translation & translator) const; func_interp * translate(ast_translation & translator) const;

View file

@ -448,7 +448,7 @@ expr_ref model::cleanup_expr(top_sort& ts, expr* e, unsigned current_partition)
// only expand auxiliary definitions that occur once. // only expand auxiliary definitions that occur once.
if (can_inline_def(ts, f)) { if (can_inline_def(ts, f)) {
fi = get_func_interp(f); fi = get_func_interp(f);
new_t = fi->get_array_interp(f); new_t = fi->get_array_interp_(f);
TRACE("model", tout << "array interpretation:" << new_t << "\n";); TRACE("model", tout << "array interpretation:" << new_t << "\n";);
} }
} }

View file

@ -253,7 +253,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
return BR_DONE; return BR_DONE;
} }
func_interp * fi = m_model.get_func_interp(g); func_interp * fi = m_model.get_func_interp(g);
if (fi && (result = fi->get_array_interp(g))) { if (fi && (result = fi->get_array_interp_(g))) {
model_evaluator ev(m_model, m_params); model_evaluator ev(m_model, m_params);
result = ev(result); result = ev(result);
m_pinned.push_back(result); m_pinned.push_back(result);