src/HOL/Multivariate_Analysis/Path_Connected.thy
author hoelzl
Tue, 26 Mar 2013 12:20:59 +0100
changeset 51528 66c3a7589de7
parent 51481 ef949192e5d6
child 53593 a7bcbb5a17d8
permissions -rw-r--r--
Series.thy is based on Limits.thy and not Deriv.thy
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
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    13
definition path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    14
  where "path g \<longleftrightarrow> continuous_on {0 .. 1} g"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    15
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    16
definition pathstart :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    17
  where "pathstart g = g 0"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    18
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    19
definition pathfinish :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    20
  where "pathfinish g = g 1"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    21
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    22
definition path_image :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> 'a set"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    23
  where "path_image g = g ` {0 .. 1}"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    24
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    25
definition reversepath :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    26
  where "reversepath g = (\<lambda>x. g(1 - x))"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    27
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    28
definition joinpaths :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> (real \<Rightarrow> 'a)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    29
    (infixr "+++" 75)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    30
  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
    31
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    32
definition simple_path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    33
  where "simple_path g \<longleftrightarrow>
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    34
    (\<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)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    35
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    36
definition injective_path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    37
  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
    38
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    39
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    40
subsection {* Some lemmas about these concepts. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    41
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    42
lemma injective_imp_simple_path: "injective_path g \<Longrightarrow> simple_path g"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    43
  unfolding injective_path_def simple_path_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    44
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    45
lemma path_image_nonempty: "path_image g \<noteq> {}"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    46
  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
    47
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    48
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
    49
  unfolding pathstart_def path_image_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    50
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    51
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
    52
  unfolding pathfinish_def path_image_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    53
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    54
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
    55
  unfolding path_def path_image_def
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    56
  apply (erule connected_continuous_image)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    57
  apply (rule convex_connected, rule convex_real_interval)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    58
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    59
50935
cfdf19d3ca32 generalize compact_path_image to topological_space
hoelzl
parents: 50884
diff changeset
    60
lemma compact_path_image[intro]: "path g \<Longrightarrow> compact(path_image g)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    61
  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
    62
  by (erule compact_continuous_image, rule compact_interval)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    63
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    64
lemma reversepath_reversepath[simp]: "reversepath(reversepath g) = g"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    65
  unfolding reversepath_def by auto
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 pathstart_reversepath[simp]: "pathstart(reversepath g) = pathfinish g"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    68
  unfolding pathstart_def reversepath_def pathfinish_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    69
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    70
lemma pathfinish_reversepath[simp]: "pathfinish(reversepath g) = pathstart g"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    71
  unfolding pathstart_def reversepath_def pathfinish_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    72
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    73
lemma pathstart_join[simp]: "pathstart (g1 +++ g2) = pathstart g1"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    74
  unfolding pathstart_def joinpaths_def pathfinish_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    75
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    76
lemma pathfinish_join[simp]: "pathfinish (g1 +++ g2) = pathfinish g2"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    77
  unfolding pathstart_def joinpaths_def pathfinish_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    78
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    79
lemma path_image_reversepath[simp]: "path_image(reversepath g) = path_image g"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    80
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    81
  have *: "\<And>g. path_image(reversepath g) \<subseteq> path_image g"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    82
    unfolding path_image_def subset_eq reversepath_def Ball_def image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    83
    apply(rule,rule,erule bexE)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    84
    apply(rule_tac x="1 - xa" in bexI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    85
    apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    86
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    87
  show ?thesis
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    88
    using *[of g] *[of "reversepath g"]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    89
    unfolding reversepath_reversepath by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    90
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
    91
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    92
lemma path_reversepath[simp]: "path (reversepath g) \<longleftrightarrow> path g"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    93
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    94
  have *: "\<And>g. path g \<Longrightarrow> path (reversepath g)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    95
    unfolding path_def reversepath_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    96
    apply (rule continuous_on_compose[unfolded o_def, of _ "\<lambda>x. 1 - x"])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    97
    apply (intro continuous_on_intros)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    98
    apply (rule continuous_on_subset[of "{0..1}"], assumption)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
    99
    apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   100
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   101
  show ?thesis
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   102
    using *[of "reversepath g"] *[of g]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   103
    unfolding reversepath_reversepath
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   104
    by (rule iffI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   105
qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   106
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   107
lemmas reversepath_simps =
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   108
  path_reversepath path_image_reversepath pathstart_reversepath pathfinish_reversepath
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   109
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   110
lemma path_join[simp]:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   111
  assumes "pathfinish g1 = pathstart g2"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   112
  shows "path (g1 +++ g2) \<longleftrightarrow> path g1 \<and> path g2"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   113
  unfolding path_def pathfinish_def pathstart_def
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   114
proof safe
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   115
  assume cont: "continuous_on {0..1} (g1 +++ g2)"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   116
  have g1: "continuous_on {0..1} g1 \<longleftrightarrow> continuous_on {0..1} ((g1 +++ g2) \<circ> (\<lambda>x. x / 2))"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   117
    by (intro continuous_on_cong refl) (auto simp: joinpaths_def)
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   118
  have g2: "continuous_on {0..1} g2 \<longleftrightarrow> continuous_on {0..1} ((g1 +++ g2) \<circ> (\<lambda>x. x / 2 + 1/2))"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   119
    using assms by (intro continuous_on_cong refl) (auto simp: joinpaths_def pathfinish_def pathstart_def)
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   120
  show "continuous_on {0..1} g1" "continuous_on {0..1} g2"
51481
ef949192e5d6 move continuous_on_inv to HOL image (simplifies isCont_inverse_function)
hoelzl
parents: 51478
diff changeset
   121
    unfolding g1 g2
ef949192e5d6 move continuous_on_inv to HOL image (simplifies isCont_inverse_function)
hoelzl
parents: 51478
diff changeset
   122
    by (auto intro!: continuous_on_intros continuous_on_subset[OF cont] simp del: o_apply)
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   123
next
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   124
  assume g1g2: "continuous_on {0..1} g1" "continuous_on {0..1} g2"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   125
  have 01: "{0 .. 1} = {0..1/2} \<union> {1/2 .. 1::real}"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   126
    by auto
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   127
  { fix x :: real assume "0 \<le> x" "x \<le> 1" then have "x \<in> (\<lambda>x. x * 2) ` {0..1 / 2}"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   128
      by (intro image_eqI[where x="x/2"]) auto }
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   129
  note 1 = this
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   130
  { fix x :: real assume "0 \<le> x" "x \<le> 1" then have "x \<in> (\<lambda>x. x * 2 - 1) ` {1 / 2..1}"
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   131
      by (intro image_eqI[where x="x/2 + 1/2"]) auto }
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   132
  note 2 = this
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   133
  show "continuous_on {0..1} (g1 +++ g2)"
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   134
    using assms unfolding joinpaths_def 01
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   135
    by (intro continuous_on_cases closed_atLeastAtMost g1g2[THEN continuous_on_compose2] continuous_on_intros)
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   136
       (auto simp: field_simps pathfinish_def pathstart_def intro!: 1 2)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   137
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   138
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   139
lemma path_image_join_subset: "path_image(g1 +++ g2) \<subseteq> (path_image g1 \<union> path_image g2)"
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   140
  unfolding path_image_def joinpaths_def by auto
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   141
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   142
lemma subset_path_image_join:
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   143
  assumes "path_image g1 \<subseteq> s" "path_image g2 \<subseteq> s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   144
  shows "path_image(g1 +++ g2) \<subseteq> s"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   145
  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
   146
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   147
lemma path_image_join:
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   148
  assumes "pathfinish g1 = pathstart g2"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   149
  shows "path_image(g1 +++ g2) = (path_image g1) \<union> (path_image g2)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   150
  apply (rule, rule path_image_join_subset, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   151
  unfolding Un_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   152
proof (erule disjE)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   153
  fix x
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   154
  assume "x \<in> path_image g1"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   155
  then obtain y where y: "y\<in>{0..1}" "x = g1 y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   156
    unfolding path_image_def image_iff by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   157
  then show "x \<in> path_image (g1 +++ g2)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   158
    unfolding joinpaths_def path_image_def image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   159
    apply (rule_tac x="(1/2) *\<^sub>R y" in bexI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   160
    apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   161
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   162
next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   163
  fix x
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   164
  assume "x \<in> path_image g2"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   165
  then obtain y where y: "y\<in>{0..1}" "x = g2 y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   166
    unfolding path_image_def image_iff by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   167
  then show "x \<in> path_image (g1 +++ g2)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   168
    unfolding joinpaths_def path_image_def image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   169
    apply(rule_tac x="(1/2) *\<^sub>R (y + 1)" in bexI)
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 50935
diff changeset
   170
    using assms(1)[unfolded pathfinish_def pathstart_def]
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   171
    apply (auto simp add: add_divide_distrib) 
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   172
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   173
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   174
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   175
lemma not_in_path_image_join:
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   176
  assumes "x \<notin> path_image g1" "x \<notin> path_image g2"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   177
  shows "x \<notin> path_image(g1 +++ g2)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   178
  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
   179
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   180
lemma simple_path_reversepath:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   181
  assumes "simple_path g"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   182
  shows "simple_path (reversepath g)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   183
  using assms
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   184
  unfolding simple_path_def reversepath_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   185
  apply -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   186
  apply (rule ballI)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   187
  apply (erule_tac x="1-x" in ballE, erule_tac x="1-y" in ballE)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   188
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   189
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   190
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   191
lemma simple_path_join_loop:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   192
  assumes "injective_path g1" "injective_path g2" "pathfinish g2 = pathstart g1"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   193
    "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g1,pathstart g2}"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   194
  shows "simple_path(g1 +++ g2)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   195
  unfolding simple_path_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   196
proof ((rule ballI)+, rule impI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   197
  let ?g = "g1 +++ g2"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   198
  note inj = assms(1,2)[unfolded injective_path_def, rule_format]
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   199
  fix x y :: real
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   200
  assume xy: "x \<in> {0..1}" "y \<in> {0..1}" "?g x = ?g y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   201
  show "x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   202
  proof (case_tac "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   203
    assume as: "x \<le> 1 / 2" "y \<le> 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   204
    then have "g1 (2 *\<^sub>R x) = g1 (2 *\<^sub>R y)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   205
      using xy(3) unfolding joinpaths_def by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   206
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   207
    have "2 *\<^sub>R x \<in> {0..1}" "2 *\<^sub>R y \<in> {0..1}" using xy(1,2) as
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   208
      by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   209
    ultimately
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   210
    show ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   211
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   212
    assume as:"x > 1 / 2" "y > 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   213
    then have "g2 (2 *\<^sub>R x - 1) = g2 (2 *\<^sub>R y - 1)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   214
      using xy(3) unfolding joinpaths_def by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   215
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   216
    have "2 *\<^sub>R x - 1 \<in> {0..1}" "2 *\<^sub>R y - 1 \<in> {0..1}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   217
      using xy(1,2) as by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   218
    ultimately
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   219
    show ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   220
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   221
    assume as:"x \<le> 1 / 2" "y > 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   222
    then have "?g x \<in> path_image g1" "?g y \<in> path_image g2"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   223
      unfolding path_image_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   224
      using xy(1,2) by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   225
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   226
      have "?g y \<noteq> pathstart g2" using as(2) unfolding pathstart_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   227
      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
   228
      by (auto simp add: field_simps)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   229
    ultimately
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   230
    have *:"?g x = pathstart g1" using assms(4) unfolding xy(3) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   231
    then have "x = 0" unfolding pathstart_def joinpaths_def using as(1) and xy(1)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   232
      using inj(1)[of "2 *\<^sub>R x" 0] by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   233
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   234
    have "y = 1" using * unfolding xy(3) assms(3)[THEN sym]
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   235
      unfolding joinpaths_def pathfinish_def using as(2) and xy(2)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   236
      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
   237
    ultimately show ?thesis by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   238
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   239
    assume as: "x > 1 / 2" "y \<le> 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   240
    then have "?g x \<in> path_image g2" "?g y \<in> path_image g1"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   241
      unfolding path_image_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   242
      using xy(1,2) by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   243
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   244
      have "?g x \<noteq> pathstart g2" using as(1) unfolding pathstart_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   245
      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
   246
      by (auto simp add: field_simps)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   247
    ultimately
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   248
    have *: "?g y = pathstart g1" using assms(4) unfolding xy(3) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   249
    then have "y = 0" unfolding pathstart_def joinpaths_def using as(2) and xy(2)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   250
      using inj(1)[of "2 *\<^sub>R y" 0] by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   251
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   252
    have "x = 1" using * unfolding xy(3)[THEN sym] assms(3)[THEN sym]
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   253
      unfolding joinpaths_def pathfinish_def using as(1) and xy(1)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   254
      using inj(2)[of "2 *\<^sub>R x - 1" 1] by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   255
    ultimately show ?thesis by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   256
  qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   257
qed
36583
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 injective_path_join:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   260
  assumes "injective_path g1" "injective_path g2" "pathfinish g1 = pathstart g2"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   261
    "(path_image g1 \<inter> path_image g2) \<subseteq> {pathstart g2}"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   262
  shows "injective_path(g1 +++ g2)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   263
  unfolding injective_path_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   264
proof (rule, rule, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   265
  let ?g = "g1 +++ g2"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   266
  note inj = assms(1,2)[unfolded injective_path_def, rule_format]
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   267
  fix x y
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   268
  assume xy: "x \<in> {0..1}" "y \<in> {0..1}" "(g1 +++ g2) x = (g1 +++ g2) y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   269
  show "x = y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   270
  proof (cases "x \<le> 1/2", case_tac[!] "y \<le> 1/2", unfold not_le)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   271
    assume "x \<le> 1 / 2" "y \<le> 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   272
    then show ?thesis using inj(1)[of "2*\<^sub>R x" "2*\<^sub>R y"] and xy
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   273
      unfolding joinpaths_def by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   274
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   275
    assume "x > 1 / 2" "y > 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   276
    then show ?thesis using inj(2)[of "2*\<^sub>R x - 1" "2*\<^sub>R y - 1"] and xy
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   277
      unfolding joinpaths_def by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   278
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   279
    assume as: "x \<le> 1 / 2" "y > 1 / 2"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   280
    then have "?g x \<in> path_image g1" "?g y \<in> path_image g2"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   281
      unfolding path_image_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   282
      using xy(1,2) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   283
    then have "?g x = pathfinish g1" "?g y = pathstart g2"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   284
      using assms(4) unfolding assms(3) xy(3) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   285
    then show ?thesis
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   286
      using as and inj(1)[of "2 *\<^sub>R x" 1] inj(2)[of "2 *\<^sub>R y - 1" 0] and xy(1,2)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   287
      unfolding pathstart_def pathfinish_def joinpaths_def
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   288
      by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   289
  next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   290
    assume as:"x > 1 / 2" "y \<le> 1 / 2" 
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   291
    then have "?g x \<in> path_image g2" "?g y \<in> path_image g1"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   292
      unfolding path_image_def joinpaths_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   293
      using xy(1,2) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   294
    then have "?g x = pathstart g2" "?g y = pathfinish g1"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   295
      using assms(4) unfolding assms(3) xy(3) by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   296
    then show ?thesis using as and inj(2)[of "2 *\<^sub>R x - 1" 0] inj(1)[of "2 *\<^sub>R y" 1] and xy(1,2)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   297
      unfolding pathstart_def pathfinish_def joinpaths_def
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   298
      by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   299
  qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   300
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   301
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   302
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
   303
 
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   304
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   305
subsection {* Reparametrizing a closed curve to start at some chosen point. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   306
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   307
definition "shiftpath a (f::real \<Rightarrow> 'a::topological_space) =
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   308
  (\<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
   309
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   310
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
   311
  unfolding pathstart_def shiftpath_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   312
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   313
lemma pathfinish_shiftpath:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   314
  assumes "0 \<le> a" "pathfinish g = pathstart g"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   315
  shows "pathfinish(shiftpath a g) = g a"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   316
  using assms unfolding pathstart_def pathfinish_def shiftpath_def
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   317
  by auto
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 endpoints_shiftpath:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   320
  assumes "pathfinish g = pathstart g" "a \<in> {0 .. 1}" 
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   321
  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
   322
  using assms by(auto intro!:pathfinish_shiftpath pathstart_shiftpath)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   323
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   324
lemma closed_shiftpath:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   325
  assumes "pathfinish g = pathstart g" "a \<in> {0..1}"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   326
  shows "pathfinish(shiftpath a g) = pathstart(shiftpath a g)"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   327
  using endpoints_shiftpath[OF assms] by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   328
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   329
lemma path_shiftpath:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   330
  assumes "path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   331
  shows "path(shiftpath a g)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   332
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   333
  have *: "{0 .. 1} = {0 .. 1-a} \<union> {1-a .. 1}" using assms(3) by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   334
  have **: "\<And>x. x + a = 1 \<Longrightarrow> g (x + a - 1) = g (x + a)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   335
    using assms(2)[unfolded pathfinish_def pathstart_def] by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   336
  show ?thesis
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   337
    unfolding path_def shiftpath_def *
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   338
    apply (rule continuous_on_union)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   339
    apply (rule closed_real_atLeastAtMost)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   340
    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a + x)"]) prefer 3
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   341
    apply (rule continuous_on_eq[of _ "g \<circ> (\<lambda>x. a - 1 + x)"]) defer prefer 3
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   342
    apply (rule continuous_on_intros)+ prefer 2
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   343
    apply (rule continuous_on_intros)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   344
    apply (rule_tac[1-2] continuous_on_subset[OF assms(1)[unfolded path_def]])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   345
    using assms(3) and **
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   346
    apply (auto, auto simp add: field_simps)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   347
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   348
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   349
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   350
lemma shiftpath_shiftpath:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   351
  assumes "pathfinish g = pathstart g" "a \<in> {0..1}" "x \<in> {0..1}" 
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   352
  shows "shiftpath (1 - a) (shiftpath a g) x = g x"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   353
  using assms unfolding pathfinish_def pathstart_def shiftpath_def by auto
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 path_image_shiftpath:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   356
  assumes "a \<in> {0..1}" "pathfinish g = pathstart g"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   357
  shows "path_image(shiftpath a g) = path_image g"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   358
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   359
  { fix x
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   360
    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)" 
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   361
    then have "\<exists>y\<in>{0..1} \<inter> {x. a + x \<le> 1}. g x = g (a + y)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   362
    proof (cases "a \<le> x")
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   363
      case False
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   364
      then show ?thesis
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   365
        apply (rule_tac x="1 + x - a" in bexI)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   366
        using as(1,2) and as(3)[THEN bspec[where x="1 + x - a"]] and assms(1)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   367
        apply (auto simp add: field_simps atomize_not)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   368
        done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   369
    next
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   370
      case True
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   371
      then show ?thesis using as(1-2) and assms(1) apply(rule_tac x="x - a" in bexI)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   372
        by(auto simp add: field_simps)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   373
    qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   374
  }
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   375
  then show ?thesis
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   376
    using assms unfolding shiftpath_def path_image_def pathfinish_def pathstart_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   377
    by(auto simp add: image_iff)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   378
qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   379
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   380
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   381
subsection {* Special case of straight-line paths. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   382
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   383
definition linepath :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> real \<Rightarrow> 'a"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   384
  where "linepath a b = (\<lambda>x. (1 - x) *\<^sub>R a + x *\<^sub>R b)"
36583
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 pathstart_linepath[simp]: "pathstart(linepath a b) = a"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   387
  unfolding pathstart_def linepath_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
lemma pathfinish_linepath[simp]: "pathfinish(linepath a b) = b"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   390
  unfolding pathfinish_def linepath_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   391
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   392
lemma continuous_linepath_at[intro]: "continuous (at x) (linepath a b)"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   393
  unfolding linepath_def by (intro continuous_intros)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   394
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   395
lemma continuous_on_linepath[intro]: "continuous_on s (linepath a b)"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   396
  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
   397
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   398
lemma path_linepath[intro]: "path(linepath a b)"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   399
  unfolding path_def by(rule continuous_on_linepath)
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
lemma path_image_linepath[simp]: "path_image(linepath a b) = (closed_segment a b)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   402
  unfolding path_image_def segment linepath_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   403
  apply (rule set_eqI, rule) defer
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   404
  unfolding mem_Collect_eq image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   405
  apply(erule exE)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   406
  apply(rule_tac x="u *\<^sub>R 1" in bexI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   407
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   408
  done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   409
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   410
lemma reversepath_linepath[simp]: "reversepath(linepath a b) = linepath b a"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   411
  unfolding reversepath_def linepath_def
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   412
  by auto
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 injective_path_linepath:
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   415
  assumes "a \<noteq> b"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   416
  shows "injective_path (linepath a b)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   417
proof -
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   418
  { fix x y :: "real"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   419
    assume "x *\<^sub>R b + y *\<^sub>R a = x *\<^sub>R a + y *\<^sub>R b"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   420
    then have "(x - y) *\<^sub>R a = (x - y) *\<^sub>R b" by (simp add: algebra_simps)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   421
    with assms have "x = y" by simp }
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   422
  then show ?thesis
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   423
    unfolding injective_path_def linepath_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   424
    by (auto simp add: algebra_simps)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   425
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   426
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   427
lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path(linepath a b)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   428
  by(auto intro!: injective_imp_simple_path injective_path_linepath)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   429
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   430
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   431
subsection {* Bounding a point away from a path. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   432
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   433
lemma not_on_path_ball:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   434
  fixes g :: "real \<Rightarrow> 'a::heine_borel"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   435
  assumes "path g" "z \<notin> path_image g"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   436
  shows "\<exists>e > 0. ball z e \<inter> (path_image g) = {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   437
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   438
  obtain a where "a \<in> path_image g" "\<forall>y \<in> path_image g. dist z a \<le> dist z y"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   439
    using distance_attains_inf[OF _ path_image_nonempty, of g z]
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   440
    using compact_path_image[THEN compact_imp_closed, OF assms(1)] by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   441
  then show ?thesis
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   442
    apply (rule_tac x="dist z a" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   443
    using assms(2)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   444
    apply (auto intro!: dist_pos_lt)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   445
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   446
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   447
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   448
lemma not_on_path_cball:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   449
  fixes g :: "real \<Rightarrow> 'a::heine_borel"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   450
  assumes "path g" "z \<notin> path_image g"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   451
  shows "\<exists>e>0. cball z e \<inter> (path_image g) = {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   452
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   453
  obtain e where "ball z e \<inter> path_image g = {}" "e>0"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   454
    using not_on_path_ball[OF assms] by auto
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   455
  moreover have "cball z (e/2) \<subseteq> ball z e" using `e>0` by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   456
  ultimately show ?thesis apply(rule_tac x="e/2" in exI) by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   457
qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   458
36583
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
subsection {* Path component, considered as a "joinability" relation (from Tom Hales). *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   461
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   462
definition "path_component s x y \<longleftrightarrow>
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   463
  (\<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   464
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   465
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
   466
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   467
lemma path_component_mem:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   468
  assumes "path_component s x y"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   469
  shows "x \<in> s" "y \<in> s"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   470
  using assms unfolding path_defs by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   471
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   472
lemma path_component_refl:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   473
  assumes "x \<in> s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   474
  shows "path_component s x x"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   475
  unfolding path_defs
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   476
  apply (rule_tac x="\<lambda>u. x" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   477
  using assms apply (auto intro!:continuous_on_intros) done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   478
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   479
lemma path_component_refl_eq: "path_component s x x \<longleftrightarrow> x \<in> s"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   480
  by (auto intro!: path_component_mem path_component_refl)
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   481
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   482
lemma path_component_sym: "path_component s x y \<Longrightarrow> path_component s y x"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   483
  using assms
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   484
  unfolding path_component_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   485
  apply (erule exE)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   486
  apply (rule_tac x="reversepath g" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   487
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   488
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   489
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   490
lemma path_component_trans:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   491
  assumes "path_component s x y" "path_component s y z"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   492
  shows "path_component s x z"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   493
  using assms
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   494
  unfolding path_component_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   495
  apply -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   496
  apply (erule exE)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   497
  apply (rule_tac x="g +++ ga" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   498
  apply (auto simp add: path_image_join)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   499
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   500
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   501
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
   502
  unfolding path_component_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   503
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   504
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   505
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
   506
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   507
lemma path_component_set:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   508
  "{y. path_component s x y} =
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   509
    {y. (\<exists>g. path g \<and> path_image g \<subseteq> s \<and> pathstart g = x \<and> pathfinish g = y)}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   510
  apply (rule set_eqI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   511
  unfolding mem_Collect_eq
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   512
  unfolding path_component_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   513
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   514
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   515
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 41959
diff changeset
   516
lemma path_component_subset: "{y. path_component s x y} \<subseteq> s"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   517
  apply (rule, rule path_component_mem(2))
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   518
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   519
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   520
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 41959
diff changeset
   521
lemma path_component_eq_empty: "{y. path_component s x y} = {} \<longleftrightarrow> x \<notin> s"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   522
  apply rule
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   523
  apply (drule equals0D[of _ x]) defer
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   524
  apply (rule equals0I)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   525
  unfolding mem_Collect_eq
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   526
  apply (drule path_component_mem(1))
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   527
  using path_component_refl
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   528
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   529
  done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   530
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   531
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   532
subsection {* Path connectedness of a space. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   533
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   534
definition "path_connected s \<longleftrightarrow>
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   535
  (\<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)"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   536
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   537
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
   538
  unfolding path_connected_def path_component_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   539
44170
510ac30f44c0 make Multivariate_Analysis work with separate set type
huffman
parents: 41959
diff changeset
   540
lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. {y. path_component s x y} = s)" 
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   541
  unfolding path_connected_component
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   542
  apply (rule, rule, rule, rule path_component_subset) 
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   543
  unfolding subset_eq mem_Collect_eq Ball_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   544
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   545
  done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   546
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   547
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   548
subsection {* Some useful lemmas about path-connectedness. *}
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   549
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   550
lemma convex_imp_path_connected:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   551
  fixes s :: "'a::real_normed_vector set"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   552
  assumes "convex s" shows "path_connected s"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   553
  unfolding path_connected_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   554
  apply (rule, rule, rule_tac x = "linepath x y" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   555
  unfolding path_image_linepath
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   556
  using assms [unfolded convex_contains_segment]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   557
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   558
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   559
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   560
lemma path_connected_imp_connected:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   561
  assumes "path_connected s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   562
  shows "connected s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   563
  unfolding connected_def not_ex
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   564
  apply (rule, rule, rule ccontr)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   565
  unfolding not_not
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   566
  apply (erule conjE)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   567
proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   568
  fix e1 e2
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   569
  assume as: "open e1" "open e2" "s \<subseteq> e1 \<union> e2" "e1 \<inter> e2 \<inter> s = {}" "e1 \<inter> s \<noteq> {}" "e2 \<inter> s \<noteq> {}"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   570
  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
   571
  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
   572
    using assms[unfolded path_connected_def,rule_format,of x1 x2] by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   573
  have *: "connected {0..1::real}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   574
    by (auto intro!: convex_connected convex_real_interval)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   575
  have "{0..1} \<subseteq> {x \<in> {0..1}. g x \<in> e1} \<union> {x \<in> {0..1}. g x \<in> e2}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   576
    using as(3) g(2)[unfolded path_defs] by blast
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   577
  moreover have "{x \<in> {0..1}. g x \<in> e1} \<inter> {x \<in> {0..1}. g x \<in> e2} = {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   578
    using as(4) g(2)[unfolded path_defs] unfolding subset_eq by auto 
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   579
  moreover have "{x \<in> {0..1}. g x \<in> e1} \<noteq> {} \<and> {x \<in> {0..1}. g x \<in> e2} \<noteq> {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   580
    using g(3,4)[unfolded path_defs] using obt
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   581
    by (simp add: ex_in_conv [symmetric], metis zero_le_one order_refl)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   582
  ultimately show False
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   583
    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}"]
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   584
    using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(1)]
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   585
    using continuous_open_in_preimage[OF g(1)[unfolded path_def] as(2)]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   586
    by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   587
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   588
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   589
lemma open_path_component:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   590
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   591
  assumes "open s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   592
  shows "open {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   593
  unfolding open_contains_ball
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   594
proof
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   595
  fix y
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   596
  assume as: "y \<in> {y. path_component s x y}"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   597
  then have "y \<in> s"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   598
    apply -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   599
    apply (rule path_component_mem(2))
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   600
    unfolding mem_Collect_eq
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   601
    apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   602
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   603
  then obtain e where e:"e>0" "ball y e \<subseteq> s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   604
    using assms[unfolded open_contains_ball] by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   605
  show "\<exists>e > 0. ball y e \<subseteq> {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   606
    apply (rule_tac x=e in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   607
    apply (rule,rule `e>0`, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   608
    unfolding mem_ball mem_Collect_eq
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   609
  proof -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   610
    fix z
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   611
    assume "dist y z < e"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   612
    then show "path_component s x z"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   613
      apply (rule_tac path_component_trans[of _ _ y]) defer
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   614
      apply (rule path_component_of_subset[OF e(2)])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   615
      apply (rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   616
      using `e>0` as
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   617
      apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   618
      done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   619
  qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   620
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   621
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   622
lemma open_non_path_component:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   623
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   624
  assumes "open s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   625
  shows "open(s - {y. path_component s x y})"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   626
  unfolding open_contains_ball
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   627
proof
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   628
  fix y
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   629
  assume as: "y\<in>s - {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   630
  then obtain e where e:"e>0" "ball y e \<subseteq> s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   631
    using assms [unfolded open_contains_ball] by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   632
  show "\<exists>e>0. ball y e \<subseteq> s - {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   633
    apply (rule_tac x=e in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   634
    apply (rule, rule `e>0`, rule, rule) defer
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   635
  proof (rule ccontr)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   636
    fix z
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   637
    assume "z \<in> ball y e" "\<not> z \<notin> {y. path_component s x y}"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   638
    then have "y \<in> {y. path_component s x y}"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   639
      unfolding not_not mem_Collect_eq using `e>0`
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   640
      apply -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   641
      apply (rule path_component_trans, assumption)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   642
      apply (rule path_component_of_subset[OF e(2)])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   643
      apply (rule convex_imp_path_connected[OF convex_ball, unfolded path_connected_component, rule_format])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   644
      apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   645
      done
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   646
    then show False using as by auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   647
  qed (insert e(2), auto)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   648
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   649
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   650
lemma connected_open_path_connected:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   651
  fixes s :: "'a::real_normed_vector set" (*TODO: generalize to metric_space*)
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   652
  assumes "open s" "connected s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   653
  shows "path_connected s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   654
  unfolding path_connected_component_set
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   655
proof (rule, rule, rule path_component_subset, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   656
  fix x y
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   657
  assume "x \<in> s" "y \<in> s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   658
  show "y \<in> {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   659
  proof (rule ccontr)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   660
    assume "y \<notin> {y. path_component s x y}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   661
    moreover
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   662
    have "{y. path_component s x y} \<inter> s \<noteq> {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   663
      using `x\<in>s` path_component_eq_empty path_component_subset[of s x] by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   664
    ultimately
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   665
    show False
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   666
      using `y\<in>s` open_non_path_component[OF assms(1)] open_path_component[OF assms(1)]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   667
      using assms(2)[unfolded connected_def not_ex, rule_format, of"{y. path_component s x y}" "s - {y. path_component s x y}"]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   668
      by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   669
  qed
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   670
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   671
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   672
lemma path_connected_continuous_image:
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   673
  assumes "continuous_on s f" "path_connected s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   674
  shows "path_connected (f ` s)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   675
  unfolding path_connected_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   676
proof (rule, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   677
  fix x' y'
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   678
  assume "x' \<in> f ` s" "y' \<in> f ` s"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   679
  then obtain x y where xy: "x\<in>s" "y\<in>s" "x' = f x" "y' = f y" by auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   680
  guess g using assms(2)[unfolded path_connected_def, rule_format, OF xy(1,2)] ..
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   681
  then show "\<exists>g. path g \<and> path_image g \<subseteq> f ` s \<and> pathstart g = x' \<and> pathfinish g = y'"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   682
    unfolding xy
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   683
    apply (rule_tac x="f \<circ> g" in exI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   684
    unfolding path_defs
51481
ef949192e5d6 move continuous_on_inv to HOL image (simplifies isCont_inverse_function)
hoelzl
parents: 51478
diff changeset
   685
    apply (intro conjI continuous_on_compose continuous_on_subset[OF assms(1)])
ef949192e5d6 move continuous_on_inv to HOL image (simplifies isCont_inverse_function)
hoelzl
parents: 51478
diff changeset
   686
    apply auto
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   687
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   688
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   689
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   690
lemma homeomorphic_path_connectedness:
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   691
  "s homeomorphic t \<Longrightarrow> (path_connected s \<longleftrightarrow> path_connected t)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   692
  unfolding homeomorphic_def homeomorphism_def
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   693
  apply (erule exE|erule conjE)+  
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   694
  apply rule
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   695
  apply (drule_tac f=f in path_connected_continuous_image) prefer 3
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   696
  apply (drule_tac f=g in path_connected_continuous_image)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   697
  apply auto
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   698
  done
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   699
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   700
lemma path_connected_empty: "path_connected {}"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   701
  unfolding path_connected_def by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   702
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   703
lemma path_connected_singleton: "path_connected {a}"
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   704
  unfolding path_connected_def pathstart_def pathfinish_def path_image_def
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   705
  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
   706
  apply (simp add: path_def continuous_on_const)
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   707
  done
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   708
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   709
lemma path_connected_Un:
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   710
  assumes "path_connected s" "path_connected t" "s \<inter> t \<noteq> {}"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   711
  shows "path_connected (s \<union> t)"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   712
  unfolding path_connected_component
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   713
proof (rule, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   714
  fix x y
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   715
  assume as: "x \<in> s \<union> t" "y \<in> s \<union> t"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   716
  from assms(3) obtain z where "z \<in> s \<inter> t" by auto
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   717
  then show "path_component (s \<union> t) x y"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   718
    using as and assms(1-2)[unfolded path_connected_component]
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   719
    apply - 
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   720
    apply (erule_tac[!] UnE)+
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   721
    apply (rule_tac[2-3] path_component_trans[of _ _ z])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   722
    apply (auto simp add:path_component_of_subset [OF Un_upper1] path_component_of_subset[OF Un_upper2])
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   723
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   724
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   725
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   726
lemma path_connected_UNION:
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   727
  assumes "\<And>i. i \<in> A \<Longrightarrow> path_connected (S i)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   728
    and "\<And>i. i \<in> A \<Longrightarrow> z \<in> S i"
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   729
  shows "path_connected (\<Union>i\<in>A. S i)"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   730
  unfolding path_connected_component
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   731
proof clarify
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   732
  fix x i y j
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   733
  assume *: "i \<in> A" "x \<in> S i" "j \<in> A" "y \<in> S j"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   734
  then have "path_component (S i) x z" and "path_component (S j) z y"
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   735
    using assms by (simp_all add: path_connected_component)
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   736
  then have "path_component (\<Union>i\<in>A. S i) x z" and "path_component (\<Union>i\<in>A. S i) z y"
48125
602dc0215954 tuned proofs -- prefer direct "rotated" instead of old-style COMP;
wenzelm
parents: 44647
diff changeset
   737
    using *(1,3) by (auto elim!: path_component_of_subset [rotated])
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   738
  then show "path_component (\<Union>i\<in>A. S i) x y"
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   739
    by (rule path_component_trans)
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   740
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   741
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   742
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   743
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
   744
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   745
lemma path_connected_punctured_universe:
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   746
  assumes "2 \<le> DIM('a::euclidean_space)"
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   747
  shows "path_connected((UNIV::'a::euclidean_space set) - {a})"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   748
proof -
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   749
  let ?A = "{x::'a. \<exists>i\<in>Basis. x \<bullet> i < a \<bullet> i}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   750
  let ?B = "{x::'a. \<exists>i\<in>Basis. a \<bullet> i < x \<bullet> i}"
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   751
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   752
  have A: "path_connected ?A"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   753
    unfolding Collect_bex_eq
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   754
  proof (rule path_connected_UNION)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   755
    fix i :: 'a
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   756
    assume "i \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   757
    then show "(\<Sum>i\<in>Basis. (a \<bullet> i - 1)*\<^sub>R i) \<in> {x::'a. x \<bullet> i < a \<bullet> i}" by simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   758
    show "path_connected {x. x \<bullet> i < a \<bullet> i}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   759
      using convex_imp_path_connected [OF convex_halfspace_lt, of i "a \<bullet> i"]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   760
      by (simp add: inner_commute)
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   761
  qed
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   762
  have B: "path_connected ?B" unfolding Collect_bex_eq
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   763
  proof (rule path_connected_UNION)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   764
    fix i :: 'a
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   765
    assume "i \<in> Basis"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   766
    then show "(\<Sum>i\<in>Basis. (a \<bullet> i + 1) *\<^sub>R i) \<in> {x::'a. a \<bullet> i < x \<bullet> i}" by simp
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   767
    show "path_connected {x. a \<bullet> i < x \<bullet> i}"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   768
      using convex_imp_path_connected [OF convex_halfspace_gt, of "a \<bullet> i" i]
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   769
      by (simp add: inner_commute)
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   770
  qed
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   771
  obtain S :: "'a set" where "S \<subseteq> Basis" "card S = Suc (Suc 0)"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   772
    using ex_card[OF assms] by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   773
  then obtain b0 b1 :: 'a where "b0 \<in> Basis" "b1 \<in> Basis" "b0 \<noteq> b1"
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   774
    unfolding card_Suc_eq by auto
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   775
  then have "a + b0 - b1 \<in> ?A \<inter> ?B" by (auto simp: inner_simps inner_Basis)
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   776
  then have "?A \<inter> ?B \<noteq> {}" by fast
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   777
  with A B have "path_connected (?A \<union> ?B)"
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   778
    by (rule path_connected_Un)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   779
  also have "?A \<union> ?B = {x. \<exists>i\<in>Basis. x \<bullet> i \<noteq> a \<bullet> i}"
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   780
    unfolding neq_iff bex_disj_distrib Collect_disj_eq ..
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   781
  also have "\<dots> = {x. x \<noteq> a}"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 49654
diff changeset
   782
    unfolding euclidean_eq_iff [where 'a='a] by (simp add: Bex_def)
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   783
  also have "\<dots> = UNIV - {a}" by auto
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   784
  finally show ?thesis .
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   785
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   786
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   787
lemma path_connected_sphere:
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   788
  assumes "2 \<le> DIM('a::euclidean_space)"
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   789
  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
   790
proof (rule linorder_cases [of r 0])
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   791
  assume "r < 0"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   792
  then have "{x::'a. norm(x - a) = r} = {}" by auto
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   793
  then show ?thesis using path_connected_empty by simp
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   794
next
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   795
  assume "r = 0"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   796
  then show ?thesis using path_connected_singleton by simp
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   797
next
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   798
  assume r: "0 < r"
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   799
  then have *: "{x::'a. norm(x - a) = r} = (\<lambda>x. a + r *\<^sub>R x) ` {x. norm x = 1}"
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   800
    apply -
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   801
    apply (rule set_eqI, rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   802
    unfolding image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   803
    apply (rule_tac x="(1/r) *\<^sub>R (x - a)" in bexI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   804
    unfolding mem_Collect_eq norm_scaleR
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   805
    apply (auto simp add: scaleR_right_diff_distrib)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   806
    done
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   807
  have **: "{x::'a. norm x = 1} = (\<lambda>x. (1/norm x) *\<^sub>R x) ` (UNIV - {0})"
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   808
    apply (rule set_eqI,rule)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   809
    unfolding image_iff
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   810
    apply (rule_tac x=x in bexI)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   811
    unfolding mem_Collect_eq
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   812
    apply (auto split:split_if_asm)
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   813
    done
44647
e4de7750cdeb modernize lemmas about 'continuous' and 'continuous_on';
huffman
parents: 44531
diff changeset
   814
  have "continuous_on (UNIV - {0}) (\<lambda>x::'a. 1 / norm x)"
e4de7750cdeb modernize lemmas about 'continuous' and 'continuous_on';
huffman
parents: 44531
diff changeset
   815
    unfolding field_divide_inverse by (simp add: continuous_on_intros)
49654
366d8b41ca17 tuned proofs;
wenzelm
parents: 49653
diff changeset
   816
  then show ?thesis unfolding * ** using path_connected_punctured_universe[OF assms]
49653
03bc7afe8814 tuned proofs;
wenzelm
parents: 48125
diff changeset
   817
    by (auto intro!: path_connected_continuous_image continuous_on_intros)
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   818
qed
36583
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   819
37674
f86de9c00c47 convert theorem path_connected_sphere to euclidean_space class
huffman
parents: 37489
diff changeset
   820
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
   821
  using path_connected_sphere path_connected_imp_connected by auto
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   822
68ce5760c585 move path-related stuff into new theory file
huffman
parents:
diff changeset
   823
end