src/HOL/Hyperreal/Transcendental.thy
 author huffman Thu May 31 22:23:50 2007 +0200 (2007-05-31) changeset 23176 40a760921d94 parent 23127 56ee8105c002 child 23177 3004310c95b1 permissions -rw-r--r--
simplify some proofs
 paulson@12196 ` 1` ```(* Title : Transcendental.thy ``` paulson@12196 ` 2` ``` Author : Jacques D. Fleuriot ``` paulson@12196 ` 3` ``` Copyright : 1998,1999 University of Cambridge ``` paulson@13958 ` 4` ``` 1999,2001 University of Edinburgh ``` paulson@15077 ` 5` ``` Conversion to Isar and new proofs by Lawrence C Paulson, 2004 ``` paulson@12196 ` 6` ```*) ``` paulson@12196 ` 7` paulson@15077 ` 8` ```header{*Power Series, Transcendental Functions etc.*} ``` paulson@15077 ` 9` nipkow@15131 ` 10` ```theory Transcendental ``` huffman@22654 ` 11` ```imports NthRoot Fact Series EvenOdd Deriv ``` nipkow@15131 ` 12` ```begin ``` paulson@15077 ` 13` huffman@23043 ` 14` ```subsection{*Properties of Power Series*} ``` paulson@15077 ` 15` huffman@23082 ` 16` ```lemma lemma_realpow_diff: ``` huffman@23082 ` 17` ``` fixes y :: "'a::recpower" ``` huffman@23082 ` 18` ``` shows "p \ n \ y ^ (Suc n - p) = (y ^ (n - p)) * y" ``` huffman@23082 ` 19` ```proof - ``` huffman@23082 ` 20` ``` assume "p \ n" ``` huffman@23082 ` 21` ``` hence "Suc n - p = Suc (n - p)" by (rule Suc_diff_le) ``` huffman@23082 ` 22` ``` thus ?thesis by (simp add: power_Suc power_commutes) ``` huffman@23082 ` 23` ```qed ``` paulson@15077 ` 24` paulson@15077 ` 25` ```lemma lemma_realpow_diff_sumr: ``` huffman@23082 ` 26` ``` fixes y :: "'a::{recpower,comm_semiring_0}" shows ``` huffman@23082 ` 27` ``` "(\p=0..p=0..p=0..p=0..p=0..z\ < \x\"}.*} ``` paulson@15077 ` 57` paulson@15077 ` 58` ```lemma powser_insidea: ``` huffman@23082 ` 59` ``` fixes x z :: "'a::{real_normed_field,banach,recpower}" ``` huffman@20849 ` 60` ``` assumes 1: "summable (\n. f n * x ^ n)" ``` huffman@23082 ` 61` ``` assumes 2: "norm z < norm x" ``` huffman@23082 ` 62` ``` shows "summable (\n. norm (f n * z ^ n))" ``` huffman@20849 ` 63` ```proof - ``` huffman@20849 ` 64` ``` from 2 have x_neq_0: "x \ 0" by clarsimp ``` huffman@20849 ` 65` ``` from 1 have "(\n. f n * x ^ n) ----> 0" ``` huffman@20849 ` 66` ``` by (rule summable_LIMSEQ_zero) ``` huffman@20849 ` 67` ``` hence "convergent (\n. f n * x ^ n)" ``` huffman@20849 ` 68` ``` by (rule convergentI) ``` huffman@20849 ` 69` ``` hence "Cauchy (\n. f n * x ^ n)" ``` huffman@20849 ` 70` ``` by (simp add: Cauchy_convergent_iff) ``` huffman@20849 ` 71` ``` hence "Bseq (\n. f n * x ^ n)" ``` huffman@20849 ` 72` ``` by (rule Cauchy_Bseq) ``` huffman@23082 ` 73` ``` then obtain K where 3: "0 < K" and 4: "\n. norm (f n * x ^ n) \ K" ``` huffman@20849 ` 74` ``` by (simp add: Bseq_def, safe) ``` huffman@23082 ` 75` ``` have "\N. \n\N. norm (norm (f n * z ^ n)) \ ``` huffman@23082 ` 76` ``` K * norm (z ^ n) * inverse (norm (x ^ n))" ``` huffman@20849 ` 77` ``` proof (intro exI allI impI) ``` huffman@20849 ` 78` ``` fix n::nat assume "0 \ n" ``` huffman@23082 ` 79` ``` have "norm (norm (f n * z ^ n)) * norm (x ^ n) = ``` huffman@23082 ` 80` ``` norm (f n * x ^ n) * norm (z ^ n)" ``` huffman@23082 ` 81` ``` by (simp add: norm_mult abs_mult) ``` huffman@23082 ` 82` ``` also have "\ \ K * norm (z ^ n)" ``` huffman@23082 ` 83` ``` by (simp only: mult_right_mono 4 norm_ge_zero) ``` huffman@23082 ` 84` ``` also have "\ = K * norm (z ^ n) * (inverse (norm (x ^ n)) * norm (x ^ n))" ``` huffman@20849 ` 85` ``` by (simp add: x_neq_0) ``` huffman@23082 ` 86` ``` also have "\ = K * norm (z ^ n) * inverse (norm (x ^ n)) * norm (x ^ n)" ``` huffman@20849 ` 87` ``` by (simp only: mult_assoc) ``` huffman@23082 ` 88` ``` finally show "norm (norm (f n * z ^ n)) \ ``` huffman@23082 ` 89` ``` K * norm (z ^ n) * inverse (norm (x ^ n))" ``` huffman@20849 ` 90` ``` by (simp add: mult_le_cancel_right x_neq_0) ``` huffman@20849 ` 91` ``` qed ``` huffman@23082 ` 92` ``` moreover have "summable (\n. K * norm (z ^ n) * inverse (norm (x ^ n)))" ``` huffman@20849 ` 93` ``` proof - ``` huffman@23082 ` 94` ``` from 2 have "norm (norm (z * inverse x)) < 1" ``` huffman@23082 ` 95` ``` using x_neq_0 ``` huffman@23082 ` 96` ``` by (simp add: nonzero_norm_divide divide_inverse [symmetric]) ``` huffman@23082 ` 97` ``` hence "summable (\n. norm (z * inverse x) ^ n)" ``` huffman@20849 ` 98` ``` by (rule summable_geometric) ``` huffman@23082 ` 99` ``` hence "summable (\n. K * norm (z * inverse x) ^ n)" ``` huffman@20849 ` 100` ``` by (rule summable_mult) ``` huffman@23082 ` 101` ``` thus "summable (\n. K * norm (z ^ n) * inverse (norm (x ^ n)))" ``` huffman@23082 ` 102` ``` using x_neq_0 ``` huffman@23082 ` 103` ``` by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib ``` huffman@23082 ` 104` ``` power_inverse norm_power mult_assoc) ``` huffman@20849 ` 105` ``` qed ``` huffman@23082 ` 106` ``` ultimately show "summable (\n. norm (f n * z ^ n))" ``` huffman@20849 ` 107` ``` by (rule summable_comparison_test) ``` huffman@20849 ` 108` ```qed ``` paulson@15077 ` 109` paulson@15229 ` 110` ```lemma powser_inside: ``` huffman@23082 ` 111` ``` fixes f :: "nat \ 'a::{real_normed_field,banach,recpower}" shows ``` huffman@23082 ` 112` ``` "[| summable (%n. f(n) * (x ^ n)); norm z < norm x |] ``` paulson@15077 ` 113` ``` ==> summable (%n. f(n) * (z ^ n))" ``` huffman@23082 ` 114` ```by (rule powser_insidea [THEN summable_norm_cancel]) ``` paulson@15077 ` 115` paulson@15077 ` 116` huffman@23043 ` 117` ```subsection{*Term-by-Term Differentiability of Power Series*} ``` huffman@23043 ` 118` huffman@23043 ` 119` ```definition ``` huffman@23082 ` 120` ``` diffs :: "(nat => 'a::ring_1) => nat => 'a" where ``` huffman@23082 ` 121` ``` "diffs c = (%n. of_nat (Suc n) * c(Suc n))" ``` paulson@15077 ` 122` paulson@15077 ` 123` ```text{*Lemma about distributing negation over it*} ``` paulson@15077 ` 124` ```lemma diffs_minus: "diffs (%n. - c n) = (%n. - diffs c n)" ``` paulson@15077 ` 125` ```by (simp add: diffs_def) ``` paulson@15077 ` 126` paulson@15077 ` 127` ```text{*Show that we can shift the terms down one*} ``` paulson@15077 ` 128` ```lemma lemma_diffs: ``` nipkow@15539 ` 129` ``` "(\n=0..n=0..n=0..n=0.. ``` huffman@23082 ` 145` ``` (%n. of_nat n * c(n) * (x ^ (n - Suc 0))) sums ``` nipkow@15546 ` 146` ``` (\n. (diffs c)(n) * (x ^ n))" ``` huffman@23082 ` 147` ```apply (subgoal_tac " (%n. of_nat n * c (n) * (x ^ (n - Suc 0))) ----> 0") ``` paulson@15077 ` 148` ```apply (rule_tac [2] LIMSEQ_imp_Suc) ``` paulson@15077 ` 149` ```apply (drule summable_sums) ``` paulson@15077 ` 150` ```apply (auto simp add: sums_def) ``` paulson@15077 ` 151` ```apply (drule_tac X="(\n. \n = 0..p=0..p=0.. (\d. n = m + d + Suc 0)" ``` paulson@15077 ` 164` ```by (simp add: less_iff_Suc_add) ``` paulson@15077 ` 165` paulson@15077 ` 166` ```lemma sumdiff: "a + b - (c + d) = a - c + b - (d::real)" ``` paulson@15077 ` 167` ```by arith ``` paulson@15077 ` 168` huffman@23082 ` 169` ```lemma sumr_diff_mult_const2: ``` huffman@23082 ` 170` ``` "setsum f {0..i = 0.. 0" shows ``` huffman@23082 ` 176` ``` "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = ``` huffman@20860 ` 177` ``` h * (\p=0..< n - Suc 0. \q=0..< n - Suc 0 - p. ``` huffman@23082 ` 178` ``` (z + h) ^ q * z ^ (n - 2 - q))" (is "?lhs = ?rhs") ``` huffman@23082 ` 179` ```apply (subgoal_tac "h * ?lhs = h * ?rhs", simp add: h) ``` huffman@20860 ` 180` ```apply (simp add: right_diff_distrib diff_divide_distrib h) ``` huffman@23112 ` 181` ```apply (simp only: times_divide_eq_left [symmetric]) ``` huffman@23112 ` 182` ```apply (simp add: divide_self [OF h]) ``` paulson@15077 ` 183` ```apply (simp add: mult_assoc [symmetric]) ``` huffman@20860 ` 184` ```apply (cases "n", simp) ``` huffman@20860 ` 185` ```apply (simp add: lemma_realpow_diff_sumr2 h ``` huffman@20860 ` 186` ``` right_diff_distrib [symmetric] mult_assoc ``` huffman@23082 ` 187` ``` del: realpow_Suc setsum_op_ivl_Suc of_nat_Suc) ``` huffman@20860 ` 188` ```apply (subst lemma_realpow_rev_sumr) ``` huffman@23082 ` 189` ```apply (subst sumr_diff_mult_const2) ``` huffman@20860 ` 190` ```apply simp ``` huffman@20860 ` 191` ```apply (simp only: lemma_termdiff1 setsum_right_distrib) ``` huffman@20860 ` 192` ```apply (rule setsum_cong [OF refl]) ``` nipkow@15539 ` 193` ```apply (simp add: diff_minus [symmetric] less_iff_Suc_add) ``` huffman@20860 ` 194` ```apply (clarify) ``` huffman@20860 ` 195` ```apply (simp add: setsum_right_distrib lemma_realpow_diff_sumr2 mult_ac ``` huffman@20860 ` 196` ``` del: setsum_op_ivl_Suc realpow_Suc) ``` huffman@20860 ` 197` ```apply (subst mult_assoc [symmetric], subst power_add [symmetric]) ``` huffman@20860 ` 198` ```apply (simp add: mult_ac) ``` huffman@20860 ` 199` ```done ``` huffman@20860 ` 200` huffman@20860 ` 201` ```lemma real_setsum_nat_ivl_bounded2: ``` huffman@23082 ` 202` ``` fixes K :: "'a::ordered_semidom" ``` huffman@23082 ` 203` ``` assumes f: "\p::nat. p < n \ f p \ K" ``` huffman@23082 ` 204` ``` assumes K: "0 \ K" ``` huffman@23082 ` 205` ``` shows "setsum f {0.. of_nat n * K" ``` huffman@23082 ` 206` ```apply (rule order_trans [OF setsum_mono]) ``` huffman@23082 ` 207` ```apply (rule f, simp) ``` huffman@23082 ` 208` ```apply (simp add: mult_right_mono K) ``` paulson@15077 ` 209` ```done ``` paulson@15077 ` 210` paulson@15229 ` 211` ```lemma lemma_termdiff3: ``` huffman@23112 ` 212` ``` fixes h z :: "'a::{real_normed_field,recpower}" ``` huffman@20860 ` 213` ``` assumes 1: "h \ 0" ``` huffman@23082 ` 214` ``` assumes 2: "norm z \ K" ``` huffman@23082 ` 215` ``` assumes 3: "norm (z + h) \ K" ``` huffman@23082 ` 216` ``` shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) ``` huffman@23082 ` 217` ``` \ of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" ``` huffman@20860 ` 218` ```proof - ``` huffman@23082 ` 219` ``` have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = ``` huffman@23082 ` 220` ``` norm (\p = 0..q = 0.. \ of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2)) * norm h" ``` huffman@23082 ` 227` ``` proof (rule mult_right_mono [OF _ norm_ge_zero]) ``` huffman@23082 ` 228` ``` from norm_ge_zero 2 have K: "0 \ K" by (rule order_trans) ``` huffman@23082 ` 229` ``` have le_Kn: "\i j n. i + j = n \ norm ((z + h) ^ i * z ^ j) \ K ^ n" ``` huffman@20860 ` 230` ``` apply (erule subst) ``` huffman@23082 ` 231` ``` apply (simp only: norm_mult norm_power power_add) ``` huffman@23082 ` 232` ``` apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) ``` huffman@20860 ` 233` ``` done ``` huffman@23082 ` 234` ``` show "norm (\p = 0..q = 0.. of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" ``` huffman@20860 ` 237` ``` apply (intro ``` huffman@23082 ` 238` ``` order_trans [OF norm_setsum] ``` huffman@20860 ` 239` ``` real_setsum_nat_ivl_bounded2 ``` huffman@20860 ` 240` ``` mult_nonneg_nonneg ``` huffman@23082 ` 241` ``` zero_le_imp_of_nat ``` huffman@20860 ` 242` ``` zero_le_power K) ``` huffman@20860 ` 243` ``` apply (rule le_Kn, simp) ``` huffman@20860 ` 244` ``` done ``` huffman@20860 ` 245` ``` qed ``` huffman@23082 ` 246` ``` also have "\ = of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" ``` huffman@20860 ` 247` ``` by (simp only: mult_assoc) ``` huffman@20860 ` 248` ``` finally show ?thesis . ``` huffman@20860 ` 249` ```qed ``` paulson@15077 ` 250` huffman@20860 ` 251` ```lemma lemma_termdiff4: ``` huffman@23112 ` 252` ``` fixes f :: "'a::{real_normed_field,recpower} \ ``` huffman@23082 ` 253` ``` 'b::real_normed_vector" ``` huffman@20860 ` 254` ``` assumes k: "0 < (k::real)" ``` huffman@23082 ` 255` ``` assumes le: "\h. \h \ 0; norm h < k\ \ norm (f h) \ K * norm h" ``` huffman@20860 ` 256` ``` shows "f -- 0 --> 0" ``` huffman@20860 ` 257` ```proof (simp add: LIM_def, safe) ``` huffman@20860 ` 258` ``` fix r::real assume r: "0 < r" ``` huffman@20860 ` 259` ``` have zero_le_K: "0 \ K" ``` huffman@20860 ` 260` ``` apply (cut_tac k) ``` huffman@23082 ` 261` ``` apply (cut_tac h="of_real (k/2)" in le, simp) ``` huffman@23082 ` 262` ``` apply (simp del: of_real_divide) ``` huffman@23082 ` 263` ``` apply (drule order_trans [OF norm_ge_zero]) ``` huffman@23082 ` 264` ``` apply (simp add: zero_le_mult_iff) ``` huffman@20860 ` 265` ``` done ``` huffman@23082 ` 266` ``` show "\s. 0 < s \ (\x. x \ 0 \ norm x < s \ norm (f x) < r)" ``` huffman@20860 ` 267` ``` proof (cases) ``` huffman@20860 ` 268` ``` assume "K = 0" ``` huffman@23082 ` 269` ``` with k r le have "0 < k \ (\x. x \ 0 \ norm x < k \ norm (f x) < r)" ``` huffman@20860 ` 270` ``` by simp ``` huffman@23082 ` 271` ``` thus "\s. 0 < s \ (\x. x \ 0 \ norm x < s \ norm (f x) < r)" .. ``` huffman@20860 ` 272` ``` next ``` huffman@20860 ` 273` ``` assume K_neq_zero: "K \ 0" ``` huffman@20860 ` 274` ``` with zero_le_K have K: "0 < K" by simp ``` huffman@23082 ` 275` ``` show "\s. 0 < s \ (\x. x \ 0 \ norm x < s \ norm (f x) < r)" ``` huffman@20860 ` 276` ``` proof (rule exI, safe) ``` huffman@20860 ` 277` ``` from k r K show "0 < min k (r * inverse K / 2)" ``` huffman@20860 ` 278` ``` by (simp add: mult_pos_pos positive_imp_inverse_positive) ``` huffman@20860 ` 279` ``` next ``` huffman@23082 ` 280` ``` fix x::'a ``` huffman@23082 ` 281` ``` assume x1: "x \ 0" and x2: "norm x < min k (r * inverse K / 2)" ``` huffman@23082 ` 282` ``` from x2 have x3: "norm x < k" and x4: "norm x < r * inverse K / 2" ``` huffman@20860 ` 283` ``` by simp_all ``` huffman@23082 ` 284` ``` from x1 x3 le have "norm (f x) \ K * norm x" by simp ``` huffman@23082 ` 285` ``` also from x4 K have "K * norm x < K * (r * inverse K / 2)" ``` huffman@20860 ` 286` ``` by (rule mult_strict_left_mono) ``` huffman@20860 ` 287` ``` also have "\ = r / 2" ``` huffman@20860 ` 288` ``` using K_neq_zero by simp ``` huffman@20860 ` 289` ``` also have "r / 2 < r" ``` huffman@20860 ` 290` ``` using r by simp ``` huffman@23082 ` 291` ``` finally show "norm (f x) < r" . ``` huffman@20860 ` 292` ``` qed ``` huffman@20860 ` 293` ``` qed ``` huffman@20860 ` 294` ```qed ``` paulson@15077 ` 295` paulson@15229 ` 296` ```lemma lemma_termdiff5: ``` huffman@23112 ` 297` ``` fixes g :: "'a::{recpower,real_normed_field} \ ``` huffman@23082 ` 298` ``` nat \ 'b::banach" ``` huffman@20860 ` 299` ``` assumes k: "0 < (k::real)" ``` huffman@20860 ` 300` ``` assumes f: "summable f" ``` huffman@23082 ` 301` ``` assumes le: "\h n. \h \ 0; norm h < k\ \ norm (g h n) \ f n * norm h" ``` huffman@20860 ` 302` ``` shows "(\h. suminf (g h)) -- 0 --> 0" ``` huffman@20860 ` 303` ```proof (rule lemma_termdiff4 [OF k]) ``` huffman@23082 ` 304` ``` fix h::'a assume "h \ 0" and "norm h < k" ``` huffman@23082 ` 305` ``` hence A: "\n. norm (g h n) \ f n * norm h" ``` huffman@20860 ` 306` ``` by (simp add: le) ``` huffman@23082 ` 307` ``` hence "\N. \n\N. norm (norm (g h n)) \ f n * norm h" ``` huffman@20860 ` 308` ``` by simp ``` huffman@23082 ` 309` ``` moreover from f have B: "summable (\n. f n * norm h)" ``` huffman@20860 ` 310` ``` by (rule summable_mult2) ``` huffman@23082 ` 311` ``` ultimately have C: "summable (\n. norm (g h n))" ``` huffman@20860 ` 312` ``` by (rule summable_comparison_test) ``` huffman@23082 ` 313` ``` hence "norm (suminf (g h)) \ (\n. norm (g h n))" ``` huffman@23082 ` 314` ``` by (rule summable_norm) ``` huffman@23082 ` 315` ``` also from A C B have "(\n. norm (g h n)) \ (\n. f n * norm h)" ``` huffman@20860 ` 316` ``` by (rule summable_le) ``` huffman@23082 ` 317` ``` also from f have "(\n. f n * norm h) = suminf f * norm h" ``` huffman@20860 ` 318` ``` by (rule suminf_mult2 [symmetric]) ``` huffman@23082 ` 319` ``` finally show "norm (suminf (g h)) \ suminf f * norm h" . ``` huffman@20860 ` 320` ```qed ``` paulson@15077 ` 321` paulson@15077 ` 322` paulson@15077 ` 323` ```text{* FIXME: Long proofs*} ``` paulson@15077 ` 324` paulson@15077 ` 325` ```lemma termdiffs_aux: ``` huffman@23112 ` 326` ``` fixes x :: "'a::{recpower,real_normed_field,banach}" ``` huffman@20849 ` 327` ``` assumes 1: "summable (\n. diffs (diffs c) n * K ^ n)" ``` huffman@23082 ` 328` ``` assumes 2: "norm x < norm K" ``` huffman@20860 ` 329` ``` shows "(\h. \n. c n * (((x + h) ^ n - x ^ n) / h ``` huffman@23082 ` 330` ``` - of_nat n * x ^ (n - Suc 0))) -- 0 --> 0" ``` huffman@20849 ` 331` ```proof - ``` huffman@20860 ` 332` ``` from dense [OF 2] ``` huffman@23082 ` 333` ``` obtain r where r1: "norm x < r" and r2: "r < norm K" by fast ``` huffman@23082 ` 334` ``` from norm_ge_zero r1 have r: "0 < r" ``` huffman@20860 ` 335` ``` by (rule order_le_less_trans) ``` huffman@20860 ` 336` ``` hence r_neq_0: "r \ 0" by simp ``` huffman@20860 ` 337` ``` show ?thesis ``` huffman@20849 ` 338` ``` proof (rule lemma_termdiff5) ``` huffman@23082 ` 339` ``` show "0 < r - norm x" using r1 by simp ``` huffman@20849 ` 340` ``` next ``` huffman@23082 ` 341` ``` from r r2 have "norm (of_real r::'a) < norm K" ``` huffman@23082 ` 342` ``` by simp ``` huffman@23082 ` 343` ``` with 1 have "summable (\n. norm (diffs (diffs c) n * (of_real r ^ n)))" ``` huffman@20860 ` 344` ``` by (rule powser_insidea) ``` huffman@23082 ` 345` ``` hence "summable (\n. diffs (diffs (\n. norm (c n))) n * r ^ n)" ``` huffman@23082 ` 346` ``` using r ``` huffman@23082 ` 347` ``` by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc) ``` huffman@23082 ` 348` ``` hence "summable (\n. of_nat n * diffs (\n. norm (c n)) n * r ^ (n - Suc 0))" ``` huffman@20860 ` 349` ``` by (rule diffs_equiv [THEN sums_summable]) ``` huffman@23082 ` 350` ``` also have "(\n. of_nat n * diffs (\n. norm (c n)) n * r ^ (n - Suc 0)) ``` huffman@23082 ` 351` ``` = (\n. diffs (%m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))" ``` huffman@20849 ` 352` ``` apply (rule ext) ``` huffman@20849 ` 353` ``` apply (simp add: diffs_def) ``` huffman@20849 ` 354` ``` apply (case_tac n, simp_all add: r_neq_0) ``` huffman@20849 ` 355` ``` done ``` huffman@20860 ` 356` ``` finally have "summable ``` huffman@23082 ` 357` ``` (\n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" ``` huffman@20860 ` 358` ``` by (rule diffs_equiv [THEN sums_summable]) ``` huffman@20860 ` 359` ``` also have ``` huffman@23082 ` 360` ``` "(\n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * ``` huffman@20860 ` 361` ``` r ^ (n - Suc 0)) = ``` huffman@23082 ` 362` ``` (\n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" ``` huffman@20849 ` 363` ``` apply (rule ext) ``` huffman@20849 ` 364` ``` apply (case_tac "n", simp) ``` huffman@20849 ` 365` ``` apply (case_tac "nat", simp) ``` huffman@20849 ` 366` ``` apply (simp add: r_neq_0) ``` huffman@20849 ` 367` ``` done ``` huffman@20860 ` 368` ``` finally show ``` huffman@23082 ` 369` ``` "summable (\n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" . ``` huffman@20849 ` 370` ``` next ``` huffman@23082 ` 371` ``` fix h::'a and n::nat ``` huffman@20860 ` 372` ``` assume h: "h \ 0" ``` huffman@23082 ` 373` ``` assume "norm h < r - norm x" ``` huffman@23082 ` 374` ``` hence "norm x + norm h < r" by simp ``` huffman@23082 ` 375` ``` with norm_triangle_ineq have xh: "norm (x + h) < r" ``` huffman@20860 ` 376` ``` by (rule order_le_less_trans) ``` huffman@23082 ` 377` ``` show "norm (c n * (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0))) ``` huffman@23082 ` 378` ``` \ norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h" ``` huffman@23082 ` 379` ``` apply (simp only: norm_mult mult_assoc) ``` huffman@23082 ` 380` ``` apply (rule mult_left_mono [OF _ norm_ge_zero]) ``` huffman@20860 ` 381` ``` apply (simp (no_asm) add: mult_assoc [symmetric]) ``` huffman@20860 ` 382` ``` apply (rule lemma_termdiff3) ``` huffman@20860 ` 383` ``` apply (rule h) ``` huffman@20860 ` 384` ``` apply (rule r1 [THEN order_less_imp_le]) ``` huffman@20860 ` 385` ``` apply (rule xh [THEN order_less_imp_le]) ``` huffman@20860 ` 386` ``` done ``` huffman@20849 ` 387` ``` qed ``` huffman@20849 ` 388` ```qed ``` webertj@20217 ` 389` huffman@20860 ` 390` ```lemma termdiffs: ``` huffman@23112 ` 391` ``` fixes K x :: "'a::{recpower,real_normed_field,banach}" ``` huffman@20860 ` 392` ``` assumes 1: "summable (\n. c n * K ^ n)" ``` huffman@20860 ` 393` ``` assumes 2: "summable (\n. (diffs c) n * K ^ n)" ``` huffman@20860 ` 394` ``` assumes 3: "summable (\n. (diffs (diffs c)) n * K ^ n)" ``` huffman@23082 ` 395` ``` assumes 4: "norm x < norm K" ``` huffman@20860 ` 396` ``` shows "DERIV (\x. \n. c n * x ^ n) x :> (\n. (diffs c) n * x ^ n)" ``` huffman@20860 ` 397` ```proof (simp add: deriv_def, rule LIM_zero_cancel) ``` huffman@20860 ` 398` ``` show "(\h. (suminf (\n. c n * (x + h) ^ n) - suminf (\n. c n * x ^ n)) / h ``` huffman@20860 ` 399` ``` - suminf (\n. diffs c n * x ^ n)) -- 0 --> 0" ``` huffman@20860 ` 400` ``` proof (rule LIM_equal2) ``` huffman@23082 ` 401` ``` show "0 < norm K - norm x" by (simp add: less_diff_eq 4) ``` huffman@20860 ` 402` ``` next ``` huffman@23082 ` 403` ``` fix h :: 'a ``` huffman@20860 ` 404` ``` assume "h \ 0" ``` huffman@23082 ` 405` ``` assume "norm (h - 0) < norm K - norm x" ``` huffman@23082 ` 406` ``` hence "norm x + norm h < norm K" by simp ``` huffman@23082 ` 407` ``` hence 5: "norm (x + h) < norm K" ``` huffman@23082 ` 408` ``` by (rule norm_triangle_ineq [THEN order_le_less_trans]) ``` huffman@20860 ` 409` ``` have A: "summable (\n. c n * x ^ n)" ``` huffman@20860 ` 410` ``` by (rule powser_inside [OF 1 4]) ``` huffman@20860 ` 411` ``` have B: "summable (\n. c n * (x + h) ^ n)" ``` huffman@20860 ` 412` ``` by (rule powser_inside [OF 1 5]) ``` huffman@20860 ` 413` ``` have C: "summable (\n. diffs c n * x ^ n)" ``` huffman@20860 ` 414` ``` by (rule powser_inside [OF 2 4]) ``` huffman@20860 ` 415` ``` show "((\n. c n * (x + h) ^ n) - (\n. c n * x ^ n)) / h ``` huffman@20860 ` 416` ``` - (\n. diffs c n * x ^ n) = ``` huffman@23082 ` 417` ``` (\n. c n * (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0)))" ``` huffman@20860 ` 418` ``` apply (subst sums_unique [OF diffs_equiv [OF C]]) ``` huffman@20860 ` 419` ``` apply (subst suminf_diff [OF B A]) ``` huffman@20860 ` 420` ``` apply (subst suminf_divide [symmetric]) ``` huffman@20860 ` 421` ``` apply (rule summable_diff [OF B A]) ``` huffman@20860 ` 422` ``` apply (subst suminf_diff) ``` huffman@20860 ` 423` ``` apply (rule summable_divide) ``` huffman@20860 ` 424` ``` apply (rule summable_diff [OF B A]) ``` huffman@20860 ` 425` ``` apply (rule sums_summable [OF diffs_equiv [OF C]]) ``` huffman@20860 ` 426` ``` apply (rule_tac f="suminf" in arg_cong) ``` huffman@20860 ` 427` ``` apply (rule ext) ``` huffman@20860 ` 428` ``` apply (simp add: ring_eq_simps) ``` huffman@20860 ` 429` ``` done ``` huffman@20860 ` 430` ``` next ``` huffman@20860 ` 431` ``` show "(\h. \n. c n * (((x + h) ^ n - x ^ n) / h - ``` huffman@23082 ` 432` ``` of_nat n * x ^ (n - Suc 0))) -- 0 --> 0" ``` huffman@20860 ` 433` ``` by (rule termdiffs_aux [OF 3 4]) ``` huffman@20860 ` 434` ``` qed ``` huffman@20860 ` 435` ```qed ``` huffman@20860 ` 436` paulson@15077 ` 437` huffman@23043 ` 438` ```subsection{*Exponential Function*} ``` huffman@23043 ` 439` huffman@23043 ` 440` ```definition ``` huffman@23115 ` 441` ``` exp :: "'a \ 'a::{recpower,real_normed_field,banach}" where ``` huffman@23115 ` 442` ``` "exp x = (\n. x ^ n /# real (fact n))" ``` huffman@23043 ` 443` huffman@23043 ` 444` ```definition ``` huffman@23043 ` 445` ``` sin :: "real => real" where ``` huffman@23043 ` 446` ``` "sin x = (\n. (if even(n) then 0 else ``` huffman@23043 ` 447` ``` ((- 1) ^ ((n - Suc 0) div 2))/(real (fact n))) * x ^ n)" ``` huffman@23043 ` 448` ``` ``` huffman@23043 ` 449` ```definition ``` huffman@23043 ` 450` ``` cos :: "real => real" where ``` huffman@23043 ` 451` ``` "cos x = (\n. (if even(n) then ((- 1) ^ (n div 2))/(real (fact n)) ``` huffman@23043 ` 452` ``` else 0) * x ^ n)" ``` huffman@23115 ` 453` huffman@23115 ` 454` ```lemma summable_exp_generic: ``` huffman@23115 ` 455` ``` fixes x :: "'a::{real_normed_algebra_1,recpower,banach}" ``` huffman@23115 ` 456` ``` defines S_def: "S \ \n. x ^ n /# real (fact n)" ``` huffman@23115 ` 457` ``` shows "summable S" ``` huffman@23115 ` 458` ```proof - ``` huffman@23115 ` 459` ``` have S_Suc: "\n. S (Suc n) = (x * S n) /# real (Suc n)" ``` huffman@23115 ` 460` ``` unfolding S_def by (simp add: power_Suc del: mult_Suc) ``` huffman@23115 ` 461` ``` obtain r :: real where r0: "0 < r" and r1: "r < 1" ``` huffman@23115 ` 462` ``` using dense [OF zero_less_one] by fast ``` huffman@23115 ` 463` ``` obtain N :: nat where N: "norm x < real N * r" ``` huffman@23115 ` 464` ``` using reals_Archimedean3 [OF r0] by fast ``` huffman@23115 ` 465` ``` from r1 show ?thesis ``` huffman@23115 ` 466` ``` proof (rule ratio_test [rule_format]) ``` huffman@23115 ` 467` ``` fix n :: nat ``` huffman@23115 ` 468` ``` assume n: "N \ n" ``` huffman@23115 ` 469` ``` have "norm x \ real N * r" ``` huffman@23115 ` 470` ``` using N by (rule order_less_imp_le) ``` huffman@23115 ` 471` ``` also have "real N * r \ real (Suc n) * r" ``` huffman@23115 ` 472` ``` using r0 n by (simp add: mult_right_mono) ``` huffman@23115 ` 473` ``` finally have "norm x * norm (S n) \ real (Suc n) * r * norm (S n)" ``` huffman@23115 ` 474` ``` using norm_ge_zero by (rule mult_right_mono) ``` huffman@23115 ` 475` ``` hence "norm (x * S n) \ real (Suc n) * r * norm (S n)" ``` huffman@23115 ` 476` ``` by (rule order_trans [OF norm_mult_ineq]) ``` huffman@23115 ` 477` ``` hence "norm (x * S n) / real (Suc n) \ r * norm (S n)" ``` huffman@23115 ` 478` ``` by (simp add: pos_divide_le_eq mult_ac) ``` huffman@23115 ` 479` ``` thus "norm (S (Suc n)) \ r * norm (S n)" ``` huffman@23115 ` 480` ``` by (simp add: S_Suc norm_scaleR inverse_eq_divide) ``` huffman@23115 ` 481` ``` qed ``` huffman@23115 ` 482` ```qed ``` huffman@23115 ` 483` huffman@23115 ` 484` ```lemma summable_norm_exp: ``` huffman@23115 ` 485` ``` fixes x :: "'a::{real_normed_algebra_1,recpower,banach}" ``` huffman@23115 ` 486` ``` shows "summable (\n. norm (x ^ n /# real (fact n)))" ``` huffman@23115 ` 487` ```proof (rule summable_norm_comparison_test [OF exI, rule_format]) ``` huffman@23115 ` 488` ``` show "summable (\n. norm x ^ n /# real (fact n))" ``` huffman@23115 ` 489` ``` by (rule summable_exp_generic) ``` huffman@23115 ` 490` ```next ``` huffman@23115 ` 491` ``` fix n show "norm (x ^ n /# real (fact n)) \ norm x ^ n /# real (fact n)" ``` huffman@23115 ` 492` ``` by (simp add: norm_scaleR norm_power_ineq) ``` huffman@23115 ` 493` ```qed ``` huffman@23115 ` 494` huffman@23043 ` 495` ```lemma summable_exp: "summable (%n. inverse (real (fact n)) * x ^ n)" ``` huffman@23115 ` 496` ```by (insert summable_exp_generic [where x=x], simp) ``` huffman@23043 ` 497` huffman@23043 ` 498` ```lemma summable_sin: ``` huffman@23043 ` 499` ``` "summable (%n. ``` huffman@23043 ` 500` ``` (if even n then 0 ``` huffman@23043 ` 501` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * ``` huffman@23043 ` 502` ``` x ^ n)" ``` huffman@23043 ` 503` ```apply (rule_tac g = "(%n. inverse (real (fact n)) * \x\ ^ n)" in summable_comparison_test) ``` huffman@23043 ` 504` ```apply (rule_tac [2] summable_exp) ``` huffman@23043 ` 505` ```apply (rule_tac x = 0 in exI) ``` huffman@23043 ` 506` ```apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) ``` huffman@23043 ` 507` ```done ``` huffman@23043 ` 508` huffman@23043 ` 509` ```lemma summable_cos: ``` huffman@23043 ` 510` ``` "summable (%n. ``` huffman@23043 ` 511` ``` (if even n then ``` huffman@23043 ` 512` ``` (- 1) ^ (n div 2)/(real (fact n)) else 0) * x ^ n)" ``` huffman@23043 ` 513` ```apply (rule_tac g = "(%n. inverse (real (fact n)) * \x\ ^ n)" in summable_comparison_test) ``` huffman@23043 ` 514` ```apply (rule_tac [2] summable_exp) ``` huffman@23043 ` 515` ```apply (rule_tac x = 0 in exI) ``` huffman@23043 ` 516` ```apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) ``` huffman@23043 ` 517` ```done ``` huffman@23043 ` 518` huffman@23043 ` 519` ```lemma lemma_STAR_sin [simp]: ``` huffman@23043 ` 520` ``` "(if even n then 0 ``` huffman@23043 ` 521` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * 0 ^ n = 0" ``` huffman@23043 ` 522` ```by (induct "n", auto) ``` huffman@23043 ` 523` huffman@23043 ` 524` ```lemma lemma_STAR_cos [simp]: ``` huffman@23043 ` 525` ``` "0 < n --> ``` huffman@23043 ` 526` ``` (- 1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0" ``` huffman@23043 ` 527` ```by (induct "n", auto) ``` huffman@23043 ` 528` huffman@23043 ` 529` ```lemma lemma_STAR_cos1 [simp]: ``` huffman@23043 ` 530` ``` "0 < n --> ``` huffman@23043 ` 531` ``` (-1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0" ``` huffman@23043 ` 532` ```by (induct "n", auto) ``` huffman@23043 ` 533` huffman@23043 ` 534` ```lemma lemma_STAR_cos2 [simp]: ``` huffman@23043 ` 535` ``` "(\n=1..n. x ^ n /# real (fact n)) sums exp x" ``` huffman@23115 ` 542` ```unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) ``` huffman@23043 ` 543` huffman@23043 ` 544` ```lemma sin_converges: ``` huffman@23043 ` 545` ``` "(%n. (if even n then 0 ``` huffman@23043 ` 546` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * ``` huffman@23043 ` 547` ``` x ^ n) sums sin(x)" ``` huffman@23112 ` 548` ```unfolding sin_def by (rule summable_sin [THEN summable_sums]) ``` huffman@23043 ` 549` huffman@23043 ` 550` ```lemma cos_converges: ``` huffman@23043 ` 551` ``` "(%n. (if even n then ``` huffman@23043 ` 552` ``` (- 1) ^ (n div 2)/(real (fact n)) ``` huffman@23043 ` 553` ``` else 0) * x ^ n) sums cos(x)" ``` huffman@23112 ` 554` ```unfolding cos_def by (rule summable_cos [THEN summable_sums]) ``` huffman@23043 ` 555` huffman@23043 ` 556` paulson@15077 ` 557` ```subsection{*Formal Derivatives of Exp, Sin, and Cos Series*} ``` paulson@15077 ` 558` paulson@15077 ` 559` ```lemma exp_fdiffs: ``` paulson@15077 ` 560` ``` "diffs (%n. inverse(real (fact n))) = (%n. inverse(real (fact n)))" ``` huffman@23082 ` 561` ```by (simp add: diffs_def mult_assoc [symmetric] real_of_nat_def ``` huffman@23082 ` 562` ``` del: mult_Suc of_nat_Suc) ``` paulson@15077 ` 563` huffman@23115 ` 564` ```lemma diffs_of_real: "diffs (\n. of_real (f n)) = (\n. of_real (diffs f n))" ``` huffman@23115 ` 565` ```by (simp add: diffs_def) ``` huffman@23115 ` 566` paulson@15077 ` 567` ```lemma sin_fdiffs: ``` paulson@15077 ` 568` ``` "diffs(%n. if even n then 0 ``` paulson@15077 ` 569` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) ``` paulson@15077 ` 570` ``` = (%n. if even n then ``` paulson@15077 ` 571` ``` (- 1) ^ (n div 2)/(real (fact n)) ``` paulson@15077 ` 572` ``` else 0)" ``` paulson@15229 ` 573` ```by (auto intro!: ext ``` huffman@23082 ` 574` ``` simp add: diffs_def divide_inverse real_of_nat_def ``` huffman@23082 ` 575` ``` simp del: mult_Suc of_nat_Suc) ``` paulson@15077 ` 576` paulson@15077 ` 577` ```lemma sin_fdiffs2: ``` paulson@15077 ` 578` ``` "diffs(%n. if even n then 0 ``` paulson@15077 ` 579` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) n ``` paulson@15077 ` 580` ``` = (if even n then ``` paulson@15077 ` 581` ``` (- 1) ^ (n div 2)/(real (fact n)) ``` paulson@15077 ` 582` ``` else 0)" ``` huffman@23176 ` 583` ```by (simp only: sin_fdiffs) ``` paulson@15077 ` 584` paulson@15077 ` 585` ```lemma cos_fdiffs: ``` paulson@15077 ` 586` ``` "diffs(%n. if even n then ``` paulson@15077 ` 587` ``` (- 1) ^ (n div 2)/(real (fact n)) else 0) ``` paulson@15077 ` 588` ``` = (%n. - (if even n then 0 ``` paulson@15077 ` 589` ``` else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n))))" ``` paulson@15229 ` 590` ```by (auto intro!: ext ``` huffman@23082 ` 591` ``` simp add: diffs_def divide_inverse odd_Suc_mult_two_ex real_of_nat_def ``` huffman@23082 ` 592` ``` simp del: mult_Suc of_nat_Suc) ``` paulson@15077 ` 593` paulson@15077 ` 594` paulson@15077 ` 595` ```lemma cos_fdiffs2: ``` paulson@15077 ` 596` ``` "diffs(%n. if even n then ``` paulson@15077 ` 597` ``` (- 1) ^ (n div 2)/(real (fact n)) else 0) n ``` paulson@15077 ` 598` ``` = - (if even n then 0 ``` paulson@15077 ` 599` ``` else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n)))" ``` huffman@23176 ` 600` ```by (simp only: cos_fdiffs) ``` paulson@15077 ` 601` paulson@15077 ` 602` ```text{*Now at last we can get the derivatives of exp, sin and cos*} ``` paulson@15077 ` 603` paulson@15077 ` 604` ```lemma lemma_sin_minus: ``` nipkow@15546 ` 605` ``` "- sin x = (\n. - ((if even n then 0 ``` paulson@15077 ` 606` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))" ``` paulson@15077 ` 607` ```by (auto intro!: sums_unique sums_minus sin_converges) ``` paulson@15077 ` 608` huffman@23115 ` 609` ```lemma lemma_exp_ext: "exp = (\x. \n. x ^ n /# real (fact n))" ``` paulson@15077 ` 610` ```by (auto intro!: ext simp add: exp_def) ``` paulson@15077 ` 611` paulson@15077 ` 612` ```lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)" ``` paulson@15229 ` 613` ```apply (simp add: exp_def) ``` paulson@15077 ` 614` ```apply (subst lemma_exp_ext) ``` huffman@23115 ` 615` ```apply (subgoal_tac "DERIV (\u. \n. of_real (inverse (real (fact n))) * u ^ n) x :> (\n. diffs (\n. of_real (inverse (real (fact n)))) n * x ^ n)") ``` huffman@23115 ` 616` ```apply (rule_tac [2] K = "of_real (1 + norm x)" in termdiffs) ``` huffman@23115 ` 617` ```apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs) ``` huffman@23115 ` 618` ```apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+ ``` huffman@23115 ` 619` ```apply (simp del: of_real_add) ``` paulson@15077 ` 620` ```done ``` paulson@15077 ` 621` paulson@15077 ` 622` ```lemma lemma_sin_ext: ``` nipkow@15546 ` 623` ``` "sin = (%x. \n. ``` paulson@15077 ` 624` ``` (if even n then 0 ``` paulson@15077 ` 625` ``` else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * ``` nipkow@15546 ` 626` ``` x ^ n)" ``` paulson@15077 ` 627` ```by (auto intro!: ext simp add: sin_def) ``` paulson@15077 ` 628` paulson@15077 ` 629` ```lemma lemma_cos_ext: ``` nipkow@15546 ` 630` ``` "cos = (%x. \n. ``` paulson@15077 ` 631` ``` (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) * ``` nipkow@15546 ` 632` ``` x ^ n)" ``` paulson@15077 ` 633` ```by (auto intro!: ext simp add: cos_def) ``` paulson@15077 ` 634` paulson@15077 ` 635` ```lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)" ``` paulson@15229 ` 636` ```apply (simp add: cos_def) ``` paulson@15077 ` 637` ```apply (subst lemma_sin_ext) ``` paulson@15077 ` 638` ```apply (auto simp add: sin_fdiffs2 [symmetric]) ``` paulson@15229 ` 639` ```apply (rule_tac K = "1 + \x\" in termdiffs) ``` webertj@20217 ` 640` ```apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs) ``` paulson@15077 ` 641` ```done ``` paulson@15077 ` 642` paulson@15077 ` 643` ```lemma DERIV_cos [simp]: "DERIV cos x :> -sin(x)" ``` paulson@15077 ` 644` ```apply (subst lemma_cos_ext) ``` paulson@15077 ` 645` ```apply (auto simp add: lemma_sin_minus cos_fdiffs2 [symmetric] minus_mult_left) ``` paulson@15229 ` 646` ```apply (rule_tac K = "1 + \x\" in termdiffs) ``` webertj@20217 ` 647` ```apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs diffs_minus) ``` paulson@15077 ` 648` ```done ``` paulson@15077 ` 649` huffman@23045 ` 650` ```lemma isCont_exp [simp]: "isCont exp x" ``` huffman@23045 ` 651` ```by (rule DERIV_exp [THEN DERIV_isCont]) ``` huffman@23045 ` 652` huffman@23045 ` 653` ```lemma isCont_sin [simp]: "isCont sin x" ``` huffman@23045 ` 654` ```by (rule DERIV_sin [THEN DERIV_isCont]) ``` huffman@23045 ` 655` huffman@23045 ` 656` ```lemma isCont_cos [simp]: "isCont cos x" ``` huffman@23045 ` 657` ```by (rule DERIV_cos [THEN DERIV_isCont]) ``` huffman@23045 ` 658` paulson@15077 ` 659` paulson@15077 ` 660` ```subsection{*Properties of the Exponential Function*} ``` paulson@15077 ` 661` paulson@15077 ` 662` ```lemma exp_zero [simp]: "exp 0 = 1" ``` paulson@15077 ` 663` ```proof - ``` huffman@23115 ` 664` ``` have "(\n = 0..<1. (0::'a) ^ n /# real (fact n)) = ``` huffman@23115 ` 665` ``` (\n. 0 ^ n /# real (fact n))" ``` huffman@23115 ` 666` ``` by (rule sums_unique [OF series_zero], simp add: power_0_left) ``` huffman@23115 ` 667` ``` thus ?thesis by (simp add: exp_def) ``` paulson@15077 ` 668` ```qed ``` paulson@15077 ` 669` huffman@23115 ` 670` ```lemma setsum_head2: ``` huffman@23115 ` 671` ``` "m \ n \ setsum f {m..n} = f m + setsum f {Suc m..n}" ``` huffman@23115 ` 672` ```by (simp add: setsum_head atLeastSucAtMost_greaterThanAtMost) ``` huffman@23115 ` 673` huffman@23115 ` 674` ```lemma setsum_cl_ivl_Suc2: ``` huffman@23115 ` 675` ``` "(\i=m..Suc n. f i) = (if Suc n < m then 0 else f m + (\i=m..n. f (Suc i)))" ``` huffman@23115 ` 676` ```by (simp add: setsum_head2 setsum_shift_bounds_cl_Suc_ivl ``` huffman@23115 ` 677` ``` del: setsum_cl_ivl_Suc) ``` huffman@23115 ` 678` huffman@23115 ` 679` ```lemma exp_series_add: ``` huffman@23115 ` 680` ``` fixes x y :: "'a::{real_field,recpower}" ``` huffman@23115 ` 681` ``` defines S_def: "S \ \x n. x ^ n /# real (fact n)" ``` huffman@23115 ` 682` ``` shows "S (x + y) n = (\i=0..n. S x i * S y (n - i))" ``` huffman@23115 ` 683` ```proof (induct n) ``` huffman@23115 ` 684` ``` case 0 ``` huffman@23115 ` 685` ``` show ?case ``` huffman@23115 ` 686` ``` unfolding S_def by simp ``` huffman@23115 ` 687` ```next ``` huffman@23115 ` 688` ``` case (Suc n) ``` huffman@23115 ` 689` ``` have S_Suc: "\x n. S x (Suc n) = (x * S x n) /# real (Suc n)" ``` huffman@23115 ` 690` ``` unfolding S_def by (simp add: power_Suc del: mult_Suc) ``` huffman@23115 ` 691` ``` hence times_S: "\x n. x * S x n = real (Suc n) *# S x (Suc n)" ``` huffman@23115 ` 692` ``` by simp ``` huffman@23115 ` 693` huffman@23115 ` 694` ``` have "real (Suc n) *# S (x + y) (Suc n) = (x + y) * S (x + y) n" ``` huffman@23115 ` 695` ``` by (simp only: times_S) ``` huffman@23115 ` 696` ``` also have "\ = (x + y) * (\i=0..n. S x i * S y (n-i))" ``` huffman@23115 ` 697` ``` by (simp only: Suc) ``` huffman@23115 ` 698` ``` also have "\ = x * (\i=0..n. S x i * S y (n-i)) ``` huffman@23115 ` 699` ``` + y * (\i=0..n. S x i * S y (n-i))" ``` huffman@23115 ` 700` ``` by (rule left_distrib) ``` huffman@23115 ` 701` ``` also have "\ = (\i=0..n. (x * S x i) * S y (n-i)) ``` huffman@23115 ` 702` ``` + (\i=0..n. S x i * (y * S y (n-i)))" ``` huffman@23115 ` 703` ``` by (simp only: setsum_right_distrib mult_ac) ``` huffman@23115 ` 704` ``` also have "\ = (\i=0..n. real (Suc i) *# (S x (Suc i) * S y (n-i))) ``` huffman@23115 ` 705` ``` + (\i=0..n. real (Suc n-i) *# (S x i * S y (Suc n-i)))" ``` huffman@23115 ` 706` ``` by (simp add: times_S Suc_diff_le) ``` huffman@23115 ` 707` ``` also have "(\i=0..n. real (Suc i) *# (S x (Suc i) * S y (n-i))) = ``` huffman@23115 ` 708` ``` (\i=0..Suc n. real i *# (S x i * S y (Suc n-i)))" ``` huffman@23115 ` 709` ``` by (subst setsum_cl_ivl_Suc2, simp) ``` huffman@23115 ` 710` ``` also have "(\i=0..n. real (Suc n-i) *# (S x i * S y (Suc n-i))) = ``` huffman@23115 ` 711` ``` (\i=0..Suc n. real (Suc n-i) *# (S x i * S y (Suc n-i)))" ``` huffman@23115 ` 712` ``` by (subst setsum_cl_ivl_Suc, simp) ``` huffman@23115 ` 713` ``` also have "(\i=0..Suc n. real i *# (S x i * S y (Suc n-i))) + ``` huffman@23115 ` 714` ``` (\i=0..Suc n. real (Suc n-i) *# (S x i * S y (Suc n-i))) = ``` huffman@23115 ` 715` ``` (\i=0..Suc n. real (Suc n) *# (S x i * S y (Suc n-i)))" ``` huffman@23115 ` 716` ``` by (simp only: setsum_addf [symmetric] scaleR_left_distrib [symmetric] ``` huffman@23115 ` 717` ``` real_of_nat_add [symmetric], simp) ``` huffman@23115 ` 718` ``` also have "\ = real (Suc n) *# (\i=0..Suc n. S x i * S y (Suc n-i))" ``` huffman@23127 ` 719` ``` by (simp only: scaleR_right.setsum) ``` huffman@23115 ` 720` ``` finally show ``` huffman@23115 ` 721` ``` "S (x + y) (Suc n) = (\i=0..Suc n. S x i * S y (Suc n - i))" ``` huffman@23115 ` 722` ``` by (simp add: scaleR_cancel_left del: setsum_cl_ivl_Suc) ``` huffman@23115 ` 723` ```qed ``` huffman@23115 ` 724` huffman@23115 ` 725` ```lemma exp_add: "exp (x + y) = exp x * exp y" ``` huffman@23115 ` 726` ```unfolding exp_def ``` huffman@23115 ` 727` ```by (simp only: Cauchy_product summable_norm_exp exp_series_add) ``` huffman@23115 ` 728` huffman@23115 ` 729` ```lemma exp_ge_add_one_self_aux: "0 \ (x::real) ==> (1 + x) \ exp(x)" ``` huffman@22998 ` 730` ```apply (drule order_le_imp_less_or_eq, auto) ``` paulson@15229 ` 731` ```apply (simp add: exp_def) ``` paulson@15077 ` 732` ```apply (rule real_le_trans) ``` paulson@15229 ` 733` ```apply (rule_tac [2] n = 2 and f = "(%n. inverse (real (fact n)) * x ^ n)" in series_pos_le) ``` paulson@15077 ` 734` ```apply (auto intro: summable_exp simp add: numeral_2_eq_2 zero_le_power zero_le_mult_iff) ``` paulson@15077 ` 735` ```done ``` paulson@15077 ` 736` huffman@23115 ` 737` ```lemma exp_gt_one [simp]: "0 < (x::real) ==> 1 < exp x" ``` paulson@15077 ` 738` ```apply (rule order_less_le_trans) ``` avigad@17014 ` 739` ```apply (rule_tac [2] exp_ge_add_one_self_aux, auto) ``` paulson@15077 ` 740` ```done ``` paulson@15077 ` 741` paulson@15077 ` 742` ```lemma DERIV_exp_add_const: "DERIV (%x. exp (x + y)) x :> exp(x + y)" ``` paulson@15077 ` 743` ```proof - ``` paulson@15077 ` 744` ``` have "DERIV (exp \ (\x. x + y)) x :> exp (x + y) * (1+0)" ``` huffman@23069 ` 745` ``` by (fast intro: DERIV_chain DERIV_add DERIV_exp DERIV_ident DERIV_const) ``` paulson@15077 ` 746` ``` thus ?thesis by (simp add: o_def) ``` paulson@15077 ` 747` ```qed ``` paulson@15077 ` 748` paulson@15077 ` 749` ```lemma DERIV_exp_minus [simp]: "DERIV (%x. exp (-x)) x :> - exp(-x)" ``` paulson@15077 ` 750` ```proof - ``` paulson@15077 ` 751` ``` have "DERIV (exp \ uminus) x :> exp (- x) * - 1" ``` huffman@23069 ` 752` ``` by (fast intro: DERIV_chain DERIV_minus DERIV_exp DERIV_ident) ``` paulson@15077 ` 753` ``` thus ?thesis by (simp add: o_def) ``` paulson@15077 ` 754` ```qed ``` paulson@15077 ` 755` paulson@15077 ` 756` ```lemma DERIV_exp_exp_zero [simp]: "DERIV (%x. exp (x + y) * exp (- x)) x :> 0" ``` paulson@15077 ` 757` ```proof - ``` paulson@15077 ` 758` ``` have "DERIV (\x. exp (x + y) * exp (- x)) x ``` paulson@15077 ` 759` ``` :> exp (x + y) * exp (- x) + - exp (- x) * exp (x + y)" ``` paulson@15077 ` 760` ``` by (fast intro: DERIV_exp_add_const DERIV_exp_minus DERIV_mult) ``` huffman@23115 ` 761` ``` thus ?thesis by (simp add: mult_commute) ``` paulson@15077 ` 762` ```qed ``` paulson@15077 ` 763` huffman@23115 ` 764` ```lemma exp_add_mult_minus [simp]: "exp(x + y)*exp(-x) = exp(y::real)" ``` paulson@15077 ` 765` ```proof - ``` paulson@15077 ` 766` ``` have "\x. DERIV (%x. exp (x + y) * exp (- x)) x :> 0" by simp ``` paulson@15077 ` 767` ``` hence "exp (x + y) * exp (- x) = exp (0 + y) * exp (- 0)" ``` paulson@15077 ` 768` ``` by (rule DERIV_isconst_all) ``` paulson@15077 ` 769` ``` thus ?thesis by simp ``` paulson@15077 ` 770` ```qed ``` paulson@15077 ` 771` paulson@15077 ` 772` ```lemma exp_mult_minus [simp]: "exp x * exp(-x) = 1" ``` huffman@23115 ` 773` ```by (simp add: exp_add [symmetric]) ``` paulson@15077 ` 774` paulson@15077 ` 775` ```lemma exp_mult_minus2 [simp]: "exp(-x)*exp(x) = 1" ``` paulson@15077 ` 776` ```by (simp add: mult_commute) ``` paulson@15077 ` 777` paulson@15077 ` 778` paulson@15077 ` 779` ```lemma exp_minus: "exp(-x) = inverse(exp(x))" ``` paulson@15077 ` 780` ```by (auto intro: inverse_unique [symmetric]) ``` paulson@15077 ` 781` paulson@15077 ` 782` ```text{*Proof: because every exponential can be seen as a square.*} ``` huffman@23115 ` 783` ```lemma exp_ge_zero [simp]: "0 \ exp (x::real)" ``` paulson@15077 ` 784` ```apply (rule_tac t = x in real_sum_of_halves [THEN subst]) ``` paulson@15077 ` 785` ```apply (subst exp_add, auto) ``` paulson@15077 ` 786` ```done ``` paulson@15077 ` 787` paulson@15077 ` 788` ```lemma exp_not_eq_zero [simp]: "exp x \ 0" ``` paulson@15077 ` 789` ```apply (cut_tac x = x in exp_mult_minus2) ``` paulson@15077 ` 790` ```apply (auto simp del: exp_mult_minus2) ``` paulson@15077 ` 791` ```done ``` paulson@15077 ` 792` huffman@23115 ` 793` ```lemma exp_gt_zero [simp]: "0 < exp (x::real)" ``` paulson@15077 ` 794` ```by (simp add: order_less_le) ``` paulson@15077 ` 795` huffman@23115 ` 796` ```lemma inv_exp_gt_zero [simp]: "0 < inverse(exp x::real)" ``` paulson@15077 ` 797` ```by (auto intro: positive_imp_inverse_positive) ``` paulson@15077 ` 798` huffman@23115 ` 799` ```lemma abs_exp_cancel [simp]: "\exp x::real\ = exp x" ``` paulson@15229 ` 800` ```by auto ``` paulson@15077 ` 801` paulson@15077 ` 802` ```lemma exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n" ``` paulson@15251 ` 803` ```apply (induct "n") ``` paulson@15077 ` 804` ```apply (auto simp add: real_of_nat_Suc right_distrib exp_add mult_commute) ``` paulson@15077 ` 805` ```done ``` paulson@15077 ` 806` paulson@15077 ` 807` ```lemma exp_diff: "exp(x - y) = exp(x)/(exp y)" ``` paulson@15229 ` 808` ```apply (simp add: diff_minus divide_inverse) ``` paulson@15077 ` 809` ```apply (simp (no_asm) add: exp_add exp_minus) ``` paulson@15077 ` 810` ```done ``` paulson@15077 ` 811` paulson@15077 ` 812` paulson@15077 ` 813` ```lemma exp_less_mono: ``` huffman@23115 ` 814` ``` fixes x y :: real ``` paulson@15077 ` 815` ``` assumes xy: "x < y" shows "exp x < exp y" ``` paulson@15077 ` 816` ```proof - ``` paulson@15077 ` 817` ``` have "1 < exp (y + - x)" ``` paulson@15077 ` 818` ``` by (rule real_less_sum_gt_zero [THEN exp_gt_one]) ``` paulson@15077 ` 819` ``` hence "exp x * inverse (exp x) < exp y * inverse (exp x)" ``` paulson@15077 ` 820` ``` by (auto simp add: exp_add exp_minus) ``` paulson@15077 ` 821` ``` thus ?thesis ``` nipkow@15539 ` 822` ``` by (simp add: divide_inverse [symmetric] pos_less_divide_eq ``` paulson@15228 ` 823` ``` del: divide_self_if) ``` paulson@15077 ` 824` ```qed ``` paulson@15077 ` 825` huffman@23115 ` 826` ```lemma exp_less_cancel: "exp (x::real) < exp y ==> x < y" ``` paulson@15228 ` 827` ```apply (simp add: linorder_not_le [symmetric]) ``` paulson@15228 ` 828` ```apply (auto simp add: order_le_less exp_less_mono) ``` paulson@15077 ` 829` ```done ``` paulson@15077 ` 830` huffman@23115 ` 831` ```lemma exp_less_cancel_iff [iff]: "(exp(x::real) < exp(y)) = (x < y)" ``` paulson@15077 ` 832` ```by (auto intro: exp_less_mono exp_less_cancel) ``` paulson@15077 ` 833` huffman@23115 ` 834` ```lemma exp_le_cancel_iff [iff]: "(exp(x::real) \ exp(y)) = (x \ y)" ``` paulson@15077 ` 835` ```by (auto simp add: linorder_not_less [symmetric]) ``` paulson@15077 ` 836` huffman@23115 ` 837` ```lemma exp_inj_iff [iff]: "(exp (x::real) = exp y) = (x = y)" ``` paulson@15077 ` 838` ```by (simp add: order_eq_iff) ``` paulson@15077 ` 839` huffman@23115 ` 840` ```lemma lemma_exp_total: "1 \ y ==> \x. 0 \ x & x \ y - 1 & exp(x::real) = y" ``` paulson@15077 ` 841` ```apply (rule IVT) ``` huffman@23045 ` 842` ```apply (auto intro: isCont_exp simp add: le_diff_eq) ``` paulson@15077 ` 843` ```apply (subgoal_tac "1 + (y - 1) \ exp (y - 1)") ``` paulson@15077 ` 844` ```apply simp ``` avigad@17014 ` 845` ```apply (rule exp_ge_add_one_self_aux, simp) ``` paulson@15077 ` 846` ```done ``` paulson@15077 ` 847` huffman@23115 ` 848` ```lemma exp_total: "0 < (y::real) ==> \x. exp x = y" ``` paulson@15077 ` 849` ```apply (rule_tac x = 1 and y = y in linorder_cases) ``` paulson@15077 ` 850` ```apply (drule order_less_imp_le [THEN lemma_exp_total]) ``` paulson@15077 ` 851` ```apply (rule_tac [2] x = 0 in exI) ``` paulson@15077 ` 852` ```apply (frule_tac [3] real_inverse_gt_one) ``` paulson@15077 ` 853` ```apply (drule_tac [4] order_less_imp_le [THEN lemma_exp_total], auto) ``` paulson@15077 ` 854` ```apply (rule_tac x = "-x" in exI) ``` paulson@15077 ` 855` ```apply (simp add: exp_minus) ``` paulson@15077 ` 856` ```done ``` paulson@15077 ` 857` paulson@15077 ` 858` paulson@15077 ` 859` ```subsection{*Properties of the Logarithmic Function*} ``` paulson@15077 ` 860` huffman@23043 ` 861` ```definition ``` huffman@23043 ` 862` ``` ln :: "real => real" where ``` huffman@23043 ` 863` ``` "ln x = (THE u. exp u = x)" ``` huffman@23043 ` 864` huffman@23043 ` 865` ```lemma ln_exp [simp]: "ln (exp x) = x" ``` paulson@15077 ` 866` ```by (simp add: ln_def) ``` paulson@15077 ` 867` huffman@22654 ` 868` ```lemma exp_ln [simp]: "0 < x \ exp (ln x) = x" ``` huffman@22654 ` 869` ```by (auto dest: exp_total) ``` huffman@22654 ` 870` huffman@23043 ` 871` ```lemma exp_ln_iff [simp]: "(exp (ln x) = x) = (0 < x)" ``` paulson@15077 ` 872` ```apply (auto dest: exp_total) ``` paulson@15077 ` 873` ```apply (erule subst, simp) ``` paulson@15077 ` 874` ```done ``` paulson@15077 ` 875` paulson@15077 ` 876` ```lemma ln_mult: "[| 0 < x; 0 < y |] ==> ln(x * y) = ln(x) + ln(y)" ``` paulson@15077 ` 877` ```apply (rule exp_inj_iff [THEN iffD1]) ``` huffman@22654 ` 878` ```apply (simp add: exp_add exp_ln mult_pos_pos) ``` paulson@15077 ` 879` ```done ``` paulson@15077 ` 880` paulson@15077 ` 881` ```lemma ln_inj_iff[simp]: "[| 0 < x; 0 < y |] ==> (ln x = ln y) = (x = y)" ``` paulson@15077 ` 882` ```apply (simp only: exp_ln_iff [symmetric]) ``` paulson@15077 ` 883` ```apply (erule subst)+ ``` paulson@15077 ` 884` ```apply simp ``` paulson@15077 ` 885` ```done ``` paulson@15077 ` 886` paulson@15077 ` 887` ```lemma ln_one[simp]: "ln 1 = 0" ``` paulson@15077 ` 888` ```by (rule exp_inj_iff [THEN iffD1], auto) ``` paulson@15077 ` 889` paulson@15077 ` 890` ```lemma ln_inverse: "0 < x ==> ln(inverse x) = - ln x" ``` paulson@15077 ` 891` ```apply (rule_tac a1 = "ln x" in add_left_cancel [THEN iffD1]) ``` paulson@15077 ` 892` ```apply (auto simp add: positive_imp_inverse_positive ln_mult [symmetric]) ``` paulson@15077 ` 893` ```done ``` paulson@15077 ` 894` paulson@15077 ` 895` ```lemma ln_div: ``` paulson@15077 ` 896` ``` "[|0 < x; 0 < y|] ==> ln(x/y) = ln x - ln y" ``` paulson@15229 ` 897` ```apply (simp add: divide_inverse) ``` paulson@15077 ` 898` ```apply (auto simp add: positive_imp_inverse_positive ln_mult ln_inverse) ``` paulson@15077 ` 899` ```done ``` paulson@15077 ` 900` paulson@15077 ` 901` ```lemma ln_less_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x < ln y) = (x < y)" ``` paulson@15077 ` 902` ```apply (simp only: exp_ln_iff [symmetric]) ``` paulson@15077 ` 903` ```apply (erule subst)+ ``` paulson@15077 ` 904` ```apply simp ``` paulson@15077 ` 905` ```done ``` paulson@15077 ` 906` paulson@15077 ` 907` ```lemma ln_le_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x \ ln y) = (x \ y)" ``` paulson@15077 ` 908` ```by (auto simp add: linorder_not_less [symmetric]) ``` paulson@15077 ` 909` paulson@15077 ` 910` ```lemma ln_realpow: "0 < x ==> ln(x ^ n) = real n * ln(x)" ``` paulson@15077 ` 911` ```by (auto dest!: exp_total simp add: exp_real_of_nat_mult [symmetric]) ``` paulson@15077 ` 912` paulson@15077 ` 913` ```lemma ln_add_one_self_le_self [simp]: "0 \ x ==> ln(1 + x) \ x" ``` paulson@15077 ` 914` ```apply (rule ln_exp [THEN subst]) ``` avigad@17014 ` 915` ```apply (rule ln_le_cancel_iff [THEN iffD2]) ``` avigad@17014 ` 916` ```apply (auto simp add: exp_ge_add_one_self_aux) ``` paulson@15077 ` 917` ```done ``` paulson@15077 ` 918` paulson@15077 ` 919` ```lemma ln_less_self [simp]: "0 < x ==> ln x < x" ``` paulson@15077 ` 920` ```apply (rule order_less_le_trans) ``` paulson@15077 ` 921` ```apply (rule_tac [2] ln_add_one_self_le_self) ``` paulson@15077 ` 922` ```apply (rule ln_less_cancel_iff [THEN iffD2], auto) ``` paulson@15077 ` 923` ```done ``` paulson@15077 ` 924` paulson@15234 ` 925` ```lemma ln_ge_zero [simp]: ``` paulson@15077 ` 926` ``` assumes x: "1 \ x" shows "0 \ ln x" ``` paulson@15077 ` 927` ```proof - ``` paulson@15077 ` 928` ``` have "0 < x" using x by arith ``` paulson@15077 ` 929` ``` hence "exp 0 \ exp (ln x)" ``` huffman@22915 ` 930` ``` by (simp add: x) ``` paulson@15077 ` 931` ``` thus ?thesis by (simp only: exp_le_cancel_iff) ``` paulson@15077 ` 932` ```qed ``` paulson@15077 ` 933` paulson@15077 ` 934` ```lemma ln_ge_zero_imp_ge_one: ``` paulson@15077 ` 935` ``` assumes ln: "0 \ ln x" ``` paulson@15077 ` 936` ``` and x: "0 < x" ``` paulson@15077 ` 937` ``` shows "1 \ x" ``` paulson@15077 ` 938` ```proof - ``` paulson@15077 ` 939` ``` from ln have "ln 1 \ ln x" by simp ``` paulson@15077 ` 940` ``` thus ?thesis by (simp add: x del: ln_one) ``` paulson@15077 ` 941` ```qed ``` paulson@15077 ` 942` paulson@15077 ` 943` ```lemma ln_ge_zero_iff [simp]: "0 < x ==> (0 \ ln x) = (1 \ x)" ``` paulson@15077 ` 944` ```by (blast intro: ln_ge_zero ln_ge_zero_imp_ge_one) ``` paulson@15077 ` 945` paulson@15234 ` 946` ```lemma ln_less_zero_iff [simp]: "0 < x ==> (ln x < 0) = (x < 1)" ``` paulson@15234 ` 947` ```by (insert ln_ge_zero_iff [of x], arith) ``` paulson@15234 ` 948` paulson@15077 ` 949` ```lemma ln_gt_zero: ``` paulson@15077 ` 950` ``` assumes x: "1 < x" shows "0 < ln x" ``` paulson@15077 ` 951` ```proof - ``` paulson@15077 ` 952` ``` have "0 < x" using x by arith ``` huffman@22915 ` 953` ``` hence "exp 0 < exp (ln x)" by (simp add: x) ``` paulson@15077 ` 954` ``` thus ?thesis by (simp only: exp_less_cancel_iff) ``` paulson@15077 ` 955` ```qed ``` paulson@15077 ` 956` paulson@15077 ` 957` ```lemma ln_gt_zero_imp_gt_one: ``` paulson@15077 ` 958` ``` assumes ln: "0 < ln x" ``` paulson@15077 ` 959` ``` and x: "0 < x" ``` paulson@15077 ` 960` ``` shows "1 < x" ``` paulson@15077 ` 961` ```proof - ``` paulson@15077 ` 962` ``` from ln have "ln 1 < ln x" by simp ``` paulson@15077 ` 963` ``` thus ?thesis by (simp add: x del: ln_one) ``` paulson@15077 ` 964` ```qed ``` paulson@15077 ` 965` paulson@15077 ` 966` ```lemma ln_gt_zero_iff [simp]: "0 < x ==> (0 < ln x) = (1 < x)" ``` paulson@15077 ` 967` ```by (blast intro: ln_gt_zero ln_gt_zero_imp_gt_one) ``` paulson@15077 ` 968` paulson@15234 ` 969` ```lemma ln_eq_zero_iff [simp]: "0 < x ==> (ln x = 0) = (x = 1)" ``` paulson@15234 ` 970` ```by (insert ln_less_zero_iff [of x] ln_gt_zero_iff [of x], arith) ``` paulson@15077 ` 971` paulson@15077 ` 972` ```lemma ln_less_zero: "[| 0 < x; x < 1 |] ==> ln x < 0" ``` paulson@15234 ` 973` ```by simp ``` paulson@15077 ` 974` paulson@15077 ` 975` ```lemma exp_ln_eq: "exp u = x ==> ln x = u" ``` paulson@15077 ` 976` ```by auto ``` paulson@15077 ` 977` huffman@23045 ` 978` ```lemma isCont_ln: "0 < x \ isCont ln x" ``` huffman@23045 ` 979` ```apply (subgoal_tac "isCont ln (exp (ln x))", simp) ``` huffman@23045 ` 980` ```apply (rule isCont_inverse_function [where f=exp], simp_all) ``` huffman@23045 ` 981` ```done ``` huffman@23045 ` 982` huffman@23045 ` 983` ```lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E" ``` huffman@23045 ` 984` ```by simp (* TODO: put in Deriv.thy *) ``` huffman@23045 ` 985` huffman@23045 ` 986` ```lemma DERIV_ln: "0 < x \ DERIV ln x :> inverse x" ``` huffman@23045 ` 987` ```apply (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) ``` huffman@23045 ` 988` ```apply (erule lemma_DERIV_subst [OF DERIV_exp exp_ln]) ``` huffman@23045 ` 989` ```apply (simp_all add: abs_if isCont_ln) ``` huffman@23045 ` 990` ```done ``` huffman@23045 ` 991` paulson@15077 ` 992` paulson@15077 ` 993` ```subsection{*Basic Properties of the Trigonometric Functions*} ``` paulson@15077 ` 994` paulson@15077 ` 995` ```lemma sin_zero [simp]: "sin 0 = 0" ``` paulson@15077 ` 996` ```by (auto intro!: sums_unique [symmetric] LIMSEQ_const ``` paulson@15077 ` 997` ``` simp add: sin_def sums_def simp del: power_0_left) ``` paulson@15077 ` 998` nipkow@15539 ` 999` ```lemma lemma_series_zero2: ``` nipkow@15539 ` 1000` ``` "(\m. n \ m --> f m = 0) --> f sums setsum f {0.. cos(x) * sin(x) + cos(x) * sin(x)" ``` paulson@15077 ` 1012` ```by (rule DERIV_mult, auto) ``` paulson@15077 ` 1013` paulson@15077 ` 1014` ```lemma DERIV_sin_sin_mult2 [simp]: ``` paulson@15077 ` 1015` ``` "DERIV (%x. sin(x)*sin(x)) x :> 2 * cos(x) * sin(x)" ``` paulson@15077 ` 1016` ```apply (cut_tac x = x in DERIV_sin_sin_mult) ``` paulson@15077 ` 1017` ```apply (auto simp add: mult_assoc) ``` paulson@15077 ` 1018` ```done ``` paulson@15077 ` 1019` paulson@15077 ` 1020` ```lemma DERIV_sin_realpow2 [simp]: ``` paulson@15077 ` 1021` ``` "DERIV (%x. (sin x)\) x :> cos(x) * sin(x) + cos(x) * sin(x)" ``` paulson@15077 ` 1022` ```by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric]) ``` paulson@15077 ` 1023` paulson@15077 ` 1024` ```lemma DERIV_sin_realpow2a [simp]: ``` paulson@15077 ` 1025` ``` "DERIV (%x. (sin x)\) x :> 2 * cos(x) * sin(x)" ``` paulson@15077 ` 1026` ```by (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1027` paulson@15077 ` 1028` ```lemma DERIV_cos_cos_mult [simp]: ``` paulson@15077 ` 1029` ``` "DERIV (%x. cos(x)*cos(x)) x :> -sin(x) * cos(x) + -sin(x) * cos(x)" ``` paulson@15077 ` 1030` ```by (rule DERIV_mult, auto) ``` paulson@15077 ` 1031` paulson@15077 ` 1032` ```lemma DERIV_cos_cos_mult2 [simp]: ``` paulson@15077 ` 1033` ``` "DERIV (%x. cos(x)*cos(x)) x :> -2 * cos(x) * sin(x)" ``` paulson@15077 ` 1034` ```apply (cut_tac x = x in DERIV_cos_cos_mult) ``` paulson@15077 ` 1035` ```apply (auto simp add: mult_ac) ``` paulson@15077 ` 1036` ```done ``` paulson@15077 ` 1037` paulson@15077 ` 1038` ```lemma DERIV_cos_realpow2 [simp]: ``` paulson@15077 ` 1039` ``` "DERIV (%x. (cos x)\) x :> -sin(x) * cos(x) + -sin(x) * cos(x)" ``` paulson@15077 ` 1040` ```by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric]) ``` paulson@15077 ` 1041` paulson@15077 ` 1042` ```lemma DERIV_cos_realpow2a [simp]: ``` paulson@15077 ` 1043` ``` "DERIV (%x. (cos x)\) x :> -2 * cos(x) * sin(x)" ``` paulson@15077 ` 1044` ```by (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1045` paulson@15077 ` 1046` ```lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E" ``` paulson@15077 ` 1047` ```by auto ``` paulson@15077 ` 1048` paulson@15077 ` 1049` ```lemma DERIV_cos_realpow2b: "DERIV (%x. (cos x)\) x :> -(2 * cos(x) * sin(x))" ``` paulson@15077 ` 1050` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1051` ```apply (rule DERIV_cos_realpow2a, auto) ``` paulson@15077 ` 1052` ```done ``` paulson@15077 ` 1053` paulson@15077 ` 1054` ```(* most useful *) ``` paulson@15229 ` 1055` ```lemma DERIV_cos_cos_mult3 [simp]: ``` paulson@15229 ` 1056` ``` "DERIV (%x. cos(x)*cos(x)) x :> -(2 * cos(x) * sin(x))" ``` paulson@15077 ` 1057` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1058` ```apply (rule DERIV_cos_cos_mult2, auto) ``` paulson@15077 ` 1059` ```done ``` paulson@15077 ` 1060` paulson@15077 ` 1061` ```lemma DERIV_sin_circle_all: ``` paulson@15077 ` 1062` ``` "\x. DERIV (%x. (sin x)\ + (cos x)\) x :> ``` paulson@15077 ` 1063` ``` (2*cos(x)*sin(x) - 2*cos(x)*sin(x))" ``` paulson@15229 ` 1064` ```apply (simp only: diff_minus, safe) ``` paulson@15229 ` 1065` ```apply (rule DERIV_add) ``` paulson@15077 ` 1066` ```apply (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1067` ```done ``` paulson@15077 ` 1068` paulson@15229 ` 1069` ```lemma DERIV_sin_circle_all_zero [simp]: ``` paulson@15229 ` 1070` ``` "\x. DERIV (%x. (sin x)\ + (cos x)\) x :> 0" ``` paulson@15077 ` 1071` ```by (cut_tac DERIV_sin_circle_all, auto) ``` paulson@15077 ` 1072` paulson@15077 ` 1073` ```lemma sin_cos_squared_add [simp]: "((sin x)\) + ((cos x)\) = 1" ``` paulson@15077 ` 1074` ```apply (cut_tac x = x and y = 0 in DERIV_sin_circle_all_zero [THEN DERIV_isconst_all]) ``` paulson@15077 ` 1075` ```apply (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1076` ```done ``` paulson@15077 ` 1077` paulson@15077 ` 1078` ```lemma sin_cos_squared_add2 [simp]: "((cos x)\) + ((sin x)\) = 1" ``` paulson@15077 ` 1079` ```apply (subst real_add_commute) ``` paulson@15077 ` 1080` ```apply (simp (no_asm) del: realpow_Suc) ``` paulson@15077 ` 1081` ```done ``` paulson@15077 ` 1082` paulson@15077 ` 1083` ```lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1" ``` paulson@15077 ` 1084` ```apply (cut_tac x = x in sin_cos_squared_add2) ``` paulson@15077 ` 1085` ```apply (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1086` ```done ``` paulson@15077 ` 1087` paulson@15077 ` 1088` ```lemma sin_squared_eq: "(sin x)\ = 1 - (cos x)\" ``` paulson@15229 ` 1089` ```apply (rule_tac a1 = "(cos x)\" in add_right_cancel [THEN iffD1]) ``` paulson@15077 ` 1090` ```apply (simp del: realpow_Suc) ``` paulson@15077 ` 1091` ```done ``` paulson@15077 ` 1092` paulson@15077 ` 1093` ```lemma cos_squared_eq: "(cos x)\ = 1 - (sin x)\" ``` paulson@15077 ` 1094` ```apply (rule_tac a1 = "(sin x)\" in add_right_cancel [THEN iffD1]) ``` paulson@15077 ` 1095` ```apply (simp del: realpow_Suc) ``` paulson@15077 ` 1096` ```done ``` paulson@15077 ` 1097` paulson@15077 ` 1098` ```lemma real_gt_one_ge_zero_add_less: "[| 1 < x; 0 \ y |] ==> 1 < x + (y::real)" ``` paulson@15077 ` 1099` ```by arith ``` paulson@15077 ` 1100` paulson@15081 ` 1101` ```lemma abs_sin_le_one [simp]: "\sin x\ \ 1" ``` huffman@23097 ` 1102` ```by (rule power2_le_imp_le, simp_all add: sin_squared_eq) ``` paulson@15077 ` 1103` paulson@15077 ` 1104` ```lemma sin_ge_minus_one [simp]: "-1 \ sin x" ``` paulson@15077 ` 1105` ```apply (insert abs_sin_le_one [of x]) ``` huffman@22998 ` 1106` ```apply (simp add: abs_le_iff del: abs_sin_le_one) ``` paulson@15077 ` 1107` ```done ``` paulson@15077 ` 1108` paulson@15077 ` 1109` ```lemma sin_le_one [simp]: "sin x \ 1" ``` paulson@15077 ` 1110` ```apply (insert abs_sin_le_one [of x]) ``` huffman@22998 ` 1111` ```apply (simp add: abs_le_iff del: abs_sin_le_one) ``` paulson@15077 ` 1112` ```done ``` paulson@15077 ` 1113` paulson@15081 ` 1114` ```lemma abs_cos_le_one [simp]: "\cos x\ \ 1" ``` huffman@23097 ` 1115` ```by (rule power2_le_imp_le, simp_all add: cos_squared_eq) ``` paulson@15077 ` 1116` paulson@15077 ` 1117` ```lemma cos_ge_minus_one [simp]: "-1 \ cos x" ``` paulson@15077 ` 1118` ```apply (insert abs_cos_le_one [of x]) ``` huffman@22998 ` 1119` ```apply (simp add: abs_le_iff del: abs_cos_le_one) ``` paulson@15077 ` 1120` ```done ``` paulson@15077 ` 1121` paulson@15077 ` 1122` ```lemma cos_le_one [simp]: "cos x \ 1" ``` paulson@15077 ` 1123` ```apply (insert abs_cos_le_one [of x]) ``` huffman@22998 ` 1124` ```apply (simp add: abs_le_iff del: abs_cos_le_one) ``` paulson@15077 ` 1125` ```done ``` paulson@15077 ` 1126` paulson@15077 ` 1127` ```lemma DERIV_fun_pow: "DERIV g x :> m ==> ``` paulson@15077 ` 1128` ``` DERIV (%x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m" ``` paulson@15077 ` 1129` ```apply (rule lemma_DERIV_subst) ``` paulson@15229 ` 1130` ```apply (rule_tac f = "(%x. x ^ n)" in DERIV_chain2) ``` paulson@15077 ` 1131` ```apply (rule DERIV_pow, auto) ``` paulson@15077 ` 1132` ```done ``` paulson@15077 ` 1133` paulson@15229 ` 1134` ```lemma DERIV_fun_exp: ``` paulson@15229 ` 1135` ``` "DERIV g x :> m ==> DERIV (%x. exp(g x)) x :> exp(g x) * m" ``` paulson@15077 ` 1136` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1137` ```apply (rule_tac f = exp in DERIV_chain2) ``` paulson@15077 ` 1138` ```apply (rule DERIV_exp, auto) ``` paulson@15077 ` 1139` ```done ``` paulson@15077 ` 1140` paulson@15229 ` 1141` ```lemma DERIV_fun_sin: ``` paulson@15229 ` 1142` ``` "DERIV g x :> m ==> DERIV (%x. sin(g x)) x :> cos(g x) * m" ``` paulson@15077 ` 1143` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1144` ```apply (rule_tac f = sin in DERIV_chain2) ``` paulson@15077 ` 1145` ```apply (rule DERIV_sin, auto) ``` paulson@15077 ` 1146` ```done ``` paulson@15077 ` 1147` paulson@15229 ` 1148` ```lemma DERIV_fun_cos: ``` paulson@15229 ` 1149` ``` "DERIV g x :> m ==> DERIV (%x. cos(g x)) x :> -sin(g x) * m" ``` paulson@15077 ` 1150` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1151` ```apply (rule_tac f = cos in DERIV_chain2) ``` paulson@15077 ` 1152` ```apply (rule DERIV_cos, auto) ``` paulson@15077 ` 1153` ```done ``` paulson@15077 ` 1154` huffman@23069 ` 1155` ```lemmas DERIV_intros = DERIV_ident DERIV_const DERIV_cos DERIV_cmult ``` paulson@15077 ` 1156` ``` DERIV_sin DERIV_exp DERIV_inverse DERIV_pow ``` paulson@15077 ` 1157` ``` DERIV_add DERIV_diff DERIV_mult DERIV_minus ``` paulson@15077 ` 1158` ``` DERIV_inverse_fun DERIV_quotient DERIV_fun_pow ``` paulson@15077 ` 1159` ``` DERIV_fun_exp DERIV_fun_sin DERIV_fun_cos ``` paulson@15077 ` 1160` paulson@15077 ` 1161` ```(* lemma *) ``` paulson@15229 ` 1162` ```lemma lemma_DERIV_sin_cos_add: ``` paulson@15229 ` 1163` ``` "\x. ``` paulson@15077 ` 1164` ``` DERIV (%x. (sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 + ``` paulson@15077 ` 1165` ``` (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2) x :> 0" ``` paulson@15077 ` 1166` ```apply (safe, rule lemma_DERIV_subst) ``` paulson@15077 ` 1167` ```apply (best intro!: DERIV_intros intro: DERIV_chain2) ``` paulson@15077 ` 1168` ``` --{*replaces the old @{text DERIV_tac}*} ``` paulson@15229 ` 1169` ```apply (auto simp add: diff_minus left_distrib right_distrib mult_ac add_ac) ``` paulson@15077 ` 1170` ```done ``` paulson@15077 ` 1171` paulson@15077 ` 1172` ```lemma sin_cos_add [simp]: ``` paulson@15077 ` 1173` ``` "(sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 + ``` paulson@15077 ` 1174` ``` (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2 = 0" ``` paulson@15077 ` 1175` ```apply (cut_tac y = 0 and x = x and y7 = y ``` paulson@15077 ` 1176` ``` in lemma_DERIV_sin_cos_add [THEN DERIV_isconst_all]) ``` paulson@15077 ` 1177` ```apply (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1178` ```done ``` paulson@15077 ` 1179` paulson@15077 ` 1180` ```lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y" ``` paulson@15077 ` 1181` ```apply (cut_tac x = x and y = y in sin_cos_add) ``` huffman@22969 ` 1182` ```apply (simp del: sin_cos_add) ``` paulson@15077 ` 1183` ```done ``` paulson@15077 ` 1184` paulson@15077 ` 1185` ```lemma cos_add: "cos (x + y) = cos x * cos y - sin x * sin y" ``` paulson@15077 ` 1186` ```apply (cut_tac x = x and y = y in sin_cos_add) ``` huffman@22969 ` 1187` ```apply (simp del: sin_cos_add) ``` paulson@15077 ` 1188` ```done ``` paulson@15077 ` 1189` paulson@15085 ` 1190` ```lemma lemma_DERIV_sin_cos_minus: ``` paulson@15085 ` 1191` ``` "\x. DERIV (%x. (sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2) x :> 0" ``` paulson@15077 ` 1192` ```apply (safe, rule lemma_DERIV_subst) ``` paulson@15077 ` 1193` ```apply (best intro!: DERIV_intros intro: DERIV_chain2) ``` paulson@15229 ` 1194` ```apply (auto simp add: diff_minus left_distrib right_distrib mult_ac add_ac) ``` paulson@15077 ` 1195` ```done ``` paulson@15077 ` 1196` paulson@15085 ` 1197` ```lemma sin_cos_minus [simp]: ``` paulson@15085 ` 1198` ``` "(sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2 = 0" ``` paulson@15085 ` 1199` ```apply (cut_tac y = 0 and x = x ``` paulson@15085 ` 1200` ``` in lemma_DERIV_sin_cos_minus [THEN DERIV_isconst_all]) ``` huffman@22969 ` 1201` ```apply simp ``` paulson@15077 ` 1202` ```done ``` paulson@15077 ` 1203` paulson@15077 ` 1204` ```lemma sin_minus [simp]: "sin (-x) = -sin(x)" ``` paulson@15077 ` 1205` ```apply (cut_tac x = x in sin_cos_minus) ``` huffman@22969 ` 1206` ```apply (simp del: sin_cos_minus) ``` paulson@15077 ` 1207` ```done ``` paulson@15077 ` 1208` paulson@15077 ` 1209` ```lemma cos_minus [simp]: "cos (-x) = cos(x)" ``` paulson@15077 ` 1210` ```apply (cut_tac x = x in sin_cos_minus) ``` huffman@22969 ` 1211` ```apply (simp del: sin_cos_minus) ``` paulson@15077 ` 1212` ```done ``` paulson@15077 ` 1213` paulson@15077 ` 1214` ```lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y" ``` huffman@22969 ` 1215` ```by (simp add: diff_minus sin_add) ``` paulson@15077 ` 1216` paulson@15077 ` 1217` ```lemma sin_diff2: "sin (x - y) = cos y * sin x - sin y * cos x" ``` paulson@15077 ` 1218` ```by (simp add: sin_diff mult_commute) ``` paulson@15077 ` 1219` paulson@15077 ` 1220` ```lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y" ``` huffman@22969 ` 1221` ```by (simp add: diff_minus cos_add) ``` paulson@15077 ` 1222` paulson@15077 ` 1223` ```lemma cos_diff2: "cos (x - y) = cos y * cos x + sin y * sin x" ``` paulson@15077 ` 1224` ```by (simp add: cos_diff mult_commute) ``` paulson@15077 ` 1225` paulson@15077 ` 1226` ```lemma sin_double [simp]: "sin(2 * x) = 2* sin x * cos x" ``` paulson@15077 ` 1227` ```by (cut_tac x = x and y = x in sin_add, auto) ``` paulson@15077 ` 1228` paulson@15077 ` 1229` paulson@15077 ` 1230` ```lemma cos_double: "cos(2* x) = ((cos x)\) - ((sin x)\)" ``` paulson@15077 ` 1231` ```apply (cut_tac x = x and y = x in cos_add) ``` huffman@22969 ` 1232` ```apply (simp add: power2_eq_square) ``` paulson@15077 ` 1233` ```done ``` paulson@15077 ` 1234` paulson@15077 ` 1235` paulson@15077 ` 1236` ```subsection{*The Constant Pi*} ``` paulson@15077 ` 1237` huffman@23043 ` 1238` ```definition ``` huffman@23043 ` 1239` ``` pi :: "real" where ``` huffman@23053 ` 1240` ``` "pi = 2 * (THE x. 0 \ (x::real) & x \ 2 & cos x = 0)" ``` huffman@23043 ` 1241` paulson@15077 ` 1242` ```text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"}; ``` paulson@15077 ` 1243` ``` hence define pi.*} ``` paulson@15077 ` 1244` paulson@15077 ` 1245` ```lemma sin_paired: ``` paulson@15077 ` 1246` ``` "(%n. (- 1) ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) ``` paulson@15077 ` 1247` ``` sums sin x" ``` paulson@15077 ` 1248` ```proof - ``` paulson@15077 ` 1249` ``` have "(\n. \k = n * 2.. 0 < sin x" ``` paulson@15077 ` 1260` ```apply (subgoal_tac ``` paulson@15077 ` 1261` ``` "(\n. \k = n * 2..n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))") ``` paulson@15077 ` 1264` ``` prefer 2 ``` paulson@15077 ` 1265` ``` apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) ``` paulson@15077 ` 1266` ```apply (rotate_tac 2) ``` paulson@15077 ` 1267` ```apply (drule sin_paired [THEN sums_unique, THEN ssubst]) ``` paulson@15077 ` 1268` ```apply (auto simp del: fact_Suc realpow_Suc) ``` paulson@15077 ` 1269` ```apply (frule sums_unique) ``` paulson@15077 ` 1270` ```apply (auto simp del: fact_Suc realpow_Suc) ``` paulson@15077 ` 1271` ```apply (rule_tac n1 = 0 in series_pos_less [THEN [2] order_le_less_trans]) ``` paulson@15077 ` 1272` ```apply (auto simp del: fact_Suc realpow_Suc) ``` paulson@15077 ` 1273` ```apply (erule sums_summable) ``` paulson@15077 ` 1274` ```apply (case_tac "m=0") ``` paulson@15077 ` 1275` ```apply (simp (no_asm_simp)) ``` paulson@15234 ` 1276` ```apply (subgoal_tac "6 * (x * (x * x) / real (Suc (Suc (Suc (Suc (Suc (Suc 0))))))) < 6 * x") ``` nipkow@15539 ` 1277` ```apply (simp only: mult_less_cancel_left, simp) ``` nipkow@15539 ` 1278` ```apply (simp (no_asm_simp) add: numeral_2_eq_2 [symmetric] mult_assoc [symmetric]) ``` paulson@15077 ` 1279` ```apply (subgoal_tac "x*x < 2*3", simp) ``` paulson@15077 ` 1280` ```apply (rule mult_strict_mono) ``` paulson@15085 ` 1281` ```apply (auto simp add: real_0_less_add_iff real_of_nat_Suc simp del: fact_Suc) ``` paulson@15077 ` 1282` ```apply (subst fact_Suc) ``` paulson@15077 ` 1283` ```apply (subst fact_Suc) ``` paulson@15077 ` 1284` ```apply (subst fact_Suc) ``` paulson@15077 ` 1285` ```apply (subst fact_Suc) ``` paulson@15077 ` 1286` ```apply (subst real_of_nat_mult) ``` paulson@15077 ` 1287` ```apply (subst real_of_nat_mult) ``` paulson@15077 ` 1288` ```apply (subst real_of_nat_mult) ``` paulson@15077 ` 1289` ```apply (subst real_of_nat_mult) ``` nipkow@15539 ` 1290` ```apply (simp (no_asm) add: divide_inverse del: fact_Suc) ``` paulson@15077 ` 1291` ```apply (auto simp add: mult_assoc [symmetric] simp del: fact_Suc) ``` paulson@15077 ` 1292` ```apply (rule_tac c="real (Suc (Suc (4*m)))" in mult_less_imp_less_right) ``` paulson@15077 ` 1293` ```apply (auto simp add: mult_assoc simp del: fact_Suc) ``` paulson@15077 ` 1294` ```apply (rule_tac c="real (Suc (Suc (Suc (4*m))))" in mult_less_imp_less_right) ``` paulson@15077 ` 1295` ```apply (auto simp add: mult_assoc mult_less_cancel_left simp del: fact_Suc) ``` paulson@15077 ` 1296` ```apply (subgoal_tac "x * (x * x ^ (4*m)) = (x ^ (4*m)) * (x * x)") ``` paulson@15077 ` 1297` ```apply (erule ssubst)+ ``` paulson@15077 ` 1298` ```apply (auto simp del: fact_Suc) ``` paulson@15077 ` 1299` ```apply (subgoal_tac "0 < x ^ (4 * m) ") ``` paulson@15077 ` 1300` ``` prefer 2 apply (simp only: zero_less_power) ``` paulson@15077 ` 1301` ```apply (simp (no_asm_simp) add: mult_less_cancel_left) ``` paulson@15077 ` 1302` ```apply (rule mult_strict_mono) ``` paulson@15077 ` 1303` ```apply (simp_all (no_asm_simp)) ``` paulson@15077 ` 1304` ```done ``` paulson@15077 ` 1305` paulson@15077 ` 1306` ```lemma sin_gt_zero1: "[|0 < x; x < 2 |] ==> 0 < sin x" ``` paulson@15077 ` 1307` ```by (auto intro: sin_gt_zero) ``` paulson@15077 ` 1308` paulson@15077 ` 1309` ```lemma cos_double_less_one: "[| 0 < x; x < 2 |] ==> cos (2 * x) < 1" ``` paulson@15077 ` 1310` ```apply (cut_tac x = x in sin_gt_zero1) ``` paulson@15077 ` 1311` ```apply (auto simp add: cos_squared_eq cos_double) ``` paulson@15077 ` 1312` ```done ``` paulson@15077 ` 1313` paulson@15077 ` 1314` ```lemma cos_paired: ``` paulson@15077 ` 1315` ``` "(%n. (- 1) ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x" ``` paulson@15077 ` 1316` ```proof - ``` paulson@15077 ` 1317` ``` have "(\n. \k = n * 2..n=0..< Suc(Suc(Suc 0)). - ((- 1) ^ n / (real(fact (2*n))) * 2 ^ (2*n))" ``` paulson@15481 ` 1338` ``` in order_less_trans) ``` paulson@15077 ` 1339` ```apply (simp (no_asm) add: fact_num_eq_if realpow_num_eq_if del: fact_Suc realpow_Suc) ``` nipkow@15561 ` 1340` ```apply (simp (no_asm) add: mult_assoc del: setsum_op_ivl_Suc) ``` paulson@15077 ` 1341` ```apply (rule sumr_pos_lt_pair) ``` paulson@15077 ` 1342` ```apply (erule sums_summable, safe) ``` paulson@15085 ` 1343` ```apply (simp (no_asm) add: divide_inverse real_0_less_add_iff mult_assoc [symmetric] ``` paulson@15085 ` 1344` ``` del: fact_Suc) ``` paulson@15077 ` 1345` ```apply (rule real_mult_inverse_cancel2) ``` paulson@15077 ` 1346` ```apply (rule real_of_nat_fact_gt_zero)+ ``` paulson@15077 ` 1347` ```apply (simp (no_asm) add: mult_assoc [symmetric] del: fact_Suc) ``` paulson@15077 ` 1348` ```apply (subst fact_lemma) ``` paulson@15481 ` 1349` ```apply (subst fact_Suc [of "Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))"]) ``` paulson@15481 ` 1350` ```apply (simp only: real_of_nat_mult) ``` huffman@23007 ` 1351` ```apply (rule mult_strict_mono, force) ``` huffman@23007 ` 1352` ``` apply (rule_tac [3] real_of_nat_fact_ge_zero) ``` paulson@15481 ` 1353` ``` prefer 2 apply force ``` paulson@15077 ` 1354` ```apply (rule real_of_nat_less_iff [THEN iffD2]) ``` paulson@15077 ` 1355` ```apply (rule fact_less_mono, auto) ``` paulson@15077 ` 1356` ```done ``` huffman@23053 ` 1357` huffman@23053 ` 1358` ```lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] ``` huffman@23053 ` 1359` ```lemmas cos_two_le_zero [simp] = cos_two_less_zero [THEN order_less_imp_le] ``` paulson@15077 ` 1360` paulson@15077 ` 1361` ```lemma cos_is_zero: "EX! x. 0 \ x & x \ 2 & cos x = 0" ``` paulson@15077 ` 1362` ```apply (subgoal_tac "\x. 0 \ x & x \ 2 & cos x = 0") ``` paulson@15077 ` 1363` ```apply (rule_tac [2] IVT2) ``` paulson@15077 ` 1364` ```apply (auto intro: DERIV_isCont DERIV_cos) ``` paulson@15077 ` 1365` ```apply (cut_tac x = xa and y = y in linorder_less_linear) ``` paulson@15077 ` 1366` ```apply (rule ccontr) ``` paulson@15077 ` 1367` ```apply (subgoal_tac " (\x. cos differentiable x) & (\x. isCont cos x) ") ``` paulson@15077 ` 1368` ```apply (auto intro: DERIV_cos DERIV_isCont simp add: differentiable_def) ``` paulson@15077 ` 1369` ```apply (drule_tac f = cos in Rolle) ``` paulson@15077 ` 1370` ```apply (drule_tac [5] f = cos in Rolle) ``` paulson@15077 ` 1371` ```apply (auto dest!: DERIV_cos [THEN DERIV_unique] simp add: differentiable_def) ``` paulson@15077 ` 1372` ```apply (drule_tac y1 = xa in order_le_less_trans [THEN sin_gt_zero]) ``` paulson@15077 ` 1373` ```apply (assumption, rule_tac y=y in order_less_le_trans, simp_all) ``` paulson@15077 ` 1374` ```apply (drule_tac y1 = y in order_le_less_trans [THEN sin_gt_zero], assumption, simp_all) ``` paulson@15077 ` 1375` ```done ``` paulson@15077 ` 1376` ``` ``` huffman@23053 ` 1377` ```lemma pi_half: "pi/2 = (THE x. 0 \ x & x \ 2 & cos x = 0)" ``` paulson@15077 ` 1378` ```by (simp add: pi_def) ``` paulson@15077 ` 1379` paulson@15077 ` 1380` ```lemma cos_pi_half [simp]: "cos (pi / 2) = 0" ``` huffman@23053 ` 1381` ```by (simp add: pi_half cos_is_zero [THEN theI']) ``` huffman@23053 ` 1382` huffman@23053 ` 1383` ```lemma pi_half_gt_zero [simp]: "0 < pi / 2" ``` huffman@23053 ` 1384` ```apply (rule order_le_neq_trans) ``` huffman@23053 ` 1385` ```apply (simp add: pi_half cos_is_zero [THEN theI']) ``` huffman@23053 ` 1386` ```apply (rule notI, drule arg_cong [where f=cos], simp) ``` paulson@15077 ` 1387` ```done ``` paulson@15077 ` 1388` huffman@23053 ` 1389` ```lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] ``` huffman@23053 ` 1390` ```lemmas pi_half_ge_zero [simp] = pi_half_gt_zero [THEN order_less_imp_le] ``` paulson@15077 ` 1391` huffman@23053 ` 1392` ```lemma pi_half_less_two [simp]: "pi / 2 < 2" ``` huffman@23053 ` 1393` ```apply (rule order_le_neq_trans) ``` huffman@23053 ` 1394` ```apply (simp add: pi_half cos_is_zero [THEN theI']) ``` huffman@23053 ` 1395` ```apply (rule notI, drule arg_cong [where f=cos], simp) ``` paulson@15077 ` 1396` ```done ``` huffman@23053 ` 1397` huffman@23053 ` 1398` ```lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] ``` huffman@23053 ` 1399` ```lemmas pi_half_le_two [simp] = pi_half_less_two [THEN order_less_imp_le] ``` paulson@15077 ` 1400` paulson@15077 ` 1401` ```lemma pi_gt_zero [simp]: "0 < pi" ``` huffman@23053 ` 1402` ```by (insert pi_half_gt_zero, simp) ``` huffman@23053 ` 1403` huffman@23053 ` 1404` ```lemma pi_ge_zero [simp]: "0 \ pi" ``` huffman@23053 ` 1405` ```by (rule pi_gt_zero [THEN order_less_imp_le]) ``` paulson@15077 ` 1406` paulson@15077 ` 1407` ```lemma pi_neq_zero [simp]: "pi \ 0" ``` huffman@22998 ` 1408` ```by (rule pi_gt_zero [THEN less_imp_neq, THEN not_sym]) ``` paulson@15077 ` 1409` huffman@23053 ` 1410` ```lemma pi_not_less_zero [simp]: "\ pi < 0" ``` huffman@23053 ` 1411` ```by (simp add: linorder_not_less) ``` paulson@15077 ` 1412` paulson@15077 ` 1413` ```lemma minus_pi_half_less_zero [simp]: "-(pi/2) < 0" ``` paulson@15077 ` 1414` ```by auto ``` paulson@15077 ` 1415` paulson@15077 ` 1416` ```lemma sin_pi_half [simp]: "sin(pi/2) = 1" ``` paulson@15077 ` 1417` ```apply (cut_tac x = "pi/2" in sin_cos_squared_add2) ``` paulson@15077 ` 1418` ```apply (cut_tac sin_gt_zero [OF pi_half_gt_zero pi_half_less_two]) ``` huffman@23053 ` 1419` ```apply (simp add: power2_eq_square) ``` paulson@15077 ` 1420` ```done ``` paulson@15077 ` 1421` paulson@15077 ` 1422` ```lemma cos_pi [simp]: "cos pi = -1" ``` nipkow@15539 ` 1423` ```by (cut_tac x = "pi/2" and y = "pi/2" in cos_add, simp) ``` paulson@15077 ` 1424` paulson@15077 ` 1425` ```lemma sin_pi [simp]: "sin pi = 0" ``` nipkow@15539 ` 1426` ```by (cut_tac x = "pi/2" and y = "pi/2" in sin_add, simp) ``` paulson@15077 ` 1427` paulson@15077 ` 1428` ```lemma sin_cos_eq: "sin x = cos (pi/2 - x)" ``` paulson@15229 ` 1429` ```by (simp add: diff_minus cos_add) ``` huffman@23053 ` 1430` ```declare sin_cos_eq [symmetric, simp] ``` paulson@15077 ` 1431` paulson@15077 ` 1432` ```lemma minus_sin_cos_eq: "-sin x = cos (x + pi/2)" ``` paulson@15229 ` 1433` ```by (simp add: cos_add) ``` paulson@15077 ` 1434` ```declare minus_sin_cos_eq [symmetric, simp] ``` paulson@15077 ` 1435` paulson@15077 ` 1436` ```lemma cos_sin_eq: "cos x = sin (pi/2 - x)" ``` paulson@15229 ` 1437` ```by (simp add: diff_minus sin_add) ``` huffman@23053 ` 1438` ```declare cos_sin_eq [symmetric, simp] ``` paulson@15077 ` 1439` paulson@15077 ` 1440` ```lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" ``` paulson@15229 ` 1441` ```by (simp add: sin_add) ``` paulson@15077 ` 1442` paulson@15077 ` 1443` ```lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" ``` paulson@15229 ` 1444` ```by (simp add: sin_add) ``` paulson@15077 ` 1445` paulson@15077 ` 1446` ```lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" ``` paulson@15229 ` 1447` ```by (simp add: cos_add) ``` paulson@15077 ` 1448` paulson@15077 ` 1449` ```lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x" ``` paulson@15077 ` 1450` ```by (simp add: sin_add cos_double) ``` paulson@15077 ` 1451` paulson@15077 ` 1452` ```lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x" ``` paulson@15077 ` 1453` ```by (simp add: cos_add cos_double) ``` paulson@15077 ` 1454` paulson@15077 ` 1455` ```lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n" ``` paulson@15251 ` 1456` ```apply (induct "n") ``` paulson@15077 ` 1457` ```apply (auto simp add: real_of_nat_Suc left_distrib) ``` paulson@15077 ` 1458` ```done ``` paulson@15077 ` 1459` paulson@15383 ` 1460` ```lemma cos_npi2 [simp]: "cos (pi * real n) = -1 ^ n" ``` paulson@15383 ` 1461` ```proof - ``` paulson@15383 ` 1462` ``` have "cos (pi * real n) = cos (real n * pi)" by (simp only: mult_commute) ``` paulson@15383 ` 1463` ``` also have "... = -1 ^ n" by (rule cos_npi) ``` paulson@15383 ` 1464` ``` finally show ?thesis . ``` paulson@15383 ` 1465` ```qed ``` paulson@15383 ` 1466` paulson@15077 ` 1467` ```lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0" ``` paulson@15251 ` 1468` ```apply (induct "n") ``` paulson@15077 ` 1469` ```apply (auto simp add: real_of_nat_Suc left_distrib) ``` paulson@15077 ` 1470` ```done ``` paulson@15077 ` 1471` paulson@15077 ` 1472` ```lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0" ``` paulson@15383 ` 1473` ```by (simp add: mult_commute [of pi]) ``` paulson@15077 ` 1474` paulson@15077 ` 1475` ```lemma cos_two_pi [simp]: "cos (2 * pi) = 1" ``` paulson@15077 ` 1476` ```by (simp add: cos_double) ``` paulson@15077 ` 1477` paulson@15077 ` 1478` ```lemma sin_two_pi [simp]: "sin (2 * pi) = 0" ``` paulson@15229 ` 1479` ```by simp ``` paulson@15077 ` 1480` paulson@15077 ` 1481` ```lemma sin_gt_zero2: "[| 0 < x; x < pi/2 |] ==> 0 < sin x" ``` paulson@15077 ` 1482` ```apply (rule sin_gt_zero, assumption) ``` paulson@15077 ` 1483` ```apply (rule order_less_trans, assumption) ``` paulson@15077 ` 1484` ```apply (rule pi_half_less_two) ``` paulson@15077 ` 1485` ```done ``` paulson@15077 ` 1486` paulson@15077 ` 1487` ```lemma sin_less_zero: ``` paulson@15077 ` 1488` ``` assumes lb: "- pi/2 < x" and "x < 0" shows "sin x < 0" ``` paulson@15077 ` 1489` ```proof - ``` paulson@15077 ` 1490` ``` have "0 < sin (- x)" using prems by (simp only: sin_gt_zero2) ``` paulson@15077 ` 1491` ``` thus ?thesis by simp ``` paulson@15077 ` 1492` ```qed ``` paulson@15077 ` 1493` paulson@15077 ` 1494` ```lemma pi_less_4: "pi < 4" ``` paulson@15077 ` 1495` ```by (cut_tac pi_half_less_two, auto) ``` paulson@15077 ` 1496` paulson@15077 ` 1497` ```lemma cos_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < cos x" ``` paulson@15077 ` 1498` ```apply (cut_tac pi_less_4) ``` paulson@15077 ` 1499` ```apply (cut_tac f = cos and a = 0 and b = x and y = 0 in IVT2_objl, safe, simp_all) ``` paulson@15077 ` 1500` ```apply (cut_tac cos_is_zero, safe) ``` paulson@15077 ` 1501` ```apply (rename_tac y z) ``` paulson@15077 ` 1502` ```apply (drule_tac x = y in spec) ``` paulson@15077 ` 1503` ```apply (drule_tac x = "pi/2" in spec, simp) ``` paulson@15077 ` 1504` ```done ``` paulson@15077 ` 1505` paulson@15077 ` 1506` ```lemma cos_gt_zero_pi: "[| -(pi/2) < x; x < pi/2 |] ==> 0 < cos x" ``` paulson@15077 ` 1507` ```apply (rule_tac x = x and y = 0 in linorder_cases) ``` paulson@15077 ` 1508` ```apply (rule cos_minus [THEN subst]) ``` paulson@15077 ` 1509` ```apply (rule cos_gt_zero) ``` paulson@15077 ` 1510` ```apply (auto intro: cos_gt_zero) ``` paulson@15077 ` 1511` ```done ``` paulson@15077 ` 1512` ``` ``` paulson@15077 ` 1513` ```lemma cos_ge_zero: "[| -(pi/2) \ x; x \ pi/2 |] ==> 0 \ cos x" ``` paulson@15077 ` 1514` ```apply (auto simp add: order_le_less cos_gt_zero_pi) ``` paulson@15077 ` 1515` ```apply (subgoal_tac "x = pi/2", auto) ``` paulson@15077 ` 1516` ```done ``` paulson@15077 ` 1517` paulson@15077 ` 1518` ```lemma sin_gt_zero_pi: "[| 0 < x; x < pi |] ==> 0 < sin x" ``` paulson@15077 ` 1519` ```apply (subst sin_cos_eq) ``` paulson@15077 ` 1520` ```apply (rotate_tac 1) ``` paulson@15077 ` 1521` ```apply (drule real_sum_of_halves [THEN ssubst]) ``` paulson@15077 ` 1522` ```apply (auto intro!: cos_gt_zero_pi simp del: sin_cos_eq [symmetric]) ``` paulson@15077 ` 1523` ```done ``` paulson@15077 ` 1524` paulson@15077 ` 1525` ```lemma sin_ge_zero: "[| 0 \ x; x \ pi |] ==> 0 \ sin x" ``` paulson@15077 ` 1526` ```by (auto simp add: order_le_less sin_gt_zero_pi) ``` paulson@15077 ` 1527` paulson@15077 ` 1528` ```lemma cos_total: "[| -1 \ y; y \ 1 |] ==> EX! x. 0 \ x & x \ pi & (cos x = y)" ``` paulson@15077 ` 1529` ```apply (subgoal_tac "\x. 0 \ x & x \ pi & cos x = y") ``` paulson@15077 ` 1530` ```apply (rule_tac [2] IVT2) ``` paulson@15077 ` 1531` ```apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos) ``` paulson@15077 ` 1532` ```apply (cut_tac x = xa and y = y in linorder_less_linear) ``` paulson@15077 ` 1533` ```apply (rule ccontr, auto) ``` paulson@15077 ` 1534` ```apply (drule_tac f = cos in Rolle) ``` paulson@15077 ` 1535` ```apply (drule_tac [5] f = cos in Rolle) ``` paulson@15077 ` 1536` ```apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos ``` paulson@15077 ` 1537` ``` dest!: DERIV_cos [THEN DERIV_unique] ``` paulson@15077 ` 1538` ``` simp add: differentiable_def) ``` paulson@15077 ` 1539` ```apply (auto dest: sin_gt_zero_pi [OF order_le_less_trans order_less_le_trans]) ``` paulson@15077 ` 1540` ```done ``` paulson@15077 ` 1541` paulson@15077 ` 1542` ```lemma sin_total: ``` paulson@15077 ` 1543` ``` "[| -1 \ y; y \ 1 |] ==> EX! x. -(pi/2) \ x & x \ pi/2 & (sin x = y)" ``` paulson@15077 ` 1544` ```apply (rule ccontr) ``` paulson@15077 ` 1545` ```apply (subgoal_tac "\x. (- (pi/2) \ x & x \ pi/2 & (sin x = y)) = (0 \ (x + pi/2) & (x + pi/2) \ pi & (cos (x + pi/2) = -y))") ``` wenzelm@18585 ` 1546` ```apply (erule contrapos_np) ``` paulson@15077 ` 1547` ```apply (simp del: minus_sin_cos_eq [symmetric]) ``` paulson@15077 ` 1548` ```apply (cut_tac y="-y" in cos_total, simp) apply simp ``` paulson@15077 ` 1549` ```apply (erule ex1E) ``` paulson@15229 ` 1550` ```apply (rule_tac a = "x - (pi/2)" in ex1I) ``` paulson@15077 ` 1551` ```apply (simp (no_asm) add: real_add_assoc) ``` paulson@15077 ` 1552` ```apply (rotate_tac 3) ``` paulson@15077 ` 1553` ```apply (drule_tac x = "xa + pi/2" in spec, safe, simp_all) ``` paulson@15077 ` 1554` ```done ``` paulson@15077 ` 1555` paulson@15077 ` 1556` ```lemma reals_Archimedean4: ``` paulson@15077 ` 1557` ``` "[| 0 < y; 0 \ x |] ==> \n. real n * y \ x & x < real (Suc n) * y" ``` paulson@15077 ` 1558` ```apply (auto dest!: reals_Archimedean3) ``` paulson@15077 ` 1559` ```apply (drule_tac x = x in spec, clarify) ``` paulson@15077 ` 1560` ```apply (subgoal_tac "x < real(LEAST m::nat. x < real m * y) * y") ``` paulson@15077 ` 1561` ``` prefer 2 apply (erule LeastI) ``` paulson@15077 ` 1562` ```apply (case_tac "LEAST m::nat. x < real m * y", simp) ``` paulson@15077 ` 1563` ```apply (subgoal_tac "~ x < real nat * y") ``` paulson@15077 ` 1564` ``` prefer 2 apply (rule not_less_Least, simp, force) ``` paulson@15077 ` 1565` ```done ``` paulson@15077 ` 1566` paulson@15077 ` 1567` ```(* Pre Isabelle99-2 proof was simpler- numerals arithmetic ``` paulson@15077 ` 1568` ``` now causes some unwanted re-arrangements of literals! *) ``` paulson@15229 ` 1569` ```lemma cos_zero_lemma: ``` paulson@15229 ` 1570` ``` "[| 0 \ x; cos x = 0 |] ==> ``` paulson@15077 ` 1571` ``` \n::nat. ~even n & x = real n * (pi/2)" ``` paulson@15077 ` 1572` ```apply (drule pi_gt_zero [THEN reals_Archimedean4], safe) ``` paulson@15086 ` 1573` ```apply (subgoal_tac "0 \ x - real n * pi & ``` paulson@15086 ` 1574` ``` (x - real n * pi) \ pi & (cos (x - real n * pi) = 0) ") ``` paulson@15086 ` 1575` ```apply (auto simp add: compare_rls) ``` paulson@15077 ` 1576` ``` prefer 3 apply (simp add: cos_diff) ``` paulson@15077 ` 1577` ``` prefer 2 apply (simp add: real_of_nat_Suc left_distrib) ``` paulson@15077 ` 1578` ```apply (simp add: cos_diff) ``` paulson@15077 ` 1579` ```apply (subgoal_tac "EX! x. 0 \ x & x \ pi & cos x = 0") ``` paulson@15077 ` 1580` ```apply (rule_tac [2] cos_total, safe) ``` paulson@15077 ` 1581` ```apply (drule_tac x = "x - real n * pi" in spec) ``` paulson@15077 ` 1582` ```apply (drule_tac x = "pi/2" in spec) ``` paulson@15077 ` 1583` ```apply (simp add: cos_diff) ``` paulson@15229 ` 1584` ```apply (rule_tac x = "Suc (2 * n)" in exI) ``` paulson@15077 ` 1585` ```apply (simp add: real_of_nat_Suc left_distrib, auto) ``` paulson@15077 ` 1586` ```done ``` paulson@15077 ` 1587` paulson@15229 ` 1588` ```lemma sin_zero_lemma: ``` paulson@15229 ` 1589` ``` "[| 0 \ x; sin x = 0 |] ==> ``` paulson@15077 ` 1590` ``` \n::nat. even n & x = real n * (pi/2)" ``` paulson@15077 ` 1591` ```apply (subgoal_tac "\n::nat. ~ even n & x + pi/2 = real n * (pi/2) ") ``` paulson@15077 ` 1592` ``` apply (clarify, rule_tac x = "n - 1" in exI) ``` paulson@15077 ` 1593` ``` apply (force simp add: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib) ``` paulson@15085 ` 1594` ```apply (rule cos_zero_lemma) ``` paulson@15085 ` 1595` ```apply (simp_all add: add_increasing) ``` paulson@15077 ` 1596` ```done ``` paulson@15077 ` 1597` paulson@15077 ` 1598` paulson@15229 ` 1599` ```lemma cos_zero_iff: ``` paulson@15229 ` 1600` ``` "(cos x = 0) = ``` paulson@15077 ` 1601` ``` ((\n::nat. ~even n & (x = real n * (pi/2))) | ``` paulson@15077 ` 1602` ``` (\n::nat. ~even n & (x = -(real n * (pi/2)))))" ``` paulson@15077 ` 1603` ```apply (rule iffI) ``` paulson@15077 ` 1604` ```apply (cut_tac linorder_linear [of 0 x], safe) ``` paulson@15077 ` 1605` ```apply (drule cos_zero_lemma, assumption+) ``` paulson@15077 ` 1606` ```apply (cut_tac x="-x" in cos_zero_lemma, simp, simp) ``` paulson@15077 ` 1607` ```apply (force simp add: minus_equation_iff [of x]) ``` paulson@15077 ` 1608` ```apply (auto simp only: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib) ``` nipkow@15539 ` 1609` ```apply (auto simp add: cos_add) ``` paulson@15077 ` 1610` ```done ``` paulson@15077 ` 1611` paulson@15077 ` 1612` ```(* ditto: but to a lesser extent *) ``` paulson@15229 ` 1613` ```lemma sin_zero_iff: ``` paulson@15229 ` 1614` ``` "(sin x = 0) = ``` paulson@15077 ` 1615` ``` ((\n::nat. even n & (x = real n * (pi/2))) | ``` paulson@15077 ` 1616` ``` (\n::nat. even n & (x = -(real n * (pi/2)))))" ``` paulson@15077 ` 1617` ```apply (rule iffI) ``` paulson@15077 ` 1618` ```apply (cut_tac linorder_linear [of 0 x], safe) ``` paulson@15077 ` 1619` ```apply (drule sin_zero_lemma, assumption+) ``` paulson@15077 ` 1620` ```apply (cut_tac x="-x" in sin_zero_lemma, simp, simp, safe) ``` paulson@15077 ` 1621` ```apply (force simp add: minus_equation_iff [of x]) ``` nipkow@15539 ` 1622` ```apply (auto simp add: even_mult_two_ex) ``` paulson@15077 ` 1623` ```done ``` paulson@15077 ` 1624` paulson@15077 ` 1625` paulson@15077 ` 1626` ```subsection{*Tangent*} ``` paulson@15077 ` 1627` huffman@23043 ` 1628` ```definition ``` huffman@23043 ` 1629` ``` tan :: "real => real" where ``` huffman@23043 ` 1630` ``` "tan x = (sin x)/(cos x)" ``` huffman@23043 ` 1631` paulson@15077 ` 1632` ```lemma tan_zero [simp]: "tan 0 = 0" ``` paulson@15077 ` 1633` ```by (simp add: tan_def) ``` paulson@15077 ` 1634` paulson@15077 ` 1635` ```lemma tan_pi [simp]: "tan pi = 0" ``` paulson@15077 ` 1636` ```by (simp add: tan_def) ``` paulson@15077 ` 1637` paulson@15077 ` 1638` ```lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0" ``` paulson@15077 ` 1639` ```by (simp add: tan_def) ``` paulson@15077 ` 1640` paulson@15077 ` 1641` ```lemma tan_minus [simp]: "tan (-x) = - tan x" ``` paulson@15077 ` 1642` ```by (simp add: tan_def minus_mult_left) ``` paulson@15077 ` 1643` paulson@15077 ` 1644` ```lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x" ``` paulson@15077 ` 1645` ```by (simp add: tan_def) ``` paulson@15077 ` 1646` paulson@15077 ` 1647` ```lemma lemma_tan_add1: ``` paulson@15077 ` 1648` ``` "[| cos x \ 0; cos y \ 0 |] ``` paulson@15077 ` 1649` ``` ==> 1 - tan(x)*tan(y) = cos (x + y)/(cos x * cos y)" ``` paulson@15229 ` 1650` ```apply (simp add: tan_def divide_inverse) ``` paulson@15229 ` 1651` ```apply (auto simp del: inverse_mult_distrib ``` paulson@15229 ` 1652` ``` simp add: inverse_mult_distrib [symmetric] mult_ac) ``` paulson@15077 ` 1653` ```apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst]) ``` paulson@15229 ` 1654` ```apply (auto simp del: inverse_mult_distrib ``` paulson@15229 ` 1655` ``` simp add: mult_assoc left_diff_distrib cos_add) ``` paulson@15234 ` 1656` ```done ``` paulson@15077 ` 1657` paulson@15077 ` 1658` ```lemma add_tan_eq: ``` paulson@15077 ` 1659` ``` "[| cos x \ 0; cos y \ 0 |] ``` paulson@15077 ` 1660` ``` ==> tan x + tan y = sin(x + y)/(cos x * cos y)" ``` paulson@15229 ` 1661` ```apply (simp add: tan_def) ``` paulson@15077 ` 1662` ```apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst]) ``` paulson@15077 ` 1663` ```apply (auto simp add: mult_assoc left_distrib) ``` nipkow@15539 ` 1664` ```apply (simp add: sin_add) ``` paulson@15077 ` 1665` ```done ``` paulson@15077 ` 1666` paulson@15229 ` 1667` ```lemma tan_add: ``` paulson@15229 ` 1668` ``` "[| cos x \ 0; cos y \ 0; cos (x + y) \ 0 |] ``` paulson@15077 ` 1669` ``` ==> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))" ``` paulson@15077 ` 1670` ```apply (simp (no_asm_simp) add: add_tan_eq lemma_tan_add1) ``` paulson@15077 ` 1671` ```apply (simp add: tan_def) ``` paulson@15077 ` 1672` ```done ``` paulson@15077 ` 1673` paulson@15229 ` 1674` ```lemma tan_double: ``` paulson@15229 ` 1675` ``` "[| cos x \ 0; cos (2 * x) \ 0 |] ``` paulson@15077 ` 1676` ``` ==> tan (2 * x) = (2 * tan x)/(1 - (tan(x) ^ 2))" ``` paulson@15077 ` 1677` ```apply (insert tan_add [of x x]) ``` paulson@15077 ` 1678` ```apply (simp add: mult_2 [symmetric]) ``` paulson@15077 ` 1679` ```apply (auto simp add: numeral_2_eq_2) ``` paulson@15077 ` 1680` ```done ``` paulson@15077 ` 1681` paulson@15077 ` 1682` ```lemma tan_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < tan x" ``` paulson@15229 ` 1683` ```by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) ``` paulson@15077 ` 1684` paulson@15077 ` 1685` ```lemma tan_less_zero: ``` paulson@15077 ` 1686` ``` assumes lb: "- pi/2 < x" and "x < 0" shows "tan x < 0" ``` paulson@15077 ` 1687` ```proof - ``` paulson@15077 ` 1688` ``` have "0 < tan (- x)" using prems by (simp only: tan_gt_zero) ``` paulson@15077 ` 1689` ``` thus ?thesis by simp ``` paulson@15077 ` 1690` ```qed ``` paulson@15077 ` 1691` paulson@15077 ` 1692` ```lemma lemma_DERIV_tan: ``` paulson@15077 ` 1693` ``` "cos x \ 0 ==> DERIV (%x. sin(x)/cos(x)) x :> inverse((cos x)\)" ``` paulson@15077 ` 1694` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 1695` ```apply (best intro!: DERIV_intros intro: DERIV_chain2) ``` paulson@15079 ` 1696` ```apply (auto simp add: divide_inverse numeral_2_eq_2) ``` paulson@15077 ` 1697` ```done ``` paulson@15077 ` 1698` paulson@15077 ` 1699` ```lemma DERIV_tan [simp]: "cos x \ 0 ==> DERIV tan x :> inverse((cos x)\)" ``` paulson@15077 ` 1700` ```by (auto dest: lemma_DERIV_tan simp add: tan_def [symmetric]) ``` paulson@15077 ` 1701` huffman@23045 ` 1702` ```lemma isCont_tan [simp]: "cos x \ 0 ==> isCont tan x" ``` huffman@23045 ` 1703` ```by (rule DERIV_tan [THEN DERIV_isCont]) ``` huffman@23045 ` 1704` paulson@15077 ` 1705` ```lemma LIM_cos_div_sin [simp]: "(%x. cos(x)/sin(x)) -- pi/2 --> 0" ``` paulson@15077 ` 1706` ```apply (subgoal_tac "(\x. cos x * inverse (sin x)) -- pi * inverse 2 --> 0*1") ``` paulson@15229 ` 1707` ```apply (simp add: divide_inverse [symmetric]) ``` huffman@22613 ` 1708` ```apply (rule LIM_mult) ``` paulson@15077 ` 1709` ```apply (rule_tac [2] inverse_1 [THEN subst]) ``` paulson@15077 ` 1710` ```apply (rule_tac [2] LIM_inverse) ``` paulson@15077 ` 1711` ```apply (simp_all add: divide_inverse [symmetric]) ``` paulson@15077 ` 1712` ```apply (simp_all only: isCont_def [symmetric] cos_pi_half [symmetric] sin_pi_half [symmetric]) ``` paulson@15077 ` 1713` ```apply (blast intro!: DERIV_isCont DERIV_sin DERIV_cos)+ ``` paulson@15077 ` 1714` ```done ``` paulson@15077 ` 1715` paulson@15077 ` 1716` ```lemma lemma_tan_total: "0 < y ==> \x. 0 < x & x < pi/2 & y < tan x" ``` paulson@15077 ` 1717` ```apply (cut_tac LIM_cos_div_sin) ``` paulson@15077 ` 1718` ```apply (simp only: LIM_def) ``` paulson@15077 ` 1719` ```apply (drule_tac x = "inverse y" in spec, safe, force) ``` paulson@15077 ` 1720` ```apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe) ``` paulson@15229 ` 1721` ```apply (rule_tac x = "(pi/2) - e" in exI) ``` paulson@15077 ` 1722` ```apply (simp (no_asm_simp)) ``` paulson@15229 ` 1723` ```apply (drule_tac x = "(pi/2) - e" in spec) ``` paulson@15229 ` 1724` ```apply (auto simp add: tan_def) ``` paulson@15077 ` 1725` ```apply (rule inverse_less_iff_less [THEN iffD1]) ``` paulson@15079 ` 1726` ```apply (auto simp add: divide_inverse) ``` paulson@15229 ` 1727` ```apply (rule real_mult_order) ``` paulson@15229 ` 1728` ```apply (subgoal_tac [3] "0 < sin e & 0 < cos e") ``` paulson@15229 ` 1729` ```apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: mult_commute) ``` paulson@15077 ` 1730` ```done ``` paulson@15077 ` 1731` paulson@15077 ` 1732` ```lemma tan_total_pos: "0 \ y ==> \x. 0 \ x & x < pi/2 & tan x = y" ``` huffman@22998 ` 1733` ```apply (frule order_le_imp_less_or_eq, safe) ``` paulson@15077 ` 1734` ``` prefer 2 apply force ``` paulson@15077 ` 1735` ```apply (drule lemma_tan_total, safe) ``` paulson@15077 ` 1736` ```apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl) ``` paulson@15077 ` 1737` ```apply (auto intro!: DERIV_tan [THEN DERIV_isCont]) ``` paulson@15077 ` 1738` ```apply (drule_tac y = xa in order_le_imp_less_or_eq) ``` paulson@15077 ` 1739` ```apply (auto dest: cos_gt_zero) ``` paulson@15077 ` 1740` ```done ``` paulson@15077 ` 1741` paulson@15077 ` 1742` ```lemma lemma_tan_total1: "\x. -(pi/2) < x & x < (pi/2) & tan x = y" ``` paulson@15077 ` 1743` ```apply (cut_tac linorder_linear [of 0 y], safe) ``` paulson@15077 ` 1744` ```apply (drule tan_total_pos) ``` paulson@15077 ` 1745` ```apply (cut_tac [2] y="-y" in tan_total_pos, safe) ``` paulson@15077 ` 1746` ```apply (rule_tac [3] x = "-x" in exI) ``` paulson@15077 ` 1747` ```apply (auto intro!: exI) ``` paulson@15077 ` 1748` ```done ``` paulson@15077 ` 1749` paulson@15077 ` 1750` ```lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y" ``` paulson@15077 ` 1751` ```apply (cut_tac y = y in lemma_tan_total1, auto) ``` paulson@15077 ` 1752` ```apply (cut_tac x = xa and y = y in linorder_less_linear, auto) ``` paulson@15077 ` 1753` ```apply (subgoal_tac [2] "\z. y < z & z < xa & DERIV tan z :> 0") ``` paulson@15077 ` 1754` ```apply (subgoal_tac "\z. xa < z & z < y & DERIV tan z :> 0") ``` paulson@15077 ` 1755` ```apply (rule_tac [4] Rolle) ``` paulson@15077 ` 1756` ```apply (rule_tac [2] Rolle) ``` paulson@15077 ` 1757` ```apply (auto intro!: DERIV_tan DERIV_isCont exI ``` paulson@15077 ` 1758` ``` simp add: differentiable_def) ``` paulson@15077 ` 1759` ```txt{*Now, simulate TRYALL*} ``` paulson@15077 ` 1760` ```apply (rule_tac [!] DERIV_tan asm_rl) ``` paulson@15077 ` 1761` ```apply (auto dest!: DERIV_unique [OF _ DERIV_tan] ``` huffman@22998 ` 1762` ``` simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym]) ``` paulson@15077 ` 1763` ```done ``` paulson@15077 ` 1764` huffman@23043 ` 1765` huffman@23043 ` 1766` ```subsection {* Inverse Trigonometric Functions *} ``` huffman@23043 ` 1767` huffman@23043 ` 1768` ```definition ``` huffman@23043 ` 1769` ``` arcsin :: "real => real" where ``` huffman@23043 ` 1770` ``` "arcsin y = (THE x. -(pi/2) \ x & x \ pi/2 & sin x = y)" ``` huffman@23043 ` 1771` huffman@23043 ` 1772` ```definition ``` huffman@23043 ` 1773` ``` arccos :: "real => real" where ``` huffman@23043 ` 1774` ``` "arccos y = (THE x. 0 \ x & x \ pi & cos x = y)" ``` huffman@23043 ` 1775` huffman@23043 ` 1776` ```definition ``` huffman@23043 ` 1777` ``` arctan :: "real => real" where ``` huffman@23043 ` 1778` ``` "arctan y = (THE x. -(pi/2) < x & x < pi/2 & tan x = y)" ``` huffman@23043 ` 1779` paulson@15229 ` 1780` ```lemma arcsin: ``` paulson@15229 ` 1781` ``` "[| -1 \ y; y \ 1 |] ``` paulson@15077 ` 1782` ``` ==> -(pi/2) \ arcsin y & ``` paulson@15077 ` 1783` ``` arcsin y \ pi/2 & sin(arcsin y) = y" ``` huffman@23011 ` 1784` ```unfolding arcsin_def by (rule theI' [OF sin_total]) ``` huffman@23011 ` 1785` huffman@23011 ` 1786` ```lemma arcsin_pi: ``` huffman@23011 ` 1787` ``` "[| -1 \ y; y \ 1 |] ``` huffman@23011 ` 1788` ``` ==> -(pi/2) \ arcsin y & arcsin y \ pi & sin(arcsin y) = y" ``` huffman@23011 ` 1789` ```apply (drule (1) arcsin) ``` huffman@23011 ` 1790` ```apply (force intro: order_trans) ``` paulson@15077 ` 1791` ```done ``` paulson@15077 ` 1792` paulson@15077 ` 1793` ```lemma sin_arcsin [simp]: "[| -1 \ y; y \ 1 |] ==> sin(arcsin y) = y" ``` paulson@15077 ` 1794` ```by (blast dest: arcsin) ``` paulson@15077 ` 1795` ``` ``` paulson@15077 ` 1796` ```lemma arcsin_bounded: ``` paulson@15077 ` 1797` ``` "[| -1 \ y; y \ 1 |] ==> -(pi/2) \ arcsin y & arcsin y \ pi/2" ``` paulson@15077 ` 1798` ```by (blast dest: arcsin) ``` paulson@15077 ` 1799` paulson@15077 ` 1800` ```lemma arcsin_lbound: "[| -1 \ y; y \ 1 |] ==> -(pi/2) \ arcsin y" ``` paulson@15077 ` 1801` ```by (blast dest: arcsin) ``` paulson@15077 ` 1802` paulson@15077 ` 1803` ```lemma arcsin_ubound: "[| -1 \ y; y \ 1 |] ==> arcsin y \ pi/2" ``` paulson@15077 ` 1804` ```by (blast dest: arcsin) ``` paulson@15077 ` 1805` paulson@15077 ` 1806` ```lemma arcsin_lt_bounded: ``` paulson@15077 ` 1807` ``` "[| -1 < y; y < 1 |] ==> -(pi/2) < arcsin y & arcsin y < pi/2" ``` paulson@15077 ` 1808` ```apply (frule order_less_imp_le) ``` paulson@15077 ` 1809` ```apply (frule_tac y = y in order_less_imp_le) ``` paulson@15077 ` 1810` ```apply (frule arcsin_bounded) ``` paulson@15077 ` 1811` ```apply (safe, simp) ``` paulson@15077 ` 1812` ```apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq) ``` paulson@15077 ` 1813` ```apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe) ``` paulson@15077 ` 1814` ```apply (drule_tac [!] f = sin in arg_cong, auto) ``` paulson@15077 ` 1815` ```done ``` paulson@15077 ` 1816` paulson@15077 ` 1817` ```lemma arcsin_sin: "[|-(pi/2) \ x; x \ pi/2 |] ==> arcsin(sin x) = x" ``` paulson@15077 ` 1818` ```apply (unfold arcsin_def) ``` huffman@23011 ` 1819` ```apply (rule the1_equality) ``` paulson@15077 ` 1820` ```apply (rule sin_total, auto) ``` paulson@15077 ` 1821` ```done ``` paulson@15077 ` 1822` huffman@22975 ` 1823` ```lemma arccos: ``` paulson@15229 ` 1824` ``` "[| -1 \ y; y \ 1 |] ``` huffman@22975 ` 1825` ``` ==> 0 \ arccos y & arccos y \ pi & cos(arccos y) = y" ``` huffman@23011 ` 1826` ```unfolding arccos_def by (rule theI' [OF cos_total]) ``` paulson@15077 ` 1827` huffman@22975 ` 1828` ```lemma cos_arccos [simp]: "[| -1 \ y; y \ 1 |] ==> cos(arccos y) = y" ``` huffman@22975 ` 1829` ```by (blast dest: arccos) ``` paulson@15077 ` 1830` ``` ``` huffman@22975 ` 1831` ```lemma arccos_bounded: "[| -1 \ y; y \ 1 |] ==> 0 \ arccos y & arccos y \ pi" ``` huffman@22975 ` 1832` ```by (blast dest: arccos) ``` paulson@15077 ` 1833` huffman@22975 ` 1834` ```lemma arccos_lbound: "[| -1 \ y; y \ 1 |] ==> 0 \ arccos y" ``` huffman@22975 ` 1835` ```by (blast dest: arccos) ``` paulson@15077 ` 1836` huffman@22975 ` 1837` ```lemma arccos_ubound: "[| -1 \ y; y \ 1 |] ==> arccos y \ pi" ``` huffman@22975 ` 1838` ```by (blast dest: arccos) ``` paulson@15077 ` 1839` huffman@22975 ` 1840` ```lemma arccos_lt_bounded: ``` paulson@15229 ` 1841` ``` "[| -1 < y; y < 1 |] ``` huffman@22975 ` 1842` ``` ==> 0 < arccos y & arccos y < pi" ``` paulson@15077 ` 1843` ```apply (frule order_less_imp_le) ``` paulson@15077 ` 1844` ```apply (frule_tac y = y in order_less_imp_le) ``` huffman@22975 ` 1845` ```apply (frule arccos_bounded, auto) ``` huffman@22975 ` 1846` ```apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq) ``` paulson@15077 ` 1847` ```apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto) ``` paulson@15077 ` 1848` ```apply (drule_tac [!] f = cos in arg_cong, auto) ``` paulson@15077 ` 1849` ```done ``` paulson@15077 ` 1850` huffman@22975 ` 1851` ```lemma arccos_cos: "[|0 \ x; x \ pi |] ==> arccos(cos x) = x" ``` huffman@22975 ` 1852` ```apply (simp add: arccos_def) ``` huffman@23011 ` 1853` ```apply (auto intro!: the1_equality cos_total) ``` paulson@15077 ` 1854` ```done ``` paulson@15077 ` 1855` huffman@22975 ` 1856` ```lemma arccos_cos2: "[|x \ 0; -pi \ x |] ==> arccos(cos x) = -x" ``` huffman@22975 ` 1857` ```apply (simp add: arccos_def) ``` huffman@23011 ` 1858` ```apply (auto intro!: the1_equality cos_total) ``` paulson@15077 ` 1859` ```done ``` paulson@15077 ` 1860` huffman@23045 ` 1861` ```lemma cos_arcsin: "\-1 \ x; x \ 1\ \ cos (arcsin x) = sqrt (1 - x\)" ``` huffman@23045 ` 1862` ```apply (subgoal_tac "x\ \ 1") ``` huffman@23052 ` 1863` ```apply (rule power2_eq_imp_eq) ``` huffman@23045 ` 1864` ```apply (simp add: cos_squared_eq) ``` huffman@23045 ` 1865` ```apply (rule cos_ge_zero) ``` huffman@23045 ` 1866` ```apply (erule (1) arcsin_lbound) ``` huffman@23045 ` 1867` ```apply (erule (1) arcsin_ubound) ``` huffman@23045 ` 1868` ```apply simp ``` huffman@23045 ` 1869` ```apply (subgoal_tac "\x\\ \ 1\", simp) ``` huffman@23045 ` 1870` ```apply (rule power_mono, simp, simp) ``` huffman@23045 ` 1871` ```done ``` huffman@23045 ` 1872` huffman@23045 ` 1873` ```lemma sin_arccos: "\-1 \ x; x \ 1\ \ sin (arccos x) = sqrt (1 - x\)" ``` huffman@23045 ` 1874` ```apply (subgoal_tac "x\ \ 1") ``` huffman@23052 ` 1875` ```apply (rule power2_eq_imp_eq) ``` huffman@23045 ` 1876` ```apply (simp add: sin_squared_eq) ``` huffman@23045 ` 1877` ```apply (rule sin_ge_zero) ``` huffman@23045 ` 1878` ```apply (erule (1) arccos_lbound) ``` huffman@23045 ` 1879` ```apply (erule (1) arccos_ubound) ``` huffman@23045 ` 1880` ```apply simp ``` huffman@23045 ` 1881` ```apply (subgoal_tac "\x\\ \ 1\", simp) ``` huffman@23045 ` 1882` ```apply (rule power_mono, simp, simp) ``` huffman@23045 ` 1883` ```done ``` huffman@23045 ` 1884` paulson@15077 ` 1885` ```lemma arctan [simp]: ``` paulson@15077 ` 1886` ``` "- (pi/2) < arctan y & arctan y < pi/2 & tan (arctan y) = y" ``` huffman@23011 ` 1887` ```unfolding arctan_def by (rule theI' [OF tan_total]) ``` paulson@15077 ` 1888` paulson@15077 ` 1889` ```lemma tan_arctan: "tan(arctan y) = y" ``` paulson@15077 ` 1890` ```by auto ``` paulson@15077 ` 1891` paulson@15077 ` 1892` ```lemma arctan_bounded: "- (pi/2) < arctan y & arctan y < pi/2" ``` paulson@15077 ` 1893` ```by (auto simp only: arctan) ``` paulson@15077 ` 1894` paulson@15077 ` 1895` ```lemma arctan_lbound: "- (pi/2) < arctan y" ``` paulson@15077 ` 1896` ```by auto ``` paulson@15077 ` 1897` paulson@15077 ` 1898` ```lemma arctan_ubound: "arctan y < pi/2" ``` paulson@15077 ` 1899` ```by (auto simp only: arctan) ``` paulson@15077 ` 1900` paulson@15077 ` 1901` ```lemma arctan_tan: ``` paulson@15077 ` 1902` ``` "[|-(pi/2) < x; x < pi/2 |] ==> arctan(tan x) = x" ``` paulson@15077 ` 1903` ```apply (unfold arctan_def) ``` huffman@23011 ` 1904` ```apply (rule the1_equality) ``` paulson@15077 ` 1905` ```apply (rule tan_total, auto) ``` paulson@15077 ` 1906` ```done ``` paulson@15077 ` 1907` paulson@15077 ` 1908` ```lemma arctan_zero_zero [simp]: "arctan 0 = 0" ``` paulson@15077 ` 1909` ```by (insert arctan_tan [of 0], simp) ``` paulson@15077 ` 1910` paulson@15077 ` 1911` ```lemma cos_arctan_not_zero [simp]: "cos(arctan x) \ 0" ``` paulson@15077 ` 1912` ```apply (auto simp add: cos_zero_iff) ``` paulson@15077 ` 1913` ```apply (case_tac "n") ``` paulson@15077 ` 1914` ```apply (case_tac [3] "n") ``` paulson@15077 ` 1915` ```apply (cut_tac [2] y = x in arctan_ubound) ``` paulson@15077 ` 1916` ```apply (cut_tac [4] y = x in arctan_lbound) ``` paulson@15077 ` 1917` ```apply (auto simp add: real_of_nat_Suc left_distrib mult_less_0_iff) ``` paulson@15077 ` 1918` ```done ``` paulson@15077 ` 1919` paulson@15077 ` 1920` ```lemma tan_sec: "cos x \ 0 ==> 1 + tan(x) ^ 2 = inverse(cos x) ^ 2" ``` paulson@15077 ` 1921` ```apply (rule power_inverse [THEN subst]) ``` paulson@15077 ` 1922` ```apply (rule_tac c1 = "(cos x)\" in real_mult_right_cancel [THEN iffD1]) ``` huffman@22960 ` 1923` ```apply (auto dest: field_power_not_zero ``` huffman@20516 ` 1924` ``` simp add: power_mult_distrib left_distrib power_divide tan_def ``` paulson@15077 ` 1925` ``` mult_assoc power_inverse [symmetric] ``` paulson@15077 ` 1926` ``` simp del: realpow_Suc) ``` paulson@15077 ` 1927` ```done ``` paulson@15077 ` 1928` huffman@23045 ` 1929` ```lemma isCont_inverse_function2: ``` huffman@23045 ` 1930` ``` fixes f g :: "real \ real" shows ``` huffman@23045 ` 1931` ``` "\a < x; x < b; ``` huffman@23045 ` 1932` ``` \z. a \ z \ z \ b \ g (f z) = z; ``` huffman@23045 ` 1933` ``` \z. a \ z \ z \ b \ isCont f z\ ``` huffman@23045 ` 1934` ``` \ isCont g (f x)" ``` huffman@23045 ` 1935` ```apply (rule isCont_inverse_function ``` huffman@23045 ` 1936` ``` [where f=f and d="min (x - a) (b - x)"]) ``` huffman@23045 ` 1937` ```apply (simp_all add: abs_le_iff) ``` huffman@23045 ` 1938` ```done ``` huffman@23045 ` 1939` huffman@23045 ` 1940` ```lemma isCont_arcsin: "\-1 < x; x < 1\ \ isCont arcsin x" ``` huffman@23045 ` 1941` ```apply (subgoal_tac "isCont arcsin (sin (arcsin x))", simp) ``` huffman@23045 ` 1942` ```apply (rule isCont_inverse_function2 [where f=sin]) ``` huffman@23045 ` 1943` ```apply (erule (1) arcsin_lt_bounded [THEN conjunct1]) ``` huffman@23045 ` 1944` ```apply (erule (1) arcsin_lt_bounded [THEN conjunct2]) ``` huffman@23045 ` 1945` ```apply (fast intro: arcsin_sin, simp) ``` huffman@23045 ` 1946` ```done ``` huffman@23045 ` 1947` huffman@23045 ` 1948` ```lemma isCont_arccos: "\-1 < x; x < 1\ \ isCont arccos x" ``` huffman@23045 ` 1949` ```apply (subgoal_tac "isCont arccos (cos (arccos x))", simp) ``` huffman@23045 ` 1950` ```apply (rule isCont_inverse_function2 [where f=cos]) ``` huffman@23045 ` 1951` ```apply (erule (1) arccos_lt_bounded [THEN conjunct1]) ``` huffman@23045 ` 1952` ```apply (erule (1) arccos_lt_bounded [THEN conjunct2]) ``` huffman@23045 ` 1953` ```apply (fast intro: arccos_cos, simp) ``` huffman@23045 ` 1954` ```done ``` huffman@23045 ` 1955` huffman@23045 ` 1956` ```lemma isCont_arctan: "isCont arctan x" ``` huffman@23045 ` 1957` ```apply (rule arctan_lbound [of x, THEN dense, THEN exE], clarify) ``` huffman@23045 ` 1958` ```apply (rule arctan_ubound [of x, THEN dense, THEN exE], clarify) ``` huffman@23045 ` 1959` ```apply (subgoal_tac "isCont arctan (tan (arctan x))", simp) ``` huffman@23045 ` 1960` ```apply (erule (1) isCont_inverse_function2 [where f=tan]) ``` huffman@23045 ` 1961` ```apply (clarify, rule arctan_tan) ``` huffman@23045 ` 1962` ```apply (erule (1) order_less_le_trans) ``` huffman@23045 ` 1963` ```apply (erule (1) order_le_less_trans) ``` huffman@23045 ` 1964` ```apply (clarify, rule isCont_tan) ``` huffman@23045 ` 1965` ```apply (rule less_imp_neq [symmetric]) ``` huffman@23045 ` 1966` ```apply (rule cos_gt_zero_pi) ``` huffman@23045 ` 1967` ```apply (erule (1) order_less_le_trans) ``` huffman@23045 ` 1968` ```apply (erule (1) order_le_less_trans) ``` huffman@23045 ` 1969` ```done ``` huffman@23045 ` 1970` huffman@23045 ` 1971` ```lemma DERIV_arcsin: ``` huffman@23045 ` 1972` ``` "\-1 < x; x < 1\ \ DERIV arcsin x :> inverse (sqrt (1 - x\))" ``` huffman@23045 ` 1973` ```apply (rule DERIV_inverse_function [where f=sin and a="-1" and b="1"]) ``` huffman@23045 ` 1974` ```apply (rule lemma_DERIV_subst [OF DERIV_sin]) ``` huffman@23045 ` 1975` ```apply (simp add: cos_arcsin) ``` huffman@23045 ` 1976` ```apply (subgoal_tac "\x\\ < 1\", simp) ``` huffman@23045 ` 1977` ```apply (rule power_strict_mono, simp, simp, simp) ``` huffman@23045 ` 1978` ```apply assumption ``` huffman@23045 ` 1979` ```apply assumption ``` huffman@23045 ` 1980` ```apply simp ``` huffman@23045 ` 1981` ```apply (erule (1) isCont_arcsin) ``` huffman@23045 ` 1982` ```done ``` huffman@23045 ` 1983` huffman@23045 ` 1984` ```lemma DERIV_arccos: ``` huffman@23045 ` 1985` ``` "\-1 < x; x < 1\ \ DERIV arccos x :> inverse (- sqrt (1 - x\))" ``` huffman@23045 ` 1986` ```apply (rule DERIV_inverse_function [where f=cos and a="-1" and b="1"]) ``` huffman@23045 ` 1987` ```apply (rule lemma_DERIV_subst [OF DERIV_cos]) ``` huffman@23045 ` 1988` ```apply (simp add: sin_arccos) ``` huffman@23045 ` 1989` ```apply (subgoal_tac "\x\\ < 1\", simp) ``` huffman@23045 ` 1990` ```apply (rule power_strict_mono, simp, simp, simp) ``` huffman@23045 ` 1991` ```apply assumption ``` huffman@23045 ` 1992` ```apply assumption ``` huffman@23045 ` 1993` ```apply simp ``` huffman@23045 ` 1994` ```apply (erule (1) isCont_arccos) ``` huffman@23045 ` 1995` ```done ``` huffman@23045 ` 1996` huffman@23045 ` 1997` ```lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\)" ``` huffman@23045 ` 1998` ```apply (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"]) ``` huffman@23045 ` 1999` ```apply (rule lemma_DERIV_subst [OF DERIV_tan]) ``` huffman@23045 ` 2000` ```apply (rule cos_arctan_not_zero) ``` huffman@23045 ` 2001` ```apply (simp add: power_inverse tan_sec [symmetric]) ``` huffman@23045 ` 2002` ```apply (subgoal_tac "0 < 1 + x\", simp) ``` huffman@23045 ` 2003` ```apply (simp add: add_pos_nonneg) ``` huffman@23045 ` 2004` ```apply (simp, simp, simp, rule isCont_arctan) ``` huffman@23045 ` 2005` ```done ``` huffman@23045 ` 2006` huffman@23045 ` 2007` huffman@23043 ` 2008` ```subsection {* More Theorems about Sin and Cos *} ``` huffman@23043 ` 2009` huffman@23052 ` 2010` ```lemma cos_45: "cos (pi / 4) = sqrt 2 / 2" ``` huffman@23052 ` 2011` ```proof - ``` huffman@23052 ` 2012` ``` let ?c = "cos (pi / 4)" and ?s = "sin (pi / 4)" ``` huffman@23052 ` 2013` ``` have nonneg: "0 \ ?c" ``` huffman@23052 ` 2014` ``` by (rule cos_ge_zero, rule order_trans [where y=0], simp_all) ``` huffman@23052 ` 2015` ``` have "0 = cos (pi / 4 + pi / 4)" ``` huffman@23052 ` 2016` ``` by simp ``` huffman@23052 ` 2017` ``` also have "cos (pi / 4 + pi / 4) = ?c\ - ?s\" ``` huffman@23052 ` 2018` ``` by (simp only: cos_add power2_eq_square) ``` huffman@23052 ` 2019` ``` also have "\ = 2 * ?c\ - 1" ``` huffman@23052 ` 2020` ``` by (simp add: sin_squared_eq) ``` huffman@23052 ` 2021` ``` finally have "?c\ = (sqrt 2 / 2)\" ``` huffman@23052 ` 2022` ``` by (simp add: power_divide) ``` huffman@23052 ` 2023` ``` thus ?thesis ``` huffman@23052 ` 2024` ``` using nonneg by (rule power2_eq_imp_eq) simp ``` huffman@23052 ` 2025` ```qed ``` huffman@23052 ` 2026` huffman@23052 ` 2027` ```lemma cos_30: "cos (pi / 6) = sqrt 3 / 2" ``` huffman@23052 ` 2028` ```proof - ``` huffman@23052 ` 2029` ``` let ?c = "cos (pi / 6)" and ?s = "sin (pi / 6)" ``` huffman@23052 ` 2030` ``` have pos_c: "0 < ?c" ``` huffman@23052 ` 2031` ``` by (rule cos_gt_zero, simp, simp) ``` huffman@23052 ` 2032` ``` have "0 = cos (pi / 6 + pi / 6 + pi / 6)" ``` huffman@23066 ` 2033` ``` by simp ``` huffman@23052 ` 2034` ``` also have "\ = (?c * ?c - ?s * ?s) * ?c - (?s * ?c + ?c * ?s) * ?s" ``` huffman@23052 ` 2035` ``` by (simp only: cos_add sin_add) ``` huffman@23052 ` 2036` ``` also have "\ = ?c * (?c\ - 3 * ?s\)" ``` huffman@23052 ` 2037` ``` by (simp add: ring_eq_simps power2_eq_square) ``` huffman@23052 ` 2038` ``` finally have "?c\ = (sqrt 3 / 2)\" ``` huffman@23052 ` 2039` ``` using pos_c by (simp add: sin_squared_eq power_divide) ``` huffman@23052 ` 2040` ``` thus ?thesis ``` huffman@23052 ` 2041` ``` using pos_c [THEN order_less_imp_le] ``` huffman@23052 ` 2042` ``` by (rule power2_eq_imp_eq) simp ``` huffman@23052 ` 2043` ```qed ``` huffman@23052 ` 2044` huffman@23052 ` 2045` ```lemma sin_45: "sin (pi / 4) = sqrt 2 / 2" ``` huffman@23052 ` 2046` ```proof - ``` huffman@23052 ` 2047` ``` have "sin (pi / 4) = cos (pi / 2 - pi / 4)" by (rule sin_cos_eq) ``` huffman@23052 ` 2048` ``` also have "pi / 2 - pi / 4 = pi / 4" by simp ``` huffman@23052 ` 2049` ``` also have "cos (pi / 4) = sqrt 2 / 2" by (rule cos_45) ``` huffman@23052 ` 2050` ``` finally show ?thesis . ``` huffman@23052 ` 2051` ```qed ``` huffman@23052 ` 2052` huffman@23052 ` 2053` ```lemma sin_60: "sin (pi / 3) = sqrt 3 / 2" ``` huffman@23052 ` 2054` ```proof - ``` huffman@23052 ` 2055` ``` have "sin (pi / 3) = cos (pi / 2 - pi / 3)" by (rule sin_cos_eq) ``` huffman@23052 ` 2056` ``` also have "pi / 2 - pi / 3 = pi / 6" by simp ``` huffman@23052 ` 2057` ``` also have "cos (pi / 6) = sqrt 3 / 2" by (rule cos_30) ``` huffman@23052 ` 2058` ``` finally show ?thesis . ``` huffman@23052 ` 2059` ```qed ``` huffman@23052 ` 2060` huffman@23052 ` 2061` ```lemma cos_60: "cos (pi / 3) = 1 / 2" ``` huffman@23052 ` 2062` ```apply (rule power2_eq_imp_eq) ``` huffman@23052 ` 2063` ```apply (simp add: cos_squared_eq sin_60 power_divide) ``` huffman@23052 ` 2064` ```apply (rule cos_ge_zero, rule order_trans [where y=0], simp_all) ``` huffman@23052 ` 2065` ```done ``` huffman@23052 ` 2066` huffman@23052 ` 2067` ```lemma sin_30: "sin (pi / 6) = 1 / 2" ``` huffman@23052 ` 2068` ```proof - ``` huffman@23052 ` 2069` ``` have "sin (pi / 6) = cos (pi / 2 - pi / 6)" by (rule sin_cos_eq) ``` huffman@23066 ` 2070` ``` also have "pi / 2 - pi / 6 = pi / 3" by simp ``` huffman@23052 ` 2071` ``` also have "cos (pi / 3) = 1 / 2" by (rule cos_60) ``` huffman@23052 ` 2072` ``` finally show ?thesis . ``` huffman@23052 ` 2073` ```qed ``` huffman@23052 ` 2074` huffman@23052 ` 2075` ```lemma tan_30: "tan (pi / 6) = 1 / sqrt 3" ``` huffman@23052 ` 2076` ```unfolding tan_def by (simp add: sin_30 cos_30) ``` huffman@23052 ` 2077` huffman@23052 ` 2078` ```lemma tan_45: "tan (pi / 4) = 1" ``` huffman@23052 ` 2079` ```unfolding tan_def by (simp add: sin_45 cos_45) ``` huffman@23052 ` 2080` huffman@23052 ` 2081` ```lemma tan_60: "tan (pi / 3) = sqrt 3" ``` huffman@23052 ` 2082` ```unfolding tan_def by (simp add: sin_60 cos_60) ``` huffman@23052 ` 2083` paulson@15085 ` 2084` ```text{*NEEDED??*} ``` paulson@15229 ` 2085` ```lemma [simp]: ``` paulson@15229 ` 2086` ``` "sin (x + 1 / 2 * real (Suc m) * pi) = ``` paulson@15229 ` 2087` ``` cos (x + 1 / 2 * real (m) * pi)" ``` paulson@15229 ` 2088` ```by (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib, auto) ``` paulson@15077 ` 2089` paulson@15085 ` 2090` ```text{*NEEDED??*} ``` paulson@15229 ` 2091` ```lemma [simp]: ``` paulson@15229 ` 2092` ``` "sin (x + real (Suc m) * pi / 2) = ``` paulson@15229 ` 2093` ``` cos (x + real (m) * pi / 2)" ``` paulson@15229 ` 2094` ```by (simp only: cos_add sin_add real_of_nat_Suc add_divide_distrib left_distrib, auto) ``` paulson@15077 ` 2095` paulson@15077 ` 2096` ```lemma DERIV_sin_add [simp]: "DERIV (%x. sin (x + k)) xa :> cos (xa + k)" ``` paulson@15077 ` 2097` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 2098` ```apply (rule_tac f = sin and g = "%x. x + k" in DERIV_chain2) ``` paulson@15077 ` 2099` ```apply (best intro!: DERIV_intros intro: DERIV_chain2)+ ``` paulson@15077 ` 2100` ```apply (simp (no_asm)) ``` paulson@15077 ` 2101` ```done ``` paulson@15077 ` 2102` paulson@15383 ` 2103` ```lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n" ``` paulson@15383 ` 2104` ```proof - ``` paulson@15383 ` 2105` ``` have "sin ((real n + 1/2) * pi) = cos (real n * pi)" ``` paulson@15383 ` 2106` ``` by (auto simp add: right_distrib sin_add left_distrib mult_ac) ``` paulson@15383 ` 2107` ``` thus ?thesis ``` paulson@15383 ` 2108` ``` by (simp add: real_of_nat_Suc left_distrib add_divide_distrib ``` paulson@15383 ` 2109` ``` mult_commute [of pi]) ``` paulson@15383 ` 2110` ```qed ``` paulson@15077 ` 2111` paulson@15077 ` 2112` ```lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1" ``` paulson@15077 ` 2113` ```by (simp add: cos_double mult_assoc power_add [symmetric] numeral_2_eq_2) ``` paulson@15077 ` 2114` paulson@15077 ` 2115` ```lemma cos_3over2_pi [simp]: "cos (3 / 2 * pi) = 0" ``` huffman@23066 ` 2116` ```apply (subgoal_tac "cos (pi + pi/2) = 0", simp) ``` huffman@23066 ` 2117` ```apply (subst cos_add, simp) ``` paulson@15077 ` 2118` ```done ``` paulson@15077 ` 2119` paulson@15077 ` 2120` ```lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0" ``` paulson@15077 ` 2121` ```by (auto simp add: mult_assoc) ``` paulson@15077 ` 2122` paulson@15077 ` 2123` ```lemma sin_3over2_pi [simp]: "sin (3 / 2 * pi) = - 1" ``` huffman@23066 ` 2124` ```apply (subgoal_tac "sin (pi + pi/2) = - 1", simp) ``` huffman@23066 ` 2125` ```apply (subst sin_add, simp) ``` paulson@15077 ` 2126` ```done ``` paulson@15077 ` 2127` paulson@15077 ` 2128` ```(*NEEDED??*) ``` paulson@15229 ` 2129` ```lemma [simp]: ``` paulson@15229 ` 2130` ``` "cos(x + 1 / 2 * real(Suc m) * pi) = -sin (x + 1 / 2 * real m * pi)" ``` paulson@15077 ` 2131` ```apply (simp only: cos_add sin_add real_of_nat_Suc right_distrib left_distrib minus_mult_right, auto) ``` paulson@15077 ` 2132` ```done ``` paulson@15077 ` 2133` paulson@15077 ` 2134` ```(*NEEDED??*) ``` paulson@15077 ` 2135` ```lemma [simp]: "cos (x + real(Suc m) * pi / 2) = -sin (x + real m * pi / 2)" ``` paulson@15229 ` 2136` ```by (simp only: cos_add sin_add real_of_nat_Suc left_distrib add_divide_distrib, auto) ``` paulson@15077 ` 2137` paulson@15077 ` 2138` ```lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" ``` paulson@15229 ` 2139` ```by (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib add_divide_distrib, auto) ``` paulson@15077 ` 2140` paulson@15077 ` 2141` ```lemma DERIV_cos_add [simp]: "DERIV (%x. cos (x + k)) xa :> - sin (xa + k)" ``` paulson@15077 ` 2142` ```apply (rule lemma_DERIV_subst) ``` paulson@15077 ` 2143` ```apply (rule_tac f = cos and g = "%x. x + k" in DERIV_chain2) ``` paulson@15077 ` 2144` ```apply (best intro!: DERIV_intros intro: DERIV_chain2)+ ``` paulson@15077 ` 2145` ```apply (simp (no_asm)) ``` paulson@15077 ` 2146` ```done ``` paulson@15077 ` 2147` paulson@15081 ` 2148` ```lemma sin_zero_abs_cos_one: "sin x = 0 ==> \cos x\ = 1" ``` nipkow@15539 ` 2149` ```by (auto simp add: sin_zero_iff even_mult_two_ex) ``` paulson@15077 ` 2150` huffman@23115 ` 2151` ```lemma exp_eq_one_iff [simp]: "(exp (x::real) = 1) = (x = 0)" ``` paulson@15077 ` 2152` ```apply auto ``` paulson@15077 ` 2153` ```apply (drule_tac f = ln in arg_cong, auto) ``` paulson@15077 ` 2154` ```done ``` paulson@15077 ` 2155` paulson@15077 ` 2156` ```lemma cos_one_sin_zero: "cos x = 1 ==> sin x = 0" ``` paulson@15077 ` 2157` ```by (cut_tac x = x in sin_cos_squared_add3, auto) ``` paulson@15077 ` 2158` paulson@15077 ` 2159` huffman@22978 ` 2160` ```subsection {* Existence of Polar Coordinates *} ``` paulson@15077 ` 2161` huffman@22978 ` 2162` ```lemma cos_x_y_le_one: "\x / sqrt (x\ + y\)\ \ 1" ``` huffman@22978 ` 2163` ```apply (rule power2_le_imp_le [OF _ zero_le_one]) ``` huffman@22978 ` 2164` ```apply (simp add: abs_divide power_divide divide_le_eq not_sum_power2_lt_zero) ``` paulson@15077 ` 2165` ```done ``` paulson@15077 ` 2166` huffman@22978 ` 2167` ```lemma cos_arccos_abs: "\y\ \ 1 \ cos (arccos y) = y" ``` huffman@22978 ` 2168` ```by (simp add: abs_le_iff) ``` paulson@15077 ` 2169` huffman@23045 ` 2170` ```lemma sin_arccos_abs: "\y\ \ 1 \ sin (arccos y) = sqrt (1 - y\)" ``` huffman@23045 ` 2171` ```by (simp add: sin_arccos abs_le_iff) ``` paulson@15077 ` 2172` huffman@22978 ` 2173` ```lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one] ``` paulson@15228 ` 2174` huffman@23045 ` 2175` ```lemmas sin_arccos_lemma1 = sin_arccos_abs [OF cos_x_y_le_one] ``` paulson@15077 ` 2176` paulson@15229 ` 2177` ```lemma polar_ex1: ``` huffman@22978 ` 2178` ``` "0 < y ==> \r a. x = r * cos a & y = r * sin a" ``` paulson@15229 ` 2179` ```apply (rule_tac x = "sqrt (x\ + y\)" in exI) ``` huffman@22978 ` 2180` ```apply (rule_tac x = "arccos (x / sqrt (x\ + y\))" in exI) ``` huffman@22978 ` 2181` ```apply (simp add: cos_arccos_lemma1) ``` huffman@23045 ` 2182` ```apply (simp add: sin_arccos_lemma1) ``` huffman@23045 ` 2183` ```apply (simp add: power_divide) ``` huffman@23045 ` 2184` ```apply (simp add: real_sqrt_mult [symmetric]) ``` huffman@23045 ` 2185` ```apply (simp add: right_diff_distrib) ``` paulson@15077 ` 2186` ```done ``` paulson@15077 ` 2187` paulson@15229 ` 2188` ```lemma polar_ex2: ``` huffman@22978 ` 2189` ``` "y < 0 ==> \r a. x = r * cos a & y = r * sin a" ``` huffman@22978 ` 2190` ```apply (insert polar_ex1 [where x=x and y="-y"], simp, clarify) ``` paulson@15077 ` 2191` ```apply (rule_tac x = r in exI) ``` huffman@22978 ` 2192` ```apply (rule_tac x = "-a" in exI, simp) ``` paulson@15077 ` 2193` ```done ``` paulson@15077 ` 2194` paulson@15077 ` 2195` ```lemma polar_Ex: "\r a. x = r * cos a & y = r * sin a" ``` huffman@22978 ` 2196` ```apply (rule_tac x=0 and y=y in linorder_cases) ``` huffman@22978 ` 2197` ```apply (erule polar_ex1) ``` huffman@22978 ` 2198` ```apply (rule_tac x=x in exI, rule_tac x=0 in exI, simp) ``` huffman@22978 ` 2199` ```apply (erule polar_ex2) ``` paulson@15077 ` 2200` ```done ``` paulson@15077 ` 2201` paulson@15077 ` 2202` huffman@23043 ` 2203` ```subsection {* Theorems about Limits *} ``` huffman@23043 ` 2204` paulson@15077 ` 2205` ```(* need to rename second isCont_inverse *) ``` paulson@15077 ` 2206` paulson@15229 ` 2207` ```lemma isCont_inv_fun: ``` huffman@20561 ` 2208` ``` fixes f g :: "real \ real" ``` huffman@20561 ` 2209` ``` shows "[| 0 < d; \z. \z - x\ \ d --> g(f(z)) = z; ``` paulson@15077 ` 2210` ``` \z. \z - x\ \ d --> isCont f z |] ``` paulson@15077 ` 2211` ``` ==> isCont g (f x)" ``` huffman@22722 ` 2212` ```by (rule isCont_inverse_function) ``` paulson@15077 ` 2213` paulson@15077 ` 2214` ```lemma isCont_inv_fun_inv: ``` huffman@20552 ` 2215` ``` fixes f g :: "real \ real" ``` huffman@20552 ` 2216` ``` shows "[| 0 < d; ``` paulson@15077 ` 2217` ``` \z. \z - x\ \ d --> g(f(z)) = z; ``` paulson@15077 ` 2218` ``` \z. \z - x\ \ d --> isCont f z |] ``` paulson@15077 ` 2219` ``` ==> \e. 0 < e & ``` paulson@15081 ` 2220` ``` (\y. 0 < \y - f(x)\ & \y - f(x)\ < e --> f(g(y)) = y)" ``` paulson@15077 ` 2221` ```apply (drule isCont_inj_range) ``` paulson@15077 ` 2222` ```prefer 2 apply (assumption, assumption, auto) ``` paulson@15077 ` 2223` ```apply (rule_tac x = e in exI, auto) ``` paulson@15077 ` 2224` ```apply (rotate_tac 2) ``` paulson@15077 ` 2225` ```apply (drule_tac x = y in spec, auto) ``` paulson@15077 ` 2226` ```done ``` paulson@15077 ` 2227` paulson@15077 ` 2228` paulson@15077 ` 2229` ```text{*Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110*} ``` paulson@15229 ` 2230` ```lemma LIM_fun_gt_zero: ``` huffman@20552 ` 2231` ``` "[| f -- c --> (l::real); 0 < l |] ``` huffman@20561 ` 2232` ``` ==> \r. 0 < r & (\x::real. x \ c & \c - x\ < r --> 0 < f x)" ``` paulson@15077 ` 2233` ```apply (auto simp add: LIM_def) ``` paulson@15077 ` 2234` ```apply (drule_tac x = "l/2" in spec, safe, force) ``` paulson@15077 ` 2235` ```apply (rule_tac x = s in exI) ``` huffman@22998 ` 2236` ```apply (auto simp only: abs_less_iff) ``` paulson@15077 ` 2237` ```done ``` paulson@15077 ` 2238` paulson@15229 ` 2239` ```lemma LIM_fun_less_zero: ``` huffman@20552 ` 2240` ``` "[| f -- c --> (l::real); l < 0 |] ``` huffman@20561 ` 2241` ``` ==> \r. 0 < r & (\x::real. x \ c & \c - x\ < r --> f x < 0)" ``` paulson@15077 ` 2242` ```apply (auto simp add: LIM_def) ``` paulson@15077 ` 2243` ```apply (drule_tac x = "-l/2" in spec, safe, force) ``` paulson@15077 ` 2244` ```apply (rule_tac x = s in exI) ``` huffman@22998 ` 2245` ```apply (auto simp only: abs_less_iff) ``` paulson@15077 ` 2246` ```done ``` paulson@15077 ` 2247` paulson@15077 ` 2248` paulson@15077 ` 2249` ```lemma LIM_fun_not_zero: ``` huffman@20552 ` 2250` ``` "[| f -- c --> (l::real); l \ 0 |] ``` huffman@20561 ` 2251` ``` ==> \r. 0 < r & (\x::real. x \ c & \c - x\ < r --> f x \ 0)" ``` paulson@15077 ` 2252` ```apply (cut_tac x = l and y = 0 in linorder_less_linear, auto) ``` paulson@15077 ` 2253` ```apply (drule LIM_fun_less_zero) ``` paulson@15241 ` 2254` ```apply (drule_tac [3] LIM_fun_gt_zero) ``` paulson@15241 ` 2255` ```apply force+ ``` paulson@15077 ` 2256` ```done ``` webertj@20432 ` 2257` ``` ``` paulson@12196 ` 2258` ```end ```