src/HOL/SEQ.thy
author haftmann
Fri Nov 27 08:41:10 2009 +0100 (2009-11-27)
changeset 33963 977b94b64905
parent 33271 7be66dee1a5a
child 35216 7641e8d831d2
permissions -rw-r--r--
renamed former datatype.ML to datatype_data.ML; datatype.ML provides uniform view on datatype.ML and datatype_rep_proofs.ML
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"
huffman@31336
   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@31336
   535
lemma convergent_minus_iff:
huffman@31336
   536
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   537
  shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
huffman@20696
   538
apply (simp add: convergent_def)
huffman@20696
   539
apply (auto dest: LIMSEQ_minus)
huffman@20696
   540
apply (drule LIMSEQ_minus, auto)
huffman@20696
   541
done
huffman@20696
   542
paulson@32707
   543
lemma lim_le:
paulson@32707
   544
  fixes x :: real
paulson@32707
   545
  assumes f: "convergent f" and fn_le: "!!n. f n \<le> x"
paulson@32707
   546
  shows "lim f \<le> x"
paulson@32707
   547
proof (rule classical)
paulson@32707
   548
  assume "\<not> lim f \<le> x"
paulson@32707
   549
  hence 0: "0 < lim f - x" by arith
paulson@32707
   550
  have 1: "f----> lim f"
paulson@32707
   551
    by (metis convergent_LIMSEQ_iff f) 
paulson@32707
   552
  thus ?thesis
paulson@32707
   553
    proof (simp add: LIMSEQ_iff)
paulson@32707
   554
      assume "\<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < r"
paulson@32707
   555
      hence "\<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   556
        by (metis 0)
paulson@32707
   557
      from this obtain no where "\<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   558
        by blast
paulson@32707
   559
      thus "lim f \<le> x"
wenzelm@32960
   560
        by (metis add_cancel_end add_minus_cancel diff_def linorder_linear 
paulson@32707
   561
                  linorder_not_le minus_diff_eq abs_diff_less_iff fn_le) 
paulson@32707
   562
    qed
paulson@32707
   563
qed
paulson@32707
   564
chaieb@30196
   565
text{* Given a binary function @{text "f:: nat \<Rightarrow> 'a \<Rightarrow> 'a"}, its values are uniquely determined by a function g *}
huffman@20696
   566
chaieb@30196
   567
lemma nat_function_unique: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))"
chaieb@30196
   568
  unfolding Ex1_def
chaieb@30196
   569
  apply (rule_tac x="nat_rec e f" in exI)
chaieb@30196
   570
  apply (rule conjI)+
chaieb@30196
   571
apply (rule def_nat_rec_0, simp)
chaieb@30196
   572
apply (rule allI, rule def_nat_rec_Suc, simp)
chaieb@30196
   573
apply (rule allI, rule impI, rule ext)
chaieb@30196
   574
apply (erule conjE)
chaieb@30196
   575
apply (induct_tac x)
chaieb@30196
   576
apply (simp add: nat_rec_0)
chaieb@30196
   577
apply (erule_tac x="n" in allE)
chaieb@30196
   578
apply (simp)
chaieb@30196
   579
done
huffman@20696
   580
paulson@15082
   581
text{*Subsequence (alternative definition, (e.g. Hoskins)*}
paulson@15082
   582
paulson@15082
   583
lemma subseq_Suc_iff: "subseq f = (\<forall>n. (f n) < (f (Suc n)))"
paulson@15082
   584
apply (simp add: subseq_def)
paulson@15082
   585
apply (auto dest!: less_imp_Suc_add)
paulson@15082
   586
apply (induct_tac k)
paulson@15082
   587
apply (auto intro: less_trans)
paulson@15082
   588
done
paulson@15082
   589
paulson@15082
   590
lemma monoseq_Suc:
paulson@15082
   591
   "monoseq X = ((\<forall>n. X n \<le> X (Suc n))
paulson@15082
   592
                 | (\<forall>n. X (Suc n) \<le> X n))"
paulson@15082
   593
apply (simp add: monoseq_def)
paulson@15082
   594
apply (auto dest!: le_imp_less_or_eq)
paulson@15082
   595
apply (auto intro!: lessI [THEN less_imp_le] dest!: less_imp_Suc_add)
paulson@15082
   596
apply (induct_tac "ka")
paulson@15082
   597
apply (auto intro: order_trans)
wenzelm@18585
   598
apply (erule contrapos_np)
paulson@15082
   599
apply (induct_tac "k")
paulson@15082
   600
apply (auto intro: order_trans)
paulson@15082
   601
done
paulson@15082
   602
nipkow@15360
   603
lemma monoI1: "\<forall>m. \<forall> n \<ge> m. X m \<le> X n ==> monoseq X"
paulson@15082
   604
by (simp add: monoseq_def)
paulson@15082
   605
nipkow@15360
   606
lemma monoI2: "\<forall>m. \<forall> n \<ge> m. X n \<le> X m ==> monoseq X"
paulson@15082
   607
by (simp add: monoseq_def)
paulson@15082
   608
paulson@15082
   609
lemma mono_SucI1: "\<forall>n. X n \<le> X (Suc n) ==> monoseq X"
paulson@15082
   610
by (simp add: monoseq_Suc)
paulson@15082
   611
paulson@15082
   612
lemma mono_SucI2: "\<forall>n. X (Suc n) \<le> X n ==> monoseq X"
paulson@15082
   613
by (simp add: monoseq_Suc)
paulson@15082
   614
hoelzl@29803
   615
lemma monoseq_minus: assumes "monoseq a"
hoelzl@29803
   616
  shows "monoseq (\<lambda> n. - a n)"
hoelzl@29803
   617
proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@29803
   618
  case True
hoelzl@29803
   619
  hence "\<forall> m. \<forall> n \<ge> m. - a n \<le> - a m" by auto
hoelzl@29803
   620
  thus ?thesis by (rule monoI2)
hoelzl@29803
   621
next
hoelzl@29803
   622
  case False
hoelzl@29803
   623
  hence "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" using `monoseq a`[unfolded monoseq_def] by auto
hoelzl@29803
   624
  thus ?thesis by (rule monoI1)
hoelzl@29803
   625
qed
hoelzl@29803
   626
hoelzl@29803
   627
lemma monoseq_le: assumes "monoseq a" and "a ----> x"
hoelzl@29803
   628
  shows "((\<forall> n. a n \<le> x) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)) \<or> 
hoelzl@29803
   629
         ((\<forall> n. x \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m))"
hoelzl@29803
   630
proof -
hoelzl@29803
   631
  { fix x n fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   632
    assume "a ----> x" and "\<forall> m. \<forall> n \<ge> m. a m \<le> a n"
hoelzl@29803
   633
    hence monotone: "\<And> m n. m \<le> n \<Longrightarrow> a m \<le> a n" by auto
hoelzl@29803
   634
    have "a n \<le> x"
hoelzl@29803
   635
    proof (rule ccontr)
hoelzl@29803
   636
      assume "\<not> a n \<le> x" hence "x < a n" by auto
hoelzl@29803
   637
      hence "0 < a n - x" by auto
hoelzl@29803
   638
      from `a ----> x`[THEN LIMSEQ_D, OF this]
hoelzl@29803
   639
      obtain no where "\<And>n'. no \<le> n' \<Longrightarrow> norm (a n' - x) < a n - x" by blast
hoelzl@29803
   640
      hence "norm (a (max no n) - x) < a n - x" by auto
hoelzl@29803
   641
      moreover
hoelzl@29803
   642
      { 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
   643
      hence "x < a (max no n)" by auto
hoelzl@29803
   644
      ultimately
hoelzl@29803
   645
      have "a (max no n) < a n" by auto
hoelzl@29803
   646
      with monotone[where m=n and n="max no n"]
nipkow@32436
   647
      show False by (auto simp:max_def split:split_if_asm)
hoelzl@29803
   648
    qed
hoelzl@29803
   649
  } note top_down = this
hoelzl@29803
   650
  { fix x n m fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   651
    assume "a ----> x" and "monoseq a" and "a m < x"
hoelzl@29803
   652
    have "a n \<le> x \<and> (\<forall> m. \<forall> n \<ge> m. a m \<le> a n)"
hoelzl@29803
   653
    proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@29803
   654
      case True with top_down and `a ----> x` show ?thesis by auto
hoelzl@29803
   655
    next
hoelzl@29803
   656
      case False with `monoseq a`[unfolded monoseq_def] have "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" by auto
hoelzl@29803
   657
      hence "- a m \<le> - x" using top_down[OF LIMSEQ_minus[OF `a ----> x`]] by blast
hoelzl@29803
   658
      hence False using `a m < x` by auto
hoelzl@29803
   659
      thus ?thesis ..
hoelzl@29803
   660
    qed
hoelzl@29803
   661
  } note when_decided = this
hoelzl@29803
   662
hoelzl@29803
   663
  show ?thesis
hoelzl@29803
   664
  proof (cases "\<exists> m. a m \<noteq> x")
hoelzl@29803
   665
    case True then obtain m where "a m \<noteq> x" by auto
hoelzl@29803
   666
    show ?thesis
hoelzl@29803
   667
    proof (cases "a m < x")
hoelzl@29803
   668
      case True with when_decided[OF `a ----> x` `monoseq a`, where m2=m]
hoelzl@29803
   669
      show ?thesis by blast
hoelzl@29803
   670
    next
hoelzl@29803
   671
      case False hence "- a m < - x" using `a m \<noteq> x` by auto
hoelzl@29803
   672
      with when_decided[OF LIMSEQ_minus[OF `a ----> x`] monoseq_minus[OF `monoseq a`], where m2=m]
hoelzl@29803
   673
      show ?thesis by auto
hoelzl@29803
   674
    qed
hoelzl@29803
   675
  qed auto
hoelzl@29803
   676
qed
hoelzl@29803
   677
chaieb@30196
   678
text{* for any sequence, there is a mootonic subsequence *}
chaieb@30196
   679
lemma seq_monosub: "\<exists>f. subseq f \<and> monoseq (\<lambda> n. (s (f n)))"
chaieb@30196
   680
proof-
chaieb@30196
   681
  {assume H: "\<forall>n. \<exists>p >n. \<forall> m\<ge>p. s m \<le> s p"
chaieb@30196
   682
    let ?P = "\<lambda> p n. p > n \<and> (\<forall>m \<ge> p. s m \<le> s p)"
chaieb@30196
   683
    from nat_function_unique[of "SOME p. ?P p 0" "\<lambda>p n. SOME p. ?P p n"]
chaieb@30196
   684
    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
   685
    have "?P (f 0) 0"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p 0"]
chaieb@30196
   686
      using H apply - 
chaieb@30196
   687
      apply (erule allE[where x=0], erule exE, rule_tac x="p" in exI) 
chaieb@30196
   688
      unfolding order_le_less by blast 
chaieb@30196
   689
    hence f0: "f 0 > 0" "\<forall>m \<ge> f 0. s m \<le> s (f 0)" by blast+
chaieb@30196
   690
    {fix n
chaieb@30196
   691
      have "?P (f (Suc n)) (f n)" 
wenzelm@32960
   692
        unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
wenzelm@32960
   693
        using H apply - 
chaieb@30196
   694
      apply (erule allE[where x="f n"], erule exE, rule_tac x="p" in exI) 
chaieb@30196
   695
      unfolding order_le_less by blast 
chaieb@30196
   696
    hence "f (Suc n) > f n" "\<forall>m \<ge> f (Suc n). s m \<le> s (f (Suc n))" by blast+}
chaieb@30196
   697
  note fSuc = this
chaieb@30196
   698
    {fix p q assume pq: "p \<ge> f q"
chaieb@30196
   699
      have "s p \<le> s(f(q))"  using f0(2)[rule_format, of p] pq fSuc
wenzelm@32960
   700
        by (cases q, simp_all) }
chaieb@30196
   701
    note pqth = this
chaieb@30196
   702
    {fix q
chaieb@30196
   703
      have "f (Suc q) > f q" apply (induct q) 
wenzelm@32960
   704
        using f0(1) fSuc(1)[of 0] apply simp by (rule fSuc(1))}
chaieb@30196
   705
    note fss = this
chaieb@30196
   706
    from fss have th1: "subseq f" unfolding subseq_Suc_iff ..
chaieb@30196
   707
    {fix a b 
chaieb@30196
   708
      have "f a \<le> f (a + b)"
chaieb@30196
   709
      proof(induct b)
wenzelm@32960
   710
        case 0 thus ?case by simp
chaieb@30196
   711
      next
wenzelm@32960
   712
        case (Suc b)
wenzelm@32960
   713
        from fSuc(1)[of "a + b"] Suc.hyps show ?case by simp
chaieb@30196
   714
      qed}
chaieb@30196
   715
    note fmon0 = this
chaieb@30196
   716
    have "monoseq (\<lambda>n. s (f n))" 
chaieb@30196
   717
    proof-
chaieb@30196
   718
      {fix n
wenzelm@32960
   719
        have "s (f n) \<ge> s (f (Suc n))" 
wenzelm@32960
   720
        proof(cases n)
wenzelm@32960
   721
          case 0
wenzelm@32960
   722
          assume n0: "n = 0"
wenzelm@32960
   723
          from fSuc(1)[of 0] have th0: "f 0 \<le> f (Suc 0)" by simp
wenzelm@32960
   724
          from f0(2)[rule_format, OF th0] show ?thesis  using n0 by simp
wenzelm@32960
   725
        next
wenzelm@32960
   726
          case (Suc m)
wenzelm@32960
   727
          assume m: "n = Suc m"
wenzelm@32960
   728
          from fSuc(1)[of n] m have th0: "f (Suc m) \<le> f (Suc (Suc m))" by simp
wenzelm@32960
   729
          from m fSuc(2)[rule_format, OF th0] show ?thesis by simp 
wenzelm@32960
   730
        qed}
chaieb@30196
   731
      thus "monoseq (\<lambda>n. s (f n))" unfolding monoseq_Suc by blast 
chaieb@30196
   732
    qed
chaieb@30196
   733
    with th1 have ?thesis by blast}
chaieb@30196
   734
  moreover
chaieb@30196
   735
  {fix N assume N: "\<forall>p >N. \<exists> m\<ge>p. s m > s p"
chaieb@30196
   736
    {fix p assume p: "p \<ge> Suc N" 
chaieb@30196
   737
      hence pN: "p > N" by arith with N obtain m where m: "m \<ge> p" "s m > s p" by blast
chaieb@30196
   738
      have "m \<noteq> p" using m(2) by auto 
chaieb@30196
   739
      with m have "\<exists>m>p. s p < s m" by - (rule exI[where x=m], auto)}
chaieb@30196
   740
    note th0 = this
chaieb@30196
   741
    let ?P = "\<lambda>m x. m > x \<and> s x < s m"
chaieb@30196
   742
    from nat_function_unique[of "SOME x. ?P x (Suc N)" "\<lambda>m x. SOME y. ?P y x"]
chaieb@30196
   743
    obtain f where f: "f 0 = (SOME x. ?P x (Suc N))" 
chaieb@30196
   744
      "\<forall>n. f (Suc n) = (SOME m. ?P m (f n))" by blast
chaieb@30196
   745
    have "?P (f 0) (Suc N)"  unfolding f(1) some_eq_ex[of "\<lambda>p. ?P p (Suc N)"]
chaieb@30196
   746
      using N apply - 
chaieb@30196
   747
      apply (erule allE[where x="Suc N"], clarsimp)
chaieb@30196
   748
      apply (rule_tac x="m" in exI)
chaieb@30196
   749
      apply auto
chaieb@30196
   750
      apply (subgoal_tac "Suc N \<noteq> m")
chaieb@30196
   751
      apply simp
chaieb@30196
   752
      apply (rule ccontr, simp)
chaieb@30196
   753
      done
chaieb@30196
   754
    hence f0: "f 0 > Suc N" "s (Suc N) < s (f 0)" by blast+
chaieb@30196
   755
    {fix n
chaieb@30196
   756
      have "f n > N \<and> ?P (f (Suc n)) (f n)"
wenzelm@32960
   757
        unfolding f(2)[rule_format, of n] some_eq_ex[of "\<lambda>p. ?P p (f n)"]
chaieb@30196
   758
      proof (induct n)
wenzelm@32960
   759
        case 0 thus ?case
wenzelm@32960
   760
          using f0 N apply auto 
wenzelm@32960
   761
          apply (erule allE[where x="f 0"], clarsimp) 
wenzelm@32960
   762
          apply (rule_tac x="m" in exI, simp)
wenzelm@32960
   763
          by (subgoal_tac "f 0 \<noteq> m", auto)
chaieb@30196
   764
      next
wenzelm@32960
   765
        case (Suc n)
wenzelm@32960
   766
        from Suc.hyps have Nfn: "N < f n" by blast
wenzelm@32960
   767
        from Suc.hyps obtain m where m: "m > f n" "s (f n) < s m" by blast
wenzelm@32960
   768
        with Nfn have mN: "m > N" by arith
wenzelm@32960
   769
        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
   770
        
wenzelm@32960
   771
        from key have th0: "f (Suc n) > N" by simp
wenzelm@32960
   772
        from N[rule_format, OF th0]
wenzelm@32960
   773
        obtain m' where m': "m' \<ge> f (Suc n)" "s (f (Suc n)) < s m'" by blast
wenzelm@32960
   774
        have "m' \<noteq> f (Suc (n))" apply (rule ccontr) using m'(2) by auto
wenzelm@32960
   775
        hence "m' > f (Suc n)" using m'(1) by simp
wenzelm@32960
   776
        with key m'(2) show ?case by auto
chaieb@30196
   777
      qed}
chaieb@30196
   778
    note fSuc = this
chaieb@30196
   779
    {fix n
chaieb@30196
   780
      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
   781
      hence "f n \<ge> Suc N" "f(Suc n) > f n" "s(f n) < s(f(Suc n))" by blast+}
chaieb@30196
   782
    note thf = this
chaieb@30196
   783
    have sqf: "subseq f" unfolding subseq_Suc_iff using thf by simp
chaieb@30196
   784
    have "monoseq (\<lambda>n. s (f n))"  unfolding monoseq_Suc using thf
chaieb@30196
   785
      apply -
chaieb@30196
   786
      apply (rule disjI1)
chaieb@30196
   787
      apply auto
chaieb@30196
   788
      apply (rule order_less_imp_le)
chaieb@30196
   789
      apply blast
chaieb@30196
   790
      done
chaieb@30196
   791
    then have ?thesis  using sqf by blast}
chaieb@30196
   792
  ultimately show ?thesis unfolding linorder_not_less[symmetric] by blast
chaieb@30196
   793
qed
chaieb@30196
   794
chaieb@30196
   795
lemma seq_suble: assumes sf: "subseq f" shows "n \<le> f n"
chaieb@30196
   796
proof(induct n)
chaieb@30196
   797
  case 0 thus ?case by simp
chaieb@30196
   798
next
chaieb@30196
   799
  case (Suc n)
chaieb@30196
   800
  from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps
chaieb@30196
   801
  have "n < f (Suc n)" by arith 
chaieb@30196
   802
  thus ?case by arith
chaieb@30196
   803
qed
chaieb@30196
   804
paulson@30730
   805
lemma LIMSEQ_subseq_LIMSEQ:
paulson@30730
   806
  "\<lbrakk> X ----> L; subseq f \<rbrakk> \<Longrightarrow> (X o f) ----> L"
paulson@30730
   807
apply (auto simp add: LIMSEQ_def) 
paulson@30730
   808
apply (drule_tac x=r in spec, clarify)  
paulson@30730
   809
apply (rule_tac x=no in exI, clarify) 
paulson@30730
   810
apply (blast intro: seq_suble le_trans dest!: spec) 
paulson@30730
   811
done
paulson@30730
   812
chaieb@30196
   813
subsection {* Bounded Monotonic Sequences *}
chaieb@30196
   814
chaieb@30196
   815
huffman@20696
   816
text{*Bounded Sequence*}
paulson@15082
   817
huffman@20552
   818
lemma BseqD: "Bseq X ==> \<exists>K. 0 < K & (\<forall>n. norm (X n) \<le> K)"
paulson@15082
   819
by (simp add: Bseq_def)
paulson@15082
   820
huffman@20552
   821
lemma BseqI: "[| 0 < K; \<forall>n. norm (X n) \<le> K |] ==> Bseq X"
paulson@15082
   822
by (auto simp add: Bseq_def)
paulson@15082
   823
paulson@15082
   824
lemma lemma_NBseq_def:
huffman@20552
   825
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) =
huffman@20552
   826
      (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
haftmann@32064
   827
proof auto
haftmann@32064
   828
  fix K :: real
haftmann@32064
   829
  from reals_Archimedean2 obtain n :: nat where "K < real n" ..
haftmann@32064
   830
  then have "K \<le> real (Suc n)" by auto
haftmann@32064
   831
  assume "\<forall>m. norm (X m) \<le> K"
haftmann@32064
   832
  have "\<forall>m. norm (X m) \<le> real (Suc n)"
haftmann@32064
   833
  proof
haftmann@32064
   834
    fix m :: 'a
haftmann@32064
   835
    from `\<forall>m. norm (X m) \<le> K` have "norm (X m) \<le> K" ..
haftmann@32064
   836
    with `K \<le> real (Suc n)` show "norm (X m) \<le> real (Suc n)" by auto
haftmann@32064
   837
  qed
haftmann@32064
   838
  then show "\<exists>N. \<forall>n. norm (X n) \<le> real (Suc N)" ..
haftmann@32064
   839
next
haftmann@32064
   840
  fix N :: nat
haftmann@32064
   841
  have "real (Suc N) > 0" by (simp add: real_of_nat_Suc)
haftmann@32064
   842
  moreover assume "\<forall>n. norm (X n) \<le> real (Suc N)"
haftmann@32064
   843
  ultimately show "\<exists>K>0. \<forall>n. norm (X n) \<le> K" by blast
haftmann@32064
   844
qed
haftmann@32064
   845
paulson@15082
   846
paulson@15082
   847
text{* alternative definition for Bseq *}
huffman@20552
   848
lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
paulson@15082
   849
apply (simp add: Bseq_def)
paulson@15082
   850
apply (simp (no_asm) add: lemma_NBseq_def)
paulson@15082
   851
done
paulson@15082
   852
paulson@15082
   853
lemma lemma_NBseq_def2:
huffman@20552
   854
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   855
apply (subst lemma_NBseq_def, auto)
paulson@15082
   856
apply (rule_tac x = "Suc N" in exI)
paulson@15082
   857
apply (rule_tac [2] x = N in exI)
paulson@15082
   858
apply (auto simp add: real_of_nat_Suc)
paulson@15082
   859
 prefer 2 apply (blast intro: order_less_imp_le)
paulson@15082
   860
apply (drule_tac x = n in spec, simp)
paulson@15082
   861
done
paulson@15082
   862
paulson@15082
   863
(* yet another definition for Bseq *)
huffman@20552
   864
lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   865
by (simp add: Bseq_def lemma_NBseq_def2)
paulson@15082
   866
huffman@20696
   867
subsubsection{*Upper Bounds and Lubs of Bounded Sequences*}
paulson@15082
   868
paulson@15082
   869
lemma Bseq_isUb:
paulson@15082
   870
  "!!(X::nat=>real). Bseq X ==> \<exists>U. isUb (UNIV::real set) {x. \<exists>n. X n = x} U"
huffman@22998
   871
by (auto intro: isUbI setleI simp add: Bseq_def abs_le_iff)
paulson@15082
   872
paulson@15082
   873
paulson@15082
   874
text{* Use completeness of reals (supremum property)
paulson@15082
   875
   to show that any bounded sequence has a least upper bound*}
paulson@15082
   876
paulson@15082
   877
lemma Bseq_isLub:
paulson@15082
   878
  "!!(X::nat=>real). Bseq X ==>
paulson@15082
   879
   \<exists>U. isLub (UNIV::real set) {x. \<exists>n. X n = x} U"
paulson@15082
   880
by (blast intro: reals_complete Bseq_isUb)
paulson@15082
   881
huffman@20696
   882
subsubsection{*A Bounded and Monotonic Sequence Converges*}
paulson@15082
   883
paulson@15082
   884
lemma lemma_converg1:
nipkow@15360
   885
     "!!(X::nat=>real). [| \<forall>m. \<forall> n \<ge> m. X m \<le> X n;
paulson@15082
   886
                  isLub (UNIV::real set) {x. \<exists>n. X n = x} (X ma)
nipkow@15360
   887
               |] ==> \<forall>n \<ge> ma. X n = X ma"
paulson@15082
   888
apply safe
paulson@15082
   889
apply (drule_tac y = "X n" in isLubD2)
paulson@15082
   890
apply (blast dest: order_antisym)+
paulson@15082
   891
done
paulson@15082
   892
paulson@15082
   893
text{* The best of both worlds: Easier to prove this result as a standard
paulson@15082
   894
   theorem and then use equivalence to "transfer" it into the
paulson@15082
   895
   equivalent nonstandard form if needed!*}
paulson@15082
   896
paulson@15082
   897
lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)"
paulson@15082
   898
apply (simp add: LIMSEQ_def)
paulson@15082
   899
apply (rule_tac x = "X m" in exI, safe)
paulson@15082
   900
apply (rule_tac x = m in exI, safe)
paulson@15082
   901
apply (drule spec, erule impE, auto)
paulson@15082
   902
done
paulson@15082
   903
paulson@15082
   904
lemma lemma_converg2:
paulson@15082
   905
   "!!(X::nat=>real).
paulson@15082
   906
    [| \<forall>m. X m ~= U;  isLub UNIV {x. \<exists>n. X n = x} U |] ==> \<forall>m. X m < U"
paulson@15082
   907
apply safe
paulson@15082
   908
apply (drule_tac y = "X m" in isLubD2)
paulson@15082
   909
apply (auto dest!: order_le_imp_less_or_eq)
paulson@15082
   910
done
paulson@15082
   911
paulson@15082
   912
lemma lemma_converg3: "!!(X ::nat=>real). \<forall>m. X m \<le> U ==> isUb UNIV {x. \<exists>n. X n = x} U"
paulson@15082
   913
by (rule setleI [THEN isUbI], auto)
paulson@15082
   914
paulson@15082
   915
text{* FIXME: @{term "U - T < U"} is redundant *}
paulson@15082
   916
lemma lemma_converg4: "!!(X::nat=> real).
paulson@15082
   917
               [| \<forall>m. X m ~= U;
paulson@15082
   918
                  isLub UNIV {x. \<exists>n. X n = x} U;
paulson@15082
   919
                  0 < T;
paulson@15082
   920
                  U + - T < U
paulson@15082
   921
               |] ==> \<exists>m. U + -T < X m & X m < U"
paulson@15082
   922
apply (drule lemma_converg2, assumption)
paulson@15082
   923
apply (rule ccontr, simp)
paulson@15082
   924
apply (simp add: linorder_not_less)
paulson@15082
   925
apply (drule lemma_converg3)
paulson@15082
   926
apply (drule isLub_le_isUb, assumption)
paulson@15082
   927
apply (auto dest: order_less_le_trans)
paulson@15082
   928
done
paulson@15082
   929
paulson@15082
   930
text{*A standard proof of the theorem for monotone increasing sequence*}
paulson@15082
   931
paulson@15082
   932
lemma Bseq_mono_convergent:
huffman@20552
   933
     "[| Bseq X; \<forall>m. \<forall>n \<ge> m. X m \<le> X n |] ==> convergent (X::nat=>real)"
paulson@15082
   934
apply (simp add: convergent_def)
paulson@15082
   935
apply (frule Bseq_isLub, safe)
paulson@15082
   936
apply (case_tac "\<exists>m. X m = U", auto)
paulson@15082
   937
apply (blast dest: lemma_converg1 Bmonoseq_LIMSEQ)
paulson@15082
   938
(* second case *)
paulson@15082
   939
apply (rule_tac x = U in exI)
paulson@15082
   940
apply (subst LIMSEQ_iff, safe)
paulson@15082
   941
apply (frule lemma_converg2, assumption)
paulson@15082
   942
apply (drule lemma_converg4, auto)
paulson@15082
   943
apply (rule_tac x = m in exI, safe)
paulson@15082
   944
apply (subgoal_tac "X m \<le> X n")
paulson@15082
   945
 prefer 2 apply blast
paulson@15082
   946
apply (drule_tac x=n and P="%m. X m < U" in spec, arith)
paulson@15082
   947
done
paulson@15082
   948
paulson@15082
   949
lemma Bseq_minus_iff: "Bseq (%n. -(X n)) = Bseq X"
paulson@15082
   950
by (simp add: Bseq_def)
paulson@15082
   951
paulson@15082
   952
text{*Main monotonicity theorem*}
paulson@15082
   953
lemma Bseq_monoseq_convergent: "[| Bseq X; monoseq X |] ==> convergent X"
paulson@15082
   954
apply (simp add: monoseq_def, safe)
paulson@15082
   955
apply (rule_tac [2] convergent_minus_iff [THEN ssubst])
paulson@15082
   956
apply (drule_tac [2] Bseq_minus_iff [THEN ssubst])
paulson@15082
   957
apply (auto intro!: Bseq_mono_convergent)
paulson@15082
   958
done
paulson@15082
   959
paulson@30730
   960
subsubsection{*Increasing and Decreasing Series*}
paulson@30730
   961
paulson@30730
   962
lemma incseq_imp_monoseq:  "incseq X \<Longrightarrow> monoseq X"
paulson@30730
   963
  by (simp add: incseq_def monoseq_def) 
paulson@30730
   964
paulson@30730
   965
lemma incseq_le: assumes inc: "incseq X" and lim: "X ----> L" shows "X n \<le> L"
paulson@30730
   966
  using monoseq_le [OF incseq_imp_monoseq [OF inc] lim]
paulson@30730
   967
proof
paulson@30730
   968
  assume "(\<forall>n. X n \<le> L) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n)"
paulson@30730
   969
  thus ?thesis by simp
paulson@30730
   970
next
paulson@30730
   971
  assume "(\<forall>n. L \<le> X n) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X n \<le> X m)"
paulson@30730
   972
  hence const: "(!!m n. m \<le> n \<Longrightarrow> X n = X m)" using inc
paulson@30730
   973
    by (auto simp add: incseq_def intro: order_antisym)
paulson@30730
   974
  have X: "!!n. X n = X 0"
paulson@30730
   975
    by (blast intro: const [of 0]) 
paulson@30730
   976
  have "X = (\<lambda>n. X 0)"
paulson@30730
   977
    by (blast intro: ext X)
paulson@30730
   978
  hence "L = X 0" using LIMSEQ_const [of "X 0"]
paulson@30730
   979
    by (auto intro: LIMSEQ_unique lim) 
paulson@30730
   980
  thus ?thesis
paulson@30730
   981
    by (blast intro: eq_refl X)
paulson@30730
   982
qed
paulson@30730
   983
paulson@30730
   984
lemma decseq_imp_monoseq:  "decseq X \<Longrightarrow> monoseq X"
paulson@30730
   985
  by (simp add: decseq_def monoseq_def)
paulson@30730
   986
paulson@30730
   987
lemma decseq_eq_incseq: "decseq X = incseq (\<lambda>n. - X n)" 
paulson@30730
   988
  by (simp add: decseq_def incseq_def)
paulson@30730
   989
paulson@30730
   990
paulson@30730
   991
lemma decseq_le: assumes dec: "decseq X" and lim: "X ----> L" shows "L \<le> X n"
paulson@30730
   992
proof -
paulson@30730
   993
  have inc: "incseq (\<lambda>n. - X n)" using dec
paulson@30730
   994
    by (simp add: decseq_eq_incseq)
paulson@30730
   995
  have "- X n \<le> - L" 
paulson@30730
   996
    by (blast intro: incseq_le [OF inc] LIMSEQ_minus lim) 
paulson@30730
   997
  thus ?thesis
paulson@30730
   998
    by simp
paulson@30730
   999
qed
paulson@30730
  1000
huffman@20696
  1001
subsubsection{*A Few More Equivalence Theorems for Boundedness*}
paulson@15082
  1002
paulson@15082
  1003
text{*alternative formulation for boundedness*}
huffman@20552
  1004
lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)"
paulson@15082
  1005
apply (unfold Bseq_def, safe)
huffman@20552
  1006
apply (rule_tac [2] x = "k + norm x" in exI)
nipkow@15360
  1007
apply (rule_tac x = K in exI, simp)
paulson@15221
  1008
apply (rule exI [where x = 0], auto)
huffman@20552
  1009
apply (erule order_less_le_trans, simp)
huffman@20552
  1010
apply (drule_tac x=n in spec, fold diff_def)
huffman@20552
  1011
apply (drule order_trans [OF norm_triangle_ineq2])
huffman@20552
  1012
apply simp
paulson@15082
  1013
done
paulson@15082
  1014
paulson@15082
  1015
text{*alternative formulation for boundedness*}
huffman@20552
  1016
lemma Bseq_iff3: "Bseq X = (\<exists>k > 0. \<exists>N. \<forall>n. norm(X(n) + -X(N)) \<le> k)"
paulson@15082
  1017
apply safe
paulson@15082
  1018
apply (simp add: Bseq_def, safe)
huffman@20552
  1019
apply (rule_tac x = "K + norm (X N)" in exI)
paulson@15082
  1020
apply auto
huffman@20552
  1021
apply (erule order_less_le_trans, simp)
paulson@15082
  1022
apply (rule_tac x = N in exI, safe)
huffman@20552
  1023
apply (drule_tac x = n in spec)
huffman@20552
  1024
apply (rule order_trans [OF norm_triangle_ineq], simp)
paulson@15082
  1025
apply (auto simp add: Bseq_iff2)
paulson@15082
  1026
done
paulson@15082
  1027
huffman@20552
  1028
lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f"
paulson@15082
  1029
apply (simp add: Bseq_def)
paulson@15221
  1030
apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto)
webertj@20217
  1031
apply (drule_tac x = n in spec, arith)
paulson@15082
  1032
done
paulson@15082
  1033
paulson@15082
  1034
huffman@20696
  1035
subsection {* Cauchy Sequences *}
paulson@15082
  1036
huffman@31336
  1037
lemma metric_CauchyI:
huffman@31336
  1038
  "(\<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
  1039
by (simp add: Cauchy_def)
huffman@31336
  1040
huffman@31336
  1041
lemma metric_CauchyD:
huffman@31336
  1042
  "\<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
  1043
by (simp add: Cauchy_def)
huffman@20751
  1044
huffman@31336
  1045
lemma Cauchy_iff:
huffman@31336
  1046
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1047
  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
  1048
unfolding Cauchy_def dist_norm ..
huffman@31336
  1049
huffman@31336
  1050
lemma CauchyI:
huffman@31336
  1051
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1052
  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
  1053
by (simp add: Cauchy_iff)
huffman@31336
  1054
huffman@20751
  1055
lemma CauchyD:
huffman@31336
  1056
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
  1057
  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
  1058
by (simp add: Cauchy_iff)
huffman@20751
  1059
paulson@30730
  1060
lemma Cauchy_subseq_Cauchy:
paulson@30730
  1061
  "\<lbrakk> Cauchy X; subseq f \<rbrakk> \<Longrightarrow> Cauchy (X o f)"
huffman@31336
  1062
apply (auto simp add: Cauchy_def)
huffman@31336
  1063
apply (drule_tac x=e in spec, clarify)
huffman@31336
  1064
apply (rule_tac x=M in exI, clarify)
huffman@31336
  1065
apply (blast intro: le_trans [OF _ seq_suble] dest!: spec)
paulson@30730
  1066
done
paulson@30730
  1067
huffman@20696
  1068
subsubsection {* Cauchy Sequences are Bounded *}
huffman@20696
  1069
paulson@15082
  1070
text{*A Cauchy sequence is bounded -- this is the standard
paulson@15082
  1071
  proof mechanization rather than the nonstandard proof*}
paulson@15082
  1072
huffman@20563
  1073
lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real)
huffman@20552
  1074
          ==>  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
huffman@20552
  1075
apply (clarify, drule spec, drule (1) mp)
huffman@20563
  1076
apply (simp only: norm_minus_commute)
huffman@20552
  1077
apply (drule order_le_less_trans [OF norm_triangle_ineq2])
huffman@20552
  1078
apply simp
huffman@20552
  1079
done
paulson@15082
  1080
paulson@15082
  1081
lemma Cauchy_Bseq: "Cauchy X ==> Bseq X"
huffman@31336
  1082
apply (simp add: Cauchy_iff)
huffman@20552
  1083
apply (drule spec, drule mp, rule zero_less_one, safe)
huffman@20552
  1084
apply (drule_tac x="M" in spec, simp)
paulson@15082
  1085
apply (drule lemmaCauchy)
huffman@22608
  1086
apply (rule_tac k="M" in Bseq_offset)
huffman@20552
  1087
apply (simp add: Bseq_def)
huffman@20552
  1088
apply (rule_tac x="1 + norm (X M)" in exI)
huffman@20552
  1089
apply (rule conjI, rule order_less_le_trans [OF zero_less_one], simp)
huffman@20552
  1090
apply (simp add: order_less_imp_le)
paulson@15082
  1091
done
paulson@15082
  1092
huffman@20696
  1093
subsubsection {* Cauchy Sequences are Convergent *}
paulson@15082
  1094
haftmann@33042
  1095
class complete_space =
haftmann@33042
  1096
  assumes Cauchy_convergent: "Cauchy X \<Longrightarrow> convergent X"
huffman@20830
  1097
haftmann@33042
  1098
class banach = real_normed_vector + complete_space
huffman@31403
  1099
huffman@22629
  1100
theorem LIMSEQ_imp_Cauchy:
huffman@22629
  1101
  assumes X: "X ----> a" shows "Cauchy X"
huffman@31336
  1102
proof (rule metric_CauchyI)
huffman@22629
  1103
  fix e::real assume "0 < e"
huffman@22629
  1104
  hence "0 < e/2" by simp
huffman@31336
  1105
  with X have "\<exists>N. \<forall>n\<ge>N. dist (X n) a < e/2" by (rule metric_LIMSEQ_D)
huffman@31336
  1106
  then obtain N where N: "\<forall>n\<ge>N. dist (X n) a < e/2" ..
huffman@31336
  1107
  show "\<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. dist (X m) (X n) < e"
huffman@22629
  1108
  proof (intro exI allI impI)
huffman@22629
  1109
    fix m assume "N \<le> m"
huffman@31336
  1110
    hence m: "dist (X m) a < e/2" using N by fast
huffman@22629
  1111
    fix n assume "N \<le> n"
huffman@31336
  1112
    hence n: "dist (X n) a < e/2" using N by fast
huffman@31336
  1113
    have "dist (X m) (X n) \<le> dist (X m) a + dist (X n) a"
huffman@31336
  1114
      by (rule dist_triangle2)
huffman@31336
  1115
    also from m n have "\<dots> < e" by simp
huffman@31336
  1116
    finally show "dist (X m) (X n) < e" .
huffman@22629
  1117
  qed
huffman@22629
  1118
qed
huffman@22629
  1119
huffman@20691
  1120
lemma convergent_Cauchy: "convergent X \<Longrightarrow> Cauchy X"
huffman@22629
  1121
unfolding convergent_def
huffman@22629
  1122
by (erule exE, erule LIMSEQ_imp_Cauchy)
huffman@20691
  1123
huffman@31403
  1124
lemma Cauchy_convergent_iff:
huffman@31403
  1125
  fixes X :: "nat \<Rightarrow> 'a::complete_space"
huffman@31403
  1126
  shows "Cauchy X = convergent X"
huffman@31403
  1127
by (fast intro: Cauchy_convergent convergent_Cauchy)
huffman@31403
  1128
huffman@31403
  1129
lemma convergent_subseq_convergent:
huffman@31403
  1130
  fixes X :: "nat \<Rightarrow> 'a::complete_space"
huffman@31403
  1131
  shows "\<lbrakk> convergent X; subseq f \<rbrakk> \<Longrightarrow> convergent (X o f)"
huffman@31403
  1132
  by (simp add: Cauchy_subseq_Cauchy Cauchy_convergent_iff [symmetric])
huffman@31403
  1133
huffman@22629
  1134
text {*
huffman@22629
  1135
Proof that Cauchy sequences converge based on the one from
huffman@22629
  1136
http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html
huffman@22629
  1137
*}
huffman@22629
  1138
huffman@22629
  1139
text {*
huffman@22629
  1140
  If sequence @{term "X"} is Cauchy, then its limit is the lub of
huffman@22629
  1141
  @{term "{r::real. \<exists>N. \<forall>n\<ge>N. r < X n}"}
huffman@22629
  1142
*}
huffman@22629
  1143
huffman@22629
  1144
lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
huffman@22629
  1145
by (simp add: isUbI setleI)
huffman@22629
  1146
haftmann@27681
  1147
locale real_Cauchy =
huffman@22629
  1148
  fixes X :: "nat \<Rightarrow> real"
huffman@22629
  1149
  assumes X: "Cauchy X"
huffman@22629
  1150
  fixes S :: "real set"
huffman@22629
  1151
  defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
huffman@22629
  1152
haftmann@27681
  1153
lemma real_CauchyI:
haftmann@27681
  1154
  assumes "Cauchy X"
haftmann@27681
  1155
  shows "real_Cauchy X"
haftmann@28823
  1156
  proof qed (fact assms)
haftmann@27681
  1157
huffman@22629
  1158
lemma (in real_Cauchy) mem_S: "\<forall>n\<ge>N. x < X n \<Longrightarrow> x \<in> S"
huffman@22629
  1159
by (unfold S_def, auto)
huffman@22629
  1160
huffman@22629
  1161
lemma (in real_Cauchy) bound_isUb:
huffman@22629
  1162
  assumes N: "\<forall>n\<ge>N. X n < x"
huffman@22629
  1163
  shows "isUb UNIV S x"
huffman@22629
  1164
proof (rule isUb_UNIV_I)
huffman@22629
  1165
  fix y::real assume "y \<in> S"
huffman@22629
  1166
  hence "\<exists>M. \<forall>n\<ge>M. y < X n"
huffman@22629
  1167
    by (simp add: S_def)
huffman@22629
  1168
  then obtain M where "\<forall>n\<ge>M. y < X n" ..
huffman@22629
  1169
  hence "y < X (max M N)" by simp
huffman@22629
  1170
  also have "\<dots> < x" using N by simp
huffman@22629
  1171
  finally show "y \<le> x"
huffman@22629
  1172
    by (rule order_less_imp_le)
huffman@22629
  1173
qed
huffman@22629
  1174
huffman@22629
  1175
lemma (in real_Cauchy) isLub_ex: "\<exists>u. isLub UNIV S u"
huffman@22629
  1176
proof (rule reals_complete)
huffman@22629
  1177
  obtain N where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (X m - X n) < 1"
haftmann@32064
  1178
    using CauchyD [OF X zero_less_one] by auto
huffman@22629
  1179
  hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
huffman@22629
  1180
  show "\<exists>x. x \<in> S"
huffman@22629
  1181
  proof
huffman@22629
  1182
    from N have "\<forall>n\<ge>N. X N - 1 < X n"
paulson@32707
  1183
      by (simp add: abs_diff_less_iff)
huffman@22629
  1184
    thus "X N - 1 \<in> S" by (rule mem_S)
huffman@22629
  1185
  qed
huffman@22629
  1186
  show "\<exists>u. isUb UNIV S u"
huffman@22629
  1187
  proof
huffman@22629
  1188
    from N have "\<forall>n\<ge>N. X n < X N + 1"
paulson@32707
  1189
      by (simp add: abs_diff_less_iff)
huffman@22629
  1190
    thus "isUb UNIV S (X N + 1)"
huffman@22629
  1191
      by (rule bound_isUb)
huffman@22629
  1192
  qed
huffman@22629
  1193
qed
huffman@22629
  1194
huffman@22629
  1195
lemma (in real_Cauchy) isLub_imp_LIMSEQ:
huffman@22629
  1196
  assumes x: "isLub UNIV S x"
huffman@22629
  1197
  shows "X ----> x"
huffman@22629
  1198
proof (rule LIMSEQ_I)
huffman@22629
  1199
  fix r::real assume "0 < r"
huffman@22629
  1200
  hence r: "0 < r/2" by simp
huffman@22629
  1201
  obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
haftmann@32064
  1202
    using CauchyD [OF X r] by auto
huffman@22629
  1203
  hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
huffman@22629
  1204
  hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
paulson@32707
  1205
    by (simp only: real_norm_def abs_diff_less_iff)
huffman@22629
  1206
huffman@22629
  1207
  from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
huffman@22629
  1208
  hence "X N - r/2 \<in> S" by (rule mem_S)
nipkow@23482
  1209
  hence 1: "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
huffman@22629
  1210
huffman@22629
  1211
  from N have "\<forall>n\<ge>N. X n < X N + r/2" by fast
huffman@22629
  1212
  hence "isUb UNIV S (X N + r/2)" by (rule bound_isUb)
nipkow@23482
  1213
  hence 2: "x \<le> X N + r/2" using x isLub_le_isUb by fast
huffman@22629
  1214
huffman@22629
  1215
  show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
huffman@22629
  1216
  proof (intro exI allI impI)
huffman@22629
  1217
    fix n assume n: "N \<le> n"
nipkow@23482
  1218
    from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+
nipkow@23482
  1219
    thus "norm (X n - x) < r" using 1 2
paulson@32707
  1220
      by (simp add: abs_diff_less_iff)
huffman@22629
  1221
  qed
huffman@22629
  1222
qed
huffman@22629
  1223
huffman@22629
  1224
lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
huffman@22629
  1225
proof -
huffman@22629
  1226
  obtain x where "isLub UNIV S x"
huffman@22629
  1227
    using isLub_ex by fast
huffman@22629
  1228
  hence "X ----> x"
huffman@22629
  1229
    by (rule isLub_imp_LIMSEQ)
huffman@22629
  1230
  thus ?thesis ..
huffman@22629
  1231
qed
huffman@22629
  1232
huffman@20830
  1233
lemma real_Cauchy_convergent:
huffman@20830
  1234
  fixes X :: "nat \<Rightarrow> real"
huffman@20830
  1235
  shows "Cauchy X \<Longrightarrow> convergent X"
haftmann@27681
  1236
unfolding convergent_def
haftmann@27681
  1237
by (rule real_Cauchy.LIMSEQ_ex)
haftmann@27681
  1238
 (rule real_CauchyI)
huffman@20830
  1239
huffman@20830
  1240
instance real :: banach
huffman@20830
  1241
by intro_classes (rule real_Cauchy_convergent)
huffman@20830
  1242
paulson@15082
  1243
huffman@20696
  1244
subsection {* Power Sequences *}
paulson@15082
  1245
paulson@15082
  1246
text{*The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
paulson@15082
  1247
"x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
paulson@15082
  1248
  also fact that bounded and monotonic sequence converges.*}
paulson@15082
  1249
huffman@20552
  1250
lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)"
paulson@15082
  1251
apply (simp add: Bseq_def)
paulson@15082
  1252
apply (rule_tac x = 1 in exI)
paulson@15082
  1253
apply (simp add: power_abs)
huffman@22974
  1254
apply (auto dest: power_mono)
paulson@15082
  1255
done
paulson@15082
  1256
paulson@15082
  1257
lemma monoseq_realpow: "[| 0 \<le> x; x \<le> 1 |] ==> monoseq (%n. x ^ n)"
paulson@15082
  1258
apply (clarify intro!: mono_SucI2)
paulson@15082
  1259
apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing, auto)
paulson@15082
  1260
done
paulson@15082
  1261
huffman@20552
  1262
lemma convergent_realpow:
huffman@20552
  1263
  "[| 0 \<le> (x::real); x \<le> 1 |] ==> convergent (%n. x ^ n)"
paulson@15082
  1264
by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
paulson@15082
  1265
huffman@22628
  1266
lemma LIMSEQ_inverse_realpow_zero_lemma:
huffman@22628
  1267
  fixes x :: real
huffman@22628
  1268
  assumes x: "0 \<le> x"
huffman@22628
  1269
  shows "real n * x + 1 \<le> (x + 1) ^ n"
huffman@22628
  1270
apply (induct n)
huffman@22628
  1271
apply simp
huffman@22628
  1272
apply simp
huffman@22628
  1273
apply (rule order_trans)
huffman@22628
  1274
prefer 2
huffman@22628
  1275
apply (erule mult_left_mono)
huffman@22628
  1276
apply (rule add_increasing [OF x], simp)
huffman@22628
  1277
apply (simp add: real_of_nat_Suc)
nipkow@23477
  1278
apply (simp add: ring_distribs)
huffman@22628
  1279
apply (simp add: mult_nonneg_nonneg x)
huffman@22628
  1280
done
huffman@22628
  1281
huffman@22628
  1282
lemma LIMSEQ_inverse_realpow_zero:
huffman@22628
  1283
  "1 < (x::real) \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) ----> 0"
huffman@22628
  1284
proof (rule LIMSEQ_inverse_zero [rule_format])
huffman@22628
  1285
  fix y :: real
huffman@22628
  1286
  assume x: "1 < x"
huffman@22628
  1287
  hence "0 < x - 1" by simp
huffman@22628
  1288
  hence "\<forall>y. \<exists>N::nat. y < real N * (x - 1)"
huffman@22628
  1289
    by (rule reals_Archimedean3)
huffman@22628
  1290
  hence "\<exists>N::nat. y < real N * (x - 1)" ..
huffman@22628
  1291
  then obtain N::nat where "y < real N * (x - 1)" ..
huffman@22628
  1292
  also have "\<dots> \<le> real N * (x - 1) + 1" by simp
huffman@22628
  1293
  also have "\<dots> \<le> (x - 1 + 1) ^ N"
huffman@22628
  1294
    by (rule LIMSEQ_inverse_realpow_zero_lemma, cut_tac x, simp)
huffman@22628
  1295
  also have "\<dots> = x ^ N" by simp
huffman@22628
  1296
  finally have "y < x ^ N" .
huffman@22628
  1297
  hence "\<forall>n\<ge>N. y < x ^ n"
huffman@22628
  1298
    apply clarify
huffman@22628
  1299
    apply (erule order_less_le_trans)
huffman@22628
  1300
    apply (erule power_increasing)
huffman@22628
  1301
    apply (rule order_less_imp_le [OF x])
huffman@22628
  1302
    done
huffman@22628
  1303
  thus "\<exists>N. \<forall>n\<ge>N. y < x ^ n" ..
huffman@22628
  1304
qed
huffman@22628
  1305
huffman@20552
  1306
lemma LIMSEQ_realpow_zero:
huffman@22628
  1307
  "\<lbrakk>0 \<le> (x::real); x < 1\<rbrakk> \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@22628
  1308
proof (cases)
huffman@22628
  1309
  assume "x = 0"
huffman@22628
  1310
  hence "(\<lambda>n. x ^ Suc n) ----> 0" by (simp add: LIMSEQ_const)
huffman@22628
  1311
  thus ?thesis by (rule LIMSEQ_imp_Suc)
huffman@22628
  1312
next
huffman@22628
  1313
  assume "0 \<le> x" and "x \<noteq> 0"
huffman@22628
  1314
  hence x0: "0 < x" by simp
huffman@22628
  1315
  assume x1: "x < 1"
huffman@22628
  1316
  from x0 x1 have "1 < inverse x"
huffman@22628
  1317
    by (rule real_inverse_gt_one)
huffman@22628
  1318
  hence "(\<lambda>n. inverse (inverse x ^ n)) ----> 0"
huffman@22628
  1319
    by (rule LIMSEQ_inverse_realpow_zero)
huffman@22628
  1320
  thus ?thesis by (simp add: power_inverse)
huffman@22628
  1321
qed
paulson@15082
  1322
huffman@20685
  1323
lemma LIMSEQ_power_zero:
haftmann@31017
  1324
  fixes x :: "'a::{real_normed_algebra_1}"
huffman@20685
  1325
  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@20685
  1326
apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
huffman@22974
  1327
apply (simp only: LIMSEQ_Zseq_iff, erule Zseq_le)
huffman@22974
  1328
apply (simp add: power_abs norm_power_ineq)
huffman@20685
  1329
done
huffman@20685
  1330
huffman@20552
  1331
lemma LIMSEQ_divide_realpow_zero:
huffman@20552
  1332
  "1 < (x::real) ==> (%n. a / (x ^ n)) ----> 0"
paulson@15082
  1333
apply (cut_tac a = a and x1 = "inverse x" in
paulson@15082
  1334
        LIMSEQ_mult [OF LIMSEQ_const LIMSEQ_realpow_zero])
paulson@15082
  1335
apply (auto simp add: divide_inverse power_inverse)
paulson@15082
  1336
apply (simp add: inverse_eq_divide pos_divide_less_eq)
paulson@15082
  1337
done
paulson@15082
  1338
paulson@15102
  1339
text{*Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}*}
paulson@15082
  1340
huffman@20552
  1341
lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < (1::real) ==> (%n. \<bar>c\<bar> ^ n) ----> 0"
huffman@20685
  1342
by (rule LIMSEQ_realpow_zero [OF abs_ge_zero])
paulson@15082
  1343
huffman@20552
  1344
lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < (1::real) ==> (%n. c ^ n) ----> 0"
paulson@15082
  1345
apply (rule LIMSEQ_rabs_zero [THEN iffD1])
paulson@15082
  1346
apply (auto intro: LIMSEQ_rabs_realpow_zero simp add: power_abs)
paulson@15082
  1347
done
paulson@15082
  1348
paulson@10751
  1349
end