summaryrefslogtreecommitdiff
path: root/src/smt
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-11-25 23:03:11 -0600
committerGitHub <noreply@github.com>2020-11-25 23:03:11 -0600
commitc41a2e9be2422a211b9687833c97ba37485cd946 (patch)
tree6e7f88a41d6bbb2581762de203f66086fe16ed49 /src/smt
parentd0c352ec04846353d630073e78e5b2fea92133c2 (diff)
Fully decouple SmtEngine and the Expr layer (#5532)
This removes the remaining dependencies of SmtEngine on the Expr layer. It now takes a NodeManager instead of a ExprManager.
Diffstat (limited to 'src/smt')
-rw-r--r--src/smt/command.cpp4
-rw-r--r--src/smt/smt_engine.cpp34
-rw-r--r--src/smt/smt_engine.h22
3 files changed, 20 insertions, 40 deletions
diff --git a/src/smt/command.cpp b/src/smt/command.cpp
index 154166eb7..fa3eb66c0 100644
--- a/src/smt/command.cpp
+++ b/src/smt/command.cpp
@@ -1442,8 +1442,8 @@ void SetUserAttributeCommand::invoke(api::Solver* solver, SymbolManager* sm)
{
solver->getSmtEngine()->setUserAttribute(
d_attr,
- d_term.getExpr(),
- api::termVectorToExprs(d_termValues),
+ d_term.getNode(),
+ api::termVectorToNodes(d_termValues),
d_strValue);
}
d_commandStatus = CommandSuccess::instance();
diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp
index 1d623fdef..161c2eba6 100644
--- a/src/smt/smt_engine.cpp
+++ b/src/smt/smt_engine.cpp
@@ -73,10 +73,9 @@ using namespace CVC4::theory;
namespace CVC4 {
-SmtEngine::SmtEngine(ExprManager* em, Options* optr)
+SmtEngine::SmtEngine(NodeManager* nm, Options* optr)
: d_state(new SmtEngineState(*this)),
- d_exprManager(em),
- d_nodeManager(d_exprManager->getNodeManager()),
+ d_nodeManager(nm),
d_absValues(new AbstractValues(d_nodeManager)),
d_asserts(new Assertions(getUserContext(), *d_absValues.get())),
d_dumpm(new DumpManager(getUserContext())),
@@ -525,14 +524,8 @@ CVC4::SExpr SmtEngine::getInfo(const std::string& key) const
if (key == "all-statistics")
{
vector<SExpr> stats;
- for (StatisticsRegistry::const_iterator i =
- NodeManager::fromExprManager(d_exprManager)
- ->getStatisticsRegistry()
- ->begin();
- i
- != NodeManager::fromExprManager(d_exprManager)
- ->getStatisticsRegistry()
- ->end();
+ StatisticsRegistry* sr = d_nodeManager->getStatisticsRegistry();
+ for (StatisticsRegistry::const_iterator i = sr->begin(); i != sr->end();
++i)
{
vector<SExpr> v;
@@ -1637,7 +1630,6 @@ void SmtEngine::pop() {
void SmtEngine::reset()
{
SmtScope smts(this);
- ExprManager *em = d_exprManager;
Trace("smt") << "SMT reset()" << endl;
if(Dump.isOn("benchmark")) {
getOutputManager().getPrinter().toStreamCmdReset(
@@ -1647,7 +1639,7 @@ void SmtEngine::reset()
Options opts;
opts.copyValues(d_originalOptions);
this->~SmtEngine();
- new (this) SmtEngine(em, &opts);
+ new (this) SmtEngine(d_nodeManager, &opts);
// Restore data set after creation
notifyStartParsing(filename);
}
@@ -1713,10 +1705,7 @@ unsigned long SmtEngine::getResourceRemaining() const
return d_resourceManager->getResourceRemaining();
}
-NodeManager* SmtEngine::getNodeManager() const
-{
- return d_exprManager->getNodeManager();
-}
+NodeManager* SmtEngine::getNodeManager() const { return d_nodeManager; }
Statistics SmtEngine::getStatistics() const
{
@@ -1733,20 +1722,15 @@ void SmtEngine::safeFlushStatistics(int fd) const {
}
void SmtEngine::setUserAttribute(const std::string& attr,
- Expr expr,
- const std::vector<Expr>& expr_values,
+ Node expr,
+ const std::vector<Node>& expr_values,
const std::string& str_value)
{
SmtScope smts(this);
finishInit();
- std::vector<Node> node_values;
- for (std::size_t i = 0, n = expr_values.size(); i < n; i++)
- {
- node_values.push_back( expr_values[i].getNode() );
- }
TheoryEngine* te = getTheoryEngine();
Assert(te != nullptr);
- te->setUserAttribute(attr, expr.getNode(), node_values, str_value);
+ te->setUserAttribute(attr, expr, expr_values, str_value);
}
void SmtEngine::setOption(const std::string& key, const CVC4::SExpr& value)
diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h
index 1c83fa61f..a55428b55 100644
--- a/src/smt/smt_engine.h
+++ b/src/smt/smt_engine.h
@@ -21,13 +21,12 @@
#include <string>
#include <vector>
+#include <map>
#include "base/modal_exception.h"
#include "context/cdhashmap_forward.h"
#include "context/cdhashset_forward.h"
#include "context/cdlist_forward.h"
-#include "expr/expr.h"
-#include "expr/expr_manager.h"
#include "options/options.h"
#include "smt/logic_exception.h"
#include "smt/output_manager.h"
@@ -48,9 +47,10 @@ namespace CVC4 {
template <bool ref_count> class NodeTemplate;
typedef NodeTemplate<true> Node;
typedef NodeTemplate<false> TNode;
+class TypeNode;
struct NodeHashFunction;
-class SmtEngine;
+class NodeManager;
class DecisionEngine;
class TheoryEngine;
class ProofManager;
@@ -58,6 +58,7 @@ class UnsatCore;
class LogicRequest;
class StatisticsRegistry;
class Printer;
+class ResourceManager;
/* -------------------------------------------------------------------------- */
@@ -147,7 +148,7 @@ class CVC4_PUBLIC SmtEngine
* If provided, optr is a pointer to a set of options that should initialize the values
* of the options object owned by this class.
*/
- SmtEngine(ExprManager* em, Options* optr = nullptr);
+ SmtEngine(NodeManager* nm, Options* optr = nullptr);
/** Destruct the SMT engine. */
~SmtEngine();
@@ -691,7 +692,7 @@ class CVC4_PUBLIC SmtEngine
/**
* Completely reset the state of the solver, as though destroyed and
* recreated. The result is as if newly constructed (so it still
- * retains the same options structure and ExprManager).
+ * retains the same options structure and NodeManager).
*/
void reset();
@@ -785,9 +786,6 @@ class CVC4_PUBLIC SmtEngine
*/
unsigned long getResourceRemaining() const;
- /** Permit access to the underlying ExprManager. */
- ExprManager* getExprManager() const { return d_exprManager; }
-
/** Permit access to the underlying NodeManager. */
NodeManager* getNodeManager() const;
@@ -806,8 +804,8 @@ class CVC4_PUBLIC SmtEngine
* In SMT-LIBv2 this is done via the syntax (! expr :attr)
*/
void setUserAttribute(const std::string& attr,
- Expr expr,
- const std::vector<Expr>& expr_values,
+ Node expr,
+ const std::vector<Node>& expr_values,
const std::string& str_value);
/** Get the options object (const and non-const versions) */
@@ -1013,9 +1011,7 @@ class CVC4_PUBLIC SmtEngine
*/
std::unique_ptr<smt::SmtEngineState> d_state;
- /** Our expression manager */
- ExprManager* d_exprManager;
- /** Our internal expression/node manager */
+ /** Our internal node manager */
NodeManager* d_nodeManager;
/** Abstract values */
std::unique_ptr<smt::AbstractValues> d_absValues;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback