src/ZF/Ordinal.thy
 author wenzelm Tue Sep 25 22:36:06 2012 +0200 (2012-09-25 ago) changeset 49566 66cbf8bb4693 parent 46993 7371429c527d child 58871 c399ae4b836f permissions -rw-r--r--
basic integration of graphview into document model;
updated Isabelle/jEdit authors and dependencies etc.;
1 (*  Title:      ZF/Ordinal.thy
2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
3     Copyright   1994  University of Cambridge
4 *)
8 theory Ordinal imports WF Bool equalities begin
10 definition
11   Memrel        :: "i=>i"  where
12     "Memrel(A)   == {z\<in>A*A . \<exists>x y. z=<x,y> & x\<in>y }"
14 definition
15   Transset  :: "i=>o"  where
16     "Transset(i) == \<forall>x\<in>i. x<=i"
18 definition
19   Ord  :: "i=>o"  where
20     "Ord(i)      == Transset(i) & (\<forall>x\<in>i. Transset(x))"
22 definition
23   lt        :: "[i,i] => o"  (infixl "<" 50)   (*less-than on ordinals*)  where
24     "i<j         == i\<in>j & Ord(j)"
26 definition
27   Limit         :: "i=>o"  where
28     "Limit(i)    == Ord(i) & 0<i & (\<forall>y. y<i \<longrightarrow> succ(y)<i)"
30 abbreviation
31   le  (infixl "le" 50) where
32   "x le y == x < succ(y)"
34 notation (xsymbols)
35   le  (infixl "\<le>" 50)
37 notation (HTML output)
38   le  (infixl "\<le>" 50)
41 subsection{*Rules for Transset*}
43 subsubsection{*Three Neat Characterisations of Transset*}
45 lemma Transset_iff_Pow: "Transset(A) <-> A<=Pow(A)"
46 by (unfold Transset_def, blast)
48 lemma Transset_iff_Union_succ: "Transset(A) <-> \<Union>(succ(A)) = A"
49 apply (unfold Transset_def)
50 apply (blast elim!: equalityE)
51 done
53 lemma Transset_iff_Union_subset: "Transset(A) <-> \<Union>(A) \<subseteq> A"
54 by (unfold Transset_def, blast)
56 subsubsection{*Consequences of Downwards Closure*}
58 lemma Transset_doubleton_D:
59     "[| Transset(C); {a,b}: C |] ==> a\<in>C & b\<in>C"
60 by (unfold Transset_def, blast)
62 lemma Transset_Pair_D:
63     "[| Transset(C); <a,b>\<in>C |] ==> a\<in>C & b\<in>C"
65 apply (blast dest: Transset_doubleton_D)
66 done
68 lemma Transset_includes_domain:
69     "[| Transset(C); A*B \<subseteq> C; b \<in> B |] ==> A \<subseteq> C"
70 by (blast dest: Transset_Pair_D)
72 lemma Transset_includes_range:
73     "[| Transset(C); A*B \<subseteq> C; a \<in> A |] ==> B \<subseteq> C"
74 by (blast dest: Transset_Pair_D)
76 subsubsection{*Closure Properties*}
78 lemma Transset_0: "Transset(0)"
79 by (unfold Transset_def, blast)
81 lemma Transset_Un:
82     "[| Transset(i);  Transset(j) |] ==> Transset(i \<union> j)"
83 by (unfold Transset_def, blast)
85 lemma Transset_Int:
86     "[| Transset(i);  Transset(j) |] ==> Transset(i \<inter> j)"
87 by (unfold Transset_def, blast)
89 lemma Transset_succ: "Transset(i) ==> Transset(succ(i))"
90 by (unfold Transset_def, blast)
92 lemma Transset_Pow: "Transset(i) ==> Transset(Pow(i))"
93 by (unfold Transset_def, blast)
95 lemma Transset_Union: "Transset(A) ==> Transset(\<Union>(A))"
96 by (unfold Transset_def, blast)
98 lemma Transset_Union_family:
99     "[| !!i. i\<in>A ==> Transset(i) |] ==> Transset(\<Union>(A))"
100 by (unfold Transset_def, blast)
102 lemma Transset_Inter_family:
103     "[| !!i. i\<in>A ==> Transset(i) |] ==> Transset(\<Inter>(A))"
104 by (unfold Inter_def Transset_def, blast)
106 lemma Transset_UN:
107      "(!!x. x \<in> A ==> Transset(B(x))) ==> Transset (\<Union>x\<in>A. B(x))"
108 by (rule Transset_Union_family, auto)
110 lemma Transset_INT:
111      "(!!x. x \<in> A ==> Transset(B(x))) ==> Transset (\<Inter>x\<in>A. B(x))"
112 by (rule Transset_Inter_family, auto)
115 subsection{*Lemmas for Ordinals*}
117 lemma OrdI:
118     "[| Transset(i);  !!x. x\<in>i ==> Transset(x) |]  ==>  Ord(i)"
121 lemma Ord_is_Transset: "Ord(i) ==> Transset(i)"
124 lemma Ord_contains_Transset:
125     "[| Ord(i);  j\<in>i |] ==> Transset(j) "
126 by (unfold Ord_def, blast)
129 lemma Ord_in_Ord: "[| Ord(i);  j\<in>i |] ==> Ord(j)"
130 by (unfold Ord_def Transset_def, blast)
132 (*suitable for rewriting PROVIDED i has been fixed*)
133 lemma Ord_in_Ord': "[| j\<in>i; Ord(i) |] ==> Ord(j)"
134 by (blast intro: Ord_in_Ord)
136 (* Ord(succ(j)) ==> Ord(j) *)
137 lemmas Ord_succD = Ord_in_Ord [OF _ succI1]
139 lemma Ord_subset_Ord: "[| Ord(i);  Transset(j);  j<=i |] ==> Ord(j)"
140 by (simp add: Ord_def Transset_def, blast)
142 lemma OrdmemD: "[| j\<in>i;  Ord(i) |] ==> j<=i"
143 by (unfold Ord_def Transset_def, blast)
145 lemma Ord_trans: "[| i\<in>j;  j\<in>k;  Ord(k) |] ==> i\<in>k"
146 by (blast dest: OrdmemD)
148 lemma Ord_succ_subsetI: "[| i\<in>j;  Ord(j) |] ==> succ(i) \<subseteq> j"
149 by (blast dest: OrdmemD)
152 subsection{*The Construction of Ordinals: 0, succ, Union*}
154 lemma Ord_0 [iff,TC]: "Ord(0)"
155 by (blast intro: OrdI Transset_0)
157 lemma Ord_succ [TC]: "Ord(i) ==> Ord(succ(i))"
158 by (blast intro: OrdI Transset_succ Ord_is_Transset Ord_contains_Transset)
160 lemmas Ord_1 = Ord_0 [THEN Ord_succ]
162 lemma Ord_succ_iff [iff]: "Ord(succ(i)) <-> Ord(i)"
163 by (blast intro: Ord_succ dest!: Ord_succD)
165 lemma Ord_Un [intro,simp,TC]: "[| Ord(i); Ord(j) |] ==> Ord(i \<union> j)"
166 apply (unfold Ord_def)
167 apply (blast intro!: Transset_Un)
168 done
170 lemma Ord_Int [TC]: "[| Ord(i); Ord(j) |] ==> Ord(i \<inter> j)"
171 apply (unfold Ord_def)
172 apply (blast intro!: Transset_Int)
173 done
175 text{*There is no set of all ordinals, for then it would contain itself*}
176 lemma ON_class: "~ (\<forall>i. i\<in>X <-> Ord(i))"
177 proof (rule notI)
178   assume X: "\<forall>i. i \<in> X \<longleftrightarrow> Ord(i)"
179   have "\<forall>x y. x\<in>X \<longrightarrow> y\<in>x \<longrightarrow> y\<in>X"
180     by (simp add: X, blast intro: Ord_in_Ord)
181   hence "Transset(X)"
182      by (auto simp add: Transset_def)
183   moreover have "\<And>x. x \<in> X \<Longrightarrow> Transset(x)"
184      by (simp add: X Ord_def)
185   ultimately have "Ord(X)" by (rule OrdI)
186   hence "X \<in> X" by (simp add: X)
187   thus "False" by (rule mem_irrefl)
188 qed
190 subsection{*< is 'less Than' for Ordinals*}
192 lemma ltI: "[| i\<in>j;  Ord(j) |] ==> i<j"
193 by (unfold lt_def, blast)
195 lemma ltE:
196     "[| i<j;  [| i\<in>j;  Ord(i);  Ord(j) |] ==> P |] ==> P"
197 apply (unfold lt_def)
198 apply (blast intro: Ord_in_Ord)
199 done
201 lemma ltD: "i<j ==> i\<in>j"
202 by (erule ltE, assumption)
204 lemma not_lt0 [simp]: "~ i<0"
205 by (unfold lt_def, blast)
207 lemma lt_Ord: "j<i ==> Ord(j)"
208 by (erule ltE, assumption)
210 lemma lt_Ord2: "j<i ==> Ord(i)"
211 by (erule ltE, assumption)
213 (* @{term"ja \<le> j ==> Ord(j)"} *)
214 lemmas le_Ord2 = lt_Ord2 [THEN Ord_succD]
216 (* i<0 ==> R *)
217 lemmas lt0E = not_lt0 [THEN notE, elim!]
219 lemma lt_trans [trans]: "[| i<j;  j<k |] ==> i<k"
220 by (blast intro!: ltI elim!: ltE intro: Ord_trans)
222 lemma lt_not_sym: "i<j ==> ~ (j<i)"
223 apply (unfold lt_def)
224 apply (blast elim: mem_asym)
225 done
227 (* [| i<j;  ~P ==> j<i |] ==> P *)
228 lemmas lt_asym = lt_not_sym [THEN swap]
230 lemma lt_irrefl [elim!]: "i<i ==> P"
231 by (blast intro: lt_asym)
233 lemma lt_not_refl: "~ i<i"
234 apply (rule notI)
235 apply (erule lt_irrefl)
236 done
239 text{* Recall that  @{term"i \<le> j"}  abbreviates  @{term"i<succ(j)"} !! *}
241 lemma le_iff: "i \<le> j <-> i<j | (i=j & Ord(j))"
242 by (unfold lt_def, blast)
244 (*Equivalently, i<j ==> i < succ(j)*)
245 lemma leI: "i<j ==> i \<le> j"
248 lemma le_eqI: "[| i=j;  Ord(j) |] ==> i \<le> j"
251 lemmas le_refl = refl [THEN le_eqI]
253 lemma le_refl_iff [iff]: "i \<le> i <-> Ord(i)"
254 by (simp (no_asm_simp) add: lt_not_refl le_iff)
256 lemma leCI: "(~ (i=j & Ord(j)) ==> i<j) ==> i \<le> j"
257 by (simp add: le_iff, blast)
259 lemma leE:
260     "[| i \<le> j;  i<j ==> P;  [| i=j;  Ord(j) |] ==> P |] ==> P"
261 by (simp add: le_iff, blast)
263 lemma le_anti_sym: "[| i \<le> j;  j \<le> i |] ==> i=j"
265 apply (blast elim: lt_asym)
266 done
268 lemma le0_iff [simp]: "i \<le> 0 <-> i=0"
269 by (blast elim!: leE)
271 lemmas le0D = le0_iff [THEN iffD1, dest!]
273 subsection{*Natural Deduction Rules for Memrel*}
275 (*The lemmas MemrelI/E give better speed than [iff] here*)
276 lemma Memrel_iff [simp]: "<a,b> \<in> Memrel(A) <-> a\<in>b & a\<in>A & b\<in>A"
277 by (unfold Memrel_def, blast)
279 lemma MemrelI [intro!]: "[| a \<in> b;  a \<in> A;  b \<in> A |] ==> <a,b> \<in> Memrel(A)"
280 by auto
282 lemma MemrelE [elim!]:
283     "[| <a,b> \<in> Memrel(A);
284         [| a \<in> A;  b \<in> A;  a\<in>b |]  ==> P |]
285      ==> P"
286 by auto
288 lemma Memrel_type: "Memrel(A) \<subseteq> A*A"
289 by (unfold Memrel_def, blast)
291 lemma Memrel_mono: "A<=B ==> Memrel(A) \<subseteq> Memrel(B)"
292 by (unfold Memrel_def, blast)
294 lemma Memrel_0 [simp]: "Memrel(0) = 0"
295 by (unfold Memrel_def, blast)
297 lemma Memrel_1 [simp]: "Memrel(1) = 0"
298 by (unfold Memrel_def, blast)
300 lemma relation_Memrel: "relation(Memrel(A))"
301 by (simp add: relation_def Memrel_def)
303 (*The membership relation (as a set) is well-founded.
304   Proof idea: show A<=B by applying the foundation axiom to A-B *)
305 lemma wf_Memrel: "wf(Memrel(A))"
306 apply (unfold wf_def)
307 apply (rule foundation [THEN disjE, THEN allI], erule disjI1, blast)
308 done
310 text{*The premise @{term "Ord(i)"} does not suffice.*}
311 lemma trans_Memrel:
312     "Ord(i) ==> trans(Memrel(i))"
313 by (unfold Ord_def Transset_def trans_def, blast)
315 text{*However, the following premise is strong enough.*}
316 lemma Transset_trans_Memrel:
317     "\<forall>j\<in>i. Transset(j) ==> trans(Memrel(i))"
318 by (unfold Transset_def trans_def, blast)
320 (*If Transset(A) then Memrel(A) internalizes the membership relation below A*)
321 lemma Transset_Memrel_iff:
322     "Transset(A) ==> <a,b> \<in> Memrel(A) <-> a\<in>b & b\<in>A"
323 by (unfold Transset_def, blast)
326 subsection{*Transfinite Induction*}
328 (*Epsilon induction over a transitive set*)
329 lemma Transset_induct:
330     "[| i \<in> k;  Transset(k);
331         !!x.[| x \<in> k;  \<forall>y\<in>x. P(y) |] ==> P(x) |]
332      ==>  P(i)"
334 apply (erule wf_Memrel [THEN wf_induct2], blast+)
335 done
337 (*Induction over an ordinal*)
338 lemmas Ord_induct [consumes 2] = Transset_induct [rule_format, OF _ Ord_is_Transset]
340 (*Induction over the class of ordinals -- a useful corollary of Ord_induct*)
342 lemma trans_induct [rule_format, consumes 1, case_names step]:
343     "[| Ord(i);
344         !!x.[| Ord(x);  \<forall>y\<in>x. P(y) |] ==> P(x) |]
345      ==>  P(i)"
346 apply (rule Ord_succ [THEN succI1 [THEN Ord_induct]], assumption)
347 apply (blast intro: Ord_succ [THEN Ord_in_Ord])
348 done
351 section{*Fundamental properties of the epsilon ordering (< on ordinals)*}
354 subsubsection{*Proving That < is a Linear Ordering on the Ordinals*}
356 lemma Ord_linear:
357      "Ord(i) \<Longrightarrow> Ord(j) \<Longrightarrow> i\<in>j | i=j | j\<in>i"
358 proof (induct i arbitrary: j rule: trans_induct)
359   case (step i)
360   note step_i = step
361   show ?case using `Ord(j)`
362     proof (induct j rule: trans_induct)
363       case (step j)
364       thus ?case using step_i
365         by (blast dest: Ord_trans)
366     qed
367 qed
369 text{*The trichotomy law for ordinals*}
370 lemma Ord_linear_lt:
371  assumes o: "Ord(i)" "Ord(j)"
372  obtains (lt) "i<j" | (eq) "i=j" | (gt) "j<i"
374 apply (rule_tac i1=i and j1=j in Ord_linear [THEN disjE])
375 apply (blast intro: o)+
376 done
378 lemma Ord_linear2:
379  assumes o: "Ord(i)" "Ord(j)"
380  obtains (lt) "i<j" | (ge) "j \<le> i"
381 apply (rule_tac i = i and j = j in Ord_linear_lt)
382 apply (blast intro: leI le_eqI sym o) +
383 done
385 lemma Ord_linear_le:
386  assumes o: "Ord(i)" "Ord(j)"
387  obtains (le) "i \<le> j" | (ge) "j \<le> i"
388 apply (rule_tac i = i and j = j in Ord_linear_lt)
389 apply (blast intro: leI le_eqI o) +
390 done
392 lemma le_imp_not_lt: "j \<le> i ==> ~ i<j"
393 by (blast elim!: leE elim: lt_asym)
395 lemma not_lt_imp_le: "[| ~ i<j;  Ord(i);  Ord(j) |] ==> j \<le> i"
396 by (rule_tac i = i and j = j in Ord_linear2, auto)
398 subsubsection{*Some Rewrite Rules for <, le*}
400 lemma Ord_mem_iff_lt: "Ord(j) ==> i\<in>j <-> i<j"
401 by (unfold lt_def, blast)
403 lemma not_lt_iff_le: "[| Ord(i);  Ord(j) |] ==> ~ i<j <-> j \<le> i"
404 by (blast dest: le_imp_not_lt not_lt_imp_le)
406 lemma not_le_iff_lt: "[| Ord(i);  Ord(j) |] ==> ~ i \<le> j <-> j<i"
407 by (simp (no_asm_simp) add: not_lt_iff_le [THEN iff_sym])
409 (*This is identical to 0<succ(i) *)
410 lemma Ord_0_le: "Ord(i) ==> 0 \<le> i"
411 by (erule not_lt_iff_le [THEN iffD1], auto)
413 lemma Ord_0_lt: "[| Ord(i);  i\<noteq>0 |] ==> 0<i"
414 apply (erule not_le_iff_lt [THEN iffD1])
415 apply (rule Ord_0, blast)
416 done
418 lemma Ord_0_lt_iff: "Ord(i) ==> i\<noteq>0 <-> 0<i"
419 by (blast intro: Ord_0_lt)
422 subsection{*Results about Less-Than or Equals*}
424 (** For ordinals, @{term"j\<subseteq>i"} implies @{term"j \<le> i"} (less-than or equals) **)
426 lemma zero_le_succ_iff [iff]: "0 \<le> succ(x) <-> Ord(x)"
427 by (blast intro: Ord_0_le elim: ltE)
429 lemma subset_imp_le: "[| j<=i;  Ord(i);  Ord(j) |] ==> j \<le> i"
430 apply (rule not_lt_iff_le [THEN iffD1], assumption+)
431 apply (blast elim: ltE mem_irrefl)
432 done
434 lemma le_imp_subset: "i \<le> j ==> i<=j"
435 by (blast dest: OrdmemD elim: ltE leE)
437 lemma le_subset_iff: "j \<le> i <-> j<=i & Ord(i) & Ord(j)"
438 by (blast dest: subset_imp_le le_imp_subset elim: ltE)
440 lemma le_succ_iff: "i \<le> succ(j) <-> i \<le> j | i=succ(j) & Ord(i)"
441 apply (simp (no_asm) add: le_iff)
442 apply blast
443 done
445 (*Just a variant of subset_imp_le*)
446 lemma all_lt_imp_le: "[| Ord(i);  Ord(j);  !!x. x<j ==> x<i |] ==> j \<le> i"
447 by (blast intro: not_lt_imp_le dest: lt_irrefl)
449 subsubsection{*Transitivity Laws*}
451 lemma lt_trans1: "[| i \<le> j;  j<k |] ==> i<k"
452 by (blast elim!: leE intro: lt_trans)
454 lemma lt_trans2: "[| i<j;  j \<le> k |] ==> i<k"
455 by (blast elim!: leE intro: lt_trans)
457 lemma le_trans: "[| i \<le> j;  j \<le> k |] ==> i \<le> k"
458 by (blast intro: lt_trans1)
460 lemma succ_leI: "i<j ==> succ(i) \<le> j"
461 apply (rule not_lt_iff_le [THEN iffD1])
462 apply (blast elim: ltE leE lt_asym)+
463 done
465 (*Identical to  succ(i) < succ(j) ==> i<j  *)
466 lemma succ_leE: "succ(i) \<le> j ==> i<j"
467 apply (rule not_le_iff_lt [THEN iffD1])
468 apply (blast elim: ltE leE lt_asym)+
469 done
471 lemma succ_le_iff [iff]: "succ(i) \<le> j <-> i<j"
472 by (blast intro: succ_leI succ_leE)
474 lemma succ_le_imp_le: "succ(i) \<le> succ(j) ==> i \<le> j"
475 by (blast dest!: succ_leE)
477 lemma lt_subset_trans: "[| i \<subseteq> j;  j<k;  Ord(i) |] ==> i<k"
478 apply (rule subset_imp_le [THEN lt_trans1])
479 apply (blast intro: elim: ltE) +
480 done
482 lemma lt_imp_0_lt: "j<i ==> 0<i"
483 by (blast intro: lt_trans1 Ord_0_le [OF lt_Ord])
485 lemma succ_lt_iff: "succ(i) < j <-> i<j & succ(i) \<noteq> j"
486 apply auto
487 apply (blast intro: lt_trans le_refl dest: lt_Ord)
488 apply (frule lt_Ord)
489 apply (rule not_le_iff_lt [THEN iffD1])
490   apply (blast intro: lt_Ord2)
491  apply blast
492 apply (simp add: lt_Ord lt_Ord2 le_iff)
493 apply (blast dest: lt_asym)
494 done
496 lemma Ord_succ_mem_iff: "Ord(j) ==> succ(i) \<in> succ(j) <-> i\<in>j"
497 apply (insert succ_le_iff [of i j])
499 done
501 subsubsection{*Union and Intersection*}
503 lemma Un_upper1_le: "[| Ord(i); Ord(j) |] ==> i \<le> i \<union> j"
504 by (rule Un_upper1 [THEN subset_imp_le], auto)
506 lemma Un_upper2_le: "[| Ord(i); Ord(j) |] ==> j \<le> i \<union> j"
507 by (rule Un_upper2 [THEN subset_imp_le], auto)
509 (*Replacing k by succ(k') yields the similar rule for le!*)
510 lemma Un_least_lt: "[| i<k;  j<k |] ==> i \<union> j < k"
511 apply (rule_tac i = i and j = j in Ord_linear_le)
512 apply (auto simp add: Un_commute le_subset_iff subset_Un_iff lt_Ord)
513 done
515 lemma Un_least_lt_iff: "[| Ord(i); Ord(j) |] ==> i \<union> j < k  <->  i<k & j<k"
516 apply (safe intro!: Un_least_lt)
517 apply (rule_tac [2] Un_upper2_le [THEN lt_trans1])
518 apply (rule Un_upper1_le [THEN lt_trans1], auto)
519 done
521 lemma Un_least_mem_iff:
522     "[| Ord(i); Ord(j); Ord(k) |] ==> i \<union> j \<in> k  <->  i\<in>k & j\<in>k"
523 apply (insert Un_least_lt_iff [of i j k])
525 done
527 (*Replacing k by succ(k') yields the similar rule for le!*)
528 lemma Int_greatest_lt: "[| i<k;  j<k |] ==> i \<inter> j < k"
529 apply (rule_tac i = i and j = j in Ord_linear_le)
530 apply (auto simp add: Int_commute le_subset_iff subset_Int_iff lt_Ord)
531 done
533 lemma Ord_Un_if:
534      "[| Ord(i); Ord(j) |] ==> i \<union> j = (if j<i then i else j)"
535 by (simp add: not_lt_iff_le le_imp_subset leI
536               subset_Un_iff [symmetric]  subset_Un_iff2 [symmetric])
538 lemma succ_Un_distrib:
539      "[| Ord(i); Ord(j) |] ==> succ(i \<union> j) = succ(i) \<union> succ(j)"
540 by (simp add: Ord_Un_if lt_Ord le_Ord2)
542 lemma lt_Un_iff:
543      "[| Ord(i); Ord(j) |] ==> k < i \<union> j <-> k < i | k < j"
544 apply (simp add: Ord_Un_if not_lt_iff_le)
545 apply (blast intro: leI lt_trans2)+
546 done
548 lemma le_Un_iff:
549      "[| Ord(i); Ord(j) |] ==> k \<le> i \<union> j <-> k \<le> i | k \<le> j"
550 by (simp add: succ_Un_distrib lt_Un_iff [symmetric])
552 lemma Un_upper1_lt: "[|k < i; Ord(j)|] ==> k < i \<union> j"
553 by (simp add: lt_Un_iff lt_Ord2)
555 lemma Un_upper2_lt: "[|k < j; Ord(i)|] ==> k < i \<union> j"
556 by (simp add: lt_Un_iff lt_Ord2)
559 lemma Ord_Union_succ_eq: "Ord(i) ==> \<Union>(succ(i)) = i"
560 by (blast intro: Ord_trans)
565 lemma Ord_Union [intro,simp,TC]: "[| !!i. i\<in>A ==> Ord(i) |] ==> Ord(\<Union>(A))"
566 apply (rule Ord_is_Transset [THEN Transset_Union_family, THEN OrdI])
567 apply (blast intro: Ord_contains_Transset)+
568 done
570 lemma Ord_UN [intro,simp,TC]:
571      "[| !!x. x\<in>A ==> Ord(B(x)) |] ==> Ord(\<Union>x\<in>A. B(x))"
572 by (rule Ord_Union, blast)
574 lemma Ord_Inter [intro,simp,TC]:
575     "[| !!i. i\<in>A ==> Ord(i) |] ==> Ord(\<Inter>(A))"
576 apply (rule Transset_Inter_family [THEN OrdI])
577 apply (blast intro: Ord_is_Transset)
579 apply (blast intro: Ord_contains_Transset)
580 done
582 lemma Ord_INT [intro,simp,TC]:
583     "[| !!x. x\<in>A ==> Ord(B(x)) |] ==> Ord(\<Inter>x\<in>A. B(x))"
584 by (rule Ord_Inter, blast)
587 (* No < version of this theorem: consider that @{term"(\<Union>i\<in>nat.i)=nat"}! *)
588 lemma UN_least_le:
589     "[| Ord(i);  !!x. x\<in>A ==> b(x) \<le> i |] ==> (\<Union>x\<in>A. b(x)) \<le> i"
590 apply (rule le_imp_subset [THEN UN_least, THEN subset_imp_le])
591 apply (blast intro: Ord_UN elim: ltE)+
592 done
594 lemma UN_succ_least_lt:
595     "[| j<i;  !!x. x\<in>A ==> b(x)<j |] ==> (\<Union>x\<in>A. succ(b(x))) < i"
596 apply (rule ltE, assumption)
597 apply (rule UN_least_le [THEN lt_trans2])
598 apply (blast intro: succ_leI)+
599 done
601 lemma UN_upper_lt:
602      "[| a\<in>A;  i < b(a);  Ord(\<Union>x\<in>A. b(x)) |] ==> i < (\<Union>x\<in>A. b(x))"
603 by (unfold lt_def, blast)
605 lemma UN_upper_le:
606      "[| a \<in> A;  i \<le> b(a);  Ord(\<Union>x\<in>A. b(x)) |] ==> i \<le> (\<Union>x\<in>A. b(x))"
607 apply (frule ltD)
608 apply (rule le_imp_subset [THEN subset_trans, THEN subset_imp_le])
609 apply (blast intro: lt_Ord UN_upper)+
610 done
612 lemma lt_Union_iff: "\<forall>i\<in>A. Ord(i) ==> (j < \<Union>(A)) <-> (\<exists>i\<in>A. j<i)"
613 by (auto simp: lt_def Ord_Union)
615 lemma Union_upper_le:
616      "[| j \<in> J;  i\<le>j;  Ord(\<Union>(J)) |] ==> i \<le> \<Union>J"
617 apply (subst Union_eq_UN)
618 apply (rule UN_upper_le, auto)
619 done
621 lemma le_implies_UN_le_UN:
622     "[| !!x. x\<in>A ==> c(x) \<le> d(x) |] ==> (\<Union>x\<in>A. c(x)) \<le> (\<Union>x\<in>A. d(x))"
623 apply (rule UN_least_le)
624 apply (rule_tac [2] UN_upper_le)
625 apply (blast intro: Ord_UN le_Ord2)+
626 done
628 lemma Ord_equality: "Ord(i) ==> (\<Union>y\<in>i. succ(y)) = i"
629 by (blast intro: Ord_trans)
631 (*Holds for all transitive sets, not just ordinals*)
632 lemma Ord_Union_subset: "Ord(i) ==> \<Union>(i) \<subseteq> i"
633 by (blast intro: Ord_trans)
636 subsection{*Limit Ordinals -- General Properties*}
638 lemma Limit_Union_eq: "Limit(i) ==> \<Union>(i) = i"
639 apply (unfold Limit_def)
640 apply (fast intro!: ltI elim!: ltE elim: Ord_trans)
641 done
643 lemma Limit_is_Ord: "Limit(i) ==> Ord(i)"
644 apply (unfold Limit_def)
645 apply (erule conjunct1)
646 done
648 lemma Limit_has_0: "Limit(i) ==> 0 < i"
649 apply (unfold Limit_def)
650 apply (erule conjunct2 [THEN conjunct1])
651 done
653 lemma Limit_nonzero: "Limit(i) ==> i \<noteq> 0"
654 by (drule Limit_has_0, blast)
656 lemma Limit_has_succ: "[| Limit(i);  j<i |] ==> succ(j) < i"
657 by (unfold Limit_def, blast)
659 lemma Limit_succ_lt_iff [simp]: "Limit(i) ==> succ(j) < i <-> (j<i)"
660 apply (safe intro!: Limit_has_succ)
661 apply (frule lt_Ord)
662 apply (blast intro: lt_trans)
663 done
665 lemma zero_not_Limit [iff]: "~ Limit(0)"
668 lemma Limit_has_1: "Limit(i) ==> 1 < i"
669 by (blast intro: Limit_has_0 Limit_has_succ)
671 lemma increasing_LimitI: "[| 0<l; \<forall>x\<in>l. \<exists>y\<in>l. x<y |] ==> Limit(l)"
672 apply (unfold Limit_def, simp add: lt_Ord2, clarify)
673 apply (drule_tac i=y in ltD)
674 apply (blast intro: lt_trans1 [OF _ ltI] lt_Ord2)
675 done
677 lemma non_succ_LimitI:
678   assumes i: "0<i" and nsucc: "\<And>y. succ(y) \<noteq> i"
679   shows "Limit(i)"
680 proof -
681   have Oi: "Ord(i)" using i by (simp add: lt_def)
682   { fix y
683     assume yi: "y<i"
684     hence Osy: "Ord(succ(y))" by (simp add: lt_Ord Ord_succ)
685     have "~ i \<le> y" using yi by (blast dest: le_imp_not_lt)
686     hence "succ(y) < i" using nsucc [of y]
687       by (blast intro: Ord_linear_lt [OF Osy Oi]) }
688   thus ?thesis using i Oi by (auto simp add: Limit_def)
689 qed
691 lemma succ_LimitE [elim!]: "Limit(succ(i)) ==> P"
692 apply (rule lt_irrefl)
693 apply (rule Limit_has_succ, assumption)
694 apply (erule Limit_is_Ord [THEN Ord_succD, THEN le_refl])
695 done
697 lemma not_succ_Limit [simp]: "~ Limit(succ(i))"
698 by blast
700 lemma Limit_le_succD: "[| Limit(i);  i \<le> succ(j) |] ==> i \<le> j"
701 by (blast elim!: leE)
704 subsubsection{*Traditional 3-Way Case Analysis on Ordinals*}
706 lemma Ord_cases_disj: "Ord(i) ==> i=0 | (\<exists>j. Ord(j) & i=succ(j)) | Limit(i)"
707 by (blast intro!: non_succ_LimitI Ord_0_lt)
709 lemma Ord_cases:
710  assumes i: "Ord(i)"
711  obtains ("0") "i=0" | (succ) j where "Ord(j)" "i=succ(j)" | (limit) "Limit(i)"
712 by (insert Ord_cases_disj [OF i], auto)
714 lemma trans_induct3_raw:
715      "[| Ord(i);
716          P(0);
717          !!x. [| Ord(x);  P(x) |] ==> P(succ(x));
718          !!x. [| Limit(x);  \<forall>y\<in>x. P(y) |] ==> P(x)
719       |] ==> P(i)"
720 apply (erule trans_induct)
721 apply (erule Ord_cases, blast+)
722 done
724 lemmas trans_induct3 = trans_induct3_raw [rule_format, case_names 0 succ limit, consumes 1]
726 text{*A set of ordinals is either empty, contains its own union, or its
727 union is a limit ordinal.*}
729 lemma Union_le: "[| !!x. x\<in>I ==> x\<le>j; Ord(j) |] ==> \<Union>(I) \<le> j"
730   by (auto simp add: le_subset_iff Union_least)
732 lemma Ord_set_cases:
733   assumes I: "\<forall>i\<in>I. Ord(i)"
734   shows "I=0 \<or> \<Union>(I) \<in> I \<or> (\<Union>(I) \<notin> I \<and> Limit(\<Union>(I)))"
735 proof (cases "\<Union>(I)" rule: Ord_cases)
736   show "Ord(\<Union>I)" using I by (blast intro: Ord_Union)
737 next
738   assume "\<Union>I = 0" thus ?thesis by (simp, blast intro: subst_elem)
739 next
740   fix j
741   assume j: "Ord(j)" and UIj:"\<Union>(I) = succ(j)"
742   { assume "\<forall>i\<in>I. i\<le>j"
743     hence "\<Union>(I) \<le> j"
744       by (simp add: Union_le j)
745     hence False
746       by (simp add: UIj lt_not_refl) }
747   then obtain i where i: "i \<in> I" "succ(j) \<le> i" using I j
748     by (atomize, auto simp add: not_le_iff_lt)
749   have "\<Union>(I) \<le> succ(j)" using UIj j by auto
750   hence "i \<le> succ(j)" using i
751     by (simp add: le_subset_iff Union_subset_iff)
752   hence "succ(j) = i" using i
753     by (blast intro: le_anti_sym)
754   hence "succ(j) \<in> I" by (simp add: i)
755   thus ?thesis by (simp add: UIj)
756 next
757   assume "Limit(\<Union>I)" thus ?thesis by auto
758 qed
760 text{*If the union of a set of ordinals is a successor, then it is an element of that set.*}
761 lemma Ord_Union_eq_succD: "[|\<forall>x\<in>X. Ord(x);  \<Union>X = succ(j)|] ==> succ(j) \<in> X"
762   by (drule Ord_set_cases, auto)
764 lemma Limit_Union [rule_format]: "[| I \<noteq> 0;  \<forall>i\<in>I. Limit(i) |] ==> Limit(\<Union>I)"
765 apply (simp add: Limit_def lt_def)
766 apply (blast intro!: equalityI)
767 done
769 end