@@ -1301,9 +1301,36 @@ void smt2_convt::convert_expr(const exprt &expr)
13011301 {
13021302 convert_constant (to_constant_expr (expr));
13031303 }
1304+ else if (expr.id () == ID_concatenation)
1305+ {
1306+ DATA_INVARIANT_WITH_DIAGNOSTICS (
1307+ !expr.operands ().empty (),
1308+ " concatenation expression should have at least one operand" ,
1309+ expr.id_string ());
1310+
1311+ if (expr.operands ().size () == 1 )
1312+ {
1313+ flatten2bv (expr.operands ().front ());
1314+ }
1315+ else // >= 2
1316+ {
1317+ out << " (concat" ;
1318+
1319+ for (const auto &op : expr.operands ())
1320+ {
1321+ // drop zero-width operands, which are not allowed by SMT-LIB
1322+ if (!is_zero_width (op.type (), ns))
1323+ {
1324+ out << ' ' ;
1325+ flatten2bv (op);
1326+ }
1327+ }
1328+
1329+ out << ' )' ;
1330+ }
1331+ }
13041332 else if (
1305- expr.id () == ID_concatenation || expr.id () == ID_bitand ||
1306- expr.id () == ID_bitor || expr.id () == ID_bitxor)
1333+ expr.id () == ID_bitand || expr.id () == ID_bitor || expr.id () == ID_bitxor)
13071334 {
13081335 DATA_INVARIANT_WITH_DIAGNOSTICS (
13091336 !expr.operands ().empty (),
@@ -2079,6 +2106,10 @@ void smt2_convt::convert_expr(const exprt &expr)
20792106
20802107 mp_integer times = numeric_cast_v<mp_integer>(replication_expr.times ());
20812108
2109+ // SMT-LIB requires that repeat is given a number of repetitions that is at
2110+ // least 1.
2111+ PRECONDITION (times >= 1 );
2112+
20822113 out << " ((_ repeat " << times << " ) " ;
20832114 flatten2bv (replication_expr.op ());
20842115 out << " )" ;
0 commit comments