96
|
1 |
|
|
2 |
package G4ip;
|
|
3 |
|
|
4 |
/** Class for propositional formulae.<p>
|
|
5 |
* @author Christian Urban
|
|
6 |
*/
|
|
7 |
public class Form {
|
|
8 |
|
|
9 |
public case False();
|
|
10 |
public case And(Form c1,Form c2);
|
|
11 |
public case Or(Form c1,Form c2);
|
|
12 |
public case Imp(Form c1,Form c2);
|
|
13 |
//public case Equ(Form c1,Form c2);
|
|
14 |
public case Atm(String c);
|
|
15 |
|
|
16 |
public String toString() {
|
|
17 |
switch(this) {
|
|
18 |
case False():
|
|
19 |
return "false";
|
|
20 |
case And(Form c1,Form c2):
|
|
21 |
return "(" + c1.toString() + " & " + c2.toString() + ")";
|
|
22 |
case Or(Form c1,Form c2):
|
|
23 |
return "(" + c1.toString() + " v " + c2.toString() + ")";
|
|
24 |
case Imp(Form c1,Form c2):
|
|
25 |
return "(" + c1.toString() + " -> " + c2.toString() + ")";
|
|
26 |
case Atm(String c):
|
|
27 |
return c;
|
|
28 |
}
|
|
29 |
}
|
|
30 |
|
|
31 |
// for testing
|
|
32 |
public String internalString() {
|
|
33 |
switch(this) {
|
|
34 |
case False():
|
|
35 |
return "false";
|
|
36 |
case And(Form c1,Form c2):
|
|
37 |
return "And(" + c1.internalString() + "," + c2.internalString() + ")";
|
|
38 |
case Or(Form c1,Form c2):
|
|
39 |
return "Or(" + c1.internalString() + "," + c2.internalString() + ")";
|
|
40 |
case Imp(Form c1,Form c2):
|
|
41 |
return "Imp(" + c1.internalString() + "," + c2.internalString() + ")";
|
|
42 |
case Atm(String c):
|
|
43 |
return "Atm(\"p"+ c + "\")";
|
|
44 |
}
|
|
45 |
}
|
|
46 |
|
|
47 |
}
|
|
48 |
|