51 template <
typename factoryt>
55 const factoryt &factory)
58 const auto operand_terms =
60 return converted.at(expr);
62 return std::accumulate(
63 ++operand_terms.begin(),
65 *operand_terms.begin(),
73 template <
typename target_typet>
78 return can_cast_type<target_typet>(operand.type());
101 if(
const auto bool_type = type_try_dynamic_cast<bool_typet>(type))
105 if(
const auto bitvector_type = type_try_dynamic_cast<bitvector_typet>(type))
109 if(
const auto array_type = type_try_dynamic_cast<array_typet>(type))
152 const std::size_t c_bool_width = to_type.
get_width();
159 static std::function<std::function<smt_termt(smt_termt)>(std::size_t)>
178 if(
const auto to_fixedbv_type = type_try_dynamic_cast<fixedbv_typet>(to_type))
181 "Generation of SMT formula for type cast to fixed-point bitvector "
185 if(
const auto to_floatbv_type = type_try_dynamic_cast<floatbv_typet>(to_type))
188 "Generation of SMT formula for type cast to floating-point bitvector "
192 const std::size_t from_width =
from_type.get_width();
193 const std::size_t to_width = to_type.
get_width();
194 if(to_width == from_width)
196 if(to_width < from_width)
198 const std::size_t extension_size = to_width - from_width;
226 if(
const auto bitvector = type_try_dynamic_cast<bitvector_typet>(
from_type))
230 "Generation of SMT formula for type cast to bit vector from type: " +
237 "Generation of SMT formula for type cast to bit vector from type: " +
251 return *converter.result;
258 const auto &from_term = converted.at(cast.
op());
261 if(
const auto bool_type = type_try_dynamic_cast<bool_typet>(to_type))
263 if(
const auto c_bool_type = type_try_dynamic_cast<c_bool_typet>(to_type))
265 if(
const auto bit_vector = type_try_dynamic_cast<bitvector_typet>(to_type))
268 "Generation of SMT formula for type cast expression: " + cast.
pretty());
276 "Generation of SMT formula for floating point type cast expression: " +
285 "Generation of SMT formula for struct construction expression: " +
286 struct_construction.
pretty());
294 "Generation of SMT formula for union construction expression: " +
295 union_construction.
pretty());
315 const auto &width = bit_vector_sort.
bit_width();
325 "Conversion of array SMT literal " + array_sort.
pretty());
333 const size_t bit_width =
334 type_checked_cast<pointer_typet>(constant_literal.
type()).get_width();
337 const auto address = 0;
346 const auto value = numeric_cast_v<mp_integer>(constant_literal);
351 sort.accept(converter);
359 if(operands_are_of_type<bitvector_typet>(concatenation))
365 "Generation of SMT formula for concatenation expression: " +
373 if(operands_are_of_type<bitvector_typet>(bitwise_and_expr))
381 "Generation of SMT formula for bitwise and expression: " +
382 bitwise_and_expr.
pretty());
390 if(operands_are_of_type<bitvector_typet>(bitwise_or_expr))
398 "Generation of SMT formula for bitwise or expression: " +
399 bitwise_or_expr.
pretty());
407 if(operands_are_of_type<bitvector_typet>(
bitwise_xor))
415 "Generation of SMT formula for bitwise xor expression: " +
431 "Generation of SMT formula for bitnot_exprt: " + bitwise_not.
pretty());
446 "Generation of SMT formula for unary minus expression: " +
456 "Generation of SMT formula for unary plus expression: " +
465 "Generation of SMT formula for \"is negative\" expression: " +
474 converted.at(if_expression.
cond()),
508 converted.at(implies.
op0()), converted.at(implies.
op1()));
523 converted.at(equal.
op0()), converted.at(equal.
op1()));
531 converted.at(not_equal.
op0()), converted.at(not_equal.
op1()));
539 "Generation of SMT formula for floating point equality expression: " +
548 "Generation of SMT formula for floating point not equal expression: " +
549 float_not_equal.
pretty());
552 template <
typename unsigned_factory_typet,
typename signed_factory_typet>
555 const unsigned_factory_typet &unsigned_factory,
556 const signed_factory_typet &signed_factory,
560 const auto &lhs = converted.at(binary_relation.
lhs());
561 const auto &rhs = converted.at(binary_relation.
rhs());
562 const typet operand_type = binary_relation.
lhs().
type();
571 const auto lhs_type_is_pointer =
573 const auto rhs_type_is_pointer =
576 lhs_type_is_pointer && rhs_type_is_pointer,
577 "pointer comparison requires that both operand types are pointers.");
578 return unsigned_factory(lhs, rhs);
583 return unsigned_factory(lhs, rhs);
585 return signed_factory(lhs, rhs);
589 "Generation of SMT formula for relational expression: " +
590 binary_relation.
pretty());
597 if(
const auto greater_than = expr_try_dynamic_cast<greater_than_exprt>(expr))
606 const auto greater_than_or_equal =
607 expr_try_dynamic_cast<greater_than_or_equal_exprt>(expr))
610 *greater_than_or_equal,
615 if(
const auto less_than = expr_try_dynamic_cast<less_than_exprt>(expr))
624 const auto less_than_or_equal =
625 expr_try_dynamic_cast<less_than_or_equal_exprt>(expr))
643 return can_cast_type<integer_bitvector_typet>(operand.type());
653 "We are only handling a binary version of plus when it has a pointer "
658 for(
auto &operand : plus.
operands())
674 "An addition expression with both operands being pointers when they are "
675 "not dereferenced is malformed");
678 *type_try_dynamic_cast<pointer_typet>(pointer.
type());
680 const auto pointer_size = pointer_sizes.at(base_type);
683 converted.at(pointer),
689 "Generation of SMT formula for plus expression: " + plus.
pretty());
698 const bool both_operands_bitvector =
705 const bool both_operands_pointers = lhs_is_pointer && rhs_is_pointer;
709 const bool one_operand_pointer = lhs_is_pointer || rhs_is_pointer;
711 if(both_operands_bitvector)
714 converted.at(minus.
lhs()), converted.at(minus.
rhs()));
716 else if(both_operands_pointers)
721 lhs_base_type == rhs_base_type,
722 "only pointers of the same object type can be subtracted.");
725 converted.at(minus.
lhs()), converted.at(minus.
rhs())),
726 pointer_sizes.at(lhs_base_type));
728 else if(one_operand_pointer)
734 "minus expressions of pointer and integer expect lhs to be the pointer");
738 converted.at(minus.
lhs()),
740 converted.at(minus.
rhs()), pointer_sizes.at(lhs_base_type)));
745 "Generation of SMT formula for minus expression: " + minus.
pretty());
756 const bool both_operands_bitvector =
760 const bool both_operands_unsigned =
764 if(both_operands_bitvector)
766 if(both_operands_unsigned)
778 "Generation of SMT formula for divide expression: " + divide.
pretty());
789 "Generation of SMT formula for floating point operation expression: " +
790 float_operation.
pretty());
797 const smt_termt &lhs = converted.at(truncation_modulo.
lhs());
798 const smt_termt &rhs = converted.at(truncation_modulo.
rhs());
800 const bool both_operands_bitvector =
804 const bool both_operands_unsigned =
808 if(both_operands_bitvector)
810 if(both_operands_unsigned)
822 "Generation of SMT formula for remainder (modulus) expression: " +
823 truncation_modulo.
pretty());
832 "Generation of SMT formula for euclidean modulo expression: " +
833 euclidean_modulo.
pretty());
844 return can_cast_type<integer_bitvector_typet>(operand.type());
853 "Generation of SMT formula for multiply expression: " +
870 const auto type = type_try_dynamic_cast<pointer_typet>(address_of.
type());
872 type,
"Result of the address_of operator should have pointer type.");
874 const auto object = object_map.find(base);
876 object != object_map.end(),
877 "Objects should be tracked before converting their address to SMT terms");
878 const std::size_t object_id =
object->second.unique_id;
880 const std::size_t max_objects = std::size_t(1) << object_bits;
881 if(object_id >= max_objects)
884 "too many addressed objects: maximum number of objects is set to 2^n=" +
887 "use the `--object-bits n` option to increase the maximum number"};
892 type->get_width() > object_bits,
893 "Pointer should be wider than object_bits in order to allow for offset "
895 const size_t offset_bits = type->get_width() - object_bits;
898 expr_try_dynamic_cast<symbol_exprt>(address_of.
object()))
904 "Generation of SMT formula for address of expression: " +
923 "Generation of SMT formula for array comprehension expression: " +
924 array_comprehension.
pretty());
936 template <
typename factoryt,
typename shiftt>
938 const factoryt &factory,
942 const smt_termt &first_operand = converted.at(shift.op0());
943 const smt_termt &second_operand = converted.at(shift.op1());
944 const auto first_bit_vector_sort =
946 const auto second_bit_vector_sort =
949 first_bit_vector_sort && second_bit_vector_sort,
950 "Shift expressions are expected to have bit vector operands.");
952 shift.type() == shift.op0().type(),
953 "Shift expression type must be equals to first operand type.");
954 const std::size_t first_width = first_bit_vector_sort->bit_width();
955 const std::size_t second_width = second_bit_vector_sort->
bit_width();
956 if(first_width > second_width)
963 else if(first_width < second_width)
965 const auto result = factory(
973 return factory(first_operand, second_operand);
982 if(
const auto left_shift = expr_try_dynamic_cast<shl_exprt>(shift))
987 if(
const auto right_logical_shift = expr_try_dynamic_cast<lshr_exprt>(shift))
991 *right_logical_shift,
994 if(
const auto right_arith_shift = expr_try_dynamic_cast<ashr_exprt>(shift))
1002 "Generation of SMT formula for shift expression: " + shift.
pretty());
1010 for(
auto it = ++with.
operands().begin(); it != with.
operands().end(); it += 2)
1012 const smt_termt &index_term = converted.at(it[0]);
1013 const smt_termt &value_term = converted.at(it[1]);
1028 "Generation of SMT formula for with expression: " + with.
pretty());
1036 "Generation of SMT formula for update expression: " + update.
pretty());
1044 "Generation of SMT formula for member extraction expression: " +
1045 member_extraction.
pretty());
1056 pointer_sort,
"Pointers should be encoded as bit vector sorted terms.");
1057 const std::size_t pointer_width = pointer_sort->bit_width();
1058 return apply_is_dynamic_object(
1071 type_try_dynamic_cast<bitvector_typet>(pointer_expr.
type());
1076 width >= object_bits,
1077 "Width should be at least as big as the number of object bits.");
1080 width - 1, width - object_bits)(converted.at(pointer_expr));
1095 "Generation of SMT formula for string constant expression: " +
1096 string_constant.
pretty());
1104 "Generation of SMT formula for extract bit expression: " +
1112 const smt_termt &from = converted.at(extract_bits.
src());
1113 const auto bit_vector_sort =
1116 bit_vector_sort,
"Extract can only be applied to bit vector terms.");
1117 const auto index_value = numeric_cast<std::size_t>(extract_bits.
index());
1120 *index_value + bit_vector_sort->bit_width() - 1, *index_value)(from);
1122 "Generation of SMT formula for extract bits expression: " +
1131 "Generation of SMT formula for bit vector replication expression: " +
1140 "Generation of SMT formula for byte extract expression: " +
1141 byte_extraction.
pretty());
1149 "Generation of SMT formula for byte update expression: " +
1158 "Generation of SMT formula for absolute value of expression: " +
1159 absolute_value_of.
pretty());
1167 "Generation of SMT formula for is not a number expression: " +
1176 "Generation of SMT formula for is finite expression: " +
1177 is_finite_expr.
pretty());
1185 "Generation of SMT formula for is infinite expression: " +
1186 is_infinite_expr.
pretty());
1194 "Generation of SMT formula for is infinite expression: " +
1195 is_normal_expr.
pretty());
1206 "Most significant bit can only be extracted from bit vector terms.");
1207 const size_t most_significant_bit_index = bit_vector_sort->bit_width() - 1;
1209 most_significant_bit_index, most_significant_bit_index);
1218 const smt_termt &left = converted.at(plus_overflow.
lhs());
1219 const smt_termt &right = converted.at(plus_overflow.
rhs());
1220 if(operands_are_of_type<unsignedbv_typet>(plus_overflow))
1226 if(operands_are_of_type<signedbv_typet>(plus_overflow))
1239 "Generation of SMT formula for plus overflow expression: " +
1247 const smt_termt &left = converted.at(minus_overflow.
lhs());
1248 const smt_termt &right = converted.at(minus_overflow.
rhs());
1249 if(operands_are_of_type<unsignedbv_typet>(minus_overflow))
1253 if(operands_are_of_type<signedbv_typet>(minus_overflow))
1271 "Generation of SMT formula for minus overflow expression: " +
1272 minus_overflow.
pretty());
1280 const auto &operand_type = mult_overflow.
lhs().
type();
1281 const smt_termt &left = converted.at(mult_overflow.
lhs());
1282 const smt_termt &right = converted.at(mult_overflow.
rhs());
1284 const auto unsigned_type =
1285 type_try_dynamic_cast<unsignedbv_typet>(operand_type))
1287 const std::size_t width = unsigned_type->get_width();
1294 const auto signed_type =
1295 type_try_dynamic_cast<signedbv_typet>(operand_type))
1299 const std::size_t width = signed_type->get_width();
1301 const auto multiplication =
1314 "Generation of SMT formula for multiply overflow expression: " +
1324 INVARIANT(type,
"Pointer object should have a bitvector-based type.");
1325 const auto converted_expr = converted.at(
pointer_object.pointer());
1326 const std::size_t width = type->get_width();
1329 width >= object_bits,
1330 "Width should be at least as big as the number of object bits.");
1331 const std::size_t ext = width - object_bits;
1333 width - 1, width - object_bits)(converted_expr);
1347 INVARIANT(type,
"Pointer offset should have a bitvector-based type.");
1348 const auto converted_expr = converted.at(
pointer_offset.pointer());
1349 const std::size_t width = type->get_width();
1351 if(offset_bits > width)
1352 offset_bits = width;
1353 const auto extract_op =
1355 if(width > offset_bits)
1367 "Generation of SMT formula for shift left overflow expression: " +
1386 "Generation of SMT formula for literal expression: " + literal.
pretty());
1394 "Generation of SMT formula for for all expression: " + for_all.
pretty());
1402 "Generation of SMT formula for exists expression: " +
exists.pretty());
1410 "Generation of SMT formula for vector expression: " + vector.
pretty());
1421 pointer_sort,
"Pointers should be encoded as bit vector sorted terms.");
1422 const std::size_t pointer_width = pointer_sort->bit_width();
1423 return call_object_size(
1433 "Generation of SMT formula for let expression: " + let.
pretty());
1441 "Generation of SMT formula for byte swap expression: " +
1450 "Generation of SMT formula for population count expression: " +
1451 population_count.
pretty());
1459 "Generation of SMT formula for count leading zeros expression: " +
1460 count_leading_zeros.
pretty());
1468 "Generation of SMT formula for count trailing zeros expression: " +
1469 count_trailing_zeros.
pretty());
1477 "zero_extend expression should have been lowered by the decision "
1478 "procedure before conversion to smt terms");
1486 "prophecy_r_or_w_ok expression should have been lowered by the decision "
1487 "procedure before conversion to smt terms");
1495 "prophecy_pointer_in_range expression should have been lowered by the "
1496 "decision procedure before conversion to smt terms");
1507 if(
const auto symbol = expr_try_dynamic_cast<symbol_exprt>(expr))
1511 if(
const auto nondet = expr_try_dynamic_cast<nondet_symbol_exprt>(expr))
1515 if(
const auto cast = expr_try_dynamic_cast<typecast_exprt>(expr))
1520 const auto float_cast = expr_try_dynamic_cast<floatbv_typecast_exprt>(expr))
1524 if(
const auto struct_construction = expr_try_dynamic_cast<struct_exprt>(expr))
1528 if(
const auto union_construction = expr_try_dynamic_cast<union_exprt>(expr))
1532 if(
const auto constant_literal = expr_try_dynamic_cast<constant_exprt>(expr))
1537 const auto concatenation = expr_try_dynamic_cast<concatenation_exprt>(expr))
1541 if(
const auto bitwise_and_expr = expr_try_dynamic_cast<bitand_exprt>(expr))
1545 if(
const auto bitwise_or_expr = expr_try_dynamic_cast<bitor_exprt>(expr))
1549 if(
const auto bitwise_xor = expr_try_dynamic_cast<bitxor_exprt>(expr))
1553 if(
const auto bitwise_not = expr_try_dynamic_cast<bitnot_exprt>(expr))
1557 if(
const auto unary_minus = expr_try_dynamic_cast<unary_minus_exprt>(expr))
1561 if(
const auto unary_plus = expr_try_dynamic_cast<unary_plus_exprt>(expr))
1565 if(
const auto is_negative = expr_try_dynamic_cast<sign_exprt>(expr))
1569 if(
const auto if_expression = expr_try_dynamic_cast<if_exprt>(expr))
1573 if(
const auto and_expression = expr_try_dynamic_cast<and_exprt>(expr))
1577 if(
const auto or_expression = expr_try_dynamic_cast<or_exprt>(expr))
1581 if(
const auto xor_expression = expr_try_dynamic_cast<xor_exprt>(expr))
1585 if(
const auto implies = expr_try_dynamic_cast<implies_exprt>(expr))
1589 if(
const auto logical_not = expr_try_dynamic_cast<not_exprt>(expr))
1593 if(
const auto equal = expr_try_dynamic_cast<equal_exprt>(expr))
1597 if(
const auto not_equal = expr_try_dynamic_cast<notequal_exprt>(expr))
1602 const auto float_equal =
1603 expr_try_dynamic_cast<ieee_float_equal_exprt>(expr))
1608 const auto float_not_equal =
1609 expr_try_dynamic_cast<ieee_float_notequal_exprt>(expr))
1614 const auto converted_relational =
1617 return *converted_relational;
1619 if(
const auto plus = expr_try_dynamic_cast<plus_exprt>(expr))
1623 if(
const auto minus = expr_try_dynamic_cast<minus_exprt>(expr))
1627 if(
const auto divide = expr_try_dynamic_cast<div_exprt>(expr))
1632 const auto float_operation =
1633 expr_try_dynamic_cast<ieee_float_op_exprt>(expr))
1637 if(
const auto truncation_modulo = expr_try_dynamic_cast<mod_exprt>(expr))
1642 const auto euclidean_modulo =
1643 expr_try_dynamic_cast<euclidean_mod_exprt>(expr))
1647 if(
const auto multiply = expr_try_dynamic_cast<mult_exprt>(expr))
1652 else if(expr.
id() == ID_floatbv_rem)
1657 if(
const auto address_of = expr_try_dynamic_cast<address_of_exprt>(expr))
1661 if(
const auto array_of = expr_try_dynamic_cast<array_of_exprt>(expr))
1666 const auto array_comprehension =
1667 expr_try_dynamic_cast<array_comprehension_exprt>(expr))
1671 if(
const auto index = expr_try_dynamic_cast<index_exprt>(expr))
1675 if(
const auto shift = expr_try_dynamic_cast<shift_exprt>(expr))
1679 if(
const auto with = expr_try_dynamic_cast<with_exprt>(expr))
1683 if(
const auto update = expr_try_dynamic_cast<update_exprt>(expr))
1687 if(
const auto member_extraction = expr_try_dynamic_cast<member_exprt>(expr))
1693 expr_try_dynamic_cast<pointer_offset_exprt>(expr))
1699 expr_try_dynamic_cast<pointer_object_exprt>(expr))
1704 const auto is_dynamic_object =
1705 expr_try_dynamic_cast<is_dynamic_object_exprt>(expr))
1708 *is_dynamic_object, converted, apply_is_dynamic_object);
1711 const auto is_invalid_pointer =
1712 expr_try_dynamic_cast<is_invalid_pointer_exprt>(expr))
1716 if(
const auto string_constant = expr_try_dynamic_cast<string_constantt>(expr))
1720 if(
const auto extract_bit = expr_try_dynamic_cast<extractbit_exprt>(expr))
1724 if(
const auto extract_bits = expr_try_dynamic_cast<extractbits_exprt>(expr))
1728 if(
const auto replication = expr_try_dynamic_cast<replication_exprt>(expr))
1733 const auto byte_extraction =
1734 expr_try_dynamic_cast<byte_extract_exprt>(expr))
1738 if(
const auto byte_update = expr_try_dynamic_cast<byte_update_exprt>(expr))
1742 if(
const auto absolute_value_of = expr_try_dynamic_cast<abs_exprt>(expr))
1746 if(
const auto is_nan_expr = expr_try_dynamic_cast<isnan_exprt>(expr))
1750 if(
const auto is_finite_expr = expr_try_dynamic_cast<isfinite_exprt>(expr))
1754 if(
const auto is_infinite_expr = expr_try_dynamic_cast<isinf_exprt>(expr))
1758 if(
const auto is_normal_expr = expr_try_dynamic_cast<isnormal_exprt>(expr))
1763 const auto plus_overflow = expr_try_dynamic_cast<plus_overflow_exprt>(expr))
1768 const auto minus_overflow =
1769 expr_try_dynamic_cast<minus_overflow_exprt>(expr))
1774 const auto mult_overflow = expr_try_dynamic_cast<mult_overflow_exprt>(expr))
1778 if(
const auto shl_overflow = expr_try_dynamic_cast<shl_overflow_exprt>(expr))
1782 if(
const auto array_construction = expr_try_dynamic_cast<array_exprt>(expr))
1786 if(
const auto literal = expr_try_dynamic_cast<literal_exprt>(expr))
1790 if(
const auto for_all = expr_try_dynamic_cast<forall_exprt>(expr))
1794 if(
const auto exists = expr_try_dynamic_cast<exists_exprt>(expr))
1798 if(
const auto vector = expr_try_dynamic_cast<vector_exprt>(expr))
1802 if(
const auto object_size = expr_try_dynamic_cast<object_size_exprt>(expr))
1806 if(
const auto let = expr_try_dynamic_cast<let_exprt>(expr))
1811 expr.
id() != ID_constraint_select_one,
1812 "constraint_select_one is not expected in smt conversion: " +
1814 if(
const auto byte_swap = expr_try_dynamic_cast<bswap_exprt>(expr))
1818 if(
const auto population_count = expr_try_dynamic_cast<popcount_exprt>(expr))
1823 const auto count_leading_zeros =
1824 expr_try_dynamic_cast<count_leading_zeros_exprt>(expr))
1829 const auto count_trailing_zeros =
1830 expr_try_dynamic_cast<count_trailing_zeros_exprt>(expr))
1834 if(
const auto zero_extend = expr_try_dynamic_cast<zero_extend_exprt>(expr))
1839 const auto prophecy_r_or_w_ok =
1840 expr_try_dynamic_cast<prophecy_r_or_w_ok_exprt>(expr))
1845 const auto prophecy_pointer_in_range =
1846 expr_try_dynamic_cast<prophecy_pointer_in_range_exprt>(expr))
1852 "Generation of SMT formula for unknown kind of expression: " +
1856 #ifndef CPROVER_INVARIANT_DO_NOT_CHECK
1857 template <
typename functiont>
1871 template <
typename functiont>
1881 const auto address_of_expr = expr_try_dynamic_cast<address_of_exprt>(expr);
1882 if(!address_of_expr)
1884 const auto array_index_expr =
1885 expr_try_dynamic_cast<index_exprt>(address_of_expr->object());
1886 if(!array_index_expr)
1890 array_index_expr->array(),
1891 type_checked_cast<pointer_typet>(address_of_expr->type())},
1892 array_index_expr->index()};
1902 std::function<
bool(
const exprt &)> filter,
1903 std::function<
void(
const exprt &)> visitor)
1908 bool operands_pushed;
1909 explicit stack_entryt(
const exprt *_e) : e(_e), operands_pushed(
false)
1914 std::stack<stack_entryt> stack;
1916 stack.emplace(&_expr);
1918 while(!stack.empty())
1920 auto &top = stack.top();
1921 if(top.operands_pushed)
1929 top.operands_pushed =
true;
1931 for(
auto &op : top.e->operands())
1944 #ifndef CPROVER_INVARIANT_DO_NOT_CHECK
1945 static bool in_conversion =
false;
1948 "Conversion of expr to smt should be non-recursive. "
1949 "Re-entrance found in conversion of " +
1951 in_conversion =
true;
1952 const auto end_conversion =
at_scope_exit([&]() { in_conversion =
false; });
1958 [](
const exprt &expr) {
1963 const auto address_of = expr_try_dynamic_cast<address_of_exprt>(expr);
1968 [&](
const exprt &expr) {
1969 const auto find_result = sub_expression_map.find(expr);
1970 if(find_result != sub_expression_map.cend())
1979 sub_expression_map.emplace_hint(find_result, expr, std::move(term));
1981 return std::move(sub_expression_map.at(lowered_expr));
API to expression classes for bitvectors.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
bool can_cast_type< signedbv_typet >(const typet &type)
Check whether a reference to a typet is a signedbv_typet.
bool can_cast_type< integer_bitvector_typet >(const typet &type)
Check whether a reference to a typet is an integer_bitvector_typet.
bool can_cast_type< bv_typet >(const typet &type)
Check whether a reference to a typet is a bv_typet.
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
bool can_cast_type< unsignedbv_typet >(const typet &type)
Check whether a reference to a typet is a unsignedbv_typet.
Expression classes for byte-level operators.
pointer_typet pointer_type(const typet &subtype)
Operator to return the address of an object.
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
Expression to define a mapping from an argument (index) to elements.
Array constructor from list of elements.
Array constructor from single element.
typet index_type() const
The type of the index expressions into any instance of this type.
const typet & element_type() const
The type of the elements of the array.
A base class for relations, i.e., binary predicates whose two operands have the same type.
Bit-wise negation of bit-vectors.
Base class of fixed-width bit-vector types.
std::size_t get_width() const
The byte swap expression.
Expression corresponding to op() where the bytes starting at position offset (given in number of byte...
Concatenation of bit-vector operands.
struct configt::bv_encodingt bv_encoding
A constant literal expression.
const irep_idt & get_value() const
bool is_null_pointer() const
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
The count trailing zeros (counting the number of zero bits starting from the least-significant bit) e...
Boute's Euclidean definition of Modulo – to match SMT-LIB2.
Base class for all expressions.
bool is_true() const
Return whether the expression is a constant representing true.
void visit_pre(std::function< void(exprt &)>)
typet & type()
Return the type of the expression.
Semantic type conversion from/to floating-point formats.
IEEE-floating-point equality.
IEEE floating-point disequality.
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
The trinary if-then-else operator.
Unbounded, signed integers (mathematical integers, not bitvectors)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irep_idt & id() const
Evaluates to true if the operand is a pointer to a dynamic object.
Evaluates to true if the operand is finite.
Evaluates to true if the operand is infinite.
Evaluates to true if the operand is NaN.
Evaluates to true if the operand is a normal number.
Extract member of struct or union.
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Binary multiplication Associativity is not specified.
A base class for multi-ary expressions Associativity is not specified.
Expression to hold a nondeterministic choice.
const irep_idt & get_identifier() const
Expression for finding the size (in bytes) of the object a pointer points to.
The plus expression Associativity is not specified.
A numerical identifier for the object a pointer points to.
The offset (in bytes) of a pointer relative to the object.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const typet & base_type() const
The type of the data what we point to.
The popcount (counting the number of bits set to 1) expression.
pointer_in_range (see pointer_in_range_exprt) with prophecy expressions to encode whether a pointer r...
A base class for a predicate that indicates that an address range is ok to read or write or both.
A base class for shift and rotate operators.
Sign of an expression Predicate is true if _op is negative, false otherwise.
static const smt_function_application_termt::factoryt< storet > store
static const smt_function_application_termt::factoryt< selectt > select
std::size_t bit_width() const
static const smt_function_application_termt::factoryt< ort > make_or
static const smt_function_application_termt::factoryt< unsigned_less_than_or_equalt > unsigned_less_than_or_equal
static const smt_function_application_termt::factoryt< signed_less_than_or_equalt > signed_less_than_or_equal
static const smt_function_application_termt::factoryt< addt > add
static const smt_function_application_termt::factoryt< arithmetic_shift_rightt > arithmetic_shift_right
static const smt_function_application_termt::factoryt< signed_greater_than_or_equalt > signed_greater_than_or_equal
static const smt_function_application_termt::factoryt< unsigned_greater_thant > unsigned_greater_than
static const smt_function_application_termt::factoryt< unsigned_remaindert > unsigned_remainder
static const smt_function_application_termt::factoryt< unsigned_greater_than_or_equalt > unsigned_greater_than_or_equal
static const smt_function_application_termt::factoryt< xort > make_xor
static const smt_function_application_termt::factoryt< nott > make_not
static const smt_function_application_termt::factoryt< shift_leftt > shift_left
static const smt_function_application_termt::factoryt< multiplyt > multiply
static smt_function_application_termt::factoryt< sign_extendt > sign_extend(std::size_t i)
static const smt_function_application_termt::factoryt< signed_less_thant > signed_less_than
static smt_function_application_termt::factoryt< zero_extendt > zero_extend(std::size_t i)
static smt_function_application_termt::factoryt< extractt > extract(std::size_t i, std::size_t j)
Makes a factory for extract function applications.
static const smt_function_application_termt::factoryt< signed_greater_thant > signed_greater_than
static const smt_function_application_termt::factoryt< logical_shift_rightt > logical_shift_right
static const smt_function_application_termt::factoryt< negatet > negate
Arithmetic negation in two's complement.
static const smt_function_application_termt::factoryt< concatt > concat
static const smt_function_application_termt::factoryt< unsigned_dividet > unsigned_divide
static const smt_function_application_termt::factoryt< unsigned_less_thant > unsigned_less_than
static const smt_function_application_termt::factoryt< signed_dividet > signed_divide
static const smt_function_application_termt::factoryt< signed_remaindert > signed_remainder
static const smt_function_application_termt::factoryt< subtractt > subtract
static const smt_function_application_termt::factoryt< andt > make_and
static const smt_function_application_termt::factoryt< distinctt > distinct
Makes applications of the function which returns true iff its two arguments are not identical.
static const smt_function_application_termt::factoryt< if_then_elset > if_then_else
static const smt_function_application_termt::factoryt< impliest > implies
static const smt_function_application_termt::factoryt< ort > make_or
static const smt_function_application_termt::factoryt< equalt > equal
static const smt_function_application_termt::factoryt< andt > make_and
static const smt_function_application_termt::factoryt< xort > make_xor
static const smt_function_application_termt::factoryt< nott > make_not
Stores identifiers in unescaped and unquoted form.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const sub_classt * cast() const &
void accept(smt_sort_const_downcast_visitort &) const
const smt_sortt & get_sort() const
Struct constructor from list of elements.
Expression to hold a symbol (variable)
const irep_idt & get_identifier() const
Semantic type conversion.
The type of an expression, extends irept.
The unary minus expression.
The unary plus expression.
Union constructor from single element.
Operator to update elements in structs and arrays.
Vector constructor from list of elements.
Operator to update elements in structs and arrays.
zero extension The operand is converted to the given type by either a) truncating if the new type is ...
static std::function< std::function< smt_termt(smt_termt)>std::size_t)> extension_for_type(const typet &type)
void filtered_visit_post(const exprt &_expr, std::function< bool(const exprt &)> filter, std::function< void(const exprt &)> visitor)
Post order traversal where the children of a node are only visited if applying the filter function to...
exprt lower_address_of_array_index(exprt expr)
Lower the address_of(array[idx]) sub expressions in expr to idx + address_of(array),...
static smt_termt convert_bit_vector_cast(const smt_termt &from_term, const typet &from_type, const bitvector_typet &to_type)
static smt_termt most_significant_bit_is_set(const smt_termt &input)
Constructs a term which is true if the most significant bit of input is set.
static smt_termt convert_array_update_to_smt(const with_exprt &with, const sub_expression_mapt &converted)
static smt_termt make_bitvector_resize_cast(const smt_termt &from_term, const bitvector_typet &from_type, const bitvector_typet &to_type)
static std::optional< smt_termt > try_relational_conversion(const exprt &expr, const sub_expression_mapt &converted)
static smt_termt convert_multiary_operator_to_terms(const multi_ary_exprt &expr, const sub_expression_mapt &converted, const factoryt &factory)
Converts operator expressions with 2 or more operands to terms expressed as binary operator applicati...
std::unordered_map< exprt, smt_termt, irep_hash > sub_expression_mapt
Post order visitation is used in order to construct the the smt terms bottom upwards without using re...
static smt_termt make_not_zero(const smt_termt &input, const typet &source_type)
Makes a term which is true if input is not 0 / false.
static smt_termt convert_relational_to_smt(const binary_relation_exprt &binary_relation, const unsigned_factory_typet &unsigned_factory, const signed_factory_typet &signed_factory, const sub_expression_mapt &converted)
static smt_termt dispatch_expr_to_smt_conversion(const exprt &expr, const sub_expression_mapt &converted, const smt_object_mapt &object_map, const type_size_mapt &pointer_sizes, const smt_object_sizet::make_applicationt &call_object_size, const smt_is_dynamic_objectt::make_applicationt &apply_is_dynamic_object)
static smt_termt convert_to_smt_shift(const factoryt &factory, const shiftt &shift, const sub_expression_mapt &converted)
static smt_sortt convert_type_to_smt_sort(const bool_typet &type)
at_scope_exitt< functiont > at_scope_exit(functiont exit_function)
static smt_termt convert_c_bool_cast(const smt_termt &from_term, const typet &from_type, const bitvector_typet &to_type)
Returns a cast to C bool expressed in smt terms.
static bool operands_are_of_type(const exprt &expr)
Ensures that all operands of the argument expression have related types.
static smt_termt convert_expr_to_smt(const symbol_exprt &symbol_expr)
Templated functions to cast to specific exprt-derived classes.
API to expression classes for floating-point arithmetic.
std::string from_type(const namespacet &ns, const irep_idt &identifier, const typet &type)
API to expression classes for 'mathematical' expressions.
mini_bddt exists(const mini_bddt &u, const unsigned var)
mp_integer bitwise_xor(const mp_integer &a, const mp_integer &b)
bitwise 'xor' of two nonnegative integers
exprt make_invalid_pointer_expr()
Create the invalid pointer constant.
exprt find_object_base_expression(const address_of_exprt &address_of)
The model of addresses we use consists of a unique object identifier and an offset.
std::unordered_map< exprt, decision_procedure_objectt, irep_hash > smt_object_mapt
Mapping from an object's base expression to the set of information about it which we track.
API to expression classes for Pointers.
bool can_cast_type< pointer_typet >(const typet &type)
Check whether a reference to a typet is a pointer_typet.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
exprt pointer_offset(const exprt &pointer)
exprt object_size(const exprt &pointer)
exprt pointer_object(const exprt &p)
Various predicates over pointers in programs.
Ranges: pair of begin and end iterators, which can be initialized from containers,...
ranget< iteratort > make_range(iteratort begin, iteratort end)
#define UNIMPLEMENTED_FEATURE(FEATURE)
#define UNREACHABLE
This should be used to mark dead code.
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
#define POSTCONDITION(CONDITION)
#define UNREACHABLE_BECAUSE(REASON)
API to expression classes.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
bool can_cast_type< array_typet >(const typet &type)
Check whether a reference to a typet is a array_typet.
bool can_cast_type< code_typet >(const typet &type)
Check whether a reference to a typet is a code_typet.
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
binary_relation_exprt less_than(exprt lhs, exprt rhs)
binary_relation_exprt greater_than(exprt lhs, exprt rhs)
at_scope_exitt(functiont exit_function)
void visit(const smt_array_sortt &) override
const smt_termt & from_term
sort_based_cast_to_bit_vector_convertert(const smt_termt &from_term, const typet &from_type, const bitvector_typet &to_type)
void visit(const smt_bool_sortt &) override
const bitvector_typet & to_type
void visit(const smt_bit_vector_sortt &) override
std::optional< smt_termt > result
void visit(const smt_array_sortt &array_sort) override
void visit(const smt_bit_vector_sortt &bit_vector_sort) override
std::optional< smt_termt > result
const constant_exprt & member_input
void visit(const smt_bool_sortt &) override
sort_based_literal_convertert(const constant_exprt &input)
std::unordered_map< typet, smt_termt, irep_hash > type_size_mapt