cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
satcheck_zcore.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
satcheck_zcore.h
"
10
11
#include <fstream>
12
13
#include <
util/invariant.h
>
14
#include <
util/string2int.h
>
15
16
#include <cstring>
17
18
satcheck_zcoret::satcheck_zcoret
()
19
{
20
}
21
22
satcheck_zcoret::~satcheck_zcoret
()
23
{
24
}
25
26
tvt
satcheck_zcoret::l_get
(
literalt
a)
const
27
{
28
UNREACHABLE
;
29
return
tvt
(
tvt::tv_enumt::TV_UNKNOWN
);
30
}
31
32
std::string
satcheck_zcoret::solver_text
()
const
33
{
34
return
"ZCore"
;
35
}
36
37
propt::resultt
satcheck_zcoret::do_prop_solve
(
const
bvt
&assumptions)
38
{
39
PRECONDITION
(assumptions.empty());
40
41
// We start counting at 1, thus there is one variable fewer.
42
{
43
std::string msg=
44
std::to_string(
no_variables
()-1)+
" variables, "
+
45
std::to_string(
no_clauses
())+
" clauses"
;
46
log
.statistics() << msg <<
messaget::eom
;
47
}
48
49
// get the core
50
std::string cnf_file=
"cnf.dimacs"
;
51
std::string core_file=
"unsat_core.cnf"
;
52
std::string trace_file=
"resolve_trace"
;
53
std::string output_file=
"cnf.out"
;
54
55
{
56
std::ofstream out(cnf_file.c_str(), std::ios::out);
57
write_dimacs_cnf
(out);
58
}
59
60
// generate resolve_trace
61
system(std::string(
"zchaff_verify "
+cnf_file+
" > "
+output_file).c_str());
62
63
// get core
64
system(
65
std::string(
"zcore "
+cnf_file+
" "
+trace_file+
" >> "
+output_file).c_str());
66
67
in_core
.clear();
68
69
// read result
70
{
71
std::ifstream in(core_file.c_str());
72
73
while
(
true
)
74
{
75
std::string line;
76
if
(!std::getline(in, line))
77
break
;
78
79
if
(!(line.substr(0, 1)==
"c"
|| line.substr(0, 1)==
"p"
))
80
{
81
const
char
*p=line.c_str();
82
83
while
(
true
)
84
{
85
int
l=unsafe_str2int(p);
86
if
(l==0)
87
break
;
88
89
if
(l<0)
90
l=-l;
91
92
in_core
.insert(l);
93
94
// next one
95
const
char
*q=strchr(p,
' '
);
96
while
(*q==
' '
) q++;
97
if
(q==NULL)
98
break
;
99
p=q;
100
}
101
}
102
}
103
}
104
105
if
(
in_core
.empty())
106
return
P_ERROR
;
107
108
remove(cnf_file.c_str());
109
// remove(core_file.c_str());
110
remove(trace_file.c_str());
111
// remove(output_file.c_str());
112
113
return
P_UNSATISFIABLE
;
114
}
cnf_clause_listt::no_clauses
size_t no_clauses() const override
Definition
cnf_clause_list.h:42
cnft::no_variables
virtual size_t no_variables() const override
Definition
cnf.h:42
dimacs_cnft::write_dimacs_cnf
virtual void write_dimacs_cnf(std::ostream &out) const
Definition
dimacs_cnf.cpp:38
literalt
Definition
literal.h:26
messaget::eom
static eomt eom
Definition
message.h:289
propt::resultt
resultt
Definition
prop.h:101
propt::resultt::P_UNSATISFIABLE
@ P_UNSATISFIABLE
Definition
prop.h:101
propt::resultt::P_ERROR
@ P_ERROR
Definition
prop.h:101
propt::log
messaget log
Definition
prop.h:134
satcheck_zcoret::do_prop_solve
resultt do_prop_solve(const bvt &assumptions) override
Definition
satcheck_zcore.cpp:37
satcheck_zcoret::l_get
tvt l_get(literalt a) const override
Definition
satcheck_zcore.cpp:26
satcheck_zcoret::~satcheck_zcoret
virtual ~satcheck_zcoret()
Definition
satcheck_zcore.cpp:22
satcheck_zcoret::satcheck_zcoret
satcheck_zcoret()
Definition
satcheck_zcore.cpp:18
satcheck_zcoret::in_core
std::set< unsigned > in_core
Definition
satcheck_zcore.h:34
satcheck_zcoret::solver_text
std::string solver_text() const override
Definition
satcheck_zcore.cpp:32
tvt
Definition
threeval.h:20
tvt::tv_enumt::TV_UNKNOWN
@ TV_UNKNOWN
Definition
threeval.h:23
bvt
std::vector< literalt > bvt
Definition
literal.h:201
satcheck_zcore.h
invariant.h
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition
invariant.h:525
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
string2int.h
solvers
sat
satcheck_zcore.cpp
Generated by
1.17.0