#include "decision/decision_engine_old.h"
#include "options/decision_options.h"
#include "prop/sat_solver.h"
+#include "smt/env.h"
#include "util/resource_manager.h"
namespace cvc5 {
namespace decision {
-DecisionEngine::DecisionEngine(context::Context* c, ResourceManager* rm)
- : d_context(c),
- d_resourceManager(rm),
- d_cnfStream(nullptr),
- d_satSolver(nullptr)
+DecisionEngine::DecisionEngine(Env& env)
+ : EnvObj(env), d_cnfStream(nullptr), d_satSolver(nullptr)
{
}
prop::SatLiteral DecisionEngine::getNext(bool& stopSearch)
{
- d_resourceManager->spendResource(Resource::DecisionStep);
+ resourceManager()->spendResource(Resource::DecisionStep);
return getNextInternal(stopSearch);
}
-DecisionEngineEmpty::DecisionEngineEmpty(context::Context* sc,
- ResourceManager* rm)
- : DecisionEngine(sc, rm)
-{
-}
+DecisionEngineEmpty::DecisionEngineEmpty(Env& env) : DecisionEngine(env) {}
bool DecisionEngineEmpty::isDone() { return false; }
void DecisionEngineEmpty::addAssertion(TNode assertion) {}
void DecisionEngineEmpty::addSkolemDefinition(TNode lem, TNode skolem) {}
#include "prop/cnf_stream.h"
#include "prop/sat_solver.h"
#include "prop/sat_solver_types.h"
+#include "smt/env_obj.h"
namespace cvc5 {
namespace decision {
-class DecisionEngine
+class DecisionEngine : protected EnvObj
{
public:
/** Constructor */
- DecisionEngine(context::Context* sc,
- ResourceManager* rm);
+ DecisionEngine(Env& env);
virtual ~DecisionEngine() {}
/** Finish initialize */
class DecisionEngineEmpty : public DecisionEngine
{
public:
- DecisionEngineEmpty(context::Context* sc, ResourceManager* rm);
+ DecisionEngineEmpty(Env& env);
bool isDone() override;
void addAssertion(TNode assertion) override;
void addSkolemDefinition(TNode lem, TNode skolem) override;
namespace cvc5 {
-DecisionEngineOld::DecisionEngineOld(context::Context* sc,
- context::UserContext* uc,
- ResourceManager* rm)
- : DecisionEngine(sc, rm),
- d_result(sc, SAT_VALUE_UNKNOWN),
+DecisionEngineOld::DecisionEngineOld(Env& env)
+ : DecisionEngine(env),
+ d_result(context(), SAT_VALUE_UNKNOWN),
d_engineState(0),
d_enabledITEStrategy(nullptr),
d_decisionStopOnly(options::decisionMode()
if (options::decisionMode() == options::DecisionMode::JUSTIFICATION)
{
- d_enabledITEStrategy.reset(
- new decision::JustificationHeuristic(this, uc, sc));
+ d_enabledITEStrategy.reset(new decision::JustificationHeuristic(env, this));
}
}
// Necessary functions
/** Constructor */
- DecisionEngineOld(context::Context* sc,
- context::UserContext* uc,
- ResourceManager* rm);
+ DecisionEngineOld(Env& env);
/** Destructor, currently does nothing */
~DecisionEngineOld()
#include "expr/node.h"
#include "prop/sat_solver_types.h"
+#include "smt/env_obj.h"
#include "smt/term_formula_removal.h"
namespace cvc5 {
class DecisionEngineOld;
-namespace context {
- class Context;
- } // namespace context
-
namespace decision {
-
-class DecisionEngine;
-
-class DecisionStrategy {
-protected:
- DecisionEngineOld* d_decisionEngine;
-public:
- DecisionStrategy(DecisionEngineOld* de, context::Context* c)
- : d_decisionEngine(de)
- {
+class DecisionStrategy : protected EnvObj
+{
+ public:
+ DecisionStrategy(Env& env, DecisionEngineOld* de)
+ : EnvObj(env), d_decisionEngine(de)
+ {
}
virtual ~DecisionStrategy() { }
virtual prop::SatLiteral getNext(bool&) = 0;
+
+ protected:
+ DecisionEngineOld* d_decisionEngine;
};/* class DecisionStrategy */
class ITEDecisionStrategy : public DecisionStrategy {
public:
- ITEDecisionStrategy(DecisionEngineOld* de, context::Context* c)
- : DecisionStrategy(de, c)
+ ITEDecisionStrategy(Env& env, DecisionEngineOld* de)
+ : DecisionStrategy(env, de)
{
}
/**
namespace cvc5 {
namespace decision {
-JustificationHeuristic::JustificationHeuristic(DecisionEngineOld* de,
- context::UserContext* uc,
- context::Context* c)
- : ITEDecisionStrategy(de, c),
- d_justified(c),
- d_exploredThreshold(c),
- d_prvsIndex(c, 0),
- d_threshPrvsIndex(c, 0),
+JustificationHeuristic::JustificationHeuristic(Env& env, DecisionEngineOld* de)
+ : ITEDecisionStrategy(env, de),
+ d_justified(context()),
+ d_exploredThreshold(context()),
+ d_prvsIndex(context(), 0),
+ d_threshPrvsIndex(context(), 0),
d_helpfulness(
smtStatisticsRegistry().registerInt("decision::jh::helpfulness")),
d_giveup(smtStatisticsRegistry().registerInt("decision::jh::giveup")),
d_timestat(smtStatisticsRegistry().registerTimer("decision::jh::time")),
- d_assertions(uc),
- d_skolemAssertions(uc),
- d_skolemCache(uc),
+ d_assertions(userContext()),
+ d_skolemAssertions(userContext()),
+ d_skolemCache(userContext()),
d_visited(),
d_visitedComputeSkolems(),
d_curDecision(),
d_curThreshold(0),
- d_childCache(uc),
- d_weightCache(uc),
- d_startIndexCache(c)
+ d_childCache(userContext()),
+ d_weightCache(userContext()),
+ d_startIndexCache(context())
{
Trace("decision") << "Justification heuristic enabled" << std::endl;
}
};
public:
- JustificationHeuristic(DecisionEngineOld* de,
- context::UserContext* uc,
- context::Context* c);
+ JustificationHeuristic(Env& env, DecisionEngineOld* de);
~JustificationHeuristic();
namespace cvc5 {
namespace decision {
-JustificationStrategy::JustificationStrategy(context::Context* c,
- context::UserContext* u,
- prop::SkolemDefManager* skdm,
- ResourceManager* rm)
- : DecisionEngine(c, rm),
+JustificationStrategy::JustificationStrategy(Env& env,
+ prop::SkolemDefManager* skdm)
+ : DecisionEngine(env),
d_skdm(skdm),
d_assertions(
- u,
- c,
+ userContext(),
+ context(),
options::jhRlvOrder()), // assertions are user-context dependent
- d_skolemAssertions(c, c), // skolem assertions are SAT-context dependent
- d_justified(c),
- d_stack(c),
- d_lastDecisionLit(c),
+ d_skolemAssertions(
+ context(), context()), // skolem assertions are SAT-context dependent
+ d_justified(context()),
+ d_stack(context()),
+ d_lastDecisionLit(context()),
d_currStatusDec(false),
d_useRlvOrder(options::jhRlvOrder()),
d_decisionStopOnly(options::decisionMode()
{
public:
/** Constructor */
- JustificationStrategy(context::Context* c,
- context::UserContext* u,
- prop::SkolemDefManager* skdm,
- ResourceManager* rm);
+ JustificationStrategy(Env& env, prop::SkolemDefManager* skdm);
/** Presolve, called at the beginning of each check-sat call */
void presolve() override;
d_assumptions(d_env.getUserContext())
{
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();
if (dmode == options::DecisionMode::JUSTIFICATION
|| dmode == options::DecisionMode::STOPONLY)
{
- d_decisionEngine.reset(new decision::JustificationStrategy(
- satContext, userContext, d_skdm.get(), rm));
+ d_decisionEngine.reset(
+ new decision::JustificationStrategy(env, d_skdm.get()));
}
else if (dmode == options::DecisionMode::JUSTIFICATION_OLD
|| dmode == options::DecisionMode::STOPONLY_OLD)
{
- d_decisionEngine.reset(new DecisionEngineOld(satContext, userContext, rm));
+ d_decisionEngine.reset(new DecisionEngineOld(env));
}
else
{
- d_decisionEngine.reset(new decision::DecisionEngineEmpty(satContext, rm));
+ d_decisionEngine.reset(new decision::DecisionEngineEmpty(env));
}
d_satSolver = SatSolverFactory::createCDCLTMinisat(smtStatisticsRegistry());
d_resourceManager.reset(nullptr);
}
-context::UserContext* Env::getUserContext() { return d_userContext.get(); }
-
context::Context* Env::getContext() { return d_context.get(); }
+context::UserContext* Env::getUserContext() { return d_userContext.get(); }
+
NodeManager* Env::getNodeManager() const { return d_nodeManager; }
ProofNodeManager* Env::getProofNodeManager() { return d_proofNodeManager; }
return d_env.evaluate(n, args, vals, visited, useRewriter);
}
-const LogicInfo& EnvObj::logicInfo() const { return d_env.getLogicInfo(); }
-
const Options& EnvObj::options() const { return d_env.getOptions(); }
context::Context* EnvObj::context() const { return d_env.getContext(); }
return d_env.getUserContext();
}
+const LogicInfo& EnvObj::logicInfo() const { return d_env.getLogicInfo(); }
+
+ResourceManager* EnvObj::resourceManager() const
+{
+ return d_env.getResourceManager();
+}
+
StatisticsRegistry& EnvObj::statisticsRegistry() const
{
return d_env.getStatisticsRegistry();
const std::unordered_map<Node, Node>& visited,
bool useRewriter = true) const;
- /** Get the current logic information. */
- const LogicInfo& logicInfo() const;
-
/** Get the options object (const version only) via Env. */
const Options& options() const;
/** Get a pointer to the UserContext via Env. */
context::UserContext* userContext() const;
+ /** Get the resource manager owned by this Env. */
+ ResourceManager* resourceManager() const;
+
+ /** Get the current logic information. */
+ const LogicInfo& logicInfo() const;
+
/** Get the statistics registry via Env. */
StatisticsRegistry& statisticsRegistry() const;