3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-23 04:38:53 +00:00

adding pb

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-05-07 16:53:25 -07:00
parent 8205b45839
commit 0ba7c9c39b
3 changed files with 487 additions and 69 deletions

View file

@ -36,6 +36,9 @@ namespace sat {
unsigned m_num_xor_propagations;
unsigned m_num_xor_conflicts;
unsigned m_num_xor_resolves;
unsigned m_num_pb_propagations;
unsigned m_num_pb_conflicts;
unsigned m_num_pb_resolves;
stats() { reset(); }
void reset() { memset(this, 0, sizeof(*this)); }
};
@ -66,6 +69,9 @@ namespace sat {
literal m_lit;
unsigned m_k;
unsigned m_size;
unsigned m_slack;
unsigned m_num_watch;
unsigned m_max_sum;
wliteral m_wlits[0];
public:
static size_t get_obj_size(unsigned num_lits) { return sizeof(card) + num_lits * sizeof(wliteral); }
@ -75,6 +81,11 @@ namespace sat {
wliteral operator[](unsigned i) const { return m_wlits[i]; }
unsigned k() const { return m_k; }
unsigned size() const { return m_size; }
unsigned slack() const { return m_slack; }
void set_slack(unsigned s) { m_slack = s; }
unsigned num_watch() const { return m_num_watch; }
unsigned max_sum() const { return m_max_sum; }
void set_num_watch(unsigned s) { m_num_watch = s; }
void swap(unsigned i, unsigned j) { std::swap(m_wlits[i], m_wlits[j]); }
void negate();
};
@ -153,7 +164,7 @@ namespace sat {
ptr_vector<card> m_cards;
ptr_vector<xor> m_xors;
ptr_vector<pb> m_pb;
ptr_vector<pb> m_pbs;
scoped_ptr_vector<card> m_card_axioms;
scoped_ptr_vector<pb> m_pb_axioms;
@ -175,6 +186,9 @@ namespace sat {
bool m_has_xor;
unsigned_vector m_parity_marks;
literal_vector m_parity_trail;
unsigned_vector m_pb_undef;
void ensure_parity_size(bool_var v);
unsigned get_parity(bool_var v);
void inc_parity(bool_var v);
@ -193,6 +207,7 @@ namespace sat {
void unwatch_literal(literal w, card* c);
// xor specific functionality
void copy_xor(card_extension& result);
void clear_watch(xor& x);
void watch_literal(xor& x, literal lit);
void unwatch_literal(literal w, xor* x);
@ -202,17 +217,28 @@ namespace sat {
bool parity(xor const& x, unsigned offset) const;
lbool add_assign(xor& x, literal alit);
void asserted_xor(literal l, ptr_vector<xor>* xors, xor* x);
void get_xor_antecedents(literal l, unsigned index, justification js, literal_vector& r);
bool is_card_index(unsigned idx) const { return 0x00 == (idx & 0x11); }
bool is_xor_index(unsigned idx) const { return 0x01 == (idx & 0x11); }
bool is_pb_index(unsigned idx) const { return 0x11 == (idx & 0x11); }
card& index2card(unsigned idx) const { SASSERT(is_card_index(idx)); return *m_cards[idx >> 2]; }
xor& index2xor(unsigned idx) const { SASSERT(!is_card_index(idx)); return *m_xors[idx >> 2]; }
pb& index2pb(unsigned idx) const { SASSERT(is_pb_index(idx)); return *m_pb[idx >> 2]; }
pb& index2pb(unsigned idx) const { SASSERT(is_pb_index(idx)); return *m_pbs[idx >> 2]; }
void get_xor_antecedents(literal l, unsigned inddex, justification js, literal_vector& r);
// pb functionality
void copy_pb(card_extension& result);
void asserted_pb(literal l, ptr_vector<pb>* pbs, pb* p);
void init_watch(pb& p, bool is_true);
lbool add_assign(pb& p, literal alit);
void watch_literal(pb& p, wliteral lit);
void clear_watch(pb& p);
void set_conflict(pb& p, literal lit);
void assign(pb& p, literal l);
void unwatch_literal(literal w, pb* p);
void get_pb_antecedents(literal l, pb const& p, literal_vector & r);
template<typename T>
@ -260,6 +286,7 @@ namespace sat {
void display(std::ostream& out, ineq& p) const;
void display(std::ostream& out, card& c, bool values) const;
void display(std::ostream& out, pb& p, bool values) const;
void display(std::ostream& out, xor& c, bool values) const;
void display_watch(std::ostream& out, bool_var v) const;
void display_watch(std::ostream& out, bool_var v, bool sign) const;