HOL.ML
author lcp
Mon, 31 Oct 1994 17:17:48 +0100
changeset 154 c801110efa1b
parent 153 c0ff8f1ebc16
child 155 722bf1319be5
permissions -rw-r--r--
HOL/ex/cla: proofs now use deepen_tac instead of best_tac HOL_dup_cs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/hol.ML
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Tobias Nipkow
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     5
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     6
For hol.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     7
Derived rules from Appendix of Mike Gordons HOL Report, Cambridge TR 68 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     8
*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
     9
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    10
open HOL;
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    11
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    12
signature HOL_LEMMAS =
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    13
  sig
128
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    14
  val allE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    15
  val all_dupE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    16
  val allI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    17
  val arg_cong	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    18
  val fun_cong	: thm
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    19
  val box_equals: thm
128
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    20
  val case_tac	: string -> int -> tactic
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    21
  val ccontr	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    22
  val classical	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    23
  val cong	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    24
  val conjunct1	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    25
  val conjunct2	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    26
  val conjE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    27
  val conjI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    28
  val contrapos	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    29
  val disjCI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    30
  val disjE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    31
  val disjI1	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    32
  val disjI2	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    33
  val eqTrueI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    34
  val eqTrueE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    35
  val ex1E	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    36
  val ex1I	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    37
  val exCI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    38
  val exI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    39
  val exE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    40
  val excluded_middle		: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    41
  val excluded_middle_tac	: string -> int -> tactic
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    42
  val False_neq_True	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    43
  val FalseE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    44
  val iffCE 	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    45
  val iffD1	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    46
  val iffD2	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    47
  val iffE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    48
  val iffI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    49
  val impCE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    50
  val impE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    51
  val not_sym	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    52
  val notE	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    53
  val notI	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    54
  val notnotD 	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    55
  val rev_mp	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    56
  val select_equality	: thm
153
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
    57
  val selectI2	: thm
128
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    58
  val spec	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    59
  val sstac	: thm list -> int -> tactic
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    60
  val ssubst	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    61
  val stac	: thm -> int -> tactic
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    62
  val strip_tac	: int -> tactic
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    63
  val swap	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    64
  val sym	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    65
  val trans	: thm
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
    66
  val TrueI	: thm
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    67
  end;
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    68
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    69
structure HOL_Lemmas : HOL_LEMMAS =
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    70
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    71
struct
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    72
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    73
(** Equality **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    74
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    75
val sym = prove_goal HOL.thy "s=t ==> t=s"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    76
 (fn prems => [cut_facts_tac prems 1, etac subst 1, rtac refl 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    77
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    78
(*calling "standard" reduces maxidx to 0*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    79
val ssubst = standard (sym RS subst);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    80
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    81
val trans = prove_goal HOL.thy "[| r=s; s=t |] ==> r=t"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    82
 (fn prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    83
	[rtac subst 1, resolve_tac prems 1, resolve_tac prems 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    84
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    85
(*Useful with eresolve_tac for proving equalties from known equalities.
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    86
	a = b
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    87
	|   |
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    88
	c = d	*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    89
val box_equals = prove_goal HOL.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    90
    "[| a=b;  a=c;  b=d |] ==> c=d"  
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    91
 (fn prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    92
  [ (rtac trans 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    93
    (rtac trans 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    94
    (rtac sym 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    95
    (REPEAT (resolve_tac prems 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    96
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    97
(** Congruence rules for meta-application **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    98
7949f97df77a Initial revision
clasohm
parents:
diff changeset
    99
(*similar to AP_THM in Gordon's HOL*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   100
val fun_cong = prove_goal HOL.thy "(f::'a=>'b) = g ==> f(x)=g(x)"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   101
  (fn [prem] => [rtac (prem RS subst) 1, rtac refl 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   102
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   103
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   104
val arg_cong = prove_goal HOL.thy "x=y ==> f(x)=f(y)"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   105
 (fn [prem] => [rtac (prem RS subst) 1, rtac refl 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   106
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   107
val cong = prove_goal HOL.thy
90
5c7a69cef18b added parentheses made necessary by change of constrain's precedence
clasohm
parents: 84
diff changeset
   108
   "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   109
 (fn [prem1,prem2] =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   110
   [rtac (prem1 RS subst) 1, rtac (prem2 RS subst) 1, rtac refl 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   111
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   112
(** Equality of booleans -- iff **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   113
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   114
val iffI = prove_goal HOL.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   115
   "[| P ==> Q;  Q ==> P |] ==> P=Q"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   116
 (fn prems=> [ (REPEAT (ares_tac (prems@[impI, iff RS mp RS mp]) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   117
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   118
val iffD2 = prove_goal HOL.thy "[| P=Q; Q |] ==> P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   119
 (fn prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   120
	[rtac ssubst 1, resolve_tac prems 1, resolve_tac prems 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   121
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   122
val iffD1 = sym RS iffD2;
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   123
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   124
val iffE = prove_goal HOL.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   125
    "[| P=Q; [| P --> Q; Q --> P |] ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   126
 (fn [p1,p2] => [REPEAT(ares_tac([p1 RS iffD2, p1 RS iffD1, p2, impI])1)]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   127
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   128
(** True **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   129
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   130
val TrueI = prove_goalw HOL.thy [True_def] "True"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   131
  (fn _ => [rtac refl 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   132
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   133
val eqTrueI  = prove_goal HOL.thy "P ==> P=True" 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   134
 (fn prems => [REPEAT(resolve_tac ([iffI,TrueI]@prems) 1)]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   135
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   136
val eqTrueE = prove_goal HOL.thy "P=True ==> P" 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   137
 (fn prems => [REPEAT(resolve_tac (prems@[TrueI,iffD2]) 1)]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   138
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   139
(** Universal quantifier **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   140
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   141
val allI = prove_goalw HOL.thy [All_def] "(!!x::'a. P(x)) ==> !x. P(x)"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   142
 (fn prems => [resolve_tac (prems RL [eqTrueI RS ext]) 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   143
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   144
val spec = prove_goalw HOL.thy [All_def] "! x::'a.P(x) ==> P(x)"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   145
 (fn prems => [rtac eqTrueE 1, resolve_tac (prems RL [fun_cong]) 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   146
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   147
val allE = prove_goal HOL.thy "[| !x.P(x);  P(x) ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   148
 (fn major::prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   149
  [ (REPEAT (resolve_tac (prems @ [major RS spec]) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   150
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   151
val all_dupE = prove_goal HOL.thy 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   152
    "[| ! x.P(x);  [| P(x); ! x.P(x) |] ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   153
 (fn prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   154
  [ (REPEAT (resolve_tac (prems @ (prems RL [spec])) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   155
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   156
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   157
(** False ** Depends upon spec; it is impossible to do propositional logic
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   158
             before quantifiers! **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   159
84
3410f4d85086 HOL/HOL.ML/notE: tidied the proof
lcp
parents: 75
diff changeset
   160
val FalseE = prove_goalw HOL.thy [False_def] "False ==> P"
3410f4d85086 HOL/HOL.ML/notE: tidied the proof
lcp
parents: 75
diff changeset
   161
 (fn [major] => [rtac (major RS spec) 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   162
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   163
val False_neq_True = prove_goal HOL.thy "False=True ==> P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   164
 (fn [prem] => [rtac (prem RS eqTrueE RS FalseE) 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   165
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   166
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   167
(** Negation **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   168
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   169
val notI = prove_goalw HOL.thy [not_def] "(P ==> False) ==> ~P"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   170
 (fn prems=> [rtac impI 1, eresolve_tac prems 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   171
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   172
val notE = prove_goalw HOL.thy [not_def] "[| ~P;  P |] ==> R"
75
74bc51d20112 HOL/HOL.ML/notE: tidied
lcp
parents: 66
diff changeset
   173
 (fn prems => [rtac (prems MRS mp RS FalseE) 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   174
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   175
(** Implication **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   176
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   177
val impE = prove_goal HOL.thy "[| P-->Q;  P;  Q ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   178
 (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   179
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   180
(* Reduces Q to P-->Q, allowing substitution in P. *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   181
val rev_mp = prove_goal HOL.thy "[| P;  P --> Q |] ==> Q"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   182
 (fn prems=>  [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   183
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   184
val contrapos = prove_goal HOL.thy "[| ~Q;  P==>Q |] ==> ~P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   185
 (fn [major,minor]=> 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   186
  [ (rtac (major RS notE RS notI) 1), 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   187
    (etac minor 1) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   188
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   189
(* ~(?t = ?s) ==> ~(?s = ?t) *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   190
val [not_sym] = compose(sym,2,contrapos);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   191
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   192
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   193
(** Existential quantifier **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   194
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   195
val exI = prove_goalw HOL.thy [Ex_def] "P(x) ==> ? x::'a.P(x)"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   196
 (fn prems => [rtac selectI 1, resolve_tac prems 1]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   197
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   198
val exE = prove_goalw HOL.thy [Ex_def]
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   199
  "[| ? x::'a.P(x); !!x. P(x) ==> Q |] ==> Q"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   200
  (fn prems => [REPEAT(resolve_tac prems 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   201
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   202
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   203
(** Conjunction **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   204
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   205
val conjI = prove_goalw HOL.thy [and_def] "[| P; Q |] ==> P&Q"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   206
 (fn prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   207
  [REPEAT (resolve_tac (prems@[allI,impI]) 1 ORELSE etac (mp RS mp) 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   208
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   209
val conjunct1 = prove_goalw HOL.thy [and_def] "[| P & Q |] ==> P"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   210
 (fn prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   211
   [resolve_tac (prems RL [spec] RL [mp]) 1, REPEAT(ares_tac [impI] 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   212
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   213
val conjunct2 = prove_goalw HOL.thy [and_def] "[| P & Q |] ==> Q"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   214
 (fn prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   215
   [resolve_tac (prems RL [spec] RL [mp]) 1, REPEAT(ares_tac [impI] 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   216
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   217
val conjE = prove_goal HOL.thy "[| P&Q;  [| P; Q |] ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   218
 (fn prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   219
	 [cut_facts_tac prems 1, resolve_tac prems 1,
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   220
	  etac conjunct1 1, etac conjunct2 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   221
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   222
(** Disjunction *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   223
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   224
val disjI1 = prove_goalw HOL.thy [or_def] "P ==> P|Q"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   225
 (fn [prem] => [REPEAT(ares_tac [allI,impI, prem RSN (2,mp)] 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   226
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   227
val disjI2 = prove_goalw HOL.thy [or_def] "Q ==> P|Q"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   228
 (fn [prem] => [REPEAT(ares_tac [allI,impI, prem RSN (2,mp)] 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   229
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   230
val disjE = prove_goalw HOL.thy [or_def] "[| P | Q; P ==> R; Q ==> R |] ==> R"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   231
 (fn [a1,a2,a3] =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   232
	[rtac (mp RS mp) 1, rtac spec 1, rtac a1 1,
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   233
	 rtac (a2 RS impI) 1, atac 1, rtac (a3 RS impI) 1, atac 1]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   234
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   235
(** CCONTR -- classical logic **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   236
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   237
val ccontr = prove_goal HOL.thy "(~P ==> False) ==> P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   238
 (fn prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   239
   [rtac (True_or_False RS (disjE RS eqTrueE)) 1, atac 1,
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   240
    rtac spec 1, fold_tac [False_def], resolve_tac prems 1,
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   241
    rtac ssubst 1, atac 1, rewtac not_def,
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   242
    REPEAT (ares_tac [impI] 1) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   243
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   244
val ccontr = prove_goalw HOL.thy [not_def] "(~P ==> False) ==> P"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   245
 (fn prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   246
   [rtac (True_or_False RS (disjE RS eqTrueE)) 1, atac 1,
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   247
    rtac spec 1, fold_tac [False_def], resolve_tac prems 1,
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   248
    rtac ssubst 1, atac 1, REPEAT (ares_tac [impI] 1) ]);
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   249
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   250
val classical = prove_goal HOL.thy "(~P ==> P) ==> P"
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   251
 (fn prems => [rtac ccontr 1, REPEAT (ares_tac (prems@[notE]) 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   252
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   253
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   254
(*Double negation law*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   255
val notnotD = prove_goal HOL.thy "~~P ==> P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   256
 (fn [major]=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   257
  [ (rtac classical 1), (eresolve_tac [major RS notE] 1) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   258
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   259
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   260
(** Unique existence **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   261
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   262
val ex1I = prove_goalw HOL.thy [Ex1_def]
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   263
    "[| P(a);  !!x. P(x) ==> x=a |] ==> ?! x. P(x)"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   264
 (fn prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   265
  [REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   266
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   267
val ex1E = prove_goalw HOL.thy [Ex1_def]
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   268
    "[| ?! x.P(x);  !!x. [| P(x);  ! y. P(y) --> y=x |] ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   269
 (fn major::prems =>
66
14b9286ed036 changed defns in hol.thy from = to ==
nipkow
parents: 48
diff changeset
   270
  [rtac (major RS exE) 1, REPEAT (etac conjE 1 ORELSE ares_tac prems 1)]);
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   271
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   272
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   273
(** Select: Hilbert's Epsilon-operator **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   274
153
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   275
(*Easier to apply than selectI: conclusion has only one occurrence of P*)
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   276
val selectI2 = prove_goal HOL.thy
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   277
    "[| P(a);  !!x. P(x) ==> Q(x) |] ==> Q(@x.P(x))"
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   278
 (fn prems => [ resolve_tac prems 1, 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   279
	        rtac selectI 1, 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   280
		resolve_tac prems 1 ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   281
153
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   282
val select_equality = prove_goal HOL.thy
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   283
    "[| P(a);  !!x. P(x) ==> x=a |] ==> (@x.P(x)) = a"
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   284
 (fn prems => [ rtac selectI2 1, 
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   285
		REPEAT (ares_tac prems 1) ]);
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   286
c0ff8f1ebc16 HOL/HOL.ML/selectI2: new rule for descriptions
lcp
parents: 128
diff changeset
   287
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   288
(** Classical intro rules for disjunction and existential quantifiers *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   289
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   290
val disjCI = prove_goal HOL.thy "(~Q ==> P) ==> P|Q"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   291
 (fn prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   292
  [ (rtac classical 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   293
    (REPEAT (ares_tac (prems@[disjI1,notI]) 1)),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   294
    (REPEAT (ares_tac (prems@[disjI2,notE]) 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   295
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   296
val excluded_middle = prove_goal HOL.thy "~P | P"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   297
 (fn _ => [ (REPEAT (ares_tac [disjCI] 1)) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   298
128
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
   299
(*For disjunctive case analysis*)
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
   300
fun excluded_middle_tac sP =
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
   301
    res_inst_tac [("Q",sP)] (excluded_middle RS disjE);
89669c58e506 INSTALLATION OF INDUCTIVE DEFINITIONS
lcp
parents: 90
diff changeset
   302
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   303
(*Classical implies (-->) elimination. *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   304
val impCE = prove_goal HOL.thy "[| P-->Q; ~P ==> R; Q ==> R |] ==> R" 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   305
 (fn major::prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   306
  [ rtac (excluded_middle RS disjE) 1,
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   307
    REPEAT (DEPTH_SOLVE_1 (ares_tac (prems @ [major RS mp]) 1))]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   308
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   309
(*Classical <-> elimination. *)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   310
val iffCE = prove_goal HOL.thy
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   311
    "[| P=Q;  [| P; Q |] ==> R;  [| ~P; ~Q |] ==> R |] ==> R"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   312
 (fn major::prems =>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   313
  [ (rtac (major RS iffE) 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   314
    (REPEAT (DEPTH_SOLVE_1 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   315
	(eresolve_tac ([asm_rl,impCE,notE]@prems) 1))) ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   316
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   317
val exCI = prove_goal HOL.thy "(! x. ~P(x) ==> P(a)) ==> ? x.P(x)"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   318
 (fn prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   319
  [ (rtac ccontr 1),
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   320
    (REPEAT (ares_tac (prems@[exI,allI,notI,notE]) 1))  ]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   321
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   322
(*Required by the "classical" module*)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   323
val swap = prove_goal HOL.thy "~P ==> (~Q ==> P) ==> Q"
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   324
 (fn major::prems=>
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   325
  [ rtac ccontr 1, rtac (major RS notE) 1, REPEAT (ares_tac prems 1)]);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   326
40
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   327
(* case distinction *)
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   328
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   329
val case_split_thm = prove_goal HOL.thy "[| P ==> Q; ~P ==> Q |] ==> Q"
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   330
  (fn [p1,p2] => [cut_facts_tac [excluded_middle] 1, etac disjE 1,
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   331
                  etac p2 1, etac p1 1]);
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   332
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   333
fun case_tac a = res_inst_tac [("P",a)] case_split_thm;
ac7b7003f177 Introduction of various new lemmas and of case_tac.
nipkow
parents: 0
diff changeset
   334
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   335
(** Standard abbreviations **)
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   336
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   337
fun stac th = rtac(th RS ssubst);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   338
fun sstac ths = EVERY' (map stac ths);
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   339
fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); 
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   340
48
21291189b51e changed "." to "$" and Cons to infix "#" to eliminate ambiguity
clasohm
parents: 40
diff changeset
   341
0
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   342
end;
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   343
7949f97df77a Initial revision
clasohm
parents:
diff changeset
   344
open HOL_Lemmas;