src/HOL/Lim.thy
author bulwahn
Fri Oct 21 11:17:14 2011 +0200 (2011-10-21)
changeset 45231 d85a2fdc586c
parent 45031 9583f2b56f85
child 50331 4b6dc5077e98
permissions -rw-r--r--
replacing code_inline by code_unfold, removing obsolete code_unfold, code_inline del now that the ancient code generator is removed
paulson@10751
     1
(*  Title       : Lim.thy
paulson@10751
     2
    Author      : Jacques D. Fleuriot
paulson@10751
     3
    Copyright   : 1998  University of Cambridge
paulson@14477
     4
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
paulson@10751
     5
*)
paulson@10751
     6
huffman@21165
     7
header{* Limits and Continuity *}
paulson@10751
     8
nipkow@15131
     9
theory Lim
haftmann@29197
    10
imports SEQ
nipkow@15131
    11
begin
paulson@14477
    12
huffman@22641
    13
text{*Standard Definitions*}
paulson@10751
    14
huffman@36661
    15
abbreviation
huffman@36662
    16
  LIM :: "['a::topological_space \<Rightarrow> 'b::topological_space, 'a, 'b] \<Rightarrow> bool"
wenzelm@21404
    17
        ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) where
huffman@36661
    18
  "f -- a --> L \<equiv> (f ---> L) (at a)"
paulson@10751
    19
wenzelm@21404
    20
definition
huffman@36662
    21
  isCont :: "['a::topological_space \<Rightarrow> 'b::topological_space, 'a] \<Rightarrow> bool" where
wenzelm@19765
    22
  "isCont f a = (f -- a --> (f a))"
paulson@10751
    23
wenzelm@21404
    24
definition
huffman@31338
    25
  isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where
haftmann@37767
    26
  "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
paulson@10751
    27
huffman@31392
    28
subsection {* Limits of Functions *}
huffman@31349
    29
huffman@36661
    30
lemma LIM_def: "f -- a --> L =
huffman@36661
    31
     (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & dist x a < s
huffman@36661
    32
        --> dist (f x) L < r)"
huffman@36661
    33
unfolding tendsto_iff eventually_at ..
paulson@10751
    34
huffman@31338
    35
lemma metric_LIM_I:
huffman@31338
    36
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>s>0. \<forall>x. x \<noteq> a \<and> dist x a < s \<longrightarrow> dist (f x) L < r)
huffman@31338
    37
    \<Longrightarrow> f -- a --> L"
huffman@31338
    38
by (simp add: LIM_def)
huffman@31338
    39
huffman@31338
    40
lemma metric_LIM_D:
huffman@31338
    41
  "\<lbrakk>f -- a --> L; 0 < r\<rbrakk>
huffman@31338
    42
    \<Longrightarrow> \<exists>s>0. \<forall>x. x \<noteq> a \<and> dist x a < s \<longrightarrow> dist (f x) L < r"
huffman@31338
    43
by (simp add: LIM_def)
paulson@14477
    44
paulson@14477
    45
lemma LIM_eq:
huffman@31338
    46
  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
huffman@31338
    47
  shows "f -- a --> L =
huffman@20561
    48
     (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
huffman@31338
    49
by (simp add: LIM_def dist_norm)
paulson@14477
    50
huffman@20552
    51
lemma LIM_I:
huffman@31338
    52
  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
huffman@31338
    53
  shows "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
huffman@20552
    54
      ==> f -- a --> L"
huffman@20552
    55
by (simp add: LIM_eq)
huffman@20552
    56
paulson@14477
    57
lemma LIM_D:
huffman@31338
    58
  fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
huffman@31338
    59
  shows "[| f -- a --> L; 0<r |]
huffman@20561
    60
      ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
paulson@14477
    61
by (simp add: LIM_eq)
paulson@14477
    62
huffman@31338
    63
lemma LIM_offset:
huffman@36662
    64
  fixes a :: "'a::real_normed_vector"
huffman@31338
    65
  shows "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
huffman@36662
    66
apply (rule topological_tendstoI)
huffman@36662
    67
apply (drule (2) topological_tendstoD)
huffman@36662
    68
apply (simp only: eventually_at dist_norm)
huffman@36662
    69
apply (clarify, rule_tac x=d in exI, safe)
huffman@20756
    70
apply (drule_tac x="x + k" in spec)
nipkow@29667
    71
apply (simp add: algebra_simps)
huffman@20756
    72
done
huffman@20756
    73
huffman@31338
    74
lemma LIM_offset_zero:
huffman@36662
    75
  fixes a :: "'a::real_normed_vector"
huffman@31338
    76
  shows "f -- a --> L \<Longrightarrow> (\<lambda>h. f (a + h)) -- 0 --> L"
huffman@21239
    77
by (drule_tac k="a" in LIM_offset, simp add: add_commute)
huffman@21239
    78
huffman@31338
    79
lemma LIM_offset_zero_cancel:
huffman@36662
    80
  fixes a :: "'a::real_normed_vector"
huffman@31338
    81
  shows "(\<lambda>h. f (a + h)) -- 0 --> L \<Longrightarrow> f -- a --> L"
huffman@21239
    82
by (drule_tac k="- a" in LIM_offset, simp)
huffman@21239
    83
hoelzl@32650
    84
lemma LIM_cong_limit: "\<lbrakk> f -- x --> L ; K = L \<rbrakk> \<Longrightarrow> f -- x --> K" by simp
hoelzl@32650
    85
huffman@31338
    86
lemma LIM_zero:
huffman@36662
    87
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@44570
    88
  shows "(f ---> l) F \<Longrightarrow> ((\<lambda>x. f x - l) ---> 0) F"
huffman@36662
    89
unfolding tendsto_iff dist_norm by simp
huffman@21239
    90
huffman@31338
    91
lemma LIM_zero_cancel:
huffman@36662
    92
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@44570
    93
  shows "((\<lambda>x. f x - l) ---> 0) F \<Longrightarrow> (f ---> l) F"
huffman@36662
    94
unfolding tendsto_iff dist_norm by simp
huffman@21239
    95
huffman@31338
    96
lemma LIM_zero_iff:
huffman@31338
    97
  fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
huffman@44570
    98
  shows "((\<lambda>x. f x - l) ---> 0) F = (f ---> l) F"
huffman@36662
    99
unfolding tendsto_iff dist_norm by simp
huffman@21399
   100
huffman@31338
   101
lemma metric_LIM_imp_LIM:
huffman@21257
   102
  assumes f: "f -- a --> l"
huffman@31338
   103
  assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> dist (g x) m \<le> dist (f x) l"
huffman@21257
   104
  shows "g -- a --> m"
huffman@44251
   105
  by (rule metric_tendsto_imp_tendsto [OF f],
huffman@44251
   106
    auto simp add: eventually_at_topological le)
huffman@21257
   107
huffman@31338
   108
lemma LIM_imp_LIM:
huffman@36662
   109
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@36662
   110
  fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
huffman@31338
   111
  assumes f: "f -- a --> l"
huffman@31338
   112
  assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
huffman@31338
   113
  shows "g -- a --> m"
huffman@44251
   114
  by (rule metric_LIM_imp_LIM [OF f],
huffman@44251
   115
    simp add: dist_norm le)
huffman@31338
   116
huffman@20561
   117
lemma LIM_const_not_eq:
huffman@44571
   118
  fixes a :: "'a::perfect_space"
huffman@44205
   119
  fixes k L :: "'b::t2_space"
huffman@23076
   120
  shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --> L"
huffman@44571
   121
  by (simp add: tendsto_const_iff)
paulson@14477
   122
huffman@21786
   123
lemmas LIM_not_zero = LIM_const_not_eq [where L = 0]
huffman@21786
   124
huffman@20561
   125
lemma LIM_const_eq:
huffman@44571
   126
  fixes a :: "'a::perfect_space"
huffman@44205
   127
  fixes k L :: "'b::t2_space"
huffman@23076
   128
  shows "(\<lambda>x. k) -- a --> L \<Longrightarrow> k = L"
huffman@44571
   129
  by (simp add: tendsto_const_iff)
paulson@14477
   130
huffman@20561
   131
lemma LIM_unique:
huffman@44571
   132
  fixes a :: "'a::perfect_space"
huffman@44205
   133
  fixes L M :: "'b::t2_space"
huffman@23076
   134
  shows "\<lbrakk>f -- a --> L; f -- a --> M\<rbrakk> \<Longrightarrow> L = M"
huffman@44571
   135
  using at_neq_bot by (rule tendsto_unique)
paulson@14477
   136
paulson@14477
   137
text{*Limits are equal for functions equal except at limit point*}
paulson@14477
   138
lemma LIM_equal:
paulson@14477
   139
     "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
huffman@36662
   140
unfolding tendsto_def eventually_at_topological by simp
paulson@14477
   141
huffman@20796
   142
lemma LIM_cong:
huffman@20796
   143
  "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
huffman@21399
   144
   \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
huffman@36662
   145
by (simp add: LIM_equal)
huffman@20796
   146
huffman@31338
   147
lemma metric_LIM_equal2:
huffman@21282
   148
  assumes 1: "0 < R"
huffman@31338
   149
  assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < R\<rbrakk> \<Longrightarrow> f x = g x"
huffman@21282
   150
  shows "g -- a --> l \<Longrightarrow> f -- a --> l"
huffman@36662
   151
apply (rule topological_tendstoI)
huffman@36662
   152
apply (drule (2) topological_tendstoD)
huffman@36662
   153
apply (simp add: eventually_at, safe)
huffman@36662
   154
apply (rule_tac x="min d R" in exI, safe)
huffman@21282
   155
apply (simp add: 1)
huffman@21282
   156
apply (simp add: 2)
huffman@21282
   157
done
huffman@21282
   158
huffman@31338
   159
lemma LIM_equal2:
huffman@36662
   160
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
huffman@31338
   161
  assumes 1: "0 < R"
huffman@31338
   162
  assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
huffman@31338
   163
  shows "g -- a --> l \<Longrightarrow> f -- a --> l"
huffman@36662
   164
by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
huffman@31338
   165
huffman@36662
   166
lemma LIM_compose_eventually:
huffman@36662
   167
  assumes f: "f -- a --> b"
huffman@36662
   168
  assumes g: "g -- b --> c"
huffman@36662
   169
  assumes inj: "eventually (\<lambda>x. f x \<noteq> b) (at a)"
huffman@36662
   170
  shows "(\<lambda>x. g (f x)) -- a --> c"
huffman@44253
   171
  using g f inj by (rule tendsto_compose_eventually)
huffman@21239
   172
huffman@31338
   173
lemma metric_LIM_compose2:
huffman@31338
   174
  assumes f: "f -- a --> b"
huffman@31338
   175
  assumes g: "g -- b --> c"
huffman@31338
   176
  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> b"
huffman@31338
   177
  shows "(\<lambda>x. g (f x)) -- a --> c"
huffman@44314
   178
  using g f inj [folded eventually_at]
huffman@44314
   179
  by (rule tendsto_compose_eventually)
huffman@31338
   180
huffman@23040
   181
lemma LIM_compose2:
huffman@31338
   182
  fixes a :: "'a::real_normed_vector"
huffman@23040
   183
  assumes f: "f -- a --> b"
huffman@23040
   184
  assumes g: "g -- b --> c"
huffman@23040
   185
  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
huffman@23040
   186
  shows "(\<lambda>x. g (f x)) -- a --> c"
huffman@31338
   187
by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
huffman@23040
   188
huffman@21239
   189
lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
huffman@44314
   190
  unfolding o_def by (rule tendsto_compose)
huffman@21239
   191
huffman@21282
   192
lemma real_LIM_sandwich_zero:
huffman@36662
   193
  fixes f g :: "'a::topological_space \<Rightarrow> real"
huffman@21282
   194
  assumes f: "f -- a --> 0"
huffman@21282
   195
  assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
huffman@21282
   196
  assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
huffman@21282
   197
  shows "g -- a --> 0"
huffman@21282
   198
proof (rule LIM_imp_LIM [OF f])
huffman@21282
   199
  fix x assume x: "x \<noteq> a"
huffman@21282
   200
  have "norm (g x - 0) = g x" by (simp add: 1 x)
huffman@21282
   201
  also have "g x \<le> f x" by (rule 2 [OF x])
huffman@21282
   202
  also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
huffman@21282
   203
  also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
huffman@21282
   204
  finally show "norm (g x - 0) \<le> norm (f x - 0)" .
huffman@21282
   205
qed
huffman@21282
   206
paulson@14477
   207
huffman@20755
   208
subsection {* Continuity *}
paulson@14477
   209
huffman@31338
   210
lemma LIM_isCont_iff:
huffman@36665
   211
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
huffman@31338
   212
  shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
huffman@21239
   213
by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
huffman@21239
   214
huffman@31338
   215
lemma isCont_iff:
huffman@36665
   216
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
huffman@31338
   217
  shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
huffman@21239
   218
by (simp add: isCont_def LIM_isCont_iff)
huffman@21239
   219
huffman@23069
   220
lemma isCont_ident [simp]: "isCont (\<lambda>x. x) a"
huffman@44314
   221
  unfolding isCont_def by (rule tendsto_ident_at)
huffman@21239
   222
huffman@21786
   223
lemma isCont_const [simp]: "isCont (\<lambda>x. k) a"
huffman@44314
   224
  unfolding isCont_def by (rule tendsto_const)
huffman@21239
   225
huffman@44233
   226
lemma isCont_norm [simp]:
huffman@36665
   227
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@31338
   228
  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
huffman@44314
   229
  unfolding isCont_def by (rule tendsto_norm)
huffman@21786
   230
huffman@44233
   231
lemma isCont_rabs [simp]:
huffman@44233
   232
  fixes f :: "'a::topological_space \<Rightarrow> real"
huffman@44233
   233
  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x\<bar>) a"
huffman@44314
   234
  unfolding isCont_def by (rule tendsto_rabs)
huffman@22627
   235
huffman@44233
   236
lemma isCont_add [simp]:
huffman@36665
   237
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@31338
   238
  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
huffman@44314
   239
  unfolding isCont_def by (rule tendsto_add)
huffman@21239
   240
huffman@44233
   241
lemma isCont_minus [simp]:
huffman@36665
   242
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@31338
   243
  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
huffman@44314
   244
  unfolding isCont_def by (rule tendsto_minus)
huffman@21239
   245
huffman@44233
   246
lemma isCont_diff [simp]:
huffman@36665
   247
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@31338
   248
  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
huffman@44314
   249
  unfolding isCont_def by (rule tendsto_diff)
huffman@21239
   250
huffman@44233
   251
lemma isCont_mult [simp]:
huffman@36665
   252
  fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra"
huffman@21786
   253
  shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
huffman@44314
   254
  unfolding isCont_def by (rule tendsto_mult)
huffman@21239
   255
huffman@44233
   256
lemma isCont_inverse [simp]:
huffman@36665
   257
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_div_algebra"
huffman@21786
   258
  shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. inverse (f x)) a"
huffman@44314
   259
  unfolding isCont_def by (rule tendsto_inverse)
huffman@21239
   260
huffman@44233
   261
lemma isCont_divide [simp]:
huffman@44233
   262
  fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_field"
huffman@44233
   263
  shows "\<lbrakk>isCont f a; isCont g a; g a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x / g x) a"
huffman@44233
   264
  unfolding isCont_def by (rule tendsto_divide)
huffman@44233
   265
huffman@44310
   266
lemma isCont_tendsto_compose:
huffman@44310
   267
  "\<lbrakk>isCont g l; (f ---> l) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. g (f x)) ---> g l) F"
huffman@44310
   268
  unfolding isCont_def by (rule tendsto_compose)
huffman@44310
   269
huffman@31338
   270
lemma metric_isCont_LIM_compose2:
huffman@31338
   271
  assumes f [unfolded isCont_def]: "isCont f a"
huffman@31338
   272
  assumes g: "g -- f a --> l"
huffman@31338
   273
  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> f a"
huffman@31338
   274
  shows "(\<lambda>x. g (f x)) -- a --> l"
huffman@31338
   275
by (rule metric_LIM_compose2 [OF f g inj])
huffman@31338
   276
huffman@23040
   277
lemma isCont_LIM_compose2:
huffman@31338
   278
  fixes a :: "'a::real_normed_vector"
huffman@23040
   279
  assumes f [unfolded isCont_def]: "isCont f a"
huffman@23040
   280
  assumes g: "g -- f a --> l"
huffman@23040
   281
  assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
huffman@23040
   282
  shows "(\<lambda>x. g (f x)) -- a --> l"
huffman@23040
   283
by (rule LIM_compose2 [OF f g inj])
huffman@23040
   284
huffman@21239
   285
lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
huffman@44314
   286
  unfolding isCont_def by (rule tendsto_compose)
huffman@21239
   287
huffman@21239
   288
lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
huffman@21282
   289
  unfolding o_def by (rule isCont_o2)
huffman@21282
   290
huffman@44233
   291
lemma (in bounded_linear) isCont:
huffman@44233
   292
  "isCont g a \<Longrightarrow> isCont (\<lambda>x. f (g x)) a"
huffman@44314
   293
  unfolding isCont_def by (rule tendsto)
huffman@21282
   294
huffman@21282
   295
lemma (in bounded_bilinear) isCont:
huffman@21282
   296
  "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
huffman@44314
   297
  unfolding isCont_def by (rule tendsto)
huffman@21282
   298
huffman@44282
   299
lemmas isCont_scaleR [simp] =
huffman@44282
   300
  bounded_bilinear.isCont [OF bounded_bilinear_scaleR]
huffman@21239
   301
huffman@44282
   302
lemmas isCont_of_real [simp] =
huffman@44282
   303
  bounded_linear.isCont [OF bounded_linear_of_real]
huffman@22627
   304
huffman@44233
   305
lemma isCont_power [simp]:
huffman@36665
   306
  fixes f :: "'a::topological_space \<Rightarrow> 'b::{power,real_normed_algebra}"
huffman@22627
   307
  shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
huffman@44314
   308
  unfolding isCont_def by (rule tendsto_power)
huffman@22627
   309
huffman@44233
   310
lemma isCont_sgn [simp]:
huffman@36665
   311
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
huffman@31338
   312
  shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. sgn (f x)) a"
huffman@44314
   313
  unfolding isCont_def by (rule tendsto_sgn)
huffman@29885
   314
huffman@44233
   315
lemma isCont_setsum [simp]:
huffman@44233
   316
  fixes f :: "'a \<Rightarrow> 'b::topological_space \<Rightarrow> 'c::real_normed_vector"
huffman@44233
   317
  fixes A :: "'a set"
huffman@44233
   318
  shows "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a"
huffman@44233
   319
  unfolding isCont_def by (simp add: tendsto_setsum)
paulson@15228
   320
huffman@44233
   321
lemmas isCont_intros =
huffman@44233
   322
  isCont_ident isCont_const isCont_norm isCont_rabs isCont_add isCont_minus
huffman@44233
   323
  isCont_diff isCont_mult isCont_inverse isCont_divide isCont_scaleR
huffman@44233
   324
  isCont_of_real isCont_power isCont_sgn isCont_setsum
hoelzl@29803
   325
hoelzl@29803
   326
lemma LIM_less_bound: fixes f :: "real \<Rightarrow> real" assumes "b < x"
hoelzl@29803
   327
  and all_le: "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and isCont: "isCont f x"
hoelzl@29803
   328
  shows "0 \<le> f x"
hoelzl@29803
   329
proof (rule ccontr)
hoelzl@29803
   330
  assume "\<not> 0 \<le> f x" hence "f x < 0" by auto
hoelzl@29803
   331
  hence "0 < - f x / 2" by auto
hoelzl@29803
   332
  from isCont[unfolded isCont_def, THEN LIM_D, OF this]
hoelzl@29803
   333
  obtain s where "s > 0" and s_D: "\<And>x'. \<lbrakk> x' \<noteq> x ; \<bar> x' - x \<bar> < s \<rbrakk> \<Longrightarrow> \<bar> f x' - f x \<bar> < - f x / 2" by auto
hoelzl@29803
   334
hoelzl@29803
   335
  let ?x = "x - min (s / 2) ((x - b) / 2)"
hoelzl@29803
   336
  have "?x < x" and "\<bar> ?x - x \<bar> < s"
hoelzl@29803
   337
    using `b < x` and `0 < s` by auto
hoelzl@29803
   338
  have "b < ?x"
hoelzl@29803
   339
  proof (cases "s < x - b")
hoelzl@29803
   340
    case True thus ?thesis using `0 < s` by auto
hoelzl@29803
   341
  next
hoelzl@29803
   342
    case False hence "s / 2 \<ge> (x - b) / 2" by auto
haftmann@32642
   343
    hence "?x = (x + b) / 2" by (simp add: field_simps min_max.inf_absorb2)
hoelzl@29803
   344
    thus ?thesis using `b < x` by auto
hoelzl@29803
   345
  qed
hoelzl@29803
   346
  hence "0 \<le> f ?x" using all_le `?x < x` by auto
hoelzl@29803
   347
  moreover have "\<bar>f ?x - f x\<bar> < - f x / 2"
hoelzl@29803
   348
    using s_D[OF _ `\<bar> ?x - x \<bar> < s`] `?x < x` by auto
hoelzl@29803
   349
  hence "f ?x - f x < - f x / 2" by auto
hoelzl@29803
   350
  hence "f ?x < f x / 2" by auto
hoelzl@29803
   351
  hence "f ?x < 0" using `f x < 0` by auto
hoelzl@29803
   352
  thus False using `0 \<le> f ?x` by auto
hoelzl@29803
   353
qed
huffman@31338
   354
paulson@14477
   355
huffman@20755
   356
subsection {* Uniform Continuity *}
huffman@20755
   357
paulson@14477
   358
lemma isUCont_isCont: "isUCont f ==> isCont f x"
huffman@23012
   359
by (simp add: isUCont_def isCont_def LIM_def, force)
paulson@14477
   360
huffman@23118
   361
lemma isUCont_Cauchy:
huffman@23118
   362
  "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
huffman@23118
   363
unfolding isUCont_def
huffman@31338
   364
apply (rule metric_CauchyI)
huffman@23118
   365
apply (drule_tac x=e in spec, safe)
huffman@31338
   366
apply (drule_tac e=s in metric_CauchyD, safe)
huffman@23118
   367
apply (rule_tac x=M in exI, simp)
huffman@23118
   368
done
huffman@23118
   369
huffman@23118
   370
lemma (in bounded_linear) isUCont: "isUCont f"
huffman@31338
   371
unfolding isUCont_def dist_norm
huffman@23118
   372
proof (intro allI impI)
huffman@23118
   373
  fix r::real assume r: "0 < r"
huffman@23118
   374
  obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
huffman@23118
   375
    using pos_bounded by fast
huffman@23118
   376
  show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
huffman@23118
   377
  proof (rule exI, safe)
huffman@23118
   378
    from r K show "0 < r / K" by (rule divide_pos_pos)
huffman@23118
   379
  next
huffman@23118
   380
    fix x y :: 'a
huffman@23118
   381
    assume xy: "norm (x - y) < r / K"
huffman@23118
   382
    have "norm (f x - f y) = norm (f (x - y))" by (simp only: diff)
huffman@23118
   383
    also have "\<dots> \<le> norm (x - y) * K" by (rule norm_le)
huffman@23118
   384
    also from K xy have "\<dots> < r" by (simp only: pos_less_divide_eq)
huffman@23118
   385
    finally show "norm (f x - f y) < r" .
huffman@23118
   386
  qed
huffman@23118
   387
qed
huffman@23118
   388
huffman@23118
   389
lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
huffman@23118
   390
by (rule isUCont [THEN isUCont_Cauchy])
huffman@23118
   391
paulson@14477
   392
huffman@21165
   393
subsection {* Relation of LIM and LIMSEQ *}
kleing@19023
   394
huffman@44532
   395
lemma sequentially_imp_eventually_within:
huffman@44532
   396
  fixes a :: "'a::metric_space"
huffman@44532
   397
  assumes "\<forall>f. (\<forall>n. f n \<in> s \<and> f n \<noteq> a) \<and> f ----> a \<longrightarrow>
huffman@44532
   398
    eventually (\<lambda>n. P (f n)) sequentially"
huffman@44532
   399
  shows "eventually P (at a within s)"
huffman@44532
   400
proof (rule ccontr)
huffman@44532
   401
  let ?I = "\<lambda>n. inverse (real (Suc n))"
huffman@44532
   402
  def F \<equiv> "\<lambda>n::nat. SOME x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x"
huffman@44532
   403
  assume "\<not> eventually P (at a within s)"
huffman@44532
   404
  hence P: "\<forall>d>0. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < d \<and> \<not> P x"
huffman@44532
   405
    unfolding Limits.eventually_within Limits.eventually_at by fast
huffman@44532
   406
  hence "\<And>n. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x" by simp
huffman@44532
   407
  hence F: "\<And>n. F n \<in> s \<and> F n \<noteq> a \<and> dist (F n) a < ?I n \<and> \<not> P (F n)"
huffman@44532
   408
    unfolding F_def by (rule someI_ex)
huffman@44532
   409
  hence F0: "\<forall>n. F n \<in> s" and F1: "\<forall>n. F n \<noteq> a"
huffman@44532
   410
    and F2: "\<forall>n. dist (F n) a < ?I n" and F3: "\<forall>n. \<not> P (F n)"
huffman@44532
   411
    by fast+
huffman@44532
   412
  from LIMSEQ_inverse_real_of_nat have "F ----> a"
huffman@44532
   413
    by (rule metric_tendsto_imp_tendsto,
huffman@44532
   414
      simp add: dist_norm F2 less_imp_le)
huffman@44532
   415
  hence "eventually (\<lambda>n. P (F n)) sequentially"
huffman@44532
   416
    using assms F0 F1 by simp
huffman@44532
   417
  thus "False" by (simp add: F3)
huffman@44532
   418
qed
huffman@44532
   419
huffman@44532
   420
lemma sequentially_imp_eventually_at:
huffman@44532
   421
  fixes a :: "'a::metric_space"
huffman@44532
   422
  assumes "\<forall>f. (\<forall>n. f n \<noteq> a) \<and> f ----> a \<longrightarrow>
huffman@44532
   423
    eventually (\<lambda>n. P (f n)) sequentially"
huffman@44532
   424
  shows "eventually P (at a)"
huffman@45031
   425
  using assms sequentially_imp_eventually_within [where s=UNIV] by simp
huffman@44532
   426
kleing@19023
   427
lemma LIMSEQ_SEQ_conv1:
huffman@44254
   428
  fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space"
huffman@44254
   429
  assumes f: "f -- a --> l"
huffman@44254
   430
  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
huffman@44254
   431
  using tendsto_compose_eventually [OF f, where F=sequentially] by simp
huffman@31338
   432
huffman@44254
   433
lemma LIMSEQ_SEQ_conv2:
huffman@44254
   434
  fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
huffman@44254
   435
  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
huffman@44254
   436
  shows "f -- a --> l"
huffman@44254
   437
  using assms unfolding tendsto_def [where l=l]
huffman@44532
   438
  by (simp add: sequentially_imp_eventually_at)
huffman@44254
   439
kleing@19023
   440
lemma LIMSEQ_SEQ_conv:
huffman@44254
   441
  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::'a::metric_space) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
huffman@44254
   442
   (X -- a --> (L::'b::topological_space))"
huffman@44253
   443
  using LIMSEQ_SEQ_conv2 LIMSEQ_SEQ_conv1 ..
kleing@19023
   444
paulson@10751
   445
end