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