Skip to content

Commit 9a7fa2d

Browse files
Correct lower bound in String indexOf
1 parent 682cd1a commit 9a7fa2d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/solvers/refinement/string_constraint_generator_indexof.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ exprt string_constraint_generatort::add_axioms_for_index_of(
5959
equal_exprt(str[index], c)));
6060
axioms.push_back(a3);
6161

62+
const auto zero = from_integer(0, index_type);
63+
const if_exprt lower_bound(
64+
binary_relation_exprt(from_index, ID_le, zero), zero, from_index);
65+
6266
symbol_exprt n=fresh_univ_index("QA_index_of", index_type);
6367
string_constraintt a4(
64-
n, from_index, index, contains, not_exprt(equal_exprt(str[n], c)));
68+
n, lower_bound, index, contains, not_exprt(equal_exprt(str[n], c)));
6569
axioms.push_back(a4);
6670

6771
symbol_exprt m=fresh_univ_index("QA_index_of", index_type);
6872
string_constraintt a5(
6973
m,
70-
from_index,
74+
lower_bound,
7175
str.length(),
7276
not_exprt(contains),
7377
not_exprt(equal_exprt(str[m], c)));

0 commit comments

Comments
 (0)