src/HOL/Cardinals/Wellorder_Extension.thy
author wenzelm
Fri Oct 27 13:50:08 2017 +0200 (22 months ago)
changeset 66924 b4d4027f743b
parent 63167 0909deb8059b
child 67443 3abf6a722518
permissions -rw-r--r--
more permissive;
blanchet@54545
     1
(*  Title:      HOL/Cardinals/Wellorder_Extension.thy
blanchet@54545
     2
    Author:     Christian Sternagel, JAIST
blanchet@54545
     3
*)
blanchet@54545
     4
wenzelm@63167
     5
section \<open>Extending Well-founded Relations to Wellorders\<close>
blanchet@54545
     6
blanchet@54545
     7
theory Wellorder_Extension
traytel@55811
     8
imports Main Order_Union
blanchet@54545
     9
begin
blanchet@54545
    10
wenzelm@63167
    11
subsection \<open>Extending Well-founded Relations to Wellorders\<close>
blanchet@54545
    12
wenzelm@63167
    13
text \<open>A \emph{downset} (also lower set, decreasing set, initial segment, or
wenzelm@63167
    14
downward closed set) is closed w.r.t.\ smaller elements.\<close>
blanchet@54545
    15
definition downset_on where
blanchet@54545
    16
  "downset_on A r = (\<forall>x y. (x, y) \<in> r \<and> y \<in> A \<longrightarrow> x \<in> A)"
blanchet@54545
    17
blanchet@54545
    18
(*
blanchet@54545
    19
text {*Connection to order filters of the @{theory Cardinals} theory.*}
blanchet@54545
    20
lemma (in wo_rel) ofilter_downset_on_conv:
blanchet@54545
    21
  "ofilter A \<longleftrightarrow> downset_on A r \<and> A \<subseteq> Field r"
blanchet@54545
    22
  by (auto simp: downset_on_def ofilter_def under_def)
blanchet@54545
    23
*)
blanchet@54545
    24
blanchet@54545
    25
lemma downset_onI:
blanchet@54545
    26
  "(\<And>x y. (x, y) \<in> r \<Longrightarrow> y \<in> A \<Longrightarrow> x \<in> A) \<Longrightarrow> downset_on A r"
blanchet@54545
    27
  by (auto simp: downset_on_def)
blanchet@54545
    28
blanchet@54545
    29
lemma downset_onD:
blanchet@54545
    30
  "downset_on A r \<Longrightarrow> (x, y) \<in> r \<Longrightarrow> y \<in> A \<Longrightarrow> x \<in> A"
blanchet@54545
    31
  unfolding downset_on_def by blast
blanchet@54545
    32
wenzelm@63167
    33
text \<open>Extensions of relations w.r.t.\ a given set.\<close>
blanchet@54545
    34
definition extension_on where
blanchet@54545
    35
  "extension_on A r s = (\<forall>x\<in>A. \<forall>y\<in>A. (x, y) \<in> s \<longrightarrow> (x, y) \<in> r)"
blanchet@54545
    36
blanchet@54545
    37
lemma extension_onI:
blanchet@54545
    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"
blanchet@54545
    39
  by (auto simp: extension_on_def)
blanchet@54545
    40
blanchet@54545
    41
lemma extension_onD:
blanchet@54545
    42
  "extension_on A r s \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> (x, y) \<in> s \<Longrightarrow> (x, y) \<in> r"
blanchet@54545
    43
  by (auto simp: extension_on_def)
blanchet@54545
    44
blanchet@54545
    45
lemma downset_on_Union:
blanchet@54545
    46
  assumes "\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p"
blanchet@54545
    47
  shows "downset_on (Field (\<Union>R)) p"
blanchet@54545
    48
  using assms by (auto intro: downset_onI dest: downset_onD)
blanchet@54545
    49
blanchet@54545
    50
lemma chain_subset_extension_on_Union:
blanchet@54545
    51
  assumes "chain\<^sub>\<subseteq> R" and "\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p"
blanchet@54545
    52
  shows "extension_on (Field (\<Union>R)) (\<Union>R) p"
blanchet@54545
    53
  using assms
blanchet@54545
    54
  by (simp add: chain_subset_def extension_on_def)
blanchet@54545
    55
     (metis (no_types) mono_Field set_mp)
blanchet@54545
    56
blanchet@54545
    57
lemma downset_on_empty [simp]: "downset_on {} p"
blanchet@54545
    58
  by (auto simp: downset_on_def)
blanchet@54545
    59
blanchet@54545
    60
lemma extension_on_empty [simp]: "extension_on {} p q"
blanchet@54545
    61
  by (auto simp: extension_on_def)
blanchet@54545
    62
wenzelm@63167
    63
text \<open>Every well-founded relation can be extended to a wellorder.\<close>
blanchet@54545
    64
theorem well_order_extension:
blanchet@54545
    65
  assumes "wf p"
blanchet@54545
    66
  shows "\<exists>w. p \<subseteq> w \<and> Well_order w"
blanchet@54545
    67
proof -
blanchet@54545
    68
  let ?K = "{r. Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p}"
wenzelm@63040
    69
  define I where "I = init_seg_of \<inter> ?K \<times> ?K"
blanchet@54545
    70
  have I_init: "I \<subseteq> init_seg_of" by (simp add: I_def)
blanchet@54545
    71
  then have subch: "\<And>R. R \<in> Chains I \<Longrightarrow> chain\<^sub>\<subseteq> R"
blanchet@54545
    72
    by (auto simp: init_seg_of_def chain_subset_def Chains_def)
blanchet@54545
    73
  have Chains_wo: "\<And>R r. R \<in> Chains I \<Longrightarrow> r \<in> R \<Longrightarrow>
blanchet@54545
    74
      Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p"
blanchet@54545
    75
    by (simp add: Chains_def I_def) blast
blanchet@54545
    76
  have FI: "Field I = ?K" by (auto simp: I_def init_seg_of_def Field_def)
blanchet@54545
    77
  then have 0: "Partial_order I"
blanchet@54545
    78
    by (auto simp: partial_order_on_def preorder_on_def antisym_def antisym_init_seg_of refl_on_def
blanchet@54545
    79
      trans_def I_def elim: trans_init_seg_of)
blanchet@54545
    80
  { fix R assume "R \<in> Chains I"
blanchet@54545
    81
    then have Ris: "R \<in> Chains init_seg_of" using mono_Chains [OF I_init] by blast
wenzelm@63167
    82
    have subch: "chain\<^sub>\<subseteq> R" using \<open>R \<in> Chains I\<close> I_init
blanchet@54545
    83
      by (auto simp: init_seg_of_def chain_subset_def Chains_def)
blanchet@54545
    84
    have "\<forall>r\<in>R. Refl r" and "\<forall>r\<in>R. trans r" and "\<forall>r\<in>R. antisym r" and
blanchet@54545
    85
      "\<forall>r\<in>R. Total r" and "\<forall>r\<in>R. wf (r - Id)" and
blanchet@54545
    86
      "\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p" and
blanchet@54545
    87
      "\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p"
wenzelm@63167
    88
      using Chains_wo [OF \<open>R \<in> Chains I\<close>] by (simp_all add: order_on_defs)
wenzelm@63167
    89
    have "Refl (\<Union>R)" using \<open>\<forall>r\<in>R. Refl r\<close>  unfolding refl_on_def by fastforce
blanchet@54545
    90
    moreover have "trans (\<Union>R)"
wenzelm@63167
    91
      by (rule chain_subset_trans_Union [OF subch \<open>\<forall>r\<in>R. trans r\<close>])
blanchet@54545
    92
    moreover have "antisym (\<Union>R)"
wenzelm@63167
    93
      by (rule chain_subset_antisym_Union [OF subch \<open>\<forall>r\<in>R. antisym r\<close>])
blanchet@54545
    94
    moreover have "Total (\<Union>R)"
wenzelm@63167
    95
      by (rule chain_subset_Total_Union [OF subch \<open>\<forall>r\<in>R. Total r\<close>])
blanchet@54545
    96
    moreover have "wf ((\<Union>R) - Id)"
blanchet@54545
    97
    proof -
blanchet@54545
    98
      have "(\<Union>R) - Id = \<Union>{r - Id | r. r \<in> R}" by blast
wenzelm@63167
    99
      with \<open>\<forall>r\<in>R. wf (r - Id)\<close> wf_Union_wf_init_segs [OF Chains_inits_DiffI [OF Ris]]
blanchet@54545
   100
      show ?thesis by fastforce
blanchet@54545
   101
    qed
blanchet@54545
   102
    ultimately have "Well_order (\<Union>R)" by (simp add: order_on_defs)
blanchet@54545
   103
    moreover have "\<forall>r\<in>R. r initial_segment_of \<Union>R" using Ris
blanchet@54545
   104
      by (simp add: Chains_init_seg_of_Union)
blanchet@54545
   105
    moreover have "downset_on (Field (\<Union>R)) p"
wenzelm@63167
   106
      by (rule downset_on_Union [OF \<open>\<And>r. r \<in> R \<Longrightarrow> downset_on (Field r) p\<close>])
blanchet@54545
   107
    moreover have "extension_on (Field (\<Union>R)) (\<Union>R) p"
wenzelm@63167
   108
      by (rule chain_subset_extension_on_Union [OF subch \<open>\<And>r. r \<in> R \<Longrightarrow> extension_on (Field r) r p\<close>])
blanchet@54545
   109
    ultimately have "\<Union>R \<in> ?K \<and> (\<forall>r\<in>R. (r,\<Union>R) \<in> I)"
wenzelm@63167
   110
      using mono_Chains [OF I_init] and \<open>R \<in> Chains I\<close>
blanchet@54545
   111
      by (simp (no_asm) add: I_def del: Field_Union) (metis Chains_wo)
blanchet@54545
   112
  }
blanchet@54545
   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
wenzelm@63167
   114
  txt \<open>Zorn's Lemma yields a maximal wellorder m.\<close>
blanchet@54545
   115
  from Zorns_po_lemma [OF 0 1] obtain m :: "('a \<times> 'a) set"
blanchet@54545
   116
    where "Well_order m" and "downset_on (Field m) p" and "extension_on (Field m) m p" and
blanchet@54545
   117
    max: "\<forall>r. Well_order r \<and> downset_on (Field r) p \<and> extension_on (Field r) r p \<and>
blanchet@54545
   118
      (m, r) \<in> I \<longrightarrow> r = m"
blanchet@54545
   119
    by (auto simp: FI)
blanchet@54545
   120
  have "Field p \<subseteq> Field m"
blanchet@54545
   121
  proof (rule ccontr)
blanchet@54545
   122
    let ?Q = "Field p - Field m"
blanchet@54545
   123
    assume "\<not> (Field p \<subseteq> Field m)"
blanchet@54545
   124
    with assms [unfolded wf_eq_minimal, THEN spec, of ?Q]
blanchet@54545
   125
      obtain x where "x \<in> Field p" and "x \<notin> Field m" and
blanchet@54545
   126
      min: "\<forall>y. (y, x) \<in> p \<longrightarrow> y \<notin> ?Q" by blast
wenzelm@63167
   127
    txt \<open>Add @{term x} as topmost element to @{term m}.\<close>
blanchet@54545
   128
    let ?s = "{(y, x) | y. y \<in> Field m}"
blanchet@54545
   129
    let ?m = "insert (x, x) m \<union> ?s"
blanchet@54545
   130
    have Fm: "Field ?m = insert x (Field m)" by (auto simp: Field_def)
blanchet@54545
   131
    have "Refl m" and "trans m" and "antisym m" and "Total m" and "wf (m - Id)"
wenzelm@63167
   132
      using \<open>Well_order m\<close> by (simp_all add: order_on_defs)
wenzelm@63167
   133
    txt \<open>We show that the extension is a wellorder.\<close>
wenzelm@63167
   134
    have "Refl ?m" using \<open>Refl m\<close> Fm by (auto simp: refl_on_def)
wenzelm@63167
   135
    moreover have "trans ?m" using \<open>trans m\<close> \<open>x \<notin> Field m\<close>
blanchet@54545
   136
      unfolding trans_def Field_def Domain_unfold Domain_converse [symmetric] by blast
wenzelm@63167
   137
    moreover have "antisym ?m" using \<open>antisym m\<close> \<open>x \<notin> Field m\<close>
blanchet@54545
   138
      unfolding antisym_def Field_def Domain_unfold Domain_converse [symmetric] by blast
wenzelm@63167
   139
    moreover have "Total ?m" using \<open>Total m\<close> Fm by (auto simp: Relation.total_on_def)
blanchet@54545
   140
    moreover have "wf (?m - Id)"
blanchet@54545
   141
    proof -
wenzelm@63167
   142
      have "wf ?s" using \<open>x \<notin> Field m\<close>
blanchet@54545
   143
        by (simp add: wf_eq_minimal Field_def Domain_unfold Domain_converse [symmetric]) metis
wenzelm@63167
   144
      thus ?thesis using \<open>wf (m - Id)\<close> \<open>x \<notin> Field m\<close>
wenzelm@63167
   145
        wf_subset [OF \<open>wf ?s\<close> Diff_subset]
blanchet@54545
   146
        by (fastforce intro!: wf_Un simp add: Un_Diff Field_def)
blanchet@54545
   147
    qed
blanchet@54545
   148
    ultimately have "Well_order ?m" by (simp add: order_on_defs)
blanchet@54545
   149
    moreover have "extension_on (Field ?m) ?m p"
wenzelm@63167
   150
      using \<open>extension_on (Field m) m p\<close> \<open>downset_on (Field m) p\<close>
blanchet@54545
   151
      by (subst Fm) (auto simp: extension_on_def dest: downset_onD)
blanchet@54545
   152
    moreover have "downset_on (Field ?m) p"
blanchet@54545
   153
      apply (subst Fm)
wenzelm@63167
   154
      using \<open>downset_on (Field m) p\<close> and min
blanchet@54545
   155
      unfolding downset_on_def Field_def by blast
blanchet@54545
   156
    moreover have "(m, ?m) \<in> I"
wenzelm@63167
   157
      using \<open>Well_order m\<close> and \<open>Well_order ?m\<close> and
wenzelm@63167
   158
      \<open>downset_on (Field m) p\<close> and \<open>downset_on (Field ?m) p\<close> and
wenzelm@63167
   159
      \<open>extension_on (Field m) m p\<close> and \<open>extension_on (Field ?m) ?m p\<close> and
wenzelm@63167
   160
      \<open>Refl m\<close> and \<open>x \<notin> Field m\<close>
blanchet@54545
   161
      by (auto simp: I_def init_seg_of_def refl_on_def)
blanchet@54545
   162
    ultimately
wenzelm@63167
   163
    \<comment>\<open>This contradicts maximality of m:\<close>
wenzelm@63167
   164
    show False using max and \<open>x \<notin> Field m\<close> unfolding Field_def by blast
blanchet@54545
   165
  qed
blanchet@54545
   166
  have "p \<subseteq> m"
wenzelm@63167
   167
    using \<open>Field p \<subseteq> Field m\<close> and \<open>extension_on (Field m) m p\<close>
blanchet@54545
   168
    unfolding Field_def extension_on_def by auto fast
wenzelm@63167
   169
  with \<open>Well_order m\<close> show ?thesis by blast
blanchet@54545
   170
qed
blanchet@54545
   171
wenzelm@63167
   172
text \<open>Every well-founded relation can be extended to a total wellorder.\<close>
blanchet@54545
   173
corollary total_well_order_extension:
blanchet@54545
   174
  assumes "wf p"
blanchet@54545
   175
  shows "\<exists>w. p \<subseteq> w \<and> Well_order w \<and> Field w = UNIV"
blanchet@54545
   176
proof -
blanchet@54545
   177
  from well_order_extension [OF assms] obtain w
blanchet@54545
   178
    where "p \<subseteq> w" and wo: "Well_order w" by blast
blanchet@54545
   179
  let ?A = "UNIV - Field w"
blanchet@54545
   180
  from well_order_on [of ?A] obtain w' where wo': "well_order_on ?A w'" ..
blanchet@55023
   181
  have [simp]: "Field w' = ?A" using well_order_on_Well_order [OF wo'] by simp
blanchet@54545
   182
  have *: "Field w \<inter> Field w' = {}" by simp
blanchet@54545
   183
  let ?w = "w \<union>o w'"
wenzelm@63167
   184
  have "p \<subseteq> ?w" using \<open>p \<subseteq> w\<close> by (auto simp: Osum_def)
blanchet@54545
   185
  moreover have "Well_order ?w" using Osum_Well_order [OF * wo] and wo' by simp
blanchet@54545
   186
  moreover have "Field ?w = UNIV" by (simp add: Field_Osum)
blanchet@54545
   187
  ultimately show ?thesis by blast
blanchet@54545
   188
qed
blanchet@54545
   189
blanchet@54545
   190
corollary well_order_on_extension:
blanchet@54545
   191
  assumes "wf p" and "Field p \<subseteq> A"
blanchet@54545
   192
  shows "\<exists>w. p \<subseteq> w \<and> well_order_on A w"
blanchet@54545
   193
proof -
wenzelm@63167
   194
  from total_well_order_extension [OF \<open>wf p\<close>] obtain r
blanchet@54545
   195
    where "p \<subseteq> r" and wo: "Well_order r" and univ: "Field r = UNIV" by blast
blanchet@54545
   196
  let ?r = "{(x, y). x \<in> A \<and> y \<in> A \<and> (x, y) \<in> r}"
wenzelm@63167
   197
  from \<open>p \<subseteq> r\<close> have "p \<subseteq> ?r" using \<open>Field p \<subseteq> A\<close> by (auto simp: Field_def)
blanchet@54545
   198
  have 1: "Field ?r = A" using wo univ
blanchet@54545
   199
    by (fastforce simp: Field_def order_on_defs refl_on_def)
blanchet@54545
   200
  have "Refl r" "trans r" "antisym r" "Total r" "wf (r - Id)"
wenzelm@63167
   201
    using \<open>Well_order r\<close> by (simp_all add: order_on_defs)
wenzelm@63167
   202
  have "refl_on A ?r" using \<open>Refl r\<close> by (auto simp: refl_on_def univ)
wenzelm@63167
   203
  moreover have "trans ?r" using \<open>trans r\<close>
blanchet@54545
   204
    unfolding trans_def by blast
wenzelm@63167
   205
  moreover have "antisym ?r" using \<open>antisym r\<close>
blanchet@54545
   206
    unfolding antisym_def by blast
wenzelm@63167
   207
  moreover have "total_on A ?r" using \<open>Total r\<close> by (simp add: total_on_def univ)
wenzelm@63167
   208
  moreover have "wf (?r - Id)" by (rule wf_subset [OF \<open>wf(r - Id)\<close>]) blast
blanchet@54545
   209
  ultimately have "well_order_on A ?r" by (simp add: order_on_defs)
wenzelm@63167
   210
  with \<open>p \<subseteq> ?r\<close> show ?thesis by blast
blanchet@54545
   211
qed
blanchet@54545
   212
blanchet@54545
   213
end