src/HOL/SEQ.thy
author hoelzl
Tue May 04 17:53:20 2010 +0200 (2010-05-04)
changeset 36647 edc381bf7200
parent 36625 2ba6525f9905
child 36650 d65f07abfa7c
permissions -rw-r--r--
Removed unnecessary assumption
wenzelm@32960
     1
(*  Title:      HOL/SEQ.thy
wenzelm@32960
     2
    Author:     Jacques D. Fleuriot, University of Cambridge
wenzelm@32960
     3
    Author:     Lawrence C Paulson
wenzelm@32960
     4
    Author:     Jeremy Avigad
wenzelm@32960
     5
    Author:     Brian Huffman
wenzelm@32960
     6
wenzelm@32960
     7
Convergence of sequences and series.
paulson@15082
     8
*)
paulson@10751
     9
huffman@22631
    10
header {* Sequences and Convergence *}
huffman@17439
    11
nipkow@15131
    12
theory SEQ
huffman@31349
    13
imports Limits
nipkow@15131
    14
begin
paulson@10751
    15
wenzelm@19765
    16
definition
huffman@22608
    17
  Zseq :: "[nat \<Rightarrow> 'a::real_normed_vector] \<Rightarrow> bool" where
huffman@22608
    18
    --{*Standard definition of sequence converging to zero*}
haftmann@28562
    19
  [code del]: "Zseq X = (\<forall>r>0. \<exists>no. \<forall>n\<ge>no. norm (X n) < r)"
huffman@22608
    20
huffman@22608
    21
definition
huffman@31336
    22
  LIMSEQ :: "[nat \<Rightarrow> 'a::metric_space, 'a] \<Rightarrow> bool"
wenzelm@21404
    23
    ("((_)/ ----> (_))" [60, 60] 60) where
paulson@15082
    24
    --{*Standard definition of convergence of sequence*}
huffman@31336
    25
  [code del]: "X ----> L = (\<forall>r>0. \<exists>no. \<forall>n\<ge>no. dist (X n) L < r)"
paulson@10751
    26
wenzelm@21404
    27
definition
huffman@31404
    28
  lim :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> 'a" where
paulson@15082
    29
    --{*Standard definition of limit using choice operator*}
huffman@20682
    30
  "lim X = (THE L. X ----> L)"
paulson@10751
    31
wenzelm@21404
    32
definition
huffman@31336
    33
  convergent :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool" where
paulson@15082
    34
    --{*Standard definition of convergence*}
huffman@20682
    35
  "convergent X = (\<exists>L. X ----> L)"
paulson@10751
    36
wenzelm@21404
    37
definition
wenzelm@21404
    38
  Bseq :: "(nat => 'a::real_normed_vector) => bool" where
paulson@15082
    39
    --{*Standard definition for bounded sequence*}
haftmann@28562
    40
  [code del]: "Bseq X = (\<exists>K>0.\<forall>n. norm (X n) \<le> K)"
paulson@10751
    41
wenzelm@21404
    42
definition
wenzelm@21404
    43
  monoseq :: "(nat=>real)=>bool" where
paulson@30730
    44
    --{*Definition of monotonicity. 
paulson@30730
    45
        The use of disjunction here complicates proofs considerably. 
paulson@30730
    46
        One alternative is to add a Boolean argument to indicate the direction. 
paulson@30730
    47
        Another is to develop the notions of increasing and decreasing first.*}
haftmann@28562
    48
  [code del]: "monoseq X = ((\<forall>m. \<forall>n\<ge>m. X m \<le> X n) | (\<forall>m. \<forall>n\<ge>m. X n \<le> X m))"
paulson@10751
    49
wenzelm@21404
    50
definition
paulson@30730
    51
  incseq :: "(nat=>real)=>bool" where
paulson@30730
    52
    --{*Increasing sequence*}
paulson@30730
    53
  [code del]: "incseq X = (\<forall>m. \<forall>n\<ge>m. X m \<le> X n)"
paulson@30730
    54
paulson@30730
    55
definition
paulson@30730
    56
  decseq :: "(nat=>real)=>bool" where
paulson@30730
    57
    --{*Increasing sequence*}
paulson@30730
    58
  [code del]: "decseq X = (\<forall>m. \<forall>n\<ge>m. X n \<le> X m)"
paulson@30730
    59
paulson@30730
    60
definition
wenzelm@21404
    61
  subseq :: "(nat => nat) => bool" where
paulson@15082
    62
    --{*Definition of subsequence*}
haftmann@28562
    63
  [code del]:   "subseq f = (\<forall>m. \<forall>n>m. (f m) < (f n))"
paulson@10751
    64
wenzelm@21404
    65
definition
huffman@31336
    66
  Cauchy :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool" where
paulson@15082
    67
    --{*Standard definition of the Cauchy condition*}
huffman@31336
    68
  [code del]: "Cauchy X = (\<forall>e>0. \<exists>M. \<forall>m \<ge> M. \<forall>n \<ge> M. dist (X m) (X n) < e)"
paulson@10751
    69
paulson@15082
    70
huffman@22608
    71
subsection {* Bounded Sequences *}
huffman@22608
    72
wenzelm@26312
    73
lemma BseqI': assumes K: "\<And>n. norm (X n) \<le> K" shows "Bseq X"
huffman@22608
    74
unfolding Bseq_def
huffman@22608
    75
proof (intro exI conjI allI)
huffman@22608
    76
  show "0 < max K 1" by simp
huffman@22608
    77
next
huffman@22608
    78
  fix n::nat
huffman@22608
    79
  have "norm (X n) \<le> K" by (rule K)
huffman@22608
    80
  thus "norm (X n) \<le> max K 1" by simp
huffman@22608
    81
qed
huffman@22608
    82
huffman@22608
    83
lemma BseqE: "\<lbrakk>Bseq X; \<And>K. \<lbrakk>0 < K; \<forall>n. norm (X n) \<le> K\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
huffman@22608
    84
unfolding Bseq_def by auto
huffman@22608
    85
wenzelm@26312
    86
lemma BseqI2': assumes K: "\<forall>n\<ge>N. norm (X n) \<le> K" shows "Bseq X"
wenzelm@26312
    87
proof (rule BseqI')
huffman@22608
    88
  let ?A = "norm ` X ` {..N}"
huffman@22608
    89
  have 1: "finite ?A" by simp
huffman@22608
    90
  fix n::nat
huffman@22608
    91
  show "norm (X n) \<le> max K (Max ?A)"
huffman@22608
    92
  proof (cases rule: linorder_le_cases)
huffman@22608
    93
    assume "n \<ge> N"
huffman@22608
    94
    hence "norm (X n) \<le> K" using K by simp
huffman@22608
    95
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
    96
  next
huffman@22608
    97
    assume "n \<le> N"
huffman@22608
    98
    hence "norm (X n) \<in> ?A" by simp
haftmann@26757
    99
    with 1 have "norm (X n) \<le> Max ?A" by (rule Max_ge)
huffman@22608
   100
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
   101
  qed
huffman@22608
   102
qed
huffman@22608
   103
huffman@22608
   104
lemma Bseq_ignore_initial_segment: "Bseq X \<Longrightarrow> Bseq (\<lambda>n. X (n + k))"
huffman@22608
   105
unfolding Bseq_def by auto
huffman@22608
   106
huffman@22608
   107
lemma Bseq_offset: "Bseq (\<lambda>n. X (n + k)) \<Longrightarrow> Bseq X"
huffman@22608
   108
apply (erule BseqE)
wenzelm@26312
   109
apply (rule_tac N="k" and K="K" in BseqI2')
huffman@22608
   110
apply clarify
huffman@22608
   111
apply (drule_tac x="n - k" in spec, simp)
huffman@22608
   112
done
huffman@22608
   113
huffman@31355
   114
lemma Bseq_conv_Bfun: "Bseq X \<longleftrightarrow> Bfun X sequentially"
huffman@31355
   115
unfolding Bfun_def eventually_sequentially
huffman@31355
   116
apply (rule iffI)
haftmann@32064
   117
apply (simp add: Bseq_def)
haftmann@32064
   118
apply (auto intro: BseqI2')
huffman@31355
   119
done
huffman@31355
   120
huffman@22608
   121
huffman@22608
   122
subsection {* Sequences That Converge to Zero *}
huffman@22608
   123
huffman@22608
   124
lemma ZseqI:
huffman@22608
   125
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n) < r) \<Longrightarrow> Zseq X"
huffman@22608
   126
unfolding Zseq_def by simp
huffman@22608
   127
huffman@22608
   128
lemma ZseqD:
huffman@22608
   129
  "\<lbrakk>Zseq X; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n) < r"
huffman@22608
   130
unfolding Zseq_def by simp
huffman@22608
   131
huffman@31392
   132
lemma Zseq_conv_Zfun: "Zseq X \<longleftrightarrow> Zfun X sequentially"
huffman@31392
   133
unfolding Zseq_def Zfun_def eventually_sequentially ..
huffman@31392
   134
huffman@22608
   135
lemma Zseq_zero: "Zseq (\<lambda>n. 0)"
huffman@22608
   136
unfolding Zseq_def by simp
huffman@22608
   137
huffman@22608
   138
lemma Zseq_const_iff: "Zseq (\<lambda>n. k) = (k = 0)"
huffman@22608
   139
unfolding Zseq_def by force
huffman@22608
   140
huffman@22608
   141
lemma Zseq_norm_iff: "Zseq (\<lambda>n. norm (X n)) = Zseq (\<lambda>n. X n)"
huffman@22608
   142
unfolding Zseq_def by simp
huffman@22608
   143
huffman@22608
   144
lemma Zseq_imp_Zseq:
huffman@22608
   145
  assumes X: "Zseq X"
huffman@22608
   146
  assumes Y: "\<And>n. norm (Y n) \<le> norm (X n) * K"
huffman@22608
   147
  shows "Zseq (\<lambda>n. Y n)"
huffman@31355
   148
using X Y Zfun_imp_Zfun [of X sequentially Y K]
huffman@31355
   149
unfolding Zseq_conv_Zfun by simp
huffman@22608
   150
huffman@22608
   151
lemma Zseq_le: "\<lbrakk>Zseq Y; \<forall>n. norm (X n) \<le> norm (Y n)\<rbrakk> \<Longrightarrow> Zseq X"
huffman@22608
   152
by (erule_tac K="1" in Zseq_imp_Zseq, simp)
huffman@22608
   153
huffman@22608
   154
lemma Zseq_add:
huffman@31349
   155
  "Zseq X \<Longrightarrow> Zseq Y \<Longrightarrow> Zseq (\<lambda>n. X n + Y n)"
huffman@31349
   156
unfolding Zseq_conv_Zfun by (rule Zfun_add)
huffman@22608
   157
huffman@22608
   158
lemma Zseq_minus: "Zseq X \<Longrightarrow> Zseq (\<lambda>n. - X n)"
huffman@22608
   159
unfolding Zseq_def by simp
huffman@22608
   160
huffman@22608
   161
lemma Zseq_diff: "\<lbrakk>Zseq X; Zseq Y\<rbrakk> \<Longrightarrow> Zseq (\<lambda>n. X n - Y n)"
huffman@22608
   162
by (simp only: diff_minus Zseq_add Zseq_minus)
huffman@22608
   163
huffman@22608
   164
lemma (in bounded_linear) Zseq:
huffman@31349
   165
  "Zseq X \<Longrightarrow> Zseq (\<lambda>n. f (X n))"
huffman@31349
   166
unfolding Zseq_conv_Zfun by (rule Zfun)
huffman@22608
   167
huffman@23127
   168
lemma (in bounded_bilinear) Zseq:
huffman@31349
   169
  "Zseq X \<Longrightarrow> Zseq Y \<Longrightarrow> Zseq (\<lambda>n. X n ** Y n)"
huffman@31349
   170
unfolding Zseq_conv_Zfun by (rule Zfun)
huffman@22608
   171
huffman@22608
   172
lemma (in bounded_bilinear) Zseq_prod_Bseq:
huffman@31355
   173
  "Zseq X \<Longrightarrow> Bseq Y \<Longrightarrow> Zseq (\<lambda>n. X n ** Y n)"
huffman@31355
   174
unfolding Zseq_conv_Zfun Bseq_conv_Bfun
huffman@31355
   175
by (rule Zfun_prod_Bfun)
huffman@22608
   176
huffman@22608
   177
lemma (in bounded_bilinear) Bseq_prod_Zseq:
huffman@31355
   178
  "Bseq X \<Longrightarrow> Zseq Y \<Longrightarrow> Zseq (\<lambda>n. X n ** Y n)"
huffman@31355
   179
unfolding Zseq_conv_Zfun Bseq_conv_Bfun
huffman@31355
   180
by (rule Bfun_prod_Zfun)
huffman@22608
   181
huffman@23127
   182
lemma (in bounded_bilinear) Zseq_left:
huffman@22608
   183
  "Zseq X \<Longrightarrow> Zseq (\<lambda>n. X n ** a)"
huffman@22608
   184
by (rule bounded_linear_left [THEN bounded_linear.Zseq])
huffman@22608
   185
huffman@23127
   186
lemma (in bounded_bilinear) Zseq_right:
huffman@22608
   187
  "Zseq X \<Longrightarrow> Zseq (\<lambda>n. a ** X n)"
huffman@22608
   188
by (rule bounded_linear_right [THEN bounded_linear.Zseq])
huffman@22608
   189
huffman@23127
   190
lemmas Zseq_mult = mult.Zseq
huffman@23127
   191
lemmas Zseq_mult_right = mult.Zseq_right
huffman@23127
   192
lemmas Zseq_mult_left = mult.Zseq_left
huffman@22608
   193
huffman@22608
   194
huffman@20696
   195
subsection {* Limits of Sequences *}
huffman@20696
   196
paulson@32877
   197
lemma [trans]: "X=Y ==> Y ----> z ==> X ----> z"
paulson@32877
   198
  by simp
paulson@32877
   199
huffman@31487
   200
lemma LIMSEQ_conv_tendsto: "(X ----> L) \<longleftrightarrow> (X ---> L) sequentially"
huffman@31488
   201
unfolding LIMSEQ_def tendsto_iff eventually_sequentially ..
huffman@31392
   202
paulson@15082
   203
lemma LIMSEQ_iff:
huffman@31336
   204
  fixes L :: "'a::real_normed_vector"
huffman@31336
   205
  shows "(X ----> L) = (\<forall>r>0. \<exists>no. \<forall>n \<ge> no. norm (X n - L) < r)"
huffman@31336
   206
unfolding LIMSEQ_def dist_norm ..
huffman@22608
   207
paulson@33271
   208
lemma LIMSEQ_iff_nz: "X ----> L = (\<forall>r>0. \<exists>no>0. \<forall>n\<ge>no. dist (X n) L < r)"
paulson@33271
   209
  by (auto simp add: LIMSEQ_def) (metis Suc_leD zero_less_Suc)  
paulson@33271
   210
huffman@22608
   211
lemma LIMSEQ_Zseq_iff: "((\<lambda>n. X n) ----> L) = Zseq (\<lambda>n. X n - L)"
huffman@31336
   212
by (simp only: LIMSEQ_iff Zseq_def)
huffman@31336
   213
huffman@31336
   214
lemma metric_LIMSEQ_I:
huffman@31336
   215
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. dist (X n) L < r) \<Longrightarrow> X ----> L"
huffman@31336
   216
by (simp add: LIMSEQ_def)
huffman@31336
   217
huffman@31336
   218
lemma metric_LIMSEQ_D:
huffman@31336
   219
  "\<lbrakk>X ----> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. dist (X n) L < r"
huffman@31336
   220
by (simp add: LIMSEQ_def)
paulson@15082
   221
huffman@20751
   222
lemma LIMSEQ_I:
huffman@31336
   223
  fixes L :: "'a::real_normed_vector"
huffman@31336
   224
  shows "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r) \<Longrightarrow> X ----> L"
huffman@31336
   225
by (simp add: LIMSEQ_iff)
huffman@20751
   226
huffman@20751
   227
lemma LIMSEQ_D:
huffman@31336
   228
  fixes L :: "'a::real_normed_vector"
huffman@31336
   229
  shows "\<lbrakk>X ----> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r"
huffman@31336
   230
by (simp add: LIMSEQ_iff)
huffman@20751
   231
huffman@22608
   232
lemma LIMSEQ_const: "(\<lambda>n. k) ----> k"
huffman@20696
   233
by (simp add: LIMSEQ_def)
huffman@20696
   234
huffman@31336
   235
lemma LIMSEQ_const_iff: "(\<lambda>n. k) ----> l \<longleftrightarrow> k = l"
huffman@31336
   236
apply (safe intro!: LIMSEQ_const)
huffman@31336
   237
apply (rule ccontr)
huffman@31336
   238
apply (drule_tac r="dist k l" in metric_LIMSEQ_D)
huffman@31336
   239
apply (simp add: zero_less_dist_iff)
huffman@31336
   240
apply auto
huffman@31336
   241
done
huffman@22608
   242
huffman@31336
   243
lemma LIMSEQ_norm:
huffman@31336
   244
  fixes a :: "'a::real_normed_vector"
huffman@31336
   245
  shows "X ----> a \<Longrightarrow> (\<lambda>n. norm (X n)) ----> norm a"
huffman@31349
   246
unfolding LIMSEQ_conv_tendsto by (rule tendsto_norm)
huffman@20696
   247
huffman@22615
   248
lemma LIMSEQ_ignore_initial_segment:
huffman@22615
   249
  "f ----> a \<Longrightarrow> (\<lambda>n. f (n + k)) ----> a"
huffman@31336
   250
apply (rule metric_LIMSEQ_I)
huffman@31336
   251
apply (drule (1) metric_LIMSEQ_D)
huffman@22615
   252
apply (erule exE, rename_tac N)
huffman@22615
   253
apply (rule_tac x=N in exI)
huffman@22615
   254
apply simp
huffman@22615
   255
done
huffman@20696
   256
huffman@22615
   257
lemma LIMSEQ_offset:
huffman@22615
   258
  "(\<lambda>n. f (n + k)) ----> a \<Longrightarrow> f ----> a"
huffman@31336
   259
apply (rule metric_LIMSEQ_I)
huffman@31336
   260
apply (drule (1) metric_LIMSEQ_D)
huffman@22615
   261
apply (erule exE, rename_tac N)
huffman@22615
   262
apply (rule_tac x="N + k" in exI)
huffman@22615
   263
apply clarify
huffman@22615
   264
apply (drule_tac x="n - k" in spec)
huffman@22615
   265
apply (simp add: le_diff_conv2)
huffman@20696
   266
done
huffman@20696
   267
huffman@22615
   268
lemma LIMSEQ_Suc: "f ----> l \<Longrightarrow> (\<lambda>n. f (Suc n)) ----> l"
huffman@30082
   269
by (drule_tac k="Suc 0" in LIMSEQ_ignore_initial_segment, simp)
huffman@22615
   270
huffman@22615
   271
lemma LIMSEQ_imp_Suc: "(\<lambda>n. f (Suc n)) ----> l \<Longrightarrow> f ----> l"
huffman@30082
   272
by (rule_tac k="Suc 0" in LIMSEQ_offset, simp)
huffman@22615
   273
huffman@22615
   274
lemma LIMSEQ_Suc_iff: "(\<lambda>n. f (Suc n)) ----> l = f ----> l"
huffman@22615
   275
by (blast intro: LIMSEQ_imp_Suc LIMSEQ_Suc)
huffman@22615
   276
hoelzl@29803
   277
lemma LIMSEQ_linear: "\<lbrakk> X ----> x ; l > 0 \<rbrakk> \<Longrightarrow> (\<lambda> n. X (n * l)) ----> x"
hoelzl@29803
   278
  unfolding LIMSEQ_def
hoelzl@29803
   279
  by (metis div_le_dividend div_mult_self1_is_m le_trans nat_mult_commute)
hoelzl@29803
   280
huffman@31336
   281
lemma LIMSEQ_add:
huffman@31336
   282
  fixes a b :: "'a::real_normed_vector"
huffman@31336
   283
  shows "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n + Y n) ----> a + b"
huffman@31349
   284
unfolding LIMSEQ_conv_tendsto by (rule tendsto_add)
huffman@22608
   285
huffman@31336
   286
lemma LIMSEQ_minus:
huffman@31336
   287
  fixes a :: "'a::real_normed_vector"
huffman@31336
   288
  shows "X ----> a \<Longrightarrow> (\<lambda>n. - X n) ----> - a"
huffman@31349
   289
unfolding LIMSEQ_conv_tendsto by (rule tendsto_minus)
huffman@22608
   290
huffman@31336
   291
lemma LIMSEQ_minus_cancel:
huffman@31336
   292
  fixes a :: "'a::real_normed_vector"
huffman@31336
   293
  shows "(\<lambda>n. - X n) ----> - a \<Longrightarrow> X ----> a"
huffman@22608
   294
by (drule LIMSEQ_minus, simp)
huffman@22608
   295
huffman@31336
   296
lemma LIMSEQ_diff:
huffman@31336
   297
  fixes a b :: "'a::real_normed_vector"
huffman@31336
   298
  shows "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n - Y n) ----> a - b"
huffman@31349
   299
unfolding LIMSEQ_conv_tendsto by (rule tendsto_diff)
huffman@22608
   300
huffman@22608
   301
lemma LIMSEQ_unique: "\<lbrakk>X ----> a; X ----> b\<rbrakk> \<Longrightarrow> a = b"
huffman@31336
   302
apply (rule ccontr)
huffman@31336
   303
apply (drule_tac r="dist a b / 2" in metric_LIMSEQ_D, simp add: zero_less_dist_iff)
huffman@31336
   304
apply (drule_tac r="dist a b / 2" in metric_LIMSEQ_D, simp add: zero_less_dist_iff)
huffman@31336
   305
apply (clarify, rename_tac M N)
huffman@31336
   306
apply (subgoal_tac "dist a b < dist a b / 2 + dist a b / 2", simp)
huffman@31336
   307
apply (subgoal_tac "dist a b \<le> dist (X (max M N)) a + dist (X (max M N)) b")
huffman@31336
   308
apply (erule le_less_trans, rule add_strict_mono, simp, simp)
huffman@31336
   309
apply (subst dist_commute, rule dist_triangle)
huffman@31336
   310
done
huffman@22608
   311
huffman@22608
   312
lemma (in bounded_linear) LIMSEQ:
huffman@22608
   313
  "X ----> a \<Longrightarrow> (\<lambda>n. f (X n)) ----> f a"
huffman@31349
   314
unfolding LIMSEQ_conv_tendsto by (rule tendsto)
huffman@22608
   315
huffman@22608
   316
lemma (in bounded_bilinear) LIMSEQ:
huffman@22608
   317
  "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n ** Y n) ----> a ** b"
huffman@31349
   318
unfolding LIMSEQ_conv_tendsto by (rule tendsto)
huffman@22608
   319
huffman@22608
   320
lemma LIMSEQ_mult:
huffman@22608
   321
  fixes a b :: "'a::real_normed_algebra"
huffman@22608
   322
  shows "[| X ----> a; Y ----> b |] ==> (%n. X n * Y n) ----> a * b"
huffman@23127
   323
by (rule mult.LIMSEQ)
huffman@22608
   324
paulson@32877
   325
lemma increasing_LIMSEQ:
paulson@32877
   326
  fixes f :: "nat \<Rightarrow> real"
paulson@32877
   327
  assumes inc: "!!n. f n \<le> f (Suc n)"
paulson@32877
   328
      and bdd: "!!n. f n \<le> l"
paulson@32877
   329
      and en: "!!e. 0 < e \<Longrightarrow> \<exists>n. l \<le> f n + e"
paulson@32877
   330
  shows "f ----> l"
paulson@32877
   331
proof (auto simp add: LIMSEQ_def)
paulson@32877
   332
  fix e :: real
paulson@32877
   333
  assume e: "0 < e"
paulson@32877
   334
  then obtain N where "l \<le> f N + e/2"
paulson@32877
   335
    by (metis half_gt_zero e en that)
paulson@32877
   336
  hence N: "l < f N + e" using e
paulson@32877
   337
    by simp
paulson@32877
   338
  { fix k
paulson@32877
   339
    have [simp]: "!!n. \<bar>f n - l\<bar> = l - f n"
paulson@32877
   340
      by (simp add: bdd) 
paulson@32877
   341
    have "\<bar>f (N+k) - l\<bar> < e"
paulson@32877
   342
    proof (induct k)
paulson@32877
   343
      case 0 show ?case using N
wenzelm@32960
   344
        by simp   
paulson@32877
   345
    next
paulson@32877
   346
      case (Suc k) thus ?case using N inc [of "N+k"]
wenzelm@32960
   347
        by simp
paulson@32877
   348
    qed 
paulson@32877
   349
  } note 1 = this
paulson@32877
   350
  { fix n
paulson@32877
   351
    have "N \<le> n \<Longrightarrow> \<bar>f n - l\<bar> < e" using 1 [of "n-N"]
paulson@32877
   352
      by simp 
paulson@32877
   353
  } note [intro] = this
paulson@32877
   354
  show " \<exists>no. \<forall>n\<ge>no. dist (f n) l < e"
paulson@32877
   355
    by (auto simp add: dist_real_def) 
paulson@32877
   356
  qed
paulson@32877
   357
huffman@22608
   358
lemma Bseq_inverse_lemma:
huffman@22608
   359
  fixes x :: "'a::real_normed_div_algebra"
huffman@22608
   360
  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
huffman@22608
   361
apply (subst nonzero_norm_inverse, clarsimp)
huffman@22608
   362
apply (erule (1) le_imp_inverse_le)
huffman@22608
   363
done
huffman@22608
   364
huffman@22608
   365
lemma Bseq_inverse:
huffman@22608
   366
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   367
  shows "\<lbrakk>X ----> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))"
huffman@31355
   368
unfolding LIMSEQ_conv_tendsto Bseq_conv_Bfun
huffman@31355
   369
by (rule Bfun_inverse)
huffman@22608
   370
huffman@22608
   371
lemma LIMSEQ_inverse:
huffman@22608
   372
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   373
  shows "\<lbrakk>X ----> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> inverse a"
huffman@31355
   374
unfolding LIMSEQ_conv_tendsto
huffman@31355
   375
by (rule tendsto_inverse)
huffman@22608
   376
huffman@22608
   377
lemma LIMSEQ_divide:
huffman@22608
   378
  fixes a b :: "'a::real_normed_field"
huffman@22608
   379
  shows "\<lbrakk>X ----> a; Y ----> b; b \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>n. X n / Y n) ----> a / b"
huffman@22608
   380
by (simp add: LIMSEQ_mult LIMSEQ_inverse divide_inverse)
huffman@22608
   381
huffman@22608
   382
lemma LIMSEQ_pow:
haftmann@31017
   383
  fixes a :: "'a::{power, real_normed_algebra}"
huffman@22608
   384
  shows "X ----> a \<Longrightarrow> (\<lambda>n. (X n) ^ m) ----> a ^ m"
huffman@30273
   385
by (induct m) (simp_all add: LIMSEQ_const LIMSEQ_mult)
huffman@22608
   386
huffman@22608
   387
lemma LIMSEQ_setsum:
huffman@31336
   388
  fixes L :: "'a \<Rightarrow> 'b::real_normed_vector"
huffman@22608
   389
  assumes n: "\<And>n. n \<in> S \<Longrightarrow> X n ----> L n"
huffman@22608
   390
  shows "(\<lambda>m. \<Sum>n\<in>S. X n m) ----> (\<Sum>n\<in>S. L n)"
huffman@31588
   391
using n unfolding LIMSEQ_conv_tendsto by (rule tendsto_setsum)
huffman@22608
   392
huffman@22608
   393
lemma LIMSEQ_setprod:
huffman@22608
   394
  fixes L :: "'a \<Rightarrow> 'b::{real_normed_algebra,comm_ring_1}"
huffman@22608
   395
  assumes n: "\<And>n. n \<in> S \<Longrightarrow> X n ----> L n"
huffman@22608
   396
  shows "(\<lambda>m. \<Prod>n\<in>S. X n m) ----> (\<Prod>n\<in>S. L n)"
huffman@22608
   397
proof (cases "finite S")
huffman@22608
   398
  case True
huffman@22608
   399
  thus ?thesis using n
huffman@22608
   400
  proof (induct)
huffman@22608
   401
    case empty
huffman@22608
   402
    show ?case
huffman@22608
   403
      by (simp add: LIMSEQ_const)
huffman@22608
   404
  next
huffman@22608
   405
    case insert
huffman@22608
   406
    thus ?case
huffman@22608
   407
      by (simp add: LIMSEQ_mult)
huffman@22608
   408
  qed
huffman@22608
   409
next
huffman@22608
   410
  case False
huffman@22608
   411
  thus ?thesis
huffman@22608
   412
    by (simp add: setprod_def LIMSEQ_const)
huffman@22608
   413
qed
huffman@22608
   414
huffman@31336
   415
lemma LIMSEQ_add_const:
huffman@31336
   416
  fixes a :: "'a::real_normed_vector"
huffman@31336
   417
  shows "f ----> a ==> (%n.(f n + b)) ----> a + b"
huffman@22614
   418
by (simp add: LIMSEQ_add LIMSEQ_const)
huffman@22614
   419
huffman@22614
   420
(* FIXME: delete *)
huffman@22614
   421
lemma LIMSEQ_add_minus:
huffman@31336
   422
  fixes a b :: "'a::real_normed_vector"
huffman@31336
   423
  shows "[| X ----> a; Y ----> b |] ==> (%n. X n + -Y n) ----> a + -b"
huffman@22614
   424
by (simp only: LIMSEQ_add LIMSEQ_minus)
huffman@22614
   425
huffman@31336
   426
lemma LIMSEQ_diff_const:
huffman@31336
   427
  fixes a b :: "'a::real_normed_vector"
huffman@31336
   428
  shows "f ----> a ==> (%n.(f n  - b)) ----> a - b"
huffman@22614
   429
by (simp add: LIMSEQ_diff LIMSEQ_const)
huffman@22614
   430
huffman@31336
   431
lemma LIMSEQ_diff_approach_zero:
huffman@31336
   432
  fixes L :: "'a::real_normed_vector"
huffman@31336
   433
  shows "g ----> L ==> (%x. f x - g x) ----> 0 ==> f ----> L"
huffman@31336
   434
by (drule (1) LIMSEQ_add, simp)
huffman@22614
   435
huffman@31336
   436
lemma LIMSEQ_diff_approach_zero2:
huffman@31336
   437
  fixes L :: "'a::real_normed_vector"
hoelzl@35292
   438
  shows "f ----> L ==> (%x. f x - g x) ----> 0 ==> g ----> L"
huffman@31336
   439
by (drule (1) LIMSEQ_diff, simp)
huffman@22614
   440
huffman@22614
   441
text{*A sequence tends to zero iff its abs does*}
huffman@31336
   442
lemma LIMSEQ_norm_zero:
huffman@31336
   443
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   444
  shows "((\<lambda>n. norm (X n)) ----> 0) \<longleftrightarrow> (X ----> 0)"
huffman@31336
   445
by (simp add: LIMSEQ_iff)
huffman@22614
   446
huffman@22614
   447
lemma LIMSEQ_rabs_zero: "((%n. \<bar>f n\<bar>) ----> 0) = (f ----> (0::real))"
huffman@31336
   448
by (simp add: LIMSEQ_iff)
huffman@22614
   449
huffman@22614
   450
lemma LIMSEQ_imp_rabs: "f ----> (l::real) ==> (%n. \<bar>f n\<bar>) ----> \<bar>l\<bar>"
huffman@22614
   451
by (drule LIMSEQ_norm, simp)
huffman@22614
   452
huffman@22614
   453
text{*An unbounded sequence's inverse tends to 0*}
huffman@22614
   454
huffman@22614
   455
lemma LIMSEQ_inverse_zero:
huffman@22974
   456
  "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> 0"
huffman@22974
   457
apply (rule LIMSEQ_I)
huffman@22974
   458
apply (drule_tac x="inverse r" in spec, safe)
huffman@22974
   459
apply (rule_tac x="N" in exI, safe)
huffman@22974
   460
apply (drule_tac x="n" in spec, safe)
huffman@22614
   461
apply (frule positive_imp_inverse_positive)
huffman@22974
   462
apply (frule (1) less_imp_inverse_less)
huffman@22974
   463
apply (subgoal_tac "0 < X n", simp)
huffman@22974
   464
apply (erule (1) order_less_trans)
huffman@22614
   465
done
huffman@22614
   466
huffman@22614
   467
text{*The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity*}
huffman@22614
   468
huffman@22614
   469
lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) ----> 0"
huffman@22614
   470
apply (rule LIMSEQ_inverse_zero, safe)
huffman@22974
   471
apply (cut_tac x = r in reals_Archimedean2)
huffman@22614
   472
apply (safe, rule_tac x = n in exI)
huffman@22614
   473
apply (auto simp add: real_of_nat_Suc)
huffman@22614
   474
done
huffman@22614
   475
huffman@22614
   476
text{*The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to
huffman@22614
   477
infinity is now easily proved*}
huffman@22614
   478
huffman@22614
   479
lemma LIMSEQ_inverse_real_of_nat_add:
huffman@22614
   480
     "(%n. r + inverse(real(Suc n))) ----> r"
huffman@22614
   481
by (cut_tac LIMSEQ_add [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat], auto)
huffman@22614
   482
huffman@22614
   483
lemma LIMSEQ_inverse_real_of_nat_add_minus:
huffman@22614
   484
     "(%n. r + -inverse(real(Suc n))) ----> r"
huffman@22614
   485
by (cut_tac LIMSEQ_add_minus [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat], auto)
huffman@22614
   486
huffman@22614
   487
lemma LIMSEQ_inverse_real_of_nat_add_minus_mult:
huffman@22614
   488
     "(%n. r*( 1 + -inverse(real(Suc n)))) ----> r"
huffman@22614
   489
by (cut_tac b=1 in
huffman@22614
   490
        LIMSEQ_mult [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat_add_minus], auto)
huffman@22614
   491
huffman@22615
   492
lemma LIMSEQ_le_const:
huffman@22615
   493
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. a \<le> X n\<rbrakk> \<Longrightarrow> a \<le> x"
huffman@22615
   494
apply (rule ccontr, simp only: linorder_not_le)
huffman@22615
   495
apply (drule_tac r="a - x" in LIMSEQ_D, simp)
huffman@22615
   496
apply clarsimp
huffman@22615
   497
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI1)
huffman@22615
   498
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI2)
huffman@22615
   499
apply simp
huffman@22615
   500
done
huffman@22615
   501
huffman@22615
   502
lemma LIMSEQ_le_const2:
huffman@22615
   503
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. X n \<le> a\<rbrakk> \<Longrightarrow> x \<le> a"
huffman@22615
   504
apply (subgoal_tac "- a \<le> - x", simp)
huffman@22615
   505
apply (rule LIMSEQ_le_const)
huffman@22615
   506
apply (erule LIMSEQ_minus)
huffman@22615
   507
apply simp
huffman@22615
   508
done
huffman@22615
   509
huffman@22615
   510
lemma LIMSEQ_le:
huffman@22615
   511
  "\<lbrakk>X ----> x; Y ----> y; \<exists>N. \<forall>n\<ge>N. X n \<le> Y n\<rbrakk> \<Longrightarrow> x \<le> (y::real)"
huffman@22615
   512
apply (subgoal_tac "0 \<le> y - x", simp)
huffman@22615
   513
apply (rule LIMSEQ_le_const)
huffman@22615
   514
apply (erule (1) LIMSEQ_diff)
huffman@22615
   515
apply (simp add: le_diff_eq)
huffman@22615
   516
done
huffman@22615
   517
paulson@15082
   518
huffman@20696
   519
subsection {* Convergence *}
paulson@15082
   520
paulson@15082
   521
lemma limI: "X ----> L ==> lim X = L"
paulson@15082
   522
apply (simp add: lim_def)
paulson@15082
   523
apply (blast intro: LIMSEQ_unique)
paulson@15082
   524
done
paulson@15082
   525
paulson@15082
   526
lemma convergentD: "convergent X ==> \<exists>L. (X ----> L)"
paulson@15082
   527
by (simp add: convergent_def)
paulson@15082
   528
paulson@15082
   529
lemma convergentI: "(X ----> L) ==> convergent X"
paulson@15082
   530
by (auto simp add: convergent_def)
paulson@15082
   531
paulson@15082
   532
lemma convergent_LIMSEQ_iff: "convergent X = (X ----> lim X)"
huffman@20682
   533
by (auto intro: theI LIMSEQ_unique simp add: convergent_def lim_def)
paulson@15082
   534
huffman@36625
   535
lemma convergent_const: "convergent (\<lambda>n. c)"
huffman@36625
   536
by (rule convergentI, rule LIMSEQ_const)
huffman@36625
   537
huffman@36625
   538
lemma convergent_add:
huffman@36625
   539
  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@36625
   540
  assumes "convergent (\<lambda>n. X n)"
huffman@36625
   541
  assumes "convergent (\<lambda>n. Y n)"
huffman@36625
   542
  shows "convergent (\<lambda>n. X n + Y n)"
huffman@36625
   543
using assms unfolding convergent_def by (fast intro: LIMSEQ_add)
huffman@36625
   544
huffman@36625
   545
lemma convergent_setsum:
huffman@36625
   546
  fixes X :: "'a \<Rightarrow> nat \<Rightarrow> 'b::real_normed_vector"
hoelzl@36647
   547
  assumes "\<And>i. i \<in> A \<Longrightarrow> convergent (\<lambda>n. X i n)"
huffman@36625
   548
  shows "convergent (\<lambda>n. \<Sum>i\<in>A. X i n)"
hoelzl@36647
   549
proof (cases "finite A")
hoelzl@36647
   550
  case True with assms show ?thesis
hoelzl@36647
   551
    by (induct A set: finite) (simp_all add: convergent_const convergent_add)
hoelzl@36647
   552
qed (simp add: convergent_const)
huffman@36625
   553
huffman@36625
   554
lemma (in bounded_linear) convergent:
huffman@36625
   555
  assumes "convergent (\<lambda>n. X n)"
huffman@36625
   556
  shows "convergent (\<lambda>n. f (X n))"
huffman@36625
   557
using assms unfolding convergent_def by (fast intro: LIMSEQ)
huffman@36625
   558
huffman@36625
   559
lemma (in bounded_bilinear) convergent:
huffman@36625
   560
  assumes "convergent (\<lambda>n. X n)" and "convergent (\<lambda>n. Y n)"
huffman@36625
   561
  shows "convergent (\<lambda>n. X n ** Y n)"
huffman@36625
   562
using assms unfolding convergent_def by (fast intro: LIMSEQ)
huffman@36625
   563
huffman@31336
   564
lemma convergent_minus_iff:
huffman@31336
   565
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   566
  shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
huffman@20696
   567
apply (simp add: convergent_def)
huffman@20696
   568
apply (auto dest: LIMSEQ_minus)
huffman@20696
   569
apply (drule LIMSEQ_minus, auto)
huffman@20696
   570
done
huffman@20696
   571
paulson@32707
   572
lemma lim_le:
paulson@32707
   573
  fixes x :: real
paulson@32707
   574
  assumes f: "convergent f" and fn_le: "!!n. f n \<le> x"
paulson@32707
   575
  shows "lim f \<le> x"
paulson@32707
   576
proof (rule classical)
paulson@32707
   577
  assume "\<not> lim f \<le> x"
paulson@32707
   578
  hence 0: "0 < lim f - x" by arith
paulson@32707
   579
  have 1: "f----> lim f"
paulson@32707
   580
    by (metis convergent_LIMSEQ_iff f) 
paulson@32707
   581
  thus ?thesis
paulson@32707
   582
    proof (simp add: LIMSEQ_iff)
paulson@32707
   583
      assume "\<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < r"
paulson@32707
   584
      hence "\<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   585
        by (metis 0)
paulson@32707
   586
      from this obtain no where "\<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   587
        by blast
paulson@32707
   588
      thus "lim f \<le> x"
wenzelm@32960
   589
        by (metis add_cancel_end add_minus_cancel diff_def linorder_linear 
paulson@32707
   590
                  linorder_not_le minus_diff_eq abs_diff_less_iff fn_le) 
paulson@32707
   591
    qed
paulson@32707
   592
qed
paulson@32707
   593
chaieb@30196
   594
text{* Given a binary function @{text "f:: nat \<Rightarrow> 'a \<Rightarrow> 'a"}, its values are uniquely determined by a function g *}
huffman@20696
   595
chaieb@30196
   596
lemma nat_function_unique: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))"
chaieb@30196
   597
  unfolding Ex1_def
chaieb@30196
   598
  apply (rule_tac x="nat_rec e f" in exI)
chaieb@30196
   599
  apply (rule conjI)+
chaieb@30196
   600
apply (rule def_nat_rec_0, simp)
chaieb@30196
   601
apply (rule allI, rule def_nat_rec_Suc, simp)
chaieb@30196
   602
apply (rule allI, rule impI, rule ext)
chaieb@30196
   603
apply (erule conjE)
chaieb@30196
   604
apply (induct_tac x)
huffman@35216
   605
apply simp
chaieb@30196
   606
apply (erule_tac x="n" in allE)
chaieb@30196
   607
apply (simp)
chaieb@30196
   608
done
huffman@20696
   609
paulson@15082
   610
text{*Subsequence (alternative definition, (e.g. Hoskins)*}
paulson@15082
   611
paulson@15082
   612
lemma subseq_Suc_iff: "subseq f = (\<forall>n. (f n) < (f (Suc n)))"
paulson@15082
   613
apply (simp add: subseq_def)
paulson@15082
   614
apply (auto dest!: less_imp_Suc_add)
paulson@15082
   615
apply (induct_tac k)
paulson@15082
   616
apply (auto intro: less_trans)
paulson@15082
   617
done
paulson@15082
   618
paulson@15082
   619
lemma monoseq_Suc:
paulson@15082
   620
   "monoseq X = ((\<forall>n. X n \<le> X (Suc n))
paulson@15082
   621
                 | (\<forall>n. X (Suc n) \<le> X n))"
paulson@15082
   622
apply (simp add: monoseq_def)
paulson@15082
   623
apply (auto dest!: le_imp_less_or_eq)
paulson@15082
   624
apply (auto intro!: lessI [THEN less_imp_le] dest!: less_imp_Suc_add)
paulson@15082
   625
apply (induct_tac "ka")
paulson@15082
   626
apply (auto intro: order_trans)
wenzelm@18585
   627
apply (erule contrapos_np)
paulson@15082
   628
apply (induct_tac "k")
paulson@15082
   629
apply (auto intro: order_trans)
paulson@15082
   630
done
paulson@15082
   631
nipkow@15360
   632
lemma monoI1: "\<forall>m. \<forall> n \<ge> m. X m \<le> X n ==> monoseq X"
paulson@15082
   633
by (simp add: monoseq_def)
paulson@15082
   634
nipkow@15360
   635
lemma monoI2: "\<forall>m. \<forall> n \<ge> m. X n \<le> X m ==> monoseq X"
paulson@15082
   636
by (simp add: monoseq_def)
paulson@15082
   637
paulson@15082
   638
lemma mono_SucI1: "\<forall>n. X n \<le> X (Suc n) ==> monoseq X"
paulson@15082
   639
by (simp add: monoseq_Suc)
paulson@15082
   640
paulson@15082
   641
lemma mono_SucI2: "\<forall>n. X (Suc n) \<le> X n ==> monoseq X"
paulson@15082
   642
by (simp add: monoseq_Suc)
paulson@15082
   643
hoelzl@29803
   644
lemma monoseq_minus: assumes "monoseq a"
hoelzl@29803
   645
  shows "monoseq (\<lambda> n. - a n)"
hoelzl@29803
   646
proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@29803
   647
  case True
hoelzl@29803
   648
  hence "\<forall> m. \<forall> n \<ge> m. - a n \<le> - a m" by auto
hoelzl@29803
   649
  thus ?thesis by (rule monoI2)
hoelzl@29803
   650
next
hoelzl@29803
   651
  case False
hoelzl@29803
   652
  hence "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" using `monoseq a`[unfolded monoseq_def] by auto
hoelzl@29803
   653
  thus ?thesis by (rule monoI1)
hoelzl@29803
   654
qed
hoelzl@29803
   655
hoelzl@29803
   656
lemma monoseq_le: assumes "monoseq a" and "a ----> x"
hoelzl@29803
   657
  shows "((\<forall> n. a n \<le> x) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)) \<or> 
hoelzl@29803
   658
         ((\<forall> n. x \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m))"
hoelzl@29803
   659
proof -
hoelzl@29803
   660
  { fix x n fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   661
    assume "a ----> x" and "\<forall> m. \<forall> n \<ge> m. a m \<le> a n"
hoelzl@29803
   662
    hence monotone: "\<And> m n. m \<le> n \<Longrightarrow> a m \<le> a n" by auto
hoelzl@29803
   663
    have "a n \<le> x"
hoelzl@29803
   664
    proof (rule ccontr)
hoelzl@29803
   665
      assume "\<not> a n \<le> x" hence "x < a n" by auto
hoelzl@29803
   666
      hence "0 < a n - x" by auto
hoelzl@29803
   667
      from `a ----> x`[THEN LIMSEQ_D, OF this]
hoelzl@29803
   668
      obtain no where "\<And>n'. no \<le> n' \<Longrightarrow> norm (a n' - x) < a n - x" by blast
hoelzl@29803
   669
      hence "norm (a (max no n) - x) < a n - x" by auto
hoelzl@29803
   670
      moreover
hoelzl@29803
   671
      { fix n' have "n \<le> n' \<Longrightarrow> x < a n'" using monotone[where m=n and n=n'] and `x < a n` by auto }
hoelzl@29803
   672
      hence "x < a (max no n)" by auto
hoelzl@29803
   673
      ultimately
hoelzl@29803
   674
      have "a (max no n) < a n" by auto
hoelzl@29803
   675
      with monotone[where m=n and n="max no n"]
nipkow@32436
   676
      show False by (auto simp:max_def split:split_if_asm)
hoelzl@29803
   677
    qed
hoelzl@29803
   678
  } note top_down = this
hoelzl@29803
   679
  { fix x n m fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   680
    assume "a ----> x" and "monoseq a" and "a m < x"
hoelzl@29803
   681
    have "a n \<le> x \<and> (\<forall> m. \<forall> n \<ge> m. a m \<le> a n)"
hoelzl@29803
   682
    proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@29803
   683
      case True with top_down and `a ----> x` show ?thesis by auto
hoelzl@29803
   684
    next
hoelzl@29803
   685
      case False with `monoseq a`[unfolded monoseq_def] have "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" by auto
hoelzl@29803
   686
      hence "- a m \<le> - x" using top_down[OF LIMSEQ_minus[OF `a ----> x`]] by blast
hoelzl@29803
   687
      hence False using `a m < x` by auto
hoelzl@29803
   688
      thus ?thesis ..
hoelzl@29803
   689
    qed
hoelzl@29803
   690
  } note when_decided = this
hoelzl@29803
   691
hoelzl@29803
   692
  show ?thesis
hoelzl@29803
   693
  proof (cases "\<exists> m. a m \<noteq> x")
hoelzl@29803
   694
    case True then obtain m where "a m \<noteq> x" by auto
hoelzl@29803
   695
    show ?thesis
hoelzl@29803
   696
    proof (cases "a m < x")
hoelzl@29803
   697
      case True with when_decided[OF `a ----> x` `monoseq a`, where m2=m]
hoelzl@29803
   698
      show ?thesis by blast
hoelzl@29803
   699
    next
hoelzl@29803
   700
      case False hence "- a m < - x" using `a m \<noteq> x` by auto
hoelzl@29803
   701
      with when_decided[OF LIMSEQ_minus[OF `a ----> x`] monoseq_minus[OF `monoseq a`], where m2=m]
hoelzl@29803
   702
      show ?thesis by auto
hoelzl@29803
   703
    qed
hoelzl@29803
   704
  qed auto
hoelzl@29803
   705
qed
hoelzl@29803
   706
chaieb@30196
   707
text{* for any sequence, there is a mootonic subsequence *}
chaieb@30196
   708
lemma seq_monosub: "\<exists>f. subseq f \<and> monoseq (\<lambda> n. (s (f n)))"
chaieb@30196
   709
proof-
chaieb@30196
   710
  {assume H: "\<forall>n. \<exists>p >n. \<forall> m\<ge>p. s m \<le> s p"
chaieb@30196
   711
    let ?P = "\<lambda> p n. p > n \<and> (\<forall>m \<ge> p. s m \<le> s p)"
chaieb@30196
   712
    from nat_function_unique[of "SOME p. ?P p 0" "\<lambda>p n. SOME p. ?P p n"]
chaieb@30196
   713
    obtain f where f: "f 0 = (SOME p. ?P p 0)" "\<forall>n. f (Suc n) = (SOME p. ?P p (f n))" by blast
chaieb@30196
   714
    have "?P (f 0) 0"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p 0"]
chaieb@30196
   715
      using H apply - 
chaieb@30196
   716
      apply (erule allE[where x=0], erule exE, rule_tac x="p" in exI) 
chaieb@30196
   717
      unfolding order_le_less by blast 
chaieb@30196
   718
    hence f0: "f 0 > 0" "\<forall>m \<ge> f 0. s m \<le> s (f 0)" by blast+
chaieb@30196
   719
    {fix n
chaieb@30196
   720
      have "?P (f (Suc n)) (f n)" 
wenzelm@32960
   721
        unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
wenzelm@32960
   722
        using H apply - 
chaieb@30196
   723
      apply (erule allE[where x="f n"], erule exE, rule_tac x="p" in exI) 
chaieb@30196
   724
      unfolding order_le_less by blast 
chaieb@30196
   725
    hence "f (Suc n) > f n" "\<forall>m \<ge> f (Suc n). s m \<le> s (f (Suc n))" by blast+}
chaieb@30196
   726
  note fSuc = this
chaieb@30196
   727
    {fix p q assume pq: "p \<ge> f q"
chaieb@30196
   728
      have "s p \<le> s(f(q))"  using f0(2)[rule_format, of p] pq fSuc
wenzelm@32960
   729
        by (cases q, simp_all) }
chaieb@30196
   730
    note pqth = this
chaieb@30196
   731
    {fix q
chaieb@30196
   732
      have "f (Suc q) > f q" apply (induct q) 
wenzelm@32960
   733
        using f0(1) fSuc(1)[of 0] apply simp by (rule fSuc(1))}
chaieb@30196
   734
    note fss = this
chaieb@30196
   735
    from fss have th1: "subseq f" unfolding subseq_Suc_iff ..
chaieb@30196
   736
    {fix a b 
chaieb@30196
   737
      have "f a \<le> f (a + b)"
chaieb@30196
   738
      proof(induct b)
wenzelm@32960
   739
        case 0 thus ?case by simp
chaieb@30196
   740
      next
wenzelm@32960
   741
        case (Suc b)
wenzelm@32960
   742
        from fSuc(1)[of "a + b"] Suc.hyps show ?case by simp
chaieb@30196
   743
      qed}
chaieb@30196
   744
    note fmon0 = this
chaieb@30196
   745
    have "monoseq (\<lambda>n. s (f n))" 
chaieb@30196
   746
    proof-
chaieb@30196
   747
      {fix n
wenzelm@32960
   748
        have "s (f n) \<ge> s (f (Suc n))" 
wenzelm@32960
   749
        proof(cases n)
wenzelm@32960
   750
          case 0
wenzelm@32960
   751
          assume n0: "n = 0"
wenzelm@32960
   752
          from fSuc(1)[of 0] have th0: "f 0 \<le> f (Suc 0)" by simp
wenzelm@32960
   753
          from f0(2)[rule_format, OF th0] show ?thesis  using n0 by simp
wenzelm@32960
   754
        next
wenzelm@32960
   755
          case (Suc m)
wenzelm@32960
   756
          assume m: "n = Suc m"
wenzelm@32960
   757
          from fSuc(1)[of n] m have th0: "f (Suc m) \<le> f (Suc (Suc m))" by simp
wenzelm@32960
   758
          from m fSuc(2)[rule_format, OF th0] show ?thesis by simp 
wenzelm@32960
   759
        qed}
chaieb@30196
   760
      thus "monoseq (\<lambda>n. s (f n))" unfolding monoseq_Suc by blast 
chaieb@30196
   761
    qed
chaieb@30196
   762
    with th1 have ?thesis by blast}
chaieb@30196
   763
  moreover
chaieb@30196
   764
  {fix N assume N: "\<forall>p >N. \<exists> m\<ge>p. s m > s p"
chaieb@30196
   765
    {fix p assume p: "p \<ge> Suc N" 
chaieb@30196
   766
      hence pN: "p > N" by arith with N obtain m where m: "m \<ge> p" "s m > s p" by blast
chaieb@30196
   767
      have "m \<noteq> p" using m(2) by auto 
chaieb@30196
   768
      with m have "\<exists>m>p. s p < s m" by - (rule exI[where x=m], auto)}
chaieb@30196
   769
    note th0 = this
chaieb@30196
   770
    let ?P = "\<lambda>m x. m > x \<and> s x < s m"
chaieb@30196
   771
    from nat_function_unique[of "SOME x. ?P x (Suc N)" "\<lambda>m x. SOME y. ?P y x"]
chaieb@30196
   772
    obtain f where f: "f 0 = (SOME x. ?P x (Suc N))" 
chaieb@30196
   773
      "\<forall>n. f (Suc n) = (SOME m. ?P m (f n))" by blast
chaieb@30196
   774
    have "?P (f 0) (Suc N)"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p (Suc N)"]
chaieb@30196
   775
      using N apply - 
chaieb@30196
   776
      apply (erule allE[where x="Suc N"], clarsimp)
chaieb@30196
   777
      apply (rule_tac x="m" in exI)
chaieb@30196
   778
      apply auto
chaieb@30196
   779
      apply (subgoal_tac "Suc N \<noteq> m")
chaieb@30196
   780
      apply simp
chaieb@30196
   781
      apply (rule ccontr, simp)
chaieb@30196
   782
      done
chaieb@30196
   783
    hence f0: "f 0 > Suc N" "s (Suc N) < s (f 0)" by blast+
chaieb@30196
   784
    {fix n
chaieb@30196
   785
      have "f n > N \<and> ?P (f (Suc n)) (f n)"
wenzelm@32960
   786
        unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
chaieb@30196
   787
      proof (induct n)
wenzelm@32960
   788
        case 0 thus ?case
wenzelm@32960
   789
          using f0 N apply auto 
wenzelm@32960
   790
          apply (erule allE[where x="f 0"], clarsimp) 
wenzelm@32960
   791
          apply (rule_tac x="m" in exI, simp)
wenzelm@32960
   792
          by (subgoal_tac "f 0 \<noteq> m", auto)
chaieb@30196
   793
      next
wenzelm@32960
   794
        case (Suc n)
wenzelm@32960
   795
        from Suc.hyps have Nfn: "N < f n" by blast
wenzelm@32960
   796
        from Suc.hyps obtain m where m: "m > f n" "s (f n) < s m" by blast
wenzelm@32960
   797
        with Nfn have mN: "m > N" by arith
wenzelm@32960
   798
        note key = Suc.hyps[unfolded some_eq_ex[of "\<lambda>p. ?P p (f n)", symmetric] f(2)[rule_format, of n, symmetric]]
wenzelm@32960
   799
        
wenzelm@32960
   800
        from key have th0: "f (Suc n) > N" by simp
wenzelm@32960
   801
        from N[rule_format, OF th0]
wenzelm@32960
   802
        obtain m' where m': "m' \<ge> f (Suc n)" "s (f (Suc n)) < s m'" by blast
wenzelm@32960
   803
        have "m' \<noteq> f (Suc (n))" apply (rule ccontr) using m'(2) by auto
wenzelm@32960
   804
        hence "m' > f (Suc n)" using m'(1) by simp
wenzelm@32960
   805
        with key m'(2) show ?case by auto
chaieb@30196
   806
      qed}
chaieb@30196
   807
    note fSuc = this
chaieb@30196
   808
    {fix n
chaieb@30196
   809
      have "f n \<ge> Suc N \<and> f(Suc n) > f n \<and> s(f n) < s(f(Suc n))" using fSuc[of n] by auto 
chaieb@30196
   810
      hence "f n \<ge> Suc N" "f(Suc n) > f n" "s(f n) < s(f(Suc n))" by blast+}
chaieb@30196
   811
    note thf = this
chaieb@30196
   812
    have sqf: "subseq f" unfolding subseq_Suc_iff using thf by simp
chaieb@30196
   813
    have "monoseq (\<lambda>n. s (f n))"  unfolding monoseq_Suc using thf
chaieb@30196
   814
      apply -
chaieb@30196
   815
      apply (rule disjI1)
chaieb@30196
   816
      apply auto
chaieb@30196
   817
      apply (rule order_less_imp_le)
chaieb@30196
   818
      apply blast
chaieb@30196
   819
      done
chaieb@30196
   820
    then have ?thesis  using sqf by blast}
chaieb@30196
   821
  ultimately show ?thesis unfolding linorder_not_less[symmetric] by blast
chaieb@30196
   822
qed
chaieb@30196
   823
chaieb@30196
   824
lemma seq_suble: assumes sf: "subseq f" shows "n \<le> f n"
chaieb@30196
   825
proof(induct n)
chaieb@30196
   826
  case 0 thus ?case by simp
chaieb@30196
   827
next
chaieb@30196
   828
  case (Suc n)
chaieb@30196
   829
  from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps
chaieb@30196
   830
  have "n < f (Suc n)" by arith 
chaieb@30196
   831
  thus ?case by arith
chaieb@30196
   832
qed
chaieb@30196
   833
paulson@30730
   834
lemma LIMSEQ_subseq_LIMSEQ:
paulson@30730
   835
  "\<lbrakk> X ----> L; subseq f \<rbrakk> \<Longrightarrow> (X o f) ----> L"
paulson@30730
   836
apply (auto simp add: LIMSEQ_def) 
paulson@30730
   837
apply (drule_tac x=r in spec, clarify)  
paulson@30730
   838
apply (rule_tac x=no in exI, clarify) 
paulson@30730
   839
apply (blast intro: seq_suble le_trans dest!: spec) 
paulson@30730
   840
done
paulson@30730
   841
chaieb@30196
   842
subsection {* Bounded Monotonic Sequences *}
chaieb@30196
   843
chaieb@30196
   844
huffman@20696
   845
text{*Bounded Sequence*}
paulson@15082
   846
huffman@20552
   847
lemma BseqD: "Bseq X ==> \<exists>K. 0 < K & (\<forall>n. norm (X n) \<le> K)"
paulson@15082
   848
by (simp add: Bseq_def)
paulson@15082
   849
huffman@20552
   850
lemma BseqI: "[| 0 < K; \<forall>n. norm (X n) \<le> K |] ==> Bseq X"
paulson@15082
   851
by (auto simp add: Bseq_def)
paulson@15082
   852
paulson@15082
   853
lemma lemma_NBseq_def:
huffman@20552
   854
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) =
huffman@20552
   855
      (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
haftmann@32064
   856
proof auto
haftmann@32064
   857
  fix K :: real
haftmann@32064
   858
  from reals_Archimedean2 obtain n :: nat where "K < real n" ..
haftmann@32064
   859
  then have "K \<le> real (Suc n)" by auto
haftmann@32064
   860
  assume "\<forall>m. norm (X m) \<le> K"
haftmann@32064
   861
  have "\<forall>m. norm (X m) \<le> real (Suc n)"
haftmann@32064
   862
  proof
haftmann@32064
   863
    fix m :: 'a
haftmann@32064
   864
    from `\<forall>m. norm (X m) \<le> K` have "norm (X m) \<le> K" ..
haftmann@32064
   865
    with `K \<le> real (Suc n)` show "norm (X m) \<le> real (Suc n)" by auto
haftmann@32064
   866
  qed
haftmann@32064
   867
  then show "\<exists>N. \<forall>n. norm (X n) \<le> real (Suc N)" ..
haftmann@32064
   868
next
haftmann@32064
   869
  fix N :: nat
haftmann@32064
   870
  have "real (Suc N) > 0" by (simp add: real_of_nat_Suc)
haftmann@32064
   871
  moreover assume "\<forall>n. norm (X n) \<le> real (Suc N)"
haftmann@32064
   872
  ultimately show "\<exists>K>0. \<forall>n. norm (X n) \<le> K" by blast
haftmann@32064
   873
qed
haftmann@32064
   874
paulson@15082
   875
paulson@15082
   876
text{* alternative definition for Bseq *}
huffman@20552
   877
lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
paulson@15082
   878
apply (simp add: Bseq_def)
paulson@15082
   879
apply (simp (no_asm) add: lemma_NBseq_def)
paulson@15082
   880
done
paulson@15082
   881
paulson@15082
   882
lemma lemma_NBseq_def2:
huffman@20552
   883
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   884
apply (subst lemma_NBseq_def, auto)
paulson@15082
   885
apply (rule_tac x = "Suc N" in exI)
paulson@15082
   886
apply (rule_tac [2] x = N in exI)
paulson@15082
   887
apply (auto simp add: real_of_nat_Suc)
paulson@15082
   888
 prefer 2 apply (blast intro: order_less_imp_le)
paulson@15082
   889
apply (drule_tac x = n in spec, simp)
paulson@15082
   890
done
paulson@15082
   891
paulson@15082
   892
(* yet another definition for Bseq *)
huffman@20552
   893
lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   894
by (simp add: Bseq_def lemma_NBseq_def2)
paulson@15082
   895
huffman@20696
   896
subsubsection{*Upper Bounds and Lubs of Bounded Sequences*}
paulson@15082
   897
paulson@15082
   898
lemma Bseq_isUb:
paulson@15082
   899
  "!!(X::nat=>real). Bseq X ==> \<exists>U. isUb (UNIV::real set) {x. \<exists>n. X n = x} U"
huffman@22998
   900
by (auto intro: isUbI setleI simp add: Bseq_def abs_le_iff)
paulson@15082
   901
paulson@15082
   902
paulson@15082
   903
text{* Use completeness of reals (supremum property)
paulson@15082
   904
   to show that any bounded sequence has a least upper bound*}
paulson@15082
   905
paulson@15082
   906
lemma Bseq_isLub:
paulson@15082
   907
  "!!(X::nat=>real). Bseq X ==>
paulson@15082
   908
   \<exists>U. isLub (UNIV::real set) {x. \<exists>n. X n = x} U"
paulson@15082
   909
by (blast intro: reals_complete Bseq_isUb)
paulson@15082
   910
huffman@20696
   911
subsubsection{*A Bounded and Monotonic Sequence Converges*}
paulson@15082
   912
paulson@15082
   913
lemma lemma_converg1:
nipkow@15360
   914
     "!!(X::nat=>real). [| \<forall>m. \<forall> n \<ge> m. X m \<le> X n;
paulson@15082
   915
                  isLub (UNIV::real set) {x. \<exists>n. X n = x} (X ma)
nipkow@15360
   916
               |] ==> \<forall>n \<ge> ma. X n = X ma"
paulson@15082
   917
apply safe
paulson@15082
   918
apply (drule_tac y = "X n" in isLubD2)
paulson@15082
   919
apply (blast dest: order_antisym)+
paulson@15082
   920
done
paulson@15082
   921
paulson@15082
   922
text{* The best of both worlds: Easier to prove this result as a standard
paulson@15082
   923
   theorem and then use equivalence to "transfer" it into the
paulson@15082
   924
   equivalent nonstandard form if needed!*}
paulson@15082
   925
paulson@15082
   926
lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)"
paulson@15082
   927
apply (simp add: LIMSEQ_def)
paulson@15082
   928
apply (rule_tac x = "X m" in exI, safe)
paulson@15082
   929
apply (rule_tac x = m in exI, safe)
paulson@15082
   930
apply (drule spec, erule impE, auto)
paulson@15082
   931
done
paulson@15082
   932
paulson@15082
   933
lemma lemma_converg2:
paulson@15082
   934
   "!!(X::nat=>real).
paulson@15082
   935
    [| \<forall>m. X m ~= U;  isLub UNIV {x. \<exists>n. X n = x} U |] ==> \<forall>m. X m < U"
paulson@15082
   936
apply safe
paulson@15082
   937
apply (drule_tac y = "X m" in isLubD2)
paulson@15082
   938
apply (auto dest!: order_le_imp_less_or_eq)
paulson@15082
   939
done
paulson@15082
   940
paulson@15082
   941
lemma lemma_converg3: "!!(X ::nat=>real). \<forall>m. X m \<le> U ==> isUb UNIV {x. \<exists>n. X n = x} U"
paulson@15082
   942
by (rule setleI [THEN isUbI], auto)
paulson@15082
   943
paulson@15082
   944
text{* FIXME: @{term "U - T < U"} is redundant *}
paulson@15082
   945
lemma lemma_converg4: "!!(X::nat=> real).
paulson@15082
   946
               [| \<forall>m. X m ~= U;
paulson@15082
   947
                  isLub UNIV {x. \<exists>n. X n = x} U;
paulson@15082
   948
                  0 < T;
paulson@15082
   949
                  U + - T < U
paulson@15082
   950
               |] ==> \<exists>m. U + -T < X m & X m < U"
paulson@15082
   951
apply (drule lemma_converg2, assumption)
paulson@15082
   952
apply (rule ccontr, simp)
paulson@15082
   953
apply (simp add: linorder_not_less)
paulson@15082
   954
apply (drule lemma_converg3)
paulson@15082
   955
apply (drule isLub_le_isUb, assumption)
paulson@15082
   956
apply (auto dest: order_less_le_trans)
paulson@15082
   957
done
paulson@15082
   958
paulson@15082
   959
text{*A standard proof of the theorem for monotone increasing sequence*}
paulson@15082
   960
paulson@15082
   961
lemma Bseq_mono_convergent:
huffman@20552
   962
     "[| Bseq X; \<forall>m. \<forall>n \<ge> m. X m \<le> X n |] ==> convergent (X::nat=>real)"
paulson@15082
   963
apply (simp add: convergent_def)
paulson@15082
   964
apply (frule Bseq_isLub, safe)
paulson@15082
   965
apply (case_tac "\<exists>m. X m = U", auto)
paulson@15082
   966
apply (blast dest: lemma_converg1 Bmonoseq_LIMSEQ)
paulson@15082
   967
(* second case *)
paulson@15082
   968
apply (rule_tac x = U in exI)
paulson@15082
   969
apply (subst LIMSEQ_iff, safe)
paulson@15082
   970
apply (frule lemma_converg2, assumption)
paulson@15082
   971
apply (drule lemma_converg4, auto)
paulson@15082
   972
apply (rule_tac x = m in exI, safe)
paulson@15082
   973
apply (subgoal_tac "X m \<le> X n")
paulson@15082
   974
 prefer 2 apply blast
paulson@15082
   975
apply (drule_tac x=n and P="%m. X m < U" in spec, arith)
paulson@15082
   976
done
paulson@15082
   977
paulson@15082
   978
lemma Bseq_minus_iff: "Bseq (%n. -(X n)) = Bseq X"
paulson@15082
   979
by (simp add: Bseq_def)
paulson@15082
   980
paulson@15082
   981
text{*Main monotonicity theorem*}
paulson@15082
   982
lemma Bseq_monoseq_convergent: "[| Bseq X; monoseq X |] ==> convergent X"
paulson@15082
   983
apply (simp add: monoseq_def, safe)
paulson@15082
   984
apply (rule_tac [2] convergent_minus_iff [THEN ssubst])
paulson@15082
   985
apply (drule_tac [2] Bseq_minus_iff [THEN ssubst])
paulson@15082
   986
apply (auto intro!: Bseq_mono_convergent)
paulson@15082
   987
done
paulson@15082
   988
paulson@30730
   989
subsubsection{*Increasing and Decreasing Series*}
paulson@30730
   990
paulson@30730
   991
lemma incseq_imp_monoseq:  "incseq X \<Longrightarrow> monoseq X"
paulson@30730
   992
  by (simp add: incseq_def monoseq_def) 
paulson@30730
   993
paulson@30730
   994
lemma incseq_le: assumes inc: "incseq X" and lim: "X ----> L" shows "X n \<le> L"
paulson@30730
   995
  using monoseq_le [OF incseq_imp_monoseq [OF inc] lim]
paulson@30730
   996
proof
paulson@30730
   997
  assume "(\<forall>n. X n \<le> L) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n)"
paulson@30730
   998
  thus ?thesis by simp
paulson@30730
   999
next
paulson@30730
  1000
  assume "(\<forall>n. L \<le> X n) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X n \<le> X m)"
paulson@30730
  1001
  hence const: "(!!m n. m \<le> n \<Longrightarrow> X n = X m)" using inc
paulson@30730
  1002
    by (auto simp add: incseq_def intro: order_antisym)
paulson@30730
  1003
  have X: "!!n. X n = X 0"
paulson@30730
  1004
    by (blast intro: const [of 0]) 
paulson@30730
  1005
  have "X = (\<lambda>n. X 0)"
paulson@30730
  1006
    by (blast intro: ext X)
paulson@30730
  1007
  hence "L = X 0" using LIMSEQ_const [of "X 0"]
paulson@30730
  1008
    by (auto intro: LIMSEQ_unique lim) 
paulson@30730
  1009
  thus ?thesis
paulson@30730
  1010
    by (blast intro: eq_refl X)
paulson@30730
  1011
qed
paulson@30730
  1012
hoelzl@35748
  1013
lemma incseq_SucI:
hoelzl@35748
  1014
  assumes "\<And>n. X n \<le> X (Suc n)"
hoelzl@35748
  1015
  shows "incseq X" unfolding incseq_def
hoelzl@35748
  1016
proof safe
hoelzl@35748
  1017
  fix m n :: nat
hoelzl@35748
  1018
  { fix d m :: nat
hoelzl@35748
  1019
    have "X m \<le> X (m + d)"
hoelzl@35748
  1020
    proof (induct d)
hoelzl@35748
  1021
      case (Suc d)
hoelzl@35748
  1022
      also have "X (m + d) \<le> X (m + Suc d)"
hoelzl@35748
  1023
        using assms by simp
hoelzl@35748
  1024
      finally show ?case .
hoelzl@35748
  1025
    qed simp }
hoelzl@35748
  1026
  note this[of m "n - m"]
hoelzl@35748
  1027
  moreover assume "m \<le> n"
hoelzl@35748
  1028
  ultimately show "X m \<le> X n" by simp
hoelzl@35748
  1029
qed
hoelzl@35748
  1030
paulson@30730
  1031
lemma decseq_imp_monoseq:  "decseq X \<Longrightarrow> monoseq X"
paulson@30730
  1032
  by (simp add: decseq_def monoseq_def)
paulson@30730
  1033
paulson@30730
  1034
lemma decseq_eq_incseq: "decseq X = incseq (\<lambda>n. - X n)" 
paulson@30730
  1035
  by (simp add: decseq_def incseq_def)
paulson@30730
  1036
paulson@30730
  1037
paulson@30730
  1038
lemma decseq_le: assumes dec: "decseq X" and lim: "X ----> L" shows "L \<le> X n"
paulson@30730
  1039
proof -
paulson@30730
  1040
  have inc: "incseq (\<lambda>n. - X n)" using dec
paulson@30730
  1041
    by (simp add: decseq_eq_incseq)
paulson@30730
  1042
  have "- X n \<le> - L" 
paulson@30730
  1043
    by (blast intro: incseq_le [OF inc] LIMSEQ_minus lim) 
paulson@30730
  1044
  thus ?thesis
paulson@30730
  1045
    by simp
paulson@30730
  1046
qed
paulson@30730
  1047
huffman@20696
  1048
subsubsection{*A Few More Equivalence Theorems for Boundedness*}
paulson@15082
  1049
paulson@15082
  1050
text{*alternative formulation for boundedness*}
huffman@20552
  1051
lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)"
paulson@15082
  1052
apply (unfold Bseq_def, safe)
huffman@20552
  1053
apply (rule_tac [2] x = "k + norm x" in exI)
nipkow@15360
  1054
apply (rule_tac x = K in exI, simp)
paulson@15221
  1055
apply (rule exI [where x = 0], auto)
huffman@20552
  1056
apply (erule order_less_le_trans, simp)
huffman@20552
  1057
apply (drule_tac x=n in spec, fold diff_def)
huffman@20552
  1058
apply (drule order_trans [OF norm_triangle_ineq2])
huffman@20552
  1059
apply simp
paulson@15082
  1060
done
paulson@15082
  1061
paulson@15082
  1062
text{*alternative formulation for boundedness*}
huffman@20552
  1063
lemma Bseq_iff3: "Bseq X = (\<exists>k > 0. \<exists>N. \<forall>n. norm(X(n) + -X(N)) \<le> k)"
paulson@15082
  1064
apply safe
paulson@15082
  1065
apply (simp add: Bseq_def, safe)
huffman@20552
  1066
apply (rule_tac x = "K + norm (X N)" in exI)
paulson@15082
  1067
apply auto
huffman@20552
  1068
apply (erule order_less_le_trans, simp)
paulson@15082
  1069
apply (rule_tac x = N in exI, safe)
huffman@20552
  1070
apply (drule_tac x = n in spec)
huffman@20552
  1071
apply (rule order_trans [OF norm_triangle_ineq], simp)
paulson@15082
  1072
apply (auto simp add: Bseq_iff2)
paulson@15082
  1073
done
paulson@15082
  1074
huffman@20552
  1075
lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f"
paulson@15082
  1076
apply (simp add: Bseq_def)
paulson@15221
  1077
apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto)
webertj@20217
  1078
apply (drule_tac x = n in spec, arith)
paulson@15082
  1079
done
paulson@15082
  1080
paulson@15082
  1081
huffman@20696
  1082
subsection {* Cauchy Sequences *}
paulson@15082
  1083
huffman@31336
  1084
lemma metric_CauchyI:
huffman@31336
  1085
  "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < e) \<Longrightarrow> Cauchy X"
huffman@31336
  1086
by (simp add: Cauchy_def)
huffman@31336
  1087
huffman@31336
  1088
lemma metric_CauchyD:
huffman@31336
  1089
  "\<lbrakk>Cauchy X; 0 < e\<rbrakk> \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < e"
huffman@20751
  1090
by (simp add: Cauchy_def)
huffman@20751
  1091
huffman@31336
  1092
lemma Cauchy_iff:
huffman@31336
  1093
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1094
  shows "Cauchy X \<longleftrightarrow> (\<forall>e>0. \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e)"
huffman@31336
  1095
unfolding Cauchy_def dist_norm ..
huffman@31336
  1096
hoelzl@35292
  1097
lemma Cauchy_iff2:
hoelzl@35292
  1098
     "Cauchy X =
hoelzl@35292
  1099
      (\<forall>j. (\<exists>M. \<forall>m \<ge> M. \<forall>n \<ge> M. \<bar>X m - X n\<bar> < inverse(real (Suc j))))"
hoelzl@35292
  1100
apply (simp add: Cauchy_iff, auto)
hoelzl@35292
  1101
apply (drule reals_Archimedean, safe)
hoelzl@35292
  1102
apply (drule_tac x = n in spec, auto)
hoelzl@35292
  1103
apply (rule_tac x = M in exI, auto)
hoelzl@35292
  1104
apply (drule_tac x = m in spec, simp)
hoelzl@35292
  1105
apply (drule_tac x = na in spec, auto)
hoelzl@35292
  1106
done
hoelzl@35292
  1107
huffman@31336
  1108
lemma CauchyI:
huffman@31336
  1109
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1110
  shows "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e) \<Longrightarrow> Cauchy X"
huffman@31336
  1111
by (simp add: Cauchy_iff)
huffman@31336
  1112
huffman@20751
  1113
lemma CauchyD:
huffman@31336
  1114
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1115
  shows "\<lbrakk>Cauchy X; 0 < e\<rbrakk> \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e"
huffman@31336
  1116
by (simp add: Cauchy_iff)
huffman@20751
  1117
paulson@30730
  1118
lemma Cauchy_subseq_Cauchy:
paulson@30730
  1119
  "\<lbrakk> Cauchy X; subseq f \<rbrakk> \<Longrightarrow> Cauchy (X o f)"
huffman@31336
  1120
apply (auto simp add: Cauchy_def)
huffman@31336
  1121
apply (drule_tac x=e in spec, clarify)
huffman@31336
  1122
apply (rule_tac x=M in exI, clarify)
huffman@31336
  1123
apply (blast intro: le_trans [OF _ seq_suble] dest!: spec)
paulson@30730
  1124
done
paulson@30730
  1125
huffman@20696
  1126
subsubsection {* Cauchy Sequences are Bounded *}
huffman@20696
  1127
paulson@15082
  1128
text{*A Cauchy sequence is bounded -- this is the standard
paulson@15082
  1129
  proof mechanization rather than the nonstandard proof*}
paulson@15082
  1130
huffman@20563
  1131
lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real)
huffman@20552
  1132
          ==>  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
huffman@20552
  1133
apply (clarify, drule spec, drule (1) mp)
huffman@20563
  1134
apply (simp only: norm_minus_commute)
huffman@20552
  1135
apply (drule order_le_less_trans [OF norm_triangle_ineq2])
huffman@20552
  1136
apply simp
huffman@20552
  1137
done
paulson@15082
  1138
paulson@15082
  1139
lemma Cauchy_Bseq: "Cauchy X ==> Bseq X"
huffman@31336
  1140
apply (simp add: Cauchy_iff)
huffman@20552
  1141
apply (drule spec, drule mp, rule zero_less_one, safe)
huffman@20552
  1142
apply (drule_tac x="M" in spec, simp)
paulson@15082
  1143
apply (drule lemmaCauchy)
huffman@22608
  1144
apply (rule_tac k="M" in Bseq_offset)
huffman@20552
  1145
apply (simp add: Bseq_def)
huffman@20552
  1146
apply (rule_tac x="1 + norm (X M)" in exI)
huffman@20552
  1147
apply (rule conjI, rule order_less_le_trans [OF zero_less_one], simp)
huffman@20552
  1148
apply (simp add: order_less_imp_le)
paulson@15082
  1149
done
paulson@15082
  1150
huffman@20696
  1151
subsubsection {* Cauchy Sequences are Convergent *}
paulson@15082
  1152
haftmann@33042
  1153
class complete_space =
haftmann@33042
  1154
  assumes Cauchy_convergent: "Cauchy X \<Longrightarrow> convergent X"
huffman@20830
  1155
haftmann@33042
  1156
class banach = real_normed_vector + complete_space
huffman@31403
  1157
huffman@22629
  1158
theorem LIMSEQ_imp_Cauchy:
huffman@22629
  1159
  assumes X: "X ----> a" shows "Cauchy X"
huffman@31336
  1160
proof (rule metric_CauchyI)
huffman@22629
  1161
  fix e::real assume "0 < e"
huffman@22629
  1162
  hence "0 < e/2" by simp
huffman@31336
  1163
  with X have "\<exists>N. \<forall>n\<ge>N. dist (X n) a < e/2" by (rule metric_LIMSEQ_D)
huffman@31336
  1164
  then obtain N where N: "\<forall>n\<ge>N. dist (X n) a < e/2" ..
huffman@31336
  1165
  show "\<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. dist (X m) (X n) < e"
huffman@22629
  1166
  proof (intro exI allI impI)
huffman@22629
  1167
    fix m assume "N \<le> m"
huffman@31336
  1168
    hence m: "dist (X m) a < e/2" using N by fast
huffman@22629
  1169
    fix n assume "N \<le> n"
huffman@31336
  1170
    hence n: "dist (X n) a < e/2" using N by fast
huffman@31336
  1171
    have "dist (X m) (X n) \<le> dist (X m) a + dist (X n) a"
huffman@31336
  1172
      by (rule dist_triangle2)
huffman@31336
  1173
    also from m n have "\<dots> < e" by simp
huffman@31336
  1174
    finally show "dist (X m) (X n) < e" .
huffman@22629
  1175
  qed
huffman@22629
  1176
qed
huffman@22629
  1177
huffman@20691
  1178
lemma convergent_Cauchy: "convergent X \<Longrightarrow> Cauchy X"
huffman@22629
  1179
unfolding convergent_def
huffman@22629
  1180
by (erule exE, erule LIMSEQ_imp_Cauchy)
huffman@20691
  1181
huffman@31403
  1182
lemma Cauchy_convergent_iff:
huffman@31403
  1183
  fixes X :: "nat \<Rightarrow> 'a::complete_space"
huffman@31403
  1184
  shows "Cauchy X = convergent X"
huffman@31403
  1185
by (fast intro: Cauchy_convergent convergent_Cauchy)
huffman@31403
  1186
huffman@31403
  1187
lemma convergent_subseq_convergent:
huffman@31403
  1188
  fixes X :: "nat \<Rightarrow> 'a::complete_space"
huffman@31403
  1189
  shows "\<lbrakk> convergent X; subseq f \<rbrakk> \<Longrightarrow> convergent (X o f)"
huffman@31403
  1190
  by (simp add: Cauchy_subseq_Cauchy Cauchy_convergent_iff [symmetric])
huffman@31403
  1191
huffman@22629
  1192
text {*
huffman@22629
  1193
Proof that Cauchy sequences converge based on the one from
huffman@22629
  1194
http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html
huffman@22629
  1195
*}
huffman@22629
  1196
huffman@22629
  1197
text {*
huffman@22629
  1198
  If sequence @{term "X"} is Cauchy, then its limit is the lub of
huffman@22629
  1199
  @{term "{r::real. \<exists>N. \<forall>n\<ge>N. r < X n}"}
huffman@22629
  1200
*}
huffman@22629
  1201
huffman@22629
  1202
lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
huffman@22629
  1203
by (simp add: isUbI setleI)
huffman@22629
  1204
haftmann@27681
  1205
locale real_Cauchy =
huffman@22629
  1206
  fixes X :: "nat \<Rightarrow> real"
huffman@22629
  1207
  assumes X: "Cauchy X"
huffman@22629
  1208
  fixes S :: "real set"
huffman@22629
  1209
  defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
huffman@22629
  1210
haftmann@27681
  1211
lemma real_CauchyI:
haftmann@27681
  1212
  assumes "Cauchy X"
haftmann@27681
  1213
  shows "real_Cauchy X"
haftmann@28823
  1214
  proof qed (fact assms)
haftmann@27681
  1215
huffman@22629
  1216
lemma (in real_Cauchy) mem_S: "\<forall>n\<ge>N. x < X n \<Longrightarrow> x \<in> S"
huffman@22629
  1217
by (unfold S_def, auto)
huffman@22629
  1218
huffman@22629
  1219
lemma (in real_Cauchy) bound_isUb:
huffman@22629
  1220
  assumes N: "\<forall>n\<ge>N. X n < x"
huffman@22629
  1221
  shows "isUb UNIV S x"
huffman@22629
  1222
proof (rule isUb_UNIV_I)
huffman@22629
  1223
  fix y::real assume "y \<in> S"
huffman@22629
  1224
  hence "\<exists>M. \<forall>n\<ge>M. y < X n"
huffman@22629
  1225
    by (simp add: S_def)
huffman@22629
  1226
  then obtain M where "\<forall>n\<ge>M. y < X n" ..
huffman@22629
  1227
  hence "y < X (max M N)" by simp
huffman@22629
  1228
  also have "\<dots> < x" using N by simp
huffman@22629
  1229
  finally show "y \<le> x"
huffman@22629
  1230
    by (rule order_less_imp_le)
huffman@22629
  1231
qed
huffman@22629
  1232
huffman@22629
  1233
lemma (in real_Cauchy) isLub_ex: "\<exists>u. isLub UNIV S u"
huffman@22629
  1234
proof (rule reals_complete)
huffman@22629
  1235
  obtain N where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (X m - X n) < 1"
haftmann@32064
  1236
    using CauchyD [OF X zero_less_one] by auto
huffman@22629
  1237
  hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
huffman@22629
  1238
  show "\<exists>x. x \<in> S"
huffman@22629
  1239
  proof
huffman@22629
  1240
    from N have "\<forall>n\<ge>N. X N - 1 < X n"
paulson@32707
  1241
      by (simp add: abs_diff_less_iff)
huffman@22629
  1242
    thus "X N - 1 \<in> S" by (rule mem_S)
huffman@22629
  1243
  qed
huffman@22629
  1244
  show "\<exists>u. isUb UNIV S u"
huffman@22629
  1245
  proof
huffman@22629
  1246
    from N have "\<forall>n\<ge>N. X n < X N + 1"
paulson@32707
  1247
      by (simp add: abs_diff_less_iff)
huffman@22629
  1248
    thus "isUb UNIV S (X N + 1)"
huffman@22629
  1249
      by (rule bound_isUb)
huffman@22629
  1250
  qed
huffman@22629
  1251
qed
huffman@22629
  1252
huffman@22629
  1253
lemma (in real_Cauchy) isLub_imp_LIMSEQ:
huffman@22629
  1254
  assumes x: "isLub UNIV S x"
huffman@22629
  1255
  shows "X ----> x"
huffman@22629
  1256
proof (rule LIMSEQ_I)
huffman@22629
  1257
  fix r::real assume "0 < r"
huffman@22629
  1258
  hence r: "0 < r/2" by simp
huffman@22629
  1259
  obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
haftmann@32064
  1260
    using CauchyD [OF X r] by auto
huffman@22629
  1261
  hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
huffman@22629
  1262
  hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
paulson@32707
  1263
    by (simp only: real_norm_def abs_diff_less_iff)
huffman@22629
  1264
huffman@22629
  1265
  from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
huffman@22629
  1266
  hence "X N - r/2 \<in> S" by (rule mem_S)
nipkow@23482
  1267
  hence 1: "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
huffman@22629
  1268
huffman@22629
  1269
  from N have "\<forall>n\<ge>N. X n < X N + r/2" by fast
huffman@22629
  1270
  hence "isUb UNIV S (X N + r/2)" by (rule bound_isUb)
nipkow@23482
  1271
  hence 2: "x \<le> X N + r/2" using x isLub_le_isUb by fast
huffman@22629
  1272
huffman@22629
  1273
  show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
huffman@22629
  1274
  proof (intro exI allI impI)
huffman@22629
  1275
    fix n assume n: "N \<le> n"
nipkow@23482
  1276
    from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+
nipkow@23482
  1277
    thus "norm (X n - x) < r" using 1 2
paulson@32707
  1278
      by (simp add: abs_diff_less_iff)
huffman@22629
  1279
  qed
huffman@22629
  1280
qed
huffman@22629
  1281
huffman@22629
  1282
lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
huffman@22629
  1283
proof -
huffman@22629
  1284
  obtain x where "isLub UNIV S x"
huffman@22629
  1285
    using isLub_ex by fast
huffman@22629
  1286
  hence "X ----> x"
huffman@22629
  1287
    by (rule isLub_imp_LIMSEQ)
huffman@22629
  1288
  thus ?thesis ..
huffman@22629
  1289
qed
huffman@22629
  1290
huffman@20830
  1291
lemma real_Cauchy_convergent:
huffman@20830
  1292
  fixes X :: "nat \<Rightarrow> real"
huffman@20830
  1293
  shows "Cauchy X \<Longrightarrow> convergent X"
haftmann@27681
  1294
unfolding convergent_def
haftmann@27681
  1295
by (rule real_Cauchy.LIMSEQ_ex)
haftmann@27681
  1296
 (rule real_CauchyI)
huffman@20830
  1297
huffman@20830
  1298
instance real :: banach
huffman@20830
  1299
by intro_classes (rule real_Cauchy_convergent)
huffman@20830
  1300
paulson@15082
  1301
huffman@20696
  1302
subsection {* Power Sequences *}
paulson@15082
  1303
paulson@15082
  1304
text{*The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
paulson@15082
  1305
"x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
paulson@15082
  1306
  also fact that bounded and monotonic sequence converges.*}
paulson@15082
  1307
huffman@20552
  1308
lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)"
paulson@15082
  1309
apply (simp add: Bseq_def)
paulson@15082
  1310
apply (rule_tac x = 1 in exI)
paulson@15082
  1311
apply (simp add: power_abs)
huffman@22974
  1312
apply (auto dest: power_mono)
paulson@15082
  1313
done
paulson@15082
  1314
paulson@15082
  1315
lemma monoseq_realpow: "[| 0 \<le> x; x \<le> 1 |] ==> monoseq (%n. x ^ n)"
paulson@15082
  1316
apply (clarify intro!: mono_SucI2)
paulson@15082
  1317
apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing, auto)
paulson@15082
  1318
done
paulson@15082
  1319
huffman@20552
  1320
lemma convergent_realpow:
huffman@20552
  1321
  "[| 0 \<le> (x::real); x \<le> 1 |] ==> convergent (%n. x ^ n)"
paulson@15082
  1322
by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
paulson@15082
  1323
huffman@22628
  1324
lemma LIMSEQ_inverse_realpow_zero_lemma:
huffman@22628
  1325
  fixes x :: real
huffman@22628
  1326
  assumes x: "0 \<le> x"
huffman@22628
  1327
  shows "real n * x + 1 \<le> (x + 1) ^ n"
huffman@22628
  1328
apply (induct n)
huffman@22628
  1329
apply simp
huffman@22628
  1330
apply simp
huffman@22628
  1331
apply (rule order_trans)
huffman@22628
  1332
prefer 2
huffman@22628
  1333
apply (erule mult_left_mono)
huffman@22628
  1334
apply (rule add_increasing [OF x], simp)
huffman@22628
  1335
apply (simp add: real_of_nat_Suc)
nipkow@23477
  1336
apply (simp add: ring_distribs)
huffman@22628
  1337
apply (simp add: mult_nonneg_nonneg x)
huffman@22628
  1338
done
huffman@22628
  1339
huffman@22628
  1340
lemma LIMSEQ_inverse_realpow_zero:
huffman@22628
  1341
  "1 < (x::real) \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) ----> 0"
huffman@22628
  1342
proof (rule LIMSEQ_inverse_zero [rule_format])
huffman@22628
  1343
  fix y :: real
huffman@22628
  1344
  assume x: "1 < x"
huffman@22628
  1345
  hence "0 < x - 1" by simp
huffman@22628
  1346
  hence "\<forall>y. \<exists>N::nat. y < real N * (x - 1)"
huffman@22628
  1347
    by (rule reals_Archimedean3)
huffman@22628
  1348
  hence "\<exists>N::nat. y < real N * (x - 1)" ..
huffman@22628
  1349
  then obtain N::nat where "y < real N * (x - 1)" ..
huffman@22628
  1350
  also have "\<dots> \<le> real N * (x - 1) + 1" by simp
huffman@22628
  1351
  also have "\<dots> \<le> (x - 1 + 1) ^ N"
huffman@22628
  1352
    by (rule LIMSEQ_inverse_realpow_zero_lemma, cut_tac x, simp)
huffman@22628
  1353
  also have "\<dots> = x ^ N" by simp
huffman@22628
  1354
  finally have "y < x ^ N" .
huffman@22628
  1355
  hence "\<forall>n\<ge>N. y < x ^ n"
huffman@22628
  1356
    apply clarify
huffman@22628
  1357
    apply (erule order_less_le_trans)
huffman@22628
  1358
    apply (erule power_increasing)
huffman@22628
  1359
    apply (rule order_less_imp_le [OF x])
huffman@22628
  1360
    done
huffman@22628
  1361
  thus "\<exists>N. \<forall>n\<ge>N. y < x ^ n" ..
huffman@22628
  1362
qed
huffman@22628
  1363
huffman@20552
  1364
lemma LIMSEQ_realpow_zero:
huffman@22628
  1365
  "\<lbrakk>0 \<le> (x::real); x < 1\<rbrakk> \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@22628
  1366
proof (cases)
huffman@22628
  1367
  assume "x = 0"
huffman@22628
  1368
  hence "(\<lambda>n. x ^ Suc n) ----> 0" by (simp add: LIMSEQ_const)
huffman@22628
  1369
  thus ?thesis by (rule LIMSEQ_imp_Suc)
huffman@22628
  1370
next
huffman@22628
  1371
  assume "0 \<le> x" and "x \<noteq> 0"
huffman@22628
  1372
  hence x0: "0 < x" by simp
huffman@22628
  1373
  assume x1: "x < 1"
huffman@22628
  1374
  from x0 x1 have "1 < inverse x"
huffman@22628
  1375
    by (rule real_inverse_gt_one)
huffman@22628
  1376
  hence "(\<lambda>n. inverse (inverse x ^ n)) ----> 0"
huffman@22628
  1377
    by (rule LIMSEQ_inverse_realpow_zero)
huffman@22628
  1378
  thus ?thesis by (simp add: power_inverse)
huffman@22628
  1379
qed
paulson@15082
  1380
huffman@20685
  1381
lemma LIMSEQ_power_zero:
haftmann@31017
  1382
  fixes x :: "'a::{real_normed_algebra_1}"
huffman@20685
  1383
  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@20685
  1384
apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
huffman@22974
  1385
apply (simp only: LIMSEQ_Zseq_iff, erule Zseq_le)
huffman@22974
  1386
apply (simp add: power_abs norm_power_ineq)
huffman@20685
  1387
done
huffman@20685
  1388
huffman@20552
  1389
lemma LIMSEQ_divide_realpow_zero:
huffman@20552
  1390
  "1 < (x::real) ==> (%n. a / (x ^ n)) ----> 0"
paulson@15082
  1391
apply (cut_tac a = a and x1 = "inverse x" in
paulson@15082
  1392
        LIMSEQ_mult [OF LIMSEQ_const LIMSEQ_realpow_zero])
paulson@15082
  1393
apply (auto simp add: divide_inverse power_inverse)
paulson@15082
  1394
apply (simp add: inverse_eq_divide pos_divide_less_eq)
paulson@15082
  1395
done
paulson@15082
  1396
paulson@15102
  1397
text{*Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}*}
paulson@15082
  1398
huffman@20552
  1399
lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < (1::real) ==> (%n. \<bar>c\<bar> ^ n) ----> 0"
huffman@20685
  1400
by (rule LIMSEQ_realpow_zero [OF abs_ge_zero])
paulson@15082
  1401
huffman@20552
  1402
lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < (1::real) ==> (%n. c ^ n) ----> 0"
paulson@15082
  1403
apply (rule LIMSEQ_rabs_zero [THEN iffD1])
paulson@15082
  1404
apply (auto intro: LIMSEQ_rabs_realpow_zero simp add: power_abs)
paulson@15082
  1405
done
paulson@15082
  1406
paulson@10751
  1407
end