tuned proofs;
authorwenzelm
Sat Sep 14 23:52:36 2013 +0200 (2013-09-14)
changeset 536403170b5eb9f5a
parent 53639 09a4954e7c07
child 53641 b19242603e92
tuned proofs;
src/HOL/Multivariate_Analysis/Path_Connected.thy
src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy
     1.1 --- a/src/HOL/Multivariate_Analysis/Path_Connected.thy	Sat Sep 14 22:50:15 2013 +0200
     1.2 +++ b/src/HOL/Multivariate_Analysis/Path_Connected.thy	Sat Sep 14 23:52:36 2013 +0200
     1.3 @@ -11,7 +11,7 @@
     1.4  subsection {* Paths. *}
     1.5  
     1.6  definition path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
     1.7 -  where "path g \<longleftrightarrow> continuous_on {0 .. 1} g"
     1.8 +  where "path g \<longleftrightarrow> continuous_on {0..1} g"
     1.9  
    1.10  definition pathstart :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a"
    1.11    where "pathstart g = g 0"
    1.12 @@ -22,10 +22,10 @@
    1.13  definition path_image :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a set"
    1.14    where "path_image g = g ` {0 .. 1}"
    1.15  
    1.16 -definition reversepath :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a)"
    1.17 +definition reversepath :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> real \<Rightarrow> 'a"
    1.18    where "reversepath g = (\<lambda>x. g(1 - x))"
    1.19  
    1.20 -definition joinpaths :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> (real \<Rightarrow> 'a)"
    1.21 +definition joinpaths :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> real \<Rightarrow> 'a"
    1.22      (infixr "+++" 75)
    1.23    where "g1 +++ g2 = (\<lambda>x. if x \<le> 1/2 then g1 (2 * x) else g2 (2 * x - 1))"
    1.24  
    1.25 @@ -40,62 +40,77 @@
    1.26  subsection {* Some lemmas about these concepts. *}
    1.27  
    1.28  lemma injective_imp_simple_path: "injective_path g \<Longrightarrow> simple_path g"
    1.29 -  unfolding injective_path_def simple_path_def by auto
    1.30 +  unfolding injective_path_def simple_path_def
    1.31 +  by auto
    1.32  
    1.33  lemma path_image_nonempty: "path_image g \<noteq> {}"
    1.34 -  unfolding path_image_def image_is_empty interval_eq_empty by auto 
    1.35 -
    1.36 -lemma pathstart_in_path_image[intro]: "(pathstart g) \<in> path_image g"
    1.37 -  unfolding pathstart_def path_image_def by auto
    1.38 +  unfolding path_image_def image_is_empty interval_eq_empty
    1.39 +  by auto
    1.40  
    1.41 -lemma pathfinish_in_path_image[intro]: "(pathfinish g) \<in> path_image g"
    1.42 -  unfolding pathfinish_def path_image_def by auto
    1.43 +lemma pathstart_in_path_image[intro]: "pathstart g \<in> path_image g"
    1.44 +  unfolding pathstart_def path_image_def
    1.45 +  by auto
    1.46  
    1.47 -lemma connected_path_image[intro]: "path g \<Longrightarrow> connected(path_image g)"
    1.48 +lemma pathfinish_in_path_image[intro]: "pathfinish g \<in> path_image g"
    1.49 +  unfolding pathfinish_def path_image_def
    1.50 +  by auto
    1.51 +
    1.52 +lemma connected_path_image[intro]: "path g \<Longrightarrow> connected (path_image g)"
    1.53    unfolding path_def path_image_def
    1.54    apply (erule connected_continuous_image)
    1.55    apply (rule convex_connected, rule convex_real_interval)
    1.56    done
    1.57  
    1.58 -lemma compact_path_image[intro]: "path g \<Longrightarrow> compact(path_image g)"
    1.59 +lemma compact_path_image[intro]: "path g \<Longrightarrow> compact (path_image g)"
    1.60    unfolding path_def path_image_def
    1.61 -  by (erule compact_continuous_image, rule compact_interval)
    1.62 +  apply (erule compact_continuous_image)
    1.63 +  apply (rule compact_interval)
    1.64 +  done
    1.65  
    1.66 -lemma reversepath_reversepath[simp]: "reversepath(reversepath g) = g"
    1.67 -  unfolding reversepath_def by auto
    1.68 +lemma reversepath_reversepath[simp]: "reversepath (reversepath g) = g"
    1.69 +  unfolding reversepath_def
    1.70 +  by auto
    1.71  
    1.72 -lemma pathstart_reversepath[simp]: "pathstart(reversepath g) = pathfinish g"
    1.73 -  unfolding pathstart_def reversepath_def pathfinish_def by auto
    1.74 +lemma pathstart_reversepath[simp]: "pathstart (reversepath g) = pathfinish g"
    1.75 +  unfolding pathstart_def reversepath_def pathfinish_def
    1.76 +  by auto
    1.77  
    1.78 -lemma pathfinish_reversepath[simp]: "pathfinish(reversepath g) = pathstart g"
    1.79 -  unfolding pathstart_def reversepath_def pathfinish_def by auto
    1.80 +lemma pathfinish_reversepath[simp]: "pathfinish (reversepath g) = pathstart g"
    1.81 +  unfolding pathstart_def reversepath_def pathfinish_def
    1.82 +  by auto
    1.83  
    1.84  lemma pathstart_join[simp]: "pathstart (g1 +++ g2) = pathstart g1"
    1.85 -  unfolding pathstart_def joinpaths_def pathfinish_def by auto
    1.86 +  unfolding pathstart_def joinpaths_def pathfinish_def
    1.87 +  by auto
    1.88  
    1.89  lemma pathfinish_join[simp]: "pathfinish (g1 +++ g2) = pathfinish g2"
    1.90 -  unfolding pathstart_def joinpaths_def pathfinish_def by auto
    1.91 +  unfolding pathstart_def joinpaths_def pathfinish_def
    1.92 +  by auto
    1.93  
    1.94 -lemma path_image_reversepath[simp]: "path_image(reversepath g) = path_image g"
    1.95 +lemma path_image_reversepath[simp]: "path_image (reversepath g) = path_image g"
    1.96  proof -
    1.97 -  have *: "\<And>g. path_image(reversepath g) \<subseteq> path_image g"
    1.98 +  have *: "\<And>g. path_image (reversepath g) \<subseteq> path_image g"
    1.99      unfolding path_image_def subset_eq reversepath_def Ball_def image_iff
   1.100 -    apply(rule,rule,erule bexE)
   1.101 -    apply(rule_tac x="1 - xa" in bexI)
   1.102 +    apply rule
   1.103 +    apply rule
   1.104 +    apply (erule bexE)
   1.105 +    apply (rule_tac x="1 - xa" in bexI)
   1.106      apply auto
   1.107      done
   1.108    show ?thesis
   1.109      using *[of g] *[of "reversepath g"]
   1.110 -    unfolding reversepath_reversepath by auto
   1.111 +    unfolding reversepath_reversepath
   1.112 +    by auto
   1.113  qed
   1.114  
   1.115 -lemma path_reversepath[simp]: "path (reversepath g) \<longleftrightarrow> path g"
   1.116 +lemma path_reversepath [simp]: "path (reversepath g) \<longleftrightarrow> path g"
   1.117  proof -
   1.118    have *: "\<And>g. path g \<Longrightarrow> path (reversepath g)"
   1.119      unfolding path_def reversepath_def
   1.120      apply (rule continuous_on_compose[unfolded o_def, of _ "\<lambda>x. 1 - x"])
   1.121      apply (intro continuous_on_intros)
   1.122 -    apply (rule continuous_on_subset[of "{0..1}"], assumption)
   1.123 +    apply (rule continuous_on_subset[of "{0..1}"])
   1.124 +    apply assumption
   1.125      apply auto
   1.126      done
   1.127    show ?thesis
   1.128 @@ -116,43 +131,59 @@
   1.129    have g1: "continuous_on {0..1} g1 \<longleftrightarrow> continuous_on {0..1} ((g1 +++ g2) \<circ> (\<lambda>x. x / 2))"
   1.130      by (intro continuous_on_cong refl) (auto simp: joinpaths_def)
   1.131    have g2: "continuous_on {0..1} g2 \<longleftrightarrow> continuous_on {0..1} ((g1 +++ g2) \<circ> (\<lambda>x. x / 2 + 1/2))"
   1.132 -    using assms by (intro continuous_on_cong refl) (auto simp: joinpaths_def pathfinish_def pathstart_def)
   1.133 -  show "continuous_on {0..1} g1" "continuous_on {0..1} g2"
   1.134 +    using assms
   1.135 +    by (intro continuous_on_cong refl) (auto simp: joinpaths_def pathfinish_def pathstart_def)
   1.136 +  show "continuous_on {0..1} g1" and "continuous_on {0..1} g2"
   1.137      unfolding g1 g2
   1.138      by (auto intro!: continuous_on_intros continuous_on_subset[OF cont] simp del: o_apply)
   1.139  next
   1.140    assume g1g2: "continuous_on {0..1} g1" "continuous_on {0..1} g2"
   1.141    have 01: "{0 .. 1} = {0..1/2} \<union> {1/2 .. 1::real}"
   1.142      by auto
   1.143 -  { fix x :: real assume "0 \<le> x" "x \<le> 1" then have "x \<in> (\<lambda>x. x * 2) ` {0..1 / 2}"
   1.144 -      by (intro image_eqI[where x="x/2"]) auto }
   1.145 +  {
   1.146 +    fix x :: real
   1.147 +    assume "0 \<le> x" and "x \<le> 1"
   1.148 +    then have "x \<in> (\<lambda>x. x * 2) ` {0..1 / 2}"
   1.149 +      by (intro image_eqI[where x="x/2"]) auto
   1.150 +  }
   1.151    note 1 = this
   1.152 -  { fix x :: real assume "0 \<le> x" "x \<le> 1" then have "x \<in> (\<lambda>x. x * 2 - 1) ` {1 / 2..1}"
   1.153 -      by (intro image_eqI[where x="x/2 + 1/2"]) auto }
   1.154 +  {
   1.155 +    fix x :: real
   1.156 +    assume "0 \<le> x" and "x \<le> 1"
   1.157 +    then have "x \<in> (\<lambda>x. x * 2 - 1) ` {1 / 2..1}"
   1.158 +      by (intro image_eqI[where x="x/2 + 1/2"]) auto
   1.159 +  }
   1.160    note 2 = this
   1.161    show "continuous_on {0..1} (g1 +++ g2)"
   1.162 -    using assms unfolding joinpaths_def 01
   1.163 -    by (intro continuous_on_cases closed_atLeastAtMost g1g2[THEN continuous_on_compose2] continuous_on_intros)
   1.164 -       (auto simp: field_simps pathfinish_def pathstart_def intro!: 1 2)
   1.165 +    using assms
   1.166 +    unfolding joinpaths_def 01
   1.167 +    apply (intro continuous_on_cases closed_atLeastAtMost g1g2[THEN continuous_on_compose2] continuous_on_intros)
   1.168 +    apply (auto simp: field_simps pathfinish_def pathstart_def intro!: 1 2)
   1.169 +    done
   1.170  qed
   1.171  
   1.172 -lemma path_image_join_subset: "path_image(g1 +++ g2) \<subseteq> (path_image g1 \<union> path_image g2)"
   1.173 -  unfolding path_image_def joinpaths_def by auto
   1.174 +lemma path_image_join_subset: "path_image (g1 +++ g2) \<subseteq> path_image g1 \<union> path_image g2"
   1.175 +  unfolding path_image_def joinpaths_def
   1.176 +  by auto
   1.177  
   1.178  lemma subset_path_image_join:
   1.179 -  assumes "path_image g1 \<subseteq> s" "path_image g2 \<subseteq> s"
   1.180 -  shows "path_image(g1 +++ g2) \<subseteq> s"
   1.181 -  using path_image_join_subset[of g1 g2] and assms by auto
   1.182 +  assumes "path_image g1 \<subseteq> s"
   1.183 +    and "path_image g2 \<subseteq> s"
   1.184 +  shows "path_image (g1 +++ g2) \<subseteq> s"
   1.185 +  using path_image_join_subset[of g1 g2] and assms
   1.186 +  by auto
   1.187  
   1.188  lemma path_image_join:
   1.189    assumes "pathfinish g1 = pathstart g2"
   1.190 -  shows "path_image(g1 +++ g2) = (path_image g1) \<union> (path_image g2)"
   1.191 -  apply (rule, rule path_image_join_subset, rule)
   1.192 +  shows "path_image (g1 +++ g2) = path_image g1 \<union> path_image g2"
   1.193 +  apply rule
   1.194 +  apply (rule path_image_join_subset)
   1.195 +  apply rule
   1.196    unfolding Un_iff
   1.197  proof (erule disjE)
   1.198    fix x
   1.199    assume "x \<in> path_image g1"
   1.200 -  then obtain y where y: "y\<in>{0..1}" "x = g1 y"
   1.201 +  then obtain y where y: "y \<in> {0..1}" "x = g1 y"
   1.202      unfolding path_image_def image_iff by auto
   1.203    then show "x \<in> path_image (g1 +++ g2)"
   1.204      unfolding joinpaths_def path_image_def image_iff
   1.205 @@ -162,20 +193,22 @@
   1.206  next
   1.207    fix x
   1.208    assume "x \<in> path_image g2"
   1.209 -  then obtain y where y: "y\<in>{0..1}" "x = g2 y"
   1.210 +  then obtain y where y: "y \<in> {0..1}" "x = g2 y"
   1.211      unfolding path_image_def image_iff by auto
   1.212    then show "x \<in> path_image (g1 +++ g2)"
   1.213      unfolding joinpaths_def path_image_def image_iff
   1.214 -    apply(rule_tac x="(1/2) *\<^sub>R (y + 1)" in bexI)
   1.215 +    apply (rule_tac x="(1/2) *\<^sub>R (y + 1)" in bexI)
   1.216      using assms(1)[unfolded pathfinish_def pathstart_def]
   1.217 -    apply (auto simp add: add_divide_distrib) 
   1.218 +    apply (auto simp add: add_divide_distrib)
   1.219      done
   1.220  qed
   1.221  
   1.222  lemma not_in_path_image_join:
   1.223 -  assumes "x \<notin> path_image g1" "x \<notin> path_image g2"
   1.224 -  shows "x \<notin> path_image(g1 +++ g2)"
   1.225 -  using assms and path_image_join_subset[of g1 g2] by auto
   1.226 +  assumes "x \<notin> path_image g1"
   1.227 +    and "x \<notin> path_image g2"
   1.228 +  shows "x \<notin> path_image (g1 +++ g2)"
   1.229 +  using assms and path_image_join_subset[of g1 g2]
   1.230 +  by auto
   1.231  
   1.232  lemma simple_path_reversepath:
   1.233    assumes "simple_path g"
   1.234 @@ -184,82 +217,111 @@
   1.235    unfolding simple_path_def reversepath_def
   1.236    apply -
   1.237    apply (rule ballI)+
   1.238 -  apply (erule_tac x="1-x" in ballE, erule_tac x="1-y" in ballE)
   1.239 +  apply (erule_tac x="1-x" in ballE)
   1.240 +  apply (erule_tac x="1-y" in ballE)
   1.241    apply auto
   1.242    done
   1.243  
   1.244  lemma simple_path_join_loop:
   1.245 -  assumes "injective_path g1" "injective_path g2" "pathfinish g2 = pathstart g1"
   1.246 -    "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g1,pathstart g2}"
   1.247 -  shows "simple_path(g1 +++ g2)"
   1.248 +  assumes "injective_path g1"
   1.249 +    and "injective_path g2"
   1.250 +    and "pathfinish g2 = pathstart g1"
   1.251 +    and "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g1, pathstart g2}"
   1.252 +  shows "simple_path (g1 +++ g2)"
   1.253    unfolding simple_path_def
   1.254 -proof ((rule ballI)+, rule impI)
   1.255 +proof (intro ballI impI)
   1.256    let ?g = "g1 +++ g2"
   1.257    note inj = assms(1,2)[unfolded injective_path_def, rule_format]
   1.258    fix x y :: real
   1.259    assume xy: "x \<in> {0..1}" "y \<in> {0..1}" "?g x = ?g y"
   1.260    show "x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0"
   1.261 -  proof (case_tac "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
   1.262 +  proof (cases "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
   1.263      assume as: "x \<le> 1 / 2" "y \<le> 1 / 2"
   1.264      then have "g1 (2 *\<^sub>R x) = g1 (2 *\<^sub>R y)"
   1.265 -      using xy(3) unfolding joinpaths_def by auto
   1.266 -    moreover
   1.267 -    have "2 *\<^sub>R x \<in> {0..1}" "2 *\<^sub>R y \<in> {0..1}" using xy(1,2) as
   1.268 +      using xy(3)
   1.269 +      unfolding joinpaths_def
   1.270 +      by auto
   1.271 +    moreover have "2 *\<^sub>R x \<in> {0..1}" "2 *\<^sub>R y \<in> {0..1}"
   1.272 +      using xy(1,2) as
   1.273        by auto
   1.274 -    ultimately
   1.275 -    show ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] by auto
   1.276 +    ultimately show ?thesis
   1.277 +      using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"]
   1.278 +      by auto
   1.279    next
   1.280 -    assume as:"x > 1 / 2" "y > 1 / 2"
   1.281 +    assume as: "x > 1 / 2" "y > 1 / 2"
   1.282      then have "g2 (2 *\<^sub>R x - 1) = g2 (2 *\<^sub>R y - 1)"
   1.283 -      using xy(3) unfolding joinpaths_def by auto
   1.284 -    moreover
   1.285 -    have "2 *\<^sub>R x - 1 \<in> {0..1}" "2 *\<^sub>R y - 1 \<in> {0..1}"
   1.286 -      using xy(1,2) as by auto
   1.287 -    ultimately
   1.288 -    show ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] by auto
   1.289 +      using xy(3)
   1.290 +      unfolding joinpaths_def
   1.291 +      by auto
   1.292 +    moreover have "2 *\<^sub>R x - 1 \<in> {0..1}" "2 *\<^sub>R y - 1 \<in> {0..1}"
   1.293 +      using xy(1,2) as
   1.294 +      by auto
   1.295 +    ultimately show ?thesis
   1.296 +      using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] by auto
   1.297    next
   1.298 -    assume as:"x \<le> 1 / 2" "y > 1 / 2"
   1.299 +    assume as: "x \<le> 1 / 2" "y > 1 / 2"
   1.300      then have "?g x \<in> path_image g1" "?g y \<in> path_image g2"
   1.301        unfolding path_image_def joinpaths_def
   1.302        using xy(1,2) by auto
   1.303 -    moreover
   1.304 -      have "?g y \<noteq> pathstart g2" using as(2) unfolding pathstart_def joinpaths_def
   1.305 +    moreover have "?g y \<noteq> pathstart g2"
   1.306 +      using as(2)
   1.307 +      unfolding pathstart_def joinpaths_def
   1.308        using inj(2)[of "2 *\<^sub>R y - 1" 0] and xy(2)
   1.309        by (auto simp add: field_simps)
   1.310 -    ultimately
   1.311 -    have *:"?g x = pathstart g1" using assms(4) unfolding xy(3) by auto
   1.312 -    then have "x = 0" unfolding pathstart_def joinpaths_def using as(1) and xy(1)
   1.313 -      using inj(1)[of "2 *\<^sub>R x" 0] by auto
   1.314 -    moreover
   1.315 -    have "y = 1" using * unfolding xy(3) assms(3)[THEN sym]
   1.316 -      unfolding joinpaths_def pathfinish_def using as(2) and xy(2)
   1.317 -      using inj(2)[of "2 *\<^sub>R y - 1" 1] by auto
   1.318 -    ultimately show ?thesis by auto
   1.319 +    ultimately have *: "?g x = pathstart g1"
   1.320 +      using assms(4)
   1.321 +      unfolding xy(3)
   1.322 +      by auto
   1.323 +    then have "x = 0"
   1.324 +      unfolding pathstart_def joinpaths_def
   1.325 +      using as(1) and xy(1)
   1.326 +      using inj(1)[of "2 *\<^sub>R x" 0]
   1.327 +      by auto
   1.328 +    moreover have "y = 1"
   1.329 +      using *
   1.330 +      unfolding xy(3) assms(3)[symmetric]
   1.331 +      unfolding joinpaths_def pathfinish_def
   1.332 +      using as(2) and xy(2)
   1.333 +      using inj(2)[of "2 *\<^sub>R y - 1" 1]
   1.334 +      by auto
   1.335 +    ultimately show ?thesis
   1.336 +      by auto
   1.337    next
   1.338      assume as: "x > 1 / 2" "y \<le> 1 / 2"
   1.339 -    then have "?g x \<in> path_image g2" "?g y \<in> path_image g1"
   1.340 +    then have "?g x \<in> path_image g2" and "?g y \<in> path_image g1"
   1.341        unfolding path_image_def joinpaths_def
   1.342        using xy(1,2) by auto
   1.343 -    moreover
   1.344 -      have "?g x \<noteq> pathstart g2" using as(1) unfolding pathstart_def joinpaths_def
   1.345 +    moreover have "?g x \<noteq> pathstart g2"
   1.346 +      using as(1)
   1.347 +      unfolding pathstart_def joinpaths_def
   1.348        using inj(2)[of "2 *\<^sub>R x - 1" 0] and xy(1)
   1.349        by (auto simp add: field_simps)
   1.350 -    ultimately
   1.351 -    have *: "?g y = pathstart g1" using assms(4) unfolding xy(3) by auto
   1.352 -    then have "y = 0" unfolding pathstart_def joinpaths_def using as(2) and xy(2)
   1.353 -      using inj(1)[of "2 *\<^sub>R y" 0] by auto
   1.354 -    moreover
   1.355 -    have "x = 1" using * unfolding xy(3)[THEN sym] assms(3)[THEN sym]
   1.356 +    ultimately have *: "?g y = pathstart g1"
   1.357 +      using assms(4)
   1.358 +      unfolding xy(3)
   1.359 +      by auto
   1.360 +    then have "y = 0"
   1.361 +      unfolding pathstart_def joinpaths_def
   1.362 +      using as(2) and xy(2)
   1.363 +      using inj(1)[of "2 *\<^sub>R y" 0]
   1.364 +      by auto
   1.365 +    moreover have "x = 1"
   1.366 +      using *
   1.367 +      unfolding xy(3)[symmetric] assms(3)[symmetric]
   1.368        unfolding joinpaths_def pathfinish_def using as(1) and xy(1)
   1.369 -      using inj(2)[of "2 *\<^sub>R x - 1" 1] by auto
   1.370 -    ultimately show ?thesis by auto
   1.371 +      using inj(2)[of "2 *\<^sub>R x - 1" 1]
   1.372 +      by auto
   1.373 +    ultimately show ?thesis
   1.374 +      by auto
   1.375    qed
   1.376  qed
   1.377  
   1.378  lemma injective_path_join:
   1.379 -  assumes "injective_path g1" "injective_path g2" "pathfinish g1 = pathstart g2"
   1.380 -    "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g2}"
   1.381 -  shows "injective_path(g1 +++ g2)"
   1.382 +  assumes "injective_path g1"
   1.383 +    and "injective_path g2"
   1.384 +    and "pathfinish g1 = pathstart g2"
   1.385 +    and "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g2}"
   1.386 +  shows "injective_path (g1 +++ g2)"
   1.387    unfolding injective_path_def
   1.388  proof (rule, rule, rule)
   1.389    let ?g = "g1 +++ g2"
   1.390 @@ -268,31 +330,39 @@
   1.391    assume xy: "x \<in> {0..1}" "y \<in> {0..1}" "(g1 +++ g2) x = (g1 +++ g2) y"
   1.392    show "x = y"
   1.393    proof (cases "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
   1.394 -    assume "x \<le> 1 / 2" "y \<le> 1 / 2"
   1.395 -    then show ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] and xy
   1.396 +    assume "x \<le> 1 / 2" and "y \<le> 1 / 2"
   1.397 +    then show ?thesis
   1.398 +      using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] and xy
   1.399        unfolding joinpaths_def by auto
   1.400    next
   1.401 -    assume "x > 1 / 2" "y > 1 / 2"
   1.402 -    then show ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] and xy
   1.403 +    assume "x > 1 / 2" and "y > 1 / 2"
   1.404 +    then show ?thesis
   1.405 +      using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] and xy
   1.406        unfolding joinpaths_def by auto
   1.407    next
   1.408      assume as: "x \<le> 1 / 2" "y > 1 / 2"
   1.409 -    then have "?g x \<in> path_image g1" "?g y \<in> path_image g2"
   1.410 +    then have "?g x \<in> path_image g1" and "?g y \<in> path_image g2"
   1.411        unfolding path_image_def joinpaths_def
   1.412 -      using xy(1,2) by auto
   1.413 -    then have "?g x = pathfinish g1" "?g y = pathstart g2"
   1.414 -      using assms(4) unfolding assms(3) xy(3) by auto
   1.415 +      using xy(1,2)
   1.416 +      by auto
   1.417 +    then have "?g x = pathfinish g1" and "?g y = pathstart g2"
   1.418 +      using assms(4)
   1.419 +      unfolding assms(3) xy(3)
   1.420 +      by auto
   1.421      then show ?thesis
   1.422        using as and inj(1)[of "2 *\<^sub>R x" 1] inj(2)[of "2 *\<^sub>R y - 1" 0] and xy(1,2)
   1.423        unfolding pathstart_def pathfinish_def joinpaths_def
   1.424        by auto
   1.425    next
   1.426 -    assume as:"x > 1 / 2" "y \<le> 1 / 2" 
   1.427 -    then have "?g x \<in> path_image g2" "?g y \<in> path_image g1"
   1.428 +    assume as:"x > 1 / 2" "y \<le> 1 / 2"
   1.429 +    then have "?g x \<in> path_image g2" and "?g y \<in> path_image g1"
   1.430        unfolding path_image_def joinpaths_def
   1.431 -      using xy(1,2) by auto
   1.432 -    then have "?g x = pathstart g2" "?g y = pathfinish g1"
   1.433 -      using assms(4) unfolding assms(3) xy(3) by auto
   1.434 +      using xy(1,2)
   1.435 +      by auto
   1.436 +    then have "?g x = pathstart g2" and "?g y = pathfinish g1"
   1.437 +      using assms(4)
   1.438 +      unfolding assms(3) xy(3)
   1.439 +      by auto
   1.440      then show ?thesis using as and inj(2)[of "2 *\<^sub>R x - 1" 0] inj(1)[of "2 *\<^sub>R y" 1] and xy(1,2)
   1.441        unfolding pathstart_def pathfinish_def joinpaths_def
   1.442        by auto
   1.443 @@ -300,64 +370,85 @@
   1.444  qed
   1.445  
   1.446  lemmas join_paths_simps = path_join path_image_join pathstart_join pathfinish_join
   1.447 - 
   1.448 +
   1.449  
   1.450 -subsection {* Reparametrizing a closed curve to start at some chosen point. *}
   1.451 +subsection {* Reparametrizing a closed curve to start at some chosen point *}
   1.452  
   1.453 -definition "shiftpath a (f::real \<Rightarrow> 'a::topological_space) =
   1.454 -  (\<lambda>x. if (a + x) \<le> 1 then f(a + x) else f(a + x - 1))"
   1.455 +definition shiftpath :: "real \<Rightarrow> (real \<Rightarrow> 'a::topological_space) \<Rightarrow> real \<Rightarrow> 'a"
   1.456 +  where "shiftpath a f = (\<lambda>x. if (a + x) \<le> 1 then f (a + x) else f (a + x - 1))"
   1.457  
   1.458 -lemma pathstart_shiftpath: "a \<le> 1 \<Longrightarrow> pathstart(shiftpath a g) = g a"
   1.459 +lemma pathstart_shiftpath: "a \<le> 1 \<Longrightarrow> pathstart (shiftpath a g) = g a"
   1.460    unfolding pathstart_def shiftpath_def by auto
   1.461  
   1.462  lemma pathfinish_shiftpath:
   1.463 -  assumes "0 \<le> a" "pathfinish g = pathstart g"
   1.464 -  shows "pathfinish(shiftpath a g) = g a"
   1.465 -  using assms unfolding pathstart_def pathfinish_def shiftpath_def
   1.466 +  assumes "0 \<le> a"
   1.467 +    and "pathfinish g = pathstart g"
   1.468 +  shows "pathfinish (shiftpath a g) = g a"
   1.469 +  using assms
   1.470 +  unfolding pathstart_def pathfinish_def shiftpath_def
   1.471    by auto
   1.472  
   1.473  lemma endpoints_shiftpath:
   1.474 -  assumes "pathfinish g = pathstart g" "a \<in> {0 .. 1}" 
   1.475 -  shows "pathfinish(shiftpath a g) = g a" "pathstart(shiftpath a g) = g a"
   1.476 -  using assms by(auto intro!:pathfinish_shiftpath pathstart_shiftpath)
   1.477 +  assumes "pathfinish g = pathstart g"
   1.478 +    and "a \<in> {0 .. 1}"
   1.479 +  shows "pathfinish (shiftpath a g) = g a"
   1.480 +    and "pathstart (shiftpath a g) = g a"
   1.481 +  using assms
   1.482 +  by (auto intro!: pathfinish_shiftpath pathstart_shiftpath)
   1.483  
   1.484  lemma closed_shiftpath:
   1.485 -  assumes "pathfinish g = pathstart g" "a \<in> {0..1}"
   1.486 -  shows "pathfinish(shiftpath a g) = pathstart(shiftpath a g)"
   1.487 -  using endpoints_shiftpath[OF assms] by auto
   1.488 +  assumes "pathfinish g = pathstart g"
   1.489 +    and "a \<in> {0..1}"
   1.490 +  shows "pathfinish (shiftpath a g) = pathstart (shiftpath a g)"
   1.491 +  using endpoints_shiftpath[OF assms]
   1.492 +  by auto
   1.493  
   1.494  lemma path_shiftpath:
   1.495 -  assumes "path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
   1.496 -  shows "path(shiftpath a g)"
   1.497 +  assumes "path g"
   1.498 +    and "pathfinish g = pathstart g"
   1.499 +    and "a \<in> {0..1}"
   1.500 +  shows "path (shiftpath a g)"
   1.501  proof -
   1.502 -  have *: "{0 .. 1} = {0 .. 1-a} \<union> {1-a .. 1}" using assms(3) by auto
   1.503 +  have *: "{0 .. 1} = {0 .. 1-a} \<union> {1-a .. 1}"
   1.504 +    using assms(3) by auto
   1.505    have **: "\<And>x. x + a = 1 \<Longrightarrow> g (x + a - 1) = g (x + a)"
   1.506 -    using assms(2)[unfolded pathfinish_def pathstart_def] by auto
   1.507 +    using assms(2)[unfolded pathfinish_def pathstart_def]
   1.508 +    by auto
   1.509    show ?thesis
   1.510      unfolding path_def shiftpath_def *
   1.511      apply (rule continuous_on_union)
   1.512      apply (rule closed_real_atLeastAtMost)+
   1.513 -    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a + x)"]) prefer 3
   1.514 -    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a - 1 + x)"]) defer prefer 3
   1.515 -    apply (rule continuous_on_intros)+ prefer 2
   1.516 +    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a + x)"])
   1.517 +    prefer 3
   1.518 +    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a - 1 + x)"])
   1.519 +    defer
   1.520 +    prefer 3
   1.521 +    apply (rule continuous_on_intros)+
   1.522 +    prefer 2
   1.523      apply (rule continuous_on_intros)+
   1.524      apply (rule_tac[1-2] continuous_on_subset[OF assms(1)[unfolded path_def]])
   1.525      using assms(3) and **
   1.526 -    apply (auto, auto simp add: field_simps)
   1.527 +    apply auto
   1.528 +    apply (auto simp add: field_simps)
   1.529      done
   1.530  qed
   1.531  
   1.532  lemma shiftpath_shiftpath:
   1.533 -  assumes "pathfinish g = pathstart g" "a \<in> {0..1}" "x \<in> {0..1}" 
   1.534 +  assumes "pathfinish g = pathstart g"
   1.535 +    and "a \<in> {0..1}"
   1.536 +    and "x \<in> {0..1}"
   1.537    shows "shiftpath (1 - a) (shiftpath a g) x = g x"
   1.538 -  using assms unfolding pathfinish_def pathstart_def shiftpath_def by auto
   1.539 +  using assms
   1.540 +  unfolding pathfinish_def pathstart_def shiftpath_def
   1.541 +  by auto
   1.542  
   1.543  lemma path_image_shiftpath:
   1.544 -  assumes "a \<in> {0..1}" "pathfinish g = pathstart g"
   1.545 -  shows "path_image(shiftpath a g) = path_image g"
   1.546 +  assumes "a \<in> {0..1}"
   1.547 +    and "pathfinish g = pathstart g"
   1.548 +  shows "path_image (shiftpath a g) = path_image g"
   1.549  proof -
   1.550    { fix x
   1.551 -    assume as:"g 1 = g 0" "x \<in> {0..1::real}" " \<forall>y\<in>{0..1} \<inter> {x. \<not> a + x \<le> 1}. g x \<noteq> g (a + y - 1)" 
   1.552 +    assume as: "g 1 = g 0" "x \<in> {0..1::real}" " \<forall>y\<in>{0..1} \<inter> {x. \<not> a + x \<le> 1}. g x \<noteq> g (a + y - 1)"
   1.553      then have "\<exists>y\<in>{0..1} \<inter> {x. a + x \<le> 1}. g x = g (a + y)"
   1.554      proof (cases "a \<le> x")
   1.555        case False
   1.556 @@ -368,46 +459,57 @@
   1.557          done
   1.558      next
   1.559        case True
   1.560 -      then show ?thesis using as(1-2) and assms(1) apply(rule_tac x="x - a" in bexI)
   1.561 -        by(auto simp add: field_simps)
   1.562 +      then show ?thesis
   1.563 +        using as(1-2) and assms(1)
   1.564 +        apply (rule_tac x="x - a" in bexI)
   1.565 +        apply (auto simp add: field_simps)
   1.566 +        done
   1.567      qed
   1.568    }
   1.569    then show ?thesis
   1.570 -    using assms unfolding shiftpath_def path_image_def pathfinish_def pathstart_def
   1.571 -    by(auto simp add: image_iff)
   1.572 +    using assms
   1.573 +    unfolding shiftpath_def path_image_def pathfinish_def pathstart_def
   1.574 +    by (auto simp add: image_iff)
   1.575  qed
   1.576  
   1.577  
   1.578 -subsection {* Special case of straight-line paths. *}
   1.579 +subsection {* Special case of straight-line paths *}
   1.580  
   1.581  definition linepath :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> real \<Rightarrow> 'a"
   1.582    where "linepath a b = (\<lambda>x. (1 - x) *\<^sub>R a + x *\<^sub>R b)"
   1.583  
   1.584 -lemma pathstart_linepath[simp]: "pathstart(linepath a b) = a"
   1.585 -  unfolding pathstart_def linepath_def by auto
   1.586 +lemma pathstart_linepath[simp]: "pathstart (linepath a b) = a"
   1.587 +  unfolding pathstart_def linepath_def
   1.588 +  by auto
   1.589  
   1.590 -lemma pathfinish_linepath[simp]: "pathfinish(linepath a b) = b"
   1.591 -  unfolding pathfinish_def linepath_def by auto
   1.592 +lemma pathfinish_linepath[simp]: "pathfinish (linepath a b) = b"
   1.593 +  unfolding pathfinish_def linepath_def
   1.594 +  by auto
   1.595  
   1.596  lemma continuous_linepath_at[intro]: "continuous (at x) (linepath a b)"
   1.597 -  unfolding linepath_def by (intro continuous_intros)
   1.598 +  unfolding linepath_def
   1.599 +  by (intro continuous_intros)
   1.600  
   1.601  lemma continuous_on_linepath[intro]: "continuous_on s (linepath a b)"
   1.602 -  using continuous_linepath_at by(auto intro!: continuous_at_imp_continuous_on)
   1.603 +  using continuous_linepath_at
   1.604 +  by (auto intro!: continuous_at_imp_continuous_on)
   1.605  
   1.606 -lemma path_linepath[intro]: "path(linepath a b)"
   1.607 -  unfolding path_def by(rule continuous_on_linepath)
   1.608 +lemma path_linepath[intro]: "path (linepath a b)"
   1.609 +  unfolding path_def
   1.610 +  by (rule continuous_on_linepath)
   1.611  
   1.612 -lemma path_image_linepath[simp]: "path_image(linepath a b) = (closed_segment a b)"
   1.613 +lemma path_image_linepath[simp]: "path_image (linepath a b) = closed_segment a b"
   1.614    unfolding path_image_def segment linepath_def
   1.615 -  apply (rule set_eqI, rule) defer
   1.616 +  apply (rule set_eqI)
   1.617 +  apply rule
   1.618 +  defer
   1.619    unfolding mem_Collect_eq image_iff
   1.620 -  apply(erule exE)
   1.621 -  apply(rule_tac x="u *\<^sub>R 1" in bexI)
   1.622 +  apply (erule exE)
   1.623 +  apply (rule_tac x="u *\<^sub>R 1" in bexI)
   1.624    apply auto
   1.625    done
   1.626  
   1.627 -lemma reversepath_linepath[simp]: "reversepath(linepath a b) = linepath b a"
   1.628 +lemma reversepath_linepath[simp]: "reversepath (linepath a b) = linepath b a"
   1.629    unfolding reversepath_def linepath_def
   1.630    by auto
   1.631  
   1.632 @@ -415,25 +517,30 @@
   1.633    assumes "a \<noteq> b"
   1.634    shows "injective_path (linepath a b)"
   1.635  proof -
   1.636 -  { fix x y :: "real"
   1.637 +  {
   1.638 +    fix x y :: "real"
   1.639      assume "x *\<^sub>R b + y *\<^sub>R a = x *\<^sub>R a + y *\<^sub>R b"
   1.640 -    then have "(x - y) *\<^sub>R a = (x - y) *\<^sub>R b" by (simp add: algebra_simps)
   1.641 -    with assms have "x = y" by simp }
   1.642 +    then have "(x - y) *\<^sub>R a = (x - y) *\<^sub>R b"
   1.643 +      by (simp add: algebra_simps)
   1.644 +    with assms have "x = y"
   1.645 +      by simp
   1.646 +  }
   1.647    then show ?thesis
   1.648      unfolding injective_path_def linepath_def
   1.649      by (auto simp add: algebra_simps)
   1.650  qed
   1.651  
   1.652 -lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path(linepath a b)"
   1.653 -  by(auto intro!: injective_imp_simple_path injective_path_linepath)
   1.654 +lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path (linepath a b)"
   1.655 +  by (auto intro!: injective_imp_simple_path injective_path_linepath)
   1.656  
   1.657  
   1.658 -subsection {* Bounding a point away from a path. *}
   1.659 +subsection {* Bounding a point away from a path *}
   1.660  
   1.661  lemma not_on_path_ball:
   1.662    fixes g :: "real \<Rightarrow> 'a::heine_borel"
   1.663 -  assumes "path g" "z \<notin> path_image g"
   1.664 -  shows "\<exists>e > 0. ball z e \<inter> (path_image g) = {}"
   1.665 +  assumes "path g"
   1.666 +    and "z \<notin> path_image g"
   1.667 +  shows "\<exists>e > 0. ball z e \<inter> path_image g = {}"
   1.668  proof -
   1.669    obtain a where "a \<in> path_image g" "\<forall>y \<in> path_image g. dist z a \<le> dist z y"
   1.670      using distance_attains_inf[OF _ path_image_nonempty, of g z]
   1.671 @@ -447,34 +554,43 @@
   1.672  
   1.673  lemma not_on_path_cball:
   1.674    fixes g :: "real \<Rightarrow> 'a::heine_borel"
   1.675 -  assumes "path g" "z \<notin> path_image g"
   1.676 +  assumes "path g"
   1.677 +    and "z \<notin> path_image g"
   1.678    shows "\<exists>e>0. cball z e \<inter> (path_image g) = {}"
   1.679  proof -
   1.680 -  obtain e where "ball z e \<inter> path_image g = {}" "e>0"
   1.681 +  obtain e where "ball z e \<inter> path_image g = {}" "e > 0"
   1.682      using not_on_path_ball[OF assms] by auto
   1.683 -  moreover have "cball z (e/2) \<subseteq> ball z e" using `e>0` by auto
   1.684 -  ultimately show ?thesis apply(rule_tac x="e/2" in exI) by auto
   1.685 +  moreover have "cball z (e/2) \<subseteq> ball z e"
   1.686 +    using `e > 0` by auto
   1.687 +  ultimately show ?thesis
   1.688 +    apply (rule_tac x="e/2" in exI)
   1.689 +    apply auto
   1.690 +    done
   1.691  qed
   1.692  
   1.693  
   1.694 -subsection {* Path component, considered as a "joinability" relation (from Tom Hales). *}
   1.695 +subsection {* Path component, considered as a "joinability" relation (from Tom Hales) *}
   1.696  
   1.697  definition "path_component s x y \<longleftrightarrow>
   1.698    (\<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)"
   1.699  
   1.700 -lemmas path_defs = path_def pathstart_def pathfinish_def path_image_def path_component_def 
   1.701 +lemmas path_defs = path_def pathstart_def pathfinish_def path_image_def path_component_def
   1.702  
   1.703  lemma path_component_mem:
   1.704    assumes "path_component s x y"
   1.705 -  shows "x \<in> s" "y \<in> s"
   1.706 -  using assms unfolding path_defs by auto
   1.707 +  shows "x \<in> s" and "y \<in> s"
   1.708 +  using assms
   1.709 +  unfolding path_defs
   1.710 +  by auto
   1.711  
   1.712  lemma path_component_refl:
   1.713    assumes "x \<in> s"
   1.714    shows "path_component s x x"
   1.715    unfolding path_defs
   1.716    apply (rule_tac x="\<lambda>u. x" in exI)
   1.717 -  using assms apply (auto intro!:continuous_on_intros) done
   1.718 +  using assms
   1.719 +  apply (auto intro!: continuous_on_intros)
   1.720 +  done
   1.721  
   1.722  lemma path_component_refl_eq: "path_component s x x \<longleftrightarrow> x \<in> s"
   1.723    by (auto intro!: path_component_mem path_component_refl)
   1.724 @@ -488,21 +604,21 @@
   1.725    done
   1.726  
   1.727  lemma path_component_trans:
   1.728 -  assumes "path_component s x y" "path_component s y z"
   1.729 +  assumes "path_component s x y"
   1.730 +    and "path_component s y z"
   1.731    shows "path_component s x z"
   1.732    using assms
   1.733    unfolding path_component_def
   1.734 -  apply -
   1.735 -  apply (erule exE)+
   1.736 +  apply (elim exE)
   1.737    apply (rule_tac x="g +++ ga" in exI)
   1.738    apply (auto simp add: path_image_join)
   1.739    done
   1.740  
   1.741 -lemma path_component_of_subset: "s \<subseteq> t \<Longrightarrow>  path_component s x y \<Longrightarrow> path_component t x y"
   1.742 +lemma path_component_of_subset: "s \<subseteq> t \<Longrightarrow> path_component s x y \<Longrightarrow> path_component t x y"
   1.743    unfolding path_component_def by auto
   1.744  
   1.745  
   1.746 -subsection {* Can also consider it as a set, as the name suggests. *}
   1.747 +text {* Can also consider it as a set, as the name suggests. *}
   1.748  
   1.749  lemma path_component_set:
   1.750    "{y. path_component s x y} =
   1.751 @@ -514,13 +630,15 @@
   1.752    done
   1.753  
   1.754  lemma path_component_subset: "{y. path_component s x y} \<subseteq> s"
   1.755 -  apply (rule, rule path_component_mem(2))
   1.756 +  apply rule
   1.757 +  apply (rule path_component_mem(2))
   1.758    apply auto
   1.759    done
   1.760  
   1.761  lemma path_component_eq_empty: "{y. path_component s x y} = {} \<longleftrightarrow> x \<notin> s"
   1.762    apply rule
   1.763 -  apply (drule equals0D[of _ x]) defer
   1.764 +  apply (drule equals0D[of _ x])
   1.765 +  defer
   1.766    apply (rule equals0I)
   1.767    unfolding mem_Collect_eq
   1.768    apply (drule path_component_mem(1))
   1.769 @@ -529,29 +647,35 @@
   1.770    done
   1.771  
   1.772  
   1.773 -subsection {* Path connectedness of a space. *}
   1.774 +subsection {* Path connectedness of a space *}
   1.775  
   1.776  definition "path_connected s \<longleftrightarrow>
   1.777 -  (\<forall>x\<in>s. \<forall>y\<in>s. \<exists>g. path g \<and> (path_image g) \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)"
   1.778 +  (\<forall>x\<in>s. \<forall>y\<in>s. \<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)"
   1.779  
   1.780  lemma path_connected_component: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. path_component s x y)"
   1.781    unfolding path_connected_def path_component_def by auto
   1.782  
   1.783 -lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. {y. path_component s x y} = s)" 
   1.784 +lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. {y. path_component s x y} = s)"
   1.785    unfolding path_connected_component
   1.786 -  apply (rule, rule, rule, rule path_component_subset) 
   1.787 +  apply rule
   1.788 +  apply rule
   1.789 +  apply rule
   1.790 +  apply (rule path_component_subset)
   1.791    unfolding subset_eq mem_Collect_eq Ball_def
   1.792    apply auto
   1.793    done
   1.794  
   1.795  
   1.796 -subsection {* Some useful lemmas about path-connectedness. *}
   1.797 +subsection {* Some useful lemmas about path-connectedness *}
   1.798  
   1.799  lemma convex_imp_path_connected:
   1.800    fixes s :: "'a::real_normed_vector set"
   1.801 -  assumes "convex s" shows "path_connected s"
   1.802 +  assumes "convex s"
   1.803 +  shows "path_connected s"
   1.804    unfolding path_connected_def
   1.805 -  apply (rule, rule, rule_tac x = "linepath x y" in exI)
   1.806 +  apply rule
   1.807 +  apply rule
   1.808 +  apply (rule_tac x = "linepath x y" in exI)
   1.809    unfolding path_image_linepath
   1.810    using assms [unfolded convex_contains_segment]
   1.811    apply auto
   1.812 @@ -561,26 +685,33 @@
   1.813    assumes "path_connected s"
   1.814    shows "connected s"
   1.815    unfolding connected_def not_ex
   1.816 -  apply (rule, rule, rule ccontr)
   1.817 +  apply rule
   1.818 +  apply rule
   1.819 +  apply (rule ccontr)
   1.820    unfolding not_not
   1.821 -  apply (erule conjE)+
   1.822 +  apply (elim conjE)
   1.823  proof -
   1.824    fix e1 e2
   1.825    assume as: "open e1" "open e2" "s \<subseteq> e1 \<union> e2" "e1 \<inter> e2 \<inter> s = {}" "e1 \<inter> s \<noteq> {}" "e2 \<inter> s \<noteq> {}"
   1.826 -  then obtain x1 x2 where obt:"x1\<in>e1\<inter>s" "x2\<in>e2\<inter>s" by auto
   1.827 -  then obtain g where g:"path g" "path_image g \<subseteq> s" "pathstart g = x1" "pathfinish g = x2"
   1.828 +  then obtain x1 x2 where obt:"x1 \<in> e1 \<inter> s" "x2 \<in> e2 \<inter> s"
   1.829 +    by auto
   1.830 +  then obtain g where g: "path g" "path_image g \<subseteq> s" "pathstart g = x1" "pathfinish g = x2"
   1.831      using assms[unfolded path_connected_def,rule_format,of x1 x2] by auto
   1.832    have *: "connected {0..1::real}"
   1.833      by (auto intro!: convex_connected convex_real_interval)
   1.834    have "{0..1} \<subseteq> {x \<in> {0..1}. g x \<in> e1} \<union> {x \<in> {0..1}. g x \<in> e2}"
   1.835      using as(3) g(2)[unfolded path_defs] by blast
   1.836    moreover have "{x \<in> {0..1}. g x \<in> e1} \<inter> {x \<in> {0..1}. g x \<in> e2} = {}"
   1.837 -    using as(4) g(2)[unfolded path_defs] unfolding subset_eq by auto 
   1.838 +    using as(4) g(2)[unfolded path_defs]
   1.839 +    unfolding subset_eq
   1.840 +    by auto
   1.841    moreover have "{x \<in> {0..1}. g x \<in> e1} \<noteq> {} \<and> {x \<in> {0..1}. g x \<in> e2} \<noteq> {}"
   1.842 -    using g(3,4)[unfolded path_defs] using obt
   1.843 +    using g(3,4)[unfolded path_defs]
   1.844 +    using obt
   1.845      by (simp add: ex_in_conv [symmetric], metis zero_le_one order_refl)
   1.846    ultimately show False
   1.847 -    using *[unfolded connected_local not_ex, rule_format, of "{x\<in>{0..1}. g x \<in> e1}" "{x\<in>{0..1}. g x \<in> e2}"]
   1.848 +    using *[unfolded connected_local not_ex, rule_format,
   1.849 +      of "{x\<in>{0..1}. g x \<in> e1}" "{x\<in>{0..1}. g x \<in> e2}"]
   1.850      using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(1)]
   1.851      using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(2)]
   1.852      by auto
   1.853 @@ -600,20 +731,23 @@
   1.854      unfolding mem_Collect_eq
   1.855      apply auto
   1.856      done
   1.857 -  then obtain e where e:"e>0" "ball y e \<subseteq> s"
   1.858 -    using assms[unfolded open_contains_ball] by auto
   1.859 +  then obtain e where e: "e > 0" "ball y e \<subseteq> s"
   1.860 +    using assms[unfolded open_contains_ball]
   1.861 +    by auto
   1.862    show "\<exists>e > 0. ball y e \<subseteq> {y. path_component s x y}"
   1.863      apply (rule_tac x=e in exI)
   1.864 -    apply (rule,rule `e>0`, rule)
   1.865 +    apply (rule,rule `e>0`)
   1.866 +    apply rule
   1.867      unfolding mem_ball mem_Collect_eq
   1.868    proof -
   1.869      fix z
   1.870      assume "dist y z < e"
   1.871      then show "path_component s x z"
   1.872 -      apply (rule_tac path_component_trans[of _ _ y]) defer
   1.873 +      apply (rule_tac path_component_trans[of _ _ y])
   1.874 +      defer
   1.875        apply (rule path_component_of_subset[OF e(2)])
   1.876        apply (rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format])
   1.877 -      using `e>0` as
   1.878 +      using `e > 0` as
   1.879        apply auto
   1.880        done
   1.881    qed
   1.882 @@ -622,16 +756,21 @@
   1.883  lemma open_non_path_component:
   1.884    fixes s :: "'a::real_normed_vector set"
   1.885    assumes "open s"
   1.886 -  shows "open(s - {y. path_component s x y})"
   1.887 +  shows "open (s - {y. path_component s x y})"
   1.888    unfolding open_contains_ball
   1.889  proof
   1.890    fix y
   1.891 -  assume as: "y\<in>s - {y. path_component s x y}"
   1.892 -  then obtain e where e:"e>0" "ball y e \<subseteq> s"
   1.893 -    using assms [unfolded open_contains_ball] by auto
   1.894 +  assume as: "y \<in> s - {y. path_component s x y}"
   1.895 +  then obtain e where e: "e > 0" "ball y e \<subseteq> s"
   1.896 +    using assms [unfolded open_contains_ball]
   1.897 +    by auto
   1.898    show "\<exists>e>0. ball y e \<subseteq> s - {y. path_component s x y}"
   1.899      apply (rule_tac x=e in exI)
   1.900 -    apply (rule, rule `e>0`, rule, rule) defer
   1.901 +    apply rule
   1.902 +    apply (rule `e>0`)
   1.903 +    apply rule
   1.904 +    apply rule
   1.905 +    defer
   1.906    proof (rule ccontr)
   1.907      fix z
   1.908      assume "z \<in> ball y e" "\<not> z \<notin> {y. path_component s x y}"
   1.909 @@ -643,43 +782,49 @@
   1.910        apply (rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format])
   1.911        apply auto
   1.912        done
   1.913 -    then show False using as by auto
   1.914 +    then show False
   1.915 +      using as by auto
   1.916    qed (insert e(2), auto)
   1.917  qed
   1.918  
   1.919  lemma connected_open_path_connected:
   1.920    fixes s :: "'a::real_normed_vector set"
   1.921 -  assumes "open s" "connected s"
   1.922 +  assumes "open s"
   1.923 +    and "connected s"
   1.924    shows "path_connected s"
   1.925    unfolding path_connected_component_set
   1.926  proof (rule, rule, rule path_component_subset, rule)
   1.927    fix x y
   1.928 -  assume "x \<in> s" "y \<in> s"
   1.929 +  assume "x \<in> s" and "y \<in> s"
   1.930    show "y \<in> {y. path_component s x y}"
   1.931    proof (rule ccontr)
   1.932 -    assume "y \<notin> {y. path_component s x y}"
   1.933 -    moreover
   1.934 -    have "{y. path_component s x y} \<inter> s \<noteq> {}"
   1.935 -      using `x\<in>s` path_component_eq_empty path_component_subset[of s x] by auto
   1.936 +    assume "\<not> ?thesis"
   1.937 +    moreover have "{y. path_component s x y} \<inter> s \<noteq> {}"
   1.938 +      using `x \<in> s` path_component_eq_empty path_component_subset[of s x]
   1.939 +      by auto
   1.940      ultimately
   1.941      show False
   1.942 -      using `y\<in>s` open_non_path_component[OF assms(1)] open_path_component[OF assms(1)]
   1.943 -      using assms(2)[unfolded connected_def not_ex, rule_format, of"{y. path_component s x y}" "s - {y. path_component s x y}"]
   1.944 +      using `y \<in> s` open_non_path_component[OF assms(1)] open_path_component[OF assms(1)]
   1.945 +      using assms(2)[unfolded connected_def not_ex, rule_format,
   1.946 +        of"{y. path_component s x y}" "s - {y. path_component s x y}"]
   1.947        by auto
   1.948    qed
   1.949  qed
   1.950  
   1.951  lemma path_connected_continuous_image:
   1.952 -  assumes "continuous_on s f" "path_connected s"
   1.953 +  assumes "continuous_on s f"
   1.954 +    and "path_connected s"
   1.955    shows "path_connected (f ` s)"
   1.956    unfolding path_connected_def
   1.957  proof (rule, rule)
   1.958    fix x' y'
   1.959    assume "x' \<in> f ` s" "y' \<in> f ` s"
   1.960 -  then obtain x y where xy: "x\<in>s" "y\<in>s" "x' = f x" "y' = f y" by auto
   1.961 -  guess g using assms(2)[unfolded path_connected_def, rule_format, OF xy(1,2)] ..
   1.962 +  then obtain x y where x: "x \<in> s" and y: "y \<in> s" and x': "x' = f x" and y': "y' = f y"
   1.963 +    by auto
   1.964 +  from x y obtain g where "path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y"
   1.965 +    using assms(2)[unfolded path_connected_def] by fast
   1.966    then show "\<exists>g. path g \<and> path_image g \<subseteq> f ` s \<and> pathstart g = x' \<and> pathfinish g = y'"
   1.967 -    unfolding xy
   1.968 +    unfolding x' y'
   1.969      apply (rule_tac x="f \<circ> g" in exI)
   1.970      unfolding path_defs
   1.971      apply (intro conjI continuous_on_compose continuous_on_subset[OF assms(1)])
   1.972 @@ -688,11 +833,12 @@
   1.973  qed
   1.974  
   1.975  lemma homeomorphic_path_connectedness:
   1.976 -  "s homeomorphic t \<Longrightarrow> (path_connected s \<longleftrightarrow> path_connected t)"
   1.977 +  "s homeomorphic t \<Longrightarrow> path_connected s \<longleftrightarrow> path_connected t"
   1.978    unfolding homeomorphic_def homeomorphism_def
   1.979 -  apply (erule exE|erule conjE)+  
   1.980 +  apply (erule exE|erule conjE)+
   1.981    apply rule
   1.982 -  apply (drule_tac f=f in path_connected_continuous_image) prefer 3
   1.983 +  apply (drule_tac f=f in path_connected_continuous_image)
   1.984 +  prefer 3
   1.985    apply (drule_tac f=g in path_connected_continuous_image)
   1.986    apply auto
   1.987    done
   1.988 @@ -702,21 +848,26 @@
   1.989  
   1.990  lemma path_connected_singleton: "path_connected {a}"
   1.991    unfolding path_connected_def pathstart_def pathfinish_def path_image_def
   1.992 -  apply (clarify, rule_tac x="\<lambda>x. a" in exI, simp add: image_constant_conv)
   1.993 +  apply clarify
   1.994 +  apply (rule_tac x="\<lambda>x. a" in exI)
   1.995 +  apply (simp add: image_constant_conv)
   1.996    apply (simp add: path_def continuous_on_const)
   1.997    done
   1.998  
   1.999  lemma path_connected_Un:
  1.1000 -  assumes "path_connected s" "path_connected t" "s \<inter> t \<noteq> {}"
  1.1001 +  assumes "path_connected s"
  1.1002 +    and "path_connected t"
  1.1003 +    and "s \<inter> t \<noteq> {}"
  1.1004    shows "path_connected (s \<union> t)"
  1.1005    unfolding path_connected_component
  1.1006  proof (rule, rule)
  1.1007    fix x y
  1.1008    assume as: "x \<in> s \<union> t" "y \<in> s \<union> t"
  1.1009 -  from assms(3) obtain z where "z \<in> s \<inter> t" by auto
  1.1010 +  from assms(3) obtain z where "z \<in> s \<inter> t"
  1.1011 +    by auto
  1.1012    then show "path_component (s \<union> t) x y"
  1.1013      using as and assms(1-2)[unfolded path_connected_component]
  1.1014 -    apply - 
  1.1015 +    apply -
  1.1016      apply (erule_tac[!] UnE)+
  1.1017      apply (rule_tac[2-3] path_component_trans[of _ _ z])
  1.1018      apply (auto simp add:path_component_of_subset [OF Un_upper1] path_component_of_subset[OF Un_upper2])
  1.1019 @@ -740,11 +891,11 @@
  1.1020  qed
  1.1021  
  1.1022  
  1.1023 -subsection {* sphere is path-connected. *}
  1.1024 +subsection {* Sphere is path-connected *}
  1.1025  
  1.1026  lemma path_connected_punctured_universe:
  1.1027    assumes "2 \<le> DIM('a::euclidean_space)"
  1.1028 -  shows "path_connected((UNIV::'a::euclidean_space set) - {a})"
  1.1029 +  shows "path_connected ((UNIV::'a set) - {a})"
  1.1030  proof -
  1.1031    let ?A = "{x::'a. \<exists>i\<in>Basis. x \<bullet> i < a \<bullet> i}"
  1.1032    let ?B = "{x::'a. \<exists>i\<in>Basis. a \<bullet> i < x \<bullet> i}"
  1.1033 @@ -754,70 +905,87 @@
  1.1034    proof (rule path_connected_UNION)
  1.1035      fix i :: 'a
  1.1036      assume "i \<in> Basis"
  1.1037 -    then show "(\<Sum>i\<in>Basis. (a \<bullet> i - 1)*\<^sub>R i) \<in> {x::'a. x \<bullet> i < a \<bullet> i}" by simp
  1.1038 +    then show "(\<Sum>i\<in>Basis. (a \<bullet> i - 1)*\<^sub>R i) \<in> {x::'a. x \<bullet> i < a \<bullet> i}"
  1.1039 +      by simp
  1.1040      show "path_connected {x. x \<bullet> i < a \<bullet> i}"
  1.1041        using convex_imp_path_connected [OF convex_halfspace_lt, of i "a \<bullet> i"]
  1.1042        by (simp add: inner_commute)
  1.1043    qed
  1.1044 -  have B: "path_connected ?B" unfolding Collect_bex_eq
  1.1045 +  have B: "path_connected ?B"
  1.1046 +    unfolding Collect_bex_eq
  1.1047    proof (rule path_connected_UNION)
  1.1048      fix i :: 'a
  1.1049      assume "i \<in> Basis"
  1.1050 -    then show "(\<Sum>i\<in>Basis. (a \<bullet> i + 1) *\<^sub>R i) \<in> {x::'a. a \<bullet> i < x \<bullet> i}" by simp
  1.1051 +    then show "(\<Sum>i\<in>Basis. (a \<bullet> i + 1) *\<^sub>R i) \<in> {x::'a. a \<bullet> i < x \<bullet> i}"
  1.1052 +      by simp
  1.1053      show "path_connected {x. a \<bullet> i < x \<bullet> i}"
  1.1054        using convex_imp_path_connected [OF convex_halfspace_gt, of "a \<bullet> i" i]
  1.1055        by (simp add: inner_commute)
  1.1056    qed
  1.1057 -  obtain S :: "'a set" where "S \<subseteq> Basis" "card S = Suc (Suc 0)"
  1.1058 -    using ex_card[OF assms] by auto
  1.1059 -  then obtain b0 b1 :: 'a where "b0 \<in> Basis" "b1 \<in> Basis" "b0 \<noteq> b1"
  1.1060 +  obtain S :: "'a set" where "S \<subseteq> Basis" and "card S = Suc (Suc 0)"
  1.1061 +    using ex_card[OF assms]
  1.1062 +    by auto
  1.1063 +  then obtain b0 b1 :: 'a where "b0 \<in> Basis" and "b1 \<in> Basis" and "b0 \<noteq> b1"
  1.1064      unfolding card_Suc_eq by auto
  1.1065 -  then have "a + b0 - b1 \<in> ?A \<inter> ?B" by (auto simp: inner_simps inner_Basis)
  1.1066 -  then have "?A \<inter> ?B \<noteq> {}" by fast
  1.1067 +  then have "a + b0 - b1 \<in> ?A \<inter> ?B"
  1.1068 +    by (auto simp: inner_simps inner_Basis)
  1.1069 +  then have "?A \<inter> ?B \<noteq> {}"
  1.1070 +    by fast
  1.1071    with A B have "path_connected (?A \<union> ?B)"
  1.1072      by (rule path_connected_Un)
  1.1073    also have "?A \<union> ?B = {x. \<exists>i\<in>Basis. x \<bullet> i \<noteq> a \<bullet> i}"
  1.1074      unfolding neq_iff bex_disj_distrib Collect_disj_eq ..
  1.1075    also have "\<dots> = {x. x \<noteq> a}"
  1.1076 -    unfolding euclidean_eq_iff [where 'a='a] by (simp add: Bex_def)
  1.1077 -  also have "\<dots> = UNIV - {a}" by auto
  1.1078 +    unfolding euclidean_eq_iff [where 'a='a]
  1.1079 +    by (simp add: Bex_def)
  1.1080 +  also have "\<dots> = UNIV - {a}"
  1.1081 +    by auto
  1.1082    finally show ?thesis .
  1.1083  qed
  1.1084  
  1.1085  lemma path_connected_sphere:
  1.1086    assumes "2 \<le> DIM('a::euclidean_space)"
  1.1087 -  shows "path_connected {x::'a::euclidean_space. norm(x - a) = r}"
  1.1088 +  shows "path_connected {x::'a. norm (x - a) = r}"
  1.1089  proof (rule linorder_cases [of r 0])
  1.1090    assume "r < 0"
  1.1091 -  then have "{x::'a. norm(x - a) = r} = {}" by auto
  1.1092 -  then show ?thesis using path_connected_empty by simp
  1.1093 +  then have "{x::'a. norm(x - a) = r} = {}"
  1.1094 +    by auto
  1.1095 +  then show ?thesis
  1.1096 +    using path_connected_empty by simp
  1.1097  next
  1.1098    assume "r = 0"
  1.1099 -  then show ?thesis using path_connected_singleton by simp
  1.1100 +  then show ?thesis
  1.1101 +    using path_connected_singleton by simp
  1.1102  next
  1.1103    assume r: "0 < r"
  1.1104 -  then have *: "{x::'a. norm(x - a) = r} = (\<lambda>x. a + r *\<^sub>R x) ` {x. norm x = 1}"
  1.1105 -    apply -
  1.1106 -    apply (rule set_eqI, rule)
  1.1107 +  have *: "{x::'a. norm(x - a) = r} = (\<lambda>x. a + r *\<^sub>R x) ` {x. norm x = 1}"
  1.1108 +    apply (rule set_eqI)
  1.1109 +    apply rule
  1.1110      unfolding image_iff
  1.1111      apply (rule_tac x="(1/r) *\<^sub>R (x - a)" in bexI)
  1.1112      unfolding mem_Collect_eq norm_scaleR
  1.1113 +    using r
  1.1114      apply (auto simp add: scaleR_right_diff_distrib)
  1.1115      done
  1.1116    have **: "{x::'a. norm x = 1} = (\<lambda>x. (1/norm x) *\<^sub>R x) ` (UNIV - {0})"
  1.1117 -    apply (rule set_eqI,rule)
  1.1118 +    apply (rule set_eqI)
  1.1119 +    apply rule
  1.1120      unfolding image_iff
  1.1121      apply (rule_tac x=x in bexI)
  1.1122      unfolding mem_Collect_eq
  1.1123 -    apply (auto split:split_if_asm)
  1.1124 +    apply (auto split: split_if_asm)
  1.1125      done
  1.1126    have "continuous_on (UNIV - {0}) (\<lambda>x::'a. 1 / norm x)"
  1.1127 -    unfolding field_divide_inverse by (simp add: continuous_on_intros)
  1.1128 -  then show ?thesis unfolding * ** using path_connected_punctured_universe[OF assms]
  1.1129 +    unfolding field_divide_inverse
  1.1130 +    by (simp add: continuous_on_intros)
  1.1131 +  then show ?thesis
  1.1132 +    unfolding * **
  1.1133 +    using path_connected_punctured_universe[OF assms]
  1.1134      by (auto intro!: path_connected_continuous_image continuous_on_intros)
  1.1135  qed
  1.1136  
  1.1137 -lemma connected_sphere: "2 \<le> DIM('a::euclidean_space) \<Longrightarrow> connected {x::'a. norm(x - a) = r}"
  1.1138 -  using path_connected_sphere path_connected_imp_connected by auto
  1.1139 +lemma connected_sphere: "2 \<le> DIM('a::euclidean_space) \<Longrightarrow> connected {x::'a. norm (x - a) = r}"
  1.1140 +  using path_connected_sphere path_connected_imp_connected
  1.1141 +  by auto
  1.1142  
  1.1143  end
     2.1 --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy	Sat Sep 14 22:50:15 2013 +0200
     2.2 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy	Sat Sep 14 23:52:36 2013 +0200
     2.3 @@ -25,7 +25,7 @@
     2.4    using dist_triangle[of y z x] by (simp add: dist_commute)
     2.5  
     2.6  (* LEGACY *)
     2.7 -lemma lim_subseq: "subseq r \<Longrightarrow> s ----> l \<Longrightarrow> (s o r) ----> l"
     2.8 +lemma lim_subseq: "subseq r \<Longrightarrow> s ----> l \<Longrightarrow> (s \<circ> r) ----> l"
     2.9    by (rule LIMSEQ_subseq_LIMSEQ)
    2.10  
    2.11  lemmas real_isGlb_unique = isGlb_unique[where 'a=real]
    2.12 @@ -85,7 +85,7 @@
    2.13    show "topological_basis B"
    2.14      using assms unfolding topological_basis_def
    2.15    proof safe
    2.16 -    fix O'::"'a set"
    2.17 +    fix O' :: "'a set"
    2.18      assume "open O'"
    2.19      with H obtain f where "\<forall>x\<in>O'. f x \<in> B \<and> x \<in> f x \<and> f x \<subseteq> O'"
    2.20        by (force intro: bchoice simp: Bex_def)
    2.21 @@ -138,14 +138,14 @@
    2.22  qed
    2.23  
    2.24  lemma basis_dense:
    2.25 -  fixes B::"'a set set"
    2.26 -    and f::"'a set \<Rightarrow> 'a"
    2.27 +  fixes B :: "'a set set"
    2.28 +    and f :: "'a set \<Rightarrow> 'a"
    2.29    assumes "topological_basis B"
    2.30      and choosefrom_basis: "\<And>B'. B' \<noteq> {} \<Longrightarrow> f B' \<in> B'"
    2.31    shows "(\<forall>X. open X \<longrightarrow> X \<noteq> {} \<longrightarrow> (\<exists>B' \<in> B. f B' \<in> X))"
    2.32  proof (intro allI impI)
    2.33 -  fix X::"'a set"
    2.34 -  assume "open X" "X \<noteq> {}"
    2.35 +  fix X :: "'a set"
    2.36 +  assume "open X" and "X \<noteq> {}"
    2.37    from topological_basisE[OF `topological_basis B` `open X` choosefrom_basis[OF `X \<noteq> {}`]]
    2.38    guess B' . note B' = this
    2.39    then show "\<exists>B'\<in>B. f B' \<in> X"
    2.40 @@ -180,7 +180,7 @@
    2.41  subsection {* Countable Basis *}
    2.42  
    2.43  locale countable_basis =
    2.44 -  fixes B::"'a::topological_space set set"
    2.45 +  fixes B :: "'a::topological_space set set"
    2.46    assumes is_basis: "topological_basis B"
    2.47      and countable_basis: "countable B"
    2.48  begin
    2.49 @@ -283,8 +283,9 @@
    2.50    proof (rule first_countableI[of "(\<lambda>(a, b). a \<times> b) ` (A \<times> B)"], safe)
    2.51      fix a b
    2.52      assume x: "a \<in> A" "b \<in> B"
    2.53 -    with A(2, 3)[of a] B(2, 3)[of b] show "x \<in> a \<times> b" "open (a \<times> b)"
    2.54 -      unfolding mem_Times_iff by (auto intro: open_Times)
    2.55 +    with A(2, 3)[of a] B(2, 3)[of b] show "x \<in> a \<times> b" and "open (a \<times> b)"
    2.56 +      unfolding mem_Times_iff
    2.57 +      by (auto intro: open_Times)
    2.58    next
    2.59      fix S
    2.60      assume "open S" "x \<in> S"
    2.61 @@ -418,7 +419,7 @@
    2.62  
    2.63  text{* Infer the "universe" from union of all sets in the topology. *}
    2.64  
    2.65 -definition "topspace T =  \<Union>{S. openin T S}"
    2.66 +definition "topspace T = \<Union>{S. openin T S}"
    2.67  
    2.68  subsubsection {* Main properties of open sets *}
    2.69  
    2.70 @@ -1007,7 +1008,7 @@
    2.71  
    2.72  lemma islimpt_approachable_le:
    2.73    fixes x :: "'a::metric_space"
    2.74 -  shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> S. x' \<noteq> x \<and> dist x' x <= e)"
    2.75 +  shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> S. x' \<noteq> x \<and> dist x' x \<le> e)"
    2.76    unfolding islimpt_approachable
    2.77    using approachable_lt_le [where f="\<lambda>y. dist y x" and P="\<lambda>y. y \<notin> S \<or> y = x",
    2.78      THEN arg_cong [where f=Not]]
    2.79 @@ -1043,7 +1044,7 @@
    2.80  lemma finite_set_avoid:
    2.81    fixes a :: "'a::metric_space"
    2.82    assumes fS: "finite S"
    2.83 -  shows  "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d <= dist a x"
    2.84 +  shows  "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d \<le> dist a x"
    2.85  proof (induct rule: finite_induct[OF fS])
    2.86    case 1
    2.87    then show ?case by (auto intro: zero_less_one)
    2.88 @@ -1423,8 +1424,9 @@
    2.89    apply (drule_tac x=UNIV in spec, simp)
    2.90    done
    2.91  
    2.92 -lemma not_trivial_limit_within: "~trivial_limit (at x within S) = (x:closure(S-{x}))"
    2.93 -  using islimpt_in_closure by (metis trivial_limit_within)
    2.94 +lemma not_trivial_limit_within: "\<not> trivial_limit (at x within S) = (x \<in> closure (S - {x}))"
    2.95 +  using islimpt_in_closure
    2.96 +  by (metis trivial_limit_within)
    2.97  
    2.98  text {* Some property holds "sufficiently close" to the limit point. *}
    2.99  
   2.100 @@ -1463,19 +1465,19 @@
   2.101  text{* Show that they yield usual definitions in the various cases. *}
   2.102  
   2.103  lemma Lim_within_le: "(f ---> l)(at a within S) \<longleftrightarrow>
   2.104 -           (\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. 0 < dist x a  \<and> dist x a  <= d \<longrightarrow> dist (f x) l < e)"
   2.105 +    (\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a \<le> d \<longrightarrow> dist (f x) l < e)"
   2.106    by (auto simp add: tendsto_iff eventually_at_le dist_nz)
   2.107  
   2.108  lemma Lim_within: "(f ---> l) (at a within S) \<longleftrightarrow>
   2.109 -        (\<forall>e >0. \<exists>d>0. \<forall>x \<in> S. 0 < dist x a  \<and> dist x a  < d  \<longrightarrow> dist (f x) l < e)"
   2.110 +    (\<forall>e >0. \<exists>d>0. \<forall>x \<in> S. 0 < dist x a \<and> dist x a  < d \<longrightarrow> dist (f x) l < e)"
   2.111    by (auto simp add: tendsto_iff eventually_at dist_nz)
   2.112  
   2.113  lemma Lim_at: "(f ---> l) (at a) \<longleftrightarrow>
   2.114 -        (\<forall>e >0. \<exists>d>0. \<forall>x. 0 < dist x a  \<and> dist x a  < d  \<longrightarrow> dist (f x) l < e)"
   2.115 +    (\<forall>e >0. \<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d  \<longrightarrow> dist (f x) l < e)"
   2.116    by (auto simp add: tendsto_iff eventually_at2)
   2.117  
   2.118  lemma Lim_at_infinity:
   2.119 -  "(f ---> l) at_infinity \<longleftrightarrow> (\<forall>e>0. \<exists>b. \<forall>x. norm x >= b \<longrightarrow> dist (f x) l < e)"
   2.120 +  "(f ---> l) at_infinity \<longleftrightarrow> (\<forall>e>0. \<exists>b. \<forall>x. norm x \<ge> b \<longrightarrow> dist (f x) l < e)"
   2.121    by (auto simp add: tendsto_iff eventually_at_infinity)
   2.122  
   2.123  lemma Lim_eventually: "eventually (\<lambda>x. f x = l) net \<Longrightarrow> (f ---> l) net"
   2.124 @@ -1489,7 +1491,8 @@
   2.125  lemma Lim_Un:
   2.126    assumes "(f ---> l) (at x within S)" "(f ---> l) (at x within T)"
   2.127    shows "(f ---> l) (at x within (S \<union> T))"
   2.128 -  using assms unfolding tendsto_def eventually_at_filter
   2.129 +  using assms
   2.130 +  unfolding tendsto_def eventually_at_filter
   2.131    apply clarify
   2.132    apply (drule spec, drule (1) mp, drule (1) mp)
   2.133    apply (drule spec, drule (1) mp, drule (1) mp)
   2.134 @@ -1515,10 +1518,10 @@
   2.135    from assms obtain T where T: "open T" "x \<in> T" "T \<subseteq> S" ..
   2.136    {
   2.137      assume "?lhs"
   2.138 -    then obtain A where "open A" "x \<in> A" "\<forall>y\<in>A. y \<noteq> x \<longrightarrow> y \<in> S \<longrightarrow> P y"
   2.139 +    then obtain A where "open A" and "x \<in> A" and "\<forall>y\<in>A. y \<noteq> x \<longrightarrow> y \<in> S \<longrightarrow> P y"
   2.140        unfolding eventually_at_topological
   2.141        by auto
   2.142 -    with T have "open (A \<inter> T)" "x \<in> A \<inter> T" "\<forall>y\<in>(A \<inter> T). y \<noteq> x \<longrightarrow> P y"
   2.143 +    with T have "open (A \<inter> T)" and "x \<in> A \<inter> T" and "\<forall>y \<in> A \<inter> T. y \<noteq> x \<longrightarrow> P y"
   2.144        by auto
   2.145      then show "?rhs"
   2.146        unfolding eventually_at_topological by auto
   2.147 @@ -1546,11 +1549,11 @@
   2.148    assumes mono: "\<And>a b. a \<in> I \<Longrightarrow> b \<in> I \<Longrightarrow> x < a \<Longrightarrow> a \<le> b \<Longrightarrow> f a \<le> f b"
   2.149      and bnd: "\<And>a. a \<in> I \<Longrightarrow> x < a \<Longrightarrow> K \<le> f a"
   2.150    shows "(f ---> Inf (f ` ({x<..} \<inter> I))) (at x within ({x<..} \<inter> I))"
   2.151 -proof cases
   2.152 -  assume "{x<..} \<inter> I = {}"
   2.153 +proof (cases "{x<..} \<inter> I = {}")
   2.154 +  case True
   2.155    then show ?thesis by (simp add: Lim_within_empty)
   2.156  next
   2.157 -  assume e: "{x<..} \<inter> I \<noteq> {}"
   2.158 +  case False
   2.159    show ?thesis
   2.160    proof (rule order_tendstoI)
   2.161      fix a
   2.162 @@ -1558,7 +1561,7 @@
   2.163      {
   2.164        fix y
   2.165        assume "y \<in> {x<..} \<inter> I"
   2.166 -      with e bnd have "Inf (f ` ({x<..} \<inter> I)) \<le> f y"
   2.167 +      with False bnd have "Inf (f ` ({x<..} \<inter> I)) \<le> f y"
   2.168          by (auto intro: cInf_lower)
   2.169        with a have "a < f y"
   2.170          by (blast intro: less_le_trans)
   2.171 @@ -1568,7 +1571,7 @@
   2.172    next
   2.173      fix a
   2.174      assume "Inf (f ` ({x<..} \<inter> I)) < a"
   2.175 -    from cInf_lessD[OF _ this] e obtain y where y: "x < y" "y \<in> I" "f y < a"
   2.176 +    from cInf_lessD[OF _ this] False obtain y where y: "x < y" "y \<in> I" "f y < a"
   2.177        by auto
   2.178      then have "eventually (\<lambda>x. x \<in> I \<longrightarrow> f x < a) (at_right x)"
   2.179        unfolding eventually_at_right by (metis less_imp_le le_less_trans mono)
   2.180 @@ -1625,7 +1628,7 @@
   2.181      and A :: "'a filter"
   2.182    assumes "(f ---> l) A"
   2.183      and "l \<noteq> 0"
   2.184 -  shows "((inverse o f) ---> inverse l) A"
   2.185 +  shows "((inverse \<circ> f) ---> inverse l) A"
   2.186    unfolding o_def using assms by (rule tendsto_inverse)
   2.187  
   2.188  lemma Lim_null:
   2.189 @@ -1646,7 +1649,7 @@
   2.190  lemma Lim_transform_bound:
   2.191    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
   2.192      and g :: "'a \<Rightarrow> 'c::real_normed_vector"
   2.193 -  assumes "eventually (\<lambda>n. norm(f n) <= norm(g n)) net"
   2.194 +  assumes "eventually (\<lambda>n. norm (f n) \<le> norm (g n)) net"
   2.195      and "(g ---> 0) net"
   2.196    shows "(f ---> 0) net"
   2.197    using assms(1) tendsto_norm_zero [OF assms(2)]
   2.198 @@ -1657,7 +1660,7 @@
   2.199  lemma Lim_in_closed_set:
   2.200    assumes "closed S"
   2.201      and "eventually (\<lambda>x. f(x) \<in> S) net"
   2.202 -    and "\<not>(trivial_limit net)" "(f ---> l) net"
   2.203 +    and "\<not> trivial_limit net" "(f ---> l) net"
   2.204    shows "l \<in> S"
   2.205  proof (rule ccontr)
   2.206    assume "l \<notin> S"
   2.207 @@ -1676,8 +1679,8 @@
   2.208  lemma Lim_dist_ubound:
   2.209    assumes "\<not>(trivial_limit net)"
   2.210      and "(f ---> l) net"
   2.211 -    and "eventually (\<lambda>x. dist a (f x) <= e) net"
   2.212 -  shows "dist a l <= e"
   2.213 +    and "eventually (\<lambda>x. dist a (f x) \<le> e) net"
   2.214 +  shows "dist a l \<le> e"
   2.215  proof -
   2.216    have "dist a l \<in> {..e}"
   2.217    proof (rule Lim_in_closed_set)
   2.218 @@ -1714,7 +1717,9 @@
   2.219  
   2.220  lemma Lim_norm_lbound:
   2.221    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
   2.222 -  assumes "\<not> (trivial_limit net)"  "(f ---> l) net"  "eventually (\<lambda>x. e <= norm(f x)) net"
   2.223 +  assumes "\<not> trivial_limit net"
   2.224 +    and "(f ---> l) net"
   2.225 +    and "eventually (\<lambda>x. e \<le> norm (f x)) net"
   2.226    shows "e \<le> norm l"
   2.227  proof -
   2.228    have "norm l \<in> {e..}"
   2.229 @@ -1946,7 +1951,7 @@
   2.230  
   2.231  
   2.232  lemma not_trivial_limit_within_ball:
   2.233 -  "(\<not> trivial_limit (at x within S)) = (\<forall>e>0. S \<inter> ball x e - {x} \<noteq> {})"
   2.234 +  "\<not> trivial_limit (at x within S) \<longleftrightarrow> (\<forall>e>0. S \<inter> ball x e - {x} \<noteq> {})"
   2.235    (is "?lhs = ?rhs")
   2.236  proof -
   2.237    {
   2.238 @@ -1954,12 +1959,12 @@
   2.239      {
   2.240        fix e :: real
   2.241        assume "e > 0"
   2.242 -      then obtain y where "y:(S-{x}) & dist y x < e"
   2.243 +      then obtain y where "y \<in> S - {x}" and "dist y x < e"
   2.244          using `?lhs` not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"]
   2.245          by auto
   2.246 -      then have "y : (S Int ball x e - {x})"
   2.247 +      then have "y \<in> S \<inter> ball x e - {x}"
   2.248          unfolding ball_def by (simp add: dist_commute)
   2.249 -      then have "S Int ball x e - {x} ~= {}" by blast
   2.250 +      then have "S \<inter> ball x e - {x} \<noteq> {}" by blast
   2.251      }
   2.252      then have "?rhs" by auto
   2.253    }
   2.254 @@ -1969,11 +1974,11 @@
   2.255      {
   2.256        fix e :: real
   2.257        assume "e > 0"
   2.258 -      then obtain y where "y : (S Int ball x e - {x})"
   2.259 +      then obtain y where "y \<in> S \<inter> ball x e - {x}"
   2.260          using `?rhs` by blast
   2.261 -      then have "y:(S-{x}) & dist y x < e"
   2.262 -        unfolding ball_def by (simp add: dist_commute)
   2.263 -      then have "EX y:(S-{x}). dist y x < e"
   2.264 +      then have "y \<in> S - {x}" and "dist y x < e"
   2.265 +        unfolding ball_def by (simp_all add: dist_commute)
   2.266 +      then have "\<exists>y \<in> S - {x}. dist y x < e"
   2.267          by auto
   2.268      }
   2.269      then have "?lhs"
   2.270 @@ -2004,16 +2009,18 @@
   2.271    assumes "a \<in> A"
   2.272    shows "infdist a A = 0"
   2.273  proof -
   2.274 -  from infdist_le[OF assms, of "dist a a"] have "infdist a A \<le> 0" by auto
   2.275 -  with infdist_nonneg[of a A] assms show "infdist a A = 0" by auto
   2.276 +  from infdist_le[OF assms, of "dist a a"] have "infdist a A \<le> 0"
   2.277 +    by auto
   2.278 +  with infdist_nonneg[of a A] assms show "infdist a A = 0"
   2.279 +    by auto
   2.280  qed
   2.281  
   2.282  lemma infdist_triangle: "infdist x A \<le> infdist y A + dist x y"
   2.283 -proof cases
   2.284 -  assume "A = {}"
   2.285 +proof (cases "A = {}")
   2.286 +  case True
   2.287    then show ?thesis by (simp add: infdist_def)
   2.288  next
   2.289 -  assume "A \<noteq> {}"
   2.290 +  case False
   2.291    then obtain a where "a \<in> A" by auto
   2.292    have "infdist x A \<le> Inf {dist x y + dist y a |a. a \<in> A}"
   2.293    proof (rule cInf_greatest)
   2.294 @@ -2202,7 +2209,7 @@
   2.295    ultimately show "?rhs" by auto
   2.296  next
   2.297    assume "?rhs"
   2.298 -  then have "e>0" by auto
   2.299 +  then have "e > 0" by auto
   2.300    {
   2.301      fix d :: real
   2.302      assume "d > 0"
   2.303 @@ -2340,7 +2347,7 @@
   2.304  lemma interior_cball:
   2.305    fixes x :: "'a::{real_normed_vector, perfect_space}"
   2.306    shows "interior (cball x e) = ball x e"
   2.307 -proof (cases "e\<ge>0")
   2.308 +proof (cases "e \<ge> 0")
   2.309    case False note cs = this
   2.310    from cs have "ball x e = {}"
   2.311      using ball_empty[of e x] by auto
   2.312 @@ -2409,7 +2416,9 @@
   2.313    then have "\<forall>S \<subseteq> cball x e. open S \<longrightarrow> S \<subseteq> ball x e"
   2.314      by auto
   2.315    ultimately show ?thesis
   2.316 -    using interior_unique[of "ball x e" "cball x e"] using open_ball[of x e] by auto
   2.317 +    using interior_unique[of "ball x e" "cball x e"]
   2.318 +    using open_ball[of x e]
   2.319 +    by auto
   2.320  qed
   2.321  
   2.322  lemma frontier_ball:
   2.323 @@ -2422,13 +2431,13 @@
   2.324  
   2.325  lemma frontier_cball:
   2.326    fixes a :: "'a::{real_normed_vector, perfect_space}"
   2.327 -  shows "frontier(cball a e) = {x. dist a x = e}"
   2.328 +  shows "frontier (cball a e) = {x. dist a x = e}"
   2.329    apply (simp add: frontier_def interior_cball closed_cball order_less_imp_le)
   2.330    apply (simp add: set_eq_iff)
   2.331    apply arith
   2.332    done
   2.333  
   2.334 -lemma cball_eq_empty: "(cball x e = {}) \<longleftrightarrow> e < 0"
   2.335 +lemma cball_eq_empty: "cball x e = {} \<longleftrightarrow> e < 0"
   2.336    apply (simp add: set_eq_iff not_le)
   2.337    apply (metis zero_le_dist dist_self order_less_le_trans)
   2.338    done
   2.339 @@ -2438,7 +2447,7 @@
   2.340  
   2.341  lemma cball_eq_sing:
   2.342    fixes x :: "'a::{metric_space,perfect_space}"
   2.343 -  shows "(cball x e = {x}) \<longleftrightarrow> e = 0"
   2.344 +  shows "cball x e = {x} \<longleftrightarrow> e = 0"
   2.345  proof (rule linorder_cases)
   2.346    assume e: "0 < e"
   2.347    obtain a where "a \<noteq> x" "dist a x < e"
   2.348 @@ -2466,7 +2475,8 @@
   2.349  lemma bounded_any_center: "bounded S \<longleftrightarrow> (\<exists>e. \<forall>y\<in>S. dist a y \<le> e)"
   2.350    unfolding bounded_def
   2.351    apply safe
   2.352 -  apply (rule_tac x="dist a x + e" in exI, clarify)
   2.353 +  apply (rule_tac x="dist a x + e" in exI)
   2.354 +  apply clarify
   2.355    apply (drule (1) bspec)
   2.356    apply (erule order_trans [OF dist_triangle add_left_mono])
   2.357    apply auto
   2.358 @@ -2526,7 +2536,7 @@
   2.359    apply auto
   2.360    done
   2.361  
   2.362 -lemma bounded_ball[simp,intro]: "bounded(ball x e)"
   2.363 +lemma bounded_ball[simp,intro]: "bounded (ball x e)"
   2.364    by (metis ball_subset_cball bounded_cball bounded_subset)
   2.365  
   2.366  lemma bounded_Un[simp]: "bounded (S \<union> T) \<longleftrightarrow> bounded S \<and> bounded T"
   2.367 @@ -2534,14 +2544,16 @@
   2.368    apply (rename_tac x y r s)
   2.369    apply (rule_tac x=x in exI)
   2.370    apply (rule_tac x="max r (dist x y + s)" in exI)
   2.371 -  apply (rule ballI, rename_tac z, safe)
   2.372 -  apply (drule (1) bspec, simp)
   2.373 +  apply (rule ballI)
   2.374 +  apply safe
   2.375 +  apply (drule (1) bspec)
   2.376 +  apply simp
   2.377    apply (drule (1) bspec)
   2.378    apply (rule min_max.le_supI2)
   2.379    apply (erule order_trans [OF dist_triangle add_left_mono])
   2.380    done
   2.381  
   2.382 -lemma bounded_Union[intro]: "finite F \<Longrightarrow> (\<forall>S\<in>F. bounded S) \<Longrightarrow> bounded(\<Union>F)"
   2.383 +lemma bounded_Union[intro]: "finite F \<Longrightarrow> \<forall>S\<in>F. bounded S \<Longrightarrow> bounded (\<Union>F)"
   2.384    by (induct rule: finite_induct[of F]) auto
   2.385  
   2.386  lemma bounded_UN [intro]: "finite A \<Longrightarrow> \<forall>x\<in>A. bounded (B x) \<Longrightarrow> bounded (\<Union>x\<in>A. B x)"
   2.387 @@ -2549,22 +2561,27 @@
   2.388  
   2.389  lemma bounded_insert [simp]: "bounded (insert x S) \<longleftrightarrow> bounded S"
   2.390  proof -
   2.391 -  have "\<forall>y\<in>{x}. dist x y \<le> 0" by simp
   2.392 -  then have "bounded {x}" unfolding bounded_def by fast
   2.393 -  then show ?thesis by (metis insert_is_Un bounded_Un)
   2.394 +  have "\<forall>y\<in>{x}. dist x y \<le> 0"
   2.395 +    by simp
   2.396 +  then have "bounded {x}"
   2.397 +    unfolding bounded_def by fast
   2.398 +  then show ?thesis
   2.399 +    by (metis insert_is_Un bounded_Un)
   2.400  qed
   2.401  
   2.402  lemma finite_imp_bounded [intro]: "finite S \<Longrightarrow> bounded S"
   2.403    by (induct set: finite) simp_all
   2.404  
   2.405 -lemma bounded_pos: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x <= b)"
   2.406 +lemma bounded_pos: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x \<le> b)"
   2.407    apply (simp add: bounded_iff)
   2.408 -  apply (subgoal_tac "\<And>x (y::real). 0 < 1 + abs y \<and> (x <= y \<longrightarrow> x <= 1 + abs y)")
   2.409 +  apply (subgoal_tac "\<And>x (y::real). 0 < 1 + abs y \<and> (x \<le> y \<longrightarrow> x \<le> 1 + abs y)")
   2.410    apply metis
   2.411    apply arith
   2.412    done
   2.413  
   2.414 -lemma Bseq_eq_bounded: "Bseq f \<longleftrightarrow> bounded (range f::_::real_normed_vector set)"
   2.415 +lemma Bseq_eq_bounded:
   2.416 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
   2.417 +  shows "Bseq f \<longleftrightarrow> bounded (range f)"
   2.418    unfolding Bseq_def bounded_pos by auto
   2.419  
   2.420  lemma bounded_Int[intro]: "bounded S \<or> bounded T \<Longrightarrow> bounded (S \<inter> T)"
   2.421 @@ -2575,11 +2592,13 @@
   2.422  
   2.423  lemma not_bounded_UNIV[simp, intro]:
   2.424    "\<not> bounded (UNIV :: 'a::{real_normed_vector, perfect_space} set)"
   2.425 -proof(auto simp add: bounded_pos not_le)
   2.426 +proof (auto simp add: bounded_pos not_le)
   2.427    obtain x :: 'a where "x \<noteq> 0"
   2.428      using perfect_choose_dist [OF zero_less_one] by fast
   2.429 -  fix b::real  assume b: "b >0"
   2.430 -  have b1: "b +1 \<ge> 0" using b by simp
   2.431 +  fix b :: real
   2.432 +  assume b: "b >0"
   2.433 +  have b1: "b +1 \<ge> 0"
   2.434 +    using b by simp
   2.435    with `x \<noteq> 0` have "b < norm (scaleR (b + 1) (sgn x))"
   2.436      by (simp add: norm_sgn)
   2.437    then show "\<exists>x::'a. b < norm x" ..
   2.438 @@ -2590,15 +2609,17 @@
   2.439      and "bounded_linear f"
   2.440    shows "bounded (f ` S)"
   2.441  proof -
   2.442 -  from assms(1) obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b"
   2.443 +  from assms(1) obtain b where b: "b > 0" "\<forall>x\<in>S. norm x \<le> b"
   2.444      unfolding bounded_pos by auto
   2.445 -  from assms(2) obtain B where B:"B>0" "\<forall>x. norm (f x) \<le> B * norm x"
   2.446 +  from assms(2) obtain B where B: "B > 0" "\<forall>x. norm (f x) \<le> B * norm x"
   2.447      using bounded_linear.pos_bounded by (auto simp add: mult_ac)
   2.448    {
   2.449      fix x
   2.450 -    assume "x\<in>S"
   2.451 -    then have "norm x \<le> b" using b by auto
   2.452 -    then have "norm (f x) \<le> B * b" using B(2)
   2.453 +    assume "x \<in> S"
   2.454 +    then have "norm x \<le> b"
   2.455 +      using b by auto
   2.456 +    then have "norm (f x) \<le> B * b"
   2.457 +      using B(2)
   2.458        apply (erule_tac x=x in allE)
   2.459        apply (metis B(1) B(2) order_trans mult_le_cancel_left_pos)
   2.460        done
   2.461 @@ -2624,11 +2645,11 @@
   2.462    assumes "bounded S"
   2.463    shows "bounded ((\<lambda>x. a + x) ` S)"
   2.464  proof -
   2.465 -  from assms obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b"
   2.466 +  from assms obtain b where b: "b > 0" "\<forall>x\<in>S. norm x \<le> b"
   2.467      unfolding bounded_pos by auto
   2.468    {
   2.469      fix x
   2.470 -    assume "x\<in>S"
   2.471 +    assume "x \<in> S"
   2.472      then have "norm (a + x) \<le> b + norm a"
   2.473        using norm_triangle_ineq[of a x] b by auto
   2.474    }
   2.475 @@ -2648,7 +2669,8 @@
   2.476  
   2.477  lemma bounded_has_Sup:
   2.478    fixes S :: "real set"
   2.479 -  assumes "bounded S" "S \<noteq> {}"
   2.480 +  assumes "bounded S"
   2.481 +    and "S \<noteq> {}"
   2.482    shows "\<forall>x\<in>S. x \<le> Sup S"
   2.483      and "\<forall>b. (\<forall>x\<in>S. x \<le> b) \<longrightarrow> Sup S \<le> b"
   2.484  proof
   2.485 @@ -2679,18 +2701,19 @@
   2.486  
   2.487  lemma bounded_has_Inf:
   2.488    fixes S :: "real set"
   2.489 -  assumes "bounded S"  "S \<noteq> {}"
   2.490 +  assumes "bounded S"
   2.491 +    and "S \<noteq> {}"
   2.492    shows "\<forall>x\<in>S. x \<ge> Inf S"
   2.493      and "\<forall>b. (\<forall>x\<in>S. x \<ge> b) \<longrightarrow> Inf S \<ge> b"
   2.494  proof
   2.495    fix x
   2.496 -  assume "x\<in>S"
   2.497 +  assume "x \<in> S"
   2.498    from assms(1) obtain a where a: "\<forall>x\<in>S. \<bar>x\<bar> \<le> a"
   2.499      unfolding bounded_real by auto
   2.500 -  then show "x \<ge> Inf S" using `x\<in>S`
   2.501 +  then show "x \<ge> Inf S" using `x \<in> S`
   2.502      by (metis cInf_lower_EX abs_le_D2 minus_le_iff)
   2.503  next
   2.504 -  show "\<forall>b. (\<forall>x\<in>S. x >= b) \<longrightarrow> Inf S \<ge> b"
   2.505 +  show "\<forall>b. (\<forall>x\<in>S. x \<ge> b) \<longrightarrow> Inf S \<ge> b"
   2.506      using assms by (metis cInf_greatest)
   2.507  qed
   2.508  
   2.509 @@ -2715,25 +2738,29 @@
   2.510  subsubsection {* Bolzano-Weierstrass property *}
   2.511  
   2.512  lemma heine_borel_imp_bolzano_weierstrass:
   2.513 -  assumes "compact s" and "infinite t" and "t \<subseteq> s"
   2.514 +  assumes "compact s"
   2.515 +    and "infinite t"
   2.516 +    and "t \<subseteq> s"
   2.517    shows "\<exists>x \<in> s. x islimpt t"
   2.518  proof (rule ccontr)
   2.519    assume "\<not> (\<exists>x \<in> s. x islimpt t)"
   2.520 -  then obtain f where f:"\<forall>x\<in>s. x \<in> f x \<and> open (f x) \<and> (\<forall>y\<in>t. y \<in> f x \<longrightarrow> y = x)"
   2.521 +  then obtain f where f: "\<forall>x\<in>s. x \<in> f x \<and> open (f x) \<and> (\<forall>y\<in>t. y \<in> f x \<longrightarrow> y = x)"
   2.522      unfolding islimpt_def
   2.523      using bchoice[of s "\<lambda> x T. x \<in> T \<and> open T \<and> (\<forall>y\<in>t. y \<in> T \<longrightarrow> y = x)"]
   2.524      by auto
   2.525 -  obtain g where g: "g\<subseteq>{t. \<exists>x. x \<in> s \<and> t = f x}" "finite g" "s \<subseteq> \<Union>g"
   2.526 +  obtain g where g: "g \<subseteq> {t. \<exists>x. x \<in> s \<and> t = f x}" "finite g" "s \<subseteq> \<Union>g"
   2.527      using assms(1)[unfolded compact_eq_heine_borel, THEN spec[where x="{t. \<exists>x. x\<in>s \<and> t = f x}"]]
   2.528      using f by auto
   2.529 -  from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa" by auto
   2.530 +  from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa"
   2.531 +    by auto
   2.532    {
   2.533      fix x y
   2.534 -    assume "x\<in>t" "y\<in>t" "f x = f y"
   2.535 +    assume "x \<in> t" "y \<in> t" "f x = f y"
   2.536      then have "x \<in> f x"  "y \<in> f x \<longrightarrow> y = x"
   2.537 -      using f[THEN bspec[where x=x]] and `t\<subseteq>s` by auto
   2.538 +      using f[THEN bspec[where x=x]] and `t \<subseteq> s` by auto
   2.539      then have "x = y"
   2.540 -      using `f x = f y` and f[THEN bspec[where x=y]] and `y\<in>t` and `t\<subseteq>s` by auto
   2.541 +      using `f x = f y` and f[THEN bspec[where x=y]] and `y \<in> t` and `t \<subseteq> s`
   2.542 +      by auto
   2.543    }
   2.544    then have "inj_on f t"
   2.545      unfolding inj_on_def by simp
   2.546 @@ -2742,14 +2769,17 @@
   2.547    moreover
   2.548    {
   2.549      fix x
   2.550 -    assume "x\<in>t" "f x \<notin> g"
   2.551 -    from g(3) assms(3) `x\<in>t` obtain h where "h\<in>g" and "x\<in>h" by auto
   2.552 -    then obtain y where "y\<in>s" "h = f y"
   2.553 +    assume "x \<in> t" "f x \<notin> g"
   2.554 +    from g(3) assms(3) `x \<in> t` obtain h where "h \<in> g" and "x \<in> h"
   2.555 +      by auto
   2.556 +    then obtain y where "y \<in> s" "h = f y"
   2.557        using g'[THEN bspec[where x=h]] by auto
   2.558      then have "y = x"
   2.559 -      using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`] by auto
   2.560 +      using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`]
   2.561 +      by auto
   2.562      then have False
   2.563 -      using `f x \<notin> g` `h\<in>g` unfolding `h = f y` by auto
   2.564 +      using `f x \<notin> g` `h \<in> g` unfolding `h = f y`
   2.565 +      by auto
   2.566    }
   2.567    then have "f ` t \<subseteq> g" by auto
   2.568    ultimately show False
   2.569 @@ -2786,7 +2816,8 @@
   2.570    proof (rule topological_tendstoI)
   2.571      fix S
   2.572      assume "open S" "l \<in> S"
   2.573 -    with A(3) have "eventually (\<lambda>i. A i \<subseteq> S) sequentially" by auto
   2.574 +    with A(3) have "eventually (\<lambda>i. A i \<subseteq> S) sequentially"
   2.575 +      by auto
   2.576      moreover
   2.577      {
   2.578        fix i
   2.579 @@ -2810,12 +2841,18 @@
   2.580    shows "infinite (range f)"
   2.581  proof
   2.582    assume "finite (range f)"
   2.583 -  then have "closed (range f)" by (rule finite_imp_closed)
   2.584 -  then have "open (- range f)" by (rule open_Compl)
   2.585 -  from assms(1) have "l \<in> - range f" by auto
   2.586 +  then have "closed (range f)"
   2.587 +    by (rule finite_imp_closed)
   2.588 +  then have "open (- range f)"
   2.589 +    by (rule open_Compl)
   2.590 +  from assms(1) have "l \<in> - range f"
   2.591 +    by auto
   2.592    from assms(2) have "eventually (\<lambda>n. f n \<in> - range f) sequentially"
   2.593 -    using `open (- range f)` `l \<in> - range f` by (rule topological_tendstoD)
   2.594 -  then show False unfolding eventually_sequentially by auto
   2.595 +    using `open (- range f)` `l \<in> - range f`
   2.596 +    by (rule topological_tendstoD)
   2.597 +  then show False
   2.598 +    unfolding eventually_sequentially
   2.599 +    by auto
   2.600  qed
   2.601  
   2.602  lemma closure_insert:
   2.603 @@ -2928,7 +2965,7 @@
   2.604  qed
   2.605  
   2.606  lemma bolzano_weierstrass_imp_closed:
   2.607 -  fixes s :: "'a::{first_countable_topology, t2_space} set"
   2.608 +  fixes s :: "'a::{first_countable_topology,t2_space} set"
   2.609    assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)"
   2.610    shows "closed s"
   2.611  proof -
   2.612 @@ -3276,7 +3313,7 @@
   2.613  
   2.614  definition seq_compact :: "'a::topological_space set \<Rightarrow> bool"
   2.615    where "seq_compact S \<longleftrightarrow>
   2.616 -    (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> (\<exists>l\<in>S. \<exists>r. subseq r \<and> ((f o r) ---> l) sequentially))"
   2.617 +    (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> (\<exists>l\<in>S. \<exists>r. subseq r \<and> ((f \<circ> r) ---> l) sequentially))"
   2.618  
   2.619  lemma seq_compact_imp_countably_compact:
   2.620    fixes U :: "'a :: first_countable_topology set"
   2.621 @@ -3391,7 +3428,7 @@
   2.622  qed
   2.623  
   2.624  lemma seq_compactI:
   2.625 -  assumes "\<And>f. \<forall>n. f n \<in> S \<Longrightarrow> \<exists>l\<in>S. \<exists>r. subseq r \<and> ((f o r) ---> l) sequentially"
   2.626 +  assumes "\<And>f. \<forall>n. f n \<in> S \<Longrightarrow> \<exists>l\<in>S. \<exists>r. subseq r \<and> ((f \<circ> r) ---> l) sequentially"
   2.627    shows "seq_compact S"
   2.628    unfolding seq_compact_def using assms by fast
   2.629  
   2.630 @@ -3611,7 +3648,7 @@
   2.631  
   2.632  lemma compact_def:
   2.633    "compact (S :: 'a::metric_space set) \<longleftrightarrow>
   2.634 -   (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> (\<exists>l\<in>S. \<exists>r. subseq r \<and> (f o r) ----> l))"
   2.635 +   (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> (\<exists>l\<in>S. \<exists>r. subseq r \<and> (f \<circ> r) ----> l))"
   2.636    unfolding compact_eq_seq_compact_metric seq_compact_def by auto
   2.637  
   2.638  subsubsection {* Complete the chain of compactness variants *}
   2.639 @@ -4514,7 +4551,7 @@
   2.640    fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
   2.641    shows "continuous (at a within s) f \<longleftrightarrow>
   2.642      (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially
   2.643 -         \<longrightarrow> ((f o x) ---> f a) sequentially)"
   2.644 +         \<longrightarrow> ((f \<circ> x) ---> f a) sequentially)"
   2.645    (is "?lhs = ?rhs")
   2.646  proof
   2.647    assume ?lhs
   2.648 @@ -4546,14 +4583,14 @@
   2.649  lemma continuous_at_sequentially:
   2.650    fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
   2.651    shows "continuous (at a) f \<longleftrightarrow>
   2.652 -    (\<forall>x. (x ---> a) sequentially --> ((f o x) ---> f a) sequentially)"
   2.653 +    (\<forall>x. (x ---> a) sequentially --> ((f \<circ> x) ---> f a) sequentially)"
   2.654    using continuous_within_sequentially[of a UNIV f] by simp
   2.655  
   2.656  lemma continuous_on_sequentially:
   2.657    fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
   2.658    shows "continuous_on s f \<longleftrightarrow>
   2.659      (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially
   2.660 -      --> ((f o x) ---> f(a)) sequentially)"
   2.661 +      --> ((f \<circ> x) ---> f a) sequentially)"
   2.662    (is "?lhs = ?rhs")
   2.663  proof
   2.664    assume ?rhs
   2.665 @@ -4804,8 +4841,8 @@
   2.666  
   2.667  lemma uniformly_continuous_on_compose[continuous_on_intros]:
   2.668    assumes "uniformly_continuous_on s f"  "uniformly_continuous_on (f ` s) g"
   2.669 -  shows "uniformly_continuous_on s (g o f)"
   2.670 -proof-
   2.671 +  shows "uniformly_continuous_on s (g \<circ> f)"
   2.672 +proof -
   2.673    {
   2.674      fix e :: real
   2.675      assume "e > 0"
   2.676 @@ -6818,7 +6855,7 @@
   2.677  
   2.678  lemma Lim_component_eq:
   2.679    fixes f :: "'a \<Rightarrow> 'b::euclidean_space"
   2.680 -  assumes net: "(f ---> l) net" "~(trivial_limit net)"
   2.681 +  assumes net: "(f ---> l) net" "\<not> trivial_limit net"
   2.682      and ev:"eventually (\<lambda>x. f(x)\<bullet>i = b) net"
   2.683    shows "l\<bullet>i = b"
   2.684    using ev[unfolded order_eq_iff eventually_conj_iff]
   2.685 @@ -6887,8 +6924,7 @@
   2.686    (\<forall>x\<in>s. (g(f x) = x)) \<and> (f ` s = t) \<and> continuous_on s f \<and>
   2.687    (\<forall>y\<in>t. (f(g y) = y)) \<and> (g ` t = s) \<and> continuous_on t g"
   2.688  
   2.689 -definition
   2.690 -  homeomorphic :: "'a::topological_space set \<Rightarrow> 'b::topological_space set \<Rightarrow> bool"
   2.691 +definition homeomorphic :: "'a::topological_space set \<Rightarrow> 'b::topological_space set \<Rightarrow> bool"
   2.692      (infixr "homeomorphic" 60)
   2.693    where "s homeomorphic t \<equiv> (\<exists>f g. homeomorphism s t f g)"
   2.694  
   2.695 @@ -7099,12 +7135,12 @@
   2.696  
   2.697  lemma cauchy_isometric:
   2.698    fixes x :: "nat \<Rightarrow> 'a::euclidean_space"
   2.699 -  assumes e: "0 < e"
   2.700 +  assumes e: "e > 0"
   2.701      and s: "subspace s"
   2.702      and f: "bounded_linear f"
   2.703 -    and normf: "\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)"
   2.704 -    and xs: "\<forall>n::nat. x n \<in> s"
   2.705 -    and cf: "Cauchy(f o x)"
   2.706 +    and normf: "\<forall>x\<in>s. norm (f x) \<ge> e * norm x"
   2.707 +    and xs: "\<forall>n. x n \<in> s"
   2.708 +    and cf: "Cauchy (f \<circ> x)"
   2.709    shows "Cauchy x"
   2.710  proof -
   2.711    interpret f: bounded_linear f by fact
   2.712 @@ -7145,24 +7181,31 @@
   2.713      fix g
   2.714      assume as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"Cauchy g"
   2.715      then obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)"
   2.716 -      using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto
   2.717 -    then have x:"\<forall>n. x n \<in> s"  "\<forall>n. g n = f (x n)" by auto
   2.718 -    then have "f \<circ> x = g" unfolding fun_eq_iff by auto
   2.719 +      using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"]
   2.720 +      by auto
   2.721 +    then have x:"\<forall>n. x n \<in> s"  "\<forall>n. g n = f (x n)"
   2.722 +      by auto
   2.723 +    then have "f \<circ> x = g"
   2.724 +      unfolding fun_eq_iff
   2.725 +      by auto
   2.726      then obtain l where "l\<in>s" and l:"(x ---> l) sequentially"
   2.727        using cs[unfolded complete_def, THEN spec[where x="x"]]
   2.728 -      using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1) by auto
   2.729 +      using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1)
   2.730 +      by auto
   2.731      then have "\<exists>l\<in>f ` s. (g ---> l) sequentially"
   2.732        using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l]
   2.733 -      unfolding `f \<circ> x = g` by auto
   2.734 +      unfolding `f \<circ> x = g`
   2.735 +      by auto
   2.736    }
   2.737 -  then show ?thesis unfolding complete_def by auto
   2.738 +  then show ?thesis
   2.739 +    unfolding complete_def by auto
   2.740  qed
   2.741  
   2.742  lemma injective_imp_isometric:
   2.743    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
   2.744    assumes s: "closed s" "subspace s"
   2.745 -    and f: "bounded_linear f" "\<forall>x\<in>s. (f x = 0) \<longrightarrow> (x = 0)"
   2.746 -  shows "\<exists>e>0. \<forall>x\<in>s. norm (f x) \<ge> e * norm(x)"
   2.747 +    and f: "bounded_linear f" "\<forall>x\<in>s. f x = 0 \<longrightarrow> x = 0"
   2.748 +  shows "\<exists>e>0. \<forall>x\<in>s. norm (f x) \<ge> e * norm x"
   2.749  proof (cases "s \<subseteq> {0::'a}")
   2.750    case True
   2.751    {
   2.752 @@ -7175,8 +7218,10 @@
   2.753  next
   2.754    interpret f: bounded_linear f by fact
   2.755    case False
   2.756 -  then obtain a where a:"a\<noteq>0" "a\<in>s" by auto
   2.757 -  from False have "s \<noteq> {}" by auto
   2.758 +  then obtain a where a: "a \<noteq> 0" "a \<in> s"
   2.759 +    by auto
   2.760 +  from False have "s \<noteq> {}"
   2.761 +    by auto
   2.762    let ?S = "{f x| x. (x \<in> s \<and> norm x = norm a)}"
   2.763    let ?S' = "{x::'a. x\<in>s \<and> norm x = norm a}"
   2.764    let ?S'' = "{x::'a. norm x = norm a}"