@@ -8,10 +8,10 @@ Author: CM Wintersteiger
88
99#include < solvers/prop/literal.h>
1010
11- #include < cassert>
1211#include < fstream>
1312
1413#include < util/arith_tools.h>
14+ #include < util/invariant.h>
1515#include < util/std_expr.h>
1616
1717#include < cuddObj.hh> // CUDD Library
@@ -80,8 +80,7 @@ qbf_bdd_coret::~qbf_bdd_coret()
8080
8181tvt qbf_bdd_coret::l_get (literalt a) const
8282{
83- assert (false );
84- return tvt (false );
83+ UNREACHABLE;
8584}
8685
8786const std::string qbf_bdd_coret::solver_text ()
@@ -122,17 +121,18 @@ propt::resultt qbf_bdd_coret::prop_solve()
122121
123122 *matrix=matrix->ExistAbstract (*bdd_variable_map[var]);
124123 }
125- else if (it-> type ==quantifiert::UNIVERSAL)
124+ else
126125 {
126+ INVARIANT (
127+ it->type == quantifiert::UNIVERSAL,
128+ " only handles quantified variables" );
127129 #if 0
128130 std::cout << "BDD A: " << var << ", " <<
129131 matrix->nodeCount() << " nodes\n";
130132 #endif
131133
132134 *matrix=matrix->UnivAbstract (*bdd_variable_map[var]);
133135 }
134- else
135- throw " unquantified variable" ;
136136 }
137137
138138 if (*matrix==bdd_manager->bddOne ())
@@ -151,12 +151,12 @@ propt::resultt qbf_bdd_coret::prop_solve()
151151
152152bool qbf_bdd_coret::is_in_core (literalt l) const
153153{
154- throw " nyi " ;
154+ UNIMPLEMENTED ;
155155}
156156
157157qdimacs_coret::modeltypet qbf_bdd_coret::m_get (literalt a) const
158158{
159- throw " nyi " ;
159+ UNIMPLEMENTED ;
160160}
161161
162162literalt qbf_bdd_coret::new_variable ()
@@ -268,17 +268,17 @@ void qbf_bdd_coret::compress_certificate(void)
268268const exprt qbf_bdd_certificatet::f_get (literalt l)
269269{
270270 quantifiert q;
271- if (! find_quantifier (l, q))
272- throw " no model for unquantified variable " ;
271+ PRECONDITION_WITH_DIAGNOSTICS (
272+ ! find_quantifier (l, q), " no model for unquantified variables " ) ;
273273
274274 // universal?
275275 if (q.type ==quantifiert::UNIVERSAL)
276276 {
277- assert (l.var_no ()!= 0 );
277+ INVARIANT (l.var_no () != 0 , " input literal wasn't properly initialized " );
278278 variable_mapt::const_iterator it=variable_map.find (l.var_no ());
279279
280- if (it==variable_map. end ())
281- throw " variable map error " ;
280+ INVARIANT (
281+ it != variable_map. end (), " variable not found in the variable map " ) ;
282282
283283 const exprt &sym=it->second .first ;
284284 unsigned index=it->second .second ;
@@ -293,7 +293,9 @@ const exprt qbf_bdd_certificatet::f_get(literalt l)
293293 else
294294 {
295295 // skolem functions for existentials
296- assert (q.type ==quantifiert::EXISTENTIAL);
296+ INVARIANT (
297+ q.type == quantifiert::EXISTENTIAL,
298+ " only quantified literals are supported" );
297299
298300 function_cachet::const_iterator it=function_cache.find (l.var_no ());
299301 if (it!=function_cache.end ())
@@ -310,7 +312,9 @@ const exprt qbf_bdd_certificatet::f_get(literalt l)
310312
311313 // no cached function, so construct one
312314
313- assert (model_bdds[l.var_no ()]!=NULL );
315+ INVARIANT (
316+ model_bdds[l.var_no ()] != nullptr ,
317+ " there must be a model BDD for the literal" );
314318 BDD &model=*model_bdds[l.var_no ()];
315319
316320 #if 0
0 commit comments