1 /********************* -*- C++ -*- */
3 ** Original author: mdeters
4 ** Major contributors: dejan
5 ** Minor contributors (to current version): none
6 ** This file is part of the CVC4 prototype.
7 ** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
8 ** Courant Institute of Mathematical Sciences
10 ** See the file COPYING in the top-level source directory for licensing
13 ** SmtEngine: the main public entry point of libcvc4.
16 #ifndef __CVC4__SMT_ENGINE_H
17 #define __CVC4__SMT_ENGINE_H
21 #include "cvc4_config.h"
22 #include "expr/node.h"
23 #include "expr/expr.h"
24 #include "expr/node_manager.h"
25 #include "expr/expr_manager.h"
26 #include "util/result.h"
27 #include "util/model.h"
28 #include "util/options.h"
29 #include "prop/prop_engine.h"
30 #include "util/decision_engine.h"
32 // In terms of abstraction, this is below (and provides services to)
33 // ValidityChecker and above (and requires the services of)
40 // TODO: SAT layer (esp. CNF- versus non-clausal solvers under the
41 // hood): use a type parameter and have check() delegate, or subclass
42 // SmtEngine and override check()?
44 // Probably better than that is to have a configuration object that
45 // indicates which passes are desired. The configuration occurs
46 // elsewhere (and can even occur at runtime). A simple "pass manager"
47 // of sorts determines check()'s behavior.
49 // The CNF conversion can go on in PropEngine.
51 class CVC4_PUBLIC SmtEngine
{
56 * Construct an SmtEngine with the given expression manager and user options.
58 SmtEngine(ExprManager
* em
, Options
* opts
) throw();
61 * Destruct the smt engine.
68 void doCommand(Command
*);
71 * Add a formula to the current context: preprocess, do per-theory
72 * setup, use processAssertionList(), asserting to T-solver for
73 * literals and conjunction of literals. Returns false iff
76 Result
assertFormula(const BoolExpr
& e
);
79 * Add a formula to the current context and call check(). Returns
80 * true iff consistent.
82 Result
query(const BoolExpr
& e
);
85 * Add a formula to the current context and call check(). Returns
86 * true iff consistent.
88 Result
checkSat(const BoolExpr
& e
);
91 * Simplify a formula without doing "much" work. Requires assist
92 * from the SAT Engine.
94 Expr
simplify(const Expr
& e
);
97 * Get a (counter)model (only if preceded by a SAT or INVALID query.
102 * Push a user-level context.
107 * Pop a user-level context. Throws an exception if nothing to pop.
113 /** Current set of assertions. */
114 // TODO: make context-aware to handle user-level push/pop.
115 std::vector
<Node
> d_assertions
;
117 /** Our expression manager */
118 ExprManager
*d_public_em
;
120 /** Out internal expression/node manager */
123 /** User-level options */
126 /** The decision engine */
129 /** The decision engine */
132 /** The propositional engine */
136 * Pre-process an Node. This is expected to be highly-variable,
137 * with a lot of "source-level configurability" to add multiple
138 * passes over the Node. TODO: may need to specify a LEVEL of
139 * preprocessing (certain contexts need more/less ?).
141 Node
preprocess(const Node
& e
);
144 * Adds a formula to the current context.
146 void addFormula(const Node
& e
);
149 * Full check of consistency in current context. Returns true iff
155 * Quick check of consistency in current context: calls
156 * processAssertionList() then look for inconsistency (based only on
162 * Process the assertion list: for literals and conjunctions of
163 * literals, assert to T-solver.
165 Node
processAssertionList();
168 };/* class SmtEngine */
170 }/* CVC4 namespace */
172 #endif /* __CVC4__SMT_ENGINE_H */