Skip to content

Commit 707ed94

Browse files
Refactoring in axioms for lastIndexOf(char)
Making some variable constants, use notequal_exprt and smaller similar changes.
1 parent e1f30e1 commit 707ed94

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/solvers/refinement/string_constraint_generator_indexof.cpp

+12-16
Original file line numberDiff line numberDiff line change
@@ -331,44 +331,40 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of(
331331
const exprt &from_index)
332332
{
333333
const typet &index_type = str.length().type();
334-
symbol_exprt index=fresh_exist_index("last_index_of", index_type);
335-
symbol_exprt contains=fresh_boolean("contains_in_last_index_of");
334+
const symbol_exprt index = fresh_exist_index("last_index_of", index_type);
335+
const symbol_exprt contains = fresh_boolean("contains_in_last_index_of");
336336

337-
exprt minus1=from_integer(-1, index_type);
338-
and_exprt a1(
337+
const exprt minus1 = from_integer(-1, index_type);
338+
const and_exprt a1(
339339
binary_relation_exprt(index, ID_ge, minus1),
340-
binary_relation_exprt(index, ID_lt, from_index_plus_one),
340+
binary_relation_exprt(index, ID_le, from_index),
341341
binary_relation_exprt(index, ID_lt, str.length()));
342342
axioms.push_back(a1);
343343

344-
equal_exprt a2(not_exprt(contains), equal_exprt(index, minus1));
344+
const notequal_exprt a2(contains, equal_exprt(index, minus1));
345345
axioms.push_back(a2);
346346

347-
implies_exprt a3(
348-
contains,
349-
and_exprt(
350-
binary_relation_exprt(from_index, ID_ge, index),
351-
equal_exprt(str[index], c)));
347+
const implies_exprt a3(contains, equal_exprt(str[index], c));
352348
axioms.push_back(a3);
353349

354-
symbol_exprt n=fresh_univ_index("QA_last_index_of1", index_type);
355-
string_constraintt a4(
356350
const exprt index1 = from_integer(1, index_type);
357351
const plus_exprt from_index_plus_one(from_index, index1);
358352
const if_exprt end_index(
359353
binary_relation_exprt(from_index_plus_one, ID_le, str.length()),
360354
from_index_plus_one,
361355
str.length());
362356

357+
const symbol_exprt n = fresh_univ_index("QA_last_index_of1", index_type);
358+
const string_constraintt a4(
363359
n,
364360
plus_exprt(index, index1),
365361
end_index,
366362
contains,
367-
not_exprt(equal_exprt(str[n], c)));
363+
notequal_exprt(str[n], c));
368364
axioms.push_back(a4);
369365

370-
symbol_exprt m=fresh_univ_index("QA_last_index_of2", index_type);
371-
string_constraintt a5(
366+
const symbol_exprt m = fresh_univ_index("QA_last_index_of2", index_type);
367+
const string_constraintt a5(
372368
m, end_index, not_exprt(contains), notequal_exprt(str[m], c));
373369
axioms.push_back(a5);
374370

0 commit comments

Comments
 (0)