diff -r c09598a97436 -r d8d85a8172b5 src/HOL/NthRoot.thy --- a/src/HOL/NthRoot.thy Sat Jul 18 21:44:18 2015 +0200 +++ b/src/HOL/NthRoot.thy Sat Jul 18 22:58:50 2015 +0200 @@ -4,7 +4,7 @@ Conversion to Isar and new proofs by Lawrence C Paulson, 2004 *) -section {* Nth Roots of Real Numbers *} +section \Nth Roots of Real Numbers\ theory NthRoot imports Deriv Binomial @@ -21,9 +21,9 @@ shows "0 < n \ 0 \ a \ 0 \ b \ a ^ n = b ^ n \ a = b" using power_eq_imp_eq_base[of a n b] by auto -subsection {* Existence of Nth Root *} +subsection \Existence of Nth Root\ -text {* Existence follows from the Intermediate Value Theorem *} +text \Existence follows from the Intermediate Value Theorem\ lemma realpow_pos_nth: assumes n: "0 < n" @@ -52,21 +52,21 @@ lemma realpow_pos_nth2: "(0::real) < a \ \r>0. r ^ Suc n = a" by (blast intro: realpow_pos_nth) -text {* Uniqueness of nth positive root *} +text \Uniqueness of nth positive root\ lemma realpow_pos_nth_unique: "\0 < n; 0 < a\ \ \!r. 0 < r \ r ^ n = (a::real)" by (auto intro!: realpow_pos_nth simp: power_eq_iff_eq_base) -subsection {* Nth Root *} +subsection \Nth Root\ -text {* We define roots of negative reals such that +text \We define roots of negative reals such that @{term "root n (- x) = - root n x"}. This allows - us to omit side conditions from many theorems. *} + us to omit side conditions from many theorems.\ lemma inj_sgn_power: assumes "0 < n" shows "inj (\y. sgn y * \y\^n :: real)" (is "inj ?f") proof (rule injI) have x: "\a b :: real. (0 < a \ b < 0) \ (a < 0 \ 0 < b) \ a \ b" by auto - fix x y assume "?f x = ?f y" with power_eq_iff_eq_base[of n "\x\" "\y\"] `0x\" "\y\"] \0 show "x = y" by (cases rule: linorder_cases[of 0 x, case_product linorder_cases[of 0 y]]) (simp_all add: x) qed @@ -87,13 +87,13 @@ assumes "0 < n" shows "sgn (root n x) * \(root n x)\^n = x" (is "?f (root n x) = x") proof cases assume "x \ 0" - with realpow_pos_nth[OF `0 < n`, of "\x\"] obtain r where "0 < r" "r ^ n = \x\" by auto - with `x \ 0` have S: "x \ range ?f" + with realpow_pos_nth[OF \0 < n\, of "\x\"] obtain r where "0 < r" "r ^ n = \x\" by auto + with \x \ 0\ have S: "x \ range ?f" by (intro image_eqI[of _ _ "sgn x * r"]) (auto simp: abs_mult sgn_mult power_mult_distrib abs_sgn_eq mult_sgn_abs) - from `0 < n` f_the_inv_into_f[OF inj_sgn_power[OF `0 < n`] this] show ?thesis + from \0 < n\ f_the_inv_into_f[OF inj_sgn_power[OF \0 < n\] this] show ?thesis by (simp add: root_def) -qed (insert `0 < n` root_sgn_power[of n 0], simp) +qed (insert \0 < n\ root_sgn_power[of n 0], simp) lemma split_root: "P (root n x) \ (n = 0 \ P 0) \ (0 < n \ (\y. sgn y * \y\^n = x \ P y))" apply (cases "n = 0") @@ -151,7 +151,7 @@ lemma real_root_one [simp]: "0 < n \ root n 1 = 1" by (simp add: real_root_pos_unique) -text {* Root function is strictly monotonic, hence injective *} +text \Root function is strictly monotonic, hence injective\ lemma real_root_le_mono: "\0 < n; x \ y\ \ root n x \ root n y" by (auto simp add: order_le_less real_root_less_mono) @@ -195,7 +195,7 @@ lemma real_root_eq_1_iff [simp]: "0 < n \ (root n x = 1) = (x = 1)" by (insert real_root_eq_iff [where y=1], simp) -text {* Roots of multiplication and division *} +text \Roots of multiplication and division\ lemma real_root_mult: "root n (x * y) = root n x * root n y" by (auto split: split_root elim!: sgn_power_injE simp: sgn_mult abs_mult power_mult_distrib) @@ -212,7 +212,7 @@ lemma real_root_power: "0 < n \ root n (x ^ k) = root n x ^ k" by (induct k) (simp_all add: real_root_mult) -text {* Roots of roots *} +text \Roots of roots\ lemma real_root_Suc_0 [simp]: "root (Suc 0) x = x" by (simp add: odd_real_root_unique) @@ -224,7 +224,7 @@ lemma real_root_commute: "root m (root n x) = root n (root m x)" by (simp add: real_root_mult_exp [symmetric] mult.commute) -text {* Monotonicity in first argument *} +text \Monotonicity in first argument\ lemma real_root_strict_decreasing: "\0 < n; n < N; 1 < x\ \ root N x < root n x" @@ -248,7 +248,7 @@ "\0 < n; n < N; 0 \ x; x \ 1\ \ root n x \ root N x" by (auto simp add: order_le_less real_root_strict_increasing) -text {* Continuity and derivatives *} +text \Continuity and derivatives\ lemma isCont_real_root: "isCont (root n) x" proof cases @@ -320,8 +320,8 @@ show "\y. x - 1 < y \ y < 0 \ - (root n y ^ n) = y" proof (rule allI, rule impI, erule conjE) fix y assume "x - 1 < y" and "y < 0" - hence "root n (-y) ^ n = -y" using `0 < n` by simp - with real_root_minus and `even n` + hence "root n (-y) ^ n = -y" using \0 < n\ by simp + with real_root_minus and \even n\ show "- (root n y ^ n) = y" by simp qed next @@ -342,7 +342,7 @@ DERIV_odd_real_root[THEN DERIV_cong] DERIV_even_real_root[THEN DERIV_cong]) -subsection {* Square Root *} +subsection \Square Root\ definition sqrt :: "real \ real" where "sqrt = root 2" @@ -546,7 +546,7 @@ by (rule filterlim_at_top_at_top[where Q="\x. True" and P="\x. 0 < x" and g="power2"]) (auto intro: eventually_gt_at_top) -subsection {* Square Root of Sum of Squares *} +subsection \Square Root of Sum of Squares\ lemma sum_squares_bound: fixes x:: "'a::linordered_field" @@ -635,8 +635,8 @@ by (metis not_less not_less_iff_gr_or_eq numeral_less_iff real_sqrt_four real_sqrt_le_iff semiring_norm(75) semiring_norm(78) semiring_norm(85)) -text{*Needed for the infinitely close relation over the nonstandard - complex numbers*} +text\Needed for the infinitely close relation over the nonstandard + complex numbers\ lemma lemma_sqrt_hcomplex_capprox: "[| 0 < u; x < u/2; y < u/2; 0 \ x; 0 \ y |] ==> sqrt (x\<^sup>2 + y\<^sup>2) < u" apply (rule real_sqrt_sum_squares_less) @@ -659,20 +659,20 @@ (simp_all add: at_infinity_eq_at_top_bot) { fix n :: nat assume "2 < n" have "1 + (real (n - 1) * n) / 2 * x n^2 = 1 + of_nat (n choose 2) * x n^2" - using `2 < n` unfolding gbinomial_def binomial_gbinomial + using \2 < n\ unfolding gbinomial_def binomial_gbinomial by (simp add: atLeast0AtMost atMost_Suc field_simps real_of_nat_diff numeral_2_eq_2 real_eq_of_nat[symmetric]) also have "\ \ (\k\{0, 2}. of_nat (n choose k) * x n^k)" by (simp add: x_def) also have "\ \ (\k=0..n. of_nat (n choose k) * x n^k)" - using `2 < n` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) + using \2 < n\ by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) also have "\ = (x n + 1) ^ n" by (simp add: binomial_ring) also have "\ = n" - using `2 < n` by (simp add: x_def) + using \2 < n\ by (simp add: x_def) finally have "real (n - 1) * (real n / 2 * (x n)\<^sup>2) \ real (n - 1) * 1" by simp then have "(x n)\<^sup>2 \ 2 / real n" - using `2 < n` unfolding mult_le_cancel_left by (simp add: field_simps) + using \2 < n\ unfolding mult_le_cancel_left by (simp add: field_simps) from real_sqrt_le_mono[OF this] have "x n \ sqrt (2 / real n)" by simp } then show "eventually (\n. x n \ sqrt (2 / real n)) sequentially" @@ -697,21 +697,21 @@ (simp_all add: at_infinity_eq_at_top_bot) { fix n :: nat assume "1 < n" have "1 + x n * n = 1 + of_nat (n choose 1) * x n^1" - using `1 < n` unfolding gbinomial_def binomial_gbinomial by (simp add: real_eq_of_nat[symmetric]) + using \1 < n\ unfolding gbinomial_def binomial_gbinomial by (simp add: real_eq_of_nat[symmetric]) also have "\ \ (\k\{0, 1}. of_nat (n choose k) * x n^k)" by (simp add: x_def) also have "\ \ (\k=0..n. of_nat (n choose k) * x n^k)" - using `1 < n` `1 \ c` by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) + using \1 < n\ \1 \ c\ by (intro setsum_mono2) (auto intro!: mult_nonneg_nonneg zero_le_power simp: x_def le_diff_eq) also have "\ = (x n + 1) ^ n" by (simp add: binomial_ring) also have "\ = c" - using `1 < n` `1 \ c` by (simp add: x_def) + using \1 < n\ \1 \ c\ by (simp add: x_def) finally have "x n \ c / n" - using `1 \ c` `1 < n` by (simp add: field_simps) } + using \1 \ c\ \1 < n\ by (simp add: field_simps) } then show "eventually (\n. x n \ c / n) sequentially" by (auto intro!: exI[of _ 3] simp: eventually_sequentially) show "eventually (\n. 0 \ x n) sequentially" - using `1 \ c` by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def) + using \1 \ c\ by (auto intro!: exI[of _ 1] simp: eventually_sequentially le_diff_eq x_def) qed from tendsto_add[OF this tendsto_const[of 1]] have "(\n. root n c) ----> 1" by (simp add: x_def) } @@ -722,10 +722,10 @@ assume "1 \ c" with ge_1 show ?thesis by blast next assume "\ 1 \ c" - with `0 < c` have "1 \ 1 / c" + with \0 < c\ have "1 \ 1 / c" by simp then have "(\n. 1 / root n (1 / c)) ----> 1 / 1" - by (intro tendsto_divide tendsto_const ge_1 `1 \ 1 / c` one_neq_zero) + by (intro tendsto_divide tendsto_const ge_1 \1 \ 1 / c\ one_neq_zero) then show ?thesis by (rule filterlim_cong[THEN iffD1, rotated 3]) (auto intro!: exI[of _ 1] simp: eventually_sequentially real_root_divide)