summaryrefslogtreecommitdiff
path: root/src/smt/command.cpp
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-09-01 13:05:48 -0500
committerGitHub <noreply@github.com>2021-09-01 18:05:48 +0000
commit7a3aa7033719b14b34c0334d6956834b850fa9eb (patch)
tree53c2f3543a6314eaabd76eff9e38c2752a5c4afa /src/smt/command.cpp
parent24c4e9d5612fd7549a8ff7acaf76ce95acaca0d9 (diff)
Print response to get-model using the API (#7084)
This changes our implementation of GetModelCommand so that we use the API to print the model. It simplifies smt::Model so that this is a pretty printing utility, and not a layer on top of TheoryModel. It adds getModel as an API method for returning the string representation of the model, analogous to our current support for getProof. This eliminates the last call to getSmtEngine() from the command layer.
Diffstat (limited to 'src/smt/command.cpp')
-rw-r--r--src/smt/command.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/smt/command.cpp b/src/smt/command.cpp
index e6be0a646..008d7a6d8 100644
--- a/src/smt/command.cpp
+++ b/src/smt/command.cpp
@@ -38,8 +38,6 @@
#include "proof/unsat_core.h"
#include "smt/dump.h"
#include "smt/model.h"
-#include "smt/smt_engine.h"
-#include "smt/smt_engine_scope.h"
#include "util/unsafe_interrupt_exception.h"
#include "util/utility.h"
@@ -1748,27 +1746,17 @@ void GetAssignmentCommand::toStream(std::ostream& out,
/* class GetModelCommand */
/* -------------------------------------------------------------------------- */
-GetModelCommand::GetModelCommand() : d_result(nullptr) {}
+GetModelCommand::GetModelCommand() {}
void GetModelCommand::invoke(api::Solver* solver, SymbolManager* sm)
{
try
{
- d_result = solver->getSmtEngine()->getModel();
- // set the model declarations, which determines what is printed in the model
- d_result->clearModelDeclarations();
std::vector<api::Sort> declareSorts = sm->getModelDeclareSorts();
- for (const api::Sort& s : declareSorts)
- {
- d_result->addDeclarationSort(sortToTypeNode(s));
- }
std::vector<api::Term> declareTerms = sm->getModelDeclareTerms();
- for (const api::Term& t : declareTerms)
- {
- d_result->addDeclarationTerm(termToNode(t));
- }
+ d_result = solver->getModel(declareSorts, declareTerms);
d_commandStatus = CommandSuccess::instance();
}
- catch (RecoverableModalException& e)
+ catch (api::CVC5ApiRecoverableException& e)
{
d_commandStatus = new CommandRecoverableFailure(e.what());
}
@@ -1782,12 +1770,6 @@ void GetModelCommand::invoke(api::Solver* solver, SymbolManager* sm)
}
}
-/* Model is private to the library -- for now
-Model* GetModelCommand::getResult() const {
- return d_result;
-}
-*/
-
void GetModelCommand::printResult(std::ostream& out, uint32_t verbosity) const
{
if (!ok())
@@ -1796,13 +1778,13 @@ void GetModelCommand::printResult(std::ostream& out, uint32_t verbosity) const
}
else
{
- out << *d_result;
+ out << d_result;
}
}
Command* GetModelCommand::clone() const
{
- GetModelCommand* c = new GetModelCommand();
+ GetModelCommand* c = new GetModelCommand;
c->d_result = d_result;
return c;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback