[proof-new] Updating theory proxy to new proof infrastructure (#5653)
authorHaniel Barbosa <hanielbbarbosa@gmail.com>
Fri, 11 Dec 2020 21:58:13 +0000 (18:58 -0300)
committerGitHub <noreply@github.com>
Fri, 11 Dec 2020 21:58:13 +0000 (18:58 -0300)
src/prop/prop_engine.cpp
src/prop/prop_engine.h
src/prop/theory_proxy.cpp

index 8c1e452e7ac3ad4dd1e01c70a81599cc702477ff..e5efcbf8f850836859ed4503b6bf10d2236249a6 100644 (file)
@@ -78,6 +78,7 @@ PropEngine::PropEngine(TheoryEngine* te,
       d_satSolver(NULL),
       d_registrar(NULL),
       d_cnfStream(NULL),
+      d_pfCnfStream(nullptr),
       d_interrupted(false),
       d_resourceManager(rm),
       d_outMgr(outMgr)
@@ -399,6 +400,8 @@ bool PropEngine::properExplanation(TNode node, TNode expl) const {
   return true;
 }
 
+ProofCnfStream* PropEngine::getProofCnfStream() { return d_pfCnfStream.get(); }
+
 std::shared_ptr<ProofNode> PropEngine::getProof()
 {
   // TODO (proj #37) implement this
index 0613249473b8a612434a35b56eb28a5f55b156b3..b36b9d22a3fbf8fa8f24fdd1a7f48b415033240f 100644 (file)
@@ -28,6 +28,7 @@
 #include "options/options.h"
 #include "preprocessing/assertion_pipeline.h"
 #include "proof/proof_manager.h"
+#include "prop/proof_cnf_stream.h"
 #include "util/resource_manager.h"
 #include "util/result.h"
 #include "util/unsafe_interrupt_exception.h"
@@ -235,6 +236,9 @@ class PropEngine
    */
   bool properExplanation(TNode node, TNode expl) const;
 
+  /** Retrieve this modules proof CNF stream. */
+  ProofCnfStream* getProofCnfStream();
+
   /**
    * Return the prop engine proof. This should be called only when proofs are
    * enabled. Returns a proof of false whose free assumptions are the
@@ -274,6 +278,8 @@ class PropEngine
 
   /** The CNF converter in use */
   CnfStream* d_cnfStream;
+  /** Proof-producing CNF converter */
+  std::unique_ptr<ProofCnfStream> d_pfCnfStream;
 
   /** Whether we were just interrupted (or not) */
   bool d_interrupted;
index d0d593f8ab469c0392ed15e53eeab5ce31a4cc52..1b9e78d80cedd51a4a8034127b21e6b48520f118 100644 (file)
@@ -75,26 +75,40 @@ void TheoryProxy::explainPropagation(SatLiteral l, SatClause& explanation) {
   TNode lNode = d_cnfStream->getNode(l);
   Debug("prop-explain") << "explainPropagation(" << lNode << ")" << std::endl;
 
-  theory::TrustNode texp = d_theoryEngine->getExplanation(lNode);
-  Node theoryExplanation = texp.getNode();
-
+  theory::TrustNode tte = d_theoryEngine->getExplanation(lNode);
+  Node theoryExplanation = tte.getNode();
+  if (CVC4::options::proofNew())
+  {
+    d_propEngine->getProofCnfStream()->convertPropagation(tte);
+  }
   if (options::unsatCores())
   {
     ProofManager::getCnfProof()->pushCurrentAssertion(theoryExplanation);
   }
-
   Debug("prop-explain") << "explainPropagation() => " << theoryExplanation << std::endl;
-  if (theoryExplanation.getKind() == kind::AND) {
-    Node::const_iterator it = theoryExplanation.begin();
-    Node::const_iterator it_end = theoryExplanation.end();
-    explanation.push_back(l);
-    for (; it != it_end; ++ it) {
-      explanation.push_back(~d_cnfStream->getLiteral(*it));
+  explanation.push_back(l);
+  if (theoryExplanation.getKind() == kind::AND)
+  {
+    for (const Node& n : theoryExplanation)
+    {
+      explanation.push_back(~d_cnfStream->getLiteral(n));
     }
-  } else {
-    explanation.push_back(l);
+  }
+  else
+  {
     explanation.push_back(~d_cnfStream->getLiteral(theoryExplanation));
   }
+  if (Trace.isOn("sat-proof"))
+  {
+    std::stringstream ss;
+    ss << "TheoryProxy::explainPropagation: clause for lit is ";
+    for (unsigned i = 0, size = explanation.size(); i < size; ++i)
+    {
+      ss << explanation[i] << " [" << d_cnfStream->getNode(explanation[i])
+         << "] ";
+    }
+    Trace("sat-proof") << ss.str() << "\n";
+  }
 }
 
 void TheoryProxy::enqueueTheoryLiteral(const SatLiteral& l) {