@@ -1079,11 +1079,16 @@ exprt fill_in_array_expr(const array_exprt &expr, std::size_t string_max_length)
1079
1079
// / * for an access in an empty array `{ }[x]` returns a fresh symbol, this
1080
1080
// / corresponds to a non-deterministic result
1081
1081
// / \param expr: an expression containing array accesses
1082
+ // / \param symbol_generator: function which given a prefix and a type generates
1083
+ // / a fresh symbol of the given type
1082
1084
// / \return an expression containing no array access
1083
- static void substitute_array_access (exprt &expr)
1085
+ static void substitute_array_access (
1086
+ exprt &expr,
1087
+ const std::function<symbol_exprt(const irep_idt &, const typet &)>
1088
+ &symbol_generator)
1084
1089
{
1085
1090
for (auto &op : expr.operands ())
1086
- substitute_array_access (op);
1091
+ substitute_array_access (op, symbol_generator );
1087
1092
1088
1093
if (expr.id ()==ID_index)
1089
1094
{
@@ -1112,9 +1117,9 @@ static void substitute_array_access(exprt &expr)
1112
1117
// Substitute recursively in branches of conditional expressions
1113
1118
if_exprt if_expr=to_if_expr (index_expr.array ());
1114
1119
exprt true_case=index_exprt (if_expr.true_case (), index_expr.index ());
1115
- substitute_array_access (true_case);
1120
+ substitute_array_access (true_case, symbol_generator );
1116
1121
exprt false_case=index_exprt (if_expr.false_case (), index_expr.index ());
1117
- substitute_array_access (false_case);
1122
+ substitute_array_access (false_case, symbol_generator );
1118
1123
expr=if_exprt (if_expr.cond (), true_case, false_case);
1119
1124
return ;
1120
1125
}
@@ -1131,7 +1136,7 @@ static void substitute_array_access(exprt &expr)
1131
1136
// Access to an empty array is undefined (non deterministic result)
1132
1137
if (array_expr.operands ().empty ())
1133
1138
{
1134
- expr = symbol_exprt (" out_of_bound_access" , char_type);
1139
+ expr = symbol_generator (" out_of_bound_access" , char_type);
1135
1140
return ;
1136
1141
}
1137
1142
@@ -1348,6 +1353,12 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
1348
1353
const auto eom=messaget::eom;
1349
1354
static const std::string indent = " " ;
1350
1355
static const std::string indent2 = " " ;
1356
+ // clang-format off
1357
+ const auto gen_symbol = [&](const irep_idt &id, const typet &type)
1358
+ {
1359
+ return generator.fresh_symbol (id, type);
1360
+ };
1361
+ // clang-format on
1351
1362
1352
1363
stream << " string_refinementt::check_axioms:" << eom;
1353
1364
@@ -1389,7 +1400,8 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
1389
1400
negaxiom = simplify_expr (negaxiom, ns);
1390
1401
exprt with_concretized_arrays =
1391
1402
concretize_arrays_in_expression (negaxiom, max_string_length, ns);
1392
- substitute_array_access (with_concretized_arrays);
1403
+
1404
+ substitute_array_access (with_concretized_arrays, gen_symbol);
1393
1405
1394
1406
stream << indent << i << " .\n " ;
1395
1407
debug_check_axioms_step (
@@ -1445,7 +1457,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
1445
1457
exprt with_concrete_arrays =
1446
1458
concretize_arrays_in_expression (negaxiom, max_string_length, ns);
1447
1459
1448
- substitute_array_access (with_concrete_arrays);
1460
+ substitute_array_access (with_concrete_arrays, gen_symbol );
1449
1461
1450
1462
stream << indent << i << " .\n " ;
1451
1463
debug_check_axioms_step (
0 commit comments