summaryrefslogtreecommitdiff
path: root/src/prop
diff options
context:
space:
mode:
authorDejan Jovanović <dejan.jovanovic@gmail.com>2010-02-13 00:55:40 +0000
committerDejan Jovanović <dejan.jovanovic@gmail.com>2010-02-13 00:55:40 +0000
commite063e5258a2a223cc0ab3aee3cb30041c4b907f8 (patch)
tree98e6d620ad51124f3a3b8811aa76a47ea530802f /src/prop
parentadf6398383d94fa4f68ef9ba50c29ea9b6ac68e1 (diff)
Improvements to CNF conversion when already in CNF
Diffstat (limited to 'src/prop')
-rw-r--r--src/prop/cnf_stream.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/prop/cnf_stream.cpp b/src/prop/cnf_stream.cpp
index 011d8ba5a..a96d499b6 100644
--- a/src/prop/cnf_stream.cpp
+++ b/src/prop/cnf_stream.cpp
@@ -318,6 +318,28 @@ SatLiteral TseitinCnfStream::toCNF(const Node& node) {
void TseitinCnfStream::convertAndAssert(const Node& node) {
Debug("cnf") << "convertAndAssert(" << node << ")" << endl;
+ // If the node is a conjuntion, we handle each conjunct separatelu
+ if (node.getKind() == AND) {
+ Node::iterator conjunct = node.begin();
+ Node::iterator node_end = node.end();
+ while (conjunct != node_end) {
+ convertAndAssert(*conjunct);
+ ++ conjunct;
+ }
+ return;
+ }
+ // If the node is a disjunction, we construct a clause and assert it
+ if (node.getKind() == OR) {
+ int nChildren = node.getNumChildren();
+ SatClause clause(nChildren);
+ Node::iterator disjunct = node.begin();
+ for (int i = 0; i < nChildren; ++ disjunct, ++ i) {
+ clause[i] = toCNF(*disjunct);
+ }
+ assertClause(clause);
+ return;
+ }
+ // Otherwise, we just convert using the definitional transformation
assertClause(toCNF(node));
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback