Go to the documentation of this file.
50 #define UNEXPECTEDCASE(S) PRECONDITION_WITH_DIAGNOSTICS(false, S);
53 #define SMT2_TODO(S) PRECONDITION_WITH_DIAGNOSTICS(false, "TODO: " S)
57 const std::string &_benchmark,
58 const std::string &_notes,
59 const std::string &_logic,
62 : use_FPA_theory(false),
63 use_array_of_bool(false),
65 use_check_sat_assuming(false),
67 use_lambda_for_array(false),
71 benchmark(_benchmark),
77 no_boolean_variables(0)
150 "variable number shall be within bounds");
156 out <<
"; SMT 2" <<
"\n";
164 out <<
"; Generated for the CPROVER SMT2 solver\n";
break;
173 out <<
"(set-info :source \"" <<
notes <<
"\")" <<
"\n";
175 out <<
"(set-option :produce-models true)" <<
"\n";
181 out <<
"(set-logic " <<
logic <<
")" <<
"\n";
194 out <<
"(check-sat-assuming (";
204 out <<
"; assumptions\n";
215 out <<
"(check-sat)\n";
223 out <<
"(get-value (" <<
id <<
"))"
231 out <<
"; end of SMT2 file"
242 std::size_t number = 0;
243 std::size_t h=pointer_width-1;
248 const typet &type = o.type();
251 numeric_cast<mp_integer>(size_expr.value_or(
nil_exprt()));
254 (o.id() != ID_symbol && o.id() != ID_string_constant) ||
255 !size_expr.has_value() || !
object_size.has_value())
261 out <<
"(assert (=> (= "
262 <<
"((_ extract " << h <<
" " << l <<
") ";
265 <<
"(= " <<
id <<
" (_ bv" << *
object_size <<
" " << size_width
281 if(expr.
id()==ID_symbol)
288 return it->second.value;
291 else if(expr.
id()==ID_nondet_symbol)
298 return it->second.value;
300 else if(expr.
id()==ID_member)
308 else if(expr.
id() == ID_literal)
316 else if(expr.
id() == ID_not)
321 else if(op.is_false())
326 else if(
const auto &array = expr_try_dynamic_cast<array_exprt>(expr))
328 exprt array_copy = *array;
329 for(
auto &element : array_copy.
operands())
331 element =
get(element);
366 if(s.size()>=2 && s[0]==
'#' && s[1]==
'b')
371 else if(s.size()>=2 && s[0]==
'#' && s[1]==
'x')
382 else if(src.
get_sub().size()==2 &&
387 else if(src.
get_sub().size()==3 &&
390 src.
get_sub()[1].id_string().substr(0, 2)==
"bv")
394 else if(src.
get_sub().size()==4 &&
397 if(type.
id()==ID_floatbv)
406 const auto s1_int = numeric_cast_v<mp_integer>(
s1);
407 const auto s2_int = numeric_cast_v<mp_integer>(
s2);
408 const auto s3_int = numeric_cast_v<mp_integer>(s3);
412 s1_int << (floatbv_type.
get_e() + floatbv_type.
get_f()),
418 else if(src.
get_sub().size()==4 &&
426 else if(src.
get_sub().size()==4 &&
434 else if(src.
get_sub().size()==4 &&
443 if(type.
id()==ID_signedbv ||
444 type.
id()==ID_unsignedbv ||
445 type.
id()==ID_c_enum ||
446 type.
id()==ID_c_bool)
450 else if(type.
id()==ID_c_enum_tag)
456 result.
type() = type;
459 else if(type.
id()==ID_fixedbv ||
460 type.
id()==ID_floatbv)
465 else if(type.
id()==ID_integer ||
473 "smt2_convt::parse_literal should not be of unsupported type " +
481 std::unordered_map<int64_t, exprt> operands_map;
485 auto maybe_default_op = operands_map.find(-1);
487 if(maybe_default_op == operands_map.end())
490 default_op = maybe_default_op->second;
492 auto maybe_size = numeric_cast<std::int64_t>(type.
size());
493 if(maybe_size.has_value())
495 while(i < maybe_size.value())
497 auto found_op = operands_map.find(i);
498 if(found_op != operands_map.end())
499 operands.emplace_back(found_op->second);
501 operands.emplace_back(default_op);
509 auto found_op = operands_map.find(i);
510 while(found_op != operands_map.end())
512 operands.emplace_back(found_op->second);
514 found_op = operands_map.find(i);
516 operands.emplace_back(default_op);
522 std::unordered_map<int64_t, exprt> *operands_map,
535 bool failure =
to_integer(index_constant, tempint);
538 long index = tempint.to_long();
540 operands_map->emplace(index, value);
542 else if(src.
get_sub().size() == 3 && src.
get_sub()[0].id() ==
"let")
547 operands_map, src.
get_sub()[1].get_sub()[0].get_sub()[1], type);
550 else if(src.
get_sub().size()==2 &&
551 src.
get_sub()[0].get_sub().size()==3 &&
552 src.
get_sub()[0].get_sub()[0].id()==
"as" &&
553 src.
get_sub()[0].get_sub()[1].id()==
"const")
557 operands_map->emplace(-1, default_value);
584 if(components.empty())
592 if(src.
get_sub().size()!=components.size()+1)
595 for(std::size_t i=0; i<components.size(); i++)
612 std::size_t offset=0;
614 for(std::size_t i=0; i<components.size(); i++)
616 std::size_t component_width=
boolbv_width(components[i].type());
619 offset + component_width <= total_width,
620 "struct component bits shall be within struct bit vector");
622 std::string component_binary=
624 total_width-offset-component_width, component_width);
629 offset+=component_width;
639 type.
id() == ID_signedbv || type.
id() == ID_unsignedbv ||
640 type.
id() == ID_integer || type.
id() == ID_rational ||
641 type.
id() == ID_real || type.
id() == ID_c_enum ||
642 type.
id() == ID_c_enum_tag || type.
id() == ID_fixedbv ||
643 type.
id() == ID_floatbv)
647 else if(type.
id()==ID_bool)
649 if(src.
id()==ID_1 || src.
id()==ID_true)
651 else if(src.
id()==ID_0 || src.
id()==ID_false)
654 else if(type.
id()==ID_pointer)
660 mp_integer v = numeric_cast_v<mp_integer>(bv_expr);
665 ptr.
object = numeric_cast_v<std::size_t>(v / pow);
671 else if(type.
id()==ID_struct)
675 else if(type.
id() == ID_struct_tag)
680 struct_expr.type() = type;
681 return std::move(struct_expr);
683 else if(type.
id()==ID_union)
687 else if(type.
id() == ID_union_tag)
691 union_expr.type() = type;
694 else if(type.
id()==ID_array)
706 if(expr.
id()==ID_symbol ||
707 expr.
id()==ID_constant ||
708 expr.
id()==ID_string_constant ||
718 else if(expr.
id()==ID_index)
727 if(array.
type().
id()==ID_pointer)
729 else if(array.
type().
id()==ID_array)
749 else if(expr.
id()==ID_member)
754 const typet &struct_op_type = struct_op.
type();
757 struct_op_type.
id() == ID_struct || struct_op_type.
id() == ID_struct_tag,
758 "member expression operand shall have struct type");
775 else if(expr.
id()==ID_if)
790 "operand of address of expression should not be of kind " +
798 if(node.
id() == ID_exists || node.
id() == ID_forall)
814 else if(expr.
id()==ID_literal)
826 out <<
"; convert\n";
827 out <<
"; Converting var_no " << l.
var_no() <<
" with expr ID of "
837 out <<
"(declare-fun ";
839 out <<
" () Bool)\n";
840 out <<
"(assert (= ";
852 out <<
"(define-fun " << identifier <<
" () Bool ";
863 if(expr.
type().
id() != ID_bool)
880 const auto identifier =
911 if(identifier.empty())
914 if(isdigit(identifier[0]))
936 std::string result =
"|";
938 for(
auto ch : identifier)
963 if(type.
id()==ID_floatbv)
968 else if(type.
id()==ID_unsignedbv)
972 else if(type.
id()==ID_c_bool)
976 else if(type.
id()==ID_signedbv)
980 else if(type.
id()==ID_bool)
984 else if(type.
id()==ID_c_enum_tag)
988 else if(type.
id() == ID_pointer)
992 else if(type.
id() == ID_struct_tag)
1016 if(expr.
id()==ID_symbol)
1023 if(expr.
id()==ID_smt2_symbol)
1031 !expr.
operands().empty(),
"non-symbol expressions shall have operands");
1049 if(expr.
id()==ID_symbol)
1055 else if(expr.
id()==ID_nondet_symbol)
1058 DATA_INVARIANT(!
id.empty(),
"nondet symbol must have identifier");
1061 else if(expr.
id()==ID_smt2_symbol)
1067 else if(expr.
id()==ID_typecast)
1071 else if(expr.
id()==ID_floatbv_typecast)
1075 else if(expr.
id()==ID_struct)
1079 else if(expr.
id()==ID_union)
1083 else if(expr.
id()==ID_constant)
1087 else if(expr.
id() == ID_concatenation && expr.
operands().size() == 1)
1091 "concatenation over a single operand should have matching types",
1096 else if(expr.
id()==ID_concatenation ||
1097 expr.
id()==ID_bitand ||
1098 expr.
id()==ID_bitor ||
1099 expr.
id()==ID_bitxor ||
1100 expr.
id()==ID_bitnand ||
1101 expr.
id()==ID_bitnor)
1105 "given expression should have at least two operands",
1110 if(expr.
id()==ID_concatenation)
1112 else if(expr.
id()==ID_bitand)
1114 else if(expr.
id()==ID_bitor)
1116 else if(expr.
id()==ID_bitxor)
1118 else if(expr.
id()==ID_bitnand)
1120 else if(expr.
id()==ID_bitnor)
1131 else if(expr.
id()==ID_bitnot)
1135 if(bitnot_expr.
type().
id() == ID_vector)
1144 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
1146 out <<
"(let ((?vectorop ";
1150 out <<
"(mk-" << smt_typename;
1157 out <<
" (bvnot (" << smt_typename <<
"." << (size-i-1)
1173 else if(expr.
id()==ID_unary_minus)
1178 unary_minus_expr.
type().
id() == ID_rational ||
1179 unary_minus_expr.
type().
id() == ID_integer ||
1180 unary_minus_expr.
type().
id() == ID_real)
1186 else if(unary_minus_expr.
type().
id() == ID_floatbv)
1198 else if(unary_minus_expr.
type().
id() == ID_vector)
1202 const std::string &smt_typename =
1209 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
1211 out <<
"(let ((?vectorop ";
1215 out <<
"(mk-" << smt_typename;
1222 out <<
" (bvneg (" << smt_typename <<
"." << (size-i-1)
1238 else if(expr.
id()==ID_unary_plus)
1243 else if(expr.
id()==ID_sign)
1249 if(op_type.
id()==ID_floatbv)
1253 out <<
"(fp.isNegative ";
1260 else if(op_type.
id()==ID_signedbv)
1266 out <<
" (_ bv0 " << op_width <<
"))";
1271 "sign should not be applied to unsupported type",
1274 else if(expr.
id()==ID_if)
1286 else if(expr.
id()==ID_and ||
1291 expr.
type().
id() == ID_bool,
1292 "logical and, or, and xor expressions should have Boolean type");
1295 "logical and, or, and xor expressions should have at least two operands");
1297 out <<
"(" << expr.
id();
1305 else if(expr.
id()==ID_implies)
1310 implies_expr.
type().
id() == ID_bool,
1311 "implies expression should have Boolean type");
1319 else if(expr.
id()==ID_not)
1324 not_expr.
type().
id() == ID_bool,
1325 "not expression should have Boolean type");
1331 else if(expr.
id() == ID_equal)
1337 "operands of equal expression shall have same type");
1345 else if(expr.
id() == ID_notequal)
1351 "operands of not equal expression shall have same type");
1359 else if(expr.
id()==ID_ieee_float_equal ||
1360 expr.
id()==ID_ieee_float_notequal)
1367 rel_expr.lhs().type() == rel_expr.rhs().type(),
1368 "operands of float equal and not equal expressions shall have same type");
1373 if(rel_expr.id() == ID_ieee_float_notequal)
1382 if(rel_expr.id() == ID_ieee_float_notequal)
1388 else if(expr.
id()==ID_le ||
1395 else if(expr.
id()==ID_plus)
1399 else if(expr.
id()==ID_floatbv_plus)
1403 else if(expr.
id()==ID_minus)
1407 else if(expr.
id()==ID_floatbv_minus)
1411 else if(expr.
id()==ID_div)
1415 else if(expr.
id()==ID_floatbv_div)
1419 else if(expr.
id()==ID_mod)
1423 else if(expr.
id() == ID_euclidean_mod)
1427 else if(expr.
id()==ID_mult)
1431 else if(expr.
id()==ID_floatbv_mult)
1435 else if(expr.
id() == ID_floatbv_rem)
1439 else if(expr.
id()==ID_address_of)
1445 else if(expr.
id() == ID_array_of)
1450 array_of_expr.type().id() == ID_array,
1451 "array of expression shall have array type");
1455 out <<
"((as const ";
1463 defined_expressionst::const_iterator it =
1469 else if(expr.
id() == ID_array_comprehension)
1474 array_comprehension.type().id() == ID_array,
1475 "array_comprehension expression shall have array type");
1479 out <<
"(lambda ((";
1482 convert_type(array_comprehension.type().size().type());
1494 else if(expr.
id()==ID_index)
1498 else if(expr.
id()==ID_ashr ||
1499 expr.
id()==ID_lshr ||
1505 if(type.
id()==ID_unsignedbv ||
1506 type.
id()==ID_signedbv ||
1509 if(shift_expr.
id() == ID_ashr)
1511 else if(shift_expr.
id() == ID_lshr)
1513 else if(shift_expr.
id() == ID_shl)
1543 if(width_op0==width_op1)
1545 else if(width_op0>width_op1)
1547 out <<
"((_ zero_extend " << width_op0-width_op1 <<
") ";
1553 out <<
"((_ extract " << width_op0-1 <<
" 0) ";
1560 "unsupported distance type for " + shift_expr.
id_string() +
": " +
1567 "unsupported type for " + shift_expr.
id_string() +
": " +
1570 else if(expr.
id() == ID_rol || expr.
id() == ID_ror)
1576 type.
id() == ID_unsignedbv || type.
id() == ID_signedbv ||
1581 if(shift_expr.
id() == ID_rol)
1582 out <<
"((_ rotate_left";
1583 else if(shift_expr.
id() == ID_ror)
1584 out <<
"((_ rotate_right";
1590 auto distance_int_op = numeric_cast<mp_integer>(shift_expr.
distance());
1592 if(distance_int_op.has_value())
1594 out << distance_int_op.value();
1598 "distance type for " + shift_expr.
id_string() +
"must be constant");
1607 "unsupported type for " + shift_expr.
id_string() +
": " +
1610 else if(expr.
id() == ID_named_term)
1614 convert(named_term_expr.value());
1618 else if(expr.
id()==ID_with)
1622 else if(expr.
id()==ID_update)
1626 else if(expr.
id()==ID_member)
1630 else if(expr.
id()==ID_pointer_offset)
1635 op.type().id() == ID_pointer,
1636 "operand of pointer offset expression shall be of pointer type");
1638 std::size_t offset_bits =
1643 if(offset_bits>result_width)
1644 offset_bits=result_width;
1647 if(result_width>offset_bits)
1648 out <<
"((_ zero_extend " << result_width-offset_bits <<
") ";
1650 out <<
"((_ extract " << offset_bits-1 <<
" 0) ";
1654 if(result_width>offset_bits)
1657 else if(expr.
id()==ID_pointer_object)
1662 op.type().id() == ID_pointer,
1663 "pointer object expressions should be of pointer type");
1669 out <<
"((_ zero_extend " << ext <<
") ";
1671 out <<
"((_ extract "
1672 << pointer_width-1 <<
" "
1680 else if(expr.
id() == ID_is_dynamic_object)
1684 else if(expr.
id() == ID_is_invalid_pointer)
1688 out <<
"(= ((_ extract "
1689 << pointer_width-1 <<
" "
1695 else if(expr.
id()==ID_string_constant)
1701 else if(expr.
id()==ID_extractbit)
1710 out <<
"(= ((_ extract " << i <<
" " << i <<
") ";
1716 out <<
"(= ((_ extract 0 0) ";
1725 else if(expr.
id()==ID_extractbits)
1739 std::swap(op1_i, op2_i);
1743 out <<
"((_ extract " << op1_i <<
" " << op2_i <<
") ";
1750 out <<
"(= ((_ extract 0 0) ";
1759 SMT2_TODO(
"smt2: extractbits with non-constant index");
1762 else if(expr.
id()==ID_replication)
1766 mp_integer times = numeric_cast_v<mp_integer>(replication_expr.
times());
1768 out <<
"((_ repeat " << times <<
") ";
1772 else if(expr.
id()==ID_byte_extract_little_endian ||
1773 expr.
id()==ID_byte_extract_big_endian)
1776 false,
"byte_extract ops should be lowered in prepare_for_convert_expr");
1778 else if(expr.
id()==ID_byte_update_little_endian ||
1779 expr.
id()==ID_byte_update_big_endian)
1782 false,
"byte_update ops should be lowered in prepare_for_convert_expr");
1784 else if(expr.
id()==ID_abs)
1790 if(type.
id()==ID_signedbv)
1794 out <<
"(ite (bvslt ";
1796 out <<
" (_ bv0 " << result_width <<
")) ";
1803 else if(type.
id()==ID_fixedbv)
1807 out <<
"(ite (bvslt ";
1809 out <<
" (_ bv0 " << result_width <<
")) ";
1816 else if(type.
id()==ID_floatbv)
1830 else if(expr.
id()==ID_isnan)
1836 if(op_type.
id()==ID_fixedbv)
1838 else if(op_type.
id()==ID_floatbv)
1842 out <<
"(fp.isNaN ";
1852 else if(expr.
id()==ID_isfinite)
1858 if(op_type.
id()==ID_fixedbv)
1860 else if(op_type.
id()==ID_floatbv)
1866 out <<
"(not (fp.isNaN ";
1870 out <<
"(not (fp.isInfinite ";
1882 else if(expr.
id()==ID_isinf)
1888 if(op_type.
id()==ID_fixedbv)
1890 else if(op_type.
id()==ID_floatbv)
1894 out <<
"(fp.isInfinite ";
1904 else if(expr.
id()==ID_isnormal)
1910 if(op_type.
id()==ID_fixedbv)
1912 else if(op_type.
id()==ID_floatbv)
1916 out <<
"(fp.isNormal ";
1929 expr.
id() == ID_overflow_result_plus ||
1930 expr.
id() == ID_overflow_result_minus)
1938 keep_result || expr.
type().
id() == ID_bool,
1939 "overflow plus and overflow minus expressions shall be of Boolean type");
1942 expr.
id() == ID_overflow_result_minus;
1943 const typet &op_type = op0.type();
1946 if(op_type.
id()==ID_signedbv)
1949 out <<
"(let ((?sum (";
1950 out << (subtract?
"bvsub":
"bvadd");
1951 out <<
" ((_ sign_extend 1) ";
1954 out <<
" ((_ sign_extend 1) ";
1964 out <<
"(mk-" << smt_typename;
1969 out <<
" ((_ extract " << width - 1 <<
" 0) ?sum) ";
1974 "((_ extract " << width <<
" " << width <<
") ?sum) "
1975 "((_ extract " << (width-1) <<
" " << (width-1) <<
") ?sum)";
1985 else if(op_type.
id()==ID_unsignedbv ||
1986 op_type.
id()==ID_pointer)
1989 out <<
"(let ((?sum (" << (subtract ?
"bvsub" :
"bvadd");
1990 out <<
" ((_ zero_extend 1) ";
1993 out <<
" ((_ zero_extend 1) ";
2005 out <<
"(mk-" << smt_typename;
2006 out <<
" ((_ extract " << width - 1 <<
" 0) ?sum) ";
2010 out <<
"((_ extract " << width <<
" " << width <<
") ?sum)";
2021 "overflow check should not be performed on unsupported type",
2026 expr.
id() == ID_overflow_result_mult)
2034 keep_result || expr.
type().
id() == ID_bool,
2035 "overflow mult expression shall be of Boolean type");
2040 const typet &op_type = op0.type();
2043 if(op_type.
id()==ID_signedbv)
2045 out <<
"(let ( (prod (bvmul ((_ sign_extend " << width <<
") ";
2047 out <<
") ((_ sign_extend " << width <<
") ";
2057 out <<
"(mk-" << smt_typename;
2062 out <<
" ((_ extract " << width - 1 <<
" 0) prod) ";
2066 out <<
"(or (bvsge prod (_ bv" <<
power(2, width-1) <<
" "
2068 out <<
" (bvslt prod (bvneg (_ bv" <<
power(2, width - 1) <<
" "
2069 << width * 2 <<
"))))";
2078 else if(op_type.
id()==ID_unsignedbv)
2080 out <<
"(let ((prod (bvmul ((_ zero_extend " << width <<
") ";
2082 out <<
") ((_ zero_extend " << width <<
") ";
2092 out <<
"(mk-" << smt_typename;
2097 out <<
" ((_ extract " << width - 1 <<
" 0) prod) ";
2101 out <<
"(bvuge prod (_ bv" <<
power(2, width) <<
" " << width * 2 <<
"))";
2113 "overflow check should not be performed on unsupported type",
2116 else if(expr.
id()==ID_array)
2122 else if(expr.
id()==ID_literal)
2126 else if(expr.
id()==ID_forall ||
2127 expr.
id()==ID_exists)
2133 throw "MathSAT does not support quantifiers";
2135 if(quantifier_expr.
id() == ID_forall)
2137 else if(quantifier_expr.
id() == ID_exists)
2142 for(
const auto &bound : quantifier_expr.
variables())
2160 else if(expr.
id()==ID_vector)
2165 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
2168 size == vector_expr.
operands().size(),
2169 "size indicated by type shall be equal to the number of operands");
2173 const std::string &smt_typename =
datatype_map.at(vector_type);
2175 out <<
"(mk-" << smt_typename;
2190 const auto object_size = expr_try_dynamic_cast<object_size_exprt>(expr))
2194 else if(expr.
id()==ID_let)
2197 const auto &variables = let_expr.
variables();
2198 const auto &values = let_expr.
values();
2203 for(
auto &binding :
make_range(variables).zip(values))
2222 else if(expr.
id()==ID_constraint_select_one)
2225 "smt2_convt::convert_expr: '" + expr.
id_string() +
2226 "' is not yet supported");
2228 else if(expr.
id() == ID_bswap)
2234 "operand of byte swap expression shall have same type as the expression");
2237 out <<
"(let ((bswap_op ";
2242 bswap_expr.
type().
id() == ID_signedbv ||
2243 bswap_expr.
type().
id() == ID_unsignedbv)
2245 const std::size_t width =
2252 width % bits_per_byte == 0,
2253 "bit width indicated by type of bswap expression should be a multiple "
2254 "of the number of bits per byte");
2256 const std::size_t bytes = width / bits_per_byte;
2265 for(std::size_t
byte = 0;
byte < bytes;
byte++)
2269 out <<
"(bswap_byte_" <<
byte <<
' ';
2270 out <<
"((_ extract " << (
byte * bits_per_byte + (bits_per_byte - 1))
2271 <<
" " << (
byte * bits_per_byte) <<
") bswap_op)";
2280 for(std::size_t
byte = 0;
byte < bytes;
byte++)
2281 out <<
" bswap_byte_" <<
byte;
2292 else if(expr.
id() == ID_popcount)
2296 else if(expr.
id() == ID_count_leading_zeros)
2300 else if(expr.
id() == ID_count_trailing_zeros)
2304 else if(expr.
id() == ID_find_first_set)
2308 else if(expr.
id() == ID_empty_union)
2312 else if(expr.
id() == ID_bitreverse)
2316 else if(expr.
id() == ID_function_application)
2320 if(function_application_expr.arguments().empty())
2328 for(
auto &op : function_application_expr.arguments())
2339 "smt2_convt::convert_expr should not be applied to unsupported type",
2348 if(dest_type.
id()==ID_c_enum_tag)
2352 if(src_type.
id()==ID_c_enum_tag)
2355 if(dest_type.
id()==ID_bool)
2358 if(src_type.
id()==ID_signedbv ||
2359 src_type.
id()==ID_unsignedbv ||
2360 src_type.
id()==ID_c_bool ||
2361 src_type.
id()==ID_fixedbv ||
2362 src_type.
id()==ID_pointer ||
2363 src_type.
id()==ID_integer)
2371 else if(src_type.
id()==ID_floatbv)
2375 out <<
"(not (fp.isZero ";
2387 else if(dest_type.
id()==ID_c_bool)
2396 out <<
" (_ bv1 " << to_width <<
")";
2397 out <<
" (_ bv0 " << to_width <<
")";
2400 else if(dest_type.
id()==ID_signedbv ||
2401 dest_type.
id()==ID_unsignedbv ||
2402 dest_type.
id()==ID_c_enum ||
2403 dest_type.
id()==ID_bv)
2407 if(src_type.
id()==ID_signedbv ||
2408 src_type.
id()==ID_unsignedbv ||
2409 src_type.
id()==ID_c_bool ||
2410 src_type.
id()==ID_c_enum ||
2411 src_type.
id()==ID_bv)
2415 if(from_width==to_width)
2417 else if(from_width<to_width)
2419 if(src_type.
id()==ID_signedbv)
2420 out <<
"((_ sign_extend ";
2422 out <<
"((_ zero_extend ";
2424 out << (to_width-from_width)
2431 out <<
"((_ extract " << (to_width-1) <<
" 0) ";
2436 else if(src_type.
id()==ID_fixedbv)
2440 std::size_t from_width=fixedbv_type.
get_width();
2447 out <<
"(let ((?tcop ";
2453 if(to_width>from_integer_bits)
2455 out <<
"((_ sign_extend "
2456 << (to_width-from_integer_bits) <<
") ";
2457 out <<
"((_ extract " << (from_width-1) <<
" "
2458 << from_fraction_bits <<
") ";
2464 out <<
"((_ extract " << (from_fraction_bits+to_width-1)
2465 <<
" " << from_fraction_bits <<
") ";
2470 out <<
" (ite (and ";
2473 out <<
"(not (= ((_ extract " << (from_fraction_bits-1) <<
" 0) ?tcop) "
2474 "(_ bv0 " << from_fraction_bits <<
")))";
2477 out <<
" (= ((_ extract " << (from_width-1) <<
" " << (from_width-1)
2482 out <<
" (_ bv1 " << to_width <<
") (_ bv0 " << to_width <<
"))";
2486 else if(src_type.
id()==ID_floatbv)
2488 if(dest_type.
id()==ID_bv)
2505 else if(dest_type.
id()==ID_signedbv)
2509 "typecast unexpected "+src_type.
id_string()+
" -> "+
2512 else if(dest_type.
id()==ID_unsignedbv)
2516 "typecast unexpected "+src_type.
id_string()+
" -> "+
2520 else if(src_type.
id()==ID_bool)
2525 if(dest_type.
id()==ID_fixedbv)
2528 out <<
" (concat (_ bv1 "
2531 "(_ bv0 " << spec.
width <<
")";
2535 out <<
" (_ bv1 " << to_width <<
")";
2536 out <<
" (_ bv0 " << to_width <<
")";
2541 else if(src_type.
id()==ID_pointer)
2545 if(from_width<to_width)
2547 out <<
"((_ sign_extend ";
2548 out << (to_width-from_width)
2555 out <<
"((_ extract " << (to_width-1) <<
" 0) ";
2560 else if(src_type.
id()==ID_integer)
2566 out <<
"(_ bv" << i <<
" " << to_width <<
")";
2569 SMT2_TODO(
"can't convert non-constant integer to bitvector");
2572 src_type.
id() == ID_struct ||
2573 src_type.
id() == ID_struct_tag)
2579 "bit vector with of source and destination type shall be equal");
2586 "bit vector with of source and destination type shall be equal");
2591 src_type.
id() == ID_union ||
2592 src_type.
id() == ID_union_tag)
2596 "bit vector with of source and destination type shall be equal");
2599 else if(src_type.
id()==ID_c_bit_field)
2603 if(from_width==to_width)
2614 std::ostringstream e_str;
2615 e_str << src_type.
id() <<
" -> " << dest_type.
id()
2616 <<
" src == " <<
format(src);
2620 else if(dest_type.
id()==ID_fixedbv)
2626 if(src_type.
id()==ID_unsignedbv ||
2627 src_type.
id()==ID_signedbv ||
2628 src_type.
id()==ID_c_enum)
2635 if(from_width==to_integer_bits)
2637 else if(from_width>to_integer_bits)
2640 out <<
"((_ extract " << (to_integer_bits-1) <<
" 0) ";
2648 from_width < to_integer_bits,
2649 "from_width should be smaller than to_integer_bits as other case "
2650 "have been handled above");
2651 if(dest_type.
id()==ID_unsignedbv)
2653 out <<
"(_ zero_extend "
2654 << (to_integer_bits-from_width) <<
") ";
2660 out <<
"((_ sign_extend "
2661 << (to_integer_bits-from_width) <<
") ";
2667 out <<
"(_ bv0 " << to_fraction_bits <<
")";
2670 else if(src_type.
id()==ID_bool)
2672 out <<
"(concat (concat"
2673 <<
" (_ bv0 " << (to_integer_bits-1) <<
") ";
2679 else if(src_type.
id()==ID_fixedbv)
2684 std::size_t from_width=from_fixedbv_type.
get_width();
2686 out <<
"(let ((?tcop ";
2692 if(to_integer_bits<=from_integer_bits)
2694 out <<
"((_ extract "
2695 << (from_fraction_bits+to_integer_bits-1) <<
" "
2696 << from_fraction_bits
2702 to_integer_bits > from_integer_bits,
2703 "to_integer_bits should be greater than from_integer_bits as the"
2704 "other case has been handled above");
2705 out <<
"((_ sign_extend "
2706 << (to_integer_bits-from_integer_bits)
2708 << (from_width-1) <<
" "
2709 << from_fraction_bits
2715 if(to_fraction_bits<=from_fraction_bits)
2717 out <<
"((_ extract "
2718 << (from_fraction_bits-1) <<
" "
2719 << (from_fraction_bits-to_fraction_bits)
2725 to_fraction_bits > from_fraction_bits,
2726 "to_fraction_bits should be greater than from_fraction_bits as the"
2727 "other case has been handled above");
2728 out <<
"(concat ((_ extract "
2729 << (from_fraction_bits-1) <<
" 0) ";
2732 <<
" (_ bv0 " << to_fraction_bits-from_fraction_bits
2741 else if(dest_type.
id()==ID_pointer)
2745 if(src_type.
id()==ID_pointer)
2751 src_type.
id() == ID_unsignedbv || src_type.
id() == ID_signedbv ||
2752 src_type.
id() == ID_bv)
2758 if(from_width==to_width)
2760 else if(from_width<to_width)
2762 out <<
"((_ sign_extend "
2763 << (to_width-from_width)
2770 out <<
"((_ extract " << to_width <<
" 0) ";
2778 else if(dest_type.
id()==ID_range)
2782 else if(dest_type.
id()==ID_floatbv)
2791 if(src_type.
id()==ID_bool)
2806 a.
build(significand, exponent);
2814 a.
build(significand, exponent);
2820 else if(src_type.
id()==ID_c_bool)
2826 else if(src_type.
id() == ID_bv)
2835 out <<
"((_ to_fp " << dest_floatbv_type.get_e() <<
" "
2836 << dest_floatbv_type.get_f() + 1 <<
") ";
2846 else if(dest_type.
id()==ID_integer)
2848 if(src_type.
id()==ID_bool)
2857 else if(dest_type.
id()==ID_c_bit_field)
2862 if(from_width==to_width)
2883 if(dest_type.
id()==ID_floatbv)
2885 if(src_type.
id()==ID_floatbv)
2912 out <<
"((_ to_fp " << dst.
get_e() <<
" "
2913 << dst.
get_f() + 1 <<
") ";
2922 else if(src_type.
id()==ID_unsignedbv)
2943 out <<
"((_ to_fp_unsigned " << dst.
get_e() <<
" "
2944 << dst.
get_f() + 1 <<
") ";
2953 else if(src_type.
id()==ID_signedbv)
2961 out <<
"((_ to_fp " << dst.
get_e() <<
" "
2962 << dst.
get_f() + 1 <<
") ";
2971 else if(src_type.
id()==ID_c_enum_tag)
2985 else if(dest_type.
id()==ID_signedbv)
2990 out <<
"((_ fp.to_sbv " << dest_width <<
") ";
2999 else if(dest_type.
id()==ID_unsignedbv)
3004 out <<
"((_ fp.to_ubv " << dest_width <<
") ";
3028 components.size() == expr.
operands().size(),
3029 "number of struct components as indicated by the struct type shall be equal"
3030 "to the number of operands of the struct expression");
3032 DATA_INVARIANT(!components.empty(),
"struct shall have struct components");
3036 const std::string &smt_typename =
datatype_map.at(struct_type);
3039 out <<
"(mk-" << smt_typename;
3042 for(struct_typet::componentst::const_iterator
3043 it=components.begin();
3044 it!=components.end();
3055 if(components.size()==1)
3060 for(std::size_t i=components.size(); i>1; i--)
3067 if(op.
type().
id() == ID_array)
3069 else if(op.
type().
id() == ID_bool)
3079 for(std::size_t i=1; i<components.size(); i++)
3089 const auto &size_expr = array_type.
size();
3095 out <<
"(let ((?far ";
3103 out <<
"(select ?far ";
3126 if(total_width==member_width)
3134 total_width > member_width,
3135 "total_width should be greater than member_width as member_width can be"
3136 "at most as large as total_width and the other case has been handled "
3140 << (total_width-member_width) <<
") ";
3150 if(expr_type.
id()==ID_unsignedbv ||
3151 expr_type.
id()==ID_signedbv ||
3152 expr_type.
id()==ID_bv ||
3153 expr_type.
id()==ID_c_enum ||
3154 expr_type.
id()==ID_c_enum_tag ||
3155 expr_type.
id()==ID_c_bool ||
3156 expr_type.
id()==ID_c_bit_field)
3162 out <<
"(_ bv" << value
3163 <<
" " << width <<
")";
3165 else if(expr_type.
id()==ID_fixedbv)
3171 out <<
"(_ bv" << v <<
" " << spec.
width <<
")";
3173 else if(expr_type.
id()==ID_floatbv)
3186 size_t e=floatbv_type.
get_e();
3187 size_t f=floatbv_type.
get_f()+1;
3193 out <<
"((_ to_fp " << e <<
" " << f <<
")"
3199 out <<
"(_ NaN " << e <<
" " << f <<
")";
3204 out <<
"(_ -oo " << e <<
" " << f <<
")";
3206 out <<
"(_ +oo " << e <<
" " << f <<
")";
3216 <<
"#b" << binaryString.substr(0, 1) <<
" "
3217 <<
"#b" << binaryString.substr(1, e) <<
" "
3218 <<
"#b" << binaryString.substr(1+e, f-1) <<
")";
3226 out <<
"(_ bv" << v <<
" " << spec.
width() <<
")";
3229 else if(expr_type.
id()==ID_pointer)
3240 else if(expr_type.
id()==ID_bool)
3249 else if(expr_type.
id()==ID_array)
3255 else if(expr_type.
id()==ID_rational)
3258 const bool negative =
has_prefix(value,
"-");
3263 size_t pos=value.find(
"/");
3265 if(
pos==std::string::npos)
3266 out << value <<
".0";
3269 out <<
"(/ " << value.substr(0,
pos) <<
".0 "
3270 << value.substr(
pos+1) <<
".0)";
3276 else if(expr_type.
id()==ID_integer)
3282 out <<
"(- " << value.substr(1, std::string::npos) <<
')';
3292 if(expr.
type().
id() == ID_integer)
3302 "unsupported type for euclidean_mod: " + expr.
type().
id_string());
3307 if(expr.
type().
id()==ID_unsignedbv ||
3308 expr.
type().
id()==ID_signedbv)
3310 if(expr.
type().
id()==ID_unsignedbv)
3326 std::vector<mp_integer> dynamic_objects;
3329 if(dynamic_objects.empty())
3335 out <<
"(let ((?obj ((_ extract "
3336 << pointer_width-1 <<
" "
3341 if(dynamic_objects.size()==1)
3343 out <<
"(= (_ bv" << dynamic_objects.front()
3350 for(
const auto &
object : dynamic_objects)
3351 out <<
" (= (_ bv" <<
object
3365 if(op_type.
id()==ID_unsignedbv ||
3366 op_type.
id()==ID_bv)
3369 if(expr.
id()==ID_le)
3371 else if(expr.
id()==ID_lt)
3373 else if(expr.
id()==ID_ge)
3375 else if(expr.
id()==ID_gt)
3384 else if(op_type.
id()==ID_signedbv ||
3385 op_type.
id()==ID_fixedbv)
3388 if(expr.
id()==ID_le)
3390 else if(expr.
id()==ID_lt)
3392 else if(expr.
id()==ID_ge)
3394 else if(expr.
id()==ID_gt)
3403 else if(op_type.
id()==ID_floatbv)
3408 if(expr.
id()==ID_le)
3410 else if(expr.
id()==ID_lt)
3412 else if(expr.
id()==ID_ge)
3414 else if(expr.
id()==ID_gt)
3426 else if(op_type.
id()==ID_rational ||
3427 op_type.
id()==ID_integer)
3438 else if(op_type.
id() == ID_pointer)
3446 if(expr.
id() == ID_le)
3448 else if(expr.
id() == ID_lt)
3450 else if(expr.
id() == ID_ge)
3452 else if(expr.
id() == ID_gt)
3471 expr.
type().
id() == ID_rational || expr.
type().
id() == ID_integer ||
3472 expr.
type().
id() == ID_real)
3477 for(
const auto &op : expr.
operands())
3486 expr.
type().
id() == ID_unsignedbv || expr.
type().
id() == ID_signedbv ||
3487 expr.
type().
id() == ID_fixedbv)
3504 else if(expr.
type().
id() == ID_floatbv)
3511 else if(expr.
type().
id() == ID_pointer)
3517 if(p.
type().
id() != ID_pointer)
3521 p.
type().
id() == ID_pointer,
3522 "one of the operands should have pointer type");
3527 if(base_type.id() == ID_empty)
3536 CHECK_RETURN(element_size_opt.has_value() && *element_size_opt >= 1);
3537 element_size = *element_size_opt;
3544 if(element_size >= 2)
3561 else if(expr.
type().
id() == ID_vector)
3565 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
3571 const std::string &smt_typename =
datatype_map.at(vector_type);
3573 out <<
"(mk-" << smt_typename;
3582 summands.reserve(expr.
operands().size());
3583 for(
const auto &op : expr.
operands())
3617 if(expr.
id()==ID_constant)
3621 mp_integer value = numeric_cast_v<mp_integer>(cexpr);
3624 out <<
"roundNearestTiesToEven";
3626 out <<
"roundTowardNegative";
3628 out <<
"roundTowardPositive";
3630 out <<
"roundTowardZero";
3634 "Rounding mode should have value 0, 1, 2, or 3",
3642 out <<
"(ite (= (_ bv0 " << width <<
") ";
3644 out <<
") roundNearestTiesToEven ";
3646 out <<
"(ite (= (_ bv1 " << width <<
") ";
3648 out <<
") roundTowardNegative ";
3650 out <<
"(ite (= (_ bv2 " << width <<
") ";
3652 out <<
") roundTowardPositive ";
3655 out <<
"roundTowardZero";
3666 type.
id() == ID_floatbv ||
3667 (type.
id() == ID_complex &&
3669 (type.
id() == ID_vector &&
3674 if(type.
id()==ID_floatbv)
3684 else if(type.
id()==ID_complex)
3688 else if(type.
id()==ID_vector)
3695 "type should not be one of the unsupported types",
3704 if(expr.
type().
id()==ID_integer)
3712 else if(expr.
type().
id()==ID_unsignedbv ||
3713 expr.
type().
id()==ID_signedbv ||
3714 expr.
type().
id()==ID_fixedbv)
3716 if(expr.
op0().
type().
id()==ID_pointer &&
3722 CHECK_RETURN(element_size.has_value() && *element_size >= 1);
3724 if(*element_size >= 2)
3729 "bitvector width of operand shall be equal to the bitvector width of "
3738 if(*element_size >= 2)
3751 else if(expr.
type().
id()==ID_floatbv)
3758 else if(expr.
type().
id()==ID_pointer)
3762 (expr.
op1().
type().
id() == ID_unsignedbv ||
3774 else if(expr.
type().
id()==ID_vector)
3778 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
3784 const std::string &smt_typename =
datatype_map.at(vector_type);
3786 out <<
"(mk-" << smt_typename;
3814 expr.
type().
id() == ID_floatbv,
3815 "type of ieee floating point expression shall be floatbv");
3833 if(expr.
type().
id()==ID_unsignedbv ||
3834 expr.
type().
id()==ID_signedbv)
3836 if(expr.
type().
id()==ID_unsignedbv)
3846 else if(expr.
type().
id()==ID_fixedbv)
3851 out <<
"((_ extract " << spec.
width-1 <<
" 0) ";
3856 out <<
" (_ bv0 " << fraction_bits <<
")) ";
3858 out <<
"((_ sign_extend " << fraction_bits <<
") ";
3864 else if(expr.
type().
id()==ID_floatbv)
3878 expr.
type().
id() == ID_floatbv,
3879 "type of ieee floating point expression shall be floatbv");
3910 "expression should have been converted to a variant with two operands");
3912 if(expr.
type().
id()==ID_unsignedbv ||
3913 expr.
type().
id()==ID_signedbv)
3924 else if(expr.
type().
id()==ID_floatbv)
3931 else if(expr.
type().
id()==ID_fixedbv)
3936 out <<
"((_ extract "
3937 << spec.
width+fraction_bits-1 <<
" "
3938 << fraction_bits <<
") ";
3942 out <<
"((_ sign_extend " << fraction_bits <<
") ";
3946 out <<
"((_ sign_extend " << fraction_bits <<
") ";
3952 else if(expr.
type().
id()==ID_rational ||
3953 expr.
type().
id()==ID_integer ||
3954 expr.
type().
id()==ID_real)
3973 expr.
type().
id() == ID_floatbv,
3974 "type of ieee floating point expression shall be floatbv");
3993 expr.
type().
id() == ID_floatbv,
3994 "type of ieee floating point expression shall be floatbv");
4008 "smt2_convt::convert_floatbv_rem to be implemented when not using "
4019 std::size_t s=expr.
operands().size();
4034 "with expression should have been converted to a version with three "
4039 if(expr_type.
id()==ID_array)
4063 out <<
"(let ((distance? ";
4064 out <<
"(bvmul (_ bv" << sub_width <<
" " << array_width <<
") ";
4068 if(array_width>index_width)
4070 out <<
"((_ zero_extend " << array_width-index_width <<
") ";
4076 out <<
"((_ extract " << array_width-1 <<
" 0) ";
4086 out <<
"(bvshl (_ bv" <<
power(2, sub_width) - 1 <<
" " << array_width
4088 out <<
"distance?)) ";
4092 out <<
"((_ zero_extend " << array_width-sub_width <<
") ";
4094 out <<
") distance?)))";
4097 else if(expr_type.
id() == ID_struct || expr_type.
id() == ID_struct_tag)
4104 const irep_idt &component_name=index.
get(ID_component_name);
4108 "struct should have accessed component");
4112 const std::string &smt_typename =
datatype_map.at(expr_type);
4114 out <<
"(update-" << smt_typename <<
"." << component_name <<
" ";
4128 out <<
"(let ((?withop ";
4132 if(m.
width==struct_width)
4142 <<
"((_ extract " << (struct_width-1) <<
" "
4143 << m.
width <<
") ?withop) ";
4152 out <<
" ((_ extract " << (m.
offset - 1) <<
" 0) ?withop))";
4157 out <<
"(concat (concat "
4158 <<
"((_ extract " << (struct_width-1) <<
" "
4161 out <<
") ((_ extract " << (m.
offset-1) <<
" 0) ?withop)";
4168 else if(expr_type.
id() == ID_union || expr_type.
id() == ID_union_tag)
4178 if(total_width==member_width)
4185 total_width > member_width,
4186 "total width should be greater than member_width as member_width is at "
4187 "most as large as total_width and the other case has been handled "
4190 out <<
"((_ extract "
4192 <<
" " << member_width <<
") ";
4199 else if(expr_type.
id()==ID_bv ||
4200 expr_type.
id()==ID_unsignedbv ||
4201 expr_type.
id()==ID_signedbv)
4221 out <<
" (bvnot (bvshl";
4224 out <<
" (repeat[" << total_width-value_width <<
"] bv0[1])";
4225 out <<
" (repeat[" << value_width <<
"] bv1[1])";
4247 "with expects struct, union, or array type, but got "+
4255 SMT2_TODO(
"smt2_convt::convert_update to be implemented");
4262 if(array_op_type.
id()==ID_array)
4297 out <<
"((_ extract " << sub_width-1 <<
" 0) ";
4301 out <<
"(bvmul (_ bv" << sub_width <<
" " << array_width <<
") ";
4305 if(array_width>index_width)
4307 out <<
"((_ zero_extend " << array_width-index_width <<
") ";
4313 out <<
"((_ extract " << array_width-1 <<
" 0) ";
4323 else if(array_op_type.
id()==ID_vector)
4329 const std::string &smt_typename =
datatype_map.at(vector_type);
4333 const auto index_int = numeric_cast<mp_integer>(expr.
index());
4334 if(!index_int.has_value())
4336 SMT2_TODO(
"non-constant index on vectors");
4340 out <<
"(" << smt_typename <<
"." << *index_int <<
" ";
4352 false,
"index with unsupported array type: " + array_op_type.
id_string());
4359 const typet &struct_op_type = struct_op.
type();
4362 if(struct_op_type.
id() == ID_struct || struct_op_type.
id() == ID_struct_tag)
4367 struct_type.
has_component(name),
"struct should have accessed component");
4371 const std::string &smt_typename =
datatype_map.at(struct_type);
4373 out <<
"(" << smt_typename <<
"."
4384 if(expr.
type().
id() == ID_bool)
4390 if(expr.
type().
id() == ID_bool)
4395 struct_op_type.
id() == ID_union || struct_op_type.
id() == ID_union_tag)
4399 width != 0,
"failed to get union member width");
4403 out <<
"((_ extract "
4413 "convert_member on an unexpected type "+struct_op_type.
id_string());
4420 if(type.
id()==ID_bool)
4426 else if(type.
id()==ID_vector)
4430 const std::string &smt_typename =
datatype_map.at(type);
4435 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
4437 out <<
"(let ((?vflop ";
4445 out <<
" (" << smt_typename <<
"." << i <<
" ?vflop)";
4453 else if(type.
id()==ID_array)
4457 else if(type.
id() == ID_struct || type.
id() == ID_struct_tag)
4461 const std::string &smt_typename =
datatype_map.at(type);
4466 out <<
"(let ((?sflop ";
4474 for(std::size_t i=components.size(); i>1; i--)
4476 out <<
"(concat (" << smt_typename <<
"."
4477 << components[i-1].get_name() <<
" ?sflop)";
4482 out <<
"(" << smt_typename <<
"."
4483 << components[0].get_name() <<
" ?sflop)";
4485 for(std::size_t i=1; i<components.size(); i++)
4493 else if(type.
id()==ID_floatbv)
4497 "floatbv expressions should be flattened when using FPA theory");
4510 if(type.
id()==ID_bool)
4517 else if(type.
id()==ID_vector)
4521 const std::string &smt_typename =
datatype_map.at(type);
4528 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
4531 out <<
"(let ((?ufop" << nesting <<
" ";
4536 out <<
"(mk-" << smt_typename;
4538 std::size_t offset=0;
4540 for(
mp_integer i=0; i!=size; ++i, offset+=subtype_width)
4544 out <<
"((_ extract " << offset+subtype_width-1 <<
" "
4545 << offset <<
") ?ufop" << nesting <<
")";
4557 else if(type.
id() == ID_struct || type.
id() == ID_struct_tag)
4563 out <<
"(let ((?ufop" << nesting <<
" ";
4568 const std::string &smt_typename =
datatype_map.at(type);
4570 out <<
"(mk-" << smt_typename;
4577 std::size_t offset=0;
4580 for(struct_typet::componentst::const_iterator
4581 it=components.begin();
4582 it!=components.end();
4589 out <<
"((_ extract " << offset+member_width-1 <<
" "
4590 << offset <<
") ?ufop" << nesting <<
")";
4592 offset+=member_width;
4613 if(expr.
id()==ID_and && value)
4620 if(expr.
id()==ID_or && !value)
4627 if(expr.
id()==ID_not)
4637 if(expr.
id() == ID_equal && value)
4641 equal_expr.
lhs().
type().
id() == ID_empty ||
4642 equal_expr.
rhs().
id() == ID_empty_union)
4648 if(equal_expr.
lhs().
id()==ID_symbol)
4658 id.type=equal_expr.
lhs().
type();
4665 out <<
"; set_to true (equal)\n";
4666 out <<
"(define-fun " << smt2_identifier;
4668 if(equal_expr.
lhs().
type().
id() == ID_mathematical_function)
4670 auto &mathematical_function_type =
4675 for(std::size_t p_nr = 0;
4676 p_nr < mathematical_function_type.domain().size();
4684 out <<
'(' <<
'p' << (p_nr + 1) <<
' ';
4685 convert_type(mathematical_function_type.domain()[p_nr]);
4694 for(std::size_t p_nr = 0;
4695 p_nr < mathematical_function_type.domain().size();
4697 out <<
' ' <<
'p' << (p_nr + 1);
4721 out <<
"; set_to " << (value?
"true":
"false") <<
"\n"
4732 out << found_literal->second;
4755 exprt lowered_expr = expr;
4762 it->id() == ID_byte_extract_little_endian ||
4763 it->id() == ID_byte_extract_big_endian)
4768 it->id() == ID_byte_update_little_endian ||
4769 it->id() == ID_byte_update_big_endian)
4775 return lowered_expr;
4792 "lower_byte_operators should remove all byte operators");
4797 return lowered_expr;
4805 if(expr.
id() == ID_exists || expr.
id() == ID_forall)
4810 for(
const auto &symbol : q_expr.variables())
4812 const auto identifier = symbol.get_identifier();
4814 id.type = symbol.type();
4825 if(expr.
id()==ID_symbol ||
4826 expr.
id()==ID_nondet_symbol)
4829 if(expr.
type().
id()==ID_code)
4834 if(expr.
id()==ID_symbol)
4837 identifier=
"nondet_"+
4842 if(
id.type.is_nil())
4844 id.type=expr.
type();
4849 out <<
"; find_symbols\n";
4850 out <<
"(declare-fun " << smt2_identifier;
4852 if(expr.
type().
id() == ID_mathematical_function)
4854 auto &mathematical_function_type =
4859 for(
auto &type : mathematical_function_type.domain())
4880 else if(expr.
id() == ID_array_of)
4887 const auto &array_type = array_of.type();
4891 out <<
"; the following is a substitute for lambda i. x\n";
4892 out <<
"(declare-fun " <<
id <<
" () ";
4897 out <<
"(assert (forall ((i ";
4899 out <<
")) (= (select " <<
id <<
" i) ";
4916 else if(expr.
id() == ID_array_comprehension)
4923 const auto &array_type = array_comprehension.type();
4924 const auto &array_size = array_type.size();
4928 out <<
"(declare-fun " <<
id <<
" () ";
4932 out <<
"; the following is a substitute for lambda i . x(i)\n";
4933 out <<
"; universally quantified initialization of the array\n";
4934 out <<
"(assert (forall ((";
4938 out <<
")) (=> (and (bvule (_ bv0 " <<
boolbv_width(array_size.type())
4945 out <<
")) (= (select " <<
id <<
" ";
4964 else if(expr.
id()==ID_array)
4971 out <<
"; the following is a substitute for an array constructor" <<
"\n";
4972 out <<
"(declare-fun " <<
id <<
" () ";
4976 for(std::size_t i=0; i<expr.
operands().size(); i++)
4978 out <<
"(assert (= (select " <<
id <<
" ";
4991 out <<
"))" <<
"\n";
4997 else if(expr.
id()==ID_string_constant)
5007 out <<
"; the following is a substitute for a string" <<
"\n";
5008 out <<
"(declare-fun " <<
id <<
" () ";
5012 for(std::size_t i=0; i<tmp.
operands().size(); i++)
5014 out <<
"(assert (= (select " <<
id <<
' ';
5018 out <<
"))" <<
"\n";
5025 const auto object_size = expr_try_dynamic_cast<object_size_exprt>(expr))
5031 out <<
"(declare-fun " <<
id <<
" () ";
5042 (expr.
id() == ID_floatbv_plus ||
5043 expr.
id() == ID_floatbv_minus ||
5044 expr.
id() == ID_floatbv_mult ||
5045 expr.
id() == ID_floatbv_div ||
5046 expr.
id() == ID_floatbv_typecast ||
5047 expr.
id() == ID_ieee_float_equal ||
5048 expr.
id() == ID_ieee_float_notequal ||
5049 ((expr.
id() == ID_lt ||
5050 expr.
id() == ID_gt ||
5051 expr.
id() == ID_le ||
5052 expr.
id() == ID_ge ||
5053 expr.
id() == ID_isnan ||
5054 expr.
id() == ID_isnormal ||
5055 expr.
id() == ID_isfinite ||
5056 expr.
id() == ID_isinf ||
5057 expr.
id() == ID_sign ||
5058 expr.
id() == ID_unary_minus ||
5059 expr.
id() == ID_typecast ||
5060 expr.
id() == ID_abs) &&
5067 if(
bvfp_set.insert(
function).second)
5069 out <<
"; this is a model for " << expr.
id() <<
" : "
5072 <<
"(define-fun " <<
function <<
" (";
5074 for(std::size_t i = 0; i < expr.
operands().size(); i++)
5078 out <<
"(op" << i <<
' ';
5088 for(std::size_t i = 0; i < tmp1.
operands().size(); i++)
5115 if(expr.
id()==ID_with)
5117 else if(expr.
id()==ID_member)
5126 if(type.
id()==ID_array)
5140 out <<
"(_ BitVec 1)";
5146 else if(type.
id()==ID_bool)
5150 else if(type.
id() == ID_struct || type.
id() == ID_struct_tag)
5160 out <<
"(_ BitVec " << width <<
")";
5163 else if(type.
id()==ID_vector)
5173 out <<
"(_ BitVec " << width <<
")";
5176 else if(type.
id()==ID_code)
5183 else if(type.
id() == ID_union || type.
id() == ID_union_tag)
5188 "failed to get width of union");
5190 out <<
"(_ BitVec " << width <<
")";
5192 else if(type.
id()==ID_pointer)
5197 else if(type.
id()==ID_bv ||
5198 type.
id()==ID_fixedbv ||
5199 type.
id()==ID_unsignedbv ||
5200 type.
id()==ID_signedbv ||
5201 type.
id()==ID_c_bool)
5206 else if(type.
id()==ID_c_enum)
5213 else if(type.
id()==ID_c_enum_tag)
5217 else if(type.
id()==ID_floatbv)
5222 out <<
"(_ FloatingPoint "
5223 << floatbv_type.
get_e() <<
" "
5224 << floatbv_type.
get_f() + 1 <<
")";
5229 else if(type.
id()==ID_rational ||
5232 else if(type.
id()==ID_integer)
5234 else if(type.
id()==ID_complex)
5244 out <<
"(_ BitVec " << width <<
")";
5247 else if(type.
id()==ID_c_bit_field)
5259 std::set<irep_idt> recstack;
5265 std::set<irep_idt> &recstack)
5267 if(type.
id()==ID_array)
5273 else if(type.
id()==ID_complex)
5280 const std::string smt_typename =
5284 out <<
"(declare-datatypes ((" << smt_typename <<
" 0)) "
5285 <<
"(((mk-" << smt_typename;
5287 out <<
" (" << smt_typename <<
".imag ";
5291 out <<
" (" << smt_typename <<
".real ";
5298 else if(type.
id()==ID_vector)
5307 mp_integer size = numeric_cast_v<mp_integer>(vector_type.
size());
5309 const std::string smt_typename =
5313 out <<
"(declare-datatypes ((" << smt_typename <<
" 0)) "
5314 <<
"(((mk-" << smt_typename;
5318 out <<
" (" << smt_typename <<
"." << i <<
" ";
5326 else if(type.
id() == ID_struct)
5329 bool need_decl=
false;
5333 const std::string smt_typename =
5348 const std::string &smt_typename =
datatype_map.at(type);
5359 out <<
"(declare-datatypes ((" << smt_typename <<
" 0)) "
5360 <<
"(((mk-" << smt_typename <<
" ";
5364 out <<
"(" << smt_typename <<
"." <<
component.get_name()
5370 out <<
"))))" <<
"\n";
5387 for(struct_union_typet::componentst::const_iterator
5388 it=components.begin();
5389 it!=components.end();
5393 out <<
"(define-fun update-" << smt_typename <<
"."
5395 <<
"((s " << smt_typename <<
") "
5398 out <<
")) " << smt_typename <<
" "
5399 <<
"(mk-" << smt_typename
5402 for(struct_union_typet::componentst::const_iterator
5403 it2=components.begin();
5404 it2!=components.end();
5411 out <<
"(" << smt_typename <<
"."
5412 << it2->get_name() <<
" s) ";
5416 out <<
"))" <<
"\n";
5422 else if(type.
id() == ID_union)
5430 else if(type.
id()==ID_code)
5434 for(
const auto ¶m : parameters)
5439 else if(type.
id()==ID_pointer)
5443 else if(type.
id() == ID_struct_tag)
5446 const irep_idt &
id = struct_tag.get_identifier();
5448 if(recstack.find(
id) == recstack.end())
5451 recstack.insert(
id);
5456 else if(type.
id() == ID_union_tag)
5459 const irep_idt &
id = union_tag.get_identifier();
5461 if(recstack.find(
id) == recstack.end())
5463 recstack.insert(
id);
5467 else if(type.
id() == ID_mathematical_function)
5469 const auto &mathematical_function_type =
5471 for(
auto &d_type : mathematical_function_type.domain())
Operator to update elements in structs and arrays.
void set_to(const exprt &expr, bool value) override
For a Boolean expression expr, add the constraint 'expr' if value is true, otherwise add 'not expr'.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
void convert_typecast(const typecast_exprt &expr)
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
void convert_euclidean_mod(const euclidean_mod_exprt &expr)
#define UNREACHABLE
This should be used to mark dead code.
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
#define UNEXPECTEDCASE(S)
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
const array_comprehension_exprt & to_array_comprehension_expr(const exprt &expr)
Cast an exprt to a array_comprehension_exprt.
const vector_exprt & to_vector_expr(const exprt &expr)
Cast an exprt to an vector_exprt.
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
void walk_array_tree(std::unordered_map< int64_t, exprt > *operands_map, const irept &src, const array_typet &type)
This function walks the SMT output and populates a map with index/value pairs for the array.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
literalt get_literal() const
const c_bool_typet & to_c_bool_type(const typet &type)
Cast a typet to a c_bool_typet.
void print_assignment(std::ostream &out) const override
Print satisfying assignment to out.
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
depth_iteratort depth_end()
struct configt::bv_encodingt bv_encoding
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
std::size_t get_number_of_solver_calls() const override
Return the number of incremental solver calls.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
exprt float_bv(const exprt &src)
void convert_type(const typet &)
const irep_idt & get_identifier() const
const euclidean_mod_exprt & to_euclidean_mod_expr(const exprt &expr)
Cast an exprt to a euclidean_mod_exprt.
#define CHECK_RETURN(CONDITION)
The type of an expression, extends irept.
std::vector< parametert > parameterst
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
void pop() override
Currently, only implements a single stack element (no nested contexts)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
datatype_mapt datatype_map
void get_dynamic_objects(std::vector< mp_integer > &objects) const
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
exprt parse_array(const irept &s, const array_typet &type)
This function is for parsing array output from SMT solvers when "(get-value |???|)" returns an array ...
bool use_array_theory(const exprt &)
void convert_floatbv(const exprt &expr)
std::size_t get_f() const
const constant_exprt & size() const
literalt convert(const exprt &expr)
The trinary if-then-else operator.
const isinf_exprt & to_isinf_expr(const exprt &expr)
Cast an exprt to a isinf_exprt.
bool has_byte_operator(const exprt &src)
Fixed-width bit-vector with IEEE floating-point interpretation.
const mp_integer string2integer(const std::string &n, unsigned base)
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
static exprt lower_byte_update(const byte_update_exprt &src, const exprt &value_as_byte_array, const optionalt< exprt > &non_const_update_bound, const namespacet &ns)
Apply a byte update src using the byte array value_as_byte_array as update value.
std::size_t get_fraction_bits() const
static bool has_quantifier(const exprt &expr)
void convert_update(const exprt &expr)
Union constructor from single element.
const string_constantt & to_string_constant(const exprt &expr)
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
void convert_plus(const plus_exprt &expr)
The plus expression Associativity is not specified.
void convert_floatbv_plus(const ieee_float_op_exprt &expr)
exprt lower_byte_extract(const byte_extract_exprt &src, const namespacet &ns)
rewrite byte extraction from an array to byte extraction from a concatenation of array index expressi...
const mathematical_function_typet & to_mathematical_function_type(const typet &type)
Cast a typet to a mathematical_function_typet.
Base class for all expressions.
std::vector< componentt > componentst
Generic base class for unary expressions.
void convert_expr(const exprt &)
A base class for binary expressions.
const bv_typet & to_bv_type(const typet &type)
Cast a typet to a bv_typet.
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
std::size_t get_bits_per_byte() const
void convert_constant(const constant_exprt &expr)
Sign of an expression Predicate is true if _op is negative, false otherwise.
void convert_literal(const literalt)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
exprt handle(const exprt &expr) override
Generate a handle, which is an expression that has the same value as the argument in any model that i...
A base class for quantifier expressions.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
Vector constructor from list of elements.
bool is_true() const
Return whether the expression is a constant representing true.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
exprt make_binary(const exprt &expr)
splits an expression with >=3 operands into nested binary expressions
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
const mp_integer & get_invalid_object() const
Expression for finding the size (in bytes) of the object a pointer points to.
bitvector_typet index_type()
#define CHECK_RETURN_WITH_DIAGNOSTICS(CONDITION,...)
std::string type2id(const typet &) const
const popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_exprt.
void flatten_array(const exprt &)
produce a flat bit-vector for a given array of fixed size
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
const find_first_set_exprt & to_find_first_set_expr(const exprt &expr)
Cast an exprt to a find_first_set_exprt.
Evaluates to true if the operand is finite.
void convert_is_dynamic_object(const unary_exprt &)
bool is_false() const
Return whether the expression is a constant representing false.
Fixed-width bit-vector with unsigned binary interpretation.
void convert_index(const index_exprt &expr)
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
const literal_exprt & to_literal_expr(const exprt &expr)
Cast a generic exprt to a literal_exprt.
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
const irep_idt & get(const irep_idt &name) const
const unary_plus_exprt & to_unary_plus_expr(const exprt &expr)
Cast an exprt to a unary_plus_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
#define INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
Same as invariant, with one or more diagnostics attached Diagnostics can be of any type that has a sp...
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
Boute's Euclidean definition of Modulo – to match SMT-LIB2.
void convert_rounding_mode_FPA(const exprt &expr)
Converting a constant or symbolic rounding mode to SMT-LIB.
Struct constructor from list of elements.
const exprt & size() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool can_cast_expr< overflow_result_exprt >(const exprt &base)
const nondet_symbol_exprt & to_nondet_symbol_expr(const exprt &expr)
Cast an exprt to a nondet_symbol_exprt.
binding_exprt::variablest & variables()
convenience accessor for binding().variables()
typet & type()
Return the type of the expression.
const pointer_object_exprt & to_pointer_object_expr(const exprt &expr)
Cast an exprt to a pointer_object_exprt.
const smt2_symbolt & to_smt2_symbol(const exprt &expr)
std::size_t number_of_solver_calls
void convert_mult(const mult_exprt &expr)
Expression classes for byte-level operators.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
static std::string convert_identifier(const irep_idt &identifier)
void convert_floatbv_div(const ieee_float_op_exprt &expr)
const typet & element_type() const
The type of the elements of the vector.
exprt prepare_for_convert_expr(const exprt &expr)
Perform steps necessary before an expression is passed to convert_expr.
void push() override
Unimplemented.
std::unordered_map< irep_idt, bool > set_values
The values which boolean identifiers have been smt2_convt::set_to or in other words those which are a...
constant_exprt parse_literal(const irept &, const typet &type)
#define DATA_INVARIANT_WITH_DIAGNOSTICS(CONDITION, REASON,...)
bool has_prefix(const std::string &s, const std::string &prefix)
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
std::size_t width() const
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
void write_footer()
Writes the end of the SMT file to the smt_convt::out stream.
const std::string & id2string(const irep_idt &d)
const irep_idt & get_name() const
void convert_relation(const binary_relation_exprt &)
Semantic type conversion from/to floating-point formats.
identifier_mapt identifier_map
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
#define forall_operands(it, expr)
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
void convert_mod(const mod_exprt &expr)
const exprt & struct_op() const
void visit_post(std::function< void(exprt &)>)
These are post-order traversal visitors, i.e., the visitor is executed on a node after its children h...
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
bool can_cast_expr< plus_overflow_exprt >(const exprt &base)
const isfinite_exprt & to_isfinite_expr(const exprt &expr)
Cast an exprt to a isfinite_exprt.
const irep_idt & get_identifier() const
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
void convert_floatbv_mult(const ieee_float_op_exprt &expr)
bool use_check_sat_assuming
const std::string & id_string() const
literalt const_literal(bool value)
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
Binary multiplication Associativity is not specified.
std::size_t get_e() const
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
exprt simplify_expr(exprt src, const namespacet &ns)
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
void convert_struct(const struct_exprt &expr)
pointer_typet pointer_type(const typet &subtype)
The unary minus expression.
void define_object_size(const irep_idt &id, const object_size_exprt &expr)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
bool use_lambda_for_array
bool has_component(const irep_idt &component_name) const
exprt object_size(const exprt &pointer)
const irep_idt & id() const
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
std::vector< exprt > operandst
std::set< irep_idt > bvfp_set
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
The Boolean constant false.
void convert_div(const div_exprt &expr)
Pointer-typed bitvector constant annotated with the pointer expression that the bitvector is the nume...
const parameterst & parameters() const
void convert_minus(const minus_exprt &expr)
exprt pointer_offset(const exprt &pointer)
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
numberingt< exprt, irep_hash > objects
resultt
Result of running the decision procedure.
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
static ieee_floatt plus_infinity(const ieee_float_spect &_spec)
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
boolbv_widtht boolbv_width
Fixed-width bit-vector with signed fixed-point interpretation.
void find_symbols_rec(const typet &type, std::set< irep_idt > &recstack)
std::size_t get_width() const
const ieee_float_op_exprt & to_ieee_float_op_expr(const exprt &expr)
Cast an exprt to an ieee_float_op_exprt.
Bit-wise negation of bit-vectors.
bool is_zero() const
Return whether the expression is a constant representing 0.
void convert_with(const with_exprt &expr)
Extract member of struct or union.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
Deprecated expression utility functions.
A base class for shift and rotate operators.
array_exprt to_array_expr() const
convert string into array constant
Structure type, corresponds to C style structs.
optionalt< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
std::size_t get_fraction_bits() const
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const sign_exprt & to_sign_expr(const exprt &expr)
Cast an exprt to a sign_exprt.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
exprt parse_rec(const irept &s, const typet &type)
const bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
Evaluates to true if the operand is infinite.
resultt dec_solve() override
Run the decision procedure to solve the problem.
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
std::string floatbv_suffix(const exprt &) const
depth_iteratort depth_begin()
smt2_convt(const namespacet &_ns, const std::string &_benchmark, const std::string &_notes, const std::string &_logic, solvert _solver, std::ostream &_out)
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
int solver(std::istream &in)
std::vector< exprt > assumptions
std::size_t get_integer_bits() const
exprt lower_byte_operators(const exprt &expr)
Lower byte_update and byte_extract operations within expr.
bool is_constant() const
Return whether the expression is a constant.
A base class for relations, i.e., binary predicates whose two operands have the same type.
void convert_floatbv_rem(const binary_exprt &expr)
struct_exprt parse_struct(const irept &s, const struct_typet &type)
const isnormal_exprt & to_isnormal_expr(const exprt &expr)
Cast an exprt to a isnormal_exprt.
const typet & base_type() const
The type of the data what we point to.
std::size_t no_boolean_variables
void convert_union(const union_exprt &expr)
static std::string binary(const constant_exprt &src)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
exprt same_object(const exprt &p1, const exprt &p2)
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
typet c_bit_field_replacement_type(const c_bit_field_typet &src, const namespacet &ns)
pointer_logict pointer_logic
std::size_t unsafe_string2size_t(const std::string &str, int base)
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
void convert_address_of_rec(const exprt &expr, const pointer_typet &result_type)
exprt get(const exprt &expr) const override
Return expr with variables replaced by values from satisfying assignment if available.
const pointer_offset_exprt & to_pointer_offset_expr(const exprt &expr)
Cast an exprt to a pointer_offset_exprt.
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
IEEE floating-point operations These have two data operands (op0 and op1) and one rounding mode (op2)...
optionalt< exprt > size_of_expr(const typet &type, const namespacet &ns)
bool is_smt2_simple_symbol_character(char ch)
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
The byte swap expression.
irep_idt get_component_name() const
There are a large number of kinds of tree structured or tree-like data in CPROVER.
tvt l_get(literalt l) const
constant_exprt to_expr() const
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
void find_symbols(const exprt &expr)
mp_integer add_object(const exprt &expr)
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
bool is_null_pointer(const constant_exprt &expr)
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
const std::string integer2binary(const mp_integer &n, std::size_t width)
std::vector< bool > boolean_assignment
Operator to return the address of an object.
Semantic type conversion.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
std::map< object_size_exprt, irep_idt > object_sizes
static ieee_floatt NaN(const ieee_float_spect &_spec)
The Boolean constant true.
A constant literal expression.
static bool is_smt2_simple_identifier(const std::string &identifier)
bool is_true(const literalt &l)
const isnan_exprt & to_isnan_expr(const exprt &expr)
Cast an exprt to a isnan_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
exprt & where()
convenience accessor for binding().where()
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
void set_value(const irep_idt &value)
void unflatten(wheret, const typet &, unsigned nesting=0)
const irep_idt & get_value() const
typet index_type() const
The type of the index expressions into any instance of this type.
optionalt< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
const membert & get_member(const struct_typet &type, const irep_idt &member) const
Array constructor from list of elements.
exprt parse_union(const irept &s, const union_typet &type)
ranget< iteratort > make_range(iteratort begin, iteratort end)
void convert_floatbv_minus(const ieee_float_op_exprt &expr)
const function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
void flatten2bv(const exprt &)
Evaluates to true if the operand is a normal number.
smt2_identifierst smt2_identifiers
static ieee_floatt minus_infinity(const ieee_float_spect &_spec)
mp_integer bitwise_or(const mp_integer &a, const mp_integer &b)
bitwise 'or' of two nonnegative integers
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
void convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
const typet & element_type() const
The type of the elements of the array.
exprt pointer_expr(const pointert &pointer, const pointer_typet &type) const
Convert an (object,offset) pair to an expression.
bool can_cast_expr< minus_overflow_exprt >(const exprt &base)
Evaluates to true if the operand is NaN.
std::string decision_procedure_text() const override
Return a textual description of the decision procedure.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
void build(const mp_integer &exp, const mp_integer &frac)
void convert_member(const member_exprt &expr)
defined_expressionst defined_expressions