This simplifies our management of how/when proofs are enabled in the PropEngine.
}
};
-PropEngine::PropEngine(TheoryEngine* te,
- Env& env,
- ProofNodeManager* pnm)
+PropEngine::PropEngine(TheoryEngine* te, Env& env)
: d_inCheckSat(false),
d_theoryEngine(te),
d_env(env),
d_skdm(new SkolemDefManager(d_env.getContext(), d_env.getUserContext())),
d_theoryProxy(nullptr),
d_satSolver(nullptr),
- d_pnm(pnm),
d_cnfStream(nullptr),
d_pfCnfStream(nullptr),
d_ppm(nullptr),
Debug("prop") << "Constructing the PropEngine" << std::endl;
context::Context* satContext = d_env.getContext();
context::UserContext* userContext = d_env.getUserContext();
+ ProofNodeManager* pnm = d_env.getProofNodeManager();
ResourceManager* rm = d_env.getResourceManager();
options::DecisionMode dmode = options::decisionMode();
// CNF stream and theory proxy required pointers to each other, make the
// theory proxy first
- d_theoryProxy = new TheoryProxy(this,
- d_theoryEngine,
- d_decisionEngine.get(),
- d_skdm.get(),
- satContext,
- userContext,
- pnm);
+ d_theoryProxy = new TheoryProxy(
+ this, d_theoryEngine, d_decisionEngine.get(), d_skdm.get(), d_env);
d_cnfStream = new CnfStream(d_satSolver,
d_theoryProxy,
userContext,
// connect theory proxy
d_theoryProxy->finishInit(d_cnfStream);
+ bool satProofs = d_env.isSatProofProducing();
// connect SAT solver
- d_satSolver->initialize(
- d_env.getContext(),
- d_theoryProxy,
- d_env.getUserContext(),
- options::unsatCoresMode() != options::UnsatCoresMode::ASSUMPTIONS
- ? pnm
- : nullptr);
+ d_satSolver->initialize(d_env.getContext(),
+ d_theoryProxy,
+ d_env.getUserContext(),
+ satProofs ? pnm : nullptr);
d_decisionEngine->finishInit(d_satSolver, d_cnfStream);
- if (pnm && options::unsatCoresMode() != options::UnsatCoresMode::ASSUMPTIONS)
+ if (satProofs)
{
d_pfCnfStream.reset(new ProofCnfStream(
userContext,
void PropEngine::checkProof(context::CDList<Node>* assertions)
{
- if (!d_pnm)
+ if (!d_env.isSatProofProducing())
{
return;
}
std::shared_ptr<ProofNode> PropEngine::getProof()
{
- if (!d_pnm)
+ if (!d_env.isSatProofProducing())
{
return nullptr;
}
Assert(options::unsatCoresMode() == options::UnsatCoresMode::ASSUMPTIONS);
std::vector<Node> core;
getUnsatCore(core);
- CDProof cdp(d_pnm);
+ CDProof cdp(d_env.getProofNodeManager());
Node fnode = NodeManager::currentNM()->mkConst(false);
cdp.addStep(fnode, PfRule::SAT_REFUTATION, core, {});
return cdp.getProofFor(fnode);
/**
* Create a PropEngine with a particular decision and theory engine.
*/
- PropEngine(TheoryEngine* te,
- Env& env,
- ProofNodeManager* pnm);
+ PropEngine(TheoryEngine* te, Env& env);
/**
* Destructor.
/** List of all of the assertions that need to be made */
std::vector<Node> d_assertionList;
- /** A pointer to the proof node maneger to be used by this engine. */
- ProofNodeManager* d_pnm;
-
/** The CNF converter in use */
CnfStream* d_cnfStream;
/** Proof-producing CNF converter */
#include "prop/cnf_stream.h"
#include "prop/prop_engine.h"
#include "prop/skolem_def_manager.h"
+#include "smt/env.h"
#include "smt/smt_statistics_registry.h"
#include "theory/rewriter.h"
#include "theory/theory_engine.h"
TheoryEngine* theoryEngine,
decision::DecisionEngine* decisionEngine,
SkolemDefManager* skdm,
- context::Context* context,
- context::UserContext* userContext,
- ProofNodeManager* pnm)
+ Env& env)
: d_propEngine(propEngine),
d_cnfStream(nullptr),
d_decisionEngine(decisionEngine),
d_theoryEngine(theoryEngine),
- d_queue(context),
- d_tpp(*theoryEngine, userContext, pnm),
- d_skdm(skdm)
+ d_queue(env.getContext()),
+ d_tpp(*theoryEngine, env.getUserContext(), env.getProofNodeManager()),
+ d_skdm(skdm),
+ d_env(env)
{
}
TrustNode tte = d_theoryEngine->getExplanation(lNode);
Node theoryExplanation = tte.getNode();
- if (options::produceProofs()
- && options::unsatCoresMode() != options::UnsatCoresMode::ASSUMPTIONS)
+ if (d_env.isTheoryProofProducing())
{
Assert(options::unsatCoresMode() != options::UnsatCoresMode::FULL_PROOF
|| tte.getGenerator());
namespace cvc5 {
+class Env;
+class TheoryEngine;
+
namespace decision {
class DecisionEngine;
}
-class TheoryEngine;
namespace prop {
TheoryEngine* theoryEngine,
decision::DecisionEngine* decisionEngine,
SkolemDefManager* skdm,
- context::Context* context,
- context::UserContext* userContext,
- ProofNodeManager* pnm);
+ Env& env);
~TheoryProxy();
/** The skolem definition manager */
SkolemDefManager* d_skdm;
+
+ /** Reference to the environment */
+ Env& d_env;
}; /* class TheoryProxy */
} // namespace prop
const std::string& Env::getFilename() const { return d_filename; }
+bool Env::isSatProofProducing() const
+{
+ return d_proofNodeManager != nullptr
+ && (!d_options.smt.unsatCores
+ || d_options.smt.unsatCoresMode
+ != options::UnsatCoresMode::ASSUMPTIONS);
+}
+
bool Env::isTheoryProofProducing() const
{
return d_proofNodeManager != nullptr
/** Return the input name, or the empty string if not set */
const std::string& getFilename() const;
+ /**
+ * Check whether the SAT solver should produce proofs. Other than whether
+ * the proof node manager is set, SAT proofs are only generated when the
+ * unsat core mode is not ASSUMPTIONS.
+ */
+ bool isSatProofProducing() const;
+
/**
* Check whether theories should produce proofs as well. Other than whether
* the proof node manager is set, theory engine proofs are conditioned on the
d_env->setProofNodeManager(pnm);
// enable it in the assertions pipeline
d_asserts->setProofGenerator(pppg);
- // enable it in the SmtSolver
- d_smtSolver->setProofNodeManager(pnm);
// enabled proofs in the preprocessor
d_pp->setProofGenerator(pppg);
}
d_state(state),
d_pp(pp),
d_stats(stats),
- d_pnm(nullptr),
d_theoryEngine(nullptr),
d_propEngine(nullptr)
{
theory::TheoryConstructor::addTheory(d_theoryEngine.get(), id);
}
// Add the proof checkers for each theory
- if (d_pnm)
+ ProofNodeManager* pnm = d_env.getProofNodeManager();
+ if (pnm)
{
- d_theoryEngine->initializeProofChecker(d_pnm->getChecker());
+ d_theoryEngine->initializeProofChecker(pnm->getChecker());
}
Trace("smt-debug") << "Making prop engine..." << std::endl;
/* force destruction of referenced PropEngine to enforce that statistics
* are unregistered by the obsolete PropEngine object before registered
* again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env, d_pnm));
+ d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env));
Trace("smt-debug") << "Setting up theory engine..." << std::endl;
d_theoryEngine->setPropEngine(getPropEngine());
* statistics are unregistered by the obsolete PropEngine object before
* registered again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env, d_pnm));
+ d_propEngine.reset(new prop::PropEngine(d_theoryEngine.get(), d_env));
d_theoryEngine->setPropEngine(getPropEngine());
// Notice that we do not reset TheoryEngine, nor does it require calling
// finishInit again. In particular, TheoryEngine::finishInit does not
as.clearCurrent();
}
-void SmtSolver::setProofNodeManager(ProofNodeManager* pnm) { d_pnm = pnm; }
-
TheoryEngine* SmtSolver::getTheoryEngine() { return d_theoryEngine.get(); }
prop::PropEngine* SmtSolver::getPropEngine() { return d_propEngine.get(); }
* into the SMT solver, and clears the buffer.
*/
void processAssertions(Assertions& as);
- /**
- * Set proof node manager. Enables proofs in this SmtSolver. Should be
- * called before finishInit.
- */
- void setProofNodeManager(ProofNodeManager* pnm);
//------------------------------------------ access methods
/** Get a pointer to the TheoryEngine owned by this solver. */
TheoryEngine* getTheoryEngine();
Preprocessor& d_pp;
/** Reference to the statistics of SmtEngine */
SmtEngineStatistics& d_stats;
- /**
- * Pointer to the proof node manager used by this SmtSolver. A non-null
- * proof node manager indicates that proofs are enabled.
- */
- ProofNodeManager* d_pnm;
/** The theory engine */
std::unique_ptr<TheoryEngine> d_theoryEngine;
/** The propositional engine */