Work towards eliminating dependencies on quantifiers engine, this updates quantifiers module to use the standard SAT-context dependent flag in quantifiers state instead of the one in QuantifiersEngine. It also eliminates the use of a custom call to theoryEngineNeedsCheck.
{
if (quant_e == QEFFORT_STANDARD)
{
- Assert(!d_quantEngine->inConflict());
+ Assert(!d_qstate.isInConflict());
double clSet = 0;
if( Trace.isOn("cegqi-engine") ){
clSet = double(clock())/double(CLOCKS_PER_SEC);
Node q = it->first;
Trace("cegqi") << "CBQI : Process quantifier " << q[0] << " at effort " << ee << std::endl;
process(q, e, ee);
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
break;
}
}
- if( d_quantEngine->inConflict() || d_quantEngine->getNumLemmasWaiting()>lastWaiting ){
+ if (d_qstate.isInConflict()
+ || d_quantEngine->getNumLemmasWaiting() > lastWaiting)
+ {
break;
}
}
namespace quantifiers {
+class QuantifiersState;
+
/** A status response to process */
enum class InstStrategyStatus
{
class InstStrategy
{
public:
- InstStrategy(QuantifiersEngine* qe) : d_quantEngine(qe) {}
+ InstStrategy(QuantifiersEngine* qe, QuantifiersState& qs)
+ : d_quantEngine(qe), d_qstate(qs)
+ {
+ }
virtual ~InstStrategy() {}
/** presolve */
virtual void presolve() {}
protected:
/** reference to the instantiation engine */
QuantifiersEngine* d_quantEngine;
+ /** The quantifiers state object */
+ QuantifiersState& d_qstate;
}; /* class InstStrategy */
} // namespace quantifiers
};
InstStrategyAutoGenTriggers::InstStrategyAutoGenTriggers(QuantifiersEngine* qe,
+ QuantifiersState& qs,
QuantRelevance* qr)
- : InstStrategy(qe), d_quant_rel(qr)
+ : InstStrategy(qe, qs), d_quant_rel(qr)
{
//how to select trigger terms
d_tr_strategy = options::triggerSelMode();
{
d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst;
}
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
break;
}
}
- if (d_quantEngine->inConflict()
- || (hasInst && options::multiTriggerPriority()))
+ if (d_qstate.isInConflict() || (hasInst && options::multiTriggerPriority()))
{
break;
}
std::map<Node, bool> d_hasUserPatterns;
public:
- InstStrategyAutoGenTriggers(QuantifiersEngine* qe, QuantRelevance* qr);
+ InstStrategyAutoGenTriggers(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantRelevance* qr);
~InstStrategyAutoGenTriggers() {}
/** get auto-generated trigger */
namespace theory {
namespace quantifiers {
-InstStrategyUserPatterns::InstStrategyUserPatterns(QuantifiersEngine* ie)
- : InstStrategy(ie)
+InstStrategyUserPatterns::InstStrategyUserPatterns(QuantifiersEngine* ie,
+ QuantifiersState& qs)
+ : InstStrategy(ie, qs)
{
}
InstStrategyUserPatterns::~InstStrategyUserPatterns() {}
{
d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst;
}
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
// we are already in conflict
break;
class InstStrategyUserPatterns : public InstStrategy
{
public:
- InstStrategyUserPatterns(QuantifiersEngine* qe);
+ InstStrategyUserPatterns(QuantifiersEngine* qe, QuantifiersState& qs);
~InstStrategyUserPatterns();
/** add pattern */
void addUserPattern(Node q, Node pat);
// user-provided patterns
if (options::userPatternsQuant() != options::UserPatMode::IGNORE)
{
- d_isup.reset(new InstStrategyUserPatterns(d_quantEngine));
+ d_isup.reset(new InstStrategyUserPatterns(d_quantEngine, qs));
d_instStrategies.push_back(d_isup.get());
}
// auto-generated patterns
d_i_ag.reset(
- new InstStrategyAutoGenTriggers(d_quantEngine, d_quant_rel.get()));
+ new InstStrategyAutoGenTriggers(d_quantEngine, qs, d_quant_rel.get()));
d_instStrategies.push_back(d_i_ag.get());
}
}
}
}
-FullModelChecker::FullModelChecker(QuantifiersEngine* qe) : QModelBuilder(qe)
+FullModelChecker::FullModelChecker(QuantifiersEngine* qe, QuantifiersState& qs)
+ : QModelBuilder(qe, qs)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
Trace("fmc") << "Full model check " << f << ", effort = " << effort << "..." << std::endl;
// register the quantifier
registerQuantifiedFormula(f);
- Assert(!d_qe->inConflict());
+ Assert(!d_qstate.isInConflict());
// we do not do model-based quantifier instantiation if the option
// disables it, or if the quantified formula has an unhandled type.
if (!optUseModel() || !isHandled(f))
{
Trace("fmc-debug-inst") << "** Added instantiation." << std::endl;
d_addedLemmas++;
- if (d_qe->inConflict() || options::fmfOneInstPerRound())
+ if (d_qstate.isInConflict() || options::fmfOneInstPerRound())
{
break;
}
{
Trace("fmc-exh-debug") << " ...success.";
addedLemmas++;
- if( d_qe->inConflict() || options::fmfOneInstPerRound() ){
+ if (d_qstate.isInConflict() || options::fmfOneInstPerRound())
+ {
break;
}
}else{
Node getSomeDomainElement( FirstOrderModelFmc * fm, TypeNode tn );
public:
- FullModelChecker(QuantifiersEngine* qe);
+ FullModelChecker(QuantifiersEngine* qe, QuantifiersState& qs);
void debugPrintCond(const char * tr, Node n, bool dispStar = false);
void debugPrint(const char * tr, Node n, bool dispStar = false);
using namespace CVC4::theory;
using namespace CVC4::theory::quantifiers;
-QModelBuilder::QModelBuilder(QuantifiersEngine* qe)
+QModelBuilder::QModelBuilder(QuantifiersEngine* qe, QuantifiersState& qs)
: TheoryEngineModelBuilder(qe->getTheoryEngine()),
d_qe(qe),
d_addedLemmas(0),
- d_triedLemmas(0)
+ d_triedLemmas(0),
+ d_qstate(qs)
{
}
#include "expr/node.h"
#include "theory/quantifiers/first_order_model.h"
#include "theory/quantifiers/inst_match.h"
+#include "theory/quantifiers/quantifiers_state.h"
#include "theory/theory_model_builder.h"
namespace CVC4 {
unsigned d_triedLemmas;
public:
- QModelBuilder(QuantifiersEngine* qe);
+ QModelBuilder(QuantifiersEngine* qe, QuantifiersState& qs);
//do exhaustive instantiation
// 0 : failed, but resorting to true exhaustive instantiation may work
//statistics
unsigned getNumAddedLemmas() { return d_addedLemmas; }
unsigned getNumTriedLemmas() { return d_triedLemmas; }
+
+ protected:
+ /** The quantifiers state object */
+ QuantifiersState& d_qstate;
};
}/* CVC4::theory::quantifiers namespace */
doCheck = quant_e == QEFFORT_MODEL;
}
if( doCheck ){
- Assert(!d_quantEngine->inConflict());
+ Assert(!d_qstate.isInConflict());
int addedLemmas = 0;
//the following will test that the model satisfies all asserted universal quantifiers by
//determine if we should check this quantifier
if( d_quantEngine->getModel()->isQuantifierActive( q ) && d_quantEngine->hasOwnership( q, this ) ){
exhaustiveInstantiate( q, e );
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
break;
}
if( d_addedLemmas>0 ){
break;
}else{
- Assert(!d_quantEngine->inConflict());
+ Assert(!d_qstate.isInConflict());
}
}
//print debug information
- if( d_quantEngine->inConflict() ){
+ if (d_qstate.isInConflict())
+ {
Trace("model-engine") << "Conflict, added lemmas = ";
}else{
Trace("model-engine") << "Added Lemmas = ";
if (inst->addInstantiation(f, m, true))
{
addedLemmas++;
- if( d_quantEngine->inConflict() ){
+ if (d_qstate.isInConflict())
+ {
break;
}
}else{
}
if (options::fullSaturateQuant() && !doCheck)
{
- if (!d_quantEngine->theoryEngineNeedsCheck())
+ if (!d_qstate.getValuation().needCheck())
{
doCheck = quant_e == QEFFORT_LAST_CALL;
fullEffort = true;
{
return;
}
- Assert(!d_quantEngine->inConflict());
+ Assert(!d_qstate.isInConflict());
double clSet = 0;
if (Trace.isOn("fs-engine"))
{
// added lemma
addedLemmas++;
}
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
break;
}
}
}
- if (d_quantEngine->inConflict()
+ if (d_qstate.isInConflict()
|| (addedLemmas > 0 && options::fullSaturateStratify()))
{
// we break if we are in conflict, or if we added any lemma at this
{
index--;
}
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
// could be conflicting for an internal reason (such as term
// indices computed in above calls)
{
// For resource-limiting (also does a time check).
d_qe->getOutputChannel().safePoint(ResourceManager::Resource::QuantifierStep);
- Assert(!d_qe->inConflict());
+ Assert(!d_qstate.isInConflict());
Assert(terms.size() == q[0].getNumChildren());
Assert(d_term_db != nullptr);
Assert(d_term_util != nullptr);
}
}
// spurious if quantifiers engine is in conflict
- return p->d_quantEngine->inConflict();
+ return p->d_qstate.isInConflict();
}
bool QuantInfo::entailmentTest( QuantConflictFind * p, Node lit, bool chEnt ) {
//}
// modified
TermDb* tdb = p->getTermDatabase();
- QuantifiersEngine* qe = p->getQuantifiersEngine();
+ QuantifiersState& qs = p->getState();
for (unsigned i = 0; i < 2; i++)
{
if (tdb->isEntailed(d_n, i == 0))
{
d_ground_eval[0] = i==0 ? p->d_true : p->d_false;
}
- if (qe->inConflict())
+ if (qs.isInConflict())
{
return false;
}
}
}else if( d_type==typ_eq ){
TermDb* tdb = p->getTermDatabase();
- QuantifiersEngine* qe = p->getQuantifiersEngine();
+ QuantifiersState& qs = p->getState();
for (unsigned i = 0, size = d_n.getNumChildren(); i < size; i++)
{
if (!expr::hasBoundVar(d_n[i]))
{
TNode t = tdb->getEntailedTerm(d_n[i]);
- if (qe->inConflict())
+ if (qs.isInConflict())
{
return false;
}
{
// check this quantified formula
checkQuantifiedFormula(q, isConflict, addedLemmas);
- if (d_conflict || d_quantEngine->inConflict())
+ if (d_conflict || d_qstate.isInConflict())
{
break;
}
// We are done if we added a lemma, or discovered a conflict in another
// way. An example of the latter case is when two disequal congruent terms
// are discovered during term indexing.
- if (addedLemmas > 0 || d_quantEngine->inConflict())
+ if (addedLemmas > 0 || d_qstate.isInConflict())
{
break;
}
Instantiate* qinst = d_quantEngine->getInstantiate();
while (qi->getNextMatch(this))
{
- if (d_quantEngine->inConflict())
+ if (d_qstate.isInConflict())
{
Trace("qcf-check") << " ... Quantifiers engine discovered conflict, ";
Trace("qcf-check") << "probably related to disequal congruent terms in "
return d_quantEngine->getTermUtil();
}
+quantifiers::QuantifiersState& QuantifiersModule::getState()
+{
+ return d_qstate;
+}
+
+quantifiers::QuantifiersInferenceManager&
+QuantifiersModule::getInferenceManager()
+{
+ return d_qim;
+}
+
QuantPhaseReq::QuantPhaseReq( Node n, bool computeEq ){
initialize( n, computeEq );
}
quantifiers::TermDb* getTermDatabase() const;
/** get currently used term utility object */
quantifiers::TermUtil* getTermUtil() const;
+ /** get the quantifiers state */
+ quantifiers::QuantifiersState& getState();
+ /** get the quantifiers inference manager */
+ quantifiers::QuantifiersInferenceManager& getInferenceManager();
//----------------------------end general queries
protected:
/** pointer to the quantifiers engine that owns this module */
activeCheckConj.clear();
activeCheckConj = acnext;
acnext.clear();
- } while (!activeCheckConj.empty()
- && !d_quantEngine->theoryEngineNeedsCheck());
+ } while (!activeCheckConj.empty() && !d_qstate.getValuation().needCheck());
Trace("sygus-engine")
<< "Finished Counterexample Guided Instantiation engine." << std::endl;
}
{
Trace("term-db-lemma") << "Disequal congruent terms : " << at << " "
<< n << "!!!!" << std::endl;
- if (!d_quantEngine->theoryEngineNeedsCheck())
+ if (!d_qstate.getValuation().needCheck())
{
Trace("term-db-lemma") << " all theories passed with no lemmas."
<< std::endl;
Trace("term-db-lemma") << " add lemma : " << lem << std::endl;
}
d_quantEngine->addLemma(lem);
- d_quantEngine->setConflict();
+ d_qstate.notifyInConflict();
d_consistent_ee = false;
return;
}
Trace("term-db-lemma")
<< "Purify equality lemma: " << eq << std::endl;
d_quantEngine->addLemma(eq);
- d_quantEngine->setConflict();
+ d_qstate.notifyInConflict();
d_consistent_ee = false;
return false;
}
d_instantiate(new quantifiers::Instantiate(this, qstate, pnm)),
d_skolemize(new quantifiers::Skolemize(this, qstate, pnm)),
d_term_enum(new quantifiers::TermEnumeration),
- d_conflict_c(qstate.getSatContext(), false),
d_quants_prereg(qstate.getUserContext()),
d_quants_red(qstate.getUserContext()),
d_lemmas_produced_c(qstate.getUserContext()),
d_util.push_back(d_instantiate.get());
d_curr_effort_level = QuantifiersModule::QEFFORT_NONE;
- d_conflict = false;
d_hasAddedLemma = false;
//don't add true lemma
d_lemmas_produced_c[d_term_util->d_true] = true;
Trace("quant-engine-debug") << "...make fmc builder." << std::endl;
d_model.reset(new quantifiers::fmcheck::FirstOrderModelFmc(
this, qstate, "FirstOrderModelFmc"));
- d_builder.reset(new quantifiers::fmcheck::FullModelChecker(this));
+ d_builder.reset(new quantifiers::fmcheck::FullModelChecker(this, qstate));
}else{
Trace("quant-engine-debug") << "...make default model builder." << std::endl;
d_model.reset(
new quantifiers::FirstOrderModel(this, qstate, "FirstOrderModel"));
- d_builder.reset(new quantifiers::QModelBuilder(this));
+ d_builder.reset(new quantifiers::QModelBuilder(this, qstate));
}
}else{
d_model.reset(
return d_te->theoryOf(THEORY_QUANTIFIERS)->getOutputChannel();
}
/** get default valuation for the quantifiers engine */
-Valuation& QuantifiersEngine::getValuation()
-{
- return d_te->theoryOf(THEORY_QUANTIFIERS)->getValuation();
-}
+Valuation& QuantifiersEngine::getValuation() { return d_qstate.getValuation(); }
const LogicInfo& QuantifiersEngine::getLogicInfo() const
{
Trace("quant-engine-debug") << "Master equality engine not consistent, return." << std::endl;
return;
}
- if (d_conflict_c.get())
+ if (d_qstate.isInConflict())
{
if (e < Theory::EFFORT_LAST_CALL)
{
}
}
- d_conflict = false;
d_hasAddedLemma = false;
bool setIncomplete = false;
Trace("quant-engine-debug") << " lemmas waiting = " << d_lemmas_waiting.size() << std::endl;
}
Trace("quant-engine-debug")
- << " Theory engine finished : " << !theoryEngineNeedsCheck()
- << std::endl;
+ << " Theory engine finished : "
+ << !d_qstate.getValuation().needCheck() << std::endl;
Trace("quant-engine-debug") << " Needs model effort : " << needsModelE << std::endl;
Trace("quant-engine-debug")
- << " In conflict : " << d_conflict << std::endl;
+ << " In conflict : " << d_qstate.isInConflict() << std::endl;
}
if( Trace.isOn("quant-engine-ee-pre") ){
Trace("quant-engine-ee-pre") << "Equality engine (pre-inference): " << std::endl;
<< " at effort " << quant_e << "..."
<< std::endl;
mdl->check(e, quant_e);
- if( d_conflict ){
+ if (d_qstate.isInConflict())
+ {
Trace("quant-engine-debug") << "...conflict!" << std::endl;
break;
}
if( d_hasAddedLemma ){
break;
}else{
- Assert(!d_conflict);
+ Assert(!d_qstate.isInConflict());
if (quant_e == QuantifiersModule::QEFFORT_CONFLICT)
{
if( e==Theory::EFFORT_FULL ){
setIncomplete = true;
}
}
- if (d_conflict_c.get())
+ if (d_qstate.isInConflict())
{
// we reported a conflicting lemma, should return
setIncomplete = true;
void QuantifiersEngine::markRelevant( Node q ) {
d_model->markRelevant( q );
}
+
bool QuantifiersEngine::hasAddedLemma() const
{
return !d_lemmas_waiting.empty() || d_hasAddedLemma;
}
-bool QuantifiersEngine::theoryEngineNeedsCheck() const
-{
- return d_te->needCheck();
-}
-void QuantifiersEngine::setConflict()
-{
- d_conflict = true;
- d_conflict_c = true;
-}
+bool QuantifiersEngine::inConflict() const { return d_qstate.isInConflict(); }
bool QuantifiersEngine::getInstWhenNeedsCheck( Theory::Effort e ) {
Trace("quant-engine-debug2") << "Get inst when needs check, counts=" << d_ierCounter << ", " << d_ierCounter_lc << std::endl;
}
else if (options::instWhenMode() == options::InstWhenMode::FULL_DELAY)
{
- performCheck = (e >= Theory::EFFORT_FULL) && !theoryEngineNeedsCheck();
+ performCheck =
+ (e >= Theory::EFFORT_FULL) && !d_qstate.getValuation().needCheck();
}
else if (options::instWhenMode() == options::InstWhenMode::FULL_LAST_CALL)
{
else if (options::instWhenMode()
== options::InstWhenMode::FULL_DELAY_LAST_CALL)
{
- performCheck = ((e == Theory::EFFORT_FULL && !theoryEngineNeedsCheck()
- && d_ierCounter % d_inst_when_phase != 0)
- || e == Theory::EFFORT_LAST_CALL);
+ performCheck =
+ ((e == Theory::EFFORT_FULL && !d_qstate.getValuation().needCheck()
+ && d_ierCounter % d_inst_when_phase != 0)
+ || e == Theory::EFFORT_LAST_CALL);
}
else if (options::instWhenMode() == options::InstWhenMode::LAST_CALL)
{
void markRelevant(Node q);
/** has added lemma */
bool hasAddedLemma() const;
- /** theory engine needs check
- *
- * This is true if the theory engine has more constraints to process. When
- * it is false, we are tentatively going to terminate solving with
- * sat/unknown. For details, see TheoryEngine::needCheck.
- */
- bool theoryEngineNeedsCheck() const;
/** is in conflict */
- bool inConflict() { return d_conflict; }
- /** set conflict */
- void setConflict();
+ bool inConflict() const;
/** get current q effort */
QuantifiersModule::QEffort getCurrentQEffort() { return d_curr_effort_level; }
/** get number of waiting lemmas */
//------------- temporary information during check
/** current effort level */
QuantifiersModule::QEffort d_curr_effort_level;
- /** are we in conflict */
- bool d_conflict;
- context::CDO<bool> d_conflict_c;
/** has added lemma this round */
bool d_hasAddedLemma;
//------------- end temporary information during check
return d_valuation.hasSatValue(n, value);
}
+Valuation& TheoryState::getValuation() { return d_valuation; }
+
} // namespace theory
} // namespace CVC4
/** Returns true if n has a current SAT assignment and stores it in value. */
virtual bool hasSatValue(TNode n, bool& value) const;
+ /** Get the underlying valuation class */
+ Valuation& getValuation();
+
protected:
/** Pointer to the SAT context object used by the theory. */
context::Context* d_context;