Skip to content

Commit dfcd4a8

Browse files
author
Enrico Steffinlongo
authored
Merge pull request #7291 from esteffin/esteffin/smt-array-concat
Add conversion for concatenation of bit vector smt2 terms
2 parents 2cd4154 + 20408ca commit dfcd4a8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ static smt_termt convert_expr_to_smt(
353353
const concatenation_exprt &concatenation,
354354
const sub_expression_mapt &converted)
355355
{
356+
if(operands_are_of_type<bitvector_typet>(concatenation))
357+
{
358+
return convert_multiary_operator_to_terms(
359+
concatenation, converted, smt_bit_vector_theoryt::concat);
360+
}
356361
UNIMPLEMENTED_FEATURE(
357362
"Generation of SMT formula for concatenation expression: " +
358363
concatenation.pretty());

unit/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,35 @@ TEST_CASE(
12511251
}
12521252
}
12531253

1254+
TEST_CASE(
1255+
"expr to smt conversion for concatenation_exprt expressions",
1256+
"[core][smt2_incremental]")
1257+
{
1258+
auto test =
1259+
expr_to_smt_conversion_test_environmentt::make(test_archt::x86_64);
1260+
SECTION("Bit vector types")
1261+
{
1262+
const exprt bit_vector_1 =
1263+
symbol_exprt{"my_bit_vector_1", signedbv_typet{8}};
1264+
const exprt bit_vector_2 =
1265+
symbol_exprt{"my_bit_vector_2", signedbv_typet{9}};
1266+
const exprt bit_vector_3 =
1267+
symbol_exprt{"my_bit_vector_3", signedbv_typet{10}};
1268+
const concatenation_exprt concatenation{
1269+
{bit_vector_1, bit_vector_2, bit_vector_3}, signedbv_typet{27}};
1270+
INFO("Expression being converted: " + concatenation.pretty(2, 0));
1271+
const smt_identifier_termt smt_id_1{
1272+
"my_bit_vector_1", smt_bit_vector_sortt{8}};
1273+
const smt_identifier_termt smt_id_2{
1274+
"my_bit_vector_2", smt_bit_vector_sortt{9}};
1275+
const smt_identifier_termt smt_id_3{
1276+
"my_bit_vector_3", smt_bit_vector_sortt{10}};
1277+
const smt_termt expected = smt_bit_vector_theoryt::concat(
1278+
smt_bit_vector_theoryt::concat(smt_id_1, smt_id_2), smt_id_3);
1279+
CHECK(test.convert(concatenation) == expected);
1280+
}
1281+
}
1282+
12541283
TEST_CASE(
12551284
"expr to smt conversion for extract bits expressions",
12561285
"[core][smt2_incremental]")

0 commit comments

Comments
 (0)