21 #include <minisat/core/Solver.h>
22 #include <minisat/simp/SimpSolver.h>
25 # define l_False Minisat::l_False
26 # define l_True Minisat::l_True
30 #error "Expected HAVE_MINISAT2"
33 void convert(
const bvt &bv, Minisat::vec<Minisat::Lit> &dest)
36 bv.size() <=
static_cast<std::size_t
>(std::numeric_limits<int>::max()));
37 dest.capacity(
static_cast<int>(bv.size()));
39 for(
const auto &literal : bv)
41 if(!literal.is_false())
42 dest.push(Minisat::mkLit(literal.var_no(), literal.sign()));
49 bv.size() <=
static_cast<std::size_t
>(std::numeric_limits<int>::max()));
50 dest.capacity(
static_cast<int>(bv.size()));
52 for(
const auto &literal : bv)
55 if(!literal.is_true())
56 dest.push(Minisat::mkLit(literal.var_no(), literal.sign()));
100 catch(Minisat::OutOfMemoryException)
103 status = statust::ERROR;
104 throw std::bad_alloc();
122 return "MiniSAT 2.2.1 without simplifier";
127 return "MiniSAT 2.2.1 with simplifier";
133 while((
unsigned)
solver->nVars()<no_variables())
144 for(
const auto &literal : bv)
146 if(literal.is_true())
148 else if(!literal.is_false())
151 literal.var_no() < (
unsigned)
solver->nVars(),
152 "variable not added yet");
156 Minisat::vec<Minisat::Lit> c;
173 static size_t cnf_clause_index = 0;
175 bool clause_removed = process_clause(bv, cnf);
180 solver_hardness->register_clause(
181 bv, cnf, cnf_clause_index, !clause_removed);
186 catch(
const Minisat::OutOfMemoryException &)
189 status = statust::ERROR;
190 throw std::bad_alloc();
206 template <
typename T>
211 log.statistics() << (no_variables() - 1) <<
" variables, "
220 log.status() <<
"SAT checker inconsistent: instance is UNSATISFIABLE"
222 status = statust::UNSAT;
223 return resultt::P_UNSATISFIABLE;
227 for(
const auto &assumption : assumptions)
229 if(assumption.is_false())
231 log.status() <<
"got FALSE as assumption: instance is UNSATISFIABLE"
233 status = statust::UNSAT;
234 return resultt::P_UNSATISFIABLE;
238 Minisat::vec<Minisat::Lit> solver_assumptions;
241 using Minisat::lbool;
245 void (*old_handler)(int) = SIG_ERR;
247 if(time_limit_seconds != 0)
251 if(old_handler == SIG_ERR)
254 alarm(time_limit_seconds);
257 lbool solver_result =
solver->solveLimited(solver_assumptions);
259 if(old_handler != SIG_ERR)
262 signal(SIGALRM, old_handler);
268 if(time_limit_seconds != 0)
270 log.warning() <<
"Time limit ignored (not supported on Win32 yet)"
278 if(solver_result ==
l_True)
282 status = statust::SAT;
283 return resultt::P_SATISFIABLE;
289 status = statust::UNSAT;
290 return resultt::P_UNSATISFIABLE;
294 status = statust::ERROR;
295 return resultt::P_ERROR;
297 catch(
const Minisat::OutOfMemoryException &)
300 status=statust::ERROR;
301 return resultt::P_ERROR;
313 bool sign = a.
sign();
316 solver->model.growTo(v + 1);
318 solver->model[v] = Minisat::lbool(value);
320 catch(
const Minisat::OutOfMemoryException &)
323 status = statust::ERROR;
324 throw std::bad_alloc();
328 template <
typename T>
332 solver(std::make_unique<T>()),
333 time_limit_seconds(0)
337 template <
typename T>
345 for(
int i=0; i<
solver->conflict.size(); i++)
346 if(var(
solver->conflict[i])==v)
365 catch(
const Minisat::OutOfMemoryException &)
369 throw std::bad_alloc();
bool is_in_conflict(literalt a) const override
Returns true if an assumption is in the final conflict.
std::unique_ptr< Minisat::SimpSolver > solver
~satcheck_minisat2_baset() override
A default destructor defined in the .cpp is used to ensure the unique_ptr to the solver is correctly ...
resultt do_prop_solve(const bvt &) override
satcheck_minisat2_baset(message_handlert &message_handler)
void set_polarity(literalt a, bool value)
void lcnf(const bvt &bv) override final
tvt l_get(literalt a) const override final
void set_assignment(literalt a, bool value) override
std::string solver_text() const override
void set_frozen(literalt a) override final
bool is_eliminated(literalt a) const
std::string solver_text() const override final
std::vector< literalt > bvt
static Minisat::Solver * solver_to_interrupt
static void interrupt_solver(int signum)
void convert_assumptions(const bvt &bv, Minisat::vec< Minisat::Lit > &dest)
void convert(const bvt &bv, Minisat::vec< Minisat::Lit > &dest)
void solver(std::vector< framet > &frames, const std::unordered_set< symbol_exprt, irep_hash > &address_taken, const solver_optionst &solver_options, const namespacet &ns, std::vector< propertyt > &properties, std::size_t property_index)
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.