Skip to content

Commit c18eb8f

Browse files
Use map-theory terminology: index→key, index_map→domain_map, remove 'array'
In a map theory the tracked expressions are 'keys' and their collection per equivalence class is the 'domain'. Rename identifiers, type aliases, function names, and comments accordingly: index_sett → key_sett index_mapt → domain_mapt index_map → domain_map update_indices → update_keys collect_indices() → collect_keys() update_index_map() → update_domain_map() record_array_index()→ record_array_key() Rename all map_theoryt members, methods, types, enum values, and comments to use map-theory terminology instead of array-specific terms: Types: array_equalityt → map_equalityt array_equalitiest → map_equalitiest array_constraint_countt → map_constraint_countt Members: array_equalities → map_equalities arrays (union-find) → maps lazy_array_constraints → lazy_constraints lazy_arrays → lazy_dispatch get_array_constraints → get_constraints array_constraint_count → constraint_count Methods: record_array_equality → record_equality record_array_let_binding→ record_let_binding record_array_key → record_key collect_arrays → collect_maps is_unbounded_array → is_unbounded_map add_array_constraint → add_map_constraint add_array_Ackermann_constraints → add_Ackermann_constraints add_array_constraints_equality → add_map_equality_constraints display_array_constraint_count → display_constraint_count finish_eager_conversion_arrays → finish_eager_conversion_maps Enum values: ARRAY_* → MAP_* C-level IR names (index_exprt, ID_index, etc.) are unchanged as they refer to the array-indexing operation, not the map-theory concept. Array-specific IR names (array_typet, index_exprt, ID_array, array_comprehension_args, etc.) and arrayst-specific method names (add_array_constraints, etc.) are unchanged. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
1 parent 6776bb8 commit c18eb8f

18 files changed

Lines changed: 362 additions & 381 deletions

src/solvers/flattening/arrays.cpp

Lines changed: 128 additions & 132 deletions
Large diffs are not rendered by default.

src/solvers/flattening/arrays.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,44 @@ class arrayst : public map_theoryt
3131
const namespacet &_ns,
3232
propt &_prop,
3333
message_handlert &message_handler,
34-
bool get_array_constraints = false);
34+
bool get_constraints = false);
3535

3636
// NOLINTNEXTLINE(readability/identifiers)
3737
typedef map_theoryt SUB;
3838

39-
literalt record_array_equality(const equal_exprt &expr) override;
39+
literalt record_equality(const equal_exprt &expr) override;
4040

4141
/// Record that \p symbol is equal to \p value for the purposes of the
4242
/// array theory. For unbounded-array-typed bindings this connects the
4343
/// two expressions in the union-find so that element-wise constraints
4444
/// propagate correctly.
45-
void record_array_let_binding(const symbol_exprt &symbol, const exprt &value)
46-
override;
45+
void
46+
record_let_binding(const symbol_exprt &symbol, const exprt &value) override;
4747

4848
protected:
4949
message_handlert &message_handler;
5050

51-
void finish_eager_conversion_arrays() override
51+
void finish_eager_conversion_maps() override
5252
{
5353
add_array_constraints();
5454
}
5555

5656
void add_array_constraints();
57-
void add_array_constraints(
58-
const index_sett &index_set, const exprt &expr);
59-
void add_array_constraints_if(
60-
const index_sett &index_set, const if_exprt &exprt);
61-
void add_array_constraints_with(
62-
const index_sett &index_set, const with_exprt &expr);
57+
void add_array_constraints(const key_sett &key_set, const exprt &expr);
58+
void add_array_constraints_if(const key_sett &key_set, const if_exprt &exprt);
59+
void
60+
add_array_constraints_with(const key_sett &key_set, const with_exprt &expr);
6361
void add_array_constraints_update(
64-
const index_sett &index_set, const update_exprt &expr);
62+
const key_sett &key_set,
63+
const update_exprt &expr);
6564
void add_array_constraints_array_of(
66-
const index_sett &index_set, const array_of_exprt &exprt);
65+
const key_sett &key_set,
66+
const array_of_exprt &exprt);
6767
void add_array_constraints_array_constant(
68-
const index_sett &index_set,
68+
const key_sett &key_set,
6969
const array_exprt &exprt);
7070
void add_array_constraints_comprehension(
71-
const index_sett &index_set,
71+
const key_sett &key_set,
7272
const array_comprehension_exprt &expr);
7373
};
7474

src/solvers/flattening/boolbv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr)
511511
type.id() != ID_bool)
512512
{
513513
// see if it is an unbounded array
514-
if(is_unbounded_array(type))
514+
if(is_unbounded_map(type))
515515
return true;
516516

517517
const bvt &bv1=convert_bv(expr.rhs());
@@ -540,7 +540,7 @@ void boolbvt::set_to(const exprt &expr, bool value)
540540
SUB::set_to(expr, value);
541541
}
542542

543-
bool boolbvt::is_unbounded_array(const typet &type) const
543+
bool boolbvt::is_unbounded_map(const typet &type) const
544544
{
545545
if(type.id()!=ID_array)
546546
return false;

src/solvers/flattening/boolbv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class boolbvt:public arrayst
5353
const namespacet &_ns,
5454
propt &_prop,
5555
message_handlert &message_handler,
56-
bool get_array_constraints = false)
57-
: arrayst(_ns, _prop, message_handler, get_array_constraints),
56+
bool get_constraints = false)
57+
: arrayst(_ns, _prop, message_handler, get_constraints),
5858
unbounded_array(unbounded_arrayt::U_NONE),
5959
bv_width(_ns),
6060
bv_utils(_prop),
@@ -267,7 +267,7 @@ class boolbvt:public arrayst
267267
exprt get_value(const exprt &expr) const;
268268

269269
// unbounded arrays
270-
bool is_unbounded_array(const typet &type) const override;
270+
bool is_unbounded_map(const typet &type) const override;
271271

272272
// quantifier instantiations
273273
class quantifiert

src/solvers/flattening/boolbv_array_of.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bvt boolbvt::convert_array_of(const array_of_exprt &expr)
2020

2121
const array_typet &array_type = expr.type();
2222

23-
if(is_unbounded_array(array_type))
23+
if(is_unbounded_map(array_type))
2424
return conversion_failed(expr);
2525

2626
std::size_t width=boolbv_width(array_type);

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
3434
{
3535
// array logic does not handle byte operators, thus lower when operating on
3636
// unbounded arrays
37-
if(is_unbounded_array(expr.op().type()))
37+
if(is_unbounded_map(expr.op().type()))
3838
{
3939
return convert_bv(lower_byte_extract(expr, ns));
4040
}

src/solvers/flattening/boolbv_byte_update.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
1717
// if we update (from) an unbounded array, lower the expression as the array
1818
// logic does not handle byte operators
1919
if(
20-
is_unbounded_array(expr.op().type()) ||
21-
is_unbounded_array(expr.value().type()))
20+
is_unbounded_map(expr.op().type()) || is_unbounded_map(expr.value().type()))
2221
{
2322
return convert_bv(lower_byte_update(expr, ns));
2423
}

src/solvers/flattening/boolbv_equality.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ literalt boolbvt::convert_equality(const equal_exprt &expr)
2222
irep_pretty_diagnosticst{expr.rhs()});
2323

2424
// see if it is an unbounded array
25-
if(is_unbounded_array(expr.lhs().type()))
25+
if(is_unbounded_map(expr.lhs().type()))
2626
{
2727
// flatten byte_update/byte_extract operators if needed
2828

2929
if(has_byte_operator(expr))
3030
{
31-
return record_array_equality(
32-
to_equal_expr(lower_byte_operators(expr, ns)));
31+
return record_equality(to_equal_expr(lower_byte_operators(expr, ns)));
3332
}
3433

35-
return record_array_equality(expr);
34+
return record_equality(expr);
3635
}
3736

3837
const bvt &lhs_bv = convert_bv(expr.lhs());

src/solvers/flattening/boolbv_get.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ exprt boolbvt::bv_get_rec(const exprt &expr, const bvt &bv, std::size_t offset)
108108
{
109109
const auto &array_type = to_array_type(type);
110110

111-
if(is_unbounded_array(type))
111+
if(is_unbounded_map(type))
112112
return bv_get_unbounded_array(expr);
113113

114114
const typet &subtype = array_type.element_type();
@@ -328,20 +328,18 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
328328
typedef std::map<mp_integer, exprt> valuest;
329329
valuest values;
330330

331-
const auto opt_num = arrays.get_number(expr);
331+
const auto opt_num = maps.get_number(expr);
332332
if(opt_num.has_value())
333333
{
334334
// get root
335-
const auto number = arrays.find_number(*opt_num);
335+
const auto number = maps.find_number(*opt_num);
336336

337-
CHECK_RETURN(number < index_map.size());
338-
index_mapt::const_iterator it=index_map.find(number);
339-
CHECK_RETURN(it != index_map.end());
340-
const index_sett &index_set=it->second;
337+
CHECK_RETURN(number < domain_map.size());
338+
domain_mapt::const_iterator it = domain_map.find(number);
339+
CHECK_RETURN(it != domain_map.end());
340+
const key_sett &key_set = it->second;
341341

342-
for(index_sett::const_iterator it1=
343-
index_set.begin();
344-
it1!=index_set.end();
342+
for(key_sett::const_iterator it1 = key_set.begin(); it1 != key_set.end();
345343
it1++)
346344
{
347345
index_exprt index(expr, *it1);

src/solvers/flattening/boolbv_index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bvt boolbvt::convert_index(const index_exprt &expr)
3434

3535
// see if the array size is constant
3636

37-
if(is_unbounded_array(array_type))
37+
if(is_unbounded_map(array_type))
3838
{
3939
// use array decision procedure
4040

@@ -65,7 +65,7 @@ bvt boolbvt::convert_index(const index_exprt &expr)
6565
// free variables
6666
bv = prop.new_variables(boolbv_width(expr.type()));
6767

68-
record_array_index(expr);
68+
record_key(expr);
6969

7070
// record type if array is a symbol
7171
if(array.id() == ID_symbol || array.id() == ID_nondet_symbol)

0 commit comments

Comments
 (0)