src/ZF/Ordinal.thy
author paulson
Wed Jun 05 15:34:55 2002 +0200 (2002-06-05)
changeset 13203 fac77a839aa2
parent 13172 03a5afa7b888
child 13243 ba53d07d32d5
permissions -rw-r--r--
Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
     1 (*  Title:      ZF/Ordinal.thy
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1994  University of Cambridge
     5 
     6 Ordinals in Zermelo-Fraenkel Set Theory 
     7 *)
     8 
     9 theory Ordinal = WF + Bool + equalities:
    10 
    11 constdefs
    12 
    13   Memrel        :: "i=>i"
    14     "Memrel(A)   == {z: A*A . EX x y. z=<x,y> & x:y }"
    15 
    16   Transset  :: "i=>o"
    17     "Transset(i) == ALL x:i. x<=i"
    18 
    19   Ord  :: "i=>o"
    20     "Ord(i)      == Transset(i) & (ALL x:i. Transset(x))"
    21 
    22   lt        :: "[i,i] => o"  (infixl "<" 50)   (*less-than on ordinals*)
    23     "i<j         == i:j & Ord(j)"
    24 
    25   Limit         :: "i=>o"
    26     "Limit(i)    == Ord(i) & 0<i & (ALL y. y<i --> succ(y)<i)"
    27 
    28 syntax
    29   "le"          :: "[i,i] => o"  (infixl 50)   (*less-than or equals*)
    30 
    31 translations
    32   "x le y"      == "x < succ(y)"
    33 
    34 syntax (xsymbols)
    35   "op le"       :: "[i,i] => o"  (infixl "\<le>" 50)  (*less-than or equals*)
    36 
    37 
    38 (*** Rules for Transset ***)
    39 
    40 (** Three neat characterisations of Transset **)
    41 
    42 lemma Transset_iff_Pow: "Transset(A) <-> A<=Pow(A)"
    43 by (unfold Transset_def, blast)
    44 
    45 lemma Transset_iff_Union_succ: "Transset(A) <-> Union(succ(A)) = A"
    46 apply (unfold Transset_def)
    47 apply (blast elim!: equalityE)
    48 done
    49 
    50 lemma Transset_iff_Union_subset: "Transset(A) <-> Union(A) <= A"
    51 by (unfold Transset_def, blast)
    52 
    53 (** Consequences of downwards closure **)
    54 
    55 lemma Transset_doubleton_D: 
    56     "[| Transset(C); {a,b}: C |] ==> a:C & b: C"
    57 by (unfold Transset_def, blast)
    58 
    59 lemma Transset_Pair_D:
    60     "[| Transset(C); <a,b>: C |] ==> a:C & b: C"
    61 apply (simp add: Pair_def)
    62 apply (blast dest: Transset_doubleton_D)
    63 done
    64 
    65 lemma Transset_includes_domain:
    66     "[| Transset(C); A*B <= C; b: B |] ==> A <= C"
    67 by (blast dest: Transset_Pair_D)
    68 
    69 lemma Transset_includes_range:
    70     "[| Transset(C); A*B <= C; a: A |] ==> B <= C"
    71 by (blast dest: Transset_Pair_D)
    72 
    73 (** Closure properties **)
    74 
    75 lemma Transset_0: "Transset(0)"
    76 by (unfold Transset_def, blast)
    77 
    78 lemma Transset_Un: 
    79     "[| Transset(i);  Transset(j) |] ==> Transset(i Un j)"
    80 by (unfold Transset_def, blast)
    81 
    82 lemma Transset_Int: 
    83     "[| Transset(i);  Transset(j) |] ==> Transset(i Int j)"
    84 by (unfold Transset_def, blast)
    85 
    86 lemma Transset_succ: "Transset(i) ==> Transset(succ(i))"
    87 by (unfold Transset_def, blast)
    88 
    89 lemma Transset_Pow: "Transset(i) ==> Transset(Pow(i))"
    90 by (unfold Transset_def, blast)
    91 
    92 lemma Transset_Union: "Transset(A) ==> Transset(Union(A))"
    93 by (unfold Transset_def, blast)
    94 
    95 lemma Transset_Union_family: 
    96     "[| !!i. i:A ==> Transset(i) |] ==> Transset(Union(A))"
    97 by (unfold Transset_def, blast)
    98 
    99 lemma Transset_Inter_family: 
   100     "[| !!i. i:A ==> Transset(i) |] ==> Transset(Inter(A))"
   101 by (unfold Inter_def Transset_def, blast)
   102 
   103 lemma Transset_UN:
   104      "(!!x. x \<in> A ==> Transset(B(x))) ==> Transset (UN x:A. B(x))"
   105 by (rule Transset_Union_family, auto) 
   106 
   107 lemma Transset_INT:
   108      "(!!x. x \<in> A ==> Transset(B(x))) ==> Transset (INT x:A. B(x))"
   109 by (rule Transset_Inter_family, auto) 
   110 
   111 
   112 (*** Natural Deduction rules for Ord ***)
   113 
   114 lemma OrdI:
   115     "[| Transset(i);  !!x. x:i ==> Transset(x) |]  ==>  Ord(i)"
   116 by (simp add: Ord_def) 
   117 
   118 lemma Ord_is_Transset: "Ord(i) ==> Transset(i)"
   119 by (simp add: Ord_def) 
   120 
   121 lemma Ord_contains_Transset: 
   122     "[| Ord(i);  j:i |] ==> Transset(j) "
   123 by (unfold Ord_def, blast)
   124 
   125 (*** Lemmas for ordinals ***)
   126 
   127 lemma Ord_in_Ord: "[| Ord(i);  j:i |] ==> Ord(j)"
   128 by (unfold Ord_def Transset_def, blast)
   129 
   130 (* Ord(succ(j)) ==> Ord(j) *)
   131 lemmas Ord_succD = Ord_in_Ord [OF _ succI1]
   132 
   133 lemma Ord_subset_Ord: "[| Ord(i);  Transset(j);  j<=i |] ==> Ord(j)"
   134 by (simp add: Ord_def Transset_def, blast)
   135 
   136 lemma OrdmemD: "[| j:i;  Ord(i) |] ==> j<=i"
   137 by (unfold Ord_def Transset_def, blast)
   138 
   139 lemma Ord_trans: "[| i:j;  j:k;  Ord(k) |] ==> i:k"
   140 by (blast dest: OrdmemD)
   141 
   142 lemma Ord_succ_subsetI: "[| i:j;  Ord(j) |] ==> succ(i) <= j"
   143 by (blast dest: OrdmemD)
   144 
   145 
   146 (*** The construction of ordinals: 0, succ, Union ***)
   147 
   148 lemma Ord_0 [iff,TC]: "Ord(0)"
   149 by (blast intro: OrdI Transset_0)
   150 
   151 lemma Ord_succ [TC]: "Ord(i) ==> Ord(succ(i))"
   152 by (blast intro: OrdI Transset_succ Ord_is_Transset Ord_contains_Transset)
   153 
   154 lemmas Ord_1 = Ord_0 [THEN Ord_succ]
   155 
   156 lemma Ord_succ_iff [iff]: "Ord(succ(i)) <-> Ord(i)"
   157 by (blast intro: Ord_succ dest!: Ord_succD)
   158 
   159 lemma Ord_Un [intro,simp,TC]: "[| Ord(i); Ord(j) |] ==> Ord(i Un j)"
   160 apply (unfold Ord_def)
   161 apply (blast intro!: Transset_Un)
   162 done
   163 
   164 lemma Ord_Int [TC]: "[| Ord(i); Ord(j) |] ==> Ord(i Int j)"
   165 apply (unfold Ord_def)
   166 apply (blast intro!: Transset_Int)
   167 done
   168 
   169 (*There is no set of all ordinals, for then it would contain itself*)
   170 lemma ON_class: "~ (ALL i. i:X <-> Ord(i))"
   171 apply (rule notI)
   172 apply (frule_tac x = "X" in spec)
   173 apply (safe elim!: mem_irrefl)
   174 apply (erule swap, rule OrdI [OF _ Ord_is_Transset])
   175 apply (simp add: Transset_def)
   176 apply (blast intro: Ord_in_Ord)+
   177 done
   178 
   179 (*** < is 'less than' for ordinals ***)
   180 
   181 lemma ltI: "[| i:j;  Ord(j) |] ==> i<j"
   182 by (unfold lt_def, blast)
   183 
   184 lemma ltE:
   185     "[| i<j;  [| i:j;  Ord(i);  Ord(j) |] ==> P |] ==> P"
   186 apply (unfold lt_def)
   187 apply (blast intro: Ord_in_Ord)
   188 done
   189 
   190 lemma ltD: "i<j ==> i:j"
   191 by (erule ltE, assumption)
   192 
   193 lemma not_lt0 [simp]: "~ i<0"
   194 by (unfold lt_def, blast)
   195 
   196 lemma lt_Ord: "j<i ==> Ord(j)"
   197 by (erule ltE, assumption)
   198 
   199 lemma lt_Ord2: "j<i ==> Ord(i)"
   200 by (erule ltE, assumption)
   201 
   202 (* "ja le j ==> Ord(j)" *)
   203 lemmas le_Ord2 = lt_Ord2 [THEN Ord_succD]
   204 
   205 (* i<0 ==> R *)
   206 lemmas lt0E = not_lt0 [THEN notE, elim!]
   207 
   208 lemma lt_trans: "[| i<j;  j<k |] ==> i<k"
   209 by (blast intro!: ltI elim!: ltE intro: Ord_trans)
   210 
   211 lemma lt_not_sym: "i<j ==> ~ (j<i)"
   212 apply (unfold lt_def)
   213 apply (blast elim: mem_asym)
   214 done
   215 
   216 (* [| i<j;  ~P ==> j<i |] ==> P *)
   217 lemmas lt_asym = lt_not_sym [THEN swap]
   218 
   219 lemma lt_irrefl [elim!]: "i<i ==> P"
   220 by (blast intro: lt_asym)
   221 
   222 lemma lt_not_refl: "~ i<i"
   223 apply (rule notI)
   224 apply (erule lt_irrefl)
   225 done
   226 
   227 
   228 (** le is less than or equals;  recall  i le j  abbrevs  i<succ(j) !! **)
   229 
   230 lemma le_iff: "i le j <-> i<j | (i=j & Ord(j))"
   231 by (unfold lt_def, blast)
   232 
   233 (*Equivalently, i<j ==> i < succ(j)*)
   234 lemma leI: "i<j ==> i le j"
   235 by (simp (no_asm_simp) add: le_iff)
   236 
   237 lemma le_eqI: "[| i=j;  Ord(j) |] ==> i le j"
   238 by (simp (no_asm_simp) add: le_iff)
   239 
   240 lemmas le_refl = refl [THEN le_eqI]
   241 
   242 lemma le_refl_iff [iff]: "i le i <-> Ord(i)"
   243 by (simp (no_asm_simp) add: lt_not_refl le_iff)
   244 
   245 lemma leCI: "(~ (i=j & Ord(j)) ==> i<j) ==> i le j"
   246 by (simp add: le_iff, blast)
   247 
   248 lemma leE:
   249     "[| i le j;  i<j ==> P;  [| i=j;  Ord(j) |] ==> P |] ==> P"
   250 by (simp add: le_iff, blast)
   251 
   252 lemma le_anti_sym: "[| i le j;  j le i |] ==> i=j"
   253 apply (simp add: le_iff)
   254 apply (blast elim: lt_asym)
   255 done
   256 
   257 lemma le0_iff [simp]: "i le 0 <-> i=0"
   258 by (blast elim!: leE)
   259 
   260 lemmas le0D = le0_iff [THEN iffD1, dest!]
   261 
   262 (*** Natural Deduction rules for Memrel ***)
   263 
   264 (*The lemmas MemrelI/E give better speed than [iff] here*)
   265 lemma Memrel_iff [simp]: "<a,b> : Memrel(A) <-> a:b & a:A & b:A"
   266 by (unfold Memrel_def, blast)
   267 
   268 lemma MemrelI [intro!]: "[| a: b;  a: A;  b: A |] ==> <a,b> : Memrel(A)"
   269 by auto
   270 
   271 lemma MemrelE [elim!]:
   272     "[| <a,b> : Memrel(A);   
   273         [| a: A;  b: A;  a:b |]  ==> P |]  
   274      ==> P"
   275 by auto
   276 
   277 lemma Memrel_type: "Memrel(A) <= A*A"
   278 by (unfold Memrel_def, blast)
   279 
   280 lemma Memrel_mono: "A<=B ==> Memrel(A) <= Memrel(B)"
   281 by (unfold Memrel_def, blast)
   282 
   283 lemma Memrel_0 [simp]: "Memrel(0) = 0"
   284 by (unfold Memrel_def, blast)
   285 
   286 lemma Memrel_1 [simp]: "Memrel(1) = 0"
   287 by (unfold Memrel_def, blast)
   288 
   289 (*The membership relation (as a set) is well-founded.
   290   Proof idea: show A<=B by applying the foundation axiom to A-B *)
   291 lemma wf_Memrel: "wf(Memrel(A))"
   292 apply (unfold wf_def)
   293 apply (rule foundation [THEN disjE, THEN allI], erule disjI1, blast) 
   294 done
   295 
   296 (*Transset(i) does not suffice, though ALL j:i.Transset(j) does*)
   297 lemma trans_Memrel: 
   298     "Ord(i) ==> trans(Memrel(i))"
   299 by (unfold Ord_def Transset_def trans_def, blast)
   300 
   301 (*If Transset(A) then Memrel(A) internalizes the membership relation below A*)
   302 lemma Transset_Memrel_iff: 
   303     "Transset(A) ==> <a,b> : Memrel(A) <-> a:b & b:A"
   304 by (unfold Transset_def, blast)
   305 
   306 
   307 (*** Transfinite induction ***)
   308 
   309 (*Epsilon induction over a transitive set*)
   310 lemma Transset_induct: 
   311     "[| i: k;  Transset(k);                           
   312         !!x.[| x: k;  ALL y:x. P(y) |] ==> P(x) |]
   313      ==>  P(i)"
   314 apply (simp add: Transset_def) 
   315 apply (erule wf_Memrel [THEN wf_induct2], blast)
   316 apply blast 
   317 done
   318 
   319 (*Induction over an ordinal*)
   320 lemmas Ord_induct = Transset_induct [OF _ Ord_is_Transset]
   321 
   322 (*Induction over the class of ordinals -- a useful corollary of Ord_induct*)
   323 
   324 lemma trans_induct:
   325     "[| Ord(i);  
   326         !!x.[| Ord(x);  ALL y:x. P(y) |] ==> P(x) |]
   327      ==>  P(i)"
   328 apply (rule Ord_succ [THEN succI1 [THEN Ord_induct]], assumption)
   329 apply (blast intro: Ord_succ [THEN Ord_in_Ord]) 
   330 done
   331 
   332 
   333 (*** Fundamental properties of the epsilon ordering (< on ordinals) ***)
   334 
   335 
   336 (** Proving that < is a linear ordering on the ordinals **)
   337 
   338 lemma Ord_linear [rule_format]:
   339      "Ord(i) ==> (ALL j. Ord(j) --> i:j | i=j | j:i)"
   340 apply (erule trans_induct)
   341 apply (rule impI [THEN allI])
   342 apply (erule_tac i=j in trans_induct) 
   343 apply (blast dest: Ord_trans) 
   344 done
   345 
   346 (*The trichotomy law for ordinals!*)
   347 lemma Ord_linear_lt:
   348     "[| Ord(i);  Ord(j);  i<j ==> P;  i=j ==> P;  j<i ==> P |] ==> P"
   349 apply (simp add: lt_def) 
   350 apply (rule_tac i1=i and j1=j in Ord_linear [THEN disjE], blast+)
   351 done
   352 
   353 lemma Ord_linear2:
   354     "[| Ord(i);  Ord(j);  i<j ==> P;  j le i ==> P |]  ==> P"
   355 apply (rule_tac i = "i" and j = "j" in Ord_linear_lt)
   356 apply (blast intro: leI le_eqI sym ) +
   357 done
   358 
   359 lemma Ord_linear_le:
   360     "[| Ord(i);  Ord(j);  i le j ==> P;  j le i ==> P |]  ==> P"
   361 apply (rule_tac i = "i" and j = "j" in Ord_linear_lt)
   362 apply (blast intro: leI le_eqI ) +
   363 done
   364 
   365 lemma le_imp_not_lt: "j le i ==> ~ i<j"
   366 by (blast elim!: leE elim: lt_asym)
   367 
   368 lemma not_lt_imp_le: "[| ~ i<j;  Ord(i);  Ord(j) |] ==> j le i"
   369 by (rule_tac i = "i" and j = "j" in Ord_linear2, auto)
   370 
   371 (** Some rewrite rules for <, le **)
   372 
   373 lemma Ord_mem_iff_lt: "Ord(j) ==> i:j <-> i<j"
   374 by (unfold lt_def, blast)
   375 
   376 lemma not_lt_iff_le: "[| Ord(i);  Ord(j) |] ==> ~ i<j <-> j le i"
   377 by (blast dest: le_imp_not_lt not_lt_imp_le)
   378 
   379 lemma not_le_iff_lt: "[| Ord(i);  Ord(j) |] ==> ~ i le j <-> j<i"
   380 by (simp (no_asm_simp) add: not_lt_iff_le [THEN iff_sym])
   381 
   382 (*This is identical to 0<succ(i) *)
   383 lemma Ord_0_le: "Ord(i) ==> 0 le i"
   384 by (erule not_lt_iff_le [THEN iffD1], auto)
   385 
   386 lemma Ord_0_lt: "[| Ord(i);  i~=0 |] ==> 0<i"
   387 apply (erule not_le_iff_lt [THEN iffD1])
   388 apply (rule Ord_0, blast)
   389 done
   390 
   391 lemma Ord_0_lt_iff: "Ord(i) ==> i~=0 <-> 0<i"
   392 by (blast intro: Ord_0_lt)
   393 
   394 
   395 (*** Results about less-than or equals ***)
   396 
   397 (** For ordinals, j<=i (subset) implies j le i (less-than or equals) **)
   398 
   399 lemma zero_le_succ_iff [iff]: "0 le succ(x) <-> Ord(x)"
   400 by (blast intro: Ord_0_le elim: ltE)
   401 
   402 lemma subset_imp_le: "[| j<=i;  Ord(i);  Ord(j) |] ==> j le i"
   403 apply (rule not_lt_iff_le [THEN iffD1], assumption)
   404 apply assumption
   405 apply (blast elim: ltE mem_irrefl)
   406 done
   407 
   408 lemma le_imp_subset: "i le j ==> i<=j"
   409 by (blast dest: OrdmemD elim: ltE leE)
   410 
   411 lemma le_subset_iff: "j le i <-> j<=i & Ord(i) & Ord(j)"
   412 by (blast dest: subset_imp_le le_imp_subset elim: ltE)
   413 
   414 lemma le_succ_iff: "i le succ(j) <-> i le j | i=succ(j) & Ord(i)"
   415 apply (simp (no_asm) add: le_iff)
   416 apply blast
   417 done
   418 
   419 (*Just a variant of subset_imp_le*)
   420 lemma all_lt_imp_le: "[| Ord(i);  Ord(j);  !!x. x<j ==> x<i |] ==> j le i"
   421 by (blast intro: not_lt_imp_le dest: lt_irrefl)
   422 
   423 (** Transitive laws **)
   424 
   425 lemma lt_trans1: "[| i le j;  j<k |] ==> i<k"
   426 by (blast elim!: leE intro: lt_trans)
   427 
   428 lemma lt_trans2: "[| i<j;  j le k |] ==> i<k"
   429 by (blast elim!: leE intro: lt_trans)
   430 
   431 lemma le_trans: "[| i le j;  j le k |] ==> i le k"
   432 by (blast intro: lt_trans1)
   433 
   434 lemma succ_leI: "i<j ==> succ(i) le j"
   435 apply (rule not_lt_iff_le [THEN iffD1]) 
   436 apply (blast elim: ltE leE lt_asym)+
   437 done
   438 
   439 (*Identical to  succ(i) < succ(j) ==> i<j  *)
   440 lemma succ_leE: "succ(i) le j ==> i<j"
   441 apply (rule not_le_iff_lt [THEN iffD1])
   442 apply (blast elim: ltE leE lt_asym)+
   443 done
   444 
   445 lemma succ_le_iff [iff]: "succ(i) le j <-> i<j"
   446 by (blast intro: succ_leI succ_leE)
   447 
   448 lemma succ_le_imp_le: "succ(i) le succ(j) ==> i le j"
   449 by (blast dest!: succ_leE)
   450 
   451 lemma lt_subset_trans: "[| i <= j;  j<k;  Ord(i) |] ==> i<k"
   452 apply (rule subset_imp_le [THEN lt_trans1]) 
   453 apply (blast intro: elim: ltE) +
   454 done
   455 
   456 lemma lt_imp_0_lt: "j<i ==> 0<i"
   457 by (blast intro: lt_trans1 Ord_0_le [OF lt_Ord]) 
   458 
   459 lemma succ_lt_iff: "succ(i) < j \<longleftrightarrow> i<j & succ(i) \<noteq> j"
   460 apply auto 
   461 apply (blast intro: lt_trans le_refl dest: lt_Ord) 
   462 apply (frule lt_Ord) 
   463 apply (rule not_le_iff_lt [THEN iffD1]) 
   464   apply (blast intro: lt_Ord2)
   465  apply blast  
   466 apply (simp add: lt_Ord lt_Ord2 le_iff) 
   467 apply (blast dest: lt_asym) 
   468 done
   469 
   470 (** Union and Intersection **)
   471 
   472 lemma Un_upper1_le: "[| Ord(i); Ord(j) |] ==> i le i Un j"
   473 by (rule Un_upper1 [THEN subset_imp_le], auto)
   474 
   475 lemma Un_upper2_le: "[| Ord(i); Ord(j) |] ==> j le i Un j"
   476 by (rule Un_upper2 [THEN subset_imp_le], auto)
   477 
   478 (*Replacing k by succ(k') yields the similar rule for le!*)
   479 lemma Un_least_lt: "[| i<k;  j<k |] ==> i Un j < k"
   480 apply (rule_tac i = "i" and j = "j" in Ord_linear_le)
   481 apply (auto simp add: Un_commute le_subset_iff subset_Un_iff lt_Ord) 
   482 done
   483 
   484 lemma Un_least_lt_iff: "[| Ord(i); Ord(j) |] ==> i Un j < k  <->  i<k & j<k"
   485 apply (safe intro!: Un_least_lt)
   486 apply (rule_tac [2] Un_upper2_le [THEN lt_trans1])
   487 apply (rule Un_upper1_le [THEN lt_trans1], auto) 
   488 done
   489 
   490 lemma Un_least_mem_iff:
   491     "[| Ord(i); Ord(j); Ord(k) |] ==> i Un j : k  <->  i:k & j:k"
   492 apply (insert Un_least_lt_iff [of i j k]) 
   493 apply (simp add: lt_def)
   494 done
   495 
   496 (*Replacing k by succ(k') yields the similar rule for le!*)
   497 lemma Int_greatest_lt: "[| i<k;  j<k |] ==> i Int j < k"
   498 apply (rule_tac i = "i" and j = "j" in Ord_linear_le)
   499 apply (auto simp add: Int_commute le_subset_iff subset_Int_iff lt_Ord) 
   500 done
   501 
   502 lemma Ord_Un_if:
   503      "[| Ord(i); Ord(j) |] ==> i \<union> j = (if j<i then i else j)"
   504 by (simp add: not_lt_iff_le le_imp_subset leI
   505               subset_Un_iff [symmetric]  subset_Un_iff2 [symmetric]) 
   506 
   507 lemma succ_Un_distrib:
   508      "[| Ord(i); Ord(j) |] ==> succ(i \<union> j) = succ(i) \<union> succ(j)"
   509 by (simp add: Ord_Un_if lt_Ord le_Ord2) 
   510 
   511 lemma lt_Un_iff:
   512      "[| Ord(i); Ord(j) |] ==> k < i \<union> j <-> k < i | k < j";
   513 apply (simp add: Ord_Un_if not_lt_iff_le) 
   514 apply (blast intro: leI lt_trans2)+ 
   515 done
   516 
   517 lemma le_Un_iff:
   518      "[| Ord(i); Ord(j) |] ==> k \<le> i \<union> j <-> k \<le> i | k \<le> j";
   519 by (simp add: succ_Un_distrib lt_Un_iff [symmetric]) 
   520 
   521 lemma Un_upper1_lt: "[|k < i; Ord(j)|] ==> k < i Un j"
   522 by (simp add: lt_Un_iff lt_Ord2) 
   523 
   524 lemma Un_upper2_lt: "[|k < j; Ord(i)|] ==> k < i Un j"
   525 by (simp add: lt_Un_iff lt_Ord2) 
   526 
   527 (*See also Transset_iff_Union_succ*)
   528 lemma Ord_Union_succ_eq: "Ord(i) ==> \<Union>(succ(i)) = i"
   529 by (blast intro: Ord_trans)
   530 
   531 
   532 (*** Results about limits ***)
   533 
   534 lemma Ord_Union [intro,simp,TC]: "[| !!i. i:A ==> Ord(i) |] ==> Ord(Union(A))"
   535 apply (rule Ord_is_Transset [THEN Transset_Union_family, THEN OrdI])
   536 apply (blast intro: Ord_contains_Transset)+
   537 done
   538 
   539 lemma Ord_UN [intro,simp,TC]:
   540      "[| !!x. x:A ==> Ord(B(x)) |] ==> Ord(UN x:A. B(x))"
   541 by (rule Ord_Union, blast)
   542 
   543 lemma Ord_Inter [intro,simp,TC]:
   544     "[| !!i. i:A ==> Ord(i) |] ==> Ord(Inter(A))" 
   545 apply (rule Transset_Inter_family [THEN OrdI])
   546 apply (blast intro: Ord_is_Transset) 
   547 apply (simp add: Inter_def) 
   548 apply (blast intro: Ord_contains_Transset) 
   549 done
   550 
   551 lemma Ord_INT [intro,simp,TC]:
   552     "[| !!x. x:A ==> Ord(B(x)) |] ==> Ord(INT x:A. B(x))"
   553 by (rule Ord_Inter, blast) 
   554 
   555 
   556 (* No < version; consider (UN i:nat.i)=nat *)
   557 lemma UN_least_le:
   558     "[| Ord(i);  !!x. x:A ==> b(x) le i |] ==> (UN x:A. b(x)) le i"
   559 apply (rule le_imp_subset [THEN UN_least, THEN subset_imp_le])
   560 apply (blast intro: Ord_UN elim: ltE)+
   561 done
   562 
   563 lemma UN_succ_least_lt:
   564     "[| j<i;  !!x. x:A ==> b(x)<j |] ==> (UN x:A. succ(b(x))) < i"
   565 apply (rule ltE, assumption)
   566 apply (rule UN_least_le [THEN lt_trans2])
   567 apply (blast intro: succ_leI)+
   568 done
   569 
   570 lemma UN_upper_lt:
   571      "[| a\<in>A;  i < b(a);  Ord(\<Union>x\<in>A. b(x)) |] ==> i < (\<Union>x\<in>A. b(x))"
   572 by (unfold lt_def, blast) 
   573 
   574 lemma UN_upper_le:
   575      "[| a: A;  i le b(a);  Ord(UN x:A. b(x)) |] ==> i le (UN x:A. b(x))"
   576 apply (frule ltD)
   577 apply (rule le_imp_subset [THEN subset_trans, THEN subset_imp_le])
   578 apply (blast intro: lt_Ord UN_upper)+
   579 done
   580 
   581 lemma lt_Union_iff: "\<forall>i\<in>A. Ord(i) ==> (j < \<Union>(A)) <-> (\<exists>i\<in>A. j<i)"
   582 by (auto simp: lt_def Ord_Union)
   583 
   584 lemma Union_upper_le:
   585      "[| j: J;  i\<le>j;  Ord(\<Union>(J)) |] ==> i \<le> \<Union>J"
   586 apply (subst Union_eq_UN)  
   587 apply (rule UN_upper_le, auto)
   588 done
   589 
   590 lemma le_implies_UN_le_UN:
   591     "[| !!x. x:A ==> c(x) le d(x) |] ==> (UN x:A. c(x)) le (UN x:A. d(x))"
   592 apply (rule UN_least_le)
   593 apply (rule_tac [2] UN_upper_le)
   594 apply (blast intro: Ord_UN le_Ord2)+ 
   595 done
   596 
   597 lemma Ord_equality: "Ord(i) ==> (UN y:i. succ(y)) = i"
   598 by (blast intro: Ord_trans)
   599 
   600 (*Holds for all transitive sets, not just ordinals*)
   601 lemma Ord_Union_subset: "Ord(i) ==> Union(i) <= i"
   602 by (blast intro: Ord_trans)
   603 
   604 
   605 (*** Limit ordinals -- general properties ***)
   606 
   607 lemma Limit_Union_eq: "Limit(i) ==> Union(i) = i"
   608 apply (unfold Limit_def)
   609 apply (fast intro!: ltI elim!: ltE elim: Ord_trans)
   610 done
   611 
   612 lemma Limit_is_Ord: "Limit(i) ==> Ord(i)"
   613 apply (unfold Limit_def)
   614 apply (erule conjunct1)
   615 done
   616 
   617 lemma Limit_has_0: "Limit(i) ==> 0 < i"
   618 apply (unfold Limit_def)
   619 apply (erule conjunct2 [THEN conjunct1])
   620 done
   621 
   622 lemma Limit_has_succ: "[| Limit(i);  j<i |] ==> succ(j) < i"
   623 by (unfold Limit_def, blast)
   624 
   625 lemma zero_not_Limit [iff]: "~ Limit(0)"
   626 by (simp add: Limit_def)
   627 
   628 lemma Limit_has_1: "Limit(i) ==> 1 < i"
   629 by (blast intro: Limit_has_0 Limit_has_succ)
   630 
   631 lemma increasing_LimitI: "[| 0<l; \<forall>x\<in>l. \<exists>y\<in>l. x<y |] ==> Limit(l)"
   632 apply (simp add: Limit_def lt_Ord2, clarify)
   633 apply (drule_tac i=y in ltD) 
   634 apply (blast intro: lt_trans1 [OF _ ltI] lt_Ord2)
   635 done
   636 
   637 lemma non_succ_LimitI: 
   638     "[| 0<i;  ALL y. succ(y) ~= i |] ==> Limit(i)"
   639 apply (unfold Limit_def)
   640 apply (safe del: subsetI)
   641 apply (rule_tac [2] not_le_iff_lt [THEN iffD1])
   642 apply (simp_all add: lt_Ord lt_Ord2) 
   643 apply (blast elim: leE lt_asym)
   644 done
   645 
   646 lemma succ_LimitE [elim!]: "Limit(succ(i)) ==> P"
   647 apply (rule lt_irrefl)
   648 apply (rule Limit_has_succ, assumption)
   649 apply (erule Limit_is_Ord [THEN Ord_succD, THEN le_refl])
   650 done
   651 
   652 lemma not_succ_Limit [simp]: "~ Limit(succ(i))"
   653 by blast
   654 
   655 lemma Limit_le_succD: "[| Limit(i);  i le succ(j) |] ==> i le j"
   656 by (blast elim!: leE)
   657 
   658 
   659 (** Traditional 3-way case analysis on ordinals **)
   660 
   661 lemma Ord_cases_disj: "Ord(i) ==> i=0 | (EX j. Ord(j) & i=succ(j)) | Limit(i)"
   662 by (blast intro!: non_succ_LimitI Ord_0_lt)
   663 
   664 lemma Ord_cases:
   665     "[| Ord(i);                  
   666         i=0                          ==> P;      
   667         !!j. [| Ord(j); i=succ(j) |] ==> P;      
   668         Limit(i)                     ==> P       
   669      |] ==> P"
   670 by (drule Ord_cases_disj, blast)  
   671 
   672 lemma trans_induct3:
   673      "[| Ord(i);                 
   674          P(0);                   
   675          !!x. [| Ord(x);  P(x) |] ==> P(succ(x));        
   676          !!x. [| Limit(x);  ALL y:x. P(y) |] ==> P(x)    
   677       |] ==> P(i)"
   678 apply (erule trans_induct)
   679 apply (erule Ord_cases, blast+)
   680 done
   681 
   682 text{*A set of ordinals is either empty, contains its own union, or its
   683 union is a limit ordinal.*}
   684 lemma Ord_set_cases:
   685    "\<forall>i\<in>I. Ord(i) ==> I=0 \<or> \<Union>(I) \<in> I \<or> (\<Union>(I) \<notin> I \<and> Limit(\<Union>(I)))"
   686 apply (clarify elim!: not_emptyE) 
   687 apply (cases "\<Union>(I)" rule: Ord_cases) 
   688    apply (blast intro: Ord_Union)
   689   apply (blast intro: subst_elem)
   690  apply auto 
   691 apply (clarify elim!: equalityE succ_subsetE)
   692 apply (simp add: Union_subset_iff)
   693 apply (subgoal_tac "B = succ(j)", blast)
   694 apply (rule le_anti_sym) 
   695  apply (simp add: le_subset_iff) 
   696 apply (simp add: ltI)
   697 done
   698 
   699 text{*If the union of a set of ordinals is a successor, then it is
   700 an element of that set.*}
   701 lemma Ord_Union_eq_succD: "[|\<forall>x\<in>X. Ord(x);  \<Union>X = succ(j)|] ==> succ(j) \<in> X"
   702 by (drule Ord_set_cases, auto)
   703 
   704 lemma Limit_Union [rule_format]: "[| I \<noteq> 0;  \<forall>i\<in>I. Limit(i) |] ==> Limit(\<Union>I)"
   705 apply (simp add: Limit_def lt_def)
   706 apply (blast intro!: equalityI)
   707 done
   708 
   709 (*special induction rules for the "induct" method*)
   710 lemmas Ord_induct = Ord_induct [consumes 2]
   711   and Ord_induct_rule = Ord_induct [rule_format, consumes 2]
   712   and trans_induct = trans_induct [consumes 1]
   713   and trans_induct_rule = trans_induct [rule_format, consumes 1]
   714   and trans_induct3 = trans_induct3 [case_names 0 succ limit, consumes 1]
   715   and trans_induct3_rule = trans_induct3 [rule_format, case_names 0 succ limit, consumes 1]
   716 
   717 ML 
   718 {*
   719 val Memrel_def = thm "Memrel_def";
   720 val Transset_def = thm "Transset_def";
   721 val Ord_def = thm "Ord_def";
   722 val lt_def = thm "lt_def";
   723 val Limit_def = thm "Limit_def";
   724 
   725 val Transset_iff_Pow = thm "Transset_iff_Pow";
   726 val Transset_iff_Union_succ = thm "Transset_iff_Union_succ";
   727 val Transset_iff_Union_subset = thm "Transset_iff_Union_subset";
   728 val Transset_doubleton_D = thm "Transset_doubleton_D";
   729 val Transset_Pair_D = thm "Transset_Pair_D";
   730 val Transset_includes_domain = thm "Transset_includes_domain";
   731 val Transset_includes_range = thm "Transset_includes_range";
   732 val Transset_0 = thm "Transset_0";
   733 val Transset_Un = thm "Transset_Un";
   734 val Transset_Int = thm "Transset_Int";
   735 val Transset_succ = thm "Transset_succ";
   736 val Transset_Pow = thm "Transset_Pow";
   737 val Transset_Union = thm "Transset_Union";
   738 val Transset_Union_family = thm "Transset_Union_family";
   739 val Transset_Inter_family = thm "Transset_Inter_family";
   740 val OrdI = thm "OrdI";
   741 val Ord_is_Transset = thm "Ord_is_Transset";
   742 val Ord_contains_Transset = thm "Ord_contains_Transset";
   743 val Ord_in_Ord = thm "Ord_in_Ord";
   744 val Ord_succD = thm "Ord_succD";
   745 val Ord_subset_Ord = thm "Ord_subset_Ord";
   746 val OrdmemD = thm "OrdmemD";
   747 val Ord_trans = thm "Ord_trans";
   748 val Ord_succ_subsetI = thm "Ord_succ_subsetI";
   749 val Ord_0 = thm "Ord_0";
   750 val Ord_succ = thm "Ord_succ";
   751 val Ord_1 = thm "Ord_1";
   752 val Ord_succ_iff = thm "Ord_succ_iff";
   753 val Ord_Un = thm "Ord_Un";
   754 val Ord_Int = thm "Ord_Int";
   755 val Ord_Inter = thm "Ord_Inter";
   756 val Ord_INT = thm "Ord_INT";
   757 val ON_class = thm "ON_class";
   758 val ltI = thm "ltI";
   759 val ltE = thm "ltE";
   760 val ltD = thm "ltD";
   761 val not_lt0 = thm "not_lt0";
   762 val lt_Ord = thm "lt_Ord";
   763 val lt_Ord2 = thm "lt_Ord2";
   764 val le_Ord2 = thm "le_Ord2";
   765 val lt0E = thm "lt0E";
   766 val lt_trans = thm "lt_trans";
   767 val lt_not_sym = thm "lt_not_sym";
   768 val lt_asym = thm "lt_asym";
   769 val lt_irrefl = thm "lt_irrefl";
   770 val lt_not_refl = thm "lt_not_refl";
   771 val le_iff = thm "le_iff";
   772 val leI = thm "leI";
   773 val le_eqI = thm "le_eqI";
   774 val le_refl = thm "le_refl";
   775 val le_refl_iff = thm "le_refl_iff";
   776 val leCI = thm "leCI";
   777 val leE = thm "leE";
   778 val le_anti_sym = thm "le_anti_sym";
   779 val le0_iff = thm "le0_iff";
   780 val le0D = thm "le0D";
   781 val Memrel_iff = thm "Memrel_iff";
   782 val MemrelI = thm "MemrelI";
   783 val MemrelE = thm "MemrelE";
   784 val Memrel_type = thm "Memrel_type";
   785 val Memrel_mono = thm "Memrel_mono";
   786 val Memrel_0 = thm "Memrel_0";
   787 val Memrel_1 = thm "Memrel_1";
   788 val wf_Memrel = thm "wf_Memrel";
   789 val trans_Memrel = thm "trans_Memrel";
   790 val Transset_Memrel_iff = thm "Transset_Memrel_iff";
   791 val Transset_induct = thm "Transset_induct";
   792 val Ord_induct = thm "Ord_induct";
   793 val trans_induct = thm "trans_induct";
   794 val Ord_linear = thm "Ord_linear";
   795 val Ord_linear_lt = thm "Ord_linear_lt";
   796 val Ord_linear2 = thm "Ord_linear2";
   797 val Ord_linear_le = thm "Ord_linear_le";
   798 val le_imp_not_lt = thm "le_imp_not_lt";
   799 val not_lt_imp_le = thm "not_lt_imp_le";
   800 val Ord_mem_iff_lt = thm "Ord_mem_iff_lt";
   801 val not_lt_iff_le = thm "not_lt_iff_le";
   802 val not_le_iff_lt = thm "not_le_iff_lt";
   803 val Ord_0_le = thm "Ord_0_le";
   804 val Ord_0_lt = thm "Ord_0_lt";
   805 val Ord_0_lt_iff = thm "Ord_0_lt_iff";
   806 val zero_le_succ_iff = thm "zero_le_succ_iff";
   807 val subset_imp_le = thm "subset_imp_le";
   808 val le_imp_subset = thm "le_imp_subset";
   809 val le_subset_iff = thm "le_subset_iff";
   810 val le_succ_iff = thm "le_succ_iff";
   811 val all_lt_imp_le = thm "all_lt_imp_le";
   812 val lt_trans1 = thm "lt_trans1";
   813 val lt_trans2 = thm "lt_trans2";
   814 val le_trans = thm "le_trans";
   815 val succ_leI = thm "succ_leI";
   816 val succ_leE = thm "succ_leE";
   817 val succ_le_iff = thm "succ_le_iff";
   818 val succ_le_imp_le = thm "succ_le_imp_le";
   819 val lt_subset_trans = thm "lt_subset_trans";
   820 val Un_upper1_le = thm "Un_upper1_le";
   821 val Un_upper2_le = thm "Un_upper2_le";
   822 val Un_least_lt = thm "Un_least_lt";
   823 val Un_least_lt_iff = thm "Un_least_lt_iff";
   824 val Un_least_mem_iff = thm "Un_least_mem_iff";
   825 val Int_greatest_lt = thm "Int_greatest_lt";
   826 val Ord_Union = thm "Ord_Union";
   827 val Ord_UN = thm "Ord_UN";
   828 val UN_least_le = thm "UN_least_le";
   829 val UN_succ_least_lt = thm "UN_succ_least_lt";
   830 val UN_upper_le = thm "UN_upper_le";
   831 val le_implies_UN_le_UN = thm "le_implies_UN_le_UN";
   832 val Ord_equality = thm "Ord_equality";
   833 val Ord_Union_subset = thm "Ord_Union_subset";
   834 val Limit_Union_eq = thm "Limit_Union_eq";
   835 val Limit_is_Ord = thm "Limit_is_Ord";
   836 val Limit_has_0 = thm "Limit_has_0";
   837 val Limit_has_succ = thm "Limit_has_succ";
   838 val non_succ_LimitI = thm "non_succ_LimitI";
   839 val succ_LimitE = thm "succ_LimitE";
   840 val not_succ_Limit = thm "not_succ_Limit";
   841 val Limit_le_succD = thm "Limit_le_succD";
   842 val Ord_cases_disj = thm "Ord_cases_disj";
   843 val Ord_cases = thm "Ord_cases";
   844 val trans_induct3 = thm "trans_induct3";
   845 *}
   846 
   847 end