mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
parent
c4b52edb29
commit
1fce2905ec
4 changed files with 24 additions and 9 deletions
|
@ -190,13 +190,17 @@ namespace datalog {
|
||||||
m_g_vars.push_back(m_f_vars.back());
|
m_g_vars.push_back(m_f_vars.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (f->get_family_id() != null_family_id) {
|
||||||
|
return BR_FAILED;
|
||||||
|
}
|
||||||
func_decl* g = nullptr;
|
func_decl* g = nullptr;
|
||||||
|
|
||||||
|
|
||||||
if (!m_pred2blast.find(f, g)) {
|
if (!m_pred2blast.find(f, g)) {
|
||||||
|
|
||||||
ptr_vector<sort> domain;
|
ptr_vector<sort> domain;
|
||||||
for (unsigned i = 0; i < m_args.size(); ++i) {
|
for (expr* arg : m_args) {
|
||||||
domain.push_back(m.get_sort(m_args[i].get()));
|
domain.push_back(m.get_sort(arg));
|
||||||
}
|
}
|
||||||
g = m_context.mk_fresh_head_predicate(f->get_name(), symbol("bv"), m_args.size(), domain.c_ptr(), f);
|
g = m_context.mk_fresh_head_predicate(f->get_name(), symbol("bv"), m_args.size(), domain.c_ptr(), f);
|
||||||
m_old_funcs.push_back(f);
|
m_old_funcs.push_back(f);
|
||||||
|
@ -205,7 +209,7 @@ namespace datalog {
|
||||||
|
|
||||||
m_dst->inherit_predicate(*m_src, f, g);
|
m_dst->inherit_predicate(*m_src, f, g);
|
||||||
}
|
}
|
||||||
result = m.mk_app(g, m_args.size(), m_args.c_ptr());
|
result = m.mk_app(g, m_args);
|
||||||
result_pr = nullptr;
|
result_pr = nullptr;
|
||||||
return BR_DONE;
|
return BR_DONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,8 @@ namespace datalog {
|
||||||
|
|
||||||
tgt.norm_vars(m_context.get_rule_manager());
|
tgt.norm_vars(m_context.get_rule_manager());
|
||||||
|
|
||||||
SASSERT(!has_quantifier(src));
|
if (has_quantifier(src))
|
||||||
|
throw has_new_quantifier();
|
||||||
|
|
||||||
if (!m_unifier.unify_rules(tgt, tail_index, src)) {
|
if (!m_unifier.unify_rules(tgt, tail_index, src)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -425,7 +426,11 @@ namespace datalog {
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (; i < pt_len && !inlining_allowed(orig, r->get_decl(i)); ++i) {};
|
for (; i < pt_len && !inlining_allowed(orig, r->get_decl(i)); ++i) {};
|
||||||
|
|
||||||
SASSERT(!has_quantifier(*r.get()));
|
CTRACE("dl", has_quantifier(*r.get()), r->display(m_context, tout););
|
||||||
|
if (has_quantifier(*r.get())) {
|
||||||
|
tgt.add_rule(r);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == pt_len) {
|
if (i == pt_len) {
|
||||||
//there's nothing we can inline in this rule
|
//there's nothing we can inline in this rule
|
||||||
|
@ -842,7 +847,12 @@ namespace datalog {
|
||||||
if (m_context.get_params().xform_inline_eager()) {
|
if (m_context.get_params().xform_inline_eager()) {
|
||||||
TRACE("dl", source.display(tout << "before eager inlining\n"););
|
TRACE("dl", source.display(tout << "before eager inlining\n"););
|
||||||
plan_inlining(source);
|
plan_inlining(source);
|
||||||
something_done = transform_rules(source, *res);
|
try {
|
||||||
|
something_done = transform_rules(source, *res);
|
||||||
|
}
|
||||||
|
catch (has_new_quantifier) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
VERIFY(res->close()); //this transformation doesn't break the negation stratification
|
VERIFY(res->close()); //this transformation doesn't break the negation stratification
|
||||||
// try eager inlining
|
// try eager inlining
|
||||||
if (do_eager_inlining(res)) {
|
if (do_eager_inlining(res)) {
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace datalog {
|
||||||
|
|
||||||
class mk_rule_inliner : public rule_transformer::plugin {
|
class mk_rule_inliner : public rule_transformer::plugin {
|
||||||
|
|
||||||
|
struct has_new_quantifier {};
|
||||||
|
|
||||||
class visitor : public st_visitor {
|
class visitor : public st_visitor {
|
||||||
context& m_context;
|
context& m_context;
|
||||||
unsigned_vector m_unifiers;
|
unsigned_vector m_unifiers;
|
||||||
|
|
|
@ -166,8 +166,7 @@ std::pair<unsigned, int> theory_arith<Ext>::analyze_monomial(expr * m) const {
|
||||||
unsigned c = 0;
|
unsigned c = 0;
|
||||||
int free_var_idx = -1;
|
int free_var_idx = -1;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (unsigned i = 0; i < to_app(m)->get_num_args(); i++) {
|
for (expr * arg : *to_app(m)) {
|
||||||
expr * arg = to_app(m)->get_arg(i);
|
|
||||||
if (m_util.is_numeral(arg))
|
if (m_util.is_numeral(arg))
|
||||||
continue;
|
continue;
|
||||||
if (var == nullptr) {
|
if (var == nullptr) {
|
||||||
|
@ -202,7 +201,7 @@ std::pair<unsigned, int> theory_arith<Ext>::analyze_monomial(expr * m) const {
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
expr * theory_arith<Ext>::get_monomial_body(expr * m) const {
|
expr * theory_arith<Ext>::get_monomial_body(expr * m) const {
|
||||||
SASSERT(m_util.is_mul(m));
|
SASSERT(m_util.is_mul(m));
|
||||||
if (m_util.is_numeral(to_app(m)->get_arg(0)))
|
if (to_app(m)->get_num_args() == 2 && m_util.is_numeral(to_app(m)->get_arg(0)))
|
||||||
return to_app(m)->get_arg(1);
|
return to_app(m)->get_arg(1);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue