mirror of
https://github.com/Z3Prover/z3
synced 2025-06-05 21:53:23 +00:00
updates
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
6e61a7c1b2
commit
44a32bc076
3 changed files with 160 additions and 113 deletions
|
@ -19,12 +19,32 @@ Revision History:
|
||||||
--*/
|
--*/
|
||||||
|
|
||||||
#include "ast/ast_util.h"
|
#include "ast/ast_util.h"
|
||||||
|
#include "ast/rewriter/bool_rewriter.h"
|
||||||
#include "solver/solver.h"
|
#include "solver/solver.h"
|
||||||
#include "qe/qe_mbi.h"
|
#include "qe/qe_mbi.h"
|
||||||
|
|
||||||
|
|
||||||
namespace qe {
|
namespace qe {
|
||||||
|
|
||||||
|
lbool mbi_plugin::check(func_decl_ref_vector const& vars, expr_ref_vector& lits, model_ref& mdl) {
|
||||||
|
SASSERT(lits.empty());
|
||||||
|
while (true) {
|
||||||
|
switch ((*this)(vars, lits, mdl)) {
|
||||||
|
case mbi_sat:
|
||||||
|
return l_true;
|
||||||
|
case mbi_unsat:
|
||||||
|
if (lits.empty()) return l_false;
|
||||||
|
block(lits);
|
||||||
|
break;
|
||||||
|
case mbi_undef:
|
||||||
|
return l_undef;
|
||||||
|
case mbi_augment:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// prop_mbi
|
// prop_mbi
|
||||||
|
|
||||||
|
@ -116,6 +136,7 @@ namespace qe {
|
||||||
blocks.push_back(expr_ref_vector(m));
|
blocks.push_back(expr_ref_vector(m));
|
||||||
blocks.push_back(expr_ref_vector(m));
|
blocks.push_back(expr_ref_vector(m));
|
||||||
mbi_result last_res = mbi_undef;
|
mbi_result last_res = mbi_undef;
|
||||||
|
bool_rewriter rw(m);
|
||||||
while (true) {
|
while (true) {
|
||||||
auto* t1 = turn ? &a : &b;
|
auto* t1 = turn ? &a : &b;
|
||||||
auto* t2 = turn ? &b : &a;
|
auto* t2 = turn ? &b : &a;
|
||||||
|
@ -156,10 +177,32 @@ namespace qe {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TBD: also implement the one-sided versions that create clausal interpolants.
|
* One-sided pogo creates clausal interpolants.
|
||||||
|
* It creates a set of consequences of b that are inconsistent with a.
|
||||||
*/
|
*/
|
||||||
lbool interpolator::pogo(mbi_plugin& a, mbi_plugin& b, func_decl_ref_vector const& vars, expr_ref& itp) {
|
lbool interpolator::pogo(mbi_plugin& a, mbi_plugin& b, func_decl_ref_vector const& vars, expr_ref& itp) {
|
||||||
NOT_IMPLEMENTED_YET();
|
expr_ref_vector lits(m), itps(m);
|
||||||
return l_undef;
|
while (true) {
|
||||||
|
model_ref mdl;
|
||||||
|
lits.reset();
|
||||||
|
switch (a.check(vars, lits, mdl)) {
|
||||||
|
case l_true:
|
||||||
|
switch (b.check(vars, lits, mdl)) {
|
||||||
|
case l_true:
|
||||||
|
return l_true;
|
||||||
|
case l_false:
|
||||||
|
a.block(lits);
|
||||||
|
itps.push_back(mk_not(mk_and(lits)));
|
||||||
|
break;
|
||||||
|
case l_undef:
|
||||||
|
return l_undef;
|
||||||
|
}
|
||||||
|
case l_false:
|
||||||
|
itp = mk_and(itps);
|
||||||
|
return l_false;
|
||||||
|
case l_undef:
|
||||||
|
return l_undef;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,6 +56,12 @@ namespace qe {
|
||||||
* \brief Block conjunction of lits from future mbi_augment or mbi_sat.
|
* \brief Block conjunction of lits from future mbi_augment or mbi_sat.
|
||||||
*/
|
*/
|
||||||
virtual void block(expr_ref_vector const& lits) = 0;
|
virtual void block(expr_ref_vector const& lits) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief perform a full check, consume internal auguments if necessary.
|
||||||
|
*/
|
||||||
|
lbool check(func_decl_ref_vector const& vars, expr_ref_vector& lits, model_ref& mdl);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class prop_mbi_plugin : public mbi_plugin {
|
class prop_mbi_plugin : public mbi_plugin {
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace qe {
|
||||||
};
|
};
|
||||||
|
|
||||||
class children {
|
class children {
|
||||||
term const& t;
|
term const& t;
|
||||||
public:
|
public:
|
||||||
children(term const& _t):t(_t) {}
|
children(term const& _t):t(_t) {}
|
||||||
children(term const* _t):t(*_t) {}
|
children(term const* _t):t(*_t) {}
|
||||||
|
@ -395,7 +395,7 @@ namespace qe {
|
||||||
|
|
||||||
void term_graph::internalize_eq(expr *a1, expr* a2) {
|
void term_graph::internalize_eq(expr *a1, expr* a2) {
|
||||||
SASSERT(m_merge.empty());
|
SASSERT(m_merge.empty());
|
||||||
merge(internalize_term(a1)->get_root(), internalize_term(a2)->get_root());
|
merge(*internalize_term(a1), *internalize_term(a2));
|
||||||
merge_flush();
|
merge_flush();
|
||||||
SASSERT(m_merge.empty());
|
SASSERT(m_merge.empty());
|
||||||
}
|
}
|
||||||
|
@ -424,13 +424,11 @@ namespace qe {
|
||||||
m_term2app.reset();
|
m_term2app.reset();
|
||||||
m_pinned.reset();
|
m_pinned.reset();
|
||||||
|
|
||||||
SASSERT(t1.is_root());
|
term *a = &t1.get_root();
|
||||||
SASSERT(t2.is_root());
|
term *b = &t2.get_root();
|
||||||
|
|
||||||
if (&t1 == &t2) return;
|
if (a == b) return;
|
||||||
|
|
||||||
term *a = &t1;
|
|
||||||
term *b = &t2;
|
|
||||||
if (a->get_class_size() > b->get_class_size()) {
|
if (a->get_class_size() > b->get_class_size()) {
|
||||||
std::swap(a, b);
|
std::swap(a, b);
|
||||||
}
|
}
|
||||||
|
@ -544,7 +542,7 @@ namespace qe {
|
||||||
// prefer uninterpreted constants over values
|
// prefer uninterpreted constants over values
|
||||||
// prefer smaller expressions over larger ones
|
// prefer smaller expressions over larger ones
|
||||||
if (t1.get_num_args() == 0 || t2.get_num_args() == 0) {
|
if (t1.get_num_args() == 0 || t2.get_num_args() == 0) {
|
||||||
if (t1.get_num_args() == t2.get_num_args()) {
|
if (t1.get_num_args() == t2.get_num_args()) {
|
||||||
// t1.get_num_args() == t2.get_num_args() == 0
|
// t1.get_num_args() == t2.get_num_args() == 0
|
||||||
if (m.is_value(t1.get_expr()) == m.is_value(t2.get_expr()))
|
if (m.is_value(t1.get_expr()) == m.is_value(t2.get_expr()))
|
||||||
return t1.get_id() < t2.get_id();
|
return t1.get_id() < t2.get_id();
|
||||||
|
@ -649,7 +647,7 @@ namespace qe {
|
||||||
// use work-list + marking to propagate.
|
// use work-list + marking to propagate.
|
||||||
// - produce equalities over represented classes.
|
// - produce equalities over represented classes.
|
||||||
// - produce other literals over represented classes
|
// - produce other literals over represented classes
|
||||||
// (walk disequalities in m_lits and represent lhs/rhs over decls or excluding decls)
|
// (walk disequalities in m_lits and represent lhs/rhs over decls or excluding decls)
|
||||||
|
|
||||||
expr_ref_vector result(m);
|
expr_ref_vector result(m);
|
||||||
m_term2app.reset();
|
m_term2app.reset();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue