This PR removes Solver::getAssignment command from the API as there is no way to assign names to terms in the API. It also removes ExpandDefinitionsCommand, an internal functionality in CVC4.
CVC4_API_SOLVER_TRY_CATCH_END;
}
-/**
- * ( get-assignment )
- */
-std::vector<std::pair<Term, Term>> Solver::getAssignment(void) const
-{
- CVC4_API_SOLVER_TRY_CATCH_BEGIN;
- CVC4::ExprManagerScope exmgrs(*(d_exprMgr.get()));
- CVC4_API_CHECK(d_smtEngine->getOptions()[options::produceAssignments])
- << "Cannot get assignment unless assignment generation is enabled "
- "(try --produce-assignments)";
- std::vector<std::pair<Expr, Expr>> assignment = d_smtEngine->getAssignment();
- std::vector<std::pair<Term, Term>> res;
- for (const auto& p : assignment)
- {
- res.emplace_back(Term(this, p.first), Term(this, p.second));
- }
- return res;
- CVC4_API_SOLVER_TRY_CATCH_END;
-}
-
/**
* ( get-info <info_flag> )
*/
*/
std::vector<Term> getAssertions() const;
- /**
- * Get the assignment of asserted formulas.
- * SMT-LIB: ( get-assignment )
- * Requires to enable option 'produce-assignments'.
- * @return a list of formula-assignment pairs
- */
- std::vector<std::pair<Term, Term>> getAssignment() const;
-
/**
* Get info from the solver.
* SMT-LIB: ( get-info <info_flag> )
Term defineFunsRec(vector[Term]& funs, vector[vector[Term]]& bound_vars,
vector[Term]& terms, bint glbl) except +
vector[Term] getAssertions() except +
- vector[pair[Term, Term]] getAssignment() except +
string getInfo(const string& flag) except +
string getOption(string& option) except +
vector[Term] getUnsatAssumptions() except +
assertions.append(term)
return assertions
- def getAssignment(self):
- '''
- Gives the assignment of *named* formulas as a dictionary.
- '''
- assignments = {}
- for a in self.csolver.getAssignment():
- varterm = Term(self)
- valterm = Term(self)
- varterm.cterm = a.first
- valterm.cterm = a.second
- assignments[varterm] = valterm
- return assignments
-
def getInfo(self, str flag):
return self.csolver.getInfo(flag.encode())
printUnknownCommand(out, "simplify");
}
-void Printer::toStreamCmdExpandDefinitions(std::ostream& out, Node n) const
-{
- printUnknownCommand(out, "expand-definitions");
-}
-
void Printer::toStreamCmdGetValue(std::ostream& out,
const std::vector<Node>& nodes) const
{
/** Print simplify command */
virtual void toStreamCmdSimplify(std::ostream& out, Node n) const;
- /** Print expand-definitions command */
- void toStreamCmdExpandDefinitions(std::ostream& out, Node n) const;
-
/** Print get-value command */
virtual void toStreamCmdGetValue(std::ostream& out,
const std::vector<Node>& nodes) const;
Printer::getPrinter(language)->toStreamCmdSimplify(out, d_term.getNode());
}
-/* -------------------------------------------------------------------------- */
-/* class ExpandDefinitionsCommand */
-/* -------------------------------------------------------------------------- */
-
-ExpandDefinitionsCommand::ExpandDefinitionsCommand(api::Term term)
- : d_term(term)
-{
-}
-api::Term ExpandDefinitionsCommand::getTerm() const { return d_term; }
-void ExpandDefinitionsCommand::invoke(api::Solver* solver)
-{
- try
- {
- d_result = api::Term(
- solver, solver->getSmtEngine()->expandDefinitions(d_term.getNode()));
- d_commandStatus = CommandSuccess::instance();
- }
- catch (exception& e)
- {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-api::Term ExpandDefinitionsCommand::getResult() const { return d_result; }
-void ExpandDefinitionsCommand::printResult(std::ostream& out,
- uint32_t verbosity) const
-{
- if (!ok())
- {
- this->Command::printResult(out, verbosity);
- }
- else
- {
- out << d_result << endl;
- }
-}
-
-Command* ExpandDefinitionsCommand::clone() const
-{
- ExpandDefinitionsCommand* c = new ExpandDefinitionsCommand(d_term);
- c->d_result = d_result;
- return c;
-}
-
-std::string ExpandDefinitionsCommand::getCommandName() const
-{
- return "expand-definitions";
-}
-
-void ExpandDefinitionsCommand::toStream(std::ostream& out,
- int toDepth,
- bool types,
- size_t dag,
- OutputLanguage language) const
-{
- Printer::getPrinter(language)->toStreamCmdExpandDefinitions(out,
- d_term.getNode());
-}
-
/* -------------------------------------------------------------------------- */
/* class GetValueCommand */
/* -------------------------------------------------------------------------- */
{
try
{
- std::vector<std::pair<api::Term, api::Term>> assignments =
- solver->getAssignment();
+ std::vector<std::pair<Expr, Expr>> assignments =
+ solver->getSmtEngine()->getAssignment();
vector<SExpr> sexprs;
for (const auto& p : assignments)
{
d_result = SExpr(sexprs);
d_commandStatus = CommandSuccess::instance();
}
- catch (api::CVC4ApiRecoverableException& e)
+ catch (RecoverableModalException& e)
{
d_commandStatus = new CommandRecoverableFailure(e.what());
}
OutputLanguage language = language::output::LANG_AUTO) const override;
}; /* class SimplifyCommand */
-class CVC4_PUBLIC ExpandDefinitionsCommand : public Command
-{
- protected:
- api::Term d_term;
- api::Term d_result;
-
- public:
- ExpandDefinitionsCommand(api::Term term);
-
- api::Term getTerm() const;
- api::Term getResult() const;
- void invoke(api::Solver* solver) override;
- void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
- Command* clone() const override;
- std::string getCommandName() const override;
- void toStream(
- std::ostream& out,
- int toDepth = -1,
- bool types = false,
- size_t dag = 1,
- OutputLanguage language = language::output::LANG_AUTO) const override;
-}; /* class ExpandDefinitionsCommand */
-
class CVC4_PUBLIC GetValueCommand : public Command
{
protected: