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