mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 00:55:31 +00:00
mbqi
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
34e0e26e3d
commit
1ee2ba2a9b
17 changed files with 132 additions and 80 deletions
|
@ -37,7 +37,14 @@ namespace mbp {
|
|||
|
||||
ast_manager& m;
|
||||
arith_util a;
|
||||
bool m_check_purified; // check that variables are properly pure
|
||||
bool m_check_purified { true }; // check that variables are properly pure
|
||||
bool m_apply_projection { false };
|
||||
|
||||
|
||||
imp(ast_manager& m) :
|
||||
m(m), a(m) {}
|
||||
|
||||
~imp() {}
|
||||
|
||||
void insert_mul(expr* x, rational const& v, obj_map<expr, rational>& ts) {
|
||||
// TRACE("qe", tout << "Adding variable " << mk_pp(x, m) << " " << v << "\n";);
|
||||
|
@ -238,11 +245,6 @@ namespace mbp {
|
|||
return rational(b.is_pos()?-1:1);
|
||||
}
|
||||
|
||||
imp(ast_manager& m):
|
||||
m(m), a(m), m_check_purified(true) {}
|
||||
|
||||
~imp() {}
|
||||
|
||||
bool operator()(model& model, app* v, app_ref_vector& vars, expr_ref_vector& lits) {
|
||||
app_ref_vector vs(m);
|
||||
vs.push_back(v);
|
||||
|
@ -271,6 +273,7 @@ namespace mbp {
|
|||
model_evaluator eval(model);
|
||||
TRACE("qe", tout << model;);
|
||||
eval.set_model_completion(true);
|
||||
compute_def |= m_apply_projection;
|
||||
|
||||
opt::model_based_opt mbo;
|
||||
obj_map<expr, unsigned> tids;
|
||||
|
@ -341,15 +344,19 @@ namespace mbp {
|
|||
for (unsigned v : real_vars) tout << "v" << v << " " << mk_pp(index2expr[v], m) << "\n";
|
||||
mbo.display(tout););
|
||||
vector<opt::model_based_opt::def> defs = mbo.project(real_vars.size(), real_vars.c_ptr(), compute_def);
|
||||
TRACE("qe", mbo.display(tout << "mbo result\n");
|
||||
for (auto const& d : defs) tout << "def: " << d << "\n";);
|
||||
|
||||
vector<row> rows;
|
||||
mbo.get_live_rows(rows);
|
||||
rows2fmls(rows, index2expr, fmls);
|
||||
TRACE("qe", mbo.display(tout << "mbo result\n");
|
||||
for (auto const& d : defs) tout << "def: " << d << "\n";
|
||||
tout << fmls << "\n";);
|
||||
|
||||
vector<def> result;
|
||||
if (compute_def)
|
||||
optdefs2mbpdef(defs, index2expr, real_vars, result);
|
||||
optdefs2mbpdef(defs, index2expr, real_vars, result);
|
||||
if (m_apply_projection)
|
||||
apply_projection(result, fmls);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -523,6 +530,20 @@ namespace mbp {
|
|||
}
|
||||
}
|
||||
|
||||
void apply_projection(vector<def>& defs, expr_ref_vector& fmls) {
|
||||
if (fmls.empty() || defs.empty())
|
||||
return;
|
||||
expr_safe_replace subst(m);
|
||||
for (auto const& d : defs)
|
||||
subst.insert(d.var, d.term);
|
||||
unsigned j = 0;
|
||||
expr_ref tmp(m);
|
||||
for (expr* fml : fmls) {
|
||||
subst(fml, tmp);
|
||||
fmls[j++] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
arith_project_plugin::arith_project_plugin(ast_manager& m):project_plugin(m) {
|
||||
|
@ -549,6 +570,10 @@ namespace mbp {
|
|||
m_imp->m_check_purified = check_purified;
|
||||
}
|
||||
|
||||
void arith_project_plugin::set_apply_projection(bool f) {
|
||||
m_imp->m_apply_projection = f;
|
||||
}
|
||||
|
||||
family_id arith_project_plugin::get_family_id() {
|
||||
return m_imp->a.get_family_id();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,11 @@ namespace mbp {
|
|||
*/
|
||||
void set_check_purified(bool check_purified);
|
||||
|
||||
/**
|
||||
* \brief apply projection
|
||||
*/
|
||||
void set_apply_projection(bool apply_project);
|
||||
|
||||
};
|
||||
|
||||
bool arith_project(model& model, app* var, expr_ref_vector& lits);
|
||||
|
|
|
@ -327,10 +327,10 @@ namespace mbp {
|
|||
|
||||
void project_plugin::purify(euf_inverter& inv, model& mdl, app_ref_vector const& vars, expr_ref_vector& lits) {
|
||||
TRACE("mbp", tout << lits << "\n" << mdl << "\n";);
|
||||
model_evaluator eval(mdl);
|
||||
extract_literals(mdl, vars, lits);
|
||||
if (!m.inc())
|
||||
return;
|
||||
model_evaluator eval(mdl);
|
||||
eval.set_expand_array_equalities(true);
|
||||
m_non_ground.reset();
|
||||
m_to_visit.reset();
|
||||
|
@ -341,7 +341,6 @@ namespace mbp {
|
|||
m_non_ground.mark(v);
|
||||
for (unsigned i = 0; m.inc() && i < lits.size(); ++i)
|
||||
lits[i] = purify(inv, eval, lits.get(i), lits);
|
||||
std::cout << m_pure_eqs << "\n";
|
||||
lits.append(m_pure_eqs);
|
||||
TRACE("mbp", tout << lits << "\n";);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue