diff options
author | Morgan Deters <mdeters@gmail.com> | 2012-09-19 21:21:00 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2012-09-19 21:21:00 +0000 |
commit | 46c12d84290f3ed23bd0b435c6e8e5852ab1af39 (patch) | |
tree | 64c2d2175eb814b9187d8cc6ccecbddf90151b2a /src/printer/smt2 | |
parent | 7a15b2c1fb45f0cc7480466473f344f8b1f5ed94 (diff) |
General subscriber infrastructure for NodeManager, as discussed in the
meeting last week. The SmtEngine now subscribes to NodeManager events,
does appropriate dumping of variable declarations, and notifies the Model
class.
The way to create a skolem is now:
nodeManager->mkSkolem("myvar_$$", TypeNode, "is a variable created by the theory of Foo")
The first argument is the name of the skolem, and the (optional) "$$" is a
placeholder for the node id (to get a unique name). Without a "$$", a "_$$"
is automatically appended to the given name.
The second argument is the type.
The (optional, but recommended) third argument is a comment, used by the
dump infrastructure to indicate what the variable is for / who owns it.
An optional fourth argument (not shown) allows you to specify flags that
control the behavior (e.g., don't do notification, and/or don't make a
unique name). Look at the documentation for details on these.
In particular, the above means you can't just do a mkSkolem(boolType) for
example---you have to specify a name and (hopefully also,
but it's optional) a comment. This leads to easier debugging than the
anonymous skolems before, since we'll be able to track where the skolems
came from.
Much of the Model and Dump stuff, as well as some Command stuff, is cleaned up
by this commit. Some remains to be cleaned up.
(this commit was certified error- and warning-free by the test-and-commit script.)
Diffstat (limited to 'src/printer/smt2')
-rw-r--r-- | src/printer/smt2/smt2_printer.cpp | 14 | ||||
-rw-r--r-- | src/printer/smt2/smt2_printer.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp index e41fd9c65..28ecc11c4 100644 --- a/src/printer/smt2/smt2_printer.cpp +++ b/src/printer/smt2/smt2_printer.cpp @@ -320,8 +320,8 @@ void Smt2Printer::toStream(std::ostream& out, TNode n, // output that support for the kind needs to be added here. out << n.getKind() << ' '; } - if(n.getMetaKind() == kind::metakind::PARAMETERIZED && - stillNeedToPrintParams) { + if( n.getMetaKind() == kind::metakind::PARAMETERIZED && + stillNeedToPrintParams ) { if(toDepth != 0) { toStream(out, n.getOperator(), toDepth < 0 ? toDepth : toDepth - 1, types); } else { @@ -528,10 +528,10 @@ void Smt2Printer::toStream(std::ostream& out, const CommandStatus* s) const thro }/* Smt2Printer::toStream(CommandStatus*) */ -void Smt2Printer::toStream(std::ostream& out, Model* m, Command* c, int c_type ) const throw(){ +void Smt2Printer::toStream(std::ostream& out, Model* m, const Command* c) const throw() { theory::TheoryModel* tm = (theory::TheoryModel*)m; - if( c_type==Model::COMMAND_DECLARE_SORT ){ - TypeNode tn = TypeNode::fromType( ((DeclareTypeCommand*)c)->getType() ); + if(dynamic_cast<const DeclareTypeCommand*>(c) != NULL) { + TypeNode tn = TypeNode::fromType( ((const DeclareTypeCommand*)c)->getType() ); if( tn.isSort() ){ //print the cardinality if( tm->d_rep_set.d_type_reps.find( tn )!=tm->d_rep_set.d_type_reps.end() ){ @@ -551,8 +551,8 @@ void Smt2Printer::toStream(std::ostream& out, Model* m, Command* c, int c_type ) } } } - }else if( c_type==Model::COMMAND_DECLARE_FUN ){ - Node n = Node::fromExpr( ((DeclareFunctionCommand*)c)->getFunction() ); + } else if(dynamic_cast<const DeclareFunctionCommand*>(c) != NULL) { + Node n = Node::fromExpr( ((const DeclareFunctionCommand*)c)->getFunction() ); Node val = tm->getValue( n ); if(val.getKind() == kind::LAMBDA) { out << "(define-fun " << n << " " << val[0] diff --git a/src/printer/smt2/smt2_printer.h b/src/printer/smt2/smt2_printer.h index 475479095..ce48f36f3 100644 --- a/src/printer/smt2/smt2_printer.h +++ b/src/printer/smt2/smt2_printer.h @@ -36,7 +36,7 @@ public: void toStream(std::ostream& out, const Command* c, int toDepth, bool types, size_t dag) const throw(); void toStream(std::ostream& out, const CommandStatus* s) const throw(); //for models - void toStream(std::ostream& out, Model* m, Command* c, int c_type ) const throw(); + void toStream(std::ostream& out, Model* m, const Command* c) const throw(); void toStream(std::ostream& out, const Result& r) const throw(); };/* class Smt2Printer */ |