201 |
205 |
202 subsection{*Zorn's Lemma: If All Chains Have Upper Bounds Then |
206 subsection{*Zorn's Lemma: If All Chains Have Upper Bounds Then |
203 There Is a Maximal Element*} |
207 There Is a Maximal Element*} |
204 |
208 |
205 lemma chain_extend: |
209 lemma chain_extend: |
206 "[| c \<in> chain S; z \<in> S; |
210 "[| c \<in> chain S; z \<in> S; \<forall>x \<in> c. x \<subseteq> (z:: 'a set) |] ==> {z} Un c \<in> chain S" |
207 \<forall>x \<in> c. x \<subseteq> (z:: 'a set) |] ==> {z} Un c \<in> chain S" |
211 by (unfold chain_def chain_subset_def) blast |
208 by (unfold chain_def) blast |
|
209 |
212 |
210 lemma chain_Union_upper: "[| c \<in> chain S; x \<in> c |] ==> x \<subseteq> Union(c)" |
213 lemma chain_Union_upper: "[| c \<in> chain S; x \<in> c |] ==> x \<subseteq> Union(c)" |
211 by (unfold chain_def) auto |
214 by auto |
212 |
215 |
213 lemma chain_ball_Union_upper: "c \<in> chain S ==> \<forall>x \<in> c. x \<subseteq> Union(c)" |
216 lemma chain_ball_Union_upper: "c \<in> chain S ==> \<forall>x \<in> c. x \<subseteq> Union(c)" |
214 by (unfold chain_def) auto |
217 by auto |
215 |
218 |
216 lemma maxchain_Zorn: |
219 lemma maxchain_Zorn: |
217 "[| c \<in> maxchain S; u \<in> S; Union(c) \<subseteq> u |] ==> Union(c) = u" |
220 "[| c \<in> maxchain S; u \<in> S; Union(c) \<subseteq> u |] ==> Union(c) = u" |
218 apply (rule ccontr) |
221 apply (rule ccontr) |
219 apply (simp add: maxchain_def) |
222 apply (simp add: maxchain_def) |
220 apply (erule conjE) |
223 apply (erule conjE) |
221 apply (subgoal_tac "({u} Un c) \<in> super S c") |
224 apply (subgoal_tac "({u} Un c) \<in> super S c") |
222 apply simp |
225 apply simp |
223 apply (unfold super_def psubset_def) |
226 apply (unfold super_def psubset_def) |
224 apply (blast intro: chain_extend dest: chain_Union_upper) |
227 apply (blast intro: chain_extend dest: chain_Union_upper) |
225 done |
228 done |
226 |
229 |
227 theorem Zorn_Lemma: |
230 theorem Zorn_Lemma: |
228 "\<forall>c \<in> chain S. Union(c): S ==> \<exists>y \<in> S. \<forall>z \<in> S. y \<subseteq> z --> y = z" |
231 "\<forall>c \<in> chain S. Union(c): S ==> \<exists>y \<in> S. \<forall>z \<in> S. y \<subseteq> z --> y = z" |
229 apply (cut_tac Hausdorff maxchain_subset_chain) |
232 apply (cut_tac Hausdorff maxchain_subset_chain) |
230 apply (erule exE) |
233 apply (erule exE) |
231 apply (drule subsetD, assumption) |
234 apply (drule subsetD, assumption) |
232 apply (drule bspec, assumption) |
235 apply (drule bspec, assumption) |
233 apply (rule_tac x = "Union(c)" in bexI) |
236 apply (rule_tac x = "Union(c)" in bexI) |
234 apply (rule ballI, rule impI) |
237 apply (rule ballI, rule impI) |
235 apply (blast dest!: maxchain_Zorn, assumption) |
238 apply (blast dest!: maxchain_Zorn, assumption) |
236 done |
239 done |
237 |
240 |
238 subsection{*Alternative version of Zorn's Lemma*} |
241 subsection{*Alternative version of Zorn's Lemma*} |
239 |
242 |
240 lemma Zorn_Lemma2: |
243 lemma Zorn_Lemma2: |
241 "\<forall>c \<in> chain S. \<exists>y \<in> S. \<forall>x \<in> c. x \<subseteq> y |
244 "\<forall>c \<in> chain S. \<exists>y \<in> S. \<forall>x \<in> c. x \<subseteq> y |
242 ==> \<exists>y \<in> S. \<forall>x \<in> S. (y :: 'a set) \<subseteq> x --> y = x" |
245 ==> \<exists>y \<in> S. \<forall>x \<in> S. (y :: 'a set) \<subseteq> x --> y = x" |
243 apply (cut_tac Hausdorff maxchain_subset_chain) |
246 apply (cut_tac Hausdorff maxchain_subset_chain) |
244 apply (erule exE) |
247 apply (erule exE) |
245 apply (drule subsetD, assumption) |
248 apply (drule subsetD, assumption) |
246 apply (drule bspec, assumption, erule bexE) |
249 apply (drule bspec, assumption, erule bexE) |
247 apply (rule_tac x = y in bexI) |
250 apply (rule_tac x = y in bexI) |
248 prefer 2 apply assumption |
251 prefer 2 apply assumption |
249 apply clarify |
252 apply clarify |
250 apply (rule ccontr) |
253 apply (rule ccontr) |
251 apply (frule_tac z = x in chain_extend) |
254 apply (frule_tac z = x in chain_extend) |
252 apply (assumption, blast) |
255 apply (assumption, blast) |
253 apply (unfold maxchain_def super_def psubset_def) |
256 apply (unfold maxchain_def super_def psubset_def) |
254 apply (blast elim!: equalityCE) |
257 apply (blast elim!: equalityCE) |
255 done |
258 done |
256 |
259 |
257 text{*Various other lemmas*} |
260 text{*Various other lemmas*} |
258 |
261 |
259 lemma chainD: "[| c \<in> chain S; x \<in> c; y \<in> c |] ==> x \<subseteq> y | y \<subseteq> x" |
262 lemma chainD: "[| c \<in> chain S; x \<in> c; y \<in> c |] ==> x \<subseteq> y | y \<subseteq> x" |
260 by (unfold chain_def) blast |
263 by (unfold chain_def chain_subset_def) blast |
261 |
264 |
262 lemma chainD2: "!!(c :: 'a set set). c \<in> chain S ==> c \<subseteq> S" |
265 lemma chainD2: "!!(c :: 'a set set). c \<in> chain S ==> c \<subseteq> S" |
263 by (unfold chain_def) blast |
266 by (unfold chain_def) blast |
264 |
267 |
265 |
|
266 (* FIXME into Relation.thy *) |
|
267 |
|
268 lemma mono_Field: "r \<subseteq> s \<Longrightarrow> Field r \<subseteq> Field s" |
|
269 by(auto simp:Field_def Domain_def Range_def) |
|
270 |
|
271 lemma Field_empty[simp]: "Field {} = {}" |
|
272 by(auto simp:Field_def) |
|
273 |
|
274 lemma Field_insert[simp]: "Field (insert (a,b) r) = {a,b} \<union> Field r" |
|
275 by(auto simp:Field_def) |
|
276 |
|
277 lemma Field_Un[simp]: "Field (r \<union> s) = Field r \<union> Field s" |
|
278 by(auto simp:Field_def) |
|
279 |
|
280 lemma Field_Union[simp]: "Field (\<Union>R) = \<Union>(Field ` R)" |
|
281 by(auto simp:Field_def) |
|
282 |
|
283 lemma Domain_converse[simp]: "Domain(r^-1) = Range r" |
|
284 by blast |
|
285 |
|
286 lemma Range_converse[simp]: "Range(r^-1) = Domain r" |
|
287 by blast |
|
288 |
|
289 lemma Field_converse[simp]: "Field(r^-1) = Field r" |
|
290 by(auto simp:Field_def) |
|
291 |
|
292 lemma reflexive_reflcl[simp]: "reflexive(r^=)" |
|
293 by(simp add:refl_def) |
|
294 |
|
295 lemma antisym_reflcl[simp]: "antisym(r^=) = antisym r" |
|
296 by(simp add:antisym_def) |
|
297 |
|
298 lemma trans_reflclI[simp]: "trans r \<Longrightarrow> trans(r^=)" |
|
299 unfolding trans_def by blast |
|
300 |
|
301 (*********************************************************) |
|
302 |
|
303 (* Define globally? In Set.thy? |
|
304 Use in def of chain at the beginning *) |
|
305 definition "subset_chain C \<equiv> \<forall>A\<in>C.\<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A" |
|
306 |
268 |
307 (* Define globally? In Relation.thy? *) |
269 (* Define globally? In Relation.thy? *) |
308 definition Chain :: "('a*'a)set \<Rightarrow> 'a set set" where |
270 definition Chain :: "('a*'a)set \<Rightarrow> 'a set set" where |
309 "Chain r \<equiv> {A. \<forall>a\<in>A.\<forall>b\<in>A. (a,b) : r \<or> (b,a) \<in> r}" |
271 "Chain r \<equiv> {A. \<forall>a\<in>A.\<forall>b\<in>A. (a,b) : r \<or> (b,a) \<in> r}" |
310 |
272 |
311 lemma mono_Chain: "r \<subseteq> s \<Longrightarrow> Chain r \<subseteq> Chain s" |
273 lemma mono_Chain: "r \<subseteq> s \<Longrightarrow> Chain r \<subseteq> Chain s" |
312 unfolding Chain_def by blast |
274 unfolding Chain_def by blast |
313 |
|
314 (* Are the following definitions the "right" ones? |
|
315 |
|
316 Key point: should the set appear as an explicit argument, |
|
317 (as currently in "refl A r") or should it remain implicitly the Field |
|
318 (as in Refl below)? I use refl/Refl merely to illusrate the point. |
|
319 |
|
320 The notation "refl A r" is closer to the usual (A,<=) in the literature |
|
321 whereas "Refl r" is shorter and avoids naming the set. |
|
322 Note that "refl A r \<Longrightarrow> A = Field r & Refl r" and "Refl r \<Longrightarrow> refl (Field r) r" |
|
323 This makes the A look redundant. |
|
324 |
|
325 A slight advantage of having the A around is that one can write "a:A" |
|
326 rather than "a:Field r". A disavantage is the multiple occurrences of |
|
327 "refl (Field r) r" (etc) in the proof of the well-ordering thm. |
|
328 |
|
329 I propose to move the definitions into Main, either as they are or |
|
330 with an additional A argument. |
|
331 |
|
332 Naming: The capital letters were chosen to distinguish them from |
|
333 versions on the whole type we have (eg reflexive) or may want to have |
|
334 (eg preorder). In case of an additional A argument one could append |
|
335 "_on" to distinguish the relativized versions. |
|
336 *) |
|
337 |
|
338 definition "Refl r \<equiv> \<forall>x \<in> Field r. (x,x) \<in> r" |
|
339 definition "Preorder r \<equiv> Refl r \<and> trans r" |
|
340 definition "Partial_order r \<equiv> Preorder r \<and> antisym r" |
|
341 definition "Total r \<equiv> \<forall>x\<in>Field r.\<forall>y\<in>Field r. x\<noteq>y \<longrightarrow> (x,y)\<in>r \<or> (y,x)\<in>r" |
|
342 definition "Linear_order r \<equiv> Partial_order r \<and> Total r" |
|
343 definition "Well_order r \<equiv> Linear_order r \<and> wf(r - Id)" |
|
344 |
|
345 lemmas Order_defs = |
|
346 Preorder_def Partial_order_def Linear_order_def Well_order_def |
|
347 |
|
348 lemma Refl_empty[simp]: "Refl {}" |
|
349 by(simp add:Refl_def) |
|
350 lemma Preorder_empty[simp]: "Preorder {}" |
|
351 by(simp add:Preorder_def trans_def) |
|
352 lemma Partial_order_empty[simp]: "Partial_order {}" |
|
353 by(simp add:Partial_order_def) |
|
354 lemma Total_empty[simp]: "Total {}" |
|
355 by(simp add:Total_def) |
|
356 lemma Linear_order_empty[simp]: "Linear_order {}" |
|
357 by(simp add:Linear_order_def) |
|
358 lemma Well_order_empty[simp]: "Well_order {}" |
|
359 by(simp add:Well_order_def) |
|
360 |
|
361 lemma Refl_converse[simp]: "Refl(r^-1) = Refl r" |
|
362 by(simp add:Refl_def) |
|
363 |
|
364 lemma Preorder_converse[simp]: "Preorder (r^-1) = Preorder r" |
|
365 by (simp add:Preorder_def) |
|
366 |
|
367 lemma Partial_order_converse[simp]: |
|
368 "Partial_order (r^-1) = Partial_order r" |
|
369 by (simp add: Partial_order_def) |
|
370 |
|
371 lemma subset_Image_Image_iff: |
|
372 "\<lbrakk> Preorder r; A \<subseteq> Field r; B \<subseteq> Field r\<rbrakk> \<Longrightarrow> |
|
373 r `` A \<subseteq> r `` B \<longleftrightarrow> (\<forall>a\<in>A.\<exists>b\<in>B. (b,a):r)" |
|
374 apply(auto simp add:subset_def Preorder_def Refl_def Image_def) |
|
375 apply metis |
|
376 by(metis trans_def) |
|
377 |
|
378 lemma subset_Image1_Image1_iff: |
|
379 "\<lbrakk> Preorder r; a : Field r; b : Field r\<rbrakk> \<Longrightarrow> r `` {a} \<subseteq> r `` {b} \<longleftrightarrow> (b,a):r" |
|
380 by(simp add:subset_Image_Image_iff) |
|
381 |
|
382 lemma Refl_antisym_eq_Image1_Image1_iff: |
|
383 "\<lbrakk>Refl r; antisym r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b" |
|
384 by(simp add:Preorder_def expand_set_eq Partial_order_def antisym_def Refl_def) |
|
385 metis |
|
386 |
|
387 lemma Partial_order_eq_Image1_Image1_iff: |
|
388 "\<lbrakk>Partial_order r; a:Field r; b:Field r\<rbrakk> \<Longrightarrow> r `` {a} = r `` {b} \<longleftrightarrow> a=b" |
|
389 by(auto simp:Preorder_def Partial_order_def Refl_antisym_eq_Image1_Image1_iff) |
|
390 |
275 |
391 text{* Zorn's lemma for partial orders: *} |
276 text{* Zorn's lemma for partial orders: *} |
392 |
277 |
393 lemma Zorns_po_lemma: |
278 lemma Zorns_po_lemma: |
394 assumes po: "Partial_order r" and u: "\<forall>C\<in>Chain r. \<exists>u\<in>Field r. \<forall>a\<in>C. (a,u):r" |
279 assumes po: "Partial_order r" and u: "\<forall>C\<in>Chain r. \<exists>u\<in>Field r. \<forall>a\<in>C. (a,u):r" |
455 |
340 |
456 lemma Chain_init_seg_of_Union: |
341 lemma Chain_init_seg_of_Union: |
457 "R \<in> Chain init_seg_of \<Longrightarrow> r\<in>R \<Longrightarrow> r initial_segment_of \<Union>R" |
342 "R \<in> Chain init_seg_of \<Longrightarrow> r\<in>R \<Longrightarrow> r initial_segment_of \<Union>R" |
458 by(auto simp add:init_seg_of_def Chain_def Ball_def) blast |
343 by(auto simp add:init_seg_of_def Chain_def Ball_def) blast |
459 |
344 |
460 lemma subset_chain_trans_Union: |
345 lemma chain_subset_trans_Union: |
461 "subset_chain R \<Longrightarrow> \<forall>r\<in>R. trans r \<Longrightarrow> trans(\<Union>R)" |
346 "chain\<^bsub>\<subseteq>\<^esub> R \<Longrightarrow> \<forall>r\<in>R. trans r \<Longrightarrow> trans(\<Union>R)" |
462 apply(auto simp add:subset_chain_def) |
347 apply(auto simp add:chain_subset_def) |
463 apply(simp (no_asm_use) add:trans_def) |
348 apply(simp (no_asm_use) add:trans_def) |
464 apply (metis subsetD) |
349 apply (metis subsetD) |
465 done |
350 done |
466 |
351 |
467 lemma subset_chain_antisym_Union: |
352 lemma chain_subset_antisym_Union: |
468 "subset_chain R \<Longrightarrow> \<forall>r\<in>R. antisym r \<Longrightarrow> antisym(\<Union>R)" |
353 "chain\<^bsub>\<subseteq>\<^esub> R \<Longrightarrow> \<forall>r\<in>R. antisym r \<Longrightarrow> antisym(\<Union>R)" |
469 apply(auto simp add:subset_chain_def antisym_def) |
354 apply(auto simp add:chain_subset_def antisym_def) |
470 apply (metis subsetD) |
355 apply (metis subsetD) |
471 done |
356 done |
472 |
357 |
473 lemma subset_chain_Total_Union: |
358 lemma chain_subset_Total_Union: |
474 assumes "subset_chain R" "\<forall>r\<in>R. Total r" |
359 assumes "chain\<^bsub>\<subseteq>\<^esub> R" "\<forall>r\<in>R. Total r" |
475 shows "Total (\<Union>R)" |
360 shows "Total (\<Union>R)" |
476 proof (simp add: Total_def Ball_def, auto del:disjCI) |
361 proof (simp add: Total_def Ball_def, auto del:disjCI) |
477 fix r s a b assume A: "r:R" "s:R" "a:Field r" "b:Field s" "a\<noteq>b" |
362 fix r s a b assume A: "r:R" "s:R" "a:Field r" "b:Field s" "a\<noteq>b" |
478 from `subset_chain R` `r:R` `s:R` have "r\<subseteq>s \<or> s\<subseteq>r" |
363 from `chain\<^bsub>\<subseteq>\<^esub> R` `r:R` `s:R` have "r\<subseteq>s \<or> s\<subseteq>r" |
479 by(simp add:subset_chain_def) |
364 by(simp add:chain_subset_def) |
480 thus "(\<exists>r\<in>R. (a,b) \<in> r) \<or> (\<exists>r\<in>R. (b,a) \<in> r)" |
365 thus "(\<exists>r\<in>R. (a,b) \<in> r) \<or> (\<exists>r\<in>R. (b,a) \<in> r)" |
481 proof |
366 proof |
482 assume "r\<subseteq>s" hence "(a,b):s \<or> (b,a):s" using assms(2) A |
367 assume "r\<subseteq>s" hence "(a,b):s \<or> (b,a):s" using assms(2) A |
483 by(simp add:Total_def)(metis mono_Field subsetD) |
368 by(simp add:Total_def)(metis mono_Field subsetD) |
484 thus ?thesis using `s:R` by blast |
369 thus ?thesis using `s:R` by blast |
515 apply(auto simp:Chain_def init_seg_of_def) |
400 apply(auto simp:Chain_def init_seg_of_def) |
516 apply (metis subsetD) |
401 apply (metis subsetD) |
517 apply (metis subsetD) |
402 apply (metis subsetD) |
518 done |
403 done |
519 |
404 |
520 theorem well_ordering: "\<exists>r::('a*'a)set. Well_order r" |
405 theorem well_ordering: "\<exists>r::('a*'a)set. Well_order r \<and> Field r = UNIV" |
521 proof- |
406 proof- |
522 -- {*The initial segment relation on well-orders: *} |
407 -- {*The initial segment relation on well-orders: *} |
523 let ?WO = "{r::('a*'a)set. Well_order r}" |
408 let ?WO = "{r::('a*'a)set. Well_order r}" |
524 def I \<equiv> "init_seg_of \<inter> ?WO \<times> ?WO" |
409 def I \<equiv> "init_seg_of \<inter> ?WO \<times> ?WO" |
525 have I_init: "I \<subseteq> init_seg_of" by(auto simp:I_def) |
410 have I_init: "I \<subseteq> init_seg_of" by(auto simp:I_def) |
526 hence subch: "!!R. R : Chain I \<Longrightarrow> subset_chain R" |
411 hence subch: "!!R. R : Chain I \<Longrightarrow> chain\<^bsub>\<subseteq>\<^esub> R" |
527 by(auto simp:init_seg_of_def subset_chain_def Chain_def) |
412 by(auto simp:init_seg_of_def chain_subset_def Chain_def) |
528 have Chain_wo: "!!R r. R \<in> Chain I \<Longrightarrow> r \<in> R \<Longrightarrow> Well_order r" |
413 have Chain_wo: "!!R r. R \<in> Chain I \<Longrightarrow> r \<in> R \<Longrightarrow> Well_order r" |
529 by(simp add:Chain_def I_def) blast |
414 by(simp add:Chain_def I_def) blast |
530 have FI: "Field I = ?WO" by(auto simp add:I_def init_seg_of_def Field_def) |
415 have FI: "Field I = ?WO" by(auto simp add:I_def init_seg_of_def Field_def) |
531 hence 0: "Partial_order I" |
416 hence 0: "Partial_order I" |
532 by(auto simp add: Partial_order_def Preorder_def antisym_def antisym_init_seg_of Refl_def trans_def I_def)(metis trans_init_seg_of) |
417 by(auto simp add: Partial_order_def Preorder_def antisym_def antisym_init_seg_of Refl_def trans_def I_def)(metis trans_init_seg_of) |
533 -- {*I-chains have upper bounds in ?WO wrt I: their Union*} |
418 -- {*I-chains have upper bounds in ?WO wrt I: their Union*} |
534 { fix R assume "R \<in> Chain I" |
419 { fix R assume "R \<in> Chain I" |
535 hence Ris: "R \<in> Chain init_seg_of" using mono_Chain[OF I_init] by blast |
420 hence Ris: "R \<in> Chain init_seg_of" using mono_Chain[OF I_init] by blast |
536 have subch: "subset_chain R" using `R : Chain I` I_init |
421 have subch: "chain\<^bsub>\<subseteq>\<^esub> R" using `R : Chain I` I_init |
537 by(auto simp:init_seg_of_def subset_chain_def Chain_def) |
422 by(auto simp:init_seg_of_def chain_subset_def Chain_def) |
538 have "\<forall>r\<in>R. Refl r" "\<forall>r\<in>R. trans r" "\<forall>r\<in>R. antisym r" "\<forall>r\<in>R. Total r" |
423 have "\<forall>r\<in>R. Refl r" "\<forall>r\<in>R. trans r" "\<forall>r\<in>R. antisym r" "\<forall>r\<in>R. Total r" |
539 "\<forall>r\<in>R. wf(r-Id)" |
424 "\<forall>r\<in>R. wf(r-Id)" |
540 using Chain_wo[OF `R \<in> Chain I`] by(simp_all add:Order_defs) |
425 using Chain_wo[OF `R \<in> Chain I`] by(simp_all add:Order_defs) |
541 have "Refl (\<Union>R)" using `\<forall>r\<in>R. Refl r` by(auto simp:Refl_def) |
426 have "Refl (\<Union>R)" using `\<forall>r\<in>R. Refl r` by(auto simp:Refl_def) |
542 moreover have "trans (\<Union>R)" |
427 moreover have "trans (\<Union>R)" |
543 by(rule subset_chain_trans_Union[OF subch `\<forall>r\<in>R. trans r`]) |
428 by(rule chain_subset_trans_Union[OF subch `\<forall>r\<in>R. trans r`]) |
544 moreover have "antisym(\<Union>R)" |
429 moreover have "antisym(\<Union>R)" |
545 by(rule subset_chain_antisym_Union[OF subch `\<forall>r\<in>R. antisym r`]) |
430 by(rule chain_subset_antisym_Union[OF subch `\<forall>r\<in>R. antisym r`]) |
546 moreover have "Total (\<Union>R)" |
431 moreover have "Total (\<Union>R)" |
547 by(rule subset_chain_Total_Union[OF subch `\<forall>r\<in>R. Total r`]) |
432 by(rule chain_subset_Total_Union[OF subch `\<forall>r\<in>R. Total r`]) |
548 moreover have "wf((\<Union>R)-Id)" |
433 moreover have "wf((\<Union>R)-Id)" |
549 proof- |
434 proof- |
550 have "(\<Union>R)-Id = \<Union>{r-Id|r. r \<in> R}" by blast |
435 have "(\<Union>R)-Id = \<Union>{r-Id|r. r \<in> R}" by blast |
551 with `\<forall>r\<in>R. wf(r-Id)` wf_Union_wf_init_segs[OF Chain_inits_DiffI[OF Ris]] |
436 with `\<forall>r\<in>R. wf(r-Id)` wf_Union_wf_init_segs[OF Chain_inits_DiffI[OF Ris]] |
552 show ?thesis by (simp (no_asm_simp)) blast |
437 show ?thesis by (simp (no_asm_simp)) blast |