# HG changeset patch # User paulson # Date 1663091808 -3600 # Node ID 19837257fd895a68be454b56b3041451f70cd890 # Parent 1bb677cceea44b0b09dd0f8ee20b6bab69d129d4# Parent 3190ee65139ba718a0bb09b1890a80ae079b50fb merged diff -r 1bb677cceea4 -r 19837257fd89 src/HOL/Analysis/Complex_Transcendental.thy --- a/src/HOL/Analysis/Complex_Transcendental.thy Tue Sep 13 11:56:38 2022 +0200 +++ b/src/HOL/Analysis/Complex_Transcendental.thy Tue Sep 13 18:56:48 2022 +0100 @@ -103,7 +103,7 @@ show "(cos_coeff n + \ * sin_coeff n) * z^n = (\ * z) ^ n /\<^sub>R (fact n)" by (auto simp: cos_coeff_def sin_coeff_def scaleR_conv_of_real field_simps elim!: evenE oddE) qed - also have "... sums (exp (\ * z))" + also have "\ sums (exp (\ * z))" by (rule exp_converges) finally have "(\n. (cos_coeff n + \ * sin_coeff n) * z^n) sums (exp (\ * z))" . moreover have "(\n. (cos_coeff n + \ * sin_coeff n) * z^n) sums (cos z + \ * sin z)" @@ -166,7 +166,7 @@ proof - have "(\n. cnj (z ^ n /\<^sub>R (fact n))) = (\n. (cnj z)^n /\<^sub>R (fact n))" by auto - also have "... sums (exp (cnj z))" + also have "\ sums (exp (cnj z))" by (rule exp_converges) finally have "(\n. cnj (z ^ n /\<^sub>R (fact n))) sums (exp (cnj z))" . moreover have "(\n. cnj (z ^ n /\<^sub>R (fact n))) sums (cnj (exp z))" @@ -234,9 +234,9 @@ proof - have "exp w = exp z \ exp (w-z) = 1" by (simp add: exp_diff) - also have "... \ (Re w = Re z \ (\n::int. Im w - Im z = of_int (2 * n) * pi))" + also have "\ \ (Re w = Re z \ (\n::int. Im w - Im z = of_int (2 * n) * pi))" by (simp add: exp_eq_1) - also have "... \ ?rhs" + also have "\ \ ?rhs" by (auto simp: algebra_simps intro!: complex_eqI) finally show ?thesis . qed @@ -250,7 +250,7 @@ proof - have "exp((2 * n * pi) * \) = exp 0" using assms unfolding Ints_def exp_eq by auto - also have "... = 1" + also have "\ = 1" by simp finally show ?thesis . qed @@ -266,7 +266,7 @@ by (auto simp: Ints_def) have "exp(((2 * n + 1) * pi) * \) = exp (pi * \)" using assms by (subst exp_eq) (auto intro!: exI[of _ n'] simp: algebra_simps) - also have "... = - 1" + also have "\ = - 1" by simp finally show ?thesis . qed @@ -363,17 +363,17 @@ qed qed -lemma sin_cos_eq_iff: "sin y = sin x \ cos y = cos x \ (\n::int. y = x + 2 * pi * n)" -proof - - { assume "sin y = sin x" "cos y = cos x" - then have "cos (y-x) = 1" - using cos_add [of y "-x"] by simp - then have "\n::int. y-x = 2 * pi * n" - using cos_one_2pi_int by auto } - then show ?thesis - apply (auto simp: sin_add cos_add) - apply (metis add.commute diff_add_cancel) - done +lemma sin_cos_eq_iff: "sin y = sin x \ cos y = cos x \ (\n::int. y = x + 2 * pi * n)" (is "?L=?R") +proof + assume ?L + then have "cos (y-x) = 1" + using cos_add [of y "-x"] by simp + then show ?R + by (metis cos_one_2pi_int add.commute diff_add_cancel mult.assoc mult.commute) +next + assume ?R + then show ?L + by (auto simp: sin_add cos_add) qed lemma exp_i_ne_1: @@ -400,17 +400,17 @@ lemma cos_eq_0: fixes z::complex - shows "cos z = 0 \ (\n::int. z = of_real(n * pi) + of_real pi/2)" + shows "cos z = 0 \ (\n::int. z = complex_of_real(n * pi) + of_real pi/2)" using sin_eq_0 [of "z - of_real pi/2"] by (simp add: sin_diff algebra_simps) lemma cos_eq_1: fixes z::complex - shows "cos z = 1 \ (\n::int. z = of_real(2 * n * pi))" + shows "cos z = 1 \ (\n::int. z = complex_of_real(2 * n * pi))" proof - have "cos z = cos (2*(z/2))" by simp - also have "... = 1 - 2 * sin (z/2) ^ 2" + also have "\ = 1 - 2 * sin (z/2) ^ 2" by (simp only: cos_double_sin) finally have [simp]: "cos z = 1 \ sin (z/2) = 0" by simp @@ -426,16 +426,16 @@ lemma csin_eq_minus1: fixes z::complex - shows "sin z = -1 \ (\n::int. z = of_real(2 * n * pi) + 3/2*pi)" + shows "sin z = -1 \ (\n::int. z = complex_of_real(2 * n * pi) + 3/2*pi)" (is "_ = ?rhs") proof - have "sin z = -1 \ sin (-z) = 1" by (simp add: equation_minus_iff) - also have "... \ (\n::int. -z = of_real(2 * n * pi) + of_real pi/2)" + 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)" + also have "\ \ (\n::int. z = - of_real(2 * n * pi) - of_real pi/2)" by (rule iff_exI) (metis add.inverse_inverse add_uminus_conv_diff minus_add_distrib) - also have "... = ?rhs" + also have "\ = ?rhs" apply safe apply (rule_tac [2] x="-(x+1)" in exI) apply (rule_tac x="-(x+1)" in exI) @@ -446,7 +446,7 @@ lemma ccos_eq_minus1: fixes z::complex - shows "cos z = -1 \ (\n::int. z = of_real(2 * n * pi) + pi)" + shows "cos z = -1 \ (\n::int. z = complex_of_real(2 * n * pi) + pi)" using csin_eq_1 [of "z - of_real pi/2"] by (simp add: sin_diff algebra_simps equation_minus_iff) @@ -455,11 +455,11 @@ proof - have "sin x = 1 \ sin (complex_of_real x) = 1" by (metis of_real_1 one_complex.simps(1) real_sin_eq sin_of_real) - also have "... \ (\n::int. complex_of_real x = of_real(2 * n * pi) + of_real pi/2)" + also have "\ \ (\n::int. complex_of_real x = of_real(2 * n * pi) + of_real pi/2)" by (simp only: csin_eq_1) - also have "... \ (\n::int. x = of_real(2 * n * pi) + of_real pi/2)" + also have "\ \ (\n::int. x = of_real(2 * n * pi) + of_real pi/2)" by (rule iff_exI) (auto simp: algebra_simps intro: injD [OF inj_of_real [where 'a = complex]]) - also have "... = ?rhs" + also have "\ = ?rhs" by (auto simp: algebra_simps) finally show ?thesis . qed @@ -468,11 +468,11 @@ proof - have "sin x = -1 \ sin (complex_of_real x) = -1" by (metis Re_complex_of_real of_real_def scaleR_minus1_left sin_of_real) - also have "... \ (\n::int. complex_of_real x = of_real(2 * n * pi) + 3/2*pi)" - by (simp only: csin_eq_minus1) - also have "... \ (\n::int. x = of_real(2 * n * pi) + 3/2*pi)" + also have "\ \ (\n::int. complex_of_real x = of_real(2 * n * pi) + 3/2*pi)" + by (simp add: csin_eq_minus1) + also have "\ \ (\n::int. x = of_real(2 * n * pi) + 3/2*pi)" by (rule iff_exI) (auto simp: algebra_simps intro: injD [OF inj_of_real [where 'a = complex]]) - also have "... = ?rhs" + also have "\ = ?rhs" by (auto simp: algebra_simps) finally show ?thesis . qed @@ -482,11 +482,11 @@ proof - have "cos x = -1 \ cos (complex_of_real x) = -1" by (metis Re_complex_of_real of_real_def scaleR_minus1_left cos_of_real) - also have "... \ (\n::int. complex_of_real x = of_real(2 * n * pi) + pi)" - by (simp only: ccos_eq_minus1) - also have "... \ (\n::int. x = of_real(2 * n * pi) + pi)" + also have "\ \ (\n::int. complex_of_real x = of_real(2 * n * pi) + pi)" + by (simp add: ccos_eq_minus1) + also have "\ \ (\n::int. x = of_real(2 * n * pi) + pi)" by (rule iff_exI) (auto simp: algebra_simps intro: injD [OF inj_of_real [where 'a = complex]]) - also have "... = ?rhs" + also have "\ = ?rhs" by (auto simp: algebra_simps) finally show ?thesis . qed @@ -697,9 +697,9 @@ by (simp add: norm_add_rule_thm) have "norm(1 + cos z) = cmod (1 + (exp (\ * z) + exp (- (\ * z))) / 2)" by (simp add: cos_exp_eq) - also have "... = cmod ((2 + exp (\ * z) + exp (- (\ * z))) / 2)" + also have "\ = cmod ((2 + exp (\ * z) + exp (- (\ * z))) / 2)" by (simp add: field_simps) - also have "... = cmod (2 + exp (\ * z) + exp (- (\ * z))) / 2" + also have "\ = cmod (2 + exp (\ * z) + exp (- (\ * z))) / 2" by (simp add: norm_divide) finally show ?thesis by (metis exp_eq_one_iff exp_le_cancel_iff mult_2 norm_cos_le norm_ge_zero norm_one norm_triangle_mono) @@ -801,16 +801,16 @@ 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) - also have "... \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" + also have "\ \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" by (intro divide_right_mono norm_triangle_ineq4) simp - also have "... \ exp \Im z\" + also have "\ \ exp \Im z\" by (rule *) finally show "cmod (sin (u *\<^sub>R z)) \ exp \Im z\" . have "cmod (cos (u *\<^sub>R z)) = cmod (exp (\ * (u * z)) + exp (- (\ * (u * z)))) / 2" by (auto simp: scaleR_conv_of_real norm_mult norm_power cos_exp_eq norm_divide) - also have "... \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" + also have "\ \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" by (intro divide_right_mono norm_triangle_ineq) simp - also have "... \ exp \Im z\" + also have "\ \ exp \Im z\" by (rule *) finally show "cmod (cos (u *\<^sub>R z)) \ exp \Im z\" . qed @@ -1019,9 +1019,9 @@ case False have "0 \ Im z \ 0 \ Im (of_real (cmod z) * exp (\ * complex_of_real (Arg2pi z)))" by (metis Arg2pi_eq) - also have "... = (0 \ Im (exp (\ * complex_of_real (Arg2pi z))))" + also have "\ = (0 \ Im (exp (\ * complex_of_real (Arg2pi z))))" using False by (simp add: zero_le_mult_iff) - also have "... \ Arg2pi z \ pi" + also have "\ \ Arg2pi z \ pi" by (simp add: Im_exp) (metis Arg2pi_ge_0 Arg2pi_lt_2pi sin_lt_zero sin_ge_zero not_le) finally show ?thesis by blast @@ -1032,9 +1032,9 @@ case False have "0 < Im z \ 0 < Im (of_real (cmod z) * exp (\ * complex_of_real (Arg2pi z)))" by (metis Arg2pi_eq) - also have "... = (0 < Im (exp (\ * complex_of_real (Arg2pi z))))" + 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" (is "_ = ?rhs") + 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) @@ -1050,9 +1050,9 @@ case False have "z \ \ \ 0 \ Re z \ z \ \ \ 0 \ Re (of_real (cmod z) * exp (\ * complex_of_real (Arg2pi z)))" by (metis Arg2pi_eq) - also have "... \ z \ \ \ 0 \ Re (exp (\ * complex_of_real (Arg2pi z)))" + also have "\ \ z \ \ \ 0 \ Re (exp (\ * complex_of_real (Arg2pi z)))" using False by (simp add: zero_le_mult_iff) - also have "... \ Arg2pi z = 0" + also have "\ \ Arg2pi z = 0" proof - have [simp]: "Arg2pi z = 0 \ z \ \" using Arg2pi_eq [of z] by (auto simp: Reals_def) @@ -1132,11 +1132,8 @@ lemma Arg2pi_add: assumes "w \ 0" "z \ 0" shows "Arg2pi w + Arg2pi z = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi(w * z) else Arg2pi(w * z) + 2*pi)" - using assms Arg2pi_diff [of "w*z" z] Arg2pi_le_div_sum_eq [of z "w*z"] - apply (auto simp: Arg2pi_ge_0 Arg2pi_divide not_le) - apply (metis Arg2pi_lt_2pi add.commute) - apply (metis (no_types) Arg2pi add.commute diff_0 diff_add_cancel diff_less_eq diff_minus_eq_add not_less) - done + using assms Arg2pi_diff [of "w*z" z] Arg2pi_le_div_sum_eq [of z "w*z"] Arg2pi [of "w * z"] + by auto lemma Arg2pi_times: assumes "w \ 0" "z \ 0" @@ -1239,7 +1236,7 @@ proof - have "ln(of_real (exp (ln z))::complex) = ln (exp (of_real (ln z)))" by (simp add: exp_of_real) - also have "... = of_real(ln z)" + also have "\ = of_real(ln z)" using assms by (subst Ln_exp) auto finally show ?thesis using assms by simp @@ -1449,7 +1446,7 @@ by (simp_all add: field_simps norm_divide del: of_real_add) have "Re (-z) \ norm (-z)" by (rule complex_Re_le_cmod) - also from z have "... < 1" by simp + also from z have "\ < 1" by simp finally have "((\z. ln (1 + z)) has_field_derivative inverse (1+z)) (at z)" by (auto intro!: derivative_eq_intros simp: complex_nonpos_Reals_iff) moreover have "(?F has_field_derivative ?F' z) (at z)" using t r @@ -1520,11 +1517,11 @@ apply (intro suminf_le summable_mult summable_geometric) apply (auto simp: norm_power field_simps simp del: of_nat_add of_nat_Suc) done - also have "... = norm z^2 * (\i. norm z^i)" using assms + also have "\ = norm z^2 * (\i. norm z^i)" using assms by (subst suminf_mult [symmetric]) (auto intro!: summable_geometric simp: norm_mult norm_power) also have "(\i. norm z^i) = inverse (1 - norm z)" using assms by (subst suminf_geometric) (simp_all add: divide_inverse) - also have "norm z^2 * ... = norm z^2 / (1 - norm z)" by (simp add: divide_inverse) + also have "norm z^2 * \ = norm z^2 / (1 - norm z)" by (simp add: divide_inverse) finally show ?thesis . qed @@ -1620,12 +1617,10 @@ text\A reference to the set of positive real numbers\ lemma Im_Ln_eq_0: "z \ 0 \ (Im(Ln z) = 0 \ 0 < Re(z) \ Im(z) = 0)" -by (metis Im_complex_of_real Im_exp Ln_in_Reals Re_Ln_pos_lt Re_Ln_pos_lt_imp - Re_complex_of_real complex_is_Real_iff exp_Ln exp_of_real pi_gt_zero) + using Im_Ln_pos_le Im_Ln_pos_lt Re_Ln_pos_lt by fastforce lemma Im_Ln_eq_pi: "z \ 0 \ (Im(Ln z) = pi \ Re(z) < 0 \ Im(z) = 0)" -by (metis Im_Ln_eq_0 Im_Ln_pos_le Im_Ln_pos_lt add.left_neutral complex_eq less_eq_real_def - mult_zero_right not_less_iff_gr_or_eq pi_ge_zero pi_neq_zero rcis_zero_arg rcis_zero_mod) + using Im_Ln_eq_0 Im_Ln_pos_le Im_Ln_pos_lt complex.expand by fastforce subsection\<^marker>\tag unimportant\\More Properties of Ln\ @@ -1637,7 +1632,7 @@ proof (rule exp_complex_eqI) have "\Im (cnj (Ln z)) - Im (Ln (cnj z))\ \ \Im (cnj (Ln z))\ + \Im (Ln (cnj z))\" by (rule abs_triangle_ineq4) - also have "... < pi + pi" + also have "\ < pi + pi" proof - have "\Im (cnj (Ln z))\ < pi" by (simp add: False Im_Ln_less_pi abs_if assms minus_less_iff mpi_less_Im_Ln) @@ -1661,7 +1656,7 @@ proof (rule exp_complex_eqI) have "\Im (Ln (inverse z)) - Im (- Ln z)\ \ \Im (Ln (inverse z))\ + \Im (- Ln z)\" by (rule abs_triangle_ineq4) - also have "... < pi + pi" + also have "\ < pi + pi" proof - have "\Im (Ln (inverse z))\ < pi" by (simp add: False Im_Ln_less_pi abs_if assms minus_less_iff mpi_less_Im_Ln) @@ -1691,8 +1686,8 @@ lemma Ln_minus_ii [simp]: "Ln(-\) = - (\ * pi/2)" proof - have "Ln(-\) = Ln(inverse \)" by simp - also have "... = - (Ln \)" using Ln_inverse by blast - also have "... = - (\ * pi/2)" by simp + also have "\ = - (Ln \)" using Ln_inverse by blast + also have "\ = - (\ * pi/2)" by simp finally show ?thesis . qed @@ -1768,11 +1763,11 @@ 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" + also have "\ = Ln (inverse (-z)) + \ * complex_of_real pi" using assms z by (simp add: Ln_minus divide_less_0_iff) - also have "... = - Ln (- z) + \ * complex_of_real pi" + also have "\ = - Ln (- z) + \ * complex_of_real pi" using z Ln_inverse by presburger - also have "... = - (Ln z) + \ * 2 * complex_of_real pi" + also have "\ = - (Ln z) + \ * 2 * complex_of_real pi" using Ln_minus assms z by auto finally show ?thesis by (simp add: True) qed @@ -1794,9 +1789,9 @@ shows "Ln (of_nat m / of_nat n) = of_real (ln (of_nat m) - ln (of_nat n))" proof - have "of_nat m / of_nat n = (of_real (of_nat m / of_nat n) :: complex)" by simp - also from assms have "Ln ... = of_real (ln (of_nat m / of_nat n))" + also from assms have "Ln \ = of_real (ln (of_nat m / of_nat n))" by (simp add: Ln_of_real[symmetric]) - also from assms have "... = of_real (ln (of_nat m) - ln (of_nat n))" + also from assms have "\ = of_real (ln (of_nat m) - ln (of_nat n))" by (simp add: ln_div) finally show ?thesis . qed @@ -1887,13 +1882,13 @@ proof (rule Arg2pi_unique_lemma [of "- (inverse z)"]) have "- (inverse z) = - (inverse (of_real(norm z) * exp(\ * t)))" by (metis is_Arg_def z) - also have "... = (cmod (- inverse z)) * exp (\ * (pi - t))" + also have "\ = (cmod (- inverse z)) * exp (\ * (pi - t))" by (auto simp: field_simps exp_diff norm_divide) finally show "is_Arg (- inverse z) (pi - t)" unfolding is_Arg_def . have "- (inverse z) = - (inverse (of_real(norm z) * exp(\ * t')))" by (metis is_Arg_def z') - also have "... = (cmod (- inverse z)) * exp (\ * (pi - t'))" + also have "\ = (cmod (- inverse z)) * exp (\ * (pi - t'))" by (auto simp: field_simps exp_diff norm_divide) finally show "is_Arg (- inverse z) (pi - t')" unfolding is_Arg_def . @@ -2125,14 +2120,14 @@ by (auto simp: exp_diff algebra_simps) then have "ln (- z / of_real(norm z)) = ln (exp (\ * (of_real (Arg2pi z) - pi)))" by simp - also have "... = \ * (of_real(Arg2pi z) - pi)" + also have "\ = \ * (of_real(Arg2pi z) - pi)" using Arg2pi [of z] assms pi_not_less_zero by auto finally have "Arg2pi z = Im (Ln (- z / of_real (cmod z))) + pi" by simp - also have "... = Im (Ln (-z) - ln (cmod z)) + pi" + also have "\ = Im (Ln (-z) - ln (cmod z)) + pi" by (metis diff_0_right minus_diff_eq zero_less_norm_iff Ln_divide_of_real False) - also have "... = Im (Ln (-z)) + pi" + also have "\ = Im (Ln (-z)) + pi" by simp finally show ?thesis . qed @@ -2341,7 +2336,7 @@ hence "(-x) powr a = exp (a * ln (-of_real x))" by (simp add: powr_def) also from x have "ln (-of_real x) = Ln (of_real x) + of_real (sgn x) * pi * \" by (simp add: Ln_minus Ln_of_real) - also from x have "exp (a * ...) = cis pi powr (of_real (sgn x) * a) * of_real x powr a" + also from x have "exp (a * \) = cis pi powr (of_real (sgn x) * a) * of_real x powr a" by (simp add: powr_def exp_add algebra_simps Ln_of_real cis_conv_exp) also note cis_pi finally show ?thesis by simp @@ -2388,14 +2383,14 @@ 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" 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 + 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)" . then show ?thesis unfolding dd_def by simp @@ -2413,14 +2408,14 @@ 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))" 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 "..." + also have "\" proof - have "nat (- n) + nat (1 - n) - Suc 0 = nat (- n) + nat (- n)" by auto @@ -2651,7 +2646,7 @@ by linarith then have "x * 2 \ e * (x\<^sup>2 * (Re s)\<^sup>2)" using e assms x by (auto simp: power2_eq_square field_simps) - also have "... < e * (2 + (x * (Re s * 2) + x\<^sup>2 * (Re s)\<^sup>2))" + also have "\ < e * (2 + (x * (Re s * 2) + x\<^sup>2 * (Re s)\<^sup>2))" using e assms \x > 0\ by (auto simp: power2_eq_square field_simps add_pos_pos) finally show "0 < e * 2 + (e * Re s * 2 - 2) * x + e * (Re s)\<^sup>2 * x\<^sup>2" @@ -2797,11 +2792,11 @@ proof - have "(exp (Ln z / 2))\<^sup>2 = (exp (Ln z))" by (metis exp_double nonzero_mult_div_cancel_left times_divide_eq_right zero_neq_numeral) - also have "... = z" + also have "\ = z" using assms exp_Ln by blast finally have "csqrt z = csqrt ((exp (Ln z / 2))\<^sup>2)" by simp - also have "... = exp (Ln z / 2)" + also have "\ = exp (Ln z / 2)" apply (rule csqrt_square) using cos_gt_zero_pi [of "(Im (Ln z) / 2)"] Im_Ln_le_pi mpi_less_Im_Ln assms by (fastforce simp: Re_exp Im_exp ) @@ -2963,15 +2958,15 @@ 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)" + also have "\ \ exp (2*\*z) = exp (\*pi)" using cis_conv_exp cis_pi by auto - also have "... \ exp (2*\*z - \*pi) = 1" + 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)" + 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)" + also have "\ \ Im z = 0 \ (\n::int. 2 * Re z = of_int (2*n + 1) * pi)" by (simp add: algebra_simps) - also have "... \ False" + 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) @@ -3191,7 +3186,7 @@ next have "tan (Re (Arctan (of_real x))) = Re (tan (Arctan (of_real x)))" by (auto simp: tan_def Complex.Re_divide Re_sin Re_cos Im_sin Im_cos field_simps power2_eq_square) - also have "... = x" + also have "\ = x" 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) @@ -3242,9 +3237,9 @@ proof - have "arctan(inverse x) = arctan(inverse(tan(arctan x)))" by (simp add: arctan) - also have "... = arctan (tan (pi / 2 - arctan x))" + also have "\ = arctan (tan (pi / 2 - arctan x))" by (simp add: tan_cot) - also have "... = pi/2 - arctan x" + also have "\ = pi/2 - arctan x" proof - have "0 < pi - arctan x" using arctan_ubound [of x] pi_gt_zero by linarith @@ -3411,7 +3406,7 @@ proof - have "\*z*2 + csqrt (1 - z\<^sup>2)*2 = 0 \ (\*z)*2 + csqrt (1 - z\<^sup>2)*2 = 0" by (simp add: algebra_simps) \ \Cancelling a factor of 2\ - moreover have "... \ (\*z) + csqrt (1 - z\<^sup>2) = 0" + moreover have "\ \ (\*z) + csqrt (1 - z\<^sup>2) = 0" by (metis Arcsin_body_lemma distrib_right no_zero_divisors zero_neq_numeral) ultimately show ?thesis apply (simp add: sin_exp_eq Arcsin_def Arcsin_body_lemma exp_minus divide_simps) @@ -3442,14 +3437,14 @@ proof - have "Arcsin(sin z) = - (\ * Ln (csqrt (1 - (\ * (exp (\*z) - inverse (exp (\*z))))\<^sup>2 / 4) - (inverse (exp (\*z)) - exp (\*z)) / 2))" by (simp add: sin_exp_eq Arcsin_def exp_minus power_divide) - also have "... = - (\ * Ln (csqrt (((exp (\*z) + inverse (exp (\*z)))/2)\<^sup>2) - (inverse (exp (\*z)) - exp (\*z)) / 2))" + also have "\ = - (\ * Ln (csqrt (((exp (\*z) + inverse (exp (\*z)))/2)\<^sup>2) - (inverse (exp (\*z)) - exp (\*z)) / 2))" by (simp add: field_simps power2_eq_square) - also have "... = - (\ * Ln (((exp (\*z) + inverse (exp (\*z)))/2) - (inverse (exp (\*z)) - exp (\*z)) / 2))" + 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 by auto - also have "... = - (\ * Ln (exp (\*z)))" + also have "\ = - (\ * Ln (exp (\*z)))" by (simp add: field_simps power2_eq_square) - also have "... = z" + also have "\ = z" using assms by (auto simp: abs_if simp del: eq_divide_eq_numeral1 split: if_split_asm) finally show ?thesis . qed @@ -3566,7 +3561,7 @@ proof - have "z*2 + \ * (2 * csqrt (1 - z\<^sup>2)) = 0 \ z*2 + \ * csqrt (1 - z\<^sup>2)*2 = 0" by (simp add: algebra_simps) \ \Cancelling a factor of 2\ - moreover have "... \ z + \ * csqrt (1 - z\<^sup>2) = 0" + moreover have "\ \ z + \ * csqrt (1 - z\<^sup>2) = 0" by (metis distrib_right mult_eq_0_iff zero_neq_numeral) ultimately show ?thesis by (simp add: cos_exp_eq Arccos_def Arccos_body_lemma exp_minus field_simps flip: power2_eq_square) @@ -3585,14 +3580,14 @@ then have "Arccos(cos z) = - (\ * Ln ((exp (\ * z) + inverse (exp (\ * z))) / 2 + \ * csqrt (((\ - (exp (\ * z))\<^sup>2 * \) / (2 * exp (\ * z)))\<^sup>2)))" by (simp add: cos_exp_eq Arccos_def exp_minus power_divide) - also have "... = - (\ * Ln ((exp (\ * z) + inverse (exp (\ * z))) / 2 + + also have "\ = - (\ * Ln ((exp (\ * z) + inverse (exp (\ * z))) / 2 + \ * ((\ - (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] by (auto simp: * Re_sin Im_sin) - also have "... = - (\ * Ln (exp (\*z)))" + also have "\ = - (\ * Ln (exp (\*z)))" by (simp add: field_simps power2_eq_square) - also have "... = z" + also have "\ = z" using assms by (subst Complex_Transcendental.Ln_exp, auto) finally show ?thesis . @@ -3676,7 +3671,7 @@ 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)"] by (simp only: abs_le_square_iff) (simp add: field_split_simps) - also have "... \ (cmod w)\<^sup>2" + also have "\ \ (cmod w)\<^sup>2" by (auto simp: cmod_power2) finally show ?thesis using abs_le_square_iff by force @@ -3975,7 +3970,7 @@ have "continuous_on {w \ \. \Re w\ \ 1} (\x. complex_of_real (arcsin (Re x))) = continuous_on {w \ \. \Re w\ \ 1} (\x. complex_of_real (Re (Arcsin (of_real (Re x)))))" by (rule continuous_on_cong [OF refl]) (simp add: arcsin_eq_Re_Arcsin) - also have "... = ?thesis" + also have "\ = ?thesis" by (rule continuous_on_cong [OF refl]) simp finally show ?thesis using continuous_on_arcsin [OF continuous_on_Re [OF continuous_on_id], of "{w \ \. \Re w\ \ 1}"] @@ -4001,7 +3996,7 @@ have "continuous_on {w \ \. \Re w\ \ 1} (\x. complex_of_real (arccos (Re x))) = continuous_on {w \ \. \Re w\ \ 1} (\x. complex_of_real (Re (Arccos (of_real (Re x)))))" by (rule continuous_on_cong [OF refl]) (simp add: arccos_eq_Re_Arccos) - also have "... = ?thesis" + also have "\ = ?thesis" by (rule continuous_on_cong [OF refl]) simp finally show ?thesis using continuous_on_arccos [OF continuous_on_Re [OF continuous_on_id], of "{w \ \. \Re w\ \ 1}"] @@ -4037,15 +4032,7 @@ fixes j::nat assumes "n \ 0" shows "exp(2 * of_real pi * \ * of_nat j / of_nat n)^n = 1" -proof - - have *: "of_nat j * (complex_of_real pi * 2) = complex_of_real (2 * real j * pi)" - by (simp) - 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 - done -qed + by (metis assms bot_nat_0.not_eq_extremum exp_divide_power_eq exp_of_nat2_mult exp_two_pi_i power_one) lemma complex_root_unity_eq: fixes j::nat and k::nat @@ -4058,13 +4045,13 @@ (\z::int. of_nat j * (\ * (of_real pi * 2)) = (of_nat k + of_nat n * of_int z) * (\ * (of_real pi * 2)))" by (simp add: algebra_simps) - also have "... \ (\z::int. of_nat j = of_nat k + of_nat n * (of_int z :: complex))" + 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)" + also have "\ \ (\z::int. of_nat j = of_nat k + of_nat n * z)" by (metis (mono_tags, opaque_lifting) 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" + 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" + also have "\ \ j mod n = k mod n" by (metis of_nat_eq_iff zmod_int) finally have "(\z. \ * (of_nat j * (of_real pi * 2)) = \ * (of_nat k * (of_real pi * 2)) + \ * (of_int z * (of_nat n * (of_real pi * 2)))) \ j mod n = k mod n" . diff -r 1bb677cceea4 -r 19837257fd89 src/HOL/Analysis/Polytope.thy --- a/src/HOL/Analysis/Polytope.thy Tue Sep 13 11:56:38 2022 +0200 +++ b/src/HOL/Analysis/Polytope.thy Tue Sep 13 18:56:48 2022 +0100 @@ -82,16 +82,16 @@ then have zne: "\u. \u \ {0<..<1}; (1 - u) *\<^sub>R y + u *\<^sub>R x \ T\ \ False" using \x \ S\ \x \ T\ \T face_of S\ unfolding face_of_def by (meson greaterThanLessThan_iff in_segment(2)) - have in01: "min (1/2) (e / norm (x - y)) \ {0<..<1}" - using \y \ x\ \e > 0\ by simp - have \
: "norm (min (1/2) (e / norm (x - y)) *\<^sub>R y - min (1/2) (e / norm (x - y)) *\<^sub>R x) \ e" + define u where "u \ min (1/2) (e / norm (x - y))" + have in01: "u \ {0<..<1}" + using \y \ x\ \e > 0\ by (simp add: u_def) + have "norm (u *\<^sub>R y - u *\<^sub>R x) \ e" using \e > 0\ - by (simp add: scaleR_diff_right [symmetric] norm_minus_commute min_mult_distrib_right) - show False - apply (rule zne [OF in01 e [THEN subsetD]]) - using \y \ T\ - apply (simp add: hull_inc mem_affine x) - by (simp add: dist_norm algebra_simps \
) + by (simp add: u_def norm_minus_commute min_mult_distrib_right flip: scaleR_diff_right) + then have "dist y ((1 - u) *\<^sub>R y + u *\<^sub>R x) \ e" + by (simp add: dist_norm algebra_simps) + then show False + using zne [OF in01 e [THEN subsetD]] by (simp add: \y \ T\ hull_inc mem_affine x) qed show ?thesis proof (rule subset_antisym) @@ -187,8 +187,8 @@ by (simp add: divide_simps) (simp add: algebra_simps) have "b \ open_segment d c" apply (simp add: open_segment_image_interval) - apply (simp add: d_def algebra_simps image_def) - apply (rule_tac x="e / (e + norm (b - c))" in bexI) + apply (simp add: d_def algebra_simps) + apply (rule_tac x="e / (e + norm (b - c))" in image_eqI) using False nbc \0 < e\ by (auto simp: algebra_simps) then have "d \ T \ c \ T" by (meson \b \ T\ \c \ u\ \d \ u\ assms face_ofD subset_iff) @@ -244,8 +244,9 @@ proof (cases "T = {}") case True then show ?thesis by (metis aff_dim_empty \T \ S\) - next case False then show ?thesis - by (metis Set.set_insert assms convex_rel_frontier_aff_dim dual_order.irrefl face_of_imp_convex face_of_subset_rel_frontier insert_not_empty subsetI) + next + case False then show ?thesis + by (smt (verit) aff_dim_empty assms convex_rel_frontier_aff_dim face_of_imp_convex face_of_subset_rel_frontier) qed ultimately show ?thesis by simp @@ -262,10 +263,10 @@ qed lemma affine_hull_face_of_disjoint_rel_interior: - fixes S :: "'a::euclidean_space set" + fixes S :: "'a::euclidean_space set" assumes "convex S" "F face_of S" "F \ S" shows "affine hull F \ rel_interior S = {}" - by (metis assms disjnt_def face_of_imp_subset order_refl subset_antisym subset_of_face_of_affine_hull) + by (meson antisym assms disjnt_def equalityD2 face_of_def subset_of_face_of_affine_hull) lemma affine_diff_divide: assumes "affine S" "k \ 0" "k \ 1" and xy: "x \ S" "y /\<^sub>R (1 - k) \ S" @@ -312,14 +313,12 @@ have a0: "a i = 0" if "i \ (S - T)" for i using ci0 [OF that] u01 a [of i] b [of i] that by (simp add: c_def Groups.ordered_comm_monoid_add_class.add_nonneg_eq_0_iff) - have [simp]: "sum a T = 1" + have "sum a T = 1" using assms by (metis sum.mono_neutral_cong_right a0 asum) - show ?thesis - apply (simp add: convex_hull_finite \finite T\) - apply (rule_tac x=a in exI) - using a0 assms - apply (auto simp: cge0 a aeqx [symmetric] sum.mono_neutral_right) - done + moreover have "(\x\T. a x *\<^sub>R x) = x" + using a0 assms by (auto simp: cge0 a aeqx [symmetric] sum.mono_neutral_right) + ultimately show ?thesis + using a assms(2) by (auto simp add: convex_hull_finite \finite T\ ) next case False define k where "k = sum c (S - T)" @@ -332,38 +331,34 @@ case True then have "sum c T = 0" by (simp add: S k_def sum_diff sumc1) - then have [simp]: "sum c (S - T) = 1" + then have "sum c (S - T) = 1" by (simp add: S sum_diff sumc1) - have ci0: "\i. i \ T \ c i = 0" + moreover have ci0: "\i. i \ T \ c i = 0" by (meson \finite T\ \sum c T = 0\ \T \ S\ cge0 sum_nonneg_eq_0_iff subsetCE) - then have [simp]: "(\i\S-T. c i *\<^sub>R i) = w" + then have "(\i\S-T. c i *\<^sub>R i) = w" by (simp add: weq_sumsum) - have "w \ convex hull (S - T)" - apply (simp add: convex_hull_finite fin) - apply (rule_tac x=c in exI) - apply (auto simp: cge0 weq True k_def) - done + ultimately have "w \ convex hull (S - T)" + using cge0 by (auto simp add: convex_hull_finite fin) then show ?thesis using disj waff by blast next case False then have sumcf: "sum c T = 1 - k" by (simp add: S k_def sum_diff sumc1) - have ge0: "\x. x \ T \ 0 \ inverse (1 - k) * c x" + have "\x. x \ T \ 0 \ inverse (1 - k) * c x" by (metis \T \ S\ cge0 inverse_nonnegative_iff_nonnegative mult_nonneg_nonneg subsetD sum_nonneg sumcf) - have eq1: "(\x\T. inverse (1 - k) * c x) = 1" + moreover have "(\x\T. inverse (1 - k) * c x) = 1" by (metis False eq_iff_diff_eq_0 mult.commute right_inverse sum_distrib_left sumcf) - have "(\i\T. c i *\<^sub>R i) /\<^sub>R (1 - k) \ convex hull T" + ultimately have "(\i\T. c i *\<^sub>R i) /\<^sub>R (1 - k) \ convex hull T" apply (simp add: convex_hull_finite fin) - apply (rule_tac x="\i. inverse (1-k) * c i" in exI) - by (metis (mono_tags, lifting) eq1 ge0 scaleR_scaleR scale_sum_right sum.cong) + by (metis (mono_tags, lifting) scaleR_right.sum scaleR_scaleR sum.cong) with \0 < k\ have "inverse(k) *\<^sub>R (w - sum (\i. c i *\<^sub>R i) T) \ affine hull T" by (simp add: affine_diff_divide [OF affine_affine_hull] False waff convex_hull_subset_affine_hull [THEN subsetD]) moreover have "inverse(k) *\<^sub>R (w - sum (\x. c x *\<^sub>R x) T) \ convex hull (S - T)" apply (simp add: weq_sumsum convex_hull_finite fin) apply (rule_tac x="\i. inverse k * c i" in exI) using \k > 0\ cge0 - apply (auto simp: scaleR_right.sum sum_distrib_left [symmetric] k_def [symmetric]) + apply (auto simp: scaleR_right.sum simp flip: sum_distrib_left k_def) done ultimately show ?thesis using disj by blast @@ -402,12 +397,9 @@ case True with \a \ T\ show ?thesis by auto next case False - then have "a \ 2 *\<^sub>R a - b" - by (simp add: scaleR_2) - with False have "a \ open_segment (2 *\<^sub>R a - b) b" - apply (clarsimp simp: open_segment_def closed_segment_def) - apply (rule_tac x="1/2" in exI) - by (simp add: algebra_simps) + then have "a \ open_segment (2 *\<^sub>R a - b) b" + by (metis diff_add_cancel inverse_eq_divide midpoint_def midpoint_in_open_segment + scaleR_2 scaleR_half_double) moreover have "2 *\<^sub>R a - b \ S" by (rule mem_affine [OF \affine S\ \a \ S\ \b \ S\, of 2 "-1", simplified]) moreover note \b \ S\ \a \ T\ @@ -648,10 +640,12 @@ T face_of S \ (\a b. S \ {x. a \ x \ b} \ T = S \ {x. a \ x = b})" lemma empty_exposed_face_of [iff]: "{} exposed_face_of S" - apply (simp add: exposed_face_of_def) - apply (rule_tac x=0 in exI) - apply (rule_tac x=1 in exI, force) - done +proof - + have "S \ {x. 0 \ x \ 1} \ {} = S \ {x. 0 \ x = 1}" + by force + then show ?thesis + using exposed_face_of_def by blast +qed lemma exposed_face_of_refl_eq [simp]: "S exposed_face_of S \ convex S" proof @@ -671,9 +665,6 @@ (T = {} \ T = S \ (\a b. a \ 0 \ S \ {x. a \ x \ b} \ T = S \ {x. a \ x = b}))" proof (cases "T = {}") - case True then show ?thesis - by simp -next case False show ?thesis proof (cases "T = S") @@ -686,7 +677,7 @@ apply (metis inner_zero_left) done qed -qed +qed auto lemma exposed_face_of_Int_supporting_hyperplane_le: "\convex S; \x. x \ S \ a \ x \ b\ \ (S \ {x. a \ x = b}) exposed_face_of S" @@ -713,13 +704,10 @@ using T teq u ueq by (simp add: face_of_Int) have ss: "S \ {x. (a + a') \ x \ b + b'}" using S s' by (force simp: inner_left_distrib) - show ?thesis - apply (simp add: exposed_face_of_def tu) - apply (rule_tac x="a+a'" in exI) - apply (rule_tac x="b+b'" in exI) - using S s' - apply (fastforce simp: ss inner_left_distrib teq ueq) - done + have "S \ {x. (a + a') \ x \ b + b'} \ T \ u = S \ {x. (a + a') \ x = b + b'}" + using S s' by (fastforce simp: ss inner_left_distrib teq ueq) + then show ?thesis + using exposed_face_of_def tu by auto qed proposition exposed_face_of_Inter: @@ -2568,15 +2556,16 @@ using \h \ F\ F_def face_of_disjoint_rel_interior hface by auto qed qed - have "S \ affine hull S \ \{{x. a h \ x \ b h} |h. h \ F}" + let ?S' = "affine hull S \ \{{x. a h \ x \ b h} |h. h \ F}" + have "S \ ?S'" using ab by (auto simp: hull_subset) - moreover have "affine hull S \ \{{x. a h \ x \ b h} |h. h \ F} \ S" + moreover have "?S' \ S" using * by blast - ultimately have "S = affine hull S \ \ {{x. a h \ x \ b h} |h. h \ F}" .. - then show ?thesis - apply (rule ssubst) - apply (force intro: polyhedron_affine_hull polyhedron_halfspace_le simp: \finite F\) - done + ultimately have "S = ?S'" .. + moreover have "polyhedron ?S'" + by (force intro: polyhedron_affine_hull polyhedron_halfspace_le simp: \finite F\) + ultimately show ?thesis + by auto qed qed @@ -2599,19 +2588,22 @@ assumes "linear h" "bij h" shows "polyhedron (h ` S) \ polyhedron S" proof - - have *: "{f. P f} = (image h) ` {f. P (h ` f)}" for P - apply safe - apply (rule_tac x="inv h ` x" in image_eqI) - apply (auto simp: \bij h\ bij_is_surj image_f_inv_f) - done - have "inj h" using bij_is_inj assms by blast + have [simp]: "inj h" using bij_is_inj assms by blast then have injim: "inj_on ((`) h) A" for A by (simp add: inj_on_def inj_image_eq_iff) - show ?thesis - using \linear h\ \inj h\ - apply (simp add: polyhedron_eq_finite_faces closed_injective_linear_image_eq) - apply (simp add: * face_of_linear_image [of h _ S, symmetric] finite_image_iff injim) - done + { fix P + have "\x. P x \ x \ (`) h ` {f. P (h ` f)}" + using bij_is_surj [OF \bij h\] + by (metis image_eqI mem_Collect_eq subset_imageE top_greatest) + then have "{f. P f} = (image h) ` {f. P (h ` f)}" + by force + } + then have "finite {F. F face_of h ` S} =finite {F. F face_of S}" + using \linear h\ + by (simp add: finite_image_iff injim flip: face_of_linear_image [of h _ S]) + then show ?thesis + using \linear h\ + by (simp add: polyhedron_eq_finite_faces closed_injective_linear_image_eq) qed lemma polyhedron_negations: @@ -2814,8 +2806,7 @@ have x: "x < ?n * a" by (meson \0 < a\ divide_less_eq floor_eq_iff) have "?n * a \ a + x" - apply (simp add: algebra_simps) - by (metis assms(2) floor_divide_lower mult.commute) + using \a>0\ by (simp add: distrib_right floor_divide_lower) also have "... < y" by (rule 1) finally have "?n * a < y" . @@ -2827,8 +2818,7 @@ have y: "y < ?n * a" by (meson \0 < a\ divide_less_eq floor_eq_iff) have "?n * a \ a + y" - apply (simp add: algebra_simps) - by (metis assms(2) floor_divide_lower mult.commute) + using \a>0\ by (simp add: distrib_right floor_divide_lower) also have "... < x" by (rule 2) finally have "?n * a < x" . @@ -3064,8 +3054,7 @@ by (metis simplex add.commute add_diff_cancel_left' aff_dim_convex_hull affine_independent_iff_card) lemma zero_simplex_sing: "0 simplex {a}" - apply (simp add: simplex_def) - using affine_independent_1 card_1_singleton_iff convex_hull_singleton by blast + using affine_independent_1 simplex_convex_hull by fastforce lemma simplex_sing [simp]: "n simplex {a} \ n = 0" using aff_dim_simplex aff_dim_sing zero_simplex_sing by blast diff -r 1bb677cceea4 -r 19837257fd89 src/HOL/Library/Extended_Nonnegative_Real.thy --- a/src/HOL/Library/Extended_Nonnegative_Real.thy Tue Sep 13 11:56:38 2022 +0200 +++ b/src/HOL/Library/Extended_Nonnegative_Real.thy Tue Sep 13 18:56:48 2022 +0100 @@ -610,11 +610,7 @@ lemma ennreal_minus_cancel: fixes a b c :: ennreal shows "c \ top \ a \ c \ b \ c \ c - a = c - b \ a = b" - apply transfer - subgoal for a b c - by (cases a b c rule: ereal3_cases) - (auto simp: top_ereal_def max_def split: if_splits) - done + by (metis ennreal_add_diff_cancel_left ennreal_add_diff_cancel_right ennreal_add_eq_top less_eqE) lemma sup_const_add_ennreal: fixes a b c :: "ennreal" @@ -624,19 +620,14 @@ lemma ennreal_diff_add_assoc: fixes a b c :: ennreal shows "a \ b \ c + b - a = c + (b - a)" - apply transfer - subgoal for a b c - by (cases a b c rule: ereal3_cases) (auto simp: field_simps max_absorb2) - done + by (metis add.left_commute ennreal_add_diff_cancel_left ennreal_add_eq_top ennreal_top_minus less_eqE) lemma mult_divide_eq_ennreal: fixes a b :: ennreal shows "b \ 0 \ b \ top \ (a * b) / b = a" unfolding divide_ennreal_def apply transfer - apply (subst mult.assoc) - apply (simp add: top_ereal_def flip: divide_ereal_def) - done + by (metis abs_ereal_ge0 divide_ereal_def ereal_divide_eq ereal_times_divide_eq top_ereal_def) lemma divide_mult_eq: "a \ 0 \ a \ \ \ x * a / (b * a) = x / (b::ennreal)" unfolding divide_ennreal_def infinity_ennreal_def @@ -650,17 +641,12 @@ lemma ennreal_mult_divide_eq: fixes a b :: ennreal shows "b \ 0 \ b \ top \ (a * b) / b = a" - unfolding divide_ennreal_def - apply transfer - apply (subst mult.assoc) - apply (simp add: top_ereal_def flip: divide_ereal_def) - done + by (fact mult_divide_eq_ennreal) lemma ennreal_add_diff_cancel: fixes a b :: ennreal shows "b \ \ \ (a + b) - b = a" - unfolding infinity_ennreal_def - by transfer (simp add: max_absorb2 top_ereal_def ereal_add_diff_cancel) + by simp lemma ennreal_minus_eq_0: "a - b = 0 \ a \ (b::ennreal)" @@ -792,14 +778,10 @@ by transfer (meson ereal_minus_mono max.mono order_refl) lemma ennreal_minus_eq_top[simp]: "a - (b::ennreal) = top \ a = top" - by transfer (auto simp: top_ereal_def max.absorb2 ereal_minus_eq_PInfty_iff split: split_max) + by (metis add_top diff_add_cancel_ennreal ennreal_mono_minus ennreal_top_minus zero_le) lemma ennreal_divide_self[simp]: "a \ 0 \ a < top \ a / a = (1::ennreal)" - unfolding divide_ennreal_def - apply transfer - subgoal for a - by (cases a) (auto simp: top_ereal_def) - done + by (metis mult_1 mult_divide_eq_ennreal top.not_eq_extremum) subsection \Coercion from \<^typ>\real\ to \<^typ>\ennreal\\ @@ -808,7 +790,8 @@ declare [[coercion ennreal]] -lemma ennreal_cong: "x = y \ ennreal x = ennreal y" by simp +lemma ennreal_cong: "x = y \ ennreal x = ennreal y" + by simp lemma ennreal_cases[cases type: ennreal]: fixes x :: ennreal @@ -892,7 +875,7 @@ by (cases "0 \ x") (auto simp: ennreal_neg simp flip: ennreal_1) lemma one_less_ennreal[simp]: "1 < ennreal x \ 1 < x" - by transfer (auto simp: max.absorb2 less_max_iff_disj) + by (meson ennreal_le_1 linorder_not_le) lemma ennreal_plus[simp]: "0 \ a \ 0 \ b \ ennreal (a + b) = ennreal a + ennreal b" @@ -992,17 +975,11 @@ by (cases "n = 0") auto next case (real r) then show ?thesis - proof cases - assume "x = 0" then show ?thesis - using power_eq_top_ennreal[of top "n - 1"] - by (cases n) (auto simp: ennreal_top_mult) - next - assume "x \ 0" - with real have "0 < r" by auto - with real show ?thesis - by (induction n) - (auto simp add: ennreal_power ennreal_mult[symmetric] inverse_ennreal) - qed + proof (cases "x = 0") + case False then show ?thesis + by (smt (verit, best) ennreal_0 ennreal_power inverse_ennreal + inverse_nonnegative_iff_nonnegative power_inverse real zero_less_power) + qed (simp add: top_power_ennreal) qed lemma power_divide_distrib_ennreal [algebra_simps]: @@ -1547,12 +1524,8 @@ fixes f :: "nat \ ennreal" shows "(\n. f n \ c) \ liminf (\n. c - f n) = c - limsup f" apply transfer - apply (simp add: ereal_diff_positive max.absorb2 liminf_ereal_cminus) - apply (subst max.absorb2) - apply (rule ereal_diff_positive) - apply (rule Limsup_bounded) - apply auto - done + apply (simp add: ereal_diff_positive liminf_ereal_cminus) + by (metis max.absorb2 ereal_diff_positive Limsup_bounded eventually_sequentiallyI) lemma ennreal_continuous_on_cmult: "(c::ennreal) < top \ continuous_on A f \ continuous_on A (\x. c * f x)" @@ -1606,7 +1579,6 @@ lemma ennreal_Inf_countable_INF: "A \ {} \ \f::nat \ ennreal. decseq f \ range f \ A \ Inf A = (INF i. f i)" - including ennreal.lifting unfolding decseq_def apply transfer subgoal for A @@ -1655,9 +1627,7 @@ shows "I \ {} \ (SUP i\I. f i + c) = (SUP i\I. f i) + c" apply transfer apply (simp add: SUP_ereal_add_left) - apply (subst (1 2) max.absorb2) - apply (auto intro: SUP_upper2 add_nonneg_nonneg) - done + by (metis SUP_upper all_not_in_conv ereal_le_add_mono1 max.absorb2 max.bounded_iff) lemma ennreal_SUP_const_minus: fixes f :: "'a \ ennreal" @@ -1689,13 +1659,9 @@ fix t assume \open t \ ennreal_of_enat x \ t\ then have \\y<\. {y <.. \} \ t\ - apply (rule_tac open_left[where y=0]) - by (auto simp: True) + by (rule_tac open_left[where y=0]) (auto simp: True) then obtain y where \{y<..} \ t\ and \y \ \\ - apply atomize_elim - apply (auto simp: greaterThanAtMost_def) - by (metis atMost_iff inf.orderE subsetI top.not_eq_extremum top_greatest) - + by fastforce from \y \ \\ obtain x' where x'y: \ennreal_of_enat x' > y\ and \x' \ \\ by (metis enat.simps(3) ennreal_Ex_less_of_nat ennreal_of_enat_enat infinity_ennreal_def top.not_eq_extremum) @@ -1907,9 +1873,7 @@ lemma add_diff_eq_ennreal: fixes x y z :: ennreal shows "z \ y \ x + (y - z) = x + y - z" - including ennreal.lifting - by transfer - (insert add_mono[of "0::ereal"], auto simp add: ereal_diff_positive max.absorb2 add_diff_eq_ereal) + using ennreal_diff_add_assoc by auto lemma add_diff_inverse_ennreal: fixes x y :: ennreal shows "x \ y \ x + (y - x) = y" @@ -2035,11 +1999,8 @@ fixes f g :: "_ \ ennreal" assumes directed: "\i j. i \ I \ j \ I \ \k\I. f i + g j \ f k + g k" shows "(SUP i\I. f i + g i) = (SUP i\I. f i) + (SUP i\I. g i)" -proof cases - assume "I = {}" then show ?thesis - by (simp add: bot_ereal_def) -next - assume "I \ {}" +proof (cases "I = {}") + case False show ?thesis proof (rule antisym) show "(SUP i\I. f i + g i) \ (SUP i\I. f i) + (SUP i\I. g i)" @@ -2053,7 +2014,8 @@ using directed by (intro SUP_least) (blast intro: SUP_upper2) finally show "(SUP i\I. f i) + (SUP i\I. g i) \ (SUP i\I. f i + g i)" . qed -qed +qed (simp add: bot_ereal_def) + lemma enn2real_eq_0_iff: "enn2real x = 0 \ x = 0 \ x = top" by (cases x) auto