|
2 | 2 |
|
3 | 3 | #include "smt2_incremental_decision_procedure.h"
|
4 | 4 |
|
| 5 | +#include <util/arith_tools.h> |
5 | 6 | #include <util/expr.h>
|
6 | 7 | #include <util/namespace.h>
|
7 | 8 | #include <util/nodiscard.h>
|
@@ -78,23 +79,21 @@ static std::vector<exprt> gather_dependent_expressions(const exprt &expr)
|
78 | 79 | void smt2_incremental_decision_proceduret::define_array_function(
|
79 | 80 | const array_exprt &array)
|
80 | 81 | {
|
81 |
| - const auto array_sort = |
82 |
| - convert_type_to_smt_sort(array.type()).cast<smt_array_sortt>(); |
| 82 | + const smt_sortt array_sort = convert_type_to_smt_sort(array.type()); |
83 | 83 | INVARIANT(
|
84 |
| - array_sort, |
| 84 | + array_sort.cast<smt_array_sortt>(), |
85 | 85 | "Converting array typed expression to SMT should result in a term of array "
|
86 | 86 | "sort.");
|
87 | 87 | const smt_identifier_termt array_identifier = smt_identifier_termt{
|
88 |
| - "array_" + std::to_string(array_sequence()), *array_sort}; |
| 88 | + "array_" + std::to_string(array_sequence()), array_sort}; |
89 | 89 | solver_process->send(smt_declare_function_commandt{array_identifier, {}});
|
90 | 90 | const std::vector<exprt> &elements = array.operands();
|
91 |
| - const std::size_t index_width = |
92 |
| - array_sort->index_sort().cast<smt_bit_vector_sortt>()->bit_width(); |
| 91 | + const typet &index_type = array.type().index_type(); |
93 | 92 | for(std::size_t i = 0; i < elements.size(); ++i)
|
94 | 93 | {
|
| 94 | + const smt_termt index = convert_expr_to_smt(from_integer(i, index_type)); |
95 | 95 | const smt_assert_commandt element_definition{smt_core_theoryt::equal(
|
96 |
| - smt_array_theoryt::select( |
97 |
| - array_identifier, smt_bit_vector_constant_termt{i, index_width}), |
| 96 | + smt_array_theoryt::select(array_identifier, index), |
98 | 97 | convert_expr_to_smt(elements.at(i)))};
|
99 | 98 | solver_process->send(element_definition);
|
100 | 99 | }
|
|
0 commit comments