src/HOL/Library/Fundamental_Theorem_Algebra.thy
changeset 53077 a1b3784f8129
parent 52380 3cc46b8cca5e
child 54230 b1d955791529
equal deleted inserted replaced
53076:47c9aff07725 53077:a1b3784f8129
    12             if 0 \<le> Re z then Complex (sqrt(Re z)) 0
    12             if 0 \<le> Re z then Complex (sqrt(Re z)) 0
    13             else Complex 0 (sqrt(- Re z))
    13             else Complex 0 (sqrt(- Re z))
    14            else Complex (sqrt((cmod z + Re z) /2))
    14            else Complex (sqrt((cmod z + Re z) /2))
    15                         ((Im z / abs(Im z)) * sqrt((cmod z - Re z) /2)))"
    15                         ((Im z / abs(Im z)) * sqrt((cmod z - Re z) /2)))"
    16 
    16 
    17 lemma csqrt[algebra]: "csqrt z ^ 2 = z"
    17 lemma csqrt[algebra]: "(csqrt z)\<^sup>2 = z"
    18 proof-
    18 proof-
    19   obtain x y where xy: "z = Complex x y" by (cases z)
    19   obtain x y where xy: "z = Complex x y" by (cases z)
    20   {assume y0: "y = 0"
    20   {assume y0: "y = 0"
    21     {assume x0: "x \<ge> 0"
    21     {assume x0: "x \<ge> 0"
    22       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    22       then have ?thesis using y0 xy real_sqrt_pow2[OF x0]
    32       let ?z = "Complex x y"
    32       let ?z = "Complex x y"
    33       from abs_Re_le_cmod[of ?z] have tha: "abs x \<le> cmod ?z" by auto
    33       from abs_Re_le_cmod[of ?z] have tha: "abs x \<le> cmod ?z" by auto
    34       hence "cmod ?z - x \<ge> 0" "cmod ?z + x \<ge> 0" by arith+
    34       hence "cmod ?z - x \<ge> 0" "cmod ?z + x \<ge> 0" by arith+
    35       hence "(sqrt (x * x + y * y) + x) / 2 \<ge> 0" "(sqrt (x * x + y * y) - x) / 2 \<ge> 0" by (simp_all add: power2_eq_square) }
    35       hence "(sqrt (x * x + y * y) + x) / 2 \<ge> 0" "(sqrt (x * x + y * y) - x) / 2 \<ge> 0" by (simp_all add: power2_eq_square) }
    36     note th = this
    36     note th = this
    37     have sq4: "\<And>x::real. x^2 / 4 = (x / 2) ^ 2"
    37     have sq4: "\<And>x::real. x\<^sup>2 / 4 = (x / 2)\<^sup>2"
    38       by (simp add: power2_eq_square)
    38       by (simp add: power2_eq_square)
    39     from th[of x y]
    39     from th[of x y]
    40     have sq4': "sqrt (((sqrt (x * x + y * y) + x)^2 / 4)) = (sqrt (x * x + y * y) + x) / 2" "sqrt (((sqrt (x * x + y * y) - x)^2 / 4)) = (sqrt (x * x + y * y) - x) / 2" unfolding sq4 by simp_all
    40     have sq4': "sqrt (((sqrt (x * x + y * y) + x)\<^sup>2 / 4)) = (sqrt (x * x + y * y) + x) / 2"
       
    41       "sqrt (((sqrt (x * x + y * y) - x)\<^sup>2 / 4)) = (sqrt (x * x + y * y) - x) / 2"
       
    42       unfolding sq4 by simp_all
    41     then have th1: "sqrt ((sqrt (x * x + y * y) + x) * (sqrt (x * x + y * y) + x) / 4) - sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) - x) / 4) = x"
    43     then have th1: "sqrt ((sqrt (x * x + y * y) + x) * (sqrt (x * x + y * y) + x) / 4) - sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) - x) / 4) = x"
    42       unfolding power2_eq_square by simp
    44       unfolding power2_eq_square by simp
    43     have "sqrt 4 = sqrt (2^2)" by simp
    45     have "sqrt 4 = sqrt (2\<^sup>2)" by simp
    44     hence sqrt4: "sqrt 4 = 2" by (simp only: real_sqrt_abs)
    46     hence sqrt4: "sqrt 4 = 2" by (simp only: real_sqrt_abs)
    45     have th2: "2 *(y * sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) + x) / 4)) / \<bar>y\<bar> = y"
    47     have th2: "2 *(y * sqrt ((sqrt (x * x + y * y) - x) * (sqrt (x * x + y * y) + x) / 4)) / \<bar>y\<bar> = y"
    46       using iffD2[OF real_sqrt_pow2_iff sum_power2_ge_zero[of x y]] y0
    48       using iffD2[OF real_sqrt_pow2_iff sum_power2_ge_zero[of x y]] y0
    47       unfolding power2_eq_square
    49       unfolding power2_eq_square
    48       by (simp add: algebra_simps real_sqrt_divide sqrt4)
    50       by (simp add: algebra_simps real_sqrt_divide sqrt4)
   182 lemma  unimodular_reduce_norm:
   184 lemma  unimodular_reduce_norm:
   183   assumes md: "cmod z = 1"
   185   assumes md: "cmod z = 1"
   184   shows "cmod (z + 1) < 1 \<or> cmod (z - 1) < 1 \<or> cmod (z + ii) < 1 \<or> cmod (z - ii) < 1"
   186   shows "cmod (z + 1) < 1 \<or> cmod (z - 1) < 1 \<or> cmod (z + ii) < 1 \<or> cmod (z - ii) < 1"
   185 proof-
   187 proof-
   186   obtain x y where z: "z = Complex x y " by (cases z, auto)
   188   obtain x y where z: "z = Complex x y " by (cases z, auto)
   187   from md z have xy: "x^2 + y^2 = 1" by (simp add: cmod_def)
   189   from md z have xy: "x\<^sup>2 + y\<^sup>2 = 1" by (simp add: cmod_def)
   188   {assume C: "cmod (z + 1) \<ge> 1" "cmod (z - 1) \<ge> 1" "cmod (z + ii) \<ge> 1" "cmod (z - ii) \<ge> 1"
   190   {assume C: "cmod (z + 1) \<ge> 1" "cmod (z - 1) \<ge> 1" "cmod (z + ii) \<ge> 1" "cmod (z - ii) \<ge> 1"
   189     from C z xy have "2*x \<le> 1" "2*x \<ge> -1" "2*y \<le> 1" "2*y \<ge> -1"
   191     from C z xy have "2*x \<le> 1" "2*x \<ge> -1" "2*y \<le> 1" "2*y \<ge> -1"
   190       by (simp_all add: cmod_def power2_eq_square algebra_simps)
   192       by (simp_all add: cmod_def power2_eq_square algebra_simps)
   191     hence "abs (2*x) \<le> 1" "abs (2*y) \<le> 1" by simp_all
   193     hence "abs (2*x) \<le> 1" "abs (2*y) \<le> 1" by simp_all
   192     hence "(abs (2 * x))^2 <= 1^2" "(abs (2 * y)) ^2 <= 1^2"
   194     hence "(abs (2 * x))\<^sup>2 <= 1\<^sup>2" "(abs (2 * y))\<^sup>2 <= 1\<^sup>2"
   193       by - (rule power_mono, simp, simp)+
   195       by - (rule power_mono, simp, simp)+
   194     hence th0: "4*x^2 \<le> 1" "4*y^2 \<le> 1"
   196     hence th0: "4*x\<^sup>2 \<le> 1" "4*y\<^sup>2 \<le> 1"
   195       by (simp_all add: power_mult_distrib)
   197       by (simp_all add: power_mult_distrib)
   196     from add_mono[OF th0] xy have False by simp }
   198     from add_mono[OF th0] xy have False by simp }
   197   thus ?thesis unfolding linorder_not_le[symmetric] by blast
   199   thus ?thesis unfolding linorder_not_le[symmetric] by blast
   198 qed
   200 qed
   199 
   201 
   452       have "cmod (poly p z) \<le> cmod (poly p w)" by simp }
   454       have "cmod (poly p z) \<le> cmod (poly p w)" by simp }
   453     hence ?thesis by blast}
   455     hence ?thesis by blast}
   454   ultimately show ?thesis by blast
   456   ultimately show ?thesis by blast
   455 qed
   457 qed
   456 
   458 
   457 lemma "(rcis (sqrt (abs r)) (a/2)) ^ 2 = rcis (abs r) a"
   459 lemma "(rcis (sqrt (abs r)) (a/2))\<^sup>2 = rcis (abs r) a"
   458   unfolding power2_eq_square
   460   unfolding power2_eq_square
   459   apply (simp add: rcis_mult)
   461   apply (simp add: rcis_mult)
   460   apply (simp add: power2_eq_square[symmetric])
   462   apply (simp add: power2_eq_square[symmetric])
   461   done
   463   done
   462 
   464 
   463 lemma cispi: "cis pi = -1"
   465 lemma cispi: "cis pi = -1"
   464   unfolding cis_def
   466   unfolding cis_def
   465   by simp
   467   by simp
   466 
   468 
   467 lemma "(rcis (sqrt (abs r)) ((pi + a)/2)) ^ 2 = rcis (- abs r) a"
   469 lemma "(rcis (sqrt (abs r)) ((pi + a)/2))\<^sup>2 = rcis (- abs r) a"
   468   unfolding power2_eq_square
   470   unfolding power2_eq_square
   469   apply (simp add: rcis_mult add_divide_distrib)
   471   apply (simp add: rcis_mult add_divide_distrib)
   470   apply (simp add: power2_eq_square[symmetric] rcis_def cispi cis_mult[symmetric])
   472   apply (simp add: power2_eq_square[symmetric] rcis_def cispi cis_mult[symmetric])
   471   done
   473   done
   472 
   474