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/symbol_manager.h"
32 #include "expr/type.h"
33 #include "options/options.h"
34 #include "options/smt_options.h"
35 #include "printer/printer.h"
36 #include "proof/unsat_core.h"
38 #include "smt/model.h"
39 #include "smt/smt_engine.h"
40 #include "smt/smt_engine_scope.h"
41 #include "util/sexpr.h"
42 #include "util/utility.h"
48 const int CommandPrintSuccess::s_iosIndex
= std::ios_base::xalloc();
49 const CommandSuccess
* CommandSuccess::s_instance
= new CommandSuccess();
50 const CommandInterrupted
* CommandInterrupted::s_instance
=
51 new CommandInterrupted();
53 std::ostream
& operator<<(std::ostream
& out
, const Command
& c
)
56 Node::setdepth::getDepth(out
),
57 Node::dag::getDag(out
),
58 Node::setlanguage::getLanguage(out
));
62 ostream
& operator<<(ostream
& out
, const Command
* c
)
75 std::ostream
& operator<<(std::ostream
& out
, const CommandStatus
& s
)
77 s
.toStream(out
, Node::setlanguage::getLanguage(out
));
81 ostream
& operator<<(ostream
& out
, const CommandStatus
* s
)
94 /* output stream insertion operator for benchmark statuses */
95 std::ostream
& operator<<(std::ostream
& out
, BenchmarkStatus status
)
99 case SMT_SATISFIABLE
: return out
<< "sat";
101 case SMT_UNSATISFIABLE
: return out
<< "unsat";
103 case SMT_UNKNOWN
: return out
<< "unknown";
105 default: return out
<< "BenchmarkStatus::[UNKNOWNSTATUS!]";
109 /* -------------------------------------------------------------------------- */
110 /* class CommandPrintSuccess */
111 /* -------------------------------------------------------------------------- */
113 void CommandPrintSuccess::applyPrintSuccess(std::ostream
& out
)
115 out
.iword(s_iosIndex
) = d_printSuccess
;
118 bool CommandPrintSuccess::getPrintSuccess(std::ostream
& out
)
120 return out
.iword(s_iosIndex
);
123 void CommandPrintSuccess::setPrintSuccess(std::ostream
& out
, bool printSuccess
)
125 out
.iword(s_iosIndex
) = printSuccess
;
128 std::ostream
& operator<<(std::ostream
& out
, CommandPrintSuccess cps
)
130 cps
.applyPrintSuccess(out
);
134 /* -------------------------------------------------------------------------- */
136 /* -------------------------------------------------------------------------- */
138 Command::Command() : d_commandStatus(nullptr), d_muted(false) {}
140 Command::Command(const api::Solver
* solver
)
141 : d_commandStatus(nullptr), d_muted(false)
145 Command::Command(const Command
& cmd
)
148 (cmd
.d_commandStatus
== NULL
) ? NULL
: &cmd
.d_commandStatus
->clone();
149 d_muted
= cmd
.d_muted
;
154 if (d_commandStatus
!= NULL
&& d_commandStatus
!= CommandSuccess::instance())
156 delete d_commandStatus
;
160 bool Command::ok() const
162 // either we haven't run the command yet, or it ran successfully
163 return d_commandStatus
== NULL
164 || dynamic_cast<const CommandSuccess
*>(d_commandStatus
) != NULL
;
167 bool Command::fail() const
169 return d_commandStatus
!= NULL
170 && dynamic_cast<const CommandFailure
*>(d_commandStatus
) != NULL
;
173 bool Command::interrupted() const
175 return d_commandStatus
!= NULL
176 && dynamic_cast<const CommandInterrupted
*>(d_commandStatus
) != NULL
;
179 void Command::invoke(api::Solver
* solver
, SymbolManager
* sm
, std::ostream
& out
)
182 if (!(isMuted() && ok()))
186 std::stoul(solver
->getOption("command-verbosity:" + getCommandName())));
190 std::string
Command::toString() const
192 std::stringstream ss
;
197 void CommandStatus::toStream(std::ostream
& out
, OutputLanguage language
) const
199 Printer::getPrinter(language
)->toStream(out
, this);
202 void Command::printResult(std::ostream
& out
, uint32_t verbosity
) const
204 if (d_commandStatus
!= NULL
)
206 if ((!ok() && verbosity
>= 1) || verbosity
>= 2)
208 out
<< *d_commandStatus
;
213 /* -------------------------------------------------------------------------- */
214 /* class EmptyCommand */
215 /* -------------------------------------------------------------------------- */
217 EmptyCommand::EmptyCommand(std::string name
) : d_name(name
) {}
218 std::string
EmptyCommand::getName() const { return d_name
; }
219 void EmptyCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
221 /* empty commands have no implementation */
222 d_commandStatus
= CommandSuccess::instance();
225 Command
* EmptyCommand::clone() const { return new EmptyCommand(d_name
); }
226 std::string
EmptyCommand::getCommandName() const { return "empty"; }
228 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
, SymbolManager
* sm
)
244 /* we don't have an output stream here, nothing to do */
245 d_commandStatus
= CommandSuccess::instance();
248 void EchoCommand::invoke(api::Solver
* solver
,
252 out
<< d_output
<< std::endl
;
253 Trace("dtview::command") << "* ~COMMAND: echo |" << d_output
<< "|~"
255 d_commandStatus
= CommandSuccess::instance();
258 std::stoul(solver
->getOption("command-verbosity:" + getCommandName())));
261 Command
* EchoCommand::clone() const { return new EchoCommand(d_output
); }
262 std::string
EchoCommand::getCommandName() const { return "echo"; }
264 void EchoCommand::toStream(std::ostream
& out
,
267 OutputLanguage language
) const
269 Printer::getPrinter(language
)->toStreamCmdEcho(out
, d_output
);
272 /* -------------------------------------------------------------------------- */
273 /* class AssertCommand */
274 /* -------------------------------------------------------------------------- */
276 AssertCommand::AssertCommand(const api::Term
& t
, bool inUnsatCore
)
277 : d_term(t
), d_inUnsatCore(inUnsatCore
)
281 api::Term
AssertCommand::getTerm() const { return d_term
; }
282 void AssertCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
286 solver
->getSmtEngine()->assertFormula(d_term
.getNode(), d_inUnsatCore
);
287 d_commandStatus
= CommandSuccess::instance();
289 catch (UnsafeInterruptException
& e
)
291 d_commandStatus
= new CommandInterrupted();
295 d_commandStatus
= new CommandFailure(e
.what());
299 Command
* AssertCommand::clone() const
301 return new AssertCommand(d_term
, d_inUnsatCore
);
304 std::string
AssertCommand::getCommandName() const { return "assert"; }
306 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
, SymbolManager
* sm
)
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
,
341 OutputLanguage language
) const
343 Printer::getPrinter(language
)->toStreamCmdPush(out
);
346 /* -------------------------------------------------------------------------- */
347 /* class PopCommand */
348 /* -------------------------------------------------------------------------- */
350 void PopCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
355 d_commandStatus
= CommandSuccess::instance();
357 catch (UnsafeInterruptException
& e
)
359 d_commandStatus
= new CommandInterrupted();
363 d_commandStatus
= new CommandFailure(e
.what());
367 Command
* PopCommand::clone() const { return new PopCommand(); }
368 std::string
PopCommand::getCommandName() const { return "pop"; }
370 void PopCommand::toStream(std::ostream
& out
,
373 OutputLanguage language
) const
375 Printer::getPrinter(language
)->toStreamCmdPop(out
);
378 /* -------------------------------------------------------------------------- */
379 /* class CheckSatCommand */
380 /* -------------------------------------------------------------------------- */
382 CheckSatCommand::CheckSatCommand() : d_term() {}
384 CheckSatCommand::CheckSatCommand(const api::Term
& term
) : d_term(term
) {}
386 api::Term
CheckSatCommand::getTerm() const { return d_term
; }
387 void CheckSatCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
389 Trace("dtview::command") << "* ~COMMAND: " << getCommandName() << "~"
394 d_term
.isNull() ? solver
->checkSat() : solver
->checkSatAssuming(d_term
);
396 d_commandStatus
= CommandSuccess::instance();
400 d_commandStatus
= new CommandFailure(e
.what());
404 api::Result
CheckSatCommand::getResult() const { return d_result
; }
405 void CheckSatCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
409 this->Command::printResult(out
, verbosity
);
413 Trace("dtview::command") << "* RESULT: " << d_result
<< std::endl
;
414 out
<< d_result
<< endl
;
418 Command
* CheckSatCommand::clone() const
420 CheckSatCommand
* c
= new CheckSatCommand(d_term
);
421 c
->d_result
= d_result
;
425 std::string
CheckSatCommand::getCommandName() const { return "check-sat"; }
427 void CheckSatCommand::toStream(std::ostream
& out
,
430 OutputLanguage language
) const
432 Printer::getPrinter(language
)->toStreamCmdCheckSat(out
, d_term
.getNode());
435 /* -------------------------------------------------------------------------- */
436 /* class CheckSatAssumingCommand */
437 /* -------------------------------------------------------------------------- */
439 CheckSatAssumingCommand::CheckSatAssumingCommand(api::Term term
)
444 CheckSatAssumingCommand::CheckSatAssumingCommand(
445 const std::vector
<api::Term
>& terms
)
450 const std::vector
<api::Term
>& CheckSatAssumingCommand::getTerms() const
455 void CheckSatAssumingCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
457 Trace("dtview::command") << "* ~COMMAND: (check-sat-assuming ( " << d_terms
458 << " )~" << std::endl
;
461 d_result
= solver
->checkSatAssuming(d_terms
);
462 d_commandStatus
= CommandSuccess::instance();
466 d_commandStatus
= new CommandFailure(e
.what());
470 api::Result
CheckSatAssumingCommand::getResult() const
472 Trace("dtview::command") << "* ~RESULT: " << d_result
<< "~" << std::endl
;
476 void CheckSatAssumingCommand::printResult(std::ostream
& out
,
477 uint32_t verbosity
) const
481 this->Command::printResult(out
, verbosity
);
485 out
<< d_result
<< endl
;
489 Command
* CheckSatAssumingCommand::clone() const
491 CheckSatAssumingCommand
* c
= new CheckSatAssumingCommand(d_terms
);
492 c
->d_result
= d_result
;
496 std::string
CheckSatAssumingCommand::getCommandName() const
498 return "check-sat-assuming";
501 void CheckSatAssumingCommand::toStream(std::ostream
& out
,
504 OutputLanguage language
) const
506 Printer::getPrinter(language
)->toStreamCmdCheckSatAssuming(
507 out
, api::termVectorToNodes(d_terms
));
510 /* -------------------------------------------------------------------------- */
511 /* class QueryCommand */
512 /* -------------------------------------------------------------------------- */
514 QueryCommand::QueryCommand(const api::Term
& t
, bool inUnsatCore
)
515 : d_term(t
), d_inUnsatCore(inUnsatCore
)
519 api::Term
QueryCommand::getTerm() const { return d_term
; }
520 void QueryCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
524 d_result
= solver
->checkEntailed(d_term
);
525 d_commandStatus
= CommandSuccess::instance();
529 d_commandStatus
= new CommandFailure(e
.what());
533 api::Result
QueryCommand::getResult() const { return d_result
; }
534 void QueryCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
538 this->Command::printResult(out
, verbosity
);
542 out
<< d_result
<< endl
;
546 Command
* QueryCommand::clone() const
548 QueryCommand
* c
= new QueryCommand(d_term
, d_inUnsatCore
);
549 c
->d_result
= d_result
;
553 std::string
QueryCommand::getCommandName() const { return "query"; }
555 void QueryCommand::toStream(std::ostream
& out
,
558 OutputLanguage language
) const
560 Printer::getPrinter(language
)->toStreamCmdQuery(out
, d_term
.getNode());
563 /* -------------------------------------------------------------------------- */
564 /* class DeclareSygusVarCommand */
565 /* -------------------------------------------------------------------------- */
567 DeclareSygusVarCommand::DeclareSygusVarCommand(const std::string
& id
,
570 : DeclarationDefinitionCommand(id
), d_var(var
), d_sort(sort
)
574 api::Term
DeclareSygusVarCommand::getVar() const { return d_var
; }
575 api::Sort
DeclareSygusVarCommand::getSort() const { return d_sort
; }
577 void DeclareSygusVarCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
579 d_commandStatus
= CommandSuccess::instance();
582 Command
* DeclareSygusVarCommand::clone() const
584 return new DeclareSygusVarCommand(d_symbol
, d_var
, d_sort
);
587 std::string
DeclareSygusVarCommand::getCommandName() const
589 return "declare-var";
592 void DeclareSygusVarCommand::toStream(std::ostream
& out
,
595 OutputLanguage language
) const
597 Printer::getPrinter(language
)->toStreamCmdDeclareVar(
598 out
, d_var
.getNode(), d_sort
.getTypeNode());
601 /* -------------------------------------------------------------------------- */
602 /* class SynthFunCommand */
603 /* -------------------------------------------------------------------------- */
605 SynthFunCommand::SynthFunCommand(const std::string
& id
,
607 const std::vector
<api::Term
>& vars
,
611 : DeclarationDefinitionCommand(id
),
620 api::Term
SynthFunCommand::getFunction() const { return d_fun
; }
622 const std::vector
<api::Term
>& SynthFunCommand::getVars() const
627 api::Sort
SynthFunCommand::getSort() const { return d_sort
; }
628 bool SynthFunCommand::isInv() const { return d_isInv
; }
630 const api::Grammar
* SynthFunCommand::getGrammar() const { return d_grammar
; }
632 void SynthFunCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
634 d_commandStatus
= CommandSuccess::instance();
637 Command
* SynthFunCommand::clone() const
639 return new SynthFunCommand(
640 d_symbol
, d_fun
, d_vars
, d_sort
, d_isInv
, d_grammar
);
643 std::string
SynthFunCommand::getCommandName() const
645 return d_isInv
? "synth-inv" : "synth-fun";
648 void SynthFunCommand::toStream(std::ostream
& out
,
651 OutputLanguage language
) const
653 std::vector
<Node
> nodeVars
= termVectorToNodes(d_vars
);
654 Printer::getPrinter(language
)->toStreamCmdSynthFun(
658 d_sort
.getTypeNode(),
660 d_grammar
->resolve().getTypeNode());
663 /* -------------------------------------------------------------------------- */
664 /* class SygusConstraintCommand */
665 /* -------------------------------------------------------------------------- */
667 SygusConstraintCommand::SygusConstraintCommand(const api::Term
& t
) : d_term(t
)
671 void SygusConstraintCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
675 solver
->addSygusConstraint(d_term
);
676 d_commandStatus
= CommandSuccess::instance();
680 d_commandStatus
= new CommandFailure(e
.what());
684 api::Term
SygusConstraintCommand::getTerm() const { return d_term
; }
686 Command
* SygusConstraintCommand::clone() const
688 return new SygusConstraintCommand(d_term
);
691 std::string
SygusConstraintCommand::getCommandName() const
696 void SygusConstraintCommand::toStream(std::ostream
& out
,
699 OutputLanguage language
) const
701 Printer::getPrinter(language
)->toStreamCmdConstraint(out
, d_term
.getNode());
704 /* -------------------------------------------------------------------------- */
705 /* class SygusInvConstraintCommand */
706 /* -------------------------------------------------------------------------- */
708 SygusInvConstraintCommand::SygusInvConstraintCommand(
709 const std::vector
<api::Term
>& predicates
)
710 : d_predicates(predicates
)
714 SygusInvConstraintCommand::SygusInvConstraintCommand(const api::Term
& inv
,
715 const api::Term
& pre
,
716 const api::Term
& trans
,
717 const api::Term
& post
)
718 : SygusInvConstraintCommand(std::vector
<api::Term
>{inv
, pre
, trans
, post
})
722 void SygusInvConstraintCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
726 solver
->addSygusInvConstraint(
727 d_predicates
[0], d_predicates
[1], d_predicates
[2], d_predicates
[3]);
728 d_commandStatus
= CommandSuccess::instance();
732 d_commandStatus
= new CommandFailure(e
.what());
736 const std::vector
<api::Term
>& SygusInvConstraintCommand::getPredicates() const
741 Command
* SygusInvConstraintCommand::clone() const
743 return new SygusInvConstraintCommand(d_predicates
);
746 std::string
SygusInvConstraintCommand::getCommandName() const
748 return "inv-constraint";
751 void SygusInvConstraintCommand::toStream(std::ostream
& out
,
754 OutputLanguage language
) const
756 Printer::getPrinter(language
)->toStreamCmdInvConstraint(
758 d_predicates
[0].getNode(),
759 d_predicates
[1].getNode(),
760 d_predicates
[2].getNode(),
761 d_predicates
[3].getNode());
764 /* -------------------------------------------------------------------------- */
765 /* class CheckSynthCommand */
766 /* -------------------------------------------------------------------------- */
768 void CheckSynthCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
772 d_result
= solver
->checkSynth();
773 d_commandStatus
= CommandSuccess::instance();
775 // check whether we should print the status
776 if (!d_result
.isUnsat()
777 || options::sygusOut() == options::SygusSolutionOutMode::STATUS_AND_DEF
778 || options::sygusOut() == options::SygusSolutionOutMode::STATUS
)
780 if (options::sygusOut() == options::SygusSolutionOutMode::STANDARD
)
782 d_solution
<< "(fail)" << endl
;
786 d_solution
<< d_result
<< endl
;
789 // check whether we should print the solution
790 if (d_result
.isUnsat()
791 && options::sygusOut() != options::SygusSolutionOutMode::STATUS
)
793 // printing a synthesis solution is a non-constant
794 // method, since it invokes a sophisticated algorithm
795 // (Figure 5 of Reynolds et al. CAV 2015).
796 // Hence, we must call here print solution here,
797 // instead of during printResult.
798 solver
->printSynthSolution(d_solution
);
803 d_commandStatus
= new CommandFailure(e
.what());
807 api::Result
CheckSynthCommand::getResult() const { return d_result
; }
808 void CheckSynthCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
812 this->Command::printResult(out
, verbosity
);
816 out
<< d_solution
.str();
820 Command
* CheckSynthCommand::clone() const { return new CheckSynthCommand(); }
822 std::string
CheckSynthCommand::getCommandName() const { return "check-synth"; }
824 void CheckSynthCommand::toStream(std::ostream
& out
,
827 OutputLanguage language
) const
829 Printer::getPrinter(language
)->toStreamCmdCheckSynth(out
);
832 /* -------------------------------------------------------------------------- */
833 /* class ResetCommand */
834 /* -------------------------------------------------------------------------- */
836 void ResetCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
840 solver
->getSmtEngine()->reset();
841 d_commandStatus
= CommandSuccess::instance();
845 d_commandStatus
= new CommandFailure(e
.what());
849 Command
* ResetCommand::clone() const { return new ResetCommand(); }
850 std::string
ResetCommand::getCommandName() const { return "reset"; }
852 void ResetCommand::toStream(std::ostream
& out
,
855 OutputLanguage language
) const
857 Printer::getPrinter(language
)->toStreamCmdReset(out
);
860 /* -------------------------------------------------------------------------- */
861 /* class ResetAssertionsCommand */
862 /* -------------------------------------------------------------------------- */
864 void ResetAssertionsCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
868 solver
->resetAssertions();
869 d_commandStatus
= CommandSuccess::instance();
873 d_commandStatus
= new CommandFailure(e
.what());
877 Command
* ResetAssertionsCommand::clone() const
879 return new ResetAssertionsCommand();
882 std::string
ResetAssertionsCommand::getCommandName() const
884 return "reset-assertions";
887 void ResetAssertionsCommand::toStream(std::ostream
& out
,
890 OutputLanguage language
) const
892 Printer::getPrinter(language
)->toStreamCmdResetAssertions(out
);
895 /* -------------------------------------------------------------------------- */
896 /* class QuitCommand */
897 /* -------------------------------------------------------------------------- */
899 void QuitCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
901 Dump("benchmark") << *this;
902 d_commandStatus
= CommandSuccess::instance();
905 Command
* QuitCommand::clone() const { return new QuitCommand(); }
906 std::string
QuitCommand::getCommandName() const { return "exit"; }
908 void QuitCommand::toStream(std::ostream
& out
,
911 OutputLanguage language
) const
913 Printer::getPrinter(language
)->toStreamCmdQuit(out
);
916 /* -------------------------------------------------------------------------- */
917 /* class CommentCommand */
918 /* -------------------------------------------------------------------------- */
920 CommentCommand::CommentCommand(std::string comment
) : d_comment(comment
) {}
921 std::string
CommentCommand::getComment() const { return d_comment
; }
922 void CommentCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
924 Dump("benchmark") << *this;
925 d_commandStatus
= CommandSuccess::instance();
928 Command
* CommentCommand::clone() const { return new CommentCommand(d_comment
); }
929 std::string
CommentCommand::getCommandName() const { return "comment"; }
931 void CommentCommand::toStream(std::ostream
& out
,
934 OutputLanguage language
) const
936 Printer::getPrinter(language
)->toStreamCmdComment(out
, d_comment
);
939 /* -------------------------------------------------------------------------- */
940 /* class CommandSequence */
941 /* -------------------------------------------------------------------------- */
943 CommandSequence::CommandSequence() : d_index(0) {}
944 CommandSequence::~CommandSequence()
946 for (unsigned i
= d_index
; i
< d_commandSequence
.size(); ++i
)
948 delete d_commandSequence
[i
];
952 void CommandSequence::addCommand(Command
* cmd
)
954 d_commandSequence
.push_back(cmd
);
957 void CommandSequence::clear() { d_commandSequence
.clear(); }
958 void CommandSequence::invoke(api::Solver
* solver
, SymbolManager
* sm
)
960 for (; d_index
< d_commandSequence
.size(); ++d_index
)
962 d_commandSequence
[d_index
]->invoke(solver
, sm
);
963 if (!d_commandSequence
[d_index
]->ok())
966 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
969 delete d_commandSequence
[d_index
];
972 AlwaysAssert(d_commandStatus
== NULL
);
973 d_commandStatus
= CommandSuccess::instance();
976 void CommandSequence::invoke(api::Solver
* solver
,
980 for (; d_index
< d_commandSequence
.size(); ++d_index
)
982 d_commandSequence
[d_index
]->invoke(solver
, sm
, out
);
983 if (!d_commandSequence
[d_index
]->ok())
986 d_commandStatus
= d_commandSequence
[d_index
]->getCommandStatus();
989 delete d_commandSequence
[d_index
];
992 AlwaysAssert(d_commandStatus
== NULL
);
993 d_commandStatus
= CommandSuccess::instance();
996 Command
* CommandSequence::clone() const
998 CommandSequence
* seq
= new CommandSequence();
999 for (const_iterator i
= begin(); i
!= end(); ++i
)
1001 seq
->addCommand((*i
)->clone());
1003 seq
->d_index
= d_index
;
1007 CommandSequence::const_iterator
CommandSequence::begin() const
1009 return d_commandSequence
.begin();
1012 CommandSequence::const_iterator
CommandSequence::end() const
1014 return d_commandSequence
.end();
1017 CommandSequence::iterator
CommandSequence::begin()
1019 return d_commandSequence
.begin();
1022 CommandSequence::iterator
CommandSequence::end()
1024 return d_commandSequence
.end();
1027 std::string
CommandSequence::getCommandName() const { return "sequence"; }
1029 void CommandSequence::toStream(std::ostream
& out
,
1032 OutputLanguage language
) const
1034 Printer::getPrinter(language
)->toStreamCmdCommandSequence(out
,
1038 /* -------------------------------------------------------------------------- */
1039 /* class DeclarationSequence */
1040 /* -------------------------------------------------------------------------- */
1042 void DeclarationSequence::toStream(std::ostream
& out
,
1045 OutputLanguage language
) const
1047 Printer::getPrinter(language
)->toStreamCmdDeclarationSequence(
1048 out
, d_commandSequence
);
1051 /* -------------------------------------------------------------------------- */
1052 /* class DeclarationDefinitionCommand */
1053 /* -------------------------------------------------------------------------- */
1055 DeclarationDefinitionCommand::DeclarationDefinitionCommand(
1056 const std::string
& id
)
1061 std::string
DeclarationDefinitionCommand::getSymbol() const { return d_symbol
; }
1063 /* -------------------------------------------------------------------------- */
1064 /* class DeclareFunctionCommand */
1065 /* -------------------------------------------------------------------------- */
1067 DeclareFunctionCommand::DeclareFunctionCommand(const std::string
& id
,
1070 : DeclarationDefinitionCommand(id
),
1073 d_printInModel(true),
1074 d_printInModelSetByUser(false)
1078 api::Term
DeclareFunctionCommand::getFunction() const { return d_func
; }
1079 api::Sort
DeclareFunctionCommand::getSort() const { return d_sort
; }
1080 bool DeclareFunctionCommand::getPrintInModel() const { return d_printInModel
; }
1081 bool DeclareFunctionCommand::getPrintInModelSetByUser() const
1083 return d_printInModelSetByUser
;
1086 void DeclareFunctionCommand::setPrintInModel(bool p
)
1089 d_printInModelSetByUser
= true;
1092 void DeclareFunctionCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1094 d_commandStatus
= CommandSuccess::instance();
1097 Command
* DeclareFunctionCommand::clone() const
1099 DeclareFunctionCommand
* dfc
=
1100 new DeclareFunctionCommand(d_symbol
, d_func
, d_sort
);
1101 dfc
->d_printInModel
= d_printInModel
;
1102 dfc
->d_printInModelSetByUser
= d_printInModelSetByUser
;
1106 std::string
DeclareFunctionCommand::getCommandName() const
1108 return "declare-fun";
1111 void DeclareFunctionCommand::toStream(std::ostream
& out
,
1114 OutputLanguage language
) const
1116 Printer::getPrinter(language
)->toStreamCmdDeclareFunction(
1117 out
, d_func
.toString(), d_sort
.getTypeNode());
1120 /* -------------------------------------------------------------------------- */
1121 /* class DeclareSortCommand */
1122 /* -------------------------------------------------------------------------- */
1124 DeclareSortCommand::DeclareSortCommand(const std::string
& id
,
1127 : DeclarationDefinitionCommand(id
), d_arity(arity
), d_sort(sort
)
1131 size_t DeclareSortCommand::getArity() const { return d_arity
; }
1132 api::Sort
DeclareSortCommand::getSort() const { return d_sort
; }
1133 void DeclareSortCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1135 d_commandStatus
= CommandSuccess::instance();
1138 Command
* DeclareSortCommand::clone() const
1140 return new DeclareSortCommand(d_symbol
, d_arity
, d_sort
);
1143 std::string
DeclareSortCommand::getCommandName() const
1145 return "declare-sort";
1148 void DeclareSortCommand::toStream(std::ostream
& out
,
1151 OutputLanguage language
) const
1153 Printer::getPrinter(language
)->toStreamCmdDeclareType(
1154 out
, d_sort
.toString(), d_arity
, d_sort
.getTypeNode());
1157 /* -------------------------------------------------------------------------- */
1158 /* class DefineSortCommand */
1159 /* -------------------------------------------------------------------------- */
1161 DefineSortCommand::DefineSortCommand(const std::string
& id
, api::Sort sort
)
1162 : DeclarationDefinitionCommand(id
), d_params(), d_sort(sort
)
1166 DefineSortCommand::DefineSortCommand(const std::string
& id
,
1167 const std::vector
<api::Sort
>& params
,
1169 : DeclarationDefinitionCommand(id
), d_params(params
), d_sort(sort
)
1173 const std::vector
<api::Sort
>& DefineSortCommand::getParameters() const
1178 api::Sort
DefineSortCommand::getSort() const { return d_sort
; }
1179 void DefineSortCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1181 d_commandStatus
= CommandSuccess::instance();
1184 Command
* DefineSortCommand::clone() const
1186 return new DefineSortCommand(d_symbol
, d_params
, d_sort
);
1189 std::string
DefineSortCommand::getCommandName() const { return "define-sort"; }
1191 void DefineSortCommand::toStream(std::ostream
& out
,
1194 OutputLanguage language
) const
1196 Printer::getPrinter(language
)->toStreamCmdDefineType(
1199 api::sortVectorToTypeNodes(d_params
),
1200 d_sort
.getTypeNode());
1203 /* -------------------------------------------------------------------------- */
1204 /* class DefineFunctionCommand */
1205 /* -------------------------------------------------------------------------- */
1207 DefineFunctionCommand::DefineFunctionCommand(const std::string
& id
,
1211 : DeclarationDefinitionCommand(id
),
1219 DefineFunctionCommand::DefineFunctionCommand(
1220 const std::string
& id
,
1222 const std::vector
<api::Term
>& formals
,
1225 : DeclarationDefinitionCommand(id
),
1233 api::Term
DefineFunctionCommand::getFunction() const { return d_func
; }
1234 const std::vector
<api::Term
>& DefineFunctionCommand::getFormals() const
1239 api::Term
DefineFunctionCommand::getFormula() const { return d_formula
; }
1240 void DefineFunctionCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1244 if (!d_func
.isNull())
1246 solver
->defineFun(d_func
, d_formals
, d_formula
, d_global
);
1248 d_commandStatus
= CommandSuccess::instance();
1250 catch (exception
& e
)
1252 d_commandStatus
= new CommandFailure(e
.what());
1256 Command
* DefineFunctionCommand::clone() const
1258 return new DefineFunctionCommand(
1259 d_symbol
, d_func
, d_formals
, d_formula
, d_global
);
1262 std::string
DefineFunctionCommand::getCommandName() const
1264 return "define-fun";
1267 void DefineFunctionCommand::toStream(std::ostream
& out
,
1270 OutputLanguage language
) const
1272 Printer::getPrinter(language
)->toStreamCmdDefineFunction(
1275 api::termVectorToNodes(d_formals
),
1276 d_func
.getNode().getType().getRangeType(),
1277 d_formula
.getNode());
1280 /* -------------------------------------------------------------------------- */
1281 /* class DefineFunctionRecCommand */
1282 /* -------------------------------------------------------------------------- */
1284 DefineFunctionRecCommand::DefineFunctionRecCommand(
1287 const std::vector
<api::Term
>& formals
,
1292 d_funcs
.push_back(func
);
1293 d_formals
.push_back(formals
);
1294 d_formulas
.push_back(formula
);
1297 DefineFunctionRecCommand::DefineFunctionRecCommand(
1299 const std::vector
<api::Term
>& funcs
,
1300 const std::vector
<std::vector
<api::Term
>>& formals
,
1301 const std::vector
<api::Term
>& formulas
,
1303 : d_funcs(funcs
), d_formals(formals
), d_formulas(formulas
), d_global(global
)
1307 const std::vector
<api::Term
>& DefineFunctionRecCommand::getFunctions() const
1312 const std::vector
<std::vector
<api::Term
>>&
1313 DefineFunctionRecCommand::getFormals() const
1318 const std::vector
<api::Term
>& DefineFunctionRecCommand::getFormulas() const
1323 void DefineFunctionRecCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1327 solver
->defineFunsRec(d_funcs
, d_formals
, d_formulas
, d_global
);
1328 d_commandStatus
= CommandSuccess::instance();
1330 catch (exception
& e
)
1332 d_commandStatus
= new CommandFailure(e
.what());
1336 Command
* DefineFunctionRecCommand::clone() const
1338 return new DefineFunctionRecCommand(d_funcs
, d_formals
, d_formulas
, d_global
);
1341 std::string
DefineFunctionRecCommand::getCommandName() const
1343 return "define-fun-rec";
1346 void DefineFunctionRecCommand::toStream(std::ostream
& out
,
1349 OutputLanguage language
) const
1351 std::vector
<std::vector
<Node
>> formals
;
1352 formals
.reserve(d_formals
.size());
1353 for (const std::vector
<api::Term
>& formal
: d_formals
)
1355 formals
.push_back(api::termVectorToNodes(formal
));
1358 Printer::getPrinter(language
)->toStreamCmdDefineFunctionRec(
1360 api::termVectorToNodes(d_funcs
),
1362 api::termVectorToNodes(d_formulas
));
1364 /* -------------------------------------------------------------------------- */
1365 /* class DeclareHeapCommand */
1366 /* -------------------------------------------------------------------------- */
1367 DeclareHeapCommand::DeclareHeapCommand(api::Sort locSort
, api::Sort dataSort
)
1368 : d_locSort(locSort
), d_dataSort(dataSort
)
1372 api::Sort
DeclareHeapCommand::getLocationSort() const { return d_locSort
; }
1373 api::Sort
DeclareHeapCommand::getDataSort() const { return d_dataSort
; }
1375 void DeclareHeapCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1377 solver
->declareSeparationHeap(d_locSort
, d_dataSort
);
1380 Command
* DeclareHeapCommand::clone() const
1382 return new DeclareHeapCommand(d_locSort
, d_dataSort
);
1385 std::string
DeclareHeapCommand::getCommandName() const
1387 return "declare-heap";
1390 void DeclareHeapCommand::toStream(std::ostream
& out
,
1393 OutputLanguage language
) const
1395 Printer::getPrinter(language
)->toStreamCmdDeclareHeap(
1396 out
, d_locSort
.getTypeNode(), d_dataSort
.getTypeNode());
1399 /* -------------------------------------------------------------------------- */
1400 /* class SetUserAttributeCommand */
1401 /* -------------------------------------------------------------------------- */
1403 SetUserAttributeCommand::SetUserAttributeCommand(
1404 const std::string
& attr
,
1406 const std::vector
<api::Term
>& termValues
,
1407 const std::string
& strValue
)
1408 : d_attr(attr
), d_term(term
), d_termValues(termValues
), d_strValue(strValue
)
1412 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1414 : SetUserAttributeCommand(attr
, term
, {}, "")
1418 SetUserAttributeCommand::SetUserAttributeCommand(
1419 const std::string
& attr
,
1421 const std::vector
<api::Term
>& values
)
1422 : SetUserAttributeCommand(attr
, term
, values
, "")
1426 SetUserAttributeCommand::SetUserAttributeCommand(const std::string
& attr
,
1428 const std::string
& value
)
1429 : SetUserAttributeCommand(attr
, term
, {}, value
)
1433 void SetUserAttributeCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1437 if (!d_term
.isNull())
1439 solver
->getSmtEngine()->setUserAttribute(
1442 api::termVectorToExprs(d_termValues
),
1445 d_commandStatus
= CommandSuccess::instance();
1447 catch (exception
& e
)
1449 d_commandStatus
= new CommandFailure(e
.what());
1453 Command
* SetUserAttributeCommand::clone() const
1455 return new SetUserAttributeCommand(d_attr
, d_term
, d_termValues
, d_strValue
);
1458 std::string
SetUserAttributeCommand::getCommandName() const
1460 return "set-user-attribute";
1463 void SetUserAttributeCommand::toStream(std::ostream
& out
,
1466 OutputLanguage language
) const
1468 Printer::getPrinter(language
)->toStreamCmdSetUserAttribute(
1469 out
, d_attr
, d_term
.getNode());
1472 /* -------------------------------------------------------------------------- */
1473 /* class SimplifyCommand */
1474 /* -------------------------------------------------------------------------- */
1476 SimplifyCommand::SimplifyCommand(api::Term term
) : d_term(term
) {}
1477 api::Term
SimplifyCommand::getTerm() const { return d_term
; }
1478 void SimplifyCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1482 d_result
= solver
->simplify(d_term
);
1483 d_commandStatus
= CommandSuccess::instance();
1485 catch (UnsafeInterruptException
& e
)
1487 d_commandStatus
= new CommandInterrupted();
1489 catch (exception
& e
)
1491 d_commandStatus
= new CommandFailure(e
.what());
1495 api::Term
SimplifyCommand::getResult() const { return d_result
; }
1496 void SimplifyCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1500 this->Command::printResult(out
, verbosity
);
1504 out
<< d_result
<< endl
;
1508 Command
* SimplifyCommand::clone() const
1510 SimplifyCommand
* c
= new SimplifyCommand(d_term
);
1511 c
->d_result
= d_result
;
1515 std::string
SimplifyCommand::getCommandName() const { return "simplify"; }
1517 void SimplifyCommand::toStream(std::ostream
& out
,
1520 OutputLanguage language
) const
1522 Printer::getPrinter(language
)->toStreamCmdSimplify(out
, d_term
.getNode());
1525 /* -------------------------------------------------------------------------- */
1526 /* class GetValueCommand */
1527 /* -------------------------------------------------------------------------- */
1529 GetValueCommand::GetValueCommand(api::Term term
) : d_terms()
1531 d_terms
.push_back(term
);
1534 GetValueCommand::GetValueCommand(const std::vector
<api::Term
>& terms
)
1537 PrettyCheckArgument(
1538 terms
.size() >= 1, terms
, "cannot get-value of an empty set of terms");
1541 const std::vector
<api::Term
>& GetValueCommand::getTerms() const
1545 void GetValueCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1549 std::vector
<api::Term
> result
= solver
->getValue(d_terms
);
1550 Assert(result
.size() == d_terms
.size());
1551 for (int i
= 0, size
= d_terms
.size(); i
< size
; i
++)
1553 api::Term request
= d_terms
[i
];
1554 api::Term value
= result
[i
];
1555 result
[i
] = solver
->mkTerm(api::SEXPR
, request
, value
);
1557 d_result
= solver
->mkTerm(api::SEXPR
, result
);
1558 d_commandStatus
= CommandSuccess::instance();
1560 catch (api::CVC4ApiRecoverableException
& e
)
1562 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1564 catch (UnsafeInterruptException
& e
)
1566 d_commandStatus
= new CommandInterrupted();
1568 catch (exception
& e
)
1570 d_commandStatus
= new CommandFailure(e
.what());
1574 api::Term
GetValueCommand::getResult() const { return d_result
; }
1575 void GetValueCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1579 this->Command::printResult(out
, verbosity
);
1583 expr::ExprDag::Scope
scope(out
, false);
1584 out
<< d_result
<< endl
;
1588 Command
* GetValueCommand::clone() const
1590 GetValueCommand
* c
= new GetValueCommand(d_terms
);
1591 c
->d_result
= d_result
;
1595 std::string
GetValueCommand::getCommandName() const { return "get-value"; }
1597 void GetValueCommand::toStream(std::ostream
& out
,
1600 OutputLanguage language
) const
1602 Printer::getPrinter(language
)->toStreamCmdGetValue(
1603 out
, api::termVectorToNodes(d_terms
));
1606 /* -------------------------------------------------------------------------- */
1607 /* class GetAssignmentCommand */
1608 /* -------------------------------------------------------------------------- */
1610 GetAssignmentCommand::GetAssignmentCommand() {}
1611 void GetAssignmentCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1615 std::map
<api::Term
, std::string
> enames
= sm
->getExpressionNames();
1616 std::vector
<api::Term
> terms
;
1617 std::vector
<std::string
> names
;
1618 for (const std::pair
<const api::Term
, std::string
>& e
: enames
)
1620 terms
.push_back(e
.first
);
1621 names
.push_back(e
.second
);
1623 // Must use vector version of getValue to ensure error is thrown regardless
1624 // of whether terms is empty.
1625 std::vector
<api::Term
> values
= solver
->getValue(terms
);
1626 Assert(values
.size() == names
.size());
1627 std::vector
<SExpr
> sexprs
;
1628 for (size_t i
= 0, nterms
= terms
.size(); i
< nterms
; i
++)
1630 std::vector
<SExpr
> ss
;
1631 ss
.emplace_back(SExpr::Keyword(names
[i
]));
1632 ss
.emplace_back(SExpr::Keyword(values
[i
].toString()));
1633 sexprs
.emplace_back(ss
);
1635 d_result
= SExpr(sexprs
);
1636 d_commandStatus
= CommandSuccess::instance();
1638 catch (api::CVC4ApiRecoverableException
& e
)
1640 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1642 catch (UnsafeInterruptException
& e
)
1644 d_commandStatus
= new CommandInterrupted();
1646 catch (exception
& e
)
1648 d_commandStatus
= new CommandFailure(e
.what());
1652 SExpr
GetAssignmentCommand::getResult() const { return d_result
; }
1653 void GetAssignmentCommand::printResult(std::ostream
& out
,
1654 uint32_t verbosity
) const
1658 this->Command::printResult(out
, verbosity
);
1662 out
<< d_result
<< endl
;
1666 Command
* GetAssignmentCommand::clone() const
1668 GetAssignmentCommand
* c
= new GetAssignmentCommand();
1669 c
->d_result
= d_result
;
1673 std::string
GetAssignmentCommand::getCommandName() const
1675 return "get-assignment";
1678 void GetAssignmentCommand::toStream(std::ostream
& out
,
1681 OutputLanguage language
) const
1683 Printer::getPrinter(language
)->toStreamCmdGetAssignment(out
);
1686 /* -------------------------------------------------------------------------- */
1687 /* class GetModelCommand */
1688 /* -------------------------------------------------------------------------- */
1690 GetModelCommand::GetModelCommand() : d_result(nullptr) {}
1691 void GetModelCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1695 d_result
= solver
->getSmtEngine()->getModel();
1696 d_commandStatus
= CommandSuccess::instance();
1698 catch (RecoverableModalException
& e
)
1700 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1702 catch (UnsafeInterruptException
& e
)
1704 d_commandStatus
= new CommandInterrupted();
1706 catch (exception
& e
)
1708 d_commandStatus
= new CommandFailure(e
.what());
1712 /* Model is private to the library -- for now
1713 Model* GetModelCommand::getResult() const {
1718 void GetModelCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
1722 this->Command::printResult(out
, verbosity
);
1730 Command
* GetModelCommand::clone() const
1732 GetModelCommand
* c
= new GetModelCommand();
1733 c
->d_result
= d_result
;
1737 std::string
GetModelCommand::getCommandName() const { return "get-model"; }
1739 void GetModelCommand::toStream(std::ostream
& out
,
1742 OutputLanguage language
) const
1744 Printer::getPrinter(language
)->toStreamCmdGetModel(out
);
1747 /* -------------------------------------------------------------------------- */
1748 /* class BlockModelCommand */
1749 /* -------------------------------------------------------------------------- */
1751 BlockModelCommand::BlockModelCommand() {}
1752 void BlockModelCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1756 solver
->blockModel();
1757 d_commandStatus
= CommandSuccess::instance();
1759 catch (api::CVC4ApiRecoverableException
& e
)
1761 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1763 catch (UnsafeInterruptException
& e
)
1765 d_commandStatus
= new CommandInterrupted();
1767 catch (exception
& e
)
1769 d_commandStatus
= new CommandFailure(e
.what());
1773 Command
* BlockModelCommand::clone() const
1775 BlockModelCommand
* c
= new BlockModelCommand();
1779 std::string
BlockModelCommand::getCommandName() const { return "block-model"; }
1781 void BlockModelCommand::toStream(std::ostream
& out
,
1784 OutputLanguage language
) const
1786 Printer::getPrinter(language
)->toStreamCmdBlockModel(out
);
1789 /* -------------------------------------------------------------------------- */
1790 /* class BlockModelValuesCommand */
1791 /* -------------------------------------------------------------------------- */
1793 BlockModelValuesCommand::BlockModelValuesCommand(
1794 const std::vector
<api::Term
>& terms
)
1797 PrettyCheckArgument(terms
.size() >= 1,
1799 "cannot block-model-values of an empty set of terms");
1802 const std::vector
<api::Term
>& BlockModelValuesCommand::getTerms() const
1806 void BlockModelValuesCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1810 solver
->blockModelValues(d_terms
);
1811 d_commandStatus
= CommandSuccess::instance();
1813 catch (RecoverableModalException
& e
)
1815 d_commandStatus
= new CommandRecoverableFailure(e
.what());
1817 catch (UnsafeInterruptException
& e
)
1819 d_commandStatus
= new CommandInterrupted();
1821 catch (exception
& e
)
1823 d_commandStatus
= new CommandFailure(e
.what());
1827 Command
* BlockModelValuesCommand::clone() const
1829 BlockModelValuesCommand
* c
= new BlockModelValuesCommand(d_terms
);
1833 std::string
BlockModelValuesCommand::getCommandName() const
1835 return "block-model-values";
1838 void BlockModelValuesCommand::toStream(std::ostream
& out
,
1841 OutputLanguage language
) const
1843 Printer::getPrinter(language
)->toStreamCmdBlockModelValues(
1844 out
, api::termVectorToNodes(d_terms
));
1847 /* -------------------------------------------------------------------------- */
1848 /* class GetProofCommand */
1849 /* -------------------------------------------------------------------------- */
1851 GetProofCommand::GetProofCommand() {}
1852 void GetProofCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1854 Unimplemented() << "Unimplemented get-proof\n";
1857 Command
* GetProofCommand::clone() const
1859 GetProofCommand
* c
= new GetProofCommand();
1863 std::string
GetProofCommand::getCommandName() const { return "get-proof"; }
1865 void GetProofCommand::toStream(std::ostream
& out
,
1868 OutputLanguage language
) const
1870 Printer::getPrinter(language
)->toStreamCmdGetProof(out
);
1873 /* -------------------------------------------------------------------------- */
1874 /* class GetInstantiationsCommand */
1875 /* -------------------------------------------------------------------------- */
1877 GetInstantiationsCommand::GetInstantiationsCommand() : d_solver(nullptr) {}
1878 void GetInstantiationsCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1883 d_commandStatus
= CommandSuccess::instance();
1885 catch (exception
& e
)
1887 d_commandStatus
= new CommandFailure(e
.what());
1891 void GetInstantiationsCommand::printResult(std::ostream
& out
,
1892 uint32_t verbosity
) const
1896 this->Command::printResult(out
, verbosity
);
1900 d_solver
->printInstantiations(out
);
1904 Command
* GetInstantiationsCommand::clone() const
1906 GetInstantiationsCommand
* c
= new GetInstantiationsCommand();
1907 // c->d_result = d_result;
1908 c
->d_solver
= d_solver
;
1912 std::string
GetInstantiationsCommand::getCommandName() const
1914 return "get-instantiations";
1917 void GetInstantiationsCommand::toStream(std::ostream
& out
,
1920 OutputLanguage language
) const
1922 Printer::getPrinter(language
)->toStreamCmdGetInstantiations(out
);
1925 /* -------------------------------------------------------------------------- */
1926 /* class GetSynthSolutionCommand */
1927 /* -------------------------------------------------------------------------- */
1929 GetSynthSolutionCommand::GetSynthSolutionCommand() : d_solver(nullptr) {}
1930 void GetSynthSolutionCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
1935 d_commandStatus
= CommandSuccess::instance();
1937 catch (exception
& e
)
1939 d_commandStatus
= new CommandFailure(e
.what());
1943 void GetSynthSolutionCommand::printResult(std::ostream
& out
,
1944 uint32_t verbosity
) const
1948 this->Command::printResult(out
, verbosity
);
1952 d_solver
->printSynthSolution(out
);
1956 Command
* GetSynthSolutionCommand::clone() const
1958 GetSynthSolutionCommand
* c
= new GetSynthSolutionCommand();
1959 c
->d_solver
= d_solver
;
1963 std::string
GetSynthSolutionCommand::getCommandName() const
1965 return "get-synth-solution";
1968 void GetSynthSolutionCommand::toStream(std::ostream
& out
,
1971 OutputLanguage language
) const
1973 Printer::getPrinter(language
)->toStreamCmdGetSynthSolution(out
);
1976 /* -------------------------------------------------------------------------- */
1977 /* class GetInterpolCommand */
1978 /* -------------------------------------------------------------------------- */
1980 GetInterpolCommand::GetInterpolCommand(const std::string
& name
, api::Term conj
)
1981 : d_name(name
), d_conj(conj
), d_resultStatus(false)
1984 GetInterpolCommand::GetInterpolCommand(const std::string
& name
,
1987 : d_name(name
), d_conj(conj
), d_sygus_grammar(g
), d_resultStatus(false)
1991 api::Term
GetInterpolCommand::getConjecture() const { return d_conj
; }
1993 const api::Grammar
* GetInterpolCommand::getGrammar() const
1995 return d_sygus_grammar
;
1998 api::Term
GetInterpolCommand::getResult() const { return d_result
; }
2000 void GetInterpolCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2004 if (d_sygus_grammar
== nullptr)
2006 d_resultStatus
= solver
->getInterpolant(d_conj
, d_result
);
2011 solver
->getInterpolant(d_conj
, *d_sygus_grammar
, d_result
);
2013 d_commandStatus
= CommandSuccess::instance();
2015 catch (exception
& e
)
2017 d_commandStatus
= new CommandFailure(e
.what());
2021 void GetInterpolCommand::printResult(std::ostream
& out
,
2022 uint32_t verbosity
) const
2026 this->Command::printResult(out
, verbosity
);
2030 expr::ExprDag::Scope
scope(out
, false);
2033 out
<< "(define-fun " << d_name
<< " () Bool " << d_result
<< ")"
2038 out
<< "none" << std::endl
;
2043 Command
* GetInterpolCommand::clone() const
2045 GetInterpolCommand
* c
=
2046 new GetInterpolCommand(d_name
, d_conj
, d_sygus_grammar
);
2047 c
->d_result
= d_result
;
2048 c
->d_resultStatus
= d_resultStatus
;
2052 std::string
GetInterpolCommand::getCommandName() const
2054 return "get-interpol";
2057 void GetInterpolCommand::toStream(std::ostream
& out
,
2060 OutputLanguage language
) const
2062 Printer::getPrinter(language
)->toStreamCmdGetInterpol(
2063 out
, d_name
, d_conj
.getNode(), d_sygus_grammar
->resolve().getTypeNode());
2066 /* -------------------------------------------------------------------------- */
2067 /* class GetAbductCommand */
2068 /* -------------------------------------------------------------------------- */
2070 GetAbductCommand::GetAbductCommand(const std::string
& name
, api::Term conj
)
2071 : d_name(name
), d_conj(conj
), d_resultStatus(false)
2074 GetAbductCommand::GetAbductCommand(const std::string
& name
,
2077 : d_name(name
), d_conj(conj
), d_sygus_grammar(g
), d_resultStatus(false)
2081 api::Term
GetAbductCommand::getConjecture() const { return d_conj
; }
2083 const api::Grammar
* GetAbductCommand::getGrammar() const
2085 return d_sygus_grammar
;
2088 std::string
GetAbductCommand::getAbductName() const { return d_name
; }
2089 api::Term
GetAbductCommand::getResult() const { return d_result
; }
2091 void GetAbductCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2095 if (d_sygus_grammar
== nullptr)
2097 d_resultStatus
= solver
->getAbduct(d_conj
, d_result
);
2101 d_resultStatus
= solver
->getAbduct(d_conj
, *d_sygus_grammar
, d_result
);
2103 d_commandStatus
= CommandSuccess::instance();
2105 catch (exception
& e
)
2107 d_commandStatus
= new CommandFailure(e
.what());
2111 void GetAbductCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2115 this->Command::printResult(out
, verbosity
);
2119 expr::ExprDag::Scope
scope(out
, false);
2122 out
<< "(define-fun " << d_name
<< " () Bool " << d_result
<< ")"
2127 out
<< "none" << std::endl
;
2132 Command
* GetAbductCommand::clone() const
2134 GetAbductCommand
* c
= new GetAbductCommand(d_name
, d_conj
, d_sygus_grammar
);
2135 c
->d_result
= d_result
;
2136 c
->d_resultStatus
= d_resultStatus
;
2140 std::string
GetAbductCommand::getCommandName() const { return "get-abduct"; }
2142 void GetAbductCommand::toStream(std::ostream
& out
,
2145 OutputLanguage language
) const
2147 Printer::getPrinter(language
)->toStreamCmdGetAbduct(
2148 out
, d_name
, d_conj
.getNode(), d_sygus_grammar
->resolve().getTypeNode());
2151 /* -------------------------------------------------------------------------- */
2152 /* class GetQuantifierEliminationCommand */
2153 /* -------------------------------------------------------------------------- */
2155 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand()
2156 : d_term(), d_doFull(true)
2159 GetQuantifierEliminationCommand::GetQuantifierEliminationCommand(
2160 const api::Term
& term
, bool doFull
)
2161 : d_term(term
), d_doFull(doFull
)
2165 api::Term
GetQuantifierEliminationCommand::getTerm() const { return d_term
; }
2166 bool GetQuantifierEliminationCommand::getDoFull() const { return d_doFull
; }
2167 void GetQuantifierEliminationCommand::invoke(api::Solver
* solver
,
2174 d_result
= solver
->getQuantifierElimination(d_term
);
2178 d_result
= solver
->getQuantifierEliminationDisjunct(d_term
);
2180 d_commandStatus
= CommandSuccess::instance();
2182 catch (exception
& e
)
2184 d_commandStatus
= new CommandFailure(e
.what());
2188 api::Term
GetQuantifierEliminationCommand::getResult() const
2192 void GetQuantifierEliminationCommand::printResult(std::ostream
& out
,
2193 uint32_t verbosity
) const
2197 this->Command::printResult(out
, verbosity
);
2201 out
<< d_result
<< endl
;
2205 Command
* GetQuantifierEliminationCommand::clone() const
2207 GetQuantifierEliminationCommand
* c
=
2208 new GetQuantifierEliminationCommand(d_term
, d_doFull
);
2209 c
->d_result
= d_result
;
2213 std::string
GetQuantifierEliminationCommand::getCommandName() const
2215 return d_doFull
? "get-qe" : "get-qe-disjunct";
2218 void GetQuantifierEliminationCommand::toStream(std::ostream
& out
,
2221 OutputLanguage language
) const
2223 Printer::getPrinter(language
)->toStreamCmdGetQuantifierElimination(
2224 out
, d_term
.getNode());
2227 /* -------------------------------------------------------------------------- */
2228 /* class GetUnsatAssumptionsCommand */
2229 /* -------------------------------------------------------------------------- */
2231 GetUnsatAssumptionsCommand::GetUnsatAssumptionsCommand() {}
2233 void GetUnsatAssumptionsCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2237 d_result
= solver
->getUnsatAssumptions();
2238 d_commandStatus
= CommandSuccess::instance();
2240 catch (api::CVC4ApiRecoverableException
& e
)
2242 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2244 catch (exception
& e
)
2246 d_commandStatus
= new CommandFailure(e
.what());
2250 std::vector
<api::Term
> GetUnsatAssumptionsCommand::getResult() const
2255 void GetUnsatAssumptionsCommand::printResult(std::ostream
& out
,
2256 uint32_t verbosity
) const
2260 this->Command::printResult(out
, verbosity
);
2264 container_to_stream(out
, d_result
, "(", ")\n", " ");
2268 Command
* GetUnsatAssumptionsCommand::clone() const
2270 GetUnsatAssumptionsCommand
* c
= new GetUnsatAssumptionsCommand
;
2271 c
->d_result
= d_result
;
2275 std::string
GetUnsatAssumptionsCommand::getCommandName() const
2277 return "get-unsat-assumptions";
2280 void GetUnsatAssumptionsCommand::toStream(std::ostream
& out
,
2283 OutputLanguage language
) const
2285 Printer::getPrinter(language
)->toStreamCmdGetUnsatAssumptions(out
);
2288 /* -------------------------------------------------------------------------- */
2289 /* class GetUnsatCoreCommand */
2290 /* -------------------------------------------------------------------------- */
2292 GetUnsatCoreCommand::GetUnsatCoreCommand() {}
2293 void GetUnsatCoreCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2298 d_result
= solver
->getUnsatCore();
2300 d_commandStatus
= CommandSuccess::instance();
2302 catch (api::CVC4ApiRecoverableException
& e
)
2304 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2306 catch (exception
& e
)
2308 d_commandStatus
= new CommandFailure(e
.what());
2312 void GetUnsatCoreCommand::printResult(std::ostream
& out
,
2313 uint32_t verbosity
) const
2317 this->Command::printResult(out
, verbosity
);
2321 UnsatCore
ucr(d_solver
->getSmtEngine(), api::termVectorToNodes(d_result
));
2326 const std::vector
<api::Term
>& GetUnsatCoreCommand::getUnsatCore() const
2328 // of course, this will be empty if the command hasn't been invoked yet
2332 Command
* GetUnsatCoreCommand::clone() const
2334 GetUnsatCoreCommand
* c
= new GetUnsatCoreCommand
;
2335 c
->d_solver
= d_solver
;
2336 c
->d_result
= d_result
;
2340 std::string
GetUnsatCoreCommand::getCommandName() const
2342 return "get-unsat-core";
2345 void GetUnsatCoreCommand::toStream(std::ostream
& out
,
2348 OutputLanguage language
) const
2350 Printer::getPrinter(language
)->toStreamCmdGetUnsatCore(out
);
2353 /* -------------------------------------------------------------------------- */
2354 /* class GetAssertionsCommand */
2355 /* -------------------------------------------------------------------------- */
2357 GetAssertionsCommand::GetAssertionsCommand() {}
2358 void GetAssertionsCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2363 const vector
<api::Term
> v
= solver
->getAssertions();
2365 copy(v
.begin(), v
.end(), ostream_iterator
<api::Term
>(ss
, "\n"));
2367 d_result
= ss
.str();
2368 d_commandStatus
= CommandSuccess::instance();
2370 catch (exception
& e
)
2372 d_commandStatus
= new CommandFailure(e
.what());
2376 std::string
GetAssertionsCommand::getResult() const { return d_result
; }
2377 void GetAssertionsCommand::printResult(std::ostream
& out
,
2378 uint32_t verbosity
) const
2382 this->Command::printResult(out
, verbosity
);
2390 Command
* GetAssertionsCommand::clone() const
2392 GetAssertionsCommand
* c
= new GetAssertionsCommand();
2393 c
->d_result
= d_result
;
2397 std::string
GetAssertionsCommand::getCommandName() const
2399 return "get-assertions";
2402 void GetAssertionsCommand::toStream(std::ostream
& out
,
2405 OutputLanguage language
) const
2407 Printer::getPrinter(language
)->toStreamCmdGetAssertions(out
);
2410 /* -------------------------------------------------------------------------- */
2411 /* class SetBenchmarkStatusCommand */
2412 /* -------------------------------------------------------------------------- */
2414 SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status
)
2419 BenchmarkStatus
SetBenchmarkStatusCommand::getStatus() const
2424 void SetBenchmarkStatusCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2430 solver
->setInfo("status", ss
.str());
2431 d_commandStatus
= CommandSuccess::instance();
2433 catch (exception
& e
)
2435 d_commandStatus
= new CommandFailure(e
.what());
2439 Command
* SetBenchmarkStatusCommand::clone() const
2441 return new SetBenchmarkStatusCommand(d_status
);
2444 std::string
SetBenchmarkStatusCommand::getCommandName() const
2449 void SetBenchmarkStatusCommand::toStream(std::ostream
& out
,
2452 OutputLanguage language
) const
2454 Result::Sat status
= Result::SAT_UNKNOWN
;
2457 case BenchmarkStatus::SMT_SATISFIABLE
: status
= Result::SAT
; break;
2458 case BenchmarkStatus::SMT_UNSATISFIABLE
: status
= Result::UNSAT
; break;
2459 case BenchmarkStatus::SMT_UNKNOWN
: status
= Result::SAT_UNKNOWN
; break;
2462 Printer::getPrinter(language
)->toStreamCmdSetBenchmarkStatus(out
, status
);
2465 /* -------------------------------------------------------------------------- */
2466 /* class SetBenchmarkLogicCommand */
2467 /* -------------------------------------------------------------------------- */
2469 SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic
)
2474 std::string
SetBenchmarkLogicCommand::getLogic() const { return d_logic
; }
2475 void SetBenchmarkLogicCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2479 solver
->setLogic(d_logic
);
2480 d_commandStatus
= CommandSuccess::instance();
2482 catch (exception
& e
)
2484 d_commandStatus
= new CommandFailure(e
.what());
2488 Command
* SetBenchmarkLogicCommand::clone() const
2490 return new SetBenchmarkLogicCommand(d_logic
);
2493 std::string
SetBenchmarkLogicCommand::getCommandName() const
2498 void SetBenchmarkLogicCommand::toStream(std::ostream
& out
,
2501 OutputLanguage language
) const
2503 Printer::getPrinter(language
)->toStreamCmdSetBenchmarkLogic(out
, d_logic
);
2506 /* -------------------------------------------------------------------------- */
2507 /* class SetInfoCommand */
2508 /* -------------------------------------------------------------------------- */
2510 SetInfoCommand::SetInfoCommand(std::string flag
, const SExpr
& sexpr
)
2511 : d_flag(flag
), d_sexpr(sexpr
)
2515 std::string
SetInfoCommand::getFlag() const { return d_flag
; }
2516 SExpr
SetInfoCommand::getSExpr() const { return d_sexpr
; }
2517 void SetInfoCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2521 solver
->getSmtEngine()->setInfo(d_flag
, d_sexpr
);
2522 d_commandStatus
= CommandSuccess::instance();
2524 catch (UnrecognizedOptionException
&)
2526 // As per SMT-LIB spec, silently accept unknown set-info keys
2527 d_commandStatus
= CommandSuccess::instance();
2529 catch (exception
& e
)
2531 d_commandStatus
= new CommandFailure(e
.what());
2535 Command
* SetInfoCommand::clone() const
2537 return new SetInfoCommand(d_flag
, d_sexpr
);
2540 std::string
SetInfoCommand::getCommandName() const { return "set-info"; }
2542 void SetInfoCommand::toStream(std::ostream
& out
,
2545 OutputLanguage language
) const
2547 Printer::getPrinter(language
)->toStreamCmdSetInfo(out
, d_flag
, d_sexpr
);
2550 /* -------------------------------------------------------------------------- */
2551 /* class GetInfoCommand */
2552 /* -------------------------------------------------------------------------- */
2554 GetInfoCommand::GetInfoCommand(std::string flag
) : d_flag(flag
) {}
2555 std::string
GetInfoCommand::getFlag() const { return d_flag
; }
2556 void GetInfoCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2561 v
.push_back(SExpr(SExpr::Keyword(string(":") + d_flag
)));
2562 v
.emplace_back(solver
->getSmtEngine()->getInfo(d_flag
));
2564 if (d_flag
== "all-options" || d_flag
== "all-statistics")
2566 ss
<< PrettySExprs(true);
2569 d_result
= ss
.str();
2570 d_commandStatus
= CommandSuccess::instance();
2572 catch (UnrecognizedOptionException
&)
2574 d_commandStatus
= new CommandUnsupported();
2576 catch (RecoverableModalException
& e
)
2578 d_commandStatus
= new CommandRecoverableFailure(e
.what());
2580 catch (exception
& e
)
2582 d_commandStatus
= new CommandFailure(e
.what());
2586 std::string
GetInfoCommand::getResult() const { return d_result
; }
2587 void GetInfoCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2591 this->Command::printResult(out
, verbosity
);
2593 else if (d_result
!= "")
2595 out
<< d_result
<< endl
;
2599 Command
* GetInfoCommand::clone() const
2601 GetInfoCommand
* c
= new GetInfoCommand(d_flag
);
2602 c
->d_result
= d_result
;
2606 std::string
GetInfoCommand::getCommandName() const { return "get-info"; }
2608 void GetInfoCommand::toStream(std::ostream
& out
,
2611 OutputLanguage language
) const
2613 Printer::getPrinter(language
)->toStreamCmdGetInfo(out
, d_flag
);
2616 /* -------------------------------------------------------------------------- */
2617 /* class SetOptionCommand */
2618 /* -------------------------------------------------------------------------- */
2620 SetOptionCommand::SetOptionCommand(std::string flag
, const SExpr
& sexpr
)
2621 : d_flag(flag
), d_sexpr(sexpr
)
2625 std::string
SetOptionCommand::getFlag() const { return d_flag
; }
2626 SExpr
SetOptionCommand::getSExpr() const { return d_sexpr
; }
2627 void SetOptionCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2631 solver
->getSmtEngine()->setOption(d_flag
, d_sexpr
);
2632 d_commandStatus
= CommandSuccess::instance();
2634 catch (UnrecognizedOptionException
&)
2636 d_commandStatus
= new CommandUnsupported();
2638 catch (exception
& e
)
2640 d_commandStatus
= new CommandFailure(e
.what());
2644 Command
* SetOptionCommand::clone() const
2646 return new SetOptionCommand(d_flag
, d_sexpr
);
2649 std::string
SetOptionCommand::getCommandName() const { return "set-option"; }
2651 void SetOptionCommand::toStream(std::ostream
& out
,
2654 OutputLanguage language
) const
2656 Printer::getPrinter(language
)->toStreamCmdSetOption(out
, d_flag
, d_sexpr
);
2659 /* -------------------------------------------------------------------------- */
2660 /* class GetOptionCommand */
2661 /* -------------------------------------------------------------------------- */
2663 GetOptionCommand::GetOptionCommand(std::string flag
) : d_flag(flag
) {}
2664 std::string
GetOptionCommand::getFlag() const { return d_flag
; }
2665 void GetOptionCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2669 d_result
= solver
->getOption(d_flag
);
2670 d_commandStatus
= CommandSuccess::instance();
2672 catch (UnrecognizedOptionException
&)
2674 d_commandStatus
= new CommandUnsupported();
2676 catch (exception
& e
)
2678 d_commandStatus
= new CommandFailure(e
.what());
2682 std::string
GetOptionCommand::getResult() const { return d_result
; }
2683 void GetOptionCommand::printResult(std::ostream
& out
, uint32_t verbosity
) const
2687 this->Command::printResult(out
, verbosity
);
2689 else if (d_result
!= "")
2691 out
<< d_result
<< endl
;
2695 Command
* GetOptionCommand::clone() const
2697 GetOptionCommand
* c
= new GetOptionCommand(d_flag
);
2698 c
->d_result
= d_result
;
2702 std::string
GetOptionCommand::getCommandName() const { return "get-option"; }
2704 void GetOptionCommand::toStream(std::ostream
& out
,
2707 OutputLanguage language
) const
2709 Printer::getPrinter(language
)->toStreamCmdGetOption(out
, d_flag
);
2712 /* -------------------------------------------------------------------------- */
2713 /* class SetExpressionNameCommand */
2714 /* -------------------------------------------------------------------------- */
2716 SetExpressionNameCommand::SetExpressionNameCommand(api::Term term
,
2718 : d_term(term
), d_name(name
)
2722 void SetExpressionNameCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2724 solver
->getSmtEngine()->setExpressionName(d_term
.getExpr(), d_name
);
2725 d_commandStatus
= CommandSuccess::instance();
2728 Command
* SetExpressionNameCommand::clone() const
2730 SetExpressionNameCommand
* c
= new SetExpressionNameCommand(d_term
, d_name
);
2734 std::string
SetExpressionNameCommand::getCommandName() const
2736 return "set-expr-name";
2739 void SetExpressionNameCommand::toStream(std::ostream
& out
,
2742 OutputLanguage language
) const
2744 Printer::getPrinter(language
)->toStreamCmdSetExpressionName(
2745 out
, d_term
.getNode(), d_name
);
2748 /* -------------------------------------------------------------------------- */
2749 /* class DatatypeDeclarationCommand */
2750 /* -------------------------------------------------------------------------- */
2752 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2753 const api::Sort
& datatype
)
2756 d_datatypes
.push_back(datatype
);
2759 DatatypeDeclarationCommand::DatatypeDeclarationCommand(
2760 const std::vector
<api::Sort
>& datatypes
)
2761 : d_datatypes(datatypes
)
2765 const std::vector
<api::Sort
>& DatatypeDeclarationCommand::getDatatypes() const
2770 void DatatypeDeclarationCommand::invoke(api::Solver
* solver
, SymbolManager
* sm
)
2772 d_commandStatus
= CommandSuccess::instance();
2775 Command
* DatatypeDeclarationCommand::clone() const
2777 return new DatatypeDeclarationCommand(d_datatypes
);
2780 std::string
DatatypeDeclarationCommand::getCommandName() const
2782 return "declare-datatypes";
2785 void DatatypeDeclarationCommand::toStream(std::ostream
& out
,
2788 OutputLanguage language
) const
2790 Printer::getPrinter(language
)->toStreamCmdDatatypeDeclaration(
2791 out
, api::sortVectorToTypeNodes(d_datatypes
));