src/HOL/Limits.thy
changeset 31355 3d18766ddc4b
parent 31353 14a58e2ca374
child 31356 ec8b9b6c47dc
equal deleted inserted replaced
31354:2ad53771c30f 31355:3d18766ddc4b
    79   assumes "\<And>i. P i \<Longrightarrow> Q i \<Longrightarrow> R i"
    79   assumes "\<And>i. P i \<Longrightarrow> Q i \<Longrightarrow> R i"
    80   shows "eventually (\<lambda>i. R i) F"
    80   shows "eventually (\<lambda>i. R i) F"
    81 using assms by (auto elim!: eventually_rev_mp)
    81 using assms by (auto elim!: eventually_rev_mp)
    82 
    82 
    83 
    83 
       
    84 subsection {* Boundedness *}
       
    85 
       
    86 definition
       
    87   Bfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" where
       
    88   "Bfun S F = (\<exists>K>0. eventually (\<lambda>i. norm (S i) \<le> K) F)"
       
    89 
       
    90 lemma BfunI: assumes K: "eventually (\<lambda>i. norm (X i) \<le> K) F" shows "Bfun X F"
       
    91 unfolding Bfun_def
       
    92 proof (intro exI conjI allI)
       
    93   show "0 < max K 1" by simp
       
    94 next
       
    95   show "eventually (\<lambda>i. norm (X i) \<le> max K 1) F"
       
    96     using K by (rule eventually_elim1, simp)
       
    97 qed
       
    98 
       
    99 lemma BfunE:
       
   100   assumes "Bfun S F"
       
   101   obtains B where "0 < B" and "eventually (\<lambda>i. norm (S i) \<le> B) F"
       
   102 using assms unfolding Bfun_def by fast
       
   103 
       
   104 
    84 subsection {* Convergence to Zero *}
   105 subsection {* Convergence to Zero *}
    85 
   106 
    86 definition
   107 definition
    87   Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" where
   108   Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" where
    88   [code del]: "Zfun S F = (\<forall>r>0. eventually (\<lambda>i. norm (S i) < r) F)"
   109   [code del]: "Zfun S F = (\<forall>r>0. eventually (\<lambda>i. norm (S i) < r) F)"
    93 
   114 
    94 lemma ZfunD:
   115 lemma ZfunD:
    95   "\<lbrakk>Zfun S F; 0 < r\<rbrakk> \<Longrightarrow> eventually (\<lambda>i. norm (S i) < r) F"
   116   "\<lbrakk>Zfun S F; 0 < r\<rbrakk> \<Longrightarrow> eventually (\<lambda>i. norm (S i) < r) F"
    96 unfolding Zfun_def by simp
   117 unfolding Zfun_def by simp
    97 
   118 
       
   119 lemma Zfun_ssubst:
       
   120   "eventually (\<lambda>i. X i = Y i) F \<Longrightarrow> Zfun Y F \<Longrightarrow> Zfun X F"
       
   121 unfolding Zfun_def by (auto elim!: eventually_rev_mp)
       
   122 
    98 lemma Zfun_zero: "Zfun (\<lambda>i. 0) F"
   123 lemma Zfun_zero: "Zfun (\<lambda>i. 0) F"
    99 unfolding Zfun_def by simp
   124 unfolding Zfun_def by simp
   100 
   125 
   101 lemma Zfun_norm_iff: "Zfun (\<lambda>i. norm (S i)) F = Zfun (\<lambda>i. S i) F"
   126 lemma Zfun_norm_iff: "Zfun (\<lambda>i. norm (S i)) F = Zfun (\<lambda>i. S i) F"
   102 unfolding Zfun_def by simp
   127 unfolding Zfun_def by simp
   103 
   128 
   104 lemma Zfun_imp_Zfun:
   129 lemma Zfun_imp_Zfun:
   105   assumes X: "Zfun X F"
   130   assumes X: "Zfun X F"
   106   assumes Y: "\<And>n. norm (Y n) \<le> norm (X n) * K"
   131   assumes Y: "eventually (\<lambda>i. norm (Y i) \<le> norm (X i) * K) F"
   107   shows "Zfun (\<lambda>n. Y n) F"
   132   shows "Zfun (\<lambda>n. Y n) F"
   108 proof (cases)
   133 proof (cases)
   109   assume K: "0 < K"
   134   assume K: "0 < K"
   110   show ?thesis
   135   show ?thesis
   111   proof (rule ZfunI)
   136   proof (rule ZfunI)
   112     fix r::real assume "0 < r"
   137     fix r::real assume "0 < r"
   113     hence "0 < r / K"
   138     hence "0 < r / K"
   114       using K by (rule divide_pos_pos)
   139       using K by (rule divide_pos_pos)
   115     then have "eventually (\<lambda>i. norm (X i) < r / K) F"
   140     then have "eventually (\<lambda>i. norm (X i) < r / K) F"
   116       using ZfunD [OF X] by fast
   141       using ZfunD [OF X] by fast
   117     then show "eventually (\<lambda>i. norm (Y i) < r) F"
   142     with Y show "eventually (\<lambda>i. norm (Y i) < r) F"
   118     proof (rule eventually_elim1)
   143     proof (rule eventually_elim2)
   119       fix i assume "norm (X i) < r / K"
   144       fix i
       
   145       assume *: "norm (Y i) \<le> norm (X i) * K"
       
   146       assume "norm (X i) < r / K"
   120       hence "norm (X i) * K < r"
   147       hence "norm (X i) * K < r"
   121         by (simp add: pos_less_divide_eq K)
   148         by (simp add: pos_less_divide_eq K)
   122       thus "norm (Y i) < r"
   149       thus "norm (Y i) < r"
   123         by (simp add: order_le_less_trans [OF Y])
   150         by (simp add: order_le_less_trans [OF *])
   124     qed
   151     qed
   125   qed
   152   qed
   126 next
   153 next
   127   assume "\<not> 0 < K"
   154   assume "\<not> 0 < K"
   128   hence K: "K \<le> 0" by (simp only: not_less)
   155   hence K: "K \<le> 0" by (simp only: not_less)
   129   {
   156   show ?thesis
   130     fix i
   157   proof (rule ZfunI)
   131     have "norm (Y i) \<le> norm (X i) * K" by (rule Y)
   158     fix r :: real
   132     also have "\<dots> \<le> norm (X i) * 0"
   159     assume "0 < r"
   133       using K norm_ge_zero by (rule mult_left_mono)
   160     from Y show "eventually (\<lambda>i. norm (Y i) < r) F"
   134     finally have "norm (Y i) = 0" by simp
   161     proof (rule eventually_elim1)
   135   }
   162       fix i
   136   thus ?thesis by (simp add: Zfun_zero)
   163       assume "norm (Y i) \<le> norm (X i) * K"
       
   164       also have "\<dots> \<le> norm (X i) * 0"
       
   165         using K norm_ge_zero by (rule mult_left_mono)
       
   166       finally show "norm (Y i) < r"
       
   167         using `0 < r` by simp
       
   168     qed
       
   169   qed
   137 qed
   170 qed
   138 
   171 
   139 lemma Zfun_le: "\<lbrakk>Zfun Y F; \<forall>n. norm (X n) \<le> norm (Y n)\<rbrakk> \<Longrightarrow> Zfun X F"
   172 lemma Zfun_le: "\<lbrakk>Zfun Y F; \<forall>n. norm (X n) \<le> norm (Y n)\<rbrakk> \<Longrightarrow> Zfun X F"
   140 by (erule_tac K="1" in Zfun_imp_Zfun, simp)
   173 by (erule_tac K="1" in Zfun_imp_Zfun, simp)
   141 
   174 
   174   assumes X: "Zfun X F"
   207   assumes X: "Zfun X F"
   175   shows "Zfun (\<lambda>n. f (X n)) F"
   208   shows "Zfun (\<lambda>n. f (X n)) F"
   176 proof -
   209 proof -
   177   obtain K where "\<And>x. norm (f x) \<le> norm x * K"
   210   obtain K where "\<And>x. norm (f x) \<le> norm x * K"
   178     using bounded by fast
   211     using bounded by fast
       
   212   then have "eventually (\<lambda>i. norm (f (X i)) \<le> norm (X i) * K) F"
       
   213     by simp
   179   with X show ?thesis
   214   with X show ?thesis
   180     by (rule Zfun_imp_Zfun)
   215     by (rule Zfun_imp_Zfun)
   181 qed
   216 qed
   182 
   217 
   183 lemma (in bounded_bilinear) Zfun:
   218 lemma (in bounded_bilinear) Zfun:
   291 lemma (in bounded_bilinear) tendsto:
   326 lemma (in bounded_bilinear) tendsto:
   292   "\<lbrakk>tendsto X a F; tendsto Y b F\<rbrakk> \<Longrightarrow> tendsto (\<lambda>n. X n ** Y n) (a ** b) F"
   327   "\<lbrakk>tendsto X a F; tendsto Y b F\<rbrakk> \<Longrightarrow> tendsto (\<lambda>n. X n ** Y n) (a ** b) F"
   293 by (simp only: tendsto_Zfun_iff prod_diff_prod
   328 by (simp only: tendsto_Zfun_iff prod_diff_prod
   294                Zfun_add Zfun Zfun_left Zfun_right)
   329                Zfun_add Zfun Zfun_left Zfun_right)
   295 
   330 
       
   331 
       
   332 subsection {* Continuity of Inverse *}
       
   333 
       
   334 lemma (in bounded_bilinear) Zfun_prod_Bfun:
       
   335   assumes X: "Zfun X F"
       
   336   assumes Y: "Bfun Y F"
       
   337   shows "Zfun (\<lambda>n. X n ** Y n) F"
       
   338 proof -
       
   339   obtain K where K: "0 \<le> K"
       
   340     and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
       
   341     using nonneg_bounded by fast
       
   342   obtain B where B: "0 < B"
       
   343     and norm_Y: "eventually (\<lambda>i. norm (Y i) \<le> B) F"
       
   344     using Y by (rule BfunE)
       
   345   have "eventually (\<lambda>i. norm (X i ** Y i) \<le> norm (X i) * (B * K)) F"
       
   346   using norm_Y proof (rule eventually_elim1)
       
   347     fix i
       
   348     assume *: "norm (Y i) \<le> B"
       
   349     have "norm (X i ** Y i) \<le> norm (X i) * norm (Y i) * K"
       
   350       by (rule norm_le)
       
   351     also have "\<dots> \<le> norm (X i) * B * K"
       
   352       by (intro mult_mono' order_refl norm_Y norm_ge_zero
       
   353                 mult_nonneg_nonneg K *)
       
   354     also have "\<dots> = norm (X i) * (B * K)"
       
   355       by (rule mult_assoc)
       
   356     finally show "norm (X i ** Y i) \<le> norm (X i) * (B * K)" .
       
   357   qed
       
   358   with X show ?thesis
       
   359   by (rule Zfun_imp_Zfun)
       
   360 qed
       
   361 
       
   362 lemma (in bounded_bilinear) flip:
       
   363   "bounded_bilinear (\<lambda>x y. y ** x)"
       
   364 apply default
       
   365 apply (rule add_right)
       
   366 apply (rule add_left)
       
   367 apply (rule scaleR_right)
       
   368 apply (rule scaleR_left)
       
   369 apply (subst mult_commute)
       
   370 using bounded by fast
       
   371 
       
   372 lemma (in bounded_bilinear) Bfun_prod_Zfun:
       
   373   assumes X: "Bfun X F"
       
   374   assumes Y: "Zfun Y F"
       
   375   shows "Zfun (\<lambda>n. X n ** Y n) F"
       
   376 using flip Y X by (rule bounded_bilinear.Zfun_prod_Bfun)
       
   377 
       
   378 lemma inverse_diff_inverse:
       
   379   "\<lbrakk>(a::'a::division_ring) \<noteq> 0; b \<noteq> 0\<rbrakk>
       
   380    \<Longrightarrow> inverse a - inverse b = - (inverse a * (a - b) * inverse b)"
       
   381 by (simp add: algebra_simps)
       
   382 
       
   383 lemma Bfun_inverse_lemma:
       
   384   fixes x :: "'a::real_normed_div_algebra"
       
   385   shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
       
   386 apply (subst nonzero_norm_inverse, clarsimp)
       
   387 apply (erule (1) le_imp_inverse_le)
       
   388 done
       
   389 
       
   390 lemma Bfun_inverse:
       
   391   fixes a :: "'a::real_normed_div_algebra"
       
   392   assumes X: "tendsto X a F"
       
   393   assumes a: "a \<noteq> 0"
       
   394   shows "Bfun (\<lambda>n. inverse (X n)) F"
       
   395 proof -
       
   396   from a have "0 < norm a" by simp
       
   397   hence "\<exists>r>0. r < norm a" by (rule dense)
       
   398   then obtain r where r1: "0 < r" and r2: "r < norm a" by fast
       
   399   have "eventually (\<lambda>i. dist (X i) a < r) F"
       
   400     using tendstoD [OF X r1] by fast
       
   401   hence "eventually (\<lambda>i. norm (inverse (X i)) \<le> inverse (norm a - r)) F"
       
   402   proof (rule eventually_elim1)
       
   403     fix i
       
   404     assume "dist (X i) a < r"
       
   405     hence 1: "norm (X i - a) < r"
       
   406       by (simp add: dist_norm)
       
   407     hence 2: "X i \<noteq> 0" using r2 by auto
       
   408     hence "norm (inverse (X i)) = inverse (norm (X i))"
       
   409       by (rule nonzero_norm_inverse)
       
   410     also have "\<dots> \<le> inverse (norm a - r)"
       
   411     proof (rule le_imp_inverse_le)
       
   412       show "0 < norm a - r" using r2 by simp
       
   413     next
       
   414       have "norm a - norm (X i) \<le> norm (a - X i)"
       
   415         by (rule norm_triangle_ineq2)
       
   416       also have "\<dots> = norm (X i - a)"
       
   417         by (rule norm_minus_commute)
       
   418       also have "\<dots> < r" using 1 .
       
   419       finally show "norm a - r \<le> norm (X i)" by simp
       
   420     qed
       
   421     finally show "norm (inverse (X i)) \<le> inverse (norm a - r)" .
       
   422   qed
       
   423   thus ?thesis by (rule BfunI)
       
   424 qed
       
   425 
       
   426 lemma tendsto_inverse_lemma:
       
   427   fixes a :: "'a::real_normed_div_algebra"
       
   428   shows "\<lbrakk>tendsto X a F; a \<noteq> 0; eventually (\<lambda>i. X i \<noteq> 0) F\<rbrakk>
       
   429          \<Longrightarrow> tendsto (\<lambda>i. inverse (X i)) (inverse a) F"
       
   430 apply (subst tendsto_Zfun_iff)
       
   431 apply (rule Zfun_ssubst)
       
   432 apply (erule eventually_elim1)
       
   433 apply (erule (1) inverse_diff_inverse)
       
   434 apply (rule Zfun_minus)
       
   435 apply (rule Zfun_mult_left)
       
   436 apply (rule mult.Bfun_prod_Zfun)
       
   437 apply (erule (1) Bfun_inverse)
       
   438 apply (simp add: tendsto_Zfun_iff)
       
   439 done
       
   440 
       
   441 lemma tendsto_inverse:
       
   442   fixes a :: "'a::real_normed_div_algebra"
       
   443   assumes X: "tendsto X a F"
       
   444   assumes a: "a \<noteq> 0"
       
   445   shows "tendsto (\<lambda>i. inverse (X i)) (inverse a) F"
       
   446 proof -
       
   447   from a have "0 < norm a" by simp
       
   448   with X have "eventually (\<lambda>i. dist (X i) a < norm a) F"
       
   449     by (rule tendstoD)
       
   450   then have "eventually (\<lambda>i. X i \<noteq> 0) F"
       
   451     unfolding dist_norm by (auto elim!: eventually_elim1)
       
   452   with X a show ?thesis
       
   453     by (rule tendsto_inverse_lemma)
       
   454 qed
       
   455 
       
   456 lemma tendsto_divide:
       
   457   fixes a b :: "'a::real_normed_field"
       
   458   shows "\<lbrakk>tendsto X a F; tendsto Y b F; b \<noteq> 0\<rbrakk>
       
   459     \<Longrightarrow> tendsto (\<lambda>n. X n / Y n) (a / b) F"
       
   460 by (simp add: mult.tendsto tendsto_inverse divide_inverse)
       
   461 
   296 end
   462 end