mirror of
https://github.com/Z3Prover/z3
synced 2025-05-11 09:44:43 +00:00
* 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
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
/*++
|
|
Copyright (c) 2021 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
polysat clauses
|
|
|
|
Author:
|
|
|
|
Nikolaj Bjorner (nbjorner) 2021-03-19
|
|
Jakob Rath 2021-04-6
|
|
|
|
--*/
|
|
|
|
#include "math/polysat/clause.h"
|
|
#include "math/polysat/solver.h"
|
|
|
|
namespace polysat {
|
|
|
|
clause_ref clause::from_unit(signed_constraint c, p_dependency_ref d) {
|
|
SASSERT(c->has_bvar());
|
|
unsigned const lvl = c->level();
|
|
sat::literal_vector lits;
|
|
lits.push_back(c.blit());
|
|
return clause::from_literals(lvl, std::move(d), std::move(lits));
|
|
}
|
|
|
|
clause_ref clause::from_literals(unsigned lvl, p_dependency_ref d, sat::literal_vector literals) {
|
|
return alloc(clause, lvl, std::move(d), std::move(literals));
|
|
}
|
|
|
|
bool clause::is_always_false(solver& s) const {
|
|
return std::all_of(m_literals.begin(), m_literals.end(), [&s](sat::literal lit) {
|
|
signed_constraint c = s.m_constraints.lookup(lit);
|
|
return c.is_always_false();
|
|
});
|
|
}
|
|
|
|
bool clause::is_currently_false(solver& s) const {
|
|
return std::all_of(m_literals.begin(), m_literals.end(), [&s](sat::literal lit) {
|
|
signed_constraint c = s.m_constraints.lookup(lit);
|
|
return c.is_currently_false(s);
|
|
});
|
|
}
|
|
|
|
std::ostream& clause::display(std::ostream& out) const {
|
|
bool first = true;
|
|
for (auto lit : *this) {
|
|
if (first)
|
|
first = false;
|
|
else
|
|
out << " \\/ ";
|
|
out << lit;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
}
|