Calling (reset-assertions) in start mode was not handled correctly.
Additionally, when calling (check-sat) after (reset-assertions) after a
(check-sat) call that answered unsat, we answered unsat instead of sat.
This cleans up and fixes reset-assertions) handling.
namespace CVC4 {
JustificationHeuristic::JustificationHeuristic(CVC4::DecisionEngine* de,
- context::UserContext *uc,
- context::Context *c):
- ITEDecisionStrategy(de, c),
- d_justified(c),
- d_exploredThreshold(c),
- d_prvsIndex(c, 0),
- d_threshPrvsIndex(c, 0),
- d_helfulness("decision::jh::helpfulness", 0),
- d_giveup("decision::jh::giveup", 0),
- d_timestat("decision::jh::time"),
- d_assertions(uc),
- d_iteAssertions(uc),
- d_iteCache(uc),
- d_visited(),
- d_visitedComputeITE(),
- d_curDecision(),
- d_curThreshold(0),
- d_childCache(uc),
- d_weightCache(uc),
- d_startIndexCache(c) {
- smtStatisticsRegistry()->registerStat(&d_helfulness);
+ context::UserContext* uc,
+ context::Context* c)
+ : ITEDecisionStrategy(de, c),
+ d_justified(c),
+ d_exploredThreshold(c),
+ d_prvsIndex(c, 0),
+ d_threshPrvsIndex(c, 0),
+ d_helpfulness("decision::jh::helpfulness", 0),
+ d_giveup("decision::jh::giveup", 0),
+ d_timestat("decision::jh::time"),
+ d_assertions(uc),
+ d_iteAssertions(uc),
+ d_iteCache(uc),
+ d_visited(),
+ d_visitedComputeITE(),
+ d_curDecision(),
+ d_curThreshold(0),
+ d_childCache(uc),
+ d_weightCache(uc),
+ d_startIndexCache(c)
+{
+ smtStatisticsRegistry()->registerStat(&d_helpfulness);
smtStatisticsRegistry()->registerStat(&d_giveup);
smtStatisticsRegistry()->registerStat(&d_timestat);
Trace("decision") << "Justification heuristic enabled" << std::endl;
JustificationHeuristic::~JustificationHeuristic()
{
- smtStatisticsRegistry()->unregisterStat(&d_helfulness);
+ smtStatisticsRegistry()->unregisterStat(&d_helpfulness);
smtStatisticsRegistry()->unregisterStat(&d_giveup);
smtStatisticsRegistry()->unregisterStat(&d_timestat);
}
if(litDecision != undefSatLiteral) {
setPrvsIndex(i);
Trace("decision") << "jh: splitting on " << litDecision << std::endl;
- ++d_helfulness;
+ ++d_helpfulness;
return litDecision;
}
}
context::CDO<unsigned> d_prvsIndex;
context::CDO<unsigned> d_threshPrvsIndex;
- IntStat d_helfulness;
+ IntStat d_helpfulness;
IntStat d_giveup;
TimerStat d_timestat;
SmtEngine* getSmt() { return d_smt; }
TheoryEngine* getTheoryEngine() { return d_smt->d_theoryEngine; }
- prop::PropEngine* getPropEngine() { return d_smt->d_propEngine; }
+ prop::PropEngine* getPropEngine() { return d_smt->getPropEngine(); }
context::Context* getUserContext() { return d_smt->d_userContext; }
context::Context* getDecisionContext() { return d_smt->d_context; }
RemoveTermFormulas* getIteRemover() { return d_iteRemover; }
public:
MinisatSatSolver(StatisticsRegistry* registry);
- virtual ~MinisatSatSolver();
-;
+ ~MinisatSatSolver() override;
static SatVariable toSatVariable(Minisat::Var var);
static Minisat::Lit toMinisatLit(SatLiteral lit);
PropEngine::~PropEngine() {
Debug("prop") << "Destructing the PropEngine" << endl;
d_decisionEngine->shutdown();
+ d_decisionEngine.reset(nullptr);
delete d_cnfStream;
delete d_registrar;
delete d_satSolver;
};/* class BVSatSolverInterface */
+class DPLLSatSolverInterface : public SatSolver
+{
+ public:
+ virtual ~DPLLSatSolverInterface(){};
-class DPLLSatSolverInterface: public SatSolver {
-public:
- virtual void initialize(context::Context* context, prop::TheoryProxy* theoryProxy) = 0;
+ virtual void initialize(context::Context* context,
+ prop::TheoryProxy* theoryProxy) = 0;
virtual void push() = 0;
virtual void requirePhase(SatLiteral lit) = 0;
virtual bool isDecision(SatVariable decn) const = 0;
-};/* class DPLLSatSolverInterface */
+}; /* class DPLLSatSolverInterface */
inline std::ostream& operator <<(std::ostream& out, prop::SatLiteral lit) {
out << lit.toString();
d_userLevels(),
d_exprManager(em),
d_nodeManager(d_exprManager->getNodeManager()),
- d_theoryEngine(NULL),
- d_propEngine(NULL),
+ d_theoryEngine(nullptr),
+ d_propEngine(nullptr),
d_proofManager(NULL),
d_definedFunctions(NULL),
d_fmfRecFunctionsDefined(NULL),
Trace("smt-debug") << "Making decision engine..." << std::endl;
Trace("smt-debug") << "Making prop engine..." << std::endl;
- d_propEngine = new PropEngine(d_theoryEngine,
- d_context,
- d_userContext,
- d_private->getReplayLog(),
- d_replayStream);
+ /* 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 PropEngine(d_theoryEngine,
+ d_context,
+ d_userContext,
+ d_private->getReplayLog(),
+ d_replayStream));
Trace("smt-debug") << "Setting up theory engine..." << std::endl;
- d_theoryEngine->setPropEngine(d_propEngine);
+ d_theoryEngine->setPropEngine(getPropEngine());
Trace("smt-debug") << "Finishing init for theory engine..." << std::endl;
d_theoryEngine->finishInit();
internalPop(true);
}
- if(d_propEngine != NULL) {
+ if (d_propEngine != nullptr)
+ {
d_propEngine->shutdown();
}
- if(d_theoryEngine != NULL) {
+ if (d_theoryEngine != nullptr)
+ {
d_theoryEngine->shutdown();
}
}
delete d_theoryEngine;
d_theoryEngine = NULL;
- delete d_propEngine;
- d_propEngine = NULL;
+ d_propEngine.reset(nullptr);
delete d_stats;
d_stats = NULL;
void SmtEngine::resetAssertions()
{
SmtScope smts(this);
+
+ if (!d_fullyInited)
+ {
+ // We're still in Start Mode, nothing asserted yet, do nothing.
+ // (see solver execution modes in the SMT-LIB standard)
+ Assert(d_context->getLevel() == 0);
+ Assert(d_userContext->getLevel() == 0);
+ DeleteAndClearCommandVector(d_modelGlobalCommands);
+ return;
+ }
+
doPendingPops();
Trace("smt") << "SMT resetAssertions()" << endl;
- if(Dump.isOn("benchmark")) {
+ if (Dump.isOn("benchmark"))
+ {
Dump("benchmark") << ResetAssertionsCommand();
}
- while(!d_userLevels.empty()) {
+ while (!d_userLevels.empty())
+ {
pop();
}
- // Also remember the global push/pop around everything.
+ // Remember the global push/pop around everything when beyond Start mode
+ // (see solver execution modes in the SMT-LIB standard)
Assert(d_userLevels.size() == 0 && d_userContext->getLevel() == 1);
d_context->popto(0);
d_userContext->popto(0);
DeleteAndClearCommandVector(d_modelGlobalCommands);
d_userContext->push();
d_context->push();
+
+ /* Create new PropEngine.
+ * First 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 PropEngine(d_theoryEngine,
+ d_context,
+ d_userContext,
+ d_private->getReplayLog(),
+ d_replayStream));
}
void SmtEngine::interrupt()
SmtEngine(const SmtEngine&) = delete;
SmtEngine& operator=(const SmtEngine&) = delete;
+ /** Get a pointer to the PropEngine owned by this SmtEngine. */
+ prop::PropEngine* getPropEngine() { return d_propEngine.get(); }
+
/**
* Check that a generated proof (via getProof()) checks.
*/
/** The theory engine */
TheoryEngine* d_theoryEngine;
/** The propositional engine */
- prop::PropEngine* d_propEngine;
+ std::unique_ptr<prop::PropEngine> d_propEngine;
/** The proof manager */
ProofManager* d_proofManager;
void StatisticsRegistry::registerStat(Stat* s)
{
#ifdef CVC4_STATISTICS_ON
- PrettyCheckArgument(d_stats.find(s) == d_stats.end(), s,
- "Statistic `%s' was not registered with this registry.",
- s->getName().c_str());
+ PrettyCheckArgument(
+ d_stats.find(s) == d_stats.end(),
+ s,
+ "Statistic `%s' is already registered with this registry.",
+ s->getName().c_str());
d_stats.insert(s);
#endif /* CVC4_STATISTICS_ON */
}/* StatisticsRegistry::registerStat_() */
regress0/rels/rel_transpose_7.cvc
regress0/rels/relations-ops.smt2
regress0/rels/rels-sharing-simp.cvc
- regress0/reset-assertions.smt2
regress0/sep/dispose-1.smt2
regress0/sep/dup-nemp.smt2
regress0/sep/issue3720-check-model.smt2
regress0/smtlib/get-unsat-assumptions.smt2
regress0/smtlib/global-decls.smt2
regress0/smtlib/reason-unknown.smt2
+ regress0/smtlib/reset-assertions1.smt2
+ regress0/smtlib/reset-assertions2.smt2
+ regress0/smtlib/reset-assertions-global.smt2
regress0/smtlib/reset-force-logic.smt2
regress0/smtlib/reset-set-logic.smt2
regress0/smtlib/set-info-status.smt2
+++ /dev/null
-; EXPECT: sat
-; EXPECT: sat
-(set-logic QF_ALL)
-(set-option :incremental true)
-(set-option :produce-models true)
-
-(declare-fun x () Real)
-(declare-fun y () Real)
-(assert (> x 0.0))
-(assert (> y 0.0))
-(assert (= (+ (* 2 x) y) 4))
-(check-sat)
-(reset-assertions)
-
-(declare-fun a () (Array Int Int))
-(assert (= (select a 4) 10))
-(check-sat)
--- /dev/null
+; EXPECT: unsat
+; EXPECT: sat
+; EXPECT: unsat
+(set-option :global-declarations true)
+(set-logic QF_BV)
+(set-option :incremental true)
+(declare-fun x2 () (_ BitVec 3))
+(declare-fun x1 () (_ BitVec 3))
+(declare-fun x0 () (_ BitVec 3))
+(assert (bvult (bvudiv (bvudiv (bvudiv x0 x0) x1) x2) x1))
+(assert (= #b000 x2))
+(check-sat)
+(reset-assertions)
+(assert (= x2 x1))
+(check-sat)
+(reset-assertions)
+(assert (distinct x1 x1))
+(check-sat)
--- /dev/null
+; EXPECT: unsat
+; EXPECT: sat
+(set-logic QF_BV)
+(declare-fun v0 () (_ BitVec 4))
+(set-option :produce-models true)
+(reset-assertions)
+(set-option :incremental true)
+(assert (and (= v0 (_ bv0 4)) (distinct v0 (_ bv0 4))))
+(check-sat)
+(reset-assertions)
+(check-sat)
--- /dev/null
+; EXPECT: sat
+; EXPECT: sat
+(set-logic QF_ALL)
+(set-option :incremental true)
+(set-option :produce-models true)
+
+(declare-fun x () Real)
+(declare-fun y () Real)
+(assert (> x 0.0))
+(assert (> y 0.0))
+(assert (= (+ (* 2 x) y) 4))
+(check-sat)
+(reset-assertions)
+
+(declare-fun a () (Array Int Int))
+(assert (= (select a 4) 10))
+(check-sat)