Improvement and bug fix for str.indexof reduction, add regression. Other minor changes.
authorajreynol <andrew.j.reynolds@gmail.com>
Thu, 1 Dec 2016 16:47:31 +0000 (10:47 -0600)
committerajreynol <andrew.j.reynolds@gmail.com>
Thu, 1 Dec 2016 16:47:47 +0000 (10:47 -0600)
src/theory/quantifiers/model_engine.cpp
src/theory/sep/kinds
src/theory/strings/theory_strings_preprocess.cpp
test/regress/regress0/strings/Makefile.am
test/regress/regress0/strings/strings-index-empty.smt2 [new file with mode: 0644]

index 1a0faa021fc84241d0348ea846a63e0a7bba2e92..20f5eae7b4cb98c27b05792d618d1179f58c2716 100644 (file)
@@ -231,7 +231,11 @@ int ModelEngine::checkModel(){
 }
 
 bool ModelEngine::considerQuantifiedFormula( Node q ) {
-  if( !d_quantEngine->getModelBuilder()->isQuantifierActive( q ) || !d_quantEngine->getModel()->isQuantifierActive( q ) ){
+  if( !d_quantEngine->getModelBuilder()->isQuantifierActive( q ) ){ 
+    Trace("model-engine-debug") << "Model builder inactive : " << q << std::endl;
+    return false;
+  }else if( !d_quantEngine->getModel()->isQuantifierActive( q ) ){
+    Trace("model-engine-debug") << "Model inactive : " << q << std::endl;
     return false;
   }else{
     if( options::fmfEmptySorts() ){
index 318442ba576a235361ffce2c6ae77602da3a9bc2..5cd9093f4a66b5e868b863466f2af0139124afbd 100644 (file)
@@ -25,7 +25,7 @@ operator SEP_EMP 2 "separation empty heap"
 operator SEP_PTO 2 "points to relation"
 operator SEP_STAR 2: "separation star"
 operator SEP_WAND 2 "separation magic wand"
-operator SEP_LABEL 2 "separation label"
+operator SEP_LABEL 2 "separation label (internal use only)"
 
 typerule SEP_NIL_REF ::CVC4::theory::sep::SepNilRefTypeRule
 typerule SEP_EMP ::CVC4::theory::sep::SepEmpTypeRule
index a697dad755d72718894554d758be5c5b7d004314..c8fe1fb00512a3deb43ee82461dab48b9892cf91 100644 (file)
@@ -116,25 +116,23 @@ Node StringsPreprocess::simplify( Node t, std::vector< Node > &new_nodes ) {
       skk = NodeManager::currentNM()->mkSkolem( "iok", NodeManager::currentNM()->integerType(), "created for indexof" );
     }
     Node st = NodeManager::currentNM()->mkNode( kind::STRING_SUBSTR, t[0], t[2], NodeManager::currentNM()->mkNode( kind::MINUS, NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, t[0] ), t[2] ) );
+    //TODO: simplify this (only applies when idof != -1)
     Node eq = st.eqNode( NodeManager::currentNM()->mkNode( kind::STRING_CONCAT, sk2, sk3, sk4 ) );
     new_nodes.push_back( eq );
+    
+    //learn range of idof?
     Node negone = NodeManager::currentNM()->mkConst( ::CVC4::Rational(-1) );
     Node krange = NodeManager::currentNM()->mkNode( kind::GEQ, skk, negone );
     new_nodes.push_back( krange );
     krange = NodeManager::currentNM()->mkNode( kind::GT, NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, t[0] ), skk);
     new_nodes.push_back( krange );
-    krange = NodeManager::currentNM()->mkNode( kind::GT, NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, t[1] ), d_zero);
-    new_nodes.push_back( krange );
-    Node start_valid = NodeManager::currentNM()->mkNode( kind::GEQ, t[2], d_zero);
 
-    //str.len(s1) < y + str.len(s2)
-    Node c1 = NodeManager::currentNM()->mkNode( kind::GT,
-                                                NodeManager::currentNM()->mkNode( kind::PLUS, t[2], NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, t[1] )),
-                                                NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, t[0] ));
+    // s2 = ""
+    Node c1 = t[1].eqNode( NodeManager::currentNM()->mkConst( ::CVC4::String("") ) );
     //~contain(t234, s2)
     Node c3 = NodeManager::currentNM()->mkNode( kind::STRING_STRCTN, st, t[1] ).negate();
     //left
-    Node left = NodeManager::currentNM()->mkNode( kind::OR, c1, c3, start_valid.negate() );
+    Node left = NodeManager::currentNM()->mkNode( kind::OR, c1, c3 );
     //t3 = s2
     Node c4 = t[1].eqNode( sk3 );
     //~contain(t2, s2)
@@ -149,7 +147,7 @@ Node StringsPreprocess::simplify( Node t, std::vector< Node > &new_nodes ) {
     Node c6 = skk.eqNode( NodeManager::currentNM()->mkNode( kind::PLUS, t[2],
                             NodeManager::currentNM()->mkNode( kind::STRING_LENGTH, sk2 )) );
     //right
-    Node right = NodeManager::currentNM()->mkNode( kind::AND, c4, c5, c6, start_valid );
+    Node right = NodeManager::currentNM()->mkNode( kind::AND, c4, c5, c6, c1.negate() );
     Node cond = skk.eqNode( negone );
     Node rr = NodeManager::currentNM()->mkNode( kind::ITE, cond, left, right );
     new_nodes.push_back( rr );
index 21d51199db1abe0c76bcf6ab9097fc6b5961e4da..70fec7b82a02979a31f79f4bd6a40c49a8e44aa5 100644 (file)
@@ -83,7 +83,8 @@ TESTS = \
   csp-prefix-exp-bug.smt2 \
   cmu-substr-rw.smt2 \
   gm-inc-071516-2.smt2 \
-  cmu-inc-nlpp-071516.smt2
+  cmu-inc-nlpp-071516.smt2 \
+  strings-index-empty.smt2
 
 FAILING_TESTS =
 
diff --git a/test/regress/regress0/strings/strings-index-empty.smt2 b/test/regress/regress0/strings/strings-index-empty.smt2
new file mode 100644 (file)
index 0000000..a726d9c
--- /dev/null
@@ -0,0 +1,11 @@
+; COMMAND-LINE: --simplification=none --strings-exp --no-strings-lazy-pp
+; EXPECT: sat
+(set-logic SLIA)
+(set-info :status sat)
+(declare-fun x () String)
+(declare-fun f () String)
+(declare-fun y () Int)
+(assert (= (str.len f) 0))
+; command line options ensure reduction is invoked for indexof, f is "", should return -1
+(assert (= (str.indexof x f 4) y))
+(check-sat)