Skip to content

Commit f7afe1f

Browse files
Replace assert by invariant
1 parent fc44d99 commit f7afe1f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/solvers/sat/cnf.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Author: Daniel Kroening, [email protected]
1212
#include "cnf.h"
1313

1414
#include <algorithm>
15-
#include <cassert>
16-
#include <iostream>
1715
#include <set>
1816

17+
#include <util/invariant.h>
18+
1919
// #define VERBOSE
2020

2121
/// Tseitin encoding of conjunction of two literals
@@ -426,22 +426,23 @@ bool cnft::process_clause(const bvt &bv, bvt &dest)
426426
for(const auto l : bv)
427427
{
428428
// we never use index 0
429-
assert(l.var_no()!=0);
429+
INVARIANT(l.var_no() != 0, "variable 0 must not be used");
430430

431431
// we never use 'unused_var_no'
432-
assert(l.var_no()!=literalt::unused_var_no());
432+
INVARIANT(
433+
l.var_no() != literalt::unused_var_no(),
434+
"variable 'unused_var_no' must not be used");
433435

434436
if(l.is_true())
435437
return true; // clause satisfied
436438

437439
if(l.is_false())
438440
continue; // will remove later
439441

440-
if(l.var_no()>=_no_variables)
441-
std::cout << "l.var_no()=" << l.var_no()
442-
<< " _no_variables=" << _no_variables << '\n';
443-
444-
assert(l.var_no()<_no_variables);
442+
INVARIANT(
443+
l.var_no() < _no_variables,
444+
"unknown variable " + std::to_string(l.var_no()) +
445+
" (no_variables = " + std::to_string(_no_variables) + " )");
445446
}
446447

447448
// now copy

0 commit comments

Comments
 (0)