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