src/HOL/Limits.thy
changeset 61976 3a27957ac658
parent 61973 0c7e865fa7cb
child 62087 44841d07ef1d
equal deleted inserted replaced
61975:b4b11391c676 61976:3a27957ac658
  1939 
  1939 
  1940 subsection \<open>Limits of Functions\<close>
  1940 subsection \<open>Limits of Functions\<close>
  1941 
  1941 
  1942 lemma LIM_eq:
  1942 lemma LIM_eq:
  1943   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1943   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1944   shows "f -- a --> L =
  1944   shows "f \<midarrow>a\<rightarrow> L =
  1945      (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
  1945      (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
  1946 by (simp add: LIM_def dist_norm)
  1946 by (simp add: LIM_def dist_norm)
  1947 
  1947 
  1948 lemma LIM_I:
  1948 lemma LIM_I:
  1949   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1949   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1950   shows "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
  1950   shows "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
  1951       ==> f -- a --> L"
  1951       ==> f \<midarrow>a\<rightarrow> L"
  1952 by (simp add: LIM_eq)
  1952 by (simp add: LIM_eq)
  1953 
  1953 
  1954 lemma LIM_D:
  1954 lemma LIM_D:
  1955   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1955   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
  1956   shows "[| f -- a --> L; 0<r |]
  1956   shows "[| f \<midarrow>a\<rightarrow> L; 0<r |]
  1957       ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
  1957       ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
  1958 by (simp add: LIM_eq)
  1958 by (simp add: LIM_eq)
  1959 
  1959 
  1960 lemma LIM_offset:
  1960 lemma LIM_offset:
  1961   fixes a :: "'a::real_normed_vector"
  1961   fixes a :: "'a::real_normed_vector"
  1962   shows "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
  1962   shows "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>x. f (x + k)) \<midarrow>(a - k)\<rightarrow> L"
  1963   unfolding filtermap_at_shift[symmetric, of a k] filterlim_def filtermap_filtermap by simp
  1963   unfolding filtermap_at_shift[symmetric, of a k] filterlim_def filtermap_filtermap by simp
  1964 
  1964 
  1965 lemma LIM_offset_zero:
  1965 lemma LIM_offset_zero:
  1966   fixes a :: "'a::real_normed_vector"
  1966   fixes a :: "'a::real_normed_vector"
  1967   shows "f -- a --> L \<Longrightarrow> (\<lambda>h. f (a + h)) -- 0 --> L"
  1967   shows "f \<midarrow>a\<rightarrow> L \<Longrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
  1968 by (drule_tac k="a" in LIM_offset, simp add: add.commute)
  1968 by (drule_tac k="a" in LIM_offset, simp add: add.commute)
  1969 
  1969 
  1970 lemma LIM_offset_zero_cancel:
  1970 lemma LIM_offset_zero_cancel:
  1971   fixes a :: "'a::real_normed_vector"
  1971   fixes a :: "'a::real_normed_vector"
  1972   shows "(\<lambda>h. f (a + h)) -- 0 --> L \<Longrightarrow> f -- a --> L"
  1972   shows "(\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L \<Longrightarrow> f \<midarrow>a\<rightarrow> L"
  1973 by (drule_tac k="- a" in LIM_offset, simp)
  1973 by (drule_tac k="- a" in LIM_offset, simp)
  1974 
  1974 
  1975 lemma LIM_offset_zero_iff:
  1975 lemma LIM_offset_zero_iff:
  1976   fixes f :: "'a :: real_normed_vector \<Rightarrow> _"
  1976   fixes f :: "'a :: real_normed_vector \<Rightarrow> _"
  1977   shows  "f -- a --> L \<longleftrightarrow> (\<lambda>h. f (a + h)) -- 0 --> L"
  1977   shows  "f \<midarrow>a\<rightarrow> L \<longleftrightarrow> (\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> L"
  1978   using LIM_offset_zero_cancel[of f a L] LIM_offset_zero[of f L a] by auto
  1978   using LIM_offset_zero_cancel[of f a L] LIM_offset_zero[of f L a] by auto
  1979 
  1979 
  1980 lemma LIM_zero:
  1980 lemma LIM_zero:
  1981   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
  1981   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
  1982   shows "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. f x - l) \<longlongrightarrow> 0) F"
  1982   shows "(f \<longlongrightarrow> l) F \<Longrightarrow> ((\<lambda>x. f x - l) \<longlongrightarrow> 0) F"
  1993 unfolding tendsto_iff dist_norm by simp
  1993 unfolding tendsto_iff dist_norm by simp
  1994 
  1994 
  1995 lemma LIM_imp_LIM:
  1995 lemma LIM_imp_LIM:
  1996   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
  1996   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
  1997   fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
  1997   fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
  1998   assumes f: "f -- a --> l"
  1998   assumes f: "f \<midarrow>a\<rightarrow> l"
  1999   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
  1999   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
  2000   shows "g -- a --> m"
  2000   shows "g \<midarrow>a\<rightarrow> m"
  2001   by (rule metric_LIM_imp_LIM [OF f],
  2001   by (rule metric_LIM_imp_LIM [OF f],
  2002     simp add: dist_norm le)
  2002     simp add: dist_norm le)
  2003 
  2003 
  2004 lemma LIM_equal2:
  2004 lemma LIM_equal2:
  2005   fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2005   fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2006   assumes 1: "0 < R"
  2006   assumes 1: "0 < R"
  2007   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
  2007   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
  2008   shows "g -- a --> l \<Longrightarrow> f -- a --> l"
  2008   shows "g \<midarrow>a\<rightarrow> l \<Longrightarrow> f \<midarrow>a\<rightarrow> l"
  2009 by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
  2009 by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
  2010 
  2010 
  2011 lemma LIM_compose2:
  2011 lemma LIM_compose2:
  2012   fixes a :: "'a::real_normed_vector"
  2012   fixes a :: "'a::real_normed_vector"
  2013   assumes f: "f -- a --> b"
  2013   assumes f: "f \<midarrow>a\<rightarrow> b"
  2014   assumes g: "g -- b --> c"
  2014   assumes g: "g \<midarrow>b\<rightarrow> c"
  2015   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
  2015   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
  2016   shows "(\<lambda>x. g (f x)) -- a --> c"
  2016   shows "(\<lambda>x. g (f x)) \<midarrow>a\<rightarrow> c"
  2017 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
  2017 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
  2018 
  2018 
  2019 lemma real_LIM_sandwich_zero:
  2019 lemma real_LIM_sandwich_zero:
  2020   fixes f g :: "'a::topological_space \<Rightarrow> real"
  2020   fixes f g :: "'a::topological_space \<Rightarrow> real"
  2021   assumes f: "f -- a --> 0"
  2021   assumes f: "f \<midarrow>a\<rightarrow> 0"
  2022   assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
  2022   assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
  2023   assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
  2023   assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
  2024   shows "g -- a --> 0"
  2024   shows "g \<midarrow>a\<rightarrow> 0"
  2025 proof (rule LIM_imp_LIM [OF f]) (* FIXME: use tendsto_sandwich *)
  2025 proof (rule LIM_imp_LIM [OF f]) (* FIXME: use tendsto_sandwich *)
  2026   fix x assume x: "x \<noteq> a"
  2026   fix x assume x: "x \<noteq> a"
  2027   have "norm (g x - 0) = g x" by (simp add: 1 x)
  2027   have "norm (g x - 0) = g x" by (simp add: 1 x)
  2028   also have "g x \<le> f x" by (rule 2 [OF x])
  2028   also have "g x \<le> f x" by (rule 2 [OF x])
  2029   also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
  2029   also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
  2034 
  2034 
  2035 subsection \<open>Continuity\<close>
  2035 subsection \<open>Continuity\<close>
  2036 
  2036 
  2037 lemma LIM_isCont_iff:
  2037 lemma LIM_isCont_iff:
  2038   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2038   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2039   shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
  2039   shows "(f \<midarrow>a\<rightarrow> f a) = ((\<lambda>h. f (a + h)) \<midarrow>0\<rightarrow> f a)"
  2040 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
  2040 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
  2041 
  2041 
  2042 lemma isCont_iff:
  2042 lemma isCont_iff:
  2043   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2043   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
  2044   shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
  2044   shows "isCont f x = (\<lambda>h. f (x + h)) \<midarrow>0\<rightarrow> f x"
  2045 by (simp add: isCont_def LIM_isCont_iff)
  2045 by (simp add: isCont_def LIM_isCont_iff)
  2046 
  2046 
  2047 lemma isCont_LIM_compose2:
  2047 lemma isCont_LIM_compose2:
  2048   fixes a :: "'a::real_normed_vector"
  2048   fixes a :: "'a::real_normed_vector"
  2049   assumes f [unfolded isCont_def]: "isCont f a"
  2049   assumes f [unfolded isCont_def]: "isCont f a"
  2050   assumes g: "g -- f a --> l"
  2050   assumes g: "g \<midarrow>f a\<rightarrow> l"
  2051   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
  2051   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
  2052   shows "(\<lambda>x. g (f x)) -- a --> l"
  2052   shows "(\<lambda>x. g (f x)) \<midarrow>a\<rightarrow> l"
  2053 by (rule LIM_compose2 [OF f g inj])
  2053 by (rule LIM_compose2 [OF f g inj])
  2054 
  2054 
  2055 
  2055 
  2056 lemma isCont_norm [simp]:
  2056 lemma isCont_norm [simp]:
  2057   fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
  2057   fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
  2401 by (rule isCont_inverse_function)
  2401 by (rule isCont_inverse_function)
  2402 
  2402 
  2403 text\<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110\<close>
  2403 text\<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110\<close>
  2404 lemma LIM_fun_gt_zero:
  2404 lemma LIM_fun_gt_zero:
  2405   fixes f :: "real \<Rightarrow> real"
  2405   fixes f :: "real \<Rightarrow> real"
  2406   shows "f -- c --> 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)"
  2406   shows "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)"
  2407 apply (drule (1) LIM_D, clarify)
  2407 apply (drule (1) LIM_D, clarify)
  2408 apply (rule_tac x = s in exI)
  2408 apply (rule_tac x = s in exI)
  2409 apply (simp add: abs_less_iff)
  2409 apply (simp add: abs_less_iff)
  2410 done
  2410 done
  2411 
  2411 
  2412 lemma LIM_fun_less_zero:
  2412 lemma LIM_fun_less_zero:
  2413   fixes f :: "real \<Rightarrow> real"
  2413   fixes f :: "real \<Rightarrow> real"
  2414   shows "f -- c --> 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)"
  2414   shows "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)"
  2415 apply (drule LIM_D [where r="-l"], simp, clarify)
  2415 apply (drule LIM_D [where r="-l"], simp, clarify)
  2416 apply (rule_tac x = s in exI)
  2416 apply (rule_tac x = s in exI)
  2417 apply (simp add: abs_less_iff)
  2417 apply (simp add: abs_less_iff)
  2418 done
  2418 done
  2419 
  2419 
  2420 lemma LIM_fun_not_zero:
  2420 lemma LIM_fun_not_zero:
  2421   fixes f :: "real \<Rightarrow> real"
  2421   fixes f :: "real \<Rightarrow> real"
  2422   shows "f -- c --> 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)"
  2422   shows "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)"
  2423   using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c] by (auto simp add: neq_iff)
  2423   using LIM_fun_gt_zero[of f l c] LIM_fun_less_zero[of f l c] by (auto simp add: neq_iff)
  2424 
  2424 
  2425 end
  2425 end
  2426 
  2426