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