From: Andrew Reynolds Date: Thu, 24 Apr 2014 12:27:38 +0000 (+0200) Subject: Compute care graph for datatypes. Preliminary results show 20x speed up on larger... X-Git-Tag: cvc5-1.0.0~6961 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d132321d74b65b293ffac4bc8c6f0d8db73614d6;p=cvc5.git Compute care graph for datatypes. Preliminary results show 20x speed up on larger problems. Improve datatypes rewriter. --- diff --git a/src/theory/datatypes/datatypes_rewriter.h b/src/theory/datatypes/datatypes_rewriter.h index 75d1f2b2e..dc85d0cd6 100644 --- a/src/theory/datatypes/datatypes_rewriter.h +++ b/src/theory/datatypes/datatypes_rewriter.h @@ -211,6 +211,8 @@ public: }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] ); + }else{ + Trace("datatypes-rewrite-debug") << "Did not rewrite equality " << in << " " << in[0].getKind() << " " << in[1].getKind() << std::endl; } } @@ -240,8 +242,12 @@ public: } } }else if( n1!=n2 ){ - Node eq = NodeManager::currentNM()->mkNode( n1.getType().isBoolean() ? kind::IFF : kind::EQUAL, n1, n2 ); - rew.push_back( eq ); + if( n1.isConst() && n2.isConst() ){ + return true; + }else{ + Node eq = NodeManager::currentNM()->mkNode( n1.getType().isBoolean() ? kind::IFF : kind::EQUAL, n1, n2 ); + rew.push_back( eq ); + } } return false; } diff --git a/src/theory/datatypes/theory_datatypes.cpp b/src/theory/datatypes/theory_datatypes.cpp index 2fb1a2679..e706d3846 100644 --- a/src/theory/datatypes/theory_datatypes.cpp +++ b/src/theory/datatypes/theory_datatypes.cpp @@ -50,7 +50,9 @@ TheoryDatatypes::TheoryDatatypes(Context* c, UserContext* u, OutputChannel& out, d_labels( c ), d_selector_apps( c ), d_conflict( c, false ), - d_collectTermsCache( c ){ + d_collectTermsCache( c ), + d_consTerms( c ), + d_selTerms( c ){ // The kinds we are treating as function application in congruence d_equalityEngine.addFunctionKind(kind::APPLY_CONSTRUCTOR); @@ -963,7 +965,45 @@ EqualityStatus TheoryDatatypes::getEqualityStatus(TNode a, TNode b){ } void TheoryDatatypes::computeCareGraph(){ - Theory::computeCareGraph(); + Trace("ajr-temp") << "Compute graph for dt..." << std::endl; + vector< pair > currentPairs; + for( unsigned r=0; r<2; r++ ){ + unsigned functionTerms = r==0 ? d_consTerms.size() : d_selTerms.size(); + for( unsigned i=0; i d_pending_merge; /** expand definition skolem functions */ std::map< Node, Node > d_exp_def_skolem; + /** All the constructor terms that the theory has seen */ + context::CDList d_consTerms; + /** All the selector terms that the theory has seen */ + context::CDList d_selTerms; private: /** assert fact */ void assertFact( Node fact, Node exp ); @@ -261,10 +265,10 @@ private: bool mustCommunicateFact( Node n, Node exp ); private: //equality queries - bool hasTerm( Node a ); - bool areEqual( Node a, Node b ); - bool areDisequal( Node a, Node b ); - Node getRepresentative( Node a ); + bool hasTerm( TNode a ); + bool areEqual( TNode a, TNode b ); + bool areDisequal( TNode a, TNode b ); + Node getRepresentative( TNode a ); public: /** get equality engine */ eq::EqualityEngine* getEqualityEngine() { return &d_equalityEngine; }