namespace theory {
namespace bv {
+/**
+ * Notifies the BV solver when assertions were reset.
+ *
+ * This class is notified after every user-context pop and maintains a flag
+ * that indicates whether assertions have been reset. If the user-context level
+ * reaches level 0 it means that the assertions were reset.
+ */
+class NotifyResetAssertions : public context::ContextNotifyObj
+{
+ public:
+ NotifyResetAssertions(context::Context* c)
+ : context::ContextNotifyObj(c, false),
+ d_context(c),
+ d_doneResetAssertions(false)
+ {
+ }
+
+ bool doneResetAssertions() { return d_doneResetAssertions; }
+
+ void reset() { d_doneResetAssertions = false; }
+
+ protected:
+ void contextNotifyPop() override
+ {
+ // If the user-context level reaches 0 it means that reset-assertions was
+ // called.
+ if (d_context->getLevel() == 0)
+ {
+ d_doneResetAssertions = true;
+ }
+ }
+
+ private:
+ /** The user-context. */
+ context::Context* d_context;
+
+ /** Flag to notify whether reset assertions was called. */
+ bool d_doneResetAssertions;
+};
+
/**
* Bit-blasting registrar.
*
: nullptr),
d_factLiteralCache(s->getSatContext()),
d_literalFactCache(s->getSatContext()),
- d_propagate(options::bitvectorPropagate())
+ d_propagate(options::bitvectorPropagate()),
+ d_resetNotify(new NotifyResetAssertions(s->getUserContext()))
{
if (pnm != nullptr)
{
d_bvProofChecker.registerTo(pnm->getChecker());
}
- switch (options::bvSatSolver())
- {
- case options::SatSolverMode::CRYPTOMINISAT:
- d_satSolver.reset(prop::SatSolverFactory::createCryptoMinisat(
- smtStatisticsRegistry(), "theory::bv::BVSolverBitblast::"));
- break;
- default:
- d_satSolver.reset(prop::SatSolverFactory::createCadical(
- smtStatisticsRegistry(), "theory::bv::BVSolverBitblast::"));
- }
- d_cnfStream.reset(new prop::CnfStream(d_satSolver.get(),
- d_bbRegistrar.get(),
- d_nullContext.get(),
- nullptr,
- smt::currentResourceManager(),
- prop::FormulaLitPolicy::INTERNAL,
- "theory::bv::BVSolverBitblast"));
+ initSatSolver();
}
void BVSolverBitblast::postCheck(Theory::Effort level)
}
}
+ // If we permanently added assertions to the SAT solver and the assertions
+ // were reset, we have to reset the SAT solver and the CNF stream.
+ if (options::bvAssertInput() && d_resetNotify->doneResetAssertions())
+ {
+ d_satSolver.reset(nullptr);
+ d_cnfStream.reset(nullptr);
+ initSatSolver();
+ d_resetNotify->reset();
+ }
+
NodeManager* nm = NodeManager::currentNM();
/* Process input assertions bit-blast queue. */
return EQUALITY_FALSE_IN_MODEL;
}
+void BVSolverBitblast::initSatSolver()
+{
+ switch (options::bvSatSolver())
+ {
+ case options::SatSolverMode::CRYPTOMINISAT:
+ d_satSolver.reset(prop::SatSolverFactory::createCryptoMinisat(
+ smtStatisticsRegistry(), "theory::bv::BVSolverBitblast::"));
+ break;
+ default:
+ d_satSolver.reset(prop::SatSolverFactory::createCadical(
+ smtStatisticsRegistry(), "theory::bv::BVSolverBitblast::"));
+ }
+ d_cnfStream.reset(new prop::CnfStream(d_satSolver.get(),
+ d_bbRegistrar.get(),
+ d_nullContext.get(),
+ nullptr,
+ smt::currentResourceManager(),
+ prop::FormulaLitPolicy::INTERNAL,
+ "theory::bv::BVSolverBitblast"));
+}
+
Node BVSolverBitblast::getValueFromSatSolver(TNode node, bool initialize)
{
if (node.isConst())