This is in preparation for moving several utilities into the quantifiers inference manager.
This PR moves ownership of TermRegistry and QuantifiersRegistry to TheoryQuantifiers from QuantifiersEngine.
#include "theory/quantifiers/ematching/ho_trigger.h"
#include "theory/quantifiers/instantiate.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_database.h"
#include "theory/quantifiers/term_util.h"
#include "theory/quantifiers/ematching/pattern_term_selector.h"
#include "theory/quantifiers/quant_relevance.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers_engine.h"
#include "util/random.h"
#include "theory/quantifiers/instantiate.h"
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_util.h"
#include "theory/quantifiers_engine.h"
**/
#include "theory/quantifiers/relevant_domain.h"
+
#include "theory/arith/arith_msum.h"
#include "theory/quantifiers/first_order_model.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_database.h"
#include "theory/quantifiers/term_util.h"
return os;
}
-TermDbSygus::TermDbSygus(QuantifiersState& qs, QuantifiersInferenceManager& qim)
+TermDbSygus::TermDbSygus(QuantifiersState& qs)
: d_qstate(qs),
- d_qim(qim),
d_syexp(new SygusExplain(this)),
d_ext_rw(new ExtendedRewriter(true)),
d_eval(new Evaluator),
d_false = NodeManager::currentNM()->mkConst( false );
}
+void TermDbSygus::finishInit(QuantifiersInferenceManager* qim) { d_qim = qim; }
+
bool TermDbSygus::reset( Theory::Effort e ) {
return true;
}
ag = d_qstate.getValuation().ensureLiteral(ag);
// must ensure that it is asserted as a literal before we begin solving
Node lem = nm->mkNode(OR, ag, ag.negate());
- d_qim.requirePhase(ag, true);
- d_qim.lemma(lem, InferenceId::QUANTIFIERS_SYGUS_ENUM_ACTIVE_GUARD_SPLIT);
+ d_qim->requirePhase(ag, true);
+ d_qim->lemma(lem, InferenceId::QUANTIFIERS_SYGUS_ENUM_ACTIVE_GUARD_SPLIT);
d_enum_to_active_guard[e] = ag;
}
}
// TODO :issue #1235 split and document this class
class TermDbSygus {
public:
- TermDbSygus(QuantifiersState& qs, QuantifiersInferenceManager& qim);
+ TermDbSygus(QuantifiersState& qs);
~TermDbSygus() {}
+ /** Finish init, which sets the inference manager */
+ void finishInit(QuantifiersInferenceManager* qim);
/** Reset this utility */
bool reset(Theory::Effort e);
/** Identify this utility */
private:
/** Reference to the quantifiers state */
QuantifiersState& d_qstate;
- /** The quantifiers inference manager */
- QuantifiersInferenceManager& d_qim;
+ /** Pointer to the quantifiers inference manager */
+ QuantifiersInferenceManager* d_qim;
//------------------------------utilities
/** sygus explanation */
#include "theory/quantifiers/ematching/trigger_term_info.h"
#include "theory/quantifiers/quantifiers_attributes.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/term_util.h"
#include "theory/quantifiers_engine.h"
namespace theory {
namespace quantifiers {
-TermDb::TermDb(QuantifiersState& qs,
- QuantifiersInferenceManager& qim,
- QuantifiersRegistry& qr)
+TermDb::TermDb(QuantifiersState& qs, QuantifiersRegistry& qr)
: d_qstate(qs),
- d_qim(qim),
+ d_qim(nullptr),
d_qreg(qr),
d_termsContext(),
d_termsContextUse(options::termDbCd() ? qs.getSatContext()
}
+void TermDb::finishInit(QuantifiersInferenceManager* qim) { d_qim = qim; }
+
void TermDb::registerQuantifier( Node q ) {
Assert(q[0].getNumChildren() == d_qreg.getNumInstantiationConstants(q));
for (size_t i = 0, nvars = q[0].getNumChildren(); i < nvars; i++)
}
Trace("term-db-lemma") << " add lemma : " << lem << std::endl;
}
- d_qim.addPendingLemma(lem, InferenceId::UNKNOWN);
+ d_qim->addPendingLemma(lem, InferenceId::UNKNOWN);
d_qstate.notifyInConflict();
d_consistent_ee = false;
return;
// equality is sent out as a lemma here.
Trace("term-db-lemma")
<< "Purify equality lemma: " << eq << std::endl;
- d_qim.addPendingLemma(eq, InferenceId::UNKNOWN);
+ d_qim->addPendingLemma(eq, InferenceId::UNKNOWN);
d_qstate.notifyInConflict();
d_consistent_ee = false;
return false;
public:
TermDb(QuantifiersState& qs,
- QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr);
~TermDb();
+ /** Finish init, which sets the inference manager */
+ void finishInit(QuantifiersInferenceManager* qim);
/** presolve (called once per user check-sat) */
void presolve();
/** reset (calculate which terms are active) */
private:
/** The quantifiers state object */
QuantifiersState& d_qstate;
- /** The quantifiers inference manager */
- QuantifiersInferenceManager& d_qim;
+ /** Pointer to the quantifiers inference manager */
+ QuantifiersInferenceManager* d_qim;
/** The quantifiers registry */
QuantifiersRegistry& d_qreg;
/** A context for the data structures below, when not context-dependent */
namespace theory {
namespace quantifiers {
-TermRegistry::TermRegistry(QuantifiersState& qs,
- QuantifiersInferenceManager& qim,
- QuantifiersRegistry& qr)
+TermRegistry::TermRegistry(QuantifiersState& qs, QuantifiersRegistry& qr)
: d_presolve(qs.getUserContext(), true),
d_presolveCache(qs.getUserContext()),
d_termEnum(new TermEnumeration),
- d_termDb(new TermDb(qs, qim, qr)),
+ d_termDb(new TermDb(qs, qr)),
d_sygusTdb(nullptr)
{
if (options::sygus() || options::sygusInst())
{
// must be constructed here since it is required for datatypes finistInit
- d_sygusTdb.reset(new TermDbSygus(qs, qim));
+ d_sygusTdb.reset(new TermDbSygus(qs));
+ }
+}
+
+void TermRegistry::finishInit(QuantifiersInferenceManager* qim)
+{
+ d_termDb->finishInit(qim);
+ if (d_sygusTdb.get())
+ {
+ d_sygusTdb->finishInit(qim);
}
}
public:
TermRegistry(QuantifiersState& qs,
- QuantifiersInferenceManager& qim,
QuantifiersRegistry& qr);
+ /** Finish init, which sets the inference manager on modules of this class */
+ void finishInit(QuantifiersInferenceManager* qim);
/** Presolve */
void presolve();
#include "theory/quantifiers/index_trie.h"
#include "theory/quantifiers/quant_module.h"
#include "theory/quantifiers/relevant_domain.h"
+#include "theory/quantifiers/term_registry.h"
#include "theory/quantifiers/term_util.h"
#include "theory/quantifiers_engine.h"
#include "util/statistics_registry.h"
ProofNodeManager* pnm)
: Theory(THEORY_QUANTIFIERS, c, u, out, valuation, logicInfo, pnm),
d_qstate(c, u, valuation, logicInfo),
+ d_qreg(),
+ d_treg(d_qstate, d_qreg),
d_qim(*this, d_qstate, pnm),
- d_qengine(d_qstate, d_qim, pnm)
+ d_qengine(d_qstate, d_qreg, d_treg, d_qim, pnm)
{
+ // Finish initializing the term registry by hooking it up to the inference
+ // manager. This is required due to a cyclic dependency between the term
+ // database and the instantiate module. Term database needs inference manager
+ // since it sends out lemmas when term indexing is inconsistent, instantiate
+ // needs term database for entailment checks.
+ d_treg.finishInit(&d_qim);
+
out.handleUserAttribute( "fun-def", this );
out.handleUserAttribute("qid", this);
out.handleUserAttribute( "quant-inst-max-level", this );
#include "expr/node.h"
#include "theory/quantifiers/proof_checker.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_rewriter.h"
#include "theory/quantifiers/quantifiers_state.h"
+#include "theory/quantifiers/term_registry.h"
#include "theory/quantifiers_engine.h"
#include "theory/theory.h"
#include "theory/valuation.h"
QuantifiersProofRuleChecker d_qChecker;
/** The quantifiers state */
QuantifiersState d_qstate;
+ /** The quantifiers registry */
+ quantifiers::QuantifiersRegistry d_qreg;
+ /** The term registry */
+ quantifiers::TermRegistry d_treg;
/** The quantifiers inference manager */
QuantifiersInferenceManager d_qim;
/** The quantifiers engine, which lives here */
#include "theory/quantifiers/fmf/first_order_model_fmc.h"
#include "theory/quantifiers/fmf/full_model_check.h"
#include "theory/quantifiers/fmf/model_builder.h"
+#include "theory/quantifiers/quant_module.h"
#include "theory/quantifiers/quantifiers_inference_manager.h"
#include "theory/quantifiers/quantifiers_modules.h"
+#include "theory/quantifiers/quantifiers_registry.h"
#include "theory/quantifiers/quantifiers_rewriter.h"
#include "theory/quantifiers/quantifiers_state.h"
-#include "theory/quantifiers/quant_module.h"
#include "theory/quantifiers/relevant_domain.h"
#include "theory/quantifiers/skolemize.h"
-#include "theory/quantifiers/sygus/term_database_sygus.h"
-#include "theory/quantifiers/term_util.h"
-#include "theory/quantifiers/term_database.h"
#include "theory/quantifiers/term_enumeration.h"
+#include "theory/quantifiers/term_registry.h"
+#include "theory/quantifiers/term_util.h"
#include "theory/theory_engine.h"
#include "theory/uf/equality_engine.h"
QuantifiersEngine::QuantifiersEngine(
quantifiers::QuantifiersState& qstate,
+ quantifiers::QuantifiersRegistry& qr,
+ quantifiers::TermRegistry& tr,
quantifiers::QuantifiersInferenceManager& qim,
ProofNodeManager* pnm)
: d_qstate(qstate),
d_te(nullptr),
d_decManager(nullptr),
d_pnm(pnm),
- d_qreg(),
- d_treg(qstate, qim, d_qreg),
+ d_qreg(qr),
+ d_treg(tr),
d_tr_trie(new inst::TriggerTrie),
d_model(nullptr),
d_builder(nullptr),
#include "context/cdhashset.h"
#include "context/cdlist.h"
#include "theory/quantifiers/quant_util.h"
-#include "theory/quantifiers/quantifiers_registry.h"
-#include "theory/quantifiers/term_registry.h"
#include "util/statistics_registry.h"
namespace CVC4 {
class QuantifiersInferenceManager;
class QuantifiersModules;
class QuantifiersState;
+class QuantifiersRegistry;
class Skolemize;
class TermDb;
class TermDbSygus;
class TermEnumeration;
+class TermRegistry;
}
// TODO: organize this more/review this, github issue #1163
public:
QuantifiersEngine(quantifiers::QuantifiersState& qstate,
+ quantifiers::QuantifiersRegistry& qr,
+ quantifiers::TermRegistry& tr,
quantifiers::QuantifiersInferenceManager& qim,
ProofNodeManager* pnm);
~QuantifiersEngine();
std::vector<QuantifiersModule*> d_modules;
//------------- quantifiers utilities
/** The quantifiers registry */
- quantifiers::QuantifiersRegistry d_qreg;
+ quantifiers::QuantifiersRegistry& d_qreg;
/** The term registry */
- quantifiers::TermRegistry d_treg;
+ quantifiers::TermRegistry& d_treg;
/** all triggers will be stored in this trie */
std::unique_ptr<inst::TriggerTrie> d_tr_trie;
/** extended model object */