summaryrefslogtreecommitdiff
path: root/src/smt
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
committerMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
commit88b52c971b43248e6ceacf1c8140a06427d0418d (patch)
tree4ee443c898a858fcdd658f3f043e4180eddd8784 /src/smt
parent29cc307cdf2c42bebf4f5615874a864783f47fd0 (diff)
* public/private code untangled (smt/smt_engine.h no longer #includes
expr/node.h). This removes the warnings we had during compilation, and heads off a number of potential linking errors due to improper inlining of private (library-only) stuff in client (out-of-library) code. * "configure" now takes some options as part of a "bare-option" build type (e.g., "./configure debug-coverage" or "./configure production-muzzle"). * split cdo.h, cdlist.h, cdmap.h, and cdset.h from context.h * split cdlist_black unit test from context_black * implement CDMap<>. * give ExprManagers ownership of the context (and have SmtEngine share that one) * fix main driver to properly report file-not-found * fix MemoryMappedInputBuffer class to report reasons for "errno"-returned system errors * src/expr/attribute.h: context-dependent attribute kinds now supported * test/unit/expr/node_white.h: context-dependent attribute tests * src/prop/cnf_conversion.h and associated parts of src/util/options.h and src/main/getopt.cpp: obsolete command-line option, removed. * src/util/Assert.h: assertions are now somewhat more useful (in debug builds, anyway) during stack unwinding. * test/unit/theory/theory_black.h: test context-dependent behavior of registerTerm() attribute for theories * src/expr/node_builder.h: formatting, fixes for arithmetic convenience node builders, check memory allocations * test/unit/expr/node_builder_black.h: add tessts for addition, subtraction, unary minus, and multiplication convenience node builders * src/expr/attribute.h: more comments * (various) code formatting, comment cleanup, added throws specifier to some destructors * contrib/code-checker: prototype perl script to test (some) code policy * contrib/indent-settings: command line for GNU indent to indent using CVC4 style (sort of; this is a work in progress) * COPYING: legal stuff * DESIGN_QUESTIONS: obsolete, removed
Diffstat (limited to 'src/smt')
-rw-r--r--src/smt/smt_engine.cpp53
-rw-r--r--src/smt/smt_engine.h28
2 files changed, 56 insertions, 25 deletions
diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp
index c45314a55..8def3e279 100644
--- a/src/smt/smt_engine.cpp
+++ b/src/smt/smt_engine.cpp
@@ -25,8 +25,45 @@ using CVC4::context::Context;
namespace CVC4 {
+namespace smt {
+
+/**
+ * This is an inelegant solution, but for the present, it will work.
+ * The point of this is to separate the public and private portions of
+ * the SmtEngine class, so that smt_engine.h doesn't
+ * #include "expr/node.h", which is a private CVC4 header (and can lead
+ * to linking errors due to the improper inlining of non-visible symbols
+ * into user code!).
+ *
+ * The "real" solution (that which is usually implemented) is to move
+ * ALL the implementation to SmtEnginePrivate and maintain a
+ * heap-allocated instance of it in SmtEngine. SmtEngine (the public
+ * one) becomes an "interface shell" which simply acts as a forwarder
+ * of method calls.
+ */
+class SmtEnginePrivate {
+public:
+
+ /**
+ * Pre-process an Node. This is expected to be highly-variable,
+ * with a lot of "source-level configurability" to add multiple
+ * passes over the Node. TODO: may need to specify a LEVEL of
+ * preprocessing (certain contexts need more/less ?).
+ */
+ static Node preprocess(SmtEngine& smt, TNode node);
+
+ /**
+ * Adds a formula to the current context.
+ */
+ static void addFormula(SmtEngine& smt, TNode node);
+};/* class SmtEnginePrivate */
+
+}/* namespace CVC4::smt */
+
+using ::CVC4::smt::SmtEnginePrivate;
+
SmtEngine::SmtEngine(ExprManager* em, const Options* opts) throw () :
- d_ctxt(new Context),
+ d_ctxt(em->getContext()),
d_exprManager(em),
d_nodeManager(em->getNodeManager()),
d_options(opts) {
@@ -37,10 +74,10 @@ SmtEngine::SmtEngine(ExprManager* em, const Options* opts) throw () :
}
SmtEngine::~SmtEngine() {
+ NodeManagerScope nms(d_nodeManager);
delete d_propEngine;
delete d_theoryEngine;
delete d_decisionEngine;
- delete d_ctxt;
}
void SmtEngine::doCommand(Command* c) {
@@ -48,7 +85,7 @@ void SmtEngine::doCommand(Command* c) {
c->invoke(this);
}
-Node SmtEngine::preprocess(TNode e) {
+Node SmtEnginePrivate::preprocess(SmtEngine& smt, TNode e) {
return e;
}
@@ -62,15 +99,15 @@ Result SmtEngine::quickCheck() {
return Result(Result::VALIDITY_UNKNOWN);
}
-void SmtEngine::addFormula(TNode e) {
+void SmtEnginePrivate::addFormula(SmtEngine& smt, TNode e) {
Debug("smt") << "push_back assertion " << e << std::endl;
- d_propEngine->assertFormula(preprocess(e));
+ smt.d_propEngine->assertFormula(SmtEnginePrivate::preprocess(smt, e));
}
Result SmtEngine::checkSat(const BoolExpr& e) {
NodeManagerScope nms(d_nodeManager);
Debug("smt") << "SMT checkSat(" << e << ")" << std::endl;
- addFormula(e.getNode());
+ SmtEnginePrivate::addFormula(*this, e.getNode());
Result r = check().asSatisfiabilityResult();
Debug("smt") << "SMT checkSat(" << e << ") ==> " << r << std::endl;
return r;
@@ -79,7 +116,7 @@ Result SmtEngine::checkSat(const BoolExpr& e) {
Result SmtEngine::query(const BoolExpr& e) {
NodeManagerScope nms(d_nodeManager);
Debug("smt") << "SMT query(" << e << ")" << std::endl;
- addFormula(e.getNode().notNode());
+ SmtEnginePrivate::addFormula(*this, e.getNode().notNode());
Result r = check().asValidityResult();
Debug("smt") << "SMT query(" << e << ") ==> " << r << std::endl;
return r;
@@ -88,7 +125,7 @@ Result SmtEngine::query(const BoolExpr& e) {
Result SmtEngine::assertFormula(const BoolExpr& e) {
NodeManagerScope nms(d_nodeManager);
Debug("smt") << "SMT assertFormula(" << e << ")" << std::endl;
- addFormula(e.getNode());
+ SmtEnginePrivate::addFormula(*this, e.getNode());
return quickCheck().asValidityResult();
}
diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h
index 7495e4100..36cb8746c 100644
--- a/src/smt/smt_engine.h
+++ b/src/smt/smt_engine.h
@@ -24,9 +24,6 @@
#include "util/result.h"
#include "util/model.h"
-// FIXME private header in public code
-#include "expr/node.h"
-
// In terms of abstraction, this is below (and provides services to)
// ValidityChecker and above (and requires the services of)
// PropEngine.
@@ -35,7 +32,7 @@ namespace CVC4 {
namespace context {
class Context;
-}
+}/* CVC4::context namespace */
class Command;
class Options;
@@ -44,7 +41,11 @@ class DecisionEngine;
namespace prop {
class PropEngine;
-}
+}/* CVC4::prop namespace */
+
+namespace smt {
+ class SmtEnginePrivate;
+}/* CVC4::smt namespace */
// TODO: SAT layer (esp. CNF- versus non-clausal solvers under the
// hood): use a type parameter and have check() delegate, or subclass
@@ -140,18 +141,9 @@ private:
/** The propositional engine */
prop::PropEngine* d_propEngine;
- /**
- * Pre-process an Node. This is expected to be highly-variable,
- * with a lot of "source-level configurability" to add multiple
- * passes over the Node. TODO: may need to specify a LEVEL of
- * preprocessing (certain contexts need more/less ?).
- */
- Node preprocess(TNode node);
-
- /**
- * Adds a formula to the current context.
- */
- void addFormula(TNode node);
+ // preprocess() and addFormula() used to be housed here; they are
+ // now in an SmtEnginePrivate class. See the comment in
+ // smt_engine.cpp.
/**
* Full check of consistency in current context. Returns true iff
@@ -166,6 +158,8 @@ private:
*/
Result quickCheck();
+ friend class ::CVC4::smt::SmtEnginePrivate;
+
};/* class SmtEngine */
}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback