src/HOL/Cardinals/Wellorder_Extension.thy
 author wenzelm Fri Oct 27 13:50:08 2017 +0200 (23 months ago) changeset 66924 b4d4027f743b parent 63167 0909deb8059b child 67443 3abf6a722518 permissions -rw-r--r--
more permissive;
     1 (*  Title:      HOL/Cardinals/Wellorder_Extension.thy

     2     Author:     Christian Sternagel, JAIST

     3 *)

     4

     5 section \<open>Extending Well-founded Relations to Wellorders\<close>

     6

     7 theory Wellorder_Extension

     8 imports Main Order_Union

     9 begin

    10

    11 subsection \<open>Extending Well-founded Relations to Wellorders\<close>

    12

    13 text \<open>A \emph{downset} (also lower set, decreasing set, initial segment, or

    14 downward closed set) is closed w.r.t.\ smaller elements.\<close>

    15 definition downset_on where

    16   "downset_on A r = (\<forall>x y. (x, y) \<in> r \<and> y \<in> A \<longrightarrow> x \<in> A)"

    17

    18 (*

    19 text {*Connection to order filters of the @{theory Cardinals} theory.*}

    20 lemma (in wo_rel) ofilter_downset_on_conv:

    21   "ofilter A \<longleftrightarrow> downset_on A r \<and> A \<subseteq> Field r"

    22   by (auto simp: downset_on_def ofilter_def under_def)

    23 *)

    24

    25 lemma downset_onI:

    26   "(\<And>x y. (x, y) \<in> r \<Longrightarrow> y \<in> A \<Longrightarrow> x \<in> A) \<Longrightarrow> downset_on A r"

    27   by (auto simp: downset_on_def)

    28

    29 lemma downset_onD:

    30   "downset_on A r \<Longrightarrow> (x, y) \<in> r \<Longrightarrow> y \<in> A \<Longrightarrow> x \<in> A"

    31   unfolding downset_on_def by blast

    32

    33 text \<open>Extensions of relations w.r.t.\ a given set.\<close>

    34 definition extension_on where

    35   "extension_on A r s = (\<forall>x\<in>A. \<forall>y\<in>A. (x, y) \<in> s \<longrightarrow> (x, y) \<in> r)"

    36

    37 lemma extension_onI:

    38   "(\<And>x y. \<lbrakk>x \<in> A; y \<in> A; (x, y) \<in> s\<rbrakk> \<Longrightarrow> (x, y) \<in> r) \<Longrightarrow> extension_on A r s"

    39   by (auto simp: extension_on_def)

    40

    41 lemma extension_onD:

    42   "extension_on A r s \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> (x, y) \<in> s \<Longrightarrow> (x, y) \<in> r"

    43   by (auto simp: extension_on_def)

    44

    45 lemma downset_on_Union:

    46   assumes "\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p"

    47   shows "downset_on (Field (\<Union>R)) p"

    48   using assms by (auto intro: downset_onI dest: downset_onD)

    49

    50 lemma chain_subset_extension_on_Union:

    51   assumes "chain\<^sub>\<subseteq> R" and "\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p"

    52   shows "extension_on (Field (\<Union>R)) (\<Union>R) p"

    53   using assms

    54   by (simp add: chain_subset_def extension_on_def)

    55      (metis (no_types) mono_Field set_mp)

    56

    57 lemma downset_on_empty [simp]: "downset_on {} p"

    58   by (auto simp: downset_on_def)

    59

    60 lemma extension_on_empty [simp]: "extension_on {} p q"

    61   by (auto simp: extension_on_def)

    62

    63 text \<open>Every well-founded relation can be extended to a wellorder.\<close>

    64 theorem well_order_extension:

    65   assumes "wf p"

    66   shows "\<exists>w. p \<subseteq> w \<and> Well_order w"

    67 proof -

    68   let ?K = "{r. Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p}"

    69   define I where "I = init_seg_of \<inter> ?K \<times> ?K"

    70   have I_init: "I \<subseteq> init_seg_of" by (simp add: I_def)

    71   then have subch: "\<And>R. R \<in> Chains I \<Longrightarrow> chain\<^sub>\<subseteq> R"

    72     by (auto simp: init_seg_of_def chain_subset_def Chains_def)

    73   have Chains_wo: "\<And>R r. R \<in> Chains I \<Longrightarrow> r \<in> R \<Longrightarrow>

    74       Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p"

    75     by (simp add: Chains_def I_def) blast

    76   have FI: "Field I = ?K" by (auto simp: I_def init_seg_of_def Field_def)

    77   then have 0: "Partial_order I"

    78     by (auto simp: partial_order_on_def preorder_on_def antisym_def antisym_init_seg_of refl_on_def

    79       trans_def I_def elim: trans_init_seg_of)

    80   { fix R assume "R \<in> Chains I"

    81     then have Ris: "R \<in> Chains init_seg_of" using mono_Chains [OF I_init] by blast

    82     have subch: "chain\<^sub>\<subseteq> R" using \<open>R \<in> Chains I\<close> I_init

    83       by (auto simp: init_seg_of_def chain_subset_def Chains_def)

    84     have "\<forall>r\<in>R. Refl r" and "\<forall>r\<in>R. trans r" and "\<forall>r\<in>R. antisym r" and

    85       "\<forall>r\<in>R. Total r" and "\<forall>r\<in>R. wf (r - Id)" and

    86       "\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p" and

    87       "\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p"

    88       using Chains_wo [OF \<open>R \<in> Chains I\<close>] by (simp_all add: order_on_defs)

    89     have "Refl (\<Union>R)" using \<open>\<forall>r\<in>R. Refl r\<close>  unfolding refl_on_def by fastforce

    90     moreover have "trans (\<Union>R)"

    91       by (rule chain_subset_trans_Union [OF subch \<open>\<forall>r\<in>R. trans r\<close>])

    92     moreover have "antisym (\<Union>R)"

    93       by (rule chain_subset_antisym_Union [OF subch \<open>\<forall>r\<in>R. antisym r\<close>])

    94     moreover have "Total (\<Union>R)"

    95       by (rule chain_subset_Total_Union [OF subch \<open>\<forall>r\<in>R. Total r\<close>])

    96     moreover have "wf ((\<Union>R) - Id)"

    97     proof -

    98       have "(\<Union>R) - Id = \<Union>{r - Id | r. r \<in> R}" by blast

    99       with \<open>\<forall>r\<in>R. wf (r - Id)\<close> wf_Union_wf_init_segs [OF Chains_inits_DiffI [OF Ris]]

   100       show ?thesis by fastforce

   101     qed

   102     ultimately have "Well_order (\<Union>R)" by (simp add: order_on_defs)

   103     moreover have "\<forall>r\<in>R. r initial_segment_of \<Union>R" using Ris

   104       by (simp add: Chains_init_seg_of_Union)

   105     moreover have "downset_on (Field (\<Union>R)) p"

   106       by (rule downset_on_Union [OF \<open>\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p\<close>])

   107     moreover have "extension_on (Field (\<Union>R)) (\<Union>R) p"

   108       by (rule chain_subset_extension_on_Union [OF subch \<open>\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p\<close>])

   109     ultimately have "\<Union>R \<in> ?K \<and> (\<forall>r\<in>R. (r,\<Union>R) \<in> I)"

   110       using mono_Chains [OF I_init] and \<open>R \<in> Chains I\<close>

   111       by (simp (no_asm) add: I_def del: Field_Union) (metis Chains_wo)

   112   }

   113   then have 1: "\<forall>R\<in>Chains I. \<exists>u\<in>Field I. \<forall>r\<in>R. (r, u) \<in> I" by (subst FI) blast

   114   txt \<open>Zorn's Lemma yields a maximal wellorder m.\<close>

   115   from Zorns_po_lemma [OF 0 1] obtain m :: "('a \<times> 'a) set"

   116     where "Well_order m" and "downset_on (Field m) p" and "extension_on (Field m) m p" and

   117     max: "\<forall>r. Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p \<and>

   118       (m, r) \<in> I \<longrightarrow> r = m"

   119     by (auto simp: FI)

   120   have "Field p \<subseteq> Field m"

   121   proof (rule ccontr)

   122     let ?Q = "Field p - Field m"

   123     assume "\<not> (Field p \<subseteq> Field m)"

   124     with assms [unfolded wf_eq_minimal, THEN spec, of ?Q]

   125       obtain x where "x \<in> Field p" and "x \<notin> Field m" and

   126       min: "\<forall>y. (y, x) \<in> p \<longrightarrow> y \<notin> ?Q" by blast

   127     txt \<open>Add @{term x} as topmost element to @{term m}.\<close>

   128     let ?s = "{(y, x) | y. y \<in> Field m}"

   129     let ?m = "insert (x, x) m \<union> ?s"

   130     have Fm: "Field ?m = insert x (Field m)" by (auto simp: Field_def)

   131     have "Refl m" and "trans m" and "antisym m" and "Total m" and "wf (m - Id)"

   132       using \<open>Well_order m\<close> by (simp_all add: order_on_defs)

   133     txt \<open>We show that the extension is a wellorder.\<close>

   134     have "Refl ?m" using \<open>Refl m\<close> Fm by (auto simp: refl_on_def)

   135     moreover have "trans ?m" using \<open>trans m\<close> \<open>x \<notin> Field m\<close>

   136       unfolding trans_def Field_def Domain_unfold Domain_converse [symmetric] by blast

   137     moreover have "antisym ?m" using \<open>antisym m\<close> \<open>x \<notin> Field m\<close>

   138       unfolding antisym_def Field_def Domain_unfold Domain_converse [symmetric] by blast

   139     moreover have "Total ?m" using \<open>Total m\<close> Fm by (auto simp: Relation.total_on_def)

   140     moreover have "wf (?m - Id)"

   141     proof -

   142       have "wf ?s" using \<open>x \<notin> Field m\<close>

   143         by (simp add: wf_eq_minimal Field_def Domain_unfold Domain_converse [symmetric]) metis

   144       thus ?thesis using \<open>wf (m - Id)\<close> \<open>x \<notin> Field m\<close>

   145         wf_subset [OF \<open>wf ?s\<close> Diff_subset]

   146         by (fastforce intro!: wf_Un simp add: Un_Diff Field_def)

   147     qed

   148     ultimately have "Well_order ?m" by (simp add: order_on_defs)

   149     moreover have "extension_on (Field ?m) ?m p"

   150       using \<open>extension_on (Field m) m p\<close> \<open>downset_on (Field m) p\<close>

   151       by (subst Fm) (auto simp: extension_on_def dest: downset_onD)

   152     moreover have "downset_on (Field ?m) p"

   153       apply (subst Fm)

   154       using \<open>downset_on (Field m) p\<close> and min

   155       unfolding downset_on_def Field_def by blast

   156     moreover have "(m, ?m) \<in> I"

   157       using \<open>Well_order m\<close> and \<open>Well_order ?m\<close> and

   158       \<open>downset_on (Field m) p\<close> and \<open>downset_on (Field ?m) p\<close> and

   159       \<open>extension_on (Field m) m p\<close> and \<open>extension_on (Field ?m) ?m p\<close> and

   160       \<open>Refl m\<close> and \<open>x \<notin> Field m\<close>

   161       by (auto simp: I_def init_seg_of_def refl_on_def)

   162     ultimately

   163     \<comment>\<open>This contradicts maximality of m:\<close>

   164     show False using max and \<open>x \<notin> Field m\<close> unfolding Field_def by blast

   165   qed

   166   have "p \<subseteq> m"

   167     using \<open>Field p \<subseteq> Field m\<close> and \<open>extension_on (Field m) m p\<close>

   168     unfolding Field_def extension_on_def by auto fast

   169   with \<open>Well_order m\<close> show ?thesis by blast

   170 qed

   171

   172 text \<open>Every well-founded relation can be extended to a total wellorder.\<close>

   173 corollary total_well_order_extension:

   174   assumes "wf p"

   175   shows "\<exists>w. p \<subseteq> w \<and> Well_order w \<and> Field w = UNIV"

   176 proof -

   177   from well_order_extension [OF assms] obtain w

   178     where "p \<subseteq> w" and wo: "Well_order w" by blast

   179   let ?A = "UNIV - Field w"

   180   from well_order_on [of ?A] obtain w' where wo': "well_order_on ?A w'" ..

   181   have [simp]: "Field w' = ?A" using well_order_on_Well_order [OF wo'] by simp

   182   have *: "Field w \<inter> Field w' = {}" by simp

   183   let ?w = "w \<union>o w'"

   184   have "p \<subseteq> ?w" using \<open>p \<subseteq> w\<close> by (auto simp: Osum_def)

   185   moreover have "Well_order ?w" using Osum_Well_order [OF * wo] and wo' by simp

   186   moreover have "Field ?w = UNIV" by (simp add: Field_Osum)

   187   ultimately show ?thesis by blast

   188 qed

   189

   190 corollary well_order_on_extension:

   191   assumes "wf p" and "Field p \<subseteq> A"

   192   shows "\<exists>w. p \<subseteq> w \<and> well_order_on A w"

   193 proof -

   194   from total_well_order_extension [OF \<open>wf p\<close>] obtain r

   195     where "p \<subseteq> r" and wo: "Well_order r" and univ: "Field r = UNIV" by blast

   196   let ?r = "{(x, y). x \<in> A \<and> y \<in> A \<and> (x, y) \<in> r}"

   197   from \<open>p \<subseteq> r\<close> have "p \<subseteq> ?r" using \<open>Field p \<subseteq> A\<close> by (auto simp: Field_def)

   198   have 1: "Field ?r = A" using wo univ

   199     by (fastforce simp: Field_def order_on_defs refl_on_def)

   200   have "Refl r" "trans r" "antisym r" "Total r" "wf (r - Id)"

   201     using \<open>Well_order r\<close> by (simp_all add: order_on_defs)

   202   have "refl_on A ?r" using \<open>Refl r\<close> by (auto simp: refl_on_def univ)

   203   moreover have "trans ?r" using \<open>trans r\<close>

   204     unfolding trans_def by blast

   205   moreover have "antisym ?r" using \<open>antisym r\<close>

   206     unfolding antisym_def by blast

   207   moreover have "total_on A ?r" using \<open>Total r\<close> by (simp add: total_on_def univ)

   208   moreover have "wf (?r - Id)" by (rule wf_subset [OF \<open>wf(r - Id)\<close>]) blast

   209   ultimately have "well_order_on A ?r" by (simp add: order_on_defs)

   210   with \<open>p \<subseteq> ?r\<close> show ?thesis by blast

   211 qed

   212

   213 end