mirror of
https://github.com/Z3Prover/z3
synced 2025-08-25 12:35:59 +00:00
Polysat updates (#5444)
* Simplify adding lemmas * Remove misleading constructor from tmp_assign. The idea is that tmp_assign is only created on the stack and short-lived. Instead of having a convenience constructor that takes a constraint_ref, it's clearer to have an explicit .get() at the call site. * Remove some log messages * bugfix * fix * Add stub for conflict_core * wip * Add example by Clemens
This commit is contained in:
parent
2ef8ee25f1
commit
8a773d2bee
12 changed files with 302 additions and 116 deletions
66
src/math/polysat/conflict_core.h
Normal file
66
src/math/polysat/conflict_core.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*++
|
||||
Copyright (c) 2021 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
polysat conflict
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2021-03-19
|
||||
Jakob Rath 2021-04-6
|
||||
|
||||
--*/
|
||||
#pragma once
|
||||
#include "math/polysat/constraint.h"
|
||||
|
||||
namespace polysat {
|
||||
|
||||
/// Represents a conflict as core (~negation of clause).
|
||||
///
|
||||
/// TODO: can probably move some clause_builder functionality into this class.
|
||||
class conflict_core {
|
||||
// constraint_ref_vector m_constraints;
|
||||
vector<constraint_literal> m_constraints;
|
||||
bool m_needs_model = true; ///< True iff the conflict depends on the current variable assignment. (If so, additional constraints must be added to the final learned clause.)
|
||||
|
||||
public:
|
||||
vector<constraint_literal> const& constraints() const {
|
||||
return m_constraints;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return m_constraints.empty();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
m_constraints.reset();
|
||||
m_needs_model = true;
|
||||
}
|
||||
|
||||
// for bailing out with a conflict at the base level
|
||||
void set(std::nullptr_t) {
|
||||
SASSERT(empty());
|
||||
m_constraints.push_back({});
|
||||
m_needs_model = false;
|
||||
}
|
||||
|
||||
// void set(
|
||||
|
||||
// TODO: set core from conflicting units
|
||||
// TODO: set clause
|
||||
|
||||
// TODO: use iterator instead (this method is needed for marking so duplicates don't necessarily have to be skipped)
|
||||
unsigned_vector vars(constraint_manager const& cm) const {
|
||||
unsigned_vector vars;
|
||||
for (auto const& c : m_constraints)
|
||||
vars.append(c->vars());
|
||||
return vars;
|
||||
}
|
||||
|
||||
std::ostream& display(std::ostream& out) const;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, conflict_core const& c) { return c.display(out); }
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue