CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
smt_responses.cpp
Go to the documentation of this file.
1// Author: Diffblue Ltd.
2
3#include "smt_responses.h"
4
5#include <util/range.h>
6
7// Define the irep_idts for responses.
8#define RESPONSE_ID(the_id, the_base) \
9 const irep_idt ID_smt_##the_id##_response{"smt_" #the_id "_response"};
10#include "smt_responses.def"
11
12#undef RESPONSE_ID
13
15{
16 return irept::operator==(other);
17}
18
20{
21 return !(*this == other);
22}
23
24#define RESPONSE_ID(the_id, the_base) \
25 template <> \
26 const smt_##the_id##_responset *the_base::cast<smt_##the_id##_responset>() \
27 const & \
28 { \
29 return id() == ID_smt_##the_id##_response \
30 ? static_cast<const smt_##the_id##_responset *>(this) \
31 : nullptr; \
32 }
33#include "smt_responses.def" // NOLINT(build/include)
34#undef RESPONSE_ID
35
36template <typename sub_classt>
38{
39 return nullptr;
40}
41
47
49 const smt_check_sat_response_kindt &other) const
50{
51 return !(*this == other);
52}
53
58
96
103
108
110 smt_termt descriptor,
111 smt_termt value)
112{
113 INVARIANT(
114 descriptor.get_sort() == value.get_sort(),
115 "SMT valuation pair must have matching sort for the descriptor and value.");
116 get_sub().push_back(upcast(std::move(descriptor)));
117 get_sub().push_back(upcast(std::move(value)));
118}
119
121 irep_idt descriptor,
122 const smt_termt &value)
123 : valuation_pairt(smt_identifier_termt{descriptor, value.get_sort()}, value)
124{
125}
126
131
133{
134 return downcast(get_sub().at(1));
135}
136
142
145{
146 return !(*this == other);
147}
148
150 std::vector<valuation_pairt> pairs)
152{
153 // SMT-LIB standard version 2.6 requires one or more pairs.
154 // See page 47, figure 3.9: Command responses.
155 INVARIANT(
156 !pairs.empty(), "Get value response must contain one or more pairs.");
157 for(auto &pair : pairs)
158 {
159 get_sub().push_back(std::move(pair));
160 }
161}
162
163std::vector<
164 std::reference_wrapper<const smt_get_value_responset::valuation_pairt>>
166{
167 return make_range(get_sub()).map([](const irept &pair) {
168 return std::cref(static_cast<const valuation_pairt &>(pair));
169 });
170}
171
176
182
184{
185 return get(ID_value);
186}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition irep.h:364
bool operator==(const irept &other) const
Definition irep.cpp:133
const irept & find(const irep_idt &name) const
Definition irep.cpp:93
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:44
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:412
subt & get_sub()
Definition irep.h:448
static irept upcast(smt_check_sat_response_kindt check_sat_response_kind)
static const smt_check_sat_response_kindt & downcast(const irept &)
bool operator==(const smt_check_sat_response_kindt &) const
bool operator!=(const smt_check_sat_response_kindt &) const
smt_check_sat_responset(smt_check_sat_response_kindt kind)
const smt_check_sat_response_kindt & kind() const
const irep_idt & message() const
smt_error_responset(irep_idt message)
bool operator==(const valuation_pairt &) const
bool operator!=(const valuation_pairt &) const
smt_get_value_responset(std::vector< valuation_pairt > pairs)
std::vector< std::reference_wrapper< const valuation_pairt > > pairs() const
Stores identifiers in unescaped and unquoted form.
Definition smt_terms.h:93
bool operator!=(const smt_responset &) const
bool operator==(const smt_responset &) const
const sub_classt * cast() const &
static irept upcast(smt_termt term)
Definition smt_terms.h:65
static const smt_termt & downcast(const irept &)
Definition smt_terms.h:71
Ranges: pair of begin and end iterators, which can be initialized from containers,...
ranget< iteratort > make_range(iteratort begin, iteratort end)
Definition range.h:522
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423