Fix performance issue with variable triggers + instantiation restrictions.
authorajreynol <andrew.j.reynolds@gmail.com>
Thu, 9 Apr 2015 10:43:37 +0000 (12:43 +0200)
committerajreynol <andrew.j.reynolds@gmail.com>
Thu, 9 Apr 2015 10:43:37 +0000 (12:43 +0200)
src/theory/quantifiers/candidate_generator.cpp
src/theory/quantifiers/instantiation_engine.cpp
src/theory/quantifiers_engine.cpp

index 7d2544b6f75efd77da598098de1aadf65c50e694..48041e89456ffc6c52f3dcaabe8e85dd8b6240cd 100644 (file)
@@ -202,12 +202,18 @@ Node CandidateGeneratorQEAll::getNextCandidate() {
     if( n.getType().isSubtypeOf( d_match_pattern_type ) ){
       TNode nh = d_qe->getTermDatabase()->getEligibleTermInEqc( n );
       if( !nh.isNull() ){
-        if( options::instMaxLevel()!=-1 ){
+        if( options::instMaxLevel()!=-1 || options::lteRestrictInstClosure() ){
           nh = d_qe->getEqualityQuery()->getInternalRepresentative( nh, d_f, d_index );
+          //don't consider this if already the instantiation is ineligible
+          if( !d_qe->getTermDatabase()->isTermEligibleForInstantiation( nh, d_f, false ) ){
+            nh = Node::null();
+          }
+        }
+        if( !nh.isNull() ){
+          d_firstTime = false;
+          //an equivalence class with the same type as the pattern, return it
+          return nh;
         }
-        d_firstTime = false;
-        //an equivalence class with the same type as the pattern, return it
-        return nh;
       }
     }
   }
index ea3e18be12cb4dd66598326c8b20bd646dfb1c2b..3b31bad1312a8c380c064e2baf1754b440f64079 100644 (file)
@@ -140,6 +140,7 @@ bool InstantiationEngine::doInstantiationRound( Theory::Effort effort ){
         //int e_use = d_quantEngine->getRelevance( f )==-1 ? e - 1 : e;
         int e_use = e;
         if( e_use>=0 ){
+          Trace("inst-engine-debug") << "inst-engine : " << f << std::endl;
           //check each instantiation strategy
           for( size_t i=0; i<d_instStrategies.size(); ++i ){
             InstStrategy* is = d_instStrategies[i];
index ba75af8730cc2bb923d8ec053519499902a11e1d..8dec3898cbb0047bf284a4cc13ee5f7aa0e35cf1 100644 (file)
@@ -991,8 +991,14 @@ eq::EqualityEngine* QuantifiersEngine::getMasterEqualityEngine(){
 void QuantifiersEngine::debugPrintEqualityEngine( const char * c ) {
   eq::EqualityEngine* ee = getMasterEqualityEngine();
   eq::EqClassesIterator eqcs_i = eq::EqClassesIterator( ee );
+  std::map< TypeNode, int > typ_num;
   while( !eqcs_i.isFinished() ){
     TNode r = (*eqcs_i);
+    TypeNode tr = r.getType();
+    if( typ_num.find( tr )==typ_num.end() ){
+      typ_num[tr] = 0;
+    }
+    typ_num[tr]++;
     bool firstTime = true;
     Trace(c) << "  " << r;
     Trace(c) << " : { ";
@@ -1013,6 +1019,9 @@ void QuantifiersEngine::debugPrintEqualityEngine( const char * c ) {
     ++eqcs_i;
   }
   Trace(c) << std::endl;
+  for( std::map< TypeNode, int >::iterator it = typ_num.begin(); it != typ_num.end(); ++it ){
+    Trace(c) << "# eqc for " << it->first << " : " << it->second << std::endl;    
+  }
 }
 
 void EqualityQueryQuantifiersEngine::reset(){