| author | wenzelm | 
| Mon, 11 Nov 2013 21:16:23 +0100 | |
| changeset 54390 | 0e1566512928 | 
| parent 54230 | b1d955791529 | 
| child 54489 | 03ff4d1e6784 | 
| permissions | -rw-r--r-- | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1 | (* Title: HOL/Transcendental.thy | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 2 | Author: Jacques D. Fleuriot, University of Cambridge, University of Edinburgh | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3 | Author: Lawrence C Paulson | 
| 51527 | 4 | Author: Jeremy Avigad | 
| 12196 | 5 | *) | 
| 6 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 7 | header{*Power Series, Transcendental Functions etc.*}
 | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 8 | |
| 15131 | 9 | theory Transcendental | 
| 25600 | 10 | imports Fact Series Deriv NthRoot | 
| 15131 | 11 | begin | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 12 | |
| 29164 | 13 | subsection {* Properties of Power Series *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 14 | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 15 | lemma lemma_realpow_diff: | 
| 31017 | 16 | fixes y :: "'a::monoid_mult" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 17 | shows "p \<le> n \<Longrightarrow> y ^ (Suc n - p) = (y ^ (n - p)) * y" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 18 | proof - | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 19 | assume "p \<le> n" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 20 | hence "Suc n - p = Suc (n - p)" by (rule Suc_diff_le) | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
30082diff
changeset | 21 | thus ?thesis by (simp add: power_commutes) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 22 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 23 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 24 | lemma lemma_realpow_diff_sumr: | 
| 53079 | 25 |   fixes y :: "'a::{comm_semiring_0,monoid_mult}"
 | 
| 26 | shows | |
| 27 | "(\<Sum>p=0..<Suc n. (x ^ p) * y ^ (Suc n - p)) = | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 28 | y * (\<Sum>p=0..<Suc n. (x ^ p) * y ^ (n - p))" | 
| 53079 | 29 | by (simp add: setsum_right_distrib lemma_realpow_diff mult_ac del: setsum_op_ivl_Suc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 30 | |
| 15229 | 31 | lemma lemma_realpow_diff_sumr2: | 
| 53079 | 32 |   fixes y :: "'a::{comm_ring,monoid_mult}"
 | 
| 33 | shows | |
| 34 | "x ^ (Suc n) - y ^ (Suc n) = | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 35 | (x - y) * (\<Sum>p=0..<Suc n. (x ^ p) * y ^ (n - p))" | 
| 53079 | 36 | apply (induct n) | 
| 37 | apply simp | |
| 38 | apply (simp del: setsum_op_ivl_Suc) | |
| 39 | apply (subst setsum_op_ivl_Suc) | |
| 40 | apply (subst lemma_realpow_diff_sumr) | |
| 41 | apply (simp add: distrib_left del: setsum_op_ivl_Suc) | |
| 42 | apply (subst mult_left_commute [of "x - y"]) | |
| 43 | apply (erule subst) | |
| 44 | apply (simp add: algebra_simps) | |
| 45 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 46 | |
| 15229 | 47 | lemma lemma_realpow_rev_sumr: | 
| 53079 | 48 | "(\<Sum>p=0..<Suc n. (x ^ p) * (y ^ (n - p))) = | 
| 49 | (\<Sum>p=0..<Suc n. (x ^ (n - p)) * (y ^ p))" | |
| 50 | apply (rule setsum_reindex_cong [where f="\<lambda>i. n - i"]) | |
| 51 | apply (rule inj_onI, simp) | |
| 52 | apply auto | |
| 53 | apply (rule_tac x="n - x" in image_eqI, simp, simp) | |
| 54 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 55 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 56 | text{*Power series has a `circle` of convergence, i.e. if it sums for @{term
 | 
| 53079 | 57 |   x}, then it sums absolutely for @{term z} with @{term "\<bar>z\<bar> < \<bar>x\<bar>"}.*}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 58 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 59 | lemma powser_insidea: | 
| 53599 | 60 | fixes x z :: "'a::real_normed_div_algebra" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 61 | assumes 1: "summable (\<lambda>n. f n * x ^ n)" | 
| 53079 | 62 | and 2: "norm z < norm x" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 63 | shows "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 64 | proof - | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 65 | from 2 have x_neq_0: "x \<noteq> 0" by clarsimp | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 66 | from 1 have "(\<lambda>n. f n * x ^ n) ----> 0" | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 67 | by (rule summable_LIMSEQ_zero) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 68 | hence "convergent (\<lambda>n. f n * x ^ n)" | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 69 | by (rule convergentI) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 70 | hence "Cauchy (\<lambda>n. f n * x ^ n)" | 
| 44726 | 71 | by (rule convergent_Cauchy) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 72 | hence "Bseq (\<lambda>n. f n * x ^ n)" | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 73 | by (rule Cauchy_Bseq) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 74 | then obtain K where 3: "0 < K" and 4: "\<forall>n. norm (f n * x ^ n) \<le> K" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 75 | by (simp add: Bseq_def, safe) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 76 | have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le> | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 77 | K * norm (z ^ n) * inverse (norm (x ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 78 | proof (intro exI allI impI) | 
| 53079 | 79 | fix n::nat | 
| 80 | assume "0 \<le> n" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 81 | have "norm (norm (f n * z ^ n)) * norm (x ^ n) = | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 82 | norm (f n * x ^ n) * norm (z ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 83 | by (simp add: norm_mult abs_mult) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 84 | also have "\<dots> \<le> K * norm (z ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 85 | by (simp only: mult_right_mono 4 norm_ge_zero) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 86 | also have "\<dots> = K * norm (z ^ n) * (inverse (norm (x ^ n)) * norm (x ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 87 | by (simp add: x_neq_0) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 88 | also have "\<dots> = K * norm (z ^ n) * inverse (norm (x ^ n)) * norm (x ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 89 | by (simp only: mult_assoc) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 90 | finally show "norm (norm (f n * z ^ n)) \<le> | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 91 | K * norm (z ^ n) * inverse (norm (x ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 92 | by (simp add: mult_le_cancel_right x_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 93 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 94 | moreover have "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x ^ n)))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 95 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 96 | from 2 have "norm (norm (z * inverse x)) < 1" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 97 | using x_neq_0 | 
| 53599 | 98 | by (simp add: norm_mult nonzero_norm_inverse divide_inverse [where 'a=real, symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 99 | hence "summable (\<lambda>n. norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 100 | by (rule summable_geometric) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 101 | hence "summable (\<lambda>n. K * norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 102 | by (rule summable_mult) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 103 | thus "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x ^ n)))" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 104 | using x_neq_0 | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 105 | by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 106 | power_inverse norm_power mult_assoc) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 107 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 108 | ultimately show "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 109 | by (rule summable_comparison_test) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 110 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 111 | |
| 15229 | 112 | lemma powser_inside: | 
| 53599 | 113 |   fixes f :: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}"
 | 
| 53079 | 114 | shows | 
| 115 | "summable (\<lambda>n. f n * (x ^ n)) \<Longrightarrow> norm z < norm x \<Longrightarrow> | |
| 116 | summable (\<lambda>n. f n * (z ^ n))" | |
| 117 | by (rule powser_insidea [THEN summable_norm_cancel]) | |
| 118 | ||
| 119 | lemma sum_split_even_odd: | |
| 120 | fixes f :: "nat \<Rightarrow> real" | |
| 121 | shows | |
| 122 | "(\<Sum> i = 0 ..< 2 * n. if even i then f i else g i) = | |
| 123 | (\<Sum> i = 0 ..< n. f (2 * i)) + (\<Sum> i = 0 ..< n. g (2 * i + 1))" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 124 | proof (induct n) | 
| 53079 | 125 | case 0 | 
| 126 | then show ?case by simp | |
| 127 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 128 | case (Suc n) | 
| 41970 | 129 | have "(\<Sum> i = 0 ..< 2 * Suc n. if even i then f i else g i) = | 
| 53079 | 130 | (\<Sum> i = 0 ..< n. f (2 * i)) + (\<Sum> i = 0 ..< n. g (2 * i + 1)) + (f (2 * n) + g (2 * n + 1))" | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 131 | using Suc.hyps unfolding One_nat_def by auto | 
| 53079 | 132 | also have "\<dots> = (\<Sum> i = 0 ..< Suc n. f (2 * i)) + (\<Sum> i = 0 ..< Suc n. g (2 * i + 1))" | 
| 133 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 134 | finally show ?case . | 
| 53079 | 135 | qed | 
| 136 | ||
| 137 | lemma sums_if': | |
| 138 | fixes g :: "nat \<Rightarrow> real" | |
| 139 | assumes "g sums x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 140 | shows "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 141 | unfolding sums_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 142 | proof (rule LIMSEQ_I) | 
| 53079 | 143 | fix r :: real | 
| 144 | assume "0 < r" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 145 | from `g sums x`[unfolded sums_def, THEN LIMSEQ_D, OF this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 146 |   obtain no where no_eq: "\<And> n. n \<ge> no \<Longrightarrow> (norm (setsum g { 0..<n } - x) < r)" by blast
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 147 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 148 | let ?SUM = "\<lambda> m. \<Sum> i = 0 ..< m. if even i then 0 else g ((i - 1) div 2)" | 
| 53079 | 149 |   {
 | 
| 150 | fix m | |
| 151 | assume "m \<ge> 2 * no" | |
| 152 | hence "m div 2 \<ge> no" by auto | |
| 41970 | 153 |     have sum_eq: "?SUM (2 * (m div 2)) = setsum g { 0 ..< m div 2 }"
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 154 | using sum_split_even_odd by auto | 
| 53079 | 155 | hence "(norm (?SUM (2 * (m div 2)) - x) < r)" | 
| 156 | using no_eq unfolding sum_eq using `m div 2 \<ge> no` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 157 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 158 | have "?SUM (2 * (m div 2)) = ?SUM m" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 159 | proof (cases "even m") | 
| 53079 | 160 | case True | 
| 161 | show ?thesis | |
| 162 | unfolding even_nat_div_two_times_two[OF True, unfolded numeral_2_eq_2[symmetric]] .. | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 163 | next | 
| 53079 | 164 | case False | 
| 165 | hence "even (Suc m)" by auto | |
| 166 | from even_nat_div_two_times_two[OF this, unfolded numeral_2_eq_2[symmetric]] | |
| 167 | odd_nat_plus_one_div_two[OF False, unfolded numeral_2_eq_2[symmetric]] | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 168 | have eq: "Suc (2 * (m div 2)) = m" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 169 | hence "even (2 * (m div 2))" using `odd m` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 170 | have "?SUM m = ?SUM (Suc (2 * (m div 2)))" unfolding eq .. | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 171 | also have "\<dots> = ?SUM (2 * (m div 2))" using `even (2 * (m div 2))` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 172 | finally show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 173 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 174 | ultimately have "(norm (?SUM m - x) < r)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 175 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 176 | thus "\<exists> no. \<forall> m \<ge> no. norm (?SUM m - x) < r" by blast | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 177 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 178 | |
| 53079 | 179 | lemma sums_if: | 
| 180 | fixes g :: "nat \<Rightarrow> real" | |
| 181 | assumes "g sums x" and "f sums y" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 182 | shows "(\<lambda> n. if even n then f (n div 2) else g ((n - 1) div 2)) sums (x + y)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 183 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 184 | let ?s = "\<lambda> n. if even n then 0 else f ((n - 1) div 2)" | 
| 53079 | 185 |   {
 | 
| 186 | fix B T E | |
| 187 | have "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)" | |
| 188 | by (cases B) auto | |
| 189 | } note if_sum = this | |
| 190 | have g_sums: "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x" | |
| 191 | using sums_if'[OF `g sums x`] . | |
| 41970 | 192 |   {
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 193 | have "?s 0 = 0" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 194 | have Suc_m1: "\<And> n. Suc n - 1 = n" by auto | 
| 41550 | 195 | have if_eq: "\<And>B T E. (if \<not> B then T else E) = (if B then E else T)" by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 196 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 197 | have "?s sums y" using sums_if'[OF `f sums y`] . | 
| 41970 | 198 | from this[unfolded sums_def, THEN LIMSEQ_Suc] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 199 | have "(\<lambda> n. if even n then f (n div 2) else 0) sums y" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 200 | unfolding sums_def setsum_shift_lb_Suc0_0_upt[where f="?s", OF `?s 0 = 0`, symmetric] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 201 | image_Suc_atLeastLessThan[symmetric] setsum_reindex[OF inj_Suc, unfolded comp_def] | 
| 31148 | 202 | even_Suc Suc_m1 if_eq . | 
| 53079 | 203 | } | 
| 204 | from sums_add[OF g_sums this] show ?thesis unfolding if_sum . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 205 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 206 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 207 | subsection {* Alternating series test / Leibniz formula *}
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 208 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 209 | lemma sums_alternating_upper_lower: | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 210 | fixes a :: "nat \<Rightarrow> real" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 211 | assumes mono: "\<And>n. a (Suc n) \<le> a n" and a_pos: "\<And>n. 0 \<le> a n" and "a ----> 0" | 
| 41970 | 212 | shows "\<exists>l. ((\<forall>n. (\<Sum>i=0..<2*n. -1^i*a i) \<le> l) \<and> (\<lambda> n. \<Sum>i=0..<2*n. -1^i*a i) ----> l) \<and> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 213 | ((\<forall>n. l \<le> (\<Sum>i=0..<2*n + 1. -1^i*a i)) \<and> (\<lambda> n. \<Sum>i=0..<2*n + 1. -1^i*a i) ----> l)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 214 | (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)") | 
| 53079 | 215 | proof (rule nested_sequence_unique) | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 216 | have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" unfolding One_nat_def by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 217 | |
| 53079 | 218 | show "\<forall>n. ?f n \<le> ?f (Suc n)" | 
| 219 | proof | |
| 220 | fix n | |
| 221 | show "?f n \<le> ?f (Suc n)" using mono[of "2*n"] by auto | |
| 222 | qed | |
| 223 | show "\<forall>n. ?g (Suc n) \<le> ?g n" | |
| 224 | proof | |
| 225 | fix n | |
| 226 | show "?g (Suc n) \<le> ?g n" using mono[of "Suc (2*n)"] | |
| 227 | unfolding One_nat_def by auto | |
| 228 | qed | |
| 229 | show "\<forall>n. ?f n \<le> ?g n" | |
| 230 | proof | |
| 231 | fix n | |
| 232 | show "?f n \<le> ?g n" using fg_diff a_pos | |
| 233 | unfolding One_nat_def by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 234 | qed | 
| 53079 | 235 | show "(\<lambda>n. ?f n - ?g n) ----> 0" unfolding fg_diff | 
| 236 | proof (rule LIMSEQ_I) | |
| 237 | fix r :: real | |
| 238 | assume "0 < r" | |
| 239 | with `a ----> 0`[THEN LIMSEQ_D] obtain N where "\<And> n. n \<ge> N \<Longrightarrow> norm (a n - 0) < r" | |
| 240 | by auto | |
| 241 | hence "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto | |
| 242 | thus "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto | |
| 243 | qed | |
| 41970 | 244 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 245 | |
| 53079 | 246 | lemma summable_Leibniz': | 
| 247 | fixes a :: "nat \<Rightarrow> real" | |
| 248 | assumes a_zero: "a ----> 0" | |
| 249 | and a_pos: "\<And> n. 0 \<le> a n" | |
| 250 | and a_monotone: "\<And> n. a (Suc n) \<le> a n" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 251 | shows summable: "summable (\<lambda> n. (-1)^n * a n)" | 
| 53079 | 252 | and "\<And>n. (\<Sum>i=0..<2*n. (-1)^i*a i) \<le> (\<Sum>i. (-1)^i*a i)" | 
| 253 | and "(\<lambda>n. \<Sum>i=0..<2*n. (-1)^i*a i) ----> (\<Sum>i. (-1)^i*a i)" | |
| 254 | and "\<And>n. (\<Sum>i. (-1)^i*a i) \<le> (\<Sum>i=0..<2*n+1. (-1)^i*a i)" | |
| 255 | and "(\<lambda>n. \<Sum>i=0..<2*n+1. (-1)^i*a i) ----> (\<Sum>i. (-1)^i*a i)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 256 | proof - | 
| 53079 | 257 | let ?S = "\<lambda>n. (-1)^n * a n" | 
| 258 | let ?P = "\<lambda>n. \<Sum>i=0..<n. ?S i" | |
| 259 | let ?f = "\<lambda>n. ?P (2 * n)" | |
| 260 | let ?g = "\<lambda>n. ?P (2 * n + 1)" | |
| 261 | obtain l :: real | |
| 262 | where below_l: "\<forall> n. ?f n \<le> l" | |
| 263 | and "?f ----> l" | |
| 264 | and above_l: "\<forall> n. l \<le> ?g n" | |
| 265 | and "?g ----> l" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 266 | using sums_alternating_upper_lower[OF a_monotone a_pos a_zero] by blast | 
| 41970 | 267 | |
| 53079 | 268 | let ?Sa = "\<lambda>m. \<Sum> n = 0..<m. ?S n" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 269 | have "?Sa ----> l" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 270 | proof (rule LIMSEQ_I) | 
| 53079 | 271 | fix r :: real | 
| 272 | assume "0 < r" | |
| 41970 | 273 | with `?f ----> l`[THEN LIMSEQ_D] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 274 | obtain f_no where f: "\<And> n. n \<ge> f_no \<Longrightarrow> norm (?f n - l) < r" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 275 | |
| 41970 | 276 | from `0 < r` `?g ----> l`[THEN LIMSEQ_D] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 277 | obtain g_no where g: "\<And> n. n \<ge> g_no \<Longrightarrow> norm (?g n - l) < r" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 278 | |
| 53079 | 279 |     {
 | 
| 280 | fix n :: nat | |
| 281 | assume "n \<ge> (max (2 * f_no) (2 * g_no))" | |
| 282 | hence "n \<ge> 2 * f_no" and "n \<ge> 2 * g_no" by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 283 | have "norm (?Sa n - l) < r" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 284 | proof (cases "even n") | 
| 53079 | 285 | case True | 
| 286 | from even_nat_div_two_times_two[OF this] | |
| 287 | have n_eq: "2 * (n div 2) = n" | |
| 288 | unfolding numeral_2_eq_2[symmetric] by auto | |
| 289 | with `n \<ge> 2 * f_no` have "n div 2 \<ge> f_no" | |
| 290 | by auto | |
| 291 | from f[OF this] show ?thesis | |
| 292 | unfolding n_eq atLeastLessThanSuc_atLeastAtMost . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 293 | next | 
| 53079 | 294 | case False | 
| 295 | hence "even (n - 1)" by simp | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 296 | from even_nat_div_two_times_two[OF this] | 
| 53079 | 297 | have n_eq: "2 * ((n - 1) div 2) = n - 1" | 
| 298 | unfolding numeral_2_eq_2[symmetric] by auto | |
| 299 | hence range_eq: "n - 1 + 1 = n" | |
| 300 | using odd_pos[OF False] by auto | |
| 301 | ||
| 302 | from n_eq `n \<ge> 2 * g_no` have "(n - 1) div 2 \<ge> g_no" | |
| 303 | by auto | |
| 304 | from g[OF this] show ?thesis | |
| 305 | unfolding n_eq atLeastLessThanSuc_atLeastAtMost range_eq . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 306 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 307 | } | 
| 53079 | 308 | thus "\<exists>no. \<forall>n \<ge> no. norm (?Sa n - l) < r" by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 309 | qed | 
| 53079 | 310 | hence sums_l: "(\<lambda>i. (-1)^i * a i) sums l" | 
| 311 | unfolding sums_def atLeastLessThanSuc_atLeastAtMost[symmetric] . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 312 | thus "summable ?S" using summable_def by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 313 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 314 | have "l = suminf ?S" using sums_unique[OF sums_l] . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 315 | |
| 53079 | 316 | fix n | 
| 317 | show "suminf ?S \<le> ?g n" | |
| 318 | unfolding sums_unique[OF sums_l, symmetric] using above_l by auto | |
| 319 | show "?f n \<le> suminf ?S" | |
| 320 | unfolding sums_unique[OF sums_l, symmetric] using below_l by auto | |
| 321 | show "?g ----> suminf ?S" | |
| 322 | using `?g ----> l` `l = suminf ?S` by auto | |
| 323 | show "?f ----> suminf ?S" | |
| 324 | using `?f ----> l` `l = suminf ?S` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 325 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 326 | |
| 53079 | 327 | theorem summable_Leibniz: | 
| 328 | fixes a :: "nat \<Rightarrow> real" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 329 | assumes a_zero: "a ----> 0" and "monoseq a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 330 | shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable") | 
| 53079 | 331 | and "0 < a 0 \<longrightarrow> | 
| 332 |       (\<forall>n. (\<Sum>i. -1^i*a i) \<in> { \<Sum>i=0..<2*n. -1^i * a i .. \<Sum>i=0..<2*n+1. -1^i * a i})" (is "?pos")
 | |
| 333 | and "a 0 < 0 \<longrightarrow> | |
| 334 |       (\<forall>n. (\<Sum>i. -1^i*a i) \<in> { \<Sum>i=0..<2*n+1. -1^i * a i .. \<Sum>i=0..<2*n. -1^i * a i})" (is "?neg")
 | |
| 335 | and "(\<lambda>n. \<Sum>i=0..<2*n. -1^i*a i) ----> (\<Sum>i. -1^i*a i)" (is "?f") | |
| 336 | and "(\<lambda>n. \<Sum>i=0..<2*n+1. -1^i*a i) ----> (\<Sum>i. -1^i*a i)" (is "?g") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 337 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 338 | have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 339 | proof (cases "(\<forall> n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 340 | case True | 
| 53079 | 341 | hence ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" and ge0: "\<And> n. 0 \<le> a n" | 
| 342 | by auto | |
| 343 |     {
 | |
| 344 | fix n | |
| 345 | have "a (Suc n) \<le> a n" | |
| 346 | using ord[where n="Suc n" and m=n] by auto | |
| 347 | } note mono = this | |
| 348 | note leibniz = summable_Leibniz'[OF `a ----> 0` ge0] | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 349 | from leibniz[OF mono] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 350 | show ?thesis using `0 \<le> a 0` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 351 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 352 | let ?a = "\<lambda> n. - a n" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 353 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 354 | with monoseq_le[OF `monoseq a` `a ----> 0`] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 355 | have "(\<forall> n. a n \<le> 0) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)" by auto | 
| 53079 | 356 | hence ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n" | 
| 357 | by auto | |
| 358 |     {
 | |
| 359 | fix n | |
| 360 | have "?a (Suc n) \<le> ?a n" using ord[where n="Suc n" and m=n] | |
| 361 | by auto | |
| 362 | } note monotone = this | |
| 363 | note leibniz = | |
| 364 | summable_Leibniz'[OF _ ge0, of "\<lambda>x. x", | |
| 365 | OF tendsto_minus[OF `a ----> 0`, unfolded minus_zero] monotone] | |
| 366 | have "summable (\<lambda> n. (-1)^n * ?a n)" | |
| 367 | using leibniz(1) by auto | |
| 368 | then obtain l where "(\<lambda> n. (-1)^n * ?a n) sums l" | |
| 369 | unfolding summable_def by auto | |
| 370 | from this[THEN sums_minus] have "(\<lambda> n. (-1)^n * a n) sums -l" | |
| 371 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 372 | hence ?summable unfolding summable_def by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 373 | moreover | 
| 53079 | 374 | have "\<And>a b :: real. \<bar>- a - - b\<bar> = \<bar>a - b\<bar>" | 
| 375 | unfolding minus_diff_minus by auto | |
| 41970 | 376 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 377 | from suminf_minus[OF leibniz(1), unfolded mult_minus_right minus_minus] | 
| 53079 | 378 | have move_minus: "(\<Sum>n. - (-1 ^ n * a n)) = - (\<Sum>n. -1 ^ n * a n)" | 
| 379 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 380 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 381 | have ?pos using `0 \<le> ?a 0` by auto | 
| 53079 | 382 | moreover have ?neg | 
| 383 | using leibniz(2,4) | |
| 384 | unfolding mult_minus_right setsum_negf move_minus neg_le_iff_le | |
| 385 | by auto | |
| 386 | moreover have ?f and ?g | |
| 387 | using leibniz(3,5)[unfolded mult_minus_right setsum_negf move_minus, THEN tendsto_minus_cancel] | |
| 388 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 389 | ultimately show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 390 | qed | 
| 53079 | 391 | from this[THEN conjunct1] | 
| 392 | this[THEN conjunct2, THEN conjunct1] | |
| 393 | this[THEN conjunct2, THEN conjunct2, THEN conjunct1] | |
| 394 | this[THEN conjunct2, THEN conjunct2, THEN conjunct2, THEN conjunct1] | |
| 395 | this[THEN conjunct2, THEN conjunct2, THEN conjunct2, THEN conjunct2] | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 396 | show ?summable and ?pos and ?neg and ?f and ?g . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 397 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 398 | |
| 29164 | 399 | subsection {* Term-by-Term Differentiability of Power Series *}
 | 
| 23043 | 400 | |
| 53079 | 401 | definition diffs :: "(nat => 'a::ring_1) => nat => 'a" | 
| 402 | where "diffs c = (\<lambda>n. of_nat (Suc n) * c(Suc n))" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 403 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 404 | text{*Lemma about distributing negation over it*}
 | 
| 53079 | 405 | lemma diffs_minus: "diffs (\<lambda>n. - c n) = (\<lambda>n. - diffs c n)" | 
| 406 | by (simp add: diffs_def) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 407 | |
| 29163 | 408 | lemma sums_Suc_imp: | 
| 409 | assumes f: "f 0 = 0" | |
| 410 | shows "(\<lambda>n. f (Suc n)) sums s \<Longrightarrow> (\<lambda>n. f n) sums s" | |
| 53079 | 411 | unfolding sums_def | 
| 412 | apply (rule LIMSEQ_imp_Suc) | |
| 413 | apply (subst setsum_shift_lb_Suc0_0_upt [where f=f, OF f, symmetric]) | |
| 414 | apply (simp only: setsum_shift_bounds_Suc_ivl) | |
| 415 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 416 | |
| 15229 | 417 | lemma diffs_equiv: | 
| 41970 | 418 |   fixes x :: "'a::{real_normed_vector, ring_1}"
 | 
| 53079 | 419 | shows "summable (\<lambda>n. (diffs c)(n) * (x ^ n)) \<Longrightarrow> | 
| 420 | (\<lambda>n. of_nat n * c(n) * (x ^ (n - Suc 0))) sums | |
| 15546 | 421 | (\<Sum>n. (diffs c)(n) * (x ^ n))" | 
| 53079 | 422 | unfolding diffs_def | 
| 423 | apply (drule summable_sums) | |
| 424 | apply (rule sums_Suc_imp, simp_all) | |
| 425 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 426 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 427 | lemma lemma_termdiff1: | 
| 31017 | 428 |   fixes z :: "'a :: {monoid_mult,comm_ring}" shows
 | 
| 41970 | 429 | "(\<Sum>p=0..<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) = | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 430 | (\<Sum>p=0..<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))" | 
| 53079 | 431 | by (auto simp add: algebra_simps power_add [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 432 | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 433 | lemma sumr_diff_mult_const2: | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 434 |   "setsum f {0..<n} - of_nat n * (r::'a::ring_1) = (\<Sum>i = 0..<n. f i - r)"
 | 
| 53079 | 435 | by (simp add: setsum_subtractf) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 436 | |
| 15229 | 437 | lemma lemma_termdiff2: | 
| 31017 | 438 |   fixes h :: "'a :: {field}"
 | 
| 53079 | 439 | assumes h: "h \<noteq> 0" | 
| 440 | shows | |
| 441 | "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = | |
| 442 | h * (\<Sum>p=0..< n - Suc 0. \<Sum>q=0..< n - Suc 0 - p. | |
| 443 | (z + h) ^ q * z ^ (n - 2 - q))" (is "?lhs = ?rhs") | |
| 444 | apply (subgoal_tac "h * ?lhs = h * ?rhs", simp add: h) | |
| 445 | apply (simp add: right_diff_distrib diff_divide_distrib h) | |
| 446 | apply (simp add: mult_assoc [symmetric]) | |
| 447 | apply (cases "n", simp) | |
| 448 | apply (simp add: lemma_realpow_diff_sumr2 h | |
| 449 | right_diff_distrib [symmetric] mult_assoc | |
| 450 | del: power_Suc setsum_op_ivl_Suc of_nat_Suc) | |
| 451 | apply (subst lemma_realpow_rev_sumr) | |
| 452 | apply (subst sumr_diff_mult_const2) | |
| 453 | apply simp | |
| 454 | apply (simp only: lemma_termdiff1 setsum_right_distrib) | |
| 455 | apply (rule setsum_cong [OF refl]) | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 456 | apply (simp add: less_iff_Suc_add) | 
| 53079 | 457 | apply (clarify) | 
| 458 | apply (simp add: setsum_right_distrib lemma_realpow_diff_sumr2 mult_ac | |
| 459 | del: setsum_op_ivl_Suc power_Suc) | |
| 460 | apply (subst mult_assoc [symmetric], subst power_add [symmetric]) | |
| 461 | apply (simp add: mult_ac) | |
| 462 | done | |
| 20860 | 463 | |
| 464 | lemma real_setsum_nat_ivl_bounded2: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34974diff
changeset | 465 | fixes K :: "'a::linordered_semidom" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 466 | assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" | 
| 53079 | 467 | and K: "0 \<le> K" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 468 |   shows "setsum f {0..<n-k} \<le> of_nat n * K"
 | 
| 53079 | 469 | apply (rule order_trans [OF setsum_mono]) | 
| 470 | apply (rule f, simp) | |
| 471 | apply (simp add: mult_right_mono K) | |
| 472 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 473 | |
| 15229 | 474 | lemma lemma_termdiff3: | 
| 31017 | 475 |   fixes h z :: "'a::{real_normed_field}"
 | 
| 20860 | 476 | assumes 1: "h \<noteq> 0" | 
| 53079 | 477 | and 2: "norm z \<le> K" | 
| 478 | and 3: "norm (z + h) \<le> K" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 479 | shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 480 | \<le> of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | 
| 20860 | 481 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 482 | have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 483 | norm (\<Sum>p = 0..<n - Suc 0. \<Sum>q = 0..<n - Suc 0 - p. | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 484 | (z + h) ^ q * z ^ (n - 2 - q)) * norm h" | 
| 20860 | 485 | apply (subst lemma_termdiff2 [OF 1]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 486 | apply (subst norm_mult) | 
| 20860 | 487 | apply (rule mult_commute) | 
| 488 | done | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 489 | also have "\<dots> \<le> of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2)) * norm h" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 490 | proof (rule mult_right_mono [OF _ norm_ge_zero]) | 
| 53079 | 491 | from norm_ge_zero 2 have K: "0 \<le> K" | 
| 492 | by (rule order_trans) | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 493 | have le_Kn: "\<And>i j n. i + j = n \<Longrightarrow> norm ((z + h) ^ i * z ^ j) \<le> K ^ n" | 
| 20860 | 494 | apply (erule subst) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 495 | apply (simp only: norm_mult norm_power power_add) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 496 | apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) | 
| 20860 | 497 | done | 
| 53079 | 498 | show "norm (\<Sum>p = 0..<n - Suc 0. \<Sum>q = 0..<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 499 | \<le> of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" | 
| 20860 | 500 | apply (intro | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 501 | order_trans [OF norm_setsum] | 
| 20860 | 502 | real_setsum_nat_ivl_bounded2 | 
| 503 | mult_nonneg_nonneg | |
| 47489 | 504 | of_nat_0_le_iff | 
| 20860 | 505 | zero_le_power K) | 
| 506 | apply (rule le_Kn, simp) | |
| 507 | done | |
| 508 | qed | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 509 | also have "\<dots> = of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | 
| 20860 | 510 | by (simp only: mult_assoc) | 
| 511 | finally show ?thesis . | |
| 512 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 513 | |
| 20860 | 514 | lemma lemma_termdiff4: | 
| 31017 | 515 |   fixes f :: "'a::{real_normed_field} \<Rightarrow>
 | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 516 | 'b::real_normed_vector" | 
| 20860 | 517 | assumes k: "0 < (k::real)" | 
| 53079 | 518 | and le: "\<And>h. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (f h) \<le> K * norm h" | 
| 20860 | 519 | shows "f -- 0 --> 0" | 
| 53079 | 520 | unfolding LIM_eq diff_0_right | 
| 521 | proof safe | |
| 29163 | 522 | let ?h = "of_real (k / 2)::'a" | 
| 523 | have "?h \<noteq> 0" and "norm ?h < k" using k by simp_all | |
| 524 | hence "norm (f ?h) \<le> K * norm ?h" by (rule le) | |
| 525 | hence "0 \<le> K * norm ?h" by (rule order_trans [OF norm_ge_zero]) | |
| 526 | hence zero_le_K: "0 \<le> K" using k by (simp add: zero_le_mult_iff) | |
| 527 | ||
| 53079 | 528 | fix r::real | 
| 529 | assume r: "0 < r" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 530 | show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> norm x < s \<longrightarrow> norm (f x) < r)" | 
| 53079 | 531 | proof cases | 
| 20860 | 532 | assume "K = 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 533 | with k r le have "0 < k \<and> (\<forall>x. x \<noteq> 0 \<and> norm x < k \<longrightarrow> norm (f x) < r)" | 
| 20860 | 534 | by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 535 | thus "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> norm x < s \<longrightarrow> norm (f x) < r)" .. | 
| 20860 | 536 | next | 
| 537 | assume K_neq_zero: "K \<noteq> 0" | |
| 538 | with zero_le_K have K: "0 < K" by simp | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 539 | show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> norm x < s \<longrightarrow> norm (f x) < r)" | 
| 20860 | 540 | proof (rule exI, safe) | 
| 53079 | 541 | from k r K | 
| 542 | show "0 < min k (r * inverse K / 2)" | |
| 20860 | 543 | by (simp add: mult_pos_pos positive_imp_inverse_positive) | 
| 544 | next | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 545 | fix x::'a | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 546 | assume x1: "x \<noteq> 0" and x2: "norm x < min k (r * inverse K / 2)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 547 | from x2 have x3: "norm x < k" and x4: "norm x < r * inverse K / 2" | 
| 20860 | 548 | by simp_all | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 549 | from x1 x3 le have "norm (f x) \<le> K * norm x" by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 550 | also from x4 K have "K * norm x < K * (r * inverse K / 2)" | 
| 20860 | 551 | by (rule mult_strict_left_mono) | 
| 552 | also have "\<dots> = r / 2" | |
| 553 | using K_neq_zero by simp | |
| 554 | also have "r / 2 < r" | |
| 555 | using r by simp | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 556 | finally show "norm (f x) < r" . | 
| 20860 | 557 | qed | 
| 558 | qed | |
| 559 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 560 | |
| 15229 | 561 | lemma lemma_termdiff5: | 
| 53079 | 562 | fixes g :: "'a::real_normed_field \<Rightarrow> nat \<Rightarrow> 'b::banach" | 
| 20860 | 563 | assumes k: "0 < (k::real)" | 
| 564 | assumes f: "summable f" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 565 | assumes le: "\<And>h n. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (g h n) \<le> f n * norm h" | 
| 20860 | 566 | shows "(\<lambda>h. suminf (g h)) -- 0 --> 0" | 
| 567 | proof (rule lemma_termdiff4 [OF k]) | |
| 53079 | 568 | fix h::'a | 
| 569 | assume "h \<noteq> 0" and "norm h < k" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 570 | hence A: "\<forall>n. norm (g h n) \<le> f n * norm h" | 
| 20860 | 571 | by (simp add: le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 572 | hence "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h" | 
| 20860 | 573 | by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 574 | moreover from f have B: "summable (\<lambda>n. f n * norm h)" | 
| 20860 | 575 | by (rule summable_mult2) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 576 | ultimately have C: "summable (\<lambda>n. norm (g h n))" | 
| 20860 | 577 | by (rule summable_comparison_test) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 578 | hence "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 579 | by (rule summable_norm) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 580 | also from A C B have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)" | 
| 20860 | 581 | by (rule summable_le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 582 | also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h" | 
| 20860 | 583 | by (rule suminf_mult2 [symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 584 | finally show "norm (suminf (g h)) \<le> suminf f * norm h" . | 
| 20860 | 585 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 586 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 587 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 588 | text{* FIXME: Long proofs*}
 | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 589 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 590 | lemma termdiffs_aux: | 
| 31017 | 591 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 592 | assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)" | 
| 53079 | 593 | and 2: "norm x < norm K" | 
| 20860 | 594 | shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x ^ n) / h | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 595 | - of_nat n * x ^ (n - Suc 0))) -- 0 --> 0" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 596 | proof - | 
| 20860 | 597 | from dense [OF 2] | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 598 | obtain r where r1: "norm x < r" and r2: "r < norm K" by fast | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 599 | from norm_ge_zero r1 have r: "0 < r" | 
| 20860 | 600 | by (rule order_le_less_trans) | 
| 601 | hence r_neq_0: "r \<noteq> 0" by simp | |
| 602 | show ?thesis | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 603 | proof (rule lemma_termdiff5) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 604 | show "0 < r - norm x" using r1 by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 605 | from r r2 have "norm (of_real r::'a) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 606 | by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 607 | with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))" | 
| 20860 | 608 | by (rule powser_insidea) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 609 | hence "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 610 | using r | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 611 | by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 612 | hence "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))" | 
| 20860 | 613 | by (rule diffs_equiv [THEN sums_summable]) | 
| 53079 | 614 | also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) = | 
| 615 | (\<lambda>n. diffs (\<lambda>m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))" | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 616 | apply (rule ext) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 617 | apply (simp add: diffs_def) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 618 | apply (case_tac n, simp_all add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 619 | done | 
| 41970 | 620 | finally have "summable | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 621 | (\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" | 
| 20860 | 622 | by (rule diffs_equiv [THEN sums_summable]) | 
| 623 | also have | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 624 | "(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * | 
| 20860 | 625 | r ^ (n - Suc 0)) = | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 626 | (\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 627 | apply (rule ext) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 628 | apply (case_tac "n", simp) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 629 | apply (case_tac "nat", simp) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 630 | apply (simp add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 631 | done | 
| 53079 | 632 | finally | 
| 633 | show "summable (\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" . | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 634 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 635 | fix h::'a and n::nat | 
| 20860 | 636 | assume h: "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 637 | assume "norm h < r - norm x" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 638 | hence "norm x + norm h < r" by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 639 | with norm_triangle_ineq have xh: "norm (x + h) < r" | 
| 20860 | 640 | by (rule order_le_less_trans) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 641 | show "norm (c n * (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0))) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 642 | \<le> norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 643 | apply (simp only: norm_mult mult_assoc) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 644 | apply (rule mult_left_mono [OF _ norm_ge_zero]) | 
| 20860 | 645 | apply (simp (no_asm) add: mult_assoc [symmetric]) | 
| 646 | apply (rule lemma_termdiff3) | |
| 647 | apply (rule h) | |
| 648 | apply (rule r1 [THEN order_less_imp_le]) | |
| 649 | apply (rule xh [THEN order_less_imp_le]) | |
| 650 | done | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 651 | qed | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 652 | qed | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19765diff
changeset | 653 | |
| 20860 | 654 | lemma termdiffs: | 
| 31017 | 655 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 656 | assumes 1: "summable (\<lambda>n. c n * K ^ n)" | 
| 53079 | 657 | and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)" | 
| 658 | and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)" | |
| 659 | and 4: "norm x < norm K" | |
| 20860 | 660 | shows "DERIV (\<lambda>x. \<Sum>n. c n * x ^ n) x :> (\<Sum>n. (diffs c) n * x ^ n)" | 
| 53079 | 661 | unfolding deriv_def | 
| 29163 | 662 | proof (rule LIM_zero_cancel) | 
| 20860 | 663 | show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x ^ n)) / h | 
| 664 | - suminf (\<lambda>n. diffs c n * x ^ n)) -- 0 --> 0" | |
| 665 | proof (rule LIM_equal2) | |
| 29163 | 666 | show "0 < norm K - norm x" using 4 by (simp add: less_diff_eq) | 
| 20860 | 667 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 668 | fix h :: 'a | 
| 20860 | 669 | assume "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 670 | assume "norm (h - 0) < norm K - norm x" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 671 | hence "norm x + norm h < norm K" by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 672 | hence 5: "norm (x + h) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 673 | by (rule norm_triangle_ineq [THEN order_le_less_trans]) | 
| 20860 | 674 | have A: "summable (\<lambda>n. c n * x ^ n)" | 
| 675 | by (rule powser_inside [OF 1 4]) | |
| 676 | have B: "summable (\<lambda>n. c n * (x + h) ^ n)" | |
| 677 | by (rule powser_inside [OF 1 5]) | |
| 678 | have C: "summable (\<lambda>n. diffs c n * x ^ n)" | |
| 679 | by (rule powser_inside [OF 2 4]) | |
| 680 | show "((\<Sum>n. c n * (x + h) ^ n) - (\<Sum>n. c n * x ^ n)) / h | |
| 41970 | 681 | - (\<Sum>n. diffs c n * x ^ n) = | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 682 | (\<Sum>n. c n * (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0)))" | 
| 20860 | 683 | apply (subst sums_unique [OF diffs_equiv [OF C]]) | 
| 684 | apply (subst suminf_diff [OF B A]) | |
| 685 | apply (subst suminf_divide [symmetric]) | |
| 686 | apply (rule summable_diff [OF B A]) | |
| 687 | apply (subst suminf_diff) | |
| 688 | apply (rule summable_divide) | |
| 689 | apply (rule summable_diff [OF B A]) | |
| 690 | apply (rule sums_summable [OF diffs_equiv [OF C]]) | |
| 29163 | 691 | apply (rule arg_cong [where f="suminf"], rule ext) | 
| 29667 | 692 | apply (simp add: algebra_simps) | 
| 20860 | 693 | done | 
| 694 | next | |
| 53079 | 695 | show "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x ^ n) / h - of_nat n * x ^ (n - Suc 0))) -- 0 --> 0" | 
| 696 | by (rule termdiffs_aux [OF 3 4]) | |
| 20860 | 697 | qed | 
| 698 | qed | |
| 699 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 700 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 701 | subsection {* Derivability of power series *}
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 702 | |
| 53079 | 703 | lemma DERIV_series': | 
| 704 | fixes f :: "real \<Rightarrow> nat \<Rightarrow> real" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 705 | assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)" | 
| 53079 | 706 |     and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)" and x0_in_I: "x0 \<in> {a <..< b}"
 | 
| 707 | and "summable (f' x0)" | |
| 708 | and "summable L" | |
| 709 |     and L_def: "\<And>n x y. \<lbrakk> x \<in> { a <..< b} ; y \<in> { a <..< b} \<rbrakk> \<Longrightarrow> \<bar>f x n - f y n\<bar> \<le> L n * \<bar>x - y\<bar>"
 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 710 | shows "DERIV (\<lambda> x. suminf (f x)) x0 :> (suminf (f' x0))" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 711 | unfolding deriv_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 712 | proof (rule LIM_I) | 
| 53079 | 713 | fix r :: real | 
| 714 | assume "0 < r" hence "0 < r/3" by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 715 | |
| 41970 | 716 | obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 717 | using suminf_exist_split[OF `0 < r/3` `summable L`] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 718 | |
| 41970 | 719 | obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 720 | using suminf_exist_split[OF `0 < r/3` `summable (f' x0)`] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 721 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 722 | let ?N = "Suc (max N_L N_f')" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 723 | have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3") and | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 724 | L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3" using N_L[of "?N"] and N_f' [of "?N"] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 725 | |
| 53079 | 726 | let ?diff = "\<lambda>i x. (f (x0 + x) i - f x0 i) / x" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 727 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 728 | let ?r = "r / (3 * real ?N)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 729 | have "0 < 3 * real ?N" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 730 | from divide_pos_pos[OF `0 < r` this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 731 | have "0 < ?r" . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 732 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 733 | let "?s n" = "SOME s. 0 < s \<and> (\<forall> x. x \<noteq> 0 \<and> \<bar> x \<bar> < s \<longrightarrow> \<bar> ?diff n x - f' x0 n \<bar> < ?r)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 734 |   def S' \<equiv> "Min (?s ` { 0 ..< ?N })"
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 735 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 736 | have "0 < S'" unfolding S'_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 737 | proof (rule iffD2[OF Min_gr_iff]) | 
| 53079 | 738 |     show "\<forall>x \<in> (?s ` { 0 ..< ?N }). 0 < x"
 | 
| 739 | proof | |
| 740 | fix x | |
| 741 |       assume "x \<in> ?s ` {0..<?N}"
 | |
| 742 |       then obtain n where "x = ?s n" and "n \<in> {0..<?N}"
 | |
| 743 | using image_iff[THEN iffD1] by blast | |
| 41970 | 744 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF `0 < ?r`, unfolded real_norm_def] | 
| 53079 | 745 | obtain s where s_bound: "0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < s \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r)" | 
| 746 | by auto | |
| 747 | have "0 < ?s n" by (rule someI2[where a=s]) (auto simp add: s_bound) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 748 | thus "0 < x" unfolding `x = ?s n` . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 749 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 750 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 751 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 752 | def S \<equiv> "min (min (x0 - a) (b - x0)) S'" | 
| 53079 | 753 | hence "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0" | 
| 754 | and "S \<le> S'" using x0_in_I and `0 < S'` | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 755 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 756 | |
| 53079 | 757 |   {
 | 
| 758 | fix x | |
| 759 | assume "x \<noteq> 0" and "\<bar> x \<bar> < S" | |
| 760 |     hence x_in_I: "x0 + x \<in> { a <..< b }"
 | |
| 761 | using S_a S_b by auto | |
| 41970 | 762 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 763 | note diff_smbl = summable_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 764 | note div_smbl = summable_divide[OF diff_smbl] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 765 | note all_smbl = summable_diff[OF div_smbl `summable (f' x0)`] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 766 | note ign = summable_ignore_initial_segment[where k="?N"] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 767 | note diff_shft_smbl = summable_diff[OF ign[OF allf_summable[OF x_in_I]] ign[OF allf_summable[OF x0_in_I]]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 768 | note div_shft_smbl = summable_divide[OF diff_shft_smbl] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 769 | note all_shft_smbl = summable_diff[OF div_smbl ign[OF `summable (f' x0)`]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 770 | |
| 53079 | 771 |     {
 | 
| 772 | fix n | |
| 41970 | 773 | have "\<bar> ?diff (n + ?N) x \<bar> \<le> L (n + ?N) * \<bar> (x0 + x) - x0 \<bar> / \<bar> x \<bar>" | 
| 53079 | 774 | using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero] | 
| 775 | unfolding abs_divide . | |
| 776 | hence "\<bar> (\<bar>?diff (n + ?N) x \<bar>) \<bar> \<le> L (n + ?N)" | |
| 777 | using `x \<noteq> 0` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 778 | } note L_ge = summable_le2[OF allI[OF this] ign[OF `summable L`]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 779 | from order_trans[OF summable_rabs[OF conjunct1[OF L_ge]] L_ge[THEN conjunct2]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 780 | have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))" . | 
| 53079 | 781 | hence "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> r / 3" (is "?L_part \<le> r/3") | 
| 782 | using L_estimate by auto | |
| 783 | ||
| 784 |     have "\<bar>\<Sum>n \<in> { 0 ..< ?N}. ?diff n x - f' x0 n \<bar> \<le>
 | |
| 785 |       (\<Sum>n \<in> { 0 ..< ?N}. \<bar>?diff n x - f' x0 n \<bar>)" ..
 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 786 |     also have "\<dots> < (\<Sum>n \<in> { 0 ..< ?N}. ?r)"
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 787 | proof (rule setsum_strict_mono) | 
| 53079 | 788 | fix n | 
| 789 |       assume "n \<in> { 0 ..< ?N}"
 | |
| 790 | have "\<bar>x\<bar> < S" using `\<bar>x\<bar> < S` . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 791 | also have "S \<le> S'" using `S \<le> S'` . | 
| 41970 | 792 | also have "S' \<le> ?s n" unfolding S'_def | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 793 | proof (rule Min_le_iff[THEN iffD2]) | 
| 53079 | 794 |         have "?s n \<in> (?s ` {0..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 795 |           using `n \<in> { 0 ..< ?N}` by auto
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 796 |         thus "\<exists> a \<in> (?s ` {0..<?N}). a \<le> ?s n" by blast
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 797 | qed auto | 
| 53079 | 798 | finally have "\<bar>x\<bar> < ?s n" . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 799 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 800 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF `0 < ?r`, unfolded real_norm_def diff_0_right, unfolded some_eq_ex[symmetric], THEN conjunct2] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 801 | have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" . | 
| 53079 | 802 | with `x \<noteq> 0` and `\<bar>x\<bar> < ?s n` show "\<bar>?diff n x - f' x0 n\<bar> < ?r" | 
| 803 | by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 804 | qed auto | 
| 53079 | 805 |     also have "\<dots> = of_nat (card {0 ..< ?N}) * ?r"
 | 
| 806 | by (rule setsum_constant) | |
| 807 | also have "\<dots> = real ?N * ?r" | |
| 808 | unfolding real_eq_of_nat by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 809 | also have "\<dots> = r/3" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 810 |     finally have "\<bar>\<Sum>n \<in> { 0 ..< ?N}. ?diff n x - f' x0 n \<bar> < r / 3" (is "?diff_part < r / 3") .
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 811 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 812 | from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 53079 | 813 | have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> = | 
| 814 | \<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>" | |
| 815 | unfolding suminf_diff[OF div_smbl `summable (f' x0)`, symmetric] | |
| 816 | using suminf_divide[OF diff_smbl, symmetric] by auto | |
| 817 | also have "\<dots> \<le> ?diff_part + \<bar> (\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N)) \<bar>" | |
| 818 | unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"] | |
| 819 | unfolding suminf_diff[OF div_shft_smbl ign[OF `summable (f' x0)`]] | |
| 820 | by (rule abs_triangle_ineq) | |
| 821 | also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part" | |
| 822 | using abs_triangle_ineq4 by auto | |
| 41970 | 823 | also have "\<dots> < r /3 + r/3 + r/3" | 
| 36842 | 824 | using `?diff_part < r/3` `?L_part \<le> r/3` and `?f'_part < r/3` | 
| 825 | by (rule add_strict_mono [OF add_less_le_mono]) | |
| 53079 | 826 | finally have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 827 | by auto | 
| 53079 | 828 | } | 
| 829 | thus "\<exists> s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow> | |
| 830 | norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r" | |
| 831 | using `0 < S` unfolding real_norm_def diff_0_right by blast | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 832 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 833 | |
| 53079 | 834 | lemma DERIV_power_series': | 
| 835 | fixes f :: "nat \<Rightarrow> real" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 836 |   assumes converges: "\<And> x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda> n. f n * real (Suc n) * x^n)"
 | 
| 53079 | 837 |     and x0_in_I: "x0 \<in> {-R <..< R}" and "0 < R"
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 838 | shows "DERIV (\<lambda> x. (\<Sum> n. f n * x^(Suc n))) x0 :> (\<Sum> n. f n * real (Suc n) * x0^n)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 839 | (is "DERIV (\<lambda> x. (suminf (?f x))) x0 :> (suminf (?f' x0))") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 840 | proof - | 
| 53079 | 841 |   {
 | 
| 842 | fix R' | |
| 843 | assume "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" | |
| 844 |     hence "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | |
| 845 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 846 | have "DERIV (\<lambda> x. (suminf (?f x))) x0 :> (suminf (?f' x0))" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 847 | proof (rule DERIV_series') | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 848 | show "summable (\<lambda> n. \<bar>f n * real (Suc n) * R'^n\<bar>)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 849 | proof - | 
| 53079 | 850 | have "(R' + R) / 2 < R" and "0 < (R' + R) / 2" | 
| 851 | using `0 < R'` `0 < R` `R' < R` by auto | |
| 852 |         hence in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | |
| 853 | using `R' < R` by auto | |
| 854 | have "norm R' < norm ((R' + R) / 2)" | |
| 855 | using `0 < R'` `0 < R` `R' < R` by auto | |
| 856 | from powser_insidea[OF converges[OF in_Rball] this] show ?thesis | |
| 857 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 858 | qed | 
| 53079 | 859 |       {
 | 
| 860 | fix n x y | |
| 861 |         assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 862 | show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 863 | proof - | 
| 53079 | 864 | have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> = | 
| 865 | (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p = 0..<Suc n. x ^ p * y ^ (n - p)\<bar>" | |
| 866 | unfolding right_diff_distrib[symmetric] lemma_realpow_diff_sumr2 abs_mult | |
| 867 | by auto | |
| 41970 | 868 | also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 869 | proof (rule mult_left_mono) | 
| 53079 | 870 | have "\<bar>\<Sum>p = 0..<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> (\<Sum>p = 0..<Suc n. \<bar>x ^ p * y ^ (n - p)\<bar>)" | 
| 871 | by (rule setsum_abs) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 872 | also have "\<dots> \<le> (\<Sum>p = 0..<Suc n. R' ^ n)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 873 | proof (rule setsum_mono) | 
| 53079 | 874 | fix p | 
| 875 |               assume "p \<in> {0..<Suc n}"
 | |
| 876 | hence "p \<le> n" by auto | |
| 877 |               {
 | |
| 878 | fix n | |
| 879 | fix x :: real | |
| 880 |                 assume "x \<in> {-R'<..<R'}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 881 | hence "\<bar>x\<bar> \<le> R'" by auto | 
| 53079 | 882 | hence "\<bar>x^n\<bar> \<le> R'^n" | 
| 883 | unfolding power_abs by (rule power_mono, auto) | |
| 884 | } | |
| 885 |               from mult_mono[OF this[OF `x \<in> {-R'<..<R'}`, of p] this[OF `y \<in> {-R'<..<R'}`, of "n-p"]] `0 < R'`
 | |
| 886 | have "\<bar>x^p * y^(n-p)\<bar> \<le> R'^p * R'^(n-p)" | |
| 887 | unfolding abs_mult by auto | |
| 888 | thus "\<bar>x^p * y^(n-p)\<bar> \<le> R'^n" | |
| 889 | unfolding power_add[symmetric] using `p \<le> n` by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 890 | qed | 
| 53079 | 891 | also have "\<dots> = real (Suc n) * R' ^ n" | 
| 892 | unfolding setsum_constant card_atLeastLessThan real_of_nat_def by auto | |
| 893 | finally show "\<bar>\<Sum>p = 0..<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>" | |
| 894 | unfolding abs_real_of_nat_cancel abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF `0 < R'`]]] . | |
| 895 | show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>" | |
| 896 | unfolding abs_mult[symmetric] by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 897 | qed | 
| 53079 | 898 | also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>" | 
| 899 | unfolding abs_mult mult_assoc[symmetric] by algebra | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 900 | finally show ?thesis . | 
| 53079 | 901 | qed | 
| 902 | } | |
| 903 |       {
 | |
| 904 | fix n | |
| 905 | show "DERIV (\<lambda> x. ?f x n) x0 :> (?f' x0 n)" | |
| 906 | by (auto intro!: DERIV_intros simp del: power_Suc) | |
| 907 | } | |
| 908 |       {
 | |
| 909 | fix x | |
| 910 |         assume "x \<in> {-R' <..< R'}"
 | |
| 911 |         hence "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | |
| 912 | using assms `R' < R` by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 913 | have "summable (\<lambda> n. f n * x^n)" | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 914 |         proof (rule summable_le2[THEN conjunct1, OF _ powser_insidea[OF converges[OF `R' \<in> {-R <..< R}`] `norm x < norm R'`]], rule allI)
 | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 915 | fix n | 
| 53079 | 916 | have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)" | 
| 917 | by (rule mult_left_mono) auto | |
| 918 | show "\<bar>f n * x ^ n\<bar> \<le> norm (f n * real (Suc n) * x ^ n)" | |
| 919 | unfolding real_norm_def abs_mult | |
| 920 | by (rule mult_right_mono) (auto simp add: le[unfolded mult_1_right]) | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 921 | qed | 
| 36777 
be5461582d0f
avoid using real-specific versions of generic lemmas
 huffman parents: 
36776diff
changeset | 922 | from this[THEN summable_mult2[where c=x], unfolded mult_assoc, unfolded mult_commute] | 
| 53079 | 923 | show "summable (?f x)" by auto | 
| 924 | } | |
| 925 | show "summable (?f' x0)" | |
| 926 |         using converges[OF `x0 \<in> {-R <..< R}`] .
 | |
| 927 |       show "x0 \<in> {-R' <..< R'}"
 | |
| 928 |         using `x0 \<in> {-R' <..< R'}` .
 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 929 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 930 | } note for_subinterval = this | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 931 | let ?R = "(R + \<bar>x0\<bar>) / 2" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 932 | have "\<bar>x0\<bar> < ?R" using assms by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 933 | hence "- ?R < x0" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 934 | proof (cases "x0 < 0") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 935 | case True | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 936 | hence "- x0 < ?R" using `\<bar>x0\<bar> < ?R` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 937 | thus ?thesis unfolding neg_less_iff_less[symmetric, of "- x0"] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 938 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 939 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 940 | have "- ?R < 0" using assms by auto | 
| 41970 | 941 | also have "\<dots> \<le> x0" using False by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 942 | finally show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 943 | qed | 
| 53079 | 944 | hence "0 < ?R" "?R < R" "- ?R < x0" and "x0 < ?R" | 
| 945 | using assms by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 946 | from for_subinterval[OF this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 947 | show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 948 | qed | 
| 29695 | 949 | |
| 53079 | 950 | |
| 29164 | 951 | subsection {* Exponential Function *}
 | 
| 23043 | 952 | |
| 53079 | 953 | definition exp :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 954 | where "exp = (\<lambda>x. \<Sum>n. x ^ n /\<^sub>R real (fact n))" | |
| 23043 | 955 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 956 | lemma summable_exp_generic: | 
| 31017 | 957 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 25062 | 958 | defines S_def: "S \<equiv> \<lambda>n. x ^ n /\<^sub>R real (fact n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 959 | shows "summable S" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 960 | proof - | 
| 25062 | 961 | have S_Suc: "\<And>n. S (Suc n) = (x * S n) /\<^sub>R real (Suc n)" | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
30082diff
changeset | 962 | unfolding S_def by (simp del: mult_Suc) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 963 | obtain r :: real where r0: "0 < r" and r1: "r < 1" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 964 | using dense [OF zero_less_one] by fast | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 965 | obtain N :: nat where N: "norm x < real N * r" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 966 | using reals_Archimedean3 [OF r0] by fast | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 967 | from r1 show ?thesis | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 968 | proof (rule ratio_test [rule_format]) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 969 | fix n :: nat | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 970 | assume n: "N \<le> n" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 971 | have "norm x \<le> real N * r" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 972 | using N by (rule order_less_imp_le) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 973 | also have "real N * r \<le> real (Suc n) * r" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 974 | using r0 n by (simp add: mult_right_mono) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 975 | finally have "norm x * norm (S n) \<le> real (Suc n) * r * norm (S n)" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 976 | using norm_ge_zero by (rule mult_right_mono) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 977 | hence "norm (x * S n) \<le> real (Suc n) * r * norm (S n)" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 978 | by (rule order_trans [OF norm_mult_ineq]) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 979 | hence "norm (x * S n) / real (Suc n) \<le> r * norm (S n)" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 980 | by (simp add: pos_divide_le_eq mult_ac) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 981 | thus "norm (S (Suc n)) \<le> r * norm (S n)" | 
| 35216 | 982 | by (simp add: S_Suc inverse_eq_divide) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 983 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 984 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 985 | |
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 986 | lemma summable_norm_exp: | 
| 31017 | 987 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 25062 | 988 | shows "summable (\<lambda>n. norm (x ^ n /\<^sub>R real (fact n)))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 989 | proof (rule summable_norm_comparison_test [OF exI, rule_format]) | 
| 25062 | 990 | show "summable (\<lambda>n. norm x ^ n /\<^sub>R real (fact n))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 991 | by (rule summable_exp_generic) | 
| 53079 | 992 | fix n | 
| 993 | show "norm (x ^ n /\<^sub>R real (fact n)) \<le> norm x ^ n /\<^sub>R real (fact n)" | |
| 35216 | 994 | by (simp add: norm_power_ineq) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 995 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 996 | |
| 53079 | 997 | lemma summable_exp: "summable (\<lambda>n. inverse (real (fact n)) * x ^ n)" | 
| 998 | using summable_exp_generic [where x=x] by simp | |
| 23043 | 999 | |
| 25062 | 1000 | lemma exp_converges: "(\<lambda>n. x ^ n /\<^sub>R real (fact n)) sums exp x" | 
| 53079 | 1001 | unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) | 
| 23043 | 1002 | |
| 1003 | ||
| 41970 | 1004 | lemma exp_fdiffs: | 
| 53079 | 1005 | "diffs (\<lambda>n. inverse(real (fact n))) = (\<lambda>n. inverse(real (fact n)))" | 
| 1006 | by (simp add: diffs_def mult_assoc [symmetric] real_of_nat_def of_nat_mult | |
| 1007 | del: mult_Suc of_nat_Suc) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1008 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1009 | lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))" | 
| 53079 | 1010 | by (simp add: diffs_def) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1011 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1012 | lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)" | 
| 53079 | 1013 | unfolding exp_def scaleR_conv_of_real | 
| 1014 | apply (rule DERIV_cong) | |
| 1015 | apply (rule termdiffs [where K="of_real (1 + norm x)"]) | |
| 1016 | apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs) | |
| 1017 | apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+ | |
| 1018 | apply (simp del: of_real_add) | |
| 1019 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1020 | |
| 51527 | 1021 | declare DERIV_exp[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | 
| 1022 | ||
| 44311 | 1023 | lemma isCont_exp: "isCont exp x" | 
| 1024 | by (rule DERIV_exp [THEN DERIV_isCont]) | |
| 1025 | ||
| 1026 | lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a" | |
| 1027 | by (rule isCont_o2 [OF _ isCont_exp]) | |
| 1028 | ||
| 1029 | lemma tendsto_exp [tendsto_intros]: | |
| 1030 | "(f ---> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) ---> exp a) F" | |
| 1031 | by (rule isCont_tendsto_compose [OF isCont_exp]) | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1032 | |
| 53079 | 1033 | lemma continuous_exp [continuous_intros]: | 
| 1034 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))" | |
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1035 | unfolding continuous_def by (rule tendsto_exp) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1036 | |
| 53079 | 1037 | lemma continuous_on_exp [continuous_on_intros]: | 
| 1038 | "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))" | |
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1039 | unfolding continuous_on_def by (auto intro: tendsto_exp) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1040 | |
| 53079 | 1041 | |
| 29167 | 1042 | subsubsection {* Properties of the Exponential Function *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1043 | |
| 23278 | 1044 | lemma powser_zero: | 
| 31017 | 1045 |   fixes f :: "nat \<Rightarrow> 'a::{real_normed_algebra_1}"
 | 
| 23278 | 1046 | shows "(\<Sum>n. f n * 0 ^ n) = f 0" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1047 | proof - | 
| 23278 | 1048 | have "(\<Sum>n = 0..<1. f n * 0 ^ n) = (\<Sum>n. f n * 0 ^ n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1049 | by (rule sums_unique [OF series_zero], simp add: power_0_left) | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 1050 | thus ?thesis unfolding One_nat_def by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1051 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1052 | |
| 23278 | 1053 | lemma exp_zero [simp]: "exp 0 = 1" | 
| 53079 | 1054 | unfolding exp_def by (simp add: scaleR_conv_of_real powser_zero) | 
| 23278 | 1055 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1056 | lemma setsum_cl_ivl_Suc2: | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1057 | "(\<Sum>i=m..Suc n. f i) = (if Suc n < m then 0 else f m + (\<Sum>i=m..n. f (Suc i)))" | 
| 53079 | 1058 | by (simp add: setsum_head_Suc setsum_shift_bounds_cl_Suc_ivl | 
| 1059 | del: setsum_cl_ivl_Suc) | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1060 | |
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1061 | lemma exp_series_add: | 
| 31017 | 1062 |   fixes x y :: "'a::{real_field}"
 | 
| 25062 | 1063 | defines S_def: "S \<equiv> \<lambda>x n. x ^ n /\<^sub>R real (fact n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1064 | shows "S (x + y) n = (\<Sum>i=0..n. S x i * S y (n - i))" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1065 | proof (induct n) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1066 | case 0 | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1067 | show ?case | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1068 | unfolding S_def by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1069 | next | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1070 | case (Suc n) | 
| 25062 | 1071 | have S_Suc: "\<And>x n. S x (Suc n) = (x * S x n) /\<^sub>R real (Suc n)" | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
30082diff
changeset | 1072 | unfolding S_def by (simp del: mult_Suc) | 
| 25062 | 1073 | hence times_S: "\<And>x n. x * S x n = real (Suc n) *\<^sub>R S x (Suc n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1074 | by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1075 | |
| 25062 | 1076 | have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * S (x + y) n" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1077 | by (simp only: times_S) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1078 | also have "\<dots> = (x + y) * (\<Sum>i=0..n. S x i * S y (n-i))" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1079 | by (simp only: Suc) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1080 | also have "\<dots> = x * (\<Sum>i=0..n. S x i * S y (n-i)) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1081 | + y * (\<Sum>i=0..n. S x i * S y (n-i))" | 
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 1082 | by (rule distrib_right) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1083 | also have "\<dots> = (\<Sum>i=0..n. (x * S x i) * S y (n-i)) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1084 | + (\<Sum>i=0..n. S x i * (y * S y (n-i)))" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1085 | by (simp only: setsum_right_distrib mult_ac) | 
| 25062 | 1086 | also have "\<dots> = (\<Sum>i=0..n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i))) | 
| 1087 | + (\<Sum>i=0..n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1088 | by (simp add: times_S Suc_diff_le) | 
| 25062 | 1089 | also have "(\<Sum>i=0..n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i))) = | 
| 1090 | (\<Sum>i=0..Suc n. real i *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1091 | by (subst setsum_cl_ivl_Suc2, simp) | 
| 25062 | 1092 | also have "(\<Sum>i=0..n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) = | 
| 1093 | (\<Sum>i=0..Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1094 | by (subst setsum_cl_ivl_Suc, simp) | 
| 25062 | 1095 | also have "(\<Sum>i=0..Suc n. real i *\<^sub>R (S x i * S y (Suc n-i))) + | 
| 1096 | (\<Sum>i=0..Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) = | |
| 1097 | (\<Sum>i=0..Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1098 | by (simp only: setsum_addf [symmetric] scaleR_left_distrib [symmetric] | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1099 | real_of_nat_add [symmetric], simp) | 
| 25062 | 1100 | also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i=0..Suc n. S x i * S y (Suc n-i))" | 
| 23127 | 1101 | by (simp only: scaleR_right.setsum) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1102 | finally show | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1103 | "S (x + y) (Suc n) = (\<Sum>i=0..Suc n. S x i * S y (Suc n - i))" | 
| 35216 | 1104 | by (simp del: setsum_cl_ivl_Suc) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1105 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1106 | |
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1107 | lemma exp_add: "exp (x + y) = exp x * exp y" | 
| 53079 | 1108 | unfolding exp_def | 
| 1109 | by (simp only: Cauchy_product summable_norm_exp exp_series_add) | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1110 | |
| 29170 | 1111 | lemma mult_exp_exp: "exp x * exp y = exp (x + y)" | 
| 53079 | 1112 | by (rule exp_add [symmetric]) | 
| 29170 | 1113 | |
| 23241 | 1114 | lemma exp_of_real: "exp (of_real x) = of_real (exp x)" | 
| 53079 | 1115 | unfolding exp_def | 
| 1116 | apply (subst suminf_of_real) | |
| 1117 | apply (rule summable_exp_generic) | |
| 1118 | apply (simp add: scaleR_conv_of_real) | |
| 1119 | done | |
| 23241 | 1120 | |
| 29170 | 1121 | lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0" | 
| 1122 | proof | |
| 1123 | have "exp x * exp (- x) = 1" by (simp add: mult_exp_exp) | |
| 1124 | also assume "exp x = 0" | |
| 1125 | finally show "False" by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1126 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1127 | |
| 29170 | 1128 | lemma exp_minus: "exp (- x) = inverse (exp x)" | 
| 53079 | 1129 | by (rule inverse_unique [symmetric], simp add: mult_exp_exp) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1130 | |
| 29170 | 1131 | lemma exp_diff: "exp (x - y) = exp x / exp y" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 1132 | using exp_add [of x "- y"] by (simp add: exp_minus divide_inverse) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1133 | |
| 29167 | 1134 | |
| 1135 | subsubsection {* Properties of the Exponential Function on Reals *}
 | |
| 1136 | ||
| 29170 | 1137 | text {* Comparisons of @{term "exp x"} with zero. *}
 | 
| 29167 | 1138 | |
| 1139 | text{*Proof: because every exponential can be seen as a square.*}
 | |
| 1140 | lemma exp_ge_zero [simp]: "0 \<le> exp (x::real)" | |
| 1141 | proof - | |
| 1142 | have "0 \<le> exp (x/2) * exp (x/2)" by simp | |
| 1143 | thus ?thesis by (simp add: exp_add [symmetric]) | |
| 1144 | qed | |
| 1145 | ||
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1146 | lemma exp_gt_zero [simp]: "0 < exp (x::real)" | 
| 53079 | 1147 | by (simp add: order_less_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1148 | |
| 29170 | 1149 | lemma not_exp_less_zero [simp]: "\<not> exp (x::real) < 0" | 
| 53079 | 1150 | by (simp add: not_less) | 
| 29170 | 1151 | |
| 1152 | lemma not_exp_le_zero [simp]: "\<not> exp (x::real) \<le> 0" | |
| 53079 | 1153 | by (simp add: not_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1154 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1155 | lemma abs_exp_cancel [simp]: "\<bar>exp x::real\<bar> = exp x" | 
| 53079 | 1156 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1157 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1158 | lemma exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n" | 
| 53079 | 1159 | by (induct n) (auto simp add: real_of_nat_Suc distrib_left exp_add mult_commute) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1160 | |
| 29170 | 1161 | text {* Strict monotonicity of exponential. *}
 | 
| 1162 | ||
| 53079 | 1163 | lemma exp_ge_add_one_self_aux: "0 \<le> (x::real) \<Longrightarrow> (1 + x) \<le> exp(x)" | 
| 1164 | apply (drule order_le_imp_less_or_eq, auto) | |
| 1165 | apply (simp add: exp_def) | |
| 1166 | apply (rule order_trans) | |
| 1167 | apply (rule_tac [2] n = 2 and f = "(\<lambda>n. inverse (real (fact n)) * x ^ n)" in series_pos_le) | |
| 1168 | apply (auto intro: summable_exp simp add: numeral_2_eq_2 zero_le_mult_iff) | |
| 1169 | done | |
| 29170 | 1170 | |
| 1171 | lemma exp_gt_one: "0 < (x::real) \<Longrightarrow> 1 < exp x" | |
| 1172 | proof - | |
| 1173 | assume x: "0 < x" | |
| 1174 | hence "1 < 1 + x" by simp | |
| 1175 | also from x have "1 + x \<le> exp x" | |
| 1176 | by (simp add: exp_ge_add_one_self_aux) | |
| 1177 | finally show ?thesis . | |
| 1178 | qed | |
| 1179 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1180 | lemma exp_less_mono: | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1181 | fixes x y :: real | 
| 53079 | 1182 | assumes "x < y" | 
| 1183 | shows "exp x < exp y" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1184 | proof - | 
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1185 | from `x < y` have "0 < y - x" by simp | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1186 | hence "1 < exp (y - x)" by (rule exp_gt_one) | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1187 | hence "1 < exp y / exp x" by (simp only: exp_diff) | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1188 | thus "exp x < exp y" by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1189 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1190 | |
| 53079 | 1191 | lemma exp_less_cancel: "exp (x::real) < exp y \<Longrightarrow> x < y" | 
| 1192 | apply (simp add: linorder_not_le [symmetric]) | |
| 1193 | apply (auto simp add: order_le_less exp_less_mono) | |
| 1194 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1195 | |
| 29170 | 1196 | lemma exp_less_cancel_iff [iff]: "exp (x::real) < exp y \<longleftrightarrow> x < y" | 
| 53079 | 1197 | by (auto intro: exp_less_mono exp_less_cancel) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1198 | |
| 29170 | 1199 | lemma exp_le_cancel_iff [iff]: "exp (x::real) \<le> exp y \<longleftrightarrow> x \<le> y" | 
| 53079 | 1200 | by (auto simp add: linorder_not_less [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1201 | |
| 29170 | 1202 | lemma exp_inj_iff [iff]: "exp (x::real) = exp y \<longleftrightarrow> x = y" | 
| 53079 | 1203 | by (simp add: order_eq_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1204 | |
| 29170 | 1205 | text {* Comparisons of @{term "exp x"} with one. *}
 | 
| 1206 | ||
| 1207 | lemma one_less_exp_iff [simp]: "1 < exp (x::real) \<longleftrightarrow> 0 < x" | |
| 1208 | using exp_less_cancel_iff [where x=0 and y=x] by simp | |
| 1209 | ||
| 1210 | lemma exp_less_one_iff [simp]: "exp (x::real) < 1 \<longleftrightarrow> x < 0" | |
| 1211 | using exp_less_cancel_iff [where x=x and y=0] by simp | |
| 1212 | ||
| 1213 | lemma one_le_exp_iff [simp]: "1 \<le> exp (x::real) \<longleftrightarrow> 0 \<le> x" | |
| 1214 | using exp_le_cancel_iff [where x=0 and y=x] by simp | |
| 1215 | ||
| 1216 | lemma exp_le_one_iff [simp]: "exp (x::real) \<le> 1 \<longleftrightarrow> x \<le> 0" | |
| 1217 | using exp_le_cancel_iff [where x=x and y=0] by simp | |
| 1218 | ||
| 1219 | lemma exp_eq_one_iff [simp]: "exp (x::real) = 1 \<longleftrightarrow> x = 0" | |
| 1220 | using exp_inj_iff [where x=x and y=0] by simp | |
| 1221 | ||
| 53079 | 1222 | lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x::real) = y" | 
| 44755 | 1223 | proof (rule IVT) | 
| 1224 | assume "1 \<le> y" | |
| 1225 | hence "0 \<le> y - 1" by simp | |
| 1226 | hence "1 + (y - 1) \<le> exp (y - 1)" by (rule exp_ge_add_one_self_aux) | |
| 1227 | thus "y \<le> exp (y - 1)" by simp | |
| 1228 | qed (simp_all add: le_diff_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1229 | |
| 53079 | 1230 | lemma exp_total: "0 < (y::real) \<Longrightarrow> \<exists>x. exp x = y" | 
| 44755 | 1231 | proof (rule linorder_le_cases [of 1 y]) | 
| 53079 | 1232 | assume "1 \<le> y" | 
| 1233 | thus "\<exists>x. exp x = y" by (fast dest: lemma_exp_total) | |
| 44755 | 1234 | next | 
| 1235 | assume "0 < y" and "y \<le> 1" | |
| 1236 | hence "1 \<le> inverse y" by (simp add: one_le_inverse_iff) | |
| 1237 | then obtain x where "exp x = inverse y" by (fast dest: lemma_exp_total) | |
| 1238 | hence "exp (- x) = y" by (simp add: exp_minus) | |
| 1239 | thus "\<exists>x. exp x = y" .. | |
| 1240 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1241 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1242 | |
| 29164 | 1243 | subsection {* Natural Logarithm *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1244 | |
| 53079 | 1245 | definition ln :: "real \<Rightarrow> real" | 
| 1246 | where "ln x = (THE u. exp u = x)" | |
| 23043 | 1247 | |
| 1248 | lemma ln_exp [simp]: "ln (exp x) = x" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1249 | by (simp add: ln_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1250 | |
| 22654 
c2b6b5a9e136
new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
 huffman parents: 
22653diff
changeset | 1251 | lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1252 | by (auto dest: exp_total) | 
| 22654 
c2b6b5a9e136
new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
 huffman parents: 
22653diff
changeset | 1253 | |
| 29171 | 1254 | lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1255 | by (metis exp_gt_zero exp_ln) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1256 | |
| 29171 | 1257 | lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1258 | by (erule subst, rule ln_exp) | 
| 29171 | 1259 | |
| 1260 | lemma ln_one [simp]: "ln 1 = 0" | |
| 53079 | 1261 | by (rule ln_unique) simp | 
| 1262 | ||
| 1263 | lemma ln_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y" | |
| 1264 | by (rule ln_unique) (simp add: exp_add) | |
| 29171 | 1265 | |
| 1266 | lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x" | |
| 53079 | 1267 | by (rule ln_unique) (simp add: exp_minus) | 
| 1268 | ||
| 1269 | lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y" | |
| 1270 | by (rule ln_unique) (simp add: exp_diff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1271 | |
| 29171 | 1272 | lemma ln_realpow: "0 < x \<Longrightarrow> ln (x ^ n) = real n * ln x" | 
| 53079 | 1273 | by (rule ln_unique) (simp add: exp_real_of_nat_mult) | 
| 1274 | ||
| 1275 | lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y" | |
| 1276 | by (subst exp_less_cancel_iff [symmetric]) simp | |
| 1277 | ||
| 1278 | lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1279 | by (simp add: linorder_not_less [symmetric]) | 
| 29171 | 1280 | |
| 53079 | 1281 | lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1282 | by (simp add: order_eq_iff) | 
| 29171 | 1283 | |
| 1284 | lemma ln_add_one_self_le_self [simp]: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1285 | apply (rule exp_le_cancel_iff [THEN iffD1]) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1286 | apply (simp add: exp_ge_add_one_self_aux) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1287 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1288 | |
| 29171 | 1289 | lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1290 | by (rule order_less_le_trans [where y="ln (1 + x)"]) simp_all | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1291 | |
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1292 | lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1293 | using ln_le_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1294 | |
| 53079 | 1295 | lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1296 | using ln_le_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1297 | |
| 53079 | 1298 | lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1299 | using ln_le_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1300 | |
| 53079 | 1301 | lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1302 | using ln_less_cancel_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1303 | |
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1304 | lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1305 | using ln_less_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1306 | |
| 53079 | 1307 | lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1308 | using ln_less_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1309 | |
| 53079 | 1310 | lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1311 | using ln_less_cancel_iff [of 1 x] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1312 | |
| 53079 | 1313 | lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1314 | using ln_inj_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1315 | |
| 53079 | 1316 | lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1317 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1318 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1319 | lemma isCont_ln: "0 < x \<Longrightarrow> isCont ln x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1320 | apply (subgoal_tac "isCont ln (exp (ln x))", simp) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1321 | apply (rule isCont_inverse_function [where f=exp], simp_all) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1322 | done | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1323 | |
| 45915 | 1324 | lemma tendsto_ln [tendsto_intros]: | 
| 53079 | 1325 | "(f ---> a) F \<Longrightarrow> 0 < a \<Longrightarrow> ((\<lambda>x. ln (f x)) ---> ln a) F" | 
| 45915 | 1326 | by (rule isCont_tendsto_compose [OF isCont_ln]) | 
| 1327 | ||
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1328 | lemma continuous_ln: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1329 | "continuous F f \<Longrightarrow> 0 < f (Lim F (\<lambda>x. x)) \<Longrightarrow> continuous F (\<lambda>x. ln (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1330 | unfolding continuous_def by (rule tendsto_ln) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1331 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1332 | lemma isCont_ln' [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1333 | "continuous (at x) f \<Longrightarrow> 0 < f x \<Longrightarrow> continuous (at x) (\<lambda>x. ln (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1334 | unfolding continuous_at by (rule tendsto_ln) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1335 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1336 | lemma continuous_within_ln [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1337 | "continuous (at x within s) f \<Longrightarrow> 0 < f x \<Longrightarrow> continuous (at x within s) (\<lambda>x. ln (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1338 | unfolding continuous_within by (rule tendsto_ln) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1339 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1340 | lemma continuous_on_ln [continuous_on_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1341 | "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. 0 < f x) \<Longrightarrow> continuous_on s (\<lambda>x. ln (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1342 | unfolding continuous_on_def by (auto intro: tendsto_ln) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 1343 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1344 | lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1345 | apply (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) | 
| 44317 
b7e9fa025f15
remove redundant lemma lemma_DERIV_subst in favor of DERIV_cong
 huffman parents: 
44316diff
changeset | 1346 | apply (erule DERIV_cong [OF DERIV_exp exp_ln]) | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1347 | apply (simp_all add: abs_if isCont_ln) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1348 | done | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1349 | |
| 53079 | 1350 | lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1 / x" | 
| 33667 | 1351 | by (rule DERIV_ln[THEN DERIV_cong], simp, simp add: divide_inverse) | 
| 1352 | ||
| 51527 | 1353 | declare DERIV_ln_divide[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | 
| 1354 | ||
| 53079 | 1355 | lemma ln_series: | 
| 1356 | assumes "0 < x" and "x < 2" | |
| 1357 | shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" | |
| 1358 | (is "ln x = suminf (?f (x - 1))") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1359 | proof - | 
| 53079 | 1360 | let ?f' = "\<lambda>x n. (-1)^n * (x - 1)^n" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1361 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1362 | have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1363 | proof (rule DERIV_isconst3[where x=x]) | 
| 53079 | 1364 | fix x :: real | 
| 1365 |     assume "x \<in> {0 <..< 2}"
 | |
| 1366 | hence "0 < x" and "x < 2" by auto | |
| 1367 | have "norm (1 - x) < 1" | |
| 1368 | using `0 < x` and `x < 2` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1369 | have "1 / x = 1 / (1 - (1 - x))" by auto | 
| 53079 | 1370 | also have "\<dots> = (\<Sum> n. (1 - x)^n)" | 
| 1371 | using geometric_sums[OF `norm (1 - x) < 1`] by (rule sums_unique) | |
| 1372 | also have "\<dots> = suminf (?f' x)" | |
| 1373 | unfolding power_mult_distrib[symmetric] | |
| 1374 | by (rule arg_cong[where f=suminf], rule arg_cong[where f="op ^"], auto) | |
| 1375 | finally have "DERIV ln x :> suminf (?f' x)" | |
| 1376 | using DERIV_ln[OF `0 < x`] unfolding divide_inverse by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1377 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1378 | have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto | 
| 53079 | 1379 | have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> | 
| 1380 | (\<Sum>n. (-1)^n * (1 / real (n + 1)) * real (Suc n) * (x - 1) ^ n)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1381 | proof (rule DERIV_power_series') | 
| 53079 | 1382 |       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 1383 | using `0 < x` `x < 2` by auto | |
| 1384 | fix x :: real | |
| 1385 |       assume "x \<in> {- 1<..<1}"
 | |
| 1386 | hence "norm (-x) < 1" by auto | |
| 1387 | show "summable (\<lambda>n. -1 ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)" | |
| 1388 | unfolding One_nat_def | |
| 1389 | by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF `norm (-x) < 1`]) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1390 | qed | 
| 53079 | 1391 | hence "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)" | 
| 1392 | unfolding One_nat_def by auto | |
| 1393 | hence "DERIV (\<lambda>x. suminf (?f (x - 1))) x :> suminf (?f' x)" | |
| 1394 | unfolding DERIV_iff repos . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1395 | ultimately have "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> (suminf (?f' x) - suminf (?f' x))" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1396 | by (rule DERIV_diff) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1397 | thus "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1398 | qed (auto simp add: assms) | 
| 44289 | 1399 | thus ?thesis by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1400 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1401 | |
| 50326 | 1402 | lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum> n. inverse(fact (n+2)) * (x ^ (n+2)))" | 
| 1403 | proof - | |
| 53079 | 1404 | have "exp x = suminf (\<lambda>n. inverse(fact n) * (x ^ n))" | 
| 50326 | 1405 | by (simp add: exp_def) | 
| 1406 | also from summable_exp have "... = (\<Sum> n::nat = 0 ..< 2. inverse(fact n) * (x ^ n)) + | |
| 1407 | (\<Sum> n. inverse(fact(n+2)) * (x ^ (n+2)))" (is "_ = ?a + _") | |
| 1408 | by (rule suminf_split_initial_segment) | |
| 1409 | also have "?a = 1 + x" | |
| 1410 | by (simp add: numeral_2_eq_2) | |
| 1411 | finally show ?thesis . | |
| 1412 | qed | |
| 1413 | ||
| 53079 | 1414 | lemma exp_bound: "0 <= (x::real) \<Longrightarrow> x <= 1 \<Longrightarrow> exp x <= 1 + x + x\<^sup>2" | 
| 50326 | 1415 | proof - | 
| 1416 | assume a: "0 <= x" | |
| 1417 | assume b: "x <= 1" | |
| 53079 | 1418 |   {
 | 
| 1419 | fix n :: nat | |
| 50326 | 1420 | have "2 * 2 ^ n \<le> fact (n + 2)" | 
| 53079 | 1421 | by (induct n) simp_all | 
| 50326 | 1422 | hence "real ((2::nat) * 2 ^ n) \<le> real (fact (n + 2))" | 
| 1423 | by (simp only: real_of_nat_le_iff) | |
| 1424 | hence "2 * 2 ^ n \<le> real (fact (n + 2))" | |
| 1425 | by simp | |
| 1426 | hence "inverse (fact (n + 2)) \<le> inverse (2 * 2 ^ n)" | |
| 1427 | by (rule le_imp_inverse_le) simp | |
| 1428 | hence "inverse (fact (n + 2)) \<le> 1/2 * (1/2)^n" | |
| 53079 | 1429 | by (simp add: power_inverse) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1430 | hence "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)" | 
| 50326 | 1431 | by (rule mult_mono) | 
| 1432 | (rule mult_mono, simp_all add: power_le_one a b mult_nonneg_nonneg) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1433 | hence "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" | 
| 50326 | 1434 | unfolding power_add by (simp add: mult_ac del: fact_Suc) } | 
| 1435 | note aux1 = this | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1436 | have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))" | 
| 50326 | 1437 | by (intro sums_mult geometric_sums, simp) | 
| 53076 | 1438 | hence aux2: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2" | 
| 50326 | 1439 | by simp | 
| 53079 | 1440 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <= x\<^sup>2" | 
| 50326 | 1441 | proof - | 
| 53079 | 1442 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <= | 
| 1443 | suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))" | |
| 50326 | 1444 | apply (rule summable_le) | 
| 1445 | apply (rule allI, rule aux1) | |
| 1446 | apply (rule summable_exp [THEN summable_ignore_initial_segment]) | |
| 1447 | by (rule sums_summable, rule aux2) | |
| 53076 | 1448 | also have "... = x\<^sup>2" | 
| 50326 | 1449 | by (rule sums_unique [THEN sym], rule aux2) | 
| 1450 | finally show ?thesis . | |
| 1451 | qed | |
| 1452 | thus ?thesis unfolding exp_first_two_terms by auto | |
| 1453 | qed | |
| 1454 | ||
| 53079 | 1455 | lemma ln_one_minus_pos_upper_bound: "0 <= x \<Longrightarrow> x < 1 \<Longrightarrow> ln (1 - x) <= - x" | 
| 50326 | 1456 | proof - | 
| 1457 | assume a: "0 <= (x::real)" and b: "x < 1" | |
| 53076 | 1458 | have "(1 - x) * (1 + x + x\<^sup>2) = (1 - x^3)" | 
| 50326 | 1459 | by (simp add: algebra_simps power2_eq_square power3_eq_cube) | 
| 1460 | also have "... <= 1" | |
| 1461 | by (auto simp add: a) | |
| 53076 | 1462 | finally have "(1 - x) * (1 + x + x\<^sup>2) <= 1" . | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1463 | moreover have c: "0 < 1 + x + x\<^sup>2" | 
| 50326 | 1464 | by (simp add: add_pos_nonneg a) | 
| 53076 | 1465 | ultimately have "1 - x <= 1 / (1 + x + x\<^sup>2)" | 
| 50326 | 1466 | by (elim mult_imp_le_div_pos) | 
| 1467 | also have "... <= 1 / exp x" | |
| 1468 | apply (rule divide_left_mono) | |
| 1469 | apply (rule exp_bound, rule a) | |
| 1470 | apply (rule b [THEN less_imp_le]) | |
| 1471 | apply simp | |
| 1472 | apply (rule mult_pos_pos) | |
| 1473 | apply (rule c) | |
| 1474 | apply simp | |
| 1475 | done | |
| 1476 | also have "... = exp (-x)" | |
| 1477 | by (auto simp add: exp_minus divide_inverse) | |
| 1478 | finally have "1 - x <= exp (- x)" . | |
| 1479 | also have "1 - x = exp (ln (1 - x))" | |
| 1480 | proof - | |
| 1481 | have "0 < 1 - x" | |
| 1482 | by (insert b, auto) | |
| 1483 | thus ?thesis | |
| 1484 | by (auto simp only: exp_ln_iff [THEN sym]) | |
| 1485 | qed | |
| 1486 | finally have "exp (ln (1 - x)) <= exp (- x)" . | |
| 1487 | thus ?thesis by (auto simp only: exp_le_cancel_iff) | |
| 1488 | qed | |
| 1489 | ||
| 1490 | lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x" | |
| 1491 | apply (case_tac "0 <= x") | |
| 1492 | apply (erule exp_ge_add_one_self_aux) | |
| 1493 | apply (case_tac "x <= -1") | |
| 1494 | apply (subgoal_tac "1 + x <= 0") | |
| 1495 | apply (erule order_trans) | |
| 1496 | apply simp | |
| 1497 | apply simp | |
| 1498 | apply (subgoal_tac "1 + x = exp(ln (1 + x))") | |
| 1499 | apply (erule ssubst) | |
| 1500 | apply (subst exp_le_cancel_iff) | |
| 1501 | apply (subgoal_tac "ln (1 - (- x)) <= - (- x)") | |
| 1502 | apply simp | |
| 1503 | apply (rule ln_one_minus_pos_upper_bound) | |
| 1504 | apply auto | |
| 1505 | done | |
| 1506 | ||
| 53079 | 1507 | lemma ln_one_plus_pos_lower_bound: "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> x - x\<^sup>2 <= ln (1 + x)" | 
| 51527 | 1508 | proof - | 
| 1509 | assume a: "0 <= x" and b: "x <= 1" | |
| 53076 | 1510 | have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)" | 
| 51527 | 1511 | by (rule exp_diff) | 
| 53076 | 1512 | also have "... <= (1 + x + x\<^sup>2) / exp (x \<^sup>2)" | 
| 53079 | 1513 | apply (rule divide_right_mono) | 
| 51527 | 1514 | apply (rule exp_bound) | 
| 1515 | apply (rule a, rule b) | |
| 1516 | apply simp | |
| 1517 | done | |
| 53076 | 1518 | also have "... <= (1 + x + x\<^sup>2) / (1 + x\<^sup>2)" | 
| 51527 | 1519 | apply (rule divide_left_mono) | 
| 1520 | apply (simp add: exp_ge_add_one_self_aux) | |
| 1521 | apply (simp add: a) | |
| 1522 | apply (simp add: mult_pos_pos add_pos_nonneg) | |
| 1523 | done | |
| 1524 | also from a have "... <= 1 + x" | |
| 1525 | by (simp add: field_simps add_strict_increasing zero_le_mult_iff) | |
| 53076 | 1526 | finally have "exp (x - x\<^sup>2) <= 1 + x" . | 
| 51527 | 1527 | also have "... = exp (ln (1 + x))" | 
| 1528 | proof - | |
| 1529 | from a have "0 < 1 + x" by auto | |
| 1530 | thus ?thesis | |
| 1531 | by (auto simp only: exp_ln_iff [THEN sym]) | |
| 1532 | qed | |
| 53076 | 1533 | finally have "exp (x - x\<^sup>2) <= exp (ln (1 + x))" . | 
| 51527 | 1534 | thus ?thesis by (auto simp only: exp_le_cancel_iff) | 
| 1535 | qed | |
| 1536 | ||
| 53079 | 1537 | lemma aux5: "x < 1 \<Longrightarrow> ln(1 - x) = - ln(1 + x / (1 - x))" | 
| 51527 | 1538 | proof - | 
| 1539 | assume a: "x < 1" | |
| 1540 | have "ln(1 - x) = - ln(1 / (1 - x))" | |
| 1541 | proof - | |
| 1542 | have "ln(1 - x) = - (- ln (1 - x))" | |
| 1543 | by auto | |
| 1544 | also have "- ln(1 - x) = ln 1 - ln(1 - x)" | |
| 1545 | by simp | |
| 1546 | also have "... = ln(1 / (1 - x))" | |
| 1547 | apply (rule ln_div [THEN sym]) | |
| 53079 | 1548 | using a apply auto | 
| 1549 | done | |
| 51527 | 1550 | finally show ?thesis . | 
| 1551 | qed | |
| 1552 | also have " 1 / (1 - x) = 1 + x / (1 - x)" using a by(simp add:field_simps) | |
| 1553 | finally show ?thesis . | |
| 1554 | qed | |
| 1555 | ||
| 53079 | 1556 | lemma ln_one_minus_pos_lower_bound: | 
| 1557 | "0 <= x \<Longrightarrow> x <= (1 / 2) \<Longrightarrow> - x - 2 * x\<^sup>2 <= ln (1 - x)" | |
| 51527 | 1558 | proof - | 
| 1559 | assume a: "0 <= x" and b: "x <= (1 / 2)" | |
| 53079 | 1560 | from b have c: "x < 1" by auto | 
| 51527 | 1561 | then have "ln (1 - x) = - ln (1 + x / (1 - x))" | 
| 1562 | by (rule aux5) | |
| 1563 | also have "- (x / (1 - x)) <= ..." | |
| 53079 | 1564 | proof - | 
| 51527 | 1565 | have "ln (1 + x / (1 - x)) <= x / (1 - x)" | 
| 1566 | apply (rule ln_add_one_self_le_self) | |
| 1567 | apply (rule divide_nonneg_pos) | |
| 53079 | 1568 | using a c apply auto | 
| 1569 | done | |
| 51527 | 1570 | thus ?thesis | 
| 1571 | by auto | |
| 1572 | qed | |
| 1573 | also have "- (x / (1 - x)) = -x / (1 - x)" | |
| 1574 | by auto | |
| 1575 | finally have d: "- x / (1 - x) <= ln (1 - x)" . | |
| 1576 | have "0 < 1 - x" using a b by simp | |
| 53076 | 1577 | hence e: "-x - 2 * x\<^sup>2 <= - x / (1 - x)" | 
| 51527 | 1578 | using mult_right_le_one_le[of "x*x" "2*x"] a b | 
| 53079 | 1579 | by (simp add: field_simps power2_eq_square) | 
| 53076 | 1580 | from e d show "- x - 2 * x\<^sup>2 <= ln (1 - x)" | 
| 51527 | 1581 | by (rule order_trans) | 
| 1582 | qed | |
| 1583 | ||
| 53079 | 1584 | lemma ln_add_one_self_le_self2: "-1 < x \<Longrightarrow> ln(1 + x) <= x" | 
| 51527 | 1585 | apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)", simp) | 
| 1586 | apply (subst ln_le_cancel_iff) | |
| 1587 | apply auto | |
| 53079 | 1588 | done | 
| 51527 | 1589 | |
| 1590 | lemma abs_ln_one_plus_x_minus_x_bound_nonneg: | |
| 53079 | 1591 | "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> abs(ln (1 + x) - x) <= x\<^sup>2" | 
| 51527 | 1592 | proof - | 
| 1593 | assume x: "0 <= x" | |
| 1594 | assume x1: "x <= 1" | |
| 1595 | from x have "ln (1 + x) <= x" | |
| 1596 | by (rule ln_add_one_self_le_self) | |
| 53079 | 1597 | then have "ln (1 + x) - x <= 0" | 
| 51527 | 1598 | by simp | 
| 1599 | then have "abs(ln(1 + x) - x) = - (ln(1 + x) - x)" | |
| 1600 | by (rule abs_of_nonpos) | |
| 53079 | 1601 | also have "... = x - ln (1 + x)" | 
| 51527 | 1602 | by simp | 
| 53076 | 1603 | also have "... <= x\<^sup>2" | 
| 51527 | 1604 | proof - | 
| 53076 | 1605 | from x x1 have "x - x\<^sup>2 <= ln (1 + x)" | 
| 51527 | 1606 | by (intro ln_one_plus_pos_lower_bound) | 
| 1607 | thus ?thesis | |
| 1608 | by simp | |
| 1609 | qed | |
| 1610 | finally show ?thesis . | |
| 1611 | qed | |
| 1612 | ||
| 1613 | lemma abs_ln_one_plus_x_minus_x_bound_nonpos: | |
| 53079 | 1614 | "-(1 / 2) <= x \<Longrightarrow> x <= 0 \<Longrightarrow> abs(ln (1 + x) - x) <= 2 * x\<^sup>2" | 
| 51527 | 1615 | proof - | 
| 1616 | assume a: "-(1 / 2) <= x" | |
| 1617 | assume b: "x <= 0" | |
| 53079 | 1618 | have "abs(ln (1 + x) - x) = x - ln(1 - (-x))" | 
| 51527 | 1619 | apply (subst abs_of_nonpos) | 
| 1620 | apply simp | |
| 1621 | apply (rule ln_add_one_self_le_self2) | |
| 1622 | using a apply auto | |
| 1623 | done | |
| 53076 | 1624 | also have "... <= 2 * x\<^sup>2" | 
| 1625 | apply (subgoal_tac "- (-x) - 2 * (-x)\<^sup>2 <= ln (1 - (-x))") | |
| 51527 | 1626 | apply (simp add: algebra_simps) | 
| 1627 | apply (rule ln_one_minus_pos_lower_bound) | |
| 1628 | using a b apply auto | |
| 1629 | done | |
| 1630 | finally show ?thesis . | |
| 1631 | qed | |
| 1632 | ||
| 1633 | lemma abs_ln_one_plus_x_minus_x_bound: | |
| 53079 | 1634 | "abs x <= 1 / 2 \<Longrightarrow> abs(ln (1 + x) - x) <= 2 * x\<^sup>2" | 
| 51527 | 1635 | apply (case_tac "0 <= x") | 
| 1636 | apply (rule order_trans) | |
| 1637 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) | |
| 1638 | apply auto | |
| 1639 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) | |
| 1640 | apply auto | |
| 53079 | 1641 | done | 
| 1642 | ||
| 1643 | lemma ln_x_over_x_mono: "exp 1 <= x \<Longrightarrow> x <= y \<Longrightarrow> (ln y / y) <= (ln x / x)" | |
| 51527 | 1644 | proof - | 
| 1645 | assume x: "exp 1 <= x" "x <= y" | |
| 1646 | moreover have "0 < exp (1::real)" by simp | |
| 1647 | ultimately have a: "0 < x" and b: "0 < y" | |
| 1648 | by (fast intro: less_le_trans order_trans)+ | |
| 1649 | have "x * ln y - x * ln x = x * (ln y - ln x)" | |
| 1650 | by (simp add: algebra_simps) | |
| 1651 | also have "... = x * ln(y / x)" | |
| 1652 | by (simp only: ln_div a b) | |
| 1653 | also have "y / x = (x + (y - x)) / x" | |
| 1654 | by simp | |
| 1655 | also have "... = 1 + (y - x) / x" | |
| 1656 | using x a by (simp add: field_simps) | |
| 1657 | also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)" | |
| 1658 | apply (rule mult_left_mono) | |
| 1659 | apply (rule ln_add_one_self_le_self) | |
| 1660 | apply (rule divide_nonneg_pos) | |
| 1661 | using x a apply simp_all | |
| 1662 | done | |
| 1663 | also have "... = y - x" using a by simp | |
| 1664 | also have "... = (y - x) * ln (exp 1)" by simp | |
| 1665 | also have "... <= (y - x) * ln x" | |
| 1666 | apply (rule mult_left_mono) | |
| 1667 | apply (subst ln_le_cancel_iff) | |
| 1668 | apply fact | |
| 1669 | apply (rule a) | |
| 1670 | apply (rule x) | |
| 1671 | using x apply simp | |
| 1672 | done | |
| 1673 | also have "... = y * ln x - x * ln x" | |
| 1674 | by (rule left_diff_distrib) | |
| 1675 | finally have "x * ln y <= y * ln x" | |
| 1676 | by arith | |
| 1677 | then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps) | |
| 1678 | also have "... = y * (ln x / x)" by simp | |
| 1679 | finally show ?thesis using b by (simp add: field_simps) | |
| 1680 | qed | |
| 1681 | ||
| 53079 | 1682 | lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1" | 
| 51527 | 1683 | using exp_ge_add_one_self[of "ln x"] by simp | 
| 1684 | ||
| 1685 | lemma ln_eq_minus_one: | |
| 53079 | 1686 | assumes "0 < x" "ln x = x - 1" | 
| 1687 | shows "x = 1" | |
| 51527 | 1688 | proof - | 
| 53079 | 1689 | let ?l = "\<lambda>y. ln y - y + 1" | 
| 51527 | 1690 | have D: "\<And>x. 0 < x \<Longrightarrow> DERIV ?l x :> (1 / x - 1)" | 
| 1691 | by (auto intro!: DERIV_intros) | |
| 1692 | ||
| 1693 | show ?thesis | |
| 1694 | proof (cases rule: linorder_cases) | |
| 1695 | assume "x < 1" | |
| 1696 | from dense[OF `x < 1`] obtain a where "x < a" "a < 1" by blast | |
| 1697 | from `x < a` have "?l x < ?l a" | |
| 1698 | proof (rule DERIV_pos_imp_increasing, safe) | |
| 53079 | 1699 | fix y | 
| 1700 | assume "x \<le> y" "y \<le> a" | |
| 51527 | 1701 | with `0 < x` `a < 1` have "0 < 1 / y - 1" "0 < y" | 
| 1702 | by (auto simp: field_simps) | |
| 1703 | with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" | |
| 1704 | by auto | |
| 1705 | qed | |
| 1706 | also have "\<dots> \<le> 0" | |
| 1707 | using ln_le_minus_one `0 < x` `x < a` by (auto simp: field_simps) | |
| 1708 | finally show "x = 1" using assms by auto | |
| 1709 | next | |
| 1710 | assume "1 < x" | |
| 53079 | 1711 | from dense[OF this] obtain a where "1 < a" "a < x" by blast | 
| 51527 | 1712 | from `a < x` have "?l x < ?l a" | 
| 1713 | proof (rule DERIV_neg_imp_decreasing, safe) | |
| 53079 | 1714 | fix y | 
| 1715 | assume "a \<le> y" "y \<le> x" | |
| 51527 | 1716 | with `1 < a` have "1 / y - 1 < 0" "0 < y" | 
| 1717 | by (auto simp: field_simps) | |
| 1718 | with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" | |
| 1719 | by blast | |
| 1720 | qed | |
| 1721 | also have "\<dots> \<le> 0" | |
| 1722 | using ln_le_minus_one `1 < a` by (auto simp: field_simps) | |
| 1723 | finally show "x = 1" using assms by auto | |
| 53079 | 1724 | next | 
| 1725 | assume "x = 1" | |
| 1726 | then show ?thesis by simp | |
| 1727 | qed | |
| 51527 | 1728 | qed | 
| 1729 | ||
| 50326 | 1730 | lemma exp_at_bot: "(exp ---> (0::real)) at_bot" | 
| 1731 | unfolding tendsto_Zfun_iff | |
| 1732 | proof (rule ZfunI, simp add: eventually_at_bot_dense) | |
| 1733 | fix r :: real assume "0 < r" | |
| 53079 | 1734 |   {
 | 
| 1735 | fix x | |
| 1736 | assume "x < ln r" | |
| 50326 | 1737 | then have "exp x < exp (ln r)" | 
| 1738 | by simp | |
| 1739 | with `0 < r` have "exp x < r" | |
| 53079 | 1740 | by simp | 
| 1741 | } | |
| 50326 | 1742 | then show "\<exists>k. \<forall>n<k. exp n < r" by auto | 
| 1743 | qed | |
| 1744 | ||
| 1745 | lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 1746 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g="ln"]) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 1747 | (auto intro: eventually_gt_at_top) | 
| 50326 | 1748 | |
| 1749 | lemma ln_at_0: "LIM x at_right 0. ln x :> at_bot" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 1750 | by (rule filterlim_at_bot_at_right[where Q="\<lambda>x. 0 < x" and P="\<lambda>x. True" and g="exp"]) | 
| 51641 
cd05e9fcc63d
remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
 hoelzl parents: 
51527diff
changeset | 1751 | (auto simp: eventually_at_filter) | 
| 50326 | 1752 | |
| 1753 | lemma ln_at_top: "LIM x at_top. ln x :> at_top" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 1754 | by (rule filterlim_at_top_at_top[where Q="\<lambda>x. 0 < x" and P="\<lambda>x. True" and g="exp"]) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 1755 | (auto intro: eventually_gt_at_top) | 
| 50326 | 1756 | |
| 50347 | 1757 | lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) ---> (0::real)) at_top" | 
| 1758 | proof (induct k) | |
| 53079 | 1759 | case 0 | 
| 50347 | 1760 | show "((\<lambda>x. x ^ 0 / exp x) ---> (0::real)) at_top" | 
| 1761 | by (simp add: inverse_eq_divide[symmetric]) | |
| 1762 | (metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono | |
| 1763 | at_top_le_at_infinity order_refl) | |
| 1764 | next | |
| 1765 | case (Suc k) | |
| 1766 | show ?case | |
| 1767 | proof (rule lhospital_at_top_at_top) | |
| 1768 | show "eventually (\<lambda>x. DERIV (\<lambda>x. x ^ Suc k) x :> (real (Suc k) * x^k)) at_top" | |
| 1769 | by eventually_elim (intro DERIV_intros, simp, simp) | |
| 1770 | show "eventually (\<lambda>x. DERIV exp x :> exp x) at_top" | |
| 1771 | by eventually_elim (auto intro!: DERIV_intros) | |
| 1772 | show "eventually (\<lambda>x. exp x \<noteq> 0) at_top" | |
| 1773 | by auto | |
| 1774 | from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"] | |
| 1775 | show "((\<lambda>x. real (Suc k) * x ^ k / exp x) ---> 0) at_top" | |
| 1776 | by simp | |
| 1777 | qed (rule exp_at_top) | |
| 1778 | qed | |
| 1779 | ||
| 51527 | 1780 | |
| 53079 | 1781 | definition powr :: "[real,real] => real" (infixr "powr" 80) | 
| 1782 |   -- {*exponentation with real exponent*}
 | |
| 1783 | where "x powr a = exp(a * ln x)" | |
| 1784 | ||
| 1785 | definition log :: "[real,real] => real" | |
| 1786 |   -- {*logarithm of @{term x} to base @{term a}*}
 | |
| 1787 | where "log a x = ln x / ln a" | |
| 51527 | 1788 | |
| 1789 | ||
| 1790 | lemma tendsto_log [tendsto_intros]: | |
| 1791 | "\<lbrakk>(f ---> a) F; (g ---> b) F; 0 < a; a \<noteq> 1; 0 < b\<rbrakk> \<Longrightarrow> ((\<lambda>x. log (f x) (g x)) ---> log a b) F" | |
| 1792 | unfolding log_def by (intro tendsto_intros) auto | |
| 1793 | ||
| 1794 | lemma continuous_log: | |
| 53079 | 1795 | assumes "continuous F f" | 
| 1796 | and "continuous F g" | |
| 1797 | and "0 < f (Lim F (\<lambda>x. x))" | |
| 1798 | and "f (Lim F (\<lambda>x. x)) \<noteq> 1" | |
| 1799 | and "0 < g (Lim F (\<lambda>x. x))" | |
| 51527 | 1800 | shows "continuous F (\<lambda>x. log (f x) (g x))" | 
| 1801 | using assms unfolding continuous_def by (rule tendsto_log) | |
| 1802 | ||
| 1803 | lemma continuous_at_within_log[continuous_intros]: | |
| 53079 | 1804 | assumes "continuous (at a within s) f" | 
| 1805 | and "continuous (at a within s) g" | |
| 1806 | and "0 < f a" | |
| 1807 | and "f a \<noteq> 1" | |
| 1808 | and "0 < g a" | |
| 51527 | 1809 | shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))" | 
| 1810 | using assms unfolding continuous_within by (rule tendsto_log) | |
| 1811 | ||
| 1812 | lemma isCont_log[continuous_intros, simp]: | |
| 1813 | assumes "isCont f a" "isCont g a" "0 < f a" "f a \<noteq> 1" "0 < g a" | |
| 1814 | shows "isCont (\<lambda>x. log (f x) (g x)) a" | |
| 1815 | using assms unfolding continuous_at by (rule tendsto_log) | |
| 1816 | ||
| 1817 | lemma continuous_on_log[continuous_on_intros]: | |
| 53079 | 1818 | assumes "continuous_on s f" "continuous_on s g" | 
| 1819 | and "\<forall>x\<in>s. 0 < f x" "\<forall>x\<in>s. f x \<noteq> 1" "\<forall>x\<in>s. 0 < g x" | |
| 51527 | 1820 | shows "continuous_on s (\<lambda>x. log (f x) (g x))" | 
| 1821 | using assms unfolding continuous_on_def by (fast intro: tendsto_log) | |
| 1822 | ||
| 1823 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | |
| 53079 | 1824 | by (simp add: powr_def) | 
| 51527 | 1825 | |
| 1826 | lemma powr_zero_eq_one [simp]: "x powr 0 = 1" | |
| 53079 | 1827 | by (simp add: powr_def) | 
| 51527 | 1828 | |
| 1829 | lemma powr_one_gt_zero_iff [simp]: "(x powr 1 = x) = (0 < x)" | |
| 53079 | 1830 | by (simp add: powr_def) | 
| 51527 | 1831 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 1832 | ||
| 53079 | 1833 | lemma powr_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)" | 
| 1834 | by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) | |
| 51527 | 1835 | |
| 1836 | lemma powr_gt_zero [simp]: "0 < x powr a" | |
| 53079 | 1837 | by (simp add: powr_def) | 
| 51527 | 1838 | |
| 1839 | lemma powr_ge_pzero [simp]: "0 <= x powr y" | |
| 53079 | 1840 | by (rule order_less_imp_le, rule powr_gt_zero) | 
| 51527 | 1841 | |
| 1842 | lemma powr_not_zero [simp]: "x powr a \<noteq> 0" | |
| 53079 | 1843 | by (simp add: powr_def) | 
| 1844 | ||
| 1845 | lemma powr_divide: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)" | |
| 1846 | apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult) | |
| 1847 | apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse) | |
| 1848 | done | |
| 51527 | 1849 | |
| 1850 | lemma powr_divide2: "x powr a / x powr b = x powr (a - b)" | |
| 1851 | apply (simp add: powr_def) | |
| 1852 | apply (subst exp_diff [THEN sym]) | |
| 1853 | apply (simp add: left_diff_distrib) | |
| 53079 | 1854 | done | 
| 51527 | 1855 | |
| 1856 | lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)" | |
| 53079 | 1857 | by (simp add: powr_def exp_add [symmetric] distrib_right) | 
| 1858 | ||
| 1859 | lemma powr_mult_base: "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)" | |
| 1860 | using assms by (auto simp: powr_add) | |
| 51527 | 1861 | |
| 1862 | lemma powr_powr: "(x powr a) powr b = x powr (a * b)" | |
| 53079 | 1863 | by (simp add: powr_def) | 
| 51527 | 1864 | |
| 1865 | lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a" | |
| 53079 | 1866 | by (simp add: powr_powr mult_commute) | 
| 51527 | 1867 | |
| 1868 | lemma powr_minus: "x powr (-a) = inverse (x powr a)" | |
| 53079 | 1869 | by (simp add: powr_def exp_minus [symmetric]) | 
| 51527 | 1870 | |
| 1871 | lemma powr_minus_divide: "x powr (-a) = 1/(x powr a)" | |
| 53079 | 1872 | by (simp add: divide_inverse powr_minus) | 
| 1873 | ||
| 1874 | lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b" | |
| 1875 | by (simp add: powr_def) | |
| 1876 | ||
| 1877 | lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b" | |
| 1878 | by (simp add: powr_def) | |
| 1879 | ||
| 1880 | lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> (x powr a < x powr b) = (a < b)" | |
| 1881 | by (blast intro: powr_less_cancel powr_less_mono) | |
| 1882 | ||
| 1883 | lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> (x powr a \<le> x powr b) = (a \<le> b)" | |
| 1884 | by (simp add: linorder_not_less [symmetric]) | |
| 51527 | 1885 | |
| 1886 | lemma log_ln: "ln x = log (exp(1)) x" | |
| 53079 | 1887 | by (simp add: log_def) | 
| 1888 | ||
| 1889 | lemma DERIV_log: | |
| 1890 | assumes "x > 0" | |
| 1891 | shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)" | |
| 51527 | 1892 | proof - | 
| 1893 | def lb \<equiv> "1 / ln b" | |
| 1894 | moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x" | |
| 1895 | using `x > 0` by (auto intro!: DERIV_intros) | |
| 1896 | ultimately show ?thesis | |
| 1897 | by (simp add: log_def) | |
| 1898 | qed | |
| 1899 | ||
| 1900 | lemmas DERIV_log[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | |
| 1901 | ||
| 53079 | 1902 | lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x" | 
| 1903 | by (simp add: powr_def log_def) | |
| 1904 | ||
| 1905 | lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr y) = y" | |
| 1906 | by (simp add: log_def powr_def) | |
| 1907 | ||
| 1908 | lemma log_mult: | |
| 1909 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> | |
| 1910 | log a (x * y) = log a x + log a y" | |
| 1911 | by (simp add: log_def ln_mult divide_inverse distrib_right) | |
| 1912 | ||
| 1913 | lemma log_eq_div_ln_mult_log: | |
| 1914 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> | |
| 1915 | log a x = (ln b/ln a) * log b x" | |
| 1916 | by (simp add: log_def divide_inverse) | |
| 51527 | 1917 | |
| 1918 | text{*Base 10 logarithms*}
 | |
| 53079 | 1919 | lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 1920 | by (simp add: log_def) | |
| 1921 | ||
| 1922 | lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x" | |
| 1923 | by (simp add: log_def) | |
| 51527 | 1924 | |
| 1925 | lemma log_one [simp]: "log a 1 = 0" | |
| 53079 | 1926 | by (simp add: log_def) | 
| 51527 | 1927 | |
| 1928 | lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1" | |
| 53079 | 1929 | by (simp add: log_def) | 
| 1930 | ||
| 1931 | lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x" | |
| 1932 | apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1]) | |
| 1933 | apply (simp add: log_mult [symmetric]) | |
| 1934 | done | |
| 1935 | ||
| 1936 | lemma log_divide: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a (x/y) = log a x - log a y" | |
| 1937 | by (simp add: log_mult divide_inverse log_inverse) | |
| 51527 | 1938 | |
| 1939 | lemma log_less_cancel_iff [simp]: | |
| 53079 | 1940 | "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y" | 
| 1941 | apply safe | |
| 1942 | apply (rule_tac [2] powr_less_cancel) | |
| 1943 | apply (drule_tac a = "log a x" in powr_less_mono, auto) | |
| 1944 | done | |
| 1945 | ||
| 1946 | lemma log_inj: | |
| 1947 | assumes "1 < b" | |
| 1948 |   shows "inj_on (log b) {0 <..}"
 | |
| 51527 | 1949 | proof (rule inj_onI, simp) | 
| 53079 | 1950 | fix x y | 
| 1951 | assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | |
| 51527 | 1952 | show "x = y" | 
| 1953 | proof (cases rule: linorder_cases) | |
| 53079 | 1954 | assume "x = y" | 
| 1955 | then show ?thesis by simp | |
| 1956 | next | |
| 51527 | 1957 | assume "x < y" hence "log b x < log b y" | 
| 1958 | using log_less_cancel_iff[OF `1 < b`] pos by simp | |
| 53079 | 1959 | then show ?thesis using * by simp | 
| 51527 | 1960 | next | 
| 1961 | assume "y < x" hence "log b y < log b x" | |
| 1962 | using log_less_cancel_iff[OF `1 < b`] pos by simp | |
| 53079 | 1963 | then show ?thesis using * by simp | 
| 1964 | qed | |
| 51527 | 1965 | qed | 
| 1966 | ||
| 1967 | lemma log_le_cancel_iff [simp]: | |
| 53079 | 1968 | "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (log a x \<le> log a y) = (x \<le> y)" | 
| 1969 | by (simp add: linorder_not_less [symmetric]) | |
| 51527 | 1970 | |
| 1971 | lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x" | |
| 1972 | using log_less_cancel_iff[of a 1 x] by simp | |
| 1973 | ||
| 1974 | lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x" | |
| 1975 | using log_le_cancel_iff[of a 1 x] by simp | |
| 1976 | ||
| 1977 | lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1" | |
| 1978 | using log_less_cancel_iff[of a x 1] by simp | |
| 1979 | ||
| 1980 | lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1" | |
| 1981 | using log_le_cancel_iff[of a x 1] by simp | |
| 1982 | ||
| 1983 | lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x" | |
| 1984 | using log_less_cancel_iff[of a a x] by simp | |
| 1985 | ||
| 1986 | lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x" | |
| 1987 | using log_le_cancel_iff[of a a x] by simp | |
| 1988 | ||
| 1989 | lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a" | |
| 1990 | using log_less_cancel_iff[of a x a] by simp | |
| 1991 | ||
| 1992 | lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a" | |
| 1993 | using log_le_cancel_iff[of a x a] by simp | |
| 1994 | ||
| 1995 | lemma powr_realpow: "0 < x ==> x powr (real n) = x^n" | |
| 53079 | 1996 | apply (induct n) | 
| 1997 | apply simp | |
| 51527 | 1998 | apply (subgoal_tac "real(Suc n) = real n + 1") | 
| 1999 | apply (erule ssubst) | |
| 2000 | apply (subst powr_add, simp, simp) | |
| 53079 | 2001 | done | 
| 51527 | 2002 | |
| 52139 | 2003 | lemma powr_realpow_numeral: "0 < x \<Longrightarrow> x powr (numeral n :: real) = x^(numeral n)" | 
| 2004 | unfolding real_of_nat_numeral[symmetric] by (rule powr_realpow) | |
| 2005 | ||
| 51527 | 2006 | lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0 else x powr (real n))" | 
| 2007 | apply (case_tac "x = 0", simp, simp) | |
| 2008 | apply (rule powr_realpow [THEN sym], simp) | |
| 53079 | 2009 | done | 
| 51527 | 2010 | |
| 2011 | lemma powr_int: | |
| 2012 | assumes "x > 0" | |
| 2013 | shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))" | |
| 53079 | 2014 | proof (cases "i < 0") | 
| 2015 | case True | |
| 51527 | 2016 | have r: "x powr i = 1 / x powr (-i)" by (simp add: powr_minus field_simps) | 
| 2017 | show ?thesis using `i < 0` `x > 0` by (simp add: r field_simps powr_realpow[symmetric]) | |
| 53079 | 2018 | next | 
| 2019 | case False | |
| 2020 | then show ?thesis by (simp add: assms powr_realpow[symmetric]) | |
| 2021 | qed | |
| 51527 | 2022 | |
| 2023 | lemma powr_numeral: "0 < x \<Longrightarrow> x powr numeral n = x^numeral n" | |
| 2024 | using powr_realpow[of x "numeral n"] by simp | |
| 2025 | ||
| 2026 | lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr neg_numeral n = 1 / x^numeral n" | |
| 2027 | using powr_int[of x "neg_numeral n"] by simp | |
| 2028 | ||
| 53079 | 2029 | lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)" | 
| 51527 | 2030 | by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr) | 
| 2031 | ||
| 2032 | lemma ln_powr: "0 < x ==> 0 < y ==> ln(x powr y) = y * ln x" | |
| 53079 | 2033 | unfolding powr_def by simp | 
| 51527 | 2034 | |
| 2035 | lemma log_powr: "0 < x ==> 0 \<le> y ==> log b (x powr y) = y * log b x" | |
| 53079 | 2036 | apply (cases "y = 0") | 
| 51527 | 2037 | apply force | 
| 2038 | apply (auto simp add: log_def ln_powr field_simps) | |
| 53079 | 2039 | done | 
| 51527 | 2040 | |
| 2041 | lemma log_nat_power: "0 < x ==> log b (x^n) = real n * log b x" | |
| 2042 | apply (subst powr_realpow [symmetric]) | |
| 2043 | apply (auto simp add: log_powr) | |
| 53079 | 2044 | done | 
| 51527 | 2045 | |
| 2046 | lemma ln_bound: "1 <= x ==> ln x <= x" | |
| 2047 | apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1") | |
| 2048 | apply simp | |
| 2049 | apply (rule ln_add_one_self_le_self, simp) | |
| 53079 | 2050 | done | 
| 51527 | 2051 | |
| 2052 | lemma powr_mono: "a <= b ==> 1 <= x ==> x powr a <= x powr b" | |
| 53079 | 2053 | apply (cases "x = 1", simp) | 
| 2054 | apply (cases "a = b", simp) | |
| 51527 | 2055 | apply (rule order_less_imp_le) | 
| 2056 | apply (rule powr_less_mono, auto) | |
| 53079 | 2057 | done | 
| 51527 | 2058 | |
| 2059 | lemma ge_one_powr_ge_zero: "1 <= x ==> 0 <= a ==> 1 <= x powr a" | |
| 2060 | apply (subst powr_zero_eq_one [THEN sym]) | |
| 2061 | apply (rule powr_mono, assumption+) | |
| 53079 | 2062 | done | 
| 2063 | ||
| 2064 | lemma powr_less_mono2: "0 < a ==> 0 < x ==> x < y ==> x powr a < y powr a" | |
| 51527 | 2065 | apply (unfold powr_def) | 
| 2066 | apply (rule exp_less_mono) | |
| 2067 | apply (rule mult_strict_left_mono) | |
| 2068 | apply (subst ln_less_cancel_iff, assumption) | |
| 2069 | apply (rule order_less_trans) | |
| 2070 | prefer 2 | |
| 2071 | apply assumption+ | |
| 53079 | 2072 | done | 
| 2073 | ||
| 2074 | lemma powr_less_mono2_neg: "a < 0 ==> 0 < x ==> x < y ==> y powr a < x powr a" | |
| 51527 | 2075 | apply (unfold powr_def) | 
| 2076 | apply (rule exp_less_mono) | |
| 2077 | apply (rule mult_strict_left_mono_neg) | |
| 2078 | apply (subst ln_less_cancel_iff) | |
| 2079 | apply assumption | |
| 2080 | apply (rule order_less_trans) | |
| 2081 | prefer 2 | |
| 2082 | apply assumption+ | |
| 53079 | 2083 | done | 
| 51527 | 2084 | |
| 2085 | lemma powr_mono2: "0 <= a ==> 0 < x ==> x <= y ==> x powr a <= y powr a" | |
| 2086 | apply (case_tac "a = 0", simp) | |
| 2087 | apply (case_tac "x = y", simp) | |
| 2088 | apply (rule order_less_imp_le) | |
| 2089 | apply (rule powr_less_mono2, auto) | |
| 53079 | 2090 | done | 
| 2091 | ||
| 2092 | lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y" | |
| 51527 | 2093 | unfolding powr_def exp_inj_iff by simp | 
| 2094 | ||
| 2095 | lemma ln_powr_bound: "1 <= x ==> 0 < a ==> ln x <= (x powr a) / a" | |
| 2096 | apply (rule mult_imp_le_div_pos) | |
| 2097 | apply (assumption) | |
| 2098 | apply (subst mult_commute) | |
| 2099 | apply (subst ln_powr [THEN sym]) | |
| 2100 | apply auto | |
| 2101 | apply (rule ln_bound) | |
| 2102 | apply (erule ge_one_powr_ge_zero) | |
| 2103 | apply (erule order_less_imp_le) | |
| 53079 | 2104 | done | 
| 51527 | 2105 | |
| 2106 | lemma ln_powr_bound2: | |
| 2107 | assumes "1 < x" and "0 < a" | |
| 2108 | shows "(ln x) powr a <= (a powr a) * x" | |
| 2109 | proof - | |
| 2110 | from assms have "ln x <= (x powr (1 / a)) / (1 / a)" | |
| 2111 | apply (intro ln_powr_bound) | |
| 2112 | apply (erule order_less_imp_le) | |
| 2113 | apply (rule divide_pos_pos) | |
| 2114 | apply simp_all | |
| 2115 | done | |
| 2116 | also have "... = a * (x powr (1 / a))" | |
| 2117 | by simp | |
| 2118 | finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a" | |
| 2119 | apply (intro powr_mono2) | |
| 2120 | apply (rule order_less_imp_le, rule assms) | |
| 2121 | apply (rule ln_gt_zero) | |
| 2122 | apply (rule assms) | |
| 2123 | apply assumption | |
| 2124 | done | |
| 2125 | also have "... = (a powr a) * ((x powr (1 / a)) powr a)" | |
| 2126 | apply (rule powr_mult) | |
| 2127 | apply (rule assms) | |
| 2128 | apply (rule powr_gt_zero) | |
| 2129 | done | |
| 2130 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | |
| 2131 | by (rule powr_powr) | |
| 2132 | also have "... = x" | |
| 2133 | apply simp | |
| 2134 | apply (subgoal_tac "a ~= 0") | |
| 2135 | using assms apply auto | |
| 2136 | done | |
| 2137 | finally show ?thesis . | |
| 2138 | qed | |
| 2139 | ||
| 2140 | lemma tendsto_powr [tendsto_intros]: | |
| 2141 | "\<lbrakk>(f ---> a) F; (g ---> b) F; 0 < a\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x powr g x) ---> a powr b) F" | |
| 2142 | unfolding powr_def by (intro tendsto_intros) | |
| 2143 | ||
| 2144 | lemma continuous_powr: | |
| 53079 | 2145 | assumes "continuous F f" | 
| 2146 | and "continuous F g" | |
| 2147 | and "0 < f (Lim F (\<lambda>x. x))" | |
| 51527 | 2148 | shows "continuous F (\<lambda>x. (f x) powr (g x))" | 
| 2149 | using assms unfolding continuous_def by (rule tendsto_powr) | |
| 2150 | ||
| 2151 | lemma continuous_at_within_powr[continuous_intros]: | |
| 53079 | 2152 | assumes "continuous (at a within s) f" | 
| 2153 | and "continuous (at a within s) g" | |
| 2154 | and "0 < f a" | |
| 51527 | 2155 | shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))" | 
| 2156 | using assms unfolding continuous_within by (rule tendsto_powr) | |
| 2157 | ||
| 2158 | lemma isCont_powr[continuous_intros, simp]: | |
| 2159 | assumes "isCont f a" "isCont g a" "0 < f a" | |
| 2160 | shows "isCont (\<lambda>x. (f x) powr g x) a" | |
| 2161 | using assms unfolding continuous_at by (rule tendsto_powr) | |
| 2162 | ||
| 2163 | lemma continuous_on_powr[continuous_on_intros]: | |
| 2164 | assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. 0 < f x" | |
| 2165 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | |
| 2166 | using assms unfolding continuous_on_def by (fast intro: tendsto_powr) | |
| 2167 | ||
| 2168 | (* FIXME: generalize by replacing d by with g x and g ---> d? *) | |
| 2169 | lemma tendsto_zero_powrI: | |
| 2170 | assumes "eventually (\<lambda>x. 0 < f x ) F" and "(f ---> 0) F" | |
| 53079 | 2171 | and "0 < d" | 
| 51527 | 2172 | shows "((\<lambda>x. f x powr d) ---> 0) F" | 
| 2173 | proof (rule tendstoI) | |
| 2174 | fix e :: real assume "0 < e" | |
| 2175 | def Z \<equiv> "e powr (1 / d)" | |
| 2176 | with `0 < e` have "0 < Z" by simp | |
| 2177 | with assms have "eventually (\<lambda>x. 0 < f x \<and> dist (f x) 0 < Z) F" | |
| 2178 | by (intro eventually_conj tendstoD) | |
| 2179 | moreover | |
| 2180 | from assms have "\<And>x. 0 < x \<and> dist x 0 < Z \<Longrightarrow> x powr d < Z powr d" | |
| 2181 | by (intro powr_less_mono2) (auto simp: dist_real_def) | |
| 2182 | with assms `0 < e` have "\<And>x. 0 < x \<and> dist x 0 < Z \<Longrightarrow> dist (x powr d) 0 < e" | |
| 2183 | unfolding dist_real_def Z_def by (auto simp: powr_powr) | |
| 2184 | ultimately | |
| 2185 | show "eventually (\<lambda>x. dist (f x powr d) 0 < e) F" by (rule eventually_elim1) | |
| 2186 | qed | |
| 2187 | ||
| 2188 | lemma tendsto_neg_powr: | |
| 53079 | 2189 | assumes "s < 0" | 
| 2190 | and "LIM x F. f x :> at_top" | |
| 51527 | 2191 | shows "((\<lambda>x. f x powr s) ---> 0) F" | 
| 2192 | proof (rule tendstoI) | |
| 2193 | fix e :: real assume "0 < e" | |
| 2194 | def Z \<equiv> "e powr (1 / s)" | |
| 2195 | from assms have "eventually (\<lambda>x. Z < f x) F" | |
| 2196 | by (simp add: filterlim_at_top_dense) | |
| 2197 | moreover | |
| 2198 | from assms have "\<And>x. Z < x \<Longrightarrow> x powr s < Z powr s" | |
| 2199 | by (auto simp: Z_def intro!: powr_less_mono2_neg) | |
| 2200 | with assms `0 < e` have "\<And>x. Z < x \<Longrightarrow> dist (x powr s) 0 < e" | |
| 2201 | by (simp add: powr_powr Z_def dist_real_def) | |
| 2202 | ultimately | |
| 2203 | show "eventually (\<lambda>x. dist (f x powr s) 0 < e) F" by (rule eventually_elim1) | |
| 2204 | qed | |
| 2205 | ||
| 29164 | 2206 | subsection {* Sine and Cosine *}
 | 
| 2207 | ||
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2208 | definition sin_coeff :: "nat \<Rightarrow> real" where | 
| 31271 | 2209 | "sin_coeff = (\<lambda>n. if even n then 0 else -1 ^ ((n - Suc 0) div 2) / real (fact n))" | 
| 2210 | ||
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2211 | definition cos_coeff :: "nat \<Rightarrow> real" where | 
| 31271 | 2212 | "cos_coeff = (\<lambda>n. if even n then (-1 ^ (n div 2)) / real (fact n) else 0)" | 
| 2213 | ||
| 53079 | 2214 | definition sin :: "real \<Rightarrow> real" | 
| 2215 | where "sin = (\<lambda>x. \<Sum>n. sin_coeff n * x ^ n)" | |
| 2216 | ||
| 2217 | definition cos :: "real \<Rightarrow> real" | |
| 2218 | where "cos = (\<lambda>x. \<Sum>n. cos_coeff n * x ^ n)" | |
| 31271 | 2219 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2220 | lemma sin_coeff_0 [simp]: "sin_coeff 0 = 0" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2221 | unfolding sin_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2222 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2223 | lemma cos_coeff_0 [simp]: "cos_coeff 0 = 1" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2224 | unfolding cos_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2225 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2226 | lemma sin_coeff_Suc: "sin_coeff (Suc n) = cos_coeff n / real (Suc n)" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2227 | unfolding cos_coeff_def sin_coeff_def | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2228 | by (simp del: mult_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2229 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2230 | lemma cos_coeff_Suc: "cos_coeff (Suc n) = - sin_coeff n / real (Suc n)" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2231 | unfolding cos_coeff_def sin_coeff_def | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2232 | by (simp del: mult_Suc, auto simp add: odd_Suc_mult_two_ex) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2233 | |
| 31271 | 2234 | lemma summable_sin: "summable (\<lambda>n. sin_coeff n * x ^ n)" | 
| 53079 | 2235 | unfolding sin_coeff_def | 
| 2236 | apply (rule summable_comparison_test [OF _ summable_exp [where x="\<bar>x\<bar>"]]) | |
| 2237 | apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | |
| 2238 | done | |
| 29164 | 2239 | |
| 31271 | 2240 | lemma summable_cos: "summable (\<lambda>n. cos_coeff n * x ^ n)" | 
| 53079 | 2241 | unfolding cos_coeff_def | 
| 2242 | apply (rule summable_comparison_test [OF _ summable_exp [where x="\<bar>x\<bar>"]]) | |
| 2243 | apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | |
| 2244 | done | |
| 29164 | 2245 | |
| 31271 | 2246 | lemma sin_converges: "(\<lambda>n. sin_coeff n * x ^ n) sums sin(x)" | 
| 53079 | 2247 | unfolding sin_def by (rule summable_sin [THEN summable_sums]) | 
| 29164 | 2248 | |
| 31271 | 2249 | lemma cos_converges: "(\<lambda>n. cos_coeff n * x ^ n) sums cos(x)" | 
| 53079 | 2250 | unfolding cos_def by (rule summable_cos [THEN summable_sums]) | 
| 29164 | 2251 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2252 | lemma diffs_sin_coeff: "diffs sin_coeff = cos_coeff" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2253 | by (simp add: diffs_def sin_coeff_Suc real_of_nat_def del: of_nat_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2254 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2255 | lemma diffs_cos_coeff: "diffs cos_coeff = (\<lambda>n. - sin_coeff n)" | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2256 | by (simp add: diffs_def cos_coeff_Suc real_of_nat_def del: of_nat_Suc) | 
| 29164 | 2257 | |
| 2258 | text{*Now at last we can get the derivatives of exp, sin and cos*}
 | |
| 2259 | ||
| 2260 | lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)" | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2261 | unfolding sin_def cos_def | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2262 | apply (rule DERIV_cong, rule termdiffs [where K="1 + \<bar>x\<bar>"]) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2263 | apply (simp_all add: diffs_sin_coeff diffs_cos_coeff | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2264 | summable_minus summable_sin summable_cos) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2265 | done | 
| 29164 | 2266 | |
| 51527 | 2267 | declare DERIV_sin[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | 
| 2268 | ||
| 29164 | 2269 | lemma DERIV_cos [simp]: "DERIV cos x :> -sin(x)" | 
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2270 | unfolding cos_def sin_def | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2271 | apply (rule DERIV_cong, rule termdiffs [where K="1 + \<bar>x\<bar>"]) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2272 | apply (simp_all add: diffs_sin_coeff diffs_cos_coeff diffs_minus | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2273 | summable_minus summable_sin summable_cos suminf_minus) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2274 | done | 
| 29164 | 2275 | |
| 51527 | 2276 | declare DERIV_cos[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | 
| 2277 | ||
| 44311 | 2278 | lemma isCont_sin: "isCont sin x" | 
| 2279 | by (rule DERIV_sin [THEN DERIV_isCont]) | |
| 2280 | ||
| 2281 | lemma isCont_cos: "isCont cos x" | |
| 2282 | by (rule DERIV_cos [THEN DERIV_isCont]) | |
| 2283 | ||
| 2284 | lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a" | |
| 2285 | by (rule isCont_o2 [OF _ isCont_sin]) | |
| 2286 | ||
| 2287 | lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a" | |
| 2288 | by (rule isCont_o2 [OF _ isCont_cos]) | |
| 2289 | ||
| 2290 | lemma tendsto_sin [tendsto_intros]: | |
| 2291 | "(f ---> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) ---> sin a) F" | |
| 2292 | by (rule isCont_tendsto_compose [OF isCont_sin]) | |
| 2293 | ||
| 2294 | lemma tendsto_cos [tendsto_intros]: | |
| 2295 | "(f ---> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) ---> cos a) F" | |
| 2296 | by (rule isCont_tendsto_compose [OF isCont_cos]) | |
| 29164 | 2297 | |
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2298 | lemma continuous_sin [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2299 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2300 | unfolding continuous_def by (rule tendsto_sin) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2301 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2302 | lemma continuous_on_sin [continuous_on_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2303 | "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2304 | unfolding continuous_on_def by (auto intro: tendsto_sin) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2305 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2306 | lemma continuous_cos [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2307 | "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2308 | unfolding continuous_def by (rule tendsto_cos) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2309 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2310 | lemma continuous_on_cos [continuous_on_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2311 | "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2312 | unfolding continuous_on_def by (auto intro: tendsto_cos) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2313 | |
| 29164 | 2314 | subsection {* Properties of Sine and Cosine *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2315 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2316 | lemma sin_zero [simp]: "sin 0 = 0" | 
| 44311 | 2317 | unfolding sin_def sin_coeff_def by (simp add: powser_zero) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2318 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2319 | lemma cos_zero [simp]: "cos 0 = 1" | 
| 44311 | 2320 | unfolding cos_def cos_coeff_def by (simp add: powser_zero) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2321 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2322 | lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2323 | proof - | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2324 | have "\<forall>x. DERIV (\<lambda>x. (sin x)\<^sup>2 + (cos x)\<^sup>2) x :> 0" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2325 | by (auto intro!: DERIV_intros) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2326 | hence "(sin x)\<^sup>2 + (cos x)\<^sup>2 = (sin 0)\<^sup>2 + (cos 0)\<^sup>2" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2327 | by (rule DERIV_isconst_all) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2328 | thus "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" by simp | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2329 | qed | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2330 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2331 | lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2332 | by (subst add_commute, rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2333 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2334 | lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2335 | using sin_cos_squared_add2 [unfolded power2_eq_square] . | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2336 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2337 | lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2338 | unfolding eq_diff_eq by (rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2339 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2340 | lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2341 | unfolding eq_diff_eq by (rule sin_cos_squared_add2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2342 | |
| 15081 | 2343 | lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2344 | by (rule power2_le_imp_le, simp_all add: sin_squared_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2345 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2346 | lemma sin_ge_minus_one [simp]: "-1 \<le> sin x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2347 | using abs_sin_le_one [of x] unfolding abs_le_iff by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2348 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2349 | lemma sin_le_one [simp]: "sin x \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2350 | using abs_sin_le_one [of x] unfolding abs_le_iff by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2351 | |
| 15081 | 2352 | lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2353 | by (rule power2_le_imp_le, simp_all add: cos_squared_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2354 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2355 | lemma cos_ge_minus_one [simp]: "-1 \<le> cos x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2356 | using abs_cos_le_one [of x] unfolding abs_le_iff by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2357 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2358 | lemma cos_le_one [simp]: "cos x \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2359 | using abs_cos_le_one [of x] unfolding abs_le_iff by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2360 | |
| 41970 | 2361 | lemma DERIV_fun_pow: "DERIV g x :> m ==> | 
| 53079 | 2362 | DERIV (\<lambda>x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m" | 
| 44311 | 2363 | by (auto intro!: DERIV_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2364 | |
| 15229 | 2365 | lemma DERIV_fun_exp: | 
| 53079 | 2366 | "DERIV g x :> m ==> DERIV (\<lambda>x. exp(g x)) x :> exp(g x) * m" | 
| 44311 | 2367 | by (auto intro!: DERIV_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2368 | |
| 15229 | 2369 | lemma DERIV_fun_sin: | 
| 53079 | 2370 | "DERIV g x :> m ==> DERIV (\<lambda>x. sin(g x)) x :> cos(g x) * m" | 
| 44311 | 2371 | by (auto intro!: DERIV_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2372 | |
| 15229 | 2373 | lemma DERIV_fun_cos: | 
| 53079 | 2374 | "DERIV g x :> m ==> DERIV (\<lambda>x. cos(g x)) x :> -sin(g x) * m" | 
| 44311 | 2375 | by (auto intro!: DERIV_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2376 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2377 | lemma sin_cos_add_lemma: | 
| 53079 | 2378 | "(sin (x + y) - (sin x * cos y + cos x * sin y))\<^sup>2 + | 
| 2379 | (cos (x + y) - (cos x * cos y - sin x * sin y))\<^sup>2 = 0" | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2380 | (is "?f x = 0") | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2381 | proof - | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2382 | have "\<forall>x. DERIV (\<lambda>x. ?f x) x :> 0" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2383 | by (auto intro!: DERIV_intros simp add: algebra_simps) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2384 | hence "?f x = ?f 0" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2385 | by (rule DERIV_isconst_all) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2386 | thus ?thesis by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2387 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2388 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2389 | lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2390 | using sin_cos_add_lemma unfolding realpow_two_sum_zero_iff by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2391 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2392 | lemma cos_add: "cos (x + y) = cos x * cos y - sin x * sin y" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2393 | using sin_cos_add_lemma unfolding realpow_two_sum_zero_iff by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2394 | |
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2395 | lemma sin_cos_minus_lemma: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2396 | "(sin(-x) + sin(x))\<^sup>2 + (cos(-x) - cos(x))\<^sup>2 = 0" (is "?f x = 0") | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2397 | proof - | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2398 | have "\<forall>x. DERIV (\<lambda>x. ?f x) x :> 0" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2399 | by (auto intro!: DERIV_intros simp add: algebra_simps) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2400 | hence "?f x = ?f 0" | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2401 | by (rule DERIV_isconst_all) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2402 | thus ?thesis by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2403 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2404 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2405 | lemma sin_minus [simp]: "sin (-x) = -sin(x)" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2406 | using sin_cos_minus_lemma [where x=x] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2407 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2408 | lemma cos_minus [simp]: "cos (-x) = cos(x)" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2409 | using sin_cos_minus_lemma [where x=x] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2410 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2411 | lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 2412 | using sin_add [of x "- y"] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2413 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2414 | lemma sin_diff2: "sin (x - y) = cos y * sin x - sin y * cos x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2415 | by (simp add: sin_diff mult_commute) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2416 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2417 | lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 2418 | using cos_add [of x "- y"] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2419 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2420 | lemma cos_diff2: "cos (x - y) = cos y * cos x + sin y * sin x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2421 | by (simp add: cos_diff mult_commute) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2422 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2423 | lemma sin_double [simp]: "sin(2 * x) = 2* sin x * cos x" | 
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 2424 | using sin_add [where x=x and y=x] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2425 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2426 | lemma cos_double: "cos(2* x) = ((cos x)\<^sup>2) - ((sin x)\<^sup>2)" | 
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 2427 | using cos_add [where x=x and y=x] | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 2428 | by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2429 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2430 | |
| 29164 | 2431 | subsection {* The Constant Pi *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2432 | |
| 53079 | 2433 | definition pi :: real | 
| 2434 | where "pi = 2 * (THE x. 0 \<le> (x::real) & x \<le> 2 & cos x = 0)" | |
| 23043 | 2435 | |
| 41970 | 2436 | text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"};
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2437 | hence define pi.*} | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2438 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2439 | lemma sin_paired: | 
| 53079 | 2440 | "(\<lambda>n. -1 ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) sums sin x" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2441 | proof - | 
| 31271 | 2442 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x" | 
| 44727 
d45acd50a894
modify lemma sums_group, and shorten proofs that use it
 huffman parents: 
44726diff
changeset | 2443 | by (rule sin_converges [THEN sums_group], simp) | 
| 31271 | 2444 | thus ?thesis unfolding One_nat_def sin_coeff_def by (simp add: mult_ac) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2445 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2446 | |
| 44728 | 2447 | lemma sin_gt_zero: | 
| 53079 | 2448 | assumes "0 < x" and "x < 2" | 
| 2449 | shows "0 < sin x" | |
| 44728 | 2450 | proof - | 
| 2451 | let ?f = "\<lambda>n. \<Sum>k = n*2..<n*2+2. -1 ^ k / real (fact (2*k+1)) * x^(2*k+1)" | |
| 2452 | have pos: "\<forall>n. 0 < ?f n" | |
| 2453 | proof | |
| 2454 | fix n :: nat | |
| 2455 | let ?k2 = "real (Suc (Suc (4 * n)))" | |
| 2456 | let ?k3 = "real (Suc (Suc (Suc (4 * n))))" | |
| 2457 | have "x * x < ?k2 * ?k3" | |
| 2458 | using assms by (intro mult_strict_mono', simp_all) | |
| 2459 | hence "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)" | |
| 2460 | by (intro mult_strict_right_mono zero_less_power `0 < x`) | |
| 2461 | thus "0 < ?f n" | |
| 2462 | by (simp del: mult_Suc, | |
| 2463 | simp add: less_divide_eq mult_pos_pos field_simps del: mult_Suc) | |
| 2464 | qed | |
| 2465 | have sums: "?f sums sin x" | |
| 2466 | by (rule sin_paired [THEN sums_group], simp) | |
| 2467 | show "0 < sin x" | |
| 2468 | unfolding sums_unique [OF sums] | |
| 2469 | using sums_summable [OF sums] pos | |
| 2470 | by (rule suminf_gt_zero) | |
| 2471 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2472 | |
| 53079 | 2473 | lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1" | 
| 2474 | using sin_gt_zero [where x = x] by (auto simp add: cos_squared_eq cos_double) | |
| 2475 | ||
| 2476 | lemma cos_paired: "(\<lambda>n. -1 ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2477 | proof - | 
| 31271 | 2478 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x" | 
| 44727 
d45acd50a894
modify lemma sums_group, and shorten proofs that use it
 huffman parents: 
44726diff
changeset | 2479 | by (rule cos_converges [THEN sums_group], simp) | 
| 31271 | 2480 | thus ?thesis unfolding cos_coeff_def by (simp add: mult_ac) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2481 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2482 | |
| 36824 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2483 | lemma real_mult_inverse_cancel: | 
| 41970 | 2484 | "[|(0::real) < x; 0 < x1; x1 * y < x * u |] | 
| 36824 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2485 | ==> inverse x * y < inverse x1 * u" | 
| 53079 | 2486 | apply (rule_tac c=x in mult_less_imp_less_left) | 
| 2487 | apply (auto simp add: mult_assoc [symmetric]) | |
| 2488 | apply (simp (no_asm) add: mult_ac) | |
| 2489 | apply (rule_tac c=x1 in mult_less_imp_less_right) | |
| 2490 | apply (auto simp add: mult_ac) | |
| 2491 | done | |
| 36824 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2492 | |
| 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2493 | lemma real_mult_inverse_cancel2: | 
| 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2494 | "[|(0::real) < x;0 < x1; x1 * y < x * u |] ==> y * inverse x < u * inverse x1" | 
| 53079 | 2495 | by (auto dest: real_mult_inverse_cancel simp add: mult_ac) | 
| 36824 
2e9a866141b8
move some theorems from RealPow.thy to Transcendental.thy
 huffman parents: 
36777diff
changeset | 2496 | |
| 53602 | 2497 | lemmas realpow_num_eq_if = power_eq_if | 
| 2498 | ||
| 2499 | lemma cos_two_less_zero [simp]: | |
| 2500 | "cos 2 < 0" | |
| 2501 | proof - | |
| 2502 | note fact_Suc [simp del] | |
| 2503 | from cos_paired | |
| 2504 | have "(\<lambda>n. - (-1 ^ n / real (fact (2 * n)) * 2 ^ (2 * n))) sums - cos 2" | |
| 2505 | by (rule sums_minus) | |
| 2506 | then have *: "(\<lambda>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n)))) sums - cos 2" | |
| 2507 | by simp | |
| 2508 | then have **: "summable (\<lambda>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))" | |
| 2509 | by (rule sums_summable) | |
| 2510 | have "0 < (\<Sum>n = 0..<Suc (Suc (Suc 0)). - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))" | |
| 2511 | by (simp add: fact_num_eq_if_nat realpow_num_eq_if) | |
| 2512 | moreover have "(\<Sum>n = 0..<Suc (Suc (Suc 0)). - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n)))) | |
| 2513 | < (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))" | |
| 2514 | proof - | |
| 2515 |     { fix d
 | |
| 2516 | have "4 * real (fact (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))) | |
| 2517 | < real (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))) * | |
| 2518 | fact (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))))" | |
| 2519 | by (simp only: real_of_nat_mult) (auto intro!: mult_strict_mono fact_less_mono_nat) | |
| 2520 | then have "4 * real (fact (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))) | |
| 2521 | < real (fact (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))))))" | |
| 2522 | by (simp only: fact_Suc [of "Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))"]) | |
| 2523 | then have "4 * inverse (real (fact (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))))))) | |
| 2524 | < inverse (real (fact (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))))" | |
| 2525 | by (simp add: inverse_eq_divide less_divide_eq) | |
| 2526 | } | |
| 2527 | note *** = this | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 2528 | have [simp]: "\<And>x y::real. 0 < x - y \<longleftrightarrow> y < x" by arith | 
| 53602 | 2529 | from ** show ?thesis by (rule sumr_pos_lt_pair) | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 2530 | (simp add: divide_inverse mult_assoc [symmetric] ***) | 
| 53602 | 2531 | qed | 
| 2532 | ultimately have "0 < (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))" | |
| 2533 | by (rule order_less_trans) | |
| 2534 | moreover from * have "- cos 2 = (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))" | |
| 2535 | by (rule sums_unique) | |
| 2536 | ultimately have "0 < - cos 2" by simp | |
| 2537 | then show ?thesis by simp | |
| 2538 | qed | |
| 23053 | 2539 | |
| 2540 | lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] | |
| 2541 | lemmas cos_two_le_zero [simp] = cos_two_less_zero [THEN order_less_imp_le] | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2542 | |
| 53079 | 2543 | lemma cos_is_zero: "EX! x. 0 \<le> x & x \<le> 2 \<and> cos x = 0" | 
| 44730 | 2544 | proof (rule ex_ex1I) | 
| 2545 | show "\<exists>x. 0 \<le> x & x \<le> 2 & cos x = 0" | |
| 2546 | by (rule IVT2, simp_all) | |
| 2547 | next | |
| 2548 | fix x y | |
| 2549 | assume x: "0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | |
| 2550 | assume y: "0 \<le> y \<and> y \<le> 2 \<and> cos y = 0" | |
| 2551 | have [simp]: "\<forall>x. cos differentiable x" | |
| 2552 | unfolding differentiable_def by (auto intro: DERIV_cos) | |
| 2553 | from x y show "x = y" | |
| 2554 | apply (cut_tac less_linear [of x y], auto) | |
| 2555 | apply (drule_tac f = cos in Rolle) | |
| 2556 | apply (drule_tac [5] f = cos in Rolle) | |
| 2557 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 2558 | apply (metis order_less_le_trans less_le sin_gt_zero) | |
| 2559 | apply (metis order_less_le_trans less_le sin_gt_zero) | |
| 2560 | done | |
| 2561 | qed | |
| 31880 | 2562 | |
| 23053 | 2563 | lemma pi_half: "pi/2 = (THE x. 0 \<le> x & x \<le> 2 & cos x = 0)" | 
| 53079 | 2564 | by (simp add: pi_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2565 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2566 | lemma cos_pi_half [simp]: "cos (pi / 2) = 0" | 
| 53079 | 2567 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 23053 | 2568 | |
| 2569 | lemma pi_half_gt_zero [simp]: "0 < pi / 2" | |
| 53079 | 2570 | apply (rule order_le_neq_trans) | 
| 2571 | apply (simp add: pi_half cos_is_zero [THEN theI']) | |
| 2572 | apply (rule notI, drule arg_cong [where f=cos], simp) | |
| 2573 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2574 | |
| 23053 | 2575 | lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] | 
| 2576 | lemmas pi_half_ge_zero [simp] = pi_half_gt_zero [THEN order_less_imp_le] | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2577 | |
| 23053 | 2578 | lemma pi_half_less_two [simp]: "pi / 2 < 2" | 
| 53079 | 2579 | apply (rule order_le_neq_trans) | 
| 2580 | apply (simp add: pi_half cos_is_zero [THEN theI']) | |
| 2581 | apply (rule notI, drule arg_cong [where f=cos], simp) | |
| 2582 | done | |
| 23053 | 2583 | |
| 2584 | lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] | |
| 2585 | lemmas pi_half_le_two [simp] = pi_half_less_two [THEN order_less_imp_le] | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2586 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2587 | lemma pi_gt_zero [simp]: "0 < pi" | 
| 53079 | 2588 | using pi_half_gt_zero by simp | 
| 23053 | 2589 | |
| 2590 | lemma pi_ge_zero [simp]: "0 \<le> pi" | |
| 53079 | 2591 | by (rule pi_gt_zero [THEN order_less_imp_le]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2592 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2593 | lemma pi_neq_zero [simp]: "pi \<noteq> 0" | 
| 53079 | 2594 | by (rule pi_gt_zero [THEN less_imp_neq, symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2595 | |
| 23053 | 2596 | lemma pi_not_less_zero [simp]: "\<not> pi < 0" | 
| 53079 | 2597 | by (simp add: linorder_not_less) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2598 | |
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 2599 | lemma minus_pi_half_less_zero: "-(pi/2) < 0" | 
| 53079 | 2600 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2601 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2602 | lemma m2pi_less_pi: "- (2 * pi) < pi" | 
| 53079 | 2603 | by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2604 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2605 | lemma sin_pi_half [simp]: "sin(pi/2) = 1" | 
| 53079 | 2606 | using sin_cos_squared_add2 [where x = "pi/2"] | 
| 2607 | using sin_gt_zero [OF pi_half_gt_zero pi_half_less_two] | |
| 2608 | by (simp add: power2_eq_1_iff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2609 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2610 | lemma cos_pi [simp]: "cos pi = -1" | 
| 53079 | 2611 | using cos_add [where x = "pi/2" and y = "pi/2"] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2612 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2613 | lemma sin_pi [simp]: "sin pi = 0" | 
| 53079 | 2614 | using sin_add [where x = "pi/2" and y = "pi/2"] by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2615 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2616 | lemma sin_cos_eq: "sin x = cos (pi/2 - x)" | 
| 53079 | 2617 | by (simp add: cos_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2618 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2619 | lemma minus_sin_cos_eq: "-sin x = cos (x + pi/2)" | 
| 53079 | 2620 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2621 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2622 | lemma cos_sin_eq: "cos x = sin (pi/2 - x)" | 
| 53079 | 2623 | by (simp add: sin_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2624 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2625 | lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" | 
| 53079 | 2626 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2627 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2628 | lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" | 
| 53079 | 2629 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2630 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2631 | lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" | 
| 53079 | 2632 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2633 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2634 | lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x" | 
| 53079 | 2635 | by (simp add: sin_add cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2636 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2637 | lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x" | 
| 53079 | 2638 | by (simp add: cos_add cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2639 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2640 | lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n" | 
| 53079 | 2641 | by (induct n) (auto simp add: real_of_nat_Suc distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2642 | |
| 15383 | 2643 | lemma cos_npi2 [simp]: "cos (pi * real n) = -1 ^ n" | 
| 2644 | proof - | |
| 2645 | have "cos (pi * real n) = cos (real n * pi)" by (simp only: mult_commute) | |
| 41970 | 2646 | also have "... = -1 ^ n" by (rule cos_npi) | 
| 15383 | 2647 | finally show ?thesis . | 
| 2648 | qed | |
| 2649 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2650 | lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0" | 
| 53079 | 2651 | by (induct n) (auto simp add: real_of_nat_Suc distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2652 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2653 | lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0" | 
| 53079 | 2654 | by (simp add: mult_commute [of pi]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2655 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2656 | lemma cos_two_pi [simp]: "cos (2 * pi) = 1" | 
| 53079 | 2657 | by (simp add: cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2658 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2659 | lemma sin_two_pi [simp]: "sin (2 * pi) = 0" | 
| 53079 | 2660 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2661 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2662 | lemma sin_gt_zero2: "[| 0 < x; x < pi/2 |] ==> 0 < sin x" | 
| 53079 | 2663 | apply (rule sin_gt_zero, assumption) | 
| 2664 | apply (rule order_less_trans, assumption) | |
| 2665 | apply (rule pi_half_less_two) | |
| 2666 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2667 | |
| 41970 | 2668 | lemma sin_less_zero: | 
| 53079 | 2669 | assumes "- pi/2 < x" and "x < 0" | 
| 2670 | shows "sin x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2671 | proof - | 
| 41970 | 2672 | have "0 < sin (- x)" using assms by (simp only: sin_gt_zero2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2673 | thus ?thesis by simp | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2674 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2675 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2676 | lemma pi_less_4: "pi < 4" | 
| 53079 | 2677 | using pi_half_less_two by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2678 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2679 | lemma cos_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < cos x" | 
| 53079 | 2680 | apply (cut_tac pi_less_4) | 
| 2681 | apply (cut_tac f = cos and a = 0 and b = x and y = 0 in IVT2_objl, safe, simp_all) | |
| 2682 | apply (cut_tac cos_is_zero, safe) | |
| 2683 | apply (rename_tac y z) | |
| 2684 | apply (drule_tac x = y in spec) | |
| 2685 | apply (drule_tac x = "pi/2" in spec, simp) | |
| 2686 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2687 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2688 | lemma cos_gt_zero_pi: "[| -(pi/2) < x; x < pi/2 |] ==> 0 < cos x" | 
| 53079 | 2689 | apply (rule_tac x = x and y = 0 in linorder_cases) | 
| 2690 | apply (rule cos_minus [THEN subst]) | |
| 2691 | apply (rule cos_gt_zero) | |
| 2692 | apply (auto intro: cos_gt_zero) | |
| 2693 | done | |
| 41970 | 2694 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2695 | lemma cos_ge_zero: "[| -(pi/2) \<le> x; x \<le> pi/2 |] ==> 0 \<le> cos x" | 
| 53079 | 2696 | apply (auto simp add: order_le_less cos_gt_zero_pi) | 
| 2697 | apply (subgoal_tac "x = pi/2", auto) | |
| 2698 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2699 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2700 | lemma sin_gt_zero_pi: "[| 0 < x; x < pi |] ==> 0 < sin x" | 
| 53079 | 2701 | by (simp add: sin_cos_eq cos_gt_zero_pi) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2702 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2703 | lemma pi_ge_two: "2 \<le> pi" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2704 | proof (rule ccontr) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2705 | assume "\<not> 2 \<le> pi" hence "pi < 2" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2706 | have "\<exists>y > pi. y < 2 \<and> y < 2 * pi" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2707 | proof (cases "2 < 2 * pi") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2708 | case True with dense[OF `pi < 2`] show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2709 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2710 | case False have "pi < 2 * pi" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2711 | from dense[OF this] and False show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2712 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2713 | then obtain y where "pi < y" and "y < 2" and "y < 2 * pi" by blast | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2714 | hence "0 < sin y" using sin_gt_zero by auto | 
| 41970 | 2715 | moreover | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2716 | have "sin y < 0" using sin_gt_zero_pi[of "y - pi"] `pi < y` and `y < 2 * pi` sin_periodic_pi[of "y - pi"] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2717 | ultimately show False by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2718 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2719 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2720 | lemma sin_ge_zero: "[| 0 \<le> x; x \<le> pi |] ==> 0 \<le> sin x" | 
| 53079 | 2721 | by (auto simp add: order_le_less sin_gt_zero_pi) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2722 | |
| 44745 | 2723 | text {* FIXME: This proof is almost identical to lemma @{text cos_is_zero}.
 | 
| 2724 | It should be possible to factor out some of the common parts. *} | |
| 2725 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2726 | lemma cos_total: "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)" | 
| 44745 | 2727 | proof (rule ex_ex1I) | 
| 2728 | assume y: "-1 \<le> y" "y \<le> 1" | |
| 2729 | show "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y" | |
| 2730 | by (rule IVT2, simp_all add: y) | |
| 2731 | next | |
| 2732 | fix a b | |
| 2733 | assume a: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" | |
| 2734 | assume b: "0 \<le> b \<and> b \<le> pi \<and> cos b = y" | |
| 2735 | have [simp]: "\<forall>x. cos differentiable x" | |
| 2736 | unfolding differentiable_def by (auto intro: DERIV_cos) | |
| 2737 | from a b show "a = b" | |
| 2738 | apply (cut_tac less_linear [of a b], auto) | |
| 2739 | apply (drule_tac f = cos in Rolle) | |
| 2740 | apply (drule_tac [5] f = cos in Rolle) | |
| 2741 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 2742 | apply (metis order_less_le_trans less_le sin_gt_zero_pi) | |
| 2743 | apply (metis order_less_le_trans less_le sin_gt_zero_pi) | |
| 2744 | done | |
| 2745 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2746 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2747 | lemma sin_total: | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2748 | "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2749 | apply (rule ccontr) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2750 | apply (subgoal_tac "\<forall>x. (- (pi/2) \<le> x & x \<le> pi/2 & (sin x = y)) = (0 \<le> (x + pi/2) & (x + pi/2) \<le> pi & (cos (x + pi/2) = -y))") | 
| 18585 | 2751 | apply (erule contrapos_np) | 
| 45309 
5885ec8eb6b0
removed ad-hoc simp rules sin_cos_eq[symmetric], minus_sin_cos_eq[symmetric], cos_sin_eq[symmetric]
 huffman parents: 
45308diff
changeset | 2752 | apply simp | 
| 41970 | 2753 | apply (cut_tac y="-y" in cos_total, simp) apply simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2754 | apply (erule ex1E) | 
| 15229 | 2755 | apply (rule_tac a = "x - (pi/2)" in ex1I) | 
| 23286 | 2756 | apply (simp (no_asm) add: add_assoc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2757 | apply (rotate_tac 3) | 
| 45309 
5885ec8eb6b0
removed ad-hoc simp rules sin_cos_eq[symmetric], minus_sin_cos_eq[symmetric], cos_sin_eq[symmetric]
 huffman parents: 
45308diff
changeset | 2758 | apply (drule_tac x = "xa + pi/2" in spec, safe, simp_all add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2759 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2760 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2761 | lemma reals_Archimedean4: | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2762 | "[| 0 < y; 0 \<le> x |] ==> \<exists>n. real n * y \<le> x & x < real (Suc n) * y" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2763 | apply (auto dest!: reals_Archimedean3) | 
| 41970 | 2764 | apply (drule_tac x = x in spec, clarify) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2765 | apply (subgoal_tac "x < real(LEAST m::nat. x < real m * y) * y") | 
| 41970 | 2766 | prefer 2 apply (erule LeastI) | 
| 2767 | apply (case_tac "LEAST m::nat. x < real m * y", simp) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2768 | apply (subgoal_tac "~ x < real nat * y") | 
| 41970 | 2769 | prefer 2 apply (rule not_less_Least, simp, force) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2770 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2771 | |
| 41970 | 2772 | (* Pre Isabelle99-2 proof was simpler- numerals arithmetic | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2773 | now causes some unwanted re-arrangements of literals! *) | 
| 15229 | 2774 | lemma cos_zero_lemma: | 
| 41970 | 2775 | "[| 0 \<le> x; cos x = 0 |] ==> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2776 | \<exists>n::nat. ~even n & x = real n * (pi/2)" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2777 | apply (drule pi_gt_zero [THEN reals_Archimedean4], safe) | 
| 41970 | 2778 | apply (subgoal_tac "0 \<le> x - real n * pi & | 
| 15086 | 2779 | (x - real n * pi) \<le> pi & (cos (x - real n * pi) = 0) ") | 
| 29667 | 2780 | apply (auto simp add: algebra_simps real_of_nat_Suc) | 
| 2781 | prefer 2 apply (simp add: cos_diff) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2782 | apply (simp add: cos_diff) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2783 | apply (subgoal_tac "EX! x. 0 \<le> x & x \<le> pi & cos x = 0") | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2784 | apply (rule_tac [2] cos_total, safe) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2785 | apply (drule_tac x = "x - real n * pi" in spec) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2786 | apply (drule_tac x = "pi/2" in spec) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2787 | apply (simp add: cos_diff) | 
| 15229 | 2788 | apply (rule_tac x = "Suc (2 * n)" in exI) | 
| 29667 | 2789 | apply (simp add: real_of_nat_Suc algebra_simps, auto) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2790 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2791 | |
| 15229 | 2792 | lemma sin_zero_lemma: | 
| 41970 | 2793 | "[| 0 \<le> x; sin x = 0 |] ==> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2794 | \<exists>n::nat. even n & x = real n * (pi/2)" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2795 | apply (subgoal_tac "\<exists>n::nat. ~ even n & x + pi/2 = real n * (pi/2) ") | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2796 | apply (clarify, rule_tac x = "n - 1" in exI) | 
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 2797 | apply (force simp add: odd_Suc_mult_two_ex real_of_nat_Suc distrib_right) | 
| 15085 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 paulson parents: 
15081diff
changeset | 2798 | apply (rule cos_zero_lemma) | 
| 45309 
5885ec8eb6b0
removed ad-hoc simp rules sin_cos_eq[symmetric], minus_sin_cos_eq[symmetric], cos_sin_eq[symmetric]
 huffman parents: 
45308diff
changeset | 2799 | apply (simp_all add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2800 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2801 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2802 | |
| 15229 | 2803 | lemma cos_zero_iff: | 
| 41970 | 2804 | "(cos x = 0) = | 
| 2805 | ((\<exists>n::nat. ~even n & (x = real n * (pi/2))) | | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2806 | (\<exists>n::nat. ~even n & (x = -(real n * (pi/2)))))" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2807 | apply (rule iffI) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2808 | apply (cut_tac linorder_linear [of 0 x], safe) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2809 | apply (drule cos_zero_lemma, assumption+) | 
| 41970 | 2810 | apply (cut_tac x="-x" in cos_zero_lemma, simp, simp) | 
| 2811 | apply (force simp add: minus_equation_iff [of x]) | |
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 2812 | apply (auto simp only: odd_Suc_mult_two_ex real_of_nat_Suc distrib_right) | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 2813 | apply (auto simp add: cos_diff cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2814 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2815 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2816 | (* ditto: but to a lesser extent *) | 
| 15229 | 2817 | lemma sin_zero_iff: | 
| 41970 | 2818 | "(sin x = 0) = | 
| 2819 | ((\<exists>n::nat. even n & (x = real n * (pi/2))) | | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2820 | (\<exists>n::nat. even n & (x = -(real n * (pi/2)))))" | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2821 | apply (rule iffI) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2822 | apply (cut_tac linorder_linear [of 0 x], safe) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2823 | apply (drule sin_zero_lemma, assumption+) | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2824 | apply (cut_tac x="-x" in sin_zero_lemma, simp, simp, safe) | 
| 41970 | 2825 | apply (force simp add: minus_equation_iff [of x]) | 
| 15539 | 2826 | apply (auto simp add: even_mult_two_ex) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2827 | done | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2828 | |
| 53079 | 2829 | lemma cos_monotone_0_pi: | 
| 2830 | assumes "0 \<le> y" and "y < x" and "x \<le> pi" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2831 | shows "cos x < cos y" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2832 | proof - | 
| 33549 | 2833 | have "- (x - y) < 0" using assms by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2834 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2835 | from MVT2[OF `y < x` DERIV_cos[THEN impI, THEN allI]] | 
| 53079 | 2836 | obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z" | 
| 2837 | by auto | |
| 33549 | 2838 | hence "0 < z" and "z < pi" using assms by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2839 | hence "0 < sin z" using sin_gt_zero_pi by auto | 
| 53079 | 2840 | hence "cos x - cos y < 0" | 
| 2841 | unfolding cos_diff minus_mult_commute[symmetric] | |
| 2842 | using `- (x - y) < 0` by (rule mult_pos_neg2) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2843 | thus ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2844 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2845 | |
| 53079 | 2846 | lemma cos_monotone_0_pi': | 
| 2847 | assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi" | |
| 2848 | shows "cos x \<le> cos y" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2849 | proof (cases "y < x") | 
| 53079 | 2850 | case True | 
| 2851 | show ?thesis | |
| 2852 | using cos_monotone_0_pi[OF `0 \<le> y` True `x \<le> pi`] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2853 | next | 
| 53079 | 2854 | case False | 
| 2855 | hence "y = x" using `y \<le> x` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2856 | thus ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2857 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2858 | |
| 53079 | 2859 | lemma cos_monotone_minus_pi_0: | 
| 2860 | assumes "-pi \<le> y" and "y < x" and "x \<le> 0" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2861 | shows "cos y < cos x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2862 | proof - | 
| 53079 | 2863 | have "0 \<le> -x" and "-x < -y" and "-y \<le> pi" | 
| 2864 | using assms by auto | |
| 2865 | from cos_monotone_0_pi[OF this] show ?thesis | |
| 2866 | unfolding cos_minus . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2867 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2868 | |
| 53079 | 2869 | lemma cos_monotone_minus_pi_0': | 
| 2870 | assumes "-pi \<le> y" and "y \<le> x" and "x \<le> 0" | |
| 2871 | shows "cos y \<le> cos x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2872 | proof (cases "y < x") | 
| 53079 | 2873 | case True | 
| 2874 | show ?thesis using cos_monotone_minus_pi_0[OF `-pi \<le> y` True `x \<le> 0`] | |
| 2875 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2876 | next | 
| 53079 | 2877 | case False | 
| 2878 | hence "y = x" using `y \<le> x` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2879 | thus ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2880 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2881 | |
| 53079 | 2882 | lemma sin_monotone_2pi': | 
| 2883 | assumes "- (pi / 2) \<le> y" and "y \<le> x" and "x \<le> pi / 2" | |
| 2884 | shows "sin y \<le> sin x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2885 | proof - | 
| 33549 | 2886 | have "0 \<le> y + pi / 2" and "y + pi / 2 \<le> x + pi / 2" and "x + pi /2 \<le> pi" | 
| 2887 | using pi_ge_two and assms by auto | |
| 53079 | 2888 | from cos_monotone_0_pi'[OF this] show ?thesis | 
| 2889 | unfolding minus_sin_cos_eq[symmetric] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2890 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2891 | |
| 53079 | 2892 | |
| 29164 | 2893 | subsection {* Tangent *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2894 | |
| 53079 | 2895 | definition tan :: "real \<Rightarrow> real" | 
| 2896 | where "tan = (\<lambda>x. sin x / cos x)" | |
| 23043 | 2897 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2898 | lemma tan_zero [simp]: "tan 0 = 0" | 
| 44311 | 2899 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2900 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2901 | lemma tan_pi [simp]: "tan pi = 0" | 
| 44311 | 2902 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2903 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2904 | lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0" | 
| 44311 | 2905 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2906 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2907 | lemma tan_minus [simp]: "tan (-x) = - tan x" | 
| 44311 | 2908 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2909 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2910 | lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x" | 
| 44311 | 2911 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2912 | |
| 41970 | 2913 | lemma lemma_tan_add1: | 
| 44311 | 2914 | "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> 1 - tan x * tan y = cos (x + y)/(cos x * cos y)" | 
| 2915 | by (simp add: tan_def cos_add field_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2916 | |
| 41970 | 2917 | lemma add_tan_eq: | 
| 44311 | 2918 | "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> tan x + tan y = sin(x + y)/(cos x * cos y)" | 
| 2919 | by (simp add: tan_def sin_add field_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2920 | |
| 15229 | 2921 | lemma tan_add: | 
| 41970 | 2922 | "[| cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0 |] | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2923 | ==> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))" | 
| 44311 | 2924 | by (simp add: add_tan_eq lemma_tan_add1, simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2925 | |
| 15229 | 2926 | lemma tan_double: | 
| 41970 | 2927 | "[| cos x \<noteq> 0; cos (2 * x) \<noteq> 0 |] | 
| 53076 | 2928 | ==> tan (2 * x) = (2 * tan x) / (1 - (tan x)\<^sup>2)" | 
| 44311 | 2929 | using tan_add [of x x] by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2930 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2931 | lemma tan_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < tan x" | 
| 53079 | 2932 | by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 41970 | 2933 | |
| 2934 | lemma tan_less_zero: | |
| 53079 | 2935 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 2936 | shows "tan x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2937 | proof - | 
| 41970 | 2938 | have "0 < tan (- x)" using assms by (simp only: tan_gt_zero) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2939 | thus ?thesis by simp | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2940 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2941 | |
| 44756 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 2942 | lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)" | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 2943 | unfolding tan_def sin_double cos_double sin_squared_eq | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 2944 | by (simp add: power2_eq_square) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 2945 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 2946 | lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)" | 
| 44311 | 2947 | unfolding tan_def | 
| 2948 | by (auto intro!: DERIV_intros, simp add: divide_inverse power2_eq_square) | |
| 2949 | ||
| 2950 | lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x" | |
| 2951 | by (rule DERIV_tan [THEN DERIV_isCont]) | |
| 2952 | ||
| 2953 | lemma isCont_tan' [simp]: | |
| 2954 | "\<lbrakk>isCont f a; cos (f a) \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a" | |
| 2955 | by (rule isCont_o2 [OF _ isCont_tan]) | |
| 2956 | ||
| 2957 | lemma tendsto_tan [tendsto_intros]: | |
| 2958 | "\<lbrakk>(f ---> a) F; cos a \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. tan (f x)) ---> tan a) F" | |
| 2959 | by (rule isCont_tendsto_compose [OF isCont_tan]) | |
| 2960 | ||
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2961 | lemma continuous_tan: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2962 | "continuous F f \<Longrightarrow> cos (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. tan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2963 | unfolding continuous_def by (rule tendsto_tan) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2964 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2965 | lemma isCont_tan'' [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2966 | "continuous (at x) f \<Longrightarrow> cos (f x) \<noteq> 0 \<Longrightarrow> continuous (at x) (\<lambda>x. tan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2967 | unfolding continuous_at by (rule tendsto_tan) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2968 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2969 | lemma continuous_within_tan [continuous_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2970 | "continuous (at x within s) f \<Longrightarrow> cos (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. tan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2971 | unfolding continuous_within by (rule tendsto_tan) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2972 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2973 | lemma continuous_on_tan [continuous_on_intros]: | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2974 | "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. cos (f x) \<noteq> 0) \<Longrightarrow> continuous_on s (\<lambda>x. tan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2975 | unfolding continuous_on_def by (auto intro: tendsto_tan) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 2976 | |
| 53079 | 2977 | lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) -- pi/2 --> 0" | 
| 44311 | 2978 | by (rule LIM_cong_limit, (rule tendsto_intros)+, simp_all) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2979 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2980 | lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x" | 
| 53079 | 2981 | apply (cut_tac LIM_cos_div_sin) | 
| 2982 | apply (simp only: LIM_eq) | |
| 2983 | apply (drule_tac x = "inverse y" in spec, safe, force) | |
| 2984 | apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe) | |
| 2985 | apply (rule_tac x = "(pi/2) - e" in exI) | |
| 2986 | apply (simp (no_asm_simp)) | |
| 2987 | apply (drule_tac x = "(pi/2) - e" in spec) | |
| 2988 | apply (auto simp add: tan_def sin_diff cos_diff) | |
| 2989 | apply (rule inverse_less_iff_less [THEN iffD1]) | |
| 2990 | apply (auto simp add: divide_inverse) | |
| 2991 | apply (rule mult_pos_pos) | |
| 2992 | apply (subgoal_tac [3] "0 < sin e & 0 < cos e") | |
| 2993 | apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: mult_commute) | |
| 2994 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2995 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2996 | lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y" | 
| 53079 | 2997 | apply (frule order_le_imp_less_or_eq, safe) | 
| 2998 | prefer 2 apply force | |
| 2999 | apply (drule lemma_tan_total, safe) | |
| 3000 | apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl) | |
| 3001 | apply (auto intro!: DERIV_tan [THEN DERIV_isCont]) | |
| 3002 | apply (drule_tac y = xa in order_le_imp_less_or_eq) | |
| 3003 | apply (auto dest: cos_gt_zero) | |
| 3004 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3005 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3006 | lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y" | 
| 53079 | 3007 | apply (cut_tac linorder_linear [of 0 y], safe) | 
| 3008 | apply (drule tan_total_pos) | |
| 3009 | apply (cut_tac [2] y="-y" in tan_total_pos, safe) | |
| 3010 | apply (rule_tac [3] x = "-x" in exI) | |
| 3011 | apply (auto del: exI intro!: exI) | |
| 3012 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3013 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3014 | lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y" | 
| 53079 | 3015 | apply (cut_tac y = y in lemma_tan_total1, auto) | 
| 3016 | apply (cut_tac x = xa and y = y in linorder_less_linear, auto) | |
| 3017 | apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0") | |
| 3018 | apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0") | |
| 3019 | apply (rule_tac [4] Rolle) | |
| 3020 | apply (rule_tac [2] Rolle) | |
| 3021 | apply (auto del: exI intro!: DERIV_tan DERIV_isCont exI | |
| 3022 | simp add: differentiable_def) | |
| 3023 |   txt{*Now, simulate TRYALL*}
 | |
| 3024 | apply (rule_tac [!] DERIV_tan asm_rl) | |
| 3025 | apply (auto dest!: DERIV_unique [OF _ DERIV_tan] | |
| 3026 | simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym]) | |
| 3027 | done | |
| 3028 | ||
| 3029 | lemma tan_monotone: | |
| 3030 | assumes "- (pi / 2) < y" and "y < x" and "x < pi / 2" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3031 | shows "tan y < tan x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3032 | proof - | 
| 53079 | 3033 | have "\<forall>x'. y \<le> x' \<and> x' \<le> x \<longrightarrow> DERIV tan x' :> inverse ((cos x')\<^sup>2)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3034 | proof (rule allI, rule impI) | 
| 53079 | 3035 | fix x' :: real | 
| 3036 | assume "y \<le> x' \<and> x' \<le> x" | |
| 33549 | 3037 | hence "-(pi/2) < x'" and "x' < pi/2" using assms by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3038 | from cos_gt_zero_pi[OF this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3039 | have "cos x' \<noteq> 0" by auto | 
| 53076 | 3040 | thus "DERIV tan x' :> inverse ((cos x')\<^sup>2)" by (rule DERIV_tan) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3041 | qed | 
| 41970 | 3042 | from MVT2[OF `y < x` this] | 
| 53079 | 3043 | obtain z where "y < z" and "z < x" | 
| 3044 | and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto | |
| 33549 | 3045 | hence "- (pi / 2) < z" and "z < pi / 2" using assms by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3046 | hence "0 < cos z" using cos_gt_zero_pi by auto | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3047 | hence inv_pos: "0 < inverse ((cos z)\<^sup>2)" by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3048 | have "0 < x - y" using `y < x` by auto | 
| 36777 
be5461582d0f
avoid using real-specific versions of generic lemmas
 huffman parents: 
36776diff
changeset | 3049 | from mult_pos_pos [OF this inv_pos] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3050 | have "0 < tan x - tan y" unfolding tan_diff by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3051 | thus ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3052 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3053 | |
| 53079 | 3054 | lemma tan_monotone': | 
| 3055 | assumes "- (pi / 2) < y" | |
| 3056 | and "y < pi / 2" | |
| 3057 | and "- (pi / 2) < x" | |
| 3058 | and "x < pi / 2" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3059 | shows "(y < x) = (tan y < tan x)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3060 | proof | 
| 53079 | 3061 | assume "y < x" | 
| 3062 | thus "tan y < tan x" | |
| 3063 | using tan_monotone and `- (pi / 2) < y` and `x < pi / 2` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3064 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3065 | assume "tan y < tan x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3066 | show "y < x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3067 | proof (rule ccontr) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3068 | assume "\<not> y < x" hence "x \<le> y" by auto | 
| 41970 | 3069 | hence "tan x \<le> tan y" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3070 | proof (cases "x = y") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3071 | case True thus ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3072 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3073 | case False hence "x < y" using `x \<le> y` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3074 | from tan_monotone[OF `- (pi/2) < x` this `y < pi / 2`] show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3075 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3076 | thus False using `tan y < tan x` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3077 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3078 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3079 | |
| 53079 | 3080 | lemma tan_inverse: "1 / (tan y) = tan (pi / 2 - y)" | 
| 3081 | unfolding tan_def sin_cos_eq[of y] cos_sin_eq[of y] by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3082 | |
| 41970 | 3083 | lemma tan_periodic_pi[simp]: "tan (x + pi) = tan x" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3084 | by (simp add: tan_def) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3085 | |
| 53079 | 3086 | lemma tan_periodic_nat[simp]: | 
| 3087 | fixes n :: nat | |
| 3088 | shows "tan (x + real n * pi) = tan x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3089 | proof (induct n arbitrary: x) | 
| 53079 | 3090 | case 0 | 
| 3091 | then show ?case by simp | |
| 3092 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3093 | case (Suc n) | 
| 53079 | 3094 | have split_pi_off: "x + real (Suc n) * pi = (x + real n * pi) + pi" | 
| 3095 | unfolding Suc_eq_plus1 real_of_nat_add real_of_one distrib_right by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3096 | show ?case unfolding split_pi_off using Suc by auto | 
| 53079 | 3097 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3098 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3099 | lemma tan_periodic_int[simp]: fixes i :: int shows "tan (x + real i * pi) = tan x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3100 | proof (cases "0 \<le> i") | 
| 53079 | 3101 | case True | 
| 3102 | hence i_nat: "real i = real (nat i)" by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3103 | show ?thesis unfolding i_nat by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3104 | next | 
| 53079 | 3105 | case False | 
| 3106 | hence i_nat: "real i = - real (nat (-i))" by auto | |
| 3107 | have "tan x = tan (x + real i * pi - real i * pi)" | |
| 3108 | by auto | |
| 3109 | also have "\<dots> = tan (x + real i * pi)" | |
| 3110 | unfolding i_nat mult_minus_left diff_minus_eq_add by (rule tan_periodic_nat) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3111 | finally show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3112 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3113 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 3114 | lemma tan_periodic_n[simp]: "tan (x + numeral n * pi) = tan x" | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 3115 | using tan_periodic_int[of _ "numeral n" ] unfolding real_numeral . | 
| 23043 | 3116 | |
| 3117 | subsection {* Inverse Trigonometric Functions *}
 | |
| 3118 | ||
| 53079 | 3119 | definition arcsin :: "real => real" | 
| 3120 | where "arcsin y = (THE x. -(pi/2) \<le> x & x \<le> pi/2 & sin x = y)" | |
| 3121 | ||
| 3122 | definition arccos :: "real => real" | |
| 3123 | where "arccos y = (THE x. 0 \<le> x & x \<le> pi & cos x = y)" | |
| 3124 | ||
| 3125 | definition arctan :: "real => real" | |
| 3126 | where "arctan y = (THE x. -(pi/2) < x & x < pi/2 & tan x = y)" | |
| 23043 | 3127 | |
| 15229 | 3128 | lemma arcsin: | 
| 53079 | 3129 | "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> | 
| 3130 | -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2 & sin(arcsin y) = y" | |
| 3131 | unfolding arcsin_def by (rule theI' [OF sin_total]) | |
| 23011 | 3132 | |
| 3133 | lemma arcsin_pi: | |
| 53079 | 3134 | "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y" | 
| 3135 | apply (drule (1) arcsin) | |
| 3136 | apply (force intro: order_trans) | |
| 3137 | done | |
| 3138 | ||
| 3139 | lemma sin_arcsin [simp]: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin(arcsin y) = y" | |
| 3140 | by (blast dest: arcsin) | |
| 3141 | ||
| 3142 | lemma arcsin_bounded: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2" | |
| 3143 | by (blast dest: arcsin) | |
| 3144 | ||
| 3145 | lemma arcsin_lbound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y" | |
| 3146 | by (blast dest: arcsin) | |
| 3147 | ||
| 3148 | lemma arcsin_ubound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2" | |
| 3149 | by (blast dest: arcsin) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3150 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3151 | lemma arcsin_lt_bounded: | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3152 | "[| -1 < y; y < 1 |] ==> -(pi/2) < arcsin y & arcsin y < pi/2" | 
| 53079 | 3153 | apply (frule order_less_imp_le) | 
| 3154 | apply (frule_tac y = y in order_less_imp_le) | |
| 3155 | apply (frule arcsin_bounded) | |
| 3156 | apply (safe, simp) | |
| 3157 | apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq) | |
| 3158 | apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe) | |
| 3159 | apply (drule_tac [!] f = sin in arg_cong, auto) | |
| 3160 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3161 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3162 | lemma arcsin_sin: "[|-(pi/2) \<le> x; x \<le> pi/2 |] ==> arcsin(sin x) = x" | 
| 53079 | 3163 | apply (unfold arcsin_def) | 
| 3164 | apply (rule the1_equality) | |
| 3165 | apply (rule sin_total, auto) | |
| 3166 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3167 | |
| 22975 | 3168 | lemma arccos: | 
| 41970 | 3169 | "[| -1 \<le> y; y \<le> 1 |] | 
| 22975 | 3170 | ==> 0 \<le> arccos y & arccos y \<le> pi & cos(arccos y) = y" | 
| 53079 | 3171 | unfolding arccos_def by (rule theI' [OF cos_total]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3172 | |
| 22975 | 3173 | lemma cos_arccos [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> cos(arccos y) = y" | 
| 53079 | 3174 | by (blast dest: arccos) | 
| 41970 | 3175 | |
| 22975 | 3176 | lemma arccos_bounded: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arccos y & arccos y \<le> pi" | 
| 53079 | 3177 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3178 | |
| 22975 | 3179 | lemma arccos_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arccos y" | 
| 53079 | 3180 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3181 | |
| 22975 | 3182 | lemma arccos_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arccos y \<le> pi" | 
| 53079 | 3183 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3184 | |
| 22975 | 3185 | lemma arccos_lt_bounded: | 
| 41970 | 3186 | "[| -1 < y; y < 1 |] | 
| 22975 | 3187 | ==> 0 < arccos y & arccos y < pi" | 
| 53079 | 3188 | apply (frule order_less_imp_le) | 
| 3189 | apply (frule_tac y = y in order_less_imp_le) | |
| 3190 | apply (frule arccos_bounded, auto) | |
| 3191 | apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq) | |
| 3192 | apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto) | |
| 3193 | apply (drule_tac [!] f = cos in arg_cong, auto) | |
| 3194 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3195 | |
| 22975 | 3196 | lemma arccos_cos: "[|0 \<le> x; x \<le> pi |] ==> arccos(cos x) = x" | 
| 53079 | 3197 | apply (simp add: arccos_def) | 
| 3198 | apply (auto intro!: the1_equality cos_total) | |
| 3199 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3200 | |
| 22975 | 3201 | lemma arccos_cos2: "[|x \<le> 0; -pi \<le> x |] ==> arccos(cos x) = -x" | 
| 53079 | 3202 | apply (simp add: arccos_def) | 
| 3203 | apply (auto intro!: the1_equality cos_total) | |
| 3204 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3205 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3206 | lemma cos_arcsin: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> cos (arcsin x) = sqrt (1 - x\<^sup>2)" | 
| 53079 | 3207 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 3208 | apply (rule power2_eq_imp_eq) | |
| 3209 | apply (simp add: cos_squared_eq) | |
| 3210 | apply (rule cos_ge_zero) | |
| 3211 | apply (erule (1) arcsin_lbound) | |
| 3212 | apply (erule (1) arcsin_ubound) | |
| 3213 | apply simp | |
| 3214 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp) | |
| 3215 | apply (rule power_mono, simp, simp) | |
| 3216 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3217 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3218 | lemma sin_arccos: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> sin (arccos x) = sqrt (1 - x\<^sup>2)" | 
| 53079 | 3219 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 3220 | apply (rule power2_eq_imp_eq) | |
| 3221 | apply (simp add: sin_squared_eq) | |
| 3222 | apply (rule sin_ge_zero) | |
| 3223 | apply (erule (1) arccos_lbound) | |
| 3224 | apply (erule (1) arccos_ubound) | |
| 3225 | apply simp | |
| 3226 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp) | |
| 3227 | apply (rule power_mono, simp, simp) | |
| 3228 | done | |
| 3229 | ||
| 3230 | lemma arctan [simp]: "- (pi/2) < arctan y & arctan y < pi/2 & tan (arctan y) = y" | |
| 3231 | unfolding arctan_def by (rule theI' [OF tan_total]) | |
| 3232 | ||
| 3233 | lemma tan_arctan: "tan (arctan y) = y" | |
| 3234 | by auto | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3235 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3236 | lemma arctan_bounded: "- (pi/2) < arctan y & arctan y < pi/2" | 
| 53079 | 3237 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3238 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3239 | lemma arctan_lbound: "- (pi/2) < arctan y" | 
| 53079 | 3240 | by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3241 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3242 | lemma arctan_ubound: "arctan y < pi/2" | 
| 53079 | 3243 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3244 | |
| 44746 | 3245 | lemma arctan_unique: | 
| 53079 | 3246 | assumes "-(pi/2) < x" | 
| 3247 | and "x < pi/2" | |
| 3248 | and "tan x = y" | |
| 44746 | 3249 | shows "arctan y = x" | 
| 3250 | using assms arctan [of y] tan_total [of y] by (fast elim: ex1E) | |
| 3251 | ||
| 53079 | 3252 | lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x" | 
| 3253 | by (rule arctan_unique) simp_all | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3254 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3255 | lemma arctan_zero_zero [simp]: "arctan 0 = 0" | 
| 53079 | 3256 | by (rule arctan_unique) simp_all | 
| 44746 | 3257 | |
| 3258 | lemma arctan_minus: "arctan (- x) = - arctan x" | |
| 3259 | apply (rule arctan_unique) | |
| 3260 | apply (simp only: neg_less_iff_less arctan_ubound) | |
| 3261 | apply (metis minus_less_iff arctan_lbound) | |
| 3262 | apply simp | |
| 3263 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3264 | |
| 44725 | 3265 | lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0" | 
| 3266 | by (intro less_imp_neq [symmetric] cos_gt_zero_pi | |
| 3267 | arctan_lbound arctan_ubound) | |
| 3268 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3269 | lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)" | 
| 44725 | 3270 | proof (rule power2_eq_imp_eq) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3271 | have "0 < 1 + x\<^sup>2" by (simp add: add_pos_nonneg) | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3272 | show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp | 
| 44725 | 3273 | show "0 \<le> cos (arctan x)" | 
| 3274 | by (intro less_imp_le cos_gt_zero_pi arctan_lbound arctan_ubound) | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3275 | have "(cos (arctan x))\<^sup>2 * (1 + (tan (arctan x))\<^sup>2) = 1" | 
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 3276 | unfolding tan_def by (simp add: distrib_left power_divide) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3277 | thus "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2" | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3278 | using `0 < 1 + x\<^sup>2` by (simp add: power_divide eq_divide_eq) | 
| 44725 | 3279 | qed | 
| 3280 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3281 | lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)" | 
| 44725 | 3282 | using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]] | 
| 3283 | using tan_arctan [of x] unfolding tan_def cos_arctan | |
| 3284 | by (simp add: eq_divide_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3285 | |
| 53076 | 3286 | lemma tan_sec: "cos x \<noteq> 0 ==> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2" | 
| 53079 | 3287 | apply (rule power_inverse [THEN subst]) | 
| 3288 | apply (rule_tac c1 = "(cos x)\<^sup>2" in real_mult_right_cancel [THEN iffD1]) | |
| 3289 | apply (auto dest: field_power_not_zero | |
| 3290 | simp add: power_mult_distrib distrib_right power_divide tan_def | |
| 3291 | mult_assoc power_inverse [symmetric]) | |
| 3292 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3293 | |
| 44746 | 3294 | lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y" | 
| 3295 | by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan) | |
| 3296 | ||
| 3297 | lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y" | |
| 3298 | by (simp only: not_less [symmetric] arctan_less_iff) | |
| 3299 | ||
| 3300 | lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y" | |
| 3301 | by (simp only: eq_iff [where 'a=real] arctan_le_iff) | |
| 3302 | ||
| 3303 | lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x" | |
| 3304 | using arctan_less_iff [of 0 x] by simp | |
| 3305 | ||
| 3306 | lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0" | |
| 3307 | using arctan_less_iff [of x 0] by simp | |
| 3308 | ||
| 3309 | lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x" | |
| 3310 | using arctan_le_iff [of 0 x] by simp | |
| 3311 | ||
| 3312 | lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 3313 | using arctan_le_iff [of x 0] by simp | |
| 3314 | ||
| 3315 | lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0" | |
| 3316 | using arctan_eq_iff [of x 0] by simp | |
| 3317 | ||
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3318 | lemma continuous_on_arcsin': "continuous_on {-1 .. 1} arcsin"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3319 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3320 |   have "continuous_on (sin ` {- pi / 2 .. pi / 2}) arcsin"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3321 | by (rule continuous_on_inv) (auto intro: continuous_on_intros simp: arcsin_sin) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3322 |   also have "sin ` {- pi / 2 .. pi / 2} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3323 | proof safe | 
| 53079 | 3324 | fix x :: real | 
| 3325 |     assume "x \<in> {-1..1}"
 | |
| 3326 |     then show "x \<in> sin ` {- pi / 2..pi / 2}"
 | |
| 3327 | using arcsin_lbound arcsin_ubound | |
| 3328 | by (intro image_eqI[where x="arcsin x"]) auto | |
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3329 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3330 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3331 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3332 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3333 | lemma continuous_on_arcsin [continuous_on_intros]: | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3334 | "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. -1 \<le> f x \<and> f x \<le> 1) \<Longrightarrow> continuous_on s (\<lambda>x. arcsin (f x))" | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3335 | using continuous_on_compose[of s f, OF _ continuous_on_subset[OF continuous_on_arcsin']] | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3336 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3337 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3338 | lemma isCont_arcsin: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> isCont arcsin x" | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3339 |   using continuous_on_arcsin'[THEN continuous_on_subset, of "{ -1 <..< 1 }"]
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3340 | by (auto simp: continuous_on_eq_continuous_at subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3341 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3342 | lemma continuous_on_arccos': "continuous_on {-1 .. 1} arccos"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3343 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3344 |   have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3345 | by (rule continuous_on_inv) (auto intro: continuous_on_intros simp: arccos_cos) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3346 |   also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3347 | proof safe | 
| 53079 | 3348 | fix x :: real | 
| 3349 |     assume "x \<in> {-1..1}"
 | |
| 3350 |     then show "x \<in> cos ` {0..pi}"
 | |
| 3351 | using arccos_lbound arccos_ubound | |
| 3352 | by (intro image_eqI[where x="arccos x"]) auto | |
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3353 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3354 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3355 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3356 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3357 | lemma continuous_on_arccos [continuous_on_intros]: | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3358 | "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. -1 \<le> f x \<and> f x \<le> 1) \<Longrightarrow> continuous_on s (\<lambda>x. arccos (f x))" | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3359 | using continuous_on_compose[of s f, OF _ continuous_on_subset[OF continuous_on_arccos']] | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3360 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3361 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3362 | lemma isCont_arccos: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> isCont arccos x" | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3363 |   using continuous_on_arccos'[THEN continuous_on_subset, of "{ -1 <..< 1 }"]
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 3364 | by (auto simp: continuous_on_eq_continuous_at subset_eq) | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3365 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3366 | lemma isCont_arctan: "isCont arctan x" | 
| 53079 | 3367 | apply (rule arctan_lbound [of x, THEN dense, THEN exE], clarify) | 
| 3368 | apply (rule arctan_ubound [of x, THEN dense, THEN exE], clarify) | |
| 3369 | apply (subgoal_tac "isCont arctan (tan (arctan x))", simp) | |
| 3370 | apply (erule (1) isCont_inverse_function2 [where f=tan]) | |
| 3371 | apply (metis arctan_tan order_le_less_trans order_less_le_trans) | |
| 3372 | apply (metis cos_gt_zero_pi isCont_tan order_less_le_trans less_le) | |
| 3373 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3374 | |
| 51478 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3375 | lemma tendsto_arctan [tendsto_intros]: "(f ---> x) F \<Longrightarrow> ((\<lambda>x. arctan (f x)) ---> arctan x) F" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3376 | by (rule isCont_tendsto_compose [OF isCont_arctan]) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3377 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3378 | lemma continuous_arctan [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. arctan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3379 | unfolding continuous_def by (rule tendsto_arctan) | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3380 | |
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3381 | lemma continuous_on_arctan [continuous_on_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. arctan (f x))" | 
| 
270b21f3ae0a
move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
 hoelzl parents: 
51477diff
changeset | 3382 | unfolding continuous_on_def by (auto intro: tendsto_arctan) | 
| 53079 | 3383 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3384 | lemma DERIV_arcsin: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3385 | "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))" | 
| 53079 | 3386 | apply (rule DERIV_inverse_function [where f=sin and a="-1" and b="1"]) | 
| 3387 | apply (rule DERIV_cong [OF DERIV_sin]) | |
| 3388 | apply (simp add: cos_arcsin) | |
| 3389 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp) | |
| 3390 | apply (rule power_strict_mono, simp, simp, simp) | |
| 3391 | apply assumption | |
| 3392 | apply assumption | |
| 3393 | apply simp | |
| 3394 | apply (erule (1) isCont_arcsin) | |
| 3395 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3396 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3397 | lemma DERIV_arccos: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3398 | "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))" | 
| 53079 | 3399 | apply (rule DERIV_inverse_function [where f=cos and a="-1" and b="1"]) | 
| 3400 | apply (rule DERIV_cong [OF DERIV_cos]) | |
| 3401 | apply (simp add: sin_arccos) | |
| 3402 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp) | |
| 3403 | apply (rule power_strict_mono, simp, simp, simp) | |
| 3404 | apply assumption | |
| 3405 | apply assumption | |
| 3406 | apply simp | |
| 3407 | apply (erule (1) isCont_arccos) | |
| 3408 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3409 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3410 | lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)" | 
| 53079 | 3411 | apply (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"]) | 
| 3412 | apply (rule DERIV_cong [OF DERIV_tan]) | |
| 3413 | apply (rule cos_arctan_not_zero) | |
| 3414 | apply (simp add: power_inverse tan_sec [symmetric]) | |
| 3415 | apply (subgoal_tac "0 < 1 + x\<^sup>2", simp) | |
| 3416 | apply (simp add: add_pos_nonneg) | |
| 3417 | apply (simp, simp, simp, rule isCont_arctan) | |
| 3418 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 3419 | |
| 31880 | 3420 | declare | 
| 3421 | DERIV_arcsin[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | |
| 3422 | DERIV_arccos[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | |
| 3423 | DERIV_arctan[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] | |
| 3424 | ||
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3425 | lemma filterlim_tan_at_right: "filterlim tan at_bot (at_right (- pi/2))" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3426 | by (rule filterlim_at_bot_at_right[where Q="\<lambda>x. - pi/2 < x \<and> x < pi/2" and P="\<lambda>x. True" and g=arctan]) | 
| 51641 
cd05e9fcc63d
remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
 hoelzl parents: 
51527diff
changeset | 3427 | (auto simp: le_less eventually_at dist_real_def simp del: less_divide_eq_numeral1 | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3428 | intro!: tan_monotone exI[of _ "pi/2"]) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3429 | |
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3430 | lemma filterlim_tan_at_left: "filterlim tan at_top (at_left (pi/2))" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3431 | by (rule filterlim_at_top_at_left[where Q="\<lambda>x. - pi/2 < x \<and> x < pi/2" and P="\<lambda>x. True" and g=arctan]) | 
| 51641 
cd05e9fcc63d
remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
 hoelzl parents: 
51527diff
changeset | 3432 | (auto simp: le_less eventually_at dist_real_def simp del: less_divide_eq_numeral1 | 
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3433 | intro!: tan_monotone exI[of _ "pi/2"]) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3434 | |
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3435 | lemma tendsto_arctan_at_top: "(arctan ---> (pi/2)) at_top" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3436 | proof (rule tendstoI) | 
| 53079 | 3437 | fix e :: real | 
| 3438 | assume "0 < e" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3439 | def y \<equiv> "pi/2 - min (pi/2) e" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3440 | then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3441 | using `0 < e` by auto | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3442 | |
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3443 | show "eventually (\<lambda>x. dist (arctan x) (pi / 2) < e) at_top" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3444 | proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI) | 
| 53079 | 3445 | fix x | 
| 3446 | assume "tan y < x" | |
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3447 | then have "arctan (tan y) < arctan x" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3448 | by (simp add: arctan_less_iff) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3449 | with y have "y < arctan x" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3450 | by (subst (asm) arctan_tan) simp_all | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3451 | with arctan_ubound[of x, arith] y `0 < e` | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3452 | show "dist (arctan x) (pi / 2) < e" | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3453 | by (simp add: dist_real_def) | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3454 | qed | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3455 | qed | 
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3456 | |
| 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3457 | lemma tendsto_arctan_at_bot: "(arctan ---> - (pi/2)) at_bot" | 
| 53079 | 3458 | unfolding filterlim_at_bot_mirror arctan_minus | 
| 3459 | by (intro tendsto_minus tendsto_arctan_at_top) | |
| 3460 | ||
| 50346 
a75c6429c3c3
add filterlim rules for eventually monotone bijective functions; mirror rules for at_top, at_bot; apply them to prove convergence of arctan at infinity and tan at pi/2
 hoelzl parents: 
50326diff
changeset | 3461 | |
| 23043 | 3462 | subsection {* More Theorems about Sin and Cos *}
 | 
| 3463 | ||
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3464 | lemma cos_45: "cos (pi / 4) = sqrt 2 / 2" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3465 | proof - | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3466 | let ?c = "cos (pi / 4)" and ?s = "sin (pi / 4)" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3467 | have nonneg: "0 \<le> ?c" | 
| 45308 
2e84e5f0463b
extend cancellation simproc patterns to cover terms like '- (2 * pi) < pi'
 huffman parents: 
44756diff
changeset | 3468 | by (simp add: cos_ge_zero) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3469 | have "0 = cos (pi / 4 + pi / 4)" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3470 | by simp | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3471 | also have "cos (pi / 4 + pi / 4) = ?c\<^sup>2 - ?s\<^sup>2" | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3472 | by (simp only: cos_add power2_eq_square) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3473 | also have "\<dots> = 2 * ?c\<^sup>2 - 1" | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3474 | by (simp add: sin_squared_eq) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3475 | finally have "?c\<^sup>2 = (sqrt 2 / 2)\<^sup>2" | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3476 | by (simp add: power_divide) | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3477 | thus ?thesis | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3478 | using nonneg by (rule power2_eq_imp_eq) simp | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3479 | qed | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3480 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3481 | lemma cos_30: "cos (pi / 6) = sqrt 3 / 2" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3482 | proof - | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3483 | let ?c = "cos (pi / 6)" and ?s = "sin (pi / 6)" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3484 | have pos_c: "0 < ?c" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3485 | by (rule cos_gt_zero, simp, simp) | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3486 | have "0 = cos (pi / 6 + pi / 6 + pi / 6)" | 
| 23066 
26a9157b620a
new field_combine_numerals simproc, which uses fractions as coefficients
 huffman parents: 
23053diff
changeset | 3487 | by simp | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3488 | also have "\<dots> = (?c * ?c - ?s * ?s) * ?c - (?s * ?c + ?c * ?s) * ?s" | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3489 | by (simp only: cos_add sin_add) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3490 | also have "\<dots> = ?c * (?c\<^sup>2 - 3 * ?s\<^sup>2)" | 
| 29667 | 3491 | by (simp add: algebra_simps power2_eq_square) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 3492 | finally have "?c\<^sup>2 = (sqrt 3 / 2)\<^sup>2" | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3493 | using pos_c by (simp add: sin_squared_eq power_divide) | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3494 | thus ?thesis | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3495 | using pos_c [THEN order_less_imp_le] | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3496 | by (rule power2_eq_imp_eq) simp | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3497 | qed | 
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3498 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3499 | lemma sin_45: "sin (pi / 4) = sqrt 2 / 2" | 
| 53079 | 3500 | by (simp add: sin_cos_eq cos_45) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3501 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3502 | lemma sin_60: "sin (pi / 3) = sqrt 3 / 2" | 
| 53079 | 3503 | by (simp add: sin_cos_eq cos_30) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3504 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3505 | lemma cos_60: "cos (pi / 3) = 1 / 2" | 
| 53079 | 3506 | apply (rule power2_eq_imp_eq) | 
| 3507 | apply (simp add: cos_squared_eq sin_60 power_divide) | |
| 3508 | apply (rule cos_ge_zero, rule order_trans [where y=0], simp_all) | |
| 3509 | done | |
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3510 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3511 | lemma sin_30: "sin (pi / 6) = 1 / 2" | 
| 53079 | 3512 | by (simp add: sin_cos_eq cos_60) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3513 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3514 | lemma tan_30: "tan (pi / 6) = 1 / sqrt 3" | 
| 53079 | 3515 | unfolding tan_def by (simp add: sin_30 cos_30) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3516 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3517 | lemma tan_45: "tan (pi / 4) = 1" | 
| 53079 | 3518 | unfolding tan_def by (simp add: sin_45 cos_45) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3519 | |
| 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3520 | lemma tan_60: "tan (pi / 3) = sqrt 3" | 
| 53079 | 3521 | unfolding tan_def by (simp add: sin_60 cos_60) | 
| 23052 
0e36f0dbfa1c
add lemmas for sin,cos,tan of 30,45,60 degrees; cleaned up
 huffman parents: 
23049diff
changeset | 3522 | |
| 15383 | 3523 | lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n" | 
| 3524 | proof - | |
| 3525 | have "sin ((real n + 1/2) * pi) = cos (real n * pi)" | |
| 29667 | 3526 | by (auto simp add: algebra_simps sin_add) | 
| 15383 | 3527 | thus ?thesis | 
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 3528 | by (simp add: real_of_nat_Suc distrib_right add_divide_distrib | 
| 15383 | 3529 | mult_commute [of pi]) | 
| 3530 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3531 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3532 | lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1" | 
| 53079 | 3533 | by (simp add: cos_double mult_assoc power_add [symmetric] numeral_2_eq_2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3534 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3535 | lemma cos_3over2_pi [simp]: "cos (3 / 2 * pi) = 0" | 
| 53079 | 3536 | apply (subgoal_tac "cos (pi + pi/2) = 0", simp) | 
| 3537 | apply (subst cos_add, simp) | |
| 3538 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3539 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3540 | lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0" | 
| 53079 | 3541 | by (auto simp add: mult_assoc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3542 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3543 | lemma sin_3over2_pi [simp]: "sin (3 / 2 * pi) = - 1" | 
| 53079 | 3544 | apply (subgoal_tac "sin (pi + pi/2) = - 1", simp) | 
| 3545 | apply (subst sin_add, simp) | |
| 3546 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3547 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3548 | lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" | 
| 53079 | 3549 | apply (simp only: cos_add sin_add real_of_nat_Suc distrib_right distrib_left add_divide_distrib) | 
| 3550 | apply auto | |
| 3551 | done | |
| 3552 | ||
| 3553 | lemma DERIV_cos_add [simp]: "DERIV (\<lambda>x. cos (x + k)) xa :> - sin (xa + k)" | |
| 31881 | 3554 | by (auto intro!: DERIV_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3555 | |
| 15081 | 3556 | lemma sin_zero_abs_cos_one: "sin x = 0 ==> \<bar>cos x\<bar> = 1" | 
| 53079 | 3557 | by (auto simp add: sin_zero_iff even_mult_two_ex) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3558 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3559 | lemma cos_one_sin_zero: "cos x = 1 ==> sin x = 0" | 
| 53079 | 3560 | using sin_cos_squared_add3 [where x = x] by auto | 
| 3561 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3562 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3563 | subsection {* Machins formula *}
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3564 | |
| 44746 | 3565 | lemma arctan_one: "arctan 1 = pi / 4" | 
| 3566 | by (rule arctan_unique, simp_all add: tan_45 m2pi_less_pi) | |
| 3567 | ||
| 53079 | 3568 | lemma tan_total_pi4: | 
| 3569 | assumes "\<bar>x\<bar> < 1" | |
| 3570 | shows "\<exists>z. - (pi / 4) < z \<and> z < pi / 4 \<and> tan z = x" | |
| 44746 | 3571 | proof | 
| 3572 | show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x" | |
| 3573 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 3574 | unfolding arctan_less_iff using assms by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3575 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3576 | |
| 53079 | 3577 | lemma arctan_add: | 
| 3578 | assumes "\<bar>x\<bar> \<le> 1" and "\<bar>y\<bar> < 1" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3579 | shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))" | 
| 44746 | 3580 | proof (rule arctan_unique [symmetric]) | 
| 3581 | have "- (pi / 4) \<le> arctan x" and "- (pi / 4) < arctan y" | |
| 3582 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 3583 | unfolding arctan_le_iff arctan_less_iff using assms by auto | |
| 3584 | from add_le_less_mono [OF this] | |
| 3585 | show 1: "- (pi / 2) < arctan x + arctan y" by simp | |
| 3586 | have "arctan x \<le> pi / 4" and "arctan y < pi / 4" | |
| 3587 | unfolding arctan_one [symmetric] | |
| 3588 | unfolding arctan_le_iff arctan_less_iff using assms by auto | |
| 3589 | from add_le_less_mono [OF this] | |
| 3590 | show 2: "arctan x + arctan y < pi / 2" by simp | |
| 3591 | show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)" | |
| 3592 | using cos_gt_zero_pi [OF 1 2] by (simp add: tan_add) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3593 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3594 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3595 | theorem machin: "pi / 4 = 4 * arctan (1/5) - arctan (1 / 239)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3596 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3597 | have "\<bar>1 / 5\<bar> < (1 :: real)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3598 | from arctan_add[OF less_imp_le[OF this] this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3599 | have "2 * arctan (1 / 5) = arctan (5 / 12)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3600 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3601 | have "\<bar>5 / 12\<bar> < (1 :: real)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3602 | from arctan_add[OF less_imp_le[OF this] this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3603 | have "2 * arctan (5 / 12) = arctan (120 / 119)" by auto | 
| 41970 | 3604 | moreover | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3605 | have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3606 | from arctan_add[OF this] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3607 | have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3608 | ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)" by auto | 
| 44746 | 3609 | thus ?thesis unfolding arctan_one by algebra | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3610 | qed | 
| 44746 | 3611 | |
| 53079 | 3612 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3613 | subsection {* Introducing the arcus tangens power series *}
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3614 | |
| 53079 | 3615 | lemma monoseq_arctan_series: | 
| 3616 | fixes x :: real | |
| 3617 | assumes "\<bar>x\<bar> \<le> 1" | |
| 3618 | shows "monoseq (\<lambda> n. 1 / real (n*2+1) * x^(n*2+1))" (is "monoseq ?a") | |
| 3619 | proof (cases "x = 0") | |
| 3620 | case True | |
| 3621 | thus ?thesis unfolding monoseq_def One_nat_def by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3622 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3623 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3624 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" using assms by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3625 | show "monoseq ?a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3626 | proof - | 
| 53079 | 3627 |     {
 | 
| 3628 | fix n | |
| 3629 | fix x :: real | |
| 3630 | assume "0 \<le> x" and "x \<le> 1" | |
| 3631 | have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le> | |
| 3632 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3633 | proof (rule mult_mono) | 
| 53079 | 3634 | show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))" | 
| 3635 | by (rule frac_le) simp_all | |
| 3636 | show "0 \<le> 1 / real (Suc (n * 2))" | |
| 3637 | by auto | |
| 3638 | show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)" | |
| 3639 | by (rule power_decreasing) (simp_all add: `0 \<le> x` `x \<le> 1`) | |
| 3640 | show "0 \<le> x ^ Suc (Suc n * 2)" | |
| 3641 | by (rule zero_le_power) (simp add: `0 \<le> x`) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3642 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3643 | } note mono = this | 
| 41970 | 3644 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3645 | show ?thesis | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3646 | proof (cases "0 \<le> x") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3647 | case True from mono[OF this `x \<le> 1`, THEN allI] | 
| 53079 | 3648 | show ?thesis unfolding Suc_eq_plus1[symmetric] | 
| 3649 | by (rule mono_SucI2) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3650 | next | 
| 53079 | 3651 | case False | 
| 3652 | hence "0 \<le> -x" and "-x \<le> 1" using `-1 \<le> x` by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3653 | from mono[OF this] | 
| 53079 | 3654 | have "\<And>n. 1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge> | 
| 3655 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" using `0 \<le> -x` by auto | |
| 31790 | 3656 | thus ?thesis unfolding Suc_eq_plus1[symmetric] by (rule mono_SucI1[OF allI]) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3657 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3658 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3659 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3660 | |
| 53079 | 3661 | lemma zeroseq_arctan_series: | 
| 3662 | fixes x :: real | |
| 3663 | assumes "\<bar>x\<bar> \<le> 1" | |
| 3664 | shows "(\<lambda> n. 1 / real (n*2+1) * x^(n*2+1)) ----> 0" (is "?a ----> 0") | |
| 3665 | proof (cases "x = 0") | |
| 3666 | case True | |
| 3667 | thus ?thesis | |
| 3668 | unfolding One_nat_def by (auto simp add: tendsto_const) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3669 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3670 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3671 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" using assms by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3672 | show "?a ----> 0" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3673 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 3674 | case True | 
| 3675 | hence "norm x < 1" by auto | |
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 3676 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF `norm x < 1`, THEN LIMSEQ_Suc]] | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 3677 | have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) ----> 0" | 
| 31790 | 3678 | unfolding inverse_eq_divide Suc_eq_plus1 by simp | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 3679 | then show ?thesis using pos2 by (rule LIMSEQ_linear) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3680 | next | 
| 53079 | 3681 | case False | 
| 3682 | hence "x = -1 \<or> x = 1" using `\<bar>x\<bar> \<le> 1` by auto | |
| 3683 | hence n_eq: "\<And> n. x ^ (n * 2 + 1) = x" | |
| 3684 | unfolding One_nat_def by auto | |
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 3685 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]] | 
| 31790 | 3686 | show ?thesis unfolding n_eq Suc_eq_plus1 by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3687 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3688 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3689 | |
| 53079 | 3690 | lemma summable_arctan_series: | 
| 3691 | fixes x :: real and n :: nat | |
| 3692 | assumes "\<bar>x\<bar> \<le> 1" | |
| 3693 | shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 3694 | (is "summable (?c x)") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3695 | by (rule summable_Leibniz(1), rule zeroseq_arctan_series[OF assms], rule monoseq_arctan_series[OF assms]) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3696 | |
| 53079 | 3697 | lemma less_one_imp_sqr_less_one: | 
| 3698 | fixes x :: real | |
| 3699 | assumes "\<bar>x\<bar> < 1" | |
| 3700 | shows "x\<^sup>2 < 1" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3701 | proof - | 
| 38642 
8fa437809c67
dropped type classes mult_mono and mult_mono1; tuned names of technical rule duplicates
 haftmann parents: 
37887diff
changeset | 3702 | from mult_left_mono[OF less_imp_le[OF `\<bar>x\<bar> < 1`] abs_ge_zero[of x]] | 
| 53076 | 3703 | have "\<bar>x\<^sup>2\<bar> < 1" using `\<bar>x\<bar> < 1` unfolding numeral_2_eq_2 power_Suc2 by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3704 | thus ?thesis using zero_le_power2 by auto | 
| 41970 | 3705 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3706 | |
| 53079 | 3707 | lemma DERIV_arctan_series: | 
| 3708 | assumes "\<bar> x \<bar> < 1" | |
| 3709 | shows "DERIV (\<lambda> x'. \<Sum> k. (-1)^k * (1 / real (k*2+1) * x' ^ (k*2+1))) x :> (\<Sum> k. (-1)^k * x^(k*2))" | |
| 3710 | (is "DERIV ?arctan _ :> ?Int") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3711 | proof - | 
| 53079 | 3712 | let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0" | 
| 3713 | ||
| 3714 | have n_even: "\<And>n :: nat. even n \<Longrightarrow> 2 * (n div 2) = n" | |
| 3715 | by presburger | |
| 3716 | then have if_eq: "\<And>n x'. ?f n * real (Suc n) * x'^n = | |
| 3717 | (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)" | |
| 3718 | by auto | |
| 3719 | ||
| 3720 |   {
 | |
| 3721 | fix x :: real | |
| 3722 | assume "\<bar>x\<bar> < 1" | |
| 3723 | hence "x\<^sup>2 < 1" by (rule less_one_imp_sqr_less_one) | |
| 53076 | 3724 | have "summable (\<lambda> n. -1 ^ n * (x\<^sup>2) ^n)" | 
| 3725 | by (rule summable_Leibniz(1), auto intro!: LIMSEQ_realpow_zero monoseq_realpow `x\<^sup>2 < 1` order_less_imp_le[OF `x\<^sup>2 < 1`]) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3726 | hence "summable (\<lambda> n. -1 ^ n * x^(2*n))" unfolding power_mult . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3727 | } note summable_Integral = this | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3728 | |
| 53079 | 3729 |   {
 | 
| 3730 | fix f :: "nat \<Rightarrow> real" | |
| 3731 | have "\<And>x. f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3732 | proof | 
| 53079 | 3733 | fix x :: real | 
| 3734 | assume "f sums x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3735 | from sums_if[OF sums_zero this] | 
| 53079 | 3736 | show "(\<lambda>n. if even n then f (n div 2) else 0) sums x" | 
| 3737 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3738 | next | 
| 53079 | 3739 | fix x :: real | 
| 3740 | assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3741 | from LIMSEQ_linear[OF this[unfolded sums_def] pos2, unfolded sum_split_even_odd[unfolded mult_commute]] | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3742 | show "f sums x" unfolding sums_def by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3743 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3744 | hence "op sums f = op sums (\<lambda> n. if even n then f (n div 2) else 0)" .. | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3745 | } note sums_even = this | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3746 | |
| 53079 | 3747 | have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int" | 
| 3748 | unfolding if_eq mult_commute[of _ 2] suminf_def sums_even[of "\<lambda> n. -1 ^ n * x ^ (2 * n)", symmetric] | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3749 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3750 | |
| 53079 | 3751 |   {
 | 
| 3752 | fix x :: real | |
| 3753 | have if_eq': "\<And>n. (if even n then -1 ^ (n div 2) * 1 / real (Suc n) else 0) * x ^ Suc n = | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3754 | (if even n then -1 ^ (n div 2) * (1 / real (Suc (2 * (n div 2))) * x ^ Suc (2 * (n div 2))) else 0)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3755 | using n_even by auto | 
| 53079 | 3756 | have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" by auto | 
| 3757 | have "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" | |
| 3758 | unfolding if_eq' idx_eq suminf_def sums_even[of "\<lambda> n. -1 ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric] | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3759 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3760 | } note arctan_eq = this | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3761 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3762 | have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum> n. ?f n * real (Suc n) * x^n)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3763 | proof (rule DERIV_power_series') | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3764 |     show "x \<in> {- 1 <..< 1}" using `\<bar> x \<bar> < 1` by auto
 | 
| 53079 | 3765 |     {
 | 
| 3766 | fix x' :: real | |
| 3767 |       assume x'_bounds: "x' \<in> {- 1 <..< 1}"
 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3768 | hence "\<bar>x'\<bar> < 1" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3769 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3770 | let ?S = "\<Sum> n. (-1)^n * x'^(2 * n)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3771 | show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" unfolding if_eq | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3772 | by (rule sums_summable[where l="0 + ?S"], rule sums_if, rule sums_zero, rule summable_sums, rule summable_Integral[OF `\<bar>x'\<bar> < 1`]) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3773 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3774 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3775 | thus ?thesis unfolding Int_eq arctan_eq . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3776 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3777 | |
| 53079 | 3778 | lemma arctan_series: | 
| 3779 | assumes "\<bar> x \<bar> \<le> 1" | |
| 3780 | shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 3781 | (is "_ = suminf (\<lambda> n. ?c x n)") | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3782 | proof - | 
| 53079 | 3783 | let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)" | 
| 3784 | ||
| 3785 |   {
 | |
| 3786 | fix r x :: real | |
| 3787 | assume "0 < r" and "r < 1" and "\<bar> x \<bar> < r" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3788 | have "\<bar>x\<bar> < 1" using `r < 1` and `\<bar>x\<bar> < r` by auto | 
| 53079 | 3789 | from DERIV_arctan_series[OF this] have "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))" . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3790 | } note DERIV_arctan_suminf = this | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3791 | |
| 53079 | 3792 |   {
 | 
| 3793 | fix x :: real | |
| 3794 | assume "\<bar>x\<bar> \<le> 1" | |
| 3795 | note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]] | |
| 3796 | } note arctan_series_borders = this | |
| 3797 | ||
| 3798 |   {
 | |
| 3799 | fix x :: real | |
| 3800 | assume "\<bar>x\<bar> < 1" | |
| 3801 | have "arctan x = (\<Sum>k. ?c x k)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3802 | proof - | 
| 53079 | 3803 | obtain r where "\<bar>x\<bar> < r" and "r < 1" | 
| 3804 | using dense[OF `\<bar>x\<bar> < 1`] by blast | |
| 3805 | hence "0 < r" and "-r < x" and "x < r" by auto | |
| 3806 | ||
| 3807 | have suminf_eq_arctan_bounded: "\<And>x a b. \<lbrakk> -r < a ; b < r ; a < b ; a \<le> x ; x \<le> b \<rbrakk> \<Longrightarrow> | |
| 3808 | suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 3809 | proof - | |
| 3810 | fix x a b | |
| 3811 | assume "-r < a" and "b < r" and "a < b" and "a \<le> x" and "x \<le> b" | |
| 3812 | hence "\<bar>x\<bar> < r" by auto | |
| 3813 | show "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 3814 | proof (rule DERIV_isconst2[of "a" "b"]) | |
| 3815 | show "a < b" and "a \<le> x" and "x \<le> b" | |
| 3816 | using `a < b` `a \<le> x` `x \<le> b` by auto | |
| 3817 | have "\<forall>x. -r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | |
| 3818 | proof (rule allI, rule impI) | |
| 3819 | fix x | |
| 3820 | assume "-r < x \<and> x < r" | |
| 3821 | hence "\<bar>x\<bar> < r" by auto | |
| 3822 | hence "\<bar>x\<bar> < 1" using `r < 1` by auto | |
| 3823 | have "\<bar> - (x\<^sup>2) \<bar> < 1" | |
| 3824 | using less_one_imp_sqr_less_one[OF `\<bar>x\<bar> < 1`] by auto | |
| 3825 | hence "(\<lambda> n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 3826 | unfolding real_norm_def[symmetric] by (rule geometric_sums) | |
| 3827 | hence "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 3828 | unfolding power_mult_distrib[symmetric] power_mult nat_mult_commute[of _ 2] by auto | |
| 3829 | hence suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)" | |
| 3830 | using sums_unique unfolding inverse_eq_divide by auto | |
| 3831 | have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))" | |
| 3832 | unfolding suminf_c'_eq_geom | |
| 3833 | by (rule DERIV_arctan_suminf[OF `0 < r` `r < 1` `\<bar>x\<bar> < r`]) | |
| 3834 | from DERIV_add_minus[OF this DERIV_arctan] | |
| 3835 | show "DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 3836 | by auto | 
| 53079 | 3837 | qed | 
| 3838 | hence DERIV_in_rball: "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0" | |
| 3839 | using `-r < a` `b < r` by auto | |
| 3840 | thus "\<forall> y. a < y \<and> y < b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0" | |
| 3841 | using `\<bar>x\<bar> < r` by auto | |
| 3842 | show "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> isCont (\<lambda> x. suminf (?c x) - arctan x) y" | |
| 3843 | using DERIV_in_rball DERIV_isCont by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3844 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3845 | qed | 
| 53079 | 3846 | |
| 3847 | have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0" | |
| 3848 | unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero | |
| 3849 | by auto | |
| 3850 | ||
| 3851 | have "suminf (?c x) - arctan x = 0" | |
| 3852 | proof (cases "x = 0") | |
| 3853 | case True | |
| 3854 | thus ?thesis using suminf_arctan_zero by auto | |
| 3855 | next | |
| 3856 | case False | |
| 3857 | hence "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" by auto | |
| 3858 | have "suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>) = suminf (?c 0) - arctan 0" | |
| 3859 | by (rule suminf_eq_arctan_bounded[where x="0" and a="-\<bar>x\<bar>" and b="\<bar>x\<bar>", symmetric]) | |
| 3860 | (simp_all only: `\<bar>x\<bar> < r` `-\<bar>x\<bar> < \<bar>x\<bar>` neg_less_iff_less) | |
| 3861 | moreover | |
| 3862 | have "suminf (?c x) - arctan x = suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>)" | |
| 3863 | by (rule suminf_eq_arctan_bounded[where x="x" and a="-\<bar>x\<bar>" and b="\<bar>x\<bar>"]) | |
| 3864 | (simp_all only: `\<bar>x\<bar> < r` `-\<bar>x\<bar> < \<bar>x\<bar>` neg_less_iff_less) | |
| 3865 | ultimately | |
| 3866 | show ?thesis using suminf_arctan_zero by auto | |
| 3867 | qed | |
| 3868 | thus ?thesis by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3869 | qed | 
| 53079 | 3870 | } note when_less_one = this | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3871 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3872 | show "arctan x = suminf (\<lambda> n. ?c x n)" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3873 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 3874 | case True | 
| 3875 | thus ?thesis by (rule when_less_one) | |
| 3876 | next | |
| 3877 | case False | |
| 3878 | hence "\<bar>x\<bar> = 1" using `\<bar>x\<bar> \<le> 1` by auto | |
| 3879 | let ?a = "\<lambda>x n. \<bar>1 / real (n*2+1) * x^(n*2+1)\<bar>" | |
| 3880 | let ?diff = "\<lambda> x n. \<bar> arctan x - (\<Sum> i = 0..<n. ?c x i)\<bar>" | |
| 3881 |     {
 | |
| 3882 | fix n :: nat | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3883 | have "0 < (1 :: real)" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3884 | moreover | 
| 53079 | 3885 |       {
 | 
| 3886 | fix x :: real | |
| 3887 | assume "0 < x" and "x < 1" | |
| 3888 | hence "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" by auto | |
| 3889 | from `0 < x` have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)" | |
| 3890 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3891 | note bounds = mp[OF arctan_series_borders(2)[OF `\<bar>x\<bar> \<le> 1`] this, unfolded when_less_one[OF `\<bar>x\<bar> < 1`, symmetric], THEN spec] | 
| 53079 | 3892 | have "0 < 1 / real (n*2+1) * x^(n*2+1)" | 
| 3893 | by (rule mult_pos_pos, auto simp only: zero_less_power[OF `0 < x`], auto) | |
| 3894 | hence a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)" | |
| 3895 | by (rule abs_of_pos) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3896 | have "?diff x n \<le> ?a x n" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3897 | proof (cases "even n") | 
| 53079 | 3898 | case True | 
| 3899 | hence sgn_pos: "(-1)^n = (1::real)" by auto | |
| 3900 | from `even n` obtain m where "2 * m = n" | |
| 3901 | unfolding even_mult_two_ex by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3902 | from bounds[of m, unfolded this atLeastAtMost_iff] | 
| 53079 | 3903 | have "\<bar>arctan x - (\<Sum>i = 0..<n. (?c x i))\<bar> \<le> (\<Sum>i = 0..<n + 1. (?c x i)) - (\<Sum>i = 0..<n. (?c x i))" | 
| 3904 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3905 | also have "\<dots> = ?c x n" unfolding One_nat_def by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3906 | also have "\<dots> = ?a x n" unfolding sgn_pos a_pos by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3907 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3908 | next | 
| 53079 | 3909 | case False | 
| 3910 | hence sgn_neg: "(-1)^n = (-1::real)" by auto | |
| 3911 | from `odd n` obtain m where m_def: "2 * m + 1 = n" | |
| 3912 | unfolding odd_Suc_mult_two_ex by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3913 | hence m_plus: "2 * (m + 1) = n + 1" by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3914 | from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2] | 
| 53079 | 3915 | have "\<bar>arctan x - (\<Sum>i = 0..<n. (?c x i))\<bar> \<le> (\<Sum>i = 0..<n. (?c x i)) - (\<Sum>i = 0..<n+1. (?c x i))" | 
| 3916 | by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3917 | also have "\<dots> = - ?c x n" unfolding One_nat_def by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3918 | also have "\<dots> = ?a x n" unfolding sgn_neg a_pos by auto | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3919 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 3920 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3921 | hence "0 \<le> ?a x n - ?diff x n" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3922 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3923 |       hence "\<forall> x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
 | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3924 | moreover have "\<And>x. isCont (\<lambda> x. ?a x n - ?diff x n) x" | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 3925 | unfolding diff_conv_add_uminus divide_inverse | 
| 53079 | 3926 | by (auto intro!: isCont_add isCont_rabs isCont_ident isCont_minus isCont_arctan | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 3927 | isCont_inverse isCont_mult isCont_power isCont_const isCont_setsum | 
| 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 3928 | simp del: add_uminus_conv_diff) | 
| 53079 | 3929 | ultimately have "0 \<le> ?a 1 n - ?diff 1 n" | 
| 3930 | by (rule LIM_less_bound) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3931 | hence "?diff 1 n \<le> ?a 1 n" by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3932 | } | 
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 3933 | have "?a 1 ----> 0" | 
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 3934 | unfolding tendsto_rabs_zero_iff power_one divide_inverse One_nat_def | 
| 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 3935 | by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3936 | have "?diff 1 ----> 0" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3937 | proof (rule LIMSEQ_I) | 
| 53079 | 3938 | fix r :: real | 
| 3939 | assume "0 < r" | |
| 3940 | obtain N :: nat where N_I: "\<And>n. N \<le> n \<Longrightarrow> ?a 1 n < r" | |
| 3941 | using LIMSEQ_D[OF `?a 1 ----> 0` `0 < r`] by auto | |
| 3942 |       {
 | |
| 3943 | fix n | |
| 3944 | assume "N \<le> n" from `?diff 1 n \<le> ?a 1 n` N_I[OF this] | |
| 3945 | have "norm (?diff 1 n - 0) < r" by auto | |
| 3946 | } | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3947 | thus "\<exists> N. \<forall> n \<ge> N. norm (?diff 1 n - 0) < r" by blast | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3948 | qed | 
| 44710 | 3949 | from this [unfolded tendsto_rabs_zero_iff, THEN tendsto_add [OF _ tendsto_const], of "- arctan 1", THEN tendsto_minus] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3950 | have "(?c 1) sums (arctan 1)" unfolding sums_def by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3951 | hence "arctan 1 = (\<Sum> i. ?c 1 i)" by (rule sums_unique) | 
| 41970 | 3952 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3953 | show ?thesis | 
| 53079 | 3954 | proof (cases "x = 1") | 
| 3955 | case True | |
| 3956 | then show ?thesis by (simp add: `arctan 1 = (\<Sum> i. ?c 1 i)`) | |
| 3957 | next | |
| 3958 | case False | |
| 3959 | hence "x = -1" using `\<bar>x\<bar> = 1` by auto | |
| 41970 | 3960 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3961 | have "- (pi / 2) < 0" using pi_gt_zero by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3962 | have "- (2 * pi) < 0" using pi_gt_zero by auto | 
| 41970 | 3963 | |
| 53079 | 3964 | have c_minus_minus: "\<And>i. ?c (- 1) i = - ?c 1 i" | 
| 3965 | unfolding One_nat_def by auto | |
| 3966 | ||
| 3967 | have "arctan (- 1) = arctan (tan (-(pi / 4)))" | |
| 3968 | unfolding tan_45 tan_minus .. | |
| 3969 | also have "\<dots> = - (pi / 4)" | |
| 3970 | by (rule arctan_tan, auto simp add: order_less_trans[OF `- (pi / 2) < 0` pi_gt_zero]) | |
| 3971 | also have "\<dots> = - (arctan (tan (pi / 4)))" | |
| 3972 | unfolding neg_equal_iff_equal by (rule arctan_tan[symmetric], auto simp add: order_less_trans[OF `- (2 * pi) < 0` pi_gt_zero]) | |
| 3973 | also have "\<dots> = - (arctan 1)" | |
| 3974 | unfolding tan_45 .. | |
| 3975 | also have "\<dots> = - (\<Sum> i. ?c 1 i)" | |
| 3976 | using `arctan 1 = (\<Sum> i. ?c 1 i)` by auto | |
| 3977 | also have "\<dots> = (\<Sum> i. ?c (- 1) i)" | |
| 3978 | using suminf_minus[OF sums_summable[OF `(?c 1) sums (arctan 1)`]] | |
| 3979 | unfolding c_minus_minus by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3980 | finally show ?thesis using `x = -1` by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3981 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3982 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3983 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3984 | |
| 53079 | 3985 | lemma arctan_half: | 
| 3986 | fixes x :: real | |
| 53076 | 3987 | shows "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3988 | proof - | 
| 53079 | 3989 | obtain y where low: "- (pi / 2) < y" and high: "y < pi / 2" and y_eq: "tan y = x" | 
| 3990 | using tan_total by blast | |
| 3991 | hence low2: "- (pi / 2) < y / 2" and high2: "y / 2 < pi / 2" | |
| 3992 | by auto | |
| 3993 | ||
| 3994 | have divide_nonzero_divide: "\<And>A B C :: real. C \<noteq> 0 \<Longrightarrow> A / B = (A / C) / (B / C)" | |
| 3995 | by auto | |
| 41970 | 3996 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3997 | have "0 < cos y" using cos_gt_zero_pi[OF low high] . | 
| 53079 | 3998 | hence "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y" | 
| 3999 | by auto | |
| 4000 | ||
| 4001 | have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 4002 | unfolding tan_def power_divide .. | |
| 4003 | also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 4004 | using `cos y \<noteq> 0` by auto | |
| 4005 | also have "\<dots> = 1 / (cos y)\<^sup>2" | |
| 4006 | unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 .. | |
| 53076 | 4007 | finally have "1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2" . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4008 | |
| 53079 | 4009 | have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)" | 
| 4010 | unfolding tan_def divide_nonzero_divide[OF `cos y \<noteq> 0`, symmetric] .. | |
| 4011 | also have "\<dots> = tan y / (1 + 1 / cos y)" | |
| 4012 | using `cos y \<noteq> 0` unfolding add_divide_distrib by auto | |
| 4013 | also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))" | |
| 4014 | unfolding cos_sqrt .. | |
| 4015 | also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))" | |
| 4016 | unfolding real_sqrt_divide by auto | |
| 4017 | finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))" | |
| 4018 | unfolding `1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2` . | |
| 4019 | ||
| 4020 | have "arctan x = y" | |
| 4021 | using arctan_tan low high y_eq by auto | |
| 4022 | also have "\<dots> = 2 * (arctan (tan (y/2)))" | |
| 4023 | using arctan_tan[OF low2 high2] by auto | |
| 4024 | also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))" | |
| 4025 | unfolding tan_half by auto | |
| 4026 | finally show ?thesis | |
| 4027 | unfolding eq `tan y = x` . | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4028 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4029 | |
| 53079 | 4030 | lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y" | 
| 4031 | by (simp only: arctan_less_iff) | |
| 4032 | ||
| 4033 | lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y" | |
| 4034 | by (simp only: arctan_le_iff) | |
| 44746 | 4035 | |
| 4036 | lemma arctan_inverse: | |
| 53079 | 4037 | assumes "x \<noteq> 0" | 
| 4038 | shows "arctan (1 / x) = sgn x * pi / 2 - arctan x" | |
| 44746 | 4039 | proof (rule arctan_unique) | 
| 4040 | show "- (pi / 2) < sgn x * pi / 2 - arctan x" | |
| 4041 | using arctan_bounded [of x] assms | |
| 4042 | unfolding sgn_real_def | |
| 4043 | apply (auto simp add: algebra_simps) | |
| 4044 | apply (drule zero_less_arctan_iff [THEN iffD2]) | |
| 4045 | apply arith | |
| 4046 | done | |
| 4047 | show "sgn x * pi / 2 - arctan x < pi / 2" | |
| 4048 | using arctan_bounded [of "- x"] assms | |
| 4049 | unfolding sgn_real_def arctan_minus | |
| 4050 | by auto | |
| 4051 | show "tan (sgn x * pi / 2 - arctan x) = 1 / x" | |
| 4052 | unfolding tan_inverse [of "arctan x", unfolded tan_arctan] | |
| 4053 | unfolding sgn_real_def | |
| 4054 | by (simp add: tan_def cos_arctan sin_arctan sin_diff cos_diff) | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4055 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4056 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4057 | theorem pi_series: "pi / 4 = (\<Sum> k. (-1)^k * 1 / real (k*2+1))" (is "_ = ?SUM") | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4058 | proof - | 
| 44746 | 4059 | have "pi / 4 = arctan 1" using arctan_one by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4060 | also have "\<dots> = ?SUM" using arctan_series[of 1] by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4061 | finally show ?thesis by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4062 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4063 | |
| 53079 | 4064 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 4065 | subsection {* Existence of Polar Coordinates *}
 | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4066 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4067 | lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1" | 
| 53079 | 4068 | apply (rule power2_le_imp_le [OF _ zero_le_one]) | 
| 4069 | apply (simp add: power_divide divide_le_eq not_sum_power2_lt_zero) | |
| 4070 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4071 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 4072 | lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 53079 | 4073 | by (simp add: abs_le_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4074 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4075 | lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)" | 
| 53079 | 4076 | by (simp add: sin_arccos abs_le_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4077 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 4078 | lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one] | 
| 15228 | 4079 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4080 | lemmas sin_arccos_lemma1 = sin_arccos_abs [OF cos_x_y_le_one] | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4081 | |
| 53079 | 4082 | lemma polar_ex1: "0 < y \<Longrightarrow> \<exists>r a. x = r * cos a & y = r * sin a" | 
| 4083 | apply (rule_tac x = "sqrt (x\<^sup>2 + y\<^sup>2)" in exI) | |
| 4084 | apply (rule_tac x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))" in exI) | |
| 4085 | apply (simp add: cos_arccos_lemma1) | |
| 4086 | apply (simp add: sin_arccos_lemma1) | |
| 4087 | apply (simp add: power_divide) | |
| 4088 | apply (simp add: real_sqrt_mult [symmetric]) | |
| 4089 | apply (simp add: right_diff_distrib) | |
| 4090 | done | |
| 4091 | ||
| 4092 | lemma polar_ex2: "y < 0 ==> \<exists>r a. x = r * cos a & y = r * sin a" | |
| 4093 | using polar_ex1 [where x=x and y="-y"] | |
| 4094 | apply simp | |
| 4095 | apply clarify | |
| 4096 | apply (metis cos_minus minus_minus minus_mult_right sin_minus) | |
| 4097 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4098 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4099 | lemma polar_Ex: "\<exists>r a. x = r * cos a & y = r * sin a" | 
| 53079 | 4100 | apply (rule_tac x=0 and y=y in linorder_cases) | 
| 4101 | apply (erule polar_ex1) | |
| 4102 | apply (rule_tac x=x in exI, rule_tac x=0 in exI, simp) | |
| 4103 | apply (erule polar_ex2) | |
| 4104 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4105 | |
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 4106 | end |