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