| author | paulson <lp15@cam.ac.uk> | 
| Thu, 29 Dec 2022 22:14:12 +0000 | |
| changeset 76822 | 25c0d4c0e110 | 
| parent 74749 | 329cb9e6b184 | 
| child 80932 | 261cd8722677 | 
| permissions | -rw-r--r-- | 
| 63572 | 1 | (* Title: HOL/Zorn.thy | 
| 2 | Author: Jacques D. Fleuriot | |
| 3 | Author: Tobias Nipkow, TUM | |
| 4 | Author: Christian Sternagel, JAIST | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30663diff
changeset | 5 | |
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
30663diff
changeset | 6 | Zorn's Lemma (ported from Larry Paulson's Zorn.thy in ZF). | 
| 14706 | 7 | *) | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 8 | |
| 74749 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 9 | section \<open>Zorn's Lemma and the Well-ordering Theorem\<close> | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 10 | |
| 15131 | 11 | theory Zorn | 
| 63572 | 12 | imports Order_Relation Hilbert_Choice | 
| 15131 | 13 | begin | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 14 | |
| 60758 | 15 | subsection \<open>Zorn's Lemma for the Subset Relation\<close> | 
| 52181 | 16 | |
| 60758 | 17 | subsubsection \<open>Results that do not require an order\<close> | 
| 52181 | 18 | |
| 61799 | 19 | text \<open>Let \<open>P\<close> be a binary predicate on the set \<open>A\<close>.\<close> | 
| 52181 | 20 | locale pred_on = | 
| 21 | fixes A :: "'a set" | |
| 63572 | 22 | and P :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubset>" 50) | 
| 52181 | 23 | begin | 
| 24 | ||
| 63572 | 25 | abbreviation Peq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50) | 
| 26 | where "x \<sqsubseteq> y \<equiv> P\<^sup>=\<^sup>= x y" | |
| 27 | ||
| 28 | text \<open>A chain is a totally ordered subset of \<open>A\<close>.\<close> | |
| 29 | definition chain :: "'a set \<Rightarrow> bool" | |
| 30 | where "chain C \<longleftrightarrow> C \<subseteq> A \<and> (\<forall>x\<in>C. \<forall>y\<in>C. x \<sqsubseteq> y \<or> y \<sqsubseteq> x)" | |
| 52181 | 31 | |
| 63572 | 32 | text \<open> | 
| 33 | We call a chain that is a proper superset of some set \<open>X\<close>, | |
| 34 | but not necessarily a chain itself, a superchain of \<open>X\<close>. | |
| 35 | \<close> | |
| 36 | abbreviation superchain :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" (infix "<c" 50) | |
| 37 | where "X <c C \<equiv> chain C \<and> X \<subset> C" | |
| 52181 | 38 | |
| 60758 | 39 | text \<open>A maximal chain is a chain that does not have a superchain.\<close> | 
| 63572 | 40 | definition maxchain :: "'a set \<Rightarrow> bool" | 
| 41 | where "maxchain C \<longleftrightarrow> chain C \<and> (\<nexists>S. C <c S)" | |
| 52181 | 42 | |
| 63572 | 43 | text \<open> | 
| 44 | We define the successor of a set to be an arbitrary | |
| 45 | superchain, if such exists, or the set itself, otherwise. | |
| 46 | \<close> | |
| 47 | definition suc :: "'a set \<Rightarrow> 'a set" | |
| 48 | where "suc C = (if \<not> chain C \<or> maxchain C then C else (SOME D. C <c D))" | |
| 52181 | 49 | |
| 63572 | 50 | lemma chainI [Pure.intro?]: "C \<subseteq> A \<Longrightarrow> (\<And>x y. x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x) \<Longrightarrow> chain C" | 
| 52181 | 51 | unfolding chain_def by blast | 
| 52 | ||
| 63572 | 53 | lemma chain_total: "chain C \<Longrightarrow> x \<in> C \<Longrightarrow> y \<in> C \<Longrightarrow> x \<sqsubseteq> y \<or> y \<sqsubseteq> x" | 
| 52181 | 54 | by (simp add: chain_def) | 
| 55 | ||
| 56 | lemma not_chain_suc [simp]: "\<not> chain X \<Longrightarrow> suc X = X" | |
| 57 | by (simp add: suc_def) | |
| 58 | ||
| 59 | lemma maxchain_suc [simp]: "maxchain X \<Longrightarrow> suc X = X" | |
| 60 | by (simp add: suc_def) | |
| 61 | ||
| 62 | lemma suc_subset: "X \<subseteq> suc X" | |
| 63 | by (auto simp: suc_def maxchain_def intro: someI2) | |
| 64 | ||
| 65 | lemma chain_empty [simp]: "chain {}"
 | |
| 66 | by (auto simp: chain_def) | |
| 67 | ||
| 63572 | 68 | lemma not_maxchain_Some: "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> C <c (SOME D. C <c D)" | 
| 52181 | 69 | by (rule someI_ex) (auto simp: maxchain_def) | 
| 70 | ||
| 63572 | 71 | lemma suc_not_equals: "chain C \<Longrightarrow> \<not> maxchain C \<Longrightarrow> suc C \<noteq> C" | 
| 55811 | 72 | using not_maxchain_Some by (auto simp: suc_def) | 
| 52181 | 73 | |
| 74 | lemma subset_suc: | |
| 63572 | 75 | assumes "X \<subseteq> Y" | 
| 76 | shows "X \<subseteq> suc Y" | |
| 52181 | 77 | using assms by (rule subset_trans) (rule suc_subset) | 
| 78 | ||
| 63572 | 79 | text \<open> | 
| 69593 | 80 | We build a set \<^term>\<open>\<C>\<close> that is closed under applications | 
| 81 | of \<^term>\<open>suc\<close> and contains the union of all its subsets. | |
| 63572 | 82 | \<close> | 
| 83 | inductive_set suc_Union_closed ("\<C>")
 | |
| 84 | where | |
| 85 | suc: "X \<in> \<C> \<Longrightarrow> suc X \<in> \<C>" | |
| 86 | | Union [unfolded Pow_iff]: "X \<in> Pow \<C> \<Longrightarrow> \<Union>X \<in> \<C>" | |
| 52181 | 87 | |
| 63572 | 88 | text \<open> | 
| 89 | Since the empty set as well as the set itself is a subset of | |
| 69593 | 90 |   every set, \<^term>\<open>\<C>\<close> contains at least \<^term>\<open>{} \<in> \<C>\<close> and
 | 
| 91 | \<^term>\<open>\<Union>\<C> \<in> \<C>\<close>. | |
| 63572 | 92 | \<close> | 
| 93 | lemma suc_Union_closed_empty: "{} \<in> \<C>"
 | |
| 94 | and suc_Union_closed_Union: "\<Union>\<C> \<in> \<C>" | |
| 95 |   using Union [of "{}"] and Union [of "\<C>"] by simp_all
 | |
| 96 | ||
| 69593 | 97 | text \<open>Thus closure under \<^term>\<open>suc\<close> will hit a maximal chain | 
| 63572 | 98 | eventually, as is shown below.\<close> | 
| 26272 | 99 | |
| 63572 | 100 | lemma suc_Union_closed_induct [consumes 1, case_names suc Union, induct pred: suc_Union_closed]: | 
| 52181 | 101 | assumes "X \<in> \<C>" | 
| 63572 | 102 | and "\<And>X. X \<in> \<C> \<Longrightarrow> Q X \<Longrightarrow> Q (suc X)" | 
| 103 | and "\<And>X. X \<subseteq> \<C> \<Longrightarrow> \<forall>x\<in>X. Q x \<Longrightarrow> Q (\<Union>X)" | |
| 104 | shows "Q X" | |
| 105 | using assms by induct blast+ | |
| 106 | ||
| 107 | lemma suc_Union_closed_cases [consumes 1, case_names suc Union, cases pred: suc_Union_closed]: | |
| 108 | assumes "X \<in> \<C>" | |
| 109 | and "\<And>Y. X = suc Y \<Longrightarrow> Y \<in> \<C> \<Longrightarrow> Q" | |
| 110 | and "\<And>Y. X = \<Union>Y \<Longrightarrow> Y \<subseteq> \<C> \<Longrightarrow> Q" | |
| 52181 | 111 | shows "Q" | 
| 63572 | 112 | using assms by cases simp_all | 
| 52181 | 113 | |
| 69593 | 114 | text \<open>On chains, \<^term>\<open>suc\<close> yields a chain.\<close> | 
| 52181 | 115 | lemma chain_suc: | 
| 63572 | 116 | assumes "chain X" | 
| 117 | shows "chain (suc X)" | |
| 52181 | 118 | using assms | 
| 63572 | 119 | by (cases "\<not> chain X \<or> maxchain X") (force simp: suc_def dest: not_maxchain_Some)+ | 
| 52181 | 120 | |
| 121 | lemma chain_sucD: | |
| 63572 | 122 | assumes "chain X" | 
| 123 | shows "suc X \<subseteq> A \<and> chain (suc X)" | |
| 52181 | 124 | proof - | 
| 63572 | 125 | from \<open>chain X\<close> have *: "chain (suc X)" | 
| 126 | by (rule chain_suc) | |
| 127 | then have "suc X \<subseteq> A" | |
| 128 | unfolding chain_def by blast | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
52821diff
changeset | 129 | with * show ?thesis by blast | 
| 52181 | 130 | qed | 
| 131 | ||
| 132 | lemma suc_Union_closed_total': | |
| 133 | assumes "X \<in> \<C>" and "Y \<in> \<C>" | |
| 134 | and *: "\<And>Z. Z \<in> \<C> \<Longrightarrow> Z \<subseteq> Y \<Longrightarrow> Z = Y \<or> suc Z \<subseteq> Y" | |
| 135 | shows "X \<subseteq> Y \<or> suc Y \<subseteq> X" | |
| 60758 | 136 | using \<open>X \<in> \<C>\<close> | 
| 63572 | 137 | proof induct | 
| 52181 | 138 | case (suc X) | 
| 139 | with * show ?case by (blast del: subsetI intro: subset_suc) | |
| 63572 | 140 | next | 
| 141 | case Union | |
| 142 | then show ?case by blast | |
| 143 | qed | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 144 | |
| 52181 | 145 | lemma suc_Union_closed_subsetD: | 
| 146 | assumes "Y \<subseteq> X" and "X \<in> \<C>" and "Y \<in> \<C>" | |
| 147 | shows "X = Y \<or> suc Y \<subseteq> X" | |
| 63572 | 148 | using assms(2,3,1) | 
| 52181 | 149 | proof (induct arbitrary: Y) | 
| 150 | case (suc X) | |
| 63572 | 151 | note * = \<open>\<And>Y. Y \<in> \<C> \<Longrightarrow> Y \<subseteq> X \<Longrightarrow> X = Y \<or> suc Y \<subseteq> X\<close> | 
| 60758 | 152 | with suc_Union_closed_total' [OF \<open>Y \<in> \<C>\<close> \<open>X \<in> \<C>\<close>] | 
| 63572 | 153 | have "Y \<subseteq> X \<or> suc X \<subseteq> Y" by blast | 
| 52181 | 154 | then show ?case | 
| 155 | proof | |
| 156 | assume "Y \<subseteq> X" | |
| 74749 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 157 | with * and \<open>Y \<in> \<C>\<close> subset_suc show ?thesis | 
| 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 158 | by fastforce | 
| 52181 | 159 | next | 
| 160 | assume "suc X \<subseteq> Y" | |
| 60758 | 161 | with \<open>Y \<subseteq> suc X\<close> show ?thesis by blast | 
| 52181 | 162 | qed | 
| 163 | next | |
| 164 | case (Union X) | |
| 165 | show ?case | |
| 166 | proof (rule ccontr) | |
| 167 | assume "\<not> ?thesis" | |
| 60758 | 168 | with \<open>Y \<subseteq> \<Union>X\<close> obtain x y z | 
| 63572 | 169 | where "\<not> suc Y \<subseteq> \<Union>X" | 
| 170 | and "x \<in> X" and "y \<in> x" and "y \<notin> Y" | |
| 171 | and "z \<in> suc Y" and "\<forall>x\<in>X. z \<notin> x" by blast | |
| 60758 | 172 | with \<open>X \<subseteq> \<C>\<close> have "x \<in> \<C>" by blast | 
| 63572 | 173 | from Union and \<open>x \<in> X\<close> have *: "\<And>y. y \<in> \<C> \<Longrightarrow> y \<subseteq> x \<Longrightarrow> x = y \<or> suc y \<subseteq> x" | 
| 174 | by blast | |
| 175 | with suc_Union_closed_total' [OF \<open>Y \<in> \<C>\<close> \<open>x \<in> \<C>\<close>] have "Y \<subseteq> x \<or> suc x \<subseteq> Y" | |
| 176 | by blast | |
| 52181 | 177 | then show False | 
| 178 | proof | |
| 179 | assume "Y \<subseteq> x" | |
| 74749 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 180 | with * [OF \<open>Y \<in> \<C>\<close>] \<open>y \<in> x\<close> \<open>y \<notin> Y\<close> \<open>x \<in> X\<close> \<open>\<not> suc Y \<subseteq> \<Union>X\<close> show False | 
| 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 181 | by blast | 
| 52181 | 182 | next | 
| 183 | assume "suc x \<subseteq> Y" | |
| 74749 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 184 | with \<open>y \<notin> Y\<close> suc_subset \<open>y \<in> x\<close> show False by blast | 
| 52181 | 185 | qed | 
| 186 | qed | |
| 187 | qed | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 188 | |
| 69593 | 189 | text \<open>The elements of \<^term>\<open>\<C>\<close> are totally ordered by the subset relation.\<close> | 
| 52181 | 190 | lemma suc_Union_closed_total: | 
| 191 | assumes "X \<in> \<C>" and "Y \<in> \<C>" | |
| 192 | shows "X \<subseteq> Y \<or> Y \<subseteq> X" | |
| 193 | proof (cases "\<forall>Z\<in>\<C>. Z \<subseteq> Y \<longrightarrow> Z = Y \<or> suc Z \<subseteq> Y") | |
| 194 | case True | |
| 195 | with suc_Union_closed_total' [OF assms] | |
| 63572 | 196 | have "X \<subseteq> Y \<or> suc Y \<subseteq> X" by blast | 
| 197 | with suc_subset [of Y] show ?thesis by blast | |
| 52181 | 198 | next | 
| 199 | case False | |
| 63572 | 200 | then obtain Z where "Z \<in> \<C>" and "Z \<subseteq> Y" and "Z \<noteq> Y" and "\<not> suc Z \<subseteq> Y" | 
| 201 | by blast | |
| 202 | with suc_Union_closed_subsetD and \<open>Y \<in> \<C>\<close> show ?thesis | |
| 203 | by blast | |
| 52181 | 204 | qed | 
| 205 | ||
| 69593 | 206 | text \<open>Once we hit a fixed point w.r.t. \<^term>\<open>suc\<close>, all other elements | 
| 207 | of \<^term>\<open>\<C>\<close> are subsets of this fixed point.\<close> | |
| 52181 | 208 | lemma suc_Union_closed_suc: | 
| 209 | assumes "X \<in> \<C>" and "Y \<in> \<C>" and "suc Y = Y" | |
| 210 | shows "X \<subseteq> Y" | |
| 63572 | 211 | using \<open>X \<in> \<C>\<close> | 
| 212 | proof induct | |
| 52181 | 213 | case (suc X) | 
| 63572 | 214 | with \<open>Y \<in> \<C>\<close> and suc_Union_closed_subsetD have "X = Y \<or> suc X \<subseteq> Y" | 
| 215 | by blast | |
| 216 | then show ?case | |
| 217 | by (auto simp: \<open>suc Y = Y\<close>) | |
| 218 | next | |
| 219 | case Union | |
| 220 | then show ?case by blast | |
| 221 | qed | |
| 52181 | 222 | |
| 223 | lemma eq_suc_Union: | |
| 224 | assumes "X \<in> \<C>" | |
| 225 | shows "suc X = X \<longleftrightarrow> X = \<Union>\<C>" | |
| 63572 | 226 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 52181 | 227 | proof | 
| 63572 | 228 | assume ?lhs | 
| 229 | then have "\<Union>\<C> \<subseteq> X" | |
| 230 | by (rule suc_Union_closed_suc [OF suc_Union_closed_Union \<open>X \<in> \<C>\<close>]) | |
| 231 | with \<open>X \<in> \<C>\<close> show ?rhs | |
| 232 | by blast | |
| 52181 | 233 | next | 
| 60758 | 234 | from \<open>X \<in> \<C>\<close> have "suc X \<in> \<C>" by (rule suc) | 
| 52181 | 235 | then have "suc X \<subseteq> \<Union>\<C>" by blast | 
| 63572 | 236 | moreover assume ?rhs | 
| 52181 | 237 | ultimately have "suc X \<subseteq> X" by simp | 
| 238 | moreover have "X \<subseteq> suc X" by (rule suc_subset) | |
| 63572 | 239 | ultimately show ?lhs .. | 
| 52181 | 240 | qed | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 241 | |
| 52181 | 242 | lemma suc_in_carrier: | 
| 243 | assumes "X \<subseteq> A" | |
| 244 | shows "suc X \<subseteq> A" | |
| 245 | using assms | |
| 63572 | 246 | by (cases "\<not> chain X \<or> maxchain X") (auto dest: chain_sucD) | 
| 52181 | 247 | |
| 248 | lemma suc_Union_closed_in_carrier: | |
| 249 | assumes "X \<in> \<C>" | |
| 250 | shows "X \<subseteq> A" | |
| 251 | using assms | |
| 63572 | 252 | by induct (auto dest: suc_in_carrier) | 
| 52181 | 253 | |
| 69593 | 254 | text \<open>All elements of \<^term>\<open>\<C>\<close> are chains.\<close> | 
| 52181 | 255 | lemma suc_Union_closed_chain: | 
| 256 | assumes "X \<in> \<C>" | |
| 257 | shows "chain X" | |
| 63572 | 258 | using assms | 
| 259 | proof induct | |
| 260 | case (suc X) | |
| 261 | then show ?case | |
| 262 | using not_maxchain_Some by (simp add: suc_def) | |
| 52181 | 263 | next | 
| 264 | case (Union X) | |
| 63572 | 265 | then have "\<Union>X \<subseteq> A" | 
| 266 | by (auto dest: suc_Union_closed_in_carrier) | |
| 52181 | 267 | moreover have "\<forall>x\<in>\<Union>X. \<forall>y\<in>\<Union>X. x \<sqsubseteq> y \<or> y \<sqsubseteq> x" | 
| 268 | proof (intro ballI) | |
| 269 | fix x y | |
| 270 | assume "x \<in> \<Union>X" and "y \<in> \<Union>X" | |
| 63572 | 271 | then obtain u v where "x \<in> u" and "u \<in> X" and "y \<in> v" and "v \<in> X" | 
| 272 | by blast | |
| 273 | with Union have "u \<in> \<C>" and "v \<in> \<C>" and "chain u" and "chain v" | |
| 274 | by blast+ | |
| 275 | with suc_Union_closed_total have "u \<subseteq> v \<or> v \<subseteq> u" | |
| 276 | by blast | |
| 52181 | 277 | then show "x \<sqsubseteq> y \<or> y \<sqsubseteq> x" | 
| 278 | proof | |
| 279 | assume "u \<subseteq> v" | |
| 60758 | 280 | from \<open>chain v\<close> show ?thesis | 
| 52181 | 281 | proof (rule chain_total) | 
| 282 | show "y \<in> v" by fact | |
| 60758 | 283 | show "x \<in> v" using \<open>u \<subseteq> v\<close> and \<open>x \<in> u\<close> by blast | 
| 52181 | 284 | qed | 
| 285 | next | |
| 286 | assume "v \<subseteq> u" | |
| 60758 | 287 | from \<open>chain u\<close> show ?thesis | 
| 52181 | 288 | proof (rule chain_total) | 
| 289 | show "x \<in> u" by fact | |
| 60758 | 290 | show "y \<in> u" using \<open>v \<subseteq> u\<close> and \<open>y \<in> v\<close> by blast | 
| 52181 | 291 | qed | 
| 292 | qed | |
| 293 | qed | |
| 294 | ultimately show ?case unfolding chain_def .. | |
| 295 | qed | |
| 296 | ||
| 60758 | 297 | subsubsection \<open>Hausdorff's Maximum Principle\<close> | 
| 52181 | 298 | |
| 63572 | 299 | text \<open>There exists a maximal totally ordered subset of \<open>A\<close>. (Note that we do not | 
| 300 | require \<open>A\<close> to be partially ordered.)\<close> | |
| 46980 | 301 | |
| 52181 | 302 | theorem Hausdorff: "\<exists>C. maxchain C" | 
| 303 | proof - | |
| 304 | let ?M = "\<Union>\<C>" | |
| 305 | have "maxchain ?M" | |
| 306 | proof (rule ccontr) | |
| 63572 | 307 | assume "\<not> ?thesis" | 
| 52181 | 308 | then have "suc ?M \<noteq> ?M" | 
| 63572 | 309 | using suc_not_equals and suc_Union_closed_chain [OF suc_Union_closed_Union] by simp | 
| 52181 | 310 | moreover have "suc ?M = ?M" | 
| 311 | using eq_suc_Union [OF suc_Union_closed_Union] by simp | |
| 312 | ultimately show False by contradiction | |
| 313 | qed | |
| 314 | then show ?thesis by blast | |
| 315 | qed | |
| 316 | ||
| 69593 | 317 | text \<open>Make notation \<^term>\<open>\<C>\<close> available again.\<close> | 
| 63572 | 318 | no_notation suc_Union_closed  ("\<C>")
 | 
| 52181 | 319 | |
| 63572 | 320 | lemma chain_extend: "chain C \<Longrightarrow> z \<in> A \<Longrightarrow> \<forall>x\<in>C. x \<sqsubseteq> z \<Longrightarrow> chain ({z} \<union> C)"
 | 
| 52181 | 321 | unfolding chain_def by blast | 
| 322 | ||
| 63572 | 323 | lemma maxchain_imp_chain: "maxchain C \<Longrightarrow> chain C" | 
| 52181 | 324 | by (simp add: maxchain_def) | 
| 325 | ||
| 326 | end | |
| 327 | ||
| 69593 | 328 | text \<open>Hide constant \<^const>\<open>pred_on.suc_Union_closed\<close>, which was just needed | 
| 63572 | 329 | for the proof of Hausforff's maximum principle.\<close> | 
| 52181 | 330 | hide_const pred_on.suc_Union_closed | 
| 331 | ||
| 332 | lemma chain_mono: | |
| 63572 | 333 | assumes "\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> P x y \<Longrightarrow> Q x y" | 
| 52181 | 334 | and "pred_on.chain A P C" | 
| 335 | shows "pred_on.chain A Q C" | |
| 336 | using assms unfolding pred_on.chain_def by blast | |
| 337 | ||
| 63572 | 338 | |
| 60758 | 339 | subsubsection \<open>Results for the proper subset relation\<close> | 
| 52181 | 340 | |
| 67399 | 341 | interpretation subset: pred_on "A" "(\<subset>)" for A . | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 342 | |
| 52181 | 343 | lemma subset_maxchain_max: | 
| 63572 | 344 | assumes "subset.maxchain A C" | 
| 345 | and "X \<in> A" | |
| 346 | and "\<Union>C \<subseteq> X" | |
| 52181 | 347 | shows "\<Union>C = X" | 
| 348 | proof (rule ccontr) | |
| 349 |   let ?C = "{X} \<union> C"
 | |
| 60758 | 350 | from \<open>subset.maxchain A C\<close> have "subset.chain A C" | 
| 52181 | 351 | and *: "\<And>S. subset.chain A S \<Longrightarrow> \<not> C \<subset> S" | 
| 352 | by (auto simp: subset.maxchain_def) | |
| 60758 | 353 | moreover have "\<forall>x\<in>C. x \<subseteq> X" using \<open>\<Union>C \<subseteq> X\<close> by auto | 
| 52181 | 354 | ultimately have "subset.chain A ?C" | 
| 60758 | 355 | using subset.chain_extend [of A C X] and \<open>X \<in> A\<close> by auto | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
52821diff
changeset | 356 | moreover assume **: "\<Union>C \<noteq> X" | 
| 60758 | 357 | moreover from ** have "C \<subset> ?C" using \<open>\<Union>C \<subseteq> X\<close> by auto | 
| 52181 | 358 | ultimately show False using * by blast | 
| 359 | qed | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 360 | |
| 68975 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 361 | lemma subset_chain_def: "\<And>\<A>. subset.chain \<A> \<C> = (\<C> \<subseteq> \<A> \<and> (\<forall>X\<in>\<C>. \<forall>Y\<in>\<C>. X \<subseteq> Y \<or> Y \<subseteq> X))" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 362 | by (auto simp: subset.chain_def) | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 363 | |
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 364 | lemma subset_chain_insert: | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 365 | "subset.chain \<A> (insert B \<B>) \<longleftrightarrow> B \<in> \<A> \<and> (\<forall>X\<in>\<B>. X \<subseteq> B \<or> B \<subseteq> X) \<and> subset.chain \<A> \<B>" | 
| 
5ce4d117cea7
A few new results, elimination of duplicates and more use of "pairwise"
 paulson <lp15@cam.ac.uk> parents: 
68745diff
changeset | 366 | by (fastforce simp add: subset_chain_def) | 
| 63572 | 367 | |
| 60758 | 368 | subsubsection \<open>Zorn's lemma\<close> | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 369 | |
| 60758 | 370 | text \<open>If every chain has an upper bound, then there is a maximal set.\<close> | 
| 69000 | 371 | theorem subset_Zorn: | 
| 52181 | 372 | assumes "\<And>C. subset.chain A C \<Longrightarrow> \<exists>U\<in>A. \<forall>X\<in>C. X \<subseteq> U" | 
| 373 | shows "\<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M" | |
| 374 | proof - | |
| 375 | from subset.Hausdorff [of A] obtain M where "subset.maxchain A M" .. | |
| 63572 | 376 | then have "subset.chain A M" | 
| 377 | by (rule subset.maxchain_imp_chain) | |
| 378 | with assms obtain Y where "Y \<in> A" and "\<forall>X\<in>M. X \<subseteq> Y" | |
| 379 | by blast | |
| 52181 | 380 | moreover have "\<forall>X\<in>A. Y \<subseteq> X \<longrightarrow> Y = X" | 
| 381 | proof (intro ballI impI) | |
| 382 | fix X | |
| 383 | assume "X \<in> A" and "Y \<subseteq> X" | |
| 384 | show "Y = X" | |
| 385 | proof (rule ccontr) | |
| 63572 | 386 | assume "\<not> ?thesis" | 
| 60758 | 387 | with \<open>Y \<subseteq> X\<close> have "\<not> X \<subseteq> Y" by blast | 
| 388 | from subset.chain_extend [OF \<open>subset.chain A M\<close> \<open>X \<in> A\<close>] and \<open>\<forall>X\<in>M. X \<subseteq> Y\<close> | |
| 63572 | 389 |       have "subset.chain A ({X} \<union> M)"
 | 
| 390 | using \<open>Y \<subseteq> X\<close> by auto | |
| 391 |       moreover have "M \<subset> {X} \<union> M"
 | |
| 392 | using \<open>\<forall>X\<in>M. X \<subseteq> Y\<close> and \<open>\<not> X \<subseteq> Y\<close> by auto | |
| 52181 | 393 | ultimately show False | 
| 60758 | 394 | using \<open>subset.maxchain A M\<close> by (auto simp: subset.maxchain_def) | 
| 52181 | 395 | qed | 
| 396 | qed | |
| 55811 | 397 | ultimately show ?thesis by blast | 
| 52181 | 398 | qed | 
| 399 | ||
| 63572 | 400 | text \<open>Alternative version of Zorn's lemma for the subset relation.\<close> | 
| 52181 | 401 | lemma subset_Zorn': | 
| 402 | assumes "\<And>C. subset.chain A C \<Longrightarrow> \<Union>C \<in> A" | |
| 403 | shows "\<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M" | |
| 404 | proof - | |
| 405 | from subset.Hausdorff [of A] obtain M where "subset.maxchain A M" .. | |
| 63572 | 406 | then have "subset.chain A M" | 
| 407 | by (rule subset.maxchain_imp_chain) | |
| 52181 | 408 | with assms have "\<Union>M \<in> A" . | 
| 409 | moreover have "\<forall>Z\<in>A. \<Union>M \<subseteq> Z \<longrightarrow> \<Union>M = Z" | |
| 410 | proof (intro ballI impI) | |
| 411 | fix Z | |
| 412 | assume "Z \<in> A" and "\<Union>M \<subseteq> Z" | |
| 60758 | 413 | with subset_maxchain_max [OF \<open>subset.maxchain A M\<close>] | 
| 52181 | 414 | show "\<Union>M = Z" . | 
| 415 | qed | |
| 416 | ultimately show ?thesis by blast | |
| 417 | qed | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 418 | |
| 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 419 | |
| 60758 | 420 | subsection \<open>Zorn's Lemma for Partial Orders\<close> | 
| 52181 | 421 | |
| 60758 | 422 | text \<open>Relate old to new definitions.\<close> | 
| 17200 | 423 | |
| 63572 | 424 | definition chain_subset :: "'a set set \<Rightarrow> bool"  ("chain\<^sub>\<subseteq>")  (* Define globally? In Set.thy? *)
 | 
| 425 | where "chain\<^sub>\<subseteq> C \<longleftrightarrow> (\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A)" | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 426 | |
| 63572 | 427 | definition chains :: "'a set set \<Rightarrow> 'a set set set" | 
| 428 |   where "chains A = {C. C \<subseteq> A \<and> chain\<^sub>\<subseteq> C}"
 | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 429 | |
| 63572 | 430 | definition Chains :: "('a \<times> 'a) set \<Rightarrow> 'a set set"  (* Define globally? In Relation.thy? *)
 | 
| 431 |   where "Chains r = {C. \<forall>a\<in>C. \<forall>b\<in>C. (a, b) \<in> r \<or> (b, a) \<in> r}"
 | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 432 | |
| 63572 | 433 | lemma chains_extend: "c \<in> chains S \<Longrightarrow> z \<in> S \<Longrightarrow> \<forall>x \<in> c. x \<subseteq> z \<Longrightarrow> {z} \<union> c \<in> chains S"
 | 
| 434 | for z :: "'a set" | |
| 63172 | 435 | unfolding chains_def chain_subset_def by blast | 
| 52183 
667961fa6a60
fixed files broken due to Zorn changes (cf. 59e5dd7b8f9a)
 popescua parents: 
52181diff
changeset | 436 | |
| 52181 | 437 | lemma mono_Chains: "r \<subseteq> s \<Longrightarrow> Chains r \<subseteq> Chains s" | 
| 438 | unfolding Chains_def by blast | |
| 439 | ||
| 440 | lemma chain_subset_alt_def: "chain\<^sub>\<subseteq> C = subset.chain UNIV C" | |
| 54482 | 441 | unfolding chain_subset_def subset.chain_def by fast | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 442 | |
| 52181 | 443 | lemma chains_alt_def: "chains A = {C. subset.chain A C}"
 | 
| 444 | by (simp add: chains_def chain_subset_alt_def subset.chain_def) | |
| 445 | ||
| 63572 | 446 | lemma Chains_subset: "Chains r \<subseteq> {C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C}"
 | 
| 52181 | 447 | by (force simp add: Chains_def pred_on.chain_def) | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 448 | |
| 52181 | 449 | lemma Chains_subset': | 
| 450 | assumes "refl r" | |
| 451 |   shows "{C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C} \<subseteq> Chains r"
 | |
| 452 | using assms | |
| 453 | by (auto simp add: Chains_def pred_on.chain_def refl_on_def) | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 454 | |
| 52181 | 455 | lemma Chains_alt_def: | 
| 456 | assumes "refl r" | |
| 457 |   shows "Chains r = {C. pred_on.chain UNIV (\<lambda>x y. (x, y) \<in> r) C}"
 | |
| 55811 | 458 | using assms Chains_subset Chains_subset' by blast | 
| 52181 | 459 | |
| 70214 
58191e01f0b1
moving around some material from Algebraic_Closure
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 460 | lemma Chains_relation_of: | 
| 
58191e01f0b1
moving around some material from Algebraic_Closure
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 461 | assumes "C \<in> Chains (relation_of P A)" shows "C \<subseteq> A" | 
| 
58191e01f0b1
moving around some material from Algebraic_Closure
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 462 | using assms unfolding Chains_def relation_of_def by auto | 
| 
58191e01f0b1
moving around some material from Algebraic_Closure
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 463 | |
| 67673 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 464 | lemma pairwise_chain_Union: | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 465 | assumes P: "\<And>S. S \<in> \<C> \<Longrightarrow> pairwise R S" and "chain\<^sub>\<subseteq> \<C>" | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 466 | shows "pairwise R (\<Union>\<C>)" | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 467 | using \<open>chain\<^sub>\<subseteq> \<C>\<close> unfolding pairwise_def chain_subset_def | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 468 | by (blast intro: P [unfolded pairwise_def, rule_format]) | 
| 
c8caefb20564
lots of new material, ultimately related to measure theory
 paulson <lp15@cam.ac.uk> parents: 
67613diff
changeset | 469 | |
| 63572 | 470 | lemma Zorn_Lemma: "\<forall>C\<in>chains A. \<Union>C \<in> A \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M" | 
| 52183 
667961fa6a60
fixed files broken due to Zorn changes (cf. 59e5dd7b8f9a)
 popescua parents: 
52181diff
changeset | 471 | using subset_Zorn' [of A] by (force simp: chains_alt_def) | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 472 | |
| 63572 | 473 | lemma Zorn_Lemma2: "\<forall>C\<in>chains A. \<exists>U\<in>A. \<forall>X\<in>C. X \<subseteq> U \<Longrightarrow> \<exists>M\<in>A. \<forall>X\<in>A. M \<subseteq> X \<longrightarrow> X = M" | 
| 52181 | 474 | using subset_Zorn [of A] by (auto simp: chains_alt_def) | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 475 | |
| 69000 | 476 | subsection \<open>Other variants of Zorn's Lemma\<close> | 
| 52183 
667961fa6a60
fixed files broken due to Zorn changes (cf. 59e5dd7b8f9a)
 popescua parents: 
52181diff
changeset | 477 | |
| 63572 | 478 | lemma chainsD: "c \<in> chains S \<Longrightarrow> x \<in> c \<Longrightarrow> y \<in> c \<Longrightarrow> x \<subseteq> y \<or> y \<subseteq> x" | 
| 63172 | 479 | unfolding chains_def chain_subset_def by blast | 
| 52183 
667961fa6a60
fixed files broken due to Zorn changes (cf. 59e5dd7b8f9a)
 popescua parents: 
52181diff
changeset | 480 | |
| 63572 | 481 | lemma chainsD2: "c \<in> chains S \<Longrightarrow> c \<subseteq> S" | 
| 63172 | 482 | unfolding chains_def by blast | 
| 52183 
667961fa6a60
fixed files broken due to Zorn changes (cf. 59e5dd7b8f9a)
 popescua parents: 
52181diff
changeset | 483 | |
| 52181 | 484 | lemma Zorns_po_lemma: | 
| 485 | assumes po: "Partial_order r" | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 486 | and u: "\<And>C. C \<in> Chains r \<Longrightarrow> \<exists>u\<in>Field r. \<forall>a\<in>C. (a, u) \<in> r" | 
| 52181 | 487 | shows "\<exists>m\<in>Field r. \<forall>a\<in>Field r. (m, a) \<in> r \<longrightarrow> a = m" | 
| 488 | proof - | |
| 63572 | 489 | have "Preorder r" | 
| 490 | using po by (simp add: partial_order_on_def) | |
| 491 | txt \<open>Mirror \<open>r\<close> in the set of subsets below (wrt \<open>r\<close>) elements of \<open>A\<close>.\<close> | |
| 492 |   let ?B = "\<lambda>x. r\<inverse> `` {x}"
 | |
| 493 | let ?S = "?B ` Field r" | |
| 494 |   have "\<exists>u\<in>Field r. \<forall>A\<in>C. A \<subseteq> r\<inverse> `` {u}"  (is "\<exists>u\<in>Field r. ?P u")
 | |
| 495 | if 1: "C \<subseteq> ?S" and 2: "\<forall>A\<in>C. \<forall>B\<in>C. A \<subseteq> B \<or> B \<subseteq> A" for C | |
| 496 | proof - | |
| 52181 | 497 |     let ?A = "{x\<in>Field r. \<exists>M\<in>C. M = ?B x}"
 | 
| 63572 | 498 | from 1 have "C = ?B ` ?A" by (auto simp: image_def) | 
| 52181 | 499 | have "?A \<in> Chains r" | 
| 500 | proof (simp add: Chains_def, intro allI impI, elim conjE) | |
| 501 | fix a b | |
| 502 | assume "a \<in> Field r" and "?B a \<in> C" and "b \<in> Field r" and "?B b \<in> C" | |
| 63572 | 503 | with 2 have "?B a \<subseteq> ?B b \<or> ?B b \<subseteq> ?B a" by auto | 
| 504 | then show "(a, b) \<in> r \<or> (b, a) \<in> r" | |
| 60758 | 505 | using \<open>Preorder r\<close> and \<open>a \<in> Field r\<close> and \<open>b \<in> Field r\<close> | 
| 52181 | 506 | by (simp add:subset_Image1_Image1_iff) | 
| 507 | qed | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 508 | then obtain u where uA: "u \<in> Field r" "\<forall>a\<in>?A. (a, u) \<in> r" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 509 | by (auto simp: dest: u) | 
| 63572 | 510 | have "?P u" | 
| 52181 | 511 | proof auto | 
| 512 | fix a B assume aB: "B \<in> C" "a \<in> B" | |
| 513 |       with 1 obtain x where "x \<in> Field r" and "B = r\<inverse> `` {x}" by auto
 | |
| 63572 | 514 | then show "(a, u) \<in> r" | 
| 515 | using uA and aB and \<open>Preorder r\<close> | |
| 54482 | 516 | unfolding preorder_on_def refl_on_def by simp (fast dest: transD) | 
| 52181 | 517 | qed | 
| 63572 | 518 | then show ?thesis | 
| 519 | using \<open>u \<in> Field r\<close> by blast | |
| 520 | qed | |
| 52181 | 521 | then have "\<forall>C\<in>chains ?S. \<exists>U\<in>?S. \<forall>A\<in>C. A \<subseteq> U" | 
| 522 | by (auto simp: chains_def chain_subset_def) | |
| 63572 | 523 | from Zorn_Lemma2 [OF this] obtain m B | 
| 524 | where "m \<in> Field r" | |
| 525 |       and "B = r\<inverse> `` {m}"
 | |
| 526 |       and "\<forall>x\<in>Field r. B \<subseteq> r\<inverse> `` {x} \<longrightarrow> r\<inverse> `` {x} = B"
 | |
| 52181 | 527 | by auto | 
| 63572 | 528 | then have "\<forall>a\<in>Field r. (m, a) \<in> r \<longrightarrow> a = m" | 
| 60758 | 529 | using po and \<open>Preorder r\<close> and \<open>m \<in> Field r\<close> | 
| 52181 | 530 | by (auto simp: subset_Image1_Image1_iff Partial_order_eq_Image1_Image1_iff) | 
| 63572 | 531 | then show ?thesis | 
| 532 | using \<open>m \<in> Field r\<close> by blast | |
| 52181 | 533 | qed | 
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 534 | |
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 535 | lemma predicate_Zorn: | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 536 | assumes po: "partial_order_on A (relation_of P A)" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 537 | and ch: "\<And>C. C \<in> Chains (relation_of P A) \<Longrightarrow> \<exists>u \<in> A. \<forall>a \<in> C. P a u" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 538 | shows "\<exists>m \<in> A. \<forall>a \<in> A. P m a \<longrightarrow> a = m" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 539 | proof - | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 540 | have "a \<in> A" if "C \<in> Chains (relation_of P A)" and "a \<in> C" for C a | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 541 | using that unfolding Chains_def relation_of_def by auto | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 542 | moreover have "(a, u) \<in> relation_of P A" if "a \<in> A" and "u \<in> A" and "P a u" for a u | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 543 | unfolding relation_of_def using that by auto | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 544 | ultimately have "\<exists>m\<in>A. \<forall>a\<in>A. (m, a) \<in> relation_of P A \<longrightarrow> a = m" | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 545 | using Zorns_po_lemma[OF Partial_order_relation_ofI[OF po], rule_format] ch | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 546 | unfolding Field_relation_of[OF partial_order_onD(1)[OF po]] by blast | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 547 | then show ?thesis | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 548 | by (auto simp: relation_of_def) | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 549 | qed | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 550 | |
| 69000 | 551 | lemma Union_in_chain: "\<lbrakk>finite \<B>; \<B> \<noteq> {}; subset.chain \<A> \<B>\<rbrakk> \<Longrightarrow> \<Union>\<B> \<in> \<B>"
 | 
| 552 | proof (induction \<B> rule: finite_induct) | |
| 553 | case (insert B \<B>) | |
| 554 | show ?case | |
| 555 |   proof (cases "\<B> = {}")
 | |
| 556 | case False | |
| 557 | then show ?thesis | |
| 558 | using insert sup.absorb2 by (auto simp: subset_chain_insert dest!: bspec [where x="\<Union>\<B>"]) | |
| 559 | qed auto | |
| 560 | qed simp | |
| 561 | ||
| 562 | lemma Inter_in_chain: "\<lbrakk>finite \<B>; \<B> \<noteq> {}; subset.chain \<A> \<B>\<rbrakk> \<Longrightarrow> \<Inter>\<B> \<in> \<B>"
 | |
| 563 | proof (induction \<B> rule: finite_induct) | |
| 564 | case (insert B \<B>) | |
| 565 | show ?case | |
| 566 |   proof (cases "\<B> = {}")
 | |
| 567 | case False | |
| 568 | then show ?thesis | |
| 569 | using insert inf.absorb2 by (auto simp: subset_chain_insert dest!: bspec [where x="\<Inter>\<B>"]) | |
| 570 | qed auto | |
| 571 | qed simp | |
| 572 | ||
| 573 | lemma finite_subset_Union_chain: | |
| 574 |   assumes "finite A" "A \<subseteq> \<Union>\<B>" "\<B> \<noteq> {}" and sub: "subset.chain \<A> \<B>"
 | |
| 575 | obtains B where "B \<in> \<B>" "A \<subseteq> B" | |
| 576 | proof - | |
| 577 | obtain \<F> where \<F>: "finite \<F>" "\<F> \<subseteq> \<B>" "A \<subseteq> \<Union>\<F>" | |
| 578 | using assms by (auto intro: finite_subset_Union) | |
| 579 | show thesis | |
| 580 |   proof (cases "\<F> = {}")
 | |
| 581 | case True | |
| 582 | then show ?thesis | |
| 583 |       using \<open>A \<subseteq> \<Union>\<F>\<close> \<open>\<B> \<noteq> {}\<close> that by fastforce
 | |
| 584 | next | |
| 585 | case False | |
| 586 | show ?thesis | |
| 587 | proof | |
| 588 | show "\<Union>\<F> \<in> \<B>" | |
| 589 | using sub \<open>\<F> \<subseteq> \<B>\<close> \<open>finite \<F>\<close> | |
| 590 | by (simp add: Union_in_chain False subset.chain_def subset_iff) | |
| 591 | show "A \<subseteq> \<Union>\<F>" | |
| 592 | using \<open>A \<subseteq> \<Union>\<F>\<close> by blast | |
| 593 | qed | |
| 594 | qed | |
| 595 | qed | |
| 596 | ||
| 597 | lemma subset_Zorn_nonempty: | |
| 598 |   assumes "\<A> \<noteq> {}" and ch: "\<And>\<C>. \<lbrakk>\<C>\<noteq>{}; subset.chain \<A> \<C>\<rbrakk> \<Longrightarrow> \<Union>\<C> \<in> \<A>"
 | |
| 599 | shows "\<exists>M\<in>\<A>. \<forall>X\<in>\<A>. M \<subseteq> X \<longrightarrow> X = M" | |
| 600 | proof (rule subset_Zorn) | |
| 601 | show "\<exists>U\<in>\<A>. \<forall>X\<in>\<C>. X \<subseteq> U" if "subset.chain \<A> \<C>" for \<C> | |
| 602 |   proof (cases "\<C> = {}")
 | |
| 603 | case True | |
| 604 | then show ?thesis | |
| 605 |       using \<open>\<A> \<noteq> {}\<close> by blast
 | |
| 606 | next | |
| 607 | case False | |
| 608 | show ?thesis | |
| 609 | by (blast intro!: ch False that Union_upper) | |
| 610 | qed | |
| 611 | qed | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 612 | |
| 60758 | 613 | subsection \<open>The Well Ordering Theorem\<close> | 
| 26191 | 614 | |
| 615 | (* The initial segment of a relation appears generally useful. | |
| 616 | Move to Relation.thy? | |
| 617 | Definition correct/most general? | |
| 618 | Naming? | |
| 619 | *) | |
| 63572 | 620 | definition init_seg_of :: "(('a \<times> 'a) set \<times> ('a \<times> 'a) set) set"
 | 
| 621 |   where "init_seg_of = {(r, s). r \<subseteq> s \<and> (\<forall>a b c. (a, b) \<in> s \<and> (b, c) \<in> r \<longrightarrow> (a, b) \<in> r)}"
 | |
| 26191 | 622 | |
| 63572 | 623 | abbreviation initial_segment_of_syntax :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"
 | 
| 624 | (infix "initial'_segment'_of" 55) | |
| 625 | where "r initial_segment_of s \<equiv> (r, s) \<in> init_seg_of" | |
| 26191 | 626 | |
| 52181 | 627 | lemma refl_on_init_seg_of [simp]: "r initial_segment_of r" | 
| 628 | by (simp add: init_seg_of_def) | |
| 26191 | 629 | |
| 630 | lemma trans_init_seg_of: | |
| 631 | "r initial_segment_of s \<Longrightarrow> s initial_segment_of t \<Longrightarrow> r initial_segment_of t" | |
| 54482 | 632 | by (simp (no_asm_use) add: init_seg_of_def) blast | 
| 26191 | 633 | |
| 63572 | 634 | lemma antisym_init_seg_of: "r initial_segment_of s \<Longrightarrow> s initial_segment_of r \<Longrightarrow> r = s" | 
| 52181 | 635 | unfolding init_seg_of_def by safe | 
| 26191 | 636 | |
| 63572 | 637 | lemma Chains_init_seg_of_Union: "R \<in> Chains init_seg_of \<Longrightarrow> r\<in>R \<Longrightarrow> r initial_segment_of \<Union>R" | 
| 52181 | 638 | by (auto simp: init_seg_of_def Ball_def Chains_def) blast | 
| 26191 | 639 | |
| 26272 | 640 | lemma chain_subset_trans_Union: | 
| 55811 | 641 | assumes "chain\<^sub>\<subseteq> R" "\<forall>r\<in>R. trans r" | 
| 642 | shows "trans (\<Union>R)" | |
| 643 | proof (intro transI, elim UnionE) | |
| 63572 | 644 | fix S1 S2 :: "'a rel" and x y z :: 'a | 
| 55811 | 645 | assume "S1 \<in> R" "S2 \<in> R" | 
| 63572 | 646 | with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1" | 
| 647 | unfolding chain_subset_def by blast | |
| 55811 | 648 | moreover assume "(x, y) \<in> S1" "(y, z) \<in> S2" | 
| 63572 | 649 | ultimately have "((x, y) \<in> S1 \<and> (y, z) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, z) \<in> S2)" | 
| 650 | by blast | |
| 651 | with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "(x, z) \<in> \<Union>R" | |
| 652 | by (auto elim: transE) | |
| 55811 | 653 | qed | 
| 26191 | 654 | |
| 26272 | 655 | lemma chain_subset_antisym_Union: | 
| 55811 | 656 | assumes "chain\<^sub>\<subseteq> R" "\<forall>r\<in>R. antisym r" | 
| 657 | shows "antisym (\<Union>R)" | |
| 658 | proof (intro antisymI, elim UnionE) | |
| 63572 | 659 | fix S1 S2 :: "'a rel" and x y :: 'a | 
| 55811 | 660 | assume "S1 \<in> R" "S2 \<in> R" | 
| 63572 | 661 | with assms(1) have "S1 \<subseteq> S2 \<or> S2 \<subseteq> S1" | 
| 662 | unfolding chain_subset_def by blast | |
| 55811 | 663 | moreover assume "(x, y) \<in> S1" "(y, x) \<in> S2" | 
| 63572 | 664 | ultimately have "((x, y) \<in> S1 \<and> (y, x) \<in> S1) \<or> ((x, y) \<in> S2 \<and> (y, x) \<in> S2)" | 
| 665 | by blast | |
| 666 | with \<open>S1 \<in> R\<close> \<open>S2 \<in> R\<close> assms(2) show "x = y" | |
| 667 | unfolding antisym_def by auto | |
| 55811 | 668 | qed | 
| 26191 | 669 | |
| 26272 | 670 | lemma chain_subset_Total_Union: | 
| 52181 | 671 | assumes "chain\<^sub>\<subseteq> R" and "\<forall>r\<in>R. Total r" | 
| 672 | shows "Total (\<Union>R)" | |
| 673 | proof (simp add: total_on_def Ball_def, auto del: disjCI) | |
| 63572 | 674 | fix r s a b | 
| 675 | assume A: "r \<in> R" "s \<in> R" "a \<in> Field r" "b \<in> Field s" "a \<noteq> b" | |
| 60758 | 676 | from \<open>chain\<^sub>\<subseteq> R\<close> and \<open>r \<in> R\<close> and \<open>s \<in> R\<close> have "r \<subseteq> s \<or> s \<subseteq> r" | 
| 52181 | 677 | by (auto simp add: chain_subset_def) | 
| 63572 | 678 | then show "(\<exists>r\<in>R. (a, b) \<in> r) \<or> (\<exists>r\<in>R. (b, a) \<in> r)" | 
| 26191 | 679 | proof | 
| 63572 | 680 | assume "r \<subseteq> s" | 
| 681 | then have "(a, b) \<in> s \<or> (b, a) \<in> s" | |
| 682 | using assms(2) A mono_Field[of r s] | |
| 55811 | 683 | by (auto simp add: total_on_def) | 
| 63572 | 684 | then show ?thesis | 
| 685 | using \<open>s \<in> R\<close> by blast | |
| 26191 | 686 | next | 
| 63572 | 687 | assume "s \<subseteq> r" | 
| 688 | then have "(a, b) \<in> r \<or> (b, a) \<in> r" | |
| 689 | using assms(2) A mono_Field[of s r] | |
| 55811 | 690 | by (fastforce simp add: total_on_def) | 
| 63572 | 691 | then show ?thesis | 
| 692 | using \<open>r \<in> R\<close> by blast | |
| 26191 | 693 | qed | 
| 694 | qed | |
| 695 | ||
| 696 | lemma wf_Union_wf_init_segs: | |
| 63572 | 697 | assumes "R \<in> Chains init_seg_of" | 
| 698 | and "\<forall>r\<in>R. wf r" | |
| 52181 | 699 | shows "wf (\<Union>R)" | 
| 63572 | 700 | proof (simp add: wf_iff_no_infinite_down_chain, rule ccontr, auto) | 
| 701 | fix f | |
| 702 | assume 1: "\<forall>i. \<exists>r\<in>R. (f (Suc i), f i) \<in> r" | |
| 52181 | 703 | then obtain r where "r \<in> R" and "(f (Suc 0), f 0) \<in> r" by auto | 
| 63572 | 704 | have "(f (Suc i), f i) \<in> r" for i | 
| 705 | proof (induct i) | |
| 706 | case 0 | |
| 707 | show ?case by fact | |
| 708 | next | |
| 709 | case (Suc i) | |
| 710 | then obtain s where s: "s \<in> R" "(f (Suc (Suc i)), f(Suc i)) \<in> s" | |
| 711 | using 1 by auto | |
| 712 | then have "s initial_segment_of r \<or> r initial_segment_of s" | |
| 713 | using assms(1) \<open>r \<in> R\<close> by (simp add: Chains_def) | |
| 714 | with Suc s show ?case by (simp add: init_seg_of_def) blast | |
| 715 | qed | |
| 716 | then show False | |
| 717 | using assms(2) and \<open>r \<in> R\<close> | |
| 52181 | 718 | by (simp add: wf_iff_no_infinite_down_chain) blast | 
| 26191 | 719 | qed | 
| 720 | ||
| 63572 | 721 | lemma initial_segment_of_Diff: "p initial_segment_of q \<Longrightarrow> p - s initial_segment_of q - s" | 
| 52181 | 722 | unfolding init_seg_of_def by blast | 
| 27476 | 723 | |
| 63572 | 724 | lemma Chains_inits_DiffI: "R \<in> Chains init_seg_of \<Longrightarrow> {r - s |r. r \<in> R} \<in> Chains init_seg_of"
 | 
| 52181 | 725 | unfolding Chains_def by (blast intro: initial_segment_of_Diff) | 
| 26191 | 726 | |
| 52181 | 727 | theorem well_ordering: "\<exists>r::'a rel. Well_order r \<and> Field r = UNIV" | 
| 728 | proof - | |
| 61799 | 729 | \<comment> \<open>The initial segment relation on well-orders:\<close> | 
| 52181 | 730 |   let ?WO = "{r::'a rel. Well_order r}"
 | 
| 63040 | 731 | define I where "I = init_seg_of \<inter> ?WO \<times> ?WO" | 
| 63572 | 732 | then have I_init: "I \<subseteq> init_seg_of" by simp | 
| 733 | then have subch: "\<And>R. R \<in> Chains I \<Longrightarrow> chain\<^sub>\<subseteq> R" | |
| 54482 | 734 | unfolding init_seg_of_def chain_subset_def Chains_def by blast | 
| 52181 | 735 | have Chains_wo: "\<And>R r. R \<in> Chains I \<Longrightarrow> r \<in> R \<Longrightarrow> Well_order r" | 
| 736 | by (simp add: Chains_def I_def) blast | |
| 63572 | 737 | have FI: "Field I = ?WO" | 
| 738 | by (auto simp add: I_def init_seg_of_def Field_def) | |
| 739 | then have 0: "Partial_order I" | |
| 52181 | 740 | by (auto simp: partial_order_on_def preorder_on_def antisym_def antisym_init_seg_of refl_on_def | 
| 63572 | 741 | trans_def I_def elim!: trans_init_seg_of) | 
| 742 | \<comment> \<open>\<open>I\<close>-chains have upper bounds in \<open>?WO\<close> wrt \<open>I\<close>: their Union\<close> | |
| 743 | have "\<Union>R \<in> ?WO \<and> (\<forall>r\<in>R. (r, \<Union>R) \<in> I)" if "R \<in> Chains I" for R | |
| 744 | proof - | |
| 745 | from that have Ris: "R \<in> Chains init_seg_of" | |
| 746 | using mono_Chains [OF I_init] by blast | |
| 747 | have subch: "chain\<^sub>\<subseteq> R" | |
| 67613 | 748 | using \<open>R \<in> Chains I\<close> I_init by (auto simp: init_seg_of_def chain_subset_def Chains_def) | 
| 52181 | 749 | have "\<forall>r\<in>R. Refl r" and "\<forall>r\<in>R. trans r" and "\<forall>r\<in>R. antisym r" | 
| 750 | and "\<forall>r\<in>R. Total r" and "\<forall>r\<in>R. wf (r - Id)" | |
| 60758 | 751 | using Chains_wo [OF \<open>R \<in> Chains I\<close>] by (simp_all add: order_on_defs) | 
| 63572 | 752 | have "Refl (\<Union>R)" | 
| 753 | using \<open>\<forall>r\<in>R. Refl r\<close> unfolding refl_on_def by fastforce | |
| 26191 | 754 | moreover have "trans (\<Union>R)" | 
| 60758 | 755 | by (rule chain_subset_trans_Union [OF subch \<open>\<forall>r\<in>R. trans r\<close>]) | 
| 52181 | 756 | moreover have "antisym (\<Union>R)" | 
| 60758 | 757 | by (rule chain_subset_antisym_Union [OF subch \<open>\<forall>r\<in>R. antisym r\<close>]) | 
| 26191 | 758 | moreover have "Total (\<Union>R)" | 
| 60758 | 759 | by (rule chain_subset_Total_Union [OF subch \<open>\<forall>r\<in>R. Total r\<close>]) | 
| 52181 | 760 | moreover have "wf ((\<Union>R) - Id)" | 
| 761 | proof - | |
| 762 |       have "(\<Union>R) - Id = \<Union>{r - Id | r. r \<in> R}" by blast
 | |
| 60758 | 763 | with \<open>\<forall>r\<in>R. wf (r - Id)\<close> and wf_Union_wf_init_segs [OF Chains_inits_DiffI [OF Ris]] | 
| 54482 | 764 | show ?thesis by fastforce | 
| 26191 | 765 | qed | 
| 63572 | 766 | ultimately have "Well_order (\<Union>R)" | 
| 767 | by (simp add:order_on_defs) | |
| 768 | moreover have "\<forall>r \<in> R. r initial_segment_of \<Union>R" | |
| 769 | using Ris by (simp add: Chains_init_seg_of_Union) | |
| 770 | ultimately show ?thesis | |
| 60758 | 771 | using mono_Chains [OF I_init] Chains_wo[of R] and \<open>R \<in> Chains I\<close> | 
| 55811 | 772 | unfolding I_def by blast | 
| 63572 | 773 | qed | 
| 68745 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 774 | then have 1: "\<exists>u\<in>Field I. \<forall>r\<in>R. (r, u) \<in> I" if "R \<in> Chains I" for R | 
| 
345ce5f262ea
Zorn's lemma for relations defined by predicates
 paulson <lp15@cam.ac.uk> parents: 
67673diff
changeset | 775 | using that by (subst FI) blast | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 776 | \<comment> \<open>Zorn's Lemma yields a maximal well-order \<open>m\<close>:\<close> | 
| 63572 | 777 | then obtain m :: "'a rel" | 
| 778 | where "Well_order m" | |
| 779 | and max: "\<forall>r. Well_order r \<and> (m, r) \<in> I \<longrightarrow> r = m" | |
| 54482 | 780 | using Zorns_po_lemma[OF 0 1] unfolding FI by fastforce | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 781 | \<comment> \<open>Now show by contradiction that \<open>m\<close> covers the whole type:\<close> | 
| 63572 | 782 | have False if "x \<notin> Field m" for x :: 'a | 
| 783 | proof - | |
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 784 | \<comment> \<open>Assuming that \<open>x\<close> is not covered and extend \<open>m\<close> at the top with \<open>x\<close>\<close> | 
| 26191 | 785 |     have "m \<noteq> {}"
 | 
| 786 | proof | |
| 52181 | 787 |       assume "m = {}"
 | 
| 788 |       moreover have "Well_order {(x, x)}"
 | |
| 789 | by (simp add: order_on_defs refl_on_def trans_def antisym_def total_on_def Field_def) | |
| 26191 | 790 | ultimately show False using max | 
| 52181 | 791 | by (auto simp: I_def init_seg_of_def simp del: Field_insert) | 
| 26191 | 792 | qed | 
| 63572 | 793 |     then have "Field m \<noteq> {}" by (auto simp: Field_def)
 | 
| 794 | moreover have "wf (m - Id)" | |
| 795 | using \<open>Well_order m\<close> by (simp add: well_order_on_def) | |
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 796 | \<comment> \<open>The extension of \<open>m\<close> by \<open>x\<close>:\<close> | 
| 52181 | 797 |     let ?s = "{(a, x) | a. a \<in> Field m}"
 | 
| 798 | let ?m = "insert (x, x) m \<union> ?s" | |
| 26191 | 799 | have Fm: "Field ?m = insert x (Field m)" | 
| 52181 | 800 | by (auto simp: Field_def) | 
| 801 | have "Refl m" and "trans m" and "antisym m" and "Total m" and "wf (m - Id)" | |
| 60758 | 802 | using \<open>Well_order m\<close> by (simp_all add: order_on_defs) | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 803 | \<comment> \<open>We show that the extension is a well-order\<close> | 
| 63572 | 804 | have "Refl ?m" | 
| 805 | using \<open>Refl m\<close> Fm unfolding refl_on_def by blast | |
| 60758 | 806 | moreover have "trans ?m" using \<open>trans m\<close> and \<open>x \<notin> Field m\<close> | 
| 52181 | 807 | unfolding trans_def Field_def by blast | 
| 63572 | 808 | moreover have "antisym ?m" | 
| 809 | using \<open>antisym m\<close> and \<open>x \<notin> Field m\<close> unfolding antisym_def Field_def by blast | |
| 810 | moreover have "Total ?m" | |
| 811 | using \<open>Total m\<close> and Fm by (auto simp: total_on_def) | |
| 52181 | 812 | moreover have "wf (?m - Id)" | 
| 813 | proof - | |
| 63572 | 814 | have "wf ?s" | 
| 815 | using \<open>x \<notin> Field m\<close> by (auto simp: wf_eq_minimal Field_def Bex_def) | |
| 816 | then show ?thesis | |
| 817 | using \<open>wf (m - Id)\<close> and \<open>x \<notin> Field m\<close> wf_subset [OF \<open>wf ?s\<close> Diff_subset] | |
| 63172 | 818 | by (auto simp: Un_Diff Field_def intro: wf_Un) | 
| 26191 | 819 | qed | 
| 63572 | 820 | ultimately have "Well_order ?m" | 
| 821 | by (simp add: order_on_defs) | |
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 822 | \<comment> \<open>We show that the extension is above \<open>m\<close>\<close> | 
| 63572 | 823 | moreover have "(m, ?m) \<in> I" | 
| 824 | using \<open>Well_order ?m\<close> and \<open>Well_order m\<close> and \<open>x \<notin> Field m\<close> | |
| 52181 | 825 | by (fastforce simp: I_def init_seg_of_def Field_def) | 
| 26191 | 826 | ultimately | 
| 67443 
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
 wenzelm parents: 
67399diff
changeset | 827 | \<comment> \<open>This contradicts maximality of \<open>m\<close>:\<close> | 
| 63572 | 828 | show False | 
| 829 | using max and \<open>x \<notin> Field m\<close> unfolding Field_def by blast | |
| 830 | qed | |
| 831 | then have "Field m = UNIV" by auto | |
| 60758 | 832 | with \<open>Well_order m\<close> show ?thesis by blast | 
| 26272 | 833 | qed | 
| 834 | ||
| 52181 | 835 | corollary well_order_on: "\<exists>r::'a rel. well_order_on A r" | 
| 26272 | 836 | proof - | 
| 63572 | 837 | obtain r :: "'a rel" where wo: "Well_order r" and univ: "Field r = UNIV" | 
| 52181 | 838 | using well_ordering [where 'a = "'a"] by blast | 
| 839 |   let ?r = "{(x, y). x \<in> A \<and> y \<in> A \<and> (x, y) \<in> r}"
 | |
| 63572 | 840 | have 1: "Field ?r = A" | 
| 841 | using wo univ by (fastforce simp: Field_def order_on_defs refl_on_def) | |
| 842 | from \<open>Well_order r\<close> have "Refl r" "trans r" "antisym r" "Total r" "wf (r - Id)" | |
| 843 | by (simp_all add: order_on_defs) | |
| 844 | from \<open>Refl r\<close> have "Refl ?r" | |
| 845 | by (auto simp: refl_on_def 1 univ) | |
| 846 | moreover from \<open>trans r\<close> have "trans ?r" | |
| 26272 | 847 | unfolding trans_def by blast | 
| 63572 | 848 | moreover from \<open>antisym r\<close> have "antisym ?r" | 
| 26272 | 849 | unfolding antisym_def by blast | 
| 63572 | 850 | moreover from \<open>Total r\<close> have "Total ?r" | 
| 851 | by (simp add:total_on_def 1 univ) | |
| 852 | moreover have "wf (?r - Id)" | |
| 853 | by (rule wf_subset [OF \<open>wf (r - Id)\<close>]) blast | |
| 854 | ultimately have "Well_order ?r" | |
| 855 | by (simp add: order_on_defs) | |
| 54482 | 856 | with 1 show ?thesis by auto | 
| 26191 | 857 | qed | 
| 858 | ||
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 859 | lemma dependent_wf_choice: | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 860 |   fixes P :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
 | 
| 63572 | 861 | assumes "wf R" | 
| 862 | and adm: "\<And>f g x r. (\<And>z. (z, x) \<in> R \<Longrightarrow> f z = g z) \<Longrightarrow> P f x r = P g x r" | |
| 863 | and P: "\<And>x f. (\<And>y. (y, x) \<in> R \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r" | |
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 864 | shows "\<exists>f. \<forall>x. P f x (f x)" | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 865 | proof (intro exI allI) | 
| 63572 | 866 | fix x | 
| 63040 | 867 | define f where "f \<equiv> wfrec R (\<lambda>f x. SOME r. P f x r)" | 
| 60758 | 868 | from \<open>wf R\<close> show "P f x (f x)" | 
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 869 | proof (induct x) | 
| 63572 | 870 | case (less x) | 
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 871 | show "P f x (f x)" | 
| 60758 | 872 | proof (subst (2) wfrec_def_adm[OF f_def \<open>wf R\<close>]) | 
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 873 | show "adm_wf R (\<lambda>f x. SOME r. P f x r)" | 
| 74749 
329cb9e6b184
A tiny bit of tidying connected with Zorn's Lemma
 paulson <lp15@cam.ac.uk> parents: 
70214diff
changeset | 874 | by (auto simp: adm_wf_def intro!: arg_cong[where f=Eps] adm) | 
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 875 | show "P f x (Eps (P f x))" | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 876 | using P by (rule someI_ex) fact | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 877 | qed | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 878 | qed | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 879 | qed | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 880 | |
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 881 | lemma (in wellorder) dependent_wellorder_choice: | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 882 | assumes "\<And>r f g x. (\<And>y. y < x \<Longrightarrow> f y = g y) \<Longrightarrow> P f x r = P g x r" | 
| 63572 | 883 | and P: "\<And>x f. (\<And>y. y < x \<Longrightarrow> P f y (f y)) \<Longrightarrow> \<exists>r. P f x r" | 
| 58184 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 884 | shows "\<exists>f. \<forall>x. P f x (f x)" | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 885 | using wf by (rule dependent_wf_choice) (auto intro!: assms) | 
| 
db1381d811ab
cleanup Wfrec; introduce dependent_wf/wellorder_choice
 hoelzl parents: 
55811diff
changeset | 886 | |
| 13551 
b7f64ee8da84
converted Hyperreal/Zorn to Isar format and moved to Library
 paulson parents: diff
changeset | 887 | end |