Skip to content

Commit ed58253

Browse files
committed
Add --external-smt2-solver for custom solver path or custom options
Similar to `--external-sat-solver`: enable calling SMT2 solvers with a non-default name or possibly wrapping a solver to pass additional options. Fixes: #8720
1 parent c914c2c commit ed58253

File tree

10 files changed

+46
-5
lines changed

10 files changed

+46
-5
lines changed

doc/man/cbmc.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@ use Z3
516516
\fB\-\-fpa\fR
517517
use theory of floating\-point arithmetic
518518
.TP
519+
\fB\-\-external\-smt2\-solver\fR \fIcmd\fR
520+
Use \fIcmd\fR to invoke the SMT2 solver. Combine with one of the solver choices
521+
for solver-specific constraints.
522+
.TP
519523
\fB\-\-refine\fR
520524
use refinement procedure (experimental)
521525
.TP

doc/man/goto-synthesizer.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ use Z3
8282
\fB\-\-fpa\fR
8383
use theory of floating\-point arithmetic
8484
.TP
85+
\fB\-\-external\-smt2\-solver\fR \fIcmd\fR
86+
Use \fIcmd\fR to invoke the SMT2 solver. Combine with one of the solver choices
87+
for solver-specific constraints.
88+
.TP
8589
\fB\-\-refine\fR
8690
use refinement procedure (experimental)
8791
.TP

doc/man/jbmc.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ use Z3
434434
\fB\-\-fpa\fR
435435
use theory of floating\-point arithmetic
436436
.TP
437+
\fB\-\-external\-smt2\-solver\fR \fIcmd\fR
438+
Use \fIcmd\fR to invoke the SMT2 solver. Combine with one of the solver choices
439+
for solver-specific constraints.
440+
.TP
437441
\fB\-\-refine\fR
438442
use refinement procedure (experimental)
439443
.TP
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE smt-backend broken-cprover-smt-backend no-new-smt
2+
main.c
3+
--z3 --external-smt2-solver z3 --trace
4+
^VERIFICATION FAILED$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

scripts/bash-autocomplete/cbmc.sh.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ _cbmc_autocomplete()
4040
_filedir -d
4141
return 0
4242
;;
43-
--external-sat-solver|--incremental-smt2-solver)
43+
--external-sat-solver|--incremental-smt2-solver|--external-smt2-solver)
4444
#a switch that takes a file parameter of which we don't know an extension
4545
_filedir -f
4646
return 0

src/goto-checker/solver_factory.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
515515
std::string("Generated by CBMC ") + CBMC_VERSION,
516516
"QF_AUFBV",
517517
solver,
518+
options.get_option("external-smt2-solver"),
518519
message_handler);
519520

520521
if(options.get_bool_option("fpa"))
@@ -672,6 +673,14 @@ static void parse_smt2_options(const cmdlinet &cmdline, optionst &options)
672673
options.set_option("smt2", true);
673674
}
674675

676+
if(cmdline.isset("external-smt2-solver"))
677+
{
678+
options.set_option(
679+
"external-smt2-solver", cmdline.get_value("external-smt2-solver"));
680+
solver_set = true;
681+
options.set_option("smt2", true);
682+
}
683+
675684
if(cmdline.isset("smt2") && !solver_set)
676685
{
677686
if(cmdline.isset("outfile"))

src/goto-checker/solver_factory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options);
104104
"(mathsat)" \
105105
"(cprover-smt2)" \
106106
"(incremental-smt2-solver):" \
107+
"(external-smt2-solver):" \
107108
"(sat-solver):" \
108109
"(external-sat-solver):" \
109110
"(no-sat-preprocessor)" \
@@ -135,6 +136,8 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options);
135136
" {y--yices} \t use Yices\n" \
136137
" {y--z3} \t use Z3\n" \
137138
" {y--fpa} \t use theory of floating-point arithmetic\n" \
139+
" {y--external-smt2-solver} {ucmd} \t command to invoke SMT2 solver " \
140+
"(combine with one of the solver choices for solver-specific constraints)\n" \
138141
" {y--refine} \t use refinement procedure (experimental)\n" \
139142
" {y--refine-arrays} \t use refinement for arrays only\n" \
140143
" {y--refine-arithmetic} \t refinement of arithmetic expressions only\n" \

src/goto-instrument/accelerate/scratch_program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class scratch_programt:public goto_programt
7474
symex(mh, symbol_table, equation, options, path_storage, guard_manager),
7575
satcheck(std::make_unique<satcheckt>(mh)),
7676
satchecker(ns, *satcheck, mh),
77-
z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3, mh),
77+
z3(ns, "accelerate", "", "", smt2_dect::solvert::Z3, "", mh),
7878
checker(&z3) // checker(&satchecker)
7979
{
8080
}

src/solvers/smt2/smt2_dec.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ decision_proceduret::resultt smt2_dect::dec_solve(const exprt &assumption)
134134
break;
135135

136136
case solvert::GENERIC:
137-
UNREACHABLE;
137+
PRECONDITION(!solver_binary_or_empty.empty());
138+
argv = {solver_binary_or_empty, temp_file_problem()};
139+
break;
138140
}
139141

140-
int res =
141-
run(argv[0], argv, stdin_filename, temp_file_stdout(), temp_file_stderr());
142+
int res = run(
143+
solver_binary_or_empty.empty() ? argv[0] : solver_binary_or_empty,
144+
argv,
145+
stdin_filename,
146+
temp_file_stdout(),
147+
temp_file_stderr());
142148

143149
if(res<0)
144150
{

src/solvers/smt2/smt2_dec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ class smt2_dect : protected smt2_stringstreamt, public smt2_convt
3131
const std::string &_notes,
3232
const std::string &_logic,
3333
solvert _solver,
34+
const std::string &_solver_binary_or_empty,
3435
message_handlert &_message_handler)
3536
: smt2_convt(_ns, _benchmark, _notes, _logic, _solver, stringstream),
37+
solver_binary_or_empty(_solver_binary_or_empty),
3638
message_handler(_message_handler)
3739
{
3840
}
3941

4042
std::string decision_procedure_text() const override;
4143

4244
protected:
45+
std::string solver_binary_or_empty;
4346
message_handlert &message_handler;
4447
resultt dec_solve(const exprt &) override;
4548

0 commit comments

Comments
 (0)