dReal4
command_cell.h
1 #pragma once
2 
3 #include <ostream>
4 #include <string>
5 #include <utility>
6 
7 #include "dreal/smt2/command.h"
9 
10 namespace dreal {
11 
12 /// CommandCell class. It is the abstract base class of the classes
13 /// representing smt2lib commands.
14 class CommandCell {
15  public:
16  /// Default constructor.
17  CommandCell() = default;
18 
19  /// Deleted copy-constructor.
20  CommandCell(const CommandCell&) = delete;
21 
22  /// Deleted move-constructor.
23  CommandCell(CommandCell&&) = default;
24 
25  /// Deleted copy-assignment operator.
26  CommandCell& operator=(const CommandCell&) = delete;
27 
28  /// Deleted move-assignment operator.
29  CommandCell& operator=(CommandCell&&) = delete;
30 
31  /// Default destructor.
32  virtual ~CommandCell() = default;
33  /// Output its string representation to @p os.
34  virtual std::ostream& Display(std::ostream& os) const = 0;
35 };
36 
37 /// "assert" command.
38 class AssertCommand : public CommandCell {
39  public:
40  explicit AssertCommand(Formula f) : f_{std::move(f)} {};
41  const Formula& get_assertion() const { return f_; }
42  std::ostream& Display(std::ostream& os) const override;
43 
44  private:
45  const Formula f_;
46 };
47 
48 /// "check-sat" command.
49 class CheckSatCommand : public CommandCell {
50  public:
51  CheckSatCommand() = default;
52  std::ostream& Display(std::ostream& os) const override;
53 };
54 
55 /// "echo" command.
56 class EchoCommand : public CommandCell {
57  public:
58  explicit EchoCommand(std::string message) : message_{std::move(message)} {}
59  std::string get_message() const { return message_; }
60  std::ostream& Display(std::ostream& os) const override;
61 
62  private:
63  const std::string message_;
64 };
65 
66 /// "exit" command.
67 class ExitCommand : public CommandCell {
68  public:
69  ExitCommand() = default;
70  std::ostream& Display(std::ostream& os) const override;
71 };
72 
73 /// "get-assertions" command.
75  public:
76  GetAssertionsCommand() = default;
77  std::ostream& Display(std::ostream& os) const override;
78 };
79 
80 /// "get-assignments" command.
82  public:
83  GetAssignmentCommand() = default;
84  std::ostream& Display(std::ostream& os) const override;
85 };
86 
87 /// "get-info" command.
88 class GetInfoCommand : public CommandCell {
89  public:
90  GetInfoCommand() = default;
91  std::string get_key() const { return key_; }
92  std::ostream& Display(std::ostream& os) const override;
93 
94  private:
95  const std::string key_;
96 };
97 
98 /// "get-model" command.
99 class GetModelCommand : public CommandCell {
100  public:
101  GetModelCommand() = default;
102  std::ostream& Display(std::ostream& os) const override;
103 };
104 
105 /// "get-option" command.
107  public:
108  explicit GetOptionCommand(std::string key) : key_{std::move(key)} {}
109  std::string get_key() const { return key_; }
110  std::ostream& Display(std::ostream& os) const override;
111 
112  private:
113  const std::string key_;
114 };
115 
116 /// "get-proof" command.
117 class GetProofCommand : public CommandCell {
118  public:
119  GetProofCommand() = default;
120  std::ostream& Display(std::ostream& os) const override;
121 };
122 
123 /// "get-unsat-assumptions" command.
125  public:
126  GetUnsatAssumptionsCommand() = default;
127  std::ostream& Display(std::ostream& os) const override;
128 };
129 
130 /// "get-unsat-core" command.
132  public:
133  GetUnsatCoreCommand() = default;
134  std::ostream& Display(std::ostream& os) const override;
135 };
136 
137 /// "pop" command.
138 class PopCommand : public CommandCell {
139  public:
140  explicit PopCommand(int level) : level_(level) {}
141  int get_level() const { return level_; }
142  std::ostream& Display(std::ostream& os) const override;
143 
144  private:
145  const int level_{};
146 };
147 
148 /// "push" command.
149 class PushCommand : public CommandCell {
150  public:
151  explicit PushCommand(int level) : level_(level) {}
152  int get_level() const { return level_; }
153  std::ostream& Display(std::ostream& os) const override;
154 
155  private:
156  const int level_{};
157 };
158 
159 /// "reset" command.
160 class ResetCommand : public CommandCell {
161  public:
162  ResetCommand() = default;
163  std::ostream& Display(std::ostream& os) const override;
164 };
165 
166 /// "reset-assertions" command.
168  public:
169  ResetAssertionsCommand() = default;
170  std::ostream& Display(std::ostream& os) const override;
171 };
172 
173 /// "set-info" command.
174 class SetInfoCommand : public CommandCell {
175  public:
176  SetInfoCommand(std::string key, std::string value)
177  : key_{std::move(key)}, value_{std::move(value)} {}
178  const std::string& get_key() const { return key_; }
179  const std::string& get_value() const { return value_; }
180  std::ostream& Display(std::ostream& os) const override;
181 
182  private:
183  const std::string key_;
184  const std::string value_;
185 };
186 
187 class SetLogicCommand : public CommandCell {
188  public:
189  explicit SetLogicCommand(const Logic logic) : logic_{logic} {}
190  Logic get_logic() const { return logic_; }
191  std::ostream& Display(std::ostream& os) const override;
192 
193  private:
194  const Logic logic_;
195 };
196 
198  public:
199  SetOptionCommand(std::string key, std::string value)
200  : key_{std::move(key)}, value_{std::move(value)} {}
201  std::ostream& Display(std::ostream& os) const override;
202 
203  private:
204  const std::string key_;
205  const std::string value_;
206 };
207 
208 // TODO(soonho): Add support the following cases:
209 // class CheckSatAssumingCommand : public CommandCell {};
210 // class DeclareConstCommand : public CommandCell {};
211 // class DeclareFunCommand : public CommandCell {};
212 // class DeclareSortCommand : public CommandCell {};
213 // class DefineFunCommand : public CommandCell {};
214 // class DefineFunRecCommand : public CommandCell {};
215 // class DefineFunsRecCommand : public CommandCell {};
216 // class DefineSortCommand : public CommandCell {};
217 // class GetValueCommand : public CommandCell { };
218 
219 } // namespace dreal
"exit" command.
Definition: command_cell.h:67
"check-sat" command.
Definition: command_cell.h:49
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
"set-info" command.
Definition: command_cell.h:174
"get-unsat-assumptions" command.
Definition: command_cell.h:124
CommandCell & operator=(const CommandCell &)=delete
Deleted copy-assignment operator.
"get-proof" command.
Definition: command_cell.h:117
"echo" command.
Definition: command_cell.h:56
"get-assertions" command.
Definition: command_cell.h:74
"get-unsat-core" command.
Definition: command_cell.h:131
"get-option" command.
Definition: command_cell.h:106
"reset-assertions" command.
Definition: command_cell.h:167
virtual ~CommandCell()=default
Default destructor.
"get-assignments" command.
Definition: command_cell.h:81
Definition: command_cell.h:187
"reset" command.
Definition: command_cell.h:160
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...
"get-model" command.
Definition: command_cell.h:99
"assert" command.
Definition: command_cell.h:38
"pop" command.
Definition: command_cell.h:138
"push" command.
Definition: command_cell.h:149
CommandCell()=default
Default constructor.
virtual std::ostream & Display(std::ostream &os) const =0
Output its string representation to os.
Represents a symbolic form of a first-order logic formula.
Definition: symbolic_formula.h:101
Definition: command_cell.h:197
CommandCell class.
Definition: command_cell.h:14
"get-info" command.
Definition: command_cell.h:88