CBMC
boolbv.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: 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>
15 #include <util/bitvector_types.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>
23 #include <util/string_constant.h>
24 
26 
28 {
29  const bool little_endian =
31  return endianness_map(type, little_endian);
32 }
33 
38  const exprt &expr,
39  std::optional<std::size_t> expected_width)
40 {
41  // check cache first
42  std::pair<bv_cachet::iterator, bool> cache_result=
43  bv_cache.insert(std::make_pair(expr, bvt()));
44 
45  // get a reference to the cache entry
46  auto &cache_entry = cache_result.first->second;
47 
48  if(!cache_result.second)
49  {
50  // Found in cache
51  return cache_entry;
52  }
53 
54  // Iterators into hash_maps do not remain valid when inserting
55  // more elements recursively. C++11 ยง23.2.5/13
56  // However, the _reference_ to the entry does!
57  cache_entry = convert_bitvector(expr);
58 
60  !expected_width || cache_entry.size() == *expected_width,
61  "bitvector width shall match the indicated expected width",
62  expr.find_source_location(),
64 
65  // check
66  for(const auto &literal : cache_entry)
67  {
68  if(freeze_all && !literal.is_constant())
69  prop.set_frozen(literal);
70 
72  literal.var_no() != literalt::unused_var_no(),
73  "variable number must be different from the unused variable number",
74  expr.find_source_location(),
76  }
77 
78  return cache_entry;
79 }
80 
84 {
85  ignoring(expr);
86 
87  // try to make it free bits
88  std::size_t width=boolbv_width(expr.type());
89  return prop.new_variables(width);
90 }
91 
98 {
99  if(expr.is_boolean())
100  return {convert(expr)};
101 
102  if(expr.id()==ID_index)
103  return convert_index(to_index_expr(expr));
104  else if(expr.id()==ID_constraint_select_one)
105  return convert_constraint_select_one(expr);
106  else if(expr.id()==ID_member)
107  return convert_member(to_member_expr(expr));
108  else if(expr.id()==ID_with)
109  return convert_with(to_with_expr(expr));
110  else if(expr.id()==ID_update)
111  return convert_update(to_update_expr(expr));
112  else if(expr.id() == ID_update_bit)
114  else if(expr.id()==ID_case)
115  return convert_case(expr);
116  else if(expr.id()==ID_cond)
117  return convert_cond(to_cond_expr(expr));
118  else if(expr.id()==ID_if)
119  return convert_if(to_if_expr(expr));
120  else if(expr.is_constant())
121  return convert_constant(to_constant_expr(expr));
122  else if(expr.id()==ID_typecast)
124  else if(expr.id()==ID_symbol)
125  return convert_symbol(to_symbol_expr(expr));
126  else if(expr.id()==ID_plus || expr.id()==ID_minus ||
127  expr.id()=="no-overflow-plus" ||
128  expr.id()=="no-overflow-minus")
129  return convert_add_sub(expr);
130  else if(expr.id() == ID_mult)
131  return convert_mult(to_mult_expr(expr));
132  else if(expr.id()==ID_div)
133  return convert_div(to_div_expr(expr));
134  else if(expr.id()==ID_mod)
135  return convert_mod(to_mod_expr(expr));
136  else if(expr.id()==ID_shl || expr.id()==ID_ashr || expr.id()==ID_lshr ||
137  expr.id()==ID_rol || expr.id()==ID_ror)
138  return convert_shift(to_shift_expr(expr));
139  else if(
140  expr.id() == ID_floatbv_plus || expr.id() == ID_floatbv_minus ||
141  expr.id() == ID_floatbv_mult || expr.id() == ID_floatbv_div)
142  {
144  }
145  else if(expr.id() == ID_floatbv_mod)
147  else if(expr.id() == ID_floatbv_rem)
149  else if(expr.id()==ID_floatbv_typecast)
151  else if(expr.id()==ID_concatenation)
153  else if(expr.id()==ID_replication)
155  else if(expr.id()==ID_extractbits)
157  else if(expr.id()==ID_bitnot || expr.id()==ID_bitand ||
158  expr.id()==ID_bitor || expr.id()==ID_bitxor ||
159  expr.id()==ID_bitxnor || expr.id()==ID_bitnor ||
160  expr.id()==ID_bitnand)
161  return convert_bitwise(expr);
162  else if(expr.id() == ID_unary_minus)
164  else if(expr.id()==ID_unary_plus)
165  {
166  return convert_bitvector(to_unary_plus_expr(expr).op());
167  }
168  else if(expr.id()==ID_abs)
169  return convert_abs(to_abs_expr(expr));
170  else if(expr.id() == ID_bswap)
171  return convert_bswap(to_bswap_expr(expr));
172  else if(expr.id()==ID_byte_extract_little_endian ||
173  expr.id()==ID_byte_extract_big_endian)
175  else if(expr.id()==ID_byte_update_little_endian ||
176  expr.id()==ID_byte_update_big_endian)
178  else if(expr.id()==ID_nondet_symbol ||
179  expr.id()=="quant_symbol")
180  return convert_symbol(expr);
181  else if(expr.id()==ID_struct)
182  return convert_struct(to_struct_expr(expr));
183  else if(expr.id()==ID_union)
184  return convert_union(to_union_expr(expr));
185  else if(expr.id() == ID_empty_union)
187  else if(expr.id()==ID_string_constant)
188  return convert_bitvector(
190  else if(expr.id() == ID_named_term)
191  {
192  const auto &named_term_expr = to_named_term_expr(expr);
193  set_to_true(equal_exprt(named_term_expr.symbol(), named_term_expr.value()));
194  return convert_symbol(named_term_expr.symbol());
195  }
196  else if(expr.id()==ID_array)
197  return convert_array(expr);
198  else if(expr.id()==ID_complex)
199  return convert_complex(to_complex_expr(expr));
200  else if(expr.id()==ID_complex_real)
202  else if(expr.id()==ID_complex_imag)
204  else if(expr.id() == ID_array_comprehension)
206  else if(expr.id()==ID_array_of)
207  return convert_array_of(to_array_of_expr(expr));
208  else if(expr.id()==ID_let)
209  return convert_let(to_let_expr(expr));
210  else if(expr.id()==ID_function_application)
213  else if(expr.id()==ID_reduction_or || expr.id()==ID_reduction_and ||
214  expr.id()==ID_reduction_nor || expr.id()==ID_reduction_nand ||
215  expr.id()==ID_reduction_xor || expr.id()==ID_reduction_xnor)
216  return convert_bv_reduction(to_unary_expr(expr));
217  else if(expr.id()==ID_not)
218  return convert_not(to_not_expr(expr));
219  else if(expr.id()==ID_power)
220  return convert_power(to_binary_expr(expr));
221  else if(expr.id() == ID_popcount)
222  return convert_bv(simplify_expr(to_popcount_expr(expr).lower(), ns));
223  else if(expr.id() == ID_count_leading_zeros)
224  {
225  return convert_bv(
227  }
228  else if(expr.id() == ID_count_trailing_zeros)
229  {
230  return convert_bv(
232  }
233  else if(expr.id() == ID_bitreverse)
235  else if(expr.id() == ID_saturating_minus || expr.id() == ID_saturating_plus)
237  else if(
238  const auto overflow_with_result =
239  expr_try_dynamic_cast<overflow_result_exprt>(expr))
240  {
241  return convert_overflow_result(*overflow_with_result);
242  }
243  else if(expr.id() == ID_find_first_set)
244  return convert_bv(simplify_expr(to_find_first_set_expr(expr).lower(), ns));
245 
246  return conversion_failed(expr);
247 }
248 
250 {
251  std::size_t width=boolbv_width(expr.type());
252 
253  const exprt &array_size = expr.type().size();
254 
255  const auto size = numeric_cast_v<mp_integer>(to_constant_expr(array_size));
256 
257  typet counter_type = expr.arg().type();
258 
259  bvt bv;
260  bv.resize(width);
261 
262  for(mp_integer i = 0; i < size; ++i)
263  {
264  exprt counter=from_integer(i, counter_type);
265 
266  exprt body = expr.instantiate({counter});
267 
268  const bvt &tmp = convert_bv(body);
269 
270  INVARIANT(
271  size * tmp.size() == width,
272  "total bitvector width shall equal the number of operands times the size "
273  "per operand");
274 
275  std::size_t offset = numeric_cast_v<std::size_t>(i * tmp.size());
276 
277  for(std::size_t j=0; j<tmp.size(); j++)
278  bv[offset+j]=tmp[j];
279  }
280 
281  return bv;
282 }
283 
285 {
286  const typet &type=expr.type();
287  std::size_t width=boolbv_width(type);
288 
289  const irep_idt &identifier = expr.get(ID_identifier);
290  CHECK_RETURN(!identifier.empty());
291 
292  bvt bv = map.get_literals(identifier, type, width);
293 
295  std::all_of(
296  bv.begin(),
297  bv.end(),
298  [this](const literalt &l) {
299  return l.var_no() < prop.no_variables() || l.is_constant();
300  }),
301  "variable number of non-constant literals should be within bounds",
302  id2string(identifier));
303 
304  return bv;
305 }
306 
307 
309  const function_application_exprt &expr)
310 {
311  // record
312  functions.record(expr);
313 
314  // make it free bits
315  return prop.new_variables(boolbv_width(expr.type()));
316 }
317 
318 
320 {
321  PRECONDITION(expr.is_boolean());
322 
323  if(expr.id()==ID_typecast)
324  return convert_typecast(to_typecast_expr(expr));
325  else if(expr.id()==ID_equal)
326  return convert_equality(to_equal_expr(expr));
327  else if(expr.id()==ID_verilog_case_equality ||
328  expr.id()==ID_verilog_case_inequality)
330  else if(expr.id()==ID_notequal)
331  {
332  const auto &notequal_expr = to_notequal_expr(expr);
333  return !convert_equality(
334  equal_exprt(notequal_expr.lhs(), notequal_expr.rhs()));
335  }
336  else if(expr.id()==ID_ieee_float_equal ||
337  expr.id()==ID_ieee_float_notequal)
338  {
340  }
341  else if(expr.id()==ID_le || expr.id()==ID_ge ||
342  expr.id()==ID_lt || expr.id()==ID_gt)
343  {
345  }
346  else if(expr.id()==ID_extractbit)
348  else if(expr.id()==ID_forall)
350  else if(expr.id()==ID_exists)
352  else if(expr.id()==ID_let)
353  {
354  bvt bv=convert_let(to_let_expr(expr));
355 
356  DATA_INVARIANT(bv.size()==1,
357  "convert_let must return 1-bit vector for boolean let");
358 
359  return bv[0];
360  }
361  else if(expr.id()==ID_index)
362  {
363  bvt bv=convert_index(to_index_expr(expr));
364  CHECK_RETURN(bv.size() == 1);
365  return bv[0];
366  }
367  else if(expr.id()==ID_member)
368  {
370  CHECK_RETURN(bv.size() == 1);
371  return bv[0];
372  }
373  else if(expr.id()==ID_case)
374  {
375  bvt bv=convert_case(expr);
376  CHECK_RETURN(bv.size() == 1);
377  return bv[0];
378  }
379  else if(expr.id()==ID_cond)
380  {
381  bvt bv = convert_cond(to_cond_expr(expr));
382  CHECK_RETURN(bv.size() == 1);
383  return bv[0];
384  }
385  else if(expr.id()==ID_sign)
386  {
387  const auto &op = to_sign_expr(expr).op();
388  const bvt &bv = convert_bv(op);
389  CHECK_RETURN(!bv.empty());
390  const irep_idt type_id = op.type().id();
391  if(type_id == ID_signedbv || type_id == ID_fixedbv || type_id == ID_floatbv)
392  return bv[bv.size()-1];
393  if(type_id == ID_unsignedbv)
394  return const_literal(false);
395  }
396  else if(expr.id()==ID_reduction_or || expr.id()==ID_reduction_and ||
397  expr.id()==ID_reduction_nor || expr.id()==ID_reduction_nand ||
398  expr.id()==ID_reduction_xor || expr.id()==ID_reduction_xnor)
399  return convert_reduction(to_unary_expr(expr));
400  else if(expr.id()==ID_onehot || expr.id()==ID_onehot0)
401  return convert_onehot(to_unary_expr(expr));
402  else if(
403  const auto binary_overflow =
404  expr_try_dynamic_cast<binary_overflow_exprt>(expr))
405  {
406  return convert_binary_overflow(*binary_overflow);
407  }
408  else if(
409  const auto unary_overflow =
410  expr_try_dynamic_cast<unary_overflow_exprt>(expr))
411  {
412  return convert_unary_overflow(*unary_overflow);
413  }
414  else if(expr.id()==ID_isnan)
415  {
416  const auto &op = to_unary_expr(expr).op();
417  const bvt &bv = convert_bv(op);
418 
419  if(op.type().id() == ID_floatbv)
420  {
421  float_utilst float_utils(prop, to_floatbv_type(op.type()));
422  return float_utils.is_NaN(bv);
423  }
424  else if(op.type().id() == ID_fixedbv)
425  return const_literal(false);
426  }
427  else if(expr.id()==ID_isfinite)
428  {
429  const auto &op = to_unary_expr(expr).op();
430  const bvt &bv = convert_bv(op);
431 
432  if(op.type().id() == ID_floatbv)
433  {
434  float_utilst float_utils(prop, to_floatbv_type(op.type()));
435  return prop.land(
436  !float_utils.is_infinity(bv),
437  !float_utils.is_NaN(bv));
438  }
439  else if(op.id() == ID_fixedbv)
440  return const_literal(true);
441  }
442  else if(expr.id()==ID_isinf)
443  {
444  const auto &op = to_unary_expr(expr).op();
445  const bvt &bv = convert_bv(op);
446 
447  if(op.type().id() == ID_floatbv)
448  {
449  float_utilst float_utils(prop, to_floatbv_type(op.type()));
450  return float_utils.is_infinity(bv);
451  }
452  else if(op.type().id() == ID_fixedbv)
453  return const_literal(false);
454  }
455  else if(expr.id()==ID_isnormal)
456  {
457  const auto &op = to_unary_expr(expr).op();
458 
459  if(op.type().id() == ID_floatbv)
460  {
461  const bvt &bv = convert_bv(op);
462  float_utilst float_utils(prop, to_floatbv_type(op.type()));
463  return float_utils.is_normal(bv);
464  }
465  else if(op.type().id() == ID_fixedbv)
466  return const_literal(true);
467  }
468  else if(expr.id() == ID_function_application)
469  {
471  return prop.new_variable();
472  }
473 
474  return SUB::convert_rest(expr);
475 }
476 
478 {
480  return true;
481 
482  const typet &type = expr.lhs().type();
483 
484  if(
485  expr.lhs().id() == ID_symbol && type == expr.rhs().type() &&
486  type.id() != ID_bool)
487  {
488  // see if it is an unbounded array
489  if(is_unbounded_array(type))
490  return true;
491 
492  const bvt &bv1=convert_bv(expr.rhs());
493 
494  const irep_idt &identifier=
496 
497  map.set_literals(identifier, type, bv1);
498 
499  if(freeze_all)
500  set_frozen(bv1);
501 
502  return false;
503  }
504 
505  return true;
506 }
507 
508 void boolbvt::set_to(const exprt &expr, bool value)
509 {
510  PRECONDITION(expr.is_boolean());
511 
512  const auto equal_expr = expr_try_dynamic_cast<equal_exprt>(expr);
513  if(value && equal_expr && !boolbv_set_equality_to_true(*equal_expr))
514  return;
515  SUB::set_to(expr, value);
516 }
517 
518 bool boolbvt::is_unbounded_array(const typet &type) const
519 {
520  if(type.id()!=ID_array)
521  return false;
522 
524  return true;
525 
526  const auto &size_opt = bv_width.get_width_opt(type);
527  if(!size_opt.has_value())
528  return true;
529 
531  if(*size_opt > MAX_FLATTENED_ARRAY_SIZE)
532  return true;
533 
534  return false;
535 }
536 
538 {
539  // to ensure freshness of the new identifiers
540  scope_counter++;
541 
543  result.reserve(binding.variables().size());
544 
545  for(const auto &binding : binding.variables())
546  {
547  const auto &old_identifier = binding.get_identifier();
548 
549  // produce a new identifier
550  const irep_idt new_identifier =
551  "boolbvt::scope::" + std::to_string(scope_counter) +
552  "::" + id2string(old_identifier);
553 
554  result.emplace_back(new_identifier, binding.type());
555  }
556 
557  return result;
558 }
559 
560 void boolbvt::print_assignment(std::ostream &out) const
561 {
563  map.show(out);
564 }
565 
567 {
568  const struct_typet::componentst &components = src.components();
569  offset_mapt dest;
570  dest.reserve(components.size());
571  std::size_t offset = 0;
572  for(const auto &comp : components)
573  {
574  dest.push_back(offset);
575  offset += boolbv_width(comp.type());
576  }
577  return dest;
578 }
configt config
Definition: config.cpp:25
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
API to expression classes for bitvectors.
const update_bit_exprt & to_update_bit_expr(const exprt &expr)
Cast an exprt to an update_bit_exprt.
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_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 bitreverse_exprt & to_bitreverse_expr(const exprt &expr)
Cast an exprt to a bitreverse_exprt.
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
const replication_exprt & to_replication_expr(const exprt &expr)
Cast an exprt to a replication_exprt.
const concatenation_exprt & to_concatenation_expr(const exprt &expr)
Cast an exprt to a concatenation_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 popcount_exprt & to_popcount_expr(const exprt &expr)
Cast an exprt to a popcount_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:3405
const array_typet & type() const
Definition: std_expr.h:3419
const symbol_exprt & arg() const
Definition: std_expr.h:3429
const exprt & size() const
Definition: std_types.h:840
const namespacet & ns
Definition: arrays.h:56
exprt & lhs()
Definition: std_expr.h:668
exprt & rhs()
Definition: std_expr.h:678
A base class for variable bindings (quantifiers, let, lambda)
Definition: std_expr.h:3099
exprt instantiate(const exprt::operandst &) const
substitute free occurrences of the variables in where() by the given values
Definition: std_expr.cpp:177
variablest & variables()
Definition: std_expr.h:3120
std::vector< symbol_exprt > variablest
Definition: std_expr.h:3101
void set_literals(const irep_idt &identifier, const typet &type, const bvt &literals)
Definition: boolbv_map.cpp:75
void show(std::ostream &out) const
Definition: boolbv_map.cpp:35
const bvt & get_literals(const irep_idt &identifier, const typet &type, std::size_t width)
Definition: boolbv_map.cpp:41
virtual std::optional< std::size_t > get_width_opt(const typet &type) const
Definition: boolbv_width.h:31
virtual bvt convert_with(const with_exprt &expr)
Definition: boolbv_with.cpp:17
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:134
virtual literalt convert_onehot(const unary_exprt &expr)
virtual bvt convert_index(const exprt &array, const mp_integer &index)
index operator with constant index
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition: boolbv.cpp:37
std::size_t scope_counter
Definition: boolbv.h:282
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 &)
Definition: boolbv_let.cpp:15
virtual bvt convert_byte_extract(const byte_extract_exprt &expr)
offset_mapt build_offset_map(const struct_typet &src)
Definition: boolbv.cpp:566
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:97
binding_exprt::variablest fresh_binding(const binding_exprt &)
create new, unique variables for the given binding
Definition: boolbv.cpp:537
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:518
virtual bvt convert_mod(const mod_exprt &expr)
Definition: boolbv_mod.cpp:12
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:477
virtual bvt convert_mult(const mult_exprt &expr)
Definition: boolbv_mult.cpp:13
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:308
virtual bvt convert_cond(const cond_exprt &)
Definition: boolbv_cond.cpp:13
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:508
virtual bvt convert_byte_update(const byte_update_exprt &expr)
boolbv_widtht bv_width
Definition: boolbv.h:115
virtual literalt convert_extractbit(const extractbit_exprt &expr)
unbounded_arrayt unbounded_array
Definition: boolbv.h:87
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:560
virtual bvt convert_not(const not_exprt &expr)
Definition: boolbv_not.cpp:13
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)
Definition: boolbv_div.cpp:13
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:249
virtual bvt convert_bv_reduction(const unary_exprt &expr)
virtual literalt convert_equality(const equal_exprt &expr)
functionst functions
Definition: boolbv.h:119
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:83
virtual endianness_mapt endianness_map(const typet &type, bool little_endian) const
Definition: boolbv.h:107
virtual literalt convert_unary_overflow(const unary_overflow_exprt &expr)
virtual std::size_t boolbv_width(const typet &type) const
Definition: boolbv.h:101
virtual bvt convert_case(const exprt &expr)
Definition: boolbv_case.cpp:13
virtual bvt convert_symbol(const exprt &expr)
Definition: boolbv.cpp:284
virtual bvt convert_update_bit(const update_bit_exprt &)
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:319
std::vector< std::size_t > offset_mapt
Definition: boolbv.h:275
virtual bvt convert_abs(const abs_exprt &expr)
Definition: boolbv_abs.cpp:17
boolbv_mapt map
Definition: boolbv.h:122
struct configt::ansi_ct ansi_c
void set_to_true(const exprt &)
For a Boolean expression expr, add the constraint 'expr'.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
bool empty() const
Definition: dstring.h:89
Maps a big-endian offset to a little-endian offset.
Equality.
Definition: std_expr.h:1361
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:224
typet & type()
Return the type of the expression.
Definition: expr.h:84
bool is_constant() const
Return whether the expression is a constant.
Definition: expr.h:212
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:384
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)
void set_to(const exprt &expr, bool value) override
For a Boolean expression expr, add the constraint 'current_context => expr' if value is true,...
void print_assignment(std::ostream &out) const override
Print satisfying assignment to out.
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:160
The type of an expression, extends irept.
Definition: type.h:29
const exprt & op() const
Definition: std_expr.h:391
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.
Definition: floatbv_expr.h:425
const floatbv_typecast_exprt & to_floatbv_typecast_expr(const exprt &expr)
Cast an exprt to a floatbv_typecast_exprt.
Definition: floatbv_expr.h:68
const std::string & id2string(const irep_idt &d)
Definition: irep.h:40
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 function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
exprt simplify_expr(exprt src, const namespacet &ns)
BigInt mp_integer
Definition: smt_terms.h:17
#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
API to expression classes.
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
Definition: std_expr.h:1445
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition: std_expr.h:2450
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
Definition: std_expr.h:2735
const empty_union_exprt & to_empty_union_expr(const exprt &expr)
Cast an exprt to an empty_union_exprt.
Definition: std_expr.h:1855
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
Definition: std_expr.h:3320
const unary_plus_exprt & to_unary_plus_expr(const exprt &expr)
Cast an exprt to a unary_plus_exprt.
Definition: std_expr.h:556
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition: std_expr.h:3037
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:272
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
Definition: std_expr.h:1272
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
Definition: std_expr.h:1660
const array_comprehension_exprt & to_array_comprehension_expr(const exprt &expr)
Cast an exprt to a array_comprehension_exprt.
Definition: std_expr.h:3472
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition: std_expr.h:2102
const complex_real_exprt & to_complex_real_expr(const exprt &expr)
Cast an exprt to a complex_real_exprt.
Definition: std_expr.h:2005
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition: std_expr.h:2352
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
Definition: std_expr.h:1811
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
Definition: std_expr.h:514
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
Definition: std_expr.h:3654
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
Definition: std_expr.h:1201
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Definition: std_expr.h:2533
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
Definition: std_expr.h:1895
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition: std_expr.h:715
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
Definition: std_expr.h:1598
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
Definition: std_expr.h:1402
const complex_exprt & to_complex_expr(const exprt &expr)
Cast an exprt to a complex_exprt.
Definition: std_expr.h:1960
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition: std_expr.h:2933
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition: std_expr.h:426
const complex_imag_exprt & to_complex_imag_expr(const exprt &expr)
Cast an exprt to a complex_imag_exprt.
Definition: std_expr.h:2048
const sign_exprt & to_sign_expr(const exprt &expr)
Cast an exprt to a sign_exprt.
Definition: std_expr.h:621
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
Definition: std_expr.h:466
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
Definition: std_expr.h:895
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition: std_expr.h:1533
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
Definition: std_expr.h:1132
const cond_exprt & to_cond_expr(const exprt &expr)
Cast an exprt to a cond_exprt.
Definition: std_expr.h:3379
const string_constantt & to_string_constant(const exprt &expr)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
endiannesst endianness
Definition: config.h:207