17 #include <core/Solver.h>
18 #include <simp/SimpSolver.h>
21 #error "Expected HAVE_GLUCOSE"
24 void convert(
const bvt &bv, Glucose::vec<Glucose::Lit> &dest)
26 dest.capacity(bv.size());
28 for(
const auto &literal : bv)
30 if(!literal.is_false())
31 dest.push(Glucose::mkLit(literal.var_no(), literal.sign()));
73 catch(Glucose::OutOfMemoryException)
75 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
76 status = statust::ERROR;
77 throw std::bad_alloc();
83 return "Glucose Syrup without simplifier";
88 return "Glucose Syrup with simplifier";
94 while((
unsigned)
solver->nVars()<no_variables())
105 for(
const auto &literal : bv)
107 if(literal.is_true())
109 else if(!literal.is_false())
112 literal.var_no() < (
unsigned)
solver->nVars(),
113 "variable not added yet");
117 Glucose::vec<Glucose::Lit> c;
134 static size_t cnf_clause_index = 0;
136 bool clause_removed = process_clause(bv, cnf);
141 solver_hardness->register_clause(
142 bv, cnf, cnf_clause_index, !clause_removed);
147 catch(Glucose::OutOfMemoryException)
149 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
150 status = statust::ERROR;
151 throw std::bad_alloc();
155 template <
typename T>
161 log.statistics() << (no_variables() - 1) <<
" variables, "
170 log.status() <<
"SAT checker inconsistent: instance is UNSATISFIABLE"
176 bool has_false =
false;
178 for(
const auto &literal : assumptions)
180 if(literal.is_false())
186 log.status() <<
"got FALSE as assumption: instance is UNSATISFIABLE"
191 Glucose::vec<Glucose::Lit> solver_assumptions;
192 convert(assumptions, solver_assumptions);
194 if(
solver->solve(solver_assumptions))
196 log.status() <<
"SAT checker: instance is SATISFIABLE"
198 status = statust::SAT;
199 return resultt::P_SATISFIABLE;
203 log.status() <<
"SAT checker: instance is UNSATISFIABLE"
209 status = statust::UNSAT;
210 return resultt::P_UNSATISFIABLE;
212 catch(Glucose::OutOfMemoryException)
214 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
215 status = statust::ERROR;
216 throw std::bad_alloc();
228 bool sign = a.
sign();
231 solver->model.growTo(v + 1);
233 solver->model[v] = Glucose::lbool(value);
235 catch(Glucose::OutOfMemoryException)
237 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
238 status = statust::ERROR;
239 throw std::bad_alloc();
243 template <
typename T>
250 template <
typename T>
258 for(
int i=0; i<
solver->conflict.size(); i++)
259 if(var(
solver->conflict[i])==v)
270 for(
const auto &literal : assumptions)
273 !literal.is_constant(),
"assumption literals must not be constant");
290 catch(Glucose::OutOfMemoryException)
294 throw std::bad_alloc();