src/FOL/ifol.ML
author wenzelm
Sun, 15 Oct 2000 19:50:35 +0200
changeset 10220 2a726de6e124
parent 12 f17d542276b6
permissions -rw-r--r--
proper symbol markup with \isamath, \isatext; support sub/super scripts:
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
signature IFOL_LEMMAS = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
  sig
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
  val allE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
  val all_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
  val all_dupE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
  val all_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
  val box_equals: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
  val conjE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  val conj_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  val conj_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  val contrapos: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  val disj_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  val disj_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  val eq_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  val eq_mp_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  val ex1I: thm
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
    27
  val ex_ex1I: thm
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  val ex1E: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
  val ex1_equalsE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
  val ex1_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
  val ex_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  val ex_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  val iffD1: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  val iffD2: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  val iffE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  val iffI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
  val iff_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
  val iff_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  val iff_refl: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  val iff_sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
  val iff_trans: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
  val impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  val imp_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
  val imp_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
  val mp_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  val notE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
  val notI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
  val not_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
  val not_impE: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  val not_sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
  val not_to_imp: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  val pred1_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  val pred2_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  val pred3_cong: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  val pred_congs: thm list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  val rev_mp: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
  val simp_equals: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  val ssubst: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  val subst_context: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
  val subst_context2: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  val subst_context3: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
  val sym: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
  val trans: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
  val TrueI: thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
structure IFOL_Lemmas : IFOL_LEMMAS =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
struct
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
val TrueI = prove_goalw IFOL.thy [True_def] "True"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
 (fn _ => [ (REPEAT (ares_tac [impI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
(*** Sequent-style elimination rules for & --> and ALL ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
val conjE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
    "[| P&Q; [| P; Q |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
  [ (REPEAT (resolve_tac prems 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
      ORELSE (resolve_tac [conjunct1, conjunct2] 1 THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
              resolve_tac prems 1))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
val impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
    "[| P-->Q;  P;  Q ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
val allE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
    "[| ALL x.P(x); P(x) ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
(*Duplicates the quantifier; for use with eresolve_tac*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
val all_dupE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
    "[| ALL x.P(x);  [| P(x); ALL x.P(x) |] ==> R \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
\    |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
 (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
(*** Negation rules, which translate between ~P and P-->False ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
val notI = prove_goalw IFOL.thy [not_def] "(P ==> False) ==> ~P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
val notE = prove_goalw IFOL.thy [not_def] "[| ~P;  P |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
  [ (resolve_tac [mp RS FalseE] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
(*This is useful with the special implication rules for each kind of P. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
val not_to_imp = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
    "[| ~P;  (P-->False) ==> Q |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI,notE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
(* For substitution int an assumption P, reduce Q to P-->Q, substitute into
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
   this implication, then apply impI to move P back into the assumptions.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
   To specify P use something like
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
      eres_inst_tac [ ("P","ALL y. ?S(x,y)") ] rev_mp 1   *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
val rev_mp = prove_goal IFOL.thy "[| P;  P --> Q |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
(*Contrapositive of an inference rule*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
val contrapos = prove_goal IFOL.thy "[| ~Q;  P==>Q |] ==> ~P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
 (fn [major,minor]=> 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
  [ (rtac (major RS notE RS notI) 1), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
    (etac minor 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
(*** Modus Ponens Tactics ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
fun mp_tac i = eresolve_tac [notE,impE] i  THEN  assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
(*Like mp_tac but instantiates no variables*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
fun eq_mp_tac i = eresolve_tac [notE,impE] i  THEN  eq_assume_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
(*** If-and-only-if ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
val iffI = prove_goalw IFOL.thy [iff_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
   "[| P ==> Q;  Q ==> P |] ==> P<->Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
 (fn prems=> [ (REPEAT (ares_tac (prems@[conjI, impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
val iffE = prove_goalw IFOL.thy [iff_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
    "[| P <-> Q;  [| P-->Q; Q-->P |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
 (fn prems => [ (resolve_tac [conjE] 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
(* Destruct rules for <-> similar to Modus Ponens *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
val iffD1 = prove_goalw IFOL.thy [iff_def] "[| P <-> Q;  P |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
 (fn prems => [ (rtac (conjunct1 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
val iffD2 = prove_goalw IFOL.thy [iff_def] "[| P <-> Q;  Q |] ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
 (fn prems => [ (rtac (conjunct2 RS mp) 1), (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
val iff_refl = prove_goal IFOL.thy "P <-> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
 (fn _ => [ (REPEAT (ares_tac [iffI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
val iff_sym = prove_goal IFOL.thy "Q <-> P ==> P <-> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
 (fn [major] =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
  [ (rtac (major RS iffE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
    (REPEAT (eresolve_tac [asm_rl,mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
val iff_trans = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
    "!!P Q R. [| P <-> Q;  Q<-> R |] ==> P <-> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
 (fn _ =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
  [ (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
    (REPEAT (eresolve_tac [asm_rl,iffE] 1 ORELSE mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
(*** Unique existence.  NOTE THAT the following 2 quantifications
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
   EX!x such that [EX!y such that P(x,y)]     (sequential)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
   EX!x,y such that P(x,y)                    (simultaneous)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
val ex1I = prove_goalw IFOL.thy [ex1_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
    "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
 (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
12
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   184
(*Sometimes easier to use: the premises have no shared variables*)
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   185
val ex_ex1I = prove_goal IFOL.thy
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   186
    "[| 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
   187
 (fn [ex,eq] => [ (rtac (ex RS exE) 1),
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   188
		  (REPEAT (ares_tac [ex1I,eq] 1)) ]);
f17d542276b6 Added ex_ex1I: new introduction rule for the EX! quantifier.
lcp
parents: 0
diff changeset
   189
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
val ex1E = prove_goalw IFOL.thy [ex1_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
    "[| EX! x.P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R"
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 (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
(*** <-> congruence rules for simplification ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
fun iff_tac prems i =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
    resolve_tac (prems RL [iffE]) i THEN
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
    REPEAT1 (eresolve_tac [asm_rl,mp] i);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
val conj_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P&Q) <-> (P'&Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
    (REPEAT  (ares_tac [iffI,conjI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
      ORELSE  eresolve_tac [iffE,conjE,mp] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
      ORELSE  iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
val disj_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
    "[| P <-> P';  Q <-> Q' |] ==> (P|Q) <-> (P'|Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
    (REPEAT  (eresolve_tac [iffE,disjE,disjI1,disjI2] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
val imp_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
    "[| P <-> P';  P' ==> Q <-> Q' |] ==> (P-->Q) <-> (P'-->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
    (REPEAT   (ares_tac [iffI,impI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
      ORELSE  eresolve_tac [iffE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
      ORELSE  mp_tac 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
val iff_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
    "[| P <-> P';  Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
    (REPEAT   (eresolve_tac [iffE] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
      ORELSE  ares_tac [iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
      ORELSE  mp_tac 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
val not_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
    "P <-> P' ==> ~P <-> ~P'"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
    (REPEAT   (ares_tac [iffI,notI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
      ORELSE  mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
      ORELSE  eresolve_tac [iffE,notE] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
val all_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
    "(!!x.P(x) <-> Q(x)) ==> (ALL x.P(x)) <-> (ALL x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
  [ (REPEAT   (ares_tac [iffI,allI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
      ORELSE   eresolve_tac [allE] 1 ORELSE iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
val ex_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
    "(!!x.P(x) <-> Q(x)) ==> (EX x.P(x)) <-> (EX x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
  [ (REPEAT   (eresolve_tac [exE] 1 ORELSE ares_tac [iffI,exI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
val ex1_cong = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
    "(!!x.P(x) <-> Q(x)) ==> (EX! x.P(x)) <-> (EX! x.Q(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
  [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
      ORELSE   mp_tac 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
      ORELSE   iff_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
(*** Equality rules ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
val sym = prove_goal IFOL.thy "a=b ==> b=a"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
 (fn [major] => [ (rtac (major RS subst) 1), (rtac refl 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
val trans = prove_goal IFOL.thy "[| a=b;  b=c |] ==> a=c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
 (fn [prem1,prem2] => [ (rtac (prem2 RS subst) 1), (rtac prem1 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
(** ~ b=a ==> ~ a=b **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
val [not_sym] = compose(sym,2,contrapos);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
(*calling "standard" reduces maxidx to 0*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
val ssubst = standard (sym RS subst);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
(*A special case of ex1E that would otherwise need quantifier expansion*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
val ex1_equalsE = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
    "[| EX! x.P(x);  P(a);  P(b) |] ==> a=b"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
    (etac ex1E 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   285
    (rtac trans 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
    (rtac sym 2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
    (REPEAT (eresolve_tac [asm_rl, spec RS mp] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
(** Polymorphic congruence rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
val subst_context = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
   "[| a=b |]  ==>  t(a)=t(b)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
  [ (resolve_tac (prems RL [ssubst]) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
    (resolve_tac [refl] 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
val subst_context2 = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
   "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
val subst_context3 = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
   "[| a=b;  c=d;  e=f |]  ==>  t(a,c,e)=t(b,d,f)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
  [ (EVERY1 (map rtac ((prems RL [ssubst]) @ [refl]))) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
(*Useful with eresolve_tac for proving equalties from known equalities.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
	a = b
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   309
	|   |
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
	c = d	*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
val box_equals = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   312
    "[| a=b;  a=c;  b=d |] ==> c=d"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
  [ (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
    (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
    (resolve_tac [sym] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
    (REPEAT (resolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
(*Dual of box_equals: for proving equalities backwards*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
val simp_equals = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
    "[| a=c;  b=d;  c=d |] ==> a=b"  
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
  [ (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
    (resolve_tac [trans] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
    (REPEAT (resolve_tac (prems @ (prems RL [sym])) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
(** Congruence rules for predicate letters **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
val pred1_cong = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   330
    "a=a' ==> P(a) <-> P(a')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   331
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   332
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   335
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
val pred2_cong = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
    "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   342
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   343
val pred3_cong = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   344
    "[| a=a';  b=b';  c=c' |] ==> P(a,b,c) <-> P(a',b',c')"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
 (fn prems =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
    (rtac iffI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
    (DEPTH_SOLVE (eresolve_tac [asm_rl, subst, ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   350
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   351
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   352
val pred_congs = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
    flat (map (fn c => 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
	       map (fn th => read_instantiate [("P",c)] th)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
		   [pred1_cong,pred2_cong,pred3_cong])
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   356
	       (explode"PQRS"));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   357
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   358
(*special case for the equality predicate!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
val eq_cong = read_instantiate [("P","op =")] pred2_cong;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   362
(*** Simplifications of assumed implications.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   363
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   364
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
     intuitionistic propositional logic.  See
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   366
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   367
    (preprint, University of St Andrews, 1991)  ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   369
val conj_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   370
    "[| (P&Q)-->S;  P-->(Q-->S) ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   371
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   372
  [ (REPEAT (ares_tac ([conjI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   373
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   374
val disj_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
    "[| (P|Q)-->S;  [| P-->S; Q-->S |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   376
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   377
  [ (DEPTH_SOLVE (ares_tac ([disjI1, disjI2, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   378
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   379
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   380
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   381
val imp_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   382
    "[| (P-->Q)-->S;  [| P; Q-->S |] ==> Q;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   383
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   384
  [ (REPEAT (ares_tac ([impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   385
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   386
(*Simplifies the implication.  Classical version is stronger. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   387
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   388
val not_impE = prove_goal IFOL.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   389
    "[| ~P --> S;  P ==> False;  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   390
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   391
  [ (REPEAT (ares_tac ([notI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   392
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   393
(*Simplifies the implication.   UNSAFE.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   394
val iff_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   395
    "[| (P<->Q)-->S;  [| P; Q-->S |] ==> Q;  [| Q; P-->S |] ==> P;  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   396
\       S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   397
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   398
  [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   399
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   400
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   401
val all_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   402
    "[| (ALL x.P(x))-->S;  !!x.P(x);  S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   403
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   404
  [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   405
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   406
(*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   407
val ex_impE = prove_goal IFOL.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   408
    "[| (EX x.P(x))-->S;  P(x)-->S ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   409
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   410
  [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   411
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   412
end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   413
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   414
open IFOL_Lemmas;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   415