[proofs] Alethe: Implementation of Process Function (#7745)
authorLachnitt <lachnitt@stanford.edu>
Fri, 3 Dec 2021 23:39:38 +0000 (15:39 -0800)
committerGitHub <noreply@github.com>
Fri, 3 Dec 2021 23:39:38 +0000 (20:39 -0300)
Add call to updater and finalizer to process function of the AlethePostProcessor.

Co-authored-by: Haniel Barbosa <hanielbbarbosa@gmail.com>
src/proof/alethe/alethe_post_processor.cpp

index 2254c025f55cf18ff3ce5b9fc24a2a327c1d0b37..46ec3f25ea43d6fbfdd59be60d04c00fcab417a8 100644 (file)
@@ -20,6 +20,7 @@
 #include "proof/proof.h"
 #include "proof/proof_checker.h"
 #include "proof/proof_node_algorithm.h"
+#include "proof/proof_node_manager.h"
 #include "theory/builtin/proof_checker.h"
 #include "util/rational.h"
 
@@ -1712,7 +1713,37 @@ AletheProofPostprocess::AletheProofPostprocess(ProofNodeManager* pnm,
 
 AletheProofPostprocess::~AletheProofPostprocess() {}
 
-void AletheProofPostprocess::process(std::shared_ptr<ProofNode> pf) {}
+void AletheProofPostprocess::process(std::shared_ptr<ProofNode> pf) {
+  // Translate proof node
+  ProofNodeUpdater updater(d_pnm, d_cb,true,false);
+  updater.process(pf->getChildren()[0]);
+
+  // In the Alethe proof format the final step has to be (cl). However, after
+  // the translation it might be (cl false). In that case additional steps are
+  // required.
+  // The function has the additional purpose of sanitizing the attributes of the
+  // first SCOPE
+  CDProof cpf(d_pnm, nullptr, "ProofNodeUpdater::CDProof", true);
+  const std::vector<std::shared_ptr<ProofNode>>& cc = pf->getChildren();
+  std::vector<Node> ccn;
+  for (const std::shared_ptr<ProofNode>& cp : cc)
+  {
+    Node cpres = cp->getResult();
+    ccn.push_back(cpres);
+    // store in the proof
+    cpf.addProof(cp);
+  }
+  if (d_cb.finalStep(
+          pf->getResult(), pf->getRule(), ccn, pf->getArguments(), &cpf))
+  {
+    std::shared_ptr<ProofNode> npn = cpf.getProofFor(pf->getResult());
+
+    // then, update the original proof node based on this one
+    Trace("pf-process-debug") << "Update node..." << std::endl;
+    d_pnm->updateNode(pf.get(), npn.get());
+    Trace("pf-process-debug") << "...update node finished." << std::endl;
+  }
+}
 
 }  // namespace proof