mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Merge branch 'master' of https://github.com/Z3Prover/z3
This commit is contained in:
commit
46df31babf
25 changed files with 151 additions and 121 deletions
|
@ -113,6 +113,8 @@ unsigned arith_eq_solver::find_abs_min(vector<numeral>& values) {
|
|||
return index;
|
||||
}
|
||||
|
||||
#ifdef _TRACE
|
||||
|
||||
static void print_row(std::ostream& out, vector<rational> const& row) {
|
||||
for(unsigned i = 0; i < row.size(); ++i) {
|
||||
out << row[i] << " ";
|
||||
|
@ -125,6 +127,7 @@ static void print_rows(std::ostream& out, vector<vector<rational> > const& rows)
|
|||
print_row(out, rows[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// The gcd of the coefficients to variables have to divide the
|
||||
|
|
|
@ -490,6 +490,7 @@ namespace smt {
|
|||
#ifdef _PROFILE_MAM
|
||||
m_counter = 0;
|
||||
#endif
|
||||
(void)m_lbl_hasher;
|
||||
}
|
||||
|
||||
#ifdef _PROFILE_MAM
|
||||
|
@ -2881,6 +2882,7 @@ namespace smt {
|
|||
- first_idx: index to be used as head of the multi-pattern mp
|
||||
*/
|
||||
void add_pattern(quantifier * qa, app * mp, unsigned first_idx) {
|
||||
(void)m_ast_manager;
|
||||
SASSERT(m_ast_manager.is_pattern(mp));
|
||||
SASSERT(first_idx < mp->get_num_args());
|
||||
app * p = to_app(mp->get_arg(first_idx));
|
||||
|
|
|
@ -566,8 +566,7 @@ namespace smt {
|
|||
TRACE("context", tout << "checking: " << mk_pp(conseq[i], m) << "\n";);
|
||||
tmp = m.mk_not(conseq[i]);
|
||||
assert_expr(tmp);
|
||||
lbool is_sat = check();
|
||||
SASSERT(is_sat != l_true);
|
||||
VERIFY(check() != l_true);
|
||||
pop(1);
|
||||
}
|
||||
model_ref mdl;
|
||||
|
|
|
@ -335,23 +335,6 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
|
||||
static bool find_arg(app * n, expr * t, expr * & other) {
|
||||
SASSERT(n->get_num_args() == 2);
|
||||
if (n->get_arg(0) == t) {
|
||||
other = n->get_arg(1);
|
||||
return true;
|
||||
}
|
||||
else if (n->get_arg(1) == t) {
|
||||
other = n->get_arg(0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool check_args(app * n, expr * t1, expr * t2) {
|
||||
SASSERT(n->get_num_args() == 2);
|
||||
return (n->get_arg(0) == t1 && n->get_arg(1) == t2) || (n->get_arg(1) == t1 && n->get_arg(0) == t2);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Internalize the given formula into the logical context.
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace smt {
|
|||
|
||||
public:
|
||||
fpa_rm_value_proc(theory_fpa * th) :
|
||||
m_th(*th), m(th->get_manager()), m_fu(th->m_fpa_util), m_bu(th->m_bv_util) {}
|
||||
m_th(*th), m(th->get_manager()), m_fu(th->m_fpa_util), m_bu(th->m_bv_util) { (void) m_th; }
|
||||
|
||||
void add_dependency(enode * e) { m_deps.push_back(model_value_dependency(e)); }
|
||||
|
||||
|
|
|
@ -527,7 +527,8 @@ namespace smt {
|
|||
c->m_compilation_threshold = UINT_MAX;
|
||||
}
|
||||
init_watch_var(*c);
|
||||
m_ineqs.insert(abv, c);
|
||||
init_watch(abv);
|
||||
m_var_infos[abv].m_ineq = c;
|
||||
m_ineqs_trail.push_back(abv);
|
||||
|
||||
if (m_enable_simplex) {
|
||||
|
@ -687,35 +688,43 @@ namespace smt {
|
|||
watch_literal(lit, &c);
|
||||
}
|
||||
|
||||
void theory_pb::init_watch(bool_var v) {
|
||||
if (m_var_infos.size() <= static_cast<unsigned>(v)) {
|
||||
m_var_infos.resize(static_cast<unsigned>(v)+100);
|
||||
}
|
||||
}
|
||||
|
||||
void theory_pb::watch_literal(literal lit, ineq* c) {
|
||||
ptr_vector<ineq>* ineqs;
|
||||
if (!m_lwatch.find(lit.index(), ineqs)) {
|
||||
init_watch(lit.var());
|
||||
ptr_vector<ineq>* ineqs = m_var_infos[lit.var()].m_lit_watch[lit.sign()];
|
||||
if (ineqs == 0) {
|
||||
ineqs = alloc(ptr_vector<ineq>);
|
||||
m_lwatch.insert(lit.index(), ineqs);
|
||||
m_var_infos[lit.var()].m_lit_watch[lit.sign()] = ineqs;
|
||||
}
|
||||
ineqs->push_back(c);
|
||||
}
|
||||
|
||||
void theory_pb::watch_var(bool_var v, ineq* c) {
|
||||
ptr_vector<ineq>* ineqs;
|
||||
if (!m_vwatch.find(v, ineqs)) {
|
||||
init_watch(v);
|
||||
ptr_vector<ineq>* ineqs = m_var_infos[v].m_var_watch;
|
||||
if (ineqs == 0) {
|
||||
ineqs = alloc(ptr_vector<ineq>);
|
||||
m_vwatch.insert(v, ineqs);
|
||||
m_var_infos[v].m_var_watch = ineqs;
|
||||
}
|
||||
ineqs->push_back(c);
|
||||
}
|
||||
|
||||
void theory_pb::unwatch_var(bool_var v, ineq* c) {
|
||||
ptr_vector<ineq>* ineqs = 0;
|
||||
if (m_vwatch.find(v, ineqs)) {
|
||||
ptr_vector<ineq>* ineqs = m_var_infos[v].m_var_watch;
|
||||
if (ineqs) {
|
||||
remove(*ineqs, c);
|
||||
}
|
||||
}
|
||||
|
||||
void theory_pb::unwatch_literal(literal w, ineq* c) {
|
||||
ptr_vector<ineq>* ineqs = 0;
|
||||
if (m_lwatch.find(w.index(), ineqs)) {
|
||||
remove(*ineqs, c);
|
||||
void theory_pb::unwatch_literal(literal lit, ineq* c) {
|
||||
ptr_vector<ineq>* ineqs = m_var_infos[lit.var()].m_lit_watch[lit.sign()];
|
||||
if (ineqs) {
|
||||
remove(*ineqs, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -741,22 +750,9 @@ namespace smt {
|
|||
|
||||
void theory_pb::reset_eh() {
|
||||
|
||||
// m_watch;
|
||||
u_map<ptr_vector<ineq>*>::iterator it = m_lwatch.begin(), end = m_lwatch.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
for (unsigned i = 0; i < m_var_infos.size(); ++i) {
|
||||
m_var_infos[i].reset();
|
||||
}
|
||||
it = m_vwatch.begin(), end = m_vwatch.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
}
|
||||
u_map<ineq*>::iterator itc = m_ineqs.begin(), endc = m_ineqs.end();
|
||||
for (; itc != endc; ++itc) {
|
||||
dealloc(itc->m_value);
|
||||
}
|
||||
m_lwatch.reset();
|
||||
m_vwatch.reset();
|
||||
m_ineqs.reset();
|
||||
m_ineqs_trail.reset();
|
||||
m_ineqs_lim.reset();
|
||||
m_stats.reset();
|
||||
|
@ -777,7 +773,8 @@ namespace smt {
|
|||
ptr_vector<ineq>* ineqs = 0;
|
||||
literal nlit(v, is_true);
|
||||
TRACE("pb", tout << "assign: " << ~nlit << "\n";);
|
||||
if (m_lwatch.find(nlit.index(), ineqs)) {
|
||||
ineqs = m_var_infos[v].m_lit_watch[nlit.sign()];
|
||||
if (ineqs != 0) {
|
||||
if (m_enable_simplex) {
|
||||
mpq_inf num(mpq(is_true?1:0),mpq(0));
|
||||
if (!update_bound(v, ~nlit, is_true, num)) {
|
||||
|
@ -797,14 +794,15 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (m_vwatch.find(v, ineqs)) {
|
||||
ineqs = m_var_infos[v].m_var_watch;
|
||||
if (ineqs != 0) {
|
||||
for (unsigned i = 0; i < ineqs->size(); ++i) {
|
||||
ineq* c = (*ineqs)[i];
|
||||
assign_watch(v, is_true, *c);
|
||||
}
|
||||
}
|
||||
ineq* c = 0;
|
||||
if (m_ineqs.find(v, c)) {
|
||||
ineq* c = m_var_infos[v].m_ineq;
|
||||
if (c != 0) {
|
||||
if (m_enable_simplex) {
|
||||
row_info const& info = m_ineq_row_info.find(v);
|
||||
scoped_eps_numeral coeff(m_mpq_inf_mgr);
|
||||
|
@ -1317,10 +1315,9 @@ namespace smt {
|
|||
unsigned sz = m_ineqs_lim[new_lim];
|
||||
while (m_ineqs_trail.size() > sz) {
|
||||
bool_var v = m_ineqs_trail.back();
|
||||
ineq* c = 0;
|
||||
VERIFY(m_ineqs.find(v, c));
|
||||
ineq* c = m_var_infos[v].m_ineq;
|
||||
clear_watch(*c);
|
||||
m_ineqs.remove(v);
|
||||
m_var_infos[v].m_ineq = 0;
|
||||
m_ineqs_trail.pop_back();
|
||||
if (m_enable_simplex) {
|
||||
row_info r_info;
|
||||
|
@ -1866,9 +1863,11 @@ namespace smt {
|
|||
}
|
||||
|
||||
void theory_pb::validate_final_check() {
|
||||
u_map<ineq*>::iterator itc = m_ineqs.begin(), endc = m_ineqs.end();
|
||||
for (; itc != endc; ++itc) {
|
||||
validate_final_check(*itc->m_value);
|
||||
for (unsigned i = 0; i < m_var_infos.size(); ++i) {
|
||||
ineq* c = m_var_infos[i].m_ineq;
|
||||
if (c) {
|
||||
validate_final_check(*c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2076,29 +2075,37 @@ namespace smt {
|
|||
return p;
|
||||
}
|
||||
|
||||
void theory_pb::display_watch(std::ostream& out, bool_var v, bool sign) const {
|
||||
watch_list const* w = m_var_infos[v].m_lit_watch[sign];
|
||||
if (!w) return;
|
||||
watch_list const& wl = *w;
|
||||
out << "watch: " << literal(v, sign) << " |-> ";
|
||||
for (unsigned i = 0; i < wl.size(); ++i) {
|
||||
out << wl[i]->lit() << " ";
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
void theory_pb::display(std::ostream& out) const {
|
||||
u_map<ptr_vector<ineq>*>::iterator it = m_lwatch.begin(), end = m_lwatch.end();
|
||||
for (; it != end; ++it) {
|
||||
out << "watch: " << to_literal(it->m_key) << " |-> ";
|
||||
watch_list const& wl = *it->m_value;
|
||||
for (unsigned vi = 0; vi < m_var_infos.size(); ++vi) {
|
||||
display_watch(out, vi, false);
|
||||
display_watch(out, vi, true);
|
||||
}
|
||||
for (unsigned vi = 0; vi < m_var_infos.size(); ++vi) {
|
||||
watch_list const* w = m_var_infos[vi].m_var_watch;
|
||||
if (!w) continue;
|
||||
out << "watch (v): " << literal(vi) << " |-> ";
|
||||
watch_list const& wl = *w;
|
||||
for (unsigned i = 0; i < wl.size(); ++i) {
|
||||
out << wl[i]->lit() << " ";
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
it = m_vwatch.begin(), end = m_vwatch.end();
|
||||
for (; it != end; ++it) {
|
||||
out << "watch (v): " << literal(it->m_key) << " |-> ";
|
||||
watch_list const& wl = *it->m_value;
|
||||
for (unsigned i = 0; i < wl.size(); ++i) {
|
||||
out << wl[i]->lit() << " ";
|
||||
for (unsigned vi = 0; vi < m_var_infos.size(); ++vi) {
|
||||
ineq* c = m_var_infos[vi].m_ineq;
|
||||
if (c) {
|
||||
display(out, *c, true);
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
u_map<ineq*>::iterator itc = m_ineqs.begin(), endc = m_ineqs.end();
|
||||
for (; itc != endc; ++itc) {
|
||||
ineq& c = *itc->m_value;
|
||||
display(out, c, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,10 +193,32 @@ namespace smt {
|
|||
typedef ptr_vector<ineq> watch_list;
|
||||
typedef map<arg_t, bool_var, arg_t::hash, arg_t::eq> arg_map;
|
||||
|
||||
struct var_info {
|
||||
watch_list* m_lit_watch[2];
|
||||
watch_list* m_var_watch;
|
||||
ineq* m_ineq;
|
||||
|
||||
var_info(): m_var_watch(0), m_ineq(0)
|
||||
{
|
||||
m_lit_watch[0] = 0;
|
||||
m_lit_watch[1] = 0;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
dealloc(m_lit_watch[0]);
|
||||
dealloc(m_lit_watch[1]);
|
||||
dealloc(m_var_watch);
|
||||
dealloc(m_ineq);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
theory_pb_params m_params;
|
||||
u_map<watch_list*> m_lwatch; // per literal.
|
||||
u_map<watch_list*> m_vwatch; // per variable.
|
||||
u_map<ineq*> m_ineqs; // per inequality.
|
||||
|
||||
svector<var_info> m_var_infos;
|
||||
// u_map<watch_list*> m_lwatch; // per literal.
|
||||
// u_map<watch_list*> m_vwatch; // per variable.
|
||||
// u_map<ineq*> m_ineqs; // per inequality.
|
||||
arg_map m_ineq_rep; // Simplex: representative inequality
|
||||
u_map<row_info> m_ineq_row_info; // Simplex: row information per variable
|
||||
uint_set m_vars; // Simplex: 0-1 variables.
|
||||
|
@ -221,6 +243,7 @@ namespace smt {
|
|||
literal compile_arg(expr* arg);
|
||||
void add_watch(ineq& c, unsigned index);
|
||||
void del_watch(watch_list& watch, unsigned index, ineq& c, unsigned ineq_index);
|
||||
void init_watch(bool_var v);
|
||||
void init_watch_literal(ineq& c);
|
||||
void init_watch_var(ineq& c);
|
||||
void clear_watch(ineq& c);
|
||||
|
@ -242,6 +265,7 @@ namespace smt {
|
|||
std::ostream& display(std::ostream& out, ineq const& c, bool values = false) const;
|
||||
std::ostream& display(std::ostream& out, arg_t const& c, bool values = false) const;
|
||||
virtual void display(std::ostream& out) const;
|
||||
void display_watch(std::ostream& out, bool_var v, bool sign) const;
|
||||
void display_resolved_lemma(std::ostream& out) const;
|
||||
|
||||
void add_clause(ineq& c, literal_vector const& lits);
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace smt {
|
|||
m_enabled.push_back(true);
|
||||
m_normalize = true;
|
||||
bool_var bv = register_var(var, true);
|
||||
(void)bv;
|
||||
TRACE("opt", tout << "enable: v" << m_bool2var[bv] << " b" << bv << " " << mk_pp(var, get_manager()) << "\n";
|
||||
tout << wfml << "\n";);
|
||||
return var;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue