mirror of
https://github.com/Z3Prover/z3
synced 2026-02-28 10:51:28 +00:00
Polysat: use constraint_literal and begin move to core-based conflict representation (#5489)
* Rename solver_scope for fixplex tests (otherwise the wrong constructor is called for polysat's solver_scope) * Update conflict_core * simplify * Be clearer about constraint_literal lifetime * remove old comment * Remove status (positive/negative) from constraint * Use constraint_literal in the solver * Fix build (constraint -> get_constraint)
This commit is contained in:
parent
30e9f24fa3
commit
ebaea2159e
19 changed files with 933 additions and 1004 deletions
|
|
@ -21,9 +21,11 @@ Author:
|
|||
#include "util/statistics.h"
|
||||
#include "util/params.h"
|
||||
#include "math/polysat/boolean.h"
|
||||
#include "math/polysat/conflict_core.h"
|
||||
#include "math/polysat/constraint.h"
|
||||
#include "math/polysat/clause_builder.h"
|
||||
#include "math/polysat/eq_constraint.h"
|
||||
#include "math/polysat/explain.h"
|
||||
#include "math/polysat/ule_constraint.h"
|
||||
#include "math/polysat/justification.h"
|
||||
#include "math/polysat/linear_solver.h"
|
||||
|
|
@ -59,6 +61,7 @@ namespace polysat {
|
|||
friend class assignments_pp;
|
||||
|
||||
typedef ptr_vector<constraint> constraints;
|
||||
typedef vector<constraint_literal> constraint_literals;
|
||||
|
||||
reslimit& m_lim;
|
||||
params_ref m_params;
|
||||
|
|
@ -68,7 +71,7 @@ namespace polysat {
|
|||
small_object_allocator m_alloc;
|
||||
poly_dep_manager m_dm;
|
||||
linear_solver m_linear_solver;
|
||||
constraints_and_clauses m_conflict;
|
||||
conflict_core m_conflict;
|
||||
// constraints m_stash_just;
|
||||
var_queue m_free_vars;
|
||||
stats m_stats;
|
||||
|
|
@ -81,8 +84,8 @@ namespace polysat {
|
|||
|
||||
// Per constraint state
|
||||
constraint_manager m_constraints;
|
||||
ptr_vector<constraint> m_original;
|
||||
ptr_vector<constraint> m_redundant;
|
||||
constraint_literals m_original;
|
||||
constraint_literals m_redundant;
|
||||
ptr_vector<clause> m_redundant_clauses;
|
||||
|
||||
svector<sat::bool_var> m_disjunctive_lemma;
|
||||
|
|
@ -90,8 +93,8 @@ namespace polysat {
|
|||
// Per variable information
|
||||
vector<rational> m_value; // assigned value
|
||||
vector<justification> m_justification; // justification for variable assignment
|
||||
vector<constraints> m_cjust; // constraints justifying variable range.
|
||||
vector<constraints> m_watch; // watch list datastructure into constraints.
|
||||
vector<constraint_literals> m_cjust; // constraints justifying variable range.
|
||||
vector<constraint_literals> m_watch; // watch list datastructure into constraints.
|
||||
unsigned_vector m_activity;
|
||||
vector<pdd> m_vars;
|
||||
unsigned_vector m_size; // store size of variables.
|
||||
|
|
@ -125,12 +128,12 @@ namespace polysat {
|
|||
m_qhead_trail.pop_back();
|
||||
}
|
||||
|
||||
void push_cjust(pvar v, constraint* c) {
|
||||
void push_cjust(pvar v, constraint_literal c) {
|
||||
if (m_cjust[v].contains(c)) // TODO: better check (flag on constraint?)
|
||||
return;
|
||||
LOG_V("cjust[v" << v << "] += " << show_deref(c));
|
||||
LOG_V("cjust[v" << v << "] += " << c);
|
||||
SASSERT(c);
|
||||
m_cjust[v].push_back(c);
|
||||
m_cjust[v].push_back(c);
|
||||
m_trail.push_back(trail_instr_t::just_i);
|
||||
m_cjust_trail.push_back(v);
|
||||
}
|
||||
|
|
@ -148,14 +151,14 @@ namespace polysat {
|
|||
|
||||
void push_level();
|
||||
void pop_levels(unsigned num_levels);
|
||||
void pop_constraints(ptr_vector<constraint>& cs);
|
||||
void pop_constraints(constraint_literals& cs);
|
||||
|
||||
void assign_bool_backtrackable(sat::literal lit, clause* reason, clause* lemma);
|
||||
void activate_constraint_base(constraint* c, bool is_true);
|
||||
void activate_constraint_base(constraint_literal c);
|
||||
void assign_bool_core(sat::literal lit, clause* reason, clause* lemma);
|
||||
// void assign_bool_base(sat::literal lit);
|
||||
void activate_constraint(constraint& c, bool is_true);
|
||||
void deactivate_constraint(constraint& c);
|
||||
void activate_constraint(constraint_literal c);
|
||||
void deactivate_constraint(constraint_literal c);
|
||||
sat::literal decide_bool(clause& lemma);
|
||||
void decide_bool(sat::literal lit, clause& lemma);
|
||||
void propagate_bool(sat::literal lit, clause* reason);
|
||||
|
|
@ -168,14 +171,13 @@ namespace polysat {
|
|||
|
||||
void propagate(sat::literal lit);
|
||||
void propagate(pvar v);
|
||||
void propagate(pvar v, rational const& val, constraint& c);
|
||||
void erase_watch(pvar v, constraint& c);
|
||||
void erase_watch(constraint& c);
|
||||
void add_watch(constraint& c);
|
||||
void add_watch(constraint& c, pvar v);
|
||||
void propagate(pvar v, rational const& val, constraint_literal c);
|
||||
void erase_watch(pvar v, constraint_literal c);
|
||||
void erase_watch(constraint_literal c);
|
||||
void add_watch(constraint_literal c);
|
||||
void add_watch(constraint_literal c, pvar v);
|
||||
|
||||
void set_conflict(constraint& c);
|
||||
void set_conflict(clause& cl);
|
||||
void set_conflict(constraint_literal c);
|
||||
void set_conflict(pvar v);
|
||||
|
||||
unsigned_vector m_marks;
|
||||
|
|
@ -184,13 +186,11 @@ namespace polysat {
|
|||
bool is_marked(pvar v) const { return m_clock == m_marks[v]; }
|
||||
void set_mark(pvar v) { LOG_V("Marking: v" << v); m_marks[v] = m_clock; }
|
||||
|
||||
void set_marks(constraints_and_clauses const& cc);
|
||||
void set_marks(conflict_core const& cc);
|
||||
void set_marks(constraint const& c);
|
||||
void set_marks(clause const& cl);
|
||||
|
||||
unsigned m_conflict_level { 0 };
|
||||
|
||||
clause_ref resolve(pvar v);
|
||||
clause_ref resolve_bool(sat::literal lit);
|
||||
|
||||
bool can_decide() const { return !m_free_vars.empty(); }
|
||||
|
|
@ -219,17 +219,17 @@ namespace polysat {
|
|||
void backjump(unsigned new_level);
|
||||
void add_lemma(clause_ref lemma);
|
||||
|
||||
constraint_literal mk_eq(pdd const& p);
|
||||
constraint_literal mk_diseq(pdd const& p);
|
||||
constraint_literal mk_ule(pdd const& p, pdd const& q);
|
||||
constraint_literal mk_ult(pdd const& p, pdd const& q);
|
||||
constraint_literal mk_sle(pdd const& p, pdd const& q);
|
||||
constraint_literal mk_slt(pdd const& p, pdd const& q);
|
||||
void new_constraint(constraint_literal c, unsigned dep, bool activate);
|
||||
static void insert_constraint(ptr_vector<constraint>& cs, constraint* c);
|
||||
constraint_literal_ref mk_eq(pdd const& p);
|
||||
constraint_literal_ref mk_diseq(pdd const& p);
|
||||
constraint_literal_ref mk_ule(pdd const& p, pdd const& q);
|
||||
constraint_literal_ref mk_ult(pdd const& p, pdd const& q);
|
||||
constraint_literal_ref mk_sle(pdd const& p, pdd const& q);
|
||||
constraint_literal_ref mk_slt(pdd const& p, pdd const& q);
|
||||
void new_constraint(constraint_literal_ref c, unsigned dep, bool activate);
|
||||
static void insert_constraint(constraint_literals& cs, constraint_literal c);
|
||||
|
||||
bool invariant();
|
||||
static bool invariant(ptr_vector<constraint> const& cs);
|
||||
static bool invariant(constraint_literals const& cs);
|
||||
bool wlist_invariant();
|
||||
bool verify_sat();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue