Skip to content

Commit 79d7f1e

Browse files
Merge pull request #6628 from thomasspriggs/tas/smt2_c_bool
Add support for incremental SMT traces containing C_bool
2 parents 60d3466 + a638644 commit 79d7f1e

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
stdbool_example.c
3+
--incremental-smt2-solver 'z3 --smt2 -in' --trace
4+
Passing problem to incremental SMT2 solving via "z3 --smt2 -in"
5+
VERIFICATION FAILED
6+
equal=FALSE\s*\([0 ]+\)
7+
equal=TRUE\s*\([0 ]+1\)
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
Test that running cbmc with the `--incremental-smt2-solver` argument can be used
13+
to generate a trace including values of C bool variables.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdbool.h>
2+
3+
int main()
4+
{
5+
int x, y;
6+
bool equal = x == y;
7+
__CPROVER_assert(equal, "Assert of integer equality.");
8+
__CPROVER_assert(!equal, "Assert of not integer equality.");
9+
return 0;
10+
}

src/solvers/smt2_incremental/construct_value_expr_from_smt.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ class value_expr_from_smt_factoryt : public smt_term_const_downcast_visitort
3838
void visit(const smt_bit_vector_constant_termt &bit_vector_constant) override
3939
{
4040
if(
41-
const auto integer_type =
42-
type_try_dynamic_cast<integer_bitvector_typet>(type_to_construct))
41+
const auto bitvector_type =
42+
type_try_dynamic_cast<bitvector_typet>(type_to_construct))
4343
{
4444
INVARIANT(
45-
integer_type->get_width() == bit_vector_constant.get_sort().bit_width(),
45+
bitvector_type->get_width() ==
46+
bit_vector_constant.get_sort().bit_width(),
4647
"Width of smt bit vector term must match the width of bit vector "
4748
"type.");
4849
result = from_integer(bit_vector_constant.value(), type_to_construct);

unit/solvers/smt2_incremental/construct_value_expr_from_smt.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
// Author: Diffblue Ltd.
22

3-
#include <testing-utils/use_catch.h>
3+
#include <util/arith_tools.h>
4+
#include <util/bitvector_types.h>
5+
#include <util/c_types.h>
6+
#include <util/mp_arith.h>
7+
#include <util/std_expr.h>
8+
#include <util/std_types.h>
49

510
#include <solvers/smt2_incremental/construct_value_expr_from_smt.h>
6-
711
#include <solvers/smt2_incremental/smt_core_theory.h>
812
#include <solvers/smt2_incremental/smt_terms.h>
913
#include <solvers/smt2_incremental/smt_to_smt2_string.h>
10-
1114
#include <testing-utils/invariant.h>
12-
13-
#include <util/arith_tools.h>
14-
#include <util/bitvector_types.h>
15-
#include <util/mp_arith.h>
16-
#include <util/std_expr.h>
17-
#include <util/std_types.h>
15+
#include <testing-utils/use_catch.h>
1816

1917
#include <string>
2018

@@ -68,6 +66,8 @@ TEST_CASE("Value expr construction from smt.", "[core][smt2_incremental]")
6866
std::tie(input_term, expected_result) = GENERATE(
6967
rowt{smt_bool_literal_termt{true}, true_exprt{}},
7068
rowt{smt_bool_literal_termt{false}, false_exprt{}},
69+
rowt{smt_bit_vector_constant_termt{0, 8}, from_integer(0, c_bool_typet(8))},
70+
rowt{smt_bit_vector_constant_termt{1, 8}, from_integer(1, c_bool_typet(8))},
7171
UNSIGNED_BIT_VECTOR_TESTS(8),
7272
SIGNED_BIT_VECTOR_TESTS(8),
7373
UNSIGNED_BIT_VECTOR_TESTS(16),

0 commit comments

Comments
 (0)