src/HOL/Library/Liminf_Limsup.thy
author wenzelm
Mon Dec 28 01:28:28 2015 +0100 (2015-12-28)
changeset 61945 1135b8de26c3
parent 61880 ff4d33058566
child 61969 e01015e49041
permissions -rw-r--r--
more symbols;
hoelzl@51340
     1
(*  Title:      HOL/Library/Liminf_Limsup.thy
hoelzl@51340
     2
    Author:     Johannes Hölzl, TU München
hoelzl@51340
     3
*)
hoelzl@51340
     4
wenzelm@60500
     5
section \<open>Liminf and Limsup on complete lattices\<close>
hoelzl@51340
     6
hoelzl@51340
     7
theory Liminf_Limsup
wenzelm@51542
     8
imports Complex_Main
hoelzl@51340
     9
begin
hoelzl@51340
    10
hoelzl@51340
    11
lemma le_Sup_iff_less:
hoelzl@53216
    12
  fixes x :: "'a :: {complete_linorder, dense_linorder}"
hoelzl@51340
    13
  shows "x \<le> (SUP i:A. f i) \<longleftrightarrow> (\<forall>y<x. \<exists>i\<in>A. y \<le> f i)" (is "?lhs = ?rhs")
hoelzl@51340
    14
  unfolding le_SUP_iff
hoelzl@51340
    15
  by (blast intro: less_imp_le less_trans less_le_trans dest: dense)
hoelzl@51340
    16
hoelzl@51340
    17
lemma Inf_le_iff_less:
hoelzl@53216
    18
  fixes x :: "'a :: {complete_linorder, dense_linorder}"
hoelzl@51340
    19
  shows "(INF i:A. f i) \<le> x \<longleftrightarrow> (\<forall>y>x. \<exists>i\<in>A. f i \<le> y)"
hoelzl@51340
    20
  unfolding INF_le_iff
hoelzl@51340
    21
  by (blast intro: less_imp_le less_trans le_less_trans dest: dense)
hoelzl@51340
    22
haftmann@56212
    23
lemma SUP_pair:
hoelzl@54257
    24
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> _ :: complete_lattice"
hoelzl@54257
    25
  shows "(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))"
hoelzl@51340
    26
  by (rule antisym) (auto intro!: SUP_least SUP_upper2)
hoelzl@51340
    27
haftmann@56212
    28
lemma INF_pair:
hoelzl@54257
    29
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> _ :: complete_lattice"
hoelzl@54257
    30
  shows "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))"
hoelzl@51340
    31
  by (rule antisym) (auto intro!: INF_greatest INF_lower2)
hoelzl@51340
    32
wenzelm@61585
    33
subsubsection \<open>\<open>Liminf\<close> and \<open>Limsup\<close>\<close>
hoelzl@51340
    34
hoelzl@54261
    35
definition Liminf :: "'a filter \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b :: complete_lattice" where
hoelzl@51340
    36
  "Liminf F f = (SUP P:{P. eventually P F}. INF x:{x. P x}. f x)"
hoelzl@51340
    37
hoelzl@54261
    38
definition Limsup :: "'a filter \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b :: complete_lattice" where
hoelzl@51340
    39
  "Limsup F f = (INF P:{P. eventually P F}. SUP x:{x. P x}. f x)"
hoelzl@51340
    40
hoelzl@51340
    41
abbreviation "liminf \<equiv> Liminf sequentially"
hoelzl@51340
    42
hoelzl@51340
    43
abbreviation "limsup \<equiv> Limsup sequentially"
hoelzl@51340
    44
hoelzl@51340
    45
lemma Liminf_eqI:
wenzelm@61730
    46
  "(\<And>P. eventually P F \<Longrightarrow> INFIMUM (Collect P) f \<le> x) \<Longrightarrow>
haftmann@56218
    47
    (\<And>y. (\<And>P. eventually P F \<Longrightarrow> INFIMUM (Collect P) f \<le> y) \<Longrightarrow> x \<le> y) \<Longrightarrow> Liminf F f = x"
hoelzl@51340
    48
  unfolding Liminf_def by (auto intro!: SUP_eqI)
hoelzl@51340
    49
hoelzl@51340
    50
lemma Limsup_eqI:
wenzelm@61730
    51
  "(\<And>P. eventually P F \<Longrightarrow> x \<le> SUPREMUM (Collect P) f) \<Longrightarrow>
haftmann@56218
    52
    (\<And>y. (\<And>P. eventually P F \<Longrightarrow> y \<le> SUPREMUM (Collect P) f) \<Longrightarrow> y \<le> x) \<Longrightarrow> Limsup F f = x"
hoelzl@51340
    53
  unfolding Limsup_def by (auto intro!: INF_eqI)
hoelzl@51340
    54
haftmann@56212
    55
lemma liminf_SUP_INF: "liminf f = (SUP n. INF m:{n..}. f m)"
hoelzl@51340
    56
  unfolding Liminf_def eventually_sequentially
haftmann@56212
    57
  by (rule SUP_eq) (auto simp: atLeast_def intro!: INF_mono)
hoelzl@51340
    58
haftmann@56212
    59
lemma limsup_INF_SUP: "limsup f = (INF n. SUP m:{n..}. f m)"
hoelzl@51340
    60
  unfolding Limsup_def eventually_sequentially
haftmann@56212
    61
  by (rule INF_eq) (auto simp: atLeast_def intro!: SUP_mono)
hoelzl@51340
    62
wenzelm@61730
    63
lemma Limsup_const:
hoelzl@51340
    64
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@54261
    65
  shows "Limsup F (\<lambda>x. c) = c"
hoelzl@51340
    66
proof -
hoelzl@51340
    67
  have *: "\<And>P. Ex P \<longleftrightarrow> P \<noteq> (\<lambda>x. False)" by auto
hoelzl@51340
    68
  have "\<And>P. eventually P F \<Longrightarrow> (SUP x : {x. P x}. c) = c"
hoelzl@51340
    69
    using ntriv by (intro SUP_const) (auto simp: eventually_False *)
hoelzl@51340
    70
  then show ?thesis
hoelzl@51340
    71
    unfolding Limsup_def using eventually_True
hoelzl@51340
    72
    by (subst INF_cong[where D="\<lambda>x. c"])
hoelzl@51340
    73
       (auto intro!: INF_const simp del: eventually_True)
hoelzl@51340
    74
qed
hoelzl@51340
    75
hoelzl@51340
    76
lemma Liminf_const:
hoelzl@51340
    77
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@54261
    78
  shows "Liminf F (\<lambda>x. c) = c"
hoelzl@51340
    79
proof -
hoelzl@51340
    80
  have *: "\<And>P. Ex P \<longleftrightarrow> P \<noteq> (\<lambda>x. False)" by auto
hoelzl@51340
    81
  have "\<And>P. eventually P F \<Longrightarrow> (INF x : {x. P x}. c) = c"
hoelzl@51340
    82
    using ntriv by (intro INF_const) (auto simp: eventually_False *)
hoelzl@51340
    83
  then show ?thesis
hoelzl@51340
    84
    unfolding Liminf_def using eventually_True
hoelzl@51340
    85
    by (subst SUP_cong[where D="\<lambda>x. c"])
hoelzl@51340
    86
       (auto intro!: SUP_const simp del: eventually_True)
hoelzl@51340
    87
qed
hoelzl@51340
    88
hoelzl@51340
    89
lemma Liminf_mono:
hoelzl@51340
    90
  assumes ev: "eventually (\<lambda>x. f x \<le> g x) F"
hoelzl@51340
    91
  shows "Liminf F f \<le> Liminf F g"
hoelzl@51340
    92
  unfolding Liminf_def
hoelzl@51340
    93
proof (safe intro!: SUP_mono)
hoelzl@51340
    94
  fix P assume "eventually P F"
hoelzl@51340
    95
  with ev have "eventually (\<lambda>x. f x \<le> g x \<and> P x) F" (is "eventually ?Q F") by (rule eventually_conj)
haftmann@56218
    96
  then show "\<exists>Q\<in>{P. eventually P F}. INFIMUM (Collect P) f \<le> INFIMUM (Collect Q) g"
hoelzl@51340
    97
    by (intro bexI[of _ ?Q]) (auto intro!: INF_mono)
hoelzl@51340
    98
qed
hoelzl@51340
    99
hoelzl@51340
   100
lemma Liminf_eq:
hoelzl@51340
   101
  assumes "eventually (\<lambda>x. f x = g x) F"
hoelzl@51340
   102
  shows "Liminf F f = Liminf F g"
lp15@61810
   103
  by (intro antisym Liminf_mono eventually_mono[OF assms]) auto
hoelzl@51340
   104
hoelzl@51340
   105
lemma Limsup_mono:
hoelzl@51340
   106
  assumes ev: "eventually (\<lambda>x. f x \<le> g x) F"
hoelzl@51340
   107
  shows "Limsup F f \<le> Limsup F g"
hoelzl@51340
   108
  unfolding Limsup_def
hoelzl@51340
   109
proof (safe intro!: INF_mono)
hoelzl@51340
   110
  fix P assume "eventually P F"
hoelzl@51340
   111
  with ev have "eventually (\<lambda>x. f x \<le> g x \<and> P x) F" (is "eventually ?Q F") by (rule eventually_conj)
haftmann@56218
   112
  then show "\<exists>Q\<in>{P. eventually P F}. SUPREMUM (Collect Q) f \<le> SUPREMUM (Collect P) g"
hoelzl@51340
   113
    by (intro bexI[of _ ?Q]) (auto intro!: SUP_mono)
hoelzl@51340
   114
qed
hoelzl@51340
   115
hoelzl@51340
   116
lemma Limsup_eq:
hoelzl@51340
   117
  assumes "eventually (\<lambda>x. f x = g x) net"
hoelzl@51340
   118
  shows "Limsup net f = Limsup net g"
lp15@61810
   119
  by (intro antisym Limsup_mono eventually_mono[OF assms]) auto
hoelzl@51340
   120
hoelzl@51340
   121
lemma Liminf_le_Limsup:
hoelzl@51340
   122
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   123
  shows "Liminf F f \<le> Limsup F f"
hoelzl@51340
   124
  unfolding Limsup_def Liminf_def
hoelzl@54261
   125
  apply (rule SUP_least)
hoelzl@54261
   126
  apply (rule INF_greatest)
hoelzl@51340
   127
proof safe
hoelzl@51340
   128
  fix P Q assume "eventually P F" "eventually Q F"
hoelzl@51340
   129
  then have "eventually (\<lambda>x. P x \<and> Q x) F" (is "eventually ?C F") by (rule eventually_conj)
hoelzl@51340
   130
  then have not_False: "(\<lambda>x. P x \<and> Q x) \<noteq> (\<lambda>x. False)"
hoelzl@51340
   131
    using ntriv by (auto simp add: eventually_False)
haftmann@56218
   132
  have "INFIMUM (Collect P) f \<le> INFIMUM (Collect ?C) f"
hoelzl@51340
   133
    by (rule INF_mono) auto
haftmann@56218
   134
  also have "\<dots> \<le> SUPREMUM (Collect ?C) f"
hoelzl@51340
   135
    using not_False by (intro INF_le_SUP) auto
haftmann@56218
   136
  also have "\<dots> \<le> SUPREMUM (Collect Q) f"
hoelzl@51340
   137
    by (rule SUP_mono) auto
haftmann@56218
   138
  finally show "INFIMUM (Collect P) f \<le> SUPREMUM (Collect Q) f" .
hoelzl@51340
   139
qed
hoelzl@51340
   140
hoelzl@51340
   141
lemma Liminf_bounded:
hoelzl@51340
   142
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   143
  assumes le: "eventually (\<lambda>n. C \<le> X n) F"
hoelzl@51340
   144
  shows "C \<le> Liminf F X"
hoelzl@51340
   145
  using Liminf_mono[OF le] Liminf_const[OF ntriv, of C] by simp
hoelzl@51340
   146
hoelzl@51340
   147
lemma Limsup_bounded:
hoelzl@51340
   148
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   149
  assumes le: "eventually (\<lambda>n. X n \<le> C) F"
hoelzl@51340
   150
  shows "Limsup F X \<le> C"
hoelzl@51340
   151
  using Limsup_mono[OF le] Limsup_const[OF ntriv, of C] by simp
hoelzl@51340
   152
hoelzl@61245
   153
lemma le_Limsup:
hoelzl@61245
   154
  assumes F: "F \<noteq> bot" and x: "\<forall>\<^sub>F x in F. l \<le> f x"
hoelzl@61245
   155
  shows "l \<le> Limsup F f"
hoelzl@61245
   156
proof -
hoelzl@61245
   157
  have "l = Limsup F (\<lambda>x. l)"
hoelzl@61245
   158
    using F by (simp add: Limsup_const)
hoelzl@61245
   159
  also have "\<dots> \<le> Limsup F f"
wenzelm@61730
   160
    by (intro Limsup_mono x)
hoelzl@61245
   161
  finally show ?thesis .
hoelzl@61245
   162
qed
hoelzl@61245
   163
hoelzl@51340
   164
lemma le_Liminf_iff:
hoelzl@51340
   165
  fixes X :: "_ \<Rightarrow> _ :: complete_linorder"
hoelzl@51340
   166
  shows "C \<le> Liminf F X \<longleftrightarrow> (\<forall>y<C. eventually (\<lambda>x. y < X x) F)"
hoelzl@51340
   167
proof -
wenzelm@61730
   168
  have "eventually (\<lambda>x. y < X x) F"
wenzelm@61730
   169
    if "eventually P F" "y < INFIMUM (Collect P) X" for y P
lp15@61810
   170
    using that by (auto elim!: eventually_mono dest: less_INF_D)
hoelzl@51340
   171
  moreover
wenzelm@61730
   172
  have "\<exists>P. eventually P F \<and> y < INFIMUM (Collect P) X"
wenzelm@61730
   173
    if "y < C" and y: "\<forall>y<C. eventually (\<lambda>x. y < X x) F" for y P
wenzelm@61730
   174
  proof (cases "\<exists>z. y < z \<and> z < C")
wenzelm@61730
   175
    case True
wenzelm@61730
   176
    then obtain z where z: "y < z \<and> z < C" ..
wenzelm@61730
   177
    moreover from z have "z \<le> INFIMUM {x. z < X x} X"
wenzelm@61730
   178
      by (auto intro!: INF_greatest)
wenzelm@61730
   179
    ultimately show ?thesis
wenzelm@61730
   180
      using y by (intro exI[of _ "\<lambda>x. z < X x"]) auto
wenzelm@61730
   181
  next
wenzelm@61730
   182
    case False
wenzelm@61730
   183
    then have "C \<le> INFIMUM {x. y < X x} X"
wenzelm@61730
   184
      by (intro INF_greatest) auto
wenzelm@61730
   185
    with \<open>y < C\<close> show ?thesis
wenzelm@61730
   186
      using y by (intro exI[of _ "\<lambda>x. y < X x"]) auto
wenzelm@61730
   187
  qed
hoelzl@51340
   188
  ultimately show ?thesis
hoelzl@51340
   189
    unfolding Liminf_def le_SUP_iff by auto
hoelzl@51340
   190
qed
hoelzl@51340
   191
hoelzl@51340
   192
lemma lim_imp_Liminf:
wenzelm@61730
   193
  fixes f :: "'a \<Rightarrow> _ :: {complete_linorder,linorder_topology}"
hoelzl@51340
   194
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   195
  assumes lim: "(f ---> f0) F"
hoelzl@51340
   196
  shows "Liminf F f = f0"
hoelzl@51340
   197
proof (intro Liminf_eqI)
hoelzl@51340
   198
  fix P assume P: "eventually P F"
haftmann@56218
   199
  then have "eventually (\<lambda>x. INFIMUM (Collect P) f \<le> f x) F"
hoelzl@51340
   200
    by eventually_elim (auto intro!: INF_lower)
haftmann@56218
   201
  then show "INFIMUM (Collect P) f \<le> f0"
hoelzl@51340
   202
    by (rule tendsto_le[OF ntriv lim tendsto_const])
hoelzl@51340
   203
next
haftmann@56218
   204
  fix y assume upper: "\<And>P. eventually P F \<Longrightarrow> INFIMUM (Collect P) f \<le> y"
hoelzl@51340
   205
  show "f0 \<le> y"
hoelzl@51340
   206
  proof cases
hoelzl@51340
   207
    assume "\<exists>z. y < z \<and> z < f0"
wenzelm@53374
   208
    then obtain z where "y < z \<and> z < f0" ..
haftmann@56218
   209
    moreover have "z \<le> INFIMUM {x. z < f x} f"
hoelzl@51340
   210
      by (rule INF_greatest) simp
hoelzl@51340
   211
    ultimately show ?thesis
hoelzl@51340
   212
      using lim[THEN topological_tendstoD, THEN upper, of "{z <..}"] by auto
hoelzl@51340
   213
  next
hoelzl@51340
   214
    assume discrete: "\<not> (\<exists>z. y < z \<and> z < f0)"
hoelzl@51340
   215
    show ?thesis
hoelzl@51340
   216
    proof (rule classical)
hoelzl@51340
   217
      assume "\<not> f0 \<le> y"
hoelzl@51340
   218
      then have "eventually (\<lambda>x. y < f x) F"
hoelzl@51340
   219
        using lim[THEN topological_tendstoD, of "{y <..}"] by auto
hoelzl@51340
   220
      then have "eventually (\<lambda>x. f0 \<le> f x) F"
lp15@61810
   221
        using discrete by (auto elim!: eventually_mono)
haftmann@56218
   222
      then have "INFIMUM {x. f0 \<le> f x} f \<le> y"
hoelzl@51340
   223
        by (rule upper)
haftmann@56218
   224
      moreover have "f0 \<le> INFIMUM {x. f0 \<le> f x} f"
hoelzl@51340
   225
        by (intro INF_greatest) simp
hoelzl@51340
   226
      ultimately show "f0 \<le> y" by simp
hoelzl@51340
   227
    qed
hoelzl@51340
   228
  qed
hoelzl@51340
   229
qed
hoelzl@51340
   230
hoelzl@51340
   231
lemma lim_imp_Limsup:
wenzelm@61730
   232
  fixes f :: "'a \<Rightarrow> _ :: {complete_linorder,linorder_topology}"
hoelzl@51340
   233
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   234
  assumes lim: "(f ---> f0) F"
hoelzl@51340
   235
  shows "Limsup F f = f0"
hoelzl@51340
   236
proof (intro Limsup_eqI)
hoelzl@51340
   237
  fix P assume P: "eventually P F"
haftmann@56218
   238
  then have "eventually (\<lambda>x. f x \<le> SUPREMUM (Collect P) f) F"
hoelzl@51340
   239
    by eventually_elim (auto intro!: SUP_upper)
haftmann@56218
   240
  then show "f0 \<le> SUPREMUM (Collect P) f"
hoelzl@51340
   241
    by (rule tendsto_le[OF ntriv tendsto_const lim])
hoelzl@51340
   242
next
haftmann@56218
   243
  fix y assume lower: "\<And>P. eventually P F \<Longrightarrow> y \<le> SUPREMUM (Collect P) f"
hoelzl@51340
   244
  show "y \<le> f0"
wenzelm@53381
   245
  proof (cases "\<exists>z. f0 < z \<and> z < y")
wenzelm@53381
   246
    case True
wenzelm@53381
   247
    then obtain z where "f0 < z \<and> z < y" ..
haftmann@56218
   248
    moreover have "SUPREMUM {x. f x < z} f \<le> z"
hoelzl@51340
   249
      by (rule SUP_least) simp
hoelzl@51340
   250
    ultimately show ?thesis
hoelzl@51340
   251
      using lim[THEN topological_tendstoD, THEN lower, of "{..< z}"] by auto
hoelzl@51340
   252
  next
wenzelm@53381
   253
    case False
hoelzl@51340
   254
    show ?thesis
hoelzl@51340
   255
    proof (rule classical)
hoelzl@51340
   256
      assume "\<not> y \<le> f0"
hoelzl@51340
   257
      then have "eventually (\<lambda>x. f x < y) F"
hoelzl@51340
   258
        using lim[THEN topological_tendstoD, of "{..< y}"] by auto
hoelzl@51340
   259
      then have "eventually (\<lambda>x. f x \<le> f0) F"
lp15@61810
   260
        using False by (auto elim!: eventually_mono simp: not_less)
haftmann@56218
   261
      then have "y \<le> SUPREMUM {x. f x \<le> f0} f"
hoelzl@51340
   262
        by (rule lower)
haftmann@56218
   263
      moreover have "SUPREMUM {x. f x \<le> f0} f \<le> f0"
hoelzl@51340
   264
        by (intro SUP_least) simp
hoelzl@51340
   265
      ultimately show "y \<le> f0" by simp
hoelzl@51340
   266
    qed
hoelzl@51340
   267
  qed
hoelzl@51340
   268
qed
hoelzl@51340
   269
hoelzl@51340
   270
lemma Liminf_eq_Limsup:
wenzelm@61730
   271
  fixes f0 :: "'a :: {complete_linorder,linorder_topology}"
hoelzl@51340
   272
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   273
    and lim: "Liminf F f = f0" "Limsup F f = f0"
hoelzl@51340
   274
  shows "(f ---> f0) F"
hoelzl@51340
   275
proof (rule order_tendstoI)
hoelzl@51340
   276
  fix a assume "f0 < a"
hoelzl@51340
   277
  with assms have "Limsup F f < a" by simp
haftmann@56218
   278
  then obtain P where "eventually P F" "SUPREMUM (Collect P) f < a"
hoelzl@51340
   279
    unfolding Limsup_def INF_less_iff by auto
hoelzl@51340
   280
  then show "eventually (\<lambda>x. f x < a) F"
lp15@61810
   281
    by (auto elim!: eventually_mono dest: SUP_lessD)
hoelzl@51340
   282
next
hoelzl@51340
   283
  fix a assume "a < f0"
hoelzl@51340
   284
  with assms have "a < Liminf F f" by simp
haftmann@56218
   285
  then obtain P where "eventually P F" "a < INFIMUM (Collect P) f"
hoelzl@51340
   286
    unfolding Liminf_def less_SUP_iff by auto
hoelzl@51340
   287
  then show "eventually (\<lambda>x. a < f x) F"
lp15@61810
   288
    by (auto elim!: eventually_mono dest: less_INF_D)
hoelzl@51340
   289
qed
hoelzl@51340
   290
hoelzl@51340
   291
lemma tendsto_iff_Liminf_eq_Limsup:
wenzelm@61730
   292
  fixes f0 :: "'a :: {complete_linorder,linorder_topology}"
hoelzl@51340
   293
  shows "\<not> trivial_limit F \<Longrightarrow> (f ---> f0) F \<longleftrightarrow> (Liminf F f = f0 \<and> Limsup F f = f0)"
hoelzl@51340
   294
  by (metis Liminf_eq_Limsup lim_imp_Limsup lim_imp_Liminf)
hoelzl@51340
   295
hoelzl@51340
   296
lemma liminf_subseq_mono:
hoelzl@51340
   297
  fixes X :: "nat \<Rightarrow> 'a :: complete_linorder"
hoelzl@51340
   298
  assumes "subseq r"
hoelzl@51340
   299
  shows "liminf X \<le> liminf (X \<circ> r) "
hoelzl@51340
   300
proof-
hoelzl@51340
   301
  have "\<And>n. (INF m:{n..}. X m) \<le> (INF m:{n..}. (X \<circ> r) m)"
hoelzl@51340
   302
  proof (safe intro!: INF_mono)
hoelzl@51340
   303
    fix n m :: nat assume "n \<le> m" then show "\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m"
wenzelm@60500
   304
      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
hoelzl@51340
   305
  qed
haftmann@56212
   306
  then show ?thesis by (auto intro!: SUP_mono simp: liminf_SUP_INF comp_def)
hoelzl@51340
   307
qed
hoelzl@51340
   308
hoelzl@51340
   309
lemma limsup_subseq_mono:
hoelzl@51340
   310
  fixes X :: "nat \<Rightarrow> 'a :: complete_linorder"
hoelzl@51340
   311
  assumes "subseq r"
hoelzl@51340
   312
  shows "limsup (X \<circ> r) \<le> limsup X"
hoelzl@51340
   313
proof-
wenzelm@61730
   314
  have "(SUP m:{n..}. (X \<circ> r) m) \<le> (SUP m:{n..}. X m)" for n
hoelzl@51340
   315
  proof (safe intro!: SUP_mono)
wenzelm@61730
   316
    fix m :: nat
wenzelm@61730
   317
    assume "n \<le> m"
wenzelm@61730
   318
    then show "\<exists>ma\<in>{n..}. (X \<circ> r) m \<le> X ma"
wenzelm@60500
   319
      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
hoelzl@51340
   320
  qed
wenzelm@61730
   321
  then show ?thesis
wenzelm@61730
   322
    by (auto intro!: INF_mono simp: limsup_INF_SUP comp_def)
hoelzl@51340
   323
qed
hoelzl@51340
   324
wenzelm@61730
   325
lemma continuous_on_imp_continuous_within:
wenzelm@61730
   326
  "continuous_on s f \<Longrightarrow> t \<subseteq> s \<Longrightarrow> x \<in> s \<Longrightarrow> continuous (at x within t) f"
wenzelm@61730
   327
  unfolding continuous_on_eq_continuous_within
wenzelm@61730
   328
  by (auto simp: continuous_within intro: tendsto_within_subset)
hoelzl@61245
   329
hoelzl@61245
   330
lemma Liminf_compose_continuous_antimono:
wenzelm@61730
   331
  fixes f :: "'a::{complete_linorder,linorder_topology} \<Rightarrow> 'b::{complete_linorder,linorder_topology}"
wenzelm@61730
   332
  assumes c: "continuous_on UNIV f"
wenzelm@61730
   333
    and am: "antimono f"
wenzelm@61730
   334
    and F: "F \<noteq> bot"
hoelzl@61245
   335
  shows "Liminf F (\<lambda>n. f (g n)) = f (Limsup F g)"
hoelzl@61245
   336
proof -
wenzelm@61730
   337
  have *: "\<exists>x. P x" if "eventually P F" for P
wenzelm@61730
   338
  proof (rule ccontr)
wenzelm@61730
   339
    assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
wenzelm@61730
   340
      by auto
wenzelm@61730
   341
    with \<open>eventually P F\<close> F show False
wenzelm@61730
   342
      by auto
wenzelm@61730
   343
  qed
hoelzl@61245
   344
  have "f (Limsup F g) = (SUP P : {P. eventually P F}. f (Sup (g ` Collect P)))"
hoelzl@61245
   345
    unfolding Limsup_def INF_def
hoelzl@61245
   346
    by (subst continuous_at_Inf_antimono[OF am continuous_on_imp_continuous_within[OF c]])
hoelzl@61245
   347
       (auto intro: eventually_True)
hoelzl@61245
   348
  also have "\<dots> = (SUP P : {P. eventually P F}. INFIMUM (g ` Collect P) f)"
hoelzl@61245
   349
    by (intro SUP_cong refl continuous_at_Sup_antimono[OF am continuous_on_imp_continuous_within[OF c]])
hoelzl@61245
   350
       (auto dest!: eventually_happens simp: F)
hoelzl@61245
   351
  finally show ?thesis
hoelzl@61245
   352
    by (auto simp: Liminf_def)
hoelzl@61245
   353
qed
hoelzl@61880
   354
subsection \<open>More Limits\<close>
hoelzl@61880
   355
hoelzl@61880
   356
lemma convergent_limsup_cl:
hoelzl@61880
   357
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
hoelzl@61880
   358
  shows "convergent X \<Longrightarrow> limsup X = lim X"
hoelzl@61880
   359
  by (auto simp: convergent_def limI lim_imp_Limsup)
hoelzl@61880
   360
hoelzl@61880
   361
lemma convergent_liminf_cl:
hoelzl@61880
   362
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
hoelzl@61880
   363
  shows "convergent X \<Longrightarrow> liminf X = lim X"
hoelzl@61880
   364
  by (auto simp: convergent_def limI lim_imp_Liminf)
hoelzl@61880
   365
hoelzl@61880
   366
lemma lim_increasing_cl:
hoelzl@61880
   367
  assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<ge> f m"
hoelzl@61880
   368
  obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
hoelzl@61880
   369
proof
hoelzl@61880
   370
  show "f ----> (SUP n. f n)"
hoelzl@61880
   371
    using assms
hoelzl@61880
   372
    by (intro increasing_tendsto)
hoelzl@61880
   373
       (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans)
hoelzl@61880
   374
qed
hoelzl@61880
   375
hoelzl@61880
   376
lemma lim_decreasing_cl:
hoelzl@61880
   377
  assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<le> f m"
hoelzl@61880
   378
  obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
hoelzl@61880
   379
proof
hoelzl@61880
   380
  show "f ----> (INF n. f n)"
hoelzl@61880
   381
    using assms
hoelzl@61880
   382
    by (intro decreasing_tendsto)
hoelzl@61880
   383
       (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans)
hoelzl@61880
   384
qed
hoelzl@61880
   385
hoelzl@61880
   386
lemma compact_complete_linorder:
hoelzl@61880
   387
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
hoelzl@61880
   388
  shows "\<exists>l r. subseq r \<and> (X \<circ> r) ----> l"
hoelzl@61880
   389
proof -
hoelzl@61880
   390
  obtain r where "subseq r" and mono: "monoseq (X \<circ> r)"
hoelzl@61880
   391
    using seq_monosub[of X]
hoelzl@61880
   392
    unfolding comp_def
hoelzl@61880
   393
    by auto
hoelzl@61880
   394
  then have "(\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) m \<le> (X \<circ> r) n) \<or> (\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) n \<le> (X \<circ> r) m)"
hoelzl@61880
   395
    by (auto simp add: monoseq_def)
hoelzl@61880
   396
  then obtain l where "(X \<circ> r) ----> l"
hoelzl@61880
   397
     using lim_increasing_cl[of "X \<circ> r"] lim_decreasing_cl[of "X \<circ> r"]
hoelzl@61880
   398
     by auto
hoelzl@61880
   399
  then show ?thesis
hoelzl@61880
   400
    using \<open>subseq r\<close> by auto
hoelzl@61880
   401
qed
hoelzl@61245
   402
hoelzl@51340
   403
end