3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-01 21:49:29 +00:00

change data-structures to concanetation decomposition normal form

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-01-07 16:03:37 -08:00
parent 0c2334417c
commit ad778f87c7
6 changed files with 235 additions and 401 deletions

View file

@ -141,22 +141,30 @@ namespace smt {
}
class ne2 {
class ne {
vector<expr_ref_vector> m_lhs;
vector<expr_ref_vector> m_rhs;
literal_vector m_lits;
dependency* m_dep;
public:
ne2(expr_ref_vector const& l, expr_ref_vector const& r, dependency* dep):
ne(expr_ref const& l, expr_ref const& r, dependency* dep):
m_dep(dep) {
m_lhs.push_back(l);
m_rhs.push_back(r);
expr_ref_vector ls(l.get_manager()); ls.push_back(l);
expr_ref_vector rs(r.get_manager()); rs.push_back(r);
m_lhs.push_back(ls);
m_rhs.push_back(rs);
}
ne2(ne2 const& other):
ne(vector<expr_ref_vector> const& l, vector<expr_ref_vector> const& r, literal_vector const& lits, dependency* dep):
m_lhs(l),
m_rhs(r),
m_lits(lits),
m_dep(dep) {}
ne(ne const& other):
m_lhs(other.m_lhs), m_rhs(other.m_rhs), m_lits(other.m_lits), m_dep(other.m_dep) {}
ne2& operator=(ne2 const& other) {
ne& operator=(ne const& other) {
if (this != &other) {
m_lhs.reset(); m_lhs.append(other.m_lhs);
m_rhs.reset(); m_rhs.append(other.m_rhs);
@ -174,136 +182,6 @@ namespace smt {
dependency* dep() const { return m_dep; }
};
// asserted or derived disqequality with dependencies
struct ne {
bool m_solved;
expr_ref m_l, m_r;
expr_ref_vector m_lhs;
expr_ref_vector m_rhs;
literal_vector m_lits;
dependency* m_dep;
ne(expr_ref& l, expr_ref& r):
m_solved(false), m_l(l), m_r(r), m_lhs(l.get_manager()), m_rhs(r.get_manager()), m_dep(0) {
m_lhs.push_back(l);
m_rhs.push_back(r);
}
ne(ne const& other):
m_solved(other.m_solved), m_l(other.m_l), m_r(other.m_r), m_lhs(other.m_lhs), m_rhs(other.m_rhs), m_lits(other.m_lits), m_dep(other.m_dep) {}
ne& operator=(ne const& other) {
m_solved = other.m_solved;
m_l = other.m_l;
m_r = other.m_r;
m_lhs.reset(); m_lhs.append(other.m_lhs);
m_rhs.reset(); m_rhs.append(other.m_rhs);
m_lits.reset(); m_lits.append(other.m_lits);
m_dep = other.m_dep;
return *this;
}
bool is_solved() const { return m_solved; }
};
class pop_lit : public trail<theory_seq> {
unsigned m_idx;
literal m_lit;
public:
pop_lit(theory_seq& th, unsigned idx): m_idx(idx), m_lit(th.m_nqs[idx].m_lits.back()) {
th.m_nqs.ref(m_idx).m_lits.pop_back();
}
virtual void undo(theory_seq & th) { th.m_nqs.ref(m_idx).m_lits.push_back(m_lit); }
};
class push_lit : public trail<theory_seq> {
unsigned m_idx;
public:
push_lit(theory_seq& th, unsigned idx, literal lit): m_idx(idx) {
th.m_nqs.ref(m_idx).m_lits.push_back(lit);
}
virtual void undo(theory_seq & th) { th.m_nqs.ref(m_idx).m_lits.pop_back(); }
};
class set_lit : public trail<theory_seq> {
unsigned m_idx;
unsigned m_i;
literal m_lit;
public:
set_lit(theory_seq& th, unsigned idx, unsigned i, literal lit):
m_idx(idx), m_i(i), m_lit(th.m_nqs[idx].m_lits[i]) {
th.m_nqs.ref(m_idx).m_lits[i] = lit;
}
virtual void undo(theory_seq & th) { th.m_nqs.ref(m_idx).m_lits[m_i] = m_lit; }
};
class solved_ne : public trail<theory_seq> {
unsigned m_idx;
public:
solved_ne(theory_seq& th, unsigned idx) : m_idx(idx) { th.m_nqs.ref(idx).m_solved = true; }
virtual void undo(theory_seq& th) { th.m_nqs.ref(m_idx).m_solved = false; }
};
void mark_solved(unsigned idx);
class push_ne : public trail<theory_seq> {
unsigned m_idx;
public:
push_ne(theory_seq& th, unsigned idx, expr* l, expr* r) : m_idx(idx) {
th.m_nqs.ref(m_idx).m_lhs.push_back(l);
th.m_nqs.ref(m_idx).m_rhs.push_back(r);
}
virtual void undo(theory_seq& th) { th.m_nqs.ref(m_idx).m_lhs.pop_back(); th.m_nqs.ref(m_idx).m_rhs.pop_back(); }
};
class pop_ne : public trail<theory_seq> {
expr_ref m_lhs;
expr_ref m_rhs;
unsigned m_idx;
public:
pop_ne(theory_seq& th, unsigned idx):
m_lhs(th.m_nqs[idx].m_lhs.back(), th.m),
m_rhs(th.m_nqs[idx].m_rhs.back(), th.m),
m_idx(idx) {
th.m_nqs.ref(idx).m_lhs.pop_back();
th.m_nqs.ref(idx).m_rhs.pop_back();
}
virtual void undo(theory_seq& th) {
th.m_nqs.ref(m_idx).m_lhs.push_back(m_lhs);
th.m_nqs.ref(m_idx).m_rhs.push_back(m_rhs);
m_lhs.reset();
m_rhs.reset();
}
};
class set_ne : public trail<theory_seq> {
expr_ref m_lhs;
expr_ref m_rhs;
unsigned m_idx;
unsigned m_i;
public:
set_ne(theory_seq& th, unsigned idx, unsigned i, expr* l, expr* r):
m_lhs(th.m_nqs[idx].m_lhs[i], th.m),
m_rhs(th.m_nqs[idx].m_rhs[i], th.m),
m_idx(idx),
m_i(i) {
th.m_nqs.ref(idx).m_lhs[i] = l;
th.m_nqs.ref(idx).m_rhs[i] = r;
}
virtual void undo(theory_seq& th) {
th.m_nqs.ref(m_idx).m_lhs[m_i] = m_lhs;
th.m_nqs.ref(m_idx).m_rhs[m_i] = m_rhs;
m_lhs.reset();
m_rhs.reset();
}
};
class push_dep : public trail<theory_seq> {
dependency* m_dep;
unsigned m_idx;
public:
push_dep(theory_seq& th, unsigned idx, dependency* d): m_dep(th.m_nqs[idx].m_dep), m_idx(idx) {
th.m_nqs.ref(idx).m_dep = d;
}
virtual void undo(theory_seq& th) {
th.m_nqs.ref(m_idx).m_dep = m_dep;
}
};
class apply {
public:
virtual ~apply() {}
@ -441,12 +319,13 @@ namespace smt {
bool solve_binary_eq(expr_ref_vector const& l, expr_ref_vector const& r, dependency* dep);
bool propagate_max_length(expr* l, expr* r, dependency* dep);
expr_ref mk_empty(sort* s) { return expr_ref(m_util.str.mk_empty(s), m); }
expr_ref mk_concat(unsigned n, expr*const* es) { return expr_ref(m_util.str.mk_concat(n, es), m); }
expr_ref mk_concat(expr_ref_vector const& es) { return mk_concat(es.size(), es.c_ptr()); }
expr_ref mk_concat(expr_ref_vector const& es, sort* s) { if (es.empty()) return mk_empty(s); return mk_concat(es.size(), es.c_ptr()); }
expr_ref mk_concat(expr* e1, expr* e2) { return expr_ref(m_util.str.mk_concat(e1, e2), m); }
expr_ref mk_concat(expr* e1, expr* e2, expr* e3) { return expr_ref(m_util.str.mk_concat(e1, e2, e3), m); }
bool solve_nqs(unsigned i);
void solve_ne(unsigned i);
bool solve_ne(unsigned i);
// asserting consequences
void linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const;