Skip to content

Commit f89db31

Browse files
committed
Incremental SMT back-end no longer requires --slice-formula
With diffblue#6590, several unnecessary symbols are no longer included in goto programs. These include unbounded arrays, which the incremental SMT back-end hitherto does not support. The use of --slice-formula was a workaround to make sure the unnecessary symbols (or equalities over them) don't end up in the formula; now they aren't part of the goto program, so the workaround no longer adds value.
1 parent 5c5e43e commit f89db31

34 files changed

+38
-52
lines changed

doc/cprover-manual/smt2-incr.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,12 @@ To use the incremental SMT2 backend it is enough to add the `--incremental-smt2-
6161
the CBMC command line followed by the command to invoke the chosen solver using smtlib 2.6 input in
6262
interactive mode.
6363

64-
Note that the use of the `--slice-formula` option is recommended at this time to slice out
65-
unnecessary code (that may not be supported at the moment) and this can also improve performance.
66-
6764
Here are two examples to show how to analyse a file `program.c` using Z3 and CVC5 solvers.
6865

6966
To use the Z3 SMT solver:
7067

7168
```shell
72-
cbmc --slice-formula --incremental-smt2-solver 'z3 -smt2 -in' program.c
69+
cbmc --incremental-smt2-solver 'z3 -smt2 -in' program.c
7370
```
7471

7572
If `z3` is not on the `PATH`, then it is enough to replace `'z3 -smt2 -in'`
@@ -78,7 +75,7 @@ with `'<command-to-execute-z3> -smt2 -in'`,
7875
Similarly to execute CBMC using the CVC5 solver:
7976

8077
```shell
81-
cbmc --slice-formula --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' program.c
78+
cbmc --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' program.c
8279
```
8380

8481
As the command to execute the solver is left to the user, it is possible to fine-tune it by passing
@@ -87,7 +84,7 @@ adding `param_name=value` to the command line, so to use the Z3 solver with `wel
8784
property set to `false` the following has to be run:
8885

8986
```shell
90-
cbmc --slice-formula --incremental-smt2-solver 'z3 -smt2 -in well_sorted_check=false' program.c
87+
cbmc --incremental-smt2-solver 'z3 -smt2 -in well_sorted_check=false' program.c
9188
```
9289

9390
### Examples
@@ -110,7 +107,7 @@ int main()
110107
To analyze it we should run:
111108

112109
```shell
113-
cbmc --incremental-smt2-solver 'z3 -smt2 -in' --slice-formula program.c
110+
cbmc --incremental-smt2-solver 'z3 -smt2 -in' program.c
114111
```
115112

116113
We will get the verification results as follows:
@@ -162,7 +159,7 @@ The incremental smt2 backend also supports trace generation, so to get a trace t
162159
assertions the `--trace` argument should be added, so the command to run is:
163160

164161
```shell
165-
cbmc --incremental-smt2-solver 'z3 -smt2 -in' --slice-formula --trace program.c
162+
cbmc --incremental-smt2-solver 'z3 -smt2 -in' --trace program.c
166163
```
167164

168165
This will append the trace to CBMC's output as follows:

doc/man/cbmc.1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ The solver name must be in the "PATH" or be an executable with full path.
461461
The SMT solver should accept incremental SMTlib v2.6 formatted input from the stdin.
462462
.br
463463
The SMT solver should support the QF_AUFBV logic.
464-
.br
465-
The flag \fB\-\-slice\-formula\fR should be added to remove some not-yet supported features.
466464
.TP
467465
\fB\-\-outfile\fR filename
468466
output formula to given file

regression/cbmc-incr-smt2/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ endif()
77

88
add_test_pl_profile(
99
"cbmc-incr-smt2-z3"
10-
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation --slice-formula"
10+
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation"
1111
"-C;${exclude_win_broken_tests};-s;new-smt-z3"
1212
"CORE"
1313
)
1414

1515
add_test_pl_profile(
1616
"cbmc-incr-smt2-cvc5"
17-
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --validate-goto-model --validate-ssa-equation --slice-formula"
17+
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --validate-goto-model --validate-ssa-equation"
1818
"-C;${exclude_win_broken_tests};-s;new-smt-cvc5"
1919
"CORE"
2020
)

regression/cbmc-incr-smt2/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ endif
1212
test: test.z3 test.cvc5
1313

1414
test.z3:
15-
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation --slice-formula" $(exclude_broken_windows_tests)
15+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation" $(exclude_broken_windows_tests)
1616

1717
test.cvc5:
18-
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --validate-goto-model --validate-ssa-equation --slice-formula" $(exclude_broken_windows_tests)
18+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --validate-goto-model --validate-ssa-equation" $(exclude_broken_windows_tests)
1919

2020
tests.log: ../test.pl test
2121

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
array_of.c
3-
3+
--slice-formula
44
Passing problem to incremental SMT2 solving
55
line \d+ False array condition: FAILURE
66
line \d+ Valid array condition: SUCCESS
@@ -10,4 +10,5 @@ line \d+ Valid array condition: SUCCESS
1010
--
1111
Test using __CPROVER_array_set consisting in an `array_of` node which sets all values of a given
1212
array to a given value.
13-
This test uses a forall SMT statement.
13+
This test uses a forall SMT statement. Requires --slice-formula for the time
14+
being, but this is a workaround.

regression/cbmc-incr-smt2/bitvector-bitwise-operators/array-misalign-between.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
array-misalign-between.c
3-
--slice-formula
3+
44
\[main\.assertion\.1\] line \d+ assertion x\[0\] == 256: SUCCESS
55
\[main\.assertion\.2\] line \d+ assertion x\[0\] == 0: FAILURE
66
\[main\.assertion\.3\] line \d+ assertion x\[1\] == 0: SUCCESS

regression/cbmc-incr-smt2/bitvector-bitwise-operators/array-misalign.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
array-misalign.c
3-
--slice-formula
3+
44
\[main.assertion\.1\] line \d+ assertion x\[0\] == 256ul: SUCCESS
55
\[main.assertion\.2\] line \d+ assertion x\[0\] == 0ul: FAILURE
66
\[main.assertion\.3\] line \d+ assertion x\[1\] == 0ul: SUCCESS

regression/cbmc-incr-smt2/bitvector-bitwise-operators/bitwise.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
bitwise_ops.c
3-
--slice-formula
3+
44
\[main\.assertion\.1\] line \d+ This is going to fail for bit-opposites: FAILURE
55
\[main\.assertion\.2\] line \d+ This is going to hold for all values != 0: SUCCESS
66
\[main\.assertion\.3\] line \d+ This is going to fail for the same value in A and B: FAILURE

regression/cbmc-incr-smt2/bitvector-bitwise-operators/byte-extract-small.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
byte-extract-small.c
3-
--slice-formula
3+
44
\[main.assertion\.1\] line \d+ assertion z == 257: SUCCESS
55
^EXIT=0$
66
^SIGNAL=0$

regression/cbmc-incr-smt2/bitvector-bitwise-operators/byte-extract.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
byte-extract.c
3-
--slice-formula
3+
44
\[main.assertion\.1\] line \d+ assertion y\[0\] == 0: FAILURE
55
^EXIT=10$
66
^SIGNAL=0$

regression/cbmc-incr-smt2/bitvector-bitwise-operators/byte-update-small.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
byte-update-small.c
3-
--slice-formula
3+
44
\[main\.assertion\.1\] line \d+ assertion x\[0\] == 2: SUCCESS
55
\[main\.assertion\.2\] line \d+ assertion x\[1\] == 1: SUCCESS
66
^EXIT=0$

regression/cbmc-incr-smt2/bitvector-bitwise-operators/byte-update.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
byte-update.c
3-
--slice-formula
3+
44
\[main\.assertion\.1\] line \d+ assertion x == 256: SUCCESS
55
^EXIT=0$
66
^SIGNAL=0$

regression/cbmc-incr-smt2/bitvector-bitwise-operators/shift_left.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
shift_left.c
3-
--slice-formula
3+
44
\[main\.assertion\.1\] line \d Shifted result should be greater than one: FAILURE
55
^EXIT=10$
66
^SIGNAL=0$

regression/cbmc-incr-smt2/bitvector-bitwise-operators/shift_right.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
shift_right.c
3-
--slice-formula --trace
3+
--trace
44
\[main\.assertion\.1\] line \d+ Right shifting a uint with leftmost bit set is a logical shift: FAILURE
55
\[main\.assertion\.2\] line \d+ Right shifting a positive number has a lower bound of 0: SUCCESS
66
\[main\.assertion\.3\] line \d+ Right shifting a negative number has a lower bound value of -1: SUCCESS

regression/cbmc-incr-smt2/nondeterministic-int-assert/control_flow.desc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Solver response - sat
2323
^EXIT=10$
2424
^SIGNAL=0$
2525
--
26-
type: pointer
2726
--
2827
Test that running cbmc with the `--incremental-smt2-solver` argument can be used
2928
to send a valid SMT2 formula to a sub-process solver for an example input file

regression/cbmc-incr-smt2/nondeterministic-int-assert/incremental_solver_called.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--verbosity 10
3+
--slice-formula --verbosity 10
44
Passing problem to incremental SMT2 solving via
55
Sending command to SMT2 solver - \(set-option :produce-models true\)
66
Sending command to SMT2 solver - \(set-logic ALL\)

regression/cbmc-incr-smt2/nondeterministic-int-assert/valid_unsat.desc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ VERIFICATION SUCCESSFUL
88
^EXIT=0$
99
^SIGNAL=0$
1010
--
11-
type: pointer
1211
--
1312
Test that given a `.c` program where all assertions hold, the solver responds
1413
with unsat and CBMC reports that verification is successful.

regression/cbmc-incr-smt2/pointers/pointer_values_2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
pointer_values_2.c
3-
--trace --slice-formula
3+
--trace
44
\[main\.assertion\.1\] line \d should fail as b can also be assigned 0xDEADBEEF: FAILURE
55
a=\(signed int \*\)3735928559
66
b=\(signed int \*\)3735928559

regression/cbmc-output-file/dump-smt-formula/cvc5-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --slice-formula --dump-smt-formula %out-file-name%
3+
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --dump-smt-formula %out-file-name%
44
Passing problem to incremental SMT2 solving via "cvc5 --lang=smtlib2.6 --incremental"
55
\[main.assertion.\d+\] line \d+ Nondeterministic int assert.: FAILURE
66
Output file matches.

regression/cbmc-output-file/dump-smt-formula/cvc5-no-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --slice-formula --dump-smt-formula %out-file-name%
3+
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --dump-smt-formula %out-file-name%
44
Passing problem to incremental SMT2 solving via "cvc5 --lang=smtlib2.6 --incremental"
55
\[main.assertion.\d+\] line \d+ Nondeterministic int assert.: FAILURE
66
Output file does not match.

regression/cbmc-output-file/dump-smt-formula/z3-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'z3 --smt2 -in' --slice-formula --dump-smt-formula %out-file-name%
3+
--incremental-smt2-solver 'z3 --smt2 -in' --dump-smt-formula %out-file-name%
44
Passing problem to incremental SMT2 solving via "z3 --smt2 -in"
55
\[main.assertion.\d+\] line \d+ Nondeterministic int assert.: FAILURE
66
Output file matches.

regression/cbmc-output-file/dump-smt-formula/z3-no-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'z3 --smt2 -in' --slice-formula --dump-smt-formula %out-file-name%
3+
--incremental-smt2-solver 'z3 --smt2 -in' --dump-smt-formula %out-file-name%
44
Passing problem to incremental SMT2 solving via "z3 --smt2 -in"
55
\[main.assertion.\d+\] line \d+ Nondeterministic int assert.: FAILURE
66
Output file does not match.

regression/cbmc-output-file/outfile/cvc5-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --slice-formula --outfile %out-file-name%
3+
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --outfile %out-file-name%
44
Passing problem to incremental SMT2 solving via SMT2 incremental dry-run
55
Output file matches.
66
^EXIT=0$

regression/cbmc-output-file/outfile/cvc5-no-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --slice-formula --outfile %out-file-name%
3+
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental' --outfile %out-file-name%
44
Passing problem to incremental SMT2 solving via SMT2 incremental dry-run
55
Output file does not match.
66
^EXIT=1$

regression/cbmc-output-file/outfile/z3-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'z3 --smt2 -in' --slice-formula --outfile %out-file-name%
3+
--incremental-smt2-solver 'z3 --smt2 -in' --outfile %out-file-name%
44
Passing problem to incremental SMT2 solving via SMT2 incremental dry-run
55
Output file matches.
66
^EXIT=0$

regression/cbmc-output-file/outfile/z3-no-match.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
--incremental-smt2-solver 'z3 --smt2 -in' --slice-formula --outfile %out-file-name%
3+
--incremental-smt2-solver 'z3 --smt2 -in' --outfile %out-file-name%
44
Passing problem to incremental SMT2 solving via SMT2 incremental dry-run
55
Output file does not match.
66
^EXIT=1$

regression/cbmc-primitives/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if(Z3_EXISTS)
88
# If `-I` (include flag) is passed, test.pl will run only the tests matching the label following it.
99
add_test_pl_profile(
1010
"cbmc-primitives-new-smt-backend"
11-
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in' --slice-formula"
11+
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in'"
1212
"-I;new-smt-backend;-s;new-smt-backend"
1313
"CORE"
1414
)

regression/cbmc-primitives/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test:
44
@../test.pl -e -p -c ../../../src/cbmc/cbmc
55

66
test.smt2_incr:
7-
@../test.pl -e -p -I new-smt-backend -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation --slice-formula"
7+
@../test.pl -e -p -I new-smt-backend -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in' --validate-goto-model --validate-ssa-equation"
88

99
tests.log: ../test.pl
1010
@../test.pl -e -p -c ../../../src/cbmc/cbmc

regression/cbmc-primitives/exists_memory_checks/negated_exists.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE new-smt-backend
1+
CORE
22
negated_exists.c
33
--pointer-check
44
^EXIT=0$

regression/cbmc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ add_test_pl_profile(
2727
# If `-I` (include flag) is passed, test.pl will run only the tests matching the label following it.
2828
add_test_pl_profile(
2929
"cbmc-new-smt-backend"
30-
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in' --slice-formula"
30+
"$<TARGET_FILE:cbmc> --incremental-smt2-solver 'z3 --smt2 -in'"
3131
"-I;new-smt-backend;-s;new-smt-backend"
3232
"CORE"
3333
)

regression/cbmc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test-paths-lifo:
3030
-s paths-lifo $(GCC_ONLY)
3131

3232
test-new-smt-backend:
33-
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in' --slice-formula" \
33+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --incremental-smt2-solver 'z3 --smt2 -in'" \
3434
-I new-smt-backend \
3535
-s new-smt-backend $(GCC_ONLY)
3636

regression/cbmc/Pointer14/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE new-smt-backend
1+
CORE
22
main.c
33
--pointer-check
44
^VERIFICATION FAILED$

regression/cbmc/Pointer27/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE new-smt-backend
1+
CORE
22
main.c
33

44
^SIGNAL=0$

src/solvers/smt2_incremental/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ The new incremental SMT backend has been designed to interoperate with external
3535
solvers, so the solver name must be in the `PATH` or an executable with full
3636
path must be provided.
3737

38-
Due to lack of support for conversion of `array_of` expressions that are added
39-
by CBMC in the before the new SMT backend is invoked, it is necessary to supply
40-
an extra argument `--slice-formula` so that instances of `arrayof_exprt` are
41-
removed from the formula to be converted.
42-
43-
As we move forward with our array-support implementation, we anticipate that the
44-
need for this extra flag will be diminished.
45-
4638
## Internal code architecture
4739

4840
### Overview of the sequence of data processing and data flow -

0 commit comments

Comments
 (0)