22#include <minisat/core/Solver.h>
23#include <minisat/simp/SimpSolver.h>
26#error "Expected HAVE_MINISAT2"
32 bv.size() <=
static_cast<std::size_t
>(std::numeric_limits<int>::max()));
33 dest.capacity(
static_cast<int>(bv.size()));
52 if(
a.var_no()>=(
unsigned)
solver->model.size())
82 catch(Minisat::OutOfMemoryException)
84 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
85 status = statust::ERROR;
86 throw std::bad_alloc();
104 return "MiniSAT 2.2.1 without simplifier";
109 return "MiniSAT 2.2.1 with simplifier";
115 while((
unsigned)
solver->nVars()<no_variables())
134 "variable not added yet");
138 Minisat::vec<Minisat::Lit>
c;
162 solver_hardness->register_clause(
168 catch(
const Minisat::OutOfMemoryException &)
170 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
171 status = statust::ERROR;
172 throw std::bad_alloc();
193 log.statistics() << (no_variables() - 1) <<
" variables, "
202 log.status() <<
"SAT checker inconsistent: instance is UNSATISFIABLE"
204 status = statust::UNSAT;
205 return resultt::P_UNSATISFIABLE;
209 for(
const auto &assumption : assumptions)
211 if(assumption.is_false())
213 log.status() <<
"got FALSE as assumption: instance is UNSATISFIABLE"
215 status = statust::UNSAT;
216 return resultt::P_UNSATISFIABLE;
223 using Minisat::lbool;
229 if(time_limit_seconds != 0)
234 log.warning() <<
"Failed to set solver time limit" <<
messaget::eom;
236 alarm(time_limit_seconds);
250 if(time_limit_seconds != 0)
252 log.warning() <<
"Time limit ignored (not supported on Win32 yet)"
262 log.status() <<
"SAT checker: instance is SATISFIABLE" <<
messaget::eom;
264 status = statust::SAT;
265 return resultt::P_SATISFIABLE;
270 log.status() <<
"SAT checker: instance is UNSATISFIABLE" <<
messaget::eom;
271 status = statust::UNSAT;
272 return resultt::P_UNSATISFIABLE;
275 log.status() <<
"SAT checker: timed out or other error" <<
messaget::eom;
276 status = statust::ERROR;
277 return resultt::P_ERROR;
279 catch(
const Minisat::OutOfMemoryException &)
281 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
282 status=statust::ERROR;
283 return resultt::P_ERROR;
294 unsigned v =
a.var_no();
295 bool sign =
a.sign();
298 solver->model.growTo(v + 1);
300 solver->model[v] = Minisat::lbool(value);
302 catch(
const Minisat::OutOfMemoryException &)
304 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
305 status = statust::ERROR;
306 throw std::bad_alloc();
315 time_limit_seconds(0)
327 for(
int i=0;
i<
solver->conflict.size();
i++)
328 if(var(
solver->conflict[
i])==v)
340 for(
const auto &assumption : bv)
342 if(!assumption.is_true())
344 assumptions.push_back(assumption);
359 solver->setFrozen(
a.var_no(),
true);
362 catch(
const Minisat::OutOfMemoryException &)
366 throw std::bad_alloc();
374 return solver->isEliminated(
a.var_no());
static bool convert(const irep_idt &identifier, const std::ostringstream &s, symbol_tablet &symbol_table, message_handlert &message_handler)
virtual void clear()
Reset the abstract state.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
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 ...
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
resultt do_prop_solve() override
void set_assignment(literalt a, bool value) override
void set_assumptions(const bvt &_assumptions) override
const std::string solver_text() override
void set_frozen(literalt a) override final
bool is_eliminated(literalt a) const
const std::string solver_text() override final
std::vector< literalt > bvt
std::unique_ptr< T > util_make_unique(Ts &&... ts)
static Minisat::Solver * solver_to_interrupt
static void interrupt_solver(int signum)
void convert(const bvt &bv, Minisat::vec< Minisat::Lit > &dest)
int solver(std::istream &in)
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.