for( int i=0; i<getNumVars(); i++ ){
//std::map< int, TNode >::iterator it = d_match.find( i );
if( !d_match[i].isNull() ){
- if( !getCurrentCanBeEqual( p, i, d_match[i], p->d_effort==QuantConflictFind::effort_conflict ) ){
+ if (!getCurrentCanBeEqual(p, i, d_match[i], p->atConflictEffort())) {
return true;
}
}
bool QuantInfo::isTConstraintSpurious( QuantConflictFind * p, std::vector< Node >& terms ) {
if( options::qcfEagerTest() ){
//check whether the instantiation evaluates as expected
- if( p->d_effort==QuantConflictFind::effort_conflict ){
+ if (p->atConflictEffort()) {
Trace("qcf-instance-check") << "Possible conflict instance for " << d_q << " : " << std::endl;
std::map< TNode, TNode > subs;
for( unsigned i=0; i<terms.size(); i++ ){
Node cons =
p->getTermUtil()->substituteBoundVariables(it->first, d_q, terms);
cons = it->second ? cons : cons.negate();
- if( !entailmentTest( p, cons, p->d_effort==QuantConflictFind::effort_conflict ) ){
+ if (!entailmentTest(p, cons, p->atConflictEffort())) {
return true;
}
}
if( slv_v==-1 ){
Trace("qcf-tconstraint-debug") << "...will solve for var #" << vn << std::endl;
slv_v = vn;
- if( p->d_effort!=QuantConflictFind::effort_conflict ){
+ if (!p->atConflictEffort()) {
break;
}
}else{
if( v==d_vars[index] ){
sum = lhs;
}else{
- if( p->d_effort==QuantConflictFind::effort_conflict ){
+ if (p->atConflictEffort()) {
Kind kn = k;
if( d_vars[index].getKind()==PLUS ){
kn = MINUS;
if( d_tgt ){
success = p->areMatchEqual( nn[0], nn[1] );
}else{
- if( p->d_effort==QuantConflictFind::effort_conflict ){
+ if (p->atConflictEffort()) {
success = p->areDisequal( nn[0], nn[1] );
}else{
success = p->areMatchDisequal( nn[0], nn[1] );
}else{
if( d_tgt && d_n.getKind()==FORALL ){
//fail
- }else if( d_n.getKind()==FORALL && p->d_effort==QuantConflictFind::effort_conflict && !options::qcfNestedConflict() ){
+ } else if (d_n.getKind() == FORALL && p->atConflictEffort() &&
+ !options::qcfNestedConflict()) {
//fail
}else{
//reset the first child to d_tgt
return true;
}
-
-QuantConflictFind::QuantConflictFind( QuantifiersEngine * qe, context::Context* c ) :
-QuantifiersModule( qe ),
-d_conflict( c, false ) {
- d_fid_count = 0;
- d_true = NodeManager::currentNM()->mkConst<bool>(true);
- d_false = NodeManager::currentNM()->mkConst<bool>(false);
-}
+QuantConflictFind::QuantConflictFind(QuantifiersEngine* qe, context::Context* c)
+ : QuantifiersModule(qe),
+ d_conflict(c, false),
+ d_true(NodeManager::currentNM()->mkConst<bool>(true)),
+ d_false(NodeManager::currentNM()->mkConst<bool>(false)),
+ d_effort(EFFORT_INVALID),
+ d_needs_computeRelEqr() {}
Node QuantConflictFind::mkEqNode( Node a, Node b ) {
return a.eqNode( b );
}
}
-short QuantConflictFind::getMaxQcfEffort() {
- if( options::qcfMode()==QCF_CONFLICT_ONLY ){
- return effort_conflict;
- }else if( options::qcfMode()==QCF_PROP_EQ || options::qcfMode()==QCF_PARTIAL ){
- return effort_prop_eq;
- }else{
- return 0;
- }
-}
-
bool QuantConflictFind::areMatchEqual( TNode n1, TNode n2 ) {
//if( d_effort==QuantConflictFind::effort_mc ){
// return n1==n2 || !areDisequal( n1, n2 );
}
bool QuantConflictFind::areMatchDisequal( TNode n1, TNode n2 ) {
- //if( d_effort==QuantConflictFind::effort_conflict ){
+ // if( d_effort==QuantConflictFind::Effort::Conflict ){
// return areDisequal( n1, n2 );
//}else{
return n1!=n2;
}
}
+namespace {
+
+// Returns the beginning of a range of efforts. The range can be iterated
+// through as unsigned using operator++.
+inline QuantConflictFind::Effort QcfEffortStart() {
+ return QuantConflictFind::EFFORT_CONFLICT;
+}
+
+// Returns the beginning of a range of efforts. The value returned is included
+// in the range.
+inline QuantConflictFind::Effort QcfEffortEnd() {
+ switch (options::qcfMode()) {
+ case QCF_PROP_EQ:
+ case QCF_PARTIAL:
+ return QuantConflictFind::EFFORT_PROP_EQ;
+ case QCF_CONFLICT_ONLY:
+ default:
+ return QuantConflictFind::EFFORT_PROP_EQ;
+ }
+}
+
+} // namespace
+
/** check */
void QuantConflictFind::check(Theory::Effort level, QEffort quant_e)
{
debugPrint("qcf-debug");
Trace("qcf-debug") << std::endl;
}
- short end_e = getMaxQcfEffort();
bool isConflict = false;
- for( short e = effort_conflict; e<=end_e; e++ ){
- d_effort = e;
+ for (unsigned e = QcfEffortStart(), end = QcfEffortEnd(); e <= end; ++e) {
+ d_effort = static_cast<Effort>(e);
Trace("qcf-check") << "Checking quantified formulas at effort " << e << "..." << std::endl;
for( unsigned i=0; i<d_quantEngine->getModel()->getNumAssertedQuantifiers(); i++ ){
Node q = d_quantEngine->getModel()->getAssertedQuantifier( i, true );
Node inst = d_quantEngine->getInstantiation( q, terms );
Debug("qcf-check-inst") << "Check instantiation " << inst << "..." << std::endl;
Assert( !getTermDatabase()->isEntailed( inst, true ) );
- Assert( getTermDatabase()->isEntailed( inst, false ) || e>effort_conflict );
+ Assert(getTermDatabase()->isEntailed(inst, false) ||
+ e > EFFORT_CONFLICT);
}
if( d_quantEngine->addInstantiation( q, terms ) ){
Trace("qcf-check") << " ... Added instantiation" << std::endl;
qi->debugPrintMatch("qcf-inst");
Trace("qcf-inst") << std::endl;
++addedLemmas;
- if( e==effort_conflict ){
+ if (e == EFFORT_CONFLICT) {
d_quantEngine->markRelevant( q );
++(d_quantEngine->d_statistics.d_instantiations_qcf);
if( options::qcfAllConflict() ){
d_conflict.set( true );
}
break;
- }else if( e==effort_prop_eq ){
+ } else if (e == EFFORT_PROP_EQ) {
d_quantEngine->markRelevant( q );
++(d_quantEngine->d_statistics.d_instantiations_qcf);
}
double clSet2 = double(clock())/double(CLOCKS_PER_SEC);
Trace("qcf-engine") << "Finished conflict find engine, time = " << (clSet2-clSet);
if( addedLemmas>0 ){
- Trace("qcf-engine") << ", effort = " << ( d_effort==effort_conflict ? "conflict" : ( d_effort==effort_prop_eq ? "prop_eq" : "mc" ) );
+ Trace("qcf-engine")
+ << ", effort = "
+ << (d_effort == EFFORT_CONFLICT
+ ? "conflict"
+ : (d_effort == EFFORT_PROP_EQ ? "prop_eq" : "mc"));
Trace("qcf-engine") << ", addedLemmas = " << addedLemmas;
}
Trace("qcf-engine") << std::endl;
}
}
+std::ostream& operator<<(std::ostream& os, const QuantConflictFind::Effort& e) {
+ switch (e) {
+ case QuantConflictFind::EFFORT_INVALID:
+ os << "Invalid";
+ break;
+ case QuantConflictFind::EFFORT_CONFLICT:
+ os << "Conflict";
+ break;
+ case QuantConflictFind::EFFORT_PROP_EQ:
+ os << "PropEq";
+ break;
+ }
+ return os;
+}
+
} /* namespace CVC4::theory::quantifiers */
} /* namespace CVC4::theory */
} /* namespace CVC4 */
#ifndef QUANT_CONFLICT_FIND
#define QUANT_CONFLICT_FIND
+#include <ostream>
+#include <vector>
+
#include "context/cdhashmap.h"
#include "context/cdchunk_list.h"
#include "theory/quantifiers_engine.h"
void setIrrelevantFunction( TNode f );
private:
std::map< Node, Node > d_op_node;
- int d_fid_count;
std::map< Node, int > d_fid;
Node mkEqNode( Node a, Node b );
public: //for ground terms
private: //for equivalence classes
// type -> list(eqc)
std::map< TypeNode, std::vector< TNode > > d_eqcs;
-public:
- enum {
- effort_conflict,
- effort_prop_eq,
+
+ public:
+ enum Effort : unsigned {
+ EFFORT_CONFLICT,
+ EFFORT_PROP_EQ,
+ EFFORT_INVALID,
};
- short d_effort;
- void setEffort( int e ) { d_effort = e; }
- static short getMaxQcfEffort();
+ void setEffort(Effort e) { d_effort = e; }
+
+ inline bool atConflictEffort() const {
+ return d_effort == QuantConflictFind::EFFORT_CONFLICT;
+ }
+
+ private:
+ Effort d_effort;
+
+ public:
bool areMatchEqual( TNode n1, TNode n2 );
bool areMatchDisequal( TNode n1, TNode n2 );
public:
std::string identify() const { return "QcfEngine"; }
};
+std::ostream& operator<<(std::ostream& os, const QuantConflictFind::Effort& e);
+
} /* namespace CVC4::theory::quantifiers */
} /* namespace CVC4::theory */
} /* namespace CVC4 */