3 Author: Jacques D. Fleuriot, University of Cambridge |
3 Author: Jacques D. Fleuriot, University of Cambridge |
4 Author: Lawrence C Paulson |
4 Author: Lawrence C Paulson |
5 Author: Jeremy Avigad |
5 Author: Jeremy Avigad |
6 *) |
6 *) |
7 |
7 |
8 section {* Limits on Real Vector Spaces *} |
8 section \<open>Limits on Real Vector Spaces\<close> |
9 |
9 |
10 theory Limits |
10 theory Limits |
11 imports Real_Vector_Spaces |
11 imports Real_Vector_Spaces |
12 begin |
12 begin |
13 |
13 |
14 subsection {* Filter going to infinity norm *} |
14 subsection \<open>Filter going to infinity norm\<close> |
15 |
15 |
16 definition at_infinity :: "'a::real_normed_vector filter" where |
16 definition at_infinity :: "'a::real_normed_vector filter" where |
17 "at_infinity = (INF r. principal {x. r \<le> norm x})" |
17 "at_infinity = (INF r. principal {x. r \<le> norm x})" |
18 |
18 |
19 lemma eventually_at_infinity: "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> P x)" |
19 lemma eventually_at_infinity: "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> P x)" |
45 lemma lim_infinity_imp_sequentially: |
45 lemma lim_infinity_imp_sequentially: |
46 "(f ---> l) at_infinity \<Longrightarrow> ((\<lambda>n. f(n)) ---> l) sequentially" |
46 "(f ---> l) at_infinity \<Longrightarrow> ((\<lambda>n. f(n)) ---> l) sequentially" |
47 by (simp add: filterlim_at_top_imp_at_infinity filterlim_compose filterlim_real_sequentially) |
47 by (simp add: filterlim_at_top_imp_at_infinity filterlim_compose filterlim_real_sequentially) |
48 |
48 |
49 |
49 |
50 subsubsection {* Boundedness *} |
50 subsubsection \<open>Boundedness\<close> |
51 |
51 |
52 definition Bfun :: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'a filter \<Rightarrow> bool" where |
52 definition Bfun :: "('a \<Rightarrow> 'b::metric_space) \<Rightarrow> 'a filter \<Rightarrow> bool" where |
53 Bfun_metric_def: "Bfun f F = (\<exists>y. \<exists>K>0. eventually (\<lambda>x. dist (f x) y \<le> K) F)" |
53 Bfun_metric_def: "Bfun f F = (\<exists>y. \<exists>K>0. eventually (\<lambda>x. dist (f x) y \<le> K) F)" |
54 |
54 |
55 abbreviation Bseq :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool" where |
55 abbreviation Bseq :: "(nat \<Rightarrow> 'a::metric_space) \<Rightarrow> bool" where |
70 fix y K assume "0 < K" and *: "eventually (\<lambda>x. dist (f x) y \<le> K) F" |
70 fix y K assume "0 < K" and *: "eventually (\<lambda>x. dist (f x) y \<le> K) F" |
71 moreover have "eventually (\<lambda>x. dist (f x) 0 \<le> dist (f x) y + dist 0 y) F" |
71 moreover have "eventually (\<lambda>x. dist (f x) 0 \<le> dist (f x) y + dist 0 y) F" |
72 by (intro always_eventually) (metis dist_commute dist_triangle) |
72 by (intro always_eventually) (metis dist_commute dist_triangle) |
73 with * have "eventually (\<lambda>x. dist (f x) 0 \<le> K + dist 0 y) F" |
73 with * have "eventually (\<lambda>x. dist (f x) 0 \<le> K + dist 0 y) F" |
74 by eventually_elim auto |
74 by eventually_elim auto |
75 with `0 < K` show "\<exists>K>0. eventually (\<lambda>x. dist (f x) 0 \<le> K) F" |
75 with \<open>0 < K\<close> show "\<exists>K>0. eventually (\<lambda>x. dist (f x) 0 \<le> K) F" |
76 by (intro exI[of _ "K + dist 0 y"] add_pos_nonneg conjI zero_le_dist) auto |
76 by (intro exI[of _ "K + dist 0 y"] add_pos_nonneg conjI zero_le_dist) auto |
77 qed auto |
77 qed auto |
78 |
78 |
79 lemma BfunI: |
79 lemma BfunI: |
80 assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F" shows "Bfun f F" |
80 assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F" shows "Bfun f F" |
153 ultimately have "\<forall>m. norm (X m) \<le> real (Suc n)" |
153 ultimately have "\<forall>m. norm (X m) \<le> real (Suc n)" |
154 by (blast intro: order_trans) |
154 by (blast intro: order_trans) |
155 then show "\<exists>N. \<forall>n. norm (X n) \<le> real (Suc N)" .. |
155 then show "\<exists>N. \<forall>n. norm (X n) \<le> real (Suc N)" .. |
156 qed (force simp add: real_of_nat_Suc) |
156 qed (force simp add: real_of_nat_Suc) |
157 |
157 |
158 text{* alternative definition for Bseq *} |
158 text\<open>alternative definition for Bseq\<close> |
159 lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))" |
159 lemma Bseq_iff: "Bseq X = (\<exists>N. \<forall>n. norm (X n) \<le> real(Suc N))" |
160 apply (simp add: Bseq_def) |
160 apply (simp add: Bseq_def) |
161 apply (simp (no_asm) add: lemma_NBseq_def) |
161 apply (simp (no_asm) add: lemma_NBseq_def) |
162 done |
162 done |
163 |
163 |
173 |
173 |
174 (* yet another definition for Bseq *) |
174 (* yet another definition for Bseq *) |
175 lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))" |
175 lemma Bseq_iff1a: "Bseq X = (\<exists>N. \<forall>n. norm (X n) < real(Suc N))" |
176 by (simp add: Bseq_def lemma_NBseq_def2) |
176 by (simp add: Bseq_def lemma_NBseq_def2) |
177 |
177 |
178 subsubsection{*A Few More Equivalence Theorems for Boundedness*} |
178 subsubsection\<open>A Few More Equivalence Theorems for Boundedness\<close> |
179 |
179 |
180 text{*alternative formulation for boundedness*} |
180 text\<open>alternative formulation for boundedness\<close> |
181 lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)" |
181 lemma Bseq_iff2: "Bseq X = (\<exists>k > 0. \<exists>x. \<forall>n. norm (X(n) + -x) \<le> k)" |
182 apply (unfold Bseq_def, safe) |
182 apply (unfold Bseq_def, safe) |
183 apply (rule_tac [2] x = "k + norm x" in exI) |
183 apply (rule_tac [2] x = "k + norm x" in exI) |
184 apply (rule_tac x = K in exI, simp) |
184 apply (rule_tac x = K in exI, simp) |
185 apply (rule exI [where x = 0], auto) |
185 apply (rule exI [where x = 0], auto) |
199 from * have "0 < K + norm (X 0)" by (rule order_less_le_trans) simp |
199 from * have "0 < K + norm (X 0)" by (rule order_less_le_trans) simp |
200 from ** have "\<forall>n. norm (X n - X 0) \<le> K + norm (X 0)" |
200 from ** have "\<forall>n. norm (X n - X 0) \<le> K + norm (X 0)" |
201 by (auto intro: order_trans norm_triangle_ineq4) |
201 by (auto intro: order_trans norm_triangle_ineq4) |
202 then have "\<forall>n. norm (X n + - X 0) \<le> K + norm (X 0)" |
202 then have "\<forall>n. norm (X n + - X 0) \<le> K + norm (X 0)" |
203 by simp |
203 by simp |
204 with `0 < K + norm (X 0)` show ?Q by blast |
204 with \<open>0 < K + norm (X 0)\<close> show ?Q by blast |
205 next |
205 next |
206 assume ?Q then show ?P by (auto simp add: Bseq_iff2) |
206 assume ?Q then show ?P by (auto simp add: Bseq_iff2) |
207 qed |
207 qed |
208 |
208 |
209 lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f" |
209 lemma BseqI2: "(\<forall>n. k \<le> f n & f n \<le> (K::real)) ==> Bseq f" |
211 apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto) |
211 apply (rule_tac x = " (\<bar>k\<bar> + \<bar>K\<bar>) + 1" in exI, auto) |
212 apply (drule_tac x = n in spec, arith) |
212 apply (drule_tac x = n in spec, arith) |
213 done |
213 done |
214 |
214 |
215 |
215 |
216 subsubsection{*Upper Bounds and Lubs of Bounded Sequences*} |
216 subsubsection\<open>Upper Bounds and Lubs of Bounded Sequences\<close> |
217 |
217 |
218 lemma Bseq_minus_iff: "Bseq (%n. -(X n) :: 'a :: real_normed_vector) = Bseq X" |
218 lemma Bseq_minus_iff: "Bseq (%n. -(X n) :: 'a :: real_normed_vector) = Bseq X" |
219 by (simp add: Bseq_def) |
219 by (simp add: Bseq_def) |
220 |
220 |
221 lemma Bseq_eq_bounded: "range f \<subseteq> {a .. b::real} \<Longrightarrow> Bseq f" |
221 lemma Bseq_eq_bounded: "range f \<subseteq> {a .. b::real} \<Longrightarrow> Bseq f" |
229 by (intro Bseq_eq_bounded[of X "X 0" B]) (auto simp: incseq_def) |
229 by (intro Bseq_eq_bounded[of X "X 0" B]) (auto simp: incseq_def) |
230 |
230 |
231 lemma decseq_bounded: "decseq X \<Longrightarrow> \<forall>i. (B::real) \<le> X i \<Longrightarrow> Bseq X" |
231 lemma decseq_bounded: "decseq X \<Longrightarrow> \<forall>i. (B::real) \<le> X i \<Longrightarrow> Bseq X" |
232 by (intro Bseq_eq_bounded[of X B "X 0"]) (auto simp: decseq_def) |
232 by (intro Bseq_eq_bounded[of X B "X 0"]) (auto simp: decseq_def) |
233 |
233 |
234 subsection {* Bounded Monotonic Sequences *} |
234 subsection \<open>Bounded Monotonic Sequences\<close> |
235 |
235 |
236 subsubsection{*A Bounded and Monotonic Sequence Converges*} |
236 subsubsection\<open>A Bounded and Monotonic Sequence Converges\<close> |
237 |
237 |
238 (* TODO: delete *) |
238 (* TODO: delete *) |
239 (* FIXME: one use in NSA/HSEQ.thy *) |
239 (* FIXME: one use in NSA/HSEQ.thy *) |
240 lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)" |
240 lemma Bmonoseq_LIMSEQ: "\<forall>n. m \<le> n --> X n = X m ==> \<exists>L. (X ----> L)" |
241 apply (rule_tac x="X m" in exI) |
241 apply (rule_tac x="X m" in exI) |
242 apply (rule filterlim_cong[THEN iffD2, OF refl refl _ tendsto_const]) |
242 apply (rule filterlim_cong[THEN iffD2, OF refl refl _ tendsto_const]) |
243 unfolding eventually_sequentially |
243 unfolding eventually_sequentially |
244 apply blast |
244 apply blast |
245 done |
245 done |
246 |
246 |
247 subsection {* Convergence to Zero *} |
247 subsection \<open>Convergence to Zero\<close> |
248 |
248 |
249 definition Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" |
249 definition Zfun :: "('a \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool" |
250 where "Zfun f F = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) F)" |
250 where "Zfun f F = (\<forall>r>0. eventually (\<lambda>x. norm (f x) < r) F)" |
251 |
251 |
252 lemma ZfunI: |
252 lemma ZfunI: |
398 |
398 |
399 lemma tendsto_0_le: "\<lbrakk>(f ---> 0) F; eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F\<rbrakk> |
399 lemma tendsto_0_le: "\<lbrakk>(f ---> 0) F; eventually (\<lambda>x. norm (g x) \<le> norm (f x) * K) F\<rbrakk> |
400 \<Longrightarrow> (g ---> 0) F" |
400 \<Longrightarrow> (g ---> 0) F" |
401 by (simp add: Zfun_imp_Zfun tendsto_Zfun_iff) |
401 by (simp add: Zfun_imp_Zfun tendsto_Zfun_iff) |
402 |
402 |
403 subsubsection {* Distance and norms *} |
403 subsubsection \<open>Distance and norms\<close> |
404 |
404 |
405 lemma tendsto_dist [tendsto_intros]: |
405 lemma tendsto_dist [tendsto_intros]: |
406 fixes l m :: "'a :: metric_space" |
406 fixes l m :: "'a :: metric_space" |
407 assumes f: "(f ---> l) F" and g: "(g ---> m) F" |
407 assumes f: "(f ---> l) F" and g: "(g ---> m) F" |
408 shows "((\<lambda>x. dist (f x) (g x)) ---> dist l m) F" |
408 shows "((\<lambda>x. dist (f x) (g x)) ---> dist l m) F" |
479 |
479 |
480 lemma tendsto_rabs_zero_iff: |
480 lemma tendsto_rabs_zero_iff: |
481 "((\<lambda>x. \<bar>f x\<bar>) ---> (0::real)) F \<longleftrightarrow> (f ---> 0) F" |
481 "((\<lambda>x. \<bar>f x\<bar>) ---> (0::real)) F \<longleftrightarrow> (f ---> 0) F" |
482 by (fold real_norm_def, rule tendsto_norm_zero_iff) |
482 by (fold real_norm_def, rule tendsto_norm_zero_iff) |
483 |
483 |
484 subsubsection {* Addition and subtraction *} |
484 subsubsection \<open>Addition and subtraction\<close> |
485 |
485 |
486 lemma tendsto_add [tendsto_intros]: |
486 lemma tendsto_add [tendsto_intros]: |
487 fixes a b :: "'a::real_normed_vector" |
487 fixes a b :: "'a::real_normed_vector" |
488 shows "\<lbrakk>(f ---> a) F; (g ---> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x + g x) ---> a + b) F" |
488 shows "\<lbrakk>(f ---> a) F; (g ---> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x + g x) ---> a + b) F" |
489 by (simp only: tendsto_Zfun_iff add_diff_add Zfun_add) |
489 by (simp only: tendsto_Zfun_iff add_diff_add Zfun_add) |
562 shows "(\<And>i. i \<in> S \<Longrightarrow> continuous_on s (f i)) \<Longrightarrow> continuous_on s (\<lambda>x. \<Sum>i\<in>S. f i x)" |
562 shows "(\<And>i. i \<in> S \<Longrightarrow> continuous_on s (f i)) \<Longrightarrow> continuous_on s (\<lambda>x. \<Sum>i\<in>S. f i x)" |
563 unfolding continuous_on_def by (auto intro: tendsto_setsum) |
563 unfolding continuous_on_def by (auto intro: tendsto_setsum) |
564 |
564 |
565 lemmas real_tendsto_sandwich = tendsto_sandwich[where 'b=real] |
565 lemmas real_tendsto_sandwich = tendsto_sandwich[where 'b=real] |
566 |
566 |
567 subsubsection {* Linear operators and multiplication *} |
567 subsubsection \<open>Linear operators and multiplication\<close> |
568 |
568 |
569 lemma (in bounded_linear) tendsto: |
569 lemma (in bounded_linear) tendsto: |
570 "(g ---> a) F \<Longrightarrow> ((\<lambda>x. f (g x)) ---> f a) F" |
570 "(g ---> a) F \<Longrightarrow> ((\<lambda>x. f (g x)) ---> f a) F" |
571 by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun) |
571 by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun) |
572 |
572 |
677 lemma continuous_on_setprod [continuous_intros]: |
677 lemma continuous_on_setprod [continuous_intros]: |
678 fixes f :: "'a \<Rightarrow> _ \<Rightarrow> 'c::{real_normed_algebra,comm_ring_1}" |
678 fixes f :: "'a \<Rightarrow> _ \<Rightarrow> 'c::{real_normed_algebra,comm_ring_1}" |
679 shows "(\<And>i. i \<in> S \<Longrightarrow> continuous_on s (f i)) \<Longrightarrow> continuous_on s (\<lambda>x. \<Prod>i\<in>S. f i x)" |
679 shows "(\<And>i. i \<in> S \<Longrightarrow> continuous_on s (f i)) \<Longrightarrow> continuous_on s (\<lambda>x. \<Prod>i\<in>S. f i x)" |
680 unfolding continuous_on_def by (auto intro: tendsto_setprod) |
680 unfolding continuous_on_def by (auto intro: tendsto_setprod) |
681 |
681 |
682 subsubsection {* Inverse and division *} |
682 subsubsection \<open>Inverse and division\<close> |
683 |
683 |
684 lemma (in bounded_bilinear) Zfun_prod_Bfun: |
684 lemma (in bounded_bilinear) Zfun_prod_Bfun: |
685 assumes f: "Zfun f F" |
685 assumes f: "Zfun f F" |
686 assumes g: "Bfun g F" |
686 assumes g: "Bfun g F" |
687 shows "Zfun (\<lambda>x. f x ** g x) F" |
687 shows "Zfun (\<lambda>x. f x ** g x) F" |
888 fix x assume "max b (c + 1) \<le> norm (f x)" |
888 fix x assume "max b (c + 1) \<le> norm (f x)" |
889 with P show "P (f x)" by auto |
889 with P show "P (f x)" by auto |
890 qed |
890 qed |
891 qed force |
891 qed force |
892 |
892 |
893 subsection {* Relate @{const at}, @{const at_left} and @{const at_right} *} |
893 subsection \<open>Relate @{const at}, @{const at_left} and @{const at_right}\<close> |
894 |
894 |
895 text {* |
895 text \<open> |
896 |
896 |
897 This lemmas are useful for conversion between @{term "at x"} to @{term "at_left x"} and |
897 This lemmas are useful for conversion between @{term "at x"} to @{term "at_left x"} and |
898 @{term "at_right x"} and also @{term "at_right 0"}. |
898 @{term "at_right x"} and also @{term "at_right 0"}. |
899 |
899 |
900 *} |
900 \<close> |
901 |
901 |
902 lemmas filterlim_split_at_real = filterlim_split_at[where 'a=real] |
902 lemmas filterlim_split_at_real = filterlim_split_at[where 'a=real] |
903 |
903 |
904 lemma filtermap_nhds_shift: "filtermap (\<lambda>x. x - d) (nhds a) = nhds (a - d::'a::real_normed_vector)" |
904 lemma filtermap_nhds_shift: "filtermap (\<lambda>x. x - d) (nhds a) = nhds (a - d::'a::real_normed_vector)" |
905 by (rule filtermap_fun_inverse[where g="\<lambda>x. x + d"]) |
905 by (rule filtermap_fun_inverse[where g="\<lambda>x. x + d"]) |
989 proof safe |
989 proof safe |
990 fix r :: real assume "0 < r" |
990 fix r :: real assume "0 < r" |
991 show "\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> norm (inverse x :: 'a) < r" |
991 show "\<exists>b. \<forall>x. b \<le> norm x \<longrightarrow> norm (inverse x :: 'a) < r" |
992 proof (intro exI[of _ "inverse (r / 2)"] allI impI) |
992 proof (intro exI[of _ "inverse (r / 2)"] allI impI) |
993 fix x :: 'a |
993 fix x :: 'a |
994 from `0 < r` have "0 < inverse (r / 2)" by simp |
994 from \<open>0 < r\<close> have "0 < inverse (r / 2)" by simp |
995 also assume *: "inverse (r / 2) \<le> norm x" |
995 also assume *: "inverse (r / 2) \<le> norm x" |
996 finally show "norm (inverse x) < r" |
996 finally show "norm (inverse x) < r" |
997 using * `0 < r` by (subst nonzero_norm_inverse) (simp_all add: inverse_eq_divide field_simps) |
997 using * \<open>0 < r\<close> by (subst nonzero_norm_inverse) (simp_all add: inverse_eq_divide field_simps) |
998 qed |
998 qed |
999 qed |
999 qed |
1000 |
1000 |
1001 lemma filterlim_inverse_at_right_top: "LIM x at_top. inverse x :> at_right (0::real)" |
1001 lemma filterlim_inverse_at_right_top: "LIM x at_top. inverse x :> at_right (0::real)" |
1002 unfolding filterlim_at |
1002 unfolding filterlim_at |
1104 fixes l :: "'a :: {real_normed_field,field}" |
1104 fixes l :: "'a :: {real_normed_field,field}" |
1105 shows "((\<lambda>x. f(1 / x)) ---> l) (at (0::'a)) \<Longrightarrow> (f ---> l) at_infinity" |
1105 shows "((\<lambda>x. f(1 / x)) ---> l) (at (0::'a)) \<Longrightarrow> (f ---> l) at_infinity" |
1106 by (simp add: inverse_eq_divide lim_at_infinity_0 comp_def) |
1106 by (simp add: inverse_eq_divide lim_at_infinity_0 comp_def) |
1107 |
1107 |
1108 |
1108 |
1109 text {* |
1109 text \<open> |
1110 |
1110 |
1111 We only show rules for multiplication and addition when the functions are either against a real |
1111 We only show rules for multiplication and addition when the functions are either against a real |
1112 value or against infinity. Further rules are easy to derive by using @{thm filterlim_uminus_at_top}. |
1112 value or against infinity. Further rules are easy to derive by using @{thm filterlim_uminus_at_top}. |
1113 |
1113 |
1114 *} |
1114 \<close> |
1115 |
1115 |
1116 lemma filterlim_tendsto_pos_mult_at_top: |
1116 lemma filterlim_tendsto_pos_mult_at_top: |
1117 assumes f: "(f ---> c) F" and c: "0 < c" |
1117 assumes f: "(f ---> c) F" and c: "0 < c" |
1118 assumes g: "LIM x F. g x :> at_top" |
1118 assumes g: "LIM x F. g x :> at_top" |
1119 shows "LIM x F. (f x * g x :: real) :> at_top" |
1119 shows "LIM x F. (f x * g x :: real) :> at_top" |
1120 unfolding filterlim_at_top_gt[where c=0] |
1120 unfolding filterlim_at_top_gt[where c=0] |
1121 proof safe |
1121 proof safe |
1122 fix Z :: real assume "0 < Z" |
1122 fix Z :: real assume "0 < Z" |
1123 from f `0 < c` have "eventually (\<lambda>x. c / 2 < f x) F" |
1123 from f \<open>0 < c\<close> have "eventually (\<lambda>x. c / 2 < f x) F" |
1124 by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_elim1 |
1124 by (auto dest!: tendstoD[where e="c / 2"] elim!: eventually_elim1 |
1125 simp: dist_real_def abs_real_def split: split_if_asm) |
1125 simp: dist_real_def abs_real_def split: split_if_asm) |
1126 moreover from g have "eventually (\<lambda>x. (Z / c * 2) \<le> g x) F" |
1126 moreover from g have "eventually (\<lambda>x. (Z / c * 2) \<le> g x) F" |
1127 unfolding filterlim_at_top by auto |
1127 unfolding filterlim_at_top by auto |
1128 ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F" |
1128 ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F" |
1129 proof eventually_elim |
1129 proof eventually_elim |
1130 fix x assume "c / 2 < f x" "Z / c * 2 \<le> g x" |
1130 fix x assume "c / 2 < f x" "Z / c * 2 \<le> g x" |
1131 with `0 < Z` `0 < c` have "c / 2 * (Z / c * 2) \<le> f x * g x" |
1131 with \<open>0 < Z\<close> \<open>0 < c\<close> have "c / 2 * (Z / c * 2) \<le> f x * g x" |
1132 by (intro mult_mono) (auto simp: zero_le_divide_iff) |
1132 by (intro mult_mono) (auto simp: zero_le_divide_iff) |
1133 with `0 < c` show "Z \<le> f x * g x" |
1133 with \<open>0 < c\<close> show "Z \<le> f x * g x" |
1134 by simp |
1134 by simp |
1135 qed |
1135 qed |
1136 qed |
1136 qed |
1137 |
1137 |
1138 lemma filterlim_at_top_mult_at_top: |
1138 lemma filterlim_at_top_mult_at_top: |
1147 moreover from g have "eventually (\<lambda>x. Z \<le> g x) F" |
1147 moreover from g have "eventually (\<lambda>x. Z \<le> g x) F" |
1148 unfolding filterlim_at_top by auto |
1148 unfolding filterlim_at_top by auto |
1149 ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F" |
1149 ultimately show "eventually (\<lambda>x. Z \<le> f x * g x) F" |
1150 proof eventually_elim |
1150 proof eventually_elim |
1151 fix x assume "1 \<le> f x" "Z \<le> g x" |
1151 fix x assume "1 \<le> f x" "Z \<le> g x" |
1152 with `0 < Z` have "1 * Z \<le> f x * g x" |
1152 with \<open>0 < Z\<close> have "1 * Z \<le> f x * g x" |
1153 by (intro mult_mono) (auto simp: zero_le_divide_iff) |
1153 by (intro mult_mono) (auto simp: zero_le_divide_iff) |
1154 then show "Z \<le> f x * g x" |
1154 then show "Z \<le> f x * g x" |
1155 by simp |
1155 by simp |
1156 qed |
1156 qed |
1157 qed |
1157 qed |
1170 |
1170 |
1171 lemma filterlim_pow_at_top: |
1171 lemma filterlim_pow_at_top: |
1172 fixes f :: "real \<Rightarrow> real" |
1172 fixes f :: "real \<Rightarrow> real" |
1173 assumes "0 < n" and f: "LIM x F. f x :> at_top" |
1173 assumes "0 < n" and f: "LIM x F. f x :> at_top" |
1174 shows "LIM x F. (f x)^n :: real :> at_top" |
1174 shows "LIM x F. (f x)^n :: real :> at_top" |
1175 using `0 < n` proof (induct n) |
1175 using \<open>0 < n\<close> proof (induct n) |
1176 case (Suc n) with f show ?case |
1176 case (Suc n) with f show ?case |
1177 by (cases "n = 0") (auto intro!: filterlim_at_top_mult_at_top) |
1177 by (cases "n = 0") (auto intro!: filterlim_at_top_mult_at_top) |
1178 qed simp |
1178 qed simp |
1179 |
1179 |
1180 lemma filterlim_pow_at_bot_even: |
1180 lemma filterlim_pow_at_bot_even: |
1298 lemma Bseq_inverse: |
1298 lemma Bseq_inverse: |
1299 fixes a :: "'a::real_normed_div_algebra" |
1299 fixes a :: "'a::real_normed_div_algebra" |
1300 shows "\<lbrakk>X ----> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))" |
1300 shows "\<lbrakk>X ----> a; a \<noteq> 0\<rbrakk> \<Longrightarrow> Bseq (\<lambda>n. inverse (X n))" |
1301 by (rule Bfun_inverse) |
1301 by (rule Bfun_inverse) |
1302 |
1302 |
1303 text{* Transformation of limit. *} |
1303 text\<open>Transformation of limit.\<close> |
1304 |
1304 |
1305 lemma eventually_at2: |
1305 lemma eventually_at2: |
1306 "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" |
1306 "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" |
1307 unfolding eventually_at dist_nz by auto |
1307 unfolding eventually_at dist_nz by auto |
1308 |
1308 |
1344 show "eventually (\<lambda>x. f x = g x) (at x)" |
1344 show "eventually (\<lambda>x. f x = g x) (at x)" |
1345 unfolding eventually_at2 |
1345 unfolding eventually_at2 |
1346 using assms(1,2) by auto |
1346 using assms(1,2) by auto |
1347 qed |
1347 qed |
1348 |
1348 |
1349 text{* Common case assuming being away from some crucial point like 0. *} |
1349 text\<open>Common case assuming being away from some crucial point like 0.\<close> |
1350 |
1350 |
1351 lemma Lim_transform_away_within: |
1351 lemma Lim_transform_away_within: |
1352 fixes a b :: "'a::t1_space" |
1352 fixes a b :: "'a::t1_space" |
1353 assumes "a \<noteq> b" |
1353 assumes "a \<noteq> b" |
1354 and "\<forall>x\<in>S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1354 and "\<forall>x\<in>S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1367 and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1367 and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1368 and fl: "(f ---> l) (at a)" |
1368 and fl: "(f ---> l) (at a)" |
1369 shows "(g ---> l) (at a)" |
1369 shows "(g ---> l) (at a)" |
1370 using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl by simp |
1370 using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl by simp |
1371 |
1371 |
1372 text{* Alternatively, within an open set. *} |
1372 text\<open>Alternatively, within an open set.\<close> |
1373 |
1373 |
1374 lemma Lim_transform_within_open: |
1374 lemma Lim_transform_within_open: |
1375 assumes "open S" and "a \<in> S" |
1375 assumes "open S" and "a \<in> S" |
1376 and "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" |
1376 and "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" |
1377 and "(f ---> l) (at a)" |
1377 and "(f ---> l) (at a)" |
1400 assumes "a = b" "x = y" |
1400 assumes "a = b" "x = y" |
1401 and "\<And>x. x \<noteq> a \<Longrightarrow> f x = g x" |
1401 and "\<And>x. x \<noteq> a \<Longrightarrow> f x = g x" |
1402 shows "((\<lambda>x. f x) ---> x) (at a) \<longleftrightarrow> ((g ---> y) (at a))" |
1402 shows "((\<lambda>x. f x) ---> x) (at a) \<longleftrightarrow> ((g ---> y) (at a))" |
1403 unfolding tendsto_def eventually_at_topological |
1403 unfolding tendsto_def eventually_at_topological |
1404 using assms by simp |
1404 using assms by simp |
1405 text{*An unbounded sequence's inverse tends to 0*} |
1405 text\<open>An unbounded sequence's inverse tends to 0\<close> |
1406 |
1406 |
1407 lemma LIMSEQ_inverse_zero: |
1407 lemma LIMSEQ_inverse_zero: |
1408 "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> 0" |
1408 "\<forall>r::real. \<exists>N. \<forall>n\<ge>N. r < X n \<Longrightarrow> (\<lambda>n. inverse (X n)) ----> 0" |
1409 apply (rule filterlim_compose[OF tendsto_inverse_0]) |
1409 apply (rule filterlim_compose[OF tendsto_inverse_0]) |
1410 apply (simp add: filterlim_at_infinity[OF order_refl] eventually_sequentially) |
1410 apply (simp add: filterlim_at_infinity[OF order_refl] eventually_sequentially) |
1411 apply (metis abs_le_D1 linorder_le_cases linorder_not_le) |
1411 apply (metis abs_le_D1 linorder_le_cases linorder_not_le) |
1412 done |
1412 done |
1413 |
1413 |
1414 text{*The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity*} |
1414 text\<open>The sequence @{term "1/n"} tends to 0 as @{term n} tends to infinity\<close> |
1415 |
1415 |
1416 lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) ----> 0" |
1416 lemma LIMSEQ_inverse_real_of_nat: "(%n. inverse(real(Suc n))) ----> 0" |
1417 by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc |
1417 by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc |
1418 filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity) |
1418 filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity) |
1419 |
1419 |
1420 text{*The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to |
1420 text\<open>The sequence @{term "r + 1/n"} tends to @{term r} as @{term n} tends to |
1421 infinity is now easily proved*} |
1421 infinity is now easily proved\<close> |
1422 |
1422 |
1423 lemma LIMSEQ_inverse_real_of_nat_add: |
1423 lemma LIMSEQ_inverse_real_of_nat_add: |
1424 "(%n. r + inverse(real(Suc n))) ----> r" |
1424 "(%n. r + inverse(real(Suc n))) ----> r" |
1425 using tendsto_add [OF tendsto_const LIMSEQ_inverse_real_of_nat] by auto |
1425 using tendsto_add [OF tendsto_const LIMSEQ_inverse_real_of_nat] by auto |
1426 |
1426 |
1432 lemma LIMSEQ_inverse_real_of_nat_add_minus_mult: |
1432 lemma LIMSEQ_inverse_real_of_nat_add_minus_mult: |
1433 "(%n. r*( 1 + -inverse(real(Suc n)))) ----> r" |
1433 "(%n. r*( 1 + -inverse(real(Suc n)))) ----> r" |
1434 using tendsto_mult [OF tendsto_const LIMSEQ_inverse_real_of_nat_add_minus [of 1]] |
1434 using tendsto_mult [OF tendsto_const LIMSEQ_inverse_real_of_nat_add_minus [of 1]] |
1435 by auto |
1435 by auto |
1436 |
1436 |
1437 subsection {* Convergence on sequences *} |
1437 subsection \<open>Convergence on sequences\<close> |
1438 |
1438 |
1439 lemma convergent_add: |
1439 lemma convergent_add: |
1440 fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector" |
1440 fixes X Y :: "nat \<Rightarrow> 'a::real_normed_vector" |
1441 assumes "convergent (\<lambda>n. X n)" |
1441 assumes "convergent (\<lambda>n. X n)" |
1442 assumes "convergent (\<lambda>n. Y n)" |
1442 assumes "convergent (\<lambda>n. Y n)" |
1469 apply (auto dest: tendsto_minus) |
1469 apply (auto dest: tendsto_minus) |
1470 apply (drule tendsto_minus, auto) |
1470 apply (drule tendsto_minus, auto) |
1471 done |
1471 done |
1472 |
1472 |
1473 |
1473 |
1474 text {* A monotone sequence converges to its least upper bound. *} |
1474 text \<open>A monotone sequence converges to its least upper bound.\<close> |
1475 |
1475 |
1476 lemma LIMSEQ_incseq_SUP: |
1476 lemma LIMSEQ_incseq_SUP: |
1477 fixes X :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder, linorder_topology}" |
1477 fixes X :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder, linorder_topology}" |
1478 assumes u: "bdd_above (range X)" |
1478 assumes u: "bdd_above (range X)" |
1479 assumes X: "incseq X" |
1479 assumes X: "incseq X" |
1487 assumes X: "decseq X" |
1487 assumes X: "decseq X" |
1488 shows "X ----> (INF i. X i)" |
1488 shows "X ----> (INF i. X i)" |
1489 by (rule order_tendstoI) |
1489 by (rule order_tendstoI) |
1490 (auto simp: eventually_sequentially u cINF_less_iff intro: X[THEN decseqD] le_less_trans less_cINF_D[OF u]) |
1490 (auto simp: eventually_sequentially u cINF_less_iff intro: X[THEN decseqD] le_less_trans less_cINF_D[OF u]) |
1491 |
1491 |
1492 text{*Main monotonicity theorem*} |
1492 text\<open>Main monotonicity theorem\<close> |
1493 |
1493 |
1494 lemma Bseq_monoseq_convergent: "Bseq X \<Longrightarrow> monoseq X \<Longrightarrow> convergent (X::nat\<Rightarrow>real)" |
1494 lemma Bseq_monoseq_convergent: "Bseq X \<Longrightarrow> monoseq X \<Longrightarrow> convergent (X::nat\<Rightarrow>real)" |
1495 by (auto simp: monoseq_iff convergent_def intro: LIMSEQ_decseq_INF LIMSEQ_incseq_SUP dest: Bseq_bdd_above Bseq_bdd_below) |
1495 by (auto simp: monoseq_iff convergent_def intro: LIMSEQ_decseq_INF LIMSEQ_incseq_SUP dest: Bseq_bdd_above Bseq_bdd_below) |
1496 |
1496 |
1497 lemma Bseq_mono_convergent: "Bseq X \<Longrightarrow> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n) \<Longrightarrow> convergent (X::nat\<Rightarrow>real)" |
1497 lemma Bseq_mono_convergent: "Bseq X \<Longrightarrow> (\<forall>m n. m \<le> n \<longrightarrow> X m \<le> X n) \<Longrightarrow> convergent (X::nat\<Rightarrow>real)" |
1515 lemma incseq_convergent: |
1515 lemma incseq_convergent: |
1516 fixes X :: "nat \<Rightarrow> real" |
1516 fixes X :: "nat \<Rightarrow> real" |
1517 assumes "incseq X" and "\<forall>i. X i \<le> B" |
1517 assumes "incseq X" and "\<forall>i. X i \<le> B" |
1518 obtains L where "X ----> L" "\<forall>i. X i \<le> L" |
1518 obtains L where "X ----> L" "\<forall>i. X i \<le> L" |
1519 proof atomize_elim |
1519 proof atomize_elim |
1520 from incseq_bounded[OF assms] `incseq X` Bseq_monoseq_convergent[of X] |
1520 from incseq_bounded[OF assms] \<open>incseq X\<close> Bseq_monoseq_convergent[of X] |
1521 obtain L where "X ----> L" |
1521 obtain L where "X ----> L" |
1522 by (auto simp: convergent_def monoseq_def incseq_def) |
1522 by (auto simp: convergent_def monoseq_def incseq_def) |
1523 with `incseq X` show "\<exists>L. X ----> L \<and> (\<forall>i. X i \<le> L)" |
1523 with \<open>incseq X\<close> show "\<exists>L. X ----> L \<and> (\<forall>i. X i \<le> L)" |
1524 by (auto intro!: exI[of _ L] incseq_le) |
1524 by (auto intro!: exI[of _ L] incseq_le) |
1525 qed |
1525 qed |
1526 |
1526 |
1527 lemma decseq_convergent: |
1527 lemma decseq_convergent: |
1528 fixes X :: "nat \<Rightarrow> real" |
1528 fixes X :: "nat \<Rightarrow> real" |
1529 assumes "decseq X" and "\<forall>i. B \<le> X i" |
1529 assumes "decseq X" and "\<forall>i. B \<le> X i" |
1530 obtains L where "X ----> L" "\<forall>i. L \<le> X i" |
1530 obtains L where "X ----> L" "\<forall>i. L \<le> X i" |
1531 proof atomize_elim |
1531 proof atomize_elim |
1532 from decseq_bounded[OF assms] `decseq X` Bseq_monoseq_convergent[of X] |
1532 from decseq_bounded[OF assms] \<open>decseq X\<close> Bseq_monoseq_convergent[of X] |
1533 obtain L where "X ----> L" |
1533 obtain L where "X ----> L" |
1534 by (auto simp: convergent_def monoseq_def decseq_def) |
1534 by (auto simp: convergent_def monoseq_def decseq_def) |
1535 with `decseq X` show "\<exists>L. X ----> L \<and> (\<forall>i. L \<le> X i)" |
1535 with \<open>decseq X\<close> show "\<exists>L. X ----> L \<and> (\<forall>i. L \<le> X i)" |
1536 by (auto intro!: exI[of _ L] decseq_le) |
1536 by (auto intro!: exI[of _ L] decseq_le) |
1537 qed |
1537 qed |
1538 |
1538 |
1539 subsubsection {* Cauchy Sequences are Bounded *} |
1539 subsubsection \<open>Cauchy Sequences are Bounded\<close> |
1540 |
1540 |
1541 text{*A Cauchy sequence is bounded -- this is the standard |
1541 text\<open>A Cauchy sequence is bounded -- this is the standard |
1542 proof mechanization rather than the nonstandard proof*} |
1542 proof mechanization rather than the nonstandard proof\<close> |
1543 |
1543 |
1544 lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real) |
1544 lemma lemmaCauchy: "\<forall>n \<ge> M. norm (X M - X n) < (1::real) |
1545 ==> \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)" |
1545 ==> \<forall>n \<ge> M. norm (X n :: 'a::real_normed_vector) < 1 + norm (X M)" |
1546 apply (clarify, drule spec, drule (1) mp) |
1546 apply (clarify, drule spec, drule (1) mp) |
1547 apply (simp only: norm_minus_commute) |
1547 apply (simp only: norm_minus_commute) |
1548 apply (drule order_le_less_trans [OF norm_triangle_ineq2]) |
1548 apply (drule order_le_less_trans [OF norm_triangle_ineq2]) |
1549 apply simp |
1549 apply simp |
1550 done |
1550 done |
1551 |
1551 |
1552 subsection {* Power Sequences *} |
1552 subsection \<open>Power Sequences\<close> |
1553 |
1553 |
1554 text{*The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term |
1554 text\<open>The sequence @{term "x^n"} tends to 0 if @{term "0\<le>x"} and @{term |
1555 "x<1"}. Proof will use (NS) Cauchy equivalence for convergence and |
1555 "x<1"}. Proof will use (NS) Cauchy equivalence for convergence and |
1556 also fact that bounded and monotonic sequence converges.*} |
1556 also fact that bounded and monotonic sequence converges.\<close> |
1557 |
1557 |
1558 lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)" |
1558 lemma Bseq_realpow: "[| 0 \<le> (x::real); x \<le> 1 |] ==> Bseq (%n. x ^ n)" |
1559 apply (simp add: Bseq_def) |
1559 apply (simp add: Bseq_def) |
1560 apply (rule_tac x = 1 in exI) |
1560 apply (rule_tac x = 1 in exI) |
1561 apply (simp add: power_abs) |
1561 apply (simp add: power_abs) |
1596 done |
1596 done |
1597 |
1597 |
1598 lemma LIMSEQ_divide_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. a / (x ^ n) :: real) ----> 0" |
1598 lemma LIMSEQ_divide_realpow_zero: "1 < x \<Longrightarrow> (\<lambda>n. a / (x ^ n) :: real) ----> 0" |
1599 by (rule tendsto_divide_0 [OF tendsto_const filterlim_realpow_sequentially_gt1]) simp |
1599 by (rule tendsto_divide_0 [OF tendsto_const filterlim_realpow_sequentially_gt1]) simp |
1600 |
1600 |
1601 text{*Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}*} |
1601 text\<open>Limit of @{term "c^n"} for @{term"\<bar>c\<bar> < 1"}\<close> |
1602 |
1602 |
1603 lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. \<bar>c\<bar> ^ n :: real) ----> 0" |
1603 lemma LIMSEQ_rabs_realpow_zero: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. \<bar>c\<bar> ^ n :: real) ----> 0" |
1604 by (rule LIMSEQ_realpow_zero [OF abs_ge_zero]) |
1604 by (rule LIMSEQ_realpow_zero [OF abs_ge_zero]) |
1605 |
1605 |
1606 lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. c ^ n :: real) ----> 0" |
1606 lemma LIMSEQ_rabs_realpow_zero2: "\<bar>c\<bar> < 1 \<Longrightarrow> (\<lambda>n. c ^ n :: real) ----> 0" |
1607 by (rule LIMSEQ_power_zero) simp |
1607 by (rule LIMSEQ_power_zero) simp |
1608 |
1608 |
1609 |
1609 |
1610 subsection {* Limits of Functions *} |
1610 subsection \<open>Limits of Functions\<close> |
1611 |
1611 |
1612 lemma LIM_eq: |
1612 lemma LIM_eq: |
1613 fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector" |
1613 fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector" |
1614 shows "f -- a --> L = |
1614 shows "f -- a --> L = |
1615 (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)" |
1615 (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)" |
1775 lemma isCont_setsum [simp]: |
1775 lemma isCont_setsum [simp]: |
1776 fixes f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::real_normed_vector" |
1776 fixes f :: "'a \<Rightarrow> 'b::t2_space \<Rightarrow> 'c::real_normed_vector" |
1777 shows "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a" |
1777 shows "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a" |
1778 by (auto intro: continuous_setsum) |
1778 by (auto intro: continuous_setsum) |
1779 |
1779 |
1780 subsection {* Uniform Continuity *} |
1780 subsection \<open>Uniform Continuity\<close> |
1781 |
1781 |
1782 definition |
1782 definition |
1783 isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where |
1783 isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where |
1784 "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)" |
1784 "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)" |
1785 |
1785 |
1821 fixes f :: "real \<Rightarrow> real" |
1821 fixes f :: "real \<Rightarrow> real" |
1822 assumes ev: "b < x" "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and "isCont f x" |
1822 assumes ev: "b < x" "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and "isCont f x" |
1823 shows "0 \<le> f x" |
1823 shows "0 \<le> f x" |
1824 proof (rule tendsto_le_const) |
1824 proof (rule tendsto_le_const) |
1825 show "(f ---> f x) (at_left x)" |
1825 show "(f ---> f x) (at_left x)" |
1826 using `isCont f x` by (simp add: filterlim_at_split isCont_def) |
1826 using \<open>isCont f x\<close> by (simp add: filterlim_at_split isCont_def) |
1827 show "eventually (\<lambda>x. 0 \<le> f x) (at_left x)" |
1827 show "eventually (\<lambda>x. 0 \<le> f x) (at_left x)" |
1828 using ev by (auto simp: eventually_at dist_real_def intro!: exI[of _ "x - b"]) |
1828 using ev by (auto simp: eventually_at dist_real_def intro!: exI[of _ "x - b"]) |
1829 qed simp |
1829 qed simp |
1830 |
1830 |
1831 |
1831 |
1832 subsection {* Nested Intervals and Bisection -- Needed for Compactness *} |
1832 subsection \<open>Nested Intervals and Bisection -- Needed for Compactness\<close> |
1833 |
1833 |
1834 lemma nested_sequence_unique: |
1834 lemma nested_sequence_unique: |
1835 assumes "\<forall>n. f n \<le> f (Suc n)" "\<forall>n. g (Suc n) \<le> g n" "\<forall>n. f n \<le> g n" "(\<lambda>n. f n - g n) ----> 0" |
1835 assumes "\<forall>n. f n \<le> f (Suc n)" "\<forall>n. g (Suc n) \<le> g n" "\<forall>n. f n \<le> g n" "(\<lambda>n. f n - g n) ----> 0" |
1836 shows "\<exists>l::real. ((\<forall>n. f n \<le> l) \<and> f ----> l) \<and> ((\<forall>n. l \<le> g n) \<and> g ----> l)" |
1836 shows "\<exists>l::real. ((\<forall>n. f n \<le> l) \<and> f ----> l) \<and> ((\<forall>n. l \<le> g n) \<and> g ----> l)" |
1837 proof - |
1837 proof - |
1838 have "incseq f" unfolding incseq_Suc_iff by fact |
1838 have "incseq f" unfolding incseq_Suc_iff by fact |
1839 have "decseq g" unfolding decseq_Suc_iff by fact |
1839 have "decseq g" unfolding decseq_Suc_iff by fact |
1840 |
1840 |
1841 { fix n |
1841 { fix n |
1842 from `decseq g` have "g n \<le> g 0" by (rule decseqD) simp |
1842 from \<open>decseq g\<close> have "g n \<le> g 0" by (rule decseqD) simp |
1843 with `\<forall>n. f n \<le> g n`[THEN spec, of n] have "f n \<le> g 0" by auto } |
1843 with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] have "f n \<le> g 0" by auto } |
1844 then obtain u where "f ----> u" "\<forall>i. f i \<le> u" |
1844 then obtain u where "f ----> u" "\<forall>i. f i \<le> u" |
1845 using incseq_convergent[OF `incseq f`] by auto |
1845 using incseq_convergent[OF \<open>incseq f\<close>] by auto |
1846 moreover |
1846 moreover |
1847 { fix n |
1847 { fix n |
1848 from `incseq f` have "f 0 \<le> f n" by (rule incseqD) simp |
1848 from \<open>incseq f\<close> have "f 0 \<le> f n" by (rule incseqD) simp |
1849 with `\<forall>n. f n \<le> g n`[THEN spec, of n] have "f 0 \<le> g n" by simp } |
1849 with \<open>\<forall>n. f n \<le> g n\<close>[THEN spec, of n] have "f 0 \<le> g n" by simp } |
1850 then obtain l where "g ----> l" "\<forall>i. l \<le> g i" |
1850 then obtain l where "g ----> l" "\<forall>i. l \<le> g i" |
1851 using decseq_convergent[OF `decseq g`] by auto |
1851 using decseq_convergent[OF \<open>decseq g\<close>] by auto |
1852 moreover note LIMSEQ_unique[OF assms(4) tendsto_diff[OF `f ----> u` `g ----> l`]] |
1852 moreover note LIMSEQ_unique[OF assms(4) tendsto_diff[OF \<open>f ----> u\<close> \<open>g ----> l\<close>]] |
1853 ultimately show ?thesis by auto |
1853 ultimately show ?thesis by auto |
1854 qed |
1854 qed |
1855 |
1855 |
1856 lemma Bolzano[consumes 1, case_names trans local]: |
1856 lemma Bolzano[consumes 1, case_names trans local]: |
1857 fixes P :: "real \<Rightarrow> real \<Rightarrow> bool" |
1857 fixes P :: "real \<Rightarrow> real \<Rightarrow> bool" |
1875 { fix n have "l n - u n = (a - b) / 2^n" by (induct n) (auto simp: field_simps) } |
1875 { fix n have "l n - u n = (a - b) / 2^n" by (induct n) (auto simp: field_simps) } |
1876 then show "(\<lambda>n. l n - u n) ----> 0" by (simp add: LIMSEQ_divide_realpow_zero) |
1876 then show "(\<lambda>n. l n - u n) ----> 0" by (simp add: LIMSEQ_divide_realpow_zero) |
1877 qed fact |
1877 qed fact |
1878 then obtain x where x: "\<And>n. l n \<le> x" "\<And>n. x \<le> u n" and "l ----> x" "u ----> x" by auto |
1878 then obtain x where x: "\<And>n. l n \<le> x" "\<And>n. x \<le> u n" and "l ----> x" "u ----> x" by auto |
1879 obtain d where "0 < d" and d: "\<And>a b. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> b - a < d \<Longrightarrow> P a b" |
1879 obtain d where "0 < d" and d: "\<And>a b. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> b - a < d \<Longrightarrow> P a b" |
1880 using `l 0 \<le> x` `x \<le> u 0` local[of x] by auto |
1880 using \<open>l 0 \<le> x\<close> \<open>x \<le> u 0\<close> local[of x] by auto |
1881 |
1881 |
1882 show "P a b" |
1882 show "P a b" |
1883 proof (rule ccontr) |
1883 proof (rule ccontr) |
1884 assume "\<not> P a b" |
1884 assume "\<not> P a b" |
1885 { fix n have "\<not> P (l n) (u n)" |
1885 { fix n have "\<not> P (l n) (u n)" |
1886 proof (induct n) |
1886 proof (induct n) |
1887 case (Suc n) with trans[of "l n" "(l n + u n) / 2" "u n"] show ?case by auto |
1887 case (Suc n) with trans[of "l n" "(l n + u n) / 2" "u n"] show ?case by auto |
1888 qed (simp add: `\<not> P a b`) } |
1888 qed (simp add: \<open>\<not> P a b\<close>) } |
1889 moreover |
1889 moreover |
1890 { have "eventually (\<lambda>n. x - d / 2 < l n) sequentially" |
1890 { have "eventually (\<lambda>n. x - d / 2 < l n) sequentially" |
1891 using `0 < d` `l ----> x` by (intro order_tendstoD[of _ x]) auto |
1891 using \<open>0 < d\<close> \<open>l ----> x\<close> by (intro order_tendstoD[of _ x]) auto |
1892 moreover have "eventually (\<lambda>n. u n < x + d / 2) sequentially" |
1892 moreover have "eventually (\<lambda>n. u n < x + d / 2) sequentially" |
1893 using `0 < d` `u ----> x` by (intro order_tendstoD[of _ x]) auto |
1893 using \<open>0 < d\<close> \<open>u ----> x\<close> by (intro order_tendstoD[of _ x]) auto |
1894 ultimately have "eventually (\<lambda>n. P (l n) (u n)) sequentially" |
1894 ultimately have "eventually (\<lambda>n. P (l n) (u n)) sequentially" |
1895 proof eventually_elim |
1895 proof eventually_elim |
1896 fix n assume "x - d / 2 < l n" "u n < x + d / 2" |
1896 fix n assume "x - d / 2 < l n" "u n < x + d / 2" |
1897 from add_strict_mono[OF this] have "u n - l n < d" by simp |
1897 from add_strict_mono[OF this] have "u n - l n < d" by simp |
1898 with x show "P (l n) (u n)" by (rule d) |
1898 with x show "P (l n) (u n)" by (rule d) |
1930 defines "S \<equiv> {a..b}" |
1930 defines "S \<equiv> {a..b}" |
1931 assumes "a \<le> b" and f: "continuous_on S f" |
1931 assumes "a \<le> b" and f: "continuous_on S f" |
1932 shows "\<exists>c d. f`S = {c..d} \<and> c \<le> d" |
1932 shows "\<exists>c d. f`S = {c..d} \<and> c \<le> d" |
1933 proof - |
1933 proof - |
1934 have S: "compact S" "S \<noteq> {}" |
1934 have S: "compact S" "S \<noteq> {}" |
1935 using `a \<le> b` by (auto simp: S_def) |
1935 using \<open>a \<le> b\<close> by (auto simp: S_def) |
1936 obtain c where "c \<in> S" "\<forall>d\<in>S. f d \<le> f c" |
1936 obtain c where "c \<in> S" "\<forall>d\<in>S. f d \<le> f c" |
1937 using continuous_attains_sup[OF S f] by auto |
1937 using continuous_attains_sup[OF S f] by auto |
1938 moreover obtain d where "d \<in> S" "\<forall>c\<in>S. f d \<le> f c" |
1938 moreover obtain d where "d \<in> S" "\<forall>c\<in>S. f d \<le> f c" |
1939 using continuous_attains_inf[OF S f] by auto |
1939 using continuous_attains_inf[OF S f] by auto |
1940 moreover have "connected (f`S)" |
1940 moreover have "connected (f`S)" |
1943 by (auto simp: connected_iff_interval) |
1943 by (auto simp: connected_iff_interval) |
1944 then show ?thesis |
1944 then show ?thesis |
1945 by auto |
1945 by auto |
1946 qed |
1946 qed |
1947 |
1947 |
1948 subsection {* Boundedness of continuous functions *} |
1948 subsection \<open>Boundedness of continuous functions\<close> |
1949 |
1949 |
1950 text{*By bisection, function continuous on closed interval is bounded above*} |
1950 text\<open>By bisection, function continuous on closed interval is bounded above\<close> |
1951 |
1951 |
1952 lemma isCont_eq_Ub: |
1952 lemma isCont_eq_Ub: |
1953 fixes f :: "real \<Rightarrow> 'a::linorder_topology" |
1953 fixes f :: "real \<Rightarrow> 'a::linorder_topology" |
1954 shows "a \<le> b \<Longrightarrow> \<forall>x::real. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow> |
1954 shows "a \<le> b \<Longrightarrow> \<forall>x::real. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow> |
1955 \<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)" |
1955 \<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)" |
2054 shows "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z; |
2054 shows "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z; |
2055 \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |] |
2055 \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |] |
2056 ==> isCont g (f x)" |
2056 ==> isCont g (f x)" |
2057 by (rule isCont_inverse_function) |
2057 by (rule isCont_inverse_function) |
2058 |
2058 |
2059 text{*Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110*} |
2059 text\<open>Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110\<close> |
2060 lemma LIM_fun_gt_zero: |
2060 lemma LIM_fun_gt_zero: |
2061 fixes f :: "real \<Rightarrow> real" |
2061 fixes f :: "real \<Rightarrow> real" |
2062 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)" |
2062 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)" |
2063 apply (drule (1) LIM_D, clarify) |
2063 apply (drule (1) LIM_D, clarify) |
2064 apply (rule_tac x = s in exI) |
2064 apply (rule_tac x = s in exI) |