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