src/HOL/Cardinals/Order_Union.thy
author wenzelm
Tue Sep 26 20:54:40 2017 +0200 (23 months ago)
changeset 66695 91500c024c7f
parent 66453 cc19f7ca2ed6
child 67006 b1278ed3cd46
permissions -rw-r--r--
tuned;
blanchet@54545
     1
(*  Title:      HOL/Cardinals/Order_Union.thy
popescua@52184
     2
    Author:     Andrei Popescu, TU Muenchen
popescua@52184
     3
popescua@52199
     4
The ordinal-like sum of two orders with disjoint fields
popescua@52184
     5
*)
popescua@52184
     6
wenzelm@63167
     7
section \<open>Order Union\<close>
popescua@52184
     8
popescua@52184
     9
theory Order_Union
wenzelm@66453
    10
imports HOL.Order_Relation
popescua@52184
    11
begin
popescua@52184
    12
popescua@52184
    13
definition Osum :: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel"  (infix "Osum" 60) where
popescua@52184
    14
  "r Osum r' = r \<union> r' \<union> {(a, a'). a \<in> Field r \<and> a' \<in> Field r'}"
popescua@52184
    15
wenzelm@52191
    16
notation Osum  (infix "\<union>o" 60)
popescua@52184
    17
popescua@52184
    18
lemma Field_Osum: "Field (r \<union>o r') = Field r \<union> Field r'"
popescua@52184
    19
  unfolding Osum_def Field_def by blast
popescua@52184
    20
popescua@52184
    21
lemma Osum_wf:
popescua@52184
    22
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
    23
        WF: "wf r" and WF': "wf r'"
popescua@52184
    24
shows "wf (r Osum r')"
popescua@52184
    25
unfolding wf_eq_minimal2 unfolding Field_Osum
popescua@52184
    26
proof(intro allI impI, elim conjE)
popescua@52184
    27
  fix A assume *: "A \<subseteq> Field r \<union> Field r'" and **: "A \<noteq> {}"
popescua@52184
    28
  obtain B where B_def: "B = A Int Field r" by blast
popescua@52184
    29
  show "\<exists>a\<in>A. \<forall>a'\<in>A. (a', a) \<notin> r \<union>o r'"
popescua@52184
    30
  proof(cases "B = {}")
popescua@52184
    31
    assume Case1: "B \<noteq> {}"
popescua@52184
    32
    hence "B \<noteq> {} \<and> B \<le> Field r" using B_def by auto
popescua@52184
    33
    then obtain a where 1: "a \<in> B" and 2: "\<forall>a1 \<in> B. (a1,a) \<notin> r"
blanchet@55021
    34
    using WF unfolding wf_eq_minimal2 by blast
popescua@52184
    35
    hence 3: "a \<in> Field r \<and> a \<notin> Field r'" using B_def FLD by auto
popescua@52184
    36
    (*  *)
popescua@52184
    37
    have "\<forall>a1 \<in> A. (a1,a) \<notin> r Osum r'"
popescua@52184
    38
    proof(intro ballI)
popescua@52184
    39
      fix a1 assume **: "a1 \<in> A"
popescua@52184
    40
      {assume Case11: "a1 \<in> Field r"
popescua@52184
    41
       hence "(a1,a) \<notin> r" using B_def ** 2 by auto
popescua@52184
    42
       moreover
popescua@52184
    43
       have "(a1,a) \<notin> r'" using 3 by (auto simp add: Field_def)
popescua@52184
    44
       ultimately have "(a1,a) \<notin> r Osum r'"
popescua@52184
    45
       using 3 unfolding Osum_def by auto
popescua@52184
    46
      }
popescua@52184
    47
      moreover
popescua@52184
    48
      {assume Case12: "a1 \<notin> Field r"
popescua@52184
    49
       hence "(a1,a) \<notin> r" unfolding Field_def by auto
popescua@52184
    50
       moreover
popescua@52184
    51
       have "(a1,a) \<notin> r'" using 3 unfolding Field_def by auto
popescua@52184
    52
       ultimately have "(a1,a) \<notin> r Osum r'"
popescua@52184
    53
       using 3 unfolding Osum_def by auto
popescua@52184
    54
      }
popescua@52184
    55
      ultimately show "(a1,a) \<notin> r Osum r'" by blast
popescua@52184
    56
    qed
popescua@52184
    57
    thus ?thesis using 1 B_def by auto
popescua@52184
    58
  next
popescua@52184
    59
    assume Case2: "B = {}"
popescua@52184
    60
    hence 1: "A \<noteq> {} \<and> A \<le> Field r'" using * ** B_def by auto
popescua@52184
    61
    then obtain a' where 2: "a' \<in> A" and 3: "\<forall>a1' \<in> A. (a1',a') \<notin> r'"
blanchet@55021
    62
    using WF' unfolding wf_eq_minimal2 by blast
popescua@52184
    63
    hence 4: "a' \<in> Field r' \<and> a' \<notin> Field r" using 1 FLD by blast
popescua@52184
    64
    (*  *)
popescua@52184
    65
    have "\<forall>a1' \<in> A. (a1',a') \<notin> r Osum r'"
popescua@52184
    66
    proof(unfold Osum_def, auto simp add: 3)
popescua@52184
    67
      fix a1' assume "(a1', a') \<in> r"
popescua@52184
    68
      thus False using 4 unfolding Field_def by blast
popescua@52184
    69
    next
popescua@52184
    70
      fix a1' assume "a1' \<in> A" and "a1' \<in> Field r"
popescua@52184
    71
      thus False using Case2 B_def by auto
popescua@52184
    72
    qed
popescua@52184
    73
    thus ?thesis using 2 by blast
popescua@52184
    74
  qed
popescua@52184
    75
qed
popescua@52184
    76
popescua@52184
    77
lemma Osum_Refl:
popescua@52184
    78
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
    79
        REFL: "Refl r" and REFL': "Refl r'"
popescua@52184
    80
shows "Refl (r Osum r')"
blanchet@58127
    81
using assms
popescua@52184
    82
unfolding refl_on_def Field_Osum unfolding Osum_def by blast
popescua@52184
    83
popescua@52184
    84
lemma Osum_trans:
popescua@52184
    85
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
    86
        TRANS: "trans r" and TRANS': "trans r'"
popescua@52184
    87
shows "trans (r Osum r')"
popescua@52184
    88
proof(unfold trans_def, auto)
popescua@52184
    89
  fix x y z assume *: "(x, y) \<in> r \<union>o r'" and **: "(y, z) \<in> r \<union>o r'"
popescua@52184
    90
  show  "(x, z) \<in> r \<union>o r'"
popescua@52184
    91
  proof-
popescua@52184
    92
    {assume Case1: "(x,y) \<in> r"
popescua@52184
    93
     hence 1: "x \<in> Field r \<and> y \<in> Field r" unfolding Field_def by auto
popescua@52184
    94
     have ?thesis
popescua@52184
    95
     proof-
popescua@52184
    96
       {assume Case11: "(y,z) \<in> r"
popescua@52184
    97
        hence "(x,z) \<in> r" using Case1 TRANS trans_def[of r] by blast
popescua@52184
    98
        hence ?thesis unfolding Osum_def by auto
popescua@52184
    99
       }
popescua@52184
   100
       moreover
popescua@52184
   101
       {assume Case12: "(y,z) \<in> r'"
popescua@52184
   102
        hence "y \<in> Field r'" unfolding Field_def by auto
popescua@52184
   103
        hence False using FLD 1 by auto
popescua@52184
   104
       }
popescua@52184
   105
       moreover
popescua@52184
   106
       {assume Case13: "z \<in> Field r'"
popescua@52184
   107
        hence ?thesis using 1 unfolding Osum_def by auto
popescua@52184
   108
       }
popescua@52184
   109
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   110
     qed
popescua@52184
   111
    }
popescua@52184
   112
    moreover
popescua@52184
   113
    {assume Case2: "(x,y) \<in> r'"
popescua@52184
   114
     hence 2: "x \<in> Field r' \<and> y \<in> Field r'" unfolding Field_def by auto
popescua@52184
   115
     have ?thesis
popescua@52184
   116
     proof-
popescua@52184
   117
       {assume Case21: "(y,z) \<in> r"
popescua@52184
   118
        hence "y \<in> Field r" unfolding Field_def by auto
popescua@52184
   119
        hence False using FLD 2 by auto
popescua@52184
   120
       }
popescua@52184
   121
       moreover
popescua@52184
   122
       {assume Case22: "(y,z) \<in> r'"
popescua@52184
   123
        hence "(x,z) \<in> r'" using Case2 TRANS' trans_def[of r'] by blast
popescua@52184
   124
        hence ?thesis unfolding Osum_def by auto
popescua@52184
   125
       }
popescua@52184
   126
       moreover
popescua@52184
   127
       {assume Case23: "y \<in> Field r"
popescua@52184
   128
        hence False using FLD 2 by auto
popescua@52184
   129
       }
popescua@52184
   130
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   131
     qed
popescua@52184
   132
    }
popescua@52184
   133
    moreover
popescua@52184
   134
    {assume Case3: "x \<in> Field r \<and> y \<in> Field r'"
popescua@52184
   135
     have ?thesis
popescua@52184
   136
     proof-
popescua@52184
   137
       {assume Case31: "(y,z) \<in> r"
popescua@52184
   138
        hence "y \<in> Field r" unfolding Field_def by auto
popescua@52184
   139
        hence False using FLD Case3 by auto
popescua@52184
   140
       }
popescua@52184
   141
       moreover
popescua@52184
   142
       {assume Case32: "(y,z) \<in> r'"
popescua@52184
   143
        hence "z \<in> Field r'" unfolding Field_def by blast
popescua@52184
   144
        hence ?thesis unfolding Osum_def using Case3 by auto
popescua@52184
   145
       }
popescua@52184
   146
       moreover
popescua@52184
   147
       {assume Case33: "y \<in> Field r"
popescua@52184
   148
        hence False using FLD Case3 by auto
popescua@52184
   149
       }
popescua@52184
   150
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   151
     qed
popescua@52184
   152
    }
popescua@52184
   153
    ultimately show ?thesis using * unfolding Osum_def by blast
popescua@52184
   154
  qed
popescua@52184
   155
qed
popescua@52184
   156
popescua@52184
   157
lemma Osum_Preorder:
popescua@52184
   158
"\<lbrakk>Field r Int Field r' = {}; Preorder r; Preorder r'\<rbrakk> \<Longrightarrow> Preorder (r Osum r')"
popescua@52184
   159
unfolding preorder_on_def using Osum_Refl Osum_trans by blast
popescua@52184
   160
popescua@52184
   161
lemma Osum_antisym:
popescua@52184
   162
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
   163
        AN: "antisym r" and AN': "antisym r'"
popescua@52184
   164
shows "antisym (r Osum r')"
popescua@52184
   165
proof(unfold antisym_def, auto)
popescua@52184
   166
  fix x y assume *: "(x, y) \<in> r \<union>o r'" and **: "(y, x) \<in> r \<union>o r'"
popescua@52184
   167
  show  "x = y"
popescua@52184
   168
  proof-
popescua@52184
   169
    {assume Case1: "(x,y) \<in> r"
popescua@52184
   170
     hence 1: "x \<in> Field r \<and> y \<in> Field r" unfolding Field_def by auto
popescua@52184
   171
     have ?thesis
popescua@52184
   172
     proof-
popescua@52184
   173
       have "(y,x) \<in> r \<Longrightarrow> ?thesis"
popescua@52184
   174
       using Case1 AN antisym_def[of r] by blast
popescua@52184
   175
       moreover
popescua@52184
   176
       {assume "(y,x) \<in> r'"
popescua@52184
   177
        hence "y \<in> Field r'" unfolding Field_def by auto
popescua@52184
   178
        hence False using FLD 1 by auto
popescua@52184
   179
       }
popescua@52184
   180
       moreover
popescua@52184
   181
       have "x \<in> Field r' \<Longrightarrow> False" using FLD 1 by auto
popescua@52184
   182
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   183
     qed
popescua@52184
   184
    }
popescua@52184
   185
    moreover
popescua@52184
   186
    {assume Case2: "(x,y) \<in> r'"
popescua@52184
   187
     hence 2: "x \<in> Field r' \<and> y \<in> Field r'" unfolding Field_def by auto
popescua@52184
   188
     have ?thesis
popescua@52184
   189
     proof-
popescua@52184
   190
       {assume "(y,x) \<in> r"
popescua@52184
   191
        hence "y \<in> Field r" unfolding Field_def by auto
popescua@52184
   192
        hence False using FLD 2 by auto
popescua@52184
   193
       }
popescua@52184
   194
       moreover
popescua@52184
   195
       have "(y,x) \<in> r' \<Longrightarrow> ?thesis"
popescua@52184
   196
       using Case2 AN' antisym_def[of r'] by blast
popescua@52184
   197
       moreover
popescua@52184
   198
       {assume "y \<in> Field r"
popescua@52184
   199
        hence False using FLD 2 by auto
popescua@52184
   200
       }
popescua@52184
   201
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   202
     qed
popescua@52184
   203
    }
popescua@52184
   204
    moreover
popescua@52184
   205
    {assume Case3: "x \<in> Field r \<and> y \<in> Field r'"
popescua@52184
   206
     have ?thesis
popescua@52184
   207
     proof-
popescua@52184
   208
       {assume "(y,x) \<in> r"
popescua@52184
   209
        hence "y \<in> Field r" unfolding Field_def by auto
popescua@52184
   210
        hence False using FLD Case3 by auto
popescua@52184
   211
       }
popescua@52184
   212
       moreover
popescua@52184
   213
       {assume Case32: "(y,x) \<in> r'"
popescua@52184
   214
        hence "x \<in> Field r'" unfolding Field_def by blast
popescua@52184
   215
        hence False using FLD Case3 by auto
popescua@52184
   216
       }
popescua@52184
   217
       moreover
popescua@52184
   218
       have "\<not> y \<in> Field r" using FLD Case3 by auto
popescua@52184
   219
       ultimately show ?thesis using ** unfolding Osum_def by blast
popescua@52184
   220
     qed
popescua@52184
   221
    }
popescua@52184
   222
    ultimately show ?thesis using * unfolding Osum_def by blast
popescua@52184
   223
  qed
popescua@52184
   224
qed
popescua@52184
   225
popescua@52184
   226
lemma Osum_Partial_order:
popescua@52184
   227
"\<lbrakk>Field r Int Field r' = {}; Partial_order r; Partial_order r'\<rbrakk> \<Longrightarrow>
popescua@52184
   228
 Partial_order (r Osum r')"
popescua@52184
   229
unfolding partial_order_on_def using Osum_Preorder Osum_antisym by blast
popescua@52184
   230
popescua@52184
   231
lemma Osum_Total:
popescua@52184
   232
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
   233
        TOT: "Total r" and TOT': "Total r'"
popescua@52184
   234
shows "Total (r Osum r')"
popescua@52184
   235
using assms
popescua@52184
   236
unfolding total_on_def  Field_Osum unfolding Osum_def by blast
popescua@52184
   237
popescua@52184
   238
lemma Osum_Linear_order:
popescua@52184
   239
"\<lbrakk>Field r Int Field r' = {}; Linear_order r; Linear_order r'\<rbrakk> \<Longrightarrow>
popescua@52184
   240
 Linear_order (r Osum r')"
popescua@52184
   241
unfolding linear_order_on_def using Osum_Partial_order Osum_Total by blast
popescua@52184
   242
popescua@52184
   243
lemma Osum_minus_Id1:
popescua@52184
   244
assumes "r \<le> Id"
popescua@52184
   245
shows "(r Osum r') - Id \<le> (r' - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   246
proof-
popescua@52184
   247
  let ?Left = "(r Osum r') - Id"
popescua@52184
   248
  let ?Right = "(r' - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   249
  {fix a::'a and b assume *: "(a,b) \<notin> Id"
popescua@52184
   250
   {assume "(a,b) \<in> r"
popescua@52184
   251
    with * have False using assms by auto
popescua@52184
   252
   }
popescua@52184
   253
   moreover
popescua@52184
   254
   {assume "(a,b) \<in> r'"
popescua@52184
   255
    with * have "(a,b) \<in> r' - Id" by auto
popescua@52184
   256
   }
popescua@52184
   257
   ultimately
popescua@52184
   258
   have "(a,b) \<in> ?Left \<Longrightarrow> (a,b) \<in> ?Right"
popescua@52184
   259
   unfolding Osum_def by auto
popescua@52184
   260
  }
popescua@52184
   261
  thus ?thesis by auto
popescua@52184
   262
qed
popescua@52184
   263
popescua@52184
   264
lemma Osum_minus_Id2:
popescua@52184
   265
assumes "r' \<le> Id"
popescua@52184
   266
shows "(r Osum r') - Id \<le> (r - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   267
proof-
popescua@52184
   268
  let ?Left = "(r Osum r') - Id"
popescua@52184
   269
  let ?Right = "(r - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   270
  {fix a::'a and b assume *: "(a,b) \<notin> Id"
popescua@52184
   271
   {assume "(a,b) \<in> r'"
popescua@52184
   272
    with * have False using assms by auto
popescua@52184
   273
   }
popescua@52184
   274
   moreover
popescua@52184
   275
   {assume "(a,b) \<in> r"
popescua@52184
   276
    with * have "(a,b) \<in> r - Id" by auto
popescua@52184
   277
   }
popescua@52184
   278
   ultimately
popescua@52184
   279
   have "(a,b) \<in> ?Left \<Longrightarrow> (a,b) \<in> ?Right"
popescua@52184
   280
   unfolding Osum_def by auto
popescua@52184
   281
  }
popescua@52184
   282
  thus ?thesis by auto
popescua@52184
   283
qed
popescua@52184
   284
popescua@52184
   285
lemma Osum_minus_Id:
popescua@52184
   286
assumes TOT: "Total r" and TOT': "Total r'" and
popescua@52184
   287
        NID: "\<not> (r \<le> Id)" and NID': "\<not> (r' \<le> Id)"
popescua@52184
   288
shows "(r Osum r') - Id \<le> (r - Id) Osum (r' - Id)"
popescua@52184
   289
proof-
popescua@52184
   290
  {fix a a' assume *: "(a,a') \<in> (r Osum r')" and **: "a \<noteq> a'"
popescua@52184
   291
   have "(a,a') \<in> (r - Id) Osum (r' - Id)"
popescua@52184
   292
   proof-
popescua@52184
   293
     {assume "(a,a') \<in> r \<or> (a,a') \<in> r'"
popescua@52184
   294
      with ** have ?thesis unfolding Osum_def by auto
popescua@52184
   295
     }
popescua@52184
   296
     moreover
popescua@52184
   297
     {assume "a \<in> Field r \<and> a' \<in> Field r'"
popescua@52184
   298
      hence "a \<in> Field(r - Id) \<and> a' \<in> Field (r' - Id)"
popescua@52184
   299
      using assms Total_Id_Field by blast
popescua@52184
   300
      hence ?thesis unfolding Osum_def by auto
popescua@52184
   301
     }
blanchet@54482
   302
     ultimately show ?thesis using * unfolding Osum_def by fast
popescua@52184
   303
   qed
popescua@52184
   304
  }
popescua@52184
   305
  thus ?thesis by(auto simp add: Osum_def)
popescua@52184
   306
qed
popescua@52184
   307
popescua@52184
   308
lemma wf_Int_Times:
popescua@52184
   309
assumes "A Int B = {}"
popescua@52184
   310
shows "wf(A \<times> B)"
blanchet@54482
   311
unfolding wf_def using assms by blast
popescua@52184
   312
popescua@52184
   313
lemma Osum_wf_Id:
popescua@52184
   314
assumes TOT: "Total r" and TOT': "Total r'" and
popescua@52184
   315
        FLD: "Field r Int Field r' = {}" and
popescua@52184
   316
        WF: "wf(r - Id)" and WF': "wf(r' - Id)"
popescua@52184
   317
shows "wf ((r Osum r') - Id)"
popescua@52184
   318
proof(cases "r \<le> Id \<or> r' \<le> Id")
popescua@52184
   319
  assume Case1: "\<not>(r \<le> Id \<or> r' \<le> Id)"
popescua@52184
   320
  have "Field(r - Id) Int Field(r' - Id) = {}"
popescua@52184
   321
  using FLD mono_Field[of "r - Id" r]  mono_Field[of "r' - Id" r']
popescua@52184
   322
            Diff_subset[of r Id] Diff_subset[of r' Id] by blast
popescua@52184
   323
  thus ?thesis
popescua@52184
   324
  using Case1 Osum_minus_Id[of r r'] assms Osum_wf[of "r - Id" "r' - Id"]
popescua@52184
   325
        wf_subset[of "(r - Id) \<union>o (r' - Id)" "(r Osum r') - Id"] by auto
popescua@52184
   326
next
popescua@52184
   327
  have 1: "wf(Field r \<times> Field r')"
popescua@52184
   328
  using FLD by (auto simp add: wf_Int_Times)
popescua@52184
   329
  assume Case2: "r \<le> Id \<or> r' \<le> Id"
popescua@52184
   330
  moreover
popescua@52184
   331
  {assume Case21: "r \<le> Id"
popescua@52184
   332
   hence "(r Osum r') - Id \<le> (r' - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   333
   using Osum_minus_Id1[of r r'] by simp
popescua@52184
   334
   moreover
popescua@52184
   335
   {have "Domain(Field r \<times> Field r') Int Range(r' - Id) = {}"
popescua@52184
   336
    using FLD unfolding Field_def by blast
popescua@52184
   337
    hence "wf((r' - Id) \<union> (Field r \<times> Field r'))"
popescua@52184
   338
    using 1 WF' wf_Un[of "Field r \<times> Field r'" "r' - Id"]
popescua@52184
   339
    by (auto simp add: Un_commute)
popescua@52184
   340
   }
blanchet@55021
   341
   ultimately have ?thesis using wf_subset by blast
popescua@52184
   342
  }
popescua@52184
   343
  moreover
popescua@52184
   344
  {assume Case22: "r' \<le> Id"
popescua@52184
   345
   hence "(r Osum r') - Id \<le> (r - Id) \<union> (Field r \<times> Field r')"
popescua@52184
   346
   using Osum_minus_Id2[of r' r] by simp
popescua@52184
   347
   moreover
popescua@52184
   348
   {have "Range(Field r \<times> Field r') Int Domain(r - Id) = {}"
popescua@52184
   349
    using FLD unfolding Field_def by blast
popescua@52184
   350
    hence "wf((r - Id) \<union> (Field r \<times> Field r'))"
popescua@52184
   351
    using 1 WF wf_Un[of "r - Id" "Field r \<times> Field r'"]
popescua@52184
   352
    by (auto simp add: Un_commute)
popescua@52184
   353
   }
blanchet@55021
   354
   ultimately have ?thesis using wf_subset by blast
popescua@52184
   355
  }
popescua@52184
   356
  ultimately show ?thesis by blast
popescua@52184
   357
qed
popescua@52184
   358
popescua@52184
   359
lemma Osum_Well_order:
popescua@52184
   360
assumes FLD: "Field r Int Field r' = {}" and
popescua@52184
   361
        WELL: "Well_order r" and WELL': "Well_order r'"
popescua@52184
   362
shows "Well_order (r Osum r')"
popescua@52184
   363
proof-
popescua@52184
   364
  have "Total r \<and> Total r'" using WELL WELL'
popescua@52184
   365
  by (auto simp add: order_on_defs)
popescua@52184
   366
  thus ?thesis using assms unfolding well_order_on_def
popescua@52184
   367
  using Osum_Linear_order Osum_wf_Id by blast
popescua@52184
   368
qed
popescua@52184
   369
popescua@52184
   370
end