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