4 void replaceBooleanWithTrue(Boolean * This) {
5 uint size=getSizeVectorBoolean(&This->parents);
6 for(uint i=0;i<size;i++) {
7 Boolean * parent=getVectorBoolean(&This->parents, i);
8 BooleanLogic * logicop=(BooleanLogic*) parent;
11 handleANDTrue(logicop, This);
14 replaceBooleanWithTrue(parent);
17 replaceBooleanWithFalse(parent);
20 handleXORTrue(logicop, This);
23 handleIMPLIESTrue(logicop, This);
29 void replaceBooleanWithBoolean(Boolean *oldb, Boolean *newb) {
30 uint size=getSizeVectorBoolean(&oldb->parents);
31 for(uint i=0;i<size;i++) {
32 Boolean * parent=getVectorBoolean(&oldb->parents, i);
33 BooleanLogic * logicop=(BooleanLogic*) parent;
35 uint parentsize=getSizeArrayBoolean(&logicop->inputs);
37 for(uint j=0;j<parentsize;j++) {
38 Boolean *b=getArrayBoolean(&logicop->inputs, i);
40 setArrayBoolean(&logicop->inputs, i, newb);
41 pushVectorBoolean(&newb->parents, parent);
47 void handleXORTrue(BooleanLogic *This, Boolean *child) {
48 uint size=getSizeArrayBoolean(&This->inputs);
49 Boolean *b=getArrayBoolean(&This->inputs, 0);
50 uint otherindex=(b==child)?1:0;
51 removeElementArrayBoolean(&This->inputs, otherindex);
55 void handleXORFalse(BooleanLogic *This, Boolean *child) {
56 uint size=getSizeArrayBoolean(&This->inputs);
57 Boolean *b=getArrayBoolean(&This->inputs, 0);
58 uint otherindex=(b==child)?1:0;
59 replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, otherindex));
62 void handleIMPLIESTrue(BooleanLogic *This, Boolean *child) {
63 uint size=getSizeArrayBoolean(&This->inputs);
64 Boolean *b=getArrayBoolean(&This->inputs, 0);
66 //Replace with other term
67 replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 1));
69 //Statement is true...
70 replaceBooleanWithTrue((Boolean *)This);
74 void handleIMPLIESFalse(BooleanLogic *This, Boolean *child) {
75 uint size=getSizeArrayBoolean(&This->inputs);
76 Boolean *b=getArrayBoolean(&This->inputs, 0);
78 //Statement is true...
79 replaceBooleanWithTrue((Boolean *)This);
81 //Make into negation of first term
82 removeElementArrayBoolean(&This->inputs, 1);
87 void handleANDTrue(BooleanLogic *This, Boolean *child) {
88 uint size=getSizeArrayBoolean(&This->inputs);
91 replaceBooleanWithTrue((Boolean *)This);
95 for(uint i=0;i<size;i++) {
96 Boolean *b=getArrayBoolean(&This->inputs, i);
98 removeElementArrayBoolean(&This->inputs, i);
103 replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
107 void handleORFalse(BooleanLogic *This, Boolean *child) {
108 uint size=getSizeArrayBoolean(&This->inputs);
111 replaceBooleanWithFalse((Boolean*) This);
114 for(uint i=0;i<size;i++) {
115 Boolean *b=getArrayBoolean(&This->inputs, i);
117 removeElementArrayBoolean(&This->inputs, i);
122 replaceBooleanWithBoolean((Boolean *)This, getArrayBoolean(&This->inputs, 0));
126 void replaceBooleanWithFalse(Boolean * This) {
127 uint size=getSizeVectorBoolean(&This->parents);
128 for(uint i=0;i<size;i++) {
129 Boolean * parent=getVectorBoolean(&This->parents, i);
130 BooleanLogic * logicop=(BooleanLogic*) parent;
131 switch(logicop->op) {
133 replaceBooleanWithFalse(parent);
136 handleORFalse(logicop, This);
139 replaceBooleanWithTrue(parent);
142 handleXORFalse(logicop, This);
145 handleIMPLIESFalse(logicop, This);