src/ZF/zf.ML
author clasohm
Thu, 16 Sep 1993 12:20:38 +0200
changeset 0 a5a9c433f639
child 6 8ce8c4d13d4d
permissions -rw-r--r--
Initial revision
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	ZF/zf.ML
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson and Martin D Coen, CU Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Basic introduction and elimination rules for Zermelo-Fraenkel Set Theory 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
open ZF;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
signature ZF_LEMMAS = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
  sig
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
  val ballE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
  val ballI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
  val ball_cong : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
  val ball_rew : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
  val ball_tac : int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
  val basic_ZF_congs : thm list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  val bexCI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  val bexE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  val bexI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  val bex_cong : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  val bspec : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  val CollectD1 : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  val CollectD2 : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  val CollectE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  val CollectI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
  val Collect_cong : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
  val emptyE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
  val empty_subsetI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
  val equalityCE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
  val equalityD1 : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  val equalityD2 : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  val equalityE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  val equalityI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  val equality_iffI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
  val equals0D : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
  val equals0I : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
  val ex1_functional : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
  val InterD : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
  val InterE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
  val InterI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
  val INT_E : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
  val INT_I : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
  val lemmas_cs : claset
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
  val PowD : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
  val PowI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
  val prove_cong_tac : thm list -> int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
  val RepFunE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
  val RepFunI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
  val RepFun_eqI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
  val RepFun_cong : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
  val ReplaceE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
  val ReplaceI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
  val Replace_iff : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
  val Replace_cong : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
  val rev_ballE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
  val rev_bspec : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
  val rev_subsetD : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
  val separation : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  val setup_induction : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
  val set_mp_tac : int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
  val subsetCE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
  val subsetD : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
  val subsetI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
  val subset_refl : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
  val subset_trans : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
  val UnionE : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
  val UnionI : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
  val UN_E : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
  val UN_I : thm
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
structure ZF_Lemmas : ZF_LEMMAS = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
struct
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
val basic_ZF_congs = mk_congs ZF.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
    ["op `", "op ``", "op Int", "op Un", "op -", "op <=", "op :", 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
     "Pow", "Union", "Inter", "fst", "snd", "succ", "Pair", "Upair", "cons",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
     "domain", "range", "restrict"];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
fun prove_cong_tac prems i =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    84
    REPEAT (ares_tac (prems@[refl]@FOL_congs@basic_ZF_congs) i);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
(*** Bounded universal quantifier ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
val ballI = prove_goalw ZF.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
    "[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
 (fn prems=> [ (REPEAT (ares_tac (prems @ [allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
val bspec = prove_goalw ZF.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
    "[| ALL x:A. P(x);  x: A |] ==> P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
  [ (rtac (major RS spec RS mp) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    96
    (resolve_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
val ballE = prove_goalw ZF.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
    "[| ALL x:A. P(x);  P(x) ==> Q;  ~ x:A ==> Q |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
  [ (rtac (major RS allE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
    (REPEAT (eresolve_tac (prems@[asm_rl,impCE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
(*Used in the datatype package*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
val rev_bspec = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
    "!!x A P. [| x: A;  ALL x:A. P(x) |] ==> P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
 (fn _ =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
  [ REPEAT (ares_tac [bspec] 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
(*Instantiates x first: better for automatic theorem proving?*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
val rev_ballE = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
    "[| ALL x:A. P(x);  ~ x:A ==> Q;  P(x) ==> Q |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
  [ (rtac (major RS ballE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
    (REPEAT (eresolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
(*Takes assumptions ALL x:A.P(x) and a:A; creates assumption P(a)*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
val ball_tac = dtac bspec THEN' assume_tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   120
(*Trival rewrite rule;   (ALL x:A.P)<->P holds only if A is nonempty!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
val ball_rew = prove_goal ZF.thy "(ALL x:A. True) <-> True"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   122
 (fn prems=> [ (REPEAT (ares_tac [TrueI,ballI,iffI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
(*Congruence rule for rewriting*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
val ball_cong = prove_goalw ZF.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
    "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
\    |] ==> (ALL x:A. P(x)) <-> (ALL x:A'. P'(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
 (fn prems=> [ (prove_cong_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
(*** Bounded existential quantifier ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   131
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
val bexI = prove_goalw ZF.thy [Bex_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
    "[| P(x);  x: A |] ==> EX x:A. P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
 (fn prems=> [ (REPEAT (ares_tac (prems @ [exI,conjI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
(*Not of the general form for such rules; ~EX has become ALL~ *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
val bexCI = prove_goal ZF.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   138
   "[| ALL x:A. ~P(x) ==> P(a);  a: A |] ==> EX x:A.P(x)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
  [ (rtac classical 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
    (REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   143
val bexE = prove_goalw ZF.thy [Bex_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
    "[| EX x:A. P(x);  !!x. [| x:A; P(x) |] ==> Q \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
\    |] ==> Q"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
  [ (rtac (major RS exE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
    (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   149
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
(*We do not even have (EX x:A. True) <-> True unless A is nonempty!!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
val bex_cong = prove_goalw ZF.thy [Bex_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
    "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
\    |] ==> (EX x:A. P(x)) <-> (EX x:A'. P'(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   155
 (fn prems=> [ (prove_cong_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
(*** Rules for subsets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
val subsetI = prove_goalw ZF.thy [subset_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
    "(!!x.x:A ==> x:B) ==> A <= B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
 (fn prems=> [ (REPEAT (ares_tac (prems @ [ballI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
(*Rule in Modus Ponens style [was called subsetE] *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   164
val subsetD = prove_goalw ZF.thy [subset_def] "[| A <= B;  c:A |] ==> c:B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   166
  [ (rtac (major RS bspec) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   167
    (resolve_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   168
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
(*Classical elimination rule*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
val subsetCE = prove_goalw ZF.thy [subset_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
    "[| A <= B;  ~(c:A) ==> P;  c:B ==> P |] ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
  [ (rtac (major RS ballE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   174
    (REPEAT (eresolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
(*Takes assumptions A<=B; c:A and creates the assumption c:B *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
val set_mp_tac = dtac subsetD THEN' assume_tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   178
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
(*Sometimes useful with premises in this order*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
val rev_subsetD = prove_goal ZF.thy "!!A B c. [| c:A; A<=B |] ==> c:B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   181
 (fn _=> [REPEAT (ares_tac [subsetD] 1)]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
val subset_refl = prove_goal ZF.thy "A <= A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
 (fn _=> [ (rtac subsetI 1), atac 1 ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
val subset_trans = prove_goal ZF.thy "[| A<=B;  B<=C |] ==> A<=C"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
 (fn prems=> [ (REPEAT (ares_tac ([subsetI]@(prems RL [subsetD])) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
(*** Rules for equality ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   191
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
(*Anti-symmetry of the subset relation*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
val equalityI = prove_goal ZF.thy "[| A <= B;  B <= A |] ==> A = B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
 (fn prems=> [ (REPEAT (resolve_tac (prems@[conjI, extension RS iffD2]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
val equality_iffI = prove_goal ZF.thy "(!!x. x:A <-> x:B) ==> A = B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
 (fn [prem] =>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
  [ (rtac equalityI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   199
    (REPEAT (ares_tac [subsetI, prem RS iffD1, prem RS iffD2] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
val equalityD1 = prove_goal ZF.thy "A = B ==> A<=B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   203
  [ (rtac (extension RS iffD1 RS conjunct1) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
    (resolve_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
val equalityD2 = prove_goal ZF.thy "A = B ==> B<=A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   207
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
  [ (rtac (extension RS iffD1 RS conjunct2) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
    (resolve_tac prems 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
val equalityE = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
    "[| A = B;  [| A<=B; B<=A |] ==> P |]  ==>  P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   214
  [ (DEPTH_SOLVE (resolve_tac (prems@[equalityD1,equalityD2]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
val equalityCE = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
    "[| A = B;  [| c:A; c:B |] ==> P;  [| ~ c:A; ~ c:B |] ==> P |]  ==>  P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
  [ (rtac (major RS equalityE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
    (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   222
(*Lemma for creating induction formulae -- for "pattern matching" on p
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
  To make the induction hypotheses usable, apply "spec" or "bspec" to
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
  put universal quantifiers over the free variables in p. 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
  Would it be better to do subgoal_tac "ALL z. p = f(z) --> R(z)" ??*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
val setup_induction = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
    "[| p: A;  !!z. z: A ==> p=z --> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
  [ (rtac mp 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   230
    (REPEAT (resolve_tac (refl::prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
(*** Rules for Replace -- the derived form of replacement ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
val ex1_functional = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
    "[| EX! z. P(a,z);  P(a,b);  P(a,c) |] ==> b = c"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   237
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   238
  [ (cut_facts_tac prems 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   239
    (best_tac FOL_dup_cs 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
val Replace_iff = prove_goalw ZF.thy [Replace_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
    "b : {y. x:A, P(x,y)}  <->  (EX x:A. P(x,b) & (ALL y. P(x,y) --> y=b))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   243
 (fn _=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
  [ (rtac (replacement RS iff_trans) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
    (REPEAT (ares_tac [refl,bex_cong,iffI,ballI,allI,conjI,impI,ex1I] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
        ORELSE eresolve_tac [conjE, spec RS mp, ex1_functional] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   247
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   248
(*Introduction; there must be a unique y such that P(x,y), namely y=b. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   249
val ReplaceI = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
    "[| x: A;  P(x,b);  !!y. P(x,y) ==> y=b |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   251
\    b : {y. x:A, P(x,y)}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
  [ (rtac (Replace_iff RS iffD2) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
    (REPEAT (ares_tac (prems@[bexI,conjI,allI,impI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   255
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
(*Elimination; may asssume there is a unique y such that P(x,y), namely y=b. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
val ReplaceE = prove_goal ZF.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   258
    "[| b : {y. x:A, P(x,y)};  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
\       !!x. [| x: A;  P(x,b);  ALL y. P(x,y)-->y=b |] ==> R \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
\    |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   262
  [ (rtac (Replace_iff RS iffD1 RS bexE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
    (etac conjE 2),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
    (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
val Replace_cong = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
    "[| A=B;  !!x y. x:B ==> P(x,y) <-> Q(x,y) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
\    {y. x:A, P(x,y)} = {y. x:B, Q(x,y)}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
   let val substprems = prems RL [subst, ssubst]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
       and iffprems = prems RL [iffD1,iffD2]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   272
   in [ (rtac equalityI 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
	(REPEAT (eresolve_tac (substprems@[asm_rl, ReplaceE, spec RS mp]) 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
	 ORELSE resolve_tac [subsetI, ReplaceI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
	 ORELSE (resolve_tac iffprems 1 THEN assume_tac 2))) ]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
   end);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   278
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
(*** Rules for RepFun ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
val RepFunI = prove_goalw ZF.thy [RepFun_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
    "!!a A. a : A ==> f(a) : {f(x). x:A}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
 (fn _ => [ (REPEAT (ares_tac [ReplaceI,refl] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   285
(*Useful for co-induction proofs*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   286
val RepFun_eqI = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
    "!!b a f. [| b=f(a);  a : A |] ==> b : {f(x). x:A}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
 (fn _ => [ etac ssubst 1, etac RepFunI 1 ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
val RepFunE = prove_goalw ZF.thy [RepFun_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
    "[| b : {f(x). x:A};  \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
\       !!x.[| x:A;  b=f(x) |] ==> P |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   293
\    P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
  [ (rtac (major RS ReplaceE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
    (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
val RepFun_cong = prove_goalw ZF.thy [RepFun_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   299
    "[| A=B;  !!x. x:B ==> f(x)=g(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
\    {f(x). x:A} = {g(x). x:B}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
 (fn prems=> [ (prove_cong_tac (prems@[Replace_cong]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
(*** Rules for Collect -- forming a subset by separation ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   306
(*Separation is derivable from Replacement*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
val separation = prove_goalw ZF.thy [Collect_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
    "a : {x:A. P(x)} <-> a:A & P(a)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   309
 (fn _=> [ (fast_tac (FOL_cs addIs  [bexI,ReplaceI] 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
		             addSEs [bexE,ReplaceE]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   312
val CollectI = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
    "[| a:A;  P(a) |] ==> a : {x:A. P(x)}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   314
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
  [ (rtac (separation RS iffD2) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
    (REPEAT (resolve_tac (prems@[conjI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
val CollectE = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
    "[| a : {x:A. P(x)};  [| a:A; P(a) |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
  [ (rtac (separation RS iffD1 RS conjE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   322
    (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
val CollectD1 = prove_goal ZF.thy "a : {x:A. P(x)} ==> a:A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
  [ (rtac (major RS CollectE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
    (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   328
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
val CollectD2 = prove_goal ZF.thy "a : {x:A. P(x)} ==> P(a)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   330
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   331
  [ (rtac (major RS CollectE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   332
    (assume_tac 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
val Collect_cong = prove_goalw ZF.thy [Collect_def] 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   335
    "[| A=B;  !!x. x:B ==> P(x) <-> Q(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
\    {x:A. P(x)} = {x:B. Q(x)}"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
 (fn prems=> [ (prove_cong_tac (prems@[Replace_cong]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
(*** Rules for Unions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
(*The order of the premises presupposes that C is rigid; A may be flexible*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   342
val UnionI = prove_goal ZF.thy "[| B: C;  A: B |] ==> A: Union(C)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   343
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   344
  [ (resolve_tac [union_iff RS iffD2] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
    (REPEAT (resolve_tac (prems @ [bexI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
val UnionE = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
    "[| A : Union(C);  !!B.[| A: B;  B: C |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   350
  [ (resolve_tac [union_iff RS iffD1 RS bexE] 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   351
    (REPEAT (ares_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   352
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   353
(*** Rules for Inter ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   354
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   355
(*Not obviously useful towards proving InterI, InterD, InterE*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   356
val Inter_iff = prove_goalw ZF.thy [Inter_def,Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   357
    "A : Inter(C) <-> (ALL x:C. A: x) & (EX x. x:C)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   358
 (fn _=> [ (rtac (separation RS iff_trans) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   359
	   (fast_tac (FOL_cs addIs [UnionI] addSEs [UnionE]) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   360
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   361
(* Intersection is well-behaved only if the family is non-empty! *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   362
val InterI = prove_goalw ZF.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   363
    "[| !!x. x: C ==> A: x;  c:C |] ==> A : Inter(C)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   364
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   365
  [ (DEPTH_SOLVE (ares_tac ([CollectI,UnionI,ballI] @ prems) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   366
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   367
(*A "destruct" rule -- every B in C contains A as an element, but
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   368
  A:B can hold when B:C does not!  This rule is analogous to "spec". *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   369
val InterD = prove_goalw ZF.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   370
    "[| A : Inter(C);  B : C |] ==> A : B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   371
 (fn [major,minor]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   372
  [ (rtac (major RS CollectD2 RS bspec) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   373
    (rtac minor 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   374
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   375
(*"Classical" elimination rule -- does not require exhibiting B:C *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   376
val InterE = prove_goalw ZF.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   377
    "[| A : Inter(C);  A:B ==> R;  ~ B:C ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   378
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   379
  [ (rtac (major RS CollectD2 RS ballE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   380
    (REPEAT (eresolve_tac prems 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   381
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   382
(*** Rules for Unions of families ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   383
(* UN x:A. B(x) abbreviates Union({B(x). x:A}) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   384
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   385
(*The order of the premises presupposes that A is rigid; b may be flexible*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   386
val UN_I = prove_goal ZF.thy "[| a: A;  b: B(a) |] ==> b: (UN x:A. B(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   387
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   388
  [ (REPEAT (resolve_tac (prems@[UnionI,RepFunI]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   389
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   390
val UN_E = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   391
    "[| b : (UN x:A. B(x));  !!x.[| x: A;  b: B(x) |] ==> R |] ==> R"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   392
 (fn major::prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   393
  [ (rtac (major RS UnionE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   394
    (REPEAT (eresolve_tac (prems@[asm_rl, RepFunE, subst]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   395
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   396
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   397
(*** Rules for Intersections of families ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   398
(* INT x:A. B(x) abbreviates Inter({B(x). x:A}) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   399
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   400
val INT_I = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   401
    "[| !!x. x: A ==> b: B(x);  a: A |] ==> b: (INT x:A. B(x))"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   402
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   403
  [ (REPEAT (ares_tac (prems@[InterI,RepFunI]) 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   404
     ORELSE eresolve_tac [RepFunE,ssubst] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   405
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   406
val INT_E = prove_goal ZF.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   407
    "[| b : (INT x:A. B(x));  a: A |] ==> b : B(a)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   408
 (fn [major,minor]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   409
  [ (rtac (major RS InterD) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   410
    (rtac (minor RS RepFunI) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   411
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   412
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   413
(*** Rules for Powersets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   414
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   415
val PowI = prove_goal ZF.thy "A <= B ==> A : Pow(B)"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   416
 (fn [prem]=> [ (rtac (prem RS (power_set RS iffD2)) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   417
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   418
val PowD = prove_goal ZF.thy "A : Pow(B)  ==>  A<=B"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   419
 (fn [major]=> [ (rtac (major RS (power_set RS iffD1)) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   420
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   421
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   422
(*** Rules for the empty set ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   423
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   424
(*The set {x:0.False} is empty; by foundation it equals 0 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   425
  See Suppes, page 21.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   426
val emptyE = prove_goal ZF.thy "a:0 ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   427
 (fn [major]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   428
  [ (rtac (foundation RS disjE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   429
    (etac (equalityD2 RS subsetD RS CollectD2 RS FalseE) 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   430
    (rtac major 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   431
    (etac bexE 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   432
    (etac (CollectD2 RS FalseE) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   433
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   434
val empty_subsetI = prove_goal ZF.thy "0 <= A"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   435
 (fn _ => [ (REPEAT (ares_tac [equalityI,subsetI,emptyE] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   436
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   437
val equals0I = prove_goal ZF.thy "[| !!y. y:A ==> False |] ==> A=0"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   438
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   439
  [ (REPEAT (ares_tac (prems@[empty_subsetI,subsetI,equalityI]) 1 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   440
      ORELSE eresolve_tac (prems RL [FalseE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   441
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   442
val equals0D = prove_goal ZF.thy "[| A=0;  a:A |] ==> P"
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   443
 (fn [major,minor]=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   444
  [ (rtac (minor RS (major RS equalityD1 RS subsetD RS emptyE)) 1) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   445
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   446
val lemmas_cs = FOL_cs
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   447
  addSIs [ballI, InterI, CollectI, PowI, subsetI]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   448
  addIs [bexI, UnionI, ReplaceI, RepFunI]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   449
  addSEs [bexE, make_elim PowD, UnionE, ReplaceE, RepFunE,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   450
	  CollectE, emptyE]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   451
  addEs [rev_ballE, InterD, make_elim InterD, subsetD, subsetCE];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   452
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   453
end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   454
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   455
open ZF_Lemmas;