3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 19:35:50 +00:00

Polysat: forbidden intervals updates (#5230)

* Pop assign_eh

* Fix scoped_ptr_vector constructors, add detach()

* Need to copy the returned lemma

* Add test

* Basic inequality tests

* Return disjunctive lemma to caller
This commit is contained in:
Jakob Rath 2021-04-30 17:41:50 +02:00 committed by GitHub
parent d6e41de344
commit 0c4824f194
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 189 additions and 24 deletions

View file

@ -62,6 +62,7 @@ namespace polysat {
bool_var bvar() const { return m_bool_var; }
bool sign() const { return m_sign; }
void assign_eh(bool is_true) { m_status = (is_true ^ !m_sign) ? l_true : l_false; }
void unassign_eh() { m_status = l_undef; }
bool is_positive() const { return m_status == l_true; }
bool is_negative() const { return m_status == l_false; }
bool is_undef() const { return m_status == l_undef; }
@ -69,6 +70,27 @@ namespace polysat {
};
inline std::ostream& operator<<(std::ostream& out, constraint const& c) { return c.display(out); }
class clause {
scoped_ptr_vector<constraint> m_literals;
public:
clause() {}
clause(scoped_ptr_vector<constraint>&& literals): m_literals(std::move(literals)) {
SASSERT(std::all_of(m_literals.begin(), m_literals.end(), [](constraint* c) { return c != nullptr; }));
SASSERT(empty() || std::all_of(m_literals.begin(), m_literals.end(), [this](constraint* c) { return c->level() == level(); }));
}
bool empty() const { return m_literals.empty(); }
unsigned size() const { return m_literals.size(); }
constraint* operator[](unsigned idx) const { return m_literals[idx]; }
using const_iterator = typename scoped_ptr_vector<constraint>::const_iterator;
const_iterator begin() const { return m_literals.begin(); }
const_iterator end() const { return m_literals.end(); }
ptr_vector<constraint> detach() { return m_literals.detach(); }
unsigned level() const { SASSERT(!empty()); return m_literals[0]->level(); }
};
}