Skip to content

Commit b524ce7

Browse files
Merge pull request #6131 from thomasspriggs/tas/incremental_smt2
Add start of foundational work for incremental SMT2 solving support
2 parents aef9f3f + b96edca commit b524ce7

File tree

15 files changed

+189
-0
lines changed

15 files changed

+189
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
/jbmc/src/jdiff/ @smowton @peterschrammel
5555
/src/cpp/ @kroening @tautschnig @peterschrammel
5656
/src/solvers/smt2 @kroening @martin-cs @tautschnig @peterschrammel @allredj @romainbrenguier
57+
/src/solvers/smt2_incremental @peterschrammel @thomasspriggs @NlightNFotis @TGWDB @chrisr-diffblue
5758
/src/statement-list/ @kroening @tautschnig @peterschrammel @pkesseli
5859

5960
/cmake/ @diffblue/diffblue-opensource

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_subdirectory(cpp)
3232
add_subdirectory(cbmc-concurrency)
3333
add_subdirectory(cbmc-cover)
3434
add_subdirectory(cbmc-incr-oneloop)
35+
add_subdirectory(cbmc-incr-smt2)
3536
add_subdirectory(cbmc-incr)
3637
add_subdirectory(cbmc-with-incr)
3738
add_subdirectory(array-refinement-with-incr)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ DIRS = cbmc \
1010
cbmc-concurrency \
1111
cbmc-cover \
1212
cbmc-incr-oneloop \
13+
cbmc-incr-smt2 \
1314
cbmc-incr \
1415
cbmc-with-incr \
1516
array-refinement-with-incr \
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
add_test_pl_tests(
3+
"$<TARGET_FILE:cbmc> --validate-goto-model --validate-ssa-equation --slice-formula"
4+
)

regression/cbmc-incr-smt2/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default: test
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
test:
7+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --validate-goto-model --validate-ssa-equation --slice-formula"
8+
9+
tests.log: ../test.pl test
10+
11+
clean:
12+
find . -name '*.out' -execdir $(RM) '{}' \;
13+
find . -name '*.smt2' -execdir $(RM) '{}' \;
14+
$(RM) tests*.log
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
test.c
3+
--incremental-smt2-solver z3
4+
Passing problem to incremental SMT2 solving via "z3"
5+
^EXIT=(0|127|134|137)$
6+
^SIGNAL=0$
7+
identifier: main::1::x
8+
--
9+
type: pointer
10+
--
11+
Test that running cbmc with the `--incremental-smt2-solver` argument causes the
12+
incremental smt2 solving to be used. Note that at the time of adding this test,
13+
an invariant violation is expected due to the unimplemented solving.
14+
Regexes matching the printing in the expected failed invariant are included in
15+
order to test that `--slice-formula` is causing the first unimplemented
16+
expression passed to `smt2_incremental_decision_proceduret` to relate to the
17+
variable `x` in function `main` and not to `cprover_initialise`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
int main()
3+
{
4+
int x;
5+
__CPROVER_assert(x, "Nondeterministic int assert.");
6+
return 0;
7+
}

src/cbmc/cbmc_parse_options.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
409409
options.set_option("smt2", true);
410410
}
411411

412+
if(cmdline.isset("incremental-smt2-solver"))
413+
{
414+
options.set_option(
415+
"incremental-smt2-solver", cmdline.get_value("incremental-smt2-solver")),
416+
solver_set = true;
417+
}
418+
412419
if(cmdline.isset("external-sat-solver"))
413420
{
414421
options.set_option(
@@ -1042,6 +1049,9 @@ void cbmc_parse_optionst::help()
10421049
" --yices use Yices\n"
10431050
" --z3 use Z3\n"
10441051
" --refine use refinement procedure (experimental)\n"
1052+
" --incremental-smt2-solver cmd\n"
1053+
" command to invoke external SMT solver for\n"
1054+
" incremental solving (experimental)\n"
10451055
" --external-sat-solver cmd command to invoke SAT solver process\n"
10461056
HELP_STRING_REFINEMENT_CBMC
10471057
" --outfile filename output formula to given file\n"

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class optionst;
5757
OPT_JSON_INTERFACE \
5858
"(smt1)(smt2)(fpa)(cvc3)(cvc4)(boolector)(yices)(z3)(mathsat)" \
5959
"(cprover-smt2)" \
60+
"(incremental-smt2-solver):" \
6061
"(external-sat-solver):" \
6162
"(no-sat-preprocessor)" \
6263
"(beautify)" \

src/goto-checker/solver_factory.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Author: Daniel Kroening, Peter Schrammel
3232
#include <solvers/sat/dimacs_cnf.h>
3333
#include <solvers/sat/external_sat.h>
3434
#include <solvers/sat/satcheck.h>
35+
#include <solvers/smt2_incremental/smt2_incremental_decision_procedure.h>
3536
#include <solvers/strings/string_refinement.h>
3637

3738
solver_factoryt::solver_factoryt(
@@ -140,6 +141,10 @@ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_solver()
140141
}
141142
else if(options.get_bool_option("refine-strings"))
142143
return get_string_refinement();
144+
const auto incremental_smt2_solver =
145+
options.get_option("incremental-smt2-solver");
146+
if(!incremental_smt2_solver.empty())
147+
return get_incremental_smt2(incremental_smt2_solver);
143148
if(options.get_bool_option("smt2"))
144149
return get_smt2(get_smt2_solver_type());
145150
return get_default();
@@ -321,6 +326,16 @@ solver_factoryt::get_string_refinement()
321326
std::move(decision_procedure), std::move(prop));
322327
}
323328

329+
std::unique_ptr<solver_factoryt::solvert>
330+
solver_factoryt::get_incremental_smt2(std::string solver_command)
331+
{
332+
no_beautification();
333+
334+
return util_make_unique<solvert>(
335+
util_make_unique<smt2_incremental_decision_proceduret>(
336+
std::move(solver_command)));
337+
}
338+
324339
std::unique_ptr<solver_factoryt::solvert>
325340
solver_factoryt::get_smt2(smt2_dect::solvert solver)
326341
{

0 commit comments

Comments
 (0)