More optimizations for quantifiers conflict find. Add trust user patterns mode.
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Fri, 17 Jan 2014 15:57:12 +0000 (09:57 -0600)
committerAndrew Reynolds <andrew.j.reynolds@gmail.com>
Fri, 17 Jan 2014 15:57:26 +0000 (09:57 -0600)
src/theory/quantifiers/inst_strategy_e_matching.cpp
src/theory/quantifiers/instantiation_engine.cpp
src/theory/quantifiers/modes.h
src/theory/quantifiers/options
src/theory/quantifiers/options_handlers.h
src/theory/quantifiers/quant_conflict_find.cpp
src/theory/quantifiers/quant_conflict_find.h

index ef81d55a1be0163084da79fe7858cc89e229a644..9acdf61522815c492c584bf7ac1d39698c60f1e9 100644 (file)
@@ -123,68 +123,71 @@ void InstStrategyAutoGenTriggers::processResetInstantiationRound( Theory::Effort
 }
 
 int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){
-  int peffort = f.getNumChildren()==3 ? 2 : 1;
-  //int peffort = f.getNumChildren()==3 ? 2 : 1;
-  //int peffort = 1;
-  if( e<peffort ){
-    return STATUS_UNFINISHED;
+  if( f.getNumChildren()==3 && options::userPatternsQuant()==USER_PAT_MODE_TRUST ){
+    return STATUS_UNKNOWN;
   }else{
-    int status = STATUS_UNKNOWN;
-    bool gen = false;
-    if( e==peffort ){
-      if( d_counter.find( f )==d_counter.end() ){
-        d_counter[f] = 0;
-        gen = true;
+    int peffort = f.getNumChildren()==3 ? 2 : 1;
+    //int peffort = 1;
+    if( e<peffort ){
+      return STATUS_UNFINISHED;
+    }else{
+      int status = STATUS_UNKNOWN;
+      bool gen = false;
+      if( e==peffort ){
+        if( d_counter.find( f )==d_counter.end() ){
+          d_counter[f] = 0;
+          gen = true;
+        }else{
+          d_counter[f]++;
+          gen = d_regenerate && d_counter[f]%d_regenerate_frequency==0;
+        }
       }else{
-        d_counter[f]++;
-        gen = d_regenerate && d_counter[f]%d_regenerate_frequency==0;
+        gen = true;
       }
-    }else{
-      gen = true;
-    }
-    if( gen ){
-      generateTriggers( f, effort, e, status );
-      if( d_auto_gen_trigger[f].empty() && f.getNumChildren()==2 ){
-        Trace("no-trigger") << "Could not find trigger for " << f << std::endl;
+      if( gen ){
+        generateTriggers( f, effort, e, status );
+        if( d_auto_gen_trigger[f].empty() && f.getNumChildren()==2 ){
+          Trace("no-trigger") << "Could not find trigger for " << f << std::endl;
+        }
       }
-    }
 
-    //if( e==4 ){
-    //  d_processed_trigger.clear();
-    //  d_quantEngine->getEqualityQuery()->setLiberal( true );
-    //}
-    Debug("quant-uf-strategy")  << "Try auto-generated triggers... " << d_tr_strategy << " " << e << std::endl;
-    //Notice() << "Try auto-generated triggers..." << std::endl;
-    for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[f].begin(); itt != d_auto_gen_trigger[f].end(); ++itt ){
-      Trigger* tr = itt->first;
-      if( tr ){
-        bool processTrigger = itt->second;
-        if( processTrigger && d_processed_trigger[f].find( tr )==d_processed_trigger[f].end() ){
-          d_processed_trigger[f][tr] = true;
-          //if( tr->isMultiTrigger() )
-            Trace("process-trigger") << "  Process " << (*tr) << "..." << std::endl;
-          InstMatch baseMatch;
-          int numInst = tr->addInstantiations( baseMatch );
-          //if( tr->isMultiTrigger() )
-            Trace("process-trigger") << "  Done, numInst = " << numInst << "." << std::endl;
-          if( d_tr_strategy==Trigger::TS_MIN_TRIGGER ){
-            d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen_min += numInst;
-          }else{
-            d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen += numInst;
-          }
-          if( tr->isMultiTrigger() ){
-            d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst;
+      //if( e==4 ){
+      //  d_processed_trigger.clear();
+      //  d_quantEngine->getEqualityQuery()->setLiberal( true );
+      //}
+      Debug("quant-uf-strategy")  << "Try auto-generated triggers... " << d_tr_strategy << " " << e << std::endl;
+      //Notice() << "Try auto-generated triggers..." << std::endl;
+      for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[f].begin(); itt != d_auto_gen_trigger[f].end(); ++itt ){
+        Trigger* tr = itt->first;
+        if( tr ){
+          bool processTrigger = itt->second;
+          if( processTrigger && d_processed_trigger[f].find( tr )==d_processed_trigger[f].end() ){
+            d_processed_trigger[f][tr] = true;
+            //if( tr->isMultiTrigger() )
+              Trace("process-trigger") << "  Process " << (*tr) << "..." << std::endl;
+            InstMatch baseMatch;
+            int numInst = tr->addInstantiations( baseMatch );
+            //if( tr->isMultiTrigger() )
+              Trace("process-trigger") << "  Done, numInst = " << numInst << "." << std::endl;
+            if( d_tr_strategy==Trigger::TS_MIN_TRIGGER ){
+              d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen_min += numInst;
+            }else{
+              d_quantEngine->getInstantiationEngine()->d_statistics.d_instantiations_auto_gen += numInst;
+            }
+            if( tr->isMultiTrigger() ){
+              d_quantEngine->d_statistics.d_multi_trigger_instantiations += numInst;
+            }
+            //d_quantEngine->d_hasInstantiated[f] = true;
           }
-          //d_quantEngine->d_hasInstantiated[f] = true;
         }
       }
+      //if( e==4 ){
+      //  d_quantEngine->getEqualityQuery()->setLiberal( false );
+      //}
+      Debug("quant-uf-strategy") << "done." << std::endl;
+      //Notice() << "done" << std::endl;
+      return status;
     }
-    //if( e==4 ){
-    //  d_quantEngine->getEqualityQuery()->setLiberal( false );
-    //}
-    Debug("quant-uf-strategy") << "done." << std::endl;
-    //Notice() << "done" << std::endl;
-    return status;
   }
 }
 
index fa7b4e342f4a54e7bca6966952a74513c3d9674f..e3ed8d0e0ff295f6d5690297424cc490cdc60b71 100644 (file)
@@ -42,7 +42,7 @@ void InstantiationEngine::finishInit(){
     //  addInstStrategy( new InstStrategyCheckCESolved( this, d_quantEngine ) );
     //}
     //these are the instantiation strategies for basic E-matching
-    if( options::userPatternsQuant() ){
+    if( options::userPatternsQuant()!=USER_PAT_MODE_IGNORE ){
       d_isup = new InstStrategyUserPatterns( d_quantEngine );
       addInstStrategy( d_isup );
     }else{
index 7a7ce9b5400ca440cf060e6ef34c5241a6823bcd..4eb12c98d273c8b0c928c270c99fb1a069e98ae1 100644 (file)
@@ -75,10 +75,19 @@ typedef enum {
   QCF_WHEN_MODE_DEFAULT,
   /** apply at standard effort */
   QCF_WHEN_MODE_STD,
-  /** default */
+  /** apply based on heuristics */
   QCF_WHEN_MODE_STD_H,
 } QcfWhenMode;
 
+typedef enum {
+  /** default, use but do not trust */
+  USER_PAT_MODE_DEFAULT,
+  /** if patterns are supplied for a quantifier, use only those */
+  USER_PAT_MODE_TRUST,
+  /** ignore user patterns */
+  USER_PAT_MODE_IGNORE,
+} UserPatMode;
+
 }/* CVC4::theory::quantifiers namespace */
 }/* CVC4::theory namespace */
 
index dc016be3f3751a565887ca2c5f26fa9c5b077ffa..4a853b6cdbd4d0d22a44784cc943b14491fa37e7 100644 (file)
@@ -82,8 +82,8 @@ option cbqi --enable-cbqi bool :default false
 option recurseCbqi --cbqi-recurse bool :default false
  turns on recursive counterexample-based quantifier instantiation
 
-option userPatternsQuant /--ignore-user-patterns bool :default true
ignore user-provided patterns for quantifier instantiation
+option userPatternsQuant --user-pat=MODE CVC4::theory::quantifiers::UserPatMode :default CVC4::theory::quantifiers::USER_PAT_MODE_DEFAULT :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToUserPatMode :handler-include "theory/quantifiers/options_handlers.h"
policy for handling user-provided patterns for quantifier instantiation
 
 option flipDecision --flip-decision/ bool :default false
  turns on flip decision heuristic
index e0b1e30e8732bd4b782c36777849010b6728422d..5bd710a79d63889d7b0127ac53b25261bdf09bc1 100644 (file)
@@ -110,7 +110,20 @@ std-h \n\
 + Apply conflict finding at standard effort when heuristic says to. \n\
 \n\
 ";
-
+static const std::string userPatModeHelp = "\
+User pattern modes currently supported by the --user-pat option:\n\
+\n\
+default \n\
++ Default, use both user-provided and auto-generated patterns when patterns\n\
+  are provided for a quantified formula.\n\
+\n\
+trust \n\
++ When provided, use only user-provided patterns for a quantified formula.\n\
+\n\
+ignore \n\
++ Ignore user-provided patterns. \n\
+\n\
+";
 inline InstWhenMode stringToInstWhenMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) {
   if(optarg == "pre-full") {
     return INST_WHEN_PRE_FULL;
@@ -215,6 +228,21 @@ inline QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg, S
   }
 }
 
+inline UserPatMode stringToUserPatMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) {
+  if(optarg ==  "default") {
+    return USER_PAT_MODE_DEFAULT;
+  } else if(optarg == "trust") {
+    return USER_PAT_MODE_TRUST;
+  } else if(optarg == "ignore") {
+    return USER_PAT_MODE_IGNORE;
+  } else if(optarg ==  "help") {
+    puts(userPatModeHelp.c_str());
+    exit(1);
+  } else {
+    throw OptionException(std::string("unknown option for --user-pat: `") +
+                          optarg + "'.  Try --user-pat help.");
+  }
+}
 }/* CVC4::theory::quantifiers namespace */
 }/* CVC4::theory namespace */
 }/* CVC4 namespace */
index d7111ea39485ce53dd8b139c851cf6e1e211a0f3..4cb62b5234c9d0d459d62f62af0d1c23ac9fc686 100755 (executable)
@@ -27,53 +27,7 @@ using namespace std;
 \r
 namespace CVC4 {\r
 \r
-/*\r
-Node QcfNodeIndex::existsTerm( QuantConflictFind * qcf, Node n, int index ) {\r
-  if( index==(int)n.getNumChildren() ){\r
-    if( d_children.empty() ){\r
-      return Node::null();\r
-    }else{\r
-      return d_children.begin()->first;\r
-    }\r
-  }else{\r
-    Node r = qcf->getRepresentative( n[index] );\r
-    if( d_children.find( r )==d_children.end() ){\r
-      return n;\r
-    }else{\r
-      return d_children[r].existsTerm( qcf, n, index+1 );\r
-    }\r
-  }\r
-}\r
-\r
-\r
-Node QcfNodeIndex::addTerm( QuantConflictFind * qcf, Node n, int index ) {\r
-  if( index==(int)n.getNumChildren() ){\r
-    if( d_children.empty() ){\r
-      d_children[ n ].clear();\r
-      return n;\r
-    }else{\r
-      return d_children.begin()->first;\r
-    }\r
-  }else{\r
-    Node r = qcf->getRepresentative( n[index] );\r
-    return d_children[r].addTerm( qcf, n, index+1 );\r
-  }\r
-}\r
-\r
-bool QcfNodeIndex::addTermEq( QuantConflictFind * qcf, Node n1, Node n2, int index ) {\r
-  if( index==(int)n1.getNumChildren() ){\r
-    Node n = addTerm( qcf, n2 );\r
-    return n==n2;\r
-  }else{\r
-    Node r = qcf->getRepresentative( n1[index] );\r
-    return d_children[r].addTermEq( qcf, n1, n2, index+1 );\r
-  }\r
-}\r
-*/\r
-\r
-\r
-\r
-Node QcfNodeIndex::existsTerm( Node n, std::vector< Node >& reps, int index ) {\r
+Node QcfNodeIndex::existsTerm( TNode n, std::vector< TNode >& reps, int index ) {\r
   if( index==(int)reps.size() ){\r
     if( d_children.empty() ){\r
       return Node::null();\r
@@ -89,7 +43,7 @@ Node QcfNodeIndex::existsTerm( Node n, std::vector< Node >& reps, int index ) {
   }\r
 }\r
 \r
-Node QcfNodeIndex::addTerm( Node n, std::vector< Node >& reps, int index ) {\r
+Node QcfNodeIndex::addTerm( TNode n, std::vector< TNode >& reps, int index ) {\r
   if( index==(int)reps.size() ){\r
     if( d_children.empty() ){\r
       d_children[ n ].clear();\r
@@ -102,7 +56,7 @@ Node QcfNodeIndex::addTerm( Node n, std::vector< Node >& reps, int index ) {
   }\r
 }\r
 \r
-bool QcfNodeIndex::addTermEq( Node n1, Node n2, std::vector< Node >& reps1, std::vector< Node >& reps2, int index ) {\r
+bool QcfNodeIndex::addTermEq( TNode n1, TNode n2, std::vector< TNode >& reps1, std::vector< TNode >& reps2, int index ) {\r
   if( index==(int)reps1.size() ){\r
     Node n = addTerm( n2, reps2 );\r
     return n==n2;\r
@@ -114,7 +68,7 @@ bool QcfNodeIndex::addTermEq( Node n1, Node n2, std::vector< Node >& reps1, std:
 \r
 \r
 void QcfNodeIndex::debugPrint( const char * c, int t ) {\r
-  for( std::map< Node, QcfNodeIndex >::iterator it = d_children.begin(); it != d_children.end(); ++it ){\r
+  for( std::map< TNode, QcfNodeIndex >::iterator it = d_children.begin(); it != d_children.end(); ++it ){\r
     if( !it->first.isNull() ){\r
       for( int j=0; j<t; j++ ){ Trace(c) << "  "; }\r
       Trace(c) << it->first << " : " << std::endl;\r
@@ -159,8 +113,8 @@ int QuantConflictFind::getFunctionId( Node f ) {
 }\r
 \r
 bool QuantConflictFind::isLessThan( Node a, Node b ) {\r
-  Assert( a.getKind()==APPLY_UF );\r
-  Assert( b.getKind()==APPLY_UF );\r
+  //Assert( a.getKind()==APPLY_UF );\r
+  //Assert( b.getKind()==APPLY_UF );\r
   /*\r
   if( a.getOperator()==b.getOperator() ){\r
     for( unsigned i=0; i<a.getNumChildren(); i++ ){\r
@@ -175,14 +129,16 @@ bool QuantConflictFind::isLessThan( Node a, Node b ) {
     return false;\r
   }else{\r
     */\r
-  return getFunctionId( a.getOperator() )<getFunctionId( b.getOperator() );\r
+  return getFunctionId( a )<getFunctionId( b );\r
   //}\r
 }\r
 \r
-Node QuantConflictFind::getFunction( Node n, bool isQuant ) {\r
+Node QuantConflictFind::getFunction( Node n, int& index, bool isQuant ) {\r
   if( isQuant && !quantifiers::TermDb::hasBoundVarAttr( n ) ){\r
+    index = 0;\r
     return n;\r
-  }else if( n.getKind()==APPLY_UF ){\r
+  }else if( isHandledUfTerm( n ) ){\r
+    /*\r
     std::map< Node, Node >::iterator it = d_op_node.find( n.getOperator() );\r
     if( it==d_op_node.end() ){\r
       std::vector< Node > children;\r
@@ -190,14 +146,15 @@ Node QuantConflictFind::getFunction( Node n, bool isQuant ) {
       for( unsigned i=0; i<n.getNumChildren(); i++ ){\r
         children.push_back( getFv( n[i].getType() ) );\r
       }\r
-      Node nn = NodeManager::currentNM()->mkNode( APPLY_UF, children );\r
+      Node nn = NodeManager::currentNM()->mkNode( n.getKind(), children );\r
       d_op_node[n.getOperator()] = nn;\r
       return nn;\r
     }else{\r
       return it->second;\r
-    }\r
+    }*/\r
+    index = 1;\r
+    return n.getOperator();\r
   }else{\r
-    //should be a variable\r
     return Node::null();\r
   }\r
 }\r
@@ -344,26 +301,29 @@ EqRegistry * QuantConflictFind::getEqRegistry( bool polarity, Node lit, bool doC
   int i;\r
   Node f1;\r
   Node f2;\r
+  int f1Index;\r
+  int f2Index;\r
   if( lit.getKind()==EQUAL ){\r
     i = polarity ? 0 : 1;\r
-    f1 = getFunction( lit[0], true );\r
-    f2 = getFunction( lit[1], true );\r
+    f1 = getFunction( lit[0], f1Index, true );\r
+    f2 = getFunction( lit[1], f2Index, true );\r
   }else if( lit.getKind()==APPLY_UF ){\r
     i = 0;\r
-    f1 = getFunction( lit, true );\r
+    f1 = getFunction( lit, f1Index, true );\r
     f2 = polarity ? d_true : d_false;\r
+    f2Index = 0;\r
   }\r
   if( !f1.isNull() && !f2.isNull() ){\r
-    if( d_eqr[i][f1].find( f2 )==d_eqr[i][f1].end() ){\r
+    if( d_eqr[i][f1Index][f1][f2Index].find( f2 )==d_eqr[i][f1Index][f1][f2Index].end() ){\r
       if( doCreate ){\r
-        Trace("qcf-register") << "RegisterEqr : " << f1 << " " << f2 << ", polarity = " << (i==0) << std::endl;\r
-        d_eqr[i][f1][f2] = new EqRegistry( d_c );\r
-        d_eqr[i][f2][f1] = d_eqr[i][f1][f2];\r
+        Trace("qcf-register") << "RegisterEqr : " << f1 << " " << f2 << ", polarity = " << (i==0) << ", indices : " << f1Index << " " << f2Index << std::endl;\r
+        d_eqr[i][f1Index][f1][f2Index][f2] = new EqRegistry( d_c );\r
+        d_eqr[i][f2Index][f2][f1Index][f1] = d_eqr[i][f1Index][f1][f2Index][f2];\r
       }else{\r
         return NULL;\r
       }\r
     }\r
-    return d_eqr[i][f1][f2];\r
+    return d_eqr[i][f1Index][f1][f2Index][f2];\r
   }else{\r
     return NULL;\r
   }\r
@@ -372,7 +332,6 @@ EqRegistry * QuantConflictFind::getEqRegistry( bool polarity, Node lit, bool doC
 void QuantConflictFind::getEqRegistryApps( Node lit, std::vector< Node >& terms ) {\r
   Assert( quantifiers::TermDb::hasBoundVarAttr( lit ) );\r
   if( lit.getKind()==EQUAL ){\r
-    bool allUf = false;\r
     for( unsigned i=0; i<2; i++ ){\r
       if( quantifiers::TermDb::hasBoundVarAttr( lit[i] ) ){\r
         if( lit[i].getKind()==BOUND_VARIABLE ){\r
@@ -380,12 +339,11 @@ void QuantConflictFind::getEqRegistryApps( Node lit, std::vector< Node >& terms
           terms.clear();\r
           return;\r
         }else{\r
-          allUf = allUf && lit[i].getKind()==APPLY_UF;\r
           terms.push_back( lit[i] );\r
         }\r
       }\r
     }\r
-    if( terms.size()==2 && allUf && isLessThan( terms[1], terms[0] ) ){\r
+    if( terms.size()==2 && isLessThan( terms[1].getOperator(), terms[0].getOperator() ) ){\r
       Node t = terms[0];\r
       terms[0] = terms[1];\r
       terms[1] = t;\r
@@ -406,7 +364,7 @@ int QuantConflictFind::evaluate( Node n ) {
     }else if( areDisequal( n1, n2 ) ){\r
       ret = -1;\r
     }\r
-  }else if( n.getKind()==APPLY_UF ){\r
+  }else if( n.getKind()==APPLY_UF ){  //predicate\r
     Node nn = getTerm( n );\r
     Debug("qcf-eval") << "Evaluate : Normalize " << nn << " to " << n << std::endl;\r
     if( areEqual( nn, d_true ) ){\r
@@ -498,7 +456,7 @@ Node QuantConflictFind::getRepresentative( Node n ) {
   }\r
 }\r
 Node QuantConflictFind::getTerm( Node n ) {\r
-  if( n.getKind()==APPLY_UF ){\r
+  if( isHandledUfTerm( n ) ){\r
     computeArgReps( n );\r
     Node nn = d_uf_terms[n.getOperator()].existsTerm( n, d_arg_reps[n] );\r
     if( !nn.isNull() ){\r
@@ -626,9 +584,11 @@ void QuantConflictFind::check( Theory::Effort level ) {
       Trace("qcf-check") << "Compute relevant equalities..." << std::endl;\r
       computeRelevantEqr();\r
 \r
-      Trace("qcf-debug") << std::endl;\r
-      debugPrint("qcf-debug");\r
-      Trace("qcf-debug") << std::endl;\r
+      if( Trace.isOn("qcf-debug") ){\r
+        Trace("qcf-debug") << std::endl;\r
+        debugPrint("qcf-debug");\r
+        Trace("qcf-debug") << std::endl;\r
+      }\r
 \r
 \r
       Trace("qcf-check") << "Checking quantified formulas..." << std::endl;\r
@@ -714,9 +674,13 @@ bool QuantConflictFind::needsCheck( Theory::Effort level ) {
 void QuantConflictFind::computeRelevantEqr() {\r
   //first, reset information\r
   for( unsigned i=0; i<2; i++ ){\r
-    for( std::map< Node, std::map< Node, EqRegistry * > >::iterator it = d_eqr[i].begin(); it != d_eqr[i].end(); ++it ){\r
-      for( std::map< Node, EqRegistry * >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){\r
-        it2->second->clear();\r
+    for( unsigned j=0; j<2; j++ ){\r
+      for( std::map< TNode, std::map< int, std::map< TNode, EqRegistry * > > >::iterator it = d_eqr[i][j].begin(); it != d_eqr[i][j].end(); ++it ){\r
+        for( unsigned jj=0; jj<2; jj++ ){\r
+          for( std::map< TNode, EqRegistry * >::iterator it2 = it->second[jj].begin(); it2 != it->second[jj].end(); ++it2 ){\r
+            it2->second->clear();\r
+          }\r
+        }\r
       }\r
     }\r
   }\r
@@ -724,14 +688,28 @@ void QuantConflictFind::computeRelevantEqr() {
   d_eqc_uf_terms.clear();\r
   d_eqcs.clear();\r
   d_arg_reps.clear();\r
+  double clSet = 0;\r
+  if( Trace.isOn("qcf-opt") ){\r
+    clSet = double(clock())/double(CLOCKS_PER_SEC);\r
+  }\r
+\r
+  long nTermst = 0;\r
+  long nTerms = 0;\r
+  long nEqc = 0;\r
+  long nEq1 = 0;\r
+  long nEq2 = 0;\r
+  long nEq1t = 0;\r
+  long nEq2t = 0;\r
+  long nComp = 0;\r
+  //relevant nodes for eq registries\r
+  std::map< TNode, std::map< TNode, std::vector< TNode > > > eqr_to_node[2];\r
 \r
   //which nodes are irrelevant for disequality matches\r
-  std::map< Node, bool > irrelevant_dnode;\r
-  //which eqc we have processed\r
-  std::map< Node, bool > process_eqc;\r
+  std::map< TNode, bool > irrelevant_dnode;\r
   //now, store matches\r
   eq::EqClassesIterator eqcs_i = eq::EqClassesIterator( getEqualityEngine() );\r
   while( !eqcs_i.isFinished() ){\r
+    nEqc++;\r
     Node r = (*eqcs_i);\r
     d_eqcs[r.getType()].push_back( r );\r
     EqcInfo * eqcir = getEqcInfo( r, false );\r
@@ -740,18 +718,12 @@ void QuantConflictFind::computeRelevantEqr() {
     if( eqcir ){\r
       for( NodeBoolMap::iterator it = eqcir->d_diseq.begin(); it != eqcir->d_diseq.end(); ++it ){\r
         if( (*it).second ){\r
-          Node rd = (*it).first;\r
-          //if we have processed the other direction\r
-          if( process_eqc.find( rd )!=process_eqc.end() ){\r
-            eq::EqClassIterator eqcd_i = eq::EqClassIterator( rd, getEqualityEngine() );\r
-            while( !eqcd_i.isFinished() ){\r
-              Node nd = (*eqcd_i);\r
-              if( irrelevant_dnode.find( nd )==irrelevant_dnode.end() ){\r
-                deqc.push_back( nd );\r
-              }\r
-              ++eqcd_i;\r
-            }\r
-          }\r
+          //Node rd = (*it).first;\r
+          //if( rd!=getRepresentative( rd ) ){\r
+          //  std::cout << "Bad rep!" << std::endl;\r
+          //  exit( 0 );\r
+          //}\r
+          deqc.push_back( (*it).first );\r
         }\r
       }\r
     }\r
@@ -760,105 +732,159 @@ void QuantConflictFind::computeRelevantEqr() {
     //process disequalities\r
     eq::EqClassIterator eqc_i = eq::EqClassIterator( r, getEqualityEngine() );\r
     while( !eqc_i.isFinished() ){\r
-      Node n = (*eqc_i);\r
-      bool isRedundant;\r
-      if( n.getKind()==APPLY_UF ){\r
-        computeArgReps( n );\r
-        Node nadd = d_eqc_uf_terms[r][n.getOperator()].addTerm( n, d_arg_reps[n] );\r
-        isRedundant = (nadd!=n);\r
-        d_uf_terms[n.getOperator()].addTerm( n, d_arg_reps[n] );\r
-      }else{\r
-        isRedundant = false;\r
-      }\r
-      //process all relevant equalities and disequalities to n\r
-      for( unsigned index=0; index<2; index++ ){\r
-        std::map< Node, std::map< Node, EqRegistry * > >::iterator itn[2];\r
-        itn[0] = d_eqr[index].find( n );\r
-        Node fn;\r
-        if( n.getKind()==APPLY_UF && !isRedundant ){\r
-          fn = getFunction( n );\r
-          itn[1] = d_eqr[index].find( fn );\r
+      TNode n = (*eqc_i);\r
+      if( n.getKind()!=EQUAL ){\r
+        nTermst++;\r
+        //node_to_rep[n] = r;\r
+        //if( n.getNumChildren()>0 ){\r
+        //  if( n.getKind()!=APPLY_UF ){\r
+        //    std::cout << n.getKind() << " " << n.getOperator() << " " << n << std::endl;\r
+        //  }\r
+        //}\r
+\r
+        bool isRedundant;\r
+        std::map< TNode, std::vector< TNode > >::iterator it_na;\r
+        TNode fn;\r
+        if( isHandledUfTerm( n ) ){\r
+          computeArgReps( n );\r
+          it_na = d_arg_reps.find( n );\r
+          Assert( it_na!=d_arg_reps.end() );\r
+          Node nadd = d_eqc_uf_terms[r][n.getOperator()].addTerm( n, d_arg_reps[n] );\r
+          isRedundant = (nadd!=n);\r
+          d_uf_terms[n.getOperator()].addTerm( n, d_arg_reps[n] );\r
+          if( !isRedundant ){\r
+            int jindex;\r
+            fn = getFunction( n, jindex );\r
+          }\r
+        }else{\r
+          isRedundant = false;\r
         }\r
-        //for n, fn...\r
-        bool relevant = false;\r
-        for( unsigned j=0; j<2; j++ ){\r
-          //if this node is relevant as an ground term or f-application\r
-          if( ( j==0 || !fn.isNull() ) && itn[j]!=d_eqr[index].end() ){\r
-            relevant = true;\r
-            std::vector< Node >& rel_nodes = index==0 ? eqc : deqc;\r
-            for( unsigned i=0; i<rel_nodes.size(); i++ ){\r
-              Node m = rel_nodes[i];\r
-              Node fm;\r
-              if( m.getKind()==APPLY_UF ){\r
-                fm = getFunction( m );\r
-              }\r
-              //process equality/disequality\r
-              if( j==1 ){\r
-                //fn with m\r
-                std::map< Node, EqRegistry * >::iterator itm = itn[j]->second.find( m );\r
-                if( itm!=itn[j]->second.end() ){\r
-                  if( itm->second->d_qni.addTerm( n, d_arg_reps[n] )==n ){\r
-                    Trace("qcf-reqr") << "Add relevant : " << n << (index==0?"":"!") << "=" << m << " for ";\r
-                    Trace("qcf-reqr") << fn << " " << m << std::endl;\r
-                  }\r
-                }\r
-              }\r
-              if( !fm.isNull() ){\r
-                std::map< Node, EqRegistry * >::iterator itm = itn[j]->second.find( fm );\r
-                if( itm!=itn[j]->second.end() ){\r
-                  Assert( d_arg_reps.find( m )!=d_arg_reps.end() );\r
-                  if( j==0 ){\r
-                    //n with fm\r
-                    if( itm->second->d_qni.addTerm( m, d_arg_reps[m] )==m ){\r
-                      Trace("qcf-reqr") << "Add relevant : " << n << (index==0?"":"!") << "=" << m << " for ";\r
-                      Trace("qcf-reqr") << n << " " << fm << std::endl;\r
-                    }\r
-                  }else{\r
-                    //fn with fm\r
-                    bool mltn = isLessThan( m, n );\r
-                    for( unsigned i=0; i<2; i++ ){\r
-                      if( i==0 || m.getOperator()==n.getOperator() ){\r
-                        Node am = ((i==0)==mltn) ? n : m;\r
-                        Node an = ((i==0)==mltn) ? m : n;\r
-                        if( itm->second->d_qni.addTermEq( an, am, d_arg_reps[n], d_arg_reps[m] ) ){\r
-                          Trace("qcf-reqr") << "Add relevant (eq) : " << an << (index==0?"":"!") << "=" << am << " for ";\r
-                          Trace("qcf-reqr") << fn << " " << fm << std::endl;\r
+        nTerms += isRedundant ? 0 : 1;\r
+\r
+        Trace("qcf-reqr") << "^ Process " << n << std::endl;\r
+        //process all relevant equalities and disequalities to n\r
+        for( unsigned index=0; index<2; index++ ){\r
+          std::map< TNode, std::map< int, std::map< TNode, EqRegistry * > > >::iterator itn[2];\r
+          itn[0] = d_eqr[index][0].find( n );\r
+          if( !fn.isNull() ){\r
+            itn[1] = d_eqr[index][1].find( fn );\r
+          }\r
+          //for n, fn...\r
+          bool relevant = false;\r
+          for( unsigned j=0; j<2; j++ ){\r
+            //if this node is relevant as an ground term or f-application\r
+            if( ( j==0 || !fn.isNull() ) && itn[j]!=d_eqr[index][j].end() ){\r
+              relevant = true;\r
+              for( unsigned jj=0; jj<2; jj++ ){\r
+                if( j==1 || jj==1 ){\r
+                  Trace("qcf-reqr") << "^^ " << index << " " << j << " " << jj << std::endl;\r
+                  //check with others\r
+                  for( std::map< TNode, EqRegistry * >::iterator itm = itn[j]->second[jj].begin(); itm != itn[j]->second[jj].end(); ++itm ){\r
+                    std::map< TNode, std::map< TNode, std::vector< TNode > > >::iterator itv = eqr_to_node[index].find( itm->first );\r
+                    if( itv!=eqr_to_node[index].end() ){\r
+                      //for( unsigned k=0; k<itv->second.size(); k++ ){\r
+                      for( std::map< TNode, std::vector< TNode > >::iterator itvr = itv->second.begin(); itvr != itv->second.end(); ++itvr ){\r
+                        TNode mr = itvr->first;\r
+                        //Assert( j==0 || getFunction( m )==itm->first );\r
+                        nComp++;\r
+                        //if it is equal or disequal to this\r
+                        if( ( index==0 && mr==r ) ||\r
+                            ( index==1 && std::find( deqc.begin(), deqc.end(), mr )!=deqc.end() ) ){\r
+                          Debug("qcf-reqr") << "^^ Check with : " << itv->first << ", # = " << itvr->second.size() << std::endl;\r
+                          for( unsigned k=0; k<itvr->second.size(); k++ ){\r
+                            TNode m = itvr->second[k];\r
+                            Debug("qcf-reqr") << "Comparing " << n << " and " << m << ", j = " << j << ", index = " << index << std::endl;\r
+                            Debug("qcf-reqr") << "Meets the criteria of " << itn[j]->first << " " << itm->first << std::endl;\r
+                            //process equality/disequality\r
+                            if( j==0 ){\r
+                              Assert( d_arg_reps.find( m )!=d_arg_reps.end() );\r
+                              //n with fm\r
+                              nEq1t++;\r
+                              if( itm->second->d_qni.addTerm( m, d_arg_reps[m] )==m ){\r
+                                nEq1++;\r
+                                Debug("qcf-reqr") << "Add relevant : " << n << (index==0?"":"!") << "=" << m << " for ";\r
+                                Debug("qcf-reqr") << n << " " << itm->first << std::endl;\r
+                              }\r
+                            }else{\r
+                              if( jj==0 ){\r
+                                //fn with m\r
+                                nEq1t++;\r
+                                if( itm->second->d_qni.addTerm( n, it_na->second )==n ){\r
+                                  nEq1++;\r
+                                  Debug("qcf-reqr") << "Add relevant : " << n << (index==0?"":"!") << "=" << m << " for ";\r
+                                  Debug("qcf-reqr") << fn << " " << m << std::endl;\r
+                                }\r
+                              }else{\r
+                                Assert( d_arg_reps.find( m )!=d_arg_reps.end() );\r
+                                //fn with fm\r
+                                bool mltn = isLessThan( itm->first, fn );\r
+                                for( unsigned i=0; i<2; i++ ){\r
+                                  if( i==0 || itm->first==fn ){\r
+                                    TNode am = ((i==0)==mltn) ? n : m;\r
+                                    TNode an = ((i==0)==mltn) ? m : n;\r
+                                    nEq2t++;\r
+                                    if( itm->second->d_qni.addTermEq( an, am, it_na->second, d_arg_reps[m] ) ){\r
+                                      nEq2++;\r
+                                      Debug("qcf-reqr") << "Add relevant (eq) : " << an << (index==0?"":"!") << "=" << am << " for ";\r
+                                      Debug("qcf-reqr") << fn << " " << itm->first << std::endl;\r
+                                    }\r
+                                  }\r
+                                }\r
+                              }\r
+                            }\r
+                          }\r
                         }\r
                       }\r
                     }\r
                   }\r
                 }\r
               }\r
+              Trace("qcf-reqr") << "- Node " << n << " is relevant for " << (j==0 ? n : fn) << ", index = " << index << std::endl;\r
+              //add it to relevant\r
+              eqr_to_node[index][j==0 ? n : fn][r].push_back( n );\r
             }\r
           }\r
-        }\r
-        if( !relevant ){\r
-          //if not relevant for disequalities, store it\r
-          if( index==1 ){\r
-            irrelevant_dnode[n] = true;\r
-          }\r
-        }else{\r
-          //if relevant for equalities, store it\r
-          if( index==0 ){\r
-            eqc.push_back( n );\r
+          if( !relevant ){\r
+            //if not relevant for disequalities, store it\r
+            if( index==1 ){\r
+              irrelevant_dnode[n] = true;\r
+            }\r
+          }else{\r
+            //if relevant for equalities, store it\r
+            if( index==0 ){\r
+              eqc.push_back( n );\r
+            }\r
           }\r
         }\r
       }\r
       ++eqc_i;\r
     }\r
-    process_eqc[r] = true;\r
+    //process_eqc[r] = true;\r
     ++eqcs_i;\r
   }\r
+  if( Trace.isOn("qcf-opt") ){\r
+    double clSet2 = double(clock())/double(CLOCKS_PER_SEC);\r
+    Trace("qcf-opt") << "Compute rel eqc : " << std::endl;\r
+    Trace("qcf-opt") << "   " << nEqc << " equivalence classes. " << std::endl;\r
+    Trace("qcf-opt") << "   " << nTerms << " / " << nTermst << " terms." << std::endl;\r
+    Trace("qcf-opt") << "   " << nEq1 << " / " << nEq1t << " pattern terms." << std::endl;\r
+    Trace("qcf-opt") << "   " << nEq2 << " / " << nEq2t << " pattern equalities." << std::endl;\r
+    Trace("qcf-opt") << "   " << nComp << " compares." << std::endl;\r
+    Trace("qcf-opt") << "   Time : " << (clSet2-clSet) << std::endl;\r
+  }\r
 }\r
 \r
-void QuantConflictFind::computeArgReps( Node n ) {\r
+void QuantConflictFind::computeArgReps( TNode n ) {\r
   if( d_arg_reps.find( n )==d_arg_reps.end() ){\r
+    Assert( isHandledUfTerm( n ) );\r
     for( unsigned j=0; j<n.getNumChildren(); j++ ){\r
       d_arg_reps[n].push_back( getRepresentative( n[j] ) );\r
     }\r
   }\r
 }\r
-\r
+bool QuantConflictFind::isHandledUfTerm( TNode n ) {\r
+  return n.getKind()==APPLY_UF;\r
+}\r
 \r
 void QuantConflictFind::QuantInfo::reset_round( QuantConflictFind * p ) {\r
   d_match.clear();\r
@@ -962,16 +988,18 @@ int QuantConflictFind::QuantInfo::addConstraint( QuantConflictFind * p, int v, N
             return addConstraint( p, vn, d_vars[v], v, true, true );\r
           }else{\r
             //unsetting variables equal\r
-\r
-            //remove disequalities owned by this\r
-            std::vector< Node > remDeq;\r
-            for( std::map< Node, int >::iterator it = d_curr_var_deq[vn].begin(); it != d_curr_var_deq[vn].end(); ++it ){\r
-              if( it->second==v ){\r
-                remDeq.push_back( it->first );\r
+            std::map< int, std::map< Node, int > >::iterator itd = d_curr_var_deq.find( vn );\r
+            if( itd!=d_curr_var_deq.end() ){\r
+              //remove disequalities owned by this\r
+              std::vector< Node > remDeq;\r
+              for( std::map< Node, int >::iterator it = itd->second.begin(); it != itd->second.end(); ++it ){\r
+                if( it->second==v ){\r
+                  remDeq.push_back( it->first );\r
+                }\r
+              }\r
+              for( unsigned i=0; i<remDeq.size(); i++ ){\r
+                d_curr_var_deq[vn].erase( remDeq[i] );\r
               }\r
-            }\r
-            for( unsigned i=0; i<remDeq.size(); i++ ){\r
-              d_curr_var_deq[vn].erase( remDeq[i] );\r
             }\r
           }\r
         }\r
@@ -992,18 +1020,21 @@ int QuantConflictFind::QuantInfo::addConstraint( QuantConflictFind * p, int v, N
             }\r
 \r
             //copy or check disequalities\r
-            std::vector< Node > addDeq;\r
-            for( std::map< Node, int >::iterator it = d_curr_var_deq[v].begin(); it != d_curr_var_deq[v].end(); ++it ){\r
-              Node dv = getCurrentValue( it->first );\r
-              if( !alreadySet ){\r
-                if( d_curr_var_deq[vn].find( dv )==d_curr_var_deq[vn].end() ){\r
-                  d_curr_var_deq[vn][dv] = v;\r
-                  addDeq.push_back( dv );\r
-                }\r
-              }else{\r
-                if( itmn->second!=dv ){\r
-                  Debug("qcf-match-debug") << "  -> fail, conflicting disequality" << std::endl;\r
-                  return -1;\r
+            std::map< int, std::map< Node, int > >::iterator itd = d_curr_var_deq.find( v );\r
+            if( itd!=d_curr_var_deq.end() ){\r
+              //std::vector< Node > addDeq;\r
+              for( std::map< Node, int >::iterator it = itd->second.begin(); it != itd->second.end(); ++it ){\r
+                Node dv = getCurrentValue( it->first );\r
+                if( !alreadySet ){\r
+                  if( d_curr_var_deq[vn].find( dv )==d_curr_var_deq[vn].end() ){\r
+                    d_curr_var_deq[vn][dv] = v;\r
+                    //addDeq.push_back( dv );\r
+                  }\r
+                }else{\r
+                  if( itmn->second!=dv ){\r
+                    Debug("qcf-match-debug") << "  -> fail, conflicting disequality" << std::endl;\r
+                    return -1;\r
+                  }\r
                 }\r
               }\r
             }\r
@@ -1103,7 +1134,7 @@ bool QuantConflictFind::QuantInfo::completeMatch( QuantConflictFind * p, Node q,
   std::vector< TypeNode > unassigned_tn[2];\r
   for( int i=0; i<getNumVars(); i++ ){\r
     if( d_match.find( i )==d_match.end() ){\r
-      Assert( i<(int)q[0].getNumChildren() );\r
+      //Assert( i<(int)q[0].getNumChildren() );\r
       int rindex = d_var_mg.find( i )==d_var_mg.end() ? 1 : 0;\r
       unassigned[rindex].push_back( i );\r
       unassigned_tn[rindex].push_back( getVar( i ).getType() );\r
@@ -1213,7 +1244,7 @@ QuantConflictFind::MatchGen::MatchGen( QuantConflictFind * p, Node q, Node n, bo
   d_qni_size = 0;\r
   if( isVar ){\r
     Assert( p->d_qinfo[q].d_var_num.find( n )!=p->d_qinfo[q].d_var_num.end() );\r
-    if( n.getKind()==APPLY_UF ){\r
+    if( p->isHandledUfTerm( n ) ){\r
       d_type = typ_var;\r
       //d_type_not = true;  //implicit disequality, in disjunction at top level\r
       d_type_not = false;\r
@@ -1277,7 +1308,7 @@ QuantConflictFind::MatchGen::MatchGen( QuantConflictFind * p, Node q, Node n, bo
           bool isValid = true;\r
           if( qni_apps.size()>0 ){\r
             for( unsigned i=0; i<qni_apps.size(); i++ ){\r
-              if( qni_apps[i].getKind()!=APPLY_UF ){\r
+              if( !p->isHandledUfTerm( qni_apps[i] ) ){\r
                 //for now, cannot handle anything besides uf\r
                 isValid = false;\r
                 qni_apps.clear();\r
@@ -1413,13 +1444,13 @@ void QuantConflictFind::MatchGen::reset( QuantConflictFind * p, bool tgt, Node q
     int vi = p->d_qinfo[q].getVarNum( d_n );\r
     Assert( vi!=-1 );\r
     int repVar = p->d_qinfo[q].getCurrentRepVar( vi );\r
-    Assert( d_n.getKind()==APPLY_UF );\r
+    Assert( p->isHandledUfTerm( d_n ) );\r
     Node f = d_n.getOperator();\r
     std::map< int, Node >::iterator it = p->d_qinfo[q].d_match.find( repVar );\r
     if( it!=p->d_qinfo[q].d_match.end() && d_tgt ) {\r
       Debug("qcf-match") << "       will be matching var within eqc = " << it->second << std::endl;\r
       //f-applications in the equivalence class in match[ repVar ]\r
-      std::map< Node, QcfNodeIndex >::iterator itut = p->d_eqc_uf_terms[ it->second ].find( f );\r
+      std::map< TNode, QcfNodeIndex >::iterator itut = p->d_eqc_uf_terms[ it->second ].find( f );\r
       if( itut!=p->d_eqc_uf_terms[ it->second ].end() ){\r
         d_qn.push_back( &itut->second );\r
       }\r
@@ -1428,7 +1459,7 @@ void QuantConflictFind::MatchGen::reset( QuantConflictFind * p, bool tgt, Node q
       //we are binding rep var\r
       d_qni_bound_cons[repVar] = Node::null();\r
       //must look at all f-applications\r
-      std::map< Node, QcfNodeIndex >::iterator itut = p->d_uf_terms.find( f );\r
+      std::map< TNode, QcfNodeIndex >::iterator itut = p->d_uf_terms.find( f );\r
       if( itut!=p->d_uf_terms.end() ){\r
         d_qn.push_back( &itut->second );\r
       }\r
@@ -1655,7 +1686,7 @@ bool QuantConflictFind::MatchGen::doMatching( QuantConflictFind * p, Node q ) {
             }else{\r
               //binding a variable\r
               d_qni_bound[index] = repVar;\r
-              std::map< Node, QcfNodeIndex >::iterator it = d_qn[index]->d_children.begin();\r
+              std::map< TNode, QcfNodeIndex >::iterator it = d_qn[index]->d_children.begin();\r
               if( it != d_qn[index]->d_children.end() ) {\r
                 d_qni.push_back( it );\r
                 //set the match\r
@@ -1682,7 +1713,7 @@ bool QuantConflictFind::MatchGen::doMatching( QuantConflictFind * p, Node q ) {
           }\r
           if( !val.isNull() ){\r
             //constrained by val\r
-            std::map< Node, QcfNodeIndex >::iterator it = d_qn[index]->d_children.find( val );\r
+            std::map< TNode, QcfNodeIndex >::iterator it = d_qn[index]->d_children.find( val );\r
             if( it!=d_qn[index]->d_children.end() ){\r
               Debug("qcf-match-debug") << "       Match" << std::endl;\r
               d_qni.push_back( it );\r
@@ -1829,38 +1860,42 @@ void QuantConflictFind::debugPrint( const char * c ) {
   for( unsigned i=0; i<2; i++ ){\r
     printed.clear();\r
     Trace(c) << "----------EQR, polarity = " << (i==0) << std::endl;\r
-    for( std::map< Node, std::map< Node, EqRegistry * > >::iterator it = d_eqr[i].begin(); it != d_eqr[i].end(); ++it ){\r
-      bool prHead = false;\r
-      for( std::map< Node, EqRegistry * >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){\r
-        bool print;\r
-        if( it->first.getKind()==APPLY_UF && it2->first.getKind()==APPLY_UF &&\r
-            it->first.getOperator()!=it2->first.getOperator() ){\r
-          print = isLessThan( it->first, it2->first );\r
-        }else{\r
-          print = printed[it->first].find( it2->first )==printed[it->first].end();\r
-        }\r
-        if( print ){\r
-          printed[it->first][it2->first] = true;\r
-          printed[it2->first][it->first] = true;\r
-          if( !prHead ){\r
-            Trace(c) << "- " << it->first << std::endl;\r
-            prHead = true;\r
-          }\r
-          Trace(c) << "    " << it2->first << ", terms : " << std::endl;\r
-\r
-          /*\r
-          Trace(c) << "    " << it2->first << " : {";\r
-          bool pr = false;\r
-          for( NodeBoolMap::iterator it3 = it2->second->d_t_eqc.begin(); it3 != it2->second->d_t_eqc.end(); ++it3 ){\r
-            if( (*it3).second ){\r
-              Trace(c) << (pr ? "," : "" ) << " " << (*it3).first;\r
-              pr = true;\r
+    for( unsigned j=0; j<2; j++ ){\r
+      for( std::map< TNode, std::map< int, std::map< TNode, EqRegistry * > > >::iterator it = d_eqr[i][j].begin(); it != d_eqr[i][j].end(); ++it ){\r
+        bool prHead = false;\r
+        for( unsigned jj=0; jj<2; jj++ ){\r
+          for( std::map< TNode, EqRegistry * >::iterator it2 = it->second[jj].begin(); it2 != it->second[jj].end(); ++it2 ){\r
+            bool print;\r
+            if( isHandledUfTerm( it->first ) && isHandledUfTerm( it2->first ) &&\r
+                it->first.getOperator()!=it2->first.getOperator() ){\r
+              print = isLessThan( it->first.getOperator(), it2->first.getOperator() );\r
+            }else{\r
+              print = printed[it->first].find( it2->first )==printed[it->first].end();\r
+            }\r
+            if( print ){\r
+              printed[it->first][it2->first] = true;\r
+              printed[it2->first][it->first] = true;\r
+              if( !prHead ){\r
+                Trace(c) << "- " << it->first << std::endl;\r
+                prHead = true;\r
+              }\r
+              Trace(c) << "    " << it2->first << ", terms : " << std::endl;\r
+\r
+              /*\r
+              Trace(c) << "    " << it2->first << " : {";\r
+              bool pr = false;\r
+              for( NodeBoolMap::iterator it3 = it2->second->d_t_eqc.begin(); it3 != it2->second->d_t_eqc.end(); ++it3 ){\r
+                if( (*it3).second ){\r
+                  Trace(c) << (pr ? "," : "" ) << " " << (*it3).first;\r
+                  pr = true;\r
+                }\r
+              }\r
+              Trace(c) << (pr ? " " : "" ) << "}" << std::endl;\r
+              */\r
+              //print qni structure\r
+              it2->second->debugPrint( c, 3 );\r
             }\r
           }\r
-          Trace(c) << (pr ? " " : "" ) << "}" << std::endl;\r
-          */\r
-          //print qni structure\r
-          it2->second->debugPrint( c, 3 );\r
         }\r
       }\r
     }\r
index 0b503d49b22eb943698c5168b6e555b375cbcc65..657586d1a504d44b14589588f6e0eb3a908b2d5d 100755 (executable)
@@ -31,16 +31,16 @@ class QuantConflictFind;
 \r
 class QcfNodeIndex {\r
 public:\r
-  std::map< Node, QcfNodeIndex > d_children;\r
+  std::map< TNode, QcfNodeIndex > d_children;\r
   void clear() { d_children.clear(); }\r
   //Node existsTerm( QuantConflictFind * qcf, Node n, int index = 0 );\r
   //Node addTerm( QuantConflictFind * qcf, Node n, int index = 0 );\r
   //bool addTermEq( QuantConflictFind * qcf, Node n1, Node n2, int index = 0 );\r
   void debugPrint( const char * c, int t );\r
   //optimized versions\r
-  Node existsTerm( Node n, std::vector< Node >& reps, int index = 0 );\r
-  Node addTerm( Node n, std::vector< Node >& reps, int index = 0 );\r
-  bool addTermEq( Node n1, Node n2, std::vector< Node >& reps1, std::vector< Node >& reps2, int index = 0 );\r
+  Node existsTerm( TNode n, std::vector< TNode >& reps, int index = 0 );\r
+  Node addTerm( TNode n, std::vector< TNode >& reps, int index = 0 );\r
+  bool addTermEq( TNode n1, TNode n2, std::vector< TNode >& reps1, std::vector< TNode >& reps2, int index = 0 );\r
 };\r
 \r
 class EqRegistry {\r
@@ -91,14 +91,14 @@ private:
   std::map< Node, Node > d_op_node;\r
   int getFunctionId( Node f );\r
   bool isLessThan( Node a, Node b );\r
-  Node getFunction( Node n, bool isQuant = false );\r
+  Node getFunction( Node n, int& index, bool isQuant = false );\r
   int d_fid_count;\r
   std::map< Node, int > d_fid;\r
   Node mkEqNode( Node a, Node b );\r
 private:  //for ground terms\r
   Node d_true;\r
   Node d_false;\r
-  std::map< Node, std::map< Node, EqRegistry * > > d_eqr[2];\r
+  std::map< int, std::map< TNode, std::map< int, std::map< TNode, EqRegistry * > > > > d_eqr[2];\r
   EqRegistry * getEqRegistry( bool polarity, Node lit, bool doCreate = true );\r
   void getEqRegistryApps( Node lit, std::vector< Node >& terms );\r
   int evaluate( Node n );\r
@@ -114,7 +114,7 @@ public:  //for quantifiers
     MatchGen * getChild( int i ) { return &d_children[d_children_order[i]]; }\r
     //current matching information\r
     std::vector< QcfNodeIndex * > d_qn;\r
-    std::vector< std::map< Node, QcfNodeIndex >::iterator > d_qni;\r
+    std::vector< std::map< TNode, QcfNodeIndex >::iterator > d_qni;\r
     bool doMatching( QuantConflictFind * p, Node q );\r
     //for matching : each index is either a variable or a ground term\r
     unsigned d_qni_size;\r
@@ -200,15 +200,17 @@ private:  //for equivalence classes
   std::map< Node, EqcInfo * > d_eqc_info;\r
   EqcInfo * getEqcInfo( Node n, bool doCreate = true );\r
   // operator -> index(terms)\r
-  std::map< Node, QcfNodeIndex > d_uf_terms;\r
+  std::map< TNode, QcfNodeIndex > d_uf_terms;\r
   // eqc x operator -> index(terms)\r
-  std::map< Node, std::map< Node, QcfNodeIndex > > d_eqc_uf_terms;\r
+  std::map< TNode, std::map< TNode, QcfNodeIndex > > d_eqc_uf_terms;\r
   // type -> list(eqc)\r
-  std::map< TypeNode, std::vector< Node > > d_eqcs;\r
+  std::map< TypeNode, std::vector< TNode > > d_eqcs;\r
   //mapping from UF terms to representatives of their arguments\r
-  std::map< Node, std::vector< Node > > d_arg_reps;\r
+  std::map< TNode, std::vector< TNode > > d_arg_reps;\r
   //compute arg reps\r
-  void computeArgReps( Node n );\r
+  void computeArgReps( TNode n );\r
+  // is this term treated as UF application?\r
+  bool isHandledUfTerm( TNode n );\r
 public:\r
   QuantConflictFind( QuantifiersEngine * qe, context::Context* c );\r
 \r