3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

tune q-eval and q-ematch

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-09-28 13:41:37 -07:00
parent 92c1b600c3
commit da124e4275
7 changed files with 119 additions and 36 deletions

View file

@ -18,9 +18,10 @@ Revision History:
--*/
#include "ast/ast.h"
#include "ast/expr_delta_pair.h"
#include "ast/has_free_vars.h"
#include "util/hashtable.h"
class contains_vars {
class contains_vars::imp {
typedef hashtable<expr_delta_pair, obj_hash<expr_delta_pair>, default_eq<expr_delta_pair> > cache;
cache m_cache;
svector<expr_delta_pair> m_todo;
@ -86,6 +87,18 @@ public:
}
};
contains_vars::contains_vars() {
m_imp = alloc(imp);
}
contains_vars::~contains_vars() {
dealloc(m_imp);
}
bool contains_vars::operator()(expr* e) {
return (*m_imp)(e);
}
bool has_free_vars(expr * n) {
contains_vars p;
return p(n);

View file

@ -20,6 +20,15 @@ Revision History:
class expr;
class contains_vars {
class imp;
imp* m_imp;
public:
contains_vars();
~contains_vars();
bool operator()(expr* n);
};
bool has_free_vars(expr * n);

View file

@ -20,6 +20,7 @@ Notes:
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/rewriter_def.h"
#include "ast/ast_pp.h"
#include "ast/ast_util.h"
struct pull_quant::imp {
@ -50,7 +51,7 @@ struct pull_quant::imp {
quantifier * q = to_quantifier(child);
expr * body = q->get_expr();
quantifier_kind k = q->get_kind() == forall_k ? exists_k : forall_k;
result = m.update_quantifier(q, k, m.mk_not(body));
result = m.update_quantifier(q, k, mk_not(m, body));
return true;
}
else {
@ -78,9 +79,8 @@ struct pull_quant::imp {
qid = nested_q->get_qid();
}
w = std::min(w, nested_q->get_weight());
unsigned j = nested_q->get_num_decls();
while (j > 0) {
--j;
for (unsigned j = nested_q->get_num_decls(); j-- > 0; ) {
var_sorts.push_back(nested_q->get_decl_sort(j));
symbol s = nested_q->get_decl_name(j);
if (std::find(var_names.begin(), var_names.end(), s) != var_names.end())
@ -254,6 +254,10 @@ struct pull_quant::imp {
}
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
if (m.is_not(f) && m.is_not(args[0])) {
result = to_app(args[0])->get_arg(0);
return BR_REWRITE1;
}
if (!m.is_or(f) && !m.is_and(f) && !m.is_not(f))
return BR_FAILED;
@ -275,7 +279,7 @@ struct pull_quant::imp {
proof_ref & result_pr) {
if (is_exists(old_q)) {
result = m.mk_not(new_body);
result = mk_not(m, new_body);
result = m.mk_not(m.update_quantifier(old_q, forall_k, result));
if (m.proofs_enabled())
m.mk_rewrite(old_q, result);