renamed theory LK to LK0
authorpaulson
Tue Jul 27 18:52:23 1999 +0200 (1999-07-27)
changeset 7093b2ee0e5d1a7f
parent 7092 d7958f38e9e0
child 7094 6f18ae72a90e
renamed theory LK to LK0
src/Sequents/LK0.ML
src/Sequents/LK0.thy
     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";
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Sequents/LK0.thy	Tue Jul 27 18:52:23 1999 +0200
     2.3 @@ -0,0 +1,142 @@
     2.4 +(*  Title:      LK/LK0
     2.5 +    ID:         $Id$
     2.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     2.7 +    Copyright   1993  University of Cambridge
     2.8 +
     2.9 +Classical First-Order Sequent Calculus
    2.10 +
    2.11 +There may be printing problems if a seqent is in expanded normal form
    2.12 +	(eta-expanded, beta-contracted)
    2.13 +*)
    2.14 +
    2.15 +LK0 = Sequents +
    2.16 +
    2.17 +global
    2.18 +
    2.19 +classes
    2.20 +  term < logic
    2.21 +
    2.22 +default
    2.23 +  term
    2.24 +
    2.25 +consts
    2.26 +
    2.27 + Trueprop	:: "two_seqi"
    2.28 + "@Trueprop"	:: "two_seqe" ("((_)/ |- (_))" [6,6] 5)
    2.29 +
    2.30 +  (*Constant to allow definitions of SEQUENCES of formulas*)
    2.31 +  "@Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
    2.32 +
    2.33 +  True,False   :: o
    2.34 +  "="          :: ['a,'a] => o       (infixl 50)
    2.35 +  Not          :: o => o             ("~ _" [40] 40)
    2.36 +  "&"          :: [o,o] => o         (infixr 35)
    2.37 +  "|"          :: [o,o] => o         (infixr 30)
    2.38 +  "-->","<->"  :: [o,o] => o         (infixr 25)
    2.39 +  The          :: ('a => o) => 'a    (binder "THE " 10)
    2.40 +  All          :: ('a => o) => o     (binder "ALL " 10)
    2.41 +  Ex           :: ('a => o) => o     (binder "EX " 10)
    2.42 +
    2.43 +syntax
    2.44 +  "~="          :: ['a, 'a] => o                (infixl 50)
    2.45 +
    2.46 +translations
    2.47 +  "x ~= y"      == "~ (x = y)"
    2.48 +
    2.49 +syntax (symbols)
    2.50 +  Not           :: o => o               ("\\<not> _" [40] 40)
    2.51 +  "op &"        :: [o, o] => o          (infixr "\\<and>" 35)
    2.52 +  "op |"        :: [o, o] => o          (infixr "\\<or>" 30)
    2.53 +  "op -->"      :: [o, o] => o          (infixr "\\<midarrow>\\<rightarrow>" 25)
    2.54 +  "op <->"      :: [o, o] => o          (infixr "\\<leftarrow>\\<rightarrow>" 25)
    2.55 +  "ALL "        :: [idts, o] => o       ("(3\\<forall>_./ _)" [0, 10] 10)
    2.56 +  "EX "         :: [idts, o] => o       ("(3\\<exists>_./ _)" [0, 10] 10)
    2.57 +  "EX! "        :: [idts, o] => o       ("(3\\<exists>!_./ _)" [0, 10] 10)
    2.58 +  "op ~="       :: ['a, 'a] => o        (infixl "\\<noteq>" 50)
    2.59 +
    2.60 +syntax (xsymbols)
    2.61 +  "op -->"      :: [o, o] => o          (infixr "\\<longrightarrow>" 25)
    2.62 +  "op <->"      :: [o, o] => o          (infixr "\\<longleftrightarrow>" 25)
    2.63 +
    2.64 +syntax (HTML output)
    2.65 +  Not           :: o => o               ("\\<not> _" [40] 40)
    2.66 +
    2.67 +
    2.68 +local
    2.69 +  
    2.70 +rules
    2.71 +
    2.72 +  (*Structural rules: contraction, thinning, exchange [Soren Heilmann] *)
    2.73 +
    2.74 +  contRS "$H |- $E, $S, $S, $F ==> $H |- $E, $S, $F"
    2.75 +  contLS "$H, $S, $S, $G |- $E ==> $H, $S, $G |- $E"
    2.76 +
    2.77 +  thinRS "$H |- $E, $F ==> $H |- $E, $S, $F"
    2.78 +  thinLS "$H, $G |- $E ==> $H, $S, $G |- $E"
    2.79 +
    2.80 +  exchRS "$H |- $E, $R, $S, $F ==> $H |- $E, $S, $R, $F"
    2.81 +  exchLS "$H, $R, $S, $G |- $E ==> $H, $S, $R, $G |- $E"
    2.82 +
    2.83 +  cut   "[| $H |- $E, P;  $H, P |- $E |] ==> $H |- $E"
    2.84 +
    2.85 +  (*Propositional rules*)
    2.86 +
    2.87 +  basic "$H, P, $G |- $E, P, $F"
    2.88 +
    2.89 +  conjR "[| $H|- $E, P, $F;  $H|- $E, Q, $F |] ==> $H|- $E, P&Q, $F"
    2.90 +  conjL "$H, P, Q, $G |- $E ==> $H, P & Q, $G |- $E"
    2.91 +
    2.92 +  disjR "$H |- $E, P, Q, $F ==> $H |- $E, P|Q, $F"
    2.93 +  disjL "[| $H, P, $G |- $E;  $H, Q, $G |- $E |] ==> $H, P|Q, $G |- $E"
    2.94 +
    2.95 +  impR  "$H, P |- $E, Q, $F ==> $H |- $E, P-->Q, $F"
    2.96 +  impL  "[| $H,$G |- $E,P;  $H, Q, $G |- $E |] ==> $H, P-->Q, $G |- $E"
    2.97 +
    2.98 +  notR  "$H, P |- $E, $F ==> $H |- $E, ~P, $F"
    2.99 +  notL  "$H, $G |- $E, P ==> $H, ~P, $G |- $E"
   2.100 +
   2.101 +  FalseL "$H, False, $G |- $E"
   2.102 +
   2.103 +  True_def "True == False-->False"
   2.104 +  iff_def  "P<->Q == (P-->Q) & (Q-->P)"
   2.105 +
   2.106 +  (*Quantifiers*)
   2.107 +
   2.108 +  allR  "(!!x.$H |- $E, P(x), $F) ==> $H |- $E, ALL x. P(x), $F"
   2.109 +  allL  "$H, P(x), $G, ALL x. P(x) |- $E ==> $H, ALL x. P(x), $G |- $E"
   2.110 +
   2.111 +  exR   "$H |- $E, P(x), $F, EX x. P(x) ==> $H |- $E, EX x. P(x), $F"
   2.112 +  exL   "(!!x.$H, P(x), $G |- $E) ==> $H, EX x. P(x), $G |- $E"
   2.113 +
   2.114 +  (*Equality*)
   2.115 +
   2.116 +  refl  "$H |- $E, a=a, $F"
   2.117 +  subst "$H(a), $G(a) |- $E(a) ==> $H(b), a=b, $G(b) |- $E(b)"
   2.118 +
   2.119 +  (* Reflection *)
   2.120 +
   2.121 +  eq_reflection  "|- x=y ==> (x==y)"
   2.122 +  iff_reflection "|- P<->Q ==> (P==Q)"
   2.123 +
   2.124 +  (*Descriptions*)
   2.125 +
   2.126 +  The "[| $H |- $E, P(a), $F;  !!x.$H, P(x) |- $E, x=a, $F |] ==> 
   2.127 +          $H |- $E, P(THE x. P(x)), $F"
   2.128 +
   2.129 +constdefs
   2.130 +  If :: [o, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
   2.131 +   "If(P,x,y) == THE z::'a. (P --> z=x) & (~P --> z=y)"
   2.132 +
   2.133 +
   2.134 +setup
   2.135 +  Simplifier.setup
   2.136 +
   2.137 +setup
   2.138 +  prover_setup
   2.139 +
   2.140 +end
   2.141 +
   2.142 +  ML
   2.143 +
   2.144 +val parse_translation = [("@Trueprop",Sequents.two_seq_tr "Trueprop")];
   2.145 +val print_translation = [("Trueprop",Sequents.two_seq_tr' "@Trueprop")];