# HG changeset patch # User paulson # Date 1601031921 -3600 # Node ID c5d1a01d2d6c179116a8b6b2d4ec6ec4f7b6b3a3 # Parent 7e90e1d178b52db53c3eb147dd3e5bff9a5cf83a de-applying and tidying diff -r 7e90e1d178b5 -r c5d1a01d2d6c src/HOL/Analysis/Complex_Transcendental.thy --- a/src/HOL/Analysis/Complex_Transcendental.thy Sun Sep 20 15:45:25 2020 +0100 +++ b/src/HOL/Analysis/Complex_Transcendental.thy Fri Sep 25 12:05:21 2020 +0100 @@ -10,7 +10,7 @@ subsection\Möbius transformations\ (* TODO: Figure out what to do with Möbius transformations *) -definition\<^marker>\tag important\ "moebius a b c d = (\z. (a*z+b) / (c*z+d :: 'a :: field))" +definition\<^marker>\tag important\ "moebius a b c d \ (\z. (a*z+b) / (c*z+d :: 'a :: field))" theorem moebius_inverse: assumes "a * d \ b * c" "c * z + d \ 0" @@ -33,11 +33,10 @@ shows "cmod (z + r) < cmod z + \r\" proof (cases z) case (Complex x y) - have "r * x / \r\ < sqrt (x*x + y*y)" - apply (rule real_less_rsqrt) - using assms - apply (simp add: Complex power2_eq_square) - using not_real_square_gt_zero by blast + then have "0 < y * y" + using assms mult_neg_neg by force + with assms have "r * x / \r\ < sqrt (x*x + y*y)" + by (simp add: real_less_rsqrt power2_eq_square) then show ?thesis using assms Complex apply (simp add: cmod_def) apply (rule power2_less_imp_less, auto) @@ -435,8 +434,7 @@ also have "... \ (\n::int. -z = of_real(2 * n * pi) + of_real pi/2)" by (simp only: csin_eq_1) also have "... \ (\n::int. z = - of_real(2 * n * pi) - of_real pi/2)" - apply (rule iff_exI) - by (metis (no_types) is_num_normalize(8) minus_minus of_real_def real_vector.scale_minus_left uminus_add_conv_diff) + by (rule iff_exI) (metis add.inverse_inverse add_uminus_conv_diff minus_add_distrib) also have "... = ?rhs" apply safe apply (rule_tac [2] x="-(x+1)" in exI) @@ -494,11 +492,18 @@ qed lemma dist_exp_i_1: "norm(exp(\ * of_real t) - 1) = 2 * \sin(t / 2)\" - apply (simp add: exp_Euler cmod_def power2_diff sin_of_real cos_of_real algebra_simps) - using cos_double_sin [of "t/2"] - apply (simp add: real_sqrt_mult) - done - +proof - + have "sqrt (2 - cos t * 2) = 2 * \sin (t / 2)\" + using cos_double_sin [of "t/2"] by (simp add: real_sqrt_mult) + then show ?thesis + by (simp add: exp_Euler cmod_def power2_diff sin_of_real cos_of_real algebra_simps) +qed + +lemma sin_cx_2pi [simp]: "\z = of_int m; even m\ \ sin (z * complex_of_real pi) = 0" + by (simp add: sin_eq_0) + +lemma cos_cx_2pi [simp]: "\z = of_int m; even m\ \ cos (z * complex_of_real pi) = 1" + using cos_eq_1 by auto lemma complex_sin_eq: fixes w :: complex @@ -524,14 +529,22 @@ qed next assume ?rhs - then obtain n::int where w: "w = z + of_real (2* of_int n*pi) \ - w = -z + of_real ((2* of_int n + 1)*pi)" + then consider n::int where "w = z + of_real (2 * of_int n * pi)" + | n::int where " w = -z + of_real ((2 * of_int n + 1) * pi)" using Ints_cases by blast then show ?lhs - using Periodic_Fun.sin.plus_of_int [of z n] - apply (auto simp: algebra_simps) - by (metis (no_types, hide_lams) add_diff_cancel_left add_diff_cancel_left' add_minus_cancel - mult.commute sin.plus_of_int sin_minus sin_plus_pi) + proof cases + case 1 + then show ?thesis + using Periodic_Fun.sin.plus_of_int [of z n] + by (auto simp: algebra_simps) + next + case 2 + then show ?thesis + using Periodic_Fun.sin.plus_of_int [of "-z" "n"] + apply (simp add: algebra_simps) + by (metis add.commute add.inverse_inverse add_diff_cancel_left diff_add_cancel sin_plus_pi) + qed qed lemma complex_cos_eq: @@ -549,14 +562,20 @@ then show ?rhs proof cases case 1 + then obtain n where "w + z = of_int n * (complex_of_real pi * 2)" + by (auto simp: sin_eq_0 algebra_simps) + then have "w = -z + of_real(2 * of_int n * pi)" + by (auto simp: algebra_simps) then show ?thesis - apply (simp add: sin_eq_0 algebra_simps) - by (metis Ints_of_int of_real_of_int_eq) + using Ints_of_int by blast next case 2 + then obtain n where "z = w + of_int n * (complex_of_real pi * 2)" + by (auto simp: sin_eq_0 algebra_simps) + then have "w = z + complex_of_real (2 * of_int(-n) * pi)" + by (auto simp: algebra_simps) then show ?thesis - apply (clarsimp simp: sin_eq_0 algebra_simps) - by (metis Ints_of_int add_minus_cancel distrib_right mult_of_int_commute mult_zero_right of_int_0 of_int_add of_real_of_int_eq) + using Ints_of_int by blast qed next assume ?rhs @@ -607,22 +626,28 @@ lemmas cos_i_times = cosh_complex [symmetric] lemma norm_cos_squared: - "norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4" - apply (cases z) - apply (simp add: cos_add cmod_power2 cos_of_real sin_of_real Complex_eq) - apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide power_divide) - apply (simp only: left_diff_distrib [symmetric] power_mult_distrib sin_squared_eq) - apply (simp add: power2_eq_square field_split_simps) - done + "norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4" +proof (cases z) + case (Complex x1 x2) + then show ?thesis + apply (simp only: cos_add cmod_power2 cos_of_real sin_of_real Complex_eq) + apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide power_divide) + apply (simp only: left_diff_distrib [symmetric] power_mult_distrib sin_squared_eq) + apply (simp add: power2_eq_square field_split_simps) + done +qed lemma norm_sin_squared: - "norm(sin z) ^ 2 = (exp(2 * Im z) + inverse(exp(2 * Im z)) - 2 * cos(2 * Re z)) / 4" - apply (cases z) - apply (simp add: sin_add cmod_power2 cos_of_real sin_of_real cos_double_cos exp_double Complex_eq) - apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide power_divide) - apply (simp only: left_diff_distrib [symmetric] power_mult_distrib cos_squared_eq) - apply (simp add: power2_eq_square field_split_simps) - done + "norm(sin z) ^ 2 = (exp(2 * Im z) + inverse(exp(2 * Im z)) - 2 * cos(2 * Re z)) / 4" +proof (cases z) + case (Complex x1 x2) + then show ?thesis + apply (simp only: sin_add cmod_power2 cos_of_real sin_of_real cos_double_cos exp_double Complex_eq) + apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide power_divide) + apply (simp only: left_diff_distrib [symmetric] power_mult_distrib cos_squared_eq) + apply (simp add: power2_eq_square field_split_simps) + done +qed lemma exp_uminus_Im: "exp (- Im z) \ exp (cmod z)" using abs_Im_le_cmod linear order_trans by fastforce @@ -633,11 +658,10 @@ proof - have "Im z \ cmod z" using abs_Im_le_cmod abs_le_D1 by auto - with exp_uminus_Im show ?thesis - apply (simp add: cos_exp_eq norm_divide) - apply (rule order_trans [OF norm_triangle_ineq], simp) - apply (metis add_mono exp_le_cancel_iff mult_2_right) - done + then have "exp (- Im z) + exp (Im z) \ exp (cmod z) * 2" + by (metis exp_uminus_Im add_mono exp_le_cancel_iff mult_2_right) + then show ?thesis + by (force simp add: cos_exp_eq norm_divide intro: order_trans [OF norm_triangle_ineq]) qed lemma norm_cos_plus1_le: @@ -730,9 +754,12 @@ next fix x assume "x \ closed_segment 0 z" + then obtain u where u: "x = complex_of_real u * z" "0 \ u" "u \ 1" + by (auto simp: closed_segment_def scaleR_conv_of_real) + then have "u * Re z \ \Re z\" + by (metis abs_ge_self abs_ge_zero mult.commute mult.right_neutral mult_mono) then show "Re x \ \Re z\" - apply (clarsimp simp: closed_segment_def scaleR_conv_of_real) - by (meson abs_ge_self abs_ge_zero linear mult_left_le_one_le mult_nonneg_nonpos order_trans) + by (simp add: u) qed auto lemma @@ -745,11 +772,11 @@ have *: "(cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2 \ exp \Im z\" proof (rule mono) show "cmod (exp (\ * (u * z))) \ exp \Im z\" - apply (simp add: abs_if mult_left_le_one_le assms not_less) - by (meson assms(1) mult_nonneg_nonneg neg_le_0_iff_le order_trans) + using assms + by (auto simp: abs_if mult_left_le_one_le not_less intro: order_trans [of _ 0]) show "cmod (exp (- (\ * (u * z)))) \ exp \Im z\" - apply (simp add: abs_if mult_left_le_one_le assms) - by (meson \0 \ u\ less_eq_real_def mult_nonneg_nonpos neg_0_le_iff_le order_trans) + using assms + by (auto simp: abs_if mult_left_le_one_le mult_nonneg_nonpos intro: order_trans [of _ 0]) qed have "cmod (sin (u *\<^sub>R z)) = cmod (exp (\ * (u * z)) - exp (- (\ * (u * z)))) / 2" by (auto simp: scaleR_conv_of_real norm_mult norm_power sin_exp_eq norm_divide) @@ -796,9 +823,7 @@ = (-1)^(k div 2) * (if even k then sin 0 else cos 0) * z^k / of_nat (fact k)" by (auto simp: sin_coeff_def elim!: oddE) show ?thesis - apply (rule order_trans [OF _ *]) - apply (simp add: **) - done + by (simp add: ** order_trans [OF _ *]) qed lemma Taylor_cos: @@ -830,9 +855,7 @@ = (-1)^(Suc k div 2) * (if even k then cos 0 else sin 0) * z^k / of_nat (fact k)" by (auto simp: cos_coeff_def elim!: evenE) show ?thesis - apply (rule order_trans [OF _ *]) - apply (simp add: **) - done + by (simp add: ** order_trans [OF _ *]) qed declare power_Suc [simp] @@ -904,8 +927,7 @@ then have "exp (\ * of_real t') = exp (\ * of_real t)" by (metis nz mult_left_cancel mult_zero_left z is_Arg_def) then have "sin t' = sin t \ cos t' = cos t" - apply (simp add: exp_Euler sin_of_real cos_of_real) - by (metis Complex_eq complex.sel) + by (metis cis.simps cis_conv_exp) then obtain n::int where n: "t' = t + 2 * n * pi" by (auto simp: sin_cos_eq_iff) then have "n=0" @@ -926,10 +948,8 @@ by blast have z: "is_Arg z t" unfolding is_Arg_def - apply (rule complex_eqI) using t False ReIm - apply (auto simp: exp_Euler sin_of_real cos_of_real field_split_simps) - done + by (intro complex_eqI) (auto simp: exp_Euler sin_of_real cos_of_real field_split_simps) show ?thesis apply (simp add: Arg2pi_def False) apply (rule theI [where a=t]) @@ -950,13 +970,14 @@ lemma Arg2pi_unique: "\of_real r * exp(\ * of_real a) = z; 0 < r; 0 \ a; a < 2*pi\ \ Arg2pi z = a" by (rule Arg2pi_unique_lemma [unfolded is_Arg_def, OF _ Arg2pi_eq]) (use Arg2pi [of z] in \auto simp: norm_mult\) -lemma Arg2pi_minus: "z \ 0 \ Arg2pi (-z) = (if Arg2pi z < pi then Arg2pi z + pi else Arg2pi z - pi)" - apply (rule Arg2pi_unique [of "norm z"]) - apply (rule complex_eqI) - using Arg2pi_ge_0 [of z] Arg2pi_eq [of z] Arg2pi_lt_2pi [of z] - apply (auto simp: Re_exp Im_exp cos_diff sin_diff cis_conv_exp [symmetric]) - apply (metis Re_rcis Im_rcis rcis_def)+ - done +lemma cos_Arg2pi: "cmod z * cos (Arg2pi z) = Re z" and sin_Arg2pi: "cmod z * sin (Arg2pi z) = Im z" + using Arg2pi_eq [of z] cis_conv_exp Re_rcis Im_rcis unfolding rcis_def by metis+ + +lemma Arg2pi_minus: + assumes "z \ 0" shows "Arg2pi (-z) = (if Arg2pi z < pi then Arg2pi z + pi else Arg2pi z - pi)" + apply (rule Arg2pi_unique [of "norm z", OF complex_eqI]) + using cos_Arg2pi sin_Arg2pi Arg2pi_ge_0 Arg2pi_lt_2pi [of z] assms + by (auto simp: Re_exp Im_exp) lemma Arg2pi_times_of_real [simp]: assumes "0 < r" shows "Arg2pi (of_real r * z) = Arg2pi z" @@ -992,11 +1013,13 @@ by (metis Arg2pi_eq) also have "... = (0 < Im (exp (\ * complex_of_real (Arg2pi z))))" using False by (simp add: zero_less_mult_iff) - also have "... \ 0 < Arg2pi z \ Arg2pi z < pi" - using Arg2pi_ge_0 Arg2pi_lt_2pi sin_le_zero sin_gt_zero - apply (auto simp: Im_exp) - using le_less apply fastforce - using not_le by blast + also have "... \ 0 < Arg2pi z \ Arg2pi z < pi" (is "_ = ?rhs") + proof - + have "0 < sin (Arg2pi z) \ ?rhs" + by (meson Arg2pi_ge_0 Arg2pi_lt_2pi less_le_trans not_le sin_le_zero sin_x_le_x) + then show ?thesis + by (auto simp: Im_exp sin_gt_zero) + qed finally show ?thesis by blast qed auto @@ -1182,10 +1205,10 @@ lemma Ln_exp [simp]: assumes "-pi < Im(z)" "Im(z) \ pi" shows "ln(exp z) = z" - apply (rule exp_complex_eqI) - using assms mpi_less_Im_Ln [of "exp z"] Im_Ln_le_pi [of "exp z"] - apply auto - done +proof (rule exp_complex_eqI) + show "\Im (ln (exp z)) - Im z\ < 2 * pi" + using assms mpi_less_Im_Ln [of "exp z"] Im_Ln_le_pi [of "exp z"] by auto +qed auto subsection\<^marker>\tag unimportant\\Relation to Real Logarithm\ @@ -1280,8 +1303,7 @@ have 1: "open ?U" by (simp add: open_Collect_conj open_halfspace_Im_gt open_halfspace_Im_lt) have 2: "\x. x \ ?U \ (exp has_derivative blinfun_apply(Blinfun ((*) (exp x)))) (at x)" - apply (simp add: bounded_linear_Blinfun_apply bounded_linear_mult_right) - using DERIV_exp has_field_derivative_def by blast + by (simp add: bounded_linear_Blinfun_apply bounded_linear_mult_right has_field_derivative_imp_has_derivative) have 3: "continuous_on ?U (\x. Blinfun ((*) (exp x)))" unfolding blinfun_mult_right.abs_eq [symmetric] by (intro continuous_intros) have 4: "Ln z \ ?U" @@ -1464,16 +1486,16 @@ also have A: "summable (\n. norm z^2 * (inverse (real_of_nat (Suc (Suc n))) * cmod z ^ n))" by (rule summable_mult, rule summable_comparison_test_ev[OF _ summable_geometric[of "norm z"]]) (auto simp: assms field_simps intro!: always_eventually) - hence "norm (\i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i) \ - (\i. norm (-(z^2) * inverse (of_nat (i+2)) * (-z)^i))" + hence "norm (\i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i) + \ (\i. norm (-(z^2) * inverse (of_nat (i+2)) * (-z)^i))" by (intro summable_norm) (auto simp: norm_power norm_inverse norm_mult mult_ac simp del: of_nat_add of_nat_Suc) also have "norm ((-z)^2 * (-z)^i) * inverse (of_nat (i+2)) \ norm ((-z)^2 * (-z)^i) * 1" for i by (intro mult_left_mono) (simp_all add: field_split_simps) hence "(\i. norm (-(z^2) * inverse (of_nat (i+2)) * (-z)^i)) - \ (\i. norm (-(z^2) * (-z)^i))" + \ (\i. norm (-(z^2) * (-z)^i))" using A assms - apply (simp_all only: norm_power norm_inverse norm_divide norm_mult) + unfolding norm_power norm_inverse norm_divide norm_mult apply (intro suminf_le summable_mult summable_geometric) apply (auto simp: norm_power field_simps simp del: of_nat_add of_nat_Suc) done @@ -1501,11 +1523,18 @@ then have w: "Im w \ pi" "- pi < Im w" using Im_Ln_le_pi [of z] mpi_less_Im_Ln [of z] assms by auto - then have "\Im w\ < pi/2 \ 0 < Re(exp w)" - using cos_lt_zero_pi [of "-(Im w)"] cos_lt_zero_pi [of "(Im w)"] - apply (auto simp: Re_exp zero_less_mult_iff cos_gt_zero_pi abs_if split: if_split_asm) - apply (metis cos_minus cos_pi_half divide_minus_left less_irrefl linorder_neqE_linordered_idom nonzero_mult_div_cancel_right zero_neq_numeral)+ - done + have "\Im w\ < pi/2 \ 0 < Re(exp w)" + proof + assume "\Im w\ < pi/2" then show "0 < Re(exp w)" + by (auto simp: Re_exp cos_gt_zero_pi split: if_split_asm) + next + assume R: "0 < Re(exp w)" then + have "\Im w\ \ pi/2" + by (metis cos_minus cos_pi_half mult_eq_0_iff Re_exp abs_if order_less_irrefl) + then show "\Im w\ < pi/2" + using cos_lt_zero_pi [of "-(Im w)"] cos_lt_zero_pi [of "(Im w)"] w R + by (force simp: Re_exp zero_less_mult_iff abs_if not_less_iff_gr_or_eq) + qed } then show ?thesis using assms by auto @@ -1521,10 +1550,8 @@ using Im_Ln_le_pi [of z] mpi_less_Im_Ln [of z] assms by auto then have "\Im w\ \ pi/2 \ 0 \ Re(exp w)" - apply (auto simp: Re_exp zero_le_mult_iff cos_ge_zero) using cos_lt_zero_pi [of "- (Im w)"] cos_lt_zero_pi [of "(Im w)"] not_le - apply (auto simp: abs_if split: if_split_asm) - done + by (auto simp: Re_exp zero_le_mult_iff abs_if intro: cos_ge_zero) } then show ?thesis using assms by auto @@ -1540,15 +1567,14 @@ using Im_Ln_le_pi [of z] mpi_less_Im_Ln [of z] assms by auto then have "0 < Im w \ Im w < pi \ 0 < Im(exp w)" - using sin_gt_zero [of "- (Im w)"] sin_gt_zero [of "(Im w)"] - apply (simp add: Im_exp zero_less_mult_iff) - using less_linear apply fastforce - done + using sin_gt_zero [of "- (Im w)"] sin_gt_zero [of "(Im w)"] less_linear + by (fastforce simp add: Im_exp zero_less_mult_iff) } then show ?thesis using assms by auto qed + lemma Im_Ln_pos_le: assumes "z \ 0" shows "0 \ Im(Ln z) \ Im(Ln z) \ pi \ 0 \ Im(z)" @@ -1559,10 +1585,8 @@ using Im_Ln_le_pi [of z] mpi_less_Im_Ln [of z] assms by auto then have "0 \ Im w \ Im w \ pi \ 0 \ Im(exp w)" - using sin_ge_zero [of "- (Im w)"] sin_ge_zero [of "(Im w)"] - apply (auto simp: Im_exp zero_le_mult_iff sin_ge_zero) - apply (metis not_le not_less_iff_gr_or_eq pi_not_less_zero sin_eq_0_pi) - done } + using sin_ge_zero [of "- (Im w)"] sin_ge_zero [of "abs(Im w)"] sin_zero_pi_iff [of "Im w"] + by (force simp: Im_exp zero_le_mult_iff sin_ge_zero) } then show ?thesis using assms by auto qed @@ -1633,10 +1657,10 @@ qed (use assms in auto) lemma Ln_minus1 [simp]: "Ln(-1) = \ * pi" - apply (rule exp_complex_eqI) - using Im_Ln_le_pi [of "-1"] mpi_less_Im_Ln [of "-1"] cis_conv_exp cis_pi - apply (auto simp: abs_if) - done +proof (rule exp_complex_eqI) + show "\Im (Ln (- 1)) - Im (\ * pi)\ < 2 * pi" + using Im_Ln_le_pi [of "-1"] mpi_less_Im_Ln [of "-1"] by auto +qed auto lemma Ln_ii [simp]: "Ln \ = \ * of_real pi/2" using Ln_exp [of "\ * (of_real pi/2)"] @@ -1715,22 +1739,16 @@ by (simp add: Ln_inverse) next case True - then have z: "Im z = 0" "Re z < 0" - using assms - apply (auto simp: complex_nonpos_Reals_iff) - by (metis complex_is_Real_iff le_imp_less_or_eq of_real_0 of_real_Re) + then have z: "Im z = 0" "Re z < 0" "- z \ \\<^sub>\\<^sub>0" + using assms complex_eq_iff complex_nonpos_Reals_iff by auto have "Ln(inverse z) = Ln(- (inverse (-z)))" by simp also have "... = Ln (inverse (-z)) + \ * complex_of_real pi" - using assms z - apply (simp add: Ln_minus) - apply (simp add: field_simps) - done + using assms z by (simp add: Ln_minus divide_less_0_iff) also have "... = - Ln (- z) + \ * complex_of_real pi" - apply (subst Ln_inverse) - using z by (auto simp add: complex_nonneg_Reals_iff) + using z Ln_inverse by presburger also have "... = - (Ln z) + \ * 2 * complex_of_real pi" - by (subst Ln_minus) (use assms z in auto) + using Ln_minus assms z by auto finally show ?thesis by (simp add: True) qed @@ -1860,11 +1878,9 @@ have [simp]: "cmod z * sin (Arg z) = Im z" using assms Arg_eq [of z] by (metis Im_exp exp_Ln norm_exp_eq_Re Arg_def) show ?thesis - apply (rule Arg_unique [of "norm z"]) - apply (rule complex_eqI) + apply (rule Arg_unique [of "norm z", OF complex_eqI]) using mpi_less_Arg [of z] Arg_le_pi [of z] assms - apply (auto simp: Re_exp Im_exp cos_diff sin_diff cis_conv_exp [symmetric]) - done + by (auto simp: Re_exp Im_exp) qed lemma Arg_times_of_real [simp]: @@ -1923,31 +1939,30 @@ by simp (metis Arg2pi_inverse Arg2pi_real Arg_real Reals_inverse) next case False - then have "Arg z < pi" "z \ 0" + then have z: "Arg z < pi" "z \ 0" using Arg_eq_0_pi Arg_le_pi by (auto simp: less_eq_real_def) - then show ?thesis - apply (simp add: False) + show ?thesis apply (rule Arg_unique [of "inverse (norm z)"]) - using False mpi_less_Arg [of z] Arg_eq [of z] - apply (auto simp: exp_minus field_simps) - done + using False z mpi_less_Arg [of z] Arg_eq [of z] + by (auto simp: exp_minus field_simps) qed lemma Arg_eq_iff: assumes "w \ 0" "z \ 0" - shows "Arg w = Arg z \ (\x. 0 < x \ w = of_real x * z)" - using assms Arg_eq [of z] Arg_eq [of w] - apply auto - apply (rule_tac x="norm w / norm z" in exI) - apply (simp add: field_split_simps) - by (metis mult.commute mult.left_commute) + shows "Arg w = Arg z \ (\x. 0 < x \ w = of_real x * z)" (is "?lhs = ?rhs") +proof + assume ?lhs + then have "w = complex_of_real (cmod w / cmod z) * z" + by (metis Arg_eq assms divide_divide_eq_right eq_divide_eq exp_not_eq_zero of_real_divide) + then show ?rhs + using assms divide_pos_pos zero_less_norm_iff by blast +qed auto lemma Arg_inverse_eq_0: "Arg(inverse z) = 0 \ Arg z = 0" by (metis Arg_eq_0 Arg_inverse inverse_inverse_eq) lemma Arg_cnj_eq_inverse: "z\0 \ Arg (cnj z) = Arg (inverse z)" - apply (simp add: Arg_eq_iff field_split_simps complex_norm_square [symmetric]) - by (metis of_real_power zero_less_norm_iff zero_less_power) + using Arg2pi_cnj_eq_inverse Arg2pi_eq_iff Arg_eq_iff by auto lemma Arg_cnj: "Arg(cnj z) = (if z \ \ then Arg z else - Arg z)" by (metis Arg_cnj_eq_inverse Arg_inverse Reals_0 complex_cnj_zero) @@ -2077,11 +2092,10 @@ show ?thesis proof (rule Arg2pi_unique [of "norm z"]) show "(cmod z) * exp (\ * (pi / 2 - arctan (Re z / Im z))) = z" - apply (auto simp: exp_Euler cos_diff sin_diff) + apply (rule complex_eqI) using assms norm_complex_def [of z, symmetric] - apply (simp add: sin_of_real cos_of_real sin_arctan cos_arctan field_simps real_sqrt_divide) - apply (metis complex_eq) - done + unfolding exp_Euler cos_diff sin_diff sin_of_real cos_of_real + by (simp_all add: field_simps real_sqrt_divide sin_arctan cos_arctan) qed (use False arctan [of "Re z / Im z"] in auto) qed (use assms in auto) @@ -2131,9 +2145,7 @@ } then show "\d>0. \x. 0 \ Im x \ x \ z \ cmod (x - z) < d \ \Arg2pi x\ < e" apply (rule_tac x="min d (Re z / 2)" in exI) - using z d - apply (auto simp: Arg2pi_eq_Im_Ln) - done + using z d by (auto simp: Arg2pi_eq_Im_Ln) qed qed @@ -2185,8 +2197,7 @@ by (simp add: exp_of_nat_mult powr_def) lemma norm_powr_real: "w \ \ \ 0 < Re w \ norm(w powr z) = exp(Re z * ln(Re w))" - apply (simp add: powr_def) - using Im_Ln_eq_0 complex_is_Real_iff norm_complex_def by auto + using Ln_Reals_eq norm_exp_eq_Re by (auto simp: Im_Ln_eq_0 powr_def norm_complex_def) lemma powr_complexpow [simp]: fixes x::complex shows "x \ 0 \ x powr (of_nat n) = x^n" @@ -2249,7 +2260,7 @@ by (auto simp: nonneg_Reals_def Reals_def powr_of_real) lemma powr_neg_real_complex: - shows "(- of_real x) powr a = (-1) powr (of_real (sgn x) * a) * of_real x powr (a :: complex)" + "(- of_real x) powr a = (-1) powr (of_real (sgn x) * a) * of_real x powr (a :: complex)" proof (cases "x = 0") assume x: "x \ 0" hence "(-x) powr a = exp (a * ln (-of_real x))" by (simp add: powr_def) @@ -2267,13 +2278,14 @@ shows "((\z. z powr s) has_field_derivative (s * z powr (s - 1))) (at z)" proof (cases "z=0") case False + then have \
: "exp (s * Ln z) * inverse z = exp ((s - 1) * Ln z)" + by (simp add: divide_complex_def exp_diff left_diff_distrib') show ?thesis unfolding powr_def proof (rule has_field_derivative_transform_within) show "((\z. exp (s * Ln z)) has_field_derivative s * (if z = 0 then 0 else exp ((s - 1) * Ln z))) (at z)" - apply (intro derivative_eq_intros | simp add: assms)+ - by (simp add: False divide_complex_def exp_diff left_diff_distrib') + by (intro derivative_eq_intros | simp add: assms False \
)+ qed (use False in auto) qed (use assms in auto) @@ -2281,11 +2293,11 @@ lemma has_field_derivative_powr_of_int: fixes z :: complex - assumes gderiv:"(g has_field_derivative gd) (at z within s)" and "g z\0" - shows "((\z. g z powr of_int n) has_field_derivative (n * g z powr (of_int n - 1) * gd)) (at z within s)" + assumes gderiv:"(g has_field_derivative gd) (at z within S)" and "g z\0" + shows "((\z. g z powr of_int n) has_field_derivative (n * g z powr (of_int n - 1) * gd)) (at z within S)" proof - define dd where "dd = of_int n * g z powr (of_int (n - 1)) * gd" - obtain e where "e>0" and e_dist:"\y\s. dist z y < e \ g y \ 0" + obtain e where "e>0" and e_dist:"\y\S. dist z y < e \ g y \ 0" using DERIV_continuous[OF gderiv,THEN continuous_within_avoid] \g z\0\ by auto have ?thesis when "n\0" proof - @@ -2298,19 +2310,19 @@ using powr_of_int[OF \g z\0\,of "n-1"] by (simp add: nat_diff_distrib') then show ?thesis unfolding dd_def dd'_def by simp qed (simp add:dd_def dd'_def) - then have "((\z. g z powr of_int n) has_field_derivative dd) (at z within s) - \ ((\z. g z powr of_int n) has_field_derivative dd') (at z within s)" + then have "((\z. g z powr of_int n) has_field_derivative dd) (at z within S) + \ ((\z. g z powr of_int n) has_field_derivative dd') (at z within S)" by simp - also have "... \ ((\z. g z ^ nat n) has_field_derivative dd') (at z within s)" + also have "... \ ((\z. g z ^ nat n) has_field_derivative dd') (at z within S)" proof (rule has_field_derivative_cong_eventually) - show "\\<^sub>F x in at z within s. g x powr of_int n = g x ^ nat n" + show "\\<^sub>F x in at z within S. g x powr of_int n = g x ^ nat n" unfolding eventually_at apply (rule exI[where x=e]) using powr_of_int that \e>0\ e_dist by (simp add: dist_commute) qed (use powr_of_int \g z\0\ that in simp) also have "..." unfolding dd'_def using gderiv that by (auto intro!: derivative_eq_intros) - finally have "((\z. g z powr of_int n) has_field_derivative dd) (at z within s)" . + finally have "((\z. g z powr of_int n) has_field_derivative dd) (at z within S)" . then show ?thesis unfolding dd_def by simp qed moreover have ?thesis when "n<0" @@ -2323,12 +2335,12 @@ then show ?thesis unfolding dd_def dd'_def by (simp add: divide_inverse) qed - then have "((\z. g z powr of_int n) has_field_derivative dd) (at z within s) - \ ((\z. g z powr of_int n) has_field_derivative dd') (at z within s)" + then have "((\z. g z powr of_int n) has_field_derivative dd) (at z within S) + \ ((\z. g z powr of_int n) has_field_derivative dd') (at z within S)" by simp - also have "... \ ((\z. inverse (g z ^ nat (-n))) has_field_derivative dd') (at z within s)" + also have "... \ ((\z. inverse (g z ^ nat (-n))) has_field_derivative dd') (at z within S)" proof (rule has_field_derivative_cong_eventually) - show "\\<^sub>F x in at z within s. g x powr of_int n = inverse (g x ^ nat (- n))" + show "\\<^sub>F x in at z within S. g x powr of_int n = inverse (g x ^ nat (- n))" unfolding eventually_at apply (rule exI[where x=e]) using powr_of_int that \e>0\ e_dist by (simp add: dist_commute) @@ -2341,7 +2353,7 @@ unfolding dd'_def using gderiv that \g z\0\ by (auto intro!: derivative_eq_intros simp add:field_split_simps power_add[symmetric]) qed - finally have "((\z. g z powr of_int n) has_field_derivative dd) (at z within s)" . + finally have "((\z. g z powr of_int n) has_field_derivative dd) (at z within S)" . then show ?thesis unfolding dd_def by simp qed ultimately show ?thesis by force @@ -2349,27 +2361,25 @@ lemma field_differentiable_powr_of_int: fixes z :: complex - assumes gderiv:"g field_differentiable (at z within s)" and "g z\0" - shows "(\z. g z powr of_int n) field_differentiable (at z within s)" + assumes gderiv: "g field_differentiable (at z within S)" and "g z \ 0" + shows "(\z. g z powr of_int n) field_differentiable (at z within S)" using has_field_derivative_powr_of_int assms(2) field_differentiable_def gderiv by blast lemma holomorphic_on_powr_of_int [holomorphic_intros]: - assumes "f holomorphic_on s" "\z\s. f z\0" - shows "(\z. (f z) powr of_int n) holomorphic_on s" + assumes holf: "f holomorphic_on S" and 0: "\z. z\S \ f z \ 0" + shows "(\z. (f z) powr of_int n) holomorphic_on S" proof (cases "n\0") case True - then have "?thesis \ (\z. (f z) ^ nat n) holomorphic_on s" - apply (rule_tac holomorphic_cong) - using assms(2) by (auto simp add:powr_of_int) - moreover have "(\z. (f z) ^ nat n) holomorphic_on s" - using assms(1) by (auto intro:holomorphic_intros) + then have "?thesis \ (\z. (f z) ^ nat n) holomorphic_on S" + by (metis (no_types, lifting) 0 holomorphic_cong powr_of_int) + moreover have "(\z. (f z) ^ nat n) holomorphic_on S" + using holf by (auto intro: holomorphic_intros) ultimately show ?thesis by auto next case False - then have "?thesis \ (\z. inverse (f z) ^ nat (-n)) holomorphic_on s" - apply (rule_tac holomorphic_cong) - using assms(2) by (auto simp add:powr_of_int power_inverse) - moreover have "(\z. inverse (f z) ^ nat (-n)) holomorphic_on s" + then have "?thesis \ (\z. inverse (f z) ^ nat (-n)) holomorphic_on S" + by (metis (no_types, lifting) "0" holomorphic_cong power_inverse powr_of_int) + moreover have "(\z. inverse (f z) ^ nat (-n)) holomorphic_on S" using assms by (auto intro!:holomorphic_intros) ultimately show ?thesis by auto qed @@ -2580,10 +2590,12 @@ then obtain xo where "xo > 0" and xo: "\x. x \ xo \ x < e * exp (Re s * x)" using e by (auto simp: field_simps) have "norm (Ln (of_nat n) / of_nat n powr s) < e" if "n \ nat \exp xo\" for n - using e xo [of "ln n"] that - apply (auto simp: norm_divide norm_powr_real field_split_simps) - apply (metis exp_less_mono exp_ln not_le of_nat_0_less_iff) - done + proof - + have "ln (real n) \ xo" + using that exp_gt_zero ln_ge_iff [of n] nat_ceiling_le_eq by fastforce + then show ?thesis + using e xo [of "ln n"] by (auto simp: norm_divide norm_powr_real field_split_simps) + qed then show "\no. \n\no. norm (Ln (of_nat n) / of_nat n powr s) < e" by blast qed @@ -2594,17 +2606,17 @@ lemma lim_ln_over_power: fixes s :: real assumes "0 < s" - shows "((\n. ln n / (n powr s)) \ 0) sequentially" - using lim_Ln_over_power [of "of_real s", THEN filterlim_sequentially_Suc [THEN iffD2]] assms - apply (subst filterlim_sequentially_Suc [symmetric]) - apply (simp add: lim_sequentially dist_norm Ln_Reals_eq norm_powr_real_powr norm_divide) - done + shows "((\n. ln n / (n powr s)) \ 0) sequentially" +proof - + have "(\n. ln (Suc n) / (Suc n) powr s) \ 0" + using lim_Ln_over_power [of "of_real s", THEN filterlim_sequentially_Suc [THEN iffD2]] assms + by (simp add: lim_sequentially dist_norm Ln_Reals_eq norm_powr_real_powr norm_divide) + then show ?thesis + using filterlim_sequentially_Suc[of "\n::nat. ln n / n powr s"] by auto +qed lemma lim_ln_over_n [tendsto_intros]: "((\n. ln(real_of_nat n) / of_nat n) \ 0) sequentially" - using lim_ln_over_power [of 1, THEN filterlim_sequentially_Suc [THEN iffD2]] - apply (subst filterlim_sequentially_Suc [symmetric]) - apply (simp add: lim_sequentially dist_norm) - done + using lim_ln_over_power [of 1] by auto lemma lim_log_over_n [tendsto_intros]: "(\n. log k n/n) \ 0" @@ -2633,12 +2645,10 @@ lemma lim_1_over_real_power: fixes s :: real assumes "0 < s" - shows "((\n. 1 / (of_nat n powr s)) \ 0) sequentially" + shows "((\n. 1 / (of_nat n powr s)) \ 0) sequentially" using lim_1_over_complex_power [of "of_real s", THEN filterlim_sequentially_Suc [THEN iffD2]] assms apply (subst filterlim_sequentially_Suc [symmetric]) - apply (simp add: lim_sequentially dist_norm) - apply (simp add: Ln_Reals_eq norm_powr_real_powr norm_divide) - done + by (simp add: lim_sequentially dist_norm Ln_Reals_eq norm_powr_real_powr norm_divide) lemma lim_1_over_Ln: "((\n. 1 / Ln(of_nat n)) \ 0) sequentially" proof (clarsimp simp add: lim_sequentially dist_norm norm_divide field_split_simps) @@ -2665,9 +2675,7 @@ lemma lim_1_over_ln: "((\n. 1 / ln(real_of_nat n)) \ 0) sequentially" using lim_1_over_Ln [THEN filterlim_sequentially_Suc [THEN iffD2]] apply (subst filterlim_sequentially_Suc [symmetric]) - apply (simp add: lim_sequentially dist_norm) - apply (simp add: Ln_Reals_eq norm_powr_real_powr norm_divide) - done + by (simp add: lim_sequentially dist_norm Ln_Reals_eq norm_powr_real_powr norm_divide) lemma lim_ln1_over_ln: "(\n. ln(Suc n) / ln n) \ 1" proof (rule Lim_transform_eventually) @@ -2719,10 +2727,9 @@ finally have "csqrt z = csqrt ((exp (Ln z / 2))\<^sup>2)" by simp also have "... = exp (Ln z / 2)" - apply (subst csqrt_square) + apply (rule csqrt_square) using cos_gt_zero_pi [of "(Im (Ln z) / 2)"] Im_Ln_le_pi mpi_less_Im_Ln assms - apply (auto simp: Re_exp Im_exp zero_less_mult_iff zero_le_mult_iff, fastforce+) - done + by (fastforce simp: Re_exp Im_exp ) finally show ?thesis using assms csqrt_square by simp qed @@ -2804,19 +2811,24 @@ "continuous (at z within (\ \ {w. 0 \ Re(w)})) csqrt" proof (cases "z \ \\<^sub>\\<^sub>0") case True - have *: "\e. \0 < e\ - \ \x'\\ \ {w. 0 \ Re w}. cmod x' < e^2 \ cmod (csqrt x') < e" - by (auto simp: Reals_def real_less_lsqrt) - have "Im z = 0" "Re z < 0 \ z = 0" + have [simp]: "Im z = 0" and 0: "Re z < 0 \ z = 0" using True cnj.code complex_cnj_zero_iff by (auto simp: Complex_eq complex_nonpos_Reals_iff) fastforce - with * show ?thesis - apply (auto simp: continuous_within_closed_nontrivial [OF closed_Real_halfspace_Re_ge]) - apply (auto simp: continuous_within_eps_delta) - using zero_less_power by blast -next - case False - then show ?thesis by (blast intro: continuous_within_csqrt) -qed + show ?thesis + using 0 + proof + assume "Re z < 0" + then show ?thesis + by (auto simp: continuous_within_closed_nontrivial [OF closed_Real_halfspace_Re_ge]) + next + assume "z = 0" + moreover + have "\e. 0 < e + \ \x'\\ \ {w. 0 \ Re w}. cmod x' < e^2 \ cmod (csqrt x') < e" + by (auto simp: Reals_def real_less_lsqrt) + ultimately show ?thesis + using zero_less_power by (fastforce simp: continuous_within_eps_delta) + qed +qed (blast intro: continuous_within_csqrt) subsection\Complex arctangent\ @@ -2870,32 +2882,32 @@ assumes "\Re z\ < pi/2" shows "Arctan(tan z) = z" proof - - have ge_pi2: "\n::int. \of_int (2*n + 1) * pi/2\ \ pi/2" - by (case_tac n rule: int_cases) (auto simp: abs_mult) - have "exp (\*z)*exp (\*z) = -1 \ exp (2*\*z) = -1" - by (metis distrib_right exp_add mult_2) - also have "... \ exp (2*\*z) = exp (\*pi)" - using cis_conv_exp cis_pi by auto - also have "... \ exp (2*\*z - \*pi) = 1" - by (metis (no_types) diff_add_cancel diff_minus_eq_add exp_add exp_minus_inverse mult.commute) - also have "... \ Re(\*2*z - \*pi) = 0 \ (\n::int. Im(\*2*z - \*pi) = of_int (2 * n) * pi)" - by (simp add: exp_eq_1) - also have "... \ Im z = 0 \ (\n::int. 2 * Re z = of_int (2*n + 1) * pi)" - by (simp add: algebra_simps) - also have "... \ False" - using assms ge_pi2 - apply (auto simp: algebra_simps) - by (metis abs_mult_pos not_less of_nat_less_0_iff of_nat_numeral) - finally have *: "exp (\*z)*exp (\*z) + 1 \ 0" - by (auto simp: add.commute minus_unique) - show ?thesis - using assms * - apply (simp add: Arctan_def tan_def sin_exp_eq cos_exp_eq exp_minus divide_simps - i_times_eq_iff power2_eq_square [symmetric]) - apply (rule Ln_unique) - apply (auto simp: divide_simps exp_minus) - apply (simp add: algebra_simps exp_double [symmetric]) - done + have "Ln ((1 - \ * tan z) / (1 + \ * tan z)) = 2 * z / \" + proof (rule Ln_unique) + have ge_pi2: "\n::int. \of_int (2*n + 1) * pi/2\ \ pi/2" + by (case_tac n rule: int_cases) (auto simp: abs_mult) + have "exp (\*z)*exp (\*z) = -1 \ exp (2*\*z) = -1" + by (metis distrib_right exp_add mult_2) + also have "... \ exp (2*\*z) = exp (\*pi)" + using cis_conv_exp cis_pi by auto + also have "... \ exp (2*\*z - \*pi) = 1" + by (metis (no_types) diff_add_cancel diff_minus_eq_add exp_add exp_minus_inverse mult.commute) + also have "... \ Re(\*2*z - \*pi) = 0 \ (\n::int. Im(\*2*z - \*pi) = of_int (2 * n) * pi)" + by (simp add: exp_eq_1) + also have "... \ Im z = 0 \ (\n::int. 2 * Re z = of_int (2*n + 1) * pi)" + by (simp add: algebra_simps) + also have "... \ False" + using assms ge_pi2 + apply (auto simp: algebra_simps) + by (metis abs_mult_pos not_less of_nat_less_0_iff of_nat_numeral) + finally have "exp (\*z)*exp (\*z) + 1 \ 0" + by (auto simp: add.commute minus_unique) + then show "exp (2 * z / \) = (1 - \ * tan z) / (1 + \ * tan z)" + apply (simp add: tan_def sin_exp_eq cos_exp_eq exp_minus divide_simps) + by (simp add: algebra_simps flip: power2_eq_square exp_double) + qed (use assms in auto) + then show ?thesis + by (auto simp: Arctan_def) qed lemma @@ -2930,12 +2942,11 @@ show "\Re(Arctan z)\ < pi/2" unfolding Arctan_def divide_complex_def using mpi_less_Im_Ln [OF nzi] - apply (auto simp: abs_if intro!: Im_Ln_less_pi * [unfolded divide_complex_def]) - done + by (auto simp: abs_if intro!: Im_Ln_less_pi * [unfolded divide_complex_def]) show "(Arctan has_field_derivative inverse(1 + z\<^sup>2)) (at z)" unfolding Arctan_def scaleR_conv_of_real apply (intro derivative_eq_intros | simp add: nz0 *)+ - using nz0 nz1 zz + using nz1 zz apply (simp add: field_split_simps power2_eq_square) apply algebra done @@ -3077,10 +3088,12 @@ proof - have ne: "1 + x\<^sup>2 \ 0" by (metis power_one sum_power2_eq_zero_iff zero_neq_one) + have ne1: "1 + \ * complex_of_real x \ 0" + using Complex_eq complex_eq_cancel_iff2 by fastforce have "Re (Ln ((1 - \ * x) * inverse (1 + \ * x))) = 0" apply (rule norm_exp_imaginary) - apply (subst exp_Ln) - using ne apply (simp_all add: cmod_def complex_eq_iff) + using ne + apply (simp add: ne1 cmod_def) apply (auto simp: field_split_simps) apply algebra done @@ -3090,11 +3103,10 @@ lemma arctan_eq_Re_Arctan: "arctan x = Re (Arctan (of_real x))" proof (rule arctan_unique) - show "- (pi / 2) < Re (Arctan (complex_of_real x))" - apply (simp add: Arctan_def) - apply (rule Im_Ln_less_pi) - apply (auto simp: Im_complex_div_lemma complex_nonpos_Reals_iff) - done + have "(1 - \ * x) / (1 + \ * x) \ \\<^sub>\\<^sub>0" + by (auto simp: Im_complex_div_lemma complex_nonpos_Reals_iff) + then show "- (pi / 2) < Re (Arctan (complex_of_real x))" + by (simp add: Arctan_def Im_Ln_less_pi) next have *: " (1 - \*x) / (1 + \*x) \ 0" by (simp add: field_split_simps) ( simp add: complex_eq_iff) @@ -3103,12 +3115,14 @@ by (simp add: Arctan_def) next have "tan (Re (Arctan (of_real x))) = Re (tan (Arctan (of_real x)))" - apply (auto simp: tan_def Complex.Re_divide Re_sin Re_cos Im_sin Im_cos) - apply (simp add: field_simps) - by (simp add: power2_eq_square) + by (auto simp: tan_def Complex.Re_divide Re_sin Re_cos Im_sin Im_cos field_simps power2_eq_square) also have "... = x" - apply (subst tan_Arctan, auto) - by (metis diff_0_right minus_diff_eq mult_zero_left not_le of_real_1 of_real_eq_iff of_real_minus of_real_power power2_eq_square real_minus_mult_self_le zero_less_one) + proof - + have "(complex_of_real x)\<^sup>2 \ - 1" + by (metis diff_0_right minus_diff_eq mult_zero_left not_le of_real_1 of_real_eq_iff of_real_minus of_real_power power2_eq_square real_minus_mult_self_le zero_less_one) + then show ?thesis + by simp + qed finally show "tan (Re (Arctan (complex_of_real x))) = x" . qed @@ -3169,18 +3183,14 @@ assumes "\x * y\ < 1" shows "(arctan x + arctan y = arctan((x + y) / (1 - x * y)))" proof (cases "x = 0 \ y = 0") - case True then show ?thesis - by auto -next case False - then have *: "\arctan x\ < pi / 2 - \arctan y\" using assms - apply (auto simp add: abs_arctan arctan_inverse [symmetric] arctan_less_iff) - apply (simp add: field_split_simps abs_mult) - done - show ?thesis - apply (rule arctan_add_raw) - using * by linarith -qed + with assms have "\x\ < inverse \y\" + by (simp add: field_split_simps abs_mult) + with False have "\arctan x\ < pi / 2 - \arctan y\" using assms + by (auto simp add: abs_arctan arctan_inverse [symmetric] arctan_less_iff) + then show ?thesis + by (intro arctan_add_raw) linarith +qed auto lemma abs_arctan_le: fixes x::real shows "\arctan x\ \ \x\" @@ -3190,9 +3200,8 @@ have "cmod (Arctan w - Arctan z) \ 1 * cmod (w-z)" if "w \ \" "z \ \" for w z apply (rule field_differentiable_bound [OF convex_Reals, of Arctan _ 1]) apply (rule has_field_derivative_at_within [OF has_field_derivative_Arctan]) - using 1 that apply (auto simp: Reals_def) - done - then have "cmod (Arctan (of_real x) - Arctan 0) \ 1 * cmod (of_real x -0)" + using 1 that by (auto simp: Reals_def) + then have "cmod (Arctan (of_real x) - Arctan 0) \ 1 * cmod (of_real x - 0)" using Reals_0 Reals_of_real by blast then show ?thesis by (simp add: Arctan_of_real) @@ -3254,8 +3263,7 @@ lemma Arcsin_body_lemma: "\ * z + csqrt(1 - z\<^sup>2) \ 0" using power2_csqrt [of "1 - z\<^sup>2"] - apply auto - by (metis complex_i_mult_minus diff_add_cancel diff_minus_eq_add diff_self mult.assoc mult.left_commute numeral_One power2_csqrt power2_eq_square zero_neq_numeral) + by (metis add.inverse_inverse complex_i_mult_minus diff_0 diff_add_cancel diff_minus_eq_add mult.assoc mult.commute numeral_One power2_eq_square zero_neq_numeral) lemma Arcsin_range_lemma: "\Re z\ < 1 \ 0 < Re(\ * z + csqrt(1 - z\<^sup>2))" using Complex.cmod_power2 [of z, symmetric] @@ -3268,12 +3276,19 @@ by (simp add: Arcsin_def Arcsin_body_lemma) lemma one_minus_z2_notin_nonpos_Reals: - assumes "(Im z = 0 \ \Re z\ < 1)" + assumes "Im z = 0 \ \Re z\ < 1" shows "1 - z\<^sup>2 \ \\<^sub>\\<^sub>0" - using assms - apply (auto simp: complex_nonpos_Reals_iff Re_power2 Im_power2) - using power2_less_0 [of "Im z"] apply force - using abs_square_less_1 not_le by blast +proof (cases "Im z = 0") + case True + with assms show ?thesis + by (simp add: complex_nonpos_Reals_iff flip: abs_square_less_1) +next + case False + have "\ (Im z)\<^sup>2 \ - 1" + using False power2_less_eq_zero_iff by fastforce + with False show ?thesis + by (auto simp add: complex_nonpos_Reals_iff Re_power2 Im_power2) +qed lemma isCont_Arcsin_lemma: assumes le0: "Re (\ * z + csqrt (1 - z\<^sup>2)) \ 0" and "(Im z = 0 \ \Re z\ < 1)" @@ -3356,9 +3371,7 @@ by (simp add: field_simps power2_eq_square) also have "... = - (\ * Ln (((exp (\*z) + inverse (exp (\*z)))/2) - (inverse (exp (\*z)) - exp (\*z)) / 2))" apply (subst csqrt_square) - using assms Re_eq_pihalf_lemma Re_less_pihalf_lemma - apply auto - done + using assms Re_eq_pihalf_lemma Re_less_pihalf_lemma by auto also have "... = - (\ * Ln (exp (\*z)))" by (simp add: field_simps power2_eq_square) also have "... = z" @@ -3453,11 +3466,8 @@ then show False using False by (simp add: power2_eq_square algebra_simps) qed - moreover have "(Im z)\<^sup>2 = ((1 + ((Im z)\<^sup>2 + cmod (1 - z\<^sup>2)) - (Re z)\<^sup>2) / 2)" - apply (subst Imz) - using abs_Re_le_cmod [of "1-z\<^sup>2"] - apply (simp add: Re_power2) - done + moreover have "(Im z)\<^sup>2 = (1 + ((Im z)\<^sup>2 + cmod (1 - z\<^sup>2)) - (Re z)\<^sup>2) / 2" + using abs_Re_le_cmod [of "1-z\<^sup>2"] by (subst Imz) (simp add: Re_power2) ultimately show False by (simp add: cmod_power2) qed @@ -3469,14 +3479,12 @@ have "z + \ * csqrt (1 - z\<^sup>2) \ \\<^sub>\\<^sub>0" by (metis complex_nonpos_Reals_iff isCont_Arccos_lemma assms) with assms show ?thesis - apply (simp add: Arccos_def) - apply (rule isCont_Ln' isCont_csqrt' continuous_intros)+ - apply (simp_all add: one_minus_z2_notin_nonpos_Reals assms) - done + unfolding Arccos_def + by (simp_all add: one_minus_z2_notin_nonpos_Reals assms) qed lemma isCont_Arccos' [simp]: - shows "isCont f z \ (Im (f z) = 0 \ \Re (f z)\ < 1) \ isCont (\x. Arccos (f x)) z" + "isCont f z \ (Im (f z) = 0 \ \Re (f z)\ < 1) \ isCont (\x. Arccos (f x)) z" by (blast intro: isCont_o2 [OF _ isCont_Arccos]) lemma cos_Arccos [simp]: "cos(Arccos z) = z" @@ -3486,15 +3494,13 @@ moreover have "... \ z + \ * csqrt (1 - z\<^sup>2) = 0" by (metis distrib_right mult_eq_0_iff zero_neq_numeral) ultimately show ?thesis - apply (simp add: cos_exp_eq Arccos_def Arccos_body_lemma exp_minus field_simps) - apply (simp add: power2_eq_square [symmetric]) - done + by (simp add: cos_exp_eq Arccos_def Arccos_body_lemma exp_minus field_simps flip: power2_eq_square) qed lemma Arccos_cos: - assumes "0 < Re z & Re z < pi \ - Re z = 0 & 0 \ Im z \ - Re z = pi & Im z \ 0" + assumes "0 < Re z \ Re z < pi \ + Re z = 0 \ 0 \ Im z \ + Re z = pi \ Im z \ 0" shows "Arccos(cos z) = z" proof - have *: "((\ - (exp (\ * z))\<^sup>2 * \) / (2 * exp (\ * z))) = sin z" @@ -3508,14 +3514,12 @@ \ * ((\ - (exp (\ * z))\<^sup>2 * \) / (2 * exp (\ * z)))))" apply (subst csqrt_square) using assms Re_sin_pos [of z] Im_sin_nonneg [of z] Im_sin_nonneg2 [of z] - apply (auto simp: * Re_sin Im_sin) - done + by (auto simp: * Re_sin Im_sin) also have "... = - (\ * Ln (exp (\*z)))" by (simp add: field_simps power2_eq_square) also have "... = z" using assms - apply (subst Complex_Transcendental.Ln_exp, auto) - done + by (subst Complex_Transcendental.Ln_exp, auto) finally show ?thesis . qed @@ -3596,9 +3600,7 @@ proof - have "(Im (Arccos w))\<^sup>2 \ (cmod (cos (Arccos w)))\<^sup>2 - (cos (Re (Arccos w)))\<^sup>2" using norm_cos_squared [of "Arccos w"] real_le_abs_sinh [of "Im (Arccos w)"] - apply (simp only: abs_le_square_iff) - apply (simp add: field_split_simps) - done + by (simp only: abs_le_square_iff) (simp add: field_split_simps) also have "... \ (cmod w)\<^sup>2" by (auto simp: cmod_power2) finally show ?thesis @@ -3651,7 +3653,7 @@ by (metis mult_cancel_left zero_neq_numeral) then have "(\ * z + csqrt (1 - z\<^sup>2))\<^sup>2 \ -1" using assms - apply (auto simp: power2_sum) + apply (simp add: power2_sum) apply (simp add: power2_eq_square algebra_simps) done then show ?thesis @@ -3685,9 +3687,7 @@ by (metis mult_cancel_left2 zero_neq_numeral) (*FIXME cancel_numeral_factor*) then have "(z + \ * csqrt (1 - z\<^sup>2))\<^sup>2 \ 1" using assms - apply (auto simp: Power.comm_semiring_1_class.power2_sum power_mult_distrib) - apply (simp add: power2_eq_square algebra_simps) - done + by (metis Arccos_def add.commute add.left_neutral cancel_comm_monoid_add_class.diff_cancel cos_Arccos csqrt_0 mult_zero_right) then show ?thesis apply (simp add: sin_exp_eq Arccos_def exp_minus) apply (simp add: divide_simps Arccos_body_lemma) @@ -3698,20 +3698,18 @@ lemma cos_sin_csqrt: assumes "0 < cos(Re z) \ cos(Re z) = 0 \ Im z * sin(Re z) \ 0" shows "cos z = csqrt(1 - (sin z)\<^sup>2)" - apply (rule csqrt_unique [THEN sym]) - apply (simp add: cos_squared_eq) - using assms - apply (auto simp: Re_cos Im_cos add_pos_pos mult_le_0_iff zero_le_mult_iff) - done +proof (rule csqrt_unique [THEN sym]) + show "(cos z)\<^sup>2 = 1 - (sin z)\<^sup>2" + by (simp add: cos_squared_eq) +qed (use assms in \auto simp: Re_cos Im_cos add_pos_pos mult_le_0_iff zero_le_mult_iff\) lemma sin_cos_csqrt: assumes "0 < sin(Re z) \ sin(Re z) = 0 \ 0 \ Im z * cos(Re z)" shows "sin z = csqrt(1 - (cos z)\<^sup>2)" - apply (rule csqrt_unique [THEN sym]) - apply (simp add: sin_squared_eq) - using assms - apply (auto simp: Re_sin Im_sin add_pos_pos mult_le_0_iff zero_le_mult_iff) - done +proof (rule csqrt_unique [THEN sym]) + show "(sin z)\<^sup>2 = 1 - (cos z)\<^sup>2" + by (simp add: sin_squared_eq) +qed (use assms in \auto simp: Re_sin Im_sin add_pos_pos mult_le_0_iff zero_le_mult_iff\) lemma Arcsin_Arccos_csqrt_pos: "(0 < Re z | Re z = 0 & 0 \ Im z) \ Arcsin z = Arccos(csqrt(1 - z\<^sup>2))" @@ -3770,10 +3768,8 @@ fix x' assume "- (pi / 2) \ x'" "x' \ pi / 2" "x = sin x'" then show "x' = Re (Arcsin (complex_of_real (sin x')))" - apply (simp add: sin_of_real [symmetric]) - apply (subst Arcsin_sin) - apply (auto simp: ) - done + unfolding sin_of_real [symmetric] + by (subst Arcsin_sin) auto qed lemma of_real_arcsin: "\x\ \ 1 \ of_real(arcsin x) = Arcsin(of_real x)" @@ -3820,10 +3816,8 @@ fix x' assume "0 \ x'" "x' \ pi" "x = cos x'" then show "x' = Re (Arccos (complex_of_real (cos x')))" - apply (simp add: cos_of_real [symmetric]) - apply (subst Arccos_cos) - apply (auto simp: ) - done + unfolding cos_of_real [symmetric] + by (subst Arccos_cos) auto qed lemma of_real_arccos: "\x\ \ 1 \ of_real(arccos x) = Arccos(of_real x)" @@ -3861,8 +3855,7 @@ have "arcsin x = pi/2 - arccos x" apply (rule sin_inj_pi) using assms arcsin [OF assms] arccos [OF assms] - apply (auto simp: algebra_simps sin_diff) - done + by (auto simp: algebra_simps sin_diff) then show ?thesis by (simp add: algebra_simps) qed @@ -3975,7 +3968,7 @@ then show ?thesis apply (simp add: exp_of_nat_mult [symmetric] mult_ac exp_Euler) apply (simp only: * cos_of_real sin_of_real) - apply (simp add: ) + apply simp done qed @@ -3993,10 +3986,7 @@ also have "... \ (\z::int. of_nat j = of_nat k + of_nat n * (of_int z :: complex))" by simp also have "... \ (\z::int. of_nat j = of_nat k + of_nat n * z)" - apply (rule HOL.iff_exI) - apply (auto simp: ) - using of_int_eq_iff apply fastforce - by (metis of_int_add of_int_mult of_int_of_nat_eq) + by (metis (mono_tags, hide_lams) of_int_add of_int_eq_iff of_int_mult of_int_of_nat_eq) also have "... \ int j mod int n = int k mod int n" by (auto simp: mod_eq_dvd_iff dvd_def algebra_simps) also have "... \ j mod n = k mod n" @@ -4038,7 +4028,7 @@ lemma complex_roots_unity: assumes "1 \ n" - shows "{z::complex. z^n = 1} = {exp(2 * of_real pi * \ * of_nat j / of_nat n) | j::nat. j < n}" + shows "{z::complex. z^n = 1} = {exp(2 * of_real pi * \ * of_nat j / of_nat n) | j. j < n}" apply (rule Finite_Set.card_seteq [symmetric]) using assms apply (auto simp: card_complex_roots_unity_explicit finite_roots_unity complex_root_unity card_roots_unity) @@ -4053,6 +4043,4 @@ apply (auto simp: Re_complex_div_eq_0 exp_of_nat_mult [symmetric] mult_ac exp_Euler) done - - end