diff options
author | Morgan Deters <mdeters@gmail.com> | 2010-10-10 22:15:38 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2010-10-10 22:15:38 +0000 |
commit | d6b37239a2e525e7878d3bb0b4372a8dabc340a9 (patch) | |
tree | 3db6b54c8b5873db1e6c91b1577d431d74632c66 /src/expr | |
parent | 7a059452ebf5729723f610da9258a47007e38253 (diff) |
additional model gen and SMT-LIBv2 compliance work: (get-assignment) now supported; work on Result type (biggest noticeable change is that CVC4 now outputs lowercase "sat" and "unsat"), Options class moved to src/smt, to allow for future work on runtime configuration via (set-option) command
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/command.cpp | 43 | ||||
-rw-r--r-- | src/expr/command.h | 25 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/expr/command.cpp b/src/expr/command.cpp index 15fea22da..38193a75b 100644 --- a/src/expr/command.cpp +++ b/src/expr/command.cpp @@ -240,6 +240,28 @@ void DefineFunctionCommand::toStream(std::ostream& out) const { out << "], << " << d_formula << " >> )"; } +/* class DefineFunctionCommand */ + +DefineNamedFunctionCommand::DefineNamedFunctionCommand(Expr func, + const std::vector<Expr>& formals, + Expr formula) : + DefineFunctionCommand(func, formals, formula) { +} + +void DefineNamedFunctionCommand::invoke(SmtEngine* smtEngine) { + this->DefineFunctionCommand::invoke(smtEngine); + if(d_func.getType().isBoolean()) { + smtEngine->addToAssignment(d_func.getExprManager()->mkExpr(kind::APPLY, + d_func)); + } +} + +void DefineNamedFunctionCommand::toStream(std::ostream& out) const { + out << "DefineNamedFunction( "; + this->DefineFunctionCommand::toStream(out); + out << " )"; +} + /* class GetValueCommand */ GetValueCommand::GetValueCommand(Expr term) : @@ -262,6 +284,27 @@ void GetValueCommand::toStream(std::ostream& out) const { out << "GetValue( << " << d_term << " >> )"; } +/* class GetAssignmentCommand */ + +GetAssignmentCommand::GetAssignmentCommand() { +} + +void GetAssignmentCommand::invoke(SmtEngine* smtEngine) { + d_result = smtEngine->getAssignment(); +} + +SExpr GetAssignmentCommand::getResult() const { + return d_result; +} + +void GetAssignmentCommand::printResult(std::ostream& out) const { + out << d_result << endl; +} + +void GetAssignmentCommand::toStream(std::ostream& out) const { + out << "GetAssignment()"; +} + /* class GetAssertionsCommand */ GetAssertionsCommand::GetAssertionsCommand() { diff --git a/src/expr/command.h b/src/expr/command.h index 4c74cfd6c..172ddea86 100644 --- a/src/expr/command.h +++ b/src/expr/command.h @@ -122,6 +122,20 @@ public: void toStream(std::ostream& out) const; };/* class DefineFunctionCommand */ +/** + * This differs from DefineFunctionCommand only in that it instructs + * the SmtEngine to "remember" this function for later retrieval with + * getAssignment(). Used for :named attributes in SMT-LIBv2. + */ +class CVC4_PUBLIC DefineNamedFunctionCommand : public DefineFunctionCommand { +public: + DefineNamedFunctionCommand(Expr func, + const std::vector<Expr>& formals, + Expr formula); + void invoke(SmtEngine* smtEngine); + void toStream(std::ostream& out) const; +};/* class DefineNamedFunctionCommand */ + class CVC4_PUBLIC CheckSatCommand : public Command { protected: BoolExpr d_expr; @@ -158,6 +172,17 @@ public: void toStream(std::ostream& out) const; };/* class GetValueCommand */ +class CVC4_PUBLIC GetAssignmentCommand : public Command { +protected: + SExpr d_result; +public: + GetAssignmentCommand(); + void invoke(SmtEngine* smtEngine); + SExpr getResult() const; + void printResult(std::ostream& out) const; + void toStream(std::ostream& out) const; +};/* class GetAssignmentCommand */ + class CVC4_PUBLIC GetAssertionsCommand : public Command { protected: std::string d_result; |