|
12 | 12 | #include <util/string_utils.h> |
13 | 13 | #include <util/tempfile.h> |
14 | 14 |
|
15 | | -#include <chrono> |
| 15 | +#include <algorithm> |
16 | 16 | #include <cstdlib> |
17 | 17 | #include <fstream> |
18 | | -#include <random> |
19 | 18 | #include <sstream> |
20 | 19 | #include <string> |
21 | | -#include <thread> |
22 | 20 |
|
23 | 21 | external_satt::external_satt(message_handlert &message_handler, std::string cmd) |
24 | 22 | : cnf_clause_list_assignmentt(message_handler), solver_cmd(std::move(cmd)) |
@@ -46,11 +44,18 @@ void external_satt::write_cnf_file(std::string cnf_file) |
46 | 44 | std::ofstream out(cnf_file); |
47 | 45 |
|
48 | 46 | // We start counting at 1, thus there is one variable fewer. |
49 | | - out << "p cnf " << (no_variables() - 1) << ' ' << no_clauses() << '\n'; |
| 47 | + out << "p cnf " << (no_variables() - 1) << ' ' |
| 48 | + << no_clauses() + assumptions.size() << '\n'; |
50 | 49 |
|
| 50 | + // output the problem clauses |
51 | 51 | for(auto &c : clauses) |
52 | 52 | dimacs_cnft::write_dimacs_clause(c, out, false); |
53 | 53 |
|
| 54 | + // output the assumption clauses |
| 55 | + forall_literals(it, assumptions) |
| 56 | + if(!it->is_constant()) |
| 57 | + out << it->dimacs() << " 0\n"; |
| 58 | + |
54 | 59 | out.close(); |
55 | 60 | } |
56 | 61 |
|
@@ -161,6 +166,14 @@ external_satt::resultt external_satt::parse_result(std::string solver_output) |
161 | 166 |
|
162 | 167 | external_satt::resultt external_satt::do_prop_solve() |
163 | 168 | { |
| 169 | + // are we assuming 'false'? |
| 170 | + if( |
| 171 | + std::find(assumptions.begin(), assumptions.end(), const_literal(false)) != |
| 172 | + assumptions.end()) |
| 173 | + { |
| 174 | + return resultt::P_UNSATISFIABLE; |
| 175 | + } |
| 176 | + |
164 | 177 | // create a temporary file |
165 | 178 | temporary_filet cnf_file("external-sat", ".cnf"); |
166 | 179 | write_cnf_file(cnf_file()); |
|
0 commit comments