777 "\<lbrakk>simple_path \<gamma>; pathfinish \<gamma> = pathstart \<gamma>; z \<notin> path_image \<gamma>; 0 < Re(winding_number \<gamma> z)\<rbrakk> |
777 "\<lbrakk>simple_path \<gamma>; pathfinish \<gamma> = pathstart \<gamma>; z \<notin> path_image \<gamma>; 0 < Re(winding_number \<gamma> z)\<rbrakk> |
778 \<Longrightarrow> winding_number \<gamma> z = 1" |
778 \<Longrightarrow> winding_number \<gamma> z = 1" |
779 using simple_closed_path_winding_number_cases |
779 using simple_closed_path_winding_number_cases |
780 by fastforce |
780 by fastforce |
781 |
781 |
|
782 |
|
783 subsection \<open>Winding number for rectangular paths\<close> |
|
784 |
|
785 (* TODO: Move *) |
|
786 lemma closed_segmentI: |
|
787 "u \<in> {0..1} \<Longrightarrow> z = (1 - u) *\<^sub>R a + u *\<^sub>R b \<Longrightarrow> z \<in> closed_segment a b" |
|
788 by (auto simp: closed_segment_def) |
|
789 |
|
790 lemma in_cbox_complex_iff: |
|
791 "x \<in> cbox a b \<longleftrightarrow> Re x \<in> {Re a..Re b} \<and> Im x \<in> {Im a..Im b}" |
|
792 by (cases x; cases a; cases b) (auto simp: cbox_Complex_eq) |
|
793 |
|
794 lemma box_Complex_eq: |
|
795 "box (Complex a c) (Complex b d) = (\<lambda>(x,y). Complex x y) ` (box a b \<times> box c d)" |
|
796 by (auto simp: box_def Basis_complex_def image_iff complex_eq_iff) |
|
797 |
|
798 lemma in_box_complex_iff: |
|
799 "x \<in> box a b \<longleftrightarrow> Re x \<in> {Re a<..<Re b} \<and> Im x \<in> {Im a<..<Im b}" |
|
800 by (cases x; cases a; cases b) (auto simp: box_Complex_eq) |
|
801 (* END TODO *) |
|
802 |
|
803 lemma closed_segment_same_Re: |
|
804 assumes "Re a = Re b" |
|
805 shows "closed_segment a b = {z. Re z = Re a \<and> Im z \<in> closed_segment (Im a) (Im b)}" |
|
806 proof safe |
|
807 fix z assume "z \<in> closed_segment a b" |
|
808 then obtain u where u: "u \<in> {0..1}" "z = a + of_real u * (b - a)" |
|
809 by (auto simp: closed_segment_def scaleR_conv_of_real algebra_simps) |
|
810 from assms show "Re z = Re a" by (auto simp: u) |
|
811 from u(1) show "Im z \<in> closed_segment (Im a) (Im b)" |
|
812 by (intro closed_segmentI[of u]) (auto simp: u algebra_simps) |
|
813 next |
|
814 fix z assume [simp]: "Re z = Re a" and "Im z \<in> closed_segment (Im a) (Im b)" |
|
815 then obtain u where u: "u \<in> {0..1}" "Im z = Im a + of_real u * (Im b - Im a)" |
|
816 by (auto simp: closed_segment_def scaleR_conv_of_real algebra_simps) |
|
817 from u(1) show "z \<in> closed_segment a b" using assms |
|
818 by (intro closed_segmentI[of u]) (auto simp: u algebra_simps scaleR_conv_of_real complex_eq_iff) |
|
819 qed |
|
820 |
|
821 lemma closed_segment_same_Im: |
|
822 assumes "Im a = Im b" |
|
823 shows "closed_segment a b = {z. Im z = Im a \<and> Re z \<in> closed_segment (Re a) (Re b)}" |
|
824 proof safe |
|
825 fix z assume "z \<in> closed_segment a b" |
|
826 then obtain u where u: "u \<in> {0..1}" "z = a + of_real u * (b - a)" |
|
827 by (auto simp: closed_segment_def scaleR_conv_of_real algebra_simps) |
|
828 from assms show "Im z = Im a" by (auto simp: u) |
|
829 from u(1) show "Re z \<in> closed_segment (Re a) (Re b)" |
|
830 by (intro closed_segmentI[of u]) (auto simp: u algebra_simps) |
|
831 next |
|
832 fix z assume [simp]: "Im z = Im a" and "Re z \<in> closed_segment (Re a) (Re b)" |
|
833 then obtain u where u: "u \<in> {0..1}" "Re z = Re a + of_real u * (Re b - Re a)" |
|
834 by (auto simp: closed_segment_def scaleR_conv_of_real algebra_simps) |
|
835 from u(1) show "z \<in> closed_segment a b" using assms |
|
836 by (intro closed_segmentI[of u]) (auto simp: u algebra_simps scaleR_conv_of_real complex_eq_iff) |
|
837 qed |
|
838 |
|
839 |
|
840 definition rectpath where |
|
841 "rectpath a1 a3 = (let a2 = Complex (Re a3) (Im a1); a4 = Complex (Re a1) (Im a3) |
|
842 in linepath a1 a2 +++ linepath a2 a3 +++ linepath a3 a4 +++ linepath a4 a1)" |
|
843 |
|
844 lemma path_rectpath [simp, intro]: "path (rectpath a b)" |
|
845 by (simp add: Let_def rectpath_def) |
|
846 |
|
847 lemma valid_path_rectpath [simp, intro]: "valid_path (rectpath a b)" |
|
848 by (simp add: Let_def rectpath_def) |
|
849 |
|
850 lemma pathstart_rectpath [simp]: "pathstart (rectpath a1 a3) = a1" |
|
851 by (simp add: rectpath_def Let_def) |
|
852 |
|
853 lemma pathfinish_rectpath [simp]: "pathfinish (rectpath a1 a3) = a1" |
|
854 by (simp add: rectpath_def Let_def) |
|
855 |
|
856 lemma simple_path_rectpath [simp, intro]: |
|
857 assumes "Re a1 \<noteq> Re a3" "Im a1 \<noteq> Im a3" |
|
858 shows "simple_path (rectpath a1 a3)" |
|
859 unfolding rectpath_def Let_def using assms |
|
860 by (intro simple_path_join_loop arc_join arc_linepath) |
|
861 (auto simp: complex_eq_iff path_image_join closed_segment_same_Re closed_segment_same_Im) |
|
862 |
|
863 lemma path_image_rectpath: |
|
864 assumes "Re a1 \<le> Re a3" "Im a1 \<le> Im a3" |
|
865 shows "path_image (rectpath a1 a3) = |
|
866 {z. Re z \<in> {Re a1, Re a3} \<and> Im z \<in> {Im a1..Im a3}} \<union> |
|
867 {z. Im z \<in> {Im a1, Im a3} \<and> Re z \<in> {Re a1..Re a3}}" (is "?lhs = ?rhs") |
|
868 proof - |
|
869 define a2 a4 where "a2 = Complex (Re a3) (Im a1)" and "a4 = Complex (Re a1) (Im a3)" |
|
870 have "?lhs = closed_segment a1 a2 \<union> closed_segment a2 a3 \<union> |
|
871 closed_segment a4 a3 \<union> closed_segment a1 a4" |
|
872 by (simp_all add: rectpath_def Let_def path_image_join closed_segment_commute |
|
873 a2_def a4_def Un_assoc) |
|
874 also have "\<dots> = ?rhs" using assms |
|
875 by (auto simp: rectpath_def Let_def path_image_join a2_def a4_def |
|
876 closed_segment_same_Re closed_segment_same_Im closed_segment_eq_real_ivl) |
|
877 finally show ?thesis . |
|
878 qed |
|
879 |
|
880 lemma path_image_rectpath_subset_cbox: |
|
881 assumes "Re a \<le> Re b" "Im a \<le> Im b" |
|
882 shows "path_image (rectpath a b) \<subseteq> cbox a b" |
|
883 using assms by (auto simp: path_image_rectpath in_cbox_complex_iff) |
|
884 |
|
885 lemma path_image_rectpath_inter_box: |
|
886 assumes "Re a \<le> Re b" "Im a \<le> Im b" |
|
887 shows "path_image (rectpath a b) \<inter> box a b = {}" |
|
888 using assms by (auto simp: path_image_rectpath in_box_complex_iff) |
|
889 |
|
890 lemma path_image_rectpath_cbox_minus_box: |
|
891 assumes "Re a \<le> Re b" "Im a \<le> Im b" |
|
892 shows "path_image (rectpath a b) = cbox a b - box a b" |
|
893 using assms by (auto simp: path_image_rectpath in_cbox_complex_iff |
|
894 in_box_complex_iff) |
|
895 |
|
896 lemma winding_number_rectpath: |
|
897 assumes "z \<in> box a1 a3" |
|
898 shows "winding_number (rectpath a1 a3) z = 1" |
|
899 proof - |
|
900 from assms have less: "Re a1 < Re a3" "Im a1 < Im a3" |
|
901 by (auto simp: in_box_complex_iff) |
|
902 define a2 a4 where "a2 = Complex (Re a3) (Im a1)" and "a4 = Complex (Re a1) (Im a3)" |
|
903 let ?l1 = "linepath a1 a2" and ?l2 = "linepath a2 a3" |
|
904 and ?l3 = "linepath a3 a4" and ?l4 = "linepath a4 a1" |
|
905 from assms and less have "z \<notin> path_image (rectpath a1 a3)" |
|
906 by (auto simp: path_image_rectpath_cbox_minus_box) |
|
907 also have "path_image (rectpath a1 a3) = |
|
908 path_image ?l1 \<union> path_image ?l2 \<union> path_image ?l3 \<union> path_image ?l4" |
|
909 by (simp add: rectpath_def Let_def path_image_join Un_assoc a2_def a4_def) |
|
910 finally have "z \<notin> \<dots>" . |
|
911 moreover have "\<forall>l\<in>{?l1,?l2,?l3,?l4}. Re (winding_number l z) > 0" |
|
912 unfolding ball_simps HOL.simp_thms a2_def a4_def |
|
913 by (intro conjI; (rule winding_number_linepath_pos_lt; |
|
914 (insert assms, auto simp: a2_def a4_def in_box_complex_iff mult_neg_neg))+) |
|
915 ultimately have "Re (winding_number (rectpath a1 a3) z) > 0" |
|
916 by (simp add: winding_number_join path_image_join rectpath_def Let_def a2_def a4_def) |
|
917 thus "winding_number (rectpath a1 a3) z = 1" using assms less |
|
918 by (intro simple_closed_path_winding_number_pos simple_path_rectpath) |
|
919 (auto simp: path_image_rectpath_cbox_minus_box) |
|
920 qed |
|
921 |
|
922 lemma winding_number_rectpath_outside: |
|
923 assumes "Re a1 \<le> Re a3" "Im a1 \<le> Im a3" |
|
924 assumes "z \<notin> cbox a1 a3" |
|
925 shows "winding_number (rectpath a1 a3) z = 0" |
|
926 using assms by (intro winding_number_zero_outside[OF _ _ _ assms(3)] |
|
927 path_image_rectpath_subset_cbox) simp_all |
|
928 |
782 end |
929 end |
783 |
930 |