src/HOL/Limits.thy
changeset 68615 3ed4ff0b7ac4
parent 68614 3cb44b0abc5c
child 68721 53ad5c01be3f
equal deleted inserted replaced
68614:3cb44b0abc5c 68615:3ed4ff0b7ac4
    34   have 2: "\<forall>x. u \<le> \<bar>x\<bar> \<longrightarrow> A x \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. A n" for A and u::real
    34   have 2: "\<forall>x. u \<le> \<bar>x\<bar> \<longrightarrow> A x \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. A n" for A and u::real
    35     by (meson abs_less_iff le_cases less_le_not_le)
    35     by (meson abs_less_iff le_cases less_le_not_le)
    36   have 3: "\<forall>x. u \<le> \<bar>x\<bar> \<longrightarrow> A x \<Longrightarrow> \<exists>N. \<forall>n\<le>N. A n" for A and u::real
    36   have 3: "\<forall>x. u \<le> \<bar>x\<bar> \<longrightarrow> A x \<Longrightarrow> \<exists>N. \<forall>n\<le>N. A n" for A and u::real
    37     by (metis (full_types) abs_ge_self abs_minus_cancel le_minus_iff order_trans)
    37     by (metis (full_types) abs_ge_self abs_minus_cancel le_minus_iff order_trans)
    38   show ?thesis
    38   show ?thesis
    39     by (auto simp add: filter_eq_iff eventually_sup eventually_at_infinity
    39     by (auto simp: filter_eq_iff eventually_sup eventually_at_infinity
    40       eventually_at_top_linorder eventually_at_bot_linorder intro: 1 2 3)
    40       eventually_at_top_linorder eventually_at_bot_linorder intro: 1 2 3)
    41 qed
    41 qed
    42 
    42 
    43 lemma at_top_le_at_infinity: "at_top \<le> (at_infinity :: real filter)"
    43 lemma at_top_le_at_infinity: "at_top \<le> (at_infinity :: real filter)"
    44   unfolding at_infinity_eq_at_top_bot by simp
    44   unfolding at_infinity_eq_at_top_bot by simp
   134 
   134 
   135 lemma BseqD: "Bseq X \<Longrightarrow> \<exists>K. 0 < K \<and> (\<forall>n. norm (X n) \<le> K)"
   135 lemma BseqD: "Bseq X \<Longrightarrow> \<exists>K. 0 < K \<and> (\<forall>n. norm (X n) \<le> K)"
   136   by (simp add: Bseq_def)
   136   by (simp add: Bseq_def)
   137 
   137 
   138 lemma BseqI: "0 < K \<Longrightarrow> \<forall>n. norm (X n) \<le> K \<Longrightarrow> Bseq X"
   138 lemma BseqI: "0 < K \<Longrightarrow> \<forall>n. norm (X n) \<le> K \<Longrightarrow> Bseq X"
   139   by (auto simp add: Bseq_def)
   139   by (auto simp: Bseq_def)
   140 
   140 
   141 lemma Bseq_bdd_above: "Bseq X \<Longrightarrow> bdd_above (range X)"
   141 lemma Bseq_bdd_above: "Bseq X \<Longrightarrow> bdd_above (range X)"
   142   for X :: "nat \<Rightarrow> real"
   142   for X :: "nat \<Rightarrow> real"
   143 proof (elim BseqE, intro bdd_aboveI2)
   143 proof (elim BseqE, intro bdd_aboveI2)
   144   fix K n
   144   fix K n
   220 lemma Bseq_iff3: "Bseq X \<longleftrightarrow> (\<exists>k>0. \<exists>N. \<forall>n. norm (X n + - X N) \<le> k)"
   220 lemma Bseq_iff3: "Bseq X \<longleftrightarrow> (\<exists>k>0. \<exists>N. \<forall>n. norm (X n + - X N) \<le> k)"
   221   (is "?P \<longleftrightarrow> ?Q")
   221   (is "?P \<longleftrightarrow> ?Q")
   222 proof
   222 proof
   223   assume ?P
   223   assume ?P
   224   then obtain K where *: "0 < K" and **: "\<And>n. norm (X n) \<le> K"
   224   then obtain K where *: "0 < K" and **: "\<And>n. norm (X n) \<le> K"
   225     by (auto simp add: Bseq_def)
   225     by (auto simp: Bseq_def)
   226   from * have "0 < K + norm (X 0)" by (rule order_less_le_trans) simp
   226   from * have "0 < K + norm (X 0)" by (rule order_less_le_trans) simp
   227   from ** have "\<forall>n. norm (X n - X 0) \<le> K + norm (X 0)"
   227   from ** have "\<forall>n. norm (X n - X 0) \<le> K + norm (X 0)"
   228     by (auto intro: order_trans norm_triangle_ineq4)
   228     by (auto intro: order_trans norm_triangle_ineq4)
   229   then have "\<forall>n. norm (X n + - X 0) \<le> K + norm (X 0)"
   229   then have "\<forall>n. norm (X n + - X 0) \<le> K + norm (X 0)"
   230     by simp
   230     by simp
   231   with \<open>0 < K + norm (X 0)\<close> show ?Q by blast
   231   with \<open>0 < K + norm (X 0)\<close> show ?Q by blast
   232 next
   232 next
   233   assume ?Q
   233   assume ?Q
   234   then show ?P by (auto simp add: Bseq_iff2)
   234   then show ?P by (auto simp: Bseq_iff2)
   235 qed
   235 qed
   236 
   236 
   237 
   237 
   238 subsubsection \<open>Upper Bounds and Lubs of Bounded Sequences\<close>
   238 subsubsection \<open>Upper Bounds and Lubs of Bounded Sequences\<close>
   239 
   239 
   686   fix a b :: 'a
   686   fix a b :: 'a
   687   show "((\<lambda>x. fst x + snd x) \<longlongrightarrow> a + b) (nhds a \<times>\<^sub>F nhds b)"
   687   show "((\<lambda>x. fst x + snd x) \<longlongrightarrow> a + b) (nhds a \<times>\<^sub>F nhds b)"
   688     unfolding tendsto_Zfun_iff add_diff_add
   688     unfolding tendsto_Zfun_iff add_diff_add
   689     using tendsto_fst[OF filterlim_ident, of "(a,b)"] tendsto_snd[OF filterlim_ident, of "(a,b)"]
   689     using tendsto_fst[OF filterlim_ident, of "(a,b)"] tendsto_snd[OF filterlim_ident, of "(a,b)"]
   690     by (intro Zfun_add)
   690     by (intro Zfun_add)
   691        (auto simp add: tendsto_Zfun_iff[symmetric] nhds_prod[symmetric] intro!: tendsto_fst)
   691        (auto simp: tendsto_Zfun_iff[symmetric] nhds_prod[symmetric] intro!: tendsto_fst)
   692   show "(uminus \<longlongrightarrow> - a) (nhds a)"
   692   show "(uminus \<longlongrightarrow> - a) (nhds a)"
   693     unfolding tendsto_Zfun_iff minus_diff_minus
   693     unfolding tendsto_Zfun_iff minus_diff_minus
   694     using filterlim_ident[of "nhds a"]
   694     using filterlim_ident[of "nhds a"]
   695     by (intro Zfun_minus) (simp add: tendsto_Zfun_iff)
   695     by (intro Zfun_minus) (simp add: tendsto_Zfun_iff)
   696 qed
   696 qed
   824   shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. f x * c)"
   824   shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. f x * c)"
   825 by (rule continuous_on_mult [OF _ continuous_on_const])
   825 by (rule continuous_on_mult [OF _ continuous_on_const])
   826 
   826 
   827 lemma continuous_on_mult_const [simp]:
   827 lemma continuous_on_mult_const [simp]:
   828   fixes c::"'a::real_normed_algebra"
   828   fixes c::"'a::real_normed_algebra"
   829   shows "continuous_on s (( * ) c)"
   829   shows "continuous_on s (( *) c)"
   830   by (intro continuous_on_mult_left continuous_on_id)
   830   by (intro continuous_on_mult_left continuous_on_id)
   831 
   831 
   832 lemma tendsto_divide_zero:
   832 lemma tendsto_divide_zero:
   833   fixes c :: "'a::real_normed_field"
   833   fixes c :: "'a::real_normed_field"
   834   shows "(f \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f x / c) \<longlongrightarrow> 0) F"
   834   shows "(f \<longlongrightarrow> 0) F \<Longrightarrow> ((\<lambda>x. f x / c) \<longlongrightarrow> 0) F"
   907 lemma (in bounded_bilinear) Bfun_prod_Zfun:
   907 lemma (in bounded_bilinear) Bfun_prod_Zfun:
   908   assumes f: "Bfun f F"
   908   assumes f: "Bfun f F"
   909     and g: "Zfun g F"
   909     and g: "Zfun g F"
   910   shows "Zfun (\<lambda>x. f x ** g x) F"
   910   shows "Zfun (\<lambda>x. f x ** g x) F"
   911   using flip g f by (rule bounded_bilinear.Zfun_prod_Bfun)
   911   using flip g f by (rule bounded_bilinear.Zfun_prod_Bfun)
   912 
       
   913 lemma Bfun_inverse_lemma:
       
   914   fixes x :: "'a::real_normed_div_algebra"
       
   915   shows "r \<le> norm x \<Longrightarrow> 0 < r \<Longrightarrow> norm (inverse x) \<le> inverse r"
       
   916   apply (subst nonzero_norm_inverse)
       
   917   apply clarsimp
       
   918   apply (erule (1) le_imp_inverse_le)
       
   919   done
       
   920 
   912 
   921 lemma Bfun_inverse:
   913 lemma Bfun_inverse:
   922   fixes a :: "'a::real_normed_div_algebra"
   914   fixes a :: "'a::real_normed_div_algebra"
   923   assumes f: "(f \<longlongrightarrow> a) F"
   915   assumes f: "(f \<longlongrightarrow> a) F"
   924   assumes a: "a \<noteq> 0"
   916   assumes a: "a \<noteq> 0"
  1302   by (metis leI less_minus_iff order_less_asym)
  1294   by (metis leI less_minus_iff order_less_asym)
  1303 
  1295 
  1304 lemma at_bot_mirror :
  1296 lemma at_bot_mirror :
  1305   shows "(at_bot::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_top"
  1297   shows "(at_bot::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_top"
  1306   apply (rule filtermap_fun_inverse[of uminus, symmetric])
  1298   apply (rule filtermap_fun_inverse[of uminus, symmetric])
  1307   subgoal unfolding filterlim_at_top eventually_at_bot_linorder using le_minus_iff by auto
  1299   subgoal unfolding filterlim_at_top filterlim_at_bot eventually_at_bot_linorder using le_minus_iff by auto
  1308   subgoal unfolding filterlim_at_bot eventually_at_top_linorder using minus_le_iff by auto
  1300   subgoal unfolding filterlim_at_bot eventually_at_top_linorder using minus_le_iff by auto
  1309   by auto
  1301   by auto
  1310 
  1302 
  1311 lemma at_top_mirror :
  1303 lemma at_top_mirror :
  1312   shows "(at_top::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_bot"
  1304   shows "(at_top::('a::{ordered_ab_group_add,linorder} filter)) = filtermap uminus at_bot"
  1313   apply (subst at_bot_mirror)
  1305   apply (subst at_bot_mirror)
  1314   by (auto simp add: filtermap_filtermap)
  1306   by (auto simp: filtermap_filtermap)
  1315 
  1307 
  1316 lemma filterlim_at_top_mirror: "(LIM x at_top. f x :> F) \<longleftrightarrow> (LIM x at_bot. f (-x::real) :> F)"
  1308 lemma filterlim_at_top_mirror: "(LIM x at_top. f x :> F) \<longleftrightarrow> (LIM x at_bot. f (-x::real) :> F)"
  1317   unfolding filterlim_def at_top_mirror filtermap_filtermap ..
  1309   unfolding filterlim_def at_top_mirror filtermap_filtermap ..
  1318 
  1310 
  1319 lemma filterlim_at_bot_mirror: "(LIM x at_bot. f x :> F) \<longleftrightarrow> (LIM x at_top. f (-x::real) :> F)"
  1311 lemma filterlim_at_bot_mirror: "(LIM x at_bot. f x :> F) \<longleftrightarrow> (LIM x at_top. f (-x::real) :> F)"
  1353   unfolding filterlim_at_top_gt[where c=0] eventually_at_filter
  1345   unfolding filterlim_at_top_gt[where c=0] eventually_at_filter
  1354 proof safe
  1346 proof safe
  1355   fix Z :: real
  1347   fix Z :: real
  1356   assume [arith]: "0 < Z"
  1348   assume [arith]: "0 < Z"
  1357   then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
  1349   then have "eventually (\<lambda>x. x < inverse Z) (nhds 0)"
  1358     by (auto simp add: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1350     by (auto simp: eventually_nhds_metric dist_real_def intro!: exI[of _ "\<bar>inverse Z\<bar>"])
  1359   then show "eventually (\<lambda>x. x \<noteq> 0 \<longrightarrow> x \<in> {0<..} \<longrightarrow> Z \<le> inverse x) (nhds 0)"
  1351   then show "eventually (\<lambda>x. x \<noteq> 0 \<longrightarrow> x \<in> {0<..} \<longrightarrow> Z \<le> inverse x) (nhds 0)"
  1360     by (auto elim!: eventually_mono simp: inverse_eq_divide field_simps)
  1352     by (auto elim!: eventually_mono simp: inverse_eq_divide field_simps)
  1361 qed
  1353 qed
  1362 
  1354 
  1363 lemma tendsto_inverse_0:
  1355 lemma tendsto_inverse_0:
  1561 lemma at_to_infinity: "(at (0::'a::{real_normed_field,field})) = filtermap inverse at_infinity"
  1553 lemma at_to_infinity: "(at (0::'a::{real_normed_field,field})) = filtermap inverse at_infinity"
  1562 proof (rule antisym)
  1554 proof (rule antisym)
  1563   have "(inverse \<longlongrightarrow> (0::'a)) at_infinity"
  1555   have "(inverse \<longlongrightarrow> (0::'a)) at_infinity"
  1564     by (fact tendsto_inverse_0)
  1556     by (fact tendsto_inverse_0)
  1565   then show "filtermap inverse at_infinity \<le> at (0::'a)"
  1557   then show "filtermap inverse at_infinity \<le> at (0::'a)"
  1566     apply (simp add: le_principal eventually_filtermap eventually_at_infinity filterlim_def at_within_def)
  1558     using filterlim_def filterlim_ident filterlim_inverse_at_iff by fastforce
  1567     apply (rule_tac x="1" in exI)
       
  1568     apply auto
       
  1569     done
       
  1570 next
  1559 next
  1571   have "filtermap inverse (filtermap inverse (at (0::'a))) \<le> filtermap inverse at_infinity"
  1560   have "filtermap inverse (filtermap inverse (at (0::'a))) \<le> filtermap inverse at_infinity"
  1572     using filterlim_inverse_at_infinity unfolding filterlim_def
  1561     using filterlim_inverse_at_infinity unfolding filterlim_def
  1573     by (rule filtermap_mono)
  1562     by (rule filtermap_mono)
  1574   then show "at (0::'a) \<le> filtermap inverse at_infinity"
  1563   then show "at (0::'a) \<le> filtermap inverse at_infinity"
  1871 
  1860 
  1872 lemma LIMSEQ_linear: "X \<longlonglongrightarrow> x \<Longrightarrow> l > 0 \<Longrightarrow> (\<lambda> n. X (n * l)) \<longlonglongrightarrow> x"
  1861 lemma LIMSEQ_linear: "X \<longlonglongrightarrow> x \<Longrightarrow> l > 0 \<Longrightarrow> (\<lambda> n. X (n * l)) \<longlonglongrightarrow> x"
  1873   unfolding tendsto_def eventually_sequentially
  1862   unfolding tendsto_def eventually_sequentially
  1874   by (metis div_le_dividend div_mult_self1_is_m le_trans mult.commute)
  1863   by (metis div_le_dividend div_mult_self1_is_m le_trans mult.commute)
  1875 
  1864 
  1876 lemma norm_inverse_le_norm: "r \<le> norm x \<Longrightarrow> 0 < r \<Longrightarrow> norm (inverse x) \<le> inverse r"
       
  1877   for x :: "'a::real_normed_div_algebra"
       
  1878   apply (subst nonzero_norm_inverse, clarsimp)
       
  1879   apply (erule (1) le_imp_inverse_le)
       
  1880   done
       
  1881 
       
  1882 lemma Bseq_inverse: "X \<longlonglongrightarrow> a \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))"
       
  1883   for a :: "'a::real_normed_div_algebra"
       
  1884   by (rule Bfun_inverse)
       
  1885 
       
  1886 
  1865 
  1887 text \<open>Transformation of limit.\<close>
  1866 text \<open>Transformation of limit.\<close>
  1888 
  1867 
  1889 lemma Lim_transform: "(g \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> a) F"
  1868 lemma Lim_transform: "(g \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. f x - g x) \<longlongrightarrow> 0) F \<Longrightarrow> (f \<longlongrightarrow> a) F"
  1890   for a b :: "'a::real_normed_vector"
  1869   for a b :: "'a::real_normed_vector"
  1898   for a :: "'a::real_normed_vector"
  1877   for a :: "'a::real_normed_vector"
  1899   using Lim_transform Lim_transform2 by blast
  1878   using Lim_transform Lim_transform2 by blast
  1900 
  1879 
  1901 lemma Lim_transform_eventually:
  1880 lemma Lim_transform_eventually:
  1902   "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f \<longlongrightarrow> l) net \<Longrightarrow> (g \<longlongrightarrow> l) net"
  1881   "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f \<longlongrightarrow> l) net \<Longrightarrow> (g \<longlongrightarrow> l) net"
  1903   apply (rule topological_tendstoI)
  1882   using eventually_elim2 by (fastforce simp add: tendsto_def)
  1904   apply (drule (2) topological_tendstoD)
       
  1905   apply (erule (1) eventually_elim2)
       
  1906   apply simp
       
  1907   done
       
  1908 
  1883 
  1909 lemma Lim_transform_within:
  1884 lemma Lim_transform_within:
  1910   assumes "(f \<longlongrightarrow> l) (at x within S)"
  1885   assumes "(f \<longlongrightarrow> l) (at x within S)"
  1911     and "0 < d"
  1886     and "0 < d"
  1912     and "\<And>x'. x'\<in>S \<Longrightarrow> 0 < dist x' x \<Longrightarrow> dist x' x < d \<Longrightarrow> f x' = g x'"
  1887     and "\<And>x'. x'\<in>S \<Longrightarrow> 0 < dist x' x \<Longrightarrow> dist x' x < d \<Longrightarrow> f x' = g x'"
  1986 text \<open>An unbounded sequence's inverse tends to 0.\<close>
  1961 text \<open>An unbounded sequence's inverse tends to 0.\<close>
  1987 lemma LIMSEQ_inverse_zero:
  1962 lemma LIMSEQ_inverse_zero:
  1988   assumes "\<And>r::real. \<exists>N. \<forall>n\<ge>N. r < X n"
  1963   assumes "\<And>r::real. \<exists>N. \<forall>n\<ge>N. r < X n"
  1989   shows "(\<lambda>n. inverse (X n)) \<longlonglongrightarrow> 0"
  1964   shows "(\<lambda>n. inverse (X n)) \<longlonglongrightarrow> 0"
  1990   apply (rule filterlim_compose[OF tendsto_inverse_0])
  1965   apply (rule filterlim_compose[OF tendsto_inverse_0])
  1991   apply (simp add: filterlim_at_infinity[OF order_refl] eventually_sequentially)
  1966   by (metis assms eventually_at_top_linorderI filterlim_at_top_dense filterlim_at_top_imp_at_infinity)
  1992   apply (metis assms abs_le_D1 linorder_le_cases linorder_not_le)
       
  1993   done
       
  1994 
  1967 
  1995 text \<open>The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity.\<close>
  1968 text \<open>The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity.\<close>
  1996 lemma LIMSEQ_inverse_real_of_nat: "(\<lambda>n. inverse (real (Suc n))) \<longlonglongrightarrow> 0"
  1969 lemma LIMSEQ_inverse_real_of_nat: "(\<lambda>n. inverse (real (Suc n))) \<longlonglongrightarrow> 0"
  1997   by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc
  1970   by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc
  1998       filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity)
  1971       filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity)
  2259 
  2232 
  2260 subsection \<open>Power Sequences\<close>
  2233 subsection \<open>Power Sequences\<close>
  2261 
  2234 
  2262 lemma Bseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> Bseq (\<lambda>n. x ^ n)"
  2235 lemma Bseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> Bseq (\<lambda>n. x ^ n)"
  2263   for x :: real
  2236   for x :: real
  2264   apply (simp add: Bseq_def)
  2237   by (metis decseq_bounded decseq_def power_decreasing zero_le_power)
  2265   apply (rule_tac x = 1 in exI)
       
  2266   apply (simp add: power_abs)
       
  2267   apply (auto dest: power_mono)
       
  2268   done
       
  2269 
  2238 
  2270 lemma monoseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> monoseq (\<lambda>n. x ^ n)"
  2239 lemma monoseq_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> monoseq (\<lambda>n. x ^ n)"
  2271   for x :: real
  2240   for x :: real
  2272   apply (clarify intro!: mono_SucI2)
  2241   using monoseq_def power_decreasing by blast
  2273   apply (cut_tac n = n and N = "Suc n" and a = x in power_decreasing)
       
  2274      apply auto
       
  2275   done
       
  2276 
  2242 
  2277 lemma convergent_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> convergent (\<lambda>n. x ^ n)"
  2243 lemma convergent_realpow: "0 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> convergent (\<lambda>n. x ^ n)"
  2278   for x :: real
  2244   for x :: real
  2279   by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
  2245   by (blast intro!: Bseq_monoseq_convergent Bseq_realpow monoseq_realpow)
  2280 
  2246 
  2301 qed
  2267 qed
  2302 
  2268 
  2303 lemma LIMSEQ_power_zero: "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
  2269 lemma LIMSEQ_power_zero: "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) \<longlonglongrightarrow> 0"
  2304   for x :: "'a::real_normed_algebra_1"
  2270   for x :: "'a::real_normed_algebra_1"
  2305   apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
  2271   apply (drule LIMSEQ_realpow_zero [OF norm_ge_zero])
  2306   apply (simp only: tendsto_Zfun_iff, erule Zfun_le)
  2272   by (simp add: Zfun_le norm_power_ineq tendsto_Zfun_iff)
  2307   apply (simp add: power_abs norm_power_ineq)
       
  2308   done
       
  2309 
  2273 
  2310 lemma LIMSEQ_divide_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. a / (x ^ n) :: real) \<longlonglongrightarrow> 0"
  2274 lemma LIMSEQ_divide_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. a / (x ^ n) :: real) \<longlonglongrightarrow> 0"
  2311   by (rule tendsto_divide_0 [OF tendsto_const filterlim_realpow_sequentially_gt1]) simp
  2275   by (rule tendsto_divide_0 [OF tendsto_const filterlim_realpow_sequentially_gt1]) simp
  2312 
  2276 
  2313 lemma
  2277 lemma
  2325     by (auto simp: eventually_sequentially)
  2289     by (auto simp: eventually_sequentially)
  2326   have "\<forall>\<^sub>F i in F. f i \<ge> N"
  2290   have "\<forall>\<^sub>F i in F. f i \<ge> N"
  2327     using \<open>filterlim f sequentially F\<close>
  2291     using \<open>filterlim f sequentially F\<close>
  2328     by (simp add: filterlim_at_top)
  2292     by (simp add: filterlim_at_top)
  2329   then show "\<forall>\<^sub>F i in F. dist (x ^ f i) 0 < e"
  2293   then show "\<forall>\<^sub>F i in F. dist (x ^ f i) 0 < e"
  2330     by (eventually_elim) (auto simp: N)
  2294     by eventually_elim (auto simp: N)
  2331 qed
  2295 qed
  2332 
  2296 
  2333 text \<open>Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}.\<close>
  2297 text \<open>Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}.\<close>
  2334 
  2298 
  2335 lemma LIMSEQ_abs_realpow_zero: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. \<bar>c\<bar> ^ n :: real) \<longlonglongrightarrow> 0"
  2299 lemma LIMSEQ_abs_realpow_zero: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. \<bar>c\<bar> ^ n :: real) \<longlonglongrightarrow> 0"
  2715 lemma isCont_eq_Ub:
  2679 lemma isCont_eq_Ub:
  2716   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2680   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2717   shows "a \<le> b \<Longrightarrow> \<forall>x::real. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2681   shows "a \<le> b \<Longrightarrow> \<forall>x::real. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2718     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
  2682     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
  2719   using continuous_attains_sup[of "{a..b}" f]
  2683   using continuous_attains_sup[of "{a..b}" f]
  2720   by (auto simp add: continuous_at_imp_continuous_on Ball_def Bex_def)
  2684   by (auto simp: continuous_at_imp_continuous_on Ball_def Bex_def)
  2721 
  2685 
  2722 lemma isCont_eq_Lb:
  2686 lemma isCont_eq_Lb:
  2723   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2687   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2724   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2688   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
  2725     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> M \<le> f x) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
  2689     \<exists>M. (\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> M \<le> f x) \<and> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
  2726   using continuous_attains_inf[of "{a..b}" f]
  2690   using continuous_attains_inf[of "{a..b}" f]
  2727   by (auto simp add: continuous_at_imp_continuous_on Ball_def Bex_def)
  2691   by (auto simp: continuous_at_imp_continuous_on Ball_def Bex_def)
  2728 
  2692 
  2729 lemma isCont_bounded:
  2693 lemma isCont_bounded:
  2730   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2694   fixes f :: "real \<Rightarrow> 'a::linorder_topology"
  2731   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow> \<exists>M. \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M"
  2695   shows "a \<le> b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow> \<exists>M. \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M"
  2732   using isCont_eq_Ub[of a b f] by auto
  2696   using isCont_eq_Ub[of a b f] by auto
  2758 proof -
  2722 proof -
  2759   obtain M where M: "a \<le> M" "M \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> f M"
  2723   obtain M where M: "a \<le> M" "M \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> f M"
  2760     using isCont_eq_Ub[OF assms] by auto
  2724     using isCont_eq_Ub[OF assms] by auto
  2761   obtain L where L: "a \<le> L" "L \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f L \<le> f x"
  2725   obtain L where L: "a \<le> L" "L \<le> b" "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f L \<le> f x"
  2762     using isCont_eq_Lb[OF assms] by auto
  2726     using isCont_eq_Lb[OF assms] by auto
  2763   show ?thesis
  2727   have "(\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f L \<le> f x \<and> f x \<le> f M)"
  2764     using IVT[of f L _ M] IVT2[of f L _ M] M L assms
  2728     using M L by simp
  2765     apply (rule_tac x="f L" in exI)
  2729   moreover
  2766     apply (rule_tac x="f M" in exI)
  2730   have "(\<forall>y. f L \<le> y \<and> y \<le> f M \<longrightarrow> (\<exists>x\<ge>a. x \<le> b \<and> f x = y))"
  2767     apply (cases "L \<le> M")
  2731   proof (cases "L \<le> M")
  2768      apply simp
  2732     case True then show ?thesis
  2769      apply (metis order_trans)
  2733     using IVT[of f L _ M] M L assms by (metis order.trans)
  2770     apply simp
  2734   next
  2771     apply (metis order_trans)
  2735     case False then show ?thesis
  2772     done
  2736     using IVT2[of f L _ M]
       
  2737     by (metis L(2) M(1) assms(2) le_cases order.trans)
       
  2738 qed
       
  2739   ultimately show ?thesis
       
  2740     by blast
  2773 qed
  2741 qed
  2774 
  2742 
  2775 
  2743 
  2776 text \<open>Continuity of inverse function.\<close>
  2744 text \<open>Continuity of inverse function.\<close>
  2777 
  2745 
  2798   moreover
  2766   moreover
  2799   have "(?A < f x \<and> f x < ?B) \<or> (?B < f x \<and> f x < ?A)"
  2767   have "(?A < f x \<and> f x < ?B) \<or> (?B < f x \<and> f x < ?A)"
  2800     using d inj by (intro continuous_inj_imp_mono[OF _ _ f] inj_on_imageI2[of g, OF inj_onI]) auto
  2768     using d inj by (intro continuous_inj_imp_mono[OF _ _ f] inj_on_imageI2[of g, OF inj_onI]) auto
  2801   then have "f x \<in> {min ?A ?B <..< max ?A ?B}"
  2769   then have "f x \<in> {min ?A ?B <..< max ?A ?B}"
  2802     by auto
  2770     by auto
  2803   ultimately
  2771   ultimately show ?thesis
  2804   show ?thesis
       
  2805     by (simp add: continuous_on_eq_continuous_at)
  2772     by (simp add: continuous_on_eq_continuous_at)
  2806 qed
  2773 qed
  2807 
  2774 
  2808 lemma isCont_inverse_function2:
  2775 lemma isCont_inverse_function2:
  2809   fixes f g :: "real \<Rightarrow> real"
  2776   fixes f g :: "real \<Rightarrow> real"
  2816   done
  2783   done
  2817 
  2784 
  2818 text \<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110.\<close>
  2785 text \<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110.\<close>
  2819 lemma LIM_fun_gt_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> 0 < f x)"
  2786 lemma LIM_fun_gt_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> 0 < f x)"
  2820   for f :: "real \<Rightarrow> real"
  2787   for f :: "real \<Rightarrow> real"
  2821   apply (drule (1) LIM_D)
  2788   by (force simp: dest: LIM_D)
  2822   apply clarify
       
  2823   apply (rule_tac x = s in exI)
       
  2824   apply (simp add: abs_less_iff)
       
  2825   done
       
  2826 
  2789 
  2827 lemma LIM_fun_less_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x < 0)"
  2790 lemma LIM_fun_less_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x < 0)"
  2828   for f :: "real \<Rightarrow> real"
  2791   for f :: "real \<Rightarrow> real"
  2829   apply (drule LIM_D [where r="-l"])
  2792   by (drule LIM_D [where r="-l"]) force+
  2830    apply simp
       
  2831   apply clarify
       
  2832   apply (rule_tac x = s in exI)
       
  2833   apply (simp add: abs_less_iff)
       
  2834   done
       
  2835 
  2793 
  2836 lemma LIM_fun_not_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0)"
  2794 lemma LIM_fun_not_zero: "f \<midarrow>c\<rightarrow> l \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists>r. 0 < r \<and> (\<forall>x. x \<noteq> c \<and> \<bar>c - x\<bar> < r \<longrightarrow> f x \<noteq> 0)"
  2837   for f :: "real \<Rightarrow> real"
  2795   for f :: "real \<Rightarrow> real"
  2838   using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c] by (auto simp add: neq_iff)
  2796   using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c] by (auto simp: neq_iff)
  2839 
  2797 
  2840 end
  2798 end