(proof-new) Allow null proofs from generators in LazyCDProof (#5196)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Tue, 6 Oct 2020 14:31:16 +0000 (09:31 -0500)
committerGitHub <noreply@github.com>
Tue, 6 Oct 2020 14:31:16 +0000 (09:31 -0500)
In some cases, a proof generator provided to a LazyCDProof may provide a null proof, which causes a segfault on proof-new currently. This PR makes LazyCDProof robust to this case; nullptr is interpreted as the fact is an assumption.

src/expr/lazy_proof.cpp
src/expr/proof_node_manager.cpp

index d66a8984b97bc3f7aae63992b7f556acb0b6f2b7..a96e30fde585b2fd5c6f76802500af07d4cb79aa 100644 (file)
@@ -83,16 +83,27 @@ std::shared_ptr<ProofNode> LazyCDProof::getProofFor(Node fact)
           // the current proof. Instead, it is only linked, and ignored on
           // future calls to getProofFor due to the check above.
           std::shared_ptr<ProofNode> pgc = pg->getProofFor(cfactGen);
-          if (isSym)
+          // If the proof was null, then the update is not performed. This is
+          // not considered an error, since this behavior is equivalent to
+          // if pg had provided the proof (ASSUME cfactGen). Ensuring the
+          // proper behavior wrt closed proofs should be done outside this
+          // method.
+          if (pgc != nullptr)
           {
-            d_manager->updateNode(cur, PfRule::SYMM, {pgc}, {});
-          }
-          else
-          {
-            d_manager->updateNode(cur, pgc.get());
+            Trace("lazy-cdproof-gen")
+                << "LazyCDProof: stored proof: " << *pgc.get() << std::endl;
+
+            if (isSym)
+            {
+              d_manager->updateNode(cur, PfRule::SYMM, {pgc}, {});
+            }
+            else
+            {
+              d_manager->updateNode(cur, pgc.get());
+            }
+            Trace("lazy-cdproof") << "LazyCDProof: Successfully added fact for "
+                                  << cfactGen << std::endl;
           }
-          Trace("lazy-cdproof") << "LazyCDProof: Successfully added fact for "
-                                << cfactGen << std::endl;
         }
         else
         {
index 9f60a49e4973586af6d6f6d1666c72cbb4589625..8ed9779d3691023e8956d7345ca5b0eb4e7adbe2 100644 (file)
@@ -254,6 +254,8 @@ bool ProofNodeManager::updateNode(
 
 bool ProofNodeManager::updateNode(ProofNode* pn, ProofNode* pnr)
 {
+  Assert(pn != nullptr);
+  Assert(pnr != nullptr);
   if (pn->getResult() != pnr->getResult())
   {
     return false;
@@ -296,6 +298,7 @@ bool ProofNodeManager::updateNodeInternal(
     const std::vector<Node>& args,
     bool needsCheck)
 {
+  Assert(pn != nullptr);
   // ---------------- check for cyclic
   std::unordered_map<const ProofNode*, bool> visited;
   std::unordered_map<const ProofNode*, bool>::iterator it;