src/FOL/IFOL.ML
author clasohm
Tue, 13 Dec 1994 11:51:12 +0100
changeset 779 4ab9176b45b7
parent 12 f17d542276b6
child 793 0b5c5f568d74
permissions -rw-r--r--
removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	FOL/ifol.ML
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Tactics and lemmas for ifol.thy (intuitionistic first-order logic)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open IFOL;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    12
qed_goalw "TrueI" IFOL.thy [True_def] "True"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
 (fn _ => [ (REPEAT (ares_tac [impI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
(*** Sequent-style elimination rules for & --> and ALL ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    17
qed_goal "conjE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
    "[| P&Q; [| P; Q |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  [ (REPEAT (resolve_tac prems 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
      ORELSE (resolve_tac [conjunct1, conjunct2] 1 THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
              resolve_tac prems 1))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    24
qed_goal "impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
    "[| P-->Q;  P;  Q ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    28
qed_goal "allE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
    "[| ALL x.P(x); P(x) ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
(*Duplicates the quantifier; for use with eresolve_tac*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    33
qed_goal "all_dupE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
    "[| ALL x.P(x);  [| P(x); ALL x.P(x) |] ==> R \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
\    |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
(*** Negation rules, which translate between ~P and P-->False ***)
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 "notI" IFOL.thy [not_def] "(P ==> False) ==> ~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    44
qed_goalw "notE" IFOL.thy [not_def] "[| ~P;  P |] ==> R"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  [ (resolve_tac [mp RS FalseE] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
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
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
(* For substitution int an assumption P, reduce Q to P-->Q, substitute into
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
   this implication, then apply impI to move P back into the assumptions.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
   To specify P use something like
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
      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
    59
qed_goal "rev_mp" IFOL.thy "[| P;  P --> Q |] ==> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
(*Contrapositive of an inference rule*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    64
qed_goal "contrapos" IFOL.thy "[| ~Q;  P==>Q |] ==> ~P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
 (fn [major,minor]=> 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
  [ (rtac (major RS notE RS notI) 1), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
    (etac minor 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*** Modus Ponens Tactics ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
fun mp_tac i = eresolve_tac [notE,impE] i  THEN  assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
(*Like mp_tac but instantiates no variables*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
fun eq_mp_tac i = eresolve_tac [notE,impE] i  THEN  eq_assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
(*** If-and-only-if ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    81
qed_goalw "iffI" IFOL.thy [iff_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
   "[| P ==> Q;  Q ==> P |] ==> P<->Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
 (fn prems=> [ (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
(*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
    87
qed_goalw "iffE" IFOL.thy [iff_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
    "[| P <-> Q;  [| P-->Q; Q-->P |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
 (fn prems => [ (resolve_tac [conjE] 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
(* Destruct rules for <-> similar to Modus Ponens *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    93
qed_goalw "iffD1" IFOL.thy [iff_def] "[| P <-> Q;  P |] ==> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    96
qed_goalw "iffD2" IFOL.thy [iff_def] "[| P <-> Q;  Q |] ==> P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
 (fn prems => [ (rtac (conjunct2 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
    99
qed_goal "iff_refl" IFOL.thy "P <-> P"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
 (fn _ => [ (REPEAT (ares_tac [iffI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   102
qed_goal "iff_sym" IFOL.thy "Q <-> P ==> P <-> Q"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
 (fn [major] =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
  [ (rtac (major RS iffE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
    (REPEAT (eresolve_tac [asm_rl,mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   108
qed_goal "iff_trans" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
    "!!P Q R. [| P <-> Q;  Q<-> R |] ==> P <-> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
 (fn _ =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
  [ (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
    (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
(*** Unique existence.  NOTE THAT the following 2 quantifications
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
   EX!x such that [EX!y such that P(x,y)]     (sequential)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
   EX!x,y such that P(x,y)                    (simultaneous)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   121
qed_goalw "ex1I" IFOL.thy [ex1_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
    "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
 (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   125
(*Sometimes easier to use: the premises have no shared variables*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   126
qed_goal "ex_ex1I" IFOL.thy
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   127
    "[| EX x.P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)"
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   128
 (fn [ex,eq] => [ (rtac (ex RS exE) 1),
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   129
		  (REPEAT (ares_tac [ex1I,eq] 1)) ]);
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   130
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   131
qed_goalw "ex1E" IFOL.thy [ex1_def]
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
    "[| EX! x.P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
    (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
(*** <-> congruence rules for simplification ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
fun iff_tac prems i =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
    resolve_tac (prems RL [iffE]) i THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
    REPEAT1 (eresolve_tac [asm_rl,mp] i);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   145
qed_goal "conj_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P&Q) <-> (P'&Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
    (REPEAT  (ares_tac [iffI,conjI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
      ORELSE  eresolve_tac [iffE,conjE,mp] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
      ORELSE  iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   153
qed_goal "disj_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
    "[| P <-> P';  Q <-> Q' |] ==> (P|Q) <-> (P'|Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
    (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   161
qed_goal "imp_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
    (REPEAT   (ares_tac [iffI,impI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
      ORELSE  eresolve_tac [iffE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
      ORELSE  mp_tac 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   169
qed_goal "iff_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
    "[| P <-> P';  Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
    (REPEAT   (eresolve_tac [iffE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   177
qed_goal "not_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
    "P <-> P' ==> ~P <-> ~P'"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
    (REPEAT   (ares_tac [iffI,notI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
      ORELSE  mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
      ORELSE  eresolve_tac [iffE,notE] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   185
qed_goal "all_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
    "(!!x.P(x) <-> Q(x)) ==> (ALL x.P(x)) <-> (ALL x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
  [ (REPEAT   (ares_tac [iffI,allI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
      ORELSE   eresolve_tac [allE] 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   192
qed_goal "ex_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
    "(!!x.P(x) <-> Q(x)) ==> (EX x.P(x)) <-> (EX x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
  [ (REPEAT   (eresolve_tac [exE] 1 ORELSE ares_tac [iffI,exI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   199
qed_goal "ex1_cong" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
    "(!!x.P(x) <-> Q(x)) ==> (EX! x.P(x)) <-> (EX! x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
  [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
(*** Equality rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   208
qed_goal "sym" IFOL.thy "a=b ==> b=a"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
 (fn [major] => [ (rtac (major RS subst) 1), (rtac refl 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   211
qed_goal "trans" IFOL.thy "[| a=b;  b=c |] ==> a=c"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
 (fn [prem1,prem2] => [ (rtac (prem2 RS subst) 1), (rtac prem1 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
(** ~ b=a ==> ~ a=b **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
val [not_sym] = compose(sym,2,contrapos);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
(*calling "standard" reduces maxidx to 0*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   218
bind_thm ("ssubst", (sym RS subst));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
(*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
   221
qed_goal "ex1_equalsE" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
    "[| EX! x.P(x);  P(a);  P(b) |] ==> a=b"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
    (etac ex1E 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
    (rtac trans 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
    (rtac sym 2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
    (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
(** Polymorphic congruence rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   232
qed_goal "subst_context" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
   "[| a=b |]  ==>  t(a)=t(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
  [ (resolve_tac (prems RL [ssubst]) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
    (resolve_tac [refl] 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   238
qed_goal "subst_context2" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
   "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   243
qed_goal "subst_context3" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
   "[| a=b;  c=d;  e=f |]  ==>  t(a,c,e)=t(b,d,f)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
(*Useful with eresolve_tac for proving equalties from known equalities.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
	a = b
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
	|   |
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
	c = d	*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   252
qed_goal "box_equals" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
    "[| a=b;  a=c;  b=d |] ==> c=d"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
  [ (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
    (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
    (resolve_tac [sym] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
(*Dual of box_equals: for proving equalities backwards*)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   261
qed_goal "simp_equals" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
    "[| a=c;  b=d;  c=d |] ==> a=b"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
  [ (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
    (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
    (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
(** Congruence rules for predicate letters **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   270
qed_goal "pred1_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
    "a=a' ==> P(a) <-> P(a')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   277
qed_goal "pred2_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
    "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   284
qed_goal "pred3_cong" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   285
    "[| a=a';  b=b';  c=c' |] ==> P(a,b,c) <-> P(a',b',c')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
val pred_congs = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
    flat (map (fn c => 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
	       map (fn th => read_instantiate [("P",c)] th)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
		   [pred1_cong,pred2_cong,pred3_cong])
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
	       (explode"PQRS"));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
(*special case for the equality predicate!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
val eq_cong = read_instantiate [("P","op =")] pred2_cong;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
(*** Simplifications of assumed implications.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
     intuitionistic propositional logic.  See
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
    (preprint, University of St Andrews, 1991)  ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   309
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   310
qed_goal "conj_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
    "[| (P&Q)-->S;  P-->(Q-->S) ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   312
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
  [ (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   315
qed_goal "disj_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
    "[| (P|Q)-->S;  [| P-->S; Q-->S |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
  [ (DEPTH_SOLVE (ares_tac ([disjI1, disjI2, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
  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
   322
qed_goal "imp_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
    "[| (P-->Q)-->S;  [| P; Q-->S |] ==> Q;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
  [ (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
  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
   329
qed_goal "not_impE" IFOL.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   330
    "[| ~P --> S;  P ==> False;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   331
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   332
  [ (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
(*Simplifies the implication.   UNSAFE.  *)
779
4ab9176b45b7 removed FOL_Lemmas and IFOL_Lemmas; added qed_goal
clasohm
parents: 12
diff changeset
   335
qed_goal "iff_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
    "[| (P<->Q)-->S;  [| P; Q-->S |] ==> Q;  [| Q; P-->S |] ==> P;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
\       S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
  [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
(*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
   342
qed_goal "all_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   343
    "[| (ALL x.P(x))-->S;  !!x.P(x);  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   344
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
  [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
(*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
   348
qed_goal "ex_impE" IFOL.thy 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
    "[| (EX x.P(x))-->S;  P(x)-->S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   350
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   351
  [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);