Skip to content

Commit 9873b7a

Browse files
thomasspriggsEnrico Steffinlongo
authored andcommitted
Add array type to sort conversion
This is sufficient for supporting the conversion of the generated expressions for non-deterministically initialised arrays. However it is not yet straight forward to regression test without support for the conversion of further kinds of expression. This is because the initialisation would be sliced away if the result of the initialisation is not read back later on.
1 parent f461894 commit 9873b7a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ static smt_sortt convert_type_to_smt_sort(const bitvector_typet &type)
8989
return smt_bit_vector_sortt{type.get_width()};
9090
}
9191

92+
static smt_sortt convert_type_to_smt_sort(const array_typet &type)
93+
{
94+
return smt_array_sortt{
95+
convert_type_to_smt_sort(type.index_type()),
96+
convert_type_to_smt_sort(type.element_type())};
97+
}
98+
9299
smt_sortt convert_type_to_smt_sort(const typet &type)
93100
{
94101
if(const auto bool_type = type_try_dynamic_cast<bool_typet>(type))
@@ -99,6 +106,10 @@ smt_sortt convert_type_to_smt_sort(const typet &type)
99106
{
100107
return convert_type_to_smt_sort(*bitvector_type);
101108
}
109+
if(const auto array_type = type_try_dynamic_cast<array_typet>(type))
110+
{
111+
return convert_type_to_smt_sort(*array_type);
112+
}
102113
UNIMPLEMENTED_FEATURE("Generation of SMT formula for type: " + type.pretty());
103114
}
104115

unit/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ expr_to_smt_conversion_test_environmentt::convert(const exprt &expression) const
9696
object_size_function.make_application);
9797
}
9898

99+
TEST_CASE("\"array_typet\" to smt sort conversion", "[core][smt2_incremental]")
100+
{
101+
auto test =
102+
expr_to_smt_conversion_test_environmentt::make(test_archt::x86_64);
103+
104+
const auto array_type =
105+
array_typet{signedbv_typet{8}, from_integer(8, c_index_type())};
106+
INFO("Type being converted: " + array_type.pretty(2, 0));
107+
const auto conversion_result = convert_type_to_smt_sort(array_type);
108+
CHECK(
109+
conversion_result ==
110+
smt_array_sortt{smt_bit_vector_sortt{64}, smt_bit_vector_sortt{8}});
111+
}
112+
99113
TEST_CASE("\"symbol_exprt\" to smt term conversion", "[core][smt2_incremental]")
100114
{
101115
auto test = expr_to_smt_conversion_test_environmentt::make(test_archt::i386);

0 commit comments

Comments
 (0)