src/HOL/HOL_lemmas.ML
author oheimb
Wed Jan 31 10:15:55 2001 +0100 (2001-01-31)
changeset 11008 f7333f055ef6
parent 11006 e85c0e2f33d6
child 11415 34a76158cbb8
permissions -rw-r--r--
improved theory reference in comment
wenzelm@7357
     1
(*  Title:      HOL/HOL_lemmas.ML
wenzelm@7357
     2
    ID:         $Id$
wenzelm@7357
     3
    Author:     Tobias Nipkow
wenzelm@7357
     4
    Copyright   1991  University of Cambridge
wenzelm@7357
     5
wenzelm@7357
     6
Derived rules from Appendix of Mike Gordons HOL Report, Cambridge TR 68.
wenzelm@7357
     7
*)
wenzelm@7357
     8
wenzelm@7357
     9
(* ML bindings *)
wenzelm@7357
    10
wenzelm@7357
    11
val plusI = thm "plusI";
wenzelm@7357
    12
val minusI = thm "minusI";
wenzelm@7357
    13
val timesI = thm "timesI";
wenzelm@7357
    14
val eq_reflection = thm "eq_reflection";
wenzelm@7357
    15
val refl = thm "refl";
wenzelm@7357
    16
val subst = thm "subst";
wenzelm@7357
    17
val ext = thm "ext";
paulson@9970
    18
val someI = thm "someI";
wenzelm@7357
    19
val impI = thm "impI";
wenzelm@7357
    20
val mp = thm "mp";
wenzelm@7357
    21
val True_def = thm "True_def";
wenzelm@7357
    22
val All_def = thm "All_def";
wenzelm@7357
    23
val Ex_def = thm "Ex_def";
wenzelm@7357
    24
val False_def = thm "False_def";
wenzelm@7357
    25
val not_def = thm "not_def";
wenzelm@7357
    26
val and_def = thm "and_def";
wenzelm@7357
    27
val or_def = thm "or_def";
wenzelm@7357
    28
val Ex1_def = thm "Ex1_def";
wenzelm@7357
    29
val iff = thm "iff";
wenzelm@7357
    30
val True_or_False = thm "True_or_False";
wenzelm@7357
    31
val Let_def = thm "Let_def";
wenzelm@7357
    32
val if_def = thm "if_def";
wenzelm@7357
    33
val arbitrary_def = thm "arbitrary_def";
wenzelm@7357
    34
wenzelm@7357
    35
wenzelm@10063
    36
section "Equality";
wenzelm@7357
    37
paulson@7618
    38
Goal "s=t ==> t=s";
paulson@7618
    39
by (etac subst 1);
paulson@7618
    40
by (rtac refl 1);
paulson@7618
    41
qed "sym";
wenzelm@7357
    42
wenzelm@7357
    43
(*calling "standard" reduces maxidx to 0*)
paulson@7618
    44
bind_thm ("ssubst", sym RS subst);
wenzelm@7357
    45
paulson@7618
    46
Goal "[| r=s; s=t |] ==> r=t";
paulson@7618
    47
by (etac subst 1 THEN assume_tac 1);
paulson@7618
    48
qed "trans";
wenzelm@7357
    49
paulson@9969
    50
val prems = goal (the_context()) "(A == B) ==> A = B";
wenzelm@7357
    51
by (rewrite_goals_tac prems);
wenzelm@7357
    52
by (rtac refl 1);
wenzelm@7357
    53
qed "def_imp_eq";
wenzelm@7357
    54
wenzelm@7357
    55
(*Useful with eresolve_tac for proving equalties from known equalities.
wenzelm@7357
    56
        a = b
wenzelm@7357
    57
        |   |
wenzelm@7357
    58
        c = d   *)
wenzelm@7357
    59
Goal "[| a=b;  a=c;  b=d |] ==> c=d";
wenzelm@7357
    60
by (rtac trans 1);
wenzelm@7357
    61
by (rtac trans 1);
wenzelm@7357
    62
by (rtac sym 1);
wenzelm@7357
    63
by (REPEAT (assume_tac 1)) ;
wenzelm@7357
    64
qed "box_equals";
wenzelm@7357
    65
wenzelm@10063
    66
wenzelm@10063
    67
section "Congruence rules for application";
wenzelm@7357
    68
wenzelm@7357
    69
(*similar to AP_THM in Gordon's HOL*)
paulson@7618
    70
Goal "(f::'a=>'b) = g ==> f(x)=g(x)";
paulson@7618
    71
by (etac subst 1);
paulson@7618
    72
by (rtac refl 1);
paulson@7618
    73
qed "fun_cong";
wenzelm@7357
    74
wenzelm@7357
    75
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
paulson@7618
    76
Goal "x=y ==> f(x)=f(y)";
paulson@7618
    77
by (etac subst 1);
paulson@7618
    78
by (rtac refl 1);
paulson@7618
    79
qed "arg_cong";
wenzelm@7357
    80
paulson@7618
    81
Goal "[| f = g; (x::'a) = y |] ==> f(x) = g(y)";
paulson@7618
    82
by (etac subst 1);
paulson@7618
    83
by (etac subst 1);
paulson@7618
    84
by (rtac refl 1);
paulson@7618
    85
qed "cong";
wenzelm@7357
    86
wenzelm@10063
    87
wenzelm@10063
    88
section "Equality of booleans -- iff";
wenzelm@7357
    89
paulson@7618
    90
val prems = Goal "[| P ==> Q;  Q ==> P |] ==> P=Q";
wenzelm@7357
    91
by (REPEAT (ares_tac (prems@[impI, iff RS mp RS mp]) 1));
wenzelm@7357
    92
qed "iffI";
wenzelm@7357
    93
paulson@7618
    94
Goal "[| P=Q; Q |] ==> P";
paulson@7618
    95
by (etac ssubst 1);
paulson@7618
    96
by (assume_tac 1);
paulson@7618
    97
qed "iffD2";
wenzelm@7357
    98
paulson@7618
    99
Goal "[| Q; P=Q |] ==> P";
paulson@7618
   100
by (etac iffD2 1);
paulson@7618
   101
by (assume_tac 1);
paulson@7618
   102
qed "rev_iffD2";
wenzelm@7357
   103
wenzelm@7357
   104
bind_thm ("iffD1", sym RS iffD2);
wenzelm@7357
   105
bind_thm ("rev_iffD1", sym RSN (2, rev_iffD2));
wenzelm@7357
   106
paulson@7618
   107
val [p1,p2] = Goal "[| P=Q; [| P --> Q; Q --> P |] ==> R |] ==> R";
paulson@7618
   108
by (REPEAT (ares_tac [p1 RS iffD2, p1 RS iffD1, p2, impI] 1));
paulson@7618
   109
qed "iffE";
wenzelm@7357
   110
wenzelm@7357
   111
wenzelm@7357
   112
section "True";
wenzelm@7357
   113
paulson@7618
   114
Goalw [True_def] "True";
paulson@7618
   115
by (rtac refl 1);
paulson@7618
   116
qed "TrueI";
wenzelm@7357
   117
paulson@7618
   118
Goal "P ==> P=True";
paulson@7618
   119
by (REPEAT (ares_tac [iffI,TrueI] 1));
paulson@7618
   120
qed "eqTrueI";
wenzelm@7357
   121
paulson@7618
   122
Goal "P=True ==> P";
paulson@7618
   123
by (etac iffD2 1);
paulson@7618
   124
by (rtac TrueI 1);
paulson@7618
   125
qed "eqTrueE";
wenzelm@7357
   126
wenzelm@7357
   127
wenzelm@10063
   128
section "Universal quantifier";
wenzelm@7357
   129
paulson@9159
   130
val prems = Goalw [All_def] "(!!x::'a. P(x)) ==> ALL x. P(x)";
paulson@8529
   131
by (resolve_tac (prems RL [eqTrueI RS ext]) 1);
paulson@8529
   132
qed "allI";
wenzelm@7357
   133
paulson@9159
   134
Goalw [All_def] "ALL x::'a. P(x) ==> P(x)";
paulson@8529
   135
by (rtac eqTrueE 1);
paulson@8529
   136
by (etac fun_cong 1);
paulson@8529
   137
qed "spec";
wenzelm@7357
   138
paulson@9969
   139
val major::prems = Goal "[| ALL x. P(x);  P(x) ==> R |] ==> R";
wenzelm@7357
   140
by (REPEAT (resolve_tac (prems @ [major RS spec]) 1)) ;
wenzelm@7357
   141
qed "allE";
wenzelm@7357
   142
paulson@9969
   143
val prems = Goal
paulson@9159
   144
    "[| ALL x. P(x);  [| P(x); ALL x. P(x) |] ==> R |] ==> R";
wenzelm@7357
   145
by (REPEAT (resolve_tac (prems @ (prems RL [spec])) 1)) ;
wenzelm@7357
   146
qed "all_dupE";
wenzelm@7357
   147
wenzelm@7357
   148
wenzelm@7357
   149
section "False";
wenzelm@10063
   150
(*Depends upon spec; it is impossible to do propositional logic before quantifiers!*)
wenzelm@7357
   151
paulson@8529
   152
Goalw [False_def] "False ==> P";
paulson@8529
   153
by (etac spec 1);
paulson@8529
   154
qed "FalseE";
wenzelm@7357
   155
paulson@8529
   156
Goal "False=True ==> P";
paulson@8529
   157
by (etac (eqTrueE RS FalseE) 1);
paulson@8529
   158
qed "False_neq_True";
wenzelm@7357
   159
wenzelm@7357
   160
wenzelm@10063
   161
section "Negation";
wenzelm@7357
   162
paulson@8529
   163
val prems = Goalw [not_def] "(P ==> False) ==> ~P";
paulson@8529
   164
by (rtac impI 1);
paulson@8529
   165
by (eresolve_tac prems 1);
paulson@8529
   166
qed "notI";
wenzelm@7357
   167
paulson@8529
   168
Goal "False ~= True";
paulson@8529
   169
by (rtac notI 1);
paulson@8529
   170
by (etac False_neq_True 1);
paulson@8529
   171
qed "False_not_True";
wenzelm@7357
   172
paulson@8529
   173
Goal "True ~= False";
paulson@8529
   174
by (rtac notI 1);
paulson@8529
   175
by (dtac sym 1);
paulson@8529
   176
by (etac False_neq_True 1);
paulson@8529
   177
qed "True_not_False";
wenzelm@7357
   178
paulson@8529
   179
Goalw [not_def] "[| ~P;  P |] ==> R";
paulson@8529
   180
by (etac (mp RS FalseE) 1);
paulson@8529
   181
by (assume_tac 1);
paulson@8529
   182
qed "notE";
wenzelm@7357
   183
paulson@9159
   184
(* Alternative ~ introduction rule: [| P ==> ~ Pa; P ==> Pa |] ==> ~ P *)
paulson@9159
   185
bind_thm ("notI2", notE RS notI);
wenzelm@7357
   186
wenzelm@7357
   187
wenzelm@10063
   188
section "Implication";
wenzelm@7357
   189
wenzelm@7357
   190
val prems = Goal "[| P-->Q;  P;  Q ==> R |] ==> R";
wenzelm@7357
   191
by (REPEAT (resolve_tac (prems@[mp]) 1));
wenzelm@7357
   192
qed "impE";
wenzelm@7357
   193
wenzelm@7357
   194
(* Reduces Q to P-->Q, allowing substitution in P. *)
wenzelm@7357
   195
Goal "[| P;  P --> Q |] ==> Q";
wenzelm@7357
   196
by (REPEAT (ares_tac [mp] 1)) ;
wenzelm@7357
   197
qed "rev_mp";
wenzelm@7357
   198
wenzelm@7357
   199
val [major,minor] = Goal "[| ~Q;  P==>Q |] ==> ~P";
wenzelm@7357
   200
by (rtac (major RS notE RS notI) 1);
wenzelm@7357
   201
by (etac minor 1) ;
paulson@10231
   202
qed "contrapos_nn";
wenzelm@7357
   203
paulson@10231
   204
Goal "t ~= s ==> s ~= t";
paulson@10231
   205
by (etac contrapos_nn 1); 
paulson@10231
   206
by (etac sym 1); 
paulson@10231
   207
qed "not_sym";
paulson@10231
   208
paulson@10231
   209
(*still used in HOLCF*)
wenzelm@7357
   210
val [major,minor] = Goal "[| P==>Q; ~Q |] ==> ~P";
paulson@10231
   211
by (rtac (minor RS contrapos_nn) 1);
wenzelm@7357
   212
by (etac major 1) ;
wenzelm@7357
   213
qed "rev_contrapos";
wenzelm@7357
   214
wenzelm@10063
   215
section "Existential quantifier";
wenzelm@7357
   216
paulson@9159
   217
Goalw [Ex_def] "P x ==> EX x::'a. P x";
paulson@9970
   218
by (etac someI 1) ;
paulson@8529
   219
qed "exI";
wenzelm@7357
   220
wenzelm@9869
   221
val [major,minor] =
paulson@9159
   222
Goalw [Ex_def] "[| EX x::'a. P(x); !!x. P(x) ==> Q |] ==> Q";
paulson@8529
   223
by (rtac (major RS minor) 1);
paulson@8529
   224
qed "exE";
wenzelm@7357
   225
wenzelm@7357
   226
wenzelm@10063
   227
section "Conjunction";
wenzelm@7357
   228
paulson@8529
   229
Goalw [and_def] "[| P; Q |] ==> P&Q";
paulson@8529
   230
by (rtac (impI RS allI) 1);
paulson@8529
   231
by (etac (mp RS mp) 1);
paulson@8529
   232
by (REPEAT (assume_tac 1));
paulson@8529
   233
qed "conjI";
wenzelm@7357
   234
paulson@8529
   235
Goalw [and_def] "[| P & Q |] ==> P";
paulson@8529
   236
by (dtac spec 1) ;
paulson@8529
   237
by (etac mp 1);
paulson@8529
   238
by (REPEAT (ares_tac [impI] 1));
paulson@8529
   239
qed "conjunct1";
wenzelm@7357
   240
paulson@8529
   241
Goalw [and_def] "[| P & Q |] ==> Q";
paulson@8529
   242
by (dtac spec 1) ;
paulson@8529
   243
by (etac mp 1);
paulson@8529
   244
by (REPEAT (ares_tac [impI] 1));
paulson@8529
   245
qed "conjunct2";
wenzelm@7357
   246
paulson@8529
   247
val [major,minor] =
paulson@8529
   248
Goal "[| P&Q;  [| P; Q |] ==> R |] ==> R";
paulson@8529
   249
by (rtac minor 1);
paulson@8529
   250
by (rtac (major RS conjunct1) 1);
paulson@8529
   251
by (rtac (major RS conjunct2) 1);
paulson@8529
   252
qed "conjE";
wenzelm@7357
   253
paulson@8529
   254
val prems =
paulson@8529
   255
Goal "[| P; P ==> Q |] ==> P & Q";
paulson@8529
   256
by (REPEAT (resolve_tac (conjI::prems) 1));
paulson@8529
   257
qed "context_conjI";
wenzelm@7357
   258
wenzelm@7357
   259
wenzelm@10063
   260
section "Disjunction";
wenzelm@7357
   261
paulson@8529
   262
Goalw [or_def] "P ==> P|Q";
paulson@8529
   263
by (REPEAT (resolve_tac [allI,impI] 1));
paulson@8529
   264
by (etac mp 1 THEN assume_tac 1);
paulson@8529
   265
qed "disjI1";
wenzelm@7357
   266
paulson@8529
   267
Goalw [or_def] "Q ==> P|Q";
paulson@8529
   268
by (REPEAT (resolve_tac [allI,impI] 1));
paulson@8529
   269
by (etac mp 1 THEN assume_tac 1);
paulson@8529
   270
qed "disjI2";
wenzelm@7357
   271
paulson@8529
   272
val [major,minorP,minorQ] =
paulson@8529
   273
Goalw [or_def]  "[| P | Q; P ==> R; Q ==> R |] ==> R";
paulson@8529
   274
by (rtac (major RS spec RS mp RS mp) 1);
paulson@8529
   275
by (DEPTH_SOLVE (ares_tac [impI,minorP,minorQ] 1));
paulson@8529
   276
qed "disjE";
wenzelm@7357
   277
wenzelm@7357
   278
wenzelm@10063
   279
section "Classical logic";
wenzelm@10063
   280
(*CCONTR -- classical logic*)
wenzelm@7357
   281
paulson@8529
   282
val [prem] = Goal  "(~P ==> P) ==> P";
paulson@8529
   283
by (rtac (True_or_False RS disjE RS eqTrueE) 1);
paulson@8529
   284
by (assume_tac 1);
paulson@8529
   285
by (rtac (notI RS prem RS eqTrueI) 1);
paulson@8529
   286
by (etac subst 1);
paulson@8529
   287
by (assume_tac 1);
paulson@8529
   288
qed "classical";
wenzelm@7357
   289
wenzelm@7832
   290
bind_thm ("ccontr", FalseE RS classical);
wenzelm@7357
   291
paulson@9159
   292
(*notE with premises exchanged; it discharges ~R so that it can be used to
paulson@9159
   293
  make elimination rules*)
paulson@9159
   294
val [premp,premnot] = Goal "[| P; ~R ==> ~P |] ==> R";
paulson@9159
   295
by (rtac ccontr 1);
paulson@9159
   296
by (etac ([premnot,premp] MRS notE) 1);
paulson@9159
   297
qed "rev_notE";
paulson@9159
   298
wenzelm@7357
   299
(*Double negation law*)
wenzelm@7357
   300
Goal "~~P ==> P";
wenzelm@7357
   301
by (rtac classical 1);
wenzelm@7357
   302
by (etac notE 1);
wenzelm@7357
   303
by (assume_tac 1);
wenzelm@7357
   304
qed "notnotD";
wenzelm@7357
   305
wenzelm@7357
   306
val [p1,p2] = Goal "[| Q; ~ P ==> ~ Q |] ==> P";
wenzelm@7357
   307
by (rtac classical 1);
wenzelm@7357
   308
by (dtac p2 1);
wenzelm@7357
   309
by (etac notE 1);
wenzelm@7357
   310
by (rtac p1 1);
paulson@10231
   311
qed "contrapos_pp";
wenzelm@7357
   312
wenzelm@10063
   313
wenzelm@10063
   314
section "Unique existence";
wenzelm@7357
   315
paulson@9159
   316
val prems = Goalw [Ex1_def] "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)";
paulson@8529
   317
by (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1));
paulson@8529
   318
qed "ex1I";
wenzelm@7357
   319
wenzelm@7357
   320
(*Sometimes easier to use: the premises have no shared variables.  Safe!*)
paulson@8529
   321
val [ex_prem,eq] = Goal
paulson@9159
   322
    "[| EX x. P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)";
paulson@8529
   323
by (rtac (ex_prem RS exE) 1);
wenzelm@7357
   324
by (REPEAT (ares_tac [ex1I,eq] 1)) ;
wenzelm@7357
   325
qed "ex_ex1I";
wenzelm@7357
   326
paulson@8529
   327
val major::prems = Goalw [Ex1_def]
paulson@9159
   328
    "[| EX! x. P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R";
paulson@8529
   329
by (rtac (major RS exE) 1);
paulson@8529
   330
by (REPEAT (etac conjE 1 ORELSE ares_tac prems 1));
paulson@8529
   331
qed "ex1E";
wenzelm@7357
   332
paulson@9159
   333
Goal "EX! x. P x ==> EX x. P x";
wenzelm@7357
   334
by (etac ex1E 1);
wenzelm@7357
   335
by (rtac exI 1);
wenzelm@7357
   336
by (assume_tac 1);
wenzelm@7357
   337
qed "ex1_implies_ex";
wenzelm@7357
   338
wenzelm@7357
   339
wenzelm@10063
   340
section "SOME: Hilbert's Epsilon-operator";
wenzelm@7357
   341
paulson@9970
   342
(*Easier to apply than someI if witness ?a comes from an EX-formula*)
paulson@9969
   343
Goal "EX x. P x ==> P (SOME x. P x)";
nipkow@9404
   344
by (etac exE 1);
paulson@9970
   345
by (etac someI 1);
nipkow@10175
   346
qed "someI_ex";
nipkow@9404
   347
paulson@9970
   348
(*Easier to apply than someI: conclusion has only one occurrence of P*)
oheimb@11006
   349
val prems = Goal "[| P a;  !!x. P x ==> Q x |] ==> Q (SOME x. P x)";
wenzelm@7357
   350
by (resolve_tac prems 1);
paulson@9970
   351
by (rtac someI 1);
wenzelm@7357
   352
by (resolve_tac prems 1) ;
paulson@9969
   353
qed "someI2";
wenzelm@7357
   354
paulson@9969
   355
(*Easier to apply than someI2 if witness ?a comes from an EX-formula*)
oheimb@11006
   356
val [major,minor] = Goal "[| EX a. P a; !!x. P x ==> Q x |] ==> Q (SOME x. P x)";
paulson@8529
   357
by (rtac (major RS exE) 1);
paulson@9969
   358
by (etac someI2 1 THEN etac minor 1);
wenzelm@9998
   359
qed "someI2_ex";
wenzelm@7357
   360
oheimb@11006
   361
val prems = Goal "[| P a;  !!x. P x ==> x=a |] ==> (SOME x. P x) = a";
paulson@9969
   362
by (rtac someI2 1);
wenzelm@7357
   363
by (REPEAT (ares_tac prems 1)) ;
paulson@9969
   364
qed "some_equality";
wenzelm@7357
   365
oheimb@11006
   366
Goal "[| EX!x. P x; P a |] ==> (SOME x. P x) = a";
paulson@9969
   367
by (rtac some_equality 1);
oheimb@11006
   368
by  (atac 1);
oheimb@11006
   369
by (etac ex1E 1);
oheimb@11006
   370
by (etac all_dupE 1);
oheimb@11006
   371
by (dtac mp 1);
oheimb@11006
   372
by  (atac 1);
wenzelm@7357
   373
by (etac ssubst 1);
wenzelm@7357
   374
by (etac allE 1);
wenzelm@7357
   375
by (etac mp 1);
wenzelm@7357
   376
by (atac 1);
paulson@9969
   377
qed "some1_equality";
wenzelm@7357
   378
nipkow@10175
   379
Goal "P (SOME x. P x) =  (EX x. P x)";
wenzelm@7357
   380
by (rtac iffI 1);
wenzelm@7357
   381
by (etac exI 1);
wenzelm@7357
   382
by (etac exE 1);
paulson@9970
   383
by (etac someI 1);
paulson@9969
   384
qed "some_eq_ex";
wenzelm@7357
   385
nipkow@10175
   386
Goal "(SOME y. y=x) = x";
paulson@9969
   387
by (rtac some_equality 1);
wenzelm@7357
   388
by (rtac refl 1);
wenzelm@7357
   389
by (atac 1);
paulson@9969
   390
qed "some_eq_trivial";
wenzelm@7357
   391
nipkow@10175
   392
Goal "(SOME y. x=y) = x";
paulson@9969
   393
by (rtac some_equality 1);
wenzelm@7357
   394
by (rtac refl 1);
wenzelm@7357
   395
by (etac sym 1);
paulson@9969
   396
qed "some_sym_eq_trivial";
wenzelm@7357
   397
wenzelm@10063
   398
wenzelm@10063
   399
section "Classical intro rules for disjunction and existential quantifiers";
wenzelm@7357
   400
paulson@9969
   401
val prems = Goal "(~Q ==> P) ==> P|Q";
wenzelm@7357
   402
by (rtac classical 1);
wenzelm@7357
   403
by (REPEAT (ares_tac (prems@[disjI1,notI]) 1));
wenzelm@7357
   404
by (REPEAT (ares_tac (prems@[disjI2,notE]) 1)) ;
wenzelm@7357
   405
qed "disjCI";
wenzelm@7357
   406
wenzelm@7357
   407
Goal "~P | P";
wenzelm@7357
   408
by (REPEAT (ares_tac [disjCI] 1)) ;
wenzelm@7357
   409
qed "excluded_middle";
wenzelm@7357
   410
wenzelm@7357
   411
(*For disjunctive case analysis*)
wenzelm@7357
   412
fun excluded_middle_tac sP =
wenzelm@7357
   413
    res_inst_tac [("Q",sP)] (excluded_middle RS disjE);
wenzelm@7357
   414
wenzelm@7357
   415
(*Classical implies (-->) elimination. *)
wenzelm@7357
   416
val major::prems = Goal "[| P-->Q; ~P ==> R; Q ==> R |] ==> R";
wenzelm@7357
   417
by (rtac (excluded_middle RS disjE) 1);
wenzelm@7357
   418
by (REPEAT (DEPTH_SOLVE_1 (ares_tac (prems @ [major RS mp]) 1)));
wenzelm@7357
   419
qed "impCE";
wenzelm@7357
   420
wenzelm@7357
   421
(*This version of --> elimination works on Q before P.  It works best for
wenzelm@7357
   422
  those cases in which P holds "almost everywhere".  Can't install as
wenzelm@7357
   423
  default: would break old proofs.*)
wenzelm@7357
   424
val major::prems = Goal
wenzelm@7357
   425
    "[| P-->Q;  Q ==> R;  ~P ==> R |] ==> R";
wenzelm@7357
   426
by (resolve_tac [excluded_middle RS disjE] 1);
wenzelm@7357
   427
by (DEPTH_SOLVE (ares_tac (prems@[major RS mp]) 1)) ;
wenzelm@7357
   428
qed "impCE'";
wenzelm@7357
   429
wenzelm@7357
   430
(*Classical <-> elimination. *)
wenzelm@7357
   431
val major::prems = Goal
wenzelm@7357
   432
    "[| P=Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R";
wenzelm@7357
   433
by (rtac (major RS iffE) 1);
wenzelm@9869
   434
by (REPEAT (DEPTH_SOLVE_1
wenzelm@9869
   435
            (eresolve_tac ([asm_rl,impCE,notE]@prems) 1)));
wenzelm@7357
   436
qed "iffCE";
wenzelm@7357
   437
paulson@9159
   438
val prems = Goal "(ALL x. ~P(x) ==> P(a)) ==> EX x. P(x)";
wenzelm@7357
   439
by (rtac ccontr 1);
wenzelm@7357
   440
by (REPEAT (ares_tac (prems@[exI,allI,notI,notE]) 1))  ;
wenzelm@7357
   441
qed "exCI";
wenzelm@7357
   442
paulson@8964
   443
Goal "x + (y+z) = y + ((x+z)::'a::plus_ac0)";
paulson@8964
   444
by (rtac (thm"plus_ac0.commute" RS trans) 1);
paulson@8964
   445
by (rtac (thm"plus_ac0.assoc" RS trans) 1);
paulson@8964
   446
by (rtac (thm"plus_ac0.commute" RS arg_cong) 1);
paulson@8964
   447
qed "plus_ac0_left_commute";
paulson@8964
   448
paulson@8964
   449
Goal "x + 0 = (x ::'a::plus_ac0)";
paulson@8964
   450
by (rtac (thm"plus_ac0.commute" RS trans) 1);
paulson@8964
   451
by (rtac (thm"plus_ac0.zero") 1);
paulson@8964
   452
qed "plus_ac0_zero_right";
paulson@8964
   453
wenzelm@9869
   454
bind_thms ("plus_ac0", [thm"plus_ac0.assoc", thm"plus_ac0.commute",
wenzelm@9869
   455
                        plus_ac0_left_commute,
wenzelm@9869
   456
                        thm"plus_ac0.zero", plus_ac0_zero_right]);
wenzelm@7357
   457
wenzelm@7357
   458
(* case distinction *)
wenzelm@7357
   459
paulson@8529
   460
val [prem1,prem2] = Goal "[| P ==> Q; ~P ==> Q |] ==> Q";
paulson@8529
   461
by (rtac (excluded_middle RS disjE) 1);
paulson@8529
   462
by (etac prem2 1);
paulson@8529
   463
by (etac prem1 1);
paulson@8529
   464
qed "case_split_thm";
wenzelm@7357
   465
wenzelm@7357
   466
fun case_tac a = res_inst_tac [("P",a)] case_split_thm;
wenzelm@7357
   467
wenzelm@7357
   468
wenzelm@7357
   469
(** Standard abbreviations **)
wenzelm@7357
   470
wenzelm@10731
   471
(* combination of (spec RS spec RS ...(j times) ... spec RS mp) *)
oheimb@7490
   472
local
oheimb@7490
   473
  fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t
oheimb@7490
   474
  |   wrong_prem (Bound _) = true
oheimb@7490
   475
  |   wrong_prem _ = false;
oheimb@7533
   476
  val filter_right = filter (fn t => not (wrong_prem (HOLogic.dest_Trueprop (hd (Thm.prems_of t)))));
oheimb@7490
   477
in
oheimb@7490
   478
  fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]);
oheimb@7490
   479
  fun smp_tac j = EVERY'[dresolve_tac (smp j), atac]
oheimb@7490
   480
end;
oheimb@7490
   481
oheimb@7490
   482
wenzelm@9869
   483
fun strip_tac i = REPEAT(resolve_tac [impI,allI] i);
oheimb@11006
   484