Skip to content

Commit 915bb93

Browse files
committed
Flattening of ID_nondet_symbol for unbounded arrays
symbol_exprt and nondet_symbol_exprt are to be treated the same when in comes to the back-end: they both introduce an uninterpreted, nullary function. Note the difference at the level of symbolic execution/programs, where the value of symbols may change (while the value of nondet_symbol_exprts cannot).
1 parent 0bf061b commit 915bb93

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/solvers/flattening/arrays.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ void arrayst::collect_arrays(const exprt &a)
181181
else if(a.id()==ID_member)
182182
{
183183
DATA_INVARIANT(
184-
to_member_expr(a).struct_op().id()==ID_symbol,
185-
("unexpected array expression: member with `"+
186-
a.op0().id_string()+"'").c_str());
184+
to_member_expr(a).struct_op().id() == ID_symbol ||
185+
to_member_expr(a).struct_op().id() == ID_nondet_symbol,
186+
("unexpected array expression: member with `" + a.op0().id_string() + "'")
187+
.c_str());
187188
}
188189
else if(a.id()==ID_constant ||
189190
a.id()==ID_array ||
@@ -451,8 +452,10 @@ void arrayst::add_array_constraints(
451452
expr.id()==ID_string_constant)
452453
{
453454
}
454-
else if(expr.id()==ID_member &&
455-
to_member_expr(expr).struct_op().id()==ID_symbol)
455+
else if(
456+
expr.id() == ID_member &&
457+
(to_member_expr(expr).struct_op().id() == ID_symbol ||
458+
to_member_expr(expr).struct_op().id() == ID_nondet_symbol))
456459
{
457460
}
458461
else if(expr.id()==ID_byte_update_little_endian ||

src/solvers/flattening/boolbv_index.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ bvt boolbvt::convert_index(const index_exprt &expr)
5151

5252
// record type if array is a symbol
5353

54-
if(array.id()==ID_symbol)
55-
map.get_map_entry(
56-
to_symbol_expr(array).get_identifier(), array_type);
54+
if(array.id() == ID_symbol || array.id() == ID_nondet_symbol)
55+
map.get_map_entry(array.get(ID_identifier), array_type);
5756

5857
// make sure we have the index in the cache
5958
convert_bv(index);

src/solvers/strings/string_refinement.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ static exprt substitute_array_access(
11271127
*if_expr, index_expr.index(), symbol_generator, left_propagate);
11281128

11291129
INVARIANT(
1130-
array.is_nil() || array.id() == ID_symbol,
1130+
array.is_nil() || array.id() == ID_symbol || array.id() == ID_nondet_symbol,
11311131
std::string(
11321132
"in case the array is unknown, it should be a symbol or nil, id: ") +
11331133
id2string(array.id()));
@@ -1700,7 +1700,9 @@ static void initial_index_set(
17001700
const exprt &s,
17011701
const exprt &i)
17021702
{
1703-
PRECONDITION(s.id() == ID_symbol || s.id() == ID_array || s.id() == ID_if);
1703+
PRECONDITION(
1704+
s.id() == ID_symbol || s.id() == ID_nondet_symbol || s.id() == ID_array ||
1705+
s.id() == ID_if);
17041706
if(s.id() == ID_array)
17051707
{
17061708
for(std::size_t j = 0; j < s.operands().size(); ++j)
@@ -2002,7 +2004,8 @@ exprt string_refinementt::get(const exprt &expr) const
20022004
}
20032005

20042006
INVARIANT(
2005-
array.is_nil() || array.id() == ID_symbol,
2007+
array.is_nil() || array.id() == ID_symbol ||
2008+
array.id() == ID_nondet_symbol,
20062009
std::string("apart from symbols, array valuations can be interpreted as "
20072010
"sparse arrays, id: ") +
20082011
id2string(array.id()));

0 commit comments

Comments
 (0)