3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-13 02:34:43 +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,7 +62,7 @@ namespace polysat {
return true;
}
bool forbidden_intervals::explain(solver& s, ptr_vector<constraint> const& conflict, pvar v, scoped_ptr_vector<constraint>& out_lemma) {
bool forbidden_intervals::explain(solver& s, ptr_vector<constraint> const& conflict, pvar v, clause& out_lemma) {
// Extract forbidden intervals from conflicting constraints
vector<fi_record> records;
@ -137,6 +137,7 @@ namespace polysat {
// - the upper bound of each interval is contained in the next interval,
// then the forbidden intervals cover the whole domain and we have a conflict.
// We learn the negation of this conjunction.
scoped_ptr_vector<constraint> literals;
for (unsigned seq_i = seq.size(); seq_i-- > 0; ) {
unsigned const i = seq[seq_i];
unsigned const next_i = seq[(seq_i+1) % seq.size()];
@ -149,14 +150,15 @@ namespace polysat {
auto const& rhs = next_hi - next_lo;
constraint* c = constraint::ult(lemma_lvl, s.m_next_bvar++, neg_t, lhs, rhs, lemma_dep);
LOG("constraint: " << *c);
out_lemma.push_back(c);
literals.push_back(c);
// Side conditions
// TODO: check whether the condition is subsumed by c? maybe at the end do a "lemma reduction" step, to try and reduce branching?
scoped_ptr<constraint>& cond = records[i].cond;
if (cond)
out_lemma.push_back(cond.detach());
literals.push_back(cond.detach());
}
out_lemma = std::move(literals);
return true;
}