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-2020 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 "api/cvc4cpp.h"
27 #include "base/check.h"
28 #include "base/output.h"
29 #include "expr/expr_iomanip.h"
30 #include "expr/node.h"
31 #include "expr/type.h"
32 #include "options/options.h"
33 #include "options/smt_options.h"
34 #include "printer/printer.h"
36 #include "smt/model.h"
37 #include "smt/smt_engine.h"
38 #include "smt/smt_engine_scope.h"
39 #include "util/sexpr.h"
40 #include "util/utility.h"
46 const int CommandPrintSuccess::s_iosIndex
= std::ios_base::xalloc();
47 const CommandSuccess
* CommandSuccess::s_instance
= new CommandSuccess();
48 const CommandInterrupted
* CommandInterrupted::s_instance
=
49 new CommandInterrupted();
51 std::ostream
& operator<<(std::ostream
& out
, const Command
& c
)
54 Node::setdepth::getDepth(out
),
55 Node::printtypes::getPrintTypes(out
),
56 Node::dag::getDag(out
),
57 Node::setlanguage::getLanguage(out
));
61 ostream
& operator<<(ostream
& out
, const Command
* c
)
74 std::ostream
& operator<<(std::ostream
& out
, const CommandStatus
& s
)
76 s
.toStream(out
, Node::setlanguage::getLanguage(out
));
80 ostream
& operator<<(ostream
& out
, const CommandStatus
* s
)
93 /* output stream insertion operator for benchmark statuses */
94 std::ostream
& operator<<(std::ostream
& out
, BenchmarkStatus status
)
98 case SMT_SATISFIABLE
: return out
<< "sat";
100 case SMT_UNSATISFIABLE
: return out
<< "unsat";
102 case SMT_UNKNOWN
: return out
<< "unknown";
104 default: return out
<< "BenchmarkStatus::[UNKNOWNSTATUS!]";
108 /* -------------------------------------------------------------------------- */
109 /* class CommandPrintSuccess */
110 /* -------------------------------------------------------------------------- */
112 void CommandPrintSuccess::applyPrintSuccess(std::ostream
& out
)
114 out
.iword(s_iosIndex
) = d_printSuccess
;
117 bool CommandPrintSuccess::getPrintSuccess(std::ostream
& out
)
119 return out
.iword(s_iosIndex
);
122 void CommandPrintSuccess::setPrintSuccess(std::ostream
& out
, bool printSuccess
)
124 out
.iword(s_iosIndex
) = printSuccess
;
127 std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
)
129 cps
.applyPrintSuccess(out
);
133 /* -------------------------------------------------------------------------- */
135 /* -------------------------------------------------------------------------- */
137 Command::Command() : d_commandStatus(nullptr), d_muted(false) {}
139 Command::Command(const api::Solver
* solver
)
140 : d_commandStatus(nullptr), d_muted(false)
144 Command::Command(const Command
& cmd
)
147 (cmd
.d_commandStatus
== NULL
) ? NULL
: &cmd
.d_commandStatus
->clone();
148 d_muted
= cmd
.d_muted
;
153 if (d_commandStatus
!= NULL
&& d_commandStatus
!= CommandSuccess::instance())
155 delete d_commandStatus
;
159 bool Command::ok() const
161 // either we haven't run the command yet, or it ran successfully
162 return d_commandStatus
== NULL
163 || dynamic_cast<const CommandSuccess
*>(d_commandStatus
) != NULL
;
166 bool Command::fail() const
168 return d_commandStatus
!= NULL
169 && dynamic_cast<const CommandFailure
*>(d_commandStatus
) != NULL
;
172 bool Command::interrupted() const
174 return d_commandStatus
!= NULL
175 && dynamic_cast<const CommandInterrupted
*>(d_commandStatus
) != NULL
;
178 void Command::invoke(api::Solver
* solver
, std::ostream
& out
)
181 if (!(isMuted() && ok()))
185 std::stoul(solver
->getOption("command-verbosity:" + getCommandName())));
189 std::string
Command::toString() const
191 std::stringstream ss
;
196 void CommandStatus::toStream(std::ostream
& out
, OutputLanguage language
) const
198 Printer::getPrinter(language
)->toStream(out
, this);
201 void Command::printResult(std::ostream
& out
, uint32_t verbosity
) const
203 if (d_commandStatus
!= NULL
)
205 if ((!ok() && verbosity
>= 1) || verbosity
>= 2)
207 out
<< *d_commandStatus
;
212 /* -------------------------------------------------------------------------- */
213 /* class EmptyCommand */
214 /* -------------------------------------------------------------------------- */
216 EmptyCommand::EmptyCommand(std::string name
) : d_name(name
) {}
217 std::string
EmptyCommand::getName() const { return d_name
; }
218 void EmptyCommand::invoke(api::Solver
* solver
)
220 /* empty commands have no implementation */
221 d_commandStatus
= CommandSuccess::instance();
224 Command
* EmptyCommand::clone() const { return new EmptyCommand(d_name
); }
225 std::string
EmptyCommand::getCommandName() const { return "empty"; }
227 void EmptyCommand::toStream(std::ostream
& out
,
231 OutputLanguage language
) const
233 Printer::getPrinter(language
)->toStreamCmdEmpty(out
, d_name
);
236 /* -------------------------------------------------------------------------- */
237 /* class EchoCommand */
238 /* -------------------------------------------------------------------------- */
240 EchoCommand::EchoCommand(std::string output
) : d_output(output
) {}
241 std::string
EchoCommand::getOutput() const { return d_output
; }
242 void EchoCommand::invoke(api::Solver
* solver
)
244 /* we don't have an output stream here, nothing to do */
245 d_commandStatus
= CommandSuccess::instance();
248 void EchoCommand::invoke(api::Solver
* solver
, std::ostream
& out
)
250 out
<< d_output
<< std::endl
;
251 Trace("dtview::command") << "* ~COMMAND: echo |" << d_output
<< "|~"
253 d_commandStatus
= CommandSuccess::instance();
256 std::stoul(solver
->getOption("command-verbosity:" + getCommandName())));
259 Command
* EchoCommand::clone() const { return new EchoCommand(d_output
); }
260 std::string
EchoCommand::getCommandName() const { return "echo"; }
262 void EchoCommand::toStream(std::ostream
& out
,
266 OutputLanguage language
) const
268 Printer::getPrinter(language
)->toStreamCmdEcho(out
, d_output
);
271 /* -------------------------------------------------------------------------- */
272 /* class AssertCommand */
273 /* -------------------------------------------------------------------------- */
275 AssertCommand::AssertCommand(const api::Term
& t
, bool inUnsatCore
)
276 : d_term(t
), d_inUnsatCore(inUnsatCore
)
280 api::Term
AssertCommand::getTerm() const { return d_term
; }
281 void AssertCommand::invoke(api::Solver
* solver
)
285 solver
->getSmtEngine()->assertFormula(d_term
.getExpr(), d_inUnsatCore
);
286 d_commandStatus
= CommandSuccess::instance();
288 catch (UnsafeInterruptException
& e
)
290 d_commandStatus
= new CommandInterrupted();
294 d_commandStatus
= new CommandFailure(e
.what());
298 Command
* AssertCommand::clone() const
300 return new AssertCommand(d_term
, d_inUnsatCore
);
303 std::string
AssertCommand::getCommandName() const { return "assert"; }
305 void AssertCommand::toStream(std::ostream
& out
,
309 OutputLanguage language
) const
311 Printer::getPrinter(language
)->toStreamCmdAssert(out
, d_term
.getNode());
314 /* -------------------------------------------------------------------------- */
315 /* class PushCommand */
316 /* -------------------------------------------------------------------------- */
318 void PushCommand::invoke(api::Solver
* solver
)
323 d_commandStatus
= CommandSuccess::instance();
325 catch (UnsafeInterruptException
& e
)
327 d_commandStatus
= new CommandInterrupted();
331 d_commandStatus
= new CommandFailure(e
.what());
335 Command
* PushCommand::clone() const { return new PushCommand(); }
336 std::string
PushCommand::getCommandName() const { return "push"; }
338 void PushCommand::toStream(std::ostream
& out
,
342 OutputLanguage language
) const
344 Printer::getPrinter(language
)->toStreamCmdPush(out
);
347 /* -------------------------------------------------------------------------- */
348 /* class PopCommand */
349 /* -------------------------------------------------------------------------- */
351 void PopCommand::invoke(api::Solver
* solver
)
356 d_commandStatus
= CommandSuccess::instance();
358 catch (UnsafeInterruptException
& e
)
360 d_commandStatus
= new CommandInterrupted();
364 d_commandStatus
= new CommandFailure(e
.what());
368 Command
* PopCommand::clone() const { return new PopCommand(); }
369 std::string
PopCommand::getCommandName() const { return "pop"; }
371 void PopCommand::toStream(std::ostream
& out
,
375 OutputLanguage language
) const
377 Printer::getPrinter(language
)->toStreamCmdPop(out
);
380 /* -------------------------------------------------------------------------- */
381 /* class CheckSatCommand */
382 /* -------------------------------------------------------------------------- */
384 CheckSatCommand::CheckSatCommand() : d_term() {}
386 CheckSatCommand::CheckSatCommand(const api::Term
& term
) : d_term(term
) {}
388 api::Term
CheckSatCommand::getTerm() const { return d_term
; }
389 void CheckSatCommand::invoke(api::Solver
* solver
)
391 Trace("dtview::command") << "* ~COMMAND: " << getCommandName() << "~"
396 d_term
.isNull() ? solver
->checkSat() : solver
->checkSatAssuming(d_term
);
398 d_commandStatus
= CommandSuccess::instance();
402 d_commandStatus
= new CommandFailure(e
.what());
406 api::Result
CheckSatCommand::getResult() const { return d_result
; }
407 void CheckSatCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
411 this->Command::printResult(out
, verbosity
);
415 Trace("dtview::command") << "* RESULT: " << d_result
<< std::endl
;
416 out
<< d_result
<< endl
;
420 Command
* CheckSatCommand::clone() const
422 CheckSatCommand
* c
= new CheckSatCommand(d_term
);
423 c
->d_result
= d_result
;
427 std::string
CheckSatCommand::getCommandName() const { return "check-sat"; }
429 void CheckSatCommand::toStream(std::ostream
& out
,
433 OutputLanguage language
) const
435 Printer::getPrinter(language
)->toStreamCmdCheckSat(out
, d_term
.getNode());
438 /* -------------------------------------------------------------------------- */
439 /* class CheckSatAssumingCommand */
440 /* -------------------------------------------------------------------------- */
442 CheckSatAssumingCommand::CheckSatAssumingCommand(api::Term term
)
447 CheckSatAssumingCommand::CheckSatAssumingCommand(
448 const std::vector
<api::Term
>& terms
)
453 const std::vector
<api::Term
>& CheckSatAssumingCommand::getTerms() const
458 void CheckSatAssumingCommand::invoke(api::Solver
* solver
)
460 Trace("dtview::command") << "* ~COMMAND: (check-sat-assuming ( " << d_terms
461 << " )~" << std::endl
;
464 d_result
= solver
->checkSatAssuming(d_terms
);
465 d_commandStatus
= CommandSuccess::instance();
469 d_commandStatus
= new CommandFailure(e
.what());
473 api::Result
CheckSatAssumingCommand::getResult() const
475 Trace("dtview::command") << "* ~RESULT: " << d_result
<< "~" << std::endl
;
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::clone() const
494 CheckSatAssumingCommand
* c
= new CheckSatAssumingCommand(d_terms
);
495 c
->d_result
= d_result
;
499 std::string
CheckSatAssumingCommand::getCommandName() const
501 return "check-sat-assuming";
504 void CheckSatAssumingCommand::toStream(std::ostream
& out
,
508 OutputLanguage language
) const
510 Printer::getPrinter(language
)->toStreamCmdCheckSatAssuming(
511 out
, api::termVectorToNodes(d_terms
));
514 /* -------------------------------------------------------------------------- */
515 /* class QueryCommand */
516 /* -------------------------------------------------------------------------- */
518 QueryCommand::QueryCommand(const api::Term
& t
, bool inUnsatCore
)
519 : d_term(t
), d_inUnsatCore(inUnsatCore
)
523 api::Term
QueryCommand::getTerm() const { return d_term
; }
524 void QueryCommand::invoke(api::Solver
* solver
)
528 d_result
= solver
->checkEntailed(d_term
);
529 d_commandStatus
= CommandSuccess::instance();
533 d_commandStatus
= new CommandFailure(e
.what());
537 api::Result
QueryCommand::getResult() const { return d_result
; }
538 void QueryCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
542 this->Command::printResult(out
, verbosity
);
546 out
<< d_result
<< endl
;
550 Command
* QueryCommand::clone() const
552 QueryCommand
* c
= new QueryCommand(d_term
, d_inUnsatCore
);
553 c
->d_result
= d_result
;
557 std::string
QueryCommand::getCommandName() const { return "query"; }
559 void QueryCommand::toStream(std::ostream
& out
,
563 OutputLanguage language
) const
565 Printer::getPrinter(language
)->toStreamCmdQuery(out
, d_term
.getNode());
568 /* -------------------------------------------------------------------------- */
569 /* class DeclareSygusVarCommand */
570 /* -------------------------------------------------------------------------- */
572 DeclareSygusVarCommand::DeclareSygusVarCommand(const std::string
& id
,
575 : DeclarationDefinitionCommand(id
), d_var(var
), d_sort(sort
)
579 api::Term
DeclareSygusVarCommand::getVar() const { return d_var
; }
580 api::Sort
DeclareSygusVarCommand::getSort() const { return d_sort
; }
582 void DeclareSygusVarCommand::invoke(api::Solver
* solver
)
586 solver
->getSmtEngine()->declareSygusVar(
587 d_symbol
, d_var
.getNode(), TypeNode::fromType(d_sort
.getType()));
588 d_commandStatus
= CommandSuccess::instance();
592 d_commandStatus
= new CommandFailure(e
.what());
596 Command
* DeclareSygusVarCommand::clone() const
598 return new DeclareSygusVarCommand(d_symbol
, d_var
, d_sort
);
601 std::string
DeclareSygusVarCommand::getCommandName() const
603 return "declare-var";
606 void DeclareSygusVarCommand::toStream(std::ostream
& out
,
610 OutputLanguage language
) const
612 Printer::getPrinter(language
)->toStreamCmdDeclareVar(
613 out
, d_var
.getNode(), TypeNode::fromType(d_sort
.getType()));
616 /* -------------------------------------------------------------------------- */
617 /* class SynthFunCommand */
618 /* -------------------------------------------------------------------------- */
620 SynthFunCommand::SynthFunCommand(const std::string
& id
,
622 const std::vector
<api::Term
>& vars
,
626 : DeclarationDefinitionCommand(id
),
635 api::Term
SynthFunCommand::getFunction() const { return d_fun
; }
637 const std::vector
<api::Term
>& SynthFunCommand::getVars() const
642 api::Sort
SynthFunCommand::getSort() const { return d_sort
; }
643 bool SynthFunCommand::isInv() const { return d_isInv
; }
645 const api::Grammar
* SynthFunCommand::getGrammar() const { return d_grammar
; }
647 void SynthFunCommand::invoke(api::Solver
* solver
)
651 std::vector
<Node
> vns
;
652 for (const api::Term
& t
: d_vars
)
654 vns
.push_back(Node::fromExpr(t
.getExpr()));
656 solver
->getSmtEngine()->declareSynthFun(
658 Node::fromExpr(d_fun
.getExpr()),
659 TypeNode::fromType(d_grammar
== nullptr
661 : d_grammar
->resolve().getType()),
664 d_commandStatus
= CommandSuccess::instance();
668 d_commandStatus
= new CommandFailure(e
.what());
672 Command
* SynthFunCommand::clone() const
674 return new SynthFunCommand(
675 d_symbol
, d_fun
, d_vars
, d_sort
, d_isInv
, d_grammar
);
678 std::string
SynthFunCommand::getCommandName() const
680 return d_isInv
? "synth-inv" : "synth-fun";
683 void SynthFunCommand::toStream(std::ostream
& out
,
687 OutputLanguage language
) const
689 std::vector
<Node
> nodeVars
= termVectorToNodes(d_vars
);
690 Printer::getPrinter(language
)->toStreamCmdSynthFun(
694 TypeNode::fromType(d_sort
.getType()),
696 TypeNode::fromType(d_grammar
->resolve().getType()));
699 /* -------------------------------------------------------------------------- */
700 /* class SygusConstraintCommand */
701 /* -------------------------------------------------------------------------- */
703 SygusConstraintCommand::SygusConstraintCommand(const api::Term
& t
) : d_term(t
)
707 void SygusConstraintCommand::invoke(api::Solver
* solver
)
711 solver
->addSygusConstraint(d_term
);
712 d_commandStatus
= CommandSuccess::instance();
716 d_commandStatus
= new CommandFailure(e
.what());
720 api::Term
SygusConstraintCommand::getTerm() const { return d_term
; }
722 Command
* SygusConstraintCommand::clone() const
724 return new SygusConstraintCommand(d_term
);
727 std::string
SygusConstraintCommand::getCommandName() const
732 void SygusConstraintCommand::toStream(std::ostream
& out
,
736 OutputLanguage language
) const
738 Printer::getPrinter(language
)->toStreamCmdConstraint(out
, d_term
.getNode());
741 /* -------------------------------------------------------------------------- */
742 /* class SygusInvConstraintCommand */
743 /* -------------------------------------------------------------------------- */
745 SygusInvConstraintCommand::SygusInvConstraintCommand(
746 const std::vector
<api::Term
>& predicates
)
747 : d_predicates(predicates
)
751 SygusInvConstraintCommand::SygusInvConstraintCommand(const api::Term
& inv
,
752 const api::Term
& pre
,
753 const api::Term
& trans
,
754 const api::Term
& post
)
755 : SygusInvConstraintCommand(std::vector
<api::Term
>{inv
, pre
, trans
, post
})
759 void SygusInvConstraintCommand::invoke(api::Solver
* solver
)
763 solver
->addSygusInvConstraint(
764 d_predicates
[0], d_predicates
[1], d_predicates
[2], d_predicates
[3]);
765 d_commandStatus
= CommandSuccess::instance();
769 d_commandStatus
= new CommandFailure(e
.what());
773 const std::vector
<api::Term
>& SygusInvConstraintCommand::getPredicates() const
778 Command
* SygusInvConstraintCommand::clone() const
780 return new SygusInvConstraintCommand(d_predicates
);
783 std::string
SygusInvConstraintCommand::getCommandName() const
785 return "inv-constraint";
788 void SygusInvConstraintCommand::toStream(std::ostream
& out
,
792 OutputLanguage language
) const
794 Printer::getPrinter(language
)->toStreamCmdInvConstraint(
796 d_predicates
[0].getNode(),
797 d_predicates
[1].getNode(),
798 d_predicates
[2].getNode(),
799 d_predicates
[3].getNode());
802 /* -------------------------------------------------------------------------- */
803 /* class CheckSynthCommand */
804 /* -------------------------------------------------------------------------- */
806 void CheckSynthCommand::invoke(api::Solver
* solver
)
810 d_result
= solver
->checkSynth();
811 d_commandStatus
= CommandSuccess::instance();
813 // check whether we should print the status
814 if (!d_result
.isUnsat()
815 || options::sygusOut() == options::SygusSolutionOutMode::STATUS_AND_DEF
816 || options::sygusOut() == options::SygusSolutionOutMode::STATUS
)
818 if (options::sygusOut() == options::SygusSolutionOutMode::STANDARD
)
820 d_solution
<< "(fail)" << endl
;
824 d_solution
<< d_result
<< endl
;
827 // check whether we should print the solution
828 if (d_result
.isUnsat()
829 && options::sygusOut() != options::SygusSolutionOutMode::STATUS
)
831 // printing a synthesis solution is a non-constant
832 // method, since it invokes a sophisticated algorithm
833 // (Figure 5 of Reynolds et al. CAV 2015).
834 // Hence, we must call here print solution here,
835 // instead of during printResult.
836 solver
->printSynthSolution(d_solution
);
841 d_commandStatus
= new CommandFailure(e
.what());
845 api::Result
CheckSynthCommand::getResult() const { return d_result
; }
846 void CheckSynthCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
850 this->Command::printResult(out
, verbosity
);
854 out
<< d_solution
.str();
858 Command
* CheckSynthCommand::clone() const { return new CheckSynthCommand(); }
860 std::string
CheckSynthCommand::getCommandName() const { return "check-synth"; }
862 void CheckSynthCommand::toStream(std::ostream
& out
,
866 OutputLanguage language
) const
868 Printer::getPrinter(language
)->toStreamCmdCheckSynth(out
);
871 /* -------------------------------------------------------------------------- */
872 /* class ResetCommand */
873 /* -------------------------------------------------------------------------- */
875 void ResetCommand::invoke(api::Solver
* solver
)
879 solver
->getSmtEngine()->reset();
880 d_commandStatus
= CommandSuccess::instance();
884 d_commandStatus
= new CommandFailure(e
.what());
888 Command
* ResetCommand::clone() const { return new ResetCommand(); }
889 std::string
ResetCommand::getCommandName() const { return "reset"; }
891 void ResetCommand::toStream(std::ostream
& out
,
895 OutputLanguage language
) const
897 Printer::getPrinter(language
)->toStreamCmdReset(out
);
900 /* -------------------------------------------------------------------------- */
901 /* class ResetAssertionsCommand */
902 /* -------------------------------------------------------------------------- */
904 void ResetAssertionsCommand::invoke(api::Solver
* solver
)
908 solver
->resetAssertions();
909 d_commandStatus
= CommandSuccess::instance();
913 d_commandStatus
= new CommandFailure(e
.what());
917 Command
* ResetAssertionsCommand::clone() const
919 return new ResetAssertionsCommand();
922 std::string
ResetAssertionsCommand::getCommandName() const
924 return "reset-assertions";
927 void ResetAssertionsCommand::toStream(std::ostream
& out
,
931 OutputLanguage language
) const
933 Printer::getPrinter(language
)->toStreamCmdResetAssertions(out
);
936 /* -------------------------------------------------------------------------- */
937 /* class QuitCommand */
938 /* -------------------------------------------------------------------------- */
940 void QuitCommand::invoke(api::Solver
* solver
)
942 Dump("benchmark") << *this;
943 d_commandStatus
= CommandSuccess::instance();
946 Command
* QuitCommand::clone() const { return new QuitCommand(); }
947 std::string
QuitCommand::getCommandName() const { return "exit"; }
949 void QuitCommand::toStream(std::ostream
& out
,
953 OutputLanguage language
) const
955 Printer::getPrinter(language
)->toStreamCmdQuit(out
);
958 /* -------------------------------------------------------------------------- */
959 /* class CommentCommand */
960 /* -------------------------------------------------------------------------- */
962 CommentCommand::CommentCommand(std::string comment
) : d_comment(comment
) {}
963 std::string
CommentCommand::getComment() const { return d_comment
; }
964 void CommentCommand::invoke(api::Solver
* solver
)
966 Dump("benchmark") << *this;
967 d_commandStatus
= CommandSuccess::instance();
970 Command
* CommentCommand::clone() const { return new CommentCommand(d_comment
); }
971 std::string
CommentCommand::getCommandName() const { return "comment"; }
973 void CommentCommand::toStream(std::ostream
& out
,
977 OutputLanguage language
) const
979 Printer::getPrinter(language
)->toStreamCmdComment(out
, d_comment
);
982 /* -------------------------------------------------------------------------- */
983 /* class CommandSequence */
984 /* -------------------------------------------------------------------------- */
986 CommandSequence::CommandSequence() : d_index(0) {}
987 CommandSequence::~CommandSequence()
989 for (unsigned i
= d_index
; i
< d_commandSequence
.size(); ++i
)
991 delete d_commandSequence
[i
];
995 void CommandSequence::addCommand(Command
* cmd
)
997 d_commandSequence
.push_back(cmd
);
1000 void CommandSequence::clear() { d_commandSequence
.clear(); }
1001 void CommandSequence::invoke(api::Solver
* solver
)
1003 for (; d_index
< d_commandSequence
.size(); ++d_index
)
1005 d_commandSequence
[d_index
]->invoke(solver
);
1006 if (!d_commandSequence
[d_index
]->ok())
1009 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
1012 delete d_commandSequence
[d_index
];
1015 AlwaysAssert(d_commandStatus
== NULL
);
1016 d_commandStatus
= CommandSuccess::instance();
1019 void CommandSequence::invoke(api::Solver
* solver
, std::ostream
& out
)
1021 for (; d_index
< d_commandSequence
.size(); ++d_index
)
1023 d_commandSequence
[d_index
]->invoke(solver
, out
);
1024 if (!d_commandSequence
[d_index
]->ok())
1027 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
1030 delete d_commandSequence
[d_index
];
1033 AlwaysAssert(d_commandStatus
== NULL
);
1034 d_commandStatus
= CommandSuccess::instance();
1037 Command
* CommandSequence::clone() const
1039 CommandSequence
* seq
= new CommandSequence();
1040 for (const_iterator i
= begin(); i
!= end(); ++i
)
1042 seq
->addCommand((*i
)->clone());
1044 seq
->d_index
= d_index
;
1048 CommandSequence::const_iterator
CommandSequence::begin() const
1050 return d_commandSequence
.begin();
1053 CommandSequence::const_iterator
CommandSequence::end() const
1055 return d_commandSequence
.end();
1058 CommandSequence::iterator
CommandSequence::begin()
1060 return d_commandSequence
.begin();
1063 CommandSequence::iterator
CommandSequence::end()
1065 return d_commandSequence
.end();
1068 std::string
CommandSequence::getCommandName() const { return "sequence"; }
1070 void CommandSequence::toStream(std::ostream
& out
,
1074 OutputLanguage language
) const
1076 Printer::getPrinter(language
)->toStreamCmdCommandSequence(out
,
1080 /* -------------------------------------------------------------------------- */
1081 /* class DeclarationSequence */
1082 /* -------------------------------------------------------------------------- */
1084 void DeclarationSequence::toStream(std::ostream
& out
,
1088 OutputLanguage language
) const
1090 Printer::getPrinter(language
)->toStreamCmdDeclarationSequence(
1091 out
, d_commandSequence
);
1094 /* -------------------------------------------------------------------------- */
1095 /* class DeclarationDefinitionCommand */
1096 /* -------------------------------------------------------------------------- */
1098 DeclarationDefinitionCommand::DeclarationDefinitionCommand(
1099 const std::string
& id
)
1104 std::string
DeclarationDefinitionCommand::getSymbol() const { return d_symbol
; }
1106 /* -------------------------------------------------------------------------- */
1107 /* class DeclareFunctionCommand */
1108 /* -------------------------------------------------------------------------- */
1110 DeclareFunctionCommand::DeclareFunctionCommand(const std::string
& id
,
1113 : DeclarationDefinitionCommand(id
),
1116 d_printInModel(true),
1117 d_printInModelSetByUser(false)
1121 api::Term
DeclareFunctionCommand::getFunction() const { return d_func
; }
1122 api::Sort
DeclareFunctionCommand::getSort() const { return d_sort
; }
1123 bool DeclareFunctionCommand::getPrintInModel() const { return d_printInModel
; }
1124 bool DeclareFunctionCommand::getPrintInModelSetByUser() const
1126 return d_printInModelSetByUser
;
1129 void DeclareFunctionCommand::setPrintInModel(bool p
)
1132 d_printInModelSetByUser
= true;
1135 void DeclareFunctionCommand::invoke(api::Solver
* solver
)
1137 d_commandStatus
= CommandSuccess::instance();
1140 Command
* DeclareFunctionCommand::clone() const
1142 DeclareFunctionCommand
* dfc
=
1143 new DeclareFunctionCommand(d_symbol
, d_func
, d_sort
);
1144 dfc
->d_printInModel
= d_printInModel
;
1145 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
1149 std::string
DeclareFunctionCommand::getCommandName() const
1151 return "declare-fun";
1154 void DeclareFunctionCommand::toStream(std::ostream
& out
,
1158 OutputLanguage language
) const
1160 Printer::getPrinter(language
)->toStreamCmdDeclareFunction(
1161 out
, d_func
.toString(), TypeNode::fromType(d_sort
.getType()));
1164 /* -------------------------------------------------------------------------- */
1165 /* class DeclareSortCommand */
1166 /* -------------------------------------------------------------------------- */
1168 DeclareSortCommand::DeclareSortCommand(const std::string
& id
,
1171 : DeclarationDefinitionCommand(id
), d_arity(arity
), d_sort(sort
)
1175 size_t DeclareSortCommand::getArity() const { return d_arity
; }
1176 api::Sort
DeclareSortCommand::getSort() const { return d_sort
; }
1177 void DeclareSortCommand::invoke(api::Solver
* solver
)
1179 d_commandStatus
= CommandSuccess::instance();
1182 Command
* DeclareSortCommand::clone() const
1184 return new DeclareSortCommand(d_symbol
, d_arity
, d_sort
);
1187 std::string
DeclareSortCommand::getCommandName() const
1189 return "declare-sort";
1192 void DeclareSortCommand::toStream(std::ostream
& out
,
1196 OutputLanguage language
) const
1198 Printer::getPrinter(language
)->toStreamCmdDeclareType(
1199 out
, d_sort
.toString(), d_arity
, TypeNode::fromType(d_sort
.getType()));
1202 /* -------------------------------------------------------------------------- */
1203 /* class DefineSortCommand */
1204 /* -------------------------------------------------------------------------- */
1206 DefineSortCommand::DefineSortCommand(const std::string
& id
, api::Sort sort
)
1207 : DeclarationDefinitionCommand(id
), d_params(), d_sort(sort
)
1211 DefineSortCommand::DefineSortCommand(const std::string
& id
,
1212 const std::vector
<api::Sort
>& params
,
1214 : DeclarationDefinitionCommand(id
), d_params(params
), d_sort(sort
)
1218 const std::vector
<api::Sort
>& DefineSortCommand::getParameters() const
1223 api::Sort
DefineSortCommand::getSort() const { return d_sort
; }
1224 void DefineSortCommand::invoke(api::Solver
* solver
)
1226 d_commandStatus
= CommandSuccess::instance();
1229 Command
* DefineSortCommand::clone() const
1231 return new DefineSortCommand(d_symbol
, d_params
, d_sort
);
1234 std::string
DefineSortCommand::getCommandName() const { return "define-sort"; }
1236 void DefineSortCommand::toStream(std::ostream
& out
,
1240 OutputLanguage language
) const
1242 Printer::getPrinter(language
)->toStreamCmdDefineType(
1245 api::sortVectorToTypeNodes(d_params
),
1246 TypeNode::fromType(d_sort
.getType()));
1249 /* -------------------------------------------------------------------------- */
1250 /* class DefineFunctionCommand */
1251 /* -------------------------------------------------------------------------- */
1253 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1257 : DeclarationDefinitionCommand(id
),
1265 DefineFunctionCommand::DefineFunctionCommand(
1266 const std::string
& id
,
1268 const std::vector
<api::Term
>& formals
,
1271 : DeclarationDefinitionCommand(id
),
1279 api::Term
DefineFunctionCommand::getFunction() const { return d_func
; }
1280 const std::vector
<api::Term
>& DefineFunctionCommand::getFormals() const
1285 api::Term
DefineFunctionCommand::getFormula() const { return d_formula
; }
1286 void DefineFunctionCommand::invoke(api::Solver
* solver
)
1290 if (!d_func
.isNull())
1292 solver
->defineFun(d_func
, d_formals
, d_formula
, d_global
);
1294 d_commandStatus
= CommandSuccess::instance();
1296 catch (exception
& e
)
1298 d_commandStatus
= new CommandFailure(e
.what());
1302 Command
* DefineFunctionCommand::clone() const
1304 return new DefineFunctionCommand(
1305 d_symbol
, d_func
, d_formals
, d_formula
, d_global
);
1308 std::string
DefineFunctionCommand::getCommandName() const
1310 return "define-fun";
1313 void DefineFunctionCommand::toStream(std::ostream
& out
,
1317 OutputLanguage language
) const
1319 Printer::getPrinter(language
)->toStreamCmdDefineFunction(
1322 api::termVectorToNodes(d_formals
),
1323 d_func
.getNode().getType().getRangeType(),
1324 d_formula
.getNode());
1327 /* -------------------------------------------------------------------------- */
1328 /* class DefineNamedFunctionCommand */
1329 /* -------------------------------------------------------------------------- */
1331 DefineNamedFunctionCommand::DefineNamedFunctionCommand(
1333 const std::string
& id
,
1335 const std::vector
<api::Term
>& formals
,
1338 : DefineFunctionCommand(id
, func
, formals
, formula
, global
)
1342 void DefineNamedFunctionCommand::invoke(api::Solver
* solver
)
1344 this->DefineFunctionCommand::invoke(solver
);
1345 if (!d_func
.isNull() && d_func
.getSort().isBoolean())
1347 solver
->getSmtEngine()->addToAssignment(d_func
.getExpr());
1349 d_commandStatus
= CommandSuccess::instance();
1352 Command
* DefineNamedFunctionCommand::clone() const
1354 return new DefineNamedFunctionCommand(
1355 d_symbol
, d_func
, d_formals
, d_formula
, d_global
);
1358 void DefineNamedFunctionCommand::toStream(std::ostream
& out
,
1362 OutputLanguage language
) const
1364 Printer::getPrinter(language
)->toStreamCmdDefineNamedFunction(
1367 api::termVectorToNodes(d_formals
),
1368 TypeNode::fromType(d_func
.getSort().getFunctionCodomainSort().getType()),
1369 d_formula
.getNode());
1372 /* -------------------------------------------------------------------------- */
1373 /* class DefineFunctionRecCommand */
1374 /* -------------------------------------------------------------------------- */
1376 DefineFunctionRecCommand::DefineFunctionRecCommand(
1379 const std::vector
<api::Term
>& formals
,
1384 d_funcs
.push_back(func
);
1385 d_formals
.push_back(formals
);
1386 d_formulas
.push_back(formula
);
1389 DefineFunctionRecCommand::DefineFunctionRecCommand(
1391 const std::vector
<api::Term
>& funcs
,
1392 const std::vector
<std::vector
<api::Term
>>& formals
,
1393 const std::vector
<api::Term
>& formulas
,
1395 : d_funcs(funcs
), d_formals(formals
), d_formulas(formulas
), d_global(global
)
1399 const std::vector
<api::Term
>& DefineFunctionRecCommand::getFunctions() const
1404 const std::vector
<std::vector
<api::Term
>>&
1405 DefineFunctionRecCommand::getFormals() const
1410 const std::vector
<api::Term
>& DefineFunctionRecCommand::getFormulas() const
1415 void DefineFunctionRecCommand::invoke(api::Solver
* solver
)
1419 solver
->defineFunsRec(d_funcs
, d_formals
, d_formulas
, d_global
);
1420 d_commandStatus
= CommandSuccess::instance();
1422 catch (exception
& e
)
1424 d_commandStatus
= new CommandFailure(e
.what());
1428 Command
* DefineFunctionRecCommand::clone() const
1430 return new DefineFunctionRecCommand(d_funcs
, d_formals
, d_formulas
, d_global
);
1433 std::string
DefineFunctionRecCommand::getCommandName() const
1435 return "define-fun-rec";
1438 void DefineFunctionRecCommand::toStream(std::ostream
& out
,
1442 OutputLanguage language
) const
1444 std::vector
<std::vector
<Node
>> formals
;
1445 formals
.reserve(d_formals
.size());
1446 for (const std::vector
<api::Term
>& formal
: d_formals
)
1448 formals
.push_back(api::termVectorToNodes(formal
));
1451 Printer::getPrinter(language
)->toStreamCmdDefineFunctionRec(
1453 api::termVectorToNodes(d_funcs
),
1455 api::termVectorToNodes(d_formulas
));
1458 /* -------------------------------------------------------------------------- */
1459 /* class SetUserAttribute */
1460 /* -------------------------------------------------------------------------- */
1462 SetUserAttributeCommand::SetUserAttributeCommand(
1463 const std::string
& attr
,
1465 const std::vector
<api::Term
>& termValues
,
1466 const std::string
& strValue
)
1467 : d_attr(attr
), d_term(term
), d_termValues(termValues
), d_strValue(strValue
)
1471 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1473 : SetUserAttributeCommand(attr
, term
, {}, "")
1477 SetUserAttributeCommand::SetUserAttributeCommand(
1478 const std::string
& attr
,
1480 const std::vector
<api::Term
>& values
)
1481 : SetUserAttributeCommand(attr
, term
, values
, "")
1485 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1487 const std::string
& value
)
1488 : SetUserAttributeCommand(attr
, term
, {}, value
)
1492 void SetUserAttributeCommand::invoke(api::Solver
* solver
)
1496 if (!d_term
.isNull())
1498 solver
->getSmtEngine()->setUserAttribute(
1501 api::termVectorToExprs(d_termValues
),
1504 d_commandStatus
= CommandSuccess::instance();
1506 catch (exception
& e
)
1508 d_commandStatus
= new CommandFailure(e
.what());
1512 Command
* SetUserAttributeCommand::clone() const
1514 return new SetUserAttributeCommand(d_attr
, d_term
, d_termValues
, d_strValue
);
1517 std::string
SetUserAttributeCommand::getCommandName() const
1519 return "set-user-attribute";
1522 void SetUserAttributeCommand::toStream(std::ostream
& out
,
1526 OutputLanguage language
) const
1528 Printer::getPrinter(language
)->toStreamCmdSetUserAttribute(
1529 out
, d_attr
, d_term
.getNode());
1532 /* -------------------------------------------------------------------------- */
1533 /* class SimplifyCommand */
1534 /* -------------------------------------------------------------------------- */
1536 SimplifyCommand::SimplifyCommand(api::Term term
) : d_term(term
) {}
1537 api::Term
SimplifyCommand::getTerm() const { return d_term
; }
1538 void SimplifyCommand::invoke(api::Solver
* solver
)
1542 d_result
= solver
->simplify(d_term
);
1543 d_commandStatus
= CommandSuccess::instance();
1545 catch (UnsafeInterruptException
& e
)
1547 d_commandStatus
= new CommandInterrupted();
1549 catch (exception
& e
)
1551 d_commandStatus
= new CommandFailure(e
.what());
1555 api::Term
SimplifyCommand::getResult() const { return d_result
; }
1556 void SimplifyCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1560 this->Command::printResult(out
, verbosity
);
1564 out
<< d_result
<< endl
;
1568 Command
* SimplifyCommand::clone() const
1570 SimplifyCommand
* c
= new SimplifyCommand(d_term
);
1571 c
->d_result
= d_result
;
1575 std::string
SimplifyCommand::getCommandName() const { return "simplify"; }
1577 void SimplifyCommand::toStream(std::ostream
& out
,
1581 OutputLanguage language
) const
1583 Printer::getPrinter(language
)->toStreamCmdSimplify(out
, d_term
.getNode());
1586 /* -------------------------------------------------------------------------- */
1587 /* class ExpandDefinitionsCommand */
1588 /* -------------------------------------------------------------------------- */
1590 ExpandDefinitionsCommand::ExpandDefinitionsCommand(api::Term term
)
1594 api::Term
ExpandDefinitionsCommand::getTerm() const { return d_term
; }
1595 void ExpandDefinitionsCommand::invoke(api::Solver
* solver
)
1597 Node t
= d_term
.getNode();
1598 d_result
= api::Term(solver
, solver
->getSmtEngine()->expandDefinitions(t
));
1599 d_commandStatus
= CommandSuccess::instance();
1602 api::Term
ExpandDefinitionsCommand::getResult() const { return d_result
; }
1603 void ExpandDefinitionsCommand::printResult(std::ostream
& out
,
1604 uint32_t verbosity
) const
1608 this->Command::printResult(out
, verbosity
);
1612 out
<< d_result
<< endl
;
1616 Command
* ExpandDefinitionsCommand::clone() const
1618 ExpandDefinitionsCommand
* c
= new ExpandDefinitionsCommand(d_term
);
1619 c
->d_result
= d_result
;
1623 std::string
ExpandDefinitionsCommand::getCommandName() const
1625 return "expand-definitions";
1628 void ExpandDefinitionsCommand::toStream(std::ostream
& out
,
1632 OutputLanguage language
) const
1634 Printer::getPrinter(language
)->toStreamCmdExpandDefinitions(out
,
1638 /* -------------------------------------------------------------------------- */
1639 /* class GetValueCommand */
1640 /* -------------------------------------------------------------------------- */
1642 GetValueCommand::GetValueCommand(api::Term term
) : d_terms()
1644 d_terms
.push_back(term
);
1647 GetValueCommand::GetValueCommand(const std::vector
<api::Term
>& terms
)
1650 PrettyCheckArgument(
1651 terms
.size() >= 1, terms
, "cannot get-value of an empty set of terms");
1654 const std::vector
<api::Term
>& GetValueCommand::getTerms() const
1658 void GetValueCommand::invoke(api::Solver
* solver
)
1662 NodeManager
* nm
= solver
->getNodeManager();
1663 smt::SmtScope
scope(solver
->getSmtEngine());
1664 std::vector
<Node
> result
;
1665 for (const Expr
& e
:
1666 solver
->getSmtEngine()->getValues(api::termVectorToExprs(d_terms
)))
1668 result
.push_back(Node::fromExpr(e
));
1670 Assert(result
.size() == d_terms
.size());
1671 for (int i
= 0, size
= d_terms
.size(); i
< size
; i
++)
1673 api::Term t
= d_terms
[i
];
1674 Node tNode
= t
.getNode();
1675 Node request
= options::expandDefinitions()
1676 ? solver
->getSmtEngine()->expandDefinitions(tNode
)
1678 Node value
= result
[i
];
1679 if (value
.getType().isInteger() && request
.getType() == nm
->realType())
1681 // Need to wrap in division-by-one so that output printers know this
1682 // is an integer-looking constant that really should be output as
1683 // a rational. Necessary for SMT-LIB standards compliance.
1684 value
= nm
->mkNode(kind::DIVISION
, value
, nm
->mkConst(Rational(1)));
1686 result
[i
] = nm
->mkNode(kind::SEXPR
, request
, value
);
1688 d_result
= api::Term(solver
, nm
->mkNode(kind::SEXPR
, result
));
1689 d_commandStatus
= CommandSuccess::instance();
1691 catch (RecoverableModalException
& e
)
1693 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1695 catch (UnsafeInterruptException
& e
)
1697 d_commandStatus
= new CommandInterrupted();
1699 catch (exception
& e
)
1701 d_commandStatus
= new CommandFailure(e
.what());
1705 api::Term
GetValueCommand::getResult() const { return d_result
; }
1706 void GetValueCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1710 this->Command::printResult(out
, verbosity
);
1714 expr::ExprDag::Scope
scope(out
, false);
1715 out
<< d_result
<< endl
;
1719 Command
* GetValueCommand::clone() const
1721 GetValueCommand
* c
= new GetValueCommand(d_terms
);
1722 c
->d_result
= d_result
;
1726 std::string
GetValueCommand::getCommandName() const { return "get-value"; }
1728 void GetValueCommand::toStream(std::ostream
& out
,
1732 OutputLanguage language
) const
1734 Printer::getPrinter(language
)->toStreamCmdGetValue(
1735 out
, api::termVectorToNodes(d_terms
));
1738 /* -------------------------------------------------------------------------- */
1739 /* class GetAssignmentCommand */
1740 /* -------------------------------------------------------------------------- */
1742 GetAssignmentCommand::GetAssignmentCommand() {}
1743 void GetAssignmentCommand::invoke(api::Solver
* solver
)
1747 std::vector
<std::pair
<Expr
, Expr
>> assignments
=
1748 solver
->getSmtEngine()->getAssignment();
1749 vector
<SExpr
> sexprs
;
1750 for (const auto& p
: assignments
)
1753 v
.emplace_back(SExpr::Keyword(p
.first
.toString()));
1754 v
.emplace_back(SExpr::Keyword(p
.second
.toString()));
1755 sexprs
.emplace_back(v
);
1757 d_result
= SExpr(sexprs
);
1758 d_commandStatus
= CommandSuccess::instance();
1760 catch (RecoverableModalException
& e
)
1762 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1764 catch (UnsafeInterruptException
& e
)
1766 d_commandStatus
= new CommandInterrupted();
1768 catch (exception
& e
)
1770 d_commandStatus
= new CommandFailure(e
.what());
1774 SExpr
GetAssignmentCommand::getResult() const { return d_result
; }
1775 void GetAssignmentCommand::printResult(std::ostream
& out
,
1776 uint32_t verbosity
) const
1780 this->Command::printResult(out
, verbosity
);
1784 out
<< d_result
<< endl
;
1788 Command
* GetAssignmentCommand::clone() const
1790 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1791 c
->d_result
= d_result
;
1795 std::string
GetAssignmentCommand::getCommandName() const
1797 return "get-assignment";
1800 void GetAssignmentCommand::toStream(std::ostream
& out
,
1804 OutputLanguage language
) const
1806 Printer::getPrinter(language
)->toStreamCmdGetAssignment(out
);
1809 /* -------------------------------------------------------------------------- */
1810 /* class GetModelCommand */
1811 /* -------------------------------------------------------------------------- */
1813 GetModelCommand::GetModelCommand() : d_result(nullptr), d_smtEngine(nullptr) {}
1814 void GetModelCommand::invoke(api::Solver
* solver
)
1818 d_result
= solver
->getSmtEngine()->getModel();
1819 d_smtEngine
= solver
->getSmtEngine();
1820 d_commandStatus
= CommandSuccess::instance();
1822 catch (RecoverableModalException
& e
)
1824 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1826 catch (UnsafeInterruptException
& e
)
1828 d_commandStatus
= new CommandInterrupted();
1830 catch (exception
& e
)
1832 d_commandStatus
= new CommandFailure(e
.what());
1836 /* Model is private to the library -- for now
1837 Model* GetModelCommand::getResult() const {
1842 void GetModelCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1846 this->Command::printResult(out
, verbosity
);
1854 Command
* GetModelCommand::clone() const
1856 GetModelCommand
* c
= new GetModelCommand();
1857 c
->d_result
= d_result
;
1858 c
->d_smtEngine
= d_smtEngine
;
1862 std::string
GetModelCommand::getCommandName() const { return "get-model"; }
1864 void GetModelCommand::toStream(std::ostream
& out
,
1868 OutputLanguage language
) const
1870 Printer::getPrinter(language
)->toStreamCmdGetModel(out
);
1873 /* -------------------------------------------------------------------------- */
1874 /* class BlockModelCommand */
1875 /* -------------------------------------------------------------------------- */
1877 BlockModelCommand::BlockModelCommand() {}
1878 void BlockModelCommand::invoke(api::Solver
* solver
)
1882 solver
->getSmtEngine()->blockModel();
1883 d_commandStatus
= CommandSuccess::instance();
1885 catch (RecoverableModalException
& e
)
1887 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1889 catch (UnsafeInterruptException
& e
)
1891 d_commandStatus
= new CommandInterrupted();
1893 catch (exception
& e
)
1895 d_commandStatus
= new CommandFailure(e
.what());
1899 Command
* BlockModelCommand::clone() const
1901 BlockModelCommand
* c
= new BlockModelCommand();
1905 std::string
BlockModelCommand::getCommandName() const { return "block-model"; }
1907 void BlockModelCommand::toStream(std::ostream
& out
,
1911 OutputLanguage language
) const
1913 Printer::getPrinter(language
)->toStreamCmdBlockModel(out
);
1916 /* -------------------------------------------------------------------------- */
1917 /* class BlockModelValuesCommand */
1918 /* -------------------------------------------------------------------------- */
1920 BlockModelValuesCommand::BlockModelValuesCommand(
1921 const std::vector
<api::Term
>& terms
)
1924 PrettyCheckArgument(terms
.size() >= 1,
1926 "cannot block-model-values of an empty set of terms");
1929 const std::vector
<api::Term
>& BlockModelValuesCommand::getTerms() const
1933 void BlockModelValuesCommand::invoke(api::Solver
* solver
)
1937 solver
->getSmtEngine()->blockModelValues(api::termVectorToExprs(d_terms
));
1938 d_commandStatus
= CommandSuccess::instance();
1940 catch (RecoverableModalException
& e
)
1942 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1944 catch (UnsafeInterruptException
& e
)
1946 d_commandStatus
= new CommandInterrupted();
1948 catch (exception
& e
)
1950 d_commandStatus
= new CommandFailure(e
.what());
1954 Command
* BlockModelValuesCommand::clone() const
1956 BlockModelValuesCommand
* c
= new BlockModelValuesCommand(d_terms
);
1960 std::string
BlockModelValuesCommand::getCommandName() const
1962 return "block-model-values";
1965 void BlockModelValuesCommand::toStream(std::ostream
& out
,
1969 OutputLanguage language
) const
1971 Printer::getPrinter(language
)->toStreamCmdBlockModelValues(
1972 out
, api::termVectorToNodes(d_terms
));
1975 /* -------------------------------------------------------------------------- */
1976 /* class GetProofCommand */
1977 /* -------------------------------------------------------------------------- */
1979 GetProofCommand::GetProofCommand() {}
1980 void GetProofCommand::invoke(api::Solver
* solver
)
1982 Unimplemented() << "Unimplemented get-proof\n";
1985 Command
* GetProofCommand::clone() const
1987 GetProofCommand
* c
= new GetProofCommand();
1991 std::string
GetProofCommand::getCommandName() const { return "get-proof"; }
1993 void GetProofCommand::toStream(std::ostream
& out
,
1997 OutputLanguage language
) const
1999 Printer::getPrinter(language
)->toStreamCmdGetProof(out
);
2002 /* -------------------------------------------------------------------------- */
2003 /* class GetInstantiationsCommand */
2004 /* -------------------------------------------------------------------------- */
2006 GetInstantiationsCommand::GetInstantiationsCommand() : d_smtEngine(nullptr) {}
2007 void GetInstantiationsCommand::invoke(api::Solver
* solver
)
2011 d_smtEngine
= solver
->getSmtEngine();
2012 d_commandStatus
= CommandSuccess::instance();
2014 catch (exception
& e
)
2016 d_commandStatus
= new CommandFailure(e
.what());
2020 void GetInstantiationsCommand::printResult(std::ostream
& out
,
2021 uint32_t verbosity
) const
2025 this->Command::printResult(out
, verbosity
);
2029 d_smtEngine
->printInstantiations(out
);
2033 Command
* GetInstantiationsCommand::clone() const
2035 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
2036 // c->d_result = d_result;
2037 c
->d_smtEngine
= d_smtEngine
;
2041 std::string
GetInstantiationsCommand::getCommandName() const
2043 return "get-instantiations";
2046 void GetInstantiationsCommand::toStream(std::ostream
& out
,
2050 OutputLanguage language
) const
2052 Printer::getPrinter(language
)->toStreamCmdGetInstantiations(out
);
2055 /* -------------------------------------------------------------------------- */
2056 /* class GetSynthSolutionCommand */
2057 /* -------------------------------------------------------------------------- */
2059 GetSynthSolutionCommand::GetSynthSolutionCommand() : d_smtEngine(nullptr) {}
2060 void GetSynthSolutionCommand::invoke(api::Solver
* solver
)
2064 d_smtEngine
= solver
->getSmtEngine();
2065 d_commandStatus
= CommandSuccess::instance();
2067 catch (exception
& e
)
2069 d_commandStatus
= new CommandFailure(e
.what());
2073 void GetSynthSolutionCommand::printResult(std::ostream
& out
,
2074 uint32_t verbosity
) const
2078 this->Command::printResult(out
, verbosity
);
2082 d_smtEngine
->printSynthSolution(out
);
2086 Command
* GetSynthSolutionCommand::clone() const
2088 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
2089 c
->d_smtEngine
= d_smtEngine
;
2093 std::string
GetSynthSolutionCommand::getCommandName() const
2095 return "get-synth-solution";
2098 void GetSynthSolutionCommand::toStream(std::ostream
& out
,
2102 OutputLanguage language
) const
2104 Printer::getPrinter(language
)->toStreamCmdGetSynthSolution(out
);
2107 /* -------------------------------------------------------------------------- */
2108 /* class GetInterpolCommand */
2109 /* -------------------------------------------------------------------------- */
2111 GetInterpolCommand::GetInterpolCommand(const std::string
& name
, api::Term conj
)
2112 : d_name(name
), d_conj(conj
), d_resultStatus(false)
2115 GetInterpolCommand::GetInterpolCommand(const std::string
& name
,
2118 : d_name(name
), d_conj(conj
), d_sygus_grammar(g
), d_resultStatus(false)
2122 api::Term
GetInterpolCommand::getConjecture() const { return d_conj
; }
2124 const api::Grammar
* GetInterpolCommand::getGrammar() const
2126 return d_sygus_grammar
;
2129 api::Term
GetInterpolCommand::getResult() const { return d_result
; }
2131 void GetInterpolCommand::invoke(api::Solver
* solver
)
2135 if (d_sygus_grammar
== nullptr)
2137 d_resultStatus
= solver
->getInterpolant(d_conj
, d_result
);
2142 solver
->getInterpolant(d_conj
, *d_sygus_grammar
, d_result
);
2144 d_commandStatus
= CommandSuccess::instance();
2146 catch (exception
& e
)
2148 d_commandStatus
= new CommandFailure(e
.what());
2152 void GetInterpolCommand::printResult(std::ostream
& out
,
2153 uint32_t verbosity
) const
2157 this->Command::printResult(out
, verbosity
);
2161 expr::ExprDag::Scope
scope(out
, false);
2164 out
<< "(define-fun " << d_name
<< " () Bool " << d_result
<< ")"
2169 out
<< "none" << std::endl
;
2174 Command
* GetInterpolCommand::clone() const
2176 GetInterpolCommand
* c
=
2177 new GetInterpolCommand(d_name
, d_conj
, d_sygus_grammar
);
2178 c
->d_result
= d_result
;
2179 c
->d_resultStatus
= d_resultStatus
;
2183 std::string
GetInterpolCommand::getCommandName() const
2185 return "get-interpol";
2188 void GetInterpolCommand::toStream(std::ostream
& out
,
2192 OutputLanguage language
) const
2194 Printer::getPrinter(language
)->toStreamCmdGetInterpol(
2198 TypeNode::fromType(d_sygus_grammar
->resolve().getType()));
2201 /* -------------------------------------------------------------------------- */
2202 /* class GetAbductCommand */
2203 /* -------------------------------------------------------------------------- */
2205 GetAbductCommand::GetAbductCommand(const std::string
& name
, api::Term conj
)
2206 : d_name(name
), d_conj(conj
), d_resultStatus(false)
2209 GetAbductCommand::GetAbductCommand(const std::string
& name
,
2212 : d_name(name
), d_conj(conj
), d_sygus_grammar(g
), d_resultStatus(false)
2216 api::Term
GetAbductCommand::getConjecture() const { return d_conj
; }
2218 const api::Grammar
* GetAbductCommand::getGrammar() const
2220 return d_sygus_grammar
;
2223 std::string
GetAbductCommand::getAbductName() const { return d_name
; }
2224 api::Term
GetAbductCommand::getResult() const { return d_result
; }
2226 void GetAbductCommand::invoke(api::Solver
* solver
)
2230 if (d_sygus_grammar
== nullptr)
2232 d_resultStatus
= solver
->getAbduct(d_conj
, d_result
);
2236 d_resultStatus
= solver
->getAbduct(d_conj
, *d_sygus_grammar
, d_result
);
2238 d_commandStatus
= CommandSuccess::instance();
2240 catch (exception
& e
)
2242 d_commandStatus
= new CommandFailure(e
.what());
2246 void GetAbductCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2250 this->Command::printResult(out
, verbosity
);
2254 expr::ExprDag::Scope
scope(out
, false);
2257 out
<< "(define-fun " << d_name
<< " () Bool " << d_result
<< ")"
2262 out
<< "none" << std::endl
;
2267 Command
* GetAbductCommand::clone() const
2269 GetAbductCommand
* c
= new GetAbductCommand(d_name
, d_conj
, d_sygus_grammar
);
2270 c
->d_result
= d_result
;
2271 c
->d_resultStatus
= d_resultStatus
;
2275 std::string
GetAbductCommand::getCommandName() const { return "get-abduct"; }
2277 void GetAbductCommand::toStream(std::ostream
& out
,
2281 OutputLanguage language
) const
2283 Printer::getPrinter(language
)->toStreamCmdGetAbduct(
2287 TypeNode::fromType(d_sygus_grammar
->resolve().getType()));
2290 /* -------------------------------------------------------------------------- */
2291 /* class GetQuantifierEliminationCommand */
2292 /* -------------------------------------------------------------------------- */
2294 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand()
2295 : d_term(), d_doFull(true)
2298 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand(
2299 const api::Term
& term
, bool doFull
)
2300 : d_term(term
), d_doFull(doFull
)
2304 api::Term
GetQuantifierEliminationCommand::getTerm() const { return d_term
; }
2305 bool GetQuantifierEliminationCommand::getDoFull() const { return d_doFull
; }
2306 void GetQuantifierEliminationCommand::invoke(api::Solver
* solver
)
2310 d_result
= api::Term(solver
,
2311 solver
->getSmtEngine()->getQuantifierElimination(
2312 d_term
.getNode(), d_doFull
));
2313 d_commandStatus
= CommandSuccess::instance();
2315 catch (exception
& e
)
2317 d_commandStatus
= new CommandFailure(e
.what());
2321 api::Term
GetQuantifierEliminationCommand::getResult() const
2325 void GetQuantifierEliminationCommand::printResult(std::ostream
& out
,
2326 uint32_t verbosity
) const
2330 this->Command::printResult(out
, verbosity
);
2334 out
<< d_result
<< endl
;
2338 Command
* GetQuantifierEliminationCommand::clone() const
2340 GetQuantifierEliminationCommand
* c
=
2341 new GetQuantifierEliminationCommand(d_term
, d_doFull
);
2342 c
->d_result
= d_result
;
2346 std::string
GetQuantifierEliminationCommand::getCommandName() const
2348 return d_doFull
? "get-qe" : "get-qe-disjunct";
2351 void GetQuantifierEliminationCommand::toStream(std::ostream
& out
,
2355 OutputLanguage language
) const
2357 Printer::getPrinter(language
)->toStreamCmdGetQuantifierElimination(
2358 out
, d_term
.getNode());
2361 /* -------------------------------------------------------------------------- */
2362 /* class GetUnsatAssumptionsCommand */
2363 /* -------------------------------------------------------------------------- */
2365 GetUnsatAssumptionsCommand::GetUnsatAssumptionsCommand() {}
2367 void GetUnsatAssumptionsCommand::invoke(api::Solver
* solver
)
2371 d_result
= solver
->getUnsatAssumptions();
2372 d_commandStatus
= CommandSuccess::instance();
2374 catch (RecoverableModalException
& e
)
2376 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2378 catch (exception
& e
)
2380 d_commandStatus
= new CommandFailure(e
.what());
2384 std::vector
<api::Term
> GetUnsatAssumptionsCommand::getResult() const
2389 void GetUnsatAssumptionsCommand::printResult(std::ostream
& out
,
2390 uint32_t verbosity
) const
2394 this->Command::printResult(out
, verbosity
);
2398 container_to_stream(out
, d_result
, "(", ")\n", " ");
2402 Command
* GetUnsatAssumptionsCommand::clone() const
2404 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
2405 c
->d_result
= d_result
;
2409 std::string
GetUnsatAssumptionsCommand::getCommandName() const
2411 return "get-unsat-assumptions";
2414 void GetUnsatAssumptionsCommand::toStream(std::ostream
& out
,
2418 OutputLanguage language
) const
2420 Printer::getPrinter(language
)->toStreamCmdGetUnsatAssumptions(out
);
2423 /* -------------------------------------------------------------------------- */
2424 /* class GetUnsatCoreCommand */
2425 /* -------------------------------------------------------------------------- */
2427 GetUnsatCoreCommand::GetUnsatCoreCommand() {}
2428 void GetUnsatCoreCommand::invoke(api::Solver
* solver
)
2432 d_result
= solver
->getSmtEngine()->getUnsatCore();
2433 d_commandStatus
= CommandSuccess::instance();
2435 catch (RecoverableModalException
& e
)
2437 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2439 catch (exception
& e
)
2441 d_commandStatus
= new CommandFailure(e
.what());
2445 void GetUnsatCoreCommand::printResult(std::ostream
& out
,
2446 uint32_t verbosity
) const
2450 this->Command::printResult(out
, verbosity
);
2454 d_result
.toStream(out
);
2458 const UnsatCore
& GetUnsatCoreCommand::getUnsatCore() const
2460 // of course, this will be empty if the command hasn't been invoked yet
2464 Command
* GetUnsatCoreCommand::clone() const
2466 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
2467 c
->d_result
= d_result
;
2471 std::string
GetUnsatCoreCommand::getCommandName() const
2473 return "get-unsat-core";
2476 void GetUnsatCoreCommand::toStream(std::ostream
& out
,
2480 OutputLanguage language
) const
2482 Printer::getPrinter(language
)->toStreamCmdGetUnsatCore(out
);
2485 /* -------------------------------------------------------------------------- */
2486 /* class GetAssertionsCommand */
2487 /* -------------------------------------------------------------------------- */
2489 GetAssertionsCommand::GetAssertionsCommand() {}
2490 void GetAssertionsCommand::invoke(api::Solver
* solver
)
2495 const vector
<api::Term
> v
= solver
->getAssertions();
2497 copy(v
.begin(), v
.end(), ostream_iterator
<api::Term
>(ss
, "\n"));
2499 d_result
= ss
.str();
2500 d_commandStatus
= CommandSuccess::instance();
2502 catch (exception
& e
)
2504 d_commandStatus
= new CommandFailure(e
.what());
2508 std::string
GetAssertionsCommand::getResult() const { return d_result
; }
2509 void GetAssertionsCommand::printResult(std::ostream
& out
,
2510 uint32_t verbosity
) const
2514 this->Command::printResult(out
, verbosity
);
2522 Command
* GetAssertionsCommand::clone() const
2524 GetAssertionsCommand
* c
= new GetAssertionsCommand();
2525 c
->d_result
= d_result
;
2529 std::string
GetAssertionsCommand::getCommandName() const
2531 return "get-assertions";
2534 void GetAssertionsCommand::toStream(std::ostream
& out
,
2538 OutputLanguage language
) const
2540 Printer::getPrinter(language
)->toStreamCmdGetAssertions(out
);
2543 /* -------------------------------------------------------------------------- */
2544 /* class SetBenchmarkStatusCommand */
2545 /* -------------------------------------------------------------------------- */
2547 SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status
)
2552 BenchmarkStatus
SetBenchmarkStatusCommand::getStatus() const
2557 void SetBenchmarkStatusCommand::invoke(api::Solver
* solver
)
2563 solver
->setInfo("status", ss
.str());
2564 d_commandStatus
= CommandSuccess::instance();
2566 catch (exception
& e
)
2568 d_commandStatus
= new CommandFailure(e
.what());
2572 Command
* SetBenchmarkStatusCommand::clone() const
2574 return new SetBenchmarkStatusCommand(d_status
);
2577 std::string
SetBenchmarkStatusCommand::getCommandName() const
2582 void SetBenchmarkStatusCommand::toStream(std::ostream
& out
,
2586 OutputLanguage language
) const
2588 Result::Sat status
= Result::SAT_UNKNOWN
;
2591 case BenchmarkStatus::SMT_SATISFIABLE
: status
= Result::SAT
; break;
2592 case BenchmarkStatus::SMT_UNSATISFIABLE
: status
= Result::UNSAT
; break;
2593 case BenchmarkStatus::SMT_UNKNOWN
: status
= Result::SAT_UNKNOWN
; break;
2596 Printer::getPrinter(language
)->toStreamCmdSetBenchmarkStatus(out
, status
);
2599 /* -------------------------------------------------------------------------- */
2600 /* class SetBenchmarkLogicCommand */
2601 /* -------------------------------------------------------------------------- */
2603 SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic
)
2608 std::string
SetBenchmarkLogicCommand::getLogic() const { return d_logic
; }
2609 void SetBenchmarkLogicCommand::invoke(api::Solver
* solver
)
2613 solver
->setLogic(d_logic
);
2614 d_commandStatus
= CommandSuccess::instance();
2616 catch (exception
& e
)
2618 d_commandStatus
= new CommandFailure(e
.what());
2622 Command
* SetBenchmarkLogicCommand::clone() const
2624 return new SetBenchmarkLogicCommand(d_logic
);
2627 std::string
SetBenchmarkLogicCommand::getCommandName() const
2632 void SetBenchmarkLogicCommand::toStream(std::ostream
& out
,
2636 OutputLanguage language
) const
2638 Printer::getPrinter(language
)->toStreamCmdSetBenchmarkLogic(out
, d_logic
);
2641 /* -------------------------------------------------------------------------- */
2642 /* class SetInfoCommand */
2643 /* -------------------------------------------------------------------------- */
2645 SetInfoCommand::SetInfoCommand(std::string flag
, const SExpr
& sexpr
)
2646 : d_flag(flag
), d_sexpr(sexpr
)
2650 std::string
SetInfoCommand::getFlag() const { return d_flag
; }
2651 SExpr
SetInfoCommand::getSExpr() const { return d_sexpr
; }
2652 void SetInfoCommand::invoke(api::Solver
* solver
)
2656 solver
->getSmtEngine()->setInfo(d_flag
, d_sexpr
);
2657 d_commandStatus
= CommandSuccess::instance();
2659 catch (UnrecognizedOptionException
&)
2661 // As per SMT-LIB spec, silently accept unknown set-info keys
2662 d_commandStatus
= CommandSuccess::instance();
2664 catch (exception
& e
)
2666 d_commandStatus
= new CommandFailure(e
.what());
2670 Command
* SetInfoCommand::clone() const
2672 return new SetInfoCommand(d_flag
, d_sexpr
);
2675 std::string
SetInfoCommand::getCommandName() const { return "set-info"; }
2677 void SetInfoCommand::toStream(std::ostream
& out
,
2681 OutputLanguage language
) const
2683 Printer::getPrinter(language
)->toStreamCmdSetInfo(out
, d_flag
, d_sexpr
);
2686 /* -------------------------------------------------------------------------- */
2687 /* class GetInfoCommand */
2688 /* -------------------------------------------------------------------------- */
2690 GetInfoCommand::GetInfoCommand(std::string flag
) : d_flag(flag
) {}
2691 std::string
GetInfoCommand::getFlag() const { return d_flag
; }
2692 void GetInfoCommand::invoke(api::Solver
* solver
)
2697 v
.push_back(SExpr(SExpr::Keyword(string(":") + d_flag
)));
2698 v
.emplace_back(solver
->getSmtEngine()->getInfo(d_flag
));
2700 if (d_flag
== "all-options" || d_flag
== "all-statistics")
2702 ss
<< PrettySExprs(true);
2705 d_result
= ss
.str();
2706 d_commandStatus
= CommandSuccess::instance();
2708 catch (UnrecognizedOptionException
&)
2710 d_commandStatus
= new CommandUnsupported();
2712 catch (RecoverableModalException
& e
)
2714 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2716 catch (exception
& e
)
2718 d_commandStatus
= new CommandFailure(e
.what());
2722 std::string
GetInfoCommand::getResult() const { return d_result
; }
2723 void GetInfoCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2727 this->Command::printResult(out
, verbosity
);
2729 else if (d_result
!= "")
2731 out
<< d_result
<< endl
;
2735 Command
* GetInfoCommand::clone() const
2737 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2738 c
->d_result
= d_result
;
2742 std::string
GetInfoCommand::getCommandName() const { return "get-info"; }
2744 void GetInfoCommand::toStream(std::ostream
& out
,
2748 OutputLanguage language
) const
2750 Printer::getPrinter(language
)->toStreamCmdGetInfo(out
, d_flag
);
2753 /* -------------------------------------------------------------------------- */
2754 /* class SetOptionCommand */
2755 /* -------------------------------------------------------------------------- */
2757 SetOptionCommand::SetOptionCommand(std::string flag
, const SExpr
& sexpr
)
2758 : d_flag(flag
), d_sexpr(sexpr
)
2762 std::string
SetOptionCommand::getFlag() const { return d_flag
; }
2763 SExpr
SetOptionCommand::getSExpr() const { return d_sexpr
; }
2764 void SetOptionCommand::invoke(api::Solver
* solver
)
2768 solver
->getSmtEngine()->setOption(d_flag
, d_sexpr
);
2769 d_commandStatus
= CommandSuccess::instance();
2771 catch (UnrecognizedOptionException
&)
2773 d_commandStatus
= new CommandUnsupported();
2775 catch (exception
& e
)
2777 d_commandStatus
= new CommandFailure(e
.what());
2781 Command
* SetOptionCommand::clone() const
2783 return new SetOptionCommand(d_flag
, d_sexpr
);
2786 std::string
SetOptionCommand::getCommandName() const { return "set-option"; }
2788 void SetOptionCommand::toStream(std::ostream
& out
,
2792 OutputLanguage language
) const
2794 Printer::getPrinter(language
)->toStreamCmdSetOption(out
, d_flag
, d_sexpr
);
2797 /* -------------------------------------------------------------------------- */
2798 /* class GetOptionCommand */
2799 /* -------------------------------------------------------------------------- */
2801 GetOptionCommand::GetOptionCommand(std::string flag
) : d_flag(flag
) {}
2802 std::string
GetOptionCommand::getFlag() const { return d_flag
; }
2803 void GetOptionCommand::invoke(api::Solver
* solver
)
2807 d_result
= solver
->getOption(d_flag
);
2808 d_commandStatus
= CommandSuccess::instance();
2810 catch (UnrecognizedOptionException
&)
2812 d_commandStatus
= new CommandUnsupported();
2814 catch (exception
& e
)
2816 d_commandStatus
= new CommandFailure(e
.what());
2820 std::string
GetOptionCommand::getResult() const { return d_result
; }
2821 void GetOptionCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2825 this->Command::printResult(out
, verbosity
);
2827 else if (d_result
!= "")
2829 out
<< d_result
<< endl
;
2833 Command
* GetOptionCommand::clone() const
2835 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2836 c
->d_result
= d_result
;
2840 std::string
GetOptionCommand::getCommandName() const { return "get-option"; }
2842 void GetOptionCommand::toStream(std::ostream
& out
,
2846 OutputLanguage language
) const
2848 Printer::getPrinter(language
)->toStreamCmdGetOption(out
, d_flag
);
2851 /* -------------------------------------------------------------------------- */
2852 /* class SetExpressionNameCommand */
2853 /* -------------------------------------------------------------------------- */
2855 SetExpressionNameCommand::SetExpressionNameCommand(api::Term term
,
2857 : d_term(term
), d_name(name
)
2861 void SetExpressionNameCommand::invoke(api::Solver
* solver
)
2863 solver
->getSmtEngine()->setExpressionName(d_term
.getExpr(), d_name
);
2864 d_commandStatus
= CommandSuccess::instance();
2867 Command
* SetExpressionNameCommand::clone() const
2869 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(d_term
, d_name
);
2873 std::string
SetExpressionNameCommand::getCommandName() const
2875 return "set-expr-name";
2878 void SetExpressionNameCommand::toStream(std::ostream
& out
,
2882 OutputLanguage language
) const
2884 Printer::getPrinter(language
)->toStreamCmdSetExpressionName(
2885 out
, d_term
.getNode(), d_name
);
2888 /* -------------------------------------------------------------------------- */
2889 /* class DatatypeDeclarationCommand */
2890 /* -------------------------------------------------------------------------- */
2892 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2893 const api::Sort
& datatype
)
2896 d_datatypes
.push_back(datatype
);
2899 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2900 const std::vector
<api::Sort
>& datatypes
)
2901 : d_datatypes(datatypes
)
2905 const std::vector
<api::Sort
>& DatatypeDeclarationCommand::getDatatypes() const
2910 void DatatypeDeclarationCommand::invoke(api::Solver
* solver
)
2912 d_commandStatus
= CommandSuccess::instance();
2915 Command
* DatatypeDeclarationCommand::clone() const
2917 return new DatatypeDeclarationCommand(d_datatypes
);
2920 std::string
DatatypeDeclarationCommand::getCommandName() const
2922 return "declare-datatypes";
2925 void DatatypeDeclarationCommand::toStream(std::ostream
& out
,
2929 OutputLanguage language
) const
2931 Printer::getPrinter(language
)->toStreamCmdDatatypeDeclaration(
2932 out
, api::sortVectorToTypeNodes(d_datatypes
));