Skip to content

Commit ef45a1d

Browse files
Replace assertions by invariants
1 parent 84e04a7 commit ef45a1d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/solvers/sat/satcheck_glucose.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Author: Daniel Kroening, [email protected]
1212
#include <inttypes.h>
1313
#endif
1414

15-
#include <cassert>
1615
#include <stack>
1716

17+
#include <util/invariant.h>
1818
#include <util/threeval.h>
1919

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

6969
try
7070
{
@@ -108,7 +108,8 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
108108
if(it->is_true())
109109
return;
110110
else if(!it->is_false())
111-
assert(it->var_no() < (unsigned)solver->nVars());
111+
INVARIANT(
112+
it->var_no() < (unsigned)solver->nVars(), "variable not added yet");
112113
}
113114

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

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

202203
try
203204
{
@@ -253,7 +254,7 @@ void satcheck_glucose_baset<T>::set_assumptions(const bvt &bv)
253254
assumptions=bv;
254255

255256
forall_literals(it, assumptions)
256-
assert(!it->is_constant());
257+
INVARIANT(!it->is_constant(), "assumption literals must not be constant");
257258
}
258259

259260
satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert():
@@ -286,7 +287,7 @@ void satcheck_glucose_simplifiert::set_frozen(literalt a)
286287

287288
bool satcheck_glucose_simplifiert::is_eliminated(literalt a) const
288289
{
289-
assert(!a.is_constant());
290+
PRECONDITION(!a.is_constant());
290291

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

0 commit comments

Comments
 (0)