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