Fix collect model info for higher-order (#3409)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Sun, 27 Oct 2019 22:47:56 +0000 (17:47 -0500)
committerAndres Noetzli <andres.noetzli@gmail.com>
Sun, 27 Oct 2019 22:47:56 +0000 (15:47 -0700)
This ensures we add lemmas when collect model info fails for the higher order extension of UF. This fixes #3405 (that benchmark now answers unknown).

src/theory/theory_model_builder.cpp
src/theory/uf/ho_extension.cpp
src/theory/uf/theory_uf.cpp

index d3fde58a7718ff4b0518fb374117a9c74ff11235..7a2a9ae1654761d665025d7668b8f68e332cde19 100644 (file)
@@ -301,12 +301,17 @@ bool TheoryEngineModelBuilder::buildModel(Model* m)
                          << std::endl;
   if (!d_te->collectModelInfo(tm))
   {
+    Trace("model-builder")
+        << "TheoryEngineModelBuilder: fail collect model info" << std::endl;
     return false;
   }
 
   // model-builder specific initialization
   if (!preProcessBuildModel(tm))
   {
+    Trace("model-builder")
+        << "TheoryEngineModelBuilder: fail preprocess build model."
+        << std::endl;
     return false;
   }
 
@@ -813,9 +818,11 @@ bool TheoryEngineModelBuilder::buildModel(Model* m)
   // modelBuilder-specific initialization
   if (!processBuildModel(tm))
   {
+    Trace("model-builder")
+        << "TheoryEngineModelBuilder: fail process build model." << std::endl;
     return false;
   }
-
+  Trace("model-builder") << "TheoryEngineModelBuilder: success" << std::endl;
   tm->d_modelBuiltSuccess = true;
   return true;
 }
index 88b2ba8d2573d18823fdd332b3ecfe5812aaa804..0ca9b151fcb564344599267b9529da5c2fd113fb 100644 (file)
@@ -186,6 +186,7 @@ Node HoExtension::getApplyUfForHoApply(Node node)
 unsigned HoExtension::checkExtensionality(TheoryModel* m)
 {
   eq::EqualityEngine* ee = d_parent.getEqualityEngine();
+  NodeManager* nm = NodeManager::currentNM();
   unsigned num_lemmas = 0;
   bool isCollectModel = (m != nullptr);
   Trace("uf-ho") << "HoExtension::checkExtensionality, collectModel="
@@ -243,6 +244,11 @@ unsigned HoExtension::checkExtensionality(TheoryModel* m)
                 << "Add extensionality deq to model : " << edeq << std::endl;
             if (!m->assertEquality(edeq[0][0], edeq[0][1], false))
             {
+              Node eq = edeq[0][0].eqNode(edeq[0][1]);
+              Node lem = nm->mkNode(OR, deq.negate(), eq);
+              Trace("uf-ho") << "HoExtension: cmi extensionality lemma " << lem
+                             << std::endl;
+              d_parent.getOutputChannel().lemma(lem);
               return 1;
             }
           }
@@ -423,6 +429,10 @@ bool HoExtension::collectModelInfoHoTerm(Node n, TheoryModel* m)
     Node hn = TheoryUfRewriter::getHoApplyForApplyUf(n);
     if (!m->assertEquality(n, hn, true))
     {
+      Node eq = n.eqNode(hn);
+      Trace("uf-ho") << "HoExtension: cmi app completion lemma " << eq
+                     << std::endl;
+      d_parent.getOutputChannel().lemma(eq);
       return false;
     }
   }
index 6284ae31e19d0f35bce4b8912316200ea91fbb17..76e6e08bcefbcc625fab8c2abfc8e60d178e93cb 100644 (file)
@@ -324,6 +324,7 @@ bool TheoryUF::collectModelInfo(TheoryModel* m)
 
   if (!m->assertEqualityEngine(&d_equalityEngine, &termSet))
   {
+    Trace("uf") << "Collect model info fail UF" << std::endl;
     return false;
   }
 
@@ -332,6 +333,7 @@ bool TheoryUF::collectModelInfo(TheoryModel* m)
     // function equivalence classes.
     if (!d_ho->collectModelInfoHo(termSet, m))
     {
+      Trace("uf") << "Collect model info fail HO" << std::endl;
       return false;
     }
   }