src/HOL/Multivariate_Analysis/Path_Connected.thy
changeset 60809 457abb82fb9e
parent 60420 884f54e01427
child 60974 6a6f15d8fbc4
equal deleted inserted replaced
60808:fd26519b1a6a 60809:457abb82fb9e
     7 theory Path_Connected
     7 theory Path_Connected
     8 imports Convex_Euclidean_Space
     8 imports Convex_Euclidean_Space
     9 begin
     9 begin
    10 
    10 
    11 (*FIXME move up?*)
    11 (*FIXME move up?*)
    12 lemma image_add_atLeastAtMost [simp]:
       
    13   fixes d::"'a::linordered_idom" shows "(op + d ` {a..b}) = {a+d..b+d}"
       
    14   apply auto
       
    15   apply (rule_tac x="x-d" in rev_image_eqI, auto)
       
    16   done
       
    17 
       
    18 lemma image_diff_atLeastAtMost [simp]:
       
    19   fixes d::"'a::linordered_idom" shows "(op - d ` {a..b}) = {d-b..d-a}"
       
    20   apply auto
       
    21   apply (rule_tac x="d-x" in rev_image_eqI, auto)
       
    22   done
       
    23 
       
    24 lemma image_mult_atLeastAtMost [simp]:
       
    25   fixes d::"'a::linordered_field"
       
    26   assumes "d>0" shows "(op * d ` {a..b}) = {d*a..d*b}"
       
    27   using assms
       
    28   apply auto
       
    29   apply (rule_tac x="x/d" in rev_image_eqI)
       
    30   apply (auto simp: field_simps)
       
    31   done
       
    32 
       
    33 lemma image_affinity_interval:
    12 lemma image_affinity_interval:
    34   fixes c :: "'a::ordered_real_vector"
    13   fixes c :: "'a::ordered_real_vector"
    35   shows "((\<lambda>x. m *\<^sub>R x + c) ` {a..b}) = (if {a..b}={} then {}
    14   shows "((\<lambda>x. m *\<^sub>R x + c) ` {a..b}) = (if {a..b}={} then {}
    36             else if 0 <= m then {m *\<^sub>R a + c .. m  *\<^sub>R b + c}
    15             else if 0 <= m then {m *\<^sub>R a + c .. m  *\<^sub>R b + c}
    37             else {m *\<^sub>R b + c .. m *\<^sub>R a + c})"
    16             else {m *\<^sub>R b + c .. m *\<^sub>R a + c})"
    38   apply (case_tac "m=0", force)
    17   apply (case_tac "m=0", force)
    39   apply (auto simp: scaleR_left_mono)
    18   apply (auto simp: scaleR_left_mono)
    40   apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI, auto simp: pos_le_divideR_eq le_diff_eq scaleR_left_mono_neg)
    19   apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI, auto simp: pos_le_divideR_eq le_diff_eq scaleR_left_mono_neg)
    41   apply (metis diff_le_eq inverse_inverse_eq order.not_eq_order_implies_strict pos_le_divideR_eq positive_imp_inverse_positive)
    20   apply (metis diff_le_eq inverse_inverse_eq order.not_eq_order_implies_strict pos_le_divideR_eq positive_imp_inverse_positive)
    42   apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI, auto simp: not_le neg_le_divideR_eq diff_le_eq)
    21   apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI, auto simp: not_le neg_le_divideR_eq diff_le_eq)
    43   using le_diff_eq scaleR_le_cancel_left_neg 
    22   using le_diff_eq scaleR_le_cancel_left_neg
    44   apply fastforce
    23   apply fastforce
    45   done
    24   done
    46 
       
    47 lemma image_affinity_atLeastAtMost:
       
    48   fixes c :: "'a::linordered_field"
       
    49   shows "((\<lambda>x. m*x + c) ` {a..b}) = (if {a..b}={} then {}
       
    50             else if 0 \<le> m then {m*a + c .. m *b + c}
       
    51             else {m*b + c .. m*a + c})"
       
    52   apply (case_tac "m=0", auto)
       
    53   apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps)
       
    54   apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps)
       
    55   done
       
    56 
       
    57 lemma image_affinity_atLeastAtMost_diff:
       
    58   fixes c :: "'a::linordered_field"
       
    59   shows "((\<lambda>x. m*x - c) ` {a..b}) = (if {a..b}={} then {}
       
    60             else if 0 \<le> m then {m*a - c .. m*b - c}
       
    61             else {m*b - c .. m*a - c})"
       
    62   using image_affinity_atLeastAtMost [of m "-c" a b]
       
    63   by simp
       
    64 
       
    65 lemma image_affinity_atLeastAtMost_div_diff:
       
    66   fixes c :: "'a::linordered_field"
       
    67   shows "((\<lambda>x. x/m - c) ` {a..b}) = (if {a..b}={} then {}
       
    68             else if 0 \<le> m then {a/m - c .. b/m - c}
       
    69             else {b/m - c .. a/m - c})"
       
    70   using image_affinity_atLeastAtMost_diff [of "inverse m" c a b]
       
    71   by (simp add: field_class.field_divide_inverse algebra_simps)
       
    72 
       
    73 lemma closed_segment_real_eq:
       
    74   fixes u::real shows "closed_segment u v = (\<lambda>x. (v - u) * x + u) ` {0..1}"
       
    75   by (simp add: add.commute [of u] image_affinity_atLeastAtMost [where c=u] closed_segment_eq_real_ivl)
       
    76 
    25 
    77 subsection \<open>Paths and Arcs\<close>
    26 subsection \<open>Paths and Arcs\<close>
    78 
    27 
    79 definition path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
    28 definition path :: "(real \<Rightarrow> 'a::topological_space) \<Rightarrow> bool"
    80   where "path g \<longleftrightarrow> continuous_on {0..1} g"
    29   where "path g \<longleftrightarrow> continuous_on {0..1} g"
   172   by (rule ext) (simp add: joinpaths_def)
   121   by (rule ext) (simp add: joinpaths_def)
   173 
   122 
   174 lemma joinpaths_linear_image: "linear f \<Longrightarrow> (f o g1) +++ (f o g2) = f o (g1 +++ g2)"
   123 lemma joinpaths_linear_image: "linear f \<Longrightarrow> (f o g1) +++ (f o g2) = f o (g1 +++ g2)"
   175   by (rule ext) (simp add: joinpaths_def)
   124   by (rule ext) (simp add: joinpaths_def)
   176 
   125 
   177 lemma simple_path_translation_eq: 
   126 lemma simple_path_translation_eq:
   178   fixes g :: "real \<Rightarrow> 'a::euclidean_space"
   127   fixes g :: "real \<Rightarrow> 'a::euclidean_space"
   179   shows "simple_path((\<lambda>x. a + x) o g) = simple_path g"
   128   shows "simple_path((\<lambda>x. a + x) o g) = simple_path g"
   180   by (simp add: simple_path_def path_translation_eq)
   129   by (simp add: simple_path_def path_translation_eq)
   181 
   130 
   182 lemma simple_path_linear_image_eq:
   131 lemma simple_path_linear_image_eq:
   361 section \<open>Path Images\<close>
   310 section \<open>Path Images\<close>
   362 
   311 
   363 lemma bounded_path_image: "path g \<Longrightarrow> bounded(path_image g)"
   312 lemma bounded_path_image: "path g \<Longrightarrow> bounded(path_image g)"
   364   by (simp add: compact_imp_bounded compact_path_image)
   313   by (simp add: compact_imp_bounded compact_path_image)
   365 
   314 
   366 lemma closed_path_image: 
   315 lemma closed_path_image:
   367   fixes g :: "real \<Rightarrow> 'a::t2_space"
   316   fixes g :: "real \<Rightarrow> 'a::t2_space"
   368   shows "path g \<Longrightarrow> closed(path_image g)"
   317   shows "path g \<Longrightarrow> closed(path_image g)"
   369   by (metis compact_path_image compact_imp_closed)
   318   by (metis compact_path_image compact_imp_closed)
   370 
   319 
   371 lemma connected_simple_path_image: "simple_path g \<Longrightarrow> connected(path_image g)"
   320 lemma connected_simple_path_image: "simple_path g \<Longrightarrow> connected(path_image g)"
   526   by (simp add: path_join)
   475   by (simp add: path_join)
   527 
   476 
   528 lemmas join_paths_simps = path_join path_image_join pathstart_join pathfinish_join
   477 lemmas join_paths_simps = path_join path_image_join pathstart_join pathfinish_join
   529 
   478 
   530 lemma simple_path_join_loop:
   479 lemma simple_path_join_loop:
   531   assumes "arc g1" "arc g2" 
   480   assumes "arc g1" "arc g2"
   532           "pathfinish g1 = pathstart g2"  "pathfinish g2 = pathstart g1" 
   481           "pathfinish g1 = pathstart g2"  "pathfinish g2 = pathstart g1"
   533           "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g1, pathstart g2}"
   482           "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g1, pathstart g2}"
   534   shows "simple_path(g1 +++ g2)"
   483   shows "simple_path(g1 +++ g2)"
   535 proof -
   484 proof -
   536   have injg1: "inj_on g1 {0..1}"
   485   have injg1: "inj_on g1 {0..1}"
   537     using assms
   486     using assms
   538     by (simp add: arc_def)
   487     by (simp add: arc_def)
   539   have injg2: "inj_on g2 {0..1}"
   488   have injg2: "inj_on g2 {0..1}"
   540     using assms
   489     using assms
   541     by (simp add: arc_def)
   490     by (simp add: arc_def)
   542   have g12: "g1 1 = g2 0" 
   491   have g12: "g1 1 = g2 0"
   543    and g21: "g2 1 = g1 0" 
   492    and g21: "g2 1 = g1 0"
   544    and sb:  "g1 ` {0..1} \<inter> g2 ` {0..1} \<subseteq> {g1 0, g2 0}"
   493    and sb:  "g1 ` {0..1} \<inter> g2 ` {0..1} \<subseteq> {g1 0, g2 0}"
   545     using assms
   494     using assms
   546     by (simp_all add: arc_def pathfinish_def pathstart_def path_image_def)
   495     by (simp_all add: arc_def pathfinish_def pathstart_def path_image_def)
   547   { fix x and y::real
   496   { fix x and y::real
   548     assume xyI: "x = 1 \<longrightarrow> y \<noteq> 0" 
   497     assume xyI: "x = 1 \<longrightarrow> y \<noteq> 0"
   549        and xy: "x \<le> 1" "0 \<le> y" " y * 2 \<le> 1" "\<not> x * 2 \<le> 1" "g2 (2 * x - 1) = g1 (2 * y)"
   498        and xy: "x \<le> 1" "0 \<le> y" " y * 2 \<le> 1" "\<not> x * 2 \<le> 1" "g2 (2 * x - 1) = g1 (2 * y)"
   550     have g1im: "g1 (2 * y) \<in> g1 ` {0..1} \<inter> g2 ` {0..1}"
   499     have g1im: "g1 (2 * y) \<in> g1 ` {0..1} \<inter> g2 ` {0..1}"
   551       using xy
   500       using xy
   552       apply simp
   501       apply simp
   553       apply (rule_tac x="2 * x - 1" in image_eqI, auto)
   502       apply (rule_tac x="2 * x - 1" in image_eqI, auto)
   554       done
   503       done
   555     have False
   504     have False
   556       using subsetD [OF sb g1im] xy 
   505       using subsetD [OF sb g1im] xy
   557       apply auto
   506       apply auto
   558       apply (drule inj_onD [OF injg1])
   507       apply (drule inj_onD [OF injg1])
   559       using g21 [symmetric] xyI
   508       using g21 [symmetric] xyI
   560       apply (auto dest: inj_onD [OF injg2])
   509       apply (auto dest: inj_onD [OF injg2])
   561       done
   510       done
   566       using xy
   515       using xy
   567       apply simp
   516       apply simp
   568       apply (rule_tac x="2 * x" in image_eqI, auto)
   517       apply (rule_tac x="2 * x" in image_eqI, auto)
   569       done
   518       done
   570     have "x = 0 \<and> y = 1"
   519     have "x = 0 \<and> y = 1"
   571       using subsetD [OF sb g1im] xy 
   520       using subsetD [OF sb g1im] xy
   572       apply auto
   521       apply auto
   573       apply (force dest: inj_onD [OF injg1])
   522       apply (force dest: inj_onD [OF injg1])
   574       using  g21 [symmetric]
   523       using  g21 [symmetric]
   575       apply (auto dest: inj_onD [OF injg2])
   524       apply (auto dest: inj_onD [OF injg2])
   576       done
   525       done
   585     apply (force dest: inj_onD [OF injg2])
   534     apply (force dest: inj_onD [OF injg2])
   586     done
   535     done
   587 qed
   536 qed
   588 
   537 
   589 lemma arc_join:
   538 lemma arc_join:
   590   assumes "arc g1" "arc g2" 
   539   assumes "arc g1" "arc g2"
   591           "pathfinish g1 = pathstart g2"
   540           "pathfinish g1 = pathstart g2"
   592           "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g2}"
   541           "path_image g1 \<inter> path_image g2 \<subseteq> {pathstart g2}"
   593     shows "arc(g1 +++ g2)"
   542     shows "arc(g1 +++ g2)"
   594 proof -
   543 proof -
   595   have injg1: "inj_on g1 {0..1}"
   544   have injg1: "inj_on g1 {0..1}"
   601   have g11: "g1 1 = g2 0"
   550   have g11: "g1 1 = g2 0"
   602    and sb:  "g1 ` {0..1} \<inter> g2 ` {0..1} \<subseteq> {g2 0}"
   551    and sb:  "g1 ` {0..1} \<inter> g2 ` {0..1} \<subseteq> {g2 0}"
   603     using assms
   552     using assms
   604     by (simp_all add: arc_def pathfinish_def pathstart_def path_image_def)
   553     by (simp_all add: arc_def pathfinish_def pathstart_def path_image_def)
   605   { fix x and y::real
   554   { fix x and y::real
   606     assume xy: "x \<le> 1" "0 \<le> y" " y * 2 \<le> 1" "\<not> x * 2 \<le> 1" "g2 (2 * x - 1) = g1 (2 * y)"       
   555     assume xy: "x \<le> 1" "0 \<le> y" " y * 2 \<le> 1" "\<not> x * 2 \<le> 1" "g2 (2 * x - 1) = g1 (2 * y)"
   607     have g1im: "g1 (2 * y) \<in> g1 ` {0..1} \<inter> g2 ` {0..1}"
   556     have g1im: "g1 (2 * y) \<in> g1 ` {0..1} \<inter> g2 ` {0..1}"
   608       using xy
   557       using xy
   609       apply simp
   558       apply simp
   610       apply (rule_tac x="2 * x - 1" in image_eqI, auto)
   559       apply (rule_tac x="2 * x - 1" in image_eqI, auto)
   611       done
   560       done
   612     have False
   561     have False
   613       using subsetD [OF sb g1im] xy 
   562       using subsetD [OF sb g1im] xy
   614       by (auto dest: inj_onD [OF injg2])
   563       by (auto dest: inj_onD [OF injg2])
   615    } note * = this
   564    } note * = this
   616   show ?thesis
   565   show ?thesis
   617     apply (simp add: arc_def inj_on_def)
   566     apply (simp add: arc_def inj_on_def)
   618     apply (clarsimp simp add: arc_imp_path assms path_join)
   567     apply (clarsimp simp add: arc_imp_path assms path_join)
   629   unfolding reversepath_def pathfinish_def pathstart_def joinpaths_def
   578   unfolding reversepath_def pathfinish_def pathstart_def joinpaths_def
   630   by (rule ext) (auto simp: mult.commute)
   579   by (rule ext) (auto simp: mult.commute)
   631 
   580 
   632 
   581 
   633 subsection\<open>Choosing a subpath of an existing path\<close>
   582 subsection\<open>Choosing a subpath of an existing path\<close>
   634     
   583 
   635 definition subpath :: "real \<Rightarrow> real \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> real \<Rightarrow> 'a::real_normed_vector"
   584 definition subpath :: "real \<Rightarrow> real \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> real \<Rightarrow> 'a::real_normed_vector"
   636   where "subpath a b g \<equiv> \<lambda>x. g((b - a) * x + a)"
   585   where "subpath a b g \<equiv> \<lambda>x. g((b - a) * x + a)"
   637 
   586 
   638 lemma path_image_subpath_gen [simp]: 
   587 lemma path_image_subpath_gen [simp]:
   639   fixes g :: "real \<Rightarrow> 'a::real_normed_vector"
   588   fixes g :: "real \<Rightarrow> 'a::real_normed_vector"
   640   shows "path_image(subpath u v g) = g ` (closed_segment u v)"
   589   shows "path_image(subpath u v g) = g ` (closed_segment u v)"
   641   apply (simp add: closed_segment_real_eq path_image_def subpath_def)
   590   apply (simp add: closed_segment_real_eq path_image_def subpath_def)
   642   apply (subst o_def [of g, symmetric])
   591   apply (subst o_def [of g, symmetric])
   643   apply (simp add: image_comp [symmetric])
   592   apply (simp add: image_comp [symmetric])
   682   by (rule ext) (simp add: subpath_def)
   631   by (rule ext) (simp add: subpath_def)
   683 
   632 
   684 lemma subpath_linear_image: "linear f \<Longrightarrow> subpath u v (f o g) = f o subpath u v g"
   633 lemma subpath_linear_image: "linear f \<Longrightarrow> subpath u v (f o g) = f o subpath u v g"
   685   by (rule ext) (simp add: subpath_def)
   634   by (rule ext) (simp add: subpath_def)
   686 
   635 
   687 lemma affine_ineq: 
   636 lemma affine_ineq:
   688   fixes x :: "'a::linordered_idom" 
   637   fixes x :: "'a::linordered_idom"
   689   assumes "x \<le> 1" "v < u"
   638   assumes "x \<le> 1" "v < u"
   690     shows "v + x * u \<le> u + x * v"
   639     shows "v + x * u \<le> u + x * v"
   691 proof -
   640 proof -
   692   have "(1-x)*(u-v) \<ge> 0"
   641   have "(1-x)*(u-v) \<ge> 0"
   693     using assms by auto
   642     using assms by auto
   694   then show ?thesis
   643   then show ?thesis
   695     by (simp add: algebra_simps)
   644     by (simp add: algebra_simps)
   696 qed
   645 qed
   697 
   646 
   698 lemma simple_path_subpath_eq: 
   647 lemma simple_path_subpath_eq:
   699   "simple_path(subpath u v g) \<longleftrightarrow>
   648   "simple_path(subpath u v g) \<longleftrightarrow>
   700      path(subpath u v g) \<and> u\<noteq>v \<and>
   649      path(subpath u v g) \<and> u\<noteq>v \<and>
   701      (\<forall>x y. x \<in> closed_segment u v \<and> y \<in> closed_segment u v \<and> g x = g y
   650      (\<forall>x y. x \<in> closed_segment u v \<and> y \<in> closed_segment u v \<and> g x = g y
   702                 \<longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u)"
   651                 \<longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u)"
   703     (is "?lhs = ?rhs")
   652     (is "?lhs = ?rhs")
   704 proof (rule iffI)
   653 proof (rule iffI)
   705   assume ?lhs
   654   assume ?lhs
   706   then have p: "path (\<lambda>x. g ((v - u) * x + u))"
   655   then have p: "path (\<lambda>x. g ((v - u) * x + u))"
   707         and sim: "(\<And>x y. \<lbrakk>x\<in>{0..1}; y\<in>{0..1}; g ((v - u) * x + u) = g ((v - u) * y + u)\<rbrakk> 
   656         and sim: "(\<And>x y. \<lbrakk>x\<in>{0..1}; y\<in>{0..1}; g ((v - u) * x + u) = g ((v - u) * y + u)\<rbrakk>
   708                   \<Longrightarrow> x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0)"
   657                   \<Longrightarrow> x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0)"
   709     by (auto simp: simple_path_def subpath_def)
   658     by (auto simp: simple_path_def subpath_def)
   710   { fix x y
   659   { fix x y
   711     assume "x \<in> closed_segment u v" "y \<in> closed_segment u v" "g x = g y"
   660     assume "x \<in> closed_segment u v" "y \<in> closed_segment u v" "g x = g y"
   712     then have "x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   661     then have "x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   713     using sim [of "(x-u)/(v-u)" "(y-u)/(v-u)"] p
   662     using sim [of "(x-u)/(v-u)" "(y-u)/(v-u)"] p
   714     by (auto simp: closed_segment_real_eq image_affinity_atLeastAtMost divide_simps 
   663     by (auto simp: closed_segment_real_eq image_affinity_atLeastAtMost divide_simps
   715        split: split_if_asm)
   664        split: split_if_asm)
   716   } moreover
   665   } moreover
   717   have "path(subpath u v g) \<and> u\<noteq>v"
   666   have "path(subpath u v g) \<and> u\<noteq>v"
   718     using sim [of "1/3" "2/3"] p
   667     using sim [of "1/3" "2/3"] p
   719     by (auto simp: subpath_def)
   668     by (auto simp: subpath_def)
   720   ultimately show ?rhs
   669   ultimately show ?rhs
   721     by metis
   670     by metis
   722 next
   671 next
   723   assume ?rhs
   672   assume ?rhs
   724   then 
   673   then
   725   have d1: "\<And>x y. \<lbrakk>g x = g y; u \<le> x; x \<le> v; u \<le> y; y \<le> v\<rbrakk> \<Longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   674   have d1: "\<And>x y. \<lbrakk>g x = g y; u \<le> x; x \<le> v; u \<le> y; y \<le> v\<rbrakk> \<Longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   726    and d2: "\<And>x y. \<lbrakk>g x = g y; v \<le> x; x \<le> u; v \<le> y; y \<le> u\<rbrakk> \<Longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   675    and d2: "\<And>x y. \<lbrakk>g x = g y; v \<le> x; x \<le> u; v \<le> y; y \<le> u\<rbrakk> \<Longrightarrow> x = y \<or> x = u \<and> y = v \<or> x = v \<and> y = u"
   727    and ne: "u < v \<or> v < u"
   676    and ne: "u < v \<or> v < u"
   728    and psp: "path (subpath u v g)"
   677    and psp: "path (subpath u v g)"
   729     by (auto simp: closed_segment_real_eq image_affinity_atLeastAtMost)
   678     by (auto simp: closed_segment_real_eq image_affinity_atLeastAtMost)
   732   show ?lhs using psp ne
   681   show ?lhs using psp ne
   733     unfolding simple_path_def subpath_def
   682     unfolding simple_path_def subpath_def
   734     by (fastforce simp add: algebra_simps affine_ineq mult_left_mono crossproduct_eq dest: d1 d2)
   683     by (fastforce simp add: algebra_simps affine_ineq mult_left_mono crossproduct_eq dest: d1 d2)
   735 qed
   684 qed
   736 
   685 
   737 lemma arc_subpath_eq: 
   686 lemma arc_subpath_eq:
   738   "arc(subpath u v g) \<longleftrightarrow> path(subpath u v g) \<and> u\<noteq>v \<and> inj_on g (closed_segment u v)"
   687   "arc(subpath u v g) \<longleftrightarrow> path(subpath u v g) \<and> u\<noteq>v \<and> inj_on g (closed_segment u v)"
   739     (is "?lhs = ?rhs")
   688     (is "?lhs = ?rhs")
   740 proof (rule iffI)
   689 proof (rule iffI)
   741   assume ?lhs
   690   assume ?lhs
   742   then have p: "path (\<lambda>x. g ((v - u) * x + u))"
   691   then have p: "path (\<lambda>x. g ((v - u) * x + u))"
   743         and sim: "(\<And>x y. \<lbrakk>x\<in>{0..1}; y\<in>{0..1}; g ((v - u) * x + u) = g ((v - u) * y + u)\<rbrakk> 
   692         and sim: "(\<And>x y. \<lbrakk>x\<in>{0..1}; y\<in>{0..1}; g ((v - u) * x + u) = g ((v - u) * y + u)\<rbrakk>
   744                   \<Longrightarrow> x = y)"
   693                   \<Longrightarrow> x = y)"
   745     by (auto simp: arc_def inj_on_def subpath_def)
   694     by (auto simp: arc_def inj_on_def subpath_def)
   746   { fix x y
   695   { fix x y
   747     assume "x \<in> closed_segment u v" "y \<in> closed_segment u v" "g x = g y"
   696     assume "x \<in> closed_segment u v" "y \<in> closed_segment u v" "g x = g y"
   748     then have "x = y"
   697     then have "x = y"
   749     using sim [of "(x-u)/(v-u)" "(y-u)/(v-u)"] p
   698     using sim [of "(x-u)/(v-u)" "(y-u)/(v-u)"] p
   750     by (force simp add: inj_on_def closed_segment_real_eq image_affinity_atLeastAtMost divide_simps 
   699     by (force simp add: inj_on_def closed_segment_real_eq image_affinity_atLeastAtMost divide_simps
   751        split: split_if_asm)
   700        split: split_if_asm)
   752   } moreover
   701   } moreover
   753   have "path(subpath u v g) \<and> u\<noteq>v"
   702   have "path(subpath u v g) \<and> u\<noteq>v"
   754     using sim [of "1/3" "2/3"] p
   703     using sim [of "1/3" "2/3"] p
   755     by (auto simp: subpath_def)
   704     by (auto simp: subpath_def)
   756   ultimately show ?rhs
   705   ultimately show ?rhs
   757     unfolding inj_on_def   
   706     unfolding inj_on_def
   758     by metis
   707     by metis
   759 next
   708 next
   760   assume ?rhs
   709   assume ?rhs
   761   then 
   710   then
   762   have d1: "\<And>x y. \<lbrakk>g x = g y; u \<le> x; x \<le> v; u \<le> y; y \<le> v\<rbrakk> \<Longrightarrow> x = y"
   711   have d1: "\<And>x y. \<lbrakk>g x = g y; u \<le> x; x \<le> v; u \<le> y; y \<le> v\<rbrakk> \<Longrightarrow> x = y"
   763    and d2: "\<And>x y. \<lbrakk>g x = g y; v \<le> x; x \<le> u; v \<le> y; y \<le> u\<rbrakk> \<Longrightarrow> x = y"
   712    and d2: "\<And>x y. \<lbrakk>g x = g y; v \<le> x; x \<le> u; v \<le> y; y \<le> u\<rbrakk> \<Longrightarrow> x = y"
   764    and ne: "u < v \<or> v < u"
   713    and ne: "u < v \<or> v < u"
   765    and psp: "path (subpath u v g)"
   714    and psp: "path (subpath u v g)"
   766     by (auto simp: inj_on_def closed_segment_real_eq image_affinity_atLeastAtMost)
   715     by (auto simp: inj_on_def closed_segment_real_eq image_affinity_atLeastAtMost)
   768     unfolding arc_def subpath_def inj_on_def
   717     unfolding arc_def subpath_def inj_on_def
   769     by (auto simp: algebra_simps affine_ineq mult_left_mono crossproduct_eq dest: d1 d2)
   718     by (auto simp: algebra_simps affine_ineq mult_left_mono crossproduct_eq dest: d1 d2)
   770 qed
   719 qed
   771 
   720 
   772 
   721 
   773 lemma simple_path_subpath: 
   722 lemma simple_path_subpath:
   774   assumes "simple_path g" "u \<in> {0..1}" "v \<in> {0..1}" "u \<noteq> v"
   723   assumes "simple_path g" "u \<in> {0..1}" "v \<in> {0..1}" "u \<noteq> v"
   775   shows "simple_path(subpath u v g)"
   724   shows "simple_path(subpath u v g)"
   776   using assms
   725   using assms
   777   apply (simp add: simple_path_subpath_eq simple_path_imp_path)
   726   apply (simp add: simple_path_subpath_eq simple_path_imp_path)
   778   apply (simp add: simple_path_def closed_segment_real_eq image_affinity_atLeastAtMost, fastforce)
   727   apply (simp add: simple_path_def closed_segment_real_eq image_affinity_atLeastAtMost, fastforce)
   784 
   733 
   785 lemma arc_subpath_arc:
   734 lemma arc_subpath_arc:
   786     "\<lbrakk>arc g; u \<in> {0..1}; v \<in> {0..1}; u \<noteq> v\<rbrakk> \<Longrightarrow> arc(subpath u v g)"
   735     "\<lbrakk>arc g; u \<in> {0..1}; v \<in> {0..1}; u \<noteq> v\<rbrakk> \<Longrightarrow> arc(subpath u v g)"
   787   by (meson arc_def arc_imp_simple_path arc_simple_path_subpath inj_onD)
   736   by (meson arc_def arc_imp_simple_path arc_simple_path_subpath inj_onD)
   788 
   737 
   789 lemma arc_simple_path_subpath_interior: 
   738 lemma arc_simple_path_subpath_interior:
   790     "\<lbrakk>simple_path g; u \<in> {0..1}; v \<in> {0..1}; u \<noteq> v; \<bar>u-v\<bar> < 1\<rbrakk> \<Longrightarrow> arc(subpath u v g)"
   739     "\<lbrakk>simple_path g; u \<in> {0..1}; v \<in> {0..1}; u \<noteq> v; \<bar>u-v\<bar> < 1\<rbrakk> \<Longrightarrow> arc(subpath u v g)"
   791     apply (rule arc_simple_path_subpath)
   740     apply (rule arc_simple_path_subpath)
   792     apply (force simp: simple_path_def)+
   741     apply (force simp: simple_path_def)+
   793     done
   742     done
   794 
   743 
   795 lemma path_image_subpath_subset: 
   744 lemma path_image_subpath_subset:
   796     "\<lbrakk>path g; u \<in> {0..1}; v \<in> {0..1}\<rbrakk> \<Longrightarrow> path_image(subpath u v g) \<subseteq> path_image g"
   745     "\<lbrakk>path g; u \<in> {0..1}; v \<in> {0..1}\<rbrakk> \<Longrightarrow> path_image(subpath u v g) \<subseteq> path_image g"
   797   apply (simp add: closed_segment_real_eq image_affinity_atLeastAtMost)
   746   apply (simp add: closed_segment_real_eq image_affinity_atLeastAtMost)
   798   apply (auto simp: path_image_def)
   747   apply (auto simp: path_image_def)
   799   done
   748   done
   800 
   749 
   947       by (simp add: algebra_simps)
   896       by (simp add: algebra_simps)
   948     with assms have "x = y"
   897     with assms have "x = y"
   949       by simp
   898       by simp
   950   }
   899   }
   951   then show ?thesis
   900   then show ?thesis
   952     unfolding arc_def inj_on_def 
   901     unfolding arc_def inj_on_def
   953     by (simp add:  path_linepath) (force simp: algebra_simps linepath_def)
   902     by (simp add:  path_linepath) (force simp: algebra_simps linepath_def)
   954 qed
   903 qed
   955 
   904 
   956 lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path (linepath a b)"
   905 lemma simple_path_linepath[intro]: "a \<noteq> b \<Longrightarrow> simple_path (linepath a b)"
   957   by (simp add: arc_imp_simple_path arc_linepath)
   906   by (simp add: arc_imp_simple_path arc_linepath)
  1064 
  1013 
  1065 lemma path_connected_component: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. path_component s x y)"
  1014 lemma path_connected_component: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. \<forall>y\<in>s. path_component s x y)"
  1066   unfolding path_connected_def path_component_def by auto
  1015   unfolding path_connected_def path_component_def by auto
  1067 
  1016 
  1068 lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. {y. path_component s x y} = s)"
  1017 lemma path_connected_component_set: "path_connected s \<longleftrightarrow> (\<forall>x\<in>s. {y. path_component s x y} = s)"
  1069   unfolding path_connected_component path_component_subset 
  1018   unfolding path_connected_component path_component_subset
  1070   apply auto
  1019   apply auto
  1071   using path_component_mem(2) by blast
  1020   using path_component_mem(2) by blast
  1072 
  1021 
  1073 subsection \<open>Some useful lemmas about path-connectedness\<close>
  1022 subsection \<open>Some useful lemmas about path-connectedness\<close>
  1074 
  1023