src/HOL/Library/Liminf_Limsup.thy
author paulson <lp15@cam.ac.uk>
Mon Feb 22 14:37:56 2016 +0000 (2016-02-22)
changeset 62379 340738057c8c
parent 62343 24106dc44def
child 62624 59ceeb6f3079
permissions -rw-r--r--
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
hoelzl@51340
     1
(*  Title:      HOL/Library/Liminf_Limsup.thy
hoelzl@51340
     2
    Author:     Johannes Hölzl, TU München
eberlm@62049
     3
    Author:     Manuel Eberl, TU München
hoelzl@51340
     4
*)
hoelzl@51340
     5
wenzelm@60500
     6
section \<open>Liminf and Limsup on complete lattices\<close>
hoelzl@51340
     7
hoelzl@51340
     8
theory Liminf_Limsup
wenzelm@51542
     9
imports Complex_Main
hoelzl@51340
    10
begin
hoelzl@51340
    11
hoelzl@51340
    12
lemma le_Sup_iff_less:
hoelzl@53216
    13
  fixes x :: "'a :: {complete_linorder, dense_linorder}"
hoelzl@51340
    14
  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
    15
  unfolding le_SUP_iff
hoelzl@51340
    16
  by (blast intro: less_imp_le less_trans less_le_trans dest: dense)
hoelzl@51340
    17
hoelzl@51340
    18
lemma Inf_le_iff_less:
hoelzl@53216
    19
  fixes x :: "'a :: {complete_linorder, dense_linorder}"
hoelzl@51340
    20
  shows "(INF i:A. f i) \<le> x \<longleftrightarrow> (\<forall>y>x. \<exists>i\<in>A. f i \<le> y)"
hoelzl@51340
    21
  unfolding INF_le_iff
hoelzl@51340
    22
  by (blast intro: less_imp_le less_trans le_less_trans dest: dense)
hoelzl@51340
    23
haftmann@56212
    24
lemma SUP_pair:
hoelzl@54257
    25
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> _ :: complete_lattice"
hoelzl@54257
    26
  shows "(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))"
hoelzl@51340
    27
  by (rule antisym) (auto intro!: SUP_least SUP_upper2)
hoelzl@51340
    28
haftmann@56212
    29
lemma INF_pair:
hoelzl@54257
    30
  fixes f :: "_ \<Rightarrow> _ \<Rightarrow> _ :: complete_lattice"
hoelzl@54257
    31
  shows "(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))"
hoelzl@51340
    32
  by (rule antisym) (auto intro!: INF_greatest INF_lower2)
hoelzl@51340
    33
wenzelm@61585
    34
subsubsection \<open>\<open>Liminf\<close> and \<open>Limsup\<close>\<close>
hoelzl@51340
    35
hoelzl@54261
    36
definition Liminf :: "'a filter \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b :: complete_lattice" where
hoelzl@51340
    37
  "Liminf F f = (SUP P:{P. eventually P F}. INF x:{x. P x}. f x)"
hoelzl@51340
    38
hoelzl@54261
    39
definition Limsup :: "'a filter \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b :: complete_lattice" where
hoelzl@51340
    40
  "Limsup F f = (INF P:{P. eventually P F}. SUP x:{x. P x}. f x)"
hoelzl@51340
    41
hoelzl@51340
    42
abbreviation "liminf \<equiv> Liminf sequentially"
hoelzl@51340
    43
hoelzl@51340
    44
abbreviation "limsup \<equiv> Limsup sequentially"
hoelzl@51340
    45
hoelzl@51340
    46
lemma Liminf_eqI:
wenzelm@61730
    47
  "(\<And>P. eventually P F \<Longrightarrow> INFIMUM (Collect P) f \<le> x) \<Longrightarrow>
haftmann@56218
    48
    (\<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
    49
  unfolding Liminf_def by (auto intro!: SUP_eqI)
hoelzl@51340
    50
hoelzl@51340
    51
lemma Limsup_eqI:
wenzelm@61730
    52
  "(\<And>P. eventually P F \<Longrightarrow> x \<le> SUPREMUM (Collect P) f) \<Longrightarrow>
haftmann@56218
    53
    (\<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
    54
  unfolding Limsup_def by (auto intro!: INF_eqI)
hoelzl@51340
    55
haftmann@56212
    56
lemma liminf_SUP_INF: "liminf f = (SUP n. INF m:{n..}. f m)"
hoelzl@51340
    57
  unfolding Liminf_def eventually_sequentially
haftmann@56212
    58
  by (rule SUP_eq) (auto simp: atLeast_def intro!: INF_mono)
hoelzl@51340
    59
haftmann@56212
    60
lemma limsup_INF_SUP: "limsup f = (INF n. SUP m:{n..}. f m)"
hoelzl@51340
    61
  unfolding Limsup_def eventually_sequentially
haftmann@56212
    62
  by (rule INF_eq) (auto simp: atLeast_def intro!: SUP_mono)
hoelzl@51340
    63
wenzelm@61730
    64
lemma Limsup_const:
hoelzl@51340
    65
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@54261
    66
  shows "Limsup F (\<lambda>x. c) = c"
hoelzl@51340
    67
proof -
hoelzl@51340
    68
  have *: "\<And>P. Ex P \<longleftrightarrow> P \<noteq> (\<lambda>x. False)" by auto
hoelzl@51340
    69
  have "\<And>P. eventually P F \<Longrightarrow> (SUP x : {x. P x}. c) = c"
hoelzl@51340
    70
    using ntriv by (intro SUP_const) (auto simp: eventually_False *)
hoelzl@51340
    71
  then show ?thesis
hoelzl@51340
    72
    unfolding Limsup_def using eventually_True
hoelzl@51340
    73
    by (subst INF_cong[where D="\<lambda>x. c"])
hoelzl@51340
    74
       (auto intro!: INF_const simp del: eventually_True)
hoelzl@51340
    75
qed
hoelzl@51340
    76
hoelzl@51340
    77
lemma Liminf_const:
hoelzl@51340
    78
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@54261
    79
  shows "Liminf F (\<lambda>x. c) = c"
hoelzl@51340
    80
proof -
hoelzl@51340
    81
  have *: "\<And>P. Ex P \<longleftrightarrow> P \<noteq> (\<lambda>x. False)" by auto
hoelzl@51340
    82
  have "\<And>P. eventually P F \<Longrightarrow> (INF x : {x. P x}. c) = c"
hoelzl@51340
    83
    using ntriv by (intro INF_const) (auto simp: eventually_False *)
hoelzl@51340
    84
  then show ?thesis
hoelzl@51340
    85
    unfolding Liminf_def using eventually_True
hoelzl@51340
    86
    by (subst SUP_cong[where D="\<lambda>x. c"])
hoelzl@51340
    87
       (auto intro!: SUP_const simp del: eventually_True)
hoelzl@51340
    88
qed
hoelzl@51340
    89
hoelzl@51340
    90
lemma Liminf_mono:
hoelzl@51340
    91
  assumes ev: "eventually (\<lambda>x. f x \<le> g x) F"
hoelzl@51340
    92
  shows "Liminf F f \<le> Liminf F g"
hoelzl@51340
    93
  unfolding Liminf_def
hoelzl@51340
    94
proof (safe intro!: SUP_mono)
hoelzl@51340
    95
  fix P assume "eventually P F"
hoelzl@51340
    96
  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
    97
  then show "\<exists>Q\<in>{P. eventually P F}. INFIMUM (Collect P) f \<le> INFIMUM (Collect Q) g"
hoelzl@51340
    98
    by (intro bexI[of _ ?Q]) (auto intro!: INF_mono)
hoelzl@51340
    99
qed
hoelzl@51340
   100
hoelzl@51340
   101
lemma Liminf_eq:
hoelzl@51340
   102
  assumes "eventually (\<lambda>x. f x = g x) F"
hoelzl@51340
   103
  shows "Liminf F f = Liminf F g"
lp15@61810
   104
  by (intro antisym Liminf_mono eventually_mono[OF assms]) auto
hoelzl@51340
   105
hoelzl@51340
   106
lemma Limsup_mono:
hoelzl@51340
   107
  assumes ev: "eventually (\<lambda>x. f x \<le> g x) F"
hoelzl@51340
   108
  shows "Limsup F f \<le> Limsup F g"
hoelzl@51340
   109
  unfolding Limsup_def
hoelzl@51340
   110
proof (safe intro!: INF_mono)
hoelzl@51340
   111
  fix P assume "eventually P F"
hoelzl@51340
   112
  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
   113
  then show "\<exists>Q\<in>{P. eventually P F}. SUPREMUM (Collect Q) f \<le> SUPREMUM (Collect P) g"
hoelzl@51340
   114
    by (intro bexI[of _ ?Q]) (auto intro!: SUP_mono)
hoelzl@51340
   115
qed
hoelzl@51340
   116
hoelzl@51340
   117
lemma Limsup_eq:
hoelzl@51340
   118
  assumes "eventually (\<lambda>x. f x = g x) net"
hoelzl@51340
   119
  shows "Limsup net f = Limsup net g"
lp15@61810
   120
  by (intro antisym Limsup_mono eventually_mono[OF assms]) auto
hoelzl@51340
   121
hoelzl@51340
   122
lemma Liminf_le_Limsup:
hoelzl@51340
   123
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   124
  shows "Liminf F f \<le> Limsup F f"
hoelzl@51340
   125
  unfolding Limsup_def Liminf_def
hoelzl@54261
   126
  apply (rule SUP_least)
hoelzl@54261
   127
  apply (rule INF_greatest)
hoelzl@51340
   128
proof safe
hoelzl@51340
   129
  fix P Q assume "eventually P F" "eventually Q F"
hoelzl@51340
   130
  then have "eventually (\<lambda>x. P x \<and> Q x) F" (is "eventually ?C F") by (rule eventually_conj)
hoelzl@51340
   131
  then have not_False: "(\<lambda>x. P x \<and> Q x) \<noteq> (\<lambda>x. False)"
hoelzl@51340
   132
    using ntriv by (auto simp add: eventually_False)
haftmann@56218
   133
  have "INFIMUM (Collect P) f \<le> INFIMUM (Collect ?C) f"
hoelzl@51340
   134
    by (rule INF_mono) auto
haftmann@56218
   135
  also have "\<dots> \<le> SUPREMUM (Collect ?C) f"
hoelzl@51340
   136
    using not_False by (intro INF_le_SUP) auto
haftmann@56218
   137
  also have "\<dots> \<le> SUPREMUM (Collect Q) f"
hoelzl@51340
   138
    by (rule SUP_mono) auto
haftmann@56218
   139
  finally show "INFIMUM (Collect P) f \<le> SUPREMUM (Collect Q) f" .
hoelzl@51340
   140
qed
hoelzl@51340
   141
hoelzl@51340
   142
lemma Liminf_bounded:
hoelzl@51340
   143
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   144
  assumes le: "eventually (\<lambda>n. C \<le> X n) F"
hoelzl@51340
   145
  shows "C \<le> Liminf F X"
hoelzl@51340
   146
  using Liminf_mono[OF le] Liminf_const[OF ntriv, of C] by simp
hoelzl@51340
   147
hoelzl@51340
   148
lemma Limsup_bounded:
hoelzl@51340
   149
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   150
  assumes le: "eventually (\<lambda>n. X n \<le> C) F"
hoelzl@51340
   151
  shows "Limsup F X \<le> C"
hoelzl@51340
   152
  using Limsup_mono[OF le] Limsup_const[OF ntriv, of C] by simp
hoelzl@51340
   153
hoelzl@61245
   154
lemma le_Limsup:
hoelzl@61245
   155
  assumes F: "F \<noteq> bot" and x: "\<forall>\<^sub>F x in F. l \<le> f x"
hoelzl@61245
   156
  shows "l \<le> Limsup F f"
hoelzl@61245
   157
proof -
hoelzl@61245
   158
  have "l = Limsup F (\<lambda>x. l)"
hoelzl@61245
   159
    using F by (simp add: Limsup_const)
hoelzl@61245
   160
  also have "\<dots> \<le> Limsup F f"
wenzelm@61730
   161
    by (intro Limsup_mono x)
hoelzl@61245
   162
  finally show ?thesis .
hoelzl@61245
   163
qed
hoelzl@61245
   164
hoelzl@51340
   165
lemma le_Liminf_iff:
hoelzl@51340
   166
  fixes X :: "_ \<Rightarrow> _ :: complete_linorder"
hoelzl@51340
   167
  shows "C \<le> Liminf F X \<longleftrightarrow> (\<forall>y<C. eventually (\<lambda>x. y < X x) F)"
hoelzl@51340
   168
proof -
wenzelm@61730
   169
  have "eventually (\<lambda>x. y < X x) F"
wenzelm@61730
   170
    if "eventually P F" "y < INFIMUM (Collect P) X" for y P
lp15@61810
   171
    using that by (auto elim!: eventually_mono dest: less_INF_D)
hoelzl@51340
   172
  moreover
wenzelm@61730
   173
  have "\<exists>P. eventually P F \<and> y < INFIMUM (Collect P) X"
wenzelm@61730
   174
    if "y < C" and y: "\<forall>y<C. eventually (\<lambda>x. y < X x) F" for y P
wenzelm@61730
   175
  proof (cases "\<exists>z. y < z \<and> z < C")
wenzelm@61730
   176
    case True
wenzelm@61730
   177
    then obtain z where z: "y < z \<and> z < C" ..
wenzelm@61730
   178
    moreover from z have "z \<le> INFIMUM {x. z < X x} X"
wenzelm@61730
   179
      by (auto intro!: INF_greatest)
wenzelm@61730
   180
    ultimately show ?thesis
wenzelm@61730
   181
      using y by (intro exI[of _ "\<lambda>x. z < X x"]) auto
wenzelm@61730
   182
  next
wenzelm@61730
   183
    case False
wenzelm@61730
   184
    then have "C \<le> INFIMUM {x. y < X x} X"
wenzelm@61730
   185
      by (intro INF_greatest) auto
wenzelm@61730
   186
    with \<open>y < C\<close> show ?thesis
wenzelm@61730
   187
      using y by (intro exI[of _ "\<lambda>x. y < X x"]) auto
wenzelm@61730
   188
  qed
hoelzl@51340
   189
  ultimately show ?thesis
hoelzl@51340
   190
    unfolding Liminf_def le_SUP_iff by auto
hoelzl@51340
   191
qed
hoelzl@51340
   192
eberlm@62049
   193
lemma Limsup_le_iff:
eberlm@62049
   194
  fixes X :: "_ \<Rightarrow> _ :: complete_linorder"
eberlm@62049
   195
  shows "C \<ge> Limsup F X \<longleftrightarrow> (\<forall>y>C. eventually (\<lambda>x. y > X x) F)"
eberlm@62049
   196
proof -
eberlm@62049
   197
  { fix y P assume "eventually P F" "y > SUPREMUM (Collect P) X"
eberlm@62049
   198
    then have "eventually (\<lambda>x. y > X x) F"
eberlm@62049
   199
      by (auto elim!: eventually_mono dest: SUP_lessD) }
eberlm@62049
   200
  moreover
eberlm@62049
   201
  { fix y P assume "y > C" and y: "\<forall>y>C. eventually (\<lambda>x. y > X x) F"
eberlm@62049
   202
    have "\<exists>P. eventually P F \<and> y > SUPREMUM (Collect P) X"
eberlm@62049
   203
    proof (cases "\<exists>z. C < z \<and> z < y")
eberlm@62049
   204
      case True
eberlm@62049
   205
      then obtain z where z: "C < z \<and> z < y" ..
eberlm@62049
   206
      moreover from z have "z \<ge> SUPREMUM {x. z > X x} X"
eberlm@62049
   207
        by (auto intro!: SUP_least)
eberlm@62049
   208
      ultimately show ?thesis
eberlm@62049
   209
        using y by (intro exI[of _ "\<lambda>x. z > X x"]) auto
eberlm@62049
   210
    next
eberlm@62049
   211
      case False
eberlm@62049
   212
      then have "C \<ge> SUPREMUM {x. y > X x} X"
eberlm@62049
   213
        by (intro SUP_least) (auto simp: not_less)
eberlm@62049
   214
      with \<open>y > C\<close> show ?thesis
eberlm@62049
   215
        using y by (intro exI[of _ "\<lambda>x. y > X x"]) auto
eberlm@62049
   216
    qed }
eberlm@62049
   217
  ultimately show ?thesis
eberlm@62049
   218
    unfolding Limsup_def INF_le_iff by auto
eberlm@62049
   219
qed
eberlm@62049
   220
eberlm@62049
   221
lemma less_LiminfD:
eberlm@62049
   222
  "y < Liminf F (f :: _ \<Rightarrow> 'a :: complete_linorder) \<Longrightarrow> eventually (\<lambda>x. f x > y) F"
eberlm@62049
   223
  using le_Liminf_iff[of "Liminf F f" F f] by simp
eberlm@62049
   224
eberlm@62049
   225
lemma Limsup_lessD:
eberlm@62049
   226
  "y > Limsup F (f :: _ \<Rightarrow> 'a :: complete_linorder) \<Longrightarrow> eventually (\<lambda>x. f x < y) F"
eberlm@62049
   227
  using Limsup_le_iff[of F f "Limsup F f"] by simp
eberlm@62049
   228
hoelzl@51340
   229
lemma lim_imp_Liminf:
wenzelm@61730
   230
  fixes f :: "'a \<Rightarrow> _ :: {complete_linorder,linorder_topology}"
hoelzl@51340
   231
  assumes ntriv: "\<not> trivial_limit F"
wenzelm@61973
   232
  assumes lim: "(f \<longlongrightarrow> f0) F"
hoelzl@51340
   233
  shows "Liminf F f = f0"
hoelzl@51340
   234
proof (intro Liminf_eqI)
hoelzl@51340
   235
  fix P assume P: "eventually P F"
haftmann@56218
   236
  then have "eventually (\<lambda>x. INFIMUM (Collect P) f \<le> f x) F"
hoelzl@51340
   237
    by eventually_elim (auto intro!: INF_lower)
haftmann@56218
   238
  then show "INFIMUM (Collect P) f \<le> f0"
hoelzl@51340
   239
    by (rule tendsto_le[OF ntriv lim tendsto_const])
hoelzl@51340
   240
next
haftmann@56218
   241
  fix y assume upper: "\<And>P. eventually P F \<Longrightarrow> INFIMUM (Collect P) f \<le> y"
hoelzl@51340
   242
  show "f0 \<le> y"
hoelzl@51340
   243
  proof cases
hoelzl@51340
   244
    assume "\<exists>z. y < z \<and> z < f0"
wenzelm@53374
   245
    then obtain z where "y < z \<and> z < f0" ..
haftmann@56218
   246
    moreover have "z \<le> INFIMUM {x. z < f x} f"
hoelzl@51340
   247
      by (rule INF_greatest) simp
hoelzl@51340
   248
    ultimately show ?thesis
hoelzl@51340
   249
      using lim[THEN topological_tendstoD, THEN upper, of "{z <..}"] by auto
hoelzl@51340
   250
  next
hoelzl@51340
   251
    assume discrete: "\<not> (\<exists>z. y < z \<and> z < f0)"
hoelzl@51340
   252
    show ?thesis
hoelzl@51340
   253
    proof (rule classical)
hoelzl@51340
   254
      assume "\<not> f0 \<le> y"
hoelzl@51340
   255
      then have "eventually (\<lambda>x. y < f x) F"
hoelzl@51340
   256
        using lim[THEN topological_tendstoD, of "{y <..}"] by auto
hoelzl@51340
   257
      then have "eventually (\<lambda>x. f0 \<le> f x) F"
lp15@61810
   258
        using discrete by (auto elim!: eventually_mono)
haftmann@56218
   259
      then have "INFIMUM {x. f0 \<le> f x} f \<le> y"
hoelzl@51340
   260
        by (rule upper)
haftmann@56218
   261
      moreover have "f0 \<le> INFIMUM {x. f0 \<le> f x} f"
hoelzl@51340
   262
        by (intro INF_greatest) simp
hoelzl@51340
   263
      ultimately show "f0 \<le> y" by simp
hoelzl@51340
   264
    qed
hoelzl@51340
   265
  qed
hoelzl@51340
   266
qed
hoelzl@51340
   267
hoelzl@51340
   268
lemma lim_imp_Limsup:
wenzelm@61730
   269
  fixes f :: "'a \<Rightarrow> _ :: {complete_linorder,linorder_topology}"
hoelzl@51340
   270
  assumes ntriv: "\<not> trivial_limit F"
wenzelm@61973
   271
  assumes lim: "(f \<longlongrightarrow> f0) F"
hoelzl@51340
   272
  shows "Limsup F f = f0"
hoelzl@51340
   273
proof (intro Limsup_eqI)
hoelzl@51340
   274
  fix P assume P: "eventually P F"
haftmann@56218
   275
  then have "eventually (\<lambda>x. f x \<le> SUPREMUM (Collect P) f) F"
hoelzl@51340
   276
    by eventually_elim (auto intro!: SUP_upper)
haftmann@56218
   277
  then show "f0 \<le> SUPREMUM (Collect P) f"
hoelzl@51340
   278
    by (rule tendsto_le[OF ntriv tendsto_const lim])
hoelzl@51340
   279
next
haftmann@56218
   280
  fix y assume lower: "\<And>P. eventually P F \<Longrightarrow> y \<le> SUPREMUM (Collect P) f"
hoelzl@51340
   281
  show "y \<le> f0"
wenzelm@53381
   282
  proof (cases "\<exists>z. f0 < z \<and> z < y")
wenzelm@53381
   283
    case True
wenzelm@53381
   284
    then obtain z where "f0 < z \<and> z < y" ..
haftmann@56218
   285
    moreover have "SUPREMUM {x. f x < z} f \<le> z"
hoelzl@51340
   286
      by (rule SUP_least) simp
hoelzl@51340
   287
    ultimately show ?thesis
hoelzl@51340
   288
      using lim[THEN topological_tendstoD, THEN lower, of "{..< z}"] by auto
hoelzl@51340
   289
  next
wenzelm@53381
   290
    case False
hoelzl@51340
   291
    show ?thesis
hoelzl@51340
   292
    proof (rule classical)
hoelzl@51340
   293
      assume "\<not> y \<le> f0"
hoelzl@51340
   294
      then have "eventually (\<lambda>x. f x < y) F"
hoelzl@51340
   295
        using lim[THEN topological_tendstoD, of "{..< y}"] by auto
hoelzl@51340
   296
      then have "eventually (\<lambda>x. f x \<le> f0) F"
lp15@61810
   297
        using False by (auto elim!: eventually_mono simp: not_less)
haftmann@56218
   298
      then have "y \<le> SUPREMUM {x. f x \<le> f0} f"
hoelzl@51340
   299
        by (rule lower)
haftmann@56218
   300
      moreover have "SUPREMUM {x. f x \<le> f0} f \<le> f0"
hoelzl@51340
   301
        by (intro SUP_least) simp
hoelzl@51340
   302
      ultimately show "y \<le> f0" by simp
hoelzl@51340
   303
    qed
hoelzl@51340
   304
  qed
hoelzl@51340
   305
qed
hoelzl@51340
   306
hoelzl@51340
   307
lemma Liminf_eq_Limsup:
wenzelm@61730
   308
  fixes f0 :: "'a :: {complete_linorder,linorder_topology}"
hoelzl@51340
   309
  assumes ntriv: "\<not> trivial_limit F"
hoelzl@51340
   310
    and lim: "Liminf F f = f0" "Limsup F f = f0"
wenzelm@61973
   311
  shows "(f \<longlongrightarrow> f0) F"
hoelzl@51340
   312
proof (rule order_tendstoI)
hoelzl@51340
   313
  fix a assume "f0 < a"
hoelzl@51340
   314
  with assms have "Limsup F f < a" by simp
haftmann@56218
   315
  then obtain P where "eventually P F" "SUPREMUM (Collect P) f < a"
hoelzl@51340
   316
    unfolding Limsup_def INF_less_iff by auto
hoelzl@51340
   317
  then show "eventually (\<lambda>x. f x < a) F"
lp15@61810
   318
    by (auto elim!: eventually_mono dest: SUP_lessD)
hoelzl@51340
   319
next
hoelzl@51340
   320
  fix a assume "a < f0"
hoelzl@51340
   321
  with assms have "a < Liminf F f" by simp
haftmann@56218
   322
  then obtain P where "eventually P F" "a < INFIMUM (Collect P) f"
hoelzl@51340
   323
    unfolding Liminf_def less_SUP_iff by auto
hoelzl@51340
   324
  then show "eventually (\<lambda>x. a < f x) F"
lp15@61810
   325
    by (auto elim!: eventually_mono dest: less_INF_D)
hoelzl@51340
   326
qed
hoelzl@51340
   327
hoelzl@51340
   328
lemma tendsto_iff_Liminf_eq_Limsup:
wenzelm@61730
   329
  fixes f0 :: "'a :: {complete_linorder,linorder_topology}"
wenzelm@61973
   330
  shows "\<not> trivial_limit F \<Longrightarrow> (f \<longlongrightarrow> f0) F \<longleftrightarrow> (Liminf F f = f0 \<and> Limsup F f = f0)"
hoelzl@51340
   331
  by (metis Liminf_eq_Limsup lim_imp_Limsup lim_imp_Liminf)
hoelzl@51340
   332
hoelzl@51340
   333
lemma liminf_subseq_mono:
hoelzl@51340
   334
  fixes X :: "nat \<Rightarrow> 'a :: complete_linorder"
hoelzl@51340
   335
  assumes "subseq r"
hoelzl@51340
   336
  shows "liminf X \<le> liminf (X \<circ> r) "
hoelzl@51340
   337
proof-
hoelzl@51340
   338
  have "\<And>n. (INF m:{n..}. X m) \<le> (INF m:{n..}. (X \<circ> r) m)"
hoelzl@51340
   339
  proof (safe intro!: INF_mono)
hoelzl@51340
   340
    fix n m :: nat assume "n \<le> m" then show "\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m"
wenzelm@60500
   341
      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
hoelzl@51340
   342
  qed
haftmann@56212
   343
  then show ?thesis by (auto intro!: SUP_mono simp: liminf_SUP_INF comp_def)
hoelzl@51340
   344
qed
hoelzl@51340
   345
hoelzl@51340
   346
lemma limsup_subseq_mono:
hoelzl@51340
   347
  fixes X :: "nat \<Rightarrow> 'a :: complete_linorder"
hoelzl@51340
   348
  assumes "subseq r"
hoelzl@51340
   349
  shows "limsup (X \<circ> r) \<le> limsup X"
hoelzl@51340
   350
proof-
wenzelm@61730
   351
  have "(SUP m:{n..}. (X \<circ> r) m) \<le> (SUP m:{n..}. X m)" for n
hoelzl@51340
   352
  proof (safe intro!: SUP_mono)
wenzelm@61730
   353
    fix m :: nat
wenzelm@61730
   354
    assume "n \<le> m"
wenzelm@61730
   355
    then show "\<exists>ma\<in>{n..}. (X \<circ> r) m \<le> X ma"
wenzelm@60500
   356
      using seq_suble[OF \<open>subseq r\<close>, of m] by (intro bexI[of _ "r m"]) auto
hoelzl@51340
   357
  qed
wenzelm@61730
   358
  then show ?thesis
wenzelm@61730
   359
    by (auto intro!: INF_mono simp: limsup_INF_SUP comp_def)
hoelzl@51340
   360
qed
hoelzl@51340
   361
wenzelm@61730
   362
lemma continuous_on_imp_continuous_within:
wenzelm@61730
   363
  "continuous_on s f \<Longrightarrow> t \<subseteq> s \<Longrightarrow> x \<in> s \<Longrightarrow> continuous (at x within t) f"
wenzelm@61730
   364
  unfolding continuous_on_eq_continuous_within
wenzelm@61730
   365
  by (auto simp: continuous_within intro: tendsto_within_subset)
hoelzl@61245
   366
eberlm@62049
   367
lemma Liminf_compose_continuous_mono:
eberlm@62049
   368
  fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
eberlm@62049
   369
  assumes c: "continuous_on UNIV f" and am: "mono f" and F: "F \<noteq> bot"
eberlm@62049
   370
  shows "Liminf F (\<lambda>n. f (g n)) = f (Liminf F g)"
eberlm@62049
   371
proof -
eberlm@62049
   372
  { fix P assume "eventually P F"
eberlm@62049
   373
    have "\<exists>x. P x"
eberlm@62049
   374
    proof (rule ccontr)
eberlm@62049
   375
      assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
eberlm@62049
   376
        by auto
eberlm@62049
   377
      with \<open>eventually P F\<close> F show False
eberlm@62049
   378
        by auto
eberlm@62049
   379
    qed }
eberlm@62049
   380
  note * = this
eberlm@62049
   381
eberlm@62049
   382
  have "f (Liminf F g) = (SUP P : {P. eventually P F}. f (Inf (g ` Collect P)))"
haftmann@62343
   383
    unfolding Liminf_def
eberlm@62049
   384
    by (subst continuous_at_Sup_mono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   385
       (auto intro: eventually_True)
eberlm@62049
   386
  also have "\<dots> = (SUP P : {P. eventually P F}. INFIMUM (g ` Collect P) f)"
eberlm@62049
   387
    by (intro SUP_cong refl continuous_at_Inf_mono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   388
       (auto dest!: eventually_happens simp: F)
eberlm@62049
   389
  finally show ?thesis by (auto simp: Liminf_def)
eberlm@62049
   390
qed
eberlm@62049
   391
eberlm@62049
   392
lemma Limsup_compose_continuous_mono:
eberlm@62049
   393
  fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
eberlm@62049
   394
  assumes c: "continuous_on UNIV f" and am: "mono f" and F: "F \<noteq> bot"
eberlm@62049
   395
  shows "Limsup F (\<lambda>n. f (g n)) = f (Limsup F g)"
eberlm@62049
   396
proof -
eberlm@62049
   397
  { fix P assume "eventually P F"
eberlm@62049
   398
    have "\<exists>x. P x"
eberlm@62049
   399
    proof (rule ccontr)
eberlm@62049
   400
      assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
eberlm@62049
   401
        by auto
eberlm@62049
   402
      with \<open>eventually P F\<close> F show False
eberlm@62049
   403
        by auto
eberlm@62049
   404
    qed }
eberlm@62049
   405
  note * = this
eberlm@62049
   406
eberlm@62049
   407
  have "f (Limsup F g) = (INF P : {P. eventually P F}. f (Sup (g ` Collect P)))"
haftmann@62343
   408
    unfolding Limsup_def
eberlm@62049
   409
    by (subst continuous_at_Inf_mono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   410
       (auto intro: eventually_True)
eberlm@62049
   411
  also have "\<dots> = (INF P : {P. eventually P F}. SUPREMUM (g ` Collect P) f)"
eberlm@62049
   412
    by (intro INF_cong refl continuous_at_Sup_mono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   413
       (auto dest!: eventually_happens simp: F)
eberlm@62049
   414
  finally show ?thesis by (auto simp: Limsup_def)
eberlm@62049
   415
qed
eberlm@62049
   416
hoelzl@61245
   417
lemma Liminf_compose_continuous_antimono:
wenzelm@61730
   418
  fixes f :: "'a::{complete_linorder,linorder_topology} \<Rightarrow> 'b::{complete_linorder,linorder_topology}"
wenzelm@61730
   419
  assumes c: "continuous_on UNIV f"
wenzelm@61730
   420
    and am: "antimono f"
wenzelm@61730
   421
    and F: "F \<noteq> bot"
hoelzl@61245
   422
  shows "Liminf F (\<lambda>n. f (g n)) = f (Limsup F g)"
hoelzl@61245
   423
proof -
wenzelm@61730
   424
  have *: "\<exists>x. P x" if "eventually P F" for P
wenzelm@61730
   425
  proof (rule ccontr)
wenzelm@61730
   426
    assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
wenzelm@61730
   427
      by auto
wenzelm@61730
   428
    with \<open>eventually P F\<close> F show False
wenzelm@61730
   429
      by auto
wenzelm@61730
   430
  qed
hoelzl@61245
   431
  have "f (Limsup F g) = (SUP P : {P. eventually P F}. f (Sup (g ` Collect P)))"
haftmann@62343
   432
    unfolding Limsup_def
hoelzl@61245
   433
    by (subst continuous_at_Inf_antimono[OF am continuous_on_imp_continuous_within[OF c]])
hoelzl@61245
   434
       (auto intro: eventually_True)
hoelzl@61245
   435
  also have "\<dots> = (SUP P : {P. eventually P F}. INFIMUM (g ` Collect P) f)"
hoelzl@61245
   436
    by (intro SUP_cong refl continuous_at_Sup_antimono[OF am continuous_on_imp_continuous_within[OF c]])
hoelzl@61245
   437
       (auto dest!: eventually_happens simp: F)
hoelzl@61245
   438
  finally show ?thesis
hoelzl@61245
   439
    by (auto simp: Liminf_def)
hoelzl@61245
   440
qed
eberlm@62049
   441
eberlm@62049
   442
lemma Limsup_compose_continuous_antimono:
eberlm@62049
   443
  fixes f :: "'a::{complete_linorder, linorder_topology} \<Rightarrow> 'b::{complete_linorder, linorder_topology}"
eberlm@62049
   444
  assumes c: "continuous_on UNIV f" and am: "antimono f" and F: "F \<noteq> bot"
eberlm@62049
   445
  shows "Limsup F (\<lambda>n. f (g n)) = f (Liminf F g)"
eberlm@62049
   446
proof -
eberlm@62049
   447
  { fix P assume "eventually P F"
eberlm@62049
   448
    have "\<exists>x. P x"
eberlm@62049
   449
    proof (rule ccontr)
eberlm@62049
   450
      assume "\<not> (\<exists>x. P x)" then have "P = (\<lambda>x. False)"
eberlm@62049
   451
        by auto
eberlm@62049
   452
      with \<open>eventually P F\<close> F show False
eberlm@62049
   453
        by auto
eberlm@62049
   454
    qed }
eberlm@62049
   455
  note * = this
eberlm@62049
   456
eberlm@62049
   457
  have "f (Liminf F g) = (INF P : {P. eventually P F}. f (Inf (g ` Collect P)))"
haftmann@62343
   458
    unfolding Liminf_def
eberlm@62049
   459
    by (subst continuous_at_Sup_antimono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   460
       (auto intro: eventually_True)
eberlm@62049
   461
  also have "\<dots> = (INF P : {P. eventually P F}. SUPREMUM (g ` Collect P) f)"
eberlm@62049
   462
    by (intro INF_cong refl continuous_at_Inf_antimono[OF am continuous_on_imp_continuous_within[OF c]])
eberlm@62049
   463
       (auto dest!: eventually_happens simp: F)
eberlm@62049
   464
  finally show ?thesis
eberlm@62049
   465
    by (auto simp: Limsup_def)
eberlm@62049
   466
qed
eberlm@62049
   467
eberlm@62049
   468
hoelzl@61880
   469
subsection \<open>More Limits\<close>
hoelzl@61880
   470
hoelzl@61880
   471
lemma convergent_limsup_cl:
hoelzl@61880
   472
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
hoelzl@61880
   473
  shows "convergent X \<Longrightarrow> limsup X = lim X"
hoelzl@61880
   474
  by (auto simp: convergent_def limI lim_imp_Limsup)
hoelzl@61880
   475
hoelzl@61880
   476
lemma convergent_liminf_cl:
hoelzl@61880
   477
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
hoelzl@61880
   478
  shows "convergent X \<Longrightarrow> liminf X = lim X"
hoelzl@61880
   479
  by (auto simp: convergent_def limI lim_imp_Liminf)
hoelzl@61880
   480
hoelzl@61880
   481
lemma lim_increasing_cl:
hoelzl@61880
   482
  assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<ge> f m"
wenzelm@61969
   483
  obtains l where "f \<longlonglongrightarrow> (l::'a::{complete_linorder,linorder_topology})"
hoelzl@61880
   484
proof
wenzelm@61969
   485
  show "f \<longlonglongrightarrow> (SUP n. f n)"
hoelzl@61880
   486
    using assms
hoelzl@61880
   487
    by (intro increasing_tendsto)
hoelzl@61880
   488
       (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans)
hoelzl@61880
   489
qed
hoelzl@61880
   490
hoelzl@61880
   491
lemma lim_decreasing_cl:
hoelzl@61880
   492
  assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<le> f m"
wenzelm@61969
   493
  obtains l where "f \<longlonglongrightarrow> (l::'a::{complete_linorder,linorder_topology})"
hoelzl@61880
   494
proof
wenzelm@61969
   495
  show "f \<longlonglongrightarrow> (INF n. f n)"
hoelzl@61880
   496
    using assms
hoelzl@61880
   497
    by (intro decreasing_tendsto)
hoelzl@61880
   498
       (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans)
hoelzl@61880
   499
qed
hoelzl@61880
   500
hoelzl@61880
   501
lemma compact_complete_linorder:
hoelzl@61880
   502
  fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
wenzelm@61969
   503
  shows "\<exists>l r. subseq r \<and> (X \<circ> r) \<longlonglongrightarrow> l"
hoelzl@61880
   504
proof -
hoelzl@61880
   505
  obtain r where "subseq r" and mono: "monoseq (X \<circ> r)"
hoelzl@61880
   506
    using seq_monosub[of X]
hoelzl@61880
   507
    unfolding comp_def
hoelzl@61880
   508
    by auto
hoelzl@61880
   509
  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
   510
    by (auto simp add: monoseq_def)
wenzelm@61969
   511
  then obtain l where "(X \<circ> r) \<longlonglongrightarrow> l"
hoelzl@61880
   512
     using lim_increasing_cl[of "X \<circ> r"] lim_decreasing_cl[of "X \<circ> r"]
hoelzl@61880
   513
     by auto
hoelzl@61880
   514
  then show ?thesis
hoelzl@61880
   515
    using \<open>subseq r\<close> by auto
hoelzl@61880
   516
qed
hoelzl@61245
   517
hoelzl@51340
   518
end