cprover
interval_domain.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Interval Domain
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_ANALYSES_INTERVAL_DOMAIN_H
13 #define CPROVER_ANALYSES_INTERVAL_DOMAIN_H
14 
15 #include <util/ieee_float.h>
16 #include <util/mp_arith.h>
17 
18 #include "ai.h"
19 #include "interval_template.h"
20 
23 
25 {
26 public:
27  // Trivial, conjunctive interval domain for both float
28  // and integers. The categorization 'float' and 'integers'
29  // is done by is_int and is_float.
30 
32  {
33  }
34 
35  void transform(
36  locationt from,
37  locationt to,
38  ai_baset &ai,
39  const namespacet &ns) final;
40 
41  void output(
42  std::ostream &out,
43  const ai_baset &ai,
44  const namespacet &ns) const final;
45 
46 protected:
47  bool join(const interval_domaint &b);
48 
49 public:
50  bool merge(
51  const interval_domaint &b,
52  locationt from,
53  locationt to)
54  {
55  return join(b);
56  }
57 
58  // no states
59  void make_bottom() final
60  {
61  int_map.clear();
62  float_map.clear();
63  bottom=true;
64  }
65 
66  // all states
67  void make_top() final
68  {
69  int_map.clear();
70  float_map.clear();
71  bottom=false;
72  }
73 
74  void make_entry() final
75  {
76  make_top();
77  }
78 
79  exprt make_expression(const symbol_exprt &) const;
80 
81  void assume(const exprt &, const namespacet &);
82 
83  static bool is_int(const typet &src)
84  {
85  return src.id()==ID_signedbv || src.id()==ID_unsignedbv;
86  }
87 
88  static bool is_float(const typet &src)
89  {
90  return src.id()==ID_floatbv;
91  }
92 
93  bool is_bottom() const
94  {
95  return bottom;
96  }
97 
98  virtual bool ai_simplify(
99  exprt &condition,
100  const namespacet &ns) const override;
101 
102 protected:
103  bool bottom;
104 
105  typedef std::map<irep_idt, integer_intervalt> int_mapt;
106  typedef std::map<irep_idt, ieee_float_intervalt> float_mapt;
107 
108  int_mapt int_map;
109  float_mapt float_map;
110 
111  void havoc_rec(const exprt &);
112  void assume_rec(const exprt &, bool negation=false);
113  void assume_rec(const exprt &lhs, irep_idt id, const exprt &rhs);
114  void assign(const class code_assignt &assignment);
117 };
118 
119 #endif // CPROVER_ANALYSES_INTERVAL_DOMAIN_H
The type of an expression.
Definition: type.h:20
static bool is_float(const typet &src)
std::map< irep_idt, integer_intervalt > int_mapt
void output(std::ostream &out, const ai_baset &ai, const namespacet &ns) const final
void havoc_rec(const exprt &)
interval_templatet< mp_integer > integer_intervalt
void assume(const exprt &, const namespacet &)
bool is_bottom() const
ieee_float_intervalt get_float_rec(const exprt &)
const irep_idt & id() const
Definition: irep.h:189
void make_bottom() final
std::map< irep_idt, ieee_float_intervalt > float_mapt
void assign(const class code_assignt &assignment)
bool merge(const interval_domaint &b, locationt from, locationt to)
integer_intervalt get_int_rec(const exprt &)
TO_BE_DOCUMENTED.
Definition: namespace.h:62
interval_templatet< ieee_floatt > ieee_float_intervalt
void assume_rec(const exprt &, bool negation=false)
void transform(locationt from, locationt to, ai_baset &ai, const namespacet &ns) final
float_mapt float_map
exprt make_expression(const symbol_exprt &) const
virtual bool ai_simplify(exprt &condition, const namespacet &ns) const override
Uses the abstract state to simplify a given expression using context- specific information.
bool join(const interval_domaint &b)
Sets *this to the mathematical join between the two domains.
Abstract Interpretation.
Definition: ai.h:108
Base class for all expressions.
Definition: expr.h:46
goto_programt::const_targett locationt
Definition: ai.h:42
Expression to hold a symbol (variable)
Definition: std_expr.h:82
static bool is_int(const typet &src)
void make_entry() final
void make_top() final
Assignment.
Definition: std_code.h:144