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/util/model.h | |
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/util/model.h')
-rw-r--r-- | src/util/model.h | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/util/model.h b/src/util/model.h index 36a5464b4..97010dd45 100644 --- a/src/util/model.h +++ b/src/util/model.h @@ -2,10 +2,10 @@ /*! \file model.h ** \verbatim ** Original author: ajreynol - ** Major contributors: none + ** Major contributors: mdeters ** Minor contributors (to current version): none ** This file is part of the CVC4 prototype. - ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys) + ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys) ** Courant Institute of Mathematical Sciences ** New York University ** See the file COPYING in the top-level source directory for licensing @@ -27,41 +27,28 @@ namespace CVC4 { -class Command; +class CVC4_PUBLIC Command; +class CVC4_PUBLIC SmtEngine; -class Model -{ -public: - //types of commands that are recorded for get-model - enum { - COMMAND_DECLARE_SORT, //DeclareTypeCommand - COMMAND_DECLARE_FUN, //DeclareFunctionCommand - COMMAND_DECLARE_DATATYPES, //DatatypeDeclarationCommand - }; +class CVC4_PUBLIC Model { private: - //list of commands that the model must report when calling get model - std::vector< Command* > d_commands; - std::vector< int > d_command_types; + /** The SmtEngine we're associated to */ + const SmtEngine& d_smt; public: + /** construct the base class */ + Model(); /** virtual destructor */ - virtual ~Model() {} - /** add command */ - virtual void addCommand( Command* c, int c_type ){ - d_commands.push_back( c ); - d_command_types.push_back( c_type ); - } + virtual ~Model() { } /** get number of commands to report */ - size_t getNumCommands() { return d_commands.size(); } + size_t getNumCommands() const; /** get command */ - Command* getCommand( int i ) { return d_commands[i]; } - /** get type of command */ - int getCommandType( int i ) { return d_command_types[i]; } + const Command* getCommand(size_t i) const; public: /** get value for expression */ - virtual Expr getValue( const Expr& expr ) = 0; + virtual Expr getValue(Expr expr) = 0; /** get cardinality for sort */ - virtual Cardinality getCardinality( const Type& t ) = 0; - /** to stream function */ + virtual Cardinality getCardinality(Type t) = 0; + /** write the model to a stream */ virtual void toStream(std::ostream& out) = 0; };/* class Model */ |