summaryrefslogtreecommitdiff
path: root/src/prop/prop_engine.cpp
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2010-02-04 00:47:45 +0000
committerTim King <taking@cs.nyu.edu>2010-02-04 00:47:45 +0000
commit7329c1f1e3603c86c7ad88cbdefe2393d9740d98 (patch)
treee48162e6caf29209ccc0d6bc2d56832b33d17859 /src/prop/prop_engine.cpp
parentd5346f64d7031d17f865cb128d5f1171f60074ed (diff)
Fixes to the cnf converter. Also a barebones utility for printing out a satisifying model.
Diffstat (limited to 'src/prop/prop_engine.cpp')
-rw-r--r--src/prop/prop_engine.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/prop/prop_engine.cpp b/src/prop/prop_engine.cpp
index 3455b845e..8485a6e32 100644
--- a/src/prop/prop_engine.cpp
+++ b/src/prop/prop_engine.cpp
@@ -70,6 +70,11 @@ Lit PropEngine::requestFreshLit(){
}
void PropEngine::assertFormula(const Node& node) {
+
+ Debug("prop") << "Asserting ";
+ node.printAst(Debug("prop"));
+ Debug("prop") << endl;
+
d_cnfStream->convertAndAssert(node);
d_assertionList.push_back(node);
}
@@ -87,6 +92,12 @@ void PropEngine::restart(){
}
}
+static void printLit(ostream & out, Lit l) {
+ const char * s = (sign(l))?"~":" ";
+ out << s << var(l);
+
+}
+
Result PropEngine::solve() {
if(d_restartMayBeNeeded)
restart();
@@ -98,7 +109,28 @@ Result PropEngine::solve() {
d_restartMayBeNeeded = true;
}
- Notice() << "result is " << (result ? "sat/invalid" : "unsat/valid") << endl;
+ Message() << "result is " << (result ? "sat/invalid" : "unsat/valid") << endl;
+
+ if(result){
+ for(map<Node,Lit>::iterator atomIter = d_atom2lit.begin();
+ atomIter != d_atom2lit.end();
+ ++atomIter){
+ Node n = (*atomIter).first;
+ Lit l = (*atomIter).second;
+
+ lbool lb = d_sat->modelValue(l);
+
+ Notice() << n << "->" << lb.toInt() << endl;
+ }
+ }else{
+ // unsat case
+ Notice() << "Conflict {";
+ for(int i=0; i< d_sat->conflict.size(); i++){
+ Notice() << endl << " ";
+ printLit(Notice(), d_sat->conflict[i]);
+ }
+ Notice() << endl << "}" << endl;
+ }
return Result(result ? Result::SAT : Result::UNSAT);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback