Skip to content

Commit c6c0029

Browse files
committed
Flattening of ID_nondet_symbol for unbounded arrays
1 parent b03abfc commit c6c0029

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/solvers/flattening/arrays.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ void arrayst::collect_arrays(const exprt &a)
182182
else if(a.id()==ID_member)
183183
{
184184
DATA_INVARIANT(
185-
to_member_expr(a).struct_op().id()==ID_symbol,
186-
("unexpected array expression: member with `"+
187-
a.op0().id_string()+"'").c_str());
185+
to_member_expr(a).struct_op().id() == ID_symbol ||
186+
to_member_expr(a).struct_op().id() == ID_nondet_symbol,
187+
("unexpected array expression: member with `" + a.op0().id_string() + "'")
188+
.c_str());
188189
}
189190
else if(a.id()==ID_constant ||
190191
a.id()==ID_array ||
@@ -458,8 +459,10 @@ void arrayst::add_array_constraints(
458459
expr.id()==ID_string_constant)
459460
{
460461
}
461-
else if(expr.id()==ID_member &&
462-
to_member_expr(expr).struct_op().id()==ID_symbol)
462+
else if(
463+
expr.id() == ID_member &&
464+
(to_member_expr(expr).struct_op().id() == ID_symbol ||
465+
to_member_expr(expr).struct_op().id() == ID_nondet_symbol))
463466
{
464467
}
465468
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/refinement/string_refinement.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,10 +1120,10 @@ static exprt substitute_array_access(
11201120
*if_expr, index_expr.index(), symbol_generator, left_propagate);
11211121

11221122
INVARIANT(
1123-
array.is_nil() || array.id() == ID_symbol,
1123+
array.is_nil() || array.id() == ID_symbol || array.id() == ID_nondet_symbol,
11241124
std::string(
1125-
"in case the array is unknown, it should be a symbol or nil, id: ")
1126-
+ id2string(array.id()));
1125+
"in case the array is unknown, it should be a symbol or nil, id: ") +
1126+
id2string(array.id()));
11271127
return index_expr;
11281128
}
11291129

@@ -1693,7 +1693,9 @@ static void initial_index_set(
16931693
const exprt &s,
16941694
const exprt &i)
16951695
{
1696-
PRECONDITION(s.id() == ID_symbol || s.id() == ID_array || s.id() == ID_if);
1696+
PRECONDITION(
1697+
s.id() == ID_symbol || s.id() == ID_nondet_symbol || s.id() == ID_array ||
1698+
s.id() == ID_if);
16971699
if(s.id() == ID_array)
16981700
{
16991701
for(std::size_t j = 0; j < s.operands().size(); ++j)
@@ -1995,11 +1997,11 @@ exprt string_refinementt::get(const exprt &expr) const
19951997
}
19961998

19971999
INVARIANT(
1998-
array.is_nil() || array.id() == ID_symbol,
1999-
std::string(
2000-
"apart from symbols, array valuations can be interpreted as "
2001-
"sparse arrays, id: ") +
2002-
id2string(array.id()));
2000+
array.is_nil() || array.id() == ID_symbol ||
2001+
array.id() == ID_nondet_symbol,
2002+
std::string("apart from symbols, array valuations can be interpreted as "
2003+
"sparse arrays, id: ") +
2004+
id2string(array.id()));
20032005
return index_exprt(array, index);
20042006
}
20052007

0 commit comments

Comments
 (0)