[proofs] Fix assertion in EqProof conversion (#7522)
authorHaniel Barbosa <hanielbbarbosa@gmail.com>
Thu, 28 Oct 2021 18:59:43 +0000 (15:59 -0300)
committerGitHub <noreply@github.com>
Thu, 28 Oct 2021 18:59:43 +0000 (18:59 +0000)
Also improves a few traces.

Fixes cvc5/cvc5-projects#330

src/theory/uf/eq_proof.cpp
test/regress/CMakeLists.txt
test/regress/regress0/proofs/project-issue330-eqproof.smt2 [new file with mode: 0644]

index 45a00a620b49efe350572f46ee6ac92866eceefc..ab091cffde713af3d25ed3d5fae3c6ce14916a75 100644 (file)
@@ -91,8 +91,8 @@ void EqProof::cleanReflPremises(std::vector<Node>& premises) const
   if (newPremises.size() != size)
   {
     Trace("eqproof-conv") << "EqProof::cleanReflPremises: removed "
-                          << (newPremises.size() >= size
-                                  ? newPremises.size() - size
+                          << (size >= newPremises.size()
+                                  ? size - newPremises.size()
                                   : 0)
                           << " refl premises from " << premises << "\n";
     premises.clear();
@@ -138,6 +138,8 @@ bool EqProof::expandTransitivityForDisequalities(
   // if no equality of the searched form, nothing to do
   if (offending == size)
   {
+    Trace("eqproof-conv")
+        << "EqProof::expandTransitivityForDisequalities: no need.\n";
     return false;
   }
   NodeManager* nm = NodeManager::currentNM();
@@ -967,6 +969,7 @@ Node EqProof::addToProof(CDProof* p,
   if (d_id == MERGED_THROUGH_REFLEXIVITY
       || (d_node.getKind() == kind::EQUAL && d_node[0] == d_node[1]))
   {
+    Trace("eqproof-conv") << "EqProof::addToProof: refl step\n";
     Node conclusion =
         d_node.getKind() == kind::EQUAL ? d_node : d_node.eqNode(d_node);
     p->addStep(conclusion, PfRule::REFL, {}, {conclusion[0]});
@@ -1170,7 +1173,9 @@ Node EqProof::addToProof(CDProof* p,
         }
       }
     }
-    Assert(p->hasStep(conclusion));
+    Assert(p->hasStep(conclusion) || assumptions.count(conclusion))
+        << "Conclusion " << conclusion
+        << " does not have a step in the proof neither it's an assumption.\n";
     visited[d_node] = conclusion;
     return conclusion;
   }
index 2529a862291ee5017ee8f75f490405c6fb8983ac..2430eb13f9f7b9f9f59633cf80b3e63ada534e2c 100644 (file)
@@ -864,6 +864,7 @@ set(regress_0_tests
   regress0/proofs/open-pf-if-unordered-iff.smt2
   regress0/proofs/open-pf-rederivation.smt2
   regress0/proofs/project-issue317-inc-sat-conflictlit.smt2
+  regress0/proofs/project-issue330-eqproof.smt2
   regress0/proofs/qgu-fuzz-1-bool-sat.smt2
   regress0/proofs/qgu-fuzz-2-bool-chainres-checking.smt2
   regress0/proofs/qgu-fuzz-3-chainres-checking.smt2
diff --git a/test/regress/regress0/proofs/project-issue330-eqproof.smt2 b/test/regress/regress0/proofs/project-issue330-eqproof.smt2
new file mode 100644 (file)
index 0000000..1da7782
--- /dev/null
@@ -0,0 +1,7 @@
+; EXPECT: sat
+(set-logic QF_SLIA)
+(declare-const x String)
+(declare-const x1 Int)
+(set-option :check-proofs true)
+(declare-const _x String)
+(check-sat-assuming ((>= 0 (ite (= x (str.++ (str.from_code 0) (str.replace_all x (str.from_code 0) (str.++ (str.from_code 0) (str.from_code 0))) _x) (ite false x (str.++ _x _x _x)) x) x1 0))))
\ No newline at end of file