-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathbv_refinement.h
115 lines (88 loc) · 2.77 KB
/
bv_refinement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*******************************************************************\
Module: Abstraction Refinement Loop
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Abstraction Refinement Loop
#ifndef CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H
#define CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H
#include <solvers/flattening/bv_pointers.h>
#define MAX_STATE 10000
class bv_refinementt:public bv_pointerst
{
private:
struct configt
{
bool output_xml = false;
/// Max number of times we refine a formula node
unsigned max_node_refinement=5;
/// Enable array refinement
bool refine_arrays=true;
/// Enable arithmetic refinement
bool refine_arithmetic=true;
};
public:
struct infot:public configt
{
const namespacet *ns=nullptr;
propt *prop=nullptr;
message_handlert *message_handler = nullptr;
};
explicit bv_refinementt(const infot &info);
decision_proceduret::resultt dec_solve(const exprt &) override;
std::string decision_procedure_text() const override
{
return "refinement loop with "+prop.solver_text();
}
protected:
// Refine array
void finish_eager_conversion_arrays() override;
// Refine arithmetic
bvt convert_mult(const mult_exprt &expr) override;
bvt convert_div(const div_exprt &expr) override;
bvt convert_mod(const mod_exprt &expr) override;
bvt convert_floatbv_op(const ieee_float_op_exprt &) override;
private:
// the list of operator approximations
struct approximationt final
{
public:
explicit approximationt(std::size_t _id_nr):
no_operands(0),
under_state(0),
over_state(0),
id_nr(_id_nr)
{
}
exprt expr;
std::size_t no_operands;
bvt op0_bv, op1_bv, op2_bv, result_bv;
mp_integer op0_value, op1_value, op2_value, result_value;
std::vector<exprt> under_assumptions;
std::vector<exprt> over_assumptions;
// the kind of under- or over-approximation
unsigned under_state, over_state;
std::string as_string() const;
void add_over_assumption(literalt l);
void add_under_assumption(literalt l);
std::size_t id_nr;
};
resultt prop_solve();
approximationt &add_approximation(const exprt &expr, bvt &bv);
bool conflicts_with(approximationt &approximation);
void check_SAT(approximationt &approximation);
void check_UNSAT(approximationt &approximation);
void initialize(approximationt &approximation);
void get_values(approximationt &approximation);
void check_SAT();
void check_UNSAT();
void arrays_overapproximated();
void freeze_lazy_constraints();
// MEMBERS
bool progress;
std::list<approximationt> approximations;
protected:
// use gui format
configt config_;
};
#endif // CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H