Skip to content

Commit 02e508e

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Array logic: support with_exprt with multiple updates
A with_exprt can hold any odd number (>=3) of operands, where each pair after the first operand is an (index, value) entry.
1 parent bff0c7e commit 02e508e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/solvers/flattening/arrays.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ void arrayst::collect_arrays(const exprt &a)
123123
collect_arrays(with_expr.old());
124124

125125
// make sure this shows as an application
126-
index_exprt index_expr(with_expr.old(), with_expr.where());
127-
record_array_index(index_expr);
126+
for(std::size_t i = 1; i < with_expr.operands().size(); i += 2)
127+
{
128+
index_exprt index_expr(with_expr.old(), with_expr.operands()[i]);
129+
record_array_index(index_expr);
130+
}
128131
}
129132
else if(a.id()==ID_update)
130133
{
@@ -501,13 +504,21 @@ void arrayst::add_array_constraints(
501504
void arrayst::add_array_constraints_with(
502505
const index_sett &index_set,
503506
const with_exprt &expr)
507+
{
508+
const exprt::operandst &operands = expr.operands();
509+
for(std::size_t i = 1; i + 1 < operands.size(); i += 2)
510+
add_array_constraints_with(index_set, expr, operands[i], operands[i + 1]);
511+
}
512+
513+
void arrayst::add_array_constraints_with(
514+
const index_sett &index_set,
515+
const with_exprt &expr,
516+
const exprt &index,
517+
const exprt &value)
504518
{
505519
// we got x=(y with [i:=v])
506520
// add constraint x[i]=v
507521

508-
const exprt &index=expr.where();
509-
const exprt &value=expr.new_value();
510-
511522
{
512523
index_exprt index_expr(expr, index, expr.type().subtype());
513524

src/solvers/flattening/arrays.h

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ class arrayst:public equalityt
111111
const index_sett &index_set, const if_exprt &exprt);
112112
void add_array_constraints_with(
113113
const index_sett &index_set, const with_exprt &expr);
114+
void add_array_constraints_with(
115+
const index_sett &index_set,
116+
const with_exprt &expr,
117+
const exprt &index,
118+
const exprt &value);
114119
void add_array_constraints_update(
115120
const index_sett &index_set, const update_exprt &expr);
116121
void add_array_constraints_array_of(

0 commit comments

Comments
 (0)