src/FOL/IFOL.ML
author wenzelm
Sat, 10 Jul 1999 21:44:26 +0200
changeset 6966 cfa87aef9ccd
parent 6113 b321f5aaa5f4
child 7355 4c43090659ca
permissions -rw-r--r--
handle THM exn;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
     1
(*  Title:      FOL/IFOL.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
1280
909079af97b7 corrected spelling of title
clasohm
parents: 1002
diff changeset
     6
Tactics and lemmas for IFOL.thy (intuitionistic first-order logic)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
     9
qed_goalw "TrueI" IFOL.thy [True_def] "True"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
 (fn _ => [ (REPEAT (ares_tac [impI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
(*** Sequent-style elimination rules for & --> and ALL ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    14
qed_goal "conjE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
    "[| P&Q; [| P; Q |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
  [ (REPEAT (resolve_tac prems 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
      ORELSE (resolve_tac [conjunct1, conjunct2] 1 THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
              resolve_tac prems 1))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    21
qed_goal "impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
    "[| P-->Q;  P;  Q ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    25
qed_goal "allE" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
    26
    "[| ALL x. P(x); P(x) ==> R |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
(*Duplicates the quantifier; for use with eresolve_tac*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    30
qed_goal "all_dupE" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
    31
    "[| ALL x. P(x);  [| P(x); ALL x. P(x) |] ==> R \
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
\    |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
(*** Negation rules, which translate between ~P and P-->False ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    38
qed_goalw "notI" IFOL.thy [not_def] "(P ==> False) ==> ~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    41
qed_goalw "notE" IFOL.thy [not_def] "[| ~P;  P |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  [ (resolve_tac [mp RS FalseE] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
1891
618f48bd4532 Addition of rev_notE
paulson
parents: 1608
diff changeset
    46
qed_goal "rev_notE" IFOL.thy "!!P R. [| P; ~P |] ==> R"
618f48bd4532 Addition of rev_notE
paulson
parents: 1608
diff changeset
    47
 (fn _ => [REPEAT (ares_tac [notE] 1)]);
618f48bd4532 Addition of rev_notE
paulson
parents: 1608
diff changeset
    48
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
(*This is useful with the special implication rules for each kind of P. *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    50
qed_goal "not_to_imp" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
    "[| ~P;  (P-->False) ==> Q |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI,notE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
1002
280ec187f8e1 Fixed typo.
lcp
parents: 821
diff changeset
    54
(* For substitution into an assumption P, reduce Q to P-->Q, substitute into
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
   this implication, then apply impI to move P back into the assumptions.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
   To specify P use something like
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
      eres_inst_tac [ ("P","ALL y. ?S(x,y)") ] rev_mp 1   *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    58
qed_goal "rev_mp" IFOL.thy "[| P;  P --> Q |] ==> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
(*Contrapositive of an inference rule*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    62
qed_goal "contrapos" IFOL.thy "[| ~Q;  P==>Q |] ==> ~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
 (fn [major,minor]=> 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
  [ (rtac (major RS notE RS notI) 1), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
    (etac minor 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
(*** Modus Ponens Tactics ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
fun mp_tac i = eresolve_tac [notE,impE] i  THEN  assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
(*Like mp_tac but instantiates no variables*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
fun eq_mp_tac i = eresolve_tac [notE,impE] i  THEN  eq_assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
(*** If-and-only-if ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    79
qed_goalw "iffI" IFOL.thy [iff_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
   "[| P ==> Q;  Q ==> P |] ==> P<->Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
 (fn prems=> [ (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    85
qed_goalw "iffE" IFOL.thy [iff_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
    "[| P <-> Q;  [| P-->Q; Q-->P |] ==> R |] ==> R"
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
    87
 (fn prems => [ (rtac conjE 1), (REPEAT (ares_tac prems 1)) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
(* Destruct rules for <-> similar to Modus Ponens *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    91
qed_goalw "iffD1" IFOL.thy [iff_def] "[| P <-> Q;  P |] ==> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    94
qed_goalw "iffD2" IFOL.thy [iff_def] "[| P <-> Q;  Q |] ==> P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
 (fn prems => [ (rtac (conjunct2 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
4462
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
    97
qed_goal "rev_iffD1" IFOL.thy "!!P. [| P; P <-> Q |] ==> Q"
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
    98
 (fn _ => [etac iffD1 1, assume_tac 1]);
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
    99
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
   100
qed_goal "rev_iffD2" IFOL.thy "!!P. [| Q; P <-> Q |] ==> P"
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
   101
 (fn _ => [etac iffD2 1, assume_tac 1]);
fefe21f761d7 New rules rev_iffD{1,2}
paulson
parents: 4187
diff changeset
   102
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   103
qed_goal "iff_refl" IFOL.thy "P <-> P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
 (fn _ => [ (REPEAT (ares_tac [iffI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   106
qed_goal "iff_sym" IFOL.thy "Q <-> P ==> P <-> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
 (fn [major] =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
  [ (rtac (major RS iffE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
    (REPEAT (eresolve_tac [asm_rl,mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   112
qed_goal "iff_trans" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
    "!!P Q R. [| P <-> Q;  Q<-> R |] ==> P <-> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
 (fn _ =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
  [ (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
    (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
(*** Unique existence.  NOTE THAT the following 2 quantifications
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
   EX!x such that [EX!y such that P(x,y)]     (sequential)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
   EX!x,y such that P(x,y)                    (simultaneous)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   125
qed_goalw "ex1I" IFOL.thy [ex1_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
    "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
 (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
2843
ea49c12f677f Updated comment
paulson
parents: 2037
diff changeset
   129
(*Sometimes easier to use: the premises have no shared variables.  Safe!*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   130
qed_goal "ex_ex1I" IFOL.thy
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   131
    "[| EX x. P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)"
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   132
 (fn [ex,eq] => [ (rtac (ex RS exE) 1),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   133
                  (REPEAT (ares_tac [ex1I,eq] 1)) ]);
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   134
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   135
qed_goalw "ex1E" IFOL.thy [ex1_def]
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   136
    "[| EX! x. P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
    (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
(*** <-> congruence rules for simplification ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
fun iff_tac prems i =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
    resolve_tac (prems RL [iffE]) i THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
    REPEAT1 (eresolve_tac [asm_rl,mp] i);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   149
qed_goal "conj_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P&Q) <-> (P'&Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
    (REPEAT  (ares_tac [iffI,conjI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
      ORELSE  eresolve_tac [iffE,conjE,mp] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
      ORELSE  iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
793
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   157
(*Reversed congruence rule!   Used in ZF/Order*)
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   158
qed_goal "conj_cong2" IFOL.thy 
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   159
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (Q&P) <-> (Q'&P')"
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   160
 (fn prems =>
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   161
  [ (cut_facts_tac prems 1),
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   162
    (REPEAT  (ares_tac [iffI,conjI] 1
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   163
      ORELSE  eresolve_tac [iffE,conjE,mp] 1
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   164
      ORELSE  iff_tac prems 1)) ]);
0b5c5f568d74 conj_cong2: new congruence rule
lcp
parents: 779
diff changeset
   165
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   166
qed_goal "disj_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
    "[| P <-> P';  Q <-> Q' |] ==> (P|Q) <-> (P'|Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
    (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   174
qed_goal "imp_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
    (REPEAT   (ares_tac [iffI,impI] 1
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   179
      ORELSE  etac iffE 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
      ORELSE  mp_tac 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   182
qed_goal "iff_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
    "[| P <-> P';  Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
  [ (cut_facts_tac prems 1),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   186
    (REPEAT   (etac iffE 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   190
qed_goal "not_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
    "P <-> P' ==> ~P <-> ~P'"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
    (REPEAT   (ares_tac [iffI,notI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
      ORELSE  mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
      ORELSE  eresolve_tac [iffE,notE] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   198
qed_goal "all_cong" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   199
    "(!!x. P(x) <-> Q(x)) ==> (ALL x. P(x)) <-> (ALL x. Q(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
  [ (REPEAT   (ares_tac [iffI,allI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
      ORELSE   mp_tac 1
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   203
      ORELSE   etac allE 1 ORELSE iff_tac prems 1)) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   205
qed_goal "ex_cong" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   206
    "(!!x. P(x) <-> Q(x)) ==> (EX x. P(x)) <-> (EX x. Q(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
 (fn prems =>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   208
  [ (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   212
qed_goal "ex1_cong" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   213
    "(!!x. P(x) <-> Q(x)) ==> (EX! x. P(x)) <-> (EX! x. Q(x))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
  [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
(*** Equality rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   221
qed_goal "sym" IFOL.thy "a=b ==> b=a"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
 (fn [major] => [ (rtac (major RS subst) 1), (rtac refl 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   224
qed_goal "trans" IFOL.thy "[| a=b;  b=c |] ==> a=c"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
 (fn [prem1,prem2] => [ (rtac (prem2 RS subst) 1), (rtac prem1 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
(** ~ b=a ==> ~ a=b **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
val [not_sym] = compose(sym,2,contrapos);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
5309
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   230
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   231
(* Two theorms for rewriting only one instance of a definition:
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   232
   the first for definitions of formulae and the second for terms *)
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   233
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   234
val prems = goal IFOL.thy "(A == B) ==> A <-> B";
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   235
by (rewrite_goals_tac prems);
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   236
by (rtac iff_refl 1);
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   237
qed "def_imp_iff";
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   238
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   239
val prems = goal IFOL.thy "(A == B) ==> A = B";
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   240
by (rewrite_goals_tac prems);
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   241
by (rtac refl 1);
6113
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   242
qed "meta_eq_to_obj_eq";
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   243
5309
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   244
2037
2c2a95cbb5c9 Declared stac
paulson
parents: 1891
diff changeset
   245
(*Substitution: rule and tactic*)
2c2a95cbb5c9 Declared stac
paulson
parents: 1891
diff changeset
   246
bind_thm ("ssubst", sym RS subst);
5139
013ea0f023e3 stac now uses CHANGED_GOAL and correctly fails when it has no useful effect,
paulson
parents: 4462
diff changeset
   247
5309
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   248
(*Apply an equality or definition ONCE.
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   249
  Fails unless the substitution has an effect*)
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   250
fun stac th = 
6966
cfa87aef9ccd handle THM exn;
wenzelm
parents: 6113
diff changeset
   251
  let val th' = th RS meta_eq_to_obj_eq handle THM _ => th
5309
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   252
  in  CHANGED_GOAL (rtac (th' RS ssubst))
01c2b317da88 stac now handles definitions as well as equalities
paulson
parents: 5139
diff changeset
   253
  end;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
(*A special case of ex1E that would otherwise need quantifier expansion*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   256
qed_goal "ex1_equalsE" IFOL.thy
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   257
    "[| EX! x. P(x);  P(a);  P(b) |] ==> a=b"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
    (etac ex1E 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
    (rtac trans 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
    (rtac sym 2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
    (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
(** Polymorphic congruence rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   267
qed_goal "subst_context" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
   "[| a=b |]  ==>  t(a)=t(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
  [ (resolve_tac (prems RL [ssubst]) 1),
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   271
    (rtac refl 1) ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   273
qed_goal "subst_context2" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
   "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   278
qed_goal "subst_context3" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
   "[| a=b;  c=d;  e=f |]  ==>  t(a,c,e)=t(b,d,f)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
(*Useful with eresolve_tac for proving equalties from known equalities.
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   284
        a = b
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   285
        |   |
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   286
        c = d   *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   287
qed_goal "box_equals" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
    "[| a=b;  a=c;  b=d |] ==> c=d"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
 (fn prems=>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   290
  [ (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   291
    (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   292
    (rtac sym 1),
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
(*Dual of box_equals: for proving equalities backwards*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   296
qed_goal "simp_equals" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
    "[| a=c;  b=d;  c=d |] ==> a=b"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
 (fn prems=>
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   299
  [ (rtac trans 1),
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   300
    (rtac trans 1),
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
    (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
(** Congruence rules for predicate letters **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   305
qed_goal "pred1_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
    "a=a' ==> P(a) <-> P(a')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   309
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   312
qed_goal "pred2_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
    "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   319
qed_goal "pred3_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
    "[| a=a';  b=b';  c=c' |] ==> P(a,b,c) <-> P(a',b',c')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
val pred_congs = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
    flat (map (fn c => 
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   330
               map (fn th => read_instantiate [("P",c)] th)
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   331
                   [pred1_cong,pred2_cong,pred3_cong])
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   332
               (explode"PQRS"));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
(*special case for the equality predicate!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   335
val eq_cong = read_instantiate [("P","op =")] pred2_cong;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
(*** Simplifications of assumed implications.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
     intuitionistic propositional logic.  See
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   342
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   343
    (preprint, University of St Andrews, 1991)  ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   344
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   345
qed_goal "conj_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
    "[| (P&Q)-->S;  P-->(Q-->S) ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
  [ (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   350
qed_goal "disj_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   351
    "[| (P|Q)-->S;  [| P-->S; Q-->S |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   352
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
  [ (DEPTH_SOLVE (ares_tac ([disjI1, disjI2, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   356
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   357
qed_goal "imp_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   358
    "[| (P-->Q)-->S;  [| P; Q-->S |] ==> Q;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
  [ (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   362
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   363
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   364
qed_goal "not_impE" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
    "[| ~P --> S;  P ==> False;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   366
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   367
  [ (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   369
(*Simplifies the implication.   UNSAFE.  *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   370
qed_goal "iff_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   371
    "[| (P<->Q)-->S;  [| P; Q-->S |] ==> Q;  [| Q; P-->S |] ==> P;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   372
\       S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   373
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   374
  [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   376
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   377
qed_goal "all_impE" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   378
    "[| (ALL x. P(x))-->S;  !!x. P(x);  S ==> R |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   379
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   380
  [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   381
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   382
(*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   383
qed_goal "ex_impE" IFOL.thy 
3835
9a5a4e123859 fixed dots;
wenzelm
parents: 3722
diff changeset
   384
    "[| (EX x. P(x))-->S;  P(x)-->S ==> R |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   385
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   386
  [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);
821
650ee089809b Added Krzysztof's theorem disj_imp_disj
lcp
parents: 793
diff changeset
   387
1608
e15e8c0c1e37 Added two of KGs rules
paulson
parents: 1459
diff changeset
   388
(*** Courtesy of Krzysztof Grabczewski ***)
e15e8c0c1e37 Added two of KGs rules
paulson
parents: 1459
diff changeset
   389
821
650ee089809b Added Krzysztof's theorem disj_imp_disj
lcp
parents: 793
diff changeset
   390
val major::prems = goal IFOL.thy "[| P|Q;  P==>R;  Q==>S |] ==> R|S";
1459
d12da312eff4 expanded tabs
clasohm
parents: 1280
diff changeset
   391
by (rtac (major RS disjE) 1);
821
650ee089809b Added Krzysztof's theorem disj_imp_disj
lcp
parents: 793
diff changeset
   392
by (REPEAT (eresolve_tac (prems RL [disjI1, disjI2]) 1));
650ee089809b Added Krzysztof's theorem disj_imp_disj
lcp
parents: 793
diff changeset
   393
qed "disj_imp_disj";
1608
e15e8c0c1e37 Added two of KGs rules
paulson
parents: 1459
diff changeset
   394
3722
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   395
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   396
(** strip ALL and --> from proved goal while preserving ALL-bound var names **)
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   397
6113
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   398
fun make_new_spec rl =
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   399
  (* Use a crazy name to avoid forall_intr failing because of
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   400
     duplicate variable name *)
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   401
  let val myspec = read_instantiate [("P","?wlzickd")] rl
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   402
      val _ $ (_ $ (vx as Var(_,vxT))) = concl_of myspec;
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   403
      val cvx = cterm_of (#sign(rep_thm myspec)) vx
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   404
  in (vxT, forall_intr cvx myspec) end;
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   405
3722
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   406
local
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   407
6113
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   408
val (specT,  spec')  = make_new_spec spec
3722
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   409
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   410
in
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   411
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   412
fun RSspec th =
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   413
  (case concl_of th of
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   414
     _ $ (Const("All",_) $ Abs(a,_,_)) =>
6113
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   415
         let val ca = cterm_of (#sign(rep_thm th)) (Var((a,0),specT))
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   416
         in th RS forall_elim ca spec' end
3722
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   417
  | _ => raise THM("RSspec",0,[th]));
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   418
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   419
fun RSmp th =
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   420
  (case concl_of th of
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   421
     _ $ (Const("op -->",_)$_$_) => th RS mp
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   422
  | _ => raise THM("RSmp",0,[th]));
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   423
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   424
fun normalize_thm funs =
6113
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   425
  let fun trans [] th = th
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   426
	| trans (f::fs) th = (trans funs (f th)) handle THM _ => trans fs th
b321f5aaa5f4 generalized qed_spec_mp code to work for ZF
paulson
parents: 6090
diff changeset
   427
  in trans funs end;
3722
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   428
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   429
fun qed_spec_mp name =
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   430
  let val thm = normalize_thm [RSspec,RSmp] (result())
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   431
  in bind_thm(name, thm) end;
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   432
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   433
fun qed_goal_spec_mp name thy s p = 
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   434
      bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goal thy s p));
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   435
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   436
fun qed_goalw_spec_mp name thy defs s p = 
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   437
      bind_thm (name, normalize_thm [RSspec,RSmp] (prove_goalw thy defs s p));
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   438
24af9e73451e qed_spec_mp, normalize_thm, etc. copied in from HOL.ML
paulson
parents: 2843
diff changeset
   439
end;
5888
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   440
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   441
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   442
(* attributes *)
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   443
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   444
local
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   445
6090
78c068b838ff eliminated Attribute structure;
wenzelm
parents: 6004
diff changeset
   446
fun gen_rulify x = Attrib.no_args (Drule.rule_attribute (K (normalize_thm [RSspec, RSmp]))) x;
5888
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   447
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   448
in
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   449
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   450
val attrib_setup =
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   451
 [Attrib.add_attributes
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   452
  [("rulify", (gen_rulify, gen_rulify), "put theorem into standard rule form")]];
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   453
d8e51792ca85 attrib_setup: rulify;
wenzelm
parents: 5309
diff changeset
   454
end;