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