src/HOL/Multivariate_Analysis/Cauchy_Integral_Thm.thy
changeset 63589 58aab4745e85
parent 63367 6c731c8b7f03
equal deleted inserted replaced
63588:d0e2bad67bd4 63589:58aab4745e85
  3451   "winding_number \<gamma> z \<equiv>
  3451   "winding_number \<gamma> z \<equiv>
  3452     @n. \<forall>e > 0. \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3452     @n. \<forall>e > 0. \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3453                     pathstart p = pathstart \<gamma> \<and>
  3453                     pathstart p = pathstart \<gamma> \<and>
  3454                     pathfinish p = pathfinish \<gamma> \<and>
  3454                     pathfinish p = pathfinish \<gamma> \<and>
  3455                     (\<forall>t \<in> {0..1}. norm(\<gamma> t - p t) < e) \<and>
  3455                     (\<forall>t \<in> {0..1}. norm(\<gamma> t - p t) < e) \<and>
  3456                     contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3456                     contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3457 
  3457 
  3458 lemma winding_number:
  3458 lemma winding_number:
  3459   assumes "path \<gamma>" "z \<notin> path_image \<gamma>" "0 < e"
  3459   assumes "path \<gamma>" "z \<notin> path_image \<gamma>" "0 < e"
  3460     shows "\<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3460     shows "\<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3461                pathstart p = pathstart \<gamma> \<and>
  3461                pathstart p = pathstart \<gamma> \<and>
  3462                pathfinish p = pathfinish \<gamma> \<and>
  3462                pathfinish p = pathfinish \<gamma> \<and>
  3463                (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3463                (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3464                contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * winding_number \<gamma> z"
  3464                contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * winding_number \<gamma> z"
  3465 proof -
  3465 proof -
  3466   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3466   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3467     using assms by blast
  3467     using assms by blast
  3468   then obtain d
  3468   then obtain d
  3469     where d: "d>0"
  3469     where d: "d>0"
  3474                       (\<forall>f. f holomorphic_on UNIV - {z} \<longrightarrow> contour_integral h2 f = contour_integral h1 f)"
  3474                       (\<forall>f. f holomorphic_on UNIV - {z} \<longrightarrow> contour_integral h2 f = contour_integral h1 f)"
  3475     using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] assms by (auto simp: open_delete)
  3475     using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] assms by (auto simp: open_delete)
  3476   then obtain h where h: "polynomial_function h \<and> pathstart h = pathstart \<gamma> \<and> pathfinish h = pathfinish \<gamma> \<and>
  3476   then obtain h where h: "polynomial_function h \<and> pathstart h = pathstart \<gamma> \<and> pathfinish h = pathfinish \<gamma> \<and>
  3477                           (\<forall>t \<in> {0..1}. norm(h t - \<gamma> t) < d/2)"
  3477                           (\<forall>t \<in> {0..1}. norm(h t - \<gamma> t) < d/2)"
  3478     using path_approx_polynomial_function [OF \<open>path \<gamma>\<close>, of "d/2"] d by auto
  3478     using path_approx_polynomial_function [OF \<open>path \<gamma>\<close>, of "d/2"] d by auto
  3479   define nn where "nn = 1/(2* pi*ii) * contour_integral h (\<lambda>w. 1/(w - z))"
  3479   define nn where "nn = 1/(2* pi*\<i>) * contour_integral h (\<lambda>w. 1/(w - z))"
  3480   have "\<exists>n. \<forall>e > 0. \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3480   have "\<exists>n. \<forall>e > 0. \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3481                         pathstart p = pathstart \<gamma> \<and>  pathfinish p = pathfinish \<gamma> \<and>
  3481                         pathstart p = pathstart \<gamma> \<and>  pathfinish p = pathfinish \<gamma> \<and>
  3482                         (\<forall>t \<in> {0..1}. norm(\<gamma> t - p t) < e) \<and>
  3482                         (\<forall>t \<in> {0..1}. norm(\<gamma> t - p t) < e) \<and>
  3483                         contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3483                         contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3484                     (is "\<exists>n. \<forall>e > 0. ?PP e n")
  3484                     (is "\<exists>n. \<forall>e > 0. ?PP e n")
  3485     proof (rule_tac x=nn in exI, clarify)
  3485     proof (rule_tac x=nn in exI, clarify)
  3486       fix e::real
  3486       fix e::real
  3487       assume e: "e>0"
  3487       assume e: "e>0"
  3488       obtain p where p: "polynomial_function p \<and>
  3488       obtain p where p: "polynomial_function p \<and>
  3507   assumes \<gamma>: "path \<gamma>" "z \<notin> path_image \<gamma>"
  3507   assumes \<gamma>: "path \<gamma>" "z \<notin> path_image \<gamma>"
  3508       and pi:
  3508       and pi:
  3509         "\<And>e. e>0 \<Longrightarrow> \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3509         "\<And>e. e>0 \<Longrightarrow> \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3510                           pathstart p = pathstart \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and>
  3510                           pathstart p = pathstart \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and>
  3511                           (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3511                           (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3512                           contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3512                           contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3513    shows "winding_number \<gamma> z = n"
  3513    shows "winding_number \<gamma> z = n"
  3514 proof -
  3514 proof -
  3515   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3515   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3516     using assms by blast
  3516     using assms by blast
  3517   then obtain e
  3517   then obtain e
  3523     using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] assms  by (auto simp: open_delete)
  3523     using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] assms  by (auto simp: open_delete)
  3524   obtain p where p:
  3524   obtain p where p:
  3525      "valid_path p \<and> z \<notin> path_image p \<and>
  3525      "valid_path p \<and> z \<notin> path_image p \<and>
  3526       pathstart p = pathstart \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and>
  3526       pathstart p = pathstart \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and>
  3527       (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3527       (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3528       contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3528       contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3529     using pi [OF e] by blast
  3529     using pi [OF e] by blast
  3530   obtain q where q:
  3530   obtain q where q:
  3531      "valid_path q \<and> z \<notin> path_image q \<and>
  3531      "valid_path q \<and> z \<notin> path_image q \<and>
  3532       pathstart q = pathstart \<gamma> \<and> pathfinish q = pathfinish \<gamma> \<and>
  3532       pathstart q = pathstart \<gamma> \<and> pathfinish q = pathfinish \<gamma> \<and>
  3533       (\<forall>t\<in>{0..1}. cmod (\<gamma> t - q t) < e) \<and> contour_integral q (\<lambda>w. 1 / (w - z)) = complex_of_real (2 * pi) * \<i> * winding_number \<gamma> z"
  3533       (\<forall>t\<in>{0..1}. cmod (\<gamma> t - q t) < e) \<and> contour_integral q (\<lambda>w. 1 / (w - z)) = complex_of_real (2 * pi) * \<i> * winding_number \<gamma> z"
  3550       and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  3550       and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  3551       and pi:
  3551       and pi:
  3552         "\<And>e. e>0 \<Longrightarrow> \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3552         "\<And>e. e>0 \<Longrightarrow> \<exists>p. valid_path p \<and> z \<notin> path_image p \<and>
  3553                            pathfinish p = pathstart p \<and>
  3553                            pathfinish p = pathstart p \<and>
  3554                            (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3554                            (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3555                            contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3555                            contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3556    shows "winding_number \<gamma> z = n"
  3556    shows "winding_number \<gamma> z = n"
  3557 proof -
  3557 proof -
  3558   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3558   have "path_image \<gamma> \<subseteq> UNIV - {z}"
  3559     using assms by blast
  3559     using assms by blast
  3560   then obtain e
  3560   then obtain e
  3566     using contour_integral_nearby_loops [of "UNIV - {z}" \<gamma>] assms  by (auto simp: open_delete)
  3566     using contour_integral_nearby_loops [of "UNIV - {z}" \<gamma>] assms  by (auto simp: open_delete)
  3567   obtain p where p:
  3567   obtain p where p:
  3568      "valid_path p \<and> z \<notin> path_image p \<and>
  3568      "valid_path p \<and> z \<notin> path_image p \<and>
  3569       pathfinish p = pathstart p \<and>
  3569       pathfinish p = pathstart p \<and>
  3570       (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3570       (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
  3571       contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * ii * n"
  3571       contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
  3572     using pi [OF e] by blast
  3572     using pi [OF e] by blast
  3573   obtain q where q:
  3573   obtain q where q:
  3574      "valid_path q \<and> z \<notin> path_image q \<and>
  3574      "valid_path q \<and> z \<notin> path_image q \<and>
  3575       pathstart q = pathstart \<gamma> \<and> pathfinish q = pathfinish \<gamma> \<and>
  3575       pathstart q = pathstart \<gamma> \<and> pathfinish q = pathfinish \<gamma> \<and>
  3576       (\<forall>t\<in>{0..1}. cmod (\<gamma> t - q t) < e) \<and> contour_integral q (\<lambda>w. 1 / (w - z)) = complex_of_real (2 * pi) * \<i> * winding_number \<gamma> z"
  3576       (\<forall>t\<in>{0..1}. cmod (\<gamma> t - q t) < e) \<and> contour_integral q (\<lambda>w. 1 / (w - z)) = complex_of_real (2 * pi) * \<i> * winding_number \<gamma> z"
  3588     by simp
  3588     by simp
  3589 qed
  3589 qed
  3590 
  3590 
  3591 lemma winding_number_valid_path:
  3591 lemma winding_number_valid_path:
  3592   assumes "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
  3592   assumes "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
  3593     shows "winding_number \<gamma> z = 1/(2*pi*ii) * contour_integral \<gamma> (\<lambda>w. 1/(w - z))"
  3593     shows "winding_number \<gamma> z = 1/(2*pi*\<i>) * contour_integral \<gamma> (\<lambda>w. 1/(w - z))"
  3594   using assms by (auto simp: valid_path_imp_path intro!: winding_number_unique)
  3594   using assms by (auto simp: valid_path_imp_path intro!: winding_number_unique)
  3595 
  3595 
  3596 lemma has_contour_integral_winding_number:
  3596 lemma has_contour_integral_winding_number:
  3597   assumes \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
  3597   assumes \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
  3598     shows "((\<lambda>w. 1/(w - z)) has_contour_integral (2*pi*ii*winding_number \<gamma> z)) \<gamma>"
  3598     shows "((\<lambda>w. 1/(w - z)) has_contour_integral (2*pi*\<i>*winding_number \<gamma> z)) \<gamma>"
  3599 by (simp add: winding_number_valid_path has_contour_integral_integral contour_integrable_inversediff assms)
  3599 by (simp add: winding_number_valid_path has_contour_integral_integral contour_integrable_inversediff assms)
  3600 
  3600 
  3601 lemma winding_number_trivial [simp]: "z \<noteq> a \<Longrightarrow> winding_number(linepath a a) z = 0"
  3601 lemma winding_number_trivial [simp]: "z \<noteq> a \<Longrightarrow> winding_number(linepath a a) z = 0"
  3602   by (simp add: winding_number_valid_path)
  3602   by (simp add: winding_number_valid_path)
  3603 
  3603 
  3695   have *: "0 \<le> Im (vector_derivative \<gamma> (at x) / (\<gamma> x - z))" if x: "0 < x" "x < 1" for x
  3695   have *: "0 \<le> Im (vector_derivative \<gamma> (at x) / (\<gamma> x - z))" if x: "0 < x" "x < 1" for x
  3696     using ge by (simp add: Complex.Im_divide algebra_simps x)
  3696     using ge by (simp add: Complex.Im_divide algebra_simps x)
  3697   show ?thesis
  3697   show ?thesis
  3698     apply (simp add: Re_winding_number [OF \<gamma>] field_simps)
  3698     apply (simp add: Re_winding_number [OF \<gamma>] field_simps)
  3699     apply (rule has_integral_component_nonneg
  3699     apply (rule has_integral_component_nonneg
  3700              [of ii "\<lambda>x. if x \<in> {0<..<1}
  3700              [of \<i> "\<lambda>x. if x \<in> {0<..<1}
  3701                          then 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x) else 0", simplified])
  3701                          then 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x) else 0", simplified])
  3702       prefer 3 apply (force simp: *)
  3702       prefer 3 apply (force simp: *)
  3703      apply (simp add: Basis_complex_def)
  3703      apply (simp add: Basis_complex_def)
  3704     apply (rule has_integral_spike_interior [of 0 1 _ "\<lambda>x. 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x)"])
  3704     apply (rule has_integral_spike_interior [of 0 1 _ "\<lambda>x. 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x)"])
  3705     apply simp
  3705     apply simp
  3716       and ge: "\<And>x. \<lbrakk>0 < x; x < 1\<rbrakk> \<Longrightarrow> e \<le> Im (vector_derivative \<gamma> (at x) / (\<gamma> x - z))"
  3716       and ge: "\<And>x. \<lbrakk>0 < x; x < 1\<rbrakk> \<Longrightarrow> e \<le> Im (vector_derivative \<gamma> (at x) / (\<gamma> x - z))"
  3717     shows "0 < Re(winding_number \<gamma> z)"
  3717     shows "0 < Re(winding_number \<gamma> z)"
  3718 proof -
  3718 proof -
  3719   have "e \<le> Im (contour_integral \<gamma> (\<lambda>w. 1 / (w - z)))"
  3719   have "e \<le> Im (contour_integral \<gamma> (\<lambda>w. 1 / (w - z)))"
  3720     apply (rule has_integral_component_le
  3720     apply (rule has_integral_component_le
  3721              [of ii "\<lambda>x. ii*e" "ii*e" "{0..1}"
  3721              [of \<i> "\<lambda>x. \<i>*e" "\<i>*e" "{0..1}"
  3722                     "\<lambda>x. if x \<in> {0<..<1} then 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x) else ii*e"
  3722                     "\<lambda>x. if x \<in> {0<..<1} then 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x) else \<i>*e"
  3723                     "contour_integral \<gamma> (\<lambda>w. 1/(w - z))", simplified])
  3723                     "contour_integral \<gamma> (\<lambda>w. 1/(w - z))", simplified])
  3724     using e
  3724     using e
  3725     apply (simp_all add: Basis_complex_def)
  3725     apply (simp_all add: Basis_complex_def)
  3726     using has_integral_const_real [of _ 0 1] apply force
  3726     using has_integral_const_real [of _ 0 1] apply force
  3727     apply (rule has_integral_spike_interior [of 0 1 _ "\<lambda>x. 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x)", simplified box_real])
  3727     apply (rule has_integral_spike_interior [of 0 1 _ "\<lambda>x. 1/(\<gamma> x - z) * vector_derivative \<gamma> (at x)", simplified box_real])
  3872     by (simp add: divide_inverse_commute integral_def)
  3872     by (simp add: divide_inverse_commute integral_def)
  3873 qed
  3873 qed
  3874 
  3874 
  3875 corollary winding_number_exp_2pi:
  3875 corollary winding_number_exp_2pi:
  3876     "\<lbrakk>path p; z \<notin> path_image p\<rbrakk>
  3876     "\<lbrakk>path p; z \<notin> path_image p\<rbrakk>
  3877      \<Longrightarrow> pathfinish p - z = exp (2 * pi * ii * winding_number p z) * (pathstart p - z)"
  3877      \<Longrightarrow> pathfinish p - z = exp (2 * pi * \<i> * winding_number p z) * (pathstart p - z)"
  3878 using winding_number [of p z 1] unfolding valid_path_def path_image_def pathstart_def pathfinish_def
  3878 using winding_number [of p z 1] unfolding valid_path_def path_image_def pathstart_def pathfinish_def
  3879   by (force dest: winding_number_exp_integral(2) [of _ 0 1 z] simp: field_simps contour_integral_integral exp_minus)
  3879   by (force dest: winding_number_exp_integral(2) [of _ 0 1 z] simp: field_simps contour_integral_integral exp_minus)
  3880 
  3880 
  3881 
  3881 
  3882 subsection\<open>The version with complex integers and equality\<close>
  3882 subsection\<open>The version with complex integers and equality\<close>
  4328   have *: "integral {0..x} (\<lambda>t. vector_derivative \<gamma> (at t) / (\<gamma> t - z)) / (2 * of_real pi * \<i>) =
  4328   have *: "integral {0..x} (\<lambda>t. vector_derivative \<gamma> (at t) / (\<gamma> t - z)) / (2 * of_real pi * \<i>) =
  4329          winding_number (subpath 0 x \<gamma>) z"
  4329          winding_number (subpath 0 x \<gamma>) z"
  4330          if x: "0 \<le> x" "x \<le> 1" for x
  4330          if x: "0 \<le> x" "x \<le> 1" for x
  4331   proof -
  4331   proof -
  4332     have "integral {0..x} (\<lambda>t. vector_derivative \<gamma> (at t) / (\<gamma> t - z)) / (2 * of_real pi * \<i>) =
  4332     have "integral {0..x} (\<lambda>t. vector_derivative \<gamma> (at t) / (\<gamma> t - z)) / (2 * of_real pi * \<i>) =
  4333           1 / (2*pi*ii) * contour_integral (subpath 0 x \<gamma>) (\<lambda>w. 1/(w - z))"
  4333           1 / (2*pi*\<i>) * contour_integral (subpath 0 x \<gamma>) (\<lambda>w. 1/(w - z))"
  4334       using assms x
  4334       using assms x
  4335       apply (simp add: contour_integral_subcontour_integral [OF contour_integrable_inversediff])
  4335       apply (simp add: contour_integral_subcontour_integral [OF contour_integrable_inversediff])
  4336       done
  4336       done
  4337     also have "... = winding_number (subpath 0 x \<gamma>) z"
  4337     also have "... = winding_number (subpath 0 x \<gamma>) z"
  4338       apply (subst winding_number_valid_path)
  4338       apply (subst winding_number_valid_path)
  4341       by (force simp: path_image_def)
  4341       by (force simp: path_image_def)
  4342     finally show ?thesis .
  4342     finally show ?thesis .
  4343   qed
  4343   qed
  4344   show ?thesis
  4344   show ?thesis
  4345     apply (rule continuous_on_eq
  4345     apply (rule continuous_on_eq
  4346                  [where f = "\<lambda>x. 1 / (2*pi*ii) *
  4346                  [where f = "\<lambda>x. 1 / (2*pi*\<i>) *
  4347                                  integral {0..x} (\<lambda>t. 1/(\<gamma> t - z) * vector_derivative \<gamma> (at t))"])
  4347                                  integral {0..x} (\<lambda>t. 1/(\<gamma> t - z) * vector_derivative \<gamma> (at t))"])
  4348     apply (rule continuous_intros)+
  4348     apply (rule continuous_intros)+
  4349     apply (rule indefinite_integral_continuous)
  4349     apply (rule indefinite_integral_continuous)
  4350     apply (rule contour_integrable_inversediff [OF assms, unfolded contour_integrable_on])
  4350     apply (rule contour_integrable_inversediff [OF assms, unfolded contour_integrable_on])
  4351       using assms
  4351       using assms
  4489 lemma Cauchy_integral_formula_weak:
  4489 lemma Cauchy_integral_formula_weak:
  4490     assumes s: "convex s" and "finite k" and conf: "continuous_on s f"
  4490     assumes s: "convex s" and "finite k" and conf: "continuous_on s f"
  4491         and fcd: "(\<And>x. x \<in> interior s - k \<Longrightarrow> f field_differentiable at x)"
  4491         and fcd: "(\<And>x. x \<in> interior s - k \<Longrightarrow> f field_differentiable at x)"
  4492         and z: "z \<in> interior s - k" and vpg: "valid_path \<gamma>"
  4492         and z: "z \<in> interior s - k" and vpg: "valid_path \<gamma>"
  4493         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  4493         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  4494       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * ii * winding_number \<gamma> z * f z)) \<gamma>"
  4494       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  4495 proof -
  4495 proof -
  4496   obtain f' where f': "(f has_field_derivative f') (at z)"
  4496   obtain f' where f': "(f has_field_derivative f') (at z)"
  4497     using fcd [OF z] by (auto simp: field_differentiable_def)
  4497     using fcd [OF z] by (auto simp: field_differentiable_def)
  4498   have pas: "path_image \<gamma> \<subseteq> s" and znotin: "z \<notin> path_image \<gamma>" using pasz by blast+
  4498   have pas: "path_image \<gamma> \<subseteq> s" and znotin: "z \<notin> path_image \<gamma>" using pasz by blast+
  4499   have c: "continuous (at x within s) (\<lambda>w. if w = z then f' else (f w - f z) / (w - z))" if "x \<in> s" for x
  4499   have c: "continuous (at x within s) (\<lambda>w. if w = z then f' else (f w - f z) / (w - z))" if "x \<in> s" for x
  4534 qed
  4534 qed
  4535 
  4535 
  4536 theorem Cauchy_integral_formula_convex_simple:
  4536 theorem Cauchy_integral_formula_convex_simple:
  4537     "\<lbrakk>convex s; f holomorphic_on s; z \<in> interior s; valid_path \<gamma>; path_image \<gamma> \<subseteq> s - {z};
  4537     "\<lbrakk>convex s; f holomorphic_on s; z \<in> interior s; valid_path \<gamma>; path_image \<gamma> \<subseteq> s - {z};
  4538       pathfinish \<gamma> = pathstart \<gamma>\<rbrakk>
  4538       pathfinish \<gamma> = pathstart \<gamma>\<rbrakk>
  4539      \<Longrightarrow> ((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * ii * winding_number \<gamma> z * f z)) \<gamma>"
  4539      \<Longrightarrow> ((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  4540   apply (rule Cauchy_integral_formula_weak [where k = "{}"])
  4540   apply (rule Cauchy_integral_formula_weak [where k = "{}"])
  4541   using holomorphic_on_imp_continuous_on
  4541   using holomorphic_on_imp_continuous_on
  4542   by auto (metis at_within_interior holomorphic_on_def interiorE subsetCE)
  4542   by auto (metis at_within_interior holomorphic_on_def interiorE subsetCE)
  4543 
  4543 
  4544 
  4544 
  4854 
  4854 
  4855 
  4855 
  4856 subsection\<open>Partial circle path\<close>
  4856 subsection\<open>Partial circle path\<close>
  4857 
  4857 
  4858 definition part_circlepath :: "[complex, real, real, real, real] \<Rightarrow> complex"
  4858 definition part_circlepath :: "[complex, real, real, real, real] \<Rightarrow> complex"
  4859   where "part_circlepath z r s t \<equiv> \<lambda>x. z + of_real r * exp (ii * of_real (linepath s t x))"
  4859   where "part_circlepath z r s t \<equiv> \<lambda>x. z + of_real r * exp (\<i> * of_real (linepath s t x))"
  4860 
  4860 
  4861 lemma pathstart_part_circlepath [simp]:
  4861 lemma pathstart_part_circlepath [simp]:
  4862      "pathstart(part_circlepath z r s t) = z + r*exp(ii * s)"
  4862      "pathstart(part_circlepath z r s t) = z + r*exp(\<i> * s)"
  4863 by (metis part_circlepath_def pathstart_def pathstart_linepath)
  4863 by (metis part_circlepath_def pathstart_def pathstart_linepath)
  4864 
  4864 
  4865 lemma pathfinish_part_circlepath [simp]:
  4865 lemma pathfinish_part_circlepath [simp]:
  4866      "pathfinish(part_circlepath z r s t) = z + r*exp(ii*t)"
  4866      "pathfinish(part_circlepath z r s t) = z + r*exp(\<i>*t)"
  4867 by (metis part_circlepath_def pathfinish_def pathfinish_linepath)
  4867 by (metis part_circlepath_def pathfinish_def pathfinish_linepath)
  4868 
  4868 
  4869 proposition has_vector_derivative_part_circlepath [derivative_intros]:
  4869 proposition has_vector_derivative_part_circlepath [derivative_intros]:
  4870     "((part_circlepath z r s t) has_vector_derivative
  4870     "((part_circlepath z r s t) has_vector_derivative
  4871       (ii * r * (of_real t - of_real s) * exp(ii * linepath s t x)))
  4871       (\<i> * r * (of_real t - of_real s) * exp(\<i> * linepath s t x)))
  4872      (at x within X)"
  4872      (at x within X)"
  4873   apply (simp add: part_circlepath_def linepath_def scaleR_conv_of_real)
  4873   apply (simp add: part_circlepath_def linepath_def scaleR_conv_of_real)
  4874   apply (rule has_vector_derivative_real_complex)
  4874   apply (rule has_vector_derivative_real_complex)
  4875   apply (rule derivative_eq_intros | simp)+
  4875   apply (rule derivative_eq_intros | simp)+
  4876   done
  4876   done
  4877 
  4877 
  4878 corollary vector_derivative_part_circlepath:
  4878 corollary vector_derivative_part_circlepath:
  4879     "vector_derivative (part_circlepath z r s t) (at x) =
  4879     "vector_derivative (part_circlepath z r s t) (at x) =
  4880        ii * r * (of_real t - of_real s) * exp(ii * linepath s t x)"
  4880        \<i> * r * (of_real t - of_real s) * exp(\<i> * linepath s t x)"
  4881   using has_vector_derivative_part_circlepath vector_derivative_at by blast
  4881   using has_vector_derivative_part_circlepath vector_derivative_at by blast
  4882 
  4882 
  4883 corollary vector_derivative_part_circlepath01:
  4883 corollary vector_derivative_part_circlepath01:
  4884     "\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk>
  4884     "\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk>
  4885      \<Longrightarrow> vector_derivative (part_circlepath z r s t) (at x within {0..1}) =
  4885      \<Longrightarrow> vector_derivative (part_circlepath z r s t) (at x within {0..1}) =
  4886           ii * r * (of_real t - of_real s) * exp(ii * linepath s t x)"
  4886           \<i> * r * (of_real t - of_real s) * exp(\<i> * linepath s t x)"
  4887   using has_vector_derivative_part_circlepath
  4887   using has_vector_derivative_part_circlepath
  4888   by (auto simp: vector_derivative_at_within_ivl)
  4888   by (auto simp: vector_derivative_at_within_ivl)
  4889 
  4889 
  4890 lemma valid_path_part_circlepath [simp]: "valid_path (part_circlepath z r s t)"
  4890 lemma valid_path_part_circlepath [simp]: "valid_path (part_circlepath z r s t)"
  4891   apply (simp add: valid_path_def)
  4891   apply (simp add: valid_path_def)
  4897 lemma path_part_circlepath [simp]: "path (part_circlepath z r s t)"
  4897 lemma path_part_circlepath [simp]: "path (part_circlepath z r s t)"
  4898   by (simp add: valid_path_imp_path)
  4898   by (simp add: valid_path_imp_path)
  4899 
  4899 
  4900 proposition path_image_part_circlepath:
  4900 proposition path_image_part_circlepath:
  4901   assumes "s \<le> t"
  4901   assumes "s \<le> t"
  4902     shows "path_image (part_circlepath z r s t) = {z + r * exp(ii * of_real x) | x. s \<le> x \<and> x \<le> t}"
  4902     shows "path_image (part_circlepath z r s t) = {z + r * exp(\<i> * of_real x) | x. s \<le> x \<and> x \<le> t}"
  4903 proof -
  4903 proof -
  4904   { fix z::real
  4904   { fix z::real
  4905     assume "0 \<le> z" "z \<le> 1"
  4905     assume "0 \<le> z" "z \<le> 1"
  4906     with \<open>s \<le> t\<close> have "\<exists>x. (exp (\<i> * linepath s t z) = exp (\<i> * of_real x)) \<and> s \<le> x \<and> x \<le> t"
  4906     with \<open>s \<le> t\<close> have "\<exists>x. (exp (\<i> * linepath s t z) = exp (\<i> * of_real x)) \<and> s \<le> x \<and> x \<le> t"
  4907       apply (rule_tac x="(1 - z) * s + z * t" in exI)
  4907       apply (rule_tac x="(1 - z) * s + z * t" in exI)
  4984     have [simp]: "\<bar>r\<bar> = r" using \<open>r > 0\<close> by linarith
  4984     have [simp]: "\<bar>r\<bar> = r" using \<open>r > 0\<close> by linarith
  4985     have [simp]: "cmod (complex_of_real t - complex_of_real s) = t-s"
  4985     have [simp]: "cmod (complex_of_real t - complex_of_real s) = t-s"
  4986       by (metis "2" abs_of_pos diff_gt_0_iff_gt norm_of_real of_real_diff)
  4986       by (metis "2" abs_of_pos diff_gt_0_iff_gt norm_of_real of_real_diff)
  4987     have "finite (part_circlepath z r s t -` {y} \<inter> {0..1})" if "y \<in> k" for y
  4987     have "finite (part_circlepath z r s t -` {y} \<inter> {0..1})" if "y \<in> k" for y
  4988     proof -
  4988     proof -
  4989       define w where "w = (y - z)/of_real r / exp(ii * of_real s)"
  4989       define w where "w = (y - z)/of_real r / exp(\<i> * of_real s)"
  4990       have fin: "finite (of_real -` {z. cmod z \<le> 1 \<and> exp (\<i> * complex_of_real (t - s) * z) = w})"
  4990       have fin: "finite (of_real -` {z. cmod z \<le> 1 \<and> exp (\<i> * complex_of_real (t - s) * z) = w})"
  4991         apply (rule finite_vimageI [OF finite_bounded_log2])
  4991         apply (rule finite_vimageI [OF finite_bounded_log2])
  4992         using \<open>s < t\<close> apply (auto simp: inj_of_real)
  4992         using \<open>s < t\<close> apply (auto simp: inj_of_real)
  4993         done
  4993         done
  4994       show ?thesis
  4994       show ?thesis
  5061     apply (rule disjE)
  5061     apply (rule disjE)
  5062     apply (force simp: part_circlepath_def simple_path_def intro: bexI [where x = "1/4"] bexI [where x = "1/3"])+
  5062     apply (force simp: part_circlepath_def simple_path_def intro: bexI [where x = "1/4"] bexI [where x = "1/3"])+
  5063     done
  5063     done
  5064 next
  5064 next
  5065   case False then have "r \<noteq> 0" "s \<noteq> t" by auto
  5065   case False then have "r \<noteq> 0" "s \<noteq> t" by auto
  5066   have *: "\<And>x y z s t. ii*((1 - x) * s + x * t) = ii*(((1 - y) * s + y * t)) + z  \<longleftrightarrow> ii*(x - y) * (t - s) = z"
  5066   have *: "\<And>x y z s t. \<i>*((1 - x) * s + x * t) = \<i>*(((1 - y) * s + y * t)) + z  \<longleftrightarrow> \<i>*(x - y) * (t - s) = z"
  5067     by (simp add: algebra_simps)
  5067     by (simp add: algebra_simps)
  5068   have abs01: "\<And>x y::real. 0 \<le> x \<and> x \<le> 1 \<and> 0 \<le> y \<and> y \<le> 1
  5068   have abs01: "\<And>x y::real. 0 \<le> x \<and> x \<le> 1 \<and> 0 \<le> y \<and> y \<le> 1
  5069                       \<Longrightarrow> (x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0 \<longleftrightarrow> \<bar>x - y\<bar> \<in> {0,1})"
  5069                       \<Longrightarrow> (x = y \<or> x = 0 \<and> y = 1 \<or> x = 1 \<and> y = 0 \<longleftrightarrow> \<bar>x - y\<bar> \<in> {0,1})"
  5070     by auto
  5070     by auto
  5071   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)"
  5071   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)"
  5132 subsection\<open>Special case of one complete circle\<close>
  5132 subsection\<open>Special case of one complete circle\<close>
  5133 
  5133 
  5134 definition circlepath :: "[complex, real, real] \<Rightarrow> complex"
  5134 definition circlepath :: "[complex, real, real] \<Rightarrow> complex"
  5135   where "circlepath z r \<equiv> part_circlepath z r 0 (2*pi)"
  5135   where "circlepath z r \<equiv> part_circlepath z r 0 (2*pi)"
  5136 
  5136 
  5137 lemma circlepath: "circlepath z r = (\<lambda>x. z + r * exp(2 * of_real pi * ii * of_real x))"
  5137 lemma circlepath: "circlepath z r = (\<lambda>x. z + r * exp(2 * of_real pi * \<i> * of_real x))"
  5138   by (simp add: circlepath_def part_circlepath_def linepath_def algebra_simps)
  5138   by (simp add: circlepath_def part_circlepath_def linepath_def algebra_simps)
  5139 
  5139 
  5140 lemma pathstart_circlepath [simp]: "pathstart (circlepath z r) = z + r"
  5140 lemma pathstart_circlepath [simp]: "pathstart (circlepath z r) = z + r"
  5141   by (simp add: circlepath_def)
  5141   by (simp add: circlepath_def)
  5142 
  5142 
  5171 
  5171 
  5172 lemma path_image_circlepath_minus: "path_image (circlepath z (-r)) = path_image (circlepath z r)"
  5172 lemma path_image_circlepath_minus: "path_image (circlepath z (-r)) = path_image (circlepath z r)"
  5173   using path_image_circlepath_minus_subset by fastforce
  5173   using path_image_circlepath_minus_subset by fastforce
  5174 
  5174 
  5175 proposition has_vector_derivative_circlepath [derivative_intros]:
  5175 proposition has_vector_derivative_circlepath [derivative_intros]:
  5176  "((circlepath z r) has_vector_derivative (2 * pi * ii * r * exp (2 * of_real pi * ii * of_real x)))
  5176  "((circlepath z r) has_vector_derivative (2 * pi * \<i> * r * exp (2 * of_real pi * \<i> * of_real x)))
  5177    (at x within X)"
  5177    (at x within X)"
  5178   apply (simp add: circlepath_def scaleR_conv_of_real)
  5178   apply (simp add: circlepath_def scaleR_conv_of_real)
  5179   apply (rule derivative_eq_intros)
  5179   apply (rule derivative_eq_intros)
  5180   apply (simp add: algebra_simps)
  5180   apply (simp add: algebra_simps)
  5181   done
  5181   done
  5182 
  5182 
  5183 corollary vector_derivative_circlepath:
  5183 corollary vector_derivative_circlepath:
  5184    "vector_derivative (circlepath z r) (at x) =
  5184    "vector_derivative (circlepath z r) (at x) =
  5185     2 * pi * ii * r * exp(2 * of_real pi * ii * x)"
  5185     2 * pi * \<i> * r * exp(2 * of_real pi * \<i> * x)"
  5186 using has_vector_derivative_circlepath vector_derivative_at by blast
  5186 using has_vector_derivative_circlepath vector_derivative_at by blast
  5187 
  5187 
  5188 corollary vector_derivative_circlepath01:
  5188 corollary vector_derivative_circlepath01:
  5189     "\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk>
  5189     "\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk>
  5190      \<Longrightarrow> vector_derivative (circlepath z r) (at x within {0..1}) =
  5190      \<Longrightarrow> vector_derivative (circlepath z r) (at x within {0..1}) =
  5191           2 * pi * ii * r * exp(2 * of_real pi * ii * x)"
  5191           2 * pi * \<i> * r * exp(2 * of_real pi * \<i> * x)"
  5192   using has_vector_derivative_circlepath
  5192   using has_vector_derivative_circlepath
  5193   by (auto simp: vector_derivative_at_within_ivl)
  5193   by (auto simp: vector_derivative_at_within_ivl)
  5194 
  5194 
  5195 lemma valid_path_circlepath [simp]: "valid_path (circlepath z r)"
  5195 lemma valid_path_circlepath [simp]: "valid_path (circlepath z r)"
  5196   by (simp add: circlepath_def)
  5196   by (simp add: circlepath_def)
  5298 
  5298 
  5299 text\<open> Hence the Cauchy formula for points inside a circle.\<close>
  5299 text\<open> Hence the Cauchy formula for points inside a circle.\<close>
  5300 
  5300 
  5301 theorem Cauchy_integral_circlepath:
  5301 theorem Cauchy_integral_circlepath:
  5302   assumes "continuous_on (cball z r) f" "f holomorphic_on (ball z r)" "norm(w - z) < r"
  5302   assumes "continuous_on (cball z r) f" "f holomorphic_on (ball z r)" "norm(w - z) < r"
  5303   shows "((\<lambda>u. f u/(u - w)) has_contour_integral (2 * of_real pi * ii * f w))
  5303   shows "((\<lambda>u. f u/(u - w)) has_contour_integral (2 * of_real pi * \<i> * f w))
  5304          (circlepath z r)"
  5304          (circlepath z r)"
  5305 proof -
  5305 proof -
  5306   have "r > 0"
  5306   have "r > 0"
  5307     using assms le_less_trans norm_ge_zero by blast
  5307     using assms le_less_trans norm_ge_zero by blast
  5308   have "((\<lambda>u. f u / (u - w)) has_contour_integral (2 * pi) * \<i> * winding_number (circlepath z r) w * f w)
  5308   have "((\<lambda>u. f u / (u - w)) has_contour_integral (2 * pi) * \<i> * winding_number (circlepath z r) w * f w)
  5318     by (simp add: winding_number_circlepath assms)
  5318     by (simp add: winding_number_circlepath assms)
  5319 qed
  5319 qed
  5320 
  5320 
  5321 corollary Cauchy_integral_circlepath_simple:
  5321 corollary Cauchy_integral_circlepath_simple:
  5322   assumes "f holomorphic_on cball z r" "norm(w - z) < r"
  5322   assumes "f holomorphic_on cball z r" "norm(w - z) < r"
  5323   shows "((\<lambda>u. f u/(u - w)) has_contour_integral (2 * of_real pi * ii * f w))
  5323   shows "((\<lambda>u. f u/(u - w)) has_contour_integral (2 * of_real pi * \<i> * f w))
  5324          (circlepath z r)"
  5324          (circlepath z r)"
  5325 using assms by (force simp: holomorphic_on_imp_continuous_on holomorphic_on_subset Cauchy_integral_circlepath)
  5325 using assms by (force simp: holomorphic_on_imp_continuous_on holomorphic_on_subset Cauchy_integral_circlepath)
  5326 
  5326 
  5327 
  5327 
  5328 lemma no_bounded_connected_component_imp_winding_number_zero:
  5328 lemma no_bounded_connected_component_imp_winding_number_zero:
  5632   assumes contf: "continuous_on (cball z r) f"
  5632   assumes contf: "continuous_on (cball z r) f"
  5633       and holf: "f holomorphic_on ball z r"
  5633       and holf: "f holomorphic_on ball z r"
  5634       and w: "w \<in> ball z r"
  5634       and w: "w \<in> ball z r"
  5635     shows "(\<lambda>u. f u/(u - w)^2) contour_integrable_on (circlepath z r)"
  5635     shows "(\<lambda>u. f u/(u - w)^2) contour_integrable_on (circlepath z r)"
  5636            (is "?thes1")
  5636            (is "?thes1")
  5637       and "(f has_field_derivative (1 / (2 * of_real pi * ii) * contour_integral(circlepath z r) (\<lambda>u. f u / (u - w)^2))) (at w)"
  5637       and "(f has_field_derivative (1 / (2 * of_real pi * \<i>) * contour_integral(circlepath z r) (\<lambda>u. f u / (u - w)^2))) (at w)"
  5638            (is "?thes2")
  5638            (is "?thes2")
  5639 proof -
  5639 proof -
  5640   have [simp]: "r \<ge> 0" using w
  5640   have [simp]: "r \<ge> 0" using w
  5641     using ball_eq_empty by fastforce
  5641     using ball_eq_empty by fastforce
  5642   have f: "continuous_on (path_image (circlepath z r)) f"
  5642   have f: "continuous_on (path_image (circlepath z r)) f"
  5643     by (rule continuous_on_subset [OF contf]) (force simp add: cball_def sphere_def)
  5643     by (rule continuous_on_subset [OF contf]) (force simp add: cball_def sphere_def)
  5644   have int: "\<And>w. dist z w < r \<Longrightarrow>
  5644   have int: "\<And>w. dist z w < r \<Longrightarrow>
  5645                  ((\<lambda>u. f u / (u - w)) has_contour_integral (\<lambda>x. 2 * of_real pi * ii * f x) w) (circlepath z r)"
  5645                  ((\<lambda>u. f u / (u - w)) has_contour_integral (\<lambda>x. 2 * of_real pi * \<i> * f x) w) (circlepath z r)"
  5646     by (rule Cauchy_integral_circlepath [OF contf holf]) (simp add: dist_norm norm_minus_commute)
  5646     by (rule Cauchy_integral_circlepath [OF contf holf]) (simp add: dist_norm norm_minus_commute)
  5647   show ?thes1
  5647   show ?thes1
  5648     apply (simp add: power2_eq_square)
  5648     apply (simp add: power2_eq_square)
  5649     apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1, simplified])
  5649     apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1, simplified])
  5650     apply (blast intro: int)
  5650     apply (blast intro: int)
  5651     done
  5651     done
  5652   have "((\<lambda>x. 2 * of_real pi * \<i> * f x) has_field_derivative contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)^2)) (at w)"
  5652   have "((\<lambda>x. 2 * of_real pi * \<i> * f x) has_field_derivative contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)^2)) (at w)"
  5653     apply (simp add: power2_eq_square)
  5653     apply (simp add: power2_eq_square)
  5654     apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1 and g = "\<lambda>x. 2 * of_real pi * ii * f x", simplified])
  5654     apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1 and g = "\<lambda>x. 2 * of_real pi * \<i> * f x", simplified])
  5655     apply (blast intro: int)
  5655     apply (blast intro: int)
  5656     done
  5656     done
  5657   then have fder: "(f has_field_derivative contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)^2) / (2 * of_real pi * \<i>)) (at w)"
  5657   then have fder: "(f has_field_derivative contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)^2) / (2 * of_real pi * \<i>)) (at w)"
  5658     by (rule DERIV_cdivide [where f = "\<lambda>x. 2 * of_real pi * \<i> * f x" and c = "2 * of_real pi * \<i>", simplified])
  5658     by (rule DERIV_cdivide [where f = "\<lambda>x. 2 * of_real pi * \<i> * f x" and c = "2 * of_real pi * \<i>", simplified])
  5659   show ?thes2
  5659   show ?thes2
  5674     then have holf_cball: "f holomorphic_on cball z r"
  5674     then have holf_cball: "f holomorphic_on cball z r"
  5675       apply (simp add: holomorphic_on_def)
  5675       apply (simp add: holomorphic_on_def)
  5676       using field_differentiable_at_within field_differentiable_def fder by blast
  5676       using field_differentiable_at_within field_differentiable_def fder by blast
  5677     then have "continuous_on (path_image (circlepath z r)) f"
  5677     then have "continuous_on (path_image (circlepath z r)) f"
  5678       using \<open>r > 0\<close> by (force elim: holomorphic_on_subset [THEN holomorphic_on_imp_continuous_on])
  5678       using \<open>r > 0\<close> by (force elim: holomorphic_on_subset [THEN holomorphic_on_imp_continuous_on])
  5679     then have contfpi: "continuous_on (path_image (circlepath z r)) (\<lambda>x. 1/(2 * of_real pi*ii) * f x)"
  5679     then have contfpi: "continuous_on (path_image (circlepath z r)) (\<lambda>x. 1/(2 * of_real pi*\<i>) * f x)"
  5680       by (auto intro: continuous_intros)+
  5680       by (auto intro: continuous_intros)+
  5681     have contf_cball: "continuous_on (cball z r) f" using holf_cball
  5681     have contf_cball: "continuous_on (cball z r) f" using holf_cball
  5682       by (simp add: holomorphic_on_imp_continuous_on holomorphic_on_subset)
  5682       by (simp add: holomorphic_on_imp_continuous_on holomorphic_on_subset)
  5683     have holf_ball: "f holomorphic_on ball z r" using holf_cball
  5683     have holf_ball: "f holomorphic_on ball z r" using holf_cball
  5684       using ball_subset_cball holomorphic_on_subset by blast
  5684       using ball_subset_cball holomorphic_on_subset by blast
  6077 proposition Cauchy_integral_formula_convex:
  6077 proposition Cauchy_integral_formula_convex:
  6078     assumes s: "convex s" and k: "finite k" and contf: "continuous_on s f"
  6078     assumes s: "convex s" and k: "finite k" and contf: "continuous_on s f"
  6079         and fcd: "(\<And>x. x \<in> interior s - k \<Longrightarrow> f field_differentiable at x)"
  6079         and fcd: "(\<And>x. x \<in> interior s - k \<Longrightarrow> f field_differentiable at x)"
  6080         and z: "z \<in> interior s" and vpg: "valid_path \<gamma>"
  6080         and z: "z \<in> interior s" and vpg: "valid_path \<gamma>"
  6081         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  6081         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  6082       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * ii * winding_number \<gamma> z * f z)) \<gamma>"
  6082       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  6083   apply (rule Cauchy_integral_formula_weak [OF s finite.emptyI contf])
  6083   apply (rule Cauchy_integral_formula_weak [OF s finite.emptyI contf])
  6084   apply (simp add: holomorphic_on_open [symmetric] field_differentiable_def)
  6084   apply (simp add: holomorphic_on_open [symmetric] field_differentiable_def)
  6085   using no_isolated_singularity [where s = "interior s"]
  6085   using no_isolated_singularity [where s = "interior s"]
  6086   apply (metis k contf fcd holomorphic_on_open field_differentiable_def continuous_on_subset
  6086   apply (metis k contf fcd holomorphic_on_open field_differentiable_def continuous_on_subset
  6087                has_field_derivative_at_within holomorphic_on_def interior_subset open_interior)
  6087                has_field_derivative_at_within holomorphic_on_def interior_subset open_interior)
  6094 
  6094 
  6095 proposition Cauchy_has_contour_integral_higher_derivative_circlepath:
  6095 proposition Cauchy_has_contour_integral_higher_derivative_circlepath:
  6096   assumes contf: "continuous_on (cball z r) f"
  6096   assumes contf: "continuous_on (cball z r) f"
  6097       and holf: "f holomorphic_on ball z r"
  6097       and holf: "f holomorphic_on ball z r"
  6098       and w: "w \<in> ball z r"
  6098       and w: "w \<in> ball z r"
  6099     shows "((\<lambda>u. f u / (u - w) ^ (Suc k)) has_contour_integral ((2 * pi * ii) / (fact k) * (deriv ^^ k) f w))
  6099     shows "((\<lambda>u. f u / (u - w) ^ (Suc k)) has_contour_integral ((2 * pi * \<i>) / (fact k) * (deriv ^^ k) f w))
  6100            (circlepath z r)"
  6100            (circlepath z r)"
  6101 using w
  6101 using w
  6102 proof (induction k arbitrary: w)
  6102 proof (induction k arbitrary: w)
  6103   case 0 then show ?case
  6103   case 0 then show ?case
  6104     using assms by (auto simp: Cauchy_integral_circlepath dist_commute dist_norm)
  6104     using assms by (auto simp: Cauchy_integral_circlepath dist_commute dist_norm)
  6135   assumes contf: "continuous_on (cball z r) f"
  6135   assumes contf: "continuous_on (cball z r) f"
  6136       and holf: "f holomorphic_on ball z r"
  6136       and holf: "f holomorphic_on ball z r"
  6137       and w: "w \<in> ball z r"
  6137       and w: "w \<in> ball z r"
  6138     shows "(\<lambda>u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)"
  6138     shows "(\<lambda>u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)"
  6139            (is "?thes1")
  6139            (is "?thes1")
  6140       and "(deriv ^^ k) f w = (fact k) / (2 * pi * ii) * contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^(Suc k))"
  6140       and "(deriv ^^ k) f w = (fact k) / (2 * pi * \<i>) * contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^(Suc k))"
  6141            (is "?thes2")
  6141            (is "?thes2")
  6142 proof -
  6142 proof -
  6143   have *: "((\<lambda>u. f u / (u - w) ^ Suc k) has_contour_integral (2 * pi) * \<i> / (fact k) * (deriv ^^ k) f w)
  6143   have *: "((\<lambda>u. f u / (u - w) ^ Suc k) has_contour_integral (2 * pi) * \<i> / (fact k) * (deriv ^^ k) f w)
  6144            (circlepath z r)"
  6144            (circlepath z r)"
  6145     using Cauchy_has_contour_integral_higher_derivative_circlepath [OF assms]
  6145     using Cauchy_has_contour_integral_higher_derivative_circlepath [OF assms]
  6150     unfolding contour_integral_unique [OF *] by (simp add: divide_simps)
  6150     unfolding contour_integral_unique [OF *] by (simp add: divide_simps)
  6151 qed
  6151 qed
  6152 
  6152 
  6153 corollary Cauchy_contour_integral_circlepath:
  6153 corollary Cauchy_contour_integral_circlepath:
  6154   assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \<in> ball z r"
  6154   assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \<in> ball z r"
  6155     shows "contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^(Suc k)) = (2 * pi * ii) * (deriv ^^ k) f w / (fact k)"
  6155     shows "contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^(Suc k)) = (2 * pi * \<i>) * (deriv ^^ k) f w / (fact k)"
  6156 by (simp add: Cauchy_higher_derivative_integral_circlepath [OF assms])
  6156 by (simp add: Cauchy_higher_derivative_integral_circlepath [OF assms])
  6157 
  6157 
  6158 corollary Cauchy_contour_integral_circlepath_2:
  6158 corollary Cauchy_contour_integral_circlepath_2:
  6159   assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \<in> ball z r"
  6159   assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \<in> ball z r"
  6160     shows "contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^2) = (2 * pi * ii) * deriv f w"
  6160     shows "contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^2) = (2 * pi * \<i>) * deriv f w"
  6161   using Cauchy_contour_integral_circlepath [OF assms, of 1]
  6161   using Cauchy_contour_integral_circlepath [OF assms, of 1]
  6162   by (simp add: power2_eq_square)
  6162   by (simp add: power2_eq_square)
  6163 
  6163 
  6164 
  6164 
  6165 subsection\<open>A holomorphic function is analytic, i.e. has local power series.\<close>
  6165 subsection\<open>A holomorphic function is analytic, i.e. has local power series.\<close>
  6261     apply (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf])
  6261     apply (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf])
  6262     using \<open>0 < r\<close>
  6262     using \<open>0 < r\<close>
  6263     apply auto
  6263     apply auto
  6264     done
  6264     done
  6265   then have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u/(u - z)^(Suc k)) * (w - z)^k)
  6265   then have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u/(u - z)^(Suc k)) * (w - z)^k)
  6266              sums (2 * of_real pi * ii * f w)"
  6266              sums (2 * of_real pi * \<i> * f w)"
  6267     using w by (auto simp: dist_commute dist_norm contour_integral_unique [OF Cauchy_integral_circlepath_simple [OF holfc]])
  6267     using w by (auto simp: dist_commute dist_norm contour_integral_unique [OF Cauchy_integral_circlepath_simple [OF holfc]])
  6268   then have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc k) * (w - z)^k / (\<i> * (of_real pi * 2)))
  6268   then have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc k) * (w - z)^k / (\<i> * (of_real pi * 2)))
  6269             sums ((2 * of_real pi * ii * f w) / (\<i> * (complex_of_real pi * 2)))"
  6269             sums ((2 * of_real pi * \<i> * f w) / (\<i> * (complex_of_real pi * 2)))"
  6270     by (rule sums_divide)
  6270     by (rule sums_divide)
  6271   then have "(\<lambda>n. (w - z) ^ n * contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc n) / (\<i> * (of_real pi * 2)))
  6271   then have "(\<lambda>n. (w - z) ^ n * contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc n) / (\<i> * (of_real pi * 2)))
  6272             sums f w"
  6272             sums f w"
  6273     by (simp add: field_simps)
  6273     by (simp add: field_simps)
  6274   then show ?thesis
  6274   then show ?thesis
  6405       done
  6405       done
  6406     have g_cint: "(\<lambda>u. g u/(u - w)) contour_integrable_on circlepath z r"
  6406     have g_cint: "(\<lambda>u. g u/(u - w)) contour_integrable_on circlepath z r"
  6407       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6407       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6408     have cif_tends_cig: "((\<lambda>n. contour_integral(circlepath z r) (\<lambda>u. f n u / (u - w))) \<longlongrightarrow> contour_integral(circlepath z r) (\<lambda>u. g u/(u - w))) F"
  6408     have cif_tends_cig: "((\<lambda>n. contour_integral(circlepath z r) (\<lambda>u. f n u / (u - w))) \<longlongrightarrow> contour_integral(circlepath z r) (\<lambda>u. g u/(u - w))) F"
  6409       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6409       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6410     have f_tends_cig: "((\<lambda>n. 2 * of_real pi * ii * f n w) \<longlongrightarrow> contour_integral (circlepath z r) (\<lambda>u. g u / (u - w))) F"
  6410     have f_tends_cig: "((\<lambda>n. 2 * of_real pi * \<i> * f n w) \<longlongrightarrow> contour_integral (circlepath z r) (\<lambda>u. g u / (u - w))) F"
  6411       apply (rule Lim_transform_eventually [where f = "\<lambda>n. contour_integral (circlepath z r) (\<lambda>u. f n u/(u - w))"])
  6411       apply (rule Lim_transform_eventually [where f = "\<lambda>n. contour_integral (circlepath z r) (\<lambda>u. f n u/(u - w))"])
  6412       apply (rule eventually_mono [OF cont])
  6412       apply (rule eventually_mono [OF cont])
  6413       apply (rule contour_integral_unique [OF Cauchy_integral_circlepath])
  6413       apply (rule contour_integral_unique [OF Cauchy_integral_circlepath])
  6414       using w
  6414       using w
  6415       apply (auto simp: norm_minus_commute dist_norm cif_tends_cig)
  6415       apply (auto simp: norm_minus_commute dist_norm cif_tends_cig)
  7075 lemma Cauchy_integral_formula_global_weak:
  7075 lemma Cauchy_integral_formula_global_weak:
  7076     assumes u: "open u" and holf: "f holomorphic_on u"
  7076     assumes u: "open u" and holf: "f holomorphic_on u"
  7077         and z: "z \<in> u" and \<gamma>: "polynomial_function \<gamma>"
  7077         and z: "z \<in> u" and \<gamma>: "polynomial_function \<gamma>"
  7078         and pasz: "path_image \<gamma> \<subseteq> u - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7078         and pasz: "path_image \<gamma> \<subseteq> u - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7079         and zero: "\<And>w. w \<notin> u \<Longrightarrow> winding_number \<gamma> w = 0"
  7079         and zero: "\<And>w. w \<notin> u \<Longrightarrow> winding_number \<gamma> w = 0"
  7080       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * ii * winding_number \<gamma> z * f z)) \<gamma>"
  7080       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  7081 proof -
  7081 proof -
  7082   obtain \<gamma>' where pf\<gamma>': "polynomial_function \<gamma>'" and \<gamma>': "\<And>x. (\<gamma> has_vector_derivative (\<gamma>' x)) (at x)"
  7082   obtain \<gamma>' where pf\<gamma>': "polynomial_function \<gamma>'" and \<gamma>': "\<And>x. (\<gamma> has_vector_derivative (\<gamma>' x)) (at x)"
  7083     using has_vector_derivative_polynomial_function [OF \<gamma>] by blast
  7083     using has_vector_derivative_polynomial_function [OF \<gamma>] by blast
  7084   then have "bounded(path_image \<gamma>')"
  7084   then have "bounded(path_image \<gamma>')"
  7085     by (simp add: path_image_def compact_imp_bounded compact_continuous_image continuous_on_polymonial_function)
  7085     by (simp add: path_image_def compact_imp_bounded compact_continuous_image continuous_on_polymonial_function)
  7466 theorem Cauchy_integral_formula_global:
  7466 theorem Cauchy_integral_formula_global:
  7467     assumes s: "open s" and holf: "f holomorphic_on s"
  7467     assumes s: "open s" and holf: "f holomorphic_on s"
  7468         and z: "z \<in> s" and vpg: "valid_path \<gamma>"
  7468         and z: "z \<in> s" and vpg: "valid_path \<gamma>"
  7469         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7469         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7470         and zero: "\<And>w. w \<notin> s \<Longrightarrow> winding_number \<gamma> w = 0"
  7470         and zero: "\<And>w. w \<notin> s \<Longrightarrow> winding_number \<gamma> w = 0"
  7471       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * ii * winding_number \<gamma> z * f z)) \<gamma>"
  7471       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  7472 proof -
  7472 proof -
  7473   have "path \<gamma>" using vpg by (blast intro: valid_path_imp_path)
  7473   have "path \<gamma>" using vpg by (blast intro: valid_path_imp_path)
  7474   have hols: "(\<lambda>w. f w / (w - z)) holomorphic_on s - {z}" "(\<lambda>w. 1 / (w - z)) holomorphic_on s - {z}"
  7474   have hols: "(\<lambda>w. f w / (w - z)) holomorphic_on s - {z}" "(\<lambda>w. 1 / (w - z)) holomorphic_on s - {z}"
  7475     by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+
  7475     by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+
  7476   then have cint_fw: "(\<lambda>w. f w / (w - z)) contour_integrable_on \<gamma>"
  7476   then have cint_fw: "(\<lambda>w. f w / (w - z)) contour_integrable_on \<gamma>"