Go to the documentation of this file.
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)
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;
133 static size_t cnf_clause_index = 0;
135 bool clause_removed = process_clause(bv, cnf);
145 catch(Glucose::OutOfMemoryException)
147 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
148 status = statust::ERROR;
149 throw std::bad_alloc();
153 template <
typename T>
159 log.statistics() << (no_variables() - 1) <<
" variables, "
168 log.status() <<
"SAT checker inconsistent: instance is UNSATISFIABLE"
174 bool has_false =
false;
176 for(
const auto &literal : assumptions)
178 if(literal.is_false())
184 log.status() <<
"got FALSE as assumption: instance is UNSATISFIABLE"
189 Glucose::vec<Glucose::Lit> solver_assumptions;
190 convert(assumptions, solver_assumptions);
192 if(
solver->solve(solver_assumptions))
194 log.status() <<
"SAT checker: instance is SATISFIABLE"
196 status = statust::SAT;
197 return resultt::P_SATISFIABLE;
201 log.status() <<
"SAT checker: instance is UNSATISFIABLE"
207 status = statust::UNSAT;
208 return resultt::P_UNSATISFIABLE;
210 catch(Glucose::OutOfMemoryException)
212 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
213 status = statust::ERROR;
214 throw std::bad_alloc();
226 bool sign = a.
sign();
229 solver->model.growTo(v + 1);
231 solver->model[v] = Glucose::lbool(value);
233 catch(Glucose::OutOfMemoryException)
235 log.error() <<
"SAT checker ran out of memory" <<
messaget::eom;
236 status = statust::ERROR;
237 throw std::bad_alloc();
241 template <
typename T>
248 template <
typename T>
256 for(
int i=0; i<
solver->conflict.size(); i++)
257 if(var(
solver->conflict[i])==v)
268 for(
const auto &literal : assumptions)
271 !literal.is_constant(),
"assumption literals must not be constant");
288 catch(Glucose::OutOfMemoryException)
292 throw std::bad_alloc();
void set_frozen(literalt a) override
~satcheck_glucose_baset() override
A default destructor defined in the .cpp is used to ensure the unique_ptr to the solver is correctly ...
std::vector< literalt > bvt
void set_assignment(literalt a, bool value) override
void set_assumptions(const bvt &_assumptions) override
std::unique_ptr< Glucose::SimpSolver > solver
void register_clause(const bvt &bv, const bvt &cnf, const size_t cnf_clause_index, bool register_cnf)
Called e.g.
std::unique_ptr< T > util_make_unique(Ts &&... ts)
#define PRECONDITION(CONDITION)
tvt l_get(literalt a) const override
const std::string solver_text() override
bool is_in_conflict(literalt a) const override
Returns true if an assumption is in the final conflict.
const std::string solver_text() override
void convert(const bvt &bv, Glucose::vec< Glucose::Lit > &dest)
A structure that facilitates collecting the complexity statistics from a decision procedure.
int solver(std::istream &in)
void lcnf(const bvt &bv) override
bool is_eliminated(literalt a) const
satcheck_glucose_baset(message_handlert &message_handler)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
resultt do_prop_solve() override
void set_polarity(literalt a, bool value)
void with_solver_hardness(T &maybe_hardness_collector, hardness_collectort::handlert handler)