3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-24 03:57:51 +00:00

Separate constraint creation from activation; add sign/polarity to constraints (#5217)

* Separate constraint creation from activation

* Basic recursive handling of disjunctive lemmas for unit tests

* Set learned constraint to true immediately

* Preliminary support for negated constraints
This commit is contained in:
Jakob Rath 2021-04-26 18:55:58 +02:00 committed by GitHub
parent 2fac9e6e66
commit 9e505d60f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 244 additions and 73 deletions

View file

@ -12,8 +12,33 @@ namespace polysat {
struct scoped_solver : public solver_scope, public solver {
scoped_solver(): solver(lim) {}
lbool check_rec() {
lbool result = check_sat();
if (result != l_undef)
return result;
auto const& new_lemma = get_lemma();
// Empty lemma => check_sat() terminated for another reason, e.g., resource limits
if (new_lemma.empty())
return l_undef;
for (auto lit : new_lemma) {
push();
assign_eh(lit, true);
result = check_rec();
pop();
// Found a model => done
if (result == l_true)
return l_true;
if (result == l_undef)
return l_undef;
// Unsat => try next literal
SASSERT(result == l_false);
}
// No literal worked? unsat
return l_false;
}
void check() {
std::cout << check_sat() << "\n";
std::cout << check_rec() << "\n";
statistics st;
collect_statistics(st);
std::cout << st << "\n";
@ -113,9 +138,9 @@ namespace polysat {
auto v = s.var(s.add_var(5));
auto q = s.var(s.add_var(5));
auto r = s.var(s.add_var(5));
s.add_eq(u - (v*q) - r, 0);
s.add_ult(r, u, 0);
s.add_ult(u, v*q, 0);
s.add_eq(u - (v*q) - r);
s.add_ult(r, u);
s.add_ult(u, v*q);
s.check();
}