1 /********************* */
4 ** Original author: Morgan Deters
5 ** Major contributors: none
6 ** Minor contributors (to current version): Kshitij Bansal, Christopher L. Conway, Dejan Jovanovic, Francois Bobot, Andrew Reynolds
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2014 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
12 ** \brief Implementation of the command pattern on SmtEngines.
14 ** Implementation of the command pattern on SmtEngines. Command
15 ** objects are generated by the parser (typically) to implement the
16 ** commands in parsed input (see Parser::parseNextCommand()), or by
20 #include "cvc4_public.h"
22 #ifndef __CVC4__COMMAND_H
23 #define __CVC4__COMMAND_H
31 #include "expr/expr.h"
32 #include "expr/type.h"
33 #include "expr/variable_type_map.h"
34 #include "util/result.h"
35 #include "util/sexpr.h"
36 #include "util/datatype.h"
37 #include "util/proof.h"
46 std::ostream
& operator<<(std::ostream
&, const Command
&) throw() CVC4_PUBLIC
;
47 std::ostream
& operator<<(std::ostream
&, const Command
*) throw() CVC4_PUBLIC
;
48 std::ostream
& operator<<(std::ostream
&, const CommandStatus
&) throw() CVC4_PUBLIC
;
49 std::ostream
& operator<<(std::ostream
&, const CommandStatus
*) throw() CVC4_PUBLIC
;
51 /** The status an SMT benchmark can have */
52 enum BenchmarkStatus
{
53 /** Benchmark is satisfiable */
55 /** Benchmark is unsatisfiable */
57 /** The status of the benchmark is unknown */
59 };/* enum BenchmarkStatus */
61 std::ostream
& operator<<(std::ostream
& out
,
62 BenchmarkStatus status
) throw() CVC4_PUBLIC
;
65 * IOStream manipulator to print success messages or not.
67 * out << Command::printsuccess(false) << CommandSuccess();
71 * out << Command::printsuccess(true) << CommandSuccess();
73 * prints a success message (in a manner appropriate for the current
76 class CVC4_PUBLIC CommandPrintSuccess
{
78 * The allocated index in ios_base for our depth setting.
80 static const int s_iosIndex
;
83 * The default setting, for ostreams that haven't yet had a
84 * setdepth() applied to them.
86 static const int s_defaultPrintSuccess
= false;
89 * When this manipulator is used, the setting is stored here.
95 * Construct a CommandPrintSuccess with the given setting.
97 CommandPrintSuccess(bool printSuccess
) throw() : d_printSuccess(printSuccess
) {}
99 inline void applyPrintSuccess(std::ostream
& out
) throw() {
100 out
.iword(s_iosIndex
) = d_printSuccess
;
103 static inline bool getPrintSuccess(std::ostream
& out
) throw() {
104 return out
.iword(s_iosIndex
);
107 static inline void setPrintSuccess(std::ostream
& out
, bool printSuccess
) throw() {
108 out
.iword(s_iosIndex
) = printSuccess
;
112 * Set the print-success state on the output stream for the current
113 * stack scope. This makes sure the old state is reset on the
114 * stream after normal OR exceptional exit from the scope, using the
119 bool d_oldPrintSuccess
;
123 inline Scope(std::ostream
& out
, bool printSuccess
) throw() :
125 d_oldPrintSuccess(CommandPrintSuccess::getPrintSuccess(out
)) {
126 CommandPrintSuccess::setPrintSuccess(out
, printSuccess
);
129 inline ~Scope() throw() {
130 CommandPrintSuccess::setPrintSuccess(d_out
, d_oldPrintSuccess
);
133 };/* class CommandPrintSuccess::Scope */
135 };/* class CommandPrintSuccess */
138 * Sets the default print-success setting when pretty-printing an Expr
139 * to an ostream. Use like this:
141 * // let out be an ostream, e an Expr
142 * out << Expr::setdepth(n) << e << endl;
144 * The depth stays permanently (until set again) with the stream.
146 inline std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
) throw() CVC4_PUBLIC
;
147 inline std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
) throw() {
148 cps
.applyPrintSuccess(out
);
152 class CVC4_PUBLIC CommandStatus
{
154 // shouldn't construct a CommandStatus (use a derived class)
155 CommandStatus() throw() {}
157 virtual ~CommandStatus() throw() {}
158 void toStream(std::ostream
& out
,
159 OutputLanguage language
= language::output::LANG_AUTO
) const throw();
160 virtual CommandStatus
& clone() const = 0;
161 };/* class CommandStatus */
163 class CVC4_PUBLIC CommandSuccess
: public CommandStatus
{
164 static const CommandSuccess
* s_instance
;
166 static const CommandSuccess
* instance() throw() { return s_instance
; }
167 CommandStatus
& clone() const { return const_cast<CommandSuccess
&>(*this); }
168 };/* class CommandSuccess */
170 class CVC4_PUBLIC CommandUnsupported
: public CommandStatus
{
172 CommandStatus
& clone() const { return *new CommandUnsupported(*this); }
173 };/* class CommandSuccess */
175 class CVC4_PUBLIC CommandFailure
: public CommandStatus
{
176 std::string d_message
;
178 CommandFailure(std::string message
) throw() : d_message(message
) {}
179 CommandFailure
& clone() const { return *new CommandFailure(*this); }
180 ~CommandFailure() throw() {}
181 std::string
getMessage() const throw() { return d_message
; }
182 };/* class CommandFailure */
184 class CVC4_PUBLIC Command
{
187 * This field contains a command status if the command has been
188 * invoked, or NULL if it has not. This field is either a
189 * dynamically-allocated pointer, or it's a pointer to the singleton
190 * CommandSuccess instance. Doing so is somewhat asymmetric, but
191 * it avoids the need to dynamically allocate memory in the common
192 * case of a successful command.
194 const CommandStatus
* d_commandStatus
;
197 * True if this command is "muted"---i.e., don't print "success" on
198 * successful execution.
203 typedef CommandPrintSuccess printsuccess
;
206 Command(const Command
& cmd
);
208 virtual ~Command() throw();
210 virtual void invoke(SmtEngine
* smtEngine
) throw() = 0;
211 virtual void invoke(SmtEngine
* smtEngine
, std::ostream
& out
) throw();
213 virtual void toStream(std::ostream
& out
, int toDepth
= -1, bool types
= false, size_t dag
= 1,
214 OutputLanguage language
= language::output::LANG_AUTO
) const throw();
216 std::string
toString() const throw();
218 virtual std::string
getCommandName() const throw() = 0;
221 * If false, instruct this Command not to print a success message.
223 void setMuted(bool muted
) throw() { d_muted
= muted
; }
226 * Determine whether this Command will print a success message.
228 bool isMuted() throw() { return d_muted
; }
231 * Either the command hasn't run yet, or it completed successfully
232 * (CommandSuccess, not CommandUnsupported or CommandFailure).
234 bool ok() const throw();
237 * The command completed in a failure state (CommandFailure, not
238 * CommandSuccess or CommandUnsupported).
240 bool fail() const throw();
242 /** Get the command status (it's NULL if we haven't run yet). */
243 const CommandStatus
* getCommandStatus() const throw() { return d_commandStatus
; }
245 virtual void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
248 * Maps this Command into one for a different ExprManager, using
249 * variableMap for the translation and extending it with any new
252 virtual Command
* exportTo(ExprManager
* exprManager
,
253 ExprManagerMapCollection
& variableMap
) = 0;
256 * Clone this Command (make a shallow copy).
258 virtual Command
* clone() const = 0;
261 class ExportTransformer
{
262 ExprManager
* d_exprManager
;
263 ExprManagerMapCollection
& d_variableMap
;
265 ExportTransformer(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
) :
266 d_exprManager(exprManager
),
267 d_variableMap(variableMap
) {
269 Expr
operator()(Expr e
) {
270 return e
.exportTo(d_exprManager
, d_variableMap
);
272 Type
operator()(Type t
) {
273 return t
.exportTo(d_exprManager
, d_variableMap
);
275 };/* class Command::ExportTransformer */
276 };/* class Command */
279 * EmptyCommands are the residue of a command after the parser handles
280 * them (and there's nothing left to do).
282 class CVC4_PUBLIC EmptyCommand
: public Command
{
286 EmptyCommand(std::string name
= "") throw();
287 ~EmptyCommand() throw() {}
288 std::string
getName() const throw();
289 void invoke(SmtEngine
* smtEngine
) throw();
290 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
291 Command
* clone() const;
292 std::string
getCommandName() const throw();
293 };/* class EmptyCommand */
295 class CVC4_PUBLIC EchoCommand
: public Command
{
297 std::string d_output
;
299 EchoCommand(std::string output
= "") throw();
300 ~EchoCommand() throw() {}
301 std::string
getOutput() const throw();
302 void invoke(SmtEngine
* smtEngine
) throw();
303 void invoke(SmtEngine
* smtEngine
, std::ostream
& out
) throw();
304 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
305 Command
* clone() const;
306 std::string
getCommandName() const throw();
307 };/* class EchoCommand */
309 class CVC4_PUBLIC AssertCommand
: public Command
{
313 AssertCommand(const Expr
& e
) throw();
314 ~AssertCommand() throw() {}
315 Expr
getExpr() const throw();
316 void invoke(SmtEngine
* smtEngine
) throw();
317 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
318 Command
* clone() const;
319 std::string
getCommandName() const throw();
320 };/* class AssertCommand */
322 class CVC4_PUBLIC PushCommand
: public Command
{
324 ~PushCommand() throw() {}
325 void invoke(SmtEngine
* smtEngine
) throw();
326 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
327 Command
* clone() const;
328 std::string
getCommandName() const throw();
329 };/* class PushCommand */
331 class CVC4_PUBLIC PopCommand
: public Command
{
333 ~PopCommand() throw() {}
334 void invoke(SmtEngine
* smtEngine
) throw();
335 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
336 Command
* clone() const;
337 std::string
getCommandName() const throw();
338 };/* class PopCommand */
340 class CVC4_PUBLIC DeclarationDefinitionCommand
: public Command
{
342 std::string d_symbol
;
344 DeclarationDefinitionCommand(const std::string
& id
) throw();
345 ~DeclarationDefinitionCommand() throw() {}
346 virtual void invoke(SmtEngine
* smtEngine
) throw() = 0;
347 std::string
getSymbol() const throw();
348 };/* class DeclarationDefinitionCommand */
350 class CVC4_PUBLIC DeclareFunctionCommand
: public DeclarationDefinitionCommand
{
355 bool d_printInModelSetByUser
;
357 DeclareFunctionCommand(const std::string
& id
, Expr func
, Type type
) throw();
358 ~DeclareFunctionCommand() throw() {}
359 Expr
getFunction() const throw();
360 Type
getType() const throw();
361 bool getPrintInModel() const throw();
362 bool getPrintInModelSetByUser() const throw();
363 void setPrintInModel( bool p
);
364 void invoke(SmtEngine
* smtEngine
) throw();
365 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
366 Command
* clone() const;
367 std::string
getCommandName() const throw();
368 };/* class DeclareFunctionCommand */
370 class CVC4_PUBLIC DeclareTypeCommand
: public DeclarationDefinitionCommand
{
375 DeclareTypeCommand(const std::string
& id
, size_t arity
, Type t
) throw();
376 ~DeclareTypeCommand() throw() {}
377 size_t getArity() const throw();
378 Type
getType() const throw();
379 void invoke(SmtEngine
* smtEngine
) throw();
380 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
381 Command
* clone() const;
382 std::string
getCommandName() const throw();
383 };/* class DeclareTypeCommand */
385 class CVC4_PUBLIC DefineTypeCommand
: public DeclarationDefinitionCommand
{
387 std::vector
<Type
> d_params
;
390 DefineTypeCommand(const std::string
& id
, Type t
) throw();
391 DefineTypeCommand(const std::string
& id
, const std::vector
<Type
>& params
, Type t
) throw();
392 ~DefineTypeCommand() throw() {}
393 const std::vector
<Type
>& getParameters() const throw();
394 Type
getType() const throw();
395 void invoke(SmtEngine
* smtEngine
) throw();
396 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
397 Command
* clone() const;
398 std::string
getCommandName() const throw();
399 };/* class DefineTypeCommand */
401 class CVC4_PUBLIC DefineFunctionCommand
: public DeclarationDefinitionCommand
{
404 std::vector
<Expr
> d_formals
;
407 DefineFunctionCommand(const std::string
& id
, Expr func
, Expr formula
) throw();
408 DefineFunctionCommand(const std::string
& id
, Expr func
,
409 const std::vector
<Expr
>& formals
, Expr formula
) throw();
410 ~DefineFunctionCommand() throw() {}
411 Expr
getFunction() const throw();
412 const std::vector
<Expr
>& getFormals() const throw();
413 Expr
getFormula() const throw();
414 void invoke(SmtEngine
* smtEngine
) throw();
415 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
416 Command
* clone() const;
417 std::string
getCommandName() const throw();
418 };/* class DefineFunctionCommand */
421 * This differs from DefineFunctionCommand only in that it instructs
422 * the SmtEngine to "remember" this function for later retrieval with
423 * getAssignment(). Used for :named attributes in SMT-LIBv2.
425 class CVC4_PUBLIC DefineNamedFunctionCommand
: public DefineFunctionCommand
{
427 DefineNamedFunctionCommand(const std::string
& id
, Expr func
,
428 const std::vector
<Expr
>& formals
, Expr formula
) throw();
429 void invoke(SmtEngine
* smtEngine
) throw();
430 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
431 Command
* clone() const;
432 };/* class DefineNamedFunctionCommand */
435 * The command when an attribute is set by a user. In SMT-LIBv2 this is done
436 * via the syntax (! expr :attr)
438 class CVC4_PUBLIC SetUserAttributeCommand
: public Command
{
442 //std::vector<Expr> d_expr_values;
443 //std::string d_str_value;
445 SetUserAttributeCommand( const std::string
& attr
, Expr expr
) throw();
446 //SetUserAttributeCommand( const std::string& id, Expr expr, std::vector<Expr>& values ) throw();
447 //SetUserAttributeCommand( const std::string& id, Expr expr, std::string& value ) throw();
448 ~SetUserAttributeCommand() throw() {}
449 void invoke(SmtEngine
* smtEngine
) throw();
450 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
451 Command
* clone() const;
452 std::string
getCommandName() const throw();
453 };/* class SetUserAttributeCommand */
456 class CVC4_PUBLIC CheckSatCommand
: public Command
{
461 CheckSatCommand() throw();
462 CheckSatCommand(const Expr
& expr
) throw();
463 ~CheckSatCommand() throw() {}
464 Expr
getExpr() const throw();
465 void invoke(SmtEngine
* smtEngine
) throw();
466 Result
getResult() const throw();
467 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
468 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
469 Command
* clone() const;
470 std::string
getCommandName() const throw();
471 };/* class CheckSatCommand */
473 class CVC4_PUBLIC QueryCommand
: public Command
{
478 QueryCommand(const Expr
& e
) throw();
479 ~QueryCommand() throw() {}
480 Expr
getExpr() const throw();
481 void invoke(SmtEngine
* smtEngine
) throw();
482 Result
getResult() const throw();
483 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
484 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
485 Command
* clone() const;
486 std::string
getCommandName() const throw();
487 };/* class QueryCommand */
489 // this is TRANSFORM in the CVC presentation language
490 class CVC4_PUBLIC SimplifyCommand
: public Command
{
495 SimplifyCommand(Expr term
) throw();
496 ~SimplifyCommand() throw() {}
497 Expr
getTerm() const throw();
498 void invoke(SmtEngine
* smtEngine
) throw();
499 Expr
getResult() const throw();
500 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
501 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
502 Command
* clone() const;
503 std::string
getCommandName() const throw();
504 };/* class SimplifyCommand */
506 class CVC4_PUBLIC ExpandDefinitionsCommand
: public Command
{
511 ExpandDefinitionsCommand(Expr term
) throw();
512 ~ExpandDefinitionsCommand() throw() {}
513 Expr
getTerm() const throw();
514 void invoke(SmtEngine
* smtEngine
) throw();
515 Expr
getResult() const throw();
516 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
517 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
518 Command
* clone() const;
519 std::string
getCommandName() const throw();
520 };/* class ExpandDefinitionsCommand */
522 class CVC4_PUBLIC GetValueCommand
: public Command
{
524 std::vector
<Expr
> d_terms
;
527 GetValueCommand(Expr term
) throw();
528 GetValueCommand(const std::vector
<Expr
>& terms
) throw();
529 ~GetValueCommand() throw() {}
530 const std::vector
<Expr
>& getTerms() const throw();
531 void invoke(SmtEngine
* smtEngine
) throw();
532 Expr
getResult() const throw();
533 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
534 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
535 Command
* clone() const;
536 std::string
getCommandName() const throw();
537 };/* class GetValueCommand */
539 class CVC4_PUBLIC GetAssignmentCommand
: public Command
{
543 GetAssignmentCommand() throw();
544 ~GetAssignmentCommand() throw() {}
545 void invoke(SmtEngine
* smtEngine
) throw();
546 SExpr
getResult() const throw();
547 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
548 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
549 Command
* clone() const;
550 std::string
getCommandName() const throw();
551 };/* class GetAssignmentCommand */
553 class CVC4_PUBLIC GetModelCommand
: public Command
{
556 SmtEngine
* d_smtEngine
;
558 GetModelCommand() throw();
559 ~GetModelCommand() throw() {}
560 void invoke(SmtEngine
* smtEngine
) throw();
561 // Model is private to the library -- for now
562 //Model* getResult() const throw();
563 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
564 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
565 Command
* clone() const;
566 std::string
getCommandName() const throw();
567 };/* class GetModelCommand */
569 class CVC4_PUBLIC GetProofCommand
: public Command
{
573 GetProofCommand() throw();
574 ~GetProofCommand() throw() {}
575 void invoke(SmtEngine
* smtEngine
) throw();
576 Proof
* getResult() const throw();
577 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
578 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
579 Command
* clone() const;
580 std::string
getCommandName() const throw();
581 };/* class GetProofCommand */
583 class CVC4_PUBLIC GetInstantiationsCommand
: public Command
{
585 //Instantiations* d_result;
586 SmtEngine
* d_smtEngine
;
588 GetInstantiationsCommand() throw();
589 ~GetInstantiationsCommand() throw() {}
590 void invoke(SmtEngine
* smtEngine
) throw();
591 //Instantiations* getResult() const throw();
592 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
593 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
594 Command
* clone() const;
595 std::string
getCommandName() const throw();
596 };/* class GetInstantiationsCommand */
598 class CVC4_PUBLIC GetUnsatCoreCommand
: public Command
{
600 //UnsatCore* d_result;
602 GetUnsatCoreCommand() throw();
603 ~GetUnsatCoreCommand() throw() {}
604 void invoke(SmtEngine
* smtEngine
) throw();
605 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
606 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
607 Command
* clone() const;
608 std::string
getCommandName() const throw();
609 };/* class GetUnsatCoreCommand */
611 class CVC4_PUBLIC GetAssertionsCommand
: public Command
{
613 std::string d_result
;
615 GetAssertionsCommand() throw();
616 ~GetAssertionsCommand() throw() {}
617 void invoke(SmtEngine
* smtEngine
) throw();
618 std::string
getResult() const throw();
619 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
620 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
621 Command
* clone() const;
622 std::string
getCommandName() const throw();
623 };/* class GetAssertionsCommand */
625 class CVC4_PUBLIC SetBenchmarkStatusCommand
: public Command
{
627 BenchmarkStatus d_status
;
629 SetBenchmarkStatusCommand(BenchmarkStatus status
) throw();
630 ~SetBenchmarkStatusCommand() throw() {}
631 BenchmarkStatus
getStatus() const throw();
632 void invoke(SmtEngine
* smtEngine
) throw();
633 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
634 Command
* clone() const;
635 std::string
getCommandName() const throw();
636 };/* class SetBenchmarkStatusCommand */
638 class CVC4_PUBLIC SetBenchmarkLogicCommand
: public Command
{
642 SetBenchmarkLogicCommand(std::string logic
) throw();
643 ~SetBenchmarkLogicCommand() throw() {}
644 std::string
getLogic() const throw();
645 void invoke(SmtEngine
* smtEngine
) throw();
646 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
647 Command
* clone() const;
648 std::string
getCommandName() const throw();
649 };/* class SetBenchmarkLogicCommand */
651 class CVC4_PUBLIC SetInfoCommand
: public Command
{
656 SetInfoCommand(std::string flag
, const SExpr
& sexpr
) throw();
657 ~SetInfoCommand() throw() {}
658 std::string
getFlag() const throw();
659 SExpr
getSExpr() const throw();
660 void invoke(SmtEngine
* smtEngine
) throw();
661 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
662 Command
* clone() const;
663 std::string
getCommandName() const throw();
664 };/* class SetInfoCommand */
666 class CVC4_PUBLIC GetInfoCommand
: public Command
{
669 std::string d_result
;
671 GetInfoCommand(std::string flag
) throw();
672 ~GetInfoCommand() throw() {}
673 std::string
getFlag() const throw();
674 void invoke(SmtEngine
* smtEngine
) throw();
675 std::string
getResult() const throw();
676 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
677 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
678 Command
* clone() const;
679 std::string
getCommandName() const throw();
680 };/* class GetInfoCommand */
682 class CVC4_PUBLIC SetOptionCommand
: public Command
{
687 SetOptionCommand(std::string flag
, const SExpr
& sexpr
) throw();
688 ~SetOptionCommand() throw() {}
689 std::string
getFlag() const throw();
690 SExpr
getSExpr() const throw();
691 void invoke(SmtEngine
* smtEngine
) throw();
692 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
693 Command
* clone() const;
694 std::string
getCommandName() const throw();
695 };/* class SetOptionCommand */
697 class CVC4_PUBLIC GetOptionCommand
: public Command
{
700 std::string d_result
;
702 GetOptionCommand(std::string flag
) throw();
703 ~GetOptionCommand() throw() {}
704 std::string
getFlag() const throw();
705 void invoke(SmtEngine
* smtEngine
) throw();
706 std::string
getResult() const throw();
707 void printResult(std::ostream
& out
, uint32_t verbosity
= 2) const throw();
708 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
709 Command
* clone() const;
710 std::string
getCommandName() const throw();
711 };/* class GetOptionCommand */
713 class CVC4_PUBLIC DatatypeDeclarationCommand
: public Command
{
715 std::vector
<DatatypeType
> d_datatypes
;
717 DatatypeDeclarationCommand(const DatatypeType
& datatype
) throw();
718 ~DatatypeDeclarationCommand() throw() {}
719 DatatypeDeclarationCommand(const std::vector
<DatatypeType
>& datatypes
) throw();
720 const std::vector
<DatatypeType
>& getDatatypes() const throw();
721 void invoke(SmtEngine
* smtEngine
) throw();
722 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
723 Command
* clone() const;
724 std::string
getCommandName() const throw();
725 };/* class DatatypeDeclarationCommand */
727 class CVC4_PUBLIC RewriteRuleCommand
: public Command
{
729 typedef std::vector
< std::vector
< Expr
> > Triggers
;
731 typedef std::vector
< Expr
> VExpr
;
738 RewriteRuleCommand(const std::vector
<Expr
>& vars
,
739 const std::vector
<Expr
>& guards
,
742 const Triggers
& d_triggers
) throw();
743 RewriteRuleCommand(const std::vector
<Expr
>& vars
,
746 ~RewriteRuleCommand() throw() {}
747 const std::vector
<Expr
>& getVars() const throw();
748 const std::vector
<Expr
>& getGuards() const throw();
749 Expr
getHead() const throw();
750 Expr
getBody() const throw();
751 const Triggers
& getTriggers() const throw();
752 void invoke(SmtEngine
* smtEngine
) throw();
753 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
754 Command
* clone() const;
755 std::string
getCommandName() const throw();
756 };/* class RewriteRuleCommand */
758 class CVC4_PUBLIC PropagateRuleCommand
: public Command
{
760 typedef std::vector
< std::vector
< Expr
> > Triggers
;
762 typedef std::vector
< Expr
> VExpr
;
770 PropagateRuleCommand(const std::vector
<Expr
>& vars
,
771 const std::vector
<Expr
>& guards
,
772 const std::vector
<Expr
>& heads
,
774 const Triggers
& d_triggers
,
775 /* true if we want a deduction rule */
776 bool d_deduction
= false) throw();
777 PropagateRuleCommand(const std::vector
<Expr
>& vars
,
778 const std::vector
<Expr
>& heads
,
780 bool d_deduction
= false) throw();
781 ~PropagateRuleCommand() throw() {}
782 const std::vector
<Expr
>& getVars() const throw();
783 const std::vector
<Expr
>& getGuards() const throw();
784 const std::vector
<Expr
>& getHeads() const throw();
785 Expr
getBody() const throw();
786 const Triggers
& getTriggers() const throw();
787 bool isDeduction() const throw();
788 void invoke(SmtEngine
* smtEngine
) throw();
789 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
790 Command
* clone() const;
791 std::string
getCommandName() const throw();
792 };/* class PropagateRuleCommand */
795 class CVC4_PUBLIC QuitCommand
: public Command
{
797 QuitCommand() throw();
798 ~QuitCommand() throw() {}
799 void invoke(SmtEngine
* smtEngine
) throw();
800 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
801 Command
* clone() const;
802 std::string
getCommandName() const throw();
803 };/* class QuitCommand */
805 class CVC4_PUBLIC CommentCommand
: public Command
{
806 std::string d_comment
;
808 CommentCommand(std::string comment
) throw();
809 ~CommentCommand() throw() {}
810 std::string
getComment() const throw();
811 void invoke(SmtEngine
* smtEngine
) throw();
812 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
813 Command
* clone() const;
814 std::string
getCommandName() const throw();
815 };/* class CommentCommand */
817 class CVC4_PUBLIC CommandSequence
: public Command
{
819 /** All the commands to be executed (in sequence) */
820 std::vector
<Command
*> d_commandSequence
;
821 /** Next command to be executed */
822 unsigned int d_index
;
824 CommandSequence() throw();
825 ~CommandSequence() throw();
827 void addCommand(Command
* cmd
) throw();
828 void clear() throw();
830 void invoke(SmtEngine
* smtEngine
) throw();
831 void invoke(SmtEngine
* smtEngine
, std::ostream
& out
) throw();
833 typedef std::vector
<Command
*>::iterator iterator
;
834 typedef std::vector
<Command
*>::const_iterator const_iterator
;
836 const_iterator
begin() const throw();
837 const_iterator
end() const throw();
839 iterator
begin() throw();
840 iterator
end() throw();
842 Command
* exportTo(ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
);
843 Command
* clone() const;
844 std::string
getCommandName() const throw();
845 };/* class CommandSequence */
847 class CVC4_PUBLIC DeclarationSequence
: public CommandSequence
{
849 ~DeclarationSequence() throw() {}
850 };/* class DeclarationSequence */
852 }/* CVC4 namespace */
854 #endif /* __CVC4__COMMAND_H */