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