1490 qed |
1490 qed |
1491 |
1491 |
1492 text{* It's also sometimes useful to extract the limit point from the net. *} |
1492 text{* It's also sometimes useful to extract the limit point from the net. *} |
1493 |
1493 |
1494 definition |
1494 definition |
1495 netlimit :: "'a::metric_space net \<Rightarrow> 'a" where |
1495 netlimit :: "'a::t2_space net \<Rightarrow> 'a" where |
1496 "netlimit net = (SOME a. \<forall>r>0. eventually (\<lambda>x. dist x a < r) net)" |
1496 "netlimit net = (SOME a. ((\<lambda>x. x) ---> a) net)" |
1497 |
1497 |
1498 lemma netlimit_within: |
1498 lemma netlimit_within: |
1499 assumes "\<not> trivial_limit (at a within S)" |
1499 assumes "\<not> trivial_limit (at a within S)" |
1500 shows "netlimit (at a within S) = a" |
1500 shows "netlimit (at a within S) = a" |
1501 using assms |
1501 unfolding netlimit_def |
1502 apply (simp add: trivial_limit_within) |
1502 apply (rule some_equality) |
1503 apply (simp add: netlimit_def eventually_within zero_less_dist_iff) |
1503 apply (rule Lim_at_within) |
1504 apply (rule some_equality, fast) |
1504 apply (rule Lim_ident_at) |
1505 apply (rename_tac b) |
1505 apply (erule Lim_unique [OF assms]) |
1506 apply (rule ccontr) |
1506 apply (rule Lim_at_within) |
1507 apply (drule_tac x="dist b a / 2" in spec, drule mp, simp add: dist_nz) |
1507 apply (rule Lim_ident_at) |
1508 apply (clarify, rename_tac r) |
|
1509 apply (simp only: islimpt_approachable) |
|
1510 apply (drule_tac x="min r (dist b a / 2)" in spec, drule mp, simp add: dist_nz) |
|
1511 apply (clarify) |
|
1512 apply (drule_tac x=x' in bspec, simp) |
|
1513 apply (drule mp, simp) |
|
1514 apply (subgoal_tac "dist b a < dist b a / 2 + dist b a / 2", simp) |
|
1515 apply (rule le_less_trans [OF dist_triangle3]) |
|
1516 apply (erule add_strict_mono) |
|
1517 apply simp |
|
1518 done |
1508 done |
1519 |
1509 |
1520 lemma netlimit_at: |
1510 lemma netlimit_at: |
1521 fixes a :: "'a::perfect_space" |
1511 fixes a :: "'a::perfect_space" |
1522 shows "netlimit (at a) = a" |
1512 shows "netlimit (at a) = a" |
3142 qed |
3132 qed |
3143 |
3133 |
3144 subsection{* Define continuity over a net to take in restrictions of the set. *} |
3134 subsection{* Define continuity over a net to take in restrictions of the set. *} |
3145 |
3135 |
3146 definition |
3136 definition |
3147 continuous :: "'a::metric_space net \<Rightarrow> ('a \<Rightarrow> 'b::metric_space) \<Rightarrow> bool" where |
3137 continuous :: "'a::t2_space net \<Rightarrow> ('a \<Rightarrow> 'b::topological_space) \<Rightarrow> bool" where |
3148 "continuous net f \<longleftrightarrow> (f ---> f(netlimit net)) net" |
3138 "continuous net f \<longleftrightarrow> (f ---> f(netlimit net)) net" |
3149 (* FIXME: generalize 'b to topological_space *) |
|
3150 |
3139 |
3151 lemma continuous_trivial_limit: |
3140 lemma continuous_trivial_limit: |
3152 "trivial_limit net ==> continuous net f" |
3141 "trivial_limit net ==> continuous net f" |
3153 unfolding continuous_def tendsto_iff trivial_limit_eq by auto |
3142 unfolding continuous_def tendsto_def trivial_limit_eq by auto |
3154 |
3143 |
3155 lemma continuous_within: "continuous (at x within s) f \<longleftrightarrow> (f ---> f(x)) (at x within s)" |
3144 lemma continuous_within: "continuous (at x within s) f \<longleftrightarrow> (f ---> f(x)) (at x within s)" |
3156 unfolding continuous_def |
3145 unfolding continuous_def |
3157 unfolding tendsto_iff |
3146 unfolding tendsto_def |
3158 using netlimit_within[of x s] |
3147 using netlimit_within[of x s] |
3159 by (cases "trivial_limit (at x within s)") (auto simp add: trivial_limit_eventually) |
3148 by (cases "trivial_limit (at x within s)") (auto simp add: trivial_limit_eventually) |
3160 |
3149 |
3161 lemma continuous_at: "continuous (at x) f \<longleftrightarrow> (f ---> f(x)) (at x)" |
3150 lemma continuous_at: "continuous (at x) f \<longleftrightarrow> (f ---> f(x)) (at x)" |
3162 using continuous_within [of x UNIV f] by (simp add: within_UNIV) |
3151 using continuous_within [of x UNIV f] by (simp add: within_UNIV) |
3163 |
3152 |
3164 lemma continuous_at_within: |
3153 lemma continuous_at_within: |
3165 fixes x :: "'a::perfect_space" |
|
3166 assumes "continuous (at x) f" shows "continuous (at x within s) f" |
3154 assumes "continuous (at x) f" shows "continuous (at x within s) f" |
3167 (* FIXME: generalize *) |
3155 using assms unfolding continuous_at continuous_within |
3168 proof(cases "x islimpt s") |
3156 by (rule Lim_at_within) |
3169 case True show ?thesis using assms unfolding continuous_def and netlimit_at |
|
3170 using Lim_at_within[of f "f x" "at x" s] |
|
3171 unfolding netlimit_within[unfolded trivial_limit_within not_not, OF True] by blast |
|
3172 next |
|
3173 case False thus ?thesis unfolding continuous_def and netlimit_at |
|
3174 unfolding Lim and trivial_limit_within by auto |
|
3175 qed |
|
3176 |
3157 |
3177 text{* Derive the epsilon-delta forms, which we often use as "definitions" *} |
3158 text{* Derive the epsilon-delta forms, which we often use as "definitions" *} |
3178 |
3159 |
3179 lemma continuous_within_eps_delta: |
3160 lemma continuous_within_eps_delta: |
3180 "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x'\<in> s. dist x' x < d --> dist (f x') (f x) < e)" |
3161 "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x'\<in> s. dist x' x < d --> dist (f x') (f x) < e)" |
3302 ==> continuous_on s g" |
3283 ==> continuous_on s g" |
3303 by (simp add: continuous_on_def) |
3284 by (simp add: continuous_on_def) |
3304 |
3285 |
3305 text{* Characterization of various kinds of continuity in terms of sequences. *} |
3286 text{* Characterization of various kinds of continuity in terms of sequences. *} |
3306 |
3287 |
|
3288 (* \<longrightarrow> could be generalized, but \<longleftarrow> requires metric space *) |
3307 lemma continuous_within_sequentially: |
3289 lemma continuous_within_sequentially: |
3308 "continuous (at a within s) f \<longleftrightarrow> |
3290 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" |
|
3291 shows "continuous (at a within s) f \<longleftrightarrow> |
3309 (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially |
3292 (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially |
3310 --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") |
3293 --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") |
3311 proof |
3294 proof |
3312 assume ?lhs |
3295 assume ?lhs |
3313 { fix x::"nat \<Rightarrow> 'a" assume x:"\<forall>n. x n \<in> s" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (x n) a < e" |
3296 { fix x::"nat \<Rightarrow> 'a" assume x:"\<forall>n. x n \<in> s" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (x n) a < e" |
3343 } |
3326 } |
3344 thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast |
3327 thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast |
3345 qed |
3328 qed |
3346 |
3329 |
3347 lemma continuous_at_sequentially: |
3330 lemma continuous_at_sequentially: |
3348 "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially |
3331 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" |
|
3332 shows "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially |
3349 --> ((f o x) ---> f a) sequentially)" |
3333 --> ((f o x) ---> f a) sequentially)" |
3350 using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto |
3334 using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto |
3351 |
3335 |
3352 lemma continuous_on_sequentially: |
3336 lemma continuous_on_sequentially: |
3353 "continuous_on s f \<longleftrightarrow> (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially |
3337 "continuous_on s f \<longleftrightarrow> (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially |
3443 |
3427 |
3444 lemma continuous_const: "continuous net (\<lambda>x. c)" |
3428 lemma continuous_const: "continuous net (\<lambda>x. c)" |
3445 by (auto simp add: continuous_def Lim_const) |
3429 by (auto simp add: continuous_def Lim_const) |
3446 |
3430 |
3447 lemma continuous_cmul: |
3431 lemma continuous_cmul: |
3448 fixes f :: "'a::metric_space \<Rightarrow> real ^ 'n::finite" |
3432 fixes f :: "'a::t2_space \<Rightarrow> real ^ 'n::finite" |
3449 shows "continuous net f ==> continuous net (\<lambda>x. c *\<^sub>R f x)" |
3433 shows "continuous net f ==> continuous net (\<lambda>x. c *\<^sub>R f x)" |
3450 by (auto simp add: continuous_def Lim_cmul) |
3434 by (auto simp add: continuous_def Lim_cmul) |
3451 |
3435 |
3452 lemma continuous_neg: |
3436 lemma continuous_neg: |
3453 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" |
3437 fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" |
3454 shows "continuous net f ==> continuous net (\<lambda>x. -(f x))" |
3438 shows "continuous net f ==> continuous net (\<lambda>x. -(f x))" |
3455 by (auto simp add: continuous_def Lim_neg) |
3439 by (auto simp add: continuous_def Lim_neg) |
3456 |
3440 |
3457 lemma continuous_add: |
3441 lemma continuous_add: |
3458 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" |
3442 fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" |
3459 shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x + g x)" |
3443 shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x + g x)" |
3460 by (auto simp add: continuous_def Lim_add) |
3444 by (auto simp add: continuous_def Lim_add) |
3461 |
3445 |
3462 lemma continuous_sub: |
3446 lemma continuous_sub: |
3463 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" |
3447 fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" |
3464 shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x - g x)" |
3448 shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x - g x)" |
3465 by (auto simp add: continuous_def Lim_sub) |
3449 by (auto simp add: continuous_def Lim_sub) |
3466 |
3450 |
3467 text{* Same thing for setwise continuity. *} |
3451 text{* Same thing for setwise continuity. *} |
3468 |
3452 |
3545 |
3529 |
3546 text{* Identity function is continuous in every sense. *} |
3530 text{* Identity function is continuous in every sense. *} |
3547 |
3531 |
3548 lemma continuous_within_id: |
3532 lemma continuous_within_id: |
3549 "continuous (at a within s) (\<lambda>x. x)" |
3533 "continuous (at a within s) (\<lambda>x. x)" |
3550 unfolding continuous_within Lim_within by auto |
3534 unfolding continuous_within by (rule Lim_at_within [OF Lim_ident_at]) |
3551 |
3535 |
3552 lemma continuous_at_id: |
3536 lemma continuous_at_id: |
3553 "continuous (at a) (\<lambda>x. x)" |
3537 "continuous (at a) (\<lambda>x. x)" |
3554 unfolding continuous_at Lim_at by auto |
3538 unfolding continuous_at by (rule Lim_ident_at) |
3555 |
3539 |
3556 lemma continuous_on_id: |
3540 lemma continuous_on_id: |
3557 "continuous_on s (\<lambda>x. x)" |
3541 "continuous_on s (\<lambda>x. x)" |
3558 unfolding continuous_on Lim_within by auto |
3542 unfolding continuous_on Lim_within by auto |
3559 |
3543 |
3562 unfolding uniformly_continuous_on_def by auto |
3546 unfolding uniformly_continuous_on_def by auto |
3563 |
3547 |
3564 text{* Continuity of all kinds is preserved under composition. *} |
3548 text{* Continuity of all kinds is preserved under composition. *} |
3565 |
3549 |
3566 lemma continuous_within_compose: |
3550 lemma continuous_within_compose: |
|
3551 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
|
3552 fixes g :: "'b::metric_space \<Rightarrow> 'c::metric_space" |
3567 assumes "continuous (at x within s) f" "continuous (at (f x) within f ` s) g" |
3553 assumes "continuous (at x within s) f" "continuous (at (f x) within f ` s) g" |
3568 shows "continuous (at x within s) (g o f)" |
3554 shows "continuous (at x within s) (g o f)" |
3569 proof- |
3555 proof- |
3570 { fix e::real assume "e>0" |
3556 { fix e::real assume "e>0" |
3571 with assms(2)[unfolded continuous_within Lim_within] obtain d where "d>0" and d:"\<forall>xa\<in>f ` s. 0 < dist xa (f x) \<and> dist xa (f x) < d \<longrightarrow> dist (g xa) (g (f x)) < e" by auto |
3557 with assms(2)[unfolded continuous_within Lim_within] obtain d where "d>0" and d:"\<forall>xa\<in>f ` s. 0 < dist xa (f x) \<and> dist xa (f x) < d \<longrightarrow> dist (g xa) (g (f x)) < e" by auto |
3576 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (g (f xa)) (g (f x)) < e" using `d'>0` by auto } |
3562 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (g (f xa)) (g (f x)) < e" using `d'>0` by auto } |
3577 thus ?thesis unfolding continuous_within Lim_within by auto |
3563 thus ?thesis unfolding continuous_within Lim_within by auto |
3578 qed |
3564 qed |
3579 |
3565 |
3580 lemma continuous_at_compose: |
3566 lemma continuous_at_compose: |
|
3567 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
|
3568 fixes g :: "'b::metric_space \<Rightarrow> 'c::metric_space" |
3581 assumes "continuous (at x) f" "continuous (at (f x)) g" |
3569 assumes "continuous (at x) f" "continuous (at (f x)) g" |
3582 shows "continuous (at x) (g o f)" |
3570 shows "continuous (at x) (g o f)" |
3583 proof- |
3571 proof- |
3584 have " continuous (at (f x) within range f) g" using assms(2) using continuous_within_subset[of "f x" UNIV g "range f", unfolded within_UNIV] by auto |
3572 have " continuous (at (f x) within range f) g" using assms(2) using continuous_within_subset[of "f x" UNIV g "range f", unfolded within_UNIV] by auto |
3585 thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto |
3573 thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto |
3601 qed |
3589 qed |
3602 |
3590 |
3603 text{* Continuity in terms of open preimages. *} |
3591 text{* Continuity in terms of open preimages. *} |
3604 |
3592 |
3605 lemma continuous_at_open: |
3593 lemma continuous_at_open: |
3606 "continuous (at x) f \<longleftrightarrow> (\<forall>t. open t \<and> f x \<in> t --> (\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x' \<in> s. (f x') \<in> t)))" (is "?lhs = ?rhs") |
3594 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
|
3595 shows "continuous (at x) f \<longleftrightarrow> (\<forall>t. open t \<and> f x \<in> t --> (\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x' \<in> s. (f x') \<in> t)))" (is "?lhs = ?rhs") |
3607 proof |
3596 proof |
3608 assume ?lhs |
3597 assume ?lhs |
3609 { fix t assume as: "open t" "f x \<in> t" |
3598 { fix t assume as: "open t" "f x \<in> t" |
3610 then obtain e where "e>0" and e:"ball (f x) e \<subseteq> t" unfolding open_contains_ball by auto |
3599 then obtain e where "e>0" and e:"ball (f x) e \<subseteq> t" unfolding open_contains_ball by auto |
3611 |
3600 |
3730 using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto |
3719 using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto |
3731 thus ?thesis using closed_Int[of s T, OF assms(2)] by auto |
3720 thus ?thesis using closed_Int[of s T, OF assms(2)] by auto |
3732 qed |
3721 qed |
3733 |
3722 |
3734 lemma continuous_open_preimage_univ: |
3723 lemma continuous_open_preimage_univ: |
3735 "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}" |
3724 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
|
3725 shows "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}" |
3736 using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto |
3726 using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto |
3737 |
3727 |
3738 lemma continuous_closed_preimage_univ: |
3728 lemma continuous_closed_preimage_univ: |
3739 "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}" |
3729 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
|
3730 shows "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}" |
3740 using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto |
3731 using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto |
3741 |
3732 |
3742 text{* Equality of continuous functions on closure and related results. *} |
3733 text{* Equality of continuous functions on closure and related results. *} |
3743 |
3734 |
3744 lemma continuous_closed_in_preimage_constant: |
3735 lemma continuous_closed_in_preimage_constant: |
3780 qed |
3771 qed |
3781 |
3772 |
3782 text{* Making a continuous function avoid some value in a neighbourhood. *} |
3773 text{* Making a continuous function avoid some value in a neighbourhood. *} |
3783 |
3774 |
3784 lemma continuous_within_avoid: |
3775 lemma continuous_within_avoid: |
|
3776 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
3785 assumes "continuous (at x within s) f" "x \<in> s" "f x \<noteq> a" |
3777 assumes "continuous (at x within s) f" "x \<in> s" "f x \<noteq> a" |
3786 shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e --> f y \<noteq> a" |
3778 shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e --> f y \<noteq> a" |
3787 proof- |
3779 proof- |
3788 obtain d where "d>0" and d:"\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < dist (f x) a" |
3780 obtain d where "d>0" and d:"\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < dist (f x) a" |
3789 using assms(1)[unfolded continuous_within Lim_within, THEN spec[where x="dist (f x) a"]] assms(3)[unfolded dist_nz] by auto |
3781 using assms(1)[unfolded continuous_within Lim_within, THEN spec[where x="dist (f x) a"]] assms(3)[unfolded dist_nz] by auto |
3792 apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_commute) } |
3784 apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_commute) } |
3793 thus ?thesis using `d>0` by auto |
3785 thus ?thesis using `d>0` by auto |
3794 qed |
3786 qed |
3795 |
3787 |
3796 lemma continuous_at_avoid: |
3788 lemma continuous_at_avoid: |
|
3789 fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) |
3797 assumes "continuous (at x) f" "f x \<noteq> a" |
3790 assumes "continuous (at x) f" "f x \<noteq> a" |
3798 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3791 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3799 using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto |
3792 using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto |
3800 |
3793 |
3801 lemma continuous_on_avoid: |
3794 lemma continuous_on_avoid: |