# HG changeset patch # User Manuel Eberl # Date 1575305514 -3600 # Node ID 6617fb368a060f479be76a3444130860204a8896 # Parent 3548d54ce3ee0973b63b58d7b1828eceea2cd488 Reorganised HOL-Complex_Analysis diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Cauchy_Integral_Formula.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Complex_Analysis/Cauchy_Integral_Formula.thy Mon Dec 02 17:51:54 2019 +0100 @@ -0,0 +1,2787 @@ +section \Cauchy's Integral Formula\ +theory Cauchy_Integral_Formula + imports Winding_Numbers +begin + +subsection\Proof\ + +lemma Cauchy_integral_formula_weak: + assumes s: "convex s" and "finite k" and conf: "continuous_on s f" + and fcd: "(\x. x \ interior s - k \ f field_differentiable at x)" + and z: "z \ interior s - k" and vpg: "valid_path \" + and pasz: "path_image \ \ s - {z}" and loop: "pathfinish \ = pathstart \" + shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" +proof - + obtain f' where f': "(f has_field_derivative f') (at z)" + using fcd [OF z] by (auto simp: field_differentiable_def) + have pas: "path_image \ \ s" and znotin: "z \ path_image \" using pasz by blast+ + have c: "continuous (at x within s) (\w. if w = z then f' else (f w - f z) / (w - z))" if "x \ s" for x + proof (cases "x = z") + case True then show ?thesis + apply (simp add: continuous_within) + apply (rule Lim_transform_away_within [of _ "z+1" _ "\w::complex. (f w - f z)/(w - z)"]) + using has_field_derivative_at_within has_field_derivative_iff f' + apply (fastforce simp add:)+ + done + next + case False + then have dxz: "dist x z > 0" by auto + have cf: "continuous (at x within s) f" + using conf continuous_on_eq_continuous_within that by blast + have "continuous (at x within s) (\w. (f w - f z) / (w - z))" + by (rule cf continuous_intros | simp add: False)+ + then show ?thesis + apply (rule continuous_transform_within [OF _ dxz that, of "\w::complex. (f w - f z)/(w - z)"]) + apply (force simp: dist_commute) + done + qed + have fink': "finite (insert z k)" using \finite k\ by blast + have *: "((\w. if w = z then f' else (f w - f z) / (w - z)) has_contour_integral 0) \" + apply (rule Cauchy_theorem_convex [OF _ s fink' _ vpg pas loop]) + using c apply (force simp: continuous_on_eq_continuous_within) + apply (rename_tac w) + apply (rule_tac d="dist w z" and f = "\w. (f w - f z)/(w - z)" in field_differentiable_transform_within) + apply (simp_all add: dist_pos_lt dist_commute) + apply (metis less_irrefl) + apply (rule derivative_intros fcd | simp)+ + done + show ?thesis + apply (rule has_contour_integral_eq) + using znotin has_contour_integral_add [OF has_contour_integral_lmul [OF has_contour_integral_winding_number [OF vpg znotin], of "f z"] *] + apply (auto simp: ac_simps divide_simps) + done +qed + +theorem Cauchy_integral_formula_convex_simple: + "\convex s; f holomorphic_on s; z \ interior s; valid_path \; path_image \ \ s - {z}; + pathfinish \ = pathstart \\ + \ ((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" + apply (rule Cauchy_integral_formula_weak [where k = "{}"]) + using holomorphic_on_imp_continuous_on + by auto (metis at_within_interior holomorphic_on_def interiorE subsetCE) + +text\ Hence the Cauchy formula for points inside a circle.\ + +theorem Cauchy_integral_circlepath: + assumes contf: "continuous_on (cball z r) f" and holf: "f holomorphic_on (ball z r)" and wz: "norm(w - z) < r" + shows "((\u. f u/(u - w)) has_contour_integral (2 * of_real pi * \ * f w)) + (circlepath z r)" +proof - + have "r > 0" + using assms le_less_trans norm_ge_zero by blast + have "((\u. f u / (u - w)) has_contour_integral (2 * pi) * \ * winding_number (circlepath z r) w * f w) + (circlepath z r)" + proof (rule Cauchy_integral_formula_weak [where s = "cball z r" and k = "{}"]) + show "\x. x \ interior (cball z r) - {} \ + f field_differentiable at x" + using holf holomorphic_on_imp_differentiable_at by auto + have "w \ sphere z r" + by simp (metis dist_commute dist_norm not_le order_refl wz) + then show "path_image (circlepath z r) \ cball z r - {w}" + using \r > 0\ by (auto simp add: cball_def sphere_def) + qed (use wz in \simp_all add: dist_norm norm_minus_commute contf\) + then show ?thesis + by (simp add: winding_number_circlepath assms) +qed + +corollary\<^marker>\tag unimportant\ Cauchy_integral_circlepath_simple: + assumes "f holomorphic_on cball z r" "norm(w - z) < r" + shows "((\u. f u/(u - w)) has_contour_integral (2 * of_real pi * \ * f w)) + (circlepath z r)" +using assms by (force simp: holomorphic_on_imp_continuous_on holomorphic_on_subset Cauchy_integral_circlepath) + +subsection\<^marker>\tag unimportant\ \General stepping result for derivative formulas\ + +lemma Cauchy_next_derivative: + assumes "continuous_on (path_image \) f'" + and leB: "\t. t \ {0..1} \ norm (vector_derivative \ (at t)) \ B" + and int: "\w. w \ s - path_image \ \ ((\u. f' u / (u - w)^k) has_contour_integral f w) \" + and k: "k \ 0" + and "open s" + and \: "valid_path \" + and w: "w \ s - path_image \" + shows "(\u. f' u / (u - w)^(Suc k)) contour_integrable_on \" + and "(f has_field_derivative (k * contour_integral \ (\u. f' u/(u - w)^(Suc k)))) + (at w)" (is "?thes2") +proof - + have "open (s - path_image \)" using \open s\ closed_valid_path_image \ by blast + then obtain d where "d>0" and d: "ball w d \ s - path_image \" using w + using open_contains_ball by blast + have [simp]: "\n. cmod (1 + of_nat n) = 1 + of_nat n" + by (metis norm_of_nat of_nat_Suc) + have cint: "\x. \x \ w; cmod (x - w) < d\ + \ (\z. (f' z / (z - x) ^ k - f' z / (z - w) ^ k) / (x * k - w * k)) contour_integrable_on \" + apply (rule contour_integrable_div [OF contour_integrable_diff]) + using int w d + by (force simp: dist_norm norm_minus_commute intro!: has_contour_integral_integrable)+ + have 1: "\\<^sub>F n in at w. (\x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k) + contour_integrable_on \" + unfolding eventually_at + apply (rule_tac x=d in exI) + apply (simp add: \d > 0\ dist_norm field_simps cint) + done + have bim_g: "bounded (image f' (path_image \))" + by (simp add: compact_imp_bounded compact_continuous_image compact_valid_path_image assms) + then obtain C where "C > 0" and C: "\x. \0 \ x; x \ 1\ \ cmod (f' (\ x)) \ C" + by (force simp: bounded_pos path_image_def) + have twom: "\\<^sub>F n in at w. + \x\path_image \. + cmod ((inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k - inverse (x - w) ^ Suc k) < e" + if "0 < e" for e + proof - + have *: "cmod ((inverse (x - u) ^ k - inverse (x - w) ^ k) / ((u - w) * k) - inverse (x - w) ^ Suc k) < e" + if x: "x \ path_image \" and "u \ w" and uwd: "cmod (u - w) < d/2" + and uw_less: "cmod (u - w) < e * (d/2) ^ (k+2) / (1 + real k)" + for u x + proof - + define ff where [abs_def]: + "ff n w = + (if n = 0 then inverse(x - w)^k + else if n = 1 then k / (x - w)^(Suc k) + else (k * of_real(Suc k)) / (x - w)^(k + 2))" for n :: nat and w + have km1: "\z::complex. z \ 0 \ z ^ (k - Suc 0) = z ^ k / z" + by (simp add: field_simps) (metis Suc_pred \k \ 0\ neq0_conv power_Suc) + have ff1: "(ff i has_field_derivative ff (Suc i) z) (at z within ball w (d/2))" + if "z \ ball w (d/2)" "i \ 1" for i z + proof - + have "z \ path_image \" + using \x \ path_image \\ d that ball_divide_subset_numeral by blast + then have xz[simp]: "x \ z" using \x \ path_image \\ by blast + then have neq: "x * x + z * z \ x * (z * 2)" + by (blast intro: dest!: sum_sqs_eq) + with xz have "\v. v \ 0 \ (x * x + z * z) * v \ (x * (z * 2) * v)" by auto + then have neqq: "\v. v \ 0 \ x * (x * v) + z * (z * v) \ x * (z * (2 * v))" + by (simp add: algebra_simps) + show ?thesis using \i \ 1\ + apply (simp add: ff_def dist_norm Nat.le_Suc_eq km1, safe) + apply (rule derivative_eq_intros | simp add: km1 | simp add: field_simps neq neqq)+ + done + qed + { fix a::real and b::real assume ab: "a > 0" "b > 0" + then have "k * (1 + real k) * (1 / a) \ k * (1 + real k) * (4 / b) \ b \ 4 * a" + by (subst mult_le_cancel_left_pos) + (use \k \ 0\ in \auto simp: divide_simps\) + with ab have "real k * (1 + real k) / a \ (real k * 4 + real k * real k * 4) / b \ b \ 4 * a" + by (simp add: field_simps) + } note canc = this + have ff2: "cmod (ff (Suc 1) v) \ real (k * (k + 1)) / (d/2) ^ (k + 2)" + if "v \ ball w (d/2)" for v + proof - + have lessd: "\z. cmod (\ z - v) < d/2 \ cmod (w - \ z) < d" + by (metis that norm_minus_commute norm_triangle_half_r dist_norm mem_ball) + have "d/2 \ cmod (x - v)" using d x that + using lessd d x + by (auto simp add: dist_norm path_image_def ball_def not_less [symmetric] del: divide_const_simps) + then have "d \ cmod (x - v) * 2" + by (simp add: field_split_simps) + then have dpow_le: "d ^ (k+2) \ (cmod (x - v) * 2) ^ (k+2)" + using \0 < d\ order_less_imp_le power_mono by blast + have "x \ v" using that + using \x \ path_image \\ ball_divide_subset_numeral d by fastforce + then show ?thesis + using \d > 0\ apply (simp add: ff_def norm_mult norm_divide norm_power dist_norm canc) + using dpow_le apply (simp add: field_split_simps) + done + qed + have ub: "u \ ball w (d/2)" + using uwd by (simp add: dist_commute dist_norm) + have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) + \ (real k * 4 + real k * real k * 4) * (cmod (u - w) * cmod (u - w)) / (d * (d * (d/2) ^ k))" + using complex_Taylor [OF _ ff1 ff2 _ ub, of w, simplified] + by (simp add: ff_def \0 < d\) + then have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) + \ (cmod (u - w) * real k) * (1 + real k) * cmod (u - w) / (d/2) ^ (k+2)" + by (simp add: field_simps) + then have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) + / (cmod (u - w) * real k) + \ (1 + real k) * cmod (u - w) / (d/2) ^ (k+2)" + using \k \ 0\ \u \ w\ by (simp add: mult_ac zero_less_mult_iff pos_divide_le_eq) + also have "\ < e" + using uw_less \0 < d\ by (simp add: mult_ac divide_simps) + finally have e: "cmod (inverse (x-u)^k - (inverse (x-w)^k + of_nat k * (u-w) / ((x-w) * (x-w)^k))) + / cmod ((u - w) * real k) < e" + by (simp add: norm_mult) + have "x \ u" + using uwd \0 < d\ x d by (force simp: dist_norm ball_def norm_minus_commute) + show ?thesis + apply (rule le_less_trans [OF _ e]) + using \k \ 0\ \x \ u\ \u \ w\ + apply (simp add: field_simps norm_divide [symmetric]) + done + qed + show ?thesis + unfolding eventually_at + apply (rule_tac x = "min (d/2) ((e*(d/2)^(k + 2))/(Suc k))" in exI) + apply (force simp: \d > 0\ dist_norm that simp del: power_Suc intro: *) + done + qed + have 2: "uniform_limit (path_image \) (\n x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k) (\x. f' x / (x - w) ^ Suc k) (at w)" + unfolding uniform_limit_iff dist_norm + proof clarify + fix e::real + assume "0 < e" + have *: "cmod (f' (\ x) * (inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - + f' (\ x) / ((\ x - w) * (\ x - w) ^ k)) < e" + if ec: "cmod ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - + inverse (\ x - w) * inverse (\ x - w) ^ k) < e / C" + and x: "0 \ x" "x \ 1" + for u x + proof (cases "(f' (\ x)) = 0") + case True then show ?thesis by (simp add: \0 < e\) + next + case False + have "cmod (f' (\ x) * (inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - + f' (\ x) / ((\ x - w) * (\ x - w) ^ k)) = + cmod (f' (\ x) * ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - + inverse (\ x - w) * inverse (\ x - w) ^ k))" + by (simp add: field_simps) + also have "\ = cmod (f' (\ x)) * + cmod ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - + inverse (\ x - w) * inverse (\ x - w) ^ k)" + by (simp add: norm_mult) + also have "\ < cmod (f' (\ x)) * (e/C)" + using False mult_strict_left_mono [OF ec] by force + also have "\ \ e" using C + by (metis False \0 < e\ frac_le less_eq_real_def mult.commute pos_le_divide_eq x zero_less_norm_iff) + finally show ?thesis . + qed + show "\\<^sub>F n in at w. + \x\path_image \. + cmod (f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k - f' x / (x - w) ^ Suc k) < e" + using twom [OF divide_pos_pos [OF \0 < e\ \C > 0\]] unfolding path_image_def + by (force intro: * elim: eventually_mono) + qed + show "(\u. f' u / (u - w) ^ (Suc k)) contour_integrable_on \" + by (rule contour_integral_uniform_limit [OF 1 2 leB \]) auto + have *: "(\n. contour_integral \ (\x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k)) + \w\ contour_integral \ (\u. f' u / (u - w) ^ (Suc k))" + by (rule contour_integral_uniform_limit [OF 1 2 leB \]) auto + have **: "contour_integral \ (\x. f' x * (inverse (x - u) ^ k - inverse (x - w) ^ k) / ((u - w) * k)) = + (f u - f w) / (u - w) / k" + if "dist u w < d" for u + proof - + have u: "u \ s - path_image \" + by (metis subsetD d dist_commute mem_ball that) + show ?thesis + apply (rule contour_integral_unique) + apply (simp add: diff_divide_distrib algebra_simps) + apply (intro has_contour_integral_diff has_contour_integral_div) + using u w apply (simp_all add: field_simps int) + done + qed + show ?thes2 + apply (simp add: has_field_derivative_iff del: power_Suc) + apply (rule Lim_transform_within [OF tendsto_mult_left [OF *] \0 < d\ ]) + apply (simp add: \k \ 0\ **) + done +qed + +lemma Cauchy_next_derivative_circlepath: + assumes contf: "continuous_on (path_image (circlepath z r)) f" + and int: "\w. w \ ball z r \ ((\u. f u / (u - w)^k) has_contour_integral g w) (circlepath z r)" + and k: "k \ 0" + and w: "w \ ball z r" + shows "(\u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)" + (is "?thes1") + and "(g has_field_derivative (k * contour_integral (circlepath z r) (\u. f u/(u - w)^(Suc k)))) (at w)" + (is "?thes2") +proof - + have "r > 0" using w + using ball_eq_empty by fastforce + have wim: "w \ ball z r - path_image (circlepath z r)" + using w by (auto simp: dist_norm) + show ?thes1 ?thes2 + by (rule Cauchy_next_derivative [OF contf _ int k open_ball valid_path_circlepath wim, where B = "2 * pi * \r\"]; + auto simp: vector_derivative_circlepath norm_mult)+ +qed + + +text\ In particular, the first derivative formula.\ + +lemma Cauchy_derivative_integral_circlepath: + assumes contf: "continuous_on (cball z r) f" + and holf: "f holomorphic_on ball z r" + and w: "w \ ball z r" + shows "(\u. f u/(u - w)^2) contour_integrable_on (circlepath z r)" + (is "?thes1") + and "(f has_field_derivative (1 / (2 * of_real pi * \) * contour_integral(circlepath z r) (\u. f u / (u - w)^2))) (at w)" + (is "?thes2") +proof - + have [simp]: "r \ 0" using w + using ball_eq_empty by fastforce + have f: "continuous_on (path_image (circlepath z r)) f" + by (rule continuous_on_subset [OF contf]) (force simp: cball_def sphere_def) + have int: "\w. dist z w < r \ + ((\u. f u / (u - w)) has_contour_integral (\x. 2 * of_real pi * \ * f x) w) (circlepath z r)" + by (rule Cauchy_integral_circlepath [OF contf holf]) (simp add: dist_norm norm_minus_commute) + show ?thes1 + apply (simp add: power2_eq_square) + apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1, simplified]) + apply (blast intro: int) + done + have "((\x. 2 * of_real pi * \ * f x) has_field_derivative contour_integral (circlepath z r) (\u. f u / (u - w)^2)) (at w)" + apply (simp add: power2_eq_square) + apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1 and g = "\x. 2 * of_real pi * \ * f x", simplified]) + apply (blast intro: int) + done + then have fder: "(f has_field_derivative contour_integral (circlepath z r) (\u. f u / (u - w)^2) / (2 * of_real pi * \)) (at w)" + by (rule DERIV_cdivide [where f = "\x. 2 * of_real pi * \ * f x" and c = "2 * of_real pi * \", simplified]) + show ?thes2 + by simp (rule fder) +qed + +subsection\Existence of all higher derivatives\ + +proposition derivative_is_holomorphic: + assumes "open S" + and fder: "\z. z \ S \ (f has_field_derivative f' z) (at z)" + shows "f' holomorphic_on S" +proof - + have *: "\h. (f' has_field_derivative h) (at z)" if "z \ S" for z + proof - + obtain r where "r > 0" and r: "cball z r \ S" + using open_contains_cball \z \ S\ \open S\ by blast + then have holf_cball: "f holomorphic_on cball z r" + apply (simp add: holomorphic_on_def) + using field_differentiable_at_within field_differentiable_def fder by blast + then have "continuous_on (path_image (circlepath z r)) f" + using \r > 0\ by (force elim: holomorphic_on_subset [THEN holomorphic_on_imp_continuous_on]) + then have contfpi: "continuous_on (path_image (circlepath z r)) (\x. 1/(2 * of_real pi*\) * f x)" + by (auto intro: continuous_intros)+ + have contf_cball: "continuous_on (cball z r) f" using holf_cball + by (simp add: holomorphic_on_imp_continuous_on holomorphic_on_subset) + have holf_ball: "f holomorphic_on ball z r" using holf_cball + using ball_subset_cball holomorphic_on_subset by blast + { fix w assume w: "w \ ball z r" + have intf: "(\u. f u / (u - w)\<^sup>2) contour_integrable_on circlepath z r" + by (blast intro: w Cauchy_derivative_integral_circlepath [OF contf_cball holf_ball]) + have fder': "(f has_field_derivative 1 / (2 * of_real pi * \) * contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2)) + (at w)" + by (blast intro: w Cauchy_derivative_integral_circlepath [OF contf_cball holf_ball]) + have f'_eq: "f' w = contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)" + using fder' ball_subset_cball r w by (force intro: DERIV_unique [OF fder]) + have "((\u. f u / (u - w)\<^sup>2 / (2 * of_real pi * \)) has_contour_integral + contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)) + (circlepath z r)" + by (rule has_contour_integral_div [OF has_contour_integral_integral [OF intf]]) + then have "((\u. f u / (2 * of_real pi * \ * (u - w)\<^sup>2)) has_contour_integral + contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)) + (circlepath z r)" + by (simp add: algebra_simps) + then have "((\u. f u / (2 * of_real pi * \ * (u - w)\<^sup>2)) has_contour_integral f' w) (circlepath z r)" + by (simp add: f'_eq) + } note * = this + show ?thesis + apply (rule exI) + apply (rule Cauchy_next_derivative_circlepath [OF contfpi, of 2 f', simplified]) + apply (simp_all add: \0 < r\ * dist_norm) + done + qed + show ?thesis + by (simp add: holomorphic_on_open [OF \open S\] *) +qed + +lemma holomorphic_deriv [holomorphic_intros]: + "\f holomorphic_on S; open S\ \ (deriv f) holomorphic_on S" +by (metis DERIV_deriv_iff_field_differentiable at_within_open derivative_is_holomorphic holomorphic_on_def) + +lemma analytic_deriv [analytic_intros]: "f analytic_on S \ (deriv f) analytic_on S" + using analytic_on_holomorphic holomorphic_deriv by auto + +lemma holomorphic_higher_deriv [holomorphic_intros]: "\f holomorphic_on S; open S\ \ (deriv ^^ n) f holomorphic_on S" + by (induction n) (auto simp: holomorphic_deriv) + +lemma analytic_higher_deriv [analytic_intros]: "f analytic_on S \ (deriv ^^ n) f analytic_on S" + unfolding analytic_on_def using holomorphic_higher_deriv by blast + +lemma has_field_derivative_higher_deriv: + "\f holomorphic_on S; open S; x \ S\ + \ ((deriv ^^ n) f has_field_derivative (deriv ^^ (Suc n)) f x) (at x)" +by (metis (no_types, hide_lams) DERIV_deriv_iff_field_differentiable at_within_open comp_apply + funpow.simps(2) holomorphic_higher_deriv holomorphic_on_def) + +lemma valid_path_compose_holomorphic: + assumes "valid_path g" and holo:"f holomorphic_on S" and "open S" "path_image g \ S" + shows "valid_path (f \ g)" +proof (rule valid_path_compose[OF \valid_path g\]) + fix x assume "x \ path_image g" + then show "f field_differentiable at x" + using analytic_on_imp_differentiable_at analytic_on_open assms holo by blast +next + have "deriv f holomorphic_on S" + using holomorphic_deriv holo \open S\ by auto + then show "continuous_on (path_image g) (deriv f)" + using assms(4) holomorphic_on_imp_continuous_on holomorphic_on_subset by auto +qed + +subsection\Morera's theorem\ + +lemma Morera_local_triangle_ball: + assumes "\z. z \ S + \ \e a. 0 < e \ z \ ball a e \ continuous_on (ball a e) f \ + (\b c. closed_segment b c \ ball a e + \ contour_integral (linepath a b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c a) f = 0)" + shows "f analytic_on S" +proof - + { fix z assume "z \ S" + with assms obtain e a where + "0 < e" and z: "z \ ball a e" and contf: "continuous_on (ball a e) f" + and 0: "\b c. closed_segment b c \ ball a e + \ contour_integral (linepath a b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c a) f = 0" + by blast + have az: "dist a z < e" using mem_ball z by blast + have sb_ball: "ball z (e - dist a z) \ ball a e" + by (simp add: dist_commute ball_subset_ball_iff) + have "\e>0. f holomorphic_on ball z e" + proof (intro exI conjI) + have sub_ball: "\y. dist a y < e \ closed_segment a y \ ball a e" + by (meson \0 < e\ centre_in_ball convex_ball convex_contains_segment mem_ball) + show "f holomorphic_on ball z (e - dist a z)" + apply (rule holomorphic_on_subset [OF _ sb_ball]) + apply (rule derivative_is_holomorphic[OF open_ball]) + apply (rule triangle_contour_integrals_starlike_primitive [OF contf _ open_ball, of a]) + apply (simp_all add: 0 \0 < e\ sub_ball) + done + qed (simp add: az) + } + then show ?thesis + by (simp add: analytic_on_def) +qed + +lemma Morera_local_triangle: + assumes "\z. z \ S + \ \t. open t \ z \ t \ continuous_on t f \ + (\a b c. convex hull {a,b,c} \ t + \ contour_integral (linepath a b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c a) f = 0)" + shows "f analytic_on S" +proof - + { fix z assume "z \ S" + with assms obtain t where + "open t" and z: "z \ t" and contf: "continuous_on t f" + and 0: "\a b c. convex hull {a,b,c} \ t + \ contour_integral (linepath a b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c a) f = 0" + by force + then obtain e where "e>0" and e: "ball z e \ t" + using open_contains_ball by blast + have [simp]: "continuous_on (ball z e) f" using contf + using continuous_on_subset e by blast + have eq0: "\b c. closed_segment b c \ ball z e \ + contour_integral (linepath z b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c z) f = 0" + by (meson 0 z \0 < e\ centre_in_ball closed_segment_subset convex_ball dual_order.trans e starlike_convex_subset) + have "\e a. 0 < e \ z \ ball a e \ continuous_on (ball a e) f \ + (\b c. closed_segment b c \ ball a e \ + contour_integral (linepath a b) f + contour_integral (linepath b c) f + contour_integral (linepath c a) f = 0)" + using \e > 0\ eq0 by force + } + then show ?thesis + by (simp add: Morera_local_triangle_ball) +qed + +proposition Morera_triangle: + "\continuous_on S f; open S; + \a b c. convex hull {a,b,c} \ S + \ contour_integral (linepath a b) f + + contour_integral (linepath b c) f + + contour_integral (linepath c a) f = 0\ + \ f analytic_on S" + using Morera_local_triangle by blast + +subsection\Combining theorems for higher derivatives including Leibniz rule\ + +lemma higher_deriv_linear [simp]: + "(deriv ^^ n) (\w. c*w) = (\z. if n = 0 then c*z else if n = 1 then c else 0)" + by (induction n) auto + +lemma higher_deriv_const [simp]: "(deriv ^^ n) (\w. c) = (\w. if n=0 then c else 0)" + by (induction n) auto + +lemma higher_deriv_ident [simp]: + "(deriv ^^ n) (\w. w) z = (if n = 0 then z else if n = 1 then 1 else 0)" + apply (induction n, simp) + apply (metis higher_deriv_linear lambda_one) + done + +lemma higher_deriv_id [simp]: + "(deriv ^^ n) id z = (if n = 0 then z else if n = 1 then 1 else 0)" + by (simp add: id_def) + +lemma has_complex_derivative_funpow_1: + "\(f has_field_derivative 1) (at z); f z = z\ \ (f^^n has_field_derivative 1) (at z)" + apply (induction n, auto) + apply (simp add: id_def) + by (metis DERIV_chain comp_funpow comp_id funpow_swap1 mult.right_neutral) + +lemma higher_deriv_uminus: + assumes "f holomorphic_on S" "open S" and z: "z \ S" + shows "(deriv ^^ n) (\w. -(f w)) z = - ((deriv ^^ n) f z)" +using z +proof (induction n arbitrary: z) + case 0 then show ?case by simp +next + case (Suc n z) + have *: "((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" + using Suc.prems assms has_field_derivative_higher_deriv by auto + have "((deriv ^^ n) (\w. - f w) has_field_derivative - deriv ((deriv ^^ n) f) z) (at z)" + apply (rule has_field_derivative_transform_within_open [of "\w. -((deriv ^^ n) f w)"]) + apply (rule derivative_eq_intros | rule * refl assms)+ + apply (auto simp add: Suc) + done + then show ?case + by (simp add: DERIV_imp_deriv) +qed + +lemma higher_deriv_add: + fixes z::complex + assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" + shows "(deriv ^^ n) (\w. f w + g w) z = (deriv ^^ n) f z + (deriv ^^ n) g z" +using z +proof (induction n arbitrary: z) + case 0 then show ?case by simp +next + case (Suc n z) + have *: "((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" + "((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z)" + using Suc.prems assms has_field_derivative_higher_deriv by auto + have "((deriv ^^ n) (\w. f w + g w) has_field_derivative + deriv ((deriv ^^ n) f) z + deriv ((deriv ^^ n) g) z) (at z)" + apply (rule has_field_derivative_transform_within_open [of "\w. (deriv ^^ n) f w + (deriv ^^ n) g w"]) + apply (rule derivative_eq_intros | rule * refl assms)+ + apply (auto simp add: Suc) + done + then show ?case + by (simp add: DERIV_imp_deriv) +qed + +lemma higher_deriv_diff: + fixes z::complex + assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" + shows "(deriv ^^ n) (\w. f w - g w) z = (deriv ^^ n) f z - (deriv ^^ n) g z" + apply (simp only: Groups.group_add_class.diff_conv_add_uminus higher_deriv_add) + apply (subst higher_deriv_add) + using assms holomorphic_on_minus apply (auto simp: higher_deriv_uminus) + done + +lemma bb: "Suc n choose k = (n choose k) + (if k = 0 then 0 else (n choose (k - 1)))" + by (cases k) simp_all + +lemma higher_deriv_mult: + fixes z::complex + assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" + shows "(deriv ^^ n) (\w. f w * g w) z = + (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)" +using z +proof (induction n arbitrary: z) + case 0 then show ?case by simp +next + case (Suc n z) + have *: "\n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" + "\n. ((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z)" + using Suc.prems assms has_field_derivative_higher_deriv by auto + have sumeq: "(\i = 0..n. + of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) = + g z * deriv ((deriv ^^ n) f) z + (\i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))" + apply (simp add: bb algebra_simps sum.distrib) + apply (subst (4) sum_Suc_reindex) + apply (auto simp: algebra_simps Suc_diff_le intro: sum.cong) + done + have "((deriv ^^ n) (\w. f w * g w) has_field_derivative + (\i = 0..Suc n. (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) + (at z)" + apply (rule has_field_derivative_transform_within_open + [of "\w. (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f w * (deriv ^^ (n - i)) g w)"]) + apply (simp add: algebra_simps) + apply (rule DERIV_cong [OF DERIV_sum]) + apply (rule DERIV_cmult) + apply (auto intro: DERIV_mult * sumeq \open S\ Suc.prems Suc.IH [symmetric]) + done + then show ?case + unfolding funpow.simps o_apply + by (simp add: DERIV_imp_deriv) +qed + +lemma higher_deriv_transform_within_open: + fixes z::complex + assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" + and fg: "\w. w \ S \ f w = g w" + shows "(deriv ^^ i) f z = (deriv ^^ i) g z" +using z +by (induction i arbitrary: z) + (auto simp: fg intro: complex_derivative_transform_within_open holomorphic_higher_deriv assms) + +lemma higher_deriv_compose_linear: + fixes z::complex + assumes f: "f holomorphic_on T" and S: "open S" and T: "open T" and z: "z \ S" + and fg: "\w. w \ S \ u * w \ T" + shows "(deriv ^^ n) (\w. f (u * w)) z = u^n * (deriv ^^ n) f (u * z)" +using z +proof (induction n arbitrary: z) + case 0 then show ?case by simp +next + case (Suc n z) + have holo0: "f holomorphic_on (*) u ` S" + by (meson fg f holomorphic_on_subset image_subset_iff) + have holo2: "(deriv ^^ n) f holomorphic_on (*) u ` S" + by (meson f fg holomorphic_higher_deriv holomorphic_on_subset image_subset_iff T) + have holo3: "(\z. u ^ n * (deriv ^^ n) f (u * z)) holomorphic_on S" + by (intro holo2 holomorphic_on_compose [where g="(deriv ^^ n) f", unfolded o_def] holomorphic_intros) + have holo1: "(\w. f (u * w)) holomorphic_on S" + apply (rule holomorphic_on_compose [where g=f, unfolded o_def]) + apply (rule holo0 holomorphic_intros)+ + done + have "deriv ((deriv ^^ n) (\w. f (u * w))) z = deriv (\z. u^n * (deriv ^^ n) f (u*z)) z" + apply (rule complex_derivative_transform_within_open [OF _ holo3 S Suc.prems]) + apply (rule holomorphic_higher_deriv [OF holo1 S]) + apply (simp add: Suc.IH) + done + also have "\ = u^n * deriv (\z. (deriv ^^ n) f (u * z)) z" + apply (rule deriv_cmult) + apply (rule analytic_on_imp_differentiable_at [OF _ Suc.prems]) + apply (rule analytic_on_compose_gen [where g="(deriv ^^ n) f" and T=T, unfolded o_def]) + apply (simp) + apply (simp add: analytic_on_open f holomorphic_higher_deriv T) + apply (blast intro: fg) + done + also have "\ = u * u ^ n * deriv ((deriv ^^ n) f) (u * z)" + apply (subst deriv_chain [where g = "(deriv ^^ n) f" and f = "(*) u", unfolded o_def]) + apply (rule derivative_intros) + using Suc.prems field_differentiable_def f fg has_field_derivative_higher_deriv T apply blast + apply (simp) + done + finally show ?case + by simp +qed + +lemma higher_deriv_add_at: + assumes "f analytic_on {z}" "g analytic_on {z}" + shows "(deriv ^^ n) (\w. f w + g w) z = (deriv ^^ n) f z + (deriv ^^ n) g z" +proof - + have "f analytic_on {z} \ g analytic_on {z}" + using assms by blast + with higher_deriv_add show ?thesis + by (auto simp: analytic_at_two) +qed + +lemma higher_deriv_diff_at: + assumes "f analytic_on {z}" "g analytic_on {z}" + shows "(deriv ^^ n) (\w. f w - g w) z = (deriv ^^ n) f z - (deriv ^^ n) g z" +proof - + have "f analytic_on {z} \ g analytic_on {z}" + using assms by blast + with higher_deriv_diff show ?thesis + by (auto simp: analytic_at_two) +qed + +lemma higher_deriv_uminus_at: + "f analytic_on {z} \ (deriv ^^ n) (\w. -(f w)) z = - ((deriv ^^ n) f z)" + using higher_deriv_uminus + by (auto simp: analytic_at) + +lemma higher_deriv_mult_at: + assumes "f analytic_on {z}" "g analytic_on {z}" + shows "(deriv ^^ n) (\w. f w * g w) z = + (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)" +proof - + have "f analytic_on {z} \ g analytic_on {z}" + using assms by blast + with higher_deriv_mult show ?thesis + by (auto simp: analytic_at_two) +qed + + +text\ Nonexistence of isolated singularities and a stronger integral formula.\ + +proposition no_isolated_singularity: + fixes z::complex + assumes f: "continuous_on S f" and holf: "f holomorphic_on (S - K)" and S: "open S" and K: "finite K" + shows "f holomorphic_on S" +proof - + { fix z + assume "z \ S" and cdf: "\x. x \ S - K \ f field_differentiable at x" + have "f field_differentiable at z" + proof (cases "z \ K") + case False then show ?thesis by (blast intro: cdf \z \ S\) + next + case True + with finite_set_avoid [OF K, of z] + obtain d where "d>0" and d: "\x. \x\K; x \ z\ \ d \ dist z x" + by blast + obtain e where "e>0" and e: "ball z e \ S" + using S \z \ S\ by (force simp: open_contains_ball) + have fde: "continuous_on (ball z (min d e)) f" + by (metis Int_iff ball_min_Int continuous_on_subset e f subsetI) + have cont: "{a,b,c} \ ball z (min d e) \ continuous_on (convex hull {a, b, c}) f" for a b c + by (simp add: hull_minimal continuous_on_subset [OF fde]) + have fd: "\{a,b,c} \ ball z (min d e); x \ interior (convex hull {a, b, c}) - K\ + \ f field_differentiable at x" for a b c x + by (metis cdf Diff_iff Int_iff ball_min_Int subsetD convex_ball e interior_mono interior_subset subset_hull) + obtain g where "\w. w \ ball z (min d e) \ (g has_field_derivative f w) (at w within ball z (min d e))" + apply (rule contour_integral_convex_primitive + [OF convex_ball fde Cauchy_theorem_triangle_cofinite [OF _ K]]) + using cont fd by auto + then have "f holomorphic_on ball z (min d e)" + by (metis open_ball at_within_open derivative_is_holomorphic) + then show ?thesis + unfolding holomorphic_on_def + by (metis open_ball \0 < d\ \0 < e\ at_within_open centre_in_ball min_less_iff_conj) + qed + } + with holf S K show ?thesis + by (simp add: holomorphic_on_open open_Diff finite_imp_closed field_differentiable_def [symmetric]) +qed + +lemma no_isolated_singularity': + fixes z::complex + assumes f: "\z. z \ K \ (f \ f z) (at z within S)" + and holf: "f holomorphic_on (S - K)" and S: "open S" and K: "finite K" + shows "f holomorphic_on S" +proof (rule no_isolated_singularity[OF _ assms(2-)]) + show "continuous_on S f" unfolding continuous_on_def + proof + fix z assume z: "z \ S" + show "(f \ f z) (at z within S)" + proof (cases "z \ K") + case False + from holf have "continuous_on (S - K) f" + by (rule holomorphic_on_imp_continuous_on) + with z False have "(f \ f z) (at z within (S - K))" + by (simp add: continuous_on_def) + also from z K S False have "at z within (S - K) = at z within S" + by (subst (1 2) at_within_open) (auto intro: finite_imp_closed) + finally show "(f \ f z) (at z within S)" . + qed (insert assms z, simp_all) + qed +qed + +proposition Cauchy_integral_formula_convex: + assumes S: "convex S" and K: "finite K" and contf: "continuous_on S f" + and fcd: "(\x. x \ interior S - K \ f field_differentiable at x)" + and z: "z \ interior S" and vpg: "valid_path \" + and pasz: "path_image \ \ S - {z}" and loop: "pathfinish \ = pathstart \" + shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" +proof - + have *: "\x. x \ interior S \ f field_differentiable at x" + unfolding holomorphic_on_open [symmetric] field_differentiable_def + using no_isolated_singularity [where S = "interior S"] + by (meson K contf continuous_at_imp_continuous_on continuous_on_interior fcd + field_differentiable_at_within field_differentiable_def holomorphic_onI + holomorphic_on_imp_differentiable_at open_interior) + show ?thesis + by (rule Cauchy_integral_formula_weak [OF S finite.emptyI contf]) (use * assms in auto) +qed + +text\ Formula for higher derivatives.\ + +lemma Cauchy_has_contour_integral_higher_derivative_circlepath: + assumes contf: "continuous_on (cball z r) f" + and holf: "f holomorphic_on ball z r" + and w: "w \ ball z r" + shows "((\u. f u / (u - w) ^ (Suc k)) has_contour_integral ((2 * pi * \) / (fact k) * (deriv ^^ k) f w)) + (circlepath z r)" +using w +proof (induction k arbitrary: w) + case 0 then show ?case + using assms by (auto simp: Cauchy_integral_circlepath dist_commute dist_norm) +next + case (Suc k) + have [simp]: "r > 0" using w + using ball_eq_empty by fastforce + have f: "continuous_on (path_image (circlepath z r)) f" + by (rule continuous_on_subset [OF contf]) (force simp: cball_def sphere_def less_imp_le) + obtain X where X: "((\u. f u / (u - w) ^ Suc (Suc k)) has_contour_integral X) (circlepath z r)" + using Cauchy_next_derivative_circlepath(1) [OF f Suc.IH _ Suc.prems] + by (auto simp: contour_integrable_on_def) + then have con: "contour_integral (circlepath z r) ((\u. f u / (u - w) ^ Suc (Suc k))) = X" + by (rule contour_integral_unique) + have "\n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) w) (at w)" + using Suc.prems assms has_field_derivative_higher_deriv by auto + then have dnf_diff: "\n. (deriv ^^ n) f field_differentiable (at w)" + by (force simp: field_differentiable_def) + have "deriv (\w. complex_of_real (2 * pi) * \ / (fact k) * (deriv ^^ k) f w) w = + of_nat (Suc k) * contour_integral (circlepath z r) (\u. f u / (u - w) ^ Suc (Suc k))" + by (force intro!: DERIV_imp_deriv Cauchy_next_derivative_circlepath [OF f Suc.IH _ Suc.prems]) + also have "\ = of_nat (Suc k) * X" + by (simp only: con) + finally have "deriv (\w. ((2 * pi) * \ / (fact k)) * (deriv ^^ k) f w) w = of_nat (Suc k) * X" . + then have "((2 * pi) * \ / (fact k)) * deriv (\w. (deriv ^^ k) f w) w = of_nat (Suc k) * X" + by (metis deriv_cmult dnf_diff) + then have "deriv (\w. (deriv ^^ k) f w) w = of_nat (Suc k) * X / ((2 * pi) * \ / (fact k))" + by (simp add: field_simps) + then show ?case + using of_nat_eq_0_iff X by fastforce +qed + +lemma Cauchy_higher_derivative_integral_circlepath: + assumes contf: "continuous_on (cball z r) f" + and holf: "f holomorphic_on ball z r" + and w: "w \ ball z r" + shows "(\u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)" + (is "?thes1") + and "(deriv ^^ k) f w = (fact k) / (2 * pi * \) * contour_integral(circlepath z r) (\u. f u/(u - w)^(Suc k))" + (is "?thes2") +proof - + have *: "((\u. f u / (u - w) ^ Suc k) has_contour_integral (2 * pi) * \ / (fact k) * (deriv ^^ k) f w) + (circlepath z r)" + using Cauchy_has_contour_integral_higher_derivative_circlepath [OF assms] + by simp + show ?thes1 using * + using contour_integrable_on_def by blast + show ?thes2 + unfolding contour_integral_unique [OF *] by (simp add: field_split_simps) +qed + +corollary Cauchy_contour_integral_circlepath: + assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \ ball z r" + shows "contour_integral(circlepath z r) (\u. f u/(u - w)^(Suc k)) = (2 * pi * \) * (deriv ^^ k) f w / (fact k)" +by (simp add: Cauchy_higher_derivative_integral_circlepath [OF assms]) + +lemma Cauchy_contour_integral_circlepath_2: + assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \ ball z r" + shows "contour_integral(circlepath z r) (\u. f u/(u - w)^2) = (2 * pi * \) * deriv f w" + using Cauchy_contour_integral_circlepath [OF assms, of 1] + by (simp add: power2_eq_square) + + +subsection\A holomorphic function is analytic, i.e. has local power series\ + +theorem holomorphic_power_series: + assumes holf: "f holomorphic_on ball z r" + and w: "w \ ball z r" + shows "((\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" +proof - + \ \Replacing \<^term>\r\ and the original (weak) premises with stronger ones\ + obtain r where "r > 0" and holfc: "f holomorphic_on cball z r" and w: "w \ ball z r" + proof + have "cball z ((r + dist w z) / 2) \ ball z r" + using w by (simp add: dist_commute field_sum_of_halves subset_eq) + then show "f holomorphic_on cball z ((r + dist w z) / 2)" + by (rule holomorphic_on_subset [OF holf]) + have "r > 0" + using w by clarsimp (metis dist_norm le_less_trans norm_ge_zero) + then show "0 < (r + dist w z) / 2" + by simp (use zero_le_dist [of w z] in linarith) + qed (use w in \auto simp: dist_commute\) + then have holf: "f holomorphic_on ball z r" + using ball_subset_cball holomorphic_on_subset by blast + have contf: "continuous_on (cball z r) f" + by (simp add: holfc holomorphic_on_imp_continuous_on) + have cint: "\k. (\u. f u / (u - z) ^ Suc k) contour_integrable_on circlepath z r" + by (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf]) (simp add: \0 < r\) + obtain B where "0 < B" and B: "\u. u \ cball z r \ norm(f u) \ B" + by (metis (no_types) bounded_pos compact_cball compact_continuous_image compact_imp_bounded contf image_eqI) + obtain k where k: "0 < k" "k \ r" and wz_eq: "norm(w - z) = r - k" + and kle: "\u. norm(u - z) = r \ k \ norm(u - w)" + proof + show "\u. cmod (u - z) = r \ r - dist z w \ cmod (u - w)" + by (metis add_diff_eq diff_add_cancel dist_norm norm_diff_ineq) + qed (use w in \auto simp: dist_norm norm_minus_commute\) + have ul: "uniform_limit (sphere z r) (\n x. (\kx. f x / (x - w)) sequentially" + unfolding uniform_limit_iff dist_norm + proof clarify + fix e::real + assume "0 < e" + have rr: "0 \ (r - k) / r" "(r - k) / r < 1" using k by auto + obtain n where n: "((r - k) / r) ^ n < e / B * k" + using real_arch_pow_inv [of "e/B*k" "(r - k)/r"] \0 < e\ \0 < B\ k by force + have "norm ((\k N" and r: "r = dist z u" for N u + proof - + have N: "((r - k) / r) ^ N < e / B * k" + apply (rule le_less_trans [OF power_decreasing n]) + using \n \ N\ k by auto + have u [simp]: "(u \ z) \ (u \ w)" + using \0 < r\ r w by auto + have wzu_not1: "(w - z) / (u - z) \ 1" + by (metis (no_types) dist_norm divide_eq_1_iff less_irrefl mem_ball norm_minus_commute r w) + have "norm ((\kk = norm ((((w - z) / (u - z)) ^ N - 1) * (u - w) / (((w - z) / (u - z) - 1) * (u - z)) - 1) * norm (f u)" + using \0 < B\ + apply (auto simp: geometric_sum [OF wzu_not1]) + apply (simp add: field_simps norm_mult [symmetric]) + done + also have "\ = norm ((u-z) ^ N * (w - u) - ((w - z) ^ N - (u-z) ^ N) * (u-w)) / (r ^ N * norm (u-w)) * norm (f u)" + using \0 < r\ r by (simp add: divide_simps norm_mult norm_divide norm_power dist_norm norm_minus_commute) + also have "\ = norm ((w - z) ^ N * (w - u)) / (r ^ N * norm (u - w)) * norm (f u)" + by (simp add: algebra_simps) + also have "\ = norm (w - z) ^ N * norm (f u) / r ^ N" + by (simp add: norm_mult norm_power norm_minus_commute) + also have "\ \ (((r - k)/r)^N) * B" + using \0 < r\ w k + apply (simp add: divide_simps) + apply (rule mult_mono [OF power_mono]) + apply (auto simp: norm_divide wz_eq norm_power dist_norm norm_minus_commute B r) + done + also have "\ < e * k" + using \0 < B\ N by (simp add: divide_simps) + also have "\ \ e * norm (u - w)" + using r kle \0 < e\ by (simp add: dist_commute dist_norm) + finally show ?thesis + by (simp add: field_split_simps norm_divide del: power_Suc) + qed + with \0 < r\ show "\\<^sub>F n in sequentially. \x\sphere z r. + norm ((\k\<^sub>F x in sequentially. + contour_integral (circlepath z r) (\u. \kku. f u / (u - z) ^ Suc k) * (w - z) ^ k)" + apply (rule eventuallyI) + apply (subst contour_integral_sum, simp) + using contour_integrable_lmul [OF cint, of "(w - z) ^ a" for a] apply (simp add: field_simps) + apply (simp only: contour_integral_lmul cint algebra_simps) + done + have cic: "\u. (\y. \k0 < r\ by (force intro!: Cauchy_higher_derivative_integral_circlepath [OF contf holf]) + have "(\k. contour_integral (circlepath z r) (\u. f u/(u - z)^(Suc k)) * (w - z)^k) + sums contour_integral (circlepath z r) (\u. f u/(u - w))" + unfolding sums_def + apply (intro Lim_transform_eventually [OF _ eq] contour_integral_uniform_limit_circlepath [OF eventuallyI ul] cic) + using \0 < r\ apply auto + done + then have "(\k. contour_integral (circlepath z r) (\u. f u/(u - z)^(Suc k)) * (w - z)^k) + sums (2 * of_real pi * \ * f w)" + using w by (auto simp: dist_commute dist_norm contour_integral_unique [OF Cauchy_integral_circlepath_simple [OF holfc]]) + then have "(\k. contour_integral (circlepath z r) (\u. f u / (u - z) ^ Suc k) * (w - z)^k / (\ * (of_real pi * 2))) + sums ((2 * of_real pi * \ * f w) / (\ * (complex_of_real pi * 2)))" + by (rule sums_divide) + then have "(\n. (w - z) ^ n * contour_integral (circlepath z r) (\u. f u / (u - z) ^ Suc n) / (\ * (of_real pi * 2))) + sums f w" + by (simp add: field_simps) + then show ?thesis + by (simp add: field_simps \0 < r\ Cauchy_higher_derivative_integral_circlepath [OF contf holf]) +qed + +subsection\The Liouville theorem and the Fundamental Theorem of Algebra\ + +text\ These weak Liouville versions don't even need the derivative formula.\ + +lemma Liouville_weak_0: + assumes holf: "f holomorphic_on UNIV" and inf: "(f \ 0) at_infinity" + shows "f z = 0" +proof (rule ccontr) + assume fz: "f z \ 0" + with inf [unfolded Lim_at_infinity, rule_format, of "norm(f z)/2"] + obtain B where B: "\x. B \ cmod x \ norm (f x) * 2 < cmod (f z)" + by (auto simp: dist_norm) + define R where "R = 1 + \B\ + norm z" + have "R > 0" unfolding R_def + proof - + have "0 \ cmod z + \B\" + by (metis (full_types) add_nonneg_nonneg norm_ge_zero real_norm_def) + then show "0 < 1 + \B\ + cmod z" + by linarith + qed + have *: "((\u. f u / (u - z)) has_contour_integral 2 * complex_of_real pi * \ * f z) (circlepath z R)" + apply (rule Cauchy_integral_circlepath) + using \R > 0\ apply (auto intro: holomorphic_on_subset [OF holf] holomorphic_on_imp_continuous_on)+ + done + have "cmod (x - z) = R \ cmod (f x) * 2 < cmod (f z)" for x + unfolding R_def + by (rule B) (use norm_triangle_ineq4 [of x z] in auto) + with \R > 0\ fz show False + using has_contour_integral_bound_circlepath [OF *, of "norm(f z)/2/R"] + by (auto simp: less_imp_le norm_mult norm_divide field_split_simps) +qed + +proposition Liouville_weak: + assumes "f holomorphic_on UNIV" and "(f \ l) at_infinity" + shows "f z = l" + using Liouville_weak_0 [of "\z. f z - l"] + by (simp add: assms holomorphic_on_diff LIM_zero) + +proposition Liouville_weak_inverse: + assumes "f holomorphic_on UNIV" and unbounded: "\B. eventually (\x. norm (f x) \ B) at_infinity" + obtains z where "f z = 0" +proof - + { assume f: "\z. f z \ 0" + have 1: "(\x. 1 / f x) holomorphic_on UNIV" + by (simp add: holomorphic_on_divide assms f) + have 2: "((\x. 1 / f x) \ 0) at_infinity" + apply (rule tendstoI [OF eventually_mono]) + apply (rule_tac B="2/e" in unbounded) + apply (simp add: dist_norm norm_divide field_split_simps) + done + have False + using Liouville_weak_0 [OF 1 2] f by simp + } + then show ?thesis + using that by blast +qed + +text\ In particular we get the Fundamental Theorem of Algebra.\ + +theorem fundamental_theorem_of_algebra: + fixes a :: "nat \ complex" + assumes "a 0 = 0 \ (\i \ {1..n}. a i \ 0)" + obtains z where "(\i\n. a i * z^i) = 0" +using assms +proof (elim disjE bexE) + assume "a 0 = 0" then show ?thesis + by (auto simp: that [of 0]) +next + fix i + assume i: "i \ {1..n}" and nz: "a i \ 0" + have 1: "(\z. \i\n. a i * z^i) holomorphic_on UNIV" + by (rule holomorphic_intros)+ + show thesis + proof (rule Liouville_weak_inverse [OF 1]) + show "\\<^sub>F x in at_infinity. B \ cmod (\i\n. a i * x ^ i)" for B + using i nz by (intro polyfun_extremal exI[of _ i]) auto + qed (use that in auto) +qed + +subsection\Weierstrass convergence theorem\ + +lemma holomorphic_uniform_limit: + assumes cont: "eventually (\n. continuous_on (cball z r) (f n) \ (f n) holomorphic_on ball z r) F" + and ulim: "uniform_limit (cball z r) f g F" + and F: "\ trivial_limit F" + obtains "continuous_on (cball z r) g" "g holomorphic_on ball z r" +proof (cases r "0::real" rule: linorder_cases) + case less then show ?thesis by (force simp: ball_empty less_imp_le continuous_on_def holomorphic_on_def intro: that) +next + case equal then show ?thesis + by (force simp: holomorphic_on_def intro: that) +next + case greater + have contg: "continuous_on (cball z r) g" + using cont uniform_limit_theorem [OF eventually_mono ulim F] by blast + have "path_image (circlepath z r) \ cball z r" + using \0 < r\ by auto + then have 1: "continuous_on (path_image (circlepath z r)) (\x. 1 / (2 * complex_of_real pi * \) * g x)" + by (intro continuous_intros continuous_on_subset [OF contg]) + have 2: "((\u. 1 / (2 * of_real pi * \) * g u / (u - w) ^ 1) has_contour_integral g w) (circlepath z r)" + if w: "w \ ball z r" for w + proof - + define d where "d = (r - norm(w - z))" + have "0 < d" "d \ r" using w by (auto simp: norm_minus_commute d_def dist_norm) + have dle: "\u. cmod (z - u) = r \ d \ cmod (u - w)" + unfolding d_def by (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute) + have ev_int: "\\<^sub>F n in F. (\u. f n u / (u - w)) contour_integrable_on circlepath z r" + apply (rule eventually_mono [OF cont]) + using w + apply (auto intro: Cauchy_higher_derivative_integral_circlepath [where k=0, simplified]) + done + have ul_less: "uniform_limit (sphere z r) (\n x. f n x / (x - w)) (\x. g x / (x - w)) F" + using greater \0 < d\ + apply (clarsimp simp add: uniform_limit_iff dist_norm norm_divide diff_divide_distrib [symmetric] divide_simps) + apply (rule_tac e1="e * d" in eventually_mono [OF uniform_limitD [OF ulim]]) + apply (force simp: dist_norm intro: dle mult_left_mono less_le_trans)+ + done + have g_cint: "(\u. g u/(u - w)) contour_integrable_on circlepath z r" + by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \0 < r\]) + have cif_tends_cig: "((\n. contour_integral(circlepath z r) (\u. f n u / (u - w))) \ contour_integral(circlepath z r) (\u. g u/(u - w))) F" + by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \0 < r\]) + have f_tends_cig: "((\n. 2 * of_real pi * \ * f n w) \ contour_integral (circlepath z r) (\u. g u / (u - w))) F" + proof (rule Lim_transform_eventually) + show "\\<^sub>F x in F. contour_integral (circlepath z r) (\u. f x u / (u - w)) + = 2 * of_real pi * \ * f x w" + apply (rule eventually_mono [OF cont contour_integral_unique [OF Cauchy_integral_circlepath]]) + using w\0 < d\ d_def by auto + qed (auto simp: cif_tends_cig) + have "\e. 0 < e \ \\<^sub>F n in F. dist (f n w) (g w) < e" + by (rule eventually_mono [OF uniform_limitD [OF ulim]]) (use w in auto) + then have "((\n. 2 * of_real pi * \ * f n w) \ 2 * of_real pi * \ * g w) F" + by (rule tendsto_mult_left [OF tendstoI]) + then have "((\u. g u / (u - w)) has_contour_integral 2 * of_real pi * \ * g w) (circlepath z r)" + using has_contour_integral_integral [OF g_cint] tendsto_unique [OF F f_tends_cig] w + by fastforce + then have "((\u. g u / (2 * of_real pi * \ * (u - w))) has_contour_integral g w) (circlepath z r)" + using has_contour_integral_div [where c = "2 * of_real pi * \"] + by (force simp: field_simps) + then show ?thesis + by (simp add: dist_norm) + qed + show ?thesis + using Cauchy_next_derivative_circlepath(2) [OF 1 2, simplified] + by (fastforce simp add: holomorphic_on_open contg intro: that) +qed + + +text\ Version showing that the limit is the limit of the derivatives.\ + +proposition has_complex_derivative_uniform_limit: + fixes z::complex + assumes cont: "eventually (\n. continuous_on (cball z r) (f n) \ + (\w \ ball z r. ((f n) has_field_derivative (f' n w)) (at w))) F" + and ulim: "uniform_limit (cball z r) f g F" + and F: "\ trivial_limit F" and "0 < r" + obtains g' where + "continuous_on (cball z r) g" + "\w. w \ ball z r \ (g has_field_derivative (g' w)) (at w) \ ((\n. f' n w) \ g' w) F" +proof - + let ?conint = "contour_integral (circlepath z r)" + have g: "continuous_on (cball z r) g" "g holomorphic_on ball z r" + by (rule holomorphic_uniform_limit [OF eventually_mono [OF cont] ulim F]; + auto simp: holomorphic_on_open field_differentiable_def)+ + then obtain g' where g': "\x. x \ ball z r \ (g has_field_derivative g' x) (at x)" + using DERIV_deriv_iff_has_field_derivative + by (fastforce simp add: holomorphic_on_open) + then have derg: "\x. x \ ball z r \ deriv g x = g' x" + by (simp add: DERIV_imp_deriv) + have tends_f'n_g': "((\n. f' n w) \ g' w) F" if w: "w \ ball z r" for w + proof - + have eq_f': "?conint (\x. f n x / (x - w)\<^sup>2) - ?conint (\x. g x / (x - w)\<^sup>2) = (f' n w - g' w) * (2 * of_real pi * \)" + if cont_fn: "continuous_on (cball z r) (f n)" + and fnd: "\w. w \ ball z r \ (f n has_field_derivative f' n w) (at w)" for n + proof - + have hol_fn: "f n holomorphic_on ball z r" + using fnd by (force simp: holomorphic_on_open) + have "(f n has_field_derivative 1 / (2 * of_real pi * \) * ?conint (\u. f n u / (u - w)\<^sup>2)) (at w)" + by (rule Cauchy_derivative_integral_circlepath [OF cont_fn hol_fn w]) + then have f': "f' n w = 1 / (2 * of_real pi * \) * ?conint (\u. f n u / (u - w)\<^sup>2)" + using DERIV_unique [OF fnd] w by blast + show ?thesis + by (simp add: f' Cauchy_contour_integral_circlepath_2 [OF g w] derg [OF w] field_split_simps) + qed + define d where "d = (r - norm(w - z))^2" + have "d > 0" + using w by (simp add: dist_commute dist_norm d_def) + have dle: "d \ cmod ((y - w)\<^sup>2)" if "r = cmod (z - y)" for y + proof - + have "w \ ball z (cmod (z - y))" + using that w by fastforce + then have "cmod (w - z) \ cmod (z - y)" + by (simp add: dist_complex_def norm_minus_commute) + moreover have "cmod (z - y) - cmod (w - z) \ cmod (y - w)" + by (metis diff_add_cancel diff_add_eq_diff_diff_swap norm_minus_commute norm_triangle_ineq2) + ultimately show ?thesis + using that by (simp add: d_def norm_power power_mono) + qed + have 1: "\\<^sub>F n in F. (\x. f n x / (x - w)\<^sup>2) contour_integrable_on circlepath z r" + by (force simp: holomorphic_on_open intro: w Cauchy_derivative_integral_circlepath eventually_mono [OF cont]) + have 2: "uniform_limit (sphere z r) (\n x. f n x / (x - w)\<^sup>2) (\x. g x / (x - w)\<^sup>2) F" + unfolding uniform_limit_iff + proof clarify + fix e::real + assume "0 < e" + with \r > 0\ show "\\<^sub>F n in F. \x\sphere z r. dist (f n x / (x - w)\<^sup>2) (g x / (x - w)\<^sup>2) < e" + apply (simp add: norm_divide field_split_simps sphere_def dist_norm) + apply (rule eventually_mono [OF uniform_limitD [OF ulim], of "e*d"]) + apply (simp add: \0 < d\) + apply (force simp: dist_norm dle intro: less_le_trans) + done + qed + have "((\n. contour_integral (circlepath z r) (\x. f n x / (x - w)\<^sup>2)) + \ contour_integral (circlepath z r) ((\x. g x / (x - w)\<^sup>2))) F" + by (rule contour_integral_uniform_limit_circlepath [OF 1 2 F \0 < r\]) + then have tendsto_0: "((\n. 1 / (2 * of_real pi * \) * (?conint (\x. f n x / (x - w)\<^sup>2) - ?conint (\x. g x / (x - w)\<^sup>2))) \ 0) F" + using Lim_null by (force intro!: tendsto_mult_right_zero) + have "((\n. f' n w - g' w) \ 0) F" + apply (rule Lim_transform_eventually [OF tendsto_0]) + apply (force simp: divide_simps intro: eq_f' eventually_mono [OF cont]) + done + then show ?thesis using Lim_null by blast + qed + obtain g' where "\w. w \ ball z r \ (g has_field_derivative (g' w)) (at w) \ ((\n. f' n w) \ g' w) F" + by (blast intro: tends_f'n_g' g') + then show ?thesis using g + using that by blast +qed + + +subsection\<^marker>\tag unimportant\ \Some more simple/convenient versions for applications\ + +lemma holomorphic_uniform_sequence: + assumes S: "open S" + and hol_fn: "\n. (f n) holomorphic_on S" + and ulim_g: "\x. x \ S \ \d. 0 < d \ cball x d \ S \ uniform_limit (cball x d) f g sequentially" + shows "g holomorphic_on S" +proof - + have "\f'. (g has_field_derivative f') (at z)" if "z \ S" for z + proof - + obtain r where "0 < r" and r: "cball z r \ S" + and ul: "uniform_limit (cball z r) f g sequentially" + using ulim_g [OF \z \ S\] by blast + have *: "\\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \ f n holomorphic_on ball z r" + proof (intro eventuallyI conjI) + show "continuous_on (cball z r) (f x)" for x + using hol_fn holomorphic_on_imp_continuous_on holomorphic_on_subset r by blast + show "f x holomorphic_on ball z r" for x + by (metis hol_fn holomorphic_on_subset interior_cball interior_subset r) + qed + show ?thesis + apply (rule holomorphic_uniform_limit [OF *]) + using \0 < r\ centre_in_ball ul + apply (auto simp: holomorphic_on_open) + done + qed + with S show ?thesis + by (simp add: holomorphic_on_open) +qed + +lemma has_complex_derivative_uniform_sequence: + fixes S :: "complex set" + assumes S: "open S" + and hfd: "\n x. x \ S \ ((f n) has_field_derivative f' n x) (at x)" + and ulim_g: "\x. x \ S + \ \d. 0 < d \ cball x d \ S \ uniform_limit (cball x d) f g sequentially" + shows "\g'. \x \ S. (g has_field_derivative g' x) (at x) \ ((\n. f' n x) \ g' x) sequentially" +proof - + have y: "\y. (g has_field_derivative y) (at z) \ (\n. f' n z) \ y" if "z \ S" for z + proof - + obtain r where "0 < r" and r: "cball z r \ S" + and ul: "uniform_limit (cball z r) f g sequentially" + using ulim_g [OF \z \ S\] by blast + have *: "\\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \ + (\w \ ball z r. ((f n) has_field_derivative (f' n w)) (at w))" + proof (intro eventuallyI conjI ballI) + show "continuous_on (cball z r) (f x)" for x + by (meson S continuous_on_subset hfd holomorphic_on_imp_continuous_on holomorphic_on_open r) + show "w \ ball z r \ (f x has_field_derivative f' x w) (at w)" for w x + using ball_subset_cball hfd r by blast + qed + show ?thesis + by (rule has_complex_derivative_uniform_limit [OF *, of g]) (use \0 < r\ ul in \force+\) + qed + show ?thesis + by (rule bchoice) (blast intro: y) +qed + +subsection\On analytic functions defined by a series\ + +lemma series_and_derivative_comparison: + fixes S :: "complex set" + assumes S: "open S" + and h: "summable h" + and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" + and to_g: "\\<^sub>F n in sequentially. \x\S. norm (f n x) \ h n" + obtains g g' where "\x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" +proof - + obtain g where g: "uniform_limit S (\n x. \id>0. cball x d \ S \ uniform_limit (cball x d) (\n x. \i S" for x + proof - + obtain d where "d>0" and d: "cball x d \ S" + using open_contains_cball [of "S"] \x \ S\ S by blast + show ?thesis + proof (intro conjI exI) + show "uniform_limit (cball x d) (\n x. \id > 0\ d in auto) + qed + have "\x. x \ S \ (\n. \i g x" + by (metis tendsto_uniform_limitI [OF g]) + moreover have "\g'. \x\S. (g has_field_derivative g' x) (at x) \ (\n. \i g' x" + by (rule has_complex_derivative_uniform_sequence [OF S]) (auto intro: * hfd DERIV_sum)+ + ultimately show ?thesis + by (metis sums_def that) +qed + +text\A version where we only have local uniform/comparative convergence.\ + +lemma series_and_derivative_comparison_local: + fixes S :: "complex set" + assumes S: "open S" + and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" + and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ (\\<^sub>F n in sequentially. \y\ball x d \ S. norm (f n y) \ h n)" + shows "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" +proof - + have "\y. (\n. f n z) sums (\n. f n z) \ (\n. f' n z) sums y \ ((\x. \n. f n x) has_field_derivative y) (at z)" + if "z \ S" for z + proof - + obtain d h where "0 < d" "summable h" and le_h: "\\<^sub>F n in sequentially. \y\ball z d \ S. norm (f n y) \ h n" + using to_g \z \ S\ by meson + then obtain r where "r>0" and r: "ball z r \ ball z d \ S" using \z \ S\ S + by (metis Int_iff open_ball centre_in_ball open_Int open_contains_ball_eq) + have 1: "open (ball z d \ S)" + by (simp add: open_Int S) + have 2: "\n x. x \ ball z d \ S \ (f n has_field_derivative f' n x) (at x)" + by (auto simp: hfd) + obtain g g' where gg': "\x \ ball z d \ S. ((\n. f n x) sums g x) \ + ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" + by (auto intro: le_h series_and_derivative_comparison [OF 1 \summable h\ hfd]) + then have "(\n. f' n z) sums g' z" + by (meson \0 < r\ centre_in_ball contra_subsetD r) + moreover have "(\n. f n z) sums (\n. f n z)" + using summable_sums centre_in_ball \0 < d\ \summable h\ le_h + by (metis (full_types) Int_iff gg' summable_def that) + moreover have "((\x. \n. f n x) has_field_derivative g' z) (at z)" + proof (rule has_field_derivative_transform_within) + show "\x. dist x z < r \ g x = (\n. f n x)" + by (metis subsetD dist_commute gg' mem_ball r sums_unique) + qed (use \0 < r\ gg' \z \ S\ \0 < d\ in auto) + ultimately show ?thesis by auto + qed + then show ?thesis + by (rule_tac x="\x. suminf (\n. f n x)" in exI) meson +qed + + +text\Sometimes convenient to compare with a complex series of positive reals. (?)\ + +lemma series_and_derivative_comparison_complex: + fixes S :: "complex set" + assumes S: "open S" + and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" + and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ range h \ \\<^sub>\\<^sub>0 \ (\\<^sub>F n in sequentially. \y\ball x d \ S. cmod(f n y) \ cmod (h n))" + shows "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" +apply (rule series_and_derivative_comparison_local [OF S hfd], assumption) +apply (rule ex_forward [OF to_g], assumption) +apply (erule exE) +apply (rule_tac x="Re \ h" in exI) +apply (force simp: summable_Re o_def nonneg_Reals_cmod_eq_Re image_subset_iff) +done + +text\Sometimes convenient to compare with a complex series of positive reals. (?)\ +lemma series_differentiable_comparison_complex: + fixes S :: "complex set" + assumes S: "open S" + and hfd: "\n x. x \ S \ f n field_differentiable (at x)" + and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ range h \ \\<^sub>\\<^sub>0 \ (\\<^sub>F n in sequentially. \y\ball x d \ S. cmod(f n y) \ cmod (h n))" + obtains g where "\x \ S. ((\n. f n x) sums g x) \ g field_differentiable (at x)" +proof - + have hfd': "\n x. x \ S \ (f n has_field_derivative deriv (f n) x) (at x)" + using hfd field_differentiable_derivI by blast + have "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. deriv (f n) x) sums g' x) \ (g has_field_derivative g' x) (at x)" + by (metis series_and_derivative_comparison_complex [OF S hfd' to_g]) + then show ?thesis + using field_differentiable_def that by blast +qed + +text\In particular, a power series is analytic inside circle of convergence.\ + +lemma power_series_and_derivative_0: + fixes a :: "nat \ complex" and r::real + assumes "summable (\n. a n * r^n)" + shows "\g g'. \z. cmod z < r \ + ((\n. a n * z^n) sums g z) \ ((\n. of_nat n * a n * z^(n - 1)) sums g' z) \ (g has_field_derivative g' z) (at z)" +proof (cases "0 < r") + case True + have der: "\n z. ((\x. a n * x ^ n) has_field_derivative of_nat n * a n * z ^ (n - 1)) (at z)" + by (rule derivative_eq_intros | simp)+ + have y_le: "\cmod (z - y) * 2 < r - cmod z\ \ cmod y \ cmod (of_real r + of_real (cmod z)) / 2" for z y + using \r > 0\ + apply (auto simp: algebra_simps norm_mult norm_divide norm_power simp flip: of_real_add) + using norm_triangle_ineq2 [of y z] + apply (simp only: diff_le_eq norm_minus_commute mult_2) + done + have "summable (\n. a n * complex_of_real r ^ n)" + using assms \r > 0\ by simp + moreover have "\z. cmod z < r \ cmod ((of_real r + of_real (cmod z)) / 2) < cmod (of_real r)" + using \r > 0\ + by (simp flip: of_real_add) + ultimately have sum: "\z. cmod z < r \ summable (\n. of_real (cmod (a n)) * ((of_real r + complex_of_real (cmod z)) / 2) ^ n)" + by (rule power_series_conv_imp_absconv_weak) + have "\g g'. \z \ ball 0 r. (\n. (a n) * z ^ n) sums g z \ + (\n. of_nat n * (a n) * z ^ (n - 1)) sums g' z \ (g has_field_derivative g' z) (at z)" + apply (rule series_and_derivative_comparison_complex [OF open_ball der]) + apply (rule_tac x="(r - norm z)/2" in exI) + apply (rule_tac x="\n. of_real(norm(a n)*((r + norm z)/2)^n)" in exI) + using \r > 0\ + apply (auto simp: sum eventually_sequentially norm_mult norm_power dist_norm intro!: mult_left_mono power_mono y_le) + done + then show ?thesis + by (simp add: ball_def) +next + case False then show ?thesis + apply (simp add: not_less) + using less_le_trans norm_not_less_zero by blast +qed + +proposition\<^marker>\tag unimportant\ power_series_and_derivative: + fixes a :: "nat \ complex" and r::real + assumes "summable (\n. a n * r^n)" + obtains g g' where "\z \ ball w r. + ((\n. a n * (z - w) ^ n) sums g z) \ ((\n. of_nat n * a n * (z - w) ^ (n - 1)) sums g' z) \ + (g has_field_derivative g' z) (at z)" + using power_series_and_derivative_0 [OF assms] + apply clarify + apply (rule_tac g="(\z. g(z - w))" in that) + using DERIV_shift [where z="-w"] + apply (auto simp: norm_minus_commute Ball_def dist_norm) + done + +proposition\<^marker>\tag unimportant\ power_series_holomorphic: + assumes "\w. w \ ball z r \ ((\n. a n*(w - z)^n) sums f w)" + shows "f holomorphic_on ball z r" +proof - + have "\f'. (f has_field_derivative f') (at w)" if w: "dist z w < r" for w + proof - + have inb: "z + complex_of_real ((dist z w + r) / 2) \ ball z r" + proof - + have wz: "cmod (w - z) < r" using w + by (auto simp: field_split_simps dist_norm norm_minus_commute) + then have "0 \ r" + by (meson less_eq_real_def norm_ge_zero order_trans) + show ?thesis + using w by (simp add: dist_norm \0\r\ flip: of_real_add) + qed + have sum: "summable (\n. a n * of_real (((cmod (z - w) + r) / 2) ^ n))" + using assms [OF inb] by (force simp: summable_def dist_norm) + obtain g g' where gg': "\u. u \ ball z ((cmod (z - w) + r) / 2) \ + (\n. a n * (u - z) ^ n) sums g u \ + (\n. of_nat n * a n * (u - z) ^ (n - 1)) sums g' u \ (g has_field_derivative g' u) (at u)" + by (rule power_series_and_derivative [OF sum, of z]) fastforce + have [simp]: "g u = f u" if "cmod (u - w) < (r - cmod (z - w)) / 2" for u + proof - + have less: "cmod (z - u) * 2 < cmod (z - w) + r" + using that dist_triangle2 [of z u w] + by (simp add: dist_norm [symmetric] algebra_simps) + show ?thesis + apply (rule sums_unique2 [of "\n. a n*(u - z)^n"]) + using gg' [of u] less w + apply (auto simp: assms dist_norm) + done + qed + have "(f has_field_derivative g' w) (at w)" + by (rule has_field_derivative_transform_within [where d="(r - norm(z - w))/2"]) + (use w gg' [of w] in \(force simp: dist_norm)+\) + then show ?thesis .. + qed + then show ?thesis by (simp add: holomorphic_on_open) +qed + +corollary holomorphic_iff_power_series: + "f holomorphic_on ball z r \ + (\w \ ball z r. (\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" + apply (intro iffI ballI holomorphic_power_series, assumption+) + apply (force intro: power_series_holomorphic [where a = "\n. (deriv ^^ n) f z / (fact n)"]) + done + +lemma power_series_analytic: + "(\w. w \ ball z r \ (\n. a n*(w - z)^n) sums f w) \ f analytic_on ball z r" + by (force simp: analytic_on_open intro!: power_series_holomorphic) + +lemma analytic_iff_power_series: + "f analytic_on ball z r \ + (\w \ ball z r. (\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" + by (simp add: analytic_on_open holomorphic_iff_power_series) + +subsection\<^marker>\tag unimportant\ \Equality between holomorphic functions, on open ball then connected set\ + +lemma holomorphic_fun_eq_on_ball: + "\f holomorphic_on ball z r; g holomorphic_on ball z r; + w \ ball z r; + \n. (deriv ^^ n) f z = (deriv ^^ n) g z\ + \ f w = g w" + apply (rule sums_unique2 [of "\n. (deriv ^^ n) f z / (fact n) * (w - z)^n"]) + apply (auto simp: holomorphic_iff_power_series) + done + +lemma holomorphic_fun_eq_0_on_ball: + "\f holomorphic_on ball z r; w \ ball z r; + \n. (deriv ^^ n) f z = 0\ + \ f w = 0" + apply (rule sums_unique2 [of "\n. (deriv ^^ n) f z / (fact n) * (w - z)^n"]) + apply (auto simp: holomorphic_iff_power_series) + done + +lemma holomorphic_fun_eq_0_on_connected: + assumes holf: "f holomorphic_on S" and "open S" + and cons: "connected S" + and der: "\n. (deriv ^^ n) f z = 0" + and "z \ S" "w \ S" + shows "f w = 0" +proof - + have *: "ball x e \ (\n. {w \ S. (deriv ^^ n) f w = 0})" + if "\u. (deriv ^^ u) f x = 0" "ball x e \ S" for x e + proof - + have "\x' n. dist x x' < e \ (deriv ^^ n) f x' = 0" + apply (rule holomorphic_fun_eq_0_on_ball [OF holomorphic_higher_deriv]) + apply (rule holomorphic_on_subset [OF holf]) + using that apply simp_all + by (metis funpow_add o_apply) + with that show ?thesis by auto + qed + have 1: "openin (top_of_set S) (\n. {w \ S. (deriv ^^ n) f w = 0})" + apply (rule open_subset, force) + using \open S\ + apply (simp add: open_contains_ball Ball_def) + apply (erule all_forward) + using "*" by auto blast+ + have 2: "closedin (top_of_set S) (\n. {w \ S. (deriv ^^ n) f w = 0})" + using assms + by (auto intro: continuous_closedin_preimage_constant holomorphic_on_imp_continuous_on holomorphic_higher_deriv) + obtain e where "e>0" and e: "ball w e \ S" using openE [OF \open S\ \w \ S\] . + then have holfb: "f holomorphic_on ball w e" + using holf holomorphic_on_subset by blast + have 3: "(\n. {w \ S. (deriv ^^ n) f w = 0}) = S \ f w = 0" + using \e>0\ e by (force intro: holomorphic_fun_eq_0_on_ball [OF holfb]) + show ?thesis + using cons der \z \ S\ + apply (simp add: connected_clopen) + apply (drule_tac x="\n. {w \ S. (deriv ^^ n) f w = 0}" in spec) + apply (auto simp: 1 2 3) + done +qed + +lemma holomorphic_fun_eq_on_connected: + assumes "f holomorphic_on S" "g holomorphic_on S" and "open S" "connected S" + and "\n. (deriv ^^ n) f z = (deriv ^^ n) g z" + and "z \ S" "w \ S" + shows "f w = g w" +proof (rule holomorphic_fun_eq_0_on_connected [of "\x. f x - g x" S z, simplified]) + show "(\x. f x - g x) holomorphic_on S" + by (intro assms holomorphic_intros) + show "\n. (deriv ^^ n) (\x. f x - g x) z = 0" + using assms higher_deriv_diff by auto +qed (use assms in auto) + +lemma holomorphic_fun_eq_const_on_connected: + assumes holf: "f holomorphic_on S" and "open S" + and cons: "connected S" + and der: "\n. 0 < n \ (deriv ^^ n) f z = 0" + and "z \ S" "w \ S" + shows "f w = f z" +proof (rule holomorphic_fun_eq_0_on_connected [of "\w. f w - f z" S z, simplified]) + show "(\w. f w - f z) holomorphic_on S" + by (intro assms holomorphic_intros) + show "\n. (deriv ^^ n) (\w. f w - f z) z = 0" + by (subst higher_deriv_diff) (use assms in \auto intro: holomorphic_intros\) +qed (use assms in auto) + +subsection\<^marker>\tag unimportant\ \Some basic lemmas about poles/singularities\ + +lemma pole_lemma: + assumes holf: "f holomorphic_on S" and a: "a \ interior S" + shows "(\z. if z = a then deriv f a + else (f z - f a) / (z - a)) holomorphic_on S" (is "?F holomorphic_on S") +proof - + have F1: "?F field_differentiable (at u within S)" if "u \ S" "u \ a" for u + proof - + have fcd: "f field_differentiable at u within S" + using holf holomorphic_on_def by (simp add: \u \ S\) + have cd: "(\z. (f z - f a) / (z - a)) field_differentiable at u within S" + by (rule fcd derivative_intros | simp add: that)+ + have "0 < dist a u" using that dist_nz by blast + then show ?thesis + by (rule field_differentiable_transform_within [OF _ _ _ cd]) (auto simp: \u \ S\) + qed + have F2: "?F field_differentiable at a" if "0 < e" "ball a e \ S" for e + proof - + have holfb: "f holomorphic_on ball a e" + by (rule holomorphic_on_subset [OF holf \ball a e \ S\]) + have 2: "?F holomorphic_on ball a e - {a}" + apply (simp add: holomorphic_on_def flip: field_differentiable_def) + using mem_ball that + apply (auto intro: F1 field_differentiable_within_subset) + done + have "isCont (\z. if z = a then deriv f a else (f z - f a) / (z - a)) x" + if "dist a x < e" for x + proof (cases "x=a") + case True + then have "f field_differentiable at a" + using holfb \0 < e\ holomorphic_on_imp_differentiable_at by auto + with True show ?thesis + by (auto simp: continuous_at has_field_derivative_iff simp flip: DERIV_deriv_iff_field_differentiable + elim: rev_iffD1 [OF _ LIM_equal]) + next + case False with 2 that show ?thesis + by (force simp: holomorphic_on_open open_Diff field_differentiable_def [symmetric] field_differentiable_imp_continuous_at) + qed + then have 1: "continuous_on (ball a e) ?F" + by (clarsimp simp: continuous_on_eq_continuous_at) + have "?F holomorphic_on ball a e" + by (auto intro: no_isolated_singularity [OF 1 2]) + with that show ?thesis + by (simp add: holomorphic_on_open field_differentiable_def [symmetric] + field_differentiable_at_within) + qed + show ?thesis + proof + fix x assume "x \ S" show "?F field_differentiable at x within S" + proof (cases "x=a") + case True then show ?thesis + using a by (auto simp: mem_interior intro: field_differentiable_at_within F2) + next + case False with F1 \x \ S\ + show ?thesis by blast + qed + qed +qed + +lemma pole_theorem: + assumes holg: "g holomorphic_on S" and a: "a \ interior S" + and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" + shows "(\z. if z = a then deriv g a + else f z - g a/(z - a)) holomorphic_on S" + using pole_lemma [OF holg a] + by (rule holomorphic_transform) (simp add: eq field_split_simps) + +lemma pole_lemma_open: + assumes "f holomorphic_on S" "open S" + shows "(\z. if z = a then deriv f a else (f z - f a)/(z - a)) holomorphic_on S" +proof (cases "a \ S") + case True with assms interior_eq pole_lemma + show ?thesis by fastforce +next + case False with assms show ?thesis + apply (simp add: holomorphic_on_def field_differentiable_def [symmetric], clarify) + apply (rule field_differentiable_transform_within [where f = "\z. (f z - f a)/(z - a)" and d = 1]) + apply (rule derivative_intros | force)+ + done +qed + +lemma pole_theorem_open: + assumes holg: "g holomorphic_on S" and S: "open S" + and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" + shows "(\z. if z = a then deriv g a + else f z - g a/(z - a)) holomorphic_on S" + using pole_lemma_open [OF holg S] + by (rule holomorphic_transform) (auto simp: eq divide_simps) + +lemma pole_theorem_0: + assumes holg: "g holomorphic_on S" and a: "a \ interior S" + and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" + and [simp]: "f a = deriv g a" "g a = 0" + shows "f holomorphic_on S" + using pole_theorem [OF holg a eq] + by (rule holomorphic_transform) (auto simp: eq field_split_simps) + +lemma pole_theorem_open_0: + assumes holg: "g holomorphic_on S" and S: "open S" + and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" + and [simp]: "f a = deriv g a" "g a = 0" + shows "f holomorphic_on S" + using pole_theorem_open [OF holg S eq] + by (rule holomorphic_transform) (auto simp: eq field_split_simps) + +lemma pole_theorem_analytic: + assumes g: "g analytic_on S" + and eq: "\z. z \ S + \ \d. 0 < d \ (\w \ ball z d - {a}. g w = (w - a) * f w)" + shows "(\z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on S" (is "?F analytic_on S") + unfolding analytic_on_def +proof + fix x + assume "x \ S" + with g obtain e where "0 < e" and e: "g holomorphic_on ball x e" + by (auto simp add: analytic_on_def) + obtain d where "0 < d" and d: "\w. w \ ball x d - {a} \ g w = (w - a) * f w" + using \x \ S\ eq by blast + have "?F holomorphic_on ball x (min d e)" + using d e \x \ S\ by (fastforce simp: holomorphic_on_subset subset_ball intro!: pole_theorem_open) + then show "\e>0. ?F holomorphic_on ball x e" + using \0 < d\ \0 < e\ not_le by fastforce +qed + +lemma pole_theorem_analytic_0: + assumes g: "g analytic_on S" + and eq: "\z. z \ S \ \d. 0 < d \ (\w \ ball z d - {a}. g w = (w - a) * f w)" + and [simp]: "f a = deriv g a" "g a = 0" + shows "f analytic_on S" +proof - + have [simp]: "(\z. if z = a then deriv g a else f z - g a / (z - a)) = f" + by auto + show ?thesis + using pole_theorem_analytic [OF g eq] by simp +qed + +lemma pole_theorem_analytic_open_superset: + assumes g: "g analytic_on S" and "S \ T" "open T" + and eq: "\z. z \ T - {a} \ g z = (z - a) * f z" + shows "(\z. if z = a then deriv g a + else f z - g a/(z - a)) analytic_on S" +proof (rule pole_theorem_analytic [OF g]) + fix z + assume "z \ S" + then obtain e where "0 < e" and e: "ball z e \ T" + using assms openE by blast + then show "\d>0. \w\ball z d - {a}. g w = (w - a) * f w" + using eq by auto +qed + +lemma pole_theorem_analytic_open_superset_0: + assumes g: "g analytic_on S" "S \ T" "open T" "\z. z \ T - {a} \ g z = (z - a) * f z" + and [simp]: "f a = deriv g a" "g a = 0" + shows "f analytic_on S" +proof - + have [simp]: "(\z. if z = a then deriv g a else f z - g a / (z - a)) = f" + by auto + have "(\z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on S" + by (rule pole_theorem_analytic_open_superset [OF g]) + then show ?thesis by simp +qed + + +subsection\General, homology form of Cauchy's theorem\ + +text\Proof is based on Dixon's, as presented in Lang's "Complex Analysis" book (page 147).\ + +lemma contour_integral_continuous_on_linepath_2D: + assumes "open U" and cont_dw: "\w. w \ U \ F w contour_integrable_on (linepath a b)" + and cond_uu: "continuous_on (U \ U) (\(x,y). F x y)" + and abu: "closed_segment a b \ U" + shows "continuous_on U (\w. contour_integral (linepath a b) (F w))" +proof - + have *: "\d>0. \x'\U. dist x' w < d \ + dist (contour_integral (linepath a b) (F x')) + (contour_integral (linepath a b) (F w)) \ \" + if "w \ U" "0 < \" "a \ b" for w \ + proof - + obtain \ where "\>0" and \: "cball w \ \ U" using open_contains_cball \open U\ \w \ U\ by force + let ?TZ = "cball w \ \ closed_segment a b" + have "uniformly_continuous_on ?TZ (\(x,y). F x y)" + proof (rule compact_uniformly_continuous) + show "continuous_on ?TZ (\(x,y). F x y)" + by (rule continuous_on_subset[OF cond_uu]) (use SigmaE \ abu in blast) + show "compact ?TZ" + by (simp add: compact_Times) + qed + then obtain \ where "\>0" + and \: "\x x'. \x\?TZ; x'\?TZ; dist x' x < \\ \ + dist ((\(x,y). F x y) x') ((\(x,y). F x y) x) < \/norm(b - a)" + apply (rule uniformly_continuous_onE [where e = "\/norm(b - a)"]) + using \0 < \\ \a \ b\ by auto + have \: "\norm (w - x1) \ \; x2 \ closed_segment a b; + norm (w - x1') \ \; x2' \ closed_segment a b; norm ((x1', x2') - (x1, x2)) < \\ + \ norm (F x1' x2' - F x1 x2) \ \ / cmod (b - a)" + for x1 x2 x1' x2' + using \ [of "(x1,x2)" "(x1',x2')"] by (force simp: dist_norm) + have le_ee: "cmod (contour_integral (linepath a b) (\x. F x' x - F w x)) \ \" + if "x' \ U" "cmod (x' - w) < \" "cmod (x' - w) < \" for x' + proof - + have "(\x. F x' x - F w x) contour_integrable_on linepath a b" + by (simp add: \w \ U\ cont_dw contour_integrable_diff that) + then have "cmod (contour_integral (linepath a b) (\x. F x' x - F w x)) \ \/norm(b - a) * norm(b - a)" + apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_integral _ \]) + using \0 < \\ \0 < \\ that apply (auto simp: norm_minus_commute) + done + also have "\ = \" using \a \ b\ by simp + finally show ?thesis . + qed + show ?thesis + apply (rule_tac x="min \ \" in exI) + using \0 < \\ \0 < \\ + apply (auto simp: dist_norm contour_integral_diff [OF cont_dw cont_dw, symmetric] \w \ U\ intro: le_ee) + done + qed + show ?thesis + proof (cases "a=b") + case True + then show ?thesis by simp + next + case False + show ?thesis + by (rule continuous_onI) (use False in \auto intro: *\) + qed +qed + +text\This version has \<^term>\polynomial_function \\ as an additional assumption.\ +lemma Cauchy_integral_formula_global_weak: + assumes "open U" and holf: "f holomorphic_on U" + and z: "z \ U" and \: "polynomial_function \" + and pasz: "path_image \ \ U - {z}" and loop: "pathfinish \ = pathstart \" + and zero: "\w. w \ U \ winding_number \ w = 0" + shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" +proof - + obtain \' where pf\': "polynomial_function \'" and \': "\x. (\ has_vector_derivative (\' x)) (at x)" + using has_vector_derivative_polynomial_function [OF \] by blast + then have "bounded(path_image \')" + by (simp add: path_image_def compact_imp_bounded compact_continuous_image continuous_on_polymonial_function) + then obtain B where "B>0" and B: "\x. x \ path_image \' \ norm x \ B" + using bounded_pos by force + define d where [abs_def]: "d z w = (if w = z then deriv f z else (f w - f z)/(w - z))" for z w + define v where "v = {w. w \ path_image \ \ winding_number \ w = 0}" + have "path \" "valid_path \" using \ + by (auto simp: path_polynomial_function valid_path_polynomial_function) + then have ov: "open v" + by (simp add: v_def open_winding_number_levelsets loop) + have uv_Un: "U \ v = UNIV" + using pasz zero by (auto simp: v_def) + have conf: "continuous_on U f" + by (metis holf holomorphic_on_imp_continuous_on) + have hol_d: "(d y) holomorphic_on U" if "y \ U" for y + proof - + have *: "(\c. if c = y then deriv f y else (f c - f y) / (c - y)) holomorphic_on U" + by (simp add: holf pole_lemma_open \open U\) + then have "isCont (\x. if x = y then deriv f y else (f x - f y) / (x - y)) y" + using at_within_open field_differentiable_imp_continuous_at holomorphic_on_def that \open U\ by fastforce + then have "continuous_on U (d y)" + apply (simp add: d_def continuous_on_eq_continuous_at \open U\, clarify) + using * holomorphic_on_def + by (meson field_differentiable_within_open field_differentiable_imp_continuous_at \open U\) + moreover have "d y holomorphic_on U - {y}" + proof - + have "\w. w \ U - {y} \ + (\w. if w = y then deriv f y else (f w - f y) / (w - y)) field_differentiable at w" + apply (rule_tac d="dist w y" and f = "\w. (f w - f y)/(w - y)" in field_differentiable_transform_within) + apply (auto simp: dist_pos_lt dist_commute intro!: derivative_intros) + using \open U\ holf holomorphic_on_imp_differentiable_at by blast + then show ?thesis + unfolding field_differentiable_def by (simp add: d_def holomorphic_on_open \open U\ open_delete) + qed + ultimately show ?thesis + by (rule no_isolated_singularity) (auto simp: \open U\) + qed + have cint_fxy: "(\x. (f x - f y) / (x - y)) contour_integrable_on \" if "y \ path_image \" for y + proof (rule contour_integrable_holomorphic_simple [where S = "U-{y}"]) + show "(\x. (f x - f y) / (x - y)) holomorphic_on U - {y}" + by (force intro: holomorphic_intros holomorphic_on_subset [OF holf]) + show "path_image \ \ U - {y}" + using pasz that by blast + qed (auto simp: \open U\ open_delete \valid_path \\) + define h where + "h z = (if z \ U then contour_integral \ (d z) else contour_integral \ (\w. f w/(w - z)))" for z + have U: "((d z) has_contour_integral h z) \" if "z \ U" for z + proof - + have "d z holomorphic_on U" + by (simp add: hol_d that) + with that show ?thesis + apply (simp add: h_def) + by (meson Diff_subset \open U\ \valid_path \\ contour_integrable_holomorphic_simple has_contour_integral_integral pasz subset_trans) + qed + have V: "((\w. f w / (w - z)) has_contour_integral h z) \" if z: "z \ v" for z + proof - + have 0: "0 = (f z) * 2 * of_real (2 * pi) * \ * winding_number \ z" + using v_def z by auto + then have "((\x. 1 / (x - z)) has_contour_integral 0) \" + using z v_def has_contour_integral_winding_number [OF \valid_path \\] by fastforce + then have "((\x. f z * (1 / (x - z))) has_contour_integral 0) \" + using has_contour_integral_lmul by fastforce + then have "((\x. f z / (x - z)) has_contour_integral 0) \" + by (simp add: field_split_simps) + moreover have "((\x. (f x - f z) / (x - z)) has_contour_integral contour_integral \ (d z)) \" + using z + apply (auto simp: v_def) + apply (metis (no_types, lifting) contour_integrable_eq d_def has_contour_integral_eq has_contour_integral_integral cint_fxy) + done + ultimately have *: "((\x. f z / (x - z) + (f x - f z) / (x - z)) has_contour_integral (0 + contour_integral \ (d z))) \" + by (rule has_contour_integral_add) + have "((\w. f w / (w - z)) has_contour_integral contour_integral \ (d z)) \" + if "z \ U" + using * by (auto simp: divide_simps has_contour_integral_eq) + moreover have "((\w. f w / (w - z)) has_contour_integral contour_integral \ (\w. f w / (w - z))) \" + if "z \ U" + apply (rule has_contour_integral_integral [OF contour_integrable_holomorphic_simple [where S=U]]) + using U pasz \valid_path \\ that + apply (auto intro: holomorphic_on_imp_continuous_on hol_d) + apply (rule continuous_intros conf holomorphic_intros holf assms | force)+ + done + ultimately show ?thesis + using z by (simp add: h_def) + qed + have znot: "z \ path_image \" + using pasz by blast + obtain d0 where "d0>0" and d0: "\x y. x \ path_image \ \ y \ - U \ d0 \ dist x y" + using separate_compact_closed [of "path_image \" "-U"] pasz \open U\ \path \\ compact_path_image + by blast + obtain dd where "0 < dd" and dd: "{y + k | y k. y \ path_image \ \ k \ ball 0 dd} \ U" + apply (rule that [of "d0/2"]) + using \0 < d0\ + apply (auto simp: dist_norm dest: d0) + done + have "\x x'. \x \ path_image \; dist x x' * 2 < dd\ \ \y k. x' = y + k \ y \ path_image \ \ dist 0 k * 2 \ dd" + apply (rule_tac x=x in exI) + apply (rule_tac x="x'-x" in exI) + apply (force simp: dist_norm) + done + then have 1: "path_image \ \ interior {y + k |y k. y \ path_image \ \ k \ cball 0 (dd / 2)}" + apply (clarsimp simp add: mem_interior) + using \0 < dd\ + apply (rule_tac x="dd/2" in exI, auto) + done + obtain T where "compact T" and subt: "path_image \ \ interior T" and T: "T \ U" + apply (rule that [OF _ 1]) + apply (fastforce simp add: \valid_path \\ compact_valid_path_image intro!: compact_sums) + apply (rule order_trans [OF _ dd]) + using \0 < dd\ by fastforce + obtain L where "L>0" + and L: "\f B. \f holomorphic_on interior T; \z. z\interior T \ cmod (f z) \ B\ \ + cmod (contour_integral \ f) \ L * B" + using contour_integral_bound_exists [OF open_interior \valid_path \\ subt] + by blast + have "bounded(f ` T)" + by (meson \compact T\ compact_continuous_image compact_imp_bounded conf continuous_on_subset T) + then obtain D where "D>0" and D: "\x. x \ T \ norm (f x) \ D" + by (auto simp: bounded_pos) + obtain C where "C>0" and C: "\x. x \ T \ norm x \ C" + using \compact T\ bounded_pos compact_imp_bounded by force + have "dist (h y) 0 \ e" if "0 < e" and le: "D * L / e + C \ cmod y" for e y + proof - + have "D * L / e > 0" using \D>0\ \L>0\ \e>0\ by simp + with le have ybig: "norm y > C" by force + with C have "y \ T" by force + then have ynot: "y \ path_image \" + using subt interior_subset by blast + have [simp]: "winding_number \ y = 0" + apply (rule winding_number_zero_outside [of _ "cball 0 C"]) + using ybig interior_subset subt + apply (force simp: loop \path \\ dist_norm intro!: C)+ + done + have [simp]: "h y = contour_integral \ (\w. f w/(w - y))" + by (rule contour_integral_unique [symmetric]) (simp add: v_def ynot V) + have holint: "(\w. f w / (w - y)) holomorphic_on interior T" + apply (rule holomorphic_on_divide) + using holf holomorphic_on_subset interior_subset T apply blast + apply (rule holomorphic_intros)+ + using \y \ T\ interior_subset by auto + have leD: "cmod (f z / (z - y)) \ D * (e / L / D)" if z: "z \ interior T" for z + proof - + have "D * L / e + cmod z \ cmod y" + using le C [of z] z using interior_subset by force + then have DL2: "D * L / e \ cmod (z - y)" + using norm_triangle_ineq2 [of y z] by (simp add: norm_minus_commute) + have "cmod (f z / (z - y)) = cmod (f z) * inverse (cmod (z - y))" + by (simp add: norm_mult norm_inverse Fields.field_class.field_divide_inverse) + also have "\ \ D * (e / L / D)" + apply (rule mult_mono) + using that D interior_subset apply blast + using \L>0\ \e>0\ \D>0\ DL2 + apply (auto simp: norm_divide field_split_simps) + done + finally show ?thesis . + qed + have "dist (h y) 0 = cmod (contour_integral \ (\w. f w / (w - y)))" + by (simp add: dist_norm) + also have "\ \ L * (D * (e / L / D))" + by (rule L [OF holint leD]) + also have "\ = e" + using \L>0\ \0 < D\ by auto + finally show ?thesis . + qed + then have "(h \ 0) at_infinity" + by (meson Lim_at_infinityI) + moreover have "h holomorphic_on UNIV" + proof - + have con_ff: "continuous (at (x,z)) (\(x,y). (f y - f x) / (y - x))" + if "x \ U" "z \ U" "x \ z" for x z + using that conf + apply (simp add: split_def continuous_on_eq_continuous_at \open U\) + apply (simp | rule continuous_intros continuous_within_compose2 [where g=f])+ + done + have con_fstsnd: "continuous_on UNIV (\x. (fst x - snd x) ::complex)" + by (rule continuous_intros)+ + have open_uu_Id: "open (U \ U - Id)" + apply (rule open_Diff) + apply (simp add: open_Times \open U\) + using continuous_closed_preimage_constant [OF con_fstsnd closed_UNIV, of 0] + apply (auto simp: Id_fstsnd_eq algebra_simps) + done + have con_derf: "continuous (at z) (deriv f)" if "z \ U" for z + apply (rule continuous_on_interior [of U]) + apply (simp add: holf holomorphic_deriv holomorphic_on_imp_continuous_on \open U\) + by (simp add: interior_open that \open U\) + have tendsto_f': "((\(x,y). if y = x then deriv f (x) + else (f (y) - f (x)) / (y - x)) \ deriv f x) + (at (x, x) within U \ U)" if "x \ U" for x + proof (rule Lim_withinI) + fix e::real assume "0 < e" + obtain k1 where "k1>0" and k1: "\x'. norm (x' - x) \ k1 \ norm (deriv f x' - deriv f x) < e" + using \0 < e\ continuous_within_E [OF con_derf [OF \x \ U\]] + by (metis UNIV_I dist_norm) + obtain k2 where "k2>0" and k2: "ball x k2 \ U" + by (blast intro: openE [OF \open U\] \x \ U\) + have neq: "norm ((f z' - f x') / (z' - x') - deriv f x) \ e" + if "z' \ x'" and less_k1: "norm (x'-x, z'-x) < k1" and less_k2: "norm (x'-x, z'-x) < k2" + for x' z' + proof - + have cs_less: "w \ closed_segment x' z' \ cmod (w - x) \ norm (x'-x, z'-x)" for w + apply (drule segment_furthest_le [where y=x]) + by (metis (no_types) dist_commute dist_norm norm_fst_le norm_snd_le order_trans) + have derf_le: "w \ closed_segment x' z' \ z' \ x' \ cmod (deriv f w - deriv f x) \ e" for w + by (blast intro: cs_less less_k1 k1 [unfolded divide_const_simps dist_norm] less_imp_le le_less_trans) + have f_has_der: "\x. x \ U \ (f has_field_derivative deriv f x) (at x within U)" + by (metis DERIV_deriv_iff_field_differentiable at_within_open holf holomorphic_on_def \open U\) + have "closed_segment x' z' \ U" + by (rule order_trans [OF _ k2]) (simp add: cs_less le_less_trans [OF _ less_k2] dist_complex_def norm_minus_commute subset_iff) + then have cint_derf: "(deriv f has_contour_integral f z' - f x') (linepath x' z')" + using contour_integral_primitive [OF f_has_der valid_path_linepath] pasz by simp + then have *: "((\x. deriv f x / (z' - x')) has_contour_integral (f z' - f x') / (z' - x')) (linepath x' z')" + by (rule has_contour_integral_div) + have "norm ((f z' - f x') / (z' - x') - deriv f x) \ e/norm(z' - x') * norm(z' - x')" + apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_diff [OF *]]) + using has_contour_integral_div [where c = "z' - x'", OF has_contour_integral_const_linepath [of "deriv f x" z' x']] + \e > 0\ \z' \ x'\ + apply (auto simp: norm_divide divide_simps derf_le) + done + also have "\ \ e" using \0 < e\ by simp + finally show ?thesis . + qed + show "\d>0. \xa\U \ U. + 0 < dist xa (x, x) \ dist xa (x, x) < d \ + dist (case xa of (x, y) \ if y = x then deriv f x else (f y - f x) / (y - x)) (deriv f x) \ e" + apply (rule_tac x="min k1 k2" in exI) + using \k1>0\ \k2>0\ \e>0\ + apply (force simp: dist_norm neq intro: dual_order.strict_trans2 k1 less_imp_le norm_fst_le) + done + qed + have con_pa_f: "continuous_on (path_image \) f" + by (meson holf holomorphic_on_imp_continuous_on holomorphic_on_subset interior_subset subt T) + have le_B: "\T. T \ {0..1} \ cmod (vector_derivative \ (at T)) \ B" + apply (rule B) + using \' using path_image_def vector_derivative_at by fastforce + have f_has_cint: "\w. w \ v - path_image \ \ ((\u. f u / (u - w) ^ 1) has_contour_integral h w) \" + by (simp add: V) + have cond_uu: "continuous_on (U \ U) (\(x,y). d x y)" + apply (simp add: continuous_on_eq_continuous_within d_def continuous_within tendsto_f') + apply (simp add: tendsto_within_open_NO_MATCH open_Times \open U\, clarify) + apply (rule Lim_transform_within_open [OF _ open_uu_Id, where f = "(\(x,y). (f y - f x) / (y - x))"]) + using con_ff + apply (auto simp: continuous_within) + done + have hol_dw: "(\z. d z w) holomorphic_on U" if "w \ U" for w + proof - + have "continuous_on U ((\(x,y). d x y) \ (\z. (w,z)))" + by (rule continuous_on_compose continuous_intros continuous_on_subset [OF cond_uu] | force intro: that)+ + then have *: "continuous_on U (\z. if w = z then deriv f z else (f w - f z) / (w - z))" + by (rule rev_iffD1 [OF _ continuous_on_cong [OF refl]]) (simp add: d_def field_simps) + have **: "\x. \x \ U; x \ w\ \ (\z. if w = z then deriv f z else (f w - f z) / (w - z)) field_differentiable at x" + apply (rule_tac f = "\x. (f w - f x)/(w - x)" and d = "dist x w" in field_differentiable_transform_within) + apply (rule \open U\ derivative_intros holomorphic_on_imp_differentiable_at [OF holf] | force simp: dist_commute)+ + done + show ?thesis + unfolding d_def + apply (rule no_isolated_singularity [OF * _ \open U\, where K = "{w}"]) + apply (auto simp: field_differentiable_def [symmetric] holomorphic_on_open open_Diff \open U\ **) + done + qed + { fix a b + assume abu: "closed_segment a b \ U" + then have "\w. w \ U \ (\z. d z w) contour_integrable_on (linepath a b)" + by (metis hol_dw continuous_on_subset contour_integrable_continuous_linepath holomorphic_on_imp_continuous_on) + then have cont_cint_d: "continuous_on U (\w. contour_integral (linepath a b) (\z. d z w))" + apply (rule contour_integral_continuous_on_linepath_2D [OF \open U\ _ _ abu]) + apply (auto intro: continuous_on_swap_args cond_uu) + done + have cont_cint_d\: "continuous_on {0..1} ((\w. contour_integral (linepath a b) (\z. d z w)) \ \)" + proof (rule continuous_on_compose) + show "continuous_on {0..1} \" + using \path \\ path_def by blast + show "continuous_on (\ ` {0..1}) (\w. contour_integral (linepath a b) (\z. d z w))" + using pasz unfolding path_image_def + by (auto intro!: continuous_on_subset [OF cont_cint_d]) + qed + have cint_cint: "(\w. contour_integral (linepath a b) (\z. d z w)) contour_integrable_on \" + apply (simp add: contour_integrable_on) + apply (rule integrable_continuous_real) + apply (rule continuous_on_mult [OF cont_cint_d\ [unfolded o_def]]) + using pf\' + by (simp add: continuous_on_polymonial_function vector_derivative_at [OF \']) + have "contour_integral (linepath a b) h = contour_integral (linepath a b) (\z. contour_integral \ (d z))" + using abu by (force simp: h_def intro: contour_integral_eq) + also have "\ = contour_integral \ (\w. contour_integral (linepath a b) (\z. d z w))" + apply (rule contour_integral_swap) + apply (rule continuous_on_subset [OF cond_uu]) + using abu pasz \valid_path \\ + apply (auto intro!: continuous_intros) + by (metis \' continuous_on_eq path_def path_polynomial_function pf\' vector_derivative_at) + finally have cint_h_eq: + "contour_integral (linepath a b) h = + contour_integral \ (\w. contour_integral (linepath a b) (\z. d z w))" . + note cint_cint cint_h_eq + } note cint_h = this + have conthu: "continuous_on U h" + proof (simp add: continuous_on_sequentially, clarify) + fix a x + assume x: "x \ U" and au: "\n. a n \ U" and ax: "a \ x" + then have A1: "\\<^sub>F n in sequentially. d (a n) contour_integrable_on \" + by (meson U contour_integrable_on_def eventuallyI) + obtain dd where "dd>0" and dd: "cball x dd \ U" using open_contains_cball \open U\ x by force + have A2: "uniform_limit (path_image \) (\n. d (a n)) (d x) sequentially" + unfolding uniform_limit_iff dist_norm + proof clarify + fix ee::real + assume "0 < ee" + show "\\<^sub>F n in sequentially. \\\path_image \. cmod (d (a n) \ - d x \) < ee" + proof - + let ?ddpa = "{(w,z) |w z. w \ cball x dd \ z \ path_image \}" + have "uniformly_continuous_on ?ddpa (\(x,y). d x y)" + apply (rule compact_uniformly_continuous [OF continuous_on_subset[OF cond_uu]]) + using dd pasz \valid_path \\ + apply (auto simp: compact_Times compact_valid_path_image simp del: mem_cball) + done + then obtain kk where "kk>0" + and kk: "\x x'. \x \ ?ddpa; x' \ ?ddpa; dist x' x < kk\ \ + dist ((\(x,y). d x y) x') ((\(x,y). d x y) x) < ee" + by (rule uniformly_continuous_onE [where e = ee]) (use \0 < ee\ in auto) + have kk: "\norm (w - x) \ dd; z \ path_image \; norm ((w, z) - (x, z)) < kk\ \ norm (d w z - d x z) < ee" + for w z + using \dd>0\ kk [of "(x,z)" "(w,z)"] by (force simp: norm_minus_commute dist_norm) + show ?thesis + using ax unfolding lim_sequentially eventually_sequentially + apply (drule_tac x="min dd kk" in spec) + using \dd > 0\ \kk > 0\ + apply (fastforce simp: kk dist_norm) + done + qed + qed + have "(\n. contour_integral \ (d (a n))) \ contour_integral \ (d x)" + by (rule contour_integral_uniform_limit [OF A1 A2 le_B]) (auto simp: \valid_path \\) + then have tendsto_hx: "(\n. contour_integral \ (d (a n))) \ h x" + by (simp add: h_def x) + then show "(h \ a) \ h x" + by (simp add: h_def x au o_def) + qed + show ?thesis + proof (simp add: holomorphic_on_open field_differentiable_def [symmetric], clarify) + fix z0 + consider "z0 \ v" | "z0 \ U" using uv_Un by blast + then show "h field_differentiable at z0" + proof cases + assume "z0 \ v" then show ?thesis + using Cauchy_next_derivative [OF con_pa_f le_B f_has_cint _ ov] V f_has_cint \valid_path \\ + by (auto simp: field_differentiable_def v_def) + next + assume "z0 \ U" then + obtain e where "e>0" and e: "ball z0 e \ U" by (blast intro: openE [OF \open U\]) + have *: "contour_integral (linepath a b) h + contour_integral (linepath b c) h + contour_integral (linepath c a) h = 0" + if abc_subset: "convex hull {a, b, c} \ ball z0 e" for a b c + proof - + have *: "\x1 x2 z. z \ U \ closed_segment x1 x2 \ U \ (\w. d w z) contour_integrable_on linepath x1 x2" + using hol_dw holomorphic_on_imp_continuous_on \open U\ + by (auto intro!: contour_integrable_holomorphic_simple) + have abc: "closed_segment a b \ U" "closed_segment b c \ U" "closed_segment c a \ U" + using that e segments_subset_convex_hull by fastforce+ + have eq0: "\w. w \ U \ contour_integral (linepath a b +++ linepath b c +++ linepath c a) (\z. d z w) = 0" + apply (rule contour_integral_unique [OF Cauchy_theorem_triangle]) + apply (rule holomorphic_on_subset [OF hol_dw]) + using e abc_subset by auto + have "contour_integral \ + (\x. contour_integral (linepath a b) (\z. d z x) + + (contour_integral (linepath b c) (\z. d z x) + + contour_integral (linepath c a) (\z. d z x))) = 0" + apply (rule contour_integral_eq_0) + using abc pasz U + apply (subst contour_integral_join [symmetric], auto intro: eq0 *)+ + done + then show ?thesis + by (simp add: cint_h abc contour_integrable_add contour_integral_add [symmetric] add_ac) + qed + show ?thesis + using e \e > 0\ + by (auto intro!: holomorphic_on_imp_differentiable_at [OF _ open_ball] analytic_imp_holomorphic + Morera_triangle continuous_on_subset [OF conthu] *) + qed + qed + qed + ultimately have [simp]: "h z = 0" for z + by (meson Liouville_weak) + have "((\w. 1 / (w - z)) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z) \" + by (rule has_contour_integral_winding_number [OF \valid_path \\ znot]) + then have "((\w. f z * (1 / (w - z))) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z * f z) \" + by (metis mult.commute has_contour_integral_lmul) + then have 1: "((\w. f z / (w - z)) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z * f z) \" + by (simp add: field_split_simps) + moreover have 2: "((\w. (f w - f z) / (w - z)) has_contour_integral 0) \" + using U [OF z] pasz d_def by (force elim: has_contour_integral_eq [where g = "\w. (f w - f z)/(w - z)"]) + show ?thesis + using has_contour_integral_add [OF 1 2] by (simp add: diff_divide_distrib) +qed + +theorem Cauchy_integral_formula_global: + assumes S: "open S" and holf: "f holomorphic_on S" + and z: "z \ S" and vpg: "valid_path \" + and pasz: "path_image \ \ S - {z}" and loop: "pathfinish \ = pathstart \" + and zero: "\w. w \ S \ winding_number \ w = 0" + shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" +proof - + have "path \" using vpg by (blast intro: valid_path_imp_path) + have hols: "(\w. f w / (w - z)) holomorphic_on S - {z}" "(\w. 1 / (w - z)) holomorphic_on S - {z}" + by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+ + then have cint_fw: "(\w. f w / (w - z)) contour_integrable_on \" + by (meson contour_integrable_holomorphic_simple holomorphic_on_imp_continuous_on open_delete S vpg pasz) + obtain d where "d>0" + and d: "\g h. \valid_path g; valid_path h; \t\{0..1}. cmod (g t - \ t) < d \ cmod (h t - \ t) < d; + pathstart h = pathstart g \ pathfinish h = pathfinish g\ + \ path_image h \ S - {z} \ (\f. f holomorphic_on S - {z} \ contour_integral h f = contour_integral g f)" + using contour_integral_nearby_ends [OF _ \path \\ pasz] S by (simp add: open_Diff) metis + obtain p where polyp: "polynomial_function p" + and ps: "pathstart p = pathstart \" and pf: "pathfinish p = pathfinish \" and led: "\t\{0..1}. cmod (p t - \ t) < d" + using path_approx_polynomial_function [OF \path \\ \d > 0\] by blast + then have ploop: "pathfinish p = pathstart p" using loop by auto + have vpp: "valid_path p" using polyp valid_path_polynomial_function by blast + have [simp]: "z \ path_image \" using pasz by blast + have paps: "path_image p \ S - {z}" and cint_eq: "(\f. f holomorphic_on S - {z} \ contour_integral p f = contour_integral \ f)" + using pf ps led d [OF vpg vpp] \d > 0\ by auto + have wn_eq: "winding_number p z = winding_number \ z" + using vpp paps + by (simp add: subset_Diff_insert vpg valid_path_polynomial_function winding_number_valid_path cint_eq hols) + have "winding_number p w = winding_number \ w" if "w \ S" for w + proof - + have hol: "(\v. 1 / (v - w)) holomorphic_on S - {z}" + using that by (force intro: holomorphic_intros holomorphic_on_subset [OF holf]) + have "w \ path_image p" "w \ path_image \" using paps pasz that by auto + then show ?thesis + using vpp vpg by (simp add: subset_Diff_insert valid_path_polynomial_function winding_number_valid_path cint_eq [OF hol]) + qed + then have wn0: "\w. w \ S \ winding_number p w = 0" + by (simp add: zero) + show ?thesis + using Cauchy_integral_formula_global_weak [OF S holf z polyp paps ploop wn0] hols + by (metis wn_eq cint_eq has_contour_integral_eqpath cint_fw cint_eq) +qed + +theorem Cauchy_theorem_global: + assumes S: "open S" and holf: "f holomorphic_on S" + and vpg: "valid_path \" and loop: "pathfinish \ = pathstart \" + and pas: "path_image \ \ S" + and zero: "\w. w \ S \ winding_number \ w = 0" + shows "(f has_contour_integral 0) \" +proof - + obtain z where "z \ S" and znot: "z \ path_image \" + proof - + have "compact (path_image \)" + using compact_valid_path_image vpg by blast + then have "path_image \ \ S" + by (metis (no_types) compact_open path_image_nonempty S) + with pas show ?thesis by (blast intro: that) + qed + then have pasz: "path_image \ \ S - {z}" using pas by blast + have hol: "(\w. (w - z) * f w) holomorphic_on S" + by (rule holomorphic_intros holf)+ + show ?thesis + using Cauchy_integral_formula_global [OF S hol \z \ S\ vpg pasz loop zero] + by (auto simp: znot elim!: has_contour_integral_eq) +qed + +corollary Cauchy_theorem_global_outside: + assumes "open S" "f holomorphic_on S" "valid_path \" "pathfinish \ = pathstart \" "path_image \ \ S" + "\w. w \ S \ w \ outside(path_image \)" + shows "(f has_contour_integral 0) \" +by (metis Cauchy_theorem_global assms winding_number_zero_in_outside valid_path_imp_path) + +lemma simply_connected_imp_winding_number_zero: + assumes "simply_connected S" "path g" + "path_image g \ S" "pathfinish g = pathstart g" "z \ S" + shows "winding_number g z = 0" +proof - + have hom: "homotopic_loops S g (linepath (pathstart g) (pathstart g))" + by (meson assms homotopic_paths_imp_homotopic_loops pathfinish_linepath simply_connected_eq_contractible_path) + then have "homotopic_paths (- {z}) g (linepath (pathstart g) (pathstart g))" + by (meson \z \ S\ homotopic_loops_imp_homotopic_paths_null homotopic_paths_subset subset_Compl_singleton) + then have "winding_number g z = winding_number(linepath (pathstart g) (pathstart g)) z" + by (rule winding_number_homotopic_paths) + also have "\ = 0" + using assms by (force intro: winding_number_trivial) + finally show ?thesis . +qed + +lemma Cauchy_theorem_simply_connected: + assumes "open S" "simply_connected S" "f holomorphic_on S" "valid_path g" + "path_image g \ S" "pathfinish g = pathstart g" + shows "(f has_contour_integral 0) g" +using assms +apply (simp add: simply_connected_eq_contractible_path) +apply (auto intro!: Cauchy_theorem_null_homotopic [where a = "pathstart g"] + homotopic_paths_imp_homotopic_loops) +using valid_path_imp_path by blast + +proposition\<^marker>\tag unimportant\ holomorphic_logarithm_exists: + assumes A: "convex A" "open A" + and f: "f holomorphic_on A" "\x. x \ A \ f x \ 0" + and z0: "z0 \ A" + obtains g where "g holomorphic_on A" and "\x. x \ A \ exp (g x) = f x" +proof - + note f' = holomorphic_derivI [OF f(1) A(2)] + obtain g where g: "\x. x \ A \ (g has_field_derivative deriv f x / f x) (at x)" + proof (rule holomorphic_convex_primitive' [OF A]) + show "(\x. deriv f x / f x) holomorphic_on A" + by (intro holomorphic_intros f A) + qed (auto simp: A at_within_open[of _ A]) + define h where "h = (\x. -g z0 + ln (f z0) + g x)" + from g and A have g_holo: "g holomorphic_on A" + by (auto simp: holomorphic_on_def at_within_open[of _ A] field_differentiable_def) + hence h_holo: "h holomorphic_on A" + by (auto simp: h_def intro!: holomorphic_intros) + have "\c. \x\A. f x / exp (h x) - 1 = c" + proof (rule has_field_derivative_zero_constant, goal_cases) + case (2 x) + note [simp] = at_within_open[OF _ \open A\] + from 2 and z0 and f show ?case + by (auto simp: h_def exp_diff field_simps intro!: derivative_eq_intros g f') + qed fact+ + then obtain c where c: "\x. x \ A \ f x / exp (h x) - 1 = c" + by blast + from c[OF z0] and z0 and f have "c = 0" + by (simp add: h_def) + with c have "\x. x \ A \ exp (h x) = f x" by simp + from that[OF h_holo this] show ?thesis . +qed + + +(* FIXME mv to Cauchy_Integral_Theorem.thy *) +subsection\Cauchy's inequality and more versions of Liouville\ + +lemma Cauchy_higher_deriv_bound: + assumes holf: "f holomorphic_on (ball z r)" + and contf: "continuous_on (cball z r) f" + and fin : "\w. w \ ball z r \ f w \ ball y B0" + and "0 < r" and "0 < n" + shows "norm ((deriv ^^ n) f z) \ (fact n) * B0 / r^n" +proof - + have "0 < B0" using \0 < r\ fin [of z] + by (metis ball_eq_empty ex_in_conv fin not_less) + have le_B0: "\w. cmod (w - z) \ r \ cmod (f w - y) \ B0" + apply (rule continuous_on_closure_norm_le [of "ball z r" "\w. f w - y"]) + apply (auto simp: \0 < r\ dist_norm norm_minus_commute) + apply (rule continuous_intros contf)+ + using fin apply (simp add: dist_commute dist_norm less_eq_real_def) + done + have "(deriv ^^ n) f z = (deriv ^^ n) (\w. f w) z - (deriv ^^ n) (\w. y) z" + using \0 < n\ by simp + also have "... = (deriv ^^ n) (\w. f w - y) z" + by (rule higher_deriv_diff [OF holf, symmetric]) (auto simp: \0 < r\) + finally have "(deriv ^^ n) f z = (deriv ^^ n) (\w. f w - y) z" . + have contf': "continuous_on (cball z r) (\u. f u - y)" + by (rule contf continuous_intros)+ + have holf': "(\u. (f u - y)) holomorphic_on (ball z r)" + by (simp add: holf holomorphic_on_diff) + define a where "a = (2 * pi)/(fact n)" + have "0 < a" by (simp add: a_def) + have "B0/r^(Suc n)*2 * pi * r = a*((fact n)*B0/r^n)" + using \0 < r\ by (simp add: a_def field_split_simps) + have der_dif: "(deriv ^^ n) (\w. f w - y) z = (deriv ^^ n) f z" + using \0 < r\ \0 < n\ + by (auto simp: higher_deriv_diff [OF holf holomorphic_on_const]) + have "norm ((2 * of_real pi * \)/(fact n) * (deriv ^^ n) (\w. f w - y) z) + \ (B0/r^(Suc n)) * (2 * pi * r)" + apply (rule has_contour_integral_bound_circlepath [of "(\u. (f u - y)/(u - z)^(Suc n))" _ z]) + using Cauchy_has_contour_integral_higher_derivative_circlepath [OF contf' holf'] + using \0 < B0\ \0 < r\ + apply (auto simp: norm_divide norm_mult norm_power divide_simps le_B0) + done + then show ?thesis + using \0 < r\ + by (auto simp: norm_divide norm_mult norm_power field_simps der_dif le_B0) +qed + +lemma Cauchy_inequality: + assumes holf: "f holomorphic_on (ball \ r)" + and contf: "continuous_on (cball \ r) f" + and "0 < r" + and nof: "\x. norm(\-x) = r \ norm(f x) \ B" + shows "norm ((deriv ^^ n) f \) \ (fact n) * B / r^n" +proof - + obtain x where "norm (\-x) = r" + by (metis abs_of_nonneg add_diff_cancel_left' \0 < r\ diff_add_cancel + dual_order.strict_implies_order norm_of_real) + then have "0 \ B" + by (metis nof norm_not_less_zero not_le order_trans) + have "((\u. f u / (u - \) ^ Suc n) has_contour_integral (2 * pi) * \ / fact n * (deriv ^^ n) f \) + (circlepath \ r)" + apply (rule Cauchy_has_contour_integral_higher_derivative_circlepath [OF contf holf]) + using \0 < r\ by simp + then have "norm ((2 * pi * \)/(fact n) * (deriv ^^ n) f \) \ (B / r^(Suc n)) * (2 * pi * r)" + apply (rule has_contour_integral_bound_circlepath) + using \0 \ B\ \0 < r\ + apply (simp_all add: norm_divide norm_power nof frac_le norm_minus_commute del: power_Suc) + done + then show ?thesis using \0 < r\ + by (simp add: norm_divide norm_mult field_simps) +qed + +lemma Liouville_polynomial: + assumes holf: "f holomorphic_on UNIV" + and nof: "\z. A \ norm z \ norm(f z) \ B * norm z ^ n" + shows "f \ = (\k\n. (deriv^^k) f 0 / fact k * \ ^ k)" +proof (cases rule: le_less_linear [THEN disjE]) + assume "B \ 0" + then have "\z. A \ norm z \ norm(f z) = 0" + by (metis nof less_le_trans zero_less_mult_iff neqE norm_not_less_zero norm_power not_le) + then have f0: "(f \ 0) at_infinity" + using Lim_at_infinity by force + then have [simp]: "f = (\w. 0)" + using Liouville_weak [OF holf, of 0] + by (simp add: eventually_at_infinity f0) meson + show ?thesis by simp +next + assume "0 < B" + have "((\k. (deriv ^^ k) f 0 / (fact k) * (\ - 0)^k) sums f \)" + apply (rule holomorphic_power_series [where r = "norm \ + 1"]) + using holf holomorphic_on_subset apply auto + done + then have sumsf: "((\k. (deriv ^^ k) f 0 / (fact k) * \^k) sums f \)" by simp + have "(deriv ^^ k) f 0 / fact k * \ ^ k = 0" if "k>n" for k + proof (cases "(deriv ^^ k) f 0 = 0") + case True then show ?thesis by simp + next + case False + define w where "w = complex_of_real (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" + have "1 \ abs (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" + using \0 < B\ by simp + then have wge1: "1 \ norm w" + by (metis norm_of_real w_def) + then have "w \ 0" by auto + have kB: "0 < fact k * B" + using \0 < B\ by simp + then have "0 \ fact k * B / cmod ((deriv ^^ k) f 0)" + by simp + then have wgeA: "A \ cmod w" + by (simp only: w_def norm_of_real) + have "fact k * B / cmod ((deriv ^^ k) f 0) < abs (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" + using \0 < B\ by simp + then have wge: "fact k * B / cmod ((deriv ^^ k) f 0) < norm w" + by (metis norm_of_real w_def) + then have "fact k * B / norm w < cmod ((deriv ^^ k) f 0)" + using False by (simp add: field_split_simps mult.commute split: if_split_asm) + also have "... \ fact k * (B * norm w ^ n) / norm w ^ k" + apply (rule Cauchy_inequality) + using holf holomorphic_on_subset apply force + using holf holomorphic_on_imp_continuous_on holomorphic_on_subset apply blast + using \w \ 0\ apply simp + by (metis nof wgeA dist_0_norm dist_norm) + also have "... = fact k * (B * 1 / cmod w ^ (k-n))" + apply (simp only: mult_cancel_left times_divide_eq_right [symmetric]) + using \k>n\ \w \ 0\ \0 < B\ apply (simp add: field_split_simps semiring_normalization_rules) + done + also have "... = fact k * B / cmod w ^ (k-n)" + by simp + finally have "fact k * B / cmod w < fact k * B / cmod w ^ (k - n)" . + then have "1 / cmod w < 1 / cmod w ^ (k - n)" + by (metis kB divide_inverse inverse_eq_divide mult_less_cancel_left_pos) + then have "cmod w ^ (k - n) < cmod w" + by (metis frac_le le_less_trans norm_ge_zero norm_one not_less order_refl wge1 zero_less_one) + with self_le_power [OF wge1] have False + by (meson diff_is_0_eq not_gr0 not_le that) + then show ?thesis by blast + qed + then have "(deriv ^^ (k + Suc n)) f 0 / fact (k + Suc n) * \ ^ (k + Suc n) = 0" for k + using not_less_eq by blast + then have "(\i. (deriv ^^ (i + Suc n)) f 0 / fact (i + Suc n) * \ ^ (i + Suc n)) sums 0" + by (rule sums_0) + with sums_split_initial_segment [OF sumsf, where n = "Suc n"] + show ?thesis + using atLeast0AtMost lessThan_Suc_atMost sums_unique2 by fastforce +qed + +text\Every bounded entire function is a constant function.\ +theorem Liouville_theorem: + assumes holf: "f holomorphic_on UNIV" + and bf: "bounded (range f)" + obtains c where "\z. f z = c" +proof - + obtain B where "\z. cmod (f z) \ B" + by (meson bf bounded_pos rangeI) + then show ?thesis + using Liouville_polynomial [OF holf, of 0 B 0, simplified] that by blast +qed + +text\A holomorphic function f has only isolated zeros unless f is 0.\ + +lemma powser_0_nonzero: + fixes a :: "nat \ 'a::{real_normed_field,banach}" + assumes r: "0 < r" + and sm: "\x. norm (x - \) < r \ (\n. a n * (x - \) ^ n) sums (f x)" + and [simp]: "f \ = 0" + and m0: "a m \ 0" and "m>0" + obtains s where "0 < s" and "\z. z \ cball \ s - {\} \ f z \ 0" +proof - + have "r \ conv_radius a" + using sm sums_summable by (auto simp: le_conv_radius_iff [where \=\]) + obtain m where am: "a m \ 0" and az [simp]: "(\n. n a n = 0)" + apply (rule_tac m = "LEAST n. a n \ 0" in that) + using m0 + apply (rule LeastI2) + apply (fastforce intro: dest!: not_less_Least)+ + done + define b where "b i = a (i+m) / a m" for i + define g where "g x = suminf (\i. b i * (x - \) ^ i)" for x + have [simp]: "b 0 = 1" + by (simp add: am b_def) + { fix x::'a + assume "norm (x - \) < r" + then have "(\n. (a m * (x - \)^m) * (b n * (x - \)^n)) sums (f x)" + using am az sm sums_zero_iff_shift [of m "(\n. a n * (x - \) ^ n)" "f x"] + by (simp add: b_def monoid_mult_class.power_add algebra_simps) + then have "x \ \ \ (\n. b n * (x - \)^n) sums (f x / (a m * (x - \)^m))" + using am by (simp add: sums_mult_D) + } note bsums = this + then have "norm (x - \) < r \ summable (\n. b n * (x - \)^n)" for x + using sums_summable by (cases "x=\") auto + then have "r \ conv_radius b" + by (simp add: le_conv_radius_iff [where \=\]) + then have "r/2 < conv_radius b" + using not_le order_trans r by fastforce + then have "continuous_on (cball \ (r/2)) g" + using powser_continuous_suminf [of "r/2" b \] by (simp add: g_def) + then obtain s where "s>0" "\x. \norm (x - \) \ s; norm (x - \) \ r/2\ \ dist (g x) (g \) < 1/2" + apply (rule continuous_onE [where x=\ and e = "1/2"]) + using r apply (auto simp: norm_minus_commute dist_norm) + done + moreover have "g \ = 1" + by (simp add: g_def) + ultimately have gnz: "\x. \norm (x - \) \ s; norm (x - \) \ r/2\ \ (g x) \ 0" + by fastforce + have "f x \ 0" if "x \ \" "norm (x - \) \ s" "norm (x - \) \ r/2" for x + using bsums [of x] that gnz [of x] + apply (auto simp: g_def) + using r sums_iff by fastforce + then show ?thesis + apply (rule_tac s="min s (r/2)" in that) + using \0 < r\ \0 < s\ by (auto simp: dist_commute dist_norm) +qed + +subsection \Complex functions and power series\ + +text \ + The following defines the power series expansion of a complex function at a given point + (assuming that it is analytic at that point). +\ +definition\<^marker>\tag important\ fps_expansion :: "(complex \ complex) \ complex \ complex fps" where + "fps_expansion f z0 = Abs_fps (\n. (deriv ^^ n) f z0 / fact n)" + +lemma + fixes r :: ereal + assumes "f holomorphic_on eball z0 r" + shows conv_radius_fps_expansion: "fps_conv_radius (fps_expansion f z0) \ r" + and eval_fps_expansion: "\z. z \ eball z0 r \ eval_fps (fps_expansion f z0) (z - z0) = f z" + and eval_fps_expansion': "\z. norm z < r \ eval_fps (fps_expansion f z0) z = f (z0 + z)" +proof - + have "(\n. fps_nth (fps_expansion f z0) n * (z - z0) ^ n) sums f z" + if "z \ ball z0 r'" "ereal r' < r" for z r' + proof - + from that(2) have "ereal r' \ r" by simp + from assms(1) and this have "f holomorphic_on ball z0 r'" + by (rule holomorphic_on_subset[OF _ ball_eball_mono]) + from holomorphic_power_series [OF this that(1)] + show ?thesis by (simp add: fps_expansion_def) + qed + hence *: "(\n. fps_nth (fps_expansion f z0) n * (z - z0) ^ n) sums f z" + if "z \ eball z0 r" for z + using that by (subst (asm) eball_conv_UNION_balls) blast + show "fps_conv_radius (fps_expansion f z0) \ r" unfolding fps_conv_radius_def + proof (rule conv_radius_geI_ex) + fix r' :: real assume r': "r' > 0" "ereal r' < r" + thus "\z. norm z = r' \ summable (\n. fps_nth (fps_expansion f z0) n * z ^ n)" + using *[of "z0 + of_real r'"] + by (intro exI[of _ "of_real r'"]) (auto simp: summable_def dist_norm) + qed + show "eval_fps (fps_expansion f z0) (z - z0) = f z" if "z \ eball z0 r" for z + using *[OF that] by (simp add: eval_fps_def sums_iff) + show "eval_fps (fps_expansion f z0) z = f (z0 + z)" if "ereal (norm z) < r" for z + using *[of "z0 + z"] and that by (simp add: eval_fps_def sums_iff dist_norm) +qed + + +text \ + We can now show several more facts about power series expansions (at least in the complex case) + with relative ease that would have been trickier without complex analysis. +\ +lemma + fixes f :: "complex fps" and r :: ereal + assumes "\z. ereal (norm z) < r \ eval_fps f z \ 0" + shows fps_conv_radius_inverse: "fps_conv_radius (inverse f) \ min r (fps_conv_radius f)" + and eval_fps_inverse: "\z. ereal (norm z) < fps_conv_radius f \ ereal (norm z) < r \ + eval_fps (inverse f) z = inverse (eval_fps f z)" +proof - + define R where "R = min (fps_conv_radius f) r" + have *: "fps_conv_radius (inverse f) \ min r (fps_conv_radius f) \ + (\z\eball 0 (min (fps_conv_radius f) r). eval_fps (inverse f) z = inverse (eval_fps f z))" + proof (cases "min r (fps_conv_radius f) > 0") + case True + define f' where "f' = fps_expansion (\z. inverse (eval_fps f z)) 0" + have holo: "(\z. inverse (eval_fps f z)) holomorphic_on eball 0 (min r (fps_conv_radius f))" + using assms by (intro holomorphic_intros) auto + from holo have radius: "fps_conv_radius f' \ min r (fps_conv_radius f)" + unfolding f'_def by (rule conv_radius_fps_expansion) + have eval_f': "eval_fps f' z = inverse (eval_fps f z)" + if "norm z < fps_conv_radius f" "norm z < r" for z + using that unfolding f'_def by (subst eval_fps_expansion'[OF holo]) auto + + have "f * f' = 1" + proof (rule eval_fps_eqD) + from radius and True have "0 < min (fps_conv_radius f) (fps_conv_radius f')" + by (auto simp: min_def split: if_splits) + also have "\ \ fps_conv_radius (f * f')" by (rule fps_conv_radius_mult) + finally show "\ > 0" . + next + from True have "R > 0" by (auto simp: R_def) + hence "eventually (\z. z \ eball 0 R) (nhds 0)" + by (intro eventually_nhds_in_open) (auto simp: zero_ereal_def) + thus "eventually (\z. eval_fps (f * f') z = eval_fps 1 z) (nhds 0)" + proof eventually_elim + case (elim z) + hence "eval_fps (f * f') z = eval_fps f z * eval_fps f' z" + using radius by (intro eval_fps_mult) + (auto simp: R_def min_def split: if_splits intro: less_trans) + also have "eval_fps f' z = inverse (eval_fps f z)" + using elim by (intro eval_f') (auto simp: R_def) + also from elim have "eval_fps f z \ 0" + by (intro assms) (auto simp: R_def) + hence "eval_fps f z * inverse (eval_fps f z) = eval_fps 1 z" + by simp + finally show "eval_fps (f * f') z = eval_fps 1 z" . + qed + qed simp_all + hence "f' = inverse f" + by (intro fps_inverse_unique [symmetric]) (simp_all add: mult_ac) + with eval_f' and radius show ?thesis by simp + next + case False + hence *: "eball 0 R = {}" + by (intro eball_empty) (auto simp: R_def min_def split: if_splits) + show ?thesis + proof safe + from False have "min r (fps_conv_radius f) \ 0" + by (simp add: min_def) + also have "0 \ fps_conv_radius (inverse f)" + by (simp add: fps_conv_radius_def conv_radius_nonneg) + finally show "min r (fps_conv_radius f) \ \" . + qed (unfold * [unfolded R_def], auto) + qed + + from * show "fps_conv_radius (inverse f) \ min r (fps_conv_radius f)" by blast + from * show "eval_fps (inverse f) z = inverse (eval_fps f z)" + if "ereal (norm z) < fps_conv_radius f" "ereal (norm z) < r" for z + using that by auto +qed + +lemma + fixes f g :: "complex fps" and r :: ereal + defines "R \ Min {r, fps_conv_radius f, fps_conv_radius g}" + assumes "fps_conv_radius f > 0" "fps_conv_radius g > 0" "r > 0" + assumes nz: "\z. z \ eball 0 r \ eval_fps g z \ 0" + shows fps_conv_radius_divide': "fps_conv_radius (f / g) \ R" + and eval_fps_divide': + "ereal (norm z) < R \ eval_fps (f / g) z = eval_fps f z / eval_fps g z" +proof - + from nz[of 0] and \r > 0\ have nz': "fps_nth g 0 \ 0" + by (auto simp: eval_fps_at_0 zero_ereal_def) + have "R \ min r (fps_conv_radius g)" + by (auto simp: R_def intro: min.coboundedI2) + also have "min r (fps_conv_radius g) \ fps_conv_radius (inverse g)" + by (intro fps_conv_radius_inverse assms) (auto simp: zero_ereal_def) + finally have radius: "fps_conv_radius (inverse g) \ R" . + have "R \ min (fps_conv_radius f) (fps_conv_radius (inverse g))" + by (intro radius min.boundedI) (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) + also have "\ \ fps_conv_radius (f * inverse g)" + by (rule fps_conv_radius_mult) + also have "f * inverse g = f / g" + by (intro fps_divide_unit [symmetric] nz') + finally show "fps_conv_radius (f / g) \ R" . + + assume z: "ereal (norm z) < R" + have "eval_fps (f * inverse g) z = eval_fps f z * eval_fps (inverse g) z" + using radius by (intro eval_fps_mult less_le_trans[OF z]) + (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) + also have "eval_fps (inverse g) z = inverse (eval_fps g z)" using \r > 0\ + by (intro eval_fps_inverse[where r = r] less_le_trans[OF z] nz) + (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) + also have "f * inverse g = f / g" by fact + finally show "eval_fps (f / g) z = eval_fps f z / eval_fps g z" by (simp add: field_split_simps) +qed + +lemma + fixes f g :: "complex fps" and r :: ereal + defines "R \ Min {r, fps_conv_radius f, fps_conv_radius g}" + assumes "subdegree g \ subdegree f" + assumes "fps_conv_radius f > 0" "fps_conv_radius g > 0" "r > 0" + assumes "\z. z \ eball 0 r \ z \ 0 \ eval_fps g z \ 0" + shows fps_conv_radius_divide: "fps_conv_radius (f / g) \ R" + and eval_fps_divide: + "ereal (norm z) < R \ c = fps_nth f (subdegree g) / fps_nth g (subdegree g) \ + eval_fps (f / g) z = (if z = 0 then c else eval_fps f z / eval_fps g z)" +proof - + define f' g' where "f' = fps_shift (subdegree g) f" and "g' = fps_shift (subdegree g) g" + have f_eq: "f = f' * fps_X ^ subdegree g" and g_eq: "g = g' * fps_X ^ subdegree g" + unfolding f'_def g'_def by (rule subdegree_decompose' le_refl | fact)+ + have subdegree: "subdegree f' = subdegree f - subdegree g" "subdegree g' = 0" + using assms(2) by (simp_all add: f'_def g'_def) + have [simp]: "fps_conv_radius f' = fps_conv_radius f" "fps_conv_radius g' = fps_conv_radius g" + by (simp_all add: f'_def g'_def) + have [simp]: "fps_nth f' 0 = fps_nth f (subdegree g)" + "fps_nth g' 0 = fps_nth g (subdegree g)" by (simp_all add: f'_def g'_def) + have g_nz: "g \ 0" + proof - + define z :: complex where "z = (if r = \ then 1 else of_real (real_of_ereal r / 2))" + from \r > 0\ have "z \ eball 0 r" + by (cases r) (auto simp: z_def eball_def) + moreover have "z \ 0" using \r > 0\ + by (cases r) (auto simp: z_def) + ultimately have "eval_fps g z \ 0" by (rule assms(6)) + thus "g \ 0" by auto + qed + have fg: "f / g = f' * inverse g'" + by (subst f_eq, subst (2) g_eq) (insert g_nz, simp add: fps_divide_unit) + + have g'_nz: "eval_fps g' z \ 0" if z: "norm z < min r (fps_conv_radius g)" for z + proof (cases "z = 0") + case False + with assms and z have "eval_fps g z \ 0" by auto + also from z have "eval_fps g z = eval_fps g' z * z ^ subdegree g" + by (subst g_eq) (auto simp: eval_fps_mult) + finally show ?thesis by auto + qed (insert \g \ 0\, auto simp: g'_def eval_fps_at_0) + + have "R \ min (min r (fps_conv_radius g)) (fps_conv_radius g')" + by (auto simp: R_def min.coboundedI1 min.coboundedI2) + also have "\ \ fps_conv_radius (inverse g')" + using g'_nz by (rule fps_conv_radius_inverse) + finally have conv_radius_inv: "R \ fps_conv_radius (inverse g')" . + hence "R \ fps_conv_radius (f' * inverse g')" + by (intro order.trans[OF _ fps_conv_radius_mult]) + (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) + thus "fps_conv_radius (f / g) \ R" by (simp add: fg) + + fix z c :: complex assume z: "ereal (norm z) < R" + assume c: "c = fps_nth f (subdegree g) / fps_nth g (subdegree g)" + show "eval_fps (f / g) z = (if z = 0 then c else eval_fps f z / eval_fps g z)" + proof (cases "z = 0") + case False + from z and conv_radius_inv have "ereal (norm z) < fps_conv_radius (inverse g')" + by simp + with z have "eval_fps (f / g) z = eval_fps f' z * eval_fps (inverse g') z" + unfolding fg by (subst eval_fps_mult) (auto simp: R_def) + also have "eval_fps (inverse g') z = inverse (eval_fps g' z)" + using z by (intro eval_fps_inverse[of "min r (fps_conv_radius g')"] g'_nz) (auto simp: R_def) + also have "eval_fps f' z * \ = eval_fps f z / eval_fps g z" + using z False assms(2) by (simp add: f'_def g'_def eval_fps_shift R_def) + finally show ?thesis using False by simp + qed (simp_all add: eval_fps_at_0 fg field_simps c) +qed + +lemma has_fps_expansion_fps_expansion [intro]: + assumes "open A" "0 \ A" "f holomorphic_on A" + shows "f has_fps_expansion fps_expansion f 0" +proof - + from assms(1,2) obtain r where r: "r > 0 " "ball 0 r \ A" + by (auto simp: open_contains_ball) + have holo: "f holomorphic_on eball 0 (ereal r)" + using r(2) and assms(3) by auto + from r(1) have "0 < ereal r" by simp + also have "r \ fps_conv_radius (fps_expansion f 0)" + using holo by (intro conv_radius_fps_expansion) auto + finally have "\ > 0" . + moreover have "eventually (\z. z \ ball 0 r) (nhds 0)" + using r(1) by (intro eventually_nhds_in_open) auto + hence "eventually (\z. eval_fps (fps_expansion f 0) z = f z) (nhds 0)" + by eventually_elim (subst eval_fps_expansion'[OF holo], auto) + ultimately show ?thesis using r(1) by (auto simp: has_fps_expansion_def) +qed + +lemma fps_conv_radius_tan: + fixes c :: complex + assumes "c \ 0" + shows "fps_conv_radius (fps_tan c) \ pi / (2 * norm c)" +proof - + have "fps_conv_radius (fps_tan c) \ + Min {pi / (2 * norm c), fps_conv_radius (fps_sin c), fps_conv_radius (fps_cos c)}" + unfolding fps_tan_def + proof (rule fps_conv_radius_divide) + fix z :: complex assume "z \ eball 0 (pi / (2 * norm c))" + with cos_eq_zero_imp_norm_ge[of "c*z"] assms + show "eval_fps (fps_cos c) z \ 0" by (auto simp: norm_mult field_simps) + qed (insert assms, auto) + thus ?thesis by (simp add: min_def) +qed + +lemma eval_fps_tan: + fixes c :: complex + assumes "norm z < pi / (2 * norm c)" + shows "eval_fps (fps_tan c) z = tan (c * z)" +proof (cases "c = 0") + case False + show ?thesis unfolding fps_tan_def + proof (subst eval_fps_divide'[where r = "pi / (2 * norm c)"]) + fix z :: complex assume "z \ eball 0 (pi / (2 * norm c))" + with cos_eq_zero_imp_norm_ge[of "c*z"] assms + show "eval_fps (fps_cos c) z \ 0" using False by (auto simp: norm_mult field_simps) + qed (insert False assms, auto simp: field_simps tan_def) + qed simp_all + +end diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Cauchy_Integral_Theorem.thy --- a/src/HOL/Complex_Analysis/Cauchy_Integral_Theorem.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Cauchy_Integral_Theorem.thy Mon Dec 02 17:51:54 2019 +0100 @@ -5,6 +5,7 @@ theory Cauchy_Integral_Theorem imports "HOL-Analysis.Analysis" + Contour_Integration begin lemma leibniz_rule_holomorphic: @@ -38,1005 +39,6 @@ shows "(\x. f x powr g x :: complex) \ measurable M borel" using assms by (simp add: powr_def) -subsection\Contour Integrals along a path\ - -text\This definition is for complex numbers only, and does not generalise to line integrals in a vector field\ - -text\piecewise differentiable function on [0,1]\ - -definition\<^marker>\tag important\ has_contour_integral :: "(complex \ complex) \ complex \ (real \ complex) \ bool" - (infixr "has'_contour'_integral" 50) - where "(f has_contour_integral i) g \ - ((\x. f(g x) * vector_derivative g (at x within {0..1})) - has_integral i) {0..1}" - -definition\<^marker>\tag important\ contour_integrable_on - (infixr "contour'_integrable'_on" 50) - where "f contour_integrable_on g \ \i. (f has_contour_integral i) g" - -definition\<^marker>\tag important\ contour_integral - where "contour_integral g f \ SOME i. (f has_contour_integral i) g \ \ f contour_integrable_on g \ i=0" - -lemma not_integrable_contour_integral: "\ f contour_integrable_on g \ contour_integral g f = 0" - unfolding contour_integrable_on_def contour_integral_def by blast - -lemma contour_integral_unique: "(f has_contour_integral i) g \ contour_integral g f = i" - apply (simp add: contour_integral_def has_contour_integral_def contour_integrable_on_def) - using has_integral_unique by blast - -lemma has_contour_integral_eqpath: - "\(f has_contour_integral y) p; f contour_integrable_on \; - contour_integral p f = contour_integral \ f\ - \ (f has_contour_integral y) \" -using contour_integrable_on_def contour_integral_unique by auto - -lemma has_contour_integral_integral: - "f contour_integrable_on i \ (f has_contour_integral (contour_integral i f)) i" - by (metis contour_integral_unique contour_integrable_on_def) - -lemma has_contour_integral_unique: - "(f has_contour_integral i) g \ (f has_contour_integral j) g \ i = j" - using has_integral_unique - by (auto simp: has_contour_integral_def) - -lemma has_contour_integral_integrable: "(f has_contour_integral i) g \ f contour_integrable_on g" - using contour_integrable_on_def by blast - -text\Show that we can forget about the localized derivative.\ - -lemma has_integral_localized_vector_derivative: - "((\x. f (g x) * vector_derivative g (at x within {a..b})) has_integral i) {a..b} \ - ((\x. f (g x) * vector_derivative g (at x)) has_integral i) {a..b}" -proof - - have *: "{a..b} - {a,b} = interior {a..b}" - by (simp add: atLeastAtMost_diff_ends) - show ?thesis - apply (rule has_integral_spike_eq [of "{a,b}"]) - apply (auto simp: at_within_interior [of _ "{a..b}"]) - done -qed - -lemma integrable_on_localized_vector_derivative: - "(\x. f (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b} \ - (\x. f (g x) * vector_derivative g (at x)) integrable_on {a..b}" - by (simp add: integrable_on_def has_integral_localized_vector_derivative) - -lemma has_contour_integral: - "(f has_contour_integral i) g \ - ((\x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}" - by (simp add: has_integral_localized_vector_derivative has_contour_integral_def) - -lemma contour_integrable_on: - "f contour_integrable_on g \ - (\t. f(g t) * vector_derivative g (at t)) integrable_on {0..1}" - by (simp add: has_contour_integral integrable_on_def contour_integrable_on_def) - -subsection\<^marker>\tag unimportant\ \Reversing a path\ - - - -lemma has_contour_integral_reversepath: - assumes "valid_path g" and f: "(f has_contour_integral i) g" - shows "(f has_contour_integral (-i)) (reversepath g)" -proof - - { fix S x - assume xs: "g C1_differentiable_on ({0..1} - S)" "x \ (-) 1 ` S" "0 \ x" "x \ 1" - have "vector_derivative (\x. g (1 - x)) (at x within {0..1}) = - - vector_derivative g (at (1 - x) within {0..1})" - proof - - obtain f' where f': "(g has_vector_derivative f') (at (1 - x))" - using xs - by (force simp: has_vector_derivative_def C1_differentiable_on_def) - have "(g \ (\x. 1 - x) has_vector_derivative -1 *\<^sub>R f') (at x)" - by (intro vector_diff_chain_within has_vector_derivative_at_within [OF f'] derivative_eq_intros | simp)+ - then have mf': "((\x. g (1 - x)) has_vector_derivative -f') (at x)" - by (simp add: o_def) - show ?thesis - using xs - by (auto simp: vector_derivative_at_within_ivl [OF mf'] vector_derivative_at_within_ivl [OF f']) - qed - } note * = this - obtain S where S: "continuous_on {0..1} g" "finite S" "g C1_differentiable_on {0..1} - S" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) - have "((\x. - (f (g (1 - x)) * vector_derivative g (at (1 - x) within {0..1}))) has_integral -i) - {0..1}" - using has_integral_affinity01 [where m= "-1" and c=1, OF f [unfolded has_contour_integral_def]] - by (simp add: has_integral_neg) - then show ?thesis - using S - apply (clarsimp simp: reversepath_def has_contour_integral_def) - apply (rule_tac S = "(\x. 1 - x) ` S" in has_integral_spike_finite) - apply (auto simp: *) - done -qed - -lemma contour_integrable_reversepath: - "valid_path g \ f contour_integrable_on g \ f contour_integrable_on (reversepath g)" - using has_contour_integral_reversepath contour_integrable_on_def by blast - -lemma contour_integrable_reversepath_eq: - "valid_path g \ (f contour_integrable_on (reversepath g) \ f contour_integrable_on g)" - using contour_integrable_reversepath valid_path_reversepath by fastforce - -lemma contour_integral_reversepath: - assumes "valid_path g" - shows "contour_integral (reversepath g) f = - (contour_integral g f)" -proof (cases "f contour_integrable_on g") - case True then show ?thesis - by (simp add: assms contour_integral_unique has_contour_integral_integral has_contour_integral_reversepath) -next - case False then have "\ f contour_integrable_on (reversepath g)" - by (simp add: assms contour_integrable_reversepath_eq) - with False show ?thesis by (simp add: not_integrable_contour_integral) -qed - - -subsection\<^marker>\tag unimportant\ \Joining two paths together\ - -lemma has_contour_integral_join: - assumes "(f has_contour_integral i1) g1" "(f has_contour_integral i2) g2" - "valid_path g1" "valid_path g2" - shows "(f has_contour_integral (i1 + i2)) (g1 +++ g2)" -proof - - obtain s1 s2 - where s1: "finite s1" "\x\{0..1} - s1. g1 differentiable at x" - and s2: "finite s2" "\x\{0..1} - s2. g2 differentiable at x" - using assms - by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - have 1: "((\x. f (g1 x) * vector_derivative g1 (at x)) has_integral i1) {0..1}" - and 2: "((\x. f (g2 x) * vector_derivative g2 (at x)) has_integral i2) {0..1}" - using assms - by (auto simp: has_contour_integral) - have i1: "((\x. (2*f (g1 (2*x))) * vector_derivative g1 (at (2*x))) has_integral i1) {0..1/2}" - and i2: "((\x. (2*f (g2 (2*x - 1))) * vector_derivative g2 (at (2*x - 1))) has_integral i2) {1/2..1}" - using has_integral_affinity01 [OF 1, where m= 2 and c=0, THEN has_integral_cmul [where c=2]] - has_integral_affinity01 [OF 2, where m= 2 and c="-1", THEN has_integral_cmul [where c=2]] - by (simp_all only: image_affinity_atLeastAtMost_div_diff, simp_all add: scaleR_conv_of_real mult_ac) - have g1: "\0 \ z; z*2 < 1; z*2 \ s1\ \ - vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at z) = - 2 *\<^sub>R vector_derivative g1 (at (z*2))" for z - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g1(2*x))" and d = "\z - 1/2\"]]) - apply (simp_all add: dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. 2*x" 2 _ g1, simplified o_def]) - apply (simp add: has_vector_derivative_def has_derivative_def bounded_linear_mult_left) - using s1 - apply (auto simp: algebra_simps vector_derivative_works) - done - have g2: "\1 < z*2; z \ 1; z*2 - 1 \ s2\ \ - vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at z) = - 2 *\<^sub>R vector_derivative g2 (at (z*2 - 1))" for z - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g2 (2*x - 1))" and d = "\z - 1/2\"]]) - apply (simp_all add: dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. 2*x - 1" 2 _ g2, simplified o_def]) - apply (simp add: has_vector_derivative_def has_derivative_def bounded_linear_mult_left) - using s2 - apply (auto simp: algebra_simps vector_derivative_works) - done - have "((\x. f ((g1 +++ g2) x) * vector_derivative (g1 +++ g2) (at x)) has_integral i1) {0..1/2}" - apply (rule has_integral_spike_finite [OF _ _ i1, of "insert (1/2) ((*)2 -` s1)"]) - using s1 - apply (force intro: finite_vimageI [where h = "(*)2"] inj_onI) - apply (clarsimp simp add: joinpaths_def scaleR_conv_of_real mult_ac g1) - done - moreover have "((\x. f ((g1 +++ g2) x) * vector_derivative (g1 +++ g2) (at x)) has_integral i2) {1/2..1}" - apply (rule has_integral_spike_finite [OF _ _ i2, of "insert (1/2) ((\x. 2*x-1) -` s2)"]) - using s2 - apply (force intro: finite_vimageI [where h = "\x. 2*x-1"] inj_onI) - apply (clarsimp simp add: joinpaths_def scaleR_conv_of_real mult_ac g2) - done - ultimately - show ?thesis - apply (simp add: has_contour_integral) - apply (rule has_integral_combine [where c = "1/2"], auto) - done -qed - -lemma contour_integrable_joinI: - assumes "f contour_integrable_on g1" "f contour_integrable_on g2" - "valid_path g1" "valid_path g2" - shows "f contour_integrable_on (g1 +++ g2)" - using assms - by (meson has_contour_integral_join contour_integrable_on_def) - -lemma contour_integrable_joinD1: - assumes "f contour_integrable_on (g1 +++ g2)" "valid_path g1" - shows "f contour_integrable_on g1" -proof - - obtain s1 - where s1: "finite s1" "\x\{0..1} - s1. g1 differentiable at x" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - have "(\x. f ((g1 +++ g2) (x/2)) * vector_derivative (g1 +++ g2) (at (x/2))) integrable_on {0..1}" - using assms - apply (auto simp: contour_integrable_on) - apply (drule integrable_on_subcbox [where a=0 and b="1/2"]) - apply (auto intro: integrable_affinity [of _ 0 "1/2::real" "1/2" 0, simplified]) - done - then have *: "(\x. (f ((g1 +++ g2) (x/2))/2) * vector_derivative (g1 +++ g2) (at (x/2))) integrable_on {0..1}" - by (auto dest: integrable_cmul [where c="1/2"] simp: scaleR_conv_of_real) - have g1: "\0 < z; z < 1; z \ s1\ \ - vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at (z/2)) = - 2 *\<^sub>R vector_derivative g1 (at z)" for z - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g1(2*x))" and d = "\(z-1)/2\"]]) - apply (simp_all add: field_simps dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. x*2" 2 _ g1, simplified o_def]) - using s1 - apply (auto simp: vector_derivative_works has_vector_derivative_def has_derivative_def bounded_linear_mult_left) - done - show ?thesis - using s1 - apply (auto simp: contour_integrable_on) - apply (rule integrable_spike_finite [of "{0,1} \ s1", OF _ _ *]) - apply (auto simp: joinpaths_def scaleR_conv_of_real g1) - done -qed - -lemma contour_integrable_joinD2: - assumes "f contour_integrable_on (g1 +++ g2)" "valid_path g2" - shows "f contour_integrable_on g2" -proof - - obtain s2 - where s2: "finite s2" "\x\{0..1} - s2. g2 differentiable at x" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - have "(\x. f ((g1 +++ g2) (x/2 + 1/2)) * vector_derivative (g1 +++ g2) (at (x/2 + 1/2))) integrable_on {0..1}" - using assms - apply (auto simp: contour_integrable_on) - apply (drule integrable_on_subcbox [where a="1/2" and b=1], auto) - apply (drule integrable_affinity [of _ "1/2::real" 1 "1/2" "1/2", simplified]) - apply (simp add: image_affinity_atLeastAtMost_diff) - done - then have *: "(\x. (f ((g1 +++ g2) (x/2 + 1/2))/2) * vector_derivative (g1 +++ g2) (at (x/2 + 1/2))) - integrable_on {0..1}" - by (auto dest: integrable_cmul [where c="1/2"] simp: scaleR_conv_of_real) - have g2: "\0 < z; z < 1; z \ s2\ \ - vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at (z/2+1/2)) = - 2 *\<^sub>R vector_derivative g2 (at z)" for z - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g2(2*x-1))" and d = "\z/2\"]]) - apply (simp_all add: field_simps dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. x*2-1" 2 _ g2, simplified o_def]) - using s2 - apply (auto simp: has_vector_derivative_def has_derivative_def bounded_linear_mult_left - vector_derivative_works add_divide_distrib) - done - show ?thesis - using s2 - apply (auto simp: contour_integrable_on) - apply (rule integrable_spike_finite [of "{0,1} \ s2", OF _ _ *]) - apply (auto simp: joinpaths_def scaleR_conv_of_real g2) - done -qed - -lemma contour_integrable_join [simp]: - shows - "\valid_path g1; valid_path g2\ - \ f contour_integrable_on (g1 +++ g2) \ f contour_integrable_on g1 \ f contour_integrable_on g2" -using contour_integrable_joinD1 contour_integrable_joinD2 contour_integrable_joinI by blast - -lemma contour_integral_join [simp]: - shows - "\f contour_integrable_on g1; f contour_integrable_on g2; valid_path g1; valid_path g2\ - \ contour_integral (g1 +++ g2) f = contour_integral g1 f + contour_integral g2 f" - by (simp add: has_contour_integral_integral has_contour_integral_join contour_integral_unique) - - -subsection\<^marker>\tag unimportant\ \Shifting the starting point of a (closed) path\ - -lemma has_contour_integral_shiftpath: - assumes f: "(f has_contour_integral i) g" "valid_path g" - and a: "a \ {0..1}" - shows "(f has_contour_integral i) (shiftpath a g)" -proof - - obtain s - where s: "finite s" and g: "\x\{0..1} - s. g differentiable at x" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - have *: "((\x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}" - using assms by (auto simp: has_contour_integral) - then have i: "i = integral {a..1} (\x. f (g x) * vector_derivative g (at x)) + - integral {0..a} (\x. f (g x) * vector_derivative g (at x))" - apply (rule has_integral_unique) - apply (subst add.commute) - apply (subst Henstock_Kurzweil_Integration.integral_combine) - using assms * integral_unique by auto - { fix x - have "0 \ x \ x + a < 1 \ x \ (\x. x - a) ` s \ - vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))" - unfolding shiftpath_def - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g(a+x))" and d = "dist(1-a) x"]]) - apply (auto simp: field_simps dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. x+a" 1 _ g, simplified o_def scaleR_one]) - apply (intro derivative_eq_intros | simp)+ - using g - apply (drule_tac x="x+a" in bspec) - using a apply (auto simp: has_vector_derivative_def vector_derivative_works image_def add.commute) - done - } note vd1 = this - { fix x - have "1 < x + a \ x \ 1 \ x \ (\x. x - a + 1) ` s \ - vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a - 1))" - unfolding shiftpath_def - apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g(a+x-1))" and d = "dist (1-a) x"]]) - apply (auto simp: field_simps dist_real_def abs_if split: if_split_asm) - apply (rule vector_diff_chain_at [of "\x. x+a-1" 1 _ g, simplified o_def scaleR_one]) - apply (intro derivative_eq_intros | simp)+ - using g - apply (drule_tac x="x+a-1" in bspec) - using a apply (auto simp: has_vector_derivative_def vector_derivative_works image_def add.commute) - done - } note vd2 = this - have va1: "(\x. f (g x) * vector_derivative g (at x)) integrable_on ({a..1})" - using * a by (fastforce intro: integrable_subinterval_real) - have v0a: "(\x. f (g x) * vector_derivative g (at x)) integrable_on ({0..a})" - apply (rule integrable_subinterval_real) - using * a by auto - have "((\x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) - has_integral integral {a..1} (\x. f (g x) * vector_derivative g (at x))) {0..1 - a}" - apply (rule has_integral_spike_finite - [where S = "{1-a} \ (\x. x-a) ` s" and f = "\x. f(g(a+x)) * vector_derivative g (at(a+x))"]) - using s apply blast - using a apply (auto simp: algebra_simps vd1) - apply (force simp: shiftpath_def add.commute) - using has_integral_affinity [where m=1 and c=a, simplified, OF integrable_integral [OF va1]] - apply (simp add: image_affinity_atLeastAtMost_diff [where m=1 and c=a, simplified] add.commute) - done - moreover - have "((\x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) - has_integral integral {0..a} (\x. f (g x) * vector_derivative g (at x))) {1 - a..1}" - apply (rule has_integral_spike_finite - [where S = "{1-a} \ (\x. x-a+1) ` s" and f = "\x. f(g(a+x-1)) * vector_derivative g (at(a+x-1))"]) - using s apply blast - using a apply (auto simp: algebra_simps vd2) - apply (force simp: shiftpath_def add.commute) - using has_integral_affinity [where m=1 and c="a-1", simplified, OF integrable_integral [OF v0a]] - apply (simp add: image_affinity_atLeastAtMost [where m=1 and c="1-a", simplified]) - apply (simp add: algebra_simps) - done - ultimately show ?thesis - using a - by (auto simp: i has_contour_integral intro: has_integral_combine [where c = "1-a"]) -qed - -lemma has_contour_integral_shiftpath_D: - assumes "(f has_contour_integral i) (shiftpath a g)" - "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" - shows "(f has_contour_integral i) g" -proof - - obtain s - where s: "finite s" and g: "\x\{0..1} - s. g differentiable at x" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - { fix x - assume x: "0 < x" "x < 1" "x \ s" - then have gx: "g differentiable at x" - using g by auto - have "vector_derivative g (at x within {0..1}) = - vector_derivative (shiftpath (1 - a) (shiftpath a g)) (at x within {0..1})" - apply (rule vector_derivative_at_within_ivl - [OF has_vector_derivative_transform_within_open - [where f = "(shiftpath (1 - a) (shiftpath a g))" and S = "{0<..<1}-s"]]) - using s g assms x - apply (auto simp: finite_imp_closed open_Diff shiftpath_shiftpath - at_within_interior [of _ "{0..1}"] vector_derivative_works [symmetric]) - apply (rule differentiable_transform_within [OF gx, of "min x (1-x)"]) - apply (auto simp: dist_real_def shiftpath_shiftpath abs_if split: if_split_asm) - done - } note vd = this - have fi: "(f has_contour_integral i) (shiftpath (1 - a) (shiftpath a g))" - using assms by (auto intro!: has_contour_integral_shiftpath) - show ?thesis - apply (simp add: has_contour_integral_def) - apply (rule has_integral_spike_finite [of "{0,1} \ s", OF _ _ fi [unfolded has_contour_integral_def]]) - using s assms vd - apply (auto simp: Path_Connected.shiftpath_shiftpath) - done -qed - -lemma has_contour_integral_shiftpath_eq: - assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" - shows "(f has_contour_integral i) (shiftpath a g) \ (f has_contour_integral i) g" - using assms has_contour_integral_shiftpath has_contour_integral_shiftpath_D by blast - -lemma contour_integrable_on_shiftpath_eq: - assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" - shows "f contour_integrable_on (shiftpath a g) \ f contour_integrable_on g" -using assms contour_integrable_on_def has_contour_integral_shiftpath_eq by auto - -lemma contour_integral_shiftpath: - assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" - shows "contour_integral (shiftpath a g) f = contour_integral g f" - using assms - by (simp add: contour_integral_def contour_integrable_on_def has_contour_integral_shiftpath_eq) - - -subsection\<^marker>\tag unimportant\ \More about straight-line paths\ - -lemma has_contour_integral_linepath: - shows "(f has_contour_integral i) (linepath a b) \ - ((\x. f(linepath a b x) * (b - a)) has_integral i) {0..1}" - by (simp add: has_contour_integral) - -lemma has_contour_integral_trivial [iff]: "(f has_contour_integral 0) (linepath a a)" - by (simp add: has_contour_integral_linepath) - -lemma has_contour_integral_trivial_iff [simp]: "(f has_contour_integral i) (linepath a a) \ i=0" - using has_contour_integral_unique by blast - -lemma contour_integral_trivial [simp]: "contour_integral (linepath a a) f = 0" - using has_contour_integral_trivial contour_integral_unique by blast - - -subsection\Relation to subpath construction\ - -lemma has_contour_integral_subpath_refl [iff]: "(f has_contour_integral 0) (subpath u u g)" - by (simp add: has_contour_integral subpath_def) - -lemma contour_integrable_subpath_refl [iff]: "f contour_integrable_on (subpath u u g)" - using has_contour_integral_subpath_refl contour_integrable_on_def by blast - -lemma contour_integral_subpath_refl [simp]: "contour_integral (subpath u u g) f = 0" - by (simp add: contour_integral_unique) - -lemma has_contour_integral_subpath: - assumes f: "f contour_integrable_on g" and g: "valid_path g" - and uv: "u \ {0..1}" "v \ {0..1}" "u \ v" - shows "(f has_contour_integral integral {u..v} (\x. f(g x) * vector_derivative g (at x))) - (subpath u v g)" -proof (cases "v=u") - case True - then show ?thesis - using f by (simp add: contour_integrable_on_def subpath_def has_contour_integral) -next - case False - obtain s where s: "\x. x \ {0..1} - s \ g differentiable at x" and fs: "finite s" - using g unfolding piecewise_C1_differentiable_on_def C1_differentiable_on_eq valid_path_def by blast - have *: "((\x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) - has_integral (1 / (v - u)) * integral {u..v} (\t. f (g t) * vector_derivative g (at t))) - {0..1}" - using f uv - apply (simp add: contour_integrable_on subpath_def has_contour_integral) - apply (drule integrable_on_subcbox [where a=u and b=v, simplified]) - apply (simp_all add: has_integral_integral) - apply (drule has_integral_affinity [where m="v-u" and c=u, simplified]) - apply (simp_all add: False image_affinity_atLeastAtMost_div_diff scaleR_conv_of_real) - apply (simp add: divide_simps False) - done - { fix x - have "x \ {0..1} \ - x \ (\t. (v-u) *\<^sub>R t + u) -` s \ - vector_derivative (\x. g ((v-u) * x + u)) (at x) = (v-u) *\<^sub>R vector_derivative g (at ((v-u) * x + u))" - apply (rule vector_derivative_at [OF vector_diff_chain_at [simplified o_def]]) - apply (intro derivative_eq_intros | simp)+ - apply (cut_tac s [of "(v - u) * x + u"]) - using uv mult_left_le [of x "v-u"] - apply (auto simp: vector_derivative_works) - done - } note vd = this - show ?thesis - apply (cut_tac has_integral_cmul [OF *, where c = "v-u"]) - using fs assms - apply (simp add: False subpath_def has_contour_integral) - apply (rule_tac S = "(\t. ((v-u) *\<^sub>R t + u)) -` s" in has_integral_spike_finite) - apply (auto simp: inj_on_def False finite_vimageI vd scaleR_conv_of_real) - done -qed - -lemma contour_integrable_subpath: - assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" - shows "f contour_integrable_on (subpath u v g)" - apply (cases u v rule: linorder_class.le_cases) - apply (metis contour_integrable_on_def has_contour_integral_subpath [OF assms]) - apply (subst reversepath_subpath [symmetric]) - apply (rule contour_integrable_reversepath) - using assms apply (blast intro: valid_path_subpath) - apply (simp add: contour_integrable_on_def) - using assms apply (blast intro: has_contour_integral_subpath) - done - -lemma has_integral_contour_integral_subpath: - assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "u \ v" - shows "(((\x. f(g x) * vector_derivative g (at x))) - has_integral contour_integral (subpath u v g) f) {u..v}" - using assms - apply (auto simp: has_integral_integrable_integral) - apply (rule integrable_on_subcbox [where a=u and b=v and S = "{0..1}", simplified]) - apply (auto simp: contour_integral_unique [OF has_contour_integral_subpath] contour_integrable_on) - done - -lemma contour_integral_subcontour_integral: - assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "u \ v" - shows "contour_integral (subpath u v g) f = - integral {u..v} (\x. f(g x) * vector_derivative g (at x))" - using assms has_contour_integral_subpath contour_integral_unique by blast - -lemma contour_integral_subpath_combine_less: - assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "w \ {0..1}" - "u {0..1}" "v \ {0..1}" "w \ {0..1}" - shows "contour_integral (subpath u v g) f + contour_integral (subpath v w g) f = - contour_integral (subpath u w g) f" -proof (cases "u\v \ v\w \ u\w") - case True - have *: "subpath v u g = reversepath(subpath u v g) \ - subpath w u g = reversepath(subpath u w g) \ - subpath w v g = reversepath(subpath v w g)" - by (auto simp: reversepath_subpath) - have "u < v \ v < w \ - u < w \ w < v \ - v < u \ u < w \ - v < w \ w < u \ - w < u \ u < v \ - w < v \ v < u" - using True assms by linarith - with assms show ?thesis - using contour_integral_subpath_combine_less [of f g u v w] - contour_integral_subpath_combine_less [of f g u w v] - contour_integral_subpath_combine_less [of f g v u w] - contour_integral_subpath_combine_less [of f g v w u] - contour_integral_subpath_combine_less [of f g w u v] - contour_integral_subpath_combine_less [of f g w v u] - apply simp - apply (elim disjE) - apply (auto simp: * contour_integral_reversepath contour_integrable_subpath - valid_path_subpath algebra_simps) - done -next - case False - then show ?thesis - apply (auto) - using assms - by (metis eq_neg_iff_add_eq_0 contour_integral_reversepath reversepath_subpath valid_path_subpath) -qed - -lemma contour_integral_integral: - "contour_integral g f = integral {0..1} (\x. f (g x) * vector_derivative g (at x))" - by (simp add: contour_integral_def integral_def has_contour_integral contour_integrable_on) - -lemma contour_integral_cong: - assumes "g = g'" "\x. x \ path_image g \ f x = f' x" - shows "contour_integral g f = contour_integral g' f'" - unfolding contour_integral_integral using assms - by (intro integral_cong) (auto simp: path_image_def) - - -text \Contour integral along a segment on the real axis\ - -lemma has_contour_integral_linepath_Reals_iff: - fixes a b :: complex and f :: "complex \ complex" - assumes "a \ Reals" "b \ Reals" "Re a < Re b" - shows "(f has_contour_integral I) (linepath a b) \ - ((\x. f (of_real x)) has_integral I) {Re a..Re b}" -proof - - from assms have [simp]: "of_real (Re a) = a" "of_real (Re b) = b" - by (simp_all add: complex_eq_iff) - from assms have "a \ b" by auto - have "((\x. f (of_real x)) has_integral I) (cbox (Re a) (Re b)) \ - ((\x. f (a + b * of_real x - a * of_real x)) has_integral I /\<^sub>R (Re b - Re a)) {0..1}" - by (subst has_integral_affinity_iff [of "Re b - Re a" _ "Re a", symmetric]) - (insert assms, simp_all add: field_simps scaleR_conv_of_real) - also have "(\x. f (a + b * of_real x - a * of_real x)) = - (\x. (f (a + b * of_real x - a * of_real x) * (b - a)) /\<^sub>R (Re b - Re a))" - using \a \ b\ by (auto simp: field_simps fun_eq_iff scaleR_conv_of_real) - also have "(\ has_integral I /\<^sub>R (Re b - Re a)) {0..1} \ - ((\x. f (linepath a b x) * (b - a)) has_integral I) {0..1}" using assms - by (subst has_integral_cmul_iff) (auto simp: linepath_def scaleR_conv_of_real algebra_simps) - also have "\ \ (f has_contour_integral I) (linepath a b)" unfolding has_contour_integral_def - by (intro has_integral_cong) (simp add: vector_derivative_linepath_within) - finally show ?thesis by simp -qed - -lemma contour_integrable_linepath_Reals_iff: - fixes a b :: complex and f :: "complex \ complex" - assumes "a \ Reals" "b \ Reals" "Re a < Re b" - shows "(f contour_integrable_on linepath a b) \ - (\x. f (of_real x)) integrable_on {Re a..Re b}" - using has_contour_integral_linepath_Reals_iff[OF assms, of f] - by (auto simp: contour_integrable_on_def integrable_on_def) - -lemma contour_integral_linepath_Reals_eq: - fixes a b :: complex and f :: "complex \ complex" - assumes "a \ Reals" "b \ Reals" "Re a < Re b" - shows "contour_integral (linepath a b) f = integral {Re a..Re b} (\x. f (of_real x))" -proof (cases "f contour_integrable_on linepath a b") - case True - thus ?thesis using has_contour_integral_linepath_Reals_iff[OF assms, of f] - using has_contour_integral_integral has_contour_integral_unique by blast -next - case False - thus ?thesis using contour_integrable_linepath_Reals_iff[OF assms, of f] - by (simp add: not_integrable_contour_integral not_integrable_integral) -qed - - - -text\Cauchy's theorem where there's a primitive\ - -lemma contour_integral_primitive_lemma: - fixes f :: "complex \ complex" and g :: "real \ complex" - assumes "a \ b" - and "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" - and "g piecewise_differentiable_on {a..b}" "\x. x \ {a..b} \ g x \ s" - shows "((\x. f'(g x) * vector_derivative g (at x within {a..b})) - has_integral (f(g b) - f(g a))) {a..b}" -proof - - obtain k where k: "finite k" "\x\{a..b} - k. g differentiable (at x within {a..b})" and cg: "continuous_on {a..b} g" - using assms by (auto simp: piecewise_differentiable_on_def) - have cfg: "continuous_on {a..b} (\x. f (g x))" - apply (rule continuous_on_compose [OF cg, unfolded o_def]) - using assms - apply (metis field_differentiable_def field_differentiable_imp_continuous_at continuous_on_eq_continuous_within continuous_on_subset image_subset_iff) - done - { fix x::real - assume a: "a < x" and b: "x < b" and xk: "x \ k" - then have "g differentiable at x within {a..b}" - using k by (simp add: differentiable_at_withinI) - then have "(g has_vector_derivative vector_derivative g (at x within {a..b})) (at x within {a..b})" - by (simp add: vector_derivative_works has_field_derivative_def scaleR_conv_of_real) - then have gdiff: "(g has_derivative (\u. u * vector_derivative g (at x within {a..b}))) (at x within {a..b})" - by (simp add: has_vector_derivative_def scaleR_conv_of_real) - have "(f has_field_derivative (f' (g x))) (at (g x) within g ` {a..b})" - using assms by (metis a atLeastAtMost_iff b DERIV_subset image_subset_iff less_eq_real_def) - then have fdiff: "(f has_derivative (*) (f' (g x))) (at (g x) within g ` {a..b})" - by (simp add: has_field_derivative_def) - have "((\x. f (g x)) has_vector_derivative f' (g x) * vector_derivative g (at x within {a..b})) (at x within {a..b})" - using diff_chain_within [OF gdiff fdiff] - by (simp add: has_vector_derivative_def scaleR_conv_of_real o_def mult_ac) - } note * = this - show ?thesis - apply (rule fundamental_theorem_of_calculus_interior_strong) - using k assms cfg * - apply (auto simp: at_within_Icc_at) - done -qed - -lemma contour_integral_primitive: - assumes "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" - and "valid_path g" "path_image g \ s" - shows "(f' has_contour_integral (f(pathfinish g) - f(pathstart g))) g" - using assms - apply (simp add: valid_path_def path_image_def pathfinish_def pathstart_def has_contour_integral_def) - apply (auto intro!: piecewise_C1_imp_differentiable contour_integral_primitive_lemma [of 0 1 s]) - done - -corollary Cauchy_theorem_primitive: - assumes "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" - and "valid_path g" "path_image g \ s" "pathfinish g = pathstart g" - shows "(f' has_contour_integral 0) g" - using assms - by (metis diff_self contour_integral_primitive) - -text\Existence of path integral for continuous function\ -lemma contour_integrable_continuous_linepath: - assumes "continuous_on (closed_segment a b) f" - shows "f contour_integrable_on (linepath a b)" -proof - - have "continuous_on {0..1} ((\x. f x * (b - a)) \ linepath a b)" - apply (rule continuous_on_compose [OF continuous_on_linepath], simp add: linepath_image_01) - apply (rule continuous_intros | simp add: assms)+ - done - then show ?thesis - apply (simp add: contour_integrable_on_def has_contour_integral_def integrable_on_def [symmetric]) - apply (rule integrable_continuous [of 0 "1::real", simplified]) - apply (rule continuous_on_eq [where f = "\x. f(linepath a b x)*(b - a)"]) - apply (auto simp: vector_derivative_linepath_within) - done -qed - -lemma has_field_der_id: "((\x. x\<^sup>2 / 2) has_field_derivative x) (at x)" - by (rule has_derivative_imp_has_field_derivative) - (rule derivative_intros | simp)+ - -lemma contour_integral_id [simp]: "contour_integral (linepath a b) (\y. y) = (b^2 - a^2)/2" - apply (rule contour_integral_unique) - using contour_integral_primitive [of UNIV "\x. x^2/2" "\x. x" "linepath a b"] - apply (auto simp: field_simps has_field_der_id) - done - -lemma contour_integrable_on_const [iff]: "(\x. c) contour_integrable_on (linepath a b)" - by (simp add: contour_integrable_continuous_linepath) - -lemma contour_integrable_on_id [iff]: "(\x. x) contour_integrable_on (linepath a b)" - by (simp add: contour_integrable_continuous_linepath) - -subsection\<^marker>\tag unimportant\ \Arithmetical combining theorems\ - -lemma has_contour_integral_neg: - "(f has_contour_integral i) g \ ((\x. -(f x)) has_contour_integral (-i)) g" - by (simp add: has_integral_neg has_contour_integral_def) - -lemma has_contour_integral_add: - "\(f1 has_contour_integral i1) g; (f2 has_contour_integral i2) g\ - \ ((\x. f1 x + f2 x) has_contour_integral (i1 + i2)) g" - by (simp add: has_integral_add has_contour_integral_def algebra_simps) - -lemma has_contour_integral_diff: - "\(f1 has_contour_integral i1) g; (f2 has_contour_integral i2) g\ - \ ((\x. f1 x - f2 x) has_contour_integral (i1 - i2)) g" - by (simp add: has_integral_diff has_contour_integral_def algebra_simps) - -lemma has_contour_integral_lmul: - "(f has_contour_integral i) g \ ((\x. c * (f x)) has_contour_integral (c*i)) g" -apply (simp add: has_contour_integral_def) -apply (drule has_integral_mult_right) -apply (simp add: algebra_simps) -done - -lemma has_contour_integral_rmul: - "(f has_contour_integral i) g \ ((\x. (f x) * c) has_contour_integral (i*c)) g" -apply (drule has_contour_integral_lmul) -apply (simp add: mult.commute) -done - -lemma has_contour_integral_div: - "(f has_contour_integral i) g \ ((\x. f x/c) has_contour_integral (i/c)) g" - by (simp add: field_class.field_divide_inverse) (metis has_contour_integral_rmul) - -lemma has_contour_integral_eq: - "\(f has_contour_integral y) p; \x. x \ path_image p \ f x = g x\ \ (g has_contour_integral y) p" -apply (simp add: path_image_def has_contour_integral_def) -by (metis (no_types, lifting) image_eqI has_integral_eq) - -lemma has_contour_integral_bound_linepath: - assumes "(f has_contour_integral i) (linepath a b)" - "0 \ B" "\x. x \ closed_segment a b \ norm(f x) \ B" - shows "norm i \ B * norm(b - a)" -proof - - { fix x::real - assume x: "0 \ x" "x \ 1" - have "norm (f (linepath a b x)) * - norm (vector_derivative (linepath a b) (at x within {0..1})) \ B * norm (b - a)" - by (auto intro: mult_mono simp: assms linepath_in_path of_real_linepath vector_derivative_linepath_within x) - } note * = this - have "norm i \ (B * norm (b - a)) * content (cbox 0 (1::real))" - apply (rule has_integral_bound - [of _ "\x. f (linepath a b x) * vector_derivative (linepath a b) (at x within {0..1})"]) - using assms * unfolding has_contour_integral_def - apply (auto simp: norm_mult) - done - then show ?thesis - by (auto simp: content_real) -qed - -(*UNUSED -lemma has_contour_integral_bound_linepath_strong: - fixes a :: real and f :: "complex \ real" - assumes "(f has_contour_integral i) (linepath a b)" - "finite k" - "0 \ B" "\x::real. x \ closed_segment a b - k \ norm(f x) \ B" - shows "norm i \ B*norm(b - a)" -*) - -lemma has_contour_integral_const_linepath: "((\x. c) has_contour_integral c*(b - a))(linepath a b)" - unfolding has_contour_integral_linepath - by (metis content_real diff_0_right has_integral_const_real lambda_one of_real_1 scaleR_conv_of_real zero_le_one) - -lemma has_contour_integral_0: "((\x. 0) has_contour_integral 0) g" - by (simp add: has_contour_integral_def) - -lemma has_contour_integral_is_0: - "(\z. z \ path_image g \ f z = 0) \ (f has_contour_integral 0) g" - by (rule has_contour_integral_eq [OF has_contour_integral_0]) auto - -lemma has_contour_integral_sum: - "\finite s; \a. a \ s \ (f a has_contour_integral i a) p\ - \ ((\x. sum (\a. f a x) s) has_contour_integral sum i s) p" - by (induction s rule: finite_induct) (auto simp: has_contour_integral_0 has_contour_integral_add) - -subsection\<^marker>\tag unimportant\ \Operations on path integrals\ - -lemma contour_integral_const_linepath [simp]: "contour_integral (linepath a b) (\x. c) = c*(b - a)" - by (rule contour_integral_unique [OF has_contour_integral_const_linepath]) - -lemma contour_integral_neg: - "f contour_integrable_on g \ contour_integral g (\x. -(f x)) = -(contour_integral g f)" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_neg) - -lemma contour_integral_add: - "f1 contour_integrable_on g \ f2 contour_integrable_on g \ contour_integral g (\x. f1 x + f2 x) = - contour_integral g f1 + contour_integral g f2" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_add) - -lemma contour_integral_diff: - "f1 contour_integrable_on g \ f2 contour_integrable_on g \ contour_integral g (\x. f1 x - f2 x) = - contour_integral g f1 - contour_integral g f2" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_diff) - -lemma contour_integral_lmul: - shows "f contour_integrable_on g - \ contour_integral g (\x. c * f x) = c*contour_integral g f" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_lmul) - -lemma contour_integral_rmul: - shows "f contour_integrable_on g - \ contour_integral g (\x. f x * c) = contour_integral g f * c" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_rmul) - -lemma contour_integral_div: - shows "f contour_integrable_on g - \ contour_integral g (\x. f x / c) = contour_integral g f / c" - by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_div) - -lemma contour_integral_eq: - "(\x. x \ path_image p \ f x = g x) \ contour_integral p f = contour_integral p g" - apply (simp add: contour_integral_def) - using has_contour_integral_eq - by (metis contour_integral_unique has_contour_integral_integrable has_contour_integral_integral) - -lemma contour_integral_eq_0: - "(\z. z \ path_image g \ f z = 0) \ contour_integral g f = 0" - by (simp add: has_contour_integral_is_0 contour_integral_unique) - -lemma contour_integral_bound_linepath: - shows - "\f contour_integrable_on (linepath a b); - 0 \ B; \x. x \ closed_segment a b \ norm(f x) \ B\ - \ norm(contour_integral (linepath a b) f) \ B*norm(b - a)" - apply (rule has_contour_integral_bound_linepath [of f]) - apply (auto simp: has_contour_integral_integral) - done - -lemma contour_integral_0 [simp]: "contour_integral g (\x. 0) = 0" - by (simp add: contour_integral_unique has_contour_integral_0) - -lemma contour_integral_sum: - "\finite s; \a. a \ s \ (f a) contour_integrable_on p\ - \ contour_integral p (\x. sum (\a. f a x) s) = sum (\a. contour_integral p (f a)) s" - by (auto simp: contour_integral_unique has_contour_integral_sum has_contour_integral_integral) - -lemma contour_integrable_eq: - "\f contour_integrable_on p; \x. x \ path_image p \ f x = g x\ \ g contour_integrable_on p" - unfolding contour_integrable_on_def - by (metis has_contour_integral_eq) - - -subsection\<^marker>\tag unimportant\ \Arithmetic theorems for path integrability\ - -lemma contour_integrable_neg: - "f contour_integrable_on g \ (\x. -(f x)) contour_integrable_on g" - using has_contour_integral_neg contour_integrable_on_def by blast - -lemma contour_integrable_add: - "\f1 contour_integrable_on g; f2 contour_integrable_on g\ \ (\x. f1 x + f2 x) contour_integrable_on g" - using has_contour_integral_add contour_integrable_on_def - by fastforce - -lemma contour_integrable_diff: - "\f1 contour_integrable_on g; f2 contour_integrable_on g\ \ (\x. f1 x - f2 x) contour_integrable_on g" - using has_contour_integral_diff contour_integrable_on_def - by fastforce - -lemma contour_integrable_lmul: - "f contour_integrable_on g \ (\x. c * f x) contour_integrable_on g" - using has_contour_integral_lmul contour_integrable_on_def - by fastforce - -lemma contour_integrable_rmul: - "f contour_integrable_on g \ (\x. f x * c) contour_integrable_on g" - using has_contour_integral_rmul contour_integrable_on_def - by fastforce - -lemma contour_integrable_div: - "f contour_integrable_on g \ (\x. f x / c) contour_integrable_on g" - using has_contour_integral_div contour_integrable_on_def - by fastforce - -lemma contour_integrable_sum: - "\finite s; \a. a \ s \ (f a) contour_integrable_on p\ - \ (\x. sum (\a. f a x) s) contour_integrable_on p" - unfolding contour_integrable_on_def - by (metis has_contour_integral_sum) - - -subsection\<^marker>\tag unimportant\ \Reversing a path integral\ - -lemma has_contour_integral_reverse_linepath: - "(f has_contour_integral i) (linepath a b) - \ (f has_contour_integral (-i)) (linepath b a)" - using has_contour_integral_reversepath valid_path_linepath by fastforce - -lemma contour_integral_reverse_linepath: - "continuous_on (closed_segment a b) f - \ contour_integral (linepath a b) f = - (contour_integral(linepath b a) f)" -apply (rule contour_integral_unique) -apply (rule has_contour_integral_reverse_linepath) -by (simp add: closed_segment_commute contour_integrable_continuous_linepath has_contour_integral_integral) - - -(* Splitting a path integral in a flat way.*) - -lemma has_contour_integral_split: - assumes f: "(f has_contour_integral i) (linepath a c)" "(f has_contour_integral j) (linepath c b)" - and k: "0 \ k" "k \ 1" - and c: "c - a = k *\<^sub>R (b - a)" - shows "(f has_contour_integral (i + j)) (linepath a b)" -proof (cases "k = 0 \ k = 1") - case True - then show ?thesis - using assms by auto -next - case False - then have k: "0 < k" "k < 1" "complex_of_real k \ 1" - using assms by auto - have c': "c = k *\<^sub>R (b - a) + a" - by (metis diff_add_cancel c) - have bc: "(b - c) = (1 - k) *\<^sub>R (b - a)" - by (simp add: algebra_simps c') - { assume *: "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R c) * (c - a)) has_integral i) {0..1}" - have **: "\x. ((k - x) / k) *\<^sub>R a + (x / k) *\<^sub>R c = (1 - x) *\<^sub>R a + x *\<^sub>R b" - using False apply (simp add: c' algebra_simps) - apply (simp add: real_vector.scale_left_distrib [symmetric] field_split_simps) - done - have "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral i) {0..k}" - using k has_integral_affinity01 [OF *, of "inverse k" "0"] - apply (simp add: divide_simps mult.commute [of _ "k"] image_affinity_atLeastAtMost ** c) - apply (auto dest: has_integral_cmul [where c = "inverse k"]) - done - } note fi = this - { assume *: "((\x. f ((1 - x) *\<^sub>R c + x *\<^sub>R b) * (b - c)) has_integral j) {0..1}" - have **: "\x. (((1 - x) / (1 - k)) *\<^sub>R c + ((x - k) / (1 - k)) *\<^sub>R b) = ((1 - x) *\<^sub>R a + x *\<^sub>R b)" - using k - apply (simp add: c' field_simps) - apply (simp add: scaleR_conv_of_real divide_simps) - apply (simp add: field_simps) - done - have "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral j) {k..1}" - using k has_integral_affinity01 [OF *, of "inverse(1 - k)" "-(k/(1 - k))"] - apply (simp add: divide_simps mult.commute [of _ "1-k"] image_affinity_atLeastAtMost ** bc) - apply (auto dest: has_integral_cmul [where k = "(1 - k) *\<^sub>R j" and c = "inverse (1 - k)"]) - done - } note fj = this - show ?thesis - using f k - apply (simp add: has_contour_integral_linepath) - apply (simp add: linepath_def) - apply (rule has_integral_combine [OF _ _ fi fj], simp_all) - done -qed - -lemma continuous_on_closed_segment_transform: - assumes f: "continuous_on (closed_segment a b) f" - and k: "0 \ k" "k \ 1" - and c: "c - a = k *\<^sub>R (b - a)" - shows "continuous_on (closed_segment a c) f" -proof - - have c': "c = (1 - k) *\<^sub>R a + k *\<^sub>R b" - using c by (simp add: algebra_simps) - have "closed_segment a c \ closed_segment a b" - by (metis c' ends_in_segment(1) in_segment(1) k subset_closed_segment) - then show "continuous_on (closed_segment a c) f" - by (rule continuous_on_subset [OF f]) -qed - -lemma contour_integral_split: - assumes f: "continuous_on (closed_segment a b) f" - and k: "0 \ k" "k \ 1" - and c: "c - a = k *\<^sub>R (b - a)" - shows "contour_integral(linepath a b) f = contour_integral(linepath a c) f + contour_integral(linepath c b) f" -proof - - have c': "c = (1 - k) *\<^sub>R a + k *\<^sub>R b" - using c by (simp add: algebra_simps) - have "closed_segment a c \ closed_segment a b" - by (metis c' ends_in_segment(1) in_segment(1) k subset_closed_segment) - moreover have "closed_segment c b \ closed_segment a b" - by (metis c' ends_in_segment(2) in_segment(1) k subset_closed_segment) - ultimately - have *: "continuous_on (closed_segment a c) f" "continuous_on (closed_segment c b) f" - by (auto intro: continuous_on_subset [OF f]) - show ?thesis - by (rule contour_integral_unique) (meson "*" c contour_integrable_continuous_linepath has_contour_integral_integral has_contour_integral_split k) -qed - -lemma contour_integral_split_linepath: - assumes f: "continuous_on (closed_segment a b) f" - and c: "c \ closed_segment a b" - shows "contour_integral(linepath a b) f = contour_integral(linepath a c) f + contour_integral(linepath c b) f" - using c by (auto simp: closed_segment_def algebra_simps intro!: contour_integral_split [OF f]) - text\The special case of midpoints used in the main quadrisection\ lemma has_contour_integral_midpoint: @@ -1056,7 +58,6 @@ apply (auto simp: midpoint_def algebra_simps scaleR_conv_of_real) done - text\A couple of special case lemmas that are useful below\ lemma triangle_linear_has_chain_integral: @@ -1081,87 +82,6 @@ apply (simp add: valid_path_join) done -subsection\Reversing the order in a double path integral\ - -text\The condition is stronger than needed but it's often true in typical situations\ - -lemma fst_im_cbox [simp]: "cbox c d \ {} \ (fst ` cbox (a,c) (b,d)) = cbox a b" - by (auto simp: cbox_Pair_eq) - -lemma snd_im_cbox [simp]: "cbox a b \ {} \ (snd ` cbox (a,c) (b,d)) = cbox c d" - by (auto simp: cbox_Pair_eq) - -proposition contour_integral_swap: - assumes fcon: "continuous_on (path_image g \ path_image h) (\(y1,y2). f y1 y2)" - and vp: "valid_path g" "valid_path h" - and gvcon: "continuous_on {0..1} (\t. vector_derivative g (at t))" - and hvcon: "continuous_on {0..1} (\t. vector_derivative h (at t))" - shows "contour_integral g (\w. contour_integral h (f w)) = - contour_integral h (\z. contour_integral g (\w. f w z))" -proof - - have gcon: "continuous_on {0..1} g" and hcon: "continuous_on {0..1} h" - using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) - have fgh1: "\x. (\t. f (g x) (h t)) = (\(y1,y2). f y1 y2) \ (\t. (g x, h t))" - by (rule ext) simp - have fgh2: "\x. (\t. f (g t) (h x)) = (\(y1,y2). f y1 y2) \ (\t. (g t, h x))" - by (rule ext) simp - have fcon_im1: "\x. 0 \ x \ x \ 1 \ continuous_on ((\t. (g x, h t)) ` {0..1}) (\(x, y). f x y)" - by (rule continuous_on_subset [OF fcon]) (auto simp: path_image_def) - have fcon_im2: "\x. 0 \ x \ x \ 1 \ continuous_on ((\t. (g t, h x)) ` {0..1}) (\(x, y). f x y)" - by (rule continuous_on_subset [OF fcon]) (auto simp: path_image_def) - have "\y. y \ {0..1} \ continuous_on {0..1} (\x. f (g x) (h y))" - by (subst fgh2) (rule fcon_im2 gcon continuous_intros | simp)+ - then have vdg: "\y. y \ {0..1} \ (\x. f (g x) (h y) * vector_derivative g (at x)) integrable_on {0..1}" - using continuous_on_mult gvcon integrable_continuous_real by blast - have "(\z. vector_derivative g (at (fst z))) = (\x. vector_derivative g (at x)) \ fst" - by auto - then have gvcon': "continuous_on (cbox (0, 0) (1, 1::real)) (\x. vector_derivative g (at (fst x)))" - apply (rule ssubst) - apply (rule continuous_intros | simp add: gvcon)+ - done - have "(\z. vector_derivative h (at (snd z))) = (\x. vector_derivative h (at x)) \ snd" - by auto - then have hvcon': "continuous_on (cbox (0, 0) (1::real, 1)) (\x. vector_derivative h (at (snd x)))" - apply (rule ssubst) - apply (rule continuous_intros | simp add: hvcon)+ - done - have "(\x. f (g (fst x)) (h (snd x))) = (\(y1,y2). f y1 y2) \ (\w. ((g \ fst) w, (h \ snd) w))" - by auto - then have fgh: "continuous_on (cbox (0, 0) (1, 1)) (\x. f (g (fst x)) (h (snd x)))" - apply (rule ssubst) - apply (rule gcon hcon continuous_intros | simp)+ - apply (auto simp: path_image_def intro: continuous_on_subset [OF fcon]) - done - have "integral {0..1} (\x. contour_integral h (f (g x)) * vector_derivative g (at x)) = - integral {0..1} (\x. contour_integral h (\y. f (g x) y * vector_derivative g (at x)))" - proof (rule integral_cong [OF contour_integral_rmul [symmetric]]) - show "\x. x \ {0..1} \ f (g x) contour_integrable_on h" - unfolding contour_integrable_on - apply (rule integrable_continuous_real) - apply (rule continuous_on_mult [OF _ hvcon]) - apply (subst fgh1) - apply (rule fcon_im1 hcon continuous_intros | simp)+ - done - qed - also have "\ = integral {0..1} - (\y. contour_integral g (\x. f x (h y) * vector_derivative h (at y)))" - unfolding contour_integral_integral - apply (subst integral_swap_continuous [where 'a = real and 'b = real, of 0 0 1 1, simplified]) - apply (rule fgh gvcon' hvcon' continuous_intros | simp add: split_def)+ - unfolding integral_mult_left [symmetric] - apply (simp only: mult_ac) - done - also have "\ = contour_integral h (\z. contour_integral g (\w. f w z))" - unfolding contour_integral_integral - apply (rule integral_cong) - unfolding integral_mult_left [symmetric] - apply (simp add: algebra_simps) - done - finally show ?thesis - by (simp add: contour_integral_integral) -qed - - subsection\<^marker>\tag unimportant\ \The key quadrisection step\ lemma norm_sum_half: @@ -2431,21 +1351,6 @@ using contour_integral_nearby [OF assms, where atends=False] unfolding linked_paths_def by simp_all -lemma C1_differentiable_polynomial_function: - fixes p :: "real \ 'a::euclidean_space" - shows "polynomial_function p \ p C1_differentiable_on S" - by (metis continuous_on_polymonial_function C1_differentiable_on_def has_vector_derivative_polynomial_function) - -lemma valid_path_polynomial_function: - fixes p :: "real \ 'a::euclidean_space" - shows "polynomial_function p \ valid_path p" -by (force simp: valid_path_def piecewise_C1_differentiable_on_def continuous_on_polymonial_function C1_differentiable_polynomial_function) - -lemma valid_path_subpath_trivial [simp]: - fixes g :: "real \ 'a::euclidean_space" - shows "z \ g x \ valid_path (subpath x x g)" - by (simp add: subpath_def valid_path_polynomial_function) - lemma contour_integral_bound_exists: assumes S: "open S" and g: "valid_path g" @@ -2497,1188 +1402,6 @@ by (intro exI[of _ L]) auto qed -text\We can treat even non-rectifiable paths as having a "length" for bounds on analytic functions in open sets.\ - -subsection \Winding Numbers\ - -definition\<^marker>\tag important\ winding_number_prop :: "[real \ complex, complex, real, real \ complex, complex] \ bool" where - "winding_number_prop \ z e p n \ - valid_path p \ z \ path_image p \ - pathstart p = pathstart \ \ - pathfinish p = pathfinish \ \ - (\t \ {0..1}. norm(\ t - p t) < e) \ - contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" - -definition\<^marker>\tag important\ winding_number:: "[real \ complex, complex] \ complex" where - "winding_number \ z \ SOME n. \e > 0. \p. winding_number_prop \ z e p n" - - -lemma winding_number: - assumes "path \" "z \ path_image \" "0 < e" - shows "\p. winding_number_prop \ z e p (winding_number \ z)" -proof - - have "path_image \ \ UNIV - {z}" - using assms by blast - then obtain d - where d: "d>0" - and pi_eq: "\h1 h2. valid_path h1 \ valid_path h2 \ - (\t\{0..1}. cmod (h1 t - \ t) < d \ cmod (h2 t - \ t) < d) \ - pathstart h2 = pathstart h1 \ pathfinish h2 = pathfinish h1 \ - path_image h1 \ UNIV - {z} \ path_image h2 \ UNIV - {z} \ - (\f. f holomorphic_on UNIV - {z} \ contour_integral h2 f = contour_integral h1 f)" - using contour_integral_nearby_ends [of "UNIV - {z}" \] assms by (auto simp: open_delete) - then obtain h where h: "polynomial_function h \ pathstart h = pathstart \ \ pathfinish h = pathfinish \ \ - (\t \ {0..1}. norm(h t - \ t) < d/2)" - using path_approx_polynomial_function [OF \path \\, of "d/2"] d by auto - define nn where "nn = 1/(2* pi*\) * contour_integral h (\w. 1/(w - z))" - have "\n. \e > 0. \p. winding_number_prop \ z e p n" - proof (rule_tac x=nn in exI, clarify) - fix e::real - assume e: "e>0" - obtain p where p: "polynomial_function p \ - pathstart p = pathstart \ \ pathfinish p = pathfinish \ \ (\t\{0..1}. cmod (p t - \ t) < min e (d/2))" - using path_approx_polynomial_function [OF \path \\, of "min e (d/2)"] d \0 by auto - have "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" - by (auto simp: intro!: holomorphic_intros) - then show "\p. winding_number_prop \ z e p nn" - apply (rule_tac x=p in exI) - using pi_eq [of h p] h p d - apply (auto simp: valid_path_polynomial_function norm_minus_commute nn_def winding_number_prop_def) - done - qed - then show ?thesis - unfolding winding_number_def by (rule someI2_ex) (blast intro: \0) -qed - -lemma winding_number_unique: - assumes \: "path \" "z \ path_image \" - and pi: "\e. e>0 \ \p. winding_number_prop \ z e p n" - shows "winding_number \ z = n" -proof - - have "path_image \ \ UNIV - {z}" - using assms by blast - then obtain e - where e: "e>0" - and pi_eq: "\h1 h2 f. \valid_path h1; valid_path h2; - (\t\{0..1}. cmod (h1 t - \ t) < e \ cmod (h2 t - \ t) < e); - pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1; f holomorphic_on UNIV - {z}\ \ - contour_integral h2 f = contour_integral h1 f" - using contour_integral_nearby_ends [of "UNIV - {z}" \] assms by (auto simp: open_delete) - obtain p where p: "winding_number_prop \ z e p n" - using pi [OF e] by blast - obtain q where q: "winding_number_prop \ z e q (winding_number \ z)" - using winding_number [OF \ e] by blast - have "2 * complex_of_real pi * \ * n = contour_integral p (\w. 1 / (w - z))" - using p by (auto simp: winding_number_prop_def) - also have "\ = contour_integral q (\w. 1 / (w - z))" - proof (rule pi_eq) - show "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" - by (auto intro!: holomorphic_intros) - qed (use p q in \auto simp: winding_number_prop_def norm_minus_commute\) - also have "\ = 2 * complex_of_real pi * \ * winding_number \ z" - using q by (auto simp: winding_number_prop_def) - finally have "2 * complex_of_real pi * \ * n = 2 * complex_of_real pi * \ * winding_number \ z" . - then show ?thesis - by simp -qed - -(*NB not winding_number_prop here due to the loop in p*) -lemma winding_number_unique_loop: - assumes \: "path \" "z \ path_image \" - and loop: "pathfinish \ = pathstart \" - and pi: - "\e. e>0 \ \p. valid_path p \ z \ path_image p \ - pathfinish p = pathstart p \ - (\t \ {0..1}. norm (\ t - p t) < e) \ - contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" - shows "winding_number \ z = n" -proof - - have "path_image \ \ UNIV - {z}" - using assms by blast - then obtain e - where e: "e>0" - and pi_eq: "\h1 h2 f. \valid_path h1; valid_path h2; - (\t\{0..1}. cmod (h1 t - \ t) < e \ cmod (h2 t - \ t) < e); - pathfinish h1 = pathstart h1; pathfinish h2 = pathstart h2; f holomorphic_on UNIV - {z}\ \ - contour_integral h2 f = contour_integral h1 f" - using contour_integral_nearby_loops [of "UNIV - {z}" \] assms by (auto simp: open_delete) - obtain p where p: - "valid_path p \ z \ path_image p \ pathfinish p = pathstart p \ - (\t \ {0..1}. norm (\ t - p t) < e) \ - contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" - using pi [OF e] by blast - obtain q where q: "winding_number_prop \ z e q (winding_number \ z)" - using winding_number [OF \ e] by blast - have "2 * complex_of_real pi * \ * n = contour_integral p (\w. 1 / (w - z))" - using p by auto - also have "\ = contour_integral q (\w. 1 / (w - z))" - proof (rule pi_eq) - show "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" - by (auto intro!: holomorphic_intros) - qed (use p q loop in \auto simp: winding_number_prop_def norm_minus_commute\) - also have "\ = 2 * complex_of_real pi * \ * winding_number \ z" - using q by (auto simp: winding_number_prop_def) - finally have "2 * complex_of_real pi * \ * n = 2 * complex_of_real pi * \ * winding_number \ z" . - then show ?thesis - by simp -qed - -proposition winding_number_valid_path: - assumes "valid_path \" "z \ path_image \" - shows "winding_number \ z = 1/(2*pi*\) * contour_integral \ (\w. 1/(w - z))" - by (rule winding_number_unique) - (use assms in \auto simp: valid_path_imp_path winding_number_prop_def\) - -proposition has_contour_integral_winding_number: - assumes \: "valid_path \" "z \ path_image \" - shows "((\w. 1/(w - z)) has_contour_integral (2*pi*\*winding_number \ z)) \" -by (simp add: winding_number_valid_path has_contour_integral_integral contour_integrable_inversediff assms) - -lemma winding_number_trivial [simp]: "z \ a \ winding_number(linepath a a) z = 0" - by (simp add: winding_number_valid_path) - -lemma winding_number_subpath_trivial [simp]: "z \ g x \ winding_number (subpath x x g) z = 0" - by (simp add: path_image_subpath winding_number_valid_path) - -lemma winding_number_join: - assumes \1: "path \1" "z \ path_image \1" - and \2: "path \2" "z \ path_image \2" - and "pathfinish \1 = pathstart \2" - shows "winding_number(\1 +++ \2) z = winding_number \1 z + winding_number \2 z" -proof (rule winding_number_unique) - show "\p. winding_number_prop (\1 +++ \2) z e p - (winding_number \1 z + winding_number \2 z)" if "e > 0" for e - proof - - obtain p1 where "winding_number_prop \1 z e p1 (winding_number \1 z)" - using \0 < e\ \1 winding_number by blast - moreover - obtain p2 where "winding_number_prop \2 z e p2 (winding_number \2 z)" - using \0 < e\ \2 winding_number by blast - ultimately - have "winding_number_prop (\1+++\2) z e (p1+++p2) (winding_number \1 z + winding_number \2 z)" - using assms - apply (simp add: winding_number_prop_def not_in_path_image_join contour_integrable_inversediff algebra_simps) - apply (auto simp: joinpaths_def) - done - then show ?thesis - by blast - qed -qed (use assms in \auto simp: not_in_path_image_join\) - -lemma winding_number_reversepath: - assumes "path \" "z \ path_image \" - shows "winding_number(reversepath \) z = - (winding_number \ z)" -proof (rule winding_number_unique) - show "\p. winding_number_prop (reversepath \) z e p (- winding_number \ z)" if "e > 0" for e - proof - - obtain p where "winding_number_prop \ z e p (winding_number \ z)" - using \0 < e\ assms winding_number by blast - then have "winding_number_prop (reversepath \) z e (reversepath p) (- winding_number \ z)" - using assms - apply (simp add: winding_number_prop_def contour_integral_reversepath contour_integrable_inversediff valid_path_imp_reverse) - apply (auto simp: reversepath_def) - done - then show ?thesis - by blast - qed -qed (use assms in auto) - -lemma winding_number_shiftpath: - assumes \: "path \" "z \ path_image \" - and "pathfinish \ = pathstart \" "a \ {0..1}" - shows "winding_number(shiftpath a \) z = winding_number \ z" -proof (rule winding_number_unique_loop) - show "\p. valid_path p \ z \ path_image p \ pathfinish p = pathstart p \ - (\t\{0..1}. cmod (shiftpath a \ t - p t) < e) \ - contour_integral p (\w. 1 / (w - z)) = - complex_of_real (2 * pi) * \ * winding_number \ z" - if "e > 0" for e - proof - - obtain p where "winding_number_prop \ z e p (winding_number \ z)" - using \0 < e\ assms winding_number by blast - then show ?thesis - apply (rule_tac x="shiftpath a p" in exI) - using assms that - apply (auto simp: winding_number_prop_def path_image_shiftpath pathfinish_shiftpath pathstart_shiftpath contour_integral_shiftpath) - apply (simp add: shiftpath_def) - done - qed -qed (use assms in \auto simp: path_shiftpath path_image_shiftpath pathfinish_shiftpath pathstart_shiftpath\) - -lemma winding_number_split_linepath: - assumes "c \ closed_segment a b" "z \ closed_segment a b" - shows "winding_number(linepath a b) z = winding_number(linepath a c) z + winding_number(linepath c b) z" -proof - - have "z \ closed_segment a c" "z \ closed_segment c b" - using assms by (meson convex_contains_segment convex_segment ends_in_segment subsetCE)+ - then show ?thesis - using assms - by (simp add: winding_number_valid_path contour_integral_split_linepath [symmetric] continuous_on_inversediff field_simps) -qed - -lemma winding_number_cong: - "(\t. \0 \ t; t \ 1\ \ p t = q t) \ winding_number p z = winding_number q z" - by (simp add: winding_number_def winding_number_prop_def pathstart_def pathfinish_def) - -lemma winding_number_constI: - assumes "c\z" "\t. \0\t; t\1\ \ g t = c" - shows "winding_number g z = 0" -proof - - have "winding_number g z = winding_number (linepath c c) z" - apply (rule winding_number_cong) - using assms unfolding linepath_def by auto - moreover have "winding_number (linepath c c) z =0" - apply (rule winding_number_trivial) - using assms by auto - ultimately show ?thesis by auto -qed - -lemma winding_number_offset: "winding_number p z = winding_number (\w. p w - z) 0" - unfolding winding_number_def -proof (intro ext arg_cong [where f = Eps] arg_cong [where f = All] imp_cong refl, safe) - fix n e g - assume "0 < e" and g: "winding_number_prop p z e g n" - then show "\r. winding_number_prop (\w. p w - z) 0 e r n" - by (rule_tac x="\t. g t - z" in exI) - (force simp: winding_number_prop_def contour_integral_integral valid_path_def path_defs - vector_derivative_def has_vector_derivative_diff_const piecewise_C1_differentiable_diff C1_differentiable_imp_piecewise) -next - fix n e g - assume "0 < e" and g: "winding_number_prop (\w. p w - z) 0 e g n" - then show "\r. winding_number_prop p z e r n" - apply (rule_tac x="\t. g t + z" in exI) - apply (simp add: winding_number_prop_def contour_integral_integral valid_path_def path_defs - piecewise_C1_differentiable_add vector_derivative_def has_vector_derivative_add_const C1_differentiable_imp_piecewise) - apply (force simp: algebra_simps) - done -qed - -subsubsection\<^marker>\tag unimportant\ \Some lemmas about negating a path\ - -lemma valid_path_negatepath: "valid_path \ \ valid_path (uminus \ \)" - unfolding o_def using piecewise_C1_differentiable_neg valid_path_def by blast - -lemma has_contour_integral_negatepath: - assumes \: "valid_path \" and cint: "((\z. f (- z)) has_contour_integral - i) \" - shows "(f has_contour_integral i) (uminus \ \)" -proof - - obtain S where cont: "continuous_on {0..1} \" and "finite S" and diff: "\ C1_differentiable_on {0..1} - S" - using \ by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) - have "((\x. - (f (- \ x) * vector_derivative \ (at x within {0..1}))) has_integral i) {0..1}" - using cint by (auto simp: has_contour_integral_def dest: has_integral_neg) - then - have "((\x. f (- \ x) * vector_derivative (uminus \ \) (at x within {0..1})) has_integral i) {0..1}" - proof (rule rev_iffD1 [OF _ has_integral_spike_eq]) - show "negligible S" - by (simp add: \finite S\ negligible_finite) - show "f (- \ x) * vector_derivative (uminus \ \) (at x within {0..1}) = - - (f (- \ x) * vector_derivative \ (at x within {0..1}))" - if "x \ {0..1} - S" for x - proof - - have "vector_derivative (uminus \ \) (at x within cbox 0 1) = - vector_derivative \ (at x within cbox 0 1)" - proof (rule vector_derivative_within_cbox) - show "(uminus \ \ has_vector_derivative - vector_derivative \ (at x within cbox 0 1)) (at x within cbox 0 1)" - using that unfolding o_def - by (metis C1_differentiable_on_eq UNIV_I diff differentiable_subset has_vector_derivative_minus subsetI that vector_derivative_works) - qed (use that in auto) - then show ?thesis - by simp - qed - qed - then show ?thesis by (simp add: has_contour_integral_def) -qed - -lemma winding_number_negatepath: - assumes \: "valid_path \" and 0: "0 \ path_image \" - shows "winding_number(uminus \ \) 0 = winding_number \ 0" -proof - - have "(/) 1 contour_integrable_on \" - using "0" \ contour_integrable_inversediff by fastforce - then have "((\z. 1/z) has_contour_integral contour_integral \ ((/) 1)) \" - by (rule has_contour_integral_integral) - then have "((\z. 1 / - z) has_contour_integral - contour_integral \ ((/) 1)) \" - using has_contour_integral_neg by auto - then show ?thesis - using assms - apply (simp add: winding_number_valid_path valid_path_negatepath image_def path_defs) - apply (simp add: contour_integral_unique has_contour_integral_negatepath) - done -qed - -lemma contour_integrable_negatepath: - assumes \: "valid_path \" and pi: "(\z. f (- z)) contour_integrable_on \" - shows "f contour_integrable_on (uminus \ \)" - by (metis \ add.inverse_inverse contour_integrable_on_def has_contour_integral_negatepath pi) - -(* A combined theorem deducing several things piecewise.*) -lemma winding_number_join_pos_combined: - "\valid_path \1; z \ path_image \1; 0 < Re(winding_number \1 z); - valid_path \2; z \ path_image \2; 0 < Re(winding_number \2 z); pathfinish \1 = pathstart \2\ - \ valid_path(\1 +++ \2) \ z \ path_image(\1 +++ \2) \ 0 < Re(winding_number(\1 +++ \2) z)" - by (simp add: valid_path_join path_image_join winding_number_join valid_path_imp_path) - - -subsubsection\<^marker>\tag unimportant\ \Useful sufficient conditions for the winding number to be positive\ - -lemma Re_winding_number: - "\valid_path \; z \ path_image \\ - \ Re(winding_number \ z) = Im(contour_integral \ (\w. 1/(w - z))) / (2*pi)" -by (simp add: winding_number_valid_path field_simps Re_divide power2_eq_square) - -lemma winding_number_pos_le: - assumes \: "valid_path \" "z \ path_image \" - and ge: "\x. \0 < x; x < 1\ \ 0 \ Im (vector_derivative \ (at x) * cnj(\ x - z))" - shows "0 \ Re(winding_number \ z)" -proof - - have ge0: "0 \ Im (vector_derivative \ (at x) / (\ x - z))" if x: "0 < x" "x < 1" for x - using ge by (simp add: Complex.Im_divide algebra_simps x) - let ?vd = "\x. 1 / (\ x - z) * vector_derivative \ (at x)" - let ?int = "\z. contour_integral \ (\w. 1 / (w - z))" - have hi: "(?vd has_integral ?int z) (cbox 0 1)" - unfolding box_real - apply (subst has_contour_integral [symmetric]) - using \ by (simp add: contour_integrable_inversediff has_contour_integral_integral) - have "0 \ Im (?int z)" - proof (rule has_integral_component_nonneg [of \, simplified]) - show "\x. x \ cbox 0 1 \ 0 \ Im (if 0 < x \ x < 1 then ?vd x else 0)" - by (force simp: ge0) - show "((\x. if 0 < x \ x < 1 then ?vd x else 0) has_integral ?int z) (cbox 0 1)" - by (rule has_integral_spike_interior [OF hi]) simp - qed - then show ?thesis - by (simp add: Re_winding_number [OF \] field_simps) -qed - -lemma winding_number_pos_lt_lemma: - assumes \: "valid_path \" "z \ path_image \" - and e: "0 < e" - and ge: "\x. \0 < x; x < 1\ \ e \ Im (vector_derivative \ (at x) / (\ x - z))" - shows "0 < Re(winding_number \ z)" -proof - - let ?vd = "\x. 1 / (\ x - z) * vector_derivative \ (at x)" - let ?int = "\z. contour_integral \ (\w. 1 / (w - z))" - have hi: "(?vd has_integral ?int z) (cbox 0 1)" - unfolding box_real - apply (subst has_contour_integral [symmetric]) - using \ by (simp add: contour_integrable_inversediff has_contour_integral_integral) - have "e \ Im (contour_integral \ (\w. 1 / (w - z)))" - proof (rule has_integral_component_le [of \ "\x. \*e" "\*e" "{0..1}", simplified]) - show "((\x. if 0 < x \ x < 1 then ?vd x else \ * complex_of_real e) has_integral ?int z) {0..1}" - by (rule has_integral_spike_interior [OF hi, simplified box_real]) (use e in simp) - show "\x. 0 \ x \ x \ 1 \ - e \ Im (if 0 < x \ x < 1 then ?vd x else \ * complex_of_real e)" - by (simp add: ge) - qed (use has_integral_const_real [of _ 0 1] in auto) - with e show ?thesis - by (simp add: Re_winding_number [OF \] field_simps) -qed - -lemma winding_number_pos_lt: - assumes \: "valid_path \" "z \ path_image \" - and e: "0 < e" - and ge: "\x. \0 < x; x < 1\ \ e \ Im (vector_derivative \ (at x) * cnj(\ x - z))" - shows "0 < Re (winding_number \ z)" -proof - - have bm: "bounded ((\w. w - z) ` (path_image \))" - using bounded_translation [of _ "-z"] \ by (simp add: bounded_valid_path_image) - then obtain B where B: "B > 0" and Bno: "\x. x \ (\w. w - z) ` (path_image \) \ norm x \ B" - using bounded_pos [THEN iffD1, OF bm] by blast - { fix x::real assume x: "0 < x" "x < 1" - then have B2: "cmod (\ x - z)^2 \ B^2" using Bno [of "\ x - z"] - by (simp add: path_image_def power2_eq_square mult_mono') - with x have "\ x \ z" using \ - using path_image_def by fastforce - then have "e / B\<^sup>2 \ Im (vector_derivative \ (at x) * cnj (\ x - z)) / (cmod (\ x - z))\<^sup>2" - using B ge [OF x] B2 e - apply (rule_tac y="e / (cmod (\ x - z))\<^sup>2" in order_trans) - apply (auto simp: divide_left_mono divide_right_mono) - done - then have "e / B\<^sup>2 \ Im (vector_derivative \ (at x) / (\ x - z))" - by (simp add: complex_div_cnj [of _ "\ x - z" for x] del: complex_cnj_diff times_complex.sel) - } note * = this - show ?thesis - using e B by (simp add: * winding_number_pos_lt_lemma [OF \, of "e/B^2"]) -qed - -subsection\The winding number is an integer\ - -text\Proof from the book Complex Analysis by Lars V. Ahlfors, Chapter 4, section 2.1, - Also on page 134 of Serge Lang's book with the name title, etc.\ - -lemma exp_fg: - fixes z::complex - assumes g: "(g has_vector_derivative g') (at x within s)" - and f: "(f has_vector_derivative (g' / (g x - z))) (at x within s)" - and z: "g x \ z" - shows "((\x. exp(-f x) * (g x - z)) has_vector_derivative 0) (at x within s)" -proof - - have *: "(exp \ (\x. (- f x)) has_vector_derivative - (g' / (g x - z)) * exp (- f x)) (at x within s)" - using assms unfolding has_vector_derivative_def scaleR_conv_of_real - by (auto intro!: derivative_eq_intros) - show ?thesis - apply (rule has_vector_derivative_eq_rhs) - using z - apply (auto intro!: derivative_eq_intros * [unfolded o_def] g) - done -qed - -lemma winding_number_exp_integral: - fixes z::complex - assumes \: "\ piecewise_C1_differentiable_on {a..b}" - and ab: "a \ b" - and z: "z \ \ ` {a..b}" - shows "(\x. vector_derivative \ (at x) / (\ x - z)) integrable_on {a..b}" - (is "?thesis1") - "exp (- (integral {a..b} (\x. vector_derivative \ (at x) / (\ x - z)))) * (\ b - z) = \ a - z" - (is "?thesis2") -proof - - let ?D\ = "\x. vector_derivative \ (at x)" - have [simp]: "\x. a \ x \ x \ b \ \ x \ z" - using z by force - have cong: "continuous_on {a..b} \" - using \ by (simp add: piecewise_C1_differentiable_on_def) - obtain k where fink: "finite k" and g_C1_diff: "\ C1_differentiable_on ({a..b} - k)" - using \ by (force simp: piecewise_C1_differentiable_on_def) - have \: "open ({a<..finite k\ by (simp add: finite_imp_closed open_Diff) - moreover have "{a<.. {a..b} - k" - by force - ultimately have g_diff_at: "\x. \x \ k; x \ {a<.. \ \ differentiable at x" - by (metis Diff_iff differentiable_on_subset C1_diff_imp_diff [OF g_C1_diff] differentiable_on_def at_within_open) - { fix w - assume "w \ z" - have "continuous_on (ball w (cmod (w - z))) (\w. 1 / (w - z))" - by (auto simp: dist_norm intro!: continuous_intros) - moreover have "\x. cmod (w - x) < cmod (w - z) \ \f'. ((\w. 1 / (w - z)) has_field_derivative f') (at x)" - by (auto simp: intro!: derivative_eq_intros) - ultimately have "\h. \y. norm(y - w) < norm(w - z) \ (h has_field_derivative 1/(y - z)) (at y)" - using holomorphic_convex_primitive [of "ball w (norm(w - z))" "{}" "\w. 1/(w - z)"] - by (force simp: field_differentiable_def Ball_def dist_norm at_within_open_NO_MATCH norm_minus_commute) - } - then obtain h where h: "\w y. w \ z \ norm(y - w) < norm(w - z) \ (h w has_field_derivative 1/(y - z)) (at y)" - by meson - have exy: "\y. ((\x. inverse (\ x - z) * ?D\ x) has_integral y) {a..b}" - unfolding integrable_on_def [symmetric] - proof (rule contour_integral_local_primitive_any [OF piecewise_C1_imp_differentiable [OF \]]) - show "\d h. 0 < d \ - (\y. cmod (y - w) < d \ (h has_field_derivative inverse (y - z))(at y within - {z}))" - if "w \ - {z}" for w - apply (rule_tac x="norm(w - z)" in exI) - using that inverse_eq_divide has_field_derivative_at_within h - by (metis Compl_insert DiffD2 insertCI right_minus_eq zero_less_norm_iff) - qed simp - have vg_int: "(\x. ?D\ x / (\ x - z)) integrable_on {a..b}" - unfolding box_real [symmetric] divide_inverse_commute - by (auto intro!: exy integrable_subinterval simp add: integrable_on_def ab) - with ab show ?thesis1 - by (simp add: divide_inverse_commute integral_def integrable_on_def) - { fix t - assume t: "t \ {a..b}" - have cball: "continuous_on (ball (\ t) (dist (\ t) z)) (\x. inverse (x - z))" - using z by (auto intro!: continuous_intros simp: dist_norm) - have icd: "\x. cmod (\ t - x) < cmod (\ t - z) \ (\w. inverse (w - z)) field_differentiable at x" - unfolding field_differentiable_def by (force simp: intro!: derivative_eq_intros) - obtain h where h: "\x. cmod (\ t - x) < cmod (\ t - z) \ - (h has_field_derivative inverse (x - z)) (at x within {y. cmod (\ t - y) < cmod (\ t - z)})" - using holomorphic_convex_primitive [where f = "\w. inverse(w - z)", OF convex_ball finite.emptyI cball icd] - by simp (auto simp: ball_def dist_norm that) - { fix x D - assume x: "x \ k" "a < x" "x < b" - then have "x \ interior ({a..b} - k)" - using open_subset_interior [OF \] by fastforce - then have con: "isCont ?D\ x" - using g_C1_diff x by (auto simp: C1_differentiable_on_eq intro: continuous_on_interior) - then have con_vd: "continuous (at x within {a..b}) (\x. ?D\ x)" - by (rule continuous_at_imp_continuous_within) - have gdx: "\ differentiable at x" - using x by (simp add: g_diff_at) - have "\d. \x \ k; a < x; x < b; - (\ has_vector_derivative d) (at x); a \ t; t \ b\ - \ ((\x. integral {a..x} - (\x. ?D\ x / - (\ x - z))) has_vector_derivative - d / (\ x - z)) - (at x within {a..b})" - apply (rule has_vector_derivative_eq_rhs) - apply (rule integral_has_vector_derivative_continuous_at [where S = "{}", simplified]) - apply (rule con_vd continuous_intros cong vg_int | simp add: continuous_at_imp_continuous_within has_vector_derivative_continuous vector_derivative_at)+ - done - then have "((\c. exp (- integral {a..c} (\x. ?D\ x / (\ x - z))) * (\ c - z)) has_derivative (\h. 0)) - (at x within {a..b})" - using x gdx t - apply (clarsimp simp add: differentiable_iff_scaleR) - apply (rule exp_fg [unfolded has_vector_derivative_def, simplified], blast intro: has_derivative_at_withinI) - apply (simp_all add: has_vector_derivative_def [symmetric]) - done - } note * = this - have "exp (- (integral {a..t} (\x. ?D\ x / (\ x - z)))) * (\ t - z) =\ a - z" - apply (rule has_derivative_zero_unique_strong_interval [of "{a,b} \ k" a b]) - using t - apply (auto intro!: * continuous_intros fink cong indefinite_integral_continuous_1 [OF vg_int] simp add: ab)+ - done - } - with ab show ?thesis2 - by (simp add: divide_inverse_commute integral_def) -qed - -lemma winding_number_exp_2pi: - "\path p; z \ path_image p\ - \ pathfinish p - z = exp (2 * pi * \ * winding_number p z) * (pathstart p - z)" -using winding_number [of p z 1] unfolding valid_path_def path_image_def pathstart_def pathfinish_def winding_number_prop_def - by (force dest: winding_number_exp_integral(2) [of _ 0 1 z] simp: field_simps contour_integral_integral exp_minus) - -lemma integer_winding_number_eq: - assumes \: "path \" and z: "z \ path_image \" - shows "winding_number \ z \ \ \ pathfinish \ = pathstart \" -proof - - obtain p where p: "valid_path p" "z \ path_image p" - "pathstart p = pathstart \" "pathfinish p = pathfinish \" - and eq: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number \ z" - using winding_number [OF assms, of 1] unfolding winding_number_prop_def by auto - then have wneq: "winding_number \ z = winding_number p z" - using eq winding_number_valid_path by force - have iff: "(winding_number \ z \ \) \ (exp (contour_integral p (\w. 1 / (w - z))) = 1)" - using eq by (simp add: exp_eq_1 complex_is_Int_iff) - have "exp (contour_integral p (\w. 1 / (w - z))) = (\ 1 - z) / (\ 0 - z)" - using p winding_number_exp_integral(2) [of p 0 1 z] - apply (simp add: valid_path_def path_defs contour_integral_integral exp_minus field_split_simps) - by (metis path_image_def pathstart_def pathstart_in_path_image) - then have "winding_number p z \ \ \ pathfinish p = pathstart p" - using p wneq iff by (auto simp: path_defs) - then show ?thesis using p eq - by (auto simp: winding_number_valid_path) -qed - -theorem integer_winding_number: - "\path \; pathfinish \ = pathstart \; z \ path_image \\ \ winding_number \ z \ \" -by (metis integer_winding_number_eq) - - -text\If the winding number's magnitude is at least one, then the path must contain points in every direction.*) - We can thus bound the winding number of a path that doesn't intersect a given ray. \ - -lemma winding_number_pos_meets: - fixes z::complex - assumes \: "valid_path \" and z: "z \ path_image \" and 1: "Re (winding_number \ z) \ 1" - and w: "w \ z" - shows "\a::real. 0 < a \ z + a*(w - z) \ path_image \" -proof - - have [simp]: "\x. 0 \ x \ x \ 1 \ \ x \ z" - using z by (auto simp: path_image_def) - have [simp]: "z \ \ ` {0..1}" - using path_image_def z by auto - have gpd: "\ piecewise_C1_differentiable_on {0..1}" - using \ valid_path_def by blast - define r where "r = (w - z) / (\ 0 - z)" - have [simp]: "r \ 0" - using w z by (auto simp: r_def) - have cont: "continuous_on {0..1} - (\x. Im (integral {0..x} (\x. vector_derivative \ (at x) / (\ x - z))))" - by (intro continuous_intros indefinite_integral_continuous_1 winding_number_exp_integral [OF gpd]; simp) - have "Arg2pi r \ 2*pi" - by (simp add: Arg2pi less_eq_real_def) - also have "\ \ Im (integral {0..1} (\x. vector_derivative \ (at x) / (\ x - z)))" - using 1 - apply (simp add: winding_number_valid_path [OF \ z] contour_integral_integral) - apply (simp add: Complex.Re_divide field_simps power2_eq_square) - done - finally have "Arg2pi r \ Im (integral {0..1} (\x. vector_derivative \ (at x) / (\ x - z)))" . - then have "\t. t \ {0..1} \ Im(integral {0..t} (\x. vector_derivative \ (at x)/(\ x - z))) = Arg2pi r" - by (simp add: Arg2pi_ge_0 cont IVT') - then obtain t where t: "t \ {0..1}" - and eqArg: "Im (integral {0..t} (\x. vector_derivative \ (at x)/(\ x - z))) = Arg2pi r" - by blast - define i where "i = integral {0..t} (\x. vector_derivative \ (at x) / (\ x - z))" - have iArg: "Arg2pi r = Im i" - using eqArg by (simp add: i_def) - have gpdt: "\ piecewise_C1_differentiable_on {0..t}" - by (metis atLeastAtMost_iff atLeastatMost_subset_iff order_refl piecewise_C1_differentiable_on_subset gpd t) - have "exp (- i) * (\ t - z) = \ 0 - z" - unfolding i_def - apply (rule winding_number_exp_integral [OF gpdt]) - using t z unfolding path_image_def by force+ - then have *: "\ t - z = exp i * (\ 0 - z)" - by (simp add: exp_minus field_simps) - then have "(w - z) = r * (\ 0 - z)" - by (simp add: r_def) - then have "z + complex_of_real (exp (Re i)) * (w - z) / complex_of_real (cmod r) = \ t" - apply simp - apply (subst Complex_Transcendental.Arg2pi_eq [of r]) - apply (simp add: iArg) - using * apply (simp add: exp_eq_polar field_simps) - done - with t show ?thesis - by (rule_tac x="exp(Re i) / norm r" in exI) (auto simp: path_image_def) -qed - -lemma winding_number_big_meets: - fixes z::complex - assumes \: "valid_path \" and z: "z \ path_image \" and "\Re (winding_number \ z)\ \ 1" - and w: "w \ z" - shows "\a::real. 0 < a \ z + a*(w - z) \ path_image \" -proof - - { assume "Re (winding_number \ z) \ - 1" - then have "Re (winding_number (reversepath \) z) \ 1" - by (simp add: \ valid_path_imp_path winding_number_reversepath z) - moreover have "valid_path (reversepath \)" - using \ valid_path_imp_reverse by auto - moreover have "z \ path_image (reversepath \)" - by (simp add: z) - ultimately have "\a::real. 0 < a \ z + a*(w - z) \ path_image (reversepath \)" - using winding_number_pos_meets w by blast - then have ?thesis - by simp - } - then show ?thesis - using assms - by (simp add: abs_if winding_number_pos_meets split: if_split_asm) -qed - -lemma winding_number_less_1: - fixes z::complex - shows - "\valid_path \; z \ path_image \; w \ z; - \a::real. 0 < a \ z + a*(w - z) \ path_image \\ - \ Re(winding_number \ z) < 1" - by (auto simp: not_less dest: winding_number_big_meets) - -text\One way of proving that WN=1 for a loop.\ -lemma winding_number_eq_1: - fixes z::complex - assumes \: "valid_path \" and z: "z \ path_image \" and loop: "pathfinish \ = pathstart \" - and 0: "0 < Re(winding_number \ z)" and 2: "Re(winding_number \ z) < 2" - shows "winding_number \ z = 1" -proof - - have "winding_number \ z \ Ints" - by (simp add: \ integer_winding_number loop valid_path_imp_path z) - then show ?thesis - using 0 2 by (auto simp: Ints_def) -qed - -subsection\Continuity of winding number and invariance on connected sets\ - -lemma continuous_at_winding_number: - fixes z::complex - assumes \: "path \" and z: "z \ path_image \" - shows "continuous (at z) (winding_number \)" -proof - - obtain e where "e>0" and cbg: "cball z e \ - path_image \" - using open_contains_cball [of "- path_image \"] z - by (force simp: closed_def [symmetric] closed_path_image [OF \]) - then have ppag: "path_image \ \ - cball z (e/2)" - by (force simp: cball_def dist_norm) - have oc: "open (- cball z (e / 2))" - by (simp add: closed_def [symmetric]) - obtain d where "d>0" and pi_eq: - "\h1 h2. \valid_path h1; valid_path h2; - (\t\{0..1}. cmod (h1 t - \ t) < d \ cmod (h2 t - \ t) < d); - pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1\ - \ - path_image h1 \ - cball z (e / 2) \ - path_image h2 \ - cball z (e / 2) \ - (\f. f holomorphic_on - cball z (e / 2) \ contour_integral h2 f = contour_integral h1 f)" - using contour_integral_nearby_ends [OF oc \ ppag] by metis - obtain p where p: "valid_path p" "z \ path_image p" - "pathstart p = pathstart \ \ pathfinish p = pathfinish \" - and pg: "\t. t\{0..1} \ cmod (\ t - p t) < min d e / 2" - and pi: "contour_integral p (\x. 1 / (x - z)) = complex_of_real (2 * pi) * \ * winding_number \ z" - using winding_number [OF \ z, of "min d e / 2"] \d>0\ \e>0\ by (auto simp: winding_number_prop_def) - { fix w - assume d2: "cmod (w - z) < d/2" and e2: "cmod (w - z) < e/2" - then have wnotp: "w \ path_image p" - using cbg \d>0\ \e>0\ - apply (simp add: path_image_def cball_def dist_norm, clarify) - apply (frule pg) - apply (drule_tac c="\ x" in subsetD) - apply (auto simp: less_eq_real_def norm_minus_commute norm_triangle_half_l) - done - have wnotg: "w \ path_image \" - using cbg e2 \e>0\ by (force simp: dist_norm norm_minus_commute) - { fix k::real - assume k: "k>0" - then obtain q where q: "valid_path q" "w \ path_image q" - "pathstart q = pathstart \ \ pathfinish q = pathfinish \" - and qg: "\t. t \ {0..1} \ cmod (\ t - q t) < min k (min d e) / 2" - and qi: "contour_integral q (\u. 1 / (u - w)) = complex_of_real (2 * pi) * \ * winding_number \ w" - using winding_number [OF \ wnotg, of "min k (min d e) / 2"] \d>0\ \e>0\ k - by (force simp: min_divide_distrib_right winding_number_prop_def) - have "contour_integral p (\u. 1 / (u - w)) = contour_integral q (\u. 1 / (u - w))" - apply (rule pi_eq [OF \valid_path q\ \valid_path p\, THEN conjunct2, THEN conjunct2, rule_format]) - apply (frule pg) - apply (frule qg) - using p q \d>0\ e2 - apply (auto simp: dist_norm norm_minus_commute intro!: holomorphic_intros) - done - then have "contour_integral p (\x. 1 / (x - w)) = complex_of_real (2 * pi) * \ * winding_number \ w" - by (simp add: pi qi) - } note pip = this - have "path p" - using p by (simp add: valid_path_imp_path) - then have "winding_number p w = winding_number \ w" - apply (rule winding_number_unique [OF _ wnotp]) - apply (rule_tac x=p in exI) - apply (simp add: p wnotp min_divide_distrib_right pip winding_number_prop_def) - done - } note wnwn = this - obtain pe where "pe>0" and cbp: "cball z (3 / 4 * pe) \ - path_image p" - using p open_contains_cball [of "- path_image p"] - by (force simp: closed_def [symmetric] closed_path_image [OF valid_path_imp_path]) - obtain L - where "L>0" - and L: "\f B. \f holomorphic_on - cball z (3 / 4 * pe); - \z \ - cball z (3 / 4 * pe). cmod (f z) \ B\ \ - cmod (contour_integral p f) \ L * B" - using contour_integral_bound_exists [of "- cball z (3/4*pe)" p] cbp \valid_path p\ by blast - { fix e::real and w::complex - assume e: "0 < e" and w: "cmod (w - z) < pe/4" "cmod (w - z) < e * pe\<^sup>2 / (8 * L)" - then have [simp]: "w \ path_image p" - using cbp p(2) \0 < pe\ - by (force simp: dist_norm norm_minus_commute path_image_def cball_def) - have [simp]: "contour_integral p (\x. 1/(x - w)) - contour_integral p (\x. 1/(x - z)) = - contour_integral p (\x. 1/(x - w) - 1/(x - z))" - by (simp add: p contour_integrable_inversediff contour_integral_diff) - { fix x - assume pe: "3/4 * pe < cmod (z - x)" - have "cmod (w - x) < pe/4 + cmod (z - x)" - by (meson add_less_cancel_right norm_diff_triangle_le order_refl order_trans_rules(21) w(1)) - then have wx: "cmod (w - x) < 4/3 * cmod (z - x)" using pe by simp - have "cmod (z - x) \ cmod (z - w) + cmod (w - x)" - using norm_diff_triangle_le by blast - also have "\ < pe/4 + cmod (w - x)" - using w by (simp add: norm_minus_commute) - finally have "pe/2 < cmod (w - x)" - using pe by auto - then have "(pe/2)^2 < cmod (w - x) ^ 2" - apply (rule power_strict_mono) - using \pe>0\ by auto - then have pe2: "pe^2 < 4 * cmod (w - x) ^ 2" - by (simp add: power_divide) - have "8 * L * cmod (w - z) < e * pe\<^sup>2" - using w \L>0\ by (simp add: field_simps) - also have "\ < e * 4 * cmod (w - x) * cmod (w - x)" - using pe2 \e>0\ by (simp add: power2_eq_square) - also have "\ < e * 4 * cmod (w - x) * (4/3 * cmod (z - x))" - using wx - apply (rule mult_strict_left_mono) - using pe2 e not_less_iff_gr_or_eq by fastforce - finally have "L * cmod (w - z) < 2/3 * e * cmod (w - x) * cmod (z - x)" - by simp - also have "\ \ e * cmod (w - x) * cmod (z - x)" - using e by simp - finally have Lwz: "L * cmod (w - z) < e * cmod (w - x) * cmod (z - x)" . - have "L * cmod (1 / (x - w) - 1 / (x - z)) \ e" - apply (cases "x=z \ x=w") - using pe \pe>0\ w \L>0\ - apply (force simp: norm_minus_commute) - using wx w(2) \L>0\ pe pe2 Lwz - apply (auto simp: divide_simps mult_less_0_iff norm_minus_commute norm_divide norm_mult power2_eq_square) - done - } note L_cmod_le = this - have *: "cmod (contour_integral p (\x. 1 / (x - w) - 1 / (x - z))) \ L * (e * pe\<^sup>2 / L / 4 * (inverse (pe / 2))\<^sup>2)" - apply (rule L) - using \pe>0\ w - apply (force simp: dist_norm norm_minus_commute intro!: holomorphic_intros) - using \pe>0\ w \L>0\ - apply (auto simp: cball_def dist_norm field_simps L_cmod_le simp del: less_divide_eq_numeral1 le_divide_eq_numeral1) - done - have "cmod (contour_integral p (\x. 1 / (x - w)) - contour_integral p (\x. 1 / (x - z))) < 2*e" - apply simp - apply (rule le_less_trans [OF *]) - using \L>0\ e - apply (force simp: field_simps) - done - then have "cmod (winding_number p w - winding_number p z) < e" - using pi_ge_two e - by (force simp: winding_number_valid_path p field_simps norm_divide norm_mult intro: less_le_trans) - } note cmod_wn_diff = this - then have "isCont (winding_number p) z" - apply (simp add: continuous_at_eps_delta, clarify) - apply (rule_tac x="min (pe/4) (e/2*pe^2/L/4)" in exI) - using \pe>0\ \L>0\ - apply (simp add: dist_norm cmod_wn_diff) - done - then show ?thesis - apply (rule continuous_transform_within [where d = "min d e / 2"]) - apply (auto simp: \d>0\ \e>0\ dist_norm wnwn) - done -qed - -corollary continuous_on_winding_number: - "path \ \ continuous_on (- path_image \) (\w. winding_number \ w)" - by (simp add: continuous_at_imp_continuous_on continuous_at_winding_number) - -subsection\<^marker>\tag unimportant\ \The winding number is constant on a connected region\ - -lemma winding_number_constant: - assumes \: "path \" and loop: "pathfinish \ = pathstart \" and cs: "connected S" and sg: "S \ path_image \ = {}" - shows "winding_number \ constant_on S" -proof - - have *: "1 \ cmod (winding_number \ y - winding_number \ z)" - if ne: "winding_number \ y \ winding_number \ z" and "y \ S" "z \ S" for y z - proof - - have "winding_number \ y \ \" "winding_number \ z \ \" - using that integer_winding_number [OF \ loop] sg \y \ S\ by auto - with ne show ?thesis - by (auto simp: Ints_def simp flip: of_int_diff) - qed - have cont: "continuous_on S (\w. winding_number \ w)" - using continuous_on_winding_number [OF \] sg - by (meson continuous_on_subset disjoint_eq_subset_Compl) - show ?thesis - using "*" zero_less_one - by (blast intro: continuous_discrete_range_constant [OF cs cont]) -qed - -lemma winding_number_eq: - "\path \; pathfinish \ = pathstart \; w \ S; z \ S; connected S; S \ path_image \ = {}\ - \ winding_number \ w = winding_number \ z" - using winding_number_constant by (metis constant_on_def) - -lemma open_winding_number_levelsets: - assumes \: "path \" and loop: "pathfinish \ = pathstart \" - shows "open {z. z \ path_image \ \ winding_number \ z = k}" -proof - - have opn: "open (- path_image \)" - by (simp add: closed_path_image \ open_Compl) - { fix z assume z: "z \ path_image \" and k: "k = winding_number \ z" - obtain e where e: "e>0" "ball z e \ - path_image \" - using open_contains_ball [of "- path_image \"] opn z - by blast - have "\e>0. \y. dist y z < e \ y \ path_image \ \ winding_number \ y = winding_number \ z" - apply (rule_tac x=e in exI) - using e apply (simp add: dist_norm ball_def norm_minus_commute) - apply (auto simp: dist_norm norm_minus_commute intro!: winding_number_eq [OF assms, where S = "ball z e"]) - done - } then - show ?thesis - by (auto simp: open_dist) -qed - -subsection\Winding number is zero "outside" a curve\ - -proposition winding_number_zero_in_outside: - assumes \: "path \" and loop: "pathfinish \ = pathstart \" and z: "z \ outside (path_image \)" - shows "winding_number \ z = 0" -proof - - obtain B::real where "0 < B" and B: "path_image \ \ ball 0 B" - using bounded_subset_ballD [OF bounded_path_image [OF \]] by auto - obtain w::complex where w: "w \ ball 0 (B + 1)" - by (metis abs_of_nonneg le_less less_irrefl mem_ball_0 norm_of_real) - have "- ball 0 (B + 1) \ outside (path_image \)" - apply (rule outside_subset_convex) - using B subset_ball by auto - then have wout: "w \ outside (path_image \)" - using w by blast - moreover have "winding_number \ constant_on outside (path_image \)" - using winding_number_constant [OF \ loop, of "outside(path_image \)"] connected_outside - by (metis DIM_complex bounded_path_image dual_order.refl \ outside_no_overlap) - ultimately have "winding_number \ z = winding_number \ w" - by (metis (no_types, hide_lams) constant_on_def z) - also have "\ = 0" - proof - - have wnot: "w \ path_image \" using wout by (simp add: outside_def) - { fix e::real assume "0" "pathfinish p = pathfinish \" - and pg1: "(\t. \0 \ t; t \ 1\ \ cmod (p t - \ t) < 1)" - and pge: "(\t. \0 \ t; t \ 1\ \ cmod (p t - \ t) < e)" - using path_approx_polynomial_function [OF \, of "min 1 e"] \e>0\ by force - have pip: "path_image p \ ball 0 (B + 1)" - using B - apply (clarsimp simp add: path_image_def dist_norm ball_def) - apply (frule (1) pg1) - apply (fastforce dest: norm_add_less) - done - then have "w \ path_image p" using w by blast - then have "\p. valid_path p \ w \ path_image p \ - pathstart p = pathstart \ \ pathfinish p = pathfinish \ \ - (\t\{0..1}. cmod (\ t - p t) < e) \ contour_integral p (\wa. 1 / (wa - w)) = 0" - apply (rule_tac x=p in exI) - apply (simp add: p valid_path_polynomial_function) - apply (intro conjI) - using pge apply (simp add: norm_minus_commute) - apply (rule contour_integral_unique [OF Cauchy_theorem_convex_simple [OF _ convex_ball [of 0 "B+1"]]]) - apply (rule holomorphic_intros | simp add: dist_norm)+ - using mem_ball_0 w apply blast - using p apply (simp_all add: valid_path_polynomial_function loop pip) - done - } - then show ?thesis - by (auto intro: winding_number_unique [OF \] simp add: winding_number_prop_def wnot) - qed - finally show ?thesis . -qed - -corollary\<^marker>\tag unimportant\ winding_number_zero_const: "a \ z \ winding_number (\t. a) z = 0" - by (rule winding_number_zero_in_outside) - (auto simp: pathfinish_def pathstart_def path_polynomial_function) - -corollary\<^marker>\tag unimportant\ winding_number_zero_outside: - "\path \; convex s; pathfinish \ = pathstart \; z \ s; path_image \ \ s\ \ winding_number \ z = 0" - by (meson convex_in_outside outside_mono subsetCE winding_number_zero_in_outside) - -lemma winding_number_zero_at_infinity: - assumes \: "path \" and loop: "pathfinish \ = pathstart \" - shows "\B. \z. B \ norm z \ winding_number \ z = 0" -proof - - obtain B::real where "0 < B" and B: "path_image \ \ ball 0 B" - using bounded_subset_ballD [OF bounded_path_image [OF \]] by auto - then show ?thesis - apply (rule_tac x="B+1" in exI, clarify) - apply (rule winding_number_zero_outside [OF \ convex_cball [of 0 B] loop]) - apply (meson less_add_one mem_cball_0 not_le order_trans) - using ball_subset_cball by blast -qed - -lemma winding_number_zero_point: - "\path \; convex s; pathfinish \ = pathstart \; open s; path_image \ \ s\ - \ \z. z \ s \ winding_number \ z = 0" - using outside_compact_in_open [of "path_image \" s] path_image_nonempty winding_number_zero_in_outside - by (fastforce simp add: compact_path_image) - - -text\If a path winds round a set, it winds rounds its inside.\ -lemma winding_number_around_inside: - assumes \: "path \" and loop: "pathfinish \ = pathstart \" - and cls: "closed s" and cos: "connected s" and s_disj: "s \ path_image \ = {}" - and z: "z \ s" and wn_nz: "winding_number \ z \ 0" and w: "w \ s \ inside s" - shows "winding_number \ w = winding_number \ z" -proof - - have ssb: "s \ inside(path_image \)" - proof - fix x :: complex - assume "x \ s" - hence "x \ path_image \" - by (meson disjoint_iff_not_equal s_disj) - thus "x \ inside (path_image \)" - using \x \ s\ by (metis (no_types) ComplI UnE cos \ loop s_disj union_with_outside winding_number_eq winding_number_zero_in_outside wn_nz z) -qed - show ?thesis - apply (rule winding_number_eq [OF \ loop w]) - using z apply blast - apply (simp add: cls connected_with_inside cos) - apply (simp add: Int_Un_distrib2 s_disj, safe) - by (meson ssb inside_inside_compact_connected [OF cls, of "path_image \"] compact_path_image connected_path_image contra_subsetD disjoint_iff_not_equal \ inside_no_overlap) - qed - - -text\Bounding a WN by 1/2 for a path and point in opposite halfspaces.\ -lemma winding_number_subpath_continuous: - assumes \: "valid_path \" and z: "z \ path_image \" - shows "continuous_on {0..1} (\x. winding_number(subpath 0 x \) z)" -proof - - have *: "integral {0..x} (\t. vector_derivative \ (at t) / (\ t - z)) / (2 * of_real pi * \) = - winding_number (subpath 0 x \) z" - if x: "0 \ x" "x \ 1" for x - proof - - have "integral {0..x} (\t. vector_derivative \ (at t) / (\ t - z)) / (2 * of_real pi * \) = - 1 / (2*pi*\) * contour_integral (subpath 0 x \) (\w. 1/(w - z))" - using assms x - apply (simp add: contour_integral_subcontour_integral [OF contour_integrable_inversediff]) - done - also have "\ = winding_number (subpath 0 x \) z" - apply (subst winding_number_valid_path) - using assms x - apply (simp_all add: path_image_subpath valid_path_subpath) - by (force simp: path_image_def) - finally show ?thesis . - qed - show ?thesis - apply (rule continuous_on_eq - [where f = "\x. 1 / (2*pi*\) * - integral {0..x} (\t. 1/(\ t - z) * vector_derivative \ (at t))"]) - apply (rule continuous_intros)+ - apply (rule indefinite_integral_continuous_1) - apply (rule contour_integrable_inversediff [OF assms, unfolded contour_integrable_on]) - using assms - apply (simp add: *) - done -qed - -lemma winding_number_ivt_pos: - assumes \: "valid_path \" and z: "z \ path_image \" and "0 \ w" "w \ Re(winding_number \ z)" - shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w" - apply (rule ivt_increasing_component_on_1 [of 0 1, where ?k = "1::complex", simplified complex_inner_1_right], simp) - apply (rule winding_number_subpath_continuous [OF \ z]) - using assms - apply (auto simp: path_image_def image_def) - done - -lemma winding_number_ivt_neg: - assumes \: "valid_path \" and z: "z \ path_image \" and "Re(winding_number \ z) \ w" "w \ 0" - shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w" - apply (rule ivt_decreasing_component_on_1 [of 0 1, where ?k = "1::complex", simplified complex_inner_1_right], simp) - apply (rule winding_number_subpath_continuous [OF \ z]) - using assms - apply (auto simp: path_image_def image_def) - done - -lemma winding_number_ivt_abs: - assumes \: "valid_path \" and z: "z \ path_image \" and "0 \ w" "w \ \Re(winding_number \ z)\" - shows "\t \ {0..1}. \Re (winding_number (subpath 0 t \) z)\ = w" - using assms winding_number_ivt_pos [of \ z w] winding_number_ivt_neg [of \ z "-w"] - by force - -lemma winding_number_lt_half_lemma: - assumes \: "valid_path \" and z: "z \ path_image \" and az: "a \ z \ b" and pag: "path_image \ \ {w. a \ w > b}" - shows "Re(winding_number \ z) < 1/2" -proof - - { assume "Re(winding_number \ z) \ 1/2" - then obtain t::real where t: "0 \ t" "t \ 1" and sub12: "Re (winding_number (subpath 0 t \) z) = 1/2" - using winding_number_ivt_pos [OF \ z, of "1/2"] by auto - have gt: "\ t - z = - (of_real (exp (- (2 * pi * Im (winding_number (subpath 0 t \) z)))) * (\ 0 - z))" - using winding_number_exp_2pi [of "subpath 0 t \" z] - apply (simp add: t \ valid_path_imp_path) - using closed_segment_eq_real_ivl path_image_def t z by (fastforce simp: path_image_subpath Euler sub12) - have "b < a \ \ 0" - proof - - have "\ 0 \ {c. b < a \ c}" - by (metis (no_types) pag atLeastAtMost_iff image_subset_iff order_refl path_image_def zero_le_one) - thus ?thesis - by blast - qed - moreover have "b < a \ \ t" - proof - - have "\ t \ {c. b < a \ c}" - by (metis (no_types) pag atLeastAtMost_iff image_subset_iff path_image_def t) - thus ?thesis - by blast - qed - ultimately have "0 < a \ (\ 0 - z)" "0 < a \ (\ t - z)" using az - by (simp add: inner_diff_right)+ - then have False - by (simp add: gt inner_mult_right mult_less_0_iff) - } - then show ?thesis by force -qed - -lemma winding_number_lt_half: - assumes "valid_path \" "a \ z \ b" "path_image \ \ {w. a \ w > b}" - shows "\Re (winding_number \ z)\ < 1/2" -proof - - have "z \ path_image \" using assms by auto - with assms show ?thesis - apply (simp add: winding_number_lt_half_lemma abs_if del: less_divide_eq_numeral1) - apply (metis complex_inner_1_right winding_number_lt_half_lemma [OF valid_path_imp_reverse, of \ z a b] - winding_number_reversepath valid_path_imp_path inner_minus_left path_image_reversepath) - done -qed - -lemma winding_number_le_half: - assumes \: "valid_path \" and z: "z \ path_image \" - and anz: "a \ 0" and azb: "a \ z \ b" and pag: "path_image \ \ {w. a \ w \ b}" - shows "\Re (winding_number \ z)\ \ 1/2" -proof - - { assume wnz_12: "\Re (winding_number \ z)\ > 1/2" - have "isCont (winding_number \) z" - by (metis continuous_at_winding_number valid_path_imp_path \ z) - then obtain d where "d>0" and d: "\x'. dist x' z < d \ dist (winding_number \ x') (winding_number \ z) < \Re(winding_number \ z)\ - 1/2" - using continuous_at_eps_delta wnz_12 diff_gt_0_iff_gt by blast - define z' where "z' = z - (d / (2 * cmod a)) *\<^sub>R a" - have *: "a \ z' \ b - d / 3 * cmod a" - unfolding z'_def inner_mult_right' divide_inverse - apply (simp add: field_split_simps algebra_simps dot_square_norm power2_eq_square anz) - apply (metis \0 < d\ add_increasing azb less_eq_real_def mult_nonneg_nonneg mult_right_mono norm_ge_zero norm_numeral) - done - have "cmod (winding_number \ z' - winding_number \ z) < \Re (winding_number \ z)\ - 1/2" - using d [of z'] anz \d>0\ by (simp add: dist_norm z'_def) - then have "1/2 < \Re (winding_number \ z)\ - cmod (winding_number \ z' - winding_number \ z)" - by simp - then have "1/2 < \Re (winding_number \ z)\ - \Re (winding_number \ z') - Re (winding_number \ z)\" - using abs_Re_le_cmod [of "winding_number \ z' - winding_number \ z"] by simp - then have wnz_12': "\Re (winding_number \ z')\ > 1/2" - by linarith - moreover have "\Re (winding_number \ z')\ < 1/2" - apply (rule winding_number_lt_half [OF \ *]) - using azb \d>0\ pag - apply (auto simp: add_strict_increasing anz field_split_simps dest!: subsetD) - done - ultimately have False - by simp - } - then show ?thesis by force -qed - -lemma winding_number_lt_half_linepath: "z \ closed_segment a b \ \Re (winding_number (linepath a b) z)\ < 1/2" - using separating_hyperplane_closed_point [of "closed_segment a b" z] - apply auto - apply (simp add: closed_segment_def) - apply (drule less_imp_le) - apply (frule winding_number_lt_half [OF valid_path_linepath [of a b]]) - apply (auto simp: segment) - done - - -text\ Positivity of WN for a linepath.\ -lemma winding_number_linepath_pos_lt: - assumes "0 < Im ((b - a) * cnj (b - z))" - shows "0 < Re(winding_number(linepath a b) z)" -proof - - have z: "z \ path_image (linepath a b)" - using assms - by (simp add: closed_segment_def) (force simp: algebra_simps) - show ?thesis - apply (rule winding_number_pos_lt [OF valid_path_linepath z assms]) - apply (simp add: linepath_def algebra_simps) - done -qed - - -subsection\Cauchy's integral formula, again for a convex enclosing set\ - -lemma Cauchy_integral_formula_weak: - assumes s: "convex s" and "finite k" and conf: "continuous_on s f" - and fcd: "(\x. x \ interior s - k \ f field_differentiable at x)" - and z: "z \ interior s - k" and vpg: "valid_path \" - and pasz: "path_image \ \ s - {z}" and loop: "pathfinish \ = pathstart \" - shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" -proof - - obtain f' where f': "(f has_field_derivative f') (at z)" - using fcd [OF z] by (auto simp: field_differentiable_def) - have pas: "path_image \ \ s" and znotin: "z \ path_image \" using pasz by blast+ - have c: "continuous (at x within s) (\w. if w = z then f' else (f w - f z) / (w - z))" if "x \ s" for x - proof (cases "x = z") - case True then show ?thesis - apply (simp add: continuous_within) - apply (rule Lim_transform_away_within [of _ "z+1" _ "\w::complex. (f w - f z)/(w - z)"]) - using has_field_derivative_at_within has_field_derivative_iff f' - apply (fastforce simp add:)+ - done - next - case False - then have dxz: "dist x z > 0" by auto - have cf: "continuous (at x within s) f" - using conf continuous_on_eq_continuous_within that by blast - have "continuous (at x within s) (\w. (f w - f z) / (w - z))" - by (rule cf continuous_intros | simp add: False)+ - then show ?thesis - apply (rule continuous_transform_within [OF _ dxz that, of "\w::complex. (f w - f z)/(w - z)"]) - apply (force simp: dist_commute) - done - qed - have fink': "finite (insert z k)" using \finite k\ by blast - have *: "((\w. if w = z then f' else (f w - f z) / (w - z)) has_contour_integral 0) \" - apply (rule Cauchy_theorem_convex [OF _ s fink' _ vpg pas loop]) - using c apply (force simp: continuous_on_eq_continuous_within) - apply (rename_tac w) - apply (rule_tac d="dist w z" and f = "\w. (f w - f z)/(w - z)" in field_differentiable_transform_within) - apply (simp_all add: dist_pos_lt dist_commute) - apply (metis less_irrefl) - apply (rule derivative_intros fcd | simp)+ - done - show ?thesis - apply (rule has_contour_integral_eq) - using znotin has_contour_integral_add [OF has_contour_integral_lmul [OF has_contour_integral_winding_number [OF vpg znotin], of "f z"] *] - apply (auto simp: ac_simps divide_simps) - done -qed - -theorem Cauchy_integral_formula_convex_simple: - "\convex s; f holomorphic_on s; z \ interior s; valid_path \; path_image \ \ s - {z}; - pathfinish \ = pathstart \\ - \ ((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" - apply (rule Cauchy_integral_formula_weak [where k = "{}"]) - using holomorphic_on_imp_continuous_on - by auto (metis at_within_interior holomorphic_on_def interiorE subsetCE) subsection\Homotopy forms of Cauchy's theorem\ @@ -3870,3290 +1593,4 @@ apply (blast dest: holomorphic_on_imp_continuous_on homotopic_loops_imp_subset) by (simp add: Cauchy_theorem_homotopic_loops) -subsection\<^marker>\tag unimportant\ \More winding number properties\ - -text\including the fact that it's +-1 inside a simple closed curve.\ - -lemma winding_number_homotopic_paths: - assumes "homotopic_paths (-{z}) g h" - shows "winding_number g z = winding_number h z" -proof - - have "path g" "path h" using homotopic_paths_imp_path [OF assms] by auto - moreover have pag: "z \ path_image g" and pah: "z \ path_image h" - using homotopic_paths_imp_subset [OF assms] by auto - ultimately obtain d e where "d > 0" "e > 0" - and d: "\p. \path p; pathstart p = pathstart g; pathfinish p = pathfinish g; \t\{0..1}. norm (p t - g t) < d\ - \ homotopic_paths (-{z}) g p" - and e: "\q. \path q; pathstart q = pathstart h; pathfinish q = pathfinish h; \t\{0..1}. norm (q t - h t) < e\ - \ homotopic_paths (-{z}) h q" - using homotopic_nearby_paths [of g "-{z}"] homotopic_nearby_paths [of h "-{z}"] by force - obtain p where p: - "valid_path p" "z \ path_image p" - "pathstart p = pathstart g" "pathfinish p = pathfinish g" - and gp_less:"\t\{0..1}. cmod (g t - p t) < d" - and pap: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number g z" - using winding_number [OF \path g\ pag \0 < d\] unfolding winding_number_prop_def by blast - obtain q where q: - "valid_path q" "z \ path_image q" - "pathstart q = pathstart h" "pathfinish q = pathfinish h" - and hq_less: "\t\{0..1}. cmod (h t - q t) < e" - and paq: "contour_integral q (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number h z" - using winding_number [OF \path h\ pah \0 < e\] unfolding winding_number_prop_def by blast - have "homotopic_paths (- {z}) g p" - by (simp add: d p valid_path_imp_path norm_minus_commute gp_less) - moreover have "homotopic_paths (- {z}) h q" - by (simp add: e q valid_path_imp_path norm_minus_commute hq_less) - ultimately have "homotopic_paths (- {z}) p q" - by (blast intro: homotopic_paths_trans homotopic_paths_sym assms) - then have "contour_integral p (\w. 1/(w - z)) = contour_integral q (\w. 1/(w - z))" - by (rule Cauchy_theorem_homotopic_paths) (auto intro!: holomorphic_intros simp: p q) - then show ?thesis - by (simp add: pap paq) -qed - -lemma winding_number_homotopic_loops: - assumes "homotopic_loops (-{z}) g h" - shows "winding_number g z = winding_number h z" -proof - - have "path g" "path h" using homotopic_loops_imp_path [OF assms] by auto - moreover have pag: "z \ path_image g" and pah: "z \ path_image h" - using homotopic_loops_imp_subset [OF assms] by auto - moreover have gloop: "pathfinish g = pathstart g" and hloop: "pathfinish h = pathstart h" - using homotopic_loops_imp_loop [OF assms] by auto - ultimately obtain d e where "d > 0" "e > 0" - and d: "\p. \path p; pathfinish p = pathstart p; \t\{0..1}. norm (p t - g t) < d\ - \ homotopic_loops (-{z}) g p" - and e: "\q. \path q; pathfinish q = pathstart q; \t\{0..1}. norm (q t - h t) < e\ - \ homotopic_loops (-{z}) h q" - using homotopic_nearby_loops [of g "-{z}"] homotopic_nearby_loops [of h "-{z}"] by force - obtain p where p: - "valid_path p" "z \ path_image p" - "pathstart p = pathstart g" "pathfinish p = pathfinish g" - and gp_less:"\t\{0..1}. cmod (g t - p t) < d" - and pap: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number g z" - using winding_number [OF \path g\ pag \0 < d\] unfolding winding_number_prop_def by blast - obtain q where q: - "valid_path q" "z \ path_image q" - "pathstart q = pathstart h" "pathfinish q = pathfinish h" - and hq_less: "\t\{0..1}. cmod (h t - q t) < e" - and paq: "contour_integral q (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number h z" - using winding_number [OF \path h\ pah \0 < e\] unfolding winding_number_prop_def by blast - have gp: "homotopic_loops (- {z}) g p" - by (simp add: gloop d gp_less norm_minus_commute p valid_path_imp_path) - have hq: "homotopic_loops (- {z}) h q" - by (simp add: e hloop hq_less norm_minus_commute q valid_path_imp_path) - have "contour_integral p (\w. 1/(w - z)) = contour_integral q (\w. 1/(w - z))" - proof (rule Cauchy_theorem_homotopic_loops) - show "homotopic_loops (- {z}) p q" - by (blast intro: homotopic_loops_trans homotopic_loops_sym gp hq assms) - qed (auto intro!: holomorphic_intros simp: p q) - then show ?thesis - by (simp add: pap paq) -qed - -lemma winding_number_paths_linear_eq: - "\path g; path h; pathstart h = pathstart g; pathfinish h = pathfinish g; - \t. t \ {0..1} \ z \ closed_segment (g t) (h t)\ - \ winding_number h z = winding_number g z" - by (blast intro: sym homotopic_paths_linear winding_number_homotopic_paths) - -lemma winding_number_loops_linear_eq: - "\path g; path h; pathfinish g = pathstart g; pathfinish h = pathstart h; - \t. t \ {0..1} \ z \ closed_segment (g t) (h t)\ - \ winding_number h z = winding_number g z" - by (blast intro: sym homotopic_loops_linear winding_number_homotopic_loops) - -lemma winding_number_nearby_paths_eq: - "\path g; path h; pathstart h = pathstart g; pathfinish h = pathfinish g; - \t. t \ {0..1} \ norm(h t - g t) < norm(g t - z)\ - \ winding_number h z = winding_number g z" - by (metis segment_bound(2) norm_minus_commute not_le winding_number_paths_linear_eq) - -lemma winding_number_nearby_loops_eq: - "\path g; path h; pathfinish g = pathstart g; pathfinish h = pathstart h; - \t. t \ {0..1} \ norm(h t - g t) < norm(g t - z)\ - \ winding_number h z = winding_number g z" - by (metis segment_bound(2) norm_minus_commute not_le winding_number_loops_linear_eq) - - -lemma winding_number_subpath_combine: - "\path g; z \ path_image g; - u \ {0..1}; v \ {0..1}; w \ {0..1}\ - \ winding_number (subpath u v g) z + winding_number (subpath v w g) z = - winding_number (subpath u w g) z" -apply (rule trans [OF winding_number_join [THEN sym] - winding_number_homotopic_paths [OF homotopic_join_subpaths]]) - using path_image_subpath_subset by auto - -subsection\Partial circle path\ - -definition\<^marker>\tag important\ part_circlepath :: "[complex, real, real, real, real] \ complex" - where "part_circlepath z r s t \ \x. z + of_real r * exp (\ * of_real (linepath s t x))" - -lemma pathstart_part_circlepath [simp]: - "pathstart(part_circlepath z r s t) = z + r*exp(\ * s)" -by (metis part_circlepath_def pathstart_def pathstart_linepath) - -lemma pathfinish_part_circlepath [simp]: - "pathfinish(part_circlepath z r s t) = z + r*exp(\*t)" -by (metis part_circlepath_def pathfinish_def pathfinish_linepath) - -lemma reversepath_part_circlepath[simp]: - "reversepath (part_circlepath z r s t) = part_circlepath z r t s" - unfolding part_circlepath_def reversepath_def linepath_def - by (auto simp:algebra_simps) - -lemma has_vector_derivative_part_circlepath [derivative_intros]: - "((part_circlepath z r s t) has_vector_derivative - (\ * r * (of_real t - of_real s) * exp(\ * linepath s t x))) - (at x within X)" - apply (simp add: part_circlepath_def linepath_def scaleR_conv_of_real) - apply (rule has_vector_derivative_real_field) - apply (rule derivative_eq_intros | simp)+ - done - -lemma differentiable_part_circlepath: - "part_circlepath c r a b differentiable at x within A" - using has_vector_derivative_part_circlepath[of c r a b x A] differentiableI_vector by blast - -lemma vector_derivative_part_circlepath: - "vector_derivative (part_circlepath z r s t) (at x) = - \ * r * (of_real t - of_real s) * exp(\ * linepath s t x)" - using has_vector_derivative_part_circlepath vector_derivative_at by blast - -lemma vector_derivative_part_circlepath01: - "\0 \ x; x \ 1\ - \ vector_derivative (part_circlepath z r s t) (at x within {0..1}) = - \ * r * (of_real t - of_real s) * exp(\ * linepath s t x)" - using has_vector_derivative_part_circlepath - by (auto simp: vector_derivative_at_within_ivl) - -lemma valid_path_part_circlepath [simp]: "valid_path (part_circlepath z r s t)" - apply (simp add: valid_path_def) - apply (rule C1_differentiable_imp_piecewise) - apply (auto simp: C1_differentiable_on_eq vector_derivative_works vector_derivative_part_circlepath has_vector_derivative_part_circlepath - intro!: continuous_intros) - done - -lemma path_part_circlepath [simp]: "path (part_circlepath z r s t)" - by (simp add: valid_path_imp_path) - -proposition path_image_part_circlepath: - assumes "s \ t" - shows "path_image (part_circlepath z r s t) = {z + r * exp(\ * of_real x) | x. s \ x \ x \ t}" -proof - - { fix z::real - assume "0 \ z" "z \ 1" - with \s \ t\ have "\x. (exp (\ * linepath s t z) = exp (\ * of_real x)) \ s \ x \ x \ t" - apply (rule_tac x="(1 - z) * s + z * t" in exI) - apply (simp add: linepath_def scaleR_conv_of_real algebra_simps) - apply (rule conjI) - using mult_right_mono apply blast - using affine_ineq by (metis "mult.commute") - } - moreover - { fix z - assume "s \ z" "z \ t" - then have "z + of_real r * exp (\ * of_real z) \ (\x. z + of_real r * exp (\ * linepath s t x)) ` {0..1}" - apply (rule_tac x="(z - s)/(t - s)" in image_eqI) - apply (simp add: linepath_def scaleR_conv_of_real divide_simps exp_eq) - apply (auto simp: field_split_simps) - done - } - ultimately show ?thesis - by (fastforce simp add: path_image_def part_circlepath_def) -qed - -lemma path_image_part_circlepath': - "path_image (part_circlepath z r s t) = (\x. z + r * cis x) ` closed_segment s t" -proof - - have "path_image (part_circlepath z r s t) = - (\x. z + r * exp(\ * of_real x)) ` linepath s t ` {0..1}" - by (simp add: image_image path_image_def part_circlepath_def) - also have "linepath s t ` {0..1} = closed_segment s t" - by (rule linepath_image_01) - finally show ?thesis by (simp add: cis_conv_exp) -qed - -lemma path_image_part_circlepath_subset: - "\s \ t; 0 \ r\ \ path_image(part_circlepath z r s t) \ sphere z r" -by (auto simp: path_image_part_circlepath sphere_def dist_norm algebra_simps norm_mult) - -lemma in_path_image_part_circlepath: - assumes "w \ path_image(part_circlepath z r s t)" "s \ t" "0 \ r" - shows "norm(w - z) = r" -proof - - have "w \ {c. dist z c = r}" - by (metis (no_types) path_image_part_circlepath_subset sphere_def subset_eq assms) - thus ?thesis - by (simp add: dist_norm norm_minus_commute) -qed - -lemma path_image_part_circlepath_subset': - assumes "r \ 0" - shows "path_image (part_circlepath z r s t) \ sphere z r" -proof (cases "s \ t") - case True - thus ?thesis using path_image_part_circlepath_subset[of s t r z] assms by simp -next - case False - thus ?thesis using path_image_part_circlepath_subset[of t s r z] assms - by (subst reversepath_part_circlepath [symmetric], subst path_image_reversepath) simp_all -qed - -lemma part_circlepath_cnj: "cnj (part_circlepath c r a b x) = part_circlepath (cnj c) r (-a) (-b) x" - by (simp add: part_circlepath_def exp_cnj linepath_def algebra_simps) - -lemma contour_integral_bound_part_circlepath: - assumes "f contour_integrable_on part_circlepath c r a b" - assumes "B \ 0" "r \ 0" "\x. x \ path_image (part_circlepath c r a b) \ norm (f x) \ B" - shows "norm (contour_integral (part_circlepath c r a b) f) \ B * r * \b - a\" -proof - - let ?I = "integral {0..1} (\x. f (part_circlepath c r a b x) * \ * of_real (r * (b - a)) * - exp (\ * linepath a b x))" - have "norm ?I \ integral {0..1} (\x::real. B * 1 * (r * \b - a\) * 1)" - proof (rule integral_norm_bound_integral, goal_cases) - case 1 - with assms(1) show ?case - by (simp add: contour_integrable_on vector_derivative_part_circlepath mult_ac) - next - case (3 x) - with assms(2-) show ?case unfolding norm_mult norm_of_real abs_mult - by (intro mult_mono) (auto simp: path_image_def) - qed auto - also have "?I = contour_integral (part_circlepath c r a b) f" - by (simp add: contour_integral_integral vector_derivative_part_circlepath mult_ac) - finally show ?thesis by simp -qed - -lemma has_contour_integral_part_circlepath_iff: - assumes "a < b" - shows "(f has_contour_integral I) (part_circlepath c r a b) \ - ((\t. f (c + r * cis t) * r * \ * cis t) has_integral I) {a..b}" -proof - - have "(f has_contour_integral I) (part_circlepath c r a b) \ - ((\x. f (part_circlepath c r a b x) * vector_derivative (part_circlepath c r a b) - (at x within {0..1})) has_integral I) {0..1}" - unfolding has_contour_integral_def .. - also have "\ \ ((\x. f (part_circlepath c r a b x) * r * (b - a) * \ * - cis (linepath a b x)) has_integral I) {0..1}" - by (intro has_integral_cong, subst vector_derivative_part_circlepath01) - (simp_all add: cis_conv_exp) - also have "\ \ ((\x. f (c + r * exp (\ * linepath (of_real a) (of_real b) x)) * - r * \ * exp (\ * linepath (of_real a) (of_real b) x) * - vector_derivative (linepath (of_real a) (of_real b)) - (at x within {0..1})) has_integral I) {0..1}" - by (intro has_integral_cong, subst vector_derivative_linepath_within) - (auto simp: part_circlepath_def cis_conv_exp of_real_linepath [symmetric]) - also have "\ \ ((\z. f (c + r * exp (\ * z)) * r * \ * exp (\ * z)) has_contour_integral I) - (linepath (of_real a) (of_real b))" - by (simp add: has_contour_integral_def) - also have "\ \ ((\t. f (c + r * cis t) * r * \ * cis t) has_integral I) {a..b}" using assms - by (subst has_contour_integral_linepath_Reals_iff) (simp_all add: cis_conv_exp) - finally show ?thesis . -qed - -lemma contour_integrable_part_circlepath_iff: - assumes "a < b" - shows "f contour_integrable_on (part_circlepath c r a b) \ - (\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" - using assms by (auto simp: contour_integrable_on_def integrable_on_def - has_contour_integral_part_circlepath_iff) - -lemma contour_integral_part_circlepath_eq: - assumes "a < b" - shows "contour_integral (part_circlepath c r a b) f = - integral {a..b} (\t. f (c + r * cis t) * r * \ * cis t)" -proof (cases "f contour_integrable_on part_circlepath c r a b") - case True - hence "(\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" - using assms by (simp add: contour_integrable_part_circlepath_iff) - with True show ?thesis - using has_contour_integral_part_circlepath_iff[OF assms] - contour_integral_unique has_integral_integrable_integral by blast -next - case False - hence "\(\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" - using assms by (simp add: contour_integrable_part_circlepath_iff) - with False show ?thesis - by (simp add: not_integrable_contour_integral not_integrable_integral) -qed - -lemma contour_integral_part_circlepath_reverse: - "contour_integral (part_circlepath c r a b) f = -contour_integral (part_circlepath c r b a) f" - by (subst reversepath_part_circlepath [symmetric], subst contour_integral_reversepath) simp_all - -lemma contour_integral_part_circlepath_reverse': - "b < a \ contour_integral (part_circlepath c r a b) f = - -contour_integral (part_circlepath c r b a) f" - by (rule contour_integral_part_circlepath_reverse) - -lemma finite_bounded_log: "finite {z::complex. norm z \ b \ exp z = w}" -proof (cases "w = 0") - case True then show ?thesis by auto -next - case False - have *: "finite {x. cmod (complex_of_real (2 * real_of_int x * pi) * \) \ b + cmod (Ln w)}" - apply (simp add: norm_mult finite_int_iff_bounded_le) - apply (rule_tac x="\(b + cmod (Ln w)) / (2*pi)\" in exI) - apply (auto simp: field_split_simps le_floor_iff) - done - have [simp]: "\P f. {z. P z \ (\n. z = f n)} = f ` {n. P (f n)}" - by blast - show ?thesis - apply (subst exp_Ln [OF False, symmetric]) - apply (simp add: exp_eq) - using norm_add_leD apply (fastforce intro: finite_subset [OF _ *]) - done -qed - -lemma finite_bounded_log2: - fixes a::complex - assumes "a \ 0" - shows "finite {z. norm z \ b \ exp(a*z) = w}" -proof - - have *: "finite ((\z. z / a) ` {z. cmod z \ b * cmod a \ exp z = w})" - by (rule finite_imageI [OF finite_bounded_log]) - show ?thesis - by (rule finite_subset [OF _ *]) (force simp: assms norm_mult) -qed - -lemma has_contour_integral_bound_part_circlepath_strong: - assumes fi: "(f has_contour_integral i) (part_circlepath z r s t)" - and "finite k" and le: "0 \ B" "0 < r" "s \ t" - and B: "\x. x \ path_image(part_circlepath z r s t) - k \ norm(f x) \ B" - shows "cmod i \ B * r * (t - s)" -proof - - consider "s = t" | "s < t" using \s \ t\ by linarith - then show ?thesis - proof cases - case 1 with fi [unfolded has_contour_integral] - have "i = 0" by (simp add: vector_derivative_part_circlepath) - with assms show ?thesis by simp - next - case 2 - have [simp]: "\r\ = r" using \r > 0\ by linarith - have [simp]: "cmod (complex_of_real t - complex_of_real s) = t-s" - by (metis "2" abs_of_pos diff_gt_0_iff_gt norm_of_real of_real_diff) - have "finite (part_circlepath z r s t -` {y} \ {0..1})" if "y \ k" for y - proof - - define w where "w = (y - z)/of_real r / exp(\ * of_real s)" - have fin: "finite (of_real -` {z. cmod z \ 1 \ exp (\ * complex_of_real (t - s) * z) = w})" - apply (rule finite_vimageI [OF finite_bounded_log2]) - using \s < t\ apply (auto simp: inj_of_real) - done - show ?thesis - apply (simp add: part_circlepath_def linepath_def vimage_def) - apply (rule finite_subset [OF _ fin]) - using le - apply (auto simp: w_def algebra_simps scaleR_conv_of_real exp_add exp_diff) - done - qed - then have fin01: "finite ((part_circlepath z r s t) -` k \ {0..1})" - by (rule finite_finite_vimage_IntI [OF \finite k\]) - have **: "((\x. if (part_circlepath z r s t x) \ k then 0 - else f(part_circlepath z r s t x) * - vector_derivative (part_circlepath z r s t) (at x)) has_integral i) {0..1}" - by (rule has_integral_spike [OF negligible_finite [OF fin01]]) (use fi has_contour_integral in auto) - have *: "\x. \0 \ x; x \ 1; part_circlepath z r s t x \ k\ \ cmod (f (part_circlepath z r s t x)) \ B" - by (auto intro!: B [unfolded path_image_def image_def, simplified]) - show ?thesis - apply (rule has_integral_bound [where 'a=real, simplified, OF _ **, simplified]) - using assms apply force - apply (simp add: norm_mult vector_derivative_part_circlepath) - using le * "2" \r > 0\ by auto - qed -qed - -lemma has_contour_integral_bound_part_circlepath: - "\(f has_contour_integral i) (part_circlepath z r s t); - 0 \ B; 0 < r; s \ t; - \x. x \ path_image(part_circlepath z r s t) \ norm(f x) \ B\ - \ norm i \ B*r*(t - s)" - by (auto intro: has_contour_integral_bound_part_circlepath_strong) - -lemma contour_integrable_continuous_part_circlepath: - "continuous_on (path_image (part_circlepath z r s t)) f - \ f contour_integrable_on (part_circlepath z r s t)" - apply (simp add: contour_integrable_on has_contour_integral_def vector_derivative_part_circlepath path_image_def) - apply (rule integrable_continuous_real) - apply (fast intro: path_part_circlepath [unfolded path_def] continuous_intros continuous_on_compose2 [where g=f, OF _ _ order_refl]) - done - -proposition winding_number_part_circlepath_pos_less: - assumes "s < t" and no: "norm(w - z) < r" - shows "0 < Re (winding_number(part_circlepath z r s t) w)" -proof - - have "0 < r" by (meson no norm_not_less_zero not_le order.strict_trans2) - note valid_path_part_circlepath - moreover have " w \ path_image (part_circlepath z r s t)" - using assms by (auto simp: path_image_def image_def part_circlepath_def norm_mult linepath_def) - moreover have "0 < r * (t - s) * (r - cmod (w - z))" - using assms by (metis \0 < r\ diff_gt_0_iff_gt mult_pos_pos) - ultimately show ?thesis - apply (rule winding_number_pos_lt [where e = "r*(t - s)*(r - norm(w - z))"]) - apply (simp add: vector_derivative_part_circlepath right_diff_distrib [symmetric] mult_ac) - apply (rule mult_left_mono)+ - using Re_Im_le_cmod [of "w-z" "linepath s t x" for x] - apply (simp add: exp_Euler cos_of_real sin_of_real part_circlepath_def algebra_simps cos_squared_eq [unfolded power2_eq_square]) - using assms \0 < r\ by auto -qed - -lemma simple_path_part_circlepath: - "simple_path(part_circlepath z r s t) \ (r \ 0 \ s \ t \ \s - t\ \ 2*pi)" -proof (cases "r = 0 \ s = t") - case True - then show ?thesis - unfolding part_circlepath_def simple_path_def - by (rule disjE) (force intro: bexI [where x = "1/4"] bexI [where x = "1/3"])+ -next - case False then have "r \ 0" "s \ t" by auto - have *: "\x y z s t. \*((1 - x) * s + x * t) = \*(((1 - y) * s + y * t)) + z \ \*(x - y) * (t - s) = z" - by (simp add: algebra_simps) - have abs01: "\x y::real. 0 \ x \ x \ 1 \ 0 \ y \ y \ 1 - \ (x = y \ x = 0 \ y = 1 \ x = 1 \ y = 0 \ \x - y\ \ {0,1})" - by auto - have **: "\x y. (\n. (complex_of_real x - of_real y) * (of_real t - of_real s) = 2 * (of_int n * of_real pi)) \ - (\n. \x - y\ * (t - s) = 2 * (of_int n * pi))" - by (force simp: algebra_simps abs_if dest: arg_cong [where f=Re] arg_cong [where f=complex_of_real] - intro: exI [where x = "-n" for n]) - have 1: "\s - t\ \ 2 * pi" - if "\x. 0 \ x \ x \ 1 \ (\n. x * (t - s) = 2 * (real_of_int n * pi)) \ x = 0 \ x = 1" - proof (rule ccontr) - assume "\ \s - t\ \ 2 * pi" - then have *: "\n. t - s \ of_int n * \s - t\" - using False that [of "2*pi / \t - s\"] - by (simp add: abs_minus_commute divide_simps) - show False - using * [of 1] * [of "-1"] by auto - qed - have 2: "\s - t\ = \2 * (real_of_int n * pi) / x\" if "x \ 0" "x * (t - s) = 2 * (real_of_int n * pi)" for x n - proof - - have "t-s = 2 * (real_of_int n * pi)/x" - using that by (simp add: field_simps) - then show ?thesis by (metis abs_minus_commute) - qed - have abs_away: "\P. (\x\{0..1}. \y\{0..1}. P \x - y\) \ (\x::real. 0 \ x \ x \ 1 \ P x)" - by force - show ?thesis using False - apply (simp add: simple_path_def) - apply (simp add: part_circlepath_def linepath_def exp_eq * ** abs01 del: Set.insert_iff) - apply (subst abs_away) - apply (auto simp: 1) - apply (rule ccontr) - apply (auto simp: 2 field_split_simps abs_mult dest: of_int_leD) - done -qed - -lemma arc_part_circlepath: - assumes "r \ 0" "s \ t" "\s - t\ < 2*pi" - shows "arc (part_circlepath z r s t)" -proof - - have *: "x = y" if eq: "\ * (linepath s t x) = \ * (linepath s t y) + 2 * of_int n * complex_of_real pi * \" - and x: "x \ {0..1}" and y: "y \ {0..1}" for x y n - proof (rule ccontr) - assume "x \ y" - have "(linepath s t x) = (linepath s t y) + 2 * of_int n * complex_of_real pi" - by (metis add_divide_eq_iff complex_i_not_zero mult.commute nonzero_mult_div_cancel_left eq) - then have "s*y + t*x = s*x + (t*y + of_int n * (pi * 2))" - by (force simp: algebra_simps linepath_def dest: arg_cong [where f=Re]) - with \x \ y\ have st: "s-t = (of_int n * (pi * 2) / (y-x))" - by (force simp: field_simps) - have "\real_of_int n\ < \y - x\" - using assms \x \ y\ by (simp add: st abs_mult field_simps) - then show False - using assms x y st by (auto dest: of_int_lessD) - qed - show ?thesis - using assms - apply (simp add: arc_def) - apply (simp add: part_circlepath_def inj_on_def exp_eq) - apply (blast intro: *) - done -qed - -subsection\Special case of one complete circle\ - -definition\<^marker>\tag important\ circlepath :: "[complex, real, real] \ complex" - where "circlepath z r \ part_circlepath z r 0 (2*pi)" - -lemma circlepath: "circlepath z r = (\x. z + r * exp(2 * of_real pi * \ * of_real x))" - by (simp add: circlepath_def part_circlepath_def linepath_def algebra_simps) - -lemma pathstart_circlepath [simp]: "pathstart (circlepath z r) = z + r" - by (simp add: circlepath_def) - -lemma pathfinish_circlepath [simp]: "pathfinish (circlepath z r) = z + r" - by (simp add: circlepath_def) (metis exp_two_pi_i mult.commute) - -lemma circlepath_minus: "circlepath z (-r) x = circlepath z r (x + 1/2)" -proof - - have "z + of_real r * exp (2 * pi * \ * (x + 1/2)) = - z + of_real r * exp (2 * pi * \ * x + pi * \)" - by (simp add: divide_simps) (simp add: algebra_simps) - also have "\ = z - r * exp (2 * pi * \ * x)" - by (simp add: exp_add) - finally show ?thesis - by (simp add: circlepath path_image_def sphere_def dist_norm) -qed - -lemma circlepath_add1: "circlepath z r (x+1) = circlepath z r x" - using circlepath_minus [of z r "x+1/2"] circlepath_minus [of z "-r" x] - by (simp add: add.commute) - -lemma circlepath_add_half: "circlepath z r (x + 1/2) = circlepath z r (x - 1/2)" - using circlepath_add1 [of z r "x-1/2"] - by (simp add: add.commute) - -lemma path_image_circlepath_minus_subset: - "path_image (circlepath z (-r)) \ path_image (circlepath z r)" - apply (simp add: path_image_def image_def circlepath_minus, clarify) - apply (case_tac "xa \ 1/2", force) - apply (force simp: circlepath_add_half)+ - done - -lemma path_image_circlepath_minus: "path_image (circlepath z (-r)) = path_image (circlepath z r)" - using path_image_circlepath_minus_subset by fastforce - -lemma has_vector_derivative_circlepath [derivative_intros]: - "((circlepath z r) has_vector_derivative (2 * pi * \ * r * exp (2 * of_real pi * \ * of_real x))) - (at x within X)" - apply (simp add: circlepath_def scaleR_conv_of_real) - apply (rule derivative_eq_intros) - apply (simp add: algebra_simps) - done - -lemma vector_derivative_circlepath: - "vector_derivative (circlepath z r) (at x) = - 2 * pi * \ * r * exp(2 * of_real pi * \ * x)" -using has_vector_derivative_circlepath vector_derivative_at by blast - -lemma vector_derivative_circlepath01: - "\0 \ x; x \ 1\ - \ vector_derivative (circlepath z r) (at x within {0..1}) = - 2 * pi * \ * r * exp(2 * of_real pi * \ * x)" - using has_vector_derivative_circlepath - by (auto simp: vector_derivative_at_within_ivl) - -lemma valid_path_circlepath [simp]: "valid_path (circlepath z r)" - by (simp add: circlepath_def) - -lemma path_circlepath [simp]: "path (circlepath z r)" - by (simp add: valid_path_imp_path) - -lemma path_image_circlepath_nonneg: - assumes "0 \ r" shows "path_image (circlepath z r) = sphere z r" -proof - - have *: "x \ (\u. z + (cmod (x - z)) * exp (\ * (of_real u * (of_real pi * 2)))) ` {0..1}" for x - proof (cases "x = z") - case True then show ?thesis by force - next - case False - define w where "w = x - z" - then have "w \ 0" by (simp add: False) - have **: "\t. \Re w = cos t * cmod w; Im w = sin t * cmod w\ \ w = of_real (cmod w) * exp (\ * t)" - using cis_conv_exp complex_eq_iff by auto - show ?thesis - apply (rule sincos_total_2pi [of "Re(w/of_real(norm w))" "Im(w/of_real(norm w))"]) - apply (simp add: divide_simps \w \ 0\ cmod_power2 [symmetric]) - apply (rule_tac x="t / (2*pi)" in image_eqI) - apply (simp add: field_simps \w \ 0\) - using False ** - apply (auto simp: w_def) - done - qed - show ?thesis - unfolding circlepath path_image_def sphere_def dist_norm - by (force simp: assms algebra_simps norm_mult norm_minus_commute intro: *) -qed - -lemma path_image_circlepath [simp]: - "path_image (circlepath z r) = sphere z \r\" - using path_image_circlepath_minus - by (force simp: path_image_circlepath_nonneg abs_if) - -lemma has_contour_integral_bound_circlepath_strong: - "\(f has_contour_integral i) (circlepath z r); - finite k; 0 \ B; 0 < r; - \x. \norm(x - z) = r; x \ k\ \ norm(f x) \ B\ - \ norm i \ B*(2*pi*r)" - unfolding circlepath_def - by (auto simp: algebra_simps in_path_image_part_circlepath dest!: has_contour_integral_bound_part_circlepath_strong) - -lemma has_contour_integral_bound_circlepath: - "\(f has_contour_integral i) (circlepath z r); - 0 \ B; 0 < r; \x. norm(x - z) = r \ norm(f x) \ B\ - \ norm i \ B*(2*pi*r)" - by (auto intro: has_contour_integral_bound_circlepath_strong) - -lemma contour_integrable_continuous_circlepath: - "continuous_on (path_image (circlepath z r)) f - \ f contour_integrable_on (circlepath z r)" - by (simp add: circlepath_def contour_integrable_continuous_part_circlepath) - -lemma simple_path_circlepath: "simple_path(circlepath z r) \ (r \ 0)" - by (simp add: circlepath_def simple_path_part_circlepath) - -lemma notin_path_image_circlepath [simp]: "cmod (w - z) < r \ w \ path_image (circlepath z r)" - by (simp add: sphere_def dist_norm norm_minus_commute) - -lemma contour_integral_circlepath: - assumes "r > 0" - shows "contour_integral (circlepath z r) (\w. 1 / (w - z)) = 2 * complex_of_real pi * \" -proof (rule contour_integral_unique) - show "((\w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \) (circlepath z r)" - unfolding has_contour_integral_def using assms - apply (subst has_integral_cong) - apply (simp add: vector_derivative_circlepath01) - using has_integral_const_real [of _ 0 1] apply (force simp: circlepath) - done -qed - -lemma winding_number_circlepath_centre: "0 < r \ winding_number (circlepath z r) z = 1" - apply (rule winding_number_unique_loop) - apply (simp_all add: sphere_def valid_path_imp_path) - apply (rule_tac x="circlepath z r" in exI) - apply (simp add: sphere_def contour_integral_circlepath) - done - -proposition winding_number_circlepath: - assumes "norm(w - z) < r" shows "winding_number(circlepath z r) w = 1" -proof (cases "w = z") - case True then show ?thesis - using assms winding_number_circlepath_centre by auto -next - case False - have [simp]: "r > 0" - using assms le_less_trans norm_ge_zero by blast - define r' where "r' = norm(w - z)" - have "r' < r" - by (simp add: assms r'_def) - have disjo: "cball z r' \ sphere z r = {}" - using \r' < r\ by (force simp: cball_def sphere_def) - have "winding_number(circlepath z r) w = winding_number(circlepath z r) z" - proof (rule winding_number_around_inside [where s = "cball z r'"]) - show "winding_number (circlepath z r) z \ 0" - by (simp add: winding_number_circlepath_centre) - show "cball z r' \ path_image (circlepath z r) = {}" - by (simp add: disjo less_eq_real_def) - qed (auto simp: r'_def dist_norm norm_minus_commute) - also have "\ = 1" - by (simp add: winding_number_circlepath_centre) - finally show ?thesis . -qed - - -text\ Hence the Cauchy formula for points inside a circle.\ - -theorem Cauchy_integral_circlepath: - assumes contf: "continuous_on (cball z r) f" and holf: "f holomorphic_on (ball z r)" and wz: "norm(w - z) < r" - shows "((\u. f u/(u - w)) has_contour_integral (2 * of_real pi * \ * f w)) - (circlepath z r)" -proof - - have "r > 0" - using assms le_less_trans norm_ge_zero by blast - have "((\u. f u / (u - w)) has_contour_integral (2 * pi) * \ * winding_number (circlepath z r) w * f w) - (circlepath z r)" - proof (rule Cauchy_integral_formula_weak [where s = "cball z r" and k = "{}"]) - show "\x. x \ interior (cball z r) - {} \ - f field_differentiable at x" - using holf holomorphic_on_imp_differentiable_at by auto - have "w \ sphere z r" - by simp (metis dist_commute dist_norm not_le order_refl wz) - then show "path_image (circlepath z r) \ cball z r - {w}" - using \r > 0\ by (auto simp add: cball_def sphere_def) - qed (use wz in \simp_all add: dist_norm norm_minus_commute contf\) - then show ?thesis - by (simp add: winding_number_circlepath assms) -qed - -corollary\<^marker>\tag unimportant\ Cauchy_integral_circlepath_simple: - assumes "f holomorphic_on cball z r" "norm(w - z) < r" - shows "((\u. f u/(u - w)) has_contour_integral (2 * of_real pi * \ * f w)) - (circlepath z r)" -using assms by (force simp: holomorphic_on_imp_continuous_on holomorphic_on_subset Cauchy_integral_circlepath) - - -lemma no_bounded_connected_component_imp_winding_number_zero: - assumes g: "path g" "path_image g \ s" "pathfinish g = pathstart g" "z \ s" - and nb: "\z. bounded (connected_component_set (- s) z) \ z \ s" - shows "winding_number g z = 0" -apply (rule winding_number_zero_in_outside) -apply (simp_all add: assms) -by (metis nb [of z] \path_image g \ s\ \z \ s\ contra_subsetD mem_Collect_eq outside outside_mono) - -lemma no_bounded_path_component_imp_winding_number_zero: - assumes g: "path g" "path_image g \ s" "pathfinish g = pathstart g" "z \ s" - and nb: "\z. bounded (path_component_set (- s) z) \ z \ s" - shows "winding_number g z = 0" -apply (rule no_bounded_connected_component_imp_winding_number_zero [OF g]) -by (simp add: bounded_subset nb path_component_subset_connected_component) - - -subsection\ Uniform convergence of path integral\ - -text\Uniform convergence when the derivative of the path is bounded, and in particular for the special case of a circle.\ - -proposition contour_integral_uniform_limit: - assumes ev_fint: "eventually (\n::'a. (f n) contour_integrable_on \) F" - and ul_f: "uniform_limit (path_image \) f l F" - and noleB: "\t. t \ {0..1} \ norm (vector_derivative \ (at t)) \ B" - and \: "valid_path \" - and [simp]: "\ trivial_limit F" - shows "l contour_integrable_on \" "((\n. contour_integral \ (f n)) \ contour_integral \ l) F" -proof - - have "0 \ B" by (meson noleB [of 0] atLeastAtMost_iff norm_ge_zero order_refl order_trans zero_le_one) - { fix e::real - assume "0 < e" - then have "0 < e / (\B\ + 1)" by simp - then have "\\<^sub>F n in F. \x\path_image \. cmod (f n x - l x) < e / (\B\ + 1)" - using ul_f [unfolded uniform_limit_iff dist_norm] by auto - with ev_fint - obtain a where fga: "\x. x \ {0..1} \ cmod (f a (\ x) - l (\ x)) < e / (\B\ + 1)" - and inta: "(\t. f a (\ t) * vector_derivative \ (at t)) integrable_on {0..1}" - using eventually_happens [OF eventually_conj] - by (fastforce simp: contour_integrable_on path_image_def) - have Ble: "B * e / (\B\ + 1) \ e" - using \0 \ B\ \0 < e\ by (simp add: field_split_simps) - have "\h. (\x\{0..1}. cmod (l (\ x) * vector_derivative \ (at x) - h x) \ e) \ h integrable_on {0..1}" - proof (intro exI conjI ballI) - show "cmod (l (\ x) * vector_derivative \ (at x) - f a (\ x) * vector_derivative \ (at x)) \ e" - if "x \ {0..1}" for x - apply (rule order_trans [OF _ Ble]) - using noleB [OF that] fga [OF that] \0 \ B\ \0 < e\ - apply (simp add: norm_mult left_diff_distrib [symmetric] norm_minus_commute divide_simps) - apply (fastforce simp: mult_ac dest: mult_mono [OF less_imp_le]) - done - qed (rule inta) - } - then show lintg: "l contour_integrable_on \" - unfolding contour_integrable_on by (metis (mono_tags, lifting)integrable_uniform_limit_real) - { fix e::real - define B' where "B' = B + 1" - have B': "B' > 0" "B' > B" using \0 \ B\ by (auto simp: B'_def) - assume "0 < e" - then have ev_no': "\\<^sub>F n in F. \x\path_image \. 2 * cmod (f n x - l x) < e / B'" - using ul_f [unfolded uniform_limit_iff dist_norm, rule_format, of "e / B' / 2"] B' - by (simp add: field_simps) - have ie: "integral {0..1::real} (\x. e / 2) < e" using \0 < e\ by simp - have *: "cmod (f x (\ t) * vector_derivative \ (at t) - l (\ t) * vector_derivative \ (at t)) \ e / 2" - if t: "t\{0..1}" and leB': "2 * cmod (f x (\ t) - l (\ t)) < e / B'" for x t - proof - - have "2 * cmod (f x (\ t) - l (\ t)) * cmod (vector_derivative \ (at t)) \ e * (B/ B')" - using mult_mono [OF less_imp_le [OF leB'] noleB] B' \0 < e\ t by auto - also have "\ < e" - by (simp add: B' \0 < e\ mult_imp_div_pos_less) - finally have "2 * cmod (f x (\ t) - l (\ t)) * cmod (vector_derivative \ (at t)) < e" . - then show ?thesis - by (simp add: left_diff_distrib [symmetric] norm_mult) - qed - have le_e: "\x. \\xa\{0..1}. 2 * cmod (f x (\ xa) - l (\ xa)) < e / B'; f x contour_integrable_on \\ - \ cmod (integral {0..1} - (\u. f x (\ u) * vector_derivative \ (at u) - l (\ u) * vector_derivative \ (at u))) < e" - apply (rule le_less_trans [OF integral_norm_bound_integral ie]) - apply (simp add: lintg integrable_diff contour_integrable_on [symmetric]) - apply (blast intro: *)+ - done - have "\\<^sub>F x in F. dist (contour_integral \ (f x)) (contour_integral \ l) < e" - apply (rule eventually_mono [OF eventually_conj [OF ev_no' ev_fint]]) - apply (simp add: dist_norm contour_integrable_on path_image_def contour_integral_integral) - apply (simp add: lintg integral_diff [symmetric] contour_integrable_on [symmetric] le_e) - done - } - then show "((\n. contour_integral \ (f n)) \ contour_integral \ l) F" - by (rule tendstoI) -qed - -corollary\<^marker>\tag unimportant\ contour_integral_uniform_limit_circlepath: - assumes "\\<^sub>F n::'a in F. (f n) contour_integrable_on (circlepath z r)" - and "uniform_limit (sphere z r) f l F" - and "\ trivial_limit F" "0 < r" - shows "l contour_integrable_on (circlepath z r)" - "((\n. contour_integral (circlepath z r) (f n)) \ contour_integral (circlepath z r) l) F" - using assms by (auto simp: vector_derivative_circlepath norm_mult intro!: contour_integral_uniform_limit) - - -subsection\<^marker>\tag unimportant\ \General stepping result for derivative formulas\ - -lemma Cauchy_next_derivative: - assumes "continuous_on (path_image \) f'" - and leB: "\t. t \ {0..1} \ norm (vector_derivative \ (at t)) \ B" - and int: "\w. w \ s - path_image \ \ ((\u. f' u / (u - w)^k) has_contour_integral f w) \" - and k: "k \ 0" - and "open s" - and \: "valid_path \" - and w: "w \ s - path_image \" - shows "(\u. f' u / (u - w)^(Suc k)) contour_integrable_on \" - and "(f has_field_derivative (k * contour_integral \ (\u. f' u/(u - w)^(Suc k)))) - (at w)" (is "?thes2") -proof - - have "open (s - path_image \)" using \open s\ closed_valid_path_image \ by blast - then obtain d where "d>0" and d: "ball w d \ s - path_image \" using w - using open_contains_ball by blast - have [simp]: "\n. cmod (1 + of_nat n) = 1 + of_nat n" - by (metis norm_of_nat of_nat_Suc) - have cint: "\x. \x \ w; cmod (x - w) < d\ - \ (\z. (f' z / (z - x) ^ k - f' z / (z - w) ^ k) / (x * k - w * k)) contour_integrable_on \" - apply (rule contour_integrable_div [OF contour_integrable_diff]) - using int w d - by (force simp: dist_norm norm_minus_commute intro!: has_contour_integral_integrable)+ - have 1: "\\<^sub>F n in at w. (\x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k) - contour_integrable_on \" - unfolding eventually_at - apply (rule_tac x=d in exI) - apply (simp add: \d > 0\ dist_norm field_simps cint) - done - have bim_g: "bounded (image f' (path_image \))" - by (simp add: compact_imp_bounded compact_continuous_image compact_valid_path_image assms) - then obtain C where "C > 0" and C: "\x. \0 \ x; x \ 1\ \ cmod (f' (\ x)) \ C" - by (force simp: bounded_pos path_image_def) - have twom: "\\<^sub>F n in at w. - \x\path_image \. - cmod ((inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k - inverse (x - w) ^ Suc k) < e" - if "0 < e" for e - proof - - have *: "cmod ((inverse (x - u) ^ k - inverse (x - w) ^ k) / ((u - w) * k) - inverse (x - w) ^ Suc k) < e" - if x: "x \ path_image \" and "u \ w" and uwd: "cmod (u - w) < d/2" - and uw_less: "cmod (u - w) < e * (d/2) ^ (k+2) / (1 + real k)" - for u x - proof - - define ff where [abs_def]: - "ff n w = - (if n = 0 then inverse(x - w)^k - else if n = 1 then k / (x - w)^(Suc k) - else (k * of_real(Suc k)) / (x - w)^(k + 2))" for n :: nat and w - have km1: "\z::complex. z \ 0 \ z ^ (k - Suc 0) = z ^ k / z" - by (simp add: field_simps) (metis Suc_pred \k \ 0\ neq0_conv power_Suc) - have ff1: "(ff i has_field_derivative ff (Suc i) z) (at z within ball w (d/2))" - if "z \ ball w (d/2)" "i \ 1" for i z - proof - - have "z \ path_image \" - using \x \ path_image \\ d that ball_divide_subset_numeral by blast - then have xz[simp]: "x \ z" using \x \ path_image \\ by blast - then have neq: "x * x + z * z \ x * (z * 2)" - by (blast intro: dest!: sum_sqs_eq) - with xz have "\v. v \ 0 \ (x * x + z * z) * v \ (x * (z * 2) * v)" by auto - then have neqq: "\v. v \ 0 \ x * (x * v) + z * (z * v) \ x * (z * (2 * v))" - by (simp add: algebra_simps) - show ?thesis using \i \ 1\ - apply (simp add: ff_def dist_norm Nat.le_Suc_eq km1, safe) - apply (rule derivative_eq_intros | simp add: km1 | simp add: field_simps neq neqq)+ - done - qed - { fix a::real and b::real assume ab: "a > 0" "b > 0" - then have "k * (1 + real k) * (1 / a) \ k * (1 + real k) * (4 / b) \ b \ 4 * a" - by (subst mult_le_cancel_left_pos) - (use \k \ 0\ in \auto simp: divide_simps\) - with ab have "real k * (1 + real k) / a \ (real k * 4 + real k * real k * 4) / b \ b \ 4 * a" - by (simp add: field_simps) - } note canc = this - have ff2: "cmod (ff (Suc 1) v) \ real (k * (k + 1)) / (d/2) ^ (k + 2)" - if "v \ ball w (d/2)" for v - proof - - have lessd: "\z. cmod (\ z - v) < d/2 \ cmod (w - \ z) < d" - by (metis that norm_minus_commute norm_triangle_half_r dist_norm mem_ball) - have "d/2 \ cmod (x - v)" using d x that - using lessd d x - by (auto simp add: dist_norm path_image_def ball_def not_less [symmetric] del: divide_const_simps) - then have "d \ cmod (x - v) * 2" - by (simp add: field_split_simps) - then have dpow_le: "d ^ (k+2) \ (cmod (x - v) * 2) ^ (k+2)" - using \0 < d\ order_less_imp_le power_mono by blast - have "x \ v" using that - using \x \ path_image \\ ball_divide_subset_numeral d by fastforce - then show ?thesis - using \d > 0\ apply (simp add: ff_def norm_mult norm_divide norm_power dist_norm canc) - using dpow_le apply (simp add: field_split_simps) - done - qed - have ub: "u \ ball w (d/2)" - using uwd by (simp add: dist_commute dist_norm) - have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) - \ (real k * 4 + real k * real k * 4) * (cmod (u - w) * cmod (u - w)) / (d * (d * (d/2) ^ k))" - using complex_Taylor [OF _ ff1 ff2 _ ub, of w, simplified] - by (simp add: ff_def \0 < d\) - then have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) - \ (cmod (u - w) * real k) * (1 + real k) * cmod (u - w) / (d/2) ^ (k+2)" - by (simp add: field_simps) - then have "cmod (inverse (x - u) ^ k - (inverse (x - w) ^ k + of_nat k * (u - w) / ((x - w) * (x - w) ^ k))) - / (cmod (u - w) * real k) - \ (1 + real k) * cmod (u - w) / (d/2) ^ (k+2)" - using \k \ 0\ \u \ w\ by (simp add: mult_ac zero_less_mult_iff pos_divide_le_eq) - also have "\ < e" - using uw_less \0 < d\ by (simp add: mult_ac divide_simps) - finally have e: "cmod (inverse (x-u)^k - (inverse (x-w)^k + of_nat k * (u-w) / ((x-w) * (x-w)^k))) - / cmod ((u - w) * real k) < e" - by (simp add: norm_mult) - have "x \ u" - using uwd \0 < d\ x d by (force simp: dist_norm ball_def norm_minus_commute) - show ?thesis - apply (rule le_less_trans [OF _ e]) - using \k \ 0\ \x \ u\ \u \ w\ - apply (simp add: field_simps norm_divide [symmetric]) - done - qed - show ?thesis - unfolding eventually_at - apply (rule_tac x = "min (d/2) ((e*(d/2)^(k + 2))/(Suc k))" in exI) - apply (force simp: \d > 0\ dist_norm that simp del: power_Suc intro: *) - done - qed - have 2: "uniform_limit (path_image \) (\n x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k) (\x. f' x / (x - w) ^ Suc k) (at w)" - unfolding uniform_limit_iff dist_norm - proof clarify - fix e::real - assume "0 < e" - have *: "cmod (f' (\ x) * (inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - - f' (\ x) / ((\ x - w) * (\ x - w) ^ k)) < e" - if ec: "cmod ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - - inverse (\ x - w) * inverse (\ x - w) ^ k) < e / C" - and x: "0 \ x" "x \ 1" - for u x - proof (cases "(f' (\ x)) = 0") - case True then show ?thesis by (simp add: \0 < e\) - next - case False - have "cmod (f' (\ x) * (inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - - f' (\ x) / ((\ x - w) * (\ x - w) ^ k)) = - cmod (f' (\ x) * ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - - inverse (\ x - w) * inverse (\ x - w) ^ k))" - by (simp add: field_simps) - also have "\ = cmod (f' (\ x)) * - cmod ((inverse (\ x - u) ^ k - inverse (\ x - w) ^ k) / ((u - w) * k) - - inverse (\ x - w) * inverse (\ x - w) ^ k)" - by (simp add: norm_mult) - also have "\ < cmod (f' (\ x)) * (e/C)" - using False mult_strict_left_mono [OF ec] by force - also have "\ \ e" using C - by (metis False \0 < e\ frac_le less_eq_real_def mult.commute pos_le_divide_eq x zero_less_norm_iff) - finally show ?thesis . - qed - show "\\<^sub>F n in at w. - \x\path_image \. - cmod (f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / of_nat k - f' x / (x - w) ^ Suc k) < e" - using twom [OF divide_pos_pos [OF \0 < e\ \C > 0\]] unfolding path_image_def - by (force intro: * elim: eventually_mono) - qed - show "(\u. f' u / (u - w) ^ (Suc k)) contour_integrable_on \" - by (rule contour_integral_uniform_limit [OF 1 2 leB \]) auto - have *: "(\n. contour_integral \ (\x. f' x * (inverse (x - n) ^ k - inverse (x - w) ^ k) / (n - w) / k)) - \w\ contour_integral \ (\u. f' u / (u - w) ^ (Suc k))" - by (rule contour_integral_uniform_limit [OF 1 2 leB \]) auto - have **: "contour_integral \ (\x. f' x * (inverse (x - u) ^ k - inverse (x - w) ^ k) / ((u - w) * k)) = - (f u - f w) / (u - w) / k" - if "dist u w < d" for u - proof - - have u: "u \ s - path_image \" - by (metis subsetD d dist_commute mem_ball that) - show ?thesis - apply (rule contour_integral_unique) - apply (simp add: diff_divide_distrib algebra_simps) - apply (intro has_contour_integral_diff has_contour_integral_div) - using u w apply (simp_all add: field_simps int) - done - qed - show ?thes2 - apply (simp add: has_field_derivative_iff del: power_Suc) - apply (rule Lim_transform_within [OF tendsto_mult_left [OF *] \0 < d\ ]) - apply (simp add: \k \ 0\ **) - done -qed - -lemma Cauchy_next_derivative_circlepath: - assumes contf: "continuous_on (path_image (circlepath z r)) f" - and int: "\w. w \ ball z r \ ((\u. f u / (u - w)^k) has_contour_integral g w) (circlepath z r)" - and k: "k \ 0" - and w: "w \ ball z r" - shows "(\u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)" - (is "?thes1") - and "(g has_field_derivative (k * contour_integral (circlepath z r) (\u. f u/(u - w)^(Suc k)))) (at w)" - (is "?thes2") -proof - - have "r > 0" using w - using ball_eq_empty by fastforce - have wim: "w \ ball z r - path_image (circlepath z r)" - using w by (auto simp: dist_norm) - show ?thes1 ?thes2 - by (rule Cauchy_next_derivative [OF contf _ int k open_ball valid_path_circlepath wim, where B = "2 * pi * \r\"]; - auto simp: vector_derivative_circlepath norm_mult)+ -qed - - -text\ In particular, the first derivative formula.\ - -lemma Cauchy_derivative_integral_circlepath: - assumes contf: "continuous_on (cball z r) f" - and holf: "f holomorphic_on ball z r" - and w: "w \ ball z r" - shows "(\u. f u/(u - w)^2) contour_integrable_on (circlepath z r)" - (is "?thes1") - and "(f has_field_derivative (1 / (2 * of_real pi * \) * contour_integral(circlepath z r) (\u. f u / (u - w)^2))) (at w)" - (is "?thes2") -proof - - have [simp]: "r \ 0" using w - using ball_eq_empty by fastforce - have f: "continuous_on (path_image (circlepath z r)) f" - by (rule continuous_on_subset [OF contf]) (force simp: cball_def sphere_def) - have int: "\w. dist z w < r \ - ((\u. f u / (u - w)) has_contour_integral (\x. 2 * of_real pi * \ * f x) w) (circlepath z r)" - by (rule Cauchy_integral_circlepath [OF contf holf]) (simp add: dist_norm norm_minus_commute) - show ?thes1 - apply (simp add: power2_eq_square) - apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1, simplified]) - apply (blast intro: int) - done - have "((\x. 2 * of_real pi * \ * f x) has_field_derivative contour_integral (circlepath z r) (\u. f u / (u - w)^2)) (at w)" - apply (simp add: power2_eq_square) - apply (rule Cauchy_next_derivative_circlepath [OF f _ _ w, where k=1 and g = "\x. 2 * of_real pi * \ * f x", simplified]) - apply (blast intro: int) - done - then have fder: "(f has_field_derivative contour_integral (circlepath z r) (\u. f u / (u - w)^2) / (2 * of_real pi * \)) (at w)" - by (rule DERIV_cdivide [where f = "\x. 2 * of_real pi * \ * f x" and c = "2 * of_real pi * \", simplified]) - show ?thes2 - by simp (rule fder) -qed - -subsection\Existence of all higher derivatives\ - -proposition derivative_is_holomorphic: - assumes "open S" - and fder: "\z. z \ S \ (f has_field_derivative f' z) (at z)" - shows "f' holomorphic_on S" -proof - - have *: "\h. (f' has_field_derivative h) (at z)" if "z \ S" for z - proof - - obtain r where "r > 0" and r: "cball z r \ S" - using open_contains_cball \z \ S\ \open S\ by blast - then have holf_cball: "f holomorphic_on cball z r" - apply (simp add: holomorphic_on_def) - using field_differentiable_at_within field_differentiable_def fder by blast - then have "continuous_on (path_image (circlepath z r)) f" - using \r > 0\ by (force elim: holomorphic_on_subset [THEN holomorphic_on_imp_continuous_on]) - then have contfpi: "continuous_on (path_image (circlepath z r)) (\x. 1/(2 * of_real pi*\) * f x)" - by (auto intro: continuous_intros)+ - have contf_cball: "continuous_on (cball z r) f" using holf_cball - by (simp add: holomorphic_on_imp_continuous_on holomorphic_on_subset) - have holf_ball: "f holomorphic_on ball z r" using holf_cball - using ball_subset_cball holomorphic_on_subset by blast - { fix w assume w: "w \ ball z r" - have intf: "(\u. f u / (u - w)\<^sup>2) contour_integrable_on circlepath z r" - by (blast intro: w Cauchy_derivative_integral_circlepath [OF contf_cball holf_ball]) - have fder': "(f has_field_derivative 1 / (2 * of_real pi * \) * contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2)) - (at w)" - by (blast intro: w Cauchy_derivative_integral_circlepath [OF contf_cball holf_ball]) - have f'_eq: "f' w = contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)" - using fder' ball_subset_cball r w by (force intro: DERIV_unique [OF fder]) - have "((\u. f u / (u - w)\<^sup>2 / (2 * of_real pi * \)) has_contour_integral - contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)) - (circlepath z r)" - by (rule has_contour_integral_div [OF has_contour_integral_integral [OF intf]]) - then have "((\u. f u / (2 * of_real pi * \ * (u - w)\<^sup>2)) has_contour_integral - contour_integral (circlepath z r) (\u. f u / (u - w)\<^sup>2) / (2 * of_real pi * \)) - (circlepath z r)" - by (simp add: algebra_simps) - then have "((\u. f u / (2 * of_real pi * \ * (u - w)\<^sup>2)) has_contour_integral f' w) (circlepath z r)" - by (simp add: f'_eq) - } note * = this - show ?thesis - apply (rule exI) - apply (rule Cauchy_next_derivative_circlepath [OF contfpi, of 2 f', simplified]) - apply (simp_all add: \0 < r\ * dist_norm) - done - qed - show ?thesis - by (simp add: holomorphic_on_open [OF \open S\] *) -qed - -lemma holomorphic_deriv [holomorphic_intros]: - "\f holomorphic_on S; open S\ \ (deriv f) holomorphic_on S" -by (metis DERIV_deriv_iff_field_differentiable at_within_open derivative_is_holomorphic holomorphic_on_def) - -lemma analytic_deriv [analytic_intros]: "f analytic_on S \ (deriv f) analytic_on S" - using analytic_on_holomorphic holomorphic_deriv by auto - -lemma holomorphic_higher_deriv [holomorphic_intros]: "\f holomorphic_on S; open S\ \ (deriv ^^ n) f holomorphic_on S" - by (induction n) (auto simp: holomorphic_deriv) - -lemma analytic_higher_deriv [analytic_intros]: "f analytic_on S \ (deriv ^^ n) f analytic_on S" - unfolding analytic_on_def using holomorphic_higher_deriv by blast - -lemma has_field_derivative_higher_deriv: - "\f holomorphic_on S; open S; x \ S\ - \ ((deriv ^^ n) f has_field_derivative (deriv ^^ (Suc n)) f x) (at x)" -by (metis (no_types, hide_lams) DERIV_deriv_iff_field_differentiable at_within_open comp_apply - funpow.simps(2) holomorphic_higher_deriv holomorphic_on_def) - -lemma valid_path_compose_holomorphic: - assumes "valid_path g" and holo:"f holomorphic_on S" and "open S" "path_image g \ S" - shows "valid_path (f \ g)" -proof (rule valid_path_compose[OF \valid_path g\]) - fix x assume "x \ path_image g" - then show "f field_differentiable at x" - using analytic_on_imp_differentiable_at analytic_on_open assms holo by blast -next - have "deriv f holomorphic_on S" - using holomorphic_deriv holo \open S\ by auto - then show "continuous_on (path_image g) (deriv f)" - using assms(4) holomorphic_on_imp_continuous_on holomorphic_on_subset by auto -qed - - -subsection\Morera's theorem\ - -lemma Morera_local_triangle_ball: - assumes "\z. z \ S - \ \e a. 0 < e \ z \ ball a e \ continuous_on (ball a e) f \ - (\b c. closed_segment b c \ ball a e - \ contour_integral (linepath a b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c a) f = 0)" - shows "f analytic_on S" -proof - - { fix z assume "z \ S" - with assms obtain e a where - "0 < e" and z: "z \ ball a e" and contf: "continuous_on (ball a e) f" - and 0: "\b c. closed_segment b c \ ball a e - \ contour_integral (linepath a b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c a) f = 0" - by blast - have az: "dist a z < e" using mem_ball z by blast - have sb_ball: "ball z (e - dist a z) \ ball a e" - by (simp add: dist_commute ball_subset_ball_iff) - have "\e>0. f holomorphic_on ball z e" - proof (intro exI conjI) - have sub_ball: "\y. dist a y < e \ closed_segment a y \ ball a e" - by (meson \0 < e\ centre_in_ball convex_ball convex_contains_segment mem_ball) - show "f holomorphic_on ball z (e - dist a z)" - apply (rule holomorphic_on_subset [OF _ sb_ball]) - apply (rule derivative_is_holomorphic[OF open_ball]) - apply (rule triangle_contour_integrals_starlike_primitive [OF contf _ open_ball, of a]) - apply (simp_all add: 0 \0 < e\ sub_ball) - done - qed (simp add: az) - } - then show ?thesis - by (simp add: analytic_on_def) -qed - -lemma Morera_local_triangle: - assumes "\z. z \ S - \ \t. open t \ z \ t \ continuous_on t f \ - (\a b c. convex hull {a,b,c} \ t - \ contour_integral (linepath a b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c a) f = 0)" - shows "f analytic_on S" -proof - - { fix z assume "z \ S" - with assms obtain t where - "open t" and z: "z \ t" and contf: "continuous_on t f" - and 0: "\a b c. convex hull {a,b,c} \ t - \ contour_integral (linepath a b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c a) f = 0" - by force - then obtain e where "e>0" and e: "ball z e \ t" - using open_contains_ball by blast - have [simp]: "continuous_on (ball z e) f" using contf - using continuous_on_subset e by blast - have eq0: "\b c. closed_segment b c \ ball z e \ - contour_integral (linepath z b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c z) f = 0" - by (meson 0 z \0 < e\ centre_in_ball closed_segment_subset convex_ball dual_order.trans e starlike_convex_subset) - have "\e a. 0 < e \ z \ ball a e \ continuous_on (ball a e) f \ - (\b c. closed_segment b c \ ball a e \ - contour_integral (linepath a b) f + contour_integral (linepath b c) f + contour_integral (linepath c a) f = 0)" - using \e > 0\ eq0 by force - } - then show ?thesis - by (simp add: Morera_local_triangle_ball) -qed - -proposition Morera_triangle: - "\continuous_on S f; open S; - \a b c. convex hull {a,b,c} \ S - \ contour_integral (linepath a b) f + - contour_integral (linepath b c) f + - contour_integral (linepath c a) f = 0\ - \ f analytic_on S" - using Morera_local_triangle by blast - -subsection\Combining theorems for higher derivatives including Leibniz rule\ - -lemma higher_deriv_linear [simp]: - "(deriv ^^ n) (\w. c*w) = (\z. if n = 0 then c*z else if n = 1 then c else 0)" - by (induction n) auto - -lemma higher_deriv_const [simp]: "(deriv ^^ n) (\w. c) = (\w. if n=0 then c else 0)" - by (induction n) auto - -lemma higher_deriv_ident [simp]: - "(deriv ^^ n) (\w. w) z = (if n = 0 then z else if n = 1 then 1 else 0)" - apply (induction n, simp) - apply (metis higher_deriv_linear lambda_one) - done - -lemma higher_deriv_id [simp]: - "(deriv ^^ n) id z = (if n = 0 then z else if n = 1 then 1 else 0)" - by (simp add: id_def) - -lemma has_complex_derivative_funpow_1: - "\(f has_field_derivative 1) (at z); f z = z\ \ (f^^n has_field_derivative 1) (at z)" - apply (induction n, auto) - apply (simp add: id_def) - by (metis DERIV_chain comp_funpow comp_id funpow_swap1 mult.right_neutral) - -lemma higher_deriv_uminus: - assumes "f holomorphic_on S" "open S" and z: "z \ S" - shows "(deriv ^^ n) (\w. -(f w)) z = - ((deriv ^^ n) f z)" -using z -proof (induction n arbitrary: z) - case 0 then show ?case by simp -next - case (Suc n z) - have *: "((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" - using Suc.prems assms has_field_derivative_higher_deriv by auto - have "((deriv ^^ n) (\w. - f w) has_field_derivative - deriv ((deriv ^^ n) f) z) (at z)" - apply (rule has_field_derivative_transform_within_open [of "\w. -((deriv ^^ n) f w)"]) - apply (rule derivative_eq_intros | rule * refl assms)+ - apply (auto simp add: Suc) - done - then show ?case - by (simp add: DERIV_imp_deriv) -qed - -lemma higher_deriv_add: - fixes z::complex - assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" - shows "(deriv ^^ n) (\w. f w + g w) z = (deriv ^^ n) f z + (deriv ^^ n) g z" -using z -proof (induction n arbitrary: z) - case 0 then show ?case by simp -next - case (Suc n z) - have *: "((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" - "((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z)" - using Suc.prems assms has_field_derivative_higher_deriv by auto - have "((deriv ^^ n) (\w. f w + g w) has_field_derivative - deriv ((deriv ^^ n) f) z + deriv ((deriv ^^ n) g) z) (at z)" - apply (rule has_field_derivative_transform_within_open [of "\w. (deriv ^^ n) f w + (deriv ^^ n) g w"]) - apply (rule derivative_eq_intros | rule * refl assms)+ - apply (auto simp add: Suc) - done - then show ?case - by (simp add: DERIV_imp_deriv) -qed - -lemma higher_deriv_diff: - fixes z::complex - assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" - shows "(deriv ^^ n) (\w. f w - g w) z = (deriv ^^ n) f z - (deriv ^^ n) g z" - apply (simp only: Groups.group_add_class.diff_conv_add_uminus higher_deriv_add) - apply (subst higher_deriv_add) - using assms holomorphic_on_minus apply (auto simp: higher_deriv_uminus) - done - -lemma bb: "Suc n choose k = (n choose k) + (if k = 0 then 0 else (n choose (k - 1)))" - by (cases k) simp_all - -lemma higher_deriv_mult: - fixes z::complex - assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" - shows "(deriv ^^ n) (\w. f w * g w) z = - (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)" -using z -proof (induction n arbitrary: z) - case 0 then show ?case by simp -next - case (Suc n z) - have *: "\n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)" - "\n. ((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z)" - using Suc.prems assms has_field_derivative_higher_deriv by auto - have sumeq: "(\i = 0..n. - of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) = - g z * deriv ((deriv ^^ n) f) z + (\i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))" - apply (simp add: bb algebra_simps sum.distrib) - apply (subst (4) sum_Suc_reindex) - apply (auto simp: algebra_simps Suc_diff_le intro: sum.cong) - done - have "((deriv ^^ n) (\w. f w * g w) has_field_derivative - (\i = 0..Suc n. (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) - (at z)" - apply (rule has_field_derivative_transform_within_open - [of "\w. (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f w * (deriv ^^ (n - i)) g w)"]) - apply (simp add: algebra_simps) - apply (rule DERIV_cong [OF DERIV_sum]) - apply (rule DERIV_cmult) - apply (auto intro: DERIV_mult * sumeq \open S\ Suc.prems Suc.IH [symmetric]) - done - then show ?case - unfolding funpow.simps o_apply - by (simp add: DERIV_imp_deriv) -qed - -lemma higher_deriv_transform_within_open: - fixes z::complex - assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \ S" - and fg: "\w. w \ S \ f w = g w" - shows "(deriv ^^ i) f z = (deriv ^^ i) g z" -using z -by (induction i arbitrary: z) - (auto simp: fg intro: complex_derivative_transform_within_open holomorphic_higher_deriv assms) - -lemma higher_deriv_compose_linear: - fixes z::complex - assumes f: "f holomorphic_on T" and S: "open S" and T: "open T" and z: "z \ S" - and fg: "\w. w \ S \ u * w \ T" - shows "(deriv ^^ n) (\w. f (u * w)) z = u^n * (deriv ^^ n) f (u * z)" -using z -proof (induction n arbitrary: z) - case 0 then show ?case by simp -next - case (Suc n z) - have holo0: "f holomorphic_on (*) u ` S" - by (meson fg f holomorphic_on_subset image_subset_iff) - have holo2: "(deriv ^^ n) f holomorphic_on (*) u ` S" - by (meson f fg holomorphic_higher_deriv holomorphic_on_subset image_subset_iff T) - have holo3: "(\z. u ^ n * (deriv ^^ n) f (u * z)) holomorphic_on S" - by (intro holo2 holomorphic_on_compose [where g="(deriv ^^ n) f", unfolded o_def] holomorphic_intros) - have holo1: "(\w. f (u * w)) holomorphic_on S" - apply (rule holomorphic_on_compose [where g=f, unfolded o_def]) - apply (rule holo0 holomorphic_intros)+ - done - have "deriv ((deriv ^^ n) (\w. f (u * w))) z = deriv (\z. u^n * (deriv ^^ n) f (u*z)) z" - apply (rule complex_derivative_transform_within_open [OF _ holo3 S Suc.prems]) - apply (rule holomorphic_higher_deriv [OF holo1 S]) - apply (simp add: Suc.IH) - done - also have "\ = u^n * deriv (\z. (deriv ^^ n) f (u * z)) z" - apply (rule deriv_cmult) - apply (rule analytic_on_imp_differentiable_at [OF _ Suc.prems]) - apply (rule analytic_on_compose_gen [where g="(deriv ^^ n) f" and T=T, unfolded o_def]) - apply (simp) - apply (simp add: analytic_on_open f holomorphic_higher_deriv T) - apply (blast intro: fg) - done - also have "\ = u * u ^ n * deriv ((deriv ^^ n) f) (u * z)" - apply (subst deriv_chain [where g = "(deriv ^^ n) f" and f = "(*) u", unfolded o_def]) - apply (rule derivative_intros) - using Suc.prems field_differentiable_def f fg has_field_derivative_higher_deriv T apply blast - apply (simp) - done - finally show ?case - by simp -qed - -lemma higher_deriv_add_at: - assumes "f analytic_on {z}" "g analytic_on {z}" - shows "(deriv ^^ n) (\w. f w + g w) z = (deriv ^^ n) f z + (deriv ^^ n) g z" -proof - - have "f analytic_on {z} \ g analytic_on {z}" - using assms by blast - with higher_deriv_add show ?thesis - by (auto simp: analytic_at_two) -qed - -lemma higher_deriv_diff_at: - assumes "f analytic_on {z}" "g analytic_on {z}" - shows "(deriv ^^ n) (\w. f w - g w) z = (deriv ^^ n) f z - (deriv ^^ n) g z" -proof - - have "f analytic_on {z} \ g analytic_on {z}" - using assms by blast - with higher_deriv_diff show ?thesis - by (auto simp: analytic_at_two) -qed - -lemma higher_deriv_uminus_at: - "f analytic_on {z} \ (deriv ^^ n) (\w. -(f w)) z = - ((deriv ^^ n) f z)" - using higher_deriv_uminus - by (auto simp: analytic_at) - -lemma higher_deriv_mult_at: - assumes "f analytic_on {z}" "g analytic_on {z}" - shows "(deriv ^^ n) (\w. f w * g w) z = - (\i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)" -proof - - have "f analytic_on {z} \ g analytic_on {z}" - using assms by blast - with higher_deriv_mult show ?thesis - by (auto simp: analytic_at_two) -qed - - -text\ Nonexistence of isolated singularities and a stronger integral formula.\ - -proposition no_isolated_singularity: - fixes z::complex - assumes f: "continuous_on S f" and holf: "f holomorphic_on (S - K)" and S: "open S" and K: "finite K" - shows "f holomorphic_on S" -proof - - { fix z - assume "z \ S" and cdf: "\x. x \ S - K \ f field_differentiable at x" - have "f field_differentiable at z" - proof (cases "z \ K") - case False then show ?thesis by (blast intro: cdf \z \ S\) - next - case True - with finite_set_avoid [OF K, of z] - obtain d where "d>0" and d: "\x. \x\K; x \ z\ \ d \ dist z x" - by blast - obtain e where "e>0" and e: "ball z e \ S" - using S \z \ S\ by (force simp: open_contains_ball) - have fde: "continuous_on (ball z (min d e)) f" - by (metis Int_iff ball_min_Int continuous_on_subset e f subsetI) - have cont: "{a,b,c} \ ball z (min d e) \ continuous_on (convex hull {a, b, c}) f" for a b c - by (simp add: hull_minimal continuous_on_subset [OF fde]) - have fd: "\{a,b,c} \ ball z (min d e); x \ interior (convex hull {a, b, c}) - K\ - \ f field_differentiable at x" for a b c x - by (metis cdf Diff_iff Int_iff ball_min_Int subsetD convex_ball e interior_mono interior_subset subset_hull) - obtain g where "\w. w \ ball z (min d e) \ (g has_field_derivative f w) (at w within ball z (min d e))" - apply (rule contour_integral_convex_primitive - [OF convex_ball fde Cauchy_theorem_triangle_cofinite [OF _ K]]) - using cont fd by auto - then have "f holomorphic_on ball z (min d e)" - by (metis open_ball at_within_open derivative_is_holomorphic) - then show ?thesis - unfolding holomorphic_on_def - by (metis open_ball \0 < d\ \0 < e\ at_within_open centre_in_ball min_less_iff_conj) - qed - } - with holf S K show ?thesis - by (simp add: holomorphic_on_open open_Diff finite_imp_closed field_differentiable_def [symmetric]) -qed - -lemma no_isolated_singularity': - fixes z::complex - assumes f: "\z. z \ K \ (f \ f z) (at z within S)" - and holf: "f holomorphic_on (S - K)" and S: "open S" and K: "finite K" - shows "f holomorphic_on S" -proof (rule no_isolated_singularity[OF _ assms(2-)]) - show "continuous_on S f" unfolding continuous_on_def - proof - fix z assume z: "z \ S" - show "(f \ f z) (at z within S)" - proof (cases "z \ K") - case False - from holf have "continuous_on (S - K) f" - by (rule holomorphic_on_imp_continuous_on) - with z False have "(f \ f z) (at z within (S - K))" - by (simp add: continuous_on_def) - also from z K S False have "at z within (S - K) = at z within S" - by (subst (1 2) at_within_open) (auto intro: finite_imp_closed) - finally show "(f \ f z) (at z within S)" . - qed (insert assms z, simp_all) - qed -qed - -proposition Cauchy_integral_formula_convex: - assumes S: "convex S" and K: "finite K" and contf: "continuous_on S f" - and fcd: "(\x. x \ interior S - K \ f field_differentiable at x)" - and z: "z \ interior S" and vpg: "valid_path \" - and pasz: "path_image \ \ S - {z}" and loop: "pathfinish \ = pathstart \" - shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" -proof - - have *: "\x. x \ interior S \ f field_differentiable at x" - unfolding holomorphic_on_open [symmetric] field_differentiable_def - using no_isolated_singularity [where S = "interior S"] - by (meson K contf continuous_at_imp_continuous_on continuous_on_interior fcd - field_differentiable_at_within field_differentiable_def holomorphic_onI - holomorphic_on_imp_differentiable_at open_interior) - show ?thesis - by (rule Cauchy_integral_formula_weak [OF S finite.emptyI contf]) (use * assms in auto) -qed - -text\ Formula for higher derivatives.\ - -lemma Cauchy_has_contour_integral_higher_derivative_circlepath: - assumes contf: "continuous_on (cball z r) f" - and holf: "f holomorphic_on ball z r" - and w: "w \ ball z r" - shows "((\u. f u / (u - w) ^ (Suc k)) has_contour_integral ((2 * pi * \) / (fact k) * (deriv ^^ k) f w)) - (circlepath z r)" -using w -proof (induction k arbitrary: w) - case 0 then show ?case - using assms by (auto simp: Cauchy_integral_circlepath dist_commute dist_norm) -next - case (Suc k) - have [simp]: "r > 0" using w - using ball_eq_empty by fastforce - have f: "continuous_on (path_image (circlepath z r)) f" - by (rule continuous_on_subset [OF contf]) (force simp: cball_def sphere_def less_imp_le) - obtain X where X: "((\u. f u / (u - w) ^ Suc (Suc k)) has_contour_integral X) (circlepath z r)" - using Cauchy_next_derivative_circlepath(1) [OF f Suc.IH _ Suc.prems] - by (auto simp: contour_integrable_on_def) - then have con: "contour_integral (circlepath z r) ((\u. f u / (u - w) ^ Suc (Suc k))) = X" - by (rule contour_integral_unique) - have "\n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) w) (at w)" - using Suc.prems assms has_field_derivative_higher_deriv by auto - then have dnf_diff: "\n. (deriv ^^ n) f field_differentiable (at w)" - by (force simp: field_differentiable_def) - have "deriv (\w. complex_of_real (2 * pi) * \ / (fact k) * (deriv ^^ k) f w) w = - of_nat (Suc k) * contour_integral (circlepath z r) (\u. f u / (u - w) ^ Suc (Suc k))" - by (force intro!: DERIV_imp_deriv Cauchy_next_derivative_circlepath [OF f Suc.IH _ Suc.prems]) - also have "\ = of_nat (Suc k) * X" - by (simp only: con) - finally have "deriv (\w. ((2 * pi) * \ / (fact k)) * (deriv ^^ k) f w) w = of_nat (Suc k) * X" . - then have "((2 * pi) * \ / (fact k)) * deriv (\w. (deriv ^^ k) f w) w = of_nat (Suc k) * X" - by (metis deriv_cmult dnf_diff) - then have "deriv (\w. (deriv ^^ k) f w) w = of_nat (Suc k) * X / ((2 * pi) * \ / (fact k))" - by (simp add: field_simps) - then show ?case - using of_nat_eq_0_iff X by fastforce -qed - -lemma Cauchy_higher_derivative_integral_circlepath: - assumes contf: "continuous_on (cball z r) f" - and holf: "f holomorphic_on ball z r" - and w: "w \ ball z r" - shows "(\u. f u / (u - w)^(Suc k)) contour_integrable_on (circlepath z r)" - (is "?thes1") - and "(deriv ^^ k) f w = (fact k) / (2 * pi * \) * contour_integral(circlepath z r) (\u. f u/(u - w)^(Suc k))" - (is "?thes2") -proof - - have *: "((\u. f u / (u - w) ^ Suc k) has_contour_integral (2 * pi) * \ / (fact k) * (deriv ^^ k) f w) - (circlepath z r)" - using Cauchy_has_contour_integral_higher_derivative_circlepath [OF assms] - by simp - show ?thes1 using * - using contour_integrable_on_def by blast - show ?thes2 - unfolding contour_integral_unique [OF *] by (simp add: field_split_simps) -qed - -corollary Cauchy_contour_integral_circlepath: - assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \ ball z r" - shows "contour_integral(circlepath z r) (\u. f u/(u - w)^(Suc k)) = (2 * pi * \) * (deriv ^^ k) f w / (fact k)" -by (simp add: Cauchy_higher_derivative_integral_circlepath [OF assms]) - -lemma Cauchy_contour_integral_circlepath_2: - assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \ ball z r" - shows "contour_integral(circlepath z r) (\u. f u/(u - w)^2) = (2 * pi * \) * deriv f w" - using Cauchy_contour_integral_circlepath [OF assms, of 1] - by (simp add: power2_eq_square) - - -subsection\A holomorphic function is analytic, i.e. has local power series\ - -theorem holomorphic_power_series: - assumes holf: "f holomorphic_on ball z r" - and w: "w \ ball z r" - shows "((\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" -proof - - \ \Replacing \<^term>\r\ and the original (weak) premises with stronger ones\ - obtain r where "r > 0" and holfc: "f holomorphic_on cball z r" and w: "w \ ball z r" - proof - have "cball z ((r + dist w z) / 2) \ ball z r" - using w by (simp add: dist_commute field_sum_of_halves subset_eq) - then show "f holomorphic_on cball z ((r + dist w z) / 2)" - by (rule holomorphic_on_subset [OF holf]) - have "r > 0" - using w by clarsimp (metis dist_norm le_less_trans norm_ge_zero) - then show "0 < (r + dist w z) / 2" - by simp (use zero_le_dist [of w z] in linarith) - qed (use w in \auto simp: dist_commute\) - then have holf: "f holomorphic_on ball z r" - using ball_subset_cball holomorphic_on_subset by blast - have contf: "continuous_on (cball z r) f" - by (simp add: holfc holomorphic_on_imp_continuous_on) - have cint: "\k. (\u. f u / (u - z) ^ Suc k) contour_integrable_on circlepath z r" - by (rule Cauchy_higher_derivative_integral_circlepath [OF contf holf]) (simp add: \0 < r\) - obtain B where "0 < B" and B: "\u. u \ cball z r \ norm(f u) \ B" - by (metis (no_types) bounded_pos compact_cball compact_continuous_image compact_imp_bounded contf image_eqI) - obtain k where k: "0 < k" "k \ r" and wz_eq: "norm(w - z) = r - k" - and kle: "\u. norm(u - z) = r \ k \ norm(u - w)" - proof - show "\u. cmod (u - z) = r \ r - dist z w \ cmod (u - w)" - by (metis add_diff_eq diff_add_cancel dist_norm norm_diff_ineq) - qed (use w in \auto simp: dist_norm norm_minus_commute\) - have ul: "uniform_limit (sphere z r) (\n x. (\kx. f x / (x - w)) sequentially" - unfolding uniform_limit_iff dist_norm - proof clarify - fix e::real - assume "0 < e" - have rr: "0 \ (r - k) / r" "(r - k) / r < 1" using k by auto - obtain n where n: "((r - k) / r) ^ n < e / B * k" - using real_arch_pow_inv [of "e/B*k" "(r - k)/r"] \0 < e\ \0 < B\ k by force - have "norm ((\k N" and r: "r = dist z u" for N u - proof - - have N: "((r - k) / r) ^ N < e / B * k" - apply (rule le_less_trans [OF power_decreasing n]) - using \n \ N\ k by auto - have u [simp]: "(u \ z) \ (u \ w)" - using \0 < r\ r w by auto - have wzu_not1: "(w - z) / (u - z) \ 1" - by (metis (no_types) dist_norm divide_eq_1_iff less_irrefl mem_ball norm_minus_commute r w) - have "norm ((\kk = norm ((((w - z) / (u - z)) ^ N - 1) * (u - w) / (((w - z) / (u - z) - 1) * (u - z)) - 1) * norm (f u)" - using \0 < B\ - apply (auto simp: geometric_sum [OF wzu_not1]) - apply (simp add: field_simps norm_mult [symmetric]) - done - also have "\ = norm ((u-z) ^ N * (w - u) - ((w - z) ^ N - (u-z) ^ N) * (u-w)) / (r ^ N * norm (u-w)) * norm (f u)" - using \0 < r\ r by (simp add: divide_simps norm_mult norm_divide norm_power dist_norm norm_minus_commute) - also have "\ = norm ((w - z) ^ N * (w - u)) / (r ^ N * norm (u - w)) * norm (f u)" - by (simp add: algebra_simps) - also have "\ = norm (w - z) ^ N * norm (f u) / r ^ N" - by (simp add: norm_mult norm_power norm_minus_commute) - also have "\ \ (((r - k)/r)^N) * B" - using \0 < r\ w k - apply (simp add: divide_simps) - apply (rule mult_mono [OF power_mono]) - apply (auto simp: norm_divide wz_eq norm_power dist_norm norm_minus_commute B r) - done - also have "\ < e * k" - using \0 < B\ N by (simp add: divide_simps) - also have "\ \ e * norm (u - w)" - using r kle \0 < e\ by (simp add: dist_commute dist_norm) - finally show ?thesis - by (simp add: field_split_simps norm_divide del: power_Suc) - qed - with \0 < r\ show "\\<^sub>F n in sequentially. \x\sphere z r. - norm ((\k\<^sub>F x in sequentially. - contour_integral (circlepath z r) (\u. \kku. f u / (u - z) ^ Suc k) * (w - z) ^ k)" - apply (rule eventuallyI) - apply (subst contour_integral_sum, simp) - using contour_integrable_lmul [OF cint, of "(w - z) ^ a" for a] apply (simp add: field_simps) - apply (simp only: contour_integral_lmul cint algebra_simps) - done - have cic: "\u. (\y. \k0 < r\ by (force intro!: Cauchy_higher_derivative_integral_circlepath [OF contf holf]) - have "(\k. contour_integral (circlepath z r) (\u. f u/(u - z)^(Suc k)) * (w - z)^k) - sums contour_integral (circlepath z r) (\u. f u/(u - w))" - unfolding sums_def - apply (intro Lim_transform_eventually [OF _ eq] contour_integral_uniform_limit_circlepath [OF eventuallyI ul] cic) - using \0 < r\ apply auto - done - then have "(\k. contour_integral (circlepath z r) (\u. f u/(u - z)^(Suc k)) * (w - z)^k) - sums (2 * of_real pi * \ * f w)" - using w by (auto simp: dist_commute dist_norm contour_integral_unique [OF Cauchy_integral_circlepath_simple [OF holfc]]) - then have "(\k. contour_integral (circlepath z r) (\u. f u / (u - z) ^ Suc k) * (w - z)^k / (\ * (of_real pi * 2))) - sums ((2 * of_real pi * \ * f w) / (\ * (complex_of_real pi * 2)))" - by (rule sums_divide) - then have "(\n. (w - z) ^ n * contour_integral (circlepath z r) (\u. f u / (u - z) ^ Suc n) / (\ * (of_real pi * 2))) - sums f w" - by (simp add: field_simps) - then show ?thesis - by (simp add: field_simps \0 < r\ Cauchy_higher_derivative_integral_circlepath [OF contf holf]) -qed - - -subsection\The Liouville theorem and the Fundamental Theorem of Algebra\ - -text\ These weak Liouville versions don't even need the derivative formula.\ - -lemma Liouville_weak_0: - assumes holf: "f holomorphic_on UNIV" and inf: "(f \ 0) at_infinity" - shows "f z = 0" -proof (rule ccontr) - assume fz: "f z \ 0" - with inf [unfolded Lim_at_infinity, rule_format, of "norm(f z)/2"] - obtain B where B: "\x. B \ cmod x \ norm (f x) * 2 < cmod (f z)" - by (auto simp: dist_norm) - define R where "R = 1 + \B\ + norm z" - have "R > 0" unfolding R_def - proof - - have "0 \ cmod z + \B\" - by (metis (full_types) add_nonneg_nonneg norm_ge_zero real_norm_def) - then show "0 < 1 + \B\ + cmod z" - by linarith - qed - have *: "((\u. f u / (u - z)) has_contour_integral 2 * complex_of_real pi * \ * f z) (circlepath z R)" - apply (rule Cauchy_integral_circlepath) - using \R > 0\ apply (auto intro: holomorphic_on_subset [OF holf] holomorphic_on_imp_continuous_on)+ - done - have "cmod (x - z) = R \ cmod (f x) * 2 < cmod (f z)" for x - unfolding R_def - by (rule B) (use norm_triangle_ineq4 [of x z] in auto) - with \R > 0\ fz show False - using has_contour_integral_bound_circlepath [OF *, of "norm(f z)/2/R"] - by (auto simp: less_imp_le norm_mult norm_divide field_split_simps) -qed - -proposition Liouville_weak: - assumes "f holomorphic_on UNIV" and "(f \ l) at_infinity" - shows "f z = l" - using Liouville_weak_0 [of "\z. f z - l"] - by (simp add: assms holomorphic_on_diff LIM_zero) - -proposition Liouville_weak_inverse: - assumes "f holomorphic_on UNIV" and unbounded: "\B. eventually (\x. norm (f x) \ B) at_infinity" - obtains z where "f z = 0" -proof - - { assume f: "\z. f z \ 0" - have 1: "(\x. 1 / f x) holomorphic_on UNIV" - by (simp add: holomorphic_on_divide assms f) - have 2: "((\x. 1 / f x) \ 0) at_infinity" - apply (rule tendstoI [OF eventually_mono]) - apply (rule_tac B="2/e" in unbounded) - apply (simp add: dist_norm norm_divide field_split_simps) - done - have False - using Liouville_weak_0 [OF 1 2] f by simp - } - then show ?thesis - using that by blast -qed - -text\ In particular we get the Fundamental Theorem of Algebra.\ - -theorem fundamental_theorem_of_algebra: - fixes a :: "nat \ complex" - assumes "a 0 = 0 \ (\i \ {1..n}. a i \ 0)" - obtains z where "(\i\n. a i * z^i) = 0" -using assms -proof (elim disjE bexE) - assume "a 0 = 0" then show ?thesis - by (auto simp: that [of 0]) -next - fix i - assume i: "i \ {1..n}" and nz: "a i \ 0" - have 1: "(\z. \i\n. a i * z^i) holomorphic_on UNIV" - by (rule holomorphic_intros)+ - show thesis - proof (rule Liouville_weak_inverse [OF 1]) - show "\\<^sub>F x in at_infinity. B \ cmod (\i\n. a i * x ^ i)" for B - using i nz by (intro polyfun_extremal exI[of _ i]) auto - qed (use that in auto) -qed - -subsection\Weierstrass convergence theorem\ - -lemma holomorphic_uniform_limit: - assumes cont: "eventually (\n. continuous_on (cball z r) (f n) \ (f n) holomorphic_on ball z r) F" - and ulim: "uniform_limit (cball z r) f g F" - and F: "\ trivial_limit F" - obtains "continuous_on (cball z r) g" "g holomorphic_on ball z r" -proof (cases r "0::real" rule: linorder_cases) - case less then show ?thesis by (force simp: ball_empty less_imp_le continuous_on_def holomorphic_on_def intro: that) -next - case equal then show ?thesis - by (force simp: holomorphic_on_def intro: that) -next - case greater - have contg: "continuous_on (cball z r) g" - using cont uniform_limit_theorem [OF eventually_mono ulim F] by blast - have "path_image (circlepath z r) \ cball z r" - using \0 < r\ by auto - then have 1: "continuous_on (path_image (circlepath z r)) (\x. 1 / (2 * complex_of_real pi * \) * g x)" - by (intro continuous_intros continuous_on_subset [OF contg]) - have 2: "((\u. 1 / (2 * of_real pi * \) * g u / (u - w) ^ 1) has_contour_integral g w) (circlepath z r)" - if w: "w \ ball z r" for w - proof - - define d where "d = (r - norm(w - z))" - have "0 < d" "d \ r" using w by (auto simp: norm_minus_commute d_def dist_norm) - have dle: "\u. cmod (z - u) = r \ d \ cmod (u - w)" - unfolding d_def by (metis add_diff_eq diff_add_cancel norm_diff_ineq norm_minus_commute) - have ev_int: "\\<^sub>F n in F. (\u. f n u / (u - w)) contour_integrable_on circlepath z r" - apply (rule eventually_mono [OF cont]) - using w - apply (auto intro: Cauchy_higher_derivative_integral_circlepath [where k=0, simplified]) - done - have ul_less: "uniform_limit (sphere z r) (\n x. f n x / (x - w)) (\x. g x / (x - w)) F" - using greater \0 < d\ - apply (clarsimp simp add: uniform_limit_iff dist_norm norm_divide diff_divide_distrib [symmetric] divide_simps) - apply (rule_tac e1="e * d" in eventually_mono [OF uniform_limitD [OF ulim]]) - apply (force simp: dist_norm intro: dle mult_left_mono less_le_trans)+ - done - have g_cint: "(\u. g u/(u - w)) contour_integrable_on circlepath z r" - by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \0 < r\]) - have cif_tends_cig: "((\n. contour_integral(circlepath z r) (\u. f n u / (u - w))) \ contour_integral(circlepath z r) (\u. g u/(u - w))) F" - by (rule contour_integral_uniform_limit_circlepath [OF ev_int ul_less F \0 < r\]) - have f_tends_cig: "((\n. 2 * of_real pi * \ * f n w) \ contour_integral (circlepath z r) (\u. g u / (u - w))) F" - proof (rule Lim_transform_eventually) - show "\\<^sub>F x in F. contour_integral (circlepath z r) (\u. f x u / (u - w)) - = 2 * of_real pi * \ * f x w" - apply (rule eventually_mono [OF cont contour_integral_unique [OF Cauchy_integral_circlepath]]) - using w\0 < d\ d_def by auto - qed (auto simp: cif_tends_cig) - have "\e. 0 < e \ \\<^sub>F n in F. dist (f n w) (g w) < e" - by (rule eventually_mono [OF uniform_limitD [OF ulim]]) (use w in auto) - then have "((\n. 2 * of_real pi * \ * f n w) \ 2 * of_real pi * \ * g w) F" - by (rule tendsto_mult_left [OF tendstoI]) - then have "((\u. g u / (u - w)) has_contour_integral 2 * of_real pi * \ * g w) (circlepath z r)" - using has_contour_integral_integral [OF g_cint] tendsto_unique [OF F f_tends_cig] w - by fastforce - then have "((\u. g u / (2 * of_real pi * \ * (u - w))) has_contour_integral g w) (circlepath z r)" - using has_contour_integral_div [where c = "2 * of_real pi * \"] - by (force simp: field_simps) - then show ?thesis - by (simp add: dist_norm) - qed - show ?thesis - using Cauchy_next_derivative_circlepath(2) [OF 1 2, simplified] - by (fastforce simp add: holomorphic_on_open contg intro: that) -qed - - -text\ Version showing that the limit is the limit of the derivatives.\ - -proposition has_complex_derivative_uniform_limit: - fixes z::complex - assumes cont: "eventually (\n. continuous_on (cball z r) (f n) \ - (\w \ ball z r. ((f n) has_field_derivative (f' n w)) (at w))) F" - and ulim: "uniform_limit (cball z r) f g F" - and F: "\ trivial_limit F" and "0 < r" - obtains g' where - "continuous_on (cball z r) g" - "\w. w \ ball z r \ (g has_field_derivative (g' w)) (at w) \ ((\n. f' n w) \ g' w) F" -proof - - let ?conint = "contour_integral (circlepath z r)" - have g: "continuous_on (cball z r) g" "g holomorphic_on ball z r" - by (rule holomorphic_uniform_limit [OF eventually_mono [OF cont] ulim F]; - auto simp: holomorphic_on_open field_differentiable_def)+ - then obtain g' where g': "\x. x \ ball z r \ (g has_field_derivative g' x) (at x)" - using DERIV_deriv_iff_has_field_derivative - by (fastforce simp add: holomorphic_on_open) - then have derg: "\x. x \ ball z r \ deriv g x = g' x" - by (simp add: DERIV_imp_deriv) - have tends_f'n_g': "((\n. f' n w) \ g' w) F" if w: "w \ ball z r" for w - proof - - have eq_f': "?conint (\x. f n x / (x - w)\<^sup>2) - ?conint (\x. g x / (x - w)\<^sup>2) = (f' n w - g' w) * (2 * of_real pi * \)" - if cont_fn: "continuous_on (cball z r) (f n)" - and fnd: "\w. w \ ball z r \ (f n has_field_derivative f' n w) (at w)" for n - proof - - have hol_fn: "f n holomorphic_on ball z r" - using fnd by (force simp: holomorphic_on_open) - have "(f n has_field_derivative 1 / (2 * of_real pi * \) * ?conint (\u. f n u / (u - w)\<^sup>2)) (at w)" - by (rule Cauchy_derivative_integral_circlepath [OF cont_fn hol_fn w]) - then have f': "f' n w = 1 / (2 * of_real pi * \) * ?conint (\u. f n u / (u - w)\<^sup>2)" - using DERIV_unique [OF fnd] w by blast - show ?thesis - by (simp add: f' Cauchy_contour_integral_circlepath_2 [OF g w] derg [OF w] field_split_simps) - qed - define d where "d = (r - norm(w - z))^2" - have "d > 0" - using w by (simp add: dist_commute dist_norm d_def) - have dle: "d \ cmod ((y - w)\<^sup>2)" if "r = cmod (z - y)" for y - proof - - have "w \ ball z (cmod (z - y))" - using that w by fastforce - then have "cmod (w - z) \ cmod (z - y)" - by (simp add: dist_complex_def norm_minus_commute) - moreover have "cmod (z - y) - cmod (w - z) \ cmod (y - w)" - by (metis diff_add_cancel diff_add_eq_diff_diff_swap norm_minus_commute norm_triangle_ineq2) - ultimately show ?thesis - using that by (simp add: d_def norm_power power_mono) - qed - have 1: "\\<^sub>F n in F. (\x. f n x / (x - w)\<^sup>2) contour_integrable_on circlepath z r" - by (force simp: holomorphic_on_open intro: w Cauchy_derivative_integral_circlepath eventually_mono [OF cont]) - have 2: "uniform_limit (sphere z r) (\n x. f n x / (x - w)\<^sup>2) (\x. g x / (x - w)\<^sup>2) F" - unfolding uniform_limit_iff - proof clarify - fix e::real - assume "0 < e" - with \r > 0\ show "\\<^sub>F n in F. \x\sphere z r. dist (f n x / (x - w)\<^sup>2) (g x / (x - w)\<^sup>2) < e" - apply (simp add: norm_divide field_split_simps sphere_def dist_norm) - apply (rule eventually_mono [OF uniform_limitD [OF ulim], of "e*d"]) - apply (simp add: \0 < d\) - apply (force simp: dist_norm dle intro: less_le_trans) - done - qed - have "((\n. contour_integral (circlepath z r) (\x. f n x / (x - w)\<^sup>2)) - \ contour_integral (circlepath z r) ((\x. g x / (x - w)\<^sup>2))) F" - by (rule contour_integral_uniform_limit_circlepath [OF 1 2 F \0 < r\]) - then have tendsto_0: "((\n. 1 / (2 * of_real pi * \) * (?conint (\x. f n x / (x - w)\<^sup>2) - ?conint (\x. g x / (x - w)\<^sup>2))) \ 0) F" - using Lim_null by (force intro!: tendsto_mult_right_zero) - have "((\n. f' n w - g' w) \ 0) F" - apply (rule Lim_transform_eventually [OF tendsto_0]) - apply (force simp: divide_simps intro: eq_f' eventually_mono [OF cont]) - done - then show ?thesis using Lim_null by blast - qed - obtain g' where "\w. w \ ball z r \ (g has_field_derivative (g' w)) (at w) \ ((\n. f' n w) \ g' w) F" - by (blast intro: tends_f'n_g' g') - then show ?thesis using g - using that by blast -qed - - -subsection\<^marker>\tag unimportant\ \Some more simple/convenient versions for applications\ - -lemma holomorphic_uniform_sequence: - assumes S: "open S" - and hol_fn: "\n. (f n) holomorphic_on S" - and ulim_g: "\x. x \ S \ \d. 0 < d \ cball x d \ S \ uniform_limit (cball x d) f g sequentially" - shows "g holomorphic_on S" -proof - - have "\f'. (g has_field_derivative f') (at z)" if "z \ S" for z - proof - - obtain r where "0 < r" and r: "cball z r \ S" - and ul: "uniform_limit (cball z r) f g sequentially" - using ulim_g [OF \z \ S\] by blast - have *: "\\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \ f n holomorphic_on ball z r" - proof (intro eventuallyI conjI) - show "continuous_on (cball z r) (f x)" for x - using hol_fn holomorphic_on_imp_continuous_on holomorphic_on_subset r by blast - show "f x holomorphic_on ball z r" for x - by (metis hol_fn holomorphic_on_subset interior_cball interior_subset r) - qed - show ?thesis - apply (rule holomorphic_uniform_limit [OF *]) - using \0 < r\ centre_in_ball ul - apply (auto simp: holomorphic_on_open) - done - qed - with S show ?thesis - by (simp add: holomorphic_on_open) -qed - -lemma has_complex_derivative_uniform_sequence: - fixes S :: "complex set" - assumes S: "open S" - and hfd: "\n x. x \ S \ ((f n) has_field_derivative f' n x) (at x)" - and ulim_g: "\x. x \ S - \ \d. 0 < d \ cball x d \ S \ uniform_limit (cball x d) f g sequentially" - shows "\g'. \x \ S. (g has_field_derivative g' x) (at x) \ ((\n. f' n x) \ g' x) sequentially" -proof - - have y: "\y. (g has_field_derivative y) (at z) \ (\n. f' n z) \ y" if "z \ S" for z - proof - - obtain r where "0 < r" and r: "cball z r \ S" - and ul: "uniform_limit (cball z r) f g sequentially" - using ulim_g [OF \z \ S\] by blast - have *: "\\<^sub>F n in sequentially. continuous_on (cball z r) (f n) \ - (\w \ ball z r. ((f n) has_field_derivative (f' n w)) (at w))" - proof (intro eventuallyI conjI ballI) - show "continuous_on (cball z r) (f x)" for x - by (meson S continuous_on_subset hfd holomorphic_on_imp_continuous_on holomorphic_on_open r) - show "w \ ball z r \ (f x has_field_derivative f' x w) (at w)" for w x - using ball_subset_cball hfd r by blast - qed - show ?thesis - by (rule has_complex_derivative_uniform_limit [OF *, of g]) (use \0 < r\ ul in \force+\) - qed - show ?thesis - by (rule bchoice) (blast intro: y) -qed - -subsection\On analytic functions defined by a series\ - -lemma series_and_derivative_comparison: - fixes S :: "complex set" - assumes S: "open S" - and h: "summable h" - and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" - and to_g: "\\<^sub>F n in sequentially. \x\S. norm (f n x) \ h n" - obtains g g' where "\x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" -proof - - obtain g where g: "uniform_limit S (\n x. \id>0. cball x d \ S \ uniform_limit (cball x d) (\n x. \i S" for x - proof - - obtain d where "d>0" and d: "cball x d \ S" - using open_contains_cball [of "S"] \x \ S\ S by blast - show ?thesis - proof (intro conjI exI) - show "uniform_limit (cball x d) (\n x. \id > 0\ d in auto) - qed - have "\x. x \ S \ (\n. \i g x" - by (metis tendsto_uniform_limitI [OF g]) - moreover have "\g'. \x\S. (g has_field_derivative g' x) (at x) \ (\n. \i g' x" - by (rule has_complex_derivative_uniform_sequence [OF S]) (auto intro: * hfd DERIV_sum)+ - ultimately show ?thesis - by (metis sums_def that) -qed - -text\A version where we only have local uniform/comparative convergence.\ - -lemma series_and_derivative_comparison_local: - fixes S :: "complex set" - assumes S: "open S" - and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" - and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ (\\<^sub>F n in sequentially. \y\ball x d \ S. norm (f n y) \ h n)" - shows "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" -proof - - have "\y. (\n. f n z) sums (\n. f n z) \ (\n. f' n z) sums y \ ((\x. \n. f n x) has_field_derivative y) (at z)" - if "z \ S" for z - proof - - obtain d h where "0 < d" "summable h" and le_h: "\\<^sub>F n in sequentially. \y\ball z d \ S. norm (f n y) \ h n" - using to_g \z \ S\ by meson - then obtain r where "r>0" and r: "ball z r \ ball z d \ S" using \z \ S\ S - by (metis Int_iff open_ball centre_in_ball open_Int open_contains_ball_eq) - have 1: "open (ball z d \ S)" - by (simp add: open_Int S) - have 2: "\n x. x \ ball z d \ S \ (f n has_field_derivative f' n x) (at x)" - by (auto simp: hfd) - obtain g g' where gg': "\x \ ball z d \ S. ((\n. f n x) sums g x) \ - ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" - by (auto intro: le_h series_and_derivative_comparison [OF 1 \summable h\ hfd]) - then have "(\n. f' n z) sums g' z" - by (meson \0 < r\ centre_in_ball contra_subsetD r) - moreover have "(\n. f n z) sums (\n. f n z)" - using summable_sums centre_in_ball \0 < d\ \summable h\ le_h - by (metis (full_types) Int_iff gg' summable_def that) - moreover have "((\x. \n. f n x) has_field_derivative g' z) (at z)" - proof (rule has_field_derivative_transform_within) - show "\x. dist x z < r \ g x = (\n. f n x)" - by (metis subsetD dist_commute gg' mem_ball r sums_unique) - qed (use \0 < r\ gg' \z \ S\ \0 < d\ in auto) - ultimately show ?thesis by auto - qed - then show ?thesis - by (rule_tac x="\x. suminf (\n. f n x)" in exI) meson -qed - - -text\Sometimes convenient to compare with a complex series of positive reals. (?)\ - -lemma series_and_derivative_comparison_complex: - fixes S :: "complex set" - assumes S: "open S" - and hfd: "\n x. x \ S \ (f n has_field_derivative f' n x) (at x)" - and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ range h \ \\<^sub>\\<^sub>0 \ (\\<^sub>F n in sequentially. \y\ball x d \ S. cmod(f n y) \ cmod (h n))" - shows "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. f' n x) sums g' x) \ (g has_field_derivative g' x) (at x)" -apply (rule series_and_derivative_comparison_local [OF S hfd], assumption) -apply (rule ex_forward [OF to_g], assumption) -apply (erule exE) -apply (rule_tac x="Re \ h" in exI) -apply (force simp: summable_Re o_def nonneg_Reals_cmod_eq_Re image_subset_iff) -done - -text\Sometimes convenient to compare with a complex series of positive reals. (?)\ -lemma series_differentiable_comparison_complex: - fixes S :: "complex set" - assumes S: "open S" - and hfd: "\n x. x \ S \ f n field_differentiable (at x)" - and to_g: "\x. x \ S \ \d h. 0 < d \ summable h \ range h \ \\<^sub>\\<^sub>0 \ (\\<^sub>F n in sequentially. \y\ball x d \ S. cmod(f n y) \ cmod (h n))" - obtains g where "\x \ S. ((\n. f n x) sums g x) \ g field_differentiable (at x)" -proof - - have hfd': "\n x. x \ S \ (f n has_field_derivative deriv (f n) x) (at x)" - using hfd field_differentiable_derivI by blast - have "\g g'. \x \ S. ((\n. f n x) sums g x) \ ((\n. deriv (f n) x) sums g' x) \ (g has_field_derivative g' x) (at x)" - by (metis series_and_derivative_comparison_complex [OF S hfd' to_g]) - then show ?thesis - using field_differentiable_def that by blast -qed - -text\In particular, a power series is analytic inside circle of convergence.\ - -lemma power_series_and_derivative_0: - fixes a :: "nat \ complex" and r::real - assumes "summable (\n. a n * r^n)" - shows "\g g'. \z. cmod z < r \ - ((\n. a n * z^n) sums g z) \ ((\n. of_nat n * a n * z^(n - 1)) sums g' z) \ (g has_field_derivative g' z) (at z)" -proof (cases "0 < r") - case True - have der: "\n z. ((\x. a n * x ^ n) has_field_derivative of_nat n * a n * z ^ (n - 1)) (at z)" - by (rule derivative_eq_intros | simp)+ - have y_le: "\cmod (z - y) * 2 < r - cmod z\ \ cmod y \ cmod (of_real r + of_real (cmod z)) / 2" for z y - using \r > 0\ - apply (auto simp: algebra_simps norm_mult norm_divide norm_power simp flip: of_real_add) - using norm_triangle_ineq2 [of y z] - apply (simp only: diff_le_eq norm_minus_commute mult_2) - done - have "summable (\n. a n * complex_of_real r ^ n)" - using assms \r > 0\ by simp - moreover have "\z. cmod z < r \ cmod ((of_real r + of_real (cmod z)) / 2) < cmod (of_real r)" - using \r > 0\ - by (simp flip: of_real_add) - ultimately have sum: "\z. cmod z < r \ summable (\n. of_real (cmod (a n)) * ((of_real r + complex_of_real (cmod z)) / 2) ^ n)" - by (rule power_series_conv_imp_absconv_weak) - have "\g g'. \z \ ball 0 r. (\n. (a n) * z ^ n) sums g z \ - (\n. of_nat n * (a n) * z ^ (n - 1)) sums g' z \ (g has_field_derivative g' z) (at z)" - apply (rule series_and_derivative_comparison_complex [OF open_ball der]) - apply (rule_tac x="(r - norm z)/2" in exI) - apply (rule_tac x="\n. of_real(norm(a n)*((r + norm z)/2)^n)" in exI) - using \r > 0\ - apply (auto simp: sum eventually_sequentially norm_mult norm_power dist_norm intro!: mult_left_mono power_mono y_le) - done - then show ?thesis - by (simp add: ball_def) -next - case False then show ?thesis - apply (simp add: not_less) - using less_le_trans norm_not_less_zero by blast -qed - -proposition\<^marker>\tag unimportant\ power_series_and_derivative: - fixes a :: "nat \ complex" and r::real - assumes "summable (\n. a n * r^n)" - obtains g g' where "\z \ ball w r. - ((\n. a n * (z - w) ^ n) sums g z) \ ((\n. of_nat n * a n * (z - w) ^ (n - 1)) sums g' z) \ - (g has_field_derivative g' z) (at z)" - using power_series_and_derivative_0 [OF assms] - apply clarify - apply (rule_tac g="(\z. g(z - w))" in that) - using DERIV_shift [where z="-w"] - apply (auto simp: norm_minus_commute Ball_def dist_norm) - done - -proposition\<^marker>\tag unimportant\ power_series_holomorphic: - assumes "\w. w \ ball z r \ ((\n. a n*(w - z)^n) sums f w)" - shows "f holomorphic_on ball z r" -proof - - have "\f'. (f has_field_derivative f') (at w)" if w: "dist z w < r" for w - proof - - have inb: "z + complex_of_real ((dist z w + r) / 2) \ ball z r" - proof - - have wz: "cmod (w - z) < r" using w - by (auto simp: field_split_simps dist_norm norm_minus_commute) - then have "0 \ r" - by (meson less_eq_real_def norm_ge_zero order_trans) - show ?thesis - using w by (simp add: dist_norm \0\r\ flip: of_real_add) - qed - have sum: "summable (\n. a n * of_real (((cmod (z - w) + r) / 2) ^ n))" - using assms [OF inb] by (force simp: summable_def dist_norm) - obtain g g' where gg': "\u. u \ ball z ((cmod (z - w) + r) / 2) \ - (\n. a n * (u - z) ^ n) sums g u \ - (\n. of_nat n * a n * (u - z) ^ (n - 1)) sums g' u \ (g has_field_derivative g' u) (at u)" - by (rule power_series_and_derivative [OF sum, of z]) fastforce - have [simp]: "g u = f u" if "cmod (u - w) < (r - cmod (z - w)) / 2" for u - proof - - have less: "cmod (z - u) * 2 < cmod (z - w) + r" - using that dist_triangle2 [of z u w] - by (simp add: dist_norm [symmetric] algebra_simps) - show ?thesis - apply (rule sums_unique2 [of "\n. a n*(u - z)^n"]) - using gg' [of u] less w - apply (auto simp: assms dist_norm) - done - qed - have "(f has_field_derivative g' w) (at w)" - by (rule has_field_derivative_transform_within [where d="(r - norm(z - w))/2"]) - (use w gg' [of w] in \(force simp: dist_norm)+\) - then show ?thesis .. - qed - then show ?thesis by (simp add: holomorphic_on_open) -qed - -corollary holomorphic_iff_power_series: - "f holomorphic_on ball z r \ - (\w \ ball z r. (\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" - apply (intro iffI ballI holomorphic_power_series, assumption+) - apply (force intro: power_series_holomorphic [where a = "\n. (deriv ^^ n) f z / (fact n)"]) - done - -lemma power_series_analytic: - "(\w. w \ ball z r \ (\n. a n*(w - z)^n) sums f w) \ f analytic_on ball z r" - by (force simp: analytic_on_open intro!: power_series_holomorphic) - -lemma analytic_iff_power_series: - "f analytic_on ball z r \ - (\w \ ball z r. (\n. (deriv ^^ n) f z / (fact n) * (w - z)^n) sums f w)" - by (simp add: analytic_on_open holomorphic_iff_power_series) - -subsection\<^marker>\tag unimportant\ \Equality between holomorphic functions, on open ball then connected set\ - -lemma holomorphic_fun_eq_on_ball: - "\f holomorphic_on ball z r; g holomorphic_on ball z r; - w \ ball z r; - \n. (deriv ^^ n) f z = (deriv ^^ n) g z\ - \ f w = g w" - apply (rule sums_unique2 [of "\n. (deriv ^^ n) f z / (fact n) * (w - z)^n"]) - apply (auto simp: holomorphic_iff_power_series) - done - -lemma holomorphic_fun_eq_0_on_ball: - "\f holomorphic_on ball z r; w \ ball z r; - \n. (deriv ^^ n) f z = 0\ - \ f w = 0" - apply (rule sums_unique2 [of "\n. (deriv ^^ n) f z / (fact n) * (w - z)^n"]) - apply (auto simp: holomorphic_iff_power_series) - done - -lemma holomorphic_fun_eq_0_on_connected: - assumes holf: "f holomorphic_on S" and "open S" - and cons: "connected S" - and der: "\n. (deriv ^^ n) f z = 0" - and "z \ S" "w \ S" - shows "f w = 0" -proof - - have *: "ball x e \ (\n. {w \ S. (deriv ^^ n) f w = 0})" - if "\u. (deriv ^^ u) f x = 0" "ball x e \ S" for x e - proof - - have "\x' n. dist x x' < e \ (deriv ^^ n) f x' = 0" - apply (rule holomorphic_fun_eq_0_on_ball [OF holomorphic_higher_deriv]) - apply (rule holomorphic_on_subset [OF holf]) - using that apply simp_all - by (metis funpow_add o_apply) - with that show ?thesis by auto - qed - have 1: "openin (top_of_set S) (\n. {w \ S. (deriv ^^ n) f w = 0})" - apply (rule open_subset, force) - using \open S\ - apply (simp add: open_contains_ball Ball_def) - apply (erule all_forward) - using "*" by auto blast+ - have 2: "closedin (top_of_set S) (\n. {w \ S. (deriv ^^ n) f w = 0})" - using assms - by (auto intro: continuous_closedin_preimage_constant holomorphic_on_imp_continuous_on holomorphic_higher_deriv) - obtain e where "e>0" and e: "ball w e \ S" using openE [OF \open S\ \w \ S\] . - then have holfb: "f holomorphic_on ball w e" - using holf holomorphic_on_subset by blast - have 3: "(\n. {w \ S. (deriv ^^ n) f w = 0}) = S \ f w = 0" - using \e>0\ e by (force intro: holomorphic_fun_eq_0_on_ball [OF holfb]) - show ?thesis - using cons der \z \ S\ - apply (simp add: connected_clopen) - apply (drule_tac x="\n. {w \ S. (deriv ^^ n) f w = 0}" in spec) - apply (auto simp: 1 2 3) - done -qed - -lemma holomorphic_fun_eq_on_connected: - assumes "f holomorphic_on S" "g holomorphic_on S" and "open S" "connected S" - and "\n. (deriv ^^ n) f z = (deriv ^^ n) g z" - and "z \ S" "w \ S" - shows "f w = g w" -proof (rule holomorphic_fun_eq_0_on_connected [of "\x. f x - g x" S z, simplified]) - show "(\x. f x - g x) holomorphic_on S" - by (intro assms holomorphic_intros) - show "\n. (deriv ^^ n) (\x. f x - g x) z = 0" - using assms higher_deriv_diff by auto -qed (use assms in auto) - -lemma holomorphic_fun_eq_const_on_connected: - assumes holf: "f holomorphic_on S" and "open S" - and cons: "connected S" - and der: "\n. 0 < n \ (deriv ^^ n) f z = 0" - and "z \ S" "w \ S" - shows "f w = f z" -proof (rule holomorphic_fun_eq_0_on_connected [of "\w. f w - f z" S z, simplified]) - show "(\w. f w - f z) holomorphic_on S" - by (intro assms holomorphic_intros) - show "\n. (deriv ^^ n) (\w. f w - f z) z = 0" - by (subst higher_deriv_diff) (use assms in \auto intro: holomorphic_intros\) -qed (use assms in auto) - -subsection\<^marker>\tag unimportant\ \Some basic lemmas about poles/singularities\ - -lemma pole_lemma: - assumes holf: "f holomorphic_on S" and a: "a \ interior S" - shows "(\z. if z = a then deriv f a - else (f z - f a) / (z - a)) holomorphic_on S" (is "?F holomorphic_on S") -proof - - have F1: "?F field_differentiable (at u within S)" if "u \ S" "u \ a" for u - proof - - have fcd: "f field_differentiable at u within S" - using holf holomorphic_on_def by (simp add: \u \ S\) - have cd: "(\z. (f z - f a) / (z - a)) field_differentiable at u within S" - by (rule fcd derivative_intros | simp add: that)+ - have "0 < dist a u" using that dist_nz by blast - then show ?thesis - by (rule field_differentiable_transform_within [OF _ _ _ cd]) (auto simp: \u \ S\) - qed - have F2: "?F field_differentiable at a" if "0 < e" "ball a e \ S" for e - proof - - have holfb: "f holomorphic_on ball a e" - by (rule holomorphic_on_subset [OF holf \ball a e \ S\]) - have 2: "?F holomorphic_on ball a e - {a}" - apply (simp add: holomorphic_on_def flip: field_differentiable_def) - using mem_ball that - apply (auto intro: F1 field_differentiable_within_subset) - done - have "isCont (\z. if z = a then deriv f a else (f z - f a) / (z - a)) x" - if "dist a x < e" for x - proof (cases "x=a") - case True - then have "f field_differentiable at a" - using holfb \0 < e\ holomorphic_on_imp_differentiable_at by auto - with True show ?thesis - by (auto simp: continuous_at has_field_derivative_iff simp flip: DERIV_deriv_iff_field_differentiable - elim: rev_iffD1 [OF _ LIM_equal]) - next - case False with 2 that show ?thesis - by (force simp: holomorphic_on_open open_Diff field_differentiable_def [symmetric] field_differentiable_imp_continuous_at) - qed - then have 1: "continuous_on (ball a e) ?F" - by (clarsimp simp: continuous_on_eq_continuous_at) - have "?F holomorphic_on ball a e" - by (auto intro: no_isolated_singularity [OF 1 2]) - with that show ?thesis - by (simp add: holomorphic_on_open field_differentiable_def [symmetric] - field_differentiable_at_within) - qed - show ?thesis - proof - fix x assume "x \ S" show "?F field_differentiable at x within S" - proof (cases "x=a") - case True then show ?thesis - using a by (auto simp: mem_interior intro: field_differentiable_at_within F2) - next - case False with F1 \x \ S\ - show ?thesis by blast - qed - qed -qed - -lemma pole_theorem: - assumes holg: "g holomorphic_on S" and a: "a \ interior S" - and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" - shows "(\z. if z = a then deriv g a - else f z - g a/(z - a)) holomorphic_on S" - using pole_lemma [OF holg a] - by (rule holomorphic_transform) (simp add: eq field_split_simps) - -lemma pole_lemma_open: - assumes "f holomorphic_on S" "open S" - shows "(\z. if z = a then deriv f a else (f z - f a)/(z - a)) holomorphic_on S" -proof (cases "a \ S") - case True with assms interior_eq pole_lemma - show ?thesis by fastforce -next - case False with assms show ?thesis - apply (simp add: holomorphic_on_def field_differentiable_def [symmetric], clarify) - apply (rule field_differentiable_transform_within [where f = "\z. (f z - f a)/(z - a)" and d = 1]) - apply (rule derivative_intros | force)+ - done -qed - -lemma pole_theorem_open: - assumes holg: "g holomorphic_on S" and S: "open S" - and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" - shows "(\z. if z = a then deriv g a - else f z - g a/(z - a)) holomorphic_on S" - using pole_lemma_open [OF holg S] - by (rule holomorphic_transform) (auto simp: eq divide_simps) - -lemma pole_theorem_0: - assumes holg: "g holomorphic_on S" and a: "a \ interior S" - and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" - and [simp]: "f a = deriv g a" "g a = 0" - shows "f holomorphic_on S" - using pole_theorem [OF holg a eq] - by (rule holomorphic_transform) (auto simp: eq field_split_simps) - -lemma pole_theorem_open_0: - assumes holg: "g holomorphic_on S" and S: "open S" - and eq: "\z. z \ S - {a} \ g z = (z - a) * f z" - and [simp]: "f a = deriv g a" "g a = 0" - shows "f holomorphic_on S" - using pole_theorem_open [OF holg S eq] - by (rule holomorphic_transform) (auto simp: eq field_split_simps) - -lemma pole_theorem_analytic: - assumes g: "g analytic_on S" - and eq: "\z. z \ S - \ \d. 0 < d \ (\w \ ball z d - {a}. g w = (w - a) * f w)" - shows "(\z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on S" (is "?F analytic_on S") - unfolding analytic_on_def -proof - fix x - assume "x \ S" - with g obtain e where "0 < e" and e: "g holomorphic_on ball x e" - by (auto simp add: analytic_on_def) - obtain d where "0 < d" and d: "\w. w \ ball x d - {a} \ g w = (w - a) * f w" - using \x \ S\ eq by blast - have "?F holomorphic_on ball x (min d e)" - using d e \x \ S\ by (fastforce simp: holomorphic_on_subset subset_ball intro!: pole_theorem_open) - then show "\e>0. ?F holomorphic_on ball x e" - using \0 < d\ \0 < e\ not_le by fastforce -qed - -lemma pole_theorem_analytic_0: - assumes g: "g analytic_on S" - and eq: "\z. z \ S \ \d. 0 < d \ (\w \ ball z d - {a}. g w = (w - a) * f w)" - and [simp]: "f a = deriv g a" "g a = 0" - shows "f analytic_on S" -proof - - have [simp]: "(\z. if z = a then deriv g a else f z - g a / (z - a)) = f" - by auto - show ?thesis - using pole_theorem_analytic [OF g eq] by simp -qed - -lemma pole_theorem_analytic_open_superset: - assumes g: "g analytic_on S" and "S \ T" "open T" - and eq: "\z. z \ T - {a} \ g z = (z - a) * f z" - shows "(\z. if z = a then deriv g a - else f z - g a/(z - a)) analytic_on S" -proof (rule pole_theorem_analytic [OF g]) - fix z - assume "z \ S" - then obtain e where "0 < e" and e: "ball z e \ T" - using assms openE by blast - then show "\d>0. \w\ball z d - {a}. g w = (w - a) * f w" - using eq by auto -qed - -lemma pole_theorem_analytic_open_superset_0: - assumes g: "g analytic_on S" "S \ T" "open T" "\z. z \ T - {a} \ g z = (z - a) * f z" - and [simp]: "f a = deriv g a" "g a = 0" - shows "f analytic_on S" -proof - - have [simp]: "(\z. if z = a then deriv g a else f z - g a / (z - a)) = f" - by auto - have "(\z. if z = a then deriv g a else f z - g a/(z - a)) analytic_on S" - by (rule pole_theorem_analytic_open_superset [OF g]) - then show ?thesis by simp -qed - - -subsection\General, homology form of Cauchy's theorem\ - -text\Proof is based on Dixon's, as presented in Lang's "Complex Analysis" book (page 147).\ - -lemma contour_integral_continuous_on_linepath_2D: - assumes "open U" and cont_dw: "\w. w \ U \ F w contour_integrable_on (linepath a b)" - and cond_uu: "continuous_on (U \ U) (\(x,y). F x y)" - and abu: "closed_segment a b \ U" - shows "continuous_on U (\w. contour_integral (linepath a b) (F w))" -proof - - have *: "\d>0. \x'\U. dist x' w < d \ - dist (contour_integral (linepath a b) (F x')) - (contour_integral (linepath a b) (F w)) \ \" - if "w \ U" "0 < \" "a \ b" for w \ - proof - - obtain \ where "\>0" and \: "cball w \ \ U" using open_contains_cball \open U\ \w \ U\ by force - let ?TZ = "cball w \ \ closed_segment a b" - have "uniformly_continuous_on ?TZ (\(x,y). F x y)" - proof (rule compact_uniformly_continuous) - show "continuous_on ?TZ (\(x,y). F x y)" - by (rule continuous_on_subset[OF cond_uu]) (use SigmaE \ abu in blast) - show "compact ?TZ" - by (simp add: compact_Times) - qed - then obtain \ where "\>0" - and \: "\x x'. \x\?TZ; x'\?TZ; dist x' x < \\ \ - dist ((\(x,y). F x y) x') ((\(x,y). F x y) x) < \/norm(b - a)" - apply (rule uniformly_continuous_onE [where e = "\/norm(b - a)"]) - using \0 < \\ \a \ b\ by auto - have \: "\norm (w - x1) \ \; x2 \ closed_segment a b; - norm (w - x1') \ \; x2' \ closed_segment a b; norm ((x1', x2') - (x1, x2)) < \\ - \ norm (F x1' x2' - F x1 x2) \ \ / cmod (b - a)" - for x1 x2 x1' x2' - using \ [of "(x1,x2)" "(x1',x2')"] by (force simp: dist_norm) - have le_ee: "cmod (contour_integral (linepath a b) (\x. F x' x - F w x)) \ \" - if "x' \ U" "cmod (x' - w) < \" "cmod (x' - w) < \" for x' - proof - - have "(\x. F x' x - F w x) contour_integrable_on linepath a b" - by (simp add: \w \ U\ cont_dw contour_integrable_diff that) - then have "cmod (contour_integral (linepath a b) (\x. F x' x - F w x)) \ \/norm(b - a) * norm(b - a)" - apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_integral _ \]) - using \0 < \\ \0 < \\ that apply (auto simp: norm_minus_commute) - done - also have "\ = \" using \a \ b\ by simp - finally show ?thesis . - qed - show ?thesis - apply (rule_tac x="min \ \" in exI) - using \0 < \\ \0 < \\ - apply (auto simp: dist_norm contour_integral_diff [OF cont_dw cont_dw, symmetric] \w \ U\ intro: le_ee) - done - qed - show ?thesis - proof (cases "a=b") - case True - then show ?thesis by simp - next - case False - show ?thesis - by (rule continuous_onI) (use False in \auto intro: *\) - qed -qed - -text\This version has \<^term>\polynomial_function \\ as an additional assumption.\ -lemma Cauchy_integral_formula_global_weak: - assumes "open U" and holf: "f holomorphic_on U" - and z: "z \ U" and \: "polynomial_function \" - and pasz: "path_image \ \ U - {z}" and loop: "pathfinish \ = pathstart \" - and zero: "\w. w \ U \ winding_number \ w = 0" - shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" -proof - - obtain \' where pf\': "polynomial_function \'" and \': "\x. (\ has_vector_derivative (\' x)) (at x)" - using has_vector_derivative_polynomial_function [OF \] by blast - then have "bounded(path_image \')" - by (simp add: path_image_def compact_imp_bounded compact_continuous_image continuous_on_polymonial_function) - then obtain B where "B>0" and B: "\x. x \ path_image \' \ norm x \ B" - using bounded_pos by force - define d where [abs_def]: "d z w = (if w = z then deriv f z else (f w - f z)/(w - z))" for z w - define v where "v = {w. w \ path_image \ \ winding_number \ w = 0}" - have "path \" "valid_path \" using \ - by (auto simp: path_polynomial_function valid_path_polynomial_function) - then have ov: "open v" - by (simp add: v_def open_winding_number_levelsets loop) - have uv_Un: "U \ v = UNIV" - using pasz zero by (auto simp: v_def) - have conf: "continuous_on U f" - by (metis holf holomorphic_on_imp_continuous_on) - have hol_d: "(d y) holomorphic_on U" if "y \ U" for y - proof - - have *: "(\c. if c = y then deriv f y else (f c - f y) / (c - y)) holomorphic_on U" - by (simp add: holf pole_lemma_open \open U\) - then have "isCont (\x. if x = y then deriv f y else (f x - f y) / (x - y)) y" - using at_within_open field_differentiable_imp_continuous_at holomorphic_on_def that \open U\ by fastforce - then have "continuous_on U (d y)" - apply (simp add: d_def continuous_on_eq_continuous_at \open U\, clarify) - using * holomorphic_on_def - by (meson field_differentiable_within_open field_differentiable_imp_continuous_at \open U\) - moreover have "d y holomorphic_on U - {y}" - proof - - have "\w. w \ U - {y} \ - (\w. if w = y then deriv f y else (f w - f y) / (w - y)) field_differentiable at w" - apply (rule_tac d="dist w y" and f = "\w. (f w - f y)/(w - y)" in field_differentiable_transform_within) - apply (auto simp: dist_pos_lt dist_commute intro!: derivative_intros) - using \open U\ holf holomorphic_on_imp_differentiable_at by blast - then show ?thesis - unfolding field_differentiable_def by (simp add: d_def holomorphic_on_open \open U\ open_delete) - qed - ultimately show ?thesis - by (rule no_isolated_singularity) (auto simp: \open U\) - qed - have cint_fxy: "(\x. (f x - f y) / (x - y)) contour_integrable_on \" if "y \ path_image \" for y - proof (rule contour_integrable_holomorphic_simple [where S = "U-{y}"]) - show "(\x. (f x - f y) / (x - y)) holomorphic_on U - {y}" - by (force intro: holomorphic_intros holomorphic_on_subset [OF holf]) - show "path_image \ \ U - {y}" - using pasz that by blast - qed (auto simp: \open U\ open_delete \valid_path \\) - define h where - "h z = (if z \ U then contour_integral \ (d z) else contour_integral \ (\w. f w/(w - z)))" for z - have U: "((d z) has_contour_integral h z) \" if "z \ U" for z - proof - - have "d z holomorphic_on U" - by (simp add: hol_d that) - with that show ?thesis - apply (simp add: h_def) - by (meson Diff_subset \open U\ \valid_path \\ contour_integrable_holomorphic_simple has_contour_integral_integral pasz subset_trans) - qed - have V: "((\w. f w / (w - z)) has_contour_integral h z) \" if z: "z \ v" for z - proof - - have 0: "0 = (f z) * 2 * of_real (2 * pi) * \ * winding_number \ z" - using v_def z by auto - then have "((\x. 1 / (x - z)) has_contour_integral 0) \" - using z v_def has_contour_integral_winding_number [OF \valid_path \\] by fastforce - then have "((\x. f z * (1 / (x - z))) has_contour_integral 0) \" - using has_contour_integral_lmul by fastforce - then have "((\x. f z / (x - z)) has_contour_integral 0) \" - by (simp add: field_split_simps) - moreover have "((\x. (f x - f z) / (x - z)) has_contour_integral contour_integral \ (d z)) \" - using z - apply (auto simp: v_def) - apply (metis (no_types, lifting) contour_integrable_eq d_def has_contour_integral_eq has_contour_integral_integral cint_fxy) - done - ultimately have *: "((\x. f z / (x - z) + (f x - f z) / (x - z)) has_contour_integral (0 + contour_integral \ (d z))) \" - by (rule has_contour_integral_add) - have "((\w. f w / (w - z)) has_contour_integral contour_integral \ (d z)) \" - if "z \ U" - using * by (auto simp: divide_simps has_contour_integral_eq) - moreover have "((\w. f w / (w - z)) has_contour_integral contour_integral \ (\w. f w / (w - z))) \" - if "z \ U" - apply (rule has_contour_integral_integral [OF contour_integrable_holomorphic_simple [where S=U]]) - using U pasz \valid_path \\ that - apply (auto intro: holomorphic_on_imp_continuous_on hol_d) - apply (rule continuous_intros conf holomorphic_intros holf assms | force)+ - done - ultimately show ?thesis - using z by (simp add: h_def) - qed - have znot: "z \ path_image \" - using pasz by blast - obtain d0 where "d0>0" and d0: "\x y. x \ path_image \ \ y \ - U \ d0 \ dist x y" - using separate_compact_closed [of "path_image \" "-U"] pasz \open U\ \path \\ compact_path_image - by blast - obtain dd where "0 < dd" and dd: "{y + k | y k. y \ path_image \ \ k \ ball 0 dd} \ U" - apply (rule that [of "d0/2"]) - using \0 < d0\ - apply (auto simp: dist_norm dest: d0) - done - have "\x x'. \x \ path_image \; dist x x' * 2 < dd\ \ \y k. x' = y + k \ y \ path_image \ \ dist 0 k * 2 \ dd" - apply (rule_tac x=x in exI) - apply (rule_tac x="x'-x" in exI) - apply (force simp: dist_norm) - done - then have 1: "path_image \ \ interior {y + k |y k. y \ path_image \ \ k \ cball 0 (dd / 2)}" - apply (clarsimp simp add: mem_interior) - using \0 < dd\ - apply (rule_tac x="dd/2" in exI, auto) - done - obtain T where "compact T" and subt: "path_image \ \ interior T" and T: "T \ U" - apply (rule that [OF _ 1]) - apply (fastforce simp add: \valid_path \\ compact_valid_path_image intro!: compact_sums) - apply (rule order_trans [OF _ dd]) - using \0 < dd\ by fastforce - obtain L where "L>0" - and L: "\f B. \f holomorphic_on interior T; \z. z\interior T \ cmod (f z) \ B\ \ - cmod (contour_integral \ f) \ L * B" - using contour_integral_bound_exists [OF open_interior \valid_path \\ subt] - by blast - have "bounded(f ` T)" - by (meson \compact T\ compact_continuous_image compact_imp_bounded conf continuous_on_subset T) - then obtain D where "D>0" and D: "\x. x \ T \ norm (f x) \ D" - by (auto simp: bounded_pos) - obtain C where "C>0" and C: "\x. x \ T \ norm x \ C" - using \compact T\ bounded_pos compact_imp_bounded by force - have "dist (h y) 0 \ e" if "0 < e" and le: "D * L / e + C \ cmod y" for e y - proof - - have "D * L / e > 0" using \D>0\ \L>0\ \e>0\ by simp - with le have ybig: "norm y > C" by force - with C have "y \ T" by force - then have ynot: "y \ path_image \" - using subt interior_subset by blast - have [simp]: "winding_number \ y = 0" - apply (rule winding_number_zero_outside [of _ "cball 0 C"]) - using ybig interior_subset subt - apply (force simp: loop \path \\ dist_norm intro!: C)+ - done - have [simp]: "h y = contour_integral \ (\w. f w/(w - y))" - by (rule contour_integral_unique [symmetric]) (simp add: v_def ynot V) - have holint: "(\w. f w / (w - y)) holomorphic_on interior T" - apply (rule holomorphic_on_divide) - using holf holomorphic_on_subset interior_subset T apply blast - apply (rule holomorphic_intros)+ - using \y \ T\ interior_subset by auto - have leD: "cmod (f z / (z - y)) \ D * (e / L / D)" if z: "z \ interior T" for z - proof - - have "D * L / e + cmod z \ cmod y" - using le C [of z] z using interior_subset by force - then have DL2: "D * L / e \ cmod (z - y)" - using norm_triangle_ineq2 [of y z] by (simp add: norm_minus_commute) - have "cmod (f z / (z - y)) = cmod (f z) * inverse (cmod (z - y))" - by (simp add: norm_mult norm_inverse Fields.field_class.field_divide_inverse) - also have "\ \ D * (e / L / D)" - apply (rule mult_mono) - using that D interior_subset apply blast - using \L>0\ \e>0\ \D>0\ DL2 - apply (auto simp: norm_divide field_split_simps) - done - finally show ?thesis . - qed - have "dist (h y) 0 = cmod (contour_integral \ (\w. f w / (w - y)))" - by (simp add: dist_norm) - also have "\ \ L * (D * (e / L / D))" - by (rule L [OF holint leD]) - also have "\ = e" - using \L>0\ \0 < D\ by auto - finally show ?thesis . - qed - then have "(h \ 0) at_infinity" - by (meson Lim_at_infinityI) - moreover have "h holomorphic_on UNIV" - proof - - have con_ff: "continuous (at (x,z)) (\(x,y). (f y - f x) / (y - x))" - if "x \ U" "z \ U" "x \ z" for x z - using that conf - apply (simp add: split_def continuous_on_eq_continuous_at \open U\) - apply (simp | rule continuous_intros continuous_within_compose2 [where g=f])+ - done - have con_fstsnd: "continuous_on UNIV (\x. (fst x - snd x) ::complex)" - by (rule continuous_intros)+ - have open_uu_Id: "open (U \ U - Id)" - apply (rule open_Diff) - apply (simp add: open_Times \open U\) - using continuous_closed_preimage_constant [OF con_fstsnd closed_UNIV, of 0] - apply (auto simp: Id_fstsnd_eq algebra_simps) - done - have con_derf: "continuous (at z) (deriv f)" if "z \ U" for z - apply (rule continuous_on_interior [of U]) - apply (simp add: holf holomorphic_deriv holomorphic_on_imp_continuous_on \open U\) - by (simp add: interior_open that \open U\) - have tendsto_f': "((\(x,y). if y = x then deriv f (x) - else (f (y) - f (x)) / (y - x)) \ deriv f x) - (at (x, x) within U \ U)" if "x \ U" for x - proof (rule Lim_withinI) - fix e::real assume "0 < e" - obtain k1 where "k1>0" and k1: "\x'. norm (x' - x) \ k1 \ norm (deriv f x' - deriv f x) < e" - using \0 < e\ continuous_within_E [OF con_derf [OF \x \ U\]] - by (metis UNIV_I dist_norm) - obtain k2 where "k2>0" and k2: "ball x k2 \ U" - by (blast intro: openE [OF \open U\] \x \ U\) - have neq: "norm ((f z' - f x') / (z' - x') - deriv f x) \ e" - if "z' \ x'" and less_k1: "norm (x'-x, z'-x) < k1" and less_k2: "norm (x'-x, z'-x) < k2" - for x' z' - proof - - have cs_less: "w \ closed_segment x' z' \ cmod (w - x) \ norm (x'-x, z'-x)" for w - apply (drule segment_furthest_le [where y=x]) - by (metis (no_types) dist_commute dist_norm norm_fst_le norm_snd_le order_trans) - have derf_le: "w \ closed_segment x' z' \ z' \ x' \ cmod (deriv f w - deriv f x) \ e" for w - by (blast intro: cs_less less_k1 k1 [unfolded divide_const_simps dist_norm] less_imp_le le_less_trans) - have f_has_der: "\x. x \ U \ (f has_field_derivative deriv f x) (at x within U)" - by (metis DERIV_deriv_iff_field_differentiable at_within_open holf holomorphic_on_def \open U\) - have "closed_segment x' z' \ U" - by (rule order_trans [OF _ k2]) (simp add: cs_less le_less_trans [OF _ less_k2] dist_complex_def norm_minus_commute subset_iff) - then have cint_derf: "(deriv f has_contour_integral f z' - f x') (linepath x' z')" - using contour_integral_primitive [OF f_has_der valid_path_linepath] pasz by simp - then have *: "((\x. deriv f x / (z' - x')) has_contour_integral (f z' - f x') / (z' - x')) (linepath x' z')" - by (rule has_contour_integral_div) - have "norm ((f z' - f x') / (z' - x') - deriv f x) \ e/norm(z' - x') * norm(z' - x')" - apply (rule has_contour_integral_bound_linepath [OF has_contour_integral_diff [OF *]]) - using has_contour_integral_div [where c = "z' - x'", OF has_contour_integral_const_linepath [of "deriv f x" z' x']] - \e > 0\ \z' \ x'\ - apply (auto simp: norm_divide divide_simps derf_le) - done - also have "\ \ e" using \0 < e\ by simp - finally show ?thesis . - qed - show "\d>0. \xa\U \ U. - 0 < dist xa (x, x) \ dist xa (x, x) < d \ - dist (case xa of (x, y) \ if y = x then deriv f x else (f y - f x) / (y - x)) (deriv f x) \ e" - apply (rule_tac x="min k1 k2" in exI) - using \k1>0\ \k2>0\ \e>0\ - apply (force simp: dist_norm neq intro: dual_order.strict_trans2 k1 less_imp_le norm_fst_le) - done - qed - have con_pa_f: "continuous_on (path_image \) f" - by (meson holf holomorphic_on_imp_continuous_on holomorphic_on_subset interior_subset subt T) - have le_B: "\T. T \ {0..1} \ cmod (vector_derivative \ (at T)) \ B" - apply (rule B) - using \' using path_image_def vector_derivative_at by fastforce - have f_has_cint: "\w. w \ v - path_image \ \ ((\u. f u / (u - w) ^ 1) has_contour_integral h w) \" - by (simp add: V) - have cond_uu: "continuous_on (U \ U) (\(x,y). d x y)" - apply (simp add: continuous_on_eq_continuous_within d_def continuous_within tendsto_f') - apply (simp add: tendsto_within_open_NO_MATCH open_Times \open U\, clarify) - apply (rule Lim_transform_within_open [OF _ open_uu_Id, where f = "(\(x,y). (f y - f x) / (y - x))"]) - using con_ff - apply (auto simp: continuous_within) - done - have hol_dw: "(\z. d z w) holomorphic_on U" if "w \ U" for w - proof - - have "continuous_on U ((\(x,y). d x y) \ (\z. (w,z)))" - by (rule continuous_on_compose continuous_intros continuous_on_subset [OF cond_uu] | force intro: that)+ - then have *: "continuous_on U (\z. if w = z then deriv f z else (f w - f z) / (w - z))" - by (rule rev_iffD1 [OF _ continuous_on_cong [OF refl]]) (simp add: d_def field_simps) - have **: "\x. \x \ U; x \ w\ \ (\z. if w = z then deriv f z else (f w - f z) / (w - z)) field_differentiable at x" - apply (rule_tac f = "\x. (f w - f x)/(w - x)" and d = "dist x w" in field_differentiable_transform_within) - apply (rule \open U\ derivative_intros holomorphic_on_imp_differentiable_at [OF holf] | force simp: dist_commute)+ - done - show ?thesis - unfolding d_def - apply (rule no_isolated_singularity [OF * _ \open U\, where K = "{w}"]) - apply (auto simp: field_differentiable_def [symmetric] holomorphic_on_open open_Diff \open U\ **) - done - qed - { fix a b - assume abu: "closed_segment a b \ U" - then have "\w. w \ U \ (\z. d z w) contour_integrable_on (linepath a b)" - by (metis hol_dw continuous_on_subset contour_integrable_continuous_linepath holomorphic_on_imp_continuous_on) - then have cont_cint_d: "continuous_on U (\w. contour_integral (linepath a b) (\z. d z w))" - apply (rule contour_integral_continuous_on_linepath_2D [OF \open U\ _ _ abu]) - apply (auto intro: continuous_on_swap_args cond_uu) - done - have cont_cint_d\: "continuous_on {0..1} ((\w. contour_integral (linepath a b) (\z. d z w)) \ \)" - proof (rule continuous_on_compose) - show "continuous_on {0..1} \" - using \path \\ path_def by blast - show "continuous_on (\ ` {0..1}) (\w. contour_integral (linepath a b) (\z. d z w))" - using pasz unfolding path_image_def - by (auto intro!: continuous_on_subset [OF cont_cint_d]) - qed - have cint_cint: "(\w. contour_integral (linepath a b) (\z. d z w)) contour_integrable_on \" - apply (simp add: contour_integrable_on) - apply (rule integrable_continuous_real) - apply (rule continuous_on_mult [OF cont_cint_d\ [unfolded o_def]]) - using pf\' - by (simp add: continuous_on_polymonial_function vector_derivative_at [OF \']) - have "contour_integral (linepath a b) h = contour_integral (linepath a b) (\z. contour_integral \ (d z))" - using abu by (force simp: h_def intro: contour_integral_eq) - also have "\ = contour_integral \ (\w. contour_integral (linepath a b) (\z. d z w))" - apply (rule contour_integral_swap) - apply (rule continuous_on_subset [OF cond_uu]) - using abu pasz \valid_path \\ - apply (auto intro!: continuous_intros) - by (metis \' continuous_on_eq path_def path_polynomial_function pf\' vector_derivative_at) - finally have cint_h_eq: - "contour_integral (linepath a b) h = - contour_integral \ (\w. contour_integral (linepath a b) (\z. d z w))" . - note cint_cint cint_h_eq - } note cint_h = this - have conthu: "continuous_on U h" - proof (simp add: continuous_on_sequentially, clarify) - fix a x - assume x: "x \ U" and au: "\n. a n \ U" and ax: "a \ x" - then have A1: "\\<^sub>F n in sequentially. d (a n) contour_integrable_on \" - by (meson U contour_integrable_on_def eventuallyI) - obtain dd where "dd>0" and dd: "cball x dd \ U" using open_contains_cball \open U\ x by force - have A2: "uniform_limit (path_image \) (\n. d (a n)) (d x) sequentially" - unfolding uniform_limit_iff dist_norm - proof clarify - fix ee::real - assume "0 < ee" - show "\\<^sub>F n in sequentially. \\\path_image \. cmod (d (a n) \ - d x \) < ee" - proof - - let ?ddpa = "{(w,z) |w z. w \ cball x dd \ z \ path_image \}" - have "uniformly_continuous_on ?ddpa (\(x,y). d x y)" - apply (rule compact_uniformly_continuous [OF continuous_on_subset[OF cond_uu]]) - using dd pasz \valid_path \\ - apply (auto simp: compact_Times compact_valid_path_image simp del: mem_cball) - done - then obtain kk where "kk>0" - and kk: "\x x'. \x \ ?ddpa; x' \ ?ddpa; dist x' x < kk\ \ - dist ((\(x,y). d x y) x') ((\(x,y). d x y) x) < ee" - by (rule uniformly_continuous_onE [where e = ee]) (use \0 < ee\ in auto) - have kk: "\norm (w - x) \ dd; z \ path_image \; norm ((w, z) - (x, z)) < kk\ \ norm (d w z - d x z) < ee" - for w z - using \dd>0\ kk [of "(x,z)" "(w,z)"] by (force simp: norm_minus_commute dist_norm) - show ?thesis - using ax unfolding lim_sequentially eventually_sequentially - apply (drule_tac x="min dd kk" in spec) - using \dd > 0\ \kk > 0\ - apply (fastforce simp: kk dist_norm) - done - qed - qed - have "(\n. contour_integral \ (d (a n))) \ contour_integral \ (d x)" - by (rule contour_integral_uniform_limit [OF A1 A2 le_B]) (auto simp: \valid_path \\) - then have tendsto_hx: "(\n. contour_integral \ (d (a n))) \ h x" - by (simp add: h_def x) - then show "(h \ a) \ h x" - by (simp add: h_def x au o_def) - qed - show ?thesis - proof (simp add: holomorphic_on_open field_differentiable_def [symmetric], clarify) - fix z0 - consider "z0 \ v" | "z0 \ U" using uv_Un by blast - then show "h field_differentiable at z0" - proof cases - assume "z0 \ v" then show ?thesis - using Cauchy_next_derivative [OF con_pa_f le_B f_has_cint _ ov] V f_has_cint \valid_path \\ - by (auto simp: field_differentiable_def v_def) - next - assume "z0 \ U" then - obtain e where "e>0" and e: "ball z0 e \ U" by (blast intro: openE [OF \open U\]) - have *: "contour_integral (linepath a b) h + contour_integral (linepath b c) h + contour_integral (linepath c a) h = 0" - if abc_subset: "convex hull {a, b, c} \ ball z0 e" for a b c - proof - - have *: "\x1 x2 z. z \ U \ closed_segment x1 x2 \ U \ (\w. d w z) contour_integrable_on linepath x1 x2" - using hol_dw holomorphic_on_imp_continuous_on \open U\ - by (auto intro!: contour_integrable_holomorphic_simple) - have abc: "closed_segment a b \ U" "closed_segment b c \ U" "closed_segment c a \ U" - using that e segments_subset_convex_hull by fastforce+ - have eq0: "\w. w \ U \ contour_integral (linepath a b +++ linepath b c +++ linepath c a) (\z. d z w) = 0" - apply (rule contour_integral_unique [OF Cauchy_theorem_triangle]) - apply (rule holomorphic_on_subset [OF hol_dw]) - using e abc_subset by auto - have "contour_integral \ - (\x. contour_integral (linepath a b) (\z. d z x) + - (contour_integral (linepath b c) (\z. d z x) + - contour_integral (linepath c a) (\z. d z x))) = 0" - apply (rule contour_integral_eq_0) - using abc pasz U - apply (subst contour_integral_join [symmetric], auto intro: eq0 *)+ - done - then show ?thesis - by (simp add: cint_h abc contour_integrable_add contour_integral_add [symmetric] add_ac) - qed - show ?thesis - using e \e > 0\ - by (auto intro!: holomorphic_on_imp_differentiable_at [OF _ open_ball] analytic_imp_holomorphic - Morera_triangle continuous_on_subset [OF conthu] *) - qed - qed - qed - ultimately have [simp]: "h z = 0" for z - by (meson Liouville_weak) - have "((\w. 1 / (w - z)) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z) \" - by (rule has_contour_integral_winding_number [OF \valid_path \\ znot]) - then have "((\w. f z * (1 / (w - z))) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z * f z) \" - by (metis mult.commute has_contour_integral_lmul) - then have 1: "((\w. f z / (w - z)) has_contour_integral complex_of_real (2 * pi) * \ * winding_number \ z * f z) \" - by (simp add: field_split_simps) - moreover have 2: "((\w. (f w - f z) / (w - z)) has_contour_integral 0) \" - using U [OF z] pasz d_def by (force elim: has_contour_integral_eq [where g = "\w. (f w - f z)/(w - z)"]) - show ?thesis - using has_contour_integral_add [OF 1 2] by (simp add: diff_divide_distrib) -qed - -theorem Cauchy_integral_formula_global: - assumes S: "open S" and holf: "f holomorphic_on S" - and z: "z \ S" and vpg: "valid_path \" - and pasz: "path_image \ \ S - {z}" and loop: "pathfinish \ = pathstart \" - and zero: "\w. w \ S \ winding_number \ w = 0" - shows "((\w. f w / (w - z)) has_contour_integral (2*pi * \ * winding_number \ z * f z)) \" -proof - - have "path \" using vpg by (blast intro: valid_path_imp_path) - have hols: "(\w. f w / (w - z)) holomorphic_on S - {z}" "(\w. 1 / (w - z)) holomorphic_on S - {z}" - by (rule holomorphic_intros holomorphic_on_subset [OF holf] | force)+ - then have cint_fw: "(\w. f w / (w - z)) contour_integrable_on \" - by (meson contour_integrable_holomorphic_simple holomorphic_on_imp_continuous_on open_delete S vpg pasz) - obtain d where "d>0" - and d: "\g h. \valid_path g; valid_path h; \t\{0..1}. cmod (g t - \ t) < d \ cmod (h t - \ t) < d; - pathstart h = pathstart g \ pathfinish h = pathfinish g\ - \ path_image h \ S - {z} \ (\f. f holomorphic_on S - {z} \ contour_integral h f = contour_integral g f)" - using contour_integral_nearby_ends [OF _ \path \\ pasz] S by (simp add: open_Diff) metis - obtain p where polyp: "polynomial_function p" - and ps: "pathstart p = pathstart \" and pf: "pathfinish p = pathfinish \" and led: "\t\{0..1}. cmod (p t - \ t) < d" - using path_approx_polynomial_function [OF \path \\ \d > 0\] by blast - then have ploop: "pathfinish p = pathstart p" using loop by auto - have vpp: "valid_path p" using polyp valid_path_polynomial_function by blast - have [simp]: "z \ path_image \" using pasz by blast - have paps: "path_image p \ S - {z}" and cint_eq: "(\f. f holomorphic_on S - {z} \ contour_integral p f = contour_integral \ f)" - using pf ps led d [OF vpg vpp] \d > 0\ by auto - have wn_eq: "winding_number p z = winding_number \ z" - using vpp paps - by (simp add: subset_Diff_insert vpg valid_path_polynomial_function winding_number_valid_path cint_eq hols) - have "winding_number p w = winding_number \ w" if "w \ S" for w - proof - - have hol: "(\v. 1 / (v - w)) holomorphic_on S - {z}" - using that by (force intro: holomorphic_intros holomorphic_on_subset [OF holf]) - have "w \ path_image p" "w \ path_image \" using paps pasz that by auto - then show ?thesis - using vpp vpg by (simp add: subset_Diff_insert valid_path_polynomial_function winding_number_valid_path cint_eq [OF hol]) - qed - then have wn0: "\w. w \ S \ winding_number p w = 0" - by (simp add: zero) - show ?thesis - using Cauchy_integral_formula_global_weak [OF S holf z polyp paps ploop wn0] hols - by (metis wn_eq cint_eq has_contour_integral_eqpath cint_fw cint_eq) -qed - -theorem Cauchy_theorem_global: - assumes S: "open S" and holf: "f holomorphic_on S" - and vpg: "valid_path \" and loop: "pathfinish \ = pathstart \" - and pas: "path_image \ \ S" - and zero: "\w. w \ S \ winding_number \ w = 0" - shows "(f has_contour_integral 0) \" -proof - - obtain z where "z \ S" and znot: "z \ path_image \" - proof - - have "compact (path_image \)" - using compact_valid_path_image vpg by blast - then have "path_image \ \ S" - by (metis (no_types) compact_open path_image_nonempty S) - with pas show ?thesis by (blast intro: that) - qed - then have pasz: "path_image \ \ S - {z}" using pas by blast - have hol: "(\w. (w - z) * f w) holomorphic_on S" - by (rule holomorphic_intros holf)+ - show ?thesis - using Cauchy_integral_formula_global [OF S hol \z \ S\ vpg pasz loop zero] - by (auto simp: znot elim!: has_contour_integral_eq) -qed - -corollary Cauchy_theorem_global_outside: - assumes "open S" "f holomorphic_on S" "valid_path \" "pathfinish \ = pathstart \" "path_image \ \ S" - "\w. w \ S \ w \ outside(path_image \)" - shows "(f has_contour_integral 0) \" -by (metis Cauchy_theorem_global assms winding_number_zero_in_outside valid_path_imp_path) - -lemma simply_connected_imp_winding_number_zero: - assumes "simply_connected S" "path g" - "path_image g \ S" "pathfinish g = pathstart g" "z \ S" - shows "winding_number g z = 0" -proof - - have hom: "homotopic_loops S g (linepath (pathstart g) (pathstart g))" - by (meson assms homotopic_paths_imp_homotopic_loops pathfinish_linepath simply_connected_eq_contractible_path) - then have "homotopic_paths (- {z}) g (linepath (pathstart g) (pathstart g))" - by (meson \z \ S\ homotopic_loops_imp_homotopic_paths_null homotopic_paths_subset subset_Compl_singleton) - then have "winding_number g z = winding_number(linepath (pathstart g) (pathstart g)) z" - by (rule winding_number_homotopic_paths) - also have "\ = 0" - using assms by (force intro: winding_number_trivial) - finally show ?thesis . -qed - -lemma Cauchy_theorem_simply_connected: - assumes "open S" "simply_connected S" "f holomorphic_on S" "valid_path g" - "path_image g \ S" "pathfinish g = pathstart g" - shows "(f has_contour_integral 0) g" -using assms -apply (simp add: simply_connected_eq_contractible_path) -apply (auto intro!: Cauchy_theorem_null_homotopic [where a = "pathstart g"] - homotopic_paths_imp_homotopic_loops) -using valid_path_imp_path by blast - -proposition\<^marker>\tag unimportant\ holomorphic_logarithm_exists: - assumes A: "convex A" "open A" - and f: "f holomorphic_on A" "\x. x \ A \ f x \ 0" - and z0: "z0 \ A" - obtains g where "g holomorphic_on A" and "\x. x \ A \ exp (g x) = f x" -proof - - note f' = holomorphic_derivI [OF f(1) A(2)] - obtain g where g: "\x. x \ A \ (g has_field_derivative deriv f x / f x) (at x)" - proof (rule holomorphic_convex_primitive' [OF A]) - show "(\x. deriv f x / f x) holomorphic_on A" - by (intro holomorphic_intros f A) - qed (auto simp: A at_within_open[of _ A]) - define h where "h = (\x. -g z0 + ln (f z0) + g x)" - from g and A have g_holo: "g holomorphic_on A" - by (auto simp: holomorphic_on_def at_within_open[of _ A] field_differentiable_def) - hence h_holo: "h holomorphic_on A" - by (auto simp: h_def intro!: holomorphic_intros) - have "\c. \x\A. f x / exp (h x) - 1 = c" - proof (rule has_field_derivative_zero_constant, goal_cases) - case (2 x) - note [simp] = at_within_open[OF _ \open A\] - from 2 and z0 and f show ?case - by (auto simp: h_def exp_diff field_simps intro!: derivative_eq_intros g f') - qed fact+ - then obtain c where c: "\x. x \ A \ f x / exp (h x) - 1 = c" - by blast - from c[OF z0] and z0 and f have "c = 0" - by (simp add: h_def) - with c have "\x. x \ A \ exp (h x) = f x" by simp - from that[OF h_holo this] show ?thesis . -qed - -subsection \Complex functions and power series\ - -text \ - The following defines the power series expansion of a complex function at a given point - (assuming that it is analytic at that point). -\ -definition\<^marker>\tag important\ fps_expansion :: "(complex \ complex) \ complex \ complex fps" where - "fps_expansion f z0 = Abs_fps (\n. (deriv ^^ n) f z0 / fact n)" - -lemma - fixes r :: ereal - assumes "f holomorphic_on eball z0 r" - shows conv_radius_fps_expansion: "fps_conv_radius (fps_expansion f z0) \ r" - and eval_fps_expansion: "\z. z \ eball z0 r \ eval_fps (fps_expansion f z0) (z - z0) = f z" - and eval_fps_expansion': "\z. norm z < r \ eval_fps (fps_expansion f z0) z = f (z0 + z)" -proof - - have "(\n. fps_nth (fps_expansion f z0) n * (z - z0) ^ n) sums f z" - if "z \ ball z0 r'" "ereal r' < r" for z r' - proof - - from that(2) have "ereal r' \ r" by simp - from assms(1) and this have "f holomorphic_on ball z0 r'" - by (rule holomorphic_on_subset[OF _ ball_eball_mono]) - from holomorphic_power_series [OF this that(1)] - show ?thesis by (simp add: fps_expansion_def) - qed - hence *: "(\n. fps_nth (fps_expansion f z0) n * (z - z0) ^ n) sums f z" - if "z \ eball z0 r" for z - using that by (subst (asm) eball_conv_UNION_balls) blast - show "fps_conv_radius (fps_expansion f z0) \ r" unfolding fps_conv_radius_def - proof (rule conv_radius_geI_ex) - fix r' :: real assume r': "r' > 0" "ereal r' < r" - thus "\z. norm z = r' \ summable (\n. fps_nth (fps_expansion f z0) n * z ^ n)" - using *[of "z0 + of_real r'"] - by (intro exI[of _ "of_real r'"]) (auto simp: summable_def dist_norm) - qed - show "eval_fps (fps_expansion f z0) (z - z0) = f z" if "z \ eball z0 r" for z - using *[OF that] by (simp add: eval_fps_def sums_iff) - show "eval_fps (fps_expansion f z0) z = f (z0 + z)" if "ereal (norm z) < r" for z - using *[of "z0 + z"] and that by (simp add: eval_fps_def sums_iff dist_norm) -qed - - -text \ - We can now show several more facts about power series expansions (at least in the complex case) - with relative ease that would have been trickier without complex analysis. -\ -lemma - fixes f :: "complex fps" and r :: ereal - assumes "\z. ereal (norm z) < r \ eval_fps f z \ 0" - shows fps_conv_radius_inverse: "fps_conv_radius (inverse f) \ min r (fps_conv_radius f)" - and eval_fps_inverse: "\z. ereal (norm z) < fps_conv_radius f \ ereal (norm z) < r \ - eval_fps (inverse f) z = inverse (eval_fps f z)" -proof - - define R where "R = min (fps_conv_radius f) r" - have *: "fps_conv_radius (inverse f) \ min r (fps_conv_radius f) \ - (\z\eball 0 (min (fps_conv_radius f) r). eval_fps (inverse f) z = inverse (eval_fps f z))" - proof (cases "min r (fps_conv_radius f) > 0") - case True - define f' where "f' = fps_expansion (\z. inverse (eval_fps f z)) 0" - have holo: "(\z. inverse (eval_fps f z)) holomorphic_on eball 0 (min r (fps_conv_radius f))" - using assms by (intro holomorphic_intros) auto - from holo have radius: "fps_conv_radius f' \ min r (fps_conv_radius f)" - unfolding f'_def by (rule conv_radius_fps_expansion) - have eval_f': "eval_fps f' z = inverse (eval_fps f z)" - if "norm z < fps_conv_radius f" "norm z < r" for z - using that unfolding f'_def by (subst eval_fps_expansion'[OF holo]) auto - - have "f * f' = 1" - proof (rule eval_fps_eqD) - from radius and True have "0 < min (fps_conv_radius f) (fps_conv_radius f')" - by (auto simp: min_def split: if_splits) - also have "\ \ fps_conv_radius (f * f')" by (rule fps_conv_radius_mult) - finally show "\ > 0" . - next - from True have "R > 0" by (auto simp: R_def) - hence "eventually (\z. z \ eball 0 R) (nhds 0)" - by (intro eventually_nhds_in_open) (auto simp: zero_ereal_def) - thus "eventually (\z. eval_fps (f * f') z = eval_fps 1 z) (nhds 0)" - proof eventually_elim - case (elim z) - hence "eval_fps (f * f') z = eval_fps f z * eval_fps f' z" - using radius by (intro eval_fps_mult) - (auto simp: R_def min_def split: if_splits intro: less_trans) - also have "eval_fps f' z = inverse (eval_fps f z)" - using elim by (intro eval_f') (auto simp: R_def) - also from elim have "eval_fps f z \ 0" - by (intro assms) (auto simp: R_def) - hence "eval_fps f z * inverse (eval_fps f z) = eval_fps 1 z" - by simp - finally show "eval_fps (f * f') z = eval_fps 1 z" . - qed - qed simp_all - hence "f' = inverse f" - by (intro fps_inverse_unique [symmetric]) (simp_all add: mult_ac) - with eval_f' and radius show ?thesis by simp - next - case False - hence *: "eball 0 R = {}" - by (intro eball_empty) (auto simp: R_def min_def split: if_splits) - show ?thesis - proof safe - from False have "min r (fps_conv_radius f) \ 0" - by (simp add: min_def) - also have "0 \ fps_conv_radius (inverse f)" - by (simp add: fps_conv_radius_def conv_radius_nonneg) - finally show "min r (fps_conv_radius f) \ \" . - qed (unfold * [unfolded R_def], auto) - qed - - from * show "fps_conv_radius (inverse f) \ min r (fps_conv_radius f)" by blast - from * show "eval_fps (inverse f) z = inverse (eval_fps f z)" - if "ereal (norm z) < fps_conv_radius f" "ereal (norm z) < r" for z - using that by auto -qed - -lemma - fixes f g :: "complex fps" and r :: ereal - defines "R \ Min {r, fps_conv_radius f, fps_conv_radius g}" - assumes "fps_conv_radius f > 0" "fps_conv_radius g > 0" "r > 0" - assumes nz: "\z. z \ eball 0 r \ eval_fps g z \ 0" - shows fps_conv_radius_divide': "fps_conv_radius (f / g) \ R" - and eval_fps_divide': - "ereal (norm z) < R \ eval_fps (f / g) z = eval_fps f z / eval_fps g z" -proof - - from nz[of 0] and \r > 0\ have nz': "fps_nth g 0 \ 0" - by (auto simp: eval_fps_at_0 zero_ereal_def) - have "R \ min r (fps_conv_radius g)" - by (auto simp: R_def intro: min.coboundedI2) - also have "min r (fps_conv_radius g) \ fps_conv_radius (inverse g)" - by (intro fps_conv_radius_inverse assms) (auto simp: zero_ereal_def) - finally have radius: "fps_conv_radius (inverse g) \ R" . - have "R \ min (fps_conv_radius f) (fps_conv_radius (inverse g))" - by (intro radius min.boundedI) (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) - also have "\ \ fps_conv_radius (f * inverse g)" - by (rule fps_conv_radius_mult) - also have "f * inverse g = f / g" - by (intro fps_divide_unit [symmetric] nz') - finally show "fps_conv_radius (f / g) \ R" . - - assume z: "ereal (norm z) < R" - have "eval_fps (f * inverse g) z = eval_fps f z * eval_fps (inverse g) z" - using radius by (intro eval_fps_mult less_le_trans[OF z]) - (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) - also have "eval_fps (inverse g) z = inverse (eval_fps g z)" using \r > 0\ - by (intro eval_fps_inverse[where r = r] less_le_trans[OF z] nz) - (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) - also have "f * inverse g = f / g" by fact - finally show "eval_fps (f / g) z = eval_fps f z / eval_fps g z" by (simp add: field_split_simps) -qed - -lemma - fixes f g :: "complex fps" and r :: ereal - defines "R \ Min {r, fps_conv_radius f, fps_conv_radius g}" - assumes "subdegree g \ subdegree f" - assumes "fps_conv_radius f > 0" "fps_conv_radius g > 0" "r > 0" - assumes "\z. z \ eball 0 r \ z \ 0 \ eval_fps g z \ 0" - shows fps_conv_radius_divide: "fps_conv_radius (f / g) \ R" - and eval_fps_divide: - "ereal (norm z) < R \ c = fps_nth f (subdegree g) / fps_nth g (subdegree g) \ - eval_fps (f / g) z = (if z = 0 then c else eval_fps f z / eval_fps g z)" -proof - - define f' g' where "f' = fps_shift (subdegree g) f" and "g' = fps_shift (subdegree g) g" - have f_eq: "f = f' * fps_X ^ subdegree g" and g_eq: "g = g' * fps_X ^ subdegree g" - unfolding f'_def g'_def by (rule subdegree_decompose' le_refl | fact)+ - have subdegree: "subdegree f' = subdegree f - subdegree g" "subdegree g' = 0" - using assms(2) by (simp_all add: f'_def g'_def) - have [simp]: "fps_conv_radius f' = fps_conv_radius f" "fps_conv_radius g' = fps_conv_radius g" - by (simp_all add: f'_def g'_def) - have [simp]: "fps_nth f' 0 = fps_nth f (subdegree g)" - "fps_nth g' 0 = fps_nth g (subdegree g)" by (simp_all add: f'_def g'_def) - have g_nz: "g \ 0" - proof - - define z :: complex where "z = (if r = \ then 1 else of_real (real_of_ereal r / 2))" - from \r > 0\ have "z \ eball 0 r" - by (cases r) (auto simp: z_def eball_def) - moreover have "z \ 0" using \r > 0\ - by (cases r) (auto simp: z_def) - ultimately have "eval_fps g z \ 0" by (rule assms(6)) - thus "g \ 0" by auto - qed - have fg: "f / g = f' * inverse g'" - by (subst f_eq, subst (2) g_eq) (insert g_nz, simp add: fps_divide_unit) - - have g'_nz: "eval_fps g' z \ 0" if z: "norm z < min r (fps_conv_radius g)" for z - proof (cases "z = 0") - case False - with assms and z have "eval_fps g z \ 0" by auto - also from z have "eval_fps g z = eval_fps g' z * z ^ subdegree g" - by (subst g_eq) (auto simp: eval_fps_mult) - finally show ?thesis by auto - qed (insert \g \ 0\, auto simp: g'_def eval_fps_at_0) - - have "R \ min (min r (fps_conv_radius g)) (fps_conv_radius g')" - by (auto simp: R_def min.coboundedI1 min.coboundedI2) - also have "\ \ fps_conv_radius (inverse g')" - using g'_nz by (rule fps_conv_radius_inverse) - finally have conv_radius_inv: "R \ fps_conv_radius (inverse g')" . - hence "R \ fps_conv_radius (f' * inverse g')" - by (intro order.trans[OF _ fps_conv_radius_mult]) - (auto simp: R_def intro: min.coboundedI1 min.coboundedI2) - thus "fps_conv_radius (f / g) \ R" by (simp add: fg) - - fix z c :: complex assume z: "ereal (norm z) < R" - assume c: "c = fps_nth f (subdegree g) / fps_nth g (subdegree g)" - show "eval_fps (f / g) z = (if z = 0 then c else eval_fps f z / eval_fps g z)" - proof (cases "z = 0") - case False - from z and conv_radius_inv have "ereal (norm z) < fps_conv_radius (inverse g')" - by simp - with z have "eval_fps (f / g) z = eval_fps f' z * eval_fps (inverse g') z" - unfolding fg by (subst eval_fps_mult) (auto simp: R_def) - also have "eval_fps (inverse g') z = inverse (eval_fps g' z)" - using z by (intro eval_fps_inverse[of "min r (fps_conv_radius g')"] g'_nz) (auto simp: R_def) - also have "eval_fps f' z * \ = eval_fps f z / eval_fps g z" - using z False assms(2) by (simp add: f'_def g'_def eval_fps_shift R_def) - finally show ?thesis using False by simp - qed (simp_all add: eval_fps_at_0 fg field_simps c) -qed - -lemma has_fps_expansion_fps_expansion [intro]: - assumes "open A" "0 \ A" "f holomorphic_on A" - shows "f has_fps_expansion fps_expansion f 0" -proof - - from assms(1,2) obtain r where r: "r > 0 " "ball 0 r \ A" - by (auto simp: open_contains_ball) - have holo: "f holomorphic_on eball 0 (ereal r)" - using r(2) and assms(3) by auto - from r(1) have "0 < ereal r" by simp - also have "r \ fps_conv_radius (fps_expansion f 0)" - using holo by (intro conv_radius_fps_expansion) auto - finally have "\ > 0" . - moreover have "eventually (\z. z \ ball 0 r) (nhds 0)" - using r(1) by (intro eventually_nhds_in_open) auto - hence "eventually (\z. eval_fps (fps_expansion f 0) z = f z) (nhds 0)" - by eventually_elim (subst eval_fps_expansion'[OF holo], auto) - ultimately show ?thesis using r(1) by (auto simp: has_fps_expansion_def) -qed - -lemma fps_conv_radius_tan: - fixes c :: complex - assumes "c \ 0" - shows "fps_conv_radius (fps_tan c) \ pi / (2 * norm c)" -proof - - have "fps_conv_radius (fps_tan c) \ - Min {pi / (2 * norm c), fps_conv_radius (fps_sin c), fps_conv_radius (fps_cos c)}" - unfolding fps_tan_def - proof (rule fps_conv_radius_divide) - fix z :: complex assume "z \ eball 0 (pi / (2 * norm c))" - with cos_eq_zero_imp_norm_ge[of "c*z"] assms - show "eval_fps (fps_cos c) z \ 0" by (auto simp: norm_mult field_simps) - qed (insert assms, auto) - thus ?thesis by (simp add: min_def) -qed - -lemma eval_fps_tan: - fixes c :: complex - assumes "norm z < pi / (2 * norm c)" - shows "eval_fps (fps_tan c) z = tan (c * z)" -proof (cases "c = 0") - case False - show ?thesis unfolding fps_tan_def - proof (subst eval_fps_divide'[where r = "pi / (2 * norm c)"]) - fix z :: complex assume "z \ eball 0 (pi / (2 * norm c))" - with cos_eq_zero_imp_norm_ge[of "c*z"] assms - show "eval_fps (fps_cos c) z \ 0" using False by (auto simp: norm_mult field_simps) - qed (insert False assms, auto simp: field_simps tan_def) -qed simp_all - -end +end \ No newline at end of file diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Complex_Analysis.thy --- a/src/HOL/Complex_Analysis/Complex_Analysis.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Complex_Analysis.thy Mon Dec 02 17:51:54 2019 +0100 @@ -1,6 +1,7 @@ theory Complex_Analysis - imports - Winding_Numbers +imports + Residue_Theorem + Riemann_Mapping begin end diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Complex_Residues.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Complex_Analysis/Complex_Residues.thy Mon Dec 02 17:51:54 2019 +0100 @@ -0,0 +1,545 @@ +theory Complex_Residues + imports Complex_Singularities +begin + +subsection \Definition of residues\ + +text\Wenda Li and LC Paulson (2016). A Formal Proof of Cauchy's Residue Theorem. + Interactive Theorem Proving\ + +definition\<^marker>\tag important\ residue :: "(complex \ complex) \ complex \ complex" where + "residue f z = (SOME int. \e>0. \\>0. \ (f has_contour_integral 2*pi* \ *int) (circlepath z \))" + +lemma Eps_cong: + assumes "\x. P x = Q x" + shows "Eps P = Eps Q" + using ext[of P Q, OF assms] by simp + +lemma residue_cong: + assumes eq: "eventually (\z. f z = g z) (at z)" and "z = z'" + shows "residue f z = residue g z'" +proof - + from assms have eq': "eventually (\z. g z = f z) (at z)" + by (simp add: eq_commute) + let ?P = "\f c e. (\\>0. \ < e \ + (f has_contour_integral of_real (2 * pi) * \ * c) (circlepath z \))" + have "residue f z = residue g z" unfolding residue_def + proof (rule Eps_cong) + fix c :: complex + have "\e>0. ?P g c e" + if "\e>0. ?P f c e" and "eventually (\z. f z = g z) (at z)" for f g + proof - + from that(1) obtain e where e: "e > 0" "?P f c e" + by blast + from that(2) obtain e' where e': "e' > 0" "\z'. z' \ z \ dist z' z < e' \ f z' = g z'" + unfolding eventually_at by blast + have "?P g c (min e e')" + proof (intro allI exI impI, goal_cases) + case (1 \) + hence "(f has_contour_integral of_real (2 * pi) * \ * c) (circlepath z \)" + using e(2) by auto + thus ?case + proof (rule has_contour_integral_eq) + fix z' assume "z' \ path_image (circlepath z \)" + hence "dist z' z < e'" and "z' \ z" + using 1 by (auto simp: dist_commute) + with e'(2)[of z'] show "f z' = g z'" by simp + qed + qed + moreover from e and e' have "min e e' > 0" by auto + ultimately show ?thesis by blast + qed + from this[OF _ eq] and this[OF _ eq'] + show "(\e>0. ?P f c e) \ (\e>0. ?P g c e)" + by blast + qed + with assms show ?thesis by simp +qed + +lemma contour_integral_circlepath_eq: + assumes "open s" and f_holo:"f holomorphic_on (s-{z})" and "0e2" + and e2_cball:"cball z e2 \ s" + shows + "f contour_integrable_on circlepath z e1" + "f contour_integrable_on circlepath z e2" + "contour_integral (circlepath z e2) f = contour_integral (circlepath z e1) f" +proof - + define l where "l \ linepath (z+e2) (z+e1)" + have [simp]:"valid_path l" "pathstart l=z+e2" "pathfinish l=z+e1" unfolding l_def by auto + have "e2>0" using \e1>0\ \e1\e2\ by auto + have zl_img:"z\path_image l" + proof + assume "z \ path_image l" + then have "e2 \ cmod (e2 - e1)" + using segment_furthest_le[of z "z+e2" "z+e1" "z+e2",simplified] \e1>0\ \e2>0\ unfolding l_def + by (auto simp add:closed_segment_commute) + thus False using \e2>0\ \e1>0\ \e1\e2\ + apply (subst (asm) norm_of_real) + by auto + qed + define g where "g \ circlepath z e2 +++ l +++ reversepath (circlepath z e1) +++ reversepath l" + show [simp]: "f contour_integrable_on circlepath z e2" "f contour_integrable_on (circlepath z e1)" + proof - + show "f contour_integrable_on circlepath z e2" + apply (intro contour_integrable_continuous_circlepath[OF + continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) + using \e2>0\ e2_cball by auto + show "f contour_integrable_on (circlepath z e1)" + apply (intro contour_integrable_continuous_circlepath[OF + continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) + using \e1>0\ \e1\e2\ e2_cball by auto + qed + have [simp]:"f contour_integrable_on l" + proof - + have "closed_segment (z + e2) (z + e1) \ cball z e2" using \e2>0\ \e1>0\ \e1\e2\ + by (intro closed_segment_subset,auto simp add:dist_norm) + hence "closed_segment (z + e2) (z + e1) \ s - {z}" using zl_img e2_cball unfolding l_def + by auto + then show "f contour_integrable_on l" unfolding l_def + apply (intro contour_integrable_continuous_linepath[OF + continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) + by auto + qed + let ?ig="\g. contour_integral g f" + have "(f has_contour_integral 0) g" + proof (rule Cauchy_theorem_global[OF _ f_holo]) + show "open (s - {z})" using \open s\ by auto + show "valid_path g" unfolding g_def l_def by auto + show "pathfinish g = pathstart g" unfolding g_def l_def by auto + next + have path_img:"path_image g \ cball z e2" + proof - + have "closed_segment (z + e2) (z + e1) \ cball z e2" using \e2>0\ \e1>0\ \e1\e2\ + by (intro closed_segment_subset,auto simp add:dist_norm) + moreover have "sphere z \e1\ \ cball z e2" using \e2>0\ \e1\e2\ \e1>0\ by auto + ultimately show ?thesis unfolding g_def l_def using \e2>0\ + by (simp add: path_image_join closed_segment_commute) + qed + show "path_image g \ s - {z}" + proof - + have "z\path_image g" using zl_img + unfolding g_def l_def by (auto simp add: path_image_join closed_segment_commute) + moreover note \cball z e2 \ s\ and path_img + ultimately show ?thesis by auto + qed + show "winding_number g w = 0" when"w \ s - {z}" for w + proof - + have "winding_number g w = 0" when "w\s" using that e2_cball + apply (intro winding_number_zero_outside[OF _ _ _ _ path_img]) + by (auto simp add:g_def l_def) + moreover have "winding_number g z=0" + proof - + let ?Wz="\g. winding_number g z" + have "?Wz g = ?Wz (circlepath z e2) + ?Wz l + ?Wz (reversepath (circlepath z e1)) + + ?Wz (reversepath l)" + using \e2>0\ \e1>0\ zl_img unfolding g_def l_def + by (subst winding_number_join,auto simp add:path_image_join closed_segment_commute)+ + also have "... = ?Wz (circlepath z e2) + ?Wz (reversepath (circlepath z e1))" + using zl_img + apply (subst (2) winding_number_reversepath) + by (auto simp add:l_def closed_segment_commute) + also have "... = 0" + proof - + have "?Wz (circlepath z e2) = 1" using \e2>0\ + by (auto intro: winding_number_circlepath_centre) + moreover have "?Wz (reversepath (circlepath z e1)) = -1" using \e1>0\ + apply (subst winding_number_reversepath) + by (auto intro: winding_number_circlepath_centre) + ultimately show ?thesis by auto + qed + finally show ?thesis . + qed + ultimately show ?thesis using that by auto + qed + qed + then have "0 = ?ig g" using contour_integral_unique by simp + also have "... = ?ig (circlepath z e2) + ?ig l + ?ig (reversepath (circlepath z e1)) + + ?ig (reversepath l)" + unfolding g_def + by (auto simp add:contour_integrable_reversepath_eq) + also have "... = ?ig (circlepath z e2) - ?ig (circlepath z e1)" + by (auto simp add:contour_integral_reversepath) + finally show "contour_integral (circlepath z e2) f = contour_integral (circlepath z e1) f" + by simp +qed + +lemma base_residue: + assumes "open s" "z\s" "r>0" and f_holo:"f holomorphic_on (s - {z})" + and r_cball:"cball z r \ s" + shows "(f has_contour_integral 2 * pi * \ * (residue f z)) (circlepath z r)" +proof - + obtain e where "e>0" and e_cball:"cball z e \ s" + using open_contains_cball[of s] \open s\ \z\s\ by auto + define c where "c \ 2 * pi * \" + define i where "i \ contour_integral (circlepath z e) f / c" + have "(f has_contour_integral c*i) (circlepath z \)" when "\>0" "\ + proof - + have "contour_integral (circlepath z e) f = contour_integral (circlepath z \) f" + "f contour_integrable_on circlepath z \" + "f contour_integrable_on circlepath z e" + using \\ + by (intro contour_integral_circlepath_eq[OF \open s\ f_holo \\>0\ _ e_cball],auto)+ + then show ?thesis unfolding i_def c_def + by (auto intro:has_contour_integral_integral) + qed + then have "\e>0. \\>0. \ (f has_contour_integral c * (residue f z)) (circlepath z \)" + unfolding residue_def c_def + apply (rule_tac someI[of _ i],intro exI[where x=e]) + by (auto simp add:\e>0\ c_def) + then obtain e' where "e'>0" + and e'_def:"\\>0. \ (f has_contour_integral c * (residue f z)) (circlepath z \)" + by auto + let ?int="\e. contour_integral (circlepath z e) f" + define \ where "\ \ Min {r,e'} / 2" + have "\>0" "\\r" "\r>0\ \e'>0\ unfolding \_def by auto + have "(f has_contour_integral c * (residue f z)) (circlepath z \)" + using e'_def[rule_format,OF \\>0\ \\] . + then show ?thesis unfolding c_def + using contour_integral_circlepath_eq[OF \open s\ f_holo \\>0\ \\\r\ r_cball] + by (auto elim: has_contour_integral_eqpath[of _ _ "circlepath z \" "circlepath z r"]) +qed + +lemma residue_holo: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s" + shows "residue f z = 0" +proof - + define c where "c \ 2 * pi * \" + obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ + using open_contains_cball_eq by blast + have "(f has_contour_integral c*residue f z) (circlepath z e)" + using f_holo + by (auto intro: base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) + moreover have "(f has_contour_integral 0) (circlepath z e)" + using f_holo e_cball \e>0\ + by (auto intro: Cauchy_theorem_convex_simple[of _ "cball z e"]) + ultimately have "c*residue f z =0" + using has_contour_integral_unique by blast + thus ?thesis unfolding c_def by auto +qed + +lemma residue_const:"residue (\_. c) z = 0" + by (intro residue_holo[of "UNIV::complex set"],auto intro:holomorphic_intros) + +lemma residue_add: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + and g_holo:"g holomorphic_on s - {z}" + shows "residue (\z. f z + g z) z= residue f z + residue g z" +proof - + define c where "c \ 2 * pi * \" + define fg where "fg \ (\z. f z+g z)" + obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ + using open_contains_cball_eq by blast + have "(fg has_contour_integral c * residue fg z) (circlepath z e)" + unfolding fg_def using f_holo g_holo + apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) + by (auto intro:holomorphic_intros) + moreover have "(fg has_contour_integral c*residue f z + c* residue g z) (circlepath z e)" + unfolding fg_def using f_holo g_holo + by (auto intro: has_contour_integral_add base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) + ultimately have "c*(residue f z + residue g z) = c * residue fg z" + using has_contour_integral_unique by (auto simp add:distrib_left) + thus ?thesis unfolding fg_def + by (auto simp add:c_def) +qed + +lemma residue_lmul: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + shows "residue (\z. c * (f z)) z= c * residue f z" +proof (cases "c=0") + case True + thus ?thesis using residue_const by auto +next + case False + define c' where "c' \ 2 * pi * \" + define f' where "f' \ (\z. c * (f z))" + obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ + using open_contains_cball_eq by blast + have "(f' has_contour_integral c' * residue f' z) (circlepath z e)" + unfolding f'_def using f_holo + apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c'_def]) + by (auto intro:holomorphic_intros) + moreover have "(f' has_contour_integral c * (c' * residue f z)) (circlepath z e)" + unfolding f'_def using f_holo + by (auto intro: has_contour_integral_lmul + base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c'_def]) + ultimately have "c' * residue f' z = c * (c' * residue f z)" + using has_contour_integral_unique by auto + thus ?thesis unfolding f'_def c'_def using False + by (auto simp add:field_simps) +qed + +lemma residue_rmul: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + shows "residue (\z. (f z) * c) z= residue f z * c" +using residue_lmul[OF assms,of c] by (auto simp add:algebra_simps) + +lemma residue_div: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + shows "residue (\z. (f z) / c) z= residue f z / c " +using residue_lmul[OF assms,of "1/c"] by (auto simp add:algebra_simps) + +lemma residue_neg: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + shows "residue (\z. - (f z)) z= - residue f z" +using residue_lmul[OF assms,of "-1"] by auto + +lemma residue_diff: + assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" + and g_holo:"g holomorphic_on s - {z}" + shows "residue (\z. f z - g z) z= residue f z - residue g z" +using residue_add[OF assms(1,2,3),of "\z. - g z"] residue_neg[OF assms(1,2,4)] +by (auto intro:holomorphic_intros g_holo) + +lemma residue_simple: + assumes "open s" "z\s" and f_holo:"f holomorphic_on s" + shows "residue (\w. f w / (w - z)) z = f z" +proof - + define c where "c \ 2 * pi * \" + define f' where "f' \ \w. f w / (w - z)" + obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ + using open_contains_cball_eq by blast + have "(f' has_contour_integral c * f z) (circlepath z e)" + unfolding f'_def c_def using \e>0\ f_holo e_cball + by (auto intro!: Cauchy_integral_circlepath_simple holomorphic_intros) + moreover have "(f' has_contour_integral c * residue f' z) (circlepath z e)" + unfolding f'_def using f_holo + apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) + by (auto intro!:holomorphic_intros) + ultimately have "c * f z = c * residue f' z" + using has_contour_integral_unique by blast + thus ?thesis unfolding c_def f'_def by auto +qed + +lemma residue_simple': + assumes s: "open s" "z \ s" and holo: "f holomorphic_on (s - {z})" + and lim: "((\w. f w * (w - z)) \ c) (at z)" + shows "residue f z = c" +proof - + define g where "g = (\w. if w = z then c else f w * (w - z))" + from holo have "(\w. f w * (w - z)) holomorphic_on (s - {z})" (is "?P") + by (force intro: holomorphic_intros) + also have "?P \ g holomorphic_on (s - {z})" + by (intro holomorphic_cong refl) (simp_all add: g_def) + finally have *: "g holomorphic_on (s - {z})" . + + note lim + also have "(\w. f w * (w - z)) \z\ c \ g \z\ g z" + by (intro filterlim_cong refl) (simp_all add: g_def [abs_def] eventually_at_filter) + finally have **: "g \z\ g z" . + + have g_holo: "g holomorphic_on s" + by (rule no_isolated_singularity'[where K = "{z}"]) + (insert assms * **, simp_all add: at_within_open_NO_MATCH) + from s and this have "residue (\w. g w / (w - z)) z = g z" + by (rule residue_simple) + also have "\\<^sub>F za in at z. g za / (za - z) = f za" + unfolding eventually_at by (auto intro!: exI[of _ 1] simp: field_simps g_def) + hence "residue (\w. g w / (w - z)) z = residue f z" + by (intro residue_cong refl) + finally show ?thesis + by (simp add: g_def) +qed + +lemma residue_holomorphic_over_power: + assumes "open A" "z0 \ A" "f holomorphic_on A" + shows "residue (\z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n" +proof - + let ?f = "\z. f z / (z - z0) ^ Suc n" + from assms(1,2) obtain r where r: "r > 0" "cball z0 r \ A" + by (auto simp: open_contains_cball) + have "(?f has_contour_integral 2 * pi * \ * residue ?f z0) (circlepath z0 r)" + using r assms by (intro base_residue[of A]) (auto intro!: holomorphic_intros) + moreover have "(?f has_contour_integral 2 * pi * \ / fact n * (deriv ^^ n) f z0) (circlepath z0 r)" + using assms r + by (intro Cauchy_has_contour_integral_higher_derivative_circlepath) + (auto intro!: holomorphic_on_subset[OF assms(3)] holomorphic_on_imp_continuous_on) + ultimately have "2 * pi * \ * residue ?f z0 = 2 * pi * \ / fact n * (deriv ^^ n) f z0" + by (rule has_contour_integral_unique) + thus ?thesis by (simp add: field_simps) +qed + +lemma residue_holomorphic_over_power': + assumes "open A" "0 \ A" "f holomorphic_on A" + shows "residue (\z. f z / z ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" + using residue_holomorphic_over_power[OF assms] by simp + +theorem residue_fps_expansion_over_power_at_0: + assumes "f has_fps_expansion F" + shows "residue (\z. f z / z ^ Suc n) 0 = fps_nth F n" +proof - + from has_fps_expansion_imp_holomorphic[OF assms] guess s . note s = this + have "residue (\z. f z / (z - 0) ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" + using assms s unfolding has_fps_expansion_def + by (intro residue_holomorphic_over_power[of s]) (auto simp: zero_ereal_def) + also from assms have "\ = fps_nth F n" + by (subst fps_nth_fps_expansion) auto + finally show ?thesis by simp +qed + +lemma residue_pole_order: + fixes f::"complex \ complex" and z::complex + defines "n \ nat (- zorder f z)" and "h \ zor_poly f z" + assumes f_iso:"isolated_singularity_at f z" + and pole:"is_pole f z" + shows "residue f z = ((deriv ^^ (n - 1)) h z / fact (n-1))" +proof - + define g where "g \ \x. if x=z then 0 else inverse (f x)" + obtain e where [simp]:"e>0" and f_holo:"f holomorphic_on ball z e - {z}" + using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by blast + obtain r where "0 < n" "0 < r" and r_cball:"cball z r \ ball z e" and h_holo: "h holomorphic_on cball z r" + and h_divide:"(\w\cball z r. (w\z \ f w = h w / (w - z) ^ n) \ h w \ 0)" + proof - + obtain r where r:"zorder f z < 0" "h z \ 0" "r>0" "cball z r \ ball z e" "h holomorphic_on cball z r" + "(\w\cball z r - {z}. f w = h w / (w - z) ^ n \ h w \ 0)" + using zorder_exist_pole[OF f_holo,simplified,OF \is_pole f z\,folded n_def h_def] by auto + have "n>0" using \zorder f z < 0\ unfolding n_def by simp + moreover have "(\w\cball z r. (w\z \ f w = h w / (w - z) ^ n) \ h w \ 0)" + using \h z\0\ r(6) by blast + ultimately show ?thesis using r(3,4,5) that by blast + qed + have r_nonzero:"\w. w \ ball z r - {z} \ f w \ 0" + using h_divide by simp + define c where "c \ 2 * pi * \" + define der_f where "der_f \ ((deriv ^^ (n - 1)) h z / fact (n-1))" + define h' where "h' \ \u. h u / (u - z) ^ n" + have "(h' has_contour_integral c / fact (n - 1) * (deriv ^^ (n - 1)) h z) (circlepath z r)" + unfolding h'_def + proof (rule Cauchy_has_contour_integral_higher_derivative_circlepath[of z r h z "n-1", + folded c_def Suc_pred'[OF \n>0\]]) + show "continuous_on (cball z r) h" using holomorphic_on_imp_continuous_on h_holo by simp + show "h holomorphic_on ball z r" using h_holo by auto + show " z \ ball z r" using \r>0\ by auto + qed + then have "(h' has_contour_integral c * der_f) (circlepath z r)" unfolding der_f_def by auto + then have "(f has_contour_integral c * der_f) (circlepath z r)" + proof (elim has_contour_integral_eq) + fix x assume "x \ path_image (circlepath z r)" + hence "x\cball z r - {z}" using \r>0\ by auto + then show "h' x = f x" using h_divide unfolding h'_def by auto + qed + moreover have "(f has_contour_integral c * residue f z) (circlepath z r)" + using base_residue[of \ball z e\ z,simplified,OF \r>0\ f_holo r_cball,folded c_def] + unfolding c_def by simp + ultimately have "c * der_f = c * residue f z" using has_contour_integral_unique by blast + hence "der_f = residue f z" unfolding c_def by auto + thus ?thesis unfolding der_f_def by auto +qed + +lemma residue_simple_pole: + assumes "isolated_singularity_at f z0" + assumes "is_pole f z0" "zorder f z0 = - 1" + shows "residue f z0 = zor_poly f z0 z0" + using assms by (subst residue_pole_order) simp_all + +lemma residue_simple_pole_limit: + assumes "isolated_singularity_at f z0" + assumes "is_pole f z0" "zorder f z0 = - 1" + assumes "((\x. f (g x) * (g x - z0)) \ c) F" + assumes "filterlim g (at z0) F" "F \ bot" + shows "residue f z0 = c" +proof - + have "residue f z0 = zor_poly f z0 z0" + by (rule residue_simple_pole assms)+ + also have "\ = c" + apply (rule zor_poly_pole_eqI) + using assms by auto + finally show ?thesis . +qed + +lemma + assumes f_holo:"f holomorphic_on s" and g_holo:"g holomorphic_on s" + and "open s" "connected s" "z \ s" + assumes g_deriv:"(g has_field_derivative g') (at z)" + assumes "f z \ 0" "g z = 0" "g' \ 0" + shows porder_simple_pole_deriv: "zorder (\w. f w / g w) z = - 1" + and residue_simple_pole_deriv: "residue (\w. f w / g w) z = f z / g'" +proof - + have [simp]:"isolated_singularity_at f z" "isolated_singularity_at g z" + using isolated_singularity_at_holomorphic[OF _ \open s\ \z\s\] f_holo g_holo + by (meson Diff_subset holomorphic_on_subset)+ + have [simp]:"not_essential f z" "not_essential g z" + unfolding not_essential_def using f_holo g_holo assms(3,5) + by (meson continuous_on_eq_continuous_at continuous_within holomorphic_on_imp_continuous_on)+ + have g_nconst:"\\<^sub>F w in at z. g w \0 " + proof (rule ccontr) + assume "\ (\\<^sub>F w in at z. g w \ 0)" + then have "\\<^sub>F w in nhds z. g w = 0" + unfolding eventually_at eventually_nhds frequently_at using \g z = 0\ + by (metis open_ball UNIV_I centre_in_ball dist_commute mem_ball) + then have "deriv g z = deriv (\_. 0) z" + by (intro deriv_cong_ev) auto + then have "deriv g z = 0" by auto + then have "g' = 0" using g_deriv DERIV_imp_deriv by blast + then show False using \g'\0\ by auto + qed + + have "zorder (\w. f w / g w) z = zorder f z - zorder g z" + proof - + have "\\<^sub>F w in at z. f w \0 \ w\s" + apply (rule non_zero_neighbour_alt) + using assms by auto + with g_nconst have "\\<^sub>F w in at z. f w * g w \ 0" + by (elim frequently_rev_mp eventually_rev_mp,auto) + then show ?thesis using zorder_divide[of f z g] by auto + qed + moreover have "zorder f z=0" + apply (rule zorder_zero_eqI[OF f_holo \open s\ \z\s\]) + using \f z\0\ by auto + moreover have "zorder g z=1" + apply (rule zorder_zero_eqI[OF g_holo \open s\ \z\s\]) + subgoal using assms(8) by auto + subgoal using DERIV_imp_deriv assms(9) g_deriv by auto + subgoal by simp + done + ultimately show "zorder (\w. f w / g w) z = - 1" by auto + + show "residue (\w. f w / g w) z = f z / g'" + proof (rule residue_simple_pole_limit[where g=id and F="at z",simplified]) + show "zorder (\w. f w / g w) z = - 1" by fact + show "isolated_singularity_at (\w. f w / g w) z" + by (auto intro: singularity_intros) + show "is_pole (\w. f w / g w) z" + proof (rule is_pole_divide) + have "\\<^sub>F x in at z. g x \ 0" + apply (rule non_zero_neighbour) + using g_nconst by auto + moreover have "g \z\ 0" + using DERIV_isCont assms(8) continuous_at g_deriv by force + ultimately show "filterlim g (at 0) (at z)" unfolding filterlim_at by simp + show "isCont f z" + using assms(3,5) continuous_on_eq_continuous_at f_holo holomorphic_on_imp_continuous_on + by auto + show "f z \ 0" by fact + qed + show "filterlim id (at z) (at z)" by (simp add: filterlim_iff) + have "((\w. (f w * (w - z)) / g w) \ f z / g') (at z)" + proof (rule lhopital_complex_simple) + show "((\w. f w * (w - z)) has_field_derivative f z) (at z)" + using assms by (auto intro!: derivative_eq_intros holomorphic_derivI[OF f_holo]) + show "(g has_field_derivative g') (at z)" by fact + qed (insert assms, auto) + then show "((\w. (f w / g w) * (w - z)) \ f z / g') (at z)" + by (simp add: field_split_simps) + qed +qed + + +subsection \Poles and residues of some well-known functions\ + +(* TODO: add more material here for other functions *) +lemma is_pole_Gamma: "is_pole Gamma (-of_nat n)" + unfolding is_pole_def using Gamma_poles . + +lemma Gamma_residue: + "residue Gamma (-of_nat n) = (-1) ^ n / fact n" +proof (rule residue_simple') + show "open (- (\\<^sub>\\<^sub>0 - {-of_nat n}) :: complex set)" + by (intro open_Compl closed_subset_Ints) auto + show "Gamma holomorphic_on (- (\\<^sub>\\<^sub>0 - {-of_nat n}) - {- of_nat n})" + by (rule holomorphic_Gamma) auto + show "(\w. Gamma w * (w - (-of_nat n))) \(-of_nat n)\ (- 1) ^ n / fact n" + using Gamma_residues[of n] by simp +qed auto + +end \ No newline at end of file diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Complex_Singularities.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Complex_Analysis/Complex_Singularities.thy Mon Dec 02 17:51:54 2019 +0100 @@ -0,0 +1,1534 @@ +theory Complex_Singularities + imports Conformal_Mappings +begin + +subsection \Non-essential singular points\ + +definition\<^marker>\tag important\ is_pole :: + "('a::topological_space \ 'b::real_normed_vector) \ 'a \ bool" where + "is_pole f a = (LIM x (at a). f x :> at_infinity)" + +lemma is_pole_cong: + assumes "eventually (\x. f x = g x) (at a)" "a=b" + shows "is_pole f a \ is_pole g b" + unfolding is_pole_def using assms by (intro filterlim_cong,auto) + +lemma is_pole_transform: + assumes "is_pole f a" "eventually (\x. f x = g x) (at a)" "a=b" + shows "is_pole g b" + using is_pole_cong assms by auto + +lemma is_pole_tendsto: + fixes f::"('a::topological_space \ 'b::real_normed_div_algebra)" + shows "is_pole f x \ ((inverse o f) \ 0) (at x)" +unfolding is_pole_def +by (auto simp add:filterlim_inverse_at_iff[symmetric] comp_def filterlim_at) + +lemma is_pole_inverse_holomorphic: + assumes "open s" + and f_holo:"f holomorphic_on (s-{z})" + and pole:"is_pole f z" + and non_z:"\x\s-{z}. f x\0" + shows "(\x. if x=z then 0 else inverse (f x)) holomorphic_on s" +proof - + define g where "g \ \x. if x=z then 0 else inverse (f x)" + have "isCont g z" unfolding isCont_def using is_pole_tendsto[OF pole] + apply (subst Lim_cong_at[where b=z and y=0 and g="inverse \ f"]) + by (simp_all add:g_def) + moreover have "continuous_on (s-{z}) f" using f_holo holomorphic_on_imp_continuous_on by auto + hence "continuous_on (s-{z}) (inverse o f)" unfolding comp_def + by (auto elim!:continuous_on_inverse simp add:non_z) + hence "continuous_on (s-{z}) g" unfolding g_def + apply (subst continuous_on_cong[where t="s-{z}" and g="inverse o f"]) + by auto + ultimately have "continuous_on s g" using open_delete[OF \open s\] \open s\ + by (auto simp add:continuous_on_eq_continuous_at) + moreover have "(inverse o f) holomorphic_on (s-{z})" + unfolding comp_def using f_holo + by (auto elim!:holomorphic_on_inverse simp add:non_z) + hence "g holomorphic_on (s-{z})" + apply (subst holomorphic_cong[where t="s-{z}" and g="inverse o f"]) + by (auto simp add:g_def) + ultimately show ?thesis unfolding g_def using \open s\ + by (auto elim!: no_isolated_singularity) +qed + +lemma not_is_pole_holomorphic: + assumes "open A" "x \ A" "f holomorphic_on A" + shows "\is_pole f x" +proof - + have "continuous_on A f" by (intro holomorphic_on_imp_continuous_on) fact + with assms have "isCont f x" by (simp add: continuous_on_eq_continuous_at) + hence "f \x\ f x" by (simp add: isCont_def) + thus "\is_pole f x" unfolding is_pole_def + using not_tendsto_and_filterlim_at_infinity[of "at x" f "f x"] by auto +qed + +lemma is_pole_inverse_power: "n > 0 \ is_pole (\z::complex. 1 / (z - a) ^ n) a" + unfolding is_pole_def inverse_eq_divide [symmetric] + by (intro filterlim_compose[OF filterlim_inverse_at_infinity] tendsto_intros) + (auto simp: filterlim_at eventually_at intro!: exI[of _ 1] tendsto_eq_intros) + +lemma is_pole_inverse: "is_pole (\z::complex. 1 / (z - a)) a" + using is_pole_inverse_power[of 1 a] by simp + +lemma is_pole_divide: + fixes f :: "'a :: t2_space \ 'b :: real_normed_field" + assumes "isCont f z" "filterlim g (at 0) (at z)" "f z \ 0" + shows "is_pole (\z. f z / g z) z" +proof - + have "filterlim (\z. f z * inverse (g z)) at_infinity (at z)" + by (intro tendsto_mult_filterlim_at_infinity[of _ "f z"] + filterlim_compose[OF filterlim_inverse_at_infinity])+ + (insert assms, auto simp: isCont_def) + thus ?thesis by (simp add: field_split_simps is_pole_def) +qed + +lemma is_pole_basic: + assumes "f holomorphic_on A" "open A" "z \ A" "f z \ 0" "n > 0" + shows "is_pole (\w. f w / (w - z) ^ n) z" +proof (rule is_pole_divide) + have "continuous_on A f" by (rule holomorphic_on_imp_continuous_on) fact + with assms show "isCont f z" by (auto simp: continuous_on_eq_continuous_at) + have "filterlim (\w. (w - z) ^ n) (nhds 0) (at z)" + using assms by (auto intro!: tendsto_eq_intros) + thus "filterlim (\w. (w - z) ^ n) (at 0) (at z)" + by (intro filterlim_atI tendsto_eq_intros) + (insert assms, auto simp: eventually_at_filter) +qed fact+ + +lemma is_pole_basic': + assumes "f holomorphic_on A" "open A" "0 \ A" "f 0 \ 0" "n > 0" + shows "is_pole (\w. f w / w ^ n) 0" + using is_pole_basic[of f A 0] assms by simp + +text \The proposition + \<^term>\\x. ((f::complex\complex) \ x) (at z) \ is_pole f z\ +can be interpreted as the complex function \<^term>\f\ has a non-essential singularity at \<^term>\z\ +(i.e. the singularity is either removable or a pole).\ +definition not_essential::"[complex \ complex, complex] \ bool" where + "not_essential f z = (\x. f\z\x \ is_pole f z)" + +definition isolated_singularity_at::"[complex \ complex, complex] \ bool" where + "isolated_singularity_at f z = (\r>0. f analytic_on ball z r-{z})" + +named_theorems singularity_intros "introduction rules for singularities" + +lemma holomorphic_factor_unique: + fixes f::"complex \ complex" and z::complex and r::real and m n::int + assumes "r>0" "g z\0" "h z\0" + and asm:"\w\ball z r-{z}. f w = g w * (w-z) powr n \ g w\0 \ f w = h w * (w - z) powr m \ h w\0" + and g_holo:"g holomorphic_on ball z r" and h_holo:"h holomorphic_on ball z r" + shows "n=m" +proof - + have [simp]:"at z within ball z r \ bot" using \r>0\ + by (auto simp add:at_within_ball_bot_iff) + have False when "n>m" + proof - + have "(h \ 0) (at z within ball z r)" + proof (rule Lim_transform_within[OF _ \r>0\, where f="\w. (w - z) powr (n - m) * g w"]) + have "\w\ball z r-{z}. h w = (w-z)powr(n-m) * g w" + using \n>m\ asm \r>0\ + apply (auto simp add:field_simps powr_diff) + by force + then show "\x' \ ball z r; 0 < dist x' z;dist x' z < r\ + \ (x' - z) powr (n - m) * g x' = h x'" for x' by auto + next + define F where "F \ at z within ball z r" + define f' where "f' \ \x. (x - z) powr (n-m)" + have "f' z=0" using \n>m\ unfolding f'_def by auto + moreover have "continuous F f'" unfolding f'_def F_def continuous_def + apply (subst Lim_ident_at) + using \n>m\ by (auto intro!:tendsto_powr_complex_0 tendsto_eq_intros) + ultimately have "(f' \ 0) F" unfolding F_def + by (simp add: continuous_within) + moreover have "(g \ g z) F" + using holomorphic_on_imp_continuous_on[OF g_holo,unfolded continuous_on_def] \r>0\ + unfolding F_def by auto + ultimately show " ((\w. f' w * g w) \ 0) F" using tendsto_mult by fastforce + qed + moreover have "(h \ h z) (at z within ball z r)" + using holomorphic_on_imp_continuous_on[OF h_holo] + by (auto simp add:continuous_on_def \r>0\) + ultimately have "h z=0" by (auto intro!: tendsto_unique) + thus False using \h z\0\ by auto + qed + moreover have False when "m>n" + proof - + have "(g \ 0) (at z within ball z r)" + proof (rule Lim_transform_within[OF _ \r>0\, where f="\w. (w - z) powr (m - n) * h w"]) + have "\w\ball z r -{z}. g w = (w-z) powr (m-n) * h w" using \m>n\ asm + apply (auto simp add:field_simps powr_diff) + by force + then show "\x' \ ball z r; 0 < dist x' z;dist x' z < r\ + \ (x' - z) powr (m - n) * h x' = g x'" for x' by auto + next + define F where "F \ at z within ball z r" + define f' where "f' \\x. (x - z) powr (m-n)" + have "f' z=0" using \m>n\ unfolding f'_def by auto + moreover have "continuous F f'" unfolding f'_def F_def continuous_def + apply (subst Lim_ident_at) + using \m>n\ by (auto intro!:tendsto_powr_complex_0 tendsto_eq_intros) + ultimately have "(f' \ 0) F" unfolding F_def + by (simp add: continuous_within) + moreover have "(h \ h z) F" + using holomorphic_on_imp_continuous_on[OF h_holo,unfolded continuous_on_def] \r>0\ + unfolding F_def by auto + ultimately show " ((\w. f' w * h w) \ 0) F" using tendsto_mult by fastforce + qed + moreover have "(g \ g z) (at z within ball z r)" + using holomorphic_on_imp_continuous_on[OF g_holo] + by (auto simp add:continuous_on_def \r>0\) + ultimately have "g z=0" by (auto intro!: tendsto_unique) + thus False using \g z\0\ by auto + qed + ultimately show "n=m" by fastforce +qed + +lemma holomorphic_factor_puncture: + assumes f_iso:"isolated_singularity_at f z" + and "not_essential f z" \ \\<^term>\f\ has either a removable singularity or a pole at \<^term>\z\\ + and non_zero:"\\<^sub>Fw in (at z). f w\0" \ \\<^term>\f\ will not be constantly zero in a neighbour of \<^term>\z\\ + shows "\!n::int. \g r. 0 < r \ g holomorphic_on cball z r \ g z\0 + \ (\w\cball z r-{z}. f w = g w * (w-z) powr n \ g w\0)" +proof - + define P where "P = (\f n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 + \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" + have imp_unique:"\!n::int. \g r. P f n g r" when "\n g r. P f n g r" + proof (rule ex_ex1I[OF that]) + fix n1 n2 :: int + assume g1_asm:"\g1 r1. P f n1 g1 r1" and g2_asm:"\g2 r2. P f n2 g2 r2" + define fac where "fac \ \n g r. \w\cball z r-{z}. f w = g w * (w - z) powr (of_int n) \ g w \ 0" + obtain g1 r1 where "0 < r1" and g1_holo: "g1 holomorphic_on cball z r1" and "g1 z\0" + and "fac n1 g1 r1" using g1_asm unfolding P_def fac_def by auto + obtain g2 r2 where "0 < r2" and g2_holo: "g2 holomorphic_on cball z r2" and "g2 z\0" + and "fac n2 g2 r2" using g2_asm unfolding P_def fac_def by auto + define r where "r \ min r1 r2" + have "r>0" using \r1>0\ \r2>0\ unfolding r_def by auto + moreover have "\w\ball z r-{z}. f w = g1 w * (w-z) powr n1 \ g1 w\0 + \ f w = g2 w * (w - z) powr n2 \ g2 w\0" + using \fac n1 g1 r1\ \fac n2 g2 r2\ unfolding fac_def r_def + by fastforce + ultimately show "n1=n2" using g1_holo g2_holo \g1 z\0\ \g2 z\0\ + apply (elim holomorphic_factor_unique) + by (auto simp add:r_def) + qed + + have P_exist:"\ n g r. P h n g r" when + "\z'. (h \ z') (at z)" "isolated_singularity_at h z" "\\<^sub>Fw in (at z). h w\0" + for h + proof - + from that(2) obtain r where "r>0" "h analytic_on ball z r - {z}" + unfolding isolated_singularity_at_def by auto + obtain z' where "(h \ z') (at z)" using \\z'. (h \ z') (at z)\ by auto + define h' where "h'=(\x. if x=z then z' else h x)" + have "h' holomorphic_on ball z r" + apply (rule no_isolated_singularity'[of "{z}"]) + subgoal by (metis LIM_equal Lim_at_imp_Lim_at_within \h \z\ z'\ empty_iff h'_def insert_iff) + subgoal using \h analytic_on ball z r - {z}\ analytic_imp_holomorphic h'_def holomorphic_transform + by fastforce + by auto + have ?thesis when "z'=0" + proof - + have "h' z=0" using that unfolding h'_def by auto + moreover have "\ h' constant_on ball z r" + using \\\<^sub>Fw in (at z). h w\0\ unfolding constant_on_def frequently_def eventually_at h'_def + apply simp + by (metis \0 < r\ centre_in_ball dist_commute mem_ball that) + moreover note \h' holomorphic_on ball z r\ + ultimately obtain g r1 n where "0 < n" "0 < r1" "ball z r1 \ ball z r" and + g:"g holomorphic_on ball z r1" + "\w. w \ ball z r1 \ h' w = (w - z) ^ n * g w" + "\w. w \ ball z r1 \ g w \ 0" + using holomorphic_factor_zero_nonconstant[of _ "ball z r" z thesis,simplified, + OF \h' holomorphic_on ball z r\ \r>0\ \h' z=0\ \\ h' constant_on ball z r\] + by (auto simp add:dist_commute) + define rr where "rr=r1/2" + have "P h' n g rr" + unfolding P_def rr_def + using \n>0\ \r1>0\ g by (auto simp add:powr_nat) + then have "P h n g rr" + unfolding h'_def P_def by auto + then show ?thesis unfolding P_def by blast + qed + moreover have ?thesis when "z'\0" + proof - + have "h' z\0" using that unfolding h'_def by auto + obtain r1 where "r1>0" "cball z r1 \ ball z r" "\x\cball z r1. h' x\0" + proof - + have "isCont h' z" "h' z\0" + by (auto simp add: Lim_cong_within \h \z\ z'\ \z'\0\ continuous_at h'_def) + then obtain r2 where r2:"r2>0" "\x\ball z r2. h' x\0" + using continuous_at_avoid[of z h' 0 ] unfolding ball_def by auto + define r1 where "r1=min r2 r / 2" + have "0 < r1" "cball z r1 \ ball z r" + using \r2>0\ \r>0\ unfolding r1_def by auto + moreover have "\x\cball z r1. h' x \ 0" + using r2 unfolding r1_def by simp + ultimately show ?thesis using that by auto + qed + then have "P h' 0 h' r1" using \h' holomorphic_on ball z r\ unfolding P_def by auto + then have "P h 0 h' r1" unfolding P_def h'_def by auto + then show ?thesis unfolding P_def by blast + qed + ultimately show ?thesis by auto + qed + + have ?thesis when "\x. (f \ x) (at z)" + apply (rule_tac imp_unique[unfolded P_def]) + using P_exist[OF that(1) f_iso non_zero] unfolding P_def . + moreover have ?thesis when "is_pole f z" + proof (rule imp_unique[unfolded P_def]) + obtain e where [simp]:"e>0" and e_holo:"f holomorphic_on ball z e - {z}" and e_nz: "\x\ball z e-{z}. f x\0" + proof - + have "\\<^sub>F z in at z. f z \ 0" + using \is_pole f z\ filterlim_at_infinity_imp_eventually_ne unfolding is_pole_def + by auto + then obtain e1 where e1:"e1>0" "\x\ball z e1-{z}. f x\0" + using that eventually_at[of "\x. f x\0" z UNIV,simplified] by (auto simp add:dist_commute) + obtain e2 where e2:"e2>0" "f holomorphic_on ball z e2 - {z}" + using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by auto + define e where "e=min e1 e2" + show ?thesis + apply (rule that[of e]) + using e1 e2 unfolding e_def by auto + qed + + define h where "h \ \x. inverse (f x)" + + have "\n g r. P h n g r" + proof - + have "h \z\ 0" + using Lim_transform_within_open assms(2) h_def is_pole_tendsto that by fastforce + moreover have "\\<^sub>Fw in (at z). h w\0" + using non_zero + apply (elim frequently_rev_mp) + unfolding h_def eventually_at by (auto intro:exI[where x=1]) + moreover have "isolated_singularity_at h z" + unfolding isolated_singularity_at_def h_def + apply (rule exI[where x=e]) + using e_holo e_nz \e>0\ by (metis open_ball analytic_on_open + holomorphic_on_inverse open_delete) + ultimately show ?thesis + using P_exist[of h] by auto + qed + then obtain n g r + where "0 < r" and + g_holo:"g holomorphic_on cball z r" and "g z\0" and + g_fac:"(\w\cball z r-{z}. h w = g w * (w - z) powr of_int n \ g w \ 0)" + unfolding P_def by auto + have "P f (-n) (inverse o g) r" + proof - + have "f w = inverse (g w) * (w - z) powr of_int (- n)" when "w\cball z r - {z}" for w + using g_fac[rule_format,of w] that unfolding h_def + apply (auto simp add:powr_minus ) + by (metis inverse_inverse_eq inverse_mult_distrib) + then show ?thesis + unfolding P_def comp_def + using \r>0\ g_holo g_fac \g z\0\ by (auto intro:holomorphic_intros) + qed + then show "\x g r. 0 < r \ g holomorphic_on cball z r \ g z \ 0 + \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int x \ g w \ 0)" + unfolding P_def by blast + qed + ultimately show ?thesis using \not_essential f z\ unfolding not_essential_def by presburger +qed + +lemma not_essential_transform: + assumes "not_essential g z" + assumes "\\<^sub>F w in (at z). g w = f w" + shows "not_essential f z" + using assms unfolding not_essential_def + by (simp add: filterlim_cong is_pole_cong) + +lemma isolated_singularity_at_transform: + assumes "isolated_singularity_at g z" + assumes "\\<^sub>F w in (at z). g w = f w" + shows "isolated_singularity_at f z" +proof - + obtain r1 where "r1>0" and r1:"g analytic_on ball z r1 - {z}" + using assms(1) unfolding isolated_singularity_at_def by auto + obtain r2 where "r2>0" and r2:" \x. x \ z \ dist x z < r2 \ g x = f x" + using assms(2) unfolding eventually_at by auto + define r3 where "r3=min r1 r2" + have "r3>0" unfolding r3_def using \r1>0\ \r2>0\ by auto + moreover have "f analytic_on ball z r3 - {z}" + proof - + have "g holomorphic_on ball z r3 - {z}" + using r1 unfolding r3_def by (subst (asm) analytic_on_open,auto) + then have "f holomorphic_on ball z r3 - {z}" + using r2 unfolding r3_def + by (auto simp add:dist_commute elim!:holomorphic_transform) + then show ?thesis by (subst analytic_on_open,auto) + qed + ultimately show ?thesis unfolding isolated_singularity_at_def by auto +qed + +lemma not_essential_powr[singularity_intros]: + assumes "LIM w (at z). f w :> (at x)" + shows "not_essential (\w. (f w) powr (of_int n)) z" +proof - + define fp where "fp=(\w. (f w) powr (of_int n))" + have ?thesis when "n>0" + proof - + have "(\w. (f w) ^ (nat n)) \z\ x ^ nat n" + using that assms unfolding filterlim_at by (auto intro!:tendsto_eq_intros) + then have "fp \z\ x ^ nat n" unfolding fp_def + apply (elim Lim_transform_within[where d=1],simp) + by (metis less_le powr_0 powr_of_int that zero_less_nat_eq zero_power) + then show ?thesis unfolding not_essential_def fp_def by auto + qed + moreover have ?thesis when "n=0" + proof - + have "fp \z\ 1 " + apply (subst tendsto_cong[where g="\_.1"]) + using that filterlim_at_within_not_equal[OF assms,of 0] unfolding fp_def by auto + then show ?thesis unfolding fp_def not_essential_def by auto + qed + moreover have ?thesis when "n<0" + proof (cases "x=0") + case True + have "LIM w (at z). inverse ((f w) ^ (nat (-n))) :> at_infinity" + apply (subst filterlim_inverse_at_iff[symmetric],simp) + apply (rule filterlim_atI) + subgoal using assms True that unfolding filterlim_at by (auto intro!:tendsto_eq_intros) + subgoal using filterlim_at_within_not_equal[OF assms,of 0] + by (eventually_elim,insert that,auto) + done + then have "LIM w (at z). fp w :> at_infinity" + proof (elim filterlim_mono_eventually) + show "\\<^sub>F x in at z. inverse (f x ^ nat (- n)) = fp x" + using filterlim_at_within_not_equal[OF assms,of 0] unfolding fp_def + apply eventually_elim + using powr_of_int that by auto + qed auto + then show ?thesis unfolding fp_def not_essential_def is_pole_def by auto + next + case False + let ?xx= "inverse (x ^ (nat (-n)))" + have "(\w. inverse ((f w) ^ (nat (-n)))) \z\?xx" + using assms False unfolding filterlim_at by (auto intro!:tendsto_eq_intros) + then have "fp \z\?xx" + apply (elim Lim_transform_within[where d=1],simp) + unfolding fp_def by (metis inverse_zero nat_mono_iff nat_zero_as_int neg_0_less_iff_less + not_le power_eq_0_iff powr_0 powr_of_int that) + then show ?thesis unfolding fp_def not_essential_def by auto + qed + ultimately show ?thesis by linarith +qed + +lemma isolated_singularity_at_powr[singularity_intros]: + assumes "isolated_singularity_at f z" "\\<^sub>F w in (at z). f w\0" + shows "isolated_singularity_at (\w. (f w) powr (of_int n)) z" +proof - + obtain r1 where "r1>0" "f analytic_on ball z r1 - {z}" + using assms(1) unfolding isolated_singularity_at_def by auto + then have r1:"f holomorphic_on ball z r1 - {z}" + using analytic_on_open[of "ball z r1-{z}" f] by blast + obtain r2 where "r2>0" and r2:"\w. w \ z \ dist w z < r2 \ f w \ 0" + using assms(2) unfolding eventually_at by auto + define r3 where "r3=min r1 r2" + have "(\w. (f w) powr of_int n) holomorphic_on ball z r3 - {z}" + apply (rule holomorphic_on_powr_of_int) + subgoal unfolding r3_def using r1 by auto + subgoal unfolding r3_def using r2 by (auto simp add:dist_commute) + done + moreover have "r3>0" unfolding r3_def using \0 < r1\ \0 < r2\ by linarith + ultimately show ?thesis unfolding isolated_singularity_at_def + apply (subst (asm) analytic_on_open[symmetric]) + by auto +qed + +lemma non_zero_neighbour: + assumes f_iso:"isolated_singularity_at f z" + and f_ness:"not_essential f z" + and f_nconst:"\\<^sub>Fw in (at z). f w\0" + shows "\\<^sub>F w in (at z). f w\0" +proof - + obtain fn fp fr where [simp]:"fp z \ 0" and "fr > 0" + and fr: "fp holomorphic_on cball z fr" + "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" + using holomorphic_factor_puncture[OF f_iso f_ness f_nconst,THEN ex1_implies_ex] by auto + have "f w \ 0" when " w \ z" "dist w z < fr" for w + proof - + have "f w = fp w * (w - z) powr of_int fn" "fp w \ 0" + using fr(2)[rule_format, of w] using that by (auto simp add:dist_commute) + moreover have "(w - z) powr of_int fn \0" + unfolding powr_eq_0_iff using \w\z\ by auto + ultimately show ?thesis by auto + qed + then show ?thesis using \fr>0\ unfolding eventually_at by auto +qed + +lemma non_zero_neighbour_pole: + assumes "is_pole f z" + shows "\\<^sub>F w in (at z). f w\0" + using assms filterlim_at_infinity_imp_eventually_ne[of f "at z" 0] + unfolding is_pole_def by auto + +lemma non_zero_neighbour_alt: + assumes holo: "f holomorphic_on S" + and "open S" "connected S" "z \ S" "\ \ S" "f \ \ 0" + shows "\\<^sub>F w in (at z). f w\0 \ w\S" +proof (cases "f z = 0") + case True + from isolated_zeros[OF holo \open S\ \connected S\ \z \ S\ True \\ \ S\ \f \ \ 0\] + obtain r where "0 < r" "ball z r \ S" "\w \ ball z r - {z}.f w \ 0" by metis + then show ?thesis unfolding eventually_at + apply (rule_tac x=r in exI) + by (auto simp add:dist_commute) +next + case False + obtain r1 where r1:"r1>0" "\y. dist z y < r1 \ f y \ 0" + using continuous_at_avoid[of z f, OF _ False] assms(2,4) continuous_on_eq_continuous_at + holo holomorphic_on_imp_continuous_on by blast + obtain r2 where r2:"r2>0" "ball z r2 \ S" + using assms(2) assms(4) openE by blast + show ?thesis unfolding eventually_at + apply (rule_tac x="min r1 r2" in exI) + using r1 r2 by (auto simp add:dist_commute) +qed + +lemma not_essential_times[singularity_intros]: + assumes f_ness:"not_essential f z" and g_ness:"not_essential g z" + assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" + shows "not_essential (\w. f w * g w) z" +proof - + define fg where "fg = (\w. f w * g w)" + have ?thesis when "\ ((\\<^sub>Fw in (at z). f w\0) \ (\\<^sub>Fw in (at z). g w\0))" + proof - + have "\\<^sub>Fw in (at z). fg w=0" + using that[unfolded frequently_def, simplified] unfolding fg_def + by (auto elim: eventually_rev_mp) + from tendsto_cong[OF this] have "fg \z\0" by auto + then show ?thesis unfolding not_essential_def fg_def by auto + qed + moreover have ?thesis when f_nconst:"\\<^sub>Fw in (at z). f w\0" and g_nconst:"\\<^sub>Fw in (at z). g w\0" + proof - + obtain fn fp fr where [simp]:"fp z \ 0" and "fr > 0" + and fr: "fp holomorphic_on cball z fr" + "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" + using holomorphic_factor_puncture[OF f_iso f_ness f_nconst,THEN ex1_implies_ex] by auto + obtain gn gp gr where [simp]:"gp z \ 0" and "gr > 0" + and gr: "gp holomorphic_on cball z gr" + "\w\cball z gr - {z}. g w = gp w * (w - z) powr of_int gn \ gp w \ 0" + using holomorphic_factor_puncture[OF g_iso g_ness g_nconst,THEN ex1_implies_ex] by auto + + define r1 where "r1=(min fr gr)" + have "r1>0" unfolding r1_def using \fr>0\ \gr>0\ by auto + have fg_times:"fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" and fgp_nz:"fp w*gp w\0" + when "w\ball z r1 - {z}" for w + proof - + have "f w = fp w * (w - z) powr of_int fn" "fp w\0" + using fr(2)[rule_format,of w] that unfolding r1_def by auto + moreover have "g w = gp w * (w - z) powr of_int gn" "gp w \ 0" + using gr(2)[rule_format, of w] that unfolding r1_def by auto + ultimately show "fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" "fp w*gp w\0" + unfolding fg_def by (auto simp add:powr_add) + qed + + have [intro]: "fp \z\fp z" "gp \z\gp z" + using fr(1) \fr>0\ gr(1) \gr>0\ + by (meson open_ball ball_subset_cball centre_in_ball + continuous_on_eq_continuous_at continuous_within holomorphic_on_imp_continuous_on + holomorphic_on_subset)+ + have ?thesis when "fn+gn>0" + proof - + have "(\w. (fp w * gp w) * (w - z) ^ (nat (fn+gn))) \z\0" + using that by (auto intro!:tendsto_eq_intros) + then have "fg \z\ 0" + apply (elim Lim_transform_within[OF _ \r1>0\]) + by (metis (no_types, hide_lams) Diff_iff cball_trivial dist_commute dist_self + eq_iff_diff_eq_0 fg_times less_le linorder_not_le mem_ball mem_cball powr_of_int + that) + then show ?thesis unfolding not_essential_def fg_def by auto + qed + moreover have ?thesis when "fn+gn=0" + proof - + have "(\w. fp w * gp w) \z\fp z*gp z" + using that by (auto intro!:tendsto_eq_intros) + then have "fg \z\ fp z*gp z" + apply (elim Lim_transform_within[OF _ \r1>0\]) + apply (subst fg_times) + by (auto simp add:dist_commute that) + then show ?thesis unfolding not_essential_def fg_def by auto + qed + moreover have ?thesis when "fn+gn<0" + proof - + have "LIM w (at z). fp w * gp w / (w-z)^nat (-(fn+gn)) :> at_infinity" + apply (rule filterlim_divide_at_infinity) + apply (insert that, auto intro!:tendsto_eq_intros filterlim_atI) + using eventually_at_topological by blast + then have "is_pole fg z" unfolding is_pole_def + apply (elim filterlim_transform_within[OF _ _ \r1>0\],simp) + apply (subst fg_times,simp add:dist_commute) + apply (subst powr_of_int) + using that by (auto simp add:field_split_simps) + then show ?thesis unfolding not_essential_def fg_def by auto + qed + ultimately show ?thesis unfolding not_essential_def fg_def by fastforce + qed + ultimately show ?thesis by auto +qed + +lemma not_essential_inverse[singularity_intros]: + assumes f_ness:"not_essential f z" + assumes f_iso:"isolated_singularity_at f z" + shows "not_essential (\w. inverse (f w)) z" +proof - + define vf where "vf = (\w. inverse (f w))" + have ?thesis when "\(\\<^sub>Fw in (at z). f w\0)" + proof - + have "\\<^sub>Fw in (at z). f w=0" + using that[unfolded frequently_def, simplified] by (auto elim: eventually_rev_mp) + then have "\\<^sub>Fw in (at z). vf w=0" + unfolding vf_def by auto + from tendsto_cong[OF this] have "vf \z\0" unfolding vf_def by auto + then show ?thesis unfolding not_essential_def vf_def by auto + qed + moreover have ?thesis when "is_pole f z" + proof - + have "vf \z\0" + using that filterlim_at filterlim_inverse_at_iff unfolding is_pole_def vf_def by blast + then show ?thesis unfolding not_essential_def vf_def by auto + qed + moreover have ?thesis when "\x. f\z\x " and f_nconst:"\\<^sub>Fw in (at z). f w\0" + proof - + from that obtain fz where fz:"f\z\fz" by auto + have ?thesis when "fz=0" + proof - + have "(\w. inverse (vf w)) \z\0" + using fz that unfolding vf_def by auto + moreover have "\\<^sub>F w in at z. inverse (vf w) \ 0" + using non_zero_neighbour[OF f_iso f_ness f_nconst] + unfolding vf_def by auto + ultimately have "is_pole vf z" + using filterlim_inverse_at_iff[of vf "at z"] unfolding filterlim_at is_pole_def by auto + then show ?thesis unfolding not_essential_def vf_def by auto + qed + moreover have ?thesis when "fz\0" + proof - + have "vf \z\inverse fz" + using fz that unfolding vf_def by (auto intro:tendsto_eq_intros) + then show ?thesis unfolding not_essential_def vf_def by auto + qed + ultimately show ?thesis by auto + qed + ultimately show ?thesis using f_ness unfolding not_essential_def by auto +qed + +lemma isolated_singularity_at_inverse[singularity_intros]: + assumes f_iso:"isolated_singularity_at f z" + and f_ness:"not_essential f z" + shows "isolated_singularity_at (\w. inverse (f w)) z" +proof - + define vf where "vf = (\w. inverse (f w))" + have ?thesis when "\(\\<^sub>Fw in (at z). f w\0)" + proof - + have "\\<^sub>Fw in (at z). f w=0" + using that[unfolded frequently_def, simplified] by (auto elim: eventually_rev_mp) + then have "\\<^sub>Fw in (at z). vf w=0" + unfolding vf_def by auto + then obtain d1 where "d1>0" and d1:"\x. x \ z \ dist x z < d1 \ vf x = 0" + unfolding eventually_at by auto + then have "vf holomorphic_on ball z d1-{z}" + apply (rule_tac holomorphic_transform[of "\_. 0"]) + by (auto simp add:dist_commute) + then have "vf analytic_on ball z d1 - {z}" + by (simp add: analytic_on_open open_delete) + then show ?thesis using \d1>0\ unfolding isolated_singularity_at_def vf_def by auto + qed + moreover have ?thesis when f_nconst:"\\<^sub>Fw in (at z). f w\0" + proof - + have "\\<^sub>F w in at z. f w \ 0" using non_zero_neighbour[OF f_iso f_ness f_nconst] . + then obtain d1 where d1:"d1>0" "\x. x \ z \ dist x z < d1 \ f x \ 0" + unfolding eventually_at by auto + obtain d2 where "d2>0" and d2:"f analytic_on ball z d2 - {z}" + using f_iso unfolding isolated_singularity_at_def by auto + define d3 where "d3=min d1 d2" + have "d3>0" unfolding d3_def using \d1>0\ \d2>0\ by auto + moreover have "vf analytic_on ball z d3 - {z}" + unfolding vf_def + apply (rule analytic_on_inverse) + subgoal using d2 unfolding d3_def by (elim analytic_on_subset) auto + subgoal for w using d1 unfolding d3_def by (auto simp add:dist_commute) + done + ultimately show ?thesis unfolding isolated_singularity_at_def vf_def by auto + qed + ultimately show ?thesis by auto +qed + +lemma not_essential_divide[singularity_intros]: + assumes f_ness:"not_essential f z" and g_ness:"not_essential g z" + assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" + shows "not_essential (\w. f w / g w) z" +proof - + have "not_essential (\w. f w * inverse (g w)) z" + apply (rule not_essential_times[where g="\w. inverse (g w)"]) + using assms by (auto intro: isolated_singularity_at_inverse not_essential_inverse) + then show ?thesis by (simp add:field_simps) +qed + +lemma + assumes f_iso:"isolated_singularity_at f z" + and g_iso:"isolated_singularity_at g z" + shows isolated_singularity_at_times[singularity_intros]: + "isolated_singularity_at (\w. f w * g w) z" and + isolated_singularity_at_add[singularity_intros]: + "isolated_singularity_at (\w. f w + g w) z" +proof - + obtain d1 d2 where "d1>0" "d2>0" + and d1:"f analytic_on ball z d1 - {z}" and d2:"g analytic_on ball z d2 - {z}" + using f_iso g_iso unfolding isolated_singularity_at_def by auto + define d3 where "d3=min d1 d2" + have "d3>0" unfolding d3_def using \d1>0\ \d2>0\ by auto + + have "(\w. f w * g w) analytic_on ball z d3 - {z}" + apply (rule analytic_on_mult) + using d1 d2 unfolding d3_def by (auto elim:analytic_on_subset) + then show "isolated_singularity_at (\w. f w * g w) z" + using \d3>0\ unfolding isolated_singularity_at_def by auto + have "(\w. f w + g w) analytic_on ball z d3 - {z}" + apply (rule analytic_on_add) + using d1 d2 unfolding d3_def by (auto elim:analytic_on_subset) + then show "isolated_singularity_at (\w. f w + g w) z" + using \d3>0\ unfolding isolated_singularity_at_def by auto +qed + +lemma isolated_singularity_at_uminus[singularity_intros]: + assumes f_iso:"isolated_singularity_at f z" + shows "isolated_singularity_at (\w. - f w) z" + using assms unfolding isolated_singularity_at_def using analytic_on_neg by blast + +lemma isolated_singularity_at_id[singularity_intros]: + "isolated_singularity_at (\w. w) z" + unfolding isolated_singularity_at_def by (simp add: gt_ex) + +lemma isolated_singularity_at_minus[singularity_intros]: + assumes f_iso:"isolated_singularity_at f z" + and g_iso:"isolated_singularity_at g z" + shows "isolated_singularity_at (\w. f w - g w) z" + using isolated_singularity_at_uminus[THEN isolated_singularity_at_add[OF f_iso,of "\w. - g w"] + ,OF g_iso] by simp + +lemma isolated_singularity_at_divide[singularity_intros]: + assumes f_iso:"isolated_singularity_at f z" + and g_iso:"isolated_singularity_at g z" + and g_ness:"not_essential g z" + shows "isolated_singularity_at (\w. f w / g w) z" + using isolated_singularity_at_inverse[THEN isolated_singularity_at_times[OF f_iso, + of "\w. inverse (g w)"],OF g_iso g_ness] by (simp add:field_simps) + +lemma isolated_singularity_at_const[singularity_intros]: + "isolated_singularity_at (\w. c) z" + unfolding isolated_singularity_at_def by (simp add: gt_ex) + +lemma isolated_singularity_at_holomorphic: + assumes "f holomorphic_on s-{z}" "open s" "z\s" + shows "isolated_singularity_at f z" + using assms unfolding isolated_singularity_at_def + by (metis analytic_on_holomorphic centre_in_ball insert_Diff openE open_delete subset_insert_iff) + +subsubsection \The order of non-essential singularities (i.e. removable singularities or poles)\ + + +definition\<^marker>\tag important\ zorder :: "(complex \ complex) \ complex \ int" where + "zorder f z = (THE n. (\h r. r>0 \ h holomorphic_on cball z r \ h z\0 + \ (\w\cball z r - {z}. f w = h w * (w-z) powr (of_int n) + \ h w \0)))" + +definition\<^marker>\tag important\ zor_poly + ::"[complex \ complex, complex] \ complex \ complex" where + "zor_poly f z = (SOME h. \r. r > 0 \ h holomorphic_on cball z r \ h z \ 0 + \ (\w\cball z r - {z}. f w = h w * (w - z) powr (zorder f z) + \ h w \0))" + +lemma zorder_exist: + fixes f::"complex \ complex" and z::complex + defines "n\zorder f z" and "g\zor_poly f z" + assumes f_iso:"isolated_singularity_at f z" + and f_ness:"not_essential f z" + and f_nconst:"\\<^sub>Fw in (at z). f w\0" + shows "g z\0 \ (\r. r>0 \ g holomorphic_on cball z r + \ (\w\cball z r - {z}. f w = g w * (w-z) powr n \ g w \0))" +proof - + define P where "P = (\n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 + \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" + have "\!n. \g r. P n g r" + using holomorphic_factor_puncture[OF assms(3-)] unfolding P_def by auto + then have "\g r. P n g r" + unfolding n_def P_def zorder_def + by (drule_tac theI',argo) + then have "\r. P n g r" + unfolding P_def zor_poly_def g_def n_def + by (drule_tac someI_ex,argo) + then obtain r1 where "P n g r1" by auto + then show ?thesis unfolding P_def by auto +qed + +lemma + fixes f::"complex \ complex" and z::complex + assumes f_iso:"isolated_singularity_at f z" + and f_ness:"not_essential f z" + and f_nconst:"\\<^sub>Fw in (at z). f w\0" + shows zorder_inverse: "zorder (\w. inverse (f w)) z = - zorder f z" + and zor_poly_inverse: "\\<^sub>Fw in (at z). zor_poly (\w. inverse (f w)) z w + = inverse (zor_poly f z w)" +proof - + define vf where "vf = (\w. inverse (f w))" + define fn vfn where + "fn = zorder f z" and "vfn = zorder vf z" + define fp vfp where + "fp = zor_poly f z" and "vfp = zor_poly vf z" + + obtain fr where [simp]:"fp z \ 0" and "fr > 0" + and fr: "fp holomorphic_on cball z fr" + "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" + using zorder_exist[OF f_iso f_ness f_nconst,folded fn_def fp_def] + by auto + have fr_inverse: "vf w = (inverse (fp w)) * (w - z) powr (of_int (-fn))" + and fr_nz: "inverse (fp w)\0" + when "w\ball z fr - {z}" for w + proof - + have "f w = fp w * (w - z) powr of_int fn" "fp w\0" + using fr(2)[rule_format,of w] that by auto + then show "vf w = (inverse (fp w)) * (w - z) powr (of_int (-fn))" "inverse (fp w)\0" + unfolding vf_def by (auto simp add:powr_minus) + qed + obtain vfr where [simp]:"vfp z \ 0" and "vfr>0" and vfr:"vfp holomorphic_on cball z vfr" + "(\w\cball z vfr - {z}. vf w = vfp w * (w - z) powr of_int vfn \ vfp w \ 0)" + proof - + have "isolated_singularity_at vf z" + using isolated_singularity_at_inverse[OF f_iso f_ness] unfolding vf_def . + moreover have "not_essential vf z" + using not_essential_inverse[OF f_ness f_iso] unfolding vf_def . + moreover have "\\<^sub>F w in at z. vf w \ 0" + using f_nconst unfolding vf_def by (auto elim:frequently_elim1) + ultimately show ?thesis using zorder_exist[of vf z, folded vfn_def vfp_def] that by auto + qed + + + define r1 where "r1 = min fr vfr" + have "r1>0" using \fr>0\ \vfr>0\ unfolding r1_def by simp + show "vfn = - fn" + apply (rule holomorphic_factor_unique[of r1 vfp z "\w. inverse (fp w)" vf]) + subgoal using \r1>0\ by simp + subgoal by simp + subgoal by simp + subgoal + proof (rule ballI) + fix w assume "w \ ball z r1 - {z}" + then have "w \ ball z fr - {z}" "w \ cball z vfr - {z}" unfolding r1_def by auto + from fr_inverse[OF this(1)] fr_nz[OF this(1)] vfr(2)[rule_format,OF this(2)] + show "vf w = vfp w * (w - z) powr of_int vfn \ vfp w \ 0 + \ vf w = inverse (fp w) * (w - z) powr of_int (- fn) \ inverse (fp w) \ 0" by auto + qed + subgoal using vfr(1) unfolding r1_def by (auto intro!:holomorphic_intros) + subgoal using fr unfolding r1_def by (auto intro!:holomorphic_intros) + done + + have "vfp w = inverse (fp w)" when "w\ball z r1-{z}" for w + proof - + have "w \ ball z fr - {z}" "w \ cball z vfr - {z}" "w\z" using that unfolding r1_def by auto + from fr_inverse[OF this(1)] fr_nz[OF this(1)] vfr(2)[rule_format,OF this(2)] \vfn = - fn\ \w\z\ + show ?thesis by auto + qed + then show "\\<^sub>Fw in (at z). vfp w = inverse (fp w)" + unfolding eventually_at using \r1>0\ + apply (rule_tac x=r1 in exI) + by (auto simp add:dist_commute) +qed + +lemma + fixes f g::"complex \ complex" and z::complex + assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" + and f_ness:"not_essential f z" and g_ness:"not_essential g z" + and fg_nconst: "\\<^sub>Fw in (at z). f w * g w\ 0" + shows zorder_times:"zorder (\w. f w * g w) z = zorder f z + zorder g z" and + zor_poly_times:"\\<^sub>Fw in (at z). zor_poly (\w. f w * g w) z w + = zor_poly f z w *zor_poly g z w" +proof - + define fg where "fg = (\w. f w * g w)" + define fn gn fgn where + "fn = zorder f z" and "gn = zorder g z" and "fgn = zorder fg z" + define fp gp fgp where + "fp = zor_poly f z" and "gp = zor_poly g z" and "fgp = zor_poly fg z" + have f_nconst:"\\<^sub>Fw in (at z). f w \ 0" and g_nconst:"\\<^sub>Fw in (at z).g w\ 0" + using fg_nconst by (auto elim!:frequently_elim1) + obtain fr where [simp]:"fp z \ 0" and "fr > 0" + and fr: "fp holomorphic_on cball z fr" + "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" + using zorder_exist[OF f_iso f_ness f_nconst,folded fp_def fn_def] by auto + obtain gr where [simp]:"gp z \ 0" and "gr > 0" + and gr: "gp holomorphic_on cball z gr" + "\w\cball z gr - {z}. g w = gp w * (w - z) powr of_int gn \ gp w \ 0" + using zorder_exist[OF g_iso g_ness g_nconst,folded gn_def gp_def] by auto + define r1 where "r1=min fr gr" + have "r1>0" unfolding r1_def using \fr>0\ \gr>0\ by auto + have fg_times:"fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" and fgp_nz:"fp w*gp w\0" + when "w\ball z r1 - {z}" for w + proof - + have "f w = fp w * (w - z) powr of_int fn" "fp w\0" + using fr(2)[rule_format,of w] that unfolding r1_def by auto + moreover have "g w = gp w * (w - z) powr of_int gn" "gp w \ 0" + using gr(2)[rule_format, of w] that unfolding r1_def by auto + ultimately show "fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" "fp w*gp w\0" + unfolding fg_def by (auto simp add:powr_add) + qed + + obtain fgr where [simp]:"fgp z \ 0" and "fgr > 0" + and fgr: "fgp holomorphic_on cball z fgr" + "\w\cball z fgr - {z}. fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0" + proof - + have "fgp z \ 0 \ (\r>0. fgp holomorphic_on cball z r + \ (\w\cball z r - {z}. fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0))" + apply (rule zorder_exist[of fg z, folded fgn_def fgp_def]) + subgoal unfolding fg_def using isolated_singularity_at_times[OF f_iso g_iso] . + subgoal unfolding fg_def using not_essential_times[OF f_ness g_ness f_iso g_iso] . + subgoal unfolding fg_def using fg_nconst . + done + then show ?thesis using that by blast + qed + define r2 where "r2 = min fgr r1" + have "r2>0" using \r1>0\ \fgr>0\ unfolding r2_def by simp + show "fgn = fn + gn " + apply (rule holomorphic_factor_unique[of r2 fgp z "\w. fp w * gp w" fg]) + subgoal using \r2>0\ by simp + subgoal by simp + subgoal by simp + subgoal + proof (rule ballI) + fix w assume "w \ ball z r2 - {z}" + then have "w \ ball z r1 - {z}" "w \ cball z fgr - {z}" unfolding r2_def by auto + from fg_times[OF this(1)] fgp_nz[OF this(1)] fgr(2)[rule_format,OF this(2)] + show "fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0 + \ fg w = fp w * gp w * (w - z) powr of_int (fn + gn) \ fp w * gp w \ 0" by auto + qed + subgoal using fgr(1) unfolding r2_def r1_def by (auto intro!:holomorphic_intros) + subgoal using fr(1) gr(1) unfolding r2_def r1_def by (auto intro!:holomorphic_intros) + done + + have "fgp w = fp w *gp w" when "w\ball z r2-{z}" for w + proof - + have "w \ ball z r1 - {z}" "w \ cball z fgr - {z}" "w\z" using that unfolding r2_def by auto + from fg_times[OF this(1)] fgp_nz[OF this(1)] fgr(2)[rule_format,OF this(2)] \fgn = fn + gn\ \w\z\ + show ?thesis by auto + qed + then show "\\<^sub>Fw in (at z). fgp w = fp w * gp w" + using \r2>0\ unfolding eventually_at by (auto simp add:dist_commute) +qed + +lemma + fixes f g::"complex \ complex" and z::complex + assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" + and f_ness:"not_essential f z" and g_ness:"not_essential g z" + and fg_nconst: "\\<^sub>Fw in (at z). f w * g w\ 0" + shows zorder_divide:"zorder (\w. f w / g w) z = zorder f z - zorder g z" and + zor_poly_divide:"\\<^sub>Fw in (at z). zor_poly (\w. f w / g w) z w + = zor_poly f z w / zor_poly g z w" +proof - + have f_nconst:"\\<^sub>Fw in (at z). f w \ 0" and g_nconst:"\\<^sub>Fw in (at z).g w\ 0" + using fg_nconst by (auto elim!:frequently_elim1) + define vg where "vg=(\w. inverse (g w))" + have "zorder (\w. f w * vg w) z = zorder f z + zorder vg z" + apply (rule zorder_times[OF f_iso _ f_ness,of vg]) + subgoal unfolding vg_def using isolated_singularity_at_inverse[OF g_iso g_ness] . + subgoal unfolding vg_def using not_essential_inverse[OF g_ness g_iso] . + subgoal unfolding vg_def using fg_nconst by (auto elim!:frequently_elim1) + done + then show "zorder (\w. f w / g w) z = zorder f z - zorder g z" + using zorder_inverse[OF g_iso g_ness g_nconst,folded vg_def] unfolding vg_def + by (auto simp add:field_simps) + + have "\\<^sub>F w in at z. zor_poly (\w. f w * vg w) z w = zor_poly f z w * zor_poly vg z w" + apply (rule zor_poly_times[OF f_iso _ f_ness,of vg]) + subgoal unfolding vg_def using isolated_singularity_at_inverse[OF g_iso g_ness] . + subgoal unfolding vg_def using not_essential_inverse[OF g_ness g_iso] . + subgoal unfolding vg_def using fg_nconst by (auto elim!:frequently_elim1) + done + then show "\\<^sub>Fw in (at z). zor_poly (\w. f w / g w) z w = zor_poly f z w / zor_poly g z w" + using zor_poly_inverse[OF g_iso g_ness g_nconst,folded vg_def] unfolding vg_def + apply eventually_elim + by (auto simp add:field_simps) +qed + +lemma zorder_exist_zero: + fixes f::"complex \ complex" and z::complex + defines "n\zorder f z" and "g\zor_poly f z" + assumes holo: "f holomorphic_on s" and + "open s" "connected s" "z\s" + and non_const: "\w\s. f w \ 0" + shows "(if f z=0 then n > 0 else n=0) \ (\r. r>0 \ cball z r \ s \ g holomorphic_on cball z r + \ (\w\cball z r. f w = g w * (w-z) ^ nat n \ g w \0))" +proof - + obtain r where "g z \ 0" and r: "r>0" "cball z r \ s" "g holomorphic_on cball z r" + "(\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + proof - + have "g z \ 0 \ (\r>0. g holomorphic_on cball z r + \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0))" + proof (rule zorder_exist[of f z,folded g_def n_def]) + show "isolated_singularity_at f z" unfolding isolated_singularity_at_def + using holo assms(4,6) + by (meson Diff_subset open_ball analytic_on_holomorphic holomorphic_on_subset openE) + show "not_essential f z" unfolding not_essential_def + using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on + by fastforce + have "\\<^sub>F w in at z. f w \ 0 \ w\s" + proof - + obtain w where "w\s" "f w\0" using non_const by auto + then show ?thesis + by (rule non_zero_neighbour_alt[OF holo \open s\ \connected s\ \z\s\]) + qed + then show "\\<^sub>F w in at z. f w \ 0" + apply (elim eventually_frequentlyE) + by auto + qed + then obtain r1 where "g z \ 0" "r1>0" and r1:"g holomorphic_on cball z r1" + "(\w\cball z r1 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + by auto + obtain r2 where r2: "r2>0" "cball z r2 \ s" + using assms(4,6) open_contains_cball_eq by blast + define r3 where "r3=min r1 r2" + have "r3>0" "cball z r3 \ s" using \r1>0\ r2 unfolding r3_def by auto + moreover have "g holomorphic_on cball z r3" + using r1(1) unfolding r3_def by auto + moreover have "(\w\cball z r3 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + using r1(2) unfolding r3_def by auto + ultimately show ?thesis using that[of r3] \g z\0\ by auto + qed + + have if_0:"if f z=0 then n > 0 else n=0" + proof - + have "f\ z \ f z" + by (metis assms(4,6,7) at_within_open continuous_on holo holomorphic_on_imp_continuous_on) + then have "(\w. g w * (w - z) powr of_int n) \z\ f z" + apply (elim Lim_transform_within_open[where s="ball z r"]) + using r by auto + moreover have "g \z\g z" + by (metis (mono_tags, lifting) open_ball at_within_open_subset + ball_subset_cball centre_in_ball continuous_on holomorphic_on_imp_continuous_on r(1,3) subsetCE) + ultimately have "(\w. (g w * (w - z) powr of_int n) / g w) \z\ f z/g z" + apply (rule_tac tendsto_divide) + using \g z\0\ by auto + then have powr_tendsto:"(\w. (w - z) powr of_int n) \z\ f z/g z" + apply (elim Lim_transform_within_open[where s="ball z r"]) + using r by auto + + have ?thesis when "n\0" "f z=0" + proof - + have "(\w. (w - z) ^ nat n) \z\ f z/g z" + using powr_tendsto + apply (elim Lim_transform_within[where d=r]) + by (auto simp add: powr_of_int \n\0\ \r>0\) + then have *:"(\w. (w - z) ^ nat n) \z\ 0" using \f z=0\ by simp + moreover have False when "n=0" + proof - + have "(\w. (w - z) ^ nat n) \z\ 1" + using \n=0\ by auto + then show False using * using LIM_unique zero_neq_one by blast + qed + ultimately show ?thesis using that by fastforce + qed + moreover have ?thesis when "n\0" "f z\0" + proof - + have False when "n>0" + proof - + have "(\w. (w - z) ^ nat n) \z\ f z/g z" + using powr_tendsto + apply (elim Lim_transform_within[where d=r]) + by (auto simp add: powr_of_int \n\0\ \r>0\) + moreover have "(\w. (w - z) ^ nat n) \z\ 0" + using \n>0\ by (auto intro!:tendsto_eq_intros) + ultimately show False using \f z\0\ \g z\0\ using LIM_unique divide_eq_0_iff by blast + qed + then show ?thesis using that by force + qed + moreover have False when "n<0" + proof - + have "(\w. inverse ((w - z) ^ nat (- n))) \z\ f z/g z" + "(\w.((w - z) ^ nat (- n))) \z\ 0" + subgoal using powr_tendsto powr_of_int that + by (elim Lim_transform_within_open[where s=UNIV],auto) + subgoal using that by (auto intro!:tendsto_eq_intros) + done + from tendsto_mult[OF this,simplified] + have "(\x. inverse ((x - z) ^ nat (- n)) * (x - z) ^ nat (- n)) \z\ 0" . + then have "(\x. 1::complex) \z\ 0" + by (elim Lim_transform_within_open[where s=UNIV],auto) + then show False using LIM_const_eq by fastforce + qed + ultimately show ?thesis by fastforce + qed + moreover have "f w = g w * (w-z) ^ nat n \ g w \0" when "w\cball z r" for w + proof (cases "w=z") + case True + then have "f \z\f w" + using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on by fastforce + then have "(\w. g w * (w-z) ^ nat n) \z\f w" + proof (elim Lim_transform_within[OF _ \r>0\]) + fix x assume "0 < dist x z" "dist x z < r" + then have "x \ cball z r - {z}" "x\z" + unfolding cball_def by (auto simp add: dist_commute) + then have "f x = g x * (x - z) powr of_int n" + using r(4)[rule_format,of x] by simp + also have "... = g x * (x - z) ^ nat n" + apply (subst powr_of_int) + using if_0 \x\z\ by (auto split:if_splits) + finally show "f x = g x * (x - z) ^ nat n" . + qed + moreover have "(\w. g w * (w-z) ^ nat n) \z\ g w * (w-z) ^ nat n" + using True apply (auto intro!:tendsto_eq_intros) + by (metis open_ball at_within_open_subset ball_subset_cball centre_in_ball + continuous_on holomorphic_on_imp_continuous_on r(1) r(3) that) + ultimately have "f w = g w * (w-z) ^ nat n" using LIM_unique by blast + then show ?thesis using \g z\0\ True by auto + next + case False + then have "f w = g w * (w - z) powr of_int n \ g w \ 0" + using r(4) that by auto + then show ?thesis using False if_0 powr_of_int by (auto split:if_splits) + qed + ultimately show ?thesis using r by auto +qed + +lemma zorder_exist_pole: + fixes f::"complex \ complex" and z::complex + defines "n\zorder f z" and "g\zor_poly f z" + assumes holo: "f holomorphic_on s-{z}" and + "open s" "z\s" + and "is_pole f z" + shows "n < 0 \ g z\0 \ (\r. r>0 \ cball z r \ s \ g holomorphic_on cball z r + \ (\w\cball z r - {z}. f w = g w / (w-z) ^ nat (- n) \ g w \0))" +proof - + obtain r where "g z \ 0" and r: "r>0" "cball z r \ s" "g holomorphic_on cball z r" + "(\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + proof - + have "g z \ 0 \ (\r>0. g holomorphic_on cball z r + \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0))" + proof (rule zorder_exist[of f z,folded g_def n_def]) + show "isolated_singularity_at f z" unfolding isolated_singularity_at_def + using holo assms(4,5) + by (metis analytic_on_holomorphic centre_in_ball insert_Diff openE open_delete subset_insert_iff) + show "not_essential f z" unfolding not_essential_def + using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on + by fastforce + from non_zero_neighbour_pole[OF \is_pole f z\] show "\\<^sub>F w in at z. f w \ 0" + apply (elim eventually_frequentlyE) + by auto + qed + then obtain r1 where "g z \ 0" "r1>0" and r1:"g holomorphic_on cball z r1" + "(\w\cball z r1 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + by auto + obtain r2 where r2: "r2>0" "cball z r2 \ s" + using assms(4,5) open_contains_cball_eq by metis + define r3 where "r3=min r1 r2" + have "r3>0" "cball z r3 \ s" using \r1>0\ r2 unfolding r3_def by auto + moreover have "g holomorphic_on cball z r3" + using r1(1) unfolding r3_def by auto + moreover have "(\w\cball z r3 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" + using r1(2) unfolding r3_def by auto + ultimately show ?thesis using that[of r3] \g z\0\ by auto + qed + + have "n<0" + proof (rule ccontr) + assume " \ n < 0" + define c where "c=(if n=0 then g z else 0)" + have [simp]:"g \z\ g z" + by (metis open_ball at_within_open ball_subset_cball centre_in_ball + continuous_on holomorphic_on_imp_continuous_on holomorphic_on_subset r(1) r(3) ) + have "\\<^sub>F x in at z. f x = g x * (x - z) ^ nat n" + unfolding eventually_at_topological + apply (rule_tac exI[where x="ball z r"]) + using r powr_of_int \\ n < 0\ by auto + moreover have "(\x. g x * (x - z) ^ nat n) \z\c" + proof (cases "n=0") + case True + then show ?thesis unfolding c_def by simp + next + case False + then have "(\x. (x - z) ^ nat n) \z\ 0" using \\ n < 0\ + by (auto intro!:tendsto_eq_intros) + from tendsto_mult[OF _ this,of g "g z",simplified] + show ?thesis unfolding c_def using False by simp + qed + ultimately have "f \z\c" using tendsto_cong by fast + then show False using \is_pole f z\ at_neq_bot not_tendsto_and_filterlim_at_infinity + unfolding is_pole_def by blast + qed + moreover have "\w\cball z r - {z}. f w = g w / (w-z) ^ nat (- n) \ g w \0" + using r(4) \n<0\ powr_of_int + by (metis Diff_iff divide_inverse eq_iff_diff_eq_0 insert_iff linorder_not_le) + ultimately show ?thesis using r(1-3) \g z\0\ by auto +qed + +lemma zorder_eqI: + assumes "open s" "z \ s" "g holomorphic_on s" "g z \ 0" + assumes fg_eq:"\w. \w \ s;w\z\ \ f w = g w * (w - z) powr n" + shows "zorder f z = n" +proof - + have "continuous_on s g" by (rule holomorphic_on_imp_continuous_on) fact + moreover have "open (-{0::complex})" by auto + ultimately have "open ((g -` (-{0})) \ s)" + unfolding continuous_on_open_vimage[OF \open s\] by blast + moreover from assms have "z \ (g -` (-{0})) \ s" by auto + ultimately obtain r where r: "r > 0" "cball z r \ s \ (g -` (-{0}))" + unfolding open_contains_cball by blast + + let ?gg= "(\w. g w * (w - z) powr n)" + define P where "P = (\n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 + \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" + have "P n g r" + unfolding P_def using r assms(3,4,5) by auto + then have "\g r. P n g r" by auto + moreover have unique: "\!n. \g r. P n g r" unfolding P_def + proof (rule holomorphic_factor_puncture) + have "ball z r-{z} \ s" using r using ball_subset_cball by blast + then have "?gg holomorphic_on ball z r-{z}" + using \g holomorphic_on s\ r by (auto intro!: holomorphic_intros) + then have "f holomorphic_on ball z r - {z}" + apply (elim holomorphic_transform) + using fg_eq \ball z r-{z} \ s\ by auto + then show "isolated_singularity_at f z" unfolding isolated_singularity_at_def + using analytic_on_open open_delete r(1) by blast + next + have "not_essential ?gg z" + proof (intro singularity_intros) + show "not_essential g z" + by (meson \continuous_on s g\ assms(1) assms(2) continuous_on_eq_continuous_at + isCont_def not_essential_def) + show " \\<^sub>F w in at z. w - z \ 0" by (simp add: eventually_at_filter) + then show "LIM w at z. w - z :> at 0" + unfolding filterlim_at by (auto intro:tendsto_eq_intros) + show "isolated_singularity_at g z" + by (meson Diff_subset open_ball analytic_on_holomorphic + assms(1,2,3) holomorphic_on_subset isolated_singularity_at_def openE) + qed + then show "not_essential f z" + apply (elim not_essential_transform) + unfolding eventually_at using assms(1,2) assms(5)[symmetric] + by (metis dist_commute mem_ball openE subsetCE) + show "\\<^sub>F w in at z. f w \ 0" unfolding frequently_at + proof (rule,rule) + fix d::real assume "0 < d" + define z' where "z'=z+min d r / 2" + have "z' \ z" " dist z' z < d " + unfolding z'_def using \d>0\ \r>0\ + by (auto simp add:dist_norm) + moreover have "f z' \ 0" + proof (subst fg_eq[OF _ \z'\z\]) + have "z' \ cball z r" unfolding z'_def using \r>0\ \d>0\ by (auto simp add:dist_norm) + then show " z' \ s" using r(2) by blast + show "g z' * (z' - z) powr of_int n \ 0" + using P_def \P n g r\ \z' \ cball z r\ calculation(1) by auto + qed + ultimately show "\x\UNIV. x \ z \ dist x z < d \ f x \ 0" by auto + qed + qed + ultimately have "(THE n. \g r. P n g r) = n" + by (rule_tac the1_equality) + then show ?thesis unfolding zorder_def P_def by blast +qed + +lemma simple_zeroI: + assumes "open s" "z \ s" "g holomorphic_on s" "g z \ 0" + assumes "\w. w \ s \ f w = g w * (w - z)" + shows "zorder f z = 1" + using assms(1-4) by (rule zorder_eqI) (use assms(5) in auto) + +lemma higher_deriv_power: + shows "(deriv ^^ j) (\w. (w - z) ^ n) w = + pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j)" +proof (induction j arbitrary: w) + case 0 + thus ?case by auto +next + case (Suc j w) + have "(deriv ^^ Suc j) (\w. (w - z) ^ n) w = deriv ((deriv ^^ j) (\w. (w - z) ^ n)) w" + by simp + also have "(deriv ^^ j) (\w. (w - z) ^ n) = + (\w. pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j))" + using Suc by (intro Suc.IH ext) + also { + have "(\ has_field_derivative of_nat (n - j) * + pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - Suc j)) (at w)" + using Suc.prems by (auto intro!: derivative_eq_intros) + also have "of_nat (n - j) * pochhammer (of_nat (Suc n - j)) j = + pochhammer (of_nat (Suc n - Suc j)) (Suc j)" + by (cases "Suc j \ n", subst pochhammer_rec) + (insert Suc.prems, simp_all add: algebra_simps Suc_diff_le pochhammer_0_left) + finally have "deriv (\w. pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j)) w = + \ * (w - z) ^ (n - Suc j)" + by (rule DERIV_imp_deriv) + } + finally show ?case . +qed + +lemma zorder_zero_eqI: + assumes f_holo:"f holomorphic_on s" and "open s" "z \ s" + assumes zero: "\i. i < nat n \ (deriv ^^ i) f z = 0" + assumes nz: "(deriv ^^ nat n) f z \ 0" and "n\0" + shows "zorder f z = n" +proof - + obtain r where [simp]:"r>0" and "ball z r \ s" + using \open s\ \z\s\ openE by blast + have nz':"\w\ball z r. f w \ 0" + proof (rule ccontr) + assume "\ (\w\ball z r. f w \ 0)" + then have "eventually (\u. f u = 0) (nhds z)" + using \r>0\ unfolding eventually_nhds + apply (rule_tac x="ball z r" in exI) + by auto + then have "(deriv ^^ nat n) f z = (deriv ^^ nat n) (\_. 0) z" + by (intro higher_deriv_cong_ev) auto + also have "(deriv ^^ nat n) (\_. 0) z = 0" + by (induction n) simp_all + finally show False using nz by contradiction + qed + + define zn g where "zn = zorder f z" and "g = zor_poly f z" + obtain e where e_if:"if f z = 0 then 0 < zn else zn = 0" and + [simp]:"e>0" and "cball z e \ ball z r" and + g_holo:"g holomorphic_on cball z e" and + e_fac:"(\w\cball z e. f w = g w * (w - z) ^ nat zn \ g w \ 0)" + proof - + have "f holomorphic_on ball z r" + using f_holo \ball z r \ s\ by auto + from that zorder_exist_zero[of f "ball z r" z,simplified,OF this nz',folded zn_def g_def] + show ?thesis by blast + qed + from this(1,2,5) have "zn\0" "g z\0" + subgoal by (auto split:if_splits) + subgoal using \0 < e\ ball_subset_cball centre_in_ball e_fac by blast + done + + define A where "A = (\i. of_nat (i choose (nat zn)) * fact (nat zn) * (deriv ^^ (i - nat zn)) g z)" + have deriv_A:"(deriv ^^ i) f z = (if zn \ int i then A i else 0)" for i + proof - + have "eventually (\w. w \ ball z e) (nhds z)" + using \cball z e \ ball z r\ \e>0\ by (intro eventually_nhds_in_open) auto + hence "eventually (\w. f w = (w - z) ^ (nat zn) * g w) (nhds z)" + apply eventually_elim + by (use e_fac in auto) + hence "(deriv ^^ i) f z = (deriv ^^ i) (\w. (w - z) ^ nat zn * g w) z" + by (intro higher_deriv_cong_ev) auto + also have "\ = (\j=0..i. of_nat (i choose j) * + (deriv ^^ j) (\w. (w - z) ^ nat zn) z * (deriv ^^ (i - j)) g z)" + using g_holo \e>0\ + by (intro higher_deriv_mult[of _ "ball z e"]) (auto intro!: holomorphic_intros) + also have "\ = (\j=0..i. if j = nat zn then + of_nat (i choose nat zn) * fact (nat zn) * (deriv ^^ (i - nat zn)) g z else 0)" + proof (intro sum.cong refl, goal_cases) + case (1 j) + have "(deriv ^^ j) (\w. (w - z) ^ nat zn) z = + pochhammer (of_nat (Suc (nat zn) - j)) j * 0 ^ (nat zn - j)" + by (subst higher_deriv_power) auto + also have "\ = (if j = nat zn then fact j else 0)" + by (auto simp: not_less pochhammer_0_left pochhammer_fact) + also have "of_nat (i choose j) * \ * (deriv ^^ (i - j)) g z = + (if j = nat zn then of_nat (i choose (nat zn)) * fact (nat zn) + * (deriv ^^ (i - nat zn)) g z else 0)" + by simp + finally show ?case . + qed + also have "\ = (if i \ zn then A i else 0)" + by (auto simp: A_def) + finally show "(deriv ^^ i) f z = \" . + qed + + have False when "nn\0\ by auto + with nz show False by auto + qed + moreover have "n\zn" + proof - + have "g z \ 0" using e_fac[rule_format,of z] \e>0\ by simp + then have "(deriv ^^ nat zn) f z \ 0" + using deriv_A[of "nat zn"] by(auto simp add:A_def) + then have "nat zn \ nat n" using zero[of "nat zn"] by linarith + moreover have "zn\0" using e_if by (auto split:if_splits) + ultimately show ?thesis using nat_le_eq_zle by blast + qed + ultimately show ?thesis unfolding zn_def by fastforce +qed + +lemma + assumes "eventually (\z. f z = g z) (at z)" "z = z'" + shows zorder_cong:"zorder f z = zorder g z'" and zor_poly_cong:"zor_poly f z = zor_poly g z'" +proof - + define P where "P = (\ff n h r. 0 < r \ h holomorphic_on cball z r \ h z\0 + \ (\w\cball z r - {z}. ff w = h w * (w-z) powr (of_int n) \ h w\0))" + have "(\r. P f n h r) = (\r. P g n h r)" for n h + proof - + have *: "\r. P g n h r" if "\r. P f n h r" and "eventually (\x. f x = g x) (at z)" for f g + proof - + from that(1) obtain r1 where r1_P:"P f n h r1" by auto + from that(2) obtain r2 where "r2>0" and r2_dist:"\x. x \ z \ dist x z \ r2 \ f x = g x" + unfolding eventually_at_le by auto + define r where "r=min r1 r2" + have "r>0" "h z\0" using r1_P \r2>0\ unfolding r_def P_def by auto + moreover have "h holomorphic_on cball z r" + using r1_P unfolding P_def r_def by auto + moreover have "g w = h w * (w - z) powr of_int n \ h w \ 0" when "w\cball z r - {z}" for w + proof - + have "f w = h w * (w - z) powr of_int n \ h w \ 0" + using r1_P that unfolding P_def r_def by auto + moreover have "f w=g w" using r2_dist[rule_format,of w] that unfolding r_def + by (simp add: dist_commute) + ultimately show ?thesis by simp + qed + ultimately show ?thesis unfolding P_def by auto + qed + from assms have eq': "eventually (\z. g z = f z) (at z)" + by (simp add: eq_commute) + show ?thesis + by (rule iffI[OF *[OF _ assms(1)] *[OF _ eq']]) + qed + then show "zorder f z = zorder g z'" "zor_poly f z = zor_poly g z'" + using \z=z'\ unfolding P_def zorder_def zor_poly_def by auto +qed + +lemma zorder_nonzero_div_power: + assumes "open s" "z \ s" "f holomorphic_on s" "f z \ 0" "n > 0" + shows "zorder (\w. f w / (w - z) ^ n) z = - n" + apply (rule zorder_eqI[OF \open s\ \z\s\ \f holomorphic_on s\ \f z\0\]) + apply (subst powr_of_int) + using \n>0\ by (auto simp add:field_simps) + +lemma zor_poly_eq: + assumes "isolated_singularity_at f z" "not_essential f z" "\\<^sub>F w in at z. f w \ 0" + shows "eventually (\w. zor_poly f z w = f w * (w - z) powr - zorder f z) (at z)" +proof - + obtain r where r:"r>0" + "(\w\cball z r - {z}. f w = zor_poly f z w * (w - z) powr of_int (zorder f z))" + using zorder_exist[OF assms] by blast + then have *: "\w\ball z r - {z}. zor_poly f z w = f w * (w - z) powr - zorder f z" + by (auto simp: field_simps powr_minus) + have "eventually (\w. w \ ball z r - {z}) (at z)" + using r eventually_at_ball'[of r z UNIV] by auto + thus ?thesis by eventually_elim (insert *, auto) +qed + +lemma zor_poly_zero_eq: + assumes "f holomorphic_on s" "open s" "connected s" "z \ s" "\w\s. f w \ 0" + shows "eventually (\w. zor_poly f z w = f w / (w - z) ^ nat (zorder f z)) (at z)" +proof - + obtain r where r:"r>0" + "(\w\cball z r - {z}. f w = zor_poly f z w * (w - z) ^ nat (zorder f z))" + using zorder_exist_zero[OF assms] by auto + then have *: "\w\ball z r - {z}. zor_poly f z w = f w / (w - z) ^ nat (zorder f z)" + by (auto simp: field_simps powr_minus) + have "eventually (\w. w \ ball z r - {z}) (at z)" + using r eventually_at_ball'[of r z UNIV] by auto + thus ?thesis by eventually_elim (insert *, auto) +qed + +lemma zor_poly_pole_eq: + assumes f_iso:"isolated_singularity_at f z" "is_pole f z" + shows "eventually (\w. zor_poly f z w = f w * (w - z) ^ nat (- zorder f z)) (at z)" +proof - + obtain e where [simp]:"e>0" and f_holo:"f holomorphic_on ball z e - {z}" + using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by blast + obtain r where r:"r>0" + "(\w\cball z r - {z}. f w = zor_poly f z w / (w - z) ^ nat (- zorder f z))" + using zorder_exist_pole[OF f_holo,simplified,OF \is_pole f z\] by auto + then have *: "\w\ball z r - {z}. zor_poly f z w = f w * (w - z) ^ nat (- zorder f z)" + by (auto simp: field_simps) + have "eventually (\w. w \ ball z r - {z}) (at z)" + using r eventually_at_ball'[of r z UNIV] by auto + thus ?thesis by eventually_elim (insert *, auto) +qed + +lemma zor_poly_eqI: + fixes f :: "complex \ complex" and z0 :: complex + defines "n \ zorder f z0" + assumes "isolated_singularity_at f z0" "not_essential f z0" "\\<^sub>F w in at z0. f w \ 0" + assumes lim: "((\x. f (g x) * (g x - z0) powr - n) \ c) F" + assumes g: "filterlim g (at z0) F" and "F \ bot" + shows "zor_poly f z0 z0 = c" +proof - + from zorder_exist[OF assms(2-4)] obtain r where + r: "r > 0" "zor_poly f z0 holomorphic_on cball z0 r" + "\w. w \ cball z0 r - {z0} \ f w = zor_poly f z0 w * (w - z0) powr n" + unfolding n_def by blast + from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" + using eventually_at_ball'[of r z0 UNIV] by auto + hence "eventually (\w. zor_poly f z0 w = f w * (w - z0) powr - n) (at z0)" + by eventually_elim (insert r, auto simp: field_simps powr_minus) + moreover have "continuous_on (ball z0 r) (zor_poly f z0)" + using r by (intro holomorphic_on_imp_continuous_on) auto + with r(1,2) have "isCont (zor_poly f z0) z0" + by (auto simp: continuous_on_eq_continuous_at) + hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" + unfolding isCont_def . + ultimately have "((\w. f w * (w - z0) powr - n) \ zor_poly f z0 z0) (at z0)" + by (blast intro: Lim_transform_eventually) + hence "((\x. f (g x) * (g x - z0) powr - n) \ zor_poly f z0 z0) F" + by (rule filterlim_compose[OF _ g]) + from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . +qed + +lemma zor_poly_zero_eqI: + fixes f :: "complex \ complex" and z0 :: complex + defines "n \ zorder f z0" + assumes "f holomorphic_on A" "open A" "connected A" "z0 \ A" "\z\A. f z \ 0" + assumes lim: "((\x. f (g x) / (g x - z0) ^ nat n) \ c) F" + assumes g: "filterlim g (at z0) F" and "F \ bot" + shows "zor_poly f z0 z0 = c" +proof - + from zorder_exist_zero[OF assms(2-6)] obtain r where + r: "r > 0" "cball z0 r \ A" "zor_poly f z0 holomorphic_on cball z0 r" + "\w. w \ cball z0 r \ f w = zor_poly f z0 w * (w - z0) ^ nat n" + unfolding n_def by blast + from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" + using eventually_at_ball'[of r z0 UNIV] by auto + hence "eventually (\w. zor_poly f z0 w = f w / (w - z0) ^ nat n) (at z0)" + by eventually_elim (insert r, auto simp: field_simps) + moreover have "continuous_on (ball z0 r) (zor_poly f z0)" + using r by (intro holomorphic_on_imp_continuous_on) auto + with r(1,2) have "isCont (zor_poly f z0) z0" + by (auto simp: continuous_on_eq_continuous_at) + hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" + unfolding isCont_def . + ultimately have "((\w. f w / (w - z0) ^ nat n) \ zor_poly f z0 z0) (at z0)" + by (blast intro: Lim_transform_eventually) + hence "((\x. f (g x) / (g x - z0) ^ nat n) \ zor_poly f z0 z0) F" + by (rule filterlim_compose[OF _ g]) + from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . +qed + +lemma zor_poly_pole_eqI: + fixes f :: "complex \ complex" and z0 :: complex + defines "n \ zorder f z0" + assumes f_iso:"isolated_singularity_at f z0" and "is_pole f z0" + assumes lim: "((\x. f (g x) * (g x - z0) ^ nat (-n)) \ c) F" + assumes g: "filterlim g (at z0) F" and "F \ bot" + shows "zor_poly f z0 z0 = c" +proof - + obtain r where r: "r > 0" "zor_poly f z0 holomorphic_on cball z0 r" + proof - + have "\\<^sub>F w in at z0. f w \ 0" + using non_zero_neighbour_pole[OF \is_pole f z0\] by (auto elim:eventually_frequentlyE) + moreover have "not_essential f z0" unfolding not_essential_def using \is_pole f z0\ by simp + ultimately show ?thesis using that zorder_exist[OF f_iso,folded n_def] by auto + qed + from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" + using eventually_at_ball'[of r z0 UNIV] by auto + have "eventually (\w. zor_poly f z0 w = f w * (w - z0) ^ nat (-n)) (at z0)" + using zor_poly_pole_eq[OF f_iso \is_pole f z0\] unfolding n_def . + moreover have "continuous_on (ball z0 r) (zor_poly f z0)" + using r by (intro holomorphic_on_imp_continuous_on) auto + with r(1,2) have "isCont (zor_poly f z0) z0" + by (auto simp: continuous_on_eq_continuous_at) + hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" + unfolding isCont_def . + ultimately have "((\w. f w * (w - z0) ^ nat (-n)) \ zor_poly f z0 z0) (at z0)" + by (blast intro: Lim_transform_eventually) + hence "((\x. f (g x) * (g x - z0) ^ nat (-n)) \ zor_poly f z0 z0) F" + by (rule filterlim_compose[OF _ g]) + from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . +qed + +end \ No newline at end of file diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Conformal_Mappings.thy --- a/src/HOL/Complex_Analysis/Conformal_Mappings.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Conformal_Mappings.thy Mon Dec 02 17:51:54 2019 +0100 @@ -5,222 +5,10 @@ text\Also Cauchy's residue theorem by Wenda Li (2016)\ theory Conformal_Mappings -imports Cauchy_Integral_Theorem +imports Cauchy_Integral_Formula begin -(* FIXME mv to Cauchy_Integral_Theorem.thy *) -subsection\Cauchy's inequality and more versions of Liouville\ - -lemma Cauchy_higher_deriv_bound: - assumes holf: "f holomorphic_on (ball z r)" - and contf: "continuous_on (cball z r) f" - and fin : "\w. w \ ball z r \ f w \ ball y B0" - and "0 < r" and "0 < n" - shows "norm ((deriv ^^ n) f z) \ (fact n) * B0 / r^n" -proof - - have "0 < B0" using \0 < r\ fin [of z] - by (metis ball_eq_empty ex_in_conv fin not_less) - have le_B0: "\w. cmod (w - z) \ r \ cmod (f w - y) \ B0" - apply (rule continuous_on_closure_norm_le [of "ball z r" "\w. f w - y"]) - apply (auto simp: \0 < r\ dist_norm norm_minus_commute) - apply (rule continuous_intros contf)+ - using fin apply (simp add: dist_commute dist_norm less_eq_real_def) - done - have "(deriv ^^ n) f z = (deriv ^^ n) (\w. f w) z - (deriv ^^ n) (\w. y) z" - using \0 < n\ by simp - also have "... = (deriv ^^ n) (\w. f w - y) z" - by (rule higher_deriv_diff [OF holf, symmetric]) (auto simp: \0 < r\) - finally have "(deriv ^^ n) f z = (deriv ^^ n) (\w. f w - y) z" . - have contf': "continuous_on (cball z r) (\u. f u - y)" - by (rule contf continuous_intros)+ - have holf': "(\u. (f u - y)) holomorphic_on (ball z r)" - by (simp add: holf holomorphic_on_diff) - define a where "a = (2 * pi)/(fact n)" - have "0 < a" by (simp add: a_def) - have "B0/r^(Suc n)*2 * pi * r = a*((fact n)*B0/r^n)" - using \0 < r\ by (simp add: a_def field_split_simps) - have der_dif: "(deriv ^^ n) (\w. f w - y) z = (deriv ^^ n) f z" - using \0 < r\ \0 < n\ - by (auto simp: higher_deriv_diff [OF holf holomorphic_on_const]) - have "norm ((2 * of_real pi * \)/(fact n) * (deriv ^^ n) (\w. f w - y) z) - \ (B0/r^(Suc n)) * (2 * pi * r)" - apply (rule has_contour_integral_bound_circlepath [of "(\u. (f u - y)/(u - z)^(Suc n))" _ z]) - using Cauchy_has_contour_integral_higher_derivative_circlepath [OF contf' holf'] - using \0 < B0\ \0 < r\ - apply (auto simp: norm_divide norm_mult norm_power divide_simps le_B0) - done - then show ?thesis - using \0 < r\ - by (auto simp: norm_divide norm_mult norm_power field_simps der_dif le_B0) -qed - -lemma Cauchy_inequality: - assumes holf: "f holomorphic_on (ball \ r)" - and contf: "continuous_on (cball \ r) f" - and "0 < r" - and nof: "\x. norm(\-x) = r \ norm(f x) \ B" - shows "norm ((deriv ^^ n) f \) \ (fact n) * B / r^n" -proof - - obtain x where "norm (\-x) = r" - by (metis abs_of_nonneg add_diff_cancel_left' \0 < r\ diff_add_cancel - dual_order.strict_implies_order norm_of_real) - then have "0 \ B" - by (metis nof norm_not_less_zero not_le order_trans) - have "((\u. f u / (u - \) ^ Suc n) has_contour_integral (2 * pi) * \ / fact n * (deriv ^^ n) f \) - (circlepath \ r)" - apply (rule Cauchy_has_contour_integral_higher_derivative_circlepath [OF contf holf]) - using \0 < r\ by simp - then have "norm ((2 * pi * \)/(fact n) * (deriv ^^ n) f \) \ (B / r^(Suc n)) * (2 * pi * r)" - apply (rule has_contour_integral_bound_circlepath) - using \0 \ B\ \0 < r\ - apply (simp_all add: norm_divide norm_power nof frac_le norm_minus_commute del: power_Suc) - done - then show ?thesis using \0 < r\ - by (simp add: norm_divide norm_mult field_simps) -qed - -lemma Liouville_polynomial: - assumes holf: "f holomorphic_on UNIV" - and nof: "\z. A \ norm z \ norm(f z) \ B * norm z ^ n" - shows "f \ = (\k\n. (deriv^^k) f 0 / fact k * \ ^ k)" -proof (cases rule: le_less_linear [THEN disjE]) - assume "B \ 0" - then have "\z. A \ norm z \ norm(f z) = 0" - by (metis nof less_le_trans zero_less_mult_iff neqE norm_not_less_zero norm_power not_le) - then have f0: "(f \ 0) at_infinity" - using Lim_at_infinity by force - then have [simp]: "f = (\w. 0)" - using Liouville_weak [OF holf, of 0] - by (simp add: eventually_at_infinity f0) meson - show ?thesis by simp -next - assume "0 < B" - have "((\k. (deriv ^^ k) f 0 / (fact k) * (\ - 0)^k) sums f \)" - apply (rule holomorphic_power_series [where r = "norm \ + 1"]) - using holf holomorphic_on_subset apply auto - done - then have sumsf: "((\k. (deriv ^^ k) f 0 / (fact k) * \^k) sums f \)" by simp - have "(deriv ^^ k) f 0 / fact k * \ ^ k = 0" if "k>n" for k - proof (cases "(deriv ^^ k) f 0 = 0") - case True then show ?thesis by simp - next - case False - define w where "w = complex_of_real (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" - have "1 \ abs (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" - using \0 < B\ by simp - then have wge1: "1 \ norm w" - by (metis norm_of_real w_def) - then have "w \ 0" by auto - have kB: "0 < fact k * B" - using \0 < B\ by simp - then have "0 \ fact k * B / cmod ((deriv ^^ k) f 0)" - by simp - then have wgeA: "A \ cmod w" - by (simp only: w_def norm_of_real) - have "fact k * B / cmod ((deriv ^^ k) f 0) < abs (fact k * B / cmod ((deriv ^^ k) f 0) + (\A\ + 1))" - using \0 < B\ by simp - then have wge: "fact k * B / cmod ((deriv ^^ k) f 0) < norm w" - by (metis norm_of_real w_def) - then have "fact k * B / norm w < cmod ((deriv ^^ k) f 0)" - using False by (simp add: field_split_simps mult.commute split: if_split_asm) - also have "... \ fact k * (B * norm w ^ n) / norm w ^ k" - apply (rule Cauchy_inequality) - using holf holomorphic_on_subset apply force - using holf holomorphic_on_imp_continuous_on holomorphic_on_subset apply blast - using \w \ 0\ apply simp - by (metis nof wgeA dist_0_norm dist_norm) - also have "... = fact k * (B * 1 / cmod w ^ (k-n))" - apply (simp only: mult_cancel_left times_divide_eq_right [symmetric]) - using \k>n\ \w \ 0\ \0 < B\ apply (simp add: field_split_simps semiring_normalization_rules) - done - also have "... = fact k * B / cmod w ^ (k-n)" - by simp - finally have "fact k * B / cmod w < fact k * B / cmod w ^ (k - n)" . - then have "1 / cmod w < 1 / cmod w ^ (k - n)" - by (metis kB divide_inverse inverse_eq_divide mult_less_cancel_left_pos) - then have "cmod w ^ (k - n) < cmod w" - by (metis frac_le le_less_trans norm_ge_zero norm_one not_less order_refl wge1 zero_less_one) - with self_le_power [OF wge1] have False - by (meson diff_is_0_eq not_gr0 not_le that) - then show ?thesis by blast - qed - then have "(deriv ^^ (k + Suc n)) f 0 / fact (k + Suc n) * \ ^ (k + Suc n) = 0" for k - using not_less_eq by blast - then have "(\i. (deriv ^^ (i + Suc n)) f 0 / fact (i + Suc n) * \ ^ (i + Suc n)) sums 0" - by (rule sums_0) - with sums_split_initial_segment [OF sumsf, where n = "Suc n"] - show ?thesis - using atLeast0AtMost lessThan_Suc_atMost sums_unique2 by fastforce -qed - -text\Every bounded entire function is a constant function.\ -theorem Liouville_theorem: - assumes holf: "f holomorphic_on UNIV" - and bf: "bounded (range f)" - obtains c where "\z. f z = c" -proof - - obtain B where "\z. cmod (f z) \ B" - by (meson bf bounded_pos rangeI) - then show ?thesis - using Liouville_polynomial [OF holf, of 0 B 0, simplified] that by blast -qed - -text\A holomorphic function f has only isolated zeros unless f is 0.\ - -lemma powser_0_nonzero: - fixes a :: "nat \ 'a::{real_normed_field,banach}" - assumes r: "0 < r" - and sm: "\x. norm (x - \) < r \ (\n. a n * (x - \) ^ n) sums (f x)" - and [simp]: "f \ = 0" - and m0: "a m \ 0" and "m>0" - obtains s where "0 < s" and "\z. z \ cball \ s - {\} \ f z \ 0" -proof - - have "r \ conv_radius a" - using sm sums_summable by (auto simp: le_conv_radius_iff [where \=\]) - obtain m where am: "a m \ 0" and az [simp]: "(\n. n a n = 0)" - apply (rule_tac m = "LEAST n. a n \ 0" in that) - using m0 - apply (rule LeastI2) - apply (fastforce intro: dest!: not_less_Least)+ - done - define b where "b i = a (i+m) / a m" for i - define g where "g x = suminf (\i. b i * (x - \) ^ i)" for x - have [simp]: "b 0 = 1" - by (simp add: am b_def) - { fix x::'a - assume "norm (x - \) < r" - then have "(\n. (a m * (x - \)^m) * (b n * (x - \)^n)) sums (f x)" - using am az sm sums_zero_iff_shift [of m "(\n. a n * (x - \) ^ n)" "f x"] - by (simp add: b_def monoid_mult_class.power_add algebra_simps) - then have "x \ \ \ (\n. b n * (x - \)^n) sums (f x / (a m * (x - \)^m))" - using am by (simp add: sums_mult_D) - } note bsums = this - then have "norm (x - \) < r \ summable (\n. b n * (x - \)^n)" for x - using sums_summable by (cases "x=\") auto - then have "r \ conv_radius b" - by (simp add: le_conv_radius_iff [where \=\]) - then have "r/2 < conv_radius b" - using not_le order_trans r by fastforce - then have "continuous_on (cball \ (r/2)) g" - using powser_continuous_suminf [of "r/2" b \] by (simp add: g_def) - then obtain s where "s>0" "\x. \norm (x - \) \ s; norm (x - \) \ r/2\ \ dist (g x) (g \) < 1/2" - apply (rule continuous_onE [where x=\ and e = "1/2"]) - using r apply (auto simp: norm_minus_commute dist_norm) - done - moreover have "g \ = 1" - by (simp add: g_def) - ultimately have gnz: "\x. \norm (x - \) \ s; norm (x - \) \ r/2\ \ (g x) \ 0" - by fastforce - have "f x \ 0" if "x \ \" "norm (x - \) \ s" "norm (x - \) \ r/2" for x - using bsums [of x] that gnz [of x] - apply (auto simp: g_def) - using r sums_iff by fastforce - then show ?thesis - apply (rule_tac s="min s (r/2)" in that) - using \0 < r\ \0 < s\ by (auto simp: dist_commute dist_norm) -qed - subsection \Analytic continuation\ proposition isolated_zeros: @@ -2173,2944 +1961,4 @@ qed qed -subsection \Cauchy's residue theorem\ - -text\Wenda Li and LC Paulson (2016). A Formal Proof of Cauchy's Residue Theorem. - Interactive Theorem Proving\ - -definition\<^marker>\tag important\ residue :: "(complex \ complex) \ complex \ complex" where - "residue f z = (SOME int. \e>0. \\>0. \ (f has_contour_integral 2*pi* \ *int) (circlepath z \))" - -lemma Eps_cong: - assumes "\x. P x = Q x" - shows "Eps P = Eps Q" - using ext[of P Q, OF assms] by simp - -lemma residue_cong: - assumes eq: "eventually (\z. f z = g z) (at z)" and "z = z'" - shows "residue f z = residue g z'" -proof - - from assms have eq': "eventually (\z. g z = f z) (at z)" - by (simp add: eq_commute) - let ?P = "\f c e. (\\>0. \ < e \ - (f has_contour_integral of_real (2 * pi) * \ * c) (circlepath z \))" - have "residue f z = residue g z" unfolding residue_def - proof (rule Eps_cong) - fix c :: complex - have "\e>0. ?P g c e" - if "\e>0. ?P f c e" and "eventually (\z. f z = g z) (at z)" for f g - proof - - from that(1) obtain e where e: "e > 0" "?P f c e" - by blast - from that(2) obtain e' where e': "e' > 0" "\z'. z' \ z \ dist z' z < e' \ f z' = g z'" - unfolding eventually_at by blast - have "?P g c (min e e')" - proof (intro allI exI impI, goal_cases) - case (1 \) - hence "(f has_contour_integral of_real (2 * pi) * \ * c) (circlepath z \)" - using e(2) by auto - thus ?case - proof (rule has_contour_integral_eq) - fix z' assume "z' \ path_image (circlepath z \)" - hence "dist z' z < e'" and "z' \ z" - using 1 by (auto simp: dist_commute) - with e'(2)[of z'] show "f z' = g z'" by simp - qed - qed - moreover from e and e' have "min e e' > 0" by auto - ultimately show ?thesis by blast - qed - from this[OF _ eq] and this[OF _ eq'] - show "(\e>0. ?P f c e) \ (\e>0. ?P g c e)" - by blast - qed - with assms show ?thesis by simp -qed - -lemma contour_integral_circlepath_eq: - assumes "open s" and f_holo:"f holomorphic_on (s-{z})" and "0e2" - and e2_cball:"cball z e2 \ s" - shows - "f contour_integrable_on circlepath z e1" - "f contour_integrable_on circlepath z e2" - "contour_integral (circlepath z e2) f = contour_integral (circlepath z e1) f" -proof - - define l where "l \ linepath (z+e2) (z+e1)" - have [simp]:"valid_path l" "pathstart l=z+e2" "pathfinish l=z+e1" unfolding l_def by auto - have "e2>0" using \e1>0\ \e1\e2\ by auto - have zl_img:"z\path_image l" - proof - assume "z \ path_image l" - then have "e2 \ cmod (e2 - e1)" - using segment_furthest_le[of z "z+e2" "z+e1" "z+e2",simplified] \e1>0\ \e2>0\ unfolding l_def - by (auto simp add:closed_segment_commute) - thus False using \e2>0\ \e1>0\ \e1\e2\ - apply (subst (asm) norm_of_real) - by auto - qed - define g where "g \ circlepath z e2 +++ l +++ reversepath (circlepath z e1) +++ reversepath l" - show [simp]: "f contour_integrable_on circlepath z e2" "f contour_integrable_on (circlepath z e1)" - proof - - show "f contour_integrable_on circlepath z e2" - apply (intro contour_integrable_continuous_circlepath[OF - continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) - using \e2>0\ e2_cball by auto - show "f contour_integrable_on (circlepath z e1)" - apply (intro contour_integrable_continuous_circlepath[OF - continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) - using \e1>0\ \e1\e2\ e2_cball by auto - qed - have [simp]:"f contour_integrable_on l" - proof - - have "closed_segment (z + e2) (z + e1) \ cball z e2" using \e2>0\ \e1>0\ \e1\e2\ - by (intro closed_segment_subset,auto simp add:dist_norm) - hence "closed_segment (z + e2) (z + e1) \ s - {z}" using zl_img e2_cball unfolding l_def - by auto - then show "f contour_integrable_on l" unfolding l_def - apply (intro contour_integrable_continuous_linepath[OF - continuous_on_subset[OF holomorphic_on_imp_continuous_on[OF f_holo]]]) - by auto - qed - let ?ig="\g. contour_integral g f" - have "(f has_contour_integral 0) g" - proof (rule Cauchy_theorem_global[OF _ f_holo]) - show "open (s - {z})" using \open s\ by auto - show "valid_path g" unfolding g_def l_def by auto - show "pathfinish g = pathstart g" unfolding g_def l_def by auto - next - have path_img:"path_image g \ cball z e2" - proof - - have "closed_segment (z + e2) (z + e1) \ cball z e2" using \e2>0\ \e1>0\ \e1\e2\ - by (intro closed_segment_subset,auto simp add:dist_norm) - moreover have "sphere z \e1\ \ cball z e2" using \e2>0\ \e1\e2\ \e1>0\ by auto - ultimately show ?thesis unfolding g_def l_def using \e2>0\ - by (simp add: path_image_join closed_segment_commute) - qed - show "path_image g \ s - {z}" - proof - - have "z\path_image g" using zl_img - unfolding g_def l_def by (auto simp add: path_image_join closed_segment_commute) - moreover note \cball z e2 \ s\ and path_img - ultimately show ?thesis by auto - qed - show "winding_number g w = 0" when"w \ s - {z}" for w - proof - - have "winding_number g w = 0" when "w\s" using that e2_cball - apply (intro winding_number_zero_outside[OF _ _ _ _ path_img]) - by (auto simp add:g_def l_def) - moreover have "winding_number g z=0" - proof - - let ?Wz="\g. winding_number g z" - have "?Wz g = ?Wz (circlepath z e2) + ?Wz l + ?Wz (reversepath (circlepath z e1)) - + ?Wz (reversepath l)" - using \e2>0\ \e1>0\ zl_img unfolding g_def l_def - by (subst winding_number_join,auto simp add:path_image_join closed_segment_commute)+ - also have "... = ?Wz (circlepath z e2) + ?Wz (reversepath (circlepath z e1))" - using zl_img - apply (subst (2) winding_number_reversepath) - by (auto simp add:l_def closed_segment_commute) - also have "... = 0" - proof - - have "?Wz (circlepath z e2) = 1" using \e2>0\ - by (auto intro: winding_number_circlepath_centre) - moreover have "?Wz (reversepath (circlepath z e1)) = -1" using \e1>0\ - apply (subst winding_number_reversepath) - by (auto intro: winding_number_circlepath_centre) - ultimately show ?thesis by auto - qed - finally show ?thesis . - qed - ultimately show ?thesis using that by auto - qed - qed - then have "0 = ?ig g" using contour_integral_unique by simp - also have "... = ?ig (circlepath z e2) + ?ig l + ?ig (reversepath (circlepath z e1)) - + ?ig (reversepath l)" - unfolding g_def - by (auto simp add:contour_integrable_reversepath_eq) - also have "... = ?ig (circlepath z e2) - ?ig (circlepath z e1)" - by (auto simp add:contour_integral_reversepath) - finally show "contour_integral (circlepath z e2) f = contour_integral (circlepath z e1) f" - by simp -qed - -lemma base_residue: - assumes "open s" "z\s" "r>0" and f_holo:"f holomorphic_on (s - {z})" - and r_cball:"cball z r \ s" - shows "(f has_contour_integral 2 * pi * \ * (residue f z)) (circlepath z r)" -proof - - obtain e where "e>0" and e_cball:"cball z e \ s" - using open_contains_cball[of s] \open s\ \z\s\ by auto - define c where "c \ 2 * pi * \" - define i where "i \ contour_integral (circlepath z e) f / c" - have "(f has_contour_integral c*i) (circlepath z \)" when "\>0" "\ - proof - - have "contour_integral (circlepath z e) f = contour_integral (circlepath z \) f" - "f contour_integrable_on circlepath z \" - "f contour_integrable_on circlepath z e" - using \\ - by (intro contour_integral_circlepath_eq[OF \open s\ f_holo \\>0\ _ e_cball],auto)+ - then show ?thesis unfolding i_def c_def - by (auto intro:has_contour_integral_integral) - qed - then have "\e>0. \\>0. \ (f has_contour_integral c * (residue f z)) (circlepath z \)" - unfolding residue_def c_def - apply (rule_tac someI[of _ i],intro exI[where x=e]) - by (auto simp add:\e>0\ c_def) - then obtain e' where "e'>0" - and e'_def:"\\>0. \ (f has_contour_integral c * (residue f z)) (circlepath z \)" - by auto - let ?int="\e. contour_integral (circlepath z e) f" - define \ where "\ \ Min {r,e'} / 2" - have "\>0" "\\r" "\r>0\ \e'>0\ unfolding \_def by auto - have "(f has_contour_integral c * (residue f z)) (circlepath z \)" - using e'_def[rule_format,OF \\>0\ \\] . - then show ?thesis unfolding c_def - using contour_integral_circlepath_eq[OF \open s\ f_holo \\>0\ \\\r\ r_cball] - by (auto elim: has_contour_integral_eqpath[of _ _ "circlepath z \" "circlepath z r"]) -qed - -lemma residue_holo: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s" - shows "residue f z = 0" -proof - - define c where "c \ 2 * pi * \" - obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ - using open_contains_cball_eq by blast - have "(f has_contour_integral c*residue f z) (circlepath z e)" - using f_holo - by (auto intro: base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) - moreover have "(f has_contour_integral 0) (circlepath z e)" - using f_holo e_cball \e>0\ - by (auto intro: Cauchy_theorem_convex_simple[of _ "cball z e"]) - ultimately have "c*residue f z =0" - using has_contour_integral_unique by blast - thus ?thesis unfolding c_def by auto -qed - -lemma residue_const:"residue (\_. c) z = 0" - by (intro residue_holo[of "UNIV::complex set"],auto intro:holomorphic_intros) - -lemma residue_add: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - and g_holo:"g holomorphic_on s - {z}" - shows "residue (\z. f z + g z) z= residue f z + residue g z" -proof - - define c where "c \ 2 * pi * \" - define fg where "fg \ (\z. f z+g z)" - obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ - using open_contains_cball_eq by blast - have "(fg has_contour_integral c * residue fg z) (circlepath z e)" - unfolding fg_def using f_holo g_holo - apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) - by (auto intro:holomorphic_intros) - moreover have "(fg has_contour_integral c*residue f z + c* residue g z) (circlepath z e)" - unfolding fg_def using f_holo g_holo - by (auto intro: has_contour_integral_add base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) - ultimately have "c*(residue f z + residue g z) = c * residue fg z" - using has_contour_integral_unique by (auto simp add:distrib_left) - thus ?thesis unfolding fg_def - by (auto simp add:c_def) -qed - -lemma residue_lmul: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - shows "residue (\z. c * (f z)) z= c * residue f z" -proof (cases "c=0") - case True - thus ?thesis using residue_const by auto -next - case False - define c' where "c' \ 2 * pi * \" - define f' where "f' \ (\z. c * (f z))" - obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ - using open_contains_cball_eq by blast - have "(f' has_contour_integral c' * residue f' z) (circlepath z e)" - unfolding f'_def using f_holo - apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c'_def]) - by (auto intro:holomorphic_intros) - moreover have "(f' has_contour_integral c * (c' * residue f z)) (circlepath z e)" - unfolding f'_def using f_holo - by (auto intro: has_contour_integral_lmul - base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c'_def]) - ultimately have "c' * residue f' z = c * (c' * residue f z)" - using has_contour_integral_unique by auto - thus ?thesis unfolding f'_def c'_def using False - by (auto simp add:field_simps) -qed - -lemma residue_rmul: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - shows "residue (\z. (f z) * c) z= residue f z * c" -using residue_lmul[OF assms,of c] by (auto simp add:algebra_simps) - -lemma residue_div: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - shows "residue (\z. (f z) / c) z= residue f z / c " -using residue_lmul[OF assms,of "1/c"] by (auto simp add:algebra_simps) - -lemma residue_neg: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - shows "residue (\z. - (f z)) z= - residue f z" -using residue_lmul[OF assms,of "-1"] by auto - -lemma residue_diff: - assumes "open s" "z \ s" and f_holo: "f holomorphic_on s - {z}" - and g_holo:"g holomorphic_on s - {z}" - shows "residue (\z. f z - g z) z= residue f z - residue g z" -using residue_add[OF assms(1,2,3),of "\z. - g z"] residue_neg[OF assms(1,2,4)] -by (auto intro:holomorphic_intros g_holo) - -lemma residue_simple: - assumes "open s" "z\s" and f_holo:"f holomorphic_on s" - shows "residue (\w. f w / (w - z)) z = f z" -proof - - define c where "c \ 2 * pi * \" - define f' where "f' \ \w. f w / (w - z)" - obtain e where "e>0" and e_cball:"cball z e \ s" using \open s\ \z\s\ - using open_contains_cball_eq by blast - have "(f' has_contour_integral c * f z) (circlepath z e)" - unfolding f'_def c_def using \e>0\ f_holo e_cball - by (auto intro!: Cauchy_integral_circlepath_simple holomorphic_intros) - moreover have "(f' has_contour_integral c * residue f' z) (circlepath z e)" - unfolding f'_def using f_holo - apply (intro base_residue[OF \open s\ \z\s\ \e>0\ _ e_cball,folded c_def]) - by (auto intro!:holomorphic_intros) - ultimately have "c * f z = c * residue f' z" - using has_contour_integral_unique by blast - thus ?thesis unfolding c_def f'_def by auto -qed - -lemma residue_simple': - assumes s: "open s" "z \ s" and holo: "f holomorphic_on (s - {z})" - and lim: "((\w. f w * (w - z)) \ c) (at z)" - shows "residue f z = c" -proof - - define g where "g = (\w. if w = z then c else f w * (w - z))" - from holo have "(\w. f w * (w - z)) holomorphic_on (s - {z})" (is "?P") - by (force intro: holomorphic_intros) - also have "?P \ g holomorphic_on (s - {z})" - by (intro holomorphic_cong refl) (simp_all add: g_def) - finally have *: "g holomorphic_on (s - {z})" . - - note lim - also have "(\w. f w * (w - z)) \z\ c \ g \z\ g z" - by (intro filterlim_cong refl) (simp_all add: g_def [abs_def] eventually_at_filter) - finally have **: "g \z\ g z" . - - have g_holo: "g holomorphic_on s" - by (rule no_isolated_singularity'[where K = "{z}"]) - (insert assms * **, simp_all add: at_within_open_NO_MATCH) - from s and this have "residue (\w. g w / (w - z)) z = g z" - by (rule residue_simple) - also have "\\<^sub>F za in at z. g za / (za - z) = f za" - unfolding eventually_at by (auto intro!: exI[of _ 1] simp: field_simps g_def) - hence "residue (\w. g w / (w - z)) z = residue f z" - by (intro residue_cong refl) - finally show ?thesis - by (simp add: g_def) -qed - -lemma residue_holomorphic_over_power: - assumes "open A" "z0 \ A" "f holomorphic_on A" - shows "residue (\z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n" -proof - - let ?f = "\z. f z / (z - z0) ^ Suc n" - from assms(1,2) obtain r where r: "r > 0" "cball z0 r \ A" - by (auto simp: open_contains_cball) - have "(?f has_contour_integral 2 * pi * \ * residue ?f z0) (circlepath z0 r)" - using r assms by (intro base_residue[of A]) (auto intro!: holomorphic_intros) - moreover have "(?f has_contour_integral 2 * pi * \ / fact n * (deriv ^^ n) f z0) (circlepath z0 r)" - using assms r - by (intro Cauchy_has_contour_integral_higher_derivative_circlepath) - (auto intro!: holomorphic_on_subset[OF assms(3)] holomorphic_on_imp_continuous_on) - ultimately have "2 * pi * \ * residue ?f z0 = 2 * pi * \ / fact n * (deriv ^^ n) f z0" - by (rule has_contour_integral_unique) - thus ?thesis by (simp add: field_simps) -qed - -lemma residue_holomorphic_over_power': - assumes "open A" "0 \ A" "f holomorphic_on A" - shows "residue (\z. f z / z ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" - using residue_holomorphic_over_power[OF assms] by simp - -theorem residue_fps_expansion_over_power_at_0: - assumes "f has_fps_expansion F" - shows "residue (\z. f z / z ^ Suc n) 0 = fps_nth F n" -proof - - from has_fps_expansion_imp_holomorphic[OF assms] guess s . note s = this - have "residue (\z. f z / (z - 0) ^ Suc n) 0 = (deriv ^^ n) f 0 / fact n" - using assms s unfolding has_fps_expansion_def - by (intro residue_holomorphic_over_power[of s]) (auto simp: zero_ereal_def) - also from assms have "\ = fps_nth F n" - by (subst fps_nth_fps_expansion) auto - finally show ?thesis by simp -qed - -lemma get_integrable_path: - assumes "open s" "connected (s-pts)" "finite pts" "f holomorphic_on (s-pts) " "a\s-pts" "b\s-pts" - obtains g where "valid_path g" "pathstart g = a" "pathfinish g = b" - "path_image g \ s-pts" "f contour_integrable_on g" using assms -proof (induct arbitrary:s thesis a rule:finite_induct[OF \finite pts\]) - case 1 - obtain g where "valid_path g" "path_image g \ s" "pathstart g = a" "pathfinish g = b" - using connected_open_polynomial_connected[OF \open s\,of a b ] \connected (s - {})\ - valid_path_polynomial_function "1.prems"(6) "1.prems"(7) by auto - moreover have "f contour_integrable_on g" - using contour_integrable_holomorphic_simple[OF _ \open s\ \valid_path g\ \path_image g \ s\,of f] - \f holomorphic_on s - {}\ - by auto - ultimately show ?case using "1"(1)[of g] by auto -next - case idt:(2 p pts) - obtain e where "e>0" and e:"\w\ball a e. w \ s \ (w \ a \ w \ insert p pts)" - using finite_ball_avoid[OF \open s\ \finite (insert p pts)\, of a] - \a \ s - insert p pts\ - by auto - define a' where "a' \ a+e/2" - have "a'\s-{p} -pts" using e[rule_format,of "a+e/2"] \e>0\ - by (auto simp add:dist_complex_def a'_def) - then obtain g' where g'[simp]:"valid_path g'" "pathstart g' = a'" "pathfinish g' = b" - "path_image g' \ s - {p} - pts" "f contour_integrable_on g'" - using idt.hyps(3)[of a' "s-{p}"] idt.prems idt.hyps(1) - by (metis Diff_insert2 open_delete) - define g where "g \ linepath a a' +++ g'" - have "valid_path g" unfolding g_def by (auto intro: valid_path_join) - moreover have "pathstart g = a" and "pathfinish g = b" unfolding g_def by auto - moreover have "path_image g \ s - insert p pts" unfolding g_def - proof (rule subset_path_image_join) - have "closed_segment a a' \ ball a e" using \e>0\ - by (auto dest!:segment_bound1 simp:a'_def dist_complex_def norm_minus_commute) - then show "path_image (linepath a a') \ s - insert p pts" using e idt(9) - by auto - next - show "path_image g' \ s - insert p pts" using g'(4) by blast - qed - moreover have "f contour_integrable_on g" - proof - - have "closed_segment a a' \ ball a e" using \e>0\ - by (auto dest!:segment_bound1 simp:a'_def dist_complex_def norm_minus_commute) - then have "continuous_on (closed_segment a a') f" - using e idt.prems(6) holomorphic_on_imp_continuous_on[OF idt.prems(5)] - apply (elim continuous_on_subset) - by auto - then have "f contour_integrable_on linepath a a'" - using contour_integrable_continuous_linepath by auto - then show ?thesis unfolding g_def - apply (rule contour_integrable_joinI) - by (auto simp add: \e>0\) - qed - ultimately show ?case using idt.prems(1)[of g] by auto -qed - -lemma Cauchy_theorem_aux: - assumes "open s" "connected (s-pts)" "finite pts" "pts \ s" "f holomorphic_on s-pts" - "valid_path g" "pathfinish g = pathstart g" "path_image g \ s-pts" - "\z. (z \ s) \ winding_number g z = 0" - "\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" - shows "contour_integral g f = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" - using assms -proof (induct arbitrary:s g rule:finite_induct[OF \finite pts\]) - case 1 - then show ?case by (simp add: Cauchy_theorem_global contour_integral_unique) -next - case (2 p pts) - note fin[simp] = \finite (insert p pts)\ - and connected = \connected (s - insert p pts)\ - and valid[simp] = \valid_path g\ - and g_loop[simp] = \pathfinish g = pathstart g\ - and holo[simp]= \f holomorphic_on s - insert p pts\ - and path_img = \path_image g \ s - insert p pts\ - and winding = \\z. z \ s \ winding_number g z = 0\ - and h = \\pa\s. 0 < h pa \ (\w\cball pa (h pa). w \ s \ (w \ pa \ w \ insert p pts))\ - have "h p>0" and "p\s" - and h_p: "\w\cball p (h p). w \ s \ (w \ p \ w \ insert p pts)" - using h \insert p pts \ s\ by auto - obtain pg where pg[simp]: "valid_path pg" "pathstart pg = pathstart g" "pathfinish pg=p+h p" - "path_image pg \ s-insert p pts" "f contour_integrable_on pg" - proof - - have "p + h p\cball p (h p)" using h[rule_format,of p] - by (simp add: \p \ s\ dist_norm) - then have "p + h p \ s - insert p pts" using h[rule_format,of p] \insert p pts \ s\ - by fastforce - moreover have "pathstart g \ s - insert p pts " using path_img by auto - ultimately show ?thesis - using get_integrable_path[OF \open s\ connected fin holo,of "pathstart g" "p+h p"] that - by blast - qed - obtain n::int where "n=winding_number g p" - using integer_winding_number[OF _ g_loop,of p] valid path_img - by (metis DiffD2 Ints_cases insertI1 subset_eq valid_path_imp_path) - define p_circ where "p_circ \ circlepath p (h p)" - define p_circ_pt where "p_circ_pt \ linepath (p+h p) (p+h p)" - define n_circ where "n_circ \ \n. ((+++) p_circ ^^ n) p_circ_pt" - define cp where "cp \ if n\0 then reversepath (n_circ (nat n)) else n_circ (nat (- n))" - have n_circ:"valid_path (n_circ k)" - "winding_number (n_circ k) p = k" - "pathstart (n_circ k) = p + h p" "pathfinish (n_circ k) = p + h p" - "path_image (n_circ k) = (if k=0 then {p + h p} else sphere p (h p))" - "p \ path_image (n_circ k)" - "\p'. p'\s - pts \ winding_number (n_circ k) p'=0 \ p'\path_image (n_circ k)" - "f contour_integrable_on (n_circ k)" - "contour_integral (n_circ k) f = k * contour_integral p_circ f" - for k - proof (induct k) - case 0 - show "valid_path (n_circ 0)" - and "path_image (n_circ 0) = (if 0=0 then {p + h p} else sphere p (h p))" - and "winding_number (n_circ 0) p = of_nat 0" - and "pathstart (n_circ 0) = p + h p" - and "pathfinish (n_circ 0) = p + h p" - and "p \ path_image (n_circ 0)" - unfolding n_circ_def p_circ_pt_def using \h p > 0\ - by (auto simp add: dist_norm) - show "winding_number (n_circ 0) p'=0 \ p'\path_image (n_circ 0)" when "p'\s- pts" for p' - unfolding n_circ_def p_circ_pt_def - apply (auto intro!:winding_number_trivial) - by (metis Diff_iff pathfinish_in_path_image pg(3) pg(4) subsetCE subset_insertI that)+ - show "f contour_integrable_on (n_circ 0)" - unfolding n_circ_def p_circ_pt_def - by (auto intro!:contour_integrable_continuous_linepath simp add:continuous_on_sing) - show "contour_integral (n_circ 0) f = of_nat 0 * contour_integral p_circ f" - unfolding n_circ_def p_circ_pt_def by auto - next - case (Suc k) - have n_Suc:"n_circ (Suc k) = p_circ +++ n_circ k" unfolding n_circ_def by auto - have pcirc:"p \ path_image p_circ" "valid_path p_circ" "pathfinish p_circ = pathstart (n_circ k)" - using Suc(3) unfolding p_circ_def using \h p > 0\ by (auto simp add: p_circ_def) - have pcirc_image:"path_image p_circ \ s - insert p pts" - proof - - have "path_image p_circ \ cball p (h p)" using \0 < h p\ p_circ_def by auto - then show ?thesis using h_p pcirc(1) by auto - qed - have pcirc_integrable:"f contour_integrable_on p_circ" - by (auto simp add:p_circ_def intro!: pcirc_image[unfolded p_circ_def] - contour_integrable_continuous_circlepath holomorphic_on_imp_continuous_on - holomorphic_on_subset[OF holo]) - show "valid_path (n_circ (Suc k))" - using valid_path_join[OF pcirc(2) Suc(1) pcirc(3)] unfolding n_circ_def by auto - show "path_image (n_circ (Suc k)) - = (if Suc k = 0 then {p + complex_of_real (h p)} else sphere p (h p))" - proof - - have "path_image p_circ = sphere p (h p)" - unfolding p_circ_def using \0 < h p\ by auto - then show ?thesis unfolding n_Suc using Suc.hyps(5) \h p>0\ - by (auto simp add: path_image_join[OF pcirc(3)] dist_norm) - qed - then show "p \ path_image (n_circ (Suc k))" using \h p>0\ by auto - show "winding_number (n_circ (Suc k)) p = of_nat (Suc k)" - proof - - have "winding_number p_circ p = 1" - by (simp add: \h p > 0\ p_circ_def winding_number_circlepath_centre) - moreover have "p \ path_image (n_circ k)" using Suc(5) \h p>0\ by auto - then have "winding_number (p_circ +++ n_circ k) p - = winding_number p_circ p + winding_number (n_circ k) p" - using valid_path_imp_path Suc.hyps(1) Suc.hyps(2) pcirc - apply (intro winding_number_join) - by auto - ultimately show ?thesis using Suc(2) unfolding n_circ_def - by auto - qed - show "pathstart (n_circ (Suc k)) = p + h p" - by (simp add: n_circ_def p_circ_def) - show "pathfinish (n_circ (Suc k)) = p + h p" - using Suc(4) unfolding n_circ_def by auto - show "winding_number (n_circ (Suc k)) p'=0 \ p'\path_image (n_circ (Suc k))" when "p'\s-pts" for p' - proof - - have " p' \ path_image p_circ" using \p \ s\ h p_circ_def that using pcirc_image by blast - moreover have "p' \ path_image (n_circ k)" - using Suc.hyps(7) that by blast - moreover have "winding_number p_circ p' = 0" - proof - - have "path_image p_circ \ cball p (h p)" - using h unfolding p_circ_def using \p \ s\ by fastforce - moreover have "p'\cball p (h p)" using \p \ s\ h that "2.hyps"(2) by fastforce - ultimately show ?thesis unfolding p_circ_def - apply (intro winding_number_zero_outside) - by auto - qed - ultimately show ?thesis - unfolding n_Suc - apply (subst winding_number_join) - by (auto simp: valid_path_imp_path pcirc Suc that not_in_path_image_join Suc.hyps(7)[OF that]) - qed - show "f contour_integrable_on (n_circ (Suc k))" - unfolding n_Suc - by (rule contour_integrable_joinI[OF pcirc_integrable Suc(8) pcirc(2) Suc(1)]) - show "contour_integral (n_circ (Suc k)) f = (Suc k) * contour_integral p_circ f" - unfolding n_Suc - by (auto simp add:contour_integral_join[OF pcirc_integrable Suc(8) pcirc(2) Suc(1)] - Suc(9) algebra_simps) - qed - have cp[simp]:"pathstart cp = p + h p" "pathfinish cp = p + h p" - "valid_path cp" "path_image cp \ s - insert p pts" - "winding_number cp p = - n" - "\p'. p'\s - pts \ winding_number cp p'=0 \ p' \ path_image cp" - "f contour_integrable_on cp" - "contour_integral cp f = - n * contour_integral p_circ f" - proof - - show "pathstart cp = p + h p" and "pathfinish cp = p + h p" and "valid_path cp" - using n_circ unfolding cp_def by auto - next - have "sphere p (h p) \ s - insert p pts" - using h[rule_format,of p] \insert p pts \ s\ by force - moreover have "p + complex_of_real (h p) \ s - insert p pts" - using pg(3) pg(4) by (metis pathfinish_in_path_image subsetCE) - ultimately show "path_image cp \ s - insert p pts" unfolding cp_def - using n_circ(5) by auto - next - show "winding_number cp p = - n" - unfolding cp_def using winding_number_reversepath n_circ \h p>0\ - by (auto simp: valid_path_imp_path) - next - show "winding_number cp p'=0 \ p' \ path_image cp" when "p'\s - pts" for p' - unfolding cp_def - apply (auto) - apply (subst winding_number_reversepath) - by (auto simp add: valid_path_imp_path n_circ(7)[OF that] n_circ(1)) - next - show "f contour_integrable_on cp" unfolding cp_def - using contour_integrable_reversepath_eq n_circ(1,8) by auto - next - show "contour_integral cp f = - n * contour_integral p_circ f" - unfolding cp_def using contour_integral_reversepath[OF n_circ(1)] n_circ(9) - by auto - qed - define g' where "g' \ g +++ pg +++ cp +++ (reversepath pg)" - have "contour_integral g' f = (\p\pts. winding_number g' p * contour_integral (circlepath p (h p)) f)" - proof (rule "2.hyps"(3)[of "s-{p}" "g'",OF _ _ \finite pts\ ]) - show "connected (s - {p} - pts)" using connected by (metis Diff_insert2) - show "open (s - {p})" using \open s\ by auto - show " pts \ s - {p}" using \insert p pts \ s\ \ p \ pts\ by blast - show "f holomorphic_on s - {p} - pts" using holo \p \ pts\ by (metis Diff_insert2) - show "valid_path g'" - unfolding g'_def cp_def using n_circ valid pg g_loop - by (auto intro!:valid_path_join ) - show "pathfinish g' = pathstart g'" - unfolding g'_def cp_def using pg(2) by simp - show "path_image g' \ s - {p} - pts" - proof - - define s' where "s' \ s - {p} - pts" - have s':"s' = s-insert p pts " unfolding s'_def by auto - then show ?thesis using path_img pg(4) cp(4) - unfolding g'_def - apply (fold s'_def s') - apply (intro subset_path_image_join) - by auto - qed - note path_join_imp[simp] - show "\z. z \ s - {p} \ winding_number g' z = 0" - proof clarify - fix z assume z:"z\s - {p}" - have "winding_number (g +++ pg +++ cp +++ reversepath pg) z = winding_number g z - + winding_number (pg +++ cp +++ (reversepath pg)) z" - proof (rule winding_number_join) - show "path g" using \valid_path g\ by (simp add: valid_path_imp_path) - show "z \ path_image g" using z path_img by auto - show "path (pg +++ cp +++ reversepath pg)" using pg(3) cp - by (simp add: valid_path_imp_path) - next - have "path_image (pg +++ cp +++ reversepath pg) \ s - insert p pts" - using pg(4) cp(4) by (auto simp:subset_path_image_join) - then show "z \ path_image (pg +++ cp +++ reversepath pg)" using z by auto - next - show "pathfinish g = pathstart (pg +++ cp +++ reversepath pg)" using g_loop by auto - qed - also have "... = winding_number g z + (winding_number pg z - + winding_number (cp +++ (reversepath pg)) z)" - proof (subst add_left_cancel,rule winding_number_join) - show "path pg" and "path (cp +++ reversepath pg)" - and "pathfinish pg = pathstart (cp +++ reversepath pg)" - by (auto simp add: valid_path_imp_path) - show "z \ path_image pg" using pg(4) z by blast - show "z \ path_image (cp +++ reversepath pg)" using z - by (metis Diff_iff \z \ path_image pg\ contra_subsetD cp(4) insertI1 - not_in_path_image_join path_image_reversepath singletonD) - qed - also have "... = winding_number g z + (winding_number pg z - + (winding_number cp z + winding_number (reversepath pg) z))" - apply (auto intro!:winding_number_join simp: valid_path_imp_path) - apply (metis Diff_iff contra_subsetD cp(4) insertI1 singletonD z) - by (metis Diff_insert2 Diff_subset contra_subsetD pg(4) z) - also have "... = winding_number g z + winding_number cp z" - apply (subst winding_number_reversepath) - apply (auto simp: valid_path_imp_path) - by (metis Diff_iff contra_subsetD insertI1 pg(4) singletonD z) - finally have "winding_number g' z = winding_number g z + winding_number cp z" - unfolding g'_def . - moreover have "winding_number g z + winding_number cp z = 0" - using winding z \n=winding_number g p\ by auto - ultimately show "winding_number g' z = 0" unfolding g'_def by auto - qed - show "\pa\s - {p}. 0 < h pa \ (\w\cball pa (h pa). w \ s - {p} \ (w \ pa \ w \ pts))" - using h by fastforce - qed - moreover have "contour_integral g' f = contour_integral g f - - winding_number g p * contour_integral p_circ f" - proof - - have "contour_integral g' f = contour_integral g f - + contour_integral (pg +++ cp +++ reversepath pg) f" - unfolding g'_def - apply (subst contour_integral_join) - by (auto simp add:open_Diff[OF \open s\,OF finite_imp_closed[OF fin]] - intro!: contour_integrable_holomorphic_simple[OF holo _ _ path_img] - contour_integrable_reversepath) - also have "... = contour_integral g f + contour_integral pg f - + contour_integral (cp +++ reversepath pg) f" - apply (subst contour_integral_join) - by (auto simp add:contour_integrable_reversepath) - also have "... = contour_integral g f + contour_integral pg f - + contour_integral cp f + contour_integral (reversepath pg) f" - apply (subst contour_integral_join) - by (auto simp add:contour_integrable_reversepath) - also have "... = contour_integral g f + contour_integral cp f" - using contour_integral_reversepath - by (auto simp add:contour_integrable_reversepath) - also have "... = contour_integral g f - winding_number g p * contour_integral p_circ f" - using \n=winding_number g p\ by auto - finally show ?thesis . - qed - moreover have "winding_number g' p' = winding_number g p'" when "p'\pts" for p' - proof - - have [simp]: "p' \ path_image g" "p' \ path_image pg" "p'\path_image cp" - using "2.prems"(8) that - apply blast - apply (metis Diff_iff Diff_insert2 contra_subsetD pg(4) that) - by (meson DiffD2 cp(4) rev_subsetD subset_insertI that) - have "winding_number g' p' = winding_number g p' - + winding_number (pg +++ cp +++ reversepath pg) p'" unfolding g'_def - apply (subst winding_number_join) - apply (simp_all add: valid_path_imp_path) - apply (intro not_in_path_image_join) - by auto - also have "... = winding_number g p' + winding_number pg p' - + winding_number (cp +++ reversepath pg) p'" - apply (subst winding_number_join) - apply (simp_all add: valid_path_imp_path) - apply (intro not_in_path_image_join) - by auto - also have "... = winding_number g p' + winding_number pg p'+ winding_number cp p' - + winding_number (reversepath pg) p'" - apply (subst winding_number_join) - by (simp_all add: valid_path_imp_path) - also have "... = winding_number g p' + winding_number cp p'" - apply (subst winding_number_reversepath) - by (simp_all add: valid_path_imp_path) - also have "... = winding_number g p'" using that by auto - finally show ?thesis . - qed - ultimately show ?case unfolding p_circ_def - apply (subst (asm) sum.cong[OF refl, - of pts _ "\p. winding_number g p * contour_integral (circlepath p (h p)) f"]) - by (auto simp add:sum.insert[OF \finite pts\ \p\pts\] algebra_simps) -qed - -lemma Cauchy_theorem_singularities: - assumes "open s" "connected s" "finite pts" and - holo:"f holomorphic_on s-pts" and - "valid_path g" and - loop:"pathfinish g = pathstart g" and - "path_image g \ s-pts" and - homo:"\z. (z \ s) \ winding_number g z = 0" and - avoid:"\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" - shows "contour_integral g f = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" - (is "?L=?R") -proof - - define circ where "circ \ \p. winding_number g p * contour_integral (circlepath p (h p)) f" - define pts1 where "pts1 \ pts \ s" - define pts2 where "pts2 \ pts - pts1" - have "pts=pts1 \ pts2" "pts1 \ pts2 = {}" "pts2 \ s={}" "pts1\s" - unfolding pts1_def pts2_def by auto - have "contour_integral g f = (\p\pts1. circ p)" unfolding circ_def - proof (rule Cauchy_theorem_aux[OF \open s\ _ _ \pts1\s\ _ \valid_path g\ loop _ homo]) - have "finite pts1" unfolding pts1_def using \finite pts\ by auto - then show "connected (s - pts1)" - using \open s\ \connected s\ connected_open_delete_finite[of s] by auto - next - show "finite pts1" using \pts = pts1 \ pts2\ assms(3) by auto - show "f holomorphic_on s - pts1" by (metis Diff_Int2 Int_absorb holo pts1_def) - show "path_image g \ s - pts1" using assms(7) pts1_def by auto - show "\p\s. 0 < h p \ (\w\cball p (h p). w \ s \ (w \ p \ w \ pts1))" - by (simp add: avoid pts1_def) - qed - moreover have "sum circ pts2=0" - proof - - have "winding_number g p=0" when "p\pts2" for p - using \pts2 \ s={}\ that homo[rule_format,of p] by auto - thus ?thesis unfolding circ_def - apply (intro sum.neutral) - by auto - qed - moreover have "?R=sum circ pts1 + sum circ pts2" - unfolding circ_def - using sum.union_disjoint[OF _ _ \pts1 \ pts2 = {}\] \finite pts\ \pts=pts1 \ pts2\ - by blast - ultimately show ?thesis - apply (fold circ_def) - by auto -qed - -theorem Residue_theorem: - fixes s pts::"complex set" and f::"complex \ complex" - and g::"real \ complex" - assumes "open s" "connected s" "finite pts" and - holo:"f holomorphic_on s-pts" and - "valid_path g" and - loop:"pathfinish g = pathstart g" and - "path_image g \ s-pts" and - homo:"\z. (z \ s) \ winding_number g z = 0" - shows "contour_integral g f = 2 * pi * \ *(\p\pts. winding_number g p * residue f p)" -proof - - define c where "c \ 2 * pi * \" - obtain h where avoid:"\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" - using finite_cball_avoid[OF \open s\ \finite pts\] by metis - have "contour_integral g f - = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" - using Cauchy_theorem_singularities[OF assms avoid] . - also have "... = (\p\pts. c * winding_number g p * residue f p)" - proof (intro sum.cong) - show "pts = pts" by simp - next - fix x assume "x \ pts" - show "winding_number g x * contour_integral (circlepath x (h x)) f - = c * winding_number g x * residue f x" - proof (cases "x\s") - case False - then have "winding_number g x=0" using homo by auto - thus ?thesis by auto - next - case True - have "contour_integral (circlepath x (h x)) f = c* residue f x" - using \x\pts\ \finite pts\ avoid[rule_format,OF True] - apply (intro base_residue[of "s-(pts-{x})",THEN contour_integral_unique,folded c_def]) - by (auto intro:holomorphic_on_subset[OF holo] open_Diff[OF \open s\ finite_imp_closed]) - then show ?thesis by auto - qed - qed - also have "... = c * (\p\pts. winding_number g p * residue f p)" - by (simp add: sum_distrib_left algebra_simps) - finally show ?thesis unfolding c_def . -qed - -subsection \Non-essential singular points\ - -definition\<^marker>\tag important\ is_pole :: - "('a::topological_space \ 'b::real_normed_vector) \ 'a \ bool" where - "is_pole f a = (LIM x (at a). f x :> at_infinity)" - -lemma is_pole_cong: - assumes "eventually (\x. f x = g x) (at a)" "a=b" - shows "is_pole f a \ is_pole g b" - unfolding is_pole_def using assms by (intro filterlim_cong,auto) - -lemma is_pole_transform: - assumes "is_pole f a" "eventually (\x. f x = g x) (at a)" "a=b" - shows "is_pole g b" - using is_pole_cong assms by auto - -lemma is_pole_tendsto: - fixes f::"('a::topological_space \ 'b::real_normed_div_algebra)" - shows "is_pole f x \ ((inverse o f) \ 0) (at x)" -unfolding is_pole_def -by (auto simp add:filterlim_inverse_at_iff[symmetric] comp_def filterlim_at) - -lemma is_pole_inverse_holomorphic: - assumes "open s" - and f_holo:"f holomorphic_on (s-{z})" - and pole:"is_pole f z" - and non_z:"\x\s-{z}. f x\0" - shows "(\x. if x=z then 0 else inverse (f x)) holomorphic_on s" -proof - - define g where "g \ \x. if x=z then 0 else inverse (f x)" - have "isCont g z" unfolding isCont_def using is_pole_tendsto[OF pole] - apply (subst Lim_cong_at[where b=z and y=0 and g="inverse \ f"]) - by (simp_all add:g_def) - moreover have "continuous_on (s-{z}) f" using f_holo holomorphic_on_imp_continuous_on by auto - hence "continuous_on (s-{z}) (inverse o f)" unfolding comp_def - by (auto elim!:continuous_on_inverse simp add:non_z) - hence "continuous_on (s-{z}) g" unfolding g_def - apply (subst continuous_on_cong[where t="s-{z}" and g="inverse o f"]) - by auto - ultimately have "continuous_on s g" using open_delete[OF \open s\] \open s\ - by (auto simp add:continuous_on_eq_continuous_at) - moreover have "(inverse o f) holomorphic_on (s-{z})" - unfolding comp_def using f_holo - by (auto elim!:holomorphic_on_inverse simp add:non_z) - hence "g holomorphic_on (s-{z})" - apply (subst holomorphic_cong[where t="s-{z}" and g="inverse o f"]) - by (auto simp add:g_def) - ultimately show ?thesis unfolding g_def using \open s\ - by (auto elim!: no_isolated_singularity) -qed - -lemma not_is_pole_holomorphic: - assumes "open A" "x \ A" "f holomorphic_on A" - shows "\is_pole f x" -proof - - have "continuous_on A f" by (intro holomorphic_on_imp_continuous_on) fact - with assms have "isCont f x" by (simp add: continuous_on_eq_continuous_at) - hence "f \x\ f x" by (simp add: isCont_def) - thus "\is_pole f x" unfolding is_pole_def - using not_tendsto_and_filterlim_at_infinity[of "at x" f "f x"] by auto -qed - -lemma is_pole_inverse_power: "n > 0 \ is_pole (\z::complex. 1 / (z - a) ^ n) a" - unfolding is_pole_def inverse_eq_divide [symmetric] - by (intro filterlim_compose[OF filterlim_inverse_at_infinity] tendsto_intros) - (auto simp: filterlim_at eventually_at intro!: exI[of _ 1] tendsto_eq_intros) - -lemma is_pole_inverse: "is_pole (\z::complex. 1 / (z - a)) a" - using is_pole_inverse_power[of 1 a] by simp - -lemma is_pole_divide: - fixes f :: "'a :: t2_space \ 'b :: real_normed_field" - assumes "isCont f z" "filterlim g (at 0) (at z)" "f z \ 0" - shows "is_pole (\z. f z / g z) z" -proof - - have "filterlim (\z. f z * inverse (g z)) at_infinity (at z)" - by (intro tendsto_mult_filterlim_at_infinity[of _ "f z"] - filterlim_compose[OF filterlim_inverse_at_infinity])+ - (insert assms, auto simp: isCont_def) - thus ?thesis by (simp add: field_split_simps is_pole_def) -qed - -lemma is_pole_basic: - assumes "f holomorphic_on A" "open A" "z \ A" "f z \ 0" "n > 0" - shows "is_pole (\w. f w / (w - z) ^ n) z" -proof (rule is_pole_divide) - have "continuous_on A f" by (rule holomorphic_on_imp_continuous_on) fact - with assms show "isCont f z" by (auto simp: continuous_on_eq_continuous_at) - have "filterlim (\w. (w - z) ^ n) (nhds 0) (at z)" - using assms by (auto intro!: tendsto_eq_intros) - thus "filterlim (\w. (w - z) ^ n) (at 0) (at z)" - by (intro filterlim_atI tendsto_eq_intros) - (insert assms, auto simp: eventually_at_filter) -qed fact+ - -lemma is_pole_basic': - assumes "f holomorphic_on A" "open A" "0 \ A" "f 0 \ 0" "n > 0" - shows "is_pole (\w. f w / w ^ n) 0" - using is_pole_basic[of f A 0] assms by simp - -text \The proposition - \<^term>\\x. ((f::complex\complex) \ x) (at z) \ is_pole f z\ -can be interpreted as the complex function \<^term>\f\ has a non-essential singularity at \<^term>\z\ -(i.e. the singularity is either removable or a pole).\ -definition not_essential::"[complex \ complex, complex] \ bool" where - "not_essential f z = (\x. f\z\x \ is_pole f z)" - -definition isolated_singularity_at::"[complex \ complex, complex] \ bool" where - "isolated_singularity_at f z = (\r>0. f analytic_on ball z r-{z})" - -named_theorems singularity_intros "introduction rules for singularities" - -lemma holomorphic_factor_unique: - fixes f::"complex \ complex" and z::complex and r::real and m n::int - assumes "r>0" "g z\0" "h z\0" - and asm:"\w\ball z r-{z}. f w = g w * (w-z) powr n \ g w\0 \ f w = h w * (w - z) powr m \ h w\0" - and g_holo:"g holomorphic_on ball z r" and h_holo:"h holomorphic_on ball z r" - shows "n=m" -proof - - have [simp]:"at z within ball z r \ bot" using \r>0\ - by (auto simp add:at_within_ball_bot_iff) - have False when "n>m" - proof - - have "(h \ 0) (at z within ball z r)" - proof (rule Lim_transform_within[OF _ \r>0\, where f="\w. (w - z) powr (n - m) * g w"]) - have "\w\ball z r-{z}. h w = (w-z)powr(n-m) * g w" - using \n>m\ asm \r>0\ - apply (auto simp add:field_simps powr_diff) - by force - then show "\x' \ ball z r; 0 < dist x' z;dist x' z < r\ - \ (x' - z) powr (n - m) * g x' = h x'" for x' by auto - next - define F where "F \ at z within ball z r" - define f' where "f' \ \x. (x - z) powr (n-m)" - have "f' z=0" using \n>m\ unfolding f'_def by auto - moreover have "continuous F f'" unfolding f'_def F_def continuous_def - apply (subst Lim_ident_at) - using \n>m\ by (auto intro!:tendsto_powr_complex_0 tendsto_eq_intros) - ultimately have "(f' \ 0) F" unfolding F_def - by (simp add: continuous_within) - moreover have "(g \ g z) F" - using holomorphic_on_imp_continuous_on[OF g_holo,unfolded continuous_on_def] \r>0\ - unfolding F_def by auto - ultimately show " ((\w. f' w * g w) \ 0) F" using tendsto_mult by fastforce - qed - moreover have "(h \ h z) (at z within ball z r)" - using holomorphic_on_imp_continuous_on[OF h_holo] - by (auto simp add:continuous_on_def \r>0\) - ultimately have "h z=0" by (auto intro!: tendsto_unique) - thus False using \h z\0\ by auto - qed - moreover have False when "m>n" - proof - - have "(g \ 0) (at z within ball z r)" - proof (rule Lim_transform_within[OF _ \r>0\, where f="\w. (w - z) powr (m - n) * h w"]) - have "\w\ball z r -{z}. g w = (w-z) powr (m-n) * h w" using \m>n\ asm - apply (auto simp add:field_simps powr_diff) - by force - then show "\x' \ ball z r; 0 < dist x' z;dist x' z < r\ - \ (x' - z) powr (m - n) * h x' = g x'" for x' by auto - next - define F where "F \ at z within ball z r" - define f' where "f' \\x. (x - z) powr (m-n)" - have "f' z=0" using \m>n\ unfolding f'_def by auto - moreover have "continuous F f'" unfolding f'_def F_def continuous_def - apply (subst Lim_ident_at) - using \m>n\ by (auto intro!:tendsto_powr_complex_0 tendsto_eq_intros) - ultimately have "(f' \ 0) F" unfolding F_def - by (simp add: continuous_within) - moreover have "(h \ h z) F" - using holomorphic_on_imp_continuous_on[OF h_holo,unfolded continuous_on_def] \r>0\ - unfolding F_def by auto - ultimately show " ((\w. f' w * h w) \ 0) F" using tendsto_mult by fastforce - qed - moreover have "(g \ g z) (at z within ball z r)" - using holomorphic_on_imp_continuous_on[OF g_holo] - by (auto simp add:continuous_on_def \r>0\) - ultimately have "g z=0" by (auto intro!: tendsto_unique) - thus False using \g z\0\ by auto - qed - ultimately show "n=m" by fastforce -qed - -lemma holomorphic_factor_puncture: - assumes f_iso:"isolated_singularity_at f z" - and "not_essential f z" \ \\<^term>\f\ has either a removable singularity or a pole at \<^term>\z\\ - and non_zero:"\\<^sub>Fw in (at z). f w\0" \ \\<^term>\f\ will not be constantly zero in a neighbour of \<^term>\z\\ - shows "\!n::int. \g r. 0 < r \ g holomorphic_on cball z r \ g z\0 - \ (\w\cball z r-{z}. f w = g w * (w-z) powr n \ g w\0)" -proof - - define P where "P = (\f n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 - \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" - have imp_unique:"\!n::int. \g r. P f n g r" when "\n g r. P f n g r" - proof (rule ex_ex1I[OF that]) - fix n1 n2 :: int - assume g1_asm:"\g1 r1. P f n1 g1 r1" and g2_asm:"\g2 r2. P f n2 g2 r2" - define fac where "fac \ \n g r. \w\cball z r-{z}. f w = g w * (w - z) powr (of_int n) \ g w \ 0" - obtain g1 r1 where "0 < r1" and g1_holo: "g1 holomorphic_on cball z r1" and "g1 z\0" - and "fac n1 g1 r1" using g1_asm unfolding P_def fac_def by auto - obtain g2 r2 where "0 < r2" and g2_holo: "g2 holomorphic_on cball z r2" and "g2 z\0" - and "fac n2 g2 r2" using g2_asm unfolding P_def fac_def by auto - define r where "r \ min r1 r2" - have "r>0" using \r1>0\ \r2>0\ unfolding r_def by auto - moreover have "\w\ball z r-{z}. f w = g1 w * (w-z) powr n1 \ g1 w\0 - \ f w = g2 w * (w - z) powr n2 \ g2 w\0" - using \fac n1 g1 r1\ \fac n2 g2 r2\ unfolding fac_def r_def - by fastforce - ultimately show "n1=n2" using g1_holo g2_holo \g1 z\0\ \g2 z\0\ - apply (elim holomorphic_factor_unique) - by (auto simp add:r_def) - qed - - have P_exist:"\ n g r. P h n g r" when - "\z'. (h \ z') (at z)" "isolated_singularity_at h z" "\\<^sub>Fw in (at z). h w\0" - for h - proof - - from that(2) obtain r where "r>0" "h analytic_on ball z r - {z}" - unfolding isolated_singularity_at_def by auto - obtain z' where "(h \ z') (at z)" using \\z'. (h \ z') (at z)\ by auto - define h' where "h'=(\x. if x=z then z' else h x)" - have "h' holomorphic_on ball z r" - apply (rule no_isolated_singularity'[of "{z}"]) - subgoal by (metis LIM_equal Lim_at_imp_Lim_at_within \h \z\ z'\ empty_iff h'_def insert_iff) - subgoal using \h analytic_on ball z r - {z}\ analytic_imp_holomorphic h'_def holomorphic_transform - by fastforce - by auto - have ?thesis when "z'=0" - proof - - have "h' z=0" using that unfolding h'_def by auto - moreover have "\ h' constant_on ball z r" - using \\\<^sub>Fw in (at z). h w\0\ unfolding constant_on_def frequently_def eventually_at h'_def - apply simp - by (metis \0 < r\ centre_in_ball dist_commute mem_ball that) - moreover note \h' holomorphic_on ball z r\ - ultimately obtain g r1 n where "0 < n" "0 < r1" "ball z r1 \ ball z r" and - g:"g holomorphic_on ball z r1" - "\w. w \ ball z r1 \ h' w = (w - z) ^ n * g w" - "\w. w \ ball z r1 \ g w \ 0" - using holomorphic_factor_zero_nonconstant[of _ "ball z r" z thesis,simplified, - OF \h' holomorphic_on ball z r\ \r>0\ \h' z=0\ \\ h' constant_on ball z r\] - by (auto simp add:dist_commute) - define rr where "rr=r1/2" - have "P h' n g rr" - unfolding P_def rr_def - using \n>0\ \r1>0\ g by (auto simp add:powr_nat) - then have "P h n g rr" - unfolding h'_def P_def by auto - then show ?thesis unfolding P_def by blast - qed - moreover have ?thesis when "z'\0" - proof - - have "h' z\0" using that unfolding h'_def by auto - obtain r1 where "r1>0" "cball z r1 \ ball z r" "\x\cball z r1. h' x\0" - proof - - have "isCont h' z" "h' z\0" - by (auto simp add: Lim_cong_within \h \z\ z'\ \z'\0\ continuous_at h'_def) - then obtain r2 where r2:"r2>0" "\x\ball z r2. h' x\0" - using continuous_at_avoid[of z h' 0 ] unfolding ball_def by auto - define r1 where "r1=min r2 r / 2" - have "0 < r1" "cball z r1 \ ball z r" - using \r2>0\ \r>0\ unfolding r1_def by auto - moreover have "\x\cball z r1. h' x \ 0" - using r2 unfolding r1_def by simp - ultimately show ?thesis using that by auto - qed - then have "P h' 0 h' r1" using \h' holomorphic_on ball z r\ unfolding P_def by auto - then have "P h 0 h' r1" unfolding P_def h'_def by auto - then show ?thesis unfolding P_def by blast - qed - ultimately show ?thesis by auto - qed - - have ?thesis when "\x. (f \ x) (at z)" - apply (rule_tac imp_unique[unfolded P_def]) - using P_exist[OF that(1) f_iso non_zero] unfolding P_def . - moreover have ?thesis when "is_pole f z" - proof (rule imp_unique[unfolded P_def]) - obtain e where [simp]:"e>0" and e_holo:"f holomorphic_on ball z e - {z}" and e_nz: "\x\ball z e-{z}. f x\0" - proof - - have "\\<^sub>F z in at z. f z \ 0" - using \is_pole f z\ filterlim_at_infinity_imp_eventually_ne unfolding is_pole_def - by auto - then obtain e1 where e1:"e1>0" "\x\ball z e1-{z}. f x\0" - using that eventually_at[of "\x. f x\0" z UNIV,simplified] by (auto simp add:dist_commute) - obtain e2 where e2:"e2>0" "f holomorphic_on ball z e2 - {z}" - using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by auto - define e where "e=min e1 e2" - show ?thesis - apply (rule that[of e]) - using e1 e2 unfolding e_def by auto - qed - - define h where "h \ \x. inverse (f x)" - - have "\n g r. P h n g r" - proof - - have "h \z\ 0" - using Lim_transform_within_open assms(2) h_def is_pole_tendsto that by fastforce - moreover have "\\<^sub>Fw in (at z). h w\0" - using non_zero - apply (elim frequently_rev_mp) - unfolding h_def eventually_at by (auto intro:exI[where x=1]) - moreover have "isolated_singularity_at h z" - unfolding isolated_singularity_at_def h_def - apply (rule exI[where x=e]) - using e_holo e_nz \e>0\ by (metis open_ball analytic_on_open - holomorphic_on_inverse open_delete) - ultimately show ?thesis - using P_exist[of h] by auto - qed - then obtain n g r - where "0 < r" and - g_holo:"g holomorphic_on cball z r" and "g z\0" and - g_fac:"(\w\cball z r-{z}. h w = g w * (w - z) powr of_int n \ g w \ 0)" - unfolding P_def by auto - have "P f (-n) (inverse o g) r" - proof - - have "f w = inverse (g w) * (w - z) powr of_int (- n)" when "w\cball z r - {z}" for w - using g_fac[rule_format,of w] that unfolding h_def - apply (auto simp add:powr_minus ) - by (metis inverse_inverse_eq inverse_mult_distrib) - then show ?thesis - unfolding P_def comp_def - using \r>0\ g_holo g_fac \g z\0\ by (auto intro:holomorphic_intros) - qed - then show "\x g r. 0 < r \ g holomorphic_on cball z r \ g z \ 0 - \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int x \ g w \ 0)" - unfolding P_def by blast - qed - ultimately show ?thesis using \not_essential f z\ unfolding not_essential_def by presburger -qed - -lemma not_essential_transform: - assumes "not_essential g z" - assumes "\\<^sub>F w in (at z). g w = f w" - shows "not_essential f z" - using assms unfolding not_essential_def - by (simp add: filterlim_cong is_pole_cong) - -lemma isolated_singularity_at_transform: - assumes "isolated_singularity_at g z" - assumes "\\<^sub>F w in (at z). g w = f w" - shows "isolated_singularity_at f z" -proof - - obtain r1 where "r1>0" and r1:"g analytic_on ball z r1 - {z}" - using assms(1) unfolding isolated_singularity_at_def by auto - obtain r2 where "r2>0" and r2:" \x. x \ z \ dist x z < r2 \ g x = f x" - using assms(2) unfolding eventually_at by auto - define r3 where "r3=min r1 r2" - have "r3>0" unfolding r3_def using \r1>0\ \r2>0\ by auto - moreover have "f analytic_on ball z r3 - {z}" - proof - - have "g holomorphic_on ball z r3 - {z}" - using r1 unfolding r3_def by (subst (asm) analytic_on_open,auto) - then have "f holomorphic_on ball z r3 - {z}" - using r2 unfolding r3_def - by (auto simp add:dist_commute elim!:holomorphic_transform) - then show ?thesis by (subst analytic_on_open,auto) - qed - ultimately show ?thesis unfolding isolated_singularity_at_def by auto -qed - -lemma not_essential_powr[singularity_intros]: - assumes "LIM w (at z). f w :> (at x)" - shows "not_essential (\w. (f w) powr (of_int n)) z" -proof - - define fp where "fp=(\w. (f w) powr (of_int n))" - have ?thesis when "n>0" - proof - - have "(\w. (f w) ^ (nat n)) \z\ x ^ nat n" - using that assms unfolding filterlim_at by (auto intro!:tendsto_eq_intros) - then have "fp \z\ x ^ nat n" unfolding fp_def - apply (elim Lim_transform_within[where d=1],simp) - by (metis less_le powr_0 powr_of_int that zero_less_nat_eq zero_power) - then show ?thesis unfolding not_essential_def fp_def by auto - qed - moreover have ?thesis when "n=0" - proof - - have "fp \z\ 1 " - apply (subst tendsto_cong[where g="\_.1"]) - using that filterlim_at_within_not_equal[OF assms,of 0] unfolding fp_def by auto - then show ?thesis unfolding fp_def not_essential_def by auto - qed - moreover have ?thesis when "n<0" - proof (cases "x=0") - case True - have "LIM w (at z). inverse ((f w) ^ (nat (-n))) :> at_infinity" - apply (subst filterlim_inverse_at_iff[symmetric],simp) - apply (rule filterlim_atI) - subgoal using assms True that unfolding filterlim_at by (auto intro!:tendsto_eq_intros) - subgoal using filterlim_at_within_not_equal[OF assms,of 0] - by (eventually_elim,insert that,auto) - done - then have "LIM w (at z). fp w :> at_infinity" - proof (elim filterlim_mono_eventually) - show "\\<^sub>F x in at z. inverse (f x ^ nat (- n)) = fp x" - using filterlim_at_within_not_equal[OF assms,of 0] unfolding fp_def - apply eventually_elim - using powr_of_int that by auto - qed auto - then show ?thesis unfolding fp_def not_essential_def is_pole_def by auto - next - case False - let ?xx= "inverse (x ^ (nat (-n)))" - have "(\w. inverse ((f w) ^ (nat (-n)))) \z\?xx" - using assms False unfolding filterlim_at by (auto intro!:tendsto_eq_intros) - then have "fp \z\?xx" - apply (elim Lim_transform_within[where d=1],simp) - unfolding fp_def by (metis inverse_zero nat_mono_iff nat_zero_as_int neg_0_less_iff_less - not_le power_eq_0_iff powr_0 powr_of_int that) - then show ?thesis unfolding fp_def not_essential_def by auto - qed - ultimately show ?thesis by linarith -qed - -lemma isolated_singularity_at_powr[singularity_intros]: - assumes "isolated_singularity_at f z" "\\<^sub>F w in (at z). f w\0" - shows "isolated_singularity_at (\w. (f w) powr (of_int n)) z" -proof - - obtain r1 where "r1>0" "f analytic_on ball z r1 - {z}" - using assms(1) unfolding isolated_singularity_at_def by auto - then have r1:"f holomorphic_on ball z r1 - {z}" - using analytic_on_open[of "ball z r1-{z}" f] by blast - obtain r2 where "r2>0" and r2:"\w. w \ z \ dist w z < r2 \ f w \ 0" - using assms(2) unfolding eventually_at by auto - define r3 where "r3=min r1 r2" - have "(\w. (f w) powr of_int n) holomorphic_on ball z r3 - {z}" - apply (rule holomorphic_on_powr_of_int) - subgoal unfolding r3_def using r1 by auto - subgoal unfolding r3_def using r2 by (auto simp add:dist_commute) - done - moreover have "r3>0" unfolding r3_def using \0 < r1\ \0 < r2\ by linarith - ultimately show ?thesis unfolding isolated_singularity_at_def - apply (subst (asm) analytic_on_open[symmetric]) - by auto -qed - -lemma non_zero_neighbour: - assumes f_iso:"isolated_singularity_at f z" - and f_ness:"not_essential f z" - and f_nconst:"\\<^sub>Fw in (at z). f w\0" - shows "\\<^sub>F w in (at z). f w\0" -proof - - obtain fn fp fr where [simp]:"fp z \ 0" and "fr > 0" - and fr: "fp holomorphic_on cball z fr" - "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" - using holomorphic_factor_puncture[OF f_iso f_ness f_nconst,THEN ex1_implies_ex] by auto - have "f w \ 0" when " w \ z" "dist w z < fr" for w - proof - - have "f w = fp w * (w - z) powr of_int fn" "fp w \ 0" - using fr(2)[rule_format, of w] using that by (auto simp add:dist_commute) - moreover have "(w - z) powr of_int fn \0" - unfolding powr_eq_0_iff using \w\z\ by auto - ultimately show ?thesis by auto - qed - then show ?thesis using \fr>0\ unfolding eventually_at by auto -qed - -lemma non_zero_neighbour_pole: - assumes "is_pole f z" - shows "\\<^sub>F w in (at z). f w\0" - using assms filterlim_at_infinity_imp_eventually_ne[of f "at z" 0] - unfolding is_pole_def by auto - -lemma non_zero_neighbour_alt: - assumes holo: "f holomorphic_on S" - and "open S" "connected S" "z \ S" "\ \ S" "f \ \ 0" - shows "\\<^sub>F w in (at z). f w\0 \ w\S" -proof (cases "f z = 0") - case True - from isolated_zeros[OF holo \open S\ \connected S\ \z \ S\ True \\ \ S\ \f \ \ 0\] - obtain r where "0 < r" "ball z r \ S" "\w \ ball z r - {z}.f w \ 0" by metis - then show ?thesis unfolding eventually_at - apply (rule_tac x=r in exI) - by (auto simp add:dist_commute) -next - case False - obtain r1 where r1:"r1>0" "\y. dist z y < r1 \ f y \ 0" - using continuous_at_avoid[of z f, OF _ False] assms(2,4) continuous_on_eq_continuous_at - holo holomorphic_on_imp_continuous_on by blast - obtain r2 where r2:"r2>0" "ball z r2 \ S" - using assms(2) assms(4) openE by blast - show ?thesis unfolding eventually_at - apply (rule_tac x="min r1 r2" in exI) - using r1 r2 by (auto simp add:dist_commute) -qed - -lemma not_essential_times[singularity_intros]: - assumes f_ness:"not_essential f z" and g_ness:"not_essential g z" - assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" - shows "not_essential (\w. f w * g w) z" -proof - - define fg where "fg = (\w. f w * g w)" - have ?thesis when "\ ((\\<^sub>Fw in (at z). f w\0) \ (\\<^sub>Fw in (at z). g w\0))" - proof - - have "\\<^sub>Fw in (at z). fg w=0" - using that[unfolded frequently_def, simplified] unfolding fg_def - by (auto elim: eventually_rev_mp) - from tendsto_cong[OF this] have "fg \z\0" by auto - then show ?thesis unfolding not_essential_def fg_def by auto - qed - moreover have ?thesis when f_nconst:"\\<^sub>Fw in (at z). f w\0" and g_nconst:"\\<^sub>Fw in (at z). g w\0" - proof - - obtain fn fp fr where [simp]:"fp z \ 0" and "fr > 0" - and fr: "fp holomorphic_on cball z fr" - "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" - using holomorphic_factor_puncture[OF f_iso f_ness f_nconst,THEN ex1_implies_ex] by auto - obtain gn gp gr where [simp]:"gp z \ 0" and "gr > 0" - and gr: "gp holomorphic_on cball z gr" - "\w\cball z gr - {z}. g w = gp w * (w - z) powr of_int gn \ gp w \ 0" - using holomorphic_factor_puncture[OF g_iso g_ness g_nconst,THEN ex1_implies_ex] by auto - - define r1 where "r1=(min fr gr)" - have "r1>0" unfolding r1_def using \fr>0\ \gr>0\ by auto - have fg_times:"fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" and fgp_nz:"fp w*gp w\0" - when "w\ball z r1 - {z}" for w - proof - - have "f w = fp w * (w - z) powr of_int fn" "fp w\0" - using fr(2)[rule_format,of w] that unfolding r1_def by auto - moreover have "g w = gp w * (w - z) powr of_int gn" "gp w \ 0" - using gr(2)[rule_format, of w] that unfolding r1_def by auto - ultimately show "fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" "fp w*gp w\0" - unfolding fg_def by (auto simp add:powr_add) - qed - - have [intro]: "fp \z\fp z" "gp \z\gp z" - using fr(1) \fr>0\ gr(1) \gr>0\ - by (meson open_ball ball_subset_cball centre_in_ball - continuous_on_eq_continuous_at continuous_within holomorphic_on_imp_continuous_on - holomorphic_on_subset)+ - have ?thesis when "fn+gn>0" - proof - - have "(\w. (fp w * gp w) * (w - z) ^ (nat (fn+gn))) \z\0" - using that by (auto intro!:tendsto_eq_intros) - then have "fg \z\ 0" - apply (elim Lim_transform_within[OF _ \r1>0\]) - by (metis (no_types, hide_lams) Diff_iff cball_trivial dist_commute dist_self - eq_iff_diff_eq_0 fg_times less_le linorder_not_le mem_ball mem_cball powr_of_int - that) - then show ?thesis unfolding not_essential_def fg_def by auto - qed - moreover have ?thesis when "fn+gn=0" - proof - - have "(\w. fp w * gp w) \z\fp z*gp z" - using that by (auto intro!:tendsto_eq_intros) - then have "fg \z\ fp z*gp z" - apply (elim Lim_transform_within[OF _ \r1>0\]) - apply (subst fg_times) - by (auto simp add:dist_commute that) - then show ?thesis unfolding not_essential_def fg_def by auto - qed - moreover have ?thesis when "fn+gn<0" - proof - - have "LIM w (at z). fp w * gp w / (w-z)^nat (-(fn+gn)) :> at_infinity" - apply (rule filterlim_divide_at_infinity) - apply (insert that, auto intro!:tendsto_eq_intros filterlim_atI) - using eventually_at_topological by blast - then have "is_pole fg z" unfolding is_pole_def - apply (elim filterlim_transform_within[OF _ _ \r1>0\],simp) - apply (subst fg_times,simp add:dist_commute) - apply (subst powr_of_int) - using that by (auto simp add:field_split_simps) - then show ?thesis unfolding not_essential_def fg_def by auto - qed - ultimately show ?thesis unfolding not_essential_def fg_def by fastforce - qed - ultimately show ?thesis by auto -qed - -lemma not_essential_inverse[singularity_intros]: - assumes f_ness:"not_essential f z" - assumes f_iso:"isolated_singularity_at f z" - shows "not_essential (\w. inverse (f w)) z" -proof - - define vf where "vf = (\w. inverse (f w))" - have ?thesis when "\(\\<^sub>Fw in (at z). f w\0)" - proof - - have "\\<^sub>Fw in (at z). f w=0" - using that[unfolded frequently_def, simplified] by (auto elim: eventually_rev_mp) - then have "\\<^sub>Fw in (at z). vf w=0" - unfolding vf_def by auto - from tendsto_cong[OF this] have "vf \z\0" unfolding vf_def by auto - then show ?thesis unfolding not_essential_def vf_def by auto - qed - moreover have ?thesis when "is_pole f z" - proof - - have "vf \z\0" - using that filterlim_at filterlim_inverse_at_iff unfolding is_pole_def vf_def by blast - then show ?thesis unfolding not_essential_def vf_def by auto - qed - moreover have ?thesis when "\x. f\z\x " and f_nconst:"\\<^sub>Fw in (at z). f w\0" - proof - - from that obtain fz where fz:"f\z\fz" by auto - have ?thesis when "fz=0" - proof - - have "(\w. inverse (vf w)) \z\0" - using fz that unfolding vf_def by auto - moreover have "\\<^sub>F w in at z. inverse (vf w) \ 0" - using non_zero_neighbour[OF f_iso f_ness f_nconst] - unfolding vf_def by auto - ultimately have "is_pole vf z" - using filterlim_inverse_at_iff[of vf "at z"] unfolding filterlim_at is_pole_def by auto - then show ?thesis unfolding not_essential_def vf_def by auto - qed - moreover have ?thesis when "fz\0" - proof - - have "vf \z\inverse fz" - using fz that unfolding vf_def by (auto intro:tendsto_eq_intros) - then show ?thesis unfolding not_essential_def vf_def by auto - qed - ultimately show ?thesis by auto - qed - ultimately show ?thesis using f_ness unfolding not_essential_def by auto -qed - -lemma isolated_singularity_at_inverse[singularity_intros]: - assumes f_iso:"isolated_singularity_at f z" - and f_ness:"not_essential f z" - shows "isolated_singularity_at (\w. inverse (f w)) z" -proof - - define vf where "vf = (\w. inverse (f w))" - have ?thesis when "\(\\<^sub>Fw in (at z). f w\0)" - proof - - have "\\<^sub>Fw in (at z). f w=0" - using that[unfolded frequently_def, simplified] by (auto elim: eventually_rev_mp) - then have "\\<^sub>Fw in (at z). vf w=0" - unfolding vf_def by auto - then obtain d1 where "d1>0" and d1:"\x. x \ z \ dist x z < d1 \ vf x = 0" - unfolding eventually_at by auto - then have "vf holomorphic_on ball z d1-{z}" - apply (rule_tac holomorphic_transform[of "\_. 0"]) - by (auto simp add:dist_commute) - then have "vf analytic_on ball z d1 - {z}" - by (simp add: analytic_on_open open_delete) - then show ?thesis using \d1>0\ unfolding isolated_singularity_at_def vf_def by auto - qed - moreover have ?thesis when f_nconst:"\\<^sub>Fw in (at z). f w\0" - proof - - have "\\<^sub>F w in at z. f w \ 0" using non_zero_neighbour[OF f_iso f_ness f_nconst] . - then obtain d1 where d1:"d1>0" "\x. x \ z \ dist x z < d1 \ f x \ 0" - unfolding eventually_at by auto - obtain d2 where "d2>0" and d2:"f analytic_on ball z d2 - {z}" - using f_iso unfolding isolated_singularity_at_def by auto - define d3 where "d3=min d1 d2" - have "d3>0" unfolding d3_def using \d1>0\ \d2>0\ by auto - moreover have "vf analytic_on ball z d3 - {z}" - unfolding vf_def - apply (rule analytic_on_inverse) - subgoal using d2 unfolding d3_def by (elim analytic_on_subset) auto - subgoal for w using d1 unfolding d3_def by (auto simp add:dist_commute) - done - ultimately show ?thesis unfolding isolated_singularity_at_def vf_def by auto - qed - ultimately show ?thesis by auto -qed - -lemma not_essential_divide[singularity_intros]: - assumes f_ness:"not_essential f z" and g_ness:"not_essential g z" - assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" - shows "not_essential (\w. f w / g w) z" -proof - - have "not_essential (\w. f w * inverse (g w)) z" - apply (rule not_essential_times[where g="\w. inverse (g w)"]) - using assms by (auto intro: isolated_singularity_at_inverse not_essential_inverse) - then show ?thesis by (simp add:field_simps) -qed - -lemma - assumes f_iso:"isolated_singularity_at f z" - and g_iso:"isolated_singularity_at g z" - shows isolated_singularity_at_times[singularity_intros]: - "isolated_singularity_at (\w. f w * g w) z" and - isolated_singularity_at_add[singularity_intros]: - "isolated_singularity_at (\w. f w + g w) z" -proof - - obtain d1 d2 where "d1>0" "d2>0" - and d1:"f analytic_on ball z d1 - {z}" and d2:"g analytic_on ball z d2 - {z}" - using f_iso g_iso unfolding isolated_singularity_at_def by auto - define d3 where "d3=min d1 d2" - have "d3>0" unfolding d3_def using \d1>0\ \d2>0\ by auto - - have "(\w. f w * g w) analytic_on ball z d3 - {z}" - apply (rule analytic_on_mult) - using d1 d2 unfolding d3_def by (auto elim:analytic_on_subset) - then show "isolated_singularity_at (\w. f w * g w) z" - using \d3>0\ unfolding isolated_singularity_at_def by auto - have "(\w. f w + g w) analytic_on ball z d3 - {z}" - apply (rule analytic_on_add) - using d1 d2 unfolding d3_def by (auto elim:analytic_on_subset) - then show "isolated_singularity_at (\w. f w + g w) z" - using \d3>0\ unfolding isolated_singularity_at_def by auto -qed - -lemma isolated_singularity_at_uminus[singularity_intros]: - assumes f_iso:"isolated_singularity_at f z" - shows "isolated_singularity_at (\w. - f w) z" - using assms unfolding isolated_singularity_at_def using analytic_on_neg by blast - -lemma isolated_singularity_at_id[singularity_intros]: - "isolated_singularity_at (\w. w) z" - unfolding isolated_singularity_at_def by (simp add: gt_ex) - -lemma isolated_singularity_at_minus[singularity_intros]: - assumes f_iso:"isolated_singularity_at f z" - and g_iso:"isolated_singularity_at g z" - shows "isolated_singularity_at (\w. f w - g w) z" - using isolated_singularity_at_uminus[THEN isolated_singularity_at_add[OF f_iso,of "\w. - g w"] - ,OF g_iso] by simp - -lemma isolated_singularity_at_divide[singularity_intros]: - assumes f_iso:"isolated_singularity_at f z" - and g_iso:"isolated_singularity_at g z" - and g_ness:"not_essential g z" - shows "isolated_singularity_at (\w. f w / g w) z" - using isolated_singularity_at_inverse[THEN isolated_singularity_at_times[OF f_iso, - of "\w. inverse (g w)"],OF g_iso g_ness] by (simp add:field_simps) - -lemma isolated_singularity_at_const[singularity_intros]: - "isolated_singularity_at (\w. c) z" - unfolding isolated_singularity_at_def by (simp add: gt_ex) - -lemma isolated_singularity_at_holomorphic: - assumes "f holomorphic_on s-{z}" "open s" "z\s" - shows "isolated_singularity_at f z" - using assms unfolding isolated_singularity_at_def - by (metis analytic_on_holomorphic centre_in_ball insert_Diff openE open_delete subset_insert_iff) - -subsubsection \The order of non-essential singularities (i.e. removable singularities or poles)\ - - -definition\<^marker>\tag important\ zorder :: "(complex \ complex) \ complex \ int" where - "zorder f z = (THE n. (\h r. r>0 \ h holomorphic_on cball z r \ h z\0 - \ (\w\cball z r - {z}. f w = h w * (w-z) powr (of_int n) - \ h w \0)))" - -definition\<^marker>\tag important\ zor_poly - ::"[complex \ complex, complex] \ complex \ complex" where - "zor_poly f z = (SOME h. \r. r > 0 \ h holomorphic_on cball z r \ h z \ 0 - \ (\w\cball z r - {z}. f w = h w * (w - z) powr (zorder f z) - \ h w \0))" - -lemma zorder_exist: - fixes f::"complex \ complex" and z::complex - defines "n\zorder f z" and "g\zor_poly f z" - assumes f_iso:"isolated_singularity_at f z" - and f_ness:"not_essential f z" - and f_nconst:"\\<^sub>Fw in (at z). f w\0" - shows "g z\0 \ (\r. r>0 \ g holomorphic_on cball z r - \ (\w\cball z r - {z}. f w = g w * (w-z) powr n \ g w \0))" -proof - - define P where "P = (\n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 - \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" - have "\!n. \g r. P n g r" - using holomorphic_factor_puncture[OF assms(3-)] unfolding P_def by auto - then have "\g r. P n g r" - unfolding n_def P_def zorder_def - by (drule_tac theI',argo) - then have "\r. P n g r" - unfolding P_def zor_poly_def g_def n_def - by (drule_tac someI_ex,argo) - then obtain r1 where "P n g r1" by auto - then show ?thesis unfolding P_def by auto -qed - -lemma - fixes f::"complex \ complex" and z::complex - assumes f_iso:"isolated_singularity_at f z" - and f_ness:"not_essential f z" - and f_nconst:"\\<^sub>Fw in (at z). f w\0" - shows zorder_inverse: "zorder (\w. inverse (f w)) z = - zorder f z" - and zor_poly_inverse: "\\<^sub>Fw in (at z). zor_poly (\w. inverse (f w)) z w - = inverse (zor_poly f z w)" -proof - - define vf where "vf = (\w. inverse (f w))" - define fn vfn where - "fn = zorder f z" and "vfn = zorder vf z" - define fp vfp where - "fp = zor_poly f z" and "vfp = zor_poly vf z" - - obtain fr where [simp]:"fp z \ 0" and "fr > 0" - and fr: "fp holomorphic_on cball z fr" - "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" - using zorder_exist[OF f_iso f_ness f_nconst,folded fn_def fp_def] - by auto - have fr_inverse: "vf w = (inverse (fp w)) * (w - z) powr (of_int (-fn))" - and fr_nz: "inverse (fp w)\0" - when "w\ball z fr - {z}" for w - proof - - have "f w = fp w * (w - z) powr of_int fn" "fp w\0" - using fr(2)[rule_format,of w] that by auto - then show "vf w = (inverse (fp w)) * (w - z) powr (of_int (-fn))" "inverse (fp w)\0" - unfolding vf_def by (auto simp add:powr_minus) - qed - obtain vfr where [simp]:"vfp z \ 0" and "vfr>0" and vfr:"vfp holomorphic_on cball z vfr" - "(\w\cball z vfr - {z}. vf w = vfp w * (w - z) powr of_int vfn \ vfp w \ 0)" - proof - - have "isolated_singularity_at vf z" - using isolated_singularity_at_inverse[OF f_iso f_ness] unfolding vf_def . - moreover have "not_essential vf z" - using not_essential_inverse[OF f_ness f_iso] unfolding vf_def . - moreover have "\\<^sub>F w in at z. vf w \ 0" - using f_nconst unfolding vf_def by (auto elim:frequently_elim1) - ultimately show ?thesis using zorder_exist[of vf z, folded vfn_def vfp_def] that by auto - qed - - - define r1 where "r1 = min fr vfr" - have "r1>0" using \fr>0\ \vfr>0\ unfolding r1_def by simp - show "vfn = - fn" - apply (rule holomorphic_factor_unique[of r1 vfp z "\w. inverse (fp w)" vf]) - subgoal using \r1>0\ by simp - subgoal by simp - subgoal by simp - subgoal - proof (rule ballI) - fix w assume "w \ ball z r1 - {z}" - then have "w \ ball z fr - {z}" "w \ cball z vfr - {z}" unfolding r1_def by auto - from fr_inverse[OF this(1)] fr_nz[OF this(1)] vfr(2)[rule_format,OF this(2)] - show "vf w = vfp w * (w - z) powr of_int vfn \ vfp w \ 0 - \ vf w = inverse (fp w) * (w - z) powr of_int (- fn) \ inverse (fp w) \ 0" by auto - qed - subgoal using vfr(1) unfolding r1_def by (auto intro!:holomorphic_intros) - subgoal using fr unfolding r1_def by (auto intro!:holomorphic_intros) - done - - have "vfp w = inverse (fp w)" when "w\ball z r1-{z}" for w - proof - - have "w \ ball z fr - {z}" "w \ cball z vfr - {z}" "w\z" using that unfolding r1_def by auto - from fr_inverse[OF this(1)] fr_nz[OF this(1)] vfr(2)[rule_format,OF this(2)] \vfn = - fn\ \w\z\ - show ?thesis by auto - qed - then show "\\<^sub>Fw in (at z). vfp w = inverse (fp w)" - unfolding eventually_at using \r1>0\ - apply (rule_tac x=r1 in exI) - by (auto simp add:dist_commute) -qed - -lemma - fixes f g::"complex \ complex" and z::complex - assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" - and f_ness:"not_essential f z" and g_ness:"not_essential g z" - and fg_nconst: "\\<^sub>Fw in (at z). f w * g w\ 0" - shows zorder_times:"zorder (\w. f w * g w) z = zorder f z + zorder g z" and - zor_poly_times:"\\<^sub>Fw in (at z). zor_poly (\w. f w * g w) z w - = zor_poly f z w *zor_poly g z w" -proof - - define fg where "fg = (\w. f w * g w)" - define fn gn fgn where - "fn = zorder f z" and "gn = zorder g z" and "fgn = zorder fg z" - define fp gp fgp where - "fp = zor_poly f z" and "gp = zor_poly g z" and "fgp = zor_poly fg z" - have f_nconst:"\\<^sub>Fw in (at z). f w \ 0" and g_nconst:"\\<^sub>Fw in (at z).g w\ 0" - using fg_nconst by (auto elim!:frequently_elim1) - obtain fr where [simp]:"fp z \ 0" and "fr > 0" - and fr: "fp holomorphic_on cball z fr" - "\w\cball z fr - {z}. f w = fp w * (w - z) powr of_int fn \ fp w \ 0" - using zorder_exist[OF f_iso f_ness f_nconst,folded fp_def fn_def] by auto - obtain gr where [simp]:"gp z \ 0" and "gr > 0" - and gr: "gp holomorphic_on cball z gr" - "\w\cball z gr - {z}. g w = gp w * (w - z) powr of_int gn \ gp w \ 0" - using zorder_exist[OF g_iso g_ness g_nconst,folded gn_def gp_def] by auto - define r1 where "r1=min fr gr" - have "r1>0" unfolding r1_def using \fr>0\ \gr>0\ by auto - have fg_times:"fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" and fgp_nz:"fp w*gp w\0" - when "w\ball z r1 - {z}" for w - proof - - have "f w = fp w * (w - z) powr of_int fn" "fp w\0" - using fr(2)[rule_format,of w] that unfolding r1_def by auto - moreover have "g w = gp w * (w - z) powr of_int gn" "gp w \ 0" - using gr(2)[rule_format, of w] that unfolding r1_def by auto - ultimately show "fg w = (fp w * gp w) * (w - z) powr (of_int (fn+gn))" "fp w*gp w\0" - unfolding fg_def by (auto simp add:powr_add) - qed - - obtain fgr where [simp]:"fgp z \ 0" and "fgr > 0" - and fgr: "fgp holomorphic_on cball z fgr" - "\w\cball z fgr - {z}. fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0" - proof - - have "fgp z \ 0 \ (\r>0. fgp holomorphic_on cball z r - \ (\w\cball z r - {z}. fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0))" - apply (rule zorder_exist[of fg z, folded fgn_def fgp_def]) - subgoal unfolding fg_def using isolated_singularity_at_times[OF f_iso g_iso] . - subgoal unfolding fg_def using not_essential_times[OF f_ness g_ness f_iso g_iso] . - subgoal unfolding fg_def using fg_nconst . - done - then show ?thesis using that by blast - qed - define r2 where "r2 = min fgr r1" - have "r2>0" using \r1>0\ \fgr>0\ unfolding r2_def by simp - show "fgn = fn + gn " - apply (rule holomorphic_factor_unique[of r2 fgp z "\w. fp w * gp w" fg]) - subgoal using \r2>0\ by simp - subgoal by simp - subgoal by simp - subgoal - proof (rule ballI) - fix w assume "w \ ball z r2 - {z}" - then have "w \ ball z r1 - {z}" "w \ cball z fgr - {z}" unfolding r2_def by auto - from fg_times[OF this(1)] fgp_nz[OF this(1)] fgr(2)[rule_format,OF this(2)] - show "fg w = fgp w * (w - z) powr of_int fgn \ fgp w \ 0 - \ fg w = fp w * gp w * (w - z) powr of_int (fn + gn) \ fp w * gp w \ 0" by auto - qed - subgoal using fgr(1) unfolding r2_def r1_def by (auto intro!:holomorphic_intros) - subgoal using fr(1) gr(1) unfolding r2_def r1_def by (auto intro!:holomorphic_intros) - done - - have "fgp w = fp w *gp w" when "w\ball z r2-{z}" for w - proof - - have "w \ ball z r1 - {z}" "w \ cball z fgr - {z}" "w\z" using that unfolding r2_def by auto - from fg_times[OF this(1)] fgp_nz[OF this(1)] fgr(2)[rule_format,OF this(2)] \fgn = fn + gn\ \w\z\ - show ?thesis by auto - qed - then show "\\<^sub>Fw in (at z). fgp w = fp w * gp w" - using \r2>0\ unfolding eventually_at by (auto simp add:dist_commute) -qed - -lemma - fixes f g::"complex \ complex" and z::complex - assumes f_iso:"isolated_singularity_at f z" and g_iso:"isolated_singularity_at g z" - and f_ness:"not_essential f z" and g_ness:"not_essential g z" - and fg_nconst: "\\<^sub>Fw in (at z). f w * g w\ 0" - shows zorder_divide:"zorder (\w. f w / g w) z = zorder f z - zorder g z" and - zor_poly_divide:"\\<^sub>Fw in (at z). zor_poly (\w. f w / g w) z w - = zor_poly f z w / zor_poly g z w" -proof - - have f_nconst:"\\<^sub>Fw in (at z). f w \ 0" and g_nconst:"\\<^sub>Fw in (at z).g w\ 0" - using fg_nconst by (auto elim!:frequently_elim1) - define vg where "vg=(\w. inverse (g w))" - have "zorder (\w. f w * vg w) z = zorder f z + zorder vg z" - apply (rule zorder_times[OF f_iso _ f_ness,of vg]) - subgoal unfolding vg_def using isolated_singularity_at_inverse[OF g_iso g_ness] . - subgoal unfolding vg_def using not_essential_inverse[OF g_ness g_iso] . - subgoal unfolding vg_def using fg_nconst by (auto elim!:frequently_elim1) - done - then show "zorder (\w. f w / g w) z = zorder f z - zorder g z" - using zorder_inverse[OF g_iso g_ness g_nconst,folded vg_def] unfolding vg_def - by (auto simp add:field_simps) - - have "\\<^sub>F w in at z. zor_poly (\w. f w * vg w) z w = zor_poly f z w * zor_poly vg z w" - apply (rule zor_poly_times[OF f_iso _ f_ness,of vg]) - subgoal unfolding vg_def using isolated_singularity_at_inverse[OF g_iso g_ness] . - subgoal unfolding vg_def using not_essential_inverse[OF g_ness g_iso] . - subgoal unfolding vg_def using fg_nconst by (auto elim!:frequently_elim1) - done - then show "\\<^sub>Fw in (at z). zor_poly (\w. f w / g w) z w = zor_poly f z w / zor_poly g z w" - using zor_poly_inverse[OF g_iso g_ness g_nconst,folded vg_def] unfolding vg_def - apply eventually_elim - by (auto simp add:field_simps) -qed - -lemma zorder_exist_zero: - fixes f::"complex \ complex" and z::complex - defines "n\zorder f z" and "g\zor_poly f z" - assumes holo: "f holomorphic_on s" and - "open s" "connected s" "z\s" - and non_const: "\w\s. f w \ 0" - shows "(if f z=0 then n > 0 else n=0) \ (\r. r>0 \ cball z r \ s \ g holomorphic_on cball z r - \ (\w\cball z r. f w = g w * (w-z) ^ nat n \ g w \0))" -proof - - obtain r where "g z \ 0" and r: "r>0" "cball z r \ s" "g holomorphic_on cball z r" - "(\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - proof - - have "g z \ 0 \ (\r>0. g holomorphic_on cball z r - \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0))" - proof (rule zorder_exist[of f z,folded g_def n_def]) - show "isolated_singularity_at f z" unfolding isolated_singularity_at_def - using holo assms(4,6) - by (meson Diff_subset open_ball analytic_on_holomorphic holomorphic_on_subset openE) - show "not_essential f z" unfolding not_essential_def - using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on - by fastforce - have "\\<^sub>F w in at z. f w \ 0 \ w\s" - proof - - obtain w where "w\s" "f w\0" using non_const by auto - then show ?thesis - by (rule non_zero_neighbour_alt[OF holo \open s\ \connected s\ \z\s\]) - qed - then show "\\<^sub>F w in at z. f w \ 0" - apply (elim eventually_frequentlyE) - by auto - qed - then obtain r1 where "g z \ 0" "r1>0" and r1:"g holomorphic_on cball z r1" - "(\w\cball z r1 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - by auto - obtain r2 where r2: "r2>0" "cball z r2 \ s" - using assms(4,6) open_contains_cball_eq by blast - define r3 where "r3=min r1 r2" - have "r3>0" "cball z r3 \ s" using \r1>0\ r2 unfolding r3_def by auto - moreover have "g holomorphic_on cball z r3" - using r1(1) unfolding r3_def by auto - moreover have "(\w\cball z r3 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - using r1(2) unfolding r3_def by auto - ultimately show ?thesis using that[of r3] \g z\0\ by auto - qed - - have if_0:"if f z=0 then n > 0 else n=0" - proof - - have "f\ z \ f z" - by (metis assms(4,6,7) at_within_open continuous_on holo holomorphic_on_imp_continuous_on) - then have "(\w. g w * (w - z) powr of_int n) \z\ f z" - apply (elim Lim_transform_within_open[where s="ball z r"]) - using r by auto - moreover have "g \z\g z" - by (metis (mono_tags, lifting) open_ball at_within_open_subset - ball_subset_cball centre_in_ball continuous_on holomorphic_on_imp_continuous_on r(1,3) subsetCE) - ultimately have "(\w. (g w * (w - z) powr of_int n) / g w) \z\ f z/g z" - apply (rule_tac tendsto_divide) - using \g z\0\ by auto - then have powr_tendsto:"(\w. (w - z) powr of_int n) \z\ f z/g z" - apply (elim Lim_transform_within_open[where s="ball z r"]) - using r by auto - - have ?thesis when "n\0" "f z=0" - proof - - have "(\w. (w - z) ^ nat n) \z\ f z/g z" - using powr_tendsto - apply (elim Lim_transform_within[where d=r]) - by (auto simp add: powr_of_int \n\0\ \r>0\) - then have *:"(\w. (w - z) ^ nat n) \z\ 0" using \f z=0\ by simp - moreover have False when "n=0" - proof - - have "(\w. (w - z) ^ nat n) \z\ 1" - using \n=0\ by auto - then show False using * using LIM_unique zero_neq_one by blast - qed - ultimately show ?thesis using that by fastforce - qed - moreover have ?thesis when "n\0" "f z\0" - proof - - have False when "n>0" - proof - - have "(\w. (w - z) ^ nat n) \z\ f z/g z" - using powr_tendsto - apply (elim Lim_transform_within[where d=r]) - by (auto simp add: powr_of_int \n\0\ \r>0\) - moreover have "(\w. (w - z) ^ nat n) \z\ 0" - using \n>0\ by (auto intro!:tendsto_eq_intros) - ultimately show False using \f z\0\ \g z\0\ using LIM_unique divide_eq_0_iff by blast - qed - then show ?thesis using that by force - qed - moreover have False when "n<0" - proof - - have "(\w. inverse ((w - z) ^ nat (- n))) \z\ f z/g z" - "(\w.((w - z) ^ nat (- n))) \z\ 0" - subgoal using powr_tendsto powr_of_int that - by (elim Lim_transform_within_open[where s=UNIV],auto) - subgoal using that by (auto intro!:tendsto_eq_intros) - done - from tendsto_mult[OF this,simplified] - have "(\x. inverse ((x - z) ^ nat (- n)) * (x - z) ^ nat (- n)) \z\ 0" . - then have "(\x. 1::complex) \z\ 0" - by (elim Lim_transform_within_open[where s=UNIV],auto) - then show False using LIM_const_eq by fastforce - qed - ultimately show ?thesis by fastforce - qed - moreover have "f w = g w * (w-z) ^ nat n \ g w \0" when "w\cball z r" for w - proof (cases "w=z") - case True - then have "f \z\f w" - using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on by fastforce - then have "(\w. g w * (w-z) ^ nat n) \z\f w" - proof (elim Lim_transform_within[OF _ \r>0\]) - fix x assume "0 < dist x z" "dist x z < r" - then have "x \ cball z r - {z}" "x\z" - unfolding cball_def by (auto simp add: dist_commute) - then have "f x = g x * (x - z) powr of_int n" - using r(4)[rule_format,of x] by simp - also have "... = g x * (x - z) ^ nat n" - apply (subst powr_of_int) - using if_0 \x\z\ by (auto split:if_splits) - finally show "f x = g x * (x - z) ^ nat n" . - qed - moreover have "(\w. g w * (w-z) ^ nat n) \z\ g w * (w-z) ^ nat n" - using True apply (auto intro!:tendsto_eq_intros) - by (metis open_ball at_within_open_subset ball_subset_cball centre_in_ball - continuous_on holomorphic_on_imp_continuous_on r(1) r(3) that) - ultimately have "f w = g w * (w-z) ^ nat n" using LIM_unique by blast - then show ?thesis using \g z\0\ True by auto - next - case False - then have "f w = g w * (w - z) powr of_int n \ g w \ 0" - using r(4) that by auto - then show ?thesis using False if_0 powr_of_int by (auto split:if_splits) - qed - ultimately show ?thesis using r by auto -qed - -lemma zorder_exist_pole: - fixes f::"complex \ complex" and z::complex - defines "n\zorder f z" and "g\zor_poly f z" - assumes holo: "f holomorphic_on s-{z}" and - "open s" "z\s" - and "is_pole f z" - shows "n < 0 \ g z\0 \ (\r. r>0 \ cball z r \ s \ g holomorphic_on cball z r - \ (\w\cball z r - {z}. f w = g w / (w-z) ^ nat (- n) \ g w \0))" -proof - - obtain r where "g z \ 0" and r: "r>0" "cball z r \ s" "g holomorphic_on cball z r" - "(\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - proof - - have "g z \ 0 \ (\r>0. g holomorphic_on cball z r - \ (\w\cball z r - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0))" - proof (rule zorder_exist[of f z,folded g_def n_def]) - show "isolated_singularity_at f z" unfolding isolated_singularity_at_def - using holo assms(4,5) - by (metis analytic_on_holomorphic centre_in_ball insert_Diff openE open_delete subset_insert_iff) - show "not_essential f z" unfolding not_essential_def - using assms(4,6) at_within_open continuous_on holo holomorphic_on_imp_continuous_on - by fastforce - from non_zero_neighbour_pole[OF \is_pole f z\] show "\\<^sub>F w in at z. f w \ 0" - apply (elim eventually_frequentlyE) - by auto - qed - then obtain r1 where "g z \ 0" "r1>0" and r1:"g holomorphic_on cball z r1" - "(\w\cball z r1 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - by auto - obtain r2 where r2: "r2>0" "cball z r2 \ s" - using assms(4,5) open_contains_cball_eq by metis - define r3 where "r3=min r1 r2" - have "r3>0" "cball z r3 \ s" using \r1>0\ r2 unfolding r3_def by auto - moreover have "g holomorphic_on cball z r3" - using r1(1) unfolding r3_def by auto - moreover have "(\w\cball z r3 - {z}. f w = g w * (w - z) powr of_int n \ g w \ 0)" - using r1(2) unfolding r3_def by auto - ultimately show ?thesis using that[of r3] \g z\0\ by auto - qed - - have "n<0" - proof (rule ccontr) - assume " \ n < 0" - define c where "c=(if n=0 then g z else 0)" - have [simp]:"g \z\ g z" - by (metis open_ball at_within_open ball_subset_cball centre_in_ball - continuous_on holomorphic_on_imp_continuous_on holomorphic_on_subset r(1) r(3) ) - have "\\<^sub>F x in at z. f x = g x * (x - z) ^ nat n" - unfolding eventually_at_topological - apply (rule_tac exI[where x="ball z r"]) - using r powr_of_int \\ n < 0\ by auto - moreover have "(\x. g x * (x - z) ^ nat n) \z\c" - proof (cases "n=0") - case True - then show ?thesis unfolding c_def by simp - next - case False - then have "(\x. (x - z) ^ nat n) \z\ 0" using \\ n < 0\ - by (auto intro!:tendsto_eq_intros) - from tendsto_mult[OF _ this,of g "g z",simplified] - show ?thesis unfolding c_def using False by simp - qed - ultimately have "f \z\c" using tendsto_cong by fast - then show False using \is_pole f z\ at_neq_bot not_tendsto_and_filterlim_at_infinity - unfolding is_pole_def by blast - qed - moreover have "\w\cball z r - {z}. f w = g w / (w-z) ^ nat (- n) \ g w \0" - using r(4) \n<0\ powr_of_int - by (metis Diff_iff divide_inverse eq_iff_diff_eq_0 insert_iff linorder_not_le) - ultimately show ?thesis using r(1-3) \g z\0\ by auto -qed - -lemma zorder_eqI: - assumes "open s" "z \ s" "g holomorphic_on s" "g z \ 0" - assumes fg_eq:"\w. \w \ s;w\z\ \ f w = g w * (w - z) powr n" - shows "zorder f z = n" -proof - - have "continuous_on s g" by (rule holomorphic_on_imp_continuous_on) fact - moreover have "open (-{0::complex})" by auto - ultimately have "open ((g -` (-{0})) \ s)" - unfolding continuous_on_open_vimage[OF \open s\] by blast - moreover from assms have "z \ (g -` (-{0})) \ s" by auto - ultimately obtain r where r: "r > 0" "cball z r \ s \ (g -` (-{0}))" - unfolding open_contains_cball by blast - - let ?gg= "(\w. g w * (w - z) powr n)" - define P where "P = (\n g r. 0 < r \ g holomorphic_on cball z r \ g z\0 - \ (\w\cball z r - {z}. f w = g w * (w-z) powr (of_int n) \ g w\0))" - have "P n g r" - unfolding P_def using r assms(3,4,5) by auto - then have "\g r. P n g r" by auto - moreover have unique: "\!n. \g r. P n g r" unfolding P_def - proof (rule holomorphic_factor_puncture) - have "ball z r-{z} \ s" using r using ball_subset_cball by blast - then have "?gg holomorphic_on ball z r-{z}" - using \g holomorphic_on s\ r by (auto intro!: holomorphic_intros) - then have "f holomorphic_on ball z r - {z}" - apply (elim holomorphic_transform) - using fg_eq \ball z r-{z} \ s\ by auto - then show "isolated_singularity_at f z" unfolding isolated_singularity_at_def - using analytic_on_open open_delete r(1) by blast - next - have "not_essential ?gg z" - proof (intro singularity_intros) - show "not_essential g z" - by (meson \continuous_on s g\ assms(1) assms(2) continuous_on_eq_continuous_at - isCont_def not_essential_def) - show " \\<^sub>F w in at z. w - z \ 0" by (simp add: eventually_at_filter) - then show "LIM w at z. w - z :> at 0" - unfolding filterlim_at by (auto intro:tendsto_eq_intros) - show "isolated_singularity_at g z" - by (meson Diff_subset open_ball analytic_on_holomorphic - assms(1,2,3) holomorphic_on_subset isolated_singularity_at_def openE) - qed - then show "not_essential f z" - apply (elim not_essential_transform) - unfolding eventually_at using assms(1,2) assms(5)[symmetric] - by (metis dist_commute mem_ball openE subsetCE) - show "\\<^sub>F w in at z. f w \ 0" unfolding frequently_at - proof (rule,rule) - fix d::real assume "0 < d" - define z' where "z'=z+min d r / 2" - have "z' \ z" " dist z' z < d " - unfolding z'_def using \d>0\ \r>0\ - by (auto simp add:dist_norm) - moreover have "f z' \ 0" - proof (subst fg_eq[OF _ \z'\z\]) - have "z' \ cball z r" unfolding z'_def using \r>0\ \d>0\ by (auto simp add:dist_norm) - then show " z' \ s" using r(2) by blast - show "g z' * (z' - z) powr of_int n \ 0" - using P_def \P n g r\ \z' \ cball z r\ calculation(1) by auto - qed - ultimately show "\x\UNIV. x \ z \ dist x z < d \ f x \ 0" by auto - qed - qed - ultimately have "(THE n. \g r. P n g r) = n" - by (rule_tac the1_equality) - then show ?thesis unfolding zorder_def P_def by blast -qed - -lemma residue_pole_order: - fixes f::"complex \ complex" and z::complex - defines "n \ nat (- zorder f z)" and "h \ zor_poly f z" - assumes f_iso:"isolated_singularity_at f z" - and pole:"is_pole f z" - shows "residue f z = ((deriv ^^ (n - 1)) h z / fact (n-1))" -proof - - define g where "g \ \x. if x=z then 0 else inverse (f x)" - obtain e where [simp]:"e>0" and f_holo:"f holomorphic_on ball z e - {z}" - using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by blast - obtain r where "0 < n" "0 < r" and r_cball:"cball z r \ ball z e" and h_holo: "h holomorphic_on cball z r" - and h_divide:"(\w\cball z r. (w\z \ f w = h w / (w - z) ^ n) \ h w \ 0)" - proof - - obtain r where r:"zorder f z < 0" "h z \ 0" "r>0" "cball z r \ ball z e" "h holomorphic_on cball z r" - "(\w\cball z r - {z}. f w = h w / (w - z) ^ n \ h w \ 0)" - using zorder_exist_pole[OF f_holo,simplified,OF \is_pole f z\,folded n_def h_def] by auto - have "n>0" using \zorder f z < 0\ unfolding n_def by simp - moreover have "(\w\cball z r. (w\z \ f w = h w / (w - z) ^ n) \ h w \ 0)" - using \h z\0\ r(6) by blast - ultimately show ?thesis using r(3,4,5) that by blast - qed - have r_nonzero:"\w. w \ ball z r - {z} \ f w \ 0" - using h_divide by simp - define c where "c \ 2 * pi * \" - define der_f where "der_f \ ((deriv ^^ (n - 1)) h z / fact (n-1))" - define h' where "h' \ \u. h u / (u - z) ^ n" - have "(h' has_contour_integral c / fact (n - 1) * (deriv ^^ (n - 1)) h z) (circlepath z r)" - unfolding h'_def - proof (rule Cauchy_has_contour_integral_higher_derivative_circlepath[of z r h z "n-1", - folded c_def Suc_pred'[OF \n>0\]]) - show "continuous_on (cball z r) h" using holomorphic_on_imp_continuous_on h_holo by simp - show "h holomorphic_on ball z r" using h_holo by auto - show " z \ ball z r" using \r>0\ by auto - qed - then have "(h' has_contour_integral c * der_f) (circlepath z r)" unfolding der_f_def by auto - then have "(f has_contour_integral c * der_f) (circlepath z r)" - proof (elim has_contour_integral_eq) - fix x assume "x \ path_image (circlepath z r)" - hence "x\cball z r - {z}" using \r>0\ by auto - then show "h' x = f x" using h_divide unfolding h'_def by auto - qed - moreover have "(f has_contour_integral c * residue f z) (circlepath z r)" - using base_residue[of \ball z e\ z,simplified,OF \r>0\ f_holo r_cball,folded c_def] - unfolding c_def by simp - ultimately have "c * der_f = c * residue f z" using has_contour_integral_unique by blast - hence "der_f = residue f z" unfolding c_def by auto - thus ?thesis unfolding der_f_def by auto -qed - -lemma simple_zeroI: - assumes "open s" "z \ s" "g holomorphic_on s" "g z \ 0" - assumes "\w. w \ s \ f w = g w * (w - z)" - shows "zorder f z = 1" - using assms(1-4) by (rule zorder_eqI) (use assms(5) in auto) - -lemma higher_deriv_power: - shows "(deriv ^^ j) (\w. (w - z) ^ n) w = - pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j)" -proof (induction j arbitrary: w) - case 0 - thus ?case by auto -next - case (Suc j w) - have "(deriv ^^ Suc j) (\w. (w - z) ^ n) w = deriv ((deriv ^^ j) (\w. (w - z) ^ n)) w" - by simp - also have "(deriv ^^ j) (\w. (w - z) ^ n) = - (\w. pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j))" - using Suc by (intro Suc.IH ext) - also { - have "(\ has_field_derivative of_nat (n - j) * - pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - Suc j)) (at w)" - using Suc.prems by (auto intro!: derivative_eq_intros) - also have "of_nat (n - j) * pochhammer (of_nat (Suc n - j)) j = - pochhammer (of_nat (Suc n - Suc j)) (Suc j)" - by (cases "Suc j \ n", subst pochhammer_rec) - (insert Suc.prems, simp_all add: algebra_simps Suc_diff_le pochhammer_0_left) - finally have "deriv (\w. pochhammer (of_nat (Suc n - j)) j * (w - z) ^ (n - j)) w = - \ * (w - z) ^ (n - Suc j)" - by (rule DERIV_imp_deriv) - } - finally show ?case . -qed - -lemma zorder_zero_eqI: - assumes f_holo:"f holomorphic_on s" and "open s" "z \ s" - assumes zero: "\i. i < nat n \ (deriv ^^ i) f z = 0" - assumes nz: "(deriv ^^ nat n) f z \ 0" and "n\0" - shows "zorder f z = n" -proof - - obtain r where [simp]:"r>0" and "ball z r \ s" - using \open s\ \z\s\ openE by blast - have nz':"\w\ball z r. f w \ 0" - proof (rule ccontr) - assume "\ (\w\ball z r. f w \ 0)" - then have "eventually (\u. f u = 0) (nhds z)" - using \r>0\ unfolding eventually_nhds - apply (rule_tac x="ball z r" in exI) - by auto - then have "(deriv ^^ nat n) f z = (deriv ^^ nat n) (\_. 0) z" - by (intro higher_deriv_cong_ev) auto - also have "(deriv ^^ nat n) (\_. 0) z = 0" - by (induction n) simp_all - finally show False using nz by contradiction - qed - - define zn g where "zn = zorder f z" and "g = zor_poly f z" - obtain e where e_if:"if f z = 0 then 0 < zn else zn = 0" and - [simp]:"e>0" and "cball z e \ ball z r" and - g_holo:"g holomorphic_on cball z e" and - e_fac:"(\w\cball z e. f w = g w * (w - z) ^ nat zn \ g w \ 0)" - proof - - have "f holomorphic_on ball z r" - using f_holo \ball z r \ s\ by auto - from that zorder_exist_zero[of f "ball z r" z,simplified,OF this nz',folded zn_def g_def] - show ?thesis by blast - qed - from this(1,2,5) have "zn\0" "g z\0" - subgoal by (auto split:if_splits) - subgoal using \0 < e\ ball_subset_cball centre_in_ball e_fac by blast - done - - define A where "A = (\i. of_nat (i choose (nat zn)) * fact (nat zn) * (deriv ^^ (i - nat zn)) g z)" - have deriv_A:"(deriv ^^ i) f z = (if zn \ int i then A i else 0)" for i - proof - - have "eventually (\w. w \ ball z e) (nhds z)" - using \cball z e \ ball z r\ \e>0\ by (intro eventually_nhds_in_open) auto - hence "eventually (\w. f w = (w - z) ^ (nat zn) * g w) (nhds z)" - apply eventually_elim - by (use e_fac in auto) - hence "(deriv ^^ i) f z = (deriv ^^ i) (\w. (w - z) ^ nat zn * g w) z" - by (intro higher_deriv_cong_ev) auto - also have "\ = (\j=0..i. of_nat (i choose j) * - (deriv ^^ j) (\w. (w - z) ^ nat zn) z * (deriv ^^ (i - j)) g z)" - using g_holo \e>0\ - by (intro higher_deriv_mult[of _ "ball z e"]) (auto intro!: holomorphic_intros) - also have "\ = (\j=0..i. if j = nat zn then - of_nat (i choose nat zn) * fact (nat zn) * (deriv ^^ (i - nat zn)) g z else 0)" - proof (intro sum.cong refl, goal_cases) - case (1 j) - have "(deriv ^^ j) (\w. (w - z) ^ nat zn) z = - pochhammer (of_nat (Suc (nat zn) - j)) j * 0 ^ (nat zn - j)" - by (subst higher_deriv_power) auto - also have "\ = (if j = nat zn then fact j else 0)" - by (auto simp: not_less pochhammer_0_left pochhammer_fact) - also have "of_nat (i choose j) * \ * (deriv ^^ (i - j)) g z = - (if j = nat zn then of_nat (i choose (nat zn)) * fact (nat zn) - * (deriv ^^ (i - nat zn)) g z else 0)" - by simp - finally show ?case . - qed - also have "\ = (if i \ zn then A i else 0)" - by (auto simp: A_def) - finally show "(deriv ^^ i) f z = \" . - qed - - have False when "nn\0\ by auto - with nz show False by auto - qed - moreover have "n\zn" - proof - - have "g z \ 0" using e_fac[rule_format,of z] \e>0\ by simp - then have "(deriv ^^ nat zn) f z \ 0" - using deriv_A[of "nat zn"] by(auto simp add:A_def) - then have "nat zn \ nat n" using zero[of "nat zn"] by linarith - moreover have "zn\0" using e_if by (auto split:if_splits) - ultimately show ?thesis using nat_le_eq_zle by blast - qed - ultimately show ?thesis unfolding zn_def by fastforce -qed - -lemma - assumes "eventually (\z. f z = g z) (at z)" "z = z'" - shows zorder_cong:"zorder f z = zorder g z'" and zor_poly_cong:"zor_poly f z = zor_poly g z'" -proof - - define P where "P = (\ff n h r. 0 < r \ h holomorphic_on cball z r \ h z\0 - \ (\w\cball z r - {z}. ff w = h w * (w-z) powr (of_int n) \ h w\0))" - have "(\r. P f n h r) = (\r. P g n h r)" for n h - proof - - have *: "\r. P g n h r" if "\r. P f n h r" and "eventually (\x. f x = g x) (at z)" for f g - proof - - from that(1) obtain r1 where r1_P:"P f n h r1" by auto - from that(2) obtain r2 where "r2>0" and r2_dist:"\x. x \ z \ dist x z \ r2 \ f x = g x" - unfolding eventually_at_le by auto - define r where "r=min r1 r2" - have "r>0" "h z\0" using r1_P \r2>0\ unfolding r_def P_def by auto - moreover have "h holomorphic_on cball z r" - using r1_P unfolding P_def r_def by auto - moreover have "g w = h w * (w - z) powr of_int n \ h w \ 0" when "w\cball z r - {z}" for w - proof - - have "f w = h w * (w - z) powr of_int n \ h w \ 0" - using r1_P that unfolding P_def r_def by auto - moreover have "f w=g w" using r2_dist[rule_format,of w] that unfolding r_def - by (simp add: dist_commute) - ultimately show ?thesis by simp - qed - ultimately show ?thesis unfolding P_def by auto - qed - from assms have eq': "eventually (\z. g z = f z) (at z)" - by (simp add: eq_commute) - show ?thesis - by (rule iffI[OF *[OF _ assms(1)] *[OF _ eq']]) - qed - then show "zorder f z = zorder g z'" "zor_poly f z = zor_poly g z'" - using \z=z'\ unfolding P_def zorder_def zor_poly_def by auto -qed - -lemma zorder_nonzero_div_power: - assumes "open s" "z \ s" "f holomorphic_on s" "f z \ 0" "n > 0" - shows "zorder (\w. f w / (w - z) ^ n) z = - n" - apply (rule zorder_eqI[OF \open s\ \z\s\ \f holomorphic_on s\ \f z\0\]) - apply (subst powr_of_int) - using \n>0\ by (auto simp add:field_simps) - -lemma zor_poly_eq: - assumes "isolated_singularity_at f z" "not_essential f z" "\\<^sub>F w in at z. f w \ 0" - shows "eventually (\w. zor_poly f z w = f w * (w - z) powr - zorder f z) (at z)" -proof - - obtain r where r:"r>0" - "(\w\cball z r - {z}. f w = zor_poly f z w * (w - z) powr of_int (zorder f z))" - using zorder_exist[OF assms] by blast - then have *: "\w\ball z r - {z}. zor_poly f z w = f w * (w - z) powr - zorder f z" - by (auto simp: field_simps powr_minus) - have "eventually (\w. w \ ball z r - {z}) (at z)" - using r eventually_at_ball'[of r z UNIV] by auto - thus ?thesis by eventually_elim (insert *, auto) -qed - -lemma zor_poly_zero_eq: - assumes "f holomorphic_on s" "open s" "connected s" "z \ s" "\w\s. f w \ 0" - shows "eventually (\w. zor_poly f z w = f w / (w - z) ^ nat (zorder f z)) (at z)" -proof - - obtain r where r:"r>0" - "(\w\cball z r - {z}. f w = zor_poly f z w * (w - z) ^ nat (zorder f z))" - using zorder_exist_zero[OF assms] by auto - then have *: "\w\ball z r - {z}. zor_poly f z w = f w / (w - z) ^ nat (zorder f z)" - by (auto simp: field_simps powr_minus) - have "eventually (\w. w \ ball z r - {z}) (at z)" - using r eventually_at_ball'[of r z UNIV] by auto - thus ?thesis by eventually_elim (insert *, auto) -qed - -lemma zor_poly_pole_eq: - assumes f_iso:"isolated_singularity_at f z" "is_pole f z" - shows "eventually (\w. zor_poly f z w = f w * (w - z) ^ nat (- zorder f z)) (at z)" -proof - - obtain e where [simp]:"e>0" and f_holo:"f holomorphic_on ball z e - {z}" - using f_iso analytic_imp_holomorphic unfolding isolated_singularity_at_def by blast - obtain r where r:"r>0" - "(\w\cball z r - {z}. f w = zor_poly f z w / (w - z) ^ nat (- zorder f z))" - using zorder_exist_pole[OF f_holo,simplified,OF \is_pole f z\] by auto - then have *: "\w\ball z r - {z}. zor_poly f z w = f w * (w - z) ^ nat (- zorder f z)" - by (auto simp: field_simps) - have "eventually (\w. w \ ball z r - {z}) (at z)" - using r eventually_at_ball'[of r z UNIV] by auto - thus ?thesis by eventually_elim (insert *, auto) -qed - -lemma zor_poly_eqI: - fixes f :: "complex \ complex" and z0 :: complex - defines "n \ zorder f z0" - assumes "isolated_singularity_at f z0" "not_essential f z0" "\\<^sub>F w in at z0. f w \ 0" - assumes lim: "((\x. f (g x) * (g x - z0) powr - n) \ c) F" - assumes g: "filterlim g (at z0) F" and "F \ bot" - shows "zor_poly f z0 z0 = c" -proof - - from zorder_exist[OF assms(2-4)] obtain r where - r: "r > 0" "zor_poly f z0 holomorphic_on cball z0 r" - "\w. w \ cball z0 r - {z0} \ f w = zor_poly f z0 w * (w - z0) powr n" - unfolding n_def by blast - from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" - using eventually_at_ball'[of r z0 UNIV] by auto - hence "eventually (\w. zor_poly f z0 w = f w * (w - z0) powr - n) (at z0)" - by eventually_elim (insert r, auto simp: field_simps powr_minus) - moreover have "continuous_on (ball z0 r) (zor_poly f z0)" - using r by (intro holomorphic_on_imp_continuous_on) auto - with r(1,2) have "isCont (zor_poly f z0) z0" - by (auto simp: continuous_on_eq_continuous_at) - hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" - unfolding isCont_def . - ultimately have "((\w. f w * (w - z0) powr - n) \ zor_poly f z0 z0) (at z0)" - by (blast intro: Lim_transform_eventually) - hence "((\x. f (g x) * (g x - z0) powr - n) \ zor_poly f z0 z0) F" - by (rule filterlim_compose[OF _ g]) - from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . -qed - -lemma zor_poly_zero_eqI: - fixes f :: "complex \ complex" and z0 :: complex - defines "n \ zorder f z0" - assumes "f holomorphic_on A" "open A" "connected A" "z0 \ A" "\z\A. f z \ 0" - assumes lim: "((\x. f (g x) / (g x - z0) ^ nat n) \ c) F" - assumes g: "filterlim g (at z0) F" and "F \ bot" - shows "zor_poly f z0 z0 = c" -proof - - from zorder_exist_zero[OF assms(2-6)] obtain r where - r: "r > 0" "cball z0 r \ A" "zor_poly f z0 holomorphic_on cball z0 r" - "\w. w \ cball z0 r \ f w = zor_poly f z0 w * (w - z0) ^ nat n" - unfolding n_def by blast - from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" - using eventually_at_ball'[of r z0 UNIV] by auto - hence "eventually (\w. zor_poly f z0 w = f w / (w - z0) ^ nat n) (at z0)" - by eventually_elim (insert r, auto simp: field_simps) - moreover have "continuous_on (ball z0 r) (zor_poly f z0)" - using r by (intro holomorphic_on_imp_continuous_on) auto - with r(1,2) have "isCont (zor_poly f z0) z0" - by (auto simp: continuous_on_eq_continuous_at) - hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" - unfolding isCont_def . - ultimately have "((\w. f w / (w - z0) ^ nat n) \ zor_poly f z0 z0) (at z0)" - by (blast intro: Lim_transform_eventually) - hence "((\x. f (g x) / (g x - z0) ^ nat n) \ zor_poly f z0 z0) F" - by (rule filterlim_compose[OF _ g]) - from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . -qed - -lemma zor_poly_pole_eqI: - fixes f :: "complex \ complex" and z0 :: complex - defines "n \ zorder f z0" - assumes f_iso:"isolated_singularity_at f z0" and "is_pole f z0" - assumes lim: "((\x. f (g x) * (g x - z0) ^ nat (-n)) \ c) F" - assumes g: "filterlim g (at z0) F" and "F \ bot" - shows "zor_poly f z0 z0 = c" -proof - - obtain r where r: "r > 0" "zor_poly f z0 holomorphic_on cball z0 r" - proof - - have "\\<^sub>F w in at z0. f w \ 0" - using non_zero_neighbour_pole[OF \is_pole f z0\] by (auto elim:eventually_frequentlyE) - moreover have "not_essential f z0" unfolding not_essential_def using \is_pole f z0\ by simp - ultimately show ?thesis using that zorder_exist[OF f_iso,folded n_def] by auto - qed - from r(1) have "eventually (\w. w \ ball z0 r \ w \ z0) (at z0)" - using eventually_at_ball'[of r z0 UNIV] by auto - have "eventually (\w. zor_poly f z0 w = f w * (w - z0) ^ nat (-n)) (at z0)" - using zor_poly_pole_eq[OF f_iso \is_pole f z0\] unfolding n_def . - moreover have "continuous_on (ball z0 r) (zor_poly f z0)" - using r by (intro holomorphic_on_imp_continuous_on) auto - with r(1,2) have "isCont (zor_poly f z0) z0" - by (auto simp: continuous_on_eq_continuous_at) - hence "(zor_poly f z0 \ zor_poly f z0 z0) (at z0)" - unfolding isCont_def . - ultimately have "((\w. f w * (w - z0) ^ nat (-n)) \ zor_poly f z0 z0) (at z0)" - by (blast intro: Lim_transform_eventually) - hence "((\x. f (g x) * (g x - z0) ^ nat (-n)) \ zor_poly f z0 z0) F" - by (rule filterlim_compose[OF _ g]) - from tendsto_unique[OF \F \ bot\ this lim] show ?thesis . -qed - -lemma residue_simple_pole: - assumes "isolated_singularity_at f z0" - assumes "is_pole f z0" "zorder f z0 = - 1" - shows "residue f z0 = zor_poly f z0 z0" - using assms by (subst residue_pole_order) simp_all - -lemma residue_simple_pole_limit: - assumes "isolated_singularity_at f z0" - assumes "is_pole f z0" "zorder f z0 = - 1" - assumes "((\x. f (g x) * (g x - z0)) \ c) F" - assumes "filterlim g (at z0) F" "F \ bot" - shows "residue f z0 = c" -proof - - have "residue f z0 = zor_poly f z0 z0" - by (rule residue_simple_pole assms)+ - also have "\ = c" - apply (rule zor_poly_pole_eqI) - using assms by auto - finally show ?thesis . -qed - -lemma lhopital_complex_simple: - assumes "(f has_field_derivative f') (at z)" - assumes "(g has_field_derivative g') (at z)" - assumes "f z = 0" "g z = 0" "g' \ 0" "f' / g' = c" - shows "((\w. f w / g w) \ c) (at z)" -proof - - have "eventually (\w. w \ z) (at z)" - by (auto simp: eventually_at_filter) - hence "eventually (\w. ((f w - f z) / (w - z)) / ((g w - g z) / (w - z)) = f w / g w) (at z)" - by eventually_elim (simp add: assms field_split_simps) - moreover have "((\w. ((f w - f z) / (w - z)) / ((g w - g z) / (w - z))) \ f' / g') (at z)" - by (intro tendsto_divide has_field_derivativeD assms) - ultimately have "((\w. f w / g w) \ f' / g') (at z)" - by (blast intro: Lim_transform_eventually) - with assms show ?thesis by simp -qed - -lemma - assumes f_holo:"f holomorphic_on s" and g_holo:"g holomorphic_on s" - and "open s" "connected s" "z \ s" - assumes g_deriv:"(g has_field_derivative g') (at z)" - assumes "f z \ 0" "g z = 0" "g' \ 0" - shows porder_simple_pole_deriv: "zorder (\w. f w / g w) z = - 1" - and residue_simple_pole_deriv: "residue (\w. f w / g w) z = f z / g'" -proof - - have [simp]:"isolated_singularity_at f z" "isolated_singularity_at g z" - using isolated_singularity_at_holomorphic[OF _ \open s\ \z\s\] f_holo g_holo - by (meson Diff_subset holomorphic_on_subset)+ - have [simp]:"not_essential f z" "not_essential g z" - unfolding not_essential_def using f_holo g_holo assms(3,5) - by (meson continuous_on_eq_continuous_at continuous_within holomorphic_on_imp_continuous_on)+ - have g_nconst:"\\<^sub>F w in at z. g w \0 " - proof (rule ccontr) - assume "\ (\\<^sub>F w in at z. g w \ 0)" - then have "\\<^sub>F w in nhds z. g w = 0" - unfolding eventually_at eventually_nhds frequently_at using \g z = 0\ - by (metis open_ball UNIV_I centre_in_ball dist_commute mem_ball) - then have "deriv g z = deriv (\_. 0) z" - by (intro deriv_cong_ev) auto - then have "deriv g z = 0" by auto - then have "g' = 0" using g_deriv DERIV_imp_deriv by blast - then show False using \g'\0\ by auto - qed - - have "zorder (\w. f w / g w) z = zorder f z - zorder g z" - proof - - have "\\<^sub>F w in at z. f w \0 \ w\s" - apply (rule non_zero_neighbour_alt) - using assms by auto - with g_nconst have "\\<^sub>F w in at z. f w * g w \ 0" - by (elim frequently_rev_mp eventually_rev_mp,auto) - then show ?thesis using zorder_divide[of f z g] by auto - qed - moreover have "zorder f z=0" - apply (rule zorder_zero_eqI[OF f_holo \open s\ \z\s\]) - using \f z\0\ by auto - moreover have "zorder g z=1" - apply (rule zorder_zero_eqI[OF g_holo \open s\ \z\s\]) - subgoal using assms(8) by auto - subgoal using DERIV_imp_deriv assms(9) g_deriv by auto - subgoal by simp - done - ultimately show "zorder (\w. f w / g w) z = - 1" by auto - - show "residue (\w. f w / g w) z = f z / g'" - proof (rule residue_simple_pole_limit[where g=id and F="at z",simplified]) - show "zorder (\w. f w / g w) z = - 1" by fact - show "isolated_singularity_at (\w. f w / g w) z" - by (auto intro: singularity_intros) - show "is_pole (\w. f w / g w) z" - proof (rule is_pole_divide) - have "\\<^sub>F x in at z. g x \ 0" - apply (rule non_zero_neighbour) - using g_nconst by auto - moreover have "g \z\ 0" - using DERIV_isCont assms(8) continuous_at g_deriv by force - ultimately show "filterlim g (at 0) (at z)" unfolding filterlim_at by simp - show "isCont f z" - using assms(3,5) continuous_on_eq_continuous_at f_holo holomorphic_on_imp_continuous_on - by auto - show "f z \ 0" by fact - qed - show "filterlim id (at z) (at z)" by (simp add: filterlim_iff) - have "((\w. (f w * (w - z)) / g w) \ f z / g') (at z)" - proof (rule lhopital_complex_simple) - show "((\w. f w * (w - z)) has_field_derivative f z) (at z)" - using assms by (auto intro!: derivative_eq_intros holomorphic_derivI[OF f_holo]) - show "(g has_field_derivative g') (at z)" by fact - qed (insert assms, auto) - then show "((\w. (f w / g w) * (w - z)) \ f z / g') (at z)" - by (simp add: field_split_simps) - qed -qed - -subsection \The argument principle\ - -theorem argument_principle: - fixes f::"complex \ complex" and poles s:: "complex set" - defines "pz \ {w. f w = 0 \ w \ poles}" \ \\<^term>\pz\ is the set of poles and zeros\ - assumes "open s" and - "connected s" and - f_holo:"f holomorphic_on s-poles" and - h_holo:"h holomorphic_on s" and - "valid_path g" and - loop:"pathfinish g = pathstart g" and - path_img:"path_image g \ s - pz" and - homo:"\z. (z \ s) \ winding_number g z = 0" and - finite:"finite pz" and - poles:"\p\poles. is_pole f p" - shows "contour_integral g (\x. deriv f x * h x / f x) = 2 * pi * \ * - (\p\pz. winding_number g p * h p * zorder f p)" - (is "?L=?R") -proof - - define c where "c \ 2 * complex_of_real pi * \ " - define ff where "ff \ (\x. deriv f x * h x / f x)" - define cont where "cont \ \ff p e. (ff has_contour_integral c * zorder f p * h p ) (circlepath p e)" - define avoid where "avoid \ \p e. \w\cball p e. w \ s \ (w \ p \ w \ pz)" - - have "\e>0. avoid p e \ (p\pz \ cont ff p e)" when "p\s" for p - proof - - obtain e1 where "e1>0" and e1_avoid:"avoid p e1" - using finite_cball_avoid[OF \open s\ finite] \p\s\ unfolding avoid_def by auto - have "\e2>0. cball p e2 \ ball p e1 \ cont ff p e2" when "p\pz" - proof - - define po where "po \ zorder f p" - define pp where "pp \ zor_poly f p" - define f' where "f' \ \w. pp w * (w - p) powr po" - define ff' where "ff' \ (\x. deriv f' x * h x / f' x)" - obtain r where "pp p\0" "r>0" and - "rw\cball p r-{p}. f w = pp w * (w - p) powr po \ pp w \ 0)" - proof - - have "isolated_singularity_at f p" - proof - - have "f holomorphic_on ball p e1 - {p}" - apply (intro holomorphic_on_subset[OF f_holo]) - using e1_avoid \p\pz\ unfolding avoid_def pz_def by force - then show ?thesis unfolding isolated_singularity_at_def - using \e1>0\ analytic_on_open open_delete by blast - qed - moreover have "not_essential f p" - proof (cases "is_pole f p") - case True - then show ?thesis unfolding not_essential_def by auto - next - case False - then have "p\s-poles" using \p\s\ poles unfolding pz_def by auto - moreover have "open (s-poles)" - using \open s\ - apply (elim open_Diff) - apply (rule finite_imp_closed) - using finite unfolding pz_def by simp - ultimately have "isCont f p" - using holomorphic_on_imp_continuous_on[OF f_holo] continuous_on_eq_continuous_at - by auto - then show ?thesis unfolding isCont_def not_essential_def by auto - qed - moreover have "\\<^sub>F w in at p. f w \ 0 " - proof (rule ccontr) - assume "\ (\\<^sub>F w in at p. f w \ 0)" - then have "\\<^sub>F w in at p. f w= 0" unfolding frequently_def by auto - then obtain rr where "rr>0" "\w\ball p rr - {p}. f w =0" - unfolding eventually_at by (auto simp add:dist_commute) - then have "ball p rr - {p} \ {w\ball p rr-{p}. f w=0}" by blast - moreover have "infinite (ball p rr - {p})" using \rr>0\ using finite_imp_not_open by fastforce - ultimately have "infinite {w\ball p rr-{p}. f w=0}" using infinite_super by blast - then have "infinite pz" - unfolding pz_def infinite_super by auto - then show False using \finite pz\ by auto - qed - ultimately obtain r where "pp p \ 0" and r:"r>0" "pp holomorphic_on cball p r" - "(\w\cball p r - {p}. f w = pp w * (w - p) powr of_int po \ pp w \ 0)" - using zorder_exist[of f p,folded po_def pp_def] by auto - define r1 where "r1=min r e1 / 2" - have "r1e1>0\ \r>0\ by auto - moreover have "r1>0" "pp holomorphic_on cball p r1" - "(\w\cball p r1 - {p}. f w = pp w * (w - p) powr of_int po \ pp w \ 0)" - unfolding r1_def using \e1>0\ r by auto - ultimately show ?thesis using that \pp p\0\ by auto - qed - - define e2 where "e2 \ r/2" - have "e2>0" using \r>0\ unfolding e2_def by auto - define anal where "anal \ \w. deriv pp w * h w / pp w" - define prin where "prin \ \w. po * h w / (w - p)" - have "((\w. prin w + anal w) has_contour_integral c * po * h p) (circlepath p e2)" - proof (rule has_contour_integral_add[of _ _ _ _ 0,simplified]) - have "ball p r \ s" - using \r avoid_def ball_subset_cball e1_avoid by (simp add: subset_eq) - then have "cball p e2 \ s" - using \r>0\ unfolding e2_def by auto - then have "(\w. po * h w) holomorphic_on cball p e2" - using h_holo by (auto intro!: holomorphic_intros) - then show "(prin has_contour_integral c * po * h p ) (circlepath p e2)" - using Cauchy_integral_circlepath_simple[folded c_def, of "\w. po * h w"] \e2>0\ - unfolding prin_def by (auto simp add: mult.assoc) - have "anal holomorphic_on ball p r" unfolding anal_def - using pp_holo h_holo pp_po \ball p r \ s\ \pp p\0\ - by (auto intro!: holomorphic_intros) - then show "(anal has_contour_integral 0) (circlepath p e2)" - using e2_def \r>0\ - by (auto elim!: Cauchy_theorem_disc_simple) - qed - then have "cont ff' p e2" unfolding cont_def po_def - proof (elim has_contour_integral_eq) - fix w assume "w \ path_image (circlepath p e2)" - then have "w\ball p r" and "w\p" unfolding e2_def using \r>0\ by auto - define wp where "wp \ w-p" - have "wp\0" and "pp w \0" - unfolding wp_def using \w\p\ \w\ball p r\ pp_po by auto - moreover have der_f':"deriv f' w = po * pp w * (w-p) powr (po - 1) + deriv pp w * (w-p) powr po" - proof (rule DERIV_imp_deriv) - have "(pp has_field_derivative (deriv pp w)) (at w)" - using DERIV_deriv_iff_has_field_derivative pp_holo \w\p\ - by (meson open_ball \w \ ball p r\ ball_subset_cball holomorphic_derivI holomorphic_on_subset) - then show " (f' has_field_derivative of_int po * pp w * (w - p) powr of_int (po - 1) - + deriv pp w * (w - p) powr of_int po) (at w)" - unfolding f'_def using \w\p\ - by (auto intro!: derivative_eq_intros DERIV_cong[OF has_field_derivative_powr_of_int]) - qed - ultimately show "prin w + anal w = ff' w" - unfolding ff'_def prin_def anal_def - apply simp - apply (unfold f'_def) - apply (fold wp_def) - apply (auto simp add:field_simps) - by (metis (no_types, lifting) diff_add_cancel mult.commute powr_add powr_to_1) - qed - then have "cont ff p e2" unfolding cont_def - proof (elim has_contour_integral_eq) - fix w assume "w \ path_image (circlepath p e2)" - then have "w\ball p r" and "w\p" unfolding e2_def using \r>0\ by auto - have "deriv f' w = deriv f w" - proof (rule complex_derivative_transform_within_open[where s="ball p r - {p}"]) - show "f' holomorphic_on ball p r - {p}" unfolding f'_def using pp_holo - by (auto intro!: holomorphic_intros) - next - have "ball p e1 - {p} \ s - poles" - using ball_subset_cball e1_avoid[unfolded avoid_def] unfolding pz_def - by auto - then have "ball p r - {p} \ s - poles" - apply (elim dual_order.trans) - using \r by auto - then show "f holomorphic_on ball p r - {p}" using f_holo - by auto - next - show "open (ball p r - {p})" by auto - show "w \ ball p r - {p}" using \w\ball p r\ \w\p\ by auto - next - fix x assume "x \ ball p r - {p}" - then show "f' x = f x" - using pp_po unfolding f'_def by auto - qed - moreover have " f' w = f w " - using \w \ ball p r\ ball_subset_cball subset_iff pp_po \w\p\ - unfolding f'_def by auto - ultimately show "ff' w = ff w" - unfolding ff'_def ff_def by simp - qed - moreover have "cball p e2 \ ball p e1" - using \0 < r\ \r e2_def by auto - ultimately show ?thesis using \e2>0\ by auto - qed - then obtain e2 where e2:"p\pz \ e2>0 \ cball p e2 \ ball p e1 \ cont ff p e2" - by auto - define e4 where "e4 \ if p\pz then e2 else e1" - have "e4>0" using e2 \e1>0\ unfolding e4_def by auto - moreover have "avoid p e4" using e2 \e1>0\ e1_avoid unfolding e4_def avoid_def by auto - moreover have "p\pz \ cont ff p e4" - by (auto simp add: e2 e4_def) - ultimately show ?thesis by auto - qed - then obtain get_e where get_e:"\p\s. get_e p>0 \ avoid p (get_e p) - \ (p\pz \ cont ff p (get_e p))" - by metis - define ci where "ci \ \p. contour_integral (circlepath p (get_e p)) ff" - define w where "w \ \p. winding_number g p" - have "contour_integral g ff = (\p\pz. w p * ci p)" unfolding ci_def w_def - proof (rule Cauchy_theorem_singularities[OF \open s\ \connected s\ finite _ \valid_path g\ loop - path_img homo]) - have "open (s - pz)" using open_Diff[OF _ finite_imp_closed[OF finite]] \open s\ by auto - then show "ff holomorphic_on s - pz" unfolding ff_def using f_holo h_holo - by (auto intro!: holomorphic_intros simp add:pz_def) - next - show "\p\s. 0 < get_e p \ (\w\cball p (get_e p). w \ s \ (w \ p \ w \ pz))" - using get_e using avoid_def by blast - qed - also have "... = (\p\pz. c * w p * h p * zorder f p)" - proof (rule sum.cong[of pz pz,simplified]) - fix p assume "p \ pz" - show "w p * ci p = c * w p * h p * (zorder f p)" - proof (cases "p\s") - assume "p \ s" - have "ci p = c * h p * (zorder f p)" unfolding ci_def - apply (rule contour_integral_unique) - using get_e \p\s\ \p\pz\ unfolding cont_def by (metis mult.assoc mult.commute) - thus ?thesis by auto - next - assume "p\s" - then have "w p=0" using homo unfolding w_def by auto - then show ?thesis by auto - qed - qed - also have "... = c*(\p\pz. w p * h p * zorder f p)" - unfolding sum_distrib_left by (simp add:algebra_simps) - finally have "contour_integral g ff = c * (\p\pz. w p * h p * of_int (zorder f p))" . - then show ?thesis unfolding ff_def c_def w_def by simp -qed - -subsection \Rouche's theorem \ - -theorem Rouche_theorem: - fixes f g::"complex \ complex" and s:: "complex set" - defines "fg\(\p. f p + g p)" - defines "zeros_fg\{p. fg p = 0}" and "zeros_f\{p. f p = 0}" - assumes - "open s" and "connected s" and - "finite zeros_fg" and - "finite zeros_f" and - f_holo:"f holomorphic_on s" and - g_holo:"g holomorphic_on s" and - "valid_path \" and - loop:"pathfinish \ = pathstart \" and - path_img:"path_image \ \ s " and - path_less:"\z\path_image \. cmod(f z) > cmod(g z)" and - homo:"\z. (z \ s) \ winding_number \ z = 0" - shows "(\p\zeros_fg. winding_number \ p * zorder fg p) - = (\p\zeros_f. winding_number \ p * zorder f p)" -proof - - have path_fg:"path_image \ \ s - zeros_fg" - proof - - have False when "z\path_image \" and "f z + g z=0" for z - proof - - have "cmod (f z) > cmod (g z)" using \z\path_image \\ path_less by auto - moreover have "f z = - g z" using \f z + g z =0\ by (simp add: eq_neg_iff_add_eq_0) - then have "cmod (f z) = cmod (g z)" by auto - ultimately show False by auto - qed - then show ?thesis unfolding zeros_fg_def fg_def using path_img by auto - qed - have path_f:"path_image \ \ s - zeros_f" - proof - - have False when "z\path_image \" and "f z =0" for z - proof - - have "cmod (g z) < cmod (f z) " using \z\path_image \\ path_less by auto - then have "cmod (g z) < 0" using \f z=0\ by auto - then show False by auto - qed - then show ?thesis unfolding zeros_f_def using path_img by auto - qed - define w where "w \ \p. winding_number \ p" - define c where "c \ 2 * complex_of_real pi * \" - define h where "h \ \p. g p / f p + 1" - obtain spikes - where "finite spikes" and spikes: "\x\{0..1} - spikes. \ differentiable at x" - using \valid_path \\ - by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) - have h_contour:"((\x. deriv h x / h x) has_contour_integral 0) \" - proof - - have outside_img:"0 \ outside (path_image (h o \))" - proof - - have "h p \ ball 1 1" when "p\path_image \" for p - proof - - have "cmod (g p/f p) <1" using path_less[rule_format,OF that] - apply (cases "cmod (f p) = 0") - by (auto simp add: norm_divide) - then show ?thesis unfolding h_def by (auto simp add:dist_complex_def) - qed - then have "path_image (h o \) \ ball 1 1" - by (simp add: image_subset_iff path_image_compose) - moreover have " (0::complex) \ ball 1 1" by (simp add: dist_norm) - ultimately show "?thesis" - using convex_in_outside[of "ball 1 1" 0] outside_mono by blast - qed - have valid_h:"valid_path (h \ \)" - proof (rule valid_path_compose_holomorphic[OF \valid_path \\ _ _ path_f]) - show "h holomorphic_on s - zeros_f" - unfolding h_def using f_holo g_holo - by (auto intro!: holomorphic_intros simp add:zeros_f_def) - next - show "open (s - zeros_f)" using \finite zeros_f\ \open s\ finite_imp_closed - by auto - qed - have "((\z. 1/z) has_contour_integral 0) (h \ \)" - proof - - have "0 \ path_image (h \ \)" using outside_img by (simp add: outside_def) - then have "((\z. 1/z) has_contour_integral c * winding_number (h \ \) 0) (h \ \)" - using has_contour_integral_winding_number[of "h o \" 0,simplified] valid_h - unfolding c_def by auto - moreover have "winding_number (h o \) 0 = 0" - proof - - have "0 \ outside (path_image (h \ \))" using outside_img . - moreover have "path (h o \)" - using valid_h by (simp add: valid_path_imp_path) - moreover have "pathfinish (h o \) = pathstart (h o \)" - by (simp add: loop pathfinish_compose pathstart_compose) - ultimately show ?thesis using winding_number_zero_in_outside by auto - qed - ultimately show ?thesis by auto - qed - moreover have "vector_derivative (h \ \) (at x) = vector_derivative \ (at x) * deriv h (\ x)" - when "x\{0..1} - spikes" for x - proof (rule vector_derivative_chain_at_general) - show "\ differentiable at x" using that \valid_path \\ spikes by auto - next - define der where "der \ \p. (deriv g p * f p - g p * deriv f p)/(f p * f p)" - define t where "t \ \ x" - have "f t\0" unfolding zeros_f_def t_def - by (metis DiffD1 image_eqI norm_not_less_zero norm_zero path_defs(4) path_less that) - moreover have "t\s" - using contra_subsetD path_image_def path_fg t_def that by fastforce - ultimately have "(h has_field_derivative der t) (at t)" - unfolding h_def der_def using g_holo f_holo \open s\ - by (auto intro!: holomorphic_derivI derivative_eq_intros) - then show "h field_differentiable at (\ x)" - unfolding t_def field_differentiable_def by blast - qed - then have " ((/) 1 has_contour_integral 0) (h \ \) - = ((\x. deriv h x / h x) has_contour_integral 0) \" - unfolding has_contour_integral - apply (intro has_integral_spike_eq[OF negligible_finite, OF \finite spikes\]) - by auto - ultimately show ?thesis by auto - qed - then have "contour_integral \ (\x. deriv h x / h x) = 0" - using contour_integral_unique by simp - moreover have "contour_integral \ (\x. deriv fg x / fg x) = contour_integral \ (\x. deriv f x / f x) - + contour_integral \ (\p. deriv h p / h p)" - proof - - have "(\p. deriv f p / f p) contour_integrable_on \" - proof (rule contour_integrable_holomorphic_simple[OF _ _ \valid_path \\ path_f]) - show "open (s - zeros_f)" using finite_imp_closed[OF \finite zeros_f\] \open s\ - by auto - then show "(\p. deriv f p / f p) holomorphic_on s - zeros_f" - using f_holo - by (auto intro!: holomorphic_intros simp add:zeros_f_def) - qed - moreover have "(\p. deriv h p / h p) contour_integrable_on \" - using h_contour - by (simp add: has_contour_integral_integrable) - ultimately have "contour_integral \ (\x. deriv f x / f x + deriv h x / h x) = - contour_integral \ (\p. deriv f p / f p) + contour_integral \ (\p. deriv h p / h p)" - using contour_integral_add[of "(\p. deriv f p / f p)" \ "(\p. deriv h p / h p)" ] - by auto - moreover have "deriv fg p / fg p = deriv f p / f p + deriv h p / h p" - when "p\ path_image \" for p - proof - - have "fg p\0" and "f p\0" using path_f path_fg that unfolding zeros_f_def zeros_fg_def - by auto - have "h p\0" - proof (rule ccontr) - assume "\ h p \ 0" - then have "g p / f p= -1" unfolding h_def by (simp add: add_eq_0_iff2) - then have "cmod (g p/f p) = 1" by auto - moreover have "cmod (g p/f p) <1" using path_less[rule_format,OF that] - apply (cases "cmod (f p) = 0") - by (auto simp add: norm_divide) - ultimately show False by auto - qed - have der_fg:"deriv fg p = deriv f p + deriv g p" unfolding fg_def - using f_holo g_holo holomorphic_on_imp_differentiable_at[OF _ \open s\] path_img that - by auto - have der_h:"deriv h p = (deriv g p * f p - g p * deriv f p)/(f p * f p)" - proof - - define der where "der \ \p. (deriv g p * f p - g p * deriv f p)/(f p * f p)" - have "p\s" using path_img that by auto - then have "(h has_field_derivative der p) (at p)" - unfolding h_def der_def using g_holo f_holo \open s\ \f p\0\ - by (auto intro!: derivative_eq_intros holomorphic_derivI) - then show ?thesis unfolding der_def using DERIV_imp_deriv by auto - qed - show ?thesis - apply (simp only:der_fg der_h) - apply (auto simp add:field_simps \h p\0\ \f p\0\ \fg p\0\) - by (auto simp add:field_simps h_def \f p\0\ fg_def) - qed - then have "contour_integral \ (\p. deriv fg p / fg p) - = contour_integral \ (\p. deriv f p / f p + deriv h p / h p)" - by (elim contour_integral_eq) - ultimately show ?thesis by auto - qed - moreover have "contour_integral \ (\x. deriv fg x / fg x) = c * (\p\zeros_fg. w p * zorder fg p)" - unfolding c_def zeros_fg_def w_def - proof (rule argument_principle[OF \open s\ \connected s\ _ _ \valid_path \\ loop _ homo - , of _ "{}" "\_. 1",simplified]) - show "fg holomorphic_on s" unfolding fg_def using f_holo g_holo holomorphic_on_add by auto - show "path_image \ \ s - {p. fg p = 0}" using path_fg unfolding zeros_fg_def . - show " finite {p. fg p = 0}" using \finite zeros_fg\ unfolding zeros_fg_def . - qed - moreover have "contour_integral \ (\x. deriv f x / f x) = c * (\p\zeros_f. w p * zorder f p)" - unfolding c_def zeros_f_def w_def - proof (rule argument_principle[OF \open s\ \connected s\ _ _ \valid_path \\ loop _ homo - , of _ "{}" "\_. 1",simplified]) - show "f holomorphic_on s" using f_holo g_holo holomorphic_on_add by auto - show "path_image \ \ s - {p. f p = 0}" using path_f unfolding zeros_f_def . - show " finite {p. f p = 0}" using \finite zeros_f\ unfolding zeros_f_def . - qed - ultimately have " c* (\p\zeros_fg. w p * (zorder fg p)) = c* (\p\zeros_f. w p * (zorder f p))" - by auto - then show ?thesis unfolding c_def using w_def by auto -qed - - -subsection \Poles and residues of some well-known functions\ - -(* TODO: add more material here for other functions *) -lemma is_pole_Gamma: "is_pole Gamma (-of_nat n)" - unfolding is_pole_def using Gamma_poles . - -lemma Gamme_residue: - "residue Gamma (-of_nat n) = (-1) ^ n / fact n" -proof (rule residue_simple') - show "open (- (\\<^sub>\\<^sub>0 - {-of_nat n}) :: complex set)" - by (intro open_Compl closed_subset_Ints) auto - show "Gamma holomorphic_on (- (\\<^sub>\\<^sub>0 - {-of_nat n}) - {- of_nat n})" - by (rule holomorphic_Gamma) auto - show "(\w. Gamma w * (w - (-of_nat n))) \(-of_nat n)\ (- 1) ^ n / fact n" - using Gamma_residues[of n] by simp -qed auto - end diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Contour_Integration.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Complex_Analysis/Contour_Integration.thy Mon Dec 02 17:51:54 2019 +0100 @@ -0,0 +1,1742 @@ +section \Contour integration\ +theory Contour_Integration + imports "HOL-Analysis.Analysis" +begin + +lemma lhopital_complex_simple: + assumes "(f has_field_derivative f') (at z)" + assumes "(g has_field_derivative g') (at z)" + assumes "f z = 0" "g z = 0" "g' \ 0" "f' / g' = c" + shows "((\w. f w / g w) \ c) (at z)" +proof - + have "eventually (\w. w \ z) (at z)" + by (auto simp: eventually_at_filter) + hence "eventually (\w. ((f w - f z) / (w - z)) / ((g w - g z) / (w - z)) = f w / g w) (at z)" + by eventually_elim (simp add: assms field_split_simps) + moreover have "((\w. ((f w - f z) / (w - z)) / ((g w - g z) / (w - z))) \ f' / g') (at z)" + by (intro tendsto_divide has_field_derivativeD assms) + ultimately have "((\w. f w / g w) \ f' / g') (at z)" + by (blast intro: Lim_transform_eventually) + with assms show ?thesis by simp +qed + +subsection\Definition\ + +text\ + This definition is for complex numbers only, and does not generalise to + line integrals in a vector field +\ + +definition\<^marker>\tag important\ has_contour_integral :: "(complex \ complex) \ complex \ (real \ complex) \ bool" + (infixr "has'_contour'_integral" 50) + where "(f has_contour_integral i) g \ + ((\x. f(g x) * vector_derivative g (at x within {0..1})) + has_integral i) {0..1}" + +definition\<^marker>\tag important\ contour_integrable_on + (infixr "contour'_integrable'_on" 50) + where "f contour_integrable_on g \ \i. (f has_contour_integral i) g" + +definition\<^marker>\tag important\ contour_integral + where "contour_integral g f \ SOME i. (f has_contour_integral i) g \ \ f contour_integrable_on g \ i=0" + +lemma not_integrable_contour_integral: "\ f contour_integrable_on g \ contour_integral g f = 0" + unfolding contour_integrable_on_def contour_integral_def by blast + +lemma contour_integral_unique: "(f has_contour_integral i) g \ contour_integral g f = i" + apply (simp add: contour_integral_def has_contour_integral_def contour_integrable_on_def) + using has_integral_unique by blast + +lemma has_contour_integral_eqpath: + "\(f has_contour_integral y) p; f contour_integrable_on \; + contour_integral p f = contour_integral \ f\ + \ (f has_contour_integral y) \" +using contour_integrable_on_def contour_integral_unique by auto + +lemma has_contour_integral_integral: + "f contour_integrable_on i \ (f has_contour_integral (contour_integral i f)) i" + by (metis contour_integral_unique contour_integrable_on_def) + +lemma has_contour_integral_unique: + "(f has_contour_integral i) g \ (f has_contour_integral j) g \ i = j" + using has_integral_unique + by (auto simp: has_contour_integral_def) + +lemma has_contour_integral_integrable: "(f has_contour_integral i) g \ f contour_integrable_on g" + using contour_integrable_on_def by blast + +text\Show that we can forget about the localized derivative.\ + +lemma has_integral_localized_vector_derivative: + "((\x. f (g x) * vector_derivative g (at x within {a..b})) has_integral i) {a..b} \ + ((\x. f (g x) * vector_derivative g (at x)) has_integral i) {a..b}" +proof - + have *: "{a..b} - {a,b} = interior {a..b}" + by (simp add: atLeastAtMost_diff_ends) + show ?thesis + apply (rule has_integral_spike_eq [of "{a,b}"]) + apply (auto simp: at_within_interior [of _ "{a..b}"]) + done +qed + +lemma integrable_on_localized_vector_derivative: + "(\x. f (g x) * vector_derivative g (at x within {a..b})) integrable_on {a..b} \ + (\x. f (g x) * vector_derivative g (at x)) integrable_on {a..b}" + by (simp add: integrable_on_def has_integral_localized_vector_derivative) + +lemma has_contour_integral: + "(f has_contour_integral i) g \ + ((\x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}" + by (simp add: has_integral_localized_vector_derivative has_contour_integral_def) + +lemma contour_integrable_on: + "f contour_integrable_on g \ + (\t. f(g t) * vector_derivative g (at t)) integrable_on {0..1}" + by (simp add: has_contour_integral integrable_on_def contour_integrable_on_def) + +subsection\<^marker>\tag unimportant\ \Reversing a path\ + + + +lemma has_contour_integral_reversepath: + assumes "valid_path g" and f: "(f has_contour_integral i) g" + shows "(f has_contour_integral (-i)) (reversepath g)" +proof - + { fix S x + assume xs: "g C1_differentiable_on ({0..1} - S)" "x \ (-) 1 ` S" "0 \ x" "x \ 1" + have "vector_derivative (\x. g (1 - x)) (at x within {0..1}) = + - vector_derivative g (at (1 - x) within {0..1})" + proof - + obtain f' where f': "(g has_vector_derivative f') (at (1 - x))" + using xs + by (force simp: has_vector_derivative_def C1_differentiable_on_def) + have "(g \ (\x. 1 - x) has_vector_derivative -1 *\<^sub>R f') (at x)" + by (intro vector_diff_chain_within has_vector_derivative_at_within [OF f'] derivative_eq_intros | simp)+ + then have mf': "((\x. g (1 - x)) has_vector_derivative -f') (at x)" + by (simp add: o_def) + show ?thesis + using xs + by (auto simp: vector_derivative_at_within_ivl [OF mf'] vector_derivative_at_within_ivl [OF f']) + qed + } note * = this + obtain S where S: "continuous_on {0..1} g" "finite S" "g C1_differentiable_on {0..1} - S" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) + have "((\x. - (f (g (1 - x)) * vector_derivative g (at (1 - x) within {0..1}))) has_integral -i) + {0..1}" + using has_integral_affinity01 [where m= "-1" and c=1, OF f [unfolded has_contour_integral_def]] + by (simp add: has_integral_neg) + then show ?thesis + using S + apply (clarsimp simp: reversepath_def has_contour_integral_def) + apply (rule_tac S = "(\x. 1 - x) ` S" in has_integral_spike_finite) + apply (auto simp: *) + done +qed + +lemma contour_integrable_reversepath: + "valid_path g \ f contour_integrable_on g \ f contour_integrable_on (reversepath g)" + using has_contour_integral_reversepath contour_integrable_on_def by blast + +lemma contour_integrable_reversepath_eq: + "valid_path g \ (f contour_integrable_on (reversepath g) \ f contour_integrable_on g)" + using contour_integrable_reversepath valid_path_reversepath by fastforce + +lemma contour_integral_reversepath: + assumes "valid_path g" + shows "contour_integral (reversepath g) f = - (contour_integral g f)" +proof (cases "f contour_integrable_on g") + case True then show ?thesis + by (simp add: assms contour_integral_unique has_contour_integral_integral has_contour_integral_reversepath) +next + case False then have "\ f contour_integrable_on (reversepath g)" + by (simp add: assms contour_integrable_reversepath_eq) + with False show ?thesis by (simp add: not_integrable_contour_integral) +qed + + +subsection\<^marker>\tag unimportant\ \Joining two paths together\ + +lemma has_contour_integral_join: + assumes "(f has_contour_integral i1) g1" "(f has_contour_integral i2) g2" + "valid_path g1" "valid_path g2" + shows "(f has_contour_integral (i1 + i2)) (g1 +++ g2)" +proof - + obtain s1 s2 + where s1: "finite s1" "\x\{0..1} - s1. g1 differentiable at x" + and s2: "finite s2" "\x\{0..1} - s2. g2 differentiable at x" + using assms + by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + have 1: "((\x. f (g1 x) * vector_derivative g1 (at x)) has_integral i1) {0..1}" + and 2: "((\x. f (g2 x) * vector_derivative g2 (at x)) has_integral i2) {0..1}" + using assms + by (auto simp: has_contour_integral) + have i1: "((\x. (2*f (g1 (2*x))) * vector_derivative g1 (at (2*x))) has_integral i1) {0..1/2}" + and i2: "((\x. (2*f (g2 (2*x - 1))) * vector_derivative g2 (at (2*x - 1))) has_integral i2) {1/2..1}" + using has_integral_affinity01 [OF 1, where m= 2 and c=0, THEN has_integral_cmul [where c=2]] + has_integral_affinity01 [OF 2, where m= 2 and c="-1", THEN has_integral_cmul [where c=2]] + by (simp_all only: image_affinity_atLeastAtMost_div_diff, simp_all add: scaleR_conv_of_real mult_ac) + have g1: "\0 \ z; z*2 < 1; z*2 \ s1\ \ + vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at z) = + 2 *\<^sub>R vector_derivative g1 (at (z*2))" for z + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g1(2*x))" and d = "\z - 1/2\"]]) + apply (simp_all add: dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. 2*x" 2 _ g1, simplified o_def]) + apply (simp add: has_vector_derivative_def has_derivative_def bounded_linear_mult_left) + using s1 + apply (auto simp: algebra_simps vector_derivative_works) + done + have g2: "\1 < z*2; z \ 1; z*2 - 1 \ s2\ \ + vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at z) = + 2 *\<^sub>R vector_derivative g2 (at (z*2 - 1))" for z + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g2 (2*x - 1))" and d = "\z - 1/2\"]]) + apply (simp_all add: dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. 2*x - 1" 2 _ g2, simplified o_def]) + apply (simp add: has_vector_derivative_def has_derivative_def bounded_linear_mult_left) + using s2 + apply (auto simp: algebra_simps vector_derivative_works) + done + have "((\x. f ((g1 +++ g2) x) * vector_derivative (g1 +++ g2) (at x)) has_integral i1) {0..1/2}" + apply (rule has_integral_spike_finite [OF _ _ i1, of "insert (1/2) ((*)2 -` s1)"]) + using s1 + apply (force intro: finite_vimageI [where h = "(*)2"] inj_onI) + apply (clarsimp simp add: joinpaths_def scaleR_conv_of_real mult_ac g1) + done + moreover have "((\x. f ((g1 +++ g2) x) * vector_derivative (g1 +++ g2) (at x)) has_integral i2) {1/2..1}" + apply (rule has_integral_spike_finite [OF _ _ i2, of "insert (1/2) ((\x. 2*x-1) -` s2)"]) + using s2 + apply (force intro: finite_vimageI [where h = "\x. 2*x-1"] inj_onI) + apply (clarsimp simp add: joinpaths_def scaleR_conv_of_real mult_ac g2) + done + ultimately + show ?thesis + apply (simp add: has_contour_integral) + apply (rule has_integral_combine [where c = "1/2"], auto) + done +qed + +lemma contour_integrable_joinI: + assumes "f contour_integrable_on g1" "f contour_integrable_on g2" + "valid_path g1" "valid_path g2" + shows "f contour_integrable_on (g1 +++ g2)" + using assms + by (meson has_contour_integral_join contour_integrable_on_def) + +lemma contour_integrable_joinD1: + assumes "f contour_integrable_on (g1 +++ g2)" "valid_path g1" + shows "f contour_integrable_on g1" +proof - + obtain s1 + where s1: "finite s1" "\x\{0..1} - s1. g1 differentiable at x" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + have "(\x. f ((g1 +++ g2) (x/2)) * vector_derivative (g1 +++ g2) (at (x/2))) integrable_on {0..1}" + using assms + apply (auto simp: contour_integrable_on) + apply (drule integrable_on_subcbox [where a=0 and b="1/2"]) + apply (auto intro: integrable_affinity [of _ 0 "1/2::real" "1/2" 0, simplified]) + done + then have *: "(\x. (f ((g1 +++ g2) (x/2))/2) * vector_derivative (g1 +++ g2) (at (x/2))) integrable_on {0..1}" + by (auto dest: integrable_cmul [where c="1/2"] simp: scaleR_conv_of_real) + have g1: "\0 < z; z < 1; z \ s1\ \ + vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at (z/2)) = + 2 *\<^sub>R vector_derivative g1 (at z)" for z + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g1(2*x))" and d = "\(z-1)/2\"]]) + apply (simp_all add: field_simps dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. x*2" 2 _ g1, simplified o_def]) + using s1 + apply (auto simp: vector_derivative_works has_vector_derivative_def has_derivative_def bounded_linear_mult_left) + done + show ?thesis + using s1 + apply (auto simp: contour_integrable_on) + apply (rule integrable_spike_finite [of "{0,1} \ s1", OF _ _ *]) + apply (auto simp: joinpaths_def scaleR_conv_of_real g1) + done +qed + +lemma contour_integrable_joinD2: + assumes "f contour_integrable_on (g1 +++ g2)" "valid_path g2" + shows "f contour_integrable_on g2" +proof - + obtain s2 + where s2: "finite s2" "\x\{0..1} - s2. g2 differentiable at x" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + have "(\x. f ((g1 +++ g2) (x/2 + 1/2)) * vector_derivative (g1 +++ g2) (at (x/2 + 1/2))) integrable_on {0..1}" + using assms + apply (auto simp: contour_integrable_on) + apply (drule integrable_on_subcbox [where a="1/2" and b=1], auto) + apply (drule integrable_affinity [of _ "1/2::real" 1 "1/2" "1/2", simplified]) + apply (simp add: image_affinity_atLeastAtMost_diff) + done + then have *: "(\x. (f ((g1 +++ g2) (x/2 + 1/2))/2) * vector_derivative (g1 +++ g2) (at (x/2 + 1/2))) + integrable_on {0..1}" + by (auto dest: integrable_cmul [where c="1/2"] simp: scaleR_conv_of_real) + have g2: "\0 < z; z < 1; z \ s2\ \ + vector_derivative (\x. if x*2 \ 1 then g1 (2*x) else g2 (2*x - 1)) (at (z/2+1/2)) = + 2 *\<^sub>R vector_derivative g2 (at z)" for z + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g2(2*x-1))" and d = "\z/2\"]]) + apply (simp_all add: field_simps dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. x*2-1" 2 _ g2, simplified o_def]) + using s2 + apply (auto simp: has_vector_derivative_def has_derivative_def bounded_linear_mult_left + vector_derivative_works add_divide_distrib) + done + show ?thesis + using s2 + apply (auto simp: contour_integrable_on) + apply (rule integrable_spike_finite [of "{0,1} \ s2", OF _ _ *]) + apply (auto simp: joinpaths_def scaleR_conv_of_real g2) + done +qed + +lemma contour_integrable_join [simp]: + shows + "\valid_path g1; valid_path g2\ + \ f contour_integrable_on (g1 +++ g2) \ f contour_integrable_on g1 \ f contour_integrable_on g2" +using contour_integrable_joinD1 contour_integrable_joinD2 contour_integrable_joinI by blast + +lemma contour_integral_join [simp]: + shows + "\f contour_integrable_on g1; f contour_integrable_on g2; valid_path g1; valid_path g2\ + \ contour_integral (g1 +++ g2) f = contour_integral g1 f + contour_integral g2 f" + by (simp add: has_contour_integral_integral has_contour_integral_join contour_integral_unique) + + +subsection\<^marker>\tag unimportant\ \Shifting the starting point of a (closed) path\ + +lemma has_contour_integral_shiftpath: + assumes f: "(f has_contour_integral i) g" "valid_path g" + and a: "a \ {0..1}" + shows "(f has_contour_integral i) (shiftpath a g)" +proof - + obtain s + where s: "finite s" and g: "\x\{0..1} - s. g differentiable at x" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + have *: "((\x. f (g x) * vector_derivative g (at x)) has_integral i) {0..1}" + using assms by (auto simp: has_contour_integral) + then have i: "i = integral {a..1} (\x. f (g x) * vector_derivative g (at x)) + + integral {0..a} (\x. f (g x) * vector_derivative g (at x))" + apply (rule has_integral_unique) + apply (subst add.commute) + apply (subst Henstock_Kurzweil_Integration.integral_combine) + using assms * integral_unique by auto + { fix x + have "0 \ x \ x + a < 1 \ x \ (\x. x - a) ` s \ + vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a))" + unfolding shiftpath_def + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g(a+x))" and d = "dist(1-a) x"]]) + apply (auto simp: field_simps dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. x+a" 1 _ g, simplified o_def scaleR_one]) + apply (intro derivative_eq_intros | simp)+ + using g + apply (drule_tac x="x+a" in bspec) + using a apply (auto simp: has_vector_derivative_def vector_derivative_works image_def add.commute) + done + } note vd1 = this + { fix x + have "1 < x + a \ x \ 1 \ x \ (\x. x - a + 1) ` s \ + vector_derivative (shiftpath a g) (at x) = vector_derivative g (at (x + a - 1))" + unfolding shiftpath_def + apply (rule vector_derivative_at [OF has_vector_derivative_transform_within [where f = "(\x. g(a+x-1))" and d = "dist (1-a) x"]]) + apply (auto simp: field_simps dist_real_def abs_if split: if_split_asm) + apply (rule vector_diff_chain_at [of "\x. x+a-1" 1 _ g, simplified o_def scaleR_one]) + apply (intro derivative_eq_intros | simp)+ + using g + apply (drule_tac x="x+a-1" in bspec) + using a apply (auto simp: has_vector_derivative_def vector_derivative_works image_def add.commute) + done + } note vd2 = this + have va1: "(\x. f (g x) * vector_derivative g (at x)) integrable_on ({a..1})" + using * a by (fastforce intro: integrable_subinterval_real) + have v0a: "(\x. f (g x) * vector_derivative g (at x)) integrable_on ({0..a})" + apply (rule integrable_subinterval_real) + using * a by auto + have "((\x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) + has_integral integral {a..1} (\x. f (g x) * vector_derivative g (at x))) {0..1 - a}" + apply (rule has_integral_spike_finite + [where S = "{1-a} \ (\x. x-a) ` s" and f = "\x. f(g(a+x)) * vector_derivative g (at(a+x))"]) + using s apply blast + using a apply (auto simp: algebra_simps vd1) + apply (force simp: shiftpath_def add.commute) + using has_integral_affinity [where m=1 and c=a, simplified, OF integrable_integral [OF va1]] + apply (simp add: image_affinity_atLeastAtMost_diff [where m=1 and c=a, simplified] add.commute) + done + moreover + have "((\x. f (shiftpath a g x) * vector_derivative (shiftpath a g) (at x)) + has_integral integral {0..a} (\x. f (g x) * vector_derivative g (at x))) {1 - a..1}" + apply (rule has_integral_spike_finite + [where S = "{1-a} \ (\x. x-a+1) ` s" and f = "\x. f(g(a+x-1)) * vector_derivative g (at(a+x-1))"]) + using s apply blast + using a apply (auto simp: algebra_simps vd2) + apply (force simp: shiftpath_def add.commute) + using has_integral_affinity [where m=1 and c="a-1", simplified, OF integrable_integral [OF v0a]] + apply (simp add: image_affinity_atLeastAtMost [where m=1 and c="1-a", simplified]) + apply (simp add: algebra_simps) + done + ultimately show ?thesis + using a + by (auto simp: i has_contour_integral intro: has_integral_combine [where c = "1-a"]) +qed + +lemma has_contour_integral_shiftpath_D: + assumes "(f has_contour_integral i) (shiftpath a g)" + "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" + shows "(f has_contour_integral i) g" +proof - + obtain s + where s: "finite s" and g: "\x\{0..1} - s. g differentiable at x" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + { fix x + assume x: "0 < x" "x < 1" "x \ s" + then have gx: "g differentiable at x" + using g by auto + have "vector_derivative g (at x within {0..1}) = + vector_derivative (shiftpath (1 - a) (shiftpath a g)) (at x within {0..1})" + apply (rule vector_derivative_at_within_ivl + [OF has_vector_derivative_transform_within_open + [where f = "(shiftpath (1 - a) (shiftpath a g))" and S = "{0<..<1}-s"]]) + using s g assms x + apply (auto simp: finite_imp_closed open_Diff shiftpath_shiftpath + at_within_interior [of _ "{0..1}"] vector_derivative_works [symmetric]) + apply (rule differentiable_transform_within [OF gx, of "min x (1-x)"]) + apply (auto simp: dist_real_def shiftpath_shiftpath abs_if split: if_split_asm) + done + } note vd = this + have fi: "(f has_contour_integral i) (shiftpath (1 - a) (shiftpath a g))" + using assms by (auto intro!: has_contour_integral_shiftpath) + show ?thesis + apply (simp add: has_contour_integral_def) + apply (rule has_integral_spike_finite [of "{0,1} \ s", OF _ _ fi [unfolded has_contour_integral_def]]) + using s assms vd + apply (auto simp: Path_Connected.shiftpath_shiftpath) + done +qed + +lemma has_contour_integral_shiftpath_eq: + assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" + shows "(f has_contour_integral i) (shiftpath a g) \ (f has_contour_integral i) g" + using assms has_contour_integral_shiftpath has_contour_integral_shiftpath_D by blast + +lemma contour_integrable_on_shiftpath_eq: + assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" + shows "f contour_integrable_on (shiftpath a g) \ f contour_integrable_on g" +using assms contour_integrable_on_def has_contour_integral_shiftpath_eq by auto + +lemma contour_integral_shiftpath: + assumes "valid_path g" "pathfinish g = pathstart g" "a \ {0..1}" + shows "contour_integral (shiftpath a g) f = contour_integral g f" + using assms + by (simp add: contour_integral_def contour_integrable_on_def has_contour_integral_shiftpath_eq) + + +subsection\<^marker>\tag unimportant\ \More about straight-line paths\ + +lemma has_contour_integral_linepath: + shows "(f has_contour_integral i) (linepath a b) \ + ((\x. f(linepath a b x) * (b - a)) has_integral i) {0..1}" + by (simp add: has_contour_integral) + +lemma has_contour_integral_trivial [iff]: "(f has_contour_integral 0) (linepath a a)" + by (simp add: has_contour_integral_linepath) + +lemma has_contour_integral_trivial_iff [simp]: "(f has_contour_integral i) (linepath a a) \ i=0" + using has_contour_integral_unique by blast + +lemma contour_integral_trivial [simp]: "contour_integral (linepath a a) f = 0" + using has_contour_integral_trivial contour_integral_unique by blast + + +subsection\Relation to subpath construction\ + +lemma has_contour_integral_subpath_refl [iff]: "(f has_contour_integral 0) (subpath u u g)" + by (simp add: has_contour_integral subpath_def) + +lemma contour_integrable_subpath_refl [iff]: "f contour_integrable_on (subpath u u g)" + using has_contour_integral_subpath_refl contour_integrable_on_def by blast + +lemma contour_integral_subpath_refl [simp]: "contour_integral (subpath u u g) f = 0" + by (simp add: contour_integral_unique) + +lemma has_contour_integral_subpath: + assumes f: "f contour_integrable_on g" and g: "valid_path g" + and uv: "u \ {0..1}" "v \ {0..1}" "u \ v" + shows "(f has_contour_integral integral {u..v} (\x. f(g x) * vector_derivative g (at x))) + (subpath u v g)" +proof (cases "v=u") + case True + then show ?thesis + using f by (simp add: contour_integrable_on_def subpath_def has_contour_integral) +next + case False + obtain s where s: "\x. x \ {0..1} - s \ g differentiable at x" and fs: "finite s" + using g unfolding piecewise_C1_differentiable_on_def C1_differentiable_on_eq valid_path_def by blast + have *: "((\x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) + has_integral (1 / (v - u)) * integral {u..v} (\t. f (g t) * vector_derivative g (at t))) + {0..1}" + using f uv + apply (simp add: contour_integrable_on subpath_def has_contour_integral) + apply (drule integrable_on_subcbox [where a=u and b=v, simplified]) + apply (simp_all add: has_integral_integral) + apply (drule has_integral_affinity [where m="v-u" and c=u, simplified]) + apply (simp_all add: False image_affinity_atLeastAtMost_div_diff scaleR_conv_of_real) + apply (simp add: divide_simps False) + done + { fix x + have "x \ {0..1} \ + x \ (\t. (v-u) *\<^sub>R t + u) -` s \ + vector_derivative (\x. g ((v-u) * x + u)) (at x) = (v-u) *\<^sub>R vector_derivative g (at ((v-u) * x + u))" + apply (rule vector_derivative_at [OF vector_diff_chain_at [simplified o_def]]) + apply (intro derivative_eq_intros | simp)+ + apply (cut_tac s [of "(v - u) * x + u"]) + using uv mult_left_le [of x "v-u"] + apply (auto simp: vector_derivative_works) + done + } note vd = this + show ?thesis + apply (cut_tac has_integral_cmul [OF *, where c = "v-u"]) + using fs assms + apply (simp add: False subpath_def has_contour_integral) + apply (rule_tac S = "(\t. ((v-u) *\<^sub>R t + u)) -` s" in has_integral_spike_finite) + apply (auto simp: inj_on_def False finite_vimageI vd scaleR_conv_of_real) + done +qed + +lemma contour_integrable_subpath: + assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" + shows "f contour_integrable_on (subpath u v g)" + apply (cases u v rule: linorder_class.le_cases) + apply (metis contour_integrable_on_def has_contour_integral_subpath [OF assms]) + apply (subst reversepath_subpath [symmetric]) + apply (rule contour_integrable_reversepath) + using assms apply (blast intro: valid_path_subpath) + apply (simp add: contour_integrable_on_def) + using assms apply (blast intro: has_contour_integral_subpath) + done + +lemma has_integral_contour_integral_subpath: + assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "u \ v" + shows "(((\x. f(g x) * vector_derivative g (at x))) + has_integral contour_integral (subpath u v g) f) {u..v}" + using assms + apply (auto simp: has_integral_integrable_integral) + apply (rule integrable_on_subcbox [where a=u and b=v and S = "{0..1}", simplified]) + apply (auto simp: contour_integral_unique [OF has_contour_integral_subpath] contour_integrable_on) + done + +lemma contour_integral_subcontour_integral: + assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "u \ v" + shows "contour_integral (subpath u v g) f = + integral {u..v} (\x. f(g x) * vector_derivative g (at x))" + using assms has_contour_integral_subpath contour_integral_unique by blast + +lemma contour_integral_subpath_combine_less: + assumes "f contour_integrable_on g" "valid_path g" "u \ {0..1}" "v \ {0..1}" "w \ {0..1}" + "u {0..1}" "v \ {0..1}" "w \ {0..1}" + shows "contour_integral (subpath u v g) f + contour_integral (subpath v w g) f = + contour_integral (subpath u w g) f" +proof (cases "u\v \ v\w \ u\w") + case True + have *: "subpath v u g = reversepath(subpath u v g) \ + subpath w u g = reversepath(subpath u w g) \ + subpath w v g = reversepath(subpath v w g)" + by (auto simp: reversepath_subpath) + have "u < v \ v < w \ + u < w \ w < v \ + v < u \ u < w \ + v < w \ w < u \ + w < u \ u < v \ + w < v \ v < u" + using True assms by linarith + with assms show ?thesis + using contour_integral_subpath_combine_less [of f g u v w] + contour_integral_subpath_combine_less [of f g u w v] + contour_integral_subpath_combine_less [of f g v u w] + contour_integral_subpath_combine_less [of f g v w u] + contour_integral_subpath_combine_less [of f g w u v] + contour_integral_subpath_combine_less [of f g w v u] + apply simp + apply (elim disjE) + apply (auto simp: * contour_integral_reversepath contour_integrable_subpath + valid_path_subpath algebra_simps) + done +next + case False + then show ?thesis + apply (auto) + using assms + by (metis eq_neg_iff_add_eq_0 contour_integral_reversepath reversepath_subpath valid_path_subpath) +qed + +lemma contour_integral_integral: + "contour_integral g f = integral {0..1} (\x. f (g x) * vector_derivative g (at x))" + by (simp add: contour_integral_def integral_def has_contour_integral contour_integrable_on) + +lemma contour_integral_cong: + assumes "g = g'" "\x. x \ path_image g \ f x = f' x" + shows "contour_integral g f = contour_integral g' f'" + unfolding contour_integral_integral using assms + by (intro integral_cong) (auto simp: path_image_def) + + +text \Contour integral along a segment on the real axis\ + +lemma has_contour_integral_linepath_Reals_iff: + fixes a b :: complex and f :: "complex \ complex" + assumes "a \ Reals" "b \ Reals" "Re a < Re b" + shows "(f has_contour_integral I) (linepath a b) \ + ((\x. f (of_real x)) has_integral I) {Re a..Re b}" +proof - + from assms have [simp]: "of_real (Re a) = a" "of_real (Re b) = b" + by (simp_all add: complex_eq_iff) + from assms have "a \ b" by auto + have "((\x. f (of_real x)) has_integral I) (cbox (Re a) (Re b)) \ + ((\x. f (a + b * of_real x - a * of_real x)) has_integral I /\<^sub>R (Re b - Re a)) {0..1}" + by (subst has_integral_affinity_iff [of "Re b - Re a" _ "Re a", symmetric]) + (insert assms, simp_all add: field_simps scaleR_conv_of_real) + also have "(\x. f (a + b * of_real x - a * of_real x)) = + (\x. (f (a + b * of_real x - a * of_real x) * (b - a)) /\<^sub>R (Re b - Re a))" + using \a \ b\ by (auto simp: field_simps fun_eq_iff scaleR_conv_of_real) + also have "(\ has_integral I /\<^sub>R (Re b - Re a)) {0..1} \ + ((\x. f (linepath a b x) * (b - a)) has_integral I) {0..1}" using assms + by (subst has_integral_cmul_iff) (auto simp: linepath_def scaleR_conv_of_real algebra_simps) + also have "\ \ (f has_contour_integral I) (linepath a b)" unfolding has_contour_integral_def + by (intro has_integral_cong) (simp add: vector_derivative_linepath_within) + finally show ?thesis by simp +qed + +lemma contour_integrable_linepath_Reals_iff: + fixes a b :: complex and f :: "complex \ complex" + assumes "a \ Reals" "b \ Reals" "Re a < Re b" + shows "(f contour_integrable_on linepath a b) \ + (\x. f (of_real x)) integrable_on {Re a..Re b}" + using has_contour_integral_linepath_Reals_iff[OF assms, of f] + by (auto simp: contour_integrable_on_def integrable_on_def) + +lemma contour_integral_linepath_Reals_eq: + fixes a b :: complex and f :: "complex \ complex" + assumes "a \ Reals" "b \ Reals" "Re a < Re b" + shows "contour_integral (linepath a b) f = integral {Re a..Re b} (\x. f (of_real x))" +proof (cases "f contour_integrable_on linepath a b") + case True + thus ?thesis using has_contour_integral_linepath_Reals_iff[OF assms, of f] + using has_contour_integral_integral has_contour_integral_unique by blast +next + case False + thus ?thesis using contour_integrable_linepath_Reals_iff[OF assms, of f] + by (simp add: not_integrable_contour_integral not_integrable_integral) +qed + +text \Cauchy's theorem where there's a primitive\ + +lemma contour_integral_primitive_lemma: + fixes f :: "complex \ complex" and g :: "real \ complex" + assumes "a \ b" + and "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" + and "g piecewise_differentiable_on {a..b}" "\x. x \ {a..b} \ g x \ s" + shows "((\x. f'(g x) * vector_derivative g (at x within {a..b})) + has_integral (f(g b) - f(g a))) {a..b}" +proof - + obtain k where k: "finite k" "\x\{a..b} - k. g differentiable (at x within {a..b})" and cg: "continuous_on {a..b} g" + using assms by (auto simp: piecewise_differentiable_on_def) + have cfg: "continuous_on {a..b} (\x. f (g x))" + apply (rule continuous_on_compose [OF cg, unfolded o_def]) + using assms + apply (metis field_differentiable_def field_differentiable_imp_continuous_at continuous_on_eq_continuous_within continuous_on_subset image_subset_iff) + done + { fix x::real + assume a: "a < x" and b: "x < b" and xk: "x \ k" + then have "g differentiable at x within {a..b}" + using k by (simp add: differentiable_at_withinI) + then have "(g has_vector_derivative vector_derivative g (at x within {a..b})) (at x within {a..b})" + by (simp add: vector_derivative_works has_field_derivative_def scaleR_conv_of_real) + then have gdiff: "(g has_derivative (\u. u * vector_derivative g (at x within {a..b}))) (at x within {a..b})" + by (simp add: has_vector_derivative_def scaleR_conv_of_real) + have "(f has_field_derivative (f' (g x))) (at (g x) within g ` {a..b})" + using assms by (metis a atLeastAtMost_iff b DERIV_subset image_subset_iff less_eq_real_def) + then have fdiff: "(f has_derivative (*) (f' (g x))) (at (g x) within g ` {a..b})" + by (simp add: has_field_derivative_def) + have "((\x. f (g x)) has_vector_derivative f' (g x) * vector_derivative g (at x within {a..b})) (at x within {a..b})" + using diff_chain_within [OF gdiff fdiff] + by (simp add: has_vector_derivative_def scaleR_conv_of_real o_def mult_ac) + } note * = this + show ?thesis + apply (rule fundamental_theorem_of_calculus_interior_strong) + using k assms cfg * + apply (auto simp: at_within_Icc_at) + done +qed + +lemma contour_integral_primitive: + assumes "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" + and "valid_path g" "path_image g \ s" + shows "(f' has_contour_integral (f(pathfinish g) - f(pathstart g))) g" + using assms + apply (simp add: valid_path_def path_image_def pathfinish_def pathstart_def has_contour_integral_def) + apply (auto intro!: piecewise_C1_imp_differentiable contour_integral_primitive_lemma [of 0 1 s]) + done + +corollary Cauchy_theorem_primitive: + assumes "\x. x \ s \ (f has_field_derivative f' x) (at x within s)" + and "valid_path g" "path_image g \ s" "pathfinish g = pathstart g" + shows "(f' has_contour_integral 0) g" + using assms + by (metis diff_self contour_integral_primitive) + +text\Existence of path integral for continuous function\ +lemma contour_integrable_continuous_linepath: + assumes "continuous_on (closed_segment a b) f" + shows "f contour_integrable_on (linepath a b)" +proof - + have "continuous_on {0..1} ((\x. f x * (b - a)) \ linepath a b)" + apply (rule continuous_on_compose [OF continuous_on_linepath], simp add: linepath_image_01) + apply (rule continuous_intros | simp add: assms)+ + done + then show ?thesis + apply (simp add: contour_integrable_on_def has_contour_integral_def integrable_on_def [symmetric]) + apply (rule integrable_continuous [of 0 "1::real", simplified]) + apply (rule continuous_on_eq [where f = "\x. f(linepath a b x)*(b - a)"]) + apply (auto simp: vector_derivative_linepath_within) + done +qed + +lemma has_field_der_id: "((\x. x\<^sup>2 / 2) has_field_derivative x) (at x)" + by (rule has_derivative_imp_has_field_derivative) + (rule derivative_intros | simp)+ + +lemma contour_integral_id [simp]: "contour_integral (linepath a b) (\y. y) = (b^2 - a^2)/2" + apply (rule contour_integral_unique) + using contour_integral_primitive [of UNIV "\x. x^2/2" "\x. x" "linepath a b"] + apply (auto simp: field_simps has_field_der_id) + done + +lemma contour_integrable_on_const [iff]: "(\x. c) contour_integrable_on (linepath a b)" + by (simp add: contour_integrable_continuous_linepath) + +lemma contour_integrable_on_id [iff]: "(\x. x) contour_integrable_on (linepath a b)" + by (simp add: contour_integrable_continuous_linepath) + +subsection\<^marker>\tag unimportant\ \Arithmetical combining theorems\ + +lemma has_contour_integral_neg: + "(f has_contour_integral i) g \ ((\x. -(f x)) has_contour_integral (-i)) g" + by (simp add: has_integral_neg has_contour_integral_def) + +lemma has_contour_integral_add: + "\(f1 has_contour_integral i1) g; (f2 has_contour_integral i2) g\ + \ ((\x. f1 x + f2 x) has_contour_integral (i1 + i2)) g" + by (simp add: has_integral_add has_contour_integral_def algebra_simps) + +lemma has_contour_integral_diff: + "\(f1 has_contour_integral i1) g; (f2 has_contour_integral i2) g\ + \ ((\x. f1 x - f2 x) has_contour_integral (i1 - i2)) g" + by (simp add: has_integral_diff has_contour_integral_def algebra_simps) + +lemma has_contour_integral_lmul: + "(f has_contour_integral i) g \ ((\x. c * (f x)) has_contour_integral (c*i)) g" +apply (simp add: has_contour_integral_def) +apply (drule has_integral_mult_right) +apply (simp add: algebra_simps) +done + +lemma has_contour_integral_rmul: + "(f has_contour_integral i) g \ ((\x. (f x) * c) has_contour_integral (i*c)) g" +apply (drule has_contour_integral_lmul) +apply (simp add: mult.commute) +done + +lemma has_contour_integral_div: + "(f has_contour_integral i) g \ ((\x. f x/c) has_contour_integral (i/c)) g" + by (simp add: field_class.field_divide_inverse) (metis has_contour_integral_rmul) + +lemma has_contour_integral_eq: + "\(f has_contour_integral y) p; \x. x \ path_image p \ f x = g x\ \ (g has_contour_integral y) p" +apply (simp add: path_image_def has_contour_integral_def) +by (metis (no_types, lifting) image_eqI has_integral_eq) + +lemma has_contour_integral_bound_linepath: + assumes "(f has_contour_integral i) (linepath a b)" + "0 \ B" "\x. x \ closed_segment a b \ norm(f x) \ B" + shows "norm i \ B * norm(b - a)" +proof - + { fix x::real + assume x: "0 \ x" "x \ 1" + have "norm (f (linepath a b x)) * + norm (vector_derivative (linepath a b) (at x within {0..1})) \ B * norm (b - a)" + by (auto intro: mult_mono simp: assms linepath_in_path of_real_linepath vector_derivative_linepath_within x) + } note * = this + have "norm i \ (B * norm (b - a)) * content (cbox 0 (1::real))" + apply (rule has_integral_bound + [of _ "\x. f (linepath a b x) * vector_derivative (linepath a b) (at x within {0..1})"]) + using assms * unfolding has_contour_integral_def + apply (auto simp: norm_mult) + done + then show ?thesis + by (auto simp: content_real) +qed + +(*UNUSED +lemma has_contour_integral_bound_linepath_strong: + fixes a :: real and f :: "complex \ real" + assumes "(f has_contour_integral i) (linepath a b)" + "finite k" + "0 \ B" "\x::real. x \ closed_segment a b - k \ norm(f x) \ B" + shows "norm i \ B*norm(b - a)" +*) + +lemma has_contour_integral_const_linepath: "((\x. c) has_contour_integral c*(b - a))(linepath a b)" + unfolding has_contour_integral_linepath + by (metis content_real diff_0_right has_integral_const_real lambda_one of_real_1 scaleR_conv_of_real zero_le_one) + +lemma has_contour_integral_0: "((\x. 0) has_contour_integral 0) g" + by (simp add: has_contour_integral_def) + +lemma has_contour_integral_is_0: + "(\z. z \ path_image g \ f z = 0) \ (f has_contour_integral 0) g" + by (rule has_contour_integral_eq [OF has_contour_integral_0]) auto + +lemma has_contour_integral_sum: + "\finite s; \a. a \ s \ (f a has_contour_integral i a) p\ + \ ((\x. sum (\a. f a x) s) has_contour_integral sum i s) p" + by (induction s rule: finite_induct) (auto simp: has_contour_integral_0 has_contour_integral_add) + +subsection\<^marker>\tag unimportant\ \Operations on path integrals\ + +lemma contour_integral_const_linepath [simp]: "contour_integral (linepath a b) (\x. c) = c*(b - a)" + by (rule contour_integral_unique [OF has_contour_integral_const_linepath]) + +lemma contour_integral_neg: + "f contour_integrable_on g \ contour_integral g (\x. -(f x)) = -(contour_integral g f)" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_neg) + +lemma contour_integral_add: + "f1 contour_integrable_on g \ f2 contour_integrable_on g \ contour_integral g (\x. f1 x + f2 x) = + contour_integral g f1 + contour_integral g f2" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_add) + +lemma contour_integral_diff: + "f1 contour_integrable_on g \ f2 contour_integrable_on g \ contour_integral g (\x. f1 x - f2 x) = + contour_integral g f1 - contour_integral g f2" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_diff) + +lemma contour_integral_lmul: + shows "f contour_integrable_on g + \ contour_integral g (\x. c * f x) = c*contour_integral g f" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_lmul) + +lemma contour_integral_rmul: + shows "f contour_integrable_on g + \ contour_integral g (\x. f x * c) = contour_integral g f * c" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_rmul) + +lemma contour_integral_div: + shows "f contour_integrable_on g + \ contour_integral g (\x. f x / c) = contour_integral g f / c" + by (simp add: contour_integral_unique has_contour_integral_integral has_contour_integral_div) + +lemma contour_integral_eq: + "(\x. x \ path_image p \ f x = g x) \ contour_integral p f = contour_integral p g" + apply (simp add: contour_integral_def) + using has_contour_integral_eq + by (metis contour_integral_unique has_contour_integral_integrable has_contour_integral_integral) + +lemma contour_integral_eq_0: + "(\z. z \ path_image g \ f z = 0) \ contour_integral g f = 0" + by (simp add: has_contour_integral_is_0 contour_integral_unique) + +lemma contour_integral_bound_linepath: + shows + "\f contour_integrable_on (linepath a b); + 0 \ B; \x. x \ closed_segment a b \ norm(f x) \ B\ + \ norm(contour_integral (linepath a b) f) \ B*norm(b - a)" + apply (rule has_contour_integral_bound_linepath [of f]) + apply (auto simp: has_contour_integral_integral) + done + +lemma contour_integral_0 [simp]: "contour_integral g (\x. 0) = 0" + by (simp add: contour_integral_unique has_contour_integral_0) + +lemma contour_integral_sum: + "\finite s; \a. a \ s \ (f a) contour_integrable_on p\ + \ contour_integral p (\x. sum (\a. f a x) s) = sum (\a. contour_integral p (f a)) s" + by (auto simp: contour_integral_unique has_contour_integral_sum has_contour_integral_integral) + +lemma contour_integrable_eq: + "\f contour_integrable_on p; \x. x \ path_image p \ f x = g x\ \ g contour_integrable_on p" + unfolding contour_integrable_on_def + by (metis has_contour_integral_eq) + + +subsection\<^marker>\tag unimportant\ \Arithmetic theorems for path integrability\ + +lemma contour_integrable_neg: + "f contour_integrable_on g \ (\x. -(f x)) contour_integrable_on g" + using has_contour_integral_neg contour_integrable_on_def by blast + +lemma contour_integrable_add: + "\f1 contour_integrable_on g; f2 contour_integrable_on g\ \ (\x. f1 x + f2 x) contour_integrable_on g" + using has_contour_integral_add contour_integrable_on_def + by fastforce + +lemma contour_integrable_diff: + "\f1 contour_integrable_on g; f2 contour_integrable_on g\ \ (\x. f1 x - f2 x) contour_integrable_on g" + using has_contour_integral_diff contour_integrable_on_def + by fastforce + +lemma contour_integrable_lmul: + "f contour_integrable_on g \ (\x. c * f x) contour_integrable_on g" + using has_contour_integral_lmul contour_integrable_on_def + by fastforce + +lemma contour_integrable_rmul: + "f contour_integrable_on g \ (\x. f x * c) contour_integrable_on g" + using has_contour_integral_rmul contour_integrable_on_def + by fastforce + +lemma contour_integrable_div: + "f contour_integrable_on g \ (\x. f x / c) contour_integrable_on g" + using has_contour_integral_div contour_integrable_on_def + by fastforce + +lemma contour_integrable_sum: + "\finite s; \a. a \ s \ (f a) contour_integrable_on p\ + \ (\x. sum (\a. f a x) s) contour_integrable_on p" + unfolding contour_integrable_on_def + by (metis has_contour_integral_sum) + + +subsection\<^marker>\tag unimportant\ \Reversing a path integral\ + +lemma has_contour_integral_reverse_linepath: + "(f has_contour_integral i) (linepath a b) + \ (f has_contour_integral (-i)) (linepath b a)" + using has_contour_integral_reversepath valid_path_linepath by fastforce + +lemma contour_integral_reverse_linepath: + "continuous_on (closed_segment a b) f + \ contour_integral (linepath a b) f = - (contour_integral(linepath b a) f)" +apply (rule contour_integral_unique) +apply (rule has_contour_integral_reverse_linepath) +by (simp add: closed_segment_commute contour_integrable_continuous_linepath has_contour_integral_integral) + + +(* Splitting a path integral in a flat way.*) + +lemma has_contour_integral_split: + assumes f: "(f has_contour_integral i) (linepath a c)" "(f has_contour_integral j) (linepath c b)" + and k: "0 \ k" "k \ 1" + and c: "c - a = k *\<^sub>R (b - a)" + shows "(f has_contour_integral (i + j)) (linepath a b)" +proof (cases "k = 0 \ k = 1") + case True + then show ?thesis + using assms by auto +next + case False + then have k: "0 < k" "k < 1" "complex_of_real k \ 1" + using assms by auto + have c': "c = k *\<^sub>R (b - a) + a" + by (metis diff_add_cancel c) + have bc: "(b - c) = (1 - k) *\<^sub>R (b - a)" + by (simp add: algebra_simps c') + { assume *: "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R c) * (c - a)) has_integral i) {0..1}" + have **: "\x. ((k - x) / k) *\<^sub>R a + (x / k) *\<^sub>R c = (1 - x) *\<^sub>R a + x *\<^sub>R b" + using False apply (simp add: c' algebra_simps) + apply (simp add: real_vector.scale_left_distrib [symmetric] field_split_simps) + done + have "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral i) {0..k}" + using k has_integral_affinity01 [OF *, of "inverse k" "0"] + apply (simp add: divide_simps mult.commute [of _ "k"] image_affinity_atLeastAtMost ** c) + apply (auto dest: has_integral_cmul [where c = "inverse k"]) + done + } note fi = this + { assume *: "((\x. f ((1 - x) *\<^sub>R c + x *\<^sub>R b) * (b - c)) has_integral j) {0..1}" + have **: "\x. (((1 - x) / (1 - k)) *\<^sub>R c + ((x - k) / (1 - k)) *\<^sub>R b) = ((1 - x) *\<^sub>R a + x *\<^sub>R b)" + using k + apply (simp add: c' field_simps) + apply (simp add: scaleR_conv_of_real divide_simps) + apply (simp add: field_simps) + done + have "((\x. f ((1 - x) *\<^sub>R a + x *\<^sub>R b) * (b - a)) has_integral j) {k..1}" + using k has_integral_affinity01 [OF *, of "inverse(1 - k)" "-(k/(1 - k))"] + apply (simp add: divide_simps mult.commute [of _ "1-k"] image_affinity_atLeastAtMost ** bc) + apply (auto dest: has_integral_cmul [where k = "(1 - k) *\<^sub>R j" and c = "inverse (1 - k)"]) + done + } note fj = this + show ?thesis + using f k + apply (simp add: has_contour_integral_linepath) + apply (simp add: linepath_def) + apply (rule has_integral_combine [OF _ _ fi fj], simp_all) + done +qed + +lemma continuous_on_closed_segment_transform: + assumes f: "continuous_on (closed_segment a b) f" + and k: "0 \ k" "k \ 1" + and c: "c - a = k *\<^sub>R (b - a)" + shows "continuous_on (closed_segment a c) f" +proof - + have c': "c = (1 - k) *\<^sub>R a + k *\<^sub>R b" + using c by (simp add: algebra_simps) + have "closed_segment a c \ closed_segment a b" + by (metis c' ends_in_segment(1) in_segment(1) k subset_closed_segment) + then show "continuous_on (closed_segment a c) f" + by (rule continuous_on_subset [OF f]) +qed + +lemma contour_integral_split: + assumes f: "continuous_on (closed_segment a b) f" + and k: "0 \ k" "k \ 1" + and c: "c - a = k *\<^sub>R (b - a)" + shows "contour_integral(linepath a b) f = contour_integral(linepath a c) f + contour_integral(linepath c b) f" +proof - + have c': "c = (1 - k) *\<^sub>R a + k *\<^sub>R b" + using c by (simp add: algebra_simps) + have "closed_segment a c \ closed_segment a b" + by (metis c' ends_in_segment(1) in_segment(1) k subset_closed_segment) + moreover have "closed_segment c b \ closed_segment a b" + by (metis c' ends_in_segment(2) in_segment(1) k subset_closed_segment) + ultimately + have *: "continuous_on (closed_segment a c) f" "continuous_on (closed_segment c b) f" + by (auto intro: continuous_on_subset [OF f]) + show ?thesis + by (rule contour_integral_unique) (meson "*" c contour_integrable_continuous_linepath has_contour_integral_integral has_contour_integral_split k) +qed + +lemma contour_integral_split_linepath: + assumes f: "continuous_on (closed_segment a b) f" + and c: "c \ closed_segment a b" + shows "contour_integral(linepath a b) f = contour_integral(linepath a c) f + contour_integral(linepath c b) f" + using c by (auto simp: closed_segment_def algebra_simps intro!: contour_integral_split [OF f]) + + +subsection\Reversing the order in a double path integral\ + +text\The condition is stronger than needed but it's often true in typical situations\ + +lemma fst_im_cbox [simp]: "cbox c d \ {} \ (fst ` cbox (a,c) (b,d)) = cbox a b" + by (auto simp: cbox_Pair_eq) + +lemma snd_im_cbox [simp]: "cbox a b \ {} \ (snd ` cbox (a,c) (b,d)) = cbox c d" + by (auto simp: cbox_Pair_eq) + +proposition contour_integral_swap: + assumes fcon: "continuous_on (path_image g \ path_image h) (\(y1,y2). f y1 y2)" + and vp: "valid_path g" "valid_path h" + and gvcon: "continuous_on {0..1} (\t. vector_derivative g (at t))" + and hvcon: "continuous_on {0..1} (\t. vector_derivative h (at t))" + shows "contour_integral g (\w. contour_integral h (f w)) = + contour_integral h (\z. contour_integral g (\w. f w z))" +proof - + have gcon: "continuous_on {0..1} g" and hcon: "continuous_on {0..1} h" + using assms by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) + have fgh1: "\x. (\t. f (g x) (h t)) = (\(y1,y2). f y1 y2) \ (\t. (g x, h t))" + by (rule ext) simp + have fgh2: "\x. (\t. f (g t) (h x)) = (\(y1,y2). f y1 y2) \ (\t. (g t, h x))" + by (rule ext) simp + have fcon_im1: "\x. 0 \ x \ x \ 1 \ continuous_on ((\t. (g x, h t)) ` {0..1}) (\(x, y). f x y)" + by (rule continuous_on_subset [OF fcon]) (auto simp: path_image_def) + have fcon_im2: "\x. 0 \ x \ x \ 1 \ continuous_on ((\t. (g t, h x)) ` {0..1}) (\(x, y). f x y)" + by (rule continuous_on_subset [OF fcon]) (auto simp: path_image_def) + have "\y. y \ {0..1} \ continuous_on {0..1} (\x. f (g x) (h y))" + by (subst fgh2) (rule fcon_im2 gcon continuous_intros | simp)+ + then have vdg: "\y. y \ {0..1} \ (\x. f (g x) (h y) * vector_derivative g (at x)) integrable_on {0..1}" + using continuous_on_mult gvcon integrable_continuous_real by blast + have "(\z. vector_derivative g (at (fst z))) = (\x. vector_derivative g (at x)) \ fst" + by auto + then have gvcon': "continuous_on (cbox (0, 0) (1, 1::real)) (\x. vector_derivative g (at (fst x)))" + apply (rule ssubst) + apply (rule continuous_intros | simp add: gvcon)+ + done + have "(\z. vector_derivative h (at (snd z))) = (\x. vector_derivative h (at x)) \ snd" + by auto + then have hvcon': "continuous_on (cbox (0, 0) (1::real, 1)) (\x. vector_derivative h (at (snd x)))" + apply (rule ssubst) + apply (rule continuous_intros | simp add: hvcon)+ + done + have "(\x. f (g (fst x)) (h (snd x))) = (\(y1,y2). f y1 y2) \ (\w. ((g \ fst) w, (h \ snd) w))" + by auto + then have fgh: "continuous_on (cbox (0, 0) (1, 1)) (\x. f (g (fst x)) (h (snd x)))" + apply (rule ssubst) + apply (rule gcon hcon continuous_intros | simp)+ + apply (auto simp: path_image_def intro: continuous_on_subset [OF fcon]) + done + have "integral {0..1} (\x. contour_integral h (f (g x)) * vector_derivative g (at x)) = + integral {0..1} (\x. contour_integral h (\y. f (g x) y * vector_derivative g (at x)))" + proof (rule integral_cong [OF contour_integral_rmul [symmetric]]) + show "\x. x \ {0..1} \ f (g x) contour_integrable_on h" + unfolding contour_integrable_on + apply (rule integrable_continuous_real) + apply (rule continuous_on_mult [OF _ hvcon]) + apply (subst fgh1) + apply (rule fcon_im1 hcon continuous_intros | simp)+ + done + qed + also have "\ = integral {0..1} + (\y. contour_integral g (\x. f x (h y) * vector_derivative h (at y)))" + unfolding contour_integral_integral + apply (subst integral_swap_continuous [where 'a = real and 'b = real, of 0 0 1 1, simplified]) + apply (rule fgh gvcon' hvcon' continuous_intros | simp add: split_def)+ + unfolding integral_mult_left [symmetric] + apply (simp only: mult_ac) + done + also have "\ = contour_integral h (\z. contour_integral g (\w. f w z))" + unfolding contour_integral_integral + apply (rule integral_cong) + unfolding integral_mult_left [symmetric] + apply (simp add: algebra_simps) + done + finally show ?thesis + by (simp add: contour_integral_integral) +qed + +lemma valid_path_negatepath: "valid_path \ \ valid_path (uminus \ \)" + unfolding o_def using piecewise_C1_differentiable_neg valid_path_def by blast + +lemma has_contour_integral_negatepath: + assumes \: "valid_path \" and cint: "((\z. f (- z)) has_contour_integral - i) \" + shows "(f has_contour_integral i) (uminus \ \)" +proof - + obtain S where cont: "continuous_on {0..1} \" and "finite S" and diff: "\ C1_differentiable_on {0..1} - S" + using \ by (auto simp: valid_path_def piecewise_C1_differentiable_on_def) + have "((\x. - (f (- \ x) * vector_derivative \ (at x within {0..1}))) has_integral i) {0..1}" + using cint by (auto simp: has_contour_integral_def dest: has_integral_neg) + then + have "((\x. f (- \ x) * vector_derivative (uminus \ \) (at x within {0..1})) has_integral i) {0..1}" + proof (rule rev_iffD1 [OF _ has_integral_spike_eq]) + show "negligible S" + by (simp add: \finite S\ negligible_finite) + show "f (- \ x) * vector_derivative (uminus \ \) (at x within {0..1}) = + - (f (- \ x) * vector_derivative \ (at x within {0..1}))" + if "x \ {0..1} - S" for x + proof - + have "vector_derivative (uminus \ \) (at x within cbox 0 1) = - vector_derivative \ (at x within cbox 0 1)" + proof (rule vector_derivative_within_cbox) + show "(uminus \ \ has_vector_derivative - vector_derivative \ (at x within cbox 0 1)) (at x within cbox 0 1)" + using that unfolding o_def + by (metis C1_differentiable_on_eq UNIV_I diff differentiable_subset has_vector_derivative_minus subsetI that vector_derivative_works) + qed (use that in auto) + then show ?thesis + by simp + qed + qed + then show ?thesis by (simp add: has_contour_integral_def) +qed + +lemma contour_integrable_negatepath: + assumes \: "valid_path \" and pi: "(\z. f (- z)) contour_integrable_on \" + shows "f contour_integrable_on (uminus \ \)" + by (metis \ add.inverse_inverse contour_integrable_on_def has_contour_integral_negatepath pi) + +lemma C1_differentiable_polynomial_function: + fixes p :: "real \ 'a::euclidean_space" + shows "polynomial_function p \ p C1_differentiable_on S" + by (metis continuous_on_polymonial_function C1_differentiable_on_def has_vector_derivative_polynomial_function) + +lemma valid_path_polynomial_function: + fixes p :: "real \ 'a::euclidean_space" + shows "polynomial_function p \ valid_path p" +by (force simp: valid_path_def piecewise_C1_differentiable_on_def continuous_on_polymonial_function C1_differentiable_polynomial_function) + +lemma valid_path_subpath_trivial [simp]: + fixes g :: "real \ 'a::euclidean_space" + shows "z \ g x \ valid_path (subpath x x g)" + by (simp add: subpath_def valid_path_polynomial_function) + +subsection\Partial circle path\ + +definition\<^marker>\tag important\ part_circlepath :: "[complex, real, real, real, real] \ complex" + where "part_circlepath z r s t \ \x. z + of_real r * exp (\ * of_real (linepath s t x))" + +lemma pathstart_part_circlepath [simp]: + "pathstart(part_circlepath z r s t) = z + r*exp(\ * s)" +by (metis part_circlepath_def pathstart_def pathstart_linepath) + +lemma pathfinish_part_circlepath [simp]: + "pathfinish(part_circlepath z r s t) = z + r*exp(\*t)" +by (metis part_circlepath_def pathfinish_def pathfinish_linepath) + +lemma reversepath_part_circlepath[simp]: + "reversepath (part_circlepath z r s t) = part_circlepath z r t s" + unfolding part_circlepath_def reversepath_def linepath_def + by (auto simp:algebra_simps) + +lemma has_vector_derivative_part_circlepath [derivative_intros]: + "((part_circlepath z r s t) has_vector_derivative + (\ * r * (of_real t - of_real s) * exp(\ * linepath s t x))) + (at x within X)" + apply (simp add: part_circlepath_def linepath_def scaleR_conv_of_real) + apply (rule has_vector_derivative_real_field) + apply (rule derivative_eq_intros | simp)+ + done + +lemma differentiable_part_circlepath: + "part_circlepath c r a b differentiable at x within A" + using has_vector_derivative_part_circlepath[of c r a b x A] differentiableI_vector by blast + +lemma vector_derivative_part_circlepath: + "vector_derivative (part_circlepath z r s t) (at x) = + \ * r * (of_real t - of_real s) * exp(\ * linepath s t x)" + using has_vector_derivative_part_circlepath vector_derivative_at by blast + +lemma vector_derivative_part_circlepath01: + "\0 \ x; x \ 1\ + \ vector_derivative (part_circlepath z r s t) (at x within {0..1}) = + \ * r * (of_real t - of_real s) * exp(\ * linepath s t x)" + using has_vector_derivative_part_circlepath + by (auto simp: vector_derivative_at_within_ivl) + +lemma valid_path_part_circlepath [simp]: "valid_path (part_circlepath z r s t)" + apply (simp add: valid_path_def) + apply (rule C1_differentiable_imp_piecewise) + apply (auto simp: C1_differentiable_on_eq vector_derivative_works vector_derivative_part_circlepath has_vector_derivative_part_circlepath + intro!: continuous_intros) + done + +lemma path_part_circlepath [simp]: "path (part_circlepath z r s t)" + by (simp add: valid_path_imp_path) + +proposition path_image_part_circlepath: + assumes "s \ t" + shows "path_image (part_circlepath z r s t) = {z + r * exp(\ * of_real x) | x. s \ x \ x \ t}" +proof - + { fix z::real + assume "0 \ z" "z \ 1" + with \s \ t\ have "\x. (exp (\ * linepath s t z) = exp (\ * of_real x)) \ s \ x \ x \ t" + apply (rule_tac x="(1 - z) * s + z * t" in exI) + apply (simp add: linepath_def scaleR_conv_of_real algebra_simps) + apply (rule conjI) + using mult_right_mono apply blast + using affine_ineq by (metis "mult.commute") + } + moreover + { fix z + assume "s \ z" "z \ t" + then have "z + of_real r * exp (\ * of_real z) \ (\x. z + of_real r * exp (\ * linepath s t x)) ` {0..1}" + apply (rule_tac x="(z - s)/(t - s)" in image_eqI) + apply (simp add: linepath_def scaleR_conv_of_real divide_simps exp_eq) + apply (auto simp: field_split_simps) + done + } + ultimately show ?thesis + by (fastforce simp add: path_image_def part_circlepath_def) +qed + +lemma path_image_part_circlepath': + "path_image (part_circlepath z r s t) = (\x. z + r * cis x) ` closed_segment s t" +proof - + have "path_image (part_circlepath z r s t) = + (\x. z + r * exp(\ * of_real x)) ` linepath s t ` {0..1}" + by (simp add: image_image path_image_def part_circlepath_def) + also have "linepath s t ` {0..1} = closed_segment s t" + by (rule linepath_image_01) + finally show ?thesis by (simp add: cis_conv_exp) +qed + +lemma path_image_part_circlepath_subset: + "\s \ t; 0 \ r\ \ path_image(part_circlepath z r s t) \ sphere z r" +by (auto simp: path_image_part_circlepath sphere_def dist_norm algebra_simps norm_mult) + +lemma in_path_image_part_circlepath: + assumes "w \ path_image(part_circlepath z r s t)" "s \ t" "0 \ r" + shows "norm(w - z) = r" +proof - + have "w \ {c. dist z c = r}" + by (metis (no_types) path_image_part_circlepath_subset sphere_def subset_eq assms) + thus ?thesis + by (simp add: dist_norm norm_minus_commute) +qed + +lemma path_image_part_circlepath_subset': + assumes "r \ 0" + shows "path_image (part_circlepath z r s t) \ sphere z r" +proof (cases "s \ t") + case True + thus ?thesis using path_image_part_circlepath_subset[of s t r z] assms by simp +next + case False + thus ?thesis using path_image_part_circlepath_subset[of t s r z] assms + by (subst reversepath_part_circlepath [symmetric], subst path_image_reversepath) simp_all +qed + +lemma part_circlepath_cnj: "cnj (part_circlepath c r a b x) = part_circlepath (cnj c) r (-a) (-b) x" + by (simp add: part_circlepath_def exp_cnj linepath_def algebra_simps) + +lemma contour_integral_bound_part_circlepath: + assumes "f contour_integrable_on part_circlepath c r a b" + assumes "B \ 0" "r \ 0" "\x. x \ path_image (part_circlepath c r a b) \ norm (f x) \ B" + shows "norm (contour_integral (part_circlepath c r a b) f) \ B * r * \b - a\" +proof - + let ?I = "integral {0..1} (\x. f (part_circlepath c r a b x) * \ * of_real (r * (b - a)) * + exp (\ * linepath a b x))" + have "norm ?I \ integral {0..1} (\x::real. B * 1 * (r * \b - a\) * 1)" + proof (rule integral_norm_bound_integral, goal_cases) + case 1 + with assms(1) show ?case + by (simp add: contour_integrable_on vector_derivative_part_circlepath mult_ac) + next + case (3 x) + with assms(2-) show ?case unfolding norm_mult norm_of_real abs_mult + by (intro mult_mono) (auto simp: path_image_def) + qed auto + also have "?I = contour_integral (part_circlepath c r a b) f" + by (simp add: contour_integral_integral vector_derivative_part_circlepath mult_ac) + finally show ?thesis by simp +qed + +lemma has_contour_integral_part_circlepath_iff: + assumes "a < b" + shows "(f has_contour_integral I) (part_circlepath c r a b) \ + ((\t. f (c + r * cis t) * r * \ * cis t) has_integral I) {a..b}" +proof - + have "(f has_contour_integral I) (part_circlepath c r a b) \ + ((\x. f (part_circlepath c r a b x) * vector_derivative (part_circlepath c r a b) + (at x within {0..1})) has_integral I) {0..1}" + unfolding has_contour_integral_def .. + also have "\ \ ((\x. f (part_circlepath c r a b x) * r * (b - a) * \ * + cis (linepath a b x)) has_integral I) {0..1}" + by (intro has_integral_cong, subst vector_derivative_part_circlepath01) + (simp_all add: cis_conv_exp) + also have "\ \ ((\x. f (c + r * exp (\ * linepath (of_real a) (of_real b) x)) * + r * \ * exp (\ * linepath (of_real a) (of_real b) x) * + vector_derivative (linepath (of_real a) (of_real b)) + (at x within {0..1})) has_integral I) {0..1}" + by (intro has_integral_cong, subst vector_derivative_linepath_within) + (auto simp: part_circlepath_def cis_conv_exp of_real_linepath [symmetric]) + also have "\ \ ((\z. f (c + r * exp (\ * z)) * r * \ * exp (\ * z)) has_contour_integral I) + (linepath (of_real a) (of_real b))" + by (simp add: has_contour_integral_def) + also have "\ \ ((\t. f (c + r * cis t) * r * \ * cis t) has_integral I) {a..b}" using assms + by (subst has_contour_integral_linepath_Reals_iff) (simp_all add: cis_conv_exp) + finally show ?thesis . +qed + +lemma contour_integrable_part_circlepath_iff: + assumes "a < b" + shows "f contour_integrable_on (part_circlepath c r a b) \ + (\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" + using assms by (auto simp: contour_integrable_on_def integrable_on_def + has_contour_integral_part_circlepath_iff) + +lemma contour_integral_part_circlepath_eq: + assumes "a < b" + shows "contour_integral (part_circlepath c r a b) f = + integral {a..b} (\t. f (c + r * cis t) * r * \ * cis t)" +proof (cases "f contour_integrable_on part_circlepath c r a b") + case True + hence "(\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" + using assms by (simp add: contour_integrable_part_circlepath_iff) + with True show ?thesis + using has_contour_integral_part_circlepath_iff[OF assms] + contour_integral_unique has_integral_integrable_integral by blast +next + case False + hence "\(\t. f (c + r * cis t) * r * \ * cis t) integrable_on {a..b}" + using assms by (simp add: contour_integrable_part_circlepath_iff) + with False show ?thesis + by (simp add: not_integrable_contour_integral not_integrable_integral) +qed + +lemma contour_integral_part_circlepath_reverse: + "contour_integral (part_circlepath c r a b) f = -contour_integral (part_circlepath c r b a) f" + by (subst reversepath_part_circlepath [symmetric], subst contour_integral_reversepath) simp_all + +lemma contour_integral_part_circlepath_reverse': + "b < a \ contour_integral (part_circlepath c r a b) f = + -contour_integral (part_circlepath c r b a) f" + by (rule contour_integral_part_circlepath_reverse) + +lemma finite_bounded_log: "finite {z::complex. norm z \ b \ exp z = w}" +proof (cases "w = 0") + case True then show ?thesis by auto +next + case False + have *: "finite {x. cmod (complex_of_real (2 * real_of_int x * pi) * \) \ b + cmod (Ln w)}" + apply (simp add: norm_mult finite_int_iff_bounded_le) + apply (rule_tac x="\(b + cmod (Ln w)) / (2*pi)\" in exI) + apply (auto simp: field_split_simps le_floor_iff) + done + have [simp]: "\P f. {z. P z \ (\n. z = f n)} = f ` {n. P (f n)}" + by blast + show ?thesis + apply (subst exp_Ln [OF False, symmetric]) + apply (simp add: exp_eq) + using norm_add_leD apply (fastforce intro: finite_subset [OF _ *]) + done +qed + +lemma finite_bounded_log2: + fixes a::complex + assumes "a \ 0" + shows "finite {z. norm z \ b \ exp(a*z) = w}" +proof - + have *: "finite ((\z. z / a) ` {z. cmod z \ b * cmod a \ exp z = w})" + by (rule finite_imageI [OF finite_bounded_log]) + show ?thesis + by (rule finite_subset [OF _ *]) (force simp: assms norm_mult) +qed + +lemma has_contour_integral_bound_part_circlepath_strong: + assumes fi: "(f has_contour_integral i) (part_circlepath z r s t)" + and "finite k" and le: "0 \ B" "0 < r" "s \ t" + and B: "\x. x \ path_image(part_circlepath z r s t) - k \ norm(f x) \ B" + shows "cmod i \ B * r * (t - s)" +proof - + consider "s = t" | "s < t" using \s \ t\ by linarith + then show ?thesis + proof cases + case 1 with fi [unfolded has_contour_integral] + have "i = 0" by (simp add: vector_derivative_part_circlepath) + with assms show ?thesis by simp + next + case 2 + have [simp]: "\r\ = r" using \r > 0\ by linarith + have [simp]: "cmod (complex_of_real t - complex_of_real s) = t-s" + by (metis "2" abs_of_pos diff_gt_0_iff_gt norm_of_real of_real_diff) + have "finite (part_circlepath z r s t -` {y} \ {0..1})" if "y \ k" for y + proof - + define w where "w = (y - z)/of_real r / exp(\ * of_real s)" + have fin: "finite (of_real -` {z. cmod z \ 1 \ exp (\ * complex_of_real (t - s) * z) = w})" + apply (rule finite_vimageI [OF finite_bounded_log2]) + using \s < t\ apply (auto simp: inj_of_real) + done + show ?thesis + apply (simp add: part_circlepath_def linepath_def vimage_def) + apply (rule finite_subset [OF _ fin]) + using le + apply (auto simp: w_def algebra_simps scaleR_conv_of_real exp_add exp_diff) + done + qed + then have fin01: "finite ((part_circlepath z r s t) -` k \ {0..1})" + by (rule finite_finite_vimage_IntI [OF \finite k\]) + have **: "((\x. if (part_circlepath z r s t x) \ k then 0 + else f(part_circlepath z r s t x) * + vector_derivative (part_circlepath z r s t) (at x)) has_integral i) {0..1}" + by (rule has_integral_spike [OF negligible_finite [OF fin01]]) (use fi has_contour_integral in auto) + have *: "\x. \0 \ x; x \ 1; part_circlepath z r s t x \ k\ \ cmod (f (part_circlepath z r s t x)) \ B" + by (auto intro!: B [unfolded path_image_def image_def, simplified]) + show ?thesis + apply (rule has_integral_bound [where 'a=real, simplified, OF _ **, simplified]) + using assms apply force + apply (simp add: norm_mult vector_derivative_part_circlepath) + using le * "2" \r > 0\ by auto + qed +qed + +lemma has_contour_integral_bound_part_circlepath: + "\(f has_contour_integral i) (part_circlepath z r s t); + 0 \ B; 0 < r; s \ t; + \x. x \ path_image(part_circlepath z r s t) \ norm(f x) \ B\ + \ norm i \ B*r*(t - s)" + by (auto intro: has_contour_integral_bound_part_circlepath_strong) + +lemma contour_integrable_continuous_part_circlepath: + "continuous_on (path_image (part_circlepath z r s t)) f + \ f contour_integrable_on (part_circlepath z r s t)" + apply (simp add: contour_integrable_on has_contour_integral_def vector_derivative_part_circlepath path_image_def) + apply (rule integrable_continuous_real) + apply (fast intro: path_part_circlepath [unfolded path_def] continuous_intros continuous_on_compose2 [where g=f, OF _ _ order_refl]) + done + +lemma simple_path_part_circlepath: + "simple_path(part_circlepath z r s t) \ (r \ 0 \ s \ t \ \s - t\ \ 2*pi)" +proof (cases "r = 0 \ s = t") + case True + then show ?thesis + unfolding part_circlepath_def simple_path_def + by (rule disjE) (force intro: bexI [where x = "1/4"] bexI [where x = "1/3"])+ +next + case False then have "r \ 0" "s \ t" by auto + have *: "\x y z s t. \*((1 - x) * s + x * t) = \*(((1 - y) * s + y * t)) + z \ \*(x - y) * (t - s) = z" + by (simp add: algebra_simps) + have abs01: "\x y::real. 0 \ x \ x \ 1 \ 0 \ y \ y \ 1 + \ (x = y \ x = 0 \ y = 1 \ x = 1 \ y = 0 \ \x - y\ \ {0,1})" + by auto + have **: "\x y. (\n. (complex_of_real x - of_real y) * (of_real t - of_real s) = 2 * (of_int n * of_real pi)) \ + (\n. \x - y\ * (t - s) = 2 * (of_int n * pi))" + by (force simp: algebra_simps abs_if dest: arg_cong [where f=Re] arg_cong [where f=complex_of_real] + intro: exI [where x = "-n" for n]) + have 1: "\s - t\ \ 2 * pi" + if "\x. 0 \ x \ x \ 1 \ (\n. x * (t - s) = 2 * (real_of_int n * pi)) \ x = 0 \ x = 1" + proof (rule ccontr) + assume "\ \s - t\ \ 2 * pi" + then have *: "\n. t - s \ of_int n * \s - t\" + using False that [of "2*pi / \t - s\"] + by (simp add: abs_minus_commute divide_simps) + show False + using * [of 1] * [of "-1"] by auto + qed + have 2: "\s - t\ = \2 * (real_of_int n * pi) / x\" if "x \ 0" "x * (t - s) = 2 * (real_of_int n * pi)" for x n + proof - + have "t-s = 2 * (real_of_int n * pi)/x" + using that by (simp add: field_simps) + then show ?thesis by (metis abs_minus_commute) + qed + have abs_away: "\P. (\x\{0..1}. \y\{0..1}. P \x - y\) \ (\x::real. 0 \ x \ x \ 1 \ P x)" + by force + show ?thesis using False + apply (simp add: simple_path_def) + apply (simp add: part_circlepath_def linepath_def exp_eq * ** abs01 del: Set.insert_iff) + apply (subst abs_away) + apply (auto simp: 1) + apply (rule ccontr) + apply (auto simp: 2 field_split_simps abs_mult dest: of_int_leD) + done +qed + +lemma arc_part_circlepath: + assumes "r \ 0" "s \ t" "\s - t\ < 2*pi" + shows "arc (part_circlepath z r s t)" +proof - + have *: "x = y" if eq: "\ * (linepath s t x) = \ * (linepath s t y) + 2 * of_int n * complex_of_real pi * \" + and x: "x \ {0..1}" and y: "y \ {0..1}" for x y n + proof (rule ccontr) + assume "x \ y" + have "(linepath s t x) = (linepath s t y) + 2 * of_int n * complex_of_real pi" + by (metis add_divide_eq_iff complex_i_not_zero mult.commute nonzero_mult_div_cancel_left eq) + then have "s*y + t*x = s*x + (t*y + of_int n * (pi * 2))" + by (force simp: algebra_simps linepath_def dest: arg_cong [where f=Re]) + with \x \ y\ have st: "s-t = (of_int n * (pi * 2) / (y-x))" + by (force simp: field_simps) + have "\real_of_int n\ < \y - x\" + using assms \x \ y\ by (simp add: st abs_mult field_simps) + then show False + using assms x y st by (auto dest: of_int_lessD) + qed + show ?thesis + using assms + apply (simp add: arc_def) + apply (simp add: part_circlepath_def inj_on_def exp_eq) + apply (blast intro: *) + done +qed + +subsection\Special case of one complete circle\ + +definition\<^marker>\tag important\ circlepath :: "[complex, real, real] \ complex" + where "circlepath z r \ part_circlepath z r 0 (2*pi)" + +lemma circlepath: "circlepath z r = (\x. z + r * exp(2 * of_real pi * \ * of_real x))" + by (simp add: circlepath_def part_circlepath_def linepath_def algebra_simps) + +lemma pathstart_circlepath [simp]: "pathstart (circlepath z r) = z + r" + by (simp add: circlepath_def) + +lemma pathfinish_circlepath [simp]: "pathfinish (circlepath z r) = z + r" + by (simp add: circlepath_def) (metis exp_two_pi_i mult.commute) + +lemma circlepath_minus: "circlepath z (-r) x = circlepath z r (x + 1/2)" +proof - + have "z + of_real r * exp (2 * pi * \ * (x + 1/2)) = + z + of_real r * exp (2 * pi * \ * x + pi * \)" + by (simp add: divide_simps) (simp add: algebra_simps) + also have "\ = z - r * exp (2 * pi * \ * x)" + by (simp add: exp_add) + finally show ?thesis + by (simp add: circlepath path_image_def sphere_def dist_norm) +qed + +lemma circlepath_add1: "circlepath z r (x+1) = circlepath z r x" + using circlepath_minus [of z r "x+1/2"] circlepath_minus [of z "-r" x] + by (simp add: add.commute) + +lemma circlepath_add_half: "circlepath z r (x + 1/2) = circlepath z r (x - 1/2)" + using circlepath_add1 [of z r "x-1/2"] + by (simp add: add.commute) + +lemma path_image_circlepath_minus_subset: + "path_image (circlepath z (-r)) \ path_image (circlepath z r)" + apply (simp add: path_image_def image_def circlepath_minus, clarify) + apply (case_tac "xa \ 1/2", force) + apply (force simp: circlepath_add_half)+ + done + +lemma path_image_circlepath_minus: "path_image (circlepath z (-r)) = path_image (circlepath z r)" + using path_image_circlepath_minus_subset by fastforce + +lemma has_vector_derivative_circlepath [derivative_intros]: + "((circlepath z r) has_vector_derivative (2 * pi * \ * r * exp (2 * of_real pi * \ * of_real x))) + (at x within X)" + apply (simp add: circlepath_def scaleR_conv_of_real) + apply (rule derivative_eq_intros) + apply (simp add: algebra_simps) + done + +lemma vector_derivative_circlepath: + "vector_derivative (circlepath z r) (at x) = + 2 * pi * \ * r * exp(2 * of_real pi * \ * x)" +using has_vector_derivative_circlepath vector_derivative_at by blast + +lemma vector_derivative_circlepath01: + "\0 \ x; x \ 1\ + \ vector_derivative (circlepath z r) (at x within {0..1}) = + 2 * pi * \ * r * exp(2 * of_real pi * \ * x)" + using has_vector_derivative_circlepath + by (auto simp: vector_derivative_at_within_ivl) + +lemma valid_path_circlepath [simp]: "valid_path (circlepath z r)" + by (simp add: circlepath_def) + +lemma path_circlepath [simp]: "path (circlepath z r)" + by (simp add: valid_path_imp_path) + +lemma path_image_circlepath_nonneg: + assumes "0 \ r" shows "path_image (circlepath z r) = sphere z r" +proof - + have *: "x \ (\u. z + (cmod (x - z)) * exp (\ * (of_real u * (of_real pi * 2)))) ` {0..1}" for x + proof (cases "x = z") + case True then show ?thesis by force + next + case False + define w where "w = x - z" + then have "w \ 0" by (simp add: False) + have **: "\t. \Re w = cos t * cmod w; Im w = sin t * cmod w\ \ w = of_real (cmod w) * exp (\ * t)" + using cis_conv_exp complex_eq_iff by auto + show ?thesis + apply (rule sincos_total_2pi [of "Re(w/of_real(norm w))" "Im(w/of_real(norm w))"]) + apply (simp add: divide_simps \w \ 0\ cmod_power2 [symmetric]) + apply (rule_tac x="t / (2*pi)" in image_eqI) + apply (simp add: field_simps \w \ 0\) + using False ** + apply (auto simp: w_def) + done + qed + show ?thesis + unfolding circlepath path_image_def sphere_def dist_norm + by (force simp: assms algebra_simps norm_mult norm_minus_commute intro: *) +qed + +lemma path_image_circlepath [simp]: + "path_image (circlepath z r) = sphere z \r\" + using path_image_circlepath_minus + by (force simp: path_image_circlepath_nonneg abs_if) + +lemma has_contour_integral_bound_circlepath_strong: + "\(f has_contour_integral i) (circlepath z r); + finite k; 0 \ B; 0 < r; + \x. \norm(x - z) = r; x \ k\ \ norm(f x) \ B\ + \ norm i \ B*(2*pi*r)" + unfolding circlepath_def + by (auto simp: algebra_simps in_path_image_part_circlepath dest!: has_contour_integral_bound_part_circlepath_strong) + +lemma has_contour_integral_bound_circlepath: + "\(f has_contour_integral i) (circlepath z r); + 0 \ B; 0 < r; \x. norm(x - z) = r \ norm(f x) \ B\ + \ norm i \ B*(2*pi*r)" + by (auto intro: has_contour_integral_bound_circlepath_strong) + +lemma contour_integrable_continuous_circlepath: + "continuous_on (path_image (circlepath z r)) f + \ f contour_integrable_on (circlepath z r)" + by (simp add: circlepath_def contour_integrable_continuous_part_circlepath) + +lemma simple_path_circlepath: "simple_path(circlepath z r) \ (r \ 0)" + by (simp add: circlepath_def simple_path_part_circlepath) + +lemma notin_path_image_circlepath [simp]: "cmod (w - z) < r \ w \ path_image (circlepath z r)" + by (simp add: sphere_def dist_norm norm_minus_commute) + +lemma contour_integral_circlepath: + assumes "r > 0" + shows "contour_integral (circlepath z r) (\w. 1 / (w - z)) = 2 * complex_of_real pi * \" +proof (rule contour_integral_unique) + show "((\w. 1 / (w - z)) has_contour_integral 2 * complex_of_real pi * \) (circlepath z r)" + unfolding has_contour_integral_def using assms + apply (subst has_integral_cong) + apply (simp add: vector_derivative_circlepath01) + using has_integral_const_real [of _ 0 1] apply (force simp: circlepath) + done +qed + +subsection\ Uniform convergence of path integral\ + +text\Uniform convergence when the derivative of the path is bounded, and in particular for the special case of a circle.\ + +proposition contour_integral_uniform_limit: + assumes ev_fint: "eventually (\n::'a. (f n) contour_integrable_on \) F" + and ul_f: "uniform_limit (path_image \) f l F" + and noleB: "\t. t \ {0..1} \ norm (vector_derivative \ (at t)) \ B" + and \: "valid_path \" + and [simp]: "\ trivial_limit F" + shows "l contour_integrable_on \" "((\n. contour_integral \ (f n)) \ contour_integral \ l) F" +proof - + have "0 \ B" by (meson noleB [of 0] atLeastAtMost_iff norm_ge_zero order_refl order_trans zero_le_one) + { fix e::real + assume "0 < e" + then have "0 < e / (\B\ + 1)" by simp + then have "\\<^sub>F n in F. \x\path_image \. cmod (f n x - l x) < e / (\B\ + 1)" + using ul_f [unfolded uniform_limit_iff dist_norm] by auto + with ev_fint + obtain a where fga: "\x. x \ {0..1} \ cmod (f a (\ x) - l (\ x)) < e / (\B\ + 1)" + and inta: "(\t. f a (\ t) * vector_derivative \ (at t)) integrable_on {0..1}" + using eventually_happens [OF eventually_conj] + by (fastforce simp: contour_integrable_on path_image_def) + have Ble: "B * e / (\B\ + 1) \ e" + using \0 \ B\ \0 < e\ by (simp add: field_split_simps) + have "\h. (\x\{0..1}. cmod (l (\ x) * vector_derivative \ (at x) - h x) \ e) \ h integrable_on {0..1}" + proof (intro exI conjI ballI) + show "cmod (l (\ x) * vector_derivative \ (at x) - f a (\ x) * vector_derivative \ (at x)) \ e" + if "x \ {0..1}" for x + apply (rule order_trans [OF _ Ble]) + using noleB [OF that] fga [OF that] \0 \ B\ \0 < e\ + apply (simp add: norm_mult left_diff_distrib [symmetric] norm_minus_commute divide_simps) + apply (fastforce simp: mult_ac dest: mult_mono [OF less_imp_le]) + done + qed (rule inta) + } + then show lintg: "l contour_integrable_on \" + unfolding contour_integrable_on by (metis (mono_tags, lifting)integrable_uniform_limit_real) + { fix e::real + define B' where "B' = B + 1" + have B': "B' > 0" "B' > B" using \0 \ B\ by (auto simp: B'_def) + assume "0 < e" + then have ev_no': "\\<^sub>F n in F. \x\path_image \. 2 * cmod (f n x - l x) < e / B'" + using ul_f [unfolded uniform_limit_iff dist_norm, rule_format, of "e / B' / 2"] B' + by (simp add: field_simps) + have ie: "integral {0..1::real} (\x. e / 2) < e" using \0 < e\ by simp + have *: "cmod (f x (\ t) * vector_derivative \ (at t) - l (\ t) * vector_derivative \ (at t)) \ e / 2" + if t: "t\{0..1}" and leB': "2 * cmod (f x (\ t) - l (\ t)) < e / B'" for x t + proof - + have "2 * cmod (f x (\ t) - l (\ t)) * cmod (vector_derivative \ (at t)) \ e * (B/ B')" + using mult_mono [OF less_imp_le [OF leB'] noleB] B' \0 < e\ t by auto + also have "\ < e" + by (simp add: B' \0 < e\ mult_imp_div_pos_less) + finally have "2 * cmod (f x (\ t) - l (\ t)) * cmod (vector_derivative \ (at t)) < e" . + then show ?thesis + by (simp add: left_diff_distrib [symmetric] norm_mult) + qed + have le_e: "\x. \\xa\{0..1}. 2 * cmod (f x (\ xa) - l (\ xa)) < e / B'; f x contour_integrable_on \\ + \ cmod (integral {0..1} + (\u. f x (\ u) * vector_derivative \ (at u) - l (\ u) * vector_derivative \ (at u))) < e" + apply (rule le_less_trans [OF integral_norm_bound_integral ie]) + apply (simp add: lintg integrable_diff contour_integrable_on [symmetric]) + apply (blast intro: *)+ + done + have "\\<^sub>F x in F. dist (contour_integral \ (f x)) (contour_integral \ l) < e" + apply (rule eventually_mono [OF eventually_conj [OF ev_no' ev_fint]]) + apply (simp add: dist_norm contour_integrable_on path_image_def contour_integral_integral) + apply (simp add: lintg integral_diff [symmetric] contour_integrable_on [symmetric] le_e) + done + } + then show "((\n. contour_integral \ (f n)) \ contour_integral \ l) F" + by (rule tendstoI) +qed + +corollary\<^marker>\tag unimportant\ contour_integral_uniform_limit_circlepath: + assumes "\\<^sub>F n::'a in F. (f n) contour_integrable_on (circlepath z r)" + and "uniform_limit (sphere z r) f l F" + and "\ trivial_limit F" "0 < r" + shows "l contour_integrable_on (circlepath z r)" + "((\n. contour_integral (circlepath z r) (f n)) \ contour_integral (circlepath z r) l) F" + using assms by (auto simp: vector_derivative_circlepath norm_mult intro!: contour_integral_uniform_limit) + +end \ No newline at end of file diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Great_Picard.thy --- a/src/HOL/Complex_Analysis/Great_Picard.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Great_Picard.thy Mon Dec 02 17:51:54 2019 +0100 @@ -4,7 +4,6 @@ theory Great_Picard imports Conformal_Mappings - begin subsection\Schottky's theorem\ diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Residue_Theorem.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Complex_Analysis/Residue_Theorem.thy Mon Dec 02 17:51:54 2019 +0100 @@ -0,0 +1,862 @@ +section \The Residue Theorem, the Argument Principle and Rouch\'{e}'s Theorem\ +theory Residue_Theorem + imports Complex_Residues +begin + +subsection \Cauchy's residue theorem\ + +lemma get_integrable_path: + assumes "open s" "connected (s-pts)" "finite pts" "f holomorphic_on (s-pts) " "a\s-pts" "b\s-pts" + obtains g where "valid_path g" "pathstart g = a" "pathfinish g = b" + "path_image g \ s-pts" "f contour_integrable_on g" using assms +proof (induct arbitrary:s thesis a rule:finite_induct[OF \finite pts\]) + case 1 + obtain g where "valid_path g" "path_image g \ s" "pathstart g = a" "pathfinish g = b" + using connected_open_polynomial_connected[OF \open s\,of a b ] \connected (s - {})\ + valid_path_polynomial_function "1.prems"(6) "1.prems"(7) by auto + moreover have "f contour_integrable_on g" + using contour_integrable_holomorphic_simple[OF _ \open s\ \valid_path g\ \path_image g \ s\,of f] + \f holomorphic_on s - {}\ + by auto + ultimately show ?case using "1"(1)[of g] by auto +next + case idt:(2 p pts) + obtain e where "e>0" and e:"\w\ball a e. w \ s \ (w \ a \ w \ insert p pts)" + using finite_ball_avoid[OF \open s\ \finite (insert p pts)\, of a] + \a \ s - insert p pts\ + by auto + define a' where "a' \ a+e/2" + have "a'\s-{p} -pts" using e[rule_format,of "a+e/2"] \e>0\ + by (auto simp add:dist_complex_def a'_def) + then obtain g' where g'[simp]:"valid_path g'" "pathstart g' = a'" "pathfinish g' = b" + "path_image g' \ s - {p} - pts" "f contour_integrable_on g'" + using idt.hyps(3)[of a' "s-{p}"] idt.prems idt.hyps(1) + by (metis Diff_insert2 open_delete) + define g where "g \ linepath a a' +++ g'" + have "valid_path g" unfolding g_def by (auto intro: valid_path_join) + moreover have "pathstart g = a" and "pathfinish g = b" unfolding g_def by auto + moreover have "path_image g \ s - insert p pts" unfolding g_def + proof (rule subset_path_image_join) + have "closed_segment a a' \ ball a e" using \e>0\ + by (auto dest!:segment_bound1 simp:a'_def dist_complex_def norm_minus_commute) + then show "path_image (linepath a a') \ s - insert p pts" using e idt(9) + by auto + next + show "path_image g' \ s - insert p pts" using g'(4) by blast + qed + moreover have "f contour_integrable_on g" + proof - + have "closed_segment a a' \ ball a e" using \e>0\ + by (auto dest!:segment_bound1 simp:a'_def dist_complex_def norm_minus_commute) + then have "continuous_on (closed_segment a a') f" + using e idt.prems(6) holomorphic_on_imp_continuous_on[OF idt.prems(5)] + apply (elim continuous_on_subset) + by auto + then have "f contour_integrable_on linepath a a'" + using contour_integrable_continuous_linepath by auto + then show ?thesis unfolding g_def + apply (rule contour_integrable_joinI) + by (auto simp add: \e>0\) + qed + ultimately show ?case using idt.prems(1)[of g] by auto +qed + +lemma Cauchy_theorem_aux: + assumes "open s" "connected (s-pts)" "finite pts" "pts \ s" "f holomorphic_on s-pts" + "valid_path g" "pathfinish g = pathstart g" "path_image g \ s-pts" + "\z. (z \ s) \ winding_number g z = 0" + "\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" + shows "contour_integral g f = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" + using assms +proof (induct arbitrary:s g rule:finite_induct[OF \finite pts\]) + case 1 + then show ?case by (simp add: Cauchy_theorem_global contour_integral_unique) +next + case (2 p pts) + note fin[simp] = \finite (insert p pts)\ + and connected = \connected (s - insert p pts)\ + and valid[simp] = \valid_path g\ + and g_loop[simp] = \pathfinish g = pathstart g\ + and holo[simp]= \f holomorphic_on s - insert p pts\ + and path_img = \path_image g \ s - insert p pts\ + and winding = \\z. z \ s \ winding_number g z = 0\ + and h = \\pa\s. 0 < h pa \ (\w\cball pa (h pa). w \ s \ (w \ pa \ w \ insert p pts))\ + have "h p>0" and "p\s" + and h_p: "\w\cball p (h p). w \ s \ (w \ p \ w \ insert p pts)" + using h \insert p pts \ s\ by auto + obtain pg where pg[simp]: "valid_path pg" "pathstart pg = pathstart g" "pathfinish pg=p+h p" + "path_image pg \ s-insert p pts" "f contour_integrable_on pg" + proof - + have "p + h p\cball p (h p)" using h[rule_format,of p] + by (simp add: \p \ s\ dist_norm) + then have "p + h p \ s - insert p pts" using h[rule_format,of p] \insert p pts \ s\ + by fastforce + moreover have "pathstart g \ s - insert p pts " using path_img by auto + ultimately show ?thesis + using get_integrable_path[OF \open s\ connected fin holo,of "pathstart g" "p+h p"] that + by blast + qed + obtain n::int where "n=winding_number g p" + using integer_winding_number[OF _ g_loop,of p] valid path_img + by (metis DiffD2 Ints_cases insertI1 subset_eq valid_path_imp_path) + define p_circ where "p_circ \ circlepath p (h p)" + define p_circ_pt where "p_circ_pt \ linepath (p+h p) (p+h p)" + define n_circ where "n_circ \ \n. ((+++) p_circ ^^ n) p_circ_pt" + define cp where "cp \ if n\0 then reversepath (n_circ (nat n)) else n_circ (nat (- n))" + have n_circ:"valid_path (n_circ k)" + "winding_number (n_circ k) p = k" + "pathstart (n_circ k) = p + h p" "pathfinish (n_circ k) = p + h p" + "path_image (n_circ k) = (if k=0 then {p + h p} else sphere p (h p))" + "p \ path_image (n_circ k)" + "\p'. p'\s - pts \ winding_number (n_circ k) p'=0 \ p'\path_image (n_circ k)" + "f contour_integrable_on (n_circ k)" + "contour_integral (n_circ k) f = k * contour_integral p_circ f" + for k + proof (induct k) + case 0 + show "valid_path (n_circ 0)" + and "path_image (n_circ 0) = (if 0=0 then {p + h p} else sphere p (h p))" + and "winding_number (n_circ 0) p = of_nat 0" + and "pathstart (n_circ 0) = p + h p" + and "pathfinish (n_circ 0) = p + h p" + and "p \ path_image (n_circ 0)" + unfolding n_circ_def p_circ_pt_def using \h p > 0\ + by (auto simp add: dist_norm) + show "winding_number (n_circ 0) p'=0 \ p'\path_image (n_circ 0)" when "p'\s- pts" for p' + unfolding n_circ_def p_circ_pt_def + apply (auto intro!:winding_number_trivial) + by (metis Diff_iff pathfinish_in_path_image pg(3) pg(4) subsetCE subset_insertI that)+ + show "f contour_integrable_on (n_circ 0)" + unfolding n_circ_def p_circ_pt_def + by (auto intro!:contour_integrable_continuous_linepath simp add:continuous_on_sing) + show "contour_integral (n_circ 0) f = of_nat 0 * contour_integral p_circ f" + unfolding n_circ_def p_circ_pt_def by auto + next + case (Suc k) + have n_Suc:"n_circ (Suc k) = p_circ +++ n_circ k" unfolding n_circ_def by auto + have pcirc:"p \ path_image p_circ" "valid_path p_circ" "pathfinish p_circ = pathstart (n_circ k)" + using Suc(3) unfolding p_circ_def using \h p > 0\ by (auto simp add: p_circ_def) + have pcirc_image:"path_image p_circ \ s - insert p pts" + proof - + have "path_image p_circ \ cball p (h p)" using \0 < h p\ p_circ_def by auto + then show ?thesis using h_p pcirc(1) by auto + qed + have pcirc_integrable:"f contour_integrable_on p_circ" + by (auto simp add:p_circ_def intro!: pcirc_image[unfolded p_circ_def] + contour_integrable_continuous_circlepath holomorphic_on_imp_continuous_on + holomorphic_on_subset[OF holo]) + show "valid_path (n_circ (Suc k))" + using valid_path_join[OF pcirc(2) Suc(1) pcirc(3)] unfolding n_circ_def by auto + show "path_image (n_circ (Suc k)) + = (if Suc k = 0 then {p + complex_of_real (h p)} else sphere p (h p))" + proof - + have "path_image p_circ = sphere p (h p)" + unfolding p_circ_def using \0 < h p\ by auto + then show ?thesis unfolding n_Suc using Suc.hyps(5) \h p>0\ + by (auto simp add: path_image_join[OF pcirc(3)] dist_norm) + qed + then show "p \ path_image (n_circ (Suc k))" using \h p>0\ by auto + show "winding_number (n_circ (Suc k)) p = of_nat (Suc k)" + proof - + have "winding_number p_circ p = 1" + by (simp add: \h p > 0\ p_circ_def winding_number_circlepath_centre) + moreover have "p \ path_image (n_circ k)" using Suc(5) \h p>0\ by auto + then have "winding_number (p_circ +++ n_circ k) p + = winding_number p_circ p + winding_number (n_circ k) p" + using valid_path_imp_path Suc.hyps(1) Suc.hyps(2) pcirc + apply (intro winding_number_join) + by auto + ultimately show ?thesis using Suc(2) unfolding n_circ_def + by auto + qed + show "pathstart (n_circ (Suc k)) = p + h p" + by (simp add: n_circ_def p_circ_def) + show "pathfinish (n_circ (Suc k)) = p + h p" + using Suc(4) unfolding n_circ_def by auto + show "winding_number (n_circ (Suc k)) p'=0 \ p'\path_image (n_circ (Suc k))" when "p'\s-pts" for p' + proof - + have " p' \ path_image p_circ" using \p \ s\ h p_circ_def that using pcirc_image by blast + moreover have "p' \ path_image (n_circ k)" + using Suc.hyps(7) that by blast + moreover have "winding_number p_circ p' = 0" + proof - + have "path_image p_circ \ cball p (h p)" + using h unfolding p_circ_def using \p \ s\ by fastforce + moreover have "p'\cball p (h p)" using \p \ s\ h that "2.hyps"(2) by fastforce + ultimately show ?thesis unfolding p_circ_def + apply (intro winding_number_zero_outside) + by auto + qed + ultimately show ?thesis + unfolding n_Suc + apply (subst winding_number_join) + by (auto simp: valid_path_imp_path pcirc Suc that not_in_path_image_join Suc.hyps(7)[OF that]) + qed + show "f contour_integrable_on (n_circ (Suc k))" + unfolding n_Suc + by (rule contour_integrable_joinI[OF pcirc_integrable Suc(8) pcirc(2) Suc(1)]) + show "contour_integral (n_circ (Suc k)) f = (Suc k) * contour_integral p_circ f" + unfolding n_Suc + by (auto simp add:contour_integral_join[OF pcirc_integrable Suc(8) pcirc(2) Suc(1)] + Suc(9) algebra_simps) + qed + have cp[simp]:"pathstart cp = p + h p" "pathfinish cp = p + h p" + "valid_path cp" "path_image cp \ s - insert p pts" + "winding_number cp p = - n" + "\p'. p'\s - pts \ winding_number cp p'=0 \ p' \ path_image cp" + "f contour_integrable_on cp" + "contour_integral cp f = - n * contour_integral p_circ f" + proof - + show "pathstart cp = p + h p" and "pathfinish cp = p + h p" and "valid_path cp" + using n_circ unfolding cp_def by auto + next + have "sphere p (h p) \ s - insert p pts" + using h[rule_format,of p] \insert p pts \ s\ by force + moreover have "p + complex_of_real (h p) \ s - insert p pts" + using pg(3) pg(4) by (metis pathfinish_in_path_image subsetCE) + ultimately show "path_image cp \ s - insert p pts" unfolding cp_def + using n_circ(5) by auto + next + show "winding_number cp p = - n" + unfolding cp_def using winding_number_reversepath n_circ \h p>0\ + by (auto simp: valid_path_imp_path) + next + show "winding_number cp p'=0 \ p' \ path_image cp" when "p'\s - pts" for p' + unfolding cp_def + apply (auto) + apply (subst winding_number_reversepath) + by (auto simp add: valid_path_imp_path n_circ(7)[OF that] n_circ(1)) + next + show "f contour_integrable_on cp" unfolding cp_def + using contour_integrable_reversepath_eq n_circ(1,8) by auto + next + show "contour_integral cp f = - n * contour_integral p_circ f" + unfolding cp_def using contour_integral_reversepath[OF n_circ(1)] n_circ(9) + by auto + qed + define g' where "g' \ g +++ pg +++ cp +++ (reversepath pg)" + have "contour_integral g' f = (\p\pts. winding_number g' p * contour_integral (circlepath p (h p)) f)" + proof (rule "2.hyps"(3)[of "s-{p}" "g'",OF _ _ \finite pts\ ]) + show "connected (s - {p} - pts)" using connected by (metis Diff_insert2) + show "open (s - {p})" using \open s\ by auto + show " pts \ s - {p}" using \insert p pts \ s\ \ p \ pts\ by blast + show "f holomorphic_on s - {p} - pts" using holo \p \ pts\ by (metis Diff_insert2) + show "valid_path g'" + unfolding g'_def cp_def using n_circ valid pg g_loop + by (auto intro!:valid_path_join ) + show "pathfinish g' = pathstart g'" + unfolding g'_def cp_def using pg(2) by simp + show "path_image g' \ s - {p} - pts" + proof - + define s' where "s' \ s - {p} - pts" + have s':"s' = s-insert p pts " unfolding s'_def by auto + then show ?thesis using path_img pg(4) cp(4) + unfolding g'_def + apply (fold s'_def s') + apply (intro subset_path_image_join) + by auto + qed + note path_join_imp[simp] + show "\z. z \ s - {p} \ winding_number g' z = 0" + proof clarify + fix z assume z:"z\s - {p}" + have "winding_number (g +++ pg +++ cp +++ reversepath pg) z = winding_number g z + + winding_number (pg +++ cp +++ (reversepath pg)) z" + proof (rule winding_number_join) + show "path g" using \valid_path g\ by (simp add: valid_path_imp_path) + show "z \ path_image g" using z path_img by auto + show "path (pg +++ cp +++ reversepath pg)" using pg(3) cp + by (simp add: valid_path_imp_path) + next + have "path_image (pg +++ cp +++ reversepath pg) \ s - insert p pts" + using pg(4) cp(4) by (auto simp:subset_path_image_join) + then show "z \ path_image (pg +++ cp +++ reversepath pg)" using z by auto + next + show "pathfinish g = pathstart (pg +++ cp +++ reversepath pg)" using g_loop by auto + qed + also have "... = winding_number g z + (winding_number pg z + + winding_number (cp +++ (reversepath pg)) z)" + proof (subst add_left_cancel,rule winding_number_join) + show "path pg" and "path (cp +++ reversepath pg)" + and "pathfinish pg = pathstart (cp +++ reversepath pg)" + by (auto simp add: valid_path_imp_path) + show "z \ path_image pg" using pg(4) z by blast + show "z \ path_image (cp +++ reversepath pg)" using z + by (metis Diff_iff \z \ path_image pg\ contra_subsetD cp(4) insertI1 + not_in_path_image_join path_image_reversepath singletonD) + qed + also have "... = winding_number g z + (winding_number pg z + + (winding_number cp z + winding_number (reversepath pg) z))" + apply (auto intro!:winding_number_join simp: valid_path_imp_path) + apply (metis Diff_iff contra_subsetD cp(4) insertI1 singletonD z) + by (metis Diff_insert2 Diff_subset contra_subsetD pg(4) z) + also have "... = winding_number g z + winding_number cp z" + apply (subst winding_number_reversepath) + apply (auto simp: valid_path_imp_path) + by (metis Diff_iff contra_subsetD insertI1 pg(4) singletonD z) + finally have "winding_number g' z = winding_number g z + winding_number cp z" + unfolding g'_def . + moreover have "winding_number g z + winding_number cp z = 0" + using winding z \n=winding_number g p\ by auto + ultimately show "winding_number g' z = 0" unfolding g'_def by auto + qed + show "\pa\s - {p}. 0 < h pa \ (\w\cball pa (h pa). w \ s - {p} \ (w \ pa \ w \ pts))" + using h by fastforce + qed + moreover have "contour_integral g' f = contour_integral g f + - winding_number g p * contour_integral p_circ f" + proof - + have "contour_integral g' f = contour_integral g f + + contour_integral (pg +++ cp +++ reversepath pg) f" + unfolding g'_def + apply (subst contour_integral_join) + by (auto simp add:open_Diff[OF \open s\,OF finite_imp_closed[OF fin]] + intro!: contour_integrable_holomorphic_simple[OF holo _ _ path_img] + contour_integrable_reversepath) + also have "... = contour_integral g f + contour_integral pg f + + contour_integral (cp +++ reversepath pg) f" + apply (subst contour_integral_join) + by (auto simp add:contour_integrable_reversepath) + also have "... = contour_integral g f + contour_integral pg f + + contour_integral cp f + contour_integral (reversepath pg) f" + apply (subst contour_integral_join) + by (auto simp add:contour_integrable_reversepath) + also have "... = contour_integral g f + contour_integral cp f" + using contour_integral_reversepath + by (auto simp add:contour_integrable_reversepath) + also have "... = contour_integral g f - winding_number g p * contour_integral p_circ f" + using \n=winding_number g p\ by auto + finally show ?thesis . + qed + moreover have "winding_number g' p' = winding_number g p'" when "p'\pts" for p' + proof - + have [simp]: "p' \ path_image g" "p' \ path_image pg" "p'\path_image cp" + using "2.prems"(8) that + apply blast + apply (metis Diff_iff Diff_insert2 contra_subsetD pg(4) that) + by (meson DiffD2 cp(4) rev_subsetD subset_insertI that) + have "winding_number g' p' = winding_number g p' + + winding_number (pg +++ cp +++ reversepath pg) p'" unfolding g'_def + apply (subst winding_number_join) + apply (simp_all add: valid_path_imp_path) + apply (intro not_in_path_image_join) + by auto + also have "... = winding_number g p' + winding_number pg p' + + winding_number (cp +++ reversepath pg) p'" + apply (subst winding_number_join) + apply (simp_all add: valid_path_imp_path) + apply (intro not_in_path_image_join) + by auto + also have "... = winding_number g p' + winding_number pg p'+ winding_number cp p' + + winding_number (reversepath pg) p'" + apply (subst winding_number_join) + by (simp_all add: valid_path_imp_path) + also have "... = winding_number g p' + winding_number cp p'" + apply (subst winding_number_reversepath) + by (simp_all add: valid_path_imp_path) + also have "... = winding_number g p'" using that by auto + finally show ?thesis . + qed + ultimately show ?case unfolding p_circ_def + apply (subst (asm) sum.cong[OF refl, + of pts _ "\p. winding_number g p * contour_integral (circlepath p (h p)) f"]) + by (auto simp add:sum.insert[OF \finite pts\ \p\pts\] algebra_simps) +qed + +lemma Cauchy_theorem_singularities: + assumes "open s" "connected s" "finite pts" and + holo:"f holomorphic_on s-pts" and + "valid_path g" and + loop:"pathfinish g = pathstart g" and + "path_image g \ s-pts" and + homo:"\z. (z \ s) \ winding_number g z = 0" and + avoid:"\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" + shows "contour_integral g f = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" + (is "?L=?R") +proof - + define circ where "circ \ \p. winding_number g p * contour_integral (circlepath p (h p)) f" + define pts1 where "pts1 \ pts \ s" + define pts2 where "pts2 \ pts - pts1" + have "pts=pts1 \ pts2" "pts1 \ pts2 = {}" "pts2 \ s={}" "pts1\s" + unfolding pts1_def pts2_def by auto + have "contour_integral g f = (\p\pts1. circ p)" unfolding circ_def + proof (rule Cauchy_theorem_aux[OF \open s\ _ _ \pts1\s\ _ \valid_path g\ loop _ homo]) + have "finite pts1" unfolding pts1_def using \finite pts\ by auto + then show "connected (s - pts1)" + using \open s\ \connected s\ connected_open_delete_finite[of s] by auto + next + show "finite pts1" using \pts = pts1 \ pts2\ assms(3) by auto + show "f holomorphic_on s - pts1" by (metis Diff_Int2 Int_absorb holo pts1_def) + show "path_image g \ s - pts1" using assms(7) pts1_def by auto + show "\p\s. 0 < h p \ (\w\cball p (h p). w \ s \ (w \ p \ w \ pts1))" + by (simp add: avoid pts1_def) + qed + moreover have "sum circ pts2=0" + proof - + have "winding_number g p=0" when "p\pts2" for p + using \pts2 \ s={}\ that homo[rule_format,of p] by auto + thus ?thesis unfolding circ_def + apply (intro sum.neutral) + by auto + qed + moreover have "?R=sum circ pts1 + sum circ pts2" + unfolding circ_def + using sum.union_disjoint[OF _ _ \pts1 \ pts2 = {}\] \finite pts\ \pts=pts1 \ pts2\ + by blast + ultimately show ?thesis + apply (fold circ_def) + by auto +qed + +theorem Residue_theorem: + fixes s pts::"complex set" and f::"complex \ complex" + and g::"real \ complex" + assumes "open s" "connected s" "finite pts" and + holo:"f holomorphic_on s-pts" and + "valid_path g" and + loop:"pathfinish g = pathstart g" and + "path_image g \ s-pts" and + homo:"\z. (z \ s) \ winding_number g z = 0" + shows "contour_integral g f = 2 * pi * \ *(\p\pts. winding_number g p * residue f p)" +proof - + define c where "c \ 2 * pi * \" + obtain h where avoid:"\p\s. h p>0 \ (\w\cball p (h p). w\s \ (w\p \ w \ pts))" + using finite_cball_avoid[OF \open s\ \finite pts\] by metis + have "contour_integral g f + = (\p\pts. winding_number g p * contour_integral (circlepath p (h p)) f)" + using Cauchy_theorem_singularities[OF assms avoid] . + also have "... = (\p\pts. c * winding_number g p * residue f p)" + proof (intro sum.cong) + show "pts = pts" by simp + next + fix x assume "x \ pts" + show "winding_number g x * contour_integral (circlepath x (h x)) f + = c * winding_number g x * residue f x" + proof (cases "x\s") + case False + then have "winding_number g x=0" using homo by auto + thus ?thesis by auto + next + case True + have "contour_integral (circlepath x (h x)) f = c* residue f x" + using \x\pts\ \finite pts\ avoid[rule_format,OF True] + apply (intro base_residue[of "s-(pts-{x})",THEN contour_integral_unique,folded c_def]) + by (auto intro:holomorphic_on_subset[OF holo] open_Diff[OF \open s\ finite_imp_closed]) + then show ?thesis by auto + qed + qed + also have "... = c * (\p\pts. winding_number g p * residue f p)" + by (simp add: sum_distrib_left algebra_simps) + finally show ?thesis unfolding c_def . +qed + +subsection \The argument principle\ + +theorem argument_principle: + fixes f::"complex \ complex" and poles s:: "complex set" + defines "pz \ {w. f w = 0 \ w \ poles}" \ \\<^term>\pz\ is the set of poles and zeros\ + assumes "open s" and + "connected s" and + f_holo:"f holomorphic_on s-poles" and + h_holo:"h holomorphic_on s" and + "valid_path g" and + loop:"pathfinish g = pathstart g" and + path_img:"path_image g \ s - pz" and + homo:"\z. (z \ s) \ winding_number g z = 0" and + finite:"finite pz" and + poles:"\p\poles. is_pole f p" + shows "contour_integral g (\x. deriv f x * h x / f x) = 2 * pi * \ * + (\p\pz. winding_number g p * h p * zorder f p)" + (is "?L=?R") +proof - + define c where "c \ 2 * complex_of_real pi * \ " + define ff where "ff \ (\x. deriv f x * h x / f x)" + define cont where "cont \ \ff p e. (ff has_contour_integral c * zorder f p * h p ) (circlepath p e)" + define avoid where "avoid \ \p e. \w\cball p e. w \ s \ (w \ p \ w \ pz)" + + have "\e>0. avoid p e \ (p\pz \ cont ff p e)" when "p\s" for p + proof - + obtain e1 where "e1>0" and e1_avoid:"avoid p e1" + using finite_cball_avoid[OF \open s\ finite] \p\s\ unfolding avoid_def by auto + have "\e2>0. cball p e2 \ ball p e1 \ cont ff p e2" when "p\pz" + proof - + define po where "po \ zorder f p" + define pp where "pp \ zor_poly f p" + define f' where "f' \ \w. pp w * (w - p) powr po" + define ff' where "ff' \ (\x. deriv f' x * h x / f' x)" + obtain r where "pp p\0" "r>0" and + "rw\cball p r-{p}. f w = pp w * (w - p) powr po \ pp w \ 0)" + proof - + have "isolated_singularity_at f p" + proof - + have "f holomorphic_on ball p e1 - {p}" + apply (intro holomorphic_on_subset[OF f_holo]) + using e1_avoid \p\pz\ unfolding avoid_def pz_def by force + then show ?thesis unfolding isolated_singularity_at_def + using \e1>0\ analytic_on_open open_delete by blast + qed + moreover have "not_essential f p" + proof (cases "is_pole f p") + case True + then show ?thesis unfolding not_essential_def by auto + next + case False + then have "p\s-poles" using \p\s\ poles unfolding pz_def by auto + moreover have "open (s-poles)" + using \open s\ + apply (elim open_Diff) + apply (rule finite_imp_closed) + using finite unfolding pz_def by simp + ultimately have "isCont f p" + using holomorphic_on_imp_continuous_on[OF f_holo] continuous_on_eq_continuous_at + by auto + then show ?thesis unfolding isCont_def not_essential_def by auto + qed + moreover have "\\<^sub>F w in at p. f w \ 0 " + proof (rule ccontr) + assume "\ (\\<^sub>F w in at p. f w \ 0)" + then have "\\<^sub>F w in at p. f w= 0" unfolding frequently_def by auto + then obtain rr where "rr>0" "\w\ball p rr - {p}. f w =0" + unfolding eventually_at by (auto simp add:dist_commute) + then have "ball p rr - {p} \ {w\ball p rr-{p}. f w=0}" by blast + moreover have "infinite (ball p rr - {p})" using \rr>0\ using finite_imp_not_open by fastforce + ultimately have "infinite {w\ball p rr-{p}. f w=0}" using infinite_super by blast + then have "infinite pz" + unfolding pz_def infinite_super by auto + then show False using \finite pz\ by auto + qed + ultimately obtain r where "pp p \ 0" and r:"r>0" "pp holomorphic_on cball p r" + "(\w\cball p r - {p}. f w = pp w * (w - p) powr of_int po \ pp w \ 0)" + using zorder_exist[of f p,folded po_def pp_def] by auto + define r1 where "r1=min r e1 / 2" + have "r1e1>0\ \r>0\ by auto + moreover have "r1>0" "pp holomorphic_on cball p r1" + "(\w\cball p r1 - {p}. f w = pp w * (w - p) powr of_int po \ pp w \ 0)" + unfolding r1_def using \e1>0\ r by auto + ultimately show ?thesis using that \pp p\0\ by auto + qed + + define e2 where "e2 \ r/2" + have "e2>0" using \r>0\ unfolding e2_def by auto + define anal where "anal \ \w. deriv pp w * h w / pp w" + define prin where "prin \ \w. po * h w / (w - p)" + have "((\w. prin w + anal w) has_contour_integral c * po * h p) (circlepath p e2)" + proof (rule has_contour_integral_add[of _ _ _ _ 0,simplified]) + have "ball p r \ s" + using \r avoid_def ball_subset_cball e1_avoid by (simp add: subset_eq) + then have "cball p e2 \ s" + using \r>0\ unfolding e2_def by auto + then have "(\w. po * h w) holomorphic_on cball p e2" + using h_holo by (auto intro!: holomorphic_intros) + then show "(prin has_contour_integral c * po * h p ) (circlepath p e2)" + using Cauchy_integral_circlepath_simple[folded c_def, of "\w. po * h w"] \e2>0\ + unfolding prin_def by (auto simp add: mult.assoc) + have "anal holomorphic_on ball p r" unfolding anal_def + using pp_holo h_holo pp_po \ball p r \ s\ \pp p\0\ + by (auto intro!: holomorphic_intros) + then show "(anal has_contour_integral 0) (circlepath p e2)" + using e2_def \r>0\ + by (auto elim!: Cauchy_theorem_disc_simple) + qed + then have "cont ff' p e2" unfolding cont_def po_def + proof (elim has_contour_integral_eq) + fix w assume "w \ path_image (circlepath p e2)" + then have "w\ball p r" and "w\p" unfolding e2_def using \r>0\ by auto + define wp where "wp \ w-p" + have "wp\0" and "pp w \0" + unfolding wp_def using \w\p\ \w\ball p r\ pp_po by auto + moreover have der_f':"deriv f' w = po * pp w * (w-p) powr (po - 1) + deriv pp w * (w-p) powr po" + proof (rule DERIV_imp_deriv) + have "(pp has_field_derivative (deriv pp w)) (at w)" + using DERIV_deriv_iff_has_field_derivative pp_holo \w\p\ + by (meson open_ball \w \ ball p r\ ball_subset_cball holomorphic_derivI holomorphic_on_subset) + then show " (f' has_field_derivative of_int po * pp w * (w - p) powr of_int (po - 1) + + deriv pp w * (w - p) powr of_int po) (at w)" + unfolding f'_def using \w\p\ + by (auto intro!: derivative_eq_intros DERIV_cong[OF has_field_derivative_powr_of_int]) + qed + ultimately show "prin w + anal w = ff' w" + unfolding ff'_def prin_def anal_def + apply simp + apply (unfold f'_def) + apply (fold wp_def) + apply (auto simp add:field_simps) + by (metis (no_types, lifting) diff_add_cancel mult.commute powr_add powr_to_1) + qed + then have "cont ff p e2" unfolding cont_def + proof (elim has_contour_integral_eq) + fix w assume "w \ path_image (circlepath p e2)" + then have "w\ball p r" and "w\p" unfolding e2_def using \r>0\ by auto + have "deriv f' w = deriv f w" + proof (rule complex_derivative_transform_within_open[where s="ball p r - {p}"]) + show "f' holomorphic_on ball p r - {p}" unfolding f'_def using pp_holo + by (auto intro!: holomorphic_intros) + next + have "ball p e1 - {p} \ s - poles" + using ball_subset_cball e1_avoid[unfolded avoid_def] unfolding pz_def + by auto + then have "ball p r - {p} \ s - poles" + apply (elim dual_order.trans) + using \r by auto + then show "f holomorphic_on ball p r - {p}" using f_holo + by auto + next + show "open (ball p r - {p})" by auto + show "w \ ball p r - {p}" using \w\ball p r\ \w\p\ by auto + next + fix x assume "x \ ball p r - {p}" + then show "f' x = f x" + using pp_po unfolding f'_def by auto + qed + moreover have " f' w = f w " + using \w \ ball p r\ ball_subset_cball subset_iff pp_po \w\p\ + unfolding f'_def by auto + ultimately show "ff' w = ff w" + unfolding ff'_def ff_def by simp + qed + moreover have "cball p e2 \ ball p e1" + using \0 < r\ \r e2_def by auto + ultimately show ?thesis using \e2>0\ by auto + qed + then obtain e2 where e2:"p\pz \ e2>0 \ cball p e2 \ ball p e1 \ cont ff p e2" + by auto + define e4 where "e4 \ if p\pz then e2 else e1" + have "e4>0" using e2 \e1>0\ unfolding e4_def by auto + moreover have "avoid p e4" using e2 \e1>0\ e1_avoid unfolding e4_def avoid_def by auto + moreover have "p\pz \ cont ff p e4" + by (auto simp add: e2 e4_def) + ultimately show ?thesis by auto + qed + then obtain get_e where get_e:"\p\s. get_e p>0 \ avoid p (get_e p) + \ (p\pz \ cont ff p (get_e p))" + by metis + define ci where "ci \ \p. contour_integral (circlepath p (get_e p)) ff" + define w where "w \ \p. winding_number g p" + have "contour_integral g ff = (\p\pz. w p * ci p)" unfolding ci_def w_def + proof (rule Cauchy_theorem_singularities[OF \open s\ \connected s\ finite _ \valid_path g\ loop + path_img homo]) + have "open (s - pz)" using open_Diff[OF _ finite_imp_closed[OF finite]] \open s\ by auto + then show "ff holomorphic_on s - pz" unfolding ff_def using f_holo h_holo + by (auto intro!: holomorphic_intros simp add:pz_def) + next + show "\p\s. 0 < get_e p \ (\w\cball p (get_e p). w \ s \ (w \ p \ w \ pz))" + using get_e using avoid_def by blast + qed + also have "... = (\p\pz. c * w p * h p * zorder f p)" + proof (rule sum.cong[of pz pz,simplified]) + fix p assume "p \ pz" + show "w p * ci p = c * w p * h p * (zorder f p)" + proof (cases "p\s") + assume "p \ s" + have "ci p = c * h p * (zorder f p)" unfolding ci_def + apply (rule contour_integral_unique) + using get_e \p\s\ \p\pz\ unfolding cont_def by (metis mult.assoc mult.commute) + thus ?thesis by auto + next + assume "p\s" + then have "w p=0" using homo unfolding w_def by auto + then show ?thesis by auto + qed + qed + also have "... = c*(\p\pz. w p * h p * zorder f p)" + unfolding sum_distrib_left by (simp add:algebra_simps) + finally have "contour_integral g ff = c * (\p\pz. w p * h p * of_int (zorder f p))" . + then show ?thesis unfolding ff_def c_def w_def by simp +qed + +subsection \Rouche's theorem \ + +theorem Rouche_theorem: + fixes f g::"complex \ complex" and s:: "complex set" + defines "fg\(\p. f p + g p)" + defines "zeros_fg\{p. fg p = 0}" and "zeros_f\{p. f p = 0}" + assumes + "open s" and "connected s" and + "finite zeros_fg" and + "finite zeros_f" and + f_holo:"f holomorphic_on s" and + g_holo:"g holomorphic_on s" and + "valid_path \" and + loop:"pathfinish \ = pathstart \" and + path_img:"path_image \ \ s " and + path_less:"\z\path_image \. cmod(f z) > cmod(g z)" and + homo:"\z. (z \ s) \ winding_number \ z = 0" + shows "(\p\zeros_fg. winding_number \ p * zorder fg p) + = (\p\zeros_f. winding_number \ p * zorder f p)" +proof - + have path_fg:"path_image \ \ s - zeros_fg" + proof - + have False when "z\path_image \" and "f z + g z=0" for z + proof - + have "cmod (f z) > cmod (g z)" using \z\path_image \\ path_less by auto + moreover have "f z = - g z" using \f z + g z =0\ by (simp add: eq_neg_iff_add_eq_0) + then have "cmod (f z) = cmod (g z)" by auto + ultimately show False by auto + qed + then show ?thesis unfolding zeros_fg_def fg_def using path_img by auto + qed + have path_f:"path_image \ \ s - zeros_f" + proof - + have False when "z\path_image \" and "f z =0" for z + proof - + have "cmod (g z) < cmod (f z) " using \z\path_image \\ path_less by auto + then have "cmod (g z) < 0" using \f z=0\ by auto + then show False by auto + qed + then show ?thesis unfolding zeros_f_def using path_img by auto + qed + define w where "w \ \p. winding_number \ p" + define c where "c \ 2 * complex_of_real pi * \" + define h where "h \ \p. g p / f p + 1" + obtain spikes + where "finite spikes" and spikes: "\x\{0..1} - spikes. \ differentiable at x" + using \valid_path \\ + by (auto simp: valid_path_def piecewise_C1_differentiable_on_def C1_differentiable_on_eq) + have h_contour:"((\x. deriv h x / h x) has_contour_integral 0) \" + proof - + have outside_img:"0 \ outside (path_image (h o \))" + proof - + have "h p \ ball 1 1" when "p\path_image \" for p + proof - + have "cmod (g p/f p) <1" using path_less[rule_format,OF that] + apply (cases "cmod (f p) = 0") + by (auto simp add: norm_divide) + then show ?thesis unfolding h_def by (auto simp add:dist_complex_def) + qed + then have "path_image (h o \) \ ball 1 1" + by (simp add: image_subset_iff path_image_compose) + moreover have " (0::complex) \ ball 1 1" by (simp add: dist_norm) + ultimately show "?thesis" + using convex_in_outside[of "ball 1 1" 0] outside_mono by blast + qed + have valid_h:"valid_path (h \ \)" + proof (rule valid_path_compose_holomorphic[OF \valid_path \\ _ _ path_f]) + show "h holomorphic_on s - zeros_f" + unfolding h_def using f_holo g_holo + by (auto intro!: holomorphic_intros simp add:zeros_f_def) + next + show "open (s - zeros_f)" using \finite zeros_f\ \open s\ finite_imp_closed + by auto + qed + have "((\z. 1/z) has_contour_integral 0) (h \ \)" + proof - + have "0 \ path_image (h \ \)" using outside_img by (simp add: outside_def) + then have "((\z. 1/z) has_contour_integral c * winding_number (h \ \) 0) (h \ \)" + using has_contour_integral_winding_number[of "h o \" 0,simplified] valid_h + unfolding c_def by auto + moreover have "winding_number (h o \) 0 = 0" + proof - + have "0 \ outside (path_image (h \ \))" using outside_img . + moreover have "path (h o \)" + using valid_h by (simp add: valid_path_imp_path) + moreover have "pathfinish (h o \) = pathstart (h o \)" + by (simp add: loop pathfinish_compose pathstart_compose) + ultimately show ?thesis using winding_number_zero_in_outside by auto + qed + ultimately show ?thesis by auto + qed + moreover have "vector_derivative (h \ \) (at x) = vector_derivative \ (at x) * deriv h (\ x)" + when "x\{0..1} - spikes" for x + proof (rule vector_derivative_chain_at_general) + show "\ differentiable at x" using that \valid_path \\ spikes by auto + next + define der where "der \ \p. (deriv g p * f p - g p * deriv f p)/(f p * f p)" + define t where "t \ \ x" + have "f t\0" unfolding zeros_f_def t_def + by (metis DiffD1 image_eqI norm_not_less_zero norm_zero path_defs(4) path_less that) + moreover have "t\s" + using contra_subsetD path_image_def path_fg t_def that by fastforce + ultimately have "(h has_field_derivative der t) (at t)" + unfolding h_def der_def using g_holo f_holo \open s\ + by (auto intro!: holomorphic_derivI derivative_eq_intros) + then show "h field_differentiable at (\ x)" + unfolding t_def field_differentiable_def by blast + qed + then have " ((/) 1 has_contour_integral 0) (h \ \) + = ((\x. deriv h x / h x) has_contour_integral 0) \" + unfolding has_contour_integral + apply (intro has_integral_spike_eq[OF negligible_finite, OF \finite spikes\]) + by auto + ultimately show ?thesis by auto + qed + then have "contour_integral \ (\x. deriv h x / h x) = 0" + using contour_integral_unique by simp + moreover have "contour_integral \ (\x. deriv fg x / fg x) = contour_integral \ (\x. deriv f x / f x) + + contour_integral \ (\p. deriv h p / h p)" + proof - + have "(\p. deriv f p / f p) contour_integrable_on \" + proof (rule contour_integrable_holomorphic_simple[OF _ _ \valid_path \\ path_f]) + show "open (s - zeros_f)" using finite_imp_closed[OF \finite zeros_f\] \open s\ + by auto + then show "(\p. deriv f p / f p) holomorphic_on s - zeros_f" + using f_holo + by (auto intro!: holomorphic_intros simp add:zeros_f_def) + qed + moreover have "(\p. deriv h p / h p) contour_integrable_on \" + using h_contour + by (simp add: has_contour_integral_integrable) + ultimately have "contour_integral \ (\x. deriv f x / f x + deriv h x / h x) = + contour_integral \ (\p. deriv f p / f p) + contour_integral \ (\p. deriv h p / h p)" + using contour_integral_add[of "(\p. deriv f p / f p)" \ "(\p. deriv h p / h p)" ] + by auto + moreover have "deriv fg p / fg p = deriv f p / f p + deriv h p / h p" + when "p\ path_image \" for p + proof - + have "fg p\0" and "f p\0" using path_f path_fg that unfolding zeros_f_def zeros_fg_def + by auto + have "h p\0" + proof (rule ccontr) + assume "\ h p \ 0" + then have "g p / f p= -1" unfolding h_def by (simp add: add_eq_0_iff2) + then have "cmod (g p/f p) = 1" by auto + moreover have "cmod (g p/f p) <1" using path_less[rule_format,OF that] + apply (cases "cmod (f p) = 0") + by (auto simp add: norm_divide) + ultimately show False by auto + qed + have der_fg:"deriv fg p = deriv f p + deriv g p" unfolding fg_def + using f_holo g_holo holomorphic_on_imp_differentiable_at[OF _ \open s\] path_img that + by auto + have der_h:"deriv h p = (deriv g p * f p - g p * deriv f p)/(f p * f p)" + proof - + define der where "der \ \p. (deriv g p * f p - g p * deriv f p)/(f p * f p)" + have "p\s" using path_img that by auto + then have "(h has_field_derivative der p) (at p)" + unfolding h_def der_def using g_holo f_holo \open s\ \f p\0\ + by (auto intro!: derivative_eq_intros holomorphic_derivI) + then show ?thesis unfolding der_def using DERIV_imp_deriv by auto + qed + show ?thesis + apply (simp only:der_fg der_h) + apply (auto simp add:field_simps \h p\0\ \f p\0\ \fg p\0\) + by (auto simp add:field_simps h_def \f p\0\ fg_def) + qed + then have "contour_integral \ (\p. deriv fg p / fg p) + = contour_integral \ (\p. deriv f p / f p + deriv h p / h p)" + by (elim contour_integral_eq) + ultimately show ?thesis by auto + qed + moreover have "contour_integral \ (\x. deriv fg x / fg x) = c * (\p\zeros_fg. w p * zorder fg p)" + unfolding c_def zeros_fg_def w_def + proof (rule argument_principle[OF \open s\ \connected s\ _ _ \valid_path \\ loop _ homo + , of _ "{}" "\_. 1",simplified]) + show "fg holomorphic_on s" unfolding fg_def using f_holo g_holo holomorphic_on_add by auto + show "path_image \ \ s - {p. fg p = 0}" using path_fg unfolding zeros_fg_def . + show " finite {p. fg p = 0}" using \finite zeros_fg\ unfolding zeros_fg_def . + qed + moreover have "contour_integral \ (\x. deriv f x / f x) = c * (\p\zeros_f. w p * zorder f p)" + unfolding c_def zeros_f_def w_def + proof (rule argument_principle[OF \open s\ \connected s\ _ _ \valid_path \\ loop _ homo + , of _ "{}" "\_. 1",simplified]) + show "f holomorphic_on s" using f_holo g_holo holomorphic_on_add by auto + show "path_image \ \ s - {p. f p = 0}" using path_f unfolding zeros_f_def . + show " finite {p. f p = 0}" using \finite zeros_f\ unfolding zeros_f_def . + qed + ultimately have " c* (\p\zeros_fg. w p * (zorder fg p)) = c* (\p\zeros_f. w p * (zorder f p))" + by auto + then show ?thesis unfolding c_def using w_def by auto +qed + +end \ No newline at end of file diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Riemann_Mapping.thy --- a/src/HOL/Complex_Analysis/Riemann_Mapping.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Riemann_Mapping.thy Mon Dec 02 17:51:54 2019 +0100 @@ -1486,4 +1486,256 @@ ultimately show ?thesis by metis qed + +subsection \Applications to Winding Numbers\ + +lemma simply_connected_inside_simple_path: + fixes p :: "real \ complex" + shows "simple_path p \ simply_connected(inside(path_image p))" + using Jordan_inside_outside connected_simple_path_image inside_simple_curve_imp_closed simply_connected_eq_frontier_properties + by fastforce + +lemma simply_connected_Int: + fixes S :: "complex set" + assumes "open S" "open T" "simply_connected S" "simply_connected T" "connected (S \ T)" + shows "simply_connected (S \ T)" + using assms by (force simp: simply_connected_eq_winding_number_zero open_Int) + + +subsection\<^marker>\tag unimportant\ \The winding number defines a continuous logarithm for the path itself\ + +lemma winding_number_as_continuous_log: + assumes "path p" and \: "\ \ path_image p" + obtains q where "path q" + "pathfinish q - pathstart q = 2 * of_real pi * \ * winding_number p \" + "\t. t \ {0..1} \ p t = \ + exp(q t)" +proof - + let ?q = "\t. 2 * of_real pi * \ * winding_number(subpath 0 t p) \ + Ln(pathstart p - \)" + show ?thesis + proof + have *: "continuous (at t within {0..1}) (\x. winding_number (subpath 0 x p) \)" + if t: "t \ {0..1}" for t + proof - + let ?B = "ball (p t) (norm(p t - \))" + have "p t \ \" + using path_image_def that \ by blast + then have "simply_connected ?B" + by (simp add: convex_imp_simply_connected) + then have "\f::complex\complex. continuous_on ?B f \ (\\ \ ?B. f \ \ 0) + \ (\g. continuous_on ?B g \ (\\ \ ?B. f \ = exp (g \)))" + by (simp add: simply_connected_eq_continuous_log) + moreover have "continuous_on ?B (\w. w - \)" + by (intro continuous_intros) + moreover have "(\z \ ?B. z - \ \ 0)" + by (auto simp: dist_norm) + ultimately obtain g where contg: "continuous_on ?B g" + and geq: "\z. z \ ?B \ z - \ = exp (g z)" by blast + obtain d where "0 < d" and d: + "\x. \x \ {0..1}; dist x t < d\ \ dist (p x) (p t) < cmod (p t - \)" + using \path p\ t unfolding path_def continuous_on_iff + by (metis \p t \ \\ right_minus_eq zero_less_norm_iff) + have "((\x. winding_number (\w. subpath 0 x p w - \) 0 - + winding_number (\w. subpath 0 t p w - \) 0) \ 0) + (at t within {0..1})" + proof (rule Lim_transform_within [OF _ \d > 0\]) + have "continuous (at t within {0..1}) (g o p)" + proof (rule continuous_within_compose) + show "continuous (at t within {0..1}) p" + using \path p\ continuous_on_eq_continuous_within path_def that by blast + show "continuous (at (p t) within p ` {0..1}) g" + by (metis (no_types, lifting) open_ball UNIV_I \p t \ \\ centre_in_ball contg continuous_on_eq_continuous_at continuous_within_topological right_minus_eq zero_less_norm_iff) + qed + with LIM_zero have "((\u. (g (subpath t u p 1) - g (subpath t u p 0))) \ 0) (at t within {0..1})" + by (auto simp: subpath_def continuous_within o_def) + then show "((\u. (g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \)) \ 0) + (at t within {0..1})" + by (simp add: tendsto_divide_zero) + show "(g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \) = + winding_number (\w. subpath 0 u p w - \) 0 - winding_number (\w. subpath 0 t p w - \) 0" + if "u \ {0..1}" "0 < dist u t" "dist u t < d" for u + proof - + have "closed_segment t u \ {0..1}" + using closed_segment_eq_real_ivl t that by auto + then have piB: "path_image(subpath t u p) \ ?B" + apply (clarsimp simp add: path_image_subpath_gen) + by (metis subsetD le_less_trans \dist u t < d\ d dist_commute dist_in_closed_segment) + have *: "path (g \ subpath t u p)" + apply (rule path_continuous_image) + using \path p\ t that apply auto[1] + using piB contg continuous_on_subset by blast + have "(g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \) + = winding_number (exp \ g \ subpath t u p) 0" + using winding_number_compose_exp [OF *] + by (simp add: pathfinish_def pathstart_def o_assoc) + also have "... = winding_number (\w. subpath t u p w - \) 0" + proof (rule winding_number_cong) + have "exp(g y) = y - \" if "y \ (subpath t u p) ` {0..1}" for y + by (metis that geq path_image_def piB subset_eq) + then show "\x. \0 \ x; x \ 1\ \ (exp \ g \ subpath t u p) x = subpath t u p x - \" + by auto + qed + also have "... = winding_number (\w. subpath 0 u p w - \) 0 - + winding_number (\w. subpath 0 t p w - \) 0" + apply (simp add: winding_number_offset [symmetric]) + using winding_number_subpath_combine [OF \path p\ \, of 0 t u] \t \ {0..1}\ \u \ {0..1}\ + by (simp add: add.commute eq_diff_eq) + finally show ?thesis . + qed + qed + then show ?thesis + by (subst winding_number_offset) (simp add: continuous_within LIM_zero_iff) + qed + show "path ?q" + unfolding path_def + by (intro continuous_intros) (simp add: continuous_on_eq_continuous_within *) + + have "\ \ p 0" + by (metis \ pathstart_def pathstart_in_path_image) + then show "pathfinish ?q - pathstart ?q = 2 * of_real pi * \ * winding_number p \" + by (simp add: pathfinish_def pathstart_def) + show "p t = \ + exp (?q t)" if "t \ {0..1}" for t + proof - + have "path (subpath 0 t p)" + using \path p\ that by auto + moreover + have "\ \ path_image (subpath 0 t p)" + using \ [unfolded path_image_def] that by (auto simp: path_image_subpath) + ultimately show ?thesis + using winding_number_exp_2pi [of "subpath 0 t p" \] \\ \ p 0\ + by (auto simp: exp_add algebra_simps pathfinish_def pathstart_def subpath_def) + qed + qed +qed + +subsection \Winding number equality is the same as path/loop homotopy in C - {0}\ + +lemma winding_number_homotopic_loops_null_eq: + assumes "path p" and \: "\ \ path_image p" + shows "winding_number p \ = 0 \ (\a. homotopic_loops (-{\}) p (\t. a))" + (is "?lhs = ?rhs") +proof + assume [simp]: ?lhs + obtain q where "path q" + and qeq: "pathfinish q - pathstart q = 2 * of_real pi * \ * winding_number p \" + and peq: "\t. t \ {0..1} \ p t = \ + exp(q t)" + using winding_number_as_continuous_log [OF assms] by blast + have *: "homotopic_with_canon (\r. pathfinish r = pathstart r) + {0..1} (-{\}) ((\w. \ + exp w) \ q) ((\w. \ + exp w) \ (\t. 0))" + proof (rule homotopic_with_compose_continuous_left) + show "homotopic_with_canon (\f. pathfinish ((\w. \ + exp w) \ f) = pathstart ((\w. \ + exp w) \ f)) + {0..1} UNIV q (\t. 0)" + proof (rule homotopic_with_mono, simp_all add: pathfinish_def pathstart_def) + have "homotopic_loops UNIV q (\t. 0)" + by (rule homotopic_loops_linear) (use qeq \path q\ in \auto simp: path_defs\) + then have "homotopic_with (\r. r 1 = r 0) (top_of_set {0..1}) euclidean q (\t. 0)" + by (simp add: homotopic_loops_def pathfinish_def pathstart_def) + then show "homotopic_with (\h. exp (h 1) = exp (h 0)) (top_of_set {0..1}) euclidean q (\t. 0)" + by (rule homotopic_with_mono) simp + qed + show "continuous_on UNIV (\w. \ + exp w)" + by (rule continuous_intros)+ + show "range (\w. \ + exp w) \ -{\}" + by auto + qed + then have "homotopic_with_canon (\r. pathfinish r = pathstart r) {0..1} (-{\}) p (\x. \ + 1)" + by (rule homotopic_with_eq) (auto simp: o_def peq pathfinish_def pathstart_def) + then have "homotopic_loops (-{\}) p (\t. \ + 1)" + by (simp add: homotopic_loops_def) + then show ?rhs .. +next + assume ?rhs + then obtain a where "homotopic_loops (-{\}) p (\t. a)" .. + then have "winding_number p \ = winding_number (\t. a) \" "a \ \" + using winding_number_homotopic_loops homotopic_loops_imp_subset by (force simp:)+ + moreover have "winding_number (\t. a) \ = 0" + by (metis winding_number_zero_const \a \ \\) + ultimately show ?lhs by metis +qed + +lemma winding_number_homotopic_paths_null_explicit_eq: + assumes "path p" and \: "\ \ path_image p" + shows "winding_number p \ = 0 \ homotopic_paths (-{\}) p (linepath (pathstart p) (pathstart p))" + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + apply (auto simp: winding_number_homotopic_loops_null_eq [OF assms]) + apply (rule homotopic_loops_imp_homotopic_paths_null) + apply (simp add: linepath_refl) + done +next + assume ?rhs + then show ?lhs + by (metis \ pathstart_in_path_image winding_number_homotopic_paths winding_number_trivial) +qed + +lemma winding_number_homotopic_paths_null_eq: + assumes "path p" and \: "\ \ path_image p" + shows "winding_number p \ = 0 \ (\a. homotopic_paths (-{\}) p (\t. a))" + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + by (auto simp: winding_number_homotopic_paths_null_explicit_eq [OF assms] linepath_refl) +next + assume ?rhs + then show ?lhs + by (metis \ homotopic_paths_imp_pathfinish pathfinish_def pathfinish_in_path_image winding_number_homotopic_paths winding_number_zero_const) +qed + +proposition winding_number_homotopic_paths_eq: + assumes "path p" and \p: "\ \ path_image p" + and "path q" and \q: "\ \ path_image q" + and qp: "pathstart q = pathstart p" "pathfinish q = pathfinish p" + shows "winding_number p \ = winding_number q \ \ homotopic_paths (-{\}) p q" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have "winding_number (p +++ reversepath q) \ = 0" + using assms by (simp add: winding_number_join winding_number_reversepath) + moreover + have "path (p +++ reversepath q)" "\ \ path_image (p +++ reversepath q)" + using assms by (auto simp: not_in_path_image_join) + ultimately obtain a where "homotopic_paths (- {\}) (p +++ reversepath q) (linepath a a)" + using winding_number_homotopic_paths_null_explicit_eq by blast + then show ?rhs + using homotopic_paths_imp_pathstart assms + by (fastforce simp add: dest: homotopic_paths_imp_homotopic_loops homotopic_paths_loop_parts) +next + assume ?rhs + then show ?lhs + by (simp add: winding_number_homotopic_paths) +qed + +lemma winding_number_homotopic_loops_eq: + assumes "path p" and \p: "\ \ path_image p" + and "path q" and \q: "\ \ path_image q" + and loops: "pathfinish p = pathstart p" "pathfinish q = pathstart q" + shows "winding_number p \ = winding_number q \ \ homotopic_loops (-{\}) p q" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + have "pathstart p \ \" "pathstart q \ \" + using \p \q by blast+ + moreover have "path_connected (-{\})" + by (simp add: path_connected_punctured_universe) + ultimately obtain r where "path r" and rim: "path_image r \ -{\}" + and pas: "pathstart r = pathstart p" and paf: "pathfinish r = pathstart q" + by (auto simp: path_connected_def) + then have "pathstart r \ \" by blast + have "homotopic_loops (- {\}) p (r +++ q +++ reversepath r)" + proof (rule homotopic_paths_imp_homotopic_loops) + show "homotopic_paths (- {\}) p (r +++ q +++ reversepath r)" + by (metis (mono_tags, hide_lams) \path r\ L \p \q \path p\ \path q\ homotopic_loops_conjugate loops not_in_path_image_join paf pas path_image_reversepath path_imp_reversepath path_join_eq pathfinish_join pathfinish_reversepath pathstart_join pathstart_reversepath rim subset_Compl_singleton winding_number_homotopic_loops winding_number_homotopic_paths_eq) + qed (use loops pas in auto) + moreover have "homotopic_loops (- {\}) (r +++ q +++ reversepath r) q" + using rim \q by (auto simp: homotopic_loops_conjugate paf \path q\ \path r\ loops) + ultimately show ?rhs + using homotopic_loops_trans by metis +next + assume ?rhs + then show ?lhs + by (simp add: winding_number_homotopic_loops) +qed + end diff -r 3548d54ce3ee -r 6617fb368a06 src/HOL/Complex_Analysis/Winding_Numbers.thy --- a/src/HOL/Complex_Analysis/Winding_Numbers.thy Mon Dec 02 22:40:16 2019 -0500 +++ b/src/HOL/Complex_Analysis/Winding_Numbers.thy Mon Dec 02 17:51:54 2019 +0100 @@ -1,23 +1,1274 @@ -section \Winding Numbers\ - -text\By John Harrison et al. Ported from HOL Light by L C Paulson (2017)\ - +section \Winding numbers\ theory Winding_Numbers -imports - Riemann_Mapping + imports Cauchy_Integral_Theorem begin -lemma simply_connected_inside_simple_path: - fixes p :: "real \ complex" - shows "simple_path p \ simply_connected(inside(path_image p))" - using Jordan_inside_outside connected_simple_path_image inside_simple_curve_imp_closed simply_connected_eq_frontier_properties - by fastforce +subsection \Definition\ + +definition\<^marker>\tag important\ winding_number_prop :: "[real \ complex, complex, real, real \ complex, complex] \ bool" where + "winding_number_prop \ z e p n \ + valid_path p \ z \ path_image p \ + pathstart p = pathstart \ \ + pathfinish p = pathfinish \ \ + (\t \ {0..1}. norm(\ t - p t) < e) \ + contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" + +definition\<^marker>\tag important\ winding_number:: "[real \ complex, complex] \ complex" where + "winding_number \ z \ SOME n. \e > 0. \p. winding_number_prop \ z e p n" + + +lemma winding_number: + assumes "path \" "z \ path_image \" "0 < e" + shows "\p. winding_number_prop \ z e p (winding_number \ z)" +proof - + have "path_image \ \ UNIV - {z}" + using assms by blast + then obtain d + where d: "d>0" + and pi_eq: "\h1 h2. valid_path h1 \ valid_path h2 \ + (\t\{0..1}. cmod (h1 t - \ t) < d \ cmod (h2 t - \ t) < d) \ + pathstart h2 = pathstart h1 \ pathfinish h2 = pathfinish h1 \ + path_image h1 \ UNIV - {z} \ path_image h2 \ UNIV - {z} \ + (\f. f holomorphic_on UNIV - {z} \ contour_integral h2 f = contour_integral h1 f)" + using contour_integral_nearby_ends [of "UNIV - {z}" \] assms by (auto simp: open_delete) + then obtain h where h: "polynomial_function h \ pathstart h = pathstart \ \ pathfinish h = pathfinish \ \ + (\t \ {0..1}. norm(h t - \ t) < d/2)" + using path_approx_polynomial_function [OF \path \\, of "d/2"] d by auto + define nn where "nn = 1/(2* pi*\) * contour_integral h (\w. 1/(w - z))" + have "\n. \e > 0. \p. winding_number_prop \ z e p n" + proof (rule_tac x=nn in exI, clarify) + fix e::real + assume e: "e>0" + obtain p where p: "polynomial_function p \ + pathstart p = pathstart \ \ pathfinish p = pathfinish \ \ (\t\{0..1}. cmod (p t - \ t) < min e (d/2))" + using path_approx_polynomial_function [OF \path \\, of "min e (d/2)"] d \0 by auto + have "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" + by (auto simp: intro!: holomorphic_intros) + then show "\p. winding_number_prop \ z e p nn" + apply (rule_tac x=p in exI) + using pi_eq [of h p] h p d + apply (auto simp: valid_path_polynomial_function norm_minus_commute nn_def winding_number_prop_def) + done + qed + then show ?thesis + unfolding winding_number_def by (rule someI2_ex) (blast intro: \0) +qed + +lemma winding_number_unique: + assumes \: "path \" "z \ path_image \" + and pi: "\e. e>0 \ \p. winding_number_prop \ z e p n" + shows "winding_number \ z = n" +proof - + have "path_image \ \ UNIV - {z}" + using assms by blast + then obtain e + where e: "e>0" + and pi_eq: "\h1 h2 f. \valid_path h1; valid_path h2; + (\t\{0..1}. cmod (h1 t - \ t) < e \ cmod (h2 t - \ t) < e); + pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1; f holomorphic_on UNIV - {z}\ \ + contour_integral h2 f = contour_integral h1 f" + using contour_integral_nearby_ends [of "UNIV - {z}" \] assms by (auto simp: open_delete) + obtain p where p: "winding_number_prop \ z e p n" + using pi [OF e] by blast + obtain q where q: "winding_number_prop \ z e q (winding_number \ z)" + using winding_number [OF \ e] by blast + have "2 * complex_of_real pi * \ * n = contour_integral p (\w. 1 / (w - z))" + using p by (auto simp: winding_number_prop_def) + also have "\ = contour_integral q (\w. 1 / (w - z))" + proof (rule pi_eq) + show "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" + by (auto intro!: holomorphic_intros) + qed (use p q in \auto simp: winding_number_prop_def norm_minus_commute\) + also have "\ = 2 * complex_of_real pi * \ * winding_number \ z" + using q by (auto simp: winding_number_prop_def) + finally have "2 * complex_of_real pi * \ * n = 2 * complex_of_real pi * \ * winding_number \ z" . + then show ?thesis + by simp +qed + +(*NB not winding_number_prop here due to the loop in p*) +lemma winding_number_unique_loop: + assumes \: "path \" "z \ path_image \" + and loop: "pathfinish \ = pathstart \" + and pi: + "\e. e>0 \ \p. valid_path p \ z \ path_image p \ + pathfinish p = pathstart p \ + (\t \ {0..1}. norm (\ t - p t) < e) \ + contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" + shows "winding_number \ z = n" +proof - + have "path_image \ \ UNIV - {z}" + using assms by blast + then obtain e + where e: "e>0" + and pi_eq: "\h1 h2 f. \valid_path h1; valid_path h2; + (\t\{0..1}. cmod (h1 t - \ t) < e \ cmod (h2 t - \ t) < e); + pathfinish h1 = pathstart h1; pathfinish h2 = pathstart h2; f holomorphic_on UNIV - {z}\ \ + contour_integral h2 f = contour_integral h1 f" + using contour_integral_nearby_loops [of "UNIV - {z}" \] assms by (auto simp: open_delete) + obtain p where p: + "valid_path p \ z \ path_image p \ pathfinish p = pathstart p \ + (\t \ {0..1}. norm (\ t - p t) < e) \ + contour_integral p (\w. 1/(w - z)) = 2 * pi * \ * n" + using pi [OF e] by blast + obtain q where q: "winding_number_prop \ z e q (winding_number \ z)" + using winding_number [OF \ e] by blast + have "2 * complex_of_real pi * \ * n = contour_integral p (\w. 1 / (w - z))" + using p by auto + also have "\ = contour_integral q (\w. 1 / (w - z))" + proof (rule pi_eq) + show "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}" + by (auto intro!: holomorphic_intros) + qed (use p q loop in \auto simp: winding_number_prop_def norm_minus_commute\) + also have "\ = 2 * complex_of_real pi * \ * winding_number \ z" + using q by (auto simp: winding_number_prop_def) + finally have "2 * complex_of_real pi * \ * n = 2 * complex_of_real pi * \ * winding_number \ z" . + then show ?thesis + by simp +qed + +proposition winding_number_valid_path: + assumes "valid_path \" "z \ path_image \" + shows "winding_number \ z = 1/(2*pi*\) * contour_integral \ (\w. 1/(w - z))" + by (rule winding_number_unique) + (use assms in \auto simp: valid_path_imp_path winding_number_prop_def\) + +proposition has_contour_integral_winding_number: + assumes \: "valid_path \" "z \ path_image \" + shows "((\w. 1/(w - z)) has_contour_integral (2*pi*\*winding_number \ z)) \" +by (simp add: winding_number_valid_path has_contour_integral_integral contour_integrable_inversediff assms) + +lemma winding_number_trivial [simp]: "z \ a \ winding_number(linepath a a) z = 0" + by (simp add: winding_number_valid_path) + +lemma winding_number_subpath_trivial [simp]: "z \ g x \ winding_number (subpath x x g) z = 0" + by (simp add: path_image_subpath winding_number_valid_path) + +lemma winding_number_join: + assumes \1: "path \1" "z \ path_image \1" + and \2: "path \2" "z \ path_image \2" + and "pathfinish \1 = pathstart \2" + shows "winding_number(\1 +++ \2) z = winding_number \1 z + winding_number \2 z" +proof (rule winding_number_unique) + show "\p. winding_number_prop (\1 +++ \2) z e p + (winding_number \1 z + winding_number \2 z)" if "e > 0" for e + proof - + obtain p1 where "winding_number_prop \1 z e p1 (winding_number \1 z)" + using \0 < e\ \1 winding_number by blast + moreover + obtain p2 where "winding_number_prop \2 z e p2 (winding_number \2 z)" + using \0 < e\ \2 winding_number by blast + ultimately + have "winding_number_prop (\1+++\2) z e (p1+++p2) (winding_number \1 z + winding_number \2 z)" + using assms + apply (simp add: winding_number_prop_def not_in_path_image_join contour_integrable_inversediff algebra_simps) + apply (auto simp: joinpaths_def) + done + then show ?thesis + by blast + qed +qed (use assms in \auto simp: not_in_path_image_join\) + +lemma winding_number_reversepath: + assumes "path \" "z \ path_image \" + shows "winding_number(reversepath \) z = - (winding_number \ z)" +proof (rule winding_number_unique) + show "\p. winding_number_prop (reversepath \) z e p (- winding_number \ z)" if "e > 0" for e + proof - + obtain p where "winding_number_prop \ z e p (winding_number \ z)" + using \0 < e\ assms winding_number by blast + then have "winding_number_prop (reversepath \) z e (reversepath p) (- winding_number \ z)" + using assms + apply (simp add: winding_number_prop_def contour_integral_reversepath contour_integrable_inversediff valid_path_imp_reverse) + apply (auto simp: reversepath_def) + done + then show ?thesis + by blast + qed +qed (use assms in auto) + +lemma winding_number_shiftpath: + assumes \: "path \" "z \ path_image \" + and "pathfinish \ = pathstart \" "a \ {0..1}" + shows "winding_number(shiftpath a \) z = winding_number \ z" +proof (rule winding_number_unique_loop) + show "\p. valid_path p \ z \ path_image p \ pathfinish p = pathstart p \ + (\t\{0..1}. cmod (shiftpath a \ t - p t) < e) \ + contour_integral p (\w. 1 / (w - z)) = + complex_of_real (2 * pi) * \ * winding_number \ z" + if "e > 0" for e + proof - + obtain p where "winding_number_prop \ z e p (winding_number \ z)" + using \0 < e\ assms winding_number by blast + then show ?thesis + apply (rule_tac x="shiftpath a p" in exI) + using assms that + apply (auto simp: winding_number_prop_def path_image_shiftpath pathfinish_shiftpath pathstart_shiftpath contour_integral_shiftpath) + apply (simp add: shiftpath_def) + done + qed +qed (use assms in \auto simp: path_shiftpath path_image_shiftpath pathfinish_shiftpath pathstart_shiftpath\) + +lemma winding_number_split_linepath: + assumes "c \ closed_segment a b" "z \ closed_segment a b" + shows "winding_number(linepath a b) z = winding_number(linepath a c) z + winding_number(linepath c b) z" +proof - + have "z \ closed_segment a c" "z \ closed_segment c b" + using assms by (meson convex_contains_segment convex_segment ends_in_segment subsetCE)+ + then show ?thesis + using assms + by (simp add: winding_number_valid_path contour_integral_split_linepath [symmetric] continuous_on_inversediff field_simps) +qed + +lemma winding_number_cong: + "(\t. \0 \ t; t \ 1\ \ p t = q t) \ winding_number p z = winding_number q z" + by (simp add: winding_number_def winding_number_prop_def pathstart_def pathfinish_def) + +lemma winding_number_constI: + assumes "c\z" "\t. \0\t; t\1\ \ g t = c" + shows "winding_number g z = 0" +proof - + have "winding_number g z = winding_number (linepath c c) z" + apply (rule winding_number_cong) + using assms unfolding linepath_def by auto + moreover have "winding_number (linepath c c) z =0" + apply (rule winding_number_trivial) + using assms by auto + ultimately show ?thesis by auto +qed + +lemma winding_number_offset: "winding_number p z = winding_number (\w. p w - z) 0" + unfolding winding_number_def +proof (intro ext arg_cong [where f = Eps] arg_cong [where f = All] imp_cong refl, safe) + fix n e g + assume "0 < e" and g: "winding_number_prop p z e g n" + then show "\r. winding_number_prop (\w. p w - z) 0 e r n" + by (rule_tac x="\t. g t - z" in exI) + (force simp: winding_number_prop_def contour_integral_integral valid_path_def path_defs + vector_derivative_def has_vector_derivative_diff_const piecewise_C1_differentiable_diff C1_differentiable_imp_piecewise) +next + fix n e g + assume "0 < e" and g: "winding_number_prop (\w. p w - z) 0 e g n" + then show "\r. winding_number_prop p z e r n" + apply (rule_tac x="\t. g t + z" in exI) + apply (simp add: winding_number_prop_def contour_integral_integral valid_path_def path_defs + piecewise_C1_differentiable_add vector_derivative_def has_vector_derivative_add_const C1_differentiable_imp_piecewise) + apply (force simp: algebra_simps) + done +qed + +lemma winding_number_negatepath: + assumes \: "valid_path \" and 0: "0 \ path_image \" + shows "winding_number(uminus \ \) 0 = winding_number \ 0" +proof - + have "(/) 1 contour_integrable_on \" + using "0" \ contour_integrable_inversediff by fastforce + then have "((\z. 1/z) has_contour_integral contour_integral \ ((/) 1)) \" + by (rule has_contour_integral_integral) + then have "((\z. 1 / - z) has_contour_integral - contour_integral \ ((/) 1)) \" + using has_contour_integral_neg by auto + then show ?thesis + using assms + apply (simp add: winding_number_valid_path valid_path_negatepath image_def path_defs) + apply (simp add: contour_integral_unique has_contour_integral_negatepath) + done +qed + +(* A combined theorem deducing several things piecewise.*) +lemma winding_number_join_pos_combined: + "\valid_path \1; z \ path_image \1; 0 < Re(winding_number \1 z); + valid_path \2; z \ path_image \2; 0 < Re(winding_number \2 z); pathfinish \1 = pathstart \2\ + \ valid_path(\1 +++ \2) \ z \ path_image(\1 +++ \2) \ 0 < Re(winding_number(\1 +++ \2) z)" + by (simp add: valid_path_join path_image_join winding_number_join valid_path_imp_path) + + +subsubsection\<^marker>\tag unimportant\ \Useful sufficient conditions for the winding number to be positive\ + +lemma Re_winding_number: + "\valid_path \; z \ path_image \\ + \ Re(winding_number \ z) = Im(contour_integral \ (\w. 1/(w - z))) / (2*pi)" +by (simp add: winding_number_valid_path field_simps Re_divide power2_eq_square) + +lemma winding_number_pos_le: + assumes \: "valid_path \" "z \ path_image \" + and ge: "\x. \0 < x; x < 1\ \ 0 \ Im (vector_derivative \ (at x) * cnj(\ x - z))" + shows "0 \ Re(winding_number \ z)" +proof - + have ge0: "0 \ Im (vector_derivative \ (at x) / (\ x - z))" if x: "0 < x" "x < 1" for x + using ge by (simp add: Complex.Im_divide algebra_simps x) + let ?vd = "\x. 1 / (\ x - z) * vector_derivative \ (at x)" + let ?int = "\z. contour_integral \ (\w. 1 / (w - z))" + have hi: "(?vd has_integral ?int z) (cbox 0 1)" + unfolding box_real + apply (subst has_contour_integral [symmetric]) + using \ by (simp add: contour_integrable_inversediff has_contour_integral_integral) + have "0 \ Im (?int z)" + proof (rule has_integral_component_nonneg [of \, simplified]) + show "\x. x \ cbox 0 1 \ 0 \ Im (if 0 < x \ x < 1 then ?vd x else 0)" + by (force simp: ge0) + show "((\x. if 0 < x \ x < 1 then ?vd x else 0) has_integral ?int z) (cbox 0 1)" + by (rule has_integral_spike_interior [OF hi]) simp + qed + then show ?thesis + by (simp add: Re_winding_number [OF \] field_simps) +qed + +lemma winding_number_pos_lt_lemma: + assumes \: "valid_path \" "z \ path_image \" + and e: "0 < e" + and ge: "\x. \0 < x; x < 1\ \ e \ Im (vector_derivative \ (at x) / (\ x - z))" + shows "0 < Re(winding_number \ z)" +proof - + let ?vd = "\x. 1 / (\ x - z) * vector_derivative \ (at x)" + let ?int = "\z. contour_integral \ (\w. 1 / (w - z))" + have hi: "(?vd has_integral ?int z) (cbox 0 1)" + unfolding box_real + apply (subst has_contour_integral [symmetric]) + using \ by (simp add: contour_integrable_inversediff has_contour_integral_integral) + have "e \ Im (contour_integral \ (\w. 1 / (w - z)))" + proof (rule has_integral_component_le [of \ "\x. \*e" "\*e" "{0..1}", simplified]) + show "((\x. if 0 < x \ x < 1 then ?vd x else \ * complex_of_real e) has_integral ?int z) {0..1}" + by (rule has_integral_spike_interior [OF hi, simplified box_real]) (use e in simp) + show "\x. 0 \ x \ x \ 1 \ + e \ Im (if 0 < x \ x < 1 then ?vd x else \ * complex_of_real e)" + by (simp add: ge) + qed (use has_integral_const_real [of _ 0 1] in auto) + with e show ?thesis + by (simp add: Re_winding_number [OF \] field_simps) +qed + +lemma winding_number_pos_lt: + assumes \: "valid_path \" "z \ path_image \" + and e: "0 < e" + and ge: "\x. \0 < x; x < 1\ \ e \ Im (vector_derivative \ (at x) * cnj(\ x - z))" + shows "0 < Re (winding_number \ z)" +proof - + have bm: "bounded ((\w. w - z) ` (path_image \))" + using bounded_translation [of _ "-z"] \ by (simp add: bounded_valid_path_image) + then obtain B where B: "B > 0" and Bno: "\x. x \ (\w. w - z) ` (path_image \) \ norm x \ B" + using bounded_pos [THEN iffD1, OF bm] by blast + { fix x::real assume x: "0 < x" "x < 1" + then have B2: "cmod (\ x - z)^2 \ B^2" using Bno [of "\ x - z"] + by (simp add: path_image_def power2_eq_square mult_mono') + with x have "\ x \ z" using \ + using path_image_def by fastforce + then have "e / B\<^sup>2 \ Im (vector_derivative \ (at x) * cnj (\ x - z)) / (cmod (\ x - z))\<^sup>2" + using B ge [OF x] B2 e + apply (rule_tac y="e / (cmod (\ x - z))\<^sup>2" in order_trans) + apply (auto simp: divide_left_mono divide_right_mono) + done + then have "e / B\<^sup>2 \ Im (vector_derivative \ (at x) / (\ x - z))" + by (simp add: complex_div_cnj [of _ "\ x - z" for x] del: complex_cnj_diff times_complex.sel) + } note * = this + show ?thesis + using e B by (simp add: * winding_number_pos_lt_lemma [OF \, of "e/B^2"]) +qed + +subsection\The winding number is an integer\ + +text\Proof from the book Complex Analysis by Lars V. Ahlfors, Chapter 4, section 2.1, + Also on page 134 of Serge Lang's book with the name title, etc.\ + +lemma exp_fg: + fixes z::complex + assumes g: "(g has_vector_derivative g') (at x within s)" + and f: "(f has_vector_derivative (g' / (g x - z))) (at x within s)" + and z: "g x \ z" + shows "((\x. exp(-f x) * (g x - z)) has_vector_derivative 0) (at x within s)" +proof - + have *: "(exp \ (\x. (- f x)) has_vector_derivative - (g' / (g x - z)) * exp (- f x)) (at x within s)" + using assms unfolding has_vector_derivative_def scaleR_conv_of_real + by (auto intro!: derivative_eq_intros) + show ?thesis + apply (rule has_vector_derivative_eq_rhs) + using z + apply (auto intro!: derivative_eq_intros * [unfolded o_def] g) + done +qed + +lemma winding_number_exp_integral: + fixes z::complex + assumes \: "\ piecewise_C1_differentiable_on {a..b}" + and ab: "a \ b" + and z: "z \ \ ` {a..b}" + shows "(\x. vector_derivative \ (at x) / (\ x - z)) integrable_on {a..b}" + (is "?thesis1") + "exp (- (integral {a..b} (\x. vector_derivative \ (at x) / (\ x - z)))) * (\ b - z) = \ a - z" + (is "?thesis2") +proof - + let ?D\ = "\x. vector_derivative \ (at x)" + have [simp]: "\x. a \ x \ x \ b \ \ x \ z" + using z by force + have cong: "continuous_on {a..b} \" + using \ by (simp add: piecewise_C1_differentiable_on_def) + obtain k where fink: "finite k" and g_C1_diff: "\ C1_differentiable_on ({a..b} - k)" + using \ by (force simp: piecewise_C1_differentiable_on_def) + have \: "open ({a<..finite k\ by (simp add: finite_imp_closed open_Diff) + moreover have "{a<.. {a..b} - k" + by force + ultimately have g_diff_at: "\x. \x \ k; x \ {a<.. \ \ differentiable at x" + by (metis Diff_iff differentiable_on_subset C1_diff_imp_diff [OF g_C1_diff] differentiable_on_def at_within_open) + { fix w + assume "w \ z" + have "continuous_on (ball w (cmod (w - z))) (\w. 1 / (w - z))" + by (auto simp: dist_norm intro!: continuous_intros) + moreover have "\x. cmod (w - x) < cmod (w - z) \ \f'. ((\w. 1 / (w - z)) has_field_derivative f') (at x)" + by (auto simp: intro!: derivative_eq_intros) + ultimately have "\h. \y. norm(y - w) < norm(w - z) \ (h has_field_derivative 1/(y - z)) (at y)" + using holomorphic_convex_primitive [of "ball w (norm(w - z))" "{}" "\w. 1/(w - z)"] + by (force simp: field_differentiable_def Ball_def dist_norm at_within_open_NO_MATCH norm_minus_commute) + } + then obtain h where h: "\w y. w \ z \ norm(y - w) < norm(w - z) \ (h w has_field_derivative 1/(y - z)) (at y)" + by meson + have exy: "\y. ((\x. inverse (\ x - z) * ?D\ x) has_integral y) {a..b}" + unfolding integrable_on_def [symmetric] + proof (rule contour_integral_local_primitive_any [OF piecewise_C1_imp_differentiable [OF \]]) + show "\d h. 0 < d \ + (\y. cmod (y - w) < d \ (h has_field_derivative inverse (y - z))(at y within - {z}))" + if "w \ - {z}" for w + apply (rule_tac x="norm(w - z)" in exI) + using that inverse_eq_divide has_field_derivative_at_within h + by (metis Compl_insert DiffD2 insertCI right_minus_eq zero_less_norm_iff) + qed simp + have vg_int: "(\x. ?D\ x / (\ x - z)) integrable_on {a..b}" + unfolding box_real [symmetric] divide_inverse_commute + by (auto intro!: exy integrable_subinterval simp add: integrable_on_def ab) + with ab show ?thesis1 + by (simp add: divide_inverse_commute integral_def integrable_on_def) + { fix t + assume t: "t \ {a..b}" + have cball: "continuous_on (ball (\ t) (dist (\ t) z)) (\x. inverse (x - z))" + using z by (auto intro!: continuous_intros simp: dist_norm) + have icd: "\x. cmod (\ t - x) < cmod (\ t - z) \ (\w. inverse (w - z)) field_differentiable at x" + unfolding field_differentiable_def by (force simp: intro!: derivative_eq_intros) + obtain h where h: "\x. cmod (\ t - x) < cmod (\ t - z) \ + (h has_field_derivative inverse (x - z)) (at x within {y. cmod (\ t - y) < cmod (\ t - z)})" + using holomorphic_convex_primitive [where f = "\w. inverse(w - z)", OF convex_ball finite.emptyI cball icd] + by simp (auto simp: ball_def dist_norm that) + { fix x D + assume x: "x \ k" "a < x" "x < b" + then have "x \ interior ({a..b} - k)" + using open_subset_interior [OF \] by fastforce + then have con: "isCont ?D\ x" + using g_C1_diff x by (auto simp: C1_differentiable_on_eq intro: continuous_on_interior) + then have con_vd: "continuous (at x within {a..b}) (\x. ?D\ x)" + by (rule continuous_at_imp_continuous_within) + have gdx: "\ differentiable at x" + using x by (simp add: g_diff_at) + have "\d. \x \ k; a < x; x < b; + (\ has_vector_derivative d) (at x); a \ t; t \ b\ + \ ((\x. integral {a..x} + (\x. ?D\ x / + (\ x - z))) has_vector_derivative + d / (\ x - z)) + (at x within {a..b})" + apply (rule has_vector_derivative_eq_rhs) + apply (rule integral_has_vector_derivative_continuous_at [where S = "{}", simplified]) + apply (rule con_vd continuous_intros cong vg_int | simp add: continuous_at_imp_continuous_within has_vector_derivative_continuous vector_derivative_at)+ + done + then have "((\c. exp (- integral {a..c} (\x. ?D\ x / (\ x - z))) * (\ c - z)) has_derivative (\h. 0)) + (at x within {a..b})" + using x gdx t + apply (clarsimp simp add: differentiable_iff_scaleR) + apply (rule exp_fg [unfolded has_vector_derivative_def, simplified], blast intro: has_derivative_at_withinI) + apply (simp_all add: has_vector_derivative_def [symmetric]) + done + } note * = this + have "exp (- (integral {a..t} (\x. ?D\ x / (\ x - z)))) * (\ t - z) =\ a - z" + apply (rule has_derivative_zero_unique_strong_interval [of "{a,b} \ k" a b]) + using t + apply (auto intro!: * continuous_intros fink cong indefinite_integral_continuous_1 [OF vg_int] simp add: ab)+ + done + } + with ab show ?thesis2 + by (simp add: divide_inverse_commute integral_def) +qed + +lemma winding_number_exp_2pi: + "\path p; z \ path_image p\ + \ pathfinish p - z = exp (2 * pi * \ * winding_number p z) * (pathstart p - z)" +using winding_number [of p z 1] unfolding valid_path_def path_image_def pathstart_def pathfinish_def winding_number_prop_def + by (force dest: winding_number_exp_integral(2) [of _ 0 1 z] simp: field_simps contour_integral_integral exp_minus) + +lemma integer_winding_number_eq: + assumes \: "path \" and z: "z \ path_image \" + shows "winding_number \ z \ \ \ pathfinish \ = pathstart \" +proof - + obtain p where p: "valid_path p" "z \ path_image p" + "pathstart p = pathstart \" "pathfinish p = pathfinish \" + and eq: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number \ z" + using winding_number [OF assms, of 1] unfolding winding_number_prop_def by auto + then have wneq: "winding_number \ z = winding_number p z" + using eq winding_number_valid_path by force + have iff: "(winding_number \ z \ \) \ (exp (contour_integral p (\w. 1 / (w - z))) = 1)" + using eq by (simp add: exp_eq_1 complex_is_Int_iff) + have "exp (contour_integral p (\w. 1 / (w - z))) = (\ 1 - z) / (\ 0 - z)" + using p winding_number_exp_integral(2) [of p 0 1 z] + apply (simp add: valid_path_def path_defs contour_integral_integral exp_minus field_split_simps) + by (metis path_image_def pathstart_def pathstart_in_path_image) + then have "winding_number p z \ \ \ pathfinish p = pathstart p" + using p wneq iff by (auto simp: path_defs) + then show ?thesis using p eq + by (auto simp: winding_number_valid_path) +qed + +theorem integer_winding_number: + "\path \; pathfinish \ = pathstart \; z \ path_image \\ \ winding_number \ z \ \" +by (metis integer_winding_number_eq) + + +text\If the winding number's magnitude is at least one, then the path must contain points in every direction.*) + We can thus bound the winding number of a path that doesn't intersect a given ray. \ + +lemma winding_number_pos_meets: + fixes z::complex + assumes \: "valid_path \" and z: "z \ path_image \" and 1: "Re (winding_number \ z) \ 1" + and w: "w \ z" + shows "\a::real. 0 < a \ z + a*(w - z) \ path_image \" +proof - + have [simp]: "\x. 0 \ x \ x \ 1 \ \ x \ z" + using z by (auto simp: path_image_def) + have [simp]: "z \ \ ` {0..1}" + using path_image_def z by auto + have gpd: "\ piecewise_C1_differentiable_on {0..1}" + using \ valid_path_def by blast + define r where "r = (w - z) / (\ 0 - z)" + have [simp]: "r \ 0" + using w z by (auto simp: r_def) + have cont: "continuous_on {0..1} + (\x. Im (integral {0..x} (\x. vector_derivative \ (at x) / (\ x - z))))" + by (intro continuous_intros indefinite_integral_continuous_1 winding_number_exp_integral [OF gpd]; simp) + have "Arg2pi r \ 2*pi" + by (simp add: Arg2pi less_eq_real_def) + also have "\ \ Im (integral {0..1} (\x. vector_derivative \ (at x) / (\ x - z)))" + using 1 + apply (simp add: winding_number_valid_path [OF \ z] contour_integral_integral) + apply (simp add: Complex.Re_divide field_simps power2_eq_square) + done + finally have "Arg2pi r \ Im (integral {0..1} (\x. vector_derivative \ (at x) / (\ x - z)))" . + then have "\t. t \ {0..1} \ Im(integral {0..t} (\x. vector_derivative \ (at x)/(\ x - z))) = Arg2pi r" + by (simp add: Arg2pi_ge_0 cont IVT') + then obtain t where t: "t \ {0..1}" + and eqArg: "Im (integral {0..t} (\x. vector_derivative \ (at x)/(\ x - z))) = Arg2pi r" + by blast + define i where "i = integral {0..t} (\x. vector_derivative \ (at x) / (\ x - z))" + have iArg: "Arg2pi r = Im i" + using eqArg by (simp add: i_def) + have gpdt: "\ piecewise_C1_differentiable_on {0..t}" + by (metis atLeastAtMost_iff atLeastatMost_subset_iff order_refl piecewise_C1_differentiable_on_subset gpd t) + have "exp (- i) * (\ t - z) = \ 0 - z" + unfolding i_def + apply (rule winding_number_exp_integral [OF gpdt]) + using t z unfolding path_image_def by force+ + then have *: "\ t - z = exp i * (\ 0 - z)" + by (simp add: exp_minus field_simps) + then have "(w - z) = r * (\ 0 - z)" + by (simp add: r_def) + then have "z + complex_of_real (exp (Re i)) * (w - z) / complex_of_real (cmod r) = \ t" + apply simp + apply (subst Complex_Transcendental.Arg2pi_eq [of r]) + apply (simp add: iArg) + using * apply (simp add: exp_eq_polar field_simps) + done + with t show ?thesis + by (rule_tac x="exp(Re i) / norm r" in exI) (auto simp: path_image_def) +qed + +lemma winding_number_big_meets: + fixes z::complex + assumes \: "valid_path \" and z: "z \ path_image \" and "\Re (winding_number \ z)\ \ 1" + and w: "w \ z" + shows "\a::real. 0 < a \ z + a*(w - z) \ path_image \" +proof - + { assume "Re (winding_number \ z) \ - 1" + then have "Re (winding_number (reversepath \) z) \ 1" + by (simp add: \ valid_path_imp_path winding_number_reversepath z) + moreover have "valid_path (reversepath \)" + using \ valid_path_imp_reverse by auto + moreover have "z \ path_image (reversepath \)" + by (simp add: z) + ultimately have "\a::real. 0 < a \ z + a*(w - z) \ path_image (reversepath \)" + using winding_number_pos_meets w by blast + then have ?thesis + by simp + } + then show ?thesis + using assms + by (simp add: abs_if winding_number_pos_meets split: if_split_asm) +qed + +lemma winding_number_less_1: + fixes z::complex + shows + "\valid_path \; z \ path_image \; w \ z; + \a::real. 0 < a \ z + a*(w - z) \ path_image \\ + \ Re(winding_number \ z) < 1" + by (auto simp: not_less dest: winding_number_big_meets) + +text\One way of proving that WN=1 for a loop.\ +lemma winding_number_eq_1: + fixes z::complex + assumes \: "valid_path \" and z: "z \ path_image \" and loop: "pathfinish \ = pathstart \" + and 0: "0 < Re(winding_number \ z)" and 2: "Re(winding_number \ z) < 2" + shows "winding_number \ z = 1" +proof - + have "winding_number \ z \ Ints" + by (simp add: \ integer_winding_number loop valid_path_imp_path z) + then show ?thesis + using 0 2 by (auto simp: Ints_def) +qed + +subsection\Continuity of winding number and invariance on connected sets\ -lemma simply_connected_Int: - fixes S :: "complex set" - assumes "open S" "open T" "simply_connected S" "simply_connected T" "connected (S \ T)" - shows "simply_connected (S \ T)" - using assms by (force simp: simply_connected_eq_winding_number_zero open_Int) +lemma continuous_at_winding_number: + fixes z::complex + assumes \: "path \" and z: "z \ path_image \" + shows "continuous (at z) (winding_number \)" +proof - + obtain e where "e>0" and cbg: "cball z e \ - path_image \" + using open_contains_cball [of "- path_image \"] z + by (force simp: closed_def [symmetric] closed_path_image [OF \]) + then have ppag: "path_image \ \ - cball z (e/2)" + by (force simp: cball_def dist_norm) + have oc: "open (- cball z (e / 2))" + by (simp add: closed_def [symmetric]) + obtain d where "d>0" and pi_eq: + "\h1 h2. \valid_path h1; valid_path h2; + (\t\{0..1}. cmod (h1 t - \ t) < d \ cmod (h2 t - \ t) < d); + pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1\ + \ + path_image h1 \ - cball z (e / 2) \ + path_image h2 \ - cball z (e / 2) \ + (\f. f holomorphic_on - cball z (e / 2) \ contour_integral h2 f = contour_integral h1 f)" + using contour_integral_nearby_ends [OF oc \ ppag] by metis + obtain p where p: "valid_path p" "z \ path_image p" + "pathstart p = pathstart \ \ pathfinish p = pathfinish \" + and pg: "\t. t\{0..1} \ cmod (\ t - p t) < min d e / 2" + and pi: "contour_integral p (\x. 1 / (x - z)) = complex_of_real (2 * pi) * \ * winding_number \ z" + using winding_number [OF \ z, of "min d e / 2"] \d>0\ \e>0\ by (auto simp: winding_number_prop_def) + { fix w + assume d2: "cmod (w - z) < d/2" and e2: "cmod (w - z) < e/2" + then have wnotp: "w \ path_image p" + using cbg \d>0\ \e>0\ + apply (simp add: path_image_def cball_def dist_norm, clarify) + apply (frule pg) + apply (drule_tac c="\ x" in subsetD) + apply (auto simp: less_eq_real_def norm_minus_commute norm_triangle_half_l) + done + have wnotg: "w \ path_image \" + using cbg e2 \e>0\ by (force simp: dist_norm norm_minus_commute) + { fix k::real + assume k: "k>0" + then obtain q where q: "valid_path q" "w \ path_image q" + "pathstart q = pathstart \ \ pathfinish q = pathfinish \" + and qg: "\t. t \ {0..1} \ cmod (\ t - q t) < min k (min d e) / 2" + and qi: "contour_integral q (\u. 1 / (u - w)) = complex_of_real (2 * pi) * \ * winding_number \ w" + using winding_number [OF \ wnotg, of "min k (min d e) / 2"] \d>0\ \e>0\ k + by (force simp: min_divide_distrib_right winding_number_prop_def) + have "contour_integral p (\u. 1 / (u - w)) = contour_integral q (\u. 1 / (u - w))" + apply (rule pi_eq [OF \valid_path q\ \valid_path p\, THEN conjunct2, THEN conjunct2, rule_format]) + apply (frule pg) + apply (frule qg) + using p q \d>0\ e2 + apply (auto simp: dist_norm norm_minus_commute intro!: holomorphic_intros) + done + then have "contour_integral p (\x. 1 / (x - w)) = complex_of_real (2 * pi) * \ * winding_number \ w" + by (simp add: pi qi) + } note pip = this + have "path p" + using p by (simp add: valid_path_imp_path) + then have "winding_number p w = winding_number \ w" + apply (rule winding_number_unique [OF _ wnotp]) + apply (rule_tac x=p in exI) + apply (simp add: p wnotp min_divide_distrib_right pip winding_number_prop_def) + done + } note wnwn = this + obtain pe where "pe>0" and cbp: "cball z (3 / 4 * pe) \ - path_image p" + using p open_contains_cball [of "- path_image p"] + by (force simp: closed_def [symmetric] closed_path_image [OF valid_path_imp_path]) + obtain L + where "L>0" + and L: "\f B. \f holomorphic_on - cball z (3 / 4 * pe); + \z \ - cball z (3 / 4 * pe). cmod (f z) \ B\ \ + cmod (contour_integral p f) \ L * B" + using contour_integral_bound_exists [of "- cball z (3/4*pe)" p] cbp \valid_path p\ by blast + { fix e::real and w::complex + assume e: "0 < e" and w: "cmod (w - z) < pe/4" "cmod (w - z) < e * pe\<^sup>2 / (8 * L)" + then have [simp]: "w \ path_image p" + using cbp p(2) \0 < pe\ + by (force simp: dist_norm norm_minus_commute path_image_def cball_def) + have [simp]: "contour_integral p (\x. 1/(x - w)) - contour_integral p (\x. 1/(x - z)) = + contour_integral p (\x. 1/(x - w) - 1/(x - z))" + by (simp add: p contour_integrable_inversediff contour_integral_diff) + { fix x + assume pe: "3/4 * pe < cmod (z - x)" + have "cmod (w - x) < pe/4 + cmod (z - x)" + by (meson add_less_cancel_right norm_diff_triangle_le order_refl order_trans_rules(21) w(1)) + then have wx: "cmod (w - x) < 4/3 * cmod (z - x)" using pe by simp + have "cmod (z - x) \ cmod (z - w) + cmod (w - x)" + using norm_diff_triangle_le by blast + also have "\ < pe/4 + cmod (w - x)" + using w by (simp add: norm_minus_commute) + finally have "pe/2 < cmod (w - x)" + using pe by auto + then have "(pe/2)^2 < cmod (w - x) ^ 2" + apply (rule power_strict_mono) + using \pe>0\ by auto + then have pe2: "pe^2 < 4 * cmod (w - x) ^ 2" + by (simp add: power_divide) + have "8 * L * cmod (w - z) < e * pe\<^sup>2" + using w \L>0\ by (simp add: field_simps) + also have "\ < e * 4 * cmod (w - x) * cmod (w - x)" + using pe2 \e>0\ by (simp add: power2_eq_square) + also have "\ < e * 4 * cmod (w - x) * (4/3 * cmod (z - x))" + using wx + apply (rule mult_strict_left_mono) + using pe2 e not_less_iff_gr_or_eq by fastforce + finally have "L * cmod (w - z) < 2/3 * e * cmod (w - x) * cmod (z - x)" + by simp + also have "\ \ e * cmod (w - x) * cmod (z - x)" + using e by simp + finally have Lwz: "L * cmod (w - z) < e * cmod (w - x) * cmod (z - x)" . + have "L * cmod (1 / (x - w) - 1 / (x - z)) \ e" + apply (cases "x=z \ x=w") + using pe \pe>0\ w \L>0\ + apply (force simp: norm_minus_commute) + using wx w(2) \L>0\ pe pe2 Lwz + apply (auto simp: divide_simps mult_less_0_iff norm_minus_commute norm_divide norm_mult power2_eq_square) + done + } note L_cmod_le = this + have *: "cmod (contour_integral p (\x. 1 / (x - w) - 1 / (x - z))) \ L * (e * pe\<^sup>2 / L / 4 * (inverse (pe / 2))\<^sup>2)" + apply (rule L) + using \pe>0\ w + apply (force simp: dist_norm norm_minus_commute intro!: holomorphic_intros) + using \pe>0\ w \L>0\ + apply (auto simp: cball_def dist_norm field_simps L_cmod_le simp del: less_divide_eq_numeral1 le_divide_eq_numeral1) + done + have "cmod (contour_integral p (\x. 1 / (x - w)) - contour_integral p (\x. 1 / (x - z))) < 2*e" + apply simp + apply (rule le_less_trans [OF *]) + using \L>0\ e + apply (force simp: field_simps) + done + then have "cmod (winding_number p w - winding_number p z) < e" + using pi_ge_two e + by (force simp: winding_number_valid_path p field_simps norm_divide norm_mult intro: less_le_trans) + } note cmod_wn_diff = this + then have "isCont (winding_number p) z" + apply (simp add: continuous_at_eps_delta, clarify) + apply (rule_tac x="min (pe/4) (e/2*pe^2/L/4)" in exI) + using \pe>0\ \L>0\ + apply (simp add: dist_norm cmod_wn_diff) + done + then show ?thesis + apply (rule continuous_transform_within [where d = "min d e / 2"]) + apply (auto simp: \d>0\ \e>0\ dist_norm wnwn) + done +qed + +corollary continuous_on_winding_number: + "path \ \ continuous_on (- path_image \) (\w. winding_number \ w)" + by (simp add: continuous_at_imp_continuous_on continuous_at_winding_number) + +subsection\<^marker>\tag unimportant\ \The winding number is constant on a connected region\ + +lemma winding_number_constant: + assumes \: "path \" and loop: "pathfinish \ = pathstart \" and cs: "connected S" and sg: "S \ path_image \ = {}" + shows "winding_number \ constant_on S" +proof - + have *: "1 \ cmod (winding_number \ y - winding_number \ z)" + if ne: "winding_number \ y \ winding_number \ z" and "y \ S" "z \ S" for y z + proof - + have "winding_number \ y \ \" "winding_number \ z \ \" + using that integer_winding_number [OF \ loop] sg \y \ S\ by auto + with ne show ?thesis + by (auto simp: Ints_def simp flip: of_int_diff) + qed + have cont: "continuous_on S (\w. winding_number \ w)" + using continuous_on_winding_number [OF \] sg + by (meson continuous_on_subset disjoint_eq_subset_Compl) + show ?thesis + using "*" zero_less_one + by (blast intro: continuous_discrete_range_constant [OF cs cont]) +qed + +lemma winding_number_eq: + "\path \; pathfinish \ = pathstart \; w \ S; z \ S; connected S; S \ path_image \ = {}\ + \ winding_number \ w = winding_number \ z" + using winding_number_constant by (metis constant_on_def) + +lemma open_winding_number_levelsets: + assumes \: "path \" and loop: "pathfinish \ = pathstart \" + shows "open {z. z \ path_image \ \ winding_number \ z = k}" +proof - + have opn: "open (- path_image \)" + by (simp add: closed_path_image \ open_Compl) + { fix z assume z: "z \ path_image \" and k: "k = winding_number \ z" + obtain e where e: "e>0" "ball z e \ - path_image \" + using open_contains_ball [of "- path_image \"] opn z + by blast + have "\e>0. \y. dist y z < e \ y \ path_image \ \ winding_number \ y = winding_number \ z" + apply (rule_tac x=e in exI) + using e apply (simp add: dist_norm ball_def norm_minus_commute) + apply (auto simp: dist_norm norm_minus_commute intro!: winding_number_eq [OF assms, where S = "ball z e"]) + done + } then + show ?thesis + by (auto simp: open_dist) +qed + +subsection\Winding number is zero "outside" a curve\ + +proposition winding_number_zero_in_outside: + assumes \: "path \" and loop: "pathfinish \ = pathstart \" and z: "z \ outside (path_image \)" + shows "winding_number \ z = 0" +proof - + obtain B::real where "0 < B" and B: "path_image \ \ ball 0 B" + using bounded_subset_ballD [OF bounded_path_image [OF \]] by auto + obtain w::complex where w: "w \ ball 0 (B + 1)" + by (metis abs_of_nonneg le_less less_irrefl mem_ball_0 norm_of_real) + have "- ball 0 (B + 1) \ outside (path_image \)" + apply (rule outside_subset_convex) + using B subset_ball by auto + then have wout: "w \ outside (path_image \)" + using w by blast + moreover have "winding_number \ constant_on outside (path_image \)" + using winding_number_constant [OF \ loop, of "outside(path_image \)"] connected_outside + by (metis DIM_complex bounded_path_image dual_order.refl \ outside_no_overlap) + ultimately have "winding_number \ z = winding_number \ w" + by (metis (no_types, hide_lams) constant_on_def z) + also have "\ = 0" + proof - + have wnot: "w \ path_image \" using wout by (simp add: outside_def) + { fix e::real assume "0" "pathfinish p = pathfinish \" + and pg1: "(\t. \0 \ t; t \ 1\ \ cmod (p t - \ t) < 1)" + and pge: "(\t. \0 \ t; t \ 1\ \ cmod (p t - \ t) < e)" + using path_approx_polynomial_function [OF \, of "min 1 e"] \e>0\ by force + have pip: "path_image p \ ball 0 (B + 1)" + using B + apply (clarsimp simp add: path_image_def dist_norm ball_def) + apply (frule (1) pg1) + apply (fastforce dest: norm_add_less) + done + then have "w \ path_image p" using w by blast + then have "\p. valid_path p \ w \ path_image p \ + pathstart p = pathstart \ \ pathfinish p = pathfinish \ \ + (\t\{0..1}. cmod (\ t - p t) < e) \ contour_integral p (\wa. 1 / (wa - w)) = 0" + apply (rule_tac x=p in exI) + apply (simp add: p valid_path_polynomial_function) + apply (intro conjI) + using pge apply (simp add: norm_minus_commute) + apply (rule contour_integral_unique [OF Cauchy_theorem_convex_simple [OF _ convex_ball [of 0 "B+1"]]]) + apply (rule holomorphic_intros | simp add: dist_norm)+ + using mem_ball_0 w apply blast + using p apply (simp_all add: valid_path_polynomial_function loop pip) + done + } + then show ?thesis + by (auto intro: winding_number_unique [OF \] simp add: winding_number_prop_def wnot) + qed + finally show ?thesis . +qed + +corollary\<^marker>\tag unimportant\ winding_number_zero_const: "a \ z \ winding_number (\t. a) z = 0" + by (rule winding_number_zero_in_outside) + (auto simp: pathfinish_def pathstart_def path_polynomial_function) + +corollary\<^marker>\tag unimportant\ winding_number_zero_outside: + "\path \; convex s; pathfinish \ = pathstart \; z \ s; path_image \ \ s\ \ winding_number \ z = 0" + by (meson convex_in_outside outside_mono subsetCE winding_number_zero_in_outside) + +lemma winding_number_zero_at_infinity: + assumes \: "path \" and loop: "pathfinish \ = pathstart \" + shows "\B. \z. B \ norm z \ winding_number \ z = 0" +proof - + obtain B::real where "0 < B" and B: "path_image \ \ ball 0 B" + using bounded_subset_ballD [OF bounded_path_image [OF \]] by auto + then show ?thesis + apply (rule_tac x="B+1" in exI, clarify) + apply (rule winding_number_zero_outside [OF \ convex_cball [of 0 B] loop]) + apply (meson less_add_one mem_cball_0 not_le order_trans) + using ball_subset_cball by blast +qed + +lemma winding_number_zero_point: + "\path \; convex s; pathfinish \ = pathstart \; open s; path_image \ \ s\ + \ \z. z \ s \ winding_number \ z = 0" + using outside_compact_in_open [of "path_image \" s] path_image_nonempty winding_number_zero_in_outside + by (fastforce simp add: compact_path_image) + + +text\If a path winds round a set, it winds rounds its inside.\ +lemma winding_number_around_inside: + assumes \: "path \" and loop: "pathfinish \ = pathstart \" + and cls: "closed s" and cos: "connected s" and s_disj: "s \ path_image \ = {}" + and z: "z \ s" and wn_nz: "winding_number \ z \ 0" and w: "w \ s \ inside s" + shows "winding_number \ w = winding_number \ z" +proof - + have ssb: "s \ inside(path_image \)" + proof + fix x :: complex + assume "x \ s" + hence "x \ path_image \" + by (meson disjoint_iff_not_equal s_disj) + thus "x \ inside (path_image \)" + using \x \ s\ by (metis (no_types) ComplI UnE cos \ loop s_disj union_with_outside winding_number_eq winding_number_zero_in_outside wn_nz z) +qed + show ?thesis + apply (rule winding_number_eq [OF \ loop w]) + using z apply blast + apply (simp add: cls connected_with_inside cos) + apply (simp add: Int_Un_distrib2 s_disj, safe) + by (meson ssb inside_inside_compact_connected [OF cls, of "path_image \"] compact_path_image connected_path_image contra_subsetD disjoint_iff_not_equal \ inside_no_overlap) + qed + + +text\Bounding a WN by 1/2 for a path and point in opposite halfspaces.\ +lemma winding_number_subpath_continuous: + assumes \: "valid_path \" and z: "z \ path_image \" + shows "continuous_on {0..1} (\x. winding_number(subpath 0 x \) z)" +proof - + have *: "integral {0..x} (\t. vector_derivative \ (at t) / (\ t - z)) / (2 * of_real pi * \) = + winding_number (subpath 0 x \) z" + if x: "0 \ x" "x \ 1" for x + proof - + have "integral {0..x} (\t. vector_derivative \ (at t) / (\ t - z)) / (2 * of_real pi * \) = + 1 / (2*pi*\) * contour_integral (subpath 0 x \) (\w. 1/(w - z))" + using assms x + apply (simp add: contour_integral_subcontour_integral [OF contour_integrable_inversediff]) + done + also have "\ = winding_number (subpath 0 x \) z" + apply (subst winding_number_valid_path) + using assms x + apply (simp_all add: path_image_subpath valid_path_subpath) + by (force simp: path_image_def) + finally show ?thesis . + qed + show ?thesis + apply (rule continuous_on_eq + [where f = "\x. 1 / (2*pi*\) * + integral {0..x} (\t. 1/(\ t - z) * vector_derivative \ (at t))"]) + apply (rule continuous_intros)+ + apply (rule indefinite_integral_continuous_1) + apply (rule contour_integrable_inversediff [OF assms, unfolded contour_integrable_on]) + using assms + apply (simp add: *) + done +qed + +lemma winding_number_ivt_pos: + assumes \: "valid_path \" and z: "z \ path_image \" and "0 \ w" "w \ Re(winding_number \ z)" + shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w" + apply (rule ivt_increasing_component_on_1 [of 0 1, where ?k = "1::complex", simplified complex_inner_1_right], simp) + apply (rule winding_number_subpath_continuous [OF \ z]) + using assms + apply (auto simp: path_image_def image_def) + done + +lemma winding_number_ivt_neg: + assumes \: "valid_path \" and z: "z \ path_image \" and "Re(winding_number \ z) \ w" "w \ 0" + shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w" + apply (rule ivt_decreasing_component_on_1 [of 0 1, where ?k = "1::complex", simplified complex_inner_1_right], simp) + apply (rule winding_number_subpath_continuous [OF \ z]) + using assms + apply (auto simp: path_image_def image_def) + done + +lemma winding_number_ivt_abs: + assumes \: "valid_path \" and z: "z \ path_image \" and "0 \ w" "w \ \Re(winding_number \ z)\" + shows "\t \ {0..1}. \Re (winding_number (subpath 0 t \) z)\ = w" + using assms winding_number_ivt_pos [of \ z w] winding_number_ivt_neg [of \ z "-w"] + by force + +lemma winding_number_lt_half_lemma: + assumes \: "valid_path \" and z: "z \ path_image \" and az: "a \ z \ b" and pag: "path_image \ \ {w. a \ w > b}" + shows "Re(winding_number \ z) < 1/2" +proof - + { assume "Re(winding_number \ z) \ 1/2" + then obtain t::real where t: "0 \ t" "t \ 1" and sub12: "Re (winding_number (subpath 0 t \) z) = 1/2" + using winding_number_ivt_pos [OF \ z, of "1/2"] by auto + have gt: "\ t - z = - (of_real (exp (- (2 * pi * Im (winding_number (subpath 0 t \) z)))) * (\ 0 - z))" + using winding_number_exp_2pi [of "subpath 0 t \" z] + apply (simp add: t \ valid_path_imp_path) + using closed_segment_eq_real_ivl path_image_def t z by (fastforce simp: path_image_subpath Euler sub12) + have "b < a \ \ 0" + proof - + have "\ 0 \ {c. b < a \ c}" + by (metis (no_types) pag atLeastAtMost_iff image_subset_iff order_refl path_image_def zero_le_one) + thus ?thesis + by blast + qed + moreover have "b < a \ \ t" + proof - + have "\ t \ {c. b < a \ c}" + by (metis (no_types) pag atLeastAtMost_iff image_subset_iff path_image_def t) + thus ?thesis + by blast + qed + ultimately have "0 < a \ (\ 0 - z)" "0 < a \ (\ t - z)" using az + by (simp add: inner_diff_right)+ + then have False + by (simp add: gt inner_mult_right mult_less_0_iff) + } + then show ?thesis by force +qed + +lemma winding_number_lt_half: + assumes "valid_path \" "a \ z \ b" "path_image \ \ {w. a \ w > b}" + shows "\Re (winding_number \ z)\ < 1/2" +proof - + have "z \ path_image \" using assms by auto + with assms show ?thesis + apply (simp add: winding_number_lt_half_lemma abs_if del: less_divide_eq_numeral1) + apply (metis complex_inner_1_right winding_number_lt_half_lemma [OF valid_path_imp_reverse, of \ z a b] + winding_number_reversepath valid_path_imp_path inner_minus_left path_image_reversepath) + done +qed + +lemma winding_number_le_half: + assumes \: "valid_path \" and z: "z \ path_image \" + and anz: "a \ 0" and azb: "a \ z \ b" and pag: "path_image \ \ {w. a \ w \ b}" + shows "\Re (winding_number \ z)\ \ 1/2" +proof - + { assume wnz_12: "\Re (winding_number \ z)\ > 1/2" + have "isCont (winding_number \) z" + by (metis continuous_at_winding_number valid_path_imp_path \ z) + then obtain d where "d>0" and d: "\x'. dist x' z < d \ dist (winding_number \ x') (winding_number \ z) < \Re(winding_number \ z)\ - 1/2" + using continuous_at_eps_delta wnz_12 diff_gt_0_iff_gt by blast + define z' where "z' = z - (d / (2 * cmod a)) *\<^sub>R a" + have *: "a \ z' \ b - d / 3 * cmod a" + unfolding z'_def inner_mult_right' divide_inverse + apply (simp add: field_split_simps algebra_simps dot_square_norm power2_eq_square anz) + apply (metis \0 < d\ add_increasing azb less_eq_real_def mult_nonneg_nonneg mult_right_mono norm_ge_zero norm_numeral) + done + have "cmod (winding_number \ z' - winding_number \ z) < \Re (winding_number \ z)\ - 1/2" + using d [of z'] anz \d>0\ by (simp add: dist_norm z'_def) + then have "1/2 < \Re (winding_number \ z)\ - cmod (winding_number \ z' - winding_number \ z)" + by simp + then have "1/2 < \Re (winding_number \ z)\ - \Re (winding_number \ z') - Re (winding_number \ z)\" + using abs_Re_le_cmod [of "winding_number \ z' - winding_number \ z"] by simp + then have wnz_12': "\Re (winding_number \ z')\ > 1/2" + by linarith + moreover have "\Re (winding_number \ z')\ < 1/2" + apply (rule winding_number_lt_half [OF \ *]) + using azb \d>0\ pag + apply (auto simp: add_strict_increasing anz field_split_simps dest!: subsetD) + done + ultimately have False + by simp + } + then show ?thesis by force +qed + +lemma winding_number_lt_half_linepath: "z \ closed_segment a b \ \Re (winding_number (linepath a b) z)\ < 1/2" + using separating_hyperplane_closed_point [of "closed_segment a b" z] + apply auto + apply (simp add: closed_segment_def) + apply (drule less_imp_le) + apply (frule winding_number_lt_half [OF valid_path_linepath [of a b]]) + apply (auto simp: segment) + done + + +text\ Positivity of WN for a linepath.\ +lemma winding_number_linepath_pos_lt: + assumes "0 < Im ((b - a) * cnj (b - z))" + shows "0 < Re(winding_number(linepath a b) z)" +proof - + have z: "z \ path_image (linepath a b)" + using assms + by (simp add: closed_segment_def) (force simp: algebra_simps) + show ?thesis + apply (rule winding_number_pos_lt [OF valid_path_linepath z assms]) + apply (simp add: linepath_def algebra_simps) + done +qed + +subsection\<^marker>\tag unimportant\ \More winding number properties\ + +text\including the fact that it's +-1 inside a simple closed curve.\ + +lemma winding_number_homotopic_paths: + assumes "homotopic_paths (-{z}) g h" + shows "winding_number g z = winding_number h z" +proof - + have "path g" "path h" using homotopic_paths_imp_path [OF assms] by auto + moreover have pag: "z \ path_image g" and pah: "z \ path_image h" + using homotopic_paths_imp_subset [OF assms] by auto + ultimately obtain d e where "d > 0" "e > 0" + and d: "\p. \path p; pathstart p = pathstart g; pathfinish p = pathfinish g; \t\{0..1}. norm (p t - g t) < d\ + \ homotopic_paths (-{z}) g p" + and e: "\q. \path q; pathstart q = pathstart h; pathfinish q = pathfinish h; \t\{0..1}. norm (q t - h t) < e\ + \ homotopic_paths (-{z}) h q" + using homotopic_nearby_paths [of g "-{z}"] homotopic_nearby_paths [of h "-{z}"] by force + obtain p where p: + "valid_path p" "z \ path_image p" + "pathstart p = pathstart g" "pathfinish p = pathfinish g" + and gp_less:"\t\{0..1}. cmod (g t - p t) < d" + and pap: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number g z" + using winding_number [OF \path g\ pag \0 < d\] unfolding winding_number_prop_def by blast + obtain q where q: + "valid_path q" "z \ path_image q" + "pathstart q = pathstart h" "pathfinish q = pathfinish h" + and hq_less: "\t\{0..1}. cmod (h t - q t) < e" + and paq: "contour_integral q (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number h z" + using winding_number [OF \path h\ pah \0 < e\] unfolding winding_number_prop_def by blast + have "homotopic_paths (- {z}) g p" + by (simp add: d p valid_path_imp_path norm_minus_commute gp_less) + moreover have "homotopic_paths (- {z}) h q" + by (simp add: e q valid_path_imp_path norm_minus_commute hq_less) + ultimately have "homotopic_paths (- {z}) p q" + by (blast intro: homotopic_paths_trans homotopic_paths_sym assms) + then have "contour_integral p (\w. 1/(w - z)) = contour_integral q (\w. 1/(w - z))" + by (rule Cauchy_theorem_homotopic_paths) (auto intro!: holomorphic_intros simp: p q) + then show ?thesis + by (simp add: pap paq) +qed + +lemma winding_number_homotopic_loops: + assumes "homotopic_loops (-{z}) g h" + shows "winding_number g z = winding_number h z" +proof - + have "path g" "path h" using homotopic_loops_imp_path [OF assms] by auto + moreover have pag: "z \ path_image g" and pah: "z \ path_image h" + using homotopic_loops_imp_subset [OF assms] by auto + moreover have gloop: "pathfinish g = pathstart g" and hloop: "pathfinish h = pathstart h" + using homotopic_loops_imp_loop [OF assms] by auto + ultimately obtain d e where "d > 0" "e > 0" + and d: "\p. \path p; pathfinish p = pathstart p; \t\{0..1}. norm (p t - g t) < d\ + \ homotopic_loops (-{z}) g p" + and e: "\q. \path q; pathfinish q = pathstart q; \t\{0..1}. norm (q t - h t) < e\ + \ homotopic_loops (-{z}) h q" + using homotopic_nearby_loops [of g "-{z}"] homotopic_nearby_loops [of h "-{z}"] by force + obtain p where p: + "valid_path p" "z \ path_image p" + "pathstart p = pathstart g" "pathfinish p = pathfinish g" + and gp_less:"\t\{0..1}. cmod (g t - p t) < d" + and pap: "contour_integral p (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number g z" + using winding_number [OF \path g\ pag \0 < d\] unfolding winding_number_prop_def by blast + obtain q where q: + "valid_path q" "z \ path_image q" + "pathstart q = pathstart h" "pathfinish q = pathfinish h" + and hq_less: "\t\{0..1}. cmod (h t - q t) < e" + and paq: "contour_integral q (\w. 1 / (w - z)) = complex_of_real (2 * pi) * \ * winding_number h z" + using winding_number [OF \path h\ pah \0 < e\] unfolding winding_number_prop_def by blast + have gp: "homotopic_loops (- {z}) g p" + by (simp add: gloop d gp_less norm_minus_commute p valid_path_imp_path) + have hq: "homotopic_loops (- {z}) h q" + by (simp add: e hloop hq_less norm_minus_commute q valid_path_imp_path) + have "contour_integral p (\w. 1/(w - z)) = contour_integral q (\w. 1/(w - z))" + proof (rule Cauchy_theorem_homotopic_loops) + show "homotopic_loops (- {z}) p q" + by (blast intro: homotopic_loops_trans homotopic_loops_sym gp hq assms) + qed (auto intro!: holomorphic_intros simp: p q) + then show ?thesis + by (simp add: pap paq) +qed + +lemma winding_number_paths_linear_eq: + "\path g; path h; pathstart h = pathstart g; pathfinish h = pathfinish g; + \t. t \ {0..1} \ z \ closed_segment (g t) (h t)\ + \ winding_number h z = winding_number g z" + by (blast intro: sym homotopic_paths_linear winding_number_homotopic_paths) + +lemma winding_number_loops_linear_eq: + "\path g; path h; pathfinish g = pathstart g; pathfinish h = pathstart h; + \t. t \ {0..1} \ z \ closed_segment (g t) (h t)\ + \ winding_number h z = winding_number g z" + by (blast intro: sym homotopic_loops_linear winding_number_homotopic_loops) + +lemma winding_number_nearby_paths_eq: + "\path g; path h; pathstart h = pathstart g; pathfinish h = pathfinish g; + \t. t \ {0..1} \ norm(h t - g t) < norm(g t - z)\ + \ winding_number h z = winding_number g z" + by (metis segment_bound(2) norm_minus_commute not_le winding_number_paths_linear_eq) + +lemma winding_number_nearby_loops_eq: + "\path g; path h; pathfinish g = pathstart g; pathfinish h = pathstart h; + \t. t \ {0..1} \ norm(h t - g t) < norm(g t - z)\ + \ winding_number h z = winding_number g z" + by (metis segment_bound(2) norm_minus_commute not_le winding_number_loops_linear_eq) + + +lemma winding_number_subpath_combine: + "\path g; z \ path_image g; + u \ {0..1}; v \ {0..1}; w \ {0..1}\ + \ winding_number (subpath u v g) z + winding_number (subpath v w g) z = + winding_number (subpath u w g) z" +apply (rule trans [OF winding_number_join [THEN sym] + winding_number_homotopic_paths [OF homotopic_join_subpaths]]) + using path_image_subpath_subset by auto + +text \Winding numbers of circular contours\ + +proposition winding_number_part_circlepath_pos_less: + assumes "s < t" and no: "norm(w - z) < r" + shows "0 < Re (winding_number(part_circlepath z r s t) w)" +proof - + have "0 < r" by (meson no norm_not_less_zero not_le order.strict_trans2) + note valid_path_part_circlepath + moreover have " w \ path_image (part_circlepath z r s t)" + using assms by (auto simp: path_image_def image_def part_circlepath_def norm_mult linepath_def) + moreover have "0 < r * (t - s) * (r - cmod (w - z))" + using assms by (metis \0 < r\ diff_gt_0_iff_gt mult_pos_pos) + ultimately show ?thesis + apply (rule winding_number_pos_lt [where e = "r*(t - s)*(r - norm(w - z))"]) + apply (simp add: vector_derivative_part_circlepath right_diff_distrib [symmetric] mult_ac) + apply (rule mult_left_mono)+ + using Re_Im_le_cmod [of "w-z" "linepath s t x" for x] + apply (simp add: exp_Euler cos_of_real sin_of_real part_circlepath_def algebra_simps cos_squared_eq [unfolded power2_eq_square]) + using assms \0 < r\ by auto +qed + +lemma winding_number_circlepath_centre: "0 < r \ winding_number (circlepath z r) z = 1" + apply (rule winding_number_unique_loop) + apply (simp_all add: sphere_def valid_path_imp_path) + apply (rule_tac x="circlepath z r" in exI) + apply (simp add: sphere_def contour_integral_circlepath) + done + +proposition winding_number_circlepath: + assumes "norm(w - z) < r" shows "winding_number(circlepath z r) w = 1" +proof (cases "w = z") + case True then show ?thesis + using assms winding_number_circlepath_centre by auto +next + case False + have [simp]: "r > 0" + using assms le_less_trans norm_ge_zero by blast + define r' where "r' = norm(w - z)" + have "r' < r" + by (simp add: assms r'_def) + have disjo: "cball z r' \ sphere z r = {}" + using \r' < r\ by (force simp: cball_def sphere_def) + have "winding_number(circlepath z r) w = winding_number(circlepath z r) z" + proof (rule winding_number_around_inside [where s = "cball z r'"]) + show "winding_number (circlepath z r) z \ 0" + by (simp add: winding_number_circlepath_centre) + show "cball z r' \ path_image (circlepath z r) = {}" + by (simp add: disjo less_eq_real_def) + qed (auto simp: r'_def dist_norm norm_minus_commute) + also have "\ = 1" + by (simp add: winding_number_circlepath_centre) + finally show ?thesis . +qed + +lemma no_bounded_connected_component_imp_winding_number_zero: + assumes g: "path g" "path_image g \ s" "pathfinish g = pathstart g" "z \ s" + and nb: "\z. bounded (connected_component_set (- s) z) \ z \ s" + shows "winding_number g z = 0" +apply (rule winding_number_zero_in_outside) +apply (simp_all add: assms) +by (metis nb [of z] \path_image g \ s\ \z \ s\ contra_subsetD mem_Collect_eq outside outside_mono) + +lemma no_bounded_path_component_imp_winding_number_zero: + assumes g: "path g" "path_image g \ s" "pathfinish g = pathstart g" "z \ s" + and nb: "\z. bounded (path_component_set (- s) z) \ z \ s" + shows "winding_number g z = 0" +apply (rule no_bounded_connected_component_imp_winding_number_zero [OF g]) +by (simp add: bounded_subset nb path_component_subset_connected_component) subsection\Winding number for a triangle\ @@ -913,241 +2164,4 @@ finally show ?thesis . qed -subsection\<^marker>\tag unimportant\ \The winding number defines a continuous logarithm for the path itself\ - -lemma winding_number_as_continuous_log: - assumes "path p" and \: "\ \ path_image p" - obtains q where "path q" - "pathfinish q - pathstart q = 2 * of_real pi * \ * winding_number p \" - "\t. t \ {0..1} \ p t = \ + exp(q t)" -proof - - let ?q = "\t. 2 * of_real pi * \ * winding_number(subpath 0 t p) \ + Ln(pathstart p - \)" - show ?thesis - proof - have *: "continuous (at t within {0..1}) (\x. winding_number (subpath 0 x p) \)" - if t: "t \ {0..1}" for t - proof - - let ?B = "ball (p t) (norm(p t - \))" - have "p t \ \" - using path_image_def that \ by blast - then have "simply_connected ?B" - by (simp add: convex_imp_simply_connected) - then have "\f::complex\complex. continuous_on ?B f \ (\\ \ ?B. f \ \ 0) - \ (\g. continuous_on ?B g \ (\\ \ ?B. f \ = exp (g \)))" - by (simp add: simply_connected_eq_continuous_log) - moreover have "continuous_on ?B (\w. w - \)" - by (intro continuous_intros) - moreover have "(\z \ ?B. z - \ \ 0)" - by (auto simp: dist_norm) - ultimately obtain g where contg: "continuous_on ?B g" - and geq: "\z. z \ ?B \ z - \ = exp (g z)" by blast - obtain d where "0 < d" and d: - "\x. \x \ {0..1}; dist x t < d\ \ dist (p x) (p t) < cmod (p t - \)" - using \path p\ t unfolding path_def continuous_on_iff - by (metis \p t \ \\ right_minus_eq zero_less_norm_iff) - have "((\x. winding_number (\w. subpath 0 x p w - \) 0 - - winding_number (\w. subpath 0 t p w - \) 0) \ 0) - (at t within {0..1})" - proof (rule Lim_transform_within [OF _ \d > 0\]) - have "continuous (at t within {0..1}) (g o p)" - proof (rule continuous_within_compose) - show "continuous (at t within {0..1}) p" - using \path p\ continuous_on_eq_continuous_within path_def that by blast - show "continuous (at (p t) within p ` {0..1}) g" - by (metis (no_types, lifting) open_ball UNIV_I \p t \ \\ centre_in_ball contg continuous_on_eq_continuous_at continuous_within_topological right_minus_eq zero_less_norm_iff) - qed - with LIM_zero have "((\u. (g (subpath t u p 1) - g (subpath t u p 0))) \ 0) (at t within {0..1})" - by (auto simp: subpath_def continuous_within o_def) - then show "((\u. (g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \)) \ 0) - (at t within {0..1})" - by (simp add: tendsto_divide_zero) - show "(g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \) = - winding_number (\w. subpath 0 u p w - \) 0 - winding_number (\w. subpath 0 t p w - \) 0" - if "u \ {0..1}" "0 < dist u t" "dist u t < d" for u - proof - - have "closed_segment t u \ {0..1}" - using closed_segment_eq_real_ivl t that by auto - then have piB: "path_image(subpath t u p) \ ?B" - apply (clarsimp simp add: path_image_subpath_gen) - by (metis subsetD le_less_trans \dist u t < d\ d dist_commute dist_in_closed_segment) - have *: "path (g \ subpath t u p)" - apply (rule path_continuous_image) - using \path p\ t that apply auto[1] - using piB contg continuous_on_subset by blast - have "(g (subpath t u p 1) - g (subpath t u p 0)) / (2 * of_real pi * \) - = winding_number (exp \ g \ subpath t u p) 0" - using winding_number_compose_exp [OF *] - by (simp add: pathfinish_def pathstart_def o_assoc) - also have "... = winding_number (\w. subpath t u p w - \) 0" - proof (rule winding_number_cong) - have "exp(g y) = y - \" if "y \ (subpath t u p) ` {0..1}" for y - by (metis that geq path_image_def piB subset_eq) - then show "\x. \0 \ x; x \ 1\ \ (exp \ g \ subpath t u p) x = subpath t u p x - \" - by auto - qed - also have "... = winding_number (\w. subpath 0 u p w - \) 0 - - winding_number (\w. subpath 0 t p w - \) 0" - apply (simp add: winding_number_offset [symmetric]) - using winding_number_subpath_combine [OF \path p\ \, of 0 t u] \t \ {0..1}\ \u \ {0..1}\ - by (simp add: add.commute eq_diff_eq) - finally show ?thesis . - qed - qed - then show ?thesis - by (subst winding_number_offset) (simp add: continuous_within LIM_zero_iff) - qed - show "path ?q" - unfolding path_def - by (intro continuous_intros) (simp add: continuous_on_eq_continuous_within *) - - have "\ \ p 0" - by (metis \ pathstart_def pathstart_in_path_image) - then show "pathfinish ?q - pathstart ?q = 2 * of_real pi * \ * winding_number p \" - by (simp add: pathfinish_def pathstart_def) - show "p t = \ + exp (?q t)" if "t \ {0..1}" for t - proof - - have "path (subpath 0 t p)" - using \path p\ that by auto - moreover - have "\ \ path_image (subpath 0 t p)" - using \ [unfolded path_image_def] that by (auto simp: path_image_subpath) - ultimately show ?thesis - using winding_number_exp_2pi [of "subpath 0 t p" \] \\ \ p 0\ - by (auto simp: exp_add algebra_simps pathfinish_def pathstart_def subpath_def) - qed - qed -qed - -subsection \Winding number equality is the same as path/loop homotopy in C - {0}\ - -lemma winding_number_homotopic_loops_null_eq: - assumes "path p" and \: "\ \ path_image p" - shows "winding_number p \ = 0 \ (\a. homotopic_loops (-{\}) p (\t. a))" - (is "?lhs = ?rhs") -proof - assume [simp]: ?lhs - obtain q where "path q" - and qeq: "pathfinish q - pathstart q = 2 * of_real pi * \ * winding_number p \" - and peq: "\t. t \ {0..1} \ p t = \ + exp(q t)" - using winding_number_as_continuous_log [OF assms] by blast - have *: "homotopic_with_canon (\r. pathfinish r = pathstart r) - {0..1} (-{\}) ((\w. \ + exp w) \ q) ((\w. \ + exp w) \ (\t. 0))" - proof (rule homotopic_with_compose_continuous_left) - show "homotopic_with_canon (\f. pathfinish ((\w. \ + exp w) \ f) = pathstart ((\w. \ + exp w) \ f)) - {0..1} UNIV q (\t. 0)" - proof (rule homotopic_with_mono, simp_all add: pathfinish_def pathstart_def) - have "homotopic_loops UNIV q (\t. 0)" - by (rule homotopic_loops_linear) (use qeq \path q\ in \auto simp: path_defs\) - then have "homotopic_with (\r. r 1 = r 0) (top_of_set {0..1}) euclidean q (\t. 0)" - by (simp add: homotopic_loops_def pathfinish_def pathstart_def) - then show "homotopic_with (\h. exp (h 1) = exp (h 0)) (top_of_set {0..1}) euclidean q (\t. 0)" - by (rule homotopic_with_mono) simp - qed - show "continuous_on UNIV (\w. \ + exp w)" - by (rule continuous_intros)+ - show "range (\w. \ + exp w) \ -{\}" - by auto - qed - then have "homotopic_with_canon (\r. pathfinish r = pathstart r) {0..1} (-{\}) p (\x. \ + 1)" - by (rule homotopic_with_eq) (auto simp: o_def peq pathfinish_def pathstart_def) - then have "homotopic_loops (-{\}) p (\t. \ + 1)" - by (simp add: homotopic_loops_def) - then show ?rhs .. -next - assume ?rhs - then obtain a where "homotopic_loops (-{\}) p (\t. a)" .. - then have "winding_number p \ = winding_number (\t. a) \" "a \ \" - using winding_number_homotopic_loops homotopic_loops_imp_subset by (force simp:)+ - moreover have "winding_number (\t. a) \ = 0" - by (metis winding_number_zero_const \a \ \\) - ultimately show ?lhs by metis -qed - -lemma winding_number_homotopic_paths_null_explicit_eq: - assumes "path p" and \: "\ \ path_image p" - shows "winding_number p \ = 0 \ homotopic_paths (-{\}) p (linepath (pathstart p) (pathstart p))" - (is "?lhs = ?rhs") -proof - assume ?lhs - then show ?rhs - apply (auto simp: winding_number_homotopic_loops_null_eq [OF assms]) - apply (rule homotopic_loops_imp_homotopic_paths_null) - apply (simp add: linepath_refl) - done -next - assume ?rhs - then show ?lhs - by (metis \ pathstart_in_path_image winding_number_homotopic_paths winding_number_trivial) -qed - -lemma winding_number_homotopic_paths_null_eq: - assumes "path p" and \: "\ \ path_image p" - shows "winding_number p \ = 0 \ (\a. homotopic_paths (-{\}) p (\t. a))" - (is "?lhs = ?rhs") -proof - assume ?lhs - then show ?rhs - by (auto simp: winding_number_homotopic_paths_null_explicit_eq [OF assms] linepath_refl) -next - assume ?rhs - then show ?lhs - by (metis \ homotopic_paths_imp_pathfinish pathfinish_def pathfinish_in_path_image winding_number_homotopic_paths winding_number_zero_const) -qed - -proposition winding_number_homotopic_paths_eq: - assumes "path p" and \p: "\ \ path_image p" - and "path q" and \q: "\ \ path_image q" - and qp: "pathstart q = pathstart p" "pathfinish q = pathfinish p" - shows "winding_number p \ = winding_number q \ \ homotopic_paths (-{\}) p q" - (is "?lhs = ?rhs") -proof - assume ?lhs - then have "winding_number (p +++ reversepath q) \ = 0" - using assms by (simp add: winding_number_join winding_number_reversepath) - moreover - have "path (p +++ reversepath q)" "\ \ path_image (p +++ reversepath q)" - using assms by (auto simp: not_in_path_image_join) - ultimately obtain a where "homotopic_paths (- {\}) (p +++ reversepath q) (linepath a a)" - using winding_number_homotopic_paths_null_explicit_eq by blast - then show ?rhs - using homotopic_paths_imp_pathstart assms - by (fastforce simp add: dest: homotopic_paths_imp_homotopic_loops homotopic_paths_loop_parts) -next - assume ?rhs - then show ?lhs - by (simp add: winding_number_homotopic_paths) -qed - -lemma winding_number_homotopic_loops_eq: - assumes "path p" and \p: "\ \ path_image p" - and "path q" and \q: "\ \ path_image q" - and loops: "pathfinish p = pathstart p" "pathfinish q = pathstart q" - shows "winding_number p \ = winding_number q \ \ homotopic_loops (-{\}) p q" - (is "?lhs = ?rhs") -proof - assume L: ?lhs - have "pathstart p \ \" "pathstart q \ \" - using \p \q by blast+ - moreover have "path_connected (-{\})" - by (simp add: path_connected_punctured_universe) - ultimately obtain r where "path r" and rim: "path_image r \ -{\}" - and pas: "pathstart r = pathstart p" and paf: "pathfinish r = pathstart q" - by (auto simp: path_connected_def) - then have "pathstart r \ \" by blast - have "homotopic_loops (- {\}) p (r +++ q +++ reversepath r)" - proof (rule homotopic_paths_imp_homotopic_loops) - show "homotopic_paths (- {\}) p (r +++ q +++ reversepath r)" - by (metis (mono_tags, hide_lams) \path r\ L \p \q \path p\ \path q\ homotopic_loops_conjugate loops not_in_path_image_join paf pas path_image_reversepath path_imp_reversepath path_join_eq pathfinish_join pathfinish_reversepath pathstart_join pathstart_reversepath rim subset_Compl_singleton winding_number_homotopic_loops winding_number_homotopic_paths_eq) - qed (use loops pas in auto) - moreover have "homotopic_loops (- {\}) (r +++ q +++ reversepath r) q" - using rim \q by (auto simp: homotopic_loops_conjugate paf \path q\ \path r\ loops) - ultimately show ?rhs - using homotopic_loops_trans by metis -next - assume ?rhs - then show ?lhs - by (simp add: winding_number_homotopic_loops) -qed - -end - +end \ No newline at end of file