*/
minisat::Lit lookupInCache(const Node & n) const;
- /**
- * Empties the internal translation cache.
- */
- void flushCache();
//negotiates the mapping of atoms to literals with PropEngine
void registerMapping(const Node & node, minisat::Lit lit, bool atom = false);
*/
CnfStream(CVC4::PropEngine *pe);
+
+ /**
+ * Empties the internal translation cache.
+ */
+ void flushCache();
+
/**
* Converts and asserts a formula.
* @param n node to convert and assert
PropEngine::PropEngine(DecisionEngine& de, TheoryEngine& te) :
d_de(de),
- d_te(te){
+ d_te(te),
+ d_restartMayBeNeeded(false){
+ d_sat = new Solver();
d_cnfStream = new CVC4::prop::TseitinCnfStream(this);
}
PropEngine::~PropEngine(){
delete d_cnfStream;
+ delete d_sat;
}
*for restarting the sat solver
*/
//TODO assert that each lit has been mapped to an atom or requested
- d_sat.addClause(c);
+ d_sat->addClause(c);
}
void PropEngine::registerAtom(const Node & n, Lit l){
}
Lit PropEngine::requestFreshLit(){
- Var v = d_sat.newVar();
+ Var v = d_sat->newVar();
Lit l(v,false);
return l;
}
void PropEngine::assertFormula(const Node& node) {
d_cnfStream->convertAndAssert(node);
+ d_assertionList.push_back(node);
+}
+
+void PropEngine::restart(){
+ delete d_sat;
+ d_sat = new Solver();
+ d_cnfStream->flushCache();
+ d_atom2lit.clear();
+ d_lit2atom.clear();
+
+ for(vector<Node>::iterator iter = d_assertionList.begin();
+ iter != d_assertionList.end(); ++iter){
+ d_cnfStream->convertAndAssert(*iter);
+ }
}
void PropEngine::solve() {
+ if(d_restartMayBeNeeded)
+ restart();
- //TODO: may need to restart if a previous query returned false
+ d_sat->verbosity = 1;
+ bool result = d_sat->solve();
- d_sat.verbosity = 1;
- bool result = d_sat.solve();
+ if(!result){
+ d_restartMayBeNeeded = true;
+ }
Notice() << "result is " << (result ? "sat/invalid" : "unsat/valid") << endl;
}
* and to start from scratch everytime. (Avoid push/pop problems?)
* Is this right?
*/
- CVC4::prop::minisat::SimpSolver d_sat;
+ CVC4::prop::minisat::Solver * d_sat;
std::map<Node, CVC4::prop::minisat::Lit> d_atom2lit;
*/
void registerAtom(const Node & n, CVC4::prop::minisat::Lit l);
+ /**
+ * Flags whether the solver may need to have its state reset before
+ * solving occurs
+ */
+ bool d_restartMayBeNeeded;
+
+ /**
+ * Cleans existing state in the PropEngine and reinitializes the state.
+ */
+ void restart();
+
+ /**
+ * Keeps track of all of the assertions that need to be made.
+ */
+ std::vector<Node> d_assertionList;
CVC4::prop::minisat::Lit requestFreshLit();