mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
integrate lambda expressions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
bf4edef761
commit
520ce9a5ee
139 changed files with 2243 additions and 1506 deletions
|
@ -101,7 +101,7 @@ class elim_small_bv_tactic : public tactic {
|
|||
});
|
||||
|
||||
var_subst vsbst(m);
|
||||
vsbst(e, substitution.size(), substitution.c_ptr(), res);
|
||||
res = vsbst(e, substitution.size(), substitution.c_ptr());
|
||||
SASSERT(is_well_sorted(m, res));
|
||||
|
||||
proof_ref pr(m);
|
||||
|
@ -123,6 +123,9 @@ class elim_small_bv_tactic : public tactic {
|
|||
expr * const * new_no_patterns,
|
||||
expr_ref & result,
|
||||
proof_ref & result_pr) {
|
||||
if (is_lambda(q)) {
|
||||
return false;
|
||||
}
|
||||
TRACE("elim_small_bv", tout << "reduce_quantifier " << mk_ismt2_pp(q, m) << std::endl; );
|
||||
unsigned long long num_steps = 0;
|
||||
unsigned curr_sz = m_bindings.size();
|
||||
|
@ -158,8 +161,8 @@ class elim_small_bv_tactic : public tactic {
|
|||
for (unsigned k = 0; k < new_bodies.size(); k++)
|
||||
tout << mk_ismt2_pp(new_bodies[k].get(), m) << std::endl; );
|
||||
|
||||
body = q->is_forall() ? m.mk_and(new_bodies.size(), new_bodies.c_ptr()) :
|
||||
m.mk_or(new_bodies.size(), new_bodies.c_ptr());
|
||||
body = is_forall(q) ? m.mk_and(new_bodies.size(), new_bodies.c_ptr()) :
|
||||
m.mk_or(new_bodies.size(), new_bodies.c_ptr());
|
||||
SASSERT(is_well_sorted(m, body));
|
||||
|
||||
proof_ref pr(m);
|
||||
|
@ -171,7 +174,7 @@ class elim_small_bv_tactic : public tactic {
|
|||
quantifier_ref new_q(m);
|
||||
new_q = m.update_quantifier(q, body);
|
||||
unused_vars_eliminator el(m, m_params);
|
||||
el(new_q, result);
|
||||
result = el(new_q);
|
||||
|
||||
TRACE("elim_small_bv", tout << "elimination result: " << mk_ismt2_pp(result, m) << std::endl; );
|
||||
|
||||
|
|
|
@ -109,10 +109,17 @@ protected:
|
|||
m_stats["quantifiers"]++;
|
||||
SASSERT(is_app(q->get_expr()));
|
||||
app * body = to_app(q->get_expr());
|
||||
if (q->is_forall())
|
||||
switch (q->get_kind()) {
|
||||
case forall_k:
|
||||
m_stats["forall-variables"] += q->get_num_decls();
|
||||
else
|
||||
break;
|
||||
case exists_k:
|
||||
m_stats["exists-variables"] += q->get_num_decls();
|
||||
break;
|
||||
case lambda_k:
|
||||
m_stats["lambda-variables"] += q->get_num_decls();
|
||||
break;
|
||||
}
|
||||
m_stats["patterns"] += q->get_num_patterns();
|
||||
m_stats["no-patterns"] += q->get_num_no_patterns();
|
||||
m_qdepth++;
|
||||
|
|
|
@ -31,7 +31,7 @@ class distribute_forall_tactic : public tactic {
|
|||
expr_ref & result,
|
||||
proof_ref & result_pr) {
|
||||
|
||||
if (!old_q->is_forall()) {
|
||||
if (!is_forall(old_q)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,7 @@ class distribute_forall_tactic : public tactic {
|
|||
expr * not_arg = m.mk_not(arg);
|
||||
quantifier_ref tmp_q(m);
|
||||
tmp_q = m.update_quantifier(old_q, not_arg);
|
||||
expr_ref new_q(m);
|
||||
elim_unused_vars(m, tmp_q, params_ref(), new_q);
|
||||
expr_ref new_q = elim_unused_vars(m, tmp_q, params_ref());
|
||||
new_args.push_back(new_q);
|
||||
}
|
||||
result = m.mk_and(new_args.size(), new_args.c_ptr());
|
||||
|
@ -69,8 +68,7 @@ class distribute_forall_tactic : public tactic {
|
|||
expr * arg = to_app(new_body)->get_arg(i);
|
||||
quantifier_ref tmp_q(m);
|
||||
tmp_q = m.update_quantifier(old_q, arg);
|
||||
expr_ref new_q(m);
|
||||
elim_unused_vars(m, tmp_q, params_ref(), new_q);
|
||||
expr_ref new_q = elim_unused_vars(m, tmp_q, params_ref());
|
||||
new_args.push_back(new_q);
|
||||
}
|
||||
result = m.mk_and(new_args.size(), new_args.c_ptr());
|
||||
|
|
|
@ -337,12 +337,14 @@ expr_ref dom_simplify_tactic::simplify_and_or(bool is_and, app * e) {
|
|||
}
|
||||
args.reverse();
|
||||
}
|
||||
|
||||
pop(scope_level() - old_lvl);
|
||||
r = is_and ? mk_and(args) : mk_or(args);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool dom_simplify_tactic::init(goal& g) {
|
||||
expr_ref_vector args(m);
|
||||
unsigned sz = g.size();
|
||||
|
|
|
@ -5,6 +5,7 @@ Module Name:
|
|||
|
||||
dom_simplify_tactic.cpp
|
||||
|
||||
|
||||
Abstract:
|
||||
|
||||
Dominator-based context simplifer.
|
||||
|
|
|
@ -79,11 +79,11 @@ class injectivity_tactic : public tactic {
|
|||
ast_manager & m() const { return m_manager; }
|
||||
|
||||
bool is_axiom(expr* n, func_decl* &f, func_decl* &g) {
|
||||
if (!is_quantifier(n))
|
||||
if (!is_forall(n))
|
||||
return false;
|
||||
|
||||
quantifier* const q = to_quantifier(n);
|
||||
if (!q->is_forall() || q->get_num_decls() != 1)
|
||||
if (q->get_num_decls() != 1)
|
||||
return false;
|
||||
|
||||
const expr * const body = q->get_expr();
|
||||
|
|
|
@ -474,7 +474,6 @@ class tseitin_cnf_tactic : public tactic {
|
|||
bool sign = m.is_not(_b, _b);
|
||||
if (!m.is_or(_b)) return NO;
|
||||
app* b = to_app(_b);
|
||||
unsigned num = b->get_num_args();
|
||||
if (first) {
|
||||
bool visited = true;
|
||||
visit(a, visited);
|
||||
|
|
|
@ -96,8 +96,7 @@ bool horn_subsume_model_converter::mk_horn(
|
|||
|
||||
// substitute variables directly.
|
||||
if (!subst.empty()) {
|
||||
expr_ref tmp(body_expr);
|
||||
vs(tmp, subst.size(), subst.c_ptr(), body_expr);
|
||||
body_expr = vs(body_expr, subst.size(), subst.c_ptr());
|
||||
}
|
||||
|
||||
if (fv.empty()) {
|
||||
|
@ -123,7 +122,7 @@ bool horn_subsume_model_converter::mk_horn(
|
|||
// formula is closed.
|
||||
DEBUG_CODE(expr_free_vars fv; fv(clause); SASSERT(fv.empty()););
|
||||
|
||||
while (is_quantifier(clause) && to_quantifier(clause)->is_forall()) {
|
||||
while (is_quantifier(clause) && to_quantifier(clause)->get_kind() == forall_k) {
|
||||
quantifier* q = to_quantifier(clause);
|
||||
clause = q->get_expr();
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ private:
|
|||
}
|
||||
else if (is_quantifier(curr.first)) {
|
||||
quantifier *q = to_quantifier(curr.first);
|
||||
if (q->is_forall()) {
|
||||
if (is_forall(q)) {
|
||||
if (q->has_patterns()) {
|
||||
ptr_vector<func_decl> next_consts;
|
||||
if (quantifier_matches(q, consts, next_consts)) {
|
||||
|
@ -199,7 +199,7 @@ private:
|
|||
stack.push_back(work_item(q->get_expr(), curr.second));
|
||||
}
|
||||
}
|
||||
else if (q->is_exists()) {
|
||||
else if (is_exists(q)) {
|
||||
stack.push_back(work_item(q->get_expr(), curr.second));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ ufbv_rewriter::~ufbv_rewriter() {
|
|||
bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small) const {
|
||||
if (e->get_kind() == AST_QUANTIFIER) {
|
||||
quantifier * q = to_quantifier(e);
|
||||
if (q->is_forall()) {
|
||||
if (is_forall(q)) {
|
||||
expr * qe = q->get_expr();
|
||||
if ((m_manager.is_eq(qe) || m_manager.is_iff(qe))) {
|
||||
app * eq = to_app(q->get_expr());
|
||||
|
@ -439,8 +439,7 @@ expr * ufbv_rewriter::rewrite(expr * n) {
|
|||
quantifier_ref q(m_manager);
|
||||
q = m_manager.update_quantifier(to_quantifier(actual), new_body);
|
||||
m_new_exprs.push_back(q);
|
||||
expr_ref new_q(m_manager);
|
||||
elim_unused_vars(m_manager, q, params_ref(), new_q);
|
||||
expr_ref new_q = elim_unused_vars(m_manager, q, params_ref());
|
||||
m_new_exprs.push_back(new_q);
|
||||
rewrite_cache(e, new_q, true);
|
||||
m_rewrite_todo.pop_back();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue