@@ -193,20 +193,22 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
193
193
symbol_exprt contains=fresh_boolean (" contains_substring" );
194
194
195
195
// We add axioms:
196
- // a1 : contains ==> offset <= from_index && offset <= |haystack| - |needle|
196
+ // a1 : contains ==> -1 <= offset && offset <= from_index
197
+ // && offset <= |haystack| - |needle|
197
198
// a2 : !contains <=> offset = -1
198
- // a3 : forall n:[0, needle.length [,
199
+ // a3 : forall n:[0, | needle| [,
199
200
// contains ==> haystack[n+offset] = needle[n]
200
201
// a4 : forall n:[offset+1, min(from_index, |haystack| - |needle|)].
201
202
// contains ==>
202
- // (exists m:[0,|substring |[. haystack[m+n] != needle[m]])
203
+ // (exists m:[0,|needle |[. haystack[m+n] != needle[m]])
203
204
// a5: forall n:[0, min(from_index, |haystack| - |needle|)].
204
205
// !contains ==>
205
- // (exists m:[0,|substring |[. haystack[m+n] != needle[m])
206
+ // (exists m:[0,|needle |[. haystack[m+n] != needle[m])
206
207
207
208
implies_exprt a1 (
208
209
contains,
209
210
and_exprt (
211
+ binary_relation_exprt (from_integer (-1 , index_type), ID_le, offset),
210
212
binary_relation_exprt (
211
213
offset, ID_le, minus_exprt (haystack.length (), needle.length ())),
212
214
binary_relation_exprt (offset, ID_le, from_index)));
@@ -255,8 +257,8 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
255
257
{
256
258
// Unfold the existential quantifier as a disjunction in case of a constant
257
259
// a4 && a5 <=> a6:
258
- // forall n:[0, min(from_index,|haystack|- |needle|)].
259
- // !contains || n > offset ==>
260
+ // forall n:[0, min(from_index, |haystack| - |needle|)].
261
+ // !contains || ( n > offset) ==>
260
262
// haystack[n] != needle[0] || ... ||
261
263
// haystack[n+|needle|-1] != needle[|needle|-1]
262
264
symbol_exprt qvar2=fresh_univ_index (" QA_index_of_string_2" , index_type);
@@ -273,6 +275,7 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
273
275
274
276
or_exprt premise (
275
277
not_exprt (contains), binary_relation_exprt (qvar2, ID_gt, offset));
278
+
276
279
string_constraintt a6 (
277
280
qvar2,
278
281
from_integer (0 , index_type),
0 commit comments