26 return "External SAT solver";
42 std::ofstream out(cnf_file);
53 for(
const auto &literal : assumptions)
55 if(!literal.is_constant())
56 out << literal.dimacs() <<
" 0\n";
65 std::ostringstream response_ostream;
66 auto cmd_result =
run(
solver_cmd, {
"", cnf_file},
"", response_ostream,
"");
69 return response_ostream.str();
74 std::istringstream response_istream(solver_output);
77 std::vector<bool> assigned_variables(
no_variables(),
false);
80 while(getline(response_istream, line))
87 log.
error() <<
"external SAT solver has provided an unexpected "
88 "response in results.\nUnexpected response: "
93 auto status = parts[1];
95 if(status ==
"UNSATISFIABLE")
99 if(status ==
"SATISFIABLE")
103 if(status ==
"TIMEOUT")
112 auto assignments =
split_string(line,
' ',
false,
true);
116 assignments.erase(assignments.begin());
118 for(
auto &assignment_string : assignments)
122 signed long long as_long = std::stoll(assignment_string);
125 if(index >= number_of_variables)
127 log.
error() <<
"SAT assignment " << as_long
128 <<
" out of range of CBMC largest variable of "
133 assigned_variables[index] =
true;
137 log.
error() <<
"SAT assignment " << assignment_string
138 <<
" caused an exception while processing"
152 for(size_t index = 1; index < no_variables(); index++)
155 if(!assigned_variables[index])
157 mstream <<
"No assignment was found for literal: " << index
165 log.error() <<
"external SAT solver has provided an unexpected response"
167 return resultt::P_ERROR;
174 std::find(assumptions.begin(), assumptions.end(),
const_literal(
false)) !=
size_t no_clauses() const override
virtual size_t no_variables() const override
static void write_dimacs_clause(const bvt &, std::ostream &, bool break_lines)
resultt do_prop_solve(const bvt &assumptions) override
std::string execute_solver(std::string)
external_satt(message_handlert &message_handler, std::string cmd)
std::string solver_text() const override
void set_assignment(literalt, bool) override
void write_cnf_file(std::string, const bvt &)
bool is_in_conflict(literalt) const override
Returns true if an assumption is in the final conflict.
resultt parse_result(std::string)
mstreamt & status() const
void conditional_output(mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
Generate output to message_stream using output_generator if the configured verbosity is at least as h...
Allows calling an external SAT solver to allow faster integration of newer SAT solvers.
std::vector< literalt > bvt
literalt const_literal(bool value)
int run(const std::string &what, const std::vector< std::string > &argv)
long long int llabs(long long int i)
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)