Prover/Formulae.pizza
author Christian Urban <urbanc@in.tum.de>
Fri, 15 Sep 2017 11:09:00 +0100
changeset 495 5bea07c95bb1
parent 96 907b1fff5637
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
96
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
package G4ip;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
/** Class for propositional formulae.<p>
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  * @author      Christian Urban
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
public class Form {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
  public case False();         
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  public case And(Form c1,Form c2);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  public case Or(Form c1,Form c2);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  public case Imp(Form c1,Form c2);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  //public case Equ(Form c1,Form c2);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  public case Atm(String c);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  public String toString() {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
    switch(this) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
    case False(): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
      return "false"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
    case And(Form c1,Form c2): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
      return "(" + c1.toString() + " & "   + c2.toString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
    case Or(Form c1,Form c2):  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
      return "(" + c1.toString() + " v "   + c2.toString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
    case Imp(Form c1,Form c2): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
      return "(" + c1.toString() + " -> "  + c2.toString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
    case Atm(String c): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
      return c; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
    }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  // for testing
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  public String internalString() {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
    switch(this) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
    case False(): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
      return "false"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
    case And(Form c1,Form c2): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
      return "And(" + c1.internalString() + ","   + c2.internalString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
    case Or(Form c1,Form c2):  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
      return "Or(" + c1.internalString() + ","   + c2.internalString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
    case Imp(Form c1,Form c2): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
      return "Imp(" + c1.internalString() + ","  + c2.internalString() + ")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
    case Atm(String c): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
      return "Atm(\"p"+ c + "\")"; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
    }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
}
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48