CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qbf_quantor.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "qbf_quantor.h"
10
11#include <cstdlib>
12#include <fstream>
13
14#include <util/invariant.h>
15
17 : qdimacs_cnft(message_handler)
18{
19}
20
24
29
30std::string qbf_quantort::solver_text() const
31{
32 return "Quantor";
33}
34
36{
37 {
38 log.status() << "Quantor: " << no_variables() << " variables, "
39 << no_clauses() << " clauses" << messaget::eom;
40 }
41
42 std::string qbf_tmp_file="quantor.qdimacs";
43 std::string result_tmp_file="quantor.out";
44
45 {
46 std::ofstream out(qbf_tmp_file.c_str());
47
48 // write it
50 }
51
52 // solve it
53 int res=system((
54 "quantor "+qbf_tmp_file+" -o "+result_tmp_file).c_str());
55 CHECK_RETURN(0==res);
56
57 bool result=false;
58
59 // read result
60 {
61 std::ifstream in(result_tmp_file.c_str());
62
63 bool result_found=false;
64 while(in)
65 {
66 std::string line;
67
68 std::getline(in, line);
69
70 if(!line.empty() && line[line.size() - 1] == '\r')
71 line.resize(line.size()-1);
72
73 if(line=="s TRUE")
74 {
75 result=true;
76 result_found=true;
77 break;
78 }
79 else if(line=="s FALSE")
80 {
81 result=false;
82 result_found=true;
83 break;
84 }
85 }
86
87 if(!result_found)
88 {
89 log.error() << "Quantor failed: unknown result" << messaget::eom;
90 return resultt::P_ERROR;
91 }
92 }
93
94 if(result)
95 {
96 log.status() << "Quantor: TRUE" << messaget::eom;
98 }
99 else
100 {
101 log.status() << "Quantor: FALSE" << messaget::eom;
103 }
104
105 return resultt::P_ERROR;
106}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
size_t no_clauses() const override
virtual size_t no_variables() const override
Definition cnf.h:42
mstreamt & error() const
Definition message.h:391
static eomt eom
Definition message.h:289
mstreamt & status() const
Definition message.h:406
resultt
Definition prop.h:101
messaget log
Definition prop.h:134
qbf_quantort(message_handlert &message_handler)
virtual resultt prop_solve()
tvt l_get(literalt a) const override
~qbf_quantort() override
std::string solver_text() const override
virtual void write_qdimacs_cnf(std::ostream &out)
Definition threeval.h:20
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495
#define UNREACHABLE
This should be used to mark dead code.
Definition invariant.h:525