src/Sequents/LK0.ML
changeset 7093 b2ee0e5d1a7f
child 7122 87b233b31889
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/Sequents/LK0.ML	Tue Jul 27 18:52:23 1999 +0200
     1.3 @@ -0,0 +1,169 @@
     1.4 +(*  Title:      LK/LK0
     1.5 +    ID:         $Id$
     1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1992  University of Cambridge
     1.8 +
     1.9 +Tactics and lemmas for LK (thanks also to Philippe de Groote)  
    1.10 +
    1.11 +Structural rules by Soren Heilmann
    1.12 +*)
    1.13 +
    1.14 +(** Structural Rules on formulas **)
    1.15 +
    1.16 +(*contraction*)
    1.17 +
    1.18 +Goal "$H |- $E, P, P, $F ==> $H |- $E, P, $F";
    1.19 +by (etac contRS 1);
    1.20 +qed "contR";
    1.21 +
    1.22 +Goal "$H, P, P, $G |- $E ==> $H, P, $G |- $E";
    1.23 +by (etac contLS 1);
    1.24 +qed "contL";
    1.25 +
    1.26 +(*thinning*)
    1.27 +
    1.28 +Goal "$H |- $E, $F ==> $H |- $E, P, $F";
    1.29 +by (etac thinRS 1);
    1.30 +qed "thinR";
    1.31 +
    1.32 +Goal "$H, $G |- $E ==> $H, P, $G |- $E";
    1.33 +by (etac thinLS 1);
    1.34 +qed "thinL";
    1.35 +
    1.36 +(*exchange*)
    1.37 +
    1.38 +Goal "$H |- $E, Q, P, $F ==> $H |- $E, P, Q, $F";
    1.39 +by (etac exchRS 1);
    1.40 +qed "exchR";
    1.41 +
    1.42 +Goal "$H, Q, P, $G |- $E ==> $H, P, Q, $G |- $E";
    1.43 +by (etac exchLS 1);
    1.44 +qed "exchL";
    1.45 +
    1.46 +(*Cut and thin, replacing the right-side formula*)
    1.47 +fun cutR_tac (sP: string) i = 
    1.48 +    res_inst_tac [ ("P",sP) ] cut i  THEN  rtac thinR i;
    1.49 +
    1.50 +(*Cut and thin, replacing the left-side formula*)
    1.51 +fun cutL_tac (sP: string) i = 
    1.52 +    res_inst_tac [ ("P",sP) ] cut i  THEN  rtac thinL (i+1);
    1.53 +
    1.54 +
    1.55 +(** If-and-only-if rules **)
    1.56 +qed_goalw "iffR" thy [iff_def]
    1.57 +    "[| $H,P |- $E,Q,$F;  $H,Q |- $E,P,$F |] ==> $H |- $E, P <-> Q, $F"
    1.58 + (fn prems=> [ (REPEAT (resolve_tac (prems@[conjR,impR]) 1)) ]);
    1.59 +
    1.60 +qed_goalw "iffL" thy [iff_def]
    1.61 +   "[| $H,$G |- $E,P,Q;  $H,Q,P,$G |- $E |] ==> $H, P <-> Q, $G |- $E"
    1.62 + (fn prems=> [ (REPEAT (resolve_tac (prems@[conjL,impL,basic]) 1)) ]);
    1.63 +
    1.64 +qed_goalw "TrueR" thy [True_def]
    1.65 +    "$H |- $E, True, $F"
    1.66 + (fn _=> [ rtac impR 1, rtac basic 1 ]);
    1.67 +
    1.68 +
    1.69 +(** Weakened quantifier rules.  Incomplete, they let the search terminate.**)
    1.70 +
    1.71 +Goal "$H, P(x), $G |- $E ==> $H, ALL x. P(x), $G |- $E";
    1.72 +by (rtac allL 1);
    1.73 +by (etac thinL 1);
    1.74 +qed "allL_thin";
    1.75 +
    1.76 +Goal "$H |- $E, P(x), $F ==> $H |- $E, EX x. P(x), $F";
    1.77 +by (rtac exR 1);
    1.78 +by (etac thinR 1);
    1.79 +qed "exR_thin";
    1.80 +
    1.81 +
    1.82 +(*The rules of LK*)
    1.83 +val prop_pack = empty_pack add_safes 
    1.84 +                [basic, refl, TrueR, FalseL, 
    1.85 +		 conjL, conjR, disjL, disjR, impL, impR, 
    1.86 +                 notL, notR, iffL, iffR];
    1.87 +
    1.88 +val LK_pack = prop_pack add_safes   [allR, exL] 
    1.89 +                        add_unsafes [allL_thin, exR_thin];
    1.90 +
    1.91 +val LK_dup_pack = prop_pack add_safes   [allR, exL] 
    1.92 +                            add_unsafes [allL, exR];
    1.93 +
    1.94 +
    1.95 +thm_pack_ref() := LK_pack;
    1.96 +
    1.97 +fun Fast_tac st = fast_tac (thm_pack()) st;
    1.98 +fun Step_tac st = step_tac (thm_pack()) st;
    1.99 +fun Safe_tac st = safe_tac (thm_pack()) st;
   1.100 +
   1.101 +fun lemma_tac th i = 
   1.102 +    rtac (thinR RS cut) i THEN REPEAT (rtac thinL i) THEN rtac th i;
   1.103 +
   1.104 +val [major,minor] = goal thy 
   1.105 +    "[| $H |- $E, $F, P --> Q;  $H |- $E, $F, P |] ==> $H |- $E, Q, $F";
   1.106 +by (rtac (thinRS RS cut) 1 THEN rtac major 1);
   1.107 +by (Step_tac 1);
   1.108 +by (rtac thinR 1 THEN rtac minor 1);
   1.109 +qed "mp_R";
   1.110 +
   1.111 +val [major,minor] = goal thy 
   1.112 +    "[| $H, $G |- $E, P --> Q;  $H, $G, Q |- $E |] ==> $H, P, $G |- $E";
   1.113 +by (rtac (thinL RS cut) 1 THEN rtac major 1);
   1.114 +by (Step_tac 1);
   1.115 +by (rtac thinL 1 THEN rtac minor 1);
   1.116 +qed "mp_L";
   1.117 +
   1.118 +
   1.119 +(** Two rules to generate left- and right- rules from implications **)
   1.120 +
   1.121 +val [major,minor] = goal thy 
   1.122 +    "[| |- P --> Q;  $H |- $E, $F, P |] ==> $H |- $E, Q, $F";
   1.123 +by (rtac mp_R 1);
   1.124 +by (rtac minor 2);
   1.125 +by (rtac thinRS 1 THEN rtac (major RS thinLS) 1);
   1.126 +qed "R_of_imp";
   1.127 +
   1.128 +val [major,minor] = goal thy 
   1.129 +    "[| |- P --> Q;  $H, $G, Q |- $E |] ==> $H, P, $G |- $E";
   1.130 +by (rtac mp_L 1);
   1.131 +by (rtac minor 2);
   1.132 +by (rtac thinRS 1 THEN rtac (major RS thinLS) 1);
   1.133 +qed "L_of_imp";
   1.134 +
   1.135 +(*Can be used to create implications in a subgoal*)
   1.136 +val [prem] = goal thy 
   1.137 +    "[| $H, $G |- $E, $F, P --> Q |] ==> $H, P, $G |- $E, Q, $F";
   1.138 +by (rtac mp_L 1);
   1.139 +by (rtac basic 2);
   1.140 +by (rtac thinR 1 THEN rtac prem 1);
   1.141 +qed "backwards_impR";
   1.142 +
   1.143 + 
   1.144 +qed_goal "conjunct1" thy "|-P&Q ==> |-P"
   1.145 +    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
   1.146 +
   1.147 +qed_goal "conjunct2" thy "|-P&Q ==> |-Q"
   1.148 +    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
   1.149 +
   1.150 +qed_goal "spec" thy "|- (ALL x. P(x)) ==> |- P(x)"
   1.151 +    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
   1.152 +
   1.153 +(** Equality **)
   1.154 +
   1.155 +Goal "|- a=b --> b=a";
   1.156 +by (safe_tac (LK_pack add_safes [subst]) 1);
   1.157 +qed "sym";
   1.158 +
   1.159 +Goal "|- a=b --> b=c --> a=c";
   1.160 +by (safe_tac (LK_pack add_safes [subst]) 1);
   1.161 +qed "trans";
   1.162 +
   1.163 +(* Symmetry of equality in hypotheses *)
   1.164 +bind_thm ("symL", sym RS L_of_imp);
   1.165 +
   1.166 +(* Symmetry of equality in hypotheses *)
   1.167 +bind_thm ("symR", sym RS R_of_imp);
   1.168 +
   1.169 +Goal "[| $H|- $E, $F, a=b;  $H|- $E, $F, b=c |] ==> $H|- $E, a=c, $F";
   1.170 +by (rtac (trans RS R_of_imp RS mp_R) 1);
   1.171 +by (ALLGOALS assume_tac);
   1.172 +qed "transR";