src/HOL/Analysis/Cauchy_Integral_Theorem.thy
changeset 65036 ab7e11730ad8
parent 64788 19f3d4af7a7d
child 65037 2cf841ff23be
equal deleted inserted replaced
65035:b46fe5138cb0 65036:ab7e11730ad8
    80       \<Longrightarrow> (g o f) piecewise_differentiable_on s"
    80       \<Longrightarrow> (g o f) piecewise_differentiable_on s"
    81   apply (simp add: piecewise_differentiable_on_def, safe)
    81   apply (simp add: piecewise_differentiable_on_def, safe)
    82   apply (blast intro: continuous_on_compose2)
    82   apply (blast intro: continuous_on_compose2)
    83   apply (rename_tac A B)
    83   apply (rename_tac A B)
    84   apply (rule_tac x="A \<union> (\<Union>x\<in>B. s \<inter> f-`{x})" in exI)
    84   apply (rule_tac x="A \<union> (\<Union>x\<in>B. s \<inter> f-`{x})" in exI)
    85   apply (blast intro: differentiable_chain_within)
    85   apply (blast intro!: differentiable_chain_within)
    86   done
    86   done
    87 
    87 
    88 lemma piecewise_differentiable_affine:
    88 lemma piecewise_differentiable_affine:
    89   fixes m::real
    89   fixes m::real
    90   assumes "f piecewise_differentiable_on ((\<lambda>x. m *\<^sub>R x + c) ` s)"
    90   assumes "f piecewise_differentiable_on ((\<lambda>x. m *\<^sub>R x + c) ` s)"
  5170 
  5170 
  5171 text\<open>Uniform convergence when the derivative of the path is bounded, and in particular for the special case of a circle.\<close>
  5171 text\<open>Uniform convergence when the derivative of the path is bounded, and in particular for the special case of a circle.\<close>
  5172 
  5172 
  5173 proposition contour_integral_uniform_limit:
  5173 proposition contour_integral_uniform_limit:
  5174   assumes ev_fint: "eventually (\<lambda>n::'a. (f n) contour_integrable_on \<gamma>) F"
  5174   assumes ev_fint: "eventually (\<lambda>n::'a. (f n) contour_integrable_on \<gamma>) F"
  5175       and ev_no: "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>n. \<forall>x \<in> path_image \<gamma>. norm(f n x - l x) < e) F"
  5175       and ul_f: "uniform_limit (path_image \<gamma>) f l F"
  5176       and noleB: "\<And>t. t \<in> {0..1} \<Longrightarrow> norm (vector_derivative \<gamma> (at t)) \<le> B"
  5176       and noleB: "\<And>t. t \<in> {0..1} \<Longrightarrow> norm (vector_derivative \<gamma> (at t)) \<le> B"
  5177       and \<gamma>: "valid_path \<gamma>"
  5177       and \<gamma>: "valid_path \<gamma>"
  5178       and [simp]: "~ (trivial_limit F)"
  5178       and [simp]: "~ (trivial_limit F)"
  5179   shows "l contour_integrable_on \<gamma>" "((\<lambda>n. contour_integral \<gamma> (f n)) \<longlongrightarrow> contour_integral \<gamma> l) F"
  5179   shows "l contour_integrable_on \<gamma>" "((\<lambda>n. contour_integral \<gamma> (f n)) \<longlongrightarrow> contour_integral \<gamma> l) F"
  5180 proof -
  5180 proof -
  5181   have "0 \<le> B" by (meson noleB [of 0] atLeastAtMost_iff norm_ge_zero order_refl order_trans zero_le_one)
  5181   have "0 \<le> B" by (meson noleB [of 0] atLeastAtMost_iff norm_ge_zero order_refl order_trans zero_le_one)
  5182   { fix e::real
  5182   { fix e::real
  5183     assume "0 < e"
  5183     assume "0 < e"
  5184     then have eB: "0 < e / (\<bar>B\<bar> + 1)" by simp
  5184     then have "0 < e / (\<bar>B\<bar> + 1)" by simp
       
  5185     then have "\<forall>\<^sub>F n in F. \<forall>x\<in>path_image \<gamma>. cmod (f n x - l x) < e / (\<bar>B\<bar> + 1)"
       
  5186       using ul_f [unfolded uniform_limit_iff dist_norm] by auto
       
  5187     with ev_fint
  5185     obtain a where fga: "\<And>x. x \<in> {0..1} \<Longrightarrow> cmod (f a (\<gamma> x) - l (\<gamma> x)) < e / (\<bar>B\<bar> + 1)"
  5188     obtain a where fga: "\<And>x. x \<in> {0..1} \<Longrightarrow> cmod (f a (\<gamma> x) - l (\<gamma> x)) < e / (\<bar>B\<bar> + 1)"
  5186                and inta: "(\<lambda>t. f a (\<gamma> t) * vector_derivative \<gamma> (at t)) integrable_on {0..1}"
  5189                and inta: "(\<lambda>t. f a (\<gamma> t) * vector_derivative \<gamma> (at t)) integrable_on {0..1}"
  5187       using eventually_happens [OF eventually_conj [OF ev_no [OF eB] ev_fint]]
  5190       using eventually_happens [OF eventually_conj]
  5188       by (fastforce simp: contour_integrable_on path_image_def)
  5191       by (fastforce simp: contour_integrable_on path_image_def)
  5189     have Ble: "B * e / (\<bar>B\<bar> + 1) \<le> e"
  5192     have Ble: "B * e / (\<bar>B\<bar> + 1) \<le> e"
  5190       using \<open>0 \<le> B\<close>  \<open>0 < e\<close> by (simp add: divide_simps)
  5193       using \<open>0 \<le> B\<close>  \<open>0 < e\<close> by (simp add: divide_simps)
  5191     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}"
  5194     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}"
  5192       apply (rule_tac x="\<lambda>x. f (a::'a) (\<gamma> x) * vector_derivative \<gamma> (at x)" in exI)
  5195       apply (rule_tac x="\<lambda>x. f (a::'a) (\<gamma> x) * vector_derivative \<gamma> (at x)" in exI)
  5207   { fix e::real
  5210   { fix e::real
  5208     define B' where "B' = B + 1"
  5211     define B' where "B' = B + 1"
  5209     have B': "B' > 0" "B' > B" using  \<open>0 \<le> B\<close> by (auto simp: B'_def)
  5212     have B': "B' > 0" "B' > B" using  \<open>0 \<le> B\<close> by (auto simp: B'_def)
  5210     assume "0 < e"
  5213     assume "0 < e"
  5211     then have ev_no': "\<forall>\<^sub>F n in F. \<forall>x\<in>path_image \<gamma>. 2 * cmod (f n x - l x) < e / B'"
  5214     then have ev_no': "\<forall>\<^sub>F n in F. \<forall>x\<in>path_image \<gamma>. 2 * cmod (f n x - l x) < e / B'"
  5212       using ev_no [of "e / B' / 2"] B' by (simp add: field_simps)
  5215       using ul_f [unfolded uniform_limit_iff dist_norm, rule_format, of "e / B' / 2"] B' 
       
  5216         by (simp add: field_simps)
  5213     have ie: "integral {0..1::real} (\<lambda>x. e / 2) < e" using \<open>0 < e\<close> by simp
  5217     have ie: "integral {0..1::real} (\<lambda>x. e / 2) < e" using \<open>0 < e\<close> by simp
  5214     have *: "cmod (f x (\<gamma> t) * vector_derivative \<gamma> (at t) - l (\<gamma> t) * vector_derivative \<gamma> (at t)) \<le> e / 2"
  5218     have *: "cmod (f x (\<gamma> t) * vector_derivative \<gamma> (at t) - l (\<gamma> t) * vector_derivative \<gamma> (at t)) \<le> e / 2"
  5215              if t: "t\<in>{0..1}" and leB': "2 * cmod (f x (\<gamma> t) - l (\<gamma> t)) < e / B'" for x t
  5219              if t: "t\<in>{0..1}" and leB': "2 * cmod (f x (\<gamma> t) - l (\<gamma> t)) < e / B'" for x t
  5216     proof -
  5220     proof -
  5217       have "2 * cmod (f x (\<gamma> t) - l (\<gamma> t)) * cmod (vector_derivative \<gamma> (at t)) \<le> e * (B/ B')"
  5221       have "2 * cmod (f x (\<gamma> t) - l (\<gamma> t)) * cmod (vector_derivative \<gamma> (at t)) \<le> e * (B/ B')"
  5233   }
  5237   }
  5234   then show "((\<lambda>n. contour_integral \<gamma> (f n)) \<longlongrightarrow> contour_integral \<gamma> l) F"
  5238   then show "((\<lambda>n. contour_integral \<gamma> (f n)) \<longlongrightarrow> contour_integral \<gamma> l) F"
  5235     by (rule tendstoI)
  5239     by (rule tendstoI)
  5236 qed
  5240 qed
  5237 
  5241 
  5238 proposition contour_integral_uniform_limit_circlepath:
  5242 corollary contour_integral_uniform_limit_circlepath:
  5239   assumes ev_fint: "eventually (\<lambda>n::'a. (f n) contour_integrable_on (circlepath z r)) F"
  5243   assumes "\<forall>\<^sub>F n::'a in F. (f n) contour_integrable_on (circlepath z r)"
  5240       and ev_no: "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>n. \<forall>x \<in> path_image (circlepath z r). norm(f n x - l x) < e) F"
  5244       and "uniform_limit (sphere z r) f l F"
  5241       and [simp]: "~ (trivial_limit F)" "0 < r"
  5245       and "~ (trivial_limit F)" "0 < r"
  5242   shows "l contour_integrable_on (circlepath z r)" "((\<lambda>n. contour_integral (circlepath z r) (f n)) \<longlongrightarrow> contour_integral (circlepath z r) l) F"
  5246     shows "l contour_integrable_on (circlepath z r)"
  5243 by (auto simp: vector_derivative_circlepath norm_mult intro: contour_integral_uniform_limit assms)
  5247           "((\<lambda>n. contour_integral (circlepath z r) (f n)) \<longlongrightarrow> contour_integral (circlepath z r) l) F"
       
  5248   using assms by (auto simp: vector_derivative_circlepath norm_mult intro!: contour_integral_uniform_limit)
  5244 
  5249 
  5245 
  5250 
  5246 subsection\<open> General stepping result for derivative formulas.\<close>
  5251 subsection\<open> General stepping result for derivative formulas.\<close>
  5247 
  5252 
  5248 proposition Cauchy_next_derivative:
  5253 proposition Cauchy_next_derivative:
  5369       unfolding eventually_at
  5374       unfolding eventually_at
  5370       apply (rule_tac x = "min (d/2) ((e*(d/2)^(k + 2))/(Suc k))" in exI)
  5375       apply (rule_tac x = "min (d/2) ((e*(d/2)^(k + 2))/(Suc k))" in exI)
  5371       apply (force simp: \<open>d > 0\<close> dist_norm that simp del: power_Suc intro: *)
  5376       apply (force simp: \<open>d > 0\<close> dist_norm that simp del: power_Suc intro: *)
  5372       done
  5377       done
  5373   qed
  5378   qed
  5374   have 2: "\<forall>\<^sub>F n in at w.
  5379   have 2: "uniform_limit (path_image \<gamma>) (\<lambda>n x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k) (\<lambda>x. f' x / (x - w) ^ Suc k) (at w)"
  5375               \<forall>x\<in>path_image \<gamma>.
  5380     unfolding uniform_limit_iff dist_norm
  5376                cmod (f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k - f' x / (x - w) ^ Suc k) < e"
  5381   proof clarify
  5377           if "0 < e" for e
  5382     fix e::real
  5378   proof -
  5383     assume "0 < e"
  5379     have *: "cmod (f' (\<gamma> x) * (inverse (\<gamma> x - u) ^ k - inverse (\<gamma> x - w) ^ k) / ((u - w) * k) -
  5384     have *: "cmod (f' (\<gamma> x) * (inverse (\<gamma> x - u) ^ k - inverse (\<gamma> x - w) ^ k) / ((u - w) * k) -
  5380                         f' (\<gamma> x) / ((\<gamma> x - w) * (\<gamma> x - w) ^ k)) < e"
  5385                         f' (\<gamma> x) / ((\<gamma> x - w) * (\<gamma> x - w) ^ k)) < e"
  5381               if ec: "cmod ((inverse (\<gamma> x - u) ^ k - inverse (\<gamma> x - w) ^ k) / ((u - w) * k) -
  5386               if ec: "cmod ((inverse (\<gamma> x - u) ^ k - inverse (\<gamma> x - w) ^ k) / ((u - w) * k) -
  5382                       inverse (\<gamma> x - w) * inverse (\<gamma> x - w) ^ k) < e / C"
  5387                       inverse (\<gamma> x - w) * inverse (\<gamma> x - w) ^ k) < e / C"
  5383                  and x: "0 \<le> x" "x \<le> 1"
  5388                  and x: "0 \<le> x" "x \<le> 1"
  5400         using False by simp
  5405         using False by simp
  5401       also have "... \<le> e" using C
  5406       also have "... \<le> e" using C
  5402         by (metis False \<open>0 < e\<close> frac_le less_eq_real_def mult.commute pos_le_divide_eq x zero_less_norm_iff)
  5407         by (metis False \<open>0 < e\<close> frac_le less_eq_real_def mult.commute pos_le_divide_eq x zero_less_norm_iff)
  5403       finally show ?thesis .
  5408       finally show ?thesis .
  5404     qed
  5409     qed
  5405     show ?thesis
  5410     show "\<forall>\<^sub>F n in at w.
  5406       using twom [OF divide_pos_pos [OF that \<open>C > 0\<close>]]   unfolding path_image_def
  5411               \<forall>x\<in>path_image \<gamma>.
       
  5412                cmod (f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k - f' x / (x - w) ^ Suc k) < e"
       
  5413       using twom [OF divide_pos_pos [OF \<open>0 < e\<close> \<open>C > 0\<close>]]   unfolding path_image_def
  5407       by (force intro: * elim: eventually_mono)
  5414       by (force intro: * elim: eventually_mono)
  5408   qed
  5415   qed
  5409   show "(\<lambda>u. f' u / (u - w) ^ (Suc k)) contour_integrable_on \<gamma>"
  5416   show "(\<lambda>u. f' u / (u - w) ^ (Suc k)) contour_integrable_on \<gamma>"
  5410     by (rule contour_integral_uniform_limit [OF 1 2 leB \<gamma>]) auto
  5417     by (rule contour_integral_uniform_limit [OF 1 2 leB \<gamma>]) auto
  5411   have *: "(\<lambda>n. contour_integral \<gamma> (\<lambda>x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k))
  5418   have *: "(\<lambda>n. contour_integral \<gamma> (\<lambda>x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k))
  6015              and kle: "\<And>u. norm(u - z) = r \<Longrightarrow> k \<le> norm(u - w)"
  6022              and kle: "\<And>u. norm(u - z) = r \<Longrightarrow> k \<le> norm(u - w)"
  6016     apply (rule_tac k = "r - dist z w" in that)
  6023     apply (rule_tac k = "r - dist z w" in that)
  6017     using w
  6024     using w
  6018     apply (auto simp: dist_norm norm_minus_commute)
  6025     apply (auto simp: dist_norm norm_minus_commute)
  6019     by (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute)
  6026     by (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute)
  6020   have *: "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>path_image (circlepath z r).
  6027   have ul: "uniform_limit (sphere z r) (\<lambda>n x. (\<Sum>k<n. (w - z) ^ k * (f x / (x - z) ^ Suc k))) (\<lambda>x. f x / (x - w)) sequentially"
  6021                 norm ((\<Sum>k<n. (w - z) ^ k * (f x / (x - z) ^ Suc k)) - f x / (x - w)) < e"
  6028     unfolding uniform_limit_iff dist_norm 
  6022           if "0 < e" for e
  6029   proof clarify
  6023   proof -
  6030     fix e::real
       
  6031     assume "0 < e"
  6024     have rr: "0 \<le> (r - k) / r" "(r - k) / r < 1" using  k by auto
  6032     have rr: "0 \<le> (r - k) / r" "(r - k) / r < 1" using  k by auto
  6025     obtain n where n: "((r - k) / r) ^ n < e / B * k"
  6033     obtain n where n: "((r - k) / r) ^ n < e / B * k"
  6026       using real_arch_pow_inv [of "e/B*k" "(r - k)/r"] \<open>0 < e\<close> \<open>0 < B\<close> k by force
  6034       using real_arch_pow_inv [of "e/B*k" "(r - k)/r"] \<open>0 < e\<close> \<open>0 < B\<close> k by force
  6027     have "norm ((\<Sum>k<N. (w - z) ^ k * f u / (u - z) ^ Suc k) - f u / (u - w)) < e"
  6035     have "norm ((\<Sum>k<N. (w - z) ^ k * f u / (u - z) ^ Suc k) - f u / (u - w)) < e"
  6028          if "n \<le> N" and r: "r = dist z u"  for N u
  6036          if "n \<le> N" and r: "r = dist z u"  for N u
  6059       also have "... \<le> e * norm (u - w)"
  6067       also have "... \<le> e * norm (u - w)"
  6060         using r kle \<open>0 < e\<close> by (simp add: dist_commute dist_norm)
  6068         using r kle \<open>0 < e\<close> by (simp add: dist_commute dist_norm)
  6061       finally show ?thesis
  6069       finally show ?thesis
  6062         by (simp add: divide_simps norm_divide del: power_Suc)
  6070         by (simp add: divide_simps norm_divide del: power_Suc)
  6063     qed
  6071     qed
  6064     with \<open>0 < r\<close> show ?thesis
  6072     with \<open>0 < r\<close> show "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>sphere z r.
       
  6073                 norm ((\<Sum>k<n. (w - z) ^ k * (f x / (x - z) ^ Suc k)) - f x / (x - w)) < e"
  6065       by (auto simp: mult_ac less_imp_le eventually_sequentially Ball_def)
  6074       by (auto simp: mult_ac less_imp_le eventually_sequentially Ball_def)
  6066   qed
  6075   qed
  6067   have eq: "\<forall>\<^sub>F x in sequentially.
  6076   have eq: "\<forall>\<^sub>F x in sequentially.
  6068              contour_integral (circlepath z r) (\<lambda>u. \<Sum>k<x. (w - z) ^ k * (f u / (u - z) ^ Suc k)) =
  6077              contour_integral (circlepath z r) (\<lambda>u. \<Sum>k<x. (w - z) ^ k * (f u / (u - z) ^ Suc k)) =
  6069              (\<Sum>k<x. contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc k) * (w - z) ^ k)"
  6078              (\<Sum>k<x. contour_integral (circlepath z r) (\<lambda>u. f u / (u - z) ^ Suc k) * (w - z) ^ k)"
  6074     done
  6083     done
  6075   have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u/(u - z)^(Suc k)) * (w - z)^k)
  6084   have "(\<lambda>k. contour_integral (circlepath z r) (\<lambda>u. f u/(u - z)^(Suc k)) * (w - z)^k)
  6076         sums contour_integral (circlepath z r) (\<lambda>u. f u/(u - w))"
  6085         sums contour_integral (circlepath z r) (\<lambda>u. f u/(u - w))"
  6077     unfolding sums_def
  6086     unfolding sums_def
  6078     apply (rule Lim_transform_eventually [OF eq])
  6087     apply (rule Lim_transform_eventually [OF eq])
  6079     apply (rule contour_integral_uniform_limit_circlepath [OF eventuallyI *])
  6088     apply (rule contour_integral_uniform_limit_circlepath [OF eventuallyI ul])
  6080     apply (rule contour_integrable_sum, simp)
  6089     apply (rule contour_integrable_sum, simp)
  6081     apply (rule contour_integrable_lmul)
  6090     apply (rule contour_integrable_lmul)
  6082     apply (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf])
  6091     apply (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf])
  6083     using \<open>0 < r\<close>
  6092     using \<open>0 < r\<close>
  6084     apply auto
  6093     apply auto
  6187 
  6196 
  6188 subsection\<open> Weierstrass convergence theorem.\<close>
  6197 subsection\<open> Weierstrass convergence theorem.\<close>
  6189 
  6198 
  6190 proposition holomorphic_uniform_limit:
  6199 proposition holomorphic_uniform_limit:
  6191   assumes cont: "eventually (\<lambda>n. continuous_on (cball z r) (f n) \<and> (f n) holomorphic_on ball z r) F"
  6200   assumes cont: "eventually (\<lambda>n. continuous_on (cball z r) (f n) \<and> (f n) holomorphic_on ball z r) F"
  6192       and lim: "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>n. \<forall>x \<in> cball z r. norm(f n x - g x) < e) F"
  6201       and ulim: "uniform_limit (cball z r) f g F"
  6193       and F:  "~ trivial_limit F"
  6202       and F:  "~ trivial_limit F"
  6194   obtains "continuous_on (cball z r) g" "g holomorphic_on ball z r"
  6203   obtains "continuous_on (cball z r) g" "g holomorphic_on ball z r"
  6195 proof (cases r "0::real" rule: linorder_cases)
  6204 proof (cases r "0::real" rule: linorder_cases)
  6196   case less then show ?thesis by (force simp add: ball_empty less_imp_le continuous_on_def holomorphic_on_def intro: that)
  6205   case less then show ?thesis by (force simp add: ball_empty less_imp_le continuous_on_def holomorphic_on_def intro: that)
  6197 next
  6206 next
  6198   case equal then show ?thesis
  6207   case equal then show ?thesis
  6199     by (force simp add: holomorphic_on_def continuous_on_sing intro: that)
  6208     by (force simp add: holomorphic_on_def continuous_on_sing intro: that)
  6200 next
  6209 next
  6201   case greater
  6210   case greater
  6202   have contg: "continuous_on (cball z r) g"
  6211   have contg: "continuous_on (cball z r) g"
  6203     using cont
  6212     using cont uniform_limit_theorem [OF eventually_mono ulim F]  by blast
  6204     by (fastforce simp: eventually_conj_iff dist_norm intro: eventually_mono [OF lim] continuous_uniform_limit [OF F])
       
  6205   have 1: "continuous_on (path_image (circlepath z r)) (\<lambda>x. 1 / (2 * complex_of_real pi * \<i>) * g x)"
  6213   have 1: "continuous_on (path_image (circlepath z r)) (\<lambda>x. 1 / (2 * complex_of_real pi * \<i>) * g x)"
  6206     apply (rule continuous_intros continuous_on_subset [OF contg])+
  6214     apply (rule continuous_intros continuous_on_subset [OF contg])+
  6207     using \<open>0 < r\<close> by auto
  6215     using \<open>0 < r\<close> by auto
  6208   have 2: "((\<lambda>u. 1 / (2 * of_real pi * \<i>) * g u / (u - w) ^ 1) has_contour_integral g w) (circlepath z r)"
  6216   have 2: "((\<lambda>u. 1 / (2 * of_real pi * \<i>) * g u / (u - w) ^ 1) has_contour_integral g w) (circlepath z r)"
  6209        if w: "w \<in> ball z r" for w
  6217        if w: "w \<in> ball z r" for w
  6215     have ev_int: "\<forall>\<^sub>F n in F. (\<lambda>u. f n u / (u - w)) contour_integrable_on circlepath z r"
  6223     have ev_int: "\<forall>\<^sub>F n in F. (\<lambda>u. f n u / (u - w)) contour_integrable_on circlepath z r"
  6216       apply (rule eventually_mono [OF cont])
  6224       apply (rule eventually_mono [OF cont])
  6217       using w
  6225       using w
  6218       apply (auto intro: Cauchy_higher_derivative_integral_circlepath [where k=0, simplified])
  6226       apply (auto intro: Cauchy_higher_derivative_integral_circlepath [where k=0, simplified])
  6219       done
  6227       done
  6220     have ev_less: "\<forall>\<^sub>F n in F. \<forall>x\<in>path_image (circlepath z r). cmod (f n x / (x - w) - g x / (x - w)) < e"
  6228     have ul_less: "uniform_limit (sphere z r) (\<lambda>n x. f n x / (x - w)) (\<lambda>x. g x / (x - w)) F"
  6221          if "e > 0" for e
  6229       using greater \<open>0 < d\<close> 
  6222       using greater \<open>0 < d\<close> \<open>0 < e\<close>
  6230       apply (clarsimp simp add: uniform_limit_iff dist_norm norm_divide diff_divide_distrib [symmetric] divide_simps)
  6223       apply (simp add: norm_divide diff_divide_distrib [symmetric] divide_simps)
  6231       apply (rule_tac e1="e * d" in eventually_mono [OF uniform_limitD [OF ulim]])
  6224       apply (rule_tac e1="e * d" in eventually_mono [OF lim])
  6232        apply (force simp: dist_norm intro: dle mult_left_mono less_le_trans)+
  6225       apply (force simp: dist_norm intro: dle mult_left_mono less_le_trans)+
       
  6226       done
  6233       done
  6227     have g_cint: "(\<lambda>u. g u/(u - w)) contour_integrable_on circlepath z r"
  6234     have g_cint: "(\<lambda>u. g u/(u - w)) contour_integrable_on circlepath z r"
  6228       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6235       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \<open>0 < r\<close>])
  6229     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"
  6236     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"
  6230       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ev_less F \<open>0 < r\<close>])
  6237       by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \<open>0 < r\<close>])
  6231     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"
  6238     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"
  6232       apply (rule Lim_transform_eventually [where f = "\<lambda>n. contour_integral (circlepath z r) (\<lambda>u. f n u/(u - w))"])
  6239       apply (rule Lim_transform_eventually [where f = "\<lambda>n. contour_integral (circlepath z r) (\<lambda>u. f n u/(u - w))"])
  6233       apply (rule eventually_mono [OF cont])
  6240       apply (rule eventually_mono [OF cont])
  6234       apply (rule contour_integral_unique [OF Cauchy_integral_circlepath])
  6241       apply (rule contour_integral_unique [OF Cauchy_integral_circlepath])
  6235       using w
  6242       using w
  6236       apply (auto simp: norm_minus_commute dist_norm cif_tends_cig)
  6243       apply (auto simp: norm_minus_commute dist_norm cif_tends_cig)
  6237       done
  6244       done
  6238     have "((\<lambda>n. 2 * of_real pi * \<i> * f n w) \<longlongrightarrow> 2 * of_real pi * \<i> * g w) F"
  6245     have "((\<lambda>n. 2 * of_real pi * \<i> * f n w) \<longlongrightarrow> 2 * of_real pi * \<i> * g w) F"
  6239       apply (rule tendsto_mult_left [OF tendstoI])
  6246       apply (rule tendsto_mult_left [OF tendstoI])
  6240       apply (rule eventually_mono [OF lim], assumption)
  6247       apply (rule eventually_mono [OF uniform_limitD [OF ulim]], assumption)
  6241       using w
  6248       using w
  6242       apply (force simp add: dist_norm)
  6249       apply (force simp add: dist_norm)
  6243       done
  6250       done
  6244     then have "((\<lambda>u. g u / (u - w)) has_contour_integral 2 * of_real pi * \<i> * g w) (circlepath z r)"
  6251     then have "((\<lambda>u. g u / (u - w)) has_contour_integral 2 * of_real pi * \<i> * g w) (circlepath z r)"
  6245       using has_contour_integral_integral [OF g_cint] tendsto_unique [OF F f_tends_cig] w
  6252       using has_contour_integral_integral [OF g_cint] tendsto_unique [OF F f_tends_cig] w
  6260 
  6267 
  6261 proposition has_complex_derivative_uniform_limit:
  6268 proposition has_complex_derivative_uniform_limit:
  6262   fixes z::complex
  6269   fixes z::complex
  6263   assumes cont: "eventually (\<lambda>n. continuous_on (cball z r) (f n) \<and>
  6270   assumes cont: "eventually (\<lambda>n. continuous_on (cball z r) (f n) \<and>
  6264                                (\<forall>w \<in> ball z r. ((f n) has_field_derivative (f' n w)) (at w))) F"
  6271                                (\<forall>w \<in> ball z r. ((f n) has_field_derivative (f' n w)) (at w))) F"
  6265       and lim: "\<And>e. 0 < e \<Longrightarrow> eventually (\<lambda>n. \<forall>x \<in> cball z r. norm(f n x - g x) < e) F"
  6272       and ulim: "uniform_limit (cball z r) f g F"
  6266       and F:  "~ trivial_limit F" and "0 < r"
  6273       and F:  "~ trivial_limit F" and "0 < r"
  6267   obtains g' where
  6274   obtains g' where
  6268       "continuous_on (cball z r) g"
  6275       "continuous_on (cball z r) g"
  6269       "\<And>w. w \<in> ball z r \<Longrightarrow> (g has_field_derivative (g' w)) (at w) \<and> ((\<lambda>n. f' n w) \<longlongrightarrow> g' w) F"
  6276       "\<And>w. w \<in> ball z r \<Longrightarrow> (g has_field_derivative (g' w)) (at w) \<and> ((\<lambda>n. f' n w) \<longlongrightarrow> g' w) F"
  6270 proof -
  6277 proof -
  6271   let ?conint = "contour_integral (circlepath z r)"
  6278   let ?conint = "contour_integral (circlepath z r)"
  6272   have g: "continuous_on (cball z r) g" "g holomorphic_on ball z r"
  6279   have g: "continuous_on (cball z r) g" "g holomorphic_on ball z r"
  6273     by (rule holomorphic_uniform_limit [OF eventually_mono [OF cont] lim F];
  6280     by (rule holomorphic_uniform_limit [OF eventually_mono [OF cont] ulim F];
  6274              auto simp: holomorphic_on_open field_differentiable_def)+
  6281              auto simp: holomorphic_on_open field_differentiable_def)+
  6275   then obtain g' where g': "\<And>x. x \<in> ball z r \<Longrightarrow> (g has_field_derivative g' x) (at x)"
  6282   then obtain g' where g': "\<And>x. x \<in> ball z r \<Longrightarrow> (g has_field_derivative g' x) (at x)"
  6276     using DERIV_deriv_iff_has_field_derivative
  6283     using DERIV_deriv_iff_has_field_derivative
  6277     by (fastforce simp add: holomorphic_on_open)
  6284     by (fastforce simp add: holomorphic_on_open)
  6278   then have derg: "\<And>x. x \<in> ball z r \<Longrightarrow> deriv g x = g' x"
  6285   then have derg: "\<And>x. x \<in> ball z r \<Longrightarrow> deriv g x = g' x"
  6301       apply (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute)
  6308       apply (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute)
  6302       apply (metis diff_ge_0_iff_ge dist_commute dist_norm less_eq_real_def mem_ball w)
  6309       apply (metis diff_ge_0_iff_ge dist_commute dist_norm less_eq_real_def mem_ball w)
  6303       done
  6310       done
  6304     have 1: "\<forall>\<^sub>F n in F. (\<lambda>x. f n x / (x - w)\<^sup>2) contour_integrable_on circlepath z r"
  6311     have 1: "\<forall>\<^sub>F n in F. (\<lambda>x. f n x / (x - w)\<^sup>2) contour_integrable_on circlepath z r"
  6305       by (force simp add: holomorphic_on_open intro: w Cauchy_derivative_integral_circlepath eventually_mono [OF cont])
  6312       by (force simp add: holomorphic_on_open intro: w Cauchy_derivative_integral_circlepath eventually_mono [OF cont])
  6306     have 2: "0 < e \<Longrightarrow> \<forall>\<^sub>F n in F. \<forall>x \<in> path_image (circlepath z r). cmod (f n x / (x - w)\<^sup>2 - g x / (x - w)\<^sup>2) < e" for e
  6313     have 2: "uniform_limit (sphere z r) (\<lambda>n x. f n x / (x - w)\<^sup>2) (\<lambda>x. g x / (x - w)\<^sup>2) F"
  6307       using \<open>r > 0\<close>
  6314       unfolding uniform_limit_iff
  6308       apply (simp add: diff_divide_distrib [symmetric] norm_divide divide_simps sphere_def)
  6315     proof clarify
  6309       apply (rule eventually_mono [OF lim, of "e*d"])
  6316       fix e::real
  6310       apply (simp add: \<open>0 < d\<close>)
  6317       assume "0 < e"
  6311       apply (force simp add: dist_norm dle intro: less_le_trans)
  6318       with  \<open>r > 0\<close>
  6312       done
  6319       show "\<forall>\<^sub>F n in F. \<forall>x\<in>sphere z r. dist (f n x / (x - w)\<^sup>2) (g x / (x - w)\<^sup>2) < e"
       
  6320         apply (simp add: diff_divide_distrib [symmetric] norm_divide divide_simps sphere_def dist_norm)
       
  6321         apply (rule eventually_mono [OF uniform_limitD [OF ulim], of "e*d"])
       
  6322          apply (simp add: \<open>0 < d\<close>)
       
  6323         apply (force simp add: dist_norm dle intro: less_le_trans)
       
  6324         done
       
  6325     qed
  6313     have "((\<lambda>n. contour_integral (circlepath z r) (\<lambda>x. f n x / (x - w)\<^sup>2))
  6326     have "((\<lambda>n. contour_integral (circlepath z r) (\<lambda>x. f n x / (x - w)\<^sup>2))
  6314              \<longlongrightarrow> contour_integral (circlepath z r) ((\<lambda>x. g x / (x - w)\<^sup>2))) F"
  6327              \<longlongrightarrow> contour_integral (circlepath z r) ((\<lambda>x. g x / (x - w)\<^sup>2))) F"
  6315       by (rule contour_integral_uniform_limit_circlepath [OF 1 2 F \<open>0 < r\<close>])
  6328       by (rule contour_integral_uniform_limit_circlepath [OF 1 2 F \<open>0 < r\<close>])
  6316     then have tendsto_0: "((\<lambda>n. 1 / (2 * of_real pi * \<i>) * (?conint (\<lambda>x. f n x / (x - w)\<^sup>2) - ?conint (\<lambda>x. g x / (x - w)\<^sup>2))) \<longlongrightarrow> 0) F"
  6329     then have tendsto_0: "((\<lambda>n. 1 / (2 * of_real pi * \<i>) * (?conint (\<lambda>x. f n x / (x - w)\<^sup>2) - ?conint (\<lambda>x. g x / (x - w)\<^sup>2))) \<longlongrightarrow> 0) F"
  6317       using Lim_null by (force intro!: tendsto_mult_right_zero)
  6330       using Lim_null by (force intro!: tendsto_mult_right_zero)
  6329 
  6342 
  6330 
  6343 
  6331 subsection\<open>Some more simple/convenient versions for applications.\<close>
  6344 subsection\<open>Some more simple/convenient versions for applications.\<close>
  6332 
  6345 
  6333 lemma holomorphic_uniform_sequence:
  6346 lemma holomorphic_uniform_sequence:
  6334   assumes s: "open s"
  6347   assumes S: "open S"
  6335       and hol_fn: "\<And>n. (f n) holomorphic_on s"
  6348       and hol_fn: "\<And>n. (f n) holomorphic_on S"
  6336       and to_g: "\<And>x. x \<in> s
  6349       and ulim_g: "\<And>x. x \<in> S \<Longrightarrow> \<exists>d. 0 < d \<and> cball x d \<subseteq> S \<and> uniform_limit (cball x d) f g sequentially"
  6337                      \<Longrightarrow> \<exists>d. 0 < d \<and> cball x d \<subseteq> s \<and>
  6350   shows "g holomorphic_on S"
  6338                              (\<forall>e. 0 < e \<longrightarrow> eventually (\<lambda>n. \<forall>y \<in> cball x d. norm(f n y - g y) < e) sequentially)"
  6351 proof -
  6339   shows "g holomorphic_on s"
  6352   have "\<exists>f'. (g has_field_derivative f') (at z)" if "z \<in> S" for z
  6340 proof -
       
  6341   have "\<exists>f'. (g has_field_derivative f') (at z)" if "z \<in> s" for z
       
  6342   proof -
  6353   proof -
  6343     obtain r where "0 < r" and r: "cball z r \<subseteq> s"
  6354     obtain r where "0 < r" and r: "cball z r \<subseteq> S"
  6344                and fg: "\<forall>e. 0 < e \<longrightarrow> eventually (\<lambda>n. \<forall>y \<in> cball z r. norm(f n y - g y) < e) sequentially"
  6355                and ul: "uniform_limit (cball z r) f g sequentially"
  6345       using to_g [OF \<open>z \<in> s\<close>] by blast
  6356       using ulim_g [OF \<open>z \<in> S\<close>] by blast 
  6346     have *: "\<forall>\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \<and> f n holomorphic_on ball z r"
  6357     have *: "\<forall>\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \<and> f n holomorphic_on ball z r"
  6347       apply (intro eventuallyI conjI)
  6358       apply (intro eventuallyI conjI)
  6348       using hol_fn holomorphic_on_imp_continuous_on holomorphic_on_subset r apply blast
  6359       using hol_fn holomorphic_on_imp_continuous_on holomorphic_on_subset r apply blast
  6349       apply (metis hol_fn holomorphic_on_subset interior_cball interior_subset r)
  6360       apply (metis hol_fn holomorphic_on_subset interior_cball interior_subset r)
  6350       done
  6361       done
  6351     show ?thesis
  6362     show ?thesis
  6352       apply (rule holomorphic_uniform_limit [OF *])
  6363       apply (rule holomorphic_uniform_limit [OF *])
  6353       using \<open>0 < r\<close> centre_in_ball fg
  6364       using \<open>0 < r\<close> centre_in_ball ul
  6354       apply (auto simp: holomorphic_on_open)
  6365       apply (auto simp: holomorphic_on_open)
  6355       done
  6366       done
  6356   qed
  6367   qed
  6357   with s show ?thesis
  6368   with S show ?thesis
  6358     by (simp add: holomorphic_on_open)
  6369     by (simp add: holomorphic_on_open)
  6359 qed
  6370 qed
  6360 
  6371 
  6361 lemma has_complex_derivative_uniform_sequence:
  6372 lemma has_complex_derivative_uniform_sequence:
  6362   fixes s :: "complex set"
  6373   fixes S :: "complex set"
  6363   assumes s: "open s"
  6374   assumes S: "open S"
  6364       and hfd: "\<And>n x. x \<in> s \<Longrightarrow> ((f n) has_field_derivative f' n x) (at x)"
  6375       and hfd: "\<And>n x. x \<in> S \<Longrightarrow> ((f n) has_field_derivative f' n x) (at x)"
  6365       and to_g: "\<And>x. x \<in> s
  6376       and ulim_g: "\<And>x. x \<in> S
  6366              \<Longrightarrow> \<exists>d. 0 < d \<and> cball x d \<subseteq> s \<and>
  6377              \<Longrightarrow> \<exists>d. 0 < d \<and> cball x d \<subseteq> S \<and> uniform_limit (cball x d) f g sequentially"
  6367                      (\<forall>e. 0 < e \<longrightarrow> eventually (\<lambda>n. \<forall>y \<in> cball x d. norm(f n y - g y) < e) sequentially)"
  6378   shows "\<exists>g'. \<forall>x \<in> S. (g has_field_derivative g' x) (at x) \<and> ((\<lambda>n. f' n x) \<longlongrightarrow> g' x) sequentially"
  6368   shows "\<exists>g'. \<forall>x \<in> s. (g has_field_derivative g' x) (at x) \<and> ((\<lambda>n. f' n x) \<longlongrightarrow> g' x) sequentially"
  6379 proof -
  6369 proof -
  6380   have y: "\<exists>y. (g has_field_derivative y) (at z) \<and> (\<lambda>n. f' n z) \<longlonglongrightarrow> y" if "z \<in> S" for z
  6370   have y: "\<exists>y. (g has_field_derivative y) (at z) \<and> (\<lambda>n. f' n z) \<longlonglongrightarrow> y" if "z \<in> s" for z
       
  6371   proof -
  6381   proof -
  6372     obtain r where "0 < r" and r: "cball z r \<subseteq> s"
  6382     obtain r where "0 < r" and r: "cball z r \<subseteq> S"
  6373                and fg: "\<forall>e. 0 < e \<longrightarrow> eventually (\<lambda>n. \<forall>y \<in> cball z r. norm(f n y - g y) < e) sequentially"
  6383                and ul: "uniform_limit (cball z r) f g sequentially"
  6374       using to_g [OF \<open>z \<in> s\<close>] by blast
  6384       using ulim_g [OF \<open>z \<in> S\<close>] by blast 
  6375     have *: "\<forall>\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \<and>
  6385     have *: "\<forall>\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \<and>
  6376                                    (\<forall>w \<in> ball z r. ((f n) has_field_derivative (f' n w)) (at w))"
  6386                                    (\<forall>w \<in> ball z r. ((f n) has_field_derivative (f' n w)) (at w))"
  6377       apply (intro eventuallyI conjI)
  6387       apply (intro eventuallyI conjI)
  6378       apply (meson hfd holomorphic_on_imp_continuous_on holomorphic_on_open holomorphic_on_subset r s)
  6388       apply (meson hfd holomorphic_on_imp_continuous_on holomorphic_on_open holomorphic_on_subset r S)
  6379       using ball_subset_cball hfd r apply blast
  6389       using ball_subset_cball hfd r apply blast
  6380       done
  6390       done
  6381     show ?thesis
  6391     show ?thesis
  6382       apply (rule has_complex_derivative_uniform_limit [OF *, of g])
  6392       apply (rule has_complex_derivative_uniform_limit [OF *, of g])
  6383       using \<open>0 < r\<close> centre_in_ball fg
  6393       using \<open>0 < r\<close> centre_in_ball ul
  6384       apply force+
  6394       apply force+
  6385       done
  6395       done
  6386   qed
  6396   qed
  6387   show ?thesis
  6397   show ?thesis
  6388     by (rule bchoice) (blast intro: y)
  6398     by (rule bchoice) (blast intro: y)
  6389 qed
  6399 qed
  6390 
  6400 
  6391 
  6401 
  6392 subsection\<open>On analytic functions defined by a series.\<close>
  6402 subsection\<open>On analytic functions defined by a series.\<close>
  6393 
  6403  
  6394 lemma series_and_derivative_comparison:
  6404 lemma series_and_derivative_comparison:
  6395   fixes s :: "complex set"
  6405   fixes S :: "complex set"
  6396   assumes s: "open s"
  6406   assumes S: "open S"
  6397       and h: "summable h"
  6407       and h: "summable h"
  6398       and hfd: "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6408       and hfd: "\<And>n x. x \<in> S \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6399       and to_g: "\<And>n x. \<lbrakk>N \<le> n; x \<in> s\<rbrakk> \<Longrightarrow> norm(f n x) \<le> h n"
  6409       and to_g: "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>S. norm (f n x) \<le> h n"
  6400   obtains g g' where "\<forall>x \<in> s. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6410   obtains g g' where "\<forall>x \<in> S. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6401 proof -
  6411 proof -
  6402   obtain g where g: "\<And>e. e>0 \<Longrightarrow> \<exists>N. \<forall>n x. N \<le> n \<and> x \<in> s \<longrightarrow> dist (\<Sum>n<n. f n x) (g x) < e"
  6412   obtain g where g: "uniform_limit S (\<lambda>n x. \<Sum>i<n. f i x) g sequentially"
  6403     using series_comparison_uniform [OF h to_g, of N s] by force
  6413     using weierstrass_m_test_ev [OF to_g h]  by force
  6404   have *: "\<exists>d>0. cball x d \<subseteq> s \<and> (\<forall>e>0. \<forall>\<^sub>F n in sequentially. \<forall>y\<in>cball x d. cmod ((\<Sum>a<n. f a y) - g y) < e)"
  6414   have *: "\<exists>d>0. cball x d \<subseteq> S \<and> uniform_limit (cball x d) (\<lambda>n x. \<Sum>i<n. f i x) g sequentially"
  6405          if "x \<in> s" for x
  6415          if "x \<in> S" for x
  6406   proof -
  6416   proof -
  6407     obtain d where "d>0" and d: "cball x d \<subseteq> s"
  6417     obtain d where "d>0" and d: "cball x d \<subseteq> S"
  6408       using open_contains_cball [of "s"] \<open>x \<in> s\<close> s by blast
  6418       using open_contains_cball [of "S"] \<open>x \<in> S\<close> S by blast
  6409     then show ?thesis
  6419     then show ?thesis
  6410       apply (rule_tac x=d in exI)
  6420       apply (rule_tac x=d in exI)
  6411       apply (auto simp: dist_norm eventually_sequentially)
  6421         using g uniform_limit_on_subset
  6412       apply (metis g contra_subsetD dist_norm)
  6422         apply (force simp: dist_norm eventually_sequentially)
  6413       done
  6423           done
  6414   qed
  6424   qed
  6415   have "(\<forall>x\<in>s. (\<lambda>n. \<Sum>i<n. f i x) \<longlonglongrightarrow> g x)"
  6425   have "\<And>x. x \<in> S \<Longrightarrow> (\<lambda>n. \<Sum>i<n. f i x) \<longlonglongrightarrow> g x"
  6416     using g by (force simp add: lim_sequentially)
  6426     by (metis tendsto_uniform_limitI [OF g])
  6417   moreover have "\<exists>g'. \<forall>x\<in>s. (g has_field_derivative g' x) (at x) \<and> (\<lambda>n. \<Sum>i<n. f' i x) \<longlonglongrightarrow> g' x"
  6427   moreover have "\<exists>g'. \<forall>x\<in>S. (g has_field_derivative g' x) (at x) \<and> (\<lambda>n. \<Sum>i<n. f' i x) \<longlonglongrightarrow> g' x"
  6418     by (rule has_complex_derivative_uniform_sequence [OF s]) (auto intro: * hfd DERIV_sum)+
  6428     by (rule has_complex_derivative_uniform_sequence [OF S]) (auto intro: * hfd DERIV_sum)+
  6419   ultimately show ?thesis
  6429   ultimately show ?thesis
  6420     by (force simp add: sums_def  conj_commute intro: that)
  6430     by (metis sums_def that)
  6421 qed
  6431 qed
  6422 
  6432 
  6423 text\<open>A version where we only have local uniform/comparative convergence.\<close>
  6433 text\<open>A version where we only have local uniform/comparative convergence.\<close>
  6424 
  6434 
  6425 lemma series_and_derivative_comparison_local:
  6435 lemma series_and_derivative_comparison_local:
  6426   fixes s :: "complex set"
  6436   fixes S :: "complex set"
  6427   assumes s: "open s"
  6437   assumes S: "open S"
  6428       and hfd: "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6438       and hfd: "\<And>n x. x \<in> S \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6429       and to_g: "\<And>x. x \<in> s \<Longrightarrow>
  6439       and to_g: "\<And>x. x \<in> S \<Longrightarrow> \<exists>d h. 0 < d \<and> summable h \<and> (\<forall>\<^sub>F n in sequentially. \<forall>y\<in>ball x d \<inter> S. norm (f n y) \<le> h n)"
  6430                       \<exists>d h N. 0 < d \<and> summable h \<and> (\<forall>n y. N \<le> n \<and> y \<in> ball x d \<longrightarrow> norm(f n y) \<le> h n)"
  6440   shows "\<exists>g g'. \<forall>x \<in> S. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6431   shows "\<exists>g g'. \<forall>x \<in> s. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
       
  6432 proof -
  6441 proof -
  6433   have "\<exists>y. (\<lambda>n. f n z) sums (\<Sum>n. f n z) \<and> (\<lambda>n. f' n z) sums y \<and> ((\<lambda>x. \<Sum>n. f n x) has_field_derivative y) (at z)"
  6442   have "\<exists>y. (\<lambda>n. f n z) sums (\<Sum>n. f n z) \<and> (\<lambda>n. f' n z) sums y \<and> ((\<lambda>x. \<Sum>n. f n x) has_field_derivative y) (at z)"
  6434        if "z \<in> s" for z
  6443        if "z \<in> S" for z
  6435   proof -
  6444   proof -
  6436     obtain d h N where "0 < d" "summable h" and le_h: "\<And>n y. \<lbrakk>N \<le> n; y \<in> ball z d\<rbrakk> \<Longrightarrow> norm(f n y) \<le> h n"
  6445     obtain d h where "0 < d" "summable h" and le_h: "\<forall>\<^sub>F n in sequentially. \<forall>y\<in>ball z d \<inter> S. norm (f n y) \<le> h n"
  6437       using to_g \<open>z \<in> s\<close> by meson
  6446       using to_g \<open>z \<in> S\<close> by meson
  6438     then obtain r where "r>0" and r: "ball z r \<subseteq> ball z d \<inter> s" using \<open>z \<in> s\<close> s
  6447     then obtain r where "r>0" and r: "ball z r \<subseteq> ball z d \<inter> S" using \<open>z \<in> S\<close> S
  6439       by (metis Int_iff open_ball centre_in_ball open_Int open_contains_ball_eq)
  6448       by (metis Int_iff open_ball centre_in_ball open_Int open_contains_ball_eq)
  6440     have 1: "open (ball z d \<inter> s)"
  6449     have 1: "open (ball z d \<inter> S)"
  6441       by (simp add: open_Int s)
  6450       by (simp add: open_Int S)
  6442     have 2: "\<And>n x. x \<in> ball z d \<inter> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6451     have 2: "\<And>n x. x \<in> ball z d \<inter> S \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6443       by (auto simp: hfd)
  6452       by (auto simp: hfd)
  6444     obtain g g' where gg': "\<forall>x \<in> ball z d \<inter> s. ((\<lambda>n. f n x) sums g x) \<and>
  6453     obtain g g' where gg': "\<forall>x \<in> ball z d \<inter> S. ((\<lambda>n. f n x) sums g x) \<and>
  6445                                     ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6454                                     ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6446       by (auto intro: le_h series_and_derivative_comparison [OF 1 \<open>summable h\<close> hfd])
  6455       by (auto intro: le_h series_and_derivative_comparison [OF 1 \<open>summable h\<close> hfd])
  6447     then have "(\<lambda>n. f' n z) sums g' z"
  6456     then have "(\<lambda>n. f' n z) sums g' z"
  6448       by (meson \<open>0 < r\<close> centre_in_ball contra_subsetD r)
  6457       by (meson \<open>0 < r\<close> centre_in_ball contra_subsetD r)
  6449     moreover have "(\<lambda>n. f n z) sums (\<Sum>n. f n z)"
  6458     moreover have "(\<lambda>n. f n z) sums (\<Sum>n. f n z)"
  6450       by (metis summable_comparison_test' summable_sums centre_in_ball \<open>0 < d\<close> \<open>summable h\<close> le_h)
  6459       using  summable_sums centre_in_ball \<open>0 < d\<close> \<open>summable h\<close> le_h
       
  6460       by (metis (full_types) Int_iff gg' summable_def that)
  6451     moreover have "((\<lambda>x. \<Sum>n. f n x) has_field_derivative g' z) (at z)"
  6461     moreover have "((\<lambda>x. \<Sum>n. f n x) has_field_derivative g' z) (at z)"
  6452       apply (rule_tac f=g in DERIV_transform_at [OF _ \<open>0 < r\<close>])
  6462       apply (rule_tac f=g in DERIV_transform_at [OF _ \<open>0 < r\<close>])
  6453       apply (simp add: gg' \<open>z \<in> s\<close> \<open>0 < d\<close>)
  6463       apply (simp add: gg' \<open>z \<in> S\<close> \<open>0 < d\<close>)
  6454       apply (metis (full_types) contra_subsetD dist_commute gg' mem_ball r sums_unique)
  6464       apply (metis (full_types) contra_subsetD dist_commute gg' mem_ball r sums_unique)
  6455       done
  6465       done
  6456     ultimately show ?thesis by auto
  6466     ultimately show ?thesis by auto
  6457   qed
  6467   qed
  6458   then show ?thesis
  6468   then show ?thesis
  6461 
  6471 
  6462 
  6472 
  6463 text\<open>Sometimes convenient to compare with a complex series of positive reals. (?)\<close>
  6473 text\<open>Sometimes convenient to compare with a complex series of positive reals. (?)\<close>
  6464 
  6474 
  6465 lemma series_and_derivative_comparison_complex:
  6475 lemma series_and_derivative_comparison_complex:
  6466   fixes s :: "complex set"
  6476   fixes S :: "complex set"
  6467   assumes s: "open s"
  6477   assumes S: "open S"
  6468       and hfd: "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6478       and hfd: "\<And>n x. x \<in> S \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
  6469       and to_g: "\<And>x. x \<in> s \<Longrightarrow>
  6479       and to_g: "\<And>x. x \<in> S \<Longrightarrow> \<exists>d h. 0 < d \<and> summable h \<and> range h \<subseteq> \<real>\<^sub>\<ge>\<^sub>0 \<and> (\<forall>\<^sub>F n in sequentially. \<forall>y\<in>ball x d \<inter> S. cmod(f n y) \<le> cmod (h n))"
  6470                       \<exists>d h N. 0 < d \<and> summable h \<and> range h \<subseteq> nonneg_Reals \<and> (\<forall>n y. N \<le> n \<and> y \<in> ball x d \<longrightarrow> cmod(f n y) \<le> cmod (h n))"
  6480   shows "\<exists>g g'. \<forall>x \<in> S. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6471   shows "\<exists>g g'. \<forall>x \<in> s. ((\<lambda>n. f n x) sums g x) \<and> ((\<lambda>n. f' n x) sums g' x) \<and> (g has_field_derivative g' x) (at x)"
  6481 apply (rule series_and_derivative_comparison_local [OF S hfd], assumption)
  6472 apply (rule series_and_derivative_comparison_local [OF s hfd], assumption)
  6482 apply (rule ex_forward [OF to_g], assumption)
  6473 apply (frule to_g)
       
  6474 apply (erule ex_forward)
       
  6475 apply (erule exE)
  6483 apply (erule exE)
  6476 apply (rule_tac x="Re o h" in exI)
  6484 apply (rule_tac x="Re o h" in exI)
  6477 apply (erule ex_forward)
  6485 apply (force simp add: summable_Re o_def nonneg_Reals_cmod_eq_Re image_subset_iff)
  6478 apply (simp add: summable_Re o_def )
       
  6479 apply (elim conjE all_forward)
       
  6480 apply (simp add: nonneg_Reals_cmod_eq_Re image_subset_iff)
       
  6481 done
  6486 done
  6482 
  6487 
  6483 
  6488 
  6484 text\<open>In particular, a power series is analytic inside circle of convergence.\<close>
  6489 text\<open>In particular, a power series is analytic inside circle of convergence.\<close>
  6485 
  6490 
  6510       apply (rule series_and_derivative_comparison_complex [OF open_ball der])
  6515       apply (rule series_and_derivative_comparison_complex [OF open_ball der])
  6511       apply (rule_tac x="(r - norm z)/2" in exI)
  6516       apply (rule_tac x="(r - norm z)/2" in exI)
  6512       apply (simp add: dist_norm)
  6517       apply (simp add: dist_norm)
  6513       apply (rule_tac x="\<lambda>n. of_real(norm(a n)*((r + norm z)/2)^n)" in exI)
  6518       apply (rule_tac x="\<lambda>n. of_real(norm(a n)*((r + norm z)/2)^n)" in exI)
  6514       using \<open>r > 0\<close>
  6519       using \<open>r > 0\<close>
  6515       apply (auto simp: sum nonneg_Reals_divide_I)
  6520       apply (auto simp: sum eventually_sequentially norm_mult norm_divide norm_power)
  6516       apply (rule_tac x=0 in exI)
  6521       apply (rule_tac x=0 in exI)
  6517       apply (force simp: norm_mult norm_divide norm_power intro!: mult_left_mono power_mono y_le)
  6522       apply (force simp: dist_norm intro!: mult_left_mono power_mono y_le)
  6518       done
  6523       done
  6519   then show ?thesis
  6524   then show ?thesis
  6520     by (simp add: dist_0_norm ball_def)
  6525     by (simp add: ball_def)
  6521 next
  6526 next
  6522   case False then show ?thesis
  6527   case False then show ?thesis
  6523     apply (simp add: not_less)
  6528     apply (simp add: not_less)
  6524     using less_le_trans norm_not_less_zero by blast
  6529     using less_le_trans norm_not_less_zero by blast
  6525 qed
  6530 qed
  6829     by auto
  6834     by auto
  6830   have "(\<lambda>z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on s"
  6835   have "(\<lambda>z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on s"
  6831     by (rule pole_theorem_analytic_open_superset [OF g])
  6836     by (rule pole_theorem_analytic_open_superset [OF g])
  6832   then show ?thesis by simp
  6837   then show ?thesis by simp
  6833 qed
  6838 qed
  6834 
       
  6835 
  6839 
  6836 
  6840 
  6837 subsection\<open>General, homology form of Cauchy's theorem.\<close>
  6841 subsection\<open>General, homology form of Cauchy's theorem.\<close>
  6838 
  6842 
  6839 text\<open>Proof is based on Dixon's, as presented in Lang's "Complex Analysis" book (page 147).\<close>
  6843 text\<open>Proof is based on Dixon's, as presented in Lang's "Complex Analysis" book (page 147).\<close>
  7194       fix a x
  7198       fix a x
  7195       assume x: "x \<in> u" and au: "\<forall>n. a n \<in> u" and ax: "a \<longlonglongrightarrow> x"
  7199       assume x: "x \<in> u" and au: "\<forall>n. a n \<in> u" and ax: "a \<longlonglongrightarrow> x"
  7196       then have A1: "\<forall>\<^sub>F n in sequentially. d (a n) contour_integrable_on \<gamma>"
  7200       then have A1: "\<forall>\<^sub>F n in sequentially. d (a n) contour_integrable_on \<gamma>"
  7197         by (meson U contour_integrable_on_def eventuallyI)
  7201         by (meson U contour_integrable_on_def eventuallyI)
  7198       obtain dd where "dd>0" and dd: "cball x dd \<subseteq> u" using open_contains_cball u x by force
  7202       obtain dd where "dd>0" and dd: "cball x dd \<subseteq> u" using open_contains_cball u x by force
  7199       have A2: "\<forall>\<^sub>F n in sequentially. \<forall>xa\<in>path_image \<gamma>. cmod (d (a n) xa - d x xa) < ee" if "0 < ee" for ee
  7203       have A2: "uniform_limit (path_image \<gamma>) (\<lambda>n. d (a n)) (d x) sequentially"
  7200       proof -
  7204         unfolding uniform_limit_iff dist_norm
  7201         let ?ddpa = "{(w,z) |w z. w \<in> cball x dd \<and> z \<in> path_image \<gamma>}"
  7205       proof clarify
  7202         have "uniformly_continuous_on ?ddpa (\<lambda>(x,y). d x y)"
  7206         fix ee::real
  7203           apply (rule compact_uniformly_continuous [OF continuous_on_subset[OF cond_uu]])
  7207         assume "0 < ee"
  7204           using dd pasz \<open>valid_path \<gamma>\<close>
  7208         show "\<forall>\<^sub>F n in sequentially. \<forall>\<xi>\<in>path_image \<gamma>. cmod (d (a n) \<xi> - d x \<xi>) < ee"
  7205           apply (auto simp: compact_Times compact_valid_path_image simp del: mem_cball)
  7209         proof -
  7206           done
  7210           let ?ddpa = "{(w,z) |w z. w \<in> cball x dd \<and> z \<in> path_image \<gamma>}"
  7207         then obtain kk where "kk>0"
  7211           have "uniformly_continuous_on ?ddpa (\<lambda>(x,y). d x y)"
       
  7212             apply (rule compact_uniformly_continuous [OF continuous_on_subset[OF cond_uu]])
       
  7213             using dd pasz \<open>valid_path \<gamma>\<close>
       
  7214              apply (auto simp: compact_Times compact_valid_path_image simp del: mem_cball)
       
  7215             done
       
  7216           then obtain kk where "kk>0"
  7208             and kk: "\<And>x x'. \<lbrakk>x\<in>?ddpa; x'\<in>?ddpa; dist x' x < kk\<rbrakk> \<Longrightarrow>
  7217             and kk: "\<And>x x'. \<lbrakk>x\<in>?ddpa; x'\<in>?ddpa; dist x' x < kk\<rbrakk> \<Longrightarrow>
  7209                              dist ((\<lambda>(x,y). d x y) x') ((\<lambda>(x,y). d x y) x) < ee"
  7218                              dist ((\<lambda>(x,y). d x y) x') ((\<lambda>(x,y). d x y) x) < ee"
  7210           apply (rule uniformly_continuous_onE [where e = ee])
  7219             apply (rule uniformly_continuous_onE [where e = ee])
  7211           using \<open>0 < ee\<close> by auto
  7220             using \<open>0 < ee\<close> by auto
  7212         have kk: "\<lbrakk>norm (w - x) \<le> dd; z \<in> path_image \<gamma>; norm ((w, z) - (x, z)) < kk\<rbrakk> \<Longrightarrow> norm (d w z - d x z) < ee"
  7221           have kk: "\<lbrakk>norm (w - x) \<le> dd; z \<in> path_image \<gamma>; norm ((w, z) - (x, z)) < kk\<rbrakk> \<Longrightarrow> norm (d w z - d x z) < ee"
  7213                  for  w z
  7222             for  w z
  7214           using \<open>dd>0\<close> kk [of "(x,z)" "(w,z)"] by (force simp add: norm_minus_commute dist_norm)
  7223             using \<open>dd>0\<close> kk [of "(x,z)" "(w,z)"] by (force simp add: norm_minus_commute dist_norm)
  7215         show ?thesis
  7224           show ?thesis
  7216           using ax unfolding lim_sequentially eventually_sequentially
  7225             using ax unfolding lim_sequentially eventually_sequentially
  7217           apply (drule_tac x="min dd kk" in spec)
  7226             apply (drule_tac x="min dd kk" in spec)
  7218           using \<open>dd > 0\<close> \<open>kk > 0\<close>
  7227             using \<open>dd > 0\<close> \<open>kk > 0\<close>
  7219           apply (fastforce simp: kk dist_norm)
  7228             apply (fastforce simp: kk dist_norm)
  7220           done
  7229             done
       
  7230         qed
  7221       qed
  7231       qed
  7222       have tendsto_hx: "(\<lambda>n. contour_integral \<gamma> (d (a n))) \<longlonglongrightarrow> h x"
  7232       have tendsto_hx: "(\<lambda>n. contour_integral \<gamma> (d (a n))) \<longlonglongrightarrow> h x"
  7223         apply (simp add: contour_integral_unique [OF U, symmetric] x)
  7233         apply (simp add: contour_integral_unique [OF U, symmetric] x)
  7224         apply (rule contour_integral_uniform_limit [OF A1 A2 le_B])
  7234         apply (rule contour_integral_uniform_limit [OF A1 A2 le_B])
  7225         apply (auto simp: \<open>valid_path \<gamma>\<close>)
  7235         apply (auto simp: \<open>valid_path \<gamma>\<close>)
  7283     using has_contour_integral_add [OF 1 2]  by (simp add: diff_divide_distrib)
  7293     using has_contour_integral_add [OF 1 2]  by (simp add: diff_divide_distrib)
  7284 qed
  7294 qed
  7285 
  7295 
  7286 
  7296 
  7287 theorem Cauchy_integral_formula_global:
  7297 theorem Cauchy_integral_formula_global:
  7288     assumes s: "open s" and holf: "f holomorphic_on s"
  7298     assumes S: "open S" and holf: "f holomorphic_on S"
  7289         and z: "z \<in> s" and vpg: "valid_path \<gamma>"
  7299         and z: "z \<in> S" and vpg: "valid_path \<gamma>"
  7290         and pasz: "path_image \<gamma> \<subseteq> s - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7300         and pasz: "path_image \<gamma> \<subseteq> S - {z}" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7291         and zero: "\<And>w. w \<notin> s \<Longrightarrow> winding_number \<gamma> w = 0"
  7301         and zero: "\<And>w. w \<notin> S \<Longrightarrow> winding_number \<gamma> w = 0"
  7292       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  7302       shows "((\<lambda>w. f w / (w - z)) has_contour_integral (2*pi * \<i> * winding_number \<gamma> z * f z)) \<gamma>"
  7293 proof -
  7303 proof -
  7294   have "path \<gamma>" using vpg by (blast intro: valid_path_imp_path)
  7304   have "path \<gamma>" using vpg by (blast intro: valid_path_imp_path)
  7295   have hols: "(\<lambda>w. f w / (w - z)) holomorphic_on s - {z}" "(\<lambda>w. 1 / (w - z)) holomorphic_on s - {z}"
  7305   have hols: "(\<lambda>w. f w / (w - z)) holomorphic_on S - {z}" "(\<lambda>w. 1 / (w - z)) holomorphic_on S - {z}"
  7296     by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+
  7306     by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+
  7297   then have cint_fw: "(\<lambda>w. f w / (w - z)) contour_integrable_on \<gamma>"
  7307   then have cint_fw: "(\<lambda>w. f w / (w - z)) contour_integrable_on \<gamma>"
  7298     by (meson contour_integrable_holomorphic_simple holomorphic_on_imp_continuous_on open_delete s vpg pasz)
  7308     by (meson contour_integrable_holomorphic_simple holomorphic_on_imp_continuous_on open_delete S vpg pasz)
  7299   obtain d where "d>0"
  7309   obtain d where "d>0"
  7300       and d: "\<And>g h. \<lbrakk>valid_path g; valid_path h; \<forall>t\<in>{0..1}. cmod (g t - \<gamma> t) < d \<and> cmod (h t - \<gamma> t) < d;
  7310       and d: "\<And>g h. \<lbrakk>valid_path g; valid_path h; \<forall>t\<in>{0..1}. cmod (g t - \<gamma> t) < d \<and> cmod (h t - \<gamma> t) < d;
  7301                      pathstart h = pathstart g \<and> pathfinish h = pathfinish g\<rbrakk>
  7311                      pathstart h = pathstart g \<and> pathfinish h = pathfinish g\<rbrakk>
  7302                      \<Longrightarrow> path_image h \<subseteq> s - {z} \<and> (\<forall>f. f holomorphic_on s - {z} \<longrightarrow> contour_integral h f = contour_integral g f)"
  7312                      \<Longrightarrow> path_image h \<subseteq> S - {z} \<and> (\<forall>f. f holomorphic_on S - {z} \<longrightarrow> contour_integral h f = contour_integral g f)"
  7303     using contour_integral_nearby_ends [OF _ \<open>path \<gamma>\<close> pasz] s by (simp add: open_Diff) metis
  7313     using contour_integral_nearby_ends [OF _ \<open>path \<gamma>\<close> pasz] S by (simp add: open_Diff) metis
  7304   obtain p where polyp: "polynomial_function p"
  7314   obtain p where polyp: "polynomial_function p"
  7305              and ps: "pathstart p = pathstart \<gamma>" and pf: "pathfinish p = pathfinish \<gamma>" and led: "\<forall>t\<in>{0..1}. cmod (p t - \<gamma> t) < d"
  7315              and ps: "pathstart p = pathstart \<gamma>" and pf: "pathfinish p = pathfinish \<gamma>" and led: "\<forall>t\<in>{0..1}. cmod (p t - \<gamma> t) < d"
  7306     using path_approx_polynomial_function [OF \<open>path \<gamma>\<close> \<open>d > 0\<close>] by blast
  7316     using path_approx_polynomial_function [OF \<open>path \<gamma>\<close> \<open>d > 0\<close>] by blast
  7307   then have ploop: "pathfinish p = pathstart p" using loop by auto
  7317   then have ploop: "pathfinish p = pathstart p" using loop by auto
  7308   have vpp: "valid_path p"  using polyp valid_path_polynomial_function by blast
  7318   have vpp: "valid_path p"  using polyp valid_path_polynomial_function by blast
  7309   have [simp]: "z \<notin> path_image \<gamma>" using pasz by blast
  7319   have [simp]: "z \<notin> path_image \<gamma>" using pasz by blast
  7310   have paps: "path_image p \<subseteq> s - {z}" and cint_eq: "(\<And>f. f holomorphic_on s - {z} \<Longrightarrow> contour_integral p f = contour_integral \<gamma> f)"
  7320   have paps: "path_image p \<subseteq> S - {z}" and cint_eq: "(\<And>f. f holomorphic_on S - {z} \<Longrightarrow> contour_integral p f = contour_integral \<gamma> f)"
  7311     using pf ps led d [OF vpg vpp] \<open>d > 0\<close> by auto
  7321     using pf ps led d [OF vpg vpp] \<open>d > 0\<close> by auto
  7312   have wn_eq: "winding_number p z = winding_number \<gamma> z"
  7322   have wn_eq: "winding_number p z = winding_number \<gamma> z"
  7313     using vpp paps
  7323     using vpp paps
  7314     by (simp add: subset_Diff_insert vpg valid_path_polynomial_function winding_number_valid_path cint_eq hols)
  7324     by (simp add: subset_Diff_insert vpg valid_path_polynomial_function winding_number_valid_path cint_eq hols)
  7315   have "winding_number p w = winding_number \<gamma> w" if "w \<notin> s" for w
  7325   have "winding_number p w = winding_number \<gamma> w" if "w \<notin> S" for w
  7316   proof -
  7326   proof -
  7317     have hol: "(\<lambda>v. 1 / (v - w)) holomorphic_on s - {z}"
  7327     have hol: "(\<lambda>v. 1 / (v - w)) holomorphic_on S - {z}"
  7318       using that by (force intro: holomorphic_intros holomorphic_on_subset [OF holf])
  7328       using that by (force intro: holomorphic_intros holomorphic_on_subset [OF holf])
  7319    have "w \<notin> path_image p" "w \<notin> path_image \<gamma>" using paps pasz that by auto
  7329    have "w \<notin> path_image p" "w \<notin> path_image \<gamma>" using paps pasz that by auto
  7320    then show ?thesis
  7330    then show ?thesis
  7321     using vpp vpg by (simp add: subset_Diff_insert valid_path_polynomial_function winding_number_valid_path cint_eq [OF hol])
  7331     using vpp vpg by (simp add: subset_Diff_insert valid_path_polynomial_function winding_number_valid_path cint_eq [OF hol])
  7322   qed
  7332   qed
  7323   then have wn0: "\<And>w. w \<notin> s \<Longrightarrow> winding_number p w = 0"
  7333   then have wn0: "\<And>w. w \<notin> S \<Longrightarrow> winding_number p w = 0"
  7324     by (simp add: zero)
  7334     by (simp add: zero)
  7325   show ?thesis
  7335   show ?thesis
  7326     using Cauchy_integral_formula_global_weak [OF s holf z polyp paps ploop wn0] hols
  7336     using Cauchy_integral_formula_global_weak [OF S holf z polyp paps ploop wn0] hols
  7327     by (metis wn_eq cint_eq has_contour_integral_eqpath cint_fw cint_eq)
  7337     by (metis wn_eq cint_eq has_contour_integral_eqpath cint_fw cint_eq)
  7328 qed
  7338 qed
  7329 
  7339 
  7330 theorem Cauchy_theorem_global:
  7340 theorem Cauchy_theorem_global:
  7331     assumes s: "open s" and holf: "f holomorphic_on s"
  7341     assumes S: "open S" and holf: "f holomorphic_on S"
  7332         and vpg: "valid_path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7342         and vpg: "valid_path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  7333         and pas: "path_image \<gamma> \<subseteq> s"
  7343         and pas: "path_image \<gamma> \<subseteq> S"
  7334         and zero: "\<And>w. w \<notin> s \<Longrightarrow> winding_number \<gamma> w = 0"
  7344         and zero: "\<And>w. w \<notin> S \<Longrightarrow> winding_number \<gamma> w = 0"
  7335       shows "(f has_contour_integral 0) \<gamma>"
  7345       shows "(f has_contour_integral 0) \<gamma>"
  7336 proof -
  7346 proof -
  7337   obtain z where "z \<in> s" and znot: "z \<notin> path_image \<gamma>"
  7347   obtain z where "z \<in> S" and znot: "z \<notin> path_image \<gamma>"
  7338   proof -
  7348   proof -
  7339     have "compact (path_image \<gamma>)"
  7349     have "compact (path_image \<gamma>)"
  7340       using compact_valid_path_image vpg by blast
  7350       using compact_valid_path_image vpg by blast
  7341     then have "path_image \<gamma> \<noteq> s"
  7351     then have "path_image \<gamma> \<noteq> S"
  7342       by (metis (no_types) compact_open path_image_nonempty s)
  7352       by (metis (no_types) compact_open path_image_nonempty S)
  7343     with pas show ?thesis by (blast intro: that)
  7353     with pas show ?thesis by (blast intro: that)
  7344   qed
  7354   qed
  7345   then have pasz: "path_image \<gamma> \<subseteq> s - {z}" using pas by blast
  7355   then have pasz: "path_image \<gamma> \<subseteq> S - {z}" using pas by blast
  7346   have hol: "(\<lambda>w. (w - z) * f w) holomorphic_on s"
  7356   have hol: "(\<lambda>w. (w - z) * f w) holomorphic_on S"
  7347     by (rule holomorphic_intros holf)+
  7357     by (rule holomorphic_intros holf)+
  7348   show ?thesis
  7358   show ?thesis
  7349     using Cauchy_integral_formula_global [OF s hol \<open>z \<in> s\<close> vpg pasz loop zero]
  7359     using Cauchy_integral_formula_global [OF S hol \<open>z \<in> S\<close> vpg pasz loop zero]
  7350     by (auto simp: znot elim!: has_contour_integral_eq)
  7360     by (auto simp: znot elim!: has_contour_integral_eq)
  7351 qed
  7361 qed
  7352 
  7362 
  7353 corollary Cauchy_theorem_global_outside:
  7363 corollary Cauchy_theorem_global_outside:
  7354     assumes "open s" "f holomorphic_on s" "valid_path \<gamma>"  "pathfinish \<gamma> = pathstart \<gamma>" "path_image \<gamma> \<subseteq> s"
  7364     assumes "open S" "f holomorphic_on S" "valid_path \<gamma>"  "pathfinish \<gamma> = pathstart \<gamma>" "path_image \<gamma> \<subseteq> S"
  7355             "\<And>w. w \<notin> s \<Longrightarrow> w \<in> outside(path_image \<gamma>)"
  7365             "\<And>w. w \<notin> S \<Longrightarrow> w \<in> outside(path_image \<gamma>)"
  7356       shows "(f has_contour_integral 0) \<gamma>"
  7366       shows "(f has_contour_integral 0) \<gamma>"
  7357 by (metis Cauchy_theorem_global assms winding_number_zero_in_outside valid_path_imp_path)
  7367 by (metis Cauchy_theorem_global assms winding_number_zero_in_outside valid_path_imp_path)
  7358 
  7368 
  7359 
  7369 
  7360 lemma simply_connected_imp_winding_number_zero:
  7370 lemma simply_connected_imp_winding_number_zero:
  7361   assumes "simply_connected s" "path g"
  7371   assumes "simply_connected S" "path g"
  7362            "path_image g \<subseteq> s" "pathfinish g = pathstart g" "z \<notin> s"
  7372            "path_image g \<subseteq> S" "pathfinish g = pathstart g" "z \<notin> S"
  7363     shows "winding_number g z = 0"
  7373     shows "winding_number g z = 0"
  7364 proof -
  7374 proof -
  7365   have "winding_number g z = winding_number(linepath (pathstart g) (pathstart g)) z"
  7375   have "winding_number g z = winding_number(linepath (pathstart g) (pathstart g)) z"
  7366     apply (rule winding_number_homotopic_paths)
  7376     apply (rule winding_number_homotopic_paths)
  7367     apply (rule homotopic_loops_imp_homotopic_paths_null [where a = "pathstart g"])
  7377     apply (rule homotopic_loops_imp_homotopic_paths_null [where a = "pathstart g"])
  7368     apply (rule homotopic_loops_subset [of s])
  7378     apply (rule homotopic_loops_subset [of S])
  7369     using assms
  7379     using assms
  7370     apply (auto simp: homotopic_paths_imp_homotopic_loops path_defs simply_connected_eq_contractible_path)
  7380     apply (auto simp: homotopic_paths_imp_homotopic_loops path_defs simply_connected_eq_contractible_path)
  7371     done
  7381     done
  7372   also have "... = 0"
  7382   also have "... = 0"
  7373     using assms by (force intro: winding_number_trivial)
  7383     using assms by (force intro: winding_number_trivial)
  7374   finally show ?thesis .
  7384   finally show ?thesis .
  7375 qed
  7385 qed
  7376 
  7386 
  7377 lemma Cauchy_theorem_simply_connected:
  7387 lemma Cauchy_theorem_simply_connected:
  7378   assumes "open s" "simply_connected s" "f holomorphic_on s" "valid_path g"
  7388   assumes "open S" "simply_connected S" "f holomorphic_on S" "valid_path g"
  7379            "path_image g \<subseteq> s" "pathfinish g = pathstart g"
  7389            "path_image g \<subseteq> S" "pathfinish g = pathstart g"
  7380     shows "(f has_contour_integral 0) g"
  7390     shows "(f has_contour_integral 0) g"
  7381 using assms
  7391 using assms
  7382 apply (simp add: simply_connected_eq_contractible_path)
  7392 apply (simp add: simply_connected_eq_contractible_path)
  7383 apply (auto intro!: Cauchy_theorem_null_homotopic [where a = "pathstart g"]
  7393 apply (auto intro!: Cauchy_theorem_null_homotopic [where a = "pathstart g"]
  7384                          homotopic_paths_imp_homotopic_loops)
  7394                          homotopic_paths_imp_homotopic_loops)