src/HOL/Hyperreal/SEQ.thy
author huffman
Mon May 14 22:32:51 2007 +0200 (2007-05-14)
changeset 22974 08b0fa905ea0
parent 22631 7ae5a6ab7bd6
child 22998 97e1f9c2cc46
permissions -rw-r--r--
tuned proofs
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@22631
    12
imports "../Real/Real"
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*}
huffman@22608
    18
  "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*}
huffman@20563
    24
  "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*}
huffman@20552
    39
  "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@15082
    43
    --{*Definition for monotonicity*}
wenzelm@19765
    44
  "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
    45
wenzelm@21404
    46
definition
wenzelm@21404
    47
  subseq :: "(nat => nat) => bool" where
paulson@15082
    48
    --{*Definition of subsequence*}
wenzelm@19765
    49
  "subseq f = (\<forall>m. \<forall>n>m. (f m) < (f n))"
paulson@10751
    50
wenzelm@21404
    51
definition
wenzelm@21404
    52
  Cauchy :: "(nat => 'a::real_normed_vector) => bool" where
paulson@15082
    53
    --{*Standard definition of the Cauchy condition*}
huffman@20563
    54
  "Cauchy X = (\<forall>e>0. \<exists>M. \<forall>m \<ge> M. \<forall>n \<ge> M. norm (X m - X n) < e)"
paulson@10751
    55
paulson@15082
    56
huffman@22608
    57
subsection {* Bounded Sequences *}
huffman@22608
    58
huffman@22608
    59
lemma BseqI: assumes K: "\<And>n. norm (X n) \<le> K" shows "Bseq X"
huffman@22608
    60
unfolding Bseq_def
huffman@22608
    61
proof (intro exI conjI allI)
huffman@22608
    62
  show "0 < max K 1" by simp
huffman@22608
    63
next
huffman@22608
    64
  fix n::nat
huffman@22608
    65
  have "norm (X n) \<le> K" by (rule K)
huffman@22608
    66
  thus "norm (X n) \<le> max K 1" by simp
huffman@22608
    67
qed
huffman@22608
    68
huffman@22608
    69
lemma BseqD: "Bseq X \<Longrightarrow> \<exists>K>0. \<forall>n. norm (X n) \<le> K"
huffman@22608
    70
unfolding Bseq_def by simp
huffman@22608
    71
huffman@22608
    72
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
    73
unfolding Bseq_def by auto
huffman@22608
    74
huffman@22608
    75
lemma BseqI2: assumes K: "\<forall>n\<ge>N. norm (X n) \<le> K" shows "Bseq X"
huffman@22608
    76
proof (rule BseqI)
huffman@22608
    77
  let ?A = "norm ` X ` {..N}"
huffman@22608
    78
  have 1: "finite ?A" by simp
huffman@22608
    79
  have 2: "?A \<noteq> {}" by auto
huffman@22608
    80
  fix n::nat
huffman@22608
    81
  show "norm (X n) \<le> max K (Max ?A)"
huffman@22608
    82
  proof (cases rule: linorder_le_cases)
huffman@22608
    83
    assume "n \<ge> N"
huffman@22608
    84
    hence "norm (X n) \<le> K" using K by simp
huffman@22608
    85
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
    86
  next
huffman@22608
    87
    assume "n \<le> N"
huffman@22608
    88
    hence "norm (X n) \<in> ?A" by simp
huffman@22608
    89
    with 1 2 have "norm (X n) \<le> Max ?A" by (rule Max_ge)
huffman@22608
    90
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
    91
  qed
huffman@22608
    92
qed
huffman@22608
    93
huffman@22608
    94
lemma Bseq_ignore_initial_segment: "Bseq X \<Longrightarrow> Bseq (\<lambda>n. X (n + k))"
huffman@22608
    95
unfolding Bseq_def by auto
huffman@22608
    96
huffman@22608
    97
lemma Bseq_offset: "Bseq (\<lambda>n. X (n + k)) \<Longrightarrow> Bseq X"
huffman@22608
    98
apply (erule BseqE)
huffman@22608
    99
apply (rule_tac N="k" and K="K" in BseqI2)
huffman@22608
   100
apply clarify
huffman@22608
   101
apply (drule_tac x="n - k" in spec, simp)
huffman@22608
   102
done
huffman@22608
   103
huffman@22608
   104
huffman@22608
   105
subsection {* Sequences That Converge to Zero *}
huffman@22608
   106
huffman@22608
   107
lemma ZseqI:
huffman@22608
   108
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n) < r) \<Longrightarrow> Zseq X"
huffman@22608
   109
unfolding Zseq_def by simp
huffman@22608
   110
huffman@22608
   111
lemma ZseqD:
huffman@22608
   112
  "\<lbrakk>Zseq X; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n) < r"
huffman@22608
   113
unfolding Zseq_def by simp
huffman@22608
   114
huffman@22608
   115
lemma Zseq_zero: "Zseq (\<lambda>n. 0)"
huffman@22608
   116
unfolding Zseq_def by simp
huffman@22608
   117
huffman@22608
   118
lemma Zseq_const_iff: "Zseq (\<lambda>n. k) = (k = 0)"
huffman@22608
   119
unfolding Zseq_def by force
huffman@22608
   120
huffman@22608
   121
lemma Zseq_norm_iff: "Zseq (\<lambda>n. norm (X n)) = Zseq (\<lambda>n. X n)"
huffman@22608
   122
unfolding Zseq_def by simp
huffman@22608
   123
huffman@22608
   124
lemma Zseq_imp_Zseq:
huffman@22608
   125
  assumes X: "Zseq X"
huffman@22608
   126
  assumes Y: "\<And>n. norm (Y n) \<le> norm (X n) * K"
huffman@22608
   127
  shows "Zseq (\<lambda>n. Y n)"
huffman@22608
   128
proof (cases)
huffman@22608
   129
  assume K: "0 < K"
huffman@22608
   130
  show ?thesis
huffman@22608
   131
  proof (rule ZseqI)
huffman@22608
   132
    fix r::real assume "0 < r"
huffman@22608
   133
    hence "0 < r / K"
huffman@22608
   134
      using K by (rule divide_pos_pos)
huffman@22608
   135
    then obtain N where "\<forall>n\<ge>N. norm (X n) < r / K"
huffman@22608
   136
      using ZseqD [OF X] by fast
huffman@22608
   137
    hence "\<forall>n\<ge>N. norm (X n) * K < r"
huffman@22608
   138
      by (simp add: pos_less_divide_eq K)
huffman@22608
   139
    hence "\<forall>n\<ge>N. norm (Y n) < r"
huffman@22608
   140
      by (simp add: order_le_less_trans [OF Y])
huffman@22608
   141
    thus "\<exists>N. \<forall>n\<ge>N. norm (Y n) < r" ..
huffman@22608
   142
  qed
huffman@22608
   143
next
huffman@22608
   144
  assume "\<not> 0 < K"
huffman@22608
   145
  hence K: "K \<le> 0" by (simp only: linorder_not_less)
huffman@22608
   146
  {
huffman@22608
   147
    fix n::nat
huffman@22608
   148
    have "norm (Y n) \<le> norm (X n) * K" by (rule Y)
huffman@22608
   149
    also have "\<dots> \<le> norm (X n) * 0"
huffman@22608
   150
      using K norm_ge_zero by (rule mult_left_mono)
huffman@22608
   151
    finally have "norm (Y n) = 0" by simp
huffman@22608
   152
  }
huffman@22608
   153
  thus ?thesis by (simp add: Zseq_zero)
huffman@22608
   154
qed
huffman@22608
   155
huffman@22608
   156
lemma Zseq_le: "\<lbrakk>Zseq Y; \<forall>n. norm (X n) \<le> norm (Y n)\<rbrakk> \<Longrightarrow> Zseq X"
huffman@22608
   157
by (erule_tac K="1" in Zseq_imp_Zseq, simp)
huffman@22608
   158
huffman@22608
   159
lemma Zseq_add:
huffman@22608
   160
  assumes X: "Zseq X"
huffman@22608
   161
  assumes Y: "Zseq Y"
huffman@22608
   162
  shows "Zseq (\<lambda>n. X n + Y n)"
huffman@22608
   163
proof (rule ZseqI)
huffman@22608
   164
  fix r::real assume "0 < r"
huffman@22608
   165
  hence r: "0 < r / 2" by simp
huffman@22608
   166
  obtain M where M: "\<forall>n\<ge>M. norm (X n) < r/2"
huffman@22608
   167
    using ZseqD [OF X r] by fast
huffman@22608
   168
  obtain N where N: "\<forall>n\<ge>N. norm (Y n) < r/2"
huffman@22608
   169
    using ZseqD [OF Y r] by fast
huffman@22608
   170
  show "\<exists>N. \<forall>n\<ge>N. norm (X n + Y n) < r"
huffman@22608
   171
  proof (intro exI allI impI)
huffman@22608
   172
    fix n assume n: "max M N \<le> n"
huffman@22608
   173
    have "norm (X n + Y n) \<le> norm (X n) + norm (Y n)"
huffman@22608
   174
      by (rule norm_triangle_ineq)
huffman@22608
   175
    also have "\<dots> < r/2 + r/2"
huffman@22608
   176
    proof (rule add_strict_mono)
huffman@22608
   177
      from M n show "norm (X n) < r/2" by simp
huffman@22608
   178
      from N n show "norm (Y n) < r/2" by simp
huffman@22608
   179
    qed
huffman@22608
   180
    finally show "norm (X n + Y n) < r" by simp
huffman@22608
   181
  qed
huffman@22608
   182
qed
huffman@22608
   183
huffman@22608
   184
lemma Zseq_minus: "Zseq X \<Longrightarrow> Zseq (\<lambda>n. - X n)"
huffman@22608
   185
unfolding Zseq_def by simp
huffman@22608
   186
huffman@22608
   187
lemma Zseq_diff: "\<lbrakk>Zseq X; Zseq Y\<rbrakk> \<Longrightarrow> Zseq (\<lambda>n. X n - Y n)"
huffman@22608
   188
by (simp only: diff_minus Zseq_add Zseq_minus)
huffman@22608
   189
huffman@22608
   190
lemma (in bounded_linear) Zseq:
huffman@22608
   191
  assumes X: "Zseq X"
huffman@22608
   192
  shows "Zseq (\<lambda>n. f (X n))"
huffman@22608
   193
proof -
huffman@22608
   194
  obtain K where "\<And>x. norm (f x) \<le> norm x * K"
huffman@22608
   195
    using bounded by fast
huffman@22608
   196
  with X show ?thesis
huffman@22608
   197
    by (rule Zseq_imp_Zseq)
huffman@22608
   198
qed
huffman@22608
   199
huffman@22608
   200
lemma (in bounded_bilinear) Zseq_prod:
huffman@22608
   201
  assumes X: "Zseq X"
huffman@22608
   202
  assumes Y: "Zseq Y"
huffman@22608
   203
  shows "Zseq (\<lambda>n. X n ** Y n)"
huffman@22608
   204
proof (rule ZseqI)
huffman@22608
   205
  fix r::real assume r: "0 < r"
huffman@22608
   206
  obtain K where K: "0 < K"
huffman@22608
   207
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@22608
   208
    using pos_bounded by fast
huffman@22608
   209
  from K have K': "0 < inverse K"
huffman@22608
   210
    by (rule positive_imp_inverse_positive)
huffman@22608
   211
  obtain M where M: "\<forall>n\<ge>M. norm (X n) < r"
huffman@22608
   212
    using ZseqD [OF X r] by fast
huffman@22608
   213
  obtain N where N: "\<forall>n\<ge>N. norm (Y n) < inverse K"
huffman@22608
   214
    using ZseqD [OF Y K'] by fast
huffman@22608
   215
  show "\<exists>N. \<forall>n\<ge>N. norm (X n ** Y n) < r"
huffman@22608
   216
  proof (intro exI allI impI)
huffman@22608
   217
    fix n assume n: "max M N \<le> n"
huffman@22608
   218
    have "norm (X n ** Y n) \<le> norm (X n) * norm (Y n) * K"
huffman@22608
   219
      by (rule norm_le)
huffman@22608
   220
    also have "norm (X n) * norm (Y n) * K < r * inverse K * K"
huffman@22608
   221
    proof (intro mult_strict_right_mono mult_strict_mono' norm_ge_zero K)
huffman@22608
   222
      from M n show Xn: "norm (X n) < r" by simp
huffman@22608
   223
      from N n show Yn: "norm (Y n) < inverse K" by simp
huffman@22608
   224
    qed
huffman@22608
   225
    also from K have "r * inverse K * K = r" by simp
huffman@22608
   226
    finally show "norm (X n ** Y n) < r" .
huffman@22608
   227
  qed
huffman@22608
   228
qed
huffman@22608
   229
huffman@22608
   230
lemma (in bounded_bilinear) Zseq_prod_Bseq:
huffman@22608
   231
  assumes X: "Zseq X"
huffman@22608
   232
  assumes Y: "Bseq Y"
huffman@22608
   233
  shows "Zseq (\<lambda>n. X n ** Y n)"
huffman@22608
   234
proof -
huffman@22608
   235
  obtain K where K: "0 \<le> K"
huffman@22608
   236
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@22608
   237
    using nonneg_bounded by fast
huffman@22608
   238
  obtain B where B: "0 < B"
huffman@22608
   239
    and norm_Y: "\<And>n. norm (Y n) \<le> B"
huffman@22608
   240
    using Y [unfolded Bseq_def] by fast
huffman@22608
   241
  from X show ?thesis
huffman@22608
   242
  proof (rule Zseq_imp_Zseq)
huffman@22608
   243
    fix n::nat
huffman@22608
   244
    have "norm (X n ** Y n) \<le> norm (X n) * norm (Y n) * K"
huffman@22608
   245
      by (rule norm_le)
huffman@22608
   246
    also have "\<dots> \<le> norm (X n) * B * K"
huffman@22608
   247
      by (intro mult_mono' order_refl norm_Y norm_ge_zero
huffman@22608
   248
                mult_nonneg_nonneg K)
huffman@22608
   249
    also have "\<dots> = norm (X n) * (B * K)"
huffman@22608
   250
      by (rule mult_assoc)
huffman@22608
   251
    finally show "norm (X n ** Y n) \<le> norm (X n) * (B * K)" .
huffman@22608
   252
  qed
huffman@22608
   253
qed
huffman@22608
   254
huffman@22608
   255
lemma (in bounded_bilinear) Bseq_prod_Zseq:
huffman@22608
   256
  assumes X: "Bseq X"
huffman@22608
   257
  assumes Y: "Zseq Y"
huffman@22608
   258
  shows "Zseq (\<lambda>n. X n ** Y n)"
huffman@22608
   259
proof -
huffman@22608
   260
  obtain K where K: "0 \<le> K"
huffman@22608
   261
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@22608
   262
    using nonneg_bounded by fast
huffman@22608
   263
  obtain B where B: "0 < B"
huffman@22608
   264
    and norm_X: "\<And>n. norm (X n) \<le> B"
huffman@22608
   265
    using X [unfolded Bseq_def] by fast
huffman@22608
   266
  from Y show ?thesis
huffman@22608
   267
  proof (rule Zseq_imp_Zseq)
huffman@22608
   268
    fix n::nat
huffman@22608
   269
    have "norm (X n ** Y n) \<le> norm (X n) * norm (Y n) * K"
huffman@22608
   270
      by (rule norm_le)
huffman@22608
   271
    also have "\<dots> \<le> B * norm (Y n) * K"
huffman@22608
   272
      by (intro mult_mono' order_refl norm_X norm_ge_zero
huffman@22608
   273
                mult_nonneg_nonneg K)
huffman@22608
   274
    also have "\<dots> = norm (Y n) * (B * K)"
huffman@22608
   275
      by (simp only: mult_ac)
huffman@22608
   276
    finally show "norm (X n ** Y n) \<le> norm (Y n) * (B * K)" .
huffman@22608
   277
  qed
huffman@22608
   278
qed
huffman@22608
   279
huffman@22608
   280
lemma (in bounded_bilinear) Zseq_prod_left:
huffman@22608
   281
  "Zseq X \<Longrightarrow> Zseq (\<lambda>n. X n ** a)"
huffman@22608
   282
by (rule bounded_linear_left [THEN bounded_linear.Zseq])
huffman@22608
   283
huffman@22608
   284
lemma (in bounded_bilinear) Zseq_prod_right:
huffman@22608
   285
  "Zseq X \<Longrightarrow> Zseq (\<lambda>n. a ** X n)"
huffman@22608
   286
by (rule bounded_linear_right [THEN bounded_linear.Zseq])
huffman@22608
   287
huffman@22608
   288
lemmas Zseq_mult = bounded_bilinear_mult.Zseq_prod
huffman@22608
   289
lemmas Zseq_mult_right = bounded_bilinear_mult.Zseq_prod_right
huffman@22608
   290
lemmas Zseq_mult_left = bounded_bilinear_mult.Zseq_prod_left
huffman@22608
   291
huffman@22608
   292
huffman@20696
   293
subsection {* Limits of Sequences *}
huffman@20696
   294
paulson@15082
   295
lemma LIMSEQ_iff:
huffman@20563
   296
      "(X ----> L) = (\<forall>r>0. \<exists>no. \<forall>n \<ge> no. norm (X n - L) < r)"
huffman@22608
   297
by (rule LIMSEQ_def)
huffman@22608
   298
huffman@22608
   299
lemma LIMSEQ_Zseq_iff: "((\<lambda>n. X n) ----> L) = Zseq (\<lambda>n. X n - L)"
huffman@22608
   300
by (simp only: LIMSEQ_def Zseq_def)
paulson@15082
   301
huffman@20751
   302
lemma LIMSEQ_I:
huffman@20751
   303
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r) \<Longrightarrow> X ----> L"
huffman@20751
   304
by (simp add: LIMSEQ_def)
huffman@20751
   305
huffman@20751
   306
lemma LIMSEQ_D:
huffman@20751
   307
  "\<lbrakk>X ----> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r"
huffman@20751
   308
by (simp add: LIMSEQ_def)
huffman@20751
   309
huffman@22608
   310
lemma LIMSEQ_const: "(\<lambda>n. k) ----> k"
huffman@20696
   311
by (simp add: LIMSEQ_def)
huffman@20696
   312
huffman@22608
   313
lemma LIMSEQ_const_iff: "(\<lambda>n. k) ----> l = (k = l)"
huffman@22608
   314
by (simp add: LIMSEQ_Zseq_iff Zseq_const_iff)
huffman@22608
   315
huffman@20696
   316
lemma LIMSEQ_norm: "X ----> a \<Longrightarrow> (\<lambda>n. norm (X n)) ----> norm a"
huffman@20696
   317
apply (simp add: LIMSEQ_def, safe)
huffman@20696
   318
apply (drule_tac x="r" in spec, safe)
huffman@20696
   319
apply (rule_tac x="no" in exI, safe)
huffman@20696
   320
apply (drule_tac x="n" in spec, safe)
huffman@20696
   321
apply (erule order_le_less_trans [OF norm_triangle_ineq3])
huffman@20696
   322
done
huffman@20696
   323
huffman@22615
   324
lemma LIMSEQ_ignore_initial_segment:
huffman@22615
   325
  "f ----> a \<Longrightarrow> (\<lambda>n. f (n + k)) ----> a"
huffman@22615
   326
apply (rule LIMSEQ_I)
huffman@22615
   327
apply (drule (1) LIMSEQ_D)
huffman@22615
   328
apply (erule exE, rename_tac N)
huffman@22615
   329
apply (rule_tac x=N in exI)
huffman@22615
   330
apply simp
huffman@22615
   331
done
huffman@20696
   332
huffman@22615
   333
lemma LIMSEQ_offset:
huffman@22615
   334
  "(\<lambda>n. f (n + k)) ----> a \<Longrightarrow> f ----> 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 + k" in exI)
huffman@22615
   339
apply clarify
huffman@22615
   340
apply (drule_tac x="n - k" in spec)
huffman@22615
   341
apply (simp add: le_diff_conv2)
huffman@20696
   342
done
huffman@20696
   343
huffman@22615
   344
lemma LIMSEQ_Suc: "f ----> l \<Longrightarrow> (\<lambda>n. f (Suc n)) ----> l"
huffman@22615
   345
by (drule_tac k="1" in LIMSEQ_ignore_initial_segment, simp)
huffman@22615
   346
huffman@22615
   347
lemma LIMSEQ_imp_Suc: "(\<lambda>n. f (Suc n)) ----> l \<Longrightarrow> f ----> l"
huffman@22615
   348
by (rule_tac k="1" in LIMSEQ_offset, simp)
huffman@22615
   349
huffman@22615
   350
lemma LIMSEQ_Suc_iff: "(\<lambda>n. f (Suc n)) ----> l = f ----> l"
huffman@22615
   351
by (blast intro: LIMSEQ_imp_Suc LIMSEQ_Suc)
huffman@22615
   352
huffman@22608
   353
lemma add_diff_add:
huffman@22608
   354
  fixes a b c d :: "'a::ab_group_add"
huffman@22608
   355
  shows "(a + c) - (b + d) = (a - b) + (c - d)"
huffman@22608
   356
by simp
huffman@22608
   357
huffman@22608
   358
lemma minus_diff_minus:
huffman@22608
   359
  fixes a b :: "'a::ab_group_add"
huffman@22608
   360
  shows "(- a) - (- b) = - (a - b)"
huffman@22608
   361
by simp
huffman@22608
   362
huffman@22608
   363
lemma LIMSEQ_add: "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n + Y n) ----> a + b"
huffman@22608
   364
by (simp only: LIMSEQ_Zseq_iff add_diff_add Zseq_add)
huffman@22608
   365
huffman@22608
   366
lemma LIMSEQ_minus: "X ----> a \<Longrightarrow> (\<lambda>n. - X n) ----> - a"
huffman@22608
   367
by (simp only: LIMSEQ_Zseq_iff minus_diff_minus Zseq_minus)
huffman@22608
   368
huffman@22608
   369
lemma LIMSEQ_minus_cancel: "(\<lambda>n. - X n) ----> - a \<Longrightarrow> X ----> a"
huffman@22608
   370
by (drule LIMSEQ_minus, simp)
huffman@22608
   371
huffman@22608
   372
lemma LIMSEQ_diff: "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n - Y n) ----> a - b"
huffman@22608
   373
by (simp add: diff_minus LIMSEQ_add LIMSEQ_minus)
huffman@22608
   374
huffman@22608
   375
lemma LIMSEQ_unique: "\<lbrakk>X ----> a; X ----> b\<rbrakk> \<Longrightarrow> a = b"
huffman@22608
   376
by (drule (1) LIMSEQ_diff, simp add: LIMSEQ_const_iff)
huffman@22608
   377
huffman@22608
   378
lemma (in bounded_linear) LIMSEQ:
huffman@22608
   379
  "X ----> a \<Longrightarrow> (\<lambda>n. f (X n)) ----> f a"
huffman@22608
   380
by (simp only: LIMSEQ_Zseq_iff diff [symmetric] Zseq)
huffman@22608
   381
huffman@22608
   382
lemma (in bounded_bilinear) LIMSEQ:
huffman@22608
   383
  "\<lbrakk>X ----> a; Y ----> b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n ** Y n) ----> a ** b"
huffman@22608
   384
by (simp only: LIMSEQ_Zseq_iff prod_diff_prod
huffman@22608
   385
               Zseq_add Zseq_prod Zseq_prod_left Zseq_prod_right)
huffman@22608
   386
huffman@22608
   387
lemma LIMSEQ_mult:
huffman@22608
   388
  fixes a b :: "'a::real_normed_algebra"
huffman@22608
   389
  shows "[| X ----> a; Y ----> b |] ==> (%n. X n * Y n) ----> a * b"
huffman@22608
   390
by (rule bounded_bilinear_mult.LIMSEQ)
huffman@22608
   391
huffman@22608
   392
lemma inverse_diff_inverse:
huffman@22608
   393
  "\<lbrakk>(a::'a::division_ring) \<noteq> 0; b \<noteq> 0\<rbrakk>
huffman@22608
   394
   \<Longrightarrow> inverse a - inverse b = - (inverse a * (a - b) * inverse b)"
huffman@22608
   395
by (simp add: right_diff_distrib left_diff_distrib mult_assoc)
huffman@22608
   396
huffman@22608
   397
lemma Bseq_inverse_lemma:
huffman@22608
   398
  fixes x :: "'a::real_normed_div_algebra"
huffman@22608
   399
  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
huffman@22608
   400
apply (subst nonzero_norm_inverse, clarsimp)
huffman@22608
   401
apply (erule (1) le_imp_inverse_le)
huffman@22608
   402
done
huffman@22608
   403
huffman@22608
   404
lemma Bseq_inverse:
huffman@22608
   405
  fixes a :: "'a::real_normed_div_algebra"
huffman@22608
   406
  assumes X: "X ----> a"
huffman@22608
   407
  assumes a: "a \<noteq> 0"
huffman@22608
   408
  shows "Bseq (\<lambda>n. inverse (X n))"
huffman@22608
   409
proof -
huffman@22608
   410
  from a have "0 < norm a" by simp
huffman@22608
   411
  hence "\<exists>r>0. r < norm a" by (rule dense)
huffman@22608
   412
  then obtain r where r1: "0 < r" and r2: "r < norm a" by fast
huffman@22608
   413
  obtain N where N: "\<And>n. N \<le> n \<Longrightarrow> norm (X n - a) < r"
huffman@22608
   414
    using LIMSEQ_D [OF X r1] by fast
huffman@22608
   415
  show ?thesis
huffman@22608
   416
  proof (rule BseqI2 [rule_format])
huffman@22608
   417
    fix n assume n: "N \<le> n"
huffman@22608
   418
    hence 1: "norm (X n - a) < r" by (rule N)
huffman@22608
   419
    hence 2: "X n \<noteq> 0" using r2 by auto
huffman@22608
   420
    hence "norm (inverse (X n)) = inverse (norm (X n))"
huffman@22608
   421
      by (rule nonzero_norm_inverse)
huffman@22608
   422
    also have "\<dots> \<le> inverse (norm a - r)"
huffman@22608
   423
    proof (rule le_imp_inverse_le)
huffman@22608
   424
      show "0 < norm a - r" using r2 by simp
huffman@22608
   425
    next
huffman@22608
   426
      have "norm a - norm (X n) \<le> norm (a - X n)"
huffman@22608
   427
        by (rule norm_triangle_ineq2)
huffman@22608
   428
      also have "\<dots> = norm (X n - a)"
huffman@22608
   429
        by (rule norm_minus_commute)
huffman@22608
   430
      also have "\<dots> < r" using 1 .
huffman@22608
   431
      finally show "norm a - r \<le> norm (X n)" by simp
huffman@22608
   432
    qed
huffman@22608
   433
    finally show "norm (inverse (X n)) \<le> inverse (norm a - r)" .
huffman@22608
   434
  qed
huffman@22608
   435
qed
huffman@22608
   436
huffman@22608
   437
lemma LIMSEQ_inverse_lemma:
huffman@22608
   438
  fixes a :: "'a::real_normed_div_algebra"
huffman@22608
   439
  shows "\<lbrakk>X ----> a; a \<noteq> 0; \<forall>n. X n \<noteq> 0\<rbrakk>
huffman@22608
   440
         \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> inverse a"
huffman@22608
   441
apply (subst LIMSEQ_Zseq_iff)
huffman@22608
   442
apply (simp add: inverse_diff_inverse nonzero_imp_inverse_nonzero)
huffman@22608
   443
apply (rule Zseq_minus)
huffman@22608
   444
apply (rule Zseq_mult_left)
huffman@22608
   445
apply (rule bounded_bilinear_mult.Bseq_prod_Zseq)
huffman@22608
   446
apply (erule (1) Bseq_inverse)
huffman@22608
   447
apply (simp add: LIMSEQ_Zseq_iff)
huffman@22608
   448
done
huffman@22608
   449
huffman@22608
   450
lemma LIMSEQ_inverse:
huffman@22608
   451
  fixes a :: "'a::real_normed_div_algebra"
huffman@22608
   452
  assumes X: "X ----> a"
huffman@22608
   453
  assumes a: "a \<noteq> 0"
huffman@22608
   454
  shows "(\<lambda>n. inverse (X n)) ----> inverse a"
huffman@22608
   455
proof -
huffman@22608
   456
  from a have "0 < norm a" by simp
huffman@22608
   457
  then obtain k where "\<forall>n\<ge>k. norm (X n - a) < norm a"
huffman@22608
   458
    using LIMSEQ_D [OF X] by fast
huffman@22608
   459
  hence "\<forall>n\<ge>k. X n \<noteq> 0" by auto
huffman@22608
   460
  hence k: "\<forall>n. X (n + k) \<noteq> 0" by simp
huffman@22608
   461
huffman@22608
   462
  from X have "(\<lambda>n. X (n + k)) ----> a"
huffman@22608
   463
    by (rule LIMSEQ_ignore_initial_segment)
huffman@22608
   464
  hence "(\<lambda>n. inverse (X (n + k))) ----> inverse a"
huffman@22608
   465
    using a k by (rule LIMSEQ_inverse_lemma)
huffman@22608
   466
  thus "(\<lambda>n. inverse (X n)) ----> inverse a"
huffman@22608
   467
    by (rule LIMSEQ_offset)
huffman@22608
   468
qed
huffman@22608
   469
huffman@22608
   470
lemma LIMSEQ_divide:
huffman@22608
   471
  fixes a b :: "'a::real_normed_field"
huffman@22608
   472
  shows "\<lbrakk>X ----> a; Y ----> b; b \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>n. X n / Y n) ----> a / b"
huffman@22608
   473
by (simp add: LIMSEQ_mult LIMSEQ_inverse divide_inverse)
huffman@22608
   474
huffman@22608
   475
lemma LIMSEQ_pow:
huffman@22608
   476
  fixes a :: "'a::{real_normed_algebra,recpower}"
huffman@22608
   477
  shows "X ----> a \<Longrightarrow> (\<lambda>n. (X n) ^ m) ----> a ^ m"
huffman@22608
   478
by (induct m) (simp_all add: power_Suc LIMSEQ_const LIMSEQ_mult)
huffman@22608
   479
huffman@22608
   480
lemma LIMSEQ_setsum:
huffman@22608
   481
  assumes n: "\<And>n. n \<in> S \<Longrightarrow> X n ----> L n"
huffman@22608
   482
  shows "(\<lambda>m. \<Sum>n\<in>S. X n m) ----> (\<Sum>n\<in>S. L n)"
huffman@22608
   483
proof (cases "finite S")
huffman@22608
   484
  case True
huffman@22608
   485
  thus ?thesis using n
huffman@22608
   486
  proof (induct)
huffman@22608
   487
    case empty
huffman@22608
   488
    show ?case
huffman@22608
   489
      by (simp add: LIMSEQ_const)
huffman@22608
   490
  next
huffman@22608
   491
    case insert
huffman@22608
   492
    thus ?case
huffman@22608
   493
      by (simp add: LIMSEQ_add)
huffman@22608
   494
  qed
huffman@22608
   495
next
huffman@22608
   496
  case False
huffman@22608
   497
  thus ?thesis
huffman@22608
   498
    by (simp add: LIMSEQ_const)
huffman@22608
   499
qed
huffman@22608
   500
huffman@22608
   501
lemma LIMSEQ_setprod:
huffman@22608
   502
  fixes L :: "'a \<Rightarrow> 'b::{real_normed_algebra,comm_ring_1}"
huffman@22608
   503
  assumes n: "\<And>n. n \<in> S \<Longrightarrow> X n ----> L n"
huffman@22608
   504
  shows "(\<lambda>m. \<Prod>n\<in>S. X n m) ----> (\<Prod>n\<in>S. L n)"
huffman@22608
   505
proof (cases "finite S")
huffman@22608
   506
  case True
huffman@22608
   507
  thus ?thesis using n
huffman@22608
   508
  proof (induct)
huffman@22608
   509
    case empty
huffman@22608
   510
    show ?case
huffman@22608
   511
      by (simp add: LIMSEQ_const)
huffman@22608
   512
  next
huffman@22608
   513
    case insert
huffman@22608
   514
    thus ?case
huffman@22608
   515
      by (simp add: LIMSEQ_mult)
huffman@22608
   516
  qed
huffman@22608
   517
next
huffman@22608
   518
  case False
huffman@22608
   519
  thus ?thesis
huffman@22608
   520
    by (simp add: setprod_def LIMSEQ_const)
huffman@22608
   521
qed
huffman@22608
   522
huffman@22614
   523
lemma LIMSEQ_add_const: "f ----> a ==> (%n.(f n + b)) ----> a + b"
huffman@22614
   524
by (simp add: LIMSEQ_add LIMSEQ_const)
huffman@22614
   525
huffman@22614
   526
(* FIXME: delete *)
huffman@22614
   527
lemma LIMSEQ_add_minus:
huffman@22614
   528
     "[| X ----> a; Y ----> b |] ==> (%n. X n + -Y n) ----> a + -b"
huffman@22614
   529
by (simp only: LIMSEQ_add LIMSEQ_minus)
huffman@22614
   530
huffman@22614
   531
lemma LIMSEQ_diff_const: "f ----> a ==> (%n.(f n  - b)) ----> a - b"
huffman@22614
   532
by (simp add: LIMSEQ_diff LIMSEQ_const)
huffman@22614
   533
huffman@22614
   534
lemma LIMSEQ_diff_approach_zero: 
huffman@22614
   535
  "g ----> L ==> (%x. f x - g x) ----> 0  ==>
huffman@22614
   536
     f ----> L"
huffman@22614
   537
  apply (drule LIMSEQ_add)
huffman@22614
   538
  apply assumption
huffman@22614
   539
  apply simp
huffman@22614
   540
done
huffman@22614
   541
huffman@22614
   542
lemma LIMSEQ_diff_approach_zero2: 
huffman@22614
   543
  "f ----> L ==> (%x. f x - g x) ----> 0  ==>
huffman@22614
   544
     g ----> L";
huffman@22614
   545
  apply (drule LIMSEQ_diff)
huffman@22614
   546
  apply assumption
huffman@22614
   547
  apply simp
huffman@22614
   548
done
huffman@22614
   549
huffman@22614
   550
text{*A sequence tends to zero iff its abs does*}
huffman@22614
   551
lemma LIMSEQ_norm_zero: "((\<lambda>n. norm (X n)) ----> 0) = (X ----> 0)"
huffman@22614
   552
by (simp add: LIMSEQ_def)
huffman@22614
   553
huffman@22614
   554
lemma LIMSEQ_rabs_zero: "((%n. \<bar>f n\<bar>) ----> 0) = (f ----> (0::real))"
huffman@22614
   555
by (simp add: LIMSEQ_def)
huffman@22614
   556
huffman@22614
   557
lemma LIMSEQ_imp_rabs: "f ----> (l::real) ==> (%n. \<bar>f n\<bar>) ----> \<bar>l\<bar>"
huffman@22614
   558
by (drule LIMSEQ_norm, simp)
huffman@22614
   559
huffman@22614
   560
text{*An unbounded sequence's inverse tends to 0*}
huffman@22614
   561
huffman@22614
   562
lemma LIMSEQ_inverse_zero:
huffman@22974
   563
  "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> 0"
huffman@22974
   564
apply (rule LIMSEQ_I)
huffman@22974
   565
apply (drule_tac x="inverse r" in spec, safe)
huffman@22974
   566
apply (rule_tac x="N" in exI, safe)
huffman@22974
   567
apply (drule_tac x="n" in spec, safe)
huffman@22614
   568
apply (frule positive_imp_inverse_positive)
huffman@22974
   569
apply (frule (1) less_imp_inverse_less)
huffman@22974
   570
apply (subgoal_tac "0 < X n", simp)
huffman@22974
   571
apply (erule (1) order_less_trans)
huffman@22614
   572
done
huffman@22614
   573
huffman@22614
   574
text{*The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity*}
huffman@22614
   575
huffman@22614
   576
lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) ----> 0"
huffman@22614
   577
apply (rule LIMSEQ_inverse_zero, safe)
huffman@22974
   578
apply (cut_tac x = r in reals_Archimedean2)
huffman@22614
   579
apply (safe, rule_tac x = n in exI)
huffman@22614
   580
apply (auto simp add: real_of_nat_Suc)
huffman@22614
   581
done
huffman@22614
   582
huffman@22614
   583
text{*The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to
huffman@22614
   584
infinity is now easily proved*}
huffman@22614
   585
huffman@22614
   586
lemma LIMSEQ_inverse_real_of_nat_add:
huffman@22614
   587
     "(%n. r + inverse(real(Suc n))) ----> r"
huffman@22614
   588
by (cut_tac LIMSEQ_add [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat], auto)
huffman@22614
   589
huffman@22614
   590
lemma LIMSEQ_inverse_real_of_nat_add_minus:
huffman@22614
   591
     "(%n. r + -inverse(real(Suc n))) ----> r"
huffman@22614
   592
by (cut_tac LIMSEQ_add_minus [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat], auto)
huffman@22614
   593
huffman@22614
   594
lemma LIMSEQ_inverse_real_of_nat_add_minus_mult:
huffman@22614
   595
     "(%n. r*( 1 + -inverse(real(Suc n)))) ----> r"
huffman@22614
   596
by (cut_tac b=1 in
huffman@22614
   597
        LIMSEQ_mult [OF LIMSEQ_const LIMSEQ_inverse_real_of_nat_add_minus], auto)
huffman@22614
   598
huffman@22615
   599
lemma LIMSEQ_le_const:
huffman@22615
   600
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. a \<le> X n\<rbrakk> \<Longrightarrow> a \<le> x"
huffman@22615
   601
apply (rule ccontr, simp only: linorder_not_le)
huffman@22615
   602
apply (drule_tac r="a - x" in LIMSEQ_D, simp)
huffman@22615
   603
apply clarsimp
huffman@22615
   604
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI1)
huffman@22615
   605
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI2)
huffman@22615
   606
apply simp
huffman@22615
   607
done
huffman@22615
   608
huffman@22615
   609
lemma LIMSEQ_le_const2:
huffman@22615
   610
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. X n \<le> a\<rbrakk> \<Longrightarrow> x \<le> a"
huffman@22615
   611
apply (subgoal_tac "- a \<le> - x", simp)
huffman@22615
   612
apply (rule LIMSEQ_le_const)
huffman@22615
   613
apply (erule LIMSEQ_minus)
huffman@22615
   614
apply simp
huffman@22615
   615
done
huffman@22615
   616
huffman@22615
   617
lemma LIMSEQ_le:
huffman@22615
   618
  "\<lbrakk>X ----> x; Y ----> y; \<exists>N. \<forall>n\<ge>N. X n \<le> Y n\<rbrakk> \<Longrightarrow> x \<le> (y::real)"
huffman@22615
   619
apply (subgoal_tac "0 \<le> y - x", simp)
huffman@22615
   620
apply (rule LIMSEQ_le_const)
huffman@22615
   621
apply (erule (1) LIMSEQ_diff)
huffman@22615
   622
apply (simp add: le_diff_eq)
huffman@22615
   623
done
huffman@22615
   624
paulson@15082
   625
huffman@20696
   626
subsection {* Convergence *}
paulson@15082
   627
paulson@15082
   628
lemma limI: "X ----> L ==> lim X = L"
paulson@15082
   629
apply (simp add: lim_def)
paulson@15082
   630
apply (blast intro: LIMSEQ_unique)
paulson@15082
   631
done
paulson@15082
   632
paulson@15082
   633
lemma convergentD: "convergent X ==> \<exists>L. (X ----> L)"
paulson@15082
   634
by (simp add: convergent_def)
paulson@15082
   635
paulson@15082
   636
lemma convergentI: "(X ----> L) ==> convergent X"
paulson@15082
   637
by (auto simp add: convergent_def)
paulson@15082
   638
paulson@15082
   639
lemma convergent_LIMSEQ_iff: "convergent X = (X ----> lim X)"
huffman@20682
   640
by (auto intro: theI LIMSEQ_unique simp add: convergent_def lim_def)
paulson@15082
   641
huffman@20696
   642
lemma convergent_minus_iff: "(convergent X) = (convergent (%n. -(X n)))"
huffman@20696
   643
apply (simp add: convergent_def)
huffman@20696
   644
apply (auto dest: LIMSEQ_minus)
huffman@20696
   645
apply (drule LIMSEQ_minus, auto)
huffman@20696
   646
done
huffman@20696
   647
huffman@20696
   648
huffman@20696
   649
subsection {* Bounded Monotonic Sequences *}
huffman@20696
   650
paulson@15082
   651
text{*Subsequence (alternative definition, (e.g. Hoskins)*}
paulson@15082
   652
paulson@15082
   653
lemma subseq_Suc_iff: "subseq f = (\<forall>n. (f n) < (f (Suc n)))"
paulson@15082
   654
apply (simp add: subseq_def)
paulson@15082
   655
apply (auto dest!: less_imp_Suc_add)
paulson@15082
   656
apply (induct_tac k)
paulson@15082
   657
apply (auto intro: less_trans)
paulson@15082
   658
done
paulson@15082
   659
paulson@15082
   660
lemma monoseq_Suc:
paulson@15082
   661
   "monoseq X = ((\<forall>n. X n \<le> X (Suc n))
paulson@15082
   662
                 | (\<forall>n. X (Suc n) \<le> X n))"
paulson@15082
   663
apply (simp add: monoseq_def)
paulson@15082
   664
apply (auto dest!: le_imp_less_or_eq)
paulson@15082
   665
apply (auto intro!: lessI [THEN less_imp_le] dest!: less_imp_Suc_add)
paulson@15082
   666
apply (induct_tac "ka")
paulson@15082
   667
apply (auto intro: order_trans)
wenzelm@18585
   668
apply (erule contrapos_np)
paulson@15082
   669
apply (induct_tac "k")
paulson@15082
   670
apply (auto intro: order_trans)
paulson@15082
   671
done
paulson@15082
   672
nipkow@15360
   673
lemma monoI1: "\<forall>m. \<forall> n \<ge> m. X m \<le> X n ==> monoseq X"
paulson@15082
   674
by (simp add: monoseq_def)
paulson@15082
   675
nipkow@15360
   676
lemma monoI2: "\<forall>m. \<forall> n \<ge> m. X n \<le> X m ==> monoseq X"
paulson@15082
   677
by (simp add: monoseq_def)
paulson@15082
   678
paulson@15082
   679
lemma mono_SucI1: "\<forall>n. X n \<le> X (Suc n) ==> monoseq X"
paulson@15082
   680
by (simp add: monoseq_Suc)
paulson@15082
   681
paulson@15082
   682
lemma mono_SucI2: "\<forall>n. X (Suc n) \<le> X n ==> monoseq X"
paulson@15082
   683
by (simp add: monoseq_Suc)
paulson@15082
   684
huffman@20696
   685
text{*Bounded Sequence*}
paulson@15082
   686
huffman@20552
   687
lemma BseqD: "Bseq X ==> \<exists>K. 0 < K & (\<forall>n. norm (X n) \<le> K)"
paulson@15082
   688
by (simp add: Bseq_def)
paulson@15082
   689
huffman@20552
   690
lemma BseqI: "[| 0 < K; \<forall>n. norm (X n) \<le> K |] ==> Bseq X"
paulson@15082
   691
by (auto simp add: Bseq_def)
paulson@15082
   692
paulson@15082
   693
lemma lemma_NBseq_def:
huffman@20552
   694
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) =
huffman@20552
   695
      (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
paulson@15082
   696
apply auto
paulson@15082
   697
 prefer 2 apply force
paulson@15082
   698
apply (cut_tac x = K in reals_Archimedean2, clarify)
paulson@15082
   699
apply (rule_tac x = n in exI, clarify)
paulson@15082
   700
apply (drule_tac x = na in spec)
paulson@15082
   701
apply (auto simp add: real_of_nat_Suc)
paulson@15082
   702
done
paulson@15082
   703
paulson@15082
   704
text{* alternative definition for Bseq *}
huffman@20552
   705
lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
paulson@15082
   706
apply (simp add: Bseq_def)
paulson@15082
   707
apply (simp (no_asm) add: lemma_NBseq_def)
paulson@15082
   708
done
paulson@15082
   709
paulson@15082
   710
lemma lemma_NBseq_def2:
huffman@20552
   711
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   712
apply (subst lemma_NBseq_def, auto)
paulson@15082
   713
apply (rule_tac x = "Suc N" in exI)
paulson@15082
   714
apply (rule_tac [2] x = N in exI)
paulson@15082
   715
apply (auto simp add: real_of_nat_Suc)
paulson@15082
   716
 prefer 2 apply (blast intro: order_less_imp_le)
paulson@15082
   717
apply (drule_tac x = n in spec, simp)
paulson@15082
   718
done
paulson@15082
   719
paulson@15082
   720
(* yet another definition for Bseq *)
huffman@20552
   721
lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   722
by (simp add: Bseq_def lemma_NBseq_def2)
paulson@15082
   723
huffman@20696
   724
subsubsection{*Upper Bounds and Lubs of Bounded Sequences*}
paulson@15082
   725
paulson@15082
   726
lemma Bseq_isUb:
paulson@15082
   727
  "!!(X::nat=>real). Bseq X ==> \<exists>U. isUb (UNIV::real set) {x. \<exists>n. X n = x} U"
paulson@15082
   728
by (auto intro: isUbI setleI simp add: Bseq_def abs_le_interval_iff)
paulson@15082
   729
paulson@15082
   730
paulson@15082
   731
text{* Use completeness of reals (supremum property)
paulson@15082
   732
   to show that any bounded sequence has a least upper bound*}
paulson@15082
   733
paulson@15082
   734
lemma Bseq_isLub:
paulson@15082
   735
  "!!(X::nat=>real). Bseq X ==>
paulson@15082
   736
   \<exists>U. isLub (UNIV::real set) {x. \<exists>n. X n = x} U"
paulson@15082
   737
by (blast intro: reals_complete Bseq_isUb)
paulson@15082
   738
huffman@20696
   739
subsubsection{*A Bounded and Monotonic Sequence Converges*}
paulson@15082
   740
paulson@15082
   741
lemma lemma_converg1:
nipkow@15360
   742
     "!!(X::nat=>real). [| \<forall>m. \<forall> n \<ge> m. X m \<le> X n;
paulson@15082
   743
                  isLub (UNIV::real set) {x. \<exists>n. X n = x} (X ma)
nipkow@15360
   744
               |] ==> \<forall>n \<ge> ma. X n = X ma"
paulson@15082
   745
apply safe
paulson@15082
   746
apply (drule_tac y = "X n" in isLubD2)
paulson@15082
   747
apply (blast dest: order_antisym)+
paulson@15082
   748
done
paulson@15082
   749
paulson@15082
   750
text{* The best of both worlds: Easier to prove this result as a standard
paulson@15082
   751
   theorem and then use equivalence to "transfer" it into the
paulson@15082
   752
   equivalent nonstandard form if needed!*}
paulson@15082
   753
paulson@15082
   754
lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)"
paulson@15082
   755
apply (simp add: LIMSEQ_def)
paulson@15082
   756
apply (rule_tac x = "X m" in exI, safe)
paulson@15082
   757
apply (rule_tac x = m in exI, safe)
paulson@15082
   758
apply (drule spec, erule impE, auto)
paulson@15082
   759
done
paulson@15082
   760
paulson@15082
   761
lemma lemma_converg2:
paulson@15082
   762
   "!!(X::nat=>real).
paulson@15082
   763
    [| \<forall>m. X m ~= U;  isLub UNIV {x. \<exists>n. X n = x} U |] ==> \<forall>m. X m < U"
paulson@15082
   764
apply safe
paulson@15082
   765
apply (drule_tac y = "X m" in isLubD2)
paulson@15082
   766
apply (auto dest!: order_le_imp_less_or_eq)
paulson@15082
   767
done
paulson@15082
   768
paulson@15082
   769
lemma lemma_converg3: "!!(X ::nat=>real). \<forall>m. X m \<le> U ==> isUb UNIV {x. \<exists>n. X n = x} U"
paulson@15082
   770
by (rule setleI [THEN isUbI], auto)
paulson@15082
   771
paulson@15082
   772
text{* FIXME: @{term "U - T < U"} is redundant *}
paulson@15082
   773
lemma lemma_converg4: "!!(X::nat=> real).
paulson@15082
   774
               [| \<forall>m. X m ~= U;
paulson@15082
   775
                  isLub UNIV {x. \<exists>n. X n = x} U;
paulson@15082
   776
                  0 < T;
paulson@15082
   777
                  U + - T < U
paulson@15082
   778
               |] ==> \<exists>m. U + -T < X m & X m < U"
paulson@15082
   779
apply (drule lemma_converg2, assumption)
paulson@15082
   780
apply (rule ccontr, simp)
paulson@15082
   781
apply (simp add: linorder_not_less)
paulson@15082
   782
apply (drule lemma_converg3)
paulson@15082
   783
apply (drule isLub_le_isUb, assumption)
paulson@15082
   784
apply (auto dest: order_less_le_trans)
paulson@15082
   785
done
paulson@15082
   786
paulson@15082
   787
text{*A standard proof of the theorem for monotone increasing sequence*}
paulson@15082
   788
paulson@15082
   789
lemma Bseq_mono_convergent:
huffman@20552
   790
     "[| Bseq X; \<forall>m. \<forall>n \<ge> m. X m \<le> X n |] ==> convergent (X::nat=>real)"
paulson@15082
   791
apply (simp add: convergent_def)
paulson@15082
   792
apply (frule Bseq_isLub, safe)
paulson@15082
   793
apply (case_tac "\<exists>m. X m = U", auto)
paulson@15082
   794
apply (blast dest: lemma_converg1 Bmonoseq_LIMSEQ)
paulson@15082
   795
(* second case *)
paulson@15082
   796
apply (rule_tac x = U in exI)
paulson@15082
   797
apply (subst LIMSEQ_iff, safe)
paulson@15082
   798
apply (frule lemma_converg2, assumption)
paulson@15082
   799
apply (drule lemma_converg4, auto)
paulson@15082
   800
apply (rule_tac x = m in exI, safe)
paulson@15082
   801
apply (subgoal_tac "X m \<le> X n")
paulson@15082
   802
 prefer 2 apply blast
paulson@15082
   803
apply (drule_tac x=n and P="%m. X m < U" in spec, arith)
paulson@15082
   804
done
paulson@15082
   805
paulson@15082
   806
lemma Bseq_minus_iff: "Bseq (%n. -(X n)) = Bseq X"
paulson@15082
   807
by (simp add: Bseq_def)
paulson@15082
   808
paulson@15082
   809
text{*Main monotonicity theorem*}
paulson@15082
   810
lemma Bseq_monoseq_convergent: "[| Bseq X; monoseq X |] ==> convergent X"
paulson@15082
   811
apply (simp add: monoseq_def, safe)
paulson@15082
   812
apply (rule_tac [2] convergent_minus_iff [THEN ssubst])
paulson@15082
   813
apply (drule_tac [2] Bseq_minus_iff [THEN ssubst])
paulson@15082
   814
apply (auto intro!: Bseq_mono_convergent)
paulson@15082
   815
done
paulson@15082
   816
huffman@20696
   817
subsubsection{*A Few More Equivalence Theorems for Boundedness*}
paulson@15082
   818
paulson@15082
   819
text{*alternative formulation for boundedness*}
huffman@20552
   820
lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)"
paulson@15082
   821
apply (unfold Bseq_def, safe)
huffman@20552
   822
apply (rule_tac [2] x = "k + norm x" in exI)
nipkow@15360
   823
apply (rule_tac x = K in exI, simp)
paulson@15221
   824
apply (rule exI [where x = 0], auto)
huffman@20552
   825
apply (erule order_less_le_trans, simp)
huffman@20552
   826
apply (drule_tac x=n in spec, fold diff_def)
huffman@20552
   827
apply (drule order_trans [OF norm_triangle_ineq2])
huffman@20552
   828
apply simp
paulson@15082
   829
done
paulson@15082
   830
paulson@15082
   831
text{*alternative formulation for boundedness*}
huffman@20552
   832
lemma Bseq_iff3: "Bseq X = (\<exists>k > 0. \<exists>N. \<forall>n. norm(X(n) + -X(N)) \<le> k)"
paulson@15082
   833
apply safe
paulson@15082
   834
apply (simp add: Bseq_def, safe)
huffman@20552
   835
apply (rule_tac x = "K + norm (X N)" in exI)
paulson@15082
   836
apply auto
huffman@20552
   837
apply (erule order_less_le_trans, simp)
paulson@15082
   838
apply (rule_tac x = N in exI, safe)
huffman@20552
   839
apply (drule_tac x = n in spec)
huffman@20552
   840
apply (rule order_trans [OF norm_triangle_ineq], simp)
paulson@15082
   841
apply (auto simp add: Bseq_iff2)
paulson@15082
   842
done
paulson@15082
   843
huffman@20552
   844
lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f"
paulson@15082
   845
apply (simp add: Bseq_def)
paulson@15221
   846
apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto)
webertj@20217
   847
apply (drule_tac x = n in spec, arith)
paulson@15082
   848
done
paulson@15082
   849
paulson@15082
   850
huffman@20696
   851
subsection {* Cauchy Sequences *}
paulson@15082
   852
huffman@20751
   853
lemma CauchyI:
huffman@20751
   854
  "(\<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
   855
by (simp add: Cauchy_def)
huffman@20751
   856
huffman@20751
   857
lemma CauchyD:
huffman@20751
   858
  "\<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
   859
by (simp add: Cauchy_def)
huffman@20751
   860
huffman@20696
   861
subsubsection {* Cauchy Sequences are Bounded *}
huffman@20696
   862
paulson@15082
   863
text{*A Cauchy sequence is bounded -- this is the standard
paulson@15082
   864
  proof mechanization rather than the nonstandard proof*}
paulson@15082
   865
huffman@20563
   866
lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real)
huffman@20552
   867
          ==>  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
huffman@20552
   868
apply (clarify, drule spec, drule (1) mp)
huffman@20563
   869
apply (simp only: norm_minus_commute)
huffman@20552
   870
apply (drule order_le_less_trans [OF norm_triangle_ineq2])
huffman@20552
   871
apply simp
huffman@20552
   872
done
paulson@15082
   873
paulson@15082
   874
lemma Cauchy_Bseq: "Cauchy X ==> Bseq X"
huffman@20552
   875
apply (simp add: Cauchy_def)
huffman@20552
   876
apply (drule spec, drule mp, rule zero_less_one, safe)
huffman@20552
   877
apply (drule_tac x="M" in spec, simp)
paulson@15082
   878
apply (drule lemmaCauchy)
huffman@22608
   879
apply (rule_tac k="M" in Bseq_offset)
huffman@20552
   880
apply (simp add: Bseq_def)
huffman@20552
   881
apply (rule_tac x="1 + norm (X M)" in exI)
huffman@20552
   882
apply (rule conjI, rule order_less_le_trans [OF zero_less_one], simp)
huffman@20552
   883
apply (simp add: order_less_imp_le)
paulson@15082
   884
done
paulson@15082
   885
huffman@20696
   886
subsubsection {* Cauchy Sequences are Convergent *}
paulson@15082
   887
huffman@20830
   888
axclass banach \<subseteq> real_normed_vector
huffman@20830
   889
  Cauchy_convergent: "Cauchy X \<Longrightarrow> convergent X"
huffman@20830
   890
huffman@22629
   891
theorem LIMSEQ_imp_Cauchy:
huffman@22629
   892
  assumes X: "X ----> a" shows "Cauchy X"
huffman@22629
   893
proof (rule CauchyI)
huffman@22629
   894
  fix e::real assume "0 < e"
huffman@22629
   895
  hence "0 < e/2" by simp
huffman@22629
   896
  with X have "\<exists>N. \<forall>n\<ge>N. norm (X n - a) < e/2" by (rule LIMSEQ_D)
huffman@22629
   897
  then obtain N where N: "\<forall>n\<ge>N. norm (X n - a) < e/2" ..
huffman@22629
   898
  show "\<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. norm (X m - X n) < e"
huffman@22629
   899
  proof (intro exI allI impI)
huffman@22629
   900
    fix m assume "N \<le> m"
huffman@22629
   901
    hence m: "norm (X m - a) < e/2" using N by fast
huffman@22629
   902
    fix n assume "N \<le> n"
huffman@22629
   903
    hence n: "norm (X n - a) < e/2" using N by fast
huffman@22629
   904
    have "norm (X m - X n) = norm ((X m - a) - (X n - a))" by simp
huffman@22629
   905
    also have "\<dots> \<le> norm (X m - a) + norm (X n - a)"
huffman@22629
   906
      by (rule norm_triangle_ineq4)
huffman@22629
   907
    also from m n have "\<dots> < e/2 + e/2" by (rule add_strict_mono)
huffman@22629
   908
    also have "e/2 + e/2 = e" by simp
huffman@22629
   909
    finally show "norm (X m - X n) < e" .
huffman@22629
   910
  qed
huffman@22629
   911
qed
huffman@22629
   912
huffman@20691
   913
lemma convergent_Cauchy: "convergent X \<Longrightarrow> Cauchy X"
huffman@22629
   914
unfolding convergent_def
huffman@22629
   915
by (erule exE, erule LIMSEQ_imp_Cauchy)
huffman@20691
   916
huffman@22629
   917
text {*
huffman@22629
   918
Proof that Cauchy sequences converge based on the one from
huffman@22629
   919
http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html
huffman@22629
   920
*}
huffman@22629
   921
huffman@22629
   922
text {*
huffman@22629
   923
  If sequence @{term "X"} is Cauchy, then its limit is the lub of
huffman@22629
   924
  @{term "{r::real. \<exists>N. \<forall>n\<ge>N. r < X n}"}
huffman@22629
   925
*}
huffman@22629
   926
huffman@22629
   927
lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
huffman@22629
   928
by (simp add: isUbI setleI)
huffman@22629
   929
huffman@22629
   930
lemma real_abs_diff_less_iff:
huffman@22629
   931
  "(\<bar>x - a\<bar> < (r::real)) = (a - r < x \<and> x < a + r)"
huffman@22629
   932
by auto
huffman@22629
   933
huffman@22629
   934
locale (open) real_Cauchy =
huffman@22629
   935
  fixes X :: "nat \<Rightarrow> real"
huffman@22629
   936
  assumes X: "Cauchy X"
huffman@22629
   937
  fixes S :: "real set"
huffman@22629
   938
  defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
huffman@22629
   939
huffman@22629
   940
lemma (in real_Cauchy) mem_S: "\<forall>n\<ge>N. x < X n \<Longrightarrow> x \<in> S"
huffman@22629
   941
by (unfold S_def, auto)
huffman@22629
   942
huffman@22629
   943
lemma (in real_Cauchy) bound_isUb:
huffman@22629
   944
  assumes N: "\<forall>n\<ge>N. X n < x"
huffman@22629
   945
  shows "isUb UNIV S x"
huffman@22629
   946
proof (rule isUb_UNIV_I)
huffman@22629
   947
  fix y::real assume "y \<in> S"
huffman@22629
   948
  hence "\<exists>M. \<forall>n\<ge>M. y < X n"
huffman@22629
   949
    by (simp add: S_def)
huffman@22629
   950
  then obtain M where "\<forall>n\<ge>M. y < X n" ..
huffman@22629
   951
  hence "y < X (max M N)" by simp
huffman@22629
   952
  also have "\<dots> < x" using N by simp
huffman@22629
   953
  finally show "y \<le> x"
huffman@22629
   954
    by (rule order_less_imp_le)
huffman@22629
   955
qed
huffman@22629
   956
huffman@22629
   957
lemma (in real_Cauchy) isLub_ex: "\<exists>u. isLub UNIV S u"
huffman@22629
   958
proof (rule reals_complete)
huffman@22629
   959
  obtain N where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (X m - X n) < 1"
huffman@22629
   960
    using CauchyD [OF X zero_less_one] by fast
huffman@22629
   961
  hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
huffman@22629
   962
  show "\<exists>x. x \<in> S"
huffman@22629
   963
  proof
huffman@22629
   964
    from N have "\<forall>n\<ge>N. X N - 1 < X n"
huffman@22629
   965
      by (simp add: real_abs_diff_less_iff)
huffman@22629
   966
    thus "X N - 1 \<in> S" by (rule mem_S)
huffman@22629
   967
  qed
huffman@22629
   968
  show "\<exists>u. isUb UNIV S u"
huffman@22629
   969
  proof
huffman@22629
   970
    from N have "\<forall>n\<ge>N. X n < X N + 1"
huffman@22629
   971
      by (simp add: real_abs_diff_less_iff)
huffman@22629
   972
    thus "isUb UNIV S (X N + 1)"
huffman@22629
   973
      by (rule bound_isUb)
huffman@22629
   974
  qed
huffman@22629
   975
qed
huffman@22629
   976
huffman@22629
   977
lemma (in real_Cauchy) isLub_imp_LIMSEQ:
huffman@22629
   978
  assumes x: "isLub UNIV S x"
huffman@22629
   979
  shows "X ----> x"
huffman@22629
   980
proof (rule LIMSEQ_I)
huffman@22629
   981
  fix r::real assume "0 < r"
huffman@22629
   982
  hence r: "0 < r/2" by simp
huffman@22629
   983
  obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
huffman@22629
   984
    using CauchyD [OF X r] by fast
huffman@22629
   985
  hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
huffman@22629
   986
  hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
huffman@22629
   987
    by (simp only: real_norm_def real_abs_diff_less_iff)
huffman@22629
   988
huffman@22629
   989
  from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
huffman@22629
   990
  hence "X N - r/2 \<in> S" by (rule mem_S)
huffman@22629
   991
  hence "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
huffman@22629
   992
  hence 1: "X N + r/2 \<le> x + r" by simp
huffman@22629
   993
huffman@22629
   994
  from N have "\<forall>n\<ge>N. X n < X N + r/2" by fast
huffman@22629
   995
  hence "isUb UNIV S (X N + r/2)" by (rule bound_isUb)
huffman@22629
   996
  hence "x \<le> X N + r/2" using x isLub_le_isUb by fast
huffman@22629
   997
  hence 2: "x - r \<le> X N - r/2" by simp
huffman@22629
   998
huffman@22629
   999
  show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
huffman@22629
  1000
  proof (intro exI allI impI)
huffman@22629
  1001
    fix n assume n: "N \<le> n"
huffman@22629
  1002
    from N n have 3: "X n < X N + r/2" by simp
huffman@22629
  1003
    from N n have 4: "X N - r/2 < X n" by simp
huffman@22629
  1004
    show "norm (X n - x) < r"
huffman@22629
  1005
      using order_less_le_trans [OF 3 1]
huffman@22629
  1006
            order_le_less_trans [OF 2 4]
huffman@22629
  1007
      by (simp add: real_abs_diff_less_iff)
huffman@22629
  1008
  qed
huffman@22629
  1009
qed
huffman@22629
  1010
huffman@22629
  1011
lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
huffman@22629
  1012
proof -
huffman@22629
  1013
  obtain x where "isLub UNIV S x"
huffman@22629
  1014
    using isLub_ex by fast
huffman@22629
  1015
  hence "X ----> x"
huffman@22629
  1016
    by (rule isLub_imp_LIMSEQ)
huffman@22629
  1017
  thus ?thesis ..
huffman@22629
  1018
qed
huffman@22629
  1019
huffman@20830
  1020
lemma real_Cauchy_convergent:
huffman@20830
  1021
  fixes X :: "nat \<Rightarrow> real"
huffman@20830
  1022
  shows "Cauchy X \<Longrightarrow> convergent X"
huffman@22629
  1023
unfolding convergent_def by (rule real_Cauchy.LIMSEQ_ex)
huffman@20830
  1024
huffman@20830
  1025
instance real :: banach
huffman@20830
  1026
by intro_classes (rule real_Cauchy_convergent)
huffman@20830
  1027
huffman@20830
  1028
lemma Cauchy_convergent_iff:
huffman@20830
  1029
  fixes X :: "nat \<Rightarrow> 'a::banach"
huffman@20830
  1030
  shows "Cauchy X = convergent X"
huffman@20830
  1031
by (fast intro: Cauchy_convergent convergent_Cauchy)
paulson@15082
  1032
paulson@15082
  1033
huffman@20696
  1034
subsection {* Power Sequences *}
paulson@15082
  1035
paulson@15082
  1036
text{*The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
paulson@15082
  1037
"x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
paulson@15082
  1038
  also fact that bounded and monotonic sequence converges.*}
paulson@15082
  1039
huffman@20552
  1040
lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)"
paulson@15082
  1041
apply (simp add: Bseq_def)
paulson@15082
  1042
apply (rule_tac x = 1 in exI)
paulson@15082
  1043
apply (simp add: power_abs)
huffman@22974
  1044
apply (auto dest: power_mono)
paulson@15082
  1045
done
paulson@15082
  1046
paulson@15082
  1047
lemma monoseq_realpow: "[| 0 \<le> x; x \<le> 1 |] ==> monoseq (%n. x ^ n)"
paulson@15082
  1048
apply (clarify intro!: mono_SucI2)
paulson@15082
  1049
apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing, auto)
paulson@15082
  1050
done
paulson@15082
  1051
huffman@20552
  1052
lemma convergent_realpow:
huffman@20552
  1053
  "[| 0 \<le> (x::real); x \<le> 1 |] ==> convergent (%n. x ^ n)"
paulson@15082
  1054
by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
paulson@15082
  1055
huffman@22628
  1056
lemma LIMSEQ_inverse_realpow_zero_lemma:
huffman@22628
  1057
  fixes x :: real
huffman@22628
  1058
  assumes x: "0 \<le> x"
huffman@22628
  1059
  shows "real n * x + 1 \<le> (x + 1) ^ n"
huffman@22628
  1060
apply (induct n)
huffman@22628
  1061
apply simp
huffman@22628
  1062
apply simp
huffman@22628
  1063
apply (rule order_trans)
huffman@22628
  1064
prefer 2
huffman@22628
  1065
apply (erule mult_left_mono)
huffman@22628
  1066
apply (rule add_increasing [OF x], simp)
huffman@22628
  1067
apply (simp add: real_of_nat_Suc)
huffman@22628
  1068
apply (simp add: ring_distrib)
huffman@22628
  1069
apply (simp add: mult_nonneg_nonneg x)
huffman@22628
  1070
done
huffman@22628
  1071
huffman@22628
  1072
lemma LIMSEQ_inverse_realpow_zero:
huffman@22628
  1073
  "1 < (x::real) \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) ----> 0"
huffman@22628
  1074
proof (rule LIMSEQ_inverse_zero [rule_format])
huffman@22628
  1075
  fix y :: real
huffman@22628
  1076
  assume x: "1 < x"
huffman@22628
  1077
  hence "0 < x - 1" by simp
huffman@22628
  1078
  hence "\<forall>y. \<exists>N::nat. y < real N * (x - 1)"
huffman@22628
  1079
    by (rule reals_Archimedean3)
huffman@22628
  1080
  hence "\<exists>N::nat. y < real N * (x - 1)" ..
huffman@22628
  1081
  then obtain N::nat where "y < real N * (x - 1)" ..
huffman@22628
  1082
  also have "\<dots> \<le> real N * (x - 1) + 1" by simp
huffman@22628
  1083
  also have "\<dots> \<le> (x - 1 + 1) ^ N"
huffman@22628
  1084
    by (rule LIMSEQ_inverse_realpow_zero_lemma, cut_tac x, simp)
huffman@22628
  1085
  also have "\<dots> = x ^ N" by simp
huffman@22628
  1086
  finally have "y < x ^ N" .
huffman@22628
  1087
  hence "\<forall>n\<ge>N. y < x ^ n"
huffman@22628
  1088
    apply clarify
huffman@22628
  1089
    apply (erule order_less_le_trans)
huffman@22628
  1090
    apply (erule power_increasing)
huffman@22628
  1091
    apply (rule order_less_imp_le [OF x])
huffman@22628
  1092
    done
huffman@22628
  1093
  thus "\<exists>N. \<forall>n\<ge>N. y < x ^ n" ..
huffman@22628
  1094
qed
huffman@22628
  1095
huffman@20552
  1096
lemma LIMSEQ_realpow_zero:
huffman@22628
  1097
  "\<lbrakk>0 \<le> (x::real); x < 1\<rbrakk> \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@22628
  1098
proof (cases)
huffman@22628
  1099
  assume "x = 0"
huffman@22628
  1100
  hence "(\<lambda>n. x ^ Suc n) ----> 0" by (simp add: LIMSEQ_const)
huffman@22628
  1101
  thus ?thesis by (rule LIMSEQ_imp_Suc)
huffman@22628
  1102
next
huffman@22628
  1103
  assume "0 \<le> x" and "x \<noteq> 0"
huffman@22628
  1104
  hence x0: "0 < x" by simp
huffman@22628
  1105
  assume x1: "x < 1"
huffman@22628
  1106
  from x0 x1 have "1 < inverse x"
huffman@22628
  1107
    by (rule real_inverse_gt_one)
huffman@22628
  1108
  hence "(\<lambda>n. inverse (inverse x ^ n)) ----> 0"
huffman@22628
  1109
    by (rule LIMSEQ_inverse_realpow_zero)
huffman@22628
  1110
  thus ?thesis by (simp add: power_inverse)
huffman@22628
  1111
qed
paulson@15082
  1112
huffman@20685
  1113
lemma LIMSEQ_power_zero:
huffman@22974
  1114
  fixes x :: "'a::{real_normed_algebra_1,recpower}"
huffman@20685
  1115
  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@20685
  1116
apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
huffman@22974
  1117
apply (simp only: LIMSEQ_Zseq_iff, erule Zseq_le)
huffman@22974
  1118
apply (simp add: power_abs norm_power_ineq)
huffman@20685
  1119
done
huffman@20685
  1120
huffman@20552
  1121
lemma LIMSEQ_divide_realpow_zero:
huffman@20552
  1122
  "1 < (x::real) ==> (%n. a / (x ^ n)) ----> 0"
paulson@15082
  1123
apply (cut_tac a = a and x1 = "inverse x" in
paulson@15082
  1124
        LIMSEQ_mult [OF LIMSEQ_const LIMSEQ_realpow_zero])
paulson@15082
  1125
apply (auto simp add: divide_inverse power_inverse)
paulson@15082
  1126
apply (simp add: inverse_eq_divide pos_divide_less_eq)
paulson@15082
  1127
done
paulson@15082
  1128
paulson@15102
  1129
text{*Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}*}
paulson@15082
  1130
huffman@20552
  1131
lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < (1::real) ==> (%n. \<bar>c\<bar> ^ n) ----> 0"
huffman@20685
  1132
by (rule LIMSEQ_realpow_zero [OF abs_ge_zero])
paulson@15082
  1133
huffman@20552
  1134
lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < (1::real) ==> (%n. c ^ n) ----> 0"
paulson@15082
  1135
apply (rule LIMSEQ_rabs_zero [THEN iffD1])
paulson@15082
  1136
apply (auto intro: LIMSEQ_rabs_realpow_zero simp add: power_abs)
paulson@15082
  1137
done
paulson@15082
  1138
paulson@10751
  1139
end