Skip to content

Commit 2b184cd

Browse files
authored
Merge pull request #8726 from tautschnig/smt-solver-command
Add --external-smt2-solver for custom solver path or custom options
2 parents b6caec4 + b8a2281 commit 2b184cd

File tree

10 files changed

+81
-32
lines changed

10 files changed

+81
-32
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: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,76 +65,90 @@ decision_proceduret::resultt smt2_dect::dec_solve(const exprt &assumption)
6565
std::vector<std::string> argv;
6666
std::string stdin_filename;
6767

68+
auto solver_binary_name = [this](const std::string &solver_name)
69+
{
70+
if(solver_binary_or_empty.empty())
71+
return solver_name;
72+
else
73+
return solver_binary_or_empty;
74+
};
75+
6876
switch(solver)
6977
{
7078
case solvert::BITWUZLA:
71-
argv = {"bitwuzla", temp_file_problem()};
79+
argv = {solver_binary_name("bitwuzla"), temp_file_problem()};
7280
break;
7381

7482
case solvert::BOOLECTOR:
75-
argv = {"boolector", "--smt2", temp_file_problem(), "-m"};
83+
argv = {
84+
solver_binary_name("boolector"), "--smt2", temp_file_problem(), "-m"};
7685
break;
7786

7887
case solvert::CPROVER_SMT2:
79-
argv = {"smt2_solver"};
88+
argv = {solver_binary_name("smt2_solver")};
8089
stdin_filename = temp_file_problem();
8190
break;
8291

8392
case solvert::CVC3:
84-
argv = {"cvc3",
85-
"+model",
86-
"-lang",
87-
"smtlib",
88-
"-output-lang",
89-
"smtlib",
90-
temp_file_problem()};
93+
argv = {
94+
solver_binary_name("cvc3"),
95+
"+model",
96+
"-lang",
97+
"smtlib",
98+
"-output-lang",
99+
"smtlib",
100+
temp_file_problem()};
91101
break;
92102

93103
case solvert::CVC4:
94104
// The flags --bitblast=eager --bv-div-zero-const help but only
95105
// work for pure bit-vector formulas.
96-
argv = {"cvc4", "-L", "smt2", temp_file_problem()};
106+
argv = {solver_binary_name("cvc4"), "-L", "smt2", temp_file_problem()};
97107
break;
98108

99109
case solvert::CVC5:
100-
argv = {"cvc5", "--lang", "smtlib", temp_file_problem()};
110+
argv = {
111+
solver_binary_name("cvc5"), "--lang", "smtlib", temp_file_problem()};
101112
break;
102113

103114
case solvert::MATHSAT:
104115
// The options below were recommended by Alberto Griggio
105116
// on 10 July 2013
106117

107-
argv = {"mathsat",
108-
"-input=smt2",
109-
"-preprocessor.toplevel_propagation=true",
110-
"-preprocessor.simplification=7",
111-
"-dpll.branching_random_frequency=0.01",
112-
"-dpll.branching_random_invalidate_phase_cache=true",
113-
"-dpll.restart_strategy=3",
114-
"-dpll.glucose_var_activity=true",
115-
"-dpll.glucose_learnt_minimization=true",
116-
"-theory.bv.eager=true",
117-
"-theory.bv.bit_blast_mode=1",
118-
"-theory.bv.delay_propagated_eqs=true",
119-
"-theory.fp.mode=1",
120-
"-theory.fp.bit_blast_mode=2",
121-
"-theory.arr.mode=1"};
118+
argv = {
119+
solver_binary_name("mathsat"),
120+
"-input=smt2",
121+
"-preprocessor.toplevel_propagation=true",
122+
"-preprocessor.simplification=7",
123+
"-dpll.branching_random_frequency=0.01",
124+
"-dpll.branching_random_invalidate_phase_cache=true",
125+
"-dpll.restart_strategy=3",
126+
"-dpll.glucose_var_activity=true",
127+
"-dpll.glucose_learnt_minimization=true",
128+
"-theory.bv.eager=true",
129+
"-theory.bv.bit_blast_mode=1",
130+
"-theory.bv.delay_propagated_eqs=true",
131+
"-theory.fp.mode=1",
132+
"-theory.fp.bit_blast_mode=2",
133+
"-theory.arr.mode=1"};
122134

123135
stdin_filename = temp_file_problem();
124136
break;
125137

126138
case solvert::YICES:
127139
// command = "yices -smt -e " // Calling convention for older versions
128140
// Convention for 2.2.1
129-
argv = {"yices-smt2", temp_file_problem()};
141+
argv = {solver_binary_name("yices-smt2"), temp_file_problem()};
130142
break;
131143

132144
case solvert::Z3:
133-
argv = {"z3", "-smt2", temp_file_problem()};
145+
argv = {solver_binary_name("z3"), "-smt2", temp_file_problem()};
134146
break;
135147

136148
case solvert::GENERIC:
137-
UNREACHABLE;
149+
PRECONDITION(!solver_binary_or_empty.empty());
150+
argv = {solver_binary_or_empty, temp_file_problem()};
151+
break;
138152
}
139153

140154
int res =

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)