package G4ip;
/** Class for propositional formulae.<p>
* @author Christian Urban
*/
public class Form {
public case False();
public case And(Form c1,Form c2);
public case Or(Form c1,Form c2);
public case Imp(Form c1,Form c2);
//public case Equ(Form c1,Form c2);
public case Atm(String c);
public String toString() {
switch(this) {
case False():
return "false";
case And(Form c1,Form c2):
return "(" + c1.toString() + " & " + c2.toString() + ")";
case Or(Form c1,Form c2):
return "(" + c1.toString() + " v " + c2.toString() + ")";
case Imp(Form c1,Form c2):
return "(" + c1.toString() + " -> " + c2.toString() + ")";
case Atm(String c):
return c;
}
}
// for testing
public String internalString() {
switch(this) {
case False():
return "false";
case And(Form c1,Form c2):
return "And(" + c1.internalString() + "," + c2.internalString() + ")";
case Or(Form c1,Form c2):
return "Or(" + c1.internalString() + "," + c2.internalString() + ")";
case Imp(Form c1,Form c2):
return "Imp(" + c1.internalString() + "," + c2.internalString() + ")";
case Atm(String c):
return "Atm(\"p"+ c + "\")";
}
}
}