src/HOL/SupInf.thy
author paulson
Tue Oct 27 12:59:57 2009 +0000 (2009-10-27)
changeset 33269 3b7e2dbbd684
child 33271 7be66dee1a5a
permissions -rw-r--r--
New theory SupInf of the supremum and infimum operators for sets of reals.
paulson@33269
     1
(*  Author: Amine Chaieb and L C Paulson, University of Cambridge *)
paulson@33269
     2
paulson@33269
     3
header {*Sup and Inf Operators on Sets of Reals.*}
paulson@33269
     4
paulson@33269
     5
theory SupInf
paulson@33269
     6
imports RComplete
paulson@33269
     7
begin
paulson@33269
     8
paulson@33269
     9
lemma minus_max_eq_min:
paulson@33269
    10
  fixes x :: "'a::{lordered_ab_group_add, linorder}"
paulson@33269
    11
  shows "- (max x y) = min (-x) (-y)"
paulson@33269
    12
by (metis le_imp_neg_le linorder_linear min_max.inf_absorb2 min_max.le_iff_inf min_max.le_iff_sup min_max.sup_absorb1)
paulson@33269
    13
paulson@33269
    14
lemma minus_min_eq_max:
paulson@33269
    15
  fixes x :: "'a::{lordered_ab_group_add, linorder}"
paulson@33269
    16
  shows "- (min x y) = max (-x) (-y)"
paulson@33269
    17
by (metis minus_max_eq_min minus_minus)
paulson@33269
    18
paulson@33269
    19
lemma minus_Max_eq_Min [simp]:
paulson@33269
    20
  fixes S :: "'a::{lordered_ab_group_add, linorder} set"
paulson@33269
    21
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> - (Max S) = Min (uminus ` S)"
paulson@33269
    22
proof (induct S rule: finite_ne_induct)
paulson@33269
    23
  case (singleton x)
paulson@33269
    24
  thus ?case by simp
paulson@33269
    25
next
paulson@33269
    26
  case (insert x S)
paulson@33269
    27
  thus ?case by (simp add: minus_max_eq_min) 
paulson@33269
    28
qed
paulson@33269
    29
paulson@33269
    30
lemma minus_Min_eq_Max [simp]:
paulson@33269
    31
  fixes S :: "'a::{lordered_ab_group_add, linorder} set"
paulson@33269
    32
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> - (Min S) = Max (uminus ` S)"
paulson@33269
    33
proof (induct S rule: finite_ne_induct)
paulson@33269
    34
  case (singleton x)
paulson@33269
    35
  thus ?case by simp
paulson@33269
    36
next
paulson@33269
    37
  case (insert x S)
paulson@33269
    38
  thus ?case by (simp add: minus_min_eq_max) 
paulson@33269
    39
qed
paulson@33269
    40
paulson@33269
    41
instantiation real :: Sup 
paulson@33269
    42
begin
paulson@33269
    43
definition
paulson@33269
    44
  Sup_real_def [code del]: "Sup X == (LEAST z::real. \<forall>x\<in>X. x\<le>z)"
paulson@33269
    45
paulson@33269
    46
instance ..
paulson@33269
    47
end
paulson@33269
    48
paulson@33269
    49
instantiation real :: Inf 
paulson@33269
    50
begin
paulson@33269
    51
definition
paulson@33269
    52
  Inf_real_def [code del]: "Inf (X::real set) == - (Sup (uminus ` X))"
paulson@33269
    53
paulson@33269
    54
instance ..
paulson@33269
    55
end
paulson@33269
    56
paulson@33269
    57
subsection{*Supremum of a set of reals*}
paulson@33269
    58
paulson@33269
    59
lemma Sup_upper [intro]: (*REAL_SUP_UBOUND in HOL4*)
paulson@33269
    60
  fixes x :: real
paulson@33269
    61
  assumes x: "x \<in> X"
paulson@33269
    62
      and z: "!!x. x \<in> X \<Longrightarrow> x \<le> z"
paulson@33269
    63
  shows "x \<le> Sup X"
paulson@33269
    64
proof (auto simp add: Sup_real_def) 
paulson@33269
    65
  from reals_complete2
paulson@33269
    66
  obtain s where s: "(\<forall>y\<in>X. y \<le> s) & (\<forall>z. ((\<forall>y\<in>X. y \<le> z) --> s \<le> z))"
paulson@33269
    67
    by (blast intro: x z)
paulson@33269
    68
  hence "x \<le> s"
paulson@33269
    69
    by (blast intro: x z)
paulson@33269
    70
  also with s have "... = (LEAST z. \<forall>x\<in>X. x \<le> z)"
paulson@33269
    71
    by (fast intro: Least_equality [symmetric])  
paulson@33269
    72
  finally show "x \<le> (LEAST z. \<forall>x\<in>X. x \<le> z)" .
paulson@33269
    73
qed
paulson@33269
    74
paulson@33269
    75
lemma Sup_least [intro]: (*REAL_IMP_SUP_LE in HOL4*)
paulson@33269
    76
  fixes z :: real
paulson@33269
    77
  assumes x: "X \<noteq> {}"
paulson@33269
    78
      and z: "\<And>x. x \<in> X \<Longrightarrow> x \<le> z"
paulson@33269
    79
  shows "Sup X \<le> z"
paulson@33269
    80
proof (auto simp add: Sup_real_def) 
paulson@33269
    81
  from reals_complete2 x
paulson@33269
    82
  obtain s where s: "(\<forall>y\<in>X. y \<le> s) & (\<forall>z. ((\<forall>y\<in>X. y \<le> z) --> s \<le> z))"
paulson@33269
    83
    by (blast intro: z)
paulson@33269
    84
  hence "(LEAST z. \<forall>x\<in>X. x \<le> z) = s"
paulson@33269
    85
    by (best intro: Least_equality)  
paulson@33269
    86
  also with s z have "... \<le> z"
paulson@33269
    87
    by blast
paulson@33269
    88
  finally show "(LEAST z. \<forall>x\<in>X. x \<le> z) \<le> z" .
paulson@33269
    89
qed
paulson@33269
    90
paulson@33269
    91
lemma Sup_singleton [simp]: "Sup {x::real} = x"
paulson@33269
    92
  by (force intro: Least_equality simp add: Sup_real_def)
paulson@33269
    93
 
paulson@33269
    94
lemma Sup_eq_maximum: (*REAL_SUP_MAX in HOL4*)
paulson@33269
    95
  fixes z :: real
paulson@33269
    96
  assumes X: "z \<in> X" and z: "!!x. x \<in> X \<Longrightarrow> x \<le> z"
paulson@33269
    97
  shows  "Sup X = z"
paulson@33269
    98
  by (force intro: Least_equality X z simp add: Sup_real_def)
paulson@33269
    99
 
paulson@33269
   100
lemma Sup_upper2: (*REAL_IMP_LE_SUP in HOL4*)
paulson@33269
   101
  fixes x :: real
paulson@33269
   102
  shows "x \<in> X \<Longrightarrow> y \<le> x \<Longrightarrow> (!!x. x \<in> X \<Longrightarrow> x \<le> z) \<Longrightarrow> y \<le> Sup X"
paulson@33269
   103
  by (metis Sup_upper real_le_trans)
paulson@33269
   104
paulson@33269
   105
lemma Sup_real_iff : (*REAL_SUP_LE in HOL4*)
paulson@33269
   106
  fixes z :: real
paulson@33269
   107
  shows "X ~= {} ==> (!!x. x \<in> X ==> x \<le> z) ==> (\<exists>x\<in>X. y<x) <-> y < Sup X"
paulson@33269
   108
  by (metis Sup_least Sup_upper linorder_not_le le_less_trans)
paulson@33269
   109
paulson@33269
   110
lemma Sup_eq:
paulson@33269
   111
  fixes a :: real
paulson@33269
   112
  shows "(!!x. x \<in> X \<Longrightarrow> x \<le> a) 
paulson@33269
   113
        \<Longrightarrow> (!!y. (!!x. x \<in> X \<Longrightarrow> x \<le> y) \<Longrightarrow> a \<le> y) \<Longrightarrow> Sup X = a"
paulson@33269
   114
  by (metis Sup_least Sup_upper add_le_cancel_left diff_add_cancel insert_absorb
paulson@33269
   115
        insert_not_empty real_le_anti_sym)
paulson@33269
   116
paulson@33269
   117
lemma Sup_le:
paulson@33269
   118
  fixes S :: "real set"
paulson@33269
   119
  shows "S \<noteq> {} \<Longrightarrow> S *<= b \<Longrightarrow> Sup S \<le> b"
paulson@33269
   120
by (metis SupInf.Sup_least setle_def)
paulson@33269
   121
paulson@33269
   122
lemma Sup_upper_EX: 
paulson@33269
   123
  fixes x :: real
paulson@33269
   124
  shows "x \<in> X \<Longrightarrow> \<exists>z. \<forall>x. x \<in> X \<longrightarrow> x \<le> z \<Longrightarrow>  x \<le> Sup X"
paulson@33269
   125
  by blast
paulson@33269
   126
paulson@33269
   127
lemma Sup_insert_nonempty: 
paulson@33269
   128
  fixes x :: real
paulson@33269
   129
  assumes x: "x \<in> X"
paulson@33269
   130
      and z: "!!x. x \<in> X \<Longrightarrow> x \<le> z"
paulson@33269
   131
  shows "Sup (insert a X) = max a (Sup X)"
paulson@33269
   132
proof (cases "Sup X \<le> a")
paulson@33269
   133
  case True
paulson@33269
   134
  thus ?thesis
paulson@33269
   135
    apply (simp add: max_def) 
paulson@33269
   136
    apply (rule Sup_eq_maximum)
paulson@33269
   137
    apply (metis insertCI)
paulson@33269
   138
    apply (metis Sup_upper insertE le_iff_sup real_le_linear real_le_trans sup_absorb1 z)     
paulson@33269
   139
    done
paulson@33269
   140
next
paulson@33269
   141
  case False
paulson@33269
   142
  hence 1:"a < Sup X" by simp
paulson@33269
   143
  have "Sup X \<le> Sup (insert a X)"
paulson@33269
   144
    apply (rule Sup_least)
paulson@33269
   145
    apply (metis empty_psubset_nonempty psubset_eq x)
paulson@33269
   146
    apply (rule Sup_upper_EX) 
paulson@33269
   147
    apply blast
paulson@33269
   148
    apply (metis insert_iff real_le_linear real_le_refl real_le_trans z)
paulson@33269
   149
    done
paulson@33269
   150
  moreover 
paulson@33269
   151
  have "Sup (insert a X) \<le> Sup X"
paulson@33269
   152
    apply (rule Sup_least)
paulson@33269
   153
    apply blast
paulson@33269
   154
    apply (metis False Sup_upper insertE real_le_linear z) 
paulson@33269
   155
    done
paulson@33269
   156
  ultimately have "Sup (insert a X) = Sup X"
paulson@33269
   157
    by (blast intro:  antisym )
paulson@33269
   158
  thus ?thesis
paulson@33269
   159
    by (metis 1 min_max.le_iff_sup real_less_def)
paulson@33269
   160
qed
paulson@33269
   161
paulson@33269
   162
lemma Sup_insert_if: 
paulson@33269
   163
  fixes X :: "real set"
paulson@33269
   164
  assumes z: "!!x. x \<in> X \<Longrightarrow> x \<le> z"
paulson@33269
   165
  shows "Sup (insert a X) = (if X={} then a else max a (Sup X))"
paulson@33269
   166
by auto (metis Sup_insert_nonempty z) 
paulson@33269
   167
paulson@33269
   168
lemma Sup: 
paulson@33269
   169
  fixes S :: "real set"
paulson@33269
   170
  shows "S \<noteq> {} \<Longrightarrow> (\<exists>b. S *<= b) \<Longrightarrow> isLub UNIV S (Sup S)"
paulson@33269
   171
by  (auto simp add: isLub_def setle_def leastP_def isUb_def intro!: setgeI) 
paulson@33269
   172
paulson@33269
   173
lemma Sup_finite_Max: 
paulson@33269
   174
  fixes S :: "real set"
paulson@33269
   175
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   176
  shows "Sup S = Max S"
paulson@33269
   177
using fS Se
paulson@33269
   178
proof-
paulson@33269
   179
  let ?m = "Max S"
paulson@33269
   180
  from Max_ge[OF fS] have Sm: "\<forall> x\<in> S. x \<le> ?m" by metis
paulson@33269
   181
  with Sup[OF Se] have lub: "isLub UNIV S (Sup S)" by (metis setle_def)
paulson@33269
   182
  from Max_in[OF fS Se] lub have mrS: "?m \<le> Sup S"
paulson@33269
   183
    by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def)
paulson@33269
   184
  moreover
paulson@33269
   185
  have "Sup S \<le> ?m" using Sm lub
paulson@33269
   186
    by (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
paulson@33269
   187
  ultimately  show ?thesis by arith
paulson@33269
   188
qed
paulson@33269
   189
paulson@33269
   190
lemma Sup_finite_in:
paulson@33269
   191
  fixes S :: "real set"
paulson@33269
   192
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   193
  shows "Sup S \<in> S"
paulson@33269
   194
  using Sup_finite_Max[OF fS Se] Max_in[OF fS Se] by metis
paulson@33269
   195
paulson@33269
   196
lemma Sup_finite_ge_iff: 
paulson@33269
   197
  fixes S :: "real set"
paulson@33269
   198
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   199
  shows "a \<le> Sup S \<longleftrightarrow> (\<exists> x \<in> S. a \<le> x)"
paulson@33269
   200
by (metis Max_ge Se Sup_finite_Max Sup_finite_in fS linorder_not_le less_le_trans)
paulson@33269
   201
paulson@33269
   202
lemma Sup_finite_le_iff: 
paulson@33269
   203
  fixes S :: "real set"
paulson@33269
   204
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   205
  shows "a \<ge> Sup S \<longleftrightarrow> (\<forall> x \<in> S. a \<ge> x)"
paulson@33269
   206
by (metis Max_ge Se Sup_finite_Max Sup_finite_in fS le_iff_sup real_le_trans) 
paulson@33269
   207
paulson@33269
   208
lemma Sup_finite_gt_iff: 
paulson@33269
   209
  fixes S :: "real set"
paulson@33269
   210
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   211
  shows "a < Sup S \<longleftrightarrow> (\<exists> x \<in> S. a < x)"
paulson@33269
   212
by (metis Se Sup_finite_le_iff fS linorder_not_less)
paulson@33269
   213
paulson@33269
   214
lemma Sup_finite_lt_iff: 
paulson@33269
   215
  fixes S :: "real set"
paulson@33269
   216
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   217
  shows "a > Sup S \<longleftrightarrow> (\<forall> x \<in> S. a > x)"
paulson@33269
   218
by (metis Se Sup_finite_ge_iff fS linorder_not_less)
paulson@33269
   219
paulson@33269
   220
lemma Sup_unique:
paulson@33269
   221
  fixes S :: "real set"
paulson@33269
   222
  shows "S *<= b \<Longrightarrow> (\<forall>b' < b. \<exists>x \<in> S. b' < x) \<Longrightarrow> Sup S = b"
paulson@33269
   223
unfolding setle_def
paulson@33269
   224
apply (rule Sup_eq, auto) 
paulson@33269
   225
apply (metis linorder_not_less) 
paulson@33269
   226
done
paulson@33269
   227
paulson@33269
   228
lemma Sup_abs_le:
paulson@33269
   229
  fixes S :: "real set"
paulson@33269
   230
  shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Sup S\<bar> \<le> a"
paulson@33269
   231
by (auto simp add: abs_le_interval_iff) (metis Sup_upper2) 
paulson@33269
   232
paulson@33269
   233
lemma Sup_bounds:
paulson@33269
   234
  fixes S :: "real set"
paulson@33269
   235
  assumes Se: "S \<noteq> {}" and l: "a <=* S" and u: "S *<= b"
paulson@33269
   236
  shows "a \<le> Sup S \<and> Sup S \<le> b"
paulson@33269
   237
proof-
paulson@33269
   238
  from Sup[OF Se] u have lub: "isLub UNIV S (Sup S)" by blast
paulson@33269
   239
  hence b: "Sup S \<le> b" using u 
paulson@33269
   240
    by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def) 
paulson@33269
   241
  from Se obtain y where y: "y \<in> S" by blast
paulson@33269
   242
  from lub l have "a \<le> Sup S"
paulson@33269
   243
    by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def)
paulson@33269
   244
       (metis le_iff_sup le_sup_iff y)
paulson@33269
   245
  with b show ?thesis by blast
paulson@33269
   246
qed
paulson@33269
   247
paulson@33269
   248
lemma Sup_asclose: 
paulson@33269
   249
  fixes S :: "real set"
paulson@33269
   250
  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Sup S - l\<bar> \<le> e"
paulson@33269
   251
proof-
paulson@33269
   252
  have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e" by arith
paulson@33269
   253
  thus ?thesis using S b Sup_bounds[of S "l - e" "l+e"] unfolding th
paulson@33269
   254
    by  (auto simp add: setge_def setle_def)
paulson@33269
   255
qed
paulson@33269
   256
paulson@33269
   257
paulson@33269
   258
subsection{*Infimum of a set of reals*}
paulson@33269
   259
paulson@33269
   260
lemma Inf_lower [intro]: 
paulson@33269
   261
  fixes z :: real
paulson@33269
   262
  assumes x: "x \<in> X"
paulson@33269
   263
      and z: "!!x. x \<in> X \<Longrightarrow> z \<le> x"
paulson@33269
   264
  shows "Inf X \<le> x"
paulson@33269
   265
proof -
paulson@33269
   266
  have "-x \<le> Sup (uminus ` X)"
paulson@33269
   267
    by (rule Sup_upper [where z = "-z"]) (auto simp add: image_iff x z)
paulson@33269
   268
  thus ?thesis 
paulson@33269
   269
    by (auto simp add: Inf_real_def)
paulson@33269
   270
qed
paulson@33269
   271
paulson@33269
   272
lemma Inf_greatest [intro]: 
paulson@33269
   273
  fixes z :: real
paulson@33269
   274
  assumes x: "X \<noteq> {}"
paulson@33269
   275
      and z: "\<And>x. x \<in> X \<Longrightarrow> z \<le> x"
paulson@33269
   276
  shows "z \<le> Inf X"
paulson@33269
   277
proof -
paulson@33269
   278
  have "Sup (uminus ` X) \<le> -z" using x z by (force intro: Sup_least)
paulson@33269
   279
  hence "z \<le> - Sup (uminus ` X)"
paulson@33269
   280
    by simp
paulson@33269
   281
  thus ?thesis 
paulson@33269
   282
    by (auto simp add: Inf_real_def)
paulson@33269
   283
qed
paulson@33269
   284
paulson@33269
   285
lemma Inf_singleton [simp]: "Inf {x::real} = x"
paulson@33269
   286
  by (simp add: Inf_real_def) 
paulson@33269
   287
 
paulson@33269
   288
lemma Inf_eq_minimum: (*REAL_INF_MIN in HOL4*)
paulson@33269
   289
  fixes z :: real
paulson@33269
   290
  assumes x: "z \<in> X" and z: "!!x. x \<in> X \<Longrightarrow> z \<le> x"
paulson@33269
   291
  shows  "Inf X = z"
paulson@33269
   292
proof -
paulson@33269
   293
  have "Sup (uminus ` X) = -z" using x z
paulson@33269
   294
    by (force intro: Sup_eq_maximum x z)
paulson@33269
   295
  thus ?thesis
paulson@33269
   296
    by (simp add: Inf_real_def) 
paulson@33269
   297
qed
paulson@33269
   298
 
paulson@33269
   299
lemma Inf_lower2:
paulson@33269
   300
  fixes x :: real
paulson@33269
   301
  shows "x \<in> X \<Longrightarrow> x \<le> y \<Longrightarrow> (!!x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> Inf X \<le> y"
paulson@33269
   302
  by (metis Inf_lower real_le_trans)
paulson@33269
   303
paulson@33269
   304
lemma Inf_real_iff:
paulson@33269
   305
  fixes z :: real
paulson@33269
   306
  shows "X \<noteq> {} \<Longrightarrow> (!!x. x \<in> X \<Longrightarrow> z \<le> x) \<Longrightarrow> (\<exists>x\<in>X. x<y) \<longleftrightarrow> Inf X < y"
paulson@33269
   307
  by (metis Inf_greatest Inf_lower less_le_not_le real_le_linear 
paulson@33269
   308
            order_less_le_trans)
paulson@33269
   309
paulson@33269
   310
lemma Inf_eq:
paulson@33269
   311
  fixes a :: real
paulson@33269
   312
  shows "(!!x. x \<in> X \<Longrightarrow> a \<le> x) \<Longrightarrow> (!!y. (!!x. x \<in> X \<Longrightarrow> y \<le> x) \<Longrightarrow> y \<le> a) \<Longrightarrow> Inf X = a"
paulson@33269
   313
  by (metis Inf_greatest Inf_lower add_le_cancel_left diff_add_cancel
paulson@33269
   314
        insert_absorb insert_not_empty real_le_anti_sym)
paulson@33269
   315
paulson@33269
   316
lemma Inf_ge: 
paulson@33269
   317
  fixes S :: "real set"
paulson@33269
   318
  shows "S \<noteq> {} \<Longrightarrow> b <=* S \<Longrightarrow> Inf S \<ge> b"
paulson@33269
   319
by (metis SupInf.Inf_greatest setge_def)
paulson@33269
   320
paulson@33269
   321
lemma Inf_lower_EX: 
paulson@33269
   322
  fixes x :: real
paulson@33269
   323
  shows "x \<in> X \<Longrightarrow> \<exists>z. \<forall>x. x \<in> X \<longrightarrow> z \<le> x \<Longrightarrow> Inf X \<le> x"
paulson@33269
   324
  by blast
paulson@33269
   325
paulson@33269
   326
lemma Inf_insert_nonempty: 
paulson@33269
   327
  fixes x :: real
paulson@33269
   328
  assumes x: "x \<in> X"
paulson@33269
   329
      and z: "!!x. x \<in> X \<Longrightarrow> z \<le> x"
paulson@33269
   330
  shows "Inf (insert a X) = min a (Inf X)"
paulson@33269
   331
proof (cases "a \<le> Inf X")
paulson@33269
   332
  case True
paulson@33269
   333
  thus ?thesis
paulson@33269
   334
    by (simp add: min_def)
paulson@33269
   335
       (blast intro: Inf_eq_minimum Inf_lower real_le_refl real_le_trans z) 
paulson@33269
   336
next
paulson@33269
   337
  case False
paulson@33269
   338
  hence 1:"Inf X < a" by simp
paulson@33269
   339
  have "Inf (insert a X) \<le> Inf X"
paulson@33269
   340
    apply (rule Inf_greatest)
paulson@33269
   341
    apply (metis empty_psubset_nonempty psubset_eq x)
paulson@33269
   342
    apply (rule Inf_lower_EX) 
paulson@33269
   343
    apply (blast intro: elim:) 
paulson@33269
   344
    apply (metis insert_iff real_le_linear real_le_refl real_le_trans z)
paulson@33269
   345
    done
paulson@33269
   346
  moreover 
paulson@33269
   347
  have "Inf X \<le> Inf (insert a X)"
paulson@33269
   348
    apply (rule Inf_greatest)
paulson@33269
   349
    apply blast
paulson@33269
   350
    apply (metis False Inf_lower insertE real_le_linear z) 
paulson@33269
   351
    done
paulson@33269
   352
  ultimately have "Inf (insert a X) = Inf X"
paulson@33269
   353
    by (blast intro:  antisym )
paulson@33269
   354
  thus ?thesis
paulson@33269
   355
    by (metis False min_max.inf_absorb2 real_le_linear)
paulson@33269
   356
qed
paulson@33269
   357
paulson@33269
   358
lemma Inf_insert_if: 
paulson@33269
   359
  fixes X :: "real set"
paulson@33269
   360
  assumes z:  "!!x. x \<in> X \<Longrightarrow> z \<le> x"
paulson@33269
   361
  shows "Inf (insert a X) = (if X={} then a else min a (Inf X))"
paulson@33269
   362
by auto (metis Inf_insert_nonempty z) 
paulson@33269
   363
paulson@33269
   364
text{*We could prove the analogous result for the supremum, and also generalise it to the union operator.*}
paulson@33269
   365
lemma Inf_binary:
paulson@33269
   366
  "Inf{a, b::real} = min a b"
paulson@33269
   367
  by (subst Inf_insert_nonempty, auto)
paulson@33269
   368
paulson@33269
   369
lemma Inf_greater:
paulson@33269
   370
  fixes z :: real
paulson@33269
   371
  shows "X \<noteq> {} \<Longrightarrow>  Inf X < z \<Longrightarrow> \<exists>x \<in> X. x < z"
paulson@33269
   372
  by (metis Inf_real_iff mem_def not_leE)
paulson@33269
   373
paulson@33269
   374
lemma Inf_close:
paulson@33269
   375
  fixes e :: real
paulson@33269
   376
  shows "X \<noteq> {} \<Longrightarrow> 0 < e \<Longrightarrow> \<exists>x \<in> X. x < Inf X + e"
paulson@33269
   377
  by (metis add_strict_increasing comm_monoid_add.mult_commute Inf_greater linorder_not_le pos_add_strict)
paulson@33269
   378
paulson@33269
   379
lemma Inf_finite_Min:
paulson@33269
   380
  fixes S :: "real set"
paulson@33269
   381
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> Inf S = Min S"
paulson@33269
   382
by (simp add: Inf_real_def Sup_finite_Max image_image) 
paulson@33269
   383
paulson@33269
   384
lemma Inf_finite_in: 
paulson@33269
   385
  fixes S :: "real set"
paulson@33269
   386
  assumes fS: "finite S" and Se: "S \<noteq> {}"
paulson@33269
   387
  shows "Inf S \<in> S"
paulson@33269
   388
  using Inf_finite_Min[OF fS Se] Min_in[OF fS Se] by metis
paulson@33269
   389
paulson@33269
   390
lemma Inf_finite_ge_iff: 
paulson@33269
   391
  fixes S :: "real set"
paulson@33269
   392
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<le> Inf S \<longleftrightarrow> (\<forall> x \<in> S. a \<le> x)"
paulson@33269
   393
by (metis Inf_finite_Min Inf_finite_in Min_le real_le_trans)
paulson@33269
   394
paulson@33269
   395
lemma Inf_finite_le_iff:
paulson@33269
   396
  fixes S :: "real set"
paulson@33269
   397
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a \<ge> Inf S \<longleftrightarrow> (\<exists> x \<in> S. a \<ge> x)"
paulson@33269
   398
by (metis Inf_finite_Min Inf_finite_ge_iff Inf_finite_in Min_le
paulson@33269
   399
          real_le_anti_sym real_le_linear)
paulson@33269
   400
paulson@33269
   401
lemma Inf_finite_gt_iff: 
paulson@33269
   402
  fixes S :: "real set"
paulson@33269
   403
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a < Inf S \<longleftrightarrow> (\<forall> x \<in> S. a < x)"
paulson@33269
   404
by (metis Inf_finite_le_iff linorder_not_less)
paulson@33269
   405
paulson@33269
   406
lemma Inf_finite_lt_iff: 
paulson@33269
   407
  fixes S :: "real set"
paulson@33269
   408
  shows "finite S \<Longrightarrow> S \<noteq> {} \<Longrightarrow> a > Inf S \<longleftrightarrow> (\<exists> x \<in> S. a > x)"
paulson@33269
   409
by (metis Inf_finite_ge_iff linorder_not_less)
paulson@33269
   410
paulson@33269
   411
lemma Inf_unique:
paulson@33269
   412
  fixes S :: "real set"
paulson@33269
   413
  shows "b <=* S \<Longrightarrow> (\<forall>b' > b. \<exists>x \<in> S. b' > x) \<Longrightarrow> Inf S = b"
paulson@33269
   414
unfolding setge_def
paulson@33269
   415
apply (rule Inf_eq, auto) 
paulson@33269
   416
apply (metis less_le_not_le linorder_not_less) 
paulson@33269
   417
done
paulson@33269
   418
paulson@33269
   419
lemma Inf_abs_ge:
paulson@33269
   420
  fixes S :: "real set"
paulson@33269
   421
  shows "S \<noteq> {} \<Longrightarrow> (\<forall>x\<in>S. \<bar>x\<bar> \<le> a) \<Longrightarrow> \<bar>Inf S\<bar> \<le> a"
paulson@33269
   422
by (simp add: Inf_real_def) (rule Sup_abs_le, auto) 
paulson@33269
   423
paulson@33269
   424
lemma Inf_asclose:
paulson@33269
   425
  fixes S :: "real set"
paulson@33269
   426
  assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>Inf S - l\<bar> \<le> e"
paulson@33269
   427
proof -
paulson@33269
   428
  have "\<bar>- Sup (uminus ` S) - l\<bar> =  \<bar>Sup (uminus ` S) - (-l)\<bar>"
paulson@33269
   429
    by auto
paulson@33269
   430
  also have "... \<le> e" 
paulson@33269
   431
    apply (rule Sup_asclose) 
paulson@33269
   432
    apply (auto simp add: S)
paulson@33269
   433
    apply (metis abs_minus_add_cancel b comm_monoid_add.mult_commute real_diff_def) 
paulson@33269
   434
    done
paulson@33269
   435
  finally have "\<bar>- Sup (uminus ` S) - l\<bar> \<le> e" .
paulson@33269
   436
  thus ?thesis
paulson@33269
   437
    by (simp add: Inf_real_def)
paulson@33269
   438
qed
paulson@33269
   439
paulson@33269
   440
subsection{*Relate max and min to sup and inf.*}
paulson@33269
   441
paulson@33269
   442
lemma real_max_Sup:
paulson@33269
   443
  fixes x :: real
paulson@33269
   444
  shows "max x y = Sup {x,y}"
paulson@33269
   445
proof-
paulson@33269
   446
  have f: "finite {x, y}" "{x,y} \<noteq> {}"  by simp_all
paulson@33269
   447
  from Sup_finite_le_iff[OF f, of "max x y"] have "Sup {x,y} \<le> max x y" by simp
paulson@33269
   448
  moreover
paulson@33269
   449
  have "max x y \<le> Sup {x,y}" using Sup_finite_ge_iff[OF f, of "max x y"]
paulson@33269
   450
    by (simp add: linorder_linear)
paulson@33269
   451
  ultimately show ?thesis by arith
paulson@33269
   452
qed
paulson@33269
   453
paulson@33269
   454
lemma real_min_Inf: 
paulson@33269
   455
  fixes x :: real
paulson@33269
   456
  shows "min x y = Inf {x,y}"
paulson@33269
   457
proof-
paulson@33269
   458
  have f: "finite {x, y}" "{x,y} \<noteq> {}"  by simp_all
paulson@33269
   459
  from Inf_finite_le_iff[OF f, of "min x y"] have "Inf {x,y} \<le> min x y"
paulson@33269
   460
    by (simp add: linorder_linear)
paulson@33269
   461
  moreover
paulson@33269
   462
  have "min x y \<le> Inf {x,y}" using Inf_finite_ge_iff[OF f, of "min x y"]
paulson@33269
   463
    by simp
paulson@33269
   464
  ultimately show ?thesis by arith
paulson@33269
   465
qed
paulson@33269
   466
paulson@33269
   467
end