cprover
Loading...
Searching...
No Matches
boolbv.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "boolbv.h"
10
11#include <algorithm>
12
13#include <util/arith_tools.h>
14#include <util/bitvector_expr.h>
16#include <util/byte_operators.h>
17#include <util/config.h>
18#include <util/floatbv_expr.h>
19#include <util/magic.h>
20#include <util/mp_arith.h>
21#include <util/simplify_expr.h>
22#include <util/std_expr.h>
24
26
28{
29 const bool little_endian =
31 return endianness_map(type, little_endian);
32}
33
37const bvt &
39{
40 // check cache first
41 std::pair<bv_cachet::iterator, bool> cache_result=
42 bv_cache.insert(std::make_pair(expr, bvt()));
43
44 // get a reference to the cache entry
45 auto &cache_entry = cache_result.first->second;
46
47 if(!cache_result.second)
48 {
49 // Found in cache
50 return cache_entry;
51 }
52
53 // Iterators into hash_maps do not remain valid when inserting
54 // more elements recursively. C++11 ยง23.2.5/13
55 // However, the _reference_ to the entry does!
56 cache_entry = convert_bitvector(expr);
57
59 !expected_width || cache_entry.size() == *expected_width,
60 "bitvector width shall match the indicated expected width",
63
64 // check
65 for(const auto &literal : cache_entry)
66 {
67 if(freeze_all && !literal.is_constant())
68 prop.set_frozen(literal);
69
71 literal.var_no() != literalt::unused_var_no(),
72 "variable number must be different from the unused variable number",
75 }
76
77 return cache_entry;
78}
79
83{
84 ignoring(expr);
85
86 // try to make it free bits
87 std::size_t width=boolbv_width(expr.type());
88 return prop.new_variables(width);
89}
90
97{
98 if(expr.is_boolean())
99 return {convert(expr)};
100
101 if(expr.id()==ID_index)
102 return convert_index(to_index_expr(expr));
103 else if(expr.id()==ID_constraint_select_one)
105 else if(expr.id()==ID_member)
106 return convert_member(to_member_expr(expr));
107 else if(expr.id()==ID_with)
108 return convert_with(to_with_expr(expr));
109 else if(expr.id()==ID_update)
110 return convert_update(to_update_expr(expr));
111 else if(expr.id()==ID_case)
112 return convert_case(expr);
113 else if(expr.id()==ID_cond)
114 return convert_cond(to_cond_expr(expr));
115 else if(expr.id()==ID_if)
116 return convert_if(to_if_expr(expr));
117 else if(expr.is_constant())
119 else if(expr.id()==ID_typecast)
121 else if(expr.id()==ID_symbol)
122 return convert_symbol(to_symbol_expr(expr));
123 else if(expr.id()==ID_plus || expr.id()==ID_minus ||
124 expr.id()=="no-overflow-plus" ||
125 expr.id()=="no-overflow-minus")
126 return convert_add_sub(expr);
127 else if(expr.id() == ID_mult)
128 return convert_mult(to_mult_expr(expr));
129 else if(expr.id()==ID_div)
130 return convert_div(to_div_expr(expr));
131 else if(expr.id()==ID_mod)
132 return convert_mod(to_mod_expr(expr));
133 else if(expr.id()==ID_shl || expr.id()==ID_ashr || expr.id()==ID_lshr ||
134 expr.id()==ID_rol || expr.id()==ID_ror)
135 return convert_shift(to_shift_expr(expr));
136 else if(
137 expr.id() == ID_floatbv_plus || expr.id() == ID_floatbv_minus ||
138 expr.id() == ID_floatbv_mult || expr.id() == ID_floatbv_div)
139 {
141 }
142 else if(expr.id() == ID_floatbv_mod)
144 else if(expr.id() == ID_floatbv_rem)
146 else if(expr.id()==ID_floatbv_typecast)
148 else if(expr.id()==ID_concatenation)
150 else if(expr.id()==ID_replication)
152 else if(expr.id()==ID_extractbits)
154 else if(expr.id()==ID_bitnot || expr.id()==ID_bitand ||
155 expr.id()==ID_bitor || expr.id()==ID_bitxor ||
156 expr.id()==ID_bitxnor || expr.id()==ID_bitnor ||
157 expr.id()==ID_bitnand)
158 return convert_bitwise(expr);
159 else if(expr.id() == ID_unary_minus)
161 else if(expr.id()==ID_unary_plus)
162 {
163 return convert_bitvector(to_unary_plus_expr(expr).op());
164 }
165 else if(expr.id()==ID_abs)
166 return convert_abs(to_abs_expr(expr));
167 else if(expr.id() == ID_bswap)
168 return convert_bswap(to_bswap_expr(expr));
169 else if(expr.id()==ID_byte_extract_little_endian ||
170 expr.id()==ID_byte_extract_big_endian)
172 else if(expr.id()==ID_byte_update_little_endian ||
173 expr.id()==ID_byte_update_big_endian)
175 else if(expr.id()==ID_nondet_symbol ||
176 expr.id()=="quant_symbol")
177 return convert_symbol(expr);
178 else if(expr.id()==ID_struct)
179 return convert_struct(to_struct_expr(expr));
180 else if(expr.id()==ID_union)
181 return convert_union(to_union_expr(expr));
182 else if(expr.id() == ID_empty_union)
184 else if(expr.id()==ID_string_constant)
185 return convert_bitvector(
187 else if(expr.id() == ID_named_term)
188 {
189 const auto &named_term_expr = to_named_term_expr(expr);
190 set_to_true(equal_exprt(named_term_expr.symbol(), named_term_expr.value()));
191 return convert_symbol(named_term_expr.symbol());
192 }
193 else if(expr.id()==ID_array)
194 return convert_array(expr);
195 else if(expr.id()==ID_complex)
196 return convert_complex(to_complex_expr(expr));
197 else if(expr.id()==ID_complex_real)
199 else if(expr.id()==ID_complex_imag)
201 else if(expr.id() == ID_array_comprehension)
203 else if(expr.id()==ID_array_of)
205 else if(expr.id()==ID_let)
206 return convert_let(to_let_expr(expr));
207 else if(expr.id()==ID_function_application)
210 else if(expr.id()==ID_reduction_or || expr.id()==ID_reduction_and ||
211 expr.id()==ID_reduction_nor || expr.id()==ID_reduction_nand ||
212 expr.id()==ID_reduction_xor || expr.id()==ID_reduction_xnor)
214 else if(expr.id()==ID_not)
215 return convert_not(to_not_expr(expr));
216 else if(expr.id()==ID_power)
217 return convert_power(to_binary_expr(expr));
218 else if(expr.id() == ID_popcount)
219 return convert_bv(simplify_expr(to_popcount_expr(expr).lower(), ns));
220 else if(expr.id() == ID_count_leading_zeros)
221 {
222 return convert_bv(
224 }
225 else if(expr.id() == ID_count_trailing_zeros)
226 {
227 return convert_bv(
229 }
230 else if(expr.id() == ID_bitreverse)
232 else if(expr.id() == ID_saturating_minus || expr.id() == ID_saturating_plus)
234 else if(
235 const auto overflow_with_result =
237 {
238 return convert_overflow_result(*overflow_with_result);
239 }
240 else if(expr.id() == ID_find_first_set)
241 return convert_bv(simplify_expr(to_find_first_set_expr(expr).lower(), ns));
242
243 return conversion_failed(expr);
244}
245
247{
248 std::size_t width=boolbv_width(expr.type());
249
250 const exprt &array_size = expr.type().size();
251
252 const auto size = numeric_cast_v<mp_integer>(to_constant_expr(array_size));
253
254 typet counter_type = expr.arg().type();
255
256 bvt bv;
257 bv.resize(width);
258
259 for(mp_integer i = 0; i < size; ++i)
260 {
261 exprt counter=from_integer(i, counter_type);
262
263 exprt body = expr.instantiate({counter});
264
265 const bvt &tmp = convert_bv(body);
266
267 INVARIANT(
268 size * tmp.size() == width,
269 "total bitvector width shall equal the number of operands times the size "
270 "per operand");
271
272 std::size_t offset = numeric_cast_v<std::size_t>(i * tmp.size());
273
274 for(std::size_t j=0; j<tmp.size(); j++)
275 bv[offset+j]=tmp[j];
276 }
277
278 return bv;
279}
280
282{
283 const typet &type=expr.type();
284 std::size_t width=boolbv_width(type);
285
286 const irep_idt &identifier = expr.get(ID_identifier);
287 CHECK_RETURN(!identifier.empty());
288
289 bvt bv = map.get_literals(identifier, type, width);
290
292 std::all_of(
293 bv.begin(),
294 bv.end(),
295 [this](const literalt &l) {
296 return l.var_no() < prop.no_variables() || l.is_constant();
297 }),
298 "variable number of non-constant literals should be within bounds",
299 id2string(identifier));
300
301 return bv;
302}
303
304
306 const function_application_exprt &expr)
307{
308 // record
309 functions.record(expr);
310
311 // make it free bits
312 return prop.new_variables(boolbv_width(expr.type()));
313}
314
315
317{
318 PRECONDITION(expr.is_boolean());
319
320 if(expr.id()==ID_typecast)
322 else if(expr.id()==ID_equal)
323 return convert_equality(to_equal_expr(expr));
324 else if(expr.id()==ID_verilog_case_equality ||
325 expr.id()==ID_verilog_case_inequality)
327 else if(expr.id()==ID_notequal)
328 {
329 const auto &notequal_expr = to_notequal_expr(expr);
330 return !convert_equality(
331 equal_exprt(notequal_expr.lhs(), notequal_expr.rhs()));
332 }
333 else if(expr.id()==ID_ieee_float_equal ||
334 expr.id()==ID_ieee_float_notequal)
335 {
337 }
338 else if(expr.id()==ID_le || expr.id()==ID_ge ||
339 expr.id()==ID_lt || expr.id()==ID_gt)
340 {
342 }
343 else if(expr.id()==ID_extractbit)
345 else if(expr.id()==ID_forall)
347 else if(expr.id()==ID_exists)
349 else if(expr.id()==ID_let)
350 {
351 bvt bv=convert_let(to_let_expr(expr));
352
353 DATA_INVARIANT(bv.size()==1,
354 "convert_let must return 1-bit vector for boolean let");
355
356 return bv[0];
357 }
358 else if(expr.id()==ID_index)
359 {
361 CHECK_RETURN(bv.size() == 1);
362 return bv[0];
363 }
364 else if(expr.id()==ID_member)
365 {
367 CHECK_RETURN(bv.size() == 1);
368 return bv[0];
369 }
370 else if(expr.id()==ID_case)
371 {
372 bvt bv=convert_case(expr);
373 CHECK_RETURN(bv.size() == 1);
374 return bv[0];
375 }
376 else if(expr.id()==ID_cond)
377 {
378 bvt bv = convert_cond(to_cond_expr(expr));
379 CHECK_RETURN(bv.size() == 1);
380 return bv[0];
381 }
382 else if(expr.id()==ID_sign)
383 {
384 const auto &op = to_sign_expr(expr).op();
385 const bvt &bv = convert_bv(op);
386 CHECK_RETURN(!bv.empty());
387 const irep_idt type_id = op.type().id();
388 if(type_id == ID_signedbv || type_id == ID_fixedbv || type_id == ID_floatbv)
389 return bv[bv.size()-1];
390 if(type_id == ID_unsignedbv)
391 return const_literal(false);
392 }
393 else if(expr.id()==ID_reduction_or || expr.id()==ID_reduction_and ||
394 expr.id()==ID_reduction_nor || expr.id()==ID_reduction_nand ||
395 expr.id()==ID_reduction_xor || expr.id()==ID_reduction_xnor)
396 return convert_reduction(to_unary_expr(expr));
397 else if(expr.id()==ID_onehot || expr.id()==ID_onehot0)
398 return convert_onehot(to_unary_expr(expr));
399 else if(
400 const auto binary_overflow =
402 {
403 return convert_binary_overflow(*binary_overflow);
404 }
405 else if(
406 const auto unary_overflow =
408 {
409 return convert_unary_overflow(*unary_overflow);
410 }
411 else if(expr.id()==ID_isnan)
412 {
413 const auto &op = to_unary_expr(expr).op();
414 const bvt &bv = convert_bv(op);
415
416 if(op.type().id() == ID_floatbv)
417 {
418 float_utilst float_utils(prop, to_floatbv_type(op.type()));
419 return float_utils.is_NaN(bv);
420 }
421 else if(op.type().id() == ID_fixedbv)
422 return const_literal(false);
423 }
424 else if(expr.id()==ID_isfinite)
425 {
426 const auto &op = to_unary_expr(expr).op();
427 const bvt &bv = convert_bv(op);
428
429 if(op.type().id() == ID_floatbv)
430 {
431 float_utilst float_utils(prop, to_floatbv_type(op.type()));
432 return prop.land(
433 !float_utils.is_infinity(bv),
434 !float_utils.is_NaN(bv));
435 }
436 else if(op.id() == ID_fixedbv)
437 return const_literal(true);
438 }
439 else if(expr.id()==ID_isinf)
440 {
441 const auto &op = to_unary_expr(expr).op();
442 const bvt &bv = convert_bv(op);
443
444 if(op.type().id() == ID_floatbv)
445 {
446 float_utilst float_utils(prop, to_floatbv_type(op.type()));
447 return float_utils.is_infinity(bv);
448 }
449 else if(op.type().id() == ID_fixedbv)
450 return const_literal(false);
451 }
452 else if(expr.id()==ID_isnormal)
453 {
454 const auto &op = to_unary_expr(expr).op();
455
456 if(op.type().id() == ID_floatbv)
457 {
458 const bvt &bv = convert_bv(op);
459 float_utilst float_utils(prop, to_floatbv_type(op.type()));
460 return float_utils.is_normal(bv);
461 }
462 else if(op.type().id() == ID_fixedbv)
463 return const_literal(true);
464 }
465 else if(expr.id() == ID_function_application)
466 {
468 return prop.new_variable();
469 }
470
471 return SUB::convert_rest(expr);
472}
473
475{
477 return true;
478
479 const typet &type = expr.lhs().type();
480
481 if(
482 expr.lhs().id() == ID_symbol && type == expr.rhs().type() &&
483 type.id() != ID_bool)
484 {
485 // see if it is an unbounded array
486 if(is_unbounded_array(type))
487 return true;
488
489 const bvt &bv1=convert_bv(expr.rhs());
490
491 const irep_idt &identifier=
493
494 map.set_literals(identifier, type, bv1);
495
496 if(freeze_all)
497 set_frozen(bv1);
498
499 return false;
500 }
501
502 return true;
503}
504
505void boolbvt::set_to(const exprt &expr, bool value)
506{
507 PRECONDITION(expr.is_boolean());
508
509 const auto equal_expr = expr_try_dynamic_cast<equal_exprt>(expr);
510 if(value && equal_expr && !boolbv_set_equality_to_true(*equal_expr))
511 return;
512 SUB::set_to(expr, value);
513}
514
515bool boolbvt::is_unbounded_array(const typet &type) const
516{
517 if(type.id()!=ID_array)
518 return false;
519
521 return true;
522
523 const auto &size_opt = bv_width.get_width_opt(type);
524 if(!size_opt.has_value())
525 return true;
526
528 if(*size_opt > MAX_FLATTENED_ARRAY_SIZE)
529 return true;
530
531 return false;
532}
533
535{
536 // to ensure freshness of the new identifiers
538
540 result.reserve(binding.variables().size());
541
542 for(const auto &binding : binding.variables())
543 {
544 const auto &old_identifier = binding.get_identifier();
545
546 // produce a new identifier
547 const irep_idt new_identifier =
548 "boolbvt::scope::" + std::to_string(scope_counter) +
549 "::" + id2string(old_identifier);
550
551 result.emplace_back(new_identifier, binding.type());
552 }
553
554 return result;
555}
556
557void boolbvt::print_assignment(std::ostream &out) const
558{
560 map.show(out);
561}
562
564{
565 const struct_typet::componentst &components = src.components();
566 offset_mapt dest;
567 dest.reserve(components.size());
568 std::size_t offset = 0;
569 for(const auto &comp : components)
570 {
571 dest.push_back(offset);
572 offset += boolbv_width(comp.type());
573 }
574 return dest;
575}
configt config
Definition config.cpp:25
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Target numeric_cast_v(const mp_integer &arg)
Convert an mp_integer to integral type Target An invariant will fail if the conversion is not possibl...
API to expression classes for bitvectors.
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
const popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_exprt.
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const find_first_set_exprt & to_find_first_set_expr(const exprt &expr)
Cast an exprt to a find_first_set_exprt.
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
const count_leading_zeros_exprt & to_count_leading_zeros_expr(const exprt &expr)
Cast an exprt to a count_leading_zeros_exprt.
const bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
const concatenation_exprt & to_concatenation_expr(const exprt &expr)
Cast an exprt to a concatenation_exprt.
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
Pre-defined bitvector types.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
Expression classes for byte-level operators.
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
Expression to define a mapping from an argument (index) to elements.
Definition std_expr.h:3358
const array_typet & type() const
Definition std_expr.h:3372
const symbol_exprt & arg() const
Definition std_expr.h:3382
const exprt & size() const
Definition std_types.h:796
const namespacet & ns
Definition arrays.h:56
exprt & lhs()
Definition std_expr.h:613
exprt & rhs()
Definition std_expr.h:623
A base class for variable bindings (quantifiers, let, lambda)
Definition std_expr.h:3052
variablest & variables()
Definition std_expr.h:3073
exprt instantiate(const exprt::operandst &) const
substitute free occurrences of the variables in where() by the given values
Definition std_expr.cpp:169
std::vector< symbol_exprt > variablest
Definition std_expr.h:3054
void set_literals(const irep_idt &identifier, const typet &type, const bvt &literals)
void show(std::ostream &out) const
const bvt & get_literals(const irep_idt &identifier, const typet &type, std::size_t width)
virtual optionalt< std::size_t > get_width_opt(const typet &type) const
virtual bvt convert_with(const with_exprt &expr)
virtual bvt convert_array(const exprt &expr)
Flatten array.
virtual literalt convert_bv_rel(const binary_relation_exprt &)
Flatten <, >, <= and >= expressions.
bv_cachet bv_cache
Definition boolbv.h:132
virtual literalt convert_onehot(const unary_exprt &expr)
virtual bvt convert_index(const exprt &array, const mp_integer &index)
index operator with constant index
std::size_t scope_counter
Definition boolbv.h:276
virtual bvt convert_constraint_select_one(const exprt &expr)
virtual bvt convert_complex_imag(const complex_imag_exprt &expr)
virtual literalt convert_reduction(const unary_exprt &expr)
virtual literalt convert_ieee_float_rel(const binary_relation_exprt &)
virtual bvt convert_complex_real(const complex_real_exprt &expr)
virtual bvt convert_complex(const complex_exprt &expr)
virtual bvt convert_let(const let_exprt &)
virtual bvt convert_byte_extract(const byte_extract_exprt &expr)
offset_mapt build_offset_map(const struct_typet &src)
Definition boolbv.cpp:563
virtual bvt convert_bitvector(const exprt &expr)
Converts an expression into its gate-level representation and returns a vector of literals correspond...
Definition boolbv.cpp:96
binding_exprt::variablest fresh_binding(const binding_exprt &)
create new, unique variables for the given binding
Definition boolbv.cpp:534
virtual literalt convert_typecast(const typecast_exprt &expr)
conversion from bitvector types to boolean
virtual bvt convert_bswap(const bswap_exprt &expr)
bool is_unbounded_array(const typet &type) const override
Definition boolbv.cpp:515
virtual bvt convert_mod(const mod_exprt &expr)
virtual bvt convert_add_sub(const exprt &expr)
virtual bvt convert_constant(const constant_exprt &expr)
virtual literalt convert_quantifier(const quantifier_exprt &expr)
virtual bool boolbv_set_equality_to_true(const equal_exprt &expr)
Definition boolbv.cpp:474
virtual bvt convert_mult(const mult_exprt &expr)
virtual bvt convert_member(const member_exprt &expr)
virtual literalt convert_verilog_case_equality(const binary_relation_exprt &expr)
virtual bvt convert_function_application(const function_application_exprt &expr)
Definition boolbv.cpp:305
virtual bvt convert_cond(const cond_exprt &)
virtual bvt convert_empty_union(const empty_union_exprt &expr)
virtual bvt convert_if(const if_exprt &expr)
Definition boolbv_if.cpp:12
virtual bvt convert_union(const union_exprt &expr)
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'.
Definition boolbv.cpp:505
virtual bvt convert_byte_update(const byte_update_exprt &expr)
boolbv_widtht bv_width
Definition boolbv.h:113
virtual literalt convert_extractbit(const extractbit_exprt &expr)
unbounded_arrayt unbounded_array
Definition boolbv.h:85
virtual bvt convert_floatbv_op(const ieee_float_op_exprt &)
void print_assignment(std::ostream &out) const override
Print satisfying assignment to out.
Definition boolbv.cpp:557
virtual bvt convert_not(const not_exprt &expr)
virtual bvt convert_extractbits(const extractbits_exprt &expr)
virtual bvt convert_shift(const binary_exprt &expr)
virtual bvt convert_update(const update_exprt &)
virtual bvt convert_unary_minus(const unary_minus_exprt &expr)
virtual bvt convert_div(const div_exprt &expr)
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition boolbv.cpp:38
virtual literalt convert_binary_overflow(const binary_overflow_exprt &expr)
virtual bvt convert_array_of(const array_of_exprt &expr)
Flatten arrays constructed from a single element.
virtual bvt convert_floatbv_mod_rem(const binary_exprt &)
virtual bvt convert_saturating_add_sub(const binary_exprt &expr)
virtual bvt convert_overflow_result(const overflow_result_exprt &expr)
virtual bvt convert_bitwise(const exprt &expr)
virtual bvt convert_array_comprehension(const array_comprehension_exprt &)
Definition boolbv.cpp:246
virtual bvt convert_bv_reduction(const unary_exprt &expr)
virtual literalt convert_equality(const equal_exprt &expr)
functionst functions
Definition boolbv.h:117
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
Definition boolbv.cpp:82
virtual endianness_mapt endianness_map(const typet &type, bool little_endian) const
Definition boolbv.h:105
virtual literalt convert_unary_overflow(const unary_overflow_exprt &expr)
virtual std::size_t boolbv_width(const typet &type) const
Definition boolbv.h:99
virtual bvt convert_case(const exprt &expr)
virtual bvt convert_symbol(const exprt &expr)
Definition boolbv.cpp:281
virtual bvt convert_floatbv_typecast(const floatbv_typecast_exprt &expr)
virtual bvt convert_power(const binary_exprt &expr)
virtual bvt convert_bv_typecast(const typecast_exprt &expr)
virtual bvt convert_concatenation(const concatenation_exprt &expr)
virtual bvt convert_struct(const struct_exprt &expr)
virtual bvt convert_bitreverse(const bitreverse_exprt &expr)
virtual bvt convert_replication(const replication_exprt &expr)
literalt convert_rest(const exprt &expr) override
Definition boolbv.cpp:316
std::vector< std::size_t > offset_mapt
Definition boolbv.h:269
virtual bvt convert_abs(const abs_exprt &expr)
boolbv_mapt map
Definition boolbv.h:120
struct configt::ansi_ct ansi_c
virtual void print_assignment(std::ostream &out) const =0
Print satisfying assignment to out.
void set_to_true(const exprt &expr)
For a Boolean expression expr, add the constraint 'expr'.
virtual void set_to(const exprt &expr, bool value)=0
For a Boolean expression expr, add the constraint 'expr' if value is true, otherwise add 'not expr'.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:39
bool empty() const
Definition dstring.h:90
Maps a big-endian offset to a little-endian offset.
Equality.
Definition std_expr.h:1306
Base class for all expressions.
Definition expr.h:56
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
Definition expr.cpp:147
bool is_boolean() const
Return whether the expression represents a Boolean.
Definition expr.h:216
bool is_constant() const
Return whether the expression is a constant.
Definition expr.h:204
typet & type()
Return the type of the expression.
Definition expr.h:84
literalt is_NaN(const bvt &)
literalt is_infinity(const bvt &)
literalt is_normal(const bvt &)
Application of (mathematical) function.
void record(const function_application_exprt &function_application)
Definition functions.cpp:15
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:44
const irep_idt & id() const
Definition irep.h:396
static var_not unused_var_no()
Definition literal.h:176
void set_frozen(literalt)
virtual void ignoring(const exprt &expr)
literalt convert(const exprt &expr) override
Convert a Boolean expression and return the corresponding literal.
virtual literalt convert_rest(const exprt &expr)
virtual literalt land(literalt a, literalt b)=0
virtual void set_frozen(literalt)
Definition prop.h:117
virtual bvt new_variables(std::size_t width)
generates a bitvector of given width with new variables
Definition prop.cpp:30
virtual literalt new_variable()=0
Structure type, corresponds to C style structs.
Definition std_types.h:231
const componentst & components() const
Definition std_types.h:147
std::vector< componentt > componentst
Definition std_types.h:140
const irep_idt & get_identifier() const
Definition std_expr.h:142
The type of an expression, extends irept.
Definition type.h:29
const exprt & op() const
Definition std_expr.h:326
auto expr_try_dynamic_cast(TExpr &base) -> typename detail::expr_try_dynamic_cast_return_typet< T, TExpr >::type
Try to cast a reference to a generic exprt to a specific derived class.
Definition expr_cast.h:81
API to expression classes for floating-point arithmetic.
const ieee_float_op_exprt & to_ieee_float_op_expr(const exprt &expr)
Cast an exprt to an ieee_float_op_exprt.
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
const std::string & id2string(const irep_idt &d)
Definition irep.h:47
std::vector< literalt > bvt
Definition literal.h:201
literalt const_literal(bool value)
Definition literal.h:188
Magic numbers used throughout the codebase.
const std::size_t MAX_FLATTENED_ARRAY_SIZE
Definition magic.h:11
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
const function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
nonstd::optional< T > optionalt
Definition optional.h:35
exprt simplify_expr(exprt src, const namespacet &ns)
BigInt mp_integer
Definition smt_terms.h:18
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition invariant.h:534
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#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...
Definition invariant.h:437
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423
API to expression classes.
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
Definition std_expr.h:1842
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
Definition std_expr.h:1543
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
Definition std_expr.h:840
const unary_plus_exprt & to_unary_plus_expr(const exprt &expr)
Cast an exprt to a unary_plus_exprt.
Definition std_expr.h:497
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition std_expr.h:1478
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
Definition std_expr.h:1217
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
Definition std_expr.h:1077
const array_comprehension_exprt & to_array_comprehension_expr(const exprt &expr)
Cast an exprt to a array_comprehension_exprt.
Definition std_expr.h:3425
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
Definition std_expr.h:3609
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
Definition std_expr.h:1603
const cond_exprt & to_cond_expr(const exprt &expr)
Cast an exprt to a cond_exprt.
Definition std_expr.h:3332
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition std_expr.h:2051
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
Definition std_expr.h:1146
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition std_expr.h:660
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
Definition std_expr.h:1390
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition std_expr.h:361
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
Definition std_expr.h:3273
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
Definition std_expr.h:403
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition std_expr.h:2403
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition std_expr.h:2886
const empty_union_exprt & to_empty_union_expr(const exprt &expr)
Cast an exprt to an empty_union_exprt.
Definition std_expr.h:1800
const complex_imag_exprt & to_complex_imag_expr(const exprt &expr)
Cast an exprt to a complex_imag_exprt.
Definition std_expr.h:1997
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
Definition std_expr.h:1754
const complex_real_exprt & to_complex_real_expr(const exprt &expr)
Cast an exprt to a complex_real_exprt.
Definition std_expr.h:1952
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition std_expr.h:2992
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition std_expr.h:2303
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition std_expr.h:222
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Definition std_expr.h:2486
const complex_exprt & to_complex_expr(const exprt &expr)
Cast an exprt to a complex_exprt.
Definition std_expr.h:1907
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
Definition std_expr.h:2688
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
Definition std_expr.h:453
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
Definition std_expr.h:1347
const sign_exprt & to_sign_expr(const exprt &expr)
Cast an exprt to a sign_exprt.
Definition std_expr.h:564
const string_constantt & to_string_constant(const exprt &expr)
endiannesst endianness
Definition config.h:204