CBMC
Loading...
Searching...
No Matches
mathematical_types.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Mathematical types
4
5Author: Daniel Kroening, kroening@kroening.com
6 Maria Svorenova, maria.svorenova@diffblue.com
7
8\*******************************************************************/
9
12
13#include "mathematical_types.h"
14
15#include "std_expr.h"
16
19bool is_number(const typet &type)
20{
21 const irep_idt &id = type.id();
22 return id == ID_rational || id == ID_real || id == ID_integer ||
23 id == ID_natural || id == ID_complex || id == ID_unsignedbv ||
24 id == ID_signedbv || id == ID_floatbv || id == ID_fixedbv;
25}
26
31
33{
34 return constant_exprt{ID_1, *this};
35}
36
41
43{
44 return constant_exprt{ID_1, *this};
45}
46
51
56
58{
59 return constant_exprt{ID_0, *this};
60}
61
63{
64 return constant_exprt{ID_1, *this};
65}
66
67bool integer_range_typet::includes(const mp_integer &singleton) const
68{
69 return from() <= singleton && singleton <= to();
70}
71
77
83
88
93
98
103
105{
106 auto difference = to() - from();
107 return difference >= 0 ? difference + 1 : 0;
108}
109
111{
112 return to() < from();
113}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:566
A constant literal expression.
Definition std_expr.h:3007
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
constant_exprt zero_expr() const
constant_exprt one_expr() const
bool includes(const mp_integer &) const
mp_integer size() const
mp_integer from() const
mp_integer to() const
constant_exprt one_expr() const
constant_exprt zero_expr() const
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:412
const irep_idt & id() const
Definition irep.h:388
const std::string & get_string(const irep_idt &name) const
Definition irep.h:401
constant_exprt zero_expr() const
constant_exprt one_expr() const
constant_exprt zero_expr() const
constant_exprt one_expr() const
constant_exprt zero_expr() const
constant_exprt one_expr() const
The type of an expression, extends irept.
Definition type.h:29
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
Mathematical types.
const mp_integer string2integer(const std::string &n, unsigned base)
Definition mp_arith.cpp:54
const std::string integer2string(const mp_integer &n, unsigned base)
Definition mp_arith.cpp:103
#define PRECONDITION(CONDITION)
Definition invariant.h:463
API to expression classes.