1 /********************* */
4 ** Top contributors (to current version):
5 ** Tim King, Morgan Deters, Andrew Reynolds
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2018 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.\endverbatim
12 ** \brief Implementation of command objects.
14 ** Implementation of command objects.
17 #include "smt/command.h"
26 #include "base/cvc4_assert.h"
27 #include "base/output.h"
28 #include "expr/expr_iomanip.h"
29 #include "expr/node.h"
30 #include "options/options.h"
31 #include "options/smt_options.h"
32 #include "printer/printer.h"
34 #include "smt/model.h"
35 #include "smt/smt_engine.h"
36 #include "smt/smt_engine_scope.h"
37 #include "util/sexpr.h"
38 #include "util/utility.h"
46 std::vector
<Expr
> ExportTo(ExprManager
* exprManager
,
47 ExprManagerMapCollection
& variableMap
,
48 const std::vector
<Expr
>& exprs
)
50 std::vector
<Expr
> exported
;
51 exported
.reserve(exprs
.size());
52 for (const Expr
& expr
: exprs
)
54 exported
.push_back(expr
.exportTo(exprManager
, variableMap
));
61 const int CommandPrintSuccess::s_iosIndex
= std::ios_base::xalloc();
62 const CommandSuccess
* CommandSuccess::s_instance
= new CommandSuccess();
63 const CommandInterrupted
* CommandInterrupted::s_instance
=
64 new CommandInterrupted();
66 std::ostream
& operator<<(std::ostream
& out
, const Command
& c
)
69 Node::setdepth::getDepth(out
),
70 Node::printtypes::getPrintTypes(out
),
71 Node::dag::getDag(out
),
72 Node::setlanguage::getLanguage(out
));
76 ostream
& operator<<(ostream
& out
, const Command
* c
)
89 std::ostream
& operator<<(std::ostream
& out
, const CommandStatus
& s
)
91 s
.toStream(out
, Node::setlanguage::getLanguage(out
));
95 ostream
& operator<<(ostream
& out
, const CommandStatus
* s
)
109 /* output stream insertion operator for benchmark statuses */
110 std::ostream
& operator<<(std::ostream
& out
, BenchmarkStatus status
)
114 case SMT_SATISFIABLE
: return out
<< "sat";
116 case SMT_UNSATISFIABLE
: return out
<< "unsat";
118 case SMT_UNKNOWN
: return out
<< "unknown";
120 default: return out
<< "BenchmarkStatus::[UNKNOWNSTATUS!]";
124 /* -------------------------------------------------------------------------- */
125 /* class CommandPrintSuccess */
126 /* -------------------------------------------------------------------------- */
128 void CommandPrintSuccess::applyPrintSuccess(std::ostream
& out
)
130 out
.iword(s_iosIndex
) = d_printSuccess
;
133 bool CommandPrintSuccess::getPrintSuccess(std::ostream
& out
)
135 return out
.iword(s_iosIndex
);
138 void CommandPrintSuccess::setPrintSuccess(std::ostream
& out
, bool printSuccess
)
140 out
.iword(s_iosIndex
) = printSuccess
;
143 std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
)
145 cps
.applyPrintSuccess(out
);
149 /* -------------------------------------------------------------------------- */
151 /* -------------------------------------------------------------------------- */
153 Command::Command() : d_commandStatus(NULL
), d_muted(false) {}
154 Command::Command(const Command
& cmd
)
157 (cmd
.d_commandStatus
== NULL
) ? NULL
: &cmd
.d_commandStatus
->clone();
158 d_muted
= cmd
.d_muted
;
163 if (d_commandStatus
!= NULL
&& d_commandStatus
!= CommandSuccess::instance())
165 delete d_commandStatus
;
169 bool Command::ok() const
171 // either we haven't run the command yet, or it ran successfully
172 return d_commandStatus
== NULL
173 || dynamic_cast<const CommandSuccess
*>(d_commandStatus
) != NULL
;
176 bool Command::fail() const
178 return d_commandStatus
!= NULL
179 && dynamic_cast<const CommandFailure
*>(d_commandStatus
) != NULL
;
182 bool Command::interrupted() const
184 return d_commandStatus
!= NULL
185 && dynamic_cast<const CommandInterrupted
*>(d_commandStatus
) != NULL
;
188 void Command::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
191 if (!(isMuted() && ok()))
194 smtEngine
->getOption("command-verbosity:" + getCommandName())
200 std::string
Command::toString() const
202 std::stringstream ss
;
207 void Command::toStream(std::ostream
& out
,
211 OutputLanguage language
) const
213 Printer::getPrinter(language
)->toStream(out
, this, toDepth
, types
, dag
);
216 void CommandStatus::toStream(std::ostream
& out
, OutputLanguage language
) const
218 Printer::getPrinter(language
)->toStream(out
, this);
221 void Command::printResult(std::ostream
& out
, uint32_t verbosity
) const
223 if (d_commandStatus
!= NULL
)
225 if ((!ok() && verbosity
>= 1) || verbosity
>= 2)
227 out
<< *d_commandStatus
;
232 /* -------------------------------------------------------------------------- */
233 /* class EmptyCommand */
234 /* -------------------------------------------------------------------------- */
236 EmptyCommand::EmptyCommand(std::string name
) : d_name(name
) {}
237 std::string
EmptyCommand::getName() const { return d_name
; }
238 void EmptyCommand::invoke(SmtEngine
* smtEngine
)
240 /* empty commands have no implementation */
241 d_commandStatus
= CommandSuccess::instance();
244 Command
* EmptyCommand::exportTo(ExprManager
* exprManager
,
245 ExprManagerMapCollection
& variableMap
)
247 return new EmptyCommand(d_name
);
250 Command
* EmptyCommand::clone() const { return new EmptyCommand(d_name
); }
251 std::string
EmptyCommand::getCommandName() const { return "empty"; }
253 /* -------------------------------------------------------------------------- */
254 /* class EchoCommand */
255 /* -------------------------------------------------------------------------- */
257 EchoCommand::EchoCommand(std::string output
) : d_output(output
) {}
258 std::string
EchoCommand::getOutput() const { return d_output
; }
259 void EchoCommand::invoke(SmtEngine
* smtEngine
)
261 /* we don't have an output stream here, nothing to do */
262 d_commandStatus
= CommandSuccess::instance();
265 void EchoCommand::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
267 out
<< d_output
<< std::endl
;
268 d_commandStatus
= CommandSuccess::instance();
270 smtEngine
->getOption("command-verbosity:" + getCommandName())
275 Command
* EchoCommand::exportTo(ExprManager
* exprManager
,
276 ExprManagerMapCollection
& variableMap
)
278 return new EchoCommand(d_output
);
281 Command
* EchoCommand::clone() const { return new EchoCommand(d_output
); }
282 std::string
EchoCommand::getCommandName() const { return "echo"; }
284 /* -------------------------------------------------------------------------- */
285 /* class AssertCommand */
286 /* -------------------------------------------------------------------------- */
288 AssertCommand::AssertCommand(const Expr
& e
, bool inUnsatCore
)
289 : d_expr(e
), d_inUnsatCore(inUnsatCore
)
293 Expr
AssertCommand::getExpr() const { return d_expr
; }
294 void AssertCommand::invoke(SmtEngine
* smtEngine
)
298 smtEngine
->assertFormula(d_expr
, d_inUnsatCore
);
299 d_commandStatus
= CommandSuccess::instance();
301 catch (UnsafeInterruptException
& e
)
303 d_commandStatus
= new CommandInterrupted();
307 d_commandStatus
= new CommandFailure(e
.what());
311 Command
* AssertCommand::exportTo(ExprManager
* exprManager
,
312 ExprManagerMapCollection
& variableMap
)
314 return new AssertCommand(d_expr
.exportTo(exprManager
, variableMap
),
318 Command
* AssertCommand::clone() const
320 return new AssertCommand(d_expr
, d_inUnsatCore
);
323 std::string
AssertCommand::getCommandName() const { return "assert"; }
325 /* -------------------------------------------------------------------------- */
326 /* class PushCommand */
327 /* -------------------------------------------------------------------------- */
329 void PushCommand::invoke(SmtEngine
* smtEngine
)
334 d_commandStatus
= CommandSuccess::instance();
336 catch (UnsafeInterruptException
& e
)
338 d_commandStatus
= new CommandInterrupted();
342 d_commandStatus
= new CommandFailure(e
.what());
346 Command
* PushCommand::exportTo(ExprManager
* exprManager
,
347 ExprManagerMapCollection
& variableMap
)
349 return new PushCommand();
352 Command
* PushCommand::clone() const { return new PushCommand(); }
353 std::string
PushCommand::getCommandName() const { return "push"; }
355 /* -------------------------------------------------------------------------- */
356 /* class PopCommand */
357 /* -------------------------------------------------------------------------- */
359 void PopCommand::invoke(SmtEngine
* smtEngine
)
364 d_commandStatus
= CommandSuccess::instance();
366 catch (UnsafeInterruptException
& e
)
368 d_commandStatus
= new CommandInterrupted();
372 d_commandStatus
= new CommandFailure(e
.what());
376 Command
* PopCommand::exportTo(ExprManager
* exprManager
,
377 ExprManagerMapCollection
& variableMap
)
379 return new PopCommand();
382 Command
* PopCommand::clone() const { return new PopCommand(); }
383 std::string
PopCommand::getCommandName() const { return "pop"; }
385 /* -------------------------------------------------------------------------- */
386 /* class CheckSatCommand */
387 /* -------------------------------------------------------------------------- */
389 CheckSatCommand::CheckSatCommand() : d_expr() {}
391 CheckSatCommand::CheckSatCommand(const Expr
& expr
) : d_expr(expr
) {}
393 Expr
CheckSatCommand::getExpr() const { return d_expr
; }
394 void CheckSatCommand::invoke(SmtEngine
* smtEngine
)
398 d_result
= smtEngine
->checkSat(d_expr
);
399 d_commandStatus
= CommandSuccess::instance();
403 d_commandStatus
= new CommandFailure(e
.what());
407 Result
CheckSatCommand::getResult() const { return d_result
; }
408 void CheckSatCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
412 this->Command::printResult(out
, verbosity
);
416 out
<< d_result
<< endl
;
420 Command
* CheckSatCommand::exportTo(ExprManager
* exprManager
,
421 ExprManagerMapCollection
& variableMap
)
424 new CheckSatCommand(d_expr
.exportTo(exprManager
, variableMap
));
425 c
->d_result
= d_result
;
429 Command
* CheckSatCommand::clone() const
431 CheckSatCommand
* c
= new CheckSatCommand(d_expr
);
432 c
->d_result
= d_result
;
436 std::string
CheckSatCommand::getCommandName() const { return "check-sat"; }
438 /* -------------------------------------------------------------------------- */
439 /* class CheckSatAssumingCommand */
440 /* -------------------------------------------------------------------------- */
442 CheckSatAssumingCommand::CheckSatAssumingCommand(Expr term
) : d_terms({term
}) {}
444 CheckSatAssumingCommand::CheckSatAssumingCommand(const std::vector
<Expr
>& terms
)
449 const std::vector
<Expr
>& CheckSatAssumingCommand::getTerms() const
454 void CheckSatAssumingCommand::invoke(SmtEngine
* smtEngine
)
458 d_result
= smtEngine
->checkSat(d_terms
);
459 d_commandStatus
= CommandSuccess::instance();
463 d_commandStatus
= new CommandFailure(e
.what());
467 Result
CheckSatAssumingCommand::getResult() const
472 void CheckSatAssumingCommand::printResult(std::ostream
& out
,
473 uint32_t verbosity
) const
477 this->Command::printResult(out
, verbosity
);
481 out
<< d_result
<< endl
;
485 Command
* CheckSatAssumingCommand::exportTo(
486 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
488 vector
<Expr
> exportedTerms
;
489 for (const Expr
& e
: d_terms
)
491 exportedTerms
.push_back(e
.exportTo(exprManager
, variableMap
));
493 CheckSatAssumingCommand
* c
= new CheckSatAssumingCommand(exportedTerms
);
494 c
->d_result
= d_result
;
498 Command
* CheckSatAssumingCommand::clone() const
500 CheckSatAssumingCommand
* c
= new CheckSatAssumingCommand(d_terms
);
501 c
->d_result
= d_result
;
505 std::string
CheckSatAssumingCommand::getCommandName() const
507 return "check-sat-assuming";
510 /* -------------------------------------------------------------------------- */
511 /* class QueryCommand */
512 /* -------------------------------------------------------------------------- */
514 QueryCommand::QueryCommand(const Expr
& e
, bool inUnsatCore
)
515 : d_expr(e
), d_inUnsatCore(inUnsatCore
)
519 Expr
QueryCommand::getExpr() const { return d_expr
; }
520 void QueryCommand::invoke(SmtEngine
* smtEngine
)
524 d_result
= smtEngine
->query(d_expr
);
525 d_commandStatus
= CommandSuccess::instance();
529 d_commandStatus
= new CommandFailure(e
.what());
533 Result
QueryCommand::getResult() const { return d_result
; }
534 void QueryCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
538 this->Command::printResult(out
, verbosity
);
542 out
<< d_result
<< endl
;
546 Command
* QueryCommand::exportTo(ExprManager
* exprManager
,
547 ExprManagerMapCollection
& variableMap
)
549 QueryCommand
* c
= new QueryCommand(d_expr
.exportTo(exprManager
, variableMap
),
551 c
->d_result
= d_result
;
555 Command
* QueryCommand::clone() const
557 QueryCommand
* c
= new QueryCommand(d_expr
, d_inUnsatCore
);
558 c
->d_result
= d_result
;
562 std::string
QueryCommand::getCommandName() const { return "query"; }
564 /* -------------------------------------------------------------------------- */
565 /* class CheckSynthCommand */
566 /* -------------------------------------------------------------------------- */
568 CheckSynthCommand::CheckSynthCommand() : d_expr() {}
569 CheckSynthCommand::CheckSynthCommand(const Expr
& expr
) : d_expr(expr
) {}
570 Expr
CheckSynthCommand::getExpr() const { return d_expr
; }
571 void CheckSynthCommand::invoke(SmtEngine
* smtEngine
)
575 d_result
= smtEngine
->checkSynth(d_expr
);
576 d_commandStatus
= CommandSuccess::instance();
577 smt::SmtScope
scope(smtEngine
);
579 // check whether we should print the status
580 if (d_result
.asSatisfiabilityResult() != Result::UNSAT
581 || options::sygusOut() == SYGUS_SOL_OUT_STATUS_AND_DEF
582 || options::sygusOut() == SYGUS_SOL_OUT_STATUS
)
584 if (options::sygusOut() == SYGUS_SOL_OUT_STANDARD
)
586 d_solution
<< "(fail)" << endl
;
590 d_solution
<< d_result
<< endl
;
593 // check whether we should print the solution
594 if (d_result
.asSatisfiabilityResult() == Result::UNSAT
595 && options::sygusOut() != SYGUS_SOL_OUT_STATUS
)
597 // printing a synthesis solution is a non-constant
598 // method, since it invokes a sophisticated algorithm
599 // (Figure 5 of Reynolds et al. CAV 2015).
600 // Hence, we must call here print solution here,
601 // instead of during printResult.
602 smtEngine
->printSynthSolution(d_solution
);
607 d_commandStatus
= new CommandFailure(e
.what());
611 Result
CheckSynthCommand::getResult() const { return d_result
; }
612 void CheckSynthCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
616 this->Command::printResult(out
, verbosity
);
620 out
<< d_solution
.str();
624 Command
* CheckSynthCommand::exportTo(ExprManager
* exprManager
,
625 ExprManagerMapCollection
& variableMap
)
627 CheckSynthCommand
* c
=
628 new CheckSynthCommand(d_expr
.exportTo(exprManager
, variableMap
));
629 c
->d_result
= d_result
;
633 Command
* CheckSynthCommand::clone() const
635 CheckSynthCommand
* c
= new CheckSynthCommand(d_expr
);
636 c
->d_result
= d_result
;
640 std::string
CheckSynthCommand::getCommandName() const { return "check-synth"; }
642 /* -------------------------------------------------------------------------- */
643 /* class ResetCommand */
644 /* -------------------------------------------------------------------------- */
646 void ResetCommand::invoke(SmtEngine
* smtEngine
)
651 d_commandStatus
= CommandSuccess::instance();
655 d_commandStatus
= new CommandFailure(e
.what());
659 Command
* ResetCommand::exportTo(ExprManager
* exprManager
,
660 ExprManagerMapCollection
& variableMap
)
662 return new ResetCommand();
665 Command
* ResetCommand::clone() const { return new ResetCommand(); }
666 std::string
ResetCommand::getCommandName() const { return "reset"; }
668 /* -------------------------------------------------------------------------- */
669 /* class ResetAssertionsCommand */
670 /* -------------------------------------------------------------------------- */
672 void ResetAssertionsCommand::invoke(SmtEngine
* smtEngine
)
676 smtEngine
->resetAssertions();
677 d_commandStatus
= CommandSuccess::instance();
681 d_commandStatus
= new CommandFailure(e
.what());
685 Command
* ResetAssertionsCommand::exportTo(ExprManager
* exprManager
,
686 ExprManagerMapCollection
& variableMap
)
688 return new ResetAssertionsCommand();
691 Command
* ResetAssertionsCommand::clone() const
693 return new ResetAssertionsCommand();
696 std::string
ResetAssertionsCommand::getCommandName() const
698 return "reset-assertions";
701 /* -------------------------------------------------------------------------- */
702 /* class QuitCommand */
703 /* -------------------------------------------------------------------------- */
705 void QuitCommand::invoke(SmtEngine
* smtEngine
)
707 Dump("benchmark") << *this;
708 d_commandStatus
= CommandSuccess::instance();
711 Command
* QuitCommand::exportTo(ExprManager
* exprManager
,
712 ExprManagerMapCollection
& variableMap
)
714 return new QuitCommand();
717 Command
* QuitCommand::clone() const { return new QuitCommand(); }
718 std::string
QuitCommand::getCommandName() const { return "exit"; }
720 /* -------------------------------------------------------------------------- */
721 /* class CommentCommand */
722 /* -------------------------------------------------------------------------- */
724 CommentCommand::CommentCommand(std::string comment
) : d_comment(comment
) {}
725 std::string
CommentCommand::getComment() const { return d_comment
; }
726 void CommentCommand::invoke(SmtEngine
* smtEngine
)
728 Dump("benchmark") << *this;
729 d_commandStatus
= CommandSuccess::instance();
732 Command
* CommentCommand::exportTo(ExprManager
* exprManager
,
733 ExprManagerMapCollection
& variableMap
)
735 return new CommentCommand(d_comment
);
738 Command
* CommentCommand::clone() const { return new CommentCommand(d_comment
); }
739 std::string
CommentCommand::getCommandName() const { return "comment"; }
741 /* -------------------------------------------------------------------------- */
742 /* class CommandSequence */
743 /* -------------------------------------------------------------------------- */
745 CommandSequence::CommandSequence() : d_index(0) {}
746 CommandSequence::~CommandSequence()
748 for (unsigned i
= d_index
; i
< d_commandSequence
.size(); ++i
)
750 delete d_commandSequence
[i
];
754 void CommandSequence::addCommand(Command
* cmd
)
756 d_commandSequence
.push_back(cmd
);
759 void CommandSequence::clear() { d_commandSequence
.clear(); }
760 void CommandSequence::invoke(SmtEngine
* smtEngine
)
762 for (; d_index
< d_commandSequence
.size(); ++d_index
)
764 d_commandSequence
[d_index
]->invoke(smtEngine
);
765 if (!d_commandSequence
[d_index
]->ok())
768 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
771 delete d_commandSequence
[d_index
];
774 AlwaysAssert(d_commandStatus
== NULL
);
775 d_commandStatus
= CommandSuccess::instance();
778 void CommandSequence::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
780 for (; d_index
< d_commandSequence
.size(); ++d_index
)
782 d_commandSequence
[d_index
]->invoke(smtEngine
, out
);
783 if (!d_commandSequence
[d_index
]->ok())
786 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
789 delete d_commandSequence
[d_index
];
792 AlwaysAssert(d_commandStatus
== NULL
);
793 d_commandStatus
= CommandSuccess::instance();
796 Command
* CommandSequence::exportTo(ExprManager
* exprManager
,
797 ExprManagerMapCollection
& variableMap
)
799 CommandSequence
* seq
= new CommandSequence();
800 for (iterator i
= begin(); i
!= end(); ++i
)
802 Command
* cmd_to_export
= *i
;
803 Command
* cmd
= cmd_to_export
->exportTo(exprManager
, variableMap
);
804 seq
->addCommand(cmd
);
805 Debug("export") << "[export] so far converted: " << seq
<< endl
;
807 seq
->d_index
= d_index
;
811 Command
* CommandSequence::clone() const
813 CommandSequence
* seq
= new CommandSequence();
814 for (const_iterator i
= begin(); i
!= end(); ++i
)
816 seq
->addCommand((*i
)->clone());
818 seq
->d_index
= d_index
;
822 CommandSequence::const_iterator
CommandSequence::begin() const
824 return d_commandSequence
.begin();
827 CommandSequence::const_iterator
CommandSequence::end() const
829 return d_commandSequence
.end();
832 CommandSequence::iterator
CommandSequence::begin()
834 return d_commandSequence
.begin();
837 CommandSequence::iterator
CommandSequence::end()
839 return d_commandSequence
.end();
842 std::string
CommandSequence::getCommandName() const { return "sequence"; }
844 /* -------------------------------------------------------------------------- */
845 /* class DeclarationDefinitionCommand */
846 /* -------------------------------------------------------------------------- */
848 DeclarationDefinitionCommand::DeclarationDefinitionCommand(
849 const std::string
& id
)
854 std::string
DeclarationDefinitionCommand::getSymbol() const { return d_symbol
; }
856 /* -------------------------------------------------------------------------- */
857 /* class DeclareFunctionCommand */
858 /* -------------------------------------------------------------------------- */
860 DeclareFunctionCommand::DeclareFunctionCommand(const std::string
& id
,
863 : DeclarationDefinitionCommand(id
),
866 d_printInModel(true),
867 d_printInModelSetByUser(false)
871 Expr
DeclareFunctionCommand::getFunction() const { return d_func
; }
872 Type
DeclareFunctionCommand::getType() const { return d_type
; }
873 bool DeclareFunctionCommand::getPrintInModel() const { return d_printInModel
; }
874 bool DeclareFunctionCommand::getPrintInModelSetByUser() const
876 return d_printInModelSetByUser
;
879 void DeclareFunctionCommand::setPrintInModel(bool p
)
882 d_printInModelSetByUser
= true;
885 void DeclareFunctionCommand::invoke(SmtEngine
* smtEngine
)
887 d_commandStatus
= CommandSuccess::instance();
890 Command
* DeclareFunctionCommand::exportTo(ExprManager
* exprManager
,
891 ExprManagerMapCollection
& variableMap
)
893 DeclareFunctionCommand
* dfc
=
894 new DeclareFunctionCommand(d_symbol
,
895 d_func
.exportTo(exprManager
, variableMap
),
896 d_type
.exportTo(exprManager
, variableMap
));
897 dfc
->d_printInModel
= d_printInModel
;
898 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
902 Command
* DeclareFunctionCommand::clone() const
904 DeclareFunctionCommand
* dfc
=
905 new DeclareFunctionCommand(d_symbol
, d_func
, d_type
);
906 dfc
->d_printInModel
= d_printInModel
;
907 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
911 std::string
DeclareFunctionCommand::getCommandName() const
913 return "declare-fun";
916 /* -------------------------------------------------------------------------- */
917 /* class DeclareTypeCommand */
918 /* -------------------------------------------------------------------------- */
920 DeclareTypeCommand::DeclareTypeCommand(const std::string
& id
,
923 : DeclarationDefinitionCommand(id
), d_arity(arity
), d_type(t
)
927 size_t DeclareTypeCommand::getArity() const { return d_arity
; }
928 Type
DeclareTypeCommand::getType() const { return d_type
; }
929 void DeclareTypeCommand::invoke(SmtEngine
* smtEngine
)
931 d_commandStatus
= CommandSuccess::instance();
934 Command
* DeclareTypeCommand::exportTo(ExprManager
* exprManager
,
935 ExprManagerMapCollection
& variableMap
)
937 return new DeclareTypeCommand(
938 d_symbol
, d_arity
, d_type
.exportTo(exprManager
, variableMap
));
941 Command
* DeclareTypeCommand::clone() const
943 return new DeclareTypeCommand(d_symbol
, d_arity
, d_type
);
946 std::string
DeclareTypeCommand::getCommandName() const
948 return "declare-sort";
951 /* -------------------------------------------------------------------------- */
952 /* class DefineTypeCommand */
953 /* -------------------------------------------------------------------------- */
955 DefineTypeCommand::DefineTypeCommand(const std::string
& id
, Type t
)
956 : DeclarationDefinitionCommand(id
), d_params(), d_type(t
)
960 DefineTypeCommand::DefineTypeCommand(const std::string
& id
,
961 const std::vector
<Type
>& params
,
963 : DeclarationDefinitionCommand(id
), d_params(params
), d_type(t
)
967 const std::vector
<Type
>& DefineTypeCommand::getParameters() const
972 Type
DefineTypeCommand::getType() const { return d_type
; }
973 void DefineTypeCommand::invoke(SmtEngine
* smtEngine
)
975 d_commandStatus
= CommandSuccess::instance();
978 Command
* DefineTypeCommand::exportTo(ExprManager
* exprManager
,
979 ExprManagerMapCollection
& variableMap
)
982 transform(d_params
.begin(),
984 back_inserter(params
),
985 ExportTransformer(exprManager
, variableMap
));
986 Type type
= d_type
.exportTo(exprManager
, variableMap
);
987 return new DefineTypeCommand(d_symbol
, params
, type
);
990 Command
* DefineTypeCommand::clone() const
992 return new DefineTypeCommand(d_symbol
, d_params
, d_type
);
995 std::string
DefineTypeCommand::getCommandName() const { return "define-sort"; }
997 /* -------------------------------------------------------------------------- */
998 /* class DefineFunctionCommand */
999 /* -------------------------------------------------------------------------- */
1001 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1004 : DeclarationDefinitionCommand(id
),
1011 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1013 const std::vector
<Expr
>& formals
,
1015 : DeclarationDefinitionCommand(id
),
1022 Expr
DefineFunctionCommand::getFunction() const { return d_func
; }
1023 const std::vector
<Expr
>& DefineFunctionCommand::getFormals() const
1028 Expr
DefineFunctionCommand::getFormula() const { return d_formula
; }
1029 void DefineFunctionCommand::invoke(SmtEngine
* smtEngine
)
1033 if (!d_func
.isNull())
1035 smtEngine
->defineFunction(d_func
, d_formals
, d_formula
);
1037 d_commandStatus
= CommandSuccess::instance();
1039 catch (exception
& e
)
1041 d_commandStatus
= new CommandFailure(e
.what());
1045 Command
* DefineFunctionCommand::exportTo(ExprManager
* exprManager
,
1046 ExprManagerMapCollection
& variableMap
)
1048 Expr func
= d_func
.exportTo(
1049 exprManager
, variableMap
, /* flags = */ ExprManager::VAR_FLAG_DEFINED
);
1050 vector
<Expr
> formals
;
1051 transform(d_formals
.begin(),
1053 back_inserter(formals
),
1054 ExportTransformer(exprManager
, variableMap
));
1055 Expr formula
= d_formula
.exportTo(exprManager
, variableMap
);
1056 return new DefineFunctionCommand(d_symbol
, func
, formals
, formula
);
1059 Command
* DefineFunctionCommand::clone() const
1061 return new DefineFunctionCommand(d_symbol
, d_func
, d_formals
, d_formula
);
1064 std::string
DefineFunctionCommand::getCommandName() const
1066 return "define-fun";
1069 /* -------------------------------------------------------------------------- */
1070 /* class DefineNamedFunctionCommand */
1071 /* -------------------------------------------------------------------------- */
1073 DefineNamedFunctionCommand::DefineNamedFunctionCommand(
1074 const std::string
& id
,
1076 const std::vector
<Expr
>& formals
,
1078 : DefineFunctionCommand(id
, func
, formals
, formula
)
1082 void DefineNamedFunctionCommand::invoke(SmtEngine
* smtEngine
)
1084 this->DefineFunctionCommand::invoke(smtEngine
);
1085 if (!d_func
.isNull() && d_func
.getType().isBoolean())
1087 smtEngine
->addToAssignment(
1088 d_func
.getExprManager()->mkExpr(kind::APPLY
, d_func
));
1090 d_commandStatus
= CommandSuccess::instance();
1093 Command
* DefineNamedFunctionCommand::exportTo(
1094 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1096 Expr func
= d_func
.exportTo(exprManager
, variableMap
);
1097 vector
<Expr
> formals
;
1098 transform(d_formals
.begin(),
1100 back_inserter(formals
),
1101 ExportTransformer(exprManager
, variableMap
));
1102 Expr formula
= d_formula
.exportTo(exprManager
, variableMap
);
1103 return new DefineNamedFunctionCommand(d_symbol
, func
, formals
, formula
);
1106 Command
* DefineNamedFunctionCommand::clone() const
1108 return new DefineNamedFunctionCommand(d_symbol
, d_func
, d_formals
, d_formula
);
1111 /* -------------------------------------------------------------------------- */
1112 /* class DefineFunctionRecCommand */
1113 /* -------------------------------------------------------------------------- */
1115 DefineFunctionRecCommand::DefineFunctionRecCommand(
1116 Expr func
, const std::vector
<Expr
>& formals
, Expr formula
)
1118 d_funcs
.push_back(func
);
1119 d_formals
.push_back(formals
);
1120 d_formulas
.push_back(formula
);
1123 DefineFunctionRecCommand::DefineFunctionRecCommand(
1124 const std::vector
<Expr
>& funcs
,
1125 const std::vector
<std::vector
<Expr
>>& formals
,
1126 const std::vector
<Expr
>& formulas
)
1128 d_funcs
.insert(d_funcs
.end(), funcs
.begin(), funcs
.end());
1129 d_formals
.insert(d_formals
.end(), formals
.begin(), formals
.end());
1130 d_formulas
.insert(d_formulas
.end(), formulas
.begin(), formulas
.end());
1133 const std::vector
<Expr
>& DefineFunctionRecCommand::getFunctions() const
1138 const std::vector
<std::vector
<Expr
>>& DefineFunctionRecCommand::getFormals()
1144 const std::vector
<Expr
>& DefineFunctionRecCommand::getFormulas() const
1149 void DefineFunctionRecCommand::invoke(SmtEngine
* smtEngine
)
1153 smtEngine
->defineFunctionsRec(d_funcs
, d_formals
, d_formulas
);
1154 d_commandStatus
= CommandSuccess::instance();
1156 catch (exception
& e
)
1158 d_commandStatus
= new CommandFailure(e
.what());
1162 Command
* DefineFunctionRecCommand::exportTo(
1163 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1165 std::vector
<Expr
> funcs
;
1166 for (unsigned i
= 0, size
= d_funcs
.size(); i
< size
; i
++)
1168 Expr func
= d_funcs
[i
].exportTo(
1169 exprManager
, variableMap
, /* flags = */ ExprManager::VAR_FLAG_DEFINED
);
1170 funcs
.push_back(func
);
1172 std::vector
<std::vector
<Expr
>> formals
;
1173 for (unsigned i
= 0, size
= d_formals
.size(); i
< size
; i
++)
1175 std::vector
<Expr
> formals_c
;
1176 transform(d_formals
[i
].begin(),
1178 back_inserter(formals_c
),
1179 ExportTransformer(exprManager
, variableMap
));
1180 formals
.push_back(formals_c
);
1182 std::vector
<Expr
> formulas
;
1183 for (unsigned i
= 0, size
= d_formulas
.size(); i
< size
; i
++)
1185 Expr formula
= d_formulas
[i
].exportTo(exprManager
, variableMap
);
1186 formulas
.push_back(formula
);
1188 return new DefineFunctionRecCommand(funcs
, formals
, formulas
);
1191 Command
* DefineFunctionRecCommand::clone() const
1193 return new DefineFunctionRecCommand(d_funcs
, d_formals
, d_formulas
);
1196 std::string
DefineFunctionRecCommand::getCommandName() const
1198 return "define-fun-rec";
1201 /* -------------------------------------------------------------------------- */
1202 /* class SetUserAttribute */
1203 /* -------------------------------------------------------------------------- */
1205 SetUserAttributeCommand::SetUserAttributeCommand(
1206 const std::string
& attr
,
1208 const std::vector
<Expr
>& expr_values
,
1209 const std::string
& str_value
)
1212 d_expr_values(expr_values
),
1213 d_str_value(str_value
)
1217 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1219 : SetUserAttributeCommand(attr
, expr
, {}, "")
1223 SetUserAttributeCommand::SetUserAttributeCommand(
1224 const std::string
& attr
, Expr expr
, const std::vector
<Expr
>& values
)
1225 : SetUserAttributeCommand(attr
, expr
, values
, "")
1229 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1231 const std::string
& value
)
1232 : SetUserAttributeCommand(attr
, expr
, {}, value
)
1236 void SetUserAttributeCommand::invoke(SmtEngine
* smtEngine
)
1240 if (!d_expr
.isNull())
1242 smtEngine
->setUserAttribute(d_attr
, d_expr
, d_expr_values
, d_str_value
);
1244 d_commandStatus
= CommandSuccess::instance();
1246 catch (exception
& e
)
1248 d_commandStatus
= new CommandFailure(e
.what());
1252 Command
* SetUserAttributeCommand::exportTo(
1253 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1255 Expr expr
= d_expr
.exportTo(exprManager
, variableMap
);
1256 return new SetUserAttributeCommand(d_attr
, expr
, d_expr_values
, d_str_value
);
1259 Command
* SetUserAttributeCommand::clone() const
1261 return new SetUserAttributeCommand(
1262 d_attr
, d_expr
, d_expr_values
, d_str_value
);
1265 std::string
SetUserAttributeCommand::getCommandName() const
1267 return "set-user-attribute";
1270 /* -------------------------------------------------------------------------- */
1271 /* class SimplifyCommand */
1272 /* -------------------------------------------------------------------------- */
1274 SimplifyCommand::SimplifyCommand(Expr term
) : d_term(term
) {}
1275 Expr
SimplifyCommand::getTerm() const { return d_term
; }
1276 void SimplifyCommand::invoke(SmtEngine
* smtEngine
)
1280 d_result
= smtEngine
->simplify(d_term
);
1281 d_commandStatus
= CommandSuccess::instance();
1283 catch (UnsafeInterruptException
& e
)
1285 d_commandStatus
= new CommandInterrupted();
1287 catch (exception
& e
)
1289 d_commandStatus
= new CommandFailure(e
.what());
1293 Expr
SimplifyCommand::getResult() const { return d_result
; }
1294 void SimplifyCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1298 this->Command::printResult(out
, verbosity
);
1302 out
<< d_result
<< endl
;
1306 Command
* SimplifyCommand::exportTo(ExprManager
* exprManager
,
1307 ExprManagerMapCollection
& variableMap
)
1309 SimplifyCommand
* c
=
1310 new SimplifyCommand(d_term
.exportTo(exprManager
, variableMap
));
1311 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1315 Command
* SimplifyCommand::clone() const
1317 SimplifyCommand
* c
= new SimplifyCommand(d_term
);
1318 c
->d_result
= d_result
;
1322 std::string
SimplifyCommand::getCommandName() const { return "simplify"; }
1324 /* -------------------------------------------------------------------------- */
1325 /* class ExpandDefinitionsCommand */
1326 /* -------------------------------------------------------------------------- */
1328 ExpandDefinitionsCommand::ExpandDefinitionsCommand(Expr term
) : d_term(term
) {}
1329 Expr
ExpandDefinitionsCommand::getTerm() const { return d_term
; }
1330 void ExpandDefinitionsCommand::invoke(SmtEngine
* smtEngine
)
1332 d_result
= smtEngine
->expandDefinitions(d_term
);
1333 d_commandStatus
= CommandSuccess::instance();
1336 Expr
ExpandDefinitionsCommand::getResult() const { return d_result
; }
1337 void ExpandDefinitionsCommand::printResult(std::ostream
& out
,
1338 uint32_t verbosity
) const
1342 this->Command::printResult(out
, verbosity
);
1346 out
<< d_result
<< endl
;
1350 Command
* ExpandDefinitionsCommand::exportTo(
1351 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1353 ExpandDefinitionsCommand
* c
=
1354 new ExpandDefinitionsCommand(d_term
.exportTo(exprManager
, variableMap
));
1355 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1359 Command
* ExpandDefinitionsCommand::clone() const
1361 ExpandDefinitionsCommand
* c
= new ExpandDefinitionsCommand(d_term
);
1362 c
->d_result
= d_result
;
1366 std::string
ExpandDefinitionsCommand::getCommandName() const
1368 return "expand-definitions";
1371 /* -------------------------------------------------------------------------- */
1372 /* class GetValueCommand */
1373 /* -------------------------------------------------------------------------- */
1375 GetValueCommand::GetValueCommand(Expr term
) : d_terms()
1377 d_terms
.push_back(term
);
1380 GetValueCommand::GetValueCommand(const std::vector
<Expr
>& terms
)
1383 PrettyCheckArgument(
1384 terms
.size() >= 1, terms
, "cannot get-value of an empty set of terms");
1387 const std::vector
<Expr
>& GetValueCommand::getTerms() const { return d_terms
; }
1388 void GetValueCommand::invoke(SmtEngine
* smtEngine
)
1392 vector
<Expr
> result
;
1393 ExprManager
* em
= smtEngine
->getExprManager();
1394 NodeManager
* nm
= NodeManager::fromExprManager(em
);
1395 for (const Expr
& e
: d_terms
)
1397 Assert(nm
== NodeManager::fromExprManager(e
.getExprManager()));
1398 smt::SmtScope
scope(smtEngine
);
1399 Node request
= Node::fromExpr(
1400 options::expandDefinitions() ? smtEngine
->expandDefinitions(e
) : e
);
1401 Node value
= Node::fromExpr(smtEngine
->getValue(e
));
1402 if (value
.getType().isInteger() && request
.getType() == nm
->realType())
1404 // Need to wrap in division-by-one so that output printers know this
1405 // is an integer-looking constant that really should be output as
1406 // a rational. Necessary for SMT-LIB standards compliance.
1407 value
= nm
->mkNode(kind::DIVISION
, value
, nm
->mkConst(Rational(1)));
1409 result
.push_back(nm
->mkNode(kind::SEXPR
, request
, value
).toExpr());
1411 d_result
= em
->mkExpr(kind::SEXPR
, result
);
1412 d_commandStatus
= CommandSuccess::instance();
1414 catch (RecoverableModalException
& e
)
1416 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1418 catch (UnsafeInterruptException
& e
)
1420 d_commandStatus
= new CommandInterrupted();
1422 catch (exception
& e
)
1424 d_commandStatus
= new CommandFailure(e
.what());
1428 Expr
GetValueCommand::getResult() const { return d_result
; }
1429 void GetValueCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1433 this->Command::printResult(out
, verbosity
);
1437 expr::ExprDag::Scope
scope(out
, false);
1438 out
<< d_result
<< endl
;
1442 Command
* GetValueCommand::exportTo(ExprManager
* exprManager
,
1443 ExprManagerMapCollection
& variableMap
)
1445 vector
<Expr
> exportedTerms
;
1446 for (std::vector
<Expr
>::const_iterator i
= d_terms
.begin();
1450 exportedTerms
.push_back((*i
).exportTo(exprManager
, variableMap
));
1452 GetValueCommand
* c
= new GetValueCommand(exportedTerms
);
1453 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1457 Command
* GetValueCommand::clone() const
1459 GetValueCommand
* c
= new GetValueCommand(d_terms
);
1460 c
->d_result
= d_result
;
1464 std::string
GetValueCommand::getCommandName() const { return "get-value"; }
1466 /* -------------------------------------------------------------------------- */
1467 /* class GetAssignmentCommand */
1468 /* -------------------------------------------------------------------------- */
1470 GetAssignmentCommand::GetAssignmentCommand() {}
1471 void GetAssignmentCommand::invoke(SmtEngine
* smtEngine
)
1475 std::vector
<std::pair
<Expr
, Expr
>> assignments
= smtEngine
->getAssignment();
1476 vector
<SExpr
> sexprs
;
1477 for (const auto& p
: assignments
)
1480 if (p
.first
.getKind() == kind::APPLY
)
1482 v
.emplace_back(SExpr::Keyword(p
.first
.getOperator().toString()));
1486 v
.emplace_back(SExpr::Keyword(p
.first
.toString()));
1488 v
.emplace_back(SExpr::Keyword(p
.second
.toString()));
1489 sexprs
.emplace_back(v
);
1491 d_result
= SExpr(sexprs
);
1492 d_commandStatus
= CommandSuccess::instance();
1494 catch (RecoverableModalException
& e
)
1496 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1498 catch (UnsafeInterruptException
& e
)
1500 d_commandStatus
= new CommandInterrupted();
1502 catch (exception
& e
)
1504 d_commandStatus
= new CommandFailure(e
.what());
1508 SExpr
GetAssignmentCommand::getResult() const { return d_result
; }
1509 void GetAssignmentCommand::printResult(std::ostream
& out
,
1510 uint32_t verbosity
) const
1514 this->Command::printResult(out
, verbosity
);
1518 out
<< d_result
<< endl
;
1522 Command
* GetAssignmentCommand::exportTo(ExprManager
* exprManager
,
1523 ExprManagerMapCollection
& variableMap
)
1525 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1526 c
->d_result
= d_result
;
1530 Command
* GetAssignmentCommand::clone() const
1532 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1533 c
->d_result
= d_result
;
1537 std::string
GetAssignmentCommand::getCommandName() const
1539 return "get-assignment";
1542 /* -------------------------------------------------------------------------- */
1543 /* class GetModelCommand */
1544 /* -------------------------------------------------------------------------- */
1546 GetModelCommand::GetModelCommand() : d_result(nullptr), d_smtEngine(nullptr) {}
1547 void GetModelCommand::invoke(SmtEngine
* smtEngine
)
1551 d_result
= smtEngine
->getModel();
1552 d_smtEngine
= smtEngine
;
1553 d_commandStatus
= CommandSuccess::instance();
1555 catch (RecoverableModalException
& e
)
1557 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1559 catch (UnsafeInterruptException
& e
)
1561 d_commandStatus
= new CommandInterrupted();
1563 catch (exception
& e
)
1565 d_commandStatus
= new CommandFailure(e
.what());
1569 /* Model is private to the library -- for now
1570 Model* GetModelCommand::getResult() const {
1575 void GetModelCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1579 this->Command::printResult(out
, verbosity
);
1587 Command
* GetModelCommand::exportTo(ExprManager
* exprManager
,
1588 ExprManagerMapCollection
& variableMap
)
1590 GetModelCommand
* c
= new GetModelCommand();
1591 c
->d_result
= d_result
;
1592 c
->d_smtEngine
= d_smtEngine
;
1596 Command
* GetModelCommand::clone() const
1598 GetModelCommand
* c
= new GetModelCommand();
1599 c
->d_result
= d_result
;
1600 c
->d_smtEngine
= d_smtEngine
;
1604 std::string
GetModelCommand::getCommandName() const { return "get-model"; }
1606 /* -------------------------------------------------------------------------- */
1607 /* class GetProofCommand */
1608 /* -------------------------------------------------------------------------- */
1610 GetProofCommand::GetProofCommand() : d_smtEngine(nullptr), d_result(nullptr) {}
1611 void GetProofCommand::invoke(SmtEngine
* smtEngine
)
1615 d_smtEngine
= smtEngine
;
1616 d_result
= &smtEngine
->getProof();
1617 d_commandStatus
= CommandSuccess::instance();
1619 catch (RecoverableModalException
& e
)
1621 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1623 catch (UnsafeInterruptException
& e
)
1625 d_commandStatus
= new CommandInterrupted();
1627 catch (exception
& e
)
1629 d_commandStatus
= new CommandFailure(e
.what());
1633 const Proof
& GetProofCommand::getResult() const { return *d_result
; }
1634 void GetProofCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1638 this->Command::printResult(out
, verbosity
);
1642 smt::SmtScope
scope(d_smtEngine
);
1643 d_result
->toStream(out
);
1647 Command
* GetProofCommand::exportTo(ExprManager
* exprManager
,
1648 ExprManagerMapCollection
& variableMap
)
1650 GetProofCommand
* c
= new GetProofCommand();
1651 c
->d_result
= d_result
;
1652 c
->d_smtEngine
= d_smtEngine
;
1656 Command
* GetProofCommand::clone() const
1658 GetProofCommand
* c
= new GetProofCommand();
1659 c
->d_result
= d_result
;
1660 c
->d_smtEngine
= d_smtEngine
;
1664 std::string
GetProofCommand::getCommandName() const { return "get-proof"; }
1666 /* -------------------------------------------------------------------------- */
1667 /* class GetInstantiationsCommand */
1668 /* -------------------------------------------------------------------------- */
1670 GetInstantiationsCommand::GetInstantiationsCommand() : d_smtEngine(nullptr) {}
1671 void GetInstantiationsCommand::invoke(SmtEngine
* smtEngine
)
1675 d_smtEngine
= smtEngine
;
1676 d_commandStatus
= CommandSuccess::instance();
1678 catch (exception
& e
)
1680 d_commandStatus
= new CommandFailure(e
.what());
1684 void GetInstantiationsCommand::printResult(std::ostream
& out
,
1685 uint32_t verbosity
) const
1689 this->Command::printResult(out
, verbosity
);
1693 d_smtEngine
->printInstantiations(out
);
1697 Command
* GetInstantiationsCommand::exportTo(
1698 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1700 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
1701 // c->d_result = d_result;
1702 c
->d_smtEngine
= d_smtEngine
;
1706 Command
* GetInstantiationsCommand::clone() const
1708 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
1709 // c->d_result = d_result;
1710 c
->d_smtEngine
= d_smtEngine
;
1714 std::string
GetInstantiationsCommand::getCommandName() const
1716 return "get-instantiations";
1719 /* -------------------------------------------------------------------------- */
1720 /* class GetSynthSolutionCommand */
1721 /* -------------------------------------------------------------------------- */
1723 GetSynthSolutionCommand::GetSynthSolutionCommand() : d_smtEngine(nullptr) {}
1724 void GetSynthSolutionCommand::invoke(SmtEngine
* smtEngine
)
1728 d_smtEngine
= smtEngine
;
1729 d_commandStatus
= CommandSuccess::instance();
1731 catch (exception
& e
)
1733 d_commandStatus
= new CommandFailure(e
.what());
1737 void GetSynthSolutionCommand::printResult(std::ostream
& out
,
1738 uint32_t verbosity
) const
1742 this->Command::printResult(out
, verbosity
);
1746 d_smtEngine
->printSynthSolution(out
);
1750 Command
* GetSynthSolutionCommand::exportTo(
1751 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1753 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
1754 c
->d_smtEngine
= d_smtEngine
;
1758 Command
* GetSynthSolutionCommand::clone() const
1760 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
1761 c
->d_smtEngine
= d_smtEngine
;
1765 std::string
GetSynthSolutionCommand::getCommandName() const
1767 return "get-instantiations";
1770 /* -------------------------------------------------------------------------- */
1771 /* class GetQuantifierEliminationCommand */
1772 /* -------------------------------------------------------------------------- */
1774 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand()
1775 : d_expr(), d_doFull(true)
1778 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand(
1779 const Expr
& expr
, bool doFull
)
1780 : d_expr(expr
), d_doFull(doFull
)
1784 Expr
GetQuantifierEliminationCommand::getExpr() const { return d_expr
; }
1785 bool GetQuantifierEliminationCommand::getDoFull() const { return d_doFull
; }
1786 void GetQuantifierEliminationCommand::invoke(SmtEngine
* smtEngine
)
1790 d_result
= smtEngine
->doQuantifierElimination(d_expr
, d_doFull
);
1791 d_commandStatus
= CommandSuccess::instance();
1793 catch (exception
& e
)
1795 d_commandStatus
= new CommandFailure(e
.what());
1799 Expr
GetQuantifierEliminationCommand::getResult() const { return d_result
; }
1800 void GetQuantifierEliminationCommand::printResult(std::ostream
& out
,
1801 uint32_t verbosity
) const
1805 this->Command::printResult(out
, verbosity
);
1809 out
<< d_result
<< endl
;
1813 Command
* GetQuantifierEliminationCommand::exportTo(
1814 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1816 GetQuantifierEliminationCommand
* c
= new GetQuantifierEliminationCommand(
1817 d_expr
.exportTo(exprManager
, variableMap
), d_doFull
);
1818 c
->d_result
= d_result
;
1822 Command
* GetQuantifierEliminationCommand::clone() const
1824 GetQuantifierEliminationCommand
* c
=
1825 new GetQuantifierEliminationCommand(d_expr
, d_doFull
);
1826 c
->d_result
= d_result
;
1830 std::string
GetQuantifierEliminationCommand::getCommandName() const
1832 return d_doFull
? "get-qe" : "get-qe-disjunct";
1835 /* -------------------------------------------------------------------------- */
1836 /* class GetUnsatAssumptionsCommand */
1837 /* -------------------------------------------------------------------------- */
1839 GetUnsatAssumptionsCommand::GetUnsatAssumptionsCommand() {}
1841 void GetUnsatAssumptionsCommand::invoke(SmtEngine
* smtEngine
)
1845 d_result
= smtEngine
->getUnsatAssumptions();
1846 d_commandStatus
= CommandSuccess::instance();
1848 catch (RecoverableModalException
& e
)
1850 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1852 catch (exception
& e
)
1854 d_commandStatus
= new CommandFailure(e
.what());
1858 std::vector
<Expr
> GetUnsatAssumptionsCommand::getResult() const
1863 void GetUnsatAssumptionsCommand::printResult(std::ostream
& out
,
1864 uint32_t verbosity
) const
1868 this->Command::printResult(out
, verbosity
);
1872 container_to_stream(out
, d_result
, "(", ")\n", " ");
1876 Command
* GetUnsatAssumptionsCommand::exportTo(
1877 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1879 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
1880 c
->d_result
= d_result
;
1884 Command
* GetUnsatAssumptionsCommand::clone() const
1886 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
1887 c
->d_result
= d_result
;
1891 std::string
GetUnsatAssumptionsCommand::getCommandName() const
1893 return "get-unsat-assumptions";
1896 /* -------------------------------------------------------------------------- */
1897 /* class GetUnsatCoreCommand */
1898 /* -------------------------------------------------------------------------- */
1900 GetUnsatCoreCommand::GetUnsatCoreCommand() {}
1901 void GetUnsatCoreCommand::invoke(SmtEngine
* smtEngine
)
1905 d_result
= smtEngine
->getUnsatCore();
1906 d_commandStatus
= CommandSuccess::instance();
1908 catch (RecoverableModalException
& e
)
1910 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1912 catch (exception
& e
)
1914 d_commandStatus
= new CommandFailure(e
.what());
1918 void GetUnsatCoreCommand::printResult(std::ostream
& out
,
1919 uint32_t verbosity
) const
1923 this->Command::printResult(out
, verbosity
);
1927 d_result
.toStream(out
);
1931 const UnsatCore
& GetUnsatCoreCommand::getUnsatCore() const
1933 // of course, this will be empty if the command hasn't been invoked yet
1937 Command
* GetUnsatCoreCommand::exportTo(ExprManager
* exprManager
,
1938 ExprManagerMapCollection
& variableMap
)
1940 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
1941 c
->d_result
= d_result
;
1945 Command
* GetUnsatCoreCommand::clone() const
1947 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
1948 c
->d_result
= d_result
;
1952 std::string
GetUnsatCoreCommand::getCommandName() const
1954 return "get-unsat-core";
1957 /* -------------------------------------------------------------------------- */
1958 /* class GetAssertionsCommand */
1959 /* -------------------------------------------------------------------------- */
1961 GetAssertionsCommand::GetAssertionsCommand() {}
1962 void GetAssertionsCommand::invoke(SmtEngine
* smtEngine
)
1967 const vector
<Expr
> v
= smtEngine
->getAssertions();
1969 copy(v
.begin(), v
.end(), ostream_iterator
<Expr
>(ss
, "\n"));
1971 d_result
= ss
.str();
1972 d_commandStatus
= CommandSuccess::instance();
1974 catch (exception
& e
)
1976 d_commandStatus
= new CommandFailure(e
.what());
1980 std::string
GetAssertionsCommand::getResult() const { return d_result
; }
1981 void GetAssertionsCommand::printResult(std::ostream
& out
,
1982 uint32_t verbosity
) const
1986 this->Command::printResult(out
, verbosity
);
1994 Command
* GetAssertionsCommand::exportTo(ExprManager
* exprManager
,
1995 ExprManagerMapCollection
& variableMap
)
1997 GetAssertionsCommand
* c
= new GetAssertionsCommand();
1998 c
->d_result
= d_result
;
2002 Command
* GetAssertionsCommand::clone() const
2004 GetAssertionsCommand
* c
= new GetAssertionsCommand();
2005 c
->d_result
= d_result
;
2009 std::string
GetAssertionsCommand::getCommandName() const
2011 return "get-assertions";
2014 /* -------------------------------------------------------------------------- */
2015 /* class SetBenchmarkStatusCommand */
2016 /* -------------------------------------------------------------------------- */
2018 SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status
)
2023 BenchmarkStatus
SetBenchmarkStatusCommand::getStatus() const
2028 void SetBenchmarkStatusCommand::invoke(SmtEngine
* smtEngine
)
2034 SExpr status
= SExpr(ss
.str());
2035 smtEngine
->setInfo("status", status
);
2036 d_commandStatus
= CommandSuccess::instance();
2038 catch (exception
& e
)
2040 d_commandStatus
= new CommandFailure(e
.what());
2044 Command
* SetBenchmarkStatusCommand::exportTo(
2045 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2047 return new SetBenchmarkStatusCommand(d_status
);
2050 Command
* SetBenchmarkStatusCommand::clone() const
2052 return new SetBenchmarkStatusCommand(d_status
);
2055 std::string
SetBenchmarkStatusCommand::getCommandName() const
2060 /* -------------------------------------------------------------------------- */
2061 /* class SetBenchmarkLogicCommand */
2062 /* -------------------------------------------------------------------------- */
2064 SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic
)
2069 std::string
SetBenchmarkLogicCommand::getLogic() const { return d_logic
; }
2070 void SetBenchmarkLogicCommand::invoke(SmtEngine
* smtEngine
)
2074 smtEngine
->setLogic(d_logic
);
2075 d_commandStatus
= CommandSuccess::instance();
2077 catch (exception
& e
)
2079 d_commandStatus
= new CommandFailure(e
.what());
2083 Command
* SetBenchmarkLogicCommand::exportTo(
2084 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2086 return new SetBenchmarkLogicCommand(d_logic
);
2089 Command
* SetBenchmarkLogicCommand::clone() const
2091 return new SetBenchmarkLogicCommand(d_logic
);
2094 std::string
SetBenchmarkLogicCommand::getCommandName() const
2099 /* -------------------------------------------------------------------------- */
2100 /* class SetInfoCommand */
2101 /* -------------------------------------------------------------------------- */
2103 SetInfoCommand::SetInfoCommand(std::string flag
, const SExpr
& sexpr
)
2104 : d_flag(flag
), d_sexpr(sexpr
)
2108 std::string
SetInfoCommand::getFlag() const { return d_flag
; }
2109 SExpr
SetInfoCommand::getSExpr() const { return d_sexpr
; }
2110 void SetInfoCommand::invoke(SmtEngine
* smtEngine
)
2114 smtEngine
->setInfo(d_flag
, d_sexpr
);
2115 d_commandStatus
= CommandSuccess::instance();
2117 catch (UnrecognizedOptionException
&)
2119 // As per SMT-LIB spec, silently accept unknown set-info keys
2120 d_commandStatus
= CommandSuccess::instance();
2122 catch (exception
& e
)
2124 d_commandStatus
= new CommandFailure(e
.what());
2128 Command
* SetInfoCommand::exportTo(ExprManager
* exprManager
,
2129 ExprManagerMapCollection
& variableMap
)
2131 return new SetInfoCommand(d_flag
, d_sexpr
);
2134 Command
* SetInfoCommand::clone() const
2136 return new SetInfoCommand(d_flag
, d_sexpr
);
2139 std::string
SetInfoCommand::getCommandName() const { return "set-info"; }
2141 /* -------------------------------------------------------------------------- */
2142 /* class GetInfoCommand */
2143 /* -------------------------------------------------------------------------- */
2145 GetInfoCommand::GetInfoCommand(std::string flag
) : d_flag(flag
) {}
2146 std::string
GetInfoCommand::getFlag() const { return d_flag
; }
2147 void GetInfoCommand::invoke(SmtEngine
* smtEngine
)
2152 v
.push_back(SExpr(SExpr::Keyword(string(":") + d_flag
)));
2153 v
.push_back(smtEngine
->getInfo(d_flag
));
2155 if (d_flag
== "all-options" || d_flag
== "all-statistics")
2157 ss
<< PrettySExprs(true);
2160 d_result
= ss
.str();
2161 d_commandStatus
= CommandSuccess::instance();
2163 catch (UnrecognizedOptionException
&)
2165 d_commandStatus
= new CommandUnsupported();
2167 catch (exception
& e
)
2169 d_commandStatus
= new CommandFailure(e
.what());
2173 std::string
GetInfoCommand::getResult() const { return d_result
; }
2174 void GetInfoCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2178 this->Command::printResult(out
, verbosity
);
2180 else if (d_result
!= "")
2182 out
<< d_result
<< endl
;
2186 Command
* GetInfoCommand::exportTo(ExprManager
* exprManager
,
2187 ExprManagerMapCollection
& variableMap
)
2189 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2190 c
->d_result
= d_result
;
2194 Command
* GetInfoCommand::clone() const
2196 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2197 c
->d_result
= d_result
;
2201 std::string
GetInfoCommand::getCommandName() const { return "get-info"; }
2203 /* -------------------------------------------------------------------------- */
2204 /* class SetOptionCommand */
2205 /* -------------------------------------------------------------------------- */
2207 SetOptionCommand::SetOptionCommand(std::string flag
, const SExpr
& sexpr
)
2208 : d_flag(flag
), d_sexpr(sexpr
)
2212 std::string
SetOptionCommand::getFlag() const { return d_flag
; }
2213 SExpr
SetOptionCommand::getSExpr() const { return d_sexpr
; }
2214 void SetOptionCommand::invoke(SmtEngine
* smtEngine
)
2218 smtEngine
->setOption(d_flag
, d_sexpr
);
2219 d_commandStatus
= CommandSuccess::instance();
2221 catch (UnrecognizedOptionException
&)
2223 d_commandStatus
= new CommandUnsupported();
2225 catch (exception
& e
)
2227 d_commandStatus
= new CommandFailure(e
.what());
2231 Command
* SetOptionCommand::exportTo(ExprManager
* exprManager
,
2232 ExprManagerMapCollection
& variableMap
)
2234 return new SetOptionCommand(d_flag
, d_sexpr
);
2237 Command
* SetOptionCommand::clone() const
2239 return new SetOptionCommand(d_flag
, d_sexpr
);
2242 std::string
SetOptionCommand::getCommandName() const { return "set-option"; }
2244 /* -------------------------------------------------------------------------- */
2245 /* class GetOptionCommand */
2246 /* -------------------------------------------------------------------------- */
2248 GetOptionCommand::GetOptionCommand(std::string flag
) : d_flag(flag
) {}
2249 std::string
GetOptionCommand::getFlag() const { return d_flag
; }
2250 void GetOptionCommand::invoke(SmtEngine
* smtEngine
)
2254 SExpr res
= smtEngine
->getOption(d_flag
);
2255 d_result
= res
.toString();
2256 d_commandStatus
= CommandSuccess::instance();
2258 catch (UnrecognizedOptionException
&)
2260 d_commandStatus
= new CommandUnsupported();
2262 catch (exception
& e
)
2264 d_commandStatus
= new CommandFailure(e
.what());
2268 std::string
GetOptionCommand::getResult() const { return d_result
; }
2269 void GetOptionCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2273 this->Command::printResult(out
, verbosity
);
2275 else if (d_result
!= "")
2277 out
<< d_result
<< endl
;
2281 Command
* GetOptionCommand::exportTo(ExprManager
* exprManager
,
2282 ExprManagerMapCollection
& variableMap
)
2284 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2285 c
->d_result
= d_result
;
2289 Command
* GetOptionCommand::clone() const
2291 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2292 c
->d_result
= d_result
;
2296 std::string
GetOptionCommand::getCommandName() const { return "get-option"; }
2298 /* -------------------------------------------------------------------------- */
2299 /* class SetExpressionNameCommand */
2300 /* -------------------------------------------------------------------------- */
2302 SetExpressionNameCommand::SetExpressionNameCommand(Expr expr
, std::string name
)
2303 : d_expr(expr
), d_name(name
)
2307 void SetExpressionNameCommand::invoke(SmtEngine
* smtEngine
)
2309 smtEngine
->setExpressionName(d_expr
, d_name
);
2310 d_commandStatus
= CommandSuccess::instance();
2313 Command
* SetExpressionNameCommand::exportTo(
2314 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2316 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(
2317 d_expr
.exportTo(exprManager
, variableMap
), d_name
);
2321 Command
* SetExpressionNameCommand::clone() const
2323 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(d_expr
, d_name
);
2327 std::string
SetExpressionNameCommand::getCommandName() const
2329 return "set-expr-name";
2332 /* -------------------------------------------------------------------------- */
2333 /* class DatatypeDeclarationCommand */
2334 /* -------------------------------------------------------------------------- */
2336 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2337 const DatatypeType
& datatype
)
2340 d_datatypes
.push_back(datatype
);
2343 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2344 const std::vector
<DatatypeType
>& datatypes
)
2345 : d_datatypes(datatypes
)
2349 const std::vector
<DatatypeType
>& DatatypeDeclarationCommand::getDatatypes()
2355 void DatatypeDeclarationCommand::invoke(SmtEngine
* smtEngine
)
2357 d_commandStatus
= CommandSuccess::instance();
2360 Command
* DatatypeDeclarationCommand::exportTo(
2361 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2363 throw ExportUnsupportedException(
2364 "export of DatatypeDeclarationCommand unsupported");
2367 Command
* DatatypeDeclarationCommand::clone() const
2369 return new DatatypeDeclarationCommand(d_datatypes
);
2372 std::string
DatatypeDeclarationCommand::getCommandName() const
2374 return "declare-datatypes";
2377 /* -------------------------------------------------------------------------- */
2378 /* class RewriteRuleCommand */
2379 /* -------------------------------------------------------------------------- */
2381 RewriteRuleCommand::RewriteRuleCommand(const std::vector
<Expr
>& vars
,
2382 const std::vector
<Expr
>& guards
,
2385 const Triggers
& triggers
)
2390 d_triggers(triggers
)
2394 RewriteRuleCommand::RewriteRuleCommand(const std::vector
<Expr
>& vars
,
2397 : d_vars(vars
), d_head(head
), d_body(body
)
2401 const std::vector
<Expr
>& RewriteRuleCommand::getVars() const { return d_vars
; }
2402 const std::vector
<Expr
>& RewriteRuleCommand::getGuards() const
2407 Expr
RewriteRuleCommand::getHead() const { return d_head
; }
2408 Expr
RewriteRuleCommand::getBody() const { return d_body
; }
2409 const RewriteRuleCommand::Triggers
& RewriteRuleCommand::getTriggers() const
2414 void RewriteRuleCommand::invoke(SmtEngine
* smtEngine
)
2418 ExprManager
* em
= smtEngine
->getExprManager();
2419 /** build vars list */
2420 Expr vars
= em
->mkExpr(kind::BOUND_VAR_LIST
, d_vars
);
2421 /** build guards list */
2423 if (d_guards
.size() == 0)
2424 guards
= em
->mkConst
<bool>(true);
2425 else if (d_guards
.size() == 1)
2426 guards
= d_guards
[0];
2428 guards
= em
->mkExpr(kind::AND
, d_guards
);
2429 /** build expression */
2431 if (d_triggers
.empty())
2433 expr
= em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, d_head
, d_body
);
2437 /** build triggers list */
2438 std::vector
<Expr
> vtriggers
;
2439 vtriggers
.reserve(d_triggers
.size());
2440 for (Triggers::const_iterator i
= d_triggers
.begin(),
2441 end
= d_triggers
.end();
2445 vtriggers
.push_back(em
->mkExpr(kind::INST_PATTERN
, *i
));
2447 Expr triggers
= em
->mkExpr(kind::INST_PATTERN_LIST
, vtriggers
);
2449 em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, d_head
, d_body
, triggers
);
2451 smtEngine
->assertFormula(expr
);
2452 d_commandStatus
= CommandSuccess::instance();
2454 catch (exception
& e
)
2456 d_commandStatus
= new CommandFailure(e
.what());
2460 Command
* RewriteRuleCommand::exportTo(ExprManager
* exprManager
,
2461 ExprManagerMapCollection
& variableMap
)
2463 /** Convert variables */
2464 VExpr vars
= ExportTo(exprManager
, variableMap
, d_vars
);
2465 /** Convert guards */
2466 VExpr guards
= ExportTo(exprManager
, variableMap
, d_guards
);
2467 /** Convert triggers */
2469 triggers
.reserve(d_triggers
.size());
2470 for (const std::vector
<Expr
>& trigger_list
: d_triggers
)
2472 triggers
.push_back(ExportTo(exprManager
, variableMap
, trigger_list
));
2474 /** Convert head and body */
2475 Expr head
= d_head
.exportTo(exprManager
, variableMap
);
2476 Expr body
= d_body
.exportTo(exprManager
, variableMap
);
2477 /** Create the converted rules */
2478 return new RewriteRuleCommand(vars
, guards
, head
, body
, triggers
);
2481 Command
* RewriteRuleCommand::clone() const
2483 return new RewriteRuleCommand(d_vars
, d_guards
, d_head
, d_body
, d_triggers
);
2486 std::string
RewriteRuleCommand::getCommandName() const
2488 return "rewrite-rule";
2491 /* -------------------------------------------------------------------------- */
2492 /* class PropagateRuleCommand */
2493 /* -------------------------------------------------------------------------- */
2495 PropagateRuleCommand::PropagateRuleCommand(const std::vector
<Expr
>& vars
,
2496 const std::vector
<Expr
>& guards
,
2497 const std::vector
<Expr
>& heads
,
2499 const Triggers
& triggers
,
2505 d_triggers(triggers
),
2506 d_deduction(deduction
)
2510 PropagateRuleCommand::PropagateRuleCommand(const std::vector
<Expr
>& vars
,
2511 const std::vector
<Expr
>& heads
,
2514 : d_vars(vars
), d_heads(heads
), d_body(body
), d_deduction(deduction
)
2518 const std::vector
<Expr
>& PropagateRuleCommand::getVars() const
2523 const std::vector
<Expr
>& PropagateRuleCommand::getGuards() const
2528 const std::vector
<Expr
>& PropagateRuleCommand::getHeads() const
2533 Expr
PropagateRuleCommand::getBody() const { return d_body
; }
2534 const PropagateRuleCommand::Triggers
& PropagateRuleCommand::getTriggers() const
2539 bool PropagateRuleCommand::isDeduction() const { return d_deduction
; }
2540 void PropagateRuleCommand::invoke(SmtEngine
* smtEngine
)
2544 ExprManager
* em
= smtEngine
->getExprManager();
2545 /** build vars list */
2546 Expr vars
= em
->mkExpr(kind::BOUND_VAR_LIST
, d_vars
);
2547 /** build guards list */
2549 if (d_guards
.size() == 0)
2550 guards
= em
->mkConst
<bool>(true);
2551 else if (d_guards
.size() == 1)
2552 guards
= d_guards
[0];
2554 guards
= em
->mkExpr(kind::AND
, d_guards
);
2555 /** build heads list */
2557 if (d_heads
.size() == 1)
2560 heads
= em
->mkExpr(kind::AND
, d_heads
);
2561 /** build expression */
2563 if (d_triggers
.empty())
2565 expr
= em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, heads
, d_body
);
2569 /** build triggers list */
2570 std::vector
<Expr
> vtriggers
;
2571 vtriggers
.reserve(d_triggers
.size());
2572 for (Triggers::const_iterator i
= d_triggers
.begin(),
2573 end
= d_triggers
.end();
2577 vtriggers
.push_back(em
->mkExpr(kind::INST_PATTERN
, *i
));
2579 Expr triggers
= em
->mkExpr(kind::INST_PATTERN_LIST
, vtriggers
);
2581 em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, heads
, d_body
, triggers
);
2583 smtEngine
->assertFormula(expr
);
2584 d_commandStatus
= CommandSuccess::instance();
2586 catch (exception
& e
)
2588 d_commandStatus
= new CommandFailure(e
.what());
2592 Command
* PropagateRuleCommand::exportTo(ExprManager
* exprManager
,
2593 ExprManagerMapCollection
& variableMap
)
2595 /** Convert variables */
2596 VExpr vars
= ExportTo(exprManager
, variableMap
, d_vars
);
2597 /** Convert guards */
2598 VExpr guards
= ExportTo(exprManager
, variableMap
, d_guards
);
2599 /** Convert heads */
2600 VExpr heads
= ExportTo(exprManager
, variableMap
, d_heads
);
2601 /** Convert triggers */
2603 triggers
.reserve(d_triggers
.size());
2604 for (const std::vector
<Expr
>& trigger_list
: d_triggers
)
2606 triggers
.push_back(ExportTo(exprManager
, variableMap
, trigger_list
));
2608 /** Convert head and body */
2609 Expr body
= d_body
.exportTo(exprManager
, variableMap
);
2610 /** Create the converted rules */
2611 return new PropagateRuleCommand(vars
, guards
, heads
, body
, triggers
);
2614 Command
* PropagateRuleCommand::clone() const
2616 return new PropagateRuleCommand(
2617 d_vars
, d_guards
, d_heads
, d_body
, d_triggers
);
2620 std::string
PropagateRuleCommand::getCommandName() const
2622 return "propagate-rule";