CBMC
Loading...
Searching...
No Matches
mathematical_types.h
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#ifndef CPROVER_UTIL_MATHEMATICAL_TYPES_H
14#define CPROVER_UTIL_MATHEMATICAL_TYPES_H
15
16#include "expr_cast.h" // IWYU pragma: keep
17#include "invariant.h"
18#include "mp_arith.h"
19#include "type.h"
20
21class constant_exprt;
22
24class integer_typet : public typet
25{
26public:
30
33};
34
36class natural_typet : public typet
37{
38public:
42
45};
46
48class rational_typet : public typet
49{
50public:
54
57};
58
60class real_typet : public typet
61{
62public:
64 {
65 }
66
69};
70
74{
75public:
76 // the domain of the function is composed of zero, one, or
77 // many variables, given by their type
78 using domaint = std::vector<typet>;
79
86
88 {
89 return (domaint &)to_type_with_subtypes(subtypes()[0]).subtypes();
90 }
91
92 const domaint &domain() const
93 {
94 return (const domaint &)to_type_with_subtypes(subtypes()[0]).subtypes();
95 }
96
97 void add_variable(const typet &_type)
98 {
99 domain().push_back(_type);
100 }
101
105 {
106 return subtypes()[1];
107 }
108
110 const typet &codomain() const
111 {
112 return subtypes()[1];
113 }
114};
115
119template <>
121{
122 return type.id() == ID_mathematical_function;
123}
124
133inline const mathematical_function_typet &
139
146
150{
151public:
153 : typet(ID_range)
154 {
155 from(_from);
156 to(_to);
157 }
158
160 mp_integer from() const;
161
163 mp_integer to() const;
164
167 bool includes(const mp_integer &) const;
168
173
177 constant_exprt one_expr() const;
178
181 mp_integer size() const;
182
185 bool empty() const;
186
187 void from(const mp_integer &);
188 void to(const mp_integer &);
189};
190
194template <>
196{
197 return type.id() == ID_range;
198}
199
209{
211 return static_cast<const integer_range_typet &>(type);
212}
213
216{
218 return static_cast<integer_range_typet &>(type);
219}
220
221bool is_number(const typet &type);
222
223#endif // CPROVER_UTIL_MATHEMATICAL_TYPES_H
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
A type for closed integer intervals [from, to].
constant_exprt zero_expr() const
constant_exprt one_expr() const
bool includes(const mp_integer &) const
integer_range_typet(const mp_integer &_from, const mp_integer &_to)
mp_integer size() const
mp_integer from() const
mp_integer to() const
Unbounded, signed integers (mathematical integers, not bitvectors)
constant_exprt one_expr() const
constant_exprt zero_expr() const
const irep_idt & id() const
Definition irep.h:388
A type for mathematical functions (do not confuse with functions/methods in code)
const domaint & domain() const
const typet & codomain() const
Return the codomain, i.e., the set of values that the function maps to (the "target").
typet & codomain()
Return the codomain, i.e., the set of values that the function maps to (the "target").
void add_variable(const typet &_type)
mathematical_function_typet(const domaint &_domain, const typet &_codomain)
Natural numbers including zero (mathematical integers, not bitvectors)
constant_exprt zero_expr() const
constant_exprt one_expr() const
Unbounded, signed rational numbers.
constant_exprt zero_expr() const
constant_exprt one_expr() const
Unbounded, signed real numbers.
constant_exprt zero_expr() const
constant_exprt one_expr() const
Type with multiple subtypes.
Definition type.h:222
subtypest & subtypes()
Definition type.h:237
The type of an expression, extends irept.
Definition type.h:29
Templated functions to cast to specific exprt-derived classes.
const integer_range_typet & to_integer_range_type(const typet &type)
Cast a typet to a integer_range_typet.
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
const mathematical_function_typet & to_mathematical_function_type(const typet &type)
Cast a typet to a mathematical_function_typet.
bool can_cast_type< integer_range_typet >(const typet &type)
Check whether a reference to a typet is a integer_range_typet.
bool can_cast_type< mathematical_function_typet >(const typet &type)
Check whether a reference to a typet is a mathematical_function_typet.
BigInt mp_integer
Definition smt_terms.h:17
#define PRECONDITION(CONDITION)
Definition invariant.h:463
Defines typet, type_with_subtypet and type_with_subtypest.
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Definition type.h:252
dstringt irep_idt