Minor fix to avoid rewriting datatype equalities into non-equalitiers, as required...
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Tue, 22 Apr 2014 08:16:56 +0000 (03:16 -0500)
committerAndrew Reynolds <andrew.j.reynolds@gmail.com>
Tue, 22 Apr 2014 08:16:56 +0000 (03:16 -0500)
src/theory/datatypes/datatypes_rewriter.h
src/theory/datatypes/theory_datatypes.cpp

index e884248e75a3c9d5dcf423c9fdcb8065c0f44cab..75d1f2b2e4f943425f114f517169fcfbb8915122 100644 (file)
@@ -207,13 +207,10 @@ public:
       std::vector< Node > rew;
       if( checkClash(in[0], in[1], rew) ){
         Trace("datatypes-rewrite") << "Rewrite clashing equality " << in << " to false" << std::endl;
-        return RewriteResponse(REWRITE_DONE,
-                               NodeManager::currentNM()->mkConst(false));
-      }else if( rew.size()!=1 || rew[0]!=in ){
-        Node nn = rew.size()==0 ? NodeManager::currentNM()->mkConst( true ) :
-                    ( rew.size()==1 ? rew[0] : NodeManager::currentNM()->mkNode( kind::AND, rew ) );
-        Trace("datatypes-rewrite") << "Rewrite equality to " << nn << std::endl;
-        return RewriteResponse(REWRITE_AGAIN_FULL, nn );
+        return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(false));
+      }else if( rew.size()==1 && rew[0]!=in ){
+        Trace("datatypes-rewrite") << "Rewrite equality " << in << " to " << rew[0] << std::endl;
+        return RewriteResponse(REWRITE_AGAIN_FULL, rew[0] );
       }
     }
 
@@ -242,7 +239,7 @@ public:
           }
         }
       }
-    }else{
+    }else if( n1!=n2 ){
       Node eq = NodeManager::currentNM()->mkNode( n1.getType().isBoolean() ? kind::IFF : kind::EQUAL, n1, n2 );
       rew.push_back( eq );
     }
index 8afcbb1de0995d7b276e939283d17c0a250edcf4..2fb1a2679fed82374ea464474df6d794b96bf45f 100644 (file)
@@ -56,6 +56,7 @@ TheoryDatatypes::TheoryDatatypes(Context* c, UserContext* u, OutputChannel& out,
   d_equalityEngine.addFunctionKind(kind::APPLY_CONSTRUCTOR);
   d_equalityEngine.addFunctionKind(kind::APPLY_SELECTOR_TOTAL);
   d_equalityEngine.addFunctionKind(kind::APPLY_TESTER);
+  d_equalityEngine.addFunctionKind(kind::APPLY_UF);
 }
 
 TheoryDatatypes::~TheoryDatatypes() {
@@ -412,6 +413,19 @@ Node TheoryDatatypes::ppRewrite(TNode in) {
         NodeManager::currentNM()->getDatatypeForTupleRecord(t).setAttribute(expr::DatatypeRecordAttr(), NodeManager::currentNM()->getDatatypeForTupleRecord(in.getAttribute(smt::BooleanTermAttr()).getType()).getAttribute(expr::DatatypeRecordAttr()));
       }
     }
+
+    if( in.getKind()==EQUAL ){
+      Node nn;
+      std::vector< Node > rew;
+      if( DatatypesRewriter::checkClash(in[0], in[1], rew) ){
+        nn = NodeManager::currentNM()->mkConst(false);
+      }else{
+        nn = rew.size()==0 ? NodeManager::currentNM()->mkConst( true ) :
+                  ( rew.size()==1 ? rew[0] : NodeManager::currentNM()->mkNode( kind::AND, rew ) );
+      }
+      return nn;
+    }
+
     // nothing to do
     return in;
   }
@@ -465,6 +479,7 @@ Node TheoryDatatypes::ppRewrite(TNode in) {
 
   Assert(!n.isNull());
 
+
   Debug("tuprec") << "REWROTE " << in << " to " << n << std::endl;
 
   return n;