Fix bug in strict symbolic length strip (#8973)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Tue, 19 Jul 2022 15:21:54 +0000 (10:21 -0500)
committerGitHub <noreply@github.com>
Tue, 19 Jul 2022 15:21:54 +0000 (15:21 +0000)
Leads to incorrect rewrites. Fixes #8970.

src/theory/strings/strings_entail.cpp
test/regress/cli/CMakeLists.txt
test/regress/cli/regress1/strings/issue8970-strip-sym-len.smt2 [new file with mode: 0644]

index a9e77615e248766d2659c5ef46e3604cd96863d2..e5111c94a8e7bc163a31cc761646f814d33b7935 100644 (file)
@@ -202,7 +202,12 @@ bool StringsEntail::stripSymbolicLength(std::vector<Node>& n1,
       }
     }
   }
-  if (sindex > 0 && (!strict || curr == zero))
+  if (strict && curr != zero)
+  {
+    // return false if we did not strip the entire length
+    ret = false;
+  }
+  else if (sindex > 0)
   {
     if (dir == 1)
     {
index 51836ea021817191e37b60c813c79919e17e0db2..41bf5cac9d5de840a9d4640d6c0040ca365a1a51 100644 (file)
@@ -2657,6 +2657,7 @@ set(regress_1_tests
   regress1/strings/issue8918-str-nth-crange-red.smt2
   regress1/strings/issue8932-cmi-unit.smt2
   regress1/strings/issue8944-sygus-inst.smt2
+  regress1/strings/issue8970-strip-sym-len.smt2
   regress1/strings/kaluza-fl.smt2
   regress1/strings/loop002.smt2
   regress1/strings/loop003.smt2
diff --git a/test/regress/cli/regress1/strings/issue8970-strip-sym-len.smt2 b/test/regress/cli/regress1/strings/issue8970-strip-sym-len.smt2
new file mode 100644 (file)
index 0000000..f44d5ae
--- /dev/null
@@ -0,0 +1,8 @@
+; EXPECT: sat
+(set-logic QF_SLIA)
+(declare-fun t () String)
+(assert (str.prefixof "-" (str.substr t 0 1)))
+(assert (> (str.len (str.substr t 0 2)) 1))
+(assert (= "-0" (str.update "-0" 0 t)))
+(assert (str.suffixof (str.replace t "-0" "-") "-"))
+(check-sat)