3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00
This commit is contained in:
Jakob Rath 2022-10-04 14:08:44 +02:00
parent 3d27ec41d0
commit 9cc9d1fac4
5 changed files with 14 additions and 5 deletions

View file

@ -46,7 +46,7 @@ namespace polysat {
}
void bool_var_manager::del_var(sat::bool_var var) {
SASSERT(std::count(m_unused.begin(), m_unused.end(), var) == 0);
SASSERT(count(m_unused, var) == 0);
auto lit = sat::literal(var);
m_value[lit.index()] = l_undef;
m_value[(~lit).index()] = l_undef;

View file

@ -50,7 +50,7 @@ namespace polysat {
clause(sat::literal_vector literals):
m_literals(std::move(literals)) {
SASSERT(std::count(m_literals.begin(), m_literals.end(), sat::null_literal) == 0);
SASSERT(count(m_literals, sat::null_literal) == 0);
}
public:
@ -69,6 +69,7 @@ namespace polysat {
const_iterator begin() const { return m_literals.begin(); }
const_iterator end() const { return m_literals.end(); }
// evaluates under pvar assignment
bool is_always_false(solver& s) const;
bool is_currently_false(solver& s) const;

View file

@ -343,9 +343,9 @@ namespace polysat {
// resolvent: ~y \/ ~z \/ u \/ v; as core: y, z, ~u, ~v
SASSERT(contains(lit));
SASSERT(std::count(cl.begin(), cl.end(), lit) > 0);
SASSERT(count(cl, lit) > 0);
SASSERT(!contains(~lit));
SASSERT(std::count(cl.begin(), cl.end(), ~lit) == 0);
SASSERT(count(cl, ~lit) == 0);
remove(s.lit2cnstr(lit));
for (sat::literal other : cl)

View file

@ -1195,7 +1195,7 @@ namespace polysat {
int64_t num_watches = 0;
signed_constraint sc(c, is_positive);
for (auto const& wlist : m_pwatch) {
auto n = std::count(wlist.begin(), wlist.end(), c);
auto n = count(wlist, c);
if (n > 1)
std::cout << sc << "\n" << * this << "\n";
VERIFY(n <= 1); // no duplicates in the watchlist

View file

@ -384,3 +384,11 @@ bool all_of(Container const& c, Predicate f)
using std::begin, std::end; // allows begin(c) to also find c.begin()
return std::all_of(begin(c), end(c), std::forward<Predicate>(f));
}
/** Compact version of std::count */
template <typename Container, typename Item>
std::size_t count(Container const& c, Item x)
{
using std::begin, std::end; // allows begin(c) to also find c.begin()
return std::count(begin(c), end(c), std::forward<Item>(x));
}