src/HOL/Conditionally_Complete_Lattices.thy
author hoelzl
Tue Nov 05 09:45:00 2013 +0100 (2013-11-05)
changeset 54262 326fd7103cb4
parent 54261 89991ef58448
child 54263 c4159fe6fa46
permissions -rw-r--r--
generalize bdd_above/below_uminus to ordered_ab_group_add
wenzelm@52265
     1
(*  Title:      HOL/Conditionally_Complete_Lattices.thy
hoelzl@51518
     2
    Author:     Amine Chaieb and L C Paulson, University of Cambridge
hoelzl@51643
     3
    Author:     Johannes Hölzl, TU München
hoelzl@54258
     4
    Author:     Luke S. Serafin, Carnegie Mellon University
hoelzl@51518
     5
*)
paulson@33269
     6
hoelzl@51773
     7
header {* Conditionally-complete Lattices *}
paulson@33269
     8
hoelzl@51773
     9
theory Conditionally_Complete_Lattices
hoelzl@51518
    10
imports Main Lubs
paulson@33269
    11
begin
paulson@33269
    12
hoelzl@54259
    13
lemma (in linorder) Sup_fin_eq_Max: "finite X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Sup_fin X = Max X"
hoelzl@51475
    14
  by (induct X rule: finite_ne_induct) (simp_all add: sup_max)
hoelzl@51475
    15
hoelzl@54259
    16
lemma (in linorder) Inf_fin_eq_Min: "finite X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Inf_fin X = Min X"
hoelzl@51475
    17
  by (induct X rule: finite_ne_induct) (simp_all add: inf_min)
hoelzl@51475
    18
hoelzl@54258
    19
context preorder
hoelzl@54258
    20
begin
hoelzl@54258
    21
hoelzl@54258
    22
definition "bdd_above A \<longleftrightarrow> (\<exists>M. \<forall>x \<in> A. x \<le> M)"
hoelzl@54258
    23
definition "bdd_below A \<longleftrightarrow> (\<exists>m. \<forall>x \<in> A. m \<le> x)"
hoelzl@54258
    24
hoelzl@54258
    25
lemma bdd_aboveI[intro]: "(\<And>x. x \<in> A \<Longrightarrow> x \<le> M) \<Longrightarrow> bdd_above A"
hoelzl@54258
    26
  by (auto simp: bdd_above_def)
hoelzl@54258
    27
hoelzl@54258
    28
lemma bdd_belowI[intro]: "(\<And>x. x \<in> A \<Longrightarrow> m \<le> x) \<Longrightarrow> bdd_below A"
hoelzl@54258
    29
  by (auto simp: bdd_below_def)
hoelzl@54258
    30
hoelzl@54258
    31
lemma bdd_above_empty [simp, intro]: "bdd_above {}"
hoelzl@54258
    32
  unfolding bdd_above_def by auto
hoelzl@54258
    33
hoelzl@54258
    34
lemma bdd_below_empty [simp, intro]: "bdd_below {}"
hoelzl@54258
    35
  unfolding bdd_below_def by auto
hoelzl@54258
    36
hoelzl@54258
    37
lemma bdd_above_mono: "bdd_above B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> bdd_above A"
hoelzl@54258
    38
  by (metis (full_types) bdd_above_def order_class.le_neq_trans psubsetD)
hoelzl@54258
    39
hoelzl@54258
    40
lemma bdd_below_mono: "bdd_below B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> bdd_below A"
hoelzl@54258
    41
  by (metis bdd_below_def order_class.le_neq_trans psubsetD)
hoelzl@54258
    42
hoelzl@54258
    43
lemma bdd_above_Int1 [simp]: "bdd_above A \<Longrightarrow> bdd_above (A \<inter> B)"
hoelzl@54258
    44
  using bdd_above_mono by auto
hoelzl@54258
    45
hoelzl@54258
    46
lemma bdd_above_Int2 [simp]: "bdd_above B \<Longrightarrow> bdd_above (A \<inter> B)"
hoelzl@54258
    47
  using bdd_above_mono by auto
hoelzl@54258
    48
hoelzl@54258
    49
lemma bdd_below_Int1 [simp]: "bdd_below A \<Longrightarrow> bdd_below (A \<inter> B)"
hoelzl@54258
    50
  using bdd_below_mono by auto
hoelzl@54258
    51
hoelzl@54258
    52
lemma bdd_below_Int2 [simp]: "bdd_below B \<Longrightarrow> bdd_below (A \<inter> B)"
hoelzl@54258
    53
  using bdd_below_mono by auto
hoelzl@54258
    54
hoelzl@54258
    55
lemma bdd_above_Ioo [simp, intro]: "bdd_above {a <..< b}"
hoelzl@54258
    56
  by (auto simp add: bdd_above_def intro!: exI[of _ b] less_imp_le)
hoelzl@54258
    57
hoelzl@54258
    58
lemma bdd_above_Ico [simp, intro]: "bdd_above {a ..< b}"
hoelzl@54258
    59
  by (auto simp add: bdd_above_def intro!: exI[of _ b] less_imp_le)
hoelzl@54258
    60
hoelzl@54258
    61
lemma bdd_above_Iio [simp, intro]: "bdd_above {..< b}"
hoelzl@54258
    62
  by (auto simp add: bdd_above_def intro: exI[of _ b] less_imp_le)
hoelzl@54258
    63
hoelzl@54258
    64
lemma bdd_above_Ioc [simp, intro]: "bdd_above {a <.. b}"
hoelzl@54258
    65
  by (auto simp add: bdd_above_def intro: exI[of _ b] less_imp_le)
hoelzl@54258
    66
hoelzl@54258
    67
lemma bdd_above_Icc [simp, intro]: "bdd_above {a .. b}"
hoelzl@54258
    68
  by (auto simp add: bdd_above_def intro: exI[of _ b] less_imp_le)
hoelzl@54258
    69
hoelzl@54258
    70
lemma bdd_above_Iic [simp, intro]: "bdd_above {.. b}"
hoelzl@54258
    71
  by (auto simp add: bdd_above_def intro: exI[of _ b] less_imp_le)
hoelzl@54258
    72
hoelzl@54258
    73
lemma bdd_below_Ioo [simp, intro]: "bdd_below {a <..< b}"
hoelzl@54258
    74
  by (auto simp add: bdd_below_def intro!: exI[of _ a] less_imp_le)
hoelzl@54258
    75
hoelzl@54258
    76
lemma bdd_below_Ioc [simp, intro]: "bdd_below {a <.. b}"
hoelzl@54258
    77
  by (auto simp add: bdd_below_def intro!: exI[of _ a] less_imp_le)
hoelzl@54258
    78
hoelzl@54258
    79
lemma bdd_below_Ioi [simp, intro]: "bdd_below {a <..}"
hoelzl@54258
    80
  by (auto simp add: bdd_below_def intro: exI[of _ a] less_imp_le)
hoelzl@54258
    81
hoelzl@54258
    82
lemma bdd_below_Ico [simp, intro]: "bdd_below {a ..< b}"
hoelzl@54258
    83
  by (auto simp add: bdd_below_def intro: exI[of _ a] less_imp_le)
hoelzl@54258
    84
hoelzl@54258
    85
lemma bdd_below_Icc [simp, intro]: "bdd_below {a .. b}"
hoelzl@54258
    86
  by (auto simp add: bdd_below_def intro: exI[of _ a] less_imp_le)
hoelzl@54258
    87
hoelzl@54258
    88
lemma bdd_below_Ici [simp, intro]: "bdd_below {a ..}"
hoelzl@54258
    89
  by (auto simp add: bdd_below_def intro: exI[of _ a] less_imp_le)
hoelzl@54258
    90
hoelzl@54258
    91
end
hoelzl@54258
    92
hoelzl@54261
    93
lemma (in order_top) bdd_above_top[simp, intro!]: "bdd_above A"
hoelzl@54261
    94
  by (rule bdd_aboveI[of _ top]) simp
hoelzl@54261
    95
hoelzl@54261
    96
lemma (in order_bot) bdd_above_bot[simp, intro!]: "bdd_below A"
hoelzl@54261
    97
  by (rule bdd_belowI[of _ bot]) simp
hoelzl@54261
    98
hoelzl@54262
    99
lemma bdd_above_uminus[simp]:
hoelzl@54262
   100
  fixes X :: "'a::ordered_ab_group_add set"
hoelzl@54262
   101
  shows "bdd_above (uminus ` X) \<longleftrightarrow> bdd_below X"
hoelzl@54262
   102
  by (auto simp: bdd_above_def bdd_below_def intro: le_imp_neg_le) (metis le_imp_neg_le minus_minus)
hoelzl@54262
   103
hoelzl@54262
   104
lemma bdd_below_uminus[simp]:
hoelzl@54262
   105
  fixes X :: "'a::ordered_ab_group_add set"
hoelzl@54262
   106
  shows"bdd_below (uminus ` X) \<longleftrightarrow> bdd_above X"
hoelzl@54262
   107
  by (auto simp: bdd_above_def bdd_below_def intro: le_imp_neg_le) (metis le_imp_neg_le minus_minus)
hoelzl@54262
   108
hoelzl@54258
   109
context lattice
hoelzl@54258
   110
begin
hoelzl@54258
   111
hoelzl@54258
   112
lemma bdd_above_insert [simp]: "bdd_above (insert a A) = bdd_above A"
hoelzl@54258
   113
  by (auto simp: bdd_above_def intro: le_supI2 sup_ge1)
hoelzl@54258
   114
hoelzl@54258
   115
lemma bdd_below_insert [simp]: "bdd_below (insert a A) = bdd_below A"
hoelzl@54258
   116
  by (auto simp: bdd_below_def intro: le_infI2 inf_le1)
hoelzl@54258
   117
hoelzl@54258
   118
lemma bdd_finite [simp]:
hoelzl@54258
   119
  assumes "finite A" shows bdd_above_finite: "bdd_above A" and bdd_below_finite: "bdd_below A"
hoelzl@54258
   120
  using assms by (induct rule: finite_induct, auto)
hoelzl@54258
   121
hoelzl@54258
   122
lemma bdd_above_Un [simp]: "bdd_above (A \<union> B) = (bdd_above A \<and> bdd_above B)"
hoelzl@54258
   123
proof
hoelzl@54258
   124
  assume "bdd_above (A \<union> B)"
hoelzl@54258
   125
  thus "bdd_above A \<and> bdd_above B" unfolding bdd_above_def by auto
hoelzl@54258
   126
next
hoelzl@54258
   127
  assume "bdd_above A \<and> bdd_above B"
hoelzl@54258
   128
  then obtain a b where "\<forall>x\<in>A. x \<le> a" "\<forall>x\<in>B. x \<le> b" unfolding bdd_above_def by auto
hoelzl@54258
   129
  hence "\<forall>x \<in> A \<union> B. x \<le> sup a b" by (auto intro: Un_iff le_supI1 le_supI2)
hoelzl@54258
   130
  thus "bdd_above (A \<union> B)" unfolding bdd_above_def ..
hoelzl@54258
   131
qed
hoelzl@54258
   132
hoelzl@54258
   133
lemma bdd_below_Un [simp]: "bdd_below (A \<union> B) = (bdd_below A \<and> bdd_below B)"
hoelzl@54258
   134
proof
hoelzl@54258
   135
  assume "bdd_below (A \<union> B)"
hoelzl@54258
   136
  thus "bdd_below A \<and> bdd_below B" unfolding bdd_below_def by auto
hoelzl@54258
   137
next
hoelzl@54258
   138
  assume "bdd_below A \<and> bdd_below B"
hoelzl@54258
   139
  then obtain a b where "\<forall>x\<in>A. a \<le> x" "\<forall>x\<in>B. b \<le> x" unfolding bdd_below_def by auto
hoelzl@54258
   140
  hence "\<forall>x \<in> A \<union> B. inf a b \<le> x" by (auto intro: Un_iff le_infI1 le_infI2)
hoelzl@54258
   141
  thus "bdd_below (A \<union> B)" unfolding bdd_below_def ..
hoelzl@54258
   142
qed
hoelzl@54258
   143
hoelzl@54259
   144
lemma bdd_above_sup[simp]: "bdd_above ((\<lambda>x. sup (f x) (g x)) ` A) \<longleftrightarrow> bdd_above (f`A) \<and> bdd_above (g`A)"
hoelzl@54259
   145
  by (auto simp: bdd_above_def intro: le_supI1 le_supI2)
hoelzl@54259
   146
hoelzl@54259
   147
lemma bdd_below_inf[simp]: "bdd_below ((\<lambda>x. inf (f x) (g x)) ` A) \<longleftrightarrow> bdd_below (f`A) \<and> bdd_below (g`A)"
hoelzl@54259
   148
  by (auto simp: bdd_below_def intro: le_infI1 le_infI2)
hoelzl@54259
   149
hoelzl@54258
   150
end
hoelzl@54258
   151
hoelzl@54258
   152
hoelzl@51475
   153
text {*
hoelzl@51475
   154
hoelzl@51475
   155
To avoid name classes with the @{class complete_lattice}-class we prefix @{const Sup} and
hoelzl@51475
   156
@{const Inf} in theorem names with c.
hoelzl@51475
   157
hoelzl@51475
   158
*}
hoelzl@51475
   159
hoelzl@51773
   160
class conditionally_complete_lattice = lattice + Sup + Inf +
hoelzl@54258
   161
  assumes cInf_lower: "x \<in> X \<Longrightarrow> bdd_below X \<Longrightarrow> Inf X \<le> x"
hoelzl@51475
   162
    and cInf_greatest: "X \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> z \<le> Inf X"
hoelzl@54258
   163
  assumes cSup_upper: "x \<in> X \<Longrightarrow> bdd_above X \<Longrightarrow> x \<le> Sup X"
hoelzl@51475
   164
    and cSup_least: "X \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> x \<le> z) \<Longrightarrow> Sup X \<le> z"
paulson@33269
   165
begin
hoelzl@51475
   166
hoelzl@54259
   167
lemma cSup_upper2: "x \<in> X \<Longrightarrow> y \<le> x \<Longrightarrow> bdd_above X \<Longrightarrow> y \<le> Sup X"
hoelzl@54259
   168
  by (metis cSup_upper order_trans)
hoelzl@54259
   169
hoelzl@54259
   170
lemma cInf_lower2: "x \<in> X \<Longrightarrow> x \<le> y \<Longrightarrow> bdd_below X \<Longrightarrow> Inf X \<le> y"
hoelzl@54259
   171
  by (metis cInf_lower order_trans)
hoelzl@54259
   172
hoelzl@54259
   173
lemma cSup_mono: "B \<noteq> {} \<Longrightarrow> bdd_above A \<Longrightarrow> (\<And>b. b \<in> B \<Longrightarrow> \<exists>a\<in>A. b \<le> a) \<Longrightarrow> Sup B \<le> Sup A"
hoelzl@54259
   174
  by (metis cSup_least cSup_upper2)
hoelzl@54259
   175
hoelzl@54259
   176
lemma cInf_mono: "B \<noteq> {} \<Longrightarrow> bdd_below A \<Longrightarrow> (\<And>b. b \<in> B \<Longrightarrow> \<exists>a\<in>A. a \<le> b) \<Longrightarrow> Inf A \<le> Inf B"
hoelzl@54259
   177
  by (metis cInf_greatest cInf_lower2)
hoelzl@54259
   178
hoelzl@54259
   179
lemma cSup_subset_mono: "A \<noteq> {} \<Longrightarrow> bdd_above B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> Sup A \<le> Sup B"
hoelzl@54259
   180
  by (metis cSup_least cSup_upper subsetD)
hoelzl@54259
   181
hoelzl@54259
   182
lemma cInf_superset_mono: "A \<noteq> {} \<Longrightarrow> bdd_below B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> Inf B \<le> Inf A"
hoelzl@54259
   183
  by (metis cInf_greatest cInf_lower subsetD)
hoelzl@54259
   184
hoelzl@54258
   185
lemma cSup_eq_maximum: "z \<in> X \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> x \<le> z) \<Longrightarrow> Sup X = z"
hoelzl@54258
   186
  by (intro antisym cSup_upper[of z X] cSup_least[of X z]) auto
hoelzl@51475
   187
hoelzl@54258
   188
lemma cInf_eq_minimum: "z \<in> X \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> Inf X = z"
hoelzl@54258
   189
  by (intro antisym cInf_lower[of z X] cInf_greatest[of X z]) auto
hoelzl@51475
   190
hoelzl@54258
   191
lemma cSup_le_iff: "S \<noteq> {} \<Longrightarrow> bdd_above S \<Longrightarrow> Sup S \<le> a \<longleftrightarrow> (\<forall>x\<in>S. x \<le> a)"
hoelzl@51475
   192
  by (metis order_trans cSup_upper cSup_least)
hoelzl@51475
   193
hoelzl@54258
   194
lemma le_cInf_iff: "S \<noteq> {} \<Longrightarrow> bdd_below S \<Longrightarrow> a \<le> Inf S \<longleftrightarrow> (\<forall>x\<in>S. a \<le> x)"
hoelzl@51475
   195
  by (metis order_trans cInf_lower cInf_greatest)
hoelzl@51475
   196
hoelzl@51475
   197
lemma cSup_eq_non_empty:
hoelzl@51475
   198
  assumes 1: "X \<noteq> {}"
hoelzl@51475
   199
  assumes 2: "\<And>x. x \<in> X \<Longrightarrow> x \<le> a"
hoelzl@51475
   200
  assumes 3: "\<And>y. (\<And>x. x \<in> X \<Longrightarrow> x \<le> y) \<Longrightarrow> a \<le> y"
hoelzl@51475
   201
  shows "Sup X = a"
hoelzl@51475
   202
  by (intro 3 1 antisym cSup_least) (auto intro: 2 1 cSup_upper)
hoelzl@51475
   203
hoelzl@51475
   204
lemma cInf_eq_non_empty:
hoelzl@51475
   205
  assumes 1: "X \<noteq> {}"
hoelzl@51475
   206
  assumes 2: "\<And>x. x \<in> X \<Longrightarrow> a \<le> x"
hoelzl@51475
   207
  assumes 3: "\<And>y. (\<And>x. x \<in> X \<Longrightarrow> y \<le> x) \<Longrightarrow> y \<le> a"
hoelzl@51475
   208
  shows "Inf X = a"
hoelzl@51475
   209
  by (intro 3 1 antisym cInf_greatest) (auto intro: 2 1 cInf_lower)
hoelzl@51475
   210
hoelzl@54258
   211
lemma cInf_cSup: "S \<noteq> {} \<Longrightarrow> bdd_below S \<Longrightarrow> Inf S = Sup {x. \<forall>s\<in>S. x \<le> s}"
hoelzl@54258
   212
  by (rule cInf_eq_non_empty) (auto intro!: cSup_upper cSup_least simp: bdd_below_def)
hoelzl@51518
   213
hoelzl@54258
   214
lemma cSup_cInf: "S \<noteq> {} \<Longrightarrow> bdd_above S \<Longrightarrow> Sup S = Inf {x. \<forall>s\<in>S. s \<le> x}"
hoelzl@54258
   215
  by (rule cSup_eq_non_empty) (auto intro!: cInf_lower cInf_greatest simp: bdd_above_def)
hoelzl@54258
   216
hoelzl@54258
   217
lemma cSup_insert: "X \<noteq> {} \<Longrightarrow> bdd_above X \<Longrightarrow> Sup (insert a X) = sup a (Sup X)"
hoelzl@54258
   218
  by (intro cSup_eq_non_empty) (auto intro: le_supI2 cSup_upper cSup_least)
paulson@33269
   219
hoelzl@54258
   220
lemma cInf_insert: "X \<noteq> {} \<Longrightarrow> bdd_below X \<Longrightarrow> Inf (insert a X) = inf a (Inf X)"
hoelzl@54258
   221
  by (intro cInf_eq_non_empty) (auto intro: le_infI2 cInf_lower cInf_greatest)
hoelzl@51475
   222
hoelzl@54259
   223
lemma cSup_singleton [simp]: "Sup {x} = x"
hoelzl@54259
   224
  by (intro cSup_eq_maximum) auto
hoelzl@54259
   225
hoelzl@54259
   226
lemma cInf_singleton [simp]: "Inf {x} = x"
hoelzl@54259
   227
  by (intro cInf_eq_minimum) auto
hoelzl@54259
   228
hoelzl@54258
   229
lemma cSup_insert_If:  "bdd_above X \<Longrightarrow> Sup (insert a X) = (if X = {} then a else sup a (Sup X))"
hoelzl@54258
   230
  using cSup_insert[of X] by simp
hoelzl@51475
   231
hoelzl@54259
   232
lemma cInf_insert_If: "bdd_below X \<Longrightarrow> Inf (insert a X) = (if X = {} then a else inf a (Inf X))"
hoelzl@54258
   233
  using cInf_insert[of X] by simp
hoelzl@51475
   234
hoelzl@51475
   235
lemma le_cSup_finite: "finite X \<Longrightarrow> x \<in> X \<Longrightarrow> x \<le> Sup X"
hoelzl@51475
   236
proof (induct X arbitrary: x rule: finite_induct)
hoelzl@51475
   237
  case (insert x X y) then show ?case
hoelzl@54258
   238
    by (cases "X = {}") (auto simp: cSup_insert intro: le_supI2)
hoelzl@51475
   239
qed simp
hoelzl@51475
   240
hoelzl@51475
   241
lemma cInf_le_finite: "finite X \<Longrightarrow> x \<in> X \<Longrightarrow> Inf X \<le> x"
hoelzl@51475
   242
proof (induct X arbitrary: x rule: finite_induct)
hoelzl@51475
   243
  case (insert x X y) then show ?case
hoelzl@54258
   244
    by (cases "X = {}") (auto simp: cInf_insert intro: le_infI2)
hoelzl@51475
   245
qed simp
hoelzl@51475
   246
hoelzl@51475
   247
lemma cSup_eq_Sup_fin: "finite X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Sup X = Sup_fin X"
hoelzl@54258
   248
  by (induct X rule: finite_ne_induct) (simp_all add: cSup_insert)
hoelzl@51475
   249
hoelzl@51475
   250
lemma cInf_eq_Inf_fin: "finite X \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Inf X = Inf_fin X"
hoelzl@54258
   251
  by (induct X rule: finite_ne_induct) (simp_all add: cInf_insert)
hoelzl@51475
   252
hoelzl@51475
   253
lemma cSup_atMost[simp]: "Sup {..x} = x"
hoelzl@51475
   254
  by (auto intro!: cSup_eq_maximum)
hoelzl@51475
   255
hoelzl@51475
   256
lemma cSup_greaterThanAtMost[simp]: "y < x \<Longrightarrow> Sup {y<..x} = x"
hoelzl@51475
   257
  by (auto intro!: cSup_eq_maximum)
hoelzl@51475
   258
hoelzl@51475
   259
lemma cSup_atLeastAtMost[simp]: "y \<le> x \<Longrightarrow> Sup {y..x} = x"
hoelzl@51475
   260
  by (auto intro!: cSup_eq_maximum)
hoelzl@51475
   261
hoelzl@51475
   262
lemma cInf_atLeast[simp]: "Inf {x..} = x"
hoelzl@51475
   263
  by (auto intro!: cInf_eq_minimum)
hoelzl@51475
   264
hoelzl@51475
   265
lemma cInf_atLeastLessThan[simp]: "y < x \<Longrightarrow> Inf {y..<x} = y"
hoelzl@51475
   266
  by (auto intro!: cInf_eq_minimum)
hoelzl@51475
   267
hoelzl@51475
   268
lemma cInf_atLeastAtMost[simp]: "y \<le> x \<Longrightarrow> Inf {y..x} = y"
hoelzl@51475
   269
  by (auto intro!: cInf_eq_minimum)
hoelzl@51475
   270
hoelzl@54259
   271
lemma cINF_lower: "bdd_below (f ` A) \<Longrightarrow> x \<in> A \<Longrightarrow> INFI A f \<le> f x"
hoelzl@54259
   272
  unfolding INF_def by (rule cInf_lower) auto
hoelzl@54259
   273
hoelzl@54259
   274
lemma cINF_greatest: "A \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> m \<le> f x) \<Longrightarrow> m \<le> INFI A f"
hoelzl@54259
   275
  unfolding INF_def by (rule cInf_greatest) auto
hoelzl@54259
   276
hoelzl@54259
   277
lemma cSUP_upper: "x \<in> A \<Longrightarrow> bdd_above (f ` A) \<Longrightarrow> f x \<le> SUPR A f"
hoelzl@54259
   278
  unfolding SUP_def by (rule cSup_upper) auto
hoelzl@54259
   279
hoelzl@54259
   280
lemma cSUP_least: "A \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<le> M) \<Longrightarrow> SUPR A f \<le> M"
hoelzl@54259
   281
  unfolding SUP_def by (rule cSup_least) auto
hoelzl@54259
   282
hoelzl@54259
   283
lemma cINF_lower2: "bdd_below (f ` A) \<Longrightarrow> x \<in> A \<Longrightarrow> f x \<le> u \<Longrightarrow> INFI A f \<le> u"
hoelzl@54259
   284
  by (auto intro: cINF_lower assms order_trans)
hoelzl@54259
   285
hoelzl@54259
   286
lemma cSUP_upper2: "bdd_above (f ` A) \<Longrightarrow> x \<in> A \<Longrightarrow> u \<le> f x \<Longrightarrow> u \<le> SUPR A f"
hoelzl@54259
   287
  by (auto intro: cSUP_upper assms order_trans)
hoelzl@54259
   288
hoelzl@54261
   289
lemma cSUP_const: "A \<noteq> {} \<Longrightarrow> (SUP x:A. c) = c"
hoelzl@54261
   290
  by (intro antisym cSUP_least) (auto intro: cSUP_upper)
hoelzl@54261
   291
hoelzl@54261
   292
lemma cINF_const: "A \<noteq> {} \<Longrightarrow> (INF x:A. c) = c"
hoelzl@54261
   293
  by (intro antisym cINF_greatest) (auto intro: cINF_lower)
hoelzl@54261
   294
hoelzl@54259
   295
lemma le_cINF_iff: "A \<noteq> {} \<Longrightarrow> bdd_below (f ` A) \<Longrightarrow> u \<le> INFI A f \<longleftrightarrow> (\<forall>x\<in>A. u \<le> f x)"
hoelzl@54259
   296
  by (metis cINF_greatest cINF_lower assms order_trans)
hoelzl@54259
   297
hoelzl@54259
   298
lemma cSUP_le_iff: "A \<noteq> {} \<Longrightarrow> bdd_above (f ` A) \<Longrightarrow> SUPR A f \<le> u \<longleftrightarrow> (\<forall>x\<in>A. f x \<le> u)"
hoelzl@54259
   299
  by (metis cSUP_least cSUP_upper assms order_trans)
hoelzl@54259
   300
hoelzl@54259
   301
lemma cINF_insert: "A \<noteq> {} \<Longrightarrow> bdd_below (f ` A) \<Longrightarrow> INFI (insert a A) f = inf (f a) (INFI A f)"
hoelzl@54259
   302
  by (metis INF_def cInf_insert assms empty_is_image image_insert)
hoelzl@54259
   303
hoelzl@54259
   304
lemma cSUP_insert: "A \<noteq> {} \<Longrightarrow> bdd_above (f ` A) \<Longrightarrow> SUPR (insert a A) f = sup (f a) (SUPR A f)"
hoelzl@54259
   305
  by (metis SUP_def cSup_insert assms empty_is_image image_insert)
hoelzl@54259
   306
hoelzl@54259
   307
lemma cINF_mono: "B \<noteq> {} \<Longrightarrow> bdd_below (f ` A) \<Longrightarrow> (\<And>m. m \<in> B \<Longrightarrow> \<exists>n\<in>A. f n \<le> g m) \<Longrightarrow> INFI A f \<le> INFI B g"
hoelzl@54259
   308
  unfolding INF_def by (auto intro: cInf_mono)
hoelzl@54259
   309
hoelzl@54259
   310
lemma cSUP_mono: "A \<noteq> {} \<Longrightarrow> bdd_above (g ` B) \<Longrightarrow> (\<And>n. n \<in> A \<Longrightarrow> \<exists>m\<in>B. f n \<le> g m) \<Longrightarrow> SUPR A f \<le> SUPR B g"
hoelzl@54259
   311
  unfolding SUP_def by (auto intro: cSup_mono)
hoelzl@54259
   312
hoelzl@54259
   313
lemma cINF_superset_mono: "A \<noteq> {} \<Longrightarrow> bdd_below (g ` B) \<Longrightarrow> A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> g x \<le> f x) \<Longrightarrow> INFI B g \<le> INFI A f"
hoelzl@54259
   314
  by (rule cINF_mono) auto
hoelzl@54259
   315
hoelzl@54259
   316
lemma cSUP_subset_mono: "A \<noteq> {} \<Longrightarrow> bdd_above (g ` B) \<Longrightarrow> A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> f x \<le> g x) \<Longrightarrow> SUPR A f \<le> SUPR B g"
hoelzl@54259
   317
  by (rule cSUP_mono) auto
hoelzl@54259
   318
hoelzl@54259
   319
lemma less_eq_cInf_inter: "bdd_below A \<Longrightarrow> bdd_below B \<Longrightarrow> A \<inter> B \<noteq> {} \<Longrightarrow> inf (Inf A) (Inf B) \<le> Inf (A \<inter> B)"
hoelzl@54259
   320
  by (metis cInf_superset_mono lattice_class.inf_sup_ord(1) le_infI1)
hoelzl@54259
   321
hoelzl@54259
   322
lemma cSup_inter_less_eq: "bdd_above A \<Longrightarrow> bdd_above B \<Longrightarrow> A \<inter> B \<noteq> {} \<Longrightarrow> Sup (A \<inter> B) \<le> sup (Sup A) (Sup B) "
hoelzl@54259
   323
  by (metis cSup_subset_mono lattice_class.inf_sup_ord(1) le_supI1)
hoelzl@54259
   324
hoelzl@54259
   325
lemma cInf_union_distrib: "A \<noteq> {} \<Longrightarrow> bdd_below A \<Longrightarrow> B \<noteq> {} \<Longrightarrow> bdd_below B \<Longrightarrow> Inf (A \<union> B) = inf (Inf A) (Inf B)"
hoelzl@54259
   326
  by (intro antisym le_infI cInf_greatest cInf_lower) (auto intro: le_infI1 le_infI2 cInf_lower)
hoelzl@54259
   327
hoelzl@54259
   328
lemma cINF_union: "A \<noteq> {} \<Longrightarrow> bdd_below (f`A) \<Longrightarrow> B \<noteq> {} \<Longrightarrow> bdd_below (f`B) \<Longrightarrow> INFI (A \<union> B) f = inf (INFI A f) (INFI B f)"
hoelzl@54259
   329
  unfolding INF_def using assms by (auto simp add: image_Un intro: cInf_union_distrib)
hoelzl@54259
   330
hoelzl@54259
   331
lemma cSup_union_distrib: "A \<noteq> {} \<Longrightarrow> bdd_above A \<Longrightarrow> B \<noteq> {} \<Longrightarrow> bdd_above B \<Longrightarrow> Sup (A \<union> B) = sup (Sup A) (Sup B)"
hoelzl@54259
   332
  by (intro antisym le_supI cSup_least cSup_upper) (auto intro: le_supI1 le_supI2 cSup_upper)
hoelzl@54259
   333
hoelzl@54259
   334
lemma cSUP_union: "A \<noteq> {} \<Longrightarrow> bdd_above (f`A) \<Longrightarrow> B \<noteq> {} \<Longrightarrow> bdd_above (f`B) \<Longrightarrow> SUPR (A \<union> B) f = sup (SUPR A f) (SUPR B f)"
hoelzl@54259
   335
  unfolding SUP_def by (auto simp add: image_Un intro: cSup_union_distrib)
hoelzl@54259
   336
hoelzl@54259
   337
lemma cINF_inf_distrib: "A \<noteq> {} \<Longrightarrow> bdd_below (f`A) \<Longrightarrow> bdd_below (g`A) \<Longrightarrow> inf (INFI A f) (INFI A g) = (INF a:A. inf (f a) (g a))"
hoelzl@54259
   338
  by (intro antisym le_infI cINF_greatest cINF_lower2)
hoelzl@54259
   339
     (auto intro: le_infI1 le_infI2 cINF_greatest cINF_lower le_infI)
hoelzl@54259
   340
hoelzl@54259
   341
lemma SUP_sup_distrib: "A \<noteq> {} \<Longrightarrow> bdd_above (f`A) \<Longrightarrow> bdd_above (g`A) \<Longrightarrow> sup (SUPR A f) (SUPR A g) = (SUP a:A. sup (f a) (g a))"
hoelzl@54259
   342
  by (intro antisym le_supI cSUP_least cSUP_upper2)
hoelzl@54259
   343
     (auto intro: le_supI1 le_supI2 cSUP_least cSUP_upper le_supI)
hoelzl@54259
   344
paulson@33269
   345
end
paulson@33269
   346
hoelzl@51773
   347
instance complete_lattice \<subseteq> conditionally_complete_lattice
hoelzl@51475
   348
  by default (auto intro: Sup_upper Sup_least Inf_lower Inf_greatest)
hoelzl@51475
   349
hoelzl@51475
   350
lemma isLub_cSup: 
hoelzl@51773
   351
  "(S::'a :: conditionally_complete_lattice set) \<noteq> {} \<Longrightarrow> (\<exists>b. S *<= b) \<Longrightarrow> isLub UNIV S (Sup S)"
hoelzl@51475
   352
  by  (auto simp add: isLub_def setle_def leastP_def isUb_def
hoelzl@54258
   353
            intro!: setgeI cSup_upper cSup_least)
hoelzl@51475
   354
hoelzl@51475
   355
lemma cSup_eq:
hoelzl@51773
   356
  fixes a :: "'a :: {conditionally_complete_lattice, no_bot}"
hoelzl@51475
   357
  assumes upper: "\<And>x. x \<in> X \<Longrightarrow> x \<le> a"
hoelzl@51475
   358
  assumes least: "\<And>y. (\<And>x. x \<in> X \<Longrightarrow> x \<le> y) \<Longrightarrow> a \<le> y"
hoelzl@51475
   359
  shows "Sup X = a"
hoelzl@51475
   360
proof cases
hoelzl@51475
   361
  assume "X = {}" with lt_ex[of a] least show ?thesis by (auto simp: less_le_not_le)
hoelzl@51475
   362
qed (intro cSup_eq_non_empty assms)
hoelzl@51475
   363
hoelzl@51475
   364
lemma cInf_eq:
hoelzl@51773
   365
  fixes a :: "'a :: {conditionally_complete_lattice, no_top}"
hoelzl@51475
   366
  assumes upper: "\<And>x. x \<in> X \<Longrightarrow> a \<le> x"
hoelzl@51475
   367
  assumes least: "\<And>y. (\<And>x. x \<in> X \<Longrightarrow> y \<le> x) \<Longrightarrow> y \<le> a"
hoelzl@51475
   368
  shows "Inf X = a"
hoelzl@51475
   369
proof cases
hoelzl@51475
   370
  assume "X = {}" with gt_ex[of a] least show ?thesis by (auto simp: less_le_not_le)
hoelzl@51475
   371
qed (intro cInf_eq_non_empty assms)
hoelzl@51475
   372
hoelzl@51773
   373
lemma cSup_le: "(S::'a::conditionally_complete_lattice set) \<noteq> {} \<Longrightarrow> S *<= b \<Longrightarrow> Sup S \<le> b"
hoelzl@51475
   374
  by (metis cSup_least setle_def)
hoelzl@51475
   375
hoelzl@51773
   376
lemma cInf_ge: "(S::'a :: conditionally_complete_lattice set) \<noteq> {} \<Longrightarrow> b <=* S \<Longrightarrow> Inf S \<ge> b"
hoelzl@51475
   377
  by (metis cInf_greatest setge_def)
hoelzl@51475
   378
hoelzl@51773
   379
class conditionally_complete_linorder = conditionally_complete_lattice + linorder
paulson@33269
   380
begin
hoelzl@51475
   381
hoelzl@51475
   382
lemma less_cSup_iff : (*REAL_SUP_LE in HOL4*)
hoelzl@54258
   383
  "X \<noteq> {} \<Longrightarrow> bdd_above X \<Longrightarrow> y < Sup X \<longleftrightarrow> (\<exists>x\<in>X. y < x)"
hoelzl@51475
   384
  by (rule iffI) (metis cSup_least not_less, metis cSup_upper less_le_trans)
hoelzl@51475
   385
hoelzl@54258
   386
lemma cInf_less_iff: "X \<noteq> {} \<Longrightarrow> bdd_below X \<Longrightarrow> Inf X < y \<longleftrightarrow> (\<exists>x\<in>X. x < y)"
hoelzl@51475
   387
  by (rule iffI) (metis cInf_greatest not_less, metis cInf_lower le_less_trans)
hoelzl@51475
   388
hoelzl@51475
   389
lemma less_cSupE:
hoelzl@51475
   390
  assumes "y < Sup X" "X \<noteq> {}" obtains x where "x \<in> X" "y < x"
hoelzl@51475
   391
  by (metis cSup_least assms not_le that)
hoelzl@51475
   392
hoelzl@51518
   393
lemma less_cSupD:
hoelzl@51518
   394
  "X \<noteq> {} \<Longrightarrow> z < Sup X \<Longrightarrow> \<exists>x\<in>X. z < x"
hoelzl@54258
   395
  by (metis less_cSup_iff not_leE bdd_above_def)
hoelzl@51518
   396
hoelzl@51518
   397
lemma cInf_lessD:
hoelzl@51518
   398
  "X \<noteq> {} \<Longrightarrow> Inf X < z \<Longrightarrow> \<exists>x\<in>X. x < z"
hoelzl@54258
   399
  by (metis cInf_less_iff not_leE bdd_below_def)
hoelzl@51518
   400
hoelzl@51475
   401
lemma complete_interval:
hoelzl@51475
   402
  assumes "a < b" and "P a" and "\<not> P b"
hoelzl@51475
   403
  shows "\<exists>c. a \<le> c \<and> c \<le> b \<and> (\<forall>x. a \<le> x \<and> x < c \<longrightarrow> P x) \<and>
hoelzl@51475
   404
             (\<forall>d. (\<forall>x. a \<le> x \<and> x < d \<longrightarrow> P x) \<longrightarrow> d \<le> c)"
hoelzl@51475
   405
proof (rule exI [where x = "Sup {d. \<forall>x. a \<le> x & x < d --> P x}"], auto)
hoelzl@51475
   406
  show "a \<le> Sup {d. \<forall>c. a \<le> c \<and> c < d \<longrightarrow> P c}"
hoelzl@54258
   407
    by (rule cSup_upper, auto simp: bdd_above_def)
hoelzl@51475
   408
       (metis `a < b` `\<not> P b` linear less_le)
hoelzl@51475
   409
next
hoelzl@51475
   410
  show "Sup {d. \<forall>c. a \<le> c \<and> c < d \<longrightarrow> P c} \<le> b"
hoelzl@51475
   411
    apply (rule cSup_least) 
hoelzl@51475
   412
    apply auto
hoelzl@51475
   413
    apply (metis less_le_not_le)
hoelzl@51475
   414
    apply (metis `a<b` `~ P b` linear less_le)
hoelzl@51475
   415
    done
hoelzl@51475
   416
next
hoelzl@51475
   417
  fix x
hoelzl@51475
   418
  assume x: "a \<le> x" and lt: "x < Sup {d. \<forall>c. a \<le> c \<and> c < d \<longrightarrow> P c}"
hoelzl@51475
   419
  show "P x"
hoelzl@51475
   420
    apply (rule less_cSupE [OF lt], auto)
hoelzl@51475
   421
    apply (metis less_le_not_le)
hoelzl@51475
   422
    apply (metis x) 
hoelzl@51475
   423
    done
hoelzl@51475
   424
next
hoelzl@51475
   425
  fix d
hoelzl@51475
   426
    assume 0: "\<forall>x. a \<le> x \<and> x < d \<longrightarrow> P x"
hoelzl@51475
   427
    thus "d \<le> Sup {d. \<forall>c. a \<le> c \<and> c < d \<longrightarrow> P c}"
hoelzl@54258
   428
      by (rule_tac cSup_upper, auto simp: bdd_above_def)
hoelzl@51475
   429
         (metis `a<b` `~ P b` linear less_le)
hoelzl@51475
   430
qed
hoelzl@51475
   431
hoelzl@51475
   432
end
hoelzl@51475
   433
hoelzl@54259
   434
lemma cSup_eq_Max: "finite (X::'a::conditionally_complete_linorder set) \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Sup X = Max X"
hoelzl@54259
   435
  using cSup_eq_Sup_fin[of X] Sup_fin_eq_Max[of X] by simp
hoelzl@51775
   436
hoelzl@54259
   437
lemma cInf_eq_Min: "finite (X::'a::conditionally_complete_linorder set) \<Longrightarrow> X \<noteq> {} \<Longrightarrow> Inf X = Min X"
hoelzl@54259
   438
  using cInf_eq_Inf_fin[of X] Inf_fin_eq_Min[of X] by simp
hoelzl@51775
   439
hoelzl@51518
   440
lemma cSup_bounds:
hoelzl@51773
   441
  fixes S :: "'a :: conditionally_complete_lattice set"
hoelzl@51518
   442
  assumes Se: "S \<noteq> {}" and l: "a <=* S" and u: "S *<= b"
hoelzl@51518
   443
  shows "a \<le> Sup S \<and> Sup S \<le> b"
hoelzl@51518
   444
proof-
hoelzl@51518
   445
  from isLub_cSup[OF Se] u have lub: "isLub UNIV S (Sup S)" by blast
hoelzl@51518
   446
  hence b: "Sup S \<le> b" using u 
hoelzl@51518
   447
    by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def) 
hoelzl@51518
   448
  from Se obtain y where y: "y \<in> S" by blast
hoelzl@51518
   449
  from lub l have "a \<le> Sup S"
hoelzl@51518
   450
    by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def)
hoelzl@51518
   451
       (metis le_iff_sup le_sup_iff y)
hoelzl@51518
   452
  with b show ?thesis by blast
hoelzl@51518
   453
qed
hoelzl@51518
   454
hoelzl@51773
   455
lemma cSup_unique: "(S::'a :: {conditionally_complete_linorder, no_bot} set) *<= b \<Longrightarrow> (\<forall>b'<b. \<exists>x\<in>S. b' < x) \<Longrightarrow> Sup S = b"
hoelzl@51475
   456
  by (rule cSup_eq) (auto simp: not_le[symmetric] setle_def)
hoelzl@51475
   457
hoelzl@51773
   458
lemma cInf_unique: "b <=* (S::'a :: {conditionally_complete_linorder, no_top} set) \<Longrightarrow> (\<forall>b'>b. \<exists>x\<in>S. b' > x) \<Longrightarrow> Inf S = b"
hoelzl@51475
   459
  by (rule cInf_eq) (auto simp: not_le[symmetric] setge_def)
hoelzl@51475
   460
hoelzl@54257
   461
lemma cSup_lessThan[simp]: "Sup {..<x::'a::{conditionally_complete_linorder, no_bot, dense_linorder}} = x"
hoelzl@51475
   462
  by (auto intro!: cSup_eq_non_empty intro: dense_le)
hoelzl@51475
   463
hoelzl@54257
   464
lemma cSup_greaterThanLessThan[simp]: "y < x \<Longrightarrow> Sup {y<..<x::'a::{conditionally_complete_linorder, no_bot, dense_linorder}} = x"
hoelzl@51475
   465
  by (auto intro!: cSup_eq intro: dense_le_bounded)
hoelzl@51475
   466
hoelzl@54257
   467
lemma cSup_atLeastLessThan[simp]: "y < x \<Longrightarrow> Sup {y..<x::'a::{conditionally_complete_linorder, no_bot, dense_linorder}} = x"
hoelzl@51475
   468
  by (auto intro!: cSup_eq intro: dense_le_bounded)
hoelzl@51475
   469
hoelzl@54257
   470
lemma cInf_greaterThan[simp]: "Inf {x::'a::{conditionally_complete_linorder, no_top, dense_linorder} <..} = x"
hoelzl@51475
   471
  by (auto intro!: cInf_eq intro: dense_ge)
hoelzl@51475
   472
hoelzl@54257
   473
lemma cInf_greaterThanAtMost[simp]: "y < x \<Longrightarrow> Inf {y<..x::'a::{conditionally_complete_linorder, no_top, dense_linorder}} = y"
hoelzl@51475
   474
  by (auto intro!: cInf_eq intro: dense_ge_bounded)
hoelzl@51475
   475
hoelzl@54257
   476
lemma cInf_greaterThanLessThan[simp]: "y < x \<Longrightarrow> Inf {y<..<x::'a::{conditionally_complete_linorder, no_top, dense_linorder}} = y"
hoelzl@51475
   477
  by (auto intro!: cInf_eq intro: dense_ge_bounded)
hoelzl@51475
   478
hoelzl@54259
   479
class linear_continuum = conditionally_complete_linorder + dense_linorder +
hoelzl@54259
   480
  assumes UNIV_not_singleton: "\<exists>a b::'a. a \<noteq> b"
hoelzl@54259
   481
begin
hoelzl@54259
   482
hoelzl@54259
   483
lemma ex_gt_or_lt: "\<exists>b. a < b \<or> b < a"
hoelzl@54259
   484
  by (metis UNIV_not_singleton neq_iff)
hoelzl@54259
   485
paulson@33269
   486
end
hoelzl@54259
   487
hoelzl@54259
   488
end