Prover/Prover.pizza
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 09 Jul 2023 08:56:24 +0100
changeset 637 eb530e39145d
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
package G4ip;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
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
import pizza.util.Hashtable;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
import java.util.Vector;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
import G4ip.Form.*;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
import G4ip.ProofDisplay.*;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
import G4ip.Sequent.*;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
/** The Gi4p prover.<p>
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
  * The prover is a thread in order to suspend the proof search
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  * after one proof is found and to let the user make a choice 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  * of whether to stop or to continue with the proof search.
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  * @author Christian Urban
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
public class Prover extends Thread
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
{ ProverApplet  parent;  // the parent of the prover;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  boolean once;          // if true then at least one proof was found
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  Sequent sequ;          // the root sequent to be proved
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  Vector  frames;        // to record all frames which have been opened
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  int index ;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  Hashtable<int,Sequent> proof;      // keeps a record of the proof
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
             
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  /** The constructor creates a prover which proves a specific sequent.<p>
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
    * The parameter parent is for access to the applet buttons.
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
  public Prover(Sequent init_sequ, ProverApplet init_parent) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
    super("Prover");
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
    parent = init_parent;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
    once   = false;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
    sequ   = new Sequent(init_sequ);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
    frames = new Vector();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
    index  = 1;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
    proof  = new Hashtable();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
   
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
  /** Starts the thread; calls prove and stops the thread when 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
    * the proof search is finished.
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
  public void run()
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
    { prove(1,sequ,initial_sc); 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
      if (once == true) { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
	parent.messages.setText("No more proofs.");
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
	parent.messages.repaint();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
	parent.repaint();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
      }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
      else { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
	parent.messages.setText("Not provable.");
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
	parent.messages.repaint();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
        parent.repaint();	
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
      }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
      parent.switch_into_input_mode();
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
      this.stop();     // everything is done, stop the thread
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
    } 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  /** Closes all frames which have been opened.
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  public void finalize() { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
    for (int i=0; i<frames.size();i++) { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
      if (frames.elementAt != null) 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
	{ ((ProofDisplay)frames.elementAt(i)).dispose(); }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
    }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
  /** The tactic of the proof search.<p>
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
    * Method prove first enumerates all formulae on the LHS        
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
    * as being the principal formula and attempts to apply left-rules,  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
    * subsequently it analyses the goal formula.                     
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
    */ 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  public void prove(int index, Sequent is,(() -> void) sc)  {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
    Form principal;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
    proof.put(index,new Sequent(is));      // add sequence to proof
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
    rightrules(index,is,sc);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
    for (int i=0;i<is.Gamma.size();i++) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
      principal = (Form)is.Gamma.elementAt(i);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
      is.Gamma.removeElement(principal);       // Gamma minus principal formula
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
      leftrules(index,principal,is,sc);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
      is.Gamma.insertElementAt(principal,i);   // put principal formula
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
    }                                          // back into Gamma 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
    //rightrules(index,is,sc);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
    proof.remove(index);                   // remove sequence from proof
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  /** Analyses the goal formula. 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  public void rightrules(int index, Sequent sequ,(()  -> void) sc)  {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
    Context Gamma = sequ.Gamma;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
    switch(sequ.G) { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
                          /** And-R
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
			    *  Gamma => A    Gamma => B  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
			    * --------------------------   
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
			    *      Gamma => A and B     
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
			    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
    case And(Form A,Form B): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
      prove(2*index,new Sequent(Gamma,A),
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
            fun() -> void { prove(2*index+1,new Sequent(Gamma,B),sc); }  ); 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
      break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
                          /** Imp-R  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
			    *   Gamma,A => B   
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
			    * ----------------- 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
			    *  Gamma => A imp B     
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
			    */ 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
    case Imp(Form A,Form B):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
      prove(2*index,new Sequent(Gamma.add(A),B),sc); break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
                           
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
                           /** Or-R 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
			     *   Gamma  => A           Gamma => B   
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
			     * ----------------- or -----------------  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
			     *  Gamma => A or B      Gamma => A or B   
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
			     */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
    case Or(Form A,Form B):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
      prove(2*index,new Sequent(Gamma,A),sc);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
      prove(2*index,new Sequent(Gamma,B),sc); break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
                           
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
                           /** Equ-R
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
			     *  Gamma => A -> B  Gamma => B -> A 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
			     * -------------------------------- 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
			     *          Gamma => A <-> B         
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
			     */ 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
    }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  /** Analyses the principal formula on the LHS. 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  public void leftrules(int index,Form principal,Sequent sequ,(() -> void) sc){
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
    Context Gamma = sequ.Gamma;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
    Form    G     = sequ.G;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
    switch(principal) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
                          /** false-L
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
			    * --------------------  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
                            *  false, Gamma => G     
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
			    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
    case False():  sc(); break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
                           /** Axiom
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
      			     *  ---------------                  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
      			     *   Gamma, G => G     G being atomic 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
      			     */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
    case Atm(String c):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
      if (G instanceof Atm) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
	if (((Atm)G).c.compareTo(c) == 0) { sc(); }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
      }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
      break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
                          /** And-L
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
			    *   Gamma, A, B => G    
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
                            * -------------------- 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
                            *  Gamma, A and B => G     
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
			    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
      
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
    case And(Form A, Form B): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
      prove(2*index,new Sequent(Gamma.add(A,B),G),sc); break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
                          /** Or-R
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
			    *  Gamma, A => G   Gamma, B => G 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
                            * ------------------------------- 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
                            *      Gamma, A or B => G      
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
			    */ 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
    case Or(Form A, Form B):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
      prove(2*index,new Sequent(Gamma.add(A),G),
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
	    fun() -> void {prove(2*index+1,new Sequent(Gamma.add(B),G),sc);});
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
      break;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
                          /** Imp-L 2         
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
			    *  Gamma, A imp (B imp C) => G  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
                            * ------------------------------
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
                            *  Gamma, (A and B) imp C => G    
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
                            */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
    case Imp(And(Form A, Form B), Form C):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
      prove(2*index,new Sequent(Gamma.add(Imp(A,Imp(B,C))),G),sc); break; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
                          /** Imp-L 3       
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
                            *  Gamma, (A imp C), (B imp C) => G 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
                            * ----------------------------------
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
                            *   Gamma, (A or B) imp C => G       
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
			    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
    case Imp(Or(Form A, Form B), Form C):  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
      prove(2*index,new Sequent(Gamma.add(Imp(A,C),Imp(B,C)),G),sc); break; 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
                          /** Imp-L 4 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
			    *  Gamma, (B imp C) => (A imp B)    Gamma, C => G 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
                            * ------------------------------------------------
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
                            *         Gamma, (A imp B) imp C => G                
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
			    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
    case Imp(Imp(Form A, Form B), Form C): 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
      prove(2*index,new Sequent(Gamma.add(Imp(B,C)),Imp(A,B)),
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
	    fun() -> void { prove(2*index+1,new Sequent(Gamma.add(C),G),sc);});
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
      break;  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
                          /** Imp-L 1         
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
			    *   Gamma(A), B => G          A being atomic       
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
                            * ------------------------    Gamma(A) means:
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
                            *  Gamma(A), A imp B => G     Gamma contains A
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
			    */ 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
    case Imp(Form A, Form B):
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
      if (A instanceof Atm) { 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
	if (Gamma.includes(A)) {
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
	  { prove(2*index,new Sequent(Gamma.add(B),G),sc); }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
	}
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
      }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
      break;    
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
    }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
  }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
  /** The initial success continuation. 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
    * Suspends the thread when a proof is found. 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
    */
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
  public void initial_sc()  {  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
    once = true;
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
    ProofDisplay p = new ProofDisplay(proof);
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
    frames.addElement(p);       // keep a record for later disposal
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
    try {                       // suspend the proof search, 
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
    suspend(); }           // it might be resumed later on  by the user
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
    catch(SecurityException sec_exc)
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
      { /* this catch is neccessary for Netscape 3.0 (Linux) */ }
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
  }  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
  
907b1fff5637 added phd and prover
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
}