From: Morgan Deters Date: Tue, 17 Nov 2009 17:09:13 +0000 (+0000) Subject: from meeting X-Git-Tag: cvc5-1.0.0~9423 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=105503064be6a198dd864d1e95d6d79e1af51d25;p=cvc5.git from meeting --- diff --git a/src/core/assert.h b/src/core/assert.h deleted file mode 100644 index a66503641..000000000 --- a/src/core/assert.h +++ /dev/null @@ -1,26 +0,0 @@ -/********************* -*- 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 - -#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/core/command.h b/src/core/command.h deleted file mode 100644 index 944b9c621..000000000 --- a/src/core/command.h +++ /dev/null @@ -1,22 +0,0 @@ -/********************* -*- 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/core/debug.h b/src/core/debug.h deleted file mode 100644 index 36942d1ae..000000000 --- a/src/core/debug.h +++ /dev/null @@ -1,26 +0,0 @@ -/********************* -*- 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 - -#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/core/decision_engine.h b/src/core/decision_engine.h deleted file mode 100644 index 81d820eaa..000000000 --- a/src/core/decision_engine.h +++ /dev/null @@ -1,42 +0,0 @@ -/********************* -*- 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/core/exception.h b/src/core/exception.h deleted file mode 100644 index 792a98701..000000000 --- a/src/core/exception.h +++ /dev/null @@ -1,48 +0,0 @@ -/********************* -*- 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 -#include - -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/core/literal.h b/src/core/literal.h deleted file mode 100644 index 8b147c640..000000000 --- a/src/core/literal.h +++ /dev/null @@ -1,21 +0,0 @@ -/********************* -*- 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/core/model.h b/src/core/model.h deleted file mode 100644 index c07b75dfa..000000000 --- a/src/core/model.h +++ /dev/null @@ -1,22 +0,0 @@ -/********************* -*- 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/core/prop_engine.h b/src/core/prop_engine.h deleted file mode 100644 index 0febd2927..000000000 --- a/src/core/prop_engine.h +++ /dev/null @@ -1,43 +0,0 @@ -/********************* -*- C++ -*- */ -/** prop_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_PROP_ENGINE_H -#define __CVC4_PROP_ENGINE_H - -#include "core/cvc4_expr.h" -#include "core/decision_engine.h" -#include "core/theory_engine.h" - -namespace CVC4 { - -// In terms of abstraction, this is below (and provides services to) -// Prover and above (and requires the services of) a specific -// propositional solver, DPLL or otherwise. - -class PropEngine { - DecisionEngine* d_de; - -public: - /** - * Create a PropEngine with a particular decision and theory engine. - */ - PropEngine(DecisionEngine*, TheoryEngine*); - - /** - * Converts to CNF if necessary. - */ - void solve(Expr); - -};/* class PropEngine */ - -} - -#endif /* __CVC4_PROP_ENGINE_H */ diff --git a/src/core/prover.h b/src/core/prover.h deleted file mode 100644 index 14eab7c03..000000000 --- a/src/core/prover.h +++ /dev/null @@ -1,114 +0,0 @@ -/********************* -*- C++ -*- */ -/** prover.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_PROVER_H -#define __CVC4_PROVER_H - -#include -#include "core/cvc4_expr.h" -#include "core/result.h" -#include "core/model.h" - -// In terms of abstraction, this is below (and provides services to) -// ValidityChecker and above (and requires the services of) -// PropEngine. - -namespace CVC4 { - -// TODO: SAT layer (esp. CNF- versus non-clausal solvers under the -// hood): use a type parameter and have check() delegate, or subclass -// Prover and override check()? -// -// Probably better than that is to have a configuration object that -// indicates which passes are desired. The configuration occurs -// elsewhere (and can even occur at runtime). A simple "pass manager" -// of sorts determines check()'s behavior. -// -// The CNF conversion can go on in PropEngine. - -class Prover { - /** Current set of assertions. */ - // TODO: make context-aware to handle user-level push/pop. - std::vector d_assertList; - -private: - /** - * Pre-process an Expr. This is expected to be highly-variable, - * with a lot of "source-level configurability" to add multiple - * passes over the Expr. TODO: may need to specify a LEVEL of - * preprocessing (certain contexts need more/less ?). - */ - void preprocess(Expr); - - /** - * Adds a formula to the current context. - */ - void addFormula(Expr); - - /** - * Full check of consistency in current context. Returns true iff - * consistent. - */ - Result check(); - - /** - * Quick check of consistency in current context: calls - * processAssertionList() then look for inconsistency (based only on - * that). - */ - Result quickCheck(); - - /** - * Process the assertion list: for literals and conjunctions of - * literals, assert to T-solver. - */ - void processAssertionList(); - -public: - /** - * Add a formula to the current context: preprocess, do per-theory - * setup, use processAssertionList(), asserting to T-solver for - * literals and conjunction of literals. Returns false iff - * inconsistent. - */ - Result assert(Expr); - - /** - * Add a formula to the current context and call check(). Returns - * true iff consistent. - */ - Result query(Expr); - - /** - * Simplify a formula without doing "much" work. Requires assist - * from the SAT Engine. - */ - Expr simplify(Expr); - - /** - * Get a (counter)model (only if preceded by a SAT or INVALID query. - */ - Model getModel(); - - /** - * Push a user-level context. - */ - void push(); - - /** - * Pop a user-level context. Throws an exception if nothing to pop. - */ - void pop(); -};/* class Prover */ - -} /* CVC4 namespace */ - -#endif /* __CVC4_PROVER_H */ diff --git a/src/core/result.h b/src/core/result.h deleted file mode 100644 index 50f488682..000000000 --- a/src/core/result.h +++ /dev/null @@ -1,65 +0,0 @@ -/********************* -*- 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/core/sat.h b/src/core/sat.h deleted file mode 100644 index 00a94c142..000000000 --- a/src/core/sat.h +++ /dev/null @@ -1,19 +0,0 @@ -/********************* -*- C++ -*- */ -/** sat.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_SAT_H -#define __CVC4_SAT_H - -namespace CVC4 { - -} /* CVC4 namespace */ - -#endif /* __CVC4_SAT_H */ diff --git a/src/core/unique_id.h b/src/core/unique_id.h deleted file mode 100644 index 1a6f3427a..000000000 --- a/src/core/unique_id.h +++ /dev/null @@ -1,35 +0,0 @@ -/********************* -*- 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 UniqueID { - static unsigned s_topID; - const unsigned d_thisID; - -public: - UniqueID() : d_thisID( s_topID++ ) { } - operator unsigned() const { return d_thisID; } -}; - -template -unsigned UniqueID::s_topID = 0; - -} /* CVC4 namespace */ - -#endif /* __CVC4_UNIQUE_ID_H */ diff --git a/src/prop/prop_engine.h b/src/prop/prop_engine.h new file mode 100644 index 000000000..0febd2927 --- /dev/null +++ b/src/prop/prop_engine.h @@ -0,0 +1,43 @@ +/********************* -*- C++ -*- */ +/** prop_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_PROP_ENGINE_H +#define __CVC4_PROP_ENGINE_H + +#include "core/cvc4_expr.h" +#include "core/decision_engine.h" +#include "core/theory_engine.h" + +namespace CVC4 { + +// In terms of abstraction, this is below (and provides services to) +// Prover and above (and requires the services of) a specific +// propositional solver, DPLL or otherwise. + +class PropEngine { + DecisionEngine* d_de; + +public: + /** + * Create a PropEngine with a particular decision and theory engine. + */ + PropEngine(DecisionEngine*, TheoryEngine*); + + /** + * Converts to CNF if necessary. + */ + void solve(Expr); + +};/* class PropEngine */ + +} + +#endif /* __CVC4_PROP_ENGINE_H */ diff --git a/src/prop/sat.h b/src/prop/sat.h new file mode 100644 index 000000000..00a94c142 --- /dev/null +++ b/src/prop/sat.h @@ -0,0 +1,19 @@ +/********************* -*- C++ -*- */ +/** sat.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_SAT_H +#define __CVC4_SAT_H + +namespace CVC4 { + +} /* CVC4 namespace */ + +#endif /* __CVC4_SAT_H */ diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h new file mode 100644 index 000000000..6f6fb355a --- /dev/null +++ b/src/smt/smt_engine.h @@ -0,0 +1,114 @@ +/********************* -*- C++ -*- */ +/** prover.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_PROVER_H +#define __CVC4_PROVER_H + +#include +#include "core/cvc4_expr.h" +#include "core/result.h" +#include "core/model.h" + +// In terms of abstraction, this is below (and provides services to) +// ValidityChecker and above (and requires the services of) +// PropEngine. + +namespace CVC4 { + +// TODO: SAT layer (esp. CNF- versus non-clausal solvers under the +// hood): use a type parameter and have check() delegate, or subclass +// SmtEngine and override check()? +// +// Probably better than that is to have a configuration object that +// indicates which passes are desired. The configuration occurs +// elsewhere (and can even occur at runtime). A simple "pass manager" +// of sorts determines check()'s behavior. +// +// The CNF conversion can go on in PropEngine. + +class SmtEngine { + /** Current set of assertions. */ + // TODO: make context-aware to handle user-level push/pop. + std::vector d_assertList; + +private: + /** + * Pre-process an Expr. This is expected to be highly-variable, + * with a lot of "source-level configurability" to add multiple + * passes over the Expr. TODO: may need to specify a LEVEL of + * preprocessing (certain contexts need more/less ?). + */ + void preprocess(Expr); + + /** + * Adds a formula to the current context. + */ + void addFormula(Expr); + + /** + * Full check of consistency in current context. Returns true iff + * consistent. + */ + Result check(); + + /** + * Quick check of consistency in current context: calls + * processAssertionList() then look for inconsistency (based only on + * that). + */ + Result quickCheck(); + + /** + * Process the assertion list: for literals and conjunctions of + * literals, assert to T-solver. + */ + void processAssertionList(); + +public: + /** + * Add a formula to the current context: preprocess, do per-theory + * setup, use processAssertionList(), asserting to T-solver for + * literals and conjunction of literals. Returns false iff + * inconsistent. + */ + Result assert(Expr); + + /** + * Add a formula to the current context and call check(). Returns + * true iff consistent. + */ + Result query(Expr); + + /** + * Simplify a formula without doing "much" work. Requires assist + * from the SAT Engine. + */ + Expr simplify(Expr); + + /** + * Get a (counter)model (only if preceded by a SAT or INVALID query. + */ + Model getModel(); + + /** + * Push a user-level context. + */ + void push(); + + /** + * Pop a user-level context. Throws an exception if nothing to pop. + */ + void pop(); +};/* class SmtEngine */ + +} /* CVC4 namespace */ + +#endif /* __CVC4_PROVER_H */ 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 + +#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 + +#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 +#include + +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 UniqueID { + static unsigned s_topID; + const unsigned d_thisID; + +public: + UniqueID() : d_thisID( s_topID++ ) { } + operator unsigned() const { return d_thisID; } +}; + +template +unsigned UniqueID::s_topID = 0; + +} /* CVC4 namespace */ + +#endif /* __CVC4_UNIQUE_ID_H */