Skip to content

Inconsistent behavior in dump_smt across solvers #2167

@intrigus-lgtm

Description

@intrigus-lgtm

The behavior in ::dump_smt is not consistent across solvers:

Z3 dumps the smt formula to the file defined in output. If there is no file defined, it just swallows everything.

void z3_convt::dump_smt()
{
const std::string &path = options.get_option("output");
/* the iostream API is just unusable */
if (path == "-")
print_smt_formulae(std::cout);
else
{
std::ofstream out(path);
print_smt_formulae(out);
}
}

Note that this wasn't always the case; previously it would output to stdout when no output was defined:

a2ff1a8#diff-0489271635db802271e51ff12caa04e85c9fe16e8a38361d69256b0afbc802dfL1305-L1321

Bitwuzla always prints to stdout

void bitwuzla_convt::dump_smt()
{
// Print formulas using binary bit-vector output format
bitwuzla_print_formula(bitw, "smt2", messaget::state.out, 2);
}

Smtlib observes output

void smtlib_convt::dump_smt()
{
auto path = config.options.get_option("output");
if (path != "")
{
assert(emit_opt_output);
emit_opt_output.emit("%s\n", "(check-sat)");
if (path == "-")
log_status("SMT formula written to standard output");
else
log_status("SMT formula written to output file {}", path);
}
}

while Boolector again just prints to stdout:

void boolector_convt::dump_smt()
{
boolector_dump_smt2(btor, messaget::state.out);
}

This is annoying when you're wondering why --z3 --smt-formula-only doesn't print anything on stdout.
The output parameter is also overused:
it is used in smt-formula printing, vcc printing, goto2c printing and maybe somewhere else.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions