Skip to content

Commit ff25fe2

Browse files
Weaken invariant for nil exprt as model of array
nil_exprt happens when the underlying solver has no formula talking about the array
1 parent 56e7b37 commit ff25fe2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/solvers/refinement/string_refinement.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,6 @@ static exprt substitute_array_access(
11231123
const bool left_propagate)
11241124
{
11251125
const exprt &array = index_expr.array();
1126-
1127-
if(array.id() == ID_symbol)
1128-
return index_expr;
11291126
if(auto array_of = expr_try_dynamic_cast<array_of_exprt>(array))
11301127
return array_of->op();
11311128
if(auto array_with = expr_try_dynamic_cast<with_exprt>(array))
@@ -1138,7 +1135,12 @@ static exprt substitute_array_access(
11381135
return substitute_array_access(
11391136
*if_expr, index_expr.index(), symbol_generator, left_propagate);
11401137

1141-
UNREACHABLE;
1138+
INVARIANT(
1139+
array.is_nil() || array.id() == ID_symbol,
1140+
std::string(
1141+
"in case the array is unknown, it should be a symbol or nil, id: ")
1142+
+ id2string(array.id()));
1143+
return index_expr;
11421144
}
11431145

11441146
/// Auxiliary function for substitute_array_access
@@ -2121,9 +2123,11 @@ exprt string_refinementt::get(const exprt &expr) const
21212123
}
21222124

21232125
INVARIANT(
2124-
array.id() == ID_symbol,
2125-
"apart from symbols, array valuations can be interpreted as sparse "
2126-
"arrays");
2126+
array.is_nil() || array.id() == ID_symbol,
2127+
std::string(
2128+
"apart from symbols, array valuations can be interpreted as "
2129+
"sparse arrays, id: ") +
2130+
id2string(array.id()));
21272131
return index_exprt(array, index);
21282132
}
21292133

0 commit comments

Comments
 (0)