Skip to content

Commit 276852e

Browse files
committed
SMT2: bvnor, bvnand are binary only; add bvxnor
The SMT-LIB2 expressions bvnor and bvnand are not multi-ary. Furthermore, this adds the (binary) bvxnor expression.
1 parent e8d3409 commit 276852e

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,9 @@ void smt2_convt::convert_expr(const exprt &expr)
12201220

12211221
convert_expr(expr.operands().front());
12221222
}
1223-
else if(expr.id()==ID_concatenation ||
1224-
expr.id()==ID_bitand ||
1225-
expr.id()==ID_bitor ||
1226-
expr.id()==ID_bitxor ||
1227-
expr.id()==ID_bitnand ||
1228-
expr.id()==ID_bitnor)
1223+
else if(
1224+
expr.id() == ID_concatenation || expr.id() == ID_bitand ||
1225+
expr.id() == ID_bitor || expr.id() == ID_bitxor)
12291226
{
12301227
DATA_INVARIANT_WITH_DIAGNOSTICS(
12311228
expr.operands().size() >= 2,
@@ -1255,6 +1252,28 @@ void smt2_convt::convert_expr(const exprt &expr)
12551252

12561253
out << ")";
12571254
}
1255+
else if(
1256+
expr.id() == ID_bitxnor || expr.id() == ID_bitnand ||
1257+
expr.id() == ID_bitnor)
1258+
{
1259+
// only exist as a binary expression
1260+
const auto &bitxnor = to_bitxnor_expr(expr);
1261+
DATA_INVARIANT(
1262+
expr.operands().size() == 2, "bitxnor should have two operands");
1263+
1264+
out << '(';
1265+
if(expr.id() == ID_bitxnor)
1266+
out << "bvxnor";
1267+
else if(expr.id() == ID_bitnand)
1268+
out << "bvnand";
1269+
else if(expr.id() == ID_bitnor)
1270+
out << "bvnor";
1271+
out << ' ';
1272+
flatten2bv(bitxnor.op0());
1273+
out << ' ';
1274+
flatten2bv(bitxnor.op1());
1275+
out << ')';
1276+
}
12581277
else if(expr.id()==ID_bitnot)
12591278
{
12601279
const bitnot_exprt &bitnot_expr = to_bitnot_expr(expr);

0 commit comments

Comments
 (0)