Skip to content

Commit

Permalink
Replace assertions by invariants
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschrammel committed Jan 13, 2018
1 parent 84e04a7 commit ef45a1d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/solvers/sat/satcheck_glucose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Author: Daniel Kroening, [email protected]
#include <inttypes.h>
#endif

#include <cassert>
#include <stack>

#include <util/invariant.h>
#include <util/threeval.h>

#include <core/Solver.h>
Expand Down Expand Up @@ -64,7 +64,7 @@ tvt satcheck_glucose_baset<T>::l_get(literalt a) const
template<typename T>
void satcheck_glucose_baset<T>::set_polarity(literalt a, bool value)
{
assert(!a.is_constant());
PRECONDITION(!a.is_constant());

try
{
Expand Down Expand Up @@ -108,7 +108,8 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
if(it->is_true())
return;
else if(!it->is_false())
assert(it->var_no() < (unsigned)solver->nVars());
INVARIANT(
it->var_no() < (unsigned)solver->nVars(), "variable not added yet");
}

Glucose::vec<Glucose::Lit> c;
Expand All @@ -133,7 +134,7 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
template<typename T>
propt::resultt satcheck_glucose_baset<T>::prop_solve()
{
assert(status!=statust::ERROR);
PRECONDITION(status != statust::ERROR);

// We start counting at 1, thus there is one variable fewer.
{
Expand Down Expand Up @@ -197,7 +198,7 @@ propt::resultt satcheck_glucose_baset<T>::prop_solve()
template<typename T>
void satcheck_glucose_baset<T>::set_assignment(literalt a, bool value)
{
assert(!a.is_constant());
PRECONDITION(!a.is_constant());

try
{
Expand Down Expand Up @@ -253,7 +254,7 @@ void satcheck_glucose_baset<T>::set_assumptions(const bvt &bv)
assumptions=bv;

forall_literals(it, assumptions)
assert(!it->is_constant());
INVARIANT(!it->is_constant(), "assumption literals must not be constant");
}

satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert():
Expand Down Expand Up @@ -286,7 +287,7 @@ void satcheck_glucose_simplifiert::set_frozen(literalt a)

bool satcheck_glucose_simplifiert::is_eliminated(literalt a) const
{
assert(!a.is_constant());
PRECONDITION(!a.is_constant());

return solver->isEliminated(a.var_no());
}

0 comments on commit ef45a1d

Please sign in to comment.