cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
smt_array_theory.cpp
Go to the documentation of this file.
1
// Author: Diffblue Ltd.
2
3
#include "
smt_array_theory.h
"
4
5
const
char
*
smt_array_theoryt::selectt::identifier
()
6
{
7
return
"select"
;
8
}
9
10
smt_sortt
smt_array_theoryt::selectt::return_sort
(
11
const
smt_termt
&array,
12
const
smt_termt
&index)
13
{
14
return
array.
get_sort
().
cast
<
smt_array_sortt
>()->element_sort();
15
}
16
17
std::vector<std::string>
smt_array_theoryt::selectt::validation_errors
(
18
const
smt_termt
&array,
19
const
smt_termt
&index)
20
{
21
const
auto
array_sort = array.
get_sort
().
cast
<
smt_array_sortt
>();
22
if
(!array_sort)
23
return
{
"\"select\" may only select from an array."
};
24
if
(array_sort->index_sort() != index.
get_sort
())
25
return
{
"Sort of arrays index must match the sort of the index supplied."
};
26
return
{};
27
}
28
29
void
smt_array_theoryt::selectt::validate
(
30
const
smt_termt
&array,
31
const
smt_termt
&index)
32
{
33
const
auto
validation_errors
=
selectt::validation_errors
(array, index);
34
INVARIANT
(
validation_errors
.empty(),
validation_errors
[0]);
35
}
36
37
const
smt_function_application_termt::factoryt<smt_array_theoryt::selectt>
38
smt_array_theoryt::select
{};
39
40
const
char
*
smt_array_theoryt::storet::identifier
()
41
{
42
return
"store"
;
43
}
44
smt_sortt
smt_array_theoryt::storet::return_sort
(
45
const
smt_termt
&array,
46
const
smt_termt
&index,
47
const
smt_termt
&value)
48
{
49
return
array.
get_sort
();
50
}
51
void
smt_array_theoryt::storet::validate
(
52
const
smt_termt
&array,
53
const
smt_termt
&index,
54
const
smt_termt
&value)
55
{
56
const
auto
array_sort = array.
get_sort
().
cast
<
smt_array_sortt
>();
57
INVARIANT
(array_sort,
"\"store\" may only update an array."
);
58
INVARIANT
(
59
array_sort->index_sort() == index.
get_sort
(),
60
"Sort of arrays index must match the sort of the index supplied."
);
61
INVARIANT
(
62
array_sort->element_sort() == value.
get_sort
(),
63
"Sort of arrays value must match the sort of the value supplied."
);
64
}
65
66
const
smt_function_application_termt::factoryt<smt_array_theoryt::storet>
67
smt_array_theoryt::store
{};
smt_array_sortt
Definition
smt_sorts.h:91
smt_array_theoryt::store
static const smt_function_application_termt::factoryt< storet > store
Definition
smt_array_theory.h:67
smt_array_theoryt::select
static const smt_function_application_termt::factoryt< selectt > select
Definition
smt_array_theory.h:38
smt_function_application_termt::factoryt
Definition
smt_terms.h:173
smt_sortt
Definition
smt_sorts.h:18
smt_sortt::cast
const sub_classt * cast() const &
smt_termt
Definition
smt_terms.h:21
smt_termt::get_sort
const smt_sortt & get_sort() const
Definition
smt_terms.cpp:36
smt_array_theory.h
INVARIANT
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition
invariant.h:423
smt_array_theoryt::selectt::identifier
static const char * identifier()
Definition
smt_array_theory.cpp:5
smt_array_theoryt::selectt::return_sort
static smt_sortt return_sort(const smt_termt &array, const smt_termt &index)
Definition
smt_array_theory.cpp:10
smt_array_theoryt::selectt::validate
static void validate(const smt_termt &array, const smt_termt &index)
Definition
smt_array_theory.cpp:29
smt_array_theoryt::selectt::validation_errors
static std::vector< std::string > validation_errors(const smt_termt &array, const smt_termt &index)
Definition
smt_array_theory.cpp:17
smt_array_theoryt::storet::identifier
static const char * identifier()
Definition
smt_array_theory.cpp:40
smt_array_theoryt::storet::validate
static void validate(const smt_termt &array, const smt_termt &index, const smt_termt &value)
Definition
smt_array_theory.cpp:51
smt_array_theoryt::storet::return_sort
static smt_sortt return_sort(const smt_termt &array, const smt_termt &index, const smt_termt &value)
Definition
smt_array_theory.cpp:44
solvers
smt2_incremental
theories
smt_array_theory.cpp
Generated by
1.17.0