cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
bv_refinement_loop.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 "
bv_refinement.h
"
10
11
#include <
util/xml.h
>
12
13
bv_refinementt::bv_refinementt
(
const
infot
&info)
14
:
bv_pointerst
(*info.
ns
, *info.
prop
, *info.
message_handler
),
15
progress
(false),
16
config_
(info)
17
{
18
// check features we need
19
PRECONDITION
(
prop
.has_assumptions());
20
PRECONDITION
(
prop
.has_set_to());
21
PRECONDITION
(
prop
.has_is_in_conflict());
22
}
23
24
decision_proceduret::resultt
bv_refinementt::dec_solve
(
const
exprt
&assumption)
25
{
26
// do the usual post-processing
27
log
.progress() <<
"BV-Refinement: post-processing"
<<
messaget::eom
;
28
finish_eager_conversion
();
29
30
log
.debug() <<
"Solving with "
<<
prop
.solver_text() <<
messaget::eom
;
31
32
unsigned
iteration=0;
33
34
// now enter the loop
35
while
(
true
)
36
{
37
iteration++;
38
39
log
.progress() <<
"BV-Refinement: iteration "
<< iteration <<
messaget::eom
;
40
41
// output the very same information in a structured fashion
42
if
(
config_
.output_xml)
43
{
44
xmlt
xml
(
"refinement-iteration"
);
45
xml
.data=std::to_string(iteration);
46
log
.status() <<
xml
<<
'\n'
;
47
}
48
49
switch
(
prop_solve
())
50
{
51
case
resultt::D_SATISFIABLE
:
52
check_SAT
();
53
if
(!
progress
)
54
{
55
log
.status() <<
"BV-Refinement: got SAT, and it simulates => SAT"
56
<<
messaget::eom
;
57
log
.statistics() <<
"Total iterations: "
<< iteration <<
messaget::eom
;
58
return
resultt::D_SATISFIABLE
;
59
}
60
else
61
log
.progress() <<
"BV-Refinement: got SAT, and it is spurious, refining"
62
<<
messaget::eom
;
63
break
;
64
65
case
resultt::D_UNSATISFIABLE
:
66
check_UNSAT
();
67
if
(!
progress
)
68
{
69
log
.status()
70
<<
"BV-Refinement: got UNSAT, and the proof passes => UNSAT"
71
<<
messaget::eom
;
72
log
.statistics() <<
"Total iterations: "
<< iteration <<
messaget::eom
;
73
return
resultt::D_UNSATISFIABLE
;
74
}
75
else
76
log
.progress()
77
<<
"BV-Refinement: got UNSAT, and the proof fails, refining"
78
<<
messaget::eom
;
79
break
;
80
81
case
resultt::D_ERROR
:
82
return
resultt::D_ERROR
;
83
}
84
}
85
}
86
87
decision_proceduret::resultt
bv_refinementt::prop_solve
()
88
{
89
// this puts the underapproximations into effect
90
std::vector<exprt> assumptions;
91
92
for
(
const
approximationt
&approximation :
approximations
)
93
{
94
assumptions.insert(
95
assumptions.end(),
96
approximation.over_assumptions.begin(),
97
approximation.over_assumptions.end());
98
assumptions.insert(
99
assumptions.end(),
100
approximation.under_assumptions.begin(),
101
approximation.under_assumptions.end());
102
}
103
104
push
(assumptions);
105
propt::resultt
result =
prop
.prop_solve(
assumption_stack
);
106
pop
();
107
108
// clang-format off
109
switch
(result)
110
{
111
case
propt::resultt::P_SATISFIABLE
:
return
resultt::D_SATISFIABLE
;
112
case
propt::resultt::P_UNSATISFIABLE
:
return
resultt::D_UNSATISFIABLE
;
113
case
propt::resultt::P_ERROR
:
return
resultt::D_ERROR
;
114
}
115
// clang-format off
116
117
UNREACHABLE
;
118
}
119
120
void
bv_refinementt::check_SAT
()
121
{
122
progress
=
false
;
123
124
arrays_overapproximated
();
125
126
// get values before modifying the formula
127
for
(
approximationt
&approximation : this->
approximations
)
128
get_values
(approximation);
129
130
for
(
approximationt
&approximation : this->approximations)
131
check_SAT
(approximation);
132
}
133
134
void
bv_refinementt::check_UNSAT
()
135
{
136
progress
=
false
;
137
138
for
(
approximationt
&approximation : this->
approximations
)
139
check_UNSAT
(approximation);
140
}
bv_refinement.h
Abstraction Refinement Loop.
arrayst::ns
const namespacet & ns
Definition
arrays.h:63
arrayst::message_handler
message_handlert & message_handler
Definition
arrays.h:65
arrayst::log
messaget log
Definition
arrays.h:64
bv_pointerst::finish_eager_conversion
void finish_eager_conversion() override
Definition
bv_pointers.cpp:1005
bv_pointerst::bv_pointerst
bv_pointerst(const namespacet &, propt &, message_handlert &, bool get_array_constraints=false)
Definition
bv_pointers.cpp:227
bv_refinementt::prop_solve
resultt prop_solve()
Definition
bv_refinement_loop.cpp:87
bv_refinementt::dec_solve
decision_proceduret::resultt dec_solve(const exprt &) override
Implementation of the decision procedure.
Definition
bv_refinement_loop.cpp:24
bv_refinementt::bv_refinementt
bv_refinementt(const infot &info)
Definition
bv_refinement_loop.cpp:13
bv_refinementt::progress
bool progress
Definition
bv_refinement.h:107
bv_refinementt::check_SAT
void check_SAT()
Definition
bv_refinement_loop.cpp:120
bv_refinementt::config_
configt config_
Definition
bv_refinement.h:112
bv_refinementt::arrays_overapproximated
void arrays_overapproximated()
check whether counterexample is spurious
Definition
refine_arrays.cpp:36
bv_refinementt::get_values
void get_values(approximationt &approximation)
Definition
refine_arithmetic.cpp:136
bv_refinementt::check_UNSAT
void check_UNSAT()
Definition
bv_refinement_loop.cpp:134
bv_refinementt::approximations
std::list< approximationt > approximations
Definition
bv_refinement.h:108
decision_proceduret::resultt
resultt
Result of running the decision procedure.
Definition
decision_procedure.h:45
decision_proceduret::resultt::D_ERROR
@ D_ERROR
Definition
decision_procedure.h:48
decision_proceduret::resultt::D_UNSATISFIABLE
@ D_UNSATISFIABLE
Definition
decision_procedure.h:47
decision_proceduret::resultt::D_SATISFIABLE
@ D_SATISFIABLE
Definition
decision_procedure.h:46
exprt
Base class for all expressions.
Definition
expr.h:57
messaget::eom
static eomt eom
Definition
message.h:289
prop_conv_solvert::pop
void pop() override
Pop whatever is on top of the stack.
Definition
prop_conv_solver.cpp:574
prop_conv_solvert::push
void push() override
Push a new context on the stack This context becomes a child context nested in the current context.
Definition
prop_conv_solver.cpp:564
prop_conv_solvert::assumption_stack
bvt assumption_stack
Assumptions on the stack.
Definition
prop_conv_solver.h:137
prop_conv_solvert::prop
propt & prop
Definition
prop_conv_solver.h:130
propt::resultt
resultt
Definition
prop.h:101
propt::resultt::P_UNSATISFIABLE
@ P_UNSATISFIABLE
Definition
prop.h:101
propt::resultt::P_SATISFIABLE
@ P_SATISFIABLE
Definition
prop.h:101
propt::resultt::P_ERROR
@ P_ERROR
Definition
prop.h:101
xmlt
Definition
xml.h:21
xml
xmlt xml(const irep_idt &property_id, const property_infot &property_info)
Definition
properties.cpp:110
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition
invariant.h:525
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
bv_refinementt::approximationt
Definition
bv_refinement.h:63
bv_refinementt::infot
Definition
bv_refinement.h:34
xml.h
solvers
refinement
bv_refinement_loop.cpp
Generated by
1.17.0