This design simplifies a number of issues and makes the PRefProofGenerator class obsolete.
LazyCDProof::~LazyCDProof() {}
-std::shared_ptr<ProofNode> LazyCDProof::mkProof(Node fact)
+std::shared_ptr<ProofNode> LazyCDProof::getProofFor(Node fact)
{
Trace("lazy-cdproof") << "LazyCDProof::mkLazyProof " << fact << std::endl;
// make the proof, which should always be non-null, since we construct an
// assumption in the worst case.
- std::shared_ptr<ProofNode> opf = CDProof::mkProof(fact);
+ std::shared_ptr<ProofNode> opf = CDProof::getProofFor(fact);
Assert(opf != nullptr);
if (!hasGenerators())
{
return it != d_gens.end();
}
+std::string LazyCDProof::identify() const { return "LazyCDProof"; }
+
} // namespace CVC4
* additionally call proof generators to generate proofs for ASSUME nodes that
* don't yet have a concrete proof.
*/
- std::shared_ptr<ProofNode> mkProof(Node fact) override;
+ std::shared_ptr<ProofNode> getProofFor(Node fact) override;
/** Add step by generator
*
* This method stores that expected can be proven by proof generator pg if
* It is important to note that pg is asked to provide a proof for expected
* only when no other call for the fact expected is provided via the addStep
* method of this class. In particular, pg is asked to prove expected when it
- * appears as the conclusion of an ASSUME leaf within CDProof::mkProof.
+ * appears as the conclusion of an ASSUME leaf within CDProof::getProofFor.
*
* @param expected The fact that can be proven.
* @param pg The generator that can proof expected.
bool hasGenerators() const;
/** Does the given fact have an explicitly provided generator? */
bool hasGenerator(Node fact) const;
+ /** identify */
+ std::string identify() const override;
protected:
typedef context::CDHashMap<Node, ProofGenerator*, NodeHashFunction>
namespace CVC4 {
-std::ostream& operator<<(std::ostream& out, CDPOverwrite opol)
-{
- switch (opol)
- {
- case CDPOverwrite::ALWAYS: out << "ALWAYS"; break;
- case CDPOverwrite::ASSUME_ONLY: out << "ASSUME_ONLY"; break;
- case CDPOverwrite::NEVER: out << "NEVER"; break;
- default: out << "CDPOverwrite:unknown"; break;
- }
- return out;
-}
-
CDProof::CDProof(ProofNodeManager* pnm, context::Context* c)
: d_manager(pnm), d_context(), d_nodes(c ? c : &d_context)
{
CDProof::~CDProof() {}
-std::shared_ptr<ProofNode> CDProof::mkProof(Node fact)
+std::shared_ptr<ProofNode> CDProof::getProofFor(Node fact)
{
std::shared_ptr<ProofNode> pf = getProofSymm(fact);
if (pf != nullptr)
return polarity ? symFact : symFact.notNode();
}
+std::string CDProof::identify() const { return "CDProof"; }
+
} // namespace CVC4
#include "context/cdhashmap.h"
#include "expr/node.h"
+#include "expr/proof_generator.h"
#include "expr/proof_node.h"
#include "expr/proof_node_manager.h"
#include "expr/proof_step_buffer.h"
namespace CVC4 {
-/** An overwrite policy for CDProof below */
-enum class CDPOverwrite : uint32_t
-{
- // always overwrite an existing step.
- ALWAYS,
- // overwrite ASSUME with non-ASSUME steps.
- ASSUME_ONLY,
- // never overwrite an existing step.
- NEVER,
-};
-/** Writes a overwrite policy name to a stream. */
-std::ostream& operator<<(std::ostream& out, CDPOverwrite opol);
-
/**
* A (context-dependent) proof.
*
* of ID_2. More generally, CDProof::isSame(F,G) returns true if F and G are
* essentially the same formula according to this class.
*/
-class CDProof
+class CDProof : public ProofGenerator
{
public:
CDProof(ProofNodeManager* pnm, context::Context* c = nullptr);
* returned proof may be updated by further calls to this class. The caller
* should call ProofNode::clone if they want to own it.
*/
- virtual std::shared_ptr<ProofNode> mkProof(Node fact);
+ std::shared_ptr<ProofNode> getProofFor(Node fact) override;
/** Add step
*
* @param expected The intended conclusion of this proof step. This must be
* null if none exist.
*/
static Node getSymmFact(TNode f);
+ /** identify */
+ std::string identify() const override;
protected:
typedef context::CDHashMap<Node, std::shared_ptr<ProofNode>, NodeHashFunction>
namespace CVC4 {
+std::ostream& operator<<(std::ostream& out, CDPOverwrite opol)
+{
+ switch (opol)
+ {
+ case CDPOverwrite::ALWAYS: out << "ALWAYS"; break;
+ case CDPOverwrite::ASSUME_ONLY: out << "ASSUME_ONLY"; break;
+ case CDPOverwrite::NEVER: out << "NEVER"; break;
+ default: out << "CDPOverwrite:unknown"; break;
+ }
+ return out;
+}
+
ProofGenerator::ProofGenerator() {}
ProofGenerator::~ProofGenerator() {}
return false;
}
-PRefProofGenerator::PRefProofGenerator(CDProof* cd) : d_proof(cd) {}
-
-PRefProofGenerator::~PRefProofGenerator() {}
-
-std::shared_ptr<ProofNode> PRefProofGenerator::getProofFor(Node f)
-{
- Trace("pfgen") << "PRefProofGenerator::getProofFor: " << f << std::endl;
- return d_proof->mkProof(f);
-}
-
-std::string PRefProofGenerator::identify() const
-{
- return "PRefProofGenerator";
-}
-
} // namespace CVC4
#define CVC4__EXPR__PROOF_GENERATOR_H
#include "expr/node.h"
-#include "expr/proof.h"
#include "expr/proof_node.h"
namespace CVC4 {
+class CDProof;
+
+/** An overwrite policy for CDProof */
+enum class CDPOverwrite : uint32_t
+{
+ // always overwrite an existing step.
+ ALWAYS,
+ // overwrite ASSUME with non-ASSUME steps.
+ ASSUME_ONLY,
+ // never overwrite an existing step.
+ NEVER,
+};
+/** Writes a overwrite policy name to a stream. */
+std::ostream& operator<<(std::ostream& out, CDPOverwrite opol);
+
/**
* An abstract proof generator class.
*
virtual std::string identify() const = 0;
};
-class CDProof;
-
-/**
- * A "copy on demand" proof generator which returns proof nodes based on a
- * reference to another CDProof.
- */
-class PRefProofGenerator : public ProofGenerator
-{
- public:
- PRefProofGenerator(CDProof* cd);
- ~PRefProofGenerator();
- /** Get proof for */
- std::shared_ptr<ProofNode> getProofFor(Node f) override;
- /** Identify this generator (for debugging, etc..) */
- std::string identify() const override;
-
- protected:
- /** The reference proof */
- CDProof* d_proof;
-};
-
} // namespace CVC4
#endif /* CVC4__EXPR__PROOF_GENERATOR_H */
std::shared_ptr<ProofNode> TConvProofGenerator::getProofForRewriting(Node t)
{
// we use the existing proofs
- PRefProofGenerator prg(&d_proof);
- LazyCDProof pf(d_proof.getManager(), &prg);
+ LazyCDProof pf(d_proof.getManager(), &d_proof);
NodeManager* nm = NodeManager::currentNM();
// Invariant: if visited[t] = s or rewritten[t] = s and t,s are distinct,
// then pf is able to generate a proof of t=s.
Assert(!visited.find(t)->second.isNull());
// make the overall proof
Node teq = t.eqNode(visited[t]);
- return pf.mkProof(teq);
+ return pf.getProofFor(teq);
}
Node TConvProofGenerator::getRewriteStep(Node t) const