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 "type.h"
19
20class constant_exprt;
21
23class integer_typet : public typet
24{
25public:
29
32};
33
35class natural_typet : public typet
36{
37public:
41
44};
45
47class rational_typet : public typet
48{
49public:
53
56};
57
59class real_typet : public typet
60{
61public:
63 {
64 }
65
68};
69
73{
74public:
75 // the domain of the function is composed of zero, one, or
76 // many variables, given by their type
77 using domaint = std::vector<typet>;
78
85
87 {
88 return (domaint &)to_type_with_subtypes(subtypes()[0]).subtypes();
89 }
90
91 const domaint &domain() const
92 {
93 return (const domaint &)to_type_with_subtypes(subtypes()[0]).subtypes();
94 }
95
96 void add_variable(const typet &_type)
97 {
98 domain().push_back(_type);
99 }
100
104 {
105 return subtypes()[1];
106 }
107
109 const typet &codomain() const
110 {
111 return subtypes()[1];
112 }
113};
114
118template <>
120{
121 return type.id() == ID_mathematical_function;
122}
123
132inline const mathematical_function_typet &
138
145
146bool is_number(const typet &type);
147
148#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:562
A constant literal expression.
Definition std_expr.h:3117
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.
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< mathematical_function_typet >(const typet &type)
Check whether a reference to a typet is a mathematical_function_typet.
#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