/* class GetValueCommand */
GetValueCommand::GetValueCommand(Expr term) throw() :
- d_term(term) {
+ d_terms() {
+ d_terms.push_back(term);
}
-Expr GetValueCommand::getTerm() const throw() {
- return d_term;
+GetValueCommand::GetValueCommand(const std::vector<Expr>& terms) throw() :
+ d_terms(terms) {
+ CheckArgument(terms.size() >= 1, terms, "cannot get-value of an empty set of terms");
+}
+
+const std::vector<Expr>& GetValueCommand::getTerms() const throw() {
+ return d_terms;
}
void GetValueCommand::invoke(SmtEngine* smtEngine) throw() {
try {
- d_result = d_term.getExprManager()->mkExpr(kind::TUPLE, d_term,
- smtEngine->getValue(d_term));
+ vector<Node> result;
+ NodeManager* nm = NodeManager::fromExprManager(smtEngine->getExprManager());
+ for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
+ Assert(nm == NodeManager::fromExprManager((*i).getExprManager()));
+ result.push_back(nm->mkNode(kind::TUPLE, Node::fromExpr(*i), Node::fromExpr(smtEngine->getValue(*i))));
+ }
+ Node n = nm->mkNode(kind::TUPLE, result);
+ d_result = nm->toExpr(n);
d_commandStatus = CommandSuccess::instance();
} catch(exception& e) {
d_commandStatus = new CommandFailure(e.what());
if(! ok()) {
this->Command::printResult(out);
} else {
+ Expr::dag::Scope scope(out, false);
out << d_result << endl;
}
}
Command* GetValueCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetValueCommand* c = new GetValueCommand(d_term.exportTo(exprManager, variableMap));
+ vector<Expr> exportedTerms;
+ for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
+ exportedTerms.push_back((*i).exportTo(exprManager, variableMap));
+ }
+ GetValueCommand* c = new GetValueCommand(exportedTerms);
c->d_result = d_result.exportTo(exprManager, variableMap);
return c;
}
Command* GetValueCommand::clone() const {
- GetValueCommand* c = new GetValueCommand(d_term);
+ GetValueCommand* c = new GetValueCommand(d_terms);
c->d_result = d_result;
return c;
}
class CVC4_PUBLIC GetValueCommand : public Command {
protected:
- Expr d_term;
+ std::vector<Expr> d_terms;
Expr d_result;
public:
GetValueCommand(Expr term) throw();
+ GetValueCommand(const std::vector<Expr>& terms) throw();
~GetValueCommand() throw() {}
- Expr getTerm() const throw();
+ const std::vector<Expr>& getTerms() const throw();
void invoke(SmtEngine* smtEngine) throw();
Expr getResult() const throw();
void printResult(std::ostream& out) const throw();
}/* CVC4::expr namespace */
-Expr Expr::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+Expr Expr::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) const {
Assert(d_exprManager != exprManager,
"No sense in cloning an Expr in the same ExprManager");
ExprManagerScope ems(*this);
* variableMap for the translation and extending it with any new
* mappings.
*/
- Expr exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Expr exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) const;
/**
* IOStream manipulator to set the maximum depth of Exprs when
}
inline TypeNode NodeManager::mkTupleType(const std::vector<TypeNode>& types) {
- Assert(types.size() >= 2);
+ Assert(types.size() >= 1);
std::vector<TypeNode> typeNodes;
for (unsigned i = 0; i < types.size(); ++ i) {
CheckArgument(!types[i].isFunctionLike(), types,
| /* value query */
GET_VALUE_TOK { PARSER_STATE->checkThatLogicIsSet(); }
LPAREN_TOK termList[terms,expr] RPAREN_TOK
- { if(terms.size() == 1) {
- $cmd = new GetValueCommand(terms[0]);
- } else {
- CommandSequence* seq = new CommandSequence();
- for(std::vector<Expr>::const_iterator i = terms.begin(),
- iend = terms.end();
- i != iend;
- ++i) {
- seq->addCommand(new GetValueCommand(*i));
- }
- $cmd = seq;
- }
- }
+ { $cmd = new GetValueCommand(terms); }
| /* get-assignment */
GET_ASSIGNMENT_TOK { PARSER_STATE->checkThatLogicIsSet(); }
{ cmd = new GetAssignmentCommand; }
}
static void toStream(std::ostream& out, const GetValueCommand* c) throw() {
- out << "GetValue( << " << c->getTerm() << " >> )";
+ out << "GetValue( << ";
+ const vector<Expr>& terms = c->getTerms();
+ copy(terms.begin(), terms.end(), ostream_iterator<Expr>(out, ", "));
+ out << " >> )";
}
static void toStream(std::ostream& out, const GetAssignmentCommand* c) throw() {
}
static void toStream(std::ostream& out, const GetValueCommand* c) throw() {
- out << "% (get-value " << c->getTerm() << ")";
+ out << "% (get-value ( ";
+ const vector<Expr>& terms = c->getTerms();
+ copy(terms.begin(), terms.end(), ostream_iterator<Expr>(out, " "));
+ out << " ))";
}
static void toStream(std::ostream& out, const GetAssignmentCommand* c) throw() {
}
static void toStream(std::ostream& out, const GetValueCommand* c) throw() {
- out << "(get-value " << c->getTerm() << ")";
+ out << "(get-value ( ";
+ const vector<Expr>& terms = c->getTerms();
+ copy(terms.begin(), terms.end(), ostream_iterator<Expr>(out, " "));
+ out << " ))";
}
static void toStream(std::ostream& out, const GetAssignmentCommand* c) throw() {
operator DISTINCT 2: "disequality"
variable SKOLEM "skolem var"
variable VARIABLE "variable"
-operator TUPLE 2: "a tuple"
+operator TUPLE 1: "a tuple"
constant TYPE_CONSTANT \
::CVC4::TypeConstant \
"::CVC4::theory::builtin::FunctionProperties::computeCardinality(%TYPE%)" \
"theory/builtin/theory_builtin_type_rules.h"
well-founded FUNCTION_TYPE false
-operator TUPLE_TYPE 2: "tuple type"
+operator TUPLE_TYPE 1: "tuple type"
cardinality TUPLE_TYPE \
"::CVC4::theory::builtin::TupleProperties::computeCardinality(%TYPE%)" \
"theory/builtin/theory_builtin_type_rules.h"