Eliminates one of the remaining calls to Rewriter::callExtendedRewrite, as well as making the initialization much clearer through use of Env.
replace(i, trn.getNode(), trn.getGenerator());
}
-void AssertionPipeline::setProofGenerator(smt::PreprocessProofGenerator* pppg)
+void AssertionPipeline::enableProofs(smt::PreprocessProofGenerator* pppg)
{
d_pppg = pppg;
}
return d_storeSubstsInAsserts && i == d_substsIndex;
}
//------------------------------------ for proofs
- /** Set proof generator */
- void setProofGenerator(smt::PreprocessProofGenerator* pppg);
+ /**
+ * Enable proofs for this assertions pipeline. This must be called
+ * explicitly since we construct the assertions pipeline before we know
+ * whether proofs are enabled.
+ *
+ * @param pppg The preprocess proof generator of the proof manager.
+ */
+ void enableProofs(smt::PreprocessProofGenerator* pppg);
/** Is proof enabled? */
bool isProofEnabled() const;
//------------------------------------ end for proofs
d_statistics(statisticsRegistry()),
d_pnm(d_env.getProofNodeManager()),
d_llpg(d_pnm ? new smt::PreprocessProofGenerator(
- d_pnm, userContext(), "NonClausalSimp::llpg")
+ d_env, userContext(), "NonClausalSimp::llpg")
: nullptr),
d_llra(d_pnm ? new LazyCDProof(
- d_pnm, nullptr, userContext(), "NonClausalSimp::llra")
+ d_pnm, nullptr, userContext(), "NonClausalSimp::llra")
: nullptr),
d_tsubsList(userContext())
{
}
}
-void Assertions::setProofGenerator(smt::PreprocessProofGenerator* pppg)
+void Assertions::enableProofs(smt::PreprocessProofGenerator* pppg)
{
- d_assertions.setProofGenerator(pppg);
+ d_assertions.enableProofs(pppg);
}
bool Assertions::isProofEnabled() const
void flipGlobalNegated();
//------------------------------------ for proofs
- /** Set proof generator */
- void setProofGenerator(smt::PreprocessProofGenerator* pppg);
+ /**
+ * Enable proofs for this assertions class. This must be called
+ * explicitly since we construct the assertions before we know
+ * whether proofs are enabled.
+ *
+ * @param pppg The preprocess proof generator of the proof manager.
+ */
+ void enableProofs(smt::PreprocessProofGenerator* pppg);
/** Is proof enabled? */
bool isProofEnabled() const;
//------------------------------------ end for proofs
namespace cvc5 {
namespace smt {
-ExpandDefs::ExpandDefs(Env& env) : d_env(env), d_tpg(nullptr) {}
+ExpandDefs::ExpandDefs(Env& env) : EnvObj(env), d_tpg(nullptr) {}
ExpandDefs::~ExpandDefs() {}
return TrustNode::mkTrustRewrite(orig, res, tpg);
}
-void ExpandDefs::setProofNodeManager(ProofNodeManager* pnm)
+void ExpandDefs::enableProofs()
{
+ // initialize if not done already
if (d_tpg == nullptr)
{
- d_tpg.reset(new TConvProofGenerator(pnm,
+ Assert(d_env.getProofNodeManager() != nullptr);
+ d_tpg.reset(new TConvProofGenerator(d_env.getProofNodeManager(),
d_env.getUserContext(),
TConvPolicy::FIXPOINT,
TConvCachePolicy::NEVER,
#include "expr/node.h"
#include "proof/trust_node.h"
+#include "smt/env_obj.h"
namespace cvc5 {
-class Env;
class ProofNodeManager;
class TConvProofGenerator;
* Its main features is expandDefinitions(TNode, ...), which returns the
* expanded formula of a term.
*/
-class ExpandDefs
+class ExpandDefs : protected EnvObj
{
public:
ExpandDefs(Env& env);
*/
Node expandDefinitions(TNode n, std::unordered_map<Node, Node>& cache);
- /**
- * Set proof node manager, which signals this class to enable proofs using the
- * given proof node manager.
- */
- void setProofNodeManager(ProofNodeManager* pnm);
+ /** Enable proofs using the proof node manager of the env. */
+ void enableProofs();
private:
/**
TrustNode expandDefinitions(TNode n,
std::unordered_map<Node, Node>& cache,
TConvProofGenerator* tpg);
- /** Reference to the environment. */
- Env& d_env;
/** A proof generator for the term conversion. */
std::unique_ptr<TConvProofGenerator> d_tpg;
};
#include "proof/proof.h"
#include "proof/proof_checker.h"
#include "proof/proof_node.h"
+#include "smt/env.h"
#include "theory/quantifiers/extended_rewrite.h"
-#include "theory/rewriter.h"
namespace cvc5 {
namespace smt {
-PreprocessProofGenerator::PreprocessProofGenerator(ProofNodeManager* pnm,
- context::Context* c,
- std::string name,
- PfRule ra,
- PfRule rpp)
- : d_pnm(pnm),
+PreprocessProofGenerator::PreprocessProofGenerator(
+ Env& env, context::Context* c, std::string name, PfRule ra, PfRule rpp)
+ : EnvObj(env),
d_ctx(c ? c : &d_context),
d_src(d_ctx),
- d_helperProofs(pnm, d_ctx),
- d_inputPf(pnm, c, "InputProof"),
+ d_helperProofs(env.getProofNodeManager(), d_ctx),
+ d_inputPf(env.getProofNodeManager(), c, "InputProof"),
d_name(name),
d_ra(ra),
d_rpp(rpp)
return nullptr;
}
// make CDProof to construct the proof below
- CDProof cdp(d_pnm);
+ CDProof cdp(d_env.getProofNodeManager());
Node curr = f;
std::vector<Node> transChildren;
if (!proofStepProcessed)
{
// maybe its just an (extended) rewrite?
- Node pr = theory::Rewriter::callExtendedRewrite(proven[0]);
+ Node pr = extendedRewrite(proven[0]);
if (proven[1] == pr)
{
Node idr = mkMethodId(MethodId::RW_EXT_REWRITE);
return cdp.getProofFor(f);
}
-ProofNodeManager* PreprocessProofGenerator::getManager() { return d_pnm; }
-
LazyCDProof* PreprocessProofGenerator::allocateHelperProof()
{
return d_helperProofs.allocateProof(nullptr, d_ctx);
{
// catch a pedantic failure now, which otherwise would not be
// triggered since we are doing lazy proof generation
- ProofChecker* pc = d_pnm->getChecker();
+ ProofChecker* pc = d_env.getProofNodeManager()->getChecker();
std::stringstream serr;
if (pc->isPedanticFailure(r, serr))
{
#include "proof/proof_generator.h"
#include "proof/proof_set.h"
#include "proof/trust_node.h"
+#include "smt/env_obj.h"
namespace cvc5 {
* whose free assumptions are intended to be input assertions, which are
* implictly all assertions that are not notified to this class.
*/
-class PreprocessProofGenerator : public ProofGenerator
+class PreprocessProofGenerator : protected EnvObj, public ProofGenerator
{
typedef context::CDHashMap<Node, TrustNode> NodeTrustNodeMap;
public:
/**
- * @param pnm The proof node manager
+ * @param env Reference to the environment
* @param c The context this class depends on
* @param name The name of this generator (for debugging)
* @param ra The proof rule to use when no generator is provided for new
* @param rpp The proof rule to use when no generator is provided for
* preprocessing steps.
*/
- PreprocessProofGenerator(ProofNodeManager* pnm,
+ PreprocessProofGenerator(Env& env,
context::Context* c = nullptr,
std::string name = "PreprocessProofGenerator",
PfRule ra = PfRule::PREPROCESS_LEMMA,
std::shared_ptr<ProofNode> getProofFor(Node f) override;
/** Identify */
std::string identify() const override;
- /** Get the proof manager */
- ProofNodeManager* getManager();
/**
* Allocate a helper proof. This returns a fresh lazy proof object that
* remains alive in the context. This feature is used to construct
* to this class.
*/
void checkEagerPedantic(PfRule r);
- /** The proof node manager */
- ProofNodeManager* d_pnm;
/** A dummy context used by this class if none is provided */
context::Context d_context;
/** The context used here */
d_propagator(env, true, true),
d_assertionsProcessed(env.getUserContext(), false),
d_exDefs(env),
- d_processor(env, stats),
- d_pnm(nullptr)
+ d_processor(env, stats)
{
}
return ret;
}
-void Preprocessor::setProofGenerator(PreprocessProofGenerator* pppg)
+void Preprocessor::enableProofs(PreprocessProofGenerator* pppg)
{
Assert(pppg != nullptr);
- d_pnm = pppg->getManager();
- d_exDefs.setProofNodeManager(d_pnm);
- d_propagator.setProof(d_pnm, userContext(), pppg);
+ d_exDefs.enableProofs();
+ d_propagator.enableProofs(userContext(), pppg);
}
} // namespace smt
/** Same as above, for a list of assertions, updating in place */
void expandDefinitions(std::vector<Node>& ns);
/**
- * Set proof node manager. Enables proofs in this preprocessor.
+ * Enable proofs for this preprocessor. This must be called
+ * explicitly since we construct the preprocessor before we know
+ * whether proofs are enabled.
+ *
+ * @param pppg The preprocess proof generator of the proof manager.
*/
- void setProofGenerator(PreprocessProofGenerator* pppg);
+ void enableProofs(PreprocessProofGenerator* pppg);
private:
/** Reference to the abstract values utility */
* passes.
*/
ProcessAssertions d_processor;
- /** Proof node manager */
- ProofNodeManager* d_pnm;
};
} // namespace smt
options().proof.proofPedantic)),
d_pnm(new ProofNodeManager(
env.getOptions(), env.getRewriter(), d_pchecker.get())),
- d_pppg(new PreprocessProofGenerator(
- d_pnm.get(), env.getUserContext(), "smt::PreprocessProofGenerator")),
+ d_pppg(nullptr),
d_pfpp(nullptr),
d_finalProof(nullptr)
{
// enable proof support in the environment/rewriter
d_env.setProofNodeManager(d_pnm.get());
+ // now construct preprocess proof generator
+ d_pppg = std::make_unique<PreprocessProofGenerator>(
+ env, env.getUserContext(), "smt::PreprocessProofGenerator");
// Now, initialize the proof postprocessor with the environment.
// By default the post-processor will update all assumptions, which
// can lead to SCOPE subproofs of the form
// be inferred from A, it was updated). This shape is problematic for
// the Alethe reconstruction, so we disable the update of scoped
// assumptions (which would disable the update of B1 in this case).
- d_pfpp.reset(new ProofPostproccess(
+ d_pfpp = std::make_unique<ProofPostproccess>(
env,
d_pppg.get(),
nullptr,
- options().proof.proofFormatMode != options::ProofFormatMode::ALETHE));
+ options().proof.proofFormatMode != options::ProofFormatMode::ALETHE);
// add rules to eliminate here
if (options().proof.proofGranularityMode
// start the unsat core manager
d_ucManager.reset(new UnsatCoreManager());
// enable it in the assertions pipeline
- d_asserts->setProofGenerator(pppg);
+ d_asserts->enableProofs(pppg);
// enabled proofs in the preprocessor
- d_smtSolver->getPreprocessor()->setProofGenerator(pppg);
+ d_smtSolver->getPreprocessor()->enableProofs(pppg);
}
Trace("smt-debug") << "SolverEngine::finishInit" << std::endl;
class Assertions;
class ResourceOutListener;
class SmtNodeManagerListener;
-class OptionsManager;
-class Preprocessor;
class CheckModels;
/** Subsolvers */
class SmtSolver;
return d_conflict;
}
-void CircuitPropagator::setProof(ProofNodeManager* pnm,
- context::Context* ctx,
- ProofGenerator* defParent)
+void CircuitPropagator::enableProofs(context::Context* ctx,
+ ProofGenerator* defParent)
{
- d_pnm = pnm;
- d_epg.reset(new EagerProofGenerator(pnm, ctx));
+ d_pnm = d_env.getProofNodeManager();
+ Assert(d_pnm != nullptr);
+ d_epg.reset(new EagerProofGenerator(d_pnm, ctx));
d_proofInternal.reset(new LazyCDProofChain(
- pnm, true, ctx, d_epg.get(), true, "CircuitPropInternalLazyChain"));
+ d_pnm, true, ctx, d_epg.get(), true, "CircuitPropInternalLazyChain"));
if (defParent != nullptr)
{
// If we provide a parent proof generator (defParent), we want the ASSUME
// leafs of proofs provided by this class to call the getProofFor method on
// the parent. To do this, we use a LazyCDProofChain.
d_proofExternal.reset(new LazyCDProofChain(
- pnm, true, ctx, defParent, false, "CircuitPropExternalLazyChain"));
+ d_pnm, true, ctx, defParent, false, "CircuitPropExternalLazyChain"));
}
}
return false;
}
/**
- * Set proof node manager, context and parent proof generator.
+ * Enable proofs based on context and parent proof generator.
*
* If parent is non-null, then it is responsible for the proofs provided
* to this class.
*/
- void setProof(ProofNodeManager* pnm,
- context::Context* ctx,
- ProofGenerator* defParent);
+ void enableProofs(context::Context* ctx, ProofGenerator* defParent);
private:
/** A context-notify object that clears out stale data. */