41 temp_file_stdout(
"smt2_dec_stdout_",
""),
42 temp_file_stderr(
"smt2_dec_stderr_",
"");
44 const auto write_problem_to_file = [&](std::ofstream problem_out) {
51 write_problem_to_file(std::ofstream(
52 temp_file_problem(), std::ios_base::out | std::ios_base::trunc));
54 std::vector<std::string> argv;
55 std::string stdin_filename;
60 argv = {
"bitwuzla", temp_file_problem()};
64 argv = {
"boolector",
"--smt2", temp_file_problem(),
"-m"};
68 argv = {
"smt2_solver"};
69 stdin_filename = temp_file_problem();
85 argv = {
"cvc4",
"-L",
"smt2", temp_file_problem()};
89 argv = {
"cvc5",
"--lang",
"smtlib", temp_file_problem()};
98 "-preprocessor.toplevel_propagation=true",
99 "-preprocessor.simplification=7",
100 "-dpll.branching_random_frequency=0.01",
101 "-dpll.branching_random_invalidate_phase_cache=true",
102 "-dpll.restart_strategy=3",
103 "-dpll.glucose_var_activity=true",
104 "-dpll.glucose_learnt_minimization=true",
105 "-theory.bv.eager=true",
106 "-theory.bv.bit_blast_mode=1",
107 "-theory.bv.delay_propagated_eqs=true",
109 "-theory.fp.bit_blast_mode=2",
110 "-theory.arr.mode=1"};
112 stdin_filename = temp_file_problem();
118 argv = {
"yices-smt2", temp_file_problem()};
122 argv = {
"z3",
"-smt2", temp_file_problem()};
130 run(argv[0], argv, stdin_filename, temp_file_stdout(), temp_file_stderr());
139 std::ifstream in(temp_file_stdout());
145 if(src.size() >= 2 && src.front() ==
'|' && src.back() ==
'|')
146 return std::string(src, 1, src.size() - 2);
159 typedef std::unordered_map<irep_idt, irept> valuest;
160 valuest parsed_values;
166 if(!parsed_opt.has_value())
169 const auto &parsed = parsed_opt.value();
171 if(parsed.id()==
"sat")
173 else if(parsed.id()==
"unsat")
175 else if(parsed.id() ==
"unknown")
178 log.error() <<
"SMT2 solver returned \"unknown\"" <<
messaget::eom;
182 parsed.id().empty() && parsed.get_sub().size() == 1 &&
183 parsed.get_sub().front().get_sub().size() == 2)
194 parsed_values[s0.
id()] =
s1;
197 parsed.id().empty() && parsed.get_sub().size() == 2 &&
198 parsed.get_sub().front().id() ==
"error")
204 const auto &message =
id2string(parsed.get_sub()[1].id());
206 log.error() <<
"SMT2 solver returned error message:\n"
221 const irept &value = parsed_values[conv_id];
222 assignment.second.value =
parse_rec(value, assignment.second.type);
228 const std::string boolean_identifier =
231 const auto found_parsed_value =
232 parsed_values.find(
drop_quotes(boolean_identifier));
233 if(found_parsed_value != parsed_values.end())
235 return found_parsed_value->second.id() == ID_true;
238 const auto found_set_value =
set_values.find(boolean_identifier);
240 return found_set_value->second;
244 return parsed_values[boolean_identifier].id() == ID_true;
resultt
Result of running the decision procedure.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
const irep_idt & id() const
Class that provides messages with a built-in verbosity 'level'.
std::size_t number_of_solver_calls
void write_footer()
Writes the end of the SMT file to the smt_convt::out stream.
static std::string convert_identifier(const irep_idt &identifier)
std::unordered_map< irep_idt, bool > set_values
The values which boolean identifiers have been smt2_convt::set_to or in other words those which are a...
exprt parse_rec(const irept &s, const typet &type)
std::vector< bool > boolean_assignment
identifier_mapt identifier_map
std::size_t no_boolean_variables
message_handlert & message_handler
std::string decision_procedure_text() const override
Return a textual description of the decision procedure.
resultt dec_solve() override
Run the decision procedure to solve the problem.
resultt read_result(std::istream &in)
std::stringstream cached_output
Everything except the footer is cached, so that output files can be rewritten with varying footers.
std::stringstream stringstream
const std::string & id2string(const irep_idt &d)
int run(const std::string &what, const std::vector< std::string > &argv)
static std::string drop_quotes(std::string src)
optionalt< irept > smt2irep(std::istream &in, message_handlert &message_handler)
returns an irep for an SMT-LIB2 expression read from a given stream returns {} when EOF is encountere...
#define UNREACHABLE
This should be used to mark dead code.