src/HOL/Library/Zorn.thy
author wenzelm
Sat May 27 17:42:02 2006 +0200 (2006-05-27)
changeset 19736 d8d0f8f51d69
parent 18585 5d379fe2eb74
child 21404 eb85850d3eb7
permissions -rw-r--r--
tuned;
     1 (*  Title       : HOL/Library/Zorn.thy
     2     ID          : $Id$
     3     Author      : Jacques D. Fleuriot
     4     Description : Zorn's Lemma -- see Larry Paulson's Zorn.thy in ZF
     5 *)
     6 
     7 header {* Zorn's Lemma *}
     8 
     9 theory Zorn
    10 imports Main
    11 begin
    12 
    13 text{*
    14   The lemma and section numbers refer to an unpublished article
    15   \cite{Abrial-Laffitte}.
    16 *}
    17 
    18 definition
    19   chain     ::  "'a set set => 'a set set set"
    20   "chain S  = {F. F \<subseteq> S & (\<forall>x \<in> F. \<forall>y \<in> F. x \<subseteq> y | y \<subseteq> x)}"
    21 
    22   super     ::  "['a set set,'a set set] => 'a set set set"
    23   "super S c = {d. d \<in> chain S & c \<subset> d}"
    24 
    25   maxchain  ::  "'a set set => 'a set set set"
    26   "maxchain S = {c. c \<in> chain S & super S c = {}}"
    27 
    28   succ      ::  "['a set set,'a set set] => 'a set set"
    29   "succ S c =
    30     (if c \<notin> chain S | c \<in> maxchain S
    31     then c else SOME c'. c' \<in> super S c)"
    32 
    33 consts
    34   TFin :: "'a set set => 'a set set set"
    35 inductive "TFin S"
    36   intros
    37     succI:        "x \<in> TFin S ==> succ S x \<in> TFin S"
    38     Pow_UnionI:   "Y \<in> Pow(TFin S) ==> Union(Y) \<in> TFin S"
    39   monos          Pow_mono
    40 
    41 
    42 subsection{*Mathematical Preamble*}
    43 
    44 lemma Union_lemma0:
    45     "(\<forall>x \<in> C. x \<subseteq> A | B \<subseteq> x) ==> Union(C) \<subseteq> A | B \<subseteq> Union(C)"
    46   by blast
    47 
    48 
    49 text{*This is theorem @{text increasingD2} of ZF/Zorn.thy*}
    50 
    51 lemma Abrial_axiom1: "x \<subseteq> succ S x"
    52   apply (unfold succ_def)
    53   apply (rule split_if [THEN iffD2])
    54   apply (auto simp add: super_def maxchain_def psubset_def)
    55   apply (rule contrapos_np, assumption)
    56   apply (rule someI2, blast+)
    57   done
    58 
    59 lemmas TFin_UnionI = TFin.Pow_UnionI [OF PowI]
    60 
    61 lemma TFin_induct:
    62           "[| n \<in> TFin S;
    63              !!x. [| x \<in> TFin S; P(x) |] ==> P(succ S x);
    64              !!Y. [| Y \<subseteq> TFin S; Ball Y P |] ==> P(Union Y) |]
    65           ==> P(n)"
    66   apply (induct set: TFin)
    67    apply blast+
    68   done
    69 
    70 lemma succ_trans: "x \<subseteq> y ==> x \<subseteq> succ S y"
    71   apply (erule subset_trans)
    72   apply (rule Abrial_axiom1)
    73   done
    74 
    75 text{*Lemma 1 of section 3.1*}
    76 lemma TFin_linear_lemma1:
    77      "[| n \<in> TFin S;  m \<in> TFin S;
    78          \<forall>x \<in> TFin S. x \<subseteq> m --> x = m | succ S x \<subseteq> m
    79       |] ==> n \<subseteq> m | succ S m \<subseteq> n"
    80   apply (erule TFin_induct)
    81    apply (erule_tac [2] Union_lemma0)
    82   apply (blast del: subsetI intro: succ_trans)
    83   done
    84 
    85 text{* Lemma 2 of section 3.2 *}
    86 lemma TFin_linear_lemma2:
    87      "m \<in> TFin S ==> \<forall>n \<in> TFin S. n \<subseteq> m --> n=m | succ S n \<subseteq> m"
    88   apply (erule TFin_induct)
    89    apply (rule impI [THEN ballI])
    90    txt{*case split using @{text TFin_linear_lemma1}*}
    91    apply (rule_tac n1 = n and m1 = x in TFin_linear_lemma1 [THEN disjE],
    92      assumption+)
    93     apply (drule_tac x = n in bspec, assumption)
    94     apply (blast del: subsetI intro: succ_trans, blast)
    95   txt{*second induction step*}
    96   apply (rule impI [THEN ballI])
    97   apply (rule Union_lemma0 [THEN disjE])
    98     apply (rule_tac [3] disjI2)
    99     prefer 2 apply blast
   100    apply (rule ballI)
   101    apply (rule_tac n1 = n and m1 = x in TFin_linear_lemma1 [THEN disjE],
   102      assumption+, auto)
   103   apply (blast intro!: Abrial_axiom1 [THEN subsetD])
   104   done
   105 
   106 text{*Re-ordering the premises of Lemma 2*}
   107 lemma TFin_subsetD:
   108      "[| n \<subseteq> m;  m \<in> TFin S;  n \<in> TFin S |] ==> n=m | succ S n \<subseteq> m"
   109   by (rule TFin_linear_lemma2 [rule_format])
   110 
   111 text{*Consequences from section 3.3 -- Property 3.2, the ordering is total*}
   112 lemma TFin_subset_linear: "[| m \<in> TFin S;  n \<in> TFin S|] ==> n \<subseteq> m | m \<subseteq> n"
   113   apply (rule disjE)
   114     apply (rule TFin_linear_lemma1 [OF _ _TFin_linear_lemma2])
   115       apply (assumption+, erule disjI2)
   116   apply (blast del: subsetI
   117     intro: subsetI Abrial_axiom1 [THEN subset_trans])
   118   done
   119 
   120 text{*Lemma 3 of section 3.3*}
   121 lemma eq_succ_upper: "[| n \<in> TFin S;  m \<in> TFin S;  m = succ S m |] ==> n \<subseteq> m"
   122   apply (erule TFin_induct)
   123    apply (drule TFin_subsetD)
   124      apply (assumption+, force, blast)
   125   done
   126 
   127 text{*Property 3.3 of section 3.3*}
   128 lemma equal_succ_Union: "m \<in> TFin S ==> (m = succ S m) = (m = Union(TFin S))"
   129   apply (rule iffI)
   130    apply (rule Union_upper [THEN equalityI])
   131     apply assumption
   132    apply (rule eq_succ_upper [THEN Union_least], assumption+)
   133   apply (erule ssubst)
   134   apply (rule Abrial_axiom1 [THEN equalityI])
   135   apply (blast del: subsetI intro: subsetI TFin_UnionI TFin.succI)
   136   done
   137 
   138 subsection{*Hausdorff's Theorem: Every Set Contains a Maximal Chain.*}
   139 
   140 text{*NB: We assume the partial ordering is @{text "\<subseteq>"},
   141  the subset relation!*}
   142 
   143 lemma empty_set_mem_chain: "({} :: 'a set set) \<in> chain S"
   144   by (unfold chain_def) auto
   145 
   146 lemma super_subset_chain: "super S c \<subseteq> chain S"
   147   by (unfold super_def) blast
   148 
   149 lemma maxchain_subset_chain: "maxchain S \<subseteq> chain S"
   150   by (unfold maxchain_def) blast
   151 
   152 lemma mem_super_Ex: "c \<in> chain S - maxchain S ==> ? d. d \<in> super S c"
   153   by (unfold super_def maxchain_def) auto
   154 
   155 lemma select_super:
   156      "c \<in> chain S - maxchain S ==> (\<some>c'. c': super S c): super S c"
   157   apply (erule mem_super_Ex [THEN exE])
   158   apply (rule someI2, auto)
   159   done
   160 
   161 lemma select_not_equals:
   162      "c \<in> chain S - maxchain S ==> (\<some>c'. c': super S c) \<noteq> c"
   163   apply (rule notI)
   164   apply (drule select_super)
   165   apply (simp add: super_def psubset_def)
   166   done
   167 
   168 lemma succI3: "c \<in> chain S - maxchain S ==> succ S c = (\<some>c'. c': super S c)"
   169   by (unfold succ_def) (blast intro!: if_not_P)
   170 
   171 lemma succ_not_equals: "c \<in> chain S - maxchain S ==> succ S c \<noteq> c"
   172   apply (frule succI3)
   173   apply (simp (no_asm_simp))
   174   apply (rule select_not_equals, assumption)
   175   done
   176 
   177 lemma TFin_chain_lemma4: "c \<in> TFin S ==> (c :: 'a set set): chain S"
   178   apply (erule TFin_induct)
   179    apply (simp add: succ_def select_super [THEN super_subset_chain[THEN subsetD]])
   180   apply (unfold chain_def)
   181   apply (rule CollectI, safe)
   182    apply (drule bspec, assumption)
   183    apply (rule_tac [2] m1 = Xa and n1 = X in TFin_subset_linear [THEN disjE],
   184      blast+)
   185   done
   186 
   187 theorem Hausdorff: "\<exists>c. (c :: 'a set set): maxchain S"
   188   apply (rule_tac x = "Union (TFin S)" in exI)
   189   apply (rule classical)
   190   apply (subgoal_tac "succ S (Union (TFin S)) = Union (TFin S) ")
   191    prefer 2
   192    apply (blast intro!: TFin_UnionI equal_succ_Union [THEN iffD2, symmetric])
   193   apply (cut_tac subset_refl [THEN TFin_UnionI, THEN TFin_chain_lemma4])
   194   apply (drule DiffI [THEN succ_not_equals], blast+)
   195   done
   196 
   197 
   198 subsection{*Zorn's Lemma: If All Chains Have Upper Bounds Then
   199                                There Is  a Maximal Element*}
   200 
   201 lemma chain_extend:
   202     "[| c \<in> chain S; z \<in> S;
   203         \<forall>x \<in> c. x \<subseteq> (z:: 'a set) |] ==> {z} Un c \<in> chain S"
   204   by (unfold chain_def) blast
   205 
   206 lemma chain_Union_upper: "[| c \<in> chain S; x \<in> c |] ==> x \<subseteq> Union(c)"
   207   by (unfold chain_def) auto
   208 
   209 lemma chain_ball_Union_upper: "c \<in> chain S ==> \<forall>x \<in> c. x \<subseteq> Union(c)"
   210   by (unfold chain_def) auto
   211 
   212 lemma maxchain_Zorn:
   213      "[| c \<in> maxchain S; u \<in> S; Union(c) \<subseteq> u |] ==> Union(c) = u"
   214   apply (rule ccontr)
   215   apply (simp add: maxchain_def)
   216   apply (erule conjE)
   217   apply (subgoal_tac "({u} Un c) \<in> super S c")
   218    apply simp
   219   apply (unfold super_def psubset_def)
   220   apply (blast intro: chain_extend dest: chain_Union_upper)
   221   done
   222 
   223 theorem Zorn_Lemma:
   224     "\<forall>c \<in> chain S. Union(c): S ==> \<exists>y \<in> S. \<forall>z \<in> S. y \<subseteq> z --> y = z"
   225   apply (cut_tac Hausdorff maxchain_subset_chain)
   226   apply (erule exE)
   227   apply (drule subsetD, assumption)
   228   apply (drule bspec, assumption)
   229   apply (rule_tac x = "Union(c)" in bexI)
   230    apply (rule ballI, rule impI)
   231    apply (blast dest!: maxchain_Zorn, assumption)
   232   done
   233 
   234 subsection{*Alternative version of Zorn's Lemma*}
   235 
   236 lemma Zorn_Lemma2:
   237   "\<forall>c \<in> chain S. \<exists>y \<in> S. \<forall>x \<in> c. x \<subseteq> y
   238     ==> \<exists>y \<in> S. \<forall>x \<in> S. (y :: 'a set) \<subseteq> x --> y = x"
   239   apply (cut_tac Hausdorff maxchain_subset_chain)
   240   apply (erule exE)
   241   apply (drule subsetD, assumption)
   242   apply (drule bspec, assumption, erule bexE)
   243   apply (rule_tac x = y in bexI)
   244    prefer 2 apply assumption
   245   apply clarify
   246   apply (rule ccontr)
   247   apply (frule_tac z = x in chain_extend)
   248     apply (assumption, blast)
   249   apply (unfold maxchain_def super_def psubset_def)
   250   apply (blast elim!: equalityCE)
   251   done
   252 
   253 text{*Various other lemmas*}
   254 
   255 lemma chainD: "[| c \<in> chain S; x \<in> c; y \<in> c |] ==> x \<subseteq> y | y \<subseteq> x"
   256   by (unfold chain_def) blast
   257 
   258 lemma chainD2: "!!(c :: 'a set set). c \<in> chain S ==> c \<subseteq> S"
   259   by (unfold chain_def) blast
   260 
   261 end