products/sources/formale sprachen/Isabelle/HOL/Complex_Analysis image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei:   Sprache: Isabelle

Original von: Isabelle©

section \<open>Winding numbers\<close>
theory Winding_Numbers
  imports Cauchy_Integral_Theorem
begin

subsection \<open>Definition\<close>

definition\<^marker>\<open>tag important\<close> winding_number_prop :: "[real \<Rightarrow> complex, complex, real, real \<Rightarrow> complex, complex] \<Rightarrow> bool" where
  "winding_number_prop \ z e p n \
      valid_path p \<and> z \<notin> path_image p \<and>
      pathstart p = pathstart \<gamma> \<and>
      pathfinish p = pathfinish \<gamma> \<and>
      (\<forall>t \<in> {0..1}. norm(\<gamma> t - p t) < e) \<and>
      contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"

definition\<^marker>\<open>tag important\<close> winding_number:: "[real \<Rightarrow> complex, complex] \<Rightarrow> 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 \
                    (\<forall>t\<in>{0..1}. cmod (h1 t - \<gamma> t) < d \<and> cmod (h2 t - \<gamma> t) < d) \<and>
                    pathstart h2 = pathstart h1 \<and> pathfinish h2 = pathfinish h1 \<longrightarrow>
                      path_image h1 \<subseteq> UNIV - {z} \<and> path_image h2 \<subseteq> UNIV - {z} \<and>
                      (\<forall>f. f holomorphic_on UNIV - {z} \<longrightarrow> contour_integral h2 f = contour_integral h1 f)"
    using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] assms by (auto simp: open_delete)
  then obtain h where h: "polynomial_function h \ pathstart h = pathstart \ \ pathfinish h = pathfinish \ \
                          (\<forall>t \<in> {0..1}. norm(h t - \<gamma> t) < d/2)"
    using path_approx_polynomial_function [OF \<open>path \<gamma>\<close>, of "d/2"] d by (metis half_gt_zero_iff)
  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 \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and> (\<forall>t\<in>{0..1}. cmod (p t - \<gamma> t) < min e (d/2))"
        using path_approx_polynomial_function [OF \<open>path \<gamma>\<close>, of "min e (d/2)"] d \<open>0<e\<close>
        by (metis min_less_iff_conj zero_less_divide_iff zero_less_numeral) 
      have "(\w. 1 / (w - z)) holomorphic_on UNIV - {z}"
        by (auto simp: intro!: holomorphic_intros)
      then have "winding_number_prop \ z e p nn"
        using pi_eq [of h p] h p d
        by (auto simp: valid_path_polynomial_function norm_minus_commute nn_def winding_number_prop_def)
      then show "\p. winding_number_prop \ z e p nn"
        by metis
    qed
  then show ?thesis
    unfolding winding_number_def by (rule someI2_ex) (blast intro: \<open>0<e\<close>)
qed

lemma winding_number_unique:
  assumes \<gamma>: "path \<gamma>" "z \<notin> path_image \<gamma>"
      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;
                    (\<forall>t\<in>{0..1}. cmod (h1 t - \<gamma> t) < e \<and> cmod (h2 t - \<gamma> t) < e);
                    pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1; f holomorphic_on UNIV - {z}\<rbrakk> \<Longrightarrow>
                    contour_integral h2 f = contour_integral h1 f"
    using contour_integral_nearby_ends [of "UNIV - {z}" \<gamma>] 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 \<gamma> 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 \<open>auto simp: winding_number_prop_def norm_minus_commute\<close>)
  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 \<gamma>: "path \<gamma>" "z \<notin> path_image \<gamma>"
      and loop: "pathfinish \ = pathstart \"
      and pi:
        "\e. e>0 \ \p. valid_path p \ z \ path_image p \
                           pathfinish p = pathstart p \<and>
                           (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
                           contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * 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;
                    (\<forall>t\<in>{0..1}. cmod (h1 t - \<gamma> t) < e \<and> cmod (h2 t - \<gamma> t) < e);
                    pathfinish h1 = pathstart h1; pathfinish h2 = pathstart h2; f holomorphic_on UNIV - {z}\<rbrakk> \<Longrightarrow>
                    contour_integral h2 f = contour_integral h1 f"
    using contour_integral_nearby_loops [of "UNIV - {z}" \<gamma>] assms  by (auto simp: open_delete)
  obtain p where p:
     "valid_path p \ z \ path_image p \ pathfinish p = pathstart p \
      (\<forall>t \<in> {0..1}. norm (\<gamma> t - p t) < e) \<and>
      contour_integral p (\<lambda>w. 1/(w - z)) = 2 * pi * \<i> * n"
    using pi [OF e] by blast
  obtain q where q: "winding_number_prop \ z e q (winding_number \ z)"
    using winding_number [OF \<gamma> 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 \<open>auto simp: winding_number_prop_def norm_minus_commute\<close>)
  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 \<open>auto simp: valid_path_imp_path winding_number_prop_def\<close>)

proposition has_contour_integral_winding_number:
  assumes \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
    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 \<gamma>1: "path \<gamma>1" "z \<notin> path_image \<gamma>1"
      and \<gamma>2: "path \<gamma>2" "z \<notin> path_image \<gamma>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 \<gamma>1 z + winding_number \<gamma>2 z)" if "e > 0" for e
  proof -
    obtain p1 where "winding_number_prop \1 z e p1 (winding_number \1 z)"
      using \<open>0 < e\<close> \<gamma>1 winding_number by blast
    moreover
    obtain p2 where "winding_number_prop \2 z e p2 (winding_number \2 z)"
      using \<open>0 < e\<close> \<gamma>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 \<open>auto simp: not_in_path_image_join\<close>)

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 \<open>0 < e\<close> assms winding_number by blast
    then have "winding_number_prop (reversepath \) z e (reversepath p) (- winding_number \ z)"
      using assms unfolding winding_number_prop_def
      apply (simp add: 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 \<gamma>: "path \<gamma>" "z \<notin> path_image \<gamma>"
      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 \
            (\<forall>t\<in>{0..1}. cmod (shiftpath a \<gamma> t - p t) < e) \<and>
            contour_integral p (\<lambda>w. 1 / (w - z)) =
            2 * pi * \<i> * winding_number \<gamma> z"
    if "e > 0" for e
  proof -
    obtain p where "winding_number_prop \ z e p (winding_number \ z)"
      using \<open>0 < e\<close> 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 \<open>auto simp: path_shiftpath path_image_shiftpath pathfinish_shiftpath pathstart_shiftpath\<close>)

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" and g: "\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"
    using g winding_number_cong by fastforce
  moreover have "winding_number (linepath c c) z = 0"
    using \<open>c\<noteq>z\<close> 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 have "winding_number_prop p z e (\t. g t + z) n"
    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
  then show "\r. winding_number_prop p z e r n"
    by metis
qed

lemma winding_number_negatepath:
  assumes \<gamma>: "valid_path \<gamma>" and 0: "0 \<notin> path_image \<gamma>"
  shows "winding_number(uminus \ \) 0 = winding_number \ 0"
proof -
  have "(/) 1 contour_integrable_on \"
    using "0" \<gamma> 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 have "contour_integral (uminus \ \) ((/) 1) =
        contour_integral \<gamma> ((/) 1)"
    using \<gamma> by (simp add: contour_integral_unique has_contour_integral_negatepath)
  then show ?thesis
    using assms by (simp add: winding_number_valid_path valid_path_negatepath image_def path_defs)
qed

text \<open>A combined theorem deducing several things piecewise.\<close>
lemma winding_number_join_pos_combined:
     "\valid_path \1; z \ path_image \1; 0 < Re(winding_number \1 z);
       valid_path \<gamma>2; z \<notin> path_image \<gamma>2; 0 < Re(winding_number \<gamma>2 z); pathfinish \<gamma>1 = pathstart \<gamma>2\<rbrakk>
      \<Longrightarrow> valid_path(\<gamma>1 +++ \<gamma>2) \<and> z \<notin> path_image(\<gamma>1 +++ \<gamma>2) \<and> 0 < Re(winding_number(\<gamma>1 +++ \<gamma>2) z)"
  by (simp add: valid_path_join path_image_join winding_number_join valid_path_imp_path)


subsubsection\<^marker>\<open>tag unimportant\<close> \<open>Useful sufficient conditions for the winding number to be positive\<close>

lemma Re_winding_number:
    "\valid_path \; z \ path_image \\
     \<Longrightarrow> Re(winding_number \<gamma> z) = Im(contour_integral \<gamma> (\<lambda>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 \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
      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 "0 \ Im (?int z)"
  proof (rule has_integral_component_nonneg [of \<i>, simplified])
    show "\x. x \ cbox 0 1 \ 0 \ Im (if 0 < x \ x < 1 then ?vd x else 0)"
      by (force simp: ge0)
    have "((\a. 1 / (a - z)) has_contour_integral contour_integral \ (\w. 1 / (w - z))) \"
      using \<gamma> by (simp flip: add: contour_integrable_inversediff has_contour_integral_integral)
    then have hi: "(?vd has_integral ?int z) (cbox 0 1)"
      using has_contour_integral by auto
    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 \<gamma>] field_simps)
qed

lemma winding_number_pos_lt_lemma:
  assumes \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
      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 "e \ Im (contour_integral \ (\w. 1 / (w - z)))"
  proof (rule has_integral_component_le [of \<i> "\<lambda>x. \<i>*e" "\<i>*e" "{0..1}", simplified])
    have "((\a. 1 / (a - z)) has_contour_integral contour_integral \ (\w. 1 / (w - z))) \"
      thm has_integral_component_le [of \<i> "\<lambda>x. \<i>*e" "\<i>*e" "{0..1}", simplified]
      using \<gamma> by (simp add: contour_integrable_inversediff has_contour_integral_integral)
    then have hi: "(?vd has_integral ?int z) (cbox 0 1)"
      using has_contour_integral by auto
    show "((\x. if 0 < x \ x < 1 then ?vd x else \ * 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 \ * 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 \<gamma>] field_simps)
qed

lemma winding_number_pos_lt:
  assumes \<gamma>: "valid_path \<gamma>" "z \<notin> path_image \<gamma>"
      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"\<gamma> 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 \ e / (cmod (\ x - z))\<^sup>2"
      using B B2 e by (auto simp: divide_left_mono)
    also have "... \ Im (vector_derivative \ (at x) * cnj (\ x - z)) / (cmod (\ x - z))\<^sup>2"
      using ge [OF x] by (auto simp: divide_right_mono)
    finally have "e / B\<^sup>2 \ Im (vector_derivative \ (at x) * cnj (\ x - z)) / (cmod (\ x - z))\<^sup>2" .
    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 \<gamma>, of "e/B^2"])
qed

subsection\<open>The winding number is an integer\<close>

text\<open>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
    using z by (auto intro!: derivative_eq_intros * [unfolded o_def] g)
qed

lemma winding_number_exp_integral:
  fixes z::complex
  assumes \<gamma>: "\<gamma> 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\<gamma> = "\<lambda>x. vector_derivative \<gamma> (at x)"
  have [simp]: "\x. a \ x \ x \ b \ \ x \ z"
    using z by force
  have con_g: "continuous_on {a..b} \"
    using \<gamma> 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 \<gamma> by (force simp: piecewise_C1_differentiable_on_def)
  have \<circ>: "open ({a<..<b} - k)"
    using \<open>finite k\<close> 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 \<gamma>]])
    show "\d h. 0 < d \
               (\<forall>y. cmod (y - w) < d \<longrightarrow> (h has_field_derivative inverse (y - z))(at y within - {z}))"
          if "w \ - {z}" for w
      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 (\<gamma> t - y) < cmod (\<gamma> 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)
    have "exp (- (integral {a..t} (\x. ?D\ x / (\ x - z)))) * (\ t - z) =\ a - z"
    proof (rule has_derivative_zero_unique_strong_interval [of "{a,b} \ k" a b])
      show "continuous_on {a..b} (\b. exp (- integral {a..b} (\x. ?D\ x / (\ x - z))) * (\ b - z))"
        by (auto intro!: continuous_intros con_g indefinite_integral_continuous_1 [OF vg_int])
      show "((\b. exp (- integral {a..b} (\x. ?D\ x / (\ x - z))) * (\ b - z)) has_derivative (\h. 0))
            (at x within {a..b})"
        if "x \ {a..b} - ({a, b} \ k)" for x
      proof -
        have x: "x \ k" "a < x" "x < b"
          using that by auto
        then have "x \ interior ({a..b} - k)"
          using open_subset_interior [OF \<circ>] 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)
        then obtain d where d: "(\ has_derivative (\x. x *\<^sub>R d)) (at x)"
          by (auto simp add: differentiable_iff_scaleR)
        show "((\c. exp (- integral {a..c} (\x. ?D\ x / (\ x - z))) * (\ c - z)) has_derivative (\h. 0))
          (at x within {a..b})"
        proof (rule exp_fg [unfolded has_vector_derivative_def, simplified])
          show "(\ has_derivative (\c. c *\<^sub>R d)) (at x within {a..b})"
            using d by (blast intro: has_derivative_at_withinI)
          have "((\x. integral {a..x} (\x. ?D\ x / (\ x - z))) has_vector_derivative d / (\ x - z))
              (at x within {a..b})"
          proof (rule has_vector_derivative_eq_rhs [OF integral_has_vector_derivative_continuous_at [where S = "{}", simplified]])
            show "continuous (at x within {a..b}) (\x. vector_derivative \ (at x) / (\ x - z))"
              using continuous_at_imp_continuous_at_within differentiable_imp_continuous_within gdx x
              by (intro con_vd continuous_intros) (force+) 
            show "vector_derivative \ (at x) / (\ x - z) = d / (\ x - z)"
              using d vector_derivative_at
              by (simp add: vector_derivative_at has_vector_derivative_def)
          qed (use x vg_int in auto)
          then show "((\x. integral {a..x} (\x. ?D\ x / (\ x - z))) has_derivative (\c. c *\<^sub>R (d / (\ x - z))))
               (at x within {a..b})"
            by (auto simp: has_vector_derivative_def)
        qed (use x in auto)
      qed
    qed (use fink t in auto)
  }
  with ab show ?thesis2
    by (simp add: divide_inverse_commute integral_def)
qed

lemma winding_number_exp_2pi:
    "\path p; z \ path_image p\
     \<Longrightarrow> pathfinish p - z = exp (2 * pi * \<i> * 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 \<gamma>: "path \<gamma>" and z: "z \<notin> path_image \<gamma>"
  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 "\ 0 \ z"
    by (metis pathstart_def pathstart_in_path_image z)
  then 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]
    by (simp add: valid_path_def path_defs contour_integral_integral exp_minus field_split_simps)
  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\<open>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 \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and 1: "Re (winding_number \<gamma> z) \<ge> 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 \<gamma> 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}
     (\<lambda>x. Im (integral {0..x} (\<lambda>x. vector_derivative \<gamma> (at x) / (\<gamma> 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
    by (simp add: winding_number_valid_path [OF \<gamma> z] contour_integral_integral Complex.Re_divide field_simps power2_eq_square)
  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 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
  proof (rule winding_number_exp_integral [OF gpdt])
    show "z \ \ ` {0..t}"
      using t z unfolding path_image_def by force
  qed (use t in auto)
  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)
  moreover have "z + exp (Re i) * (exp (\ * Im i) * (\ 0 - z)) = \ t"
    using * by (simp add: exp_eq_polar field_simps)
  moreover have "Arg2pi r = Im i"
    using eqArg by (simp add: i_def)
  ultimately have "z + complex_of_real (exp (Re i)) * (w - z) / complex_of_real (cmod r) = \ t"
    using Complex_Transcendental.Arg2pi_eq [of r] \<open>r \<noteq> 0\<close>
    by (metis  mult.left_commute nonzero_mult_div_cancel_left norm_eq_zero of_real_0 of_real_eq_iff times_divide_eq_left)
  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 \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and "\<bar>Re (winding_number \<gamma> z)\<bar> \<ge> 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: \<gamma> valid_path_imp_path winding_number_reversepath z)
    moreover have "valid_path (reversepath \)"
      using \<gamma> 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;
    \<And>a::real. 0 < a \<Longrightarrow> z + a*(w - z) \<notin> path_image \<gamma>\<rbrakk>
   \<Longrightarrow> Re(winding_number \<gamma> z) < 1"
   by (auto simp: not_less dest: winding_number_big_meets)

text\<open>One way of proving that WN=1 for a loop.\<close>
lemma winding_number_eq_1:
  fixes z::complex
  assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
      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: \<gamma> integer_winding_number loop valid_path_imp_path z)
  then show ?thesis
    using 0 2 by (auto simp: Ints_def)
qed

subsection\<open>Continuity of winding number and invariance on connected sets\<close>

theorem continuous_at_winding_number:
  fixes z::complex
  assumes \<gamma>: "path \<gamma>" and z: "z \<notin> path_image \<gamma>"
  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 \<gamma>])
  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;
              (\<forall>t\<in>{0..1}. cmod (h1 t - \<gamma> t) < d \<and> cmod (h2 t - \<gamma> t) < d);
              pathstart h2 = pathstart h1; pathfinish h2 = pathfinish h1\<rbrakk>
             \<Longrightarrow>
               path_image h1 \<subseteq> - cball z (e/2) \<and>
               path_image h2 \<subseteq> - cball z (e/2) \<and>
               (\<forall>f. f holomorphic_on - cball z (e/2) \<longrightarrow> contour_integral h2 f = contour_integral h1 f)"
    using contour_integral_nearby_ends [OF oc \<gamma> ppag] by metis
  obtain p where "valid_path p" "z \ path_image p"
              and 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 \<gamma> z, of "min d e/2"] \<open>d>0\<close> \<open>e>0\<close> by (auto simp: winding_number_prop_def)
  { fix w
    assume d2: "cmod (w - z) < d/2" and e2: "cmod (w - z) < e/2"
    have wnotp: "w \ path_image p"
    proof (clarsimp simp add: path_image_def)
      show False if w: "w = p x" and "0 \ x" "x \ 1" for x
      proof -
        have "cmod (\ x - p x) < min d e/2"
          using pg that by auto
        then have "cmod (z - \ x) < e"
          by (metis e2 less_divide_eq_numeral1(1) min_less_iff_conj norm_minus_commute norm_triangle_half_l w)
        then show ?thesis
          using cbg that by (auto simp add: path_image_def cball_def dist_norm less_eq_real_def)
      qed
    qed
    have wnotg: "w \ path_image \"
      using cbg e2 \<open>e>0\<close> 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 \<gamma> wnotg, of "min k (min d e) / 2"] \<open>d>0\<close> \<open>e>0\<close> k
        by (force simp: min_divide_distrib_right winding_number_prop_def)
      moreover have "\t. t \ {0..1} \ cmod (q t - \ t) < d \ cmod (p t - \ t) < d"
        using pg qg \<open>0 < d\<close> by (fastforce simp add: norm_minus_commute)
      moreover have "(\u. 1 / (u-w)) holomorphic_on - cball z (e/2)"
        using e2 by (auto simp: dist_norm norm_minus_commute intro!: holomorphic_intros)
      ultimately have "contour_integral p (\u. 1 / (u - w)) = contour_integral q (\u. 1 / (u - w))"
        by (metis p \<open>valid_path p\<close> pi_eq)
      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"
      by (simp add: \<open>valid_path p\<close> valid_path_imp_path)
    moreover have "\e. e > 0 \ winding_number_prop p w e p (winding_number \ w)"
      by (simp add: \<open>valid_path p\<close> pip winding_number_prop_def wnotp)
    ultimately have "winding_number p w = winding_number \ w"
      using winding_number_unique wnotp by blast
  } note wnwn = this
  obtain pe where "pe>0" and cbp: "cball z (3 / 4 * pe) \ - path_image p"
    using \<open>valid_path p\<close> \<open>z \<notin> path_image p\<close> 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);
                      \<forall>z \<in> - cball z (3 / 4 * pe). cmod (f z) \<le> B\<rbrakk> \<Longrightarrow>
                      cmod (contour_integral p f) \<le> L * B"
    using contour_integral_bound_exists [of "- cball z (3/4*pe)" p] cbp \<open>valid_path p\<close> 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) \<open>0 < pe\<close>
      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 (\<lambda>x. 1/(x - w) - 1/(x - z))"
      by (simp add: \<open>valid_path p\<close> \<open>z \<notin> path_image p\<close> 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_less: "(pe/2)^2 < cmod (w - x) ^ 2"
        by (simp add: \<open>0 < pe\<close> less_eq_real_def power_strict_mono)
      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 \<open>L>0\<close> by (simp add: field_simps)
      also have "\ < e * 4 * cmod (w - x) * cmod (w - x)"
        using pe2 \<open>e>0\<close> by (simp add: power2_eq_square)
      also have "\ < e * 4 * cmod (w - x) * (4/3 * cmod (z - x))"
        using \<open>0 < pe\<close> pe_less e less_eq_real_def wx 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"
      proof (cases "x=z \ x=w")
        case True
        with pe \<open>pe>0\<close> w \<open>L>0\<close>
        show ?thesis
          by (force simp: norm_minus_commute)
      next
        case False
        with wx w(2) \<open>L>0\<close> pe pe2 Lwz
        show ?thesis
          by (auto simp: divide_simps mult_less_0_iff norm_minus_commute norm_divide norm_mult power2_eq_square)
      qed
    } note L_cmod_le = this
    let ?f = "(\x. 1 / (x - w) - 1 / (x - z))"
    have "cmod (contour_integral p ?f) \ L * (e * pe\<^sup>2 / L / 4 * (inverse (pe / 2))\<^sup>2)"
    proof (rule L)
      show "?f holomorphic_on - cball z (3 / 4 * pe)"
        using \<open>pe>0\<close> w
        by (force simp: dist_norm norm_minus_commute intro!: holomorphic_intros)
      show " \u \- cball z (3 / 4 * pe). cmod (?f u) \ e * pe\<^sup>2 / L / 4 * (inverse (pe / 2))\<^sup>2"
        using \<open>pe>0\<close> w \<open>L>0\<close>
        by (auto simp: cball_def dist_norm field_simps L_cmod_le  simp del: less_divide_eq_numeral1 le_divide_eq_numeral1)
    qed
    also have "\ < 2*e"
      using \<open>L>0\<close> e by (force simp: field_simps)
    finally have "cmod (winding_number p w - winding_number p z) < e"
      using pi_ge_two e
      by (force simp: winding_number_valid_path \<open>valid_path p\<close> \<open>z \<notin> path_image p\<close> field_simps norm_divide norm_mult intro: less_le_trans)
  } note cmod_wn_diff = this
  have "isCont (winding_number p) z"
  proof (clarsimp simp add: continuous_at_eps_delta)
    fix e::real assume "e>0"
    show "\d>0. \x'. dist x' z < d \ dist (winding_number p x') (winding_number p z) < e"
      using \<open>pe>0\<close> \<open>L>0\<close> \<open>e>0\<close>
      by (rule_tac x="min (pe/4) (e/2*pe^2/L/4)" in exI) (simp add: dist_norm cmod_wn_diff)
  qed
  then show ?thesis
    apply (rule continuous_transform_within [where d = "min d e/2"])
    apply (auto simp: \<open>d>0\<close> \<open>e>0\<close> 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>\<open>tag unimportant\<close> \<open>The winding number is constant on a connected region\<close>

lemma winding_number_constant:
  assumes \<gamma>: "path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>" and cs: "connected S" and sg: "S \<inter> path_image \<gamma> = {}"
  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 \<gamma> loop] sg \<open>y \<in> S\<close> 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 \<gamma>] 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 \ = {}\
      \<Longrightarrow> winding_number \<gamma> w = winding_number \<gamma> z"
  using winding_number_constant by (metis constant_on_def)

lemma open_winding_number_levelsets:
  assumes \<gamma>: "path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
  shows "open {z. z \ path_image \ \ winding_number \ z = k}"
proof (clarsimp simp: open_dist)
  fix z assume z: "z \ path_image \" and k: "k = winding_number \ z"
  have "open (- path_image \)"
    by (simp add: closed_path_image \<gamma> open_Compl)
  then obtain e where "e>0" "ball z e \ - path_image \"
    using open_contains_ball [of "- path_image \"] z by blast
  then show "\e>0. \y. dist y z < e \ y \ path_image \ \ winding_number \ y = winding_number \ z"
    using \<open>e>0\<close> by (force simp: norm_minus_commute dist_norm intro: winding_number_eq [OF assms, where S = "ball z e"])
qed

subsection\<open>Winding number is zero "outside" a curve\<close>

proposition winding_number_zero_in_outside:
  assumes \<gamma>: "path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>" and z: "z \<in> outside (path_image \<gamma>)"
    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 \<gamma>]] 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 \)"
    using B subset_ball  by (intro outside_subset_convex) 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 \<gamma> loop, of "outside(path_image \<gamma>)"] connected_outside
    by (metis DIM_complex bounded_path_image dual_order.refl \<gamma> 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
      obtain p where p: "polynomial_function p" "pathstart p = pathstart \" "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 \<gamma>, of "min 1 e"] \<open>e>0\<close>
        by (metis atLeastAtMost_iff min_less_iff_conj zero_less_one)
      have "\p. valid_path p \ w \ path_image p \
                     pathstart p = pathstart \<gamma> \<and> pathfinish p = pathfinish \<gamma> \<and>
                     (\<forall>t\<in>{0..1}. cmod (\<gamma> t - p t) < e) \<and> contour_integral p (\<lambda>wa. 1 / (wa - w)) = 0"
      proof (intro exI conjI)
        have "\x. \0 \ x; x \ 1\ \ cmod (p x) < B + 1"
          using B unfolding image_subset_iff path_image_def
          by (meson add_strict_mono atLeastAtMost_iff le_less_trans mem_ball_0 norm_triangle_sub pg1) 
        then have pip: "path_image p \ ball 0 (B + 1)"
          by (auto simp add: path_image_def dist_norm ball_def)
        then show "w \ path_image p" using w by blast
        show vap: "valid_path p"
          by (simp add: p(1) valid_path_polynomial_function)
        show "\t\{0..1}. cmod (\ t - p t) < e"
          by (metis atLeastAtMost_iff norm_minus_commute pge)
        show "contour_integral p (\wa. 1 / (wa - w)) = 0"
        proof (rule contour_integral_unique [OF Cauchy_theorem_convex_simple [OF _ convex_ball [of 0 "B+1"]]])
          have "\z. cmod z < B + 1 \ z \ w"
            using mem_ball_0 w by blast
          then show "(\z. 1 / (z - w)) holomorphic_on ball 0 (B + 1)"
            by (intro holomorphic_intros; simp add: dist_norm)
        qed (use p vap pip loop in auto)
      qed (use p in auto)
    }
    then show ?thesis
      by (auto intro: winding_number_unique [OF \<gamma>] simp add: winding_number_prop_def wnot)
  qed
  finally show ?thesis .
qed

corollary\<^marker>\<open>tag unimportant\<close> winding_number_zero_const: "a \<noteq> z \<Longrightarrow> winding_number (\<lambda>t. a) z = 0"
  by (rule winding_number_zero_in_outside)
     (auto simp: pathfinish_def pathstart_def path_polynomial_function)

corollary\<^marker>\<open>tag unimportant\<close> 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 \<gamma>: "path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
    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 \<gamma>]] by auto
  have "winding_number \ z = 0" if "B + 1 \ cmod z" for z
  proof (rule winding_number_zero_outside [OF \<gamma> convex_cball loop])
    show "z \ cball 0 B"
      using that by auto
    show "path_image \ \ cball 0 B"
      using B order.trans by blast
  qed
  then show ?thesis
    by metis
qed

lemma winding_number_zero_point:
    "\path \; convex S; pathfinish \ = pathstart \; open S; path_image \ \ S\
     \<Longrightarrow> \<exists>z. z \<in> S \<and> winding_number \<gamma> 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\<open>If a path winds round a set, it winds rounds its inside.\<close>
lemma winding_number_around_inside:
  assumes \<gamma>: "path \<gamma>" and loop: "pathfinish \<gamma> = pathstart \<gamma>"
      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 \)"
      by (metis Compl_iff S_disj UnE \<gamma> \<open>x \<in> S\<close> cos inside_outside loop winding_number_eq winding_number_zero_in_outside wn_nz z)
  qed
  show ?thesis
  proof (rule winding_number_eq [OF \<gamma> loop w])
    show "z \ S \ inside S"
      using z by blast
    show "connected (S \ inside S)"
      by (simp add: cls connected_with_inside cos)
    show "(S \ inside S) \ path_image \ = {}"
      unfolding disjoint_iff Un_iff 
      by (metis ComplD UnI1 \<gamma> cls compact_path_image connected_path_image inside_Un_outside inside_inside_compact_connected ssb subsetD)
  qed
qed

text\<open>Bounding a WN by 1/2 for a path and point in opposite halfspaces.\<close>
lemma winding_number_subpath_continuous:
  assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>"
    shows "continuous_on {0..1} (\x. winding_number(subpath 0 x \) z)"
proof (rule continuous_on_eq)
  let ?f = "\x. integral {0..x} (\t. vector_derivative \ (at t) / (\ t - z))"
  show "continuous_on {0..1} (\x. 1 / (2 * pi * \) * ?f x)"
  proof (intro indefinite_integral_continuous_1 winding_number_exp_integral continuous_intros)
    show "\ piecewise_C1_differentiable_on {0..1}"
      using \<gamma> valid_path_def by blast
  qed (use path_image_def z in auto)
  show "1 / (2 * pi * \) * ?f x = winding_number (subpath 0 x \) z"
    if x: "x \ {0..1}" for x
  proof -
    have "1 / (2*pi*\) * ?f x = 1 / (2*pi*\) * contour_integral (subpath 0 x \) (\w. 1/(w - z))"
      using assms x
      by (simp add: contour_integral_subcontour_integral [OF contour_integrable_inversediff])
    also have "\ = winding_number (subpath 0 x \) z"
    proof (subst winding_number_valid_path)
      show "z \ path_image (subpath 0 x \)"
        using assms x atLeastAtMost_iff path_image_subpath_subset by force
    qed (use assms x valid_path_subpath in \<open>force+\<close>)
    finally show ?thesis .
  qed
qed

lemma winding_number_ivt_pos:
    assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and "0 \<le> w" "w \<le> Re(winding_number \<gamma> z)"
    shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w"
proof -
  have "continuous_on {0..1} (\x. winding_number (subpath 0 x \) z)"
    using \<gamma> winding_number_subpath_continuous z by blast
  moreover have "Re (winding_number (subpath 0 0 \) z) \ w" "w \ Re (winding_number (subpath 0 1 \) z)"
    using assms by (auto simp: path_image_def image_def)
  ultimately show ?thesis
    using ivt_increasing_component_on_1[of 0 1, where ?k = "1"by force
qed

lemma winding_number_ivt_neg:
    assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and "Re(winding_number \<gamma> z) \<le> w" "w \<le> 0"
      shows "\t \ {0..1}. Re(winding_number(subpath 0 t \) z) = w"
proof -
  have "continuous_on {0..1} (\x. winding_number (subpath 0 x \) z)"
    using \<gamma> winding_number_subpath_continuous z by blast
  moreover have "Re (winding_number (subpath 0 0 \) z) \ w" "w \ Re (winding_number (subpath 0 1 \) z)"
    using assms by (auto simp: path_image_def image_def)
  ultimately show ?thesis
    using ivt_decreasing_component_on_1[of 0 1, where ?k = "1"by force
qed

lemma winding_number_ivt_abs:
    assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and "0 \<le> w" "w \<le> \<bar>Re(winding_number \<gamma> z)\<bar>"
      shows "\t \ {0..1}. \Re (winding_number (subpath 0 t \) z)\ = w"
  using assms winding_number_ivt_pos [of \<gamma> z w] winding_number_ivt_neg [of \<gamma> z "-w"]
  by force

lemma winding_number_lt_half_lemma:
  assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>" and az: "a \<bullet> z \<le> b" and pag: "path_image \<gamma> \<subseteq> {w. a \<bullet> 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 \<gamma> 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 \<gamma> 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"
      by (metis atLeastAtMost_iff image_eqI mem_Collect_eq pag path_image_def subset_iff t)
    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 have "Re (winding_number \ z) < 0 \ - Re (winding_number \ z) < 1/2"
    by (metis complex_inner_1_right winding_number_lt_half_lemma [OF valid_path_imp_reverse, of \<gamma> z a b]
        winding_number_reversepath valid_path_imp_path inner_minus_left path_image_reversepath)
  with assms show ?thesis
    using \<open>z \<notin> path_image \<gamma>\<close> winding_number_lt_half_lemma by fastforce
qed

lemma winding_number_le_half:
  assumes \<gamma>: "valid_path \<gamma>" and z: "z \<notin> path_image \<gamma>"
      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 \<gamma> 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 * 6 \ d * cmod a + b * 6"
      by (metis \<open>0 < d\<close> add_increasing azb less_eq_real_def mult_nonneg_nonneg mult_right_mono norm_ge_zero norm_numeral)
    with anz have *: "a \ z' \ b - d / 3 * cmod a"
      unfolding z'_def inner_mult_right' divide_inverse
      by (simp add: field_split_simps algebra_simps dot_square_norm power2_eq_square)
    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"
    proof (rule winding_number_lt_half [OF \<gamma> *])
      show "path_image \ \ {w. b - d / 3 * cmod a < a \ w}"
        using azb \<open>d>0\<close> pag by (auto simp: add_strict_increasing anz field_split_simps dest!: subsetD)
    qed
    ultimately have False
      by simp
  }
  then show ?thesis by force
qed

lemma winding_number_lt_half_linepath:
  assumes "z \ closed_segment a b" shows "\Re (winding_number (linepath a b) z)\ < 1/2"
proof -
  obtain u v where "u \ z \ v" and uv: "\x. x \ closed_segment a b \ inner u x > v"
    using separating_hyperplane_closed_point assms closed_segment convex_closed_segment less_eq_real_def by metis
  moreover have "path_image (linepath a b) \ {w. v < u \ w}"
    using in_segment(1) uv by auto
  ultimately show ?thesis
    using winding_number_lt_half by auto
qed

text\<open> Positivity of WN for a linepath.\<close>
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
    by (intro winding_number_pos_lt [OF valid_path_linepath z assms]) (simp add: linepath_def algebra_simps)
qed

subsection\<^marker>\<open>tag unimportant\<close> \<open>More winding number properties\<close>

text\<open>including the fact that it's +-1 inside a simple closed curve.\<close>

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\
            \<Longrightarrow> 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\
            \<Longrightarrow> 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 \<open>path g\<close> pag \<open>0 < d\<close>] 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"
--> --------------------

--> maximum size reached

--> --------------------

¤ Dauer der Verarbeitung: 0.48 Sekunden  (vorverarbeitet)  ¤





Druckansicht
unsichere Verbindung
Druckansicht
sprechenden Kalenders

Eigene Datei ansehen




schauen Sie vor die Tür

Fenster


Die Firma ist wie angegeben erreichbar.

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff