src/Sequents/LK0.ML
author paulson
Tue, 27 Jul 1999 18:52:23 +0200
changeset 7093 b2ee0e5d1a7f
child 7122 87b233b31889
permissions -rw-r--r--
renamed theory LK to LK0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7093
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     1
(*  Title:      LK/LK0
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     2
    ID:         $Id$
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     5
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     6
Tactics and lemmas for LK (thanks also to Philippe de Groote)  
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     7
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     8
Structural rules by Soren Heilmann
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
     9
*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    10
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    11
(** Structural Rules on formulas **)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    12
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    13
(*contraction*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    14
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    15
Goal "$H |- $E, P, P, $F ==> $H |- $E, P, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    16
by (etac contRS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    17
qed "contR";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    18
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    19
Goal "$H, P, P, $G |- $E ==> $H, P, $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    20
by (etac contLS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    21
qed "contL";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    22
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    23
(*thinning*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    24
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    25
Goal "$H |- $E, $F ==> $H |- $E, P, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    26
by (etac thinRS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    27
qed "thinR";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    28
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    29
Goal "$H, $G |- $E ==> $H, P, $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    30
by (etac thinLS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    31
qed "thinL";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    32
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    33
(*exchange*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    34
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    35
Goal "$H |- $E, Q, P, $F ==> $H |- $E, P, Q, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    36
by (etac exchRS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    37
qed "exchR";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    38
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    39
Goal "$H, Q, P, $G |- $E ==> $H, P, Q, $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    40
by (etac exchLS 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    41
qed "exchL";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    42
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    43
(*Cut and thin, replacing the right-side formula*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    44
fun cutR_tac (sP: string) i = 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    45
    res_inst_tac [ ("P",sP) ] cut i  THEN  rtac thinR i;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    46
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    47
(*Cut and thin, replacing the left-side formula*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    48
fun cutL_tac (sP: string) i = 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    49
    res_inst_tac [ ("P",sP) ] cut i  THEN  rtac thinL (i+1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    50
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    51
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    52
(** If-and-only-if rules **)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    53
qed_goalw "iffR" thy [iff_def]
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    54
    "[| $H,P |- $E,Q,$F;  $H,Q |- $E,P,$F |] ==> $H |- $E, P <-> Q, $F"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    55
 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjR,impR]) 1)) ]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    56
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    57
qed_goalw "iffL" thy [iff_def]
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    58
   "[| $H,$G |- $E,P,Q;  $H,Q,P,$G |- $E |] ==> $H, P <-> Q, $G |- $E"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    59
 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjL,impL,basic]) 1)) ]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    60
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    61
qed_goalw "TrueR" thy [True_def]
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    62
    "$H |- $E, True, $F"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    63
 (fn _=> [ rtac impR 1, rtac basic 1 ]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    64
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    65
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    66
(** Weakened quantifier rules.  Incomplete, they let the search terminate.**)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    67
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    68
Goal "$H, P(x), $G |- $E ==> $H, ALL x. P(x), $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    69
by (rtac allL 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    70
by (etac thinL 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    71
qed "allL_thin";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    72
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    73
Goal "$H |- $E, P(x), $F ==> $H |- $E, EX x. P(x), $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    74
by (rtac exR 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    75
by (etac thinR 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    76
qed "exR_thin";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    77
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    78
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    79
(*The rules of LK*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    80
val prop_pack = empty_pack add_safes 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    81
                [basic, refl, TrueR, FalseL, 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    82
		 conjL, conjR, disjL, disjR, impL, impR, 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    83
                 notL, notR, iffL, iffR];
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    84
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    85
val LK_pack = prop_pack add_safes   [allR, exL] 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    86
                        add_unsafes [allL_thin, exR_thin];
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    87
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    88
val LK_dup_pack = prop_pack add_safes   [allR, exL] 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    89
                            add_unsafes [allL, exR];
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    90
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    91
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    92
thm_pack_ref() := LK_pack;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    93
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    94
fun Fast_tac st = fast_tac (thm_pack()) st;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    95
fun Step_tac st = step_tac (thm_pack()) st;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    96
fun Safe_tac st = safe_tac (thm_pack()) st;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    97
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    98
fun lemma_tac th i = 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
    99
    rtac (thinR RS cut) i THEN REPEAT (rtac thinL i) THEN rtac th i;
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   100
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   101
val [major,minor] = goal thy 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   102
    "[| $H |- $E, $F, P --> Q;  $H |- $E, $F, P |] ==> $H |- $E, Q, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   103
by (rtac (thinRS RS cut) 1 THEN rtac major 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   104
by (Step_tac 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   105
by (rtac thinR 1 THEN rtac minor 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   106
qed "mp_R";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   107
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   108
val [major,minor] = goal thy 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   109
    "[| $H, $G |- $E, P --> Q;  $H, $G, Q |- $E |] ==> $H, P, $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   110
by (rtac (thinL RS cut) 1 THEN rtac major 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   111
by (Step_tac 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   112
by (rtac thinL 1 THEN rtac minor 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   113
qed "mp_L";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   114
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   115
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   116
(** Two rules to generate left- and right- rules from implications **)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   117
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   118
val [major,minor] = goal thy 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   119
    "[| |- P --> Q;  $H |- $E, $F, P |] ==> $H |- $E, Q, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   120
by (rtac mp_R 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   121
by (rtac minor 2);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   122
by (rtac thinRS 1 THEN rtac (major RS thinLS) 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   123
qed "R_of_imp";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   124
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   125
val [major,minor] = goal thy 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   126
    "[| |- P --> Q;  $H, $G, Q |- $E |] ==> $H, P, $G |- $E";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   127
by (rtac mp_L 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   128
by (rtac minor 2);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   129
by (rtac thinRS 1 THEN rtac (major RS thinLS) 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   130
qed "L_of_imp";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   131
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   132
(*Can be used to create implications in a subgoal*)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   133
val [prem] = goal thy 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   134
    "[| $H, $G |- $E, $F, P --> Q |] ==> $H, P, $G |- $E, Q, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   135
by (rtac mp_L 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   136
by (rtac basic 2);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   137
by (rtac thinR 1 THEN rtac prem 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   138
qed "backwards_impR";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   139
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   140
 
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   141
qed_goal "conjunct1" thy "|-P&Q ==> |-P"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   142
    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   143
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   144
qed_goal "conjunct2" thy "|-P&Q ==> |-Q"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   145
    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   146
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   147
qed_goal "spec" thy "|- (ALL x. P(x)) ==> |- P(x)"
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   148
    (fn [major] => [lemma_tac major 1,  Fast_tac 1]);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   149
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   150
(** Equality **)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   151
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   152
Goal "|- a=b --> b=a";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   153
by (safe_tac (LK_pack add_safes [subst]) 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   154
qed "sym";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   155
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   156
Goal "|- a=b --> b=c --> a=c";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   157
by (safe_tac (LK_pack add_safes [subst]) 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   158
qed "trans";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   159
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   160
(* Symmetry of equality in hypotheses *)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   161
bind_thm ("symL", sym RS L_of_imp);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   162
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   163
(* Symmetry of equality in hypotheses *)
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   164
bind_thm ("symR", sym RS R_of_imp);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   165
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   166
Goal "[| $H|- $E, $F, a=b;  $H|- $E, $F, b=c |] ==> $H|- $E, a=c, $F";
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   167
by (rtac (trans RS R_of_imp RS mp_R) 1);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   168
by (ALLGOALS assume_tac);
b2ee0e5d1a7f renamed theory LK to LK0
paulson
parents:
diff changeset
   169
qed "transR";