ProofGenerator* dpg,
context::Context* c,
const std::string& name,
- bool autoSym)
+ bool autoSym,
+ bool doCache)
: CDProof(pnm, c, name, autoSym),
d_gens(c ? c : &d_context),
- d_defaultGen(dpg)
+ d_defaultGen(dpg),
+ d_doCache(doCache),
+ d_allVisited(c ? c : &d_context)
{
}
// otherwise, we traverse the proof opf and fill in the ASSUME leafs that
// have generators
std::unordered_set<ProofNode*> visited;
- std::unordered_set<ProofNode*>::iterator it;
std::vector<ProofNode*> visit;
ProofNode* cur;
visit.push_back(opf.get());
+ bool alreadyVisited;
do
{
cur = visit.back();
visit.pop_back();
- it = visited.find(cur);
+ if (d_doCache)
+ {
+ alreadyVisited = d_allVisited.find(cur) != d_allVisited.end();
+ }
+ else
+ {
+ alreadyVisited = visited.find(cur) != visited.end();
+ }
- if (it == visited.end())
+ if (!alreadyVisited)
{
- visited.insert(cur);
+ if (d_doCache)
+ {
+ d_allVisited.insert(cur);
+ }
+ else
+ {
+ visited.insert(cur);
+ }
Node cfact = cur->getResult();
if (getProof(cfact).get() != cur)
{
#ifndef CVC5__PROOF__LAZY_PROOF_H
#define CVC5__PROOF__LAZY_PROOF_H
+#include "context/cdhashset.h"
#include "proof/proof.h"
namespace cvc5 {
* @param name The name of this proof generator (for debugging)
* @param autoSym Whether symmetry steps are automatically added when adding
* steps to this proof
+ * @param doCache Whether the proofs we process in getProofFor are cached
+ * based on the context of this class. In other words, we assume that the
+ * subproofs returned by getProofFor are not re-processed on repeated calls
+ * to getProofFor, even if new steps are provided to this class in the
+ * meantime.
*/
LazyCDProof(ProofNodeManager* pnm,
ProofGenerator* dpg = nullptr,
context::Context* c = nullptr,
const std::string& name = "LazyCDProof",
- bool autoSym = true);
+ bool autoSym = true,
+ bool doCache = true);
~LazyCDProof();
/**
* Get lazy proof for fact, or nullptr if it does not exist. This may
protected:
typedef context::CDHashMap<Node, ProofGenerator*> NodeProofGeneratorMap;
+ typedef context::CDHashSet<ProofNode*> ProofNodeSet;
/** Maps facts that can be proven to generators */
NodeProofGeneratorMap d_gens;
/** The default proof generator */
* proof generator for the symmetric form of fact was provided.
*/
ProofGenerator* getGeneratorFor(Node fact, bool& isSym);
+ /** whether d_allVisited is maintained */
+ bool d_doCache;
+ /** The set of proof nodes we have processed in getProofFor */
+ ProofNodeSet d_allVisited;
};
} // namespace cvc5