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