mirror of
https://github.com/Z3Prover/z3
synced 2025-07-23 20:58:54 +00:00
adding in-processing
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
fb84ba8c34
commit
c3d29e75ef
9 changed files with 484 additions and 106 deletions
|
@ -59,10 +59,16 @@ namespace sat {
|
|||
unsigned index() const { return m_index; }
|
||||
literal lit() const { return m_lit; }
|
||||
literal operator[](unsigned i) const { return m_lits[i]; }
|
||||
literal const* begin() const { return m_lits; }
|
||||
literal const* end() const { return static_cast<literal const*>(m_lits) + m_size; }
|
||||
unsigned k() const { return m_k; }
|
||||
unsigned size() const { return m_size; }
|
||||
void swap(unsigned i, unsigned j) { std::swap(m_lits[i], m_lits[j]); }
|
||||
void negate();
|
||||
void negate();
|
||||
void update_size(unsigned sz) { SASSERT(sz <= m_size); m_size = sz; }
|
||||
void update_k(unsigned k) { m_k = k; }
|
||||
void nullify_literal() { m_lit = null_literal; }
|
||||
literal_vector literals() const { return literal_vector(m_size, m_lits); }
|
||||
};
|
||||
|
||||
typedef std::pair<unsigned, literal> wliteral;
|
||||
|
@ -76,6 +82,7 @@ namespace sat {
|
|||
unsigned m_num_watch;
|
||||
unsigned m_max_sum;
|
||||
wliteral m_wlits[0];
|
||||
void update_max_sum();
|
||||
public:
|
||||
static size_t get_obj_size(unsigned num_lits) { return sizeof(pb) + num_lits * sizeof(wliteral); }
|
||||
pb(unsigned index, literal lit, svector<wliteral> const& wlits, unsigned k);
|
||||
|
@ -83,7 +90,7 @@ namespace sat {
|
|||
literal lit() const { return m_lit; }
|
||||
wliteral operator[](unsigned i) const { return m_wlits[i]; }
|
||||
wliteral const* begin() const { return m_wlits; }
|
||||
wliteral const* end() const { return (wliteral const*)m_wlits + m_size; }
|
||||
wliteral const* end() const { return static_cast<wliteral const*>(m_wlits) + m_size; }
|
||||
|
||||
unsigned k() const { return m_k; }
|
||||
unsigned size() const { return m_size; }
|
||||
|
@ -94,6 +101,10 @@ namespace sat {
|
|||
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();
|
||||
void update_size(unsigned sz) { m_size = sz; update_max_sum(); }
|
||||
void update_k(unsigned k) { m_k = k; }
|
||||
void nullify_literal() { m_lit = null_literal; }
|
||||
literal_vector literals() const { literal_vector lits; for (auto wl : *this) lits.push_back(wl.second); return lits; }
|
||||
};
|
||||
|
||||
class xor {
|
||||
|
@ -109,7 +120,7 @@ namespace sat {
|
|||
literal operator[](unsigned i) const { return m_lits[i]; }
|
||||
unsigned size() const { return m_size; }
|
||||
literal const* begin() const { return m_lits; }
|
||||
literal const* end() const { return (literal const*)m_lits + m_size; }
|
||||
literal const* end() const { return static_cast<literal const*>(m_lits) + m_size; }
|
||||
void swap(unsigned i, unsigned j) { std::swap(m_lits[i], m_lits[j]); }
|
||||
void negate() { m_lits[0].neg(); }
|
||||
};
|
||||
|
@ -131,9 +142,6 @@ namespace sat {
|
|||
ptr_vector<xor> m_xors;
|
||||
ptr_vector<pb> m_pbs;
|
||||
|
||||
scoped_ptr_vector<card> m_card_axioms;
|
||||
scoped_ptr_vector<pb> m_pb_axioms;
|
||||
|
||||
// watch literals
|
||||
unsigned_vector m_index_trail;
|
||||
unsigned_vector m_index_lim;
|
||||
|
@ -157,7 +165,14 @@ namespace sat {
|
|||
void inc_parity(bool_var v);
|
||||
void reset_parity(bool_var v);
|
||||
|
||||
void clear_index_trail_back();
|
||||
|
||||
solver& s() const { return *m_solver; }
|
||||
|
||||
void gc();
|
||||
|
||||
// cardinality
|
||||
void init_watch(card& c);
|
||||
void init_watch(card& c, bool is_true);
|
||||
void init_watch(bool_var v);
|
||||
void assign(card& c, literal lit);
|
||||
|
@ -170,6 +185,10 @@ namespace sat {
|
|||
void unwatch_literal(literal w, card& c);
|
||||
void get_card_antecedents(literal l, card const& c, literal_vector & r);
|
||||
void copy_card(card_extension& result);
|
||||
void simplify(card& c);
|
||||
void nullify_tracking_literal(card& c);
|
||||
void remove_constraint(card& c);
|
||||
void unit_propagation_simplification(literal lit, literal_vector const& lits);
|
||||
|
||||
// xor specific functionality
|
||||
void copy_xor(card_extension& result);
|
||||
|
@ -177,17 +196,19 @@ namespace sat {
|
|||
void watch_literal(xor& x, literal lit);
|
||||
void unwatch_literal(literal w, xor& x);
|
||||
void init_watch(xor& x, bool is_true);
|
||||
void assign(xor& x, literal lit);
|
||||
void assign(xor& x, literal lit);
|
||||
void set_conflict(xor& x, literal lit);
|
||||
bool parity(xor const& x, unsigned offset) const;
|
||||
lbool add_assign(xor& x, literal alit);
|
||||
void get_xor_antecedents(literal l, unsigned index, justification js, literal_vector& r);
|
||||
void get_xor_antecedents(literal l, xor const& x, literal_vector & r);
|
||||
void simplify(xor& x);
|
||||
|
||||
|
||||
bool is_card_index(unsigned idx) const { return 0x0 == (idx & 0x3); }
|
||||
bool is_xor_index(unsigned idx) const { return 0x1 == (idx & 0x3); }
|
||||
bool is_pb_index(unsigned idx) const { return 0x3 == (idx & 0x3); }
|
||||
unsigned index2position(unsigned idx) const { return idx >> 2; }
|
||||
card& index2card(unsigned idx) const { SASSERT(is_card_index(idx)); return *m_cards[idx >> 2]; }
|
||||
xor& index2xor(unsigned idx) const { SASSERT(is_xor_index(idx)); return *m_xors[idx >> 2]; }
|
||||
pb& index2pb(unsigned idx) const { SASSERT(is_pb_index(idx)); return *m_pbs[idx >> 2]; }
|
||||
|
@ -205,6 +226,11 @@ namespace sat {
|
|||
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);
|
||||
void simplify(pb& p);
|
||||
void simplify2(pb& p);
|
||||
bool is_cardinality(pb const& p);
|
||||
void nullify_tracking_literal(pb& p);
|
||||
void remove_constraint(pb& p);
|
||||
|
||||
inline lbool value(literal lit) const { return m_lookahead ? m_lookahead->value(lit) : m_solver->value(lit); }
|
||||
inline unsigned lvl(literal lit) const { return m_solver->lvl(lit); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue