26 return "External SAT solver";
42 std::ofstream out(cnf_file);
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 reponse: "
93 auto status = parts[1];
95 if(status ==
"UNSATISFIABLE")
99 if(status ==
"SATISFIABLE")
103 if(status ==
"TIMEOUT")
116 assignments.erase(assignments.begin());
118 for(
auto &assignment_string : assignments)
122 signed long long as_long = std::stol(assignment_string);
123 size_t index = std::labs(as_long);
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 if(!assigned_variables[index])
154 log.
error() <<
"No assignment was found for literal: " << index
162 log.
error() <<
"external SAT solver has provided an unexpected response"