@@ -450,7 +450,85 @@ exprt aval_bval(const bitnot_exprt &expr)
450450 return combine_aval_bval (aval, op_bval, lower_to_aval_bval (expr.type ()));
451451}
452452
453- exprt aval_bval_bitwise (const multi_ary_exprt &expr)
453+ exprt aval_bval_bitand (const bitand_exprt &expr)
454+ {
455+ auto &type = expr.type ();
456+ PRECONDITION (is_four_valued (type));
457+ PRECONDITION (!expr.operands ().empty ());
458+
459+ for (auto &op : expr.operands ())
460+ PRECONDITION (is_aval_bval (op));
461+
462+ // All result bits are computed bit-wise.
463+ // 0 is the dominating value.
464+ // Otherwise, any bit involving x/z is x.
465+
466+ // A bit is zero of both aval and bval bits are zero.
467+ exprt::operandst bit_is_zero_disjuncts;
468+
469+ for (auto &op : expr.operands ())
470+ bit_is_zero_disjuncts.push_back (
471+ bitand_exprt{bitnot_exprt{aval (op)}, bitnot_exprt{bval (op)}});
472+
473+ auto bit_is_zero =
474+ bitor_exprt{bit_is_zero_disjuncts, bit_is_zero_disjuncts.front ().type ()};
475+
476+ // bval: one if not bit_is_zero, and any bval bit is one
477+ exprt::operandst bval_disjuncts;
478+
479+ for (auto &op : expr.operands ())
480+ bval_disjuncts.push_back (bval (op));
481+
482+ auto bval = bitand_exprt{
483+ bitor_exprt{bval_disjuncts, bval_disjuncts.front ().type ()},
484+ bitnot_exprt{bit_is_zero}};
485+
486+ // aval: one if not bit_is_zero and bval is zero
487+ auto aval = bitand_exprt{bitnot_exprt{bit_is_zero}, bitnot_exprt{bval}};
488+
489+ return combine_aval_bval (aval, bval, lower_to_aval_bval (expr.type ()));
490+ }
491+
492+ exprt aval_bval_bitor (const bitor_exprt &expr)
493+ {
494+ auto &type = expr.type ();
495+ PRECONDITION (is_four_valued (type));
496+ PRECONDITION (!expr.operands ().empty ());
497+
498+ for (auto &op : expr.operands ())
499+ PRECONDITION (is_aval_bval (op));
500+
501+ // All result bits are computed bit-wise.
502+ // 1 is the dominating value.
503+ // Otherwise, any bit involving x/z is x.
504+
505+ // A bit is one if the aval bit is one and the bval bit is zero.
506+ exprt::operandst bit_is_one_disjuncts;
507+
508+ for (auto &op : expr.operands ())
509+ bit_is_one_disjuncts.push_back (
510+ bitand_exprt{aval (op), bitnot_exprt{bval (op)}});
511+
512+ auto bit_is_one =
513+ bitor_exprt{bit_is_one_disjuncts, bit_is_one_disjuncts.front ().type ()};
514+
515+ // bval: one if not bit_is_one, and any bval bit is one
516+ exprt::operandst bval_disjuncts;
517+
518+ for (auto &op : expr.operands ())
519+ bval_disjuncts.push_back (bval (op));
520+
521+ auto bval = bitand_exprt{
522+ bitor_exprt{bval_disjuncts, bval_disjuncts.front ().type ()},
523+ bitnot_exprt{bit_is_one}};
524+
525+ // aval: one if bit_is_one
526+ auto aval = bit_is_one;
527+
528+ return combine_aval_bval (aval, bval, lower_to_aval_bval (expr.type ()));
529+ }
530+
531+ exprt aval_bval_xor_xnor (const multi_ary_exprt &expr)
454532{
455533 auto &type = expr.type ();
456534 PRECONDITION (is_four_valued (type));
0 commit comments