src/HOL/Cardinals/Wellorder_Relation_LFP.thy
author blanchet
Mon Nov 18 18:04:45 2013 +0100 (2013-11-18)
changeset 54477 f001ef2637d3
parent 54473 8bee5ca99e63
permissions -rw-r--r--
moved theorems out of LFP
blanchet@54473
     1
(*  Title:      HOL/Cardinals/Wellorder_Relation_LFP.thy
blanchet@48975
     2
    Author:     Andrei Popescu, TU Muenchen
blanchet@48975
     3
    Copyright   2012
blanchet@48975
     4
blanchet@54473
     5
Well-order relations (LFP).
blanchet@48975
     6
*)
blanchet@48975
     7
blanchet@54473
     8
header {* Well-Order Relations (LFP) *}
blanchet@48975
     9
blanchet@54473
    10
theory Wellorder_Relation_LFP
blanchet@54473
    11
imports Wellfounded_More_LFP
blanchet@48975
    12
begin
blanchet@48975
    13
blanchet@48975
    14
blanchet@48975
    15
text{* In this section, we develop basic concepts and results pertaining
blanchet@48975
    16
to well-order relations.  Note that we consider well-order relations
blanchet@48975
    17
as {\em non-strict relations},
blanchet@48975
    18
i.e., as containing the diagonals of their fields. *}
blanchet@48975
    19
blanchet@48975
    20
blanchet@48975
    21
locale wo_rel = rel + assumes WELL: "Well_order r"
blanchet@48975
    22
begin
blanchet@48975
    23
blanchet@48975
    24
text{* The following context encompasses all this section. In other words,
blanchet@48975
    25
for the whole section, we consider a fixed well-order relation @{term "r"}. *}
blanchet@48975
    26
blanchet@48975
    27
(* context wo_rel  *)
blanchet@48975
    28
blanchet@48975
    29
blanchet@48975
    30
subsection {* Auxiliaries *}
blanchet@48975
    31
blanchet@48975
    32
blanchet@48975
    33
lemma REFL: "Refl r"
blanchet@48975
    34
using WELL order_on_defs[of _ r] by auto
blanchet@48975
    35
blanchet@48975
    36
blanchet@48975
    37
lemma TRANS: "trans r"
blanchet@48975
    38
using WELL order_on_defs[of _ r] by auto
blanchet@48975
    39
blanchet@48975
    40
blanchet@48975
    41
lemma ANTISYM: "antisym r"
blanchet@48975
    42
using WELL order_on_defs[of _ r] by auto
blanchet@48975
    43
blanchet@48975
    44
blanchet@48975
    45
lemma TOTAL: "Total r"
blanchet@48975
    46
using WELL order_on_defs[of _ r] by auto
blanchet@48975
    47
blanchet@48975
    48
blanchet@48975
    49
lemma TOTALS: "\<forall>a \<in> Field r. \<forall>b \<in> Field r. (a,b) \<in> r \<or> (b,a) \<in> r"
blanchet@48975
    50
using REFL TOTAL refl_on_def[of _ r] total_on_def[of _ r] by force
blanchet@48975
    51
blanchet@48975
    52
blanchet@48975
    53
lemma LIN: "Linear_order r"
blanchet@48975
    54
using WELL well_order_on_def[of _ r] by auto
blanchet@48975
    55
blanchet@48975
    56
blanchet@48975
    57
lemma WF: "wf (r - Id)"
blanchet@48975
    58
using WELL well_order_on_def[of _ r] by auto
blanchet@48975
    59
blanchet@48975
    60
blanchet@48975
    61
lemma cases_Total:
blanchet@48975
    62
"\<And> phi a b. \<lbrakk>{a,b} <= Field r; ((a,b) \<in> r \<Longrightarrow> phi a b); ((b,a) \<in> r \<Longrightarrow> phi a b)\<rbrakk>
blanchet@48975
    63
             \<Longrightarrow> phi a b"
blanchet@48975
    64
using TOTALS by auto
blanchet@48975
    65
blanchet@48975
    66
blanchet@48975
    67
lemma cases_Total3:
blanchet@48975
    68
"\<And> phi a b. \<lbrakk>{a,b} \<le> Field r; ((a,b) \<in> r - Id \<or> (b,a) \<in> r - Id \<Longrightarrow> phi a b);
blanchet@48975
    69
              (a = b \<Longrightarrow> phi a b)\<rbrakk>  \<Longrightarrow> phi a b"
blanchet@48975
    70
using TOTALS by auto
blanchet@48975
    71
blanchet@48975
    72
blanchet@48975
    73
subsection {* Well-founded induction and recursion adapted to non-strict well-order relations  *}
blanchet@48975
    74
blanchet@48975
    75
blanchet@48975
    76
text{* Here we provide induction and recursion principles specific to {\em non-strict}
blanchet@48975
    77
well-order relations.
blanchet@48975
    78
Although minor variations of those for well-founded relations, they will be useful
blanchet@48975
    79
for doing away with the tediousness of
blanchet@48975
    80
having to take out the diagonal each time in order to switch to a well-founded relation. *}
blanchet@48975
    81
blanchet@48975
    82
blanchet@48975
    83
lemma well_order_induct:
blanchet@48975
    84
assumes IND: "\<And>x. \<forall>y. y \<noteq> x \<and> (y, x) \<in> r \<longrightarrow> P y \<Longrightarrow> P x"
blanchet@48975
    85
shows "P a"
blanchet@48975
    86
proof-
blanchet@48975
    87
  have "\<And>x. \<forall>y. (y, x) \<in> r - Id \<longrightarrow> P y \<Longrightarrow> P x"
blanchet@48975
    88
  using IND by blast
blanchet@48975
    89
  thus "P a" using WF wf_induct[of "r - Id" P a] by blast
blanchet@48975
    90
qed
blanchet@48975
    91
blanchet@48975
    92
blanchet@48975
    93
definition
blanchet@48975
    94
worec :: "(('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
blanchet@48975
    95
where
blanchet@48975
    96
"worec F \<equiv> wfrec (r - Id) F"
blanchet@48975
    97
blanchet@48975
    98
blanchet@48975
    99
definition
blanchet@48975
   100
adm_wo :: "(('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> bool"
blanchet@48975
   101
where
blanchet@48975
   102
"adm_wo H \<equiv> \<forall>f g x. (\<forall>y \<in> underS x. f y = g y) \<longrightarrow> H f x = H g x"
blanchet@48975
   103
blanchet@48975
   104
blanchet@48975
   105
lemma worec_fixpoint:
blanchet@48975
   106
assumes ADM: "adm_wo H"
blanchet@48975
   107
shows "worec H = H (worec H)"
blanchet@48975
   108
proof-
blanchet@48975
   109
  let ?rS = "r - Id"
blanchet@48975
   110
  have "adm_wf (r - Id) H"
blanchet@48975
   111
  unfolding adm_wf_def
blanchet@48975
   112
  using ADM adm_wo_def[of H] underS_def by auto
blanchet@48975
   113
  hence "wfrec ?rS H = H (wfrec ?rS H)"
blanchet@48975
   114
  using WF wfrec_fixpoint[of ?rS H] by simp
blanchet@48975
   115
  thus ?thesis unfolding worec_def .
blanchet@48975
   116
qed
blanchet@48975
   117
blanchet@48975
   118
blanchet@48975
   119
subsection {* The notions of maximum, minimum, supremum, successor and order filter  *}
blanchet@48975
   120
blanchet@48975
   121
blanchet@48975
   122
text{*
blanchet@48975
   123
We define the successor {\em of a set}, and not of an element (the latter is of course
blanchet@48975
   124
a particular case).  Also, we define the maximum {\em of two elements}, @{text "max2"},
blanchet@48975
   125
and the minimum {\em of a set}, @{text "minim"} -- we chose these variants since we
blanchet@48975
   126
consider them the most useful for well-orders.  The minimum is defined in terms of the
blanchet@48975
   127
auxiliary relational operator @{text "isMinim"}.  Then, supremum and successor are
blanchet@48975
   128
defined in terms of minimum as expected.
blanchet@48975
   129
The minimum is only meaningful for non-empty sets, and the successor is only
blanchet@48975
   130
meaningful for sets for which strict upper bounds exist.
blanchet@48975
   131
Order filters for well-orders are also known as ``initial segments". *}
blanchet@48975
   132
blanchet@48975
   133
blanchet@48975
   134
definition max2 :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
blanchet@48975
   135
where "max2 a b \<equiv> if (a,b) \<in> r then b else a"
blanchet@48975
   136
blanchet@48975
   137
blanchet@48975
   138
definition isMinim :: "'a set \<Rightarrow> 'a \<Rightarrow> bool"
blanchet@48975
   139
where "isMinim A b \<equiv> b \<in> A \<and> (\<forall>a \<in> A. (b,a) \<in> r)"
blanchet@48975
   140
blanchet@48975
   141
definition minim :: "'a set \<Rightarrow> 'a"
blanchet@48975
   142
where "minim A \<equiv> THE b. isMinim A b"
blanchet@48975
   143
blanchet@48975
   144
blanchet@48975
   145
definition supr :: "'a set \<Rightarrow> 'a"
blanchet@48975
   146
where "supr A \<equiv> minim (Above A)"
blanchet@48975
   147
blanchet@48975
   148
definition suc :: "'a set \<Rightarrow> 'a"
blanchet@48975
   149
where "suc A \<equiv> minim (AboveS A)"
blanchet@48975
   150
blanchet@48975
   151
definition ofilter :: "'a set \<Rightarrow> bool"
blanchet@48975
   152
where
blanchet@48975
   153
"ofilter A \<equiv> (A \<le> Field r) \<and> (\<forall>a \<in> A. under a \<le> A)"
blanchet@48975
   154
blanchet@48975
   155
blanchet@48975
   156
subsubsection {* Properties of max2 *}
blanchet@48975
   157
blanchet@48975
   158
blanchet@48975
   159
lemma max2_greater_among:
blanchet@48975
   160
assumes "a \<in> Field r" and "b \<in> Field r"
blanchet@48975
   161
shows "(a, max2 a b) \<in> r \<and> (b, max2 a b) \<in> r \<and> max2 a b \<in> {a,b}"
blanchet@48975
   162
proof-
blanchet@48975
   163
  {assume "(a,b) \<in> r"
blanchet@48975
   164
   hence ?thesis using max2_def assms REFL refl_on_def
blanchet@48975
   165
   by (auto simp add: refl_on_def)
blanchet@48975
   166
  }
blanchet@48975
   167
  moreover
blanchet@48975
   168
  {assume "a = b"
blanchet@48975
   169
   hence "(a,b) \<in> r" using REFL  assms
blanchet@48975
   170
   by (auto simp add: refl_on_def)
blanchet@48975
   171
  }
blanchet@48975
   172
  moreover
blanchet@48975
   173
  {assume *: "a \<noteq> b \<and> (b,a) \<in> r"
blanchet@48975
   174
   hence "(a,b) \<notin> r" using ANTISYM
blanchet@48975
   175
   by (auto simp add: antisym_def)
blanchet@48975
   176
   hence ?thesis using * max2_def assms REFL refl_on_def
blanchet@48975
   177
   by (auto simp add: refl_on_def)
blanchet@48975
   178
  }
blanchet@48975
   179
  ultimately show ?thesis using assms TOTAL
blanchet@48975
   180
  total_on_def[of "Field r" r] by blast
blanchet@48975
   181
qed
blanchet@48975
   182
blanchet@48975
   183
blanchet@48975
   184
lemma max2_greater:
blanchet@48975
   185
assumes "a \<in> Field r" and "b \<in> Field r"
blanchet@48975
   186
shows "(a, max2 a b) \<in> r \<and> (b, max2 a b) \<in> r"
blanchet@48975
   187
using assms by (auto simp add: max2_greater_among)
blanchet@48975
   188
blanchet@48975
   189
blanchet@48975
   190
lemma max2_among:
blanchet@48975
   191
assumes "a \<in> Field r" and "b \<in> Field r"
blanchet@48975
   192
shows "max2 a b \<in> {a, b}"
blanchet@48975
   193
using assms max2_greater_among[of a b] by simp
blanchet@48975
   194
blanchet@48975
   195
blanchet@48975
   196
lemma max2_equals1:
blanchet@48975
   197
assumes "a \<in> Field r" and "b \<in> Field r"
blanchet@48975
   198
shows "(max2 a b = a) = ((b,a) \<in> r)"
blanchet@48975
   199
using assms ANTISYM unfolding antisym_def using TOTALS
blanchet@48975
   200
by(auto simp add: max2_def max2_among)
blanchet@48975
   201
blanchet@48975
   202
blanchet@48975
   203
lemma max2_equals2:
blanchet@48975
   204
assumes "a \<in> Field r" and "b \<in> Field r"
blanchet@48975
   205
shows "(max2 a b = b) = ((a,b) \<in> r)"
blanchet@48975
   206
using assms ANTISYM unfolding antisym_def using TOTALS
blanchet@48975
   207
unfolding max2_def by auto
blanchet@48975
   208
blanchet@48975
   209
blanchet@48975
   210
subsubsection {* Existence and uniqueness for isMinim and well-definedness of minim *}
blanchet@48975
   211
blanchet@48975
   212
blanchet@48975
   213
lemma isMinim_unique:
blanchet@48975
   214
assumes MINIM: "isMinim B a" and MINIM': "isMinim B a'"
blanchet@48975
   215
shows "a = a'"
blanchet@48975
   216
proof-
blanchet@48975
   217
  {have "a \<in> B"
blanchet@48975
   218
   using MINIM isMinim_def by simp
blanchet@48975
   219
   hence "(a',a) \<in> r"
blanchet@48975
   220
   using MINIM' isMinim_def by simp
blanchet@48975
   221
  }
blanchet@48975
   222
  moreover
blanchet@48975
   223
  {have "a' \<in> B"
blanchet@48975
   224
   using MINIM' isMinim_def by simp
blanchet@48975
   225
   hence "(a,a') \<in> r"
blanchet@48975
   226
   using MINIM isMinim_def by simp
blanchet@48975
   227
  }
blanchet@48975
   228
  ultimately
blanchet@48975
   229
  show ?thesis using ANTISYM antisym_def[of r] by blast
blanchet@48975
   230
qed
blanchet@48975
   231
blanchet@48975
   232
blanchet@48975
   233
lemma Well_order_isMinim_exists:
blanchet@48975
   234
assumes SUB: "B \<le> Field r" and NE: "B \<noteq> {}"
blanchet@48975
   235
shows "\<exists>b. isMinim B b"
blanchet@48975
   236
proof-
traytel@51764
   237
  from spec[OF WF[unfolded wf_eq_minimal[of "r - Id"]], of B] NE obtain b where
traytel@51764
   238
  *: "b \<in> B \<and> (\<forall>b'. b' \<noteq> b \<and> (b',b) \<in> r \<longrightarrow> b' \<notin> B)" by auto
blanchet@48975
   239
  show ?thesis
blanchet@48975
   240
  proof(simp add: isMinim_def, rule exI[of _ b], auto)
blanchet@48975
   241
    show "b \<in> B" using * by simp
blanchet@48975
   242
  next
blanchet@48975
   243
    fix b' assume As: "b' \<in> B"
blanchet@48975
   244
    hence **: "b \<in> Field r \<and> b' \<in> Field r" using As SUB * by auto
blanchet@48975
   245
    (*  *)
blanchet@48975
   246
    from As  * have "b' = b \<or> (b',b) \<notin> r" by auto
blanchet@48975
   247
    moreover
blanchet@48975
   248
    {assume "b' = b"
blanchet@48975
   249
     hence "(b,b') \<in> r"
blanchet@48975
   250
     using ** REFL by (auto simp add: refl_on_def)
blanchet@48975
   251
    }
blanchet@48975
   252
    moreover
blanchet@48975
   253
    {assume "b' \<noteq> b \<and> (b',b) \<notin> r"
blanchet@48975
   254
     hence "(b,b') \<in> r"
blanchet@48975
   255
     using ** TOTAL by (auto simp add: total_on_def)
blanchet@48975
   256
    }
blanchet@48975
   257
    ultimately show "(b,b') \<in> r" by blast
blanchet@48975
   258
  qed
blanchet@48975
   259
qed
blanchet@48975
   260
blanchet@48975
   261
blanchet@48975
   262
lemma minim_isMinim:
blanchet@48975
   263
assumes SUB: "B \<le> Field r" and NE: "B \<noteq> {}"
blanchet@48975
   264
shows "isMinim B (minim B)"
blanchet@48975
   265
proof-
blanchet@48975
   266
  let ?phi = "(\<lambda> b. isMinim B b)"
blanchet@48975
   267
  from assms Well_order_isMinim_exists
blanchet@48975
   268
  obtain b where *: "?phi b" by blast
blanchet@48975
   269
  moreover
blanchet@48975
   270
  have "\<And> b'. ?phi b' \<Longrightarrow> b' = b"
blanchet@48975
   271
  using isMinim_unique * by auto
blanchet@48975
   272
  ultimately show ?thesis
blanchet@48975
   273
  unfolding minim_def using theI[of ?phi b] by blast
blanchet@48975
   274
qed
blanchet@48975
   275
blanchet@48975
   276
blanchet@48975
   277
subsubsection{* Properties of minim *}
blanchet@48975
   278
blanchet@48975
   279
blanchet@48975
   280
lemma minim_in:
blanchet@48975
   281
assumes "B \<le> Field r" and "B \<noteq> {}"
blanchet@48975
   282
shows "minim B \<in> B"
blanchet@48975
   283
proof-
blanchet@48975
   284
  from minim_isMinim[of B] assms
blanchet@48975
   285
  have "isMinim B (minim B)" by simp
blanchet@48975
   286
  thus ?thesis by (simp add: isMinim_def)
blanchet@48975
   287
qed
blanchet@48975
   288
blanchet@48975
   289
blanchet@48975
   290
lemma minim_inField:
blanchet@48975
   291
assumes "B \<le> Field r" and "B \<noteq> {}"
blanchet@48975
   292
shows "minim B \<in> Field r"
blanchet@48975
   293
proof-
blanchet@48975
   294
  have "minim B \<in> B" using assms by (simp add: minim_in)
blanchet@48975
   295
  thus ?thesis using assms by blast
blanchet@48975
   296
qed
blanchet@48975
   297
blanchet@48975
   298
blanchet@48975
   299
lemma minim_least:
blanchet@48975
   300
assumes  SUB: "B \<le> Field r" and IN: "b \<in> B"
blanchet@48975
   301
shows "(minim B, b) \<in> r"
blanchet@48975
   302
proof-
blanchet@48975
   303
  from minim_isMinim[of B] assms
blanchet@48975
   304
  have "isMinim B (minim B)" by auto
blanchet@48975
   305
  thus ?thesis by (auto simp add: isMinim_def IN)
blanchet@48975
   306
qed
blanchet@48975
   307
blanchet@48975
   308
blanchet@48975
   309
lemma equals_minim:
blanchet@48975
   310
assumes SUB: "B \<le> Field r" and IN: "a \<in> B" and
blanchet@48975
   311
        LEAST: "\<And> b. b \<in> B \<Longrightarrow> (a,b) \<in> r"
blanchet@48975
   312
shows "a = minim B"
blanchet@48975
   313
proof-
blanchet@48975
   314
  from minim_isMinim[of B] assms
blanchet@48975
   315
  have "isMinim B (minim B)" by auto
blanchet@48975
   316
  moreover have "isMinim B a" using IN LEAST isMinim_def by auto
blanchet@48975
   317
  ultimately show ?thesis
blanchet@48975
   318
  using isMinim_unique by auto
blanchet@48975
   319
qed
blanchet@48975
   320
blanchet@48975
   321
blanchet@48975
   322
subsubsection{* Properties of successor *}
blanchet@48975
   323
blanchet@48975
   324
blanchet@48975
   325
lemma suc_AboveS:
blanchet@48975
   326
assumes SUB: "B \<le> Field r" and ABOVES: "AboveS B \<noteq> {}"
blanchet@48975
   327
shows "suc B \<in> AboveS B"
blanchet@48975
   328
proof(unfold suc_def)
blanchet@48975
   329
  have "AboveS B \<le> Field r"
blanchet@48975
   330
  using AboveS_Field by auto
blanchet@48975
   331
  thus "minim (AboveS B) \<in> AboveS B"
blanchet@48975
   332
  using assms by (simp add: minim_in)
blanchet@48975
   333
qed
blanchet@48975
   334
blanchet@48975
   335
blanchet@48975
   336
lemma suc_greater:
blanchet@48975
   337
assumes SUB: "B \<le> Field r" and ABOVES: "AboveS B \<noteq> {}" and
blanchet@48975
   338
        IN: "b \<in> B"
blanchet@48975
   339
shows "suc B \<noteq> b \<and> (b,suc B) \<in> r"
blanchet@48975
   340
proof-
blanchet@48975
   341
  from assms suc_AboveS
blanchet@48975
   342
  have "suc B \<in> AboveS B" by simp
blanchet@48975
   343
  with IN AboveS_def show ?thesis by simp
blanchet@48975
   344
qed
blanchet@48975
   345
blanchet@48975
   346
blanchet@48975
   347
lemma suc_least_AboveS:
blanchet@48975
   348
assumes ABOVES: "a \<in> AboveS B"
blanchet@48975
   349
shows "(suc B,a) \<in> r"
blanchet@48975
   350
proof(unfold suc_def)
blanchet@48975
   351
  have "AboveS B \<le> Field r"
blanchet@48975
   352
  using AboveS_Field by auto
blanchet@48975
   353
  thus "(minim (AboveS B),a) \<in> r"
blanchet@48975
   354
  using assms minim_least by simp
blanchet@48975
   355
qed
blanchet@48975
   356
blanchet@48975
   357
blanchet@48975
   358
lemma suc_inField:
blanchet@48975
   359
assumes "B \<le> Field r" and "AboveS B \<noteq> {}"
blanchet@48975
   360
shows "suc B \<in> Field r"
blanchet@48975
   361
proof-
blanchet@48975
   362
  have "suc B \<in> AboveS B" using suc_AboveS assms by simp
blanchet@48975
   363
  thus ?thesis
blanchet@48975
   364
  using assms AboveS_Field by auto
blanchet@48975
   365
qed
blanchet@48975
   366
blanchet@48975
   367
blanchet@48975
   368
lemma equals_suc_AboveS:
blanchet@48975
   369
assumes SUB: "B \<le> Field r" and ABV: "a \<in> AboveS B" and
blanchet@48975
   370
        MINIM: "\<And> a'. a' \<in> AboveS B \<Longrightarrow> (a,a') \<in> r"
blanchet@48975
   371
shows "a = suc B"
blanchet@48975
   372
proof(unfold suc_def)
blanchet@48975
   373
  have "AboveS B \<le> Field r"
blanchet@48975
   374
  using AboveS_Field[of B] by auto
blanchet@48975
   375
  thus "a = minim (AboveS B)"
blanchet@48975
   376
  using assms equals_minim
blanchet@48975
   377
  by simp
blanchet@48975
   378
qed
blanchet@48975
   379
blanchet@48975
   380
blanchet@48975
   381
lemma suc_underS:
blanchet@48975
   382
assumes IN: "a \<in> Field r"
blanchet@48975
   383
shows "a = suc (underS a)"
blanchet@48975
   384
proof-
blanchet@48975
   385
  have "underS a \<le> Field r"
blanchet@48975
   386
  using underS_Field by auto
blanchet@48975
   387
  moreover
blanchet@48975
   388
  have "a \<in> AboveS (underS a)"
blanchet@48975
   389
  using in_AboveS_underS IN by auto
blanchet@48975
   390
  moreover
blanchet@48975
   391
  have "\<forall>a' \<in> AboveS (underS a). (a,a') \<in> r"
blanchet@48975
   392
  proof(clarify)
blanchet@48975
   393
    fix a'
blanchet@48975
   394
    assume *: "a' \<in> AboveS (underS a)"
blanchet@48975
   395
    hence **: "a' \<in> Field r"
blanchet@48975
   396
    using AboveS_Field by auto
blanchet@48975
   397
    {assume "(a,a') \<notin> r"
blanchet@48975
   398
     hence "a' = a \<or> (a',a) \<in> r"
blanchet@48975
   399
     using TOTAL IN ** by (auto simp add: total_on_def)
blanchet@48975
   400
     moreover
blanchet@48975
   401
     {assume "a' = a"
blanchet@48975
   402
      hence "(a,a') \<in> r"
blanchet@48975
   403
      using REFL IN ** by (auto simp add: refl_on_def)
blanchet@48975
   404
     }
blanchet@48975
   405
     moreover
blanchet@48975
   406
     {assume "a' \<noteq> a \<and> (a',a) \<in> r"
blanchet@48975
   407
      hence "a' \<in> underS a"
blanchet@48975
   408
      unfolding underS_def by simp
blanchet@48975
   409
      hence "a' \<notin> AboveS (underS a)"
blanchet@48975
   410
      using AboveS_disjoint by blast
blanchet@48975
   411
      with * have False by simp
blanchet@48975
   412
     }
blanchet@48975
   413
     ultimately have "(a,a') \<in> r" by blast
blanchet@48975
   414
    }
blanchet@48975
   415
    thus  "(a, a') \<in> r" by blast
blanchet@48975
   416
  qed
blanchet@48975
   417
  ultimately show ?thesis
blanchet@48975
   418
  using equals_suc_AboveS by auto
blanchet@48975
   419
qed
blanchet@48975
   420
blanchet@48975
   421
blanchet@54477
   422
subsubsection {* Properties of order filters *}
blanchet@48975
   423
blanchet@48975
   424
blanchet@48975
   425
lemma under_ofilter:
blanchet@48975
   426
"ofilter (under a)"
blanchet@48975
   427
proof(unfold ofilter_def under_def, auto simp add: Field_def)
blanchet@48975
   428
  fix aa x
blanchet@48975
   429
  assume "(aa,a) \<in> r" "(x,aa) \<in> r"
blanchet@48975
   430
  thus "(x,a) \<in> r"
blanchet@48975
   431
  using TRANS trans_def[of r] by blast
blanchet@48975
   432
qed
blanchet@48975
   433
blanchet@48975
   434
blanchet@48975
   435
lemma underS_ofilter:
blanchet@48975
   436
"ofilter (underS a)"
blanchet@48975
   437
proof(unfold ofilter_def underS_def under_def, auto simp add: Field_def)
blanchet@48975
   438
  fix aa assume "(a, aa) \<in> r" "(aa, a) \<in> r" and DIFF: "aa \<noteq> a"
blanchet@48975
   439
  thus False
blanchet@48975
   440
  using ANTISYM antisym_def[of r] by blast
blanchet@48975
   441
next
blanchet@48975
   442
  fix aa x
blanchet@48975
   443
  assume "(aa,a) \<in> r" "aa \<noteq> a" "(x,aa) \<in> r"
blanchet@48975
   444
  thus "(x,a) \<in> r"
blanchet@48975
   445
  using TRANS trans_def[of r] by blast
blanchet@48975
   446
qed
blanchet@48975
   447
blanchet@48975
   448
blanchet@48975
   449
lemma Field_ofilter:
blanchet@48975
   450
"ofilter (Field r)"
blanchet@48975
   451
by(unfold ofilter_def under_def, auto simp add: Field_def)
blanchet@48975
   452
blanchet@48975
   453
blanchet@48975
   454
lemma ofilter_underS_Field:
blanchet@48975
   455
"ofilter A = ((\<exists>a \<in> Field r. A = underS a) \<or> (A = Field r))"
blanchet@48975
   456
proof
blanchet@48975
   457
  assume "(\<exists>a\<in>Field r. A = underS a) \<or> A = Field r"
blanchet@48975
   458
  thus "ofilter A"
blanchet@48975
   459
  by (auto simp: underS_ofilter Field_ofilter)
blanchet@48975
   460
next
blanchet@48975
   461
  assume *: "ofilter A"
blanchet@48975
   462
  let ?One = "(\<exists>a\<in>Field r. A = underS a)"
blanchet@48975
   463
  let ?Two = "(A = Field r)"
blanchet@48975
   464
  show "?One \<or> ?Two"
blanchet@48975
   465
  proof(cases ?Two, simp)
blanchet@48975
   466
    let ?B = "(Field r) - A"
blanchet@48975
   467
    let ?a = "minim ?B"
blanchet@48975
   468
    assume "A \<noteq> Field r"
blanchet@48975
   469
    moreover have "A \<le> Field r" using * ofilter_def by simp
blanchet@48975
   470
    ultimately have 1: "?B \<noteq> {}" by blast
blanchet@48975
   471
    hence 2: "?a \<in> Field r" using minim_inField[of ?B] by blast
blanchet@48975
   472
    have 3: "?a \<in> ?B" using minim_in[of ?B] 1 by blast
blanchet@48975
   473
    hence 4: "?a \<notin> A" by blast
blanchet@48975
   474
    have 5: "A \<le> Field r" using * ofilter_def[of A] by auto
blanchet@48975
   475
    (*  *)
blanchet@48975
   476
    moreover
blanchet@48975
   477
    have "A = underS ?a"
blanchet@48975
   478
    proof
blanchet@48975
   479
      show "A \<le> underS ?a"
blanchet@48975
   480
      proof(unfold underS_def, auto simp add: 4)
blanchet@48975
   481
        fix x assume **: "x \<in> A"
blanchet@48975
   482
        hence 11: "x \<in> Field r" using 5 by auto
blanchet@48975
   483
        have 12: "x \<noteq> ?a" using 4 ** by auto
blanchet@48975
   484
        have 13: "under x \<le> A" using * ofilter_def ** by auto
blanchet@48975
   485
        {assume "(x,?a) \<notin> r"
blanchet@48975
   486
         hence "(?a,x) \<in> r"
blanchet@48975
   487
         using TOTAL total_on_def[of "Field r" r]
blanchet@48975
   488
               2 4 11 12 by auto
blanchet@48975
   489
         hence "?a \<in> under x" using under_def by auto
blanchet@48975
   490
         hence "?a \<in> A" using ** 13 by blast
blanchet@48975
   491
         with 4 have False by simp
blanchet@48975
   492
        }
blanchet@48975
   493
        thus "(x,?a) \<in> r" by blast
blanchet@48975
   494
      qed
blanchet@48975
   495
    next
blanchet@48975
   496
      show "underS ?a \<le> A"
blanchet@48975
   497
      proof(unfold underS_def, auto)
blanchet@48975
   498
        fix x
blanchet@48975
   499
        assume **: "x \<noteq> ?a" and ***: "(x,?a) \<in> r"
blanchet@48975
   500
        hence 11: "x \<in> Field r" using Field_def by fastforce
blanchet@48975
   501
         {assume "x \<notin> A"
blanchet@48975
   502
          hence "x \<in> ?B" using 11 by auto
blanchet@48975
   503
          hence "(?a,x) \<in> r" using 3 minim_least[of ?B x] by blast
blanchet@48975
   504
          hence False
blanchet@48975
   505
          using ANTISYM antisym_def[of r] ** *** by auto
blanchet@48975
   506
         }
blanchet@48975
   507
        thus "x \<in> A" by blast
blanchet@48975
   508
      qed
blanchet@48975
   509
    qed
blanchet@48975
   510
    ultimately have ?One using 2 by blast
blanchet@48975
   511
    thus ?thesis by simp
blanchet@48975
   512
  qed
blanchet@48975
   513
qed
blanchet@48975
   514
blanchet@48975
   515
blanchet@48975
   516
lemma ofilter_UNION:
blanchet@48975
   517
"(\<And> i. i \<in> I \<Longrightarrow> ofilter(A i)) \<Longrightarrow> ofilter (\<Union> i \<in> I. A i)"
blanchet@48975
   518
unfolding ofilter_def by blast
blanchet@48975
   519
blanchet@48975
   520
blanchet@48975
   521
lemma ofilter_under_UNION:
blanchet@48975
   522
assumes "ofilter A"
blanchet@48975
   523
shows "A = (\<Union> a \<in> A. under a)"
blanchet@48975
   524
proof
blanchet@48975
   525
  have "\<forall>a \<in> A. under a \<le> A"
blanchet@48975
   526
  using assms ofilter_def by auto
blanchet@48975
   527
  thus "(\<Union> a \<in> A. under a) \<le> A" by blast
blanchet@48975
   528
next
blanchet@48975
   529
  have "\<forall>a \<in> A. a \<in> under a"
blanchet@48975
   530
  using REFL Refl_under_in assms ofilter_def by blast
blanchet@48975
   531
  thus "A \<le> (\<Union> a \<in> A. under a)" by blast
blanchet@48975
   532
qed
blanchet@48975
   533
blanchet@48975
   534
blanchet@48975
   535
subsubsection{* Other properties *}
blanchet@48975
   536
blanchet@48975
   537
blanchet@48975
   538
lemma ofilter_linord:
blanchet@48975
   539
assumes OF1: "ofilter A" and OF2: "ofilter B"
blanchet@48975
   540
shows "A \<le> B \<or> B \<le> A"
blanchet@48975
   541
proof(cases "A = Field r")
blanchet@48975
   542
  assume Case1: "A = Field r"
blanchet@48975
   543
  hence "B \<le> A" using OF2 ofilter_def by auto
blanchet@48975
   544
  thus ?thesis by simp
blanchet@48975
   545
next
blanchet@48975
   546
  assume Case2: "A \<noteq> Field r"
blanchet@48975
   547
  with ofilter_underS_Field OF1 obtain a where
blanchet@48975
   548
  1: "a \<in> Field r \<and> A = underS a" by auto
blanchet@48975
   549
  show ?thesis
blanchet@48975
   550
  proof(cases "B = Field r")
blanchet@48975
   551
    assume Case21: "B = Field r"
blanchet@48975
   552
    hence "A \<le> B" using OF1 ofilter_def by auto
blanchet@48975
   553
    thus ?thesis by simp
blanchet@48975
   554
  next
blanchet@48975
   555
    assume Case22: "B \<noteq> Field r"
blanchet@48975
   556
    with ofilter_underS_Field OF2 obtain b where
blanchet@48975
   557
    2: "b \<in> Field r \<and> B = underS b" by auto
blanchet@48975
   558
    have "a = b \<or> (a,b) \<in> r \<or> (b,a) \<in> r"
blanchet@48975
   559
    using 1 2 TOTAL total_on_def[of _ r] by auto
blanchet@48975
   560
    moreover
blanchet@48975
   561
    {assume "a = b" with 1 2 have ?thesis by auto
blanchet@48975
   562
    }
blanchet@48975
   563
    moreover
blanchet@48975
   564
    {assume "(a,b) \<in> r"
blanchet@48975
   565
     with underS_incr TRANS ANTISYM 1 2
blanchet@48975
   566
     have "A \<le> B" by auto
blanchet@48975
   567
     hence ?thesis by auto
blanchet@48975
   568
    }
blanchet@48975
   569
    moreover
blanchet@48975
   570
     {assume "(b,a) \<in> r"
blanchet@48975
   571
     with underS_incr TRANS ANTISYM 1 2
blanchet@48975
   572
     have "B \<le> A" by auto
blanchet@48975
   573
     hence ?thesis by auto
blanchet@48975
   574
    }
blanchet@48975
   575
    ultimately show ?thesis by blast
blanchet@48975
   576
  qed
blanchet@48975
   577
qed
blanchet@48975
   578
blanchet@48975
   579
blanchet@48975
   580
lemma ofilter_AboveS_Field:
blanchet@48975
   581
assumes "ofilter A"
blanchet@48975
   582
shows "A \<union> (AboveS A) = Field r"
blanchet@48975
   583
proof
blanchet@48975
   584
  show "A \<union> (AboveS A) \<le> Field r"
blanchet@48975
   585
  using assms ofilter_def AboveS_Field by auto
blanchet@48975
   586
next
blanchet@48975
   587
  {fix x assume *: "x \<in> Field r" and **: "x \<notin> A"
blanchet@48975
   588
   {fix y assume ***: "y \<in> A"
blanchet@48975
   589
    with ** have 1: "y \<noteq> x" by auto
blanchet@48975
   590
    {assume "(y,x) \<notin> r"
blanchet@48975
   591
     moreover
blanchet@48975
   592
     have "y \<in> Field r" using assms ofilter_def *** by auto
blanchet@48975
   593
     ultimately have "(x,y) \<in> r"
blanchet@48975
   594
     using 1 * TOTAL total_on_def[of _ r] by auto
blanchet@48975
   595
     with *** assms ofilter_def under_def have "x \<in> A" by auto
blanchet@48975
   596
     with ** have False by contradiction
blanchet@48975
   597
    }
blanchet@48975
   598
    hence "(y,x) \<in> r" by blast
blanchet@48975
   599
    with 1 have "y \<noteq> x \<and> (y,x) \<in> r" by auto
blanchet@48975
   600
   }
blanchet@48975
   601
   with * have "x \<in> AboveS A" unfolding AboveS_def by auto
blanchet@48975
   602
  }
blanchet@48975
   603
  thus "Field r \<le> A \<union> (AboveS A)" by blast
blanchet@48975
   604
qed
blanchet@48975
   605
blanchet@48975
   606
blanchet@48975
   607
lemma suc_ofilter_in:
blanchet@48975
   608
assumes OF: "ofilter A" and ABOVE_NE: "AboveS A \<noteq> {}" and
blanchet@48975
   609
        REL: "(b,suc A) \<in> r" and DIFF: "b \<noteq> suc A"
blanchet@48975
   610
shows "b \<in> A"
blanchet@48975
   611
proof-
blanchet@48975
   612
  have *: "suc A \<in> Field r \<and> b \<in> Field r"
blanchet@48975
   613
  using WELL REL well_order_on_domain by auto
blanchet@48975
   614
  {assume **: "b \<notin> A"
blanchet@48975
   615
   hence "b \<in> AboveS A"
blanchet@48975
   616
   using OF * ofilter_AboveS_Field by auto
blanchet@48975
   617
   hence "(suc A, b) \<in> r"
blanchet@48975
   618
   using suc_least_AboveS by auto
blanchet@48975
   619
   hence False using REL DIFF ANTISYM *
blanchet@48975
   620
   by (auto simp add: antisym_def)
blanchet@48975
   621
  }
blanchet@48975
   622
  thus ?thesis by blast
blanchet@48975
   623
qed
blanchet@48975
   624
blanchet@48975
   625
blanchet@48975
   626
blanchet@48975
   627
end (* context wo_rel *)
blanchet@48975
   628
blanchet@48975
   629
blanchet@48975
   630
blanchet@48975
   631
end