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 "expr_cast.h"
17#include "invariant.h"
18#include "std_types.h"
19
22{
23public:
25 : expr_protectedt(_id, std::move(_type))
26 {
27 }
28
29 static void check(
30 const exprt &expr,
32 {
34 vm,
35 expr.operands().size() == 0,
36 "nullary expression must not have operands");
37 }
38
39 static void validate(
40 const exprt &expr,
41 const namespacet &,
43 {
44 check(expr, vm);
45 }
46
48 operandst &operands() = delete;
49 const operandst &operands() const = delete;
50
51 const exprt &op0() const = delete;
52 exprt &op0() = delete;
53 const exprt &op1() const = delete;
54 exprt &op1() = delete;
55 const exprt &op2() const = delete;
56 exprt &op2() = delete;
57 const exprt &op3() const = delete;
58 exprt &op3() = delete;
59
60 void copy_to_operands(const exprt &expr) = delete;
61 void copy_to_operands(const exprt &, const exprt &) = delete;
62 void copy_to_operands(const exprt &, const exprt &, const exprt &) = delete;
63};
64
67{
68public:
69 // constructor
71 const irep_idt &_id,
72 exprt _op0,
73 exprt _op1,
74 exprt _op2,
75 typet _type)
77 _id,
78 std::move(_type),
79 {std::move(_op0), std::move(_op1), std::move(_op2)})
80 {
81 }
82
83 // make op0 to op2 public
84 using exprt::op0;
85 using exprt::op1;
86 using exprt::op2;
87
88 const exprt &op3() const = delete;
89 exprt &op3() = delete;
90
91 static void check(
92 const exprt &expr,
94 {
96 vm,
97 expr.operands().size() == 3,
98 "ternary expression must have three operands");
99 }
100
101 static void validate(
102 const exprt &expr,
103 const namespacet &,
105 {
106 check(expr, vm);
107 }
108};
109
116inline const ternary_exprt &to_ternary_expr(const exprt &expr)
117{
119 return static_cast<const ternary_exprt &>(expr);
120}
121
124{
126 return static_cast<ternary_exprt &>(expr);
127}
128
131{
132public:
135 {
136 }
137
140 symbol_exprt(const irep_idt &identifier, typet type)
142 {
143 set_identifier(identifier);
144 }
145
151 {
152 return symbol_exprt(id, typet());
153 }
154
155 void set_identifier(const irep_idt &identifier)
156 {
157 set(ID_identifier, identifier);
158 }
159
161 {
162 return get(ID_identifier);
163 }
164
167 {
168 if(location.is_not_nil())
169 add_source_location() = std::move(location);
170 return *this;
171 }
172
175 {
176 if(location.is_not_nil())
177 add_source_location() = std::move(location);
178 return std::move(*this);
179 }
180
183 {
184 if(other.source_location().is_not_nil())
185 add_source_location() = other.source_location();
186 return *this;
187 }
188
191 {
192 if(other.source_location().is_not_nil())
193 add_source_location() = other.source_location();
194 return std::move(*this);
195 }
196};
197
198// NOLINTNEXTLINE(readability/namespace)
199namespace std
200{
201template <>
202// NOLINTNEXTLINE(readability/identifiers)
203struct hash<::symbol_exprt>
204{
205 size_t operator()(const ::symbol_exprt &sym)
206 {
207 return irep_id_hash()(sym.get_identifier());
208 }
209};
210} // namespace std
211
215{
216public:
220 : symbol_exprt(identifier, std::move(type))
221 {
222 }
223
225 {
227 }
228
230 {
231 return set(ID_C_static_lifetime, true);
232 }
233
238
239 bool is_thread_local() const
240 {
242 }
243
245 {
246 return set(ID_C_thread_local, true);
247 }
248
253};
254
255template <>
256inline bool can_cast_expr<symbol_exprt>(const exprt &base)
257{
258 return base.id() == ID_symbol;
259}
260
261inline void validate_expr(const symbol_exprt &value)
262{
263 validate_operands(value, 0, "Symbols must not have operands");
264}
265
272inline const symbol_exprt &to_symbol_expr(const exprt &expr)
273{
274 PRECONDITION(expr.id()==ID_symbol);
275 const symbol_exprt &ret = static_cast<const symbol_exprt &>(expr);
277 return ret;
278}
279
282{
283 PRECONDITION(expr.id()==ID_symbol);
284 symbol_exprt &ret = static_cast<symbol_exprt &>(expr);
286 return ret;
287}
288
289
292{
293public:
298 {
299 set_identifier(identifier);
300 }
301
306 irep_idt identifier,
307 typet type,
308 source_locationt location)
310 {
311 set_identifier(std::move(identifier));
312 add_source_location() = std::move(location);
313 }
314
315 void set_identifier(const irep_idt &identifier)
316 {
317 set(ID_identifier, identifier);
318 }
319
321 {
322 return get(ID_identifier);
323 }
324};
325
326template <>
328{
329 return base.id() == ID_nondet_symbol;
330}
331
332inline void validate_expr(const nondet_symbol_exprt &value)
333{
334 validate_operands(value, 0, "Symbols must not have operands");
335}
336
344{
347 return static_cast<const nondet_symbol_exprt &>(expr);
348}
349
352{
353 PRECONDITION(expr.id()==ID_symbol);
355 return static_cast<nondet_symbol_exprt &>(expr);
356}
357
358
361{
362public:
365 {
366 }
367
369 : expr_protectedt(_id, std::move(_type), {std::move(_op)})
370 {
371 }
372
373 static void check(
374 const exprt &expr,
376 {
378 vm,
379 expr.operands().size() == 1,
380 "unary expression must have one operand");
381 }
382
383 static void validate(
384 const exprt &expr,
385 const namespacet &,
387 {
388 check(expr, vm);
389 }
390
391 const exprt &op() const
392 {
393 return op0();
394 }
395
397 {
398 return op0();
399 }
400
401 const exprt &op1() const = delete;
402 exprt &op1() = delete;
403 const exprt &op2() const = delete;
404 exprt &op2() = delete;
405 const exprt &op3() const = delete;
406 exprt &op3() = delete;
407};
408
409template <>
410inline bool can_cast_expr<unary_exprt>(const exprt &base)
411{
412 return base.operands().size() == 1;
413}
414
415inline void validate_expr(const unary_exprt &value)
416{
417 unary_exprt::check(value);
418}
419
426inline const unary_exprt &to_unary_expr(const exprt &expr)
427{
428 unary_exprt::check(expr);
429 return static_cast<const unary_exprt &>(expr);
430}
431
434{
435 unary_exprt::check(expr);
436 return static_cast<unary_exprt &>(expr);
437}
438
439
442{
443public:
445 {
446 }
447};
448
449template <>
450inline bool can_cast_expr<abs_exprt>(const exprt &base)
451{
452 return base.id() == ID_abs;
453}
454
455inline void validate_expr(const abs_exprt &value)
456{
457 validate_operands(value, 1, "Absolute value must have one operand");
458}
459
466inline const abs_exprt &to_abs_expr(const exprt &expr)
467{
468 PRECONDITION(expr.id()==ID_abs);
469 abs_exprt::check(expr);
470 return static_cast<const abs_exprt &>(expr);
471}
472
475{
476 PRECONDITION(expr.id()==ID_abs);
477 abs_exprt::check(expr);
478 return static_cast<abs_exprt &>(expr);
479}
480
481
484{
485public:
487 : unary_exprt(ID_unary_minus, std::move(_op), std::move(_type))
488 {
489 }
490
493 {
494 }
495};
496
497template <>
499{
500 return base.id() == ID_unary_minus;
501}
502
503inline void validate_expr(const unary_minus_exprt &value)
504{
505 validate_operands(value, 1, "Unary minus must have one operand");
506}
507
515{
518 return static_cast<const unary_minus_exprt &>(expr);
519}
520
523{
526 return static_cast<unary_minus_exprt &>(expr);
527}
528
531{
532public:
535 {
536 }
537};
538
539template <>
541{
542 return base.id() == ID_unary_plus;
543}
544
545inline void validate_expr(const unary_plus_exprt &value)
546{
547 validate_operands(value, 1, "unary plus must have one operand");
548}
549
556inline const unary_plus_exprt &to_unary_plus_expr(const exprt &expr)
557{
558 PRECONDITION(expr.id() == ID_unary_plus);
560 return static_cast<const unary_plus_exprt &>(expr);
561}
562
565{
566 PRECONDITION(expr.id() == ID_unary_plus);
568 return static_cast<unary_plus_exprt &>(expr);
569}
570
574{
575public:
576 explicit predicate_exprt(const irep_idt &_id)
578 {
579 }
580};
581
585{
586public:
588 : unary_exprt(_id, std::move(_op), bool_typet())
589 {
590 }
591};
592
596{
597public:
600 {
601 }
602};
603
604template <>
605inline bool can_cast_expr<sign_exprt>(const exprt &base)
606{
607 return base.id() == ID_sign;
608}
609
610inline void validate_expr(const sign_exprt &expr)
611{
612 validate_operands(expr, 1, "sign expression must have one operand");
613}
614
621inline const sign_exprt &to_sign_expr(const exprt &expr)
622{
623 PRECONDITION(expr.id() == ID_sign);
624 sign_exprt::check(expr);
625 return static_cast<const sign_exprt &>(expr);
626}
627
630{
631 PRECONDITION(expr.id() == ID_sign);
632 sign_exprt::check(expr);
633 return static_cast<sign_exprt &>(expr);
634}
635
638{
639public:
641 : expr_protectedt(_id, _lhs.type(), {_lhs, std::move(_rhs)})
642 {
643 }
644
646 : expr_protectedt(_id, std::move(_type), {std::move(_lhs), std::move(_rhs)})
647 {
648 }
649
650 static void check(
651 const exprt &expr,
653 {
655 vm,
656 expr.operands().size() == 2,
657 "binary expression must have two operands");
658 }
659
660 static void validate(
661 const exprt &expr,
662 const namespacet &,
664 {
665 check(expr, vm);
666 }
667
669 {
670 return exprt::op0();
671 }
672
673 const exprt &lhs() const
674 {
675 return exprt::op0();
676 }
677
679 {
680 return exprt::op1();
681 }
682
683 const exprt &rhs() const
684 {
685 return exprt::op1();
686 }
687
688 // make op0 and op1 public
689 using exprt::op0;
690 using exprt::op1;
691
692 const exprt &op2() const = delete;
693 exprt &op2() = delete;
694 const exprt &op3() const = delete;
695 exprt &op3() = delete;
696};
697
698template <>
699inline bool can_cast_expr<binary_exprt>(const exprt &base)
700{
701 return base.operands().size() == 2;
702}
703
704inline void validate_expr(const binary_exprt &value)
705{
706 binary_exprt::check(value);
707}
708
715inline const binary_exprt &to_binary_expr(const exprt &expr)
716{
718 return static_cast<const binary_exprt &>(expr);
719}
720
723{
725 return static_cast<binary_exprt &>(expr);
726}
727
731{
732public:
734 : binary_exprt(std::move(_op0), _id, std::move(_op1), bool_typet())
735 {
736 }
737
738 static void check(
739 const exprt &expr,
741 {
742 binary_exprt::check(expr, vm);
743 }
744
745 static void validate(
746 const exprt &expr,
747 const namespacet &ns,
749 {
750 binary_exprt::validate(expr, ns, vm);
751
753 vm,
754 expr.is_boolean(),
755 "result of binary predicate expression should be of type bool");
756 }
757};
758
762{
763public:
768
769 static void check(
770 const exprt &expr,
772 {
774 }
775
776 static void validate(
777 const exprt &expr,
778 const namespacet &ns,
780 {
782
783 // we now can safely assume that 'expr' is a binary predicate
784 const auto &expr_binary = static_cast<const binary_predicate_exprt &>(expr);
785
786 // check that the types of the operands are the same
788 vm,
789 expr_binary.op0().type() == expr_binary.op1().type(),
790 "lhs and rhs of binary relation expression should have same type");
791 }
792};
793
794template <>
796{
797 return can_cast_expr<binary_exprt>(base);
798}
799
800inline void validate_expr(const binary_relation_exprt &value)
801{
803}
804
807{
808public:
813};
814
815template <>
817{
818 return base.id() == ID_gt;
819}
820
821inline void validate_expr(const greater_than_exprt &value)
822{
824}
825
835
836template <>
838{
839 return base.id() == ID_ge;
840}
841
843{
845}
846
849{
850public:
855};
856
857template <>
858inline bool can_cast_expr<less_than_exprt>(const exprt &base)
859{
860 return base.id() == ID_lt;
861}
862
863inline void validate_expr(const less_than_exprt &value)
864{
866}
867
877
878template <>
880{
881 return base.id() == ID_le;
882}
883
885{
887}
888
896{
898 return static_cast<const binary_relation_exprt &>(expr);
899}
900
903{
905 return static_cast<binary_relation_exprt &>(expr);
906}
907
908
912{
913public:
915 : expr_protectedt(_id, std::move(_type))
916 {
917 operands() = std::move(_operands);
918 }
919
922 {
923 PRECONDITION(!_operands.empty());
924 type() = _operands.front().type();
925 operands() = std::move(_operands);
926 }
927
929 : expr_protectedt(_id, _lhs.type(), {_lhs, std::move(_rhs)})
930 {
931 }
932
934 : expr_protectedt(_id, std::move(_type), {std::move(_lhs), std::move(_rhs)})
935 {
936 }
937
938 // In contrast to exprt::opX, the methods
939 // below check the size.
941 {
942 PRECONDITION(operands().size() >= 1);
943 return operands().front();
944 }
945
947 {
948 PRECONDITION(operands().size() >= 2);
949 return operands()[1];
950 }
951
953 {
954 PRECONDITION(operands().size() >= 3);
955 return operands()[2];
956 }
957
959 {
960 PRECONDITION(operands().size() >= 4);
961 return operands()[3];
962 }
963
964 const exprt &op0() const
965 {
966 PRECONDITION(operands().size() >= 1);
967 return operands().front();
968 }
969
970 const exprt &op1() const
971 {
972 PRECONDITION(operands().size() >= 2);
973 return operands()[1];
974 }
975
976 const exprt &op2() const
977 {
978 PRECONDITION(operands().size() >= 3);
979 return operands()[2];
980 }
981
982 const exprt &op3() const
983 {
984 PRECONDITION(operands().size() >= 4);
985 return operands()[3];
986 }
987};
988
995inline const multi_ary_exprt &to_multi_ary_expr(const exprt &expr)
996{
997 return static_cast<const multi_ary_exprt &>(expr);
998}
999
1002{
1003 return static_cast<multi_ary_exprt &>(expr);
1004}
1005
1006
1010{
1011public:
1013 : multi_ary_exprt(std::move(_lhs), ID_plus, std::move(_rhs))
1014 {
1015 }
1016
1019 std::move(_lhs),
1020 ID_plus,
1021 std::move(_rhs),
1022 std::move(_type))
1023 {
1024 }
1025
1028 {
1029 }
1030
1032 : multi_ary_exprt(ID_plus, std::move(_operands), std::move(_type))
1033 {
1034 }
1035};
1036
1037template <>
1038inline bool can_cast_expr<plus_exprt>(const exprt &base)
1039{
1040 return base.id() == ID_plus;
1041}
1042
1043inline void validate_expr(const plus_exprt &value)
1044{
1045 validate_operands(value, 2, "Plus must have two or more operands", true);
1046}
1047
1054inline const plus_exprt &to_plus_expr(const exprt &expr)
1055{
1056 PRECONDITION(expr.id()==ID_plus);
1057 const plus_exprt &ret = static_cast<const plus_exprt &>(expr);
1059 return ret;
1060}
1061
1064{
1065 PRECONDITION(expr.id()==ID_plus);
1066 plus_exprt &ret = static_cast<plus_exprt &>(expr);
1068 return ret;
1069}
1070
1071
1074{
1075public:
1077 : binary_exprt(std::move(_lhs), ID_minus, std::move(_rhs))
1078 {
1079 }
1080};
1081
1082template <>
1083inline bool can_cast_expr<minus_exprt>(const exprt &base)
1084{
1085 return base.id() == ID_minus;
1086}
1087
1088inline void validate_expr(const minus_exprt &value)
1089{
1090 validate_operands(value, 2, "Minus must have two or more operands", true);
1091}
1092
1099inline const minus_exprt &to_minus_expr(const exprt &expr)
1100{
1101 PRECONDITION(expr.id()==ID_minus);
1102 const minus_exprt &ret = static_cast<const minus_exprt &>(expr);
1104 return ret;
1105}
1106
1109{
1110 PRECONDITION(expr.id()==ID_minus);
1111 minus_exprt &ret = static_cast<minus_exprt &>(expr);
1113 return ret;
1114}
1115
1116
1120{
1121public:
1123 : multi_ary_exprt(std::move(_lhs), ID_mult, std::move(_rhs))
1124 {
1125 }
1126
1129 {
1130 }
1131
1136};
1137
1138template <>
1139inline bool can_cast_expr<mult_exprt>(const exprt &base)
1140{
1141 return base.id() == ID_mult;
1142}
1143
1144inline void validate_expr(const mult_exprt &value)
1145{
1146 validate_operands(value, 2, "Multiply must have two or more operands", true);
1147}
1148
1155inline const mult_exprt &to_mult_expr(const exprt &expr)
1156{
1157 PRECONDITION(expr.id()==ID_mult);
1158 const mult_exprt &ret = static_cast<const mult_exprt &>(expr);
1160 return ret;
1161}
1162
1165{
1166 PRECONDITION(expr.id()==ID_mult);
1167 mult_exprt &ret = static_cast<mult_exprt &>(expr);
1169 return ret;
1170}
1171
1172
1175{
1176public:
1178 : binary_exprt(std::move(_lhs), ID_div, std::move(_rhs))
1179 {
1180 }
1181
1184 {
1185 return op0();
1186 }
1187
1189 const exprt &dividend() const
1190 {
1191 return op0();
1192 }
1193
1196 {
1197 return op1();
1198 }
1199
1201 const exprt &divisor() const
1202 {
1203 return op1();
1204 }
1205};
1206
1207template <>
1208inline bool can_cast_expr<div_exprt>(const exprt &base)
1209{
1210 return base.id() == ID_div;
1211}
1212
1213inline void validate_expr(const div_exprt &value)
1214{
1215 validate_operands(value, 2, "Divide must have two operands");
1216}
1217
1224inline const div_exprt &to_div_expr(const exprt &expr)
1225{
1226 PRECONDITION(expr.id()==ID_div);
1227 const div_exprt &ret = static_cast<const div_exprt &>(expr);
1229 return ret;
1230}
1231
1234{
1235 PRECONDITION(expr.id()==ID_div);
1236 div_exprt &ret = static_cast<div_exprt &>(expr);
1238 return ret;
1239}
1240
1246{
1247public:
1249 : binary_exprt(std::move(_lhs), ID_mod, std::move(_rhs))
1250 {
1251 }
1252
1255 {
1256 return op0();
1257 }
1258
1260 const exprt &dividend() const
1261 {
1262 return op0();
1263 }
1264
1267 {
1268 return op1();
1269 }
1270
1272 const exprt &divisor() const
1273 {
1274 return op1();
1275 }
1276};
1277
1278template <>
1279inline bool can_cast_expr<mod_exprt>(const exprt &base)
1280{
1281 return base.id() == ID_mod;
1282}
1283
1284inline void validate_expr(const mod_exprt &value)
1285{
1286 validate_operands(value, 2, "Modulo must have two operands");
1287}
1288
1295inline const mod_exprt &to_mod_expr(const exprt &expr)
1296{
1297 PRECONDITION(expr.id()==ID_mod);
1298 const mod_exprt &ret = static_cast<const mod_exprt &>(expr);
1300 return ret;
1301}
1302
1305{
1306 PRECONDITION(expr.id()==ID_mod);
1307 mod_exprt &ret = static_cast<mod_exprt &>(expr);
1309 return ret;
1310}
1311
1314{
1315public:
1320
1323 {
1324 return op0();
1325 }
1326
1328 const exprt &dividend() const
1329 {
1330 return op0();
1331 }
1332
1335 {
1336 return op1();
1337 }
1338
1340 const exprt &divisor() const
1341 {
1342 return op1();
1343 }
1344};
1345
1346template <>
1348{
1349 return base.id() == ID_euclidean_mod;
1350}
1351
1352inline void validate_expr(const euclidean_mod_exprt &value)
1353{
1354 validate_operands(value, 2, "Modulo must have two operands");
1355}
1356
1364{
1365 PRECONDITION(expr.id() == ID_euclidean_mod);
1366 const euclidean_mod_exprt &ret =
1367 static_cast<const euclidean_mod_exprt &>(expr);
1369 return ret;
1370}
1371
1374{
1375 PRECONDITION(expr.id() == ID_euclidean_mod);
1376 euclidean_mod_exprt &ret = static_cast<euclidean_mod_exprt &>(expr);
1378 return ret;
1379}
1380
1381
1384{
1385public:
1387 : binary_relation_exprt(std::move(_lhs), ID_equal, std::move(_rhs))
1388 {
1389 PRECONDITION(lhs().type() == rhs().type());
1390 }
1391
1392 static void check(
1393 const exprt &expr,
1395 {
1397 }
1398
1399 static void validate(
1400 const exprt &expr,
1401 const namespacet &ns,
1403 {
1404 binary_relation_exprt::validate(expr, ns, vm);
1405 }
1406};
1407
1408template <>
1409inline bool can_cast_expr<equal_exprt>(const exprt &base)
1410{
1411 return base.id() == ID_equal;
1412}
1413
1414inline void validate_expr(const equal_exprt &value)
1415{
1416 equal_exprt::check(value);
1417}
1418
1425inline const equal_exprt &to_equal_expr(const exprt &expr)
1426{
1427 PRECONDITION(expr.id()==ID_equal);
1428 equal_exprt::check(expr);
1429 return static_cast<const equal_exprt &>(expr);
1430}
1431
1434{
1435 PRECONDITION(expr.id()==ID_equal);
1436 equal_exprt::check(expr);
1437 return static_cast<equal_exprt &>(expr);
1438}
1439
1440
1443{
1444public:
1449};
1450
1451template <>
1452inline bool can_cast_expr<notequal_exprt>(const exprt &base)
1453{
1454 return base.id() == ID_notequal;
1455}
1456
1457inline void validate_expr(const notequal_exprt &value)
1458{
1459 validate_operands(value, 2, "Inequality must have two operands");
1460}
1461
1468inline const notequal_exprt &to_notequal_expr(const exprt &expr)
1469{
1470 PRECONDITION(expr.id()==ID_notequal);
1471 const notequal_exprt &ret = static_cast<const notequal_exprt &>(expr);
1473 return ret;
1474}
1475
1478{
1479 PRECONDITION(expr.id()==ID_notequal);
1480 notequal_exprt &ret = static_cast<notequal_exprt &>(expr);
1482 return ret;
1483}
1484
1485
1488{
1489public:
1490 // _array must have either index or vector type.
1491 // When _array has array_type, the type of _index
1492 // must be array_type.index_type().
1493 // This will eventually be enforced using a precondition.
1495 : binary_exprt(
1496 _array,
1497 ID_index,
1498 std::move(_index),
1499 to_type_with_subtype(_array.type()).subtype())
1500 {
1501 const auto &array_op_type = _array.type();
1503 array_op_type.id() == ID_array || array_op_type.id() == ID_vector);
1504 }
1505
1507 : binary_exprt(
1508 std::move(_array),
1509 ID_index,
1510 std::move(_index),
1511 std::move(_type))
1512 {
1513 const auto &array_op_type = array().type();
1515 array_op_type.id() == ID_array || array_op_type.id() == ID_vector);
1516 }
1517
1519 {
1520 return op0();
1521 }
1522
1523 const exprt &array() const
1524 {
1525 return op0();
1526 }
1527
1529 {
1530 return op1();
1531 }
1532
1533 const exprt &index() const
1534 {
1535 return op1();
1536 }
1537};
1538
1539template <>
1540inline bool can_cast_expr<index_exprt>(const exprt &base)
1541{
1542 return base.id() == ID_index;
1543}
1544
1545inline void validate_expr(const index_exprt &value)
1546{
1547 validate_operands(value, 2, "Array index must have two operands");
1548}
1549
1556inline const index_exprt &to_index_expr(const exprt &expr)
1557{
1558 PRECONDITION(expr.id()==ID_index);
1559 const index_exprt &ret = static_cast<const index_exprt &>(expr);
1561 return ret;
1562}
1563
1566{
1567 PRECONDITION(expr.id()==ID_index);
1568 index_exprt &ret = static_cast<index_exprt &>(expr);
1570 return ret;
1571}
1572
1573
1576{
1577public:
1579 : unary_exprt(ID_array_of, std::move(_what), std::move(_type))
1580 {
1581 }
1582
1583 const array_typet &type() const
1584 {
1585 return static_cast<const array_typet &>(unary_exprt::type());
1586 }
1587
1589 {
1590 return static_cast<array_typet &>(unary_exprt::type());
1591 }
1592
1594 {
1595 return op0();
1596 }
1597
1598 const exprt &what() const
1599 {
1600 return op0();
1601 }
1602};
1603
1604template <>
1605inline bool can_cast_expr<array_of_exprt>(const exprt &base)
1606{
1607 return base.id() == ID_array_of;
1608}
1609
1610inline void validate_expr(const array_of_exprt &value)
1611{
1612 validate_operands(value, 1, "'Array of' must have one operand");
1613}
1614
1621inline const array_of_exprt &to_array_of_expr(const exprt &expr)
1622{
1623 PRECONDITION(expr.id()==ID_array_of);
1625 return static_cast<const array_of_exprt &>(expr);
1626}
1627
1630{
1631 PRECONDITION(expr.id()==ID_array_of);
1633 return static_cast<array_of_exprt &>(expr);
1634}
1635
1636
1639{
1640public:
1642 : multi_ary_exprt(ID_array, std::move(_operands), std::move(_type))
1643 {
1644 }
1645
1646 const array_typet &type() const
1647 {
1648 return static_cast<const array_typet &>(multi_ary_exprt::type());
1649 }
1650
1652 {
1653 return static_cast<array_typet &>(multi_ary_exprt::type());
1654 }
1655
1657 {
1658 if(other.source_location().is_not_nil())
1659 add_source_location() = other.source_location();
1660 return *this;
1661 }
1662
1664 {
1665 if(other.source_location().is_not_nil())
1666 add_source_location() = other.source_location();
1667 return std::move(*this);
1668 }
1669};
1670
1671template <>
1672inline bool can_cast_expr<array_exprt>(const exprt &base)
1673{
1674 return base.id() == ID_array;
1675}
1676
1683inline const array_exprt &to_array_expr(const exprt &expr)
1684{
1685 PRECONDITION(expr.id()==ID_array);
1686 return static_cast<const array_exprt &>(expr);
1687}
1688
1691{
1692 PRECONDITION(expr.id()==ID_array);
1693 return static_cast<array_exprt &>(expr);
1694}
1695
1699{
1700public:
1702 : multi_ary_exprt(ID_array_list, std::move(_operands), std::move(_type))
1703 {
1704 }
1705
1706 const array_typet &type() const
1707 {
1708 return static_cast<const array_typet &>(multi_ary_exprt::type());
1709 }
1710
1712 {
1713 return static_cast<array_typet &>(multi_ary_exprt::type());
1714 }
1715
1717 void add(exprt index, exprt value)
1718 {
1719 add_to_operands(std::move(index), std::move(value));
1720 }
1721};
1722
1723template <>
1725{
1726 return base.id() == ID_array_list;
1727}
1728
1729inline void validate_expr(const array_list_exprt &value)
1730{
1731 PRECONDITION(value.operands().size() % 2 == 0);
1732}
1733
1735{
1737 auto &ret = static_cast<const array_list_exprt &>(expr);
1739 return ret;
1740}
1741
1743{
1745 auto &ret = static_cast<array_list_exprt &>(expr);
1747 return ret;
1748}
1749
1752{
1753public:
1755 : multi_ary_exprt(ID_vector, std::move(_operands), std::move(_type))
1756 {
1757 }
1758};
1759
1760template <>
1761inline bool can_cast_expr<vector_exprt>(const exprt &base)
1762{
1763 return base.id() == ID_vector;
1764}
1765
1772inline const vector_exprt &to_vector_expr(const exprt &expr)
1773{
1774 PRECONDITION(expr.id()==ID_vector);
1775 return static_cast<const vector_exprt &>(expr);
1776}
1777
1780{
1781 PRECONDITION(expr.id()==ID_vector);
1782 return static_cast<vector_exprt &>(expr);
1783}
1784
1785
1788{
1789public:
1791 : unary_exprt(ID_union, std::move(_value), std::move(_type))
1792 {
1794 }
1795
1797 {
1798 return get(ID_component_name);
1799 }
1800
1801 void set_component_name(const irep_idt &component_name)
1802 {
1803 set(ID_component_name, component_name);
1804 }
1805
1806 std::size_t get_component_number() const
1807 {
1809 }
1810
1811 void set_component_number(std::size_t component_number)
1812 {
1813 set_size_t(ID_component_number, component_number);
1814 }
1815};
1816
1817template <>
1818inline bool can_cast_expr<union_exprt>(const exprt &base)
1819{
1820 return base.id() == ID_union;
1821}
1822
1823inline void validate_expr(const union_exprt &value)
1824{
1825 validate_operands(value, 1, "Union constructor must have one operand");
1826}
1827
1834inline const union_exprt &to_union_expr(const exprt &expr)
1835{
1836 PRECONDITION(expr.id()==ID_union);
1837 union_exprt::check(expr);
1838 return static_cast<const union_exprt &>(expr);
1839}
1840
1843{
1844 PRECONDITION(expr.id()==ID_union);
1845 union_exprt::check(expr);
1846 return static_cast<union_exprt &>(expr);
1847}
1848
1852{
1853public:
1854 explicit empty_union_exprt(typet _type)
1855 : nullary_exprt(ID_empty_union, std::move(_type))
1856 {
1857 }
1858};
1859
1860template <>
1862{
1863 return base.id() == ID_empty_union;
1864}
1865
1866inline void validate_expr(const empty_union_exprt &value)
1867{
1869 value, 0, "Empty-union constructor must not have any operand");
1870}
1871
1879{
1880 PRECONDITION(expr.id() == ID_empty_union);
1882 return static_cast<const empty_union_exprt &>(expr);
1883}
1884
1887{
1888 PRECONDITION(expr.id() == ID_empty_union);
1890 return static_cast<empty_union_exprt &>(expr);
1891}
1892
1895{
1896public:
1898 : multi_ary_exprt(ID_struct, std::move(_operands), std::move(_type))
1899 {
1900 }
1901
1902 exprt &component(const irep_idt &name, const namespacet &ns);
1903 const exprt &component(const irep_idt &name, const namespacet &ns) const;
1904};
1905
1906template <>
1907inline bool can_cast_expr<struct_exprt>(const exprt &base)
1908{
1909 return base.id() == ID_struct;
1910}
1911
1918inline const struct_exprt &to_struct_expr(const exprt &expr)
1919{
1920 PRECONDITION(expr.id()==ID_struct);
1921 return static_cast<const struct_exprt &>(expr);
1922}
1923
1926{
1927 PRECONDITION(expr.id()==ID_struct);
1928 return static_cast<struct_exprt &>(expr);
1929}
1930
1931
1934{
1935public:
1937 : binary_exprt(
1938 std::move(_real),
1939 ID_complex,
1940 std::move(_imag),
1941 std::move(_type))
1942 {
1943 }
1944
1946 {
1947 return op0();
1948 }
1949
1950 const exprt &real() const
1951 {
1952 return op0();
1953 }
1954
1956 {
1957 return op1();
1958 }
1959
1960 const exprt &imag() const
1961 {
1962 return op1();
1963 }
1964};
1965
1966template <>
1967inline bool can_cast_expr<complex_exprt>(const exprt &base)
1968{
1969 return base.id() == ID_complex;
1970}
1971
1972inline void validate_expr(const complex_exprt &value)
1973{
1974 validate_operands(value, 2, "Complex constructor must have two operands");
1975}
1976
1983inline const complex_exprt &to_complex_expr(const exprt &expr)
1984{
1985 PRECONDITION(expr.id()==ID_complex);
1986 const complex_exprt &ret = static_cast<const complex_exprt &>(expr);
1988 return ret;
1989}
1990
1993{
1994 PRECONDITION(expr.id()==ID_complex);
1995 complex_exprt &ret = static_cast<complex_exprt &>(expr);
1997 return ret;
1998}
1999
2002{
2003public:
2004 explicit complex_real_exprt(const exprt &op)
2006 {
2007 }
2008};
2009
2010template <>
2012{
2013 return base.id() == ID_complex_real;
2014}
2015
2016inline void validate_expr(const complex_real_exprt &expr)
2017{
2019 expr, 1, "real part retrieval operation must have one operand");
2020}
2021
2029{
2030 PRECONDITION(expr.id() == ID_complex_real);
2032 return static_cast<const complex_real_exprt &>(expr);
2033}
2034
2037{
2038 PRECONDITION(expr.id() == ID_complex_real);
2040 return static_cast<complex_real_exprt &>(expr);
2041}
2042
2045{
2046public:
2047 explicit complex_imag_exprt(const exprt &op)
2049 {
2050 }
2051};
2052
2053template <>
2055{
2056 return base.id() == ID_complex_imag;
2057}
2058
2059inline void validate_expr(const complex_imag_exprt &expr)
2060{
2062 expr, 1, "imaginary part retrieval operation must have one operand");
2063}
2064
2072{
2073 PRECONDITION(expr.id() == ID_complex_imag);
2074 const complex_imag_exprt &ret = static_cast<const complex_imag_exprt &>(expr);
2076 return ret;
2077}
2078
2081{
2082 PRECONDITION(expr.id() == ID_complex_imag);
2083 complex_imag_exprt &ret = static_cast<complex_imag_exprt &>(expr);
2085 return ret;
2086}
2087
2088
2091{
2092public:
2094 : unary_exprt(ID_typecast, std::move(op), std::move(_type))
2095 {
2096 }
2097
2098 // returns a typecast if the type doesn't already match
2099 static exprt conditional_cast(const exprt &expr, const typet &type)
2100 {
2101 if(expr.type() == type)
2102 return expr;
2103 else
2104 return typecast_exprt(expr, type);
2105 }
2106};
2107
2108template <>
2109inline bool can_cast_expr<typecast_exprt>(const exprt &base)
2110{
2111 return base.id() == ID_typecast;
2112}
2113
2114inline void validate_expr(const typecast_exprt &value)
2115{
2116 validate_operands(value, 1, "Typecast must have one operand");
2117}
2118
2125inline const typecast_exprt &to_typecast_expr(const exprt &expr)
2126{
2127 PRECONDITION(expr.id()==ID_typecast);
2129 return static_cast<const typecast_exprt &>(expr);
2130}
2131
2134{
2135 PRECONDITION(expr.id()==ID_typecast);
2137 return static_cast<typecast_exprt &>(expr);
2138}
2139
2144{
2145public:
2147 : multi_ary_exprt(std::move(op0), ID_and, std::move(op1), bool_typet())
2148 {
2149 }
2150
2153 ID_and,
2154 {std::move(op0), std::move(op1), std::move(op2)},
2155 bool_typet())
2156 {
2157 }
2158
2161 ID_and,
2162 {std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2163 bool_typet())
2164 {
2165 }
2166
2171};
2172
2176
2178
2183
2184template <>
2185inline bool can_cast_expr<and_exprt>(const exprt &base)
2186{
2187 return base.id() == ID_and;
2188}
2189
2196inline const and_exprt &to_and_expr(const exprt &expr)
2197{
2198 PRECONDITION(expr.id()==ID_and);
2199 return static_cast<const and_exprt &>(expr);
2200}
2201
2204{
2205 PRECONDITION(expr.id()==ID_and);
2206 return static_cast<and_exprt &>(expr);
2207}
2208
2217{
2218public:
2220 : multi_ary_exprt(std::move(op0), ID_nand, std::move(op1), bool_typet())
2221 {
2222 }
2223
2228};
2229
2236inline const nand_exprt &to_nand_expr(const exprt &expr)
2237{
2238 PRECONDITION(expr.id() == ID_nand);
2239 return static_cast<const nand_exprt &>(expr);
2240}
2241
2244{
2245 PRECONDITION(expr.id() == ID_nand);
2246 return static_cast<nand_exprt &>(expr);
2247}
2248
2251{
2252public:
2254 : binary_exprt(std::move(op0), ID_implies, std::move(op1), bool_typet())
2255 {
2256 }
2257};
2258
2259template <>
2260inline bool can_cast_expr<implies_exprt>(const exprt &base)
2261{
2262 return base.id() == ID_implies;
2263}
2264
2265inline void validate_expr(const implies_exprt &value)
2266{
2267 validate_operands(value, 2, "Implies must have two operands");
2268}
2269
2276inline const implies_exprt &to_implies_expr(const exprt &expr)
2277{
2278 PRECONDITION(expr.id()==ID_implies);
2279 const implies_exprt &ret = static_cast<const implies_exprt &>(expr);
2281 return ret;
2282}
2283
2286{
2287 PRECONDITION(expr.id()==ID_implies);
2288 implies_exprt &ret = static_cast<implies_exprt &>(expr);
2290 return ret;
2291}
2292
2297{
2298public:
2300 : multi_ary_exprt(std::move(op0), ID_or, std::move(op1), bool_typet())
2301 {
2302 }
2303
2306 ID_or,
2307 {std::move(op0), std::move(op1), std::move(op2)},
2308 bool_typet())
2309 {
2310 }
2311
2314 ID_or,
2315 {std::move(op0), std::move(op1), std::move(op2), std::move(op3)},
2316 bool_typet())
2317 {
2318 }
2319
2324};
2325
2329
2331
2332template <>
2333inline bool can_cast_expr<or_exprt>(const exprt &base)
2334{
2335 return base.id() == ID_or;
2336}
2337
2344inline const or_exprt &to_or_expr(const exprt &expr)
2345{
2346 PRECONDITION(expr.id()==ID_or);
2347 return static_cast<const or_exprt &>(expr);
2348}
2349
2352{
2353 PRECONDITION(expr.id()==ID_or);
2354 return static_cast<or_exprt &>(expr);
2355}
2356
2365{
2366public:
2368 : multi_ary_exprt(std::move(op0), ID_nor, std::move(op1), bool_typet())
2369 {
2370 }
2371
2376};
2377
2384inline const nor_exprt &to_nor_expr(const exprt &expr)
2385{
2386 PRECONDITION(expr.id() == ID_nor);
2387 return static_cast<const nor_exprt &>(expr);
2388}
2389
2392{
2393 PRECONDITION(expr.id() == ID_nor);
2394 return static_cast<nor_exprt &>(expr);
2395}
2396
2401{
2402public:
2404 : multi_ary_exprt(std::move(_op0), ID_xor, std::move(_op1), bool_typet())
2405 {
2406 }
2407
2412};
2413
2414template <>
2415inline bool can_cast_expr<xor_exprt>(const exprt &base)
2416{
2417 return base.id() == ID_xor;
2418}
2419
2426inline const xor_exprt &to_xor_expr(const exprt &expr)
2427{
2428 PRECONDITION(expr.id()==ID_xor);
2429 return static_cast<const xor_exprt &>(expr);
2430}
2431
2434{
2435 PRECONDITION(expr.id()==ID_xor);
2436 return static_cast<xor_exprt &>(expr);
2437}
2438
2445{
2446public:
2448 : multi_ary_exprt(std::move(_op0), ID_xnor, std::move(_op1), bool_typet())
2449 {
2450 }
2451
2456};
2457
2458template <>
2459inline bool can_cast_expr<xnor_exprt>(const exprt &base)
2460{
2461 return base.id() == ID_xnor;
2462}
2463
2470inline const xnor_exprt &to_xnor_expr(const exprt &expr)
2471{
2472 PRECONDITION(expr.id() == ID_xnor);
2473 return static_cast<const xnor_exprt &>(expr);
2474}
2475
2478{
2479 PRECONDITION(expr.id() == ID_xnor);
2480 return static_cast<xnor_exprt &>(expr);
2481}
2482
2485{
2486public:
2488 {
2489 PRECONDITION(as_const(*this).op().is_boolean());
2490 }
2491};
2492
2493template <>
2494inline bool can_cast_expr<not_exprt>(const exprt &base)
2495{
2496 return base.id() == ID_not;
2497}
2498
2499inline void validate_expr(const not_exprt &value)
2500{
2501 validate_operands(value, 1, "Not must have one operand");
2502}
2503
2510inline const not_exprt &to_not_expr(const exprt &expr)
2511{
2512 PRECONDITION(expr.id()==ID_not);
2513 not_exprt::check(expr);
2514 return static_cast<const not_exprt &>(expr);
2515}
2516
2519{
2520 PRECONDITION(expr.id()==ID_not);
2521 not_exprt::check(expr);
2522 return static_cast<not_exprt &>(expr);
2523}
2524
2525
2528{
2529public:
2531 : ternary_exprt(ID_if, std::move(cond), t, std::move(f), t.type())
2532 {
2533 }
2534
2536 : ternary_exprt(
2537 ID_if,
2538 std::move(cond),
2539 std::move(t),
2540 std::move(f),
2541 std::move(type))
2542 {
2543 }
2544
2546 {
2547 return op0();
2548 }
2549
2550 const exprt &cond() const
2551 {
2552 return op0();
2553 }
2554
2556 {
2557 return op1();
2558 }
2559
2560 const exprt &true_case() const
2561 {
2562 return op1();
2563 }
2564
2566 {
2567 return op2();
2568 }
2569
2570 const exprt &false_case() const
2571 {
2572 return op2();
2573 }
2574
2575 static void check(
2576 const exprt &expr,
2578 {
2579 ternary_exprt::check(expr, vm);
2580 }
2581
2582 static void validate(
2583 const exprt &expr,
2584 const namespacet &ns,
2586 {
2587 ternary_exprt::validate(expr, ns, vm);
2588 }
2589};
2590
2591template <>
2592inline bool can_cast_expr<if_exprt>(const exprt &base)
2593{
2594 return base.id() == ID_if;
2595}
2596
2597inline void validate_expr(const if_exprt &value)
2598{
2599 validate_operands(value, 3, "If-then-else must have three operands");
2600}
2601
2608inline const if_exprt &to_if_expr(const exprt &expr)
2609{
2610 PRECONDITION(expr.id()==ID_if);
2611 const if_exprt &ret = static_cast<const if_exprt &>(expr);
2613 return ret;
2614}
2615
2618{
2619 PRECONDITION(expr.id()==ID_if);
2620 if_exprt &ret = static_cast<if_exprt &>(expr);
2622 return ret;
2623}
2624
2629{
2630public:
2633 ID_with,
2634 _old.type(),
2635 {_old, std::move(_where), std::move(_new_value)})
2636 {
2637 }
2638
2640 {
2641 return op0();
2642 }
2643
2644 const exprt &old() const
2645 {
2646 return op0();
2647 }
2648
2650 {
2651 return op1();
2652 }
2653
2654 const exprt &where() const
2655 {
2656 return op1();
2657 }
2658
2660 {
2661 return op2();
2662 }
2663
2664 const exprt &new_value() const
2665 {
2666 return op2();
2667 }
2668};
2669
2670template <>
2671inline bool can_cast_expr<with_exprt>(const exprt &base)
2672{
2673 return base.id() == ID_with;
2674}
2675
2676inline void validate_expr(const with_exprt &value)
2677{
2678 validate_operands(value, 3, "array/structure update must have 3 operands");
2679}
2680
2687inline const with_exprt &to_with_expr(const exprt &expr)
2688{
2689 PRECONDITION(expr.id()==ID_with);
2690 const with_exprt &ret = static_cast<const with_exprt &>(expr);
2692 return ret;
2693}
2694
2697{
2698 PRECONDITION(expr.id()==ID_with);
2699 with_exprt &ret = static_cast<with_exprt &>(expr);
2701 return ret;
2702}
2703
2705{
2706public:
2709 {
2710 }
2711
2712 const exprt &index() const
2713 {
2714 return op0();
2715 }
2716
2718 {
2719 return op0();
2720 }
2721};
2722
2723template <>
2725{
2726 return base.id() == ID_index_designator;
2727}
2728
2729inline void validate_expr(const index_designatort &value)
2730{
2731 validate_operands(value, 1, "Index designator must have one operand");
2732}
2733
2741{
2743 const index_designatort &ret = static_cast<const index_designatort &>(expr);
2745 return ret;
2746}
2747
2750{
2752 index_designatort &ret = static_cast<index_designatort &>(expr);
2754 return ret;
2755}
2756
2758{
2759public:
2765
2767 {
2768 return get(ID_component_name);
2769 }
2770};
2771
2772template <>
2774{
2775 return base.id() == ID_member_designator;
2776}
2777
2778inline void validate_expr(const member_designatort &value)
2779{
2780 validate_operands(value, 0, "Member designator must not have operands");
2781}
2782
2790{
2792 const member_designatort &ret = static_cast<const member_designatort &>(expr);
2794 return ret;
2795}
2796
2799{
2801 member_designatort &ret = static_cast<member_designatort &>(expr);
2803 return ret;
2804}
2805
2806
2809{
2810public:
2812 : ternary_exprt(
2813 ID_update,
2814 _old,
2815 std::move(_designator),
2816 std::move(_new_value),
2817 _old.type())
2818 {
2819 }
2820
2822 {
2823 return op0();
2824 }
2825
2826 const exprt &old() const
2827 {
2828 return op0();
2829 }
2830
2831 // the designator operands are either
2832 // 1) member_designator or
2833 // 2) index_designator
2834 // as defined above
2836 {
2837 return op1().operands();
2838 }
2839
2841 {
2842 return op1().operands();
2843 }
2844
2846 {
2847 return op2();
2848 }
2849
2850 const exprt &new_value() const
2851 {
2852 return op2();
2853 }
2854
2856 with_exprt make_with_expr() const;
2857
2858 static void check(
2859 const exprt &expr,
2861 {
2862 ternary_exprt::check(expr, vm);
2863 }
2864
2865 static void validate(
2866 const exprt &expr,
2867 const namespacet &ns,
2869 {
2870 ternary_exprt::validate(expr, ns, vm);
2871 }
2872};
2873
2874template <>
2875inline bool can_cast_expr<update_exprt>(const exprt &base)
2876{
2877 return base.id() == ID_update;
2878}
2879
2880inline void validate_expr(const update_exprt &value)
2881{
2883 value, 3, "Array/structure update must have three operands");
2884}
2885
2892inline const update_exprt &to_update_expr(const exprt &expr)
2893{
2894 PRECONDITION(expr.id()==ID_update);
2895 const update_exprt &ret = static_cast<const update_exprt &>(expr);
2897 return ret;
2898}
2899
2902{
2903 PRECONDITION(expr.id()==ID_update);
2904 update_exprt &ret = static_cast<update_exprt &>(expr);
2906 return ret;
2907}
2908
2909
2910#if 0
2913{
2914public:
2916 const exprt &_array,
2917 const exprt &_index,
2918 const exprt &_new_value):
2920 {
2921 add_to_operands(_array, _index, _new_value);
2922 }
2923
2925 {
2926 operands().resize(3);
2927 }
2928
2929 exprt &array()
2930 {
2931 return op0();
2932 }
2933
2934 const exprt &array() const
2935 {
2936 return op0();
2937 }
2938
2939 exprt &index()
2940 {
2941 return op1();
2942 }
2943
2944 const exprt &index() const
2945 {
2946 return op1();
2947 }
2948
2949 exprt &new_value()
2950 {
2951 return op2();
2952 }
2953
2954 const exprt &new_value() const
2955 {
2956 return op2();
2957 }
2958};
2959
2960template<> inline bool can_cast_expr<array_update_exprt>(const exprt &base)
2961{
2962 return base.id()==ID_array_update;
2963}
2964
2965inline void validate_expr(const array_update_exprt &value)
2966{
2967 validate_operands(value, 3, "Array update must have three operands");
2968}
2969
2976inline const array_update_exprt &to_array_update_expr(const exprt &expr)
2977{
2979 const array_update_exprt &ret = static_cast<const array_update_exprt &>(expr);
2981 return ret;
2982}
2983
2986{
2988 array_update_exprt &ret = static_cast<array_update_exprt &>(expr);
2990 return ret;
2991}
2992
2993#endif
2994
2995
2998{
2999public:
3000 member_exprt(exprt op, const irep_idt &component_name, typet _type)
3001 : unary_exprt(ID_member, std::move(op), std::move(_type))
3002 {
3003 const auto &compound_type_id = compound().type().id();
3007 set_component_name(component_name);
3008 }
3009
3019
3021 {
3022 return get(ID_component_name);
3023 }
3024
3025 void set_component_name(const irep_idt &component_name)
3026 {
3027 set(ID_component_name, component_name);
3028 }
3029
3030 std::size_t get_component_number() const
3031 {
3033 }
3034
3035 // will go away, use compound()
3036 const exprt &struct_op() const
3037 {
3038 return op0();
3039 }
3040
3041 // will go away, use compound()
3043 {
3044 return op0();
3045 }
3046
3047 const exprt &compound() const
3048 {
3049 return op0();
3050 }
3051
3053 {
3054 return op0();
3055 }
3056
3057 static void check(
3058 const exprt &expr,
3060 {
3061 DATA_CHECK(
3062 vm,
3063 expr.operands().size() == 1,
3064 "member expression must have one operand");
3065 }
3066
3067 static void validate(
3068 const exprt &expr,
3069 const namespacet &ns,
3071};
3072
3073template <>
3074inline bool can_cast_expr<member_exprt>(const exprt &base)
3075{
3076 return base.id() == ID_member;
3077}
3078
3079inline void validate_expr(const member_exprt &value)
3080{
3081 validate_operands(value, 1, "Extract member must have one operand");
3082}
3083
3090inline const member_exprt &to_member_expr(const exprt &expr)
3091{
3092 PRECONDITION(expr.id()==ID_member);
3093 member_exprt::check(expr);
3094 return static_cast<const member_exprt &>(expr);
3095}
3096
3099{
3100 PRECONDITION(expr.id()==ID_member);
3101 member_exprt::check(expr);
3102 return static_cast<member_exprt &>(expr);
3103}
3104
3105
3108{
3109public:
3111 {
3112 }
3113};
3114
3115template <>
3116inline bool can_cast_expr<type_exprt>(const exprt &base)
3117{
3118 return base.id() == ID_type;
3119}
3120
3127inline const type_exprt &to_type_expr(const exprt &expr)
3128{
3130 type_exprt::check(expr);
3131 return static_cast<const type_exprt &>(expr);
3132}
3133
3136{
3138 type_exprt::check(expr);
3139 return static_cast<type_exprt &>(expr);
3140}
3141
3144{
3145public:
3146 constant_exprt(const irep_idt &_value, typet _type)
3147 : nullary_exprt(ID_constant, std::move(_type))
3148 {
3149 set_value(_value);
3150 }
3151
3152 const irep_idt &get_value() const
3153 {
3154 return get(ID_value);
3155 }
3156
3157 void set_value(const irep_idt &value)
3158 {
3159 set(ID_value, value);
3160 }
3161
3165 bool is_null_pointer() const;
3166
3167 using irept::operator==;
3168 using irept::operator!=;
3170 bool operator==(bool rhs) const;
3172 bool operator!=(bool rhs) const;
3174 bool operator==(int rhs) const;
3176 bool operator!=(int rhs) const;
3178 bool operator==(std::nullptr_t) const;
3180 bool operator!=(std::nullptr_t) const;
3181
3182 static void check(
3183 const exprt &expr,
3185
3186 static void validate(
3187 const exprt &expr,
3188 const namespacet &,
3190 {
3191 check(expr, vm);
3192 }
3193
3194protected:
3195 bool value_is_zero_string() const;
3196};
3197
3198template <>
3199inline bool can_cast_expr<constant_exprt>(const exprt &base)
3200{
3201 return base.is_constant();
3202}
3203
3204inline void validate_expr(const constant_exprt &value)
3205{
3206 validate_operands(value, 0, "Constants must not have operands");
3207}
3208
3215inline const constant_exprt &to_constant_expr(const exprt &expr)
3216{
3217 PRECONDITION(expr.is_constant());
3219 return static_cast<const constant_exprt &>(expr);
3220}
3221
3224{
3225 PRECONDITION(expr.is_constant());
3227 return static_cast<constant_exprt &>(expr);
3228}
3229
3232bool operator==(const exprt &lhs, bool rhs);
3233
3236bool operator!=(const exprt &lhs, bool rhs);
3237
3249bool operator==(const exprt &lhs, int rhs);
3250
3252bool operator!=(const exprt &lhs, int rhs);
3253
3256bool operator==(const exprt &lhs, std::nullptr_t);
3257
3259bool operator!=(const exprt &lhs, std::nullptr_t);
3260
3263{
3264public:
3268};
3269
3272{
3273public:
3277};
3278
3281{
3282public:
3287};
3288
3289template <>
3290inline bool can_cast_expr<nil_exprt>(const exprt &base)
3291{
3292 return base.id() == ID_nil;
3293}
3294
3297{
3298public:
3299 explicit infinity_exprt(typet _type)
3300 : nullary_exprt(ID_infinity, std::move(_type))
3301 {
3302 }
3303};
3304
3307{
3308public:
3309 using variablest = std::vector<symbol_exprt>;
3310
3313 irep_idt _id,
3314 const variablest &_variables,
3315 exprt _where,
3316 typet _type)
3317 : binary_exprt(
3319 ID_tuple,
3321 typet(ID_tuple)),
3322 _id,
3323 std::move(_where),
3324 std::move(_type))
3325 {
3326 }
3327
3329 {
3330 return (variablest &)to_multi_ary_expr(op0()).operands();
3331 }
3332
3333 const variablest &variables() const
3334 {
3335 return (variablest &)to_multi_ary_expr(op0()).operands();
3336 }
3337
3339 {
3340 return op1();
3341 }
3342
3343 const exprt &where() const
3344 {
3345 return op1();
3346 }
3347
3350 exprt instantiate(const exprt::operandst &) const;
3351
3354 exprt instantiate(const variablest &) const;
3355};
3356
3357template <>
3358inline bool can_cast_expr<binding_exprt>(const exprt &base)
3359{
3360 return base.id() == ID_forall || base.id() == ID_exists ||
3361 base.id() == ID_lambda || base.id() == ID_array_comprehension;
3362}
3363
3365{
3367 binding_expr, 2, "Binding expressions must have two operands");
3368}
3369
3376inline const binding_exprt &to_binding_expr(const exprt &expr)
3377{
3379 expr.id() == ID_forall || expr.id() == ID_exists ||
3380 expr.id() == ID_lambda || expr.id() == ID_array_comprehension);
3381 const binding_exprt &ret = static_cast<const binding_exprt &>(expr);
3383 return ret;
3384}
3385
3393{
3395 expr.id() == ID_forall || expr.id() == ID_exists ||
3396 expr.id() == ID_lambda || expr.id() == ID_array_comprehension);
3397 binding_exprt &ret = static_cast<binding_exprt &>(expr);
3399 return ret;
3400}
3401
3404{
3405public:
3409 const exprt &where)
3410 : binary_exprt(
3413 std::move(variables),
3414 where,
3415 where.type()),
3416 ID_let,
3418 where.type())
3419 {
3420 PRECONDITION(this->variables().size() == this->values().size());
3421 }
3422
3425 : let_exprt(
3427 operandst{std::move(value)},
3428 where)
3429 {
3430 }
3431
3433 {
3434 return static_cast<binding_exprt &>(op0());
3435 }
3436
3437 const binding_exprt &binding() const
3438 {
3439 return static_cast<const binding_exprt &>(op0());
3440 }
3441
3444 {
3445 auto &variables = binding().variables();
3446 PRECONDITION(variables.size() == 1);
3447 return variables.front();
3448 }
3449
3451 const symbol_exprt &symbol() const
3452 {
3453 const auto &variables = binding().variables();
3454 PRECONDITION(variables.size() == 1);
3455 return variables.front();
3456 }
3457
3460 {
3461 auto &values = this->values();
3462 PRECONDITION(values.size() == 1);
3463 return values.front();
3464 }
3465
3467 const exprt &value() const
3468 {
3469 const auto &values = this->values();
3470 PRECONDITION(values.size() == 1);
3471 return values.front();
3472 }
3473
3475 {
3476 return static_cast<multi_ary_exprt &>(op1()).operands();
3477 }
3478
3479 const operandst &values() const
3480 {
3481 return static_cast<const multi_ary_exprt &>(op1()).operands();
3482 }
3483
3486 {
3487 return binding().variables();
3488 }
3489
3492 {
3493 return binding().variables();
3494 }
3495
3498 {
3499 return binding().where();
3500 }
3501
3503 const exprt &where() const
3504 {
3505 return binding().where();
3506 }
3507
3508 static void validate(const exprt &, validation_modet);
3509};
3510
3511template <>
3512inline bool can_cast_expr<let_exprt>(const exprt &base)
3513{
3514 return base.id() == ID_let;
3515}
3516
3518{
3519 validate_operands(let_expr, 2, "Let must have two operands");
3520}
3521
3528inline const let_exprt &to_let_expr(const exprt &expr)
3529{
3530 PRECONDITION(expr.id()==ID_let);
3531 const let_exprt &ret = static_cast<const let_exprt &>(expr);
3533 return ret;
3534}
3535
3538{
3539 PRECONDITION(expr.id()==ID_let);
3540 let_exprt &ret = static_cast<let_exprt &>(expr);
3542 return ret;
3543}
3544
3545
3550{
3551public:
3553 : multi_ary_exprt(ID_cond, std::move(_operands), std::move(_type))
3554 {
3555 }
3556
3560 void add_case(const exprt &condition, const exprt &value)
3561 {
3562 PRECONDITION(condition.is_boolean());
3563 operands().reserve(operands().size() + 2);
3564 operands().push_back(condition);
3565 operands().push_back(value);
3566 }
3567
3568 // a lowering to nested if_exprt
3569 exprt lower() const;
3570};
3571
3572template <>
3573inline bool can_cast_expr<cond_exprt>(const exprt &base)
3574{
3575 return base.id() == ID_cond;
3576}
3577
3578inline void validate_expr(const cond_exprt &value)
3579{
3581 value.operands().size() % 2 == 0, "cond must have even number of operands");
3582}
3583
3590inline const cond_exprt &to_cond_expr(const exprt &expr)
3591{
3592 PRECONDITION(expr.id() == ID_cond);
3593 const cond_exprt &ret = static_cast<const cond_exprt &>(expr);
3595 return ret;
3596}
3597
3600{
3601 PRECONDITION(expr.id() == ID_cond);
3602 cond_exprt &ret = static_cast<cond_exprt &>(expr);
3604 return ret;
3605}
3606
3612{
3613public:
3615 : multi_ary_exprt(ID_case, std::move(_operands), std::move(_type))
3616 {
3617 }
3618
3621 : multi_ary_exprt(ID_case, {std::move(_select_value)}, std::move(_type))
3622 {
3623 }
3624
3626 const exprt &select_value() const
3627 {
3628 PRECONDITION(!operands().empty());
3629 return operands()[0];
3630 }
3631
3634 {
3635 PRECONDITION(!operands().empty());
3636 return operands()[0];
3637 }
3638
3644 {
3645 operands().reserve(operands().size() + 2);
3646 operands().push_back(case_value);
3647 operands().push_back(result_value);
3648 }
3649
3651 std::size_t number_of_cases() const
3652 {
3653 PRECONDITION(operands().size() >= 1);
3654 return (operands().size() - 1) / 2;
3655 }
3656
3658 const exprt &case_value(std::size_t i) const
3659 {
3661 return operands()[1 + 2 * i];
3662 }
3663
3665 exprt &case_value(std::size_t i)
3666 {
3668 return operands()[1 + 2 * i];
3669 }
3670
3672 const exprt &result_value(std::size_t i) const
3673 {
3675 return operands()[1 + 2 * i + 1];
3676 }
3677
3679 exprt &result_value(std::size_t i)
3680 {
3682 return operands()[1 + 2 * i + 1];
3683 }
3684
3685 static void validate_expr(const case_exprt &value)
3686 {
3688 value.operands().size() >= 1,
3689 "case expression must have at least one operand");
3691 value.operands().size() % 2 == 1,
3692 "case expression must have odd number of operands");
3693 }
3694};
3695
3696template <>
3697inline bool can_cast_expr<case_exprt>(const exprt &base)
3698{
3699 return base.id() == ID_case;
3700}
3701
3708inline const case_exprt &to_case_expr(const exprt &expr)
3709{
3710 PRECONDITION(expr.id() == ID_case);
3711 const case_exprt &ret = static_cast<const case_exprt &>(expr);
3713 return ret;
3714}
3715
3718{
3719 PRECONDITION(expr.id() == ID_case);
3720 case_exprt &ret = static_cast<case_exprt &>(expr);
3722 return ret;
3723}
3724
3734{
3735public:
3738 exprt body,
3739 array_typet _type)
3740 : binding_exprt(
3742 {std::move(arg)},
3743 std::move(body),
3744 std::move(_type))
3745 {
3746 }
3747
3748 const array_typet &type() const
3749 {
3750 return static_cast<const array_typet &>(binary_exprt::type());
3751 }
3752
3754 {
3755 return static_cast<array_typet &>(binary_exprt::type());
3756 }
3757
3758 const symbol_exprt &arg() const
3759 {
3760 auto &variables = this->variables();
3761 PRECONDITION(variables.size() == 1);
3762 return variables[0];
3763 }
3764
3766 {
3767 auto &variables = this->variables();
3768 PRECONDITION(variables.size() == 1);
3769 return variables[0];
3770 }
3771
3772 const exprt &body() const
3773 {
3774 return where();
3775 }
3776
3778 {
3779 return where();
3780 }
3781};
3782
3783template <>
3785{
3786 return base.id() == ID_array_comprehension;
3787}
3788
3790{
3791 validate_operands(value, 2, "'Array comprehension' must have two operands");
3792}
3793
3800inline const array_comprehension_exprt &
3802{
3805 static_cast<const array_comprehension_exprt &>(expr);
3807 return ret;
3808}
3809
3819
3820inline void validate_expr(const class class_method_descriptor_exprt &value);
3821
3824{
3825public:
3841 typet _type,
3845 : nullary_exprt(ID_virtual_function, std::move(_type))
3846 {
3849 set(ID_C_class, std::move(class_id));
3850 set(ID_C_base_name, std::move(base_method_name));
3851 set(ID_identifier, std::move(id));
3852 validate_expr(*this);
3853 }
3854
3862 {
3863 return get(ID_component_name);
3864 }
3865
3869 const irep_idt &class_id() const
3870 {
3871 return get(ID_C_class);
3872 }
3873
3877 {
3878 return get(ID_C_base_name);
3879 }
3880
3885 {
3886 return get(ID_identifier);
3887 }
3888};
3889
3890inline void validate_expr(const class class_method_descriptor_exprt &value)
3891{
3892 validate_operands(value, 0, "class method descriptor must not have operands");
3894 !value.mangled_method_name().empty(),
3895 "class method descriptor must have a mangled method name.");
3897 !value.class_id().empty(), "class method descriptor must have a class id.");
3899 !value.base_method_name().empty(),
3900 "class method descriptor must have a base method name.");
3902 value.get_identifier() == id2string(value.class_id()) + "." +
3904 "class method descriptor must have an identifier in the expected format.");
3905}
3906
3913inline const class_method_descriptor_exprt &
3915{
3918 return static_cast<const class_method_descriptor_exprt &>(expr);
3919}
3920
3921template <>
3923{
3924 return base.id() == ID_virtual_function;
3925}
3926
3933{
3934public:
3936 : binary_exprt(
3937 std::move(symbol),
3939 value, // not moved, for type
3940 value.type())
3941 {
3942 PRECONDITION(symbol.type() == type());
3943 }
3944
3945 const symbol_exprt &symbol() const
3946 {
3947 return static_cast<const symbol_exprt &>(op0());
3948 }
3949
3951 {
3952 return static_cast<symbol_exprt &>(op0());
3953 }
3954
3955 const exprt &value() const
3956 {
3957 return op1();
3958 }
3959
3961 {
3962 return op1();
3963 }
3964};
3965
3966template <>
3968{
3969 return base.id() == ID_named_term;
3970}
3971
3972inline void validate_expr(const named_term_exprt &value)
3973{
3974 validate_operands(value, 2, "'named term' must have two operands");
3975}
3976
3984{
3985 PRECONDITION(expr.id() == ID_named_term);
3986 const named_term_exprt &ret = static_cast<const named_term_exprt &>(expr);
3988 return ret;
3989}
3990
3993{
3994 PRECONDITION(expr.id() == ID_named_term);
3995 named_term_exprt &ret = static_cast<named_term_exprt &>(expr);
3997 return ret;
3998}
3999
4000#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:442
abs_exprt(exprt _op)
Definition std_expr.h:444
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:2144
and_exprt(exprt op0, exprt op1, exprt op2)
Definition std_expr.h:2151
and_exprt(exprt op0, exprt op1)
Definition std_expr.h:2146
and_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
Definition std_expr.h:2159
and_exprt(exprt::operandst _operands)
Definition std_expr.h:2167
Expression to define a mapping from an argument (index) to elements.
Definition std_expr.h:3734
const array_typet & type() const
Definition std_expr.h:3748
const symbol_exprt & arg() const
Definition std_expr.h:3758
const exprt & body() const
Definition std_expr.h:3772
array_typet & type()
Definition std_expr.h:3753
symbol_exprt & arg()
Definition std_expr.h:3765
array_comprehension_exprt(symbol_exprt arg, exprt body, array_typet _type)
Definition std_expr.h:3736
Array constructor from list of elements.
Definition std_expr.h:1639
array_exprt && with_source_location(const exprt &other) &&
Definition std_expr.h:1663
const array_typet & type() const
Definition std_expr.h:1646
array_exprt & with_source_location(const exprt &other) &
Definition std_expr.h:1656
array_exprt(operandst _operands, array_typet _type)
Definition std_expr.h:1641
array_typet & type()
Definition std_expr.h:1651
Array constructor from a list of index-element pairs Operands are index/value pairs,...
Definition std_expr.h:1699
void add(exprt index, exprt value)
add an index/value pair
Definition std_expr.h:1717
const array_typet & type() const
Definition std_expr.h:1706
array_list_exprt(operandst _operands, array_typet _type)
Definition std_expr.h:1701
array_typet & type()
Definition std_expr.h:1711
Array constructor from single element.
Definition std_expr.h:1576
array_typet & type()
Definition std_expr.h:1588
array_of_exprt(exprt _what, array_typet _type)
Definition std_expr.h:1578
const exprt & what() const
Definition std_expr.h:1598
const array_typet & type() const
Definition std_expr.h:1583
exprt & what()
Definition std_expr.h:1593
Arrays with given size.
Definition std_types.h:807
A base class for binary expressions.
Definition std_expr.h:638
exprt & lhs()
Definition std_expr.h:668
binary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:640
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:660
const exprt & op2() const =delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:650
exprt & rhs()
Definition std_expr.h:678
exprt & op0()
Definition expr.h:134
const exprt & lhs() const
Definition std_expr.h:673
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:645
const exprt & rhs() const
Definition std_expr.h:683
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:731
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:738
binary_predicate_exprt(exprt _op0, const irep_idt &_id, exprt _op1)
Definition std_expr.h:733
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:745
A base class for relations, i.e., binary predicates whose two operands have the same type.
Definition std_expr.h:762
binary_relation_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:764
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:769
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:776
A base class for variable bindings (quantifiers, let, lambda)
Definition std_expr.h:3307
const variablest & variables() const
Definition std_expr.h:3333
const exprt & where() const
Definition std_expr.h:3343
exprt & where()
Definition std_expr.h:3338
variablest & variables()
Definition std_expr.h:3328
binding_exprt(irep_idt _id, const variablest &_variables, exprt _where, typet _type)
construct the binding expression
Definition std_expr.h:3312
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:3309
The Boolean type.
Definition std_types.h:36
Case expression: evaluates to the value corresponding to the first matching case.
Definition std_expr.h:3612
exprt & result_value(std::size_t i)
Get the result value for the i-th case.
Definition std_expr.h:3679
void add_case(const exprt &case_value, const exprt &result_value)
Add a case: value to compare and corresponding result.
Definition std_expr.h:3643
static void validate_expr(const case_exprt &value)
Definition std_expr.h:3685
const exprt & case_value(std::size_t i) const
Get the case value for the i-th case.
Definition std_expr.h:3658
case_exprt(operandst _operands, typet _type)
Definition std_expr.h:3614
exprt & select_value()
Get the value that is being compared against.
Definition std_expr.h:3633
const exprt & result_value(std::size_t i) const
Get the result value for the i-th case.
Definition std_expr.h:3672
std::size_t number_of_cases() const
Get the number of cases (excluding the select value)
Definition std_expr.h:3651
case_exprt(exprt _select_value, typet _type)
Constructor with select value.
Definition std_expr.h:3620
exprt & case_value(std::size_t i)
Get the case value for the i-th case.
Definition std_expr.h:3665
const exprt & select_value() const
Get the value that is being compared against.
Definition std_expr.h:3626
An expression describing a method on a class.
Definition std_expr.h:3824
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:3876
const irep_idt & mangled_method_name() const
The method name after mangling it by combining it with the descriptor.
Definition std_expr.h:3861
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:3884
class_method_descriptor_exprt(typet _type, irep_idt mangled_method_name, irep_idt class_id, irep_idt base_method_name)
Definition std_expr.h:3840
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:3869
Complex constructor from a pair of numbers.
Definition std_expr.h:1934
complex_exprt(exprt _real, exprt _imag, complex_typet _type)
Definition std_expr.h:1936
exprt real()
Definition std_expr.h:1945
exprt imag()
Definition std_expr.h:1955
const exprt & real() const
Definition std_expr.h:1950
const exprt & imag() const
Definition std_expr.h:1960
Imaginary part of the expression describing a complex number.
Definition std_expr.h:2045
complex_imag_exprt(const exprt &op)
Definition std_expr.h:2047
Real part of the expression describing a complex number.
Definition std_expr.h:2002
complex_real_exprt(const exprt &op)
Definition std_expr.h:2004
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:3550
void add_case(const exprt &condition, const exprt &value)
adds a case to a cond expression
Definition std_expr.h:3560
cond_exprt(operandst _operands, typet _type)
Definition std_expr.h:3552
exprt lower() const
Definition std_expr.cpp:458
A constant literal expression.
Definition std_expr.h:3144
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:3186
const irep_idt & get_value() const
Definition std_expr.h:3152
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:3146
void set_value(const irep_idt &value)
Definition std_expr.h:3157
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:215
decorated_symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:219
bool is_static_lifetime() const
Definition std_expr.h:224
bool is_thread_local() const
Definition std_expr.h:239
Division.
Definition std_expr.h:1175
div_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1177
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1183
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1189
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1201
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1195
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:1852
empty_union_exprt(typet _type)
Definition std_expr.h:1854
Equality.
Definition std_expr.h:1384
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:1392
equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1386
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:1399
Boute's Euclidean definition of Modulo – to match SMT-LIB2.
Definition std_expr.h:1314
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1334
euclidean_mod_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1316
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1340
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1322
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1328
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:3272
Binary greater than operator expression.
Definition std_expr.h:807
greater_than_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:809
Binary greater than or equal operator expression.
Definition std_expr.h:828
greater_than_or_equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:830
The trinary if-then-else operator.
Definition std_expr.h:2528
const exprt & false_case() const
Definition std_expr.h:2570
exprt & cond()
Definition std_expr.h:2545
const exprt & cond() const
Definition std_expr.h:2550
if_exprt(exprt cond, const exprt &t, exprt f)
Definition std_expr.h:2530
const exprt & true_case() const
Definition std_expr.h:2560
exprt & false_case()
Definition std_expr.h:2565
if_exprt(exprt cond, exprt t, exprt f, typet type)
Definition std_expr.h:2535
exprt & true_case()
Definition std_expr.h:2555
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2575
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2582
Boolean implication.
Definition std_expr.h:2251
implies_exprt(exprt op0, exprt op1)
Definition std_expr.h:2253
const exprt & index() const
Definition std_expr.h:2712
index_designatort(exprt _index)
Definition std_expr.h:2707
exprt & index()
Definition std_expr.h:2717
Array index operator.
Definition std_expr.h:1488
exprt & index()
Definition std_expr.h:1528
index_exprt(exprt _array, exprt _index, typet _type)
Definition std_expr.h:1506
index_exprt(const exprt &_array, exprt _index)
Definition std_expr.h:1494
exprt & array()
Definition std_expr.h:1518
const exprt & index() const
Definition std_expr.h:1533
const exprt & array() const
Definition std_expr.h:1523
An expression denoting infinity.
Definition std_expr.h:3297
infinity_exprt(typet _type)
Definition std_expr.h:3299
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:849
less_than_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:851
Binary less than or equal operator expression.
Definition std_expr.h:870
less_than_or_equal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:872
A let expression.
Definition std_expr.h:3404
binding_exprt::variablest & variables()
convenience accessor for binding().variables()
Definition std_expr.h:3485
const binding_exprt & binding() const
Definition std_expr.h:3437
const binding_exprt::variablest & variables() const
convenience accessor for binding().variables()
Definition std_expr.h:3491
operandst & values()
Definition std_expr.h:3474
let_exprt(symbol_exprt symbol, exprt value, const exprt &where)
convenience constructor for the case of a single binding
Definition std_expr.h:3424
const exprt & where() const
convenience accessor for binding().where()
Definition std_expr.h:3503
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:3451
let_exprt(binding_exprt::variablest variables, operandst values, const exprt &where)
Definition std_expr.h:3406
exprt & value()
convenience accessor for the value of a single binding
Definition std_expr.h:3459
exprt & where()
convenience accessor for binding().where()
Definition std_expr.h:3497
binding_exprt & binding()
Definition std_expr.h:3432
const operandst & values() const
Definition std_expr.h:3479
const exprt & value() const
convenience accessor for the value of a single binding
Definition std_expr.h:3467
symbol_exprt & symbol()
convenience accessor for the symbol of a single binding
Definition std_expr.h:3443
irep_idt get_component_name() const
Definition std_expr.h:2766
member_designatort(const irep_idt &_component_name)
Definition std_expr.h:2760
Extract member of struct or union.
Definition std_expr.h:2998
const exprt & compound() const
Definition std_expr.h:3047
exprt & struct_op()
Definition std_expr.h:3042
const exprt & struct_op() const
Definition std_expr.h:3036
irep_idt get_component_name() const
Definition std_expr.h:3020
void set_component_name(const irep_idt &component_name)
Definition std_expr.h:3025
exprt & compound()
Definition std_expr.h:3052
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:3057
member_exprt(exprt op, const irep_idt &component_name, typet _type)
Definition std_expr.h:3000
std::size_t get_component_number() const
Definition std_expr.h:3030
member_exprt(exprt op, const struct_typet::componentt &c)
Definition std_expr.h:3010
Binary minus.
Definition std_expr.h:1074
minus_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1076
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Definition std_expr.h:1246
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition std_expr.h:1254
const exprt & dividend() const
The dividend of a division is the number that is being divided.
Definition std_expr.h:1260
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1266
const exprt & divisor() const
The divisor of a division is the number the dividend is being divided by.
Definition std_expr.h:1272
mod_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1248
Binary multiplication Associativity is not specified.
Definition std_expr.h:1120
mult_exprt(exprt::operandst factors, typet type)
Definition std_expr.h:1132
mult_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1122
mult_exprt(exprt::operandst factors)
Definition std_expr.h:1127
A base class for multi-ary expressions Associativity is not specified.
Definition std_expr.h:912
exprt & op1()
Definition std_expr.h:946
const exprt & op0() const
Definition std_expr.h:964
multi_ary_exprt(exprt _lhs, const irep_idt &_id, exprt _rhs, typet _type)
Definition std_expr.h:933
const exprt & op2() const
Definition std_expr.h:976
const exprt & op3() const
Definition std_expr.h:982
exprt & op0()
Definition std_expr.h:940
exprt & op2()
Definition std_expr.h:952
multi_ary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
Definition std_expr.h:928
multi_ary_exprt(const irep_idt &_id, operandst _operands, typet _type)
Definition std_expr.h:914
const exprt & op1() const
Definition std_expr.h:970
multi_ary_exprt(const irep_idt &_id, operandst _operands)
Definition std_expr.h:920
exprt & op3()
Definition std_expr.h:958
Expression that introduces a new symbol that is equal to the operand.
Definition std_expr.h:3933
named_term_exprt(symbol_exprt symbol, exprt value)
Definition std_expr.h:3935
symbol_exprt & symbol()
Definition std_expr.h:3950
const exprt & value() const
Definition std_expr.h:3955
const symbol_exprt & symbol() const
Definition std_expr.h:3945
exprt & value()
Definition std_expr.h:3960
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:2217
nand_exprt(exprt op0, exprt op1)
Definition std_expr.h:2219
nand_exprt(exprt::operandst _operands)
Definition std_expr.h:2224
The NIL expression.
Definition std_expr.h:3281
Expression to hold a nondeterministic choice.
Definition std_expr.h:292
void set_identifier(const irep_idt &identifier)
Definition std_expr.h:315
nondet_symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:296
const irep_idt & get_identifier() const
Definition std_expr.h:320
nondet_symbol_exprt(irep_idt identifier, typet type, source_locationt location)
Definition std_expr.h:305
Boolean NOR.
Definition std_expr.h:2365
nor_exprt(exprt op0, exprt op1)
Definition std_expr.h:2367
nor_exprt(exprt::operandst _operands)
Definition std_expr.h:2372
Boolean negation.
Definition std_expr.h:2485
not_exprt(exprt _op)
Definition std_expr.h:2487
Disequality.
Definition std_expr.h:1443
notequal_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1445
An expression without operands.
Definition std_expr.h:22
exprt & op0()=delete
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:29
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:39
const exprt & op1() const =delete
nullary_exprt(const irep_idt &_id, typet _type)
Definition std_expr.h:24
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:2297
or_exprt(exprt op0, exprt op1, exprt op2)
Definition std_expr.h:2304
or_exprt(exprt::operandst _operands)
Definition std_expr.h:2320
or_exprt(exprt op0, exprt op1, exprt op2, exprt op3)
Definition std_expr.h:2312
or_exprt(exprt op0, exprt op1)
Definition std_expr.h:2299
The plus expression Associativity is not specified.
Definition std_expr.h:1010
plus_exprt(exprt _lhs, exprt _rhs, typet _type)
Definition std_expr.h:1017
plus_exprt(exprt _lhs, exprt _rhs)
Definition std_expr.h:1012
plus_exprt(operandst _operands, typet _type)
Definition std_expr.h:1031
plus_exprt(operandst _operands)
Definition std_expr.h:1026
A base class for expressions that are predicates, i.e., Boolean-typed.
Definition std_expr.h:574
predicate_exprt(const irep_idt &_id)
Definition std_expr.h:576
Sign of an expression Predicate is true if _op is negative, false otherwise.
Definition std_expr.h:596
sign_exprt(exprt _op)
Definition std_expr.h:598
Struct constructor from list of elements.
Definition std_expr.h:1895
exprt & component(const irep_idt &name, const namespacet &ns)
Definition std_expr.cpp:308
struct_exprt(operandst _operands, typet _type)
Definition std_expr.h:1897
Expression to hold a symbol (variable)
Definition std_expr.h:131
void set_identifier(const irep_idt &identifier)
Definition std_expr.h:155
static symbol_exprt typeless(const irep_idt &id)
Generate a symbol_exprt without a proper type.
Definition std_expr.h:150
symbol_exprt & with_source_location(const exprt &other) &
Add the source location from other, if it has any.
Definition std_expr.h:182
symbol_exprt & with_source_location(source_locationt location) &
Add the source location from location, if it is non-nil.
Definition std_expr.h:166
symbol_exprt && with_source_location(source_locationt location) &&
Add the source location from location, if it is non-nil.
Definition std_expr.h:174
symbol_exprt && with_source_location(const exprt &other) &&
Add the source location from other, if it has any.
Definition std_expr.h:190
symbol_exprt(typet type)
Definition std_expr.h:134
symbol_exprt(const irep_idt &identifier, typet type)
Definition std_expr.h:140
const irep_idt & get_identifier() const
Definition std_expr.h:160
An expression with three operands.
Definition std_expr.h:67
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:101
ternary_exprt(const irep_idt &_id, exprt _op0, exprt _op1, exprt _op2, typet _type)
Definition std_expr.h:70
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:91
The Boolean constant true.
Definition std_expr.h:3263
An expression denoting a type.
Definition std_expr.h:3108
type_exprt(typet type)
Definition std_expr.h:3110
Semantic type conversion.
Definition std_expr.h:2091
static exprt conditional_cast(const exprt &expr, const typet &type)
Definition std_expr.h:2099
typecast_exprt(exprt op, typet _type)
Definition std_expr.h:2093
The type of an expression, extends irept.
Definition type.h:29
Generic base class for unary expressions.
Definition std_expr.h:361
unary_exprt(const irep_idt &_id, const exprt &_op)
Definition std_expr.h:363
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:373
const exprt & op1() const =delete
exprt & op3()=delete
const exprt & op() const
Definition std_expr.h:391
unary_exprt(const irep_idt &_id, exprt _op, typet _type)
Definition std_expr.h:368
const exprt & op2() const =delete
exprt & op()
Definition std_expr.h:396
static void validate(const exprt &expr, const namespacet &, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:383
exprt & op1()=delete
The unary minus expression.
Definition std_expr.h:484
unary_minus_exprt(exprt _op)
Definition std_expr.h:491
unary_minus_exprt(exprt _op, typet _type)
Definition std_expr.h:486
The unary plus expression.
Definition std_expr.h:531
unary_plus_exprt(exprt op)
Definition std_expr.h:533
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly one argu...
Definition std_expr.h:585
unary_predicate_exprt(const irep_idt &_id, exprt _op)
Definition std_expr.h:587
Union constructor from single element.
Definition std_expr.h:1788
std::size_t get_component_number() const
Definition std_expr.h:1806
void set_component_number(std::size_t component_number)
Definition std_expr.h:1811
void set_component_name(const irep_idt &component_name)
Definition std_expr.h:1801
irep_idt get_component_name() const
Definition std_expr.h:1796
union_exprt(const irep_idt &_component_name, exprt _value, typet _type)
Definition std_expr.h:1790
Operator to update elements in structs and arrays.
Definition std_expr.h:2809
exprt & old()
Definition std_expr.h:2821
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:2835
exprt & new_value()
Definition std_expr.h:2845
static void validate(const exprt &expr, const namespacet &ns, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2865
const exprt & new_value() const
Definition std_expr.h:2850
update_exprt(const exprt &_old, exprt _designator, exprt _new_value)
Definition std_expr.h:2811
static void check(const exprt &expr, const validation_modet vm=validation_modet::INVARIANT)
Definition std_expr.h:2858
const exprt & old() const
Definition std_expr.h:2826
const exprt::operandst & designator() const
Definition std_expr.h:2840
Vector constructor from list of elements.
Definition std_expr.h:1752
vector_exprt(operandst _operands, vector_typet _type)
Definition std_expr.h:1754
The vector type.
Definition std_types.h:1064
Operator to update elements in structs and arrays.
Definition std_expr.h:2629
const exprt & old() const
Definition std_expr.h:2644
const exprt & where() const
Definition std_expr.h:2654
exprt & new_value()
Definition std_expr.h:2659
exprt & where()
Definition std_expr.h:2649
with_exprt(const exprt &_old, exprt _where, exprt _new_value)
Definition std_expr.h:2631
const exprt & new_value() const
Definition std_expr.h:2664
exprt & old()
Definition std_expr.h:2639
Boolean XNOR.
Definition std_expr.h:2445
xnor_exprt(exprt::operandst _operands)
Definition std_expr.h:2452
xnor_exprt(exprt _op0, exprt _op1)
Definition std_expr.h:2447
Boolean XOR All operands must be boolean, and the result is always boolean.
Definition std_expr.h:2401
xor_exprt(exprt _op0, exprt _op1)
Definition std_expr.h:2403
xor_exprt(exprt::operandst _operands)
Definition std_expr.h:2408
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:1409
bool can_cast_expr< notequal_exprt >(const exprt &base)
Definition std_expr.h:1452
bool can_cast_expr< complex_exprt >(const exprt &base)
Definition std_expr.h:1967
bool can_cast_expr< not_exprt >(const exprt &base)
Definition std_expr.h:2494
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
Definition std_expr.h:1918
const array_list_exprt & to_array_list_expr(const exprt &expr)
Definition std_expr.h:1734
bool can_cast_expr< typecast_exprt >(const exprt &base)
Definition std_expr.h:2109
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:3127
const array_of_exprt & to_array_of_expr(const exprt &expr)
Cast an exprt to an array_of_exprt.
Definition std_expr.h:1621
bool can_cast_expr< struct_exprt >(const exprt &base)
Definition std_expr.h:1907
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
Definition std_expr.h:895
const unary_plus_exprt & to_unary_plus_expr(const exprt &expr)
Cast an exprt to a unary_plus_exprt.
Definition std_expr.h:556
bool can_cast_expr< xor_exprt >(const exprt &base)
Definition std_expr.h:2415
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition std_expr.h:1556
bool can_cast_expr< mult_exprt >(const exprt &base)
Definition std_expr.h:1139
bool can_cast_expr< if_exprt >(const exprt &base)
Definition std_expr.h:2592
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:3914
bool can_cast_expr< named_term_exprt >(const exprt &base)
Definition std_expr.h:3967
bool can_cast_expr< binding_exprt >(const exprt &base)
Definition std_expr.h:3358
const mod_exprt & to_mod_expr(const exprt &expr)
Cast an exprt to a mod_exprt.
Definition std_expr.h:1295
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
Definition std_expr.h:1155
const and_exprt & to_and_expr(const exprt &expr)
Cast an exprt to a and_exprt.
Definition std_expr.h:2196
bool can_cast_expr< member_designatort >(const exprt &base)
Definition std_expr.h:2773
const array_comprehension_exprt & to_array_comprehension_expr(const exprt &expr)
Cast an exprt to a array_comprehension_exprt.
Definition std_expr.h:3801
const ternary_exprt & to_ternary_expr(const exprt &expr)
Cast an exprt to a ternary_exprt.
Definition std_expr.h:116
const named_term_exprt & to_named_term_expr(const exprt &expr)
Cast an exprt to a named_term_exprt.
Definition std_expr.h:3983
const xnor_exprt & to_xnor_expr(const exprt &expr)
Cast an exprt to a xnor_exprt.
Definition std_expr.h:2470
bool can_cast_expr< xnor_exprt >(const exprt &base)
Definition std_expr.h:2459
bool can_cast_expr< array_comprehension_exprt >(const exprt &base)
Definition std_expr.h:3784
const xor_exprt & to_xor_expr(const exprt &expr)
Cast an exprt to a xor_exprt.
Definition std_expr.h:2426
const or_exprt & to_or_expr(const exprt &expr)
Cast an exprt to a or_exprt.
Definition std_expr.h:2344
const array_exprt & to_array_expr(const exprt &expr)
Cast an exprt to an array_exprt.
Definition std_expr.h:1683
bool can_cast_expr< complex_imag_exprt >(const exprt &base)
Definition std_expr.h:2054
bool can_cast_expr< abs_exprt >(const exprt &base)
Definition std_expr.h:450
bool can_cast_expr< sign_exprt >(const exprt &base)
Definition std_expr.h:605
const cond_exprt & to_cond_expr(const exprt &expr)
Cast an exprt to a cond_exprt.
Definition std_expr.h:3590
bool can_cast_expr< type_exprt >(const exprt &base)
Definition std_expr.h:3116
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:3922
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition std_expr.h:2125
void validate_expr(const symbol_exprt &value)
Definition std_expr.h:261
const div_exprt & to_div_expr(const exprt &expr)
Cast an exprt to a div_exprt.
Definition std_expr.h:1224
bool can_cast_expr< unary_minus_exprt >(const exprt &base)
Definition std_expr.h:498
bool can_cast_expr< less_than_exprt >(const exprt &base)
Definition std_expr.h:858
bool can_cast_expr< with_exprt >(const exprt &base)
Definition std_expr.h:2671
const vector_exprt & to_vector_expr(const exprt &expr)
Cast an exprt to an vector_exprt.
Definition std_expr.h:1772
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:1083
bool can_cast_expr< let_exprt >(const exprt &base)
Definition std_expr.h:3512
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition std_expr.h:715
const plus_exprt & to_plus_expr(const exprt &expr)
Cast an exprt to a plus_exprt.
Definition std_expr.h:1054
const notequal_exprt & to_notequal_expr(const exprt &expr)
Cast an exprt to an notequal_exprt.
Definition std_expr.h:1468
bool can_cast_expr< plus_exprt >(const exprt &base)
Definition std_expr.h:1038
const nand_exprt & to_nand_expr(const exprt &expr)
Cast an exprt to a nand_exprt.
Definition std_expr.h:2236
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
Definition std_expr.h:426
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
Definition std_expr.h:995
bool can_cast_expr< array_of_exprt >(const exprt &base)
Definition std_expr.h:1605
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
Definition std_expr.h:3528
const abs_exprt & to_abs_expr(const exprt &expr)
Cast an exprt to a abs_exprt.
Definition std_expr.h:466
bool can_cast_expr< nondet_symbol_exprt >(const exprt &base)
Definition std_expr.h:327
bool can_cast_expr< case_exprt >(const exprt &base)
Definition std_expr.h:3697
bool can_cast_expr< constant_exprt >(const exprt &base)
Definition std_expr.h:3199
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Definition std_expr.h:2608
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition std_expr.h:3090
bool can_cast_expr< index_exprt >(const exprt &base)
Definition std_expr.h:1540
bool can_cast_expr< symbol_exprt >(const exprt &base)
Definition std_expr.h:256
const empty_union_exprt & to_empty_union_expr(const exprt &expr)
Cast an exprt to an empty_union_exprt.
Definition std_expr.h:1878
const minus_exprt & to_minus_expr(const exprt &expr)
Cast an exprt to a minus_exprt.
Definition std_expr.h:1099
bool can_cast_expr< member_exprt >(const exprt &base)
Definition std_expr.h:3074
bool can_cast_expr< empty_union_exprt >(const exprt &base)
Definition std_expr.h:1861
const complex_imag_exprt & to_complex_imag_expr(const exprt &expr)
Cast an exprt to a complex_imag_exprt.
Definition std_expr.h:2071
const binding_exprt & to_binding_expr(const exprt &expr)
Cast an exprt to a binding_exprt.
Definition std_expr.h:3376
bool can_cast_expr< or_exprt >(const exprt &base)
Definition std_expr.h:2333
bool can_cast_expr< mod_exprt >(const exprt &base)
Definition std_expr.h:1279
const index_designatort & to_index_designator(const exprt &expr)
Cast an exprt to an index_designatort.
Definition std_expr.h:2740
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
Definition std_expr.h:1834
bool can_cast_expr< cond_exprt >(const exprt &base)
Definition std_expr.h:3573
const complex_real_exprt & to_complex_real_expr(const exprt &expr)
Cast an exprt to a complex_real_exprt.
Definition std_expr.h:2028
bool can_cast_expr< update_exprt >(const exprt &base)
Definition std_expr.h:2875
bool can_cast_expr< binary_relation_exprt >(const exprt &base)
Definition std_expr.h:795
bool can_cast_expr< euclidean_mod_exprt >(const exprt &base)
Definition std_expr.h:1347
bool can_cast_expr< vector_exprt >(const exprt &base)
Definition std_expr.h:1761
const case_exprt & to_case_expr(const exprt &expr)
Cast an exprt to a case_exprt.
Definition std_expr.h:3708
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition std_expr.h:3215
bool can_cast_expr< array_list_exprt >(const exprt &base)
Definition std_expr.h:1724
bool can_cast_expr< index_designatort >(const exprt &base)
Definition std_expr.h:2724
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition std_expr.h:2510
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition std_expr.h:272
const with_exprt & to_with_expr(const exprt &expr)
Cast an exprt to a with_exprt.
Definition std_expr.h:2687
const complex_exprt & to_complex_expr(const exprt &expr)
Cast an exprt to a complex_exprt.
Definition std_expr.h:1983
bool can_cast_expr< unary_plus_exprt >(const exprt &base)
Definition std_expr.h:540
bool can_cast_expr< and_exprt >(const exprt &base)
Definition std_expr.h:2185
bool can_cast_expr< greater_than_exprt >(const exprt &base)
Definition std_expr.h:816
const implies_exprt & to_implies_expr(const exprt &expr)
Cast an exprt to a implies_exprt.
Definition std_expr.h:2276
bool can_cast_expr< array_exprt >(const exprt &base)
Definition std_expr.h:1672
bool can_cast_expr< binary_exprt >(const exprt &base)
Definition std_expr.h:699
bool can_cast_expr< div_exprt >(const exprt &base)
Definition std_expr.h:1208
const update_exprt & to_update_expr(const exprt &expr)
Cast an exprt to an update_exprt.
Definition std_expr.h:2892
bool can_cast_expr< nil_exprt >(const exprt &base)
Definition std_expr.h:3290
const unary_minus_exprt & to_unary_minus_expr(const exprt &expr)
Cast an exprt to a unary_minus_exprt.
Definition std_expr.h:514
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
Definition std_expr.h:1425
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:837
bool can_cast_expr< implies_exprt >(const exprt &base)
Definition std_expr.h:2260
bool can_cast_expr< unary_exprt >(const exprt &base)
Definition std_expr.h:410
bool can_cast_expr< less_than_or_equal_exprt >(const exprt &base)
Definition std_expr.h:879
const nondet_symbol_exprt & to_nondet_symbol_expr(const exprt &expr)
Cast an exprt to a nondet_symbol_exprt.
Definition std_expr.h:343
bool can_cast_expr< union_exprt >(const exprt &base)
Definition std_expr.h:1818
const member_designatort & to_member_designator(const exprt &expr)
Cast an exprt to an member_designatort.
Definition std_expr.h:2789
bool can_cast_expr< complex_real_exprt >(const exprt &base)
Definition std_expr.h:2011
const sign_exprt & to_sign_expr(const exprt &expr)
Cast an exprt to a sign_exprt.
Definition std_expr.h:621
const nor_exprt & to_nor_expr(const exprt &expr)
Cast an exprt to a nor_exprt.
Definition std_expr.h:2384
const euclidean_mod_exprt & to_euclidean_mod_expr(const exprt &expr)
Cast an exprt to a euclidean_mod_exprt.
Definition std_expr.h:1363
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:205
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