src/HOL/SEQ.thy
author huffman
Sun Apr 01 16:09:58 2012 +0200 (2012-04-01)
changeset 47255 30a1692557b0
parent 44714 a8990b5d7365
child 50087 635d73673b5e
permissions -rw-r--r--
removed Nat_Numeral.thy, moving all theorems elsewhere
wenzelm@32960
     1
(*  Title:      HOL/SEQ.thy
wenzelm@32960
     2
    Author:     Jacques D. Fleuriot, University of Cambridge
wenzelm@32960
     3
    Author:     Lawrence C Paulson
wenzelm@32960
     4
    Author:     Jeremy Avigad
wenzelm@32960
     5
    Author:     Brian Huffman
wenzelm@32960
     6
wenzelm@32960
     7
Convergence of sequences and series.
paulson@15082
     8
*)
paulson@10751
     9
huffman@22631
    10
header {* Sequences and Convergence *}
huffman@17439
    11
nipkow@15131
    12
theory SEQ
huffman@36822
    13
imports Limits RComplete
nipkow@15131
    14
begin
paulson@10751
    15
hoelzl@41972
    16
subsection {* Monotone sequences and subsequences *}
paulson@10751
    17
wenzelm@21404
    18
definition
hoelzl@41367
    19
  monoseq :: "(nat \<Rightarrow> 'a::order) \<Rightarrow> bool" where
hoelzl@41367
    20
    --{*Definition of monotonicity.
hoelzl@41367
    21
        The use of disjunction here complicates proofs considerably.
hoelzl@41367
    22
        One alternative is to add a Boolean argument to indicate the direction.
paulson@30730
    23
        Another is to develop the notions of increasing and decreasing first.*}
haftmann@37767
    24
  "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
    25
wenzelm@21404
    26
definition
hoelzl@41367
    27
  incseq :: "(nat \<Rightarrow> 'a::order) \<Rightarrow> bool" where
paulson@30730
    28
    --{*Increasing sequence*}
hoelzl@41367
    29
  "incseq X \<longleftrightarrow> (\<forall>m. \<forall>n\<ge>m. X m \<le> X n)"
paulson@30730
    30
paulson@30730
    31
definition
hoelzl@41367
    32
  decseq :: "(nat \<Rightarrow> 'a::order) \<Rightarrow> bool" where
hoelzl@41367
    33
    --{*Decreasing sequence*}
hoelzl@41367
    34
  "decseq X \<longleftrightarrow> (\<forall>m. \<forall>n\<ge>m. X n \<le> X m)"
paulson@30730
    35
paulson@30730
    36
definition
hoelzl@41367
    37
  subseq :: "(nat \<Rightarrow> nat) \<Rightarrow> bool" where
paulson@15082
    38
    --{*Definition of subsequence*}
hoelzl@41367
    39
  "subseq f \<longleftrightarrow> (\<forall>m. \<forall>n>m. f m < f n)"
paulson@10751
    40
hoelzl@41972
    41
lemma incseq_mono: "mono f \<longleftrightarrow> incseq f"
hoelzl@41972
    42
  unfolding mono_def incseq_def by auto
hoelzl@41972
    43
hoelzl@41972
    44
lemma incseq_SucI:
hoelzl@41972
    45
  "(\<And>n. X n \<le> X (Suc n)) \<Longrightarrow> incseq X"
hoelzl@41972
    46
  using lift_Suc_mono_le[of X]
hoelzl@41972
    47
  by (auto simp: incseq_def)
hoelzl@41972
    48
hoelzl@41972
    49
lemma incseqD: "\<And>i j. incseq f \<Longrightarrow> i \<le> j \<Longrightarrow> f i \<le> f j"
hoelzl@41972
    50
  by (auto simp: incseq_def)
hoelzl@41972
    51
hoelzl@41972
    52
lemma incseq_SucD: "incseq A \<Longrightarrow> A i \<le> A (Suc i)"
hoelzl@41972
    53
  using incseqD[of A i "Suc i"] by auto
hoelzl@41972
    54
hoelzl@41972
    55
lemma incseq_Suc_iff: "incseq f \<longleftrightarrow> (\<forall>n. f n \<le> f (Suc n))"
hoelzl@41972
    56
  by (auto intro: incseq_SucI dest: incseq_SucD)
hoelzl@41972
    57
hoelzl@41972
    58
lemma incseq_const[simp, intro]: "incseq (\<lambda>x. k)"
hoelzl@41972
    59
  unfolding incseq_def by auto
hoelzl@41972
    60
hoelzl@41972
    61
lemma decseq_SucI:
hoelzl@41972
    62
  "(\<And>n. X (Suc n) \<le> X n) \<Longrightarrow> decseq X"
hoelzl@41972
    63
  using order.lift_Suc_mono_le[OF dual_order, of X]
hoelzl@41972
    64
  by (auto simp: decseq_def)
hoelzl@41972
    65
hoelzl@41972
    66
lemma decseqD: "\<And>i j. decseq f \<Longrightarrow> i \<le> j \<Longrightarrow> f j \<le> f i"
hoelzl@41972
    67
  by (auto simp: decseq_def)
hoelzl@41972
    68
hoelzl@41972
    69
lemma decseq_SucD: "decseq A \<Longrightarrow> A (Suc i) \<le> A i"
hoelzl@41972
    70
  using decseqD[of A i "Suc i"] by auto
hoelzl@41972
    71
hoelzl@41972
    72
lemma decseq_Suc_iff: "decseq f \<longleftrightarrow> (\<forall>n. f (Suc n) \<le> f n)"
hoelzl@41972
    73
  by (auto intro: decseq_SucI dest: decseq_SucD)
hoelzl@41972
    74
hoelzl@41972
    75
lemma decseq_const[simp, intro]: "decseq (\<lambda>x. k)"
hoelzl@41972
    76
  unfolding decseq_def by auto
hoelzl@41972
    77
hoelzl@41972
    78
lemma monoseq_iff: "monoseq X \<longleftrightarrow> incseq X \<or> decseq X"
hoelzl@41972
    79
  unfolding monoseq_def incseq_def decseq_def ..
hoelzl@41972
    80
hoelzl@41972
    81
lemma monoseq_Suc:
hoelzl@41972
    82
  "monoseq X \<longleftrightarrow> (\<forall>n. X n \<le> X (Suc n)) \<or> (\<forall>n. X (Suc n) \<le> X n)"
hoelzl@41972
    83
  unfolding monoseq_iff incseq_Suc_iff decseq_Suc_iff ..
hoelzl@41972
    84
hoelzl@41972
    85
lemma monoI1: "\<forall>m. \<forall> n \<ge> m. X m \<le> X n ==> monoseq X"
hoelzl@41972
    86
by (simp add: monoseq_def)
hoelzl@41972
    87
hoelzl@41972
    88
lemma monoI2: "\<forall>m. \<forall> n \<ge> m. X n \<le> X m ==> monoseq X"
hoelzl@41972
    89
by (simp add: monoseq_def)
hoelzl@41972
    90
hoelzl@41972
    91
lemma mono_SucI1: "\<forall>n. X n \<le> X (Suc n) ==> monoseq X"
hoelzl@41972
    92
by (simp add: monoseq_Suc)
hoelzl@41972
    93
hoelzl@41972
    94
lemma mono_SucI2: "\<forall>n. X (Suc n) \<le> X n ==> monoseq X"
hoelzl@41972
    95
by (simp add: monoseq_Suc)
hoelzl@41972
    96
hoelzl@41972
    97
lemma monoseq_minus:
hoelzl@41972
    98
  fixes a :: "nat \<Rightarrow> 'a::ordered_ab_group_add"
hoelzl@41972
    99
  assumes "monoseq a"
hoelzl@41972
   100
  shows "monoseq (\<lambda> n. - a n)"
hoelzl@41972
   101
proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@41972
   102
  case True
hoelzl@41972
   103
  hence "\<forall> m. \<forall> n \<ge> m. - a n \<le> - a m" by auto
hoelzl@41972
   104
  thus ?thesis by (rule monoI2)
hoelzl@41972
   105
next
hoelzl@41972
   106
  case False
hoelzl@41972
   107
  hence "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" using `monoseq a`[unfolded monoseq_def] by auto
hoelzl@41972
   108
  thus ?thesis by (rule monoI1)
hoelzl@41972
   109
qed
hoelzl@41972
   110
hoelzl@41972
   111
text{*Subsequence (alternative definition, (e.g. Hoskins)*}
hoelzl@41972
   112
hoelzl@41972
   113
lemma subseq_Suc_iff: "subseq f = (\<forall>n. (f n) < (f (Suc n)))"
hoelzl@41972
   114
apply (simp add: subseq_def)
hoelzl@41972
   115
apply (auto dest!: less_imp_Suc_add)
hoelzl@41972
   116
apply (induct_tac k)
hoelzl@41972
   117
apply (auto intro: less_trans)
hoelzl@41972
   118
done
hoelzl@41972
   119
hoelzl@41972
   120
text{* for any sequence, there is a monotonic subsequence *}
hoelzl@41972
   121
lemma seq_monosub:
hoelzl@41972
   122
  fixes s :: "nat => 'a::linorder"
hoelzl@41972
   123
  shows "\<exists>f. subseq f \<and> monoseq (\<lambda> n. (s (f n)))"
hoelzl@41972
   124
proof cases
hoelzl@41972
   125
  let "?P p n" = "p > n \<and> (\<forall>m\<ge>p. s m \<le> s p)"
hoelzl@41972
   126
  assume *: "\<forall>n. \<exists>p. ?P p n"
hoelzl@41972
   127
  def f \<equiv> "nat_rec (SOME p. ?P p 0) (\<lambda>_ n. SOME p. ?P p n)"
hoelzl@41972
   128
  have f_0: "f 0 = (SOME p. ?P p 0)" unfolding f_def by simp
hoelzl@41972
   129
  have f_Suc: "\<And>i. f (Suc i) = (SOME p. ?P p (f i))" unfolding f_def nat_rec_Suc ..
hoelzl@41972
   130
  have P_0: "?P (f 0) 0" unfolding f_0 using *[rule_format] by (rule someI2_ex) auto
hoelzl@41972
   131
  have P_Suc: "\<And>i. ?P (f (Suc i)) (f i)" unfolding f_Suc using *[rule_format] by (rule someI2_ex) auto
hoelzl@41972
   132
  then have "subseq f" unfolding subseq_Suc_iff by auto
hoelzl@41972
   133
  moreover have "monoseq (\<lambda>n. s (f n))" unfolding monoseq_Suc
hoelzl@41972
   134
  proof (intro disjI2 allI)
hoelzl@41972
   135
    fix n show "s (f (Suc n)) \<le> s (f n)"
hoelzl@41972
   136
    proof (cases n)
hoelzl@41972
   137
      case 0 with P_Suc[of 0] P_0 show ?thesis by auto
hoelzl@41972
   138
    next
hoelzl@41972
   139
      case (Suc m)
hoelzl@41972
   140
      from P_Suc[of n] Suc have "f (Suc m) \<le> f (Suc (Suc m))" by simp
hoelzl@41972
   141
      with P_Suc Suc show ?thesis by simp
hoelzl@41972
   142
    qed
hoelzl@41972
   143
  qed
hoelzl@41972
   144
  ultimately show ?thesis by auto
hoelzl@41972
   145
next
hoelzl@41972
   146
  let "?P p m" = "m < p \<and> s m < s p"
hoelzl@41972
   147
  assume "\<not> (\<forall>n. \<exists>p>n. (\<forall>m\<ge>p. s m \<le> s p))"
hoelzl@41972
   148
  then obtain N where N: "\<And>p. p > N \<Longrightarrow> \<exists>m>p. s p < s m" by (force simp: not_le le_less)
hoelzl@41972
   149
  def f \<equiv> "nat_rec (SOME p. ?P p (Suc N)) (\<lambda>_ n. SOME p. ?P p n)"
hoelzl@41972
   150
  have f_0: "f 0 = (SOME p. ?P p (Suc N))" unfolding f_def by simp
hoelzl@41972
   151
  have f_Suc: "\<And>i. f (Suc i) = (SOME p. ?P p (f i))" unfolding f_def nat_rec_Suc ..
hoelzl@41972
   152
  have P_0: "?P (f 0) (Suc N)"
hoelzl@41972
   153
    unfolding f_0 some_eq_ex[of "\<lambda>p. ?P p (Suc N)"] using N[of "Suc N"] by auto
hoelzl@41972
   154
  { fix i have "N < f i \<Longrightarrow> ?P (f (Suc i)) (f i)"
hoelzl@41972
   155
      unfolding f_Suc some_eq_ex[of "\<lambda>p. ?P p (f i)"] using N[of "f i"] . }
hoelzl@41972
   156
  note P' = this
hoelzl@41972
   157
  { fix i have "N < f i \<and> ?P (f (Suc i)) (f i)"
hoelzl@41972
   158
      by (induct i) (insert P_0 P', auto) }
hoelzl@41972
   159
  then have "subseq f" "monoseq (\<lambda>x. s (f x))"
hoelzl@41972
   160
    unfolding subseq_Suc_iff monoseq_Suc by (auto simp: not_le intro: less_imp_le)
hoelzl@41972
   161
  then show ?thesis by auto
hoelzl@41972
   162
qed
hoelzl@41972
   163
hoelzl@41972
   164
lemma seq_suble: assumes sf: "subseq f" shows "n \<le> f n"
hoelzl@41972
   165
proof(induct n)
hoelzl@41972
   166
  case 0 thus ?case by simp
hoelzl@41972
   167
next
hoelzl@41972
   168
  case (Suc n)
hoelzl@41972
   169
  from sf[unfolded subseq_Suc_iff, rule_format, of n] Suc.hyps
hoelzl@41972
   170
  have "n < f (Suc n)" by arith
hoelzl@41972
   171
  thus ?case by arith
hoelzl@41972
   172
qed
hoelzl@41972
   173
hoelzl@41972
   174
lemma incseq_imp_monoseq:  "incseq X \<Longrightarrow> monoseq X"
hoelzl@41972
   175
  by (simp add: incseq_def monoseq_def)
hoelzl@41972
   176
hoelzl@41972
   177
lemma decseq_imp_monoseq:  "decseq X \<Longrightarrow> monoseq X"
hoelzl@41972
   178
  by (simp add: decseq_def monoseq_def)
hoelzl@41972
   179
hoelzl@41972
   180
lemma decseq_eq_incseq:
hoelzl@41972
   181
  fixes X :: "nat \<Rightarrow> 'a::ordered_ab_group_add" shows "decseq X = incseq (\<lambda>n. - X n)" 
hoelzl@41972
   182
  by (simp add: decseq_def incseq_def)
hoelzl@41972
   183
hoelzl@41972
   184
subsection {* Defintions of limits *}
hoelzl@41972
   185
huffman@44206
   186
abbreviation (in topological_space)
huffman@44206
   187
  LIMSEQ :: "[nat \<Rightarrow> 'a, 'a] \<Rightarrow> bool"
hoelzl@41972
   188
    ("((_)/ ----> (_))" [60, 60] 60) where
hoelzl@41972
   189
  "X ----> L \<equiv> (X ---> L) sequentially"
hoelzl@41972
   190
hoelzl@41972
   191
definition
huffman@44205
   192
  lim :: "(nat \<Rightarrow> 'a::t2_space) \<Rightarrow> 'a" where
hoelzl@41972
   193
    --{*Standard definition of limit using choice operator*}
hoelzl@41972
   194
  "lim X = (THE L. X ----> L)"
hoelzl@41972
   195
huffman@44206
   196
definition (in topological_space) convergent :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool" where
hoelzl@41972
   197
  "convergent X = (\<exists>L. X ----> L)"
hoelzl@41972
   198
hoelzl@41972
   199
definition
hoelzl@41972
   200
  Bseq :: "(nat => 'a::real_normed_vector) => bool" where
hoelzl@41972
   201
    --{*Standard definition for bounded sequence*}
hoelzl@41972
   202
  "Bseq X = (\<exists>K>0.\<forall>n. norm (X n) \<le> K)"
hoelzl@41972
   203
huffman@44206
   204
definition (in metric_space) Cauchy :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool" where
haftmann@37767
   205
  "Cauchy X = (\<forall>e>0. \<exists>M. \<forall>m \<ge> M. \<forall>n \<ge> M. dist (X m) (X n) < e)"
paulson@10751
   206
paulson@15082
   207
huffman@22608
   208
subsection {* Bounded Sequences *}
huffman@22608
   209
wenzelm@26312
   210
lemma BseqI': assumes K: "\<And>n. norm (X n) \<le> K" shows "Bseq X"
huffman@22608
   211
unfolding Bseq_def
huffman@22608
   212
proof (intro exI conjI allI)
huffman@22608
   213
  show "0 < max K 1" by simp
huffman@22608
   214
next
huffman@22608
   215
  fix n::nat
huffman@22608
   216
  have "norm (X n) \<le> K" by (rule K)
huffman@22608
   217
  thus "norm (X n) \<le> max K 1" by simp
huffman@22608
   218
qed
huffman@22608
   219
huffman@22608
   220
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
   221
unfolding Bseq_def by auto
huffman@22608
   222
wenzelm@26312
   223
lemma BseqI2': assumes K: "\<forall>n\<ge>N. norm (X n) \<le> K" shows "Bseq X"
wenzelm@26312
   224
proof (rule BseqI')
huffman@22608
   225
  let ?A = "norm ` X ` {..N}"
huffman@22608
   226
  have 1: "finite ?A" by simp
huffman@22608
   227
  fix n::nat
huffman@22608
   228
  show "norm (X n) \<le> max K (Max ?A)"
huffman@22608
   229
  proof (cases rule: linorder_le_cases)
huffman@22608
   230
    assume "n \<ge> N"
huffman@22608
   231
    hence "norm (X n) \<le> K" using K by simp
huffman@22608
   232
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
   233
  next
huffman@22608
   234
    assume "n \<le> N"
huffman@22608
   235
    hence "norm (X n) \<in> ?A" by simp
haftmann@26757
   236
    with 1 have "norm (X n) \<le> Max ?A" by (rule Max_ge)
huffman@22608
   237
    thus "norm (X n) \<le> max K (Max ?A)" by simp
huffman@22608
   238
  qed
huffman@22608
   239
qed
huffman@22608
   240
huffman@22608
   241
lemma Bseq_ignore_initial_segment: "Bseq X \<Longrightarrow> Bseq (\<lambda>n. X (n + k))"
huffman@22608
   242
unfolding Bseq_def by auto
huffman@22608
   243
huffman@22608
   244
lemma Bseq_offset: "Bseq (\<lambda>n. X (n + k)) \<Longrightarrow> Bseq X"
huffman@22608
   245
apply (erule BseqE)
wenzelm@26312
   246
apply (rule_tac N="k" and K="K" in BseqI2')
huffman@22608
   247
apply clarify
huffman@22608
   248
apply (drule_tac x="n - k" in spec, simp)
huffman@22608
   249
done
huffman@22608
   250
huffman@31355
   251
lemma Bseq_conv_Bfun: "Bseq X \<longleftrightarrow> Bfun X sequentially"
huffman@31355
   252
unfolding Bfun_def eventually_sequentially
huffman@31355
   253
apply (rule iffI)
haftmann@32064
   254
apply (simp add: Bseq_def)
haftmann@32064
   255
apply (auto intro: BseqI2')
huffman@31355
   256
done
huffman@31355
   257
huffman@22608
   258
huffman@20696
   259
subsection {* Limits of Sequences *}
huffman@20696
   260
paulson@32877
   261
lemma [trans]: "X=Y ==> Y ----> z ==> X ----> z"
paulson@32877
   262
  by simp
paulson@32877
   263
huffman@36660
   264
lemma LIMSEQ_def: "X ----> L = (\<forall>r>0. \<exists>no. \<forall>n\<ge>no. dist (X n) L < r)"
huffman@36660
   265
unfolding tendsto_iff eventually_sequentially ..
huffman@31392
   266
paulson@15082
   267
lemma LIMSEQ_iff:
huffman@31336
   268
  fixes L :: "'a::real_normed_vector"
huffman@31336
   269
  shows "(X ----> L) = (\<forall>r>0. \<exists>no. \<forall>n \<ge> no. norm (X n - L) < r)"
huffman@31336
   270
unfolding LIMSEQ_def dist_norm ..
huffman@22608
   271
paulson@33271
   272
lemma LIMSEQ_iff_nz: "X ----> L = (\<forall>r>0. \<exists>no>0. \<forall>n\<ge>no. dist (X n) L < r)"
huffman@36660
   273
  unfolding LIMSEQ_def by (metis Suc_leD zero_less_Suc)
paulson@33271
   274
huffman@31336
   275
lemma metric_LIMSEQ_I:
huffman@31336
   276
  "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. dist (X n) L < r) \<Longrightarrow> X ----> L"
huffman@31336
   277
by (simp add: LIMSEQ_def)
huffman@31336
   278
huffman@31336
   279
lemma metric_LIMSEQ_D:
huffman@31336
   280
  "\<lbrakk>X ----> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. dist (X n) L < r"
huffman@31336
   281
by (simp add: LIMSEQ_def)
paulson@15082
   282
huffman@20751
   283
lemma LIMSEQ_I:
huffman@31336
   284
  fixes L :: "'a::real_normed_vector"
huffman@31336
   285
  shows "(\<And>r. 0 < r \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r) \<Longrightarrow> X ----> L"
huffman@31336
   286
by (simp add: LIMSEQ_iff)
huffman@20751
   287
huffman@20751
   288
lemma LIMSEQ_D:
huffman@31336
   289
  fixes L :: "'a::real_normed_vector"
huffman@31336
   290
  shows "\<lbrakk>X ----> L; 0 < r\<rbrakk> \<Longrightarrow> \<exists>no. \<forall>n\<ge>no. norm (X n - L) < r"
huffman@31336
   291
by (simp add: LIMSEQ_iff)
huffman@20751
   292
huffman@36662
   293
lemma LIMSEQ_const_iff:
huffman@44205
   294
  fixes k l :: "'a::t2_space"
huffman@36662
   295
  shows "(\<lambda>n. k) ----> l \<longleftrightarrow> k = l"
huffman@44205
   296
  using trivial_limit_sequentially by (rule tendsto_const_iff)
huffman@22608
   297
huffman@22615
   298
lemma LIMSEQ_ignore_initial_segment:
huffman@22615
   299
  "f ----> a \<Longrightarrow> (\<lambda>n. f (n + k)) ----> a"
huffman@36662
   300
apply (rule topological_tendstoI)
huffman@36662
   301
apply (drule (2) topological_tendstoD)
huffman@36662
   302
apply (simp only: eventually_sequentially)
huffman@22615
   303
apply (erule exE, rename_tac N)
huffman@22615
   304
apply (rule_tac x=N in exI)
huffman@22615
   305
apply simp
huffman@22615
   306
done
huffman@20696
   307
huffman@22615
   308
lemma LIMSEQ_offset:
huffman@22615
   309
  "(\<lambda>n. f (n + k)) ----> a \<Longrightarrow> f ----> a"
huffman@36662
   310
apply (rule topological_tendstoI)
huffman@36662
   311
apply (drule (2) topological_tendstoD)
huffman@36662
   312
apply (simp only: eventually_sequentially)
huffman@22615
   313
apply (erule exE, rename_tac N)
huffman@22615
   314
apply (rule_tac x="N + k" in exI)
huffman@22615
   315
apply clarify
huffman@22615
   316
apply (drule_tac x="n - k" in spec)
huffman@22615
   317
apply (simp add: le_diff_conv2)
huffman@20696
   318
done
huffman@20696
   319
huffman@22615
   320
lemma LIMSEQ_Suc: "f ----> l \<Longrightarrow> (\<lambda>n. f (Suc n)) ----> l"
huffman@30082
   321
by (drule_tac k="Suc 0" in LIMSEQ_ignore_initial_segment, simp)
huffman@22615
   322
huffman@22615
   323
lemma LIMSEQ_imp_Suc: "(\<lambda>n. f (Suc n)) ----> l \<Longrightarrow> f ----> l"
huffman@30082
   324
by (rule_tac k="Suc 0" in LIMSEQ_offset, simp)
huffman@22615
   325
huffman@22615
   326
lemma LIMSEQ_Suc_iff: "(\<lambda>n. f (Suc n)) ----> l = f ----> l"
huffman@22615
   327
by (blast intro: LIMSEQ_imp_Suc LIMSEQ_Suc)
huffman@22615
   328
hoelzl@29803
   329
lemma LIMSEQ_linear: "\<lbrakk> X ----> x ; l > 0 \<rbrakk> \<Longrightarrow> (\<lambda> n. X (n * l)) ----> x"
huffman@36662
   330
  unfolding tendsto_def eventually_sequentially
hoelzl@29803
   331
  by (metis div_le_dividend div_mult_self1_is_m le_trans nat_mult_commute)
hoelzl@29803
   332
huffman@36662
   333
lemma LIMSEQ_unique:
huffman@44205
   334
  fixes a b :: "'a::t2_space"
huffman@36662
   335
  shows "\<lbrakk>X ----> a; X ----> b\<rbrakk> \<Longrightarrow> a = b"
huffman@44205
   336
  using trivial_limit_sequentially by (rule tendsto_unique)
huffman@22608
   337
paulson@32877
   338
lemma increasing_LIMSEQ:
paulson@32877
   339
  fixes f :: "nat \<Rightarrow> real"
paulson@32877
   340
  assumes inc: "!!n. f n \<le> f (Suc n)"
paulson@32877
   341
      and bdd: "!!n. f n \<le> l"
paulson@32877
   342
      and en: "!!e. 0 < e \<Longrightarrow> \<exists>n. l \<le> f n + e"
paulson@32877
   343
  shows "f ----> l"
paulson@32877
   344
proof (auto simp add: LIMSEQ_def)
paulson@32877
   345
  fix e :: real
paulson@32877
   346
  assume e: "0 < e"
paulson@32877
   347
  then obtain N where "l \<le> f N + e/2"
paulson@32877
   348
    by (metis half_gt_zero e en that)
paulson@32877
   349
  hence N: "l < f N + e" using e
paulson@32877
   350
    by simp
paulson@32877
   351
  { fix k
paulson@32877
   352
    have [simp]: "!!n. \<bar>f n - l\<bar> = l - f n"
paulson@32877
   353
      by (simp add: bdd) 
paulson@32877
   354
    have "\<bar>f (N+k) - l\<bar> < e"
paulson@32877
   355
    proof (induct k)
paulson@32877
   356
      case 0 show ?case using N
wenzelm@32960
   357
        by simp   
paulson@32877
   358
    next
paulson@32877
   359
      case (Suc k) thus ?case using N inc [of "N+k"]
wenzelm@32960
   360
        by simp
paulson@32877
   361
    qed 
paulson@32877
   362
  } note 1 = this
paulson@32877
   363
  { fix n
paulson@32877
   364
    have "N \<le> n \<Longrightarrow> \<bar>f n - l\<bar> < e" using 1 [of "n-N"]
paulson@32877
   365
      by simp 
paulson@32877
   366
  } note [intro] = this
paulson@32877
   367
  show " \<exists>no. \<forall>n\<ge>no. dist (f n) l < e"
paulson@32877
   368
    by (auto simp add: dist_real_def) 
paulson@32877
   369
  qed
paulson@32877
   370
huffman@22608
   371
lemma Bseq_inverse_lemma:
huffman@22608
   372
  fixes x :: "'a::real_normed_div_algebra"
huffman@22608
   373
  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
huffman@22608
   374
apply (subst nonzero_norm_inverse, clarsimp)
huffman@22608
   375
apply (erule (1) le_imp_inverse_le)
huffman@22608
   376
done
huffman@22608
   377
huffman@22608
   378
lemma Bseq_inverse:
huffman@22608
   379
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   380
  shows "\<lbrakk>X ----> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))"
huffman@36660
   381
unfolding Bseq_conv_Bfun by (rule Bfun_inverse)
huffman@22608
   382
huffman@31336
   383
lemma LIMSEQ_diff_approach_zero:
huffman@31336
   384
  fixes L :: "'a::real_normed_vector"
huffman@31336
   385
  shows "g ----> L ==> (%x. f x - g x) ----> 0 ==> f ----> L"
huffman@44313
   386
  by (drule (1) tendsto_add, simp)
huffman@22614
   387
huffman@31336
   388
lemma LIMSEQ_diff_approach_zero2:
huffman@31336
   389
  fixes L :: "'a::real_normed_vector"
hoelzl@35292
   390
  shows "f ----> L ==> (%x. f x - g x) ----> 0 ==> g ----> L"
huffman@44313
   391
  by (drule (1) tendsto_diff, simp)
huffman@22614
   392
huffman@22614
   393
text{*An unbounded sequence's inverse tends to 0*}
huffman@22614
   394
huffman@22614
   395
lemma LIMSEQ_inverse_zero:
huffman@22974
   396
  "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> 0"
huffman@22974
   397
apply (rule LIMSEQ_I)
huffman@22974
   398
apply (drule_tac x="inverse r" in spec, safe)
huffman@22974
   399
apply (rule_tac x="N" in exI, safe)
huffman@22974
   400
apply (drule_tac x="n" in spec, safe)
huffman@22614
   401
apply (frule positive_imp_inverse_positive)
huffman@22974
   402
apply (frule (1) less_imp_inverse_less)
huffman@22974
   403
apply (subgoal_tac "0 < X n", simp)
huffman@22974
   404
apply (erule (1) order_less_trans)
huffman@22614
   405
done
huffman@22614
   406
huffman@22614
   407
text{*The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity*}
huffman@22614
   408
huffman@22614
   409
lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) ----> 0"
huffman@22614
   410
apply (rule LIMSEQ_inverse_zero, safe)
huffman@22974
   411
apply (cut_tac x = r in reals_Archimedean2)
huffman@22614
   412
apply (safe, rule_tac x = n in exI)
huffman@22614
   413
apply (auto simp add: real_of_nat_Suc)
huffman@22614
   414
done
huffman@22614
   415
huffman@22614
   416
text{*The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to
huffman@22614
   417
infinity is now easily proved*}
huffman@22614
   418
huffman@22614
   419
lemma LIMSEQ_inverse_real_of_nat_add:
huffman@22614
   420
     "(%n. r + inverse(real(Suc n))) ----> r"
huffman@44313
   421
  using tendsto_add [OF tendsto_const LIMSEQ_inverse_real_of_nat] by auto
huffman@22614
   422
huffman@22614
   423
lemma LIMSEQ_inverse_real_of_nat_add_minus:
huffman@22614
   424
     "(%n. r + -inverse(real(Suc n))) ----> r"
huffman@44710
   425
  using tendsto_add [OF tendsto_const
huffman@44710
   426
    tendsto_minus [OF LIMSEQ_inverse_real_of_nat]] by auto
huffman@22614
   427
huffman@22614
   428
lemma LIMSEQ_inverse_real_of_nat_add_minus_mult:
huffman@22614
   429
     "(%n. r*( 1 + -inverse(real(Suc n)))) ----> r"
huffman@44313
   430
  using tendsto_mult [OF tendsto_const
huffman@44313
   431
    LIMSEQ_inverse_real_of_nat_add_minus [of 1]]
huffman@44313
   432
  by auto
huffman@22614
   433
huffman@22615
   434
lemma LIMSEQ_le_const:
huffman@22615
   435
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. a \<le> X n\<rbrakk> \<Longrightarrow> a \<le> x"
huffman@22615
   436
apply (rule ccontr, simp only: linorder_not_le)
huffman@22615
   437
apply (drule_tac r="a - x" in LIMSEQ_D, simp)
huffman@22615
   438
apply clarsimp
huffman@22615
   439
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI1)
huffman@22615
   440
apply (drule_tac x="max N no" in spec, drule mp, rule le_maxI2)
huffman@22615
   441
apply simp
huffman@22615
   442
done
huffman@22615
   443
huffman@22615
   444
lemma LIMSEQ_le_const2:
huffman@22615
   445
  "\<lbrakk>X ----> (x::real); \<exists>N. \<forall>n\<ge>N. X n \<le> a\<rbrakk> \<Longrightarrow> x \<le> a"
huffman@22615
   446
apply (subgoal_tac "- a \<le> - x", simp)
huffman@22615
   447
apply (rule LIMSEQ_le_const)
huffman@44313
   448
apply (erule tendsto_minus)
huffman@22615
   449
apply simp
huffman@22615
   450
done
huffman@22615
   451
huffman@22615
   452
lemma LIMSEQ_le:
huffman@22615
   453
  "\<lbrakk>X ----> x; Y ----> y; \<exists>N. \<forall>n\<ge>N. X n \<le> Y n\<rbrakk> \<Longrightarrow> x \<le> (y::real)"
huffman@22615
   454
apply (subgoal_tac "0 \<le> y - x", simp)
huffman@22615
   455
apply (rule LIMSEQ_le_const)
huffman@44313
   456
apply (erule (1) tendsto_diff)
huffman@22615
   457
apply (simp add: le_diff_eq)
huffman@22615
   458
done
huffman@22615
   459
paulson@15082
   460
huffman@20696
   461
subsection {* Convergence *}
paulson@15082
   462
paulson@15082
   463
lemma limI: "X ----> L ==> lim X = L"
paulson@15082
   464
apply (simp add: lim_def)
paulson@15082
   465
apply (blast intro: LIMSEQ_unique)
paulson@15082
   466
done
paulson@15082
   467
paulson@15082
   468
lemma convergentD: "convergent X ==> \<exists>L. (X ----> L)"
paulson@15082
   469
by (simp add: convergent_def)
paulson@15082
   470
paulson@15082
   471
lemma convergentI: "(X ----> L) ==> convergent X"
paulson@15082
   472
by (auto simp add: convergent_def)
paulson@15082
   473
paulson@15082
   474
lemma convergent_LIMSEQ_iff: "convergent X = (X ----> lim X)"
huffman@20682
   475
by (auto intro: theI LIMSEQ_unique simp add: convergent_def lim_def)
paulson@15082
   476
huffman@36625
   477
lemma convergent_const: "convergent (\<lambda>n. c)"
huffman@44313
   478
  by (rule convergentI, rule tendsto_const)
huffman@36625
   479
huffman@36625
   480
lemma convergent_add:
huffman@36625
   481
  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@36625
   482
  assumes "convergent (\<lambda>n. X n)"
huffman@36625
   483
  assumes "convergent (\<lambda>n. Y n)"
huffman@36625
   484
  shows "convergent (\<lambda>n. X n + Y n)"
huffman@44313
   485
  using assms unfolding convergent_def by (fast intro: tendsto_add)
huffman@36625
   486
huffman@36625
   487
lemma convergent_setsum:
huffman@36625
   488
  fixes X :: "'a \<Rightarrow> nat \<Rightarrow> 'b::real_normed_vector"
hoelzl@36647
   489
  assumes "\<And>i. i \<in> A \<Longrightarrow> convergent (\<lambda>n. X i n)"
huffman@36625
   490
  shows "convergent (\<lambda>n. \<Sum>i\<in>A. X i n)"
hoelzl@36647
   491
proof (cases "finite A")
wenzelm@36650
   492
  case True from this and assms show ?thesis
hoelzl@36647
   493
    by (induct A set: finite) (simp_all add: convergent_const convergent_add)
hoelzl@36647
   494
qed (simp add: convergent_const)
huffman@36625
   495
huffman@36625
   496
lemma (in bounded_linear) convergent:
huffman@36625
   497
  assumes "convergent (\<lambda>n. X n)"
huffman@36625
   498
  shows "convergent (\<lambda>n. f (X n))"
huffman@44313
   499
  using assms unfolding convergent_def by (fast intro: tendsto)
huffman@36625
   500
huffman@36625
   501
lemma (in bounded_bilinear) convergent:
huffman@36625
   502
  assumes "convergent (\<lambda>n. X n)" and "convergent (\<lambda>n. Y n)"
huffman@36625
   503
  shows "convergent (\<lambda>n. X n ** Y n)"
huffman@44313
   504
  using assms unfolding convergent_def by (fast intro: tendsto)
huffman@36625
   505
huffman@31336
   506
lemma convergent_minus_iff:
huffman@31336
   507
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   508
  shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
huffman@20696
   509
apply (simp add: convergent_def)
huffman@44313
   510
apply (auto dest: tendsto_minus)
huffman@44313
   511
apply (drule tendsto_minus, auto)
huffman@20696
   512
done
huffman@20696
   513
paulson@32707
   514
lemma lim_le:
paulson@32707
   515
  fixes x :: real
paulson@32707
   516
  assumes f: "convergent f" and fn_le: "!!n. f n \<le> x"
paulson@32707
   517
  shows "lim f \<le> x"
paulson@32707
   518
proof (rule classical)
paulson@32707
   519
  assume "\<not> lim f \<le> x"
paulson@32707
   520
  hence 0: "0 < lim f - x" by arith
paulson@32707
   521
  have 1: "f----> lim f"
paulson@32707
   522
    by (metis convergent_LIMSEQ_iff f) 
paulson@32707
   523
  thus ?thesis
paulson@32707
   524
    proof (simp add: LIMSEQ_iff)
paulson@32707
   525
      assume "\<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < r"
paulson@32707
   526
      hence "\<exists>no. \<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   527
        by (metis 0)
paulson@32707
   528
      from this obtain no where "\<forall>n\<ge>no. \<bar>f n - lim f\<bar> < lim f - x"
wenzelm@32960
   529
        by blast
paulson@32707
   530
      thus "lim f \<le> x"
haftmann@37887
   531
        by (metis 1 LIMSEQ_le_const2 fn_le)
paulson@32707
   532
    qed
paulson@32707
   533
qed
paulson@32707
   534
hoelzl@41367
   535
lemma monoseq_le:
hoelzl@41367
   536
  fixes a :: "nat \<Rightarrow> real"
hoelzl@41367
   537
  assumes "monoseq a" and "a ----> x"
hoelzl@29803
   538
  shows "((\<forall> n. a n \<le> x) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)) \<or> 
hoelzl@29803
   539
         ((\<forall> n. x \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m))"
hoelzl@29803
   540
proof -
hoelzl@29803
   541
  { fix x n fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   542
    assume "a ----> x" and "\<forall> m. \<forall> n \<ge> m. a m \<le> a n"
hoelzl@29803
   543
    hence monotone: "\<And> m n. m \<le> n \<Longrightarrow> a m \<le> a n" by auto
hoelzl@29803
   544
    have "a n \<le> x"
hoelzl@29803
   545
    proof (rule ccontr)
hoelzl@29803
   546
      assume "\<not> a n \<le> x" hence "x < a n" by auto
hoelzl@29803
   547
      hence "0 < a n - x" by auto
hoelzl@29803
   548
      from `a ----> x`[THEN LIMSEQ_D, OF this]
hoelzl@29803
   549
      obtain no where "\<And>n'. no \<le> n' \<Longrightarrow> norm (a n' - x) < a n - x" by blast
hoelzl@29803
   550
      hence "norm (a (max no n) - x) < a n - x" by auto
hoelzl@29803
   551
      moreover
hoelzl@29803
   552
      { fix n' have "n \<le> n' \<Longrightarrow> x < a n'" using monotone[where m=n and n=n'] and `x < a n` by auto }
hoelzl@29803
   553
      hence "x < a (max no n)" by auto
hoelzl@29803
   554
      ultimately
hoelzl@29803
   555
      have "a (max no n) < a n" by auto
hoelzl@29803
   556
      with monotone[where m=n and n="max no n"]
nipkow@32436
   557
      show False by (auto simp:max_def split:split_if_asm)
hoelzl@29803
   558
    qed
hoelzl@29803
   559
  } note top_down = this
hoelzl@29803
   560
  { fix x n m fix a :: "nat \<Rightarrow> real"
hoelzl@29803
   561
    assume "a ----> x" and "monoseq a" and "a m < x"
hoelzl@29803
   562
    have "a n \<le> x \<and> (\<forall> m. \<forall> n \<ge> m. a m \<le> a n)"
hoelzl@29803
   563
    proof (cases "\<forall> m. \<forall> n \<ge> m. a m \<le> a n")
hoelzl@29803
   564
      case True with top_down and `a ----> x` show ?thesis by auto
hoelzl@29803
   565
    next
hoelzl@29803
   566
      case False with `monoseq a`[unfolded monoseq_def] have "\<forall> m. \<forall> n \<ge> m. - a m \<le> - a n" by auto
huffman@44313
   567
      hence "- a m \<le> - x" using top_down[OF tendsto_minus[OF `a ----> x`]] by blast
hoelzl@29803
   568
      hence False using `a m < x` by auto
hoelzl@29803
   569
      thus ?thesis ..
hoelzl@29803
   570
    qed
hoelzl@29803
   571
  } note when_decided = this
hoelzl@29803
   572
hoelzl@29803
   573
  show ?thesis
hoelzl@29803
   574
  proof (cases "\<exists> m. a m \<noteq> x")
hoelzl@29803
   575
    case True then obtain m where "a m \<noteq> x" by auto
hoelzl@29803
   576
    show ?thesis
hoelzl@29803
   577
    proof (cases "a m < x")
hoelzl@29803
   578
      case True with when_decided[OF `a ----> x` `monoseq a`, where m2=m]
hoelzl@29803
   579
      show ?thesis by blast
hoelzl@29803
   580
    next
hoelzl@29803
   581
      case False hence "- a m < - x" using `a m \<noteq> x` by auto
huffman@44313
   582
      with when_decided[OF tendsto_minus[OF `a ----> x`] monoseq_minus[OF `monoseq a`], where m2=m]
hoelzl@29803
   583
      show ?thesis by auto
hoelzl@29803
   584
    qed
hoelzl@29803
   585
  qed auto
hoelzl@29803
   586
qed
hoelzl@29803
   587
paulson@30730
   588
lemma LIMSEQ_subseq_LIMSEQ:
paulson@30730
   589
  "\<lbrakk> X ----> L; subseq f \<rbrakk> \<Longrightarrow> (X o f) ----> L"
huffman@36662
   590
apply (rule topological_tendstoI)
huffman@36662
   591
apply (drule (2) topological_tendstoD)
huffman@36662
   592
apply (simp only: eventually_sequentially)
huffman@36662
   593
apply (clarify, rule_tac x=N in exI, clarsimp)
paulson@30730
   594
apply (blast intro: seq_suble le_trans dest!: spec) 
paulson@30730
   595
done
paulson@30730
   596
huffman@44208
   597
lemma convergent_subseq_convergent:
huffman@44208
   598
  "\<lbrakk>convergent X; subseq f\<rbrakk> \<Longrightarrow> convergent (X o f)"
huffman@44208
   599
  unfolding convergent_def by (auto intro: LIMSEQ_subseq_LIMSEQ)
huffman@44208
   600
huffman@44208
   601
chaieb@30196
   602
subsection {* Bounded Monotonic Sequences *}
chaieb@30196
   603
huffman@20696
   604
text{*Bounded Sequence*}
paulson@15082
   605
huffman@20552
   606
lemma BseqD: "Bseq X ==> \<exists>K. 0 < K & (\<forall>n. norm (X n) \<le> K)"
paulson@15082
   607
by (simp add: Bseq_def)
paulson@15082
   608
huffman@20552
   609
lemma BseqI: "[| 0 < K; \<forall>n. norm (X n) \<le> K |] ==> Bseq X"
paulson@15082
   610
by (auto simp add: Bseq_def)
paulson@15082
   611
paulson@15082
   612
lemma lemma_NBseq_def:
huffman@20552
   613
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) =
huffman@20552
   614
      (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
haftmann@32064
   615
proof auto
haftmann@32064
   616
  fix K :: real
haftmann@32064
   617
  from reals_Archimedean2 obtain n :: nat where "K < real n" ..
haftmann@32064
   618
  then have "K \<le> real (Suc n)" by auto
haftmann@32064
   619
  assume "\<forall>m. norm (X m) \<le> K"
haftmann@32064
   620
  have "\<forall>m. norm (X m) \<le> real (Suc n)"
haftmann@32064
   621
  proof
haftmann@32064
   622
    fix m :: 'a
haftmann@32064
   623
    from `\<forall>m. norm (X m) \<le> K` have "norm (X m) \<le> K" ..
haftmann@32064
   624
    with `K \<le> real (Suc n)` show "norm (X m) \<le> real (Suc n)" by auto
haftmann@32064
   625
  qed
haftmann@32064
   626
  then show "\<exists>N. \<forall>n. norm (X n) \<le> real (Suc N)" ..
haftmann@32064
   627
next
haftmann@32064
   628
  fix N :: nat
haftmann@32064
   629
  have "real (Suc N) > 0" by (simp add: real_of_nat_Suc)
haftmann@32064
   630
  moreover assume "\<forall>n. norm (X n) \<le> real (Suc N)"
haftmann@32064
   631
  ultimately show "\<exists>K>0. \<forall>n. norm (X n) \<le> K" by blast
haftmann@32064
   632
qed
haftmann@32064
   633
paulson@15082
   634
paulson@15082
   635
text{* alternative definition for Bseq *}
huffman@20552
   636
lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))"
paulson@15082
   637
apply (simp add: Bseq_def)
paulson@15082
   638
apply (simp (no_asm) add: lemma_NBseq_def)
paulson@15082
   639
done
paulson@15082
   640
paulson@15082
   641
lemma lemma_NBseq_def2:
huffman@20552
   642
     "(\<exists>K > 0. \<forall>n. norm (X n) \<le> K) = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   643
apply (subst lemma_NBseq_def, auto)
paulson@15082
   644
apply (rule_tac x = "Suc N" in exI)
paulson@15082
   645
apply (rule_tac [2] x = N in exI)
paulson@15082
   646
apply (auto simp add: real_of_nat_Suc)
paulson@15082
   647
 prefer 2 apply (blast intro: order_less_imp_le)
paulson@15082
   648
apply (drule_tac x = n in spec, simp)
paulson@15082
   649
done
paulson@15082
   650
paulson@15082
   651
(* yet another definition for Bseq *)
huffman@20552
   652
lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))"
paulson@15082
   653
by (simp add: Bseq_def lemma_NBseq_def2)
paulson@15082
   654
huffman@20696
   655
subsubsection{*Upper Bounds and Lubs of Bounded Sequences*}
paulson@15082
   656
paulson@15082
   657
lemma Bseq_isUb:
paulson@15082
   658
  "!!(X::nat=>real). Bseq X ==> \<exists>U. isUb (UNIV::real set) {x. \<exists>n. X n = x} U"
huffman@22998
   659
by (auto intro: isUbI setleI simp add: Bseq_def abs_le_iff)
paulson@15082
   660
paulson@15082
   661
text{* Use completeness of reals (supremum property)
paulson@15082
   662
   to show that any bounded sequence has a least upper bound*}
paulson@15082
   663
paulson@15082
   664
lemma Bseq_isLub:
paulson@15082
   665
  "!!(X::nat=>real). Bseq X ==>
paulson@15082
   666
   \<exists>U. isLub (UNIV::real set) {x. \<exists>n. X n = x} U"
paulson@15082
   667
by (blast intro: reals_complete Bseq_isUb)
paulson@15082
   668
huffman@20696
   669
subsubsection{*A Bounded and Monotonic Sequence Converges*}
paulson@15082
   670
huffman@44714
   671
(* TODO: delete *)
huffman@44714
   672
(* FIXME: one use in NSA/HSEQ.thy *)
paulson@15082
   673
lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)"
huffman@36662
   674
unfolding tendsto_def eventually_sequentially
paulson@15082
   675
apply (rule_tac x = "X m" in exI, safe)
paulson@15082
   676
apply (rule_tac x = m in exI, safe)
paulson@15082
   677
apply (drule spec, erule impE, auto)
paulson@15082
   678
done
paulson@15082
   679
huffman@44714
   680
text {* A monotone sequence converges to its least upper bound. *}
paulson@15082
   681
huffman@44714
   682
lemma isLub_mono_imp_LIMSEQ:
huffman@44714
   683
  fixes X :: "nat \<Rightarrow> real"
huffman@44714
   684
  assumes u: "isLub UNIV {x. \<exists>n. X n = x} u" (* FIXME: use 'range X' *)
huffman@44714
   685
  assumes X: "\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n"
huffman@44714
   686
  shows "X ----> u"
huffman@44714
   687
proof (rule LIMSEQ_I)
huffman@44714
   688
  have 1: "\<forall>n. X n \<le> u"
huffman@44714
   689
    using isLubD2 [OF u] by auto
huffman@44714
   690
  have "\<forall>y. (\<forall>n. X n \<le> y) \<longrightarrow> u \<le> y"
huffman@44714
   691
    using isLub_le_isUb [OF u] by (auto simp add: isUb_def setle_def)
huffman@44714
   692
  hence 2: "\<forall>y<u. \<exists>n. y < X n"
huffman@44714
   693
    by (metis not_le)
huffman@44714
   694
  fix r :: real assume "0 < r"
huffman@44714
   695
  hence "u - r < u" by simp
huffman@44714
   696
  hence "\<exists>m. u - r < X m" using 2 by simp
huffman@44714
   697
  then obtain m where "u - r < X m" ..
huffman@44714
   698
  with X have "\<forall>n\<ge>m. u - r < X n"
huffman@44714
   699
    by (fast intro: less_le_trans)
huffman@44714
   700
  hence "\<exists>m. \<forall>n\<ge>m. u - r < X n" ..
huffman@44714
   701
  thus "\<exists>m. \<forall>n\<ge>m. norm (X n - u) < r"
huffman@44714
   702
    using 1 by (simp add: diff_less_eq add_commute)
huffman@44714
   703
qed
paulson@15082
   704
paulson@15082
   705
text{*A standard proof of the theorem for monotone increasing sequence*}
paulson@15082
   706
paulson@15082
   707
lemma Bseq_mono_convergent:
huffman@20552
   708
     "[| Bseq X; \<forall>m. \<forall>n \<ge> m. X m \<le> X n |] ==> convergent (X::nat=>real)"
huffman@44714
   709
proof -
huffman@44714
   710
  assume "Bseq X"
huffman@44714
   711
  then obtain u where u: "isLub UNIV {x. \<exists>n. X n = x} u"
huffman@44714
   712
    using Bseq_isLub by fast
huffman@44714
   713
  assume "\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n"
huffman@44714
   714
  with u have "X ----> u"
huffman@44714
   715
    by (rule isLub_mono_imp_LIMSEQ)
huffman@44714
   716
  thus "convergent X"
huffman@44714
   717
    by (rule convergentI)
huffman@44714
   718
qed
paulson@15082
   719
paulson@15082
   720
lemma Bseq_minus_iff: "Bseq (%n. -(X n)) = Bseq X"
paulson@15082
   721
by (simp add: Bseq_def)
paulson@15082
   722
paulson@15082
   723
text{*Main monotonicity theorem*}
hoelzl@41367
   724
lemma Bseq_monoseq_convergent: "[| Bseq X; monoseq X |] ==> convergent (X::nat\<Rightarrow>real)"
paulson@15082
   725
apply (simp add: monoseq_def, safe)
paulson@15082
   726
apply (rule_tac [2] convergent_minus_iff [THEN ssubst])
paulson@15082
   727
apply (drule_tac [2] Bseq_minus_iff [THEN ssubst])
paulson@15082
   728
apply (auto intro!: Bseq_mono_convergent)
paulson@15082
   729
done
paulson@15082
   730
paulson@30730
   731
subsubsection{*Increasing and Decreasing Series*}
paulson@30730
   732
hoelzl@41367
   733
lemma incseq_le:
hoelzl@41367
   734
  fixes X :: "nat \<Rightarrow> real"
hoelzl@41367
   735
  assumes inc: "incseq X" and lim: "X ----> L" shows "X n \<le> L"
paulson@30730
   736
  using monoseq_le [OF incseq_imp_monoseq [OF inc] lim]
paulson@30730
   737
proof
paulson@30730
   738
  assume "(\<forall>n. X n \<le> L) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n)"
paulson@30730
   739
  thus ?thesis by simp
paulson@30730
   740
next
paulson@30730
   741
  assume "(\<forall>n. L \<le> X n) \<and> (\<forall>m n. m \<le> n \<longrightarrow> X n \<le> X m)"
paulson@30730
   742
  hence const: "(!!m n. m \<le> n \<Longrightarrow> X n = X m)" using inc
paulson@30730
   743
    by (auto simp add: incseq_def intro: order_antisym)
paulson@30730
   744
  have X: "!!n. X n = X 0"
paulson@30730
   745
    by (blast intro: const [of 0]) 
paulson@30730
   746
  have "X = (\<lambda>n. X 0)"
huffman@44568
   747
    by (blast intro: X)
huffman@44313
   748
  hence "L = X 0" using tendsto_const [of "X 0" sequentially]
huffman@44313
   749
    by (auto intro: LIMSEQ_unique lim)
paulson@30730
   750
  thus ?thesis
paulson@30730
   751
    by (blast intro: eq_refl X)
paulson@30730
   752
qed
paulson@30730
   753
hoelzl@41367
   754
lemma decseq_le:
hoelzl@41367
   755
  fixes X :: "nat \<Rightarrow> real" assumes dec: "decseq X" and lim: "X ----> L" shows "L \<le> X n"
paulson@30730
   756
proof -
paulson@30730
   757
  have inc: "incseq (\<lambda>n. - X n)" using dec
paulson@30730
   758
    by (simp add: decseq_eq_incseq)
paulson@30730
   759
  have "- X n \<le> - L" 
huffman@44313
   760
    by (blast intro: incseq_le [OF inc] tendsto_minus lim) 
paulson@30730
   761
  thus ?thesis
paulson@30730
   762
    by simp
paulson@30730
   763
qed
paulson@30730
   764
huffman@20696
   765
subsubsection{*A Few More Equivalence Theorems for Boundedness*}
paulson@15082
   766
paulson@15082
   767
text{*alternative formulation for boundedness*}
huffman@20552
   768
lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)"
paulson@15082
   769
apply (unfold Bseq_def, safe)
huffman@20552
   770
apply (rule_tac [2] x = "k + norm x" in exI)
nipkow@15360
   771
apply (rule_tac x = K in exI, simp)
paulson@15221
   772
apply (rule exI [where x = 0], auto)
huffman@20552
   773
apply (erule order_less_le_trans, simp)
haftmann@37887
   774
apply (drule_tac x=n in spec, fold diff_minus)
huffman@20552
   775
apply (drule order_trans [OF norm_triangle_ineq2])
huffman@20552
   776
apply simp
paulson@15082
   777
done
paulson@15082
   778
paulson@15082
   779
text{*alternative formulation for boundedness*}
huffman@20552
   780
lemma Bseq_iff3: "Bseq X = (\<exists>k > 0. \<exists>N. \<forall>n. norm(X(n) + -X(N)) \<le> k)"
paulson@15082
   781
apply safe
paulson@15082
   782
apply (simp add: Bseq_def, safe)
huffman@20552
   783
apply (rule_tac x = "K + norm (X N)" in exI)
paulson@15082
   784
apply auto
huffman@20552
   785
apply (erule order_less_le_trans, simp)
paulson@15082
   786
apply (rule_tac x = N in exI, safe)
huffman@20552
   787
apply (drule_tac x = n in spec)
huffman@20552
   788
apply (rule order_trans [OF norm_triangle_ineq], simp)
paulson@15082
   789
apply (auto simp add: Bseq_iff2)
paulson@15082
   790
done
paulson@15082
   791
huffman@20552
   792
lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f"
paulson@15082
   793
apply (simp add: Bseq_def)
paulson@15221
   794
apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto)
webertj@20217
   795
apply (drule_tac x = n in spec, arith)
paulson@15082
   796
done
paulson@15082
   797
paulson@15082
   798
huffman@20696
   799
subsection {* Cauchy Sequences *}
paulson@15082
   800
huffman@31336
   801
lemma metric_CauchyI:
huffman@31336
   802
  "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < e) \<Longrightarrow> Cauchy X"
huffman@31336
   803
by (simp add: Cauchy_def)
huffman@31336
   804
huffman@31336
   805
lemma metric_CauchyD:
huffman@31336
   806
  "\<lbrakk>Cauchy X; 0 < e\<rbrakk> \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (X m) (X n) < e"
huffman@20751
   807
by (simp add: Cauchy_def)
huffman@20751
   808
huffman@31336
   809
lemma Cauchy_iff:
huffman@31336
   810
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   811
  shows "Cauchy X \<longleftrightarrow> (\<forall>e>0. \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e)"
huffman@31336
   812
unfolding Cauchy_def dist_norm ..
huffman@31336
   813
hoelzl@35292
   814
lemma Cauchy_iff2:
hoelzl@35292
   815
     "Cauchy X =
hoelzl@35292
   816
      (\<forall>j. (\<exists>M. \<forall>m \<ge> M. \<forall>n \<ge> M. \<bar>X m - X n\<bar> < inverse(real (Suc j))))"
hoelzl@35292
   817
apply (simp add: Cauchy_iff, auto)
hoelzl@35292
   818
apply (drule reals_Archimedean, safe)
hoelzl@35292
   819
apply (drule_tac x = n in spec, auto)
hoelzl@35292
   820
apply (rule_tac x = M in exI, auto)
hoelzl@35292
   821
apply (drule_tac x = m in spec, simp)
hoelzl@35292
   822
apply (drule_tac x = na in spec, auto)
hoelzl@35292
   823
done
hoelzl@35292
   824
huffman@31336
   825
lemma CauchyI:
huffman@31336
   826
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   827
  shows "(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e) \<Longrightarrow> Cauchy X"
huffman@31336
   828
by (simp add: Cauchy_iff)
huffman@31336
   829
huffman@20751
   830
lemma CauchyD:
huffman@31336
   831
  fixes X :: "nat \<Rightarrow> 'a::real_normed_vector"
huffman@31336
   832
  shows "\<lbrakk>Cauchy X; 0 < e\<rbrakk> \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (X m - X n) < e"
huffman@31336
   833
by (simp add: Cauchy_iff)
huffman@20751
   834
paulson@30730
   835
lemma Cauchy_subseq_Cauchy:
paulson@30730
   836
  "\<lbrakk> Cauchy X; subseq f \<rbrakk> \<Longrightarrow> Cauchy (X o f)"
huffman@31336
   837
apply (auto simp add: Cauchy_def)
huffman@31336
   838
apply (drule_tac x=e in spec, clarify)
huffman@31336
   839
apply (rule_tac x=M in exI, clarify)
huffman@31336
   840
apply (blast intro: le_trans [OF _ seq_suble] dest!: spec)
paulson@30730
   841
done
paulson@30730
   842
huffman@20696
   843
subsubsection {* Cauchy Sequences are Bounded *}
huffman@20696
   844
paulson@15082
   845
text{*A Cauchy sequence is bounded -- this is the standard
paulson@15082
   846
  proof mechanization rather than the nonstandard proof*}
paulson@15082
   847
huffman@20563
   848
lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real)
huffman@20552
   849
          ==>  \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)"
huffman@20552
   850
apply (clarify, drule spec, drule (1) mp)
huffman@20563
   851
apply (simp only: norm_minus_commute)
huffman@20552
   852
apply (drule order_le_less_trans [OF norm_triangle_ineq2])
huffman@20552
   853
apply simp
huffman@20552
   854
done
paulson@15082
   855
paulson@15082
   856
lemma Cauchy_Bseq: "Cauchy X ==> Bseq X"
huffman@31336
   857
apply (simp add: Cauchy_iff)
huffman@20552
   858
apply (drule spec, drule mp, rule zero_less_one, safe)
huffman@20552
   859
apply (drule_tac x="M" in spec, simp)
paulson@15082
   860
apply (drule lemmaCauchy)
huffman@22608
   861
apply (rule_tac k="M" in Bseq_offset)
huffman@20552
   862
apply (simp add: Bseq_def)
huffman@20552
   863
apply (rule_tac x="1 + norm (X M)" in exI)
huffman@20552
   864
apply (rule conjI, rule order_less_le_trans [OF zero_less_one], simp)
huffman@20552
   865
apply (simp add: order_less_imp_le)
paulson@15082
   866
done
paulson@15082
   867
huffman@20696
   868
subsubsection {* Cauchy Sequences are Convergent *}
paulson@15082
   869
huffman@44206
   870
class complete_space = metric_space +
haftmann@33042
   871
  assumes Cauchy_convergent: "Cauchy X \<Longrightarrow> convergent X"
huffman@20830
   872
haftmann@33042
   873
class banach = real_normed_vector + complete_space
huffman@31403
   874
huffman@22629
   875
theorem LIMSEQ_imp_Cauchy:
huffman@22629
   876
  assumes X: "X ----> a" shows "Cauchy X"
huffman@31336
   877
proof (rule metric_CauchyI)
huffman@22629
   878
  fix e::real assume "0 < e"
huffman@22629
   879
  hence "0 < e/2" by simp
huffman@31336
   880
  with X have "\<exists>N. \<forall>n\<ge>N. dist (X n) a < e/2" by (rule metric_LIMSEQ_D)
huffman@31336
   881
  then obtain N where N: "\<forall>n\<ge>N. dist (X n) a < e/2" ..
huffman@31336
   882
  show "\<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. dist (X m) (X n) < e"
huffman@22629
   883
  proof (intro exI allI impI)
huffman@22629
   884
    fix m assume "N \<le> m"
huffman@31336
   885
    hence m: "dist (X m) a < e/2" using N by fast
huffman@22629
   886
    fix n assume "N \<le> n"
huffman@31336
   887
    hence n: "dist (X n) a < e/2" using N by fast
huffman@31336
   888
    have "dist (X m) (X n) \<le> dist (X m) a + dist (X n) a"
huffman@31336
   889
      by (rule dist_triangle2)
huffman@31336
   890
    also from m n have "\<dots> < e" by simp
huffman@31336
   891
    finally show "dist (X m) (X n) < e" .
huffman@22629
   892
  qed
huffman@22629
   893
qed
huffman@22629
   894
huffman@20691
   895
lemma convergent_Cauchy: "convergent X \<Longrightarrow> Cauchy X"
huffman@22629
   896
unfolding convergent_def
huffman@22629
   897
by (erule exE, erule LIMSEQ_imp_Cauchy)
huffman@20691
   898
huffman@31403
   899
lemma Cauchy_convergent_iff:
huffman@31403
   900
  fixes X :: "nat \<Rightarrow> 'a::complete_space"
huffman@31403
   901
  shows "Cauchy X = convergent X"
huffman@31403
   902
by (fast intro: Cauchy_convergent convergent_Cauchy)
huffman@31403
   903
huffman@22629
   904
text {*
huffman@22629
   905
Proof that Cauchy sequences converge based on the one from
huffman@22629
   906
http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html
huffman@22629
   907
*}
huffman@22629
   908
huffman@22629
   909
text {*
huffman@22629
   910
  If sequence @{term "X"} is Cauchy, then its limit is the lub of
huffman@22629
   911
  @{term "{r::real. \<exists>N. \<forall>n\<ge>N. r < X n}"}
huffman@22629
   912
*}
huffman@22629
   913
huffman@22629
   914
lemma isUb_UNIV_I: "(\<And>y. y \<in> S \<Longrightarrow> y \<le> u) \<Longrightarrow> isUb UNIV S u"
huffman@22629
   915
by (simp add: isUbI setleI)
huffman@22629
   916
haftmann@27681
   917
locale real_Cauchy =
huffman@22629
   918
  fixes X :: "nat \<Rightarrow> real"
huffman@22629
   919
  assumes X: "Cauchy X"
huffman@22629
   920
  fixes S :: "real set"
huffman@22629
   921
  defines S_def: "S \<equiv> {x::real. \<exists>N. \<forall>n\<ge>N. x < X n}"
huffman@22629
   922
haftmann@27681
   923
lemma real_CauchyI:
haftmann@27681
   924
  assumes "Cauchy X"
haftmann@27681
   925
  shows "real_Cauchy X"
haftmann@28823
   926
  proof qed (fact assms)
haftmann@27681
   927
huffman@22629
   928
lemma (in real_Cauchy) mem_S: "\<forall>n\<ge>N. x < X n \<Longrightarrow> x \<in> S"
huffman@22629
   929
by (unfold S_def, auto)
huffman@22629
   930
huffman@22629
   931
lemma (in real_Cauchy) bound_isUb:
huffman@22629
   932
  assumes N: "\<forall>n\<ge>N. X n < x"
huffman@22629
   933
  shows "isUb UNIV S x"
huffman@22629
   934
proof (rule isUb_UNIV_I)
huffman@22629
   935
  fix y::real assume "y \<in> S"
huffman@22629
   936
  hence "\<exists>M. \<forall>n\<ge>M. y < X n"
huffman@22629
   937
    by (simp add: S_def)
huffman@22629
   938
  then obtain M where "\<forall>n\<ge>M. y < X n" ..
huffman@22629
   939
  hence "y < X (max M N)" by simp
huffman@22629
   940
  also have "\<dots> < x" using N by simp
huffman@22629
   941
  finally show "y \<le> x"
huffman@22629
   942
    by (rule order_less_imp_le)
huffman@22629
   943
qed
huffman@22629
   944
huffman@22629
   945
lemma (in real_Cauchy) isLub_ex: "\<exists>u. isLub UNIV S u"
huffman@22629
   946
proof (rule reals_complete)
huffman@22629
   947
  obtain N where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (X m - X n) < 1"
haftmann@32064
   948
    using CauchyD [OF X zero_less_one] by auto
huffman@22629
   949
  hence N: "\<forall>n\<ge>N. norm (X n - X N) < 1" by simp
huffman@22629
   950
  show "\<exists>x. x \<in> S"
huffman@22629
   951
  proof
huffman@22629
   952
    from N have "\<forall>n\<ge>N. X N - 1 < X n"
paulson@32707
   953
      by (simp add: abs_diff_less_iff)
huffman@22629
   954
    thus "X N - 1 \<in> S" by (rule mem_S)
huffman@22629
   955
  qed
huffman@22629
   956
  show "\<exists>u. isUb UNIV S u"
huffman@22629
   957
  proof
huffman@22629
   958
    from N have "\<forall>n\<ge>N. X n < X N + 1"
paulson@32707
   959
      by (simp add: abs_diff_less_iff)
huffman@22629
   960
    thus "isUb UNIV S (X N + 1)"
huffman@22629
   961
      by (rule bound_isUb)
huffman@22629
   962
  qed
huffman@22629
   963
qed
huffman@22629
   964
huffman@22629
   965
lemma (in real_Cauchy) isLub_imp_LIMSEQ:
huffman@22629
   966
  assumes x: "isLub UNIV S x"
huffman@22629
   967
  shows "X ----> x"
huffman@22629
   968
proof (rule LIMSEQ_I)
huffman@22629
   969
  fix r::real assume "0 < r"
huffman@22629
   970
  hence r: "0 < r/2" by simp
huffman@22629
   971
  obtain N where "\<forall>n\<ge>N. \<forall>m\<ge>N. norm (X n - X m) < r/2"
haftmann@32064
   972
    using CauchyD [OF X r] by auto
huffman@22629
   973
  hence "\<forall>n\<ge>N. norm (X n - X N) < r/2" by simp
huffman@22629
   974
  hence N: "\<forall>n\<ge>N. X N - r/2 < X n \<and> X n < X N + r/2"
paulson@32707
   975
    by (simp only: real_norm_def abs_diff_less_iff)
huffman@22629
   976
huffman@22629
   977
  from N have "\<forall>n\<ge>N. X N - r/2 < X n" by fast
huffman@22629
   978
  hence "X N - r/2 \<in> S" by (rule mem_S)
nipkow@23482
   979
  hence 1: "X N - r/2 \<le> x" using x isLub_isUb isUbD by fast
huffman@22629
   980
huffman@22629
   981
  from N have "\<forall>n\<ge>N. X n < X N + r/2" by fast
huffman@22629
   982
  hence "isUb UNIV S (X N + r/2)" by (rule bound_isUb)
nipkow@23482
   983
  hence 2: "x \<le> X N + r/2" using x isLub_le_isUb by fast
huffman@22629
   984
huffman@22629
   985
  show "\<exists>N. \<forall>n\<ge>N. norm (X n - x) < r"
huffman@22629
   986
  proof (intro exI allI impI)
huffman@22629
   987
    fix n assume n: "N \<le> n"
nipkow@23482
   988
    from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+
nipkow@23482
   989
    thus "norm (X n - x) < r" using 1 2
paulson@32707
   990
      by (simp add: abs_diff_less_iff)
huffman@22629
   991
  qed
huffman@22629
   992
qed
huffman@22629
   993
huffman@22629
   994
lemma (in real_Cauchy) LIMSEQ_ex: "\<exists>x. X ----> x"
huffman@22629
   995
proof -
huffman@22629
   996
  obtain x where "isLub UNIV S x"
huffman@22629
   997
    using isLub_ex by fast
huffman@22629
   998
  hence "X ----> x"
huffman@22629
   999
    by (rule isLub_imp_LIMSEQ)
huffman@22629
  1000
  thus ?thesis ..
huffman@22629
  1001
qed
huffman@22629
  1002
huffman@20830
  1003
lemma real_Cauchy_convergent:
huffman@20830
  1004
  fixes X :: "nat \<Rightarrow> real"
huffman@20830
  1005
  shows "Cauchy X \<Longrightarrow> convergent X"
haftmann@27681
  1006
unfolding convergent_def
haftmann@27681
  1007
by (rule real_Cauchy.LIMSEQ_ex)
haftmann@27681
  1008
 (rule real_CauchyI)
huffman@20830
  1009
huffman@20830
  1010
instance real :: banach
huffman@20830
  1011
by intro_classes (rule real_Cauchy_convergent)
huffman@20830
  1012
paulson@15082
  1013
huffman@20696
  1014
subsection {* Power Sequences *}
paulson@15082
  1015
paulson@15082
  1016
text{*The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term
paulson@15082
  1017
"x<1"}.  Proof will use (NS) Cauchy equivalence for convergence and
paulson@15082
  1018
  also fact that bounded and monotonic sequence converges.*}
paulson@15082
  1019
huffman@20552
  1020
lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)"
paulson@15082
  1021
apply (simp add: Bseq_def)
paulson@15082
  1022
apply (rule_tac x = 1 in exI)
paulson@15082
  1023
apply (simp add: power_abs)
huffman@22974
  1024
apply (auto dest: power_mono)
paulson@15082
  1025
done
paulson@15082
  1026
hoelzl@41367
  1027
lemma monoseq_realpow: fixes x :: real shows "[| 0 \<le> x; x \<le> 1 |] ==> monoseq (%n. x ^ n)"
paulson@15082
  1028
apply (clarify intro!: mono_SucI2)
paulson@15082
  1029
apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing, auto)
paulson@15082
  1030
done
paulson@15082
  1031
huffman@20552
  1032
lemma convergent_realpow:
huffman@20552
  1033
  "[| 0 \<le> (x::real); x \<le> 1 |] ==> convergent (%n. x ^ n)"
paulson@15082
  1034
by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
paulson@15082
  1035
huffman@22628
  1036
lemma LIMSEQ_inverse_realpow_zero_lemma:
huffman@22628
  1037
  fixes x :: real
huffman@22628
  1038
  assumes x: "0 \<le> x"
huffman@22628
  1039
  shows "real n * x + 1 \<le> (x + 1) ^ n"
huffman@22628
  1040
apply (induct n)
huffman@22628
  1041
apply simp
huffman@22628
  1042
apply simp
huffman@22628
  1043
apply (rule order_trans)
huffman@22628
  1044
prefer 2
huffman@22628
  1045
apply (erule mult_left_mono)
huffman@22628
  1046
apply (rule add_increasing [OF x], simp)
huffman@22628
  1047
apply (simp add: real_of_nat_Suc)
nipkow@23477
  1048
apply (simp add: ring_distribs)
huffman@22628
  1049
apply (simp add: mult_nonneg_nonneg x)
huffman@22628
  1050
done
huffman@22628
  1051
huffman@22628
  1052
lemma LIMSEQ_inverse_realpow_zero:
huffman@22628
  1053
  "1 < (x::real) \<Longrightarrow> (\<lambda>n. inverse (x ^ n)) ----> 0"
huffman@22628
  1054
proof (rule LIMSEQ_inverse_zero [rule_format])
huffman@22628
  1055
  fix y :: real
huffman@22628
  1056
  assume x: "1 < x"
huffman@22628
  1057
  hence "0 < x - 1" by simp
huffman@22628
  1058
  hence "\<forall>y. \<exists>N::nat. y < real N * (x - 1)"
huffman@22628
  1059
    by (rule reals_Archimedean3)
huffman@22628
  1060
  hence "\<exists>N::nat. y < real N * (x - 1)" ..
huffman@22628
  1061
  then obtain N::nat where "y < real N * (x - 1)" ..
huffman@22628
  1062
  also have "\<dots> \<le> real N * (x - 1) + 1" by simp
huffman@22628
  1063
  also have "\<dots> \<le> (x - 1 + 1) ^ N"
huffman@22628
  1064
    by (rule LIMSEQ_inverse_realpow_zero_lemma, cut_tac x, simp)
huffman@22628
  1065
  also have "\<dots> = x ^ N" by simp
huffman@22628
  1066
  finally have "y < x ^ N" .
huffman@22628
  1067
  hence "\<forall>n\<ge>N. y < x ^ n"
huffman@22628
  1068
    apply clarify
huffman@22628
  1069
    apply (erule order_less_le_trans)
huffman@22628
  1070
    apply (erule power_increasing)
huffman@22628
  1071
    apply (rule order_less_imp_le [OF x])
huffman@22628
  1072
    done
huffman@22628
  1073
  thus "\<exists>N. \<forall>n\<ge>N. y < x ^ n" ..
huffman@22628
  1074
qed
huffman@22628
  1075
huffman@20552
  1076
lemma LIMSEQ_realpow_zero:
huffman@22628
  1077
  "\<lbrakk>0 \<le> (x::real); x < 1\<rbrakk> \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@22628
  1078
proof (cases)
huffman@22628
  1079
  assume "x = 0"
huffman@44313
  1080
  hence "(\<lambda>n. x ^ Suc n) ----> 0" by (simp add: tendsto_const)
huffman@22628
  1081
  thus ?thesis by (rule LIMSEQ_imp_Suc)
huffman@22628
  1082
next
huffman@22628
  1083
  assume "0 \<le> x" and "x \<noteq> 0"
huffman@22628
  1084
  hence x0: "0 < x" by simp
huffman@22628
  1085
  assume x1: "x < 1"
huffman@22628
  1086
  from x0 x1 have "1 < inverse x"
huffman@36776
  1087
    by (rule one_less_inverse)
huffman@22628
  1088
  hence "(\<lambda>n. inverse (inverse x ^ n)) ----> 0"
huffman@22628
  1089
    by (rule LIMSEQ_inverse_realpow_zero)
huffman@22628
  1090
  thus ?thesis by (simp add: power_inverse)
huffman@22628
  1091
qed
paulson@15082
  1092
huffman@20685
  1093
lemma LIMSEQ_power_zero:
haftmann@31017
  1094
  fixes x :: "'a::{real_normed_algebra_1}"
huffman@20685
  1095
  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) ----> 0"
huffman@20685
  1096
apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
huffman@44313
  1097
apply (simp only: tendsto_Zfun_iff, erule Zfun_le)
huffman@22974
  1098
apply (simp add: power_abs norm_power_ineq)
huffman@20685
  1099
done
huffman@20685
  1100
huffman@20552
  1101
lemma LIMSEQ_divide_realpow_zero:
huffman@20552
  1102
  "1 < (x::real) ==> (%n. a / (x ^ n)) ----> 0"
huffman@44313
  1103
using tendsto_mult [OF tendsto_const [of a]
huffman@44313
  1104
  LIMSEQ_realpow_zero [of "inverse x"]]
paulson@15082
  1105
apply (auto simp add: divide_inverse power_inverse)
paulson@15082
  1106
apply (simp add: inverse_eq_divide pos_divide_less_eq)
paulson@15082
  1107
done
paulson@15082
  1108
paulson@15102
  1109
text{*Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}*}
paulson@15082
  1110
huffman@20552
  1111
lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < (1::real) ==> (%n. \<bar>c\<bar> ^ n) ----> 0"
huffman@20685
  1112
by (rule LIMSEQ_realpow_zero [OF abs_ge_zero])
paulson@15082
  1113
huffman@20552
  1114
lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < (1::real) ==> (%n. c ^ n) ----> 0"
huffman@44313
  1115
apply (rule tendsto_rabs_zero_cancel)
paulson@15082
  1116
apply (auto intro: LIMSEQ_rabs_realpow_zero simp add: power_abs)
paulson@15082
  1117
done
paulson@15082
  1118
paulson@10751
  1119
end