CBMC
Loading...
Searching...
No Matches
state_encoding_targets.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: State Encoding Targets
4
5Author: Daniel Kroening, dkr@amazon.com
6
7\*******************************************************************/
8
9#ifndef CPROVER_CPROVER_STATE_ENCODING_TARGETS_H
10#define CPROVER_CPROVER_STATE_ENCODING_TARGETS_H
11
13
14#include <iosfwd>
15
17{
18public:
19 virtual void annotation(const std::string &)
20 {
21 }
22
24
25 void set_to_true(exprt expr)
26 {
27 set_to_true(source_location, std::move(expr));
28 }
29
34
35 virtual ~encoding_targett() = default;
36
37protected:
39};
40
42{
43public:
45
46 using constraintst = std::vector<exprt>;
48
50 {
53
54 constraints.emplace_back(std::move(expr));
55 }
56
57protected:
59};
60
61static inline void operator<<(encoding_targett &target, exprt constraint)
62{
63 target.set_to_true(std::move(constraint));
64}
65
66static inline void
68{
69 for(const auto &constraint : src.constraints)
70 target << constraint;
71}
72
74{
75public:
76 state_encoding_smt2_convt(const namespacet &ns, std::ostream &_out)
77 : smt2_convt(ns, "", "cprover", "", smt2_convt::solvert::GENERIC, _out)
78
79 {
80 use_array_of_bool = true;
81 use_as_const = true;
83 }
84
85 void add_converters();
86};
87
89{
90public:
91 smt2_encoding_targett(const namespacet &ns, std::ostream &_out)
92 : out(_out), smt2_conv(ns, _out)
93 {
94 }
95
97 {
98 // finish the conversion to SMT-LIB2
99 smt2_conv();
100 }
101
102 void set_to_true(source_locationt, exprt expr) override
103 {
104 smt2_conv.set_to_true(std::move(expr));
105 }
106
107 void annotation(const std::string &text) override
108 {
109 if(text.empty())
110 out << '\n';
111 else
112 out << ';' << ' ' << text << '\n';
113 }
114
115protected:
116 std::ostream &out;
118
120};
121
123{
124public:
125 explicit ascii_encoding_targett(std::ostream &_out) : out(_out)
126 {
127 }
128
129 void set_to_true(source_locationt, exprt) override;
130
131 void annotation(const std::string &text) override
132 {
133 out << text << '\n';
134 }
135
136protected:
137 std::ostream &out;
138 std::size_t counter = 0;
139};
140
141#endif // CPROVER_CPROVER_STATE_ENCODING_TARGETS_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
void annotation(const std::string &text) override
ascii_encoding_targett(std::ostream &_out)
void set_to_true(source_locationt, exprt) override
container_encoding_targett()=default
void set_to_true(source_locationt source_location, exprt expr) override
void set_to_true(const exprt &)
For a Boolean expression expr, add the constraint 'expr'.
void set_to_true(exprt expr)
virtual void annotation(const std::string &)
virtual ~encoding_targett()=default
void set_source_location(source_locationt __source_location)
virtual void set_to_true(source_locationt, exprt)=0
source_locationt source_location
Base class for all expressions.
Definition expr.h:56
source_locationt & add_source_location()
Definition expr.h:236
bool is_not_nil() const
Definition irep.h:372
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
const namespacet & ns
Definition smt2_conv.h:100
bool use_as_const
Definition smt2_conv.h:69
bool use_array_of_bool
Definition smt2_conv.h:68
void set_to_true(source_locationt, exprt expr) override
smt2_encoding_targett(const namespacet &ns, std::ostream &_out)
void annotation(const std::string &text) override
state_encoding_smt2_convt smt2_conv
static const source_locationt & nil()
state_encoding_smt2_convt(const namespacet &ns, std::ostream &_out)
static void operator<<(encoding_targett &target, exprt constraint)