-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathinterval_domain.h
123 lines (94 loc) · 2.78 KB
/
interval_domain.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
116
117
118
119
120
121
122
123
/*******************************************************************\
Module: Interval Domain
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// Interval Domain
#ifndef CPROVER_ANALYSES_INTERVAL_DOMAIN_H
#define CPROVER_ANALYSES_INTERVAL_DOMAIN_H
#include <util/ieee_float.h>
#include <util/integer_interval.h>
#include <util/interval_template.h>
#include "ai_domain.h"
typedef interval_templatet<ieee_float_valuet> ieee_float_intervalt;
class interval_domaint:public ai_domain_baset
{
public:
// Trivial, conjunctive interval domain for both float
// and integers. The categorization 'float' and 'integers'
// is done by is_int and is_float.
interval_domaint():bottom(true)
{
}
void transform(
const irep_idt &function_from,
trace_ptrt trace_from,
const irep_idt &function_to,
trace_ptrt trace_to,
ai_baset &ai,
const namespacet &ns) final override;
void output(
std::ostream &out,
const ai_baset &ai,
const namespacet &ns) const override;
protected:
bool join(const interval_domaint &b);
public:
bool merge(const interval_domaint &b, trace_ptrt, trace_ptrt)
{
return join(b);
}
// no states
void make_bottom() final override
{
int_map.clear();
float_map.clear();
bottom=true;
}
// all states
void make_top() final override
{
int_map.clear();
float_map.clear();
bottom=false;
}
bool is_bottom() const override final
{
#if 0
// This invariant should hold but is not correctly enforced at the moment.
DATA_INVARIANT(!bottom || (int_map.empty() && float_map.empty()),
"If the domain is bottom the value maps must be empty");
#endif
return bottom;
}
bool is_top() const override final
{
return !bottom && int_map.empty() && float_map.empty();
}
exprt make_expression(const symbol_exprt &) const;
void assume(const exprt &, const namespacet &);
static bool is_int(const typet &src)
{
return src.id()==ID_signedbv || src.id()==ID_unsignedbv;
}
static bool is_float(const typet &src)
{
return src.id()==ID_floatbv;
}
virtual bool ai_simplify(
exprt &condition,
const namespacet &ns) const override;
protected:
bool bottom;
typedef std::map<irep_idt, integer_intervalt> int_mapt;
typedef std::map<irep_idt, ieee_float_intervalt> float_mapt;
int_mapt int_map;
float_mapt float_map;
void havoc_rec(const exprt &);
void assume_rec(const exprt &, bool negation=false);
void assume_rec(const exprt &lhs, irep_idt id, const exprt &rhs);
void assign(const exprt &lhs, const exprt &rhs);
integer_intervalt get_int_rec(const exprt &);
ieee_float_intervalt get_float_rec(const exprt &);
};
#endif // CPROVER_ANALYSES_INTERVAL_DOMAIN_H