#include "boolean.h"
#include "csolver.h"
-void replaceBooleanWithTrue(CSolver * This, Boolean *bexpr) {
- if (This->constraints.contains(bexpr)) {
- This->constraints.remove(bexpr);
+void CSolver::replaceBooleanWithTrue(Boolean *bexpr) {
+ if (constraints.contains(bexpr)) {
+ constraints.remove(bexpr);
}
uint size = bexpr->parents.getSize();
BooleanLogic *logicop = (BooleanLogic *) parent;
switch (logicop->op) {
case L_AND:
- handleANDTrue(This, logicop, bexpr);
+ handleANDTrue(logicop, bexpr);
break;
case L_OR:
- replaceBooleanWithTrue(This, parent);
+ replaceBooleanWithTrue(parent);
break;
case L_NOT:
- replaceBooleanWithFalse(This, parent);
+ replaceBooleanWithFalse(parent);
break;
case L_XOR:
handleXORTrue(logicop, bexpr);
break;
case L_IMPLIES:
- handleIMPLIESTrue(This, logicop, bexpr);
+ handleIMPLIESTrue(logicop, bexpr);
break;
}
}
}
-void replaceBooleanWithBoolean(CSolver * This, Boolean *oldb, Boolean *newb) {
- if (This->constraints.contains(oldb)) {
- This->constraints.remove(oldb);
- This->constraints.add(newb);
+void CSolver::replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb) {
+ if (constraints.contains(oldb)) {
+ constraints.remove(oldb);
+ constraints.add(newb);
}
uint size = oldb->parents.getSize();
bexpr->op = L_NOT;
}
-void handleXORFalse(CSolver * This, BooleanLogic *bexpr, Boolean *child) {
+void CSolver::handleXORFalse(BooleanLogic *bexpr, Boolean *child) {
uint size = bexpr->inputs.getSize();
Boolean *b = bexpr->inputs.get(0);
uint otherindex = (b == child) ? 1 : 0;
- replaceBooleanWithBoolean(This, (Boolean *)bexpr, bexpr->inputs.get(otherindex));
+ replaceBooleanWithBoolean(bexpr, bexpr->inputs.get(otherindex));
}
-void handleIMPLIESTrue(CSolver * This, BooleanLogic *bexpr, Boolean *child) {
+void CSolver::handleIMPLIESTrue(BooleanLogic *bexpr, Boolean *child) {
uint size = bexpr->inputs.getSize();
Boolean *b = bexpr->inputs.get(0);
if (b == child) {
//Replace with other term
- replaceBooleanWithBoolean(This, (Boolean *)bexpr, bexpr->inputs.get(1));
+ replaceBooleanWithBoolean(bexpr, bexpr->inputs.get(1));
} else {
//Statement is true...
- replaceBooleanWithTrue(This, (Boolean *)bexpr);
+ replaceBooleanWithTrue(bexpr);
}
}
-void handleIMPLIESFalse(CSolver * This, BooleanLogic *bexpr, Boolean *child) {
+void CSolver::handleIMPLIESFalse(BooleanLogic *bexpr, Boolean *child) {
uint size = bexpr->inputs.getSize();
Boolean *b = bexpr->inputs.get(0);
if (b == child) {
//Statement is true...
- replaceBooleanWithTrue(This, (Boolean *)bexpr);
+ replaceBooleanWithTrue(bexpr);
} else {
//Make into negation of first term
bexpr->inputs.get(1);
}
}
-void handleANDTrue(CSolver * This, BooleanLogic *bexpr, Boolean *child) {
+void CSolver::handleANDTrue(BooleanLogic *bexpr, Boolean *child) {
uint size = bexpr->inputs.getSize();
if (size == 1) {
- replaceBooleanWithTrue(This, (Boolean *)bexpr);
+ replaceBooleanWithTrue(bexpr);
return;
}
}
if (size == 2) {
- replaceBooleanWithBoolean(This, (Boolean *)bexpr, bexpr->inputs.get(0));
+ replaceBooleanWithBoolean(bexpr, bexpr->inputs.get(0));
}
}
-void handleORFalse(CSolver * This, BooleanLogic *bexpr, Boolean *child) {
+void CSolver::handleORFalse(BooleanLogic *bexpr, Boolean *child) {
uint size = bexpr->inputs.getSize();
if (size == 1) {
- replaceBooleanWithFalse(This, (Boolean *) bexpr);
+ replaceBooleanWithFalse(bexpr);
}
for (uint i = 0; i < size; i++) {
}
if (size == 2) {
- replaceBooleanWithBoolean(This, (Boolean *)bexpr, bexpr->inputs.get(0));
+ replaceBooleanWithBoolean(bexpr, bexpr->inputs.get(0));
}
}
-void replaceBooleanWithFalse(CSolver * This, Boolean *bexpr) {
- if (This->constraints.contains(bexpr)) {
- This->unsat=true;
- This->constraints.remove(bexpr);
+void CSolver::replaceBooleanWithFalse(Boolean *bexpr) {
+ if (constraints.contains(bexpr)) {
+ setUnSAT();
+ constraints.remove(bexpr);
}
uint size = bexpr->parents.getSize();
BooleanLogic *logicop = (BooleanLogic *) parent;
switch (logicop->op) {
case L_AND:
- replaceBooleanWithFalse(This, parent);
+ replaceBooleanWithFalse(parent);
break;
case L_OR:
- handleORFalse(This, logicop, bexpr);
+ handleORFalse(logicop, bexpr);
break;
case L_NOT:
- replaceBooleanWithTrue(This, parent);
+ replaceBooleanWithTrue(parent);
break;
case L_XOR:
- handleXORFalse(This, logicop, bexpr);
+ handleXORFalse(logicop, bexpr);
break;
case L_IMPLIES:
- handleIMPLIESFalse(This, logicop, bexpr);
+ handleIMPLIESFalse(logicop, bexpr);
break;
}
}