CBMC
Loading...
Searching...
No Matches
std_expr.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: API to expression classes
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9
10#ifndef CPROVER_UTIL_STD_EXPR_H
11#define CPROVER_UTIL_STD_EXPR_H
12
15
16#include "deprecate.h"
17#include "expr_cast.h"
18#include "invariant.h"
19#include "std_types.h"
20
23{
24public:
26 : expr_protectedt(_id, std::move(_type))
27 {
28 }
29
30 static void check(
31 const exprt &expr,
33 {
35 vm,
36 expr.operands().size() == 0,
37 "nullary expression must not have operands");
38 }
39
40 static void validate(
41 const exprt &expr,
42 const namespacet &,
44 {
45 check(expr, vm);
46 }
47
49 operandst &operands() = delete;
50 const operandst &operands() const = delete;
51
52 const exprt &op0() const = delete;
53 exprt &op0() = delete;
54 const exprt &op1() const = delete;
55 exprt &op1() = delete;
56 const exprt &op2() const = delete;
57 exprt &op2() = delete;
58 const exprt &op3() const = delete;
59 exprt &op3() = delete;
60
61 void copy_to_operands(const exprt &expr) = delete;
62 void copy_to_operands(const exprt &, const exprt &) = delete;
63 void copy_to_operands(const exprt &, const exprt &, const exprt &) = delete;
64};
65
68{
69public:
70 // constructor
72 const irep_idt &_id,
73 exprt _op0,
74 exprt _op1,
75 exprt _op2,
76 typet _type)
78 _id,
79 std::move(_type),
80 {std::move(_op0), std::move(_op1), std::move(_op2)})
81 {
82 }
83
84 // make op0 to op2 public
85 using exprt::op0;
86 using exprt::op1;
87 using exprt::op2;
88
89 const exprt &op3() const = delete;
90 exprt &op3() = delete;
91
92 static void check(
93 const exprt &expr,
95 {
97 vm,
98 expr.operands().size() == 3,
99 "ternary expression must have three operands");
100 }
101
102 static void validate(
103 const exprt &expr,
104 const namespacet &,
106 {
107 check(expr, vm);
108 }
109};
110
117inline const ternary_exprt &to_ternary_expr(const exprt &expr)
118{
120 return static_cast<const ternary_exprt &>(expr);
121}
122
125{
127 return static_cast<ternary_exprt &>(expr);
128}
129
132{
133public:
136 {
137 }
138
141 symbol_exprt(const irep_idt &identifier, typet type)
143 {
144 set_identifier(identifier);
145 }
146
152 {
153 return symbol_exprt(id, typet());
154 }
155
156 void set_identifier(const irep_idt &identifier)
157 {
158 set(ID_identifier, identifier);
159 }
160
162 {
163 return get(ID_identifier);
164 }
165
168 {
169 if(location.is_not_nil())
170 add_source_location() = std::move(location);
171 return *this;
172 }
173
176 {
177 if(location.is_not_nil())
178 add_source_location() = std::move(location);
179 return std::move(*this);
180 }
181
184 {
185 if(other.source_location().is_not_nil())
186 add_source_location() = other.source_location();
187 return *this;
188 }
189
192 {
193 if(other.source_location().is_not_nil())
194 add_source_location() = other.source_location();
195 return std::move(*this);
196 }
197};
198
199// NOLINTNEXTLINE(readability/namespace)
200namespace std
201{
202template <>
203// NOLINTNEXTLINE(readability/identifiers)
204struct hash<::symbol_exprt>
205{
206 size_t operator()(const ::symbol_exprt &sym)
207 {
208 return irep_id_hash()(sym.get_identifier());
209 }
210};
211} // namespace std
212
216{
217public:
221 : symbol_exprt(identifier, std::move(type))
222 {
223 }
224
226 {
228 }
229
231 {
232 return set(ID_C_static_lifetime, true);
233 }
234
239
240 bool is_thread_local() const
241 {
243 }
244
246 {
247 return set(ID_C_thread_local, true);
248 }
249
254};
255
256template <>
257inline bool can_cast_expr<symbol_exprt>(const exprt &base)
258{
259 return base.id() == ID_symbol;
260}
261
262inline void validate_expr(const symbol_exprt &value)
263{
264 validate_operands(value, 0, "Symbols must not have operands");
265}
266
273inline const symbol_exprt &to_symbol_expr(const exprt &expr)
274{
275 PRECONDITION(expr.id()==ID_symbol);
276 const symbol_exprt &ret = static_cast<const symbol_exprt &>(expr);
278 return ret;
279}
280
283{
284 PRECONDITION(expr.id()==ID_symbol);
285 symbol_exprt &ret = static_cast<symbol_exprt &>(expr);
287 return ret;
288}
289
290
293{
294public:
299 {
300 set_identifier(identifier);
301 }
302
307 irep_idt identifier,
308 typet type,
309 source_locationt location)
311 {
312 set_identifier(std::move(identifier));
313 add_source_location() = std::move(location);
314 }
315
316 void set_identifier(const irep_idt &identifier)
317 {
318 set(ID_identifier, identifier);
319 }
320
322 {
323 return get(ID_identifier);
324 }
325};
326
327template <>
329{
330 return base.id() == ID_nondet_symbol;
331}
332
333inline void validate_expr(const nondet_symbol_exprt &value)
334{
335 validate_operands(value, 0, "Symbols must not have operands");
336}
337
345{
348 return static_cast<const nondet_symbol_exprt &>(expr);
349}
350
353{
354 PRECONDITION(expr.id()==ID_symbol);
356 return static_cast<nondet_symbol_exprt &>(expr);
357}
358
359
362{
363public:
366 {
367 }
368
370 : expr_protectedt(_id, std::move(_type), {std::move(_op)})
371 {
372 }
373
374 static void check(
375 const exprt &expr,
377 {
379 vm,
380 expr.operands().size() == 1,
381 "unary expression must have one operand");
382 }
383
384 static void validate(
385 const exprt &expr,
386 const namespacet &,
388 {
389 check(expr, vm);
390 }
391
392 const exprt &op() const
393 {
394 return op0();
395 }
396
398 {
399 return op0();
400 }
401
402 const exprt &op1() const = delete;
403 exprt &op1() = delete;
404 const exprt &op2() const = delete;
405 exprt &op2() = delete;
406 const exprt &op3() const = delete;
407 exprt &op3() = delete;
408};
409
410template <>
411inline bool can_cast_expr<unary_exprt>(const exprt &base)
412{
413 return base.operands().size() == 1;
414}
415
416inline void validate_expr(const unary_exprt &value)
417{
418 unary_exprt::check(value);
419}
420
427inline const unary_exprt &to_unary_expr(const exprt &expr)
428{
429 unary_exprt::check(expr);
430 return static_cast<const unary_exprt &>(expr);
431}
432
435{
436 unary_exprt::check(expr);
437 return static_cast<unary_exprt &>(expr);
438}
439
440
443{
444public:
446 {
447 }
448};
449
450template <>
451inline bool can_cast_expr<abs_exprt>(const exprt &base)
452{
453 return base.id() == ID_abs;
454}
455
456inline void validate_expr(const abs_exprt &value)
457{
458 validate_operands(value, 1, "Absolute value must have one operand");
459}
460
467inline const abs_exprt &to_abs_expr(const exprt &expr)
468{
469 PRECONDITION(expr.id()==ID_abs);
470 abs_exprt::check(expr);
471 return static_cast<const abs_exprt &>(expr);
472}
473
476{
477 PRECONDITION(expr.id()==ID_abs);
478 abs_exprt::check(expr);
479 return static_cast<abs_exprt &>(expr);
480}
481
482
485{
486public:
488 : unary_exprt(ID_unary_minus, std::move(_op), std::move(_type))
489 {
490 }
491
494 {
495 }
496};
497
498template <>
500{
501 return base.id() == ID_unary_minus;
502}
503
504inline void validate_expr(const unary_minus_exprt &value)
505{
506 validate_operands(value, 1, "Unary minus must have one operand");
507}
508
516{
519 return static_cast<const unary_minus_exprt &>(expr);
520}
521
524{
527 return static_cast<unary_minus_exprt &>(expr);
528}
529
532{
533public:
536 {
537 }
538};
539
540template <>
542{
543 return base.id() == ID_unary_plus;
544}
545
546inline void validate_expr(const unary_plus_exprt &value)
547{
548 validate_operands(value, 1, "unary plus must have one operand");
549}
550
557inline const unary_plus_exprt &to_unary_plus_expr(const exprt &expr)
558{
559 PRECONDITION(expr.id() == ID_unary_plus);
561 return static_cast<const unary_plus_exprt &>(expr);
562}
563
566{
567 PRECONDITION(expr.id() == ID_unary_plus);
569 return static_cast<unary_plus_exprt &>(expr);
570}
571
575{
576public:
577 explicit predicate_exprt(const irep_idt &_id)
579 {
580 }
581};
582
586{
587public:
589 : unary_exprt(_id, std::move(_op), bool_typet())
590 {
591 }
592};
593
597{
598public:
601 {
602 }
603};
604
605template <>
606inline bool can_cast_expr<sign_exprt>(const exprt &base)
607{
608 return base.id() == ID_sign;
609}
610
611inline void validate_expr(const sign_exprt &expr)
612{
613 validate_operands(expr, 1, "sign expression must have one operand");
614}
615
622inline const sign_exprt &to_sign_expr(const exprt &expr)
623{
624 PRECONDITION(expr.id() == ID_sign);
625 sign_exprt::check(expr);
626 return static_cast<const sign_exprt &>(expr);
627}
628
631{
632 PRECONDITION(expr.id() == ID_sign);
633 sign_exprt::check(expr);
634 return static_cast<sign_exprt &>(expr);
635}
636
639{
640public:
642 : expr_protectedt(_id, _lhs.type(), {_lhs, std::move(_rhs)})
643 {
644 }
645
647 : expr_protectedt(_id, std::move(_type), {std::move(_lhs), std::move(_rhs)})
648 {
649 }
650
651 static void check(
652 const exprt &expr,
654 {
656 vm,
657 expr.operands().size() == 2,
658 "binary expression must have two operands");
659 }
660
661 static void validate(
662 const exprt &expr,
663 const namespacet &,
665 {
666 check(expr, vm);
667 }
668
670 {
671 return exprt::op0();
672 }
673
674 const exprt &lhs() const
675 {
676 return exprt::op0();
677 }
678
680 {
681 return exprt::op1();
682 }
683
684 const exprt &rhs() const
685 {
686 return exprt::op1();
687 }
688
689 // make op0 and op1 public
690 using exprt::op0;
691 using exprt::op1;
692
693 const exprt &op2() const = delete;
694 exprt &op2() = delete;
695 const exprt &op3() const = delete;
696 exprt &op3() = delete;
697};
698
699template <>
700inline bool can_cast_expr<binary_exprt>(const exprt &base)
701{
702 return base.operands().size() == 2;
703}
704
705inline void validate_expr(const binary_exprt &value)
706{
707 binary_exprt::check(value);
708}
709
716inline const binary_exprt &to_binary_expr(const exprt &expr)
717{
719 return static_cast<const binary_exprt &>(expr);
720}
721
724{
726 return static_cast<binary_exprt &>(expr);
727}
728
732{
733public:
735 : binary_exprt(std::move(_op0), _id, std::move(_op1), bool_typet())
736 {
737 }
738
739 static void check(
740 const exprt &expr,
742 {
743 binary_exprt::check(expr, vm);
744 }
745
746 static void validate(
747 const exprt &expr,
748 const namespacet &ns,
750 {
751 binary_exprt::validate(expr, ns, vm);
752
754 vm,
755 expr.is_boolean(),
756 "result of binary predicate expression should be of type bool");
757 }
758};
759
763{
764public:
769
770 static void check(
771 const exprt &expr,
773 {
775 }
776
777 static void validate(
778 const exprt &expr,
779 const namespacet &ns,
781 {
783
784 // we now can safely assume that 'expr' is a binary predicate
785 const auto &expr_binary = static_cast<const binary_predicate_exprt &>(expr);
786
787 // check that the types of the operands are the same
789 vm,
790 expr_binary.op0().type() == expr_binary.op1().type(),
791 "lhs and rhs of binary relation expression should have same type");
792 }
793};
794
795template <>
797{
798 return can_cast_expr<binary_exprt>(base);
799}
800
801inline void validate_expr(const binary_relation_exprt &value)
802{
804}
805
808{
809public:
814};
815
816template <>
818{
819 return base.id() == ID_gt;
820}
821
822inline void validate_expr(const greater_than_exprt &value)
823{
825}
826
836
837template <>
839{
840 return base.id() == ID_ge;
841}
842
844{
846}
847
850{
851public:
856};
857
858template <>
859inline bool can_cast_expr<less_than_exprt>(const exprt &base)
860{
861 return base.id() == ID_lt;
862}
863
864inline void validate_expr(const less_than_exprt &value)
865{
867}
868
878
879template <>
881{
882 return base.id() == ID_le;
883}
884
886{
888}
889
897{
899 return static_cast<const binary_relation_exprt &>(expr);
900}
901
904{
906 return static_cast<binary_relation_exprt &>(expr);
907}
908
909
913{
914public:
916 : expr_protectedt(_id, std::move(_type))
917 {
918 operands() = std::move(_operands);
919 }
920
923 {
924 PRECONDITION(!_operands.empty());
925 type() = _operands.front().type();
926 operands() = std::move(_operands);
927 }
928
930 : expr_protectedt(_id, _lhs.type(), {_lhs, std::move(_rhs)})
931 {
932 }
933
935 : expr_protectedt(_id, std::move(_type), {std::move(_lhs), std::move(_rhs)})
936 {
937 }
938
939 // In contrast to exprt::opX, the methods
940 // below check the size.
942 {
943 PRECONDITION(operands().size() >= 1);
944 return operands().front();
945 }
946
948 {
949 PRECONDITION(operands().size() >= 2);
950 return operands()[1];
951 }
952
954 {
955 PRECONDITION(operands().size() >= 3);
956 return operands()[2];
957 }
958
960 {
961 PRECONDITION(operands().size() >= 4);
962 return operands()[3];
963 }
964
965 const exprt &op0() const
966 {
967 PRECONDITION(operands().size() >= 1);
968 return operands().front();
969 }
970
971 const exprt &op1() const
972 {
973 PRECONDITION(operands().size() >= 2);
974 return operands()[1];
975 }
976
977 const exprt &op2() const
978 {
979 PRECONDITION(operands().size() >= 3);
980 return operands()[2];
981 }
982
983 const exprt &op3() const
984 {
985 PRECONDITION(operands().size() >= 4);
986 return operands()[3];
987 }
988};
989
996inline const multi_ary_exprt &to_multi_ary_expr(const exprt &expr)
997{
998 return static_cast<const multi_ary_exprt &>(expr);
999}
1000
1003{
1004 return static_cast<multi_ary_exprt &>(expr);
1005}
1006
1007
1011{
1012public:
1014 : multi_ary_exprt(std::move(_lhs), ID_plus, std::move(_rhs))
1015 {
1016 }
1017
1020 std::move(_lhs),
1021 ID_plus,
1022 std::move(_rhs),
1023 std::move(_type))
1024 {
1025 }
1026
1029 {
1030 }
1031
1033 : multi_ary_exprt(ID_plus, std::move(_operands), std::move(_type))
1034 {
1035 }
1036};
1037
1038template <>
1039inline bool can_cast_expr<plus_exprt>(const exprt &base)
1040{
1041 return base.id() == ID_plus;
1042}
1043
1044inline void validate_expr(const plus_exprt &value)
1045{
1046 validate_operands(value, 2, "Plus must have two or more operands", true);
1047}
1048
1055inline const plus_exprt &to_plus_expr(const exprt &expr)
1056{
1057 PRECONDITION(expr.id()==ID_plus);
1058 const plus_exprt &ret = static_cast<const plus_exprt &>(expr);
1060 return ret;
1061}
1062
1065{
1066 PRECONDITION(expr.id()==ID_plus);
1067 plus_exprt &ret = static_cast<plus_exprt &>(expr);
1069 return ret;
1070}
1071
1072
1075{
1076public:
1078 : binary_exprt(std::move(_lhs), ID_minus, std::move(_rhs))
1079 {
1080 }
1081};
1082
1083template <>
1084inline bool can_cast_expr<minus_exprt>(const exprt &base)
1085{
1086 return base.id() == ID_minus;
1087}
1088
1089inline void validate_expr(const minus_exprt &value)
1090{
1091 validate_operands(value, 2, "Minus must have two or more operands", true);
1092}
1093
1100inline const minus_exprt &to_minus_expr(const exprt &expr)
1101{
1102 PRECONDITION(expr.id()==ID_minus);
1103 const minus_exprt &ret = static_cast<const minus_exprt &>(expr);
1105 return ret;
1106}
1107
1110{
1111 PRECONDITION(expr.id()==ID_minus);
1112 minus_exprt &ret = static_cast<minus_exprt &>(expr);
1114 return ret;
1115}
1116
1117
1121{
1122public:
1124 : multi_ary_exprt(std::move(_lhs), ID_mult, std::move(_rhs))
1125 {
1126 }
1127
1130 {
1131 }
1132
1137};
1138
1139template <>
1140inline bool can_cast_expr<mult_exprt>(const exprt &base)
1141{
1142 return base.id() == ID_mult;
1143}
1144
1145inline void validate_expr(const mult_exprt &value)
1146{
1147 validate_operands(value, 2, "Multiply must have two or more operands", true);
1148}
1149
1156inline const mult_exprt &to_mult_expr(const exprt &expr)
1157{
1158 PRECONDITION(expr.id()==ID_mult);
1159 const mult_exprt &ret = static_cast<const mult_exprt &>(expr);
1161 return ret;
1162}
1163
1166{
1167 PRECONDITION(expr.id()==ID_mult);
1168 mult_exprt &ret = static_cast<mult_exprt &>(expr);
1170 return ret;
1171}
1172
1173
1176{
1177public:
1179 : binary_exprt(std::move(_lhs), ID_div, std::move(_rhs))
1180 {
1181 }
1182
1185 {
1186 return op0();
1187 }
1188
1190 const exprt &dividend() const
1191 {
1192 return op0();
1193 }
1194
1197 {
1198 return op1();
1199 }
1200
1202 const exprt &divisor() const
1203 {
1204 return op1();
1205 }
1206};
1207
1208template <>
1209inline bool can_cast_expr<div_exprt>(const exprt &base)
1210{
1211 return base.id() == ID_div;
1212}
1213
1214inline void validate_expr(const div_exprt &value)
1215{
1216 validate_operands(value, 2, "Divide must have two operands");
1217}
1218
1225inline const div_exprt &to_div_expr(const exprt &expr)
1226{
1227 PRECONDITION(expr.id()==ID_div);
1228 const div_exprt &ret = static_cast<const div_exprt &>(expr);
1230 return ret;
1231}
1232
1235{
1236 PRECONDITION(expr.id()==ID_div);
1237 div_exprt &ret = static_cast<div_exprt &>(expr);
1239 return ret;
1240}
1241
1247{
1248public:
1250 : binary_exprt(std::move(_lhs), ID_mod, std::move(_rhs))
1251 {
1252 }
1253
1256 {
1257 return op0();
1258 }
1259
1261 const exprt &dividend() const
1262 {
1263 return op0();
1264 }
1265
1268 {
1269 return op1();
1270 }
1271
1273 const exprt &divisor() const
1274 {
1275 return op1();
1276 }
1277};
1278
1279template <>
1280inline bool can_cast_expr<mod_exprt>(const exprt &base)
1281{
1282 return base.id() == ID_mod;
1283}
1284
1285inline void validate_expr(const mod_exprt &value)
1286{
1287 validate_operands(value, 2, "Modulo must have two operands");
1288}
1289
1296inline const mod_exprt &to_mod_expr(const exprt &expr)
1297{
1298 PRECONDITION(expr.id()==ID_mod);
1299 const mod_exprt &ret = static_cast<const mod_exprt &>(expr);
1301 return ret;
1302}
1303
1306{
1307 PRECONDITION(expr.id()==ID_mod);
1308 mod_exprt &ret = static_cast<mod_exprt &>(expr);
1310 return ret;
1311}
1312
1315{
1316public:
1321
1324 {
1325 return op0();
1326 }
1327
1329 const exprt &dividend() const
1330 {
1331 return op0();
1332 }
1333
1336 {
1337 return op1();
1338 }
1339
1341 const exprt &divisor() const
1342 {
1343 return op1();
1344 }
1345};
1346
1347template <>
1349{
1350 return base.id() == ID_euclidean_mod;
1351}
1352
1353inline void validate_expr(const euclidean_mod_exprt &value)
1354{
1355 validate_operands(value, 2, "Modulo must have two operands");
1356}
1357
1365{
1366 PRECONDITION(expr.id() == ID_euclidean_mod);
1367 const euclidean_mod_exprt &ret =
1368 static_cast<const euclidean_mod_exprt &>(expr);
1370 return ret;
1371}
1372
1375{
1376 PRECONDITION(expr.id() == ID_euclidean_mod);
1377 euclidean_mod_exprt &ret = static_cast<euclidean_mod_exprt &>(expr);
1379 return ret;
1380}
1381
1382
1385{
1386public:
1388 : binary_relation_exprt(std::move(_lhs), ID_equal, std::move(_rhs))
1389 {
1390 PRECONDITION(lhs().type() == rhs().type());
1391 }
1392
1393 static void check(
1394 const exprt &expr,
1396 {
1398 }
1399
1400 static void validate(
1401 const exprt &expr,
1402 const namespacet &ns,
1404 {
1405 binary_relation_exprt::validate(expr, ns, vm);
1406 }
1407};
1408
1409template <>
1410inline bool can_cast_expr<equal_exprt>(const exprt &base)
1411{
1412 return base.id() == ID_equal;
1413}
1414
1415inline void validate_expr(const equal_exprt &value)
1416{
1417 equal_exprt::check(value);
1418}
1419
1426inline const equal_exprt &to_equal_expr(const exprt &expr)
1427{
1428 PRECONDITION(expr.id()==ID_equal);
1429 equal_exprt::check(expr);
1430 return static_cast<const equal_exprt &>(expr);
1431}
1432
1435{
1436 PRECONDITION(expr.id()==ID_equal);
1437 equal_exprt::check(expr);
1438 return static_cast<equal_exprt &>(expr);
1439}
1440
1441
1444{
1445public:
1450};
1451
1452template <>
1453inline bool can_cast_expr<notequal_exprt>(const exprt &base)
1454{
1455 return base.id() == ID_notequal;
1456}
1457
1458inline void validate_expr(const notequal_exprt &value)
1459{
1460 validate_operands(value, 2, "Inequality must have two operands");
1461}
1462
1469inline const notequal_exprt &to_notequal_expr(const exprt &expr)
1470{
1471 PRECONDITION(expr.id()==ID_notequal);
1472 const notequal_exprt &ret = static_cast<const notequal_exprt &>(expr);
1474 return ret;
1475}
1476
1479{
1480 PRECONDITION(expr.id()==ID_notequal);
1481 notequal_exprt &ret = static_cast<notequal_exprt &>(expr);
1483 return ret;
1484}
1485
1486
1489{
1490public:
1491 // _array must have either index or vector type.
1492 // When _array has array_type, the type of _index
1493 // must be array_type.index_type().
1494 // This will eventually be enforced using a precondition.
1496 : binary_exprt(
1497 _array,
1498 ID_index,
1499 std::move(_index),
1500 to_type_with_subtype(_array.type()).subtype())
1501 {
1502 const auto &array_op_type = _array.type();
1504 array_op_type.id() == ID_array || array_op_type.id() == ID_vector);
1505 }
1506
1508 : binary_exprt(
1509 std::move(_array),
1510 ID_index,
1511 std::move(_index),
1512 std::move(_type))
1513 {
1514 const auto &array_op_type = array().type();
1516 array_op_type.id() == ID_array || array_op_type.id() == ID_vector);
1517 }
1518
1520 {
1521 return op0();
1522 }
1523
1524 const exprt &array() const
1525 {
1526 return op0();
1527 }
1528
1530 {
1531 return op1();
1532 }
1533
1534 const exprt &index() const
1535 {
1536 return op1();
1537 }
1538};
1539
1540template <>
1541inline bool can_cast_expr<index_exprt>(const exprt &base)
1542{
1543 return base.id() == ID_index;
1544}
1545
1546inline void validate_expr(const index_exprt &value)
1547{
1548 validate_operands(value, 2, "Array index must have two operands");
1549}
1550
1557inline const index_exprt &to_index_expr(const exprt &expr)
1558{
1559 PRECONDITION(expr.id()==ID_index);
1560 const index_exprt &ret = static_cast<const index_exprt &>(expr);
1562 return ret;
1563}
1564
1567{
1568 PRECONDITION(expr.id()==ID_index);
1569 index_exprt &ret = static_cast<index_exprt &>(expr);
1571 return ret;
1572}
1573
1574
1577{
1578public:
1580 : unary_exprt(ID_array_of, std::move(_what), std::move(_type))
1581 {
1582 }
1583
1584 const array_typet &type() const
1585 {
1586 return static_cast<const array_typet &>(unary_exprt::type());
1587 }
1588
1590 {
1591 return static_cast<array_typet &>(unary_exprt::type());
1592 }
1593
1595 {
1596 return op0();
1597 }
1598
1599 const exprt &what() const
1600 {
1601 return op0();
1602 }
1603};
1604
1605template <>
1606inline bool can_cast_expr<array_of_exprt>(const exprt &base)
1607{
1608 return base.id() == ID_array_of;
1609}
1610
1611inline void validate_expr(const array_of_exprt &value)
1612{
1613 validate_operands(value, 1, "'Array of' must have one operand");
1614}
1615
1622inline const array_of_exprt &to_array_of_expr(const exprt &expr)
1623{
1624 PRECONDITION(expr.id()==ID_array_of);
1626 return static_cast<const array_of_exprt &>(expr);
1627}
1628
1631{
1632 PRECONDITION(expr.id()==ID_array_of);
1634 return static_cast<array_of_exprt &>(expr);
1635}
1636
1637
1640{
1641public:
1643 : multi_ary_exprt(ID_array, std::move(_operands), std::move(_type))
1644 {
1645 }
1646
1647 const array_typet &type() const
1648 {
1649 return static_cast<const array_typet &>(multi_ary_exprt::type());
1650 }
1651
1653 {
1654 return static_cast<array_typet &>(multi_ary_exprt::type());
1655 }
1656
1658 {
1659 if(other.source_location().is_not_nil())
1660 add_source_location() = other.source_location();
1661 return *this;
1662 }
1663
1665 {
1666 if(other.source_location().is_not_nil())
1667 add_source_location() = other.source_location();
1668 return std::move(*this);
1669 }
1670};
1671
1672template <>
1673inline bool can_cast_expr<array_exprt>(const exprt &base)
1674{
1675 return base.id() == ID_array;
1676}
1677
1684inline const array_exprt &to_array_expr(const exprt &expr)
1685{
1686 PRECONDITION(expr.id()==ID_array);
1687 return static_cast<const array_exprt &>(expr);
1688}
1689
1692{
1693 PRECONDITION(expr.id()==ID_array);
1694 return static_cast<array_exprt &>(expr);
1695}
1696
1700{
1701public:
1703 : multi_ary_exprt(ID_array_list, std::move(_operands), std::move(_type))
1704 {
1705 }
1706
1707 const array_typet &type() const
1708 {
1709 return static_cast<const array_typet &>(multi_ary_exprt::type());
1710 }
1711
1713 {
1714 return static_cast<array_typet &>(multi_ary_exprt::type());
1715 }
1716
1718 void add(exprt index, exprt value)
1719 {
1720 add_to_operands(std::move(index), std::move(value));
1721 }
1722};
1723
1724template <>
1726{
1727 return base.id() == ID_array_list;
1728}
1729
1730inline void validate_expr(const array_list_exprt &value)
1731{
1732 PRECONDITION(value.operands().size() % 2 == 0);
1733}
1734
1736{
1738 auto &ret = static_cast<const array_list_exprt &>(expr);
1740 return ret;
1741}
1742
1744{
1746 auto &ret = static_cast<array_list_exprt &>(expr);
1748 return ret;
1749}
1750
1753{
1754public:
1756 : multi_ary_exprt(ID_vector, std::move(_operands), std::move(_type))
1757 {
1758 }
1759};
1760
1761template <>
1762inline bool can_cast_expr<vector_exprt>(const exprt &base)
1763{
1764 return base.id() == ID_vector;
1765}
1766
1773inline const vector_exprt &to_vector_expr(const exprt &expr)
1774{
1775 PRECONDITION(expr.id()==ID_vector);
1776 return static_cast<const vector_exprt &>(expr);
1777}
1778
1781{
1782 PRECONDITION(expr.id()==ID_vector);
1783 return static_cast<vector_exprt &>(expr);
1784}
1785
1786
1789{
1790public:
1792 : unary_exprt(ID_union, std::move(_value), std::move(_type))
1793 {
1795 }
1796
1798 {
1799 return get(ID_component_name);
1800 }
1801
1802 void set_component_name(const irep_idt &component_name)
1803 {
1804 set(ID_component_name, component_name);
1805 }
1806
1807 std::size_t get_component_number() const
1808 {
1810 }
1811
1812 void set_component_number(std::size_t component_number)
1813 {
1814 set_size_t(ID_component_number, component_number);
1815 }
1816};
1817
1818template <>
1819inline bool can_cast_expr<union_exprt>(const exprt &base)
1820{
1821 return base.id() == ID_union;
1822}
1823
1824inline void validate_expr(const union_exprt &value)
1825{
1826 validate_operands(value, 1, "Union constructor must have one operand");
1827}
1828
1835inline const union_exprt &to_union_expr(const exprt &expr)
1836{
1837 PRECONDITION(expr.id()==ID_union);
1838 union_exprt::check(expr);
1839 return static_cast<const union_exprt &>(expr);
1840}
1841
1844{
1845 PRECONDITION(expr.id()==ID_union);
1846 union_exprt::check(expr);
1847 return static_cast<union_exprt &>(expr);
1848}
1849
1853{
1854public:
1855 explicit empty_union_exprt(typet _type)
1856 : nullary_exprt(ID_empty_union, std::move(_type))
1857 {
1858 }
1859};
1860
1861template <>
1863{
1864 return base.id() == ID_empty_union;
1865}
1866
1867inline void validate_expr(const empty_union_exprt &value)
1868{
1870 value, 0, "Empty-union constructor must not have any operand");
1871}
1872
1880{
1881 PRECONDITION(expr.id() == ID_empty_union);
1883 return static_cast<const empty_union_exprt &>(expr);
1884}
1885
1888{
1889 PRECONDITION(expr.id() == ID_empty_union);
1891 return static_cast<empty_union_exprt &>(expr);
1892}
1893
1896{
1897public:
1899 : multi_ary_exprt(ID_struct, std::move(_operands), std::move(_type))
1900 {
1901 }
1902
1903 exprt &component(const irep_idt &name, const namespacet &ns);
1904 const exprt &component(const irep_idt &name, const namespacet &ns) const;
1905};
1906
1907template <>
1908inline bool can_cast_expr<struct_exprt>(const exprt &base)
1909{
1910 return base.id() == ID_struct;
1911}
1912
1919inline const struct_exprt &to_struct_expr(const exprt &expr)
1920{
1921 PRECONDITION(expr.id()==ID_struct);
1922 return static_cast<const struct_exprt &>(expr);
1923}
1924
1927{
1928 PRECONDITION(expr.id()==ID_struct);
1929 return static_cast<struct_exprt &>(expr);
1930}
1931
1932
1935{
1936public:
1938 : binary_exprt(
1939 std::move(_real),
1940 ID_complex,
1941 std::move(_imag),
1942 std::move(_type))
1943 {
1944 }
1945
1947 {
1948 return op0();
1949 }
1950
1951 const exprt &real() const
1952 {
1953 return op0();
1954 }
1955
1957 {
1958 return op1();
1959 }
1960
1961 const exprt &imag() const
1962 {
1963 return op1();
1964 }
1965};
1966
1967template <>
1968inline bool can_cast_expr<complex_exprt>(const exprt &base)
1969{
1970 return base.id() == ID_complex;
1971}
1972
1973inline void validate_expr(const complex_exprt &value)
1974{
1975 validate_operands(value, 2, "Complex constructor must have two operands");
1976}
1977
1984inline const complex_exprt &to_complex_expr(const exprt &expr)
1985{
1986 PRECONDITION(expr.id()==ID_complex);
1987 const complex_exprt &ret = static_cast<const complex_exprt &>(expr);
1989 return ret;
1990}
1991
1994{
1995 PRECONDITION(expr.id()==ID_complex);
1996 complex_exprt &ret = static_cast<complex_exprt &>(expr);
1998 return ret;
1999}
2000
2003{
2004public:
2005 explicit complex_real_exprt(const exprt &op)
2007 {
2008 }
2009};
2010
2011template <>
2013{
2014 return base.id() == ID_complex_real;
2015}
2016
2017inline void validate_expr(const complex_real_exprt &expr)
2018{
2020 expr, 1, "real part retrieval operation must have one operand");
2021}
2022
2030{
2031 PRECONDITION(expr.id() == ID_complex_real);
2033 return static_cast<const complex_real_exprt &>(expr);
2034}
2035
2038{
2039 PRECONDITION(expr.id() == ID_complex_real);
2041 return static_cast<complex_real_exprt &>(expr);
2042}
2043
2046{
2047public:
2048 explicit complex_imag_exprt(const exprt &op)
2050 {
2051 }
2052};
2053
2054template <>
2056{
2057 return base.id() == ID_complex_imag;
2058}
2059
2060inline void validate_expr(const complex_imag_exprt &expr)
2061{
2063 expr, 1, "imaginary part retrieval operation must have one operand");
2064}
2065
2073{
2074 PRECONDITION(expr.id() == ID_complex_imag);
2075 const complex_imag_exprt &ret = static_cast<const complex_imag_exprt &>(expr);
2077 return ret;
2078}
2079
2082{
2083 PRECONDITION(expr.id() == ID_complex_imag);
2084 complex_imag_exprt &ret = static_cast<complex_imag_exprt &>(expr);
2086 return ret;
2087}
2088
2089
2092{
2093public:
2095 : unary_exprt(ID_typecast, std::move(op), std::move(_type))
2096 {
2097 }
2098
2099 // returns a typecast if the type doesn't already match
2100 static exprt conditional_cast(const exprt &expr, const typet &type)
2101 {
2102 if(expr.type() == type)
2103 return expr;
2104 else
2105 return typecast_exprt(expr, type);
2106 }
2107};
2108
2109template <>
2110inline bool can_cast_expr<typecast_exprt>(const exprt &base)
2111{
2112 return base.id() == ID_typecast;
2113}
2114
2115inline void validate_expr(const typecast_exprt &value)
2116{
2117 validate_operands(value, 1, "Typecast must have one operand");
2118}
2119
2126inline const typecast_exprt &to_typecast_expr(const exprt &expr)
2127{
2128 PRECONDITION(expr.id()==ID_typecast);
2130 return static_cast<const typecast_exprt &>(expr);
2131}
2132
2135{
2136 PRECONDITION(expr.id()==ID_typecast);
2138 return static_cast<typecast_exprt &>(expr);
2139}
2140
2145{
2146public:
2148 : multi_ary_exprt(std::move(op0), ID_and, std::move(op1), bool_typet())
2149 {
2150 }
2151
2154 ID_and,
2155 {std::move(op0), std::move(op1), std::move(op2)},
2156 bool_typet())
2157 {
2158 }
2159
2162 ID_and,
2163 {std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2164 bool_typet())
2165 {
2166 }
2167
2172};
2173
2177
2179
2184
2185template <>
2186inline bool can_cast_expr<and_exprt>(const exprt &base)
2187{
2188 return base.id() == ID_and;
2189}
2190
2197inline const and_exprt &to_and_expr(const exprt &expr)
2198{
2199 PRECONDITION(expr.id()==ID_and);
2200 return static_cast<const and_exprt &>(expr);
2201}
2202
2205{
2206 PRECONDITION(expr.id()==ID_and);
2207 return static_cast<and_exprt &>(expr);
2208}
2209
2218{
2219public:
2221 : multi_ary_exprt(std::move(op0), ID_nand, std::move(op1), bool_typet())
2222 {
2223 }
2224
2229};
2230
2237inline const nand_exprt &to_nand_expr(const exprt &expr)
2238{
2239 PRECONDITION(expr.id() == ID_nand);
2240 return static_cast<const nand_exprt &>(expr);
2241}
2242
2245{
2246 PRECONDITION(expr.id() == ID_nand);
2247 return static_cast<nand_exprt &>(expr);
2248}
2249
2252{
2253public:
2255 : binary_exprt(std::move(op0), ID_implies, std::move(op1), bool_typet())
2256 {
2257 }
2258};
2259
2260template <>
2261inline bool can_cast_expr<implies_exprt>(const exprt &base)
2262{
2263 return base.id() == ID_implies;
2264}
2265
2266inline void validate_expr(const implies_exprt &value)
2267{
2268 validate_operands(value, 2, "Implies must have two operands");
2269}
2270
2277inline const implies_exprt &to_implies_expr(const exprt &expr)
2278{
2279 PRECONDITION(expr.id()==ID_implies);
2280 const implies_exprt &ret = static_cast<const implies_exprt &>(expr);
2282 return ret;
2283}
2284
2287{
2288 PRECONDITION(expr.id()==ID_implies);
2289 implies_exprt &ret = static_cast<implies_exprt &>(expr);
2291 return ret;
2292}
2293
2298{
2299public:
2301 : multi_ary_exprt(std::move(op0), ID_or, std::move(op1), bool_typet())
2302 {
2303 }
2304
2307 ID_or,
2308 {std::move(op0), std::move(op1), std::move(op2)},
2309 bool_typet())
2310 {
2311 }
2312
2315 ID_or,
2316 {std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2317 bool_typet())
2318 {
2319 }
2320
2325};
2326
2330
2332
2333template <>
2334inline bool can_cast_expr<or_exprt>(const exprt &base)
2335{
2336 return base.id() == ID_or;
2337}
2338
2345inline const or_exprt &to_or_expr(const exprt &expr)
2346{
2347 PRECONDITION(expr.id()==ID_or);
2348 return static_cast<const or_exprt &>(expr);
2349}
2350
2353{
2354 PRECONDITION(expr.id()==ID_or);
2355 return static_cast<or_exprt &>(expr);
2356}
2357
2366{
2367public:
2369 : multi_ary_exprt(std::move(op0), ID_nor, std::move(op1), bool_typet())
2370 {
2371 }
2372
2377};
2378
2385inline const nor_exprt &to_nor_expr(const exprt &expr)
2386{
2387 PRECONDITION(expr.id() == ID_nor);
2388 return static_cast<const nor_exprt &>(expr);
2389}
2390
2393{
2394 PRECONDITION(expr.id() == ID_nor);
2395 return static_cast<nor_exprt &>(expr);
2396}
2397
2402{
2403public:
2405 : multi_ary_exprt(std::move(_op0), ID_xor, std::move(_op1), bool_typet())
2406 {
2407 }
2408
2413};
2414
2415template <>
2416inline bool can_cast_expr<xor_exprt>(const exprt &base)
2417{
2418 return base.id() == ID_xor;
2419}
2420
2427inline const xor_exprt &to_xor_expr(const exprt &expr)
2428{
2429 PRECONDITION(expr.id()==ID_xor);
2430 return static_cast<const xor_exprt &>(expr);
2431}
2432
2435{
2436 PRECONDITION(expr.id()==ID_xor);
2437 return static_cast<xor_exprt &>(expr);
2438}
2439
2446{
2447public:
2449 : multi_ary_exprt(std::move(_op0), ID_xnor, std::move(_op1), bool_typet())
2450 {
2451 }
2452
2457};
2458
2459template <>
2460inline bool can_cast_expr<xnor_exprt>(const exprt &base)
2461{
2462 return base.id() == ID_xnor;
2463}
2464
2471inline const xnor_exprt &to_xnor_expr(const exprt &expr)
2472{
2473 PRECONDITION(expr.id() == ID_xnor);
2474 return static_cast<const xnor_exprt &>(expr);
2475}
2476
2479{
2480 PRECONDITION(expr.id() == ID_xnor);
2481 return static_cast<xnor_exprt &>(expr);
2482}
2483
2486{
2487public:
2489 {
2490 PRECONDITION(as_const(*this).op().is_boolean());
2491 }
2492};
2493
2494template <>
2495inline bool can_cast_expr<not_exprt>(const exprt &base)
2496{
2497 return base.id() == ID_not;
2498}
2499
2500inline void validate_expr(const not_exprt &value)
2501{
2502 validate_operands(value, 1, "Not must have one operand");
2503}
2504
2511inline const not_exprt &to_not_expr(const exprt &expr)
2512{
2513 PRECONDITION(expr.id()==ID_not);
2514 not_exprt::check(expr);
2515 return static_cast<const not_exprt &>(expr);
2516}
2517
2520{
2521 PRECONDITION(expr.id()==ID_not);
2522 not_exprt::check(expr);
2523 return static_cast<not_exprt &>(expr);
2524}
2525
2526
2529{
2530public:
2532 : ternary_exprt(ID_if, std::move(cond), t, std::move(f), t.type())
2533 {
2534 }
2535
2537 : ternary_exprt(
2538 ID_if,
2539 std::move(cond),
2540 std::move(t),
2541 std::move(f),
2542 std::move(type))
2543 {
2544 }
2545
2547 {
2548 return op0();
2549 }
2550
2551 const exprt &cond() const
2552 {
2553 return op0();
2554 }
2555
2557 {
2558 return op1();
2559 }
2560
2561 const exprt &true_case() const
2562 {
2563 return op1();
2564 }
2565
2567 {
2568 return op2();
2569 }
2570
2571 const exprt &false_case() const
2572 {
2573 return op2();
2574 }
2575
2576 static void check(
2577 const exprt &expr,
2579 {
2580 ternary_exprt::check(expr, vm);
2581 }
2582
2583 static void validate(
2584 const exprt &expr,
2585 const namespacet &ns,
2587 {
2588 ternary_exprt::validate(expr, ns, vm);
2589 }
2590};
2591
2592template <>
2593inline bool can_cast_expr<if_exprt>(const exprt &base)
2594{
2595 return base.id() == ID_if;
2596}
2597
2598inline void validate_expr(const if_exprt &value)
2599{
2600 validate_operands(value, 3, "If-then-else must have three operands");
2601}
2602
2609inline const if_exprt &to_if_expr(const exprt &expr)
2610{
2611 PRECONDITION(expr.id()==ID_if);
2612 const if_exprt &ret = static_cast<const if_exprt &>(expr);
2614 return ret;
2615}
2616
2619{
2620 PRECONDITION(expr.id()==ID_if);
2621 if_exprt &ret = static_cast<if_exprt &>(expr);
2623 return ret;
2624}
2625
2630{
2631public:
2634 ID_with,
2635 _old.type(),
2636 {_old, std::move(_where), std::move(_new_value)})
2637 {
2638 }
2639
2641 {
2642 return op0();
2643 }
2644
2645 const exprt &old() const
2646 {
2647 return op0();
2648 }
2649
2651 {
2652 return op1();
2653 }
2654
2655 const exprt &where() const
2656 {
2657 return op1();
2658 }
2659
2661 {
2662 return op2();
2663 }
2664
2665 const exprt &new_value() const
2666 {
2667 return op2();
2668 }
2669};
2670
2671template <>
2672inline bool can_cast_expr<with_exprt>(const exprt &base)
2673{
2674 return base.id() == ID_with;
2675}
2676
2677inline void validate_expr(const with_exprt &value)
2678{
2679 validate_operands(value, 3, "array/structure update must have 3 operands");
2680}
2681
2688inline const with_exprt &to_with_expr(const exprt &expr)
2689{
2690 PRECONDITION(expr.id()==ID_with);
2691 const with_exprt &ret = static_cast<const with_exprt &>(expr);
2693 return ret;
2694}
2695
2698{
2699 PRECONDITION(expr.id()==ID_with);
2700 with_exprt &ret = static_cast<with_exprt &>(expr);
2702 return ret;
2703}
2704
2706{
2707public:
2710 {
2711 }
2712
2713 const exprt &index() const
2714 {
2715 return op0();
2716 }
2717
2719 {
2720 return op0();
2721 }
2722};
2723
2724template <>
2726{
2727 return base.id() == ID_index_designator;
2728}
2729
2730inline void validate_expr(const index_designatort &value)
2731{
2732 validate_operands(value, 1, "Index designator must have one operand");
2733}
2734
2742{
2744 const index_designatort &ret = static_cast<const index_designatort &>(expr);
2746 return ret;
2747}
2748
2751{
2753 index_designatort &ret = static_cast<index_designatort &>(expr);
2755 return ret;
2756}
2757
2759{
2760public:
2766
2768 {
2769 return get(ID_component_name);
2770 }
2771};
2772
2773template <>
2775{
2776 return base.id() == ID_member_designator;
2777}
2778
2779inline void validate_expr(const member_designatort &value)
2780{
2781 validate_operands(value, 0, "Member designator must not have operands");
2782}
2783
2791{
2793 const member_designatort &ret = static_cast<const member_designatort &>(expr);
2795 return ret;
2796}
2797
2800{
2802 member_designatort &ret = static_cast<member_designatort &>(expr);
2804 return ret;
2805}
2806
2807
2810{
2811public:
2813 : ternary_exprt(
2814 ID_update,
2815 _old,
2816 std::move(_designator),
2817 std::move(_new_value),
2818 _old.type())
2819 {
2820 }
2821
2823 {
2824 return op0();
2825 }
2826
2827 const exprt &old() const
2828 {
2829 return op0();
2830 }
2831
2832 // the designator operands are either
2833 // 1) member_designator or
2834 // 2) index_designator
2835 // as defined above
2837 {
2838 return op1().operands();
2839 }
2840
2842 {
2843 return op1().operands();
2844 }
2845
2847 {
2848 return op2();
2849 }
2850
2851 const exprt &new_value() const
2852 {
2853 return op2();
2854 }
2855
2857 with_exprt make_with_expr() const;
2858
2859 static void check(
2860 const exprt &expr,
2862 {
2863 ternary_exprt::check(expr, vm);
2864 }
2865
2866 static void validate(
2867 const exprt &expr,
2868 const namespacet &ns,
2870 {
2871 ternary_exprt::validate(expr, ns, vm);
2872 }
2873};
2874
2875template <>
2876inline bool can_cast_expr<update_exprt>(const exprt &base)
2877{
2878 return base.id() == ID_update;
2879}
2880
2881inline void validate_expr(const update_exprt &value)
2882{
2884 value, 3, "Array/structure update must have three operands");
2885}
2886
2893inline const update_exprt &to_update_expr(const exprt &expr)
2894{
2895 PRECONDITION(expr.id()==ID_update);
2896 const update_exprt &ret = static_cast<const update_exprt &>(expr);
2898 return ret;
2899}
2900
2903{
2904 PRECONDITION(expr.id()==ID_update);
2905 update_exprt &ret = static_cast<update_exprt &>(expr);
2907 return ret;
2908}
2909
2910
2911#if 0
2914{
2915public:
2917 const exprt &_array,
2918 const exprt &_index,
2919 const exprt &_new_value):
2921 {
2922 add_to_operands(_array, _index, _new_value);
2923 }
2924
2926 {
2927 operands().resize(3);
2928 }
2929
2930 exprt &array()
2931 {
2932 return op0();
2933 }
2934
2935 const exprt &array() const
2936 {
2937 return op0();
2938 }
2939
2940 exprt &index()
2941 {
2942 return op1();
2943 }
2944
2945 const exprt &index() const
2946 {
2947 return op1();
2948 }
2949
2950 exprt &new_value()
2951 {
2952 return op2();
2953 }
2954
2955 const exprt &new_value() const
2956 {
2957 return op2();
2958 }
2959};
2960
2961template<> inline bool can_cast_expr<array_update_exprt>(const exprt &base)
2962{
2963 return base.id()==ID_array_update;
2964}
2965
2966inline void validate_expr(const array_update_exprt &value)
2967{
2968 validate_operands(value, 3, "Array update must have three operands");
2969}
2970
2977inline const array_update_exprt &to_array_update_expr(const exprt &expr)
2978{
2980 const array_update_exprt &ret = static_cast<const array_update_exprt &>(expr);
2982 return ret;
2983}
2984
2987{
2989 array_update_exprt &ret = static_cast<array_update_exprt &>(expr);
2991 return ret;
2992}
2993
2994#endif
2995
2996
2999{
3000public:
3001 member_exprt(exprt op, const irep_idt &component_name, typet _type)
3002 : unary_exprt(ID_member, std::move(op), std::move(_type))
3003 {
3004 const auto &compound_type_id = compound().type().id();
3008 set_component_name(component_name);
3009 }
3010
3020
3022 {
3023 return get(ID_component_name);
3024 }
3025
3026 void set_component_name(const irep_idt &component_name)
3027 {
3028 set(ID_component_name, component_name);
3029 }
3030
3031 std::size_t get_component_number() const
3032 {
3034 }
3035
3036 // will go away, use compound()
3037 const exprt &struct_op() const
3038 {
3039 return op0();
3040 }
3041
3042 // will go away, use compound()
3044 {
3045 return op0();
3046 }
3047
3048 const exprt &compound() const
3049 {
3050 return op0();
3051 }
3052
3054 {
3055 return op0();
3056 }
3057
3058 static void check(
3059 const exprt &expr,
3061 {
3062 DATA_CHECK(
3063 vm,
3064 expr.operands().size() == 1,
3065 "member expression must have one operand");
3066 }
3067
3068 static void validate(
3069 const exprt &expr,
3070 const namespacet &ns,
3072};
3073
3074template <>
3075inline bool can_cast_expr<member_exprt>(const exprt &base)
3076{
3077 return base.id() == ID_member;
3078}
3079
3080inline void validate_expr(const member_exprt &value)
3081{
3082 validate_operands(value, 1, "Extract member must have one operand");
3083}
3084
3091inline const member_exprt &to_member_expr(const exprt &expr)
3092{
3093 PRECONDITION(expr.id()==ID_member);
3094 member_exprt::check(expr);
3095 return static_cast<const member_exprt &>(expr);
3096}
3097
3100{
3101 PRECONDITION(expr.id()==ID_member);
3102 member_exprt::check(expr);
3103 return static_cast<member_exprt &>(expr);
3104}
3105
3106
3109{
3110public:
3112 {
3113 }
3114};
3115
3116template <>
3117inline bool can_cast_expr<type_exprt>(const exprt &base)
3118{
3119 return base.id() == ID_type;
3120}
3121
3128inline const type_exprt &to_type_expr(const exprt &expr)
3129{
3131 type_exprt::check(expr);
3132 return static_cast<const type_exprt &>(expr);
3133}
3134
3137{
3139 type_exprt::check(expr);
3140 return static_cast<type_exprt &>(expr);
3141}
3142
3145{
3146public:
3147 constant_exprt(const irep_idt &_value, typet _type)
3148 : nullary_exprt(ID_constant, std::move(_type))
3149 {
3150 set_value(_value);
3151 }
3152
3153 const irep_idt &get_value() const
3154 {
3155 return get(ID_value);
3156 }
3157
3158 void set_value(const irep_idt &value)
3159 {
3160 set(ID_value, value);
3161 }
3162
3166 bool is_null_pointer() const;
3167
3168 using irept::operator==;
3169 using irept::operator!=;
3171 bool operator==(bool rhs) const;
3173 bool operator!=(bool rhs) const;
3175 bool operator==(int rhs) const;
3177 bool operator!=(int rhs) const;
3179 bool operator==(std::nullptr_t) const;
3181 bool operator!=(std::nullptr_t) const;
3182
3183 static void check(
3184 const exprt &expr,
3186
3187 static void validate(
3188 const exprt &expr,
3189 const namespacet &,
3191 {
3192 check(expr, vm);
3193 }
3194
3195protected:
3196 bool value_is_zero_string() const;
3197};
3198
3199template <>
3200inline bool can_cast_expr<constant_exprt>(const exprt &base)
3201{
3202 return base.is_constant();
3203}
3204
3205inline void validate_expr(const constant_exprt &value)
3206{
3207 validate_operands(value, 0, "Constants must not have operands");
3208}
3209
3216inline const constant_exprt &to_constant_expr(const exprt &expr)
3217{
3218 PRECONDITION(expr.is_constant());
3220 return static_cast<const constant_exprt &>(expr);
3221}
3222
3225{
3226 PRECONDITION(expr.is_constant());
3228 return static_cast<constant_exprt &>(expr);
3229}
3230
3233bool operator==(const exprt &lhs, bool rhs);
3234
3237bool operator!=(const exprt &lhs, bool rhs);
3238
3250bool operator==(const exprt &lhs, int rhs);
3251
3253bool operator!=(const exprt &lhs, int rhs);
3254
3257bool operator==(const exprt &lhs, std::nullptr_t);
3258
3260bool operator!=(const exprt &lhs, std::nullptr_t);
3261
3264{
3265public:
3269};
3270
3273{
3274public:
3278};
3279
3282{
3283public:
3288};
3289
3290template <>
3291inline bool can_cast_expr<nil_exprt>(const exprt &base)
3292{
3293 return base.id() == ID_nil;
3294}
3295
3298{
3299public:
3300 explicit infinity_exprt(typet _type)
3301 : nullary_exprt(ID_infinity, std::move(_type))
3302 {
3303 }
3304};
3305
3308{
3309public:
3310 using variablest = std::vector<symbol_exprt>;
3311
3314 irep_idt _id,
3315 const variablest &_variables,
3316 exprt _where,
3317 typet _type)
3318 : binary_exprt(
3320 ID_tuple,
3322 typet(ID_tuple)),
3323 _id,
3324 std::move(_where),
3325 std::move(_type))
3326 {
3327 }
3328
3330 {
3331 return (variablest &)to_multi_ary_expr(op0()).operands();
3332 }
3333
3334 const variablest &variables() const
3335 {
3336 return (variablest &)to_multi_ary_expr(op0()).operands();
3337 }
3338
3340 {
3341 return op1();
3342 }
3343
3344 const exprt &where() const
3345 {
3346 return op1();
3347 }
3348
3351 exprt instantiate(const exprt::operandst &) const;
3352
3355 exprt instantiate(const variablest &) const;
3356};
3357
3358template <>
3359inline bool can_cast_expr<binding_exprt>(const exprt &base)
3360{
3361 return base.id() == ID_forall || base.id() == ID_exists ||
3362 base.id() == ID_lambda || base.id() == ID_array_comprehension;
3363}
3364
3366{
3368 binding_expr, 2, "Binding expressions must have two operands");
3369}
3370
3377inline const binding_exprt &to_binding_expr(const exprt &expr)
3378{
3380 expr.id() == ID_forall || expr.id() == ID_exists ||
3381 expr.id() == ID_lambda || expr.id() == ID_array_comprehension);
3382 const binding_exprt &ret = static_cast<const binding_exprt &>(expr);
3384 return ret;
3385}
3386
3394{
3396 expr.id() == ID_forall || expr.id() == ID_exists ||
3397 expr.id() == ID_lambda || expr.id() == ID_array_comprehension);
3398 binding_exprt &ret = static_cast<binding_exprt &>(expr);
3400 return ret;
3401}
3402
3405{
3406public:
3410 const exprt &where)
3411 : binary_exprt(
3414 std::move(variables),
3415 where,
3416 where.type()),
3417 ID_let,
3419 where.type())
3420 {
3421 PRECONDITION(this->variables().size() == this->values().size());
3422 }
3423
3426 : let_exprt(
3428 operandst{std::move(value)},
3429 where)
3430 {
3431 }
3432
3434 {
3435 return static_cast<binding_exprt &>(op0());
3436 }
3437
3438 const binding_exprt &binding() const
3439 {
3440 return static_cast<const binding_exprt &>(op0());
3441 }
3442
3445 {
3446 auto &variables = binding().variables();
3447 PRECONDITION(variables.size() == 1);
3448 return variables.front();
3449 }
3450
3452 const symbol_exprt &symbol() const
3453 {
3454 const auto &variables = binding().variables();
3455 PRECONDITION(variables.size() == 1);
3456 return variables.front();
3457 }
3458
3461 {
3462 auto &values = this->values();
3463 PRECONDITION(values.size() == 1);
3464 return values.front();
3465 }
3466
3468 const exprt &value() const
3469 {
3470 const auto &values = this->values();
3471 PRECONDITION(values.size() == 1);
3472 return values.front();
3473 }
3474
3476 {
3477 return static_cast<multi_ary_exprt &>(op1()).operands();
3478 }
3479
3480 const operandst &values() const
3481 {
3482 return static_cast<const multi_ary_exprt &>(op1()).operands();
3483 }
3484
3487 {
3488 return binding().variables();
3489 }
3490
3493 {
3494 return binding().variables();
3495 }
3496
3499 {
3500 return binding().where();
3501 }
3502
3504 const exprt &where() const
3505 {
3506 return binding().where();
3507 }
3508
3509 static void validate(const exprt &, validation_modet);
3510};
3511
3512template <>
3513inline bool can_cast_expr<let_exprt>(const exprt &base)
3514{
3515 return base.id() == ID_let;
3516}
3517
3519{
3520 validate_operands(let_expr, 2, "Let must have two operands");
3521}
3522
3529inline const let_exprt &to_let_expr(const exprt &expr)
3530{
3531 PRECONDITION(expr.id()==ID_let);
3532 const let_exprt &ret = static_cast<const let_exprt &>(expr);
3534 return ret;
3535}
3536
3539{
3540 PRECONDITION(expr.id()==ID_let);
3541 let_exprt &ret = static_cast<let_exprt &>(expr);
3543 return ret;
3544}
3545
3546
3551{
3552public:
3554 : multi_ary_exprt(ID_cond, std::move(_operands), std::move(_type))
3555 {
3556 }
3557
3561 void add_case(const exprt &condition, const exprt &value)
3562 {
3563 PRECONDITION(condition.is_boolean());
3564 operands().reserve(operands().size() + 2);
3565 operands().push_back(condition);
3566 operands().push_back(value);
3567 }
3568
3569 // a lowering to nested if_exprt
3570 exprt lower() const;
3571};
3572
3573template <>
3574inline bool can_cast_expr<cond_exprt>(const exprt &base)
3575{
3576 return base.id() == ID_cond;
3577}
3578
3579inline void validate_expr(const cond_exprt &value)
3580{
3582 value.operands().size() % 2 == 0, "cond must have even number of operands");
3583}
3584
3591inline const cond_exprt &to_cond_expr(const exprt &expr)
3592{
3593 PRECONDITION(expr.id() == ID_cond);
3594 const cond_exprt &ret = static_cast<const cond_exprt &>(expr);
3596 return ret;
3597}
3598
3601{
3602 PRECONDITION(expr.id() == ID_cond);
3603 cond_exprt &ret = static_cast<cond_exprt &>(expr);
3605 return ret;
3606}
3607
3613// NOLINTNEXTLINE(readability/identifiers)
3614class DEPRECATED(SINCE(2026, 1, 18, "SMV-specific, has no other use"))
3616{
3617public:
3619 : multi_ary_exprt(ID_case, std::move(_operands), std::move(_type))
3620 {
3621 }
3622
3625 : multi_ary_exprt(ID_case, {std::move(_select_value)}, std::move(_type))
3626 {
3627 }
3628
3630 const exprt &select_value() const
3631 {
3632 PRECONDITION(!operands().empty());
3633 return operands()[0];
3634 }
3635
3638 {
3639 PRECONDITION(!operands().empty());
3640 return operands()[0];
3641 }
3642
3647 void add_case(const exprt &case_value, const exprt &result_value)
3648 {
3649 operands().reserve(operands().size() + 2);
3650 operands().push_back(case_value);
3651 operands().push_back(result_value);
3652 }
3653
3655 std::size_t number_of_cases() const
3656 {
3657 PRECONDITION(operands().size() >= 1);
3658 return (operands().size() - 1) / 2;
3659 }
3660
3662 const exprt &case_value(std::size_t i) const
3663 {
3664 PRECONDITION(i < number_of_cases());
3665 return operands()[1 + 2 * i];
3666 }
3667
3669 exprt &case_value(std::size_t i)
3670 {
3671 PRECONDITION(i < number_of_cases());
3672 return operands()[1 + 2 * i];
3673 }
3674
3676 const exprt &result_value(std::size_t i) const
3677 {
3678 PRECONDITION(i < number_of_cases());
3679 return operands()[1 + 2 * i + 1];
3680 }
3681
3683 exprt &result_value(std::size_t i)
3684 {
3685 PRECONDITION(i < number_of_cases());
3686 return operands()[1 + 2 * i + 1];
3687 }
3688
3689 static void validate_expr(const case_exprt &value)
3690 {
3692 value.operands().size() >= 1,
3693 "case expression must have at least one operand");
3695 value.operands().size() % 2 == 1,
3696 "case expression must have odd number of operands");
3697 }
3698};
3699
3700template <>
3701inline bool can_cast_expr<case_exprt>(const exprt &base)
3702{
3703 return base.id() == ID_case;
3704}
3705
3712inline const case_exprt &to_case_expr(const exprt &expr)
3713{
3714 PRECONDITION(expr.id() == ID_case);
3715 const case_exprt &ret = static_cast<const case_exprt &>(expr);
3717 return ret;
3718}
3719
3722{
3723 PRECONDITION(expr.id() == ID_case);
3724 case_exprt &ret = static_cast<case_exprt &>(expr);
3726 return ret;
3727}
3728
3738{
3739public:
3742 exprt body,
3743 array_typet _type)
3744 : binding_exprt(
3746 {std::move(arg)},
3747 std::move(body),
3748 std::move(_type))
3749 {
3750 }
3751
3752 const array_typet &type() const
3753 {
3754 return static_cast<const array_typet &>(binary_exprt::type());
3755 }
3756
3758 {
3759 return static_cast<array_typet &>(binary_exprt::type());
3760 }
3761
3762 const symbol_exprt &arg() const
3763 {
3764 auto &variables = this->variables();
3765 PRECONDITION(variables.size() == 1);
3766 return variables[0];
3767 }
3768
3770 {
3771 auto &variables = this->variables();
3772 PRECONDITION(variables.size() == 1);
3773 return variables[0];
3774 }
3775
3776 const exprt &body() const
3777 {
3778 return where();
3779 }
3780
3782 {
3783 return where();
3784 }
3785};
3786
3787template <>
3789{
3790 return base.id() == ID_array_comprehension;
3791}
3792
3794{
3795 validate_operands(value, 2, "'Array comprehension' must have two operands");
3796}
3797
3804inline const array_comprehension_exprt &
3806{
3809 static_cast<const array_comprehension_exprt &>(expr);
3811 return ret;
3812}
3813
3823
3824inline void validate_expr(const class class_method_descriptor_exprt &value);
3825
3828{
3829public:
3845 typet _type,
3849 : nullary_exprt(ID_virtual_function, std::move(_type))
3850 {
3853 set(ID_C_class, std::move(class_id));
3854 set(ID_C_base_name, std::move(base_method_name));
3855 set(ID_identifier, std::move(id));
3856 validate_expr(*this);
3857 }
3858
3866 {
3867 return get(ID_component_name);
3868 }
3869
3873 const irep_idt &class_id() const
3874 {
3875 return get(ID_C_class);
3876 }
3877
3881 {
3882 return get(ID_C_base_name);
3883 }
3884
3889 {
3890 return get(ID_identifier);
3891 }
3892};
3893
3894inline void validate_expr(const class class_method_descriptor_exprt &value)
3895{
3896 validate_operands(value, 0, "class method descriptor must not have operands");
3898 !value.mangled_method_name().empty(),
3899 "class method descriptor must have a mangled method name.");
3901 !value.class_id().empty(), "class method descriptor must have a class id.");
3903 !value.base_method_name().empty(),
3904 "class method descriptor must have a base method name.");
3906 value.get_identifier() == id2string(value.class_id()) + "." +
3908 "class method descriptor must have an identifier in the expected format.");
3909}
3910
3917inline const class_method_descriptor_exprt &
3919{
3922 return static_cast<const class_method_descriptor_exprt &>(expr);
3923}
3924
3925template <>
3927{
3928 return base.id() == ID_virtual_function;
3929}
3930
3937{
3938public:
3940 : binary_exprt(
3941 std::move(symbol),
3943 value, // not moved, for type
3944 value.type())
3945 {
3946 PRECONDITION(symbol.type() == type());
3947 }
3948
3949 const symbol_exprt &symbol() const
3950 {
3951 return static_cast<const symbol_exprt &>(op0());
3952 }
3953
3955 {
3956 return static_cast<symbol_exprt &>(op0());
3957 }
3958
3959 const exprt &value() const
3960 {
3961 return op1();
3962 }
3963
3965 {
3966 return op1();
3967 }
3968};
3969
3970template <>
3972{
3973 return base.id() == ID_named_term;
3974}
3975
3976inline void validate_expr(const named_term_exprt &value)
3977{
3978 validate_operands(value, 2, "'named term' must have two operands");
3979}
3980
3988{
3989 PRECONDITION(expr.id() == ID_named_term);
3990 const named_term_exprt &ret = static_cast<const named_term_exprt &>(expr);
3992 return ret;
3993}
3994
3997{
3998 PRECONDITION(expr.id() == ID_named_term);
3999 named_term_exprt &ret = static_cast<named_term_exprt &>(expr);
4001 return ret;
4002}
4003
4004#endif // CPROVER_UTIL_STD_EXPR_H
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
Definition as_const.h:14
Absolute value.
Definition std_expr.h:443
abs_exprt(exprt _op)
Definition std_expr.h:445
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ait()
Definition ai.h:565
Boolean AND All operands must be boolean, and the result is always boolean.
Definition std_expr.h:2145
and_exprt(exprt op0, exprt op1, exprt op2)
Definition std_expr.h:2152
and_exprt(exprt op0, exprt op1)
Definition std_expr.h:2147
and_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
Definition std_expr.h:2160
and_exprt(exprt::operandst _operands)
Definition std_expr.h:2168
Expression to define a mapping from an argument (index) to elements.
Definition std_expr.h:3738
const array_typet & type() const
Definition std_expr.h:3752
const symbol_exprt & arg() const
Definition std_expr.h:3762
const exprt & body() const
Definition std_expr.h:3776
array_typet & type()
Definition std_expr.h:3757
symbol_exprt & arg()
Definition std_expr.h:3769
array_comprehension_exprt(symbol_exprt arg, exprt body, array_typet _type)
Definition std_expr.h:3740
Array constructor from list of elements.
Definition std_expr.h:1640
array_exprt && with_source_location(const exprt &other) &&
Definition std_expr.h:1664
const array_typet & type() const
Definition std_expr.h:1647
array_exprt & with_source_location(const exprt &other) &
Definition std_expr.h:1657
array_exprt(operandst _operands, array_typet _type)
Definition std_expr.h:1642
array_typet & type()
Definition std_expr.h:1652
Array constructor from a list of index-element pairs Operands are index/value pairs,...
Definition std_expr.h:1700
void add(exprt index, exprt value)
add an index/value pair
Definition std_expr.h:1718
const array_typet & type() const
Definition std_expr.h:1707
array_list_exprt(operandst _operands, array_typet _type)
Definition std_expr.h:1702
array_typet & type()
Definition std_expr.h:1712
Array constructor from single element.
Definition std_expr.h:1577
array_typet & type()
Definition std_expr.h:1589
array_of_exprt(exprt _what, array_typet _type)
Definition std_expr.h:1579
const exprt & what() const
Definition std_expr.h:1599
const array_typet & type() const
Definition std_expr.h:1584
exprt & what()
Definition std_expr.h:1594
Arrays with given size.
Definition std_types.h:807
A base class for binary expressions.
Definition std_expr.h:639
exprt & lhs()
Definition std_expr.h:669
binary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:641
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:661
const exprt & op2() const =delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:651
exprt & rhs()
Definition std_expr.h:679
exprt & op0()
Definition expr.h:134
const exprt & lhs() const
Definition std_expr.h:674
exprt & op1()
Definition expr.h:137
exprt & op3()=delete
binary_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs, typet _type)
Definition std_expr.h:646
const exprt & rhs() const
Definition std_expr.h:684
exprt & op2()=delete
const exprt & op3() const =delete
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
Definition std_expr.h:732
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:739
binary_predicate_exprt(exprt _op0, const irep_idt &_id, exprt _op1)
Definition std_expr.h:734
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:746
A base class for relations, i.e., binary predicates whose two operands have the same type.
Definition std_expr.h:763
binary_relation_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:765
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:770
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:777
A base class for variable bindings (quantifiers, let, lambda)
Definition std_expr.h:3308
const variablest & variables() const
Definition std_expr.h:3334
const exprt & where() const
Definition std_expr.h:3344
exprt & where()
Definition std_expr.h:3339
variablest & variables()
Definition std_expr.h:3329
binding_exprt(irep_idt _id, const variablest &_variables, exprt _where, typet _type)
construct the binding expression
Definition std_expr.h:3313
exprt instantiate(const exprt::operandst &) const
substitute free occurrences of the variables in where() by the given values
Definition std_expr.cpp:419
std::vector< symbol_exprt > variablest
Definition std_expr.h:3310
The Boolean type.
Definition std_types.h:36
Case expression: evaluates to the value corresponding to the first matching case.
Definition std_expr.h:3616
exprt & result_value(std::size_t i)
Get the result value for the i-th case.
Definition std_expr.h:3683
void add_case(const exprt &case_value, const exprt &result_value)
Add a case: value to compare and corresponding result.
Definition std_expr.h:3647
static void validate_expr(const case_exprt &value)
Definition std_expr.h:3689
const exprt & case_value(std::size_t i) const
Get the case value for the i-th case.
Definition std_expr.h:3662
case_exprt(operandst _operands, typet _type)
Definition std_expr.h:3618
exprt & select_value()
Get the value that is being compared against.
Definition std_expr.h:3637
const exprt & result_value(std::size_t i) const
Get the result value for the i-th case.
Definition std_expr.h:3676
std::size_t number_of_cases() const
Get the number of cases (excluding the select value)
Definition std_expr.h:3655
case_exprt(exprt _select_value, typet _type)
Constructor with select value.
Definition std_expr.h:3624
exprt & case_value(std::size_t i)
Get the case value for the i-th case.
Definition std_expr.h:3669
const exprt & select_value() const
Get the value that is being compared against.
Definition std_expr.h:3630
An expression describing a method on a class.
Definition std_expr.h:3828
const irep_idt & base_method_name() const
The name of the method to which this expression is applied as would be seen in the source code.
Definition std_expr.h:3880
const irep_idt & mangled_method_name() const
The method name after mangling it by combining it with the descriptor.
Definition std_expr.h:3865
const irep_idt & get_identifier() const
A unique identifier of the combination of class and method overload to which this expression refers.
Definition std_expr.h:3888
class_method_descriptor_exprt(typet _type, irep_idt mangled_method_name, irep_idt class_id, irep_idt base_method_name)
Definition std_expr.h:3844
const irep_idt & class_id() const
Unique identifier in the symbol table, of the compile time type of the class which this expression is...
Definition std_expr.h:3873
Complex constructor from a pair of numbers.
Definition std_expr.h:1935
complex_exprt(exprt _real, exprt _imag, complex_typet _type)
Definition std_expr.h:1937
exprt real()
Definition std_expr.h:1946
exprt imag()
Definition std_expr.h:1956
const exprt & real() const
Definition std_expr.h:1951
const exprt & imag() const
Definition std_expr.h:1961
Imaginary part of the expression describing a complex number.
Definition std_expr.h:2046
complex_imag_exprt(const exprt &op)
Definition std_expr.h:2048
Real part of the expression describing a complex number.
Definition std_expr.h:2003
complex_real_exprt(const exprt &op)
Definition std_expr.h:2005
Complex numbers made of pair of given subtype.
Definition std_types.h:1133
this is a parametric version of an if-expression: it returns the value of the first case (using the o...
Definition std_expr.h:3551
void add_case(const exprt &condition, const exprt &value)
adds a case to a cond expression
Definition std_expr.h:3561
cond_exprt(operandst _operands, typet _type)
Definition std_expr.h:3553
exprt lower() const
Definition std_expr.cpp:458
A constant literal expression.
Definition std_expr.h:3145
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:3187
const irep_idt & get_value() const
Definition std_expr.h:3153
bool operator!=(bool rhs) const
Return whether the expression lhs is not a constant of Boolean type or is not representing the Boolea...
Definition std_expr.cpp:47
bool value_is_zero_string() const
Definition std_expr.cpp:26
bool operator==(bool rhs) const
Return whether the expression lhs is a constant of Boolean type that is representing the Boolean valu...
Definition std_expr.cpp:42
constant_exprt(const irep_idt &_value, typet _type)
Definition std_expr.h:3147
void set_value(const irep_idt &value)
Definition std_expr.h:3158
bool is_null_pointer() const
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
Definition std_expr.cpp:170
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.cpp:210
Expression to hold a symbol (variable) with extra accessors to ID_c_static_lifetime and ID_C_thread_l...
Definition std_expr.h:216
decorated_symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:220
bool is_static_lifetime() const
Definition std_expr.h:225
bool is_thread_local() const
Definition std_expr.h:240
Division.
Definition std_expr.h:1176
div_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1178
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1184
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1190
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1202
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1196
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Union constructor to support unions without any member (a GCC/Clang feature).
Definition std_expr.h:1853
empty_union_exprt(typet _type)
Definition std_expr.h:1855
Equality.
Definition std_expr.h:1385
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:1393
equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1387
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:1400
Boute's Euclidean definition of Modulo – to match SMT-LIB2.
Definition std_expr.h:1315
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1335
euclidean_mod_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1317
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1341
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1323
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1329
Base class for all expressions.
Definition expr.h:349
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
exprt & op2()
Definition expr.h:140
Base class for all expressions.
Definition expr.h:57
std::vector< exprt > operandst
Definition expr.h:59
bool is_boolean() const
Return whether the expression represents a Boolean.
Definition expr.h:229
static void check(const exprt &, const validation_modet)
Check that the expression is well-formed (shallow checks only, i.e., subexpressions and its type are ...
Definition expr.h:259
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
bool is_constant() const
Return whether the expression is a constant.
Definition expr.h:213
typet & type()
Return the type of the expression.
Definition expr.h:85
operandst & operands()
Definition expr.h:95
exprt & op2()
Definition expr.h:140
source_locationt & add_source_location()
Definition expr.h:241
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
Definition expr.h:171
The Boolean constant false.
Definition std_expr.h:3273
Binary greater than operator expression.
Definition std_expr.h:808
greater_than_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:810
Binary greater than or equal operator expression.
Definition std_expr.h:829
greater_than_or_equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:831
The trinary if-then-else operator.
Definition std_expr.h:2529
const exprt & false_case() const
Definition std_expr.h:2571
exprt & cond()
Definition std_expr.h:2546
const exprt & cond() const
Definition std_expr.h:2551
if_exprt(exprt cond, const exprt &t, exprt f)
Definition std_expr.h:2531
const exprt & true_case() const
Definition std_expr.h:2561
exprt & false_case()
Definition std_expr.h:2566
if_exprt(exprt cond, exprt t, exprt f, typet type)
Definition std_expr.h:2536
exprt & true_case()
Definition std_expr.h:2556
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2576
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2583
Boolean implication.
Definition std_expr.h:2252
implies_exprt(exprt op0, exprt op1)
Definition std_expr.h:2254
const exprt & index() const
Definition std_expr.h:2713
index_designatort(exprt _index)
Definition std_expr.h:2708
exprt & index()
Definition std_expr.h:2718
Array index operator.
Definition std_expr.h:1489
exprt & index()
Definition std_expr.h:1529
index_exprt(exprt _array, exprt _index, typet _type)
Definition std_expr.h:1507
index_exprt(const exprt &_array, exprt _index)
Definition std_expr.h:1495
exprt & array()
Definition std_expr.h:1519
const exprt & index() const
Definition std_expr.h:1534
const exprt & array() const
Definition std_expr.h:1524
An expression denoting infinity.
Definition std_expr.h:3298
infinity_exprt(typet _type)
Definition std_expr.h:3300
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
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:44
void remove(const irep_idt &name)
Definition irep.cpp:87
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:412
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:388
Binary less than operator expression.
Definition std_expr.h:850
less_than_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:852
Binary less than or equal operator expression.
Definition std_expr.h:871
less_than_or_equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:873
A let expression.
Definition std_expr.h:3405
binding_exprt::variablest & variables()
convenience accessor for binding().variables()
Definition std_expr.h:3486
const binding_exprt & binding() const
Definition std_expr.h:3438
const binding_exprt::variablest & variables() const
convenience accessor for binding().variables()
Definition std_expr.h:3492
operandst & values()
Definition std_expr.h:3475
let_exprt(symbol_exprt symbol, exprt value, const exprt &where)
convenience constructor for the case of a single binding
Definition std_expr.h:3425
const exprt & where() const
convenience accessor for binding().where()
Definition std_expr.h:3504
static void validate(const exprt &, validation_modet)
Definition std_expr.cpp:362
const symbol_exprt & symbol() const
convenience accessor for the symbol of a single binding
Definition std_expr.h:3452
let_exprt(binding_exprt::variablest variables, operandst values, const exprt &where)
Definition std_expr.h:3407
exprt & value()
convenience accessor for the value of a single binding
Definition std_expr.h:3460
exprt & where()
convenience accessor for binding().where()
Definition std_expr.h:3498
binding_exprt & binding()
Definition std_expr.h:3433
const operandst & values() const
Definition std_expr.h:3480
const exprt & value() const
convenience accessor for the value of a single binding
Definition std_expr.h:3468
symbol_exprt & symbol()
convenience accessor for the symbol of a single binding
Definition std_expr.h:3444
irep_idt get_component_name() const
Definition std_expr.h:2767
member_designatort(const irep_idt &_component_name)
Definition std_expr.h:2761
Extract member of struct or union.
Definition std_expr.h:2999
const exprt & compound() const
Definition std_expr.h:3048
exprt & struct_op()
Definition std_expr.h:3043
const exprt & struct_op() const
Definition std_expr.h:3037
irep_idt get_component_name() const
Definition std_expr.h:3021
void set_component_name(const irep_idt &component_name)
Definition std_expr.h:3026
exprt & compound()
Definition std_expr.h:3053
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Check that the member expression has the right number of operands, refers to a component that exists ...
Definition std_expr.cpp:327
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:3058
member_exprt(exprt op, const irep_idt &component_name, typet _type)
Definition std_expr.h:3001
std::size_t get_component_number() const
Definition std_expr.h:3031
member_exprt(exprt op, const struct_typet::componentt &c)
Definition std_expr.h:3011
Binary minus.
Definition std_expr.h:1075
minus_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1077
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Definition std_expr.h:1247
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1255
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1261
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1267
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1273
mod_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1249
Binary multiplication Associativity is not specified.
Definition std_expr.h:1121
mult_exprt(exprt::operandst factors, typet type)
Definition std_expr.h:1133
mult_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1123
mult_exprt(exprt::operandst factors)
Definition std_expr.h:1128
A base class for multi-ary expressions Associativity is not specified.
Definition std_expr.h:913
exprt & op1()
Definition std_expr.h:947
const exprt & op0() const
Definition std_expr.h:965
multi_ary_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs, typet _type)
Definition std_expr.h:934
const exprt & op2() const
Definition std_expr.h:977
const exprt & op3() const
Definition std_expr.h:983
exprt & op0()
Definition std_expr.h:941
exprt & op2()
Definition std_expr.h:953
multi_ary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:929
multi_ary_exprt(const irep_idt &_id, operandst _operands, typet _type)
Definition std_expr.h:915
const exprt & op1() const
Definition std_expr.h:971
multi_ary_exprt(const irep_idt &_id, operandst _operands)
Definition std_expr.h:921
exprt & op3()
Definition std_expr.h:959
Expression that introduces a new symbol that is equal to the operand.
Definition std_expr.h:3937
named_term_exprt(symbol_exprt symbol, exprt value)
Definition std_expr.h:3939
symbol_exprt & symbol()
Definition std_expr.h:3954
const exprt & value() const
Definition std_expr.h:3959
const symbol_exprt & symbol() const
Definition std_expr.h:3949
exprt & value()
Definition std_expr.h:3964
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
Boolean NAND.
Definition std_expr.h:2218
nand_exprt(exprt op0, exprt op1)
Definition std_expr.h:2220
nand_exprt(exprt::operandst _operands)
Definition std_expr.h:2225
The NIL expression.
Definition std_expr.h:3282
Expression to hold a nondeterministic choice.
Definition std_expr.h:293
void set_identifier(const irep_idt &identifier)
Definition std_expr.h:316
nondet_symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:297
const irep_idt & get_identifier() const
Definition std_expr.h:321
nondet_symbol_exprt(irep_idt identifier, typet type, source_locationt location)
Definition std_expr.h:306
Boolean NOR.
Definition std_expr.h:2366
nor_exprt(exprt op0, exprt op1)
Definition std_expr.h:2368
nor_exprt(exprt::operandst _operands)
Definition std_expr.h:2373
Boolean negation.
Definition std_expr.h:2486
not_exprt(exprt _op)
Definition std_expr.h:2488
Disequality.
Definition std_expr.h:1444
notequal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1446
An expression without operands.
Definition std_expr.h:23
exprt & op0()=delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:30
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:40
const exprt & op1() const =delete
nullary_exprt(const irep_idt &_id, typet _type)
Definition std_expr.h:25
const exprt & op0() const =delete
void copy_to_operands(const exprt &, const exprt &, const exprt &)=delete
exprt & op3()=delete
void copy_to_operands(const exprt &expr)=delete
operandst & operands()=delete
remove all operand methods
void copy_to_operands(const exprt &, const exprt &)=delete
const operandst & operands() const =delete
exprt & op1()=delete
exprt & op2()=delete
const exprt & op3() const =delete
const exprt & op2() const =delete
Boolean OR All operands must be boolean, and the result is always boolean.
Definition std_expr.h:2298
or_exprt(exprt op0, exprt op1, exprt op2)
Definition std_expr.h:2305
or_exprt(exprt::operandst _operands)
Definition std_expr.h:2321
or_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
Definition std_expr.h:2313
or_exprt(exprt op0, exprt op1)
Definition std_expr.h:2300
The plus expression Associativity is not specified.
Definition std_expr.h:1011
plus_exprt(exprt _lhs, exprt _rhs, typet _type)
Definition std_expr.h:1018
plus_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1013
plus_exprt(operandst _operands, typet _type)
Definition std_expr.h:1032
plus_exprt(operandst _operands)
Definition std_expr.h:1027
A base class for expressions that are predicates, i.e., Boolean-typed.
Definition std_expr.h:575
predicate_exprt(const irep_idt &_id)
Definition std_expr.h:577
Sign of an expression Predicate is true if _op is negative, false otherwise.
Definition std_expr.h:597
sign_exprt(exprt _op)
Definition std_expr.h:599
Struct constructor from list of elements.
Definition std_expr.h:1896
exprt & component(const irep_idt &name, const namespacet &ns)
Definition std_expr.cpp:308
struct_exprt(operandst _operands, typet _type)
Definition std_expr.h:1898
Expression to hold a symbol (variable)
Definition std_expr.h:132
void set_identifier(const irep_idt &identifier)
Definition std_expr.h:156
static symbol_exprt typeless(const irep_idt &id)
Generate a symbol_exprt without a proper type.
Definition std_expr.h:151
symbol_exprt & with_source_location(const exprt &other) &
Add the source location from other, if it has any.
Definition std_expr.h:183
symbol_exprt & with_source_location(source_locationt location) &
Add the source location from location, if it is non-nil.
Definition std_expr.h:167
symbol_exprt && with_source_location(source_locationt location) &&
Add the source location from location, if it is non-nil.
Definition std_expr.h:175
symbol_exprt && with_source_location(const exprt &other) &&
Add the source location from other, if it has any.
Definition std_expr.h:191
symbol_exprt(typet type)
Definition std_expr.h:135
symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:141
const irep_idt & get_identifier() const
Definition std_expr.h:161
An expression with three operands.
Definition std_expr.h:68
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:102
ternary_exprt(const irep_idt &_id, exprt _op0, exprt _op1, exprt _op2, typet _type)
Definition std_expr.h:71
const exprt & op3() const =delete
exprt & op0()
Definition expr.h:134
exprt & op1()
Definition expr.h:137
exprt & op2()
Definition expr.h:140
exprt & op3()=delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:92
The Boolean constant true.
Definition std_expr.h:3264
An expression denoting a type.
Definition std_expr.h:3109
type_exprt(typet type)
Definition std_expr.h:3111
Semantic type conversion.
Definition std_expr.h:2092
static exprt conditional_cast(const exprt &expr, const typet &type)
Definition std_expr.h:2100
typecast_exprt(exprt op, typet _type)
Definition std_expr.h:2094
The type of an expression, extends irept.
Definition type.h:29
Generic base class for unary expressions.
Definition std_expr.h:362
unary_exprt(const irep_idt &_id, const exprt &_op)
Definition std_expr.h:364
const exprt & op3() const =delete
exprt & op2()=delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:374
const exprt & op1() const =delete
exprt & op3()=delete
const exprt & op() const
Definition std_expr.h:392
unary_exprt(const irep_idt &_id, exprt _op, typet _type)
Definition std_expr.h:369
const exprt & op2() const =delete
exprt & op()
Definition std_expr.h:397
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:384
exprt & op1()=delete
The unary minus expression.
Definition std_expr.h:485
unary_minus_exprt(exprt _op)
Definition std_expr.h:492
unary_minus_exprt(exprt _op, typet _type)
Definition std_expr.h:487
The unary plus expression.
Definition std_expr.h:532
unary_plus_exprt(exprt op)
Definition std_expr.h:534
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
Definition std_expr.h:586
unary_predicate_exprt(const irep_idt &_id, exprt _op)
Definition std_expr.h:588
Union constructor from single element.
Definition std_expr.h:1789
std::size_t get_component_number() const
Definition std_expr.h:1807
void set_component_number(std::size_t component_number)
Definition std_expr.h:1812
void set_component_name(const irep_idt &component_name)
Definition std_expr.h:1802
irep_idt get_component_name() const
Definition std_expr.h:1797
union_exprt(const irep_idt &_component_name, exprt _value, typet _type)
Definition std_expr.h:1791
Operator to update elements in structs and arrays.
Definition std_expr.h:2810
exprt & old()
Definition std_expr.h:2822
with_exprt make_with_expr() const
converts an update expr into a (possibly nested) with expression
Definition std_expr.cpp:388
exprt::operandst & designator()
Definition std_expr.h:2836
exprt & new_value()
Definition std_expr.h:2846
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2866
const exprt & new_value() const
Definition std_expr.h:2851
update_exprt(const exprt &_old, exprt _designator, exprt _new_value)
Definition std_expr.h:2812
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2859
const exprt & old() const
Definition std_expr.h:2827
const exprt::operandst & designator() const
Definition std_expr.h:2841
Vector constructor from list of elements.
Definition std_expr.h:1753
vector_exprt(operandst _operands, vector_typet _type)
Definition std_expr.h:1755
The vector type.
Definition std_types.h:1064
Operator to update elements in structs and arrays.
Definition std_expr.h:2630
const exprt & old() const
Definition std_expr.h:2645
const exprt & where() const
Definition std_expr.h:2655
exprt & new_value()
Definition std_expr.h:2660
exprt & where()
Definition std_expr.h:2650
with_exprt(const exprt &_old, exprt _where, exprt _new_value)
Definition std_expr.h:2632
const exprt & new_value() const
Definition std_expr.h:2665
exprt & old()
Definition std_expr.h:2640
Boolean XNOR.
Definition std_expr.h:2446
xnor_exprt(exprt::operandst _operands)
Definition std_expr.h:2453
xnor_exprt(exprt _op0, exprt _op1)
Definition std_expr.h:2448
Boolean XOR All operands must be boolean, and the result is always boolean.
Definition std_expr.h:2402
xor_exprt(exprt _op0, exprt _op1)
Definition std_expr.h:2404
xor_exprt(exprt::operandst _operands)
Definition std_expr.h:2409
#define SINCE(year, month, day, msg)
Definition deprecate.h:26
#define DEPRECATED(msg)
Definition deprecate.h:23
Templated functions to cast to specific exprt-derived classes.
void validate_operands(const exprt &value, exprt::operandst::size_type number, const char *message, bool allow_more=false)
Definition expr_cast.h:250
const irept & get_nil_irep()
Definition irep.cpp:19
dstring_hash irep_id_hash
Definition irep.h:38
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
STL namespace.
#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
bool can_cast_expr< equal_exprt >(const exprt &base)
Definition std_expr.h:1410
bool can_cast_expr< notequal_exprt >(const exprt &base)
Definition std_expr.h:1453
bool can_cast_expr< complex_exprt >(const exprt &base)
Definition std_expr.h:1968
bool can_cast_expr< not_exprt >(const exprt &base)
Definition std_expr.h:2495
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
Definition std_expr.h:1919
const array_list_exprt & to_array_list_expr(const exprt &expr)
Definition std_expr.h:1735
bool can_cast_expr< typecast_exprt >(const exprt &base)
Definition std_expr.h:2110
bool operator==(const exprt &lhs, bool rhs)
Return whether the expression lhs is a constant of Boolean type that is representing the Boolean valu...
Definition std_expr.cpp:32
const type_exprt & to_type_expr(const exprt &expr)
Cast an exprt to an type_exprt.
Definition std_expr.h:3128
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
Definition std_expr.h:1622
bool can_cast_expr< struct_exprt >(const exprt &base)
Definition std_expr.h:1908
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
Definition std_expr.h:896
const unary_plus_exprt & to_unary_plus_expr(const exprt &expr)
Cast an exprt to a unary_plus_exprt.
Definition std_expr.h:557
bool can_cast_expr< xor_exprt >(const exprt &base)
Definition std_expr.h:2416
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition std_expr.h:1557
bool can_cast_expr< mult_exprt >(const exprt &base)
Definition std_expr.h:1140
bool can_cast_expr< if_exprt >(const exprt &base)
Definition std_expr.h:2593
const class_method_descriptor_exprt & to_class_method_descriptor_expr(const exprt &expr)
Cast an exprt to a class_method_descriptor_exprt.
Definition std_expr.h:3918
bool can_cast_expr< named_term_exprt >(const exprt &base)
Definition std_expr.h:3971
bool can_cast_expr< binding_exprt >(const exprt &base)
Definition std_expr.h:3359
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
Definition std_expr.h:1296
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
Definition std_expr.h:1156
const and_exprt & to_and_expr(const exprt &expr)
Cast an exprt to a and_exprt.
Definition std_expr.h:2197
bool can_cast_expr< member_designatort >(const exprt &base)
Definition std_expr.h:2774
const array_comprehension_exprt & to_array_comprehension_expr(const exprt &expr)
Cast an exprt to a array_comprehension_exprt.
Definition std_expr.h:3805
const ternary_exprt & to_ternary_expr(const exprt &expr)
Cast an exprt to a ternary_exprt.
Definition std_expr.h:117
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
Definition std_expr.h:3987
const xnor_exprt & to_xnor_expr(const exprt &expr)
Cast an exprt to a xnor_exprt.
Definition std_expr.h:2471
bool can_cast_expr< xnor_exprt >(const exprt &base)
Definition std_expr.h:2460
bool can_cast_expr< array_comprehension_exprt >(const exprt &base)
Definition std_expr.h:3788
const xor_exprt & to_xor_expr(const exprt &expr)
Cast an exprt to a xor_exprt.
Definition std_expr.h:2427
const or_exprt & to_or_expr(const exprt &expr)
Cast an exprt to a or_exprt.
Definition std_expr.h:2345
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
Definition std_expr.h:1684
bool can_cast_expr< complex_imag_exprt >(const exprt &base)
Definition std_expr.h:2055
bool can_cast_expr< abs_exprt >(const exprt &base)
Definition std_expr.h:451
bool can_cast_expr< sign_exprt >(const exprt &base)
Definition std_expr.h:606
const cond_exprt & to_cond_expr(const exprt &expr)
Cast an exprt to a cond_exprt.
Definition std_expr.h:3591
bool can_cast_expr< type_exprt >(const exprt &base)
Definition std_expr.h:3117
exprt disjunction(const exprt::operandst &)
1) generates a disjunction for two or more operands 2) for one operand, returns the operand 3) return...
Definition std_expr.cpp:240
bool can_cast_expr< class_method_descriptor_exprt >(const exprt &base)
Definition std_expr.h:3926
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition std_expr.h:2126
void validate_expr(const symbol_exprt &value)
Definition std_expr.h:262
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
Definition std_expr.h:1225
bool can_cast_expr< unary_minus_exprt >(const exprt &base)
Definition std_expr.h:499
bool can_cast_expr< less_than_exprt >(const exprt &base)
Definition std_expr.h:859
bool can_cast_expr< with_exprt >(const exprt &base)
Definition std_expr.h:2672
const vector_exprt & to_vector_expr(const exprt &expr)
Cast an exprt to an vector_exprt.
Definition std_expr.h:1773
exprt conjunction(const exprt::operandst &)
1) generates a conjunction for two or more operands 2) for one operand, returns the operand 3) return...
Definition std_expr.cpp:275
bool can_cast_expr< minus_exprt >(const exprt &base)
Definition std_expr.h:1084
bool can_cast_expr< let_exprt >(const exprt &base)
Definition std_expr.h:3513
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition std_expr.h:716
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
Definition std_expr.h:1055
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
Definition std_expr.h:1469
bool can_cast_expr< plus_exprt >(const exprt &base)
Definition std_expr.h:1039
const nand_exprt & to_nand_expr(const exprt &expr)
Cast an exprt to a nand_exprt.
Definition std_expr.h:2237
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition std_expr.h:427
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
Definition std_expr.h:996
bool can_cast_expr< array_of_exprt >(const exprt &base)
Definition std_expr.h:1606
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
Definition std_expr.h:3529
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
Definition std_expr.h:467
bool can_cast_expr< nondet_symbol_exprt >(const exprt &base)
Definition std_expr.h:328
bool can_cast_expr< case_exprt >(const exprt &base)
Definition std_expr.h:3701
bool can_cast_expr< constant_exprt >(const exprt &base)
Definition std_expr.h:3200
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition std_expr.h:2609
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition std_expr.h:3091
bool can_cast_expr< index_exprt >(const exprt &base)
Definition std_expr.h:1541
bool can_cast_expr< symbol_exprt >(const exprt &base)
Definition std_expr.h:257
const empty_union_exprt & to_empty_union_expr(const exprt &expr)
Cast an exprt to an empty_union_exprt.
Definition std_expr.h:1879
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
Definition std_expr.h:1100
bool can_cast_expr< member_exprt >(const exprt &base)
Definition std_expr.h:3075
bool can_cast_expr< empty_union_exprt >(const exprt &base)
Definition std_expr.h:1862
const complex_imag_exprt & to_complex_imag_expr(const exprt &expr)
Cast an exprt to a complex_imag_exprt.
Definition std_expr.h:2072
const binding_exprt & to_binding_expr(const exprt &expr)
Cast an exprt to a binding_exprt.
Definition std_expr.h:3377
bool can_cast_expr< or_exprt >(const exprt &base)
Definition std_expr.h:2334
bool can_cast_expr< mod_exprt >(const exprt &base)
Definition std_expr.h:1280
const index_designatort & to_index_designator(const exprt &expr)
Cast an exprt to an index_designatort.
Definition std_expr.h:2741
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
Definition std_expr.h:1835
bool can_cast_expr< cond_exprt >(const exprt &base)
Definition std_expr.h:3574
const complex_real_exprt & to_complex_real_expr(const exprt &expr)
Cast an exprt to a complex_real_exprt.
Definition std_expr.h:2029
bool can_cast_expr< update_exprt >(const exprt &base)
Definition std_expr.h:2876
bool can_cast_expr< binary_relation_exprt >(const exprt &base)
Definition std_expr.h:796
bool can_cast_expr< euclidean_mod_exprt >(const exprt &base)
Definition std_expr.h:1348
bool can_cast_expr< vector_exprt >(const exprt &base)
Definition std_expr.h:1762
const case_exprt & to_case_expr(const exprt &expr)
Cast an exprt to a case_exprt.
Definition std_expr.h:3712
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition std_expr.h:3216
bool can_cast_expr< array_list_exprt >(const exprt &base)
Definition std_expr.h:1725
bool can_cast_expr< index_designatort >(const exprt &base)
Definition std_expr.h:2725
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition std_expr.h:2511
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition std_expr.h:273
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Definition std_expr.h:2688
const complex_exprt & to_complex_expr(const exprt &expr)
Cast an exprt to a complex_exprt.
Definition std_expr.h:1984
bool can_cast_expr< unary_plus_exprt >(const exprt &base)
Definition std_expr.h:541
bool can_cast_expr< and_exprt >(const exprt &base)
Definition std_expr.h:2186
bool can_cast_expr< greater_than_exprt >(const exprt &base)
Definition std_expr.h:817
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
Definition std_expr.h:2277
bool can_cast_expr< array_exprt >(const exprt &base)
Definition std_expr.h:1673
bool can_cast_expr< binary_exprt >(const exprt &base)
Definition std_expr.h:700
bool can_cast_expr< div_exprt >(const exprt &base)
Definition std_expr.h:1209
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
Definition std_expr.h:2893
bool can_cast_expr< nil_exprt >(const exprt &base)
Definition std_expr.h:3291
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
Definition std_expr.h:515
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
Definition std_expr.h:1426
bool operator!=(const exprt &lhs, bool rhs)
Return whether the expression lhs is not a constant of Boolean type or is not representing the Boolea...
Definition std_expr.cpp:37
bool can_cast_expr< greater_than_or_equal_exprt >(const exprt &base)
Definition std_expr.h:838
bool can_cast_expr< implies_exprt >(const exprt &base)
Definition std_expr.h:2261
bool can_cast_expr< unary_exprt >(const exprt &base)
Definition std_expr.h:411
bool can_cast_expr< less_than_or_equal_exprt >(const exprt &base)
Definition std_expr.h:880
const nondet_symbol_exprt & to_nondet_symbol_expr(const exprt &expr)
Cast an exprt to a nondet_symbol_exprt.
Definition std_expr.h:344
bool can_cast_expr< union_exprt >(const exprt &base)
Definition std_expr.h:1819
const member_designatort & to_member_designator(const exprt &expr)
Cast an exprt to an member_designatort.
Definition std_expr.h:2790
bool can_cast_expr< complex_real_exprt >(const exprt &base)
Definition std_expr.h:2012
const sign_exprt & to_sign_expr(const exprt &expr)
Cast an exprt to a sign_exprt.
Definition std_expr.h:622
const nor_exprt & to_nor_expr(const exprt &expr)
Cast an exprt to a nor_exprt.
Definition std_expr.h:2385
const euclidean_mod_exprt & to_euclidean_mod_expr(const exprt &expr)
Cast an exprt to a euclidean_mod_exprt.
Definition std_expr.h:1364
Pre-defined types.
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
Definition std_types.h:1158
size_t operator()(const ::symbol_exprt &sym)
Definition std_expr.h:206
const type_with_subtypet & to_type_with_subtype(const typet &type)
Definition type.h:208
#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