20 apply(subst(2) euclidean_dist_l2) apply(cases "i<DIM('a)") |
20 apply(subst(2) euclidean_dist_l2) apply(cases "i<DIM('a)") |
21 apply(rule member_le_setL2) by auto |
21 apply(rule member_le_setL2) by auto |
22 |
22 |
23 subsection{* General notion of a topology *} |
23 subsection{* General notion of a topology *} |
24 |
24 |
25 definition "istopology L \<longleftrightarrow> {} \<in> L \<and> (\<forall>S \<in>L. \<forall>T \<in>L. S \<inter> T \<in> L) \<and> (\<forall>K. K \<subseteq>L \<longrightarrow> \<Union> K \<in> L)" |
25 definition "istopology L \<longleftrightarrow> L {} \<and> (\<forall>S T. L S \<longrightarrow> L T \<longrightarrow> L (S \<inter> T)) \<and> (\<forall>K. Ball K L \<longrightarrow> L (\<Union> K))" |
26 typedef (open) 'a topology = "{L::('a set) set. istopology L}" |
26 typedef (open) 'a topology = "{L::('a set) \<Rightarrow> bool. istopology L}" |
27 morphisms "openin" "topology" |
27 morphisms "openin" "topology" |
28 unfolding istopology_def by blast |
28 unfolding istopology_def by blast |
29 |
29 |
30 lemma istopology_open_in[intro]: "istopology(openin U)" |
30 lemma istopology_open_in[intro]: "istopology(openin U)" |
31 using openin[of U] by blast |
31 using openin[of U] by blast |
32 |
32 |
33 lemma topology_inverse': "istopology U \<Longrightarrow> openin (topology U) = U" |
33 lemma topology_inverse': "istopology U \<Longrightarrow> openin (topology U) = U" |
34 using topology_inverse[unfolded mem_def Collect_def] . |
34 using topology_inverse[unfolded mem_Collect_eq] . |
35 |
35 |
36 lemma topology_inverse_iff: "istopology U \<longleftrightarrow> openin (topology U) = U" |
36 lemma topology_inverse_iff: "istopology U \<longleftrightarrow> openin (topology U) = U" |
37 using topology_inverse[of U] istopology_open_in[of "topology U"] by auto |
37 using topology_inverse[of U] istopology_open_in[of "topology U"] by auto |
38 |
38 |
39 lemma topology_eq: "T1 = T2 \<longleftrightarrow> (\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S)" |
39 lemma topology_eq: "T1 = T2 \<longleftrightarrow> (\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S)" |
40 proof- |
40 proof- |
41 {assume "T1=T2" hence "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S" by simp} |
41 {assume "T1=T2" hence "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S" by simp} |
42 moreover |
42 moreover |
43 {assume H: "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S" |
43 {assume H: "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S" |
44 hence "openin T1 = openin T2" by (metis mem_def set_eqI) |
44 hence "openin T1 = openin T2" by (simp add: fun_eq_iff) |
45 hence "topology (openin T1) = topology (openin T2)" by simp |
45 hence "topology (openin T1) = topology (openin T2)" by simp |
46 hence "T1 = T2" unfolding openin_inverse .} |
46 hence "T1 = T2" unfolding openin_inverse .} |
47 ultimately show ?thesis by blast |
47 ultimately show ?thesis by blast |
48 qed |
48 qed |
49 |
49 |
56 lemma openin_clauses: |
56 lemma openin_clauses: |
57 fixes U :: "'a topology" |
57 fixes U :: "'a topology" |
58 shows "openin U {}" |
58 shows "openin U {}" |
59 "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)" |
59 "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)" |
60 "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)" |
60 "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)" |
61 using openin[of U] unfolding istopology_def Collect_def mem_def |
61 using openin[of U] unfolding istopology_def mem_Collect_eq |
62 unfolding subset_eq Ball_def mem_def by auto |
62 by fast+ |
63 |
63 |
64 lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U" |
64 lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U" |
65 unfolding topspace_def by blast |
65 unfolding topspace_def by blast |
66 lemma openin_empty[simp]: "openin U {}" by (simp add: openin_clauses) |
66 lemma openin_empty[simp]: "openin U {}" by (simp add: openin_clauses) |
67 |
67 |
128 then show ?thesis using oS cT by (auto simp add: openin_closedin_eq) |
128 then show ?thesis using oS cT by (auto simp add: openin_closedin_eq) |
129 qed |
129 qed |
130 |
130 |
131 subsection{* Subspace topology. *} |
131 subsection{* Subspace topology. *} |
132 |
132 |
133 definition "subtopology U V = topology {S \<inter> V |S. openin U S}" |
133 term "{f x |x. P x}" |
134 |
134 term "{y. \<exists>x. y = f x \<and> P x}" |
135 lemma istopology_subtopology: "istopology {S \<inter> V |S. openin U S}" (is "istopology ?L") |
135 |
136 proof- |
136 definition "subtopology U V = topology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)" |
137 have "{} \<in> ?L" by blast |
137 |
138 {fix A B assume A: "A \<in> ?L" and B: "B \<in> ?L" |
138 lemma istopology_subtopology: "istopology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)" |
|
139 (is "istopology ?L") |
|
140 proof- |
|
141 have "?L {}" by blast |
|
142 {fix A B assume A: "?L A" and B: "?L B" |
139 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 |
143 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 |
140 have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ |
144 have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ |
141 then have "A \<inter> B \<in> ?L" by blast} |
145 then have "?L (A \<inter> B)" by blast} |
142 moreover |
146 moreover |
143 {fix K assume K: "K \<subseteq> ?L" |
147 {fix K assume K: "K \<subseteq> Collect ?L" |
144 have th0: "?L = (\<lambda>S. S \<inter> V) ` openin U " |
148 have th0: "Collect ?L = (\<lambda>S. S \<inter> V) ` Collect (openin U)" |
145 apply (rule set_eqI) |
149 apply (rule set_eqI) |
146 apply (simp add: Ball_def image_iff) |
150 apply (simp add: Ball_def image_iff) |
147 by (metis mem_def) |
151 by metis |
148 from K[unfolded th0 subset_image_iff] |
152 from K[unfolded th0 subset_image_iff] |
149 obtain Sk where Sk: "Sk \<subseteq> openin U" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast |
153 obtain Sk where Sk: "Sk \<subseteq> Collect (openin U)" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast |
150 have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto |
154 have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto |
151 moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq mem_def) |
155 moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq) |
152 ultimately have "\<Union>K \<in> ?L" by blast} |
156 ultimately have "?L (\<Union>K)" by blast} |
153 ultimately show ?thesis unfolding istopology_def by blast |
157 ultimately show ?thesis |
|
158 unfolding subset_eq mem_Collect_eq istopology_def by blast |
154 qed |
159 qed |
155 |
160 |
156 lemma openin_subtopology: |
161 lemma openin_subtopology: |
157 "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" |
162 "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" |
158 unfolding subtopology_def topology_inverse'[OF istopology_subtopology] |
163 unfolding subtopology_def topology_inverse'[OF istopology_subtopology] |
159 by (auto simp add: Collect_def) |
164 by auto |
160 |
165 |
161 lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" |
166 lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" |
162 by (auto simp add: topspace_def openin_subtopology) |
167 by (auto simp add: topspace_def openin_subtopology) |
163 |
168 |
164 lemma closedin_subtopology: |
169 lemma closedin_subtopology: |
208 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S" |
213 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S" |
209 unfolding euclidean_def |
214 unfolding euclidean_def |
210 apply (rule cong[where x=S and y=S]) |
215 apply (rule cong[where x=S and y=S]) |
211 apply (rule topology_inverse[symmetric]) |
216 apply (rule topology_inverse[symmetric]) |
212 apply (auto simp add: istopology_def) |
217 apply (auto simp add: istopology_def) |
213 by (auto simp add: mem_def subset_eq) |
218 done |
214 |
219 |
215 lemma topspace_euclidean: "topspace euclidean = UNIV" |
220 lemma topspace_euclidean: "topspace euclidean = UNIV" |
216 apply (simp add: topspace_def) |
221 apply (simp add: topspace_def) |
217 apply (rule set_eqI) |
222 apply (rule set_eqI) |
218 by (auto simp add: open_openin[symmetric]) |
223 by (auto simp add: open_openin[symmetric]) |
264 "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ |
269 "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ |
265 lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" |
270 lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" |
266 "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ |
271 "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ |
267 |
272 |
268 lemma open_ball[intro, simp]: "open (ball x e)" |
273 lemma open_ball[intro, simp]: "open (ball x e)" |
269 unfolding open_dist ball_def Collect_def Ball_def mem_def |
274 unfolding open_dist ball_def mem_Collect_eq Ball_def |
270 unfolding dist_commute |
275 unfolding dist_commute |
271 apply clarify |
276 apply clarify |
272 apply (rule_tac x="e - dist xa x" in exI) |
277 apply (rule_tac x="e - dist xa x" in exI) |
273 using dist_triangle_alt[where z=x] |
278 using dist_triangle_alt[where z=x] |
274 apply (clarsimp simp add: diff_less_iff) |
279 apply (clarsimp simp add: diff_less_iff) |
490 |
495 |
491 lemma closed_limpt: "closed S \<longleftrightarrow> (\<forall>x. x islimpt S \<longrightarrow> x \<in> S)" |
496 lemma closed_limpt: "closed S \<longleftrightarrow> (\<forall>x. x islimpt S \<longrightarrow> x \<in> S)" |
492 unfolding closed_def |
497 unfolding closed_def |
493 apply (subst open_subopen) |
498 apply (subst open_subopen) |
494 apply (simp add: islimpt_def subset_eq) |
499 apply (simp add: islimpt_def subset_eq) |
495 by (metis ComplE ComplI insertCI insert_absorb mem_def) |
500 by (metis ComplE ComplI) |
496 |
501 |
497 lemma islimpt_EMPTY[simp]: "\<not> x islimpt {}" |
502 lemma islimpt_EMPTY[simp]: "\<not> x islimpt {}" |
498 unfolding islimpt_def by auto |
503 unfolding islimpt_def by auto |
499 |
504 |
500 lemma finite_set_avoid: |
505 lemma finite_set_avoid: |
689 using closed_limpt[of t] |
694 using closed_limpt[of t] |
690 by auto |
695 by auto |
691 } |
696 } |
692 ultimately show ?thesis |
697 ultimately show ?thesis |
693 using hull_unique[of S, of "closure S", of closed] |
698 using hull_unique[of S, of "closure S", of closed] |
694 unfolding mem_def |
|
695 by simp |
699 by simp |
696 qed |
700 qed |
697 |
701 |
698 lemma closure_eq: "closure S = S \<longleftrightarrow> closed S" |
702 lemma closure_eq: "closure S = S \<longleftrightarrow> closed S" |
699 unfolding closure_hull |
703 unfolding closure_hull |
700 using hull_eq[of closed, unfolded mem_def, OF closed_Inter, of S] |
704 using hull_eq[of closed, OF closed_Inter, of S] |
701 by (metis mem_def subset_eq) |
705 by metis |
702 |
706 |
703 lemma closure_closed[simp]: "closed S \<Longrightarrow> closure S = S" |
707 lemma closure_closed[simp]: "closed S \<Longrightarrow> closure S = S" |
704 using closure_eq[of S] |
708 using closure_eq[of S] |
705 by simp |
709 by simp |
706 |
710 |
719 using hull_mono[of S T closed] |
723 using hull_mono[of S T closed] |
720 by assumption |
724 by assumption |
721 |
725 |
722 lemma closure_minimal: "S \<subseteq> T \<Longrightarrow> closed T \<Longrightarrow> closure S \<subseteq> T" |
726 lemma closure_minimal: "S \<subseteq> T \<Longrightarrow> closed T \<Longrightarrow> closure S \<subseteq> T" |
723 using hull_minimal[of S T closed] |
727 using hull_minimal[of S T closed] |
724 unfolding closure_hull mem_def |
728 unfolding closure_hull |
725 by simp |
729 by simp |
726 |
730 |
727 lemma closure_unique: "S \<subseteq> T \<and> closed T \<and> (\<forall> T'. S \<subseteq> T' \<and> closed T' \<longrightarrow> T \<subseteq> T') \<Longrightarrow> closure S = T" |
731 lemma closure_unique: "S \<subseteq> T \<and> closed T \<and> (\<forall> T'. S \<subseteq> T' \<and> closed T' \<longrightarrow> T \<subseteq> T') \<Longrightarrow> closure S = T" |
728 using hull_unique[of S T closed] |
732 using hull_unique[of S T closed] |
729 unfolding closure_hull mem_def |
733 unfolding closure_hull |
730 by simp |
734 by simp |
731 |
735 |
732 lemma closure_empty[simp]: "closure {} = {}" |
736 lemma closure_empty[simp]: "closure {} = {}" |
733 using closed_empty closure_closed[of "{}"] |
737 using closed_empty closure_closed[of "{}"] |
734 by simp |
738 by simp |
1621 } ultimately |
1625 } ultimately |
1622 show ?thesis unfolding open_contains_ball by auto |
1626 show ?thesis unfolding open_contains_ball by auto |
1623 qed |
1627 qed |
1624 |
1628 |
1625 lemma open_contains_cball_eq: "open S ==> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))" |
1629 lemma open_contains_cball_eq: "open S ==> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))" |
1626 by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball mem_def) |
1630 by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball) |
1627 |
1631 |
1628 lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)" |
1632 lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)" |
1629 apply (simp add: interior_def, safe) |
1633 apply (simp add: interior_def, safe) |
1630 apply (force simp add: open_contains_cball) |
1634 apply (force simp add: open_contains_cball) |
1631 apply (rule_tac x="ball x e" in exI) |
1635 apply (rule_tac x="ball x e" in exI) |