mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
better encodings for at-most-1, #755
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
5d9820f3e2
commit
8d2b70a5e2
17 changed files with 232 additions and 253 deletions
|
@ -138,63 +138,6 @@ lbool solver::get_consequences_core(expr_ref_vector const& asms, expr_ref_vector
|
|||
|
||||
lbool solver::find_mutexes(expr_ref_vector const& vars, vector<expr_ref_vector>& mutexes) {
|
||||
return l_true;
|
||||
#if 0
|
||||
// complete for literals, but inefficient.
|
||||
// see more efficient (incomplete) version in sat_solver
|
||||
|
||||
mutexes.reset();
|
||||
ast_manager& m = vars.get_manager();
|
||||
|
||||
typedef obj_hashtable<expr> expr_set;
|
||||
|
||||
expr_set A, P;
|
||||
|
||||
for (unsigned i = 0; i < vars.size(); ++i) {
|
||||
A.insert(vars[i]);
|
||||
}
|
||||
|
||||
while (!A.empty()) {
|
||||
P = A;
|
||||
expr_ref_vector mutex(m);
|
||||
while (!P.empty()) {
|
||||
expr_ref_vector asms(m);
|
||||
expr* p = *P.begin();
|
||||
P.remove(p);
|
||||
if (!is_literal(m, p)) {
|
||||
break;
|
||||
}
|
||||
mutex.push_back(p);
|
||||
asms.push_back(p);
|
||||
expr_set Q;
|
||||
expr_set::iterator it = P.begin(), end = P.end();
|
||||
for (; it != end; ++it) {
|
||||
expr* q = *it;
|
||||
scoped_assumption_push _scoped_push(asms, q);
|
||||
if (is_literal(m, q)) {
|
||||
lbool is_sat = check_sat(asms);
|
||||
switch (is_sat) {
|
||||
case l_false:
|
||||
Q.insert(q);
|
||||
break;
|
||||
case l_true:
|
||||
break;
|
||||
case l_undef:
|
||||
return l_undef;
|
||||
}
|
||||
}
|
||||
}
|
||||
P = Q;
|
||||
}
|
||||
if (mutex.size() > 1) {
|
||||
mutexes.push_back(mutex);
|
||||
}
|
||||
for (unsigned i = 0; i < mutex.size(); ++i) {
|
||||
A.remove(mutex[i].get());
|
||||
}
|
||||
}
|
||||
return l_true;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
bool solver::is_literal(ast_manager& m, expr* e) {
|
||||
|
|
|
@ -22,6 +22,7 @@ Notes:
|
|||
#include"solver_na2as.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
|
||||
|
||||
solver_na2as::solver_na2as(ast_manager & m):
|
||||
m(m),
|
||||
m_assumptions(m) {
|
||||
|
@ -71,6 +72,11 @@ lbool solver_na2as::get_consequences(expr_ref_vector const& asms, expr_ref_vecto
|
|||
return get_consequences_core(m_assumptions, vars, consequences);
|
||||
}
|
||||
|
||||
lbool solver_na2as::find_mutexes(expr_ref_vector const& vars, vector<expr_ref_vector>& mutexes) {
|
||||
return l_true;
|
||||
}
|
||||
|
||||
|
||||
void solver_na2as::push() {
|
||||
m_scopes.push_back(m_assumptions.size());
|
||||
push_core();
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
virtual unsigned get_num_assumptions() const { return m_assumptions.size(); }
|
||||
virtual expr * get_assumption(unsigned idx) const { return m_assumptions[idx]; }
|
||||
virtual lbool get_consequences(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences);
|
||||
virtual lbool find_mutexes(expr_ref_vector const& vars, vector<expr_ref_vector>& mutexes);
|
||||
protected:
|
||||
virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) = 0;
|
||||
virtual void push_core() = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue