Make strings fmf apply to all but internally generated Skolems (#1780)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Mon, 16 Apr 2018 01:52:46 +0000 (20:52 -0500)
committerGitHub <noreply@github.com>
Mon, 16 Apr 2018 01:52:46 +0000 (20:52 -0500)
src/theory/strings/theory_strings.cpp
src/theory/strings/theory_strings.h

index 713c346e04810fcc4b0f01d298a62058b4cf3935..fe6f7ea772f176cd8e4f74ef2706b08a5198d24c 100644 (file)
@@ -648,8 +648,14 @@ void TheoryStrings::preRegisterTerm(TNode n) {
         TypeNode tn = n.getType();
         if( tn.isString() ) {
           registerTerm( n, 0 );
-          // FMF
-          if( n.getKind() == kind::VARIABLE && options::stringFMF() ){
+          // if finite model finding is enabled,
+          // then we minimize the length of this term if it is a variable
+          // but not an internally generated Skolem, or a term that does
+          // not belong to this theory.
+          if (options::stringFMF()
+              && (n.isVar() ? d_all_skolems.find(n) == d_all_skolems.end()
+                            : kindToTheoryId(n.getKind()) != THEORY_STRINGS))
+          {
             d_input_vars.insert(n);
           }
           d_equalityEngine.addTerm(n);
@@ -3569,6 +3575,7 @@ Node TheoryStrings::mkSkolemCached( Node a, Node b, int id, const char * c, int
 //isLenSplit: -1-ignore, 0-no restriction, 1-greater than one, 2-one
 Node TheoryStrings::mkSkolemS( const char *c, int isLenSplit ) {
   Node n = NodeManager::currentNM()->mkSkolem( c, NodeManager::currentNM()->stringType(), "string sko" );
+  d_all_skolems.insert(n);
   d_length_lemma_terms_cache.insert( n );
   ++(d_statistics.d_new_skolems);
   if( isLenSplit==0 ){
index cff49ccb82f61bed08957b0b138cf3f932f91615..22406adef3a16352ea0a214a5c1a8b1c625066dc 100644 (file)
@@ -489,6 +489,8 @@ private:
     sk_id_deq_z,
   };
   std::map<Node, std::map<Node, std::map<int, Node> > > d_skolem_cache;
+  /** the set of all skolems we have generated */
+  std::unordered_set<Node, NodeHashFunction> d_all_skolems;
   Node mkSkolemCached(
       Node a, Node b, int id, const char* c, int isLenSplit = 0);
   inline Node mkSkolemS(const char* c, int isLenSplit = 0);