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