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