mirror of
https://github.com/Z3Prover/z3
synced 2025-06-19 20:33:38 +00:00
fix #6807
This commit is contained in:
parent
3e58f0cff1
commit
d0d434e4f1
4 changed files with 29 additions and 24 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "ast/bv_decl_plugin.h"
|
#include "ast/bv_decl_plugin.h"
|
||||||
#include "ast/array_decl_plugin.h"
|
#include "ast/array_decl_plugin.h"
|
||||||
|
#include "ast/ast_ll_pp.h"
|
||||||
|
|
||||||
class ackr_helper {
|
class ackr_helper {
|
||||||
public:
|
public:
|
||||||
|
@ -40,11 +41,9 @@ public:
|
||||||
inline bool is_uninterp_fn(app const * a) const {
|
inline bool is_uninterp_fn(app const * a) const {
|
||||||
if (is_uninterp(a))
|
if (is_uninterp(a))
|
||||||
return true;
|
return true;
|
||||||
else {
|
|
||||||
decl_plugin * p = m_bvutil.get_manager().get_plugin(a->get_family_id());
|
decl_plugin * p = m_bvutil.get_manager().get_plugin(a->get_family_id());
|
||||||
return p->is_considered_uninterpreted(a->get_decl());
|
return p->is_considered_uninterpreted(a->get_decl());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief determines if a term is a candidate select for Ackerman reduction
|
\brief determines if a term is a candidate select for Ackerman reduction
|
||||||
|
@ -64,11 +63,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (expr* arg : *a) {
|
for (expr* arg : *a)
|
||||||
non_select.mark(arg, true);
|
non_select.mark(arg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void prune_non_select(obj_map<app, app_set*> & sels, expr_mark& non_select) {
|
void prune_non_select(obj_map<app, app_set*> & sels, expr_mark& non_select) {
|
||||||
ptr_vector<app> nons;
|
ptr_vector<app> nons;
|
||||||
|
@ -112,7 +110,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(fun2terms_map& f2t, sel2terms_map& s2t, app* a) {
|
void insert(fun2terms_map& f2t, sel2terms_map& s2t, app* a) {
|
||||||
if (a->get_num_args() == 0) return;
|
if (a->get_num_args() == 0)
|
||||||
|
return;
|
||||||
ast_manager& m = m_bvutil.get_manager();
|
ast_manager& m = m_bvutil.get_manager();
|
||||||
app_set* ts = nullptr;
|
app_set* ts = nullptr;
|
||||||
bool is_const_args = true;
|
bool is_const_args = true;
|
||||||
|
@ -129,22 +128,19 @@ public:
|
||||||
ts = alloc(app_set);
|
ts = alloc(app_set);
|
||||||
f2t.insert(fd, ts);
|
f2t.insert(fd, ts);
|
||||||
}
|
}
|
||||||
is_const_args = m.is_value(a->get_arg(0));
|
is_const_args = m.is_unique_value(a->get_arg(0));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
for (unsigned i = 1; is_const_args && i < a->get_num_args(); ++i) {
|
|
||||||
is_const_args &= m.is_value(a->get_arg(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_const_args) {
|
for (unsigned i = 1; is_const_args && i < a->get_num_args(); ++i)
|
||||||
|
is_const_args &= m.is_unique_value(a->get_arg(i));
|
||||||
|
|
||||||
|
if (is_const_args)
|
||||||
ts->const_args.insert(a);
|
ts->const_args.insert(a);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
ts->var_args.insert(a);
|
ts->var_args.insert(a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bv_util m_bvutil;
|
bv_util m_bvutil;
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "ackermannization/ackr_info.h"
|
#include "ackermannization/ackr_info.h"
|
||||||
#include "ast/for_each_expr.h"
|
#include "ast/for_each_expr.h"
|
||||||
#include "ast/ast_util.h"
|
#include "ast/ast_util.h"
|
||||||
|
#include "ast/ast_pp.h"
|
||||||
|
#include "ast/ast_ll_pp.h"
|
||||||
#include "model/model_smt2_pp.h"
|
#include "model/model_smt2_pp.h"
|
||||||
|
|
||||||
lackr::lackr(ast_manager& m, const params_ref& p, lackr_stats& st,
|
lackr::lackr(ast_manager& m, const params_ref& p, lackr_stats& st,
|
||||||
|
@ -142,10 +144,10 @@ bool lackr::ackr(app * const t1, app * const t2) {
|
||||||
// Introduce the ackermann lemma for each pair of terms.
|
// Introduce the ackermann lemma for each pair of terms.
|
||||||
//
|
//
|
||||||
void lackr::eager_enc() {
|
void lackr::eager_enc() {
|
||||||
TRACE("ackermannize", tout << "#funs: " << m_fun2terms.size() << "#sels: " << m_sel2terms.size() << std::endl;);
|
TRACE("ackermannize", tout << "#funs: " << m_fun2terms.size() << " #sels: " << m_sel2terms.size() << std::endl;);
|
||||||
for (auto const& kv : m_fun2terms) {
|
for (auto const& [k,v] : m_fun2terms) {
|
||||||
checkpoint();
|
checkpoint();
|
||||||
ackr(kv.get_value());
|
ackr(v);
|
||||||
}
|
}
|
||||||
for (auto const& kv : m_sel2terms) {
|
for (auto const& kv : m_sel2terms) {
|
||||||
checkpoint();
|
checkpoint();
|
||||||
|
@ -172,14 +174,13 @@ void lackr::ackr(app_set const* ts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lackr::abstract_fun(fun2terms_map const& apps) {
|
void lackr::abstract_fun(fun2terms_map const& apps) {
|
||||||
for (auto const& kv : apps) {
|
for (auto const& [fd, v] : apps) {
|
||||||
func_decl* fd = kv.m_key;
|
for (app * t : v->var_args) {
|
||||||
for (app * t : kv.m_value->var_args) {
|
|
||||||
app * fc = m.mk_fresh_const(fd->get_name(), t->get_sort());
|
app * fc = m.mk_fresh_const(fd->get_name(), t->get_sort());
|
||||||
SASSERT(t->get_decl() == fd);
|
SASSERT(t->get_decl() == fd);
|
||||||
m_info->set_abstr(t, fc);
|
m_info->set_abstr(t, fc);
|
||||||
}
|
}
|
||||||
for (app * t : kv.m_value->const_args) {
|
for (app * t : v->const_args) {
|
||||||
app * fc = m.mk_fresh_const(fd->get_name(), t->get_sort());
|
app * fc = m.mk_fresh_const(fd->get_name(), t->get_sort());
|
||||||
SASSERT(t->get_decl() == fd);
|
SASSERT(t->get_decl() == fd);
|
||||||
m_info->set_abstr(t, fc);
|
m_info->set_abstr(t, fc);
|
||||||
|
|
|
@ -633,6 +633,12 @@ bool array_decl_plugin::is_value(app * _e) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool array_decl_plugin::is_unique_value(app* _e) const {
|
||||||
|
array_util u(*m_manager);
|
||||||
|
expr* e = _e;
|
||||||
|
return u.is_const(e, e) && m_manager->is_unique_value(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func_decl * array_recognizers::get_as_array_func_decl(expr * n) const {
|
func_decl * array_recognizers::get_as_array_func_decl(expr * n) const {
|
||||||
SASSERT(is_as_array(n));
|
SASSERT(is_as_array(n));
|
||||||
|
|
|
@ -137,6 +137,8 @@ class array_decl_plugin : public decl_plugin {
|
||||||
|
|
||||||
bool is_value(app * e) const override;
|
bool is_value(app * e) const override;
|
||||||
|
|
||||||
|
bool is_unique_value(app* e) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class array_recognizers {
|
class array_recognizers {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue