Skip to content

Commit 2d16c2c

Browse files
Correct comments and axioms in lastIndexOf
This new version should be clearer and the added axioms match the comments.
1 parent 68cdc6f commit 2d16c2c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/solvers/refinement/string_constraint_generator_indexof.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
221221
symbol_exprt contains=fresh_boolean("contains_substring");
222222

223223
// We add axioms:
224-
// a1 : contains => |substring| >= length && offset <= from_index
224+
// a1 : contains => offset <= from_index && offset <= |haystack| - |needle|
225225
// a2 : !contains <=> offset=-1
226226
// a3 : forall n:[0, substring.length[,
227227
// contains => str[n+offset]=substring[n]
@@ -235,8 +235,8 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
235235
implies_exprt a1(
236236
contains,
237237
and_exprt(
238-
haystack.axiom_for_is_longer_than(
239-
plus_exprt_with_overflow_check(needle.length(), offset)),
238+
binary_relation_exprt(
239+
offset, ID_le, minus_exprt(haystack.length(), needle.length())),
240240
binary_relation_exprt(offset, ID_le, from_index)));
241241
axioms.push_back(a1);
242242

0 commit comments

Comments
 (0)