src/HOL/Complex_Analysis/Contour_Integration.thy
changeset 78517 28c1f4f5335f
parent 77491 9d431c939a7f
child 80052 35b2143aeec6
equal deleted inserted replaced
78516:56a408fa2440 78517:28c1f4f5335f
    42 
    42 
    43 lemma not_integrable_contour_integral: "\<not> f contour_integrable_on g \<Longrightarrow> contour_integral g f = 0"
    43 lemma not_integrable_contour_integral: "\<not> f contour_integrable_on g \<Longrightarrow> contour_integral g f = 0"
    44   unfolding contour_integrable_on_def contour_integral_def by blast
    44   unfolding contour_integrable_on_def contour_integral_def by blast
    45 
    45 
    46 lemma contour_integral_unique: "(f has_contour_integral i) g \<Longrightarrow> contour_integral g f = i"
    46 lemma contour_integral_unique: "(f has_contour_integral i) g \<Longrightarrow> contour_integral g f = i"
    47   apply (simp add: contour_integral_def has_contour_integral_def contour_integrable_on_def)
    47   unfolding contour_integral_def has_contour_integral_def contour_integrable_on_def
    48   using has_integral_unique by blast
    48   using has_integral_unique by blast
    49 
    49 
    50 lemma has_contour_integral_eqpath:
    50 lemma has_contour_integral_eqpath:
    51      "\<lbrakk>(f has_contour_integral y) p; f contour_integrable_on \<gamma>;
    51   "\<lbrakk>(f has_contour_integral y) p; f contour_integrable_on \<gamma>;
    52        contour_integral p f = contour_integral \<gamma> f\<rbrakk>
    52        contour_integral p f = contour_integral \<gamma> f\<rbrakk>
    53       \<Longrightarrow> (f has_contour_integral y) \<gamma>"
    53       \<Longrightarrow> (f has_contour_integral y) \<gamma>"
    54 using contour_integrable_on_def contour_integral_unique by auto
    54   using contour_integrable_on_def contour_integral_unique by auto
    55 
    55 
    56 lemma has_contour_integral_integral:
    56 lemma has_contour_integral_integral:
    57     "f contour_integrable_on i \<Longrightarrow> (f has_contour_integral (contour_integral i f)) i"
    57     "f contour_integrable_on i \<Longrightarrow> (f has_contour_integral (contour_integral i f)) i"
    58   by (metis contour_integral_unique contour_integrable_on_def)
    58   by (metis contour_integral_unique contour_integrable_on_def)
    59 
    59 
   327     unfolding contour_integrable_on
   327     unfolding contour_integrable_on
   328     by (intro integrable_spike_finite [OF fin01 _ *]) (auto simp: joinpaths_def scaleR_conv_of_real g2)
   328     by (intro integrable_spike_finite [OF fin01 _ *]) (auto simp: joinpaths_def scaleR_conv_of_real g2)
   329 qed
   329 qed
   330 
   330 
   331 lemma contour_integrable_join [simp]:
   331 lemma contour_integrable_join [simp]:
   332     "\<lbrakk>valid_path g1; valid_path g2\<rbrakk>
   332   "\<lbrakk>valid_path g1; valid_path g2\<rbrakk>
   333      \<Longrightarrow> f contour_integrable_on (g1 +++ g2) \<longleftrightarrow> f contour_integrable_on g1 \<and> f contour_integrable_on g2"
   333      \<Longrightarrow> f contour_integrable_on (g1 +++ g2) \<longleftrightarrow> f contour_integrable_on g1 \<and> f contour_integrable_on g2"
   334 using contour_integrable_joinD1 contour_integrable_joinD2 contour_integrable_joinI by blast
   334   using contour_integrable_joinD1 contour_integrable_joinD2 contour_integrable_joinI by blast
   335 
   335 
   336 lemma contour_integral_join [simp]:
   336 lemma contour_integral_join [simp]:
   337     "\<lbrakk>f contour_integrable_on g1; f contour_integrable_on g2; valid_path g1; valid_path g2\<rbrakk>
   337   "\<lbrakk>f contour_integrable_on g1; f contour_integrable_on g2; valid_path g1; valid_path g2\<rbrakk>
   338         \<Longrightarrow> contour_integral (g1 +++ g2) f = contour_integral g1 f + contour_integral g2 f"
   338         \<Longrightarrow> contour_integral (g1 +++ g2) f = contour_integral g1 f + contour_integral g2 f"
   339   by (simp add: has_contour_integral_integral has_contour_integral_join contour_integral_unique)
   339   by (simp add: has_contour_integral_integral has_contour_integral_join contour_integral_unique)
   340 
   340 
   341 
   341 
   342 subsection\<^marker>\<open>tag unimportant\<close> \<open>Shifting the starting point of a (closed) path\<close>
   342 subsection\<^marker>\<open>tag unimportant\<close> \<open>Shifting the starting point of a (closed) path\<close>
   351     using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq)
   351     using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq)
   352   have *: "((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}"
   352   have *: "((\<lambda>x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}"
   353     using assms by (auto simp: has_contour_integral)
   353     using assms by (auto simp: has_contour_integral)
   354   then have i: "i = integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) +
   354   then have i: "i = integral {a..1} (\<lambda>x. f (g x) * vector_derivative g (at x)) +
   355                     integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))"
   355                     integral {0..a} (\<lambda>x. f (g x) * vector_derivative g (at x))"
   356     apply (rule has_integral_unique)
   356     by (smt (verit, ccfv_threshold) Henstock_Kurzweil_Integration.integral_combine a add.commute atLeastAtMost_iff has_integral_iff)
   357     apply (subst add.commute)
       
   358     apply (subst Henstock_Kurzweil_Integration.integral_combine)
       
   359     using assms * integral_unique by auto
       
   360 
       
   361   have vd1: "vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))"
   357   have vd1: "vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))"
   362     if "0 \<le> x" "x + a < 1" "x \<notin> (\<lambda>x. x - a) ` S" for x
   358     if "0 \<le> x" "x + a < 1" "x \<notin> (\<lambda>x. x - a) ` S" for x
   363     unfolding shiftpath_def
   359     unfolding shiftpath_def
   364   proof (rule vector_derivative_at [OF has_vector_derivative_transform_within])
   360   proof (rule vector_derivative_at [OF has_vector_derivative_transform_within])
   365     have "((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)"
   361     have "((\<lambda>x. g (x + a)) has_vector_derivative vector_derivative g (at (a + x))) (at x)"
   369       have "g differentiable at (x + a)"
   365       have "g differentiable at (x + a)"
   370         using g a that by force
   366         using g a that by force
   371       then show "(g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))"
   367       then show "(g has_vector_derivative vector_derivative g (at (a + x))) (at (x + a))"
   372         by (metis add.commute vector_derivative_works)
   368         by (metis add.commute vector_derivative_works)
   373     qed
   369     qed
   374     then
   370     then show "((\<lambda>x. g (a + x)) has_vector_derivative vector_derivative g (at (x + a))) (at x)"
   375     show "((\<lambda>x. g (a + x)) has_vector_derivative vector_derivative g (at (x + a))) (at x)"
       
   376       by (auto simp: field_simps)
   371       by (auto simp: field_simps)
   377     show "0 < dist (1 - a) x"
   372     show "0 < dist (1 - a) x"
   378       using that by auto
   373       using that by auto
   379   qed (use that in \<open>auto simp: dist_real_def\<close>)
   374   qed (use that in \<open>auto simp: dist_real_def\<close>)
   380 
   375 
   472     shows "(f has_contour_integral i) (shiftpath a g) \<longleftrightarrow> (f has_contour_integral i) g"
   467     shows "(f has_contour_integral i) (shiftpath a g) \<longleftrightarrow> (f has_contour_integral i) g"
   473   using assms has_contour_integral_shiftpath has_contour_integral_shiftpath_D by blast
   468   using assms has_contour_integral_shiftpath has_contour_integral_shiftpath_D by blast
   474 
   469 
   475 lemma contour_integrable_on_shiftpath_eq:
   470 lemma contour_integrable_on_shiftpath_eq:
   476   assumes "valid_path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
   471   assumes "valid_path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
   477     shows "f contour_integrable_on (shiftpath a g) \<longleftrightarrow> f contour_integrable_on g"
   472   shows "f contour_integrable_on (shiftpath a g) \<longleftrightarrow> f contour_integrable_on g"
   478 using assms contour_integrable_on_def has_contour_integral_shiftpath_eq by auto
   473   using assms contour_integrable_on_def has_contour_integral_shiftpath_eq by auto
   479 
   474 
   480 lemma contour_integral_shiftpath:
   475 lemma contour_integral_shiftpath:
   481   assumes "valid_path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
   476   assumes "valid_path g" "pathfinish g = pathstart g" "a \<in> {0..1}"
   482     shows "contour_integral (shiftpath a g) f = contour_integral g f"
   477     shows "contour_integral (shiftpath a g) f = contour_integral g f"
   483    using assms
   478    using assms
   554 qed
   549 qed
   555 
   550 
   556 lemma contour_integrable_subpath:
   551 lemma contour_integrable_subpath:
   557   assumes "f contour_integrable_on g" "valid_path g" "u \<in> {0..1}" "v \<in> {0..1}"
   552   assumes "f contour_integrable_on g" "valid_path g" "u \<in> {0..1}" "v \<in> {0..1}"
   558     shows "f contour_integrable_on (subpath u v g)"
   553     shows "f contour_integrable_on (subpath u v g)"
   559 proof (cases u v rule: linorder_class.le_cases)
   554   by (smt (verit, ccfv_threshold) assms contour_integrable_on_def contour_integrable_reversepath_eq
   560   case le
   555       has_contour_integral_subpath reversepath_subpath valid_path_subpath)
   561   then show ?thesis
       
   562     by (metis contour_integrable_on_def has_contour_integral_subpath [OF assms])
       
   563 next
       
   564   case ge
       
   565   with assms show ?thesis
       
   566     by (metis (no_types, lifting) contour_integrable_on_def contour_integrable_reversepath_eq has_contour_integral_subpath reversepath_subpath valid_path_subpath)
       
   567 qed
       
   568 
   556 
   569 lemma has_integral_contour_integral_subpath:
   557 lemma has_integral_contour_integral_subpath:
   570   assumes "f contour_integrable_on g" "valid_path g" "u \<in> {0..1}" "v \<in> {0..1}" "u \<le> v"
   558   assumes "f contour_integrable_on g" "valid_path g" "u \<in> {0..1}" "v \<in> {0..1}" "u \<le> v"
   571     shows "(((\<lambda>x. f(g x) * vector_derivative g (at x)))
   559     shows "((\<lambda>x. f(g x) * vector_derivative g (at x))
   572             has_integral  contour_integral (subpath u v g) f) {u..v}"
   560             has_integral  contour_integral (subpath u v g) f) {u..v}"
   573   using assms
   561           (is "(?fg has_integral _)_")
   574 proof -
   562 proof -
   575   have "(\<lambda>r. f (g r) * vector_derivative g (at r)) integrable_on {u..v}"
   563   have "(?fg has_integral integral {u..v} ?fg) {u..v}"
   576     by (metis (full_types) assms(1) assms(3) assms(4) atLeastAtMost_iff atLeastatMost_subset_iff contour_integrable_on integrable_on_subinterval)
   564     using assms contour_integrable_on integrable_on_subinterval by fastforce
   577   then have "((\<lambda>r. f (g r) * vector_derivative g (at r)) has_integral integral {u..v} (\<lambda>r. f (g r) * vector_derivative g (at r))) {u..v}"
       
   578     by blast
       
   579   then show ?thesis
   565   then show ?thesis
   580     by (metis (full_types) assms contour_integral_unique has_contour_integral_subpath)
   566     by (metis (full_types) assms contour_integral_unique has_contour_integral_subpath)
   581 qed
   567 qed
   582 
   568 
   583 lemma contour_integral_subcontour_integral:
   569 lemma contour_integral_subcontour_integral:
   651   hence "finite ({0, 1} \<union> g -` A \<inter> {0<..<1})" by auto
   637   hence "finite ({0, 1} \<union> g -` A \<inter> {0<..<1})" by auto
   652   thus "negligible ({0, 1} \<union> g -` A \<inter> {0<..<1})" by (rule negligible_finite)
   638   thus "negligible ({0, 1} \<union> g -` A \<inter> {0<..<1})" by (rule negligible_finite)
   653 next
   639 next
   654   fix x assume "x \<in> {0..1} - ({0, 1} \<union> g -` A \<inter> {0<..<1})"
   640   fix x assume "x \<in> {0..1} - ({0, 1} \<union> g -` A \<inter> {0<..<1})"
   655   hence "g x \<in> path_image g - A" by (auto simp: path_image_def)
   641   hence "g x \<in> path_image g - A" by (auto simp: path_image_def)
   656   from assms(4)[OF this] and assms(3)
   642   with assms show "f' (g' x) * vector_derivative g' (at x) = f (g x) * vector_derivative g (at x)" 
   657     show "f' (g' x) * vector_derivative g' (at x) = f (g x) * vector_derivative g (at x)" by simp
   643     by simp
   658   qed
   644 qed
   659 
   645 
   660 
   646 
   661 text \<open>Contour integral along a segment on the real axis\<close>
   647 text \<open>Contour integral along a segment on the real axis\<close>
   662 
   648 
   663 lemma has_contour_integral_linepath_Reals_iff:
   649 lemma has_contour_integral_linepath_Reals_iff:
   664   fixes a b :: complex and f :: "complex \<Rightarrow> complex"
   650   fixes a b :: complex and f :: "complex \<Rightarrow> complex"
   665   assumes "a \<in> Reals" "b \<in> Reals" "Re a < Re b"
   651   assumes "a \<in> Reals" "b \<in> Reals" "Re a < Re b"
   666   shows   "(f has_contour_integral I) (linepath a b) \<longleftrightarrow>
   652   shows   "(f has_contour_integral I) (linepath a b) \<longleftrightarrow>
   667              ((\<lambda>x. f (of_real x)) has_integral I) {Re a..Re b}"
   653            ((\<lambda>x. f (of_real x)) has_integral I) {Re a..Re b}"
   668 proof -
   654 proof -
   669   from assms have [simp]: "of_real (Re a) = a" "of_real (Re b) = b"
   655   from assms have [simp]: "of_real (Re a) = a" "of_real (Re b) = b"
   670     by (simp_all add: complex_eq_iff)
   656     by (simp_all add: complex_eq_iff)
   671   from assms have "a \<noteq> b" by auto
   657   from assms have "a \<noteq> b" by auto
   672   have "((\<lambda>x. f (of_real x)) has_integral I) (cbox (Re a) (Re b)) \<longleftrightarrow>
   658   have "((\<lambda>x. f (of_real x)) has_integral I) (cbox (Re a) (Re b)) \<longleftrightarrow>
   736     then have fdiff: "(f has_derivative (*) (f' (g x))) (at (g x) within g ` {a..b})"
   722     then have fdiff: "(f has_derivative (*) (f' (g x))) (at (g x) within g ` {a..b})"
   737       by (simp add: has_field_derivative_def)
   723       by (simp add: has_field_derivative_def)
   738     have "((\<lambda>x. f (g x)) has_vector_derivative f' (g x) * vector_derivative g (at x within {a..b})) (at x within {a..b})"
   724     have "((\<lambda>x. f (g x)) has_vector_derivative f' (g x) * vector_derivative g (at x within {a..b})) (at x within {a..b})"
   739       using diff_chain_within [OF gdiff fdiff]
   725       using diff_chain_within [OF gdiff fdiff]
   740       by (simp add: has_vector_derivative_def scaleR_conv_of_real o_def mult_ac)
   726       by (simp add: has_vector_derivative_def scaleR_conv_of_real o_def mult_ac)
   741   } note * = this
   727   } then show ?thesis
   742   show ?thesis
   728     using assms cfg 
   743     using assms cfg *
       
   744     by (force simp: at_within_Icc_at intro: fundamental_theorem_of_calculus_interior_strong [OF \<open>finite K\<close>])
   729     by (force simp: at_within_Icc_at intro: fundamental_theorem_of_calculus_interior_strong [OF \<open>finite K\<close>])
   745 qed
   730 qed
   746 
   731 
   747 lemma contour_integral_primitive:
   732 lemma contour_integral_primitive:
   748   assumes "\<And>x. x \<in> S \<Longrightarrow> (f has_field_derivative f' x) (at x within S)"
   733   assumes "\<And>x. x \<in> S \<Longrightarrow> (f has_field_derivative f' x) (at x within S)"
   757   assumes "\<And>x. x \<in> S \<Longrightarrow> (f has_field_derivative f' x) (at x within S)"
   742   assumes "\<And>x. x \<in> S \<Longrightarrow> (f has_field_derivative f' x) (at x within S)"
   758       and "valid_path g"  "path_image g \<subseteq> S" "pathfinish g = pathstart g"
   743       and "valid_path g"  "path_image g \<subseteq> S" "pathfinish g = pathstart g"
   759     shows "(f' has_contour_integral 0) g"
   744     shows "(f' has_contour_integral 0) g"
   760   using assms by (metis diff_self contour_integral_primitive)
   745   using assms by (metis diff_self contour_integral_primitive)
   761 
   746 
   762 text\<open>Existence of path integral for continuous function\<close>
   747 
   763 lemma contour_integrable_continuous_linepath:
   748 lemma contour_integrable_continuous_linepath:
   764   assumes "continuous_on (closed_segment a b) f"
   749   assumes "continuous_on (closed_segment a b) f"
   765   shows "f contour_integrable_on (linepath a b)"
   750   shows "f contour_integrable_on (linepath a b)"
   766 proof -
   751 proof -
   767   have "continuous_on (closed_segment a b) (\<lambda>x. f x * (b - a))"
   752   have "continuous_on (closed_segment a b) (\<lambda>x. f x * (b - a))"
   949     "f contour_integrable_on g \<Longrightarrow> (\<lambda>x. f x / c) contour_integrable_on g"
   934     "f contour_integrable_on g \<Longrightarrow> (\<lambda>x. f x / c) contour_integrable_on g"
   950   using has_contour_integral_div contour_integrable_on_def
   935   using has_contour_integral_div contour_integrable_on_def
   951   by fastforce
   936   by fastforce
   952 
   937 
   953 lemma contour_integrable_sum:
   938 lemma contour_integrable_sum:
   954     "\<lbrakk>finite s; \<And>a. a \<in> s \<Longrightarrow> (f a) contour_integrable_on p\<rbrakk>
   939   "\<lbrakk>finite s; \<And>a. a \<in> s \<Longrightarrow> (f a) contour_integrable_on p\<rbrakk>
   955      \<Longrightarrow> (\<lambda>x. sum (\<lambda>a. f a x) s) contour_integrable_on p"
   940      \<Longrightarrow> (\<lambda>x. sum (\<lambda>a. f a x) s) contour_integrable_on p"
   956    unfolding contour_integrable_on_def
   941   unfolding contour_integrable_on_def by (metis has_contour_integral_sum)
   957    by (metis has_contour_integral_sum)
       
   958 
   942 
   959 lemma contour_integrable_neg_iff:
   943 lemma contour_integrable_neg_iff:
   960   "(\<lambda>x. -f x) contour_integrable_on g \<longleftrightarrow> f contour_integrable_on g"
   944   "(\<lambda>x. -f x) contour_integrable_on g \<longleftrightarrow> f contour_integrable_on g"
   961   using contour_integrable_neg[of f g] contour_integrable_neg[of "\<lambda>x. -f x" g] by auto
   945   using contour_integrable_neg[of f g] contour_integrable_neg[of "\<lambda>x. -f x" g] by auto
   962 
   946 
  1025     have "((\<lambda>x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral j) {k..1}"
  1009     have "((\<lambda>x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral j) {k..1}"
  1026       using k has_integral_affinity01 [OF *, of "inverse(1 - k)" "-(k/(1 - k))"]
  1010       using k has_integral_affinity01 [OF *, of "inverse(1 - k)" "-(k/(1 - k))"]
  1027       apply (simp add: divide_simps mult.commute [of _ "1-k"] image_affinity_atLeastAtMost ** bc)
  1011       apply (simp add: divide_simps mult.commute [of _ "1-k"] image_affinity_atLeastAtMost ** bc)
  1028       apply (auto dest: has_integral_cmul [where k = "(1 - k) *\<^sub>R j" and c = "inverse (1 - k)"])
  1012       apply (auto dest: has_integral_cmul [where k = "(1 - k) *\<^sub>R j" and c = "inverse (1 - k)"])
  1029       done
  1013       done
  1030   } note fj = this
  1014   } 
  1031   show ?thesis
  1015   then show ?thesis
  1032     using f k unfolding has_contour_integral_linepath
  1016     using f k unfolding has_contour_integral_linepath
  1033     by (simp add: linepath_def has_integral_combine [OF _ _ fi fj])
  1017     by (simp add: linepath_def has_integral_combine [OF _ _ fi])
  1034 qed
  1018 qed
  1035 
  1019 
  1036 lemma continuous_on_closed_segment_transform:
  1020 lemma continuous_on_closed_segment_transform:
  1037   assumes f: "continuous_on (closed_segment a b) f"
  1021   assumes f: "continuous_on (closed_segment a b) f"
  1038       and k: "0 \<le> k" "k \<le> 1"
  1022       and k: "0 \<le> k" "k \<le> 1"
  1105        "continuous_on (cbox (0, 0) (1::real, 1)) ((\<lambda>x. vector_derivative h (at x)) \<circ> snd)"
  1089        "continuous_on (cbox (0, 0) (1::real, 1)) ((\<lambda>x. vector_derivative h (at x)) \<circ> snd)"
  1106     by (rule continuous_intros | simp add: gvcon hvcon)+
  1090     by (rule continuous_intros | simp add: gvcon hvcon)+
  1107   then have gvcon': "continuous_on (cbox (0, 0) (1, 1::real)) (\<lambda>z. vector_derivative g (at (fst z)))"
  1091   then have gvcon': "continuous_on (cbox (0, 0) (1, 1::real)) (\<lambda>z. vector_derivative g (at (fst z)))"
  1108        and  hvcon': "continuous_on (cbox (0, 0) (1::real, 1)) (\<lambda>x. vector_derivative h (at (snd x)))"
  1092        and  hvcon': "continuous_on (cbox (0, 0) (1::real, 1)) (\<lambda>x. vector_derivative h (at (snd x)))"
  1109     by auto
  1093     by auto
  1110   have "continuous_on (cbox (0, 0) (1, 1)) ((\<lambda>(y1, y2). f y1 y2) \<circ> (\<lambda>w. ((g \<circ> fst) w, (h \<circ> snd) w)))"
  1094   have "continuous_on ((\<lambda>x. (g (fst x), h (snd x))) ` cbox (0,0) (1,1)) (\<lambda>(y1, y2). f y1 y2)"
  1111     apply (intro gcon hcon continuous_intros | simp)+
  1095     by (auto simp: path_image_def intro: continuous_on_subset [OF fcon])
  1112     apply (auto simp: path_image_def intro: continuous_on_subset [OF fcon])
  1096   then have "continuous_on (cbox (0, 0) (1, 1)) ((\<lambda>(y1, y2). f y1 y2) \<circ> (\<lambda>w. ((g \<circ> fst) w, (h \<circ> snd) w)))"
  1113     done
  1097     by (intro gcon hcon continuous_intros | simp)+
  1114   then have fgh: "continuous_on (cbox (0, 0) (1, 1)) (\<lambda>x. f (g (fst x)) (h (snd x)))"
  1098   then have fgh: "continuous_on (cbox (0, 0) (1, 1)) (\<lambda>x. f (g (fst x)) (h (snd x)))"
  1115     by auto
  1099     by auto
  1116   have "integral {0..1} (\<lambda>x. contour_integral h (f (g x)) * vector_derivative g (at x)) =
  1100   have "integral {0..1} (\<lambda>x. contour_integral h (f (g x)) * vector_derivative g (at x)) =
  1117         integral {0..1} (\<lambda>x. contour_integral h (\<lambda>y. f (g x) y * vector_derivative g (at x)))"
  1101         integral {0..1} (\<lambda>x. contour_integral h (\<lambda>y. f (g x) y * vector_derivative g (at x)))"
  1118   proof (rule integral_cong [OF contour_integral_rmul [symmetric]])
  1102   proof (rule integral_cong [OF contour_integral_rmul [symmetric]])
  1184   by (metis continuous_on_polymonial_function C1_differentiable_on_def  has_vector_derivative_polynomial_function)
  1168   by (metis continuous_on_polymonial_function C1_differentiable_on_def  has_vector_derivative_polynomial_function)
  1185 
  1169 
  1186 lemma valid_path_polynomial_function:
  1170 lemma valid_path_polynomial_function:
  1187   fixes p :: "real \<Rightarrow> 'a::euclidean_space"
  1171   fixes p :: "real \<Rightarrow> 'a::euclidean_space"
  1188   shows "polynomial_function p \<Longrightarrow> valid_path p"
  1172   shows "polynomial_function p \<Longrightarrow> valid_path p"
  1189 by (force simp: valid_path_def piecewise_C1_differentiable_on_def continuous_on_polymonial_function C1_differentiable_polynomial_function)
  1173   by (force simp: valid_path_def piecewise_C1_differentiable_on_def continuous_on_polymonial_function C1_differentiable_polynomial_function)
  1190 
  1174 
  1191 lemma valid_path_subpath_trivial [simp]:
  1175 lemma valid_path_subpath_trivial [simp]:
  1192     fixes g :: "real \<Rightarrow> 'a::euclidean_space"
  1176     fixes g :: "real \<Rightarrow> 'a::euclidean_space"
  1193     shows "z \<noteq> g x \<Longrightarrow> valid_path (subpath x x g)"
  1177     shows "z \<noteq> g x \<Longrightarrow> valid_path (subpath x x g)"
  1194   by (simp add: subpath_def valid_path_polynomial_function)
  1178   by (simp add: subpath_def valid_path_polynomial_function)
  1197 
  1181 
  1198 definition\<^marker>\<open>tag important\<close> part_circlepath :: "[complex, real, real, real, real] \<Rightarrow> complex"
  1182 definition\<^marker>\<open>tag important\<close> part_circlepath :: "[complex, real, real, real, real] \<Rightarrow> complex"
  1199   where "part_circlepath z r s t \<equiv> \<lambda>x. z + of_real r * exp (\<i> * of_real (linepath s t x))"
  1183   where "part_circlepath z r s t \<equiv> \<lambda>x. z + of_real r * exp (\<i> * of_real (linepath s t x))"
  1200 
  1184 
  1201 lemma pathstart_part_circlepath [simp]:
  1185 lemma pathstart_part_circlepath [simp]:
  1202      "pathstart(part_circlepath z r s t) = z + r*exp(\<i> * s)"
  1186   "pathstart(part_circlepath z r s t) = z + r*exp(\<i> * s)"
  1203 by (metis part_circlepath_def pathstart_def pathstart_linepath)
  1187   by (metis part_circlepath_def pathstart_def pathstart_linepath)
  1204 
  1188 
  1205 lemma pathfinish_part_circlepath [simp]:
  1189 lemma pathfinish_part_circlepath [simp]:
  1206      "pathfinish(part_circlepath z r s t) = z + r*exp(\<i>*t)"
  1190   "pathfinish(part_circlepath z r s t) = z + r*exp(\<i>*t)"
  1207 by (metis part_circlepath_def pathfinish_def pathfinish_linepath)
  1191   by (metis part_circlepath_def pathfinish_def pathfinish_linepath)
  1208 
  1192 
  1209 lemma reversepath_part_circlepath[simp]:
  1193 lemma reversepath_part_circlepath[simp]:
  1210     "reversepath (part_circlepath z r s t) = part_circlepath z r t s"
  1194   "reversepath (part_circlepath z r s t) = part_circlepath z r t s"
  1211   unfolding part_circlepath_def reversepath_def linepath_def
  1195   unfolding part_circlepath_def reversepath_def linepath_def
  1212   by (auto simp:algebra_simps)
  1196   by (auto simp:algebra_simps)
  1213 
  1197 
  1214 lemma has_vector_derivative_part_circlepath [derivative_intros]:
  1198 lemma has_vector_derivative_part_circlepath [derivative_intros]:
  1215     "((part_circlepath z r s t) has_vector_derivative
  1199     "((part_circlepath z r s t) has_vector_derivative
  1282 by (auto simp: path_image_part_circlepath sphere_def dist_norm algebra_simps norm_mult)
  1266 by (auto simp: path_image_part_circlepath sphere_def dist_norm algebra_simps norm_mult)
  1283 
  1267 
  1284 lemma in_path_image_part_circlepath:
  1268 lemma in_path_image_part_circlepath:
  1285   assumes "w \<in> path_image(part_circlepath z r s t)" "s \<le> t" "0 \<le> r"
  1269   assumes "w \<in> path_image(part_circlepath z r s t)" "s \<le> t" "0 \<le> r"
  1286     shows "norm(w - z) = r"
  1270     shows "norm(w - z) = r"
  1287 proof -
  1271   by (smt (verit) assms dist_norm mem_Collect_eq norm_minus_commute path_image_part_circlepath_subset sphere_def subsetD)
  1288   have "w \<in> {c. dist z c = r}"
       
  1289     by (metis (no_types) path_image_part_circlepath_subset sphere_def subset_eq assms)
       
  1290   thus ?thesis
       
  1291     by (simp add: dist_norm norm_minus_commute)
       
  1292 qed
       
  1293 
  1272 
  1294 lemma path_image_part_circlepath_subset':
  1273 lemma path_image_part_circlepath_subset':
  1295   assumes "r \<ge> 0"
  1274   assumes "r \<ge> 0"
  1296   shows   "path_image (part_circlepath z r s t) \<subseteq> sphere z r"
  1275   shows   "path_image (part_circlepath z r s t) \<subseteq> sphere z r"
  1297 proof (cases "s \<le> t")
  1276   by (smt (verit) assms path_image_part_circlepath_subset reversepath_part_circlepath reversepath_simps(2))
  1298   case True
       
  1299   thus ?thesis using path_image_part_circlepath_subset[of s t r z] assms by simp
       
  1300 next
       
  1301   case False
       
  1302   thus ?thesis using path_image_part_circlepath_subset[of t s r z] assms
       
  1303     by (subst reversepath_part_circlepath [symmetric], subst path_image_reversepath) simp_all
       
  1304 qed
       
  1305 
  1277 
  1306 lemma part_circlepath_cnj: "cnj (part_circlepath c r a b x) = part_circlepath (cnj c) r (-a) (-b) x"
  1278 lemma part_circlepath_cnj: "cnj (part_circlepath c r a b x) = part_circlepath (cnj c) r (-a) (-b) x"
  1307   by (simp add: part_circlepath_def exp_cnj linepath_def algebra_simps)
  1279   by (simp add: part_circlepath_def exp_cnj linepath_def algebra_simps)
  1308 
  1280 
  1309 lemma contour_integral_bound_part_circlepath:
  1281 lemma contour_integral_bound_part_circlepath:
  1456                        vector_derivative (part_circlepath z r s t) (at x)) has_integral i)  {0..1}"
  1428                        vector_derivative (part_circlepath z r s t) (at x)) has_integral i)  {0..1}"
  1457       by (rule has_integral_spike [OF negligible_finite [OF fin01]])  (use fi has_contour_integral in auto)
  1429       by (rule has_integral_spike [OF negligible_finite [OF fin01]])  (use fi has_contour_integral in auto)
  1458     have *: "\<And>x. \<lbrakk>0 \<le> x; x \<le> 1; part_circlepath z r s t x \<notin> k\<rbrakk> \<Longrightarrow> cmod (f (part_circlepath z r s t x)) \<le> B"
  1430     have *: "\<And>x. \<lbrakk>0 \<le> x; x \<le> 1; part_circlepath z r s t x \<notin> k\<rbrakk> \<Longrightarrow> cmod (f (part_circlepath z r s t x)) \<le> B"
  1459       by (auto intro!: B [unfolded path_image_def image_def])
  1431       by (auto intro!: B [unfolded path_image_def image_def])
  1460     show ?thesis
  1432     show ?thesis
  1461       apply (rule has_integral_bound [where 'a=real, simplified, OF _ **, simplified])
  1433       using has_integral_bound [where 'a=real, simplified, OF _ **]
  1462       using assms le * "2" \<open>r > 0\<close> by (auto simp add: norm_mult vector_derivative_part_circlepath)
  1434       using assms le * "2" \<open>r > 0\<close> by (auto simp add: norm_mult vector_derivative_part_circlepath)
  1463   qed
  1435   qed
  1464 qed
  1436 qed
  1465 
  1437 
  1466 corollary contour_integral_bound_part_circlepath_strong:
  1438 corollary contour_integral_bound_part_circlepath_strong:
  1518       using that by (simp add: field_simps)
  1490       using that by (simp add: field_simps)
  1519     then show ?thesis by (metis abs_minus_commute)
  1491     then show ?thesis by (metis abs_minus_commute)
  1520   qed
  1492   qed
  1521   have abs_away: "\<And>P. (\<forall>x\<in>{0..1}. \<forall>y\<in>{0..1}. P \<bar>x - y\<bar>) \<longleftrightarrow> (\<forall>x::real. 0 \<le> x \<and> x \<le> 1 \<longrightarrow> P x)"
  1493   have abs_away: "\<And>P. (\<forall>x\<in>{0..1}. \<forall>y\<in>{0..1}. P \<bar>x - y\<bar>) \<longleftrightarrow> (\<forall>x::real. 0 \<le> x \<and> x \<le> 1 \<longrightarrow> P x)"
  1522     by force
  1494     by force
       
  1495   have "\<And>x n. \<lbrakk>s \<noteq> t; \<bar>s - t\<bar> \<le> 2 * pi; 0 \<le> x; x < 1;
       
  1496             x * (t - s) = 2 * (real_of_int n * pi)\<rbrakk>
       
  1497            \<Longrightarrow> x = 0"
       
  1498     by (rule ccontr) (auto simp: 2 field_split_simps abs_mult dest: of_int_leD)
       
  1499   then
  1523   show ?thesis using False
  1500   show ?thesis using False
  1524     apply (simp add: simple_path_def loop_free_def)
  1501     apply (simp add: simple_path_def loop_free_def)
  1525     apply (simp add: part_circlepath_def linepath_def exp_eq  * ** abs01 del: Set.insert_iff)
  1502     apply (simp add: part_circlepath_def linepath_def exp_eq  * ** abs01 del: Set.insert_iff)
  1526     apply (subst abs_away)
  1503     apply (subst abs_away)
  1527     apply (auto simp: 1)
  1504     apply (auto simp: 1)
  1528     apply (rule ccontr)
       
  1529     apply (auto simp: 2 field_split_simps abs_mult dest: of_int_leD)
       
  1530     done
  1505     done
  1531 qed
  1506 qed
  1532 
  1507 
  1533 lemma arc_part_circlepath:
  1508 lemma arc_part_circlepath:
  1534   assumes "r \<noteq> 0" "s \<noteq> t" "\<bar>s - t\<bar> < 2*pi"
  1509   assumes "r \<noteq> 0" "s \<noteq> t" "\<bar>s - t\<bar> < 2*pi"
  1717     with ev_fint
  1692     with ev_fint
  1718     obtain a where fga: "\<And>x. x \<in> {0..1} \<Longrightarrow> cmod (f a (\<gamma> x) - l (\<gamma> x)) < e / (\<bar>B\<bar> + 1)"
  1693     obtain a where fga: "\<And>x. x \<in> {0..1} \<Longrightarrow> cmod (f a (\<gamma> x) - l (\<gamma> x)) < e / (\<bar>B\<bar> + 1)"
  1719                and inta: "(\<lambda>t. f a (\<gamma> t) * vector_derivative \<gamma> (at t)) integrable_on {0..1}"
  1694                and inta: "(\<lambda>t. f a (\<gamma> t) * vector_derivative \<gamma> (at t)) integrable_on {0..1}"
  1720       using eventually_happens [OF eventually_conj]
  1695       using eventually_happens [OF eventually_conj]
  1721       by (fastforce simp: contour_integrable_on path_image_def)
  1696       by (fastforce simp: contour_integrable_on path_image_def)
  1722     have Ble: "B * e / (\<bar>B\<bar> + 1) \<le> e"
       
  1723       using \<open>0 \<le> B\<close>  \<open>0 < e\<close> by (simp add: field_split_simps)
       
  1724     have "\<exists>h. (\<forall>x\<in>{0..1}. cmod (l (\<gamma> x) * vector_derivative \<gamma> (at x) - h x) \<le> e) \<and> h integrable_on {0..1}"
  1697     have "\<exists>h. (\<forall>x\<in>{0..1}. cmod (l (\<gamma> x) * vector_derivative \<gamma> (at x) - h x) \<le> e) \<and> h integrable_on {0..1}"
  1725     proof (intro exI conjI ballI)
  1698     proof (intro exI conjI ballI)
  1726       show "cmod (l (\<gamma> x) * vector_derivative \<gamma> (at x) - f a (\<gamma> x) * vector_derivative \<gamma> (at x)) \<le> e"
  1699       show "cmod (l (\<gamma> x) * vector_derivative \<gamma> (at x) - f a (\<gamma> x) * vector_derivative \<gamma> (at x)) \<le> e"
  1727         if "x \<in> {0..1}" for x
  1700         if "x \<in> {0..1}" for x
  1728         apply (rule order_trans [OF _ Ble])
  1701       proof -
  1729         using noleB [OF that] fga [OF that] \<open>0 \<le> B\<close> \<open>0 < e\<close>
  1702         have "cmod (l (\<gamma> x) * vector_derivative \<gamma> (at x) - f a (\<gamma> x) * vector_derivative \<gamma> (at x)) \<le> B * e / (\<bar>B\<bar> + 1)"
  1730         apply (fastforce simp: mult_ac dest: mult_mono [OF less_imp_le] simp add: norm_mult left_diff_distrib [symmetric] norm_minus_commute divide_simps)
  1703           using noleB [OF that] fga [OF that] \<open>0 \<le> B\<close> \<open>0 < e\<close>
  1731         done
  1704           by (fastforce simp: mult_ac dest: mult_mono [OF less_imp_le] simp add: norm_mult left_diff_distrib [symmetric] norm_minus_commute divide_simps)
       
  1705         also have "\<dots> \<le> e"
       
  1706           using \<open>0 \<le> B\<close>  \<open>0 < e\<close> by (simp add: field_split_simps)
       
  1707         finally show ?thesis .
       
  1708       qed
  1732     qed (rule inta)
  1709     qed (rule inta)
  1733   }
  1710   }
  1734   then show lintg: "l contour_integrable_on \<gamma>"
  1711   then show lintg: "l contour_integrable_on \<gamma>"
  1735     unfolding contour_integrable_on by (metis (mono_tags, lifting)integrable_uniform_limit_real)
  1712     unfolding contour_integrable_on by (metis (mono_tags, lifting)integrable_uniform_limit_real)
  1736   { fix e::real
  1713   { fix e::real