BVMinisat::sign(lit));
}
-SatValue BVMinisatSatSolver::toSatLiteralValue(bool res) {
- if(res) return SAT_VALUE_TRUE;
- else return SAT_VALUE_FALSE;
-}
-
SatValue BVMinisatSatSolver::toSatLiteralValue(BVMinisat::lbool res) {
if(res == (BVMinisat::lbool((uint8_t)0))) return SAT_VALUE_TRUE;
if(res == (BVMinisat::lbool((uint8_t)2))) return SAT_VALUE_UNKNOWN;
static SatVariable toSatVariable(BVMinisat::Var var);
static BVMinisat::Lit toMinisatLit(SatLiteral lit);
static SatLiteral toSatLiteral(BVMinisat::Lit lit);
- static SatValue toSatLiteralValue(bool res);
static SatValue toSatLiteralValue(BVMinisat::lbool res);
static void toMinisatClause(SatClause& clause, BVMinisat::vec<BVMinisat::Lit>& minisat_clause);
// Solving:
//
bool simplify (); // Removes already satisfied clauses.
- bool solve (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions.
+ lbool solve (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions.
lbool solveLimited (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions (With resource constraints).
- bool solve (); // Search without assumptions.
- bool solve (Lit p); // Search for a model that respects a single assumption.
- bool solve (Lit p, Lit q); // Search for a model that respects two assumptions.
- bool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
+ lbool solve (); // Search without assumptions.
+ lbool solve (Lit p); // Search for a model that respects a single assumption.
+ lbool solve (Lit p, Lit q); // Search for a model that respects two assumptions.
+ lbool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
bool okay () const; // FALSE means solver is in a conflicting state
lbool assertAssumption(Lit p, bool propagate); // Assert a new assumption, start BCP if propagate = true
lbool propagateAssumptions(); // Do BCP over asserted assumptions
(conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
(propagation_budget < 0 || propagations < (uint64_t)propagation_budget); }
-// FIXME: after the introduction of asynchronous interrruptions the solve-versions that return a
-// pure bool do not give a safe interface. Either interrupts must be possible to turn off here, or
-// all calls to solve must return an 'lbool'. I'm not yet sure which I prefer.
-inline bool Solver::solve () { budgetOff(); return solve_() == l_True; }
-inline bool Solver::solve (Lit p) { budgetOff(); assumptions.push(p); return solve_() == l_True; }
-inline bool Solver::solve (Lit p, Lit q) { budgetOff(); assumptions.push(p); assumptions.push(q); return solve_() == l_True; }
-inline bool Solver::solve (Lit p, Lit q, Lit r) { budgetOff(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_() == l_True; }
-inline bool Solver::solve (const vec<Lit>& assumps){ budgetOff(); assumps.copyTo(assumptions); return solve_() == l_True; }
+inline lbool Solver::solve () { budgetOff(); return solve_(); }
+inline lbool Solver::solve (Lit p) { budgetOff(); assumptions.push(p); return solve_(); }
+inline lbool Solver::solve (Lit p, Lit q) { budgetOff(); assumptions.push(p); assumptions.push(q); return solve_(); }
+inline lbool Solver::solve (Lit p, Lit q, Lit r) { budgetOff(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(); }
+inline lbool Solver::solve (const vec<Lit>& assumps){ budgetOff(); assumps.copyTo(assumptions); return solve_(); }
inline lbool Solver::solveLimited (const vec<Lit>& assumps){ assumps.copyTo(assumptions); return solve_(); }
inline bool Solver::okay () const { return ok; }
// Solving:
//
- bool solve (const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
- lbool solveLimited(const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
- lbool solveLimited(bool do_simp = true, bool turn_off_simp = false);
- bool solve ( bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p , bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p, Lit q, bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p, Lit q, Lit r, bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+ lbool solveLimited(const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+ lbool solveLimited(bool do_simp = true, bool turn_off_simp = false);
+ lbool solve ( bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p , bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p, Lit q, bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p, Lit q, Lit r, bool do_simp = true, bool turn_off_simp = false);
bool eliminate (bool turn_off_elim = false); // Perform variable elimination based simplification.
// Memory managment:
inline bool SimpSolver::addClause (Lit p, Lit q, Lit r) { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
inline void SimpSolver::setFrozen (Var v, bool b) { frozen[v] = (char)b; if (use_simplification && !b) { updateElimHeap(v); } }
-inline bool SimpSolver::solve ( bool do_simp, bool turn_off_simp) { budgetOff(); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p , bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.push(p); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p, Lit q, bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.push(p); assumptions.push(q); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p, Lit q, Lit r, bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
+inline lbool SimpSolver::solve ( bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ return solve_(do_simp, turn_off_simp);
+ }
+inline lbool SimpSolver::solve (Lit p , bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.push(p);
+ return solve_(do_simp, turn_off_simp);
+ }
+inline lbool SimpSolver::solve (Lit p, Lit q, bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.push(p);
+ assumptions.push(q);
+ return solve_(do_simp, turn_off_simp);
+ }
+inline lbool SimpSolver::solve (Lit p, Lit q, Lit r, bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.push(p);
+ assumptions.push(q);
+ assumptions.push(r);
+ return solve_(do_simp, turn_off_simp);
+ }
+inline lbool SimpSolver::solve (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
budgetOff(); assumps.copyTo(assumptions);
- return solve_(do_simp, turn_off_simp) == l_True;
+ return solve_(do_simp, turn_off_simp);
}
inline lbool SimpSolver::solveLimited (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
// Solving:
//
bool simplify (); // Removes already satisfied clauses.
- bool solve (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions.
+ lbool solve (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions.
lbool solveLimited (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions (With resource constraints).
- bool solve (); // Search without assumptions.
- bool solve (Lit p); // Search for a model that respects a single assumption.
- bool solve (Lit p, Lit q); // Search for a model that respects two assumptions.
- bool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
+ lbool solve (); // Search without assumptions.
+ lbool solve (Lit p); // Search for a model that respects a single assumption.
+ lbool solve (Lit p, Lit q); // Search for a model that respects two assumptions.
+ lbool solve (Lit p, Lit q, Lit r); // Search for a model that respects three assumptions.
bool okay () const; // FALSE means solver is in a conflicting state
void toDimacs ();
inline void Solver::clearInterrupt(){ asynch_interrupt = false; }
inline void Solver::budgetOff(){ conflict_budget = propagation_budget = -1; }
-// FIXME: after the introduction of asynchronous interrruptions the solve-versions that return a
-// pure bool do not give a safe interface. Either interrupts must be possible to turn off here, or
-// all calls to solve must return an 'lbool'. I'm not yet sure which I prefer.
-inline bool Solver::solve () { budgetOff(); assumptions.clear(); return solve_() == l_True; }
-inline bool Solver::solve (Lit p) { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_() == l_True; }
-inline bool Solver::solve (Lit p, Lit q) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_() == l_True; }
-inline bool Solver::solve (Lit p, Lit q, Lit r) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_() == l_True; }
-inline bool Solver::solve (const vec<Lit>& assumps){ budgetOff(); assumps.copyTo(assumptions); return solve_() == l_True; }
+inline lbool Solver::solve () { budgetOff(); assumptions.clear(); return solve_(); }
+inline lbool Solver::solve (Lit p) { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_(); }
+inline lbool Solver::solve (Lit p, Lit q) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_(); }
+inline lbool Solver::solve (Lit p, Lit q, Lit r) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(); }
+inline lbool Solver::solve (const vec<Lit>& assumps){ budgetOff(); assumps.copyTo(assumptions); return solve_(); }
inline lbool Solver::solveLimited (const vec<Lit>& assumps){ assumps.copyTo(assumptions); return solve_(); }
inline bool Solver::okay () const { return ok; }
Minisat::sign(lit));
}
-SatValue MinisatSatSolver::toSatLiteralValue(bool res) {
- if(res) return SAT_VALUE_TRUE;
- else return SAT_VALUE_FALSE;
-}
-
SatValue MinisatSatSolver::toSatLiteralValue(Minisat::lbool res) {
if(res == (Minisat::lbool((uint8_t)0))) return SAT_VALUE_TRUE;
if(res == (Minisat::lbool((uint8_t)2))) return SAT_VALUE_UNKNOWN;
static SatVariable toSatVariable(Minisat::Var var);
static Minisat::Lit toMinisatLit(SatLiteral lit);
static SatLiteral toSatLiteral(Minisat::Lit lit);
- static SatValue toSatLiteralValue(bool res);
static SatValue toSatLiteralValue(Minisat::lbool res);
static Minisat::lbool toMinisatlbool(SatValue val);
//(Commented because not in use) static bool tobool(SatValue val);
// Solving:
//
- bool solve (const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
- lbool solveLimited(const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
- bool solve ( bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p , bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p, Lit q, bool do_simp = true, bool turn_off_simp = false);
- bool solve (Lit p, Lit q, Lit r, bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+ lbool solveLimited(const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+ lbool solve ( bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p , bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p, Lit q, bool do_simp = true, bool turn_off_simp = false);
+ lbool solve (Lit p, Lit q, Lit r, bool do_simp = true, bool turn_off_simp = false);
bool eliminate (bool turn_off_elim = false); // Perform variable elimination based simplification.
// Memory managment:
{ add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp, removable, proof_id); }
inline void SimpSolver::setFrozen (Var v, bool b) { frozen[v] = (char)b; if (use_simplification && !b) { updateElimHeap(v); } }
-inline bool SimpSolver::solve ( bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.clear(); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p , bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p, Lit q, bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (Lit p, Lit q, Lit r, bool do_simp, bool turn_off_simp) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(do_simp, turn_off_simp) == l_True; }
-inline bool SimpSolver::solve (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
- budgetOff(); assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp) == l_True; }
+// the solver can always return unknown due to resource limiting
+inline lbool SimpSolver::solve ( bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.clear();
+ return solve_(do_simp, turn_off_simp);
+ }
+
+inline lbool SimpSolver::solve (Lit p , bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.clear();
+ assumptions.push(p);
+ return solve_(do_simp, turn_off_simp);
+ }
+
+inline lbool SimpSolver::solve (Lit p, Lit q, bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.clear();
+ assumptions.push(p);
+ assumptions.push(q);
+ return solve_(do_simp, turn_off_simp);
+ }
+
+inline lbool SimpSolver::solve (Lit p, Lit q, Lit r, bool do_simp, bool turn_off_simp) {
+ budgetOff();
+ assumptions.clear();
+ assumptions.push(p);
+ assumptions.push(q);
+ assumptions.push(r);
+ return solve_(do_simp, turn_off_simp);
+ }
+
+ inline lbool SimpSolver::solve (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
+ budgetOff();
+ assumps.copyTo(assumptions);
+ return solve_(do_simp, turn_off_simp);
+ }
inline lbool SimpSolver::solveLimited (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){
assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp); }
Trace("limit") << "ResourceManager::spendResource: elapsed time" << d_cumulativeTimer.elapsed() << std::endl;
}
- if (smt::smtEngineInScope()) {
- theory::Rewriter::clearCaches();
- }
if (d_isHardLimit) {
+ if (smt::smtEngineInScope()) {
+ theory::Rewriter::clearCaches();
+ }
throw UnsafeInterruptException();
}