Skip to content

Commit a0e52ef

Browse files
author
Enrico Steffinlongo
committed
Add --dump-smt-formula argument
1 parent 6201501 commit a0e52ef

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/goto-checker/solver_factory.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_solver()
149149
options.get_option("incremental-smt2-solver");
150150
if(!incremental_smt2_solver.empty())
151151
{
152-
const auto out_filename = options.get_option("outfile");
152+
if(options.get_option("outfile") != "")
153+
{
154+
throw invalid_command_line_argument_exceptiont(
155+
"Argument --outfile is incompatible with --incremental-smt2-solver. "
156+
"Use --dump-smt-formula instead.",
157+
"--outfile");
158+
}
159+
const auto out_filename = options.get_option("dump-smt-formula");
153160
return get_incremental_smt2(incremental_smt2_solver, out_filename);
154161
}
155162
if(options.get_bool_option("smt2"))
@@ -332,7 +339,8 @@ solver_factoryt::get_string_refinement()
332339
std::move(decision_procedure), std::move(prop));
333340
}
334341

335-
std::unique_ptr<std::ofstream> open_outfile_and_check(const std::string &filename)
342+
std::unique_ptr<std::ofstream>
343+
open_outfile_and_check(const std::string &filename, const std::string &arg_name)
336344
{
337345
if(filename.empty())
338346
return nullptr;
@@ -346,7 +354,7 @@ std::unique_ptr<std::ofstream> open_outfile_and_check(const std::string &filenam
346354
if(!*out)
347355
{
348356
throw invalid_command_line_argument_exceptiont(
349-
"failed to open file: " + filename, "--filename");
357+
"failed to open file: " + filename, arg_name);
350358
}
351359

352360
std::cout << "Outputting SMTLib formula to file: " << filename << "\n";
@@ -360,7 +368,9 @@ std::unique_ptr<solver_factoryt::solvert> solver_factoryt::get_incremental_smt2(
360368
no_beautification();
361369

362370
auto solver_process = util_make_unique<smt_piped_solver_processt>(
363-
std::move(solver_command), message_handler, open_outfile_and_check(outfile));
371+
std::move(solver_command),
372+
message_handler,
373+
open_outfile_and_check(outfile, "--dump-smt-formula"));
364374

365375
return util_make_unique<solvert>(
366376
util_make_unique<smt2_incremental_decision_proceduret>(
@@ -416,7 +426,7 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
416426
}
417427
else
418428
{
419-
auto out = open_outfile_and_check(filename);
429+
auto out = open_outfile_and_check(filename, "--outfile");
420430

421431
auto smt2_conv = util_make_unique<smt2_convt>(
422432
ns,
@@ -558,6 +568,10 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options)
558568
if(cmdline.isset("outfile"))
559569
options.set_option("outfile", cmdline.get_value("outfile"));
560570

571+
if(cmdline.isset("dump-smt-formula"))
572+
options.set_option(
573+
"dump-smt-formula", cmdline.get_value("dump-smt-formula"));
574+
561575
if(cmdline.isset("write-solver-stats-to"))
562576
{
563577
options.set_option(

src/goto-checker/solver_factory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options);
115115
"(refine-arrays)" \
116116
"(refine-arithmetic)" \
117117
"(outfile):" \
118+
"(dump-smt-formula):" \
118119
"(write-solver-stats-to):"
119120

120121
#define HELP_SOLVER \
@@ -142,6 +143,8 @@ void parse_solver_options(const cmdlinet &cmdline, optionst &options);
142143
" command to invoke external SMT solver for\n" \
143144
" incremental solving (experimental)\n" \
144145
" --outfile filename output formula to given file\n" \
146+
" --dump-smt-formula filename output smt incremental formula to the\n" \
147+
" given file\n" \
145148
" --write-solver-stats-to json-file\n" \
146149
" collect the solver query complexity\n"
147150

0 commit comments

Comments
 (0)