1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Abdalrhman Mohamed, Tim King, Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Implementation of the command pattern on SmtEngines. |
14 |
|
* |
15 |
|
* Command objects are generated by the parser (typically) to implement the |
16 |
|
* commands in parsed input (see Parser::parseNextCommand()), or by client |
17 |
|
* code. |
18 |
|
*/ |
19 |
|
|
20 |
|
#include "cvc5_public.h" |
21 |
|
|
22 |
|
#ifndef CVC5__COMMAND_H |
23 |
|
#define CVC5__COMMAND_H |
24 |
|
|
25 |
|
#include <iosfwd> |
26 |
|
#include <sstream> |
27 |
|
#include <string> |
28 |
|
#include <vector> |
29 |
|
|
30 |
|
#include "api/cpp/cvc5.h" |
31 |
|
#include "cvc5_export.h" |
32 |
|
#include "options/language.h" |
33 |
|
|
34 |
|
namespace cvc5 { |
35 |
|
|
36 |
|
namespace api { |
37 |
|
class Solver; |
38 |
|
class Term; |
39 |
|
} // namespace api |
40 |
|
|
41 |
|
class SymbolManager; |
42 |
|
class Command; |
43 |
|
class CommandStatus; |
44 |
|
|
45 |
|
namespace smt { |
46 |
|
class Model; |
47 |
|
} |
48 |
|
|
49 |
|
/** |
50 |
|
* Convert a symbolic expression to string. This method differs from |
51 |
|
* Term::toString in that it does not depend on the output language. |
52 |
|
* |
53 |
|
* @param sexpr the symbolic expression to convert |
54 |
|
* @return the symbolic expression as string |
55 |
|
*/ |
56 |
|
std::string sexprToString(api::Term sexpr) CVC5_EXPORT; |
57 |
|
|
58 |
|
std::ostream& operator<<(std::ostream&, const Command&) CVC5_EXPORT; |
59 |
|
std::ostream& operator<<(std::ostream&, const Command*) CVC5_EXPORT; |
60 |
|
std::ostream& operator<<(std::ostream&, const CommandStatus&) CVC5_EXPORT; |
61 |
|
std::ostream& operator<<(std::ostream&, const CommandStatus*) CVC5_EXPORT; |
62 |
|
|
63 |
|
/** The status an SMT benchmark can have */ |
64 |
|
enum BenchmarkStatus |
65 |
|
{ |
66 |
|
/** Benchmark is satisfiable */ |
67 |
|
SMT_SATISFIABLE, |
68 |
|
/** Benchmark is unsatisfiable */ |
69 |
|
SMT_UNSATISFIABLE, |
70 |
|
/** The status of the benchmark is unknown */ |
71 |
|
SMT_UNKNOWN |
72 |
|
}; /* enum BenchmarkStatus */ |
73 |
|
|
74 |
|
std::ostream& operator<<(std::ostream& out, BenchmarkStatus status) CVC5_EXPORT; |
75 |
|
|
76 |
|
/** |
77 |
|
* IOStream manipulator to print success messages or not. |
78 |
|
* |
79 |
|
* out << Command::printsuccess(false) << CommandSuccess(); |
80 |
|
* |
81 |
|
* prints nothing, but |
82 |
|
* |
83 |
|
* out << Command::printsuccess(true) << CommandSuccess(); |
84 |
|
* |
85 |
|
* prints a success message (in a manner appropriate for the current |
86 |
|
* output language). |
87 |
|
*/ |
88 |
|
class CVC5_EXPORT CommandPrintSuccess |
89 |
|
{ |
90 |
|
public: |
91 |
|
/** Construct a CommandPrintSuccess with the given setting. */ |
92 |
142 |
CommandPrintSuccess(bool printSuccess) : d_printSuccess(printSuccess) {} |
93 |
|
void applyPrintSuccess(std::ostream& out); |
94 |
|
static bool getPrintSuccess(std::ostream& out); |
95 |
|
static void setPrintSuccess(std::ostream& out, bool printSuccess); |
96 |
|
|
97 |
|
private: |
98 |
|
/** The allocated index in ios_base for our depth setting. */ |
99 |
|
static const int s_iosIndex; |
100 |
|
|
101 |
|
/** |
102 |
|
* The default setting, for ostreams that haven't yet had a setdepth() |
103 |
|
* applied to them. |
104 |
|
*/ |
105 |
|
static const int s_defaultPrintSuccess = false; |
106 |
|
|
107 |
|
/** When this manipulator is used, the setting is stored here. */ |
108 |
|
bool d_printSuccess; |
109 |
|
|
110 |
|
}; /* class CommandPrintSuccess */ |
111 |
|
|
112 |
|
/** |
113 |
|
* Sets the default print-success setting when pretty-printing an Expr |
114 |
|
* to an ostream. Use like this: |
115 |
|
* |
116 |
|
* // let out be an ostream, e an Expr |
117 |
|
* out << Expr::setdepth(n) << e << endl; |
118 |
|
* |
119 |
|
* The depth stays permanently (until set again) with the stream. |
120 |
|
*/ |
121 |
|
std::ostream& operator<<(std::ostream& out, |
122 |
|
CommandPrintSuccess cps) CVC5_EXPORT; |
123 |
|
|
124 |
|
class CVC5_EXPORT CommandStatus |
125 |
|
{ |
126 |
|
protected: |
127 |
|
// shouldn't construct a CommandStatus (use a derived class) |
128 |
19778 |
CommandStatus() {} |
129 |
|
|
130 |
|
public: |
131 |
58 |
virtual ~CommandStatus() {} |
132 |
|
void toStream(std::ostream& out, |
133 |
|
Language language = Language::LANG_AUTO) const; |
134 |
|
virtual CommandStatus& clone() const = 0; |
135 |
|
}; /* class CommandStatus */ |
136 |
|
|
137 |
9858 |
class CVC5_EXPORT CommandSuccess : public CommandStatus |
138 |
|
{ |
139 |
|
static const CommandSuccess* s_instance; |
140 |
|
|
141 |
|
public: |
142 |
596944 |
static const CommandSuccess* instance() { return s_instance; } |
143 |
|
CommandStatus& clone() const override |
144 |
|
{ |
145 |
|
return const_cast<CommandSuccess&>(*this); |
146 |
|
} |
147 |
|
}; /* class CommandSuccess */ |
148 |
|
|
149 |
9860 |
class CVC5_EXPORT CommandInterrupted : public CommandStatus |
150 |
|
{ |
151 |
|
static const CommandInterrupted* s_instance; |
152 |
|
|
153 |
|
public: |
154 |
|
static const CommandInterrupted* instance() { return s_instance; } |
155 |
|
CommandStatus& clone() const override |
156 |
|
{ |
157 |
|
return const_cast<CommandInterrupted&>(*this); |
158 |
|
} |
159 |
|
}; /* class CommandInterrupted */ |
160 |
|
|
161 |
|
class CVC5_EXPORT CommandUnsupported : public CommandStatus |
162 |
|
{ |
163 |
|
public: |
164 |
|
CommandStatus& clone() const override |
165 |
|
{ |
166 |
|
return *new CommandUnsupported(*this); |
167 |
|
} |
168 |
|
}; /* class CommandSuccess */ |
169 |
|
|
170 |
78 |
class CVC5_EXPORT CommandFailure : public CommandStatus |
171 |
|
{ |
172 |
|
std::string d_message; |
173 |
|
|
174 |
|
public: |
175 |
39 |
CommandFailure(std::string message) : d_message(message) {} |
176 |
|
CommandFailure& clone() const override { return *new CommandFailure(*this); } |
177 |
39 |
std::string getMessage() const { return d_message; } |
178 |
|
}; /* class CommandFailure */ |
179 |
|
|
180 |
|
/** |
181 |
|
* The execution of the command resulted in a non-fatal error and further |
182 |
|
* commands can be processed. This status is for example used when a user asks |
183 |
|
* for an unsat core in a place that is not immediately preceded by an |
184 |
|
* unsat/valid response. |
185 |
|
*/ |
186 |
38 |
class CVC5_EXPORT CommandRecoverableFailure : public CommandStatus |
187 |
|
{ |
188 |
|
std::string d_message; |
189 |
|
|
190 |
|
public: |
191 |
19 |
CommandRecoverableFailure(std::string message) : d_message(message) {} |
192 |
|
CommandRecoverableFailure& clone() const override |
193 |
|
{ |
194 |
|
return *new CommandRecoverableFailure(*this); |
195 |
|
} |
196 |
19 |
std::string getMessage() const { return d_message; } |
197 |
|
}; /* class CommandRecoverableFailure */ |
198 |
|
|
199 |
|
class CVC5_EXPORT Command |
200 |
|
{ |
201 |
|
public: |
202 |
|
typedef CommandPrintSuccess printsuccess; |
203 |
|
|
204 |
|
Command(); |
205 |
|
Command(const Command& cmd); |
206 |
|
|
207 |
|
virtual ~Command(); |
208 |
|
|
209 |
|
/** |
210 |
|
* Invoke the command on the solver and symbol manager sm. |
211 |
|
*/ |
212 |
|
virtual void invoke(api::Solver* solver, SymbolManager* sm) = 0; |
213 |
|
/** |
214 |
|
* Same as above, and prints the result to output stream out. |
215 |
|
*/ |
216 |
|
virtual void invoke(api::Solver* solver, |
217 |
|
SymbolManager* sm, |
218 |
|
std::ostream& out); |
219 |
|
|
220 |
|
virtual void toStream(std::ostream& out, |
221 |
|
int toDepth = -1, |
222 |
|
size_t dag = 1, |
223 |
|
Language language = Language::LANG_AUTO) const = 0; |
224 |
|
|
225 |
|
std::string toString() const; |
226 |
|
|
227 |
|
virtual std::string getCommandName() const = 0; |
228 |
|
|
229 |
|
/** |
230 |
|
* If false, instruct this Command not to print a success message. |
231 |
|
*/ |
232 |
5770 |
void setMuted(bool muted) { d_muted = muted; } |
233 |
|
/** |
234 |
|
* Determine whether this Command will print a success message. |
235 |
|
*/ |
236 |
298579 |
bool isMuted() { return d_muted; } |
237 |
|
/** |
238 |
|
* Either the command hasn't run yet, or it completed successfully |
239 |
|
* (CommandSuccess, not CommandUnsupported or CommandFailure). |
240 |
|
*/ |
241 |
|
bool ok() const; |
242 |
|
|
243 |
|
/** |
244 |
|
* The command completed in a failure state (CommandFailure, not |
245 |
|
* CommandSuccess or CommandUnsupported). |
246 |
|
*/ |
247 |
|
bool fail() const; |
248 |
|
|
249 |
|
/** |
250 |
|
* The command was ran but was interrupted due to resource limiting. |
251 |
|
*/ |
252 |
|
bool interrupted() const; |
253 |
|
|
254 |
|
/** Get the command status (it's NULL if we haven't run yet). */ |
255 |
|
const CommandStatus* getCommandStatus() const { return d_commandStatus; } |
256 |
|
virtual void printResult(std::ostream& out, uint32_t verbosity = 2) const; |
257 |
|
|
258 |
|
/** |
259 |
|
* Clone this Command (make a shallow copy). |
260 |
|
*/ |
261 |
|
virtual Command* clone() const = 0; |
262 |
|
|
263 |
|
/** |
264 |
|
* This field contains a command status if the command has been |
265 |
|
* invoked, or NULL if it has not. This field is either a |
266 |
|
* dynamically-allocated pointer, or it's a pointer to the singleton |
267 |
|
* CommandSuccess instance. Doing so is somewhat asymmetric, but |
268 |
|
* it avoids the need to dynamically allocate memory in the common |
269 |
|
* case of a successful command. |
270 |
|
*/ |
271 |
|
const CommandStatus* d_commandStatus; |
272 |
|
|
273 |
|
/** |
274 |
|
* True if this command is "muted"---i.e., don't print "success" on |
275 |
|
* successful execution. |
276 |
|
*/ |
277 |
|
bool d_muted; |
278 |
|
|
279 |
|
/** |
280 |
|
* Reset the given solver in-place (keep the object at the same memory |
281 |
|
* location). |
282 |
|
*/ |
283 |
|
static void resetSolver(api::Solver* solver); |
284 |
|
|
285 |
|
protected: |
286 |
|
// These methods rely on Command being a friend of classes in the API. |
287 |
|
// Subclasses of command should use these methods for conversions, |
288 |
|
// which is currently necessary for e.g. printing commands. |
289 |
|
/** Helper to convert a Term to an internal Node */ |
290 |
|
static Node termToNode(const api::Term& term); |
291 |
|
/** Helper to convert a vector of Terms to internal Nodes. */ |
292 |
|
static std::vector<Node> termVectorToNodes( |
293 |
|
const std::vector<api::Term>& terms); |
294 |
|
/** Helper to convert a Sort to an internal TypeNode */ |
295 |
|
static TypeNode sortToTypeNode(const api::Sort& sort); |
296 |
|
/** Helper to convert a vector of Sorts to internal TypeNodes. */ |
297 |
|
static std::vector<TypeNode> sortVectorToTypeNodes( |
298 |
|
const std::vector<api::Sort>& sorts); |
299 |
|
/** Helper to convert a Grammar to an internal TypeNode */ |
300 |
|
static TypeNode grammarToTypeNode(api::Grammar* grammar); |
301 |
|
}; /* class Command */ |
302 |
|
|
303 |
|
/** |
304 |
|
* EmptyCommands are the residue of a command after the parser handles |
305 |
|
* them (and there's nothing left to do). |
306 |
|
*/ |
307 |
884 |
class CVC5_EXPORT EmptyCommand : public Command |
308 |
|
{ |
309 |
|
public: |
310 |
|
EmptyCommand(std::string name = ""); |
311 |
|
std::string getName() const; |
312 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
313 |
|
Command* clone() const override; |
314 |
|
std::string getCommandName() const override; |
315 |
|
void toStream(std::ostream& out, |
316 |
|
int toDepth = -1, |
317 |
|
size_t dag = 1, |
318 |
|
Language language = Language::LANG_AUTO) const override; |
319 |
|
|
320 |
|
protected: |
321 |
|
std::string d_name; |
322 |
|
}; /* class EmptyCommand */ |
323 |
|
|
324 |
18 |
class CVC5_EXPORT EchoCommand : public Command |
325 |
|
{ |
326 |
|
public: |
327 |
|
EchoCommand(std::string output = ""); |
328 |
|
|
329 |
|
std::string getOutput() const; |
330 |
|
|
331 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
332 |
|
void invoke(api::Solver* solver, |
333 |
|
SymbolManager* sm, |
334 |
|
std::ostream& out) override; |
335 |
|
|
336 |
|
Command* clone() const override; |
337 |
|
std::string getCommandName() const override; |
338 |
|
void toStream(std::ostream& out, |
339 |
|
int toDepth = -1, |
340 |
|
size_t dag = 1, |
341 |
|
Language language = Language::LANG_AUTO) const override; |
342 |
|
|
343 |
|
protected: |
344 |
|
std::string d_output; |
345 |
|
}; /* class EchoCommand */ |
346 |
|
|
347 |
160200 |
class CVC5_EXPORT AssertCommand : public Command |
348 |
|
{ |
349 |
|
protected: |
350 |
|
api::Term d_term; |
351 |
|
|
352 |
|
public: |
353 |
|
AssertCommand(const api::Term& t); |
354 |
|
|
355 |
|
api::Term getTerm() const; |
356 |
|
|
357 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
358 |
|
|
359 |
|
Command* clone() const override; |
360 |
|
std::string getCommandName() const override; |
361 |
|
void toStream(std::ostream& out, |
362 |
|
int toDepth = -1, |
363 |
|
size_t dag = 1, |
364 |
|
Language language = Language::LANG_AUTO) const override; |
365 |
|
}; /* class AssertCommand */ |
366 |
|
|
367 |
10026 |
class CVC5_EXPORT PushCommand : public Command |
368 |
|
{ |
369 |
|
public: |
370 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
371 |
|
Command* clone() const override; |
372 |
|
std::string getCommandName() const override; |
373 |
|
void toStream(std::ostream& out, |
374 |
|
int toDepth = -1, |
375 |
|
size_t dag = 1, |
376 |
|
Language language = Language::LANG_AUTO) const override; |
377 |
|
}; /* class PushCommand */ |
378 |
|
|
379 |
8445 |
class CVC5_EXPORT PopCommand : public Command |
380 |
|
{ |
381 |
|
public: |
382 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
383 |
|
Command* clone() const override; |
384 |
|
std::string getCommandName() const override; |
385 |
|
void toStream(std::ostream& out, |
386 |
|
int toDepth = -1, |
387 |
|
size_t dag = 1, |
388 |
|
Language language = Language::LANG_AUTO) const override; |
389 |
|
}; /* class PopCommand */ |
390 |
|
|
391 |
179460 |
class CVC5_EXPORT DeclarationDefinitionCommand : public Command |
392 |
|
{ |
393 |
|
protected: |
394 |
|
std::string d_symbol; |
395 |
|
|
396 |
|
public: |
397 |
|
DeclarationDefinitionCommand(const std::string& id); |
398 |
|
|
399 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override = 0; |
400 |
|
std::string getSymbol() const; |
401 |
|
}; /* class DeclarationDefinitionCommand */ |
402 |
|
|
403 |
344892 |
class CVC5_EXPORT DeclareFunctionCommand : public DeclarationDefinitionCommand |
404 |
|
{ |
405 |
|
protected: |
406 |
|
api::Term d_func; |
407 |
|
api::Sort d_sort; |
408 |
|
|
409 |
|
public: |
410 |
|
DeclareFunctionCommand(const std::string& id, api::Term func, api::Sort sort); |
411 |
|
api::Term getFunction() const; |
412 |
|
api::Sort getSort() const; |
413 |
|
|
414 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
415 |
|
Command* clone() const override; |
416 |
|
std::string getCommandName() const override; |
417 |
|
void toStream(std::ostream& out, |
418 |
|
int toDepth = -1, |
419 |
|
size_t dag = 1, |
420 |
|
Language language = Language::LANG_AUTO) const override; |
421 |
|
}; /* class DeclareFunctionCommand */ |
422 |
|
|
423 |
6 |
class CVC5_EXPORT DeclarePoolCommand : public DeclarationDefinitionCommand |
424 |
|
{ |
425 |
|
protected: |
426 |
|
api::Term d_func; |
427 |
|
api::Sort d_sort; |
428 |
|
std::vector<api::Term> d_initValue; |
429 |
|
|
430 |
|
public: |
431 |
|
DeclarePoolCommand(const std::string& id, |
432 |
|
api::Term func, |
433 |
|
api::Sort sort, |
434 |
|
const std::vector<api::Term>& initValue); |
435 |
|
api::Term getFunction() const; |
436 |
|
api::Sort getSort() const; |
437 |
|
const std::vector<api::Term>& getInitialValue() const; |
438 |
|
|
439 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
440 |
|
Command* clone() const override; |
441 |
|
std::string getCommandName() const override; |
442 |
|
void toStream(std::ostream& out, |
443 |
|
int toDepth = -1, |
444 |
|
size_t dag = 1, |
445 |
|
Language language = Language::LANG_AUTO) const override; |
446 |
|
}; /* class DeclarePoolCommand */ |
447 |
|
|
448 |
7762 |
class CVC5_EXPORT DeclareSortCommand : public DeclarationDefinitionCommand |
449 |
|
{ |
450 |
|
protected: |
451 |
|
size_t d_arity; |
452 |
|
api::Sort d_sort; |
453 |
|
|
454 |
|
public: |
455 |
|
DeclareSortCommand(const std::string& id, size_t arity, api::Sort sort); |
456 |
|
|
457 |
|
size_t getArity() const; |
458 |
|
api::Sort getSort() const; |
459 |
|
|
460 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
461 |
|
Command* clone() const override; |
462 |
|
std::string getCommandName() const override; |
463 |
|
void toStream(std::ostream& out, |
464 |
|
int toDepth = -1, |
465 |
|
size_t dag = 1, |
466 |
|
Language language = Language::LANG_AUTO) const override; |
467 |
|
}; /* class DeclareSortCommand */ |
468 |
|
|
469 |
412 |
class CVC5_EXPORT DefineSortCommand : public DeclarationDefinitionCommand |
470 |
|
{ |
471 |
|
protected: |
472 |
|
std::vector<api::Sort> d_params; |
473 |
|
api::Sort d_sort; |
474 |
|
|
475 |
|
public: |
476 |
|
DefineSortCommand(const std::string& id, api::Sort sort); |
477 |
|
DefineSortCommand(const std::string& id, |
478 |
|
const std::vector<api::Sort>& params, |
479 |
|
api::Sort sort); |
480 |
|
|
481 |
|
const std::vector<api::Sort>& getParameters() const; |
482 |
|
api::Sort getSort() const; |
483 |
|
|
484 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
485 |
|
Command* clone() const override; |
486 |
|
std::string getCommandName() const override; |
487 |
|
void toStream(std::ostream& out, |
488 |
|
int toDepth = -1, |
489 |
|
size_t dag = 1, |
490 |
|
Language language = Language::LANG_AUTO) const override; |
491 |
|
}; /* class DefineSortCommand */ |
492 |
|
|
493 |
4530 |
class CVC5_EXPORT DefineFunctionCommand : public DeclarationDefinitionCommand |
494 |
|
{ |
495 |
|
public: |
496 |
|
DefineFunctionCommand(const std::string& id, |
497 |
|
api::Term func, |
498 |
|
api::Term formula, |
499 |
|
bool global); |
500 |
|
DefineFunctionCommand(const std::string& id, |
501 |
|
api::Term func, |
502 |
|
const std::vector<api::Term>& formals, |
503 |
|
api::Term formula, |
504 |
|
bool global); |
505 |
|
|
506 |
|
api::Term getFunction() const; |
507 |
|
const std::vector<api::Term>& getFormals() const; |
508 |
|
api::Term getFormula() const; |
509 |
|
|
510 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
511 |
|
Command* clone() const override; |
512 |
|
std::string getCommandName() const override; |
513 |
|
void toStream(std::ostream& out, |
514 |
|
int toDepth = -1, |
515 |
|
size_t dag = 1, |
516 |
|
Language language = Language::LANG_AUTO) const override; |
517 |
|
|
518 |
|
protected: |
519 |
|
/** The function we are defining */ |
520 |
|
api::Term d_func; |
521 |
|
/** The formal arguments for the function we are defining */ |
522 |
|
std::vector<api::Term> d_formals; |
523 |
|
/** The formula corresponding to the body of the function we are defining */ |
524 |
|
api::Term d_formula; |
525 |
|
/** |
526 |
|
* Stores whether this definition is global (i.e. should persist when |
527 |
|
* popping the user context. |
528 |
|
*/ |
529 |
|
bool d_global; |
530 |
|
}; /* class DefineFunctionCommand */ |
531 |
|
|
532 |
|
/** |
533 |
|
* The command when parsing define-fun-rec or define-funs-rec. |
534 |
|
* This command will assert a set of quantified formulas that specify |
535 |
|
* the (mutually recursive) function definitions provided to it. |
536 |
|
*/ |
537 |
240 |
class CVC5_EXPORT DefineFunctionRecCommand : public Command |
538 |
|
{ |
539 |
|
public: |
540 |
|
DefineFunctionRecCommand(api::Term func, |
541 |
|
const std::vector<api::Term>& formals, |
542 |
|
api::Term formula, |
543 |
|
bool global); |
544 |
|
DefineFunctionRecCommand(const std::vector<api::Term>& funcs, |
545 |
|
const std::vector<std::vector<api::Term> >& formals, |
546 |
|
const std::vector<api::Term>& formula, |
547 |
|
bool global); |
548 |
|
|
549 |
|
const std::vector<api::Term>& getFunctions() const; |
550 |
|
const std::vector<std::vector<api::Term> >& getFormals() const; |
551 |
|
const std::vector<api::Term>& getFormulas() const; |
552 |
|
|
553 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
554 |
|
Command* clone() const override; |
555 |
|
std::string getCommandName() const override; |
556 |
|
void toStream(std::ostream& out, |
557 |
|
int toDepth = -1, |
558 |
|
size_t dag = 1, |
559 |
|
Language language = Language::LANG_AUTO) const override; |
560 |
|
|
561 |
|
protected: |
562 |
|
/** functions we are defining */ |
563 |
|
std::vector<api::Term> d_funcs; |
564 |
|
/** formal arguments for each of the functions we are defining */ |
565 |
|
std::vector<std::vector<api::Term> > d_formals; |
566 |
|
/** formulas corresponding to the bodies of the functions we are defining */ |
567 |
|
std::vector<api::Term> d_formulas; |
568 |
|
/** |
569 |
|
* Stores whether this definition is global (i.e. should persist when |
570 |
|
* popping the user context. |
571 |
|
*/ |
572 |
|
bool d_global; |
573 |
|
}; /* class DefineFunctionRecCommand */ |
574 |
|
|
575 |
|
/** |
576 |
|
* In separation logic inputs, which is an extension of smt2 inputs, this |
577 |
|
* corresponds to the command: |
578 |
|
* (declare-heap (T U)) |
579 |
|
* where T is the location sort and U is the data sort. |
580 |
|
*/ |
581 |
174 |
class CVC5_EXPORT DeclareHeapCommand : public Command |
582 |
|
{ |
583 |
|
public: |
584 |
|
DeclareHeapCommand(api::Sort locSort, api::Sort dataSort); |
585 |
|
api::Sort getLocationSort() const; |
586 |
|
api::Sort getDataSort() const; |
587 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
588 |
|
Command* clone() const override; |
589 |
|
std::string getCommandName() const override; |
590 |
|
void toStream(std::ostream& out, |
591 |
|
int toDepth = -1, |
592 |
|
size_t dag = 1, |
593 |
|
Language language = Language::LANG_AUTO) const override; |
594 |
|
|
595 |
|
protected: |
596 |
|
/** The location sort */ |
597 |
|
api::Sort d_locSort; |
598 |
|
/** The data sort */ |
599 |
|
api::Sort d_dataSort; |
600 |
|
}; |
601 |
|
|
602 |
|
/** |
603 |
|
* The command when parsing check-sat. |
604 |
|
* This command will check satisfiability of the input formula. |
605 |
|
*/ |
606 |
18502 |
class CVC5_EXPORT CheckSatCommand : public Command |
607 |
|
{ |
608 |
|
public: |
609 |
|
CheckSatCommand(); |
610 |
|
CheckSatCommand(const api::Term& term); |
611 |
|
|
612 |
|
api::Term getTerm() const; |
613 |
|
api::Result getResult() const; |
614 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
615 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
616 |
|
Command* clone() const override; |
617 |
|
std::string getCommandName() const override; |
618 |
|
void toStream(std::ostream& out, |
619 |
|
int toDepth = -1, |
620 |
|
size_t dag = 1, |
621 |
|
Language language = Language::LANG_AUTO) const override; |
622 |
|
|
623 |
|
private: |
624 |
|
api::Term d_term; |
625 |
|
api::Result d_result; |
626 |
|
}; /* class CheckSatCommand */ |
627 |
|
|
628 |
|
/** |
629 |
|
* The command when parsing check-sat-assuming. |
630 |
|
* This command will assume a set of formulas and check satisfiability of the |
631 |
|
* input formula under these assumptions. |
632 |
|
*/ |
633 |
1988 |
class CVC5_EXPORT CheckSatAssumingCommand : public Command |
634 |
|
{ |
635 |
|
public: |
636 |
|
CheckSatAssumingCommand(api::Term term); |
637 |
|
CheckSatAssumingCommand(const std::vector<api::Term>& terms); |
638 |
|
|
639 |
|
const std::vector<api::Term>& getTerms() const; |
640 |
|
api::Result getResult() const; |
641 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
642 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
643 |
|
Command* clone() const override; |
644 |
|
std::string getCommandName() const override; |
645 |
|
void toStream(std::ostream& out, |
646 |
|
int toDepth = -1, |
647 |
|
size_t dag = 1, |
648 |
|
Language language = Language::LANG_AUTO) const override; |
649 |
|
|
650 |
|
private: |
651 |
|
std::vector<api::Term> d_terms; |
652 |
|
api::Result d_result; |
653 |
|
}; /* class CheckSatAssumingCommand */ |
654 |
|
|
655 |
1230 |
class CVC5_EXPORT QueryCommand : public Command |
656 |
|
{ |
657 |
|
protected: |
658 |
|
api::Term d_term; |
659 |
|
api::Result d_result; |
660 |
|
|
661 |
|
public: |
662 |
|
QueryCommand(const api::Term& t); |
663 |
|
|
664 |
|
api::Term getTerm() const; |
665 |
|
api::Result getResult() const; |
666 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
667 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
668 |
|
Command* clone() const override; |
669 |
|
std::string getCommandName() const override; |
670 |
|
void toStream(std::ostream& out, |
671 |
|
int toDepth = -1, |
672 |
|
size_t dag = 1, |
673 |
|
Language language = Language::LANG_AUTO) const override; |
674 |
|
}; /* class QueryCommand */ |
675 |
|
|
676 |
|
/* ------------------- sygus commands ------------------ */ |
677 |
|
|
678 |
|
/** Declares a sygus universal variable */ |
679 |
622 |
class CVC5_EXPORT DeclareSygusVarCommand : public DeclarationDefinitionCommand |
680 |
|
{ |
681 |
|
public: |
682 |
|
DeclareSygusVarCommand(const std::string& id, api::Term var, api::Sort sort); |
683 |
|
/** returns the declared variable */ |
684 |
|
api::Term getVar() const; |
685 |
|
/** returns the declared variable's sort */ |
686 |
|
api::Sort getSort() const; |
687 |
|
/** invokes this command |
688 |
|
* |
689 |
|
* The declared sygus variable is communicated to the SMT engine in case a |
690 |
|
* synthesis conjecture is built later on. |
691 |
|
*/ |
692 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
693 |
|
/** creates a copy of this command */ |
694 |
|
Command* clone() const override; |
695 |
|
/** returns this command's name */ |
696 |
|
std::string getCommandName() const override; |
697 |
|
/** prints this command */ |
698 |
|
void toStream(std::ostream& out, |
699 |
|
int toDepth = -1, |
700 |
|
size_t dag = 1, |
701 |
|
Language language = Language::LANG_AUTO) const override; |
702 |
|
|
703 |
|
protected: |
704 |
|
/** the declared variable */ |
705 |
|
api::Term d_var; |
706 |
|
/** the declared variable's sort */ |
707 |
|
api::Sort d_sort; |
708 |
|
}; |
709 |
|
|
710 |
|
/** Declares a sygus function-to-synthesize |
711 |
|
* |
712 |
|
* This command is also used for the special case in which we are declaring an |
713 |
|
* invariant-to-synthesize |
714 |
|
*/ |
715 |
696 |
class CVC5_EXPORT SynthFunCommand : public DeclarationDefinitionCommand |
716 |
|
{ |
717 |
|
public: |
718 |
|
SynthFunCommand(const std::string& id, |
719 |
|
api::Term fun, |
720 |
|
const std::vector<api::Term>& vars, |
721 |
|
api::Sort sort, |
722 |
|
bool isInv, |
723 |
|
api::Grammar* g); |
724 |
|
/** returns the function-to-synthesize */ |
725 |
|
api::Term getFunction() const; |
726 |
|
/** returns the input variables of the function-to-synthesize */ |
727 |
|
const std::vector<api::Term>& getVars() const; |
728 |
|
/** returns the sygus sort of the function-to-synthesize */ |
729 |
|
api::Sort getSort() const; |
730 |
|
/** returns whether the function-to-synthesize should be an invariant */ |
731 |
|
bool isInv() const; |
732 |
|
/** Get the sygus grammar given for the synth fun command */ |
733 |
|
const api::Grammar* getGrammar() const; |
734 |
|
|
735 |
|
/** invokes this command |
736 |
|
* |
737 |
|
* The declared function-to-synthesize is communicated to the SMT engine in |
738 |
|
* case a synthesis conjecture is built later on. |
739 |
|
*/ |
740 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
741 |
|
/** creates a copy of this command */ |
742 |
|
Command* clone() const override; |
743 |
|
/** returns this command's name */ |
744 |
|
std::string getCommandName() const override; |
745 |
|
/** prints this command */ |
746 |
|
void toStream(std::ostream& out, |
747 |
|
int toDepth = -1, |
748 |
|
size_t dag = 1, |
749 |
|
Language language = Language::LANG_AUTO) const override; |
750 |
|
|
751 |
|
protected: |
752 |
|
/** the function-to-synthesize */ |
753 |
|
api::Term d_fun; |
754 |
|
/** the input variables of the function-to-synthesize */ |
755 |
|
std::vector<api::Term> d_vars; |
756 |
|
/** sort of the function-to-synthesize */ |
757 |
|
api::Sort d_sort; |
758 |
|
/** whether the function-to-synthesize should be an invariant */ |
759 |
|
bool d_isInv; |
760 |
|
/** optional grammar for the possible values of the function-to-sytnhesize */ |
761 |
|
api::Grammar* d_grammar; |
762 |
|
}; |
763 |
|
|
764 |
|
/** Declares a sygus constraint */ |
765 |
1276 |
class CVC5_EXPORT SygusConstraintCommand : public Command |
766 |
|
{ |
767 |
|
public: |
768 |
|
SygusConstraintCommand(const api::Term& t, bool isAssume = false); |
769 |
|
/** returns the declared constraint */ |
770 |
|
api::Term getTerm() const; |
771 |
|
/** invokes this command |
772 |
|
* |
773 |
|
* The declared constraint is communicated to the SMT engine in case a |
774 |
|
* synthesis conjecture is built later on. |
775 |
|
*/ |
776 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
777 |
|
/** creates a copy of this command */ |
778 |
|
Command* clone() const override; |
779 |
|
/** returns this command's name */ |
780 |
|
std::string getCommandName() const override; |
781 |
|
/** prints this command */ |
782 |
|
void toStream(std::ostream& out, |
783 |
|
int toDepth = -1, |
784 |
|
size_t dag = 1, |
785 |
|
Language language = Language::LANG_AUTO) const override; |
786 |
|
|
787 |
|
protected: |
788 |
|
/** the declared constraint */ |
789 |
|
api::Term d_term; |
790 |
|
/** true if this is a sygus assumption */ |
791 |
|
bool d_isAssume; |
792 |
|
}; |
793 |
|
|
794 |
|
/** Declares a sygus invariant constraint |
795 |
|
* |
796 |
|
* Invarint constraints are declared in a somewhat implicit manner in the SyGuS |
797 |
|
* language: they are declared in terms of the previously declared |
798 |
|
* invariant-to-synthesize, precondition, transition relation and condition. |
799 |
|
* |
800 |
|
* The actual constraint must be built such that the invariant is not stronger |
801 |
|
* than the precondition, not weaker than the postcondition and inductive |
802 |
|
* w.r.t. the transition relation. |
803 |
|
*/ |
804 |
28 |
class CVC5_EXPORT SygusInvConstraintCommand : public Command |
805 |
|
{ |
806 |
|
public: |
807 |
|
SygusInvConstraintCommand(const std::vector<api::Term>& predicates); |
808 |
|
SygusInvConstraintCommand(const api::Term& inv, |
809 |
|
const api::Term& pre, |
810 |
|
const api::Term& trans, |
811 |
|
const api::Term& post); |
812 |
|
/** returns the place holder predicates */ |
813 |
|
const std::vector<api::Term>& getPredicates() const; |
814 |
|
/** invokes this command |
815 |
|
* |
816 |
|
* The place holders are communicated to the SMT engine and the actual |
817 |
|
* invariant constraint is built, in case an actual synthesis conjecture is |
818 |
|
* built later on. |
819 |
|
*/ |
820 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
821 |
|
/** creates a copy of this command */ |
822 |
|
Command* clone() const override; |
823 |
|
/** returns this command's name */ |
824 |
|
std::string getCommandName() const override; |
825 |
|
/** prints this command */ |
826 |
|
void toStream(std::ostream& out, |
827 |
|
int toDepth = -1, |
828 |
|
size_t dag = 1, |
829 |
|
Language language = Language::LANG_AUTO) const override; |
830 |
|
|
831 |
|
protected: |
832 |
|
/** the place holder predicates with which to build the actual constraint |
833 |
|
* (i.e. the invariant, precondition, transition relation and postcondition) |
834 |
|
*/ |
835 |
|
std::vector<api::Term> d_predicates; |
836 |
|
}; |
837 |
|
|
838 |
|
/** Declares a synthesis conjecture */ |
839 |
390 |
class CVC5_EXPORT CheckSynthCommand : public Command |
840 |
|
{ |
841 |
|
public: |
842 |
195 |
CheckSynthCommand(){}; |
843 |
|
/** returns the result of the check-synth call */ |
844 |
|
api::Result getResult() const; |
845 |
|
/** prints the result of the check-synth-call */ |
846 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
847 |
|
/** invokes this command |
848 |
|
* |
849 |
|
* This invocation makes the SMT engine build a synthesis conjecture based on |
850 |
|
* previously declared information (such as universal variables, |
851 |
|
* functions-to-synthesize and so on), set up attributes to guide the solving, |
852 |
|
* and then perform a satisfiability check, whose result is stored in |
853 |
|
* d_result. |
854 |
|
*/ |
855 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
856 |
|
/** creates a copy of this command */ |
857 |
|
Command* clone() const override; |
858 |
|
/** returns this command's name */ |
859 |
|
std::string getCommandName() const override; |
860 |
|
/** prints this command */ |
861 |
|
void toStream(std::ostream& out, |
862 |
|
int toDepth = -1, |
863 |
|
size_t dag = 1, |
864 |
|
Language language = Language::LANG_AUTO) const override; |
865 |
|
|
866 |
|
protected: |
867 |
|
/** result of the check-synth call */ |
868 |
|
api::Result d_result; |
869 |
|
/** string stream that stores the output of the solution */ |
870 |
|
std::stringstream d_solution; |
871 |
|
}; |
872 |
|
|
873 |
|
/* ------------------- sygus commands ------------------ */ |
874 |
|
|
875 |
|
// this is TRANSFORM in the CVC presentation language |
876 |
|
class CVC5_EXPORT SimplifyCommand : public Command |
877 |
|
{ |
878 |
|
protected: |
879 |
|
api::Term d_term; |
880 |
|
api::Term d_result; |
881 |
|
|
882 |
|
public: |
883 |
|
SimplifyCommand(api::Term term); |
884 |
|
|
885 |
|
api::Term getTerm() const; |
886 |
|
api::Term getResult() const; |
887 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
888 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
889 |
|
Command* clone() const override; |
890 |
|
std::string getCommandName() const override; |
891 |
|
void toStream(std::ostream& out, |
892 |
|
int toDepth = -1, |
893 |
|
size_t dag = 1, |
894 |
|
Language language = Language::LANG_AUTO) const override; |
895 |
|
}; /* class SimplifyCommand */ |
896 |
|
|
897 |
128 |
class CVC5_EXPORT GetValueCommand : public Command |
898 |
|
{ |
899 |
|
protected: |
900 |
|
std::vector<api::Term> d_terms; |
901 |
|
api::Term d_result; |
902 |
|
|
903 |
|
public: |
904 |
|
GetValueCommand(api::Term term); |
905 |
|
GetValueCommand(const std::vector<api::Term>& terms); |
906 |
|
|
907 |
|
const std::vector<api::Term>& getTerms() const; |
908 |
|
api::Term getResult() const; |
909 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
910 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
911 |
|
Command* clone() const override; |
912 |
|
std::string getCommandName() const override; |
913 |
|
void toStream(std::ostream& out, |
914 |
|
int toDepth = -1, |
915 |
|
size_t dag = 1, |
916 |
|
Language language = Language::LANG_AUTO) const override; |
917 |
|
}; /* class GetValueCommand */ |
918 |
|
|
919 |
20 |
class CVC5_EXPORT GetAssignmentCommand : public Command |
920 |
|
{ |
921 |
|
protected: |
922 |
|
api::Term d_result; |
923 |
|
|
924 |
|
public: |
925 |
|
GetAssignmentCommand(); |
926 |
|
|
927 |
|
api::Term getResult() const; |
928 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
929 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
930 |
|
Command* clone() const override; |
931 |
|
std::string getCommandName() const override; |
932 |
|
void toStream(std::ostream& out, |
933 |
|
int toDepth = -1, |
934 |
|
size_t dag = 1, |
935 |
|
Language language = Language::LANG_AUTO) const override; |
936 |
|
}; /* class GetAssignmentCommand */ |
937 |
|
|
938 |
62 |
class CVC5_EXPORT GetModelCommand : public Command |
939 |
|
{ |
940 |
|
public: |
941 |
|
GetModelCommand(); |
942 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
943 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
944 |
|
Command* clone() const override; |
945 |
|
std::string getCommandName() const override; |
946 |
|
void toStream(std::ostream& out, |
947 |
|
int toDepth = -1, |
948 |
|
size_t dag = 1, |
949 |
|
Language language = Language::LANG_AUTO) const override; |
950 |
|
|
951 |
|
protected: |
952 |
|
/** Result of printing the model */ |
953 |
|
std::string d_result; |
954 |
|
}; /* class GetModelCommand */ |
955 |
|
|
956 |
|
/** The command to block models. */ |
957 |
28 |
class CVC5_EXPORT BlockModelCommand : public Command |
958 |
|
{ |
959 |
|
public: |
960 |
|
BlockModelCommand(); |
961 |
|
|
962 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
963 |
|
Command* clone() const override; |
964 |
|
std::string getCommandName() const override; |
965 |
|
void toStream(std::ostream& out, |
966 |
|
int toDepth = -1, |
967 |
|
size_t dag = 1, |
968 |
|
Language language = Language::LANG_AUTO) const override; |
969 |
|
}; /* class BlockModelCommand */ |
970 |
|
|
971 |
|
/** The command to block model values. */ |
972 |
16 |
class CVC5_EXPORT BlockModelValuesCommand : public Command |
973 |
|
{ |
974 |
|
public: |
975 |
|
BlockModelValuesCommand(const std::vector<api::Term>& terms); |
976 |
|
|
977 |
|
const std::vector<api::Term>& getTerms() const; |
978 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
979 |
|
Command* clone() const override; |
980 |
|
std::string getCommandName() const override; |
981 |
|
void toStream(std::ostream& out, |
982 |
|
int toDepth = -1, |
983 |
|
size_t dag = 1, |
984 |
|
Language language = Language::LANG_AUTO) const override; |
985 |
|
|
986 |
|
protected: |
987 |
|
/** The terms we are blocking */ |
988 |
|
std::vector<api::Term> d_terms; |
989 |
|
}; /* class BlockModelValuesCommand */ |
990 |
|
|
991 |
2 |
class CVC5_EXPORT GetProofCommand : public Command |
992 |
|
{ |
993 |
|
public: |
994 |
|
GetProofCommand(); |
995 |
|
|
996 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
997 |
|
|
998 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
999 |
|
|
1000 |
|
Command* clone() const override; |
1001 |
|
std::string getCommandName() const override; |
1002 |
|
void toStream(std::ostream& out, |
1003 |
|
int toDepth = -1, |
1004 |
|
size_t dag = 1, |
1005 |
|
Language language = Language::LANG_AUTO) const override; |
1006 |
|
|
1007 |
|
private: |
1008 |
|
/** the result of the getProof call */ |
1009 |
|
std::string d_result; |
1010 |
|
}; /* class GetProofCommand */ |
1011 |
|
|
1012 |
30 |
class CVC5_EXPORT GetInstantiationsCommand : public Command |
1013 |
|
{ |
1014 |
|
public: |
1015 |
|
GetInstantiationsCommand(); |
1016 |
|
|
1017 |
|
static bool isEnabled(api::Solver* solver, const api::Result& res); |
1018 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1019 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1020 |
|
Command* clone() const override; |
1021 |
|
std::string getCommandName() const override; |
1022 |
|
void toStream(std::ostream& out, |
1023 |
|
int toDepth = -1, |
1024 |
|
size_t dag = 1, |
1025 |
|
Language language = Language::LANG_AUTO) const override; |
1026 |
|
|
1027 |
|
protected: |
1028 |
|
api::Solver* d_solver; |
1029 |
|
}; /* class GetInstantiationsCommand */ |
1030 |
|
|
1031 |
|
/** The command (get-interpol s B (G)?) |
1032 |
|
* |
1033 |
|
* This command asks for an interpolant from the current set of assertions and |
1034 |
|
* conjecture (goal) B. |
1035 |
|
* |
1036 |
|
* The symbol s is the name for the interpolation predicate. If we successfully |
1037 |
|
* find a predicate P, then the output response of this command is: (define-fun |
1038 |
|
* s () Bool P) |
1039 |
|
*/ |
1040 |
16 |
class CVC5_EXPORT GetInterpolCommand : public Command |
1041 |
|
{ |
1042 |
|
public: |
1043 |
|
GetInterpolCommand(const std::string& name, api::Term conj); |
1044 |
|
/** The argument g is the grammar of the interpolation query */ |
1045 |
|
GetInterpolCommand(const std::string& name, api::Term conj, api::Grammar* g); |
1046 |
|
|
1047 |
|
/** Get the conjecture of the interpolation query */ |
1048 |
|
api::Term getConjecture() const; |
1049 |
|
/** Get the sygus grammar given for the interpolation query */ |
1050 |
|
const api::Grammar* getGrammar() const; |
1051 |
|
/** Get the result of the query, which is the solution to the interpolation |
1052 |
|
* query. */ |
1053 |
|
api::Term getResult() const; |
1054 |
|
|
1055 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1056 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1057 |
|
Command* clone() const override; |
1058 |
|
std::string getCommandName() const override; |
1059 |
|
void toStream(std::ostream& out, |
1060 |
|
int toDepth = -1, |
1061 |
|
size_t dag = 1, |
1062 |
|
Language language = Language::LANG_AUTO) const override; |
1063 |
|
|
1064 |
|
protected: |
1065 |
|
/** The name of the interpolation predicate */ |
1066 |
|
std::string d_name; |
1067 |
|
/** The conjecture of the interpolation query */ |
1068 |
|
api::Term d_conj; |
1069 |
|
/** The (optional) grammar of the interpolation query */ |
1070 |
|
api::Grammar* d_sygus_grammar; |
1071 |
|
/** the return status of the command */ |
1072 |
|
bool d_resultStatus; |
1073 |
|
/** the return expression of the command */ |
1074 |
|
api::Term d_result; |
1075 |
|
}; /* class GetInterpolCommand */ |
1076 |
|
|
1077 |
|
/** The command (get-abduct s B (G)?) |
1078 |
|
* |
1079 |
|
* This command asks for an abduct from the current set of assertions and |
1080 |
|
* conjecture (goal) given by the argument B. |
1081 |
|
* |
1082 |
|
* The symbol s is the name for the abduction predicate. If we successfully |
1083 |
|
* find a predicate P, then the output response of this command is: |
1084 |
|
* (define-fun s () Bool P) |
1085 |
|
* |
1086 |
|
* A grammar G can be optionally provided to indicate the syntactic restrictions |
1087 |
|
* on the possible solutions returned. |
1088 |
|
*/ |
1089 |
24 |
class CVC5_EXPORT GetAbductCommand : public Command |
1090 |
|
{ |
1091 |
|
public: |
1092 |
|
GetAbductCommand(const std::string& name, api::Term conj); |
1093 |
|
GetAbductCommand(const std::string& name, api::Term conj, api::Grammar* g); |
1094 |
|
|
1095 |
|
/** Get the conjecture of the abduction query */ |
1096 |
|
api::Term getConjecture() const; |
1097 |
|
/** Get the grammar given for the abduction query */ |
1098 |
|
const api::Grammar* getGrammar() const; |
1099 |
|
/** Get the name of the abduction predicate for the abduction query */ |
1100 |
|
std::string getAbductName() const; |
1101 |
|
/** Get the result of the query, which is the solution to the abduction query. |
1102 |
|
*/ |
1103 |
|
api::Term getResult() const; |
1104 |
|
|
1105 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1106 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1107 |
|
Command* clone() const override; |
1108 |
|
std::string getCommandName() const override; |
1109 |
|
void toStream(std::ostream& out, |
1110 |
|
int toDepth = -1, |
1111 |
|
size_t dag = 1, |
1112 |
|
Language language = Language::LANG_AUTO) const override; |
1113 |
|
|
1114 |
|
protected: |
1115 |
|
/** The name of the abduction predicate */ |
1116 |
|
std::string d_name; |
1117 |
|
/** The conjecture of the abduction query */ |
1118 |
|
api::Term d_conj; |
1119 |
|
/** The (optional) grammar of the abduction query */ |
1120 |
|
api::Grammar* d_sygus_grammar; |
1121 |
|
/** the return status of the command */ |
1122 |
|
bool d_resultStatus; |
1123 |
|
/** the return expression of the command */ |
1124 |
|
api::Term d_result; |
1125 |
|
}; /* class GetAbductCommand */ |
1126 |
|
|
1127 |
16 |
class CVC5_EXPORT GetQuantifierEliminationCommand : public Command |
1128 |
|
{ |
1129 |
|
protected: |
1130 |
|
api::Term d_term; |
1131 |
|
bool d_doFull; |
1132 |
|
api::Term d_result; |
1133 |
|
|
1134 |
|
public: |
1135 |
|
GetQuantifierEliminationCommand(); |
1136 |
|
GetQuantifierEliminationCommand(const api::Term& term, bool doFull); |
1137 |
|
|
1138 |
|
api::Term getTerm() const; |
1139 |
|
bool getDoFull() const; |
1140 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1141 |
|
api::Term getResult() const; |
1142 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1143 |
|
|
1144 |
|
Command* clone() const override; |
1145 |
|
std::string getCommandName() const override; |
1146 |
|
void toStream(std::ostream& out, |
1147 |
|
int toDepth = -1, |
1148 |
|
size_t dag = 1, |
1149 |
|
Language language = Language::LANG_AUTO) const override; |
1150 |
|
}; /* class GetQuantifierEliminationCommand */ |
1151 |
|
|
1152 |
22 |
class CVC5_EXPORT GetUnsatAssumptionsCommand : public Command |
1153 |
|
{ |
1154 |
|
public: |
1155 |
|
GetUnsatAssumptionsCommand(); |
1156 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1157 |
|
std::vector<api::Term> getResult() const; |
1158 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1159 |
|
Command* clone() const override; |
1160 |
|
std::string getCommandName() const override; |
1161 |
|
void toStream(std::ostream& out, |
1162 |
|
int toDepth = -1, |
1163 |
|
size_t dag = 1, |
1164 |
|
Language language = Language::LANG_AUTO) const override; |
1165 |
|
|
1166 |
|
protected: |
1167 |
|
std::vector<api::Term> d_result; |
1168 |
|
}; /* class GetUnsatAssumptionsCommand */ |
1169 |
|
|
1170 |
28 |
class CVC5_EXPORT GetUnsatCoreCommand : public Command |
1171 |
|
{ |
1172 |
|
public: |
1173 |
|
GetUnsatCoreCommand(); |
1174 |
|
const std::vector<api::Term>& getUnsatCore() const; |
1175 |
|
|
1176 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1177 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1178 |
|
|
1179 |
|
Command* clone() const override; |
1180 |
|
std::string getCommandName() const override; |
1181 |
|
void toStream(std::ostream& out, |
1182 |
|
int toDepth = -1, |
1183 |
|
size_t dag = 1, |
1184 |
|
Language language = Language::LANG_AUTO) const override; |
1185 |
|
|
1186 |
|
protected: |
1187 |
|
/** The symbol manager we were invoked with */ |
1188 |
|
SymbolManager* d_sm; |
1189 |
|
/** the result of the unsat core call */ |
1190 |
|
std::vector<api::Term> d_result; |
1191 |
|
}; /* class GetUnsatCoreCommand */ |
1192 |
|
|
1193 |
|
class CVC5_EXPORT GetDifficultyCommand : public Command |
1194 |
|
{ |
1195 |
|
public: |
1196 |
|
GetDifficultyCommand(); |
1197 |
|
const std::map<api::Term, api::Term>& getDifficultyMap() const; |
1198 |
|
|
1199 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1200 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1201 |
|
|
1202 |
|
Command* clone() const override; |
1203 |
|
std::string getCommandName() const override; |
1204 |
|
void toStream(std::ostream& out, |
1205 |
|
int toDepth = -1, |
1206 |
|
size_t dag = 1, |
1207 |
|
Language language = Language::LANG_AUTO) const override; |
1208 |
|
|
1209 |
|
protected: |
1210 |
|
/** The symbol manager we were invoked with */ |
1211 |
|
SymbolManager* d_sm; |
1212 |
|
/** the result of the get difficulty call */ |
1213 |
|
std::map<api::Term, api::Term> d_result; |
1214 |
|
}; |
1215 |
|
|
1216 |
|
class CVC5_EXPORT GetAssertionsCommand : public Command |
1217 |
|
{ |
1218 |
|
protected: |
1219 |
|
std::string d_result; |
1220 |
|
|
1221 |
|
public: |
1222 |
|
GetAssertionsCommand(); |
1223 |
|
|
1224 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1225 |
|
std::string getResult() const; |
1226 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1227 |
|
Command* clone() const override; |
1228 |
|
std::string getCommandName() const override; |
1229 |
|
void toStream(std::ostream& out, |
1230 |
|
int toDepth = -1, |
1231 |
|
size_t dag = 1, |
1232 |
|
Language language = Language::LANG_AUTO) const override; |
1233 |
|
}; /* class GetAssertionsCommand */ |
1234 |
|
|
1235 |
|
class CVC5_EXPORT SetBenchmarkStatusCommand : public Command |
1236 |
|
{ |
1237 |
|
protected: |
1238 |
|
BenchmarkStatus d_status; |
1239 |
|
|
1240 |
|
public: |
1241 |
|
SetBenchmarkStatusCommand(BenchmarkStatus status); |
1242 |
|
|
1243 |
|
BenchmarkStatus getStatus() const; |
1244 |
|
|
1245 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1246 |
|
Command* clone() const override; |
1247 |
|
std::string getCommandName() const override; |
1248 |
|
void toStream(std::ostream& out, |
1249 |
|
int toDepth = -1, |
1250 |
|
size_t dag = 1, |
1251 |
|
Language language = Language::LANG_AUTO) const override; |
1252 |
|
}; /* class SetBenchmarkStatusCommand */ |
1253 |
|
|
1254 |
11224 |
class CVC5_EXPORT SetBenchmarkLogicCommand : public Command |
1255 |
|
{ |
1256 |
|
protected: |
1257 |
|
std::string d_logic; |
1258 |
|
|
1259 |
|
public: |
1260 |
|
SetBenchmarkLogicCommand(std::string logic); |
1261 |
|
|
1262 |
|
std::string getLogic() const; |
1263 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1264 |
|
Command* clone() const override; |
1265 |
|
std::string getCommandName() const override; |
1266 |
|
void toStream(std::ostream& out, |
1267 |
|
int toDepth = -1, |
1268 |
|
size_t dag = 1, |
1269 |
|
Language language = Language::LANG_AUTO) const override; |
1270 |
|
}; /* class SetBenchmarkLogicCommand */ |
1271 |
|
|
1272 |
11416 |
class CVC5_EXPORT SetInfoCommand : public Command |
1273 |
|
{ |
1274 |
|
protected: |
1275 |
|
std::string d_flag; |
1276 |
|
std::string d_value; |
1277 |
|
|
1278 |
|
public: |
1279 |
|
SetInfoCommand(const std::string& flag, const std::string& value); |
1280 |
|
|
1281 |
|
const std::string& getFlag() const; |
1282 |
|
const std::string& getValue() const; |
1283 |
|
|
1284 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1285 |
|
Command* clone() const override; |
1286 |
|
std::string getCommandName() const override; |
1287 |
|
void toStream(std::ostream& out, |
1288 |
|
int toDepth = -1, |
1289 |
|
size_t dag = 1, |
1290 |
|
Language language = Language::LANG_AUTO) const override; |
1291 |
|
}; /* class SetInfoCommand */ |
1292 |
|
|
1293 |
40 |
class CVC5_EXPORT GetInfoCommand : public Command |
1294 |
|
{ |
1295 |
|
protected: |
1296 |
|
std::string d_flag; |
1297 |
|
std::string d_result; |
1298 |
|
|
1299 |
|
public: |
1300 |
|
GetInfoCommand(std::string flag); |
1301 |
|
|
1302 |
|
std::string getFlag() const; |
1303 |
|
std::string getResult() const; |
1304 |
|
|
1305 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1306 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1307 |
|
Command* clone() const override; |
1308 |
|
std::string getCommandName() const override; |
1309 |
|
void toStream(std::ostream& out, |
1310 |
|
int toDepth = -1, |
1311 |
|
size_t dag = 1, |
1312 |
|
Language language = Language::LANG_AUTO) const override; |
1313 |
|
}; /* class GetInfoCommand */ |
1314 |
|
|
1315 |
14806 |
class CVC5_EXPORT SetOptionCommand : public Command |
1316 |
|
{ |
1317 |
|
protected: |
1318 |
|
std::string d_flag; |
1319 |
|
std::string d_value; |
1320 |
|
|
1321 |
|
public: |
1322 |
|
SetOptionCommand(const std::string& flag, const std::string& value); |
1323 |
|
|
1324 |
|
const std::string& getFlag() const; |
1325 |
|
const std::string& getValue() const; |
1326 |
|
|
1327 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1328 |
|
Command* clone() const override; |
1329 |
|
std::string getCommandName() const override; |
1330 |
|
void toStream(std::ostream& out, |
1331 |
|
int toDepth = -1, |
1332 |
|
size_t dag = 1, |
1333 |
|
Language language = Language::LANG_AUTO) const override; |
1334 |
|
}; /* class SetOptionCommand */ |
1335 |
|
|
1336 |
82 |
class CVC5_EXPORT GetOptionCommand : public Command |
1337 |
|
{ |
1338 |
|
protected: |
1339 |
|
std::string d_flag; |
1340 |
|
std::string d_result; |
1341 |
|
|
1342 |
|
public: |
1343 |
|
GetOptionCommand(std::string flag); |
1344 |
|
|
1345 |
|
std::string getFlag() const; |
1346 |
|
std::string getResult() const; |
1347 |
|
|
1348 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1349 |
|
void printResult(std::ostream& out, uint32_t verbosity = 2) const override; |
1350 |
|
Command* clone() const override; |
1351 |
|
std::string getCommandName() const override; |
1352 |
|
void toStream(std::ostream& out, |
1353 |
|
int toDepth = -1, |
1354 |
|
size_t dag = 1, |
1355 |
|
Language language = Language::LANG_AUTO) const override; |
1356 |
|
}; /* class GetOptionCommand */ |
1357 |
|
|
1358 |
2130 |
class CVC5_EXPORT DatatypeDeclarationCommand : public Command |
1359 |
|
{ |
1360 |
|
private: |
1361 |
|
std::vector<api::Sort> d_datatypes; |
1362 |
|
|
1363 |
|
public: |
1364 |
|
DatatypeDeclarationCommand(const api::Sort& datatype); |
1365 |
|
|
1366 |
|
DatatypeDeclarationCommand(const std::vector<api::Sort>& datatypes); |
1367 |
|
const std::vector<api::Sort>& getDatatypes() const; |
1368 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1369 |
|
Command* clone() const override; |
1370 |
|
std::string getCommandName() const override; |
1371 |
|
void toStream(std::ostream& out, |
1372 |
|
int toDepth = -1, |
1373 |
|
size_t dag = 1, |
1374 |
|
Language language = Language::LANG_AUTO) const override; |
1375 |
|
}; /* class DatatypeDeclarationCommand */ |
1376 |
|
|
1377 |
98 |
class CVC5_EXPORT ResetCommand : public Command |
1378 |
|
{ |
1379 |
|
public: |
1380 |
49 |
ResetCommand() {} |
1381 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1382 |
|
Command* clone() const override; |
1383 |
|
std::string getCommandName() const override; |
1384 |
|
void toStream(std::ostream& out, |
1385 |
|
int toDepth = -1, |
1386 |
|
size_t dag = 1, |
1387 |
|
Language language = Language::LANG_AUTO) const override; |
1388 |
|
}; /* class ResetCommand */ |
1389 |
|
|
1390 |
72 |
class CVC5_EXPORT ResetAssertionsCommand : public Command |
1391 |
|
{ |
1392 |
|
public: |
1393 |
36 |
ResetAssertionsCommand() {} |
1394 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1395 |
|
Command* clone() const override; |
1396 |
|
std::string getCommandName() const override; |
1397 |
|
void toStream(std::ostream& out, |
1398 |
|
int toDepth = -1, |
1399 |
|
size_t dag = 1, |
1400 |
|
Language language = Language::LANG_AUTO) const override; |
1401 |
|
}; /* class ResetAssertionsCommand */ |
1402 |
|
|
1403 |
1468 |
class CVC5_EXPORT QuitCommand : public Command |
1404 |
|
{ |
1405 |
|
public: |
1406 |
734 |
QuitCommand() {} |
1407 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1408 |
|
Command* clone() const override; |
1409 |
|
std::string getCommandName() const override; |
1410 |
|
void toStream(std::ostream& out, |
1411 |
|
int toDepth = -1, |
1412 |
|
size_t dag = 1, |
1413 |
|
Language language = Language::LANG_AUTO) const override; |
1414 |
|
}; /* class QuitCommand */ |
1415 |
|
|
1416 |
|
class CVC5_EXPORT CommentCommand : public Command |
1417 |
|
{ |
1418 |
|
std::string d_comment; |
1419 |
|
|
1420 |
|
public: |
1421 |
|
CommentCommand(std::string comment); |
1422 |
|
|
1423 |
|
std::string getComment() const; |
1424 |
|
|
1425 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1426 |
|
Command* clone() const override; |
1427 |
|
std::string getCommandName() const override; |
1428 |
|
void toStream(std::ostream& out, |
1429 |
|
int toDepth = -1, |
1430 |
|
size_t dag = 1, |
1431 |
|
Language language = Language::LANG_AUTO) const override; |
1432 |
|
}; /* class CommentCommand */ |
1433 |
|
|
1434 |
|
class CVC5_EXPORT CommandSequence : public Command |
1435 |
|
{ |
1436 |
|
protected: |
1437 |
|
/** All the commands to be executed (in sequence) */ |
1438 |
|
std::vector<Command*> d_commandSequence; |
1439 |
|
/** Next command to be executed */ |
1440 |
|
unsigned int d_index; |
1441 |
|
|
1442 |
|
public: |
1443 |
|
CommandSequence(); |
1444 |
|
~CommandSequence(); |
1445 |
|
|
1446 |
|
void addCommand(Command* cmd); |
1447 |
|
void clear(); |
1448 |
|
|
1449 |
|
void invoke(api::Solver* solver, SymbolManager* sm) override; |
1450 |
|
void invoke(api::Solver* solver, |
1451 |
|
SymbolManager* sm, |
1452 |
|
std::ostream& out) override; |
1453 |
|
|
1454 |
|
typedef std::vector<Command*>::iterator iterator; |
1455 |
|
typedef std::vector<Command*>::const_iterator const_iterator; |
1456 |
|
|
1457 |
|
const_iterator begin() const; |
1458 |
|
const_iterator end() const; |
1459 |
|
|
1460 |
|
iterator begin(); |
1461 |
|
iterator end(); |
1462 |
|
|
1463 |
|
Command* clone() const override; |
1464 |
|
std::string getCommandName() const override; |
1465 |
|
void toStream(std::ostream& out, |
1466 |
|
int toDepth = -1, |
1467 |
|
size_t dag = 1, |
1468 |
|
Language language = Language::LANG_AUTO) const override; |
1469 |
|
}; /* class CommandSequence */ |
1470 |
|
|
1471 |
14814 |
class CVC5_EXPORT DeclarationSequence : public CommandSequence |
1472 |
|
{ |
1473 |
|
void toStream(std::ostream& out, |
1474 |
|
int toDepth = -1, |
1475 |
|
size_t dag = 1, |
1476 |
|
Language language = Language::LANG_AUTO) const override; |
1477 |
|
}; |
1478 |
|
|
1479 |
|
} // namespace cvc5 |
1480 |
|
|
1481 |
|
#endif /* CVC5__COMMAND_H */ |