src/HOL/Library/Order_Union.thy
changeset 56013 d64a4ef26edb
parent 56012 cfb21e03fe2a
parent 56008 30666a281ae3
child 56014 748778ac0ab8
     1.1 --- a/src/HOL/Library/Order_Union.thy	Thu Dec 05 17:52:12 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,376 +0,0 @@
     1.4 -(*  Title:      HOL/Library/Order_Union.thy
     1.5 -    Author:     Andrei Popescu, TU Muenchen
     1.6 -
     1.7 -The ordinal-like sum of two orders with disjoint fields
     1.8 -*)
     1.9 -
    1.10 -header {* Order Union *}
    1.11 -
    1.12 -theory Order_Union
    1.13 -imports "~~/src/HOL/Cardinals/Wellfounded_More_Base" 
    1.14 -begin
    1.15 -
    1.16 -definition Osum :: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel"  (infix "Osum" 60) where
    1.17 -  "r Osum r' = r \<union> r' \<union> {(a, a'). a \<in> Field r \<and> a' \<in> Field r'}"
    1.18 -
    1.19 -notation Osum  (infix "\<union>o" 60)
    1.20 -
    1.21 -lemma Field_Osum: "Field (r \<union>o r') = Field r \<union> Field r'"
    1.22 -  unfolding Osum_def Field_def by blast
    1.23 -
    1.24 -lemma Osum_wf:
    1.25 -assumes FLD: "Field r Int Field r' = {}" and
    1.26 -        WF: "wf r" and WF': "wf r'"
    1.27 -shows "wf (r Osum r')"
    1.28 -unfolding wf_eq_minimal2 unfolding Field_Osum
    1.29 -proof(intro allI impI, elim conjE)
    1.30 -  fix A assume *: "A \<subseteq> Field r \<union> Field r'" and **: "A \<noteq> {}"
    1.31 -  obtain B where B_def: "B = A Int Field r" by blast
    1.32 -  show "\<exists>a\<in>A. \<forall>a'\<in>A. (a', a) \<notin> r \<union>o r'"
    1.33 -  proof(cases "B = {}")
    1.34 -    assume Case1: "B \<noteq> {}"
    1.35 -    hence "B \<noteq> {} \<and> B \<le> Field r" using B_def by auto
    1.36 -    then obtain a where 1: "a \<in> B" and 2: "\<forall>a1 \<in> B. (a1,a) \<notin> r"
    1.37 -    using WF  unfolding wf_eq_minimal2 by blast
    1.38 -    hence 3: "a \<in> Field r \<and> a \<notin> Field r'" using B_def FLD by auto
    1.39 -    (*  *)
    1.40 -    have "\<forall>a1 \<in> A. (a1,a) \<notin> r Osum r'"
    1.41 -    proof(intro ballI)
    1.42 -      fix a1 assume **: "a1 \<in> A"
    1.43 -      {assume Case11: "a1 \<in> Field r"
    1.44 -       hence "(a1,a) \<notin> r" using B_def ** 2 by auto
    1.45 -       moreover
    1.46 -       have "(a1,a) \<notin> r'" using 3 by (auto simp add: Field_def)
    1.47 -       ultimately have "(a1,a) \<notin> r Osum r'"
    1.48 -       using 3 unfolding Osum_def by auto
    1.49 -      }
    1.50 -      moreover
    1.51 -      {assume Case12: "a1 \<notin> Field r"
    1.52 -       hence "(a1,a) \<notin> r" unfolding Field_def by auto
    1.53 -       moreover
    1.54 -       have "(a1,a) \<notin> r'" using 3 unfolding Field_def by auto
    1.55 -       ultimately have "(a1,a) \<notin> r Osum r'"
    1.56 -       using 3 unfolding Osum_def by auto
    1.57 -      }
    1.58 -      ultimately show "(a1,a) \<notin> r Osum r'" by blast
    1.59 -    qed
    1.60 -    thus ?thesis using 1 B_def by auto
    1.61 -  next
    1.62 -    assume Case2: "B = {}"
    1.63 -    hence 1: "A \<noteq> {} \<and> A \<le> Field r'" using * ** B_def by auto
    1.64 -    then obtain a' where 2: "a' \<in> A" and 3: "\<forall>a1' \<in> A. (a1',a') \<notin> r'"
    1.65 -    using WF' unfolding wf_eq_minimal2 by blast
    1.66 -    hence 4: "a' \<in> Field r' \<and> a' \<notin> Field r" using 1 FLD by blast
    1.67 -    (*  *)
    1.68 -    have "\<forall>a1' \<in> A. (a1',a') \<notin> r Osum r'"
    1.69 -    proof(unfold Osum_def, auto simp add: 3)
    1.70 -      fix a1' assume "(a1', a') \<in> r"
    1.71 -      thus False using 4 unfolding Field_def by blast
    1.72 -    next
    1.73 -      fix a1' assume "a1' \<in> A" and "a1' \<in> Field r"
    1.74 -      thus False using Case2 B_def by auto
    1.75 -    qed
    1.76 -    thus ?thesis using 2 by blast
    1.77 -  qed
    1.78 -qed
    1.79 -
    1.80 -lemma Osum_Refl:
    1.81 -assumes FLD: "Field r Int Field r' = {}" and
    1.82 -        REFL: "Refl r" and REFL': "Refl r'"
    1.83 -shows "Refl (r Osum r')"
    1.84 -using assms 
    1.85 -unfolding refl_on_def Field_Osum unfolding Osum_def by blast
    1.86 -
    1.87 -lemma Osum_trans:
    1.88 -assumes FLD: "Field r Int Field r' = {}" and
    1.89 -        TRANS: "trans r" and TRANS': "trans r'"
    1.90 -shows "trans (r Osum r')"
    1.91 -proof(unfold trans_def, auto)
    1.92 -  fix x y z assume *: "(x, y) \<in> r \<union>o r'" and **: "(y, z) \<in> r \<union>o r'"
    1.93 -  show  "(x, z) \<in> r \<union>o r'"
    1.94 -  proof-
    1.95 -    {assume Case1: "(x,y) \<in> r"
    1.96 -     hence 1: "x \<in> Field r \<and> y \<in> Field r" unfolding Field_def by auto
    1.97 -     have ?thesis
    1.98 -     proof-
    1.99 -       {assume Case11: "(y,z) \<in> r"
   1.100 -        hence "(x,z) \<in> r" using Case1 TRANS trans_def[of r] by blast
   1.101 -        hence ?thesis unfolding Osum_def by auto
   1.102 -       }
   1.103 -       moreover
   1.104 -       {assume Case12: "(y,z) \<in> r'"
   1.105 -        hence "y \<in> Field r'" unfolding Field_def by auto
   1.106 -        hence False using FLD 1 by auto
   1.107 -       }
   1.108 -       moreover
   1.109 -       {assume Case13: "z \<in> Field r'"
   1.110 -        hence ?thesis using 1 unfolding Osum_def by auto
   1.111 -       }
   1.112 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.113 -     qed
   1.114 -    }
   1.115 -    moreover
   1.116 -    {assume Case2: "(x,y) \<in> r'"
   1.117 -     hence 2: "x \<in> Field r' \<and> y \<in> Field r'" unfolding Field_def by auto
   1.118 -     have ?thesis
   1.119 -     proof-
   1.120 -       {assume Case21: "(y,z) \<in> r"
   1.121 -        hence "y \<in> Field r" unfolding Field_def by auto
   1.122 -        hence False using FLD 2 by auto
   1.123 -       }
   1.124 -       moreover
   1.125 -       {assume Case22: "(y,z) \<in> r'"
   1.126 -        hence "(x,z) \<in> r'" using Case2 TRANS' trans_def[of r'] by blast
   1.127 -        hence ?thesis unfolding Osum_def by auto
   1.128 -       }
   1.129 -       moreover
   1.130 -       {assume Case23: "y \<in> Field r"
   1.131 -        hence False using FLD 2 by auto
   1.132 -       }
   1.133 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.134 -     qed
   1.135 -    }
   1.136 -    moreover
   1.137 -    {assume Case3: "x \<in> Field r \<and> y \<in> Field r'"
   1.138 -     have ?thesis
   1.139 -     proof-
   1.140 -       {assume Case31: "(y,z) \<in> r"
   1.141 -        hence "y \<in> Field r" unfolding Field_def by auto
   1.142 -        hence False using FLD Case3 by auto
   1.143 -       }
   1.144 -       moreover
   1.145 -       {assume Case32: "(y,z) \<in> r'"
   1.146 -        hence "z \<in> Field r'" unfolding Field_def by blast
   1.147 -        hence ?thesis unfolding Osum_def using Case3 by auto
   1.148 -       }
   1.149 -       moreover
   1.150 -       {assume Case33: "y \<in> Field r"
   1.151 -        hence False using FLD Case3 by auto
   1.152 -       }
   1.153 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.154 -     qed
   1.155 -    }
   1.156 -    ultimately show ?thesis using * unfolding Osum_def by blast
   1.157 -  qed
   1.158 -qed
   1.159 -
   1.160 -lemma Osum_Preorder:
   1.161 -"\<lbrakk>Field r Int Field r' = {}; Preorder r; Preorder r'\<rbrakk> \<Longrightarrow> Preorder (r Osum r')"
   1.162 -unfolding preorder_on_def using Osum_Refl Osum_trans by blast
   1.163 -
   1.164 -lemma Osum_antisym:
   1.165 -assumes FLD: "Field r Int Field r' = {}" and
   1.166 -        AN: "antisym r" and AN': "antisym r'"
   1.167 -shows "antisym (r Osum r')"
   1.168 -proof(unfold antisym_def, auto)
   1.169 -  fix x y assume *: "(x, y) \<in> r \<union>o r'" and **: "(y, x) \<in> r \<union>o r'"
   1.170 -  show  "x = y"
   1.171 -  proof-
   1.172 -    {assume Case1: "(x,y) \<in> r"
   1.173 -     hence 1: "x \<in> Field r \<and> y \<in> Field r" unfolding Field_def by auto
   1.174 -     have ?thesis
   1.175 -     proof-
   1.176 -       have "(y,x) \<in> r \<Longrightarrow> ?thesis"
   1.177 -       using Case1 AN antisym_def[of r] by blast
   1.178 -       moreover
   1.179 -       {assume "(y,x) \<in> r'"
   1.180 -        hence "y \<in> Field r'" unfolding Field_def by auto
   1.181 -        hence False using FLD 1 by auto
   1.182 -       }
   1.183 -       moreover
   1.184 -       have "x \<in> Field r' \<Longrightarrow> False" using FLD 1 by auto
   1.185 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.186 -     qed
   1.187 -    }
   1.188 -    moreover
   1.189 -    {assume Case2: "(x,y) \<in> r'"
   1.190 -     hence 2: "x \<in> Field r' \<and> y \<in> Field r'" unfolding Field_def by auto
   1.191 -     have ?thesis
   1.192 -     proof-
   1.193 -       {assume "(y,x) \<in> r"
   1.194 -        hence "y \<in> Field r" unfolding Field_def by auto
   1.195 -        hence False using FLD 2 by auto
   1.196 -       }
   1.197 -       moreover
   1.198 -       have "(y,x) \<in> r' \<Longrightarrow> ?thesis"
   1.199 -       using Case2 AN' antisym_def[of r'] by blast
   1.200 -       moreover
   1.201 -       {assume "y \<in> Field r"
   1.202 -        hence False using FLD 2 by auto
   1.203 -       }
   1.204 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.205 -     qed
   1.206 -    }
   1.207 -    moreover
   1.208 -    {assume Case3: "x \<in> Field r \<and> y \<in> Field r'"
   1.209 -     have ?thesis
   1.210 -     proof-
   1.211 -       {assume "(y,x) \<in> r"
   1.212 -        hence "y \<in> Field r" unfolding Field_def by auto
   1.213 -        hence False using FLD Case3 by auto
   1.214 -       }
   1.215 -       moreover
   1.216 -       {assume Case32: "(y,x) \<in> r'"
   1.217 -        hence "x \<in> Field r'" unfolding Field_def by blast
   1.218 -        hence False using FLD Case3 by auto
   1.219 -       }
   1.220 -       moreover
   1.221 -       have "\<not> y \<in> Field r" using FLD Case3 by auto
   1.222 -       ultimately show ?thesis using ** unfolding Osum_def by blast
   1.223 -     qed
   1.224 -    }
   1.225 -    ultimately show ?thesis using * unfolding Osum_def by blast
   1.226 -  qed
   1.227 -qed
   1.228 -
   1.229 -lemma Osum_Partial_order:
   1.230 -"\<lbrakk>Field r Int Field r' = {}; Partial_order r; Partial_order r'\<rbrakk> \<Longrightarrow>
   1.231 - Partial_order (r Osum r')"
   1.232 -unfolding partial_order_on_def using Osum_Preorder Osum_antisym by blast
   1.233 -
   1.234 -lemma Osum_Total:
   1.235 -assumes FLD: "Field r Int Field r' = {}" and
   1.236 -        TOT: "Total r" and TOT': "Total r'"
   1.237 -shows "Total (r Osum r')"
   1.238 -using assms
   1.239 -unfolding total_on_def  Field_Osum unfolding Osum_def by blast
   1.240 -
   1.241 -lemma Osum_Linear_order:
   1.242 -"\<lbrakk>Field r Int Field r' = {}; Linear_order r; Linear_order r'\<rbrakk> \<Longrightarrow>
   1.243 - Linear_order (r Osum r')"
   1.244 -unfolding linear_order_on_def using Osum_Partial_order Osum_Total by blast
   1.245 -
   1.246 -lemma Osum_minus_Id1:
   1.247 -assumes "r \<le> Id"
   1.248 -shows "(r Osum r') - Id \<le> (r' - Id) \<union> (Field r \<times> Field r')"
   1.249 -proof-
   1.250 -  let ?Left = "(r Osum r') - Id"
   1.251 -  let ?Right = "(r' - Id) \<union> (Field r \<times> Field r')"
   1.252 -  {fix a::'a and b assume *: "(a,b) \<notin> Id"
   1.253 -   {assume "(a,b) \<in> r"
   1.254 -    with * have False using assms by auto
   1.255 -   }
   1.256 -   moreover
   1.257 -   {assume "(a,b) \<in> r'"
   1.258 -    with * have "(a,b) \<in> r' - Id" by auto
   1.259 -   }
   1.260 -   ultimately
   1.261 -   have "(a,b) \<in> ?Left \<Longrightarrow> (a,b) \<in> ?Right"
   1.262 -   unfolding Osum_def by auto
   1.263 -  }
   1.264 -  thus ?thesis by auto
   1.265 -qed
   1.266 -
   1.267 -lemma Osum_minus_Id2:
   1.268 -assumes "r' \<le> Id"
   1.269 -shows "(r Osum r') - Id \<le> (r - Id) \<union> (Field r \<times> Field r')"
   1.270 -proof-
   1.271 -  let ?Left = "(r Osum r') - Id"
   1.272 -  let ?Right = "(r - Id) \<union> (Field r \<times> Field r')"
   1.273 -  {fix a::'a and b assume *: "(a,b) \<notin> Id"
   1.274 -   {assume "(a,b) \<in> r'"
   1.275 -    with * have False using assms by auto
   1.276 -   }
   1.277 -   moreover
   1.278 -   {assume "(a,b) \<in> r"
   1.279 -    with * have "(a,b) \<in> r - Id" by auto
   1.280 -   }
   1.281 -   ultimately
   1.282 -   have "(a,b) \<in> ?Left \<Longrightarrow> (a,b) \<in> ?Right"
   1.283 -   unfolding Osum_def by auto
   1.284 -  }
   1.285 -  thus ?thesis by auto
   1.286 -qed
   1.287 -
   1.288 -lemma Osum_minus_Id:
   1.289 -assumes TOT: "Total r" and TOT': "Total r'" and
   1.290 -        NID: "\<not> (r \<le> Id)" and NID': "\<not> (r' \<le> Id)"
   1.291 -shows "(r Osum r') - Id \<le> (r - Id) Osum (r' - Id)"
   1.292 -proof-
   1.293 -  {fix a a' assume *: "(a,a') \<in> (r Osum r')" and **: "a \<noteq> a'"
   1.294 -   have "(a,a') \<in> (r - Id) Osum (r' - Id)"
   1.295 -   proof-
   1.296 -     {assume "(a,a') \<in> r \<or> (a,a') \<in> r'"
   1.297 -      with ** have ?thesis unfolding Osum_def by auto
   1.298 -     }
   1.299 -     moreover
   1.300 -     {assume "a \<in> Field r \<and> a' \<in> Field r'"
   1.301 -      hence "a \<in> Field(r - Id) \<and> a' \<in> Field (r' - Id)"
   1.302 -      using assms Total_Id_Field by blast
   1.303 -      hence ?thesis unfolding Osum_def by auto
   1.304 -     }
   1.305 -     ultimately show ?thesis using * unfolding Osum_def by blast
   1.306 -   qed
   1.307 -  }
   1.308 -  thus ?thesis by(auto simp add: Osum_def)
   1.309 -qed
   1.310 -
   1.311 -lemma wf_Int_Times:
   1.312 -assumes "A Int B = {}"
   1.313 -shows "wf(A \<times> B)"
   1.314 -proof(unfold wf_def, auto)
   1.315 -  fix P x
   1.316 -  assume *: "\<forall>x. (\<forall>y. y \<in> A \<and> x \<in> B \<longrightarrow> P y) \<longrightarrow> P x"
   1.317 -  moreover have "\<forall>y \<in> A. P y" using assms * by blast
   1.318 -  ultimately show "P x" using * by (case_tac "x \<in> B", auto)
   1.319 -qed
   1.320 -
   1.321 -lemma Osum_wf_Id:
   1.322 -assumes TOT: "Total r" and TOT': "Total r'" and
   1.323 -        FLD: "Field r Int Field r' = {}" and
   1.324 -        WF: "wf(r - Id)" and WF': "wf(r' - Id)"
   1.325 -shows "wf ((r Osum r') - Id)"
   1.326 -proof(cases "r \<le> Id \<or> r' \<le> Id")
   1.327 -  assume Case1: "\<not>(r \<le> Id \<or> r' \<le> Id)"
   1.328 -  have "Field(r - Id) Int Field(r' - Id) = {}"
   1.329 -  using FLD mono_Field[of "r - Id" r]  mono_Field[of "r' - Id" r']
   1.330 -            Diff_subset[of r Id] Diff_subset[of r' Id] by blast
   1.331 -  thus ?thesis
   1.332 -  using Case1 Osum_minus_Id[of r r'] assms Osum_wf[of "r - Id" "r' - Id"]
   1.333 -        wf_subset[of "(r - Id) \<union>o (r' - Id)" "(r Osum r') - Id"] by auto
   1.334 -next
   1.335 -  have 1: "wf(Field r \<times> Field r')"
   1.336 -  using FLD by (auto simp add: wf_Int_Times)
   1.337 -  assume Case2: "r \<le> Id \<or> r' \<le> Id"
   1.338 -  moreover
   1.339 -  {assume Case21: "r \<le> Id"
   1.340 -   hence "(r Osum r') - Id \<le> (r' - Id) \<union> (Field r \<times> Field r')"
   1.341 -   using Osum_minus_Id1[of r r'] by simp
   1.342 -   moreover
   1.343 -   {have "Domain(Field r \<times> Field r') Int Range(r' - Id) = {}"
   1.344 -    using FLD unfolding Field_def by blast
   1.345 -    hence "wf((r' - Id) \<union> (Field r \<times> Field r'))"
   1.346 -    using 1 WF' wf_Un[of "Field r \<times> Field r'" "r' - Id"]
   1.347 -    by (auto simp add: Un_commute)
   1.348 -   }
   1.349 -   ultimately have ?thesis by (auto simp add: wf_subset)
   1.350 -  }
   1.351 -  moreover
   1.352 -  {assume Case22: "r' \<le> Id"
   1.353 -   hence "(r Osum r') - Id \<le> (r - Id) \<union> (Field r \<times> Field r')"
   1.354 -   using Osum_minus_Id2[of r' r] by simp
   1.355 -   moreover
   1.356 -   {have "Range(Field r \<times> Field r') Int Domain(r - Id) = {}"
   1.357 -    using FLD unfolding Field_def by blast
   1.358 -    hence "wf((r - Id) \<union> (Field r \<times> Field r'))"
   1.359 -    using 1 WF wf_Un[of "r - Id" "Field r \<times> Field r'"]
   1.360 -    by (auto simp add: Un_commute)
   1.361 -   }
   1.362 -   ultimately have ?thesis by (auto simp add: wf_subset)
   1.363 -  }
   1.364 -  ultimately show ?thesis by blast
   1.365 -qed
   1.366 -
   1.367 -lemma Osum_Well_order:
   1.368 -assumes FLD: "Field r Int Field r' = {}" and
   1.369 -        WELL: "Well_order r" and WELL': "Well_order r'"
   1.370 -shows "Well_order (r Osum r')"
   1.371 -proof-
   1.372 -  have "Total r \<and> Total r'" using WELL WELL'
   1.373 -  by (auto simp add: order_on_defs)
   1.374 -  thus ?thesis using assms unfolding well_order_on_def
   1.375 -  using Osum_Linear_order Osum_wf_Id by blast
   1.376 -qed
   1.377 -
   1.378 -end
   1.379 -