fix --check-model --finite-model-find when used together (related to bug 486)
authorMorgan Deters <mdeters@cs.nyu.edu>
Fri, 25 Jan 2013 22:06:02 +0000 (17:06 -0500)
committerMorgan Deters <mdeters@cs.nyu.edu>
Fri, 25 Jan 2013 22:39:21 +0000 (17:39 -0500)
src/smt/smt_engine.cpp
src/theory/model.cpp
src/theory/theory_engine.cpp

index 77e43d518fde80c224ed3b9703472c436ad294a4..66c7e4cbcbf9ce7889aef016255fe477a84b47ca 100644 (file)
@@ -2443,7 +2443,7 @@ Result SmtEngine::checkSat(const Expr& ex) throw(TypeCheckingException, ModalExc
   Trace("smt") << "SmtEngine::checkSat(" << e << ") => " << r << endl;
 
   // Check that SAT results generate a model correctly.
-  if(options::checkModels()){
+  if(options::checkModels()) {
     if(r.asSatisfiabilityResult().isSat() == Result::SAT ||
        (r.isUnknown() && r.whyUnknown() == Result::INCOMPLETE) ){
       checkModel(/* hard failure iff */ ! r.isUnknown());
@@ -2513,7 +2513,7 @@ Result SmtEngine::query(const Expr& ex) throw(TypeCheckingException, ModalExcept
   Trace("smt") << "SMT query(" << e << ") ==> " << r << endl;
 
   // Check that SAT results generate a model correctly.
-  if(options::checkModels()){
+  if(options::checkModels()) {
     if(r.asSatisfiabilityResult().isSat() == Result::SAT ||
        (r.isUnknown() && r.whyUnknown() == Result::INCOMPLETE) ){
       checkModel(/* hard failure iff */ ! r.isUnknown());
index 2333a4394ae5cd807bb51d048ea395752e5ac276..713587be267ef959d5291527042503015d45ee22 100644 (file)
@@ -131,6 +131,9 @@ Node TheoryModel::getModelValue(TNode n, bool hasBoundVars) const
         children.push_back(val);
       }
       Node val = Rewriter::rewrite(NodeManager::currentNM()->mkNode(n.getKind(), children));
+      if(val.getKind() == kind::CARDINALITY_CONSTRAINT) {
+        val = NodeManager::currentNM()->mkConst(getCardinality(val[0].getType().toType()).getFiniteCardinality() <= val[1].getConst<Rational>().getNumerator());
+      }
       Assert(hasBoundVars || val.isConst());
       return val;
     }
index 2ea0e866fc5326e6cc4db5f9223ddfa6c8d5ad9b..a23480eeb02f148d9af82519840d128688c5ae2a 100644 (file)
@@ -1378,19 +1378,19 @@ void TheoryEngine::handleUserAttribute(const char* attr, Theory* t) {
   d_attr_handle[ str ].push_back( t );
 }
 
-void TheoryEngine::checkTheoryAssertionsWithModel()
-{
-  for (TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
-    Theory* theory = d_theoryTable[theoryId];
-    if (theory && d_logicInfo.isTheoryEnabled(theoryId)) {
-      if (theoryId == THEORY_QUANTIFIERS || theoryId == THEORY_REWRITERULES) {
-        continue;
-      }
-      context::CDList<Assertion>::const_iterator it = theory->facts_begin(), it_end = theory->facts_end();
-      for (unsigned i = 0; it != it_end; ++ it, ++i) {
-        Node assertion = (*it).assertion;
-        Node val = getModel()->getValue(assertion);
-        Assert(val == d_true);
+void TheoryEngine::checkTheoryAssertionsWithModel() {
+  for(TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
+    if(theoryId != THEORY_REWRITERULES) {
+      Theory* theory = d_theoryTable[theoryId];
+      if(theory && d_logicInfo.isTheoryEnabled(theoryId)) {
+        for(context::CDList<Assertion>::const_iterator it = theory->facts_begin(),
+              it_end = theory->facts_end();
+            it != it_end;
+            ++it) {
+          Node assertion = (*it).assertion;
+          Node val = getModel()->getValue(assertion);
+          Assert(val == d_true);
+        }
       }
     }
   }