src/HOL/Limits.thy
author hoelzl
Fri Mar 22 10:41:43 2013 +0100 (2013-03-22)
changeset 51474 1e9e68247ad1
parent 51472 adb441e4b9e9
child 51478 270b21f3ae0a
permissions -rw-r--r--
generalize Bfun and Bseq to metric spaces; Bseq is an abbreviation for Bfun
     1 (*  Title       : Limits.thy
     2     Author      : Brian Huffman
     3 *)
     4 
     5 header {* Filters and Limits *}
     6 
     7 theory Limits
     8 imports RealVector
     9 begin
    10 
    11 definition at_infinity :: "'a::real_normed_vector filter" where
    12   "at_infinity = Abs_filter (\<lambda>P. \<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x)"
    13 
    14 lemma eventually_at_infinity:
    15   "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> P x)"
    16 unfolding at_infinity_def
    17 proof (rule eventually_Abs_filter, rule is_filter.intro)
    18   fix P Q :: "'a \<Rightarrow> bool"
    19   assume "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x" and "\<exists>s. \<forall>x. s \<le> norm x \<longrightarrow> Q x"
    20   then obtain r s where
    21     "\<forall>x. r \<le> norm x \<longrightarrow> P x" and "\<forall>x. s \<le> norm x \<longrightarrow> Q x" by auto
    22   then have "\<forall>x. max r s \<le> norm x \<longrightarrow> P x \<and> Q x" by simp
    23   then show "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x \<and> Q x" ..
    24 qed auto
    25 
    26 lemma at_infinity_eq_at_top_bot:
    27   "(at_infinity \<Colon> real filter) = sup at_top at_bot"
    28   unfolding sup_filter_def at_infinity_def eventually_at_top_linorder eventually_at_bot_linorder
    29 proof (intro arg_cong[where f=Abs_filter] ext iffI)
    30   fix P :: "real \<Rightarrow> bool" assume "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x"
    31   then guess r ..
    32   then have "(\<forall>x\<ge>r. P x) \<and> (\<forall>x\<le>-r. P x)" by auto
    33   then show "(\<exists>r. \<forall>x\<ge>r. P x) \<and> (\<exists>r. \<forall>x\<le>r. P x)" by auto
    34 next
    35   fix P :: "real \<Rightarrow> bool" assume "(\<exists>r. \<forall>x\<ge>r. P x) \<and> (\<exists>r. \<forall>x\<le>r. P x)"
    36   then obtain p q where "\<forall>x\<ge>p. P x" "\<forall>x\<le>q. P x" by auto
    37   then show "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x"
    38     by (intro exI[of _ "max p (-q)"])
    39        (auto simp: abs_real_def)
    40 qed
    41 
    42 lemma at_top_le_at_infinity:
    43   "at_top \<le> (at_infinity :: real filter)"
    44   unfolding at_infinity_eq_at_top_bot by simp
    45 
    46 lemma at_bot_le_at_infinity:
    47   "at_bot \<le> (at_infinity :: real filter)"
    48   unfolding at_infinity_eq_at_top_bot by simp
    49 
    50 subsection {* Boundedness *}
    51 
    52 lemma Bfun_def:
    53   "Bfun f F \<longleftrightarrow> (\<exists>K>0. eventually (\<lambda>x. norm (f x) \<le> K) F)"
    54   unfolding Bfun_metric_def norm_conv_dist
    55 proof safe
    56   fix y K assume "0 < K" and *: "eventually (\<lambda>x. dist (f x) y \<le> K) F"
    57   moreover have "eventually (\<lambda>x. dist (f x) 0 \<le> dist (f x) y + dist 0 y) F"
    58     by (intro always_eventually) (metis dist_commute dist_triangle)
    59   with * have "eventually (\<lambda>x. dist (f x) 0 \<le> K + dist 0 y) F"
    60     by eventually_elim auto
    61   with `0 < K` show "\<exists>K>0. eventually (\<lambda>x. dist (f x) 0 \<le> K) F"
    62     by (intro exI[of _ "K + dist 0 y"] add_pos_nonneg conjI zero_le_dist) auto
    63 qed auto
    64 
    65 lemma BfunI:
    66   assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F" shows "Bfun f F"
    67 unfolding Bfun_def
    68 proof (intro exI conjI allI)
    69   show "0 < max K 1" by simp
    70 next
    71   show "eventually (\<lambda>x. norm (f x) \<le> max K 1) F"
    72     using K by (rule eventually_elim1, simp)
    73 qed
    74 
    75 lemma BfunE:
    76   assumes "Bfun f F"
    77   obtains B where "0 < B" and "eventually (\<lambda>x. norm (f x) \<le> B) F"
    78 using assms unfolding Bfun_def by fast
    79 
    80 subsection {* Convergence to Zero *}
    81 
    82 definition Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool"
    83   where "Zfun f F = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) F)"
    84 
    85 lemma ZfunI:
    86   "(\<And>r. 0 < r \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F) \<Longrightarrow> Zfun f F"
    87   unfolding Zfun_def by simp
    88 
    89 lemma ZfunD:
    90   "\<lbrakk>Zfun f F; 0 < r\<rbrakk> \<Longrightarrow> eventually (\<lambda>x. norm (f x) < r) F"
    91   unfolding Zfun_def by simp
    92 
    93 lemma Zfun_ssubst:
    94   "eventually (\<lambda>x. f x = g x) F \<Longrightarrow> Zfun g F \<Longrightarrow> Zfun f F"
    95   unfolding Zfun_def by (auto elim!: eventually_rev_mp)
    96 
    97 lemma Zfun_zero: "Zfun (\<lambda>x. 0) F"
    98   unfolding Zfun_def by simp
    99 
   100 lemma Zfun_norm_iff: "Zfun (\<lambda>x. norm (f x)) F = Zfun (\<lambda>x. f x) F"
   101   unfolding Zfun_def by simp
   102 
   103 lemma Zfun_imp_Zfun:
   104   assumes f: "Zfun f F"
   105   assumes g: "eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F"
   106   shows "Zfun (\<lambda>x. g x) F"
   107 proof (cases)
   108   assume K: "0 < K"
   109   show ?thesis
   110   proof (rule ZfunI)
   111     fix r::real assume "0 < r"
   112     hence "0 < r / K"
   113       using K by (rule divide_pos_pos)
   114     then have "eventually (\<lambda>x. norm (f x) < r / K) F"
   115       using ZfunD [OF f] by fast
   116     with g show "eventually (\<lambda>x. norm (g x) < r) F"
   117     proof eventually_elim
   118       case (elim x)
   119       hence "norm (f x) * K < r"
   120         by (simp add: pos_less_divide_eq K)
   121       thus ?case
   122         by (simp add: order_le_less_trans [OF elim(1)])
   123     qed
   124   qed
   125 next
   126   assume "\<not> 0 < K"
   127   hence K: "K \<le> 0" by (simp only: not_less)
   128   show ?thesis
   129   proof (rule ZfunI)
   130     fix r :: real
   131     assume "0 < r"
   132     from g show "eventually (\<lambda>x. norm (g x) < r) F"
   133     proof eventually_elim
   134       case (elim x)
   135       also have "norm (f x) * K \<le> norm (f x) * 0"
   136         using K norm_ge_zero by (rule mult_left_mono)
   137       finally show ?case
   138         using `0 < r` by simp
   139     qed
   140   qed
   141 qed
   142 
   143 lemma Zfun_le: "\<lbrakk>Zfun g F; \<forall>x. norm (f x) \<le> norm (g x)\<rbrakk> \<Longrightarrow> Zfun f F"
   144   by (erule_tac K="1" in Zfun_imp_Zfun, simp)
   145 
   146 lemma Zfun_add:
   147   assumes f: "Zfun f F" and g: "Zfun g F"
   148   shows "Zfun (\<lambda>x. f x + g x) F"
   149 proof (rule ZfunI)
   150   fix r::real assume "0 < r"
   151   hence r: "0 < r / 2" by simp
   152   have "eventually (\<lambda>x. norm (f x) < r/2) F"
   153     using f r by (rule ZfunD)
   154   moreover
   155   have "eventually (\<lambda>x. norm (g x) < r/2) F"
   156     using g r by (rule ZfunD)
   157   ultimately
   158   show "eventually (\<lambda>x. norm (f x + g x) < r) F"
   159   proof eventually_elim
   160     case (elim x)
   161     have "norm (f x + g x) \<le> norm (f x) + norm (g x)"
   162       by (rule norm_triangle_ineq)
   163     also have "\<dots> < r/2 + r/2"
   164       using elim by (rule add_strict_mono)
   165     finally show ?case
   166       by simp
   167   qed
   168 qed
   169 
   170 lemma Zfun_minus: "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. - f x) F"
   171   unfolding Zfun_def by simp
   172 
   173 lemma Zfun_diff: "\<lbrakk>Zfun f F; Zfun g F\<rbrakk> \<Longrightarrow> Zfun (\<lambda>x. f x - g x) F"
   174   by (simp only: diff_minus Zfun_add Zfun_minus)
   175 
   176 lemma (in bounded_linear) Zfun:
   177   assumes g: "Zfun g F"
   178   shows "Zfun (\<lambda>x. f (g x)) F"
   179 proof -
   180   obtain K where "\<And>x. norm (f x) \<le> norm x * K"
   181     using bounded by fast
   182   then have "eventually (\<lambda>x. norm (f (g x)) \<le> norm (g x) * K) F"
   183     by simp
   184   with g show ?thesis
   185     by (rule Zfun_imp_Zfun)
   186 qed
   187 
   188 lemma (in bounded_bilinear) Zfun:
   189   assumes f: "Zfun f F"
   190   assumes g: "Zfun g F"
   191   shows "Zfun (\<lambda>x. f x ** g x) F"
   192 proof (rule ZfunI)
   193   fix r::real assume r: "0 < r"
   194   obtain K where K: "0 < K"
   195     and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
   196     using pos_bounded by fast
   197   from K have K': "0 < inverse K"
   198     by (rule positive_imp_inverse_positive)
   199   have "eventually (\<lambda>x. norm (f x) < r) F"
   200     using f r by (rule ZfunD)
   201   moreover
   202   have "eventually (\<lambda>x. norm (g x) < inverse K) F"
   203     using g K' by (rule ZfunD)
   204   ultimately
   205   show "eventually (\<lambda>x. norm (f x ** g x) < r) F"
   206   proof eventually_elim
   207     case (elim x)
   208     have "norm (f x ** g x) \<le> norm (f x) * norm (g x) * K"
   209       by (rule norm_le)
   210     also have "norm (f x) * norm (g x) * K < r * inverse K * K"
   211       by (intro mult_strict_right_mono mult_strict_mono' norm_ge_zero elim K)
   212     also from K have "r * inverse K * K = r"
   213       by simp
   214     finally show ?case .
   215   qed
   216 qed
   217 
   218 lemma (in bounded_bilinear) Zfun_left:
   219   "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. f x ** a) F"
   220   by (rule bounded_linear_left [THEN bounded_linear.Zfun])
   221 
   222 lemma (in bounded_bilinear) Zfun_right:
   223   "Zfun f F \<Longrightarrow> Zfun (\<lambda>x. a ** f x) F"
   224   by (rule bounded_linear_right [THEN bounded_linear.Zfun])
   225 
   226 lemmas Zfun_mult = bounded_bilinear.Zfun [OF bounded_bilinear_mult]
   227 lemmas Zfun_mult_right = bounded_bilinear.Zfun_right [OF bounded_bilinear_mult]
   228 lemmas Zfun_mult_left = bounded_bilinear.Zfun_left [OF bounded_bilinear_mult]
   229 
   230 lemma tendsto_Zfun_iff: "(f ---> a) F = Zfun (\<lambda>x. f x - a) F"
   231   by (simp only: tendsto_iff Zfun_def dist_norm)
   232 
   233 subsubsection {* Distance and norms *}
   234 
   235 lemma tendsto_norm [tendsto_intros]:
   236   "(f ---> a) F \<Longrightarrow> ((\<lambda>x. norm (f x)) ---> norm a) F"
   237   unfolding norm_conv_dist by (intro tendsto_intros)
   238 
   239 lemma tendsto_norm_zero:
   240   "(f ---> 0) F \<Longrightarrow> ((\<lambda>x. norm (f x)) ---> 0) F"
   241   by (drule tendsto_norm, simp)
   242 
   243 lemma tendsto_norm_zero_cancel:
   244   "((\<lambda>x. norm (f x)) ---> 0) F \<Longrightarrow> (f ---> 0) F"
   245   unfolding tendsto_iff dist_norm by simp
   246 
   247 lemma tendsto_norm_zero_iff:
   248   "((\<lambda>x. norm (f x)) ---> 0) F \<longleftrightarrow> (f ---> 0) F"
   249   unfolding tendsto_iff dist_norm by simp
   250 
   251 lemma tendsto_rabs [tendsto_intros]:
   252   "(f ---> (l::real)) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) ---> \<bar>l\<bar>) F"
   253   by (fold real_norm_def, rule tendsto_norm)
   254 
   255 lemma tendsto_rabs_zero:
   256   "(f ---> (0::real)) F \<Longrightarrow> ((\<lambda>x. \<bar>f x\<bar>) ---> 0) F"
   257   by (fold real_norm_def, rule tendsto_norm_zero)
   258 
   259 lemma tendsto_rabs_zero_cancel:
   260   "((\<lambda>x. \<bar>f x\<bar>) ---> (0::real)) F \<Longrightarrow> (f ---> 0) F"
   261   by (fold real_norm_def, rule tendsto_norm_zero_cancel)
   262 
   263 lemma tendsto_rabs_zero_iff:
   264   "((\<lambda>x. \<bar>f x\<bar>) ---> (0::real)) F \<longleftrightarrow> (f ---> 0) F"
   265   by (fold real_norm_def, rule tendsto_norm_zero_iff)
   266 
   267 subsubsection {* Addition and subtraction *}
   268 
   269 lemma tendsto_add [tendsto_intros]:
   270   fixes a b :: "'a::real_normed_vector"
   271   shows "\<lbrakk>(f ---> a) F; (g ---> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x + g x) ---> a + b) F"
   272   by (simp only: tendsto_Zfun_iff add_diff_add Zfun_add)
   273 
   274 lemma tendsto_add_zero:
   275   fixes f g :: "'a::type \<Rightarrow> 'b::real_normed_vector"
   276   shows "\<lbrakk>(f ---> 0) F; (g ---> 0) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x + g x) ---> 0) F"
   277   by (drule (1) tendsto_add, simp)
   278 
   279 lemma tendsto_minus [tendsto_intros]:
   280   fixes a :: "'a::real_normed_vector"
   281   shows "(f ---> a) F \<Longrightarrow> ((\<lambda>x. - f x) ---> - a) F"
   282   by (simp only: tendsto_Zfun_iff minus_diff_minus Zfun_minus)
   283 
   284 lemma tendsto_minus_cancel:
   285   fixes a :: "'a::real_normed_vector"
   286   shows "((\<lambda>x. - f x) ---> - a) F \<Longrightarrow> (f ---> a) F"
   287   by (drule tendsto_minus, simp)
   288 
   289 lemma tendsto_minus_cancel_left:
   290     "(f ---> - (y::_::real_normed_vector)) F \<longleftrightarrow> ((\<lambda>x. - f x) ---> y) F"
   291   using tendsto_minus_cancel[of f "- y" F]  tendsto_minus[of f "- y" F]
   292   by auto
   293 
   294 lemma tendsto_diff [tendsto_intros]:
   295   fixes a b :: "'a::real_normed_vector"
   296   shows "\<lbrakk>(f ---> a) F; (g ---> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x - g x) ---> a - b) F"
   297   by (simp add: diff_minus tendsto_add tendsto_minus)
   298 
   299 lemma tendsto_setsum [tendsto_intros]:
   300   fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> 'c::real_normed_vector"
   301   assumes "\<And>i. i \<in> S \<Longrightarrow> (f i ---> a i) F"
   302   shows "((\<lambda>x. \<Sum>i\<in>S. f i x) ---> (\<Sum>i\<in>S. a i)) F"
   303 proof (cases "finite S")
   304   assume "finite S" thus ?thesis using assms
   305     by (induct, simp add: tendsto_const, simp add: tendsto_add)
   306 next
   307   assume "\<not> finite S" thus ?thesis
   308     by (simp add: tendsto_const)
   309 qed
   310 
   311 lemmas real_tendsto_sandwich = tendsto_sandwich[where 'b=real]
   312 
   313 subsubsection {* Linear operators and multiplication *}
   314 
   315 lemma (in bounded_linear) tendsto:
   316   "(g ---> a) F \<Longrightarrow> ((\<lambda>x. f (g x)) ---> f a) F"
   317   by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun)
   318 
   319 lemma (in bounded_linear) tendsto_zero:
   320   "(g ---> 0) F \<Longrightarrow> ((\<lambda>x. f (g x)) ---> 0) F"
   321   by (drule tendsto, simp only: zero)
   322 
   323 lemma (in bounded_bilinear) tendsto:
   324   "\<lbrakk>(f ---> a) F; (g ---> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x ** g x) ---> a ** b) F"
   325   by (simp only: tendsto_Zfun_iff prod_diff_prod
   326                  Zfun_add Zfun Zfun_left Zfun_right)
   327 
   328 lemma (in bounded_bilinear) tendsto_zero:
   329   assumes f: "(f ---> 0) F"
   330   assumes g: "(g ---> 0) F"
   331   shows "((\<lambda>x. f x ** g x) ---> 0) F"
   332   using tendsto [OF f g] by (simp add: zero_left)
   333 
   334 lemma (in bounded_bilinear) tendsto_left_zero:
   335   "(f ---> 0) F \<Longrightarrow> ((\<lambda>x. f x ** c) ---> 0) F"
   336   by (rule bounded_linear.tendsto_zero [OF bounded_linear_left])
   337 
   338 lemma (in bounded_bilinear) tendsto_right_zero:
   339   "(f ---> 0) F \<Longrightarrow> ((\<lambda>x. c ** f x) ---> 0) F"
   340   by (rule bounded_linear.tendsto_zero [OF bounded_linear_right])
   341 
   342 lemmas tendsto_of_real [tendsto_intros] =
   343   bounded_linear.tendsto [OF bounded_linear_of_real]
   344 
   345 lemmas tendsto_scaleR [tendsto_intros] =
   346   bounded_bilinear.tendsto [OF bounded_bilinear_scaleR]
   347 
   348 lemmas tendsto_mult [tendsto_intros] =
   349   bounded_bilinear.tendsto [OF bounded_bilinear_mult]
   350 
   351 lemmas tendsto_mult_zero =
   352   bounded_bilinear.tendsto_zero [OF bounded_bilinear_mult]
   353 
   354 lemmas tendsto_mult_left_zero =
   355   bounded_bilinear.tendsto_left_zero [OF bounded_bilinear_mult]
   356 
   357 lemmas tendsto_mult_right_zero =
   358   bounded_bilinear.tendsto_right_zero [OF bounded_bilinear_mult]
   359 
   360 lemma tendsto_power [tendsto_intros]:
   361   fixes f :: "'a \<Rightarrow> 'b::{power,real_normed_algebra}"
   362   shows "(f ---> a) F \<Longrightarrow> ((\<lambda>x. f x ^ n) ---> a ^ n) F"
   363   by (induct n) (simp_all add: tendsto_const tendsto_mult)
   364 
   365 lemma tendsto_setprod [tendsto_intros]:
   366   fixes f :: "'a \<Rightarrow> 'b \<Rightarrow> 'c::{real_normed_algebra,comm_ring_1}"
   367   assumes "\<And>i. i \<in> S \<Longrightarrow> (f i ---> L i) F"
   368   shows "((\<lambda>x. \<Prod>i\<in>S. f i x) ---> (\<Prod>i\<in>S. L i)) F"
   369 proof (cases "finite S")
   370   assume "finite S" thus ?thesis using assms
   371     by (induct, simp add: tendsto_const, simp add: tendsto_mult)
   372 next
   373   assume "\<not> finite S" thus ?thesis
   374     by (simp add: tendsto_const)
   375 qed
   376 
   377 subsubsection {* Inverse and division *}
   378 
   379 lemma (in bounded_bilinear) Zfun_prod_Bfun:
   380   assumes f: "Zfun f F"
   381   assumes g: "Bfun g F"
   382   shows "Zfun (\<lambda>x. f x ** g x) F"
   383 proof -
   384   obtain K where K: "0 \<le> K"
   385     and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
   386     using nonneg_bounded by fast
   387   obtain B where B: "0 < B"
   388     and norm_g: "eventually (\<lambda>x. norm (g x) \<le> B) F"
   389     using g by (rule BfunE)
   390   have "eventually (\<lambda>x. norm (f x ** g x) \<le> norm (f x) * (B * K)) F"
   391   using norm_g proof eventually_elim
   392     case (elim x)
   393     have "norm (f x ** g x) \<le> norm (f x) * norm (g x) * K"
   394       by (rule norm_le)
   395     also have "\<dots> \<le> norm (f x) * B * K"
   396       by (intro mult_mono' order_refl norm_g norm_ge_zero
   397                 mult_nonneg_nonneg K elim)
   398     also have "\<dots> = norm (f x) * (B * K)"
   399       by (rule mult_assoc)
   400     finally show "norm (f x ** g x) \<le> norm (f x) * (B * K)" .
   401   qed
   402   with f show ?thesis
   403     by (rule Zfun_imp_Zfun)
   404 qed
   405 
   406 lemma (in bounded_bilinear) flip:
   407   "bounded_bilinear (\<lambda>x y. y ** x)"
   408   apply default
   409   apply (rule add_right)
   410   apply (rule add_left)
   411   apply (rule scaleR_right)
   412   apply (rule scaleR_left)
   413   apply (subst mult_commute)
   414   using bounded by fast
   415 
   416 lemma (in bounded_bilinear) Bfun_prod_Zfun:
   417   assumes f: "Bfun f F"
   418   assumes g: "Zfun g F"
   419   shows "Zfun (\<lambda>x. f x ** g x) F"
   420   using flip g f by (rule bounded_bilinear.Zfun_prod_Bfun)
   421 
   422 lemma Bfun_inverse_lemma:
   423   fixes x :: "'a::real_normed_div_algebra"
   424   shows "\<lbrakk>r \<le> norm x; 0 < r\<rbrakk> \<Longrightarrow> norm (inverse x) \<le> inverse r"
   425   apply (subst nonzero_norm_inverse, clarsimp)
   426   apply (erule (1) le_imp_inverse_le)
   427   done
   428 
   429 lemma Bfun_inverse:
   430   fixes a :: "'a::real_normed_div_algebra"
   431   assumes f: "(f ---> a) F"
   432   assumes a: "a \<noteq> 0"
   433   shows "Bfun (\<lambda>x. inverse (f x)) F"
   434 proof -
   435   from a have "0 < norm a" by simp
   436   hence "\<exists>r>0. r < norm a" by (rule dense)
   437   then obtain r where r1: "0 < r" and r2: "r < norm a" by fast
   438   have "eventually (\<lambda>x. dist (f x) a < r) F"
   439     using tendstoD [OF f r1] by fast
   440   hence "eventually (\<lambda>x. norm (inverse (f x)) \<le> inverse (norm a - r)) F"
   441   proof eventually_elim
   442     case (elim x)
   443     hence 1: "norm (f x - a) < r"
   444       by (simp add: dist_norm)
   445     hence 2: "f x \<noteq> 0" using r2 by auto
   446     hence "norm (inverse (f x)) = inverse (norm (f x))"
   447       by (rule nonzero_norm_inverse)
   448     also have "\<dots> \<le> inverse (norm a - r)"
   449     proof (rule le_imp_inverse_le)
   450       show "0 < norm a - r" using r2 by simp
   451     next
   452       have "norm a - norm (f x) \<le> norm (a - f x)"
   453         by (rule norm_triangle_ineq2)
   454       also have "\<dots> = norm (f x - a)"
   455         by (rule norm_minus_commute)
   456       also have "\<dots> < r" using 1 .
   457       finally show "norm a - r \<le> norm (f x)" by simp
   458     qed
   459     finally show "norm (inverse (f x)) \<le> inverse (norm a - r)" .
   460   qed
   461   thus ?thesis by (rule BfunI)
   462 qed
   463 
   464 lemma tendsto_inverse [tendsto_intros]:
   465   fixes a :: "'a::real_normed_div_algebra"
   466   assumes f: "(f ---> a) F"
   467   assumes a: "a \<noteq> 0"
   468   shows "((\<lambda>x. inverse (f x)) ---> inverse a) F"
   469 proof -
   470   from a have "0 < norm a" by simp
   471   with f have "eventually (\<lambda>x. dist (f x) a < norm a) F"
   472     by (rule tendstoD)
   473   then have "eventually (\<lambda>x. f x \<noteq> 0) F"
   474     unfolding dist_norm by (auto elim!: eventually_elim1)
   475   with a have "eventually (\<lambda>x. inverse (f x) - inverse a =
   476     - (inverse (f x) * (f x - a) * inverse a)) F"
   477     by (auto elim!: eventually_elim1 simp: inverse_diff_inverse)
   478   moreover have "Zfun (\<lambda>x. - (inverse (f x) * (f x - a) * inverse a)) F"
   479     by (intro Zfun_minus Zfun_mult_left
   480       bounded_bilinear.Bfun_prod_Zfun [OF bounded_bilinear_mult]
   481       Bfun_inverse [OF f a] f [unfolded tendsto_Zfun_iff])
   482   ultimately show ?thesis
   483     unfolding tendsto_Zfun_iff by (rule Zfun_ssubst)
   484 qed
   485 
   486 lemma tendsto_divide [tendsto_intros]:
   487   fixes a b :: "'a::real_normed_field"
   488   shows "\<lbrakk>(f ---> a) F; (g ---> b) F; b \<noteq> 0\<rbrakk>
   489     \<Longrightarrow> ((\<lambda>x. f x / g x) ---> a / b) F"
   490   by (simp add: tendsto_mult tendsto_inverse divide_inverse)
   491 
   492 lemma tendsto_sgn [tendsto_intros]:
   493   fixes l :: "'a::real_normed_vector"
   494   shows "\<lbrakk>(f ---> l) F; l \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. sgn (f x)) ---> sgn l) F"
   495   unfolding sgn_div_norm by (simp add: tendsto_intros)
   496 
   497 lemma filterlim_at_infinity:
   498   fixes f :: "_ \<Rightarrow> 'a\<Colon>real_normed_vector"
   499   assumes "0 \<le> c"
   500   shows "(LIM x F. f x :> at_infinity) \<longleftrightarrow> (\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F)"
   501   unfolding filterlim_iff eventually_at_infinity
   502 proof safe
   503   fix P :: "'a \<Rightarrow> bool" and b
   504   assume *: "\<forall>r>c. eventually (\<lambda>x. r \<le> norm (f x)) F"
   505     and P: "\<forall>x. b \<le> norm x \<longrightarrow> P x"
   506   have "max b (c + 1) > c" by auto
   507   with * have "eventually (\<lambda>x. max b (c + 1) \<le> norm (f x)) F"
   508     by auto
   509   then show "eventually (\<lambda>x. P (f x)) F"
   510   proof eventually_elim
   511     fix x assume "max b (c + 1) \<le> norm (f x)"
   512     with P show "P (f x)" by auto
   513   qed
   514 qed force
   515 
   516 subsection {* Relate @{const at}, @{const at_left} and @{const at_right} *}
   517 
   518 text {*
   519 
   520 This lemmas are useful for conversion between @{term "at x"} to @{term "at_left x"} and
   521 @{term "at_right x"} and also @{term "at_right 0"}.
   522 
   523 *}
   524 
   525 lemmas filterlim_split_at_real = filterlim_split_at[where 'a=real]
   526 
   527 lemma filtermap_nhds_shift: "filtermap (\<lambda>x. x - d) (nhds a) = nhds (a - d::real)"
   528   unfolding filter_eq_iff eventually_filtermap eventually_nhds_metric
   529   by (intro allI ex_cong) (auto simp: dist_real_def field_simps)
   530 
   531 lemma filtermap_nhds_minus: "filtermap (\<lambda>x. - x) (nhds a) = nhds (- a::real)"
   532   unfolding filter_eq_iff eventually_filtermap eventually_nhds_metric
   533   apply (intro allI ex_cong)
   534   apply (auto simp: dist_real_def field_simps)
   535   apply (erule_tac x="-x" in allE)
   536   apply simp
   537   done
   538 
   539 lemma filtermap_at_shift: "filtermap (\<lambda>x. x - d) (at a) = at (a - d::real)"
   540   unfolding at_def filtermap_nhds_shift[symmetric]
   541   by (simp add: filter_eq_iff eventually_filtermap eventually_within)
   542 
   543 lemma filtermap_at_right_shift: "filtermap (\<lambda>x. x - d) (at_right a) = at_right (a - d::real)"
   544   unfolding filtermap_at_shift[symmetric]
   545   by (simp add: filter_eq_iff eventually_filtermap eventually_within)
   546 
   547 lemma at_right_to_0: "at_right (a::real) = filtermap (\<lambda>x. x + a) (at_right 0)"
   548   using filtermap_at_right_shift[of "-a" 0] by simp
   549 
   550 lemma filterlim_at_right_to_0:
   551   "filterlim f F (at_right (a::real)) \<longleftrightarrow> filterlim (\<lambda>x. f (x + a)) F (at_right 0)"
   552   unfolding filterlim_def filtermap_filtermap at_right_to_0[of a] ..
   553 
   554 lemma eventually_at_right_to_0:
   555   "eventually P (at_right (a::real)) \<longleftrightarrow> eventually (\<lambda>x. P (x + a)) (at_right 0)"
   556   unfolding at_right_to_0[of a] by (simp add: eventually_filtermap)
   557 
   558 lemma filtermap_at_minus: "filtermap (\<lambda>x. - x) (at a) = at (- a::real)"
   559   unfolding at_def filtermap_nhds_minus[symmetric]
   560   by (simp add: filter_eq_iff eventually_filtermap eventually_within)
   561 
   562 lemma at_left_minus: "at_left (a::real) = filtermap (\<lambda>x. - x) (at_right (- a))"
   563   by (simp add: filter_eq_iff eventually_filtermap eventually_within filtermap_at_minus[symmetric])
   564 
   565 lemma at_right_minus: "at_right (a::real) = filtermap (\<lambda>x. - x) (at_left (- a))"
   566   by (simp add: filter_eq_iff eventually_filtermap eventually_within filtermap_at_minus[symmetric])
   567 
   568 lemma filterlim_at_left_to_right:
   569   "filterlim f F (at_left (a::real)) \<longleftrightarrow> filterlim (\<lambda>x. f (- x)) F (at_right (-a))"
   570   unfolding filterlim_def filtermap_filtermap at_left_minus[of a] ..
   571 
   572 lemma eventually_at_left_to_right:
   573   "eventually P (at_left (a::real)) \<longleftrightarrow> eventually (\<lambda>x. P (- x)) (at_right (-a))"
   574   unfolding at_left_minus[of a] by (simp add: eventually_filtermap)
   575 
   576 lemma at_top_mirror: "at_top = filtermap uminus (at_bot :: real filter)"
   577   unfolding filter_eq_iff eventually_filtermap eventually_at_top_linorder eventually_at_bot_linorder
   578   by (metis le_minus_iff minus_minus)
   579 
   580 lemma at_bot_mirror: "at_bot = filtermap uminus (at_top :: real filter)"
   581   unfolding at_top_mirror filtermap_filtermap by (simp add: filtermap_ident)
   582 
   583 lemma filterlim_at_top_mirror: "(LIM x at_top. f x :> F) \<longleftrightarrow> (LIM x at_bot. f (-x::real) :> F)"
   584   unfolding filterlim_def at_top_mirror filtermap_filtermap ..
   585 
   586 lemma filterlim_at_bot_mirror: "(LIM x at_bot. f x :> F) \<longleftrightarrow> (LIM x at_top. f (-x::real) :> F)"
   587   unfolding filterlim_def at_bot_mirror filtermap_filtermap ..
   588 
   589 lemma filterlim_uminus_at_top_at_bot: "LIM x at_bot. - x :: real :> at_top"
   590   unfolding filterlim_at_top eventually_at_bot_dense
   591   by (metis leI minus_less_iff order_less_asym)
   592 
   593 lemma filterlim_uminus_at_bot_at_top: "LIM x at_top. - x :: real :> at_bot"
   594   unfolding filterlim_at_bot eventually_at_top_dense
   595   by (metis leI less_minus_iff order_less_asym)
   596 
   597 lemma filterlim_uminus_at_top: "(LIM x F. f x :> at_top) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_bot)"
   598   using filterlim_compose[OF filterlim_uminus_at_bot_at_top, of f F]
   599   using filterlim_compose[OF filterlim_uminus_at_top_at_bot, of "\<lambda>x. - f x" F]
   600   by auto
   601 
   602 lemma filterlim_uminus_at_bot: "(LIM x F. f x :> at_bot) \<longleftrightarrow> (LIM x F. - (f x) :: real :> at_top)"
   603   unfolding filterlim_uminus_at_top by simp
   604 
   605 lemma filterlim_inverse_at_top_right: "LIM x at_right (0::real). inverse x :> at_top"
   606   unfolding filterlim_at_top_gt[where c=0] eventually_within at_def
   607 proof safe
   608   fix Z :: real assume [arith]: "0 < Z"
   609   then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
   610     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
   611   then show "eventually (\<lambda>x. x \<in> - {0} \<longrightarrow> x \<in> {0<..} \<longrightarrow> Z \<le> inverse x) (nhds 0)"
   612     by (auto elim!: eventually_elim1 simp: inverse_eq_divide field_simps)
   613 qed
   614 
   615 lemma filterlim_inverse_at_top:
   616   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. 0 < f x) F \<Longrightarrow> LIM x F. inverse (f x) :> at_top"
   617   by (intro filterlim_compose[OF filterlim_inverse_at_top_right])
   618      (simp add: filterlim_def eventually_filtermap le_within_iff at_def eventually_elim1)
   619 
   620 lemma filterlim_inverse_at_bot_neg:
   621   "LIM x (at_left (0::real)). inverse x :> at_bot"
   622   by (simp add: filterlim_inverse_at_top_right filterlim_uminus_at_bot filterlim_at_left_to_right)
   623 
   624 lemma filterlim_inverse_at_bot:
   625   "(f ---> (0 :: real)) F \<Longrightarrow> eventually (\<lambda>x. f x < 0) F \<Longrightarrow> LIM x F. inverse (f x) :> at_bot"
   626   unfolding filterlim_uminus_at_bot inverse_minus_eq[symmetric]
   627   by (rule filterlim_inverse_at_top) (simp_all add: tendsto_minus_cancel_left[symmetric])
   628 
   629 lemma tendsto_inverse_0:
   630   fixes x :: "_ \<Rightarrow> 'a\<Colon>real_normed_div_algebra"
   631   shows "(inverse ---> (0::'a)) at_infinity"
   632   unfolding tendsto_Zfun_iff diff_0_right Zfun_def eventually_at_infinity
   633 proof safe
   634   fix r :: real assume "0 < r"
   635   show "\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> norm (inverse x :: 'a) < r"
   636   proof (intro exI[of _ "inverse (r / 2)"] allI impI)
   637     fix x :: 'a
   638     from `0 < r` have "0 < inverse (r / 2)" by simp
   639     also assume *: "inverse (r / 2) \<le> norm x"
   640     finally show "norm (inverse x) < r"
   641       using * `0 < r` by (subst nonzero_norm_inverse) (simp_all add: inverse_eq_divide field_simps)
   642   qed
   643 qed
   644 
   645 lemma at_right_to_top: "(at_right (0::real)) = filtermap inverse at_top"
   646 proof (rule antisym)
   647   have "(inverse ---> (0::real)) at_top"
   648     by (metis tendsto_inverse_0 filterlim_mono at_top_le_at_infinity order_refl)
   649   then show "filtermap inverse at_top \<le> at_right (0::real)"
   650     unfolding at_within_eq
   651     by (intro le_withinI) (simp_all add: eventually_filtermap eventually_gt_at_top filterlim_def)
   652 next
   653   have "filtermap inverse (filtermap inverse (at_right (0::real))) \<le> filtermap inverse at_top"
   654     using filterlim_inverse_at_top_right unfolding filterlim_def by (rule filtermap_mono)
   655   then show "at_right (0::real) \<le> filtermap inverse at_top"
   656     by (simp add: filtermap_ident filtermap_filtermap)
   657 qed
   658 
   659 lemma eventually_at_right_to_top:
   660   "eventually P (at_right (0::real)) \<longleftrightarrow> eventually (\<lambda>x. P (inverse x)) at_top"
   661   unfolding at_right_to_top eventually_filtermap ..
   662 
   663 lemma filterlim_at_right_to_top:
   664   "filterlim f F (at_right (0::real)) \<longleftrightarrow> (LIM x at_top. f (inverse x) :> F)"
   665   unfolding filterlim_def at_right_to_top filtermap_filtermap ..
   666 
   667 lemma at_top_to_right: "at_top = filtermap inverse (at_right (0::real))"
   668   unfolding at_right_to_top filtermap_filtermap inverse_inverse_eq filtermap_ident ..
   669 
   670 lemma eventually_at_top_to_right:
   671   "eventually P at_top \<longleftrightarrow> eventually (\<lambda>x. P (inverse x)) (at_right (0::real))"
   672   unfolding at_top_to_right eventually_filtermap ..
   673 
   674 lemma filterlim_at_top_to_right:
   675   "filterlim f F at_top \<longleftrightarrow> (LIM x (at_right (0::real)). f (inverse x) :> F)"
   676   unfolding filterlim_def at_top_to_right filtermap_filtermap ..
   677 
   678 lemma filterlim_inverse_at_infinity:
   679   fixes x :: "_ \<Rightarrow> 'a\<Colon>{real_normed_div_algebra, division_ring_inverse_zero}"
   680   shows "filterlim inverse at_infinity (at (0::'a))"
   681   unfolding filterlim_at_infinity[OF order_refl]
   682 proof safe
   683   fix r :: real assume "0 < r"
   684   then show "eventually (\<lambda>x::'a. r \<le> norm (inverse x)) (at 0)"
   685     unfolding eventually_at norm_inverse
   686     by (intro exI[of _ "inverse r"])
   687        (auto simp: norm_conv_dist[symmetric] field_simps inverse_eq_divide)
   688 qed
   689 
   690 lemma filterlim_inverse_at_iff:
   691   fixes g :: "'a \<Rightarrow> 'b\<Colon>{real_normed_div_algebra, division_ring_inverse_zero}"
   692   shows "(LIM x F. inverse (g x) :> at 0) \<longleftrightarrow> (LIM x F. g x :> at_infinity)"
   693   unfolding filterlim_def filtermap_filtermap[symmetric]
   694 proof
   695   assume "filtermap g F \<le> at_infinity"
   696   then have "filtermap inverse (filtermap g F) \<le> filtermap inverse at_infinity"
   697     by (rule filtermap_mono)
   698   also have "\<dots> \<le> at 0"
   699     using tendsto_inverse_0
   700     by (auto intro!: le_withinI exI[of _ 1]
   701              simp: eventually_filtermap eventually_at_infinity filterlim_def at_def)
   702   finally show "filtermap inverse (filtermap g F) \<le> at 0" .
   703 next
   704   assume "filtermap inverse (filtermap g F) \<le> at 0"
   705   then have "filtermap inverse (filtermap inverse (filtermap g F)) \<le> filtermap inverse (at 0)"
   706     by (rule filtermap_mono)
   707   with filterlim_inverse_at_infinity show "filtermap g F \<le> at_infinity"
   708     by (auto intro: order_trans simp: filterlim_def filtermap_filtermap)
   709 qed
   710 
   711 lemma tendsto_inverse_0_at_top:
   712   "LIM x F. f x :> at_top \<Longrightarrow> ((\<lambda>x. inverse (f x) :: real) ---> 0) F"
   713  by (metis at_top_le_at_infinity filterlim_at filterlim_inverse_at_iff filterlim_mono order_refl)
   714 
   715 text {*
   716 
   717 We only show rules for multiplication and addition when the functions are either against a real
   718 value or against infinity. Further rules are easy to derive by using @{thm filterlim_uminus_at_top}.
   719 
   720 *}
   721 
   722 lemma filterlim_tendsto_pos_mult_at_top: 
   723   assumes f: "(f ---> c) F" and c: "0 < c"
   724   assumes g: "LIM x F. g x :> at_top"
   725   shows "LIM x F. (f x * g x :: real) :> at_top"
   726   unfolding filterlim_at_top_gt[where c=0]
   727 proof safe
   728   fix Z :: real assume "0 < Z"
   729   from f `0 < c` have "eventually (\<lambda>x. c / 2 < f x) F"
   730     by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_elim1
   731              simp: dist_real_def abs_real_def split: split_if_asm)
   732   moreover from g have "eventually (\<lambda>x. (Z / c * 2) \<le> g x) F"
   733     unfolding filterlim_at_top by auto
   734   ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
   735   proof eventually_elim
   736     fix x assume "c / 2 < f x" "Z / c * 2 \<le> g x"
   737     with `0 < Z` `0 < c` have "c / 2 * (Z / c * 2) \<le> f x * g x"
   738       by (intro mult_mono) (auto simp: zero_le_divide_iff)
   739     with `0 < c` show "Z \<le> f x * g x"
   740        by simp
   741   qed
   742 qed
   743 
   744 lemma filterlim_at_top_mult_at_top: 
   745   assumes f: "LIM x F. f x :> at_top"
   746   assumes g: "LIM x F. g x :> at_top"
   747   shows "LIM x F. (f x * g x :: real) :> at_top"
   748   unfolding filterlim_at_top_gt[where c=0]
   749 proof safe
   750   fix Z :: real assume "0 < Z"
   751   from f have "eventually (\<lambda>x. 1 \<le> f x) F"
   752     unfolding filterlim_at_top by auto
   753   moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
   754     unfolding filterlim_at_top by auto
   755   ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F"
   756   proof eventually_elim
   757     fix x assume "1 \<le> f x" "Z \<le> g x"
   758     with `0 < Z` have "1 * Z \<le> f x * g x"
   759       by (intro mult_mono) (auto simp: zero_le_divide_iff)
   760     then show "Z \<le> f x * g x"
   761        by simp
   762   qed
   763 qed
   764 
   765 lemma filterlim_tendsto_pos_mult_at_bot:
   766   assumes "(f ---> c) F" "0 < (c::real)" "filterlim g at_bot F"
   767   shows "LIM x F. f x * g x :> at_bot"
   768   using filterlim_tendsto_pos_mult_at_top[OF assms(1,2), of "\<lambda>x. - g x"] assms(3)
   769   unfolding filterlim_uminus_at_bot by simp
   770 
   771 lemma filterlim_tendsto_add_at_top: 
   772   assumes f: "(f ---> c) F"
   773   assumes g: "LIM x F. g x :> at_top"
   774   shows "LIM x F. (f x + g x :: real) :> at_top"
   775   unfolding filterlim_at_top_gt[where c=0]
   776 proof safe
   777   fix Z :: real assume "0 < Z"
   778   from f have "eventually (\<lambda>x. c - 1 < f x) F"
   779     by (auto dest!: tendstoD[where e=1] elim!: eventually_elim1 simp: dist_real_def)
   780   moreover from g have "eventually (\<lambda>x. Z - (c - 1) \<le> g x) F"
   781     unfolding filterlim_at_top by auto
   782   ultimately show "eventually (\<lambda>x. Z \<le> f x + g x) F"
   783     by eventually_elim simp
   784 qed
   785 
   786 lemma LIM_at_top_divide:
   787   fixes f g :: "'a \<Rightarrow> real"
   788   assumes f: "(f ---> a) F" "0 < a"
   789   assumes g: "(g ---> 0) F" "eventually (\<lambda>x. 0 < g x) F"
   790   shows "LIM x F. f x / g x :> at_top"
   791   unfolding divide_inverse
   792   by (rule filterlim_tendsto_pos_mult_at_top[OF f]) (rule filterlim_inverse_at_top[OF g])
   793 
   794 lemma filterlim_at_top_add_at_top: 
   795   assumes f: "LIM x F. f x :> at_top"
   796   assumes g: "LIM x F. g x :> at_top"
   797   shows "LIM x F. (f x + g x :: real) :> at_top"
   798   unfolding filterlim_at_top_gt[where c=0]
   799 proof safe
   800   fix Z :: real assume "0 < Z"
   801   from f have "eventually (\<lambda>x. 0 \<le> f x) F"
   802     unfolding filterlim_at_top by auto
   803   moreover from g have "eventually (\<lambda>x. Z \<le> g x) F"
   804     unfolding filterlim_at_top by auto
   805   ultimately show "eventually (\<lambda>x. Z \<le> f x + g x) F"
   806     by eventually_elim simp
   807 qed
   808 
   809 lemma tendsto_divide_0:
   810   fixes f :: "_ \<Rightarrow> 'a\<Colon>{real_normed_div_algebra, division_ring_inverse_zero}"
   811   assumes f: "(f ---> c) F"
   812   assumes g: "LIM x F. g x :> at_infinity"
   813   shows "((\<lambda>x. f x / g x) ---> 0) F"
   814   using tendsto_mult[OF f filterlim_compose[OF tendsto_inverse_0 g]] by (simp add: divide_inverse)
   815 
   816 lemma linear_plus_1_le_power:
   817   fixes x :: real
   818   assumes x: "0 \<le> x"
   819   shows "real n * x + 1 \<le> (x + 1) ^ n"
   820 proof (induct n)
   821   case (Suc n)
   822   have "real (Suc n) * x + 1 \<le> (x + 1) * (real n * x + 1)"
   823     by (simp add: field_simps real_of_nat_Suc mult_nonneg_nonneg x)
   824   also have "\<dots> \<le> (x + 1)^Suc n"
   825     using Suc x by (simp add: mult_left_mono)
   826   finally show ?case .
   827 qed simp
   828 
   829 lemma filterlim_realpow_sequentially_gt1:
   830   fixes x :: "'a :: real_normed_div_algebra"
   831   assumes x[arith]: "1 < norm x"
   832   shows "LIM n sequentially. x ^ n :> at_infinity"
   833 proof (intro filterlim_at_infinity[THEN iffD2] allI impI)
   834   fix y :: real assume "0 < y"
   835   have "0 < norm x - 1" by simp
   836   then obtain N::nat where "y < real N * (norm x - 1)" by (blast dest: reals_Archimedean3)
   837   also have "\<dots> \<le> real N * (norm x - 1) + 1" by simp
   838   also have "\<dots> \<le> (norm x - 1 + 1) ^ N" by (rule linear_plus_1_le_power) simp
   839   also have "\<dots> = norm x ^ N" by simp
   840   finally have "\<forall>n\<ge>N. y \<le> norm x ^ n"
   841     by (metis order_less_le_trans power_increasing order_less_imp_le x)
   842   then show "eventually (\<lambda>n. y \<le> norm (x ^ n)) sequentially"
   843     unfolding eventually_sequentially
   844     by (auto simp: norm_power)
   845 qed simp
   846 
   847 
   848 (* Unfortunately eventually_within was overwritten by Multivariate_Analysis.
   849    Hence it was references as Limits.within, but now it is Basic_Topology.eventually_within *)
   850 lemmas eventually_within = eventually_within
   851 
   852 end
   853