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