src/HOL/Analysis/Connected.thy
changeset 67686 2c58505bf151
parent 67683 817944aeac3f
parent 67685 bdff8bf0a75b
child 67707 68ca05a7f159
equal deleted inserted replaced
67683:817944aeac3f 67686:2c58505bf151
  1093     then show ?lhs
  1093     then show ?lhs
  1094       using compact_cbox is_interval_cbox by blast
  1094       using compact_cbox is_interval_cbox by blast
  1095   qed
  1095   qed
  1096 qed
  1096 qed
  1097 
  1097 
       
  1098 text \<open>Hence some handy theorems on distance, diameter etc. of/from a set.\<close>
       
  1099 
       
  1100 lemma distance_attains_sup:
       
  1101   assumes "compact s" "s \<noteq> {}"
       
  1102   shows "\<exists>x\<in>s. \<forall>y\<in>s. dist a y \<le> dist a x"
       
  1103 proof (rule continuous_attains_sup [OF assms])
       
  1104   {
       
  1105     fix x
       
  1106     assume "x\<in>s"
       
  1107     have "(dist a \<longlongrightarrow> dist a x) (at x within s)"
       
  1108       by (intro tendsto_dist tendsto_const tendsto_ident_at)
       
  1109   }
       
  1110   then show "continuous_on s (dist a)"
       
  1111     unfolding continuous_on ..
       
  1112 qed
       
  1113 
       
  1114 text \<open>For \emph{minimal} distance, we only need closure, not compactness.\<close>
       
  1115 
       
  1116 lemma distance_attains_inf:
       
  1117   fixes a :: "'a::heine_borel"
       
  1118   assumes "closed s" and "s \<noteq> {}"
       
  1119   obtains x where "x\<in>s" "\<And>y. y \<in> s \<Longrightarrow> dist a x \<le> dist a y"
       
  1120 proof -
       
  1121   from assms obtain b where "b \<in> s" by auto
       
  1122   let ?B = "s \<inter> cball a (dist b a)"
       
  1123   have "?B \<noteq> {}" using \<open>b \<in> s\<close>
       
  1124     by (auto simp: dist_commute)
       
  1125   moreover have "continuous_on ?B (dist a)"
       
  1126     by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const)
       
  1127   moreover have "compact ?B"
       
  1128     by (intro closed_Int_compact \<open>closed s\<close> compact_cball)
       
  1129   ultimately obtain x where "x \<in> ?B" "\<forall>y\<in>?B. dist a x \<le> dist a y"
       
  1130     by (metis continuous_attains_inf)
       
  1131   with that show ?thesis by fastforce
       
  1132 qed
       
  1133 
       
  1134 
  1098 subsection\<open>Relations among convergence and absolute convergence for power series.\<close>
  1135 subsection\<open>Relations among convergence and absolute convergence for power series.\<close>
  1099 
  1136 
  1100 lemma summable_imp_bounded:
  1137 lemma summable_imp_bounded:
  1101   fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
  1138   fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
  1102   shows "summable f \<Longrightarrow> bounded (range f)"
  1139   shows "summable f \<Longrightarrow> bounded (range f)"
  1351 lemma infdist_pos_not_in_closed:
  1388 lemma infdist_pos_not_in_closed:
  1352   assumes "closed S" "S \<noteq> {}" "x \<notin> S"
  1389   assumes "closed S" "S \<noteq> {}" "x \<notin> S"
  1353   shows "infdist x S > 0"
  1390   shows "infdist x S > 0"
  1354 using in_closed_iff_infdist_zero[OF assms(1) assms(2), of x] assms(3) infdist_nonneg le_less by fastforce
  1391 using in_closed_iff_infdist_zero[OF assms(1) assms(2), of x] assms(3) infdist_nonneg le_less by fastforce
  1355 
  1392 
       
  1393 lemma
       
  1394   infdist_attains_inf:
       
  1395   fixes X::"'a::heine_borel set"
       
  1396   assumes "closed X"
       
  1397   assumes "X \<noteq> {}"
       
  1398   obtains x where "x \<in> X" "infdist y X = dist y x"
       
  1399 proof -
       
  1400   have "bdd_below (dist y ` X)"
       
  1401     by auto
       
  1402   from distance_attains_inf[OF assms, of y]
       
  1403   obtain x where INF: "x \<in> X" "\<And>z. z \<in> X \<Longrightarrow> dist y x \<le> dist y z" by auto
       
  1404   have "infdist y X = dist y x"
       
  1405     by (auto simp: infdist_def assms
       
  1406       intro!: antisym cINF_lower[OF _ \<open>x \<in> X\<close>] cINF_greatest[OF assms(2) INF(2)])
       
  1407   with \<open>x \<in> X\<close> show ?thesis ..
       
  1408 qed
       
  1409 
       
  1410 
  1356 text \<open>Every metric space is a T4 space:\<close>
  1411 text \<open>Every metric space is a T4 space:\<close>
  1357 
  1412 
  1358 instance metric_space \<subseteq> t4_space
  1413 instance metric_space \<subseteq> t4_space
  1359 proof
  1414 proof
  1360   fix S T::"'a set" assume H: "closed S" "closed T" "S \<inter> T = {}"
  1415   fix S T::"'a set" assume H: "closed S" "closed T" "S \<inter> T = {}"
  1420 
  1475 
  1421 lemma continuous_infdist[continuous_intros]:
  1476 lemma continuous_infdist[continuous_intros]:
  1422   assumes "continuous F f"
  1477   assumes "continuous F f"
  1423   shows "continuous F (\<lambda>x. infdist (f x) A)"
  1478   shows "continuous F (\<lambda>x. infdist (f x) A)"
  1424   using assms unfolding continuous_def by (rule tendsto_infdist)
  1479   using assms unfolding continuous_def by (rule tendsto_infdist)
       
  1480 
       
  1481 lemma compact_infdist_le:
       
  1482   fixes A::"'a::heine_borel set"
       
  1483   assumes "A \<noteq> {}"
       
  1484   assumes "compact A"
       
  1485   assumes "e > 0"
       
  1486   shows "compact {x. infdist x A \<le> e}"
       
  1487 proof -
       
  1488   from continuous_closed_vimage[of "{0..e}" "\<lambda>x. infdist x A"]
       
  1489     continuous_infdist[OF continuous_ident, of _ UNIV A]
       
  1490   have "closed {x. infdist x A \<le> e}" by (auto simp: vimage_def infdist_nonneg)
       
  1491   moreover
       
  1492   from assms obtain x0 b where b: "\<And>x. x \<in> A \<Longrightarrow> dist x0 x \<le> b" "closed A"
       
  1493     by (auto simp: compact_eq_bounded_closed bounded_def)
       
  1494   {
       
  1495     fix y
       
  1496     assume le: "infdist y A \<le> e"
       
  1497     from infdist_attains_inf[OF \<open>closed A\<close> \<open>A \<noteq> {}\<close>, of y]
       
  1498     obtain z where z: "z \<in> A" "infdist y A = dist y z" by blast
       
  1499     have "dist x0 y \<le> dist y z + dist x0 z"
       
  1500       by (metis dist_commute dist_triangle)
       
  1501     also have "dist y z \<le> e" using le z by simp
       
  1502     also have "dist x0 z \<le> b" using b z by simp
       
  1503     finally have "dist x0 y \<le> b + e" by arith
       
  1504   } then
       
  1505   have "bounded {x. infdist x A \<le> e}"
       
  1506     by (auto simp: bounded_any_center[where a=x0] intro!: exI[where x="b + e"])
       
  1507   ultimately show "compact {x. infdist x A \<le> e}"
       
  1508     by (simp add: compact_eq_bounded_closed)
       
  1509 qed
  1425 
  1510 
  1426 subsection \<open>Equality of continuous functions on closure and related results.\<close>
  1511 subsection \<open>Equality of continuous functions on closure and related results.\<close>
  1427 
  1512 
  1428 lemma continuous_closedin_preimage_constant:
  1513 lemma continuous_closedin_preimage_constant:
  1429   fixes f :: "_ \<Rightarrow> 'b::t1_space"
  1514   fixes f :: "_ \<Rightarrow> 'b::t1_space"
  2207     by force
  2292     by force
  2208   ultimately show ?thesis
  2293   ultimately show ?thesis
  2209     by (metis assms continuous_open_vimage vimage_def)
  2294     by (metis assms continuous_open_vimage vimage_def)
  2210 qed
  2295 qed
  2211 
  2296 
       
  2297 lemma open_neg_translation:
       
  2298   fixes s :: "'a::real_normed_vector set"
       
  2299   assumes "open s"
       
  2300   shows "open((\<lambda>x. a - x) ` s)"
       
  2301   using open_translation[OF open_negations[OF assms], of a]
       
  2302   by (auto simp: image_image)
       
  2303 
  2212 lemma open_affinity:
  2304 lemma open_affinity:
  2213   fixes S :: "'a::real_normed_vector set"
  2305   fixes S :: "'a::real_normed_vector set"
  2214   assumes "open S"  "c \<noteq> 0"
  2306   assumes "open S"  "c \<noteq> 0"
  2215   shows "open ((\<lambda>x. a + c *\<^sub>R x) ` S)"
  2307   shows "open ((\<lambda>x. a + c *\<^sub>R x) ` S)"
  2216 proof -
  2308 proof -
  2389 lemma continuous_on_real_range:
  2481 lemma continuous_on_real_range:
  2390   fixes f :: "'a::real_normed_vector \<Rightarrow> real"
  2482   fixes f :: "'a::real_normed_vector \<Rightarrow> real"
  2391   shows "continuous_on s f \<longleftrightarrow>
  2483   shows "continuous_on s f \<longleftrightarrow>
  2392     (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d \<longrightarrow> \<bar>f x' - f x\<bar> < e))"
  2484     (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d \<longrightarrow> \<bar>f x' - f x\<bar> < e))"
  2393   unfolding continuous_on_iff dist_norm by simp
  2485   unfolding continuous_on_iff dist_norm by simp
  2394 
       
  2395 text \<open>Hence some handy theorems on distance, diameter etc. of/from a set.\<close>
       
  2396 
       
  2397 lemma distance_attains_sup:
       
  2398   assumes "compact s" "s \<noteq> {}"
       
  2399   shows "\<exists>x\<in>s. \<forall>y\<in>s. dist a y \<le> dist a x"
       
  2400 proof (rule continuous_attains_sup [OF assms])
       
  2401   {
       
  2402     fix x
       
  2403     assume "x\<in>s"
       
  2404     have "(dist a \<longlongrightarrow> dist a x) (at x within s)"
       
  2405       by (intro tendsto_dist tendsto_const tendsto_ident_at)
       
  2406   }
       
  2407   then show "continuous_on s (dist a)"
       
  2408     unfolding continuous_on ..
       
  2409 qed
       
  2410 
       
  2411 text \<open>For \emph{minimal} distance, we only need closure, not compactness.\<close>
       
  2412 
       
  2413 lemma distance_attains_inf:
       
  2414   fixes a :: "'a::heine_borel"
       
  2415   assumes "closed s" and "s \<noteq> {}"
       
  2416   obtains x where "x\<in>s" "\<And>y. y \<in> s \<Longrightarrow> dist a x \<le> dist a y"
       
  2417 proof -
       
  2418   from assms obtain b where "b \<in> s" by auto
       
  2419   let ?B = "s \<inter> cball a (dist b a)"
       
  2420   have "?B \<noteq> {}" using \<open>b \<in> s\<close>
       
  2421     by (auto simp: dist_commute)
       
  2422   moreover have "continuous_on ?B (dist a)"
       
  2423     by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const)
       
  2424   moreover have "compact ?B"
       
  2425     by (intro closed_Int_compact \<open>closed s\<close> compact_cball)
       
  2426   ultimately obtain x where "x \<in> ?B" "\<forall>y\<in>?B. dist a x \<le> dist a y"
       
  2427     by (metis continuous_attains_inf)
       
  2428   with that show ?thesis by fastforce
       
  2429 qed
       
  2430 
  2486 
  2431 
  2487 
  2432 subsection \<open>Cartesian products\<close>
  2488 subsection \<open>Cartesian products\<close>
  2433 
  2489 
  2434 lemma bounded_Times:
  2490 lemma bounded_Times:
  2909     using assms(3) by auto
  2965     using assms(3) by auto
  2910   show ?thesis
  2966   show ?thesis
  2911     using separate_compact_closed[OF assms(2,1) *] by (force simp: dist_commute)
  2967     using separate_compact_closed[OF assms(2,1) *] by (force simp: dist_commute)
  2912 qed
  2968 qed
  2913 
  2969 
       
  2970 lemma compact_in_open_separated:
       
  2971   fixes A::"'a::heine_borel set"
       
  2972   assumes "A \<noteq> {}"
       
  2973   assumes "compact A"
       
  2974   assumes "open B"
       
  2975   assumes "A \<subseteq> B"
       
  2976   obtains e where "e > 0" "{x. infdist x A \<le> e} \<subseteq> B"
       
  2977 proof atomize_elim
       
  2978   have "closed (- B)" "compact A" "- B \<inter> A = {}"
       
  2979     using assms by (auto simp: open_Diff compact_eq_bounded_closed)
       
  2980   from separate_closed_compact[OF this]
       
  2981   obtain d'::real where d': "d'>0" "\<And>x y. x \<notin> B \<Longrightarrow> y \<in> A \<Longrightarrow> d' \<le> dist x y"
       
  2982     by auto
       
  2983   define d where "d = d' / 2"
       
  2984   hence "d>0" "d < d'" using d' by auto
       
  2985   with d' have d: "\<And>x y. x \<notin> B \<Longrightarrow> y \<in> A \<Longrightarrow> d < dist x y"
       
  2986     by force
       
  2987   show "\<exists>e>0. {x. infdist x A \<le> e} \<subseteq> B"
       
  2988   proof (rule ccontr)
       
  2989     assume "\<nexists>e. 0 < e \<and> {x. infdist x A \<le> e} \<subseteq> B"
       
  2990     with \<open>d > 0\<close> obtain x where x: "infdist x A \<le> d" "x \<notin> B"
       
  2991       by auto
       
  2992     from assms have "closed A" "A \<noteq> {}" by (auto simp: compact_eq_bounded_closed)
       
  2993     from infdist_attains_inf[OF this]
       
  2994     obtain y where y: "y \<in> A" "infdist x A = dist x y"
       
  2995       by auto
       
  2996     have "dist x y \<le> d" using x y by simp
       
  2997     also have "\<dots> < dist x y" using y d x by auto
       
  2998     finally show False by simp
       
  2999   qed
       
  3000 qed
       
  3001 
  2914 
  3002 
  2915 subsection \<open>Compact sets and the closure operation.\<close>
  3003 subsection \<open>Compact sets and the closure operation.\<close>
  2916 
  3004 
  2917 lemma closed_scaling:
  3005 lemma closed_scaling:
  2918   fixes S :: "'a::real_normed_vector set"
  3006   fixes S :: "'a::real_normed_vector set"
  4218     then show ?thesis by simp
  4306     then show ?thesis by simp
  4219   qed
  4307   qed
  4220   ultimately show ?thesis
  4308   ultimately show ?thesis
  4221     using \<open>x\<in>s\<close> by blast
  4309     using \<open>x\<in>s\<close> by blast
  4222 qed
  4310 qed
       
  4311 
       
  4312 lemma banach_fix_type:
       
  4313   fixes f::"'a::complete_space\<Rightarrow>'a"
       
  4314   assumes c:"0 \<le> c" "c < 1"
       
  4315       and lipschitz:"\<forall>x. \<forall>y. dist (f x) (f y) \<le> c * dist x y"
       
  4316   shows "\<exists>!x. (f x = x)"
       
  4317   using assms banach_fix[OF complete_UNIV UNIV_not_empty assms(1,2) subset_UNIV, of f]
       
  4318   by auto
  4223 
  4319 
  4224 
  4320 
  4225 subsection \<open>Edelstein fixed point theorem\<close>
  4321 subsection \<open>Edelstein fixed point theorem\<close>
  4226 
  4322 
  4227 theorem edelstein_fix:
  4323 theorem edelstein_fix: