summaryrefslogtreecommitdiff
path: root/src/prop
diff options
context:
space:
mode:
Diffstat (limited to 'src/prop')
-rw-r--r--src/prop/cnf_stream.cpp18
-rw-r--r--src/prop/cnf_stream.h7
-rw-r--r--src/prop/prop_engine.cpp4
3 files changed, 21 insertions, 8 deletions
diff --git a/src/prop/cnf_stream.cpp b/src/prop/cnf_stream.cpp
index e278c8175..65ed6caf6 100644
--- a/src/prop/cnf_stream.cpp
+++ b/src/prop/cnf_stream.cpp
@@ -21,6 +21,7 @@
#include "sat.h"
#include "prop/cnf_stream.h"
#include "prop/prop_engine.h"
+#include "theory/theory_engine.h"
#include "expr/node.h"
#include "util/Assert.h"
#include "util/output.h"
@@ -33,8 +34,8 @@ using namespace CVC4::kind;
namespace CVC4 {
namespace prop {
-CnfStream::CnfStream(SatInputInterface *satSolver) :
- d_satSolver(satSolver) {
+CnfStream::CnfStream(SatInputInterface *satSolver, theory::Registrar reg) :
+ d_satSolver(satSolver), d_registrar(reg) {
}
void CnfStream::recordTranslation(TNode node) {
@@ -45,8 +46,9 @@ void CnfStream::recordTranslation(TNode node) {
}
}
-TseitinCnfStream::TseitinCnfStream(SatInputInterface* satSolver) :
- CnfStream(satSolver) {
+
+TseitinCnfStream::TseitinCnfStream(SatInputInterface* satSolver, theory::Registrar reg) :
+ CnfStream(satSolver, reg) {
}
void CnfStream::assertClause(TNode node, SatClause& c) {
@@ -114,6 +116,12 @@ SatLiteral CnfStream::newLiteral(TNode node, bool theoryLiteral) {
// Here, you can have it
Debug("cnf") << "newLiteral(" << node << ") => " << lit << endl;
+ // have to keep track of this, because with the call to preRegister(),
+ // the cnf stream is re-entrant!
+ bool wasAssertingLemma = d_assertingLemma;
+ d_registrar.preRegister(node);
+ d_assertingLemma = wasAssertingLemma;
+
return lit;
}
@@ -147,7 +155,7 @@ SatLiteral CnfStream::convertAtom(TNode node) {
SatLiteral CnfStream::getLiteral(TNode node) {
TranslationCache::iterator find = d_translationCache.find(node);
- Assert(find != d_translationCache.end(), "Literal not in the CNF Cache: %s", node.toString().c_str());
+ Assert(find != d_translationCache.end(), "Literal not in the CNF Cache: %s\n", node.toString().c_str());
SatLiteral literal = find->second.literal;
Debug("cnf") << "CnfStream::getLiteral(" << node << ") => " << literal << std::endl;
return literal;
diff --git a/src/prop/cnf_stream.h b/src/prop/cnf_stream.h
index 9d152a915..929cae346 100644
--- a/src/prop/cnf_stream.h
+++ b/src/prop/cnf_stream.h
@@ -29,6 +29,7 @@
#include "expr/node.h"
#include "prop/sat.h"
+#include "theory/registrar.h"
#include <ext/hash_map>
@@ -70,6 +71,8 @@ private:
protected:
+ theory::Registrar d_registrar;
+
/** Top level nodes that we translated */
std::vector<TNode> d_translationTrail;
@@ -177,7 +180,7 @@ public:
* set of clauses and sends them to the given sat solver.
* @param satSolver the sat solver to use
*/
- CnfStream(SatInputInterface* satSolver);
+ CnfStream(SatInputInterface* satSolver, theory::Registrar r);
/**
* Destructs a CnfStream. This implementation does nothing, but we
@@ -252,7 +255,7 @@ public:
* Constructs the stream to use the given sat solver.
* @param satSolver the sat solver to use
*/
- TseitinCnfStream(SatInputInterface* satSolver);
+ TseitinCnfStream(SatInputInterface* satSolver, theory::Registrar reg);
private:
diff --git a/src/prop/prop_engine.cpp b/src/prop/prop_engine.cpp
index 4da3aa842..84e51d1d9 100644
--- a/src/prop/prop_engine.cpp
+++ b/src/prop/prop_engine.cpp
@@ -21,6 +21,7 @@
#include "sat.h"
#include "theory/theory_engine.h"
+#include "theory/registrar.h"
#include "util/Assert.h"
#include "util/options.h"
#include "util/output.h"
@@ -62,7 +63,8 @@ PropEngine::PropEngine(TheoryEngine* te, Context* context) :
d_context(context) {
Debug("prop") << "Constructing the PropEngine" << endl;
d_satSolver = new SatSolver(this, d_theoryEngine, d_context);
- d_cnfStream = new CVC4::prop::TseitinCnfStream(d_satSolver);
+ theory::Registrar reg(d_theoryEngine);
+ d_cnfStream = new CVC4::prop::TseitinCnfStream(d_satSolver, reg);
d_satSolver->setCnfStream(d_cnfStream);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback