Prover/Formulae.pizza
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 10 Aug 2014 03:08:48 +0100
changeset 301 1d95918391c8
parent 96 907b1fff5637
permissions -rw-r--r--
updated


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 + "\")"; 
    }
  }

}