mirror of
https://github.com/Z3Prover/z3
synced 2025-08-03 09:50:23 +00:00
merge
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
c03be16039
15 changed files with 487 additions and 438 deletions
|
@ -76,7 +76,7 @@ asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p):
|
|||
void asserted_formulas::setup() {
|
||||
switch (m_params.m_lift_ite) {
|
||||
case LI_FULL:
|
||||
m_params.m_ng_lift_ite = LI_NONE;
|
||||
m_params.m_ng_lift_ite = LI_NONE;
|
||||
break;
|
||||
case LI_CONSERVATIVE:
|
||||
if (m_params.m_ng_lift_ite == LI_CONSERVATIVE)
|
||||
|
@ -85,7 +85,7 @@ void asserted_formulas::setup() {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (m_params.m_relevancy_lvl == 0)
|
||||
m_params.m_relevancy_lemma = false;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void asserted_formulas::setup_simplifier_plugins(simplifier & s, basic_simplifie
|
|||
s.register_plugin(alloc(array_simplifier_plugin, m, *bsimp, s, m_params));
|
||||
bvsimp = alloc(bv_simplifier_plugin, m, *bsimp, m_params);
|
||||
s.register_plugin(bvsimp);
|
||||
s.register_plugin(alloc(datatype_simplifier_plugin, m, *bsimp));
|
||||
s.register_plugin(alloc(datatype_simplifier_plugin, m, *bsimp));
|
||||
s.register_plugin(alloc(fpa_simplifier_plugin, m, *bsimp));
|
||||
s.register_plugin(alloc(seq_simplifier_plugin, m, *bsimp));
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void asserted_formulas::set_eliminate_and(bool flag) {
|
|||
|
||||
|
||||
void asserted_formulas::assert_expr(expr * e, proof * _in_pr) {
|
||||
if (inconsistent())
|
||||
if (inconsistent())
|
||||
return;
|
||||
m_has_quantifiers |= ::has_quantifiers(e);
|
||||
if (!m_params.m_preprocess) {
|
||||
|
@ -177,7 +177,7 @@ void asserted_formulas::assert_expr(expr * e, proof * _in_pr) {
|
|||
}
|
||||
|
||||
void asserted_formulas::assert_expr(expr * e) {
|
||||
if (inconsistent())
|
||||
if (inconsistent())
|
||||
return;
|
||||
assert_expr(e, m.mk_asserted(e));
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ void asserted_formulas::push_scope() {
|
|||
m_bv_sharing.push_scope();
|
||||
commit();
|
||||
}
|
||||
|
||||
|
||||
void asserted_formulas::pop_scope(unsigned num_scopes) {
|
||||
TRACE("asserted_formulas_scopes", tout << "before pop " << num_scopes << "\n"; display(tout););
|
||||
m_bv_sharing.pop_scope(num_scopes);
|
||||
|
@ -230,15 +230,15 @@ void asserted_formulas::reset() {
|
|||
|
||||
#ifdef Z3DEBUG
|
||||
bool asserted_formulas::check_well_sorted() const {
|
||||
for (unsigned i = 0; i < m_asserted_formulas.size(); i++) {
|
||||
if (!is_well_sorted(m, m_asserted_formulas.get(i))) return false;
|
||||
for (unsigned i = 0; i < m_asserted_formulas.size(); i++) {
|
||||
if (!is_well_sorted(m, m_asserted_formulas.get(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void asserted_formulas::reduce() {
|
||||
if (inconsistent())
|
||||
if (inconsistent())
|
||||
return;
|
||||
if (canceled()) {
|
||||
return;
|
||||
|
@ -255,7 +255,7 @@ void asserted_formulas::reduce() {
|
|||
|
||||
|
||||
#define INVOKE(COND, FUNC) if (COND) { FUNC; IF_VERBOSE(10000, verbose_stream() << "total size: " << get_total_size() << "\n";); } TRACE("reduce_step_ll", ast_mark visited; display_ll(tout, visited);); TRACE("reduce_step", display(tout << #FUNC << " ");); CASSERT("well_sorted",check_well_sorted()); if (inconsistent() || canceled()) { TRACE("after_reduce", display(tout);); TRACE("after_reduce_ll", ast_mark visited; display_ll(tout, visited);); return; }
|
||||
|
||||
|
||||
set_eliminate_and(false); // do not eliminate and before nnf.
|
||||
INVOKE(m_params.m_propagate_booleans, propagate_booleans());
|
||||
INVOKE(m_params.m_propagate_values, propagate_values());
|
||||
|
@ -268,18 +268,18 @@ void asserted_formulas::reduce() {
|
|||
INVOKE(m_params.m_lift_ite != LI_NONE, lift_ite());
|
||||
INVOKE(m_params.m_eliminate_term_ite && m_params.m_lift_ite != LI_FULL, eliminate_term_ite());
|
||||
INVOKE(m_params.m_refine_inj_axiom && has_quantifiers(), refine_inj_axiom());
|
||||
INVOKE(m_params.m_distribute_forall && has_quantifiers(), apply_distribute_forall());
|
||||
TRACE("qbv_bug", tout << "after distribute_forall:\n"; display(tout););
|
||||
INVOKE(m_params.m_distribute_forall && has_quantifiers(), apply_distribute_forall());
|
||||
TRACE("qbv_bug", tout << "after distribute_forall:\n"; display(tout););
|
||||
INVOKE(m_params.m_macro_finder && has_quantifiers(), find_macros());
|
||||
INVOKE(m_params.m_quasi_macros && has_quantifiers(), apply_quasi_macros());
|
||||
INVOKE(m_params.m_quasi_macros && has_quantifiers(), apply_quasi_macros());
|
||||
INVOKE(m_params.m_simplify_bit2int, apply_bit2int());
|
||||
INVOKE(m_params.m_eliminate_bounds && has_quantifiers(), cheap_quant_fourier_motzkin());
|
||||
INVOKE(m_params.m_ematching && has_quantifiers(), infer_patterns());
|
||||
INVOKE(m_params.m_max_bv_sharing && has_bv(), max_bv_sharing());
|
||||
INVOKE(m_params.m_bb_quantifiers, elim_bvs_from_quantifiers());
|
||||
// temporary HACK: make sure that arith & bv are list-assoc
|
||||
// temporary HACK: make sure that arith & bv are list-assoc
|
||||
// this may destroy some simplification steps such as max_bv_sharing
|
||||
reduce_asserted_formulas();
|
||||
reduce_asserted_formulas();
|
||||
|
||||
CASSERT("well_sorted",check_well_sorted());
|
||||
|
||||
|
@ -293,7 +293,7 @@ void asserted_formulas::reduce() {
|
|||
void asserted_formulas::eliminate_and() {
|
||||
IF_IVERBOSE(10, verbose_stream() << "(smt.eliminating-and)\n";);
|
||||
set_eliminate_and(true);
|
||||
reduce_asserted_formulas();
|
||||
reduce_asserted_formulas();
|
||||
TRACE("after_elim_and", display(tout););
|
||||
}
|
||||
|
||||
|
@ -333,10 +333,10 @@ void asserted_formulas::display(std::ostream & out) const {
|
|||
void asserted_formulas::display_ll(std::ostream & out, ast_mark & pp_visited) const {
|
||||
if (!m_asserted_formulas.empty()) {
|
||||
unsigned sz = m_asserted_formulas.size();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
ast_def_ll_pp(out, m, m_asserted_formulas.get(i), pp_visited, true, false);
|
||||
out << "asserted formulas:\n";
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
out << "#" << m_asserted_formulas[i]->get_id() << " ";
|
||||
out << "\n";
|
||||
}
|
||||
|
@ -389,8 +389,12 @@ void asserted_formulas::find_macros_core() {
|
|||
expr_ref_vector new_exprs(m);
|
||||
proof_ref_vector new_prs(m);
|
||||
unsigned sz = m_asserted_formulas.size();
|
||||
m_macro_finder->operator()(sz - m_asserted_qhead, m_asserted_formulas.c_ptr() + m_asserted_qhead,
|
||||
m_asserted_formula_prs.c_ptr() + m_asserted_qhead, new_exprs, new_prs);
|
||||
expr_dependency_ref_vector new_deps(m);
|
||||
m_macro_finder->operator()(sz - m_asserted_qhead,
|
||||
m_asserted_formulas.c_ptr() + m_asserted_qhead,
|
||||
m_asserted_formula_prs.c_ptr() + m_asserted_qhead,
|
||||
0, // 0 == No dependency tracking
|
||||
new_exprs, new_prs, new_deps);
|
||||
swap_asserted_formulas(new_exprs, new_prs);
|
||||
reduce_and_solve();
|
||||
}
|
||||
|
@ -412,14 +416,17 @@ void asserted_formulas::apply_quasi_macros() {
|
|||
TRACE("before_quasi_macros", display(tout););
|
||||
expr_ref_vector new_exprs(m);
|
||||
proof_ref_vector new_prs(m);
|
||||
expr_dependency_ref_vector new_deps(m);
|
||||
quasi_macros proc(m, m_macro_manager);
|
||||
while (proc(m_asserted_formulas.size() - m_asserted_qhead,
|
||||
m_asserted_formulas.c_ptr() + m_asserted_qhead,
|
||||
m_asserted_formula_prs.c_ptr() + m_asserted_qhead,
|
||||
new_exprs, new_prs)) {
|
||||
0, // 0 == No dependency tracking
|
||||
new_exprs, new_prs, new_deps)) {
|
||||
swap_asserted_formulas(new_exprs, new_prs);
|
||||
new_exprs.reset();
|
||||
new_prs.reset();
|
||||
new_deps.reset();
|
||||
}
|
||||
TRACE("after_quasi_macros", display(tout););
|
||||
reduce_and_solve();
|
||||
|
@ -432,7 +439,7 @@ void asserted_formulas::nnf_cnf() {
|
|||
proof_ref_vector new_prs(m);
|
||||
expr_ref_vector push_todo(m);
|
||||
proof_ref_vector push_todo_prs(m);
|
||||
|
||||
|
||||
unsigned i = m_asserted_qhead;
|
||||
unsigned sz = m_asserted_formulas.size();
|
||||
TRACE("nnf_bug", tout << "i: " << i << " sz: " << sz << "\n";);
|
||||
|
@ -462,8 +469,8 @@ void asserted_formulas::nnf_cnf() {
|
|||
CASSERT("well_sorted",is_well_sorted(m, r1));
|
||||
if (canceled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (m.proofs_enabled())
|
||||
pr = m.mk_modus_ponens(push_todo_prs.get(k), pr1);
|
||||
else
|
||||
|
@ -600,7 +607,7 @@ void asserted_formulas::propagate_values() {
|
|||
// C is a set which contains formulas of the form
|
||||
// { x = n }, where x is a variable and n a numeral.
|
||||
// R contains the rest.
|
||||
//
|
||||
//
|
||||
// - new_exprs1 is the set C
|
||||
// - new_exprs2 is the set R
|
||||
//
|
||||
|
@ -665,7 +672,7 @@ void asserted_formulas::propagate_values() {
|
|||
// x->n will be removed from m_cache. If we don't do that, the next transformation
|
||||
// may simplify constraints in C using these entries, and the variables x in C
|
||||
// will be (silently) eliminated, and models produced by Z3 will not contain them.
|
||||
flush_cache();
|
||||
flush_cache();
|
||||
}
|
||||
TRACE("propagate_values", tout << "after:\n"; display(tout););
|
||||
}
|
||||
|
@ -788,7 +795,7 @@ void asserted_formulas::refine_inj_axiom() {
|
|||
TRACE("inj_axiom", tout << "simplifying...\n" << mk_pp(n, m) << "\n" << mk_pp(new_n, m) << "\n";);
|
||||
m_asserted_formulas.set(i, new_n);
|
||||
if (m.proofs_enabled()) {
|
||||
proof_ref new_pr(m);
|
||||
proof_ref new_pr(m);
|
||||
new_pr = m.mk_rewrite(n, new_n);
|
||||
new_pr = m.mk_modus_ponens(pr, new_pr);
|
||||
m_asserted_formula_prs.set(i, new_pr);
|
||||
|
@ -862,7 +869,7 @@ void asserted_formulas::max_bv_sharing() {
|
|||
}
|
||||
reduce_asserted_formulas();
|
||||
TRACE("bv_sharing", display(tout););
|
||||
|
||||
|
||||
}
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue