src/HOL/Complex.thy
changeset 59741 5b762cd73a8e
parent 59658 0cc388370041
child 59746 ddae5727c5a9
equal deleted inserted replaced
59734:f41a2f77ab1b 59741:5b762cd73a8e
   213   by (simp add: complex_eq_iff polar_Ex)
   213   by (simp add: complex_eq_iff polar_Ex)
   214 
   214 
   215 lemma i_even_power [simp]: "\<i> ^ (n * 2) = (-1) ^ n"
   215 lemma i_even_power [simp]: "\<i> ^ (n * 2) = (-1) ^ n"
   216   by (metis mult.commute power2_i power_mult)
   216   by (metis mult.commute power2_i power_mult)
   217 
   217 
       
   218 lemma Re_ii_times [simp]: "Re (ii*z) = - Im z"
       
   219   by simp
       
   220 
       
   221 lemma Im_ii_times [simp]: "Im (ii*z) = Re z"
       
   222   by simp
       
   223 
       
   224 lemma ii_times_eq_iff: "ii*w = z \<longleftrightarrow> w = -(ii*z)"
       
   225   by auto
       
   226 
       
   227 lemma divide_numeral_i [simp]: "z / (numeral n * ii) = -(ii*z) / numeral n"
       
   228   by (metis divide_divide_eq_left divide_i mult.commute mult_minus_right)
       
   229 
   218 subsection {* Vector Norm *}
   230 subsection {* Vector Norm *}
   219 
   231 
   220 instantiation complex :: real_normed_field
   232 instantiation complex :: real_normed_field
   221 begin
   233 begin
   222 
   234 
   306   apply (rule abs_sqrt_wlog [where x="Re z"])
   318   apply (rule abs_sqrt_wlog [where x="Re z"])
   307   apply (rule abs_sqrt_wlog [where x="Im z"])
   319   apply (rule abs_sqrt_wlog [where x="Im z"])
   308   apply (rule power2_le_imp_le)
   320   apply (rule power2_le_imp_le)
   309   apply (simp_all add: power2_sum add.commute sum_squares_bound real_sqrt_mult [symmetric])
   321   apply (simp_all add: power2_sum add.commute sum_squares_bound real_sqrt_mult [symmetric])
   310   done
   322   done
       
   323 
       
   324 lemma complex_unit_circle: "z \<noteq> 0 \<Longrightarrow> (Re z / cmod z)\<^sup>2 + (Im z / cmod z)\<^sup>2 = 1"
       
   325   by (simp add: norm_complex_def divide_simps complex_eq_iff)
   311 
   326 
   312 
   327 
   313 text {* Properties of complex signum. *}
   328 text {* Properties of complex signum. *}
   314 
   329 
   315 lemma sgn_eq: "sgn z = z / complex_of_real (cmod z)"
   330 lemma sgn_eq: "sgn z = z / complex_of_real (cmod z)"
   506 lemma complex_norm_square: "of_real ((norm z)\<^sup>2) = z * cnj z"
   521 lemma complex_norm_square: "of_real ((norm z)\<^sup>2) = z * cnj z"
   507 by (cases z)
   522 by (cases z)
   508    (auto simp: complex_eq_iff norm_complex_def power2_eq_square[symmetric] of_real_power[symmetric]
   523    (auto simp: complex_eq_iff norm_complex_def power2_eq_square[symmetric] of_real_power[symmetric]
   509          simp del: of_real_power)
   524          simp del: of_real_power)
   510 
   525 
   511 lemma re_complex_div_eq_0: "Re (a / b) = 0 \<longleftrightarrow> Re (a * cnj b) = 0"
   526 lemma Re_complex_div_eq_0: "Re (a / b) = 0 \<longleftrightarrow> Re (a * cnj b) = 0"
   512   by (auto simp add: Re_divide)
   527   by (auto simp add: Re_divide)
   513 
   528 
   514 lemma im_complex_div_eq_0: "Im (a / b) = 0 \<longleftrightarrow> Im (a * cnj b) = 0"
   529 lemma Im_complex_div_eq_0: "Im (a / b) = 0 \<longleftrightarrow> Im (a * cnj b) = 0"
   515   by (auto simp add: Im_divide)
   530   by (auto simp add: Im_divide)
   516 
   531 
   517 lemma complex_div_gt_0:
   532 lemma complex_div_gt_0:
   518   "(Re (a / b) > 0 \<longleftrightarrow> Re (a * cnj b) > 0) \<and> (Im (a / b) > 0 \<longleftrightarrow> Im (a * cnj b) > 0)"
   533   "(Re (a / b) > 0 \<longleftrightarrow> Re (a * cnj b) > 0) \<and> (Im (a / b) > 0 \<longleftrightarrow> Im (a * cnj b) > 0)"
   519 proof cases
   534 proof cases
   524     by (simp add: complex_eq_iff sum_power2_gt_zero_iff)
   539     by (simp add: complex_eq_iff sum_power2_gt_zero_iff)
   525   then show ?thesis
   540   then show ?thesis
   526     by (simp add: Re_divide Im_divide zero_less_divide_iff)
   541     by (simp add: Re_divide Im_divide zero_less_divide_iff)
   527 qed
   542 qed
   528 
   543 
   529 lemma re_complex_div_gt_0: "Re (a / b) > 0 \<longleftrightarrow> Re (a * cnj b) > 0"
   544 lemma Re_complex_div_gt_0: "Re (a / b) > 0 \<longleftrightarrow> Re (a * cnj b) > 0"
   530   and im_complex_div_gt_0: "Im (a / b) > 0 \<longleftrightarrow> Im (a * cnj b) > 0"
   545   and Im_complex_div_gt_0: "Im (a / b) > 0 \<longleftrightarrow> Im (a * cnj b) > 0"
   531   using complex_div_gt_0 by auto
   546   using complex_div_gt_0 by auto
   532 
   547 
   533 lemma re_complex_div_ge_0: "Re(a / b) \<ge> 0 \<longleftrightarrow> Re(a * cnj b) \<ge> 0"
   548 lemma Re_complex_div_ge_0: "Re(a / b) \<ge> 0 \<longleftrightarrow> Re(a * cnj b) \<ge> 0"
   534   by (metis le_less re_complex_div_eq_0 re_complex_div_gt_0)
   549   by (metis le_less Re_complex_div_eq_0 Re_complex_div_gt_0)
   535 
   550 
   536 lemma im_complex_div_ge_0: "Im(a / b) \<ge> 0 \<longleftrightarrow> Im(a * cnj b) \<ge> 0"
   551 lemma Im_complex_div_ge_0: "Im(a / b) \<ge> 0 \<longleftrightarrow> Im(a * cnj b) \<ge> 0"
   537   by (metis im_complex_div_eq_0 im_complex_div_gt_0 le_less)
   552   by (metis Im_complex_div_eq_0 Im_complex_div_gt_0 le_less)
   538 
   553 
   539 lemma re_complex_div_lt_0: "Re(a / b) < 0 \<longleftrightarrow> Re(a * cnj b) < 0"
   554 lemma Re_complex_div_lt_0: "Re(a / b) < 0 \<longleftrightarrow> Re(a * cnj b) < 0"
   540   by (metis less_asym neq_iff re_complex_div_eq_0 re_complex_div_gt_0)
   555   by (metis less_asym neq_iff Re_complex_div_eq_0 Re_complex_div_gt_0)
   541 
   556 
   542 lemma im_complex_div_lt_0: "Im(a / b) < 0 \<longleftrightarrow> Im(a * cnj b) < 0"
   557 lemma Im_complex_div_lt_0: "Im(a / b) < 0 \<longleftrightarrow> Im(a * cnj b) < 0"
   543   by (metis im_complex_div_eq_0 im_complex_div_gt_0 less_asym neq_iff)
   558   by (metis Im_complex_div_eq_0 Im_complex_div_gt_0 less_asym neq_iff)
   544 
   559 
   545 lemma re_complex_div_le_0: "Re(a / b) \<le> 0 \<longleftrightarrow> Re(a * cnj b) \<le> 0"
   560 lemma Re_complex_div_le_0: "Re(a / b) \<le> 0 \<longleftrightarrow> Re(a * cnj b) \<le> 0"
   546   by (metis not_le re_complex_div_gt_0)
   561   by (metis not_le Re_complex_div_gt_0)
   547 
   562 
   548 lemma im_complex_div_le_0: "Im(a / b) \<le> 0 \<longleftrightarrow> Im(a * cnj b) \<le> 0"
   563 lemma Im_complex_div_le_0: "Im(a / b) \<le> 0 \<longleftrightarrow> Im(a * cnj b) \<le> 0"
   549   by (metis im_complex_div_gt_0 not_le)
   564   by (metis Im_complex_div_gt_0 not_le)
   550 
   565 
   551 lemma Re_setsum[simp]: "Re (setsum f s) = (\<Sum>x\<in>s. Re (f x))"
   566 lemma Re_setsum[simp]: "Re (setsum f s) = (\<Sum>x\<in>s. Re (f x))"
   552   by (induct s rule: infinite_finite_induct) auto
   567   by (induct s rule: infinite_finite_induct) auto
   553 
   568 
   554 lemma Im_setsum[simp]: "Im (setsum f s) = (\<Sum>x\<in>s. Im(f x))"
   569 lemma Im_setsum[simp]: "Im (setsum f s) = (\<Sum>x\<in>s. Im(f x))"
   805   by simp
   820   by simp
   806 
   821 
   807 lemma csqrt_ii [simp]: "csqrt \<i> = (1 + \<i>) / sqrt 2"
   822 lemma csqrt_ii [simp]: "csqrt \<i> = (1 + \<i>) / sqrt 2"
   808   by (simp add: complex_eq_iff Re_divide Im_divide real_sqrt_divide real_div_sqrt)
   823   by (simp add: complex_eq_iff Re_divide Im_divide real_sqrt_divide real_div_sqrt)
   809 
   824 
   810 lemma power2_csqrt[algebra]: "(csqrt z)\<^sup>2 = z"
   825 lemma power2_csqrt[simp,algebra]: "(csqrt z)\<^sup>2 = z"
   811 proof cases
   826 proof cases
   812   assume "Im z = 0" then show ?thesis
   827   assume "Im z = 0" then show ?thesis
   813     using real_sqrt_pow2[of "Re z"] real_sqrt_pow2[of "- Re z"]
   828     using real_sqrt_pow2[of "Re z"] real_sqrt_pow2[of "- Re z"]
   814     by (cases "0::real" "Re z" rule: linorder_cases)
   829     by (cases "0::real" "Re z" rule: linorder_cases)
   815        (simp_all add: complex_eq_iff Re_power2 Im_power2 power2_eq_square cmod_eq_Re)
   830        (simp_all add: complex_eq_iff Re_power2 Im_power2 power2_eq_square cmod_eq_Re)