mirror of
https://github.com/Z3Prover/z3
synced 2025-06-20 21:03:39 +00:00
revisit as-array evaluation
This commit is contained in:
parent
38b82fa742
commit
976c0a391c
1 changed files with 42 additions and 30 deletions
|
@ -150,7 +150,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
|
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
|
||||||
auto st = reduce_app_core(f, num, args, result, result_pr);
|
auto st = reduce_app_core(f, num, args, result, result_pr);
|
||||||
CTRACE("model_evaluator", st != BR_FAILED,
|
CTRACE("model_evaluator", st != BR_FAILED,
|
||||||
tout << f->get_name() << " ";
|
tout << st << " " << mk_pp(f, m) << " ";
|
||||||
for (unsigned i = 0; i < num; ++i) tout << mk_pp(args[i], m) << " ";
|
for (unsigned i = 0; i < num; ++i) tout << mk_pp(args[i], m) << " ";
|
||||||
tout << "\n--> " << result << "\n";);
|
tout << "\n--> " << result << "\n";);
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
result_pr = nullptr;
|
result_pr = nullptr;
|
||||||
family_id fid = f->get_family_id();
|
family_id fid = f->get_family_id();
|
||||||
bool _is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
|
bool _is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
|
||||||
|
func_decl* g = nullptr;
|
||||||
br_status st = BR_FAILED;
|
br_status st = BR_FAILED;
|
||||||
#if 0
|
#if 0
|
||||||
struct pp {
|
struct pp {
|
||||||
|
@ -171,6 +172,8 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
};
|
};
|
||||||
pp _pp(f, result);
|
pp _pp(f, result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (num == 0 && (fid == null_family_id || _is_uninterp || m_ar.is_as_array(f))) {
|
if (num == 0 && (fid == null_family_id || _is_uninterp || m_ar.is_as_array(f))) {
|
||||||
expr * val = m_model.get_const_interp(f);
|
expr * val = m_model.get_const_interp(f);
|
||||||
if (val != nullptr) {
|
if (val != nullptr) {
|
||||||
|
@ -243,40 +246,49 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
result = args[0];
|
result = args[0];
|
||||||
st = BR_DONE;
|
st = BR_DONE;
|
||||||
}
|
}
|
||||||
else if (evaluate(f, num, args, result)) {
|
else if (evaluate(f, num, args, result))
|
||||||
st = BR_REWRITE1;
|
st = BR_REWRITE1;
|
||||||
}
|
if (st == BR_FAILED && !m.is_builtin_family_id(fid))
|
||||||
if (st == BR_FAILED && !m.is_builtin_family_id(fid)) {
|
|
||||||
st = evaluate_partial_theory_func(f, num, args, result, result_pr);
|
st = evaluate_partial_theory_func(f, num, args, result, result_pr);
|
||||||
}
|
|
||||||
if (st == BR_DONE && is_app(result)) {
|
if (st == BR_DONE && is_app(result)) {
|
||||||
app* a = to_app(result);
|
app* a = to_app(result);
|
||||||
if (evaluate(a->get_decl(), a->get_num_args(), a->get_args(), result)) {
|
if (evaluate(a->get_decl(), a->get_num_args(), a->get_args(), result))
|
||||||
st = BR_REWRITE1;
|
st = BR_REWRITE1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (st == BR_DONE && is_app(result) && expand_as_array(to_app(result)->get_decl(), result))
|
||||||
|
return BR_REWRITE_FULL;
|
||||||
|
|
||||||
|
if (st == BR_FAILED && expand_as_array(f, result))
|
||||||
|
return BR_REWRITE_FULL;
|
||||||
|
return st;
|
||||||
}
|
}
|
||||||
if (st == BR_FAILED && num == 0 && m_ar.is_as_array(f) && m_model_completion) {
|
|
||||||
|
bool expand_as_array(func_decl* f, expr_ref& result) {
|
||||||
|
if (!m_model_completion)
|
||||||
|
return false;
|
||||||
func_decl* g = nullptr;
|
func_decl* g = nullptr;
|
||||||
VERIFY(m_ar.is_as_array(f, g));
|
if (!m_ar.is_as_array(f, g))
|
||||||
|
return false;
|
||||||
expr* def = nullptr;
|
expr* def = nullptr;
|
||||||
if (m_def_cache.find(g, def)) {
|
if (m_def_cache.find(g, def)) {
|
||||||
result = def;
|
result = def;
|
||||||
TRACE("model_evaluator", tout << result << "\n";);
|
TRACE("model_evaluator", tout << result << "\n";);
|
||||||
return BR_DONE;
|
return true;
|
||||||
}
|
}
|
||||||
func_interp * fi = m_model.get_func_interp(g);
|
expr_ref tmp(m);
|
||||||
if (fi && (result = fi->get_array_interp(g))) {
|
func_interp* fi = m_model.get_func_interp(g);
|
||||||
|
if (fi && (tmp = fi->get_array_interp(g))) {
|
||||||
model_evaluator ev(m_model, m_params);
|
model_evaluator ev(m_model, m_params);
|
||||||
ev.set_model_completion(false);
|
ev.set_model_completion(false);
|
||||||
result = ev(result);
|
result = ev(tmp);
|
||||||
m_pinned.push_back(result);
|
m_pinned.push_back(result);
|
||||||
m_def_cache.insert(g, result);
|
m_def_cache.insert(g, result);
|
||||||
TRACE("model_evaluator", tout << mk_pp(g, m) << " " << result << "\n";);
|
TRACE("model_evaluator", tout << mk_pp(g, m) << " " << result << "\n";);
|
||||||
return BR_DONE;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return st;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void expand_stores(expr_ref& val) {
|
void expand_stores(expr_ref& val) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue