Fix isLeq function in String utility (#3659)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Wed, 29 Jan 2020 19:55:01 +0000 (13:55 -0600)
committerGitHub <noreply@github.com>
Wed, 29 Jan 2020 19:55:01 +0000 (13:55 -0600)
src/util/regexp.cpp
test/regress/CMakeLists.txt
test/regress/regress0/strings/issue3657-evalLeq.smt2 [new file with mode: 0644]
test/regress/regress1/strings/issue3657-unexpectedUnsatCVC4.smt2 [new file with mode: 0644]

index d91280926afafdeb87d31801b0b401f2bb0b81e4..ee63308ab9c98e14365a1305cb0a9cd00fc0112c 100644 (file)
@@ -331,11 +331,13 @@ bool String::isLeq(const String &y) const
     {
       return false;
     }
-    if (d_str[i] > y.d_str[i])
+    unsigned ci = convertUnsignedIntToCode(d_str[i]);
+    unsigned cyi = convertUnsignedIntToCode(y.d_str[i]);
+    if (ci > cyi)
     {
       return false;
     }
-    if (d_str[i] < y.d_str[i])
+    if (ci < cyi)
     {
       return true;
     }
index 418670fa6b9590dc0eb92740ee2941f525746312..bd36657276972bce001bd968ff0394d4d64bead2 100644 (file)
@@ -889,6 +889,7 @@ set(regress_0_tests
   regress0/strings/issue2958.smt2
   regress0/strings/issue3440.smt2
   regress0/strings/issue3497.smt2
+  regress0/strings/issue3657-evalLeq.smt2
   regress0/strings/itos-entail.smt2
   regress0/strings/leadingzero001.smt2
   regress0/strings/loop001.smt2
@@ -1653,6 +1654,7 @@ set(regress_1_tests
   regress1/strings/issue3217.smt2
   regress1/strings/issue3272.smt2
   regress1/strings/issue3357.smt2
+  regress1/strings/issue3657-unexpectedUnsatCVC4.smt2
   regress1/strings/kaluza-fl.smt2
   regress1/strings/loop002.smt2
   regress1/strings/loop003.smt2
diff --git a/test/regress/regress0/strings/issue3657-evalLeq.smt2 b/test/regress/regress0/strings/issue3657-evalLeq.smt2
new file mode 100644 (file)
index 0000000..a557f4e
--- /dev/null
@@ -0,0 +1,6 @@
+(set-info :smt-lib-version 2.5)
+(set-logic ALL)
+(set-info :status sat)
+(assert (not (str.< "\xe8" "\x19")))
+(check-sat)
+(exit)
diff --git a/test/regress/regress1/strings/issue3657-unexpectedUnsatCVC4.smt2 b/test/regress/regress1/strings/issue3657-unexpectedUnsatCVC4.smt2
new file mode 100644 (file)
index 0000000..b2bb295
--- /dev/null
@@ -0,0 +1,258 @@
+; COMMAND-LINE: --strings-exp --fmf-fun-rlv -i\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+; EXPECT: sat\r
+(set-info :smt-lib-version 2.5)\r
+(set-option :produce-models true)\r
+(set-logic ALL)\r
+(declare-datatypes () ((a0(c0$0)(c0$1)(c0$2)(c0$3(c0$3$0 a1)(c0$3$1 Int)(c0$3$2 String)(c0$3$3 Int))(c0$4(c0$4$0 Int))(c0$5))(a1(c1$0(c1$0$0 a0)(c1$0$1 a0)(c1$0$2 String)(c1$0$3 Int))(c1$1(c1$1$0 Int))(c1$2)(c1$3(c1$3$0 Int))(c1$4)(c1$5))(a2(c2$0(c2$0$0 Int)(c2$0$1 a0))(c2$1(c2$1$0 String)(c2$1$1 a0)(c2$1$2 a1)))))\r
+(push 1)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v0() a0)\r
+(declare-fun v1() a2)\r
+(declare-fun v2() a2)\r
+(declare-fun v3() a0)\r
+(declare-fun v4() Bool)\r
+(declare-fun v5() a1)\r
+(declare-fun v6() Bool)\r
+(declare-fun v7() String)\r
+(declare-fun v8() a2)\r
+(pop 1)\r
+(push 1)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v9() a2)\r
+(declare-fun va() a1)\r
+(declare-fun vb() Int)\r
+(declare-fun vc() Bool)\r
+(declare-fun vd() Int)\r
+(declare-fun ve() Bool)\r
+(declare-fun vf() Bool)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v10() a1)\r
+(declare-fun v11() a0)\r
+(declare-fun v12() a1)\r
+(declare-fun v13() Int)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v14() Bool)\r
+(declare-fun v15() a0)\r
+(declare-fun v16() Bool)\r
+(declare-fun v17() a1)\r
+(declare-fun v18() a2)\r
+(declare-fun v19() a0)\r
+(declare-fun v1a() Int)\r
+(declare-fun v1b() Bool)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v1c() String)\r
+(declare-fun v1d() Int)\r
+(declare-fun v1e() a1)\r
+(declare-fun v1f() a0)\r
+(declare-fun v20() Bool)\r
+(declare-fun v21() Int)\r
+(declare-fun v22() Int)\r
+(declare-fun v23() String)\r
+(declare-fun v24() a0)\r
+(declare-fun v25() a0)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v26() Bool)\r
+(declare-fun v27() Bool)\r
+(declare-fun v28() Int)\r
+(declare-fun v29() a2)\r
+(declare-fun v2a() Int)\r
+(declare-fun v2b() Int)\r
+(declare-fun v2c() String)\r
+(declare-fun v2d() String)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v2e() a2)\r
+(declare-fun v2f() a1)\r
+(declare-fun v30() a0)\r
+(declare-fun v31() a2)\r
+(declare-fun v32() String)\r
+(declare-fun v33() Bool)\r
+(declare-fun v34() Int)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v35() String)\r
+(declare-fun v36() a1)\r
+(declare-fun v37() a1)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v38() a2)\r
+(declare-fun v39() Bool)\r
+(pop 1)\r
+(define-funs-rec ((fa((v38 a2)(v39 Bool))a2)(f9((v35 String)(v36 a1)(v37 a1))String)(f8((v2e a2)(v2f a1)(v30 a0)(v31 a2)(v32 String)(v33 Bool)(v34 Int))a0)(f7((v26 Bool)(v27 Bool)(v28 Int)(v29 a2)(v2a Int)(v2b Int)(v2c String)(v2d String))a0)(f6((v1c String)(v1d Int)(v1e a1)(v1f a0)(v20 Bool)(v21 Int)(v22 Int)(v23 String)(v24 a0)(v25 a0))Int)(f5((v14 Bool)(v15 a0)(v16 Bool)(v17 a1)(v18 a2)(v19 a0)(v1a Int)(v1b Bool))a0)(f4((v10 a1)(v11 a0)(v12 a1)(v13 Int))Bool)(f3((v9 a2)(va a1)(vb Int)(vc Bool)(vd Int)(ve Bool)(vf Bool))Int)(f2()Int)(f1((v0 a0)(v1 a2)(v2 a2)(v3 a0)(v4 Bool)(v5 a1)(v6 Bool)(v7 String)(v8 a2))Int)(f0()Bool))(v38 "\xea" (c0$3 c1$5 1 "\xc6\xff" (- 2)) c0$5 (- 9) (c0$3 c1$4 0 "" v1a) (str.< (ite (is-c0$4 v11) "\xe8" "") "\x19") 0 (- 1) 0 false))\r
+(push 1)\r
+(assert true)\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v3a() a0)\r
+(declare-fun v3b() a2)\r
+(declare-fun v3c() a2)\r
+(declare-fun v3d() a0)\r
+(declare-fun v3e() Bool)\r
+(declare-fun v3f() a1)\r
+(declare-fun v40() Bool)\r
+(declare-fun v41() String)\r
+(declare-fun v42() a2)\r
+(assert true)\r
+(assert (= (c0$4 0) v3a))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v3b))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v3c))\r
+(assert (= (c0$4 0) v3d))\r
+(assert v3e)\r
+(assert (= c1$2 v3f))\r
+(assert v40)\r
+(assert (= "\xc4\xbf)9N\xc2]" v41))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v42))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(assert true)\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v43() a2)\r
+(declare-fun v44() a1)\r
+(declare-fun v45() Int)\r
+(declare-fun v46() Bool)\r
+(declare-fun v47() Int)\r
+(declare-fun v48() Bool)\r
+(declare-fun v49() Bool)\r
+(assert true)\r
+(assert (= (c2$1 ";," c0$0 c1$4) v43))\r
+(assert (= c1$2 v44))\r
+(assert (= 9 v45))\r
+(assert v46)\r
+(assert (= 9 v47))\r
+(assert v48)\r
+(assert v49)\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v4a() a1)\r
+(declare-fun v4b() a0)\r
+(declare-fun v4c() a1)\r
+(declare-fun v4d() Int)\r
+(assert (not (f4 v4a v4b v4c v4d)))\r
+(assert (= c1$2 v4a))\r
+(assert (= (c0$4 0) v4b))\r
+(assert (= c1$2 v4c))\r
+(assert (= 9 v4d))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v4e() Bool)\r
+(declare-fun v4f() a0)\r
+(declare-fun v50() Bool)\r
+(declare-fun v51() a1)\r
+(declare-fun v52() a2)\r
+(declare-fun v53() a0)\r
+(declare-fun v54() Int)\r
+(declare-fun v55() Bool)\r
+(assert (= (c0$3 c1$4 0 "" 9) (f5 v4e v4f v50 v51 v52 v53 v54 v55)))\r
+(assert v4e)\r
+(assert (= (c0$4 0) v4f))\r
+(assert v50)\r
+(assert (= c1$2 v51))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v52))\r
+(assert (= (c0$4 0) v53))\r
+(assert (= 9 v54))\r
+(assert v55)\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v56() String)\r
+(declare-fun v57() Int)\r
+(declare-fun v58() a1)\r
+(declare-fun v59() a0)\r
+(declare-fun v5a() Bool)\r
+(declare-fun v5b() Int)\r
+(declare-fun v5c() Int)\r
+(declare-fun v5d() String)\r
+(declare-fun v5e() a0)\r
+(declare-fun v5f() a0)\r
+(assert true)\r
+(assert (= "\xc4\xbf)9N\xc2]" v56))\r
+(assert (= 9 v57))\r
+(assert (= c1$2 v58))\r
+(assert (= (c0$4 0) v59))\r
+(assert v5a)\r
+(assert (= 9 v5b))\r
+(assert (= 9 v5c))\r
+(assert (= "\xc4\xbf)9N\xc2]" v5d))\r
+(assert (= (c0$4 0) v5e))\r
+(assert (= (c0$4 0) v5f))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v60() Bool)\r
+(declare-fun v61() Bool)\r
+(declare-fun v62() Int)\r
+(declare-fun v63() a2)\r
+(declare-fun v64() Int)\r
+(declare-fun v65() Int)\r
+(declare-fun v66() String)\r
+(declare-fun v67() String)\r
+(assert true)\r
+(assert v60)\r
+(assert v61)\r
+(assert (= 9 v62))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v63))\r
+(assert (= 9 v64))\r
+(assert (= 9 v65))\r
+(assert (= "\xc4\xbf)9N\xc2]" v66))\r
+(assert (= "\xc4\xbf)9N\xc2]" v67))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v68() a2)\r
+(declare-fun v69() a1)\r
+(declare-fun v6a() a0)\r
+(declare-fun v6b() a2)\r
+(declare-fun v6c() String)\r
+(declare-fun v6d() Bool)\r
+(declare-fun v6e() Int)\r
+(assert true)\r
+(assert (= (c2$1 ";," c0$0 c1$4) v68))\r
+(assert (= c1$2 v69))\r
+(assert (= (c0$4 0) v6a))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v6b))\r
+(assert (= "\xc4\xbf)9N\xc2]" v6c))\r
+(assert v6d)\r
+(assert (= 9 v6e))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v6f() String)\r
+(declare-fun v70() a1)\r
+(declare-fun v71() a1)\r
+(assert true)\r
+(assert (= "\xc4\xbf)9N\xc2]" v6f))\r
+(assert (= c1$2 v70))\r
+(assert (= c1$2 v71))\r
+(check-sat)\r
+(pop 1)\r
+(push 1)\r
+(declare-fun v72() a2)\r
+(declare-fun v73() Bool)\r
+(assert (= (c2$1 ";," c0$0 c1$4) (fa v72 v73)))\r
+(assert (= (c2$1 ";," c0$0 c1$4) v72))\r
+(assert v73)\r
+(check-sat)\r
+(pop 1)\r
+(exit)\r