CBMC
bitvector_expr.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: API to expression classes for bitvectors
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_UTIL_BITVECTOR_EXPR_H
10 #define CPROVER_UTIL_BITVECTOR_EXPR_H
11 
14 
15 #include "std_expr.h"
16 
18 class bswap_exprt : public unary_exprt
19 {
20 public:
21  bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
22  : unary_exprt(ID_bswap, std::move(_op), std::move(_type))
23  {
24  set_bits_per_byte(bits_per_byte);
25  }
26 
27  bswap_exprt(exprt _op, std::size_t bits_per_byte)
28  : unary_exprt(ID_bswap, std::move(_op))
29  {
30  set_bits_per_byte(bits_per_byte);
31  }
32 
33  std::size_t get_bits_per_byte() const
34  {
35  return get_size_t(ID_bits_per_byte);
36  }
37 
38  void set_bits_per_byte(std::size_t bits_per_byte)
39  {
40  set_size_t(ID_bits_per_byte, bits_per_byte);
41  }
42 };
43 
44 template <>
45 inline bool can_cast_expr<bswap_exprt>(const exprt &base)
46 {
47  return base.id() == ID_bswap;
48 }
49 
50 inline void validate_expr(const bswap_exprt &value)
51 {
52  validate_operands(value, 1, "bswap must have one operand");
54  value.op().type() == value.type(), "bswap type must match operand type");
55 }
56 
63 inline const bswap_exprt &to_bswap_expr(const exprt &expr)
64 {
65  PRECONDITION(expr.id() == ID_bswap);
66  const bswap_exprt &ret = static_cast<const bswap_exprt &>(expr);
67  validate_expr(ret);
68  return ret;
69 }
70 
73 {
74  PRECONDITION(expr.id() == ID_bswap);
75  bswap_exprt &ret = static_cast<bswap_exprt &>(expr);
76  validate_expr(ret);
77  return ret;
78 }
79 
81 class bitnot_exprt : public unary_exprt
82 {
83 public:
84  explicit bitnot_exprt(exprt op) : unary_exprt(ID_bitnot, std::move(op))
85  {
86  }
87 };
88 
89 template <>
90 inline bool can_cast_expr<bitnot_exprt>(const exprt &base)
91 {
92  return base.id() == ID_bitnot;
93 }
94 
95 inline void validate_expr(const bitnot_exprt &value)
96 {
97  validate_operands(value, 1, "Bit-wise not must have one operand");
98 }
99 
106 inline const bitnot_exprt &to_bitnot_expr(const exprt &expr)
107 {
108  PRECONDITION(expr.id() == ID_bitnot);
109  const bitnot_exprt &ret = static_cast<const bitnot_exprt &>(expr);
110  validate_expr(ret);
111  return ret;
112 }
113 
116 {
117  PRECONDITION(expr.id() == ID_bitnot);
118  bitnot_exprt &ret = static_cast<bitnot_exprt &>(expr);
119  validate_expr(ret);
120  return ret;
121 }
122 
125 {
126 public:
127  bitor_exprt(const exprt &_op0, exprt _op1)
128  : multi_ary_exprt(_op0, ID_bitor, std::move(_op1), _op0.type())
129  {
130  }
131 };
132 
133 template <>
134 inline bool can_cast_expr<bitor_exprt>(const exprt &base)
135 {
136  return base.id() == ID_bitor;
137 }
138 
145 inline const bitor_exprt &to_bitor_expr(const exprt &expr)
146 {
147  PRECONDITION(expr.id() == ID_bitor);
148  return static_cast<const bitor_exprt &>(expr);
149 }
150 
153 {
154  PRECONDITION(expr.id() == ID_bitor);
155  return static_cast<bitor_exprt &>(expr);
156 }
157 
160 {
161 public:
163  : multi_ary_exprt(std::move(_op0), ID_bitxor, std::move(_op1))
164  {
165  }
166 };
167 
168 template <>
169 inline bool can_cast_expr<bitxor_exprt>(const exprt &base)
170 {
171  return base.id() == ID_bitxor;
172 }
173 
180 inline const bitxor_exprt &to_bitxor_expr(const exprt &expr)
181 {
182  PRECONDITION(expr.id() == ID_bitxor);
183  return static_cast<const bitxor_exprt &>(expr);
184 }
185 
188 {
189  PRECONDITION(expr.id() == ID_bitxor);
190  return static_cast<bitxor_exprt &>(expr);
191 }
192 
195 {
196 public:
197  bitand_exprt(const exprt &_op0, exprt _op1)
198  : multi_ary_exprt(_op0, ID_bitand, std::move(_op1), _op0.type())
199  {
200  }
201 };
202 
203 template <>
204 inline bool can_cast_expr<bitand_exprt>(const exprt &base)
205 {
206  return base.id() == ID_bitand;
207 }
208 
215 inline const bitand_exprt &to_bitand_expr(const exprt &expr)
216 {
217  PRECONDITION(expr.id() == ID_bitand);
218  return static_cast<const bitand_exprt &>(expr);
219 }
220 
223 {
224  PRECONDITION(expr.id() == ID_bitand);
225  return static_cast<bitand_exprt &>(expr);
226 }
227 
229 class shift_exprt : public binary_exprt
230 {
231 public:
232  shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
233  : binary_exprt(std::move(_src), _id, std::move(_distance))
234  {
235  }
236 
237  shift_exprt(exprt _src, const irep_idt &_id, const std::size_t _distance);
238 
240  {
241  return op0();
242  }
243 
244  const exprt &op() const
245  {
246  return op0();
247  }
248 
250  {
251  return op1();
252  }
253 
254  const exprt &distance() const
255  {
256  return op1();
257  }
258 };
259 
260 template <>
261 inline bool can_cast_expr<shift_exprt>(const exprt &base)
262 {
263  return base.id() == ID_shl || base.id() == ID_ashr || base.id() == ID_lshr ||
264  base.id() == ID_ror || base.id() == ID_rol;
265 }
266 
267 inline void validate_expr(const shift_exprt &value)
268 {
269  validate_operands(value, 2, "Shifts must have two operands");
270 }
271 
278 inline const shift_exprt &to_shift_expr(const exprt &expr)
279 {
280  const shift_exprt &ret = static_cast<const shift_exprt &>(expr);
281  validate_expr(ret);
282  return ret;
283 }
284 
287 {
288  shift_exprt &ret = static_cast<shift_exprt &>(expr);
289  validate_expr(ret);
290  return ret;
291 }
292 
294 class shl_exprt : public shift_exprt
295 {
296 public:
297  shl_exprt(exprt _src, exprt _distance)
298  : shift_exprt(std::move(_src), ID_shl, std::move(_distance))
299  {
300  }
301 
302  shl_exprt(exprt _src, const std::size_t _distance)
303  : shift_exprt(std::move(_src), ID_shl, _distance)
304  {
305  }
306 };
307 
308 template <>
309 inline bool can_cast_expr<shl_exprt>(const exprt &base)
310 {
311  return base.id() == ID_shl;
312 }
313 
320 inline const shl_exprt &to_shl_expr(const exprt &expr)
321 {
322  PRECONDITION(expr.id() == ID_shl);
323  const shl_exprt &ret = static_cast<const shl_exprt &>(expr);
324  validate_expr(ret);
325  return ret;
326 }
327 
330 {
331  PRECONDITION(expr.id() == ID_shl);
332  shl_exprt &ret = static_cast<shl_exprt &>(expr);
333  validate_expr(ret);
334  return ret;
335 }
336 
338 class ashr_exprt : public shift_exprt
339 {
340 public:
341  ashr_exprt(exprt _src, exprt _distance)
342  : shift_exprt(std::move(_src), ID_ashr, std::move(_distance))
343  {
344  }
345 
346  ashr_exprt(exprt _src, const std::size_t _distance)
347  : shift_exprt(std::move(_src), ID_ashr, _distance)
348  {
349  }
350 };
351 
352 template <>
353 inline bool can_cast_expr<ashr_exprt>(const exprt &base)
354 {
355  return base.id() == ID_ashr;
356 }
357 
359 class lshr_exprt : public shift_exprt
360 {
361 public:
362  lshr_exprt(exprt _src, exprt _distance)
363  : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
364  {
365  }
366 
367  lshr_exprt(exprt _src, const std::size_t _distance)
368  : shift_exprt(std::move(_src), ID_lshr, std::move(_distance))
369  {
370  }
371 };
372 
373 template <>
374 inline bool can_cast_expr<lshr_exprt>(const exprt &base)
375 {
376  return base.id() == ID_lshr;
377 }
378 
381 {
382 public:
385  : binary_predicate_exprt(std::move(_src), ID_extractbit, std::move(_index))
386  {
387  }
388 
389  extractbit_exprt(exprt _src, const std::size_t _index);
390 
392  {
393  return op0();
394  }
395 
397  {
398  return op1();
399  }
400 
401  const exprt &src() const
402  {
403  return op0();
404  }
405 
406  const exprt &index() const
407  {
408  return op1();
409  }
410 };
411 
412 template <>
413 inline bool can_cast_expr<extractbit_exprt>(const exprt &base)
414 {
415  return base.id() == ID_extractbit;
416 }
417 
418 inline void validate_expr(const extractbit_exprt &value)
419 {
420  validate_operands(value, 2, "Extract bit must have two operands");
421 }
422 
429 inline const extractbit_exprt &to_extractbit_expr(const exprt &expr)
430 {
431  PRECONDITION(expr.id() == ID_extractbit);
432  const extractbit_exprt &ret = static_cast<const extractbit_exprt &>(expr);
433  validate_expr(ret);
434  return ret;
435 }
436 
439 {
440  PRECONDITION(expr.id() == ID_extractbit);
441  extractbit_exprt &ret = static_cast<extractbit_exprt &>(expr);
442  validate_expr(ret);
443  return ret;
444 }
445 
448 {
449 public:
455  extractbits_exprt(exprt _src, exprt _upper, exprt _lower, typet _type)
456  : expr_protectedt(
457  ID_extractbits,
458  std::move(_type),
459  {std::move(_src), std::move(_upper), std::move(_lower)})
460  {
461  }
462 
464  exprt _src,
465  const std::size_t _upper,
466  const std::size_t _lower,
467  typet _type);
468 
470  {
471  return op0();
472  }
473 
475  {
476  return op1();
477  }
478 
480  {
481  return op2();
482  }
483 
484  const exprt &src() const
485  {
486  return op0();
487  }
488 
489  const exprt &upper() const
490  {
491  return op1();
492  }
493 
494  const exprt &lower() const
495  {
496  return op2();
497  }
498 };
499 
500 template <>
501 inline bool can_cast_expr<extractbits_exprt>(const exprt &base)
502 {
503  return base.id() == ID_extractbits;
504 }
505 
506 inline void validate_expr(const extractbits_exprt &value)
507 {
508  validate_operands(value, 3, "Extract bits must have three operands");
509 }
510 
517 inline const extractbits_exprt &to_extractbits_expr(const exprt &expr)
518 {
519  PRECONDITION(expr.id() == ID_extractbits);
520  const extractbits_exprt &ret = static_cast<const extractbits_exprt &>(expr);
521  validate_expr(ret);
522  return ret;
523 }
524 
527 {
528  PRECONDITION(expr.id() == ID_extractbits);
529  extractbits_exprt &ret = static_cast<extractbits_exprt &>(expr);
530  validate_expr(ret);
531  return ret;
532 }
533 
536 {
537 public:
542  update_bit_exprt(exprt _src, exprt _index, exprt _new_value)
543  : expr_protectedt(
544  ID_update_bit,
545  _src.type(),
546  {_src, std::move(_index), std::move(_new_value)})
547  {
548  PRECONDITION(new_value().type().id() == ID_bool);
549  }
550 
551  update_bit_exprt(exprt _src, const std::size_t _index, exprt _new_value);
552 
554  {
555  return op0();
556  }
557 
559  {
560  return op1();
561  }
562 
564  {
565  return op2();
566  }
567 
568  const exprt &src() const
569  {
570  return op0();
571  }
572 
573  const exprt &index() const
574  {
575  return op1();
576  }
577 
578  const exprt &new_value() const
579  {
580  return op2();
581  }
582 
583  static void check(
584  const exprt &expr,
586  {
587  validate_operands(expr, 3, "update_bit must have three operands");
588  }
589 
591  exprt lower() const;
592 };
593 
594 template <>
595 inline bool can_cast_expr<update_bit_exprt>(const exprt &base)
596 {
597  return base.id() == ID_update_bit;
598 }
599 
606 inline const update_bit_exprt &to_update_bit_expr(const exprt &expr)
607 {
608  PRECONDITION(expr.id() == ID_update_bit);
610  return static_cast<const update_bit_exprt &>(expr);
611 }
612 
615 {
616  PRECONDITION(expr.id() == ID_update_bit);
618  return static_cast<update_bit_exprt &>(expr);
619 }
620 
623 {
624 public:
629  update_bits_exprt(exprt _src, exprt _index, exprt _new_value)
630  : expr_protectedt(
631  ID_update_bits,
632  _src.type(),
633  {_src, std::move(_index), std::move(_new_value)})
634  {
635  }
636 
637  update_bits_exprt(exprt _src, const std::size_t _index, exprt _new_value);
638 
640  {
641  return op0();
642  }
643 
645  {
646  return op1();
647  }
648 
650  {
651  return op2();
652  }
653 
654  const exprt &src() const
655  {
656  return op0();
657  }
658 
659  const exprt &index() const
660  {
661  return op1();
662  }
663 
664  const exprt &new_value() const
665  {
666  return op2();
667  }
668 
669  static void check(
670  const exprt &expr,
672  {
673  validate_operands(expr, 3, "update_bits must have three operands");
674  }
675 
677  exprt lower() const;
678 };
679 
680 template <>
681 inline bool can_cast_expr<update_bits_exprt>(const exprt &base)
682 {
683  return base.id() == ID_update_bits;
684 }
685 
692 inline const update_bits_exprt &to_update_bits_expr(const exprt &expr)
693 {
694  PRECONDITION(expr.id() == ID_update_bits);
696  return static_cast<const update_bits_exprt &>(expr);
697 }
698 
701 {
702  PRECONDITION(expr.id() == ID_update_bits);
704  return static_cast<update_bits_exprt &>(expr);
705 }
706 
709 {
710 public:
712  : binary_exprt(
713  std::move(_times),
714  ID_replication,
715  std::move(_src),
716  std::move(_type))
717  {
718  }
719 
721  {
722  return static_cast<constant_exprt &>(op0());
723  }
724 
725  const constant_exprt &times() const
726  {
727  return static_cast<const constant_exprt &>(op0());
728  }
729 
731  {
732  return op1();
733  }
734 
735  const exprt &op() const
736  {
737  return op1();
738  }
739 };
740 
741 template <>
742 inline bool can_cast_expr<replication_exprt>(const exprt &base)
743 {
744  return base.id() == ID_replication;
745 }
746 
747 inline void validate_expr(const replication_exprt &value)
748 {
749  validate_operands(value, 2, "Bit-wise replication must have two operands");
750 }
751 
758 inline const replication_exprt &to_replication_expr(const exprt &expr)
759 {
760  PRECONDITION(expr.id() == ID_replication);
761  const replication_exprt &ret = static_cast<const replication_exprt &>(expr);
762  validate_expr(ret);
763  return ret;
764 }
765 
768 {
769  PRECONDITION(expr.id() == ID_replication);
770  replication_exprt &ret = static_cast<replication_exprt &>(expr);
771  validate_expr(ret);
772  return ret;
773 }
774 
781 {
782 public:
784  : multi_ary_exprt(ID_concatenation, std::move(_operands), std::move(_type))
785  {
786  }
787 
789  : multi_ary_exprt(
790  ID_concatenation,
791  {std::move(_op0), std::move(_op1)},
792  std::move(_type))
793  {
794  }
795 };
796 
797 template <>
799 {
800  return base.id() == ID_concatenation;
801 }
802 
810 {
811  PRECONDITION(expr.id() == ID_concatenation);
812  return static_cast<const concatenation_exprt &>(expr);
813 }
814 
817 {
818  PRECONDITION(expr.id() == ID_concatenation);
819  return static_cast<concatenation_exprt &>(expr);
820 }
821 
824 {
825 public:
827  : unary_exprt(ID_popcount, std::move(_op), std::move(_type))
828  {
829  }
830 
831  explicit popcount_exprt(const exprt &_op)
832  : unary_exprt(ID_popcount, _op, _op.type())
833  {
834  }
835 
838  exprt lower() const;
839 };
840 
841 template <>
842 inline bool can_cast_expr<popcount_exprt>(const exprt &base)
843 {
844  return base.id() == ID_popcount;
845 }
846 
847 inline void validate_expr(const popcount_exprt &value)
848 {
849  validate_operands(value, 1, "popcount must have one operand");
850 }
851 
858 inline const popcount_exprt &to_popcount_expr(const exprt &expr)
859 {
860  PRECONDITION(expr.id() == ID_popcount);
861  const popcount_exprt &ret = static_cast<const popcount_exprt &>(expr);
862  validate_expr(ret);
863  return ret;
864 }
865 
868 {
869  PRECONDITION(expr.id() == ID_popcount);
870  popcount_exprt &ret = static_cast<popcount_exprt &>(expr);
871  validate_expr(ret);
872  return ret;
873 }
874 
878 {
879 public:
880  binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
881  : binary_predicate_exprt(std::move(_lhs), make_id(kind), std::move(_rhs))
882  {
883  INVARIANT(
884  valid_id(id()),
885  "The kind used to construct binary_overflow_exprt should be in the set "
886  "of expected valid kinds.");
887  }
888 
889  static void check(
890  const exprt &expr,
892  {
893  binary_exprt::check(expr, vm);
894 
895  if(expr.id() != ID_overflow_shl)
896  {
897  const binary_exprt &binary_expr = to_binary_expr(expr);
898  DATA_CHECK(
899  vm,
900  binary_expr.lhs().type() == binary_expr.rhs().type(),
901  "operand types must match");
902  }
903  }
904 
905  static void validate(
906  const exprt &expr,
907  const namespacet &,
909  {
910  check(expr, vm);
911  }
912 
914  static bool valid_id(const irep_idt &id)
915  {
916  return id == ID_overflow_plus || id == ID_overflow_mult ||
917  id == ID_overflow_minus || id == ID_overflow_shl;
918  }
919 
920 private:
921  static irep_idt make_id(const irep_idt &kind)
922  {
923  if(valid_id(kind))
924  return kind;
925  else
926  return "overflow-" + id2string(kind);
927  }
928 };
929 
930 template <>
932 {
933  return binary_overflow_exprt::valid_id(base.id());
934 }
935 
936 inline void validate_expr(const binary_overflow_exprt &value)
937 {
939  value, 2, "binary overflow expression must have two operands");
940 }
941 
949 {
950  PRECONDITION(
951  expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
952  expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
953  const binary_overflow_exprt &ret =
954  static_cast<const binary_overflow_exprt &>(expr);
955  validate_expr(ret);
956  return ret;
957 }
958 
961 {
962  PRECONDITION(
963  expr.id() == ID_overflow_plus || expr.id() == ID_overflow_mult ||
964  expr.id() == ID_overflow_minus || expr.id() == ID_overflow_shl);
965  binary_overflow_exprt &ret = static_cast<binary_overflow_exprt &>(expr);
966  validate_expr(ret);
967  return ret;
968 }
969 
971 {
972 public:
974  : binary_overflow_exprt(std::move(_lhs), ID_overflow_plus, std::move(_rhs))
975  {
976  }
977 
980  exprt lower() const;
981 };
982 
983 template <>
985 {
986  return base.id() == ID_overflow_plus;
987 }
988 
990 {
991 public:
993  : binary_overflow_exprt(std::move(_lhs), ID_overflow_minus, std::move(_rhs))
994  {
995  }
996 
999  exprt lower() const;
1000 };
1001 
1002 template <>
1004 {
1005  return base.id() == ID_overflow_minus;
1006 }
1007 
1009 {
1010 public:
1012  : binary_overflow_exprt(std::move(_lhs), ID_overflow_mult, std::move(_rhs))
1013  {
1014  }
1015 
1018  exprt lower() const;
1019 };
1020 
1021 template <>
1023 {
1024  return base.id() == ID_overflow_mult;
1025 }
1026 
1028 {
1029 public:
1031  : binary_overflow_exprt(std::move(_lhs), ID_overflow_shl, std::move(_rhs))
1032  {
1033  }
1034 };
1035 
1036 template <>
1038 {
1039  return base.id() == ID_overflow_shl;
1040 }
1041 
1045 {
1046 public:
1048  : unary_predicate_exprt("overflow-" + id2string(kind), std::move(_op))
1049  {
1050  }
1051 
1052  static void check(
1053  const exprt &expr,
1055  {
1056  unary_exprt::check(expr, vm);
1057  }
1058 
1059  static void validate(
1060  const exprt &expr,
1061  const namespacet &,
1063  {
1064  check(expr, vm);
1065  }
1066 };
1067 
1068 template <>
1070 {
1071  return base.id() == ID_overflow_unary_minus;
1072 }
1073 
1074 inline void validate_expr(const unary_overflow_exprt &value)
1075 {
1077  value, 1, "unary overflow expression must have one operand");
1078 }
1079 
1083 {
1084 public:
1086  : unary_overflow_exprt(ID_unary_minus, std::move(_op))
1087  {
1088  }
1089 
1090  static void check(
1091  const exprt &expr,
1093  {
1094  unary_exprt::check(expr, vm);
1095  }
1096 
1097  static void validate(
1098  const exprt &expr,
1099  const namespacet &,
1101  {
1102  check(expr, vm);
1103  }
1104 };
1105 
1106 template <>
1108 {
1109  return base.id() == ID_overflow_unary_minus;
1110 }
1111 
1113 {
1115  value, 1, "unary minus overflow expression must have one operand");
1116 }
1117 
1125 {
1126  PRECONDITION(expr.id() == ID_overflow_unary_minus);
1127  const unary_overflow_exprt &ret =
1128  static_cast<const unary_overflow_exprt &>(expr);
1129  validate_expr(ret);
1130  return ret;
1131 }
1132 
1135 {
1136  PRECONDITION(expr.id() == ID_overflow_unary_minus);
1137  unary_overflow_exprt &ret = static_cast<unary_overflow_exprt &>(expr);
1138  validate_expr(ret);
1139  return ret;
1140 }
1141 
1148 {
1149 public:
1150  count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
1151  : unary_exprt(ID_count_leading_zeros, std::move(_op), std::move(_type))
1152  {
1153  zero_permitted(_zero_permitted);
1154  }
1155 
1156  explicit count_leading_zeros_exprt(const exprt &_op)
1157  : count_leading_zeros_exprt(_op, true, _op.type())
1158  {
1159  }
1160 
1161  bool zero_permitted() const
1162  {
1163  return !get_bool(ID_C_bounds_check);
1164  }
1165 
1166  void zero_permitted(bool value)
1167  {
1168  set(ID_C_bounds_check, !value);
1169  }
1170 
1171  static void check(
1172  const exprt &expr,
1174  {
1175  DATA_CHECK(
1176  vm,
1177  expr.operands().size() == 1,
1178  "unary expression must have a single operand");
1179  DATA_CHECK(
1180  vm,
1182  "operand must be of bitvector type");
1183  }
1184 
1185  static void validate(
1186  const exprt &expr,
1187  const namespacet &,
1189  {
1190  check(expr, vm);
1191  }
1192 
1195  exprt lower() const;
1196 };
1197 
1198 template <>
1200 {
1201  return base.id() == ID_count_leading_zeros;
1202 }
1203 
1204 inline void validate_expr(const count_leading_zeros_exprt &value)
1205 {
1206  validate_operands(value, 1, "count_leading_zeros must have one operand");
1207 }
1208 
1215 inline const count_leading_zeros_exprt &
1217 {
1218  PRECONDITION(expr.id() == ID_count_leading_zeros);
1219  const count_leading_zeros_exprt &ret =
1220  static_cast<const count_leading_zeros_exprt &>(expr);
1221  validate_expr(ret);
1222  return ret;
1223 }
1224 
1227 {
1228  PRECONDITION(expr.id() == ID_count_leading_zeros);
1230  static_cast<count_leading_zeros_exprt &>(expr);
1231  validate_expr(ret);
1232  return ret;
1233 }
1234 
1241 {
1242 public:
1243  count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
1244  : unary_exprt(ID_count_trailing_zeros, std::move(_op), std::move(_type))
1245  {
1246  zero_permitted(_zero_permitted);
1247  }
1248 
1249  explicit count_trailing_zeros_exprt(const exprt &_op)
1250  : count_trailing_zeros_exprt(_op, true, _op.type())
1251  {
1252  }
1253 
1254  bool zero_permitted() const
1255  {
1256  return !get_bool(ID_C_bounds_check);
1257  }
1258 
1259  void zero_permitted(bool value)
1260  {
1261  set(ID_C_bounds_check, !value);
1262  }
1263 
1264  static void check(
1265  const exprt &expr,
1267  {
1268  DATA_CHECK(
1269  vm,
1270  expr.operands().size() == 1,
1271  "unary expression must have a single operand");
1272  DATA_CHECK(
1273  vm,
1275  "operand must be of bitvector type");
1276  }
1277 
1278  static void validate(
1279  const exprt &expr,
1280  const namespacet &,
1282  {
1283  check(expr, vm);
1284  }
1285 
1288  exprt lower() const;
1289 };
1290 
1291 template <>
1293 {
1294  return base.id() == ID_count_trailing_zeros;
1295 }
1296 
1298 {
1299  validate_operands(value, 1, "count_trailing_zeros must have one operand");
1300 }
1301 
1308 inline const count_trailing_zeros_exprt &
1310 {
1311  PRECONDITION(expr.id() == ID_count_trailing_zeros);
1312  const count_trailing_zeros_exprt &ret =
1313  static_cast<const count_trailing_zeros_exprt &>(expr);
1314  validate_expr(ret);
1315  return ret;
1316 }
1317 
1320 {
1321  PRECONDITION(expr.id() == ID_count_trailing_zeros);
1323  static_cast<count_trailing_zeros_exprt &>(expr);
1324  validate_expr(ret);
1325  return ret;
1326 }
1327 
1330 {
1331 public:
1333  : unary_exprt(ID_bitreverse, std::move(op))
1334  {
1335  }
1336 
1339  exprt lower() const;
1340 };
1341 
1342 template <>
1343 inline bool can_cast_expr<bitreverse_exprt>(const exprt &base)
1344 {
1345  return base.id() == ID_bitreverse;
1346 }
1347 
1348 inline void validate_expr(const bitreverse_exprt &value)
1349 {
1350  validate_operands(value, 1, "Bit-wise reverse must have one operand");
1351 }
1352 
1359 inline const bitreverse_exprt &to_bitreverse_expr(const exprt &expr)
1360 {
1361  PRECONDITION(expr.id() == ID_bitreverse);
1362  const bitreverse_exprt &ret = static_cast<const bitreverse_exprt &>(expr);
1363  validate_expr(ret);
1364  return ret;
1365 }
1366 
1369 {
1370  PRECONDITION(expr.id() == ID_bitreverse);
1371  bitreverse_exprt &ret = static_cast<bitreverse_exprt &>(expr);
1372  validate_expr(ret);
1373  return ret;
1374 }
1375 
1378 {
1379 public:
1381  : binary_exprt(std::move(_lhs), ID_saturating_plus, std::move(_rhs))
1382  {
1383  }
1384 
1386  : binary_exprt(
1387  std::move(_lhs),
1388  ID_saturating_plus,
1389  std::move(_rhs),
1390  std::move(_type))
1391  {
1392  }
1393 };
1394 
1395 template <>
1397 {
1398  return base.id() == ID_saturating_plus;
1399 }
1400 
1401 inline void validate_expr(const saturating_plus_exprt &value)
1402 {
1403  validate_operands(value, 2, "saturating plus must have two operands");
1404 }
1405 
1413 {
1414  PRECONDITION(expr.id() == ID_saturating_plus);
1415  const saturating_plus_exprt &ret =
1416  static_cast<const saturating_plus_exprt &>(expr);
1417  validate_expr(ret);
1418  return ret;
1419 }
1420 
1423 {
1424  PRECONDITION(expr.id() == ID_saturating_plus);
1425  saturating_plus_exprt &ret = static_cast<saturating_plus_exprt &>(expr);
1426  validate_expr(ret);
1427  return ret;
1428 }
1429 
1432 {
1433 public:
1435  : binary_exprt(std::move(_lhs), ID_saturating_minus, std::move(_rhs))
1436  {
1437  }
1438 };
1439 
1440 template <>
1442 {
1443  return base.id() == ID_saturating_minus;
1444 }
1445 
1446 inline void validate_expr(const saturating_minus_exprt &value)
1447 {
1448  validate_operands(value, 2, "saturating minus must have two operands");
1449 }
1450 
1458 {
1459  PRECONDITION(expr.id() == ID_saturating_minus);
1460  const saturating_minus_exprt &ret =
1461  static_cast<const saturating_minus_exprt &>(expr);
1462  validate_expr(ret);
1463  return ret;
1464 }
1465 
1468 {
1469  PRECONDITION(expr.id() == ID_saturating_minus);
1470  saturating_minus_exprt &ret = static_cast<saturating_minus_exprt &>(expr);
1471  validate_expr(ret);
1472  return ret;
1473 }
1474 
1478 {
1479 public:
1480  overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
1481  : expr_protectedt(
1482  make_id(kind),
1483  struct_typet{
1484  {{ID_value, _lhs.type()},
1485  {"overflow-" + id2string(kind), bool_typet{}}}},
1486  {_lhs, std::move(_rhs)})
1487  {
1488  INVARIANT(
1489  valid_id(id()),
1490  "The kind used to construct overflow_result_exprt should be in the set "
1491  "of expected valid kinds.");
1492  }
1493 
1495  : expr_protectedt(
1496  make_id(kind),
1497  struct_typet{
1498  {{ID_value, _op.type()},
1499  {"overflow-" + id2string(kind), bool_typet{}}}},
1500  {_op})
1501  {
1502  INVARIANT(
1503  valid_id(id()),
1504  "The kind used to construct overflow_result_exprt should be in the set "
1505  "of expected valid kinds.");
1506  }
1507 
1508  // make op0 and op1 public
1509  using exprt::op0;
1510  using exprt::op1;
1511 
1512  const exprt &op2() const = delete;
1513  exprt &op2() = delete;
1514  const exprt &op3() const = delete;
1515  exprt &op3() = delete;
1516 
1517  static void check(
1518  const exprt &expr,
1520  {
1521  if(expr.id() != ID_overflow_result_unary_minus)
1522  binary_exprt::check(expr, vm);
1523 
1524  if(
1525  expr.id() != ID_overflow_result_unary_minus &&
1526  expr.id() != ID_overflow_result_shl)
1527  {
1528  const binary_exprt &binary_expr = to_binary_expr(expr);
1529  DATA_CHECK(
1530  vm,
1531  binary_expr.lhs().type() == binary_expr.rhs().type(),
1532  "operand types must match");
1533  }
1534  }
1535 
1536  static void validate(
1537  const exprt &expr,
1538  const namespacet &,
1540  {
1541  check(expr, vm);
1542  }
1543 
1545  static bool valid_id(const irep_idt &id)
1546  {
1547  return id == ID_overflow_result_plus || id == ID_overflow_result_mult ||
1548  id == ID_overflow_result_minus || id == ID_overflow_result_shl ||
1549  id == ID_overflow_result_unary_minus;
1550  }
1551 
1552 private:
1553  static irep_idt make_id(const irep_idt &kind)
1554  {
1555  return "overflow_result-" + id2string(kind);
1556  }
1557 };
1558 
1559 template <>
1561 {
1562  return overflow_result_exprt::valid_id(base.id());
1563 }
1564 
1565 inline void validate_expr(const overflow_result_exprt &value)
1566 {
1567  if(value.id() == ID_overflow_result_unary_minus)
1568  {
1570  value, 1, "unary overflow expression must have two operands");
1571  }
1572  else
1573  {
1575  value, 2, "binary overflow expression must have two operands");
1576  }
1577 }
1578 
1586 {
1588  const overflow_result_exprt &ret =
1589  static_cast<const overflow_result_exprt &>(expr);
1590  validate_expr(ret);
1591  return ret;
1592 }
1593 
1596 {
1598  overflow_result_exprt &ret = static_cast<overflow_result_exprt &>(expr);
1599  validate_expr(ret);
1600  return ret;
1601 }
1602 
1606 {
1607 public:
1609  : unary_exprt(ID_find_first_set, std::move(_op), std::move(_type))
1610  {
1611  }
1612 
1613  explicit find_first_set_exprt(const exprt &_op)
1614  : find_first_set_exprt(_op, _op.type())
1615  {
1616  }
1617 
1618  static void check(
1619  const exprt &expr,
1621  {
1622  DATA_CHECK(
1623  vm,
1624  expr.operands().size() == 1,
1625  "unary expression must have a single operand");
1626  DATA_CHECK(
1627  vm,
1629  "operand must be of bitvector type");
1630  }
1631 
1632  static void validate(
1633  const exprt &expr,
1634  const namespacet &,
1636  {
1637  check(expr, vm);
1638  }
1639 
1642  exprt lower() const;
1643 };
1644 
1645 template <>
1647 {
1648  return base.id() == ID_find_first_set;
1649 }
1650 
1651 inline void validate_expr(const find_first_set_exprt &value)
1652 {
1653  validate_operands(value, 1, "find_first_set must have one operand");
1654 }
1655 
1663 {
1664  PRECONDITION(expr.id() == ID_find_first_set);
1665  const find_first_set_exprt &ret =
1666  static_cast<const find_first_set_exprt &>(expr);
1667  validate_expr(ret);
1668  return ret;
1669 }
1670 
1673 {
1674  PRECONDITION(expr.id() == ID_find_first_set);
1675  find_first_set_exprt &ret = static_cast<find_first_set_exprt &>(expr);
1676  validate_expr(ret);
1677  return ret;
1678 }
1679 
1680 #endif // CPROVER_UTIL_BITVECTOR_EXPR_H
const update_bit_exprt & to_update_bit_expr(const exprt &expr)
Cast an exprt to an update_bit_exprt.
bool can_cast_expr< count_trailing_zeros_exprt >(const exprt &base)
bool can_cast_expr< mult_overflow_exprt >(const exprt &base)
bool can_cast_expr< replication_exprt >(const exprt &base)
bool can_cast_expr< bswap_exprt >(const exprt &base)
bool can_cast_expr< find_first_set_exprt >(const exprt &base)
bool can_cast_expr< saturating_plus_exprt >(const exprt &base)
bool can_cast_expr< bitreverse_exprt >(const exprt &base)
bool can_cast_expr< count_leading_zeros_exprt >(const exprt &base)
bool can_cast_expr< shift_exprt >(const exprt &base)
bool can_cast_expr< bitand_exprt >(const exprt &base)
bool can_cast_expr< update_bits_exprt >(const exprt &base)
bool can_cast_expr< saturating_minus_exprt >(const exprt &base)
const overflow_result_exprt & to_overflow_result_expr(const exprt &expr)
Cast an exprt to a overflow_result_exprt.
const binary_overflow_exprt & to_binary_overflow_expr(const exprt &expr)
Cast an exprt to a binary_overflow_exprt.
bool can_cast_expr< popcount_exprt >(const exprt &base)
bool can_cast_expr< extractbits_exprt >(const exprt &base)
bool can_cast_expr< bitxor_exprt >(const exprt &base)
const shift_exprt & to_shift_expr(const exprt &expr)
Cast an exprt to a shift_exprt.
bool can_cast_expr< bitor_exprt >(const exprt &base)
bool can_cast_expr< update_bit_exprt >(const exprt &base)
bool can_cast_expr< minus_overflow_exprt >(const exprt &base)
void validate_expr(const bswap_exprt &value)
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
bool can_cast_expr< ashr_exprt >(const exprt &base)
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const unary_overflow_exprt & to_unary_overflow_expr(const exprt &expr)
Cast an exprt to a unary_overflow_exprt.
bool can_cast_expr< shl_overflow_exprt >(const exprt &base)
const saturating_plus_exprt & to_saturating_plus_expr(const exprt &expr)
Cast an exprt to a saturating_plus_exprt.
const bitxor_exprt & to_bitxor_expr(const exprt &expr)
Cast an exprt to a bitxor_exprt.
const bitand_exprt & to_bitand_expr(const exprt &expr)
Cast an exprt to a bitand_exprt.
bool can_cast_expr< overflow_result_exprt >(const exprt &base)
bool can_cast_expr< concatenation_exprt >(const exprt &base)
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.
bool can_cast_expr< unary_overflow_exprt >(const exprt &base)
const count_trailing_zeros_exprt & to_count_trailing_zeros_expr(const exprt &expr)
Cast an exprt to a count_trailing_zeros_exprt.
bool can_cast_expr< lshr_exprt >(const exprt &base)
bool can_cast_expr< shl_exprt >(const exprt &base)
bool can_cast_expr< plus_overflow_exprt >(const exprt &base)
const bitnot_exprt & to_bitnot_expr(const exprt &expr)
Cast an exprt to a bitnot_exprt.
bool can_cast_expr< bitnot_exprt >(const exprt &base)
const saturating_minus_exprt & to_saturating_minus_expr(const exprt &expr)
Cast an exprt to a saturating_minus_exprt.
bool can_cast_expr< binary_overflow_exprt >(const exprt &base)
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.
bool can_cast_expr< unary_minus_overflow_exprt >(const exprt &base)
bool can_cast_expr< extractbit_exprt >(const exprt &base)
const bitor_exprt & to_bitor_expr(const exprt &expr)
Cast an exprt to a bitor_exprt.
const bswap_exprt & to_bswap_expr(const exprt &expr)
Cast an exprt to a bswap_exprt.
const shl_exprt & to_shl_expr(const exprt &expr)
Cast an exprt to a shl_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.
const update_bits_exprt & to_update_bits_expr(const exprt &expr)
Cast an exprt to an update_bits_exprt.
Arithmetic right shift.
ashr_exprt(exprt _src, exprt _distance)
ashr_exprt(exprt _src, const std::size_t _distance)
A base class for binary expressions.
Definition: std_expr.h:638
exprt & op1()
Definition: expr.h:136
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:650
exprt & lhs()
Definition: std_expr.h:668
exprt & op0()
Definition: expr.h:133
exprt & rhs()
Definition: std_expr.h:678
A Boolean expression returning true, iff operation kind would result in an overflow when applied to o...
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of a binary_overflow_exprt.
static irep_idt make_id(const irep_idt &kind)
binary_overflow_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition: std_expr.h:731
Bit-wise AND.
bitand_exprt(const exprt &_op0, exprt _op1)
Bit-wise negation of bit-vectors.
bitnot_exprt(exprt op)
Bit-wise OR.
bitor_exprt(const exprt &_op0, exprt _op1)
Reverse the order of bits in a bit-vector.
bitreverse_exprt(exprt op)
exprt lower() const
Lower a bitreverse_exprt to arithmetic and logic expressions.
Bit-wise XOR.
bitxor_exprt(exprt _op0, exprt _op1)
The Boolean type.
Definition: std_types.h:36
The byte swap expression.
bswap_exprt(exprt _op, std::size_t bits_per_byte)
std::size_t get_bits_per_byte() const
bswap_exprt(exprt _op, std::size_t bits_per_byte, typet _type)
void set_bits_per_byte(std::size_t bits_per_byte)
Concatenation of bit-vector operands.
concatenation_exprt(operandst _operands, typet _type)
concatenation_exprt(exprt _op0, exprt _op1, typet _type)
A constant literal expression.
Definition: std_expr.h:2987
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
void zero_permitted(bool value)
exprt lower() const
Lower a count_leading_zeros_exprt to arithmetic and logic expressions.
count_leading_zeros_exprt(const exprt &_op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
count_leading_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
The count trailing zeros (counting the number of zero bits starting from the least-significant bit) e...
count_trailing_zeros_exprt(const exprt &_op)
count_trailing_zeros_exprt(exprt _op, bool _zero_permitted, typet _type)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
void zero_permitted(bool value)
exprt lower() const
Lower a count_trailing_zeros_exprt to arithmetic and logic expressions.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:344
exprt & op1()
Definition: expr.h:136
exprt & op2()
Definition: expr.h:139
exprt & op0()
Definition: expr.h:133
Base class for all expressions.
Definition: expr.h:56
std::vector< exprt > operandst
Definition: expr.h:58
exprt & op1()
Definition: expr.h:136
typet & type()
Return the type of the expression.
Definition: expr.h:84
exprt & op0()
Definition: expr.h:133
operandst & operands()
Definition: expr.h:94
Extracts a single bit of a bit-vector operand.
extractbit_exprt(exprt _src, exprt _index)
Extract the _index-th least significant bit from _src.
const exprt & src() const
const exprt & index() const
Extracts a sub-range of a bit-vector operand.
const exprt & lower() const
const exprt & upper() const
extractbits_exprt(exprt _src, exprt _upper, exprt _lower, typet _type)
Extract the bits [_lower .
const exprt & src() const
Returns one plus the index of the least-significant one bit, or zero if the operand is zero.
find_first_set_exprt(exprt _op, typet _type)
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
exprt lower() const
Lower a find_first_set_exprt to arithmetic and logic expressions.
find_first_set_exprt(const exprt &_op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:57
std::size_t get_size_t(const irep_idt &name) const
Definition: irep.cpp:67
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:408
void set_size_t(const irep_idt &name, const std::size_t value)
Definition: irep.cpp:82
const irep_idt & id() const
Definition: irep.h:384
Logical right shift.
lshr_exprt(exprt _src, const std::size_t _distance)
lshr_exprt(exprt _src, exprt _distance)
minus_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a minus_overflow_exprt to arithmetic and logic expressions.
mult_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a mult_overflow_exprt to arithmetic and logic expressions.
A base class for multi-ary expressions Associativity is not specified.
Definition: std_expr.h:912
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
An expression returning both the result of the arithmetic operation under wrap-around semantics as we...
exprt & op2()=delete
const exprt & op3() const =delete
overflow_result_exprt(exprt _lhs, const irep_idt &kind, exprt _rhs)
exprt & op3()=delete
overflow_result_exprt(exprt _op, const irep_idt &kind)
const exprt & op2() const =delete
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
static bool valid_id(const irep_idt &id)
Returns true iff id is a valid identifier of an overflow_exprt.
static irep_idt make_id(const irep_idt &kind)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
plus_overflow_exprt(exprt _lhs, exprt _rhs)
exprt lower() const
Lower a plus_overflow_exprt to arithmetic and logic expressions.
The popcount (counting the number of bits set to 1) expression.
exprt lower() const
Lower a popcount_exprt to arithmetic and logic expressions.
popcount_exprt(exprt _op, typet _type)
popcount_exprt(const exprt &_op)
Bit-vector replication.
const exprt & op() const
const constant_exprt & times() const
constant_exprt & times()
replication_exprt(constant_exprt _times, exprt _src, typet _type)
Saturating subtraction expression.
saturating_minus_exprt(exprt _lhs, exprt _rhs)
The saturating plus expression.
saturating_plus_exprt(exprt _lhs, exprt _rhs, typet _type)
saturating_plus_exprt(exprt _lhs, exprt _rhs)
A base class for shift and rotate operators.
exprt & distance()
exprt & op()
const exprt & distance() const
shift_exprt(exprt _src, const irep_idt &_id, exprt _distance)
const exprt & op() const
Left shift.
shl_exprt(exprt _src, const std::size_t _distance)
shl_exprt(exprt _src, exprt _distance)
shl_overflow_exprt(exprt _lhs, exprt _rhs)
Structure type, corresponds to C style structs.
Definition: std_types.h:231
The type of an expression, extends irept.
Definition: type.h:29
Generic base class for unary expressions.
Definition: std_expr.h:361
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_expr.h:373
const exprt & op() const
Definition: std_expr.h:391
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
A Boolean expression returning true, iff operation kind would result in an overflow when applied to t...
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
unary_overflow_exprt(const irep_idt &kind, exprt _op)
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
Definition: std_expr.h:585
Replaces a sub-range of a bit-vector operand.
const exprt & new_value() const
update_bit_exprt(exprt _src, exprt _index, exprt _new_value)
Replaces the bit [_index] from _src to produce a result of the same type as _src.
const exprt & src() const
exprt lower() const
A lowering to masking, shifting, or.
const exprt & index() const
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
update_bit_exprt(exprt _src, const std::size_t _index, exprt _new_value)
Replaces a sub-range of a bit-vector operand.
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
const exprt & src() const
const exprt & index() const
update_bits_exprt(exprt _src, exprt _index, exprt _new_value)
Replace the bits [_index .
exprt lower() const
A lowering to masking, shifting, or.
update_bits_exprt(exprt _src, const std::size_t _index, exprt _new_value)
const exprt & new_value() const
void validate_operands(const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false)
Definition: expr_cast.h:250
const std::string & id2string(const irep_idt &d)
Definition: irep.h:40
#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(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition: invariant.h:423
API to expression classes.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition: std_expr.h:715
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition: std_expr.h:426
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
Definition: std_types.h:943
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
validation_modet