| 
36583
 | 
     1  | 
(*  Title:      Multivariate_Analysis/Path_Connected.thy
  | 
| 
 | 
     2  | 
    Author:     Robert Himmelmann, TU Muenchen
  | 
| 
 | 
     3  | 
*)
  | 
| 
 | 
     4  | 
  | 
| 
 | 
     5  | 
header {* Continuous paths and path-connected sets *}
 | 
| 
 | 
     6  | 
  | 
| 
 | 
     7  | 
theory Path_Connected
  | 
| 
 | 
     8  | 
imports Convex_Euclidean_Space
  | 
| 
 | 
     9  | 
begin
  | 
| 
 | 
    10  | 
  | 
| 
 | 
    11  | 
subsection {* Paths. *}
 | 
| 
 | 
    12  | 
  | 
| 
 | 
    13  | 
definition
  | 
| 
 | 
    14  | 
  path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
  | 
| 
 | 
    15  | 
  where "path g \<longleftrightarrow> continuous_on {0 .. 1} g"
 | 
| 
 | 
    16  | 
  | 
| 
 | 
    17  | 
definition
  | 
| 
 | 
    18  | 
  pathstart :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a"
  | 
| 
 | 
    19  | 
  where "pathstart g = g 0"
  | 
| 
 | 
    20  | 
  | 
| 
 | 
    21  | 
definition
  | 
| 
 | 
    22  | 
  pathfinish :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a"
  | 
| 
 | 
    23  | 
  where "pathfinish g = g 1"
  | 
| 
 | 
    24  | 
  | 
| 
 | 
    25  | 
definition
  | 
| 
 | 
    26  | 
  path_image :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a set"
  | 
| 
 | 
    27  | 
  where "path_image g = g ` {0 .. 1}"
 | 
| 
 | 
    28  | 
  | 
| 
 | 
    29  | 
definition
  | 
| 
 | 
    30  | 
  reversepath :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a)"
  | 
| 
 | 
    31  | 
  where "reversepath g = (\<lambda>x. g(1 - x))"
  | 
| 
 | 
    32  | 
  | 
| 
 | 
    33  | 
definition
  | 
| 
 | 
    34  | 
  joinpaths :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> (real \<Rightarrow> 'a)"
  | 
| 
 | 
    35  | 
    (infixr "+++" 75)
  | 
| 
 | 
    36  | 
  where "g1 +++ g2 = (\<lambda>x. if x \<le> 1/2 then g1 (2 * x) else g2 (2 * x - 1))"
  | 
| 
 | 
    37  | 
  | 
| 
 | 
    38  | 
definition
  | 
| 
 | 
    39  | 
  simple_path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
  | 
| 
 | 
    40  | 
  where "simple_path g \<longleftrightarrow>
  | 
| 
 | 
    41  | 
  (\<forall>x\<in>{0..1}. \<forall>y\<in>{0..1}. g x = g y \<longrightarrow> x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0)"
 | 
| 
 | 
    42  | 
  | 
| 
 | 
    43  | 
definition
  | 
| 
 | 
    44  | 
  injective_path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
  | 
| 
 | 
    45  | 
  where "injective_path g \<longleftrightarrow> (\<forall>x\<in>{0..1}. \<forall>y\<in>{0..1}. g x = g y \<longrightarrow> x = y)"
 | 
| 
 | 
    46  | 
  | 
| 
 | 
    47  | 
subsection {* Some lemmas about these concepts. *}
 | 
| 
 | 
    48  | 
  | 
| 
 | 
    49  | 
lemma injective_imp_simple_path:
  | 
| 
 | 
    50  | 
  "injective_path g \<Longrightarrow> simple_path g"
  | 
| 
 | 
    51  | 
  unfolding injective_path_def simple_path_def by auto
  | 
| 
 | 
    52  | 
  | 
| 
 | 
    53  | 
lemma path_image_nonempty: "path_image g \<noteq> {}"
 | 
| 
 | 
    54  | 
  unfolding path_image_def image_is_empty interval_eq_empty by auto 
  | 
| 
 | 
    55  | 
  | 
| 
 | 
    56  | 
lemma pathstart_in_path_image[intro]: "(pathstart g) \<in> path_image g"
  | 
| 
 | 
    57  | 
  unfolding pathstart_def path_image_def by auto
  | 
| 
 | 
    58  | 
  | 
| 
 | 
    59  | 
lemma pathfinish_in_path_image[intro]: "(pathfinish g) \<in> path_image g"
  | 
| 
 | 
    60  | 
  unfolding pathfinish_def path_image_def by auto
  | 
| 
 | 
    61  | 
  | 
| 
 | 
    62  | 
lemma connected_path_image[intro]: "path g \<Longrightarrow> connected(path_image g)"
  | 
| 
 | 
    63  | 
  unfolding path_def path_image_def
  | 
| 
 | 
    64  | 
  apply (erule connected_continuous_image)
  | 
| 
 | 
    65  | 
  by(rule convex_connected, rule convex_real_interval)
  | 
| 
 | 
    66  | 
  | 
| 
 | 
    67  | 
lemma compact_path_image[intro]: "path g \<Longrightarrow> compact(path_image g)"
  | 
| 
 | 
    68  | 
  unfolding path_def path_image_def
  | 
| 
 | 
    69  | 
  by (erule compact_continuous_image, rule compact_real_interval)
  | 
| 
 | 
    70  | 
  | 
| 
 | 
    71  | 
lemma reversepath_reversepath[simp]: "reversepath(reversepath g) = g"
  | 
| 
 | 
    72  | 
  unfolding reversepath_def by auto
  | 
| 
 | 
    73  | 
  | 
| 
 | 
    74  | 
lemma pathstart_reversepath[simp]: "pathstart(reversepath g) = pathfinish g"
  | 
| 
 | 
    75  | 
  unfolding pathstart_def reversepath_def pathfinish_def by auto
  | 
| 
 | 
    76  | 
  | 
| 
 | 
    77  | 
lemma pathfinish_reversepath[simp]: "pathfinish(reversepath g) = pathstart g"
  | 
| 
 | 
    78  | 
  unfolding pathstart_def reversepath_def pathfinish_def by auto
  | 
| 
 | 
    79  | 
  | 
| 
 | 
    80  | 
lemma pathstart_join[simp]: "pathstart(g1 +++ g2) = pathstart g1"
  | 
| 
 | 
    81  | 
  unfolding pathstart_def joinpaths_def pathfinish_def by auto
  | 
| 
 | 
    82  | 
  | 
| 
 | 
    83  | 
lemma pathfinish_join[simp]:"pathfinish(g1 +++ g2) = pathfinish g2"
  | 
| 
 | 
    84  | 
  unfolding pathstart_def joinpaths_def pathfinish_def by auto
  | 
| 
 | 
    85  | 
  | 
| 
 | 
    86  | 
lemma path_image_reversepath[simp]: "path_image(reversepath g) = path_image g" proof-
  | 
| 
 | 
    87  | 
  have *:"\<And>g. path_image(reversepath g) \<subseteq> path_image g"
  | 
| 
 | 
    88  | 
    unfolding path_image_def subset_eq reversepath_def Ball_def image_iff apply(rule,rule,erule bexE)  
  | 
| 
 | 
    89  | 
    apply(rule_tac x="1 - xa" in bexI) by auto
  | 
| 
 | 
    90  | 
  show ?thesis using *[of g] *[of "reversepath g"] unfolding reversepath_reversepath by auto qed
  | 
| 
 | 
    91  | 
  | 
| 
 | 
    92  | 
lemma path_reversepath[simp]: "path(reversepath g) \<longleftrightarrow> path g" proof-
  | 
| 
 | 
    93  | 
  have *:"\<And>g. path g \<Longrightarrow> path(reversepath g)" unfolding path_def reversepath_def
  | 
| 
 | 
    94  | 
    apply(rule continuous_on_compose[unfolded o_def, of _ "\<lambda>x. 1 - x"])
  | 
| 
 | 
    95  | 
    apply(rule continuous_on_sub, rule continuous_on_const, rule continuous_on_id)
  | 
| 
 | 
    96  | 
    apply(rule continuous_on_subset[of "{0..1}"], assumption) by auto
 | 
| 
 | 
    97  | 
  show ?thesis using *[of "reversepath g"] *[of g] unfolding reversepath_reversepath by (rule iffI) qed
  | 
| 
 | 
    98  | 
  | 
| 
 | 
    99  | 
lemmas reversepath_simps = path_reversepath path_image_reversepath pathstart_reversepath pathfinish_reversepath
  | 
| 
 | 
   100  | 
  | 
| 
 | 
   101  | 
lemma path_join[simp]: assumes "pathfinish g1 = pathstart g2" shows "path (g1 +++ g2) \<longleftrightarrow>  path g1 \<and> path g2"
  | 
| 
 | 
   102  | 
  unfolding path_def pathfinish_def pathstart_def apply rule defer apply(erule conjE) proof-
  | 
| 
 | 
   103  | 
  assume as:"continuous_on {0..1} (g1 +++ g2)"
 | 
| 
 | 
   104  | 
  have *:"g1 = (\<lambda>x. g1 (2 *\<^sub>R x)) \<circ> (\<lambda>x. (1/2) *\<^sub>R x)" 
  | 
| 
 | 
   105  | 
         "g2 = (\<lambda>x. g2 (2 *\<^sub>R x - 1)) \<circ> (\<lambda>x. (1/2) *\<^sub>R (x + 1))"
  | 
| 
 | 
   106  | 
    unfolding o_def by (auto simp add: add_divide_distrib)
  | 
| 
 | 
   107  | 
  have "op *\<^sub>R (1 / 2) ` {0::real..1} \<subseteq> {0..1}"  "(\<lambda>x. (1 / 2) *\<^sub>R (x + 1)) ` {(0::real)..1} \<subseteq> {0..1}"
 | 
| 
 | 
   108  | 
    by auto
  | 
| 
 | 
   109  | 
  thus "continuous_on {0..1} g1 \<and> continuous_on {0..1} g2" apply -apply rule
 | 
| 
 | 
   110  | 
    apply(subst *) defer apply(subst *) apply (rule_tac[!] continuous_on_compose)
  | 
| 
 | 
   111  | 
    apply (rule continuous_on_cmul, rule continuous_on_add, rule continuous_on_id, rule continuous_on_const) defer
  | 
| 
 | 
   112  | 
    apply (rule continuous_on_cmul, rule continuous_on_id) apply(rule_tac[!] continuous_on_eq[of _ "g1 +++ g2"]) defer prefer 3
  | 
| 
 | 
   113  | 
    apply(rule_tac[1-2] continuous_on_subset[of "{0 .. 1}"]) apply(rule as, assumption, rule as, assumption)
 | 
| 
 | 
   114  | 
    apply(rule) defer apply rule proof-
  | 
| 
 | 
   115  | 
    fix x assume "x \<in> op *\<^sub>R (1 / 2) ` {0::real..1}"
 | 
| 
 | 
   116  | 
    hence "x \<le> 1 / 2" unfolding image_iff by auto
  | 
| 
 | 
   117  | 
    thus "(g1 +++ g2) x = g1 (2 *\<^sub>R x)" unfolding joinpaths_def by auto next
  | 
| 
 | 
   118  | 
    fix x assume "x \<in> (\<lambda>x. (1 / 2) *\<^sub>R (x + 1)) ` {0::real..1}"
 | 
| 
 | 
   119  | 
    hence "x \<ge> 1 / 2" unfolding image_iff by auto
  | 
| 
 | 
   120  | 
    thus "(g1 +++ g2) x = g2 (2 *\<^sub>R x - 1)" proof(cases "x = 1 / 2")
  | 
| 
 | 
   121  | 
      case True hence "x = (1/2) *\<^sub>R 1" unfolding Cart_eq by auto
  | 
| 
 | 
   122  | 
      thus ?thesis unfolding joinpaths_def using assms[unfolded pathstart_def pathfinish_def] by (auto simp add: mult_ac)
  | 
| 
 | 
   123  | 
    qed (auto simp add:le_less joinpaths_def) qed
  | 
| 
 | 
   124  | 
next assume as:"continuous_on {0..1} g1" "continuous_on {0..1} g2"
 | 
| 
 | 
   125  | 
  have *:"{0 .. 1::real} = {0.. (1/2)*\<^sub>R 1} \<union> {(1/2) *\<^sub>R 1 .. 1}" by auto
 | 
| 
 | 
   126  | 
  have **:"op *\<^sub>R 2 ` {0..(1 / 2) *\<^sub>R 1} = {0..1::real}" apply(rule set_ext, rule) unfolding image_iff 
 | 
| 
 | 
   127  | 
    defer apply(rule_tac x="(1/2)*\<^sub>R x" in bexI) by auto
  | 
| 
 | 
   128  | 
  have ***:"(\<lambda>x. 2 *\<^sub>R x - 1) ` {(1 / 2) *\<^sub>R 1..1} = {0..1::real}"
 | 
| 
 | 
   129  | 
    apply (auto simp add: image_def)
  | 
| 
 | 
   130  | 
    apply (rule_tac x="(x + 1) / 2" in bexI)
  | 
| 
 | 
   131  | 
    apply (auto simp add: add_divide_distrib)
  | 
| 
 | 
   132  | 
    done
  | 
| 
 | 
   133  | 
  show "continuous_on {0..1} (g1 +++ g2)" unfolding * apply(rule continuous_on_union) apply (rule closed_real_atLeastAtMost)+ proof-
 | 
| 
 | 
   134  | 
    show "continuous_on {0..(1 / 2) *\<^sub>R 1} (g1 +++ g2)" apply(rule continuous_on_eq[of _ "\<lambda>x. g1 (2 *\<^sub>R x)"]) defer
 | 
| 
 | 
   135  | 
      unfolding o_def[THEN sym] apply(rule continuous_on_compose) apply(rule continuous_on_cmul, rule continuous_on_id)
  | 
| 
 | 
   136  | 
      unfolding ** apply(rule as(1)) unfolding joinpaths_def by auto next
  | 
| 
 | 
   137  | 
    show "continuous_on {(1/2)*\<^sub>R1..1} (g1 +++ g2)" apply(rule continuous_on_eq[of _ "g2 \<circ> (\<lambda>x. 2 *\<^sub>R x - 1)"]) defer
 | 
| 
 | 
   138  | 
      apply(rule continuous_on_compose) apply(rule continuous_on_sub, rule continuous_on_cmul, rule continuous_on_id, rule continuous_on_const)
  | 
| 
 | 
   139  | 
      unfolding *** o_def joinpaths_def apply(rule as(2)) using assms[unfolded pathstart_def pathfinish_def]
  | 
| 
 | 
   140  | 
      by (auto simp add: mult_ac) qed qed
  | 
| 
 | 
   141  | 
  | 
| 
 | 
   142  | 
lemma path_image_join_subset: "path_image(g1 +++ g2) \<subseteq> (path_image g1 \<union> path_image g2)" proof
  | 
| 
 | 
   143  | 
  fix x assume "x \<in> path_image (g1 +++ g2)"
  | 
| 
 | 
   144  | 
  then obtain y where y:"y\<in>{0..1}" "x = (if y \<le> 1 / 2 then g1 (2 *\<^sub>R y) else g2 (2 *\<^sub>R y - 1))"
 | 
| 
 | 
   145  | 
    unfolding path_image_def image_iff joinpaths_def by auto
  | 
| 
 | 
   146  | 
  thus "x \<in> path_image g1 \<union> path_image g2" apply(cases "y \<le> 1/2")
  | 
| 
 | 
   147  | 
    apply(rule_tac UnI1) defer apply(rule_tac UnI2) unfolding y(2) path_image_def using y(1)
  | 
| 
 | 
   148  | 
    by(auto intro!: imageI) qed
  | 
| 
 | 
   149  | 
  | 
| 
 | 
   150  | 
lemma subset_path_image_join:
  | 
| 
 | 
   151  | 
  assumes "path_image g1 \<subseteq> s" "path_image g2 \<subseteq> s" shows "path_image(g1 +++ g2) \<subseteq> s"
  | 
| 
 | 
   152  | 
  using path_image_join_subset[of g1 g2] and assms by auto
  | 
| 
 | 
   153  | 
  | 
| 
 | 
   154  | 
lemma path_image_join:
  | 
| 
 | 
   155  | 
  assumes "path g1" "path g2" "pathfinish g1 = pathstart g2"
  | 
| 
 | 
   156  | 
  shows "path_image(g1 +++ g2) = (path_image g1) \<union> (path_image g2)"
  | 
| 
 | 
   157  | 
apply(rule, rule path_image_join_subset, rule) unfolding Un_iff proof(erule disjE)
  | 
| 
 | 
   158  | 
  fix x assume "x \<in> path_image g1"
  | 
| 
 | 
   159  | 
  then obtain y where y:"y\<in>{0..1}" "x = g1 y" unfolding path_image_def image_iff by auto
 | 
| 
 | 
   160  | 
  thus "x \<in> path_image (g1 +++ g2)" unfolding joinpaths_def path_image_def image_iff
  | 
| 
 | 
   161  | 
    apply(rule_tac x="(1/2) *\<^sub>R y" in bexI) by auto next
  | 
| 
 | 
   162  | 
  fix x assume "x \<in> path_image g2"
  | 
| 
 | 
   163  | 
  then obtain y where y:"y\<in>{0..1}" "x = g2 y" unfolding path_image_def image_iff by auto
 | 
| 
 | 
   164  | 
  then show "x \<in> path_image (g1 +++ g2)" unfolding joinpaths_def path_image_def image_iff
  | 
| 
 | 
   165  | 
    apply(rule_tac x="(1/2) *\<^sub>R (y + 1)" in bexI) using assms(3)[unfolded pathfinish_def pathstart_def]
  | 
| 
 | 
   166  | 
    by (auto simp add: add_divide_distrib) qed
  | 
| 
 | 
   167  | 
  | 
| 
 | 
   168  | 
lemma not_in_path_image_join:
  | 
| 
 | 
   169  | 
  assumes "x \<notin> path_image g1" "x \<notin> path_image g2" shows "x \<notin> path_image(g1 +++ g2)"
  | 
| 
 | 
   170  | 
  using assms and path_image_join_subset[of g1 g2] by auto
  | 
| 
 | 
   171  | 
  | 
| 
 | 
   172  | 
lemma simple_path_reversepath: assumes "simple_path g" shows "simple_path (reversepath g)"
  | 
| 
 | 
   173  | 
  using assms unfolding simple_path_def reversepath_def apply- apply(rule ballI)+
  | 
| 
 | 
   174  | 
  apply(erule_tac x="1-x" in ballE, erule_tac x="1-y" in ballE)
  | 
| 
 | 
   175  | 
  by auto
  | 
| 
 | 
   176  | 
  | 
| 
 | 
   177  | 
lemma simple_path_join_loop:
  | 
| 
 | 
   178  | 
  assumes "injective_path g1" "injective_path g2" "pathfinish g2 = pathstart g1"
  | 
| 
 | 
   179  | 
  "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g1,pathstart g2}"
 | 
| 
 | 
   180  | 
  shows "simple_path(g1 +++ g2)"
  | 
| 
 | 
   181  | 
unfolding simple_path_def proof((rule ballI)+, rule impI) let ?g = "g1 +++ g2"
  | 
| 
 | 
   182  | 
  note inj = assms(1,2)[unfolded injective_path_def, rule_format]
  | 
| 
 | 
   183  | 
  fix x y::"real" assume xy:"x \<in> {0..1}" "y \<in> {0..1}" "?g x = ?g y"
 | 
| 
 | 
   184  | 
  show "x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0" proof(case_tac "x \<le> 1/2",case_tac[!] "y \<le> 1/2", unfold not_le)
  | 
| 
 | 
   185  | 
    assume as:"x \<le> 1 / 2" "y \<le> 1 / 2"
  | 
| 
 | 
   186  | 
    hence "g1 (2 *\<^sub>R x) = g1 (2 *\<^sub>R y)" using xy(3) unfolding joinpaths_def by auto
  | 
| 
 | 
   187  | 
    moreover have "2 *\<^sub>R x \<in> {0..1}" "2 *\<^sub>R y \<in> {0..1}" using xy(1,2) as
 | 
| 
 | 
   188  | 
      by auto
  | 
| 
 | 
   189  | 
    ultimately show ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] by auto
  | 
| 
 | 
   190  | 
  next assume as:"x > 1 / 2" "y > 1 / 2"
  | 
| 
 | 
   191  | 
    hence "g2 (2 *\<^sub>R x - 1) = g2 (2 *\<^sub>R y - 1)" using xy(3) unfolding joinpaths_def by auto
  | 
| 
 | 
   192  | 
    moreover have "2 *\<^sub>R x - 1 \<in> {0..1}" "2 *\<^sub>R y - 1 \<in> {0..1}" using xy(1,2) as by auto
 | 
| 
 | 
   193  | 
    ultimately show ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] by auto
  | 
| 
 | 
   194  | 
  next assume as:"x \<le> 1 / 2" "y > 1 / 2"
  | 
| 
 | 
   195  | 
    hence "?g x \<in> path_image g1" "?g y \<in> path_image g2" unfolding path_image_def joinpaths_def
  | 
| 
 | 
   196  | 
      using xy(1,2) by auto
  | 
| 
 | 
   197  | 
    moreover have "?g y \<noteq> pathstart g2" using as(2) unfolding pathstart_def joinpaths_def
  | 
| 
 | 
   198  | 
      using inj(2)[of "2 *\<^sub>R y - 1" 0] and xy(2)
  | 
| 
 | 
   199  | 
      by (auto simp add: field_simps)
  | 
| 
 | 
   200  | 
    ultimately have *:"?g x = pathstart g1" using assms(4) unfolding xy(3) by auto
  | 
| 
 | 
   201  | 
    hence "x = 0" unfolding pathstart_def joinpaths_def using as(1) and xy(1)
  | 
| 
 | 
   202  | 
      using inj(1)[of "2 *\<^sub>R x" 0] by auto
  | 
| 
 | 
   203  | 
    moreover have "y = 1" using * unfolding xy(3) assms(3)[THEN sym]
  | 
| 
 | 
   204  | 
      unfolding joinpaths_def pathfinish_def using as(2) and xy(2)
  | 
| 
 | 
   205  | 
      using inj(2)[of "2 *\<^sub>R y - 1" 1] by auto
  | 
| 
 | 
   206  | 
    ultimately show ?thesis by auto
  | 
| 
 | 
   207  | 
  next assume as:"x > 1 / 2" "y \<le> 1 / 2"
  | 
| 
 | 
   208  | 
    hence "?g x \<in> path_image g2" "?g y \<in> path_image g1" unfolding path_image_def joinpaths_def
  | 
| 
 | 
   209  | 
      using xy(1,2) by auto
  | 
| 
 | 
   210  | 
    moreover have "?g x \<noteq> pathstart g2" using as(1) unfolding pathstart_def joinpaths_def
  | 
| 
 | 
   211  | 
      using inj(2)[of "2 *\<^sub>R x - 1" 0] and xy(1)
  | 
| 
 | 
   212  | 
      by (auto simp add: field_simps)
  | 
| 
 | 
   213  | 
    ultimately have *:"?g y = pathstart g1" using assms(4) unfolding xy(3) by auto
  | 
| 
 | 
   214  | 
    hence "y = 0" unfolding pathstart_def joinpaths_def using as(2) and xy(2)
  | 
| 
 | 
   215  | 
      using inj(1)[of "2 *\<^sub>R y" 0] by auto
  | 
| 
 | 
   216  | 
    moreover have "x = 1" using * unfolding xy(3)[THEN sym] assms(3)[THEN sym]
  | 
| 
 | 
   217  | 
      unfolding joinpaths_def pathfinish_def using as(1) and xy(1)
  | 
| 
 | 
   218  | 
      using inj(2)[of "2 *\<^sub>R x - 1" 1] by auto
  | 
| 
 | 
   219  | 
    ultimately show ?thesis by auto qed qed
  | 
| 
 | 
   220  | 
  | 
| 
 | 
   221  | 
lemma injective_path_join:
  | 
| 
 | 
   222  | 
  assumes "injective_path g1" "injective_path g2" "pathfinish g1 = pathstart g2"
  | 
| 
 | 
   223  | 
  "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g2}"
 | 
| 
 | 
   224  | 
  shows "injective_path(g1 +++ g2)"
  | 
| 
 | 
   225  | 
  unfolding injective_path_def proof(rule,rule,rule) let ?g = "g1 +++ g2"
  | 
| 
 | 
   226  | 
  note inj = assms(1,2)[unfolded injective_path_def, rule_format]
  | 
| 
 | 
   227  | 
  fix x y assume xy:"x \<in> {0..1}" "y \<in> {0..1}" "(g1 +++ g2) x = (g1 +++ g2) y"
 | 
| 
 | 
   228  | 
  show "x = y" proof(cases "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
  | 
| 
 | 
   229  | 
    assume "x \<le> 1 / 2" "y \<le> 1 / 2" thus ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] and xy
  | 
| 
 | 
   230  | 
      unfolding joinpaths_def by auto
  | 
| 
 | 
   231  | 
  next assume "x > 1 / 2" "y > 1 / 2" thus ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] and xy
  | 
| 
 | 
   232  | 
      unfolding joinpaths_def by auto
  | 
| 
 | 
   233  | 
  next assume as:"x \<le> 1 / 2" "y > 1 / 2" 
  | 
| 
 | 
   234  | 
    hence "?g x \<in> path_image g1" "?g y \<in> path_image g2" unfolding path_image_def joinpaths_def
  | 
| 
 | 
   235  | 
      using xy(1,2) by auto
  | 
| 
 | 
   236  | 
    hence "?g x = pathfinish g1" "?g y = pathstart g2" using assms(4) unfolding assms(3) xy(3) by auto
  | 
| 
 | 
   237  | 
    thus ?thesis using as and inj(1)[of "2 *\<^sub>R x" 1] inj(2)[of "2 *\<^sub>R y - 1" 0] and xy(1,2)
  | 
| 
 | 
   238  | 
      unfolding pathstart_def pathfinish_def joinpaths_def
  | 
| 
 | 
   239  | 
      by auto
  | 
| 
 | 
   240  | 
  next assume as:"x > 1 / 2" "y \<le> 1 / 2" 
  | 
| 
 | 
   241  | 
    hence "?g x \<in> path_image g2" "?g y \<in> path_image g1" unfolding path_image_def joinpaths_def
  | 
| 
 | 
   242  | 
      using xy(1,2) by auto
  | 
| 
 | 
   243  | 
    hence "?g x = pathstart g2" "?g y = pathfinish g1" using assms(4) unfolding assms(3) xy(3) by auto
  | 
| 
 | 
   244  | 
    thus ?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)
  | 
| 
 | 
   245  | 
      unfolding pathstart_def pathfinish_def joinpaths_def
  | 
| 
 | 
   246  | 
      by auto qed qed
  | 
| 
 | 
   247  | 
  | 
| 
 | 
   248  | 
lemmas join_paths_simps = path_join path_image_join pathstart_join pathfinish_join
  | 
| 
 | 
   249  | 
 
  | 
| 
 | 
   250  | 
subsection {* Reparametrizing a closed curve to start at some chosen point. *}
 | 
| 
 | 
   251  | 
  | 
| 
 | 
   252  | 
definition "shiftpath a (f::real \<Rightarrow> 'a::topological_space) =
  | 
| 
 | 
   253  | 
  (\<lambda>x. if (a + x) \<le> 1 then f(a + x) else f(a + x - 1))"
  | 
| 
 | 
   254  | 
  | 
| 
 | 
   255  | 
lemma pathstart_shiftpath: "a \<le> 1 \<Longrightarrow> pathstart(shiftpath a g) = g a"
  | 
| 
 | 
   256  | 
  unfolding pathstart_def shiftpath_def by auto
  | 
| 
 | 
   257  | 
  | 
| 
 | 
   258  | 
lemma pathfinish_shiftpath: assumes "0 \<le> a" "pathfinish g = pathstart g"
  | 
| 
 | 
   259  | 
  shows "pathfinish(shiftpath a g) = g a"
  | 
| 
 | 
   260  | 
  using assms unfolding pathstart_def pathfinish_def shiftpath_def
  | 
| 
 | 
   261  | 
  by auto
  | 
| 
 | 
   262  | 
  | 
| 
 | 
   263  | 
lemma endpoints_shiftpath:
  | 
| 
 | 
   264  | 
  assumes "pathfinish g = pathstart g" "a \<in> {0 .. 1}" 
 | 
| 
 | 
   265  | 
  shows "pathfinish(shiftpath a g) = g a" "pathstart(shiftpath a g) = g a"
  | 
| 
 | 
   266  | 
  using assms by(auto intro!:pathfinish_shiftpath pathstart_shiftpath)
  | 
| 
 | 
   267  | 
  | 
| 
 | 
   268  | 
lemma closed_shiftpath:
  | 
| 
 | 
   269  | 
  assumes "pathfinish g = pathstart g" "a \<in> {0..1}"
 | 
| 
 | 
   270  | 
  shows "pathfinish(shiftpath a g) = pathstart(shiftpath a g)"
  | 
| 
 | 
   271  | 
  using endpoints_shiftpath[OF assms] by auto
  | 
| 
 | 
   272  | 
  | 
| 
 | 
   273  | 
lemma path_shiftpath:
  | 
| 
 | 
   274  | 
  assumes "path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
 | 
| 
 | 
   275  | 
  shows "path(shiftpath a g)" proof-
  | 
| 
 | 
   276  | 
  have *:"{0 .. 1} = {0 .. 1-a} \<union> {1-a .. 1}" using assms(3) by auto
 | 
| 
 | 
   277  | 
  have **:"\<And>x. x + a = 1 \<Longrightarrow> g (x + a - 1) = g (x + a)"
  | 
| 
 | 
   278  | 
    using assms(2)[unfolded pathfinish_def pathstart_def] by auto
  | 
| 
 | 
   279  | 
  show ?thesis unfolding path_def shiftpath_def * apply(rule continuous_on_union)
  | 
| 
 | 
   280  | 
    apply(rule closed_real_atLeastAtMost)+ apply(rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a + x)"]) prefer 3
  | 
| 
 | 
   281  | 
    apply(rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a - 1 + x)"]) defer prefer 3
  | 
| 
 | 
   282  | 
    apply(rule continuous_on_intros)+ prefer 2 apply(rule continuous_on_intros)+
  | 
| 
 | 
   283  | 
    apply(rule_tac[1-2] continuous_on_subset[OF assms(1)[unfolded path_def]])
  | 
| 
 | 
   284  | 
    using assms(3) and ** by(auto, auto simp add: field_simps) qed
  | 
| 
 | 
   285  | 
  | 
| 
 | 
   286  | 
lemma shiftpath_shiftpath: assumes "pathfinish g = pathstart g" "a \<in> {0..1}" "x \<in> {0..1}" 
 | 
| 
 | 
   287  | 
  shows "shiftpath (1 - a) (shiftpath a g) x = g x"
  | 
| 
 | 
   288  | 
  using assms unfolding pathfinish_def pathstart_def shiftpath_def by auto
  | 
| 
 | 
   289  | 
  | 
| 
 | 
   290  | 
lemma path_image_shiftpath:
  | 
| 
 | 
   291  | 
  assumes "a \<in> {0..1}" "pathfinish g = pathstart g"
 | 
| 
 | 
   292  | 
  shows "path_image(shiftpath a g) = path_image g" proof-
  | 
| 
 | 
   293  | 
  { fix x 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)" 
 | 
| 
 | 
   294  | 
    hence "\<exists>y\<in>{0..1} \<inter> {x. a + x \<le> 1}. g x = g (a + y)" proof(cases "a \<le> x")
 | 
| 
 | 
   295  | 
      case False thus ?thesis apply(rule_tac x="1 + x - a" in bexI)
  | 
| 
 | 
   296  | 
        using as(1,2) and as(3)[THEN bspec[where x="1 + x - a"]] and assms(1)
  | 
| 
 | 
   297  | 
        by(auto simp add: field_simps atomize_not) next
  | 
| 
 | 
   298  | 
      case True thus ?thesis using as(1-2) and assms(1) apply(rule_tac x="x - a" in bexI)
  | 
| 
 | 
   299  | 
        by(auto simp add: field_simps) qed }
  | 
| 
 | 
   300  | 
  thus ?thesis using assms unfolding shiftpath_def path_image_def pathfinish_def pathstart_def
  | 
| 
 | 
   301  | 
    by(auto simp add: image_iff) qed
  | 
| 
 | 
   302  | 
  | 
| 
 | 
   303  | 
subsection {* Special case of straight-line paths. *}
 | 
| 
 | 
   304  | 
  | 
| 
 | 
   305  | 
definition
  | 
| 
 | 
   306  | 
  linepath :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> real \<Rightarrow> 'a" where
  | 
| 
 | 
   307  | 
  "linepath a b = (\<lambda>x. (1 - x) *\<^sub>R a + x *\<^sub>R b)"
  | 
| 
 | 
   308  | 
  | 
| 
 | 
   309  | 
lemma pathstart_linepath[simp]: "pathstart(linepath a b) = a"
  | 
| 
 | 
   310  | 
  unfolding pathstart_def linepath_def by auto
  | 
| 
 | 
   311  | 
  | 
| 
 | 
   312  | 
lemma pathfinish_linepath[simp]: "pathfinish(linepath a b) = b"
  | 
| 
 | 
   313  | 
  unfolding pathfinish_def linepath_def by auto
  | 
| 
 | 
   314  | 
  | 
| 
 | 
   315  | 
lemma continuous_linepath_at[intro]: "continuous (at x) (linepath a b)"
  | 
| 
 | 
   316  | 
  unfolding linepath_def by (intro continuous_intros)
  | 
| 
 | 
   317  | 
  | 
| 
 | 
   318  | 
lemma continuous_on_linepath[intro]: "continuous_on s (linepath a b)"
  | 
| 
 | 
   319  | 
  using continuous_linepath_at by(auto intro!: continuous_at_imp_continuous_on)
  | 
| 
 | 
   320  | 
  | 
| 
 | 
   321  | 
lemma path_linepath[intro]: "path(linepath a b)"
  | 
| 
 | 
   322  | 
  unfolding path_def by(rule continuous_on_linepath)
  | 
| 
 | 
   323  | 
  | 
| 
 | 
   324  | 
lemma path_image_linepath[simp]: "path_image(linepath a b) = (closed_segment a b)"
  | 
| 
 | 
   325  | 
  unfolding path_image_def segment linepath_def apply (rule set_ext, rule) defer
  | 
| 
 | 
   326  | 
  unfolding mem_Collect_eq image_iff apply(erule exE) apply(rule_tac x="u *\<^sub>R 1" in bexI)
  | 
| 
 | 
   327  | 
  by auto
  | 
| 
 | 
   328  | 
  | 
| 
 | 
   329  | 
lemma reversepath_linepath[simp]:  "reversepath(linepath a b) = linepath b a"
  | 
| 
 | 
   330  | 
  unfolding reversepath_def linepath_def by(rule ext, auto)
  | 
| 
 | 
   331  | 
  | 
| 
 | 
   332  | 
lemma injective_path_linepath:
  | 
| 
 | 
   333  | 
  assumes "a \<noteq> b" shows "injective_path(linepath a b)"
  | 
| 
 | 
   334  | 
proof -
  | 
| 
 | 
   335  | 
  { fix x y :: "real"
 | 
| 
 | 
   336  | 
    assume "x *\<^sub>R b + y *\<^sub>R a = x *\<^sub>R a + y *\<^sub>R b"
  | 
| 
 | 
   337  | 
    hence "(x - y) *\<^sub>R a = (x - y) *\<^sub>R b" by (simp add: algebra_simps)
  | 
| 
 | 
   338  | 
    with assms have "x = y" by simp }
  | 
| 
 | 
   339  | 
  thus ?thesis unfolding injective_path_def linepath_def by(auto simp add: algebra_simps) qed
  | 
| 
 | 
   340  | 
  | 
| 
 | 
   341  | 
lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path(linepath a b)" by(auto intro!: injective_imp_simple_path injective_path_linepath)
  | 
| 
 | 
   342  | 
  | 
| 
 | 
   343  | 
subsection {* Bounding a point away from a path. *}
 | 
| 
 | 
   344  | 
  | 
| 
 | 
   345  | 
lemma not_on_path_ball:
  | 
| 
 | 
   346  | 
  fixes g :: "real \<Rightarrow> 'a::heine_borel"
  | 
| 
 | 
   347  | 
  assumes "path g" "z \<notin> path_image g"
  | 
| 
 | 
   348  | 
  shows "\<exists>e>0. ball z e \<inter> (path_image g) = {}" proof-
 | 
| 
 | 
   349  | 
  obtain a where "a\<in>path_image g" "\<forall>y\<in>path_image g. dist z a \<le> dist z y"
  | 
| 
 | 
   350  | 
    using distance_attains_inf[OF _ path_image_nonempty, of g z]
  | 
| 
 | 
   351  | 
    using compact_path_image[THEN compact_imp_closed, OF assms(1)] by auto
  | 
| 
 | 
   352  | 
  thus ?thesis apply(rule_tac x="dist z a" in exI) using assms(2) by(auto intro!: dist_pos_lt) qed
  | 
| 
 | 
   353  | 
  | 
| 
 | 
   354  | 
lemma not_on_path_cball:
  | 
| 
 | 
   355  | 
  fixes g :: "real \<Rightarrow> 'a::heine_borel"
  | 
| 
 | 
   356  | 
  assumes "path g" "z \<notin> path_image g"
  | 
| 
 | 
   357  | 
  shows "\<exists>e>0. cball z e \<inter> (path_image g) = {}" proof-
 | 
| 
 | 
   358  | 
  obtain e where "ball z e \<inter> path_image g = {}" "e>0" using not_on_path_ball[OF assms] by auto
 | 
| 
 | 
   359  | 
  moreover have "cball z (e/2) \<subseteq> ball z e" using `e>0` by auto
  | 
| 
 | 
   360  | 
  ultimately show ?thesis apply(rule_tac x="e/2" in exI) by auto qed
  | 
| 
 | 
   361  | 
  | 
| 
 | 
   362  | 
subsection {* Path component, considered as a "joinability" relation (from Tom Hales). *}
 | 
| 
 | 
   363  | 
  | 
| 
 | 
   364  | 
definition "path_component s x y \<longleftrightarrow> (\<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)"
  | 
| 
 | 
   365  | 
  | 
| 
 | 
   366  | 
lemmas path_defs = path_def pathstart_def pathfinish_def path_image_def path_component_def 
  | 
| 
 | 
   367  | 
  | 
| 
 | 
   368  | 
lemma path_component_mem: assumes "path_component s x y" shows "x \<in> s" "y \<in> s"
  | 
| 
 | 
   369  | 
  using assms unfolding path_defs by auto
  | 
| 
 | 
   370  | 
  | 
| 
 | 
   371  | 
lemma path_component_refl: assumes "x \<in> s" shows "path_component s x x"
  | 
| 
 | 
   372  | 
  unfolding path_defs apply(rule_tac x="\<lambda>u. x" in exI) using assms 
  | 
| 
 | 
   373  | 
  by(auto intro!:continuous_on_intros)
  | 
| 
 | 
   374  | 
  | 
| 
 | 
   375  | 
lemma path_component_refl_eq: "path_component s x x \<longleftrightarrow> x \<in> s"
  | 
| 
 | 
   376  | 
  by(auto intro!: path_component_mem path_component_refl)
  | 
| 
 | 
   377  | 
  | 
| 
 | 
   378  | 
lemma path_component_sym: "path_component s x y \<Longrightarrow> path_component s y x"
  | 
| 
 | 
   379  | 
  using assms unfolding path_component_def apply(erule exE) apply(rule_tac x="reversepath g" in exI)
  | 
| 
 | 
   380  | 
  by auto
  | 
| 
 | 
   381  | 
  | 
| 
 | 
   382  | 
lemma path_component_trans: assumes "path_component s x y" "path_component s y z" shows "path_component s x z"
  | 
| 
 | 
   383  | 
  using assms unfolding path_component_def apply- apply(erule exE)+ apply(rule_tac x="g +++ ga" in exI) by(auto simp add: path_image_join)
  | 
| 
 | 
   384  | 
  | 
| 
 | 
   385  | 
lemma path_component_of_subset: "s \<subseteq> t \<Longrightarrow>  path_component s x y \<Longrightarrow> path_component t x y"
  | 
| 
 | 
   386  | 
  unfolding path_component_def by auto
  | 
| 
 | 
   387  | 
  | 
| 
 | 
   388  | 
subsection {* Can also consider it as a set, as the name suggests. *}
 | 
| 
 | 
   389  | 
  | 
| 
 | 
   390  | 
lemma path_component_set: "path_component s x = { y. (\<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y )}"
 | 
| 
 | 
   391  | 
  apply(rule set_ext) unfolding mem_Collect_eq unfolding mem_def path_component_def by auto
  | 
| 
 | 
   392  | 
  | 
| 
 | 
   393  | 
lemma mem_path_component_set:"x \<in> path_component s y \<longleftrightarrow> path_component s y x" unfolding mem_def by auto
  | 
| 
 | 
   394  | 
  | 
| 
 | 
   395  | 
lemma path_component_subset: "(path_component s x) \<subseteq> s"
  | 
| 
 | 
   396  | 
  apply(rule, rule path_component_mem(2)) by(auto simp add:mem_def)
  | 
| 
 | 
   397  | 
  | 
| 
 | 
   398  | 
lemma path_component_eq_empty: "path_component s x = {} \<longleftrightarrow> x \<notin> s"
 | 
| 
 | 
   399  | 
  apply rule apply(drule equals0D[of _ x]) defer apply(rule equals0I) unfolding mem_path_component_set
  | 
| 
 | 
   400  | 
  apply(drule path_component_mem(1)) using path_component_refl by auto
  | 
| 
 | 
   401  | 
  | 
| 
 | 
   402  | 
subsection {* Path connectedness of a space. *}
 | 
| 
 | 
   403  | 
  | 
| 
 | 
   404  | 
definition "path_connected s \<longleftrightarrow> (\<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)"
  | 
| 
 | 
   405  | 
  | 
| 
 | 
   406  | 
lemma path_connected_component: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. path_component s x y)"
  | 
| 
 | 
   407  | 
  unfolding path_connected_def path_component_def by auto
  | 
| 
 | 
   408  | 
  | 
| 
 | 
   409  | 
lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. path_component s x = s)" 
  | 
| 
 | 
   410  | 
  unfolding path_connected_component apply(rule, rule, rule, rule path_component_subset) 
  | 
| 
 | 
   411  | 
  unfolding subset_eq mem_path_component_set Ball_def mem_def by auto
  | 
| 
 | 
   412  | 
  | 
| 
 | 
   413  | 
subsection {* Some useful lemmas about path-connectedness. *}
 | 
| 
 | 
   414  | 
  | 
| 
 | 
   415  | 
lemma convex_imp_path_connected:
  | 
| 
 | 
   416  | 
  fixes s :: "'a::real_normed_vector set"
  | 
| 
 | 
   417  | 
  assumes "convex s" shows "path_connected s"
  | 
| 
 | 
   418  | 
  unfolding path_connected_def apply(rule,rule,rule_tac x="linepath x y" in exI)
  | 
| 
 | 
   419  | 
  unfolding path_image_linepath using assms[unfolded convex_contains_segment] by auto
  | 
| 
 | 
   420  | 
  | 
| 
 | 
   421  | 
lemma path_connected_imp_connected: assumes "path_connected s" shows "connected s"
  | 
| 
 | 
   422  | 
  unfolding connected_def not_ex apply(rule,rule,rule ccontr) unfolding not_not apply(erule conjE)+ proof-
  | 
| 
 | 
   423  | 
  fix e1 e2 assume as:"open e1" "open e2" "s \<subseteq> e1 \<union> e2" "e1 \<inter> e2 \<inter> s = {}" "e1 \<inter> s \<noteq> {}" "e2 \<inter> s \<noteq> {}"
 | 
| 
 | 
   424  | 
  then obtain x1 x2 where obt:"x1\<in>e1\<inter>s" "x2\<in>e2\<inter>s" by auto
  | 
| 
 | 
   425  | 
  then obtain g where g:"path g" "path_image g \<subseteq> s" "pathstart g = x1" "pathfinish g = x2"
  | 
| 
 | 
   426  | 
    using assms[unfolded path_connected_def,rule_format,of x1 x2] by auto
  | 
| 
 | 
   427  | 
  have *:"connected {0..1::real}" by(auto intro!: convex_connected convex_real_interval)
 | 
| 
 | 
   428  | 
  have "{0..1} \<subseteq> {x \<in> {0..1}. g x \<in> e1} \<union> {x \<in> {0..1}. g x \<in> e2}" using as(3) g(2)[unfolded path_defs] by blast
 | 
| 
 | 
   429  | 
  moreover have "{x \<in> {0..1}. g x \<in> e1} \<inter> {x \<in> {0..1}. g x \<in> e2} = {}" using as(4) g(2)[unfolded path_defs] unfolding subset_eq by auto 
 | 
| 
 | 
   430  | 
  moreover have "{x \<in> {0..1}. g x \<in> e1} \<noteq> {} \<and> {x \<in> {0..1}. g x \<in> e2} \<noteq> {}" using g(3,4)[unfolded path_defs] using obt
 | 
| 
 | 
   431  | 
    by (simp add: ex_in_conv [symmetric], metis zero_le_one order_refl)
  | 
| 
 | 
   432  | 
  ultimately show False 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}"]
 | 
| 
 | 
   433  | 
    using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(1)]
  | 
| 
 | 
   434  | 
    using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(2)] by auto qed
  | 
| 
 | 
   435  | 
  | 
| 
 | 
   436  | 
lemma open_path_component:
  | 
| 
 | 
   437  | 
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
  | 
| 
 | 
   438  | 
  assumes "open s" shows "open(path_component s x)"
  | 
| 
 | 
   439  | 
  unfolding open_contains_ball proof
  | 
| 
 | 
   440  | 
  fix y assume as:"y \<in> path_component s x"
  | 
| 
 | 
   441  | 
  hence "y\<in>s" apply- apply(rule path_component_mem(2)) unfolding mem_def by auto
  | 
| 
 | 
   442  | 
  then obtain e where e:"e>0" "ball y e \<subseteq> s" using assms[unfolded open_contains_ball] by auto
  | 
| 
 | 
   443  | 
  show "\<exists>e>0. ball y e \<subseteq> path_component s x" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule) unfolding mem_ball mem_path_component_set proof-
  | 
| 
 | 
   444  | 
    fix z assume "dist y z < e" thus "path_component s x z" apply(rule_tac path_component_trans[of _ _ y]) defer 
  | 
| 
 | 
   445  | 
      apply(rule path_component_of_subset[OF e(2)]) apply(rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format]) using `e>0`
  | 
| 
 | 
   446  | 
      using as[unfolded mem_def] by auto qed qed
  | 
| 
 | 
   447  | 
  | 
| 
 | 
   448  | 
lemma open_non_path_component:
  | 
| 
 | 
   449  | 
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
  | 
| 
 | 
   450  | 
  assumes "open s" shows "open(s - path_component s x)"
  | 
| 
 | 
   451  | 
  unfolding open_contains_ball proof
  | 
| 
 | 
   452  | 
  fix y assume as:"y\<in>s - path_component s x" 
  | 
| 
 | 
   453  | 
  then obtain e where e:"e>0" "ball y e \<subseteq> s" using assms[unfolded open_contains_ball] by auto
  | 
| 
 | 
   454  | 
  show "\<exists>e>0. ball y e \<subseteq> s - path_component s x" apply(rule_tac x=e in exI) apply(rule,rule `e>0`,rule,rule) defer proof(rule ccontr)
  | 
| 
 | 
   455  | 
    fix z assume "z\<in>ball y e" "\<not> z \<notin> path_component s x" 
  | 
| 
 | 
   456  | 
    hence "y \<in> path_component s x" unfolding not_not mem_path_component_set using `e>0` 
  | 
| 
 | 
   457  | 
      apply- apply(rule path_component_trans,assumption) apply(rule path_component_of_subset[OF e(2)])
  | 
| 
 | 
   458  | 
      apply(rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format]) by auto
  | 
| 
 | 
   459  | 
    thus False using as by auto qed(insert e(2), auto) qed
  | 
| 
 | 
   460  | 
  | 
| 
 | 
   461  | 
lemma connected_open_path_connected:
  | 
| 
 | 
   462  | 
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
  | 
| 
 | 
   463  | 
  assumes "open s" "connected s" shows "path_connected s"
  | 
| 
 | 
   464  | 
  unfolding path_connected_component_set proof(rule,rule,rule path_component_subset, rule)
  | 
| 
 | 
   465  | 
  fix x y assume "x \<in> s" "y \<in> s" show "y \<in> path_component s x" proof(rule ccontr)
  | 
| 
 | 
   466  | 
    assume "y \<notin> path_component s x" moreover
  | 
| 
 | 
   467  | 
    have "path_component s x \<inter> s \<noteq> {}" using `x\<in>s` path_component_eq_empty path_component_subset[of s x] by auto
 | 
| 
 | 
   468  | 
    ultimately show False using `y\<in>s` open_non_path_component[OF assms(1)] open_path_component[OF assms(1)]
  | 
| 
 | 
   469  | 
    using assms(2)[unfolded connected_def not_ex, rule_format, of"path_component s x" "s - path_component s x"] by auto
  | 
| 
 | 
   470  | 
qed qed
  | 
| 
 | 
   471  | 
  | 
| 
 | 
   472  | 
lemma path_connected_continuous_image:
  | 
| 
 | 
   473  | 
  assumes "continuous_on s f" "path_connected s" shows "path_connected (f ` s)"
  | 
| 
 | 
   474  | 
  unfolding path_connected_def proof(rule,rule)
  | 
| 
 | 
   475  | 
  fix x' y' assume "x' \<in> f ` s" "y' \<in> f ` s"
  | 
| 
 | 
   476  | 
  then obtain x y where xy:"x\<in>s" "y\<in>s" "x' = f x" "y' = f y" by auto
  | 
| 
 | 
   477  | 
  guess g using assms(2)[unfolded path_connected_def,rule_format,OF xy(1,2)] ..
  | 
| 
 | 
   478  | 
  thus "\<exists>g. path g \<and> path_image g \<subseteq> f ` s \<and> pathstart g = x' \<and> pathfinish g = y'"
  | 
| 
 | 
   479  | 
    unfolding xy apply(rule_tac x="f \<circ> g" in exI) unfolding path_defs
  | 
| 
 | 
   480  | 
    using assms(1) by(auto intro!: continuous_on_compose continuous_on_subset[of _ _ "g ` {0..1}"]) qed
 | 
| 
 | 
   481  | 
  | 
| 
 | 
   482  | 
lemma homeomorphic_path_connectedness:
  | 
| 
 | 
   483  | 
  "s homeomorphic t \<Longrightarrow> (path_connected s \<longleftrightarrow> path_connected t)"
  | 
| 
 | 
   484  | 
  unfolding homeomorphic_def homeomorphism_def apply(erule exE|erule conjE)+ apply rule
  | 
| 
 | 
   485  | 
  apply(drule_tac f=f in path_connected_continuous_image) prefer 3
  | 
| 
 | 
   486  | 
  apply(drule_tac f=g in path_connected_continuous_image) by auto
  | 
| 
 | 
   487  | 
  | 
| 
 | 
   488  | 
lemma path_connected_empty: "path_connected {}"
 | 
| 
 | 
   489  | 
  unfolding path_connected_def by auto
  | 
| 
 | 
   490  | 
  | 
| 
 | 
   491  | 
lemma path_connected_singleton: "path_connected {a}"
 | 
| 
 | 
   492  | 
  unfolding path_connected_def pathstart_def pathfinish_def path_image_def
  | 
| 
 | 
   493  | 
  apply (clarify, rule_tac x="\<lambda>x. a" in exI, simp add: image_constant_conv)
  | 
| 
 | 
   494  | 
  apply (simp add: path_def continuous_on_const)
  | 
| 
 | 
   495  | 
  done
  | 
| 
 | 
   496  | 
  | 
| 
 | 
   497  | 
lemma path_connected_Un: assumes "path_connected s" "path_connected t" "s \<inter> t \<noteq> {}"
 | 
| 
 | 
   498  | 
  shows "path_connected (s \<union> t)" unfolding path_connected_component proof(rule,rule)
  | 
| 
 | 
   499  | 
  fix x y assume as:"x \<in> s \<union> t" "y \<in> s \<union> t" 
  | 
| 
 | 
   500  | 
  from assms(3) obtain z where "z \<in> s \<inter> t" by auto
  | 
| 
 | 
   501  | 
  thus "path_component (s \<union> t) x y" using as using assms(1-2)[unfolded path_connected_component] apply- 
  | 
| 
 | 
   502  | 
    apply(erule_tac[!] UnE)+ apply(rule_tac[2-3] path_component_trans[of _ _ z])
  | 
| 
 | 
   503  | 
    by(auto simp add:path_component_of_subset [OF Un_upper1] path_component_of_subset[OF Un_upper2]) qed
  | 
| 
 | 
   504  | 
  | 
| 
 | 
   505  | 
subsection {* sphere is path-connected. *}
 | 
| 
 | 
   506  | 
  | 
| 
 | 
   507  | 
lemma path_connected_punctured_universe:
  | 
| 
 | 
   508  | 
 assumes "2 \<le> CARD('n::finite)" shows "path_connected((UNIV::(real^'n) set) - {a})" proof-
 | 
| 
 | 
   509  | 
  obtain \<psi> where \<psi>:"bij_betw \<psi> {1..CARD('n)} (UNIV::'n set)" using ex_bij_betw_nat_finite_1[OF finite_UNIV] by auto
 | 
| 
 | 
   510  | 
  let ?U = "UNIV::(real^'n) set" let ?u = "?U - {0}"
 | 
| 
 | 
   511  | 
  let ?basis = "\<lambda>k. basis (\<psi> k)"
  | 
| 
 | 
   512  | 
  let ?A = "\<lambda>k. {x::real^'n. \<exists>i\<in>{1..k}. inner (basis (\<psi> i)) x \<noteq> 0}"
 | 
| 
 | 
   513  | 
  have "\<forall>k\<in>{2..CARD('n)}. path_connected (?A k)" proof
 | 
| 
 | 
   514  | 
    have *:"\<And>k. ?A (Suc k) = {x. inner (?basis (Suc k)) x < 0} \<union> {x. inner (?basis (Suc k)) x > 0} \<union> ?A k" apply(rule set_ext,rule) defer
 | 
| 
 | 
   515  | 
      apply(erule UnE)+  unfolding mem_Collect_eq apply(rule_tac[1-2] x="Suc k" in bexI)
  | 
| 
 | 
   516  | 
      by(auto elim!: ballE simp add: not_less le_Suc_eq)
  | 
| 
 | 
   517  | 
    fix k assume "k \<in> {2..CARD('n)}" thus "path_connected (?A k)" proof(induct k)
 | 
| 
 | 
   518  | 
      case (Suc k) show ?case proof(cases "k = 1")
  | 
| 
 | 
   519  | 
        case False from Suc have d:"k \<in> {1..CARD('n)}" "Suc k \<in> {1..CARD('n)}" by auto
 | 
| 
 | 
   520  | 
        hence "\<psi> k \<noteq> \<psi> (Suc k)" using \<psi>[unfolded bij_betw_def inj_on_def, THEN conjunct1, THEN bspec[where x=k]] by auto
  | 
| 
 | 
   521  | 
        hence **:"?basis k + ?basis (Suc k) \<in> {x. 0 < inner (?basis (Suc k)) x} \<inter> (?A k)" 
 | 
| 
 | 
   522  | 
          "?basis k - ?basis (Suc k) \<in> {x. 0 > inner (?basis (Suc k)) x} \<inter> ({x. 0 < inner (?basis (Suc k)) x} \<union> (?A k))" using d
 | 
| 
 | 
   523  | 
          by(auto simp add: inner_basis intro!:bexI[where x=k])
  | 
| 
 | 
   524  | 
        show ?thesis unfolding * Un_assoc apply(rule path_connected_Un) defer apply(rule path_connected_Un) 
  | 
| 
 | 
   525  | 
          prefer 5 apply(rule_tac[1-2] convex_imp_path_connected, rule convex_halfspace_lt, rule convex_halfspace_gt)
  | 
| 
 | 
   526  | 
          apply(rule Suc(1)) using d ** False by auto
  | 
| 
 | 
   527  | 
      next case True hence d:"1\<in>{1..CARD('n)}" "2\<in>{1..CARD('n)}" using Suc(2) by auto
 | 
| 
 | 
   528  | 
        have ***:"Suc 1 = 2" by auto
  | 
| 
 | 
   529  | 
        have **:"\<And>s t P Q. s \<union> t \<union> {x. P x \<or> Q x} = (s \<union> {x. P x}) \<union> (t \<union> {x. Q x})" by auto
 | 
| 
 | 
   530  | 
        have nequals0I:"\<And>x A. x\<in>A \<Longrightarrow> A \<noteq> {}" by auto
 | 
| 
 | 
   531  | 
        have "\<psi> 2 \<noteq> \<psi> (Suc 0)" using \<psi>[unfolded bij_betw_def inj_on_def, THEN conjunct1, THEN bspec[where x=2]] using assms by auto
  | 
| 
 | 
   532  | 
        thus ?thesis unfolding * True unfolding ** neq_iff bex_disj_distrib apply -
  | 
| 
 | 
   533  | 
          apply(rule path_connected_Un, rule_tac[1-2] path_connected_Un) defer 3 apply(rule_tac[1-4] convex_imp_path_connected) 
  | 
| 
 | 
   534  | 
          apply(rule_tac[5] x=" ?basis 1 + ?basis 2" in nequals0I)
  | 
| 
 | 
   535  | 
          apply(rule_tac[6] x="-?basis 1 + ?basis 2" in nequals0I)
  | 
| 
 | 
   536  | 
          apply(rule_tac[7] x="-?basis 1 - ?basis 2" in nequals0I)
  | 
| 
 | 
   537  | 
          using d unfolding *** by(auto intro!: convex_halfspace_gt convex_halfspace_lt, auto simp add: inner_basis)
  | 
| 
 | 
   538  | 
  qed qed auto qed note lem = this
  | 
| 
 | 
   539  | 
  | 
| 
 | 
   540  | 
  have ***:"\<And>x::real^'n. (\<exists>i\<in>{1..CARD('n)}. inner (basis (\<psi> i)) x \<noteq> 0) \<longleftrightarrow> (\<exists>i. inner (basis i) x \<noteq> 0)"
 | 
| 
 | 
   541  | 
    apply rule apply(erule bexE) apply(rule_tac x="\<psi> i" in exI) defer apply(erule exE) proof- 
  | 
| 
 | 
   542  | 
    fix x::"real^'n" and i assume as:"inner (basis i) x \<noteq> 0"
  | 
| 
 | 
   543  | 
    have "i\<in>\<psi> ` {1..CARD('n)}" using \<psi>[unfolded bij_betw_def, THEN conjunct2] by auto
 | 
| 
 | 
   544  | 
    then obtain j where "j\<in>{1..CARD('n)}" "\<psi> j = i" by auto
 | 
| 
 | 
   545  | 
    thus "\<exists>i\<in>{1..CARD('n)}. inner (basis (\<psi> i)) x \<noteq> 0" apply(rule_tac x=j in bexI) using as by auto qed auto
 | 
| 
 | 
   546  | 
  have *:"?U - {a} = (\<lambda>x. x + a) ` {x. x \<noteq> 0}" apply(rule set_ext) unfolding image_iff 
 | 
| 
 | 
   547  | 
    apply rule apply(rule_tac x="x - a" in bexI) by auto
  | 
| 
 | 
   548  | 
  have **:"\<And>x::real^'n. x\<noteq>0 \<longleftrightarrow> (\<exists>i. inner (basis i) x \<noteq> 0)" unfolding Cart_eq by(auto simp add: inner_basis)
  | 
| 
 | 
   549  | 
  show ?thesis unfolding * apply(rule path_connected_continuous_image) apply(rule continuous_on_intros)+ 
  | 
| 
 | 
   550  | 
    unfolding ** apply(rule lem[THEN bspec[where x="CARD('n)"], unfolded ***]) using assms by auto qed
 | 
| 
 | 
   551  | 
  | 
| 
 | 
   552  | 
lemma path_connected_sphere: assumes "2 \<le> CARD('n::finite)" shows "path_connected {x::real^'n. norm(x - a) = r}" proof(cases "r\<le>0")
 | 
| 
 | 
   553  | 
  case True thus ?thesis proof(cases "r=0") 
  | 
| 
 | 
   554  | 
    case False hence "{x::real^'n. norm(x - a) = r} = {}" using True by auto
 | 
| 
 | 
   555  | 
    thus ?thesis using path_connected_empty by auto
  | 
| 
 | 
   556  | 
  qed(auto intro!:path_connected_singleton) next
  | 
| 
 | 
   557  | 
  case False hence *:"{x::real^'n. norm(x - a) = r} = (\<lambda>x. a + r *\<^sub>R x) ` {x. norm x = 1}" unfolding not_le apply -apply(rule set_ext,rule)
 | 
| 
 | 
   558  | 
    unfolding image_iff apply(rule_tac x="(1/r) *\<^sub>R (x - a)" in bexI) unfolding mem_Collect_eq norm_scaleR by (auto simp add: scaleR_right_diff_distrib)
  | 
| 
 | 
   559  | 
  have **:"{x::real^'n. norm x = 1} = (\<lambda>x. (1/norm x) *\<^sub>R x) ` (UNIV - {0})" apply(rule set_ext,rule)
 | 
| 
 | 
   560  | 
    unfolding image_iff apply(rule_tac x=x in bexI) unfolding mem_Collect_eq by(auto split:split_if_asm)
  | 
| 
 | 
   561  | 
  have "continuous_on (UNIV - {0}) (\<lambda>x::real^'n. 1 / norm x)" unfolding o_def continuous_on_eq_continuous_within
 | 
| 
 | 
   562  | 
    apply(rule, rule continuous_at_within_inv[unfolded o_def inverse_eq_divide]) apply(rule continuous_at_within)
  | 
| 
 | 
   563  | 
    apply(rule continuous_at_norm[unfolded o_def]) by auto
  | 
| 
 | 
   564  | 
  thus ?thesis unfolding * ** using path_connected_punctured_universe[OF assms]
  | 
| 
 | 
   565  | 
    by(auto intro!: path_connected_continuous_image continuous_on_intros) qed
  | 
| 
 | 
   566  | 
  | 
| 
 | 
   567  | 
lemma connected_sphere: "2 \<le> CARD('n) \<Longrightarrow> connected {x::real^'n. norm(x - a) = r}"
 | 
| 
 | 
   568  | 
  using path_connected_sphere path_connected_imp_connected by auto
  | 
| 
 | 
   569  | 
  | 
| 
 | 
   570  | 
end
  |