mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 20:05:51 +00:00
remove eq constraint, fix gc for external constraints
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
f8a3857adb
commit
b36bc11b85
15 changed files with 133 additions and 275 deletions
|
@ -19,10 +19,9 @@ Author:
|
|||
|
||||
namespace polysat {
|
||||
|
||||
enum ckind_t { eq_t, ule_t };
|
||||
enum ckind_t { ule_t };
|
||||
|
||||
class constraint;
|
||||
class eq_constraint;
|
||||
class ule_constraint;
|
||||
class signed_constraint;
|
||||
|
||||
|
@ -47,6 +46,7 @@ namespace polysat {
|
|||
|
||||
// Association to external dependency values (i.e., external names for constraints)
|
||||
u_map<constraint*> m_external_constraints;
|
||||
unsigned m_num_external = 0;
|
||||
|
||||
// Manage association of constraints to boolean variables
|
||||
void assign_bv2c(sat::bool_var bv, constraint* c);
|
||||
|
@ -58,8 +58,8 @@ namespace polysat {
|
|||
|
||||
constraint* dedup(constraint* c);
|
||||
|
||||
void gc_constraints();
|
||||
void gc_clauses();
|
||||
void gc_constraints(solver& s);
|
||||
void gc_clauses(solver& s);
|
||||
|
||||
public:
|
||||
constraint_manager(bool_var_manager& bvars): m_bvars(bvars) {}
|
||||
|
@ -73,12 +73,13 @@ namespace polysat {
|
|||
|
||||
/// Register a unit clause with an external dependency.
|
||||
void register_external(constraint* c);
|
||||
void unregister_external(constraint* c);
|
||||
|
||||
/// Release clauses at the given level and above.
|
||||
void release_level(unsigned lvl);
|
||||
|
||||
/// Garbage-collect temporary constraints (i.e., those that do not have a boolean variable).
|
||||
void gc();
|
||||
void gc(solver& s);
|
||||
bool should_gc();
|
||||
|
||||
constraint* lookup(sat::bool_var var) const;
|
||||
|
@ -113,13 +114,13 @@ namespace polysat {
|
|||
class constraint {
|
||||
friend class constraint_manager;
|
||||
friend class clause;
|
||||
friend class eq_constraint;
|
||||
friend class ule_constraint;
|
||||
|
||||
// constraint_manager* m_manager;
|
||||
clause* m_unit_clause = nullptr; ///< If this constraint was asserted by a unit clause, we store that clause here.
|
||||
ckind_t m_kind;
|
||||
unsigned_vector m_vars;
|
||||
bool m_is_external = false;
|
||||
/** The boolean variable associated to this constraint, if any.
|
||||
* If this is not null_bool_var, then the constraint corresponds to a literal on the assignment stack.
|
||||
* Convention: the plain constraint corresponds the positive sat::literal.
|
||||
|
@ -138,7 +139,7 @@ namespace polysat {
|
|||
virtual bool operator==(constraint const& other) const = 0;
|
||||
bool operator!=(constraint const& other) const { return !operator==(other); }
|
||||
|
||||
bool is_eq() const { return m_kind == ckind_t::eq_t; }
|
||||
virtual bool is_eq() const { return false; }
|
||||
bool is_ule() const { return m_kind == ckind_t::ule_t; }
|
||||
ckind_t kind() const { return m_kind; }
|
||||
virtual std::ostream& display(std::ostream& out, lbool status = l_undef) const = 0;
|
||||
|
@ -150,9 +151,8 @@ namespace polysat {
|
|||
virtual bool is_currently_true(solver& s, bool is_positive) const = 0;
|
||||
virtual void narrow(solver& s, bool is_positive) = 0;
|
||||
virtual inequality as_inequality(bool is_positive) const = 0;
|
||||
|
||||
|
||||
eq_constraint& to_eq();
|
||||
eq_constraint const& to_eq() const;
|
||||
ule_constraint& to_ule();
|
||||
ule_constraint const& to_ule() const;
|
||||
unsigned_vector& vars() { return m_vars; }
|
||||
|
@ -165,6 +165,10 @@ namespace polysat {
|
|||
clause* unit_clause() const { return m_unit_clause; }
|
||||
void set_unit_clause(clause* cl);
|
||||
p_dependency* unit_dep() const { return m_unit_clause ? m_unit_clause->dep() : nullptr; }
|
||||
|
||||
void set_external() { m_is_external = true; }
|
||||
void unset_external() { m_is_external = false; }
|
||||
bool is_external() const { return m_is_external; }
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, constraint const& c) { return c.display(out); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue