src/HOL/Limits.thy
author huffman
Mon Jun 01 10:36:42 2009 -0700 (2009-06-01)
changeset 31355 3d18766ddc4b
parent 31353 14a58e2ca374
child 31356 ec8b9b6c47dc
permissions -rw-r--r--
limits of inverse using filters
huffman@31349
     1
(*  Title       : Limits.thy
huffman@31349
     2
    Author      : Brian Huffman
huffman@31349
     3
*)
huffman@31349
     4
huffman@31349
     5
header {* Filters and Limits *}
huffman@31349
     6
huffman@31349
     7
theory Limits
huffman@31349
     8
imports RealVector RComplete
huffman@31349
     9
begin
huffman@31349
    10
huffman@31349
    11
subsection {* Filters *}
huffman@31349
    12
huffman@31349
    13
typedef (open) 'a filter =
huffman@31349
    14
  "{f :: ('a \<Rightarrow> bool) \<Rightarrow> bool. f (\<lambda>x. True)
huffman@31349
    15
    \<and> (\<forall>P Q. (\<forall>x. P x \<longrightarrow> Q x) \<longrightarrow> f P \<longrightarrow> f Q)
huffman@31349
    16
    \<and> (\<forall>P Q. f P \<longrightarrow> f Q \<longrightarrow> f (\<lambda>x. P x \<and> Q x))}"
huffman@31349
    17
proof
huffman@31349
    18
  show "(\<lambda>P. True) \<in> ?filter" by simp
huffman@31349
    19
qed
huffman@31349
    20
huffman@31349
    21
definition
huffman@31349
    22
  eventually :: "('a \<Rightarrow> bool) \<Rightarrow> 'a filter \<Rightarrow> bool" where
huffman@31353
    23
  [simp del]: "eventually P F \<longleftrightarrow> Rep_filter F P"
huffman@31349
    24
huffman@31349
    25
lemma eventually_True [simp]: "eventually (\<lambda>x. True) F"
huffman@31349
    26
unfolding eventually_def using Rep_filter [of F] by blast
huffman@31349
    27
huffman@31349
    28
lemma eventually_mono:
huffman@31349
    29
  "(\<forall>x. P x \<longrightarrow> Q x) \<Longrightarrow> eventually P F \<Longrightarrow> eventually Q F"
huffman@31349
    30
unfolding eventually_def using Rep_filter [of F] by blast
huffman@31349
    31
huffman@31349
    32
lemma eventually_conj:
huffman@31349
    33
  "\<lbrakk>eventually (\<lambda>x. P x) F; eventually (\<lambda>x. Q x) F\<rbrakk>
huffman@31349
    34
    \<Longrightarrow> eventually (\<lambda>x. P x \<and> Q x) F"
huffman@31349
    35
unfolding eventually_def using Rep_filter [of F] by blast
huffman@31349
    36
huffman@31349
    37
lemma eventually_mp:
huffman@31349
    38
  assumes "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
huffman@31349
    39
  assumes "eventually (\<lambda>x. P x) F"
huffman@31349
    40
  shows "eventually (\<lambda>x. Q x) F"
huffman@31349
    41
proof (rule eventually_mono)
huffman@31349
    42
  show "\<forall>x. (P x \<longrightarrow> Q x) \<and> P x \<longrightarrow> Q x" by simp
huffman@31349
    43
  show "eventually (\<lambda>x. (P x \<longrightarrow> Q x) \<and> P x) F"
huffman@31349
    44
    using assms by (rule eventually_conj)
huffman@31349
    45
qed
huffman@31349
    46
huffman@31349
    47
lemma eventually_rev_mp:
huffman@31349
    48
  assumes "eventually (\<lambda>x. P x) F"
huffman@31349
    49
  assumes "eventually (\<lambda>x. P x \<longrightarrow> Q x) F"
huffman@31349
    50
  shows "eventually (\<lambda>x. Q x) F"
huffman@31349
    51
using assms(2) assms(1) by (rule eventually_mp)
huffman@31349
    52
huffman@31349
    53
lemma eventually_conj_iff:
huffman@31349
    54
  "eventually (\<lambda>x. P x \<and> Q x) net \<longleftrightarrow> eventually P net \<and> eventually Q net"
huffman@31349
    55
by (auto intro: eventually_conj elim: eventually_rev_mp)
huffman@31349
    56
huffman@31349
    57
lemma eventually_Abs_filter:
huffman@31349
    58
  assumes "f (\<lambda>x. True)"
huffman@31349
    59
  assumes "\<And>P Q. (\<forall>x. P x \<longrightarrow> Q x) \<Longrightarrow> f P \<Longrightarrow> f Q"
huffman@31349
    60
  assumes "\<And>P Q. f P \<Longrightarrow> f Q \<Longrightarrow> f (\<lambda>x. P x \<and> Q x)"
huffman@31349
    61
  shows "eventually P (Abs_filter f) \<longleftrightarrow> f P"
huffman@31349
    62
unfolding eventually_def using assms
huffman@31349
    63
by (subst Abs_filter_inverse, auto)
huffman@31349
    64
huffman@31349
    65
lemma filter_ext:
huffman@31349
    66
  "(\<And>P. eventually P F \<longleftrightarrow> eventually P F') \<Longrightarrow> F = F'"
huffman@31349
    67
unfolding eventually_def
huffman@31349
    68
by (simp add: Rep_filter_inject [THEN iffD1] ext)
huffman@31349
    69
huffman@31349
    70
lemma eventually_elim1:
huffman@31349
    71
  assumes "eventually (\<lambda>i. P i) F"
huffman@31349
    72
  assumes "\<And>i. P i \<Longrightarrow> Q i"
huffman@31349
    73
  shows "eventually (\<lambda>i. Q i) F"
huffman@31349
    74
using assms by (auto elim!: eventually_rev_mp)
huffman@31349
    75
huffman@31349
    76
lemma eventually_elim2:
huffman@31349
    77
  assumes "eventually (\<lambda>i. P i) F"
huffman@31349
    78
  assumes "eventually (\<lambda>i. Q i) F"
huffman@31349
    79
  assumes "\<And>i. P i \<Longrightarrow> Q i \<Longrightarrow> R i"
huffman@31349
    80
  shows "eventually (\<lambda>i. R i) F"
huffman@31349
    81
using assms by (auto elim!: eventually_rev_mp)
huffman@31349
    82
huffman@31349
    83
huffman@31355
    84
subsection {* Boundedness *}
huffman@31355
    85
huffman@31355
    86
definition
huffman@31355
    87
  Bfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" where
huffman@31355
    88
  "Bfun S F = (\<exists>K>0. eventually (\<lambda>i. norm (S i) \<le> K) F)"
huffman@31355
    89
huffman@31355
    90
lemma BfunI: assumes K: "eventually (\<lambda>i. norm (X i) \<le> K) F" shows "Bfun X F"
huffman@31355
    91
unfolding Bfun_def
huffman@31355
    92
proof (intro exI conjI allI)
huffman@31355
    93
  show "0 < max K 1" by simp
huffman@31355
    94
next
huffman@31355
    95
  show "eventually (\<lambda>i. norm (X i) \<le> max K 1) F"
huffman@31355
    96
    using K by (rule eventually_elim1, simp)
huffman@31355
    97
qed
huffman@31355
    98
huffman@31355
    99
lemma BfunE:
huffman@31355
   100
  assumes "Bfun S F"
huffman@31355
   101
  obtains B where "0 < B" and "eventually (\<lambda>i. norm (S i) \<le> B) F"
huffman@31355
   102
using assms unfolding Bfun_def by fast
huffman@31355
   103
huffman@31355
   104
huffman@31349
   105
subsection {* Convergence to Zero *}
huffman@31349
   106
huffman@31349
   107
definition
huffman@31349
   108
  Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" where
huffman@31353
   109
  [code del]: "Zfun S F = (\<forall>r>0. eventually (\<lambda>i. norm (S i) < r) F)"
huffman@31349
   110
huffman@31349
   111
lemma ZfunI:
huffman@31349
   112
  "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>i. norm (S i) < r) F) \<Longrightarrow> Zfun S F"
huffman@31349
   113
unfolding Zfun_def by simp
huffman@31349
   114
huffman@31349
   115
lemma ZfunD:
huffman@31349
   116
  "\<lbrakk>Zfun S F; 0 < r\<rbrakk> \<Longrightarrow> eventually (\<lambda>i. norm (S i) < r) F"
huffman@31349
   117
unfolding Zfun_def by simp
huffman@31349
   118
huffman@31355
   119
lemma Zfun_ssubst:
huffman@31355
   120
  "eventually (\<lambda>i. X i = Y i) F \<Longrightarrow> Zfun Y F \<Longrightarrow> Zfun X F"
huffman@31355
   121
unfolding Zfun_def by (auto elim!: eventually_rev_mp)
huffman@31355
   122
huffman@31349
   123
lemma Zfun_zero: "Zfun (\<lambda>i. 0) F"
huffman@31349
   124
unfolding Zfun_def by simp
huffman@31349
   125
huffman@31349
   126
lemma Zfun_norm_iff: "Zfun (\<lambda>i. norm (S i)) F = Zfun (\<lambda>i. S i) F"
huffman@31349
   127
unfolding Zfun_def by simp
huffman@31349
   128
huffman@31349
   129
lemma Zfun_imp_Zfun:
huffman@31349
   130
  assumes X: "Zfun X F"
huffman@31355
   131
  assumes Y: "eventually (\<lambda>i. norm (Y i) \<le> norm (X i) * K) F"
huffman@31349
   132
  shows "Zfun (\<lambda>n. Y n) F"
huffman@31349
   133
proof (cases)
huffman@31349
   134
  assume K: "0 < K"
huffman@31349
   135
  show ?thesis
huffman@31349
   136
  proof (rule ZfunI)
huffman@31349
   137
    fix r::real assume "0 < r"
huffman@31349
   138
    hence "0 < r / K"
huffman@31349
   139
      using K by (rule divide_pos_pos)
huffman@31349
   140
    then have "eventually (\<lambda>i. norm (X i) < r / K) F"
huffman@31349
   141
      using ZfunD [OF X] by fast
huffman@31355
   142
    with Y show "eventually (\<lambda>i. norm (Y i) < r) F"
huffman@31355
   143
    proof (rule eventually_elim2)
huffman@31355
   144
      fix i
huffman@31355
   145
      assume *: "norm (Y i) \<le> norm (X i) * K"
huffman@31355
   146
      assume "norm (X i) < r / K"
huffman@31349
   147
      hence "norm (X i) * K < r"
huffman@31349
   148
        by (simp add: pos_less_divide_eq K)
huffman@31349
   149
      thus "norm (Y i) < r"
huffman@31355
   150
        by (simp add: order_le_less_trans [OF *])
huffman@31349
   151
    qed
huffman@31349
   152
  qed
huffman@31349
   153
next
huffman@31349
   154
  assume "\<not> 0 < K"
huffman@31349
   155
  hence K: "K \<le> 0" by (simp only: not_less)
huffman@31355
   156
  show ?thesis
huffman@31355
   157
  proof (rule ZfunI)
huffman@31355
   158
    fix r :: real
huffman@31355
   159
    assume "0 < r"
huffman@31355
   160
    from Y show "eventually (\<lambda>i. norm (Y i) < r) F"
huffman@31355
   161
    proof (rule eventually_elim1)
huffman@31355
   162
      fix i
huffman@31355
   163
      assume "norm (Y i) \<le> norm (X i) * K"
huffman@31355
   164
      also have "\<dots> \<le> norm (X i) * 0"
huffman@31355
   165
        using K norm_ge_zero by (rule mult_left_mono)
huffman@31355
   166
      finally show "norm (Y i) < r"
huffman@31355
   167
        using `0 < r` by simp
huffman@31355
   168
    qed
huffman@31355
   169
  qed
huffman@31349
   170
qed
huffman@31349
   171
huffman@31349
   172
lemma Zfun_le: "\<lbrakk>Zfun Y F; \<forall>n. norm (X n) \<le> norm (Y n)\<rbrakk> \<Longrightarrow> Zfun X F"
huffman@31349
   173
by (erule_tac K="1" in Zfun_imp_Zfun, simp)
huffman@31349
   174
huffman@31349
   175
lemma Zfun_add:
huffman@31349
   176
  assumes X: "Zfun X F" and Y: "Zfun Y F"
huffman@31349
   177
  shows "Zfun (\<lambda>n. X n + Y n) F"
huffman@31349
   178
proof (rule ZfunI)
huffman@31349
   179
  fix r::real assume "0 < r"
huffman@31349
   180
  hence r: "0 < r / 2" by simp
huffman@31349
   181
  have "eventually (\<lambda>i. norm (X i) < r/2) F"
huffman@31349
   182
    using X r by (rule ZfunD)
huffman@31349
   183
  moreover
huffman@31349
   184
  have "eventually (\<lambda>i. norm (Y i) < r/2) F"
huffman@31349
   185
    using Y r by (rule ZfunD)
huffman@31349
   186
  ultimately
huffman@31349
   187
  show "eventually (\<lambda>i. norm (X i + Y i) < r) F"
huffman@31349
   188
  proof (rule eventually_elim2)
huffman@31349
   189
    fix i
huffman@31349
   190
    assume *: "norm (X i) < r/2" "norm (Y i) < r/2"
huffman@31349
   191
    have "norm (X i + Y i) \<le> norm (X i) + norm (Y i)"
huffman@31349
   192
      by (rule norm_triangle_ineq)
huffman@31349
   193
    also have "\<dots> < r/2 + r/2"
huffman@31349
   194
      using * by (rule add_strict_mono)
huffman@31349
   195
    finally show "norm (X i + Y i) < r"
huffman@31349
   196
      by simp
huffman@31349
   197
  qed
huffman@31349
   198
qed
huffman@31349
   199
huffman@31349
   200
lemma Zfun_minus: "Zfun X F \<Longrightarrow> Zfun (\<lambda>i. - X i) F"
huffman@31349
   201
unfolding Zfun_def by simp
huffman@31349
   202
huffman@31349
   203
lemma Zfun_diff: "\<lbrakk>Zfun X F; Zfun Y F\<rbrakk> \<Longrightarrow> Zfun (\<lambda>i. X i - Y i) F"
huffman@31349
   204
by (simp only: diff_minus Zfun_add Zfun_minus)
huffman@31349
   205
huffman@31349
   206
lemma (in bounded_linear) Zfun:
huffman@31349
   207
  assumes X: "Zfun X F"
huffman@31349
   208
  shows "Zfun (\<lambda>n. f (X n)) F"
huffman@31349
   209
proof -
huffman@31349
   210
  obtain K where "\<And>x. norm (f x) \<le> norm x * K"
huffman@31349
   211
    using bounded by fast
huffman@31355
   212
  then have "eventually (\<lambda>i. norm (f (X i)) \<le> norm (X i) * K) F"
huffman@31355
   213
    by simp
huffman@31349
   214
  with X show ?thesis
huffman@31349
   215
    by (rule Zfun_imp_Zfun)
huffman@31349
   216
qed
huffman@31349
   217
huffman@31349
   218
lemma (in bounded_bilinear) Zfun:
huffman@31349
   219
  assumes X: "Zfun X F"
huffman@31349
   220
  assumes Y: "Zfun Y F"
huffman@31349
   221
  shows "Zfun (\<lambda>n. X n ** Y n) F"
huffman@31349
   222
proof (rule ZfunI)
huffman@31349
   223
  fix r::real assume r: "0 < r"
huffman@31349
   224
  obtain K where K: "0 < K"
huffman@31349
   225
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@31349
   226
    using pos_bounded by fast
huffman@31349
   227
  from K have K': "0 < inverse K"
huffman@31349
   228
    by (rule positive_imp_inverse_positive)
huffman@31349
   229
  have "eventually (\<lambda>i. norm (X i) < r) F"
huffman@31349
   230
    using X r by (rule ZfunD)
huffman@31349
   231
  moreover
huffman@31349
   232
  have "eventually (\<lambda>i. norm (Y i) < inverse K) F"
huffman@31349
   233
    using Y K' by (rule ZfunD)
huffman@31349
   234
  ultimately
huffman@31349
   235
  show "eventually (\<lambda>i. norm (X i ** Y i) < r) F"
huffman@31349
   236
  proof (rule eventually_elim2)
huffman@31349
   237
    fix i
huffman@31349
   238
    assume *: "norm (X i) < r" "norm (Y i) < inverse K"
huffman@31349
   239
    have "norm (X i ** Y i) \<le> norm (X i) * norm (Y i) * K"
huffman@31349
   240
      by (rule norm_le)
huffman@31349
   241
    also have "norm (X i) * norm (Y i) * K < r * inverse K * K"
huffman@31349
   242
      by (intro mult_strict_right_mono mult_strict_mono' norm_ge_zero * K)
huffman@31349
   243
    also from K have "r * inverse K * K = r"
huffman@31349
   244
      by simp
huffman@31349
   245
    finally show "norm (X i ** Y i) < r" .
huffman@31349
   246
  qed
huffman@31349
   247
qed
huffman@31349
   248
huffman@31349
   249
lemma (in bounded_bilinear) Zfun_left:
huffman@31349
   250
  "Zfun X F \<Longrightarrow> Zfun (\<lambda>n. X n ** a) F"
huffman@31349
   251
by (rule bounded_linear_left [THEN bounded_linear.Zfun])
huffman@31349
   252
huffman@31349
   253
lemma (in bounded_bilinear) Zfun_right:
huffman@31349
   254
  "Zfun X F \<Longrightarrow> Zfun (\<lambda>n. a ** X n) F"
huffman@31349
   255
by (rule bounded_linear_right [THEN bounded_linear.Zfun])
huffman@31349
   256
huffman@31349
   257
lemmas Zfun_mult = mult.Zfun
huffman@31349
   258
lemmas Zfun_mult_right = mult.Zfun_right
huffman@31349
   259
lemmas Zfun_mult_left = mult.Zfun_left
huffman@31349
   260
huffman@31349
   261
huffman@31349
   262
subsection{* Limits *}
huffman@31349
   263
huffman@31349
   264
definition
huffman@31349
   265
  tendsto :: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'b \<Rightarrow> 'a filter \<Rightarrow> bool" where
huffman@31353
   266
  [code del]: "tendsto f l net \<longleftrightarrow> (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)"
huffman@31349
   267
huffman@31349
   268
lemma tendstoI:
huffman@31349
   269
  "(\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net)
huffman@31349
   270
    \<Longrightarrow> tendsto f l net"
huffman@31349
   271
  unfolding tendsto_def by auto
huffman@31349
   272
huffman@31349
   273
lemma tendstoD:
huffman@31349
   274
  "tendsto f l net \<Longrightarrow> 0 < e \<Longrightarrow> eventually (\<lambda>x. dist (f x) l < e) net"
huffman@31349
   275
  unfolding tendsto_def by auto
huffman@31349
   276
huffman@31349
   277
lemma tendsto_Zfun_iff: "tendsto (\<lambda>n. X n) L F = Zfun (\<lambda>n. X n - L) F"
huffman@31349
   278
by (simp only: tendsto_def Zfun_def dist_norm)
huffman@31349
   279
huffman@31349
   280
lemma tendsto_const: "tendsto (\<lambda>n. k) k F"
huffman@31349
   281
by (simp add: tendsto_def)
huffman@31349
   282
huffman@31349
   283
lemma tendsto_norm:
huffman@31349
   284
  fixes a :: "'a::real_normed_vector"
huffman@31349
   285
  shows "tendsto X a F \<Longrightarrow> tendsto (\<lambda>n. norm (X n)) (norm a) F"
huffman@31349
   286
apply (simp add: tendsto_def dist_norm, safe)
huffman@31349
   287
apply (drule_tac x="e" in spec, safe)
huffman@31349
   288
apply (erule eventually_elim1)
huffman@31349
   289
apply (erule order_le_less_trans [OF norm_triangle_ineq3])
huffman@31349
   290
done
huffman@31349
   291
huffman@31349
   292
lemma add_diff_add:
huffman@31349
   293
  fixes a b c d :: "'a::ab_group_add"
huffman@31349
   294
  shows "(a + c) - (b + d) = (a - b) + (c - d)"
huffman@31349
   295
by simp
huffman@31349
   296
huffman@31349
   297
lemma minus_diff_minus:
huffman@31349
   298
  fixes a b :: "'a::ab_group_add"
huffman@31349
   299
  shows "(- a) - (- b) = - (a - b)"
huffman@31349
   300
by simp
huffman@31349
   301
huffman@31349
   302
lemma tendsto_add:
huffman@31349
   303
  fixes a b :: "'a::real_normed_vector"
huffman@31349
   304
  shows "\<lbrakk>tendsto X a F; tendsto Y b F\<rbrakk> \<Longrightarrow> tendsto (\<lambda>n. X n + Y n) (a + b) F"
huffman@31349
   305
by (simp only: tendsto_Zfun_iff add_diff_add Zfun_add)
huffman@31349
   306
huffman@31349
   307
lemma tendsto_minus:
huffman@31349
   308
  fixes a :: "'a::real_normed_vector"
huffman@31349
   309
  shows "tendsto X a F \<Longrightarrow> tendsto (\<lambda>n. - X n) (- a) F"
huffman@31349
   310
by (simp only: tendsto_Zfun_iff minus_diff_minus Zfun_minus)
huffman@31349
   311
huffman@31349
   312
lemma tendsto_minus_cancel:
huffman@31349
   313
  fixes a :: "'a::real_normed_vector"
huffman@31349
   314
  shows "tendsto (\<lambda>n. - X n) (- a) F \<Longrightarrow> tendsto X a F"
huffman@31349
   315
by (drule tendsto_minus, simp)
huffman@31349
   316
huffman@31349
   317
lemma tendsto_diff:
huffman@31349
   318
  fixes a b :: "'a::real_normed_vector"
huffman@31349
   319
  shows "\<lbrakk>tendsto X a F; tendsto Y b F\<rbrakk> \<Longrightarrow> tendsto (\<lambda>n. X n - Y n) (a - b) F"
huffman@31349
   320
by (simp add: diff_minus tendsto_add tendsto_minus)
huffman@31349
   321
huffman@31349
   322
lemma (in bounded_linear) tendsto:
huffman@31349
   323
  "tendsto X a F \<Longrightarrow> tendsto (\<lambda>n. f (X n)) (f a) F"
huffman@31349
   324
by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun)
huffman@31349
   325
huffman@31349
   326
lemma (in bounded_bilinear) tendsto:
huffman@31349
   327
  "\<lbrakk>tendsto X a F; tendsto Y b F\<rbrakk> \<Longrightarrow> tendsto (\<lambda>n. X n ** Y n) (a ** b) F"
huffman@31349
   328
by (simp only: tendsto_Zfun_iff prod_diff_prod
huffman@31349
   329
               Zfun_add Zfun Zfun_left Zfun_right)
huffman@31349
   330
huffman@31355
   331
huffman@31355
   332
subsection {* Continuity of Inverse *}
huffman@31355
   333
huffman@31355
   334
lemma (in bounded_bilinear) Zfun_prod_Bfun:
huffman@31355
   335
  assumes X: "Zfun X F"
huffman@31355
   336
  assumes Y: "Bfun Y F"
huffman@31355
   337
  shows "Zfun (\<lambda>n. X n ** Y n) F"
huffman@31355
   338
proof -
huffman@31355
   339
  obtain K where K: "0 \<le> K"
huffman@31355
   340
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@31355
   341
    using nonneg_bounded by fast
huffman@31355
   342
  obtain B where B: "0 < B"
huffman@31355
   343
    and norm_Y: "eventually (\<lambda>i. norm (Y i) \<le> B) F"
huffman@31355
   344
    using Y by (rule BfunE)
huffman@31355
   345
  have "eventually (\<lambda>i. norm (X i ** Y i) \<le> norm (X i) * (B * K)) F"
huffman@31355
   346
  using norm_Y proof (rule eventually_elim1)
huffman@31355
   347
    fix i
huffman@31355
   348
    assume *: "norm (Y i) \<le> B"
huffman@31355
   349
    have "norm (X i ** Y i) \<le> norm (X i) * norm (Y i) * K"
huffman@31355
   350
      by (rule norm_le)
huffman@31355
   351
    also have "\<dots> \<le> norm (X i) * B * K"
huffman@31355
   352
      by (intro mult_mono' order_refl norm_Y norm_ge_zero
huffman@31355
   353
                mult_nonneg_nonneg K *)
huffman@31355
   354
    also have "\<dots> = norm (X i) * (B * K)"
huffman@31355
   355
      by (rule mult_assoc)
huffman@31355
   356
    finally show "norm (X i ** Y i) \<le> norm (X i) * (B * K)" .
huffman@31355
   357
  qed
huffman@31355
   358
  with X show ?thesis
huffman@31355
   359
  by (rule Zfun_imp_Zfun)
huffman@31355
   360
qed
huffman@31355
   361
huffman@31355
   362
lemma (in bounded_bilinear) flip:
huffman@31355
   363
  "bounded_bilinear (\<lambda>x y. y ** x)"
huffman@31355
   364
apply default
huffman@31355
   365
apply (rule add_right)
huffman@31355
   366
apply (rule add_left)
huffman@31355
   367
apply (rule scaleR_right)
huffman@31355
   368
apply (rule scaleR_left)
huffman@31355
   369
apply (subst mult_commute)
huffman@31355
   370
using bounded by fast
huffman@31355
   371
huffman@31355
   372
lemma (in bounded_bilinear) Bfun_prod_Zfun:
huffman@31355
   373
  assumes X: "Bfun X F"
huffman@31355
   374
  assumes Y: "Zfun Y F"
huffman@31355
   375
  shows "Zfun (\<lambda>n. X n ** Y n) F"
huffman@31355
   376
using flip Y X by (rule bounded_bilinear.Zfun_prod_Bfun)
huffman@31355
   377
huffman@31355
   378
lemma inverse_diff_inverse:
huffman@31355
   379
  "\<lbrakk>(a::'a::division_ring) \<noteq> 0; b \<noteq> 0\<rbrakk>
huffman@31355
   380
   \<Longrightarrow> inverse a - inverse b = - (inverse a * (a - b) * inverse b)"
huffman@31355
   381
by (simp add: algebra_simps)
huffman@31355
   382
huffman@31355
   383
lemma Bfun_inverse_lemma:
huffman@31355
   384
  fixes x :: "'a::real_normed_div_algebra"
huffman@31355
   385
  shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
huffman@31355
   386
apply (subst nonzero_norm_inverse, clarsimp)
huffman@31355
   387
apply (erule (1) le_imp_inverse_le)
huffman@31355
   388
done
huffman@31355
   389
huffman@31355
   390
lemma Bfun_inverse:
huffman@31355
   391
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   392
  assumes X: "tendsto X a F"
huffman@31355
   393
  assumes a: "a \<noteq> 0"
huffman@31355
   394
  shows "Bfun (\<lambda>n. inverse (X n)) F"
huffman@31355
   395
proof -
huffman@31355
   396
  from a have "0 < norm a" by simp
huffman@31355
   397
  hence "\<exists>r>0. r < norm a" by (rule dense)
huffman@31355
   398
  then obtain r where r1: "0 < r" and r2: "r < norm a" by fast
huffman@31355
   399
  have "eventually (\<lambda>i. dist (X i) a < r) F"
huffman@31355
   400
    using tendstoD [OF X r1] by fast
huffman@31355
   401
  hence "eventually (\<lambda>i. norm (inverse (X i)) \<le> inverse (norm a - r)) F"
huffman@31355
   402
  proof (rule eventually_elim1)
huffman@31355
   403
    fix i
huffman@31355
   404
    assume "dist (X i) a < r"
huffman@31355
   405
    hence 1: "norm (X i - a) < r"
huffman@31355
   406
      by (simp add: dist_norm)
huffman@31355
   407
    hence 2: "X i \<noteq> 0" using r2 by auto
huffman@31355
   408
    hence "norm (inverse (X i)) = inverse (norm (X i))"
huffman@31355
   409
      by (rule nonzero_norm_inverse)
huffman@31355
   410
    also have "\<dots> \<le> inverse (norm a - r)"
huffman@31355
   411
    proof (rule le_imp_inverse_le)
huffman@31355
   412
      show "0 < norm a - r" using r2 by simp
huffman@31355
   413
    next
huffman@31355
   414
      have "norm a - norm (X i) \<le> norm (a - X i)"
huffman@31355
   415
        by (rule norm_triangle_ineq2)
huffman@31355
   416
      also have "\<dots> = norm (X i - a)"
huffman@31355
   417
        by (rule norm_minus_commute)
huffman@31355
   418
      also have "\<dots> < r" using 1 .
huffman@31355
   419
      finally show "norm a - r \<le> norm (X i)" by simp
huffman@31355
   420
    qed
huffman@31355
   421
    finally show "norm (inverse (X i)) \<le> inverse (norm a - r)" .
huffman@31355
   422
  qed
huffman@31355
   423
  thus ?thesis by (rule BfunI)
huffman@31355
   424
qed
huffman@31355
   425
huffman@31355
   426
lemma tendsto_inverse_lemma:
huffman@31355
   427
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   428
  shows "\<lbrakk>tendsto X a F; a \<noteq> 0; eventually (\<lambda>i. X i \<noteq> 0) F\<rbrakk>
huffman@31355
   429
         \<Longrightarrow> tendsto (\<lambda>i. inverse (X i)) (inverse a) F"
huffman@31355
   430
apply (subst tendsto_Zfun_iff)
huffman@31355
   431
apply (rule Zfun_ssubst)
huffman@31355
   432
apply (erule eventually_elim1)
huffman@31355
   433
apply (erule (1) inverse_diff_inverse)
huffman@31355
   434
apply (rule Zfun_minus)
huffman@31355
   435
apply (rule Zfun_mult_left)
huffman@31355
   436
apply (rule mult.Bfun_prod_Zfun)
huffman@31355
   437
apply (erule (1) Bfun_inverse)
huffman@31355
   438
apply (simp add: tendsto_Zfun_iff)
huffman@31355
   439
done
huffman@31355
   440
huffman@31355
   441
lemma tendsto_inverse:
huffman@31355
   442
  fixes a :: "'a::real_normed_div_algebra"
huffman@31355
   443
  assumes X: "tendsto X a F"
huffman@31355
   444
  assumes a: "a \<noteq> 0"
huffman@31355
   445
  shows "tendsto (\<lambda>i. inverse (X i)) (inverse a) F"
huffman@31355
   446
proof -
huffman@31355
   447
  from a have "0 < norm a" by simp
huffman@31355
   448
  with X have "eventually (\<lambda>i. dist (X i) a < norm a) F"
huffman@31355
   449
    by (rule tendstoD)
huffman@31355
   450
  then have "eventually (\<lambda>i. X i \<noteq> 0) F"
huffman@31355
   451
    unfolding dist_norm by (auto elim!: eventually_elim1)
huffman@31355
   452
  with X a show ?thesis
huffman@31355
   453
    by (rule tendsto_inverse_lemma)
huffman@31355
   454
qed
huffman@31355
   455
huffman@31355
   456
lemma tendsto_divide:
huffman@31355
   457
  fixes a b :: "'a::real_normed_field"
huffman@31355
   458
  shows "\<lbrakk>tendsto X a F; tendsto Y b F; b \<noteq> 0\<rbrakk>
huffman@31355
   459
    \<Longrightarrow> tendsto (\<lambda>n. X n / Y n) (a / b) F"
huffman@31355
   460
by (simp add: mult.tendsto tendsto_inverse divide_inverse)
huffman@31355
   461
huffman@31349
   462
end