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