diff options
author | Christopher L. Conway <christopherleeconway@gmail.com> | 2010-05-13 05:30:30 +0000 |
---|---|---|
committer | Christopher L. Conway <christopherleeconway@gmail.com> | 2010-05-13 05:30:30 +0000 |
commit | 8394cecaf2b1a261b44af54501ef1a433cdbadc2 (patch) | |
tree | d4af6dec9e07b2406a84785eea73a1480c91580f /src/prop/sat.cpp | |
parent | 7730b9562b11d13236ce566f15ede0cb3416fe21 (diff) |
Minor refactorings to PropEngine, SatSolver
Diffstat (limited to 'src/prop/sat.cpp')
-rw-r--r-- | src/prop/sat.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/prop/sat.cpp b/src/prop/sat.cpp new file mode 100644 index 000000000..c578cf361 --- /dev/null +++ b/src/prop/sat.cpp @@ -0,0 +1,43 @@ +#include "cnf_stream.h" +#include "prop_engine.h" +#include "sat.h" +#include "context/context.h" +#include "theory/theory_engine.h" + +namespace CVC4 { +namespace prop { + +void SatSolver::theoryCheck(SatClause& conflict) { + // Try theory propagation + if (!d_theoryEngine->check(theory::Theory::FULL_EFFORT)) { + // We have a conflict, get it + Node conflictNode = d_theoryEngine->getConflict(); + Debug("prop") << "SatSolver::theoryCheck() => conflict: " << conflictNode << std::endl; + // Go through the literals and construct the conflict clause + Node::const_iterator literal_it = conflictNode.begin(); + Node::const_iterator literal_end = conflictNode.end(); + while (literal_it != literal_end) { + // Get the literal corresponding to the node + SatLiteral l = d_cnfStream->getLiteral(*literal_it); + // Add the negation to the conflict clause and continue + conflict.push(~l); + literal_it ++; + } + } +} + +void SatSolver::enqueueTheoryLiteral(const SatLiteral& l) { + Node literalNode = d_cnfStream->getNode(l); + // We can get null from the prop engine if the literal is useless (i.e.) + // the expression is not in context anyomore + if(!literalNode.isNull()) { + d_theoryEngine->assertFact(literalNode); + } +} + +void SatSolver::setCnfStream(CnfStream* cnfStream) { + d_cnfStream = cnfStream; +} + +}/* CVC4::prop namespace */ +}/* CVC4 namespace */ |