70 lemma openin_subopen: "openin U S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>T. openin U T \<and> x \<in> T \<and> T \<subseteq> S)" (is "?lhs \<longleftrightarrow> ?rhs") |
70 lemma openin_subopen: "openin U S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>T. openin U T \<and> x \<in> T \<and> T \<subseteq> S)" (is "?lhs \<longleftrightarrow> ?rhs") |
71 proof- |
71 proof- |
72 {assume ?lhs then have ?rhs by auto } |
72 {assume ?lhs then have ?rhs by auto } |
73 moreover |
73 moreover |
74 {assume H: ?rhs |
74 {assume H: ?rhs |
75 then obtain t where t: "\<forall>x\<in>S. openin U (t x) \<and> x \<in> t x \<and> t x \<subseteq> S" |
75 then obtain t where t: "\<forall>x\<in>S. openin U (t x) \<and> x \<in> t x \<and> t x \<subseteq> S" |
76 unfolding Ball_def ex_simps(6)[symmetric] choice_iff by blast |
76 unfolding Ball_def ex_simps(6)[symmetric] choice_iff by blast |
77 from t have th0: "\<forall>x\<in> t`S. openin U x" by auto |
77 from t have th0: "\<forall>x\<in> t`S. openin U x" by auto |
78 have "\<Union> t`S = S" using t by auto |
78 have "\<Union> t`S = S" using t by auto |
79 with openin_Union[OF th0] have "openin U S" by simp } |
79 with openin_Union[OF th0] have "openin U S" by simp } |
80 ultimately show ?thesis by blast |
80 ultimately show ?thesis by blast |
81 qed |
81 qed |
82 |
82 |
83 subsection{* Closed sets *} |
83 subsection{* Closed sets *} |
84 |
84 |
85 definition "closedin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> openin U (topspace U - S)" |
85 definition "closedin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> openin U (topspace U - S)" |
86 |
86 |
87 lemma closedin_subset: "closedin U S \<Longrightarrow> S \<subseteq> topspace U" by (metis closedin_def) |
87 lemma closedin_subset: "closedin U S \<Longrightarrow> S \<subseteq> topspace U" by (metis closedin_def) |
88 lemma closedin_empty[simp]: "closedin U {}" by (simp add: closedin_def) |
88 lemma closedin_empty[simp]: "closedin U {}" by (simp add: closedin_def) |
89 lemma closedin_topspace[intro,simp]: |
89 lemma closedin_topspace[intro,simp]: |
90 "closedin U (topspace U)" by (simp add: closedin_def) |
90 "closedin U (topspace U)" by (simp add: closedin_def) |
91 lemma closedin_Un[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<union> T)" |
91 lemma closedin_Un[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<union> T)" |
92 by (auto simp add: Diff_Un closedin_def) |
92 by (auto simp add: Diff_Un closedin_def) |
93 |
93 |
94 lemma Diff_Inter[intro]: "A - \<Inter>S = \<Union> {A - s|s. s\<in>S}" by auto |
94 lemma Diff_Inter[intro]: "A - \<Inter>S = \<Union> {A - s|s. s\<in>S}" by auto |
134 from A B obtain Sa and Sb where Sa: "openin U Sa" "A = Sa \<inter> V" and Sb: "openin U Sb" "B = Sb \<inter> V" by blast |
134 from A B obtain Sa and Sb where Sa: "openin U Sa" "A = Sa \<inter> V" and Sb: "openin U Sb" "B = Sb \<inter> V" by blast |
135 have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ |
135 have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ |
136 then have "A \<inter> B \<in> ?L" by blast} |
136 then have "A \<inter> B \<in> ?L" by blast} |
137 moreover |
137 moreover |
138 {fix K assume K: "K \<subseteq> ?L" |
138 {fix K assume K: "K \<subseteq> ?L" |
139 have th0: "?L = (\<lambda>S. S \<inter> V) ` openin U " |
139 have th0: "?L = (\<lambda>S. S \<inter> V) ` openin U " |
140 apply (rule set_ext) |
140 apply (rule set_ext) |
141 apply (simp add: Ball_def image_iff) |
141 apply (simp add: Ball_def image_iff) |
142 by (metis mem_def) |
142 by (metis mem_def) |
143 from K[unfolded th0 subset_image_iff] |
143 from K[unfolded th0 subset_image_iff] |
144 obtain Sk where Sk: "Sk \<subseteq> openin U" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast |
144 obtain Sk where Sk: "Sk \<subseteq> openin U" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast |
145 have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto |
145 have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto |
146 moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq mem_def) |
146 moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq mem_def) |
147 ultimately have "\<Union>K \<in> ?L" by blast} |
147 ultimately have "\<Union>K \<in> ?L" by blast} |
148 ultimately show ?thesis unfolding istopology_def by blast |
148 ultimately show ?thesis unfolding istopology_def by blast |
149 qed |
149 qed |
150 |
150 |
151 lemma openin_subtopology: |
151 lemma openin_subtopology: |
152 "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" |
152 "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" |
153 unfolding subtopology_def topology_inverse'[OF istopology_subtopology] |
153 unfolding subtopology_def topology_inverse'[OF istopology_subtopology] |
154 by (auto simp add: Collect_def) |
154 by (auto simp add: Collect_def) |
155 |
155 |
156 lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" |
156 lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" |
157 by (auto simp add: topspace_def openin_subtopology) |
157 by (auto simp add: topspace_def openin_subtopology) |
158 |
158 |
159 lemma closedin_subtopology: |
159 lemma closedin_subtopology: |
160 "closedin (subtopology U V) S \<longleftrightarrow> (\<exists>T. closedin U T \<and> S = T \<inter> V)" |
160 "closedin (subtopology U V) S \<longleftrightarrow> (\<exists>T. closedin U T \<and> S = T \<inter> V)" |
161 unfolding closedin_def topspace_subtopology |
161 unfolding closedin_def topspace_subtopology |
162 apply (simp add: openin_subtopology) |
162 apply (simp add: openin_subtopology) |
163 apply (rule iffI) |
163 apply (rule iffI) |
164 apply clarify |
164 apply clarify |
287 subsection{* Open and closed balls. *} |
287 subsection{* Open and closed balls. *} |
288 |
288 |
289 definition "ball x e = {y. dist x y < e}" |
289 definition "ball x e = {y. dist x y < e}" |
290 definition "cball x e = {y. dist x y \<le> e}" |
290 definition "cball x e = {y. dist x y \<le> e}" |
291 |
291 |
292 lemma mem_ball[simp]: "y \<in> ball x e \<longleftrightarrow> dist x y < e" by (simp add: ball_def) |
292 lemma mem_ball[simp]: "y \<in> ball x e \<longleftrightarrow> dist x y < e" by (simp add: ball_def) |
293 lemma mem_cball[simp]: "y \<in> cball x e \<longleftrightarrow> dist x y \<le> e" by (simp add: cball_def) |
293 lemma mem_cball[simp]: "y \<in> cball x e \<longleftrightarrow> dist x y \<le> e" by (simp add: cball_def) |
294 lemma mem_ball_0[simp]: "x \<in> ball 0 e \<longleftrightarrow> norm x < e" by (simp add: dist_def) |
294 lemma mem_ball_0[simp]: "x \<in> ball 0 e \<longleftrightarrow> norm x < e" by (simp add: dist_def) |
295 lemma mem_cball_0[simp]: "x \<in> cball 0 e \<longleftrightarrow> norm x \<le> e" by (simp add: dist_def) |
295 lemma mem_cball_0[simp]: "x \<in> cball 0 e \<longleftrightarrow> norm x \<le> e" by (simp add: dist_def) |
296 lemma centre_in_cball[simp]: "x \<in> cball x e \<longleftrightarrow> 0\<le> e" by simp |
296 lemma centre_in_cball[simp]: "x \<in> cball x e \<longleftrightarrow> 0\<le> e" by simp |
297 lemma ball_subset_cball[simp,intro]: "ball x e \<subseteq> cball x e" by (simp add: subset_eq) |
297 lemma ball_subset_cball[simp,intro]: "ball x e \<subseteq> cball x e" by (simp add: subset_eq) |
298 lemma subset_ball[intro]: "d <= e ==> ball x d \<subseteq> ball x e" by (simp add: subset_eq) |
298 lemma subset_ball[intro]: "d <= e ==> ball x d \<subseteq> ball x e" by (simp add: subset_eq) |
299 lemma subset_cball[intro]: "d <= e ==> cball x d \<subseteq> cball x e" by (simp add: subset_eq) |
299 lemma subset_cball[intro]: "d <= e ==> cball x d \<subseteq> cball x e" by (simp add: subset_eq) |
300 lemma ball_max_Un: "ball a (max r s) = ball a r \<union> ball a s" |
300 lemma ball_max_Un: "ball a (max r s) = ball a r \<union> ball a s" |
301 by (simp add: expand_set_eq) arith |
301 by (simp add: expand_set_eq) arith |
302 |
302 |
303 lemma ball_min_Int: "ball a (min r s) = ball a r \<inter> ball a s" |
303 lemma ball_min_Int: "ball a (min r s) = ball a r \<inter> ball a s" |
304 by (simp add: expand_set_eq) |
304 by (simp add: expand_set_eq) |
305 |
305 |
306 subsection{* Topological properties of open balls *} |
306 subsection{* Topological properties of open balls *} |
307 |
307 |
308 lemma diff_less_iff: "(a::real) - b > 0 \<longleftrightarrow> a > b" |
308 lemma diff_less_iff: "(a::real) - b > 0 \<longleftrightarrow> a > b" |
309 "(a::real) - b < 0 \<longleftrightarrow> a < b" |
309 "(a::real) - b < 0 \<longleftrightarrow> a < b" |
310 "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ |
310 "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ |
311 lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" |
311 lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" |
312 "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ |
312 "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ |
313 |
313 |
314 lemma open_ball[intro, simp]: "open (ball x e)" |
314 lemma open_ball[intro, simp]: "open (ball x e)" |
315 unfolding open_def ball_def Collect_def Ball_def mem_def |
315 unfolding open_def ball_def Collect_def Ball_def mem_def |
316 unfolding dist_sym |
316 unfolding dist_sym |
387 { fix y assume "y\<in>?T" |
387 { fix y assume "y\<in>?T" |
388 then obtain B where "y\<in>B" "B\<in>{B. \<exists>x\<in>S. B = ball x (d x)}" by auto |
388 then obtain B where "y\<in>B" "B\<in>{B. \<exists>x\<in>S. B = ball x (d x)}" by auto |
389 then obtain x where "x\<in>S" and x:"y \<in> ball x (d x)" by auto |
389 then obtain x where "x\<in>S" and x:"y \<in> ball x (d x)" by auto |
390 assume "y\<in>U" |
390 assume "y\<in>U" |
391 hence "y\<in>S" using d[OF `x\<in>S`] and x by(auto simp add: dist_sym) } |
391 hence "y\<in>S" using d[OF `x\<in>S`] and x by(auto simp add: dist_sym) } |
392 ultimately have "S = ?T \<inter> U" by blast |
392 ultimately have "S = ?T \<inter> U" by blast |
393 with oT have ?lhs unfolding openin_subtopology open_openin[symmetric] by blast} |
393 with oT have ?lhs unfolding openin_subtopology open_openin[symmetric] by blast} |
394 ultimately show ?thesis by blast |
394 ultimately show ?thesis by blast |
395 qed |
395 qed |
396 |
396 |
397 text{* These "transitivity" results are handy too. *} |
397 text{* These "transitivity" results are handy too. *} |
398 |
398 |
399 lemma openin_trans[trans]: "openin (subtopology euclidean T) S \<Longrightarrow> openin (subtopology euclidean U) T |
399 lemma openin_trans[trans]: "openin (subtopology euclidean T) S \<Longrightarrow> openin (subtopology euclidean U) T |
400 \<Longrightarrow> openin (subtopology euclidean U) S" |
400 \<Longrightarrow> openin (subtopology euclidean U) S" |
401 unfolding open_openin openin_open by blast |
401 unfolding open_openin openin_open by blast |
402 |
402 |
403 lemma openin_open_trans: "openin (subtopology euclidean T) S \<Longrightarrow> open T \<Longrightarrow> open S" |
403 lemma openin_open_trans: "openin (subtopology euclidean T) S \<Longrightarrow> open T \<Longrightarrow> open S" |
404 by (auto simp add: openin_open intro: openin_trans) |
404 by (auto simp add: openin_open intro: openin_trans) |
405 |
405 |
406 lemma closedin_trans[trans]: |
406 lemma closedin_trans[trans]: |
407 "closedin (subtopology euclidean T) S \<Longrightarrow> |
407 "closedin (subtopology euclidean T) S \<Longrightarrow> |
408 closedin (subtopology euclidean U) T |
408 closedin (subtopology euclidean U) T |
409 ==> closedin (subtopology euclidean U) S" |
409 ==> closedin (subtopology euclidean U) S" |
410 by (auto simp add: closedin_closed closed_closedin closed_Inter Int_assoc) |
410 by (auto simp add: closedin_closed closed_closedin closed_Inter Int_assoc) |
411 |
411 |
412 lemma closedin_closed_trans: "closedin (subtopology euclidean T) S \<Longrightarrow> closed T \<Longrightarrow> closed S" |
412 lemma closedin_closed_trans: "closedin (subtopology euclidean T) S \<Longrightarrow> closed T \<Longrightarrow> closed S" |
413 by (auto simp add: closedin_closed intro: closedin_trans) |
413 by (auto simp add: closedin_closed intro: closedin_trans) |
414 |
414 |
415 subsection{* Connectedness *} |
415 subsection{* Connectedness *} |
416 |
416 |
417 definition "connected S \<longleftrightarrow> |
417 definition "connected S \<longleftrightarrow> |
418 ~(\<exists>e1 e2. open e1 \<and> open e2 \<and> S \<subseteq> (e1 \<union> e2) \<and> (e1 \<inter> e2 \<inter> S = {}) |
418 ~(\<exists>e1 e2. open e1 \<and> open e2 \<and> S \<subseteq> (e1 \<union> e2) \<and> (e1 \<inter> e2 \<inter> S = {}) |
419 \<and> ~(e1 \<inter> S = {}) \<and> ~(e2 \<inter> S = {}))" |
419 \<and> ~(e1 \<inter> S = {}) \<and> ~(e2 \<inter> S = {}))" |
420 |
420 |
421 lemma connected_local: |
421 lemma connected_local: |
422 "connected S \<longleftrightarrow> ~(\<exists>e1 e2. |
422 "connected S \<longleftrightarrow> ~(\<exists>e1 e2. |
423 openin (subtopology euclidean S) e1 \<and> |
423 openin (subtopology euclidean S) e1 \<and> |
424 openin (subtopology euclidean S) e2 \<and> |
424 openin (subtopology euclidean S) e2 \<and> |
425 S \<subseteq> e1 \<union> e2 \<and> |
425 S \<subseteq> e1 \<union> e2 \<and> |
426 e1 \<inter> e2 = {} \<and> |
426 e1 \<inter> e2 = {} \<and> |
636 from x obtain e where e: "e>0" "\<forall>x'. dist x x' < e \<longrightarrow> x' \<in> S" |
636 from x obtain e where e: "e>0" "\<forall>x'. dist x x' < e \<longrightarrow> x' \<in> S" |
637 unfolding mem_interior subset_eq Ball_def mem_ball by blast |
637 unfolding mem_interior subset_eq Ball_def mem_ball by blast |
638 {fix d::real assume d: "d>0" |
638 {fix d::real assume d: "d>0" |
639 let ?m = "min d e / 2" |
639 let ?m = "min d e / 2" |
640 have mde2: "?m \<ge> 0" using e(1) d(1) by arith |
640 have mde2: "?m \<ge> 0" using e(1) d(1) by arith |
641 from vector_choose_dist[OF mde2, of x] |
641 from vector_choose_dist[OF mde2, of x] |
642 obtain y where y: "dist x y = ?m" by blast |
642 obtain y where y: "dist x y = ?m" by blast |
643 have th: "dist x y < e" "dist x y < d" unfolding y using e(1) d(1) by arith+ |
643 have th: "dist x y < e" "dist x y < d" unfolding y using e(1) d(1) by arith+ |
644 have "\<exists>x'\<in>S. x'\<noteq> x \<and> dist x' x < d" |
644 have "\<exists>x'\<in>S. x'\<noteq> x \<and> dist x' x < d" |
645 apply (rule bexI[where x=y]) |
645 apply (rule bexI[where x=y]) |
646 using e th y by (auto simp add: dist_sym)} |
646 using e th y by (auto simp add: dist_sym)} |
647 then show ?thesis unfolding islimpt_approachable by blast |
647 then show ?thesis unfolding islimpt_approachable by blast |
648 qed |
648 qed |
649 |
649 |
650 lemma interior_closed_Un_empty_interior: |
650 lemma interior_closed_Un_empty_interior: |
651 assumes cS: "closed S" and iT: "interior T = {}" |
651 assumes cS: "closed S" and iT: "interior T = {}" |
652 shows "interior(S \<union> T) = interior S" |
652 shows "interior(S \<union> T) = interior S" |
653 proof- |
653 proof- |
654 have "interior S \<subseteq> interior (S\<union>T)" |
654 have "interior S \<subseteq> interior (S\<union>T)" |
655 by (rule subset_interior, blast) |
655 by (rule subset_interior, blast) |
656 moreover |
656 moreover |
657 {fix x e assume e: "e > 0" "\<forall>x' \<in> ball x e. x'\<in>(S\<union>T)" |
657 {fix x e assume e: "e > 0" "\<forall>x' \<in> ball x e. x'\<in>(S\<union>T)" |
658 {fix y assume y: "y \<in> ball x e" |
658 {fix y assume y: "y \<in> ball x e" |
659 {fix d::real assume d: "d > 0" |
659 {fix d::real assume d: "d > 0" |
660 let ?k = "min d (e - dist x y)" |
660 let ?k = "min d (e - dist x y)" |
661 have kp: "?k > 0" using d e(1) y[unfolded mem_ball] by norm |
661 have kp: "?k > 0" using d e(1) y[unfolded mem_ball] by norm |
662 have "?k/2 \<ge> 0" using kp by simp |
662 have "?k/2 \<ge> 0" using kp by simp |
663 then obtain w where w: "dist y w = ?k/ 2" by (metis vector_choose_dist) |
663 then obtain w where w: "dist y w = ?k/ 2" by (metis vector_choose_dist) |
664 from iT[unfolded expand_set_eq mem_interior] |
664 from iT[unfolded expand_set_eq mem_interior] |
665 have "\<not> ball w (?k/4) \<subseteq> T" using kp by (auto simp add: Arith_Tools.less_divide_eq_number_of1) |
665 have "\<not> ball w (?k/4) \<subseteq> T" using kp by (auto simp add: Arith_Tools.less_divide_eq_number_of1) |
666 then obtain z where z: "dist w z < ?k/4" "z \<notin> T" by (auto simp add: subset_eq) |
666 then obtain z where z: "dist w z < ?k/4" "z \<notin> T" by (auto simp add: subset_eq) |
667 have "z \<notin> T \<and> z\<noteq> y \<and> dist z y < d \<and> dist x z < e" using z apply simp |
667 have "z \<notin> T \<and> z\<noteq> y \<and> dist z y < d \<and> dist x z < e" using z apply simp |
668 using w e(1) d apply (auto simp only: dist_sym) |
668 using w e(1) d apply (auto simp only: dist_sym) |
669 apply (auto simp add: min_def cong del: if_weak_cong) |
669 apply (auto simp add: min_def cong del: if_weak_cong) |
670 apply (cases "d \<le> e - dist x y", auto simp add: ring_simps cong del: if_weak_cong) |
670 apply (cases "d \<le> e - dist x y", auto simp add: ring_simps cong del: if_weak_cong) |
671 apply norm |
671 apply norm |
672 apply (cases "d \<le> e - dist x y", auto simp add: ring_simps not_le not_less cong del: if_weak_cong) |
672 apply (cases "d \<le> e - dist x y", auto simp add: ring_simps not_le not_less cong del: if_weak_cong) |
673 apply norm |
673 apply norm |
929 hence "closed S" using closure_subset_eq by auto |
929 hence "closed S" using closure_subset_eq by auto |
930 } |
930 } |
931 thus ?thesis using frontier_subset_closed[of S] by auto |
931 thus ?thesis using frontier_subset_closed[of S] by auto |
932 qed |
932 qed |
933 |
933 |
934 lemma frontier_complement: "frontier(UNIV - S) = frontier S" |
934 lemma frontier_complement: "frontier(UNIV - S) = frontier S" |
935 by (auto simp add: frontier_def closure_complement interior_complement) |
935 by (auto simp add: frontier_def closure_complement interior_complement) |
936 |
936 |
937 lemma frontier_disjoint_eq: "frontier S \<inter> S = {} \<longleftrightarrow> open S" |
937 lemma frontier_disjoint_eq: "frontier S \<inter> S = {} \<longleftrightarrow> open S" |
938 using frontier_complement frontier_subset_eq[of "UNIV - S"] |
938 using frontier_complement frontier_subset_eq[of "UNIV - S"] |
939 unfolding open_closed by auto |
939 unfolding open_closed by auto |
940 |
940 |
941 subsection{* A variant of nets (Slightly non-standard but good for our purposes). *} |
941 subsection{* A variant of nets (Slightly non-standard but good for our purposes). *} |
942 |
942 |
943 typedef (open) 'a net = |
943 typedef (open) 'a net = |
944 "{g :: 'a \<Rightarrow> 'a \<Rightarrow> bool. \<forall>x y. (\<forall>z. g z x \<longrightarrow> g z y) \<or> (\<forall>z. g z y \<longrightarrow> g z x)}" |
944 "{g :: 'a \<Rightarrow> 'a \<Rightarrow> bool. \<forall>x y. (\<forall>z. g z x \<longrightarrow> g z y) \<or> (\<forall>z. g z y \<longrightarrow> g z x)}" |
945 morphisms "netord" "mknet" by blast |
945 morphisms "netord" "mknet" by blast |
946 lemma net: "(\<forall>z. netord n z x \<longrightarrow> netord n z y) \<or> (\<forall>z. netord n z y \<longrightarrow> netord n z x)" |
946 lemma net: "(\<forall>z. netord n z x \<longrightarrow> netord n z y) \<or> (\<forall>z. netord n z y \<longrightarrow> netord n z x)" |
947 using netord[of n] by auto |
947 using netord[of n] by auto |
948 |
948 |
949 lemma oldnet: "netord n x x \<Longrightarrow> netord n y y \<Longrightarrow> |
949 lemma oldnet: "netord n x x \<Longrightarrow> netord n y y \<Longrightarrow> |
950 \<exists>z. netord n z z \<and> (\<forall>w. netord n w z \<longrightarrow> netord n w x \<and> netord n w y)" |
950 \<exists>z. netord n z z \<and> (\<forall>w. netord n w z \<longrightarrow> netord n w x \<and> netord n w y)" |
951 by (metis net) |
951 by (metis net) |
952 |
952 |
953 lemma net_dilemma: |
953 lemma net_dilemma: |
954 "\<exists>a. (\<exists>x. netord net x a) \<and> (\<forall>x. netord net x a \<longrightarrow> P x) \<Longrightarrow> |
954 "\<exists>a. (\<exists>x. netord net x a) \<and> (\<forall>x. netord net x a \<longrightarrow> P x) \<Longrightarrow> |
955 \<exists>b. (\<exists>x. netord net x b) \<and> (\<forall>x. netord net x b \<longrightarrow> Q x) |
955 \<exists>b. (\<exists>x. netord net x b) \<and> (\<forall>x. netord net x b \<longrightarrow> Q x) |
956 \<Longrightarrow> \<exists>c. (\<exists>x. netord net x c) \<and> (\<forall>x. netord net x c \<longrightarrow> P x \<and> Q x)" |
956 \<Longrightarrow> \<exists>c. (\<exists>x. netord net x c) \<and> (\<forall>x. netord net x c \<longrightarrow> P x \<and> Q x)" |
957 by (metis net) |
957 by (metis net) |
958 |
958 |
1014 by (simp add: within_def at_def netord_inverse) |
1014 by (simp add: within_def at_def netord_inverse) |
1015 |
1015 |
1016 subsection{* Identify Trivial limits, where we can't approach arbitrarily closely. *} |
1016 subsection{* Identify Trivial limits, where we can't approach arbitrarily closely. *} |
1017 |
1017 |
1018 |
1018 |
1019 definition "trivial_limit (net:: 'a net) \<longleftrightarrow> |
1019 definition "trivial_limit (net:: 'a net) \<longleftrightarrow> |
1020 (\<forall>(a::'a) b. a = b) \<or> (\<exists>(a::'a) b. a \<noteq> b \<and> (\<forall>x. ~(netord (net) x a) \<and> ~(netord(net) x b)))" |
1020 (\<forall>(a::'a) b. a = b) \<or> (\<exists>(a::'a) b. a \<noteq> b \<and> (\<forall>x. ~(netord (net) x a) \<and> ~(netord(net) x b)))" |
1021 |
1021 |
1022 |
1022 |
1023 lemma trivial_limit_within: "trivial_limit (at (a::real^'n) within S) \<longleftrightarrow> ~(a islimpt S)" |
1023 lemma trivial_limit_within: "trivial_limit (at (a::real^'n) within S) \<longleftrightarrow> ~(a islimpt S)" |
1024 proof- |
1024 proof- |
1025 {assume "\<forall>(a::real^'n) b. a = b" hence "\<not> a islimpt S" |
1025 {assume "\<forall>(a::real^'n) b. a = b" hence "\<not> a islimpt S" |
1026 apply (simp add: islimpt_approachable_le) |
1026 apply (simp add: islimpt_approachable_le) |
1027 by (rule exI[where x=1], auto)} |
1027 by (rule exI[where x=1], auto)} |
1028 moreover |
1028 moreover |
1029 {fix b c assume bc: "b \<noteq> c" "\<forall>x. \<not> netord (at a within S) x b \<and> \<not> netord (at a within S) x c" |
1029 {fix b c assume bc: "b \<noteq> c" "\<forall>x. \<not> netord (at a within S) x b \<and> \<not> netord (at a within S) x c" |
1030 have "dist a b > 0 \<or> dist a c > 0" using bc by (auto simp add: within at dist_nz[THEN sym]) |
1030 have "dist a b > 0 \<or> dist a c > 0" using bc by (auto simp add: within at dist_nz[THEN sym]) |
1031 then have "\<not> a islimpt S" |
1031 then have "\<not> a islimpt S" |
1032 using bc |
1032 using bc |
1033 unfolding within at dist_nz islimpt_approachable_le |
1033 unfolding within at dist_nz islimpt_approachable_le |
1034 by(auto simp add: dist_triangle dist_sym dist_eq_0[THEN sym]) } |
1034 by(auto simp add: dist_triangle dist_sym dist_eq_0[THEN sym]) } |
1035 moreover |
1035 moreover |
1036 {assume "\<not> a islimpt S" |
1036 {assume "\<not> a islimpt S" |
1037 then obtain e where e: "e > 0" "\<forall>x' \<in> S. x' \<noteq> a \<longrightarrow> dist x' a > e" |
1037 then obtain e where e: "e > 0" "\<forall>x' \<in> S. x' \<noteq> a \<longrightarrow> dist x' a > e" |
1038 unfolding islimpt_approachable_le by (auto simp add: not_le) |
1038 unfolding islimpt_approachable_le by (auto simp add: not_le) |
1039 from e vector_choose_dist[of e a] obtain b where b: "dist a b = e" by auto |
1039 from e vector_choose_dist[of e a] obtain b where b: "dist a b = e" by auto |
1040 from b e(1) have "a \<noteq> b" by (simp add: dist_nz) |
1040 from b e(1) have "a \<noteq> b" by (simp add: dist_nz) |
1041 moreover have "\<forall>x. \<not> ((0 < dist x a \<and> dist x a \<le> dist a a) \<and> x \<in> S) \<and> |
1041 moreover have "\<forall>x. \<not> ((0 < dist x a \<and> dist x a \<le> dist a a) \<and> x \<in> S) \<and> |
1042 \<not> ((0 < dist x a \<and> dist x a \<le> dist b a) \<and> x \<in> S)" |
1042 \<not> ((0 < dist x a \<and> dist x a \<le> dist b a) \<and> x \<in> S)" |
1043 using e(2) b by (auto simp add: dist_refl dist_sym) |
1043 using e(2) b by (auto simp add: dist_refl dist_sym) |
1044 ultimately have "trivial_limit (at a within S)" unfolding trivial_limit_def within at |
1044 ultimately have "trivial_limit (at a within S)" unfolding trivial_limit_def within at |
1045 by blast} |
1045 by blast} |
1046 ultimately show ?thesis unfolding trivial_limit_def by blast |
1046 ultimately show ?thesis unfolding trivial_limit_def by blast |
1047 qed |
1047 qed |
1048 |
1048 |
1049 lemma trivial_limit_at: "~(trivial_limit (at a))" |
1049 lemma trivial_limit_at: "~(trivial_limit (at a))" |
1050 apply (subst within_UNIV[symmetric]) |
1050 apply (subst within_UNIV[symmetric]) |
1051 by (simp add: trivial_limit_within islimpt_UNIV) |
1051 by (simp add: trivial_limit_within islimpt_UNIV) |
1052 |
1052 |
1053 lemma trivial_limit_at_infinity: "~(trivial_limit (at_infinity :: ('a::{norm,zero_neq_one}) net))" |
1053 lemma trivial_limit_at_infinity: "~(trivial_limit (at_infinity :: ('a::{norm,zero_neq_one}) net))" |
1054 apply (simp add: trivial_limit_def at_infinity) |
1054 apply (simp add: trivial_limit_def at_infinity) |
1055 by (metis order_refl zero_neq_one) |
1055 by (metis order_refl zero_neq_one) |
1056 |
1056 |
1057 lemma trivial_limit_sequentially: "~(trivial_limit sequentially)" |
1057 lemma trivial_limit_sequentially: "~(trivial_limit sequentially)" |
1058 by (auto simp add: trivial_limit_def sequentially) |
1058 by (auto simp add: trivial_limit_def sequentially) |
1059 |
1059 |
1060 subsection{* Some property holds "sufficiently close" to the limit point. *} |
1060 subsection{* Some property holds "sufficiently close" to the limit point. *} |
1061 |
1061 |
1062 definition "eventually P net \<longleftrightarrow> trivial_limit net \<or> (\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> P x))" |
1062 definition "eventually P net \<longleftrightarrow> trivial_limit net \<or> (\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> P x))" |
1063 |
1063 |
1464 } |
1464 } |
1465 hence "l = l'" using norm_ge_zero[of "l - l'"] unfolding le_less and dist_nz[of l l', unfolded dist_def, THEN sym] by auto |
1465 hence "l = l'" using norm_ge_zero[of "l - l'"] unfolding le_less and dist_nz[of l l', unfolded dist_def, THEN sym] by auto |
1466 thus ?thesis using assms using Lim_sub[of f l net f l'] by simp |
1466 thus ?thesis using assms using Lim_sub[of f l net f l'] by simp |
1467 qed |
1467 qed |
1468 |
1468 |
1469 lemma tendsto_Lim: |
1469 lemma tendsto_Lim: |
1470 "~(trivial_limit (net::('b::zero_neq_one net))) \<Longrightarrow> (f ---> l) net ==> Lim net f = l" |
1470 "~(trivial_limit (net::('b::zero_neq_one net))) \<Longrightarrow> (f ---> l) net ==> Lim net f = l" |
1471 unfolding Lim_def using Lim_unique[of net f] by auto |
1471 unfolding Lim_def using Lim_unique[of net f] by auto |
1472 |
1472 |
1473 text{* Limit under bilinear function (surprisingly tedious, but important) *} |
1473 text{* Limit under bilinear function (surprisingly tedious, but important) *} |
1474 |
1474 |
1475 lemma norm_bound_lemma: |
1475 lemma norm_bound_lemma: |
1476 "0 < e \<Longrightarrow> \<exists>d>0. \<forall>(x'::real^'b) y'::real^'a. norm(x' - (x::real^'b)) < d \<and> norm(y' - y) < d \<longrightarrow> norm(x') * norm(y' - y) + norm(x' - x) * norm(y) < e" |
1476 "0 < e \<Longrightarrow> \<exists>d>0. \<forall>(x'::real^'b) y'::real^'a. norm(x' - (x::real^'b)) < d \<and> norm(y' - y) < d \<longrightarrow> norm(x') * norm(y' - y) + norm(x' - x) * norm(y) < e" |
1477 proof- |
1477 proof- |
1478 assume e: "0 < e" |
1478 assume e: "0 < e" |
1479 have th1: "(2 * norm x + 2 * norm y + 2) > 0" using norm_ge_zero[of x] norm_ge_zero[of y] by norm |
1479 have th1: "(2 * norm x + 2 * norm y + 2) > 0" using norm_ge_zero[of x] norm_ge_zero[of y] by norm |
1480 hence th0: "0 < e / (2 * norm x + 2 * norm y + 2)" using `e>0` using divide_pos_pos by auto |
1480 hence th0: "0 < e / (2 * norm x + 2 * norm y + 2)" using `e>0` using divide_pos_pos by auto |
1481 moreover |
1481 moreover |
1482 { fix x' y' |
1482 { fix x' y' |
1483 assume h: "norm (x' - x) < 1" "norm (x' - x) < e / (2 * norm x + 2 * norm y + 2)" |
1483 assume h: "norm (x' - x) < 1" "norm (x' - x) < e / (2 * norm x + 2 * norm y + 2)" |
1484 "norm (y' - y) < 1" "norm (y' - y) < e / (2 * norm x + 2 * norm y + 2)" |
1484 "norm (y' - y) < 1" "norm (y' - y) < e / (2 * norm x + 2 * norm y + 2)" |
1485 have th: "\<And>a b (c::real). a \<ge> 0 \<Longrightarrow> c \<ge> 0 \<Longrightarrow> a + (b + c) < e ==> b < e " by arith |
1485 have th: "\<And>a b (c::real). a \<ge> 0 \<Longrightarrow> c \<ge> 0 \<Longrightarrow> a + (b + c) < e ==> b < e " by arith |
1486 from h have thx: "norm (x' - x) * norm y < e / 2" |
1486 from h have thx: "norm (x' - x) * norm y < e / 2" |
1487 using th0 th1 apply (simp add: field_simps) |
1487 using th0 th1 apply (simp add: field_simps) |
1488 apply (rule th) defer defer apply assumption |
1488 apply (rule th) defer defer apply assumption |
1489 by (simp_all add: norm_ge_zero zero_le_mult_iff) |
1489 by (simp_all add: norm_ge_zero zero_le_mult_iff) |
1490 |
1490 |
1491 have "norm x' - norm x < 1" apply(rule le_less_trans) |
1491 have "norm x' - norm x < 1" apply(rule le_less_trans) |
1492 using h(1) using norm_triangle_ineq2[of x' x] by auto |
1492 using h(1) using norm_triangle_ineq2[of x' x] by auto |
1493 hence *:"norm x' < 1 + norm x" by auto |
1493 hence *:"norm x' < 1 + norm x" by auto |
1494 |
1494 |
1495 have thy: "norm (y' - y) * norm x' < e / (2 * norm x + 2 * norm y + 2) * (1 + norm x)" |
1495 have thy: "norm (y' - y) * norm x' < e / (2 * norm x + 2 * norm y + 2) * (1 + norm x)" |
1496 using mult_strict_mono'[OF h(4) * norm_ge_zero norm_ge_zero] by auto |
1496 using mult_strict_mono'[OF h(4) * norm_ge_zero norm_ge_zero] by auto |
1497 also have "\<dots> \<le> e/2" apply simp unfolding divide_le_eq |
1497 also have "\<dots> \<le> e/2" apply simp unfolding divide_le_eq |
1498 using th1 th0 `e>0` apply auto |
1498 using th1 th0 `e>0` apply auto |
1499 unfolding mult_assoc and real_mult_le_cancel_iff2[OF `e>0`] by auto |
1499 unfolding mult_assoc and real_mult_le_cancel_iff2[OF `e>0`] by auto |
1500 |
1500 |
1501 finally have "norm x' * norm (y' - y) + norm (x' - x) * norm y < e" |
1501 finally have "norm x' * norm (y' - y) + norm (x' - x) * norm y < e" |
1502 using thx and e by (simp add: field_simps) } |
1502 using thx and e by (simp add: field_simps) } |
1503 ultimately show ?thesis apply(rule_tac x="min 1 (e / 2 / (norm x + norm y + 1))" in exI) by auto |
1503 ultimately show ?thesis apply(rule_tac x="min 1 (e / 2 / (norm x + norm y + 1))" in exI) by auto |
1504 qed |
1504 qed |
1505 |
1505 |
1506 lemma Lim_bilinear: |
1506 lemma Lim_bilinear: |
1507 fixes net :: "'a net" and h:: "real ^'m \<Rightarrow> real ^'n \<Rightarrow> real ^'p" |
1507 fixes net :: "'a net" and h:: "real ^'m \<Rightarrow> real ^'n \<Rightarrow> real ^'p" |
1508 assumes "(f ---> l) net" and "(g ---> m) net" and "bilinear h" |
1508 assumes "(f ---> l) net" and "(g ---> m) net" and "bilinear h" |
1509 shows "((\<lambda>x. h (f x) (g x)) ---> (h l m)) net" |
1509 shows "((\<lambda>x. h (f x) (g x)) ---> (h l m)) net" |
1510 proof(cases "trivial_limit net") |
1510 proof(cases "trivial_limit net") |
1511 case True thus "((\<lambda>x. h (f x) (g x)) ---> h l m) net" unfolding Lim .. |
1511 case True thus "((\<lambda>x. h (f x) (g x)) ---> h l m) net" unfolding Lim .. |
1600 qed |
1600 qed |
1601 |
1601 |
1602 lemma Lim_transform_eventually: "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net ==> (g ---> l) net" |
1602 lemma Lim_transform_eventually: "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net ==> (g ---> l) net" |
1603 using Lim_eventually[of "\<lambda>x. f x - g x" 0 net] Lim_transform[of f g net l] by auto |
1603 using Lim_eventually[of "\<lambda>x. f x - g x" 0 net] Lim_transform[of f g net l] by auto |
1604 |
1604 |
1605 lemma Lim_transform_within: |
1605 lemma Lim_transform_within: |
1606 assumes "0 < d" "(\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x')" |
1606 assumes "0 < d" "(\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x')" |
1607 "(f ---> l) (at x within S)" |
1607 "(f ---> l) (at x within S)" |
1608 shows "(g ---> l) (at x within S)" |
1608 shows "(g ---> l) (at x within S)" |
1609 proof- |
1609 proof- |
1610 have "((\<lambda>x. f x - g x) ---> 0) (at x within S)" unfolding Lim_within[of "\<lambda>x. f x - g x" 0 x S] using assms(1,2) by auto |
1610 have "((\<lambda>x. f x - g x) ---> 0) (at x within S)" unfolding Lim_within[of "\<lambda>x. f x - g x" 0 x S] using assms(1,2) by auto |
1611 thus ?thesis using Lim_transform[of f g "at x within S" l] using assms(3) by auto |
1611 thus ?thesis using Lim_transform[of f g "at x within S" l] using assms(3) by auto |
1612 qed |
1612 qed |
1613 |
1613 |
1614 lemma Lim_transform_at: "0 < d \<Longrightarrow> (\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x') \<Longrightarrow> |
1614 lemma Lim_transform_at: "0 < d \<Longrightarrow> (\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x') \<Longrightarrow> |
1615 (f ---> l) (at x) ==> (g ---> l) (at x)" |
1615 (f ---> l) (at x) ==> (g ---> l) (at x)" |
1616 apply (subst within_UNIV[symmetric]) |
1616 apply (subst within_UNIV[symmetric]) |
1617 using Lim_transform_within[of d UNIV x f g l] |
1617 using Lim_transform_within[of d UNIV x f g l] |
1618 by (auto simp add: within_UNIV) |
1618 by (auto simp add: within_UNIV) |
1619 |
1619 |
1620 text{* Common case assuming being away from some crucial point like 0. *} |
1620 text{* Common case assuming being away from some crucial point like 0. *} |
1621 |
1621 |
1622 lemma Lim_transform_away_within: |
1622 lemma Lim_transform_away_within: |
1623 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1623 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1624 assumes "a\<noteq>b" "\<forall>x\<in> S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1624 assumes "a\<noteq>b" "\<forall>x\<in> S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1625 and "(f ---> l) (at a within S)" |
1625 and "(f ---> l) (at a within S)" |
1626 shows "(g ---> l) (at a within S)" |
1626 shows "(g ---> l) (at a within S)" |
1627 proof- |
1627 proof- |
1628 have "\<forall>x'\<in>S. 0 < dist x' a \<and> dist x' a < dist a b \<longrightarrow> f x' = g x'" using assms(2) |
1628 have "\<forall>x'\<in>S. 0 < dist x' a \<and> dist x' a < dist a b \<longrightarrow> f x' = g x'" using assms(2) |
1629 apply auto apply(erule_tac x=x' in ballE) by (auto simp add: dist_sym dist_refl) |
1629 apply auto apply(erule_tac x=x' in ballE) by (auto simp add: dist_sym dist_refl) |
1630 thus ?thesis using Lim_transform_within[of "dist a b" S a f g l] using assms(1,3) unfolding dist_nz by auto |
1630 thus ?thesis using Lim_transform_within[of "dist a b" S a f g l] using assms(1,3) unfolding dist_nz by auto |
1631 qed |
1631 qed |
1632 |
1632 |
1633 lemma Lim_transform_away_at: |
1633 lemma Lim_transform_away_at: |
1634 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1634 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1635 assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1635 assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" |
1636 and fl: "(f ---> l) (at a)" |
1636 and fl: "(f ---> l) (at a)" |
1637 shows "(g ---> l) (at a)" |
1637 shows "(g ---> l) (at a)" |
1638 using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl |
1638 using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl |
1639 by (auto simp add: within_UNIV) |
1639 by (auto simp add: within_UNIV) |
1640 |
1640 |
1641 text{* Alternatively, within an open set. *} |
1641 text{* Alternatively, within an open set. *} |
1642 |
1642 |
1643 lemma Lim_transform_within_open: |
1643 lemma Lim_transform_within_open: |
1644 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1644 fixes f:: "real ^'m \<Rightarrow> real ^'n" |
1645 assumes "open S" "a \<in> S" "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" "(f ---> l) (at a)" |
1645 assumes "open S" "a \<in> S" "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" "(f ---> l) (at a)" |
1646 shows "(g ---> l) (at a)" |
1646 shows "(g ---> l) (at a)" |
1647 proof- |
1647 proof- |
1648 from assms(1,2) obtain e::real where "e>0" and e:"ball a e \<subseteq> S" unfolding open_contains_ball by auto |
1648 from assms(1,2) obtain e::real where "e>0" and e:"ball a e \<subseteq> S" unfolding open_contains_ball by auto |
1649 hence "\<forall>x'. 0 < dist x' a \<and> dist x' a < e \<longrightarrow> f x' = g x'" using assms(3) |
1649 hence "\<forall>x'. 0 < dist x' a \<and> dist x' a < e \<longrightarrow> f x' = g x'" using assms(3) |
1650 unfolding ball_def subset_eq apply auto apply(erule_tac x=x' in allE) apply(erule_tac x=x' in ballE) by(auto simp add: dist_refl dist_sym) |
1650 unfolding ball_def subset_eq apply auto apply(erule_tac x=x' in allE) apply(erule_tac x=x' in ballE) by(auto simp add: dist_refl dist_sym) |
1651 thus ?thesis using Lim_transform_at[of e a f g l] `e>0` assms(4) by auto |
1651 thus ?thesis using Lim_transform_at[of e a f g l] `e>0` assms(4) by auto |
1652 qed |
1652 qed |
1653 |
1653 |
1654 text{* A congruence rule allowing us to transform limits assuming not at point. *} |
1654 text{* A congruence rule allowing us to transform limits assuming not at point. *} |
1655 |
1655 |
1656 lemma Lim_cong_within[cong add]: |
1656 lemma Lim_cong_within[cong add]: |
1657 "(\<And>x. x \<noteq> a \<Longrightarrow> f x = g x) ==> ((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))" |
1657 "(\<And>x. x \<noteq> a \<Longrightarrow> f x = g x) ==> ((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))" |
1658 by (simp add: Lim_within dist_nz[symmetric]) |
1658 by (simp add: Lim_within dist_nz[symmetric]) |
1659 |
1659 |
1660 lemma Lim_cong_at[cong add]: |
1660 lemma Lim_cong_at[cong add]: |
1661 "(\<And>x. x \<noteq> a ==> f x = g x) ==> (((\<lambda>x. f x) ---> l) (at a) \<longleftrightarrow> ((g ---> l) (at a)))" |
1661 "(\<And>x. x \<noteq> a ==> f x = g x) ==> (((\<lambda>x. f x) ---> l) (at a) \<longleftrightarrow> ((g ---> l) (at a)))" |
1662 by (simp add: Lim_at dist_nz[symmetric]) |
1662 by (simp add: Lim_at dist_nz[symmetric]) |
1663 |
1663 |
1664 text{* Useful lemmas on closure and set of possible sequential limits.*} |
1664 text{* Useful lemmas on closure and set of possible sequential limits.*} |
1665 |
1665 |
1666 lemma closure_sequential: |
1666 lemma closure_sequential: |
1667 "l \<in> closure S \<longleftrightarrow> (\<exists>x. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially)" (is "?lhs = ?rhs") |
1667 "l \<in> closure S \<longleftrightarrow> (\<exists>x. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially)" (is "?lhs = ?rhs") |
1668 proof |
1668 proof |
1669 assume "?lhs" moreover |
1669 assume "?lhs" moreover |
1670 { assume "l \<in> S" |
1670 { assume "l \<in> S" |
1671 hence "?rhs" using Lim_const[of l sequentially] by auto |
1671 hence "?rhs" using Lim_const[of l sequentially] by auto |
1815 |
1815 |
1816 lemma closure_ball: "0 < e ==> (closure(ball x e) = cball x e)" |
1816 lemma closure_ball: "0 < e ==> (closure(ball x e) = cball x e)" |
1817 apply (simp add: closure_def islimpt_ball expand_set_eq) |
1817 apply (simp add: closure_def islimpt_ball expand_set_eq) |
1818 by arith |
1818 by arith |
1819 |
1819 |
1820 lemma interior_cball: "interior(cball x e) = ball x e" |
1820 lemma interior_cball: "interior(cball x e) = ball x e" |
1821 proof(cases "e\<ge>0") |
1821 proof(cases "e\<ge>0") |
1822 case False note cs = this |
1822 case False note cs = this |
1823 from cs have "ball x e = {}" using ball_empty[of e x] by auto moreover |
1823 from cs have "ball x e = {}" using ball_empty[of e x] by auto moreover |
1824 { fix y assume "y \<in> cball x e" |
1824 { fix y assume "y \<in> cball x e" |
1825 hence False unfolding mem_cball using dist_nz[of x y] cs by (auto simp add: dist_refl) } |
1825 hence False unfolding mem_cball using dist_nz[of x y] cs by (auto simp add: dist_refl) } |
1826 hence "cball x e = {}" by auto |
1826 hence "cball x e = {}" by auto |
1827 hence "interior (cball x e) = {}" using interior_empty by auto |
1827 hence "interior (cball x e) = {}" using interior_empty by auto |
1828 ultimately show ?thesis by blast |
1828 ultimately show ?thesis by blast |
1829 next |
1829 next |
1830 case True note cs = this |
1830 case True note cs = this |
1831 have "ball x e \<subseteq> cball x e" using ball_subset_cball by auto moreover |
1831 have "ball x e \<subseteq> cball x e" using ball_subset_cball by auto moreover |
1832 { fix S y assume as: "S \<subseteq> cball x e" "open S" "y\<in>S" |
1832 { fix S y assume as: "S \<subseteq> cball x e" "open S" "y\<in>S" |
1833 then obtain d where "d>0" and d:"\<forall>x'. dist x' y < d \<longrightarrow> x' \<in> S" unfolding open_def by blast |
1833 then obtain d where "d>0" and d:"\<forall>x'. dist x' y < d \<longrightarrow> x' \<in> S" unfolding open_def by blast |
1834 |
1834 |
1835 then obtain xa where xa:"dist y xa = d / 2" using vector_choose_dist[of "d/2" y] by auto |
1835 then obtain xa where xa:"dist y xa = d / 2" using vector_choose_dist[of "d/2" y] by auto |
1836 hence xa_y:"xa \<noteq> y" using dist_nz[of y xa] using `d>0` by auto |
1836 hence xa_y:"xa \<noteq> y" using dist_nz[of y xa] using `d>0` by auto |
1837 have "xa\<in>S" using d[THEN spec[where x=xa]] using xa apply(auto simp add: dist_sym) unfolding dist_nz[THEN sym] using xa_y by auto |
1837 have "xa\<in>S" using d[THEN spec[where x=xa]] using xa apply(auto simp add: dist_sym) unfolding dist_nz[THEN sym] using xa_y by auto |
1838 hence xa_cball:"xa \<in> cball x e" using as(1) by auto |
1838 hence xa_cball:"xa \<in> cball x e" using as(1) by auto |
1839 |
1839 |
1840 hence "y \<in> ball x e" proof(cases "x = y") |
1840 hence "y \<in> ball x e" proof(cases "x = y") |
2163 lemma convergent_bounded_monotone: fixes s::"nat \<Rightarrow> real" |
2163 lemma convergent_bounded_monotone: fixes s::"nat \<Rightarrow> real" |
2164 assumes "\<forall>n. abs(s n) \<le> b" and "(\<forall>m n. m \<le> n --> s m \<le> s n) \<or> (\<forall>m n. m \<le> n --> s n \<le> s m)" |
2164 assumes "\<forall>n. abs(s n) \<le> b" and "(\<forall>m n. m \<le> n --> s m \<le> s n) \<or> (\<forall>m n. m \<le> n --> s n \<le> s m)" |
2165 shows "\<exists>l. \<forall>e::real>0. \<exists>N. \<forall>n\<ge>N. abs(s n - l) < e" |
2165 shows "\<exists>l. \<forall>e::real>0. \<exists>N. \<forall>n\<ge>N. abs(s n - l) < e" |
2166 using convergent_bounded_increasing[of s b] assms using convergent_bounded_increasing[of "\<lambda>n. - s n" b] |
2166 using convergent_bounded_increasing[of s b] assms using convergent_bounded_increasing[of "\<lambda>n. - s n" b] |
2167 apply auto unfolding minus_add_distrib[THEN sym, unfolded diff_minus[THEN sym]] |
2167 apply auto unfolding minus_add_distrib[THEN sym, unfolded diff_minus[THEN sym]] |
2168 unfolding abs_minus_cancel by(rule_tac x="-l" in exI)auto |
2168 unfolding abs_minus_cancel by(rule_tac x="-l" in exI)auto |
2169 |
2169 |
2170 lemma compact_real_lemma: |
2170 lemma compact_real_lemma: |
2171 assumes "\<forall>n::nat. abs(s n) \<le> b" |
2171 assumes "\<forall>n::nat. abs(s n) \<le> b" |
2172 shows "\<exists>l r. (\<forall>m n::nat. m < n --> r m < r n) \<and> |
2172 shows "\<exists>l r. (\<forall>m n::nat. m < n --> r m < r n) \<and> |
2173 (\<forall>e>0::real. \<exists>N. \<forall>n\<ge>N. (abs(s (r n) - l) < e))" |
2173 (\<forall>e>0::real. \<exists>N. \<forall>n\<ge>N. (abs(s (r n) - l) < e))" |
2174 proof- |
2174 proof- |
2175 obtain r where r:"\<forall>m n::nat. m < n \<longrightarrow> r m < r n" |
2175 obtain r where r:"\<forall>m n::nat. m < n \<longrightarrow> r m < r n" |
2176 "(\<forall>m n. m \<le> n \<longrightarrow> s (r m) \<le> s (r n)) \<or> (\<forall>m n. m \<le> n \<longrightarrow> s (r n) \<le> s (r m))" |
2176 "(\<forall>m n. m \<le> n \<longrightarrow> s (r m) \<le> s (r n)) \<or> (\<forall>m n. m \<le> n \<longrightarrow> s (r n) \<le> s (r m))" |
2177 using seq_monosub[of s] by (auto simp add: subseq_def monoseq_def) |
2177 using seq_monosub[of s] by (auto simp add: subseq_def monoseq_def) |
2178 thus ?thesis using convergent_bounded_monotone[of "s o r" b] and assms by auto |
2178 thus ?thesis using convergent_bounded_monotone[of "s o r" b] and assms by auto |
2179 qed |
2179 qed |
2180 |
2180 |
2181 lemma compact_lemma: |
2181 lemma compact_lemma: |
2182 assumes "bounded s" and "\<forall>n. (x::nat \<Rightarrow>real^'a) n \<in> s" |
2182 assumes "bounded s" and "\<forall>n. (x::nat \<Rightarrow>real^'a) n \<in> s" |
2183 shows "\<forall>d\<in>{1.. dimindex(UNIV::'a set)}. |
2183 shows "\<forall>d\<in>{1.. dimindex(UNIV::'a set)}. |
2184 \<exists>l::(real^'a). \<exists> r. (\<forall>n m::nat. m < n --> r m < r n) \<and> |
2184 \<exists>l::(real^'a). \<exists> r. (\<forall>n m::nat. m < n --> r m < r n) \<and> |
2185 (\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>i\<in>{1..d}. \<bar>x (r n) $ i - l $ i\<bar> < e)" |
2185 (\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>i\<in>{1..d}. \<bar>x (r n) $ i - l $ i\<bar> < e)" |
2186 proof- |
2186 proof- |
2324 qed |
2324 qed |
2325 |
2325 |
2326 lemma compact_imp_complete: assumes "compact s" shows "complete s" |
2326 lemma compact_imp_complete: assumes "compact s" shows "complete s" |
2327 proof- |
2327 proof- |
2328 { fix f assume as: "(\<forall>n::nat. f n \<in> s)" "cauchy f" |
2328 { fix f assume as: "(\<forall>n::nat. f n \<in> s)" "cauchy f" |
2329 from as(1) obtain l r where lr: "l\<in>s" "(\<forall>m n. m < n \<longrightarrow> r m < r n)" "((f \<circ> r) ---> l) sequentially" using assms unfolding compact_def by blast |
2329 from as(1) obtain l r where lr: "l\<in>s" "(\<forall>m n. m < n \<longrightarrow> r m < r n)" "((f \<circ> r) ---> l) sequentially" using assms unfolding compact_def by blast |
2330 |
2330 |
2331 { fix n :: nat have lr':"n \<le> r n" |
2331 { fix n :: nat have lr':"n \<le> r n" |
2332 proof (induct n) |
2332 proof (induct n) |
2333 show "0 \<le> r 0" using lr(2) by blast |
2333 show "0 \<le> r 0" using lr(2) by blast |
2334 next fix na assume "na \<le> r na" moreover have "na < Suc na \<longrightarrow> r na < r (Suc na)" using lr(2) by blast |
2334 next fix na assume "na \<le> r na" moreover have "na < Suc na \<longrightarrow> r na < r (Suc na)" using lr(2) by blast |
2335 ultimately show "Suc na \<le> r (Suc na)" by auto |
2335 ultimately show "Suc na \<le> r (Suc na)" by auto |
2336 qed } note lr' = this |
2336 qed } note lr' = this |
2337 |
2337 |
2338 { fix e::real assume "e>0" |
2338 { fix e::real assume "e>0" |
2339 from as(2) obtain N where N:"\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (f m) (f n) < e/2" unfolding cauchy_def using `e>0` apply (erule_tac x="e/2" in allE) by auto |
2339 from as(2) obtain N where N:"\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (f m) (f n) < e/2" unfolding cauchy_def using `e>0` apply (erule_tac x="e/2" in allE) by auto |
2340 from lr(3)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] obtain M where M:"\<forall>n\<ge>M. dist ((f \<circ> r) n) l < e/2" using `e>0` by auto |
2340 from lr(3)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] obtain M where M:"\<forall>n\<ge>M. dist ((f \<circ> r) n) l < e/2" using `e>0` by auto |
2341 { fix n::nat assume n:"n \<ge> max N M" |
2341 { fix n::nat assume n:"n \<ge> max N M" |
2342 have "dist ((f \<circ> r) n) l < e/2" using n M by auto |
2342 have "dist ((f \<circ> r) n) l < e/2" using n M by auto |
2343 moreover have "r n \<ge> N" using lr'[of n] n by auto |
2343 moreover have "r n \<ge> N" using lr'[of n] n by auto |
2344 hence "dist (f n) ((f \<circ> r) n) < e / 2" using N using n by auto |
2344 hence "dist (f n) ((f \<circ> r) n) < e / 2" using N using n by auto |
2345 ultimately have "dist (f n) l < e" using dist_triangle_half_r[of "f (r n)" "f n" e l] by (auto simp add: dist_sym) } |
2345 ultimately have "dist (f n) l < e" using dist_triangle_half_r[of "f (r n)" "f n" e l] by (auto simp add: dist_sym) } |
2346 hence "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast } |
2346 hence "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast } |
2347 hence "\<exists>l\<in>s. (f ---> l) sequentially" using `l\<in>s` unfolding Lim_sequentially by auto } |
2347 hence "\<exists>l\<in>s. (f ---> l) sequentially" using `l\<in>s` unfolding Lim_sequentially by auto } |
2348 thus ?thesis unfolding complete_def by auto |
2348 thus ?thesis unfolding complete_def by auto |
2349 qed |
2349 qed |
2350 |
2350 |
2351 lemma complete_univ: |
2351 lemma complete_univ: |
2352 "complete UNIV" |
2352 "complete UNIV" |
2353 proof(simp add: complete_def, rule, rule) |
2353 proof(simp add: complete_def, rule, rule) |
2354 fix f::"nat \<Rightarrow> real^'n" assume "cauchy f" |
2354 fix f::"nat \<Rightarrow> real^'n" assume "cauchy f" |
2355 hence "bounded (f`UNIV)" using cauchy_imp_bounded[of f] unfolding image_def by auto |
2355 hence "bounded (f`UNIV)" using cauchy_imp_bounded[of f] unfolding image_def by auto |
2356 hence "compact (closure (f`UNIV))" using bounded_closed_imp_compact[of "closure (range f)"] by auto |
2356 hence "compact (closure (f`UNIV))" using bounded_closed_imp_compact[of "closure (range f)"] by auto |
2427 assumes "compact s" "s \<subseteq> (\<Union> t)" "\<forall>b \<in> t. open b" |
2427 assumes "compact s" "s \<subseteq> (\<Union> t)" "\<forall>b \<in> t. open b" |
2428 shows "\<exists>e>0. \<forall>x \<in> s. \<exists>b \<in> t. ball x e \<subseteq> b" |
2428 shows "\<exists>e>0. \<forall>x \<in> s. \<exists>b \<in> t. ball x e \<subseteq> b" |
2429 proof(rule ccontr) |
2429 proof(rule ccontr) |
2430 assume "\<not> (\<exists>e>0. \<forall>x\<in>s. \<exists>b\<in>t. ball x e \<subseteq> b)" |
2430 assume "\<not> (\<exists>e>0. \<forall>x\<in>s. \<exists>b\<in>t. ball x e \<subseteq> b)" |
2431 hence cont:"\<forall>e>0. \<exists>x\<in>s. \<forall>xa\<in>t. \<not> (ball x e \<subseteq> xa)" by auto |
2431 hence cont:"\<forall>e>0. \<exists>x\<in>s. \<forall>xa\<in>t. \<not> (ball x e \<subseteq> xa)" by auto |
2432 { fix n::nat |
2432 { fix n::nat |
2433 have "1 / real (n + 1) > 0" by auto |
2433 have "1 / real (n + 1) > 0" by auto |
2434 hence "\<exists>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> (ball x (inverse (real (n+1))) \<subseteq> xa))" using cont unfolding Bex_def by auto } |
2434 hence "\<exists>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> (ball x (inverse (real (n+1))) \<subseteq> xa))" using cont unfolding Bex_def by auto } |
2435 hence "\<forall>n::nat. \<exists>x. x \<in> s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)" by auto |
2435 hence "\<forall>n::nat. \<exists>x. x \<in> s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)" by auto |
2436 then obtain f where f:"\<forall>n::nat. f n \<in> s \<and> (\<forall>xa\<in>t. \<not> ball (f n) (inverse (real (n + 1))) \<subseteq> xa)" |
2436 then obtain f where f:"\<forall>n::nat. f n \<in> s \<and> (\<forall>xa\<in>t. \<not> ball (f n) (inverse (real (n + 1))) \<subseteq> xa)" |
2437 using choice[of "\<lambda>n::nat. \<lambda>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)"] by auto |
2437 using choice[of "\<lambda>n::nat. \<lambda>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)"] by auto |
2438 |
2438 |
2439 then obtain l r where l:"l\<in>s" and r:"\<forall>m n. m < n \<longrightarrow> r m < r n" and lr:"((f \<circ> r) ---> l) sequentially" |
2439 then obtain l r where l:"l\<in>s" and r:"\<forall>m n. m < n \<longrightarrow> r m < r n" and lr:"((f \<circ> r) ---> l) sequentially" |
2440 using assms(1)[unfolded compact_def, THEN spec[where x=f]] by auto |
2440 using assms(1)[unfolded compact_def, THEN spec[where x=f]] by auto |
2441 |
2441 |
2442 obtain b where "l\<in>b" "b\<in>t" using assms(2) and l by auto |
2442 obtain b where "l\<in>b" "b\<in>t" using assms(2) and l by auto |
2443 then obtain e where "e>0" and e:"\<forall>z. dist z l < e \<longrightarrow> z\<in>b" |
2443 then obtain e where "e>0" and e:"\<forall>z. dist z l < e \<longrightarrow> z\<in>b" |
2444 using assms(3)[THEN bspec[where x=b]] unfolding open_def by auto |
2444 using assms(3)[THEN bspec[where x=b]] unfolding open_def by auto |
2445 |
2445 |
2446 then obtain N1 where N1:"\<forall>n\<ge>N1. dist ((f \<circ> r) n) l < e / 2" |
2446 then obtain N1 where N1:"\<forall>n\<ge>N1. dist ((f \<circ> r) n) l < e / 2" |
2447 using lr[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
2447 using lr[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
2448 |
2448 |
2449 obtain N2::nat where N2:"N2>0" "inverse (real N2) < e /2" using real_arch_inv[of "e/2"] and `e>0` by auto |
2449 obtain N2::nat where N2:"N2>0" "inverse (real N2) < e /2" using real_arch_inv[of "e/2"] and `e>0` by auto |
2450 have N2':"inverse (real (r (N1 + N2) +1 )) < e/2" |
2450 have N2':"inverse (real (r (N1 + N2) +1 )) < e/2" |
2451 apply(rule order_less_trans) apply(rule less_imp_inverse_less) using N2 |
2451 apply(rule order_less_trans) apply(rule less_imp_inverse_less) using N2 |
2452 using monotone_bigger[OF r, of "N1 + N2"] by auto |
2452 using monotone_bigger[OF r, of "N1 + N2"] by auto |
2453 |
2453 |
2454 def x \<equiv> "(f (r (N1 + N2)))" |
2454 def x \<equiv> "(f (r (N1 + N2)))" |
2455 have x:"\<not> ball x (inverse (real (r (N1 + N2) + 1))) \<subseteq> b" unfolding x_def |
2455 have x:"\<not> ball x (inverse (real (r (N1 + N2) + 1))) \<subseteq> b" unfolding x_def |
2456 using f[THEN spec[where x="r (N1 + N2)"]] using `b\<in>t` by auto |
2456 using f[THEN spec[where x="r (N1 + N2)"]] using `b\<in>t` by auto |
2457 have "\<exists>y\<in>ball x (inverse (real (r (N1 + N2) + 1))). y\<notin>b" apply(rule ccontr) using x by auto |
2457 have "\<exists>y\<in>ball x (inverse (real (r (N1 + N2) + 1))). y\<notin>b" apply(rule ccontr) using x by auto |
2458 then obtain y where y:"y \<in> ball x (inverse (real (r (N1 + N2) + 1)))" "y \<notin> b" by auto |
2458 then obtain y where y:"y \<in> ball x (inverse (real (r (N1 + N2) + 1)))" "y \<notin> b" by auto |
2459 |
2459 |
2460 have "dist x l < e/2" using N1 unfolding x_def o_def by auto |
2460 have "dist x l < e/2" using N1 unfolding x_def o_def by auto |
2461 hence "dist y l < e" using y N2' using dist_triangle[of y l x]by (auto simp add:dist_sym) |
2461 hence "dist y l < e" using y N2' using dist_triangle[of y l x]by (auto simp add:dist_sym) |
2462 |
2462 |
2463 thus False using e and `y\<notin>b` by auto |
2463 thus False using e and `y\<notin>b` by auto |
2464 qed |
2464 qed |
2465 |
2465 |
2466 lemma compact_imp_heine_borel: "compact s ==> (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) |
2466 lemma compact_imp_heine_borel: "compact s ==> (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) |
2467 \<longrightarrow> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" |
2467 \<longrightarrow> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" |
2559 hence "inj x" unfolding inj_on_def by auto |
2559 hence "inj x" unfolding inj_on_def by auto |
2560 moreover |
2560 moreover |
2561 { fix n::nat |
2561 { fix n::nat |
2562 have "x n \<in> s" |
2562 have "x n \<in> s" |
2563 proof(cases "n = 0") |
2563 proof(cases "n = 0") |
2564 case True thus ?thesis unfolding x_def using beyond by auto |
2564 case True thus ?thesis unfolding x_def using beyond by auto |
2565 next |
2565 next |
2566 case False then obtain z where "n = Suc z" using not0_implies_Suc by auto |
2566 case False then obtain z where "n = Suc z" using not0_implies_Suc by auto |
2567 thus ?thesis unfolding x_def using beyond by auto |
2567 thus ?thesis unfolding x_def using beyond by auto |
2568 qed } |
2568 qed } |
2569 ultimately have "infinite (range x) \<and> range x \<subseteq> s" unfolding x_def using range_inj_infinite[of "helper_2 beyond"] using beyond(1) by auto |
2569 ultimately have "infinite (range x) \<and> range x \<subseteq> s" unfolding x_def using range_inj_infinite[of "helper_2 beyond"] using beyond(1) by auto |
2570 |
2570 |
2571 then obtain l where "l\<in>s" and l:"l islimpt range x" using assms[THEN spec[where x="range x"]] by auto |
2571 then obtain l where "l\<in>s" and l:"l islimpt range x" using assms[THEN spec[where x="range x"]] by auto |
2572 then obtain y where "x y \<noteq> l" and y:"dist (x y) l < 1/2" unfolding islimpt_approachable apply(erule_tac x="1/2" in allE) by auto |
2572 then obtain y where "x y \<noteq> l" and y:"dist (x y) l < 1/2" unfolding islimpt_approachable apply(erule_tac x="1/2" in allE) by auto |
2573 then obtain z where "x z \<noteq> l" and z:"dist (x z) l < dist (x y) l" using l[unfolded islimpt_approachable, THEN spec[where x="dist (x y) l"]] |
2573 then obtain z where "x z \<noteq> l" and z:"dist (x z) l < dist (x y) l" using l[unfolded islimpt_approachable, THEN spec[where x="dist (x y) l"]] |
2574 unfolding dist_nz by auto |
2574 unfolding dist_nz by auto |
2575 show False using y and z and dist_triangle_half_l[of "x y" l 1 "x z"] and **[of y z] by auto |
2575 show False using y and z and dist_triangle_half_l[of "x y" l 1 "x z"] and **[of y z] by auto |
2576 qed |
2576 qed |
2577 |
2577 |
2578 lemma sequence_infinite_lemma: |
2578 lemma sequence_infinite_lemma: |
2579 assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" |
2579 assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" |
2580 shows "infinite {y::real^'a. (\<exists> n. y = f n)}" |
2580 shows "infinite {y::real^'a. (\<exists> n. y = f n)}" |
2581 proof(rule ccontr) |
2581 proof(rule ccontr) |
2582 let ?A = "(\<lambda>x. dist x l) ` {y. \<exists>n. y = f n}" |
2582 let ?A = "(\<lambda>x. dist x l) ` {y. \<exists>n. y = f n}" |
2583 assume "\<not> infinite {y. \<exists>n. y = f n}" |
2583 assume "\<not> infinite {y. \<exists>n. y = f n}" |
2584 hence **:"finite ?A" "?A \<noteq> {}" by auto |
2584 hence **:"finite ?A" "?A \<noteq> {}" by auto |
2585 obtain k where k:"dist (f k) l = Min ?A" using Min_in[OF **] by auto |
2585 obtain k where k:"dist (f k) l = Min ?A" using Min_in[OF **] by auto |
2586 have "0 < Min ?A" using assms(1) unfolding dist_nz unfolding Min_gr_iff[OF **] by auto |
2586 have "0 < Min ?A" using assms(1) unfolding dist_nz unfolding Min_gr_iff[OF **] by auto |
2587 then obtain N where "dist (f N) l < Min ?A" using assms(2)[unfolded Lim_sequentially, THEN spec[where x="Min ?A"]] by auto |
2587 then obtain N where "dist (f N) l < Min ?A" using assms(2)[unfolded Lim_sequentially, THEN spec[where x="Min ?A"]] by auto |
2588 moreover have "dist (f N) l \<in> ?A" by auto |
2588 moreover have "dist (f N) l \<in> ?A" by auto |
2589 ultimately show False using Min_le[OF **(1), of "dist (f N) l"] by auto |
2589 ultimately show False using Min_le[OF **(1), of "dist (f N) l"] by auto |
2590 qed |
2590 qed |
2591 |
2591 |
2592 lemma sequence_unique_limpt: |
2592 lemma sequence_unique_limpt: |
2593 assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" "l' islimpt {y. (\<exists>n. y = f n)}" |
2593 assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" "l' islimpt {y. (\<exists>n. y = f n)}" |
2594 shows "l' = l" |
2594 shows "l' = l" |
2595 proof(rule ccontr) |
2595 proof(rule ccontr) |
2596 def e \<equiv> "dist l' l" |
2596 def e \<equiv> "dist l' l" |
2597 assume "l' \<noteq> l" hence "e>0" unfolding dist_nz e_def by auto |
2597 assume "l' \<noteq> l" hence "e>0" unfolding dist_nz e_def by auto |
2598 then obtain N::nat where N:"\<forall>n\<ge>N. dist (f n) l < e / 2" |
2598 then obtain N::nat where N:"\<forall>n\<ge>N. dist (f n) l < e / 2" |
2599 using assms(2)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
2599 using assms(2)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
2600 def d \<equiv> "Min (insert (e/2) ((\<lambda>n. if dist (f n) l' = 0 then e/2 else dist (f n) l') ` {0 .. N}))" |
2600 def d \<equiv> "Min (insert (e/2) ((\<lambda>n. if dist (f n) l' = 0 then e/2 else dist (f n) l') ` {0 .. N}))" |
2601 have "d>0" using `e>0` unfolding d_def e_def using dist_pos_le[of _ l', unfolded order_le_less] by auto |
2601 have "d>0" using `e>0` unfolding d_def e_def using dist_pos_le[of _ l', unfolded order_le_less] by auto |
2602 obtain k where k:"f k \<noteq> l'" "dist (f k) l' < d" using `d>0` and assms(3)[unfolded islimpt_approachable, THEN spec[where x="d"]] by auto |
2602 obtain k where k:"f k \<noteq> l'" "dist (f k) l' < d" using `d>0` and assms(3)[unfolded islimpt_approachable, THEN spec[where x="d"]] by auto |
2603 have "k\<ge>N" using k(1)[unfolded dist_nz] using k(2)[unfolded d_def] |
2603 have "k\<ge>N" using k(1)[unfolded dist_nz] using k(2)[unfolded d_def] |
2604 by force |
2604 by force |
2605 hence "dist l' l < e" using N[THEN spec[where x=k]] using k(2)[unfolded d_def] and dist_triangle_half_r[of "f k" l' e l] by auto |
2605 hence "dist l' l < e" using N[THEN spec[where x=k]] using k(2)[unfolded d_def] and dist_triangle_half_r[of "f k" l' e l] by auto |
2606 thus False unfolding e_def by auto |
2606 thus False unfolding e_def by auto |
2607 qed |
2607 qed |
2608 |
2608 |
2609 lemma bolzano_weierstrass_imp_closed: |
2609 lemma bolzano_weierstrass_imp_closed: |
2610 assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" |
2610 assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" |
2611 shows "closed s" |
2611 shows "closed s" |
2612 proof- |
2612 proof- |
2613 { fix x l assume as: "\<forall>n::nat. x n \<in> s" "(x ---> l) sequentially" |
2613 { fix x l assume as: "\<forall>n::nat. x n \<in> s" "(x ---> l) sequentially" |
2614 hence "l \<in> s" |
2614 hence "l \<in> s" |
2634 assume ?rhs |
2634 assume ?rhs |
2635 hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x\<in>s. x islimpt t)" using heine_borel_imp_bolzano_weierstrass[of s] by blast |
2635 hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x\<in>s. x islimpt t)" using heine_borel_imp_bolzano_weierstrass[of s] by blast |
2636 thus ?lhs using bolzano_weierstrass_imp_bounded[of s] bolzano_weierstrass_imp_closed[of s] bounded_closed_imp_compact[of s] by blast |
2636 thus ?lhs using bolzano_weierstrass_imp_bounded[of s] bolzano_weierstrass_imp_closed[of s] bounded_closed_imp_compact[of s] by blast |
2637 qed |
2637 qed |
2638 |
2638 |
2639 lemma compact_eq_bolzano_weierstrass: |
2639 lemma compact_eq_bolzano_weierstrass: |
2640 "compact s \<longleftrightarrow> (\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t))" (is "?lhs = ?rhs") |
2640 "compact s \<longleftrightarrow> (\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t))" (is "?lhs = ?rhs") |
2641 proof |
2641 proof |
2642 assume ?lhs thus ?rhs unfolding compact_eq_heine_borel using heine_borel_imp_bolzano_weierstrass[of s] by auto |
2642 assume ?lhs thus ?rhs unfolding compact_eq_heine_borel using heine_borel_imp_bolzano_weierstrass[of s] by auto |
2643 next |
2643 next |
2644 assume ?rhs thus ?lhs using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed bounded_closed_imp_compact by auto |
2644 assume ?rhs thus ?lhs using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed bounded_closed_imp_compact by auto |
2645 qed |
2645 qed |
2646 |
2646 |
2647 lemma compact_eq_bounded_closed: |
2647 lemma compact_eq_bounded_closed: |
2648 "compact s \<longleftrightarrow> bounded s \<and> closed s" (is "?lhs = ?rhs") |
2648 "compact s \<longleftrightarrow> bounded s \<and> closed s" (is "?lhs = ?rhs") |
2649 proof |
2649 proof |
2650 assume ?lhs thus ?rhs unfolding compact_eq_bolzano_weierstrass using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed by auto |
2650 assume ?lhs thus ?rhs unfolding compact_eq_bolzano_weierstrass using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed by auto |
2651 next |
2651 next |
2652 assume ?rhs thus ?lhs using bounded_closed_imp_compact by auto |
2652 assume ?rhs thus ?lhs using bounded_closed_imp_compact by auto |
2653 qed |
2653 qed |
2654 |
2654 |
2655 lemma compact_imp_bounded: |
2655 lemma compact_imp_bounded: |
2656 "compact s ==> bounded s" |
2656 "compact s ==> bounded s" |
2657 unfolding compact_eq_bounded_closed |
2657 unfolding compact_eq_bounded_closed |
2658 by simp |
2658 by simp |
2659 |
2659 |
2660 lemma compact_imp_closed: |
2660 lemma compact_imp_closed: |
2661 "compact s ==> closed s" |
2661 "compact s ==> closed s" |
2662 unfolding compact_eq_bounded_closed |
2662 unfolding compact_eq_bounded_closed |
2663 by simp |
2663 by simp |
2664 |
2664 |
2665 text{* In particular, some common special cases. *} |
2665 text{* In particular, some common special cases. *} |
2666 |
2666 |
2667 lemma compact_empty[simp]: |
2667 lemma compact_empty[simp]: |
2668 "compact {}" |
2668 "compact {}" |
2669 unfolding compact_def |
2669 unfolding compact_def |
2670 by simp |
2670 by simp |
2671 |
2671 |
2672 (* FIXME : Rename *) |
2672 (* FIXME : Rename *) |
2673 lemma compact_union[intro]: |
2673 lemma compact_union[intro]: |
2674 "compact s \<Longrightarrow> compact t ==> compact (s \<union> t)" |
2674 "compact s \<Longrightarrow> compact t ==> compact (s \<union> t)" |
2675 unfolding compact_eq_bounded_closed |
2675 unfolding compact_eq_bounded_closed |
2676 using bounded_Un[of s t] |
2676 using bounded_Un[of s t] |
2677 using closed_Un[of s t] |
2677 using closed_Un[of s t] |
2678 by simp |
2678 by simp |
2679 |
2679 |
2680 lemma compact_inter[intro]: |
2680 lemma compact_inter[intro]: |
2681 "compact s \<Longrightarrow> compact t ==> compact (s \<inter> t)" |
2681 "compact s \<Longrightarrow> compact t ==> compact (s \<inter> t)" |
2682 unfolding compact_eq_bounded_closed |
2682 unfolding compact_eq_bounded_closed |
2683 using bounded_Int[of s t] |
2683 using bounded_Int[of s t] |
2684 using closed_Int[of s t] |
2684 using closed_Int[of s t] |
2685 by simp |
2685 by simp |
2686 |
2686 |
2687 lemma compact_inter_closed[intro]: |
2687 lemma compact_inter_closed[intro]: |
2688 "compact s \<Longrightarrow> closed t ==> compact (s \<inter> t)" |
2688 "compact s \<Longrightarrow> closed t ==> compact (s \<inter> t)" |
2689 unfolding compact_eq_bounded_closed |
2689 unfolding compact_eq_bounded_closed |
2690 using closed_Int[of s t] |
2690 using closed_Int[of s t] |
2691 using bounded_subset[of "s \<inter> t" s] |
2691 using bounded_subset[of "s \<inter> t" s] |
2692 by blast |
2692 by blast |
2693 |
2693 |
2694 lemma closed_inter_compact[intro]: |
2694 lemma closed_inter_compact[intro]: |
2695 "closed s \<Longrightarrow> compact t ==> compact (s \<inter> t)" |
2695 "closed s \<Longrightarrow> compact t ==> compact (s \<inter> t)" |
2696 proof- |
2696 proof- |
2697 assume "closed s" "compact t" |
2697 assume "closed s" "compact t" |
2698 moreover |
2698 moreover |
2699 have "s \<inter> t = t \<inter> s" by auto ultimately |
2699 have "s \<inter> t = t \<inter> s" by auto ultimately |
2700 show ?thesis |
2700 show ?thesis |
2701 using compact_inter_closed[of t s] |
2701 using compact_inter_closed[of t s] |
2702 by auto |
2702 by auto |
2703 qed |
2703 qed |
2704 |
2704 |
2705 lemma finite_imp_closed: |
2705 lemma finite_imp_closed: |
2706 "finite s ==> closed s" |
2706 "finite s ==> closed s" |
2707 proof- |
2707 proof- |
2708 assume "finite s" hence "\<not>( \<exists>t. t \<subseteq> s \<and> infinite t)" using finite_subset by auto |
2708 assume "finite s" hence "\<not>( \<exists>t. t \<subseteq> s \<and> infinite t)" using finite_subset by auto |
2709 thus ?thesis using bolzano_weierstrass_imp_closed[of s] by auto |
2709 thus ?thesis using bolzano_weierstrass_imp_closed[of s] by auto |
2710 qed |
2710 qed |
2711 |
2711 |
2712 lemma finite_imp_compact: |
2712 lemma finite_imp_compact: |
2713 "finite s ==> compact s" |
2713 "finite s ==> compact s" |
2714 unfolding compact_eq_bounded_closed |
2714 unfolding compact_eq_bounded_closed |
2715 using finite_imp_closed finite_imp_bounded |
2715 using finite_imp_closed finite_imp_bounded |
2716 by blast |
2716 by blast |
2717 |
2717 |
2718 lemma compact_sing[simp]: |
2718 lemma compact_sing[simp]: |
2719 "compact {a}" |
2719 "compact {a}" |
2720 using finite_imp_compact[of "{a}"] |
2720 using finite_imp_compact[of "{a}"] |
2721 by blast |
2721 by blast |
2722 |
2722 |
2723 lemma closed_sing[simp]: |
2723 lemma closed_sing[simp]: |
2724 "closed {a}" |
2724 "closed {a}" |
2725 using compact_eq_bounded_closed compact_sing[of a] |
2725 using compact_eq_bounded_closed compact_sing[of a] |
2726 by blast |
2726 by blast |
2727 |
2727 |
2728 lemma compact_cball[simp]: |
2728 lemma compact_cball[simp]: |
2729 "compact(cball x e)" |
2729 "compact(cball x e)" |
2730 using compact_eq_bounded_closed bounded_cball closed_cball |
2730 using compact_eq_bounded_closed bounded_cball closed_cball |
2731 by blast |
2731 by blast |
2732 |
2732 |
2733 lemma compact_frontier_bounded[intro]: |
2733 lemma compact_frontier_bounded[intro]: |
2734 "bounded s ==> compact(frontier s)" |
2734 "bounded s ==> compact(frontier s)" |
2735 unfolding frontier_def |
2735 unfolding frontier_def |
2736 using compact_eq_bounded_closed |
2736 using compact_eq_bounded_closed |
2737 by blast |
2737 by blast |
2738 |
2738 |
2739 lemma compact_frontier[intro]: |
2739 lemma compact_frontier[intro]: |
2740 "compact s ==> compact (frontier s)" |
2740 "compact s ==> compact (frontier s)" |
2741 using compact_eq_bounded_closed compact_frontier_bounded |
2741 using compact_eq_bounded_closed compact_frontier_bounded |
2742 by blast |
2742 by blast |
2743 |
2743 |
2744 lemma frontier_subset_compact: |
2744 lemma frontier_subset_compact: |
2745 "compact s ==> frontier s \<subseteq> s" |
2745 "compact s ==> frontier s \<subseteq> s" |
2746 using frontier_subset_closed compact_eq_bounded_closed |
2746 using frontier_subset_closed compact_eq_bounded_closed |
2747 by blast |
2747 by blast |
2748 |
2748 |
2749 lemma open_delete: |
2749 lemma open_delete: |
2750 "open s ==> open(s - {x})" |
2750 "open s ==> open(s - {x})" |
2751 using open_diff[of s "{x}"] closed_sing |
2751 using open_diff[of s "{x}"] closed_sing |
2752 by blast |
2752 by blast |
2753 |
2753 |
2754 text{* Finite intersection property. I could make it an equivalence in fact. *} |
2754 text{* Finite intersection property. I could make it an equivalence in fact. *} |
2755 |
2755 |
2756 lemma compact_imp_fip: |
2756 lemma compact_imp_fip: |
2757 assumes "compact s" "\<forall>t \<in> f. closed t" |
2757 assumes "compact s" "\<forall>t \<in> f. closed t" |
2758 "\<forall>f'. finite f' \<and> f' \<subseteq> f --> (s \<inter> (\<Inter> f') \<noteq> {})" |
2758 "\<forall>f'. finite f' \<and> f' \<subseteq> f --> (s \<inter> (\<Inter> f') \<noteq> {})" |
2759 shows "s \<inter> (\<Inter> f) \<noteq> {}" |
2759 shows "s \<inter> (\<Inter> f) \<noteq> {}" |
2760 proof |
2760 proof |
2761 assume as:"s \<inter> (\<Inter> f) = {}" |
2761 assume as:"s \<inter> (\<Inter> f) = {}" |
2787 moreover |
2787 moreover |
2788 have "r (max N n) \<ge> n" using lr(2) using monotone_bigger[of r "max N n"] by auto |
2788 have "r (max N n) \<ge> n" using lr(2) using monotone_bigger[of r "max N n"] by auto |
2789 hence "(x \<circ> r) (max N n) \<in> s n" |
2789 hence "(x \<circ> r) (max N n) \<in> s n" |
2790 using x apply(erule_tac x=n in allE) |
2790 using x apply(erule_tac x=n in allE) |
2791 using x apply(erule_tac x="r (max N n)" in allE) |
2791 using x apply(erule_tac x="r (max N n)" in allE) |
2792 using assms(3) apply(erule_tac x=n in allE)apply( erule_tac x="r (max N n)" in allE) by auto |
2792 using assms(3) apply(erule_tac x=n in allE)apply( erule_tac x="r (max N n)" in allE) by auto |
2793 ultimately have "\<exists>y\<in>s n. dist y l < e" by auto |
2793 ultimately have "\<exists>y\<in>s n. dist y l < e" by auto |
2794 } |
2794 } |
2795 hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by blast |
2795 hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by blast |
2796 } |
2796 } |
2797 thus ?thesis by auto |
2797 thus ?thesis by auto |
2798 qed |
2798 qed |
2799 |
2799 |
2800 text{* Decreasing case does not even need compactness, just completeness. *} |
2800 text{* Decreasing case does not even need compactness, just completeness. *} |
2801 |
2801 |
2802 lemma decreasing_closed_nest: |
2802 lemma decreasing_closed_nest: |
2803 assumes "\<forall>n. closed(s n)" |
2803 assumes "\<forall>n. closed(s n)" |
2804 "\<forall>n. (s n \<noteq> {})" |
2804 "\<forall>n. (s n \<noteq> {})" |
2805 "\<forall>m n. m \<le> n --> s n \<subseteq> s m" |
2805 "\<forall>m n. m \<le> n --> s n \<subseteq> s m" |
2806 "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y \<in> (s n). dist x y < e" |
2806 "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y \<in> (s n). dist x y < e" |
2807 shows "\<exists>a::real^'a. \<forall>n::nat. a \<in> s n" |
2807 shows "\<exists>a::real^'a. \<forall>n::nat. a \<in> s n" |
2808 proof- |
2808 proof- |
2809 have "\<forall>n. \<exists> x. x\<in>s n" using assms(2) by auto |
2809 have "\<forall>n. \<exists> x. x\<in>s n" using assms(2) by auto |
2810 hence "\<exists>t. \<forall>n. t n \<in> s n" using choice[of "\<lambda> n x. x \<in> s n"] by auto |
2810 hence "\<exists>t. \<forall>n. t n \<in> s n" using choice[of "\<lambda> n x. x \<in> s n"] by auto |
2811 then obtain t where t: "\<forall>n. t n \<in> s n" by auto |
2811 then obtain t where t: "\<forall>n. t n \<in> s n" by auto |
2812 { fix e::real assume "e>0" |
2812 { fix e::real assume "e>0" |
2998 hence "eventually (\<lambda>xa. dist (f xa) (f x) < e) (at x)" using assms unfolding continuous_at tendsto_def by auto |
2998 hence "eventually (\<lambda>xa. dist (f xa) (f x) < e) (at x)" using assms unfolding continuous_at tendsto_def by auto |
2999 then obtain d where d:"d>0" "\<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" unfolding eventually_at by auto |
2999 then obtain d where d:"d>0" "\<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" unfolding eventually_at by auto |
3000 { fix x' assume "\<not> 0 < dist x' x" |
3000 { fix x' assume "\<not> 0 < dist x' x" |
3001 hence "x=x'" |
3001 hence "x=x'" |
3002 using dist_nz[of x' x] by auto |
3002 using dist_nz[of x' x] by auto |
3003 hence "dist (f x') (f x) < e" using dist_refl[of "f x'"] `e>0` by auto |
3003 hence "dist (f x') (f x) < e" using dist_refl[of "f x'"] `e>0` by auto |
3004 } |
3004 } |
3005 thus "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using d by auto |
3005 thus "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using d by auto |
3006 qed |
3006 qed |
3007 |
3007 |
3008 lemma continuous_on_eq_continuous_within: |
3008 lemma continuous_on_eq_continuous_within: |
3009 "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x within s) f)" (is "?lhs = ?rhs") |
3009 "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x within s) f)" (is "?lhs = ?rhs") |
3010 proof |
3010 proof |
3011 assume ?rhs |
3011 assume ?rhs |
3012 { fix x assume "x\<in>s" |
3012 { fix x assume "x\<in>s" |
3013 fix e::real assume "e>0" |
3013 fix e::real assume "e>0" |
3014 assume "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" |
3014 assume "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" |
3015 then 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) < e" by auto |
3015 then 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) < e" by auto |
3016 { fix x' assume as:"x'\<in>s" "dist x' x < d" |
3016 { fix x' assume as:"x'\<in>s" "dist x' x < d" |
3017 hence "dist (f x') (f x) < e" using dist_refl[of "f x'"] `e>0` d `x'\<in>s` dist_eq_0[of x' x] dist_pos_le[of x' x] as(2) by (metis dist_eq_0 dist_nz) } |
3017 hence "dist (f x') (f x) < e" using dist_refl[of "f x'"] `e>0` d `x'\<in>s` dist_eq_0[of x' x] dist_pos_le[of x' x] as(2) by (metis dist_eq_0 dist_nz) } |
3018 hence "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `d>0` by (auto simp add: dist_refl) |
3018 hence "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `d>0` by (auto simp add: dist_refl) |
3019 } |
3019 } |
3020 thus ?lhs using `?rhs` unfolding continuous_on_def continuous_within Lim_within by auto |
3020 thus ?lhs using `?rhs` unfolding continuous_on_def continuous_within Lim_within by auto |
3021 next |
3021 next |
3022 assume ?lhs |
3022 assume ?lhs |
3023 thus ?rhs unfolding continuous_on_def continuous_within Lim_within by blast |
3023 thus ?rhs unfolding continuous_on_def continuous_within Lim_within by blast |
3024 qed |
3024 qed |
3025 |
3025 |
3026 lemma continuous_on: |
3026 lemma continuous_on: |
3027 "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. (f ---> f(x)) (at x within s))" |
3027 "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. (f ---> f(x)) (at x within s))" |
3028 by (auto simp add: continuous_on_eq_continuous_within continuous_within) |
3028 by (auto simp add: continuous_on_eq_continuous_within continuous_within) |
3029 |
3029 |
3030 lemma continuous_on_eq_continuous_at: |
3030 lemma continuous_on_eq_continuous_at: |
3031 "open s ==> (continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x) f))" |
3031 "open s ==> (continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x) f))" |
3032 by (auto simp add: continuous_on continuous_at Lim_within_open) |
3032 by (auto simp add: continuous_on continuous_at Lim_within_open) |
3033 |
3033 |
3034 lemma continuous_within_subset: |
3034 lemma continuous_within_subset: |
3035 "continuous (at x within s) f \<Longrightarrow> t \<subseteq> s |
3035 "continuous (at x within s) f \<Longrightarrow> t \<subseteq> s |
3036 ==> continuous (at x within t) f" |
3036 ==> continuous (at x within t) f" |
3037 unfolding continuous_within by(metis Lim_within_subset) |
3037 unfolding continuous_within by(metis Lim_within_subset) |
3038 |
3038 |
3039 lemma continuous_on_subset: |
3039 lemma continuous_on_subset: |
3040 "continuous_on s f \<Longrightarrow> t \<subseteq> s ==> continuous_on t f" |
3040 "continuous_on s f \<Longrightarrow> t \<subseteq> s ==> continuous_on t f" |
3041 unfolding continuous_on by (metis subset_eq Lim_within_subset) |
3041 unfolding continuous_on by (metis subset_eq Lim_within_subset) |
3042 |
3042 |
3043 lemma continuous_on_interior: |
3043 lemma continuous_on_interior: |
3044 "continuous_on s f \<Longrightarrow> x \<in> interior s ==> continuous (at x) f" |
3044 "continuous_on s f \<Longrightarrow> x \<in> interior s ==> continuous (at x) f" |
3045 unfolding interior_def |
3045 unfolding interior_def |
3046 apply simp |
3046 apply simp |
3047 by (meson continuous_on_eq_continuous_at continuous_on_subset) |
3047 by (meson continuous_on_eq_continuous_at continuous_on_subset) |
3048 |
3048 |
3049 lemma continuous_on_eq: |
3049 lemma continuous_on_eq: |
3050 "(\<forall>x \<in> s. f x = g x) \<Longrightarrow> continuous_on s f |
3050 "(\<forall>x \<in> s. f x = g x) \<Longrightarrow> continuous_on s f |
3051 ==> continuous_on s g" |
3051 ==> continuous_on s g" |
3052 by (simp add: continuous_on_def) |
3052 by (simp add: continuous_on_def) |
3053 |
3053 |
3054 text{* Characterization of various kinds of continuity in terms of sequences. *} |
3054 text{* Characterization of various kinds of continuity in terms of sequences. *} |
3055 |
3055 |
3056 lemma continuous_within_sequentially: |
3056 lemma continuous_within_sequentially: |
3057 "continuous (at a within s) f \<longleftrightarrow> |
3057 "continuous (at a within s) f \<longleftrightarrow> |
3058 (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially |
3058 (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially |
3059 --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") |
3059 --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") |
3060 proof |
3060 proof |
3061 assume ?lhs |
3061 assume ?lhs |
3091 hence "False" apply(erule_tac x=e in allE) using `e>0` using x by auto |
3091 hence "False" apply(erule_tac x=e in allE) using `e>0` using x by auto |
3092 } |
3092 } |
3093 thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast |
3093 thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast |
3094 qed |
3094 qed |
3095 |
3095 |
3096 lemma continuous_at_sequentially: |
3096 lemma continuous_at_sequentially: |
3097 "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially |
3097 "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially |
3098 --> ((f o x) ---> f a) sequentially)" |
3098 --> ((f o x) ---> f a) sequentially)" |
3099 using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto |
3099 using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto |
3100 |
3100 |
3101 lemma continuous_on_sequentially: |
3101 lemma continuous_on_sequentially: |
3102 "continuous_on s f \<longleftrightarrow> (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially |
3102 "continuous_on s f \<longleftrightarrow> (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially |
3103 --> ((f o x) ---> f(a)) sequentially)" (is "?lhs = ?rhs") |
3103 --> ((f o x) ---> f(a)) sequentially)" (is "?lhs = ?rhs") |
3104 proof |
3104 proof |
3105 assume ?rhs thus ?lhs using continuous_within_sequentially[of _ s f] unfolding continuous_on_eq_continuous_within by auto |
3105 assume ?rhs thus ?lhs using continuous_within_sequentially[of _ s f] unfolding continuous_on_eq_continuous_within by auto |
3106 next |
3106 next |
3107 assume ?lhs thus ?rhs unfolding continuous_on_eq_continuous_within using continuous_within_sequentially[of _ s f] by auto |
3107 assume ?lhs thus ?rhs unfolding continuous_on_eq_continuous_within using continuous_within_sequentially[of _ s f] by auto |
3108 qed |
3108 qed |
3109 |
3109 |
3110 lemma uniformly_continuous_on_sequentially: |
3110 lemma uniformly_continuous_on_sequentially: |
3111 "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> |
3111 "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> |
3112 ((\<lambda>n. x n - y n) ---> 0) sequentially |
3112 ((\<lambda>n. x n - y n) ---> 0) sequentially |
3113 \<longrightarrow> ((\<lambda>n. f(x n) - f(y n)) ---> 0) sequentially)" (is "?lhs = ?rhs") |
3113 \<longrightarrow> ((\<lambda>n. f(x n) - f(y n)) ---> 0) sequentially)" (is "?lhs = ?rhs") |
3114 proof |
3114 proof |
3115 assume ?lhs |
3115 assume ?lhs |
3116 { fix x y assume x:"\<forall>n. x n \<in> s" and y:"\<forall>n. y n \<in> s" and xy:"((\<lambda>n. x n - y n) ---> 0) sequentially" |
3116 { fix x y assume x:"\<forall>n. x n \<in> s" and y:"\<forall>n. y n \<in> s" and xy:"((\<lambda>n. x n - y n) ---> 0) sequentially" |
3117 { fix e::real assume "e>0" |
3117 { fix e::real assume "e>0" |
3118 then obtain d where "d>0" and d:"\<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" |
3118 then obtain d where "d>0" and d:"\<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" |
3119 using `?lhs`[unfolded uniformly_continuous_on_def, THEN spec[where x=e]] by auto |
3119 using `?lhs`[unfolded uniformly_continuous_on_def, THEN spec[where x=e]] by auto |
3120 obtain N where N:"\<forall>n\<ge>N. norm (x n - y n - 0) < d" using xy[unfolded Lim_sequentially dist_def] and `d>0` by auto |
3120 obtain N where N:"\<forall>n\<ge>N. norm (x n - y n - 0) < d" using xy[unfolded Lim_sequentially dist_def] and `d>0` by auto |
3121 { fix n assume "n\<ge>N" |
3121 { fix n assume "n\<ge>N" |
3150 thus ?lhs unfolding uniformly_continuous_on_def by blast |
3150 thus ?lhs unfolding uniformly_continuous_on_def by blast |
3151 qed |
3151 qed |
3152 |
3152 |
3153 text{* The usual transformation theorems. *} |
3153 text{* The usual transformation theorems. *} |
3154 |
3154 |
3155 lemma continuous_transform_within: |
3155 lemma continuous_transform_within: |
3156 assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'" |
3156 assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'" |
3157 "continuous (at x within s) f" |
3157 "continuous (at x within s) f" |
3158 shows "continuous (at x within s) g" |
3158 shows "continuous (at x within s) g" |
3159 proof- |
3159 proof- |
3160 { fix e::real assume "e>0" |
3160 { fix e::real assume "e>0" |
3161 then obtain d' where d':"d'>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d' \<longrightarrow> dist (f xa) (f x) < e" using assms(4) unfolding continuous_within Lim_within by auto |
3161 then obtain d' where d':"d'>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d' \<longrightarrow> dist (f xa) (f x) < e" using assms(4) unfolding continuous_within Lim_within by auto |
3162 { fix x' assume "x'\<in>s" "0 < dist x' x" "dist x' x < (min d d')" |
3162 { fix x' assume "x'\<in>s" "0 < dist x' x" "dist x' x < (min d d')" |
3163 hence "dist (f x') (g x) < e" using assms(2,3) apply(erule_tac x=x in ballE) unfolding dist_refl using d' by auto } |
3163 hence "dist (f x') (g x) < e" using assms(2,3) apply(erule_tac x=x in ballE) unfolding dist_refl using d' by auto } |
3164 hence "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast |
3164 hence "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast |
3165 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto } |
3165 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto } |
3166 hence "(f ---> g x) (at x within s)" unfolding Lim_within using assms(1) by auto |
3166 hence "(f ---> g x) (at x within s)" unfolding Lim_within using assms(1) by auto |
3167 thus ?thesis unfolding continuous_within using Lim_transform_within[of d s x f g "g x"] using assms by blast |
3167 thus ?thesis unfolding continuous_within using Lim_transform_within[of d s x f g "g x"] using assms by blast |
3168 qed |
3168 qed |
3169 |
3169 |
3170 lemma continuous_transform_at: |
3170 lemma continuous_transform_at: |
3171 assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'" |
3171 assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'" |
3172 "continuous (at x) f" |
3172 "continuous (at x) f" |
3178 hence "dist (f x') (g x) < e" using assms(2) apply(erule_tac x=x in allE) unfolding dist_refl using d' by auto |
3178 hence "dist (f x') (g x) < e" using assms(2) apply(erule_tac x=x in allE) unfolding dist_refl using d' by auto |
3179 } |
3179 } |
3180 hence "\<forall>xa. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast |
3180 hence "\<forall>xa. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast |
3181 hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto |
3181 hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto |
3182 } |
3182 } |
3183 hence "(f ---> g x) (at x)" unfolding Lim_at using assms(1) by auto |
3183 hence "(f ---> g x) (at x)" unfolding Lim_at using assms(1) by auto |
3184 thus ?thesis unfolding continuous_at using Lim_transform_at[of d x f g "g x"] using assms by blast |
3184 thus ?thesis unfolding continuous_at using Lim_transform_at[of d x f g "g x"] using assms by blast |
3185 qed |
3185 qed |
3186 |
3186 |
3187 text{* Combination results for pointwise continuity. *} |
3187 text{* Combination results for pointwise continuity. *} |
3188 |
3188 |
3189 lemma continuous_const: "continuous net (\<lambda>x::'a::zero_neq_one. c)" |
3189 lemma continuous_const: "continuous net (\<lambda>x::'a::zero_neq_one. c)" |
3190 by(auto simp add: continuous_def Lim_const) |
3190 by(auto simp add: continuous_def Lim_const) |
3191 |
3191 |
3192 lemma continuous_cmul: |
3192 lemma continuous_cmul: |
3193 "continuous net f ==> continuous net (\<lambda>x. c *s f x)" |
3193 "continuous net f ==> continuous net (\<lambda>x. c *s f x)" |
3194 by(auto simp add: continuous_def Lim_cmul) |
3194 by(auto simp add: continuous_def Lim_cmul) |
3195 |
3195 |
3196 lemma continuous_neg: |
3196 lemma continuous_neg: |
3197 "continuous net f ==> continuous net (\<lambda>x. -(f x))" |
3197 "continuous net f ==> continuous net (\<lambda>x. -(f x))" |
3198 by(auto simp add: continuous_def Lim_neg) |
3198 by(auto simp add: continuous_def Lim_neg) |
3199 |
3199 |
3200 lemma continuous_add: |
3200 lemma continuous_add: |
3201 "continuous net f \<Longrightarrow> continuous net g |
3201 "continuous net f \<Longrightarrow> continuous net g |
3202 ==> continuous net (\<lambda>x. f x + g x)" |
3202 ==> continuous net (\<lambda>x. f x + g x)" |
3203 by(auto simp add: continuous_def Lim_add) |
3203 by(auto simp add: continuous_def Lim_add) |
3204 |
3204 |
3205 lemma continuous_sub: |
3205 lemma continuous_sub: |
3206 "continuous net f \<Longrightarrow> continuous net g |
3206 "continuous net f \<Longrightarrow> continuous net g |
3207 ==> continuous net (\<lambda>x. f(x) - g(x))" |
3207 ==> continuous net (\<lambda>x. f(x) - g(x))" |
3208 by(auto simp add: continuous_def Lim_sub) |
3208 by(auto simp add: continuous_def Lim_sub) |
3209 |
3209 |
3210 text{* Same thing for setwise continuity. *} |
3210 text{* Same thing for setwise continuity. *} |
3211 |
3211 |
3212 lemma continuous_on_const: |
3212 lemma continuous_on_const: |
3213 "continuous_on s (\<lambda>x. c)" |
3213 "continuous_on s (\<lambda>x. c)" |
3214 unfolding continuous_on_eq_continuous_within using continuous_const by blast |
3214 unfolding continuous_on_eq_continuous_within using continuous_const by blast |
3215 |
3215 |
3216 lemma continuous_on_cmul: |
3216 lemma continuous_on_cmul: |
3217 "continuous_on s f ==> continuous_on s (\<lambda>x. c *s (f x))" |
3217 "continuous_on s f ==> continuous_on s (\<lambda>x. c *s (f x))" |
3218 unfolding continuous_on_eq_continuous_within using continuous_cmul by blast |
3218 unfolding continuous_on_eq_continuous_within using continuous_cmul by blast |
3219 |
3219 |
3220 lemma continuous_on_neg: |
3220 lemma continuous_on_neg: |
3221 "continuous_on s f ==> continuous_on s (\<lambda>x. -(f x))" |
3221 "continuous_on s f ==> continuous_on s (\<lambda>x. -(f x))" |
3222 unfolding continuous_on_eq_continuous_within using continuous_neg by blast |
3222 unfolding continuous_on_eq_continuous_within using continuous_neg by blast |
3223 |
3223 |
3224 lemma continuous_on_add: |
3224 lemma continuous_on_add: |
3225 "continuous_on s f \<Longrightarrow> continuous_on s g |
3225 "continuous_on s f \<Longrightarrow> continuous_on s g |
3226 ==> continuous_on s (\<lambda>x. f x + g x)" |
3226 ==> continuous_on s (\<lambda>x. f x + g x)" |
3227 unfolding continuous_on_eq_continuous_within using continuous_add by blast |
3227 unfolding continuous_on_eq_continuous_within using continuous_add by blast |
3228 |
3228 |
3229 lemma continuous_on_sub: |
3229 lemma continuous_on_sub: |
3230 "continuous_on s f \<Longrightarrow> continuous_on s g |
3230 "continuous_on s f \<Longrightarrow> continuous_on s g |
3231 ==> continuous_on s (\<lambda>x. f(x) - g(x))" |
3231 ==> continuous_on s (\<lambda>x. f(x) - g(x))" |
3232 unfolding continuous_on_eq_continuous_within using continuous_sub by blast |
3232 unfolding continuous_on_eq_continuous_within using continuous_sub by blast |
3233 |
3233 |
3234 text{* Same thing for uniform continuity, using sequential formulations. *} |
3234 text{* Same thing for uniform continuity, using sequential formulations. *} |
3235 |
3235 |
3236 lemma uniformly_continuous_on_const: |
3236 lemma uniformly_continuous_on_const: |
3237 "uniformly_continuous_on s (\<lambda>x. c)" |
3237 "uniformly_continuous_on s (\<lambda>x. c)" |
3238 unfolding uniformly_continuous_on_sequentially using Lim_const[of 0] by auto |
3238 unfolding uniformly_continuous_on_sequentially using Lim_const[of 0] by auto |
3239 |
3239 |
3240 lemma uniformly_continuous_on_cmul: |
3240 lemma uniformly_continuous_on_cmul: |
3241 assumes "uniformly_continuous_on s f" |
3241 assumes "uniformly_continuous_on s f" |
3242 shows "uniformly_continuous_on s (\<lambda>x. c *s f(x))" |
3242 shows "uniformly_continuous_on s (\<lambda>x. c *s f(x))" |
3243 proof- |
3243 proof- |
3244 { fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially" |
3244 { fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially" |
3245 hence "((\<lambda>n. c *s f (x n) - c *s f (y n)) ---> 0) sequentially" |
3245 hence "((\<lambda>n. c *s f (x n) - c *s f (y n)) ---> 0) sequentially" |
3265 using Lim_add[of "\<lambda> n. f (x n) - f (y n)" 0 sequentially "\<lambda> n. g (x n) - g (y n)" 0] by auto |
3265 using Lim_add[of "\<lambda> n. f (x n) - f (y n)" 0 sequentially "\<lambda> n. g (x n) - g (y n)" 0] by auto |
3266 hence "((\<lambda>n. f (x n) + g (x n) - (f (y n) + g (y n))) ---> 0) sequentially" unfolding Lim_sequentially and * by auto } |
3266 hence "((\<lambda>n. f (x n) + g (x n) - (f (y n) + g (y n))) ---> 0) sequentially" unfolding Lim_sequentially and * by auto } |
3267 thus ?thesis using assms unfolding uniformly_continuous_on_sequentially by auto |
3267 thus ?thesis using assms unfolding uniformly_continuous_on_sequentially by auto |
3268 qed |
3268 qed |
3269 |
3269 |
3270 lemma uniformly_continuous_on_sub: |
3270 lemma uniformly_continuous_on_sub: |
3271 "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s g |
3271 "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s g |
3272 ==> uniformly_continuous_on s (\<lambda>x. f x - g x)" |
3272 ==> uniformly_continuous_on s (\<lambda>x. f x - g x)" |
3273 unfolding ab_diff_minus |
3273 unfolding ab_diff_minus |
3274 using uniformly_continuous_on_add[of s f "\<lambda>x. - g x"] |
3274 using uniformly_continuous_on_add[of s f "\<lambda>x. - g x"] |
3275 using uniformly_continuous_on_neg[of s g] by auto |
3275 using uniformly_continuous_on_neg[of s g] by auto |
3276 |
3276 |
3277 text{* Identity function is continuous in every sense. *} |
3277 text{* Identity function is continuous in every sense. *} |
3278 |
3278 |
3279 lemma continuous_within_id: |
3279 lemma continuous_within_id: |
3280 "continuous (at a within s) (\<lambda>x. x)" |
3280 "continuous (at a within s) (\<lambda>x. x)" |
3281 unfolding continuous_within Lim_within by auto |
3281 unfolding continuous_within Lim_within by auto |
3282 |
3282 |
3283 lemma continuous_at_id: |
3283 lemma continuous_at_id: |
3284 "continuous (at a) (\<lambda>x. x)" |
3284 "continuous (at a) (\<lambda>x. x)" |
3285 unfolding continuous_at Lim_at by auto |
3285 unfolding continuous_at Lim_at by auto |
3286 |
3286 |
3287 lemma continuous_on_id: |
3287 lemma continuous_on_id: |
3288 "continuous_on s (\<lambda>x. x)" |
3288 "continuous_on s (\<lambda>x. x)" |
3289 unfolding continuous_on Lim_within by auto |
3289 unfolding continuous_on Lim_within by auto |
3290 |
3290 |
3291 lemma uniformly_continuous_on_id: |
3291 lemma uniformly_continuous_on_id: |
3292 "uniformly_continuous_on s (\<lambda>x. x)" |
3292 "uniformly_continuous_on s (\<lambda>x. x)" |
3293 unfolding uniformly_continuous_on_def by auto |
3293 unfolding uniformly_continuous_on_def by auto |
3294 |
3294 |
3295 text{* Continuity of all kinds is preserved under composition. *} |
3295 text{* Continuity of all kinds is preserved under composition. *} |
3296 |
3296 |
3297 lemma continuous_within_compose: |
3297 lemma continuous_within_compose: |
3298 assumes "continuous (at x within s) f" "continuous (at (f x) within f ` s) g" |
3298 assumes "continuous (at x within s) f" "continuous (at (f x) within f ` s) g" |
3299 shows "continuous (at x within s) (g o f)" |
3299 shows "continuous (at x within s) (g o f)" |
3300 proof- |
3300 proof- |
3301 { fix e::real assume "e>0" |
3301 { fix e::real assume "e>0" |
3302 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 |
3302 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 |
3303 from assms(1)[unfolded continuous_within Lim_within] 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) < d" using `d>0` by auto |
3303 from assms(1)[unfolded continuous_within Lim_within] 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) < d" using `d>0` by auto |
3304 { fix y assume as:"y\<in>s" "0 < dist y x" "dist y x < d'" |
3304 { fix y assume as:"y\<in>s" "0 < dist y x" "dist y x < d'" |
3305 hence "dist (f y) (f x) < d" using d'[THEN bspec[where x=y]] by (auto simp add:dist_sym) |
3305 hence "dist (f y) (f x) < d" using d'[THEN bspec[where x=y]] by (auto simp add:dist_sym) |
3306 hence "dist (g (f y)) (g (f x)) < e" using as(1) d[THEN bspec[where x="f y"]] unfolding dist_nz[THEN sym] using `e>0` by (auto simp add: dist_refl) } |
3306 hence "dist (g (f y)) (g (f x)) < e" using as(1) d[THEN bspec[where x="f y"]] unfolding dist_nz[THEN sym] using `e>0` by (auto simp add: dist_refl) } |
3307 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 } |
3307 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 } |
3308 thus ?thesis unfolding continuous_within Lim_within by auto |
3308 thus ?thesis unfolding continuous_within Lim_within by auto |
3309 qed |
3309 qed |
3310 |
3310 |
3311 lemma continuous_at_compose: |
3311 lemma continuous_at_compose: |
3312 assumes "continuous (at x) f" "continuous (at (f x)) g" |
3312 assumes "continuous (at x) f" "continuous (at (f x)) g" |
3313 shows "continuous (at x) (g o f)" |
3313 shows "continuous (at x) (g o f)" |
3314 proof- |
3314 proof- |
3315 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 |
3315 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 |
3316 thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto |
3316 thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto |
3317 qed |
3317 qed |
3318 |
3318 |
3319 lemma continuous_on_compose: |
3319 lemma continuous_on_compose: |
3320 "continuous_on s f \<Longrightarrow> continuous_on (f ` s) g \<Longrightarrow> continuous_on s (g o f)" |
3320 "continuous_on s f \<Longrightarrow> continuous_on (f ` s) g \<Longrightarrow> continuous_on s (g o f)" |
3321 unfolding continuous_on_eq_continuous_within using continuous_within_compose[of _ s f g] by auto |
3321 unfolding continuous_on_eq_continuous_within using continuous_within_compose[of _ s f g] by auto |
3322 |
3322 |
3323 lemma uniformly_continuous_on_compose: |
3323 lemma uniformly_continuous_on_compose: |
3324 assumes "uniformly_continuous_on s f" "uniformly_continuous_on (f ` s) g" |
3324 assumes "uniformly_continuous_on s f" "uniformly_continuous_on (f ` s) g" |
3325 shows "uniformly_continuous_on s (g o f)" |
3325 shows "uniformly_continuous_on s (g o f)" |
3326 proof- |
3326 proof- |
3327 { fix e::real assume "e>0" |
3327 { fix e::real assume "e>0" |
3328 then obtain d where "d>0" and d:"\<forall>x\<in>f ` s. \<forall>x'\<in>f ` s. dist x' x < d \<longrightarrow> dist (g x') (g x) < e" using assms(2) unfolding uniformly_continuous_on_def by auto |
3328 then obtain d where "d>0" and d:"\<forall>x\<in>f ` s. \<forall>x'\<in>f ` s. dist x' x < d \<longrightarrow> dist (g x') (g x) < e" using assms(2) unfolding uniformly_continuous_on_def by auto |
3331 thus ?thesis using assms unfolding uniformly_continuous_on_def by auto |
3331 thus ?thesis using assms unfolding uniformly_continuous_on_def by auto |
3332 qed |
3332 qed |
3333 |
3333 |
3334 text{* Continuity in terms of open preimages. *} |
3334 text{* Continuity in terms of open preimages. *} |
3335 |
3335 |
3336 lemma continuous_at_open: |
3336 lemma continuous_at_open: |
3337 "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") |
3337 "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") |
3338 proof |
3338 proof |
3339 assume ?lhs |
3339 assume ?lhs |
3340 { fix t assume as: "open t" "f x \<in> t" |
3340 { fix t assume as: "open t" "f x \<in> t" |
3341 then obtain e where "e>0" and e:"ball (f x) e \<subseteq> t" unfolding open_contains_ball by auto |
3341 then obtain e where "e>0" and e:"ball (f x) e \<subseteq> t" unfolding open_contains_ball by auto |
3342 |
3342 |
3343 obtain d where "d>0" and d:"\<forall>y. 0 < dist y x \<and> dist y x < d \<longrightarrow> dist (f y) (f x) < e" using `e>0` using `?lhs`[unfolded continuous_at Lim_at open_def] by auto |
3343 obtain d where "d>0" and d:"\<forall>y. 0 < dist y x \<and> dist y x < d \<longrightarrow> dist (f y) (f x) < e" using `e>0` using `?lhs`[unfolded continuous_at Lim_at open_def] by auto |
3344 |
3344 |
3345 have "open (ball x d)" using open_ball by auto |
3345 have "open (ball x d)" using open_ball by auto |
3346 moreover have "x \<in> ball x d" unfolding centre_in_ball using `d>0` by simp |
3346 moreover have "x \<in> ball x d" unfolding centre_in_ball using `d>0` by simp |
3347 moreover |
3347 moreover |
3348 { fix x' assume "x'\<in>ball x d" hence "f x' \<in> t" |
3348 { fix x' assume "x'\<in>ball x d" hence "f x' \<in> t" |
3349 using e[unfolded subset_eq Ball_def mem_ball, THEN spec[where x="f x'"]] d[THEN spec[where x=x']] |
3349 using e[unfolded subset_eq Ball_def mem_ball, THEN spec[where x="f x'"]] d[THEN spec[where x=x']] |
3350 unfolding mem_ball apply (auto simp add: dist_sym) |
3350 unfolding mem_ball apply (auto simp add: dist_sym) |
3351 unfolding dist_nz[THEN sym] using as(2) by auto } |
3351 unfolding dist_nz[THEN sym] using as(2) by auto } |
3352 hence "\<forall>x'\<in>ball x d. f x' \<in> t" by auto |
3352 hence "\<forall>x'\<in>ball x d. f x' \<in> t" by auto |
3353 ultimately have "\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x'\<in>s. f x' \<in> t)" |
3353 ultimately have "\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x'\<in>s. f x' \<in> t)" |
3354 apply(rule_tac x="ball x d" in exI) by simp } |
3354 apply(rule_tac x="ball x d" in exI) by simp } |
3355 thus ?rhs by auto |
3355 thus ?rhs by auto |
3356 next |
3356 next |
3357 assume ?rhs |
3357 assume ?rhs |
3358 { fix e::real assume "e>0" |
3358 { fix e::real assume "e>0" |
3361 then obtain d where "d>0" and d:"ball x d \<subseteq> s" unfolding open_contains_ball by auto |
3361 then obtain d where "d>0" and d:"ball x d \<subseteq> s" unfolding open_contains_ball by auto |
3362 { fix y assume "0 < dist y x \<and> dist y x < d" |
3362 { fix y assume "0 < dist y x \<and> dist y x < d" |
3363 hence "dist (f y) (f x) < e" using d[unfolded subset_eq Ball_def mem_ball, THEN spec[where x=y]] |
3363 hence "dist (f y) (f x) < e" using d[unfolded subset_eq Ball_def mem_ball, THEN spec[where x=y]] |
3364 using s(3)[THEN bspec[where x=y], unfolded mem_ball] by (auto simp add: dist_sym) } |
3364 using s(3)[THEN bspec[where x=y], unfolded mem_ball] by (auto simp add: dist_sym) } |
3365 hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `d>0` by auto } |
3365 hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `d>0` by auto } |
3366 thus ?lhs unfolding continuous_at Lim_at by auto |
3366 thus ?lhs unfolding continuous_at Lim_at by auto |
3367 qed |
3367 qed |
3368 |
3368 |
3369 lemma continuous_on_open: |
3369 lemma continuous_on_open: |
3370 "continuous_on s f \<longleftrightarrow> |
3370 "continuous_on s f \<longleftrightarrow> |
3371 (\<forall>t. openin (subtopology euclidean (f ` s)) t |
3371 (\<forall>t. openin (subtopology euclidean (f ` s)) t |
3372 --> openin (subtopology euclidean s) {x \<in> s. f x \<in> t})" (is "?lhs = ?rhs") |
3372 --> openin (subtopology euclidean s) {x \<in> s. f x \<in> t})" (is "?lhs = ?rhs") |
3373 proof |
3373 proof |
3374 assume ?lhs |
3374 assume ?lhs |
3375 { fix t assume as:"openin (subtopology euclidean (f ` s)) t" |
3375 { fix t assume as:"openin (subtopology euclidean (f ` s)) t" |
3376 have "{x \<in> s. f x \<in> t} \<subseteq> s" using as[unfolded openin_euclidean_subtopology_iff] by auto |
3376 have "{x \<in> s. f x \<in> t} \<subseteq> s" using as[unfolded openin_euclidean_subtopology_iff] by auto |
3377 moreover |
3377 moreover |
3378 { fix x assume as':"x\<in>{x \<in> s. f x \<in> t}" |
3378 { fix x assume as':"x\<in>{x \<in> s. f x \<in> t}" |
3379 then obtain e where e: "e>0" "\<forall>x'\<in>f ` s. dist x' (f x) < e \<longrightarrow> x' \<in> t" using as[unfolded openin_euclidean_subtopology_iff, THEN conjunct2, THEN bspec[where x="f x"]] by auto |
3379 then obtain e where e: "e>0" "\<forall>x'\<in>f ` s. dist x' (f x) < e \<longrightarrow> x' \<in> t" using as[unfolded openin_euclidean_subtopology_iff, THEN conjunct2, THEN bspec[where x="f x"]] by auto |
3380 from this(1) obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `?lhs`[unfolded continuous_on Lim_within, THEN bspec[where x=x]] using as' by auto |
3380 from this(1) obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `?lhs`[unfolded continuous_on Lim_within, THEN bspec[where x=x]] using as' by auto |
3381 have "\<exists>e>0. \<forall>x'\<in>s. dist x' x < e \<longrightarrow> x' \<in> {x \<in> s. f x \<in> t}" using d e unfolding dist_nz[THEN sym] by (rule_tac x=d in exI, auto simp add: dist_refl) } |
3381 have "\<exists>e>0. \<forall>x'\<in>s. dist x' x < e \<longrightarrow> x' \<in> {x \<in> s. f x \<in> t}" using d e unfolding dist_nz[THEN sym] by (rule_tac x=d in exI, auto simp add: dist_refl) } |
3382 ultimately have "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" unfolding openin_euclidean_subtopology_iff by auto } |
3382 ultimately have "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" unfolding openin_euclidean_subtopology_iff by auto } |
3383 thus ?rhs unfolding continuous_on Lim_within using openin by auto |
3383 thus ?rhs unfolding continuous_on Lim_within using openin by auto |
3384 next |
3384 next |
3385 assume ?rhs |
3385 assume ?rhs |
3386 { fix e::real and x assume "x\<in>s" "e>0" |
3386 { fix e::real and x assume "x\<in>s" "e>0" |
3387 { fix xa x' assume "dist (f xa) (f x) < e" "xa \<in> s" "x' \<in> s" "dist (f xa) (f x') < e - dist (f xa) (f x)" |
3387 { fix xa x' assume "dist (f xa) (f x) < e" "xa \<in> s" "x' \<in> s" "dist (f xa) (f x') < e - dist (f xa) (f x)" |
3388 hence "dist (f x') (f x) < e" using dist_triangle[of "f x'" "f x" "f xa"] |
3388 hence "dist (f x') (f x) < e" using dist_triangle[of "f x'" "f x" "f xa"] |
3389 by (auto simp add: dist_sym) } |
3389 by (auto simp add: dist_sym) } |
3390 hence "ball (f x) e \<inter> f ` s \<subseteq> f ` s \<and> (\<forall>xa\<in>ball (f x) e \<inter> f ` s. \<exists>ea>0. \<forall>x'\<in>f ` s. dist x' xa < ea \<longrightarrow> x' \<in> ball (f x) e \<inter> f ` s)" apply auto |
3390 hence "ball (f x) e \<inter> f ` s \<subseteq> f ` s \<and> (\<forall>xa\<in>ball (f x) e \<inter> f ` s. \<exists>ea>0. \<forall>x'\<in>f ` s. dist x' xa < ea \<longrightarrow> x' \<in> ball (f x) e \<inter> f ` s)" apply auto |
3391 apply(rule_tac x="e - dist (f xa) (f x)" in exI) using `e>0` by (auto simp add: dist_sym) |
3391 apply(rule_tac x="e - dist (f xa) (f x)" in exI) using `e>0` by (auto simp add: dist_sym) |
3392 hence "\<forall>xa\<in>{xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}. \<exists>ea>0. \<forall>x'\<in>s. dist x' xa < ea \<longrightarrow> x' \<in> {xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}" |
3392 hence "\<forall>xa\<in>{xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}. \<exists>ea>0. \<forall>x'\<in>s. dist x' xa < ea \<longrightarrow> x' \<in> {xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}" |
3393 using `?rhs`[unfolded openin_euclidean_subtopology_iff, THEN spec[where x="ball (f x) e \<inter> f ` s"]] by auto |
3393 using `?rhs`[unfolded openin_euclidean_subtopology_iff, THEN spec[where x="ball (f x) e \<inter> f ` s"]] by auto |
3394 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" apply(erule_tac x=x in ballE) apply auto unfolding dist_refl using `e>0` `x\<in>s` by (auto simp add: dist_sym) } |
3394 hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" apply(erule_tac x=x in ballE) apply auto unfolding dist_refl using `e>0` `x\<in>s` by (auto simp add: dist_sym) } |
3395 thus ?lhs unfolding continuous_on Lim_within by auto |
3395 thus ?lhs unfolding continuous_on Lim_within by auto |
3421 thus ?lhs unfolding continuous_on_open by auto |
3421 thus ?lhs unfolding continuous_on_open by auto |
3422 qed |
3422 qed |
3423 |
3423 |
3424 text{* Half-global and completely global cases. *} |
3424 text{* Half-global and completely global cases. *} |
3425 |
3425 |
3426 lemma continuous_open_in_preimage: |
3426 lemma continuous_open_in_preimage: |
3427 assumes "continuous_on s f" "open t" |
3427 assumes "continuous_on s f" "open t" |
3428 shows "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" |
3428 shows "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" |
3429 proof- |
3429 proof- |
3430 have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto |
3430 have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto |
3431 have "openin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" |
3431 have "openin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" |
3432 using openin_open_Int[of t "f ` s", OF assms(2)] unfolding openin_open by auto |
3432 using openin_open_Int[of t "f ` s", OF assms(2)] unfolding openin_open by auto |
3433 thus ?thesis using assms(1)[unfolded continuous_on_open, THEN spec[where x="t \<inter> f ` s"]] using * by auto |
3433 thus ?thesis using assms(1)[unfolded continuous_on_open, THEN spec[where x="t \<inter> f ` s"]] using * by auto |
3434 qed |
3434 qed |
3435 |
3435 |
3436 lemma continuous_closed_in_preimage: |
3436 lemma continuous_closed_in_preimage: |
3437 assumes "continuous_on s f" "closed t" |
3437 assumes "continuous_on s f" "closed t" |
3438 shows "closedin (subtopology euclidean s) {x \<in> s. f x \<in> t}" |
3438 shows "closedin (subtopology euclidean s) {x \<in> s. f x \<in> t}" |
3439 proof- |
3439 proof- |
3440 have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto |
3440 have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto |
3441 have "closedin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" |
3441 have "closedin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" |
3442 using closedin_closed_Int[of t "f ` s", OF assms(2)] unfolding Int_commute by auto |
3442 using closedin_closed_Int[of t "f ` s", OF assms(2)] unfolding Int_commute by auto |
3443 thus ?thesis |
3443 thus ?thesis |
3444 using assms(1)[unfolded continuous_on_closed, THEN spec[where x="t \<inter> f ` s"]] using * by auto |
3444 using assms(1)[unfolded continuous_on_closed, THEN spec[where x="t \<inter> f ` s"]] using * by auto |
3445 qed |
3445 qed |
3446 |
3446 |
3447 lemma continuous_open_preimage: |
3447 lemma continuous_open_preimage: |
3448 assumes "continuous_on s f" "open s" "open t" |
3448 assumes "continuous_on s f" "open s" "open t" |
3449 shows "open {x \<in> s. f x \<in> t}" |
3449 shows "open {x \<in> s. f x \<in> t}" |
3450 proof- |
3450 proof- |
3451 obtain T where T: "open T" "{x \<in> s. f x \<in> t} = s \<inter> T" |
3451 obtain T where T: "open T" "{x \<in> s. f x \<in> t} = s \<inter> T" |
3452 using continuous_open_in_preimage[OF assms(1,3)] unfolding openin_open by auto |
3452 using continuous_open_in_preimage[OF assms(1,3)] unfolding openin_open by auto |
3453 thus ?thesis using open_inter[of s T, OF assms(2)] by auto |
3453 thus ?thesis using open_inter[of s T, OF assms(2)] by auto |
3454 qed |
3454 qed |
3455 |
3455 |
3456 lemma continuous_closed_preimage: |
3456 lemma continuous_closed_preimage: |
3457 assumes "continuous_on s f" "closed s" "closed t" |
3457 assumes "continuous_on s f" "closed s" "closed t" |
3458 shows "closed {x \<in> s. f x \<in> t}" |
3458 shows "closed {x \<in> s. f x \<in> t}" |
3459 proof- |
3459 proof- |
3460 obtain T where T: "closed T" "{x \<in> s. f x \<in> t} = s \<inter> T" |
3460 obtain T where T: "closed T" "{x \<in> s. f x \<in> t} = s \<inter> T" |
3461 using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto |
3461 using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto |
3462 thus ?thesis using closed_Int[of s T, OF assms(2)] by auto |
3462 thus ?thesis using closed_Int[of s T, OF assms(2)] by auto |
3463 qed |
3463 qed |
3464 |
3464 |
3465 lemma continuous_open_preimage_univ: |
3465 lemma continuous_open_preimage_univ: |
3466 "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}" |
3466 "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}" |
3467 using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto |
3467 using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto |
3468 |
3468 |
3469 lemma continuous_closed_preimage_univ: |
3469 lemma continuous_closed_preimage_univ: |
3470 "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}" |
3470 "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}" |
3471 using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto |
3471 using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto |
3472 |
3472 |
3473 text{* Equality of continuous functions on closure and related results. *} |
3473 text{* Equality of continuous functions on closure and related results. *} |
3474 |
3474 |
3475 lemma continuous_closed_in_preimage_constant: |
3475 lemma continuous_closed_in_preimage_constant: |
3476 "continuous_on s f ==> closedin (subtopology euclidean s) {x \<in> s. f x = a}" |
3476 "continuous_on s f ==> closedin (subtopology euclidean s) {x \<in> s. f x = a}" |
3477 using continuous_closed_in_preimage[of s f "{a}"] closed_sing by auto |
3477 using continuous_closed_in_preimage[of s f "{a}"] closed_sing by auto |
3478 |
3478 |
3479 lemma continuous_closed_preimage_constant: |
3479 lemma continuous_closed_preimage_constant: |
3480 "continuous_on s f \<Longrightarrow> closed s ==> closed {x \<in> s. f x = a}" |
3480 "continuous_on s f \<Longrightarrow> closed s ==> closed {x \<in> s. f x = a}" |
3481 using continuous_closed_preimage[of s f "{a}"] closed_sing by auto |
3481 using continuous_closed_preimage[of s f "{a}"] closed_sing by auto |
3482 |
3482 |
3483 lemma continuous_constant_on_closure: |
3483 lemma continuous_constant_on_closure: |
3484 assumes "continuous_on (closure s) f" |
3484 assumes "continuous_on (closure s) f" |
3485 "\<forall>x \<in> s. f x = a" |
3485 "\<forall>x \<in> s. f x = a" |
3486 shows "\<forall>x \<in> (closure s). f x = a" |
3486 shows "\<forall>x \<in> (closure s). f x = a" |
3487 using continuous_closed_preimage_constant[of "closure s" f a] |
3487 using continuous_closed_preimage_constant[of "closure s" f a] |
3488 assms closure_minimal[of s "{x \<in> closure s. f x = a}"] closure_subset unfolding subset_eq by auto |
3488 assms closure_minimal[of s "{x \<in> closure s. f x = a}"] closure_subset unfolding subset_eq by auto |
3489 |
3489 |
3490 lemma image_closure_subset: |
3490 lemma image_closure_subset: |
3491 assumes "continuous_on (closure s) f" "closed t" "(f ` s) \<subseteq> t" |
3491 assumes "continuous_on (closure s) f" "closed t" "(f ` s) \<subseteq> t" |
3492 shows "f ` (closure s) \<subseteq> t" |
3492 shows "f ` (closure s) \<subseteq> t" |
3493 proof- |
3493 proof- |
3494 have "s \<subseteq> {x \<in> closure s. f x \<in> t}" using assms(3) closure_subset by auto |
3494 have "s \<subseteq> {x \<in> closure s. f x \<in> t}" using assms(3) closure_subset by auto |
3495 moreover have "closed {x \<in> closure s. f x \<in> t}" |
3495 moreover have "closed {x \<in> closure s. f x \<in> t}" |
3521 hence "f y \<noteq> a" using d[THEN bspec[where x=y]] assms(3)[unfolded dist_nz] |
3521 hence "f y \<noteq> a" using d[THEN bspec[where x=y]] assms(3)[unfolded dist_nz] |
3522 apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_sym) } |
3522 apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_sym) } |
3523 thus ?thesis using `d>0` by auto |
3523 thus ?thesis using `d>0` by auto |
3524 qed |
3524 qed |
3525 |
3525 |
3526 lemma continuous_at_avoid: |
3526 lemma continuous_at_avoid: |
3527 assumes "continuous (at x) f" "f x \<noteq> a" |
3527 assumes "continuous (at x) f" "f x \<noteq> a" |
3528 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3528 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3529 using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto |
3529 using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto |
3530 |
3530 |
3531 lemma continuous_on_avoid: |
3531 lemma continuous_on_avoid: |
3532 assumes "continuous_on s f" "x \<in> s" "f x \<noteq> a" |
3532 assumes "continuous_on s f" "x \<in> s" "f x \<noteq> a" |
3533 shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e \<longrightarrow> f y \<noteq> a" |
3533 shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e \<longrightarrow> f y \<noteq> a" |
3534 using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x], OF assms(2)] continuous_within_avoid[of x s f a] assms(2,3) by auto |
3534 using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x], OF assms(2)] continuous_within_avoid[of x s f a] assms(2,3) by auto |
3535 |
3535 |
3536 lemma continuous_on_open_avoid: |
3536 lemma continuous_on_open_avoid: |
3537 assumes "continuous_on s f" "open s" "x \<in> s" "f x \<noteq> a" |
3537 assumes "continuous_on s f" "open s" "x \<in> s" "f x \<noteq> a" |
3538 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3538 shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" |
3539 using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)] continuous_at_avoid[of x f a] assms(3,4) by auto |
3539 using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)] continuous_at_avoid[of x f a] assms(3,4) by auto |
3540 |
3540 |
3541 text{* Proving a function is constant by proving open-ness of level set. *} |
3541 text{* Proving a function is constant by proving open-ness of level set. *} |
3542 |
3542 |
3543 lemma continuous_levelset_open_in_cases: |
3543 lemma continuous_levelset_open_in_cases: |
3544 "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> |
3544 "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> |
3545 openin (subtopology euclidean s) {x \<in> s. f x = a} |
3545 openin (subtopology euclidean s) {x \<in> s. f x = a} |
3546 ==> (\<forall>x \<in> s. f x \<noteq> a) \<or> (\<forall>x \<in> s. f x = a)" |
3546 ==> (\<forall>x \<in> s. f x \<noteq> a) \<or> (\<forall>x \<in> s. f x = a)" |
3547 unfolding connected_clopen using continuous_closed_in_preimage_constant by auto |
3547 unfolding connected_clopen using continuous_closed_in_preimage_constant by auto |
3548 |
3548 |
3549 lemma continuous_levelset_open_in: |
3549 lemma continuous_levelset_open_in: |
3550 "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> |
3550 "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> |
3551 openin (subtopology euclidean s) {x \<in> s. f x = a} \<Longrightarrow> |
3551 openin (subtopology euclidean s) {x \<in> s. f x = a} \<Longrightarrow> |
3552 (\<exists>x \<in> s. f x = a) ==> (\<forall>x \<in> s. f x = a)" |
3552 (\<exists>x \<in> s. f x = a) ==> (\<forall>x \<in> s. f x = a)" |
3553 using continuous_levelset_open_in_cases[of s f ] |
3553 using continuous_levelset_open_in_cases[of s f ] |
3554 by meson |
3554 by meson |
3555 |
3555 |
3556 lemma continuous_levelset_open: |
3556 lemma continuous_levelset_open: |
3557 assumes "connected s" "continuous_on s f" "open {x \<in> s. f x = a}" "\<exists>x \<in> s. f x = a" |
3557 assumes "connected s" "continuous_on s f" "open {x \<in> s. f x = a}" "\<exists>x \<in> s. f x = a" |
3558 shows "\<forall>x \<in> s. f x = a" |
3558 shows "\<forall>x \<in> s. f x = a" |
3559 using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by auto |
3559 using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by auto |
3560 |
3560 |
3561 text{* Some arithmetical combinations (more to prove). *} |
3561 text{* Some arithmetical combinations (more to prove). *} |
3562 |
3562 |
3563 lemma open_scaling[intro]: |
3563 lemma open_scaling[intro]: |
3564 assumes "c \<noteq> 0" "open s" |
3564 assumes "c \<noteq> 0" "open s" |
3565 shows "open((\<lambda>x. c *s x) ` s)" |
3565 shows "open((\<lambda>x. c *s x) ` s)" |
3566 proof- |
3566 proof- |
3567 { fix x assume "x \<in> s" |
3567 { fix x assume "x \<in> s" |
3568 then obtain e where "e>0" and e:"\<forall>x'. dist x' x < e \<longrightarrow> x' \<in> s" using assms(2)[unfolded open_def, THEN bspec[where x=x]] by auto |
3568 then obtain e where "e>0" and e:"\<forall>x'. dist x' x < e \<longrightarrow> x' \<in> s" using assms(2)[unfolded open_def, THEN bspec[where x=x]] by auto |
3569 have "e * abs c > 0" using assms(1)[unfolded zero_less_abs_iff[THEN sym]] using real_mult_order[OF `e>0`] by auto |
3569 have "e * abs c > 0" using assms(1)[unfolded zero_less_abs_iff[THEN sym]] using real_mult_order[OF `e>0`] by auto |
3570 moreover |
3570 moreover |
3571 { fix y assume "dist y (c *s x) < e * \<bar>c\<bar>" |
3571 { fix y assume "dist y (c *s x) < e * \<bar>c\<bar>" |
3572 hence "norm ((1 / c) *s y - x) < e" unfolding dist_def |
3572 hence "norm ((1 / c) *s y - x) < e" unfolding dist_def |
3573 using norm_mul[of c "(1 / c) *s y - x", unfolded vector_ssub_ldistrib, unfolded vector_smult_assoc] assms(1) |
3573 using norm_mul[of c "(1 / c) *s y - x", unfolded vector_ssub_ldistrib, unfolded vector_smult_assoc] assms(1) |
3574 mult_less_imp_less_left[of "abs c" "norm ((1 / c) *s y - x)" e, unfolded real_mult_commute[of "abs c" e]] assms(1)[unfolded zero_less_abs_iff[THEN sym]] by simp |
3574 mult_less_imp_less_left[of "abs c" "norm ((1 / c) *s y - x)" e, unfolded real_mult_commute[of "abs c" e]] assms(1)[unfolded zero_less_abs_iff[THEN sym]] by simp |
3575 hence "y \<in> op *s c ` s" using rev_image_eqI[of "(1 / c) *s y" s y "op *s c"] e[THEN spec[where x="(1 / c) *s y"]] assms(1) unfolding dist_def vector_smult_assoc by auto } |
3575 hence "y \<in> op *s c ` s" using rev_image_eqI[of "(1 / c) *s y" s y "op *s c"] e[THEN spec[where x="(1 / c) *s y"]] assms(1) unfolding dist_def vector_smult_assoc by auto } |
3576 ultimately have "\<exists>e>0. \<forall>x'. dist x' (c *s x) < e \<longrightarrow> x' \<in> op *s c ` s" apply(rule_tac x="e * abs c" in exI) by auto } |
3576 ultimately have "\<exists>e>0. \<forall>x'. dist x' (c *s x) < e \<longrightarrow> x' \<in> op *s c ` s" apply(rule_tac x="e * abs c" in exI) by auto } |
3577 thus ?thesis unfolding open_def by auto |
3577 thus ?thesis unfolding open_def by auto |
3578 qed |
3578 qed |
3579 |
3579 |
3580 lemma open_negations: |
3580 lemma open_negations: |
3581 "open s ==> open ((\<lambda> x. -x) ` s)" unfolding pth_3 by auto |
3581 "open s ==> open ((\<lambda> x. -x) ` s)" unfolding pth_3 by auto |
3582 |
3582 |
3583 lemma open_translation: |
3583 lemma open_translation: |
3584 assumes "open s" shows "open((\<lambda>x. a + x) ` s)" |
3584 assumes "open s" shows "open((\<lambda>x. a + x) ` s)" |
3585 proof- |
3585 proof- |
3586 { fix x have "continuous (at x) (\<lambda>x. x - a)" using continuous_sub[of "at x" "\<lambda>x. x" "\<lambda>x. a"] continuous_at_id[of x] continuous_const[of "at x" a] by auto } |
3586 { fix x have "continuous (at x) (\<lambda>x. x - a)" using continuous_sub[of "at x" "\<lambda>x. x" "\<lambda>x. a"] continuous_at_id[of x] continuous_const[of "at x" a] by auto } |
3587 moreover have "{x. x - a \<in> s} = op + a ` s" apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto |
3587 moreover have "{x. x - a \<in> s} = op + a ` s" apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto |
3588 ultimately show ?thesis using continuous_open_preimage_univ[of "\<lambda>x. x - a" s] using assms by auto |
3588 ultimately show ?thesis using continuous_open_preimage_univ[of "\<lambda>x. x - a" s] using assms by auto |
3589 qed |
3589 qed |
3590 |
3590 |
3591 lemma open_affinity: |
3591 lemma open_affinity: |
3592 assumes "open s" "c \<noteq> 0" |
3592 assumes "open s" "c \<noteq> 0" |
3593 shows "open ((\<lambda>x. a + c *s x) ` s)" |
3593 shows "open ((\<lambda>x. a + c *s x) ` s)" |
3594 proof- |
3594 proof- |
3595 have *:"(\<lambda>x. a + c *s x) = (\<lambda>x. a + x) \<circ> (\<lambda>x. c *s x)" unfolding o_def .. |
3595 have *:"(\<lambda>x. a + c *s x) = (\<lambda>x. a + x) \<circ> (\<lambda>x. c *s x)" unfolding o_def .. |
3596 have "op + a ` op *s c ` s = (op + a \<circ> op *s c) ` s" by auto |
3596 have "op + a ` op *s c ` s = (op + a \<circ> op *s c) ` s" by auto |
3597 thus ?thesis using assms open_translation[of "op *s c ` s" a] unfolding * by auto |
3597 thus ?thesis using assms open_translation[of "op *s c ` s" a] unfolding * by auto |
3598 qed |
3598 qed |
3599 |
3599 |
3600 lemma interior_translation: "interior ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (interior s)" |
3600 lemma interior_translation: "interior ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (interior s)" |
3601 proof (rule set_ext, rule) |
3601 proof (rule set_ext, rule) |
3602 fix x assume "x \<in> interior (op + a ` s)" |
3602 fix x assume "x \<in> interior (op + a ` s)" |
3603 then obtain e where "e>0" and e:"ball x e \<subseteq> op + a ` s" unfolding mem_interior by auto |
3603 then obtain e where "e>0" and e:"ball x e \<subseteq> op + a ` s" unfolding mem_interior by auto |
3604 hence "ball (x - a) e \<subseteq> s" unfolding subset_eq Ball_def mem_ball dist_def apply auto apply(erule_tac x="a + xa" in allE) unfolding ab_group_add_class.diff_diff_eq[THEN sym] by auto |
3604 hence "ball (x - a) e \<subseteq> s" unfolding subset_eq Ball_def mem_ball dist_def apply auto apply(erule_tac x="a + xa" in allE) unfolding ab_group_add_class.diff_diff_eq[THEN sym] by auto |
3605 thus "x \<in> op + a ` interior s" unfolding image_iff apply(rule_tac x="x - a" in bexI) unfolding mem_interior using `e > 0` by auto |
3605 thus "x \<in> op + a ` interior s" unfolding image_iff apply(rule_tac x="x - a" in bexI) unfolding mem_interior using `e > 0` by auto |
3606 next |
3606 next |
3607 fix x assume "x \<in> op + a ` interior s" |
3607 fix x assume "x \<in> op + a ` interior s" |
3608 then obtain y e where "e>0" and e:"ball y e \<subseteq> s" and y:"x = a + y" unfolding image_iff Bex_def mem_interior by auto |
3608 then obtain y e where "e>0" and e:"ball y e \<subseteq> s" and y:"x = a + y" unfolding image_iff Bex_def mem_interior by auto |
3609 { fix z have *:"a + y - z = y + a - z" by auto |
3609 { fix z have *:"a + y - z = y + a - z" by auto |
3610 assume "z\<in>ball x e" |
3610 assume "z\<in>ball x e" |
3611 hence "z - a \<in> s" using e[unfolded subset_eq, THEN bspec[where x="z - a"]] unfolding mem_ball dist_def y ab_group_add_class.diff_diff_eq2 * by auto |
3611 hence "z - a \<in> s" using e[unfolded subset_eq, THEN bspec[where x="z - a"]] unfolding mem_ball dist_def y ab_group_add_class.diff_diff_eq2 * by auto |
3612 hence "z \<in> op + a ` s" unfolding image_iff by(auto intro!: bexI[where x="z - a"]) } |
3612 hence "z \<in> op + a ` s" unfolding image_iff by(auto intro!: bexI[where x="z - a"]) } |
3627 then obtain d where "d>0" and d:"\<forall>x'\<in>s. dist x' l < d \<longrightarrow> dist (f x') (f l) < e" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=l], OF `l\<in>s`] by auto |
3627 then obtain d where "d>0" and d:"\<forall>x'\<in>s. dist x' l < d \<longrightarrow> dist (f x') (f l) < e" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=l], OF `l\<in>s`] by auto |
3628 then obtain N::nat where N:"\<forall>n\<ge>N. dist ((y \<circ> r) n) l < d" using lr[unfolded Lim_sequentially, THEN spec[where x=d]] by auto |
3628 then obtain N::nat where N:"\<forall>n\<ge>N. dist ((y \<circ> r) n) l < d" using lr[unfolded Lim_sequentially, THEN spec[where x=d]] by auto |
3629 { fix n::nat assume "n\<ge>N" hence "dist ((x \<circ> r) n) (f l) < e" using N[THEN spec[where x=n]] d[THEN bspec[where x="y (r n)"]] y[THEN spec[where x="r n"]] by auto } |
3629 { fix n::nat assume "n\<ge>N" hence "dist ((x \<circ> r) n) (f l) < e" using N[THEN spec[where x=n]] d[THEN bspec[where x="y (r n)"]] y[THEN spec[where x="r n"]] by auto } |
3630 hence "\<exists>N. \<forall>n\<ge>N. dist ((x \<circ> r) n) (f l) < e" by auto } |
3630 hence "\<exists>N. \<forall>n\<ge>N. dist ((x \<circ> r) n) (f l) < e" by auto } |
3631 hence "\<exists>l\<in>f ` s. \<exists>r. (\<forall>m n. m < n \<longrightarrow> r m < r n) \<and> ((x \<circ> r) ---> l) sequentially" unfolding Lim_sequentially using r lr `l\<in>s` by auto } |
3631 hence "\<exists>l\<in>f ` s. \<exists>r. (\<forall>m n. m < n \<longrightarrow> r m < r n) \<and> ((x \<circ> r) ---> l) sequentially" unfolding Lim_sequentially using r lr `l\<in>s` by auto } |
3632 thus ?thesis unfolding compact_def by auto |
3632 thus ?thesis unfolding compact_def by auto |
3633 qed |
3633 qed |
3634 |
3634 |
3635 lemma connected_continuous_image: |
3635 lemma connected_continuous_image: |
3636 assumes "continuous_on s f" "connected s" |
3636 assumes "continuous_on s f" "connected s" |
3637 shows "connected(f ` s)" |
3637 shows "connected(f ` s)" |
3638 proof- |
3638 proof- |
3639 { fix T assume as: "T \<noteq> {}" "T \<noteq> f ` s" "openin (subtopology euclidean (f ` s)) T" "closedin (subtopology euclidean (f ` s)) T" |
3639 { fix T assume as: "T \<noteq> {}" "T \<noteq> f ` s" "openin (subtopology euclidean (f ` s)) T" "closedin (subtopology euclidean (f ` s)) T" |
3640 have "{x \<in> s. f x \<in> T} = {} \<or> {x \<in> s. f x \<in> T} = s" |
3640 have "{x \<in> s. f x \<in> T} = {} \<or> {x \<in> s. f x \<in> T} = s" |
3641 using assms(1)[unfolded continuous_on_open, THEN spec[where x=T]] |
3641 using assms(1)[unfolded continuous_on_open, THEN spec[where x=T]] |
3642 using assms(1)[unfolded continuous_on_closed, THEN spec[where x=T]] |
3642 using assms(1)[unfolded continuous_on_closed, THEN spec[where x=T]] |
3643 using assms(2)[unfolded connected_clopen, THEN spec[where x="{x \<in> s. f x \<in> T}"]] as(3,4) by auto |
3643 using assms(2)[unfolded connected_clopen, THEN spec[where x="{x \<in> s. f x \<in> T}"]] as(3,4) by auto |
3644 hence False using as(1,2) |
3644 hence False using as(1,2) |
3645 using as(4)[unfolded closedin_def topspace_euclidean_subtopology] by auto } |
3645 using as(4)[unfolded closedin_def topspace_euclidean_subtopology] by auto } |
3646 thus ?thesis unfolding connected_clopen by auto |
3646 thus ?thesis unfolding connected_clopen by auto |
3647 qed |
3647 qed |
3648 |
3648 |
3649 text{* Continuity implies uniform continuity on a compact domain. *} |
3649 text{* Continuity implies uniform continuity on a compact domain. *} |
3650 |
3650 |
3651 lemma compact_uniformly_continuous: |
3651 lemma compact_uniformly_continuous: |
3652 assumes "continuous_on s f" "compact s" |
3652 assumes "continuous_on s f" "compact s" |
3653 shows "uniformly_continuous_on s f" |
3653 shows "uniformly_continuous_on s f" |
3654 proof- |
3654 proof- |
3655 { fix x assume x:"x\<in>s" |
3655 { fix x assume x:"x\<in>s" |
3656 hence "\<forall>xa. \<exists>y. 0 < xa \<longrightarrow> (y > 0 \<and> (\<forall>x'\<in>s. dist x' x < y \<longrightarrow> dist (f x') (f x) < xa))" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=x]] by auto |
3656 hence "\<forall>xa. \<exists>y. 0 < xa \<longrightarrow> (y > 0 \<and> (\<forall>x'\<in>s. dist x' x < y \<longrightarrow> dist (f x') (f x) < xa))" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=x]] by auto |
3657 hence "\<exists>fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)" using choice[of "\<lambda>e d. e>0 \<longrightarrow> d>0 \<and>(\<forall>x'\<in>s. (dist x' x < d \<longrightarrow> dist (f x') (f x) < e))"] by auto } |
3657 hence "\<exists>fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)" using choice[of "\<lambda>e d. e>0 \<longrightarrow> d>0 \<and>(\<forall>x'\<in>s. (dist x' x < d \<longrightarrow> dist (f x') (f x) < e))"] by auto } |
3658 then have "\<forall>x\<in>s. \<exists>y. \<forall>xa. 0 < xa \<longrightarrow> (\<forall>x'\<in>s. y xa > 0 \<and> (dist x' x < y xa \<longrightarrow> dist (f x') (f x) < xa))" by auto |
3658 then have "\<forall>x\<in>s. \<exists>y. \<forall>xa. 0 < xa \<longrightarrow> (\<forall>x'\<in>s. y xa > 0 \<and> (dist x' x < y xa \<longrightarrow> dist (f x') (f x) < xa))" by auto |
3659 then obtain d where d:"\<forall>e>0. \<forall>x\<in>s. \<forall>x'\<in>s. d x e > 0 \<and> (dist x' x < d x e \<longrightarrow> dist (f x') (f x) < e)" |
3659 then obtain d where d:"\<forall>e>0. \<forall>x\<in>s. \<forall>x'\<in>s. d x e > 0 \<and> (dist x' x < d x e \<longrightarrow> dist (f x') (f x) < e)" |
3660 using bchoice[of s "\<lambda>x fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)"] by blast |
3660 using bchoice[of s "\<lambda>x fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)"] by blast |
3661 |
3661 |
3662 { fix e::real assume "e>0" |
3662 { fix e::real assume "e>0" |
3663 |
3663 |
3664 { fix x assume "x\<in>s" hence "x \<in> ball x (d x (e / 2))" unfolding centre_in_ball using d[THEN spec[where x="e/2"]] using `e>0` by auto } |
3664 { fix x assume "x\<in>s" hence "x \<in> ball x (d x (e / 2))" unfolding centre_in_ball using d[THEN spec[where x="e/2"]] using `e>0` by auto } |
3670 { fix x y assume "x\<in>s" "y\<in>s" and as:"dist y x < ea" |
3670 { fix x y assume "x\<in>s" "y\<in>s" and as:"dist y x < ea" |
3671 obtain z where "z\<in>s" and z:"ball x ea \<subseteq> ball z (d z (e / 2))" using ea[THEN bspec[where x=x]] and `x\<in>s` by auto |
3671 obtain z where "z\<in>s" and z:"ball x ea \<subseteq> ball z (d z (e / 2))" using ea[THEN bspec[where x=x]] and `x\<in>s` by auto |
3672 hence "x\<in>ball z (d z (e / 2))" using `ea>0` unfolding subset_eq by auto |
3672 hence "x\<in>ball z (d z (e / 2))" using `ea>0` unfolding subset_eq by auto |
3673 hence "dist (f z) (f x) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `x\<in>s` and `z\<in>s` |
3673 hence "dist (f z) (f x) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `x\<in>s` and `z\<in>s` |
3674 by (auto simp add: dist_sym) |
3674 by (auto simp add: dist_sym) |
3675 moreover have "y\<in>ball z (d z (e / 2))" using as and `ea>0` and z[unfolded subset_eq] |
3675 moreover have "y\<in>ball z (d z (e / 2))" using as and `ea>0` and z[unfolded subset_eq] |
3676 by (auto simp add: dist_sym) |
3676 by (auto simp add: dist_sym) |
3677 hence "dist (f z) (f y) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `y\<in>s` and `z\<in>s` |
3677 hence "dist (f z) (f y) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `y\<in>s` and `z\<in>s` |
3678 by (auto simp add: dist_sym) |
3678 by (auto simp add: dist_sym) |
3679 ultimately have "dist (f y) (f x) < e" using dist_triangle_half_r[of "f z" "f x" e "f y"] |
3679 ultimately have "dist (f y) (f x) < e" using dist_triangle_half_r[of "f z" "f x" e "f y"] |
3680 by (auto simp add: dist_sym) } |
3680 by (auto simp add: dist_sym) } |
3681 then have "\<exists>d>0. \<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `ea>0` by auto } |
3681 then have "\<exists>d>0. \<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `ea>0` by auto } |
3682 thus ?thesis unfolding uniformly_continuous_on_def by auto |
3682 thus ?thesis unfolding uniformly_continuous_on_def by auto |
3683 qed |
3683 qed |
3684 |
3684 |
3685 text{* Continuity of inverse function on compact domain. *} |
3685 text{* Continuity of inverse function on compact domain. *} |
3686 |
3686 |
3687 lemma continuous_on_inverse: |
3687 lemma continuous_on_inverse: |
3688 assumes "continuous_on s f" "compact s" "\<forall>x \<in> s. g (f x) = x" |
3688 assumes "continuous_on s f" "compact s" "\<forall>x \<in> s. g (f x) = x" |
3689 shows "continuous_on (f ` s) g" |
3689 shows "continuous_on (f ` s) g" |
3690 proof- |
3690 proof- |
3691 have *:"g ` f ` s = s" using assms(3) by (auto simp add: image_iff) |
3691 have *:"g ` f ` s = s" using assms(3) by (auto simp add: image_iff) |
3692 { fix t assume t:"closedin (subtopology euclidean (g ` f ` s)) t" |
3692 { fix t assume t:"closedin (subtopology euclidean (g ` f ` s)) t" |
3693 then obtain T where T: "closed T" "t = s \<inter> T" unfolding closedin_closed unfolding * by auto |
3693 then obtain T where T: "closed T" "t = s \<inter> T" unfolding closedin_closed unfolding * by auto |
3694 have "continuous_on (s \<inter> T) f" using continuous_on_subset[OF assms(1), of "s \<inter> t"] |
3694 have "continuous_on (s \<inter> T) f" using continuous_on_subset[OF assms(1), of "s \<inter> t"] |
3695 unfolding T(2) and Int_left_absorb by auto |
3695 unfolding T(2) and Int_left_absorb by auto |
3696 moreover have "compact (s \<inter> T)" |
3696 moreover have "compact (s \<inter> T)" |
3697 using assms(2) unfolding compact_eq_bounded_closed |
3697 using assms(2) unfolding compact_eq_bounded_closed |
3698 using bounded_subset[of s "s \<inter> T"] and T(1) by auto |
3698 using bounded_subset[of s "s \<inter> T"] and T(1) by auto |
3699 ultimately have "closed (f ` t)" using T(1) unfolding T(2) |
3699 ultimately have "closed (f ` t)" using T(1) unfolding T(2) |
3700 using compact_continuous_image unfolding compact_eq_bounded_closed by auto |
3700 using compact_continuous_image unfolding compact_eq_bounded_closed by auto |
3701 moreover have "{x \<in> f ` s. g x \<in> t} = f ` s \<inter> f ` t" using assms(3) unfolding T(2) by auto |
3701 moreover have "{x \<in> f ` s. g x \<in> t} = f ` s \<inter> f ` t" using assms(3) unfolding T(2) by auto |
3736 obtain B where "B>0" and B:"\<forall>x. norm (f x) \<le> B * norm x" using linear_bounded_pos[OF assms] by auto |
3736 obtain B where "B>0" and B:"\<forall>x. norm (f x) \<le> B * norm x" using linear_bounded_pos[OF assms] by auto |
3737 { fix e::real assume "e>0" |
3737 { fix e::real assume "e>0" |
3738 { fix x::"real^'a" assume "norm x < e / B" |
3738 { fix x::"real^'a" assume "norm x < e / B" |
3739 hence "B * norm x < e" using `B>0` using mult_strict_right_mono[of "norm x" " e / B" B] unfolding real_mult_commute by auto |
3739 hence "B * norm x < e" using `B>0` using mult_strict_right_mono[of "norm x" " e / B" B] unfolding real_mult_commute by auto |
3740 hence "norm (f x) < e" using B[THEN spec[where x=x]] `B>0` using order_le_less_trans[of "norm (f x)" "B * norm x" e] by auto } |
3740 hence "norm (f x) < e" using B[THEN spec[where x=x]] `B>0` using order_le_less_trans[of "norm (f x)" "B * norm x" e] by auto } |
3741 moreover have "e / B > 0" using `e>0` `B>0` divide_pos_pos by auto |
3741 moreover have "e / B > 0" using `e>0` `B>0` divide_pos_pos by auto |
3742 ultimately have "\<exists>d>0. \<forall>x. 0 < dist x 0 \<and> dist x 0 < d \<longrightarrow> dist (f x) 0 < e" unfolding dist_def by auto } |
3742 ultimately have "\<exists>d>0. \<forall>x. 0 < dist x 0 \<and> dist x 0 < d \<longrightarrow> dist (f x) 0 < e" unfolding dist_def by auto } |
3743 thus ?thesis unfolding Lim_at by auto |
3743 thus ?thesis unfolding Lim_at by auto |
3744 qed |
3744 qed |
3745 |
3745 |
3746 lemma linear_continuous_at: |
3746 lemma linear_continuous_at: |
3747 assumes "linear f" shows "continuous (at a) f" |
3747 assumes "linear f" shows "continuous (at a) f" |
3748 unfolding continuous_at Lim_at_zero[of f "f a" a] using linear_lim_0[OF assms] |
3748 unfolding continuous_at Lim_at_zero[of f "f a" a] using linear_lim_0[OF assms] |
3749 unfolding Lim_null[of "\<lambda>x. f (a + x)"] unfolding linear_sub[OF assms, THEN sym] by auto |
3749 unfolding Lim_null[of "\<lambda>x. f (a + x)"] unfolding linear_sub[OF assms, THEN sym] by auto |
3750 |
3750 |
3751 lemma linear_continuous_within: |
3751 lemma linear_continuous_within: |
3752 "linear f ==> continuous (at x within s) f" |
3752 "linear f ==> continuous (at x within s) f" |
3753 using continuous_at_imp_continuous_within[of x f s] using linear_continuous_at[of f] by auto |
3753 using continuous_at_imp_continuous_within[of x f s] using linear_continuous_at[of f] by auto |
3754 |
3754 |
3755 lemma linear_continuous_on: |
3755 lemma linear_continuous_on: |
3756 "linear f ==> continuous_on s f" |
3756 "linear f ==> continuous_on s f" |
3757 using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto |
3757 using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto |
3758 |
3758 |
3759 text{* Also bilinear functions, in composition form. *} |
3759 text{* Also bilinear functions, in composition form. *} |
3760 |
3760 |
3761 lemma bilinear_continuous_at_compose: |
3761 lemma bilinear_continuous_at_compose: |
3762 "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bilinear h |
3762 "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bilinear h |
3763 ==> continuous (at x) (\<lambda>x. h (f x) (g x))" |
3763 ==> continuous (at x) (\<lambda>x. h (f x) (g x))" |
3764 unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto |
3764 unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto |
3765 |
3765 |
3766 lemma bilinear_continuous_within_compose: |
3766 lemma bilinear_continuous_within_compose: |
3767 "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bilinear h |
3767 "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bilinear h |
3768 ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))" |
3768 ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))" |
3769 unfolding continuous_within using Lim_bilinear[of f "f x"] by auto |
3769 unfolding continuous_within using Lim_bilinear[of f "f x"] by auto |
3770 |
3770 |
3771 lemma bilinear_continuous_on_compose: |
3771 lemma bilinear_continuous_on_compose: |
3772 "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bilinear h |
3772 "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bilinear h |
3773 ==> continuous_on s (\<lambda>x. h (f x) (g x))" |
3773 ==> continuous_on s (\<lambda>x. h (f x) (g x))" |
3774 unfolding continuous_on_eq_continuous_within apply auto apply(erule_tac x=x in ballE) apply auto apply(erule_tac x=x in ballE) apply auto |
3774 unfolding continuous_on_eq_continuous_within apply auto apply(erule_tac x=x in ballE) apply auto apply(erule_tac x=x in ballE) apply auto |
3775 using bilinear_continuous_within_compose[of _ s f g h] by auto |
3775 using bilinear_continuous_within_compose[of _ s f g h] by auto |
3776 |
3776 |
3777 subsection{* Topological stuff lifted from and dropped to R *} |
3777 subsection{* Topological stuff lifted from and dropped to R *} |
3778 |
3778 |
3779 |
3779 |
3780 lemma open_vec1: |
3780 lemma open_vec1: |
3781 "open(vec1 ` s) \<longleftrightarrow> |
3781 "open(vec1 ` s) \<longleftrightarrow> |
3782 (\<forall>x \<in> s. \<exists>e>0. \<forall>x'. abs(x' - x) < e --> x' \<in> s)" (is "?lhs = ?rhs") |
3782 (\<forall>x \<in> s. \<exists>e>0. \<forall>x'. abs(x' - x) < e --> x' \<in> s)" (is "?lhs = ?rhs") |
3783 unfolding open_def apply simp unfolding forall_vec1 dist_vec1 vec1_in_image_vec1 by simp |
3783 unfolding open_def apply simp unfolding forall_vec1 dist_vec1 vec1_in_image_vec1 by simp |
3784 |
3784 |
3785 lemma islimpt_approachable_vec1: |
3785 lemma islimpt_approachable_vec1: |
3786 "(vec1 x) islimpt (vec1 ` s) \<longleftrightarrow> |
3786 "(vec1 x) islimpt (vec1 ` s) \<longleftrightarrow> |
3787 (\<forall>e>0. \<exists>x'\<in> s. x' \<noteq> x \<and> abs(x' - x) < e)" |
3787 (\<forall>e>0. \<exists>x'\<in> s. x' \<noteq> x \<and> abs(x' - x) < e)" |
3788 by (auto simp add: islimpt_approachable dist_vec1 vec1_eq) |
3788 by (auto simp add: islimpt_approachable dist_vec1 vec1_eq) |
3789 |
3789 |
3790 lemma closed_vec1: |
3790 lemma closed_vec1: |
3791 "closed (vec1 ` s) \<longleftrightarrow> |
3791 "closed (vec1 ` s) \<longleftrightarrow> |
3792 (\<forall>x. (\<forall>e>0. \<exists>x' \<in> s. x' \<noteq> x \<and> abs(x' - x) < e) |
3792 (\<forall>x. (\<forall>e>0. \<exists>x' \<in> s. x' \<noteq> x \<and> abs(x' - x) < e) |
3793 --> x \<in> s)" |
3793 --> x \<in> s)" |
3794 unfolding closed_limpt islimpt_approachable forall_vec1 apply simp |
3794 unfolding closed_limpt islimpt_approachable forall_vec1 apply simp |
3795 unfolding dist_vec1 vec1_in_image_vec1 abs_minus_commute by auto |
3795 unfolding dist_vec1 vec1_in_image_vec1 abs_minus_commute by auto |
3796 |
3796 |
3797 lemma continuous_at_vec1_range: |
3797 lemma continuous_at_vec1_range: |
3798 "continuous (at x) (vec1 o f) \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. |
3798 "continuous (at x) (vec1 o f) \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. |
3799 \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)" |
3799 \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)" |
3800 unfolding continuous_at unfolding Lim_at apply simp unfolding dist_vec1 unfolding dist_nz[THEN sym] unfolding dist_def apply auto |
3800 unfolding continuous_at unfolding Lim_at apply simp unfolding dist_vec1 unfolding dist_nz[THEN sym] unfolding dist_def apply auto |
3801 apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto |
3801 apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto |
3802 apply(erule_tac x=e in allE) by auto |
3802 apply(erule_tac x=e in allE) by auto |
3803 |
3803 |
3804 lemma continuous_on_vec1_range: |
3804 lemma continuous_on_vec1_range: |
3805 " continuous_on s (vec1 o f) \<longleftrightarrow> (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d --> abs(f x' - f x) < e))" |
3805 " continuous_on s (vec1 o f) \<longleftrightarrow> (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d --> abs(f x' - f x) < e))" |
3806 unfolding continuous_on_def apply (simp del: dist_sym) unfolding dist_vec1 unfolding dist_def .. |
3806 unfolding continuous_on_def apply (simp del: dist_sym) unfolding dist_vec1 unfolding dist_def .. |
3807 |
3807 |
3808 lemma continuous_at_vec1_norm: |
3808 lemma continuous_at_vec1_norm: |
3809 "\<forall>x. continuous (at x) (vec1 o norm)" |
3809 "\<forall>x. continuous (at x) (vec1 o norm)" |
3810 unfolding continuous_at_vec1_range using real_abs_sub_norm order_le_less_trans by blast |
3810 unfolding continuous_at_vec1_range using real_abs_sub_norm order_le_less_trans by blast |
3811 |
3811 |
3812 lemma continuous_on_vec1_norm: |
3812 lemma continuous_on_vec1_norm: |
3813 "\<forall>s. continuous_on s (vec1 o norm)" |
3813 "\<forall>s. continuous_on s (vec1 o norm)" |
3814 unfolding continuous_on_vec1_range norm_vec1[THEN sym] by (metis norm_vec1 order_le_less_trans real_abs_sub_norm) |
3814 unfolding continuous_on_vec1_range norm_vec1[THEN sym] by (metis norm_vec1 order_le_less_trans real_abs_sub_norm) |
3815 |
3815 |
3816 lemma continuous_at_vec1_component: |
3816 lemma continuous_at_vec1_component: |
3817 assumes "1 \<le> i" "i \<le> dimindex(UNIV::('a set))" |
3817 assumes "1 \<le> i" "i \<le> dimindex(UNIV::('a set))" |
3818 shows "continuous (at (a::real^'a)) (\<lambda> x. vec1(x$i))" |
3818 shows "continuous (at (a::real^'a)) (\<lambda> x. vec1(x$i))" |
3819 proof- |
3819 proof- |
3820 { fix e::real and x assume "0 < dist x a" "dist x a < e" "e>0" |
3820 { fix e::real and x assume "0 < dist x a" "dist x a < e" "e>0" |
3821 hence "\<bar>x $ i - a $ i\<bar> < e" using component_le_norm[of i "x - a"] vector_minus_component[of i x a] assms unfolding dist_def by auto } |
3821 hence "\<bar>x $ i - a $ i\<bar> < e" using component_le_norm[of i "x - a"] vector_minus_component[of i x a] assms unfolding dist_def by auto } |
3822 thus ?thesis unfolding continuous_at tendsto_def eventually_at dist_vec1 by auto |
3822 thus ?thesis unfolding continuous_at tendsto_def eventually_at dist_vec1 by auto |
3823 qed |
3823 qed |
3824 |
3824 |
3825 lemma continuous_on_vec1_component: |
3825 lemma continuous_on_vec1_component: |
3826 assumes "i \<in> {1..dimindex (UNIV::'a set)}" shows "continuous_on s (\<lambda> x::real^'a. vec1(x$i))" |
3826 assumes "i \<in> {1..dimindex (UNIV::'a set)}" shows "continuous_on s (\<lambda> x::real^'a. vec1(x$i))" |
3827 proof- |
3827 proof- |
3828 { fix e::real and x xa assume "x\<in>s" "e>0" "xa\<in>s" "0 < norm (xa - x) \<and> norm (xa - x) < e" |
3828 { fix e::real and x xa assume "x\<in>s" "e>0" "xa\<in>s" "0 < norm (xa - x) \<and> norm (xa - x) < e" |
3829 hence "\<bar>xa $ i - x $ i\<bar> < e" using component_le_norm[of i "xa - x"] vector_minus_component[of i xa x] assms by auto } |
3829 hence "\<bar>xa $ i - x $ i\<bar> < e" using component_le_norm[of i "xa - x"] vector_minus_component[of i xa x] assms by auto } |
3830 thus ?thesis unfolding continuous_on Lim_within dist_vec1 unfolding dist_def by auto |
3830 thus ?thesis unfolding continuous_on Lim_within dist_vec1 unfolding dist_def by auto |
3831 qed |
3831 qed |
3832 |
3832 |
3833 lemma continuous_at_vec1_infnorm: |
3833 lemma continuous_at_vec1_infnorm: |
3834 "continuous (at x) (vec1 o infnorm)" |
3834 "continuous (at x) (vec1 o infnorm)" |
3835 unfolding continuous_at Lim_at o_def unfolding dist_vec1 unfolding dist_def |
3835 unfolding continuous_at Lim_at o_def unfolding dist_vec1 unfolding dist_def |
3836 apply auto apply (rule_tac x=e in exI) apply auto |
3836 apply auto apply (rule_tac x=e in exI) apply auto |
3837 using order_trans[OF real_abs_sub_infnorm infnorm_le_norm, of _ x] by (metis xt1(7)) |
3837 using order_trans[OF real_abs_sub_infnorm infnorm_le_norm, of _ x] by (metis xt1(7)) |
3838 |
3838 |
3839 text{* Hence some handy theorems on distance, diameter etc. of/from a set. *} |
3839 text{* Hence some handy theorems on distance, diameter etc. of/from a set. *} |
3840 |
3840 |
3841 lemma compact_attains_sup: |
3841 lemma compact_attains_sup: |
3842 assumes "compact (vec1 ` s)" "s \<noteq> {}" |
3842 assumes "compact (vec1 ` s)" "s \<noteq> {}" |
3843 shows "\<exists>x \<in> s. \<forall>y \<in> s. y \<le> x" |
3843 shows "\<exists>x \<in> s. \<forall>y \<in> s. y \<le> x" |
3844 proof- |
3844 proof- |
3845 from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto |
3845 from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto |
3846 { fix e::real assume as: "\<forall>x\<in>s. x \<le> rsup s" "rsup s \<notin> s" "0 < e" "\<forall>x'\<in>s. x' = rsup s \<or> \<not> rsup s - x' < e" |
3846 { fix e::real assume as: "\<forall>x\<in>s. x \<le> rsup s" "rsup s \<notin> s" "0 < e" "\<forall>x'\<in>s. x' = rsup s \<or> \<not> rsup s - x' < e" |
3849 ultimately have False using isLub_le_isUb[of UNIV s "rsup s" "rsup s - e"] using `e>0` by auto } |
3849 ultimately have False using isLub_le_isUb[of UNIV s "rsup s" "rsup s - e"] using `e>0` by auto } |
3850 thus ?thesis using bounded_has_rsup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rsup s"]] |
3850 thus ?thesis using bounded_has_rsup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rsup s"]] |
3851 apply(rule_tac x="rsup s" in bexI) by auto |
3851 apply(rule_tac x="rsup s" in bexI) by auto |
3852 qed |
3852 qed |
3853 |
3853 |
3854 lemma compact_attains_inf: |
3854 lemma compact_attains_inf: |
3855 assumes "compact (vec1 ` s)" "s \<noteq> {}" shows "\<exists>x \<in> s. \<forall>y \<in> s. x \<le> y" |
3855 assumes "compact (vec1 ` s)" "s \<noteq> {}" shows "\<exists>x \<in> s. \<forall>y \<in> s. x \<le> y" |
3856 proof- |
3856 proof- |
3857 from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto |
3857 from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto |
3858 { fix e::real assume as: "\<forall>x\<in>s. x \<ge> rinf s" "rinf s \<notin> s" "0 < e" |
3858 { fix e::real assume as: "\<forall>x\<in>s. x \<ge> rinf s" "rinf s \<notin> s" "0 < e" |
3859 "\<forall>x'\<in>s. x' = rinf s \<or> \<not> abs (x' - rinf s) < e" |
3859 "\<forall>x'\<in>s. x' = rinf s \<or> \<not> abs (x' - rinf s) < e" |
3860 have "isGlb UNIV s (rinf s)" using rinf[OF assms(2)] unfolding setge_def using as(1) by auto |
3860 have "isGlb UNIV s (rinf s)" using rinf[OF assms(2)] unfolding setge_def using as(1) by auto |
3861 moreover |
3861 moreover |
3862 { fix x assume "x \<in> s" |
3862 { fix x assume "x \<in> s" |
3863 hence *:"abs (x - rinf s) = x - rinf s" using as(1)[THEN bspec[where x=x]] by auto |
3863 hence *:"abs (x - rinf s) = x - rinf s" using as(1)[THEN bspec[where x=x]] by auto |
3864 have "rinf s + e \<le> x" using as(4)[THEN bspec[where x=x]] using as(2) `x\<in>s` unfolding * by auto } |
3864 have "rinf s + e \<le> x" using as(4)[THEN bspec[where x=x]] using as(2) `x\<in>s` unfolding * by auto } |
3865 hence "isLb UNIV s (rinf s + e)" unfolding isLb_def and setge_def by auto |
3865 hence "isLb UNIV s (rinf s + e)" unfolding isLb_def and setge_def by auto |
3866 ultimately have False using isGlb_le_isLb[of UNIV s "rinf s" "rinf s + e"] using `e>0` by auto } |
3866 ultimately have False using isGlb_le_isLb[of UNIV s "rinf s" "rinf s + e"] using `e>0` by auto } |
3867 thus ?thesis using bounded_has_rinf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rinf s"]] |
3867 thus ?thesis using bounded_has_rinf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rinf s"]] |
3868 apply(rule_tac x="rinf s" in bexI) by auto |
3868 apply(rule_tac x="rinf s" in bexI) by auto |
3869 qed |
3869 qed |
3870 |
3870 |
3871 lemma continuous_attains_sup: |
3871 lemma continuous_attains_sup: |
3872 "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s (vec1 o f) |
3872 "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s (vec1 o f) |
3873 ==> (\<exists>x \<in> s. \<forall>y \<in> s. f y \<le> f x)" |
3873 ==> (\<exists>x \<in> s. \<forall>y \<in> s. f y \<le> f x)" |
3874 using compact_attains_sup[of "f ` s"] |
3874 using compact_attains_sup[of "f ` s"] |
3875 using compact_continuous_image[of s "vec1 \<circ> f"] unfolding image_compose by auto |
3875 using compact_continuous_image[of s "vec1 \<circ> f"] unfolding image_compose by auto |
3876 |
3876 |
3877 lemma continuous_attains_inf: |
3877 lemma continuous_attains_inf: |
3878 "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s (vec1 o f) |
3878 "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s (vec1 o f) |
3879 ==> (\<exists>x \<in> s. \<forall>y \<in> s. f x \<le> f y)" |
3879 ==> (\<exists>x \<in> s. \<forall>y \<in> s. f x \<le> f y)" |
3880 using compact_attains_inf[of "f ` s"] |
3880 using compact_attains_inf[of "f ` s"] |
3881 using compact_continuous_image[of s "vec1 \<circ> f"] unfolding image_compose by auto |
3881 using compact_continuous_image[of s "vec1 \<circ> f"] unfolding image_compose by auto |
3882 |
3882 |
3883 lemma distance_attains_sup: |
3883 lemma distance_attains_sup: |
3884 assumes "compact s" "s \<noteq> {}" |
3884 assumes "compact s" "s \<noteq> {}" |
3885 shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a y \<le> dist a x" |
3885 shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a y \<le> dist a x" |
3886 proof- |
3886 proof- |
3887 { fix x assume "x\<in>s" fix e::real assume "e>0" |
3887 { fix x assume "x\<in>s" fix e::real assume "e>0" |
3888 { fix x' assume "x'\<in>s" and as:"norm (x' - x) < e" |
3888 { fix x' assume "x'\<in>s" and as:"norm (x' - x) < e" |
3909 fix e::real assume "e>0" |
3909 fix e::real assume "e>0" |
3910 { fix x' assume "x'\<in>?B" and as:"norm (x' - x) < e" |
3910 { fix x' assume "x'\<in>?B" and as:"norm (x' - x) < e" |
3911 hence "\<bar>norm (x' - a) - norm (x - a)\<bar> < e" |
3911 hence "\<bar>norm (x' - a) - norm (x - a)\<bar> < e" |
3912 using real_abs_sub_norm[of "x' - a" "x - a"] by auto } |
3912 using real_abs_sub_norm[of "x' - a" "x - a"] by auto } |
3913 hence "\<exists>d>0. \<forall>x'\<in>?B. norm (x' - x) < d \<longrightarrow> \<bar>dist x' a - dist x a\<bar> < e" using `e>0` unfolding dist_def by auto } |
3913 hence "\<exists>d>0. \<forall>x'\<in>?B. norm (x' - x) < d \<longrightarrow> \<bar>dist x' a - dist x a\<bar> < e" using `e>0` unfolding dist_def by auto } |
3914 hence "continuous_on (cball a (dist b a) \<inter> s) (vec1 \<circ> dist a)" unfolding continuous_on_vec1_range |
3914 hence "continuous_on (cball a (dist b a) \<inter> s) (vec1 \<circ> dist a)" unfolding continuous_on_vec1_range |
3915 by (auto simp add: dist_sym) |
3915 by (auto simp add: dist_sym) |
3916 moreover have "compact ?B" using compact_cball[of a "dist b a"] unfolding compact_eq_bounded_closed using bounded_Int and closed_Int and assms(1) by auto |
3916 moreover have "compact ?B" using compact_cball[of a "dist b a"] unfolding compact_eq_bounded_closed using bounded_Int and closed_Int and assms(1) by auto |
3917 ultimately obtain x where "x\<in>cball a (dist b a) \<inter> s" "\<forall>y\<in>cball a (dist b a) \<inter> s. dist a x \<le> dist a y" using continuous_attains_inf[of ?B "dist a"] by fastsimp |
3917 ultimately obtain x where "x\<in>cball a (dist b a) \<inter> s" "\<forall>y\<in>cball a (dist b a) \<inter> s. dist a x \<le> dist a y" using continuous_attains_inf[of ?B "dist a"] by fastsimp |
3918 thus ?thesis by fastsimp |
3918 thus ?thesis by fastsimp |
3919 qed |
3919 qed |
3920 |
3920 |
3921 subsection{* We can now extend limit compositions to consider the scalar multiplier. *} |
3921 subsection{* We can now extend limit compositions to consider the scalar multiplier. *} |
3922 |
3922 |
3923 lemma Lim_mul: |
3923 lemma Lim_mul: |
3924 assumes "((vec1 o c) ---> vec1 d) net" "(f ---> l) net" |
3924 assumes "((vec1 o c) ---> vec1 d) net" "(f ---> l) net" |
3925 shows "((\<lambda>x. c(x) *s f x) ---> (d *s l)) net" |
3925 shows "((\<lambda>x. c(x) *s f x) ---> (d *s l)) net" |
3926 proof- |
3926 proof- |
3927 have "bilinear (\<lambda>x. op *s (dest_vec1 (x::real^1)))" unfolding bilinear_def linear_def |
3927 have "bilinear (\<lambda>x. op *s (dest_vec1 (x::real^1)))" unfolding bilinear_def linear_def |
3928 unfolding dest_vec1_add dest_vec1_cmul |
3928 unfolding dest_vec1_add dest_vec1_cmul |
3929 apply vector apply auto unfolding semiring_class.right_distrib semiring_class.left_distrib by auto |
3929 apply vector apply auto unfolding semiring_class.right_distrib semiring_class.left_distrib by auto |
3930 thus ?thesis using Lim_bilinear[OF assms, of "\<lambda>x y. (dest_vec1 x) *s y"] by auto |
3930 thus ?thesis using Lim_bilinear[OF assms, of "\<lambda>x y. (dest_vec1 x) *s y"] by auto |
3931 qed |
3931 qed |
3932 |
3932 |
3933 lemma Lim_vmul: |
3933 lemma Lim_vmul: |
3934 "((vec1 o c) ---> vec1 d) net ==> ((\<lambda>x. c(x) *s v) ---> d *s v) net" |
3934 "((vec1 o c) ---> vec1 d) net ==> ((\<lambda>x. c(x) *s v) ---> d *s v) net" |
3935 using Lim_mul[of c d net "\<lambda>x. v" v] using Lim_const[of v] by auto |
3935 using Lim_mul[of c d net "\<lambda>x. v" v] using Lim_const[of v] by auto |
3936 |
3936 |
3937 lemma continuous_vmul: |
3937 lemma continuous_vmul: |
3938 "continuous net (vec1 o c) ==> continuous net (\<lambda>x. c(x) *s v)" |
3938 "continuous net (vec1 o c) ==> continuous net (\<lambda>x. c(x) *s v)" |
3939 unfolding continuous_def using Lim_vmul[of c] by auto |
3939 unfolding continuous_def using Lim_vmul[of c] by auto |
3940 |
3940 |
3941 lemma continuous_mul: |
3941 lemma continuous_mul: |
3942 "continuous net (vec1 o c) \<Longrightarrow> continuous net f |
3942 "continuous net (vec1 o c) \<Longrightarrow> continuous net f |
3943 ==> continuous net (\<lambda>x. c(x) *s f x) " |
3943 ==> continuous net (\<lambda>x. c(x) *s f x) " |
3944 unfolding continuous_def using Lim_mul[of c] by auto |
3944 unfolding continuous_def using Lim_mul[of c] by auto |
3945 |
3945 |
3946 lemma continuous_on_vmul: |
3946 lemma continuous_on_vmul: |
3947 "continuous_on s (vec1 o c) ==> continuous_on s (\<lambda>x. c(x) *s v)" |
3947 "continuous_on s (vec1 o c) ==> continuous_on s (\<lambda>x. c(x) *s v)" |
3948 unfolding continuous_on_eq_continuous_within using continuous_vmul[of _ c] by auto |
3948 unfolding continuous_on_eq_continuous_within using continuous_vmul[of _ c] by auto |
3949 |
3949 |
3950 lemma continuous_on_mul: |
3950 lemma continuous_on_mul: |
3951 "continuous_on s (vec1 o c) \<Longrightarrow> continuous_on s f |
3951 "continuous_on s (vec1 o c) \<Longrightarrow> continuous_on s f |
3952 ==> continuous_on s (\<lambda>x. c(x) *s f x)" |
3952 ==> continuous_on s (\<lambda>x. c(x) *s f x)" |
3953 unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto |
3953 unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto |
3954 |
3954 |
3955 text{* And so we have continuity of inverse. *} |
3955 text{* And so we have continuity of inverse. *} |
3956 |
3956 |
3957 lemma Lim_inv: |
3957 lemma Lim_inv: |
3958 assumes "((vec1 o f) ---> vec1 l) (net::'a net)" "l \<noteq> 0" |
3958 assumes "((vec1 o f) ---> vec1 l) (net::'a net)" "l \<noteq> 0" |
3959 shows "((vec1 o inverse o f) ---> vec1(inverse l)) net" |
3959 shows "((vec1 o inverse o f) ---> vec1(inverse l)) net" |
3960 proof(cases "trivial_limit net") |
3960 proof(cases "trivial_limit net") |
3961 case True thus ?thesis unfolding tendsto_def unfolding eventually_def by auto |
3961 case True thus ?thesis unfolding tendsto_def unfolding eventually_def by auto |
3962 next |
3962 next |
3972 hence fxl0: "(f x) * l \<noteq> 0" using `l \<noteq> 0` by auto |
3972 hence fxl0: "(f x) * l \<noteq> 0" using `l \<noteq> 0` by auto |
3973 from * have **:"\<bar>f x - l\<bar> < l\<twosuperior> * e / 2" by auto |
3973 from * have **:"\<bar>f x - l\<bar> < l\<twosuperior> * e / 2" by auto |
3974 have "\<bar>f x\<bar> * 2 \<ge> \<bar>l\<bar>" using * by (auto simp del: Arith_Tools.less_divide_eq_number_of1) |
3974 have "\<bar>f x\<bar> * 2 \<ge> \<bar>l\<bar>" using * by (auto simp del: Arith_Tools.less_divide_eq_number_of1) |
3975 hence "\<bar>f x\<bar> * 2 * \<bar>l\<bar> \<ge> \<bar>l\<bar> * \<bar>l\<bar>" unfolding mult_le_cancel_right by auto |
3975 hence "\<bar>f x\<bar> * 2 * \<bar>l\<bar> \<ge> \<bar>l\<bar> * \<bar>l\<bar>" unfolding mult_le_cancel_right by auto |
3976 hence "\<bar>f x * l\<bar> * 2 \<ge> \<bar>l\<bar>^2" unfolding real_mult_commute and power2_eq_square by auto |
3976 hence "\<bar>f x * l\<bar> * 2 \<ge> \<bar>l\<bar>^2" unfolding real_mult_commute and power2_eq_square by auto |
3977 hence ***:"inverse \<bar>f x * l\<bar> \<le> inverse (l\<twosuperior> / 2)" using fxl0 |
3977 hence ***:"inverse \<bar>f x * l\<bar> \<le> inverse (l\<twosuperior> / 2)" using fxl0 |
3978 using le_imp_inverse_le[of "l^2 / 2" "\<bar>f x * l\<bar>"] by auto |
3978 using le_imp_inverse_le[of "l^2 / 2" "\<bar>f x * l\<bar>"] by auto |
3979 |
3979 |
3980 have "dist ((vec1 \<circ> inverse \<circ> f) x) (vec1 (inverse l)) < e" unfolding o_def unfolding dist_vec1 |
3980 have "dist ((vec1 \<circ> inverse \<circ> f) x) (vec1 (inverse l)) < e" unfolding o_def unfolding dist_vec1 |
3981 unfolding inverse_diff_inverse[OF fx0 `l\<noteq>0`] apply simp |
3981 unfolding inverse_diff_inverse[OF fx0 `l\<noteq>0`] apply simp |
3982 unfolding mult_commute[of "inverse (f x)"] |
3982 unfolding mult_commute[of "inverse (f x)"] |
3983 unfolding real_divide_def[THEN sym] |
3983 unfolding real_divide_def[THEN sym] |
3984 unfolding divide_divide_eq_left |
3984 unfolding divide_divide_eq_left |
3985 unfolding nonzero_abs_divide[OF fxl0] |
3985 unfolding nonzero_abs_divide[OF fxl0] |
3986 using mult_less_le_imp_less[OF **, of "inverse \<bar>f x * l\<bar>", of "inverse (l^2 / 2)"] using *** using fx0 `l\<noteq>0` |
3986 using mult_less_le_imp_less[OF **, of "inverse \<bar>f x * l\<bar>", of "inverse (l^2 / 2)"] using *** using fx0 `l\<noteq>0` |
3987 unfolding inverse_eq_divide using `e>0` by auto } |
3987 unfolding inverse_eq_divide using `e>0` by auto } |
3988 hence "(\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> dist ((vec1 \<circ> inverse \<circ> f) x) (vec1 (inverse l)) < e))" |
3988 hence "(\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> dist ((vec1 \<circ> inverse \<circ> f) x) (vec1 (inverse l)) < e))" |
3989 using y1 by auto } |
3989 using y1 by auto } |
3990 thus ?thesis unfolding tendsto_def eventually_def by auto |
3990 thus ?thesis unfolding tendsto_def eventually_def by auto |
3991 qed |
3991 qed |
3992 |
3992 |
3993 lemma continuous_inv: |
3993 lemma continuous_inv: |
3994 "continuous net (vec1 o f) \<Longrightarrow> f(netlimit net) \<noteq> 0 |
3994 "continuous net (vec1 o f) \<Longrightarrow> f(netlimit net) \<noteq> 0 |
3995 ==> continuous net (vec1 o inverse o f)" |
3995 ==> continuous net (vec1 o inverse o f)" |
3996 unfolding continuous_def using Lim_inv by auto |
3996 unfolding continuous_def using Lim_inv by auto |
3997 |
3997 |
3998 lemma continuous_at_within_inv: |
3998 lemma continuous_at_within_inv: |
3999 assumes "continuous (at a within s) (vec1 o f)" "f a \<noteq> 0" |
3999 assumes "continuous (at a within s) (vec1 o f)" "f a \<noteq> 0" |
4000 shows "continuous (at a within s) (vec1 o inverse o f)" |
4000 shows "continuous (at a within s) (vec1 o inverse o f)" |
4001 proof(cases "trivial_limit (at a within s)") |
4001 proof(cases "trivial_limit (at a within s)") |
4002 case True thus ?thesis unfolding continuous_def tendsto_def eventually_def by auto |
4002 case True thus ?thesis unfolding continuous_def tendsto_def eventually_def by auto |
4003 next |
4003 next |
4004 case False note cs = this |
4004 case False note cs = this |
4005 thus ?thesis using netlimit_within[OF cs] assms(2) continuous_inv[OF assms(1)] by auto |
4005 thus ?thesis using netlimit_within[OF cs] assms(2) continuous_inv[OF assms(1)] by auto |
4006 qed |
4006 qed |
4007 |
4007 |
4008 lemma continuous_at_inv: |
4008 lemma continuous_at_inv: |
4009 "continuous (at a) (vec1 o f) \<Longrightarrow> f a \<noteq> 0 |
4009 "continuous (at a) (vec1 o f) \<Longrightarrow> f a \<noteq> 0 |
4010 ==> continuous (at a) (vec1 o inverse o f) " |
4010 ==> continuous (at a) (vec1 o inverse o f) " |
4011 using within_UNIV[THEN sym, of a] using continuous_at_within_inv[of a UNIV] by auto |
4011 using within_UNIV[THEN sym, of a] using continuous_at_within_inv[of a UNIV] by auto |
4012 |
4012 |
4013 subsection{* Preservation properties for pasted sets. *} |
4013 subsection{* Preservation properties for pasted sets. *} |
4034 then obtain N::nat where N:"\<forall>n\<ge>N. dist (x n) l < e" using as(2)[unfolded Lim_sequentially, THEN spec[where x=e]] by auto |
4034 then obtain N::nat where N:"\<forall>n\<ge>N. dist (x n) l < e" using as(2)[unfolded Lim_sequentially, THEN spec[where x=e]] by auto |
4035 { fix n::nat assume "n\<ge>N" |
4035 { fix n::nat assume "n\<ge>N" |
4036 hence "dist (fstcart (x n)) (fstcart l) < e" "dist (sndcart (x n)) (sndcart l) < e" |
4036 hence "dist (fstcart (x n)) (fstcart l) < e" "dist (sndcart (x n)) (sndcart l) < e" |
4037 using N[THEN spec[where x=n]] dist_fstcart[of "x n" l] dist_sndcart[of "x n" l] by auto } |
4037 using N[THEN spec[where x=n]] dist_fstcart[of "x n" l] dist_sndcart[of "x n" l] by auto } |
4038 hence "\<exists>N. \<forall>n\<ge>N. dist (fstcart (x n)) (fstcart l) < e" "\<exists>N. \<forall>n\<ge>N. dist (sndcart (x n)) (sndcart l) < e" by auto } |
4038 hence "\<exists>N. \<forall>n\<ge>N. dist (fstcart (x n)) (fstcart l) < e" "\<exists>N. \<forall>n\<ge>N. dist (sndcart (x n)) (sndcart l) < e" by auto } |
4039 ultimately have "fstcart l \<in> s" "sndcart l \<in> t" |
4039 ultimately have "fstcart l \<in> s" "sndcart l \<in> t" |
4040 using assms(1)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. fstcart (x n)"], THEN spec[where x="fstcart l"]] |
4040 using assms(1)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. fstcart (x n)"], THEN spec[where x="fstcart l"]] |
4041 using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. sndcart (x n)"], THEN spec[where x="sndcart l"]] |
4041 using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. sndcart (x n)"], THEN spec[where x="sndcart l"]] |
4042 unfolding Lim_sequentially by auto |
4042 unfolding Lim_sequentially by auto |
4043 hence "l \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}" using pastecart_fst_snd[THEN sym, of l] by auto } |
4043 hence "l \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}" using pastecart_fst_snd[THEN sym, of l] by auto } |
4044 thus ?thesis unfolding closed_sequential_limits by auto |
4044 thus ?thesis unfolding closed_sequential_limits by auto |
4045 qed |
4045 qed |
4046 |
4046 |
4047 lemma compact_pastecart: |
4047 lemma compact_pastecart: |
4048 "compact s \<Longrightarrow> compact t ==> compact {pastecart x y | x y . x \<in> s \<and> y \<in> t}" |
4048 "compact s \<Longrightarrow> compact t ==> compact {pastecart x y | x y . x \<in> s \<and> y \<in> t}" |
4049 unfolding compact_eq_bounded_closed using bounded_pastecart[of s t] closed_pastecart[of s t] by auto |
4049 unfolding compact_eq_bounded_closed using bounded_pastecart[of s t] closed_pastecart[of s t] by auto |
4050 |
4050 |
4051 text{* Hence some useful properties follow quite easily. *} |
4051 text{* Hence some useful properties follow quite easily. *} |
4052 |
4052 |
4053 lemma compact_scaling: |
4053 lemma compact_scaling: |
4054 assumes "compact s" shows "compact ((\<lambda>x. c *s x) ` s)" |
4054 assumes "compact s" shows "compact ((\<lambda>x. c *s x) ` s)" |
4055 proof- |
4055 proof- |
4056 let ?f = "\<lambda>x. c *s x" |
4056 let ?f = "\<lambda>x. c *s x" |
4057 have *:"linear ?f" unfolding linear_def vector_smult_assoc vector_add_ldistrib real_mult_commute by auto |
4057 have *:"linear ?f" unfolding linear_def vector_smult_assoc vector_add_ldistrib real_mult_commute by auto |
4058 show ?thesis using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f] |
4058 show ?thesis using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f] |
4059 using linear_continuous_at[OF *] assms by auto |
4059 using linear_continuous_at[OF *] assms by auto |
4060 qed |
4060 qed |
4061 |
4061 |
4062 lemma compact_negations: |
4062 lemma compact_negations: |
4063 assumes "compact s" shows "compact ((\<lambda>x. -x) ` s)" |
4063 assumes "compact s" shows "compact ((\<lambda>x. -x) ` s)" |
4064 proof- |
4064 proof- |
4065 have "uminus ` s = (\<lambda>x. -1 *s x) ` s" apply auto unfolding image_iff pth_3 by auto |
4065 have "uminus ` s = (\<lambda>x. -1 *s x) ` s" apply auto unfolding image_iff pth_3 by auto |
4066 thus ?thesis using compact_scaling[OF assms, of "-1"] by auto |
4066 thus ?thesis using compact_scaling[OF assms, of "-1"] by auto |
4067 qed |
4067 qed |
4068 |
4068 |
4069 lemma compact_sums: |
4069 lemma compact_sums: |
4070 assumes "compact s" "compact t" shows "compact {x + y | x y. x \<in> s \<and> y \<in> t}" |
4070 assumes "compact s" "compact t" shows "compact {x + y | x y. x \<in> s \<and> y \<in> t}" |
4071 proof- |
4071 proof- |
4072 have *:"{x + y | x y. x \<in> s \<and> y \<in> t} =(\<lambda>z. fstcart z + sndcart z) ` {pastecart x y | x y. x \<in> s \<and> y \<in> t}" |
4072 have *:"{x + y | x y. x \<in> s \<and> y \<in> t} =(\<lambda>z. fstcart z + sndcart z) ` {pastecart x y | x y. x \<in> s \<and> y \<in> t}" |
4073 apply auto unfolding image_iff apply(rule_tac x="pastecart xa y" in bexI) unfolding fstcart_pastecart sndcart_pastecart by auto |
4073 apply auto unfolding image_iff apply(rule_tac x="pastecart xa y" in bexI) unfolding fstcart_pastecart sndcart_pastecart by auto |
4074 have "linear (\<lambda>z::real^('a, 'a) finite_sum. fstcart z + sndcart z)" unfolding linear_def |
4074 have "linear (\<lambda>z::real^('a, 'a) finite_sum. fstcart z + sndcart z)" unfolding linear_def |
4075 unfolding fstcart_add sndcart_add apply auto |
4075 unfolding fstcart_add sndcart_add apply auto |
4076 unfolding vector_add_ldistrib fstcart_cmul[THEN sym] sndcart_cmul[THEN sym] by auto |
4076 unfolding vector_add_ldistrib fstcart_cmul[THEN sym] sndcart_cmul[THEN sym] by auto |
4077 hence "continuous_on {pastecart x y |x y. x \<in> s \<and> y \<in> t} (\<lambda>z. fstcart z + sndcart z)" |
4077 hence "continuous_on {pastecart x y |x y. x \<in> s \<and> y \<in> t} (\<lambda>z. fstcart z + sndcart z)" |
4078 using continuous_at_imp_continuous_on linear_continuous_at by auto |
4078 using continuous_at_imp_continuous_on linear_continuous_at by auto |
4079 thus ?thesis unfolding * using compact_continuous_image compact_pastecart[OF assms] by auto |
4079 thus ?thesis unfolding * using compact_continuous_image compact_pastecart[OF assms] by auto |
4080 qed |
4080 qed |
4081 |
4081 |
4082 lemma compact_differences: |
4082 lemma compact_differences: |
4083 assumes "compact s" "compact t" shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}" |
4083 assumes "compact s" "compact t" shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}" |
4084 proof- |
4084 proof- |
4085 have "{x - y | x y::real^'a. x\<in>s \<and> y \<in> t} = {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}" |
4085 have "{x - y | x y::real^'a. x\<in>s \<and> y \<in> t} = {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}" |
4086 apply auto apply(rule_tac x= xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4086 apply auto apply(rule_tac x= xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4087 thus ?thesis using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto |
4087 thus ?thesis using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto |
4088 qed |
4088 qed |
4089 |
4089 |
4090 lemma compact_translation: |
4090 lemma compact_translation: |
4091 assumes "compact s" shows "compact ((\<lambda>x. a + x) ` s)" |
4091 assumes "compact s" shows "compact ((\<lambda>x. a + x) ` s)" |
4092 proof- |
4092 proof- |
4093 have "{x + y |x y. x \<in> s \<and> y \<in> {a}} = (\<lambda>x. a + x) ` s" by auto |
4093 have "{x + y |x y. x \<in> s \<and> y \<in> {a}} = (\<lambda>x. a + x) ` s" by auto |
4094 thus ?thesis using compact_sums[OF assms compact_sing[of a]] by auto |
4094 thus ?thesis using compact_sums[OF assms compact_sing[of a]] by auto |
4095 qed |
4095 qed |
4096 |
4096 |
4097 lemma compact_affinity: |
4097 lemma compact_affinity: |
4098 assumes "compact s" shows "compact ((\<lambda>x. a + c *s x) ` s)" |
4098 assumes "compact s" shows "compact ((\<lambda>x. a + c *s x) ` s)" |
4099 proof- |
4099 proof- |
4100 have "op + a ` op *s c ` s = (\<lambda>x. a + c *s x) ` s" by auto |
4100 have "op + a ` op *s c ` s = (\<lambda>x. a + c *s x) ` s" by auto |
4101 thus ?thesis using compact_translation[OF compact_scaling[OF assms], of a c] by auto |
4101 thus ?thesis using compact_translation[OF compact_scaling[OF assms], of a c] by auto |
4102 qed |
4102 qed |
4103 |
4103 |
4104 text{* Hence we get the following. *} |
4104 text{* Hence we get the following. *} |
4105 |
4105 |
4106 lemma compact_sup_maxdistance: |
4106 lemma compact_sup_maxdistance: |
4107 assumes "compact s" "s \<noteq> {}" |
4107 assumes "compact s" "s \<noteq> {}" |
4108 shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)" |
4108 shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)" |
4109 proof- |
4109 proof- |
4110 have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto |
4110 have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto |
4111 then obtain x where x:"x\<in>{x - y |x y. x \<in> s \<and> y \<in> s}" "\<forall>y\<in>{x - y |x y. x \<in> s \<and> y \<in> s}. norm y \<le> norm x" |
4111 then obtain x where x:"x\<in>{x - y |x y. x \<in> s \<and> y \<in> s}" "\<forall>y\<in>{x - y |x y. x \<in> s \<and> y \<in> s}. norm y \<le> norm x" |
4112 using compact_differences[OF assms(1) assms(1)] |
4112 using compact_differences[OF assms(1) assms(1)] |
4113 using distance_attains_sup[unfolded dist_def, of "{x - y | x y . x\<in>s \<and> y\<in>s}" 0] by(auto simp add: norm_minus_cancel) |
4113 using distance_attains_sup[unfolded dist_def, of "{x - y | x y . x\<in>s \<and> y\<in>s}" 0] by(auto simp add: norm_minus_cancel) |
4114 from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto |
4114 from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto |
4115 thus ?thesis using x(2)[unfolded `x = a - b`] by blast |
4115 thus ?thesis using x(2)[unfolded `x = a - b`] by blast |
4116 qed |
4116 qed |
4117 |
4117 |
4118 text{* We can state this in terms of diameter of a set. *} |
4118 text{* We can state this in terms of diameter of a set. *} |
4119 |
4119 |
4120 definition "diameter s = (if s = {} then 0::real else rsup {norm(x - y) | x y. x \<in> s \<and> y \<in> s})" |
4120 definition "diameter s = (if s = {} then 0::real else rsup {norm(x - y) | x y. x \<in> s \<and> y \<in> s})" |
4121 |
4121 |
4122 lemma diameter_bounded: |
4122 lemma diameter_bounded: |
4123 assumes "bounded s" |
4123 assumes "bounded s" |
4124 shows "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" |
4124 shows "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" |
4125 "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" |
4125 "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" |
4126 proof- |
4126 proof- |
4127 let ?D = "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}" |
4127 let ?D = "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}" |
4128 obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_def] by auto |
4128 obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_def] by auto |
4129 { fix x y assume "x \<in> s" "y \<in> s" |
4129 { fix x y assume "x \<in> s" "y \<in> s" |
4130 hence "norm (x - y) \<le> 2 * a" using norm_triangle_ineq[of x "-y", unfolded norm_minus_cancel] a[THEN bspec[where x=x]] a[THEN bspec[where x=y]] by (auto simp add: ring_simps) } |
4130 hence "norm (x - y) \<le> 2 * a" using norm_triangle_ineq[of x "-y", unfolded norm_minus_cancel] a[THEN bspec[where x=x]] a[THEN bspec[where x=y]] by (auto simp add: ring_simps) } |
4131 note * = this |
4131 note * = this |
4132 { fix x y assume "x\<in>s" "y\<in>s" hence "s \<noteq> {}" by auto |
4132 { fix x y assume "x\<in>s" "y\<in>s" hence "s \<noteq> {}" by auto |
4133 have lub:"isLub UNIV ?D (rsup ?D)" using * rsup[of ?D] using `s\<noteq>{}` unfolding setle_def by auto |
4133 have lub:"isLub UNIV ?D (rsup ?D)" using * rsup[of ?D] using `s\<noteq>{}` unfolding setle_def by auto |
4134 have "norm(x - y) \<le> diameter s" unfolding diameter_def using `s\<noteq>{}` *[OF `x\<in>s` `y\<in>s`] `x\<in>s` `y\<in>s` isLubD1[OF lub] unfolding setle_def by auto } |
4134 have "norm(x - y) \<le> diameter s" unfolding diameter_def using `s\<noteq>{}` *[OF `x\<in>s` `y\<in>s`] `x\<in>s` `y\<in>s` isLubD1[OF lub] unfolding setle_def by auto } |
4135 moreover |
4135 moreover |
4136 { fix d::real assume "d>0" "d < diameter s" |
4136 { fix d::real assume "d>0" "d < diameter s" |
4137 hence "s\<noteq>{}" unfolding diameter_def by auto |
4137 hence "s\<noteq>{}" unfolding diameter_def by auto |
4138 hence lub:"isLub UNIV ?D (rsup ?D)" using * rsup[of ?D] unfolding setle_def by auto |
4138 hence lub:"isLub UNIV ?D (rsup ?D)" using * rsup[of ?D] unfolding setle_def by auto |
4139 have "\<exists>d' \<in> ?D. d' > d" |
4139 have "\<exists>d' \<in> ?D. d' > d" |
4140 proof(rule ccontr) |
4140 proof(rule ccontr) |
4141 assume "\<not> (\<exists>d'\<in>{norm (x - y) |x y. x \<in> s \<and> y \<in> s}. d < d')" |
4141 assume "\<not> (\<exists>d'\<in>{norm (x - y) |x y. x \<in> s \<and> y \<in> s}. d < d')" |
4142 hence as:"\<forall>d'\<in>?D. d' \<le> d" apply auto apply(erule_tac x="norm (x - y)" in allE) by auto |
4142 hence as:"\<forall>d'\<in>?D. d' \<le> d" apply auto apply(erule_tac x="norm (x - y)" in allE) by auto |
4146 hence "\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d" by auto } |
4146 hence "\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d" by auto } |
4147 ultimately show "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" |
4147 ultimately show "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" |
4148 "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" by auto |
4148 "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" by auto |
4149 qed |
4149 qed |
4150 |
4150 |
4151 lemma diameter_bounded_bound: |
4151 lemma diameter_bounded_bound: |
4152 "bounded s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s ==> norm(x - y) \<le> diameter s" |
4152 "bounded s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s ==> norm(x - y) \<le> diameter s" |
4153 using diameter_bounded by blast |
4153 using diameter_bounded by blast |
4154 |
4154 |
4155 lemma diameter_compact_attained: |
4155 lemma diameter_compact_attained: |
4156 assumes "compact s" "s \<noteq> {}" |
4156 assumes "compact s" "s \<noteq> {}" |
4157 shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)" |
4157 shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)" |
4158 proof- |
4158 proof- |
4159 have b:"bounded s" using assms(1) compact_eq_bounded_closed by auto |
4159 have b:"bounded s" using assms(1) compact_eq_bounded_closed by auto |
4160 then obtain x y where xys:"x\<in>s" "y\<in>s" and xy:"\<forall>u\<in>s. \<forall>v\<in>s. norm (u - v) \<le> norm (x - y)" using compact_sup_maxdistance[OF assms] by auto |
4160 then obtain x y where xys:"x\<in>s" "y\<in>s" and xy:"\<forall>u\<in>s. \<forall>v\<in>s. norm (u - v) \<le> norm (x - y)" using compact_sup_maxdistance[OF assms] by auto |
4161 hence "diameter s \<le> norm (x - y)" using rsup_le[of "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}" "norm (x - y)"] |
4161 hence "diameter s \<le> norm (x - y)" using rsup_le[of "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}" "norm (x - y)"] |
4162 unfolding setle_def and diameter_def by auto |
4162 unfolding setle_def and diameter_def by auto |
4163 thus ?thesis using diameter_bounded(1)[OF b, THEN bspec[where x=x], THEN bspec[where x=y], OF xys] and xys by auto |
4163 thus ?thesis using diameter_bounded(1)[OF b, THEN bspec[where x=x], THEN bspec[where x=y], OF xys] and xys by auto |
4164 qed |
4164 qed |
4165 |
4165 |
4166 text{* Related results with closure as the conclusion. *} |
4166 text{* Related results with closure as the conclusion. *} |
4167 |
4167 |
4168 lemma closed_scaling: |
4168 lemma closed_scaling: |
4169 assumes "closed s" shows "closed ((\<lambda>x. c *s x) ` s)" |
4169 assumes "closed s" shows "closed ((\<lambda>x. c *s x) ` s)" |
4170 proof(cases "s={}") |
4170 proof(cases "s={}") |
4171 case True thus ?thesis by auto |
4171 case True thus ?thesis by auto |
4172 next |
4172 next |
4173 case False |
4173 case False |
4174 show ?thesis |
4174 show ?thesis |
4175 proof(cases "c=0") |
4175 proof(cases "c=0") |
4176 have *:"(\<lambda>x. 0) ` s = {0}" using `s\<noteq>{}` by auto |
4176 have *:"(\<lambda>x. 0) ` s = {0}" using `s\<noteq>{}` by auto |
4177 case True thus ?thesis apply auto unfolding * using closed_sing by auto |
4177 case True thus ?thesis apply auto unfolding * using closed_sing by auto |
4178 next |
4178 next |
4179 case False |
4179 case False |
4180 { fix x l assume as:"\<forall>n::nat. x n \<in> op *s c ` s" "(x ---> l) sequentially" |
4180 { fix x l assume as:"\<forall>n::nat. x n \<in> op *s c ` s" "(x ---> l) sequentially" |
4181 { fix n::nat have "(1 / c) *s x n \<in> s" using as(1)[THEN spec[where x=n]] using `c\<noteq>0` by (auto simp add: vector_smult_assoc) } |
4181 { fix n::nat have "(1 / c) *s x n \<in> s" using as(1)[THEN spec[where x=n]] using `c\<noteq>0` by (auto simp add: vector_smult_assoc) } |
4182 moreover |
4182 moreover |
4183 { fix e::real assume "e>0" |
4183 { fix e::real assume "e>0" |
4184 hence "0 < e *\<bar>c\<bar>" using `c\<noteq>0` mult_pos_pos[of e "abs c"] by auto |
4184 hence "0 < e *\<bar>c\<bar>" using `c\<noteq>0` mult_pos_pos[of e "abs c"] by auto |
4185 then obtain N where "\<forall>n\<ge>N. dist (x n) l < e * \<bar>c\<bar>" using as(2)[unfolded Lim_sequentially, THEN spec[where x="e * abs c"]] by auto |
4185 then obtain N where "\<forall>n\<ge>N. dist (x n) l < e * \<bar>c\<bar>" using as(2)[unfolded Lim_sequentially, THEN spec[where x="e * abs c"]] by auto |
4186 hence "\<exists>N. \<forall>n\<ge>N. dist ((1 / c) *s x n) ((1 / c) *s l) < e" unfolding dist_def unfolding vector_ssub_ldistrib[THEN sym] norm_mul |
4186 hence "\<exists>N. \<forall>n\<ge>N. dist ((1 / c) *s x n) ((1 / c) *s l) < e" unfolding dist_def unfolding vector_ssub_ldistrib[THEN sym] norm_mul |
4187 using mult_imp_div_pos_less[of "abs c" _ e] `c\<noteq>0` by auto } |
4187 using mult_imp_div_pos_less[of "abs c" _ e] `c\<noteq>0` by auto } |
4188 hence "((\<lambda>n. (1 / c) *s x n) ---> (1 / c) *s l) sequentially" unfolding Lim_sequentially by auto |
4188 hence "((\<lambda>n. (1 / c) *s x n) ---> (1 / c) *s l) sequentially" unfolding Lim_sequentially by auto |
4189 ultimately have "l \<in> op *s c ` s" using assms[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. (1/c) *s x n"], THEN spec[where x="(1/c) *s l"]] |
4189 ultimately have "l \<in> op *s c ` s" using assms[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. (1/c) *s x n"], THEN spec[where x="(1/c) *s l"]] |
4190 unfolding image_iff using `c\<noteq>0` apply(rule_tac x="(1 / c) *s l" in bexI) apply auto unfolding vector_smult_assoc by auto } |
4190 unfolding image_iff using `c\<noteq>0` apply(rule_tac x="(1 / c) *s l" in bexI) apply auto unfolding vector_smult_assoc by auto } |
4191 thus ?thesis unfolding closed_sequential_limits by auto |
4191 thus ?thesis unfolding closed_sequential_limits by auto |
4192 qed |
4192 qed |
4193 qed |
4193 qed |
4194 |
4194 |
4195 lemma closed_negations: |
4195 lemma closed_negations: |
4196 assumes "closed s" shows "closed ((\<lambda>x. -x) ` s)" |
4196 assumes "closed s" shows "closed ((\<lambda>x. -x) ` s)" |
4197 using closed_scaling[OF assms, of "-1"] unfolding pth_3 by auto |
4197 using closed_scaling[OF assms, of "-1"] unfolding pth_3 by auto |
4198 |
4198 |
4199 lemma compact_closed_sums: |
4199 lemma compact_closed_sums: |
4200 assumes "compact s" "closed t" shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}" |
4200 assumes "compact s" "closed t" shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}" |
4201 proof- |
4201 proof- |
4202 let ?S = "{x + y |x y. x \<in> s \<and> y \<in> t}" |
4202 let ?S = "{x + y |x y. x \<in> s \<and> y \<in> t}" |
4203 { fix x l assume as:"\<forall>n. x n \<in> ?S" "(x ---> l) sequentially" |
4203 { fix x l assume as:"\<forall>n. x n \<in> ?S" "(x ---> l) sequentially" |
4204 from as(1) obtain f where f:"\<forall>n. x n = fst (f n) + snd (f n)" "\<forall>n. fst (f n) \<in> s" "\<forall>n. snd (f n) \<in> t" |
4204 from as(1) obtain f where f:"\<forall>n. x n = fst (f n) + snd (f n)" "\<forall>n. fst (f n) \<in> s" "\<forall>n. snd (f n) \<in> t" |
4206 obtain l' r where "l'\<in>s" and r:"\<forall>m n. m < n \<longrightarrow> r m < r n" and lr:"(((\<lambda>n. fst (f n)) \<circ> r) ---> l') sequentially" |
4206 obtain l' r where "l'\<in>s" and r:"\<forall>m n. m < n \<longrightarrow> r m < r n" and lr:"(((\<lambda>n. fst (f n)) \<circ> r) ---> l') sequentially" |
4207 using assms(1)[unfolded compact_def, THEN spec[where x="\<lambda> n. fst (f n)"]] using f(2) by auto |
4207 using assms(1)[unfolded compact_def, THEN spec[where x="\<lambda> n. fst (f n)"]] using f(2) by auto |
4208 have "((\<lambda>n. snd (f (r n))) ---> l - l') sequentially" |
4208 have "((\<lambda>n. snd (f (r n))) ---> l - l') sequentially" |
4209 using Lim_sub[OF lim_subsequence[OF r as(2)] lr] and f(1) unfolding o_def by auto |
4209 using Lim_sub[OF lim_subsequence[OF r as(2)] lr] and f(1) unfolding o_def by auto |
4210 hence "l - l' \<in> t" |
4210 hence "l - l' \<in> t" |
4211 using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda> n. snd (f (r n))"], THEN spec[where x="l - l'"]] |
4211 using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda> n. snd (f (r n))"], THEN spec[where x="l - l'"]] |
4212 using f(3) by auto |
4212 using f(3) by auto |
4213 hence "l \<in> ?S" using `l' \<in> s` apply auto apply(rule_tac x=l' in exI) apply(rule_tac x="l - l'" in exI) by auto |
4213 hence "l \<in> ?S" using `l' \<in> s` apply auto apply(rule_tac x=l' in exI) apply(rule_tac x="l - l'" in exI) by auto |
4214 } |
4214 } |
4215 thus ?thesis unfolding closed_sequential_limits by auto |
4215 thus ?thesis unfolding closed_sequential_limits by auto |
4216 qed |
4216 qed |
4217 |
4217 |
4218 lemma closed_compact_sums: |
4218 lemma closed_compact_sums: |
4219 assumes "closed s" "compact t" |
4219 assumes "closed s" "compact t" |
4220 shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}" |
4220 shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}" |
4221 proof- |
4221 proof- |
4222 have "{x + y |x y. x \<in> t \<and> y \<in> s} = {x + y |x y. x \<in> s \<and> y \<in> t}" apply auto |
4222 have "{x + y |x y. x \<in> t \<and> y \<in> s} = {x + y |x y. x \<in> s \<and> y \<in> t}" apply auto |
4223 apply(rule_tac x=y in exI) apply auto apply(rule_tac x=y in exI) by auto |
4223 apply(rule_tac x=y in exI) apply auto apply(rule_tac x=y in exI) by auto |
4224 thus ?thesis using compact_closed_sums[OF assms(2,1)] by simp |
4224 thus ?thesis using compact_closed_sums[OF assms(2,1)] by simp |
4225 qed |
4225 qed |
4226 |
4226 |
4227 lemma compact_closed_differences: |
4227 lemma compact_closed_differences: |
4228 assumes "compact s" "closed t" |
4228 assumes "compact s" "closed t" |
4229 shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}" |
4229 shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}" |
4230 proof- |
4230 proof- |
4231 have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}" |
4231 have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}" |
4232 apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4232 apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4233 thus ?thesis using compact_closed_sums[OF assms(1) closed_negations[OF assms(2)]] by auto |
4233 thus ?thesis using compact_closed_sums[OF assms(1) closed_negations[OF assms(2)]] by auto |
4234 qed |
4234 qed |
4235 |
4235 |
4236 lemma closed_compact_differences: |
4236 lemma closed_compact_differences: |
4237 assumes "closed s" "compact t" |
4237 assumes "closed s" "compact t" |
4238 shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}" |
4238 shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}" |
4239 proof- |
4239 proof- |
4240 have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}" |
4240 have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}" |
4241 apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4241 apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto |
4242 thus ?thesis using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]] by simp |
4242 thus ?thesis using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]] by simp |
4243 qed |
4243 qed |
4244 |
4244 |
4245 lemma closed_translation: |
4245 lemma closed_translation: |
4246 assumes "closed s" shows "closed ((\<lambda>x. a + x) ` s)" |
4246 assumes "closed s" shows "closed ((\<lambda>x. a + x) ` s)" |
4247 proof- |
4247 proof- |
4248 have "{a + y |y. y \<in> s} = (op + a ` s)" by auto |
4248 have "{a + y |y. y \<in> s} = (op + a ` s)" by auto |
4249 thus ?thesis using compact_closed_sums[OF compact_sing[of a] assms] by auto |
4249 thus ?thesis using compact_closed_sums[OF compact_sing[of a] assms] by auto |
4250 qed |
4250 qed |
4251 |
4251 |
4252 lemma translation_UNIV: |
4252 lemma translation_UNIV: |
4253 "range (\<lambda>x::real^'a. a + x) = UNIV" |
4253 "range (\<lambda>x::real^'a. a + x) = UNIV" |
4254 apply (auto simp add: image_iff) apply(rule_tac x="x - a" in exI) by auto |
4254 apply (auto simp add: image_iff) apply(rule_tac x="x - a" in exI) by auto |
4255 |
4255 |
4256 lemma translation_diff: "(\<lambda>x::real^'a. a + x) ` (s - t) = ((\<lambda>x. a + x) ` s) - ((\<lambda>x. a + x) ` t)" by auto |
4256 lemma translation_diff: "(\<lambda>x::real^'a. a + x) ` (s - t) = ((\<lambda>x. a + x) ` s) - ((\<lambda>x. a + x) ` t)" by auto |
4257 |
4257 |
4258 lemma closure_translation: |
4258 lemma closure_translation: |
4259 "closure ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (closure s)" |
4259 "closure ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (closure s)" |
4260 proof- |
4260 proof- |
4261 have *:"op + a ` (UNIV - s) = UNIV - op + a ` s" apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto |
4261 have *:"op + a ` (UNIV - s) = UNIV - op + a ` s" apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto |
4262 show ?thesis unfolding closure_interior translation_diff translation_UNIV using interior_translation[of a "UNIV - s"] unfolding * by auto |
4262 show ?thesis unfolding closure_interior translation_diff translation_UNIV using interior_translation[of a "UNIV - s"] unfolding * by auto |
4263 qed |
4263 qed |
4264 |
4264 |
4265 lemma frontier_translation: |
4265 lemma frontier_translation: |
4266 "frontier((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (frontier s)" |
4266 "frontier((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (frontier s)" |
4267 unfolding frontier_def translation_diff interior_translation closure_translation by auto |
4267 unfolding frontier_def translation_diff interior_translation closure_translation by auto |
4268 |
4268 |
4269 subsection{* Separation between points and sets. *} |
4269 subsection{* Separation between points and sets. *} |
4270 |
4270 |
4271 lemma separate_point_closed: |
4271 lemma separate_point_closed: |
4272 "closed s \<Longrightarrow> a \<notin> s ==> (\<exists>d>0. \<forall>x\<in>s. d \<le> dist a x)" |
4272 "closed s \<Longrightarrow> a \<notin> s ==> (\<exists>d>0. \<forall>x\<in>s. d \<le> dist a x)" |
4273 proof(cases "s = {}") |
4273 proof(cases "s = {}") |
4274 case True |
4274 case True |
4275 thus ?thesis by(auto intro!: exI[where x=1]) |
4275 thus ?thesis by(auto intro!: exI[where x=1]) |
4276 next |
4276 next |
4278 assume "closed s" "a \<notin> s" |
4278 assume "closed s" "a \<notin> s" |
4279 then obtain x where "x\<in>s" "\<forall>y\<in>s. dist a x \<le> dist a y" using `s \<noteq> {}` distance_attains_inf [of s a] by blast |
4279 then obtain x where "x\<in>s" "\<forall>y\<in>s. dist a x \<le> dist a y" using `s \<noteq> {}` distance_attains_inf [of s a] by blast |
4280 with `x\<in>s` show ?thesis using dist_pos_lt[of a x] and`a \<notin> s` by blast |
4280 with `x\<in>s` show ?thesis using dist_pos_lt[of a x] and`a \<notin> s` by blast |
4281 qed |
4281 qed |
4282 |
4282 |
4283 lemma separate_compact_closed: |
4283 lemma separate_compact_closed: |
4284 assumes "compact s" and "closed t" and "s \<inter> t = {}" |
4284 assumes "compact s" and "closed t" and "s \<inter> t = {}" |
4285 shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" |
4285 shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" |
4286 proof- |
4286 proof- |
4287 have "0 \<notin> {x - y |x y. x \<in> s \<and> y \<in> t}" using assms(3) by auto |
4287 have "0 \<notin> {x - y |x y. x \<in> s \<and> y \<in> t}" using assms(3) by auto |
4288 then obtain d where "d>0" and d:"\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. d \<le> dist 0 x" |
4288 then obtain d where "d>0" and d:"\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. d \<le> dist 0 x" |
4289 using separate_point_closed[OF compact_closed_differences[OF assms(1,2)], of 0] by auto |
4289 using separate_point_closed[OF compact_closed_differences[OF assms(1,2)], of 0] by auto |
4290 { fix x y assume "x\<in>s" "y\<in>t" |
4290 { fix x y assume "x\<in>s" "y\<in>t" |
4291 hence "x - y \<in> {x - y |x y. x \<in> s \<and> y \<in> t}" by auto |
4291 hence "x - y \<in> {x - y |x y. x \<in> s \<and> y \<in> t}" by auto |
4292 hence "d \<le> dist (x - y) 0" using d[THEN bspec[where x="x - y"]] using dist_sym |
4292 hence "d \<le> dist (x - y) 0" using d[THEN bspec[where x="x - y"]] using dist_sym |
4293 by (auto simp add: dist_sym) |
4293 by (auto simp add: dist_sym) |
4294 hence "d \<le> dist x y" unfolding dist_def by auto } |
4294 hence "d \<le> dist x y" unfolding dist_def by auto } |
4295 thus ?thesis using `d>0` by auto |
4295 thus ?thesis using `d>0` by auto |
4296 qed |
4296 qed |
4297 |
4297 |
4298 lemma separate_closed_compact: |
4298 lemma separate_closed_compact: |
4299 assumes "closed s" and "compact t" and "s \<inter> t = {}" |
4299 assumes "closed s" and "compact t" and "s \<inter> t = {}" |
4300 shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" |
4300 shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" |
4301 proof- |
4301 proof- |
4302 have *:"t \<inter> s = {}" using assms(3) by auto |
4302 have *:"t \<inter> s = {}" using assms(3) by auto |
4303 show ?thesis using separate_compact_closed[OF assms(2,1) *] |
4303 show ?thesis using separate_compact_closed[OF assms(2,1) *] |
4304 apply auto apply(rule_tac x=d in exI) apply auto apply (erule_tac x=y in ballE) |
4304 apply auto apply(rule_tac x=d in exI) apply auto apply (erule_tac x=y in ballE) |
4305 by (auto simp add: dist_sym) |
4305 by (auto simp add: dist_sym) |
4306 qed |
4306 qed |
4307 |
4307 |
4308 (* A cute way of denoting open and closed intervals using overloading. *) |
4308 (* A cute way of denoting open and closed intervals using overloading. *) |
4309 |
4309 |
4481 { fix x assume x:"x\<in>{a<..<b}" |
4481 { fix x assume x:"x\<in>{a<..<b}" |
4482 { fix i assume "i\<in>dimset x" |
4482 { fix i assume "i\<in>dimset x" |
4483 hence "\<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" |
4483 hence "\<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" |
4484 using x[unfolded mem_interval, THEN bspec[where x=i]] |
4484 using x[unfolded mem_interval, THEN bspec[where x=i]] |
4485 using open_interval_lemma[of "a$i" "x$i" "b$i"] by auto } |
4485 using open_interval_lemma[of "a$i" "x$i" "b$i"] by auto } |
4486 |
4486 |
4487 hence "\<forall>i\<in>dimset x. \<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" by auto |
4487 hence "\<forall>i\<in>dimset x. \<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" by auto |
4488 then obtain d where d:"\<forall>i\<in>dimset x. 0 < d i \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d i \<longrightarrow> a $ i < x' \<and> x' < b $ i)" |
4488 then obtain d where d:"\<forall>i\<in>dimset x. 0 < d i \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d i \<longrightarrow> a $ i < x' \<and> x' < b $ i)" |
4489 using bchoice[of "dimset x" "\<lambda>i d. d>0 \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d \<longrightarrow> a $ i < x' \<and> x' < b $ i)"] by auto |
4489 using bchoice[of "dimset x" "\<lambda>i d. d>0 \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d \<longrightarrow> a $ i < x' \<and> x' < b $ i)"] by auto |
4490 |
4490 |
4491 let ?d = "Min (d ` dimset x)" |
4491 let ?d = "Min (d ` dimset x)" |
4492 have **:"finite (d ` dimset x)" "d ` dimset x \<noteq> {}" using dimindex_ge_1[of "UNIV::'n set"] by auto |
4492 have **:"finite (d ` dimset x)" "d ` dimset x \<noteq> {}" using dimindex_ge_1[of "UNIV::'n set"] by auto |
4493 have "?d>0" unfolding Min_gr_iff[OF **] using d by auto |
4493 have "?d>0" unfolding Min_gr_iff[OF **] using d by auto |
4494 moreover |
4494 moreover |
4495 { fix x' assume as:"dist x' x < ?d" |
4495 { fix x' assume as:"dist x' x < ?d" |
4496 { fix i assume i:"i \<in> dimset x" |
4496 { fix i assume i:"i \<in> dimset x" |
4497 have "\<bar>x'$i - x $ i\<bar> < d i" |
4497 have "\<bar>x'$i - x $ i\<bar> < d i" |
4498 using norm_bound_component_lt[OF as[unfolded dist_def], THEN bspec[where x=i], OF i] |
4498 using norm_bound_component_lt[OF as[unfolded dist_def], THEN bspec[where x=i], OF i] |
4499 unfolding vector_minus_component[OF i] and Min_gr_iff[OF **] using i by auto |
4499 unfolding vector_minus_component[OF i] and Min_gr_iff[OF **] using i by auto |
4500 hence "a $ i < x' $ i" "x' $ i < b $ i" using d[THEN bspec[where x=i], OF i] by auto } |
4500 hence "a $ i < x' $ i" "x' $ i < b $ i" using d[THEN bspec[where x=i], OF i] by auto } |
4501 hence "a < x' \<and> x' < b" unfolding vector_less_def by auto } |
4501 hence "a < x' \<and> x' < b" unfolding vector_less_def by auto } |
4502 ultimately have "\<exists>e>0. \<forall>x'. dist x' x < e \<longrightarrow> x' \<in> {a<..<b}" by auto |
4502 ultimately have "\<exists>e>0. \<forall>x'. dist x' x < e \<longrightarrow> x' \<in> {a<..<b}" by auto |
4503 } |
4503 } |
4504 thus ?thesis unfolding open_def using open_interval_lemma by auto |
4504 thus ?thesis unfolding open_def using open_interval_lemma by auto |
4607 finally have "(e *s x + (1 - e) *s y) $ i < b $ i" using i by (auto simp add: vector_add_component vector_smult_component) |
4607 finally have "(e *s x + (1 - e) *s y) $ i < b $ i" using i by (auto simp add: vector_add_component vector_smult_component) |
4608 } ultimately have "a $ i < (e *s x + (1 - e) *s y) $ i \<and> (e *s x + (1 - e) *s y) $ i < b $ i" by auto } |
4608 } ultimately have "a $ i < (e *s x + (1 - e) *s y) $ i \<and> (e *s x + (1 - e) *s y) $ i < b $ i" by auto } |
4609 thus ?thesis unfolding mem_interval by auto |
4609 thus ?thesis unfolding mem_interval by auto |
4610 qed |
4610 qed |
4611 |
4611 |
4612 lemma closure_open_interval: fixes a :: "real^'n" |
4612 lemma closure_open_interval: fixes a :: "real^'n" |
4613 assumes "{a<..<b} \<noteq> {}" |
4613 assumes "{a<..<b} \<noteq> {}" |
4614 shows "closure {a<..<b} = {a .. b}" |
4614 shows "closure {a<..<b} = {a .. b}" |
4615 proof- |
4615 proof- |
4616 have ab:"a < b" using assms[unfolded interval_ne_empty] unfolding vector_less_def by auto |
4616 have ab:"a < b" using assms[unfolded interval_ne_empty] unfolding vector_less_def by auto |
4617 let ?c = "(1 / 2) *s (a + b)" |
4617 let ?c = "(1 / 2) *s (a + b)" |
4618 { fix x assume as:"x \<in> {a .. b}" |
4618 { fix x assume as:"x \<in> {a .. b}" |
4619 def f == "\<lambda>n::nat. x + (inverse (real n + 1)) *s (?c - x)" |
4619 def f == "\<lambda>n::nat. x + (inverse (real n + 1)) *s (?c - x)" |
4620 { fix n assume fn:"f n < b \<longrightarrow> a < f n \<longrightarrow> f n = x" and xc:"x \<noteq> ?c" |
4620 { fix n assume fn:"f n < b \<longrightarrow> a < f n \<longrightarrow> f n = x" and xc:"x \<noteq> ?c" |
4621 have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto |
4621 have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto |
4622 have "inverse (real n + 1) *s (1 / 2) *s (a + b) + (1 - inverse (real n + 1)) *s x = |
4622 have "inverse (real n + 1) *s (1 / 2) *s (a + b) + (1 - inverse (real n + 1)) *s x = |
4623 x + inverse (real n + 1) *s ((1 / 2) *s (a + b) - x)" by (auto simp add: vector_ssub_ldistrib vector_add_ldistrib field_simps vector_sadd_rdistrib[THEN sym]) |
4623 x + inverse (real n + 1) *s ((1 / 2) *s (a + b) - x)" by (auto simp add: vector_ssub_ldistrib vector_add_ldistrib field_simps vector_sadd_rdistrib[THEN sym]) |
4624 hence "f n < b" and "a < f n" using open_closed_interval_convex[OF open_interval_midpoint[OF assms] as *] unfolding f_def by auto |
4624 hence "f n < b" and "a < f n" using open_closed_interval_convex[OF open_interval_midpoint[OF assms] as *] unfolding f_def by auto |
4625 hence False using fn unfolding f_def using xc by(auto simp add: vector_mul_lcancel vector_ssub_ldistrib) } |
4625 hence False using fn unfolding f_def using xc by(auto simp add: vector_mul_lcancel vector_ssub_ldistrib) } |
4626 moreover |
4626 moreover |
4627 { assume "\<not> (f ---> x) sequentially" |
4627 { assume "\<not> (f ---> x) sequentially" |
4643 lemma bounded_subset_open_interval_symmetric: fixes s::"(real^'n) set" |
4643 lemma bounded_subset_open_interval_symmetric: fixes s::"(real^'n) set" |
4644 assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a<..<a}" |
4644 assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a<..<a}" |
4645 proof- |
4645 proof- |
4646 obtain b where "b>0" and b:"\<forall>x\<in>s. norm x \<le> b" using assms[unfolded bounded_pos] by auto |
4646 obtain b where "b>0" and b:"\<forall>x\<in>s. norm x \<le> b" using assms[unfolded bounded_pos] by auto |
4647 def a \<equiv> "(\<chi> i. b+1)::real^'n" |
4647 def a \<equiv> "(\<chi> i. b+1)::real^'n" |
4648 { fix x assume "x\<in>s" |
4648 { fix x assume "x\<in>s" |
4649 fix i assume i:"i\<in>dimset a" |
4649 fix i assume i:"i\<in>dimset a" |
4650 have "(-a)$i < x$i" and "x$i < a$i" using b[THEN bspec[where x=x], OF `x\<in>s`] and component_le_norm[OF i, of x] |
4650 have "(-a)$i < x$i" and "x$i < a$i" using b[THEN bspec[where x=x], OF `x\<in>s`] and component_le_norm[OF i, of x] |
4651 unfolding vector_uminus_component[OF i] and a_def and Cart_lambda_beta'[OF i] by auto |
4651 unfolding vector_uminus_component[OF i] and a_def and Cart_lambda_beta'[OF i] by auto |
4652 } |
4652 } |
4653 thus ?thesis by(auto intro: exI[where x=a] simp add: vector_less_def) |
4653 thus ?thesis by(auto intro: exI[where x=a] simp add: vector_less_def) |
4654 qed |
4654 qed |
4655 |
4655 |
4656 lemma bounded_subset_open_interval: |
4656 lemma bounded_subset_open_interval: |
4657 "bounded s ==> (\<exists>a b. s \<subseteq> {a<..<b})" |
4657 "bounded s ==> (\<exists>a b. s \<subseteq> {a<..<b})" |
4658 by(metis bounded_subset_open_interval_symmetric) |
4658 by(metis bounded_subset_open_interval_symmetric) |
4659 |
4659 |
4660 lemma bounded_subset_closed_interval_symmetric: |
4660 lemma bounded_subset_closed_interval_symmetric: |
4661 assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a .. a}" |
4661 assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a .. a}" |
4662 proof- |
4662 proof- |
4663 obtain a where "s \<subseteq> {- a<..<a}" using bounded_subset_open_interval_symmetric[OF assms] by auto |
4663 obtain a where "s \<subseteq> {- a<..<a}" using bounded_subset_open_interval_symmetric[OF assms] by auto |
4664 thus ?thesis using interval_open_subset_closed[of "-a" a] by auto |
4664 thus ?thesis using interval_open_subset_closed[of "-a" a] by auto |
4665 qed |
4665 qed |
4666 |
4666 |
4667 lemma bounded_subset_closed_interval: |
4667 lemma bounded_subset_closed_interval: |
4668 "bounded s ==> (\<exists>a b. s \<subseteq> {a .. b})" |
4668 "bounded s ==> (\<exists>a b. s \<subseteq> {a .. b})" |
4669 using bounded_subset_closed_interval_symmetric[of s] by auto |
4669 using bounded_subset_closed_interval_symmetric[of s] by auto |
4670 |
4670 |
4671 lemma frontier_closed_interval: |
4671 lemma frontier_closed_interval: |
4672 "frontier {a .. b} = {a .. b} - {a<..<b}" |
4672 "frontier {a .. b} = {a .. b} - {a<..<b}" |
4673 unfolding frontier_def unfolding interior_closed_interval and closure_closed[OF closed_interval] .. |
4673 unfolding frontier_def unfolding interior_closed_interval and closure_closed[OF closed_interval] .. |
4674 |
4674 |
4675 lemma frontier_open_interval: |
4675 lemma frontier_open_interval: |
4676 "frontier {a<..<b} = (if {a<..<b} = {} then {} else {a .. b} - {a<..<b})" |
4676 "frontier {a<..<b} = (if {a<..<b} = {} then {} else {a .. b} - {a<..<b})" |
4677 proof(cases "{a<..<b} = {}") |
4677 proof(cases "{a<..<b} = {}") |
4678 case True thus ?thesis using frontier_empty by auto |
4678 case True thus ?thesis using frontier_empty by auto |
4679 next |
4679 next |
4680 case False thus ?thesis unfolding frontier_def and closure_open_interval[OF False] and interior_open[OF open_interval] by auto |
4680 case False thus ?thesis unfolding frontier_def and closure_open_interval[OF False] and interior_open[OF open_interval] by auto |
4799 { fix e::real |
4799 { fix e::real |
4800 assume "0 < e" "\<forall>e>0. \<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> dist l (f x) < e)" |
4800 assume "0 < e" "\<forall>e>0. \<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> dist l (f x) < e)" |
4801 then obtain x y where x:"netord net x y" and y:"\<forall>x. netord net x y \<longrightarrow> dist l (f x) < e / norm a" apply(erule_tac x="e / norm a" in allE) apply auto using False using norm_ge_zero[of a] apply auto |
4801 then obtain x y where x:"netord net x y" and y:"\<forall>x. netord net x y \<longrightarrow> dist l (f x) < e / norm a" apply(erule_tac x="e / norm a" in allE) apply auto using False using norm_ge_zero[of a] apply auto |
4802 using divide_pos_pos[of e "norm a"] by auto |
4802 using divide_pos_pos[of e "norm a"] by auto |
4803 { fix z assume "netord net z y" hence "dist l (f z) < e / norm a" using y by blast |
4803 { fix z assume "netord net z y" hence "dist l (f z) < e / norm a" using y by blast |
4804 hence "norm a * norm (l - f z) < e" unfolding dist_def and |
4804 hence "norm a * norm (l - f z) < e" unfolding dist_def and |
4805 pos_less_divide_eq[OF False[unfolded vec_0 zero_less_norm_iff[of a, THEN sym]]] and real_mult_commute by auto |
4805 pos_less_divide_eq[OF False[unfolded vec_0 zero_less_norm_iff[of a, THEN sym]]] and real_mult_commute by auto |
4806 hence "\<bar>a \<bullet> l - a \<bullet> f z\<bar> < e" using order_le_less_trans[OF norm_cauchy_schwarz_abs[of a "l - f z"], of e] unfolding dot_rsub[symmetric] by auto } |
4806 hence "\<bar>a \<bullet> l - a \<bullet> f z\<bar> < e" using order_le_less_trans[OF norm_cauchy_schwarz_abs[of a "l - f z"], of e] unfolding dot_rsub[symmetric] by auto } |
4807 hence "\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> \<bar>a \<bullet> l - a \<bullet> f x\<bar> < e)" using x by auto } |
4807 hence "\<exists>y. (\<exists>x. netord net x y) \<and> (\<forall>x. netord net x y \<longrightarrow> \<bar>a \<bullet> l - a \<bullet> f x\<bar> < e)" using x by auto } |
4808 thus ?thesis using assms unfolding Lim apply (auto simp add: dist_sym) |
4808 thus ?thesis using assms unfolding Lim apply (auto simp add: dist_sym) |
4809 unfolding dist_vec1 by auto |
4809 unfolding dist_vec1 by auto |
4810 qed |
4810 qed |
4811 |
4811 |
4812 lemma continuous_at_vec1_dot: |
4812 lemma continuous_at_vec1_dot: |
4813 "continuous (at x) (vec1 o (\<lambda>y. a \<bullet> y))" |
4813 "continuous (at x) (vec1 o (\<lambda>y. a \<bullet> y))" |
4814 proof- |
4814 proof- |
4815 have "((\<lambda>x. x) ---> x) (at x)" unfolding Lim_at by auto |
4815 have "((\<lambda>x. x) ---> x) (at x)" unfolding Lim_at by auto |
4816 thus ?thesis unfolding continuous_at and o_def using Lim_vec1_dot[of "\<lambda>x. x" x "at x" a] by auto |
4816 thus ?thesis unfolding continuous_at and o_def using Lim_vec1_dot[of "\<lambda>x. x" x "at x" a] by auto |
4817 qed |
4817 qed |
4818 |
4818 |
4819 lemma continuous_on_vec1_dot: |
4819 lemma continuous_on_vec1_dot: |
4820 "continuous_on s (vec1 o (\<lambda>y. a \<bullet> y)) " |
4820 "continuous_on s (vec1 o (\<lambda>y. a \<bullet> y)) " |
4821 using continuous_at_imp_continuous_on[of s "vec1 o (\<lambda>y. a \<bullet> y)"] |
4821 using continuous_at_imp_continuous_on[of s "vec1 o (\<lambda>y. a \<bullet> y)"] |
4822 using continuous_at_vec1_dot |
4822 using continuous_at_vec1_dot |
4823 by auto |
4823 by auto |
4824 |
4824 |
4992 using continuous_on_id |
4992 using continuous_on_id |
4993 apply(rule_tac x = "(\<lambda>x::real^'a.x)" in exI) |
4993 apply(rule_tac x = "(\<lambda>x::real^'a.x)" in exI) |
4994 apply(rule_tac x = "(\<lambda>x::real^'b.x)" in exI) |
4994 apply(rule_tac x = "(\<lambda>x::real^'b.x)" in exI) |
4995 by blast |
4995 by blast |
4996 |
4996 |
4997 lemma homeomorphic_sym: |
4997 lemma homeomorphic_sym: |
4998 "s homeomorphic t \<longleftrightarrow> t homeomorphic s" |
4998 "s homeomorphic t \<longleftrightarrow> t homeomorphic s" |
4999 unfolding homeomorphic_def |
4999 unfolding homeomorphic_def |
5000 unfolding homeomorphism_def |
5000 unfolding homeomorphism_def |
5001 by blast |
5001 by blast |
5002 |
5002 |
5003 lemma homeomorphic_trans: |
5003 lemma homeomorphic_trans: |
5004 assumes "s homeomorphic t" "t homeomorphic u" shows "s homeomorphic u" |
5004 assumes "s homeomorphic t" "t homeomorphic u" shows "s homeomorphic u" |
5005 proof- |
5005 proof- |
5006 obtain f1 g1 where fg1:"\<forall>x\<in>s. g1 (f1 x) = x" "f1 ` s = t" "continuous_on s f1" "\<forall>y\<in>t. f1 (g1 y) = y" "g1 ` t = s" "continuous_on t g1" |
5006 obtain f1 g1 where fg1:"\<forall>x\<in>s. g1 (f1 x) = x" "f1 ` s = t" "continuous_on s f1" "\<forall>y\<in>t. f1 (g1 y) = y" "g1 ` t = s" "continuous_on t g1" |
5007 using assms(1) unfolding homeomorphic_def homeomorphism_def by auto |
5007 using assms(1) unfolding homeomorphic_def homeomorphism_def by auto |
5008 obtain f2 g2 where fg2:"\<forall>x\<in>t. g2 (f2 x) = x" "f2 ` t = u" "continuous_on t f2" "\<forall>y\<in>u. f2 (g2 y) = y" "g2 ` u = t" "continuous_on u g2" |
5008 obtain f2 g2 where fg2:"\<forall>x\<in>t. g2 (f2 x) = x" "f2 ` t = u" "continuous_on t f2" "\<forall>y\<in>u. f2 (g2 y) = y" "g2 ` u = t" "continuous_on u g2" |
5009 using assms(2) unfolding homeomorphic_def homeomorphism_def by auto |
5009 using assms(2) unfolding homeomorphic_def homeomorphism_def by auto |
5010 |
5010 |
5011 { fix x assume "x\<in>s" hence "(g1 \<circ> g2) ((f2 \<circ> f1) x) = x" using fg1(1)[THEN bspec[where x=x]] and fg2(1)[THEN bspec[where x="f1 x"]] and fg1(2) by auto } |
5011 { fix x assume "x\<in>s" hence "(g1 \<circ> g2) ((f2 \<circ> f1) x) = x" using fg1(1)[THEN bspec[where x=x]] and fg2(1)[THEN bspec[where x="f1 x"]] and fg1(2) by auto } |
5012 moreover have "(f2 \<circ> f1) ` s = u" using fg1(2) fg2(2) by auto |
5012 moreover have "(f2 \<circ> f1) ` s = u" using fg1(2) fg2(2) by auto |
5013 moreover have "continuous_on s (f2 \<circ> f1)" using continuous_on_compose[OF fg1(3)] and fg2(3) unfolding fg1(2) by auto |
5013 moreover have "continuous_on s (f2 \<circ> f1)" using continuous_on_compose[OF fg1(3)] and fg2(3) unfolding fg1(2) by auto |
5014 moreover { fix y assume "y\<in>u" hence "(f2 \<circ> f1) ((g1 \<circ> g2) y) = y" using fg2(4)[THEN bspec[where x=y]] and fg1(4)[THEN bspec[where x="g2 y"]] and fg2(5) by auto } |
5014 moreover { fix y assume "y\<in>u" hence "(f2 \<circ> f1) ((g1 \<circ> g2) y) = y" using fg2(4)[THEN bspec[where x=y]] and fg1(4)[THEN bspec[where x="g2 y"]] and fg2(5) by auto } |
5015 moreover have "(g1 \<circ> g2) ` u = s" using fg1(5) fg2(5) by auto |
5015 moreover have "(g1 \<circ> g2) ` u = s" using fg1(5) fg2(5) by auto |
5016 moreover have "continuous_on u (g1 \<circ> g2)" using continuous_on_compose[OF fg2(6)] and fg1(6) unfolding fg2(5) by auto |
5016 moreover have "continuous_on u (g1 \<circ> g2)" using continuous_on_compose[OF fg2(6)] and fg1(6) unfolding fg2(5) by auto |
5017 ultimately show ?thesis unfolding homeomorphic_def homeomorphism_def apply(rule_tac x="f2 \<circ> f1" in exI) apply(rule_tac x="g1 \<circ> g2" in exI) by auto |
5017 ultimately show ?thesis unfolding homeomorphic_def homeomorphism_def apply(rule_tac x="f2 \<circ> f1" in exI) apply(rule_tac x="g1 \<circ> g2" in exI) by auto |
5018 qed |
5018 qed |
5019 |
5019 |
5020 lemma homeomorphic_minimal: |
5020 lemma homeomorphic_minimal: |
5021 "s homeomorphic t \<longleftrightarrow> |
5021 "s homeomorphic t \<longleftrightarrow> |
5022 (\<exists>f g. (\<forall>x\<in>s. f(x) \<in> t \<and> (g(f(x)) = x)) \<and> |
5022 (\<exists>f g. (\<forall>x\<in>s. f(x) \<in> t \<and> (g(f(x)) = x)) \<and> |
5023 (\<forall>y\<in>t. g(y) \<in> s \<and> (f(g(y)) = y)) \<and> |
5023 (\<forall>y\<in>t. g(y) \<in> s \<and> (f(g(y)) = y)) \<and> |
5024 continuous_on s f \<and> continuous_on t g)" |
5024 continuous_on s f \<and> continuous_on t g)" |
5025 unfolding homeomorphic_def homeomorphism_def |
5025 unfolding homeomorphic_def homeomorphism_def |
5026 apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) |
5026 apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) |
5027 apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) apply auto |
5027 apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) apply auto |
5028 unfolding image_iff |
5028 unfolding image_iff |
5029 apply(erule_tac x="g x" in ballE) apply(erule_tac x="x" in ballE) |
5029 apply(erule_tac x="g x" in ballE) apply(erule_tac x="x" in ballE) |
5030 apply auto apply(rule_tac x="g x" in bexI) apply auto |
5030 apply auto apply(rule_tac x="g x" in bexI) apply auto |
5031 apply(erule_tac x="f x" in ballE) apply(erule_tac x="x" in ballE) |
5031 apply(erule_tac x="f x" in ballE) apply(erule_tac x="x" in ballE) |
5032 apply auto apply(rule_tac x="f x" in bexI) by auto |
5032 apply auto apply(rule_tac x="f x" in bexI) by auto |
5033 |
5033 |
5034 subsection{* Relatively weak hypotheses if a set is compact. *} |
5034 subsection{* Relatively weak hypotheses if a set is compact. *} |
5035 |
5035 |
5036 definition "inv_on f s = (\<lambda>x. SOME y. y\<in>s \<and> f y = x)" |
5036 definition "inv_on f s = (\<lambda>x. SOME y. y\<in>s \<and> f y = x)" |
5037 |
5037 |
5038 lemma assumes "inj_on f s" "x\<in>s" |
5038 lemma assumes "inj_on f s" "x\<in>s" |
5039 shows "inv_on f s (f x) = x" |
5039 shows "inv_on f s (f x) = x" |
5040 using assms unfolding inj_on_def inv_on_def by auto |
5040 using assms unfolding inj_on_def inv_on_def by auto |
5041 |
5041 |
5042 lemma homeomorphism_compact: |
5042 lemma homeomorphism_compact: |
5043 assumes "compact s" "continuous_on s f" "f ` s = t" "inj_on f s" |
5043 assumes "compact s" "continuous_on s f" "f ` s = t" "inj_on f s" |
5044 shows "\<exists>g. homeomorphism s t f g" |
5044 shows "\<exists>g. homeomorphism s t f g" |
5045 proof- |
5045 proof- |
5046 def g \<equiv> "\<lambda>x. SOME y. y\<in>s \<and> f y = x" |
5046 def g \<equiv> "\<lambda>x. SOME y. y\<in>s \<and> f y = x" |
5047 have g:"\<forall>x\<in>s. g (f x) = x" using assms(3) assms(4)[unfolded inj_on_def] unfolding g_def by auto |
5047 have g:"\<forall>x\<in>s. g (f x) = x" using assms(3) assms(4)[unfolded inj_on_def] unfolding g_def by auto |
5051 hence "f (g y) = y" unfolding x(1)[THEN sym] by auto } |
5051 hence "f (g y) = y" unfolding x(1)[THEN sym] by auto } |
5052 hence g':"\<forall>x\<in>t. f (g x) = x" by auto |
5052 hence g':"\<forall>x\<in>t. f (g x) = x" by auto |
5053 moreover |
5053 moreover |
5054 { fix x |
5054 { fix x |
5055 have "x\<in>s \<Longrightarrow> x \<in> g ` t" using g[THEN bspec[where x=x]] unfolding image_iff using assms(3) by(auto intro!: bexI[where x="f x"]) |
5055 have "x\<in>s \<Longrightarrow> x \<in> g ` t" using g[THEN bspec[where x=x]] unfolding image_iff using assms(3) by(auto intro!: bexI[where x="f x"]) |
5056 moreover |
5056 moreover |
5057 { assume "x\<in>g ` t" |
5057 { assume "x\<in>g ` t" |
5058 then obtain y where y:"y\<in>t" "g y = x" by auto |
5058 then obtain y where y:"y\<in>t" "g y = x" by auto |
5059 then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto |
5059 then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto |
5060 hence "x \<in> s" unfolding g_def using someI2[of "\<lambda>b. b\<in>s \<and> f b = y" x' "\<lambda>x. x\<in>s"] unfolding y(2)[THEN sym] and g_def by auto } |
5060 hence "x \<in> s" unfolding g_def using someI2[of "\<lambda>b. b\<in>s \<and> f b = y" x' "\<lambda>x. x\<in>s"] unfolding y(2)[THEN sym] and g_def by auto } |
5061 ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" by auto } |
5061 ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" by auto } |
5062 hence "g ` t = s" by auto |
5062 hence "g ` t = s" by auto |
5063 ultimately |
5063 ultimately |
5064 show ?thesis unfolding homeomorphism_def homeomorphic_def |
5064 show ?thesis unfolding homeomorphism_def homeomorphic_def |
5065 apply(rule_tac x=g in exI) using g and assms(3) and continuous_on_inverse[OF assms(2,1), of g, unfolded assms(3)] and assms(2) by auto |
5065 apply(rule_tac x=g in exI) using g and assms(3) and continuous_on_inverse[OF assms(2,1), of g, unfolded assms(3)] and assms(2) by auto |
5066 qed |
5066 qed |
5067 |
5067 |
5068 lemma homeomorphic_compact: |
5068 lemma homeomorphic_compact: |
5069 "compact s \<Longrightarrow> continuous_on s f \<Longrightarrow> (f ` s = t) \<Longrightarrow> inj_on f s |
5069 "compact s \<Longrightarrow> continuous_on s f \<Longrightarrow> (f ` s = t) \<Longrightarrow> inj_on f s |
5070 \<Longrightarrow> s homeomorphic t" |
5070 \<Longrightarrow> s homeomorphic t" |
5071 unfolding homeomorphic_def by(metis homeomorphism_compact) |
5071 unfolding homeomorphic_def by(metis homeomorphism_compact) |
5072 |
5072 |
5073 text{* Preservation of topological properties. *} |
5073 text{* Preservation of topological properties. *} |
5074 |
5074 |
5075 lemma homeomorphic_compactness: |
5075 lemma homeomorphic_compactness: |
5076 "s homeomorphic t ==> (compact s \<longleftrightarrow> compact t)" |
5076 "s homeomorphic t ==> (compact s \<longleftrightarrow> compact t)" |
5077 unfolding homeomorphic_def homeomorphism_def |
5077 unfolding homeomorphic_def homeomorphism_def |
5078 by (metis compact_continuous_image) |
5078 by (metis compact_continuous_image) |
5079 |
5079 |
5080 text{* Results on translation, scaling etc. *} |
5080 text{* Results on translation, scaling etc. *} |
5081 |
5081 |
5082 lemma homeomorphic_scaling: |
5082 lemma homeomorphic_scaling: |
5083 assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. c *s x) ` s)" |
5083 assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. c *s x) ` s)" |
5084 unfolding homeomorphic_minimal |
5084 unfolding homeomorphic_minimal |
5085 apply(rule_tac x="\<lambda>x. c *s x" in exI) |
5085 apply(rule_tac x="\<lambda>x. c *s x" in exI) |
5086 apply(rule_tac x="\<lambda>x. (1 / c) *s x" in exI) |
5086 apply(rule_tac x="\<lambda>x. (1 / c) *s x" in exI) |
5087 apply auto unfolding vector_smult_assoc using assms apply auto |
5087 apply auto unfolding vector_smult_assoc using assms apply auto |
5088 using continuous_on_cmul[OF continuous_on_id] by auto |
5088 using continuous_on_cmul[OF continuous_on_id] by auto |
5089 |
5089 |
5090 lemma homeomorphic_translation: |
5090 lemma homeomorphic_translation: |
5091 "s homeomorphic ((\<lambda>x. a + x) ` s)" |
5091 "s homeomorphic ((\<lambda>x. a + x) ` s)" |
5092 unfolding homeomorphic_minimal |
5092 unfolding homeomorphic_minimal |
5093 apply(rule_tac x="\<lambda>x. a + x" in exI) |
5093 apply(rule_tac x="\<lambda>x. a + x" in exI) |
5094 apply(rule_tac x="\<lambda>x. -a + x" in exI) |
5094 apply(rule_tac x="\<lambda>x. -a + x" in exI) |
5095 using continuous_on_add[OF continuous_on_const continuous_on_id] by auto |
5095 using continuous_on_add[OF continuous_on_const continuous_on_id] by auto |
5096 |
5096 |
5097 lemma homeomorphic_affinity: |
5097 lemma homeomorphic_affinity: |
5098 assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. a + c *s x) ` s)" |
5098 assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. a + c *s x) ` s)" |
5099 proof- |
5099 proof- |
5100 have *:"op + a ` op *s c ` s = (\<lambda>x. a + c *s x) ` s" by auto |
5100 have *:"op + a ` op *s c ` s = (\<lambda>x. a + c *s x) ` s" by auto |
5101 show ?thesis |
5101 show ?thesis |
5102 using homeomorphic_trans |
5102 using homeomorphic_trans |
5125 show ?cth unfolding homeomorphic_minimal |
5125 show ?cth unfolding homeomorphic_minimal |
5126 apply(rule_tac x="\<lambda>x. b + (e/d) *s (x - a)" in exI) |
5126 apply(rule_tac x="\<lambda>x. b + (e/d) *s (x - a)" in exI) |
5127 apply(rule_tac x="\<lambda>x. a + (d/e) *s (x - b)" in exI) |
5127 apply(rule_tac x="\<lambda>x. a + (d/e) *s (x - b)" in exI) |
5128 apply (auto simp add: dist_sym) unfolding dist_def and vector_smult_assoc using assms apply auto |
5128 apply (auto simp add: dist_sym) unfolding dist_def and vector_smult_assoc using assms apply auto |
5129 unfolding norm_minus_cancel and norm_mul |
5129 unfolding norm_minus_cancel and norm_mul |
5130 using continuous_on_add[OF continuous_on_const continuous_on_cmul[OF continuous_on_sub[OF continuous_on_id continuous_on_const]]] |
5130 using continuous_on_add[OF continuous_on_const continuous_on_cmul[OF continuous_on_sub[OF continuous_on_id continuous_on_const]]] |
5131 apply auto |
5131 apply auto |
5132 using pos_le_divide_eq[OF *(1), THEN sym] unfolding real_mult_commute[of _ "\<bar>e / d\<bar>"] |
5132 using pos_le_divide_eq[OF *(1), THEN sym] unfolding real_mult_commute[of _ "\<bar>e / d\<bar>"] |
5133 using pos_le_divide_eq[OF *(2), THEN sym] unfolding real_mult_commute[of _ "\<bar>d / e\<bar>"] |
5133 using pos_le_divide_eq[OF *(2), THEN sym] unfolding real_mult_commute[of _ "\<bar>d / e\<bar>"] |
5134 by auto |
5134 by auto |
5135 qed |
5135 qed |
5136 |
5136 |
5137 text{* "Isometry" (up to constant bounds) of injective linear map etc. *} |
5137 text{* "Isometry" (up to constant bounds) of injective linear map etc. *} |
5138 |
5138 |
5139 lemma cauchy_isometric: |
5139 lemma cauchy_isometric: |
5140 assumes e:"0 < e" and s:"subspace s" and f:"linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and xs:"\<forall>n::nat. x n \<in> s" and cf:"cauchy(f o x)" |
5140 assumes e:"0 < e" and s:"subspace s" and f:"linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and xs:"\<forall>n::nat. x n \<in> s" and cf:"cauchy(f o x)" |
5141 shows "cauchy x" |
5141 shows "cauchy x" |
5142 proof- |
5142 proof- |
5143 { fix d::real assume "d>0" |
5143 { fix d::real assume "d>0" |
5144 then obtain N where N:"\<forall>n\<ge>N. norm (f (x n) - f (x N)) < e * d" |
5144 then obtain N where N:"\<forall>n\<ge>N. norm (f (x n) - f (x N)) < e * d" |
5145 using cf[unfolded cauchy o_def dist_def, THEN spec[where x="e*d"]] and e and mult_pos_pos[of e d] by auto |
5145 using cf[unfolded cauchy o_def dist_def, THEN spec[where x="e*d"]] and e and mult_pos_pos[of e d] by auto |
5146 { fix n assume "n\<ge>N" |
5146 { fix n assume "n\<ge>N" |
5147 hence "norm (f (x n - x N)) < e * d" using N[THEN spec[where x=n]] unfolding linear_sub[OF f, THEN sym] by auto |
5147 hence "norm (f (x n - x N)) < e * d" using N[THEN spec[where x=n]] unfolding linear_sub[OF f, THEN sym] by auto |
5148 moreover have "e * norm (x n - x N) \<le> norm (f (x n - x N))" |
5148 moreover have "e * norm (x n - x N) \<le> norm (f (x n - x N))" |
5149 using subspace_sub[OF s, of "x n" "x N"] using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]] |
5149 using subspace_sub[OF s, of "x n" "x N"] using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]] |
5150 using normf[THEN bspec[where x="x n - x N"]] by auto |
5150 using normf[THEN bspec[where x="x n - x N"]] by auto |
5151 ultimately have "norm (x n - x N) < d" using `e>0` |
5151 ultimately have "norm (x n - x N) < d" using `e>0` |
5152 using mult_left_less_imp_less[of e "norm (x n - x N)" d] by auto } |
5152 using mult_left_less_imp_less[of e "norm (x n - x N)" d] by auto } |
5153 hence "\<exists>N. \<forall>n\<ge>N. norm (x n - x N) < d" by auto } |
5153 hence "\<exists>N. \<forall>n\<ge>N. norm (x n - x N) < d" by auto } |
5154 thus ?thesis unfolding cauchy and dist_def by auto |
5154 thus ?thesis unfolding cauchy and dist_def by auto |
5155 qed |
5155 qed |
5156 |
5156 |
5157 lemma complete_isometric_image: |
5157 lemma complete_isometric_image: |
5158 assumes "0 < e" and s:"subspace s" and f:"linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and cs:"complete s" |
5158 assumes "0 < e" and s:"subspace s" and f:"linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and cs:"complete s" |
5159 shows "complete(f ` s)" |
5159 shows "complete(f ` s)" |
5160 proof- |
5160 proof- |
5161 { fix g assume as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"cauchy g" |
5161 { fix g assume as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"cauchy g" |
5162 then obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)" unfolding image_iff and Bex_def |
5162 then obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)" unfolding image_iff and Bex_def |
5163 using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto |
5163 using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto |
5164 hence x:"\<forall>n. x n \<in> s" "\<forall>n. g n = f (x n)" by auto |
5164 hence x:"\<forall>n. x n \<in> s" "\<forall>n. g n = f (x n)" by auto |
5165 hence "f \<circ> x = g" unfolding expand_fun_eq by auto |
5165 hence "f \<circ> x = g" unfolding expand_fun_eq by auto |
5166 then obtain l where "l\<in>s" and l:"(x ---> l) sequentially" |
5166 then obtain l where "l\<in>s" and l:"(x ---> l) sequentially" |
5167 using cs[unfolded complete_def, THEN spec[where x="x"]] |
5167 using cs[unfolded complete_def, THEN spec[where x="x"]] |
5168 using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1) by auto |
5168 using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1) by auto |
5169 hence "\<exists>l\<in>f ` s. (g ---> l) sequentially" |
5169 hence "\<exists>l\<in>f ` s. (g ---> l) sequentially" |
5170 using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l] |
5170 using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l] |
5171 unfolding `f \<circ> x = g` by auto } |
5171 unfolding `f \<circ> x = g` by auto } |
5172 thus ?thesis unfolding complete_def by auto |
5172 thus ?thesis unfolding complete_def by auto |
5173 qed |
5173 qed |
5174 |
5174 |
5175 lemma dist_0_norm:"dist 0 x = norm x" unfolding dist_def by(auto simp add: norm_minus_cancel) |
5175 lemma dist_0_norm:"dist 0 x = norm x" unfolding dist_def by(auto simp add: norm_minus_cancel) |
5211 hence "norm (f b) / norm b * norm x \<le> norm (f x)" |
5211 hence "norm (f b) / norm b * norm x \<le> norm (f x)" |
5212 proof(cases "x=0") |
5212 proof(cases "x=0") |
5213 case True thus "norm (f b) / norm b * norm x \<le> norm (f x)" by auto |
5213 case True thus "norm (f b) / norm b * norm x \<le> norm (f x)" by auto |
5214 next |
5214 next |
5215 case False |
5215 case False |
5216 hence *:"0 < norm a / norm x" using `a\<noteq>0` unfolding zero_less_norm_iff[THEN sym] by(simp only: divide_pos_pos) |
5216 hence *:"0 < norm a / norm x" using `a\<noteq>0` unfolding zero_less_norm_iff[THEN sym] by(simp only: divide_pos_pos) |
5217 have "\<forall>c. \<forall>x\<in>s. c *s x \<in> s" using s[unfolded subspace_def] by auto |
5217 have "\<forall>c. \<forall>x\<in>s. c *s x \<in> s" using s[unfolded subspace_def] by auto |
5218 hence "(norm a / norm x) *s x \<in> {x \<in> s. norm x = norm a}" using `x\<in>s` and `x\<noteq>0` by auto |
5218 hence "(norm a / norm x) *s x \<in> {x \<in> s. norm x = norm a}" using `x\<in>s` and `x\<noteq>0` by auto |
5219 thus "norm (f b) / norm b * norm x \<le> norm (f x)" using b[THEN bspec[where x="(norm a / norm x) *s x"]] |
5219 thus "norm (f b) / norm b * norm x \<le> norm (f x)" using b[THEN bspec[where x="(norm a / norm x) *s x"]] |
5220 unfolding linear_cmul[OF f(1)] and norm_mul and ba using `x\<noteq>0` `a\<noteq>0` |
5220 unfolding linear_cmul[OF f(1)] and norm_mul and ba using `x\<noteq>0` `a\<noteq>0` |
5221 by (auto simp add: real_mult_commute pos_le_divide_eq pos_divide_le_eq) |
5221 by (auto simp add: real_mult_commute pos_le_divide_eq pos_divide_le_eq) |
5222 qed } |
5222 qed } |
5223 ultimately |
5223 ultimately |
5224 show ?thesis by auto |
5224 show ?thesis by auto |
5225 qed |
5225 qed |
5226 |
5226 |
5227 lemma closed_injective_image_subspace: |
5227 lemma closed_injective_image_subspace: |
5228 assumes "subspace s" "linear f" "\<forall>x\<in>s. f x = 0 --> x = 0" "closed s" |
5228 assumes "subspace s" "linear f" "\<forall>x\<in>s. f x = 0 --> x = 0" "closed s" |
5229 shows "closed(f ` s)" |
5229 shows "closed(f ` s)" |
5230 proof- |
5230 proof- |
5231 obtain e where "e>0" and e:"\<forall>x\<in>s. e * norm x \<le> norm (f x)" using injective_imp_isometric[OF assms(4,1,2,3)] by auto |
5231 obtain e where "e>0" and e:"\<forall>x\<in>s. e * norm x \<le> norm (f x)" using injective_imp_isometric[OF assms(4,1,2,3)] by auto |
5232 show ?thesis using complete_isometric_image[OF `e>0` assms(1,2) e] and assms(4) |
5232 show ?thesis using complete_isometric_image[OF `e>0` assms(1,2) e] and assms(4) |
5233 unfolding complete_eq_closed[THEN sym] by auto |
5233 unfolding complete_eq_closed[THEN sym] by auto |
5234 qed |
5234 qed |
5235 |
5235 |
5236 subsection{* Some properties of a canonical subspace. *} |
5236 subsection{* Some properties of a canonical subspace. *} |
5237 |
5237 |
5238 lemma subspace_substandard: |
5238 lemma subspace_substandard: |
5239 "subspace {x::real^'n. (\<forall>i \<in> dimset x. d < i \<longrightarrow> x$i = 0)}" |
5239 "subspace {x::real^'n. (\<forall>i \<in> dimset x. d < i \<longrightarrow> x$i = 0)}" |
5240 unfolding subspace_def by(auto simp add: vector_add_component vector_smult_component elim!: ballE) |
5240 unfolding subspace_def by(auto simp add: vector_add_component vector_smult_component elim!: ballE) |
5241 |
5241 |
5242 lemma closed_substandard: |
5242 lemma closed_substandard: |
5243 "closed {x::real^'n. \<forall>i \<in> dimset x. d < i --> x$i = 0}" (is "closed ?A") |
5243 "closed {x::real^'n. \<forall>i \<in> dimset x. d < i --> x$i = 0}" (is "closed ?A") |
5244 proof- |
5244 proof- |
5245 let ?D = "{Suc d..dimindex(UNIV::('n set))}" |
5245 let ?D = "{Suc d..dimindex(UNIV::('n set))}" |
5246 let ?Bs = "{{x::real^'n. basis i \<bullet> x = 0}| i. i \<in> ?D}" |
5246 let ?Bs = "{{x::real^'n. basis i \<bullet> x = 0}| i. i \<in> ?D}" |
5247 { fix x |
5247 { fix x |
5248 { assume "x\<in>?A" |
5248 { assume "x\<in>?A" |
5249 hence x:"\<forall>i\<in>?D. d < i \<longrightarrow> x $ i = 0" by auto |
5249 hence x:"\<forall>i\<in>?D. d < i \<longrightarrow> x $ i = 0" by auto |
5250 hence "x\<in> \<Inter> ?Bs" by(auto simp add: dot_basis x) } |
5250 hence "x\<in> \<Inter> ?Bs" by(auto simp add: dot_basis x) } |
5251 moreover |
5251 moreover |
5252 { assume x:"x\<in>\<Inter>?Bs" |
5252 { assume x:"x\<in>\<Inter>?Bs" |
5253 { fix i assume i:"i\<in>dimset x" and "d < i" |
5253 { fix i assume i:"i\<in>dimset x" and "d < i" |
5254 hence "i \<in> ?D" by auto |
5254 hence "i \<in> ?D" by auto |
5326 using dim_substandard[OF dim_subset_univ[of s]] by auto |
5326 using dim_substandard[OF dim_subset_univ[of s]] by auto |
5327 have "\<forall>x\<in>?t. f x = 0 \<longrightarrow> x = 0" using linear_0[OF f(1)] using f(3)[unfolded inj_on_def] |
5327 have "\<forall>x\<in>?t. f x = 0 \<longrightarrow> x = 0" using linear_0[OF f(1)] using f(3)[unfolded inj_on_def] |
5328 by(erule_tac x=0 in ballE) auto |
5328 by(erule_tac x=0 in ballE) auto |
5329 moreover have "closed ?t" using closed_substandard by auto |
5329 moreover have "closed ?t" using closed_substandard by auto |
5330 moreover have "subspace ?t" using subspace_substandard by auto |
5330 moreover have "subspace ?t" using subspace_substandard by auto |
5331 ultimately show ?thesis using closed_injective_image_subspace[of ?t f] |
5331 ultimately show ?thesis using closed_injective_image_subspace[of ?t f] |
5332 unfolding f(2) using f(1) by auto |
5332 unfolding f(2) using f(1) by auto |
5333 qed |
5333 qed |
5334 |
5334 |
5335 lemma complete_subspace: |
5335 lemma complete_subspace: |
5336 "subspace s ==> complete s" |
5336 "subspace s ==> complete s" |
5337 using complete_eq_closed closed_subspace |
5337 using complete_eq_closed closed_subspace |
5338 by auto |
5338 by auto |
5339 |
5339 |
5340 lemma dim_closure: |
5340 lemma dim_closure: |
5341 "dim(closure s) = dim s" (is "?dc = ?d") |
5341 "dim(closure s) = dim s" (is "?dc = ?d") |
5342 proof- |
5342 proof- |
5343 have "?dc \<le> ?d" using closure_minimal[OF span_inc, of s] |
5343 have "?dc \<le> ?d" using closure_minimal[OF span_inc, of s] |
5344 using closed_subspace[OF subspace_span, of s] |
5344 using closed_subspace[OF subspace_span, of s] |
5345 using dim_subset[of "closure s" "span s"] unfolding dim_span by auto |
5345 using dim_subset[of "closure s" "span s"] unfolding dim_span by auto |
5346 thus ?thesis using dim_subset[OF closure_subset, of s] by auto |
5346 thus ?thesis using dim_subset[OF closure_subset, of s] by auto |
5347 qed |
5347 qed |
5348 |
5348 |
5349 text{* Affine transformations of intervals. *} |
5349 text{* Affine transformations of intervals. *} |
5350 |
5350 |
5351 lemma affinity_inverses: |
5351 lemma affinity_inverses: |
5352 assumes m0: "m \<noteq> (0::'a::field)" |
5352 assumes m0: "m \<noteq> (0::'a::field)" |
5353 shows "(\<lambda>x. m *s x + c) o (\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) = id" |
5353 shows "(\<lambda>x. m *s x + c) o (\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) = id" |
5354 "(\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) o (\<lambda>x. m *s x + c) = id" |
5354 "(\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) o (\<lambda>x. m *s x + c) = id" |
5355 using m0 |
5355 using m0 |
5356 apply (auto simp add: expand_fun_eq vector_add_ldistrib vector_smult_assoc) |
5356 apply (auto simp add: expand_fun_eq vector_add_ldistrib vector_smult_assoc) |
5357 by (simp add: vector_smult_lneg[symmetric] vector_smult_assoc vector_sneg_minus1[symmetric]) |
5357 by (simp add: vector_smult_lneg[symmetric] vector_smult_assoc vector_sneg_minus1[symmetric]) |
5358 |
5358 |
5359 lemma real_affinity_le: |
5359 lemma real_affinity_le: |
5360 "0 < (m::'a::ordered_field) ==> (m * x + c \<le> y \<longleftrightarrow> x \<le> inverse(m) * y + -(c / m))" |
5360 "0 < (m::'a::ordered_field) ==> (m * x + c \<le> y \<longleftrightarrow> x \<le> inverse(m) * y + -(c / m))" |
5361 by (simp add: field_simps inverse_eq_divide) |
5361 by (simp add: field_simps inverse_eq_divide) |
5362 |
5362 |
5363 lemma real_le_affinity: |
5363 lemma real_le_affinity: |
5364 "0 < (m::'a::ordered_field) ==> (y \<le> m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) \<le> x)" |
5364 "0 < (m::'a::ordered_field) ==> (y \<le> m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) \<le> x)" |
5365 by (simp add: field_simps inverse_eq_divide) |
5365 by (simp add: field_simps inverse_eq_divide) |
5366 |
5366 |
5367 lemma real_affinity_lt: |
5367 lemma real_affinity_lt: |
5368 "0 < (m::'a::ordered_field) ==> (m * x + c < y \<longleftrightarrow> x < inverse(m) * y + -(c / m))" |
5368 "0 < (m::'a::ordered_field) ==> (m * x + c < y \<longleftrightarrow> x < inverse(m) * y + -(c / m))" |
5369 by (simp add: field_simps inverse_eq_divide) |
5369 by (simp add: field_simps inverse_eq_divide) |
5370 |
5370 |
5371 lemma real_lt_affinity: |
5371 lemma real_lt_affinity: |
5372 "0 < (m::'a::ordered_field) ==> (y < m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) < x)" |
5372 "0 < (m::'a::ordered_field) ==> (y < m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) < x)" |
5373 by (simp add: field_simps inverse_eq_divide) |
5373 by (simp add: field_simps inverse_eq_divide) |
5374 |
5374 |
5375 lemma real_affinity_eq: |
5375 lemma real_affinity_eq: |
5376 "(m::'a::ordered_field) \<noteq> 0 ==> (m * x + c = y \<longleftrightarrow> x = inverse(m) * y + -(c / m))" |
5376 "(m::'a::ordered_field) \<noteq> 0 ==> (m * x + c = y \<longleftrightarrow> x = inverse(m) * y + -(c / m))" |
5377 by (simp add: field_simps inverse_eq_divide) |
5377 by (simp add: field_simps inverse_eq_divide) |
5378 |
5378 |
5379 lemma real_eq_affinity: |
5379 lemma real_eq_affinity: |
5380 "(m::'a::ordered_field) \<noteq> 0 ==> (y = m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) = x)" |
5380 "(m::'a::ordered_field) \<noteq> 0 ==> (y = m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) = x)" |
5381 by (simp add: field_simps inverse_eq_divide) |
5381 by (simp add: field_simps inverse_eq_divide) |
5382 |
5382 |
5383 lemma vector_affinity_eq: |
5383 lemma vector_affinity_eq: |
5384 assumes m0: "(m::'a::field) \<noteq> 0" |
5384 assumes m0: "(m::'a::field) \<noteq> 0" |
5385 shows "m *s x + c = y \<longleftrightarrow> x = inverse m *s y + -(inverse m *s c)" |
5385 shows "m *s x + c = y \<longleftrightarrow> x = inverse m *s y + -(inverse m *s c)" |
5386 proof |
5386 proof |
5387 assume h: "m *s x + c = y" |
5387 assume h: "m *s x + c = y" |
5388 hence "m *s x = y - c" by (simp add: ring_simps) |
5388 hence "m *s x = y - c" by (simp add: ring_simps) |
5389 hence "inverse m *s (m *s x) = inverse m *s (y - c)" by simp |
5389 hence "inverse m *s (m *s x) = inverse m *s (y - c)" by simp |
5390 then show "x = inverse m *s y + - (inverse m *s c)" |
5390 then show "x = inverse m *s y + - (inverse m *s c)" |
5391 using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) |
5391 using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) |
5392 next |
5392 next |
5393 assume h: "x = inverse m *s y + - (inverse m *s c)" |
5393 assume h: "x = inverse m *s y + - (inverse m *s c)" |
5394 show "m *s x + c = y" unfolding h diff_minus[symmetric] |
5394 show "m *s x + c = y" unfolding h diff_minus[symmetric] |
5395 using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) |
5395 using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) |
5396 qed |
5396 qed |
5397 |
5397 |
5398 lemma vector_eq_affinity: |
5398 lemma vector_eq_affinity: |
5399 "(m::'a::field) \<noteq> 0 ==> (y = m *s x + c \<longleftrightarrow> inverse(m) *s y + -(inverse(m) *s c) = x)" |
5399 "(m::'a::field) \<noteq> 0 ==> (y = m *s x + c \<longleftrightarrow> inverse(m) *s y + -(inverse(m) *s c) = x)" |
5400 using vector_affinity_eq[where m=m and x=x and y=y and c=c] |
5400 using vector_affinity_eq[where m=m and x=x and y=y and c=c] |
5401 by metis |
5401 by metis |
5402 |
5402 |
5403 lemma image_affinity_interval: fixes m::real |
5403 lemma image_affinity_interval: fixes m::real |
5413 ultimately show ?thesis by auto |
5413 ultimately show ?thesis by auto |
5414 next |
5414 next |
5415 case False |
5415 case False |
5416 { fix y assume "a \<le> y" "y \<le> b" "m > 0" |
5416 { fix y assume "a \<le> y" "y \<le> b" "m > 0" |
5417 hence "m *s a + c \<le> m *s y + c" "m *s y + c \<le> m *s b + c" |
5417 hence "m *s a + c \<le> m *s y + c" "m *s y + c \<le> m *s b + c" |
5418 unfolding vector_less_eq_def by(auto simp add: vector_smult_component vector_add_component) |
5418 unfolding vector_less_eq_def by(auto simp add: vector_smult_component vector_add_component) |
5419 } moreover |
5419 } moreover |
5420 { fix y assume "a \<le> y" "y \<le> b" "m < 0" |
5420 { fix y assume "a \<le> y" "y \<le> b" "m < 0" |
5421 hence "m *s b + c \<le> m *s y + c" "m *s y + c \<le> m *s a + c" |
5421 hence "m *s b + c \<le> m *s y + c" "m *s y + c \<le> m *s a + c" |
5422 unfolding vector_less_eq_def by(auto simp add: vector_smult_component vector_add_component mult_left_mono_neg elim!:ballE) |
5422 unfolding vector_less_eq_def by(auto simp add: vector_smult_component vector_add_component mult_left_mono_neg elim!:ballE) |
5423 } moreover |
5423 } moreover |
5424 { fix y assume "m > 0" "m *s a + c \<le> y" "y \<le> m *s b + c" |
5424 { fix y assume "m > 0" "m *s a + c \<le> y" "y \<le> m *s b + c" |
5425 hence "y \<in> (\<lambda>x. m *s x + c) ` {a..b}" |
5425 hence "y \<in> (\<lambda>x. m *s x + c) ` {a..b}" |
5426 unfolding image_iff Bex_def mem_interval vector_less_eq_def |
5426 unfolding image_iff Bex_def mem_interval vector_less_eq_def |
5427 apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] |
5427 apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] |
5428 intro!: exI[where x="(1 / m) *s (y - c)"]) |
5428 intro!: exI[where x="(1 / m) *s (y - c)"]) |
5429 by(auto elim!: ballE simp add: pos_le_divide_eq pos_divide_le_eq real_mult_commute) |
5429 by(auto elim!: ballE simp add: pos_le_divide_eq pos_divide_le_eq real_mult_commute) |
5430 } moreover |
5430 } moreover |
5431 { fix y assume "m *s b + c \<le> y" "y \<le> m *s a + c" "m < 0" |
5431 { fix y assume "m *s b + c \<le> y" "y \<le> m *s a + c" "m < 0" |
5432 hence "y \<in> (\<lambda>x. m *s x + c) ` {a..b}" |
5432 hence "y \<in> (\<lambda>x. m *s x + c) ` {a..b}" |
5433 unfolding image_iff Bex_def mem_interval vector_less_eq_def |
5433 unfolding image_iff Bex_def mem_interval vector_less_eq_def |
5434 apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] |
5434 apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] |
5484 also have "\<dots> \<le> c ^ m * d * (1 - c ^ k) + (1 - c) * c ^ (m + k) * d" |
5484 also have "\<dots> \<le> c ^ m * d * (1 - c ^ k) + (1 - c) * c ^ (m + k) * d" |
5485 using Suc by (auto simp add: ring_simps) |
5485 using Suc by (auto simp add: ring_simps) |
5486 also have "\<dots> = (c ^ m) * (d * (1 - c ^ k) + (1 - c) * c ^ k * d)" |
5486 also have "\<dots> = (c ^ m) * (d * (1 - c ^ k) + (1 - c) * c ^ k * d)" |
5487 unfolding power_add by (auto simp add: ring_simps) |
5487 unfolding power_add by (auto simp add: ring_simps) |
5488 also have "\<dots> \<le> (c ^ m) * d * (1 - c ^ Suc k)" |
5488 also have "\<dots> \<le> (c ^ m) * d * (1 - c ^ Suc k)" |
5489 using c by (auto simp add: ring_simps dist_pos_le) |
5489 using c by (auto simp add: ring_simps dist_pos_le) |
5490 finally show ?case by auto |
5490 finally show ?case by auto |
5491 qed |
5491 qed |
5492 } note cf_z2 = this |
5492 } note cf_z2 = this |
5493 { fix e::real assume "e>0" |
5493 { fix e::real assume "e>0" |
5494 hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (z m) (z n) < e" |
5494 hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (z m) (z n) < e" |
5495 proof(cases "d = 0") |
5495 proof(cases "d = 0") |
5496 case True |
5496 case True |
5497 hence "\<And>n. z n = z0" using cf_z2[of 0] and c unfolding z_def by (auto simp add: pos_prod_le[OF `1 - c > 0`] dist_le_0) |
5497 hence "\<And>n. z n = z0" using cf_z2[of 0] and c unfolding z_def by (auto simp add: pos_prod_le[OF `1 - c > 0`] dist_le_0) |
5498 thus ?thesis using `e>0` by auto |
5498 thus ?thesis using `e>0` by auto |
5499 next |
5499 next |
5500 case False hence "d>0" unfolding d_def using dist_pos_le[of "z 0" "z 1"] |
5500 case False hence "d>0" unfolding d_def using dist_pos_le[of "z 0" "z 1"] |
5501 by (metis False d_def real_less_def) |
5501 by (metis False d_def real_less_def) |
5502 hence "0 < e * (1 - c) / d" using `e>0` and `1-c>0` |
5502 hence "0 < e * (1 - c) / d" using `e>0` and `1-c>0` |
5503 using divide_pos_pos[of "e * (1 - c)" d] and mult_pos_pos[of e "1 - c"] by auto |
5503 using divide_pos_pos[of "e * (1 - c)" d] and mult_pos_pos[of e "1 - c"] by auto |
5504 then obtain N where N:"c ^ N < e * (1 - c) / d" using real_arch_pow_inv[of "e * (1 - c) / d" c] and c by auto |
5504 then obtain N where N:"c ^ N < e * (1 - c) / d" using real_arch_pow_inv[of "e * (1 - c) / d" c] and c by auto |
5505 { fix m n::nat assume "m>n" and as:"m\<ge>N" "n\<ge>N" |
5505 { fix m n::nat assume "m>n" and as:"m\<ge>N" "n\<ge>N" |
5506 have *:"c ^ n \<le> c ^ N" using `n\<ge>N` and c using power_decreasing[OF `n\<ge>N`, of c] by auto |
5506 have *:"c ^ n \<le> c ^ N" using `n\<ge>N` and c using power_decreasing[OF `n\<ge>N`, of c] by auto |
5507 have "1 - c ^ (m - n) > 0" using c and power_strict_mono[of c 1 "m - n"] using `m>n` by auto |
5507 have "1 - c ^ (m - n) > 0" using c and power_strict_mono[of c 1 "m - n"] using `m>n` by auto |
5508 hence **:"d * (1 - c ^ (m - n)) / (1 - c) > 0" |
5508 hence **:"d * (1 - c ^ (m - n)) / (1 - c) > 0" |
5509 using real_mult_order[OF `d>0`, of "1 - c ^ (m - n)"] |
5509 using real_mult_order[OF `d>0`, of "1 - c ^ (m - n)"] |
5510 using divide_pos_pos[of "d * (1 - c ^ (m - n))" "1 - c"] |
5510 using divide_pos_pos[of "d * (1 - c ^ (m - n))" "1 - c"] |
5511 using `0 < 1 - c` by auto |
5511 using `0 < 1 - c` by auto |
5512 |
5512 |
5513 have "dist (z m) (z n) \<le> c ^ n * d * (1 - c ^ (m - n)) / (1 - c)" |
5513 have "dist (z m) (z n) \<le> c ^ n * d * (1 - c ^ (m - n)) / (1 - c)" |
5514 using cf_z2[of n "m - n"] and `m>n` unfolding pos_le_divide_eq[OF `1-c>0`] |
5514 using cf_z2[of n "m - n"] and `m>n` unfolding pos_le_divide_eq[OF `1-c>0`] |
5515 by (auto simp add: real_mult_commute dist_sym) |
5515 by (auto simp add: real_mult_commute dist_sym) |
5516 also have "\<dots> \<le> c ^ N * d * (1 - c ^ (m - n)) / (1 - c)" |
5516 also have "\<dots> \<le> c ^ N * d * (1 - c ^ (m - n)) / (1 - c)" |
5517 using mult_right_mono[OF * order_less_imp_le[OF **]] |
5517 using mult_right_mono[OF * order_less_imp_le[OF **]] |
5518 unfolding real_mult_assoc by auto |
5518 unfolding real_mult_assoc by auto |
5519 also have "\<dots> < (e * (1 - c) / d) * d * (1 - c ^ (m - n)) / (1 - c)" |
5519 also have "\<dots> < (e * (1 - c) / d) * d * (1 - c ^ (m - n)) / (1 - c)" |
5527 proof(cases "n = m") |
5527 proof(cases "n = m") |
5528 case True thus ?thesis using `e>0` by auto |
5528 case True thus ?thesis using `e>0` by auto |
5529 next |
5529 next |
5530 case False thus ?thesis using as and *[of n m] *[of m n] unfolding nat_neq_iff by (auto simp add: dist_sym) |
5530 case False thus ?thesis using as and *[of n m] *[of m n] unfolding nat_neq_iff by (auto simp add: dist_sym) |
5531 qed } |
5531 qed } |
5532 thus ?thesis by auto |
5532 thus ?thesis by auto |
5533 qed |
5533 qed |
5534 } |
5534 } |
5535 hence "cauchy z" unfolding cauchy_def by auto |
5535 hence "cauchy z" unfolding cauchy_def by auto |
5536 then obtain x where "x\<in>s" and x:"(z ---> x) sequentially" using s(1)[unfolded compact_def complete_def, THEN spec[where x=z]] and z_in_s by auto |
5536 then obtain x where "x\<in>s" and x:"(z ---> x) sequentially" using s(1)[unfolded compact_def complete_def, THEN spec[where x=z]] and z_in_s by auto |
5537 |
5537 |
5538 def e \<equiv> "dist (f x) x" |
5538 def e \<equiv> "dist (f x) x" |
5539 have "e = 0" proof(rule ccontr) |
5539 have "e = 0" proof(rule ccontr) |
5540 assume "e \<noteq> 0" hence "e>0" unfolding e_def using dist_pos_le[of "f x" x] |
5540 assume "e \<noteq> 0" hence "e>0" unfolding e_def using dist_pos_le[of "f x" x] |
5541 by (metis dist_eq_0 dist_nz dist_sym e_def) |
5541 by (metis dist_eq_0 dist_nz dist_sym e_def) |
5542 then obtain N where N:"\<forall>n\<ge>N. dist (z n) x < e / 2" |
5542 then obtain N where N:"\<forall>n\<ge>N. dist (z n) x < e / 2" |
5543 using x[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
5543 using x[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto |
5544 hence N':"dist (z N) x < e / 2" by auto |
5544 hence N':"dist (z N) x < e / 2" by auto |
5545 |
5545 |
5546 have *:"c * dist (z N) x \<le> dist (z N) x" unfolding mult_le_cancel_right2 |
5546 have *:"c * dist (z N) x \<le> dist (z N) x" unfolding mult_le_cancel_right2 |
5547 using dist_pos_le[of "z N" x] and c |
5547 using dist_pos_le[of "z N" x] and c |
5548 by (metis dist_eq_0 dist_nz dist_sym order_less_asym real_less_def) |
5548 by (metis dist_eq_0 dist_nz dist_sym order_less_asym real_less_def) |
5549 have "dist (f (z N)) (f x) \<le> c * dist (z N) x" using lipschitz[THEN bspec[where x="z N"], THEN bspec[where x=x]] |
5549 have "dist (f (z N)) (f x) \<le> c * dist (z N) x" using lipschitz[THEN bspec[where x="z N"], THEN bspec[where x=x]] |
5550 using z_in_s[of N] `x\<in>s` using c by auto |
5550 using z_in_s[of N] `x\<in>s` using c by auto |
5551 also have "\<dots> < e / 2" using N' and c using * by auto |
5551 also have "\<dots> < e / 2" using N' and c using * by auto |
5552 finally show False unfolding fzn |
5552 finally show False unfolding fzn |
5553 using N[THEN spec[where x="Suc N"]] and dist_triangle_half_r[of "z (Suc N)" "f x" e x] |
5553 using N[THEN spec[where x="Suc N"]] and dist_triangle_half_r[of "z (Suc N)" "f x" e x] |
5557 moreover |
5557 moreover |
5558 { fix y assume "f y = y" "y\<in>s" |
5558 { fix y assume "f y = y" "y\<in>s" |
5559 hence "dist x y \<le> c * dist x y" using lipschitz[THEN bspec[where x=x], THEN bspec[where x=y]] |
5559 hence "dist x y \<le> c * dist x y" using lipschitz[THEN bspec[where x=x], THEN bspec[where x=y]] |
5560 using `x\<in>s` and `f x = x` by auto |
5560 using `x\<in>s` and `f x = x` by auto |
5561 hence "dist x y = 0" unfolding mult_le_cancel_right1 |
5561 hence "dist x y = 0" unfolding mult_le_cancel_right1 |
5562 using c and dist_pos_le[of x y] by auto |
5562 using c and dist_pos_le[of x y] by auto |
5563 hence "y = x" unfolding dist_eq_0 by auto |
5563 hence "y = x" unfolding dist_eq_0 by auto |
5564 } |
5564 } |
5565 ultimately show ?thesis unfolding Bex1_def using `x\<in>s` by blast+ |
5565 ultimately show ?thesis unfolding Bex1_def using `x\<in>s` by blast+ |
5566 qed |
5566 qed |
5567 |
5567 |
5568 subsection{* Edelstein fixed point theorem. *} |
5568 subsection{* Edelstein fixed point theorem. *} |
5569 |
5569 |
5570 lemma edelstein_fix: |
5570 lemma edelstein_fix: |
5571 assumes s:"compact s" "s \<noteq> {}" and gs:"(g ` s) \<subseteq> s" |
5571 assumes s:"compact s" "s \<noteq> {}" and gs:"(g ` s) \<subseteq> s" |
5572 and dist:"\<forall>x\<in>s. \<forall>y\<in>s. x \<noteq> y \<longrightarrow> dist (g x) (g y) < dist x y" |
5572 and dist:"\<forall>x\<in>s. \<forall>y\<in>s. x \<noteq> y \<longrightarrow> dist (g x) (g y) < dist x y" |
5573 shows "\<exists>! x::real^'a\<in>s. g x = x" |
5573 shows "\<exists>! x::real^'a\<in>s. g x = x" |
5574 proof(cases "\<exists>x\<in>s. g x \<noteq> x") |
5574 proof(cases "\<exists>x\<in>s. g x \<noteq> x") |
5575 obtain x where "x\<in>s" using s(2) by auto |
5575 obtain x where "x\<in>s" using s(2) by auto |
5576 case False hence g:"\<forall>x\<in>s. g x = x" by auto |
5576 case False hence g:"\<forall>x\<in>s. g x = x" by auto |
5577 { fix y assume "y\<in>s" |
5577 { fix y assume "y\<in>s" |
5578 hence "x = y" using `x\<in>s` and dist[THEN bspec[where x=x], THEN bspec[where x=y]] |
5578 hence "x = y" using `x\<in>s` and dist[THEN bspec[where x=x], THEN bspec[where x=y]] |
5579 unfolding g[THEN bspec[where x=x], OF `x\<in>s`] |
5579 unfolding g[THEN bspec[where x=x], OF `x\<in>s`] |
5580 unfolding g[THEN bspec[where x=y], OF `y\<in>s`] by auto } |
5580 unfolding g[THEN bspec[where x=y], OF `y\<in>s`] by auto } |
5581 thus ?thesis unfolding Bex1_def using `x\<in>s` and g by blast+ |
5581 thus ?thesis unfolding Bex1_def using `x\<in>s` and g by blast+ |
5582 next |
5582 next |
5583 case True |
5583 case True |
5584 then obtain x where [simp]:"x\<in>s" and "g x \<noteq> x" by auto |
5584 then obtain x where [simp]:"x\<in>s" and "g x \<noteq> x" by auto |
5585 { fix x y assume "x \<in> s" "y \<in> s" |
5585 { fix x y assume "x \<in> s" "y \<in> s" |
5586 hence "dist (g x) (g y) \<le> dist x y" |
5586 hence "dist (g x) (g y) \<le> dist x y" |