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