1 /********************* */
4 ** Top contributors (to current version):
5 ** Tim King, Morgan Deters, Aina Niemetz
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"
45 std::vector
<Expr
> ExportTo(ExprManager
* exprManager
,
46 ExprManagerMapCollection
& variableMap
,
47 const std::vector
<Expr
>& exprs
)
49 std::vector
<Expr
> exported
;
50 exported
.reserve(exprs
.size());
51 for (const Expr
& expr
: exprs
)
53 exported
.push_back(expr
.exportTo(exprManager
, variableMap
));
60 const int CommandPrintSuccess::s_iosIndex
= std::ios_base::xalloc();
61 const CommandSuccess
* CommandSuccess::s_instance
= new CommandSuccess();
62 const CommandInterrupted
* CommandInterrupted::s_instance
=
63 new CommandInterrupted();
65 std::ostream
& operator<<(std::ostream
& out
, const Command
& c
)
68 Node::setdepth::getDepth(out
),
69 Node::printtypes::getPrintTypes(out
),
70 Node::dag::getDag(out
),
71 Node::setlanguage::getLanguage(out
));
75 ostream
& operator<<(ostream
& out
, const Command
* c
)
88 std::ostream
& operator<<(std::ostream
& out
, const CommandStatus
& s
)
90 s
.toStream(out
, Node::setlanguage::getLanguage(out
));
94 ostream
& operator<<(ostream
& out
, const CommandStatus
* s
)
108 /* output stream insertion operator for benchmark statuses */
109 std::ostream
& operator<<(std::ostream
& out
, BenchmarkStatus status
)
113 case SMT_SATISFIABLE
: return out
<< "sat";
115 case SMT_UNSATISFIABLE
: return out
<< "unsat";
117 case SMT_UNKNOWN
: return out
<< "unknown";
119 default: return out
<< "BenchmarkStatus::[UNKNOWNSTATUS!]";
123 /* -------------------------------------------------------------------------- */
124 /* class CommandPrintSuccess */
125 /* -------------------------------------------------------------------------- */
127 void CommandPrintSuccess::applyPrintSuccess(std::ostream
& out
)
129 out
.iword(s_iosIndex
) = d_printSuccess
;
132 bool CommandPrintSuccess::getPrintSuccess(std::ostream
& out
)
134 return out
.iword(s_iosIndex
);
137 void CommandPrintSuccess::setPrintSuccess(std::ostream
& out
, bool printSuccess
)
139 out
.iword(s_iosIndex
) = printSuccess
;
142 std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
)
144 cps
.applyPrintSuccess(out
);
148 /* -------------------------------------------------------------------------- */
150 /* -------------------------------------------------------------------------- */
152 Command::Command() : d_commandStatus(NULL
), d_muted(false) {}
153 Command::Command(const Command
& cmd
)
156 (cmd
.d_commandStatus
== NULL
) ? NULL
: &cmd
.d_commandStatus
->clone();
157 d_muted
= cmd
.d_muted
;
162 if (d_commandStatus
!= NULL
&& d_commandStatus
!= CommandSuccess::instance())
164 delete d_commandStatus
;
168 bool Command::ok() const
170 // either we haven't run the command yet, or it ran successfully
171 return d_commandStatus
== NULL
172 || dynamic_cast<const CommandSuccess
*>(d_commandStatus
) != NULL
;
175 bool Command::fail() const
177 return d_commandStatus
!= NULL
178 && dynamic_cast<const CommandFailure
*>(d_commandStatus
) != NULL
;
181 bool Command::interrupted() const
183 return d_commandStatus
!= NULL
184 && dynamic_cast<const CommandInterrupted
*>(d_commandStatus
) != NULL
;
187 void Command::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
190 if (!(isMuted() && ok()))
193 smtEngine
->getOption("command-verbosity:" + getCommandName())
199 std::string
Command::toString() const
201 std::stringstream ss
;
206 void Command::toStream(std::ostream
& out
,
210 OutputLanguage language
) const
212 Printer::getPrinter(language
)->toStream(out
, this, toDepth
, types
, dag
);
215 void CommandStatus::toStream(std::ostream
& out
, OutputLanguage language
) const
217 Printer::getPrinter(language
)->toStream(out
, this);
220 void Command::printResult(std::ostream
& out
, uint32_t verbosity
) const
222 if (d_commandStatus
!= NULL
)
224 if ((!ok() && verbosity
>= 1) || verbosity
>= 2)
226 out
<< *d_commandStatus
;
231 /* -------------------------------------------------------------------------- */
232 /* class EmptyCommand */
233 /* -------------------------------------------------------------------------- */
235 EmptyCommand::EmptyCommand(std::string name
) : d_name(name
) {}
236 std::string
EmptyCommand::getName() const { return d_name
; }
237 void EmptyCommand::invoke(SmtEngine
* smtEngine
)
239 /* empty commands have no implementation */
240 d_commandStatus
= CommandSuccess::instance();
243 Command
* EmptyCommand::exportTo(ExprManager
* exprManager
,
244 ExprManagerMapCollection
& variableMap
)
246 return new EmptyCommand(d_name
);
249 Command
* EmptyCommand::clone() const { return new EmptyCommand(d_name
); }
250 std::string
EmptyCommand::getCommandName() const { return "empty"; }
252 /* -------------------------------------------------------------------------- */
253 /* class EchoCommand */
254 /* -------------------------------------------------------------------------- */
256 EchoCommand::EchoCommand(std::string output
) : d_output(output
) {}
257 std::string
EchoCommand::getOutput() const { return d_output
; }
258 void EchoCommand::invoke(SmtEngine
* smtEngine
)
260 /* we don't have an output stream here, nothing to do */
261 d_commandStatus
= CommandSuccess::instance();
264 void EchoCommand::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
266 out
<< d_output
<< std::endl
;
267 d_commandStatus
= CommandSuccess::instance();
269 smtEngine
->getOption("command-verbosity:" + getCommandName())
274 Command
* EchoCommand::exportTo(ExprManager
* exprManager
,
275 ExprManagerMapCollection
& variableMap
)
277 return new EchoCommand(d_output
);
280 Command
* EchoCommand::clone() const { return new EchoCommand(d_output
); }
281 std::string
EchoCommand::getCommandName() const { return "echo"; }
283 /* -------------------------------------------------------------------------- */
284 /* class AssertCommand */
285 /* -------------------------------------------------------------------------- */
287 AssertCommand::AssertCommand(const Expr
& e
, bool inUnsatCore
)
288 : d_expr(e
), d_inUnsatCore(inUnsatCore
)
292 Expr
AssertCommand::getExpr() const { return d_expr
; }
293 void AssertCommand::invoke(SmtEngine
* smtEngine
)
297 smtEngine
->assertFormula(d_expr
, d_inUnsatCore
);
298 d_commandStatus
= CommandSuccess::instance();
300 catch (UnsafeInterruptException
& e
)
302 d_commandStatus
= new CommandInterrupted();
306 d_commandStatus
= new CommandFailure(e
.what());
310 Command
* AssertCommand::exportTo(ExprManager
* exprManager
,
311 ExprManagerMapCollection
& variableMap
)
313 return new AssertCommand(d_expr
.exportTo(exprManager
, variableMap
),
317 Command
* AssertCommand::clone() const
319 return new AssertCommand(d_expr
, d_inUnsatCore
);
322 std::string
AssertCommand::getCommandName() const { return "assert"; }
324 /* -------------------------------------------------------------------------- */
325 /* class PushCommand */
326 /* -------------------------------------------------------------------------- */
328 void PushCommand::invoke(SmtEngine
* smtEngine
)
333 d_commandStatus
= CommandSuccess::instance();
335 catch (UnsafeInterruptException
& e
)
337 d_commandStatus
= new CommandInterrupted();
341 d_commandStatus
= new CommandFailure(e
.what());
345 Command
* PushCommand::exportTo(ExprManager
* exprManager
,
346 ExprManagerMapCollection
& variableMap
)
348 return new PushCommand();
351 Command
* PushCommand::clone() const { return new PushCommand(); }
352 std::string
PushCommand::getCommandName() const { return "push"; }
354 /* -------------------------------------------------------------------------- */
355 /* class PopCommand */
356 /* -------------------------------------------------------------------------- */
358 void PopCommand::invoke(SmtEngine
* smtEngine
)
363 d_commandStatus
= CommandSuccess::instance();
365 catch (UnsafeInterruptException
& e
)
367 d_commandStatus
= new CommandInterrupted();
371 d_commandStatus
= new CommandFailure(e
.what());
375 Command
* PopCommand::exportTo(ExprManager
* exprManager
,
376 ExprManagerMapCollection
& variableMap
)
378 return new PopCommand();
381 Command
* PopCommand::clone() const { return new PopCommand(); }
382 std::string
PopCommand::getCommandName() const { return "pop"; }
384 /* -------------------------------------------------------------------------- */
385 /* class CheckSatCommand */
386 /* -------------------------------------------------------------------------- */
388 CheckSatCommand::CheckSatCommand() : d_expr() {}
389 CheckSatCommand::CheckSatCommand(const Expr
& expr
, bool inUnsatCore
)
390 : d_expr(expr
), d_inUnsatCore(inUnsatCore
)
394 Expr
CheckSatCommand::getExpr() const { return d_expr
; }
395 void CheckSatCommand::invoke(SmtEngine
* smtEngine
)
399 d_result
= smtEngine
->checkSat(d_expr
);
400 d_commandStatus
= CommandSuccess::instance();
404 d_commandStatus
= new CommandFailure(e
.what());
408 Result
CheckSatCommand::getResult() const { return d_result
; }
409 void CheckSatCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
413 this->Command::printResult(out
, verbosity
);
417 out
<< d_result
<< endl
;
421 Command
* CheckSatCommand::exportTo(ExprManager
* exprManager
,
422 ExprManagerMapCollection
& variableMap
)
424 CheckSatCommand
* c
= new CheckSatCommand(
425 d_expr
.exportTo(exprManager
, variableMap
), d_inUnsatCore
);
426 c
->d_result
= d_result
;
430 Command
* CheckSatCommand::clone() const
432 CheckSatCommand
* c
= new CheckSatCommand(d_expr
, d_inUnsatCore
);
433 c
->d_result
= d_result
;
437 std::string
CheckSatCommand::getCommandName() const { return "check-sat"; }
439 /* -------------------------------------------------------------------------- */
440 /* class CheckSatAssumingCommand */
441 /* -------------------------------------------------------------------------- */
443 CheckSatAssumingCommand::CheckSatAssumingCommand(Expr term
) : d_terms()
445 d_terms
.push_back(term
);
448 CheckSatAssumingCommand::CheckSatAssumingCommand(const std::vector
<Expr
>& terms
,
450 : d_terms(terms
), d_inUnsatCore(inUnsatCore
)
453 terms
.size() >= 1, terms
, "cannot get-value of an empty set of terms");
456 const std::vector
<Expr
>& CheckSatAssumingCommand::getTerms() const
461 void CheckSatAssumingCommand::invoke(SmtEngine
* smtEngine
)
465 d_result
= smtEngine
->checkSat(d_terms
);
466 d_commandStatus
= CommandSuccess::instance();
470 d_commandStatus
= new CommandFailure(e
.what());
474 Result
CheckSatAssumingCommand::getResult() const
479 void CheckSatAssumingCommand::printResult(std::ostream
& out
,
480 uint32_t verbosity
) const
484 this->Command::printResult(out
, verbosity
);
488 out
<< d_result
<< endl
;
492 Command
* CheckSatAssumingCommand::exportTo(
493 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
495 vector
<Expr
> exportedTerms
;
496 for (const Expr
& e
: d_terms
)
498 exportedTerms
.push_back(e
.exportTo(exprManager
, variableMap
));
500 CheckSatAssumingCommand
* c
=
501 new CheckSatAssumingCommand(exportedTerms
, d_inUnsatCore
);
502 c
->d_result
= d_result
;
506 Command
* CheckSatAssumingCommand::clone() const
508 CheckSatAssumingCommand
* c
=
509 new CheckSatAssumingCommand(d_terms
, d_inUnsatCore
);
510 c
->d_result
= d_result
;
514 std::string
CheckSatAssumingCommand::getCommandName() const
516 return "check-sat-assuming";
519 /* -------------------------------------------------------------------------- */
520 /* class QueryCommand */
521 /* -------------------------------------------------------------------------- */
523 QueryCommand::QueryCommand(const Expr
& e
, bool inUnsatCore
)
524 : d_expr(e
), d_inUnsatCore(inUnsatCore
)
528 Expr
QueryCommand::getExpr() const { return d_expr
; }
529 void QueryCommand::invoke(SmtEngine
* smtEngine
)
533 d_result
= smtEngine
->query(d_expr
);
534 d_commandStatus
= CommandSuccess::instance();
538 d_commandStatus
= new CommandFailure(e
.what());
542 Result
QueryCommand::getResult() const { return d_result
; }
543 void QueryCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
547 this->Command::printResult(out
, verbosity
);
551 out
<< d_result
<< endl
;
555 Command
* QueryCommand::exportTo(ExprManager
* exprManager
,
556 ExprManagerMapCollection
& variableMap
)
558 QueryCommand
* c
= new QueryCommand(d_expr
.exportTo(exprManager
, variableMap
),
560 c
->d_result
= d_result
;
564 Command
* QueryCommand::clone() const
566 QueryCommand
* c
= new QueryCommand(d_expr
, d_inUnsatCore
);
567 c
->d_result
= d_result
;
571 std::string
QueryCommand::getCommandName() const { return "query"; }
573 /* -------------------------------------------------------------------------- */
574 /* class CheckSynthCommand */
575 /* -------------------------------------------------------------------------- */
577 CheckSynthCommand::CheckSynthCommand() : d_expr() {}
578 CheckSynthCommand::CheckSynthCommand(const Expr
& expr
) : d_expr(expr
) {}
579 Expr
CheckSynthCommand::getExpr() const { return d_expr
; }
580 void CheckSynthCommand::invoke(SmtEngine
* smtEngine
)
584 d_result
= smtEngine
->checkSynth(d_expr
);
585 d_commandStatus
= CommandSuccess::instance();
586 smt::SmtScope
scope(smtEngine
);
588 // check whether we should print the status
589 if (d_result
.asSatisfiabilityResult() != Result::UNSAT
590 || options::sygusOut() == SYGUS_SOL_OUT_STATUS_AND_DEF
591 || options::sygusOut() == SYGUS_SOL_OUT_STATUS
)
593 if (options::sygusOut() == SYGUS_SOL_OUT_STANDARD
)
595 d_solution
<< "(fail)" << endl
;
599 d_solution
<< d_result
<< endl
;
602 // check whether we should print the solution
603 if (d_result
.asSatisfiabilityResult() == Result::UNSAT
604 && options::sygusOut() != SYGUS_SOL_OUT_STATUS
)
606 // printing a synthesis solution is a non-constant
607 // method, since it invokes a sophisticated algorithm
608 // (Figure 5 of Reynolds et al. CAV 2015).
609 // Hence, we must call here print solution here,
610 // instead of during printResult.
611 smtEngine
->printSynthSolution(d_solution
);
616 d_commandStatus
= new CommandFailure(e
.what());
620 Result
CheckSynthCommand::getResult() const { return d_result
; }
621 void CheckSynthCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
625 this->Command::printResult(out
, verbosity
);
629 out
<< d_solution
.str();
633 Command
* CheckSynthCommand::exportTo(ExprManager
* exprManager
,
634 ExprManagerMapCollection
& variableMap
)
636 CheckSynthCommand
* c
=
637 new CheckSynthCommand(d_expr
.exportTo(exprManager
, variableMap
));
638 c
->d_result
= d_result
;
642 Command
* CheckSynthCommand::clone() const
644 CheckSynthCommand
* c
= new CheckSynthCommand(d_expr
);
645 c
->d_result
= d_result
;
649 std::string
CheckSynthCommand::getCommandName() const { return "check-synth"; }
651 /* -------------------------------------------------------------------------- */
652 /* class ResetCommand */
653 /* -------------------------------------------------------------------------- */
655 void ResetCommand::invoke(SmtEngine
* smtEngine
)
660 d_commandStatus
= CommandSuccess::instance();
664 d_commandStatus
= new CommandFailure(e
.what());
668 Command
* ResetCommand::exportTo(ExprManager
* exprManager
,
669 ExprManagerMapCollection
& variableMap
)
671 return new ResetCommand();
674 Command
* ResetCommand::clone() const { return new ResetCommand(); }
675 std::string
ResetCommand::getCommandName() const { return "reset"; }
677 /* -------------------------------------------------------------------------- */
678 /* class ResetAssertionsCommand */
679 /* -------------------------------------------------------------------------- */
681 void ResetAssertionsCommand::invoke(SmtEngine
* smtEngine
)
685 smtEngine
->resetAssertions();
686 d_commandStatus
= CommandSuccess::instance();
690 d_commandStatus
= new CommandFailure(e
.what());
694 Command
* ResetAssertionsCommand::exportTo(ExprManager
* exprManager
,
695 ExprManagerMapCollection
& variableMap
)
697 return new ResetAssertionsCommand();
700 Command
* ResetAssertionsCommand::clone() const
702 return new ResetAssertionsCommand();
705 std::string
ResetAssertionsCommand::getCommandName() const
707 return "reset-assertions";
710 /* -------------------------------------------------------------------------- */
711 /* class QuitCommand */
712 /* -------------------------------------------------------------------------- */
714 void QuitCommand::invoke(SmtEngine
* smtEngine
)
716 Dump("benchmark") << *this;
717 d_commandStatus
= CommandSuccess::instance();
720 Command
* QuitCommand::exportTo(ExprManager
* exprManager
,
721 ExprManagerMapCollection
& variableMap
)
723 return new QuitCommand();
726 Command
* QuitCommand::clone() const { return new QuitCommand(); }
727 std::string
QuitCommand::getCommandName() const { return "exit"; }
729 /* -------------------------------------------------------------------------- */
730 /* class CommentCommand */
731 /* -------------------------------------------------------------------------- */
733 CommentCommand::CommentCommand(std::string comment
) : d_comment(comment
) {}
734 std::string
CommentCommand::getComment() const { return d_comment
; }
735 void CommentCommand::invoke(SmtEngine
* smtEngine
)
737 Dump("benchmark") << *this;
738 d_commandStatus
= CommandSuccess::instance();
741 Command
* CommentCommand::exportTo(ExprManager
* exprManager
,
742 ExprManagerMapCollection
& variableMap
)
744 return new CommentCommand(d_comment
);
747 Command
* CommentCommand::clone() const { return new CommentCommand(d_comment
); }
748 std::string
CommentCommand::getCommandName() const { return "comment"; }
750 /* -------------------------------------------------------------------------- */
751 /* class CommandSequence */
752 /* -------------------------------------------------------------------------- */
754 CommandSequence::CommandSequence() : d_index(0) {}
755 CommandSequence::~CommandSequence()
757 for (unsigned i
= d_index
; i
< d_commandSequence
.size(); ++i
)
759 delete d_commandSequence
[i
];
763 void CommandSequence::addCommand(Command
* cmd
)
765 d_commandSequence
.push_back(cmd
);
768 void CommandSequence::clear() { d_commandSequence
.clear(); }
769 void CommandSequence::invoke(SmtEngine
* smtEngine
)
771 for (; d_index
< d_commandSequence
.size(); ++d_index
)
773 d_commandSequence
[d_index
]->invoke(smtEngine
);
774 if (!d_commandSequence
[d_index
]->ok())
777 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
780 delete d_commandSequence
[d_index
];
783 AlwaysAssert(d_commandStatus
== NULL
);
784 d_commandStatus
= CommandSuccess::instance();
787 void CommandSequence::invoke(SmtEngine
* smtEngine
, std::ostream
& out
)
789 for (; d_index
< d_commandSequence
.size(); ++d_index
)
791 d_commandSequence
[d_index
]->invoke(smtEngine
, out
);
792 if (!d_commandSequence
[d_index
]->ok())
795 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
798 delete d_commandSequence
[d_index
];
801 AlwaysAssert(d_commandStatus
== NULL
);
802 d_commandStatus
= CommandSuccess::instance();
805 Command
* CommandSequence::exportTo(ExprManager
* exprManager
,
806 ExprManagerMapCollection
& variableMap
)
808 CommandSequence
* seq
= new CommandSequence();
809 for (iterator i
= begin(); i
!= end(); ++i
)
811 Command
* cmd_to_export
= *i
;
812 Command
* cmd
= cmd_to_export
->exportTo(exprManager
, variableMap
);
813 seq
->addCommand(cmd
);
814 Debug("export") << "[export] so far converted: " << seq
<< endl
;
816 seq
->d_index
= d_index
;
820 Command
* CommandSequence::clone() const
822 CommandSequence
* seq
= new CommandSequence();
823 for (const_iterator i
= begin(); i
!= end(); ++i
)
825 seq
->addCommand((*i
)->clone());
827 seq
->d_index
= d_index
;
831 CommandSequence::const_iterator
CommandSequence::begin() const
833 return d_commandSequence
.begin();
836 CommandSequence::const_iterator
CommandSequence::end() const
838 return d_commandSequence
.end();
841 CommandSequence::iterator
CommandSequence::begin()
843 return d_commandSequence
.begin();
846 CommandSequence::iterator
CommandSequence::end()
848 return d_commandSequence
.end();
851 std::string
CommandSequence::getCommandName() const { return "sequence"; }
853 /* -------------------------------------------------------------------------- */
854 /* class DeclarationDefinitionCommand */
855 /* -------------------------------------------------------------------------- */
857 DeclarationDefinitionCommand::DeclarationDefinitionCommand(
858 const std::string
& id
)
863 std::string
DeclarationDefinitionCommand::getSymbol() const { return d_symbol
; }
865 /* -------------------------------------------------------------------------- */
866 /* class DeclareFunctionCommand */
867 /* -------------------------------------------------------------------------- */
869 DeclareFunctionCommand::DeclareFunctionCommand(const std::string
& id
,
872 : DeclarationDefinitionCommand(id
),
875 d_printInModel(true),
876 d_printInModelSetByUser(false)
880 Expr
DeclareFunctionCommand::getFunction() const { return d_func
; }
881 Type
DeclareFunctionCommand::getType() const { return d_type
; }
882 bool DeclareFunctionCommand::getPrintInModel() const { return d_printInModel
; }
883 bool DeclareFunctionCommand::getPrintInModelSetByUser() const
885 return d_printInModelSetByUser
;
888 void DeclareFunctionCommand::setPrintInModel(bool p
)
891 d_printInModelSetByUser
= true;
894 void DeclareFunctionCommand::invoke(SmtEngine
* smtEngine
)
896 d_commandStatus
= CommandSuccess::instance();
899 Command
* DeclareFunctionCommand::exportTo(ExprManager
* exprManager
,
900 ExprManagerMapCollection
& variableMap
)
902 DeclareFunctionCommand
* dfc
=
903 new DeclareFunctionCommand(d_symbol
,
904 d_func
.exportTo(exprManager
, variableMap
),
905 d_type
.exportTo(exprManager
, variableMap
));
906 dfc
->d_printInModel
= d_printInModel
;
907 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
911 Command
* DeclareFunctionCommand::clone() const
913 DeclareFunctionCommand
* dfc
=
914 new DeclareFunctionCommand(d_symbol
, d_func
, d_type
);
915 dfc
->d_printInModel
= d_printInModel
;
916 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
920 std::string
DeclareFunctionCommand::getCommandName() const
922 return "declare-fun";
925 /* -------------------------------------------------------------------------- */
926 /* class DeclareTypeCommand */
927 /* -------------------------------------------------------------------------- */
929 DeclareTypeCommand::DeclareTypeCommand(const std::string
& id
,
932 : DeclarationDefinitionCommand(id
), d_arity(arity
), d_type(t
)
936 size_t DeclareTypeCommand::getArity() const { return d_arity
; }
937 Type
DeclareTypeCommand::getType() const { return d_type
; }
938 void DeclareTypeCommand::invoke(SmtEngine
* smtEngine
)
940 d_commandStatus
= CommandSuccess::instance();
943 Command
* DeclareTypeCommand::exportTo(ExprManager
* exprManager
,
944 ExprManagerMapCollection
& variableMap
)
946 return new DeclareTypeCommand(
947 d_symbol
, d_arity
, d_type
.exportTo(exprManager
, variableMap
));
950 Command
* DeclareTypeCommand::clone() const
952 return new DeclareTypeCommand(d_symbol
, d_arity
, d_type
);
955 std::string
DeclareTypeCommand::getCommandName() const
957 return "declare-sort";
960 /* -------------------------------------------------------------------------- */
961 /* class DefineTypeCommand */
962 /* -------------------------------------------------------------------------- */
964 DefineTypeCommand::DefineTypeCommand(const std::string
& id
, Type t
)
965 : DeclarationDefinitionCommand(id
), d_params(), d_type(t
)
969 DefineTypeCommand::DefineTypeCommand(const std::string
& id
,
970 const std::vector
<Type
>& params
,
972 : DeclarationDefinitionCommand(id
), d_params(params
), d_type(t
)
976 const std::vector
<Type
>& DefineTypeCommand::getParameters() const
981 Type
DefineTypeCommand::getType() const { return d_type
; }
982 void DefineTypeCommand::invoke(SmtEngine
* smtEngine
)
984 d_commandStatus
= CommandSuccess::instance();
987 Command
* DefineTypeCommand::exportTo(ExprManager
* exprManager
,
988 ExprManagerMapCollection
& variableMap
)
991 transform(d_params
.begin(),
993 back_inserter(params
),
994 ExportTransformer(exprManager
, variableMap
));
995 Type type
= d_type
.exportTo(exprManager
, variableMap
);
996 return new DefineTypeCommand(d_symbol
, params
, type
);
999 Command
* DefineTypeCommand::clone() const
1001 return new DefineTypeCommand(d_symbol
, d_params
, d_type
);
1004 std::string
DefineTypeCommand::getCommandName() const { return "define-sort"; }
1006 /* -------------------------------------------------------------------------- */
1007 /* class DefineFunctionCommand */
1008 /* -------------------------------------------------------------------------- */
1010 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1013 : DeclarationDefinitionCommand(id
),
1020 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1022 const std::vector
<Expr
>& formals
,
1024 : DeclarationDefinitionCommand(id
),
1031 Expr
DefineFunctionCommand::getFunction() const { return d_func
; }
1032 const std::vector
<Expr
>& DefineFunctionCommand::getFormals() const
1037 Expr
DefineFunctionCommand::getFormula() const { return d_formula
; }
1038 void DefineFunctionCommand::invoke(SmtEngine
* smtEngine
)
1042 if (!d_func
.isNull())
1044 smtEngine
->defineFunction(d_func
, d_formals
, d_formula
);
1046 d_commandStatus
= CommandSuccess::instance();
1048 catch (exception
& e
)
1050 d_commandStatus
= new CommandFailure(e
.what());
1054 Command
* DefineFunctionCommand::exportTo(ExprManager
* exprManager
,
1055 ExprManagerMapCollection
& variableMap
)
1057 Expr func
= d_func
.exportTo(
1058 exprManager
, variableMap
, /* flags = */ ExprManager::VAR_FLAG_DEFINED
);
1059 vector
<Expr
> formals
;
1060 transform(d_formals
.begin(),
1062 back_inserter(formals
),
1063 ExportTransformer(exprManager
, variableMap
));
1064 Expr formula
= d_formula
.exportTo(exprManager
, variableMap
);
1065 return new DefineFunctionCommand(d_symbol
, func
, formals
, formula
);
1068 Command
* DefineFunctionCommand::clone() const
1070 return new DefineFunctionCommand(d_symbol
, d_func
, d_formals
, d_formula
);
1073 std::string
DefineFunctionCommand::getCommandName() const
1075 return "define-fun";
1078 /* -------------------------------------------------------------------------- */
1079 /* class DefineNamedFunctionCommand */
1080 /* -------------------------------------------------------------------------- */
1082 DefineNamedFunctionCommand::DefineNamedFunctionCommand(
1083 const std::string
& id
,
1085 const std::vector
<Expr
>& formals
,
1087 : DefineFunctionCommand(id
, func
, formals
, formula
)
1091 void DefineNamedFunctionCommand::invoke(SmtEngine
* smtEngine
)
1093 this->DefineFunctionCommand::invoke(smtEngine
);
1094 if (!d_func
.isNull() && d_func
.getType().isBoolean())
1096 smtEngine
->addToAssignment(
1097 d_func
.getExprManager()->mkExpr(kind::APPLY
, d_func
));
1099 d_commandStatus
= CommandSuccess::instance();
1102 Command
* DefineNamedFunctionCommand::exportTo(
1103 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1105 Expr func
= d_func
.exportTo(exprManager
, variableMap
);
1106 vector
<Expr
> formals
;
1107 transform(d_formals
.begin(),
1109 back_inserter(formals
),
1110 ExportTransformer(exprManager
, variableMap
));
1111 Expr formula
= d_formula
.exportTo(exprManager
, variableMap
);
1112 return new DefineNamedFunctionCommand(d_symbol
, func
, formals
, formula
);
1115 Command
* DefineNamedFunctionCommand::clone() const
1117 return new DefineNamedFunctionCommand(d_symbol
, d_func
, d_formals
, d_formula
);
1120 /* -------------------------------------------------------------------------- */
1121 /* class DefineFunctionRecCommand */
1122 /* -------------------------------------------------------------------------- */
1124 DefineFunctionRecCommand::DefineFunctionRecCommand(
1125 Expr func
, const std::vector
<Expr
>& formals
, Expr formula
)
1127 d_funcs
.push_back(func
);
1128 d_formals
.push_back(formals
);
1129 d_formulas
.push_back(formula
);
1132 DefineFunctionRecCommand::DefineFunctionRecCommand(
1133 const std::vector
<Expr
>& funcs
,
1134 const std::vector
<std::vector
<Expr
>>& formals
,
1135 const std::vector
<Expr
>& formulas
)
1137 d_funcs
.insert(d_funcs
.end(), funcs
.begin(), funcs
.end());
1138 d_formals
.insert(d_formals
.end(), formals
.begin(), formals
.end());
1139 d_formulas
.insert(d_formulas
.end(), formulas
.begin(), formulas
.end());
1142 const std::vector
<Expr
>& DefineFunctionRecCommand::getFunctions() const
1147 const std::vector
<std::vector
<Expr
>>& DefineFunctionRecCommand::getFormals()
1153 const std::vector
<Expr
>& DefineFunctionRecCommand::getFormulas() const
1158 void DefineFunctionRecCommand::invoke(SmtEngine
* smtEngine
)
1162 smtEngine
->defineFunctionsRec(d_funcs
, d_formals
, d_formulas
);
1163 d_commandStatus
= CommandSuccess::instance();
1165 catch (exception
& e
)
1167 d_commandStatus
= new CommandFailure(e
.what());
1171 Command
* DefineFunctionRecCommand::exportTo(
1172 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1174 std::vector
<Expr
> funcs
;
1175 for (unsigned i
= 0, size
= d_funcs
.size(); i
< size
; i
++)
1177 Expr func
= d_funcs
[i
].exportTo(
1178 exprManager
, variableMap
, /* flags = */ ExprManager::VAR_FLAG_DEFINED
);
1179 funcs
.push_back(func
);
1181 std::vector
<std::vector
<Expr
>> formals
;
1182 for (unsigned i
= 0, size
= d_formals
.size(); i
< size
; i
++)
1184 std::vector
<Expr
> formals_c
;
1185 transform(d_formals
[i
].begin(),
1187 back_inserter(formals_c
),
1188 ExportTransformer(exprManager
, variableMap
));
1189 formals
.push_back(formals_c
);
1191 std::vector
<Expr
> formulas
;
1192 for (unsigned i
= 0, size
= d_formulas
.size(); i
< size
; i
++)
1194 Expr formula
= d_formulas
[i
].exportTo(exprManager
, variableMap
);
1195 formulas
.push_back(formula
);
1197 return new DefineFunctionRecCommand(funcs
, formals
, formulas
);
1200 Command
* DefineFunctionRecCommand::clone() const
1202 return new DefineFunctionRecCommand(d_funcs
, d_formals
, d_formulas
);
1205 std::string
DefineFunctionRecCommand::getCommandName() const
1207 return "define-fun-rec";
1210 /* -------------------------------------------------------------------------- */
1211 /* class SetUserAttribute */
1212 /* -------------------------------------------------------------------------- */
1214 SetUserAttributeCommand::SetUserAttributeCommand(
1215 const std::string
& attr
,
1217 const std::vector
<Expr
>& expr_values
,
1218 const std::string
& str_value
)
1221 d_expr_values(expr_values
),
1222 d_str_value(str_value
)
1226 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1228 : SetUserAttributeCommand(attr
, expr
, {}, "")
1232 SetUserAttributeCommand::SetUserAttributeCommand(
1233 const std::string
& attr
, Expr expr
, const std::vector
<Expr
>& values
)
1234 : SetUserAttributeCommand(attr
, expr
, values
, "")
1238 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1240 const std::string
& value
)
1241 : SetUserAttributeCommand(attr
, expr
, {}, value
)
1245 void SetUserAttributeCommand::invoke(SmtEngine
* smtEngine
)
1249 if (!d_expr
.isNull())
1251 smtEngine
->setUserAttribute(d_attr
, d_expr
, d_expr_values
, d_str_value
);
1253 d_commandStatus
= CommandSuccess::instance();
1255 catch (exception
& e
)
1257 d_commandStatus
= new CommandFailure(e
.what());
1261 Command
* SetUserAttributeCommand::exportTo(
1262 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1264 Expr expr
= d_expr
.exportTo(exprManager
, variableMap
);
1265 return new SetUserAttributeCommand(d_attr
, expr
, d_expr_values
, d_str_value
);
1268 Command
* SetUserAttributeCommand::clone() const
1270 return new SetUserAttributeCommand(
1271 d_attr
, d_expr
, d_expr_values
, d_str_value
);
1274 std::string
SetUserAttributeCommand::getCommandName() const
1276 return "set-user-attribute";
1279 /* -------------------------------------------------------------------------- */
1280 /* class SimplifyCommand */
1281 /* -------------------------------------------------------------------------- */
1283 SimplifyCommand::SimplifyCommand(Expr term
) : d_term(term
) {}
1284 Expr
SimplifyCommand::getTerm() const { return d_term
; }
1285 void SimplifyCommand::invoke(SmtEngine
* smtEngine
)
1289 d_result
= smtEngine
->simplify(d_term
);
1290 d_commandStatus
= CommandSuccess::instance();
1292 catch (UnsafeInterruptException
& e
)
1294 d_commandStatus
= new CommandInterrupted();
1296 catch (exception
& e
)
1298 d_commandStatus
= new CommandFailure(e
.what());
1302 Expr
SimplifyCommand::getResult() const { return d_result
; }
1303 void SimplifyCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1307 this->Command::printResult(out
, verbosity
);
1311 out
<< d_result
<< endl
;
1315 Command
* SimplifyCommand::exportTo(ExprManager
* exprManager
,
1316 ExprManagerMapCollection
& variableMap
)
1318 SimplifyCommand
* c
=
1319 new SimplifyCommand(d_term
.exportTo(exprManager
, variableMap
));
1320 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1324 Command
* SimplifyCommand::clone() const
1326 SimplifyCommand
* c
= new SimplifyCommand(d_term
);
1327 c
->d_result
= d_result
;
1331 std::string
SimplifyCommand::getCommandName() const { return "simplify"; }
1333 /* -------------------------------------------------------------------------- */
1334 /* class ExpandDefinitionsCommand */
1335 /* -------------------------------------------------------------------------- */
1337 ExpandDefinitionsCommand::ExpandDefinitionsCommand(Expr term
) : d_term(term
) {}
1338 Expr
ExpandDefinitionsCommand::getTerm() const { return d_term
; }
1339 void ExpandDefinitionsCommand::invoke(SmtEngine
* smtEngine
)
1341 d_result
= smtEngine
->expandDefinitions(d_term
);
1342 d_commandStatus
= CommandSuccess::instance();
1345 Expr
ExpandDefinitionsCommand::getResult() const { return d_result
; }
1346 void ExpandDefinitionsCommand::printResult(std::ostream
& out
,
1347 uint32_t verbosity
) const
1351 this->Command::printResult(out
, verbosity
);
1355 out
<< d_result
<< endl
;
1359 Command
* ExpandDefinitionsCommand::exportTo(
1360 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1362 ExpandDefinitionsCommand
* c
=
1363 new ExpandDefinitionsCommand(d_term
.exportTo(exprManager
, variableMap
));
1364 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1368 Command
* ExpandDefinitionsCommand::clone() const
1370 ExpandDefinitionsCommand
* c
= new ExpandDefinitionsCommand(d_term
);
1371 c
->d_result
= d_result
;
1375 std::string
ExpandDefinitionsCommand::getCommandName() const
1377 return "expand-definitions";
1380 /* -------------------------------------------------------------------------- */
1381 /* class GetValueCommand */
1382 /* -------------------------------------------------------------------------- */
1384 GetValueCommand::GetValueCommand(Expr term
) : d_terms()
1386 d_terms
.push_back(term
);
1389 GetValueCommand::GetValueCommand(const std::vector
<Expr
>& terms
)
1392 PrettyCheckArgument(
1393 terms
.size() >= 1, terms
, "cannot get-value of an empty set of terms");
1396 const std::vector
<Expr
>& GetValueCommand::getTerms() const { return d_terms
; }
1397 void GetValueCommand::invoke(SmtEngine
* smtEngine
)
1401 vector
<Expr
> result
;
1402 ExprManager
* em
= smtEngine
->getExprManager();
1403 NodeManager
* nm
= NodeManager::fromExprManager(em
);
1404 for (const Expr
& e
: d_terms
)
1406 Assert(nm
== NodeManager::fromExprManager(e
.getExprManager()));
1407 smt::SmtScope
scope(smtEngine
);
1408 Node request
= Node::fromExpr(
1409 options::expandDefinitions() ? smtEngine
->expandDefinitions(e
) : e
);
1410 Node value
= Node::fromExpr(smtEngine
->getValue(e
));
1411 if (value
.getType().isInteger() && request
.getType() == nm
->realType())
1413 // Need to wrap in special marker so that output printers know this
1414 // is an integer-looking constant that really should be output as
1415 // a rational. Necessary for SMT-LIB standards compliance, but ugly.
1416 value
= nm
->mkNode(kind::APPLY_TYPE_ASCRIPTION
,
1417 nm
->mkConst(AscriptionType(em
->realType())),
1420 result
.push_back(nm
->mkNode(kind::SEXPR
, request
, value
).toExpr());
1422 d_result
= em
->mkExpr(kind::SEXPR
, result
);
1423 d_commandStatus
= CommandSuccess::instance();
1425 catch (RecoverableModalException
& e
)
1427 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1429 catch (UnsafeInterruptException
& e
)
1431 d_commandStatus
= new CommandInterrupted();
1433 catch (exception
& e
)
1435 d_commandStatus
= new CommandFailure(e
.what());
1439 Expr
GetValueCommand::getResult() const { return d_result
; }
1440 void GetValueCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1444 this->Command::printResult(out
, verbosity
);
1448 expr::ExprDag::Scope
scope(out
, false);
1449 out
<< d_result
<< endl
;
1453 Command
* GetValueCommand::exportTo(ExprManager
* exprManager
,
1454 ExprManagerMapCollection
& variableMap
)
1456 vector
<Expr
> exportedTerms
;
1457 for (std::vector
<Expr
>::const_iterator i
= d_terms
.begin();
1461 exportedTerms
.push_back((*i
).exportTo(exprManager
, variableMap
));
1463 GetValueCommand
* c
= new GetValueCommand(exportedTerms
);
1464 c
->d_result
= d_result
.exportTo(exprManager
, variableMap
);
1468 Command
* GetValueCommand::clone() const
1470 GetValueCommand
* c
= new GetValueCommand(d_terms
);
1471 c
->d_result
= d_result
;
1475 std::string
GetValueCommand::getCommandName() const { return "get-value"; }
1477 /* -------------------------------------------------------------------------- */
1478 /* class GetAssignmentCommand */
1479 /* -------------------------------------------------------------------------- */
1481 GetAssignmentCommand::GetAssignmentCommand() {}
1482 void GetAssignmentCommand::invoke(SmtEngine
* smtEngine
)
1486 std::vector
<std::pair
<Expr
, Expr
>> assignments
= smtEngine
->getAssignment();
1487 vector
<SExpr
> sexprs
;
1488 for (const auto& p
: assignments
)
1491 if (p
.first
.getKind() == kind::APPLY
)
1493 v
.emplace_back(SExpr::Keyword(p
.first
.getOperator().toString()));
1497 v
.emplace_back(SExpr::Keyword(p
.first
.toString()));
1499 v
.emplace_back(SExpr::Keyword(p
.second
.toString()));
1500 sexprs
.emplace_back(v
);
1502 d_result
= SExpr(sexprs
);
1503 d_commandStatus
= CommandSuccess::instance();
1505 catch (RecoverableModalException
& e
)
1507 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1509 catch (UnsafeInterruptException
& e
)
1511 d_commandStatus
= new CommandInterrupted();
1513 catch (exception
& e
)
1515 d_commandStatus
= new CommandFailure(e
.what());
1519 SExpr
GetAssignmentCommand::getResult() const { return d_result
; }
1520 void GetAssignmentCommand::printResult(std::ostream
& out
,
1521 uint32_t verbosity
) const
1525 this->Command::printResult(out
, verbosity
);
1529 out
<< d_result
<< endl
;
1533 Command
* GetAssignmentCommand::exportTo(ExprManager
* exprManager
,
1534 ExprManagerMapCollection
& variableMap
)
1536 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1537 c
->d_result
= d_result
;
1541 Command
* GetAssignmentCommand::clone() const
1543 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1544 c
->d_result
= d_result
;
1548 std::string
GetAssignmentCommand::getCommandName() const
1550 return "get-assignment";
1553 /* -------------------------------------------------------------------------- */
1554 /* class GetModelCommand */
1555 /* -------------------------------------------------------------------------- */
1557 GetModelCommand::GetModelCommand() : d_result(nullptr), d_smtEngine(nullptr) {}
1558 void GetModelCommand::invoke(SmtEngine
* smtEngine
)
1562 d_result
= smtEngine
->getModel();
1563 d_smtEngine
= smtEngine
;
1564 d_commandStatus
= CommandSuccess::instance();
1566 catch (RecoverableModalException
& e
)
1568 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1570 catch (UnsafeInterruptException
& e
)
1572 d_commandStatus
= new CommandInterrupted();
1574 catch (exception
& e
)
1576 d_commandStatus
= new CommandFailure(e
.what());
1580 /* Model is private to the library -- for now
1581 Model* GetModelCommand::getResult() const {
1586 void GetModelCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1590 this->Command::printResult(out
, verbosity
);
1598 Command
* GetModelCommand::exportTo(ExprManager
* exprManager
,
1599 ExprManagerMapCollection
& variableMap
)
1601 GetModelCommand
* c
= new GetModelCommand();
1602 c
->d_result
= d_result
;
1603 c
->d_smtEngine
= d_smtEngine
;
1607 Command
* GetModelCommand::clone() const
1609 GetModelCommand
* c
= new GetModelCommand();
1610 c
->d_result
= d_result
;
1611 c
->d_smtEngine
= d_smtEngine
;
1615 std::string
GetModelCommand::getCommandName() const { return "get-model"; }
1617 /* -------------------------------------------------------------------------- */
1618 /* class GetProofCommand */
1619 /* -------------------------------------------------------------------------- */
1621 GetProofCommand::GetProofCommand() : d_smtEngine(nullptr), d_result(nullptr) {}
1622 void GetProofCommand::invoke(SmtEngine
* smtEngine
)
1626 d_smtEngine
= smtEngine
;
1627 d_result
= &smtEngine
->getProof();
1628 d_commandStatus
= CommandSuccess::instance();
1630 catch (RecoverableModalException
& e
)
1632 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1634 catch (UnsafeInterruptException
& e
)
1636 d_commandStatus
= new CommandInterrupted();
1638 catch (exception
& e
)
1640 d_commandStatus
= new CommandFailure(e
.what());
1644 const Proof
& GetProofCommand::getResult() const { return *d_result
; }
1645 void GetProofCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1649 this->Command::printResult(out
, verbosity
);
1653 smt::SmtScope
scope(d_smtEngine
);
1654 d_result
->toStream(out
);
1658 Command
* GetProofCommand::exportTo(ExprManager
* exprManager
,
1659 ExprManagerMapCollection
& variableMap
)
1661 GetProofCommand
* c
= new GetProofCommand();
1662 c
->d_result
= d_result
;
1663 c
->d_smtEngine
= d_smtEngine
;
1667 Command
* GetProofCommand::clone() const
1669 GetProofCommand
* c
= new GetProofCommand();
1670 c
->d_result
= d_result
;
1671 c
->d_smtEngine
= d_smtEngine
;
1675 std::string
GetProofCommand::getCommandName() const { return "get-proof"; }
1677 /* -------------------------------------------------------------------------- */
1678 /* class GetInstantiationsCommand */
1679 /* -------------------------------------------------------------------------- */
1681 GetInstantiationsCommand::GetInstantiationsCommand() : d_smtEngine(nullptr) {}
1682 void GetInstantiationsCommand::invoke(SmtEngine
* smtEngine
)
1686 d_smtEngine
= smtEngine
;
1687 d_commandStatus
= CommandSuccess::instance();
1689 catch (exception
& e
)
1691 d_commandStatus
= new CommandFailure(e
.what());
1695 void GetInstantiationsCommand::printResult(std::ostream
& out
,
1696 uint32_t verbosity
) const
1700 this->Command::printResult(out
, verbosity
);
1704 d_smtEngine
->printInstantiations(out
);
1708 Command
* GetInstantiationsCommand::exportTo(
1709 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1711 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
1712 // c->d_result = d_result;
1713 c
->d_smtEngine
= d_smtEngine
;
1717 Command
* GetInstantiationsCommand::clone() const
1719 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
1720 // c->d_result = d_result;
1721 c
->d_smtEngine
= d_smtEngine
;
1725 std::string
GetInstantiationsCommand::getCommandName() const
1727 return "get-instantiations";
1730 /* -------------------------------------------------------------------------- */
1731 /* class GetSynthSolutionCommand */
1732 /* -------------------------------------------------------------------------- */
1734 GetSynthSolutionCommand::GetSynthSolutionCommand() : d_smtEngine(nullptr) {}
1735 void GetSynthSolutionCommand::invoke(SmtEngine
* smtEngine
)
1739 d_smtEngine
= smtEngine
;
1740 d_commandStatus
= CommandSuccess::instance();
1742 catch (exception
& e
)
1744 d_commandStatus
= new CommandFailure(e
.what());
1748 void GetSynthSolutionCommand::printResult(std::ostream
& out
,
1749 uint32_t verbosity
) const
1753 this->Command::printResult(out
, verbosity
);
1757 d_smtEngine
->printSynthSolution(out
);
1761 Command
* GetSynthSolutionCommand::exportTo(
1762 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1764 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
1765 c
->d_smtEngine
= d_smtEngine
;
1769 Command
* GetSynthSolutionCommand::clone() const
1771 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
1772 c
->d_smtEngine
= d_smtEngine
;
1776 std::string
GetSynthSolutionCommand::getCommandName() const
1778 return "get-instantiations";
1781 /* -------------------------------------------------------------------------- */
1782 /* class GetQuantifierEliminationCommand */
1783 /* -------------------------------------------------------------------------- */
1785 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand() : d_expr() {}
1786 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand(
1787 const Expr
& expr
, bool doFull
)
1788 : d_expr(expr
), d_doFull(doFull
)
1792 Expr
GetQuantifierEliminationCommand::getExpr() const { return d_expr
; }
1793 bool GetQuantifierEliminationCommand::getDoFull() const { return d_doFull
; }
1794 void GetQuantifierEliminationCommand::invoke(SmtEngine
* smtEngine
)
1798 d_result
= smtEngine
->doQuantifierElimination(d_expr
, d_doFull
);
1799 d_commandStatus
= CommandSuccess::instance();
1801 catch (exception
& e
)
1803 d_commandStatus
= new CommandFailure(e
.what());
1807 Expr
GetQuantifierEliminationCommand::getResult() const { return d_result
; }
1808 void GetQuantifierEliminationCommand::printResult(std::ostream
& out
,
1809 uint32_t verbosity
) const
1813 this->Command::printResult(out
, verbosity
);
1817 out
<< d_result
<< endl
;
1821 Command
* GetQuantifierEliminationCommand::exportTo(
1822 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1824 GetQuantifierEliminationCommand
* c
= new GetQuantifierEliminationCommand(
1825 d_expr
.exportTo(exprManager
, variableMap
), d_doFull
);
1826 c
->d_result
= d_result
;
1830 Command
* GetQuantifierEliminationCommand::clone() const
1832 GetQuantifierEliminationCommand
* c
=
1833 new GetQuantifierEliminationCommand(d_expr
, d_doFull
);
1834 c
->d_result
= d_result
;
1838 std::string
GetQuantifierEliminationCommand::getCommandName() const
1840 return d_doFull
? "get-qe" : "get-qe-disjunct";
1843 /* -------------------------------------------------------------------------- */
1844 /* class GetUnsatAssumptionsCommand */
1845 /* -------------------------------------------------------------------------- */
1847 GetUnsatAssumptionsCommand::GetUnsatAssumptionsCommand() {}
1849 void GetUnsatAssumptionsCommand::invoke(SmtEngine
* smtEngine
)
1853 d_result
= smtEngine
->getUnsatAssumptions();
1854 d_commandStatus
= CommandSuccess::instance();
1856 catch (RecoverableModalException
& e
)
1858 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1860 catch (exception
& e
)
1862 d_commandStatus
= new CommandFailure(e
.what());
1866 std::vector
<Expr
> GetUnsatAssumptionsCommand::getResult() const
1871 void GetUnsatAssumptionsCommand::printResult(std::ostream
& out
,
1872 uint32_t verbosity
) const
1876 this->Command::printResult(out
, verbosity
);
1880 out
<< d_result
<< endl
;
1884 Command
* GetUnsatAssumptionsCommand::exportTo(
1885 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
1887 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
1888 c
->d_result
= d_result
;
1892 Command
* GetUnsatAssumptionsCommand::clone() const
1894 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
1895 c
->d_result
= d_result
;
1899 std::string
GetUnsatAssumptionsCommand::getCommandName() const
1901 return "get-unsat-assumptions";
1904 /* -------------------------------------------------------------------------- */
1905 /* class GetUnsatCoreCommand */
1906 /* -------------------------------------------------------------------------- */
1908 GetUnsatCoreCommand::GetUnsatCoreCommand() {}
1909 void GetUnsatCoreCommand::invoke(SmtEngine
* smtEngine
)
1913 d_result
= smtEngine
->getUnsatCore();
1914 d_commandStatus
= CommandSuccess::instance();
1916 catch (RecoverableModalException
& e
)
1918 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1920 catch (exception
& e
)
1922 d_commandStatus
= new CommandFailure(e
.what());
1926 void GetUnsatCoreCommand::printResult(std::ostream
& out
,
1927 uint32_t verbosity
) const
1931 this->Command::printResult(out
, verbosity
);
1935 d_result
.toStream(out
);
1939 const UnsatCore
& GetUnsatCoreCommand::getUnsatCore() const
1941 // of course, this will be empty if the command hasn't been invoked yet
1945 Command
* GetUnsatCoreCommand::exportTo(ExprManager
* exprManager
,
1946 ExprManagerMapCollection
& variableMap
)
1948 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
1949 c
->d_result
= d_result
;
1953 Command
* GetUnsatCoreCommand::clone() const
1955 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
1956 c
->d_result
= d_result
;
1960 std::string
GetUnsatCoreCommand::getCommandName() const
1962 return "get-unsat-core";
1965 /* -------------------------------------------------------------------------- */
1966 /* class GetAssertionsCommand */
1967 /* -------------------------------------------------------------------------- */
1969 GetAssertionsCommand::GetAssertionsCommand() {}
1970 void GetAssertionsCommand::invoke(SmtEngine
* smtEngine
)
1975 const vector
<Expr
> v
= smtEngine
->getAssertions();
1977 copy(v
.begin(), v
.end(), ostream_iterator
<Expr
>(ss
, "\n"));
1979 d_result
= ss
.str();
1980 d_commandStatus
= CommandSuccess::instance();
1982 catch (exception
& e
)
1984 d_commandStatus
= new CommandFailure(e
.what());
1988 std::string
GetAssertionsCommand::getResult() const { return d_result
; }
1989 void GetAssertionsCommand::printResult(std::ostream
& out
,
1990 uint32_t verbosity
) const
1994 this->Command::printResult(out
, verbosity
);
2002 Command
* GetAssertionsCommand::exportTo(ExprManager
* exprManager
,
2003 ExprManagerMapCollection
& variableMap
)
2005 GetAssertionsCommand
* c
= new GetAssertionsCommand();
2006 c
->d_result
= d_result
;
2010 Command
* GetAssertionsCommand::clone() const
2012 GetAssertionsCommand
* c
= new GetAssertionsCommand();
2013 c
->d_result
= d_result
;
2017 std::string
GetAssertionsCommand::getCommandName() const
2019 return "get-assertions";
2022 /* -------------------------------------------------------------------------- */
2023 /* class SetBenchmarkStatusCommand */
2024 /* -------------------------------------------------------------------------- */
2026 SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status
)
2031 BenchmarkStatus
SetBenchmarkStatusCommand::getStatus() const
2036 void SetBenchmarkStatusCommand::invoke(SmtEngine
* smtEngine
)
2042 SExpr status
= SExpr(ss
.str());
2043 smtEngine
->setInfo("status", status
);
2044 d_commandStatus
= CommandSuccess::instance();
2046 catch (exception
& e
)
2048 d_commandStatus
= new CommandFailure(e
.what());
2052 Command
* SetBenchmarkStatusCommand::exportTo(
2053 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2055 return new SetBenchmarkStatusCommand(d_status
);
2058 Command
* SetBenchmarkStatusCommand::clone() const
2060 return new SetBenchmarkStatusCommand(d_status
);
2063 std::string
SetBenchmarkStatusCommand::getCommandName() const
2068 /* -------------------------------------------------------------------------- */
2069 /* class SetBenchmarkLogicCommand */
2070 /* -------------------------------------------------------------------------- */
2072 SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic
)
2077 std::string
SetBenchmarkLogicCommand::getLogic() const { return d_logic
; }
2078 void SetBenchmarkLogicCommand::invoke(SmtEngine
* smtEngine
)
2082 smtEngine
->setLogic(d_logic
);
2083 d_commandStatus
= CommandSuccess::instance();
2085 catch (exception
& e
)
2087 d_commandStatus
= new CommandFailure(e
.what());
2091 Command
* SetBenchmarkLogicCommand::exportTo(
2092 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2094 return new SetBenchmarkLogicCommand(d_logic
);
2097 Command
* SetBenchmarkLogicCommand::clone() const
2099 return new SetBenchmarkLogicCommand(d_logic
);
2102 std::string
SetBenchmarkLogicCommand::getCommandName() const
2107 /* -------------------------------------------------------------------------- */
2108 /* class SetInfoCommand */
2109 /* -------------------------------------------------------------------------- */
2111 SetInfoCommand::SetInfoCommand(std::string flag
, const SExpr
& sexpr
)
2112 : d_flag(flag
), d_sexpr(sexpr
)
2116 std::string
SetInfoCommand::getFlag() const { return d_flag
; }
2117 SExpr
SetInfoCommand::getSExpr() const { return d_sexpr
; }
2118 void SetInfoCommand::invoke(SmtEngine
* smtEngine
)
2122 smtEngine
->setInfo(d_flag
, d_sexpr
);
2123 d_commandStatus
= CommandSuccess::instance();
2125 catch (UnrecognizedOptionException
&)
2127 // As per SMT-LIB spec, silently accept unknown set-info keys
2128 d_commandStatus
= CommandSuccess::instance();
2130 catch (exception
& e
)
2132 d_commandStatus
= new CommandFailure(e
.what());
2136 Command
* SetInfoCommand::exportTo(ExprManager
* exprManager
,
2137 ExprManagerMapCollection
& variableMap
)
2139 return new SetInfoCommand(d_flag
, d_sexpr
);
2142 Command
* SetInfoCommand::clone() const
2144 return new SetInfoCommand(d_flag
, d_sexpr
);
2147 std::string
SetInfoCommand::getCommandName() const { return "set-info"; }
2149 /* -------------------------------------------------------------------------- */
2150 /* class GetInfoCommand */
2151 /* -------------------------------------------------------------------------- */
2153 GetInfoCommand::GetInfoCommand(std::string flag
) : d_flag(flag
) {}
2154 std::string
GetInfoCommand::getFlag() const { return d_flag
; }
2155 void GetInfoCommand::invoke(SmtEngine
* smtEngine
)
2160 v
.push_back(SExpr(SExpr::Keyword(string(":") + d_flag
)));
2161 v
.push_back(smtEngine
->getInfo(d_flag
));
2163 if (d_flag
== "all-options" || d_flag
== "all-statistics")
2165 ss
<< PrettySExprs(true);
2168 d_result
= ss
.str();
2169 d_commandStatus
= CommandSuccess::instance();
2171 catch (UnrecognizedOptionException
&)
2173 d_commandStatus
= new CommandUnsupported();
2175 catch (exception
& e
)
2177 d_commandStatus
= new CommandFailure(e
.what());
2181 std::string
GetInfoCommand::getResult() const { return d_result
; }
2182 void GetInfoCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2186 this->Command::printResult(out
, verbosity
);
2188 else if (d_result
!= "")
2190 out
<< d_result
<< endl
;
2194 Command
* GetInfoCommand::exportTo(ExprManager
* exprManager
,
2195 ExprManagerMapCollection
& variableMap
)
2197 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2198 c
->d_result
= d_result
;
2202 Command
* GetInfoCommand::clone() const
2204 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2205 c
->d_result
= d_result
;
2209 std::string
GetInfoCommand::getCommandName() const { return "get-info"; }
2211 /* -------------------------------------------------------------------------- */
2212 /* class SetOptionCommand */
2213 /* -------------------------------------------------------------------------- */
2215 SetOptionCommand::SetOptionCommand(std::string flag
, const SExpr
& sexpr
)
2216 : d_flag(flag
), d_sexpr(sexpr
)
2220 std::string
SetOptionCommand::getFlag() const { return d_flag
; }
2221 SExpr
SetOptionCommand::getSExpr() const { return d_sexpr
; }
2222 void SetOptionCommand::invoke(SmtEngine
* smtEngine
)
2226 smtEngine
->setOption(d_flag
, d_sexpr
);
2227 d_commandStatus
= CommandSuccess::instance();
2229 catch (UnrecognizedOptionException
&)
2231 d_commandStatus
= new CommandUnsupported();
2233 catch (exception
& e
)
2235 d_commandStatus
= new CommandFailure(e
.what());
2239 Command
* SetOptionCommand::exportTo(ExprManager
* exprManager
,
2240 ExprManagerMapCollection
& variableMap
)
2242 return new SetOptionCommand(d_flag
, d_sexpr
);
2245 Command
* SetOptionCommand::clone() const
2247 return new SetOptionCommand(d_flag
, d_sexpr
);
2250 std::string
SetOptionCommand::getCommandName() const { return "set-option"; }
2252 /* -------------------------------------------------------------------------- */
2253 /* class GetOptionCommand */
2254 /* -------------------------------------------------------------------------- */
2256 GetOptionCommand::GetOptionCommand(std::string flag
) : d_flag(flag
) {}
2257 std::string
GetOptionCommand::getFlag() const { return d_flag
; }
2258 void GetOptionCommand::invoke(SmtEngine
* smtEngine
)
2262 SExpr res
= smtEngine
->getOption(d_flag
);
2263 d_result
= res
.toString();
2264 d_commandStatus
= CommandSuccess::instance();
2266 catch (UnrecognizedOptionException
&)
2268 d_commandStatus
= new CommandUnsupported();
2270 catch (exception
& e
)
2272 d_commandStatus
= new CommandFailure(e
.what());
2276 std::string
GetOptionCommand::getResult() const { return d_result
; }
2277 void GetOptionCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2281 this->Command::printResult(out
, verbosity
);
2283 else if (d_result
!= "")
2285 out
<< d_result
<< endl
;
2289 Command
* GetOptionCommand::exportTo(ExprManager
* exprManager
,
2290 ExprManagerMapCollection
& variableMap
)
2292 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2293 c
->d_result
= d_result
;
2297 Command
* GetOptionCommand::clone() const
2299 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2300 c
->d_result
= d_result
;
2304 std::string
GetOptionCommand::getCommandName() const { return "get-option"; }
2306 /* -------------------------------------------------------------------------- */
2307 /* class SetExpressionNameCommand */
2308 /* -------------------------------------------------------------------------- */
2310 SetExpressionNameCommand::SetExpressionNameCommand(Expr expr
, std::string name
)
2311 : d_expr(expr
), d_name(name
)
2315 void SetExpressionNameCommand::invoke(SmtEngine
* smtEngine
)
2317 smtEngine
->setExpressionName(d_expr
, d_name
);
2318 d_commandStatus
= CommandSuccess::instance();
2321 Command
* SetExpressionNameCommand::exportTo(
2322 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2324 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(
2325 d_expr
.exportTo(exprManager
, variableMap
), d_name
);
2329 Command
* SetExpressionNameCommand::clone() const
2331 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(d_expr
, d_name
);
2335 std::string
SetExpressionNameCommand::getCommandName() const
2337 return "set-expr-name";
2340 /* -------------------------------------------------------------------------- */
2341 /* class DatatypeDeclarationCommand */
2342 /* -------------------------------------------------------------------------- */
2344 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2345 const DatatypeType
& datatype
)
2348 d_datatypes
.push_back(datatype
);
2351 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2352 const std::vector
<DatatypeType
>& datatypes
)
2353 : d_datatypes(datatypes
)
2357 const std::vector
<DatatypeType
>& DatatypeDeclarationCommand::getDatatypes()
2363 void DatatypeDeclarationCommand::invoke(SmtEngine
* smtEngine
)
2365 d_commandStatus
= CommandSuccess::instance();
2368 Command
* DatatypeDeclarationCommand::exportTo(
2369 ExprManager
* exprManager
, ExprManagerMapCollection
& variableMap
)
2371 throw ExportUnsupportedException(
2372 "export of DatatypeDeclarationCommand unsupported");
2375 Command
* DatatypeDeclarationCommand::clone() const
2377 return new DatatypeDeclarationCommand(d_datatypes
);
2380 std::string
DatatypeDeclarationCommand::getCommandName() const
2382 return "declare-datatypes";
2385 /* -------------------------------------------------------------------------- */
2386 /* class RewriteRuleCommand */
2387 /* -------------------------------------------------------------------------- */
2389 RewriteRuleCommand::RewriteRuleCommand(const std::vector
<Expr
>& vars
,
2390 const std::vector
<Expr
>& guards
,
2393 const Triggers
& triggers
)
2398 d_triggers(triggers
)
2402 RewriteRuleCommand::RewriteRuleCommand(const std::vector
<Expr
>& vars
,
2405 : d_vars(vars
), d_head(head
), d_body(body
)
2409 const std::vector
<Expr
>& RewriteRuleCommand::getVars() const { return d_vars
; }
2410 const std::vector
<Expr
>& RewriteRuleCommand::getGuards() const
2415 Expr
RewriteRuleCommand::getHead() const { return d_head
; }
2416 Expr
RewriteRuleCommand::getBody() const { return d_body
; }
2417 const RewriteRuleCommand::Triggers
& RewriteRuleCommand::getTriggers() const
2422 void RewriteRuleCommand::invoke(SmtEngine
* smtEngine
)
2426 ExprManager
* em
= smtEngine
->getExprManager();
2427 /** build vars list */
2428 Expr vars
= em
->mkExpr(kind::BOUND_VAR_LIST
, d_vars
);
2429 /** build guards list */
2431 if (d_guards
.size() == 0)
2432 guards
= em
->mkConst
<bool>(true);
2433 else if (d_guards
.size() == 1)
2434 guards
= d_guards
[0];
2436 guards
= em
->mkExpr(kind::AND
, d_guards
);
2437 /** build expression */
2439 if (d_triggers
.empty())
2441 expr
= em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, d_head
, d_body
);
2445 /** build triggers list */
2446 std::vector
<Expr
> vtriggers
;
2447 vtriggers
.reserve(d_triggers
.size());
2448 for (Triggers::const_iterator i
= d_triggers
.begin(),
2449 end
= d_triggers
.end();
2453 vtriggers
.push_back(em
->mkExpr(kind::INST_PATTERN
, *i
));
2455 Expr triggers
= em
->mkExpr(kind::INST_PATTERN_LIST
, vtriggers
);
2457 em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, d_head
, d_body
, triggers
);
2459 smtEngine
->assertFormula(expr
);
2460 d_commandStatus
= CommandSuccess::instance();
2462 catch (exception
& e
)
2464 d_commandStatus
= new CommandFailure(e
.what());
2468 Command
* RewriteRuleCommand::exportTo(ExprManager
* exprManager
,
2469 ExprManagerMapCollection
& variableMap
)
2471 /** Convert variables */
2472 VExpr vars
= ExportTo(exprManager
, variableMap
, d_vars
);
2473 /** Convert guards */
2474 VExpr guards
= ExportTo(exprManager
, variableMap
, d_guards
);
2475 /** Convert triggers */
2477 triggers
.reserve(d_triggers
.size());
2478 for (const std::vector
<Expr
>& trigger_list
: d_triggers
)
2480 triggers
.push_back(ExportTo(exprManager
, variableMap
, trigger_list
));
2482 /** Convert head and body */
2483 Expr head
= d_head
.exportTo(exprManager
, variableMap
);
2484 Expr body
= d_body
.exportTo(exprManager
, variableMap
);
2485 /** Create the converted rules */
2486 return new RewriteRuleCommand(vars
, guards
, head
, body
, triggers
);
2489 Command
* RewriteRuleCommand::clone() const
2491 return new RewriteRuleCommand(d_vars
, d_guards
, d_head
, d_body
, d_triggers
);
2494 std::string
RewriteRuleCommand::getCommandName() const
2496 return "rewrite-rule";
2499 /* -------------------------------------------------------------------------- */
2500 /* class PropagateRuleCommand */
2501 /* -------------------------------------------------------------------------- */
2503 PropagateRuleCommand::PropagateRuleCommand(const std::vector
<Expr
>& vars
,
2504 const std::vector
<Expr
>& guards
,
2505 const std::vector
<Expr
>& heads
,
2507 const Triggers
& triggers
,
2513 d_triggers(triggers
),
2514 d_deduction(deduction
)
2518 PropagateRuleCommand::PropagateRuleCommand(const std::vector
<Expr
>& vars
,
2519 const std::vector
<Expr
>& heads
,
2522 : d_vars(vars
), d_heads(heads
), d_body(body
), d_deduction(deduction
)
2526 const std::vector
<Expr
>& PropagateRuleCommand::getVars() const
2531 const std::vector
<Expr
>& PropagateRuleCommand::getGuards() const
2536 const std::vector
<Expr
>& PropagateRuleCommand::getHeads() const
2541 Expr
PropagateRuleCommand::getBody() const { return d_body
; }
2542 const PropagateRuleCommand::Triggers
& PropagateRuleCommand::getTriggers() const
2547 bool PropagateRuleCommand::isDeduction() const { return d_deduction
; }
2548 void PropagateRuleCommand::invoke(SmtEngine
* smtEngine
)
2552 ExprManager
* em
= smtEngine
->getExprManager();
2553 /** build vars list */
2554 Expr vars
= em
->mkExpr(kind::BOUND_VAR_LIST
, d_vars
);
2555 /** build guards list */
2557 if (d_guards
.size() == 0)
2558 guards
= em
->mkConst
<bool>(true);
2559 else if (d_guards
.size() == 1)
2560 guards
= d_guards
[0];
2562 guards
= em
->mkExpr(kind::AND
, d_guards
);
2563 /** build heads list */
2565 if (d_heads
.size() == 1)
2568 heads
= em
->mkExpr(kind::AND
, d_heads
);
2569 /** build expression */
2571 if (d_triggers
.empty())
2573 expr
= em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, heads
, d_body
);
2577 /** build triggers list */
2578 std::vector
<Expr
> vtriggers
;
2579 vtriggers
.reserve(d_triggers
.size());
2580 for (Triggers::const_iterator i
= d_triggers
.begin(),
2581 end
= d_triggers
.end();
2585 vtriggers
.push_back(em
->mkExpr(kind::INST_PATTERN
, *i
));
2587 Expr triggers
= em
->mkExpr(kind::INST_PATTERN_LIST
, vtriggers
);
2589 em
->mkExpr(kind::RR_REWRITE
, vars
, guards
, heads
, d_body
, triggers
);
2591 smtEngine
->assertFormula(expr
);
2592 d_commandStatus
= CommandSuccess::instance();
2594 catch (exception
& e
)
2596 d_commandStatus
= new CommandFailure(e
.what());
2600 Command
* PropagateRuleCommand::exportTo(ExprManager
* exprManager
,
2601 ExprManagerMapCollection
& variableMap
)
2603 /** Convert variables */
2604 VExpr vars
= ExportTo(exprManager
, variableMap
, d_vars
);
2605 /** Convert guards */
2606 VExpr guards
= ExportTo(exprManager
, variableMap
, d_guards
);
2607 /** Convert heads */
2608 VExpr heads
= ExportTo(exprManager
, variableMap
, d_heads
);
2609 /** Convert triggers */
2611 triggers
.reserve(d_triggers
.size());
2612 for (const std::vector
<Expr
>& trigger_list
: d_triggers
)
2614 triggers
.push_back(ExportTo(exprManager
, variableMap
, trigger_list
));
2616 /** Convert head and body */
2617 Expr body
= d_body
.exportTo(exprManager
, variableMap
);
2618 /** Create the converted rules */
2619 return new PropagateRuleCommand(vars
, guards
, heads
, body
, triggers
);
2622 Command
* PropagateRuleCommand::clone() const
2624 return new PropagateRuleCommand(
2625 d_vars
, d_guards
, d_heads
, d_body
, d_triggers
);
2628 std::string
PropagateRuleCommand::getCommandName() const
2630 return "propagate-rule";