mirror of
https://github.com/Z3Prover/z3
synced 2025-08-12 06:00:53 +00:00
merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
b482dbd589
379 changed files with 7440 additions and 3352 deletions
28
src/tactic/bv/CMakeLists.txt
Normal file
28
src/tactic/bv/CMakeLists.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
z3_add_component(bv_tactics
|
||||
SOURCES
|
||||
bit_blaster_model_converter.cpp
|
||||
bit_blaster_tactic.cpp
|
||||
bv1_blaster_tactic.cpp
|
||||
bvarray2uf_rewriter.cpp
|
||||
bvarray2uf_tactic.cpp
|
||||
bv_bound_chk_tactic.cpp
|
||||
bv_bounds_tactic.cpp
|
||||
bv_size_reduction_tactic.cpp
|
||||
dt2bv_tactic.cpp
|
||||
elim_small_bv_tactic.cpp
|
||||
max_bv_sharing_tactic.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
bit_blaster
|
||||
core_tactics
|
||||
tactic
|
||||
TACTIC_HEADERS
|
||||
bit_blaster_tactic.h
|
||||
bv1_blaster_tactic.h
|
||||
bv_bound_chk_tactic.h
|
||||
bv_bounds_tactic.h
|
||||
bv_size_reduction_tactic.h
|
||||
bvarray2uf_tactic.h
|
||||
dt2bv_tactic.h
|
||||
elim_small_bv_tactic.h
|
||||
max_bv_sharing_tactic.h
|
||||
)
|
|
@ -234,6 +234,7 @@ class bv_bounds_simplifier : public ctx_simplify_tactic::simplifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
expr_set* get_expr_vars(expr* t) {
|
||||
unsigned id = t->get_id();
|
||||
m_expr_vars.reserve(id + 1);
|
||||
|
@ -259,7 +260,9 @@ class bv_bounds_simplifier : public ctx_simplify_tactic::simplifier {
|
|||
}
|
||||
return set;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
expr_cnt* get_expr_bounds(expr* t) {
|
||||
unsigned id = t->get_id();
|
||||
m_bound_exprs.reserve(id + 1);
|
||||
|
@ -288,6 +291,7 @@ class bv_bounds_simplifier : public ctx_simplify_tactic::simplifier {
|
|||
}
|
||||
return set;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
bv_bounds_simplifier(ast_manager& m, params_ref const& p) : m(m), m_params(p), m_bv(m) {
|
||||
|
@ -392,17 +396,86 @@ public:
|
|||
return result != 0;
|
||||
}
|
||||
|
||||
// check if t contains v
|
||||
ptr_vector<expr> todo;
|
||||
bool contains(expr* t, expr* v) {
|
||||
ast_fast_mark1 mark;
|
||||
todo.push_back(t);
|
||||
while (!todo.empty()) {
|
||||
t = todo.back();
|
||||
todo.pop_back();
|
||||
if (mark.is_marked(t)) {
|
||||
continue;
|
||||
}
|
||||
if (t == v) {
|
||||
todo.reset();
|
||||
return true;
|
||||
}
|
||||
mark.mark(t);
|
||||
|
||||
if (!is_app(t)) {
|
||||
continue;
|
||||
}
|
||||
app* a = to_app(t);
|
||||
todo.append(a->get_num_args(), a->get_args());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool contains_bound(expr* t) {
|
||||
ast_fast_mark1 mark1;
|
||||
ast_fast_mark2 mark2;
|
||||
|
||||
todo.push_back(t);
|
||||
while (!todo.empty()) {
|
||||
t = todo.back();
|
||||
todo.pop_back();
|
||||
if (mark1.is_marked(t)) {
|
||||
continue;
|
||||
}
|
||||
mark1.mark(t);
|
||||
|
||||
if (!is_app(t)) {
|
||||
continue;
|
||||
}
|
||||
interval b;
|
||||
expr* e;
|
||||
if (is_bound(t, e, b)) {
|
||||
if (mark2.is_marked(e)) {
|
||||
todo.reset();
|
||||
return true;
|
||||
}
|
||||
mark2.mark(e);
|
||||
if (m_bound.contains(e)) {
|
||||
todo.reset();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
app* a = to_app(t);
|
||||
todo.append(a->get_num_args(), a->get_args());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool may_simplify(expr* t) {
|
||||
if (m_bv.is_numeral(t))
|
||||
return false;
|
||||
|
||||
while (m.is_not(t, t));
|
||||
|
||||
for (auto & v : m_bound) {
|
||||
if (contains(t, v.m_key)) return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
expr_set* used_exprs = get_expr_vars(t);
|
||||
for (map::iterator I = m_bound.begin(), E = m_bound.end(); I != E; ++I) {
|
||||
if (contains(t, I->m_key)) return true;
|
||||
if (I->m_value.is_singleton() && used_exprs->contains(I->m_key))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
expr* t1;
|
||||
interval b;
|
||||
|
@ -411,11 +484,16 @@ public:
|
|||
return b.is_full() || m_bound.contains(t1);
|
||||
}
|
||||
|
||||
if (contains_bound(t)) {
|
||||
return true;
|
||||
}
|
||||
#if 0
|
||||
expr_cnt* bounds = get_expr_bounds(t);
|
||||
for (expr_cnt::iterator I = bounds->begin(), E = bounds->end(); I != E; ++I) {
|
||||
if (I->m_value > 1 || m_bound.contains(I->m_key))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ Revision History:
|
|||
#include "var_subst.h"
|
||||
#include "ast_util.h"
|
||||
#include "enum2bv_rewriter.h"
|
||||
#include "ast_pp.h"
|
||||
|
||||
|
||||
class dt2bv_tactic : public tactic {
|
||||
|
@ -53,30 +54,32 @@ class dt2bv_tactic : public tactic {
|
|||
|
||||
void operator()(app* a) {
|
||||
if (m.is_eq(a)) {
|
||||
return;
|
||||
// no-op
|
||||
}
|
||||
if (m.is_distinct(a)) {
|
||||
return;
|
||||
else if (m.is_distinct(a)) {
|
||||
// no-op
|
||||
}
|
||||
if (m_t.m_dt.is_recognizer(a->get_decl()) &&
|
||||
else if (m_t.m_dt.is_recognizer(a->get_decl()) &&
|
||||
m_t.is_fd(a->get_arg(0))) {
|
||||
m_t.m_fd_sorts.insert(get_sort(a->get_arg(0)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_t.is_fd(a) && a->get_num_args() > 0) {
|
||||
else if (m_t.is_fd(a) && a->get_num_args() > 0) {
|
||||
m_t.m_non_fd_sorts.insert(get_sort(a));
|
||||
args_cannot_be_fd(a);
|
||||
}
|
||||
else if (m_t.is_fd(a)) {
|
||||
m_t.m_fd_sorts.insert(get_sort(a));
|
||||
}
|
||||
else {
|
||||
unsigned sz = a->get_num_args();
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (m_t.is_fd(a->get_arg(i))) {
|
||||
m_t.m_non_fd_sorts.insert(get_sort(a->get_arg(i)));
|
||||
}
|
||||
}
|
||||
args_cannot_be_fd(a);
|
||||
}
|
||||
}
|
||||
|
||||
void args_cannot_be_fd(app* a) {
|
||||
for (expr* arg : *a) {
|
||||
if (m_t.is_fd(arg)) {
|
||||
m_t.m_non_fd_sorts.insert(get_sort(arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue