mirror of
https://github.com/Z3Prover/z3
synced 2025-08-25 20:46:01 +00:00
Polysat: conflict resolution wip (#5529)
* conflict_core doesn't need gc() anymore * update comments, ensure_bvar for new constraints * Make sure constraints can only be created through constraint_manager * fix constraint::display if no boolean variable is assigned * Move clause into separate file * Add conflict_core binary resolution * conflict_core additions * reactivate conflict resolution outer loop * wip * seems commented includes break CI build
This commit is contained in:
parent
8b374c3745
commit
dc547510db
16 changed files with 423 additions and 335 deletions
|
@ -16,14 +16,12 @@ Author:
|
|||
|
||||
namespace polysat {
|
||||
|
||||
class solver;
|
||||
|
||||
/** Conflict state, represented as core (~negation of clause). */
|
||||
class conflict_core {
|
||||
vector<signed_constraint> m_constraints;
|
||||
|
||||
/** Storage for new constraints that may not yet have a boolean variable yet */
|
||||
// TODO: not necessary anymore, if we keep constraint_manager::gc()
|
||||
ptr_vector<constraint> m_storage;
|
||||
|
||||
// If this is not null_var, the conflict was due to empty viable set for this variable.
|
||||
// Can be treated like "v = x" for any value x.
|
||||
pvar m_conflict_var = null_var;
|
||||
|
@ -35,21 +33,20 @@ namespace polysat {
|
|||
// For example: if we have 4x+y=2 and y=0, then we have a conflict no matter the value of x, so we should drop x=? from the core.
|
||||
|
||||
public:
|
||||
~conflict_core() {
|
||||
gc();
|
||||
}
|
||||
|
||||
vector<signed_constraint> const& constraints() const { return m_constraints; }
|
||||
bool needs_model() const { return m_needs_model; }
|
||||
pvar conflict_var() const { return m_conflict_var; }
|
||||
|
||||
bool is_bailout() const { return m_constraints.size() == 1 && !m_constraints[0]; }
|
||||
|
||||
bool empty() const {
|
||||
return m_constraints.empty() && !m_needs_model;
|
||||
return m_constraints.empty() && !m_needs_model && m_conflict_var == null_var;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
m_constraints.reset();
|
||||
m_needs_model = false;
|
||||
gc();
|
||||
m_conflict_var = null_var;
|
||||
SASSERT(empty());
|
||||
}
|
||||
|
||||
|
@ -58,20 +55,21 @@ namespace polysat {
|
|||
/** conflict because the constraint c is false under current variable assignment */
|
||||
void set(signed_constraint c);
|
||||
/** conflict because there is no viable value for the variable v */
|
||||
void set(pvar v, vector<signed_constraint> const& cjust_v);
|
||||
void set(pvar v);
|
||||
|
||||
/** Garbage-collect temporary constraints */
|
||||
void gc() {
|
||||
for (auto* c : m_storage)
|
||||
if (!c->has_bvar())
|
||||
dealloc(c);
|
||||
m_storage.reset();
|
||||
}
|
||||
void push(signed_constraint c);
|
||||
|
||||
/** Perform boolean resolution with the clause upon variable 'var'.
|
||||
* Precondition: core/clause contain complementary 'var'-literals.
|
||||
*/
|
||||
void resolve(sat::bool_var var, clause const& cl);
|
||||
void resolve(constraint_manager const& m, sat::bool_var var, clause const& cl);
|
||||
|
||||
/** Convert the core into a lemma to be learned. */
|
||||
clause_ref build_lemma(solver& s, unsigned trail_idx);
|
||||
|
||||
using const_iterator = decltype(m_constraints)::const_iterator;
|
||||
const_iterator begin() { return constraints().begin(); }
|
||||
const_iterator end() { return constraints().end(); }
|
||||
|
||||
std::ostream& display(std::ostream& out) const;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue