This is the second prerequisite for eliminating dependencies on quantifiers engine. This PR threads a quantifiers inference manager through all modules in quantifiers that add lemmas.
The code for adding lemmas in quantifiers engine will be migrated to this class.
theory/quantifiers/quant_util.h
theory/quantifiers/quantifiers_attributes.cpp
theory/quantifiers/quantifiers_attributes.h
+ theory/quantifiers/quantifiers_inference_manager.cpp
+ theory/quantifiers/quantifiers_inference_manager.h
theory/quantifiers/quantifiers_modules.cpp
theory/quantifiers/quantifiers_modules.h
theory/quantifiers/quantifiers_rewriter.cpp
}
InstStrategyCegqi::InstStrategyCegqi(QuantifiersEngine* qe,
- QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_irew(new InstRewriterCegqi(this)),
d_cbqi_set_quant_inactive(false),
d_incomplete_check(false),
typedef context::CDHashMap< Node, int, NodeHashFunction> NodeIntMap;
public:
- InstStrategyCegqi(QuantifiersEngine* qe, QuantifiersState& qs);
+ InstStrategyCegqi(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~InstStrategyCegqi();
/** whether to do counterexample-guided instantiation for quantifier q */
}
ConjectureGenerator::ConjectureGenerator(QuantifiersEngine* qe,
- QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_notify(*this),
d_uequalityEngine(
d_notify, qs.getSatContext(), "ConjectureGenerator::ee", false),
unsigned flushWaitingConjectures( unsigned& addedLemmas, int ldepth, int rdepth );
public:
- ConjectureGenerator(QuantifiersEngine* qe, QuantifiersState& qs);
+ ConjectureGenerator(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~ConjectureGenerator();
/* needs check */
namespace quantifiers {
InstantiationEngine::InstantiationEngine(QuantifiersEngine* qe,
- QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_instStrategies(),
d_isup(),
d_i_ag(),
void doInstantiationRound(Theory::Effort effort);
public:
- InstantiationEngine(QuantifiersEngine* qe, QuantifiersState& qs);
+ InstantiationEngine(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~InstantiationEngine();
void presolve() override;
bool needsCheck(Theory::Effort e) override;
return lem;
}
-BoundedIntegers::BoundedIntegers(QuantifiersEngine* qe, QuantifiersState& qs)
- : QuantifiersModule(qs, qe)
+BoundedIntegers::BoundedIntegers(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe)
{
}
std::map< Node, std::map< Node, BoundInstTrie > > d_bnd_it;
public:
- BoundedIntegers(QuantifiersEngine* qe, QuantifiersState& qs);
+ BoundedIntegers(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
virtual ~BoundedIntegers();
void presolve() override;
using namespace CVC4::theory::inst;
//Model Engine constructor
-ModelEngine::ModelEngine(QuantifiersEngine* qe, QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+ModelEngine::ModelEngine(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_incomplete_check(true),
d_addedLemmas(0),
d_triedLemmas(0),
int d_triedLemmas;
int d_totalLemmas;
public:
- ModelEngine(QuantifiersEngine* qe, QuantifiersState& qs);
+ ModelEngine(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
virtual ~ModelEngine();
public:
InstStrategyEnum::InstStrategyEnum(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
RelevantDomain* rd)
- : QuantifiersModule(qs, qe), d_rd(rd), d_fullSaturateLimit(-1)
+ : QuantifiersModule(qs, qim, qe), d_rd(rd), d_fullSaturateLimit(-1)
{
}
void InstStrategyEnum::presolve()
public:
InstStrategyEnum(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
RelevantDomain* rd);
~InstStrategyEnum() {}
/** Presolve */
}
QuantConflictFind::QuantConflictFind(QuantifiersEngine* qe,
- QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_conflict(qs.getSatContext(), false),
d_true(NodeManager::currentNM()->mkConst<bool>(true)),
d_false(NodeManager::currentNM()->mkConst<bool>(false)),
bool areMatchDisequal( TNode n1, TNode n2 );
public:
- QuantConflictFind(QuantifiersEngine* qe, QuantifiersState& qs);
+ QuantConflictFind(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
/** register quantifier */
void registerQuantifier(Node q) override;
using namespace CVC4::theory;
using namespace CVC4::theory::quantifiers;
-QuantDSplit::QuantDSplit(QuantifiersEngine* qe, QuantifiersState& qs)
- : QuantifiersModule(qs, qe), d_added_split(qs.getUserContext())
+QuantDSplit::QuantDSplit(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe), d_added_split(qs.getUserContext())
{
}
typedef context::CDHashSet<Node, NodeHashFunction> NodeSet;
public:
- QuantDSplit(QuantifiersEngine* qe, QuantifiersState& qs);
+ QuantDSplit(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
/** determine whether this quantified formula will be reduced */
void checkOwnership(Node q) override;
/* whether this module needs to check this round */
namespace CVC4 {
namespace theory {
-QuantifiersModule::QuantifiersModule(quantifiers::QuantifiersState& qs,
- QuantifiersEngine* qe)
- : d_quantEngine(qe), d_qstate(qs)
+QuantifiersModule::QuantifiersModule(
+ quantifiers::QuantifiersState& qs,
+ quantifiers::QuantifiersInferenceManager& qim,
+ QuantifiersEngine* qe)
+ : d_quantEngine(qe), d_qstate(qs), d_qim(qim)
{
}
#include <map>
#include <vector>
+#include "theory/quantifiers/quantifiers_inference_manager.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/theory.h"
#include "theory/uf/equality_engine.h"
};
public:
- QuantifiersModule(quantifiers::QuantifiersState& qs, QuantifiersEngine* qe);
+ QuantifiersModule(quantifiers::QuantifiersState& qs,
+ quantifiers::QuantifiersInferenceManager& qim,
+ QuantifiersEngine* qe);
virtual ~QuantifiersModule(){}
/** Presolve.
*
QuantifiersEngine* d_quantEngine;
/** The state of the quantifiers engine */
quantifiers::QuantifiersState& d_qstate;
+ /** The quantifiers inference manager */
+ quantifiers::QuantifiersInferenceManager& d_qim;
};/* class QuantifiersModule */
/** Quantifiers utility
--- /dev/null
+/********************* */
+/*! \file quantifiers_inference_manager.cpp
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Andrew Reynolds
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
+ ** in the top-level source directory and their institutional affiliations.
+ ** All rights reserved. See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief Utility for quantifiers inference manager
+ **/
+
+#include "theory/quantifiers/quantifiers_inference_manager.h"
+
+namespace CVC4 {
+namespace theory {
+namespace quantifiers {
+
+QuantifiersInferenceManager::QuantifiersInferenceManager(
+ Theory& t, QuantifiersState& state, ProofNodeManager* pnm)
+ : InferenceManagerBuffered(t, state, pnm)
+{
+}
+
+QuantifiersInferenceManager::~QuantifiersInferenceManager() {}
+
+} // namespace quantifiers
+} // namespace theory
+} // namespace CVC4
--- /dev/null
+/********************* */
+/*! \file quantifiers_inference_manager.h
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Andrew Reynolds
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
+ ** in the top-level source directory and their institutional affiliations.
+ ** All rights reserved. See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief Utility for quantifiers inference manager
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_INFERENCE_MANAGER_H
+#define CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_INFERENCE_MANAGER_H
+
+#include "theory/inference_manager_buffered.h"
+#include "theory/quantifiers/quantifiers_state.h"
+
+namespace CVC4 {
+namespace theory {
+namespace quantifiers {
+
+/**
+ * The quantifiers inference manager.
+ */
+class QuantifiersInferenceManager : public InferenceManagerBuffered
+{
+ public:
+ QuantifiersInferenceManager(Theory& t,
+ QuantifiersState& state,
+ ProofNodeManager* pnm);
+ ~QuantifiersInferenceManager();
+};
+
+} // namespace quantifiers
+} // namespace theory
+} // namespace CVC4
+
+#endif /* CVC4__THEORY__QUANTIFIERS__QUANTIFIERS_INFERENCE_MANAGER_H */
QuantifiersModules::~QuantifiersModules() {}
void QuantifiersModules::initialize(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
std::vector<QuantifiersModule*>& modules)
{
// add quantifiers modules
if (options::quantConflictFind())
{
- d_qcf.reset(new QuantConflictFind(qe, qs));
+ d_qcf.reset(new QuantConflictFind(qe, qs, qim));
modules.push_back(d_qcf.get());
}
if (options::conjectureGen())
{
- d_sg_gen.reset(new ConjectureGenerator(qe, qs));
+ d_sg_gen.reset(new ConjectureGenerator(qe, qs, qim));
modules.push_back(d_sg_gen.get());
}
if (!options::finiteModelFind() || options::fmfInstEngine())
{
- d_inst_engine.reset(new InstantiationEngine(qe, qs));
+ d_inst_engine.reset(new InstantiationEngine(qe, qs, qim));
modules.push_back(d_inst_engine.get());
}
if (options::cegqi())
{
- d_i_cbqi.reset(new InstStrategyCegqi(qe, qs));
+ d_i_cbqi.reset(new InstStrategyCegqi(qe, qs, qim));
modules.push_back(d_i_cbqi.get());
qe->getInstantiate()->addRewriter(d_i_cbqi->getInstRewriter());
}
if (options::sygus())
{
- d_synth_e.reset(new SynthEngine(qe, qs));
+ d_synth_e.reset(new SynthEngine(qe, qs, qim));
modules.push_back(d_synth_e.get());
}
// finite model finding
if (options::fmfBound())
{
- d_bint.reset(new BoundedIntegers(qe, qs));
+ d_bint.reset(new BoundedIntegers(qe, qs, qim));
modules.push_back(d_bint.get());
}
if (options::finiteModelFind() || options::fmfBound())
{
- d_model_engine.reset(new ModelEngine(qe, qs));
+ d_model_engine.reset(new ModelEngine(qe, qs, qim));
modules.push_back(d_model_engine.get());
}
if (options::quantDynamicSplit() != options::QuantDSplitMode::NONE)
{
- d_qsplit.reset(new QuantDSplit(qe, qs));
+ d_qsplit.reset(new QuantDSplit(qe, qs, qim));
modules.push_back(d_qsplit.get());
}
if (options::quantAlphaEquiv())
if (options::fullSaturateQuant() || options::fullSaturateInterleave())
{
d_rel_dom.reset(new RelevantDomain(qe));
- d_fs.reset(new InstStrategyEnum(qe, qs, d_rel_dom.get()));
+ d_fs.reset(new InstStrategyEnum(qe, qs, qim, d_rel_dom.get()));
modules.push_back(d_fs.get());
}
if (options::sygusInst())
{
- d_sygus_inst.reset(new SygusInst(qe, qs));
+ d_sygus_inst.reset(new SygusInst(qe, qs, qim));
modules.push_back(d_sygus_inst.get());
}
}
*/
void initialize(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
std::vector<QuantifiersModule*>& modules);
private:
namespace theory {
namespace quantifiers {
-SynthEngine::SynthEngine(QuantifiersEngine* qe, QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+SynthEngine::SynthEngine(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_tds(qe->getTermDatabaseSygus()),
d_conj(nullptr),
d_sqp(qe)
typedef context::CDHashMap<Node, bool, NodeHashFunction> NodeBoolMap;
public:
- SynthEngine(QuantifiersEngine* qe, QuantifiersState& qs);
+ SynthEngine(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~SynthEngine();
/** presolve
*
return os;
}
-TermDbSygus::TermDbSygus(QuantifiersEngine* qe, QuantifiersState& qs)
+TermDbSygus::TermDbSygus(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
: d_quantEngine(qe),
d_qstate(qs),
+ d_qim(qim),
d_syexp(new SygusExplain(this)),
d_ext_rw(new ExtendedRewriter(true)),
d_eval(new Evaluator),
// TODO :issue #1235 split and document this class
class TermDbSygus {
public:
- TermDbSygus(QuantifiersEngine* qe, QuantifiersState& qs);
+ TermDbSygus(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~TermDbSygus() {}
/** Reset this utility */
bool reset(Theory::Effort e);
QuantifiersEngine* d_quantEngine;
/** Reference to the quantifiers state */
QuantifiersState& d_qstate;
+ /** The quantifiers inference manager */
+ QuantifiersInferenceManager& d_qim;
//------------------------------utilities
/** sygus explanation */
} // namespace
-SygusInst::SygusInst(QuantifiersEngine* qe, QuantifiersState& qs)
- : QuantifiersModule(qs, qe),
+SygusInst::SygusInst(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim)
+ : QuantifiersModule(qs, qim, qe),
d_ce_lemma_added(qs.getUserContext()),
d_global_terms(qs.getUserContext()),
d_notified_assertions(qs.getUserContext())
class SygusInst : public QuantifiersModule
{
public:
- SygusInst(QuantifiersEngine* qe, QuantifiersState& qs);
+ SygusInst(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim);
~SygusInst() = default;
bool needsCheck(Theory::Effort e) override;
namespace theory {
namespace quantifiers {
-TermDb::TermDb(QuantifiersState& qs, QuantifiersEngine* qe)
- : d_quantEngine(qe), d_inactive_map(qs.getSatContext())
+TermDb::TermDb(QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
+ QuantifiersEngine* qe)
+ : d_quantEngine(qe),
+ d_qstate(qs),
+ d_qim(qim),
+ d_inactive_map(qs.getSatContext())
{
d_consistent_ee = true;
d_true = NodeManager::currentNM()->mkConst(true);
typedef context::CDHashMap<Node, bool, NodeHashFunction> NodeBoolMap;
public:
- TermDb(QuantifiersState& qs, QuantifiersEngine* qe);
+ TermDb(QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
+ QuantifiersEngine* qe);
~TermDb();
/** presolve (called once per user check-sat) */
void presolve();
private:
/** reference to the quantifiers engine */
QuantifiersEngine* d_quantEngine;
+ /** The quantifiers state object */
+ QuantifiersState& d_qstate;
+ /** The quantifiers inference manager */
+ QuantifiersInferenceManager& d_qim;
/** terms processed */
std::unordered_set< Node, NodeHashFunction > d_processed;
/** terms processed */
namespace theory {
namespace quantifiers {
-TermUtil::TermUtil(QuantifiersEngine* qe) : d_quantEngine(qe)
+TermUtil::TermUtil()
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
friend class ::CVC4::theory::QuantifiersEngine;
friend class Instantiate;
- private:
- /** reference to the quantifiers engine */
- QuantifiersEngine* d_quantEngine;
-public:
- TermUtil(QuantifiersEngine * qe);
+ public:
+ TermUtil();
~TermUtil();
/** boolean terms */
Node d_true;
ProofNodeManager* pnm)
: Theory(THEORY_QUANTIFIERS, c, u, out, valuation, logicInfo, pnm),
d_qstate(c, u, valuation),
- d_qengine(d_qstate, pnm)
+ d_qim(*this, d_qstate, pnm),
+ d_qengine(d_qstate, d_qim, pnm)
{
out.handleUserAttribute( "fun-def", this );
out.handleUserAttribute("qid", this);
}
// indicate we are using the quantifiers theory state object
d_theoryState = &d_qstate;
+ // use the inference manager as the official inference manager
+ d_inferManager = &d_qim;
// Set the pointer to the quantifiers engine, which this theory owns. This
// pointer will be retreived by TheoryEngine and set to all theories
#include "expr/node.h"
#include "theory/quantifiers/proof_checker.h"
+#include "theory/quantifiers/quantifiers_inference_manager.h"
#include "theory/quantifiers/quantifiers_rewriter.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers_engine.h"
QuantifiersProofRuleChecker d_qChecker;
/** The quantifiers state */
QuantifiersState d_qstate;
+ /** The quantifiers inference manager */
+ QuantifiersInferenceManager d_qim;
/** The quantifiers engine, which lives here */
QuantifiersEngine d_qengine;
};/* class TheoryQuantifiers */
namespace CVC4 {
namespace theory {
-QuantifiersEngine::QuantifiersEngine(quantifiers::QuantifiersState& qstate,
- ProofNodeManager* pnm)
+QuantifiersEngine::QuantifiersEngine(
+ quantifiers::QuantifiersState& qstate,
+ quantifiers::QuantifiersInferenceManager& qim,
+ ProofNodeManager* pnm)
: d_qstate(qstate),
+ d_qim(qim),
d_te(nullptr),
d_decManager(nullptr),
d_masterEqualityEngine(nullptr),
d_tr_trie(new inst::TriggerTrie),
d_model(nullptr),
d_builder(nullptr),
- d_term_util(new quantifiers::TermUtil(this)),
+ d_term_util(new quantifiers::TermUtil),
d_term_canon(new expr::TermCanonize),
- d_term_db(new quantifiers::TermDb(qstate, this)),
+ d_term_db(new quantifiers::TermDb(qstate, qim, this)),
d_sygus_tdb(nullptr),
d_quant_attr(new quantifiers::QuantAttributes(this)),
d_instantiate(new quantifiers::Instantiate(this, qstate, pnm)),
if (options::sygus() || options::sygusInst())
{
// must be constructed here since it is required for datatypes finistInit
- d_sygus_tdb.reset(new quantifiers::TermDbSygus(this, qstate));
+ d_sygus_tdb.reset(new quantifiers::TermDbSygus(this, qstate, qim));
}
d_util.push_back(d_instantiate.get());
d_masterEqualityEngine = mee;
// Initialize the modules and the utilities here.
d_qmodules.reset(new quantifiers::QuantifiersModules);
- d_qmodules->initialize(this, d_qstate, d_modules);
+ d_qmodules->initialize(this, d_qstate, d_qim, d_modules);
if (d_qmodules->d_rel_dom.get())
{
d_util.push_back(d_qmodules->d_rel_dom.get());
#include "theory/quantifiers/instantiate.h"
#include "theory/quantifiers/quant_util.h"
#include "theory/quantifiers/quantifiers_attributes.h"
+#include "theory/quantifiers/quantifiers_inference_manager.h"
#include "theory/quantifiers/quantifiers_state.h"
#include "theory/quantifiers/skolemize.h"
#include "theory/quantifiers/sygus/term_database_sygus.h"
public:
QuantifiersEngine(quantifiers::QuantifiersState& qstate,
+ quantifiers::QuantifiersInferenceManager& qim,
ProofNodeManager* pnm);
~QuantifiersEngine();
//---------------------- external interface
private:
/** The quantifiers state object */
quantifiers::QuantifiersState& d_qstate;
+ /** The quantifiers inference manager */
+ quantifiers::QuantifiersInferenceManager& d_qim;
/** Pointer to theory engine object */
TheoryEngine* d_te;
/** Reference to the decision manager of the theory engine */