@@ -155,16 +155,20 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
155
155
symbol_exprt contains=fresh_boolean (" contains_substring" );
156
156
157
157
// We add axioms:
158
- // a1 : contains => |substring| >= length &&offset <= from_index
158
+ // a1 : contains => |str|-| substring|>=offset && offset<= from_index
159
159
// a2 : !contains => offset=-1
160
- // a3 : forall 0 <= witness<substring.length ,
160
+ // a3 : forall 0<= witness<| substring| ,
161
161
// contains => str[witness+offset]=substring[witness]
162
+ // a4 : forall n:[offset+1[, |str|-|substring|[.
163
+ // contains => (exists m:[0,|substring|[. str[n+m]!=substring[m]])
164
+ // a5: forall n:[0,|str|-|substring|[.
165
+ // !contains => (exists m:[0,|substring|[. str[n+m]!=substring[m])
162
166
163
167
implies_exprt a1 (
164
168
contains,
165
169
and_exprt (
166
- str.axiom_for_is_longer_than (
167
- plus_exprt_with_overflow_check ( substring.length (), offset)),
170
+ str.axiom_for_is_longer_than (plus_exprt_with_overflow_check (
171
+ substring.length (), offset)),
168
172
binary_relation_exprt (offset, ID_le, from_index)));
169
173
axioms.push_back (a1);
170
174
@@ -174,10 +178,33 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
174
178
axioms.push_back (a2);
175
179
176
180
symbol_exprt qvar=fresh_univ_index (" QA_index_of_string" , index_type);
177
- equal_exprt constr3 (str[plus_exprt (qvar, offset)], substring[qvar]);
178
- string_constraintt a3 (qvar, substring.length (), contains, constr3);
181
+ string_constraintt a3 (
182
+ qvar,
183
+ substring.length (),
184
+ contains,
185
+ equal_exprt (str[plus_exprt (qvar, offset)], substring[qvar]));
179
186
axioms.push_back (a3);
180
187
188
+ string_not_contains_constraintt a4 (
189
+ plus_exprt_with_overflow_check (offset, from_integer (1 , index_type)),
190
+ minus_exprt (str.length (), substring.length ()),
191
+ contains,
192
+ from_integer (0 , index_type),
193
+ substring.length (),
194
+ str,
195
+ substring);
196
+ axioms.push_back (a4);
197
+
198
+ string_not_contains_constraintt a5 (
199
+ from_integer (0 , index_type),
200
+ minus_exprt (str.length (), substring.length ()),
201
+ not_exprt (contains),
202
+ from_integer (0 , index_type),
203
+ substring.length (),
204
+ str,
205
+ substring);
206
+ axioms.push_back (a5);
207
+
181
208
return offset;
182
209
}
183
210
0 commit comments