3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-04 15:03:57 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-07-27 17:02:27 -07:00
commit b482dbd589
379 changed files with 7440 additions and 3352 deletions

25
src/tactic/CMakeLists.txt Normal file
View file

@ -0,0 +1,25 @@
z3_add_component(tactic
SOURCES
equiv_proof_converter.cpp
extension_model_converter.cpp
filter_model_converter.cpp
goal.cpp
goal_num_occurs.cpp
goal_shared_occs.cpp
goal_util.cpp
horn_subsume_model_converter.cpp
model_converter.cpp
probe.cpp
proof_converter.cpp
replace_proof_converter.cpp
sine_filter.cpp
tactical.cpp
tactic.cpp
COMPONENT_DEPENDENCIES
ast
model
TACTIC_HEADERS
probe.h
sine_filter.h
tactic.h
)

View file

@ -0,0 +1,9 @@
z3_add_component(aig_tactic
SOURCES
aig.cpp
aig_tactic.cpp
COMPONENT_DEPENDENCIES
tactic
TACTIC_HEADERS
aig_tactic.h
)

View file

@ -0,0 +1,50 @@
z3_add_component(arith_tactics
SOURCES
add_bounds_tactic.cpp
arith_bounds_tactic.cpp
bound_manager.cpp
bound_propagator.cpp
bv2int_rewriter.cpp
bv2real_rewriter.cpp
card2bv_tactic.cpp
degree_shift_tactic.cpp
diff_neq_tactic.cpp
elim01_tactic.cpp
eq2bv_tactic.cpp
factor_tactic.cpp
fix_dl_var_tactic.cpp
fm_tactic.cpp
lia2card_tactic.cpp
lia2pb_tactic.cpp
linear_equation.cpp
nla2bv_tactic.cpp
normalize_bounds_tactic.cpp
pb2bv_model_converter.cpp
pb2bv_tactic.cpp
probe_arith.cpp
propagate_ineqs_tactic.cpp
purify_arith_tactic.cpp
recover_01_tactic.cpp
COMPONENT_DEPENDENCIES
core_tactics
sat
TACTIC_HEADERS
add_bounds_tactic.h
card2bv_tactic.h
degree_shift_tactic.h
diff_neq_tactic.h
elim01_tactic.h
eq2bv_tactic.h
factor_tactic.h
fix_dl_var_tactic.h
fm_tactic.h
lia2pb_tactic.h
lia2card_tactic.h
nla2bv_tactic.h
normalize_bounds_tactic.h
pb2bv_tactic.h
probe_arith.h
propagate_ineqs_tactic.h
purify_arith_tactic.h
recover_01_tactic.h
)

View file

@ -169,7 +169,7 @@ public:
for (; bit != bend; ++bit) {
if (!is_app(*bit)) continue;
app* x = to_app(*bit);
bool s1, s2;
bool s1 = false, s2 = false;
rational lo, hi;
if (a.is_int(x) &&
bounds.has_lower(x, lo, s1) && !s1 && zero <= lo &&

View file

@ -176,7 +176,7 @@ public:
bound_manager::iterator bit = bounds.begin(), bend = bounds.end();
for (; bit != bend; ++bit) {
expr* x = *bit;
bool s1, s2;
bool s1 = false, s2 = false;
rational lo, hi;
if (a.is_int(x) &&
bounds.has_lower(x, lo, s1) && !s1 && lo.is_zero() &&

View 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
)

View file

@ -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;
}

View file

@ -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));
}
}
}

View file

@ -0,0 +1,46 @@
z3_add_component(core_tactics
SOURCES
blast_term_ite_tactic.cpp
cofactor_elim_term_ite.cpp
cofactor_term_ite_tactic.cpp
collect_statistics_tactic.cpp
ctx_simplify_tactic.cpp
der_tactic.cpp
distribute_forall_tactic.cpp
elim_term_ite_tactic.cpp
elim_uncnstr_tactic.cpp
nnf_tactic.cpp
occf_tactic.cpp
pb_preprocess_tactic.cpp
propagate_values_tactic.cpp
reduce_args_tactic.cpp
simplify_tactic.cpp
solve_eqs_tactic.cpp
split_clause_tactic.cpp
symmetry_reduce_tactic.cpp
tseitin_cnf_tactic.cpp
collect_occs.cpp
COMPONENT_DEPENDENCIES
normal_forms
tactic
TACTIC_HEADERS
blast_term_ite_tactic.h
cofactor_term_ite_tactic.h
collect_statistics_tactic.h
ctx_simplify_tactic.h
der_tactic.h
distribute_forall_tactic.h
elim_term_ite_tactic.h
elim_uncnstr_tactic.h
nnf_tactic.h
occf_tactic.h
pb_preprocess_tactic.h
propagate_values_tactic.h
reduce_args_tactic.h
simplify_tactic.h
solve_eqs_tactic.h
split_clause_tactic.h
symmetry_reduce_tactic.h
tseitin_cnf_tactic.h
)

View file

@ -62,14 +62,14 @@ class blast_term_ite_tactic : public tactic {
for (unsigned i = 0; i < num_args; ++i) {
expr* c, *t, *e;
if (!m.is_bool(args[i]) && m.is_ite(args[i], c, t, e)) {
enable_trace("blast_term_ite");
// enable_trace("blast_term_ite");
TRACE("blast_term_ite", result = m.mk_app(f, num_args, args); tout << result << "\n";);
expr_ref e1(m), e2(m);
ptr_vector<expr> args1(num_args, args);
args1[i] = t;
++m_num_fresh;
e1 = m.mk_app(f, num_args, args1.c_ptr());
if (t == e) {
if (m.are_equal(t,e)) {
result = e1;
return BR_REWRITE1;
}

View file

@ -47,10 +47,10 @@ class collect_statistics_tactic : public tactic {
public:
collect_statistics_tactic(ast_manager & m, params_ref const & p) :
m(m),
m(m),
m_params(p) {
}
}
virtual ~collect_statistics_tactic() {}
virtual tactic * translate(ast_manager & m_) {
@ -60,21 +60,21 @@ public:
virtual void updt_params(params_ref const & p) {
m_params = p;
}
virtual void collect_param_descrs(param_descrs & r) {}
virtual void operator()(goal_ref const & g, goal_ref_buffer & result,
model_converter_ref & mc, proof_converter_ref & pc,
model_converter_ref & mc, proof_converter_ref & pc,
expr_dependency_ref & core) {
mc = 0;
tactic_report report("collect-statistics", *g);
tactic_report report("collect-statistics", *g);
collect_proc cp(m, m_stats);
expr_mark visited;
expr_mark visited;
const unsigned sz = g->size();
for (unsigned i = 0; i < sz; i++)
for_each_expr(cp, visited, g->form(i));
std::cout << "(" << std::endl;
stats_type::iterator it = m_stats.begin();
stats_type::iterator end = m_stats.end();
@ -84,7 +84,7 @@ public:
g->inc_depth();
result.push_back(g.get());
}
}
virtual void cleanup() {}
@ -98,11 +98,12 @@ protected:
class collect_proc {
public:
ast_manager & m;
stats_type & m_stats;
stats_type & m_stats;
obj_hashtable<sort> m_seen_sorts;
obj_hashtable<func_decl> m_seen_func_decls;
unsigned m_qdepth;
collect_proc(ast_manager & m, stats_type & s) : m(m), m_stats(s) {}
collect_proc(ast_manager & m, stats_type & s) : m(m), m_stats(s), m_qdepth(0) {}
void operator()(var * v) {
m_stats["bound-variables"]++;
@ -113,7 +114,18 @@ protected:
m_stats["quantifiers"]++;
SASSERT(is_app(q->get_expr()));
app * body = to_app(q->get_expr());
if (q->is_forall())
m_stats["forall-variables"] += q->get_num_decls();
else
m_stats["exists-variables"] += q->get_num_decls();
m_stats["patterns"] += q->get_num_patterns();
m_stats["no-patterns"] += q->get_num_no_patterns();
m_qdepth++;
if (m_stats.find("max-quantification-depth") == m_stats.end() ||
m_stats["max-quantification-depth"] < m_qdepth)
m_stats["max-quantification-depth"] = m_qdepth;
this->operator()(body);
m_qdepth--;
}
void operator()(app * n) {
@ -121,7 +133,7 @@ protected:
this->operator()(n->get_decl());
}
void operator()(sort * s) {
void operator()(sort * s) {
if (m.is_uninterp(s)) {
if (!m_seen_sorts.contains(s)) {
m_stats["uninterpreted-sorts"]++;
@ -135,7 +147,7 @@ protected:
std::stringstream ss;
ss << "(declare-sort " << mk_ismt2_pp(s, m, prms) << ")";
m_stats[ss.str()]++;
if (s->get_info()->get_num_parameters() > 0) {
std::stringstream ssname;
ssname << "(declare-sort (_ " << s->get_name() << " *))";

View file

@ -0,0 +1,17 @@
z3_add_component(fpa_tactics
SOURCES
fpa2bv_model_converter.cpp
fpa2bv_tactic.cpp
qffp_tactic.cpp
COMPONENT_DEPENDENCIES
arith_tactics
bv_tactics
core_tactics
fpa
sat_tactic
smtlogic_tactics
smt_tactic
TACTIC_HEADERS
fpa2bv_tactic.h
qffp_tactic.h
)

View file

@ -137,7 +137,8 @@ void goal::push_back(expr * f, proof * pr, expr_dependency * d) {
}
void goal::quick_process(bool save_first, expr_ref& f, expr_dependency * d) {
if (!m().is_and(f) && !(m().is_not(f) && m().is_or(to_app(f)->get_arg(0)))) {
expr* g = 0;
if (!m().is_and(f) && !(m().is_not(f, g) && m().is_or(g))) {
if (!save_first) {
push_back(f, 0, d);
}
@ -170,8 +171,8 @@ void goal::quick_process(bool save_first, expr_ref& f, expr_dependency * d) {
todo.push_back(expr_pol(t->get_arg(i), false));
}
}
else if (m().is_not(curr)) {
todo.push_back(expr_pol(to_app(curr)->get_arg(0), !pol));
else if (m().is_not(curr, g)) {
todo.push_back(expr_pol(g, !pol));
}
else {
if (!pol) {

View file

@ -0,0 +1,9 @@
z3_add_component(nlsat_smt_tactic
SOURCES
nl_purify_tactic.cpp
COMPONENT_DEPENDENCIES
nlsat_tactic
smt_tactic
TACTIC_HEADERS
nl_purify_tactic.h
)

View file

@ -0,0 +1,21 @@
z3_add_component(portfolio
SOURCES
default_tactic.cpp
enum2bv_solver.cpp
pb2bv_solver.cpp
bounded_int2bv_solver.cpp
fd_solver.cpp
smt_strategic_solver.cpp
COMPONENT_DEPENDENCIES
aig_tactic
fp
fpa_tactics
qe
sat_solver
sls_tactic
smtlogic_tactics
subpaving_tactic
ufbv_tactic
TACTIC_HEADERS
default_tactic.h
)

View file

@ -183,7 +183,7 @@ public:
// translate bit-vector consequences back to integer values
for (unsigned i = 0; i < consequences.size(); ++i) {
expr* a, *b, *u, *v;
expr* a = 0, *b = 0, *u = 0, *v = 0;
func_decl* f;
rational num;
unsigned bvsize;
@ -243,7 +243,7 @@ private:
for (; it != end; ++it) {
expr* e = *it;
rational lo, hi;
bool s1, s2;
bool s1 = false, s2 = false;
SASSERT(is_uninterp_const(e));
func_decl* f = to_app(e)->get_decl();

View file

@ -128,7 +128,7 @@ public:
// translate enumeration constants to bit-vectors.
for (unsigned i = 0; i < vars.size(); ++i) {
func_decl* f;
func_decl* f = 0;
if (is_app(vars[i]) && is_uninterp_const(vars[i]) && m_rewriter.enum2bv().find(to_app(vars[i])->get_decl(), f)) {
bvars.push_back(m.mk_const(f));
}
@ -140,7 +140,7 @@ public:
// translate bit-vector consequences back to enumeration types
for (unsigned i = 0; i < consequences.size(); ++i) {
expr* a, *b, *u, *v;
expr* a = 0, *b = 0, *u = 0, *v = 0;
func_decl* f;
rational num;
unsigned bvsize;

View file

@ -0,0 +1,15 @@
z3_add_component(sls_tactic
SOURCES
bvsls_opt_engine.cpp
sls_engine.cpp
sls_tactic.cpp
COMPONENT_DEPENDENCIES
bv_tactics
core_tactics
normal_forms
tactic
PYG_FILES
sls_params.pyg
TACTIC_HEADERS
sls_tactic.h
)

View file

@ -0,0 +1,45 @@
z3_add_component(smtlogic_tactics
SOURCES
nra_tactic.cpp
qfaufbv_tactic.cpp
qfauflia_tactic.cpp
qfbv_tactic.cpp
qfidl_tactic.cpp
qflia_tactic.cpp
qflra_tactic.cpp
qfnia_tactic.cpp
qfnra_tactic.cpp
qfufbv_ackr_model_converter.cpp
qfufbv_tactic.cpp
qfufnra_tactic.cpp
qfuf_tactic.cpp
quant_tactics.cpp
COMPONENT_DEPENDENCIES
ackermannization
aig_tactic
arith_tactics
bv_tactics
fp
muz
nlsat_tactic
nlsat_smt_tactic
qe
sat_solver
smt_tactic
PYG_FILES
qfufbv_tactic_params.pyg
TACTIC_HEADERS
nra_tactic.h
qfaufbv_tactic.h
qfauflia_tactic.h
qfbv_tactic.h
qfidl_tactic.h
qflia_tactic.h
qflra_tactic.h
qfnia_tactic.h
qfnra_tactic.h
qfuf_tactic.h
qfufbv_tactic.h
qfufnra_tactic.h
quant_tactics.h
)

View file

@ -0,0 +1,19 @@
z3_add_component(ufbv_tactic
SOURCES
macro_finder_tactic.cpp
quasi_macros_tactic.cpp
ufbv_rewriter.cpp
ufbv_rewriter_tactic.cpp
ufbv_tactic.cpp
COMPONENT_DEPENDENCIES
core_tactics
macros
normal_forms
rewriter
smt_tactic
TACTIC_HEADERS
macro_finder_tactic.h
quasi_macros_tactic.h
ufbv_rewriter_tactic.h
ufbv_tactic.h
)