@@ -2182,6 +2182,42 @@ inline and_exprt &to_and_expr(exprt &expr)
2182
2182
return static_cast <and_exprt &>(expr);
2183
2183
}
2184
2184
2185
+ // / \brief Boolean NAND
2186
+ // / When given one operand, this is equivalent to the negation.
2187
+ // / When given three or more operands, this is equivalent to the negation
2188
+ // / of the and expression with the same operands.
2189
+ class nand_exprt : public multi_ary_exprt
2190
+ {
2191
+ public:
2192
+ nand_exprt (exprt op0, exprt op1)
2193
+ : multi_ary_exprt(std::move(op0), ID_nand, std::move(op1), bool_typet())
2194
+ {
2195
+ }
2196
+
2197
+ explicit nand_exprt (exprt::operandst _operands)
2198
+ : multi_ary_exprt(ID_nand, std::move(_operands), bool_typet())
2199
+ {
2200
+ }
2201
+ };
2202
+
2203
+ // / \brief Cast an exprt to a \ref nand_exprt
2204
+ // /
2205
+ // / \a expr must be known to be \ref nand_exprt.
2206
+ // /
2207
+ // / \param expr: Source expression
2208
+ // / \return Object of type \ref nand_exprt
2209
+ inline const nand_exprt &to_nand_expr (const exprt &expr)
2210
+ {
2211
+ PRECONDITION (expr.id () == ID_nand);
2212
+ return static_cast <const nand_exprt &>(expr);
2213
+ }
2214
+
2215
+ // / \copydoc to_nand_expr(const exprt &)
2216
+ inline nand_exprt &to_nand_expr (exprt &expr)
2217
+ {
2218
+ PRECONDITION (expr.id () == ID_nand);
2219
+ return static_cast <nand_exprt &>(expr);
2220
+ }
2185
2221
2186
2222
// / \brief Boolean implication
2187
2223
class implies_exprt :public binary_exprt
@@ -2290,6 +2326,42 @@ inline or_exprt &to_or_expr(exprt &expr)
2290
2326
return static_cast <or_exprt &>(expr);
2291
2327
}
2292
2328
2329
+ // / \brief Boolean NOR
2330
+ // / When given one operand, this is equivalent to the negation.
2331
+ // / When given three or more operands, this is equivalent to the negation
2332
+ // / of the and expression with the same operands.
2333
+ class nor_exprt : public multi_ary_exprt
2334
+ {
2335
+ public:
2336
+ nor_exprt (exprt op0, exprt op1)
2337
+ : multi_ary_exprt(std::move(op0), ID_nor, std::move(op1), bool_typet())
2338
+ {
2339
+ }
2340
+
2341
+ explicit nor_exprt (exprt::operandst _operands)
2342
+ : multi_ary_exprt(ID_nor, std::move(_operands), bool_typet())
2343
+ {
2344
+ }
2345
+ };
2346
+
2347
+ // / \brief Cast an exprt to a \ref nor_exprt
2348
+ // /
2349
+ // / \a expr must be known to be \ref nor_exprt.
2350
+ // /
2351
+ // / \param expr: Source expression
2352
+ // / \return Object of type \ref nor_exprt
2353
+ inline const nor_exprt &to_nor_expr (const exprt &expr)
2354
+ {
2355
+ PRECONDITION (expr.id () == ID_nor);
2356
+ return static_cast <const nor_exprt &>(expr);
2357
+ }
2358
+
2359
+ // / \copydoc to_nor_expr(const exprt &)
2360
+ inline nor_exprt &to_nor_expr (exprt &expr)
2361
+ {
2362
+ PRECONDITION (expr.id () == ID_nor);
2363
+ return static_cast <nor_exprt &>(expr);
2364
+ }
2293
2365
2294
2366
// / \brief Boolean XOR
2295
2367
class xor_exprt :public multi_ary_exprt
@@ -2332,6 +2404,50 @@ inline xor_exprt &to_xor_expr(exprt &expr)
2332
2404
}
2333
2405
2334
2406
2407
+ // / \brief Boolean XNOR
2408
+ // / When given one operand, this is equivalent to the negation.
2409
+ // / When given three or more operands, this is equivalent to the negation
2410
+ // / of the xor expression with the same operands.
2411
+ class xnor_exprt :public multi_ary_exprt
2412
+ {
2413
+ public:
2414
+ xnor_exprt (exprt _op0, exprt _op1)
2415
+ : multi_ary_exprt(std::move(_op0), ID_xnor, std::move(_op1), bool_typet())
2416
+ {
2417
+ }
2418
+
2419
+ explicit xnor_exprt (exprt::operandst _operands)
2420
+ : multi_ary_exprt(ID_xnor, std::move(_operands), bool_typet())
2421
+ {
2422
+ }
2423
+ };
2424
+
2425
+ template <>
2426
+ inline bool can_cast_expr<xnor_exprt>(const exprt &base)
2427
+ {
2428
+ return base.id () == ID_xnor;
2429
+ }
2430
+
2431
+ // / \brief Cast an exprt to a \ref xnor_exprt
2432
+ // /
2433
+ // / \a expr must be known to be \ref xnor_exprt.
2434
+ // /
2435
+ // / \param expr: Source expression
2436
+ // / \return Object of type \ref xnor_exprt
2437
+ inline const xnor_exprt &to_xnor_expr (const exprt &expr)
2438
+ {
2439
+ PRECONDITION (expr.id ()==ID_xnor);
2440
+ return static_cast <const xnor_exprt &>(expr);
2441
+ }
2442
+
2443
+ // / \copydoc to_xnor_expr(const exprt &)
2444
+ inline xnor_exprt &to_xnor_expr (exprt &expr)
2445
+ {
2446
+ PRECONDITION (expr.id ()==ID_xnor);
2447
+ return static_cast <xnor_exprt &>(expr);
2448
+ }
2449
+
2450
+
2335
2451
// / \brief Boolean negation
2336
2452
class not_exprt :public unary_exprt
2337
2453
{
0 commit comments