diff options
author | Morgan Deters <mdeters@gmail.com> | 2009-11-17 17:09:13 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2009-11-17 17:09:13 +0000 |
commit | 105503064be6a198dd864d1e95d6d79e1af51d25 (patch) | |
tree | 040d1dfc2d696c2efef84cf2cb044072d97a337a /src/util | |
parent | 61330b862f7b5565f70e3c1f4d26a8c51a0f534a (diff) |
from meeting
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/assert.h | 26 | ||||
-rw-r--r-- | src/util/command.h | 22 | ||||
-rw-r--r-- | src/util/debug.h | 26 | ||||
-rw-r--r-- | src/util/decision_engine.h | 42 | ||||
-rw-r--r-- | src/util/exception.h | 48 | ||||
-rw-r--r-- | src/util/literal.h | 21 | ||||
-rw-r--r-- | src/util/model.h | 22 | ||||
-rw-r--r-- | src/util/result.h | 65 | ||||
-rw-r--r-- | src/util/unique_id.h | 35 |
9 files changed, 307 insertions, 0 deletions
diff --git a/src/util/assert.h b/src/util/assert.h new file mode 100644 index 000000000..a66503641 --- /dev/null +++ b/src/util/assert.h @@ -0,0 +1,26 @@ +/********************* -*- C++ -*- */ +/** assert.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_ASSERT_H +#define __CVC4_ASSERT_H + +#include <cassert> + +#ifdef DEBUG +// the __builtin_expect() helps us if assert is built-in or a macro +# define cvc4assert(x) assert(__builtin_expect((x), 1)) +#else +// TODO: use a compiler annotation when assertions are off ? +// (to improve optimization) +# define cvc4assert(x) +#endif /* DEBUG */ + +#endif /* __CVC4_ASSERT_H */ diff --git a/src/util/command.h b/src/util/command.h new file mode 100644 index 000000000..944b9c621 --- /dev/null +++ b/src/util/command.h @@ -0,0 +1,22 @@ +/********************* -*- C++ -*- */ +/** command.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_COMMAND_H +#define __CVC4_COMMAND_H + +namespace CVC4 { + +class Command { // distinct from Exprs +}; + +} /* CVC4 namespace */ + +#endif /* __CVC4_COMMAND_H */ diff --git a/src/util/debug.h b/src/util/debug.h new file mode 100644 index 000000000..36942d1ae --- /dev/null +++ b/src/util/debug.h @@ -0,0 +1,26 @@ +/********************* -*- C++ -*- */ +/** debug.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_DEBUG_H +#define __CVC4_DEBUG_H + +#include <cassert> + +#ifdef DEBUG +// the __builtin_expect() helps us if assert is built-in or a macro +# define cvc4assert(x) assert(__builtin_expect((x), 1)) +#else +// TODO: use a compiler annotation when assertions are off ? +// (to improve optimization) +# define cvc4assert(x) +#endif /* DEBUG */ + +#endif /* __CVC4_DEBUG_H */ diff --git a/src/util/decision_engine.h b/src/util/decision_engine.h new file mode 100644 index 000000000..81d820eaa --- /dev/null +++ b/src/util/decision_engine.h @@ -0,0 +1,42 @@ +/********************* -*- C++ -*- */ +/** decision_engine.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_DECISION_ENGINE_H +#define __CVC4_DECISION_ENGINE_H + +#include "core/literal.h" + +namespace CVC4 { + +// In terms of abstraction, this is below (and provides services to) +// PropEngine. + +/** + * A decision mechanism for the next decision. + */ +class DecisionEngine { +public: + /** + * Get the next decision. + */ + virtual Literal nextDecision() = 0; + + // TODO: design decision: decision engine should be notified of + // propagated lits, and also why(?) (so that it can make decisions + // based on the utility of various theories and various theory + // literals). How? Maybe TheoryEngine has a backdoor into + // DecisionEngine "behind the back" of the PropEngine? + +};/* class DecisionEngine */ + +}/* CVC4 namespace */ + +#endif /* __CVC4_DECISION_ENGINE_H */ diff --git a/src/util/exception.h b/src/util/exception.h new file mode 100644 index 000000000..792a98701 --- /dev/null +++ b/src/util/exception.h @@ -0,0 +1,48 @@ +/********************* -*- C++ -*- */ +/** exception.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + ** Exception class. + **/ + +#ifndef __CVC4_EXCEPTION_H +#define __CVC4_EXCEPTION_H + +#include <string> +#include <iostream> + +namespace CVC4 { + + class Exception { + protected: + std::string d_msg; + public: + // Constructors + Exception(): d_msg("Unknown exception") { } + Exception(const std::string& msg): d_msg(msg) { } + Exception(const char* msg): d_msg(msg) { } + // Destructor + virtual ~Exception() { } + // NON-VIRTUAL METHODs for setting and printing the error message + void setMessage(const std::string& msg) { d_msg = msg; } + // Printing: feel free to redefine toString(). When inherited, + // it's recommended that this method print the type of exception + // before the actual message. + virtual std::string toString() const { return d_msg; } + // No need to overload operator<< for the inherited classes + friend std::ostream& operator<<(std::ostream& os, const Exception& e); + + }; // end of class Exception + + inline std::ostream& operator<<(std::ostream& os, const Exception& e) { + return os << e.toString(); + } + +}/* CVC4 namespace */ + +#endif /* __CVC4_EXCEPTION_H */ diff --git a/src/util/literal.h b/src/util/literal.h new file mode 100644 index 000000000..8b147c640 --- /dev/null +++ b/src/util/literal.h @@ -0,0 +1,21 @@ +/********************* -*- C++ -*- */ +/** literal.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_LITERAL_H +#define __CVC4_LITERAL_H + +namespace CVC4 { + +class Literal; + +}/* CVC4 namespace */ + +#endif /* __CVC4_LITERAL_H */ diff --git a/src/util/model.h b/src/util/model.h new file mode 100644 index 000000000..c07b75dfa --- /dev/null +++ b/src/util/model.h @@ -0,0 +1,22 @@ +/********************* -*- C++ -*- */ +/** model.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_MODEL_H +#define __CVC4_MODEL_H + +namespace CVC4 { + +class Model { +};/* class Model */ + +}/* CVC4 namespace */ + +#endif /* __CVC4_MODEL_H */ diff --git a/src/util/result.h b/src/util/result.h new file mode 100644 index 000000000..50f488682 --- /dev/null +++ b/src/util/result.h @@ -0,0 +1,65 @@ +/********************* -*- C++ -*- */ +/** result.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_RESULT_H +#define __CVC4_RESULT_H + +namespace CVC4 { + +// TODO: perhaps best to templatize Result on its Kind (SAT/Validity), +// but this requires doing the same for Prover and needs discussion. + +// TODO: subclass to provide models, etc. This is really just +// intended as a three-valued response code. + +/** + * Three-valued, immutable SMT result, with optional explanation. + */ +class Result { +public: + enum SAT { + UNSAT = 0, + SAT = 1, + SAT_UNKNOWN = 2 + }; + + enum Validity { + INVALID = 0, + VALID = 1, + VALIDITY_UNKNOWN = 2 + }; + + enum UnknownExplanation { + REQUIRES_FULL_CHECK, + INCOMPLETE, + TIMEOUT, + BAIL, + OTHER + }; + +private: + enum SAT d_sat; + enum Validity d_validity; + enum { TYPE_SAT, TYPE_VALIDITY } d_which; + +public: + Result(enum SAT); + Result(enum Validity); + + enum SAT isSAT(); + enum Validity isValid(); + enum UnknownExplanation whyUnknown(); + +};/* class Result */ + +}/* CVC4 namespace */ + +#endif /* __CVC4_RESULT_H */ diff --git a/src/util/unique_id.h b/src/util/unique_id.h new file mode 100644 index 000000000..1a6f3427a --- /dev/null +++ b/src/util/unique_id.h @@ -0,0 +1,35 @@ +/********************* -*- C++ -*- */ +/** unique_id.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 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 + ** information. + ** + **/ + +#ifndef __CVC4_UNIQUE_ID_H +#define __CVC4_UNIQUE_ID_H + +namespace CVC4 { + +// NOTE that UniqueID is intended for startup registration; it +// shouldn't be used in multi-threaded contexts. + +template <class T> +class UniqueID { + static unsigned s_topID; + const unsigned d_thisID; + +public: + UniqueID() : d_thisID( s_topID++ ) { } + operator unsigned() const { return d_thisID; } +}; + +template <class T> +unsigned UniqueID<T>::s_topID = 0; + +} /* CVC4 namespace */ + +#endif /* __CVC4_UNIQUE_ID_H */ |