This moves the utility class beneath quantifiers registry.
bool InstStrategyCegqi::doAddInstantiation( std::vector< Node >& subs ) {
Assert(!d_curr_quant.isNull());
//if doing partial quantifier elimination, record the instantiation and set the incomplete flag instead of sending instantiation lemma
- if( d_quantEngine->getQuantAttributes()->isQuantElimPartial( d_curr_quant ) ){
+ if (d_qreg.getQuantAttributes().isQuantElimPartial(d_curr_quant))
+ {
d_cbqi_set_quant_inactive = true;
d_incomplete_check = true;
d_quantEngine->getInstantiate()->recordInstantiation(
return false;
}
// also ignore internal quantifiers
- QuantAttributes* qattr = d_quantEngine->getQuantAttributes();
- if (qattr->isInternal(q))
+ QuantAttributes& qattr = d_qreg.getQuantAttributes();
+ if (qattr.isInternal(q))
{
return false;
}
}
if (Trace.isOn("trigger"))
{
- quantifiers::QuantAttributes* qa = d_quantEngine->getQuantAttributes();
- Trace("trigger") << "Trigger for " << qa->quantToString(q) << ": "
+ quantifiers::QuantAttributes& qa = d_qreg.getQuantAttributes();
+ Trace("trigger") << "Trigger for " << qa.quantToString(q) << ": "
<< std::endl;
for (const Node& n : d_nodes)
{
}
}
-int QuantAttributes::getQuantInstLevel( Node q ) {
+int64_t QuantAttributes::getQuantInstLevel(Node q)
+{
std::map< Node, QAttributes >::iterator it = d_qattr.find( q );
if( it==d_qattr.end() ){
return -1;
Node d_sygusSideCondition;
/** stores the maximum instantiation level allowed for this quantified formula
* (-1 means allow any) */
- int d_qinstLevel;
+ int64_t d_qinstLevel;
/** is this formula marked for quantifier elimination? */
bool d_quant_elim;
/** is this formula marked for partial quantifier elimination? */
/** is sygus conjecture */
bool isSygus( Node q );
/** get instantiation level */
- int getQuantInstLevel( Node q );
+ int64_t getQuantInstLevel(Node q);
/** is quant elim */
bool isQuantElim( Node q );
/** is quant elim partial */
namespace theory {
namespace quantifiers {
+QuantifiersRegistry::QuantifiersRegistry() : d_quantAttr() {}
+
void QuantifiersRegistry::registerQuantifier(Node q)
{
if (d_inst_constants.find(q) != d_inst_constants.end())
InstConstantAttribute ica;
ic.setAttribute(ica, q);
}
+ // compute attributes
+ d_quantAttr.computeAttributes(q);
}
bool QuantifiersRegistry::reset(Theory::Effort e) { return true; }
terms.end());
}
+QuantAttributes& QuantifiersRegistry::getQuantAttributes()
+{
+ return d_quantAttr;
+}
+Node QuantifiersRegistry::getNameForQuant(Node q) const
+{
+ Node name = d_quantAttr.getQuantName(q);
+ if (!name.isNull())
+ {
+ return name;
+ }
+ return q;
+}
+
+bool QuantifiersRegistry::getNameForQuant(Node q, Node& name, bool req) const
+{
+ name = getNameForQuant(q);
+ // if we have a name, or we did not require one
+ return name != q || !req;
+}
+
} // namespace quantifiers
} // namespace theory
} // namespace CVC4
#include "expr/node.h"
#include "theory/quantifiers/quant_util.h"
+#include "theory/quantifiers/quantifiers_attributes.h"
namespace CVC4 {
namespace theory {
friend class Instantiate;
public:
- QuantifiersRegistry() {}
+ QuantifiersRegistry();
~QuantifiersRegistry() {}
/**
* Register quantifier, which allocates the instantiation constants for q.
/** substitute { instantiation constants of q -> terms } in n */
Node substituteInstConstants(Node n, Node q, std::vector<Node>& terms);
//----------------------------- end instantiation constants
+ /** Get quantifiers attributes utility class */
+ QuantAttributes& getQuantAttributes();
+ /**
+ * Get quantifiers name, which returns a variable corresponding to the name of
+ * quantified formula q if q has a name, or otherwise returns q itself.
+ */
+ Node getNameForQuant(Node q) const;
+ /**
+ * Get name for quantified formula. Returns true if q has a name or if req
+ * is false. Sets name to the result of the above method.
+ */
+ bool getNameForQuant(Node q, Node& name, bool req = true) const;
+
private:
/**
* Maps quantified formulas to the module that owns them, if any module has
std::map<Node, Node> d_inst_constants_map;
/** map from universal quantifiers to the list of instantiation constants */
std::map<Node, std::vector<Node> > d_inst_constants;
+ /** The quantifiers attributes class */
+ QuantAttributes d_quantAttr;
};
} // namespace quantifiers
SynthConjecture::SynthConjecture(QuantifiersEngine* qe,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
+ QuantifiersRegistry& qr,
SygusStatistics& s)
: d_qe(qe),
d_qstate(qs),
d_qim(qim),
+ d_qreg(qr),
d_stats(s),
d_tds(qe->getTermDatabaseSygus()),
d_hasSolution(false),
Assert(d_master != nullptr);
}
- Assert(d_qe->getQuantAttributes()->isSygus(q));
+ Assert(d_qreg.getQuantAttributes().isSygus(q));
// if the base instantiation is an existential, store its variables
if (d_base_inst.getKind() == NOT && d_base_inst[0].getKind() == FORALL)
{
SynthConjecture(QuantifiersEngine* qe,
QuantifiersState& qs,
QuantifiersInferenceManager& qim,
+ QuantifiersRegistry& qr,
SygusStatistics& s);
~SynthConjecture();
/** presolve */
QuantifiersState& d_qstate;
/** Reference to the quantifiers inference manager */
QuantifiersInferenceManager& d_qim;
+ /** The quantifiers registry */
+ QuantifiersRegistry& d_qreg;
/** reference to the statistics of parent */
SygusStatistics& d_stats;
/** term database sygus of d_qe */
d_sqp(qe)
{
d_conjs.push_back(std::unique_ptr<SynthConjecture>(
- new SynthConjecture(d_quantEngine, qs, qim, d_statistics)));
+ new SynthConjecture(d_quantEngine, qs, qim, qr, d_statistics)));
d_conj = d_conjs.back().get();
}
// allocate a new synthesis conjecture if not assigned
if (d_conjs.back()->isAssigned())
{
- d_conjs.push_back(std::unique_ptr<SynthConjecture>(
- new SynthConjecture(d_quantEngine, d_qstate, d_qim, d_statistics)));
+ d_conjs.push_back(std::unique_ptr<SynthConjecture>(new SynthConjecture(
+ d_quantEngine, d_qstate, d_qim, d_qreg, d_statistics)));
}
d_conjs.back()->assign(q);
}
{
// take ownership of quantified formulas with sygus attribute, and function
// definitions when options::sygusRecFun is true.
- QuantAttributes* qa = d_quantEngine->getQuantAttributes();
- if (qa->isSygus(q) || (options::sygusRecFun() && qa->isFunDef(q)))
+ QuantAttributes& qa = d_qreg.getQuantAttributes();
+ if (qa.isSygus(q) || (options::sygusRecFun() && qa.isFunDef(q)))
{
d_qreg.setOwner(q, this, 2);
}
{
return;
}
- if (d_quantEngine->getQuantAttributes()->isFunDef(q))
+ if (d_qreg.getQuantAttributes().isFunDef(q))
{
Assert(options::sygusRecFun());
// If it is a recursive function definition, add it to the function
{
if( options::instMaxLevel()!=-1 ){
if( n.hasAttribute(InstLevelAttribute()) ){
- int fml = f.isNull() ? -1 : d_quantEngine->getQuantAttributes()->getQuantInstLevel( f );
+ int64_t fml =
+ f.isNull() ? -1 : d_qreg.getQuantAttributes().getQuantInstLevel(f);
unsigned ml = fml>=0 ? fml : options::instMaxLevel();
if( n.getAttribute(InstLevelAttribute())>ml ){
struct ContainsUConstAttributeId {};
typedef expr::Attribute<ContainsUConstAttributeId, uint64_t> ContainsUConstAttribute;
-//for quantifier instantiation level
+/**
+ * for quantifier instantiation level.
+ */
struct QuantInstLevelAttributeId {};
-typedef expr::Attribute<QuantInstLevelAttributeId, uint64_t> QuantInstLevelAttribute;
+typedef expr::Attribute<QuantInstLevelAttributeId, uint64_t>
+ QuantInstLevelAttribute;
/** Attribute for id number */
struct QuantIdNumAttributeId {};
d_term_db(new quantifiers::TermDb(qstate, qim, d_qreg, this)),
d_eq_query(nullptr),
d_sygus_tdb(nullptr),
- d_quant_attr(new quantifiers::QuantAttributes),
d_instantiate(
new quantifiers::Instantiate(this, qstate, qim, d_qreg, pnm)),
d_skolemize(new quantifiers::Skolemize(this, qstate, pnm)),
{
return d_sygus_tdb.get();
}
-quantifiers::QuantAttributes* QuantifiersEngine::getQuantAttributes() const
-{
- return d_quant_attr.get();
-}
quantifiers::Instantiate* QuantifiersEngine::getInstantiate() const
{
return d_instantiate.get();
{
d_util[i]->registerQuantifier(f);
}
- // compute attributes
- d_quant_attr->computeAttributes(f);
for (QuantifiersModule*& mdl : d_modules)
{
Node QuantifiersEngine::getNameForQuant(Node q) const
{
- Node name = d_quant_attr->getQuantName(q);
- if (!name.isNull())
- {
- return name;
- }
- return q;
+ return d_qreg.getNameForQuant(q);
}
bool QuantifiersEngine::getNameForQuant(Node q, Node& name, bool req) const
{
- name = getNameForQuant(q);
- // if we have a name, or we did not require one
- return name != q || !req;
+ return d_qreg.getNameForQuant(q, name, req);
}
bool QuantifiersEngine::getSynthSolutions(
#include "theory/quantifiers/instantiate.h"
#include "theory/quantifiers/quant_module.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"
quantifiers::TermDb* getTermDatabase() const;
/** get term database sygus */
quantifiers::TermDbSygus* getTermDatabaseSygus() const;
- /** get quantifiers attributes */
- quantifiers::QuantAttributes* getQuantAttributes() const;
/** get instantiate utility */
quantifiers::Instantiate* getInstantiate() const;
/** get skolemize utility */
std::unique_ptr<quantifiers::EqualityQueryQuantifiersEngine> d_eq_query;
/** sygus term database */
std::unique_ptr<quantifiers::TermDbSygus> d_sygus_tdb;
- /** quantifiers attributes */
- std::unique_ptr<quantifiers::QuantAttributes> d_quant_attr;
/** instantiate utility */
std::unique_ptr<quantifiers::Instantiate> d_instantiate;
/** skolemize utility */