| author | wenzelm | 
| Mon, 29 Feb 2016 20:43:16 +0100 | |
| changeset 62476 | d396da07055d | 
| parent 62393 | a620a8756b7c | 
| child 62679 | 092cb9c96c99 | 
| 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 | ||
| 60758 | 7 | section\<open>Power Series, Transcendental Functions etc.\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 8 | |
| 15131 | 9 | theory Transcendental | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 10 | imports Binomial Series Deriv NthRoot | 
| 15131 | 11 | begin | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 12 | |
| 62083 | 13 | text \<open>A fact theorem on reals.\<close> | 
| 14 | ||
| 15 | lemma square_fact_le_2_fact: | |
| 16 | shows "fact n * fact n \<le> (fact (2 * n) :: real)" | |
| 17 | proof (induct n) | |
| 18 | case 0 then show ?case by simp | |
| 19 | next | |
| 20 | case (Suc n) | |
| 21 | have "(fact (Suc n)) * (fact (Suc n)) = of_nat (Suc n) * of_nat (Suc n) * (fact n * fact n :: real)" | |
| 22 | by (simp add: field_simps) | |
| 23 | also have "\<dots> \<le> of_nat (Suc n) * of_nat (Suc n) * fact (2 * n)" | |
| 24 | by (rule mult_left_mono [OF Suc]) simp | |
| 25 | also have "\<dots> \<le> of_nat (Suc (Suc (2 * n))) * of_nat (Suc (2 * n)) * fact (2 * n)" | |
| 26 | by (rule mult_right_mono)+ (auto simp: field_simps) | |
| 27 | also have "\<dots> = fact (2 * Suc n)" by (simp add: field_simps) | |
| 28 | finally show ?case . | |
| 29 | qed | |
| 30 | ||
| 31 | ||
| 62347 | 32 | lemma fact_in_Reals: "fact n \<in> \<real>" | 
| 33 | by (induction n) auto | |
| 34 | ||
| 35 | lemma of_real_fact [simp]: "of_real (fact n) = fact n" | |
| 36 | by (metis of_nat_fact of_real_of_nat_eq) | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 37 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 38 | lemma pochhammer_of_real: "pochhammer (of_real x) n = of_real (pochhammer x n)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 39 | by (simp add: pochhammer_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 40 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 41 | lemma norm_fact [simp]: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 42 |   "norm (fact n :: 'a :: {real_normed_algebra_1}) = fact n"
 | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 43 | proof - | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 44 | have "(fact n :: 'a) = of_real (fact n)" by simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 45 | also have "norm \<dots> = fact n" by (subst norm_of_real) simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 46 | finally show ?thesis . | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 47 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 48 | |
| 57025 | 49 | lemma root_test_convergence: | 
| 50 | fixes f :: "nat \<Rightarrow> 'a::banach" | |
| 61969 | 51 | assumes f: "(\<lambda>n. root n (norm (f n))) \<longlonglongrightarrow> x" \<comment> "could be weakened to lim sup" | 
| 57025 | 52 | assumes "x < 1" | 
| 53 | shows "summable f" | |
| 54 | proof - | |
| 55 | have "0 \<le> x" | |
| 56 | by (rule LIMSEQ_le[OF tendsto_const f]) (auto intro!: exI[of _ 1]) | |
| 60758 | 57 | from \<open>x < 1\<close> obtain z where z: "x < z" "z < 1" | 
| 57025 | 58 | by (metis dense) | 
| 60758 | 59 | from f \<open>x < z\<close> | 
| 57025 | 60 | have "eventually (\<lambda>n. root n (norm (f n)) < z) sequentially" | 
| 61 | by (rule order_tendstoD) | |
| 62 | then have "eventually (\<lambda>n. norm (f n) \<le> z^n) sequentially" | |
| 63 | using eventually_ge_at_top | |
| 64 | proof eventually_elim | |
| 65 | fix n assume less: "root n (norm (f n)) < z" and n: "1 \<le> n" | |
| 66 | from power_strict_mono[OF less, of n] n | |
| 67 | show "norm (f n) \<le> z ^ n" | |
| 68 | by simp | |
| 69 | qed | |
| 70 | then show "summable f" | |
| 71 | unfolding eventually_sequentially | |
| 60758 | 72 | using z \<open>0 \<le> x\<close> by (auto intro!: summable_comparison_test[OF _ summable_geometric]) | 
| 57025 | 73 | qed | 
| 74 | ||
| 60758 | 75 | subsection \<open>Properties of Power Series\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 76 | |
| 62379 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 77 | lemma powser_zero [simp]: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 78 | fixes f :: "nat \<Rightarrow> 'a::real_normed_algebra_1" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 79 | shows "(\<Sum>n. f n * 0 ^ n) = f 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 80 | proof - | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 81 | have "(\<Sum>n<1. f n * 0 ^ n) = (\<Sum>n. f n * 0 ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 82 |     by (subst suminf_finite[where N="{0}"]) (auto simp: power_0_left)
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 83 | thus ?thesis unfolding One_nat_def by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 84 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 85 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 86 | lemma powser_sums_zero: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 87 | fixes a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 88 | shows "(\<lambda>n. a n * 0^n) sums a 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 89 |     using sums_finite [of "{0}" "\<lambda>n. a n * 0 ^ n"]
 | 
| 54573 | 90 | by simp | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 91 | |
| 62379 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 92 | lemma powser_sums_zero_iff [simp]: | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 93 | fixes a :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 94 | shows "(\<lambda>n. a n * 0^n) sums x \<longleftrightarrow> a 0 = x" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 95 | using powser_sums_zero sums_unique2 by blast | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 96 | |
| 60758 | 97 | text\<open>Power series has a circle or radius of convergence: if it sums for @{term
 | 
| 98 |   x}, then it sums absolutely for @{term z} with @{term "\<bar>z\<bar> < \<bar>x\<bar>"}.\<close>
 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 99 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 100 | lemma powser_insidea: | 
| 53599 | 101 | fixes x z :: "'a::real_normed_div_algebra" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 102 | assumes 1: "summable (\<lambda>n. f n * x^n)" | 
| 53079 | 103 | and 2: "norm z < norm x" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 104 | shows "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 105 | proof - | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 106 | from 2 have x_neq_0: "x \<noteq> 0" by clarsimp | 
| 61969 | 107 | from 1 have "(\<lambda>n. f n * x^n) \<longlonglongrightarrow> 0" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 108 | by (rule summable_LIMSEQ_zero) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 109 | hence "convergent (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 110 | by (rule convergentI) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 111 | hence "Cauchy (\<lambda>n. f n * x^n)" | 
| 44726 | 112 | by (rule convergent_Cauchy) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 113 | hence "Bseq (\<lambda>n. f n * x^n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 114 | by (rule Cauchy_Bseq) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 115 | 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 | 116 | by (simp add: Bseq_def, safe) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 117 | have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le> | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 118 | K * norm (z ^ n) * inverse (norm (x^n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 119 | proof (intro exI allI impI) | 
| 53079 | 120 | fix n::nat | 
| 121 | assume "0 \<le> n" | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 122 | have "norm (norm (f n * z ^ n)) * norm (x^n) = | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 123 | norm (f n * x^n) * norm (z ^ n)" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 124 | by (simp add: norm_mult abs_mult) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 125 | also have "\<dots> \<le> K * norm (z ^ n)" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 126 | by (simp only: mult_right_mono 4 norm_ge_zero) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 127 | 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 | 128 | by (simp add: x_neq_0) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 129 | also have "\<dots> = K * norm (z ^ n) * inverse (norm (x^n)) * norm (x^n)" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 130 | by (simp only: mult.assoc) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 131 | finally show "norm (norm (f n * z ^ n)) \<le> | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 132 | K * norm (z ^ n) * inverse (norm (x^n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 133 | by (simp add: mult_le_cancel_right x_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 134 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 135 | 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 | 136 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 137 | from 2 have "norm (norm (z * inverse x)) < 1" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 138 | using x_neq_0 | 
| 53599 | 139 | 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 | 140 | hence "summable (\<lambda>n. norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 141 | by (rule summable_geometric) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 142 | hence "summable (\<lambda>n. K * norm (z * inverse x) ^ n)" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 143 | by (rule summable_mult) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 144 | thus "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x^n)))" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 145 | using x_neq_0 | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 146 | by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 147 | power_inverse norm_power mult.assoc) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 148 | qed | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 149 | ultimately show "summable (\<lambda>n. norm (f n * z ^ n))" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 150 | by (rule summable_comparison_test) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 151 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 152 | |
| 15229 | 153 | lemma powser_inside: | 
| 53599 | 154 |   fixes f :: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}"
 | 
| 53079 | 155 | shows | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 156 | "summable (\<lambda>n. f n * (x^n)) \<Longrightarrow> norm z < norm x \<Longrightarrow> | 
| 53079 | 157 | summable (\<lambda>n. f n * (z ^ n))" | 
| 158 | by (rule powser_insidea [THEN summable_norm_cancel]) | |
| 159 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 160 | lemma powser_times_n_limit_0: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 161 |   fixes x :: "'a::{real_normed_div_algebra,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 162 | assumes "norm x < 1" | 
| 61969 | 163 | shows "(\<lambda>n. of_nat n * x ^ n) \<longlonglongrightarrow> 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 164 | proof - | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 165 | have "norm x / (1 - norm x) \<ge> 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 166 | using assms | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 167 | by (auto simp: divide_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 168 | moreover obtain N where N: "norm x / (1 - norm x) < of_int N" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 169 | using ex_le_of_int | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 170 | by (meson ex_less_of_int) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 171 | ultimately have N0: "N>0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 172 | by auto | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 173 | then have *: "real_of_int (N + 1) * norm x / real_of_int N < 1" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 174 | using N assms | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 175 | by (auto simp: field_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 176 |   { fix n::nat
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 177 | assume "N \<le> int n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 178 | then have "real_of_int N * real_of_nat (Suc n) \<le> real_of_nat n * real_of_int (1 + N)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 179 | by (simp add: algebra_simps) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 180 | then have "(real_of_int N * real_of_nat (Suc n)) * (norm x * norm (x ^ n)) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 181 | \<le> (real_of_nat n * (1 + N)) * (norm x * norm (x ^ n))" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 182 | using N0 mult_mono by fastforce | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 183 | then have "real_of_int N * (norm x * (real_of_nat (Suc n) * norm (x ^ n))) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 184 | \<le> real_of_nat n * (norm x * ((1 + N) * norm (x ^ n)))" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 185 | by (simp add: algebra_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 186 | } note ** = this | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 187 | show ?thesis using * | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 188 | apply (rule summable_LIMSEQ_zero [OF summable_ratio_test, where N1="nat N"]) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 189 | apply (simp add: N0 norm_mult field_simps ** | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 190 | del: of_nat_Suc of_int_add) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 191 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 192 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 193 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 194 | corollary lim_n_over_pown: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 195 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 61973 | 196 | shows "1 < norm x \<Longrightarrow> ((\<lambda>n. of_nat n / x^n) \<longlongrightarrow> 0) sequentially" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 197 | using powser_times_n_limit_0 [of "inverse x"] | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 198 | by (simp add: norm_divide divide_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 199 | |
| 53079 | 200 | lemma sum_split_even_odd: | 
| 201 | fixes f :: "nat \<Rightarrow> real" | |
| 202 | shows | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 203 | "(\<Sum>i<2 * n. if even i then f i else g i) = | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 204 | (\<Sum>i<n. f (2 * i)) + (\<Sum>i<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 | 205 | proof (induct n) | 
| 53079 | 206 | case 0 | 
| 207 | then show ?case by simp | |
| 208 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 209 | case (Suc n) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 210 | have "(\<Sum>i<2 * Suc n. if even i then f i else g i) = | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 211 | (\<Sum>i<n. f (2 * i)) + (\<Sum>i<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 | 212 | using Suc.hyps unfolding One_nat_def by auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 213 | also have "\<dots> = (\<Sum>i<Suc n. f (2 * i)) + (\<Sum>i<Suc n. g (2 * i + 1))" | 
| 53079 | 214 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 215 | finally show ?case . | 
| 53079 | 216 | qed | 
| 217 | ||
| 218 | lemma sums_if': | |
| 219 | fixes g :: "nat \<Rightarrow> real" | |
| 220 | 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 | 221 | 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 | 222 | unfolding sums_def | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 223 | proof (rule LIMSEQ_I) | 
| 53079 | 224 | fix r :: real | 
| 225 | assume "0 < r" | |
| 60758 | 226 | from \<open>g sums x\<close>[unfolded sums_def, THEN LIMSEQ_D, OF this] | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 227 |   obtain no where no_eq: "\<And> n. n \<ge> no \<Longrightarrow> (norm (setsum g {..<n} - x) < r)" by blast
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 228 | |
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 229 | let ?SUM = "\<lambda> m. \<Sum>i<m. if even i then 0 else g ((i - 1) div 2)" | 
| 53079 | 230 |   {
 | 
| 231 | fix m | |
| 232 | assume "m \<ge> 2 * no" | |
| 233 | hence "m div 2 \<ge> no" by auto | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 234 |     have sum_eq: "?SUM (2 * (m div 2)) = setsum g {..< 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 | 235 | using sum_split_even_odd by auto | 
| 53079 | 236 | hence "(norm (?SUM (2 * (m div 2)) - x) < r)" | 
| 60758 | 237 | using no_eq unfolding sum_eq using \<open>m div 2 \<ge> no\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 238 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 239 | 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 | 240 | proof (cases "even m") | 
| 53079 | 241 | case True | 
| 58710 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 242 | then show ?thesis by (auto simp add: even_two_times_div_two) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 243 | next | 
| 53079 | 244 | case False | 
| 58834 | 245 | then have eq: "Suc (2 * (m div 2)) = m" by simp | 
| 60758 | 246 | hence "even (2 * (m div 2))" using \<open>odd m\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 247 | have "?SUM m = ?SUM (Suc (2 * (m div 2)))" unfolding eq .. | 
| 60758 | 248 | also have "\<dots> = ?SUM (2 * (m div 2))" using \<open>even (2 * (m div 2))\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 249 | 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 | 250 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 251 | 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 | 252 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 253 | 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 | 254 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 255 | |
| 53079 | 256 | lemma sums_if: | 
| 257 | fixes g :: "nat \<Rightarrow> real" | |
| 258 | 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 | 259 | 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 | 260 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 261 | let ?s = "\<lambda> n. if even n then 0 else f ((n - 1) div 2)" | 
| 53079 | 262 |   {
 | 
| 263 | fix B T E | |
| 264 | have "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)" | |
| 265 | by (cases B) auto | |
| 266 | } note if_sum = this | |
| 267 | have g_sums: "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x" | |
| 60758 | 268 | using sums_if'[OF \<open>g sums x\<close>] . | 
| 41970 | 269 |   {
 | 
| 41550 | 270 | 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 | 271 | |
| 60758 | 272 | have "?s sums y" using sums_if'[OF \<open>f sums y\<close>] . | 
| 41970 | 273 | 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 | 274 | have "(\<lambda> n. if even n then f (n div 2) else 0) sums y" | 
| 57418 | 275 | by (simp add: lessThan_Suc_eq_insert_0 image_iff setsum.reindex if_eq sums_def cong del: if_cong) | 
| 53079 | 276 | } | 
| 277 | 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 | 278 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 279 | |
| 60758 | 280 | subsection \<open>Alternating series test / Leibniz formula\<close> | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 281 | text\<open>FIXME: generalise these results from the reals via type classes?\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 282 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 283 | 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 | 284 | fixes a :: "nat \<Rightarrow> real" | 
| 61969 | 285 | assumes mono: "\<And>n. a (Suc n) \<le> a n" and a_pos: "\<And>n. 0 \<le> a n" and "a \<longlonglongrightarrow> 0" | 
| 286 | shows "\<exists>l. ((\<forall>n. (\<Sum>i<2*n. (- 1)^i*a i) \<le> l) \<and> (\<lambda> n. \<Sum>i<2*n. (- 1)^i*a i) \<longlonglongrightarrow> l) \<and> | |
| 287 | ((\<forall>n. l \<le> (\<Sum>i<2*n + 1. (- 1)^i*a i)) \<and> (\<lambda> n. \<Sum>i<2*n + 1. (- 1)^i*a i) \<longlonglongrightarrow> l)" | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 288 | (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)") | 
| 53079 | 289 | 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 | 290 | 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 | 291 | |
| 53079 | 292 | show "\<forall>n. ?f n \<le> ?f (Suc n)" | 
| 293 | proof | |
| 294 | fix n | |
| 295 | show "?f n \<le> ?f (Suc n)" using mono[of "2*n"] by auto | |
| 296 | qed | |
| 297 | show "\<forall>n. ?g (Suc n) \<le> ?g n" | |
| 298 | proof | |
| 299 | fix n | |
| 300 | show "?g (Suc n) \<le> ?g n" using mono[of "Suc (2*n)"] | |
| 301 | unfolding One_nat_def by auto | |
| 302 | qed | |
| 303 | show "\<forall>n. ?f n \<le> ?g n" | |
| 304 | proof | |
| 305 | fix n | |
| 306 | show "?f n \<le> ?g n" using fg_diff a_pos | |
| 307 | 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 | 308 | qed | 
| 61969 | 309 | show "(\<lambda>n. ?f n - ?g n) \<longlonglongrightarrow> 0" unfolding fg_diff | 
| 53079 | 310 | proof (rule LIMSEQ_I) | 
| 311 | fix r :: real | |
| 312 | assume "0 < r" | |
| 61969 | 313 | with \<open>a \<longlonglongrightarrow> 0\<close>[THEN LIMSEQ_D] obtain N where "\<And> n. n \<ge> N \<Longrightarrow> norm (a n - 0) < r" | 
| 53079 | 314 | by auto | 
| 315 | hence "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto | |
| 316 | thus "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto | |
| 317 | qed | |
| 41970 | 318 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 319 | |
| 53079 | 320 | lemma summable_Leibniz': | 
| 321 | fixes a :: "nat \<Rightarrow> real" | |
| 61969 | 322 | assumes a_zero: "a \<longlonglongrightarrow> 0" | 
| 53079 | 323 | and a_pos: "\<And> n. 0 \<le> a n" | 
| 324 | 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 | 325 | shows summable: "summable (\<lambda> n. (-1)^n * a n)" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 326 | and "\<And>n. (\<Sum>i<2*n. (-1)^i*a i) \<le> (\<Sum>i. (-1)^i*a i)" | 
| 61969 | 327 | and "(\<lambda>n. \<Sum>i<2*n. (-1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (-1)^i*a i)" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 328 | and "\<And>n. (\<Sum>i. (-1)^i*a i) \<le> (\<Sum>i<2*n+1. (-1)^i*a i)" | 
| 61969 | 329 | and "(\<lambda>n. \<Sum>i<2*n+1. (-1)^i*a i) \<longlonglongrightarrow> (\<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 | 330 | proof - | 
| 53079 | 331 | let ?S = "\<lambda>n. (-1)^n * a n" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 332 | let ?P = "\<lambda>n. \<Sum>i<n. ?S i" | 
| 53079 | 333 | let ?f = "\<lambda>n. ?P (2 * n)" | 
| 334 | let ?g = "\<lambda>n. ?P (2 * n + 1)" | |
| 335 | obtain l :: real | |
| 336 | where below_l: "\<forall> n. ?f n \<le> l" | |
| 61969 | 337 | and "?f \<longlonglongrightarrow> l" | 
| 53079 | 338 | and above_l: "\<forall> n. l \<le> ?g n" | 
| 61969 | 339 | and "?g \<longlonglongrightarrow> l" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 340 | using sums_alternating_upper_lower[OF a_monotone a_pos a_zero] by blast | 
| 41970 | 341 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 342 | let ?Sa = "\<lambda>m. \<Sum>n<m. ?S n" | 
| 61969 | 343 | have "?Sa \<longlonglongrightarrow> l" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 344 | proof (rule LIMSEQ_I) | 
| 53079 | 345 | fix r :: real | 
| 346 | assume "0 < r" | |
| 61969 | 347 | with \<open>?f \<longlonglongrightarrow> l\<close>[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 | 348 | 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 | 349 | |
| 61969 | 350 | from \<open>0 < r\<close> \<open>?g \<longlonglongrightarrow> l\<close>[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 | 351 | 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 | 352 | |
| 53079 | 353 |     {
 | 
| 354 | fix n :: nat | |
| 355 | assume "n \<ge> (max (2 * f_no) (2 * g_no))" | |
| 356 | 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 | 357 | 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 | 358 | proof (cases "even n") | 
| 53079 | 359 | case True | 
| 58710 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 360 | then have n_eq: "2 * (n div 2) = n" by (simp add: even_two_times_div_two) | 
| 60758 | 361 | with \<open>n \<ge> 2 * f_no\<close> have "n div 2 \<ge> f_no" | 
| 53079 | 362 | by auto | 
| 363 | from f[OF this] show ?thesis | |
| 364 | 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 | 365 | next | 
| 53079 | 366 | case False | 
| 367 | hence "even (n - 1)" by simp | |
| 58710 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 368 | then have n_eq: "2 * ((n - 1) div 2) = n - 1" | 
| 
7216a10d69ba
augmented and tuned facts on even/odd and division
 haftmann parents: 
58709diff
changeset | 369 | by (simp add: even_two_times_div_two) | 
| 53079 | 370 | hence range_eq: "n - 1 + 1 = n" | 
| 371 | using odd_pos[OF False] by auto | |
| 372 | ||
| 60758 | 373 | from n_eq \<open>n \<ge> 2 * g_no\<close> have "(n - 1) div 2 \<ge> g_no" | 
| 53079 | 374 | by auto | 
| 375 | from g[OF this] show ?thesis | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 376 | unfolding n_eq range_eq . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 377 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 378 | } | 
| 53079 | 379 | 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 | 380 | qed | 
| 53079 | 381 | hence sums_l: "(\<lambda>i. (-1)^i * a i) sums l" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 382 | unfolding sums_def . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 383 | 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 | 384 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 385 | 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 | 386 | |
| 53079 | 387 | fix n | 
| 388 | show "suminf ?S \<le> ?g n" | |
| 389 | unfolding sums_unique[OF sums_l, symmetric] using above_l by auto | |
| 390 | show "?f n \<le> suminf ?S" | |
| 391 | unfolding sums_unique[OF sums_l, symmetric] using below_l by auto | |
| 61969 | 392 | show "?g \<longlonglongrightarrow> suminf ?S" | 
| 393 | using \<open>?g \<longlonglongrightarrow> l\<close> \<open>l = suminf ?S\<close> by auto | |
| 394 | show "?f \<longlonglongrightarrow> suminf ?S" | |
| 395 | using \<open>?f \<longlonglongrightarrow> l\<close> \<open>l = suminf ?S\<close> by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 396 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 397 | |
| 53079 | 398 | theorem summable_Leibniz: | 
| 399 | fixes a :: "nat \<Rightarrow> real" | |
| 61969 | 400 | assumes a_zero: "a \<longlonglongrightarrow> 0" and "monoseq a" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 401 | shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable") | 
| 53079 | 402 | and "0 < a 0 \<longrightarrow> | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 403 |       (\<forall>n. (\<Sum>i. (- 1)^i*a i) \<in> { \<Sum>i<2*n. (- 1)^i * a i .. \<Sum>i<2*n+1. (- 1)^i * a i})" (is "?pos")
 | 
| 53079 | 404 | and "a 0 < 0 \<longrightarrow> | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 405 |       (\<forall>n. (\<Sum>i. (- 1)^i*a i) \<in> { \<Sum>i<2*n+1. (- 1)^i * a i .. \<Sum>i<2*n. (- 1)^i * a i})" (is "?neg")
 | 
| 61969 | 406 | and "(\<lambda>n. \<Sum>i<2*n. (- 1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (- 1)^i*a i)" (is "?f") | 
| 407 | and "(\<lambda>n. \<Sum>i<2*n+1. (- 1)^i*a i) \<longlonglongrightarrow> (\<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 | 408 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 409 | 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 | 410 | 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 | 411 | case True | 
| 53079 | 412 | hence ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" and ge0: "\<And> n. 0 \<le> a n" | 
| 413 | by auto | |
| 414 |     {
 | |
| 415 | fix n | |
| 416 | have "a (Suc n) \<le> a n" | |
| 417 | using ord[where n="Suc n" and m=n] by auto | |
| 418 | } note mono = this | |
| 61969 | 419 | note leibniz = summable_Leibniz'[OF \<open>a \<longlonglongrightarrow> 0\<close> ge0] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 420 | from leibniz[OF mono] | 
| 60758 | 421 | show ?thesis using \<open>0 \<le> a 0\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 422 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 423 | 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 | 424 | case False | 
| 61969 | 425 | with monoseq_le[OF \<open>monoseq a\<close> \<open>a \<longlonglongrightarrow> 0\<close>] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 426 | have "(\<forall> n. a n \<le> 0) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)" by auto | 
| 53079 | 427 | hence ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n" | 
| 428 | by auto | |
| 429 |     {
 | |
| 430 | fix n | |
| 431 | have "?a (Suc n) \<le> ?a n" using ord[where n="Suc n" and m=n] | |
| 432 | by auto | |
| 433 | } note monotone = this | |
| 434 | note leibniz = | |
| 435 | summable_Leibniz'[OF _ ge0, of "\<lambda>x. x", | |
| 61969 | 436 | OF tendsto_minus[OF \<open>a \<longlonglongrightarrow> 0\<close>, unfolded minus_zero] monotone] | 
| 53079 | 437 | have "summable (\<lambda> n. (-1)^n * ?a n)" | 
| 438 | using leibniz(1) by auto | |
| 439 | then obtain l where "(\<lambda> n. (-1)^n * ?a n) sums l" | |
| 440 | unfolding summable_def by auto | |
| 441 | from this[THEN sums_minus] have "(\<lambda> n. (-1)^n * a n) sums -l" | |
| 442 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 443 | 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 | 444 | moreover | 
| 53079 | 445 | have "\<And>a b :: real. \<bar>- a - - b\<bar> = \<bar>a - b\<bar>" | 
| 446 | unfolding minus_diff_minus by auto | |
| 41970 | 447 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 448 | from suminf_minus[OF leibniz(1), unfolded mult_minus_right minus_minus] | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 449 | have move_minus: "(\<Sum>n. - ((- 1) ^ n * a n)) = - (\<Sum>n. (- 1) ^ n * a n)" | 
| 53079 | 450 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 451 | |
| 60758 | 452 | have ?pos using \<open>0 \<le> ?a 0\<close> by auto | 
| 53079 | 453 | moreover have ?neg | 
| 454 | using leibniz(2,4) | |
| 455 | unfolding mult_minus_right setsum_negf move_minus neg_le_iff_le | |
| 456 | by auto | |
| 457 | moreover have ?f and ?g | |
| 458 | using leibniz(3,5)[unfolded mult_minus_right setsum_negf move_minus, THEN tendsto_minus_cancel] | |
| 459 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 460 | 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 | 461 | qed | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 462 | then show ?summable and ?pos and ?neg and ?f and ?g | 
| 54573 | 463 | by safe | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 464 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 465 | |
| 60758 | 466 | subsection \<open>Term-by-Term Differentiability of Power Series\<close> | 
| 23043 | 467 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 468 | definition diffs :: "(nat \<Rightarrow> 'a::ring_1) \<Rightarrow> nat \<Rightarrow> 'a" | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 469 | where "diffs c = (\<lambda>n. of_nat (Suc n) * c (Suc n))" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 470 | |
| 60758 | 471 | text\<open>Lemma about distributing negation over it\<close> | 
| 53079 | 472 | lemma diffs_minus: "diffs (\<lambda>n. - c n) = (\<lambda>n. - diffs c n)" | 
| 473 | by (simp add: diffs_def) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 474 | |
| 15229 | 475 | lemma diffs_equiv: | 
| 41970 | 476 |   fixes x :: "'a::{real_normed_vector, ring_1}"
 | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 477 | shows "summable (\<lambda>n. diffs c n * x^n) \<Longrightarrow> | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 478 | (\<lambda>n. of_nat n * c n * x^(n - Suc 0)) sums (\<Sum>n. diffs c n * x^n)" | 
| 53079 | 479 | unfolding diffs_def | 
| 54573 | 480 | by (simp add: summable_sums sums_Suc_imp) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 481 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 482 | lemma lemma_termdiff1: | 
| 31017 | 483 |   fixes z :: "'a :: {monoid_mult,comm_ring}" shows
 | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 484 | "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) = | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 485 | (\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))" | 
| 53079 | 486 | by (auto simp add: algebra_simps power_add [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 487 | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 488 | lemma sumr_diff_mult_const2: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 489 |   "setsum f {..<n} - of_nat n * (r::'a::ring_1) = (\<Sum>i<n. f i - r)"
 | 
| 53079 | 490 | by (simp add: setsum_subtractf) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 491 | |
| 60162 | 492 | lemma lemma_realpow_rev_sumr: | 
| 493 | "(\<Sum>p<Suc n. (x ^ p) * (y ^ (n - p))) = | |
| 494 | (\<Sum>p<Suc n. (x ^ (n - p)) * (y ^ p))" | |
| 495 | by (subst nat_diff_setsum_reindex[symmetric]) simp | |
| 496 | ||
| 15229 | 497 | lemma lemma_termdiff2: | 
| 31017 | 498 |   fixes h :: "'a :: {field}"
 | 
| 53079 | 499 | assumes h: "h \<noteq> 0" | 
| 500 | shows | |
| 501 | "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) = | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 502 | h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. | 
| 53079 | 503 | (z + h) ^ q * z ^ (n - 2 - q))" (is "?lhs = ?rhs") | 
| 504 | apply (subgoal_tac "h * ?lhs = h * ?rhs", simp add: h) | |
| 505 | apply (simp add: right_diff_distrib diff_divide_distrib h) | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 506 | apply (simp add: mult.assoc [symmetric]) | 
| 53079 | 507 | apply (cases "n", simp) | 
| 60162 | 508 | apply (simp add: diff_power_eq_setsum h | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 509 | right_diff_distrib [symmetric] mult.assoc | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 510 | del: power_Suc setsum_lessThan_Suc of_nat_Suc) | 
| 53079 | 511 | apply (subst lemma_realpow_rev_sumr) | 
| 512 | apply (subst sumr_diff_mult_const2) | |
| 513 | apply simp | |
| 514 | apply (simp only: lemma_termdiff1 setsum_right_distrib) | |
| 57418 | 515 | apply (rule setsum.cong [OF refl]) | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 516 | apply (simp add: less_iff_Suc_add) | 
| 53079 | 517 | apply (clarify) | 
| 60162 | 518 | apply (simp add: setsum_right_distrib diff_power_eq_setsum ac_simps | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 519 | del: setsum_lessThan_Suc power_Suc) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 520 | apply (subst mult.assoc [symmetric], subst power_add [symmetric]) | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 521 | apply (simp add: ac_simps) | 
| 53079 | 522 | done | 
| 20860 | 523 | |
| 524 | 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 | 525 | fixes K :: "'a::linordered_semidom" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 526 | assumes f: "\<And>p::nat. p < n \<Longrightarrow> f p \<le> K" | 
| 53079 | 527 | and K: "0 \<le> K" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 528 |   shows "setsum f {..<n-k} \<le> of_nat n * K"
 | 
| 53079 | 529 | apply (rule order_trans [OF setsum_mono]) | 
| 530 | apply (rule f, simp) | |
| 531 | apply (simp add: mult_right_mono K) | |
| 532 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 533 | |
| 15229 | 534 | lemma lemma_termdiff3: | 
| 31017 | 535 |   fixes h z :: "'a::{real_normed_field}"
 | 
| 20860 | 536 | assumes 1: "h \<noteq> 0" | 
| 53079 | 537 | and 2: "norm z \<le> K" | 
| 538 | and 3: "norm (z + h) \<le> K" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 539 | 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 | 540 | \<le> of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | 
| 20860 | 541 | proof - | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 542 | have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) = | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 543 | norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 544 | (z + h) ^ q * z ^ (n - 2 - q)) * norm h" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 545 | by (metis (lifting, no_types) lemma_termdiff2 [OF 1] mult.commute norm_mult) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 546 | 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 | 547 | proof (rule mult_right_mono [OF _ norm_ge_zero]) | 
| 53079 | 548 | from norm_ge_zero 2 have K: "0 \<le> K" | 
| 549 | by (rule order_trans) | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 550 | have le_Kn: "\<And>i j n. i + j = n \<Longrightarrow> norm ((z + h) ^ i * z ^ j) \<le> K ^ n" | 
| 20860 | 551 | apply (erule subst) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 552 | apply (simp only: norm_mult norm_power power_add) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 553 | apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K) | 
| 20860 | 554 | done | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 555 | show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 556 | \<le> of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))" | 
| 20860 | 557 | apply (intro | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 558 | order_trans [OF norm_setsum] | 
| 20860 | 559 | real_setsum_nat_ivl_bounded2 | 
| 560 | mult_nonneg_nonneg | |
| 47489 | 561 | of_nat_0_le_iff | 
| 20860 | 562 | zero_le_power K) | 
| 563 | apply (rule le_Kn, simp) | |
| 564 | done | |
| 565 | qed | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 566 | also have "\<dots> = of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 567 | by (simp only: mult.assoc) | 
| 20860 | 568 | finally show ?thesis . | 
| 569 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 570 | |
| 20860 | 571 | lemma lemma_termdiff4: | 
| 56167 | 572 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | 
| 20860 | 573 | assumes k: "0 < (k::real)" | 
| 53079 | 574 | and le: "\<And>h. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (f h) \<le> K * norm h" | 
| 61976 | 575 | shows "f \<midarrow>0\<rightarrow> 0" | 
| 56167 | 576 | proof (rule tendsto_norm_zero_cancel) | 
| 61976 | 577 | show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0" | 
| 56167 | 578 | proof (rule real_tendsto_sandwich) | 
| 579 | show "eventually (\<lambda>h. 0 \<le> norm (f h)) (at 0)" | |
| 20860 | 580 | by simp | 
| 56167 | 581 | show "eventually (\<lambda>h. norm (f h) \<le> K * norm h) (at 0)" | 
| 582 | using k by (auto simp add: eventually_at dist_norm le) | |
| 61976 | 583 | show "(\<lambda>h. 0) \<midarrow>(0::'a)\<rightarrow> (0::real)" | 
| 56167 | 584 | by (rule tendsto_const) | 
| 61976 | 585 | have "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> K * norm (0::'a)" | 
| 56167 | 586 | by (intro tendsto_intros) | 
| 61976 | 587 | then show "(\<lambda>h. K * norm h) \<midarrow>(0::'a)\<rightarrow> 0" | 
| 56167 | 588 | by simp | 
| 20860 | 589 | qed | 
| 590 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 591 | |
| 15229 | 592 | lemma lemma_termdiff5: | 
| 56167 | 593 | fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach" | 
| 20860 | 594 | assumes k: "0 < (k::real)" | 
| 595 | assumes f: "summable f" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 596 | assumes le: "\<And>h n. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (g h n) \<le> f n * norm h" | 
| 61976 | 597 | shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 598 | proof (rule lemma_termdiff4 [OF k]) | 
| 53079 | 599 | fix h::'a | 
| 600 | assume "h \<noteq> 0" and "norm h < k" | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 601 | hence A: "\<forall>n. norm (g h n) \<le> f n * norm h" | 
| 20860 | 602 | by (simp add: le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 603 | hence "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h" | 
| 20860 | 604 | by simp | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 605 | moreover from f have B: "summable (\<lambda>n. f n * norm h)" | 
| 20860 | 606 | by (rule summable_mult2) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 607 | ultimately have C: "summable (\<lambda>n. norm (g h n))" | 
| 20860 | 608 | by (rule summable_comparison_test) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 609 | hence "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 610 | by (rule summable_norm) | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 611 | also from A C B have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)" | 
| 56213 | 612 | by (rule suminf_le) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 613 | also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h" | 
| 20860 | 614 | by (rule suminf_mult2 [symmetric]) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 615 | finally show "norm (suminf (g h)) \<le> suminf f * norm h" . | 
| 20860 | 616 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 617 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 618 | |
| 60758 | 619 | text\<open>FIXME: Long proofs\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 620 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 621 | lemma termdiffs_aux: | 
| 31017 | 622 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 623 | assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)" | 
| 53079 | 624 | and 2: "norm x < norm K" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 625 | shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x^n) / h | 
| 61976 | 626 | - of_nat n * x ^ (n - Suc 0))) \<midarrow>0\<rightarrow> 0" | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 627 | proof - | 
| 20860 | 628 | from dense [OF 2] | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 629 | 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 | 630 | from norm_ge_zero r1 have r: "0 < r" | 
| 20860 | 631 | by (rule order_le_less_trans) | 
| 632 | hence r_neq_0: "r \<noteq> 0" by simp | |
| 633 | show ?thesis | |
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 634 | proof (rule lemma_termdiff5) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 635 | show "0 < r - norm x" using r1 by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 636 | from r r2 have "norm (of_real r::'a) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 637 | by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 638 | with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))" | 
| 20860 | 639 | by (rule powser_insidea) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 640 | 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 | 641 | using r | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 642 | 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 | 643 | hence "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))" | 
| 20860 | 644 | by (rule diffs_equiv [THEN sums_summable]) | 
| 53079 | 645 | also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) = | 
| 646 | (\<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 | 647 | apply (rule ext) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 648 | apply (simp add: diffs_def) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 649 | apply (case_tac n, simp_all add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 650 | done | 
| 41970 | 651 | finally have "summable | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 652 | (\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))" | 
| 20860 | 653 | by (rule diffs_equiv [THEN sums_summable]) | 
| 654 | also have | |
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 655 | "(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * | 
| 20860 | 656 | r ^ (n - Suc 0)) = | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 657 | (\<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 | 658 | apply (rule ext) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 659 | apply (case_tac "n", simp) | 
| 55417 
01fbfb60c33e
adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems
 blanchet parents: 
54576diff
changeset | 660 | apply (rename_tac nat) | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 661 | apply (case_tac "nat", simp) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 662 | apply (simp add: r_neq_0) | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 663 | done | 
| 53079 | 664 | finally | 
| 665 | 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 | 666 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 667 | fix h::'a and n::nat | 
| 20860 | 668 | assume h: "h \<noteq> 0" | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 669 | assume "norm h < r - norm x" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 670 | hence "norm x + norm h < r" by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 671 | with norm_triangle_ineq have xh: "norm (x + h) < r" | 
| 20860 | 672 | by (rule order_le_less_trans) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 673 | show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 674 | \<le> norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 675 | apply (simp only: norm_mult mult.assoc) | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 676 | apply (rule mult_left_mono [OF _ norm_ge_zero]) | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 677 | apply (simp add: mult.assoc [symmetric]) | 
| 54575 | 678 | apply (metis h lemma_termdiff3 less_eq_real_def r1 xh) | 
| 20860 | 679 | done | 
| 20849 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 680 | qed | 
| 
389cd9c8cfe1
rewrite proofs of powser_insidea and termdiffs_aux
 huffman parents: 
20692diff
changeset | 681 | qed | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19765diff
changeset | 682 | |
| 20860 | 683 | lemma termdiffs: | 
| 31017 | 684 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 20860 | 685 | assumes 1: "summable (\<lambda>n. c n * K ^ n)" | 
| 54575 | 686 | and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)" | 
| 687 | and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)" | |
| 688 | and 4: "norm x < norm K" | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 689 | shows "DERIV (\<lambda>x. \<Sum>n. c n * x^n) x :> (\<Sum>n. (diffs c) n * x^n)" | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 690 | unfolding DERIV_def | 
| 29163 | 691 | proof (rule LIM_zero_cancel) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 692 | show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h | 
| 61976 | 693 | - suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0" | 
| 20860 | 694 | proof (rule LIM_equal2) | 
| 29163 | 695 | show "0 < norm K - norm x" using 4 by (simp add: less_diff_eq) | 
| 20860 | 696 | next | 
| 23082 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 697 | fix h :: 'a | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 698 | assume "norm (h - 0) < norm K - norm x" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 699 | hence "norm x + norm h < norm K" by simp | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 700 | hence 5: "norm (x + h) < norm K" | 
| 
ffef77eed382
generalize powerseries and termdiffs lemmas using axclasses
 huffman parents: 
23069diff
changeset | 701 | by (rule norm_triangle_ineq [THEN order_le_less_trans]) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 702 | have "summable (\<lambda>n. c n * x^n)" | 
| 56167 | 703 | and "summable (\<lambda>n. c n * (x + h) ^ n)" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 704 | and "summable (\<lambda>n. diffs c n * x^n)" | 
| 56167 | 705 | using 1 2 4 5 by (auto elim: powser_inside) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 706 | then have "((\<Sum>n. c n * (x + h) ^ n) - (\<Sum>n. c n * x^n)) / h - (\<Sum>n. diffs c n * x^n) = | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 707 | (\<Sum>n. (c n * (x + h) ^ n - c n * x^n) / h - of_nat n * c n * x ^ (n - Suc 0))" | 
| 56167 | 708 | by (intro sums_unique sums_diff sums_divide diffs_equiv summable_sums) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 709 | then show "((\<Sum>n. c n * (x + h) ^ n) - (\<Sum>n. c n * x^n)) / h - (\<Sum>n. diffs c n * x^n) = | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 710 | (\<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))" | 
| 54575 | 711 | by (simp add: algebra_simps) | 
| 20860 | 712 | next | 
| 61976 | 713 | show "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<midarrow>0\<rightarrow> 0" | 
| 53079 | 714 | by (rule termdiffs_aux [OF 3 4]) | 
| 20860 | 715 | qed | 
| 716 | qed | |
| 717 | ||
| 60758 | 718 | subsection \<open>The Derivative of a Power Series Has the Same Radius of Convergence\<close> | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 719 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 720 | lemma termdiff_converges: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 721 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 722 | assumes K: "norm x < K" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 723 | and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 724 | shows "summable (\<lambda>n. diffs c n * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 725 | proof (cases "x = 0") | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 726 | case True then show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 727 | using powser_sums_zero sums_summable by auto | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 728 | next | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 729 | case False | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 730 | then have "K>0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 731 | using K less_trans zero_less_norm_iff by blast | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 732 | then obtain r::real where r: "norm x < norm r" "norm r < K" "r>0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 733 | using K False | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 734 | by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"]) | 
| 61969 | 735 | have "(\<lambda>n. of_nat n * (x / of_real r) ^ n) \<longlonglongrightarrow> 0" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 736 | using r by (simp add: norm_divide powser_times_n_limit_0 [of "x / of_real r"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 737 | then obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> real_of_nat n * norm x ^ n < r ^ n" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 738 | using r unfolding LIMSEQ_iff | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 739 | apply (drule_tac x=1 in spec) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 740 | apply (auto simp: norm_divide norm_mult norm_power field_simps) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 741 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 742 | have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 743 | apply (rule summable_comparison_test' [of "\<lambda>n. norm(c n * (of_real r) ^ n)" N]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 744 | apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 745 | using N r norm_of_real [of "r+K", where 'a = 'a] | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 746 | apply (auto simp add: norm_divide norm_mult norm_power field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 747 | using less_eq_real_def by fastforce | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 748 | then have "summable (\<lambda>n. (of_nat (Suc n) * c(Suc n)) * x ^ Suc n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 749 | using summable_iff_shift [of "\<lambda>n. of_nat n * c n * x ^ n" 1] | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 750 | by simp | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 751 | then have "summable (\<lambda>n. (of_nat (Suc n) * c(Suc n)) * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 752 | using False summable_mult2 [of "\<lambda>n. (of_nat (Suc n) * c(Suc n) * x ^ n) * x" "inverse x"] | 
| 60867 | 753 | by (simp add: mult.assoc) (auto simp: ac_simps) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 754 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 755 | by (simp add: diffs_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 756 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 757 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 758 | lemma termdiff_converges_all: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 759 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 760 | assumes "\<And>x. summable (\<lambda>n. c n * x^n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 761 | shows "summable (\<lambda>n. diffs c n * x^n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 762 | apply (rule termdiff_converges [where K = "1 + norm x"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 763 | using assms | 
| 60762 | 764 | apply auto | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 765 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 766 | |
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 767 | lemma termdiffs_strong: | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 768 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 769 | assumes sm: "summable (\<lambda>n. c n * K ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 770 | and K: "norm x < norm K" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 771 | shows "DERIV (\<lambda>x. \<Sum>n. c n * x^n) x :> (\<Sum>n. diffs c n * x^n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 772 | proof - | 
| 60762 | 773 | have K2: "norm ((of_real (norm K) + of_real (norm x)) / 2 :: 'a) < norm K" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 774 | using K | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 775 | apply (auto simp: norm_divide field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 776 | apply (rule le_less_trans [of _ "of_real (norm K) + of_real (norm x)"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 777 | apply (auto simp: mult_2_right norm_triangle_mono) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 778 | done | 
| 60762 | 779 | then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2" | 
| 780 | by simp | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 781 | have "summable (\<lambda>n. c n * (of_real (norm x + norm K) / 2) ^ n)" | 
| 60762 | 782 | by (metis K2 summable_norm_cancel [OF powser_insidea [OF sm]] add.commute of_real_add) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 783 | moreover have "\<And>x. norm x < norm K \<Longrightarrow> summable (\<lambda>n. diffs c n * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 784 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 785 | moreover have "\<And>x. norm x < norm K \<Longrightarrow> summable (\<lambda>n. diffs(diffs c) n * x ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 786 | by (blast intro: sm termdiff_converges powser_inside) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 787 | ultimately show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 788 | apply (rule termdiffs [where K = "of_real (norm x + norm K) / 2"]) | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 789 | apply (auto simp: field_simps) | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 790 | using K | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 791 | apply (simp_all add: of_real_add [symmetric] del: of_real_add) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 792 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 793 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 794 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 795 | lemma termdiffs_strong_converges_everywhere: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 796 |     fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 797 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 798 | shows "((\<lambda>x. \<Sum>n. c n * x^n) has_field_derivative (\<Sum>n. diffs c n * x^n)) (at x)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 799 | using termdiffs_strong[OF assms[of "of_real (norm x + 1)"], of x] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 800 | by (force simp del: of_real_add) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 801 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 802 | lemma isCont_powser: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 803 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 804 | assumes "summable (\<lambda>n. c n * K ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 805 | assumes "norm x < norm K" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 806 | shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 807 | using termdiffs_strong[OF assms] by (blast intro!: DERIV_isCont) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 808 | |
| 61552 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 809 | lemmas isCont_powser' = isCont_o2[OF _ isCont_powser] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 810 | |
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 811 | lemma isCont_powser_converges_everywhere: | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 812 |   fixes K x :: "'a::{real_normed_field,banach}"
 | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 813 | assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 814 | shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x" | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 815 | using termdiffs_strong[OF assms[of "of_real (norm x + 1)"], of x] | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 816 | by (force intro!: DERIV_isCont simp del: of_real_add) | 
| 
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
 eberlm parents: 
61531diff
changeset | 817 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 818 | lemma powser_limit_0: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 819 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 820 | assumes s: "0 < s" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 821 | and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 61973 | 822 | shows "(f \<longlongrightarrow> a 0) (at 0)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 823 | proof - | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 824 | have "summable (\<lambda>n. a n * (of_real s / 2) ^ n)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 825 | apply (rule sums_summable [where l = "f (of_real s / 2)", OF sm]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 826 | using s | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 827 | apply (auto simp: norm_divide) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 828 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 829 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) has_field_derivative (\<Sum>n. diffs a n * 0 ^ n)) (at 0)" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 830 | apply (rule termdiffs_strong) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 831 | using s | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 832 | apply (auto simp: norm_divide) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 833 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 834 | then have "isCont (\<lambda>x. \<Sum>n. a n * x ^ n) 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 835 | by (blast intro: DERIV_continuous) | 
| 61973 | 836 | then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 837 | by (simp add: continuous_within powser_zero) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 838 | then show ?thesis | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 839 | apply (rule Lim_transform) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 840 | apply (auto simp add: LIM_eq) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 841 | apply (rule_tac x="s" in exI) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 842 | using s | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 843 | apply (auto simp: sm [THEN sums_unique]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 844 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 845 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 846 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 847 | lemma powser_limit_0_strong: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 848 |   fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 849 | assumes s: "0 < s" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 850 | and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)" | 
| 61973 | 851 | shows "(f \<longlongrightarrow> a 0) (at 0)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 852 | proof - | 
| 61973 | 853 | have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)" | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 854 | apply (rule powser_limit_0 [OF s]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 855 | apply (case_tac "x=0") | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 856 | apply (auto simp add: powser_sums_zero sm) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 857 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 858 | show ?thesis | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 859 | apply (subst LIM_equal [where g = "(\<lambda>x. if x = 0 then a 0 else f x)"]) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 860 | apply (simp_all add: *) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 861 | done | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 862 | qed | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 863 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 864 | |
| 60758 | 865 | subsection \<open>Derivability of power series\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 866 | |
| 53079 | 867 | lemma DERIV_series': | 
| 868 | 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 | 869 | assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)" | 
| 53079 | 870 |     and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)" and x0_in_I: "x0 \<in> {a <..< b}"
 | 
| 871 | and "summable (f' x0)" | |
| 872 | and "summable L" | |
| 873 |     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 | 874 | shows "DERIV (\<lambda> x. suminf (f x)) x0 :> (suminf (f' x0))" | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 875 | unfolding DERIV_def | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 876 | proof (rule LIM_I) | 
| 53079 | 877 | fix r :: real | 
| 878 | 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 | 879 | |
| 41970 | 880 | obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3" | 
| 60758 | 881 | using suminf_exist_split[OF \<open>0 < r/3\<close> \<open>summable L\<close>] by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 882 | |
| 41970 | 883 | obtain N_f' where N_f': "\<And> n. N_f' \<le> n \<Longrightarrow> \<bar> \<Sum> i. f' x0 (i + n) \<bar> < r/3" | 
| 60758 | 884 | using suminf_exist_split[OF \<open>0 < r/3\<close> \<open>summable (f' x0)\<close>] by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 885 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 886 | 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 | 887 | 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 | 888 | 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 | 889 | |
| 53079 | 890 | 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 | 891 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 892 | let ?r = "r / (3 * real ?N)" | 
| 60758 | 893 | from \<open>0 < r\<close> have "0 < ?r" by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 894 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 895 | let ?s = "\<lambda>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)" | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 896 |   def S' \<equiv> "Min (?s ` {..< ?N })"
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 897 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 898 | 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 | 899 | proof (rule iffD2[OF Min_gr_iff]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 900 |     show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
 | 
| 53079 | 901 | proof | 
| 902 | fix x | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 903 |       assume "x \<in> ?s ` {..<?N}"
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 904 |       then obtain n where "x = ?s n" and "n \<in> {..<?N}"
 | 
| 53079 | 905 | using image_iff[THEN iffD1] by blast | 
| 60758 | 906 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def] | 
| 53079 | 907 | 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)" | 
| 908 | by auto | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 909 | have "0 < ?s n" by (rule someI2[where a=s]) (auto simp add: s_bound simp del: of_nat_Suc) | 
| 60758 | 910 | thus "0 < x" unfolding \<open>x = ?s n\<close> . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 911 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 912 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 913 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 914 | def S \<equiv> "min (min (x0 - a) (b - x0)) S'" | 
| 53079 | 915 | hence "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0" | 
| 60758 | 916 | and "S \<le> S'" using x0_in_I and \<open>0 < S'\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 917 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 918 | |
| 53079 | 919 |   {
 | 
| 920 | fix x | |
| 921 | assume "x \<noteq> 0" and "\<bar> x \<bar> < S" | |
| 922 |     hence x_in_I: "x0 + x \<in> { a <..< b }"
 | |
| 923 | using S_a S_b by auto | |
| 41970 | 924 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 925 | 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 | 926 | note div_smbl = summable_divide[OF diff_smbl] | 
| 60758 | 927 | note all_smbl = summable_diff[OF div_smbl \<open>summable (f' x0)\<close>] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 928 | 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 | 929 | 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 | 930 | note div_shft_smbl = summable_divide[OF diff_shft_smbl] | 
| 60758 | 931 | note all_shft_smbl = summable_diff[OF div_smbl ign[OF \<open>summable (f' x0)\<close>]] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 932 | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 933 |     { fix n
 | 
| 41970 | 934 | have "\<bar> ?diff (n + ?N) x \<bar> \<le> L (n + ?N) * \<bar> (x0 + x) - x0 \<bar> / \<bar> x \<bar>" | 
| 53079 | 935 | using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero] | 
| 936 | unfolding abs_divide . | |
| 937 | hence "\<bar> (\<bar>?diff (n + ?N) x \<bar>) \<bar> \<le> L (n + ?N)" | |
| 60758 | 938 | using \<open>x \<noteq> 0\<close> by auto } | 
| 939 | note 1 = this and 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]] | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 940 | then have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))" | 
| 60758 | 941 | by (metis (lifting) abs_idempotent order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 942 | then have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> r / 3" (is "?L_part \<le> r/3") | 
| 53079 | 943 | using L_estimate by auto | 
| 944 | ||
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 945 | have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n \<bar> \<le> (\<Sum>n<?N. \<bar>?diff n x - f' x0 n \<bar>)" .. | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 946 | also have "\<dots> < (\<Sum>n<?N. ?r)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 947 | proof (rule setsum_strict_mono) | 
| 53079 | 948 | fix n | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 949 |       assume "n \<in> {..< ?N}"
 | 
| 60758 | 950 | have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> . | 
| 951 | also have "S \<le> S'" using \<open>S \<le> S'\<close> . | |
| 41970 | 952 | 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 | 953 | proof (rule Min_le_iff[THEN iffD2]) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 954 |         have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
 | 
| 60758 | 955 |           using \<open>n \<in> {..< ?N}\<close> by auto
 | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 956 |         thus "\<exists> a \<in> (?s ` {..<?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 | 957 | qed auto | 
| 53079 | 958 | 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 | 959 | |
| 60758 | 960 | from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def diff_0_right, unfolded some_eq_ex[symmetric], THEN conjunct2] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 961 | have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" . | 
| 60758 | 962 | with \<open>x \<noteq> 0\<close> and \<open>\<bar>x\<bar> < ?s n\<close> show "\<bar>?diff n x - f' x0 n\<bar> < ?r" | 
| 53079 | 963 | by blast | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 964 | qed auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 965 |     also have "\<dots> = of_nat (card {..<?N}) * ?r"
 | 
| 53079 | 966 | by (rule setsum_constant) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 967 | also have "\<dots> = real ?N * ?r" by simp | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 968 | also have "\<dots> = r/3" by (auto simp del: of_nat_Suc) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 969 | finally have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n \<bar> < r / 3" (is "?diff_part < r / 3") . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 970 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 971 | from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]] | 
| 53079 | 972 | have "\<bar>(suminf (f (x0 + x)) - (suminf (f x0))) / x - suminf (f' x0)\<bar> = | 
| 973 | \<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>" | |
| 60758 | 974 | unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric] | 
| 53079 | 975 | using suminf_divide[OF diff_smbl, symmetric] by auto | 
| 976 | also have "\<dots> \<le> ?diff_part + \<bar> (\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N)) \<bar>" | |
| 977 | unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"] | |
| 60758 | 978 | unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]] | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 979 | apply (subst (5) add.commute) | 
| 53079 | 980 | by (rule abs_triangle_ineq) | 
| 981 | also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part" | |
| 982 | using abs_triangle_ineq4 by auto | |
| 41970 | 983 | also have "\<dots> < r /3 + r/3 + r/3" | 
| 60758 | 984 | using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close> | 
| 36842 | 985 | by (rule add_strict_mono [OF add_less_le_mono]) | 
| 53079 | 986 | 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 | 987 | by auto | 
| 53079 | 988 | } | 
| 989 | thus "\<exists> s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow> | |
| 990 | norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r" | |
| 60758 | 991 | using \<open>0 < S\<close> 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 | 992 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 993 | |
| 53079 | 994 | lemma DERIV_power_series': | 
| 995 | 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 | 996 |   assumes converges: "\<And> x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda> n. f n * real (Suc n) * x^n)"
 | 
| 53079 | 997 |     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 | 998 | 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 | 999 | (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 | 1000 | proof - | 
| 53079 | 1001 |   {
 | 
| 1002 | fix R' | |
| 1003 | assume "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" | |
| 1004 |     hence "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
 | |
| 1005 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1006 | 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 | 1007 | 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 | 1008 | 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 | 1009 | proof - | 
| 53079 | 1010 | have "(R' + R) / 2 < R" and "0 < (R' + R) / 2" | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 1011 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 53079 | 1012 |         hence in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
 | 
| 60758 | 1013 | using \<open>R' < R\<close> by auto | 
| 53079 | 1014 | have "norm R' < norm ((R' + R) / 2)" | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 1015 | using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps) | 
| 53079 | 1016 | from powser_insidea[OF converges[OF in_Rball] this] show ?thesis | 
| 1017 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1018 | qed | 
| 53079 | 1019 |       {
 | 
| 1020 | fix n x y | |
| 1021 |         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 | 1022 | 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 | 1023 | proof - | 
| 53079 | 1024 | have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> = | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1025 | (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>" | 
| 60162 | 1026 | unfolding right_diff_distrib[symmetric] diff_power_eq_setsum abs_mult | 
| 53079 | 1027 | by auto | 
| 41970 | 1028 | 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 | 1029 | proof (rule mult_left_mono) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1030 | have "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> (\<Sum>p<Suc n. \<bar>x ^ p * y ^ (n - p)\<bar>)" | 
| 53079 | 1031 | by (rule setsum_abs) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1032 | also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)" | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1033 | proof (rule setsum_mono) | 
| 53079 | 1034 | fix p | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1035 |               assume "p \<in> {..<Suc n}"
 | 
| 53079 | 1036 | hence "p \<le> n" by auto | 
| 1037 |               {
 | |
| 1038 | fix n | |
| 1039 | fix x :: real | |
| 1040 |                 assume "x \<in> {-R'<..<R'}"
 | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1041 | hence "\<bar>x\<bar> \<le> R'" by auto | 
| 53079 | 1042 | hence "\<bar>x^n\<bar> \<le> R'^n" | 
| 1043 | unfolding power_abs by (rule power_mono, auto) | |
| 1044 | } | |
| 60758 | 1045 |               from mult_mono[OF this[OF \<open>x \<in> {-R'<..<R'}\<close>, of p] this[OF \<open>y \<in> {-R'<..<R'}\<close>, of "n-p"]] \<open>0 < R'\<close>
 | 
| 53079 | 1046 | have "\<bar>x^p * y^(n-p)\<bar> \<le> R'^p * R'^(n-p)" | 
| 1047 | unfolding abs_mult by auto | |
| 1048 | thus "\<bar>x^p * y^(n-p)\<bar> \<le> R'^n" | |
| 60758 | 1049 | unfolding power_add[symmetric] using \<open>p \<le> n\<close> by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1050 | qed | 
| 53079 | 1051 | also have "\<dots> = real (Suc n) * R' ^ n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1052 | unfolding setsum_constant card_atLeastLessThan by auto | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1053 | finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1054 | unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]] | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1055 | by linarith | 
| 53079 | 1056 | show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>" | 
| 1057 | unfolding abs_mult[symmetric] by auto | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1058 | qed | 
| 53079 | 1059 | also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 1060 | 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 | 1061 | finally show ?thesis . | 
| 53079 | 1062 | qed | 
| 1063 | } | |
| 1064 |       {
 | |
| 1065 | fix n | |
| 1066 | show "DERIV (\<lambda> x. ?f x n) x0 :> (?f' x0 n)" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1067 | by (auto intro!: derivative_eq_intros simp del: power_Suc) | 
| 53079 | 1068 | } | 
| 1069 |       {
 | |
| 1070 | fix x | |
| 1071 |         assume "x \<in> {-R' <..< R'}"
 | |
| 1072 |         hence "R' \<in> {-R <..< R}" and "norm x < norm R'"
 | |
| 60758 | 1073 | using assms \<open>R' < R\<close> by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1074 | have "summable (\<lambda> n. f n * x^n)" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1075 | proof (rule summable_comparison_test, intro exI allI impI) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 1076 | fix n | 
| 53079 | 1077 | have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)" | 
| 1078 | by (rule mult_left_mono) auto | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1079 | show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)" | 
| 53079 | 1080 | unfolding real_norm_def abs_mult | 
| 61284 
2314c2f62eb1
real_of_nat_Suc is now a simprule
 paulson <lp15@cam.ac.uk> parents: 
61076diff
changeset | 1081 | using le mult_right_mono by fastforce | 
| 60758 | 1082 |         qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
 | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 1083 | from this[THEN summable_mult2[where c=x], unfolded mult.assoc, unfolded mult.commute] | 
| 53079 | 1084 | show "summable (?f x)" by auto | 
| 1085 | } | |
| 1086 | show "summable (?f' x0)" | |
| 60758 | 1087 |         using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
 | 
| 53079 | 1088 |       show "x0 \<in> {-R' <..< R'}"
 | 
| 60758 | 1089 |         using \<open>x0 \<in> {-R' <..< R'}\<close> .
 | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1090 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1091 | } 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 | 1092 | let ?R = "(R + \<bar>x0\<bar>) / 2" | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 1093 | have "\<bar>x0\<bar> < ?R" using assms by (auto simp: field_simps) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1094 | hence "- ?R < x0" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1095 | 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 | 1096 | case True | 
| 60758 | 1097 | hence "- x0 < ?R" using \<open>\<bar>x0\<bar> < ?R\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1098 | 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 | 1099 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1100 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1101 | have "- ?R < 0" using assms by auto | 
| 41970 | 1102 | 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 | 1103 | finally show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1104 | qed | 
| 53079 | 1105 | hence "0 < ?R" "?R < R" "- ?R < x0" and "x0 < ?R" | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 1106 | using assms by (auto simp: field_simps) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1107 | 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 | 1108 | show ?thesis . | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1109 | qed | 
| 29695 | 1110 | |
| 53079 | 1111 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1112 | lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z::'a::real_normed_field. pochhammer z n) z" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1113 | by (induction n) (auto intro!: continuous_intros simp: pochhammer_rec') | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1114 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1115 | lemma continuous_on_pochhammer [continuous_intros]: | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1116 | fixes A :: "'a :: real_normed_field set" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1117 | shows "continuous_on A (\<lambda>z. pochhammer z n)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1118 | by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1119 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 1120 | |
| 60758 | 1121 | subsection \<open>Exponential Function\<close> | 
| 23043 | 1122 | |
| 58656 | 1123 | definition exp :: "'a \<Rightarrow> 'a::{real_normed_algebra_1,banach}"
 | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1124 | where "exp = (\<lambda>x. \<Sum>n. x^n /\<^sub>R fact n)" | 
| 23043 | 1125 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1126 | lemma summable_exp_generic: | 
| 31017 | 1127 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1128 | defines S_def: "S \<equiv> \<lambda>n. x^n /\<^sub>R fact n" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1129 | shows "summable S" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1130 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1131 | have S_Suc: "\<And>n. S (Suc n) = (x * S n) /\<^sub>R (Suc n)" | 
| 30273 
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
 huffman parents: 
30082diff
changeset | 1132 | 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 | 1133 | 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 | 1134 | 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 | 1135 | obtain N :: nat where N: "norm x < real N * r" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1136 | using ex_less_of_nat_mult r0 by auto | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1137 | from r1 show ?thesis | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1138 | proof (rule summable_ratio_test [rule_format]) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1139 | fix n :: nat | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1140 | assume n: "N \<le> n" | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1141 | 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 | 1142 | 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 | 1143 | 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 | 1144 | 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 | 1145 | 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 | 1146 | 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 | 1147 | 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 | 1148 | 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 | 1149 | hence "norm (x * S n) / real (Suc n) \<le> r * norm (S n)" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 1150 | by (simp add: pos_divide_le_eq ac_simps) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1151 | thus "norm (S (Suc n)) \<le> r * norm (S n)" | 
| 35216 | 1152 | 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 | 1153 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1154 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1155 | |
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1156 | lemma summable_norm_exp: | 
| 31017 | 1157 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1158 | shows "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1159 | proof (rule summable_norm_comparison_test [OF exI, rule_format]) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1160 | show "summable (\<lambda>n. norm x^n /\<^sub>R fact n)" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1161 | by (rule summable_exp_generic) | 
| 53079 | 1162 | fix n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1163 | show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" | 
| 35216 | 1164 | 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 | 1165 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1166 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1167 | lemma summable_exp: | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1168 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1169 | shows "summable (\<lambda>n. inverse (fact n) * x^n)" | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1170 | using summable_exp_generic [where x=x] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1171 | by (simp add: scaleR_conv_of_real nonzero_of_real_inverse) | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1172 | |
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1173 | lemma exp_converges: "(\<lambda>n. x^n /\<^sub>R fact n) sums exp x" | 
| 53079 | 1174 | unfolding exp_def by (rule summable_exp_generic [THEN summable_sums]) | 
| 23043 | 1175 | |
| 41970 | 1176 | lemma exp_fdiffs: | 
| 60241 | 1177 |   "diffs (\<lambda>n. inverse (fact n)) = (\<lambda>n. inverse (fact n :: 'a::{real_normed_field,banach}))"
 | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1178 | by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1179 | del: mult_Suc of_nat_Suc) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1180 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1181 | lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))" | 
| 53079 | 1182 | by (simp add: diffs_def) | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1183 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1184 | lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)" | 
| 53079 | 1185 | unfolding exp_def scaleR_conv_of_real | 
| 1186 | apply (rule DERIV_cong) | |
| 1187 | apply (rule termdiffs [where K="of_real (1 + norm x)"]) | |
| 1188 | apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs) | |
| 1189 | apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+ | |
| 1190 | apply (simp del: of_real_add) | |
| 1191 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1192 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1193 | declare DERIV_exp[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 1194 | DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 1195 | |
| 58656 | 1196 | lemma norm_exp: "norm (exp x) \<le> exp (norm x)" | 
| 1197 | proof - | |
| 1198 | from summable_norm[OF summable_norm_exp, of x] | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1199 | have "norm (exp x) \<le> (\<Sum>n. inverse (fact n) * norm (x^n))" | 
| 58656 | 1200 | by (simp add: exp_def) | 
| 1201 | also have "\<dots> \<le> exp (norm x)" | |
| 1202 | using summable_exp_generic[of "norm x"] summable_norm_exp[of x] | |
| 1203 | by (auto simp: exp_def intro!: suminf_le norm_power_ineq) | |
| 1204 | finally show ?thesis . | |
| 1205 | qed | |
| 1206 | ||
| 1207 | lemma isCont_exp: | |
| 1208 |   fixes x::"'a::{real_normed_field,banach}"
 | |
| 1209 | shows "isCont exp x" | |
| 44311 | 1210 | by (rule DERIV_exp [THEN DERIV_isCont]) | 
| 1211 | ||
| 58656 | 1212 | lemma isCont_exp' [simp]: | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1213 |   fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
| 58656 | 1214 | shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a" | 
| 44311 | 1215 | by (rule isCont_o2 [OF _ isCont_exp]) | 
| 1216 | ||
| 1217 | lemma tendsto_exp [tendsto_intros]: | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1218 |   fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
| 61973 | 1219 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F" | 
| 44311 | 1220 | 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 | 1221 | |
| 53079 | 1222 | lemma continuous_exp [continuous_intros]: | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1223 |   fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
| 58656 | 1224 | shows "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 | 1225 | 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 | 1226 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 1227 | lemma continuous_on_exp [continuous_intros]: | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1228 |   fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
 | 
| 58656 | 1229 | shows "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 | 1230 | 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 | 1231 | |
| 53079 | 1232 | |
| 60758 | 1233 | subsubsection \<open>Properties of the Exponential Function\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1234 | |
| 23278 | 1235 | lemma exp_zero [simp]: "exp 0 = 1" | 
| 53079 | 1236 | unfolding exp_def by (simp add: scaleR_conv_of_real powser_zero) | 
| 23278 | 1237 | |
| 58656 | 1238 | lemma exp_series_add_commuting: | 
| 1239 |   fixes x y :: "'a::{real_normed_algebra_1, banach}"
 | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1240 | defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n" | 
| 58656 | 1241 | assumes comm: "x * y = y * x" | 
| 56213 | 1242 | shows "S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1243 | proof (induct n) | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1244 | case 0 | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1245 | show ?case | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1246 | unfolding S_def by simp | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1247 | next | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1248 | case (Suc n) | 
| 25062 | 1249 | 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 | 1250 | unfolding S_def by (simp del: mult_Suc) | 
| 25062 | 1251 | 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 | 1252 | by simp | 
| 58656 | 1253 | have S_comm: "\<And>n. S x n * y = y * S x n" | 
| 1254 | by (simp add: power_commuting_commutes comm S_def) | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1255 | |
| 25062 | 1256 | 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 | 1257 | by (simp only: times_S) | 
| 56213 | 1258 | also have "\<dots> = (x + y) * (\<Sum>i\<le>n. S x i * S y (n-i))" | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1259 | by (simp only: Suc) | 
| 56213 | 1260 | also have "\<dots> = x * (\<Sum>i\<le>n. S x i * S y (n-i)) | 
| 1261 | + y * (\<Sum>i\<le>n. S x i * S y (n-i))" | |
| 49962 
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
 webertj parents: 
47489diff
changeset | 1262 | by (rule distrib_right) | 
| 58656 | 1263 | also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n-i)) | 
| 1264 | + (\<Sum>i\<le>n. S x i * y * S y (n-i))" | |
| 1265 | by (simp add: setsum_right_distrib ac_simps S_comm) | |
| 1266 | also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n-i)) | |
| 56213 | 1267 | + (\<Sum>i\<le>n. S x i * (y * S y (n-i)))" | 
| 58656 | 1268 | by (simp add: ac_simps) | 
| 56213 | 1269 | also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i))) | 
| 1270 | + (\<Sum>i\<le>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 | 1271 | by (simp add: times_S Suc_diff_le) | 
| 56213 | 1272 | also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i))) = | 
| 1273 | (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 1274 | by (subst setsum_atMost_Suc_shift) simp | |
| 1275 | also have "(\<Sum>i\<le>n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) = | |
| 1276 | (\<Sum>i\<le>Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 1277 | by simp | |
| 1278 | also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n-i))) + | |
| 1279 | (\<Sum>i\<le>Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) = | |
| 1280 | (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n-i)))" | |
| 57418 | 1281 | by (simp only: setsum.distrib [symmetric] scaleR_left_distrib [symmetric] | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1282 | of_nat_add [symmetric]) simp | 
| 56213 | 1283 | also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n-i))" | 
| 23127 | 1284 | 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 | 1285 | finally show | 
| 56213 | 1286 | "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))" | 
| 35216 | 1287 | 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 | 1288 | qed | 
| 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1289 | |
| 58656 | 1290 | lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y" | 
| 53079 | 1291 | unfolding exp_def | 
| 58656 | 1292 | by (simp only: Cauchy_product summable_norm_exp exp_series_add_commuting) | 
| 1293 | ||
| 1294 | lemma exp_add: | |
| 1295 |   fixes x y::"'a::{real_normed_field,banach}"
 | |
| 1296 | shows "exp (x + y) = exp x * exp y" | |
| 1297 | by (rule exp_add_commuting) (simp add: ac_simps) | |
| 1298 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1299 | lemma exp_double: "exp(2 * z) = exp z ^ 2" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1300 | by (simp add: exp_add_commuting mult_2 power2_eq_square) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1301 | |
| 58656 | 1302 | lemmas mult_exp_exp = exp_add [symmetric] | 
| 29170 | 1303 | |
| 23241 | 1304 | lemma exp_of_real: "exp (of_real x) = of_real (exp x)" | 
| 53079 | 1305 | unfolding exp_def | 
| 1306 | apply (subst suminf_of_real) | |
| 1307 | apply (rule summable_exp_generic) | |
| 1308 | apply (simp add: scaleR_conv_of_real) | |
| 1309 | done | |
| 23241 | 1310 | |
| 59862 | 1311 | corollary exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>" | 
| 1312 | by (metis Reals_cases Reals_of_real exp_of_real) | |
| 1313 | ||
| 29170 | 1314 | lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0" | 
| 1315 | proof | |
| 58656 | 1316 | have "exp x * exp (- x) = 1" by (simp add: exp_add_commuting[symmetric]) | 
| 29170 | 1317 | also assume "exp x = 0" | 
| 1318 | finally show "False" by simp | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1319 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1320 | |
| 58656 | 1321 | lemma exp_minus_inverse: | 
| 1322 | shows "exp x * exp (- x) = 1" | |
| 1323 | by (simp add: exp_add_commuting[symmetric]) | |
| 1324 | ||
| 1325 | lemma exp_minus: | |
| 1326 |   fixes x :: "'a::{real_normed_field, banach}"
 | |
| 1327 | shows "exp (- x) = inverse (exp x)" | |
| 1328 | by (intro inverse_unique [symmetric] exp_minus_inverse) | |
| 1329 | ||
| 1330 | lemma exp_diff: | |
| 1331 |   fixes x :: "'a::{real_normed_field, banach}"
 | |
| 1332 | shows "exp (x - y) = exp x / exp y" | |
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 1333 | 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 | 1334 | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1335 | lemma exp_of_nat_mult: | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1336 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1337 | shows "exp(of_nat n * x) = exp(x) ^ n" | 
| 60867 | 1338 | by (induct n) (auto simp add: distrib_left exp_add mult.commute) | 
| 60162 | 1339 | |
| 1340 | corollary exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1341 | by (simp add: exp_of_nat_mult) | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1342 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1343 | lemma exp_setsum: "finite I \<Longrightarrow> exp(setsum f I) = setprod (\<lambda>x. exp(f x)) I" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1344 | by (induction I rule: finite_induct) (auto simp: exp_add_commuting mult.commute) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1345 | |
| 62379 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1346 | lemma exp_divide_power_eq: | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1347 |   fixes x:: "'a::{real_normed_field,banach}"
 | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1348 | assumes "n>0" shows "exp (x / of_nat n) ^ n = exp x" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1349 | using assms | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1350 | proof (induction n arbitrary: x) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1351 | case 0 then show ?case by simp | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1352 | next | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1353 | case (Suc n) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1354 | show ?case | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1355 | proof (cases "n=0") | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1356 | case True then show ?thesis by simp | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1357 | next | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1358 | case False | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1359 | then have [simp]: "x * of_nat n / (1 + of_nat n) / of_nat n = x / (1 + of_nat n)" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1360 | by simp | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1361 | have [simp]: "x / (1 + of_nat n) + x * of_nat n / (1 + of_nat n) = x" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1362 | apply (simp add: divide_simps) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1363 | using of_nat_eq_0_iff apply (fastforce simp: distrib_left) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1364 | done | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1365 | show ?thesis | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1366 | using Suc.IH [of "x * of_nat n / (1 + of_nat n)"] False | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1367 | by (simp add: exp_add [symmetric]) | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1368 | qed | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1369 | qed | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62347diff
changeset | 1370 | |
| 29167 | 1371 | |
| 60758 | 1372 | subsubsection \<open>Properties of the Exponential Function on Reals\<close> | 
| 1373 | ||
| 1374 | text \<open>Comparisons of @{term "exp x"} with zero.\<close>
 | |
| 1375 | ||
| 1376 | text\<open>Proof: because every exponential can be seen as a square.\<close> | |
| 29167 | 1377 | lemma exp_ge_zero [simp]: "0 \<le> exp (x::real)" | 
| 1378 | proof - | |
| 1379 | have "0 \<le> exp (x/2) * exp (x/2)" by simp | |
| 1380 | thus ?thesis by (simp add: exp_add [symmetric]) | |
| 1381 | qed | |
| 1382 | ||
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1383 | lemma exp_gt_zero [simp]: "0 < exp (x::real)" | 
| 53079 | 1384 | by (simp add: order_less_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1385 | |
| 29170 | 1386 | lemma not_exp_less_zero [simp]: "\<not> exp (x::real) < 0" | 
| 53079 | 1387 | by (simp add: not_less) | 
| 29170 | 1388 | |
| 1389 | lemma not_exp_le_zero [simp]: "\<not> exp (x::real) \<le> 0" | |
| 53079 | 1390 | by (simp add: not_le) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1391 | |
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1392 | lemma abs_exp_cancel [simp]: "\<bar>exp x::real\<bar> = exp x" | 
| 53079 | 1393 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1394 | |
| 60758 | 1395 | text \<open>Strict monotonicity of exponential.\<close> | 
| 29170 | 1396 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1397 | lemma exp_ge_add_one_self_aux: | 
| 54575 | 1398 | assumes "0 \<le> (x::real)" shows "1+x \<le> exp(x)" | 
| 1399 | using order_le_imp_less_or_eq [OF assms] | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1400 | proof | 
| 54575 | 1401 | assume "0 < x" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1402 | have "1+x \<le> (\<Sum>n<2. inverse (fact n) * x^n)" | 
| 54575 | 1403 | by (auto simp add: numeral_2_eq_2) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1404 | also have "... \<le> (\<Sum>n. inverse (fact n) * x^n)" | 
| 56213 | 1405 | apply (rule setsum_le_suminf [OF summable_exp]) | 
| 60758 | 1406 | using \<open>0 < x\<close> | 
| 54575 | 1407 | apply (auto simp add: zero_le_mult_iff) | 
| 1408 | done | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1409 | finally show "1+x \<le> exp x" | 
| 54575 | 1410 | by (simp add: exp_def) | 
| 1411 | next | |
| 1412 | assume "0 = x" | |
| 1413 | then show "1 + x \<le> exp x" | |
| 1414 | by auto | |
| 1415 | qed | |
| 29170 | 1416 | |
| 1417 | lemma exp_gt_one: "0 < (x::real) \<Longrightarrow> 1 < exp x" | |
| 1418 | proof - | |
| 1419 | assume x: "0 < x" | |
| 1420 | hence "1 < 1 + x" by simp | |
| 1421 | also from x have "1 + x \<le> exp x" | |
| 1422 | by (simp add: exp_ge_add_one_self_aux) | |
| 1423 | finally show ?thesis . | |
| 1424 | qed | |
| 1425 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1426 | lemma exp_less_mono: | 
| 23115 
4615b2078592
generalized exp to work over any complete field; new proof of exp_add
 huffman parents: 
23112diff
changeset | 1427 | fixes x y :: real | 
| 53079 | 1428 | assumes "x < y" | 
| 1429 | shows "exp x < exp y" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1430 | proof - | 
| 60758 | 1431 | from \<open>x < y\<close> have "0 < y - x" by simp | 
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1432 | hence "1 < exp (y - x)" by (rule exp_gt_one) | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1433 | hence "1 < exp y / exp x" by (simp only: exp_diff) | 
| 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 1434 | thus "exp x < exp y" by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1435 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1436 | |
| 53079 | 1437 | lemma exp_less_cancel: "exp (x::real) < exp y \<Longrightarrow> x < y" | 
| 54575 | 1438 | unfolding linorder_not_le [symmetric] | 
| 1439 | by (auto simp add: order_le_less exp_less_mono) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1440 | |
| 29170 | 1441 | lemma exp_less_cancel_iff [iff]: "exp (x::real) < exp y \<longleftrightarrow> x < y" | 
| 53079 | 1442 | by (auto intro: exp_less_mono exp_less_cancel) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1443 | |
| 29170 | 1444 | lemma exp_le_cancel_iff [iff]: "exp (x::real) \<le> exp y \<longleftrightarrow> x \<le> y" | 
| 53079 | 1445 | by (auto simp add: linorder_not_less [symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1446 | |
| 29170 | 1447 | lemma exp_inj_iff [iff]: "exp (x::real) = exp y \<longleftrightarrow> x = y" | 
| 53079 | 1448 | by (simp add: order_eq_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1449 | |
| 60758 | 1450 | text \<open>Comparisons of @{term "exp x"} with one.\<close>
 | 
| 29170 | 1451 | |
| 1452 | lemma one_less_exp_iff [simp]: "1 < exp (x::real) \<longleftrightarrow> 0 < x" | |
| 1453 | using exp_less_cancel_iff [where x=0 and y=x] by simp | |
| 1454 | ||
| 1455 | lemma exp_less_one_iff [simp]: "exp (x::real) < 1 \<longleftrightarrow> x < 0" | |
| 1456 | using exp_less_cancel_iff [where x=x and y=0] by simp | |
| 1457 | ||
| 1458 | lemma one_le_exp_iff [simp]: "1 \<le> exp (x::real) \<longleftrightarrow> 0 \<le> x" | |
| 1459 | using exp_le_cancel_iff [where x=0 and y=x] by simp | |
| 1460 | ||
| 1461 | lemma exp_le_one_iff [simp]: "exp (x::real) \<le> 1 \<longleftrightarrow> x \<le> 0" | |
| 1462 | using exp_le_cancel_iff [where x=x and y=0] by simp | |
| 1463 | ||
| 1464 | lemma exp_eq_one_iff [simp]: "exp (x::real) = 1 \<longleftrightarrow> x = 0" | |
| 1465 | using exp_inj_iff [where x=x and y=0] by simp | |
| 1466 | ||
| 53079 | 1467 | lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x::real) = y" | 
| 44755 | 1468 | proof (rule IVT) | 
| 1469 | assume "1 \<le> y" | |
| 1470 | hence "0 \<le> y - 1" by simp | |
| 1471 | hence "1 + (y - 1) \<le> exp (y - 1)" by (rule exp_ge_add_one_self_aux) | |
| 1472 | thus "y \<le> exp (y - 1)" by simp | |
| 1473 | qed (simp_all add: le_diff_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1474 | |
| 53079 | 1475 | lemma exp_total: "0 < (y::real) \<Longrightarrow> \<exists>x. exp x = y" | 
| 44755 | 1476 | proof (rule linorder_le_cases [of 1 y]) | 
| 53079 | 1477 | assume "1 \<le> y" | 
| 1478 | thus "\<exists>x. exp x = y" by (fast dest: lemma_exp_total) | |
| 44755 | 1479 | next | 
| 1480 | assume "0 < y" and "y \<le> 1" | |
| 1481 | hence "1 \<le> inverse y" by (simp add: one_le_inverse_iff) | |
| 1482 | then obtain x where "exp x = inverse y" by (fast dest: lemma_exp_total) | |
| 1483 | hence "exp (- x) = y" by (simp add: exp_minus) | |
| 1484 | thus "\<exists>x. exp x = y" .. | |
| 1485 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1486 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1487 | |
| 60758 | 1488 | subsection \<open>Natural Logarithm\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1489 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1490 | class ln = real_normed_algebra_1 + banach + | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1491 | fixes ln :: "'a \<Rightarrow> 'a" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1492 | assumes ln_one [simp]: "ln 1 = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1493 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1494 | definition powr :: "['a,'a] => 'a::ln" (infixr "powr" 80) | 
| 61799 | 1495 | \<comment> \<open>exponentation via ln and exp\<close> | 
| 60020 
065ecea354d0
Complex roots of unity. Better definition of ln for complex numbers. Used [code del] to stop code generation for powr.
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1496 | where [code del]: "x powr a \<equiv> if x = 0 then 0 else exp(a * ln x)" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1497 | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1498 | lemma powr_0 [simp]: "0 powr z = 0" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1499 | by (simp add: powr_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 1500 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1501 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1502 | instantiation real :: ln | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1503 | begin | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1504 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1505 | definition ln_real :: "real \<Rightarrow> real" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1506 | where "ln_real x = (THE u. exp u = x)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1507 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1508 | instance | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1509 | by intro_classes (simp add: ln_real_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1510 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1511 | end | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1512 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1513 | lemma powr_eq_0_iff [simp]: "w powr z = 0 \<longleftrightarrow> w = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1514 | by (simp add: powr_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1515 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1516 | lemma ln_exp [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1517 | fixes x::real shows "ln (exp x) = x" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1518 | by (simp add: ln_real_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1519 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1520 | lemma exp_ln [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1521 | fixes x::real shows "0 < x \<Longrightarrow> exp (ln x) = x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1522 | 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 | 1523 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1524 | lemma exp_ln_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1525 | fixes x::real shows "exp (ln x) = x \<longleftrightarrow> 0 < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1526 | by (metis exp_gt_zero exp_ln) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1527 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1528 | lemma ln_unique: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1529 | fixes x::real shows "exp y = x \<Longrightarrow> ln x = y" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1530 | by (erule subst, rule ln_exp) | 
| 29171 | 1531 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1532 | lemma ln_mult: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1533 | fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y" | 
| 53079 | 1534 | by (rule ln_unique) (simp add: exp_add) | 
| 29171 | 1535 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1536 | lemma ln_setprod: | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1537 | fixes f:: "'a => real" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1538 | shows | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 1539 | "\<lbrakk>finite I; \<And>i. i \<in> I \<Longrightarrow> f i > 0\<rbrakk> \<Longrightarrow> ln(setprod f I) = setsum (\<lambda>x. ln(f x)) I" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 1540 | by (induction I rule: finite_induct) (auto simp: ln_mult setprod_pos) | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 1541 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1542 | lemma ln_inverse: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1543 | fixes x::real shows "0 < x \<Longrightarrow> ln (inverse x) = - ln x" | 
| 53079 | 1544 | by (rule ln_unique) (simp add: exp_minus) | 
| 1545 | ||
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1546 | lemma ln_div: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1547 | fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y" | 
| 53079 | 1548 | by (rule ln_unique) (simp add: exp_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1549 | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1550 | lemma ln_realpow: "0 < x \<Longrightarrow> ln (x^n) = real n * ln x" | 
| 53079 | 1551 | by (rule ln_unique) (simp add: exp_real_of_nat_mult) | 
| 1552 | ||
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1553 | lemma ln_less_cancel_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1554 | fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y" | 
| 53079 | 1555 | by (subst exp_less_cancel_iff [symmetric]) simp | 
| 1556 | ||
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1557 | lemma ln_le_cancel_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1558 | fixes x::real shows "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 | 1559 | by (simp add: linorder_not_less [symmetric]) | 
| 29171 | 1560 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1561 | lemma ln_inj_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1562 | fixes x::real shows "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 | 1563 | by (simp add: order_eq_iff) | 
| 29171 | 1564 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1565 | lemma ln_add_one_self_le_self [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1566 | fixes x::real shows "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 | 1567 | apply (rule exp_le_cancel_iff [THEN iffD1]) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1568 | apply (simp add: exp_ge_add_one_self_aux) | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1569 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1570 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1571 | lemma ln_less_self [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1572 | fixes x::real shows "0 < x \<Longrightarrow> ln x < x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1573 | 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 | 1574 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1575 | lemma ln_ge_zero [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1576 | fixes x::real shows "1 \<le> x \<Longrightarrow> 0 \<le> ln x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1577 | 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 | 1578 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1579 | lemma ln_ge_zero_imp_ge_one: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1580 | fixes x::real shows "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 | 1581 | 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 | 1582 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1583 | lemma ln_ge_zero_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1584 | fixes x::real shows "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 | 1585 | 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 | 1586 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1587 | lemma ln_less_zero_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1588 | fixes x::real shows "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 | 1589 | 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 | 1590 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1591 | lemma ln_gt_zero: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1592 | fixes x::real shows "1 < x \<Longrightarrow> 0 < ln x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1593 | 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 | 1594 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1595 | lemma ln_gt_zero_imp_gt_one: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1596 | fixes x::real shows "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 | 1597 | 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 | 1598 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1599 | lemma ln_gt_zero_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1600 | fixes x::real shows "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 | 1601 | 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 | 1602 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1603 | lemma ln_eq_zero_iff [simp]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1604 | fixes x::real shows "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 | 1605 | using ln_inj_iff [of x 1] by simp | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1606 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1607 | lemma ln_less_zero: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1608 | fixes x::real shows "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 | 1609 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1610 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1611 | lemma ln_neg_is_const: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1612 | fixes x::real shows "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1613 | by (auto simp add: ln_real_def intro!: arg_cong[where f=The]) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1614 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1615 | lemma isCont_ln: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1616 | fixes x::real assumes "x \<noteq> 0" shows "isCont ln x" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1617 | proof cases | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1618 | assume "0 < x" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1619 | moreover then have "isCont ln (exp (ln x))" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1620 | by (intro isCont_inv_fun[where d="\<bar>x\<bar>" and f=exp]) auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1621 | ultimately show ?thesis | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1622 | by simp | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1623 | next | 
| 60758 | 1624 | assume "\<not> 0 < x" with \<open>x \<noteq> 0\<close> show "isCont ln x" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1625 | unfolding isCont_def | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1626 | by (subst filterlim_cong[OF _ refl, of _ "nhds (ln 0)" _ "\<lambda>_. ln 0"]) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1627 | (auto simp: ln_neg_is_const not_less eventually_at dist_real_def | 
| 58729 
e8ecc79aee43
add tendsto_const and tendsto_ident_at as simp and intro rules
 hoelzl parents: 
58710diff
changeset | 1628 | intro!: exI[of _ "\<bar>x\<bar>"]) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 1629 | qed | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1630 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1631 | lemma tendsto_ln [tendsto_intros]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1632 | fixes a::real shows | 
| 61973 | 1633 | "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F" | 
| 45915 | 1634 | by (rule isCont_tendsto_compose [OF isCont_ln]) | 
| 1635 | ||
| 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 | 1636 | lemma continuous_ln: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1637 | "continuous F f \<Longrightarrow> f (Lim F (\<lambda>x. x)) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. ln (f x :: real))" | 
| 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 | 1638 | 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 | 1639 | |
| 
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 | 1640 | lemma isCont_ln' [continuous_intros]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1641 | "continuous (at x) f \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow> continuous (at x) (\<lambda>x. ln (f x :: real))" | 
| 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 | 1642 | 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 | 1643 | |
| 
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 | 1644 | lemma continuous_within_ln [continuous_intros]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1645 | "continuous (at x within s) f \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. ln (f x :: real))" | 
| 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 | 1646 | 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 | 1647 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 1648 | lemma continuous_on_ln [continuous_intros]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1649 | "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. f x \<noteq> 0) \<Longrightarrow> continuous_on s (\<lambda>x. ln (f x :: real))" | 
| 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 | 1650 | 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 | 1651 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1652 | lemma DERIV_ln: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1653 | fixes x::real shows "0 < x \<Longrightarrow> DERIV ln x :> inverse x" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1654 | apply (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"]) | 
| 54576 | 1655 | apply (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln) | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 1656 | done | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 1657 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1658 | lemma DERIV_ln_divide: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1659 | fixes x::real shows "0 < x \<Longrightarrow> DERIV ln x :> 1 / x" | 
| 33667 | 1660 | by (rule DERIV_ln[THEN DERIV_cong], simp, simp add: divide_inverse) | 
| 1661 | ||
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 1662 | declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 1663 | DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 1664 | |
| 51527 | 1665 | |
| 53079 | 1666 | lemma ln_series: | 
| 1667 | assumes "0 < x" and "x < 2" | |
| 1668 | shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))" | |
| 1669 | (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 | 1670 | proof - | 
| 53079 | 1671 | 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 | 1672 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1673 | 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 | 1674 | proof (rule DERIV_isconst3[where x=x]) | 
| 53079 | 1675 | fix x :: real | 
| 1676 |     assume "x \<in> {0 <..< 2}"
 | |
| 1677 | hence "0 < x" and "x < 2" by auto | |
| 1678 | have "norm (1 - x) < 1" | |
| 60758 | 1679 | using \<open>0 < x\<close> and \<open>x < 2\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1680 | have "1 / x = 1 / (1 - (1 - x))" by auto | 
| 53079 | 1681 | also have "\<dots> = (\<Sum> n. (1 - x)^n)" | 
| 60758 | 1682 | using geometric_sums[OF \<open>norm (1 - x) < 1\<close>] by (rule sums_unique) | 
| 53079 | 1683 | also have "\<dots> = suminf (?f' x)" | 
| 1684 | unfolding power_mult_distrib[symmetric] | |
| 1685 | by (rule arg_cong[where f=suminf], rule arg_cong[where f="op ^"], auto) | |
| 1686 | finally have "DERIV ln x :> suminf (?f' x)" | |
| 60758 | 1687 | using DERIV_ln[OF \<open>0 < x\<close>] 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 | 1688 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1689 | have repos: "\<And> h x :: real. h - 1 + x = h + x - 1" by auto | 
| 53079 | 1690 | have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> | 
| 1691 | (\<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 | 1692 | proof (rule DERIV_power_series') | 
| 53079 | 1693 |       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
 | 
| 60758 | 1694 | using \<open>0 < x\<close> \<open>x < 2\<close> by auto | 
| 53079 | 1695 | fix x :: real | 
| 1696 |       assume "x \<in> {- 1<..<1}"
 | |
| 1697 | hence "norm (-x) < 1" by auto | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1698 | show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)" | 
| 53079 | 1699 | unfolding One_nat_def | 
| 60758 | 1700 | by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF \<open>norm (-x) < 1\<close>]) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1701 | qed | 
| 53079 | 1702 | hence "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)" | 
| 1703 | unfolding One_nat_def by auto | |
| 1704 | hence "DERIV (\<lambda>x. suminf (?f (x - 1))) x :> suminf (?f' x)" | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 1705 | unfolding DERIV_def repos . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 1706 | 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 | 1707 | 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 | 1708 | 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 | 1709 | qed (auto simp add: assms) | 
| 44289 | 1710 | 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 | 1711 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 1712 | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1713 | lemma exp_first_two_terms: | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1714 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1715 | shows "exp x = 1 + x + (\<Sum> n. inverse(fact (n+2)) * (x ^ (n+2)))" | 
| 50326 | 1716 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1717 | have "exp x = suminf (\<lambda>n. inverse(fact n) * (x^n))" | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1718 | by (simp add: exp_def scaleR_conv_of_real nonzero_of_real_inverse) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1719 | also from summable_exp have "... = (\<Sum> n. inverse(fact(n+2)) * (x ^ (n+2))) + | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1720 | (\<Sum> n::nat<2. inverse(fact n) * (x^n))" (is "_ = _ + ?a") | 
| 50326 | 1721 | by (rule suminf_split_initial_segment) | 
| 1722 | also have "?a = 1 + x" | |
| 1723 | by (simp add: numeral_2_eq_2) | |
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1724 | finally show ?thesis | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 1725 | by simp | 
| 50326 | 1726 | qed | 
| 1727 | ||
| 53079 | 1728 | lemma exp_bound: "0 <= (x::real) \<Longrightarrow> x <= 1 \<Longrightarrow> exp x <= 1 + x + x\<^sup>2" | 
| 50326 | 1729 | proof - | 
| 1730 | assume a: "0 <= x" | |
| 1731 | assume b: "x <= 1" | |
| 53079 | 1732 |   {
 | 
| 1733 | fix n :: nat | |
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1734 | have "(2::nat) * 2 ^ n \<le> fact (n + 2)" | 
| 53079 | 1735 | by (induct n) simp_all | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1736 | hence "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1737 | by (simp only: of_nat_le_iff) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1738 | hence "((2::real) * 2 ^ n) \<le> fact (n + 2)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1739 | unfolding of_nat_fact | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1740 | by (simp add: of_nat_mult of_nat_power) | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1741 | hence "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)" | 
| 50326 | 1742 | by (rule le_imp_inverse_le) simp | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1743 | hence "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n" | 
| 60867 | 1744 | by (simp add: power_inverse [symmetric]) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1745 | hence "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)" | 
| 50326 | 1746 | by (rule mult_mono) | 
| 56536 | 1747 | (rule mult_mono, simp_all add: power_le_one a b) | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1748 | hence "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 1749 | unfolding power_add by (simp add: ac_simps del: fact.simps) } | 
| 50326 | 1750 | note aux1 = this | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 1751 | have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))" | 
| 50326 | 1752 | by (intro sums_mult geometric_sums, simp) | 
| 53076 | 1753 | hence aux2: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2" | 
| 50326 | 1754 | by simp | 
| 53079 | 1755 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <= x\<^sup>2" | 
| 50326 | 1756 | proof - | 
| 53079 | 1757 | have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <= | 
| 1758 | suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))" | |
| 56213 | 1759 | apply (rule suminf_le) | 
| 50326 | 1760 | apply (rule allI, rule aux1) | 
| 1761 | apply (rule summable_exp [THEN summable_ignore_initial_segment]) | |
| 1762 | by (rule sums_summable, rule aux2) | |
| 53076 | 1763 | also have "... = x\<^sup>2" | 
| 50326 | 1764 | by (rule sums_unique [THEN sym], rule aux2) | 
| 1765 | finally show ?thesis . | |
| 1766 | qed | |
| 1767 | thus ?thesis unfolding exp_first_two_terms by auto | |
| 1768 | qed | |
| 1769 | ||
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1770 | corollary exp_half_le2: "exp(1/2) \<le> (2::real)" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1771 | using exp_bound [of "1/2"] | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1772 | by (simp add: field_simps) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1773 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1774 | corollary exp_le: "exp 1 \<le> (3::real)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1775 | using exp_bound [of 1] | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1776 | by (simp add: field_simps) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 1777 | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1778 | lemma exp_bound_half: "norm(z) \<le> 1/2 \<Longrightarrow> norm(exp z) \<le> 2" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1779 | by (blast intro: order_trans intro!: exp_half_le2 norm_exp) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1780 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1781 | lemma exp_bound_lemma: | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1782 | assumes "norm(z) \<le> 1/2" shows "norm(exp z) \<le> 1 + 2 * norm(z)" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1783 | proof - | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1784 | have n: "(norm z)\<^sup>2 \<le> norm z * 1" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1785 | unfolding power2_eq_square | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1786 | apply (rule mult_left_mono) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1787 | using assms | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1788 | apply auto | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1789 | done | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1790 | show ?thesis | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1791 | apply (rule order_trans [OF norm_exp]) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1792 | apply (rule order_trans [OF exp_bound]) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1793 | using assms n | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1794 | apply auto | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1795 | done | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1796 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1797 | |
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1798 | lemma real_exp_bound_lemma: | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1799 | fixes x :: real | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1800 | shows "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp(x) \<le> 1 + 2 * x" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1801 | using exp_bound_lemma [of x] | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1802 | by simp | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 1803 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1804 | lemma ln_one_minus_pos_upper_bound: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1805 | fixes x::real shows "0 <= x \<Longrightarrow> x < 1 \<Longrightarrow> ln (1 - x) <= - x" | 
| 50326 | 1806 | proof - | 
| 1807 | assume a: "0 <= (x::real)" and b: "x < 1" | |
| 53076 | 1808 | have "(1 - x) * (1 + x + x\<^sup>2) = (1 - x^3)" | 
| 50326 | 1809 | by (simp add: algebra_simps power2_eq_square power3_eq_cube) | 
| 1810 | also have "... <= 1" | |
| 1811 | by (auto simp add: a) | |
| 53076 | 1812 | 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 | 1813 | moreover have c: "0 < 1 + x + x\<^sup>2" | 
| 50326 | 1814 | by (simp add: add_pos_nonneg a) | 
| 53076 | 1815 | ultimately have "1 - x <= 1 / (1 + x + x\<^sup>2)" | 
| 50326 | 1816 | by (elim mult_imp_le_div_pos) | 
| 1817 | also have "... <= 1 / exp x" | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1818 | by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs | 
| 54576 | 1819 | real_sqrt_pow2_iff real_sqrt_power) | 
| 50326 | 1820 | also have "... = exp (-x)" | 
| 1821 | by (auto simp add: exp_minus divide_inverse) | |
| 1822 | finally have "1 - x <= exp (- x)" . | |
| 1823 | also have "1 - x = exp (ln (1 - x))" | |
| 54576 | 1824 | by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq) | 
| 50326 | 1825 | finally have "exp (ln (1 - x)) <= exp (- x)" . | 
| 1826 | thus ?thesis by (auto simp only: exp_le_cancel_iff) | |
| 1827 | qed | |
| 1828 | ||
| 1829 | lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x" | |
| 1830 | apply (case_tac "0 <= x") | |
| 1831 | apply (erule exp_ge_add_one_self_aux) | |
| 1832 | apply (case_tac "x <= -1") | |
| 1833 | apply (subgoal_tac "1 + x <= 0") | |
| 1834 | apply (erule order_trans) | |
| 1835 | apply simp | |
| 1836 | apply simp | |
| 1837 | apply (subgoal_tac "1 + x = exp(ln (1 + x))") | |
| 1838 | apply (erule ssubst) | |
| 1839 | apply (subst exp_le_cancel_iff) | |
| 1840 | apply (subgoal_tac "ln (1 - (- x)) <= - (- x)") | |
| 1841 | apply simp | |
| 1842 | apply (rule ln_one_minus_pos_upper_bound) | |
| 1843 | apply auto | |
| 1844 | done | |
| 1845 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1846 | lemma ln_one_plus_pos_lower_bound: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1847 | fixes x::real shows "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> x - x\<^sup>2 <= ln (1 + x)" | 
| 51527 | 1848 | proof - | 
| 1849 | assume a: "0 <= x" and b: "x <= 1" | |
| 53076 | 1850 | have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)" | 
| 51527 | 1851 | by (rule exp_diff) | 
| 53076 | 1852 | also have "... <= (1 + x + x\<^sup>2) / exp (x \<^sup>2)" | 
| 54576 | 1853 | by (metis a b divide_right_mono exp_bound exp_ge_zero) | 
| 53076 | 1854 | also have "... <= (1 + x + x\<^sup>2) / (1 + x\<^sup>2)" | 
| 56544 | 1855 | by (simp add: a divide_left_mono add_pos_nonneg) | 
| 51527 | 1856 | also from a have "... <= 1 + x" | 
| 1857 | by (simp add: field_simps add_strict_increasing zero_le_mult_iff) | |
| 53076 | 1858 | finally have "exp (x - x\<^sup>2) <= 1 + x" . | 
| 51527 | 1859 | also have "... = exp (ln (1 + x))" | 
| 1860 | proof - | |
| 1861 | from a have "0 < 1 + x" by auto | |
| 1862 | thus ?thesis | |
| 1863 | by (auto simp only: exp_ln_iff [THEN sym]) | |
| 1864 | qed | |
| 53076 | 1865 | finally have "exp (x - x\<^sup>2) <= exp (ln (1 + x))" . | 
| 54576 | 1866 | thus ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1867 | by (metis exp_le_cancel_iff) | 
| 51527 | 1868 | qed | 
| 1869 | ||
| 53079 | 1870 | lemma ln_one_minus_pos_lower_bound: | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 1871 | fixes x::real | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1872 | shows "0 <= x \<Longrightarrow> x <= (1 / 2) \<Longrightarrow> - x - 2 * x\<^sup>2 <= ln (1 - x)" | 
| 51527 | 1873 | proof - | 
| 1874 | assume a: "0 <= x" and b: "x <= (1 / 2)" | |
| 53079 | 1875 | from b have c: "x < 1" by auto | 
| 51527 | 1876 | then have "ln (1 - x) = - ln (1 + x / (1 - x))" | 
| 54576 | 1877 | apply (subst ln_inverse [symmetric]) | 
| 1878 | apply (simp add: field_simps) | |
| 1879 | apply (rule arg_cong [where f=ln]) | |
| 1880 | apply (simp add: field_simps) | |
| 1881 | done | |
| 51527 | 1882 | also have "- (x / (1 - x)) <= ..." | 
| 53079 | 1883 | proof - | 
| 51527 | 1884 | have "ln (1 + x / (1 - x)) <= x / (1 - x)" | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1885 | using a c by (intro ln_add_one_self_le_self) auto | 
| 51527 | 1886 | thus ?thesis | 
| 1887 | by auto | |
| 1888 | qed | |
| 1889 | also have "- (x / (1 - x)) = -x / (1 - x)" | |
| 1890 | by auto | |
| 1891 | finally have d: "- x / (1 - x) <= ln (1 - x)" . | |
| 1892 | have "0 < 1 - x" using a b by simp | |
| 53076 | 1893 | hence e: "-x - 2 * x\<^sup>2 <= - x / (1 - x)" | 
| 51527 | 1894 | using mult_right_le_one_le[of "x*x" "2*x"] a b | 
| 53079 | 1895 | by (simp add: field_simps power2_eq_square) | 
| 53076 | 1896 | from e d show "- x - 2 * x\<^sup>2 <= ln (1 - x)" | 
| 51527 | 1897 | by (rule order_trans) | 
| 1898 | qed | |
| 1899 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1900 | lemma ln_add_one_self_le_self2: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1901 | fixes x::real shows "-1 < x \<Longrightarrow> ln(1 + x) <= x" | 
| 51527 | 1902 | apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)", simp) | 
| 1903 | apply (subst ln_le_cancel_iff) | |
| 1904 | apply auto | |
| 53079 | 1905 | done | 
| 51527 | 1906 | |
| 1907 | lemma abs_ln_one_plus_x_minus_x_bound_nonneg: | |
| 61944 | 1908 | fixes x::real shows "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= x\<^sup>2" | 
| 51527 | 1909 | proof - | 
| 1910 | assume x: "0 <= x" | |
| 1911 | assume x1: "x <= 1" | |
| 1912 | from x have "ln (1 + x) <= x" | |
| 1913 | by (rule ln_add_one_self_le_self) | |
| 53079 | 1914 | then have "ln (1 + x) - x <= 0" | 
| 51527 | 1915 | by simp | 
| 61944 | 1916 | then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)" | 
| 51527 | 1917 | by (rule abs_of_nonpos) | 
| 53079 | 1918 | also have "... = x - ln (1 + x)" | 
| 51527 | 1919 | by simp | 
| 53076 | 1920 | also have "... <= x\<^sup>2" | 
| 51527 | 1921 | proof - | 
| 53076 | 1922 | from x x1 have "x - x\<^sup>2 <= ln (1 + x)" | 
| 51527 | 1923 | by (intro ln_one_plus_pos_lower_bound) | 
| 1924 | thus ?thesis | |
| 1925 | by simp | |
| 1926 | qed | |
| 1927 | finally show ?thesis . | |
| 1928 | qed | |
| 1929 | ||
| 1930 | lemma abs_ln_one_plus_x_minus_x_bound_nonpos: | |
| 61944 | 1931 | fixes x::real shows "-(1 / 2) <= x \<Longrightarrow> x <= 0 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= 2 * x\<^sup>2" | 
| 51527 | 1932 | proof - | 
| 1933 | assume a: "-(1 / 2) <= x" | |
| 1934 | assume b: "x <= 0" | |
| 61944 | 1935 | have "\<bar>ln (1 + x) - x\<bar> = x - ln(1 - (-x))" | 
| 51527 | 1936 | apply (subst abs_of_nonpos) | 
| 1937 | apply simp | |
| 1938 | apply (rule ln_add_one_self_le_self2) | |
| 1939 | using a apply auto | |
| 1940 | done | |
| 53076 | 1941 | also have "... <= 2 * x\<^sup>2" | 
| 1942 | apply (subgoal_tac "- (-x) - 2 * (-x)\<^sup>2 <= ln (1 - (-x))") | |
| 51527 | 1943 | apply (simp add: algebra_simps) | 
| 1944 | apply (rule ln_one_minus_pos_lower_bound) | |
| 1945 | using a b apply auto | |
| 1946 | done | |
| 1947 | finally show ?thesis . | |
| 1948 | qed | |
| 1949 | ||
| 1950 | lemma abs_ln_one_plus_x_minus_x_bound: | |
| 61944 | 1951 | fixes x::real shows "\<bar>x\<bar> <= 1 / 2 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= 2 * x\<^sup>2" | 
| 51527 | 1952 | apply (case_tac "0 <= x") | 
| 1953 | apply (rule order_trans) | |
| 1954 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg) | |
| 1955 | apply auto | |
| 1956 | apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos) | |
| 1957 | apply auto | |
| 53079 | 1958 | done | 
| 1959 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1960 | lemma ln_x_over_x_mono: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1961 | fixes x::real shows "exp 1 <= x \<Longrightarrow> x <= y \<Longrightarrow> (ln y / y) <= (ln x / x)" | 
| 51527 | 1962 | proof - | 
| 1963 | assume x: "exp 1 <= x" "x <= y" | |
| 1964 | moreover have "0 < exp (1::real)" by simp | |
| 1965 | ultimately have a: "0 < x" and b: "0 < y" | |
| 1966 | by (fast intro: less_le_trans order_trans)+ | |
| 1967 | have "x * ln y - x * ln x = x * (ln y - ln x)" | |
| 1968 | by (simp add: algebra_simps) | |
| 1969 | also have "... = x * ln(y / x)" | |
| 1970 | by (simp only: ln_div a b) | |
| 1971 | also have "y / x = (x + (y - x)) / x" | |
| 1972 | by simp | |
| 1973 | also have "... = 1 + (y - x) / x" | |
| 1974 | using x a by (simp add: field_simps) | |
| 1975 | also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)" | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 1976 | using x a | 
| 56571 
f4635657d66f
added divide_nonneg_nonneg and co; made it a simp rule
 hoelzl parents: 
56544diff
changeset | 1977 | by (intro mult_left_mono ln_add_one_self_le_self) simp_all | 
| 51527 | 1978 | also have "... = y - x" using a by simp | 
| 1979 | also have "... = (y - x) * ln (exp 1)" by simp | |
| 1980 | also have "... <= (y - x) * ln x" | |
| 1981 | apply (rule mult_left_mono) | |
| 1982 | apply (subst ln_le_cancel_iff) | |
| 1983 | apply fact | |
| 1984 | apply (rule a) | |
| 1985 | apply (rule x) | |
| 1986 | using x apply simp | |
| 1987 | done | |
| 1988 | also have "... = y * ln x - x * ln x" | |
| 1989 | by (rule left_diff_distrib) | |
| 1990 | finally have "x * ln y <= y * ln x" | |
| 1991 | by arith | |
| 1992 | then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps) | |
| 1993 | also have "... = y * (ln x / x)" by simp | |
| 1994 | finally show ?thesis using b by (simp add: field_simps) | |
| 1995 | qed | |
| 1996 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1997 | lemma ln_le_minus_one: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 1998 | fixes x::real shows "0 < x \<Longrightarrow> ln x \<le> x - 1" | 
| 51527 | 1999 | using exp_ge_add_one_self[of "ln x"] by simp | 
| 2000 | ||
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2001 | corollary ln_diff_le: | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2002 | fixes x::real | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2003 | shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2004 | by (simp add: ln_div [symmetric] diff_divide_distrib ln_le_minus_one) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2005 | |
| 51527 | 2006 | lemma ln_eq_minus_one: | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2007 | fixes x::real | 
| 53079 | 2008 | assumes "0 < x" "ln x = x - 1" | 
| 2009 | shows "x = 1" | |
| 51527 | 2010 | proof - | 
| 53079 | 2011 | let ?l = "\<lambda>y. ln y - y + 1" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2012 | have D: "\<And>x::real. 0 < x \<Longrightarrow> DERIV ?l x :> (1 / x - 1)" | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2013 | by (auto intro!: derivative_eq_intros) | 
| 51527 | 2014 | |
| 2015 | show ?thesis | |
| 2016 | proof (cases rule: linorder_cases) | |
| 2017 | assume "x < 1" | |
| 60758 | 2018 | from dense[OF \<open>x < 1\<close>] obtain a where "x < a" "a < 1" by blast | 
| 2019 | from \<open>x < a\<close> have "?l x < ?l a" | |
| 51527 | 2020 | proof (rule DERIV_pos_imp_increasing, safe) | 
| 53079 | 2021 | fix y | 
| 2022 | assume "x \<le> y" "y \<le> a" | |
| 60758 | 2023 | with \<open>0 < x\<close> \<open>a < 1\<close> have "0 < 1 / y - 1" "0 < y" | 
| 51527 | 2024 | by (auto simp: field_simps) | 
| 61762 
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
 paulson <lp15@cam.ac.uk> parents: 
61738diff
changeset | 2025 | with D show "\<exists>z. DERIV ?l y :> z \<and> 0 < z" by blast | 
| 51527 | 2026 | qed | 
| 2027 | also have "\<dots> \<le> 0" | |
| 60758 | 2028 | using ln_le_minus_one \<open>0 < x\<close> \<open>x < a\<close> by (auto simp: field_simps) | 
| 51527 | 2029 | finally show "x = 1" using assms by auto | 
| 2030 | next | |
| 2031 | assume "1 < x" | |
| 53079 | 2032 | from dense[OF this] obtain a where "1 < a" "a < x" by blast | 
| 60758 | 2033 | from \<open>a < x\<close> have "?l x < ?l a" | 
| 51527 | 2034 | proof (rule DERIV_neg_imp_decreasing, safe) | 
| 53079 | 2035 | fix y | 
| 2036 | assume "a \<le> y" "y \<le> x" | |
| 60758 | 2037 | with \<open>1 < a\<close> have "1 / y - 1 < 0" "0 < y" | 
| 51527 | 2038 | by (auto simp: field_simps) | 
| 2039 | with D show "\<exists>z. DERIV ?l y :> z \<and> z < 0" | |
| 2040 | by blast | |
| 2041 | qed | |
| 2042 | also have "\<dots> \<le> 0" | |
| 60758 | 2043 | using ln_le_minus_one \<open>1 < a\<close> by (auto simp: field_simps) | 
| 51527 | 2044 | finally show "x = 1" using assms by auto | 
| 53079 | 2045 | next | 
| 2046 | assume "x = 1" | |
| 2047 | then show ?thesis by simp | |
| 2048 | qed | |
| 51527 | 2049 | qed | 
| 2050 | ||
| 61973 | 2051 | lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot" | 
| 50326 | 2052 | unfolding tendsto_Zfun_iff | 
| 2053 | proof (rule ZfunI, simp add: eventually_at_bot_dense) | |
| 2054 | fix r :: real assume "0 < r" | |
| 53079 | 2055 |   {
 | 
| 2056 | fix x | |
| 2057 | assume "x < ln r" | |
| 50326 | 2058 | then have "exp x < exp (ln r)" | 
| 2059 | by simp | |
| 60758 | 2060 | with \<open>0 < r\<close> have "exp x < r" | 
| 53079 | 2061 | by simp | 
| 2062 | } | |
| 50326 | 2063 | then show "\<exists>k. \<forall>n<k. exp n < r" by auto | 
| 2064 | qed | |
| 2065 | ||
| 2066 | 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 | 2067 | 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 | 2068 | (auto intro: eventually_gt_at_top) | 
| 50326 | 2069 | |
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2070 | lemma lim_exp_minus_1: | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2071 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 61973 | 2072 | shows "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)" | 
| 59613 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2073 | proof - | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2074 | have "((\<lambda>z::'a. exp(z) - 1) has_field_derivative 1) (at 0)" | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2075 | by (intro derivative_eq_intros | simp)+ | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2076 | then show ?thesis | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2077 | by (simp add: Deriv.DERIV_iff2) | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2078 | qed | 
| 
7103019278f0
The function frac. Various lemmas about limits, series, the exp function, etc.
 paulson <lp15@cam.ac.uk> parents: 
59587diff
changeset | 2079 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2080 | lemma ln_at_0: "LIM x at_right 0. ln (x::real) :> 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 | 2081 | 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 | 2082 | (auto simp: eventually_at_filter) | 
| 50326 | 2083 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2084 | lemma ln_at_top: "LIM x at_top. ln (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 | 2085 | 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 | 2086 | (auto intro: eventually_gt_at_top) | 
| 50326 | 2087 | |
| 60721 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2088 | lemma filtermap_ln_at_top: "filtermap (ln::real \<Rightarrow> real) at_top = at_top" | 
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2089 | by (intro filtermap_fun_inverse[of exp] exp_at_top ln_at_top) auto | 
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2090 | |
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2091 | lemma filtermap_exp_at_top: "filtermap (exp::real \<Rightarrow> real) at_top = at_top" | 
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2092 | by (intro filtermap_fun_inverse[of ln] exp_at_top ln_at_top) | 
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2093 | (auto simp: eventually_at_top_dense) | 
| 
c1b7793c23a3
generalized filtermap_homeomorph to filtermap_fun_inverse; add eventually_at_top/bot_not_equal
 hoelzl parents: 
60688diff
changeset | 2094 | |
| 61973 | 2095 | lemma tendsto_power_div_exp_0: "((\<lambda>x. x ^ k / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2096 | proof (induct k) | 
| 53079 | 2097 | case 0 | 
| 61973 | 2098 | show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top" | 
| 50347 | 2099 | by (simp add: inverse_eq_divide[symmetric]) | 
| 2100 | (metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono | |
| 2101 | at_top_le_at_infinity order_refl) | |
| 2102 | next | |
| 2103 | case (Suc k) | |
| 2104 | show ?case | |
| 2105 | proof (rule lhospital_at_top_at_top) | |
| 2106 | show "eventually (\<lambda>x. DERIV (\<lambda>x. x ^ Suc k) x :> (real (Suc k) * x^k)) at_top" | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2107 | by eventually_elim (intro derivative_eq_intros, auto) | 
| 50347 | 2108 | show "eventually (\<lambda>x. DERIV exp x :> exp x) at_top" | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2109 | by eventually_elim auto | 
| 50347 | 2110 | show "eventually (\<lambda>x. exp x \<noteq> 0) at_top" | 
| 2111 | by auto | |
| 2112 | from tendsto_mult[OF tendsto_const Suc, of "real (Suc k)"] | |
| 61973 | 2113 | show "((\<lambda>x. real (Suc k) * x ^ k / exp x) \<longlongrightarrow> 0) at_top" | 
| 50347 | 2114 | by simp | 
| 2115 | qed (rule exp_at_top) | |
| 2116 | qed | |
| 2117 | ||
| 51527 | 2118 | |
| 53079 | 2119 | definition log :: "[real,real] => real" | 
| 61799 | 2120 |   \<comment> \<open>logarithm of @{term x} to base @{term a}\<close>
 | 
| 53079 | 2121 | where "log a x = ln x / ln a" | 
| 51527 | 2122 | |
| 2123 | ||
| 2124 | lemma tendsto_log [tendsto_intros]: | |
| 61973 | 2125 | "\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F; 0 < a; a \<noteq> 1; 0 < b\<rbrakk> \<Longrightarrow> ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F" | 
| 51527 | 2126 | unfolding log_def by (intro tendsto_intros) auto | 
| 2127 | ||
| 2128 | lemma continuous_log: | |
| 53079 | 2129 | assumes "continuous F f" | 
| 2130 | and "continuous F g" | |
| 2131 | and "0 < f (Lim F (\<lambda>x. x))" | |
| 2132 | and "f (Lim F (\<lambda>x. x)) \<noteq> 1" | |
| 2133 | and "0 < g (Lim F (\<lambda>x. x))" | |
| 51527 | 2134 | shows "continuous F (\<lambda>x. log (f x) (g x))" | 
| 2135 | using assms unfolding continuous_def by (rule tendsto_log) | |
| 2136 | ||
| 2137 | lemma continuous_at_within_log[continuous_intros]: | |
| 53079 | 2138 | assumes "continuous (at a within s) f" | 
| 2139 | and "continuous (at a within s) g" | |
| 2140 | and "0 < f a" | |
| 2141 | and "f a \<noteq> 1" | |
| 2142 | and "0 < g a" | |
| 51527 | 2143 | shows "continuous (at a within s) (\<lambda>x. log (f x) (g x))" | 
| 2144 | using assms unfolding continuous_within by (rule tendsto_log) | |
| 2145 | ||
| 2146 | lemma isCont_log[continuous_intros, simp]: | |
| 2147 | assumes "isCont f a" "isCont g a" "0 < f a" "f a \<noteq> 1" "0 < g a" | |
| 2148 | shows "isCont (\<lambda>x. log (f x) (g x)) a" | |
| 2149 | using assms unfolding continuous_at by (rule tendsto_log) | |
| 2150 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2151 | lemma continuous_on_log[continuous_intros]: | 
| 53079 | 2152 | assumes "continuous_on s f" "continuous_on s g" | 
| 2153 | and "\<forall>x\<in>s. 0 < f x" "\<forall>x\<in>s. f x \<noteq> 1" "\<forall>x\<in>s. 0 < g x" | |
| 51527 | 2154 | shows "continuous_on s (\<lambda>x. log (f x) (g x))" | 
| 2155 | using assms unfolding continuous_on_def by (fast intro: tendsto_log) | |
| 2156 | ||
| 2157 | lemma powr_one_eq_one [simp]: "1 powr a = 1" | |
| 53079 | 2158 | by (simp add: powr_def) | 
| 51527 | 2159 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2160 | lemma powr_zero_eq_one [simp]: "x powr 0 = (if x=0 then 0 else 1)" | 
| 53079 | 2161 | by (simp add: powr_def) | 
| 51527 | 2162 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2163 | lemma powr_one_gt_zero_iff [simp]: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2164 | fixes x::real shows "(x powr 1 = x) = (0 \<le> x)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2165 | by (auto simp: powr_def) | 
| 51527 | 2166 | declare powr_one_gt_zero_iff [THEN iffD2, simp] | 
| 2167 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2168 | lemma powr_mult: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2169 | fixes x::real shows "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)" | 
| 53079 | 2170 | by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left) | 
| 51527 | 2171 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2172 | lemma powr_ge_pzero [simp]: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2173 | fixes x::real shows "0 <= x powr y" | 
| 53079 | 2174 | by (simp add: powr_def) | 
| 51527 | 2175 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2176 | lemma powr_divide: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2177 | fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)" | 
| 53079 | 2178 | apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult) | 
| 2179 | apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse) | |
| 2180 | done | |
| 51527 | 2181 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2182 | lemma powr_divide2: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2183 | fixes x::real shows "x powr a / x powr b = x powr (a - b)" | 
| 51527 | 2184 | apply (simp add: powr_def) | 
| 2185 | apply (subst exp_diff [THEN sym]) | |
| 2186 | apply (simp add: left_diff_distrib) | |
| 53079 | 2187 | done | 
| 51527 | 2188 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2189 | lemma powr_add: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2190 | fixes x::real shows "x powr (a + b) = (x powr a) * (x powr b)" | 
| 53079 | 2191 | by (simp add: powr_def exp_add [symmetric] distrib_right) | 
| 2192 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2193 | lemma powr_mult_base: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2194 | fixes x::real shows "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)" | 
| 53079 | 2195 | using assms by (auto simp: powr_add) | 
| 51527 | 2196 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2197 | lemma powr_powr: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2198 | fixes x::real shows "(x powr a) powr b = x powr (a * b)" | 
| 53079 | 2199 | by (simp add: powr_def) | 
| 51527 | 2200 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2201 | lemma powr_powr_swap: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2202 | fixes x::real shows "(x powr a) powr b = (x powr b) powr a" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 2203 | by (simp add: powr_powr mult.commute) | 
| 51527 | 2204 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2205 | lemma powr_minus: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2206 | fixes x::real shows "x powr (-a) = inverse (x powr a)" | 
| 53079 | 2207 | by (simp add: powr_def exp_minus [symmetric]) | 
| 51527 | 2208 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2209 | lemma powr_minus_divide: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2210 | fixes x::real shows "x powr (-a) = 1/(x powr a)" | 
| 53079 | 2211 | by (simp add: divide_inverse powr_minus) | 
| 2212 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2213 | lemma divide_powr_uminus: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2214 | fixes a::real shows "a / b powr c = a * b powr (- c)" | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2215 | by (simp add: powr_minus_divide) | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2216 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2217 | lemma powr_less_mono: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2218 | fixes x::real shows "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b" | 
| 53079 | 2219 | by (simp add: powr_def) | 
| 2220 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2221 | lemma powr_less_cancel: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2222 | fixes x::real shows "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b" | 
| 53079 | 2223 | by (simp add: powr_def) | 
| 2224 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2225 | lemma powr_less_cancel_iff [simp]: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2226 | fixes x::real shows "1 < x \<Longrightarrow> (x powr a < x powr b) = (a < b)" | 
| 53079 | 2227 | by (blast intro: powr_less_cancel powr_less_mono) | 
| 2228 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2229 | lemma powr_le_cancel_iff [simp]: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2230 | fixes x::real shows "1 < x \<Longrightarrow> (x powr a \<le> x powr b) = (a \<le> b)" | 
| 53079 | 2231 | by (simp add: linorder_not_less [symmetric]) | 
| 51527 | 2232 | |
| 2233 | lemma log_ln: "ln x = log (exp(1)) x" | |
| 53079 | 2234 | by (simp add: log_def) | 
| 2235 | ||
| 2236 | lemma DERIV_log: | |
| 2237 | assumes "x > 0" | |
| 2238 | shows "DERIV (\<lambda>y. log b y) x :> 1 / (ln b * x)" | |
| 51527 | 2239 | proof - | 
| 2240 | def lb \<equiv> "1 / ln b" | |
| 2241 | moreover have "DERIV (\<lambda>y. lb * ln y) x :> lb / x" | |
| 60758 | 2242 | using \<open>x > 0\<close> by (auto intro!: derivative_eq_intros) | 
| 51527 | 2243 | ultimately show ?thesis | 
| 2244 | by (simp add: log_def) | |
| 2245 | qed | |
| 2246 | ||
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2247 | lemmas DERIV_log[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 2248 | DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2249 | |
| 53079 | 2250 | lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x" | 
| 2251 | by (simp add: powr_def log_def) | |
| 2252 | ||
| 2253 | lemma log_powr_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a (a powr y) = y" | |
| 2254 | by (simp add: log_def powr_def) | |
| 2255 | ||
| 2256 | lemma log_mult: | |
| 2257 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> | |
| 2258 | log a (x * y) = log a x + log a y" | |
| 2259 | by (simp add: log_def ln_mult divide_inverse distrib_right) | |
| 2260 | ||
| 2261 | lemma log_eq_div_ln_mult_log: | |
| 2262 | "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> | |
| 2263 | log a x = (ln b/ln a) * log b x" | |
| 2264 | by (simp add: log_def divide_inverse) | |
| 51527 | 2265 | |
| 60758 | 2266 | text\<open>Base 10 logarithms\<close> | 
| 53079 | 2267 | lemma log_base_10_eq1: "0 < x \<Longrightarrow> log 10 x = (ln (exp 1) / ln 10) * ln x" | 
| 2268 | by (simp add: log_def) | |
| 2269 | ||
| 2270 | lemma log_base_10_eq2: "0 < x \<Longrightarrow> log 10 x = (log 10 (exp 1)) * ln x" | |
| 2271 | by (simp add: log_def) | |
| 51527 | 2272 | |
| 2273 | lemma log_one [simp]: "log a 1 = 0" | |
| 53079 | 2274 | by (simp add: log_def) | 
| 51527 | 2275 | |
| 2276 | lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1" | |
| 53079 | 2277 | by (simp add: log_def) | 
| 2278 | ||
| 2279 | lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x" | |
| 2280 | apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1]) | |
| 2281 | apply (simp add: log_mult [symmetric]) | |
| 2282 | done | |
| 2283 | ||
| 2284 | 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" | |
| 2285 | by (simp add: log_mult divide_inverse log_inverse) | |
| 51527 | 2286 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2287 | lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> (x::real) \<noteq> 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2288 | by (simp add: powr_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2289 | |
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2290 | lemma log_add_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log b x + y = log b (x * b powr y)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2291 | and add_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> y + log b x = log b (b powr y * x)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2292 | and log_minus_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log b x - y = log b (x * b powr -y)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2293 | and minus_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> y - log b x = log b (b powr y / x)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2294 | by (simp_all add: log_mult log_divide) | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2295 | |
| 51527 | 2296 | lemma log_less_cancel_iff [simp]: | 
| 53079 | 2297 | "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y" | 
| 2298 | apply safe | |
| 2299 | apply (rule_tac [2] powr_less_cancel) | |
| 2300 | apply (drule_tac a = "log a x" in powr_less_mono, auto) | |
| 2301 | done | |
| 2302 | ||
| 2303 | lemma log_inj: | |
| 2304 | assumes "1 < b" | |
| 2305 |   shows "inj_on (log b) {0 <..}"
 | |
| 51527 | 2306 | proof (rule inj_onI, simp) | 
| 53079 | 2307 | fix x y | 
| 2308 | assume pos: "0 < x" "0 < y" and *: "log b x = log b y" | |
| 51527 | 2309 | show "x = y" | 
| 2310 | proof (cases rule: linorder_cases) | |
| 53079 | 2311 | assume "x = y" | 
| 2312 | then show ?thesis by simp | |
| 2313 | next | |
| 51527 | 2314 | assume "x < y" hence "log b x < log b y" | 
| 60758 | 2315 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2316 | then show ?thesis using * by simp | 
| 51527 | 2317 | next | 
| 2318 | assume "y < x" hence "log b y < log b x" | |
| 60758 | 2319 | using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp | 
| 53079 | 2320 | then show ?thesis using * by simp | 
| 2321 | qed | |
| 51527 | 2322 | qed | 
| 2323 | ||
| 2324 | lemma log_le_cancel_iff [simp]: | |
| 53079 | 2325 | "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (log a x \<le> log a y) = (x \<le> y)" | 
| 2326 | by (simp add: linorder_not_less [symmetric]) | |
| 51527 | 2327 | |
| 2328 | lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x" | |
| 2329 | using log_less_cancel_iff[of a 1 x] by simp | |
| 2330 | ||
| 2331 | lemma zero_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 \<le> log a x \<longleftrightarrow> 1 \<le> x" | |
| 2332 | using log_le_cancel_iff[of a 1 x] by simp | |
| 2333 | ||
| 2334 | lemma log_less_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 0 \<longleftrightarrow> x < 1" | |
| 2335 | using log_less_cancel_iff[of a x 1] by simp | |
| 2336 | ||
| 2337 | lemma log_le_zero_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 0 \<longleftrightarrow> x \<le> 1" | |
| 2338 | using log_le_cancel_iff[of a x 1] by simp | |
| 2339 | ||
| 2340 | lemma one_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 < log a x \<longleftrightarrow> a < x" | |
| 2341 | using log_less_cancel_iff[of a a x] by simp | |
| 2342 | ||
| 2343 | lemma one_le_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> log a x \<longleftrightarrow> a \<le> x" | |
| 2344 | using log_le_cancel_iff[of a a x] by simp | |
| 2345 | ||
| 2346 | lemma log_less_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x < 1 \<longleftrightarrow> x < a" | |
| 2347 | using log_less_cancel_iff[of a x a] by simp | |
| 2348 | ||
| 2349 | lemma log_le_one_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> log a x \<le> 1 \<longleftrightarrow> x \<le> a" | |
| 2350 | using log_le_cancel_iff[of a x a] by simp | |
| 2351 | ||
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2352 | lemma le_log_iff: | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2353 | assumes "1 < b" "x > 0" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2354 | shows "y \<le> log b x \<longleftrightarrow> b powr y \<le> (x::real)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2355 | using assms | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2356 | apply auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2357 | apply (metis (no_types, hide_lams) less_irrefl less_le_trans linear powr_le_cancel_iff | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2358 | powr_log_cancel zero_less_one) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2359 | apply (metis not_less order.trans order_refl powr_le_cancel_iff powr_log_cancel zero_le_one) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2360 | done | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2361 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2362 | lemma less_log_iff: | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2363 | assumes "1 < b" "x > 0" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2364 | shows "y < log b x \<longleftrightarrow> b powr y < x" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2365 | by (metis assms dual_order.strict_trans less_irrefl powr_less_cancel_iff | 
| 58984 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2366 | powr_log_cancel zero_less_one) | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2367 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2368 | lemma | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2369 | assumes "1 < b" "x > 0" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2370 | shows log_less_iff: "log b x < y \<longleftrightarrow> x < b powr y" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2371 | and log_le_iff: "log b x \<le> y \<longleftrightarrow> x \<le> b powr y" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2372 | using le_log_iff[OF assms, of y] less_log_iff[OF assms, of y] | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2373 | by auto | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2374 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2375 | lemmas powr_le_iff = le_log_iff[symmetric] | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2376 | and powr_less_iff = le_log_iff[symmetric] | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2377 | and less_powr_iff = log_less_iff[symmetric] | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2378 | and le_powr_iff = log_le_iff[symmetric] | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2379 | |
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2380 | lemma | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2381 | floor_log_eq_powr_iff: "x > 0 \<Longrightarrow> b > 1 \<Longrightarrow> \<lfloor>log b x\<rfloor> = k \<longleftrightarrow> b powr k \<le> x \<and> x < b powr (k + 1)" | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2382 | by (auto simp add: floor_eq_iff powr_le_iff less_powr_iff) | 
| 
ae0c56c485ae
added lemmas: convert between powr and log in comparisons, pull log out of addition/subtraction
 immler parents: 
58981diff
changeset | 2383 | |
| 51527 | 2384 | lemma powr_realpow: "0 < x ==> x powr (real n) = x^n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2385 | by (induct n) (simp_all add: ac_simps powr_add of_nat_Suc) | 
| 51527 | 2386 | |
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 2387 | lemma powr_numeral: "0 < x \<Longrightarrow> x powr (numeral n :: real) = x ^ (numeral n)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2388 | by (metis of_nat_numeral powr_realpow) | 
| 52139 | 2389 | |
| 62049 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2390 | lemma powr_real_of_int: | 
| 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2391 | "x > 0 \<Longrightarrow> x powr real_of_int n = (if n \<ge> 0 then x ^ nat n else inverse (x ^ nat (-n)))" | 
| 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2392 | using powr_realpow[of x "nat n"] powr_realpow[of x "nat (-n)"] | 
| 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2393 | by (auto simp: field_simps powr_minus) | 
| 
b0f941e207cf
Added lots of material on infinite sums, convergence radii, harmonic numbers, Gamma function
 eberlm parents: 
61976diff
changeset | 2394 | |
| 57180 | 2395 | lemma powr2_sqrt[simp]: "0 < x \<Longrightarrow> sqrt x powr 2 = x" | 
| 61738 
c4f6031f1310
New material about paths, winding numbers, etc. Added lemmas to divide_const_simps. Misc tuning.
 paulson <lp15@cam.ac.uk> parents: 
61694diff
changeset | 2396 | by(simp add: powr_numeral) | 
| 57180 | 2397 | |
| 51527 | 2398 | lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0 else x powr (real n))" | 
| 2399 | apply (case_tac "x = 0", simp, simp) | |
| 2400 | apply (rule powr_realpow [THEN sym], simp) | |
| 53079 | 2401 | done | 
| 51527 | 2402 | |
| 2403 | lemma powr_int: | |
| 2404 | assumes "x > 0" | |
| 2405 | shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))" | |
| 53079 | 2406 | proof (cases "i < 0") | 
| 2407 | case True | |
| 51527 | 2408 | have r: "x powr i = 1 / x powr (-i)" by (simp add: powr_minus field_simps) | 
| 60758 | 2409 | show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close> by (simp add: r field_simps powr_realpow[symmetric]) | 
| 53079 | 2410 | next | 
| 2411 | case False | |
| 2412 | then show ?thesis by (simp add: assms powr_realpow[symmetric]) | |
| 2413 | qed | |
| 51527 | 2414 | |
| 58981 | 2415 | lemma compute_powr[code]: | 
| 2416 | fixes i::real | |
| 2417 | shows "b powr i = | |
| 2418 | (if b \<le> 0 then Code.abort (STR ''op powr with nonpositive base'') (\<lambda>_. b powr i) | |
| 61942 | 2419 | else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>) | 
| 58981 | 2420 | else Code.abort (STR ''op powr with non-integer exponent'') (\<lambda>_. b powr i))" | 
| 59587 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 nipkow parents: 
58984diff
changeset | 2421 | by (auto simp: powr_int) | 
| 58981 | 2422 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2423 | lemma powr_one: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2424 | fixes x::real shows "0 \<le> x \<Longrightarrow> x powr 1 = x" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2425 | using powr_realpow [of x 1] | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2426 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2427 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2428 | lemma powr_neg_one: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2429 | fixes x::real shows "0 < x \<Longrightarrow> x powr - 1 = 1 / x" | 
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2430 | using powr_int [of x "- 1"] by simp | 
| 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2431 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2432 | lemma powr_neg_numeral: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2433 | fixes x::real shows "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n" | 
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 2434 | using powr_int [of x "- numeral n"] by simp | 
| 51527 | 2435 | |
| 53079 | 2436 | lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)" | 
| 51527 | 2437 | by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr) | 
| 2438 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2439 | lemma ln_powr: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2440 | fixes x::real shows "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x" | 
| 56483 | 2441 | by (simp add: powr_def) | 
| 2442 | ||
| 56952 | 2443 | lemma ln_root: "\<lbrakk> n > 0; b > 0 \<rbrakk> \<Longrightarrow> ln (root n b) = ln b / n" | 
| 2444 | by(simp add: root_powr_inverse ln_powr) | |
| 2445 | ||
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2446 | lemma ln_sqrt: "0 < x \<Longrightarrow> ln (sqrt x) = ln x / 2" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 2447 | by (simp add: ln_powr powr_numeral ln_powr[symmetric] mult.commute) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2448 | |
| 56952 | 2449 | lemma log_root: "\<lbrakk> n > 0; a > 0 \<rbrakk> \<Longrightarrow> log b (root n a) = log b a / n" | 
| 2450 | by(simp add: log_def ln_root) | |
| 2451 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2452 | lemma log_powr: "x \<noteq> 0 \<Longrightarrow> log b (x powr y) = y * log b x" | 
| 56483 | 2453 | by (simp add: log_def ln_powr) | 
| 2454 | ||
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2455 | lemma log_nat_power: "0 < x \<Longrightarrow> log b (x^n) = real n * log b x" | 
| 56483 | 2456 | by (simp add: log_powr powr_realpow [symmetric]) | 
| 2457 | ||
| 2458 | lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b" | |
| 2459 | by (simp add: log_def) | |
| 2460 | ||
| 2461 | lemma log_base_pow: "0 < a \<Longrightarrow> log (a ^ n) x = log a x / n" | |
| 2462 | by (simp add: log_def ln_realpow) | |
| 2463 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2464 | lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b" | 
| 56483 | 2465 | by (simp add: log_def ln_powr) | 
| 51527 | 2466 | |
| 56952 | 2467 | lemma log_base_root: "\<lbrakk> n > 0; b > 0 \<rbrakk> \<Longrightarrow> log (root n b) x = n * (log b x)" | 
| 2468 | by(simp add: log_def ln_root) | |
| 2469 | ||
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2470 | lemma ln_bound: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2471 | fixes x::real shows "1 <= x ==> ln x <= x" | 
| 51527 | 2472 | apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1") | 
| 2473 | apply simp | |
| 2474 | apply (rule ln_add_one_self_le_self, simp) | |
| 53079 | 2475 | done | 
| 51527 | 2476 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2477 | lemma powr_mono: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2478 | fixes x::real shows "a <= b ==> 1 <= x ==> x powr a <= x powr b" | 
| 53079 | 2479 | apply (cases "x = 1", simp) | 
| 2480 | apply (cases "a = b", simp) | |
| 51527 | 2481 | apply (rule order_less_imp_le) | 
| 2482 | apply (rule powr_less_mono, auto) | |
| 53079 | 2483 | done | 
| 51527 | 2484 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2485 | lemma ge_one_powr_ge_zero: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2486 | fixes x::real shows "1 <= x ==> 0 <= a ==> 1 <= x powr a" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2487 | using powr_mono by fastforce | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2488 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2489 | lemma powr_less_mono2: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2490 | fixes x::real shows "0 < a ==> 0 \<le> x ==> x < y ==> x powr a < y powr a" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2491 | by (simp add: powr_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2492 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2493 | lemma powr_less_mono2_neg: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2494 | fixes x::real shows "a < 0 ==> 0 < x ==> x < y ==> y powr a < x powr a" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2495 | by (simp add: powr_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2496 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2497 | lemma powr_mono2: | 
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2498 | fixes x::real shows "0 <= a ==> 0 \<le> x ==> x <= y ==> x powr a <= y powr a" | 
| 51527 | 2499 | apply (case_tac "a = 0", simp) | 
| 2500 | apply (case_tac "x = y", simp) | |
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2501 | apply (metis dual_order.strict_iff_order powr_less_mono2) | 
| 53079 | 2502 | done | 
| 2503 | ||
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2504 | lemma powr_mono2': | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2505 | assumes "a \<le> 0" "x > 0" "x \<le> (y::real)" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2506 | shows "x powr a \<ge> y powr a" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2507 | proof - | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2508 | from assms have "x powr -a \<le> y powr -a" by (intro powr_mono2) simp_all | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2509 | with assms show ?thesis by (auto simp add: powr_minus field_simps) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2510 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2511 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2512 | lemma powr_inj: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2513 | fixes x::real shows "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y" | 
| 51527 | 2514 | unfolding powr_def exp_inj_iff by simp | 
| 2515 | ||
| 60141 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2516 | lemma powr_half_sqrt: "0 \<le> x \<Longrightarrow> x powr (1/2) = sqrt x" | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2517 | by (simp add: powr_def root_powr_inverse sqrt_def) | 
| 
833adf7db7d8
New material, mostly about limits. Consolidation.
 paulson <lp15@cam.ac.uk> parents: 
60036diff
changeset | 2518 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2519 | lemma ln_powr_bound: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2520 | fixes x::real shows "1 <= x ==> 0 < a ==> ln x <= (x powr a) / a" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2521 | by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute mult_imp_le_div_pos not_less powr_gt_zero) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2522 | |
| 51527 | 2523 | |
| 2524 | lemma ln_powr_bound2: | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2525 | fixes x::real | 
| 51527 | 2526 | assumes "1 < x" and "0 < a" | 
| 2527 | shows "(ln x) powr a <= (a powr a) * x" | |
| 2528 | proof - | |
| 2529 | from assms have "ln x <= (x powr (1 / a)) / (1 / a)" | |
| 54575 | 2530 | by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff) | 
| 51527 | 2531 | also have "... = a * (x powr (1 / a))" | 
| 2532 | by simp | |
| 2533 | finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a" | |
| 54575 | 2534 | by (metis assms less_imp_le ln_gt_zero powr_mono2) | 
| 51527 | 2535 | also have "... = (a powr a) * ((x powr (1 / a)) powr a)" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2536 | using assms powr_mult by auto | 
| 51527 | 2537 | also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)" | 
| 2538 | by (rule powr_powr) | |
| 54575 | 2539 | also have "... = x" using assms | 
| 2540 | by auto | |
| 51527 | 2541 | finally show ?thesis . | 
| 2542 | qed | |
| 2543 | ||
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2544 | lemma tendsto_powr [tendsto_intros]: | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2545 | fixes a::real | 
| 61973 | 2546 | assumes f: "(f \<longlongrightarrow> a) F" and g: "(g \<longlongrightarrow> b) F" and a: "a \<noteq> 0" | 
| 2547 | shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F" | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2548 | unfolding powr_def | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2549 | proof (rule filterlim_If) | 
| 61973 | 2550 |   from f show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
 | 
| 61810 | 2551 | by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2552 | qed (insert f g a, auto intro!: tendsto_intros intro: tendsto_mono inf_le1) | 
| 51527 | 2553 | |
| 2554 | lemma continuous_powr: | |
| 53079 | 2555 | assumes "continuous F f" | 
| 2556 | and "continuous F g" | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2557 | and "f (Lim F (\<lambda>x. x)) \<noteq> 0" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2558 | shows "continuous F (\<lambda>x. (f x) powr (g x :: real))" | 
| 51527 | 2559 | using assms unfolding continuous_def by (rule tendsto_powr) | 
| 2560 | ||
| 2561 | lemma continuous_at_within_powr[continuous_intros]: | |
| 53079 | 2562 | assumes "continuous (at a within s) f" | 
| 2563 | and "continuous (at a within s) g" | |
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2564 | and "f a \<noteq> 0" | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2565 | shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x :: real))" | 
| 51527 | 2566 | using assms unfolding continuous_within by (rule tendsto_powr) | 
| 2567 | ||
| 2568 | lemma isCont_powr[continuous_intros, simp]: | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2569 | assumes "isCont f a" "isCont g a" "f a \<noteq> (0::real)" | 
| 51527 | 2570 | shows "isCont (\<lambda>x. (f x) powr g x) a" | 
| 2571 | using assms unfolding continuous_at by (rule tendsto_powr) | |
| 2572 | ||
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2573 | lemma continuous_on_powr[continuous_intros]: | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2574 | assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> (0::real)" | 
| 51527 | 2575 | shows "continuous_on s (\<lambda>x. (f x) powr (g x))" | 
| 2576 | using assms unfolding continuous_on_def by (fast intro: tendsto_powr) | |
| 2577 | ||
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2578 | lemma tendsto_powr2: | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2579 | fixes a::real | 
| 61973 | 2580 | assumes f: "(f \<longlongrightarrow> a) F" and g: "(g \<longlongrightarrow> b) F" and f_nonneg: "\<forall>\<^sub>F x in F. 0 \<le> f x" and b: "0 < b" | 
| 2581 | shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F" | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2582 | unfolding powr_def | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2583 | proof (rule filterlim_If) | 
| 61973 | 2584 |   from f show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
 | 
| 61810 | 2585 | by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2586 | next | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2587 |   { assume "a = 0"
 | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2588 |     with f f_nonneg have "LIM x inf F (principal {x. f x \<noteq> 0}). f x :> at_right 0"
 | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2589 | by (auto simp add: filterlim_at eventually_inf_principal le_less | 
| 61810 | 2590 | elim: eventually_mono intro: tendsto_mono inf_le1) | 
| 61973 | 2591 |     then have "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> 0) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2592 | by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_0] | 
| 60758 | 2593 | filterlim_tendsto_pos_mult_at_bot[OF _ \<open>0 < b\<close>] | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2594 | intro: tendsto_mono inf_le1 g) } | 
| 61973 | 2595 |   then show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x \<noteq> 0}))"
 | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2596 | using f g by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1) | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2597 | qed | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2598 | |
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2599 | lemma DERIV_powr: | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2600 | fixes r::real | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2601 | assumes g: "DERIV g x :> m" and pos: "g x > 0" and f: "DERIV f x :> r" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2602 | shows "DERIV (\<lambda>x. g x powr f x) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2603 | proof - | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2604 | have "DERIV (\<lambda>x. exp (f x * ln (g x))) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2605 | using pos | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2606 | by (auto intro!: derivative_eq_intros g pos f simp: powr_def field_simps exp_diff) | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2607 | then show ?thesis | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2608 | proof (rule DERIV_cong_ev[OF refl _ refl, THEN iffD1, rotated]) | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2609 | from DERIV_isCont[OF g] pos have "\<forall>\<^sub>F x in at x. 0 < g x" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2610 | unfolding isCont_def by (rule order_tendstoD(1)) | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2611 | with pos show "\<forall>\<^sub>F x in nhds x. exp (f x * ln (g x)) = g x powr f x" | 
| 61810 | 2612 | by (auto simp: eventually_at_filter powr_def elim: eventually_mono) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2613 | qed | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2614 | qed | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2615 | |
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2616 | lemma DERIV_fun_powr: | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2617 | fixes r::real | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2618 | assumes g: "DERIV g x :> m" and pos: "g x > 0" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2619 | shows "DERIV (\<lambda>x. (g x) powr r) x :> r * (g x) powr (r - of_nat 1) * m" | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2620 | using DERIV_powr[OF g pos DERIV_const, of r] pos | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2621 | by (simp add: powr_divide2[symmetric] field_simps) | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2622 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2623 | lemma has_real_derivative_powr: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2624 | assumes "z > 0" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2625 | shows "((\<lambda>z. z powr r) has_real_derivative r * z powr (r - 1)) (at z)" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2626 | proof (subst DERIV_cong_ev[OF refl _ refl]) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2627 | from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)" by (intro t1_space_nhds) auto | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2628 | thus "eventually (\<lambda>z. z powr r = exp (r * ln z)) (nhds z)" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2629 | unfolding powr_def by eventually_elim simp | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2630 | from assms show "((\<lambda>z. exp (r * ln z)) has_real_derivative r * z powr (r - 1)) (at z)" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2631 | by (auto intro!: derivative_eq_intros simp: powr_def field_simps exp_diff) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2632 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2633 | |
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2634 | declare has_real_derivative_powr[THEN DERIV_chain2, derivative_intros] | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61518diff
changeset | 2635 | |
| 51527 | 2636 | lemma tendsto_zero_powrI: | 
| 61973 | 2637 | assumes "(f \<longlongrightarrow> (0::real)) F" "(g \<longlongrightarrow> b) F" "\<forall>\<^sub>F x in F. 0 \<le> f x" "0 < b" | 
| 2638 | shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> 0) F" | |
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2639 | using tendsto_powr2[OF assms] by simp | 
| 51527 | 2640 | |
| 2641 | lemma tendsto_neg_powr: | |
| 53079 | 2642 | assumes "s < 0" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2643 | and f: "LIM x F. f x :> at_top" | 
| 61973 | 2644 | shows "((\<lambda>x. f x powr s) \<longlongrightarrow> (0::real)) F" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2645 | proof - | 
| 61973 | 2646 | have "((\<lambda>x. exp (s * ln (f x))) \<longlongrightarrow> (0::real)) F" (is "?X") | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2647 | by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top] | 
| 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2648 | filterlim_tendsto_neg_mult_at_bot assms) | 
| 61973 | 2649 | also have "?X \<longleftrightarrow> ((\<lambda>x. f x powr s) \<longlongrightarrow> (0::real)) F" | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2650 | using f filterlim_at_top_dense[of f F] | 
| 61810 | 2651 | by (intro filterlim_cong[OF refl refl]) (auto simp: neq_iff powr_def elim: eventually_mono) | 
| 60182 
e1ea5a6379c9
generalized tends over powr; added DERIV rule for powr
 hoelzl parents: 
60162diff
changeset | 2652 | finally show ?thesis . | 
| 51527 | 2653 | qed | 
| 2654 | ||
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2655 | lemma tendsto_exp_limit_at_right: | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2656 | fixes x :: real | 
| 61973 | 2657 | shows "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2658 | proof cases | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2659 | assume "x \<noteq> 0" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2660 | have "((\<lambda>y. ln (1 + x * y)::real) has_real_derivative 1 * x) (at 0)" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2661 | by (auto intro!: derivative_eq_intros) | 
| 61973 | 2662 | then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2663 | by (auto simp add: has_field_derivative_def field_has_derivative_at) | 
| 61973 | 2664 | then have *: "((\<lambda>y. exp (ln (1 + x * y) / y)) \<longlongrightarrow> exp x) (at 0)" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2665 | by (rule tendsto_intros) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2666 | then show ?thesis | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2667 | proof (rule filterlim_mono_eventually) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2668 | show "eventually (\<lambda>xa. exp (ln (1 + x * xa) / xa) = (1 + x * xa) powr (1 / xa)) (at_right 0)" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2669 | unfolding eventually_at_right[OF zero_less_one] | 
| 60758 | 2670 | using \<open>x \<noteq> 0\<close> | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2671 | apply (intro exI[of _ "1 / \<bar>x\<bar>"]) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2672 | apply (auto simp: field_simps powr_def abs_if) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 2673 | by (metis add_less_same_cancel1 mult_less_0_iff not_less_iff_gr_or_eq zero_less_one) | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2674 | qed (simp_all add: at_eq_sup_left_right) | 
| 58729 
e8ecc79aee43
add tendsto_const and tendsto_ident_at as simp and intro rules
 hoelzl parents: 
58710diff
changeset | 2675 | qed simp | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2676 | |
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2677 | lemma tendsto_exp_limit_at_top: | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2678 | fixes x :: real | 
| 61973 | 2679 | shows "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2680 | apply (subst filterlim_at_top_to_right) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2681 | apply (simp add: inverse_eq_divide) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2682 | apply (rule tendsto_exp_limit_at_right) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2683 | done | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2684 | |
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2685 | lemma tendsto_exp_limit_sequentially: | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2686 | fixes x :: real | 
| 61969 | 2687 | shows "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2688 | proof (rule filterlim_mono_eventually) | 
| 61944 | 2689 | from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" .. | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2690 | hence "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top" | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2691 | apply (intro eventually_sequentiallyI [of n]) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2692 | apply (case_tac "x \<ge> 0") | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2693 | apply (rule add_pos_nonneg, auto intro: divide_nonneg_nonneg) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2694 | apply (subgoal_tac "x / real xa > -1") | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2695 | apply (auto simp add: field_simps) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2696 | done | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2697 | then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top" | 
| 61810 | 2698 | by (rule eventually_mono) (erule powr_realpow) | 
| 61969 | 2699 | show "(\<lambda>n. (1 + x / real n) powr real n) \<longlonglongrightarrow> exp x" | 
| 57275 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2700 | by (rule filterlim_compose [OF tendsto_exp_limit_at_top filterlim_real_sequentially]) | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2701 | qed auto | 
| 
0ddb5b755cdc
moved lemmas from the proof of the Central Limit Theorem by Jeremy Avigad and Luke Serafin
 hoelzl parents: 
57180diff
changeset | 2702 | |
| 60758 | 2703 | subsection \<open>Sine and Cosine\<close> | 
| 29164 | 2704 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2705 | definition sin_coeff :: "nat \<Rightarrow> real" where | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2706 | "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))" | 
| 31271 | 2707 | |
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2708 | definition cos_coeff :: "nat \<Rightarrow> real" where | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2709 | "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)" | 
| 31271 | 2710 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2711 | definition sin :: "'a \<Rightarrow> 'a::{real_normed_algebra_1,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2712 | where "sin = (\<lambda>x. \<Sum>n. sin_coeff n *\<^sub>R x^n)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2713 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2714 | definition cos :: "'a \<Rightarrow> 'a::{real_normed_algebra_1,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2715 | where "cos = (\<lambda>x. \<Sum>n. cos_coeff n *\<^sub>R x^n)" | 
| 31271 | 2716 | |
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2717 | 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 | 2718 | unfolding sin_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2719 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2720 | 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 | 2721 | unfolding cos_coeff_def by simp | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2722 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2723 | 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 | 2724 | 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 | 2725 | by (simp del: mult_Suc) | 
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2726 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2727 | 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 | 2728 | unfolding cos_coeff_def sin_coeff_def | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 2729 | by (simp del: mult_Suc) (auto elim: oddE) | 
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2730 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2731 | lemma summable_norm_sin: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2732 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2733 | shows "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2734 | unfolding sin_coeff_def | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2735 | apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2736 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 2737 | done | 
| 29164 | 2738 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2739 | lemma summable_norm_cos: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2740 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2741 | shows "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))" | 
| 53079 | 2742 | unfolding cos_coeff_def | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2743 | apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2744 | apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff) | 
| 53079 | 2745 | done | 
| 29164 | 2746 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2747 | lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2748 | unfolding sin_def | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2749 | by (metis (full_types) summable_norm_cancel summable_norm_sin summable_sums) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2750 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2751 | lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2752 | unfolding cos_def | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2753 | by (metis (full_types) summable_norm_cancel summable_norm_cos summable_sums) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2754 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2755 | lemma sin_of_real: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2756 | fixes x::real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2757 | shows "sin (of_real x) = of_real (sin x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2758 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2759 | have "(\<lambda>n. of_real (sin_coeff n *\<^sub>R x^n)) = (\<lambda>n. sin_coeff n *\<^sub>R (of_real x)^n)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2760 | proof | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2761 | fix n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2762 | show "of_real (sin_coeff n *\<^sub>R x^n) = sin_coeff n *\<^sub>R of_real x^n" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2763 | by (simp add: scaleR_conv_of_real) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2764 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2765 | also have "... sums (sin (of_real x))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2766 | by (rule sin_converges) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2767 | finally have "(\<lambda>n. of_real (sin_coeff n *\<^sub>R x^n)) sums (sin (of_real x))" . | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2768 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2769 | using sums_unique2 sums_of_real [OF sin_converges] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2770 | by blast | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2771 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2772 | |
| 59862 | 2773 | corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>" | 
| 2774 | by (metis Reals_cases Reals_of_real sin_of_real) | |
| 2775 | ||
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2776 | lemma cos_of_real: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2777 | fixes x::real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2778 | shows "cos (of_real x) = of_real (cos x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2779 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2780 | have "(\<lambda>n. of_real (cos_coeff n *\<^sub>R x^n)) = (\<lambda>n. cos_coeff n *\<^sub>R (of_real x)^n)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2781 | proof | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2782 | fix n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2783 | show "of_real (cos_coeff n *\<^sub>R x^n) = cos_coeff n *\<^sub>R of_real x^n" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2784 | by (simp add: scaleR_conv_of_real) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2785 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2786 | also have "... sums (cos (of_real x))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2787 | by (rule cos_converges) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2788 | finally have "(\<lambda>n. of_real (cos_coeff n *\<^sub>R x^n)) sums (cos (of_real x))" . | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2789 | then show ?thesis | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2790 | using sums_unique2 sums_of_real [OF cos_converges] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2791 | by blast | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2792 | qed | 
| 29164 | 2793 | |
| 59862 | 2794 | corollary cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>" | 
| 2795 | by (metis Reals_cases Reals_of_real cos_of_real) | |
| 2796 | ||
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2797 | lemma diffs_sin_coeff: "diffs sin_coeff = cos_coeff" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2798 | by (simp add: diffs_def sin_coeff_Suc del: of_nat_Suc) | 
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2799 | |
| 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2800 | lemma diffs_cos_coeff: "diffs cos_coeff = (\<lambda>n. - sin_coeff n)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2801 | by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc) | 
| 29164 | 2802 | |
| 60758 | 2803 | text\<open>Now at last we can get the derivatives of exp, sin and cos\<close> | 
| 29164 | 2804 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2805 | lemma DERIV_sin [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2806 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2807 | shows "DERIV sin x :> cos(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2808 | unfolding sin_def cos_def scaleR_conv_of_real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2809 | apply (rule DERIV_cong) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2810 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2811 | apply (simp_all add: norm_less_p1 diffs_of_real diffs_sin_coeff diffs_cos_coeff | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2812 | summable_minus_iff scaleR_conv_of_real [symmetric] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2813 | summable_norm_sin [THEN summable_norm_cancel] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2814 | summable_norm_cos [THEN summable_norm_cancel]) | 
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2815 | done | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2816 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2817 | declare DERIV_sin[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 2818 | DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2819 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2820 | lemma DERIV_cos [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2821 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2822 | shows "DERIV cos x :> -sin(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2823 | unfolding sin_def cos_def scaleR_conv_of_real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2824 | apply (rule DERIV_cong) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2825 | apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"]) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2826 | apply (simp_all add: norm_less_p1 diffs_of_real diffs_minus suminf_minus | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2827 | diffs_sin_coeff diffs_cos_coeff | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2828 | summable_minus_iff scaleR_conv_of_real [symmetric] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2829 | summable_norm_sin [THEN summable_norm_cancel] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2830 | summable_norm_cos [THEN summable_norm_cancel]) | 
| 44319 
806e0390de53
move sin_coeff and cos_coeff lemmas to Transcendental.thy; simplify some proofs
 huffman parents: 
44318diff
changeset | 2831 | done | 
| 29164 | 2832 | |
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 2833 | declare DERIV_cos[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 2834 | DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 51527 | 2835 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2836 | lemma isCont_sin: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2837 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2838 | shows "isCont sin x" | 
| 44311 | 2839 | by (rule DERIV_sin [THEN DERIV_isCont]) | 
| 2840 | ||
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2841 | lemma isCont_cos: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2842 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2843 | shows "isCont cos x" | 
| 44311 | 2844 | by (rule DERIV_cos [THEN DERIV_isCont]) | 
| 2845 | ||
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2846 | lemma isCont_sin' [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2847 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2848 | shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a" | 
| 44311 | 2849 | by (rule isCont_o2 [OF _ isCont_sin]) | 
| 2850 | ||
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2851 | (*FIXME A CONTEXT FOR F WOULD BE BETTER*) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2852 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2853 | lemma isCont_cos' [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2854 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2855 | shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a" | 
| 44311 | 2856 | by (rule isCont_o2 [OF _ isCont_cos]) | 
| 2857 | ||
| 2858 | lemma tendsto_sin [tendsto_intros]: | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2859 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 61973 | 2860 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F" | 
| 44311 | 2861 | by (rule isCont_tendsto_compose [OF isCont_sin]) | 
| 2862 | ||
| 2863 | lemma tendsto_cos [tendsto_intros]: | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2864 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 61973 | 2865 | shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F" | 
| 44311 | 2866 | by (rule isCont_tendsto_compose [OF isCont_cos]) | 
| 29164 | 2867 | |
| 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 | 2868 | lemma continuous_sin [continuous_intros]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2869 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2870 | shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (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 | 2871 | 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 | 2872 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2873 | lemma continuous_on_sin [continuous_intros]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2874 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2875 | shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (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 | 2876 | 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 | 2877 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2878 | lemma continuous_within_sin: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2879 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2880 | shows "continuous (at z within s) sin" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2881 | by (simp add: continuous_within tendsto_sin) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2882 | |
| 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 | 2883 | lemma continuous_cos [continuous_intros]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2884 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2885 | shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (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 | 2886 | 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 | 2887 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 2888 | lemma continuous_on_cos [continuous_intros]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2889 |   fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2890 | shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (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 | 2891 | 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 | 2892 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2893 | lemma continuous_within_cos: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2894 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2895 | shows "continuous (at z within s) cos" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2896 | by (simp add: continuous_within tendsto_cos) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2897 | |
| 60758 | 2898 | subsection \<open>Properties of Sine and Cosine\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2899 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2900 | lemma sin_zero [simp]: "sin 0 = 0" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2901 | unfolding sin_def sin_coeff_def by (simp add: scaleR_conv_of_real powser_zero) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2902 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 2903 | lemma cos_zero [simp]: "cos 0 = 1" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2904 | unfolding cos_def cos_coeff_def by (simp add: scaleR_conv_of_real powser_zero) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2905 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2906 | lemma DERIV_fun_sin: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2907 | "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin(g x)) x :> cos(g x) * m" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2908 | by (auto intro!: derivative_intros) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2909 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2910 | lemma DERIV_fun_cos: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2911 | "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> -sin(g x) * m" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2912 | by (auto intro!: derivative_eq_intros) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2913 | |
| 60758 | 2914 | subsection \<open>Deriving the Addition Formulas\<close> | 
| 2915 | ||
| 2916 | text\<open>The the product of two cosine series\<close> | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2917 | lemma cos_x_cos_y: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2918 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2919 | shows "(\<lambda>p. \<Sum>n\<le>p. | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2920 | if even p \<and> even n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2921 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2922 | sums (cos x * cos y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2923 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2924 |   { fix n p::nat
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2925 | assume "n\<le>p" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2926 | then have *: "even n \<Longrightarrow> even p \<Longrightarrow> (-1) ^ (n div 2) * (-1) ^ ((p - n) div 2) = (-1 :: real) ^ (p div 2)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2927 | by (metis div_add power_add le_add_diff_inverse odd_add) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2928 | have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) = | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2929 | (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | 
| 60758 | 2930 | using \<open>n\<le>p\<close> | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2931 | by (auto simp: * algebra_simps cos_coeff_def binomial_fact) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2932 | } | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2933 | then have "(\<lambda>p. \<Sum>n\<le>p. if even p \<and> even n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2934 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2935 | (\<lambda>p. \<Sum>n\<le>p. (cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2936 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2937 | also have "... = (\<lambda>p. \<Sum>n\<le>p. (cos_coeff n *\<^sub>R x^n) * (cos_coeff (p - n) *\<^sub>R y^(p-n)))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2938 | by (simp add: algebra_simps) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2939 | also have "... sums (cos x * cos y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2940 | using summable_norm_cos | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2941 | by (auto simp: cos_def scaleR_conv_of_real intro!: Cauchy_product_sums) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2942 | finally show ?thesis . | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2943 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2944 | |
| 60758 | 2945 | text\<open>The product of two sine series\<close> | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2946 | lemma sin_x_sin_y: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2947 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2948 | shows "(\<lambda>p. \<Sum>n\<le>p. | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2949 | if even p \<and> odd n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2950 | then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2951 | sums (sin x * sin y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2952 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2953 |   { fix n p::nat
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2954 | assume "n\<le>p" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2955 |     { assume np: "odd n" "even p"
 | 
| 60758 | 2956 | with \<open>n\<le>p\<close> have "n - Suc 0 + (p - Suc n) = p - Suc (Suc 0)" "Suc (Suc 0) \<le> p" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2957 | by arith+ | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2958 | moreover have "(p - Suc (Suc 0)) div 2 = p div 2 - Suc 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2959 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2960 | ultimately have *: "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))" | 
| 60758 | 2961 | using np \<open>n\<le>p\<close> | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2962 | apply (simp add: power_add [symmetric] div_add [symmetric] del: div_add) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2963 | apply (metis (no_types) One_nat_def Suc_1 le_div_geq minus_minus mult.left_neutral mult_minus_left power.simps(2) zero_less_Suc) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2964 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2965 | } then | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2966 | have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) = | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2967 | (if even p \<and> odd n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2968 | then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | 
| 60758 | 2969 | using \<open>n\<le>p\<close> | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 2970 | by (auto simp: algebra_simps sin_coeff_def binomial_fact) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2971 | } | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2972 | then have "(\<lambda>p. \<Sum>n\<le>p. if even p \<and> odd n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2973 | then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) = | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2974 | (\<lambda>p. \<Sum>n\<le>p. (sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2975 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2976 | also have "... = (\<lambda>p. \<Sum>n\<le>p. (sin_coeff n *\<^sub>R x^n) * (sin_coeff (p - n) *\<^sub>R y^(p-n)))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2977 | by (simp add: algebra_simps) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2978 | also have "... sums (sin x * sin y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2979 | using summable_norm_sin | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2980 | by (auto simp: sin_def scaleR_conv_of_real intro!: Cauchy_product_sums) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2981 | finally show ?thesis . | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2982 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2983 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2984 | lemma sums_cos_x_plus_y: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2985 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2986 | shows | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2987 | "(\<lambda>p. \<Sum>n\<le>p. if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2988 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2989 | else 0) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2990 | sums cos (x + y)" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 2991 | proof - | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2992 |   { fix p::nat
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2993 | have "(\<Sum>n\<le>p. if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2994 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 2995 | else 0) = | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2996 | (if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 2997 | then \<Sum>n\<le>p. ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2998 | else 0)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 2999 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3000 | also have "... = (if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3001 | then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n)) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3002 | else 0)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3003 | by (auto simp: setsum_right_distrib field_simps scaleR_conv_of_real nonzero_of_real_divide) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3004 | also have "... = cos_coeff p *\<^sub>R ((x + y) ^ p)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3005 | by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3006 | finally have "(\<Sum>n\<le>p. if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3007 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3008 | else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)" . | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3009 | } | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3010 | then have "(\<lambda>p. \<Sum>n\<le>p. | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3011 | if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3012 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3013 | else 0) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3014 | = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3015 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3016 | also have "... sums cos (x + y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3017 | by (rule cos_converges) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3018 | finally show ?thesis . | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3019 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3020 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3021 | theorem cos_add: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3022 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3023 | shows "cos (x + y) = cos x * cos y - sin x * sin y" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3024 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3025 |   { fix n p::nat
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3026 | assume "n\<le>p" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3027 | then have "(if even p \<and> even n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3028 | then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) - | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3029 | (if even p \<and> odd n | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3030 | then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3031 | = (if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3032 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3033 | by simp | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3034 | } | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3035 | then have "(\<lambda>p. \<Sum>n\<le>p. (if even p | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3036 | then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3037 | sums (cos x * cos y - sin x * sin y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3038 | using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3039 | by (simp add: setsum_subtractf [symmetric]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3040 | then show ?thesis | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3041 | by (blast intro: sums_cos_x_plus_y sums_unique2) | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3042 | qed | 
| 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3043 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3044 | lemma sin_minus_converges: "(\<lambda>n. - (sin_coeff n *\<^sub>R (-x)^n)) sums sin(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3045 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3046 | have [simp]: "\<And>n. - (sin_coeff n *\<^sub>R (-x)^n) = (sin_coeff n *\<^sub>R x^n)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3047 | by (auto simp: sin_coeff_def elim!: oddE) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3048 | show ?thesis | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3049 | by (simp add: sin_def summable_norm_sin [THEN summable_norm_cancel, THEN summable_sums]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3050 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3051 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3052 | lemma sin_minus [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3053 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3054 | shows "sin (-x) = -sin(x)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3055 | using sin_minus_converges [of x] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3056 | by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel] suminf_minus sums_iff equation_minus_iff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3057 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3058 | lemma cos_minus_converges: "(\<lambda>n. (cos_coeff n *\<^sub>R (-x)^n)) sums cos(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3059 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3060 | have [simp]: "\<And>n. (cos_coeff n *\<^sub>R (-x)^n) = (cos_coeff n *\<^sub>R x^n)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3061 | by (auto simp: Transcendental.cos_coeff_def elim!: evenE) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3062 | show ?thesis | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3063 | by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel, THEN summable_sums]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3064 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3065 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3066 | lemma cos_minus [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3067 |   fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3068 | shows "cos (-x) = cos(x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3069 | using cos_minus_converges [of x] | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3070 | by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3071 | suminf_minus sums_iff equation_minus_iff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3072 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3073 | lemma sin_cos_squared_add [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3074 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3075 | shows "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3076 | using cos_add [of x "-x"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3077 | by (simp add: power2_eq_square algebra_simps) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3078 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3079 | lemma sin_cos_squared_add2 [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3080 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3081 | shows "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3082 | by (subst add.commute, rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3083 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3084 | lemma sin_cos_squared_add3 [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3085 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3086 | shows "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 | 3087 | using sin_cos_squared_add2 [unfolded power2_eq_square] . | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3088 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3089 | lemma sin_squared_eq: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3090 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3091 | shows "(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 | 3092 | unfolding eq_diff_eq by (rule sin_cos_squared_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3093 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3094 | lemma cos_squared_eq: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3095 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3096 | shows "(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 | 3097 | unfolding eq_diff_eq by (rule sin_cos_squared_add2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3098 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3099 | lemma abs_sin_le_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3100 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3101 | shows "\<bar>sin x\<bar> \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3102 | by (rule power2_le_imp_le, simp_all add: sin_squared_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3103 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3104 | lemma sin_ge_minus_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3105 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3106 | shows "-1 \<le> sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3107 | using abs_sin_le_one [of x] unfolding abs_le_iff by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3108 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3109 | lemma sin_le_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3110 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3111 | shows "sin x \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3112 | 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 | 3113 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3114 | lemma abs_cos_le_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3115 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3116 | shows "\<bar>cos x\<bar> \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3117 | by (rule power2_le_imp_le, simp_all add: cos_squared_eq) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3118 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3119 | lemma cos_ge_minus_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3120 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3121 | shows "-1 \<le> cos x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3122 | using abs_cos_le_one [of x] unfolding abs_le_iff by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3123 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3124 | lemma cos_le_one [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3125 | fixes x :: real | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3126 | shows "cos x \<le> 1" | 
| 44308 
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
 huffman parents: 
44307diff
changeset | 3127 | 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 | 3128 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3129 | lemma cos_diff: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3130 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3131 | shows "cos (x - y) = cos x * cos y + sin x * sin y" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3132 | using cos_add [of x "- y"] by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3133 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3134 | lemma cos_double: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3135 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3136 | shows "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3137 | using cos_add [where x=x and y=x] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3138 | by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3139 | |
| 61762 
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
 paulson <lp15@cam.ac.uk> parents: 
61738diff
changeset | 3140 | lemma sin_cos_le1: | 
| 61944 | 3141 | fixes x::real shows "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1" | 
| 61762 
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
 paulson <lp15@cam.ac.uk> parents: 
61738diff
changeset | 3142 | using cos_diff [of x y] | 
| 
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
 paulson <lp15@cam.ac.uk> parents: 
61738diff
changeset | 3143 | by (metis abs_cos_le_one add.commute) | 
| 
d50b993b4fb9
Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
 paulson <lp15@cam.ac.uk> parents: 
61738diff
changeset | 3144 | |
| 41970 | 3145 | lemma DERIV_fun_pow: "DERIV g x :> m ==> | 
| 53079 | 3146 | DERIV (\<lambda>x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3147 | by (auto intro!: derivative_eq_intros simp:) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3148 | |
| 15229 | 3149 | lemma DERIV_fun_exp: | 
| 53079 | 3150 | "DERIV g x :> m ==> DERIV (\<lambda>x. exp(g x)) x :> exp(g x) * m" | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 3151 | by (auto intro!: derivative_intros) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3152 | |
| 60758 | 3153 | subsection \<open>The Constant Pi\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3154 | |
| 53079 | 3155 | definition pi :: real | 
| 3156 | where "pi = 2 * (THE x. 0 \<le> (x::real) & x \<le> 2 & cos x = 0)" | |
| 23043 | 3157 | |
| 60758 | 3158 | text\<open>Show that there's a least positive @{term x} with @{term "cos(x) = 0"};
 | 
| 3159 | hence define pi.\<close> | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3160 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3161 | lemma sin_paired: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3162 | fixes x :: real | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3163 | shows "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3164 | proof - | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3165 | have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3166 | apply (rule sums_group) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3167 | using sin_converges [of x, unfolded scaleR_conv_of_real] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3168 | by auto | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 3169 | thus ?thesis unfolding One_nat_def sin_coeff_def by (simp add: ac_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3170 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3171 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3172 | lemma sin_gt_zero_02: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3173 | fixes x :: real | 
| 53079 | 3174 | assumes "0 < x" and "x < 2" | 
| 3175 | shows "0 < sin x" | |
| 44728 | 3176 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3177 | let ?f = "\<lambda>n::nat. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / (fact (2*k+1)) * x^(2*k+1)" | 
| 44728 | 3178 | have pos: "\<forall>n. 0 < ?f n" | 
| 3179 | proof | |
| 3180 | fix n :: nat | |
| 3181 | let ?k2 = "real (Suc (Suc (4 * n)))" | |
| 3182 | let ?k3 = "real (Suc (Suc (Suc (4 * n))))" | |
| 3183 | have "x * x < ?k2 * ?k3" | |
| 3184 | using assms by (intro mult_strict_mono', simp_all) | |
| 3185 | hence "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)" | |
| 60758 | 3186 | by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>) | 
| 44728 | 3187 | thus "0 < ?f n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3188 | by (simp add: divide_simps mult_ac del: mult_Suc) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3189 | qed | 
| 44728 | 3190 | have sums: "?f sums sin x" | 
| 3191 | by (rule sin_paired [THEN sums_group], simp) | |
| 3192 | show "0 < sin x" | |
| 3193 | unfolding sums_unique [OF sums] | |
| 3194 | using sums_summable [OF sums] pos | |
| 56213 | 3195 | by (rule suminf_pos) | 
| 44728 | 3196 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3197 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3198 | lemma cos_double_less_one: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3199 | fixes x :: real | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3200 | shows "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3201 | using sin_gt_zero_02 [where x = x] by (auto simp: cos_squared_eq cos_double) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3202 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3203 | lemma cos_paired: | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3204 | fixes x :: real | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3205 | shows "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x" | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3206 | proof - | 
| 31271 | 3207 | have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3208 | apply (rule sums_group) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3209 | using cos_converges [of x, unfolded scaleR_conv_of_real] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3210 | by auto | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 3211 | thus ?thesis unfolding cos_coeff_def by (simp add: ac_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3212 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3213 | |
| 53602 | 3214 | lemmas realpow_num_eq_if = power_eq_if | 
| 3215 | ||
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3216 | lemma sumr_pos_lt_pair: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3217 | fixes f :: "nat \<Rightarrow> real" | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3218 | shows "\<lbrakk>summable f; | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3219 | \<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk> | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3220 |       \<Longrightarrow> setsum f {..<k} < suminf f"
 | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3221 | unfolding One_nat_def | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3222 | apply (subst suminf_split_initial_segment [where k=k], assumption, simp) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3223 | apply (drule_tac k=k in summable_ignore_initial_segment) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3224 | apply (drule_tac k="Suc (Suc 0)" in sums_group [OF summable_sums], simp) | 
| 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3225 | apply simp | 
| 60162 | 3226 | by (metis (no_types, lifting) add.commute suminf_pos summable_def sums_unique) | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 3227 | |
| 53602 | 3228 | lemma cos_two_less_zero [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3229 | "cos 2 < (0::real)" | 
| 53602 | 3230 | proof - | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3231 | note fact.simps(2) [simp del] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3232 | from sums_minus [OF cos_paired] | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3233 | have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / fact (2 * n))) sums - cos (2::real)" | 
| 53602 | 3234 | by simp | 
| 60162 | 3235 | then have sm: "summable (\<lambda>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3236 | by (rule sums_summable) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3237 | have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3238 | by (simp add: fact_num_eq_if realpow_num_eq_if) | 
| 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3239 | moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) | 
| 60162 | 3240 | < (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3241 | proof - | 
| 3242 |     { fix d
 | |
| 60162 | 3243 | let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))" | 
| 3244 | have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3245 | unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono) | 
| 60162 | 3246 | then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3247 | by (simp only: fact.simps(2) [of "Suc (?six4d)"] of_nat_mult of_nat_fact) | 
| 60162 | 3248 | then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))" | 
| 53602 | 3249 | by (simp add: inverse_eq_divide less_divide_eq) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3250 | } | 
| 60162 | 3251 | then show ?thesis | 
| 60867 | 3252 | by (force intro!: sumr_pos_lt_pair [OF sm] simp add: divide_inverse algebra_simps) | 
| 53602 | 3253 | qed | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3254 | ultimately have "0 < (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3255 | by (rule order_less_trans) | 
| 59730 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 paulson <lp15@cam.ac.uk> parents: 
59669diff
changeset | 3256 | moreover from * have "- cos 2 = (\<Sum>n. - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))" | 
| 53602 | 3257 | by (rule sums_unique) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3258 | ultimately have "(0::real) < - cos 2" by simp | 
| 53602 | 3259 | then show ?thesis by simp | 
| 3260 | qed | |
| 23053 | 3261 | |
| 3262 | lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq] | |
| 3263 | 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 | 3264 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3265 | lemma cos_is_zero: "EX! x::real. 0 \<le> x & x \<le> 2 \<and> cos x = 0" | 
| 44730 | 3266 | proof (rule ex_ex1I) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3267 | show "\<exists>x::real. 0 \<le> x & x \<le> 2 & cos x = 0" | 
| 44730 | 3268 | by (rule IVT2, simp_all) | 
| 3269 | next | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3270 | fix x::real and y::real | 
| 44730 | 3271 | assume x: "0 \<le> x \<and> x \<le> 2 \<and> cos x = 0" | 
| 3272 | assume y: "0 \<le> y \<and> y \<le> 2 \<and> cos y = 0" | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3273 | have [simp]: "\<forall>x::real. cos differentiable (at x)" | 
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 3274 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 44730 | 3275 | from x y show "x = y" | 
| 3276 | apply (cut_tac less_linear [of x y], auto) | |
| 3277 | apply (drule_tac f = cos in Rolle) | |
| 3278 | apply (drule_tac [5] f = cos in Rolle) | |
| 3279 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3280 | apply (metis order_less_le_trans less_le sin_gt_zero_02) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3281 | apply (metis order_less_le_trans less_le sin_gt_zero_02) | 
| 44730 | 3282 | done | 
| 3283 | qed | |
| 31880 | 3284 | |
| 23053 | 3285 | lemma pi_half: "pi/2 = (THE x. 0 \<le> x & x \<le> 2 & cos x = 0)" | 
| 53079 | 3286 | by (simp add: pi_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3287 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3288 | lemma cos_pi_half [simp]: "cos (pi / 2) = 0" | 
| 53079 | 3289 | by (simp add: pi_half cos_is_zero [THEN theI']) | 
| 23053 | 3290 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3291 | lemma cos_of_real_pi_half [simp]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3292 |   fixes x :: "'a :: {real_field,banach,real_normed_algebra_1}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3293 | shows "cos ((of_real pi / 2) :: 'a) = 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3294 | by (metis cos_pi_half cos_of_real eq_numeral_simps(4) nonzero_of_real_divide of_real_0 of_real_numeral) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3295 | |
| 23053 | 3296 | lemma pi_half_gt_zero [simp]: "0 < pi / 2" | 
| 53079 | 3297 | apply (rule order_le_neq_trans) | 
| 3298 | apply (simp add: pi_half cos_is_zero [THEN theI']) | |
| 54575 | 3299 | apply (metis cos_pi_half cos_zero zero_neq_one) | 
| 53079 | 3300 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3301 | |
| 23053 | 3302 | lemmas pi_half_neq_zero [simp] = pi_half_gt_zero [THEN less_imp_neq, symmetric] | 
| 3303 | 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 | 3304 | |
| 23053 | 3305 | lemma pi_half_less_two [simp]: "pi / 2 < 2" | 
| 53079 | 3306 | apply (rule order_le_neq_trans) | 
| 3307 | apply (simp add: pi_half cos_is_zero [THEN theI']) | |
| 54575 | 3308 | apply (metis cos_pi_half cos_two_neq_zero) | 
| 53079 | 3309 | done | 
| 23053 | 3310 | |
| 3311 | lemmas pi_half_neq_two [simp] = pi_half_less_two [THEN less_imp_neq] | |
| 3312 | 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 | 3313 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3314 | lemma pi_gt_zero [simp]: "0 < pi" | 
| 53079 | 3315 | using pi_half_gt_zero by simp | 
| 23053 | 3316 | |
| 3317 | lemma pi_ge_zero [simp]: "0 \<le> pi" | |
| 53079 | 3318 | by (rule pi_gt_zero [THEN order_less_imp_le]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3319 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3320 | lemma pi_neq_zero [simp]: "pi \<noteq> 0" | 
| 53079 | 3321 | by (rule pi_gt_zero [THEN less_imp_neq, symmetric]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3322 | |
| 23053 | 3323 | lemma pi_not_less_zero [simp]: "\<not> pi < 0" | 
| 53079 | 3324 | by (simp add: linorder_not_less) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3325 | |
| 29165 
562f95f06244
cleaned up some proofs; removed redundant simp rules
 huffman parents: 
29164diff
changeset | 3326 | lemma minus_pi_half_less_zero: "-(pi/2) < 0" | 
| 53079 | 3327 | by simp | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3328 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3329 | lemma m2pi_less_pi: "- (2*pi) < pi" | 
| 53079 | 3330 | by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3331 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3332 | lemma sin_pi_half [simp]: "sin(pi/2) = 1" | 
| 53079 | 3333 | using sin_cos_squared_add2 [where x = "pi/2"] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3334 | using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two] | 
| 53079 | 3335 | by (simp add: power2_eq_1_iff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3336 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3337 | lemma sin_of_real_pi_half [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3338 |   fixes x :: "'a :: {real_field,banach,real_normed_algebra_1}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3339 | shows "sin ((of_real pi / 2) :: 'a) = 1" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3340 | using sin_pi_half | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3341 | by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3342 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3343 | lemma sin_cos_eq: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3344 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3345 | shows "sin x = cos (of_real pi / 2 - x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3346 | by (simp add: cos_diff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3347 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3348 | lemma minus_sin_cos_eq: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3349 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3350 | shows "-sin x = cos (x + of_real pi / 2)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3351 | by (simp add: cos_add nonzero_of_real_divide) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3352 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3353 | lemma cos_sin_eq: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3354 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3355 | shows "cos x = sin (of_real pi / 2 - x)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3356 | using sin_cos_eq [of "of_real pi / 2 - x"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3357 | by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3358 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3359 | lemma sin_add: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3360 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3361 | shows "sin (x + y) = sin x * cos y + cos x * sin y" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3362 | using cos_add [of "of_real pi / 2 - x" "-y"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3363 | by (simp add: cos_sin_eq) (simp add: sin_cos_eq) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3364 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3365 | lemma sin_diff: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3366 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3367 | shows "sin (x - y) = sin x * cos y - cos x * sin y" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3368 | using sin_add [of x "- y"] by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3369 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3370 | lemma sin_double: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3371 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3372 | shows "sin(2 * x) = 2 * sin x * cos x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3373 | using sin_add [where x=x and y=x] by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3374 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3375 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3376 | lemma cos_of_real_pi [simp]: "cos (of_real pi) = -1" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3377 | using cos_add [where x = "pi/2" and y = "pi/2"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3378 | by (simp add: cos_of_real) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3379 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3380 | lemma sin_of_real_pi [simp]: "sin (of_real pi) = 0" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3381 | using sin_add [where x = "pi/2" and y = "pi/2"] | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3382 | by (simp add: sin_of_real) | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3383 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3384 | lemma cos_pi [simp]: "cos pi = -1" | 
| 53079 | 3385 | 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 | 3386 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3387 | lemma sin_pi [simp]: "sin pi = 0" | 
| 53079 | 3388 | 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 | 3389 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3390 | lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x" | 
| 53079 | 3391 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3392 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3393 | lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x" | 
| 53079 | 3394 | by (simp add: sin_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3395 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3396 | lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x" | 
| 53079 | 3397 | by (simp add: cos_add) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3398 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3399 | lemma cos_periodic_pi2 [simp]: "cos (pi + x) = - cos x" | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3400 | by (simp add: cos_add) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3401 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3402 | lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3403 | by (simp add: sin_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3404 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3405 | lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3406 | by (simp add: cos_add sin_double cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3407 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3408 | lemma cos_npi [simp]: "cos (real n * pi) = (- 1) ^ n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3409 | by (induct n) (auto simp: distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3410 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 3411 | lemma cos_npi2 [simp]: "cos (pi * real n) = (- 1) ^ n" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3412 | by (metis cos_npi mult.commute) | 
| 15383 | 3413 | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3414 | lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3415 | by (induct n) (auto simp: of_nat_Suc distrib_right) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3416 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3417 | lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0" | 
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 3418 | by (simp add: mult.commute [of pi]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3419 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3420 | lemma cos_two_pi [simp]: "cos (2*pi) = 1" | 
| 53079 | 3421 | by (simp add: cos_double) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3422 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3423 | lemma sin_two_pi [simp]: "sin (2*pi) = 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3424 | by (simp add: sin_double) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3425 | |
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3426 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3427 | lemma sin_times_sin: | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3428 |   fixes w :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3429 | shows "sin(w) * sin(z) = (cos(w - z) - cos(w + z)) / 2" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3430 | by (simp add: cos_diff cos_add) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3431 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3432 | lemma sin_times_cos: | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3433 |   fixes w :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3434 | shows "sin(w) * cos(z) = (sin(w + z) + sin(w - z)) / 2" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3435 | by (simp add: sin_diff sin_add) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3436 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3437 | lemma cos_times_sin: | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3438 |   fixes w :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3439 | shows "cos(w) * sin(z) = (sin(w + z) - sin(w - z)) / 2" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3440 | by (simp add: sin_diff sin_add) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3441 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3442 | lemma cos_times_cos: | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3443 |   fixes w :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3444 | shows "cos(w) * cos(z) = (cos(w - z) + cos(w + z)) / 2" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3445 | by (simp add: cos_diff cos_add) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3446 | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 3447 | lemma sin_plus_sin: (*FIXME field should not be necessary*) | 
| 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 3448 |   fixes w :: "'a::{real_normed_field,banach,field}"
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3449 | shows "sin(w) + sin(z) = 2 * sin((w + z) / 2) * cos((w - z) / 2)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3450 | apply (simp add: mult.assoc sin_times_cos) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3451 | apply (simp add: field_simps) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3452 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3453 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3454 | lemma sin_diff_sin: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 3455 |   fixes w :: "'a::{real_normed_field,banach,field}"
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3456 | shows "sin(w) - sin(z) = 2 * sin((w - z) / 2) * cos((w + z) / 2)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3457 | apply (simp add: mult.assoc sin_times_cos) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3458 | apply (simp add: field_simps) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3459 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3460 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3461 | lemma cos_plus_cos: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 3462 |   fixes w :: "'a::{real_normed_field,banach,field}"
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3463 | shows "cos(w) + cos(z) = 2 * cos((w + z) / 2) * cos((w - z) / 2)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3464 | apply (simp add: mult.assoc cos_times_cos) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3465 | apply (simp add: field_simps) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3466 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3467 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3468 | lemma cos_diff_cos: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 3469 |   fixes w :: "'a::{real_normed_field,banach,field}"
 | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3470 | shows "cos(w) - cos(z) = 2 * sin((w + z) / 2) * sin((z - w) / 2)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3471 | apply (simp add: mult.assoc sin_times_sin) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3472 | apply (simp add: field_simps) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3473 | done | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3474 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3475 | lemma cos_double_cos: | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3476 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3477 | shows "cos(2 * z) = 2 * cos z ^ 2 - 1" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3478 | by (simp add: cos_double sin_squared_eq) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3479 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3480 | lemma cos_double_sin: | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3481 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3482 | shows "cos(2 * z) = 1 - 2 * sin z ^ 2" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3483 | by (simp add: cos_double sin_squared_eq) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3484 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3485 | lemma sin_pi_minus [simp]: "sin (pi - x) = sin x" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3486 | by (metis sin_minus sin_periodic_pi minus_minus uminus_add_conv_diff) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3487 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3488 | lemma cos_pi_minus [simp]: "cos (pi - x) = -(cos x)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3489 | by (metis cos_minus cos_periodic_pi uminus_add_conv_diff) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3490 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3491 | lemma sin_minus_pi [simp]: "sin (x - pi) = - (sin x)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3492 | by (simp add: sin_diff) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3493 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3494 | lemma cos_minus_pi [simp]: "cos (x - pi) = -(cos x)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3495 | by (simp add: cos_diff) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3496 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3497 | lemma sin_2pi_minus [simp]: "sin (2*pi - x) = -(sin x)" | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3498 | by (metis sin_periodic_pi2 add_diff_eq mult_2 sin_pi_minus) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3499 | |
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3500 | lemma cos_2pi_minus [simp]: "cos (2*pi - x) = cos x" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3501 | by (metis (no_types, hide_lams) cos_add cos_minus cos_two_pi sin_minus sin_two_pi | 
| 59741 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3502 | diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff) | 
| 
5b762cd73a8e
Lots of new material on complex-valued functions. Modified simplification of (x/n)^k
 paulson <lp15@cam.ac.uk> parents: 
59731diff
changeset | 3503 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3504 | lemma sin_gt_zero2: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3505 | by (metis sin_gt_zero_02 order_less_trans pi_half_less_two) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3506 | |
| 41970 | 3507 | lemma sin_less_zero: | 
| 53079 | 3508 | assumes "- pi/2 < x" and "x < 0" | 
| 3509 | shows "sin x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3510 | proof - | 
| 41970 | 3511 | have "0 < sin (- x)" using assms by (simp only: sin_gt_zero2) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3512 | thus ?thesis by simp | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3513 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3514 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3515 | lemma pi_less_4: "pi < 4" | 
| 53079 | 3516 | using pi_half_less_two by auto | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3517 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3518 | lemma cos_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cos x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3519 | by (simp add: cos_sin_eq sin_gt_zero2) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3520 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3521 | lemma cos_gt_zero_pi: "\<lbrakk>-(pi/2) < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cos x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3522 | using cos_gt_zero [of x] cos_gt_zero [of "-x"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3523 | by (cases rule: linorder_cases [of x 0]) auto | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3524 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3525 | lemma cos_ge_zero: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2\<rbrakk> \<Longrightarrow> 0 \<le> cos x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3526 | apply (auto simp: order_le_less cos_gt_zero_pi) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3527 | by (metis cos_pi_half eq_divide_eq eq_numeral_simps(4)) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3528 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3529 | lemma sin_gt_zero: "\<lbrakk>0 < x; x < pi \<rbrakk> \<Longrightarrow> 0 < sin x" | 
| 53079 | 3530 | 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 | 3531 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3532 | lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2*pi \<Longrightarrow> sin x < 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3533 | using sin_gt_zero [of "x-pi"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3534 | by (simp add: sin_diff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3535 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3536 | 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 | 3537 | proof (rule ccontr) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3538 | assume "\<not> 2 \<le> pi" hence "pi < 2" by auto | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3539 | have "\<exists>y > pi. y < 2 \<and> y < 2*pi" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3540 | proof (cases "2 < 2*pi") | 
| 60758 | 3541 | case True with dense[OF \<open>pi < 2\<close>] show ?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 | 3542 | next | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3543 | case False have "pi < 2*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 | 3544 | 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 | 3545 | qed | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3546 | then obtain y where "pi < y" and "y < 2" and "y < 2*pi" by blast | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3547 | hence "0 < sin y" using sin_gt_zero_02 by auto | 
| 41970 | 3548 | moreover | 
| 60758 | 3549 | have "sin y < 0" using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2*pi\<close> sin_periodic_pi[of "y - 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 | 3550 | 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 | 3551 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3552 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3553 | lemma sin_ge_zero: "\<lbrakk>0 \<le> x; x \<le> pi\<rbrakk> \<Longrightarrow> 0 \<le> sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3554 | by (auto simp: order_le_less sin_gt_zero) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3555 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3556 | lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2*pi \<Longrightarrow> sin x \<le> 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3557 | using sin_ge_zero [of "x-pi"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3558 | by (simp add: sin_diff) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3559 | |
| 61799 | 3560 | text \<open>FIXME: This proof is almost identical to lemma \<open>cos_is_zero\<close>. | 
| 60758 | 3561 | It should be possible to factor out some of the common parts.\<close> | 
| 44745 | 3562 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3563 | lemma cos_total: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)" | 
| 44745 | 3564 | proof (rule ex_ex1I) | 
| 3565 | assume y: "-1 \<le> y" "y \<le> 1" | |
| 3566 | show "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y" | |
| 3567 | by (rule IVT2, simp_all add: y) | |
| 3568 | next | |
| 3569 | fix a b | |
| 3570 | assume a: "0 \<le> a \<and> a \<le> pi \<and> cos a = y" | |
| 3571 | assume b: "0 \<le> b \<and> b \<le> pi \<and> cos b = y" | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3572 | have [simp]: "\<forall>x::real. cos differentiable (at x)" | 
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 3573 | unfolding real_differentiable_def by (auto intro: DERIV_cos) | 
| 44745 | 3574 | from a b show "a = b" | 
| 3575 | apply (cut_tac less_linear [of a b], auto) | |
| 3576 | apply (drule_tac f = cos in Rolle) | |
| 3577 | apply (drule_tac [5] f = cos in Rolle) | |
| 3578 | apply (auto dest!: DERIV_cos [THEN DERIV_unique]) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3579 | apply (metis order_less_le_trans less_le sin_gt_zero) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3580 | apply (metis order_less_le_trans less_le sin_gt_zero) | 
| 44745 | 3581 | done | 
| 3582 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3583 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3584 | lemma sin_total: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3585 | assumes y: "-1 \<le> y" "y \<le> 1" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3586 | shows "\<exists>! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3587 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3588 | from cos_total [OF y] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3589 | obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3590 | and uniq: "\<And>x'. 0 \<le> x' \<Longrightarrow> x' \<le> pi \<Longrightarrow> cos x' = y \<Longrightarrow> x' = x " | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3591 | by blast | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3592 | show ?thesis | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3593 | apply (simp add: sin_cos_eq) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3594 | apply (rule ex1I [where a="pi/2 - x"]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3595 | apply (cut_tac [2] x'="pi/2 - xa" in uniq) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3596 | using x | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3597 | apply auto | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3598 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3599 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3600 | |
| 15229 | 3601 | lemma cos_zero_lemma: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3602 | assumes "0 \<le> x" "cos x = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3603 | shows "\<exists>n. odd n \<and> x = of_nat n * (pi/2) \<and> n > 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3604 | proof - | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3605 | have xle: "x < (1 + real_of_int \<lfloor>x/pi\<rfloor>) * pi" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3606 | using floor_correct [of "x/pi"] | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3607 | by (simp add: add.commute divide_less_eq) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3608 | obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi" | 
| 61942 | 3609 | apply (rule that [of "nat \<lfloor>x/pi\<rfloor>"]) | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3610 | using assms | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3611 | apply (simp_all add: xle) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3612 | apply (metis floor_less_iff less_irrefl mult_imp_div_pos_less not_le pi_gt_zero) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3613 | done | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3614 | then have x: "0 \<le> x - n * pi" "(x - n * pi) \<le> pi" "cos (x - n * pi) = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3615 | by (auto simp: algebra_simps cos_diff assms) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3616 | then have "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3617 | by (auto simp: intro!: cos_total) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3618 | then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3619 | and uniq: "\<And>\<phi>. \<lbrakk>0 \<le> \<phi>; \<phi> \<le> pi; cos \<phi> = 0\<rbrakk> \<Longrightarrow> \<phi> = \<theta>" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3620 | by blast | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3621 | then have "x - real n * pi = \<theta>" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3622 | using x by blast | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3623 | moreover have "pi/2 = \<theta>" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3624 | using pi_half_ge_zero uniq by fastforce | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3625 | ultimately show ?thesis | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3626 | by (rule_tac x = "Suc (2 * n)" in exI) (simp add: algebra_simps) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3627 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3628 | |
| 15229 | 3629 | lemma sin_zero_lemma: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3630 | "\<lbrakk>0 \<le> x; sin x = 0\<rbrakk> \<Longrightarrow> \<exists>n::nat. even n & x = real n * (pi/2)" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3631 | using cos_zero_lemma [of "x + pi/2"] | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3632 | apply (clarsimp simp add: cos_add) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3633 | apply (rule_tac x = "n - 1" in exI) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3634 | apply (simp add: algebra_simps of_nat_diff) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3635 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3636 | |
| 15229 | 3637 | lemma cos_zero_iff: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3638 | "(cos x = 0) \<longleftrightarrow> | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3639 | ((\<exists>n. odd n & (x = real n * (pi/2))) \<or> (\<exists>n. odd n & (x = -(real n * (pi/2)))))" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3640 | (is "?lhs = ?rhs") | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3641 | proof - | 
| 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3642 |   { fix n :: nat
 | 
| 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3643 | assume "odd n" | 
| 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3644 | then obtain m where "n = 2 * m + 1" .. | 
| 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3645 | then have "cos (real n * pi / 2) = 0" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3646 | by (simp add: field_simps) (simp add: cos_add add_divide_distrib) | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3647 | } note * = this | 
| 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3648 | show ?thesis | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3649 | proof | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3650 | assume "cos x = 0" then show ?rhs | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3651 | using cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3652 | next | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3653 | assume ?rhs then show "cos x = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3654 | by (auto dest: * simp del: eq_divide_eq_numeral1) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3655 | qed | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 3656 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3657 | |
| 15229 | 3658 | lemma sin_zero_iff: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3659 | "(sin x = 0) \<longleftrightarrow> | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3660 | ((\<exists>n. even n & (x = real n * (pi/2))) \<or> (\<exists>n. even n & (x = -(real n * (pi/2)))))" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3661 | (is "?lhs = ?rhs") | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3662 | proof | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3663 | assume "sin x = 0" then show ?rhs | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3664 | using sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3665 | next | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3666 | assume ?rhs then show "sin x = 0" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3667 | by (auto elim: evenE) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3668 | qed | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3669 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3670 | lemma cos_zero_iff_int: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3671 | "cos x = 0 \<longleftrightarrow> (\<exists>n. odd n \<and> x = of_int n * (pi/2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3672 | proof safe | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3673 | assume "cos x = 0" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3674 | then show "\<exists>n. odd n & x = of_int n * (pi/2)" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3675 | apply (simp add: cos_zero_iff, safe) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3676 | apply (metis even_int_iff of_int_of_nat_eq) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3677 | apply (rule_tac x="- (int n)" in exI, simp) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3678 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3679 | next | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3680 | fix n::int | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3681 | assume "odd n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3682 | then show "cos (of_int n * (pi / 2)) = 0" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3683 | apply (simp add: cos_zero_iff) | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3684 | apply (case_tac n rule: int_cases2, simp_all) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3685 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3686 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3687 | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3688 | lemma sin_zero_iff_int: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3689 | "sin x = 0 \<longleftrightarrow> (\<exists>n. even n & (x = of_int n * (pi/2)))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3690 | proof safe | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3691 | assume "sin x = 0" | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3692 | then show "\<exists>n. even n \<and> x = of_int n * (pi / 2)" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3693 | apply (simp add: sin_zero_iff, safe) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3694 | apply (metis even_int_iff of_int_of_nat_eq) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3695 | apply (rule_tac x="- (int n)" in exI, simp) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3696 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3697 | next | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3698 | fix n::int | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3699 | assume "even n" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3700 | then show "sin (of_int n * (pi / 2)) = 0" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3701 | apply (simp add: sin_zero_iff) | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 3702 | apply (case_tac n rule: int_cases2, simp_all) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3703 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3704 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3705 | |
| 60688 
01488b559910
avoid explicit definition of the relation of associated elements in a ring -- prefer explicit normalization instead
 haftmann parents: 
60301diff
changeset | 3706 | lemma sin_zero_iff_int2: | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3707 | "sin x = 0 \<longleftrightarrow> (\<exists>n::int. x = of_int n * pi)" | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3708 | apply (simp only: sin_zero_iff_int) | 
| 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 3709 | apply (safe elim!: evenE) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3710 | apply (simp_all add: field_simps) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3711 | using dvd_triv_left apply fastforce | 
| 60688 
01488b559910
avoid explicit definition of the relation of associated elements in a ring -- prefer explicit normalization instead
 haftmann parents: 
60301diff
changeset | 3712 | done | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3713 | |
| 53079 | 3714 | lemma cos_monotone_0_pi: | 
| 3715 | 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 | 3716 | 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 | 3717 | proof - | 
| 33549 | 3718 | have "- (x - y) < 0" using assms by auto | 
| 60758 | 3719 | from MVT2[OF \<open>y < x\<close> DERIV_cos[THEN impI, THEN allI]] | 
| 53079 | 3720 | obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z" | 
| 3721 | by auto | |
| 33549 | 3722 | hence "0 < z" and "z < pi" using assms by auto | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3723 | hence "0 < sin z" using sin_gt_zero by auto | 
| 53079 | 3724 | hence "cos x - cos y < 0" | 
| 3725 | unfolding cos_diff minus_mult_commute[symmetric] | |
| 60758 | 3726 | using \<open>- (x - y) < 0\<close> 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 | 3727 | 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 | 3728 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3729 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3730 | lemma cos_monotone_0_pi_le: | 
| 53079 | 3731 | assumes "0 \<le> y" and "y \<le> x" and "x \<le> pi" | 
| 3732 | 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 | 3733 | proof (cases "y < x") | 
| 53079 | 3734 | case True | 
| 3735 | show ?thesis | |
| 60758 | 3736 | using cos_monotone_0_pi[OF \<open>0 \<le> y\<close> True \<open>x \<le> pi\<close>] by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3737 | next | 
| 53079 | 3738 | case False | 
| 60758 | 3739 | hence "y = x" using \<open>y \<le> x\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3740 | 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 | 3741 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3742 | |
| 53079 | 3743 | lemma cos_monotone_minus_pi_0: | 
| 3744 | 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 | 3745 | 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 | 3746 | proof - | 
| 53079 | 3747 | have "0 \<le> -x" and "-x < -y" and "-y \<le> pi" | 
| 3748 | using assms by auto | |
| 3749 | from cos_monotone_0_pi[OF this] show ?thesis | |
| 3750 | 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 | 3751 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3752 | |
| 53079 | 3753 | lemma cos_monotone_minus_pi_0': | 
| 3754 | assumes "-pi \<le> y" and "y \<le> x" and "x \<le> 0" | |
| 3755 | 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 | 3756 | proof (cases "y < x") | 
| 53079 | 3757 | case True | 
| 60758 | 3758 | show ?thesis using cos_monotone_minus_pi_0[OF \<open>-pi \<le> y\<close> True \<open>x \<le> 0\<close>] | 
| 53079 | 3759 | by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3760 | next | 
| 53079 | 3761 | case False | 
| 60758 | 3762 | hence "y = x" using \<open>y \<le> x\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3763 | 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 | 3764 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3765 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3766 | lemma sin_monotone_2pi: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3767 | assumes "- (pi/2) \<le> y" and "y < x" and "x \<le> pi/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3768 | shows "sin y < sin x" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3769 | apply (simp add: sin_cos_eq) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3770 | apply (rule cos_monotone_0_pi) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3771 | using assms | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3772 | apply auto | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3773 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3774 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3775 | lemma sin_monotone_2pi_le: | 
| 53079 | 3776 | assumes "- (pi / 2) \<le> y" and "y \<le> x" and "x \<le> pi / 2" | 
| 3777 | shows "sin y \<le> sin x" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3778 | by (metis assms le_less sin_monotone_2pi) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3779 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3780 | lemma sin_x_le_x: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3781 | fixes x::real assumes x: "x \<ge> 0" shows "sin x \<le> x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3782 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3783 | let ?f = "\<lambda>x. x - sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3784 | from x have "?f x \<ge> ?f 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3785 | apply (rule DERIV_nonneg_imp_nondecreasing) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3786 | apply (intro allI impI exI[of _ "1 - cos x" for x]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3787 | apply (auto intro!: derivative_eq_intros simp: field_simps) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3788 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3789 | thus "sin x \<le> x" by simp | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 3790 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3791 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3792 | lemma sin_x_ge_neg_x: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3793 | fixes x::real assumes x: "x \<ge> 0" shows "sin x \<ge> - x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3794 | proof - | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3795 | let ?f = "\<lambda>x. x + sin x" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3796 | from x have "?f x \<ge> ?f 0" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3797 | apply (rule DERIV_nonneg_imp_nondecreasing) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3798 | apply (intro allI impI exI[of _ "1 + cos x" for x]) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3799 | apply (auto intro!: derivative_eq_intros simp: field_simps real_0_le_add_iff) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3800 | done | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3801 | thus "sin x \<ge> -x" by simp | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3802 | qed | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3803 | |
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3804 | lemma abs_sin_x_le_abs_x: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3805 | fixes x::real shows "\<bar>sin x\<bar> \<le> \<bar>x\<bar>" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3806 | using sin_x_ge_neg_x [of x] sin_x_le_x [of x] sin_x_ge_neg_x [of "-x"] sin_x_le_x [of "-x"] | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3807 | by (auto simp: abs_real_def) | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3808 | |
| 53079 | 3809 | |
| 60758 | 3810 | subsection \<open>More Corollaries about Sine and Cosine\<close> | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3811 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3812 | lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3813 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3814 | have "sin ((real n + 1/2) * pi) = cos (real n * pi)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3815 | by (auto simp: algebra_simps sin_add) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3816 | thus ?thesis | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3817 | by (simp add: distrib_right add_divide_distrib add.commute mult.commute [of pi]) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3818 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3819 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3820 | lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3821 | by (cases "even n") (simp_all add: cos_double mult.assoc) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3822 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3823 | lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3824 | apply (subgoal_tac "cos (pi + pi/2) = 0", simp) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3825 | apply (subst cos_add, simp) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3826 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3827 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3828 | lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3829 | by (auto simp: mult.assoc sin_double) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3830 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3831 | lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3832 | apply (subgoal_tac "sin (pi + pi/2) = - 1", simp) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3833 | apply (subst sin_add, simp) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3834 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3835 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3836 | lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3837 | by (simp only: cos_add sin_add of_nat_Suc distrib_right distrib_left add_divide_distrib, auto) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3838 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3839 | lemma DERIV_cos_add [simp]: "DERIV (\<lambda>x. cos (x + k)) xa :> - sin (xa + k)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3840 | by (auto intro!: derivative_eq_intros) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3841 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3842 | lemma sin_zero_norm_cos_one: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3843 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3844 | assumes "sin x = 0" shows "norm (cos x) = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3845 | using sin_cos_squared_add [of x, unfolded assms] | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3846 | by (simp add: square_norm_one) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3847 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3848 | lemma sin_zero_abs_cos_one: "sin x = 0 \<Longrightarrow> \<bar>cos x\<bar> = (1::real)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3849 | using sin_zero_norm_cos_one by fastforce | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3850 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3851 | lemma cos_one_sin_zero: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3852 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3853 | assumes "cos x = 1" shows "sin x = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3854 | using sin_cos_squared_add [of x, unfolded assms] | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3855 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3856 | |
| 61070 | 3857 | lemma sin_times_pi_eq_0: "sin(x * pi) = 0 \<longleftrightarrow> x \<in> \<int>" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3858 | by (simp add: sin_zero_iff_int2) (metis Ints_cases Ints_of_int) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3859 | |
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3860 | lemma cos_one_2pi: | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3861 | "cos(x) = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2*pi) | (\<exists>n::nat. x = -(n * 2*pi))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3862 | (is "?lhs = ?rhs") | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3863 | proof | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3864 | assume "cos(x) = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3865 | then have "sin x = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3866 | by (simp add: cos_one_sin_zero) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3867 | then show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3868 | proof (simp only: sin_zero_iff, elim exE disjE conjE) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3869 | fix n::nat | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3870 | assume n: "even n" "x = real n * (pi/2)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3871 | then obtain m where m: "n = 2 * m" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3872 | using dvdE by blast | 
| 60758 | 3873 | then have me: "even m" using \<open>?lhs\<close> n | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3874 | by (auto simp: field_simps) (metis one_neq_neg_one power_minus_odd power_one) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3875 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3876 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3877 | by (auto simp: field_simps elim!: evenE) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3878 | next | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3879 | fix n::nat | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3880 | assume n: "even n" "x = - (real n * (pi/2))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3881 | then obtain m where m: "n = 2 * m" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3882 | using dvdE by blast | 
| 60758 | 3883 | then have me: "even m" using \<open>?lhs\<close> n | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3884 | by (auto simp: field_simps) (metis one_neq_neg_one power_minus_odd power_one) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3885 | show ?rhs | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3886 | using m me n | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3887 | by (auto simp: field_simps elim!: evenE) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3888 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3889 | next | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3890 | assume "?rhs" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3891 | then show "cos x = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3892 | by (metis cos_2npi cos_minus mult.assoc mult.left_commute) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3893 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3894 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3895 | lemma cos_one_2pi_int: "cos(x) = 1 \<longleftrightarrow> (\<exists>n::int. x = n * 2*pi)" | 
| 61799 | 3896 | apply auto \<comment>\<open>FIXME simproc bug\<close> | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3897 | apply (auto simp: cos_one_2pi) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3898 | apply (metis of_int_of_nat_eq) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3899 | apply (metis mult_minus_right of_int_minus of_int_of_nat_eq) | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3900 | by (metis mult_minus_right of_int_of_nat ) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3901 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3902 | lemma sin_cos_sqrt: "0 \<le> sin(x) \<Longrightarrow> (sin(x) = sqrt(1 - (cos(x) ^ 2)))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3903 | using sin_squared_eq real_sqrt_unique by fastforce | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3904 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3905 | lemma sin_eq_0_pi: "-pi < x \<Longrightarrow> x < pi \<Longrightarrow> sin(x) = 0 \<Longrightarrow> x = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3906 | by (metis sin_gt_zero sin_minus minus_less_iff neg_0_less_iff_less not_less_iff_gr_or_eq) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3907 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3908 | lemma cos_treble_cos: | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3909 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3910 | shows "cos(3 * x) = 4 * cos(x) ^ 3 - 3 * cos x" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3911 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3912 | have *: "(sin x * (sin x * 3)) = 3 - (cos x * (cos x * 3))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3913 | by (simp add: mult.assoc [symmetric] sin_squared_eq [unfolded power2_eq_square]) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3914 | have "cos(3 * x) = cos(2*x + x)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3915 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3916 | also have "... = 4 * cos(x) ^ 3 - 3 * cos x" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3917 | apply (simp only: cos_add cos_double sin_double) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3918 | apply (simp add: * field_simps power2_eq_square power3_eq_cube) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3919 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3920 | finally show ?thesis . | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3921 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3922 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3923 | lemma cos_45: "cos (pi / 4) = sqrt 2 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3924 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3925 | let ?c = "cos (pi / 4)" and ?s = "sin (pi / 4)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3926 | have nonneg: "0 \<le> ?c" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3927 | by (simp add: cos_ge_zero) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3928 | have "0 = cos (pi / 4 + pi / 4)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3929 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3930 | also have "cos (pi / 4 + pi / 4) = ?c\<^sup>2 - ?s\<^sup>2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3931 | by (simp only: cos_add power2_eq_square) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3932 | also have "\<dots> = 2 * ?c\<^sup>2 - 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3933 | by (simp add: sin_squared_eq) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3934 | finally have "?c\<^sup>2 = (sqrt 2 / 2)\<^sup>2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3935 | by (simp add: power_divide) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3936 | thus ?thesis | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3937 | using nonneg by (rule power2_eq_imp_eq) simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3938 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3939 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3940 | lemma cos_30: "cos (pi / 6) = sqrt 3/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3941 | proof - | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3942 | let ?c = "cos (pi / 6)" and ?s = "sin (pi / 6)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3943 | have pos_c: "0 < ?c" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3944 | by (rule cos_gt_zero, simp, simp) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3945 | have "0 = cos (pi / 6 + pi / 6 + pi / 6)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3946 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3947 | also have "\<dots> = (?c * ?c - ?s * ?s) * ?c - (?s * ?c + ?c * ?s) * ?s" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3948 | by (simp only: cos_add sin_add) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3949 | also have "\<dots> = ?c * (?c\<^sup>2 - 3 * ?s\<^sup>2)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3950 | by (simp add: algebra_simps power2_eq_square) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3951 | finally have "?c\<^sup>2 = (sqrt 3/2)\<^sup>2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3952 | using pos_c by (simp add: sin_squared_eq power_divide) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3953 | thus ?thesis | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3954 | using pos_c [THEN order_less_imp_le] | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3955 | by (rule power2_eq_imp_eq) simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3956 | qed | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3957 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3958 | lemma sin_45: "sin (pi / 4) = sqrt 2 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3959 | by (simp add: sin_cos_eq cos_45) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3960 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3961 | lemma sin_60: "sin (pi / 3) = sqrt 3/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3962 | by (simp add: sin_cos_eq cos_30) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3963 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3964 | lemma cos_60: "cos (pi / 3) = 1 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3965 | apply (rule power2_eq_imp_eq) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3966 | apply (simp add: cos_squared_eq sin_60 power_divide) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3967 | apply (rule cos_ge_zero, rule order_trans [where y=0], simp_all) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3968 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3969 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3970 | lemma sin_30: "sin (pi / 6) = 1 / 2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3971 | by (simp add: sin_cos_eq cos_60) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3972 | |
| 61070 | 3973 | lemma cos_integer_2pi: "n \<in> \<int> \<Longrightarrow> cos(2*pi * n) = 1" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3974 | by (metis Ints_cases cos_one_2pi_int mult.assoc mult.commute) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3975 | |
| 61070 | 3976 | lemma sin_integer_2pi: "n \<in> \<int> \<Longrightarrow> sin(2*pi * n) = 0" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3977 | by (metis sin_two_pi Ints_mult mult.assoc mult.commute sin_times_pi_eq_0) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3978 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3979 | lemma cos_int_2npi [simp]: "cos (2 * of_int (n::int) * pi) = 1" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3980 | by (simp add: cos_one_2pi_int) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3981 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3982 | lemma sin_int_2npi [simp]: "sin (2 * of_int (n::int) * pi) = 0" | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 3983 | by (metis Ints_of_int mult.assoc mult.commute sin_integer_2pi) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3984 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3985 | lemma sincos_principal_value: "\<exists>y. (-pi < y \<and> y \<le> pi) \<and> (sin(y) = sin(x) \<and> cos(y) = cos(x))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3986 | apply (rule exI [where x="pi - (2*pi) * frac((pi - x) / (2*pi))"]) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3987 | apply (auto simp: field_simps frac_lt_1) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3988 | apply (simp_all add: frac_def divide_simps) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3989 | apply (simp_all add: add_divide_distrib diff_divide_distrib) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3990 | apply (simp_all add: sin_diff cos_diff mult.assoc [symmetric] cos_integer_2pi sin_integer_2pi) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3991 | done | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3992 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 3993 | |
| 60758 | 3994 | subsection \<open>Tangent\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 3995 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 3996 | definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 53079 | 3997 | where "tan = (\<lambda>x. sin x / cos x)" | 
| 23043 | 3998 | |
| 59862 | 3999 | lemma tan_of_real: | 
| 60241 | 4000 |   "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 59862 | 4001 | by (simp add: tan_def sin_of_real cos_of_real) | 
| 4002 | ||
| 4003 | lemma tan_in_Reals [simp]: | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 4004 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 59862 | 4005 | shows "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>" | 
| 4006 | by (simp add: tan_def) | |
| 4007 | ||
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4008 | lemma tan_zero [simp]: "tan 0 = 0" | 
| 44311 | 4009 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4010 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4011 | lemma tan_pi [simp]: "tan pi = 0" | 
| 44311 | 4012 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4013 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4014 | lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0" | 
| 44311 | 4015 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4016 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4017 | lemma tan_minus [simp]: "tan (-x) = - tan x" | 
| 44311 | 4018 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4019 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4020 | lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x" | 
| 44311 | 4021 | by (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4022 | |
| 41970 | 4023 | lemma lemma_tan_add1: | 
| 44311 | 4024 | "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> 1 - tan x * tan y = cos (x + y)/(cos x * cos y)" | 
| 4025 | by (simp add: tan_def cos_add field_simps) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4026 | |
| 41970 | 4027 | lemma add_tan_eq: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4028 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4029 | shows "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> tan x + tan y = sin(x + y)/(cos x * cos y)" | 
| 44311 | 4030 | by (simp add: tan_def sin_add field_simps) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4031 | |
| 15229 | 4032 | lemma tan_add: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4033 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4034 | shows | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4035 | "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0\<rbrakk> | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4036 | \<Longrightarrow> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4037 | by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4038 | |
| 15229 | 4039 | lemma tan_double: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4040 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4041 | shows | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4042 | "\<lbrakk>cos x \<noteq> 0; cos (2 * x) \<noteq> 0\<rbrakk> | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4043 | \<Longrightarrow> tan (2 * x) = (2 * tan x) / (1 - (tan x)\<^sup>2)" | 
| 44311 | 4044 | using tan_add [of x x] by (simp add: power2_eq_square) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4045 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4046 | lemma tan_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < tan x" | 
| 53079 | 4047 | by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 41970 | 4048 | |
| 4049 | lemma tan_less_zero: | |
| 53079 | 4050 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 4051 | shows "tan x < 0" | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4052 | proof - | 
| 41970 | 4053 | have "0 < tan (- x)" using assms by (simp only: tan_gt_zero) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4054 | thus ?thesis by simp | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4055 | qed | 
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4056 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4057 | lemma tan_half: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 4058 |   fixes x :: "'a::{real_normed_field,banach,field}"
 | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4059 | shows "tan x = sin (2 * x) / (cos (2 * x) + 1)" | 
| 44756 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4060 | unfolding tan_def sin_double cos_double sin_squared_eq | 
| 
efcd71fbaeec
simplify proof of tan_half, removing unused assumptions
 huffman parents: 
44755diff
changeset | 4061 | 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 | 4062 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4063 | lemma tan_30: "tan (pi / 6) = 1 / sqrt 3" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4064 | unfolding tan_def by (simp add: sin_30 cos_30) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4065 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4066 | lemma tan_45: "tan (pi / 4) = 1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4067 | unfolding tan_def by (simp add: sin_45 cos_45) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4068 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4069 | lemma tan_60: "tan (pi / 3) = sqrt 3" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4070 | unfolding tan_def by (simp add: sin_60 cos_60) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4071 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4072 | lemma DERIV_tan [simp]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4073 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4074 | shows "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)" | 
| 44311 | 4075 | unfolding tan_def | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4076 | by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) | 
| 44311 | 4077 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4078 | lemma isCont_tan: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4079 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4080 | shows "cos x \<noteq> 0 \<Longrightarrow> isCont tan x" | 
| 44311 | 4081 | by (rule DERIV_tan [THEN DERIV_isCont]) | 
| 4082 | ||
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4083 | lemma isCont_tan' [simp,continuous_intros]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4084 |   fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4085 | shows "\<lbrakk>isCont f a; cos (f a) \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a" | 
| 44311 | 4086 | by (rule isCont_o2 [OF _ isCont_tan]) | 
| 4087 | ||
| 4088 | lemma tendsto_tan [tendsto_intros]: | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4089 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 61973 | 4090 | shows "\<lbrakk>(f \<longlongrightarrow> a) F; cos a \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F" | 
| 44311 | 4091 | by (rule isCont_tendsto_compose [OF isCont_tan]) | 
| 4092 | ||
| 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 | 4093 | lemma continuous_tan: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4094 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4095 | shows "continuous F f \<Longrightarrow> cos (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. tan (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 | 4096 | 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 | 4097 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4098 | lemma continuous_on_tan [continuous_intros]: | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4099 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4100 | shows "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. cos (f x) \<noteq> 0) \<Longrightarrow> continuous_on s (\<lambda>x. tan (f x))" | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4101 | unfolding continuous_on_def by (auto intro: tendsto_tan) | 
| 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 | 4102 | |
| 
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 | 4103 | lemma continuous_within_tan [continuous_intros]: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4104 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 4105 | shows | 
| 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 | 4106 | "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 | 4107 | 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 | 4108 | |
| 61976 | 4109 | lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0" | 
| 44311 | 4110 | by (rule LIM_cong_limit, (rule tendsto_intros)+, simp_all) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4111 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4112 | lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x" | 
| 53079 | 4113 | apply (cut_tac LIM_cos_div_sin) | 
| 4114 | apply (simp only: LIM_eq) | |
| 4115 | apply (drule_tac x = "inverse y" in spec, safe, force) | |
| 4116 | apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe) | |
| 4117 | apply (rule_tac x = "(pi/2) - e" in exI) | |
| 4118 | apply (simp (no_asm_simp)) | |
| 4119 | apply (drule_tac x = "(pi/2) - e" in spec) | |
| 4120 | apply (auto simp add: tan_def sin_diff cos_diff) | |
| 4121 | apply (rule inverse_less_iff_less [THEN iffD1]) | |
| 4122 | apply (auto simp add: divide_inverse) | |
| 4123 | apply (rule mult_pos_pos) | |
| 4124 | apply (subgoal_tac [3] "0 < sin e & 0 < cos e") | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 4125 | apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: mult.commute) | 
| 53079 | 4126 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4127 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4128 | lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y" | 
| 53079 | 4129 | apply (frule order_le_imp_less_or_eq, safe) | 
| 4130 | prefer 2 apply force | |
| 4131 | apply (drule lemma_tan_total, safe) | |
| 4132 | apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl) | |
| 4133 | apply (auto intro!: DERIV_tan [THEN DERIV_isCont]) | |
| 4134 | apply (drule_tac y = xa in order_le_imp_less_or_eq) | |
| 4135 | apply (auto dest: cos_gt_zero) | |
| 4136 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4137 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4138 | lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y" | 
| 53079 | 4139 | apply (cut_tac linorder_linear [of 0 y], safe) | 
| 4140 | apply (drule tan_total_pos) | |
| 4141 | apply (cut_tac [2] y="-y" in tan_total_pos, safe) | |
| 4142 | apply (rule_tac [3] x = "-x" in exI) | |
| 4143 | apply (auto del: exI intro!: exI) | |
| 4144 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4145 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4146 | lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y" | 
| 53079 | 4147 | apply (cut_tac y = y in lemma_tan_total1, auto) | 
| 57492 
74bf65a1910a
Hypsubst preserves equality hypotheses
 Thomas Sewell <thomas.sewell@nicta.com.au> parents: 
57418diff
changeset | 4148 | apply hypsubst_thin | 
| 53079 | 4149 | apply (cut_tac x = xa and y = y in linorder_less_linear, auto) | 
| 4150 | apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0") | |
| 4151 | apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0") | |
| 4152 | apply (rule_tac [4] Rolle) | |
| 4153 | apply (rule_tac [2] Rolle) | |
| 4154 | apply (auto del: exI intro!: DERIV_tan DERIV_isCont exI | |
| 56181 
2aa0b19e74f3
unify syntax for has_derivative and differentiable
 hoelzl parents: 
56167diff
changeset | 4155 | simp add: real_differentiable_def) | 
| 60758 | 4156 | txt\<open>Now, simulate TRYALL\<close> | 
| 53079 | 4157 | apply (rule_tac [!] DERIV_tan asm_rl) | 
| 4158 | apply (auto dest!: DERIV_unique [OF _ DERIV_tan] | |
| 4159 | simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym]) | |
| 4160 | done | |
| 4161 | ||
| 4162 | lemma tan_monotone: | |
| 4163 | 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 | 4164 | 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 | 4165 | proof - | 
| 53079 | 4166 | 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 | 4167 | proof (rule allI, rule impI) | 
| 53079 | 4168 | fix x' :: real | 
| 4169 | assume "y \<le> x' \<and> x' \<le> x" | |
| 33549 | 4170 | 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 | 4171 | 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 | 4172 | have "cos x' \<noteq> 0" by auto | 
| 53076 | 4173 | 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 | 4174 | qed | 
| 60758 | 4175 | from MVT2[OF \<open>y < x\<close> this] | 
| 53079 | 4176 | obtain z where "y < z" and "z < x" | 
| 4177 | and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto | |
| 33549 | 4178 | 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 | 4179 | 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 | 4180 | hence inv_pos: "0 < inverse ((cos z)\<^sup>2)" by auto | 
| 60758 | 4181 | have "0 < x - y" using \<open>y < x\<close> by auto | 
| 56544 | 4182 | with inv_pos have "0 < tan x - tan y" unfolding tan_diff by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4183 | 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 | 4184 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4185 | |
| 53079 | 4186 | lemma tan_monotone': | 
| 4187 | assumes "- (pi / 2) < y" | |
| 4188 | and "y < pi / 2" | |
| 4189 | and "- (pi / 2) < x" | |
| 4190 | 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 | 4191 | 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 | 4192 | proof | 
| 53079 | 4193 | assume "y < x" | 
| 4194 | thus "tan y < tan x" | |
| 60758 | 4195 | using tan_monotone and \<open>- (pi / 2) < y\<close> and \<open>x < pi / 2\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4196 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4197 | 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 | 4198 | show "y < x" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4199 | proof (rule ccontr) | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4200 | assume "\<not> y < x" hence "x \<le> y" by auto | 
| 41970 | 4201 | 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 | 4202 | 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 | 4203 | 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 | 4204 | next | 
| 60758 | 4205 | case False hence "x < y" using \<open>x \<le> y\<close> by auto | 
| 4206 | from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi / 2\<close>] show ?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 | 4207 | qed | 
| 60758 | 4208 | thus False using \<open>tan y < tan x\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4209 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4210 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4211 | |
| 53079 | 4212 | lemma tan_inverse: "1 / (tan y) = tan (pi / 2 - y)" | 
| 4213 | 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 | 4214 | |
| 41970 | 4215 | 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 | 4216 | 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 | 4217 | |
| 53079 | 4218 | lemma tan_periodic_nat[simp]: | 
| 4219 | fixes n :: nat | |
| 4220 | 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 | 4221 | proof (induct n arbitrary: x) | 
| 53079 | 4222 | case 0 | 
| 4223 | then show ?case by simp | |
| 4224 | next | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4225 | case (Suc n) | 
| 53079 | 4226 | have split_pi_off: "x + real (Suc n) * pi = (x + real n * pi) + pi" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4227 | unfolding Suc_eq_plus1 of_nat_add 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 | 4228 | show ?case unfolding split_pi_off using Suc by auto | 
| 53079 | 4229 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4230 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4231 | lemma tan_periodic_int[simp]: fixes i :: int shows "tan (x + of_int i * 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 | 4232 | proof (cases "0 \<le> i") | 
| 53079 | 4233 | case True | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4234 | hence i_nat: "of_int i = of_int (nat i)" by auto | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4235 | show ?thesis unfolding i_nat | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4236 | by (metis of_int_of_nat_eq 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 | 4237 | next | 
| 53079 | 4238 | case False | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4239 | hence i_nat: "of_int i = - of_int (nat (-i))" by auto | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4240 | have "tan x = tan (x + of_int i * pi - of_int i * pi)" | 
| 53079 | 4241 | by auto | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4242 | also have "\<dots> = tan (x + of_int i * pi)" | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4243 | unfolding i_nat mult_minus_left diff_minus_eq_add | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4244 | by (metis of_int_of_nat_eq 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 | 4245 | 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 | 4246 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4247 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
46240diff
changeset | 4248 | lemma tan_periodic_n[simp]: "tan (x + numeral n * pi) = tan x" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4249 | using tan_periodic_int[of _ "numeral n" ] by simp | 
| 23043 | 4250 | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4251 | lemma tan_minus_45: "tan (-(pi/4)) = -1" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4252 | unfolding tan_def by (simp add: sin_45 cos_45) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4253 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4254 | lemma tan_diff: | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4255 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4256 | shows | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4257 | "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0; cos (x - y) \<noteq> 0\<rbrakk> | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4258 | \<Longrightarrow> tan(x - y) = (tan(x) - tan(y))/(1 + tan(x) * tan(y))" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4259 | using tan_add [of x "-y"] | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4260 | by simp | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4261 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4262 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4263 | lemma tan_pos_pi2_le: "0 \<le> x ==> x < pi/2 \<Longrightarrow> 0 \<le> tan x" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4264 | using less_eq_real_def tan_gt_zero by auto | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4265 | |
| 61944 | 4266 | lemma cos_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> cos(x) = 1 / sqrt(1 + tan(x) ^ 2)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4267 | using cos_gt_zero_pi [of x] | 
| 62390 | 4268 | by (simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4269 | |
| 61944 | 4270 | lemma sin_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> sin(x) = tan(x) / sqrt(1 + tan(x) ^ 2)" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4271 | using cos_gt_zero [of "x"] cos_gt_zero [of "-x"] | 
| 62390 | 4272 | by (force simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4273 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4274 | lemma tan_mono_le: "-(pi/2) < x ==> x \<le> y ==> y < pi/2 \<Longrightarrow> tan(x) \<le> tan(y)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4275 | using less_eq_real_def tan_monotone by auto | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4276 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4277 | lemma tan_mono_lt_eq: "-(pi/2) < x ==> x < pi/2 ==> -(pi/2) < y ==> y < pi/2 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4278 | \<Longrightarrow> (tan(x) < tan(y) \<longleftrightarrow> x < y)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4279 | using tan_monotone' by blast | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4280 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4281 | lemma tan_mono_le_eq: "-(pi/2) < x ==> x < pi/2 ==> -(pi/2) < y ==> y < pi/2 | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4282 | \<Longrightarrow> (tan(x) \<le> tan(y) \<longleftrightarrow> x \<le> y)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4283 | by (meson tan_mono_le not_le tan_monotone) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4284 | |
| 61944 | 4285 | lemma tan_bound_pi2: "\<bar>x\<bar> < pi/4 \<Longrightarrow> \<bar>tan x\<bar> < 1" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4286 | using tan_45 tan_monotone [of x "pi/4"] tan_monotone [of "-x" "pi/4"] | 
| 62390 | 4287 | by (auto simp: abs_if split: if_split_asm) | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4288 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4289 | lemma tan_cot: "tan(pi/2 - x) = inverse(tan x)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4290 | by (simp add: tan_def sin_diff cos_diff) | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4291 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4292 | subsection \<open>Cotangent\<close> | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4293 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4294 | definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4295 | where "cot = (\<lambda>x. cos x / sin x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4296 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4297 | lemma cot_of_real: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4298 |   "of_real (cot x) = (cot (of_real x) :: 'a::{real_normed_field,banach})"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4299 | by (simp add: cot_def sin_of_real cos_of_real) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4300 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4301 | lemma cot_in_Reals [simp]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4302 |   fixes z :: "'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4303 | shows "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4304 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4305 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4306 | lemma cot_zero [simp]: "cot 0 = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4307 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4308 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4309 | lemma cot_pi [simp]: "cot pi = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4310 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4311 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4312 | lemma cot_npi [simp]: "cot (real (n::nat) * pi) = 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4313 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4314 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4315 | lemma cot_minus [simp]: "cot (-x) = - cot x" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4316 | by (simp add: cot_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4317 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4318 | lemma cot_periodic [simp]: "cot (x + 2*pi) = cot x" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4319 | by (simp add: cot_def) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4320 | |
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4321 | lemma cot_altdef: "cot x = inverse (tan x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4322 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4323 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4324 | lemma tan_altdef: "tan x = inverse (cot x)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4325 | by (simp add: cot_def tan_def) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4326 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4327 | lemma tan_cot': "tan(pi/2 - x) = cot x" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4328 | by (simp add: tan_cot cot_altdef) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4329 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4330 | lemma cot_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cot x" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4331 | by (simp add: cot_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4332 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4333 | lemma cot_less_zero: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4334 | assumes lb: "- pi/2 < x" and "x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4335 | shows "cot x < 0" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4336 | proof - | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4337 | have "0 < cot (- x)" using assms by (simp only: cot_gt_zero) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4338 | thus ?thesis by simp | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4339 | qed | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4340 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4341 | lemma DERIV_cot [simp]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4342 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4343 | shows "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4344 | unfolding cot_def using cos_squared_eq[of x] | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4345 | by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4346 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4347 | lemma isCont_cot: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4348 |   fixes x :: "'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4349 | shows "sin x \<noteq> 0 \<Longrightarrow> isCont cot x" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4350 | by (rule DERIV_cot [THEN DERIV_isCont]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4351 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4352 | lemma isCont_cot' [simp,continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4353 |   fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4354 | shows "\<lbrakk>isCont f a; sin (f a) \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4355 | by (rule isCont_o2 [OF _ isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4356 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4357 | lemma tendsto_cot [tendsto_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4358 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 61973 | 4359 | shows "\<lbrakk>(f \<longlongrightarrow> a) F; sin a \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F" | 
| 61531 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4360 | by (rule isCont_tendsto_compose [OF isCont_cot]) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4361 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4362 | lemma continuous_cot: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4363 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4364 | shows "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4365 | unfolding continuous_def by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4366 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4367 | lemma continuous_on_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4368 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4369 | shows "continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. sin (f x) \<noteq> 0) \<Longrightarrow> continuous_on s (\<lambda>x. cot (f x))" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4370 | unfolding continuous_on_def by (auto intro: tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4371 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4372 | lemma continuous_within_cot [continuous_intros]: | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4373 |   fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
 | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4374 | shows | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4375 | "continuous (at x within s) f \<Longrightarrow> sin (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. cot (f x))" | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4376 | unfolding continuous_within by (rule tendsto_cot) | 
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4377 | |
| 
ab2e862263e7
Rounding function, uniform limits, cotangent, binomial identities
 eberlm parents: 
61524diff
changeset | 4378 | |
| 60758 | 4379 | subsection \<open>Inverse Trigonometric Functions\<close> | 
| 23043 | 4380 | |
| 53079 | 4381 | definition arcsin :: "real => real" | 
| 4382 | where "arcsin y = (THE x. -(pi/2) \<le> x & x \<le> pi/2 & sin x = y)" | |
| 4383 | ||
| 4384 | definition arccos :: "real => real" | |
| 4385 | where "arccos y = (THE x. 0 \<le> x & x \<le> pi & cos x = y)" | |
| 4386 | ||
| 4387 | definition arctan :: "real => real" | |
| 4388 | where "arctan y = (THE x. -(pi/2) < x & x < pi/2 & tan x = y)" | |
| 23043 | 4389 | |
| 15229 | 4390 | lemma arcsin: | 
| 53079 | 4391 | "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> | 
| 4392 | -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2 & sin(arcsin y) = y" | |
| 4393 | unfolding arcsin_def by (rule theI' [OF sin_total]) | |
| 23011 | 4394 | |
| 4395 | lemma arcsin_pi: | |
| 53079 | 4396 | "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y" | 
| 4397 | apply (drule (1) arcsin) | |
| 4398 | apply (force intro: order_trans) | |
| 4399 | done | |
| 4400 | ||
| 4401 | lemma sin_arcsin [simp]: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin(arcsin y) = y" | |
| 4402 | by (blast dest: arcsin) | |
| 4403 | ||
| 4404 | lemma arcsin_bounded: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2" | |
| 4405 | by (blast dest: arcsin) | |
| 4406 | ||
| 4407 | lemma arcsin_lbound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y" | |
| 4408 | by (blast dest: arcsin) | |
| 4409 | ||
| 4410 | lemma arcsin_ubound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2" | |
| 4411 | by (blast dest: arcsin) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4412 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4413 | lemma arcsin_lt_bounded: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4414 | "\<lbrakk>-1 < y; y < 1\<rbrakk> \<Longrightarrow> -(pi/2) < arcsin y & arcsin y < pi/2" | 
| 53079 | 4415 | apply (frule order_less_imp_le) | 
| 4416 | apply (frule_tac y = y in order_less_imp_le) | |
| 4417 | apply (frule arcsin_bounded) | |
| 4418 | apply (safe, simp) | |
| 4419 | apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq) | |
| 4420 | apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe) | |
| 4421 | apply (drule_tac [!] f = sin in arg_cong, auto) | |
| 4422 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4423 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4424 | lemma arcsin_sin: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2\<rbrakk> \<Longrightarrow> arcsin(sin x) = x" | 
| 53079 | 4425 | apply (unfold arcsin_def) | 
| 4426 | apply (rule the1_equality) | |
| 4427 | apply (rule sin_total, auto) | |
| 4428 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4429 | |
| 59869 | 4430 | lemma arcsin_0 [simp]: "arcsin 0 = 0" | 
| 4431 | using arcsin_sin [of 0] | |
| 4432 | by simp | |
| 4433 | ||
| 4434 | lemma arcsin_1 [simp]: "arcsin 1 = pi/2" | |
| 4435 | using arcsin_sin [of "pi/2"] | |
| 4436 | by simp | |
| 4437 | ||
| 4438 | lemma arcsin_minus_1 [simp]: "arcsin (-1) = - (pi/2)" | |
| 4439 | using arcsin_sin [of "-pi/2"] | |
| 4440 | by simp | |
| 4441 | ||
| 4442 | lemma arcsin_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin(-x) = -arcsin x" | |
| 4443 | by (metis (no_types, hide_lams) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus) | |
| 4444 | ||
| 61944 | 4445 | lemma arcsin_eq_iff: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arcsin x = arcsin y \<longleftrightarrow> x = y)" | 
| 61649 
268d88ec9087
Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
 paulson <lp15@cam.ac.uk> parents: 
61609diff
changeset | 4446 | by (metis abs_le_iff arcsin minus_le_iff) | 
| 59869 | 4447 | |
| 4448 | lemma cos_arcsin_nonzero: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos(arcsin x) \<noteq> 0" | |
| 4449 | using arcsin_lt_bounded cos_gt_zero_pi by force | |
| 4450 | ||
| 22975 | 4451 | lemma arccos: | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4452 | "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> | 
| 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4453 | \<Longrightarrow> 0 \<le> arccos y & arccos y \<le> pi & cos(arccos y) = y" | 
| 53079 | 4454 | unfolding arccos_def by (rule theI' [OF cos_total]) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4455 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4456 | lemma cos_arccos [simp]: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> cos(arccos y) = y" | 
| 53079 | 4457 | by (blast dest: arccos) | 
| 41970 | 4458 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4459 | lemma arccos_bounded: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 \<le> arccos y & arccos y \<le> pi" | 
| 53079 | 4460 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4461 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4462 | lemma arccos_lbound: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 \<le> arccos y" | 
| 53079 | 4463 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4464 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4465 | lemma arccos_ubound: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> arccos y \<le> pi" | 
| 53079 | 4466 | by (blast dest: arccos) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4467 | |
| 22975 | 4468 | lemma arccos_lt_bounded: | 
| 59869 | 4469 | "\<lbrakk>-1 < y; y < 1\<rbrakk> \<Longrightarrow> 0 < arccos y & arccos y < pi" | 
| 53079 | 4470 | apply (frule order_less_imp_le) | 
| 4471 | apply (frule_tac y = y in order_less_imp_le) | |
| 4472 | apply (frule arccos_bounded, auto) | |
| 4473 | apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq) | |
| 4474 | apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto) | |
| 4475 | apply (drule_tac [!] f = cos in arg_cong, auto) | |
| 4476 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4477 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4478 | lemma arccos_cos: "\<lbrakk>0 \<le> x; x \<le> pi\<rbrakk> \<Longrightarrow> arccos(cos x) = x" | 
| 53079 | 4479 | apply (simp add: arccos_def) | 
| 4480 | apply (auto intro!: the1_equality cos_total) | |
| 4481 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4482 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4483 | lemma arccos_cos2: "\<lbrakk>x \<le> 0; -pi \<le> x\<rbrakk> \<Longrightarrow> arccos(cos x) = -x" | 
| 53079 | 4484 | apply (simp add: arccos_def) | 
| 4485 | apply (auto intro!: the1_equality cos_total) | |
| 4486 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4487 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4488 | lemma cos_arcsin: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> cos (arcsin x) = sqrt (1 - x\<^sup>2)" | 
| 53079 | 4489 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 4490 | apply (rule power2_eq_imp_eq) | |
| 4491 | apply (simp add: cos_squared_eq) | |
| 4492 | apply (rule cos_ge_zero) | |
| 4493 | apply (erule (1) arcsin_lbound) | |
| 4494 | apply (erule (1) arcsin_ubound) | |
| 4495 | apply simp | |
| 4496 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp) | |
| 4497 | apply (rule power_mono, simp, simp) | |
| 4498 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4499 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4500 | lemma sin_arccos: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> sin (arccos x) = sqrt (1 - x\<^sup>2)" | 
| 53079 | 4501 | apply (subgoal_tac "x\<^sup>2 \<le> 1") | 
| 4502 | apply (rule power2_eq_imp_eq) | |
| 4503 | apply (simp add: sin_squared_eq) | |
| 4504 | apply (rule sin_ge_zero) | |
| 4505 | apply (erule (1) arccos_lbound) | |
| 4506 | apply (erule (1) arccos_ubound) | |
| 4507 | apply simp | |
| 4508 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp) | |
| 4509 | apply (rule power_mono, simp, simp) | |
| 4510 | done | |
| 4511 | ||
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4512 | lemma arccos_0 [simp]: "arccos 0 = pi/2" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4513 | by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero pi_half_ge_zero not_le not_zero_less_neg_numeral numeral_One) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4514 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4515 | lemma arccos_1 [simp]: "arccos 1 = 0" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4516 | using arccos_cos by force | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4517 | |
| 59869 | 4518 | lemma arccos_minus_1 [simp]: "arccos(-1) = pi" | 
| 4519 | by (metis arccos_cos cos_pi order_refl pi_ge_zero) | |
| 4520 | ||
| 4521 | lemma arccos_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos(-x) = pi - arccos x" | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4522 | by (metis arccos_cos arccos_cos2 cos_minus_pi cos_total diff_le_0_iff_le le_add_same_cancel1 | 
| 59869 | 4523 | minus_diff_eq uminus_add_conv_diff) | 
| 4524 | ||
| 4525 | lemma sin_arccos_nonzero: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> ~(sin(arccos x) = 0)" | |
| 4526 | using arccos_lt_bounded sin_gt_zero by force | |
| 4527 | ||
| 4528 | lemma arctan: "- (pi/2) < arctan y & arctan y < pi/2 & tan (arctan y) = y" | |
| 53079 | 4529 | unfolding arctan_def by (rule theI' [OF tan_total]) | 
| 4530 | ||
| 4531 | lemma tan_arctan: "tan (arctan y) = y" | |
| 59869 | 4532 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4533 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4534 | lemma arctan_bounded: "- (pi/2) < arctan y & arctan y < pi/2" | 
| 53079 | 4535 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4536 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4537 | lemma arctan_lbound: "- (pi/2) < arctan y" | 
| 59869 | 4538 | by (simp add: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4539 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4540 | lemma arctan_ubound: "arctan y < pi/2" | 
| 53079 | 4541 | by (auto simp only: arctan) | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4542 | |
| 44746 | 4543 | lemma arctan_unique: | 
| 53079 | 4544 | assumes "-(pi/2) < x" | 
| 4545 | and "x < pi/2" | |
| 4546 | and "tan x = y" | |
| 44746 | 4547 | shows "arctan y = x" | 
| 4548 | using assms arctan [of y] tan_total [of y] by (fast elim: ex1E) | |
| 4549 | ||
| 53079 | 4550 | lemma arctan_tan: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> arctan (tan x) = x" | 
| 4551 | by (rule arctan_unique) simp_all | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4552 | |
| 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4553 | lemma arctan_zero_zero [simp]: "arctan 0 = 0" | 
| 53079 | 4554 | by (rule arctan_unique) simp_all | 
| 44746 | 4555 | |
| 4556 | lemma arctan_minus: "arctan (- x) = - arctan x" | |
| 4557 | apply (rule arctan_unique) | |
| 4558 | apply (simp only: neg_less_iff_less arctan_ubound) | |
| 59869 | 4559 | apply (metis minus_less_iff arctan_lbound, simp add: arctan) | 
| 44746 | 4560 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4561 | |
| 44725 | 4562 | lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0" | 
| 4563 | by (intro less_imp_neq [symmetric] cos_gt_zero_pi | |
| 4564 | arctan_lbound arctan_ubound) | |
| 4565 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4566 | lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)" | 
| 44725 | 4567 | 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 | 4568 | 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 | 4569 | show "0 \<le> 1 / sqrt (1 + x\<^sup>2)" by simp | 
| 44725 | 4570 | show "0 \<le> cos (arctan x)" | 
| 4571 | 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 | 4572 | 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 | 4573 | 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 | 4574 | thus "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2" | 
| 60758 | 4575 | using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq) | 
| 44725 | 4576 | qed | 
| 4577 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4578 | lemma sin_arctan: "sin (arctan x) = x / sqrt (1 + x\<^sup>2)" | 
| 44725 | 4579 | using add_pos_nonneg [OF zero_less_one zero_le_power2 [of x]] | 
| 4580 | using tan_arctan [of x] unfolding tan_def cos_arctan | |
| 4581 | by (simp add: eq_divide_eq) | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4582 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4583 | lemma tan_sec: | 
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59865diff
changeset | 4584 |   fixes x :: "'a::{real_normed_field,banach,field}"
 | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4585 | shows "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2" | 
| 53079 | 4586 | apply (rule power_inverse [THEN subst]) | 
| 56217 
dc429a5b13c4
Some rationalisation of basic lemmas
 paulson <lp15@cam.ac.uk> parents: 
56213diff
changeset | 4587 | apply (rule_tac c1 = "(cos x)\<^sup>2" in mult_right_cancel [THEN iffD1]) | 
| 60867 | 4588 | apply (auto simp add: tan_def field_simps) | 
| 53079 | 4589 | done | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 4590 | |
| 44746 | 4591 | lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y" | 
| 4592 | by (metis tan_monotone' arctan_lbound arctan_ubound tan_arctan) | |
| 4593 | ||
| 4594 | lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y" | |
| 4595 | by (simp only: not_less [symmetric] arctan_less_iff) | |
| 4596 | ||
| 4597 | lemma arctan_eq_iff: "arctan x = arctan y \<longleftrightarrow> x = y" | |
| 4598 | by (simp only: eq_iff [where 'a=real] arctan_le_iff) | |
| 4599 | ||
| 4600 | lemma zero_less_arctan_iff [simp]: "0 < arctan x \<longleftrightarrow> 0 < x" | |
| 4601 | using arctan_less_iff [of 0 x] by simp | |
| 4602 | ||
| 4603 | lemma arctan_less_zero_iff [simp]: "arctan x < 0 \<longleftrightarrow> x < 0" | |
| 4604 | using arctan_less_iff [of x 0] by simp | |
| 4605 | ||
| 4606 | lemma zero_le_arctan_iff [simp]: "0 \<le> arctan x \<longleftrightarrow> 0 \<le> x" | |
| 4607 | using arctan_le_iff [of 0 x] by simp | |
| 4608 | ||
| 4609 | lemma arctan_le_zero_iff [simp]: "arctan x \<le> 0 \<longleftrightarrow> x \<le> 0" | |
| 4610 | using arctan_le_iff [of x 0] by simp | |
| 4611 | ||
| 4612 | lemma arctan_eq_zero_iff [simp]: "arctan x = 0 \<longleftrightarrow> x = 0" | |
| 4613 | using arctan_eq_iff [of x 0] by simp | |
| 4614 | ||
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4615 | 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 | 4616 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4617 |   have "continuous_on (sin ` {- pi / 2 .. pi / 2}) arcsin"
 | 
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 4618 | by (rule continuous_on_inv) (auto intro: continuous_intros simp: arcsin_sin) | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4619 |   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 | 4620 | proof safe | 
| 53079 | 4621 | fix x :: real | 
| 4622 |     assume "x \<in> {-1..1}"
 | |
| 4623 |     then show "x \<in> sin ` {- pi / 2..pi / 2}"
 | |
| 4624 | using arcsin_lbound arcsin_ubound | |
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 4625 | 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 | 4626 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4627 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4628 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4629 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 4630 | lemma continuous_on_arcsin [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4631 | "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 | 4632 | 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 | 4633 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4634 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4635 | 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 | 4636 |   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 | 4637 | 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 | 4638 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4639 | 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 | 4640 | proof - | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4641 |   have "continuous_on (cos ` {0 .. pi}) arccos"
 | 
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 4642 | by (rule continuous_on_inv) (auto intro: continuous_intros simp: arccos_cos) | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4643 |   also have "cos ` {0 .. pi} = {-1 .. 1}"
 | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4644 | proof safe | 
| 53079 | 4645 | fix x :: real | 
| 4646 |     assume "x \<in> {-1..1}"
 | |
| 4647 |     then show "x \<in> cos ` {0..pi}"
 | |
| 4648 | using arccos_lbound arccos_ubound | |
| 4649 | 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 | 4650 | qed simp | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4651 | finally show ?thesis . | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4652 | qed | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4653 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 4654 | lemma continuous_on_arccos [continuous_intros]: | 
| 51482 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4655 | "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 | 4656 | 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 | 4657 | by (auto simp: comp_def subset_eq) | 
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4658 | |
| 
80efd8c49f52
arcsin and arccos are continuous on {0 .. 1} (including the endpoints)
 hoelzl parents: 
51481diff
changeset | 4659 | 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 | 4660 |   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 | 4661 | 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 | 4662 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4663 | lemma isCont_arctan: "isCont arctan x" | 
| 53079 | 4664 | apply (rule arctan_lbound [of x, THEN dense, THEN exE], clarify) | 
| 4665 | apply (rule arctan_ubound [of x, THEN dense, THEN exE], clarify) | |
| 59869 | 4666 | apply (subgoal_tac "isCont arctan (tan (arctan x))", simp add: arctan) | 
| 53079 | 4667 | apply (erule (1) isCont_inverse_function2 [where f=tan]) | 
| 4668 | apply (metis arctan_tan order_le_less_trans order_less_le_trans) | |
| 4669 | apply (metis cos_gt_zero_pi isCont_tan order_less_le_trans less_le) | |
| 4670 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4671 | |
| 61973 | 4672 | lemma tendsto_arctan [tendsto_intros]: "(f \<longlongrightarrow> x) F \<Longrightarrow> ((\<lambda>x. arctan (f x)) \<longlongrightarrow> arctan x) F" | 
| 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 | 4673 | 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 | 4674 | |
| 
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 | 4675 | 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 | 4676 | 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 | 4677 | |
| 56371 
fb9ae0727548
extend continuous_intros; remove continuous_on_intros and isCont_intros
 hoelzl parents: 
56261diff
changeset | 4678 | lemma continuous_on_arctan [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. arctan (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 | 4679 | unfolding continuous_on_def by (auto intro: tendsto_arctan) | 
| 53079 | 4680 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4681 | lemma DERIV_arcsin: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4682 | "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4683 | apply (rule DERIV_inverse_function [where f=sin and a="-1" and b=1]) | 
| 53079 | 4684 | apply (rule DERIV_cong [OF DERIV_sin]) | 
| 4685 | apply (simp add: cos_arcsin) | |
| 4686 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4687 | apply (rule power_strict_mono, simp, simp, simp, assumption, assumption) | 
| 53079 | 4688 | apply simp | 
| 4689 | apply (erule (1) isCont_arcsin) | |
| 4690 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4691 | |
| 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4692 | lemma DERIV_arccos: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4693 | "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))" | 
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4694 | apply (rule DERIV_inverse_function [where f=cos and a="-1" and b=1]) | 
| 53079 | 4695 | apply (rule DERIV_cong [OF DERIV_cos]) | 
| 4696 | apply (simp add: sin_arccos) | |
| 4697 | apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp) | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 4698 | apply (rule power_strict_mono, simp, simp, simp, assumption, assumption) | 
| 53079 | 4699 | apply simp | 
| 4700 | apply (erule (1) isCont_arccos) | |
| 4701 | done | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4702 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 4703 | lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)" | 
| 53079 | 4704 | apply (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"]) | 
| 4705 | apply (rule DERIV_cong [OF DERIV_tan]) | |
| 4706 | apply (rule cos_arctan_not_zero) | |
| 60867 | 4707 | apply (simp_all add: add_pos_nonneg arctan isCont_arctan) | 
| 4708 | apply (simp add: arctan power_inverse [symmetric] tan_sec [symmetric]) | |
| 53079 | 4709 | apply (subgoal_tac "0 < 1 + x\<^sup>2", simp) | 
| 59869 | 4710 | apply (simp_all add: add_pos_nonneg arctan isCont_arctan) | 
| 53079 | 4711 | done | 
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 4712 | |
| 31880 | 4713 | declare | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4714 | DERIV_arcsin[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 4715 | DERIV_arcsin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4716 | DERIV_arccos[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 4717 | DERIV_arccos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 56381 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 hoelzl parents: 
56371diff
changeset | 4718 | DERIV_arctan[THEN DERIV_chain2, derivative_intros] | 
| 61518 
ff12606337e9
new lemmas about topology, etc., for Cauchy integral formula
 paulson parents: 
61284diff
changeset | 4719 | DERIV_arctan[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros] | 
| 31880 | 4720 | |
| 61881 
b4bfa62e799d
Transcendental: use [simp]-canonical form - (pi/2)
 hoelzl parents: 
61810diff
changeset | 4721 | lemma filterlim_tan_at_right: "filterlim tan at_bot (at_right (- (pi/2)))" | 
| 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 | 4722 | 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]) | 
| 59869 | 4723 | (auto simp: arctan 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 | 4724 | 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 | 4725 | |
| 
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 | 4726 | 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 | 4727 | 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]) | 
| 59869 | 4728 | (auto simp: arctan 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 | 4729 | 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 | 4730 | |
| 61973 | 4731 | lemma tendsto_arctan_at_top: "(arctan \<longlongrightarrow> (pi/2)) 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 | 4732 | proof (rule tendstoI) | 
| 53079 | 4733 | fix e :: real | 
| 4734 | 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 | 4735 | 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 | 4736 | then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y" | 
| 60758 | 4737 | using \<open>0 < e\<close> by auto | 
| 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 | 4738 | |
| 
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 | 4739 | 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 | 4740 | proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI) | 
| 53079 | 4741 | fix x | 
| 4742 | 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 | 4743 | 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 | 4744 | 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 | 4745 | 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 | 4746 | by (subst (asm) arctan_tan) simp_all | 
| 60758 | 4747 | with arctan_ubound[of x, arith] y \<open>0 < e\<close> | 
| 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 | 4748 | 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 | 4749 | 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 | 4750 | 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 | 4751 | 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 | 4752 | |
| 61973 | 4753 | lemma tendsto_arctan_at_bot: "(arctan \<longlongrightarrow> - (pi/2)) at_bot" | 
| 53079 | 4754 | unfolding filterlim_at_bot_mirror arctan_minus | 
| 4755 | by (intro tendsto_minus tendsto_arctan_at_top) | |
| 4756 | ||
| 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 | 4757 | |
| 60758 | 4758 | subsection\<open>Prove Totality of the Trigonometric Functions\<close> | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4759 | |
| 59869 | 4760 | lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y" | 
| 4761 | by (simp add: abs_le_iff) | |
| 4762 | ||
| 4763 | lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)" | |
| 4764 | by (simp add: sin_arccos abs_le_iff) | |
| 4765 | ||
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4766 | lemma sin_mono_less_eq: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2; -(pi/2) \<le> y; y \<le> pi/2\<rbrakk> | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4767 | \<Longrightarrow> (sin(x) < sin(y) \<longleftrightarrow> x < y)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4768 | by (metis not_less_iff_gr_or_eq sin_monotone_2pi) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4769 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4770 | lemma sin_mono_le_eq: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2; -(pi/2) \<le> y; y \<le> pi/2\<rbrakk> | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4771 | \<Longrightarrow> (sin(x) \<le> sin(y) \<longleftrightarrow> x \<le> y)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4772 | by (meson leD le_less_linear sin_monotone_2pi sin_monotone_2pi_le) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4773 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4774 | lemma sin_inj_pi: | 
| 59869 | 4775 | "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2;-(pi/2) \<le> y; y \<le> pi/2; sin(x) = sin(y)\<rbrakk> \<Longrightarrow> x = y" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4776 | by (metis arcsin_sin) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4777 | |
| 59869 | 4778 | lemma cos_mono_less_eq: | 
| 4779 | "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi \<Longrightarrow> (cos(x) < cos(y) \<longleftrightarrow> y < x)" | |
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4780 | by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4781 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4782 | lemma cos_mono_le_eq: "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4783 | \<Longrightarrow> (cos(x) \<le> cos(y) \<longleftrightarrow> y \<le> x)" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4784 | by (metis arccos_cos cos_monotone_0_pi_le eq_iff linear) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4785 | |
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4786 | lemma cos_inj_pi: "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi ==> cos(x) = cos(y) | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4787 | \<Longrightarrow> x = y" | 
| 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4788 | by (metis arccos_cos) | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4789 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4790 | lemma arccos_le_pi2: "\<lbrakk>0 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> arccos y \<le> pi/2" | 
| 59751 
916c0f6c83e3
New material for complex sin, cos, tan, Ln, also some reorganisation
 paulson <lp15@cam.ac.uk> parents: 
59746diff
changeset | 4791 | by (metis (mono_tags) arccos_0 arccos cos_le_one cos_monotone_0_pi_le | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4792 | cos_pi cos_pi_half pi_half_ge_zero antisym_conv less_eq_neg_nonpos linear minus_minus order.trans order_refl) | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4793 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4794 | lemma sincos_total_pi_half: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4795 | assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4796 | shows "\<exists>t. 0 \<le> t \<and> t \<le> pi/2 \<and> x = cos t \<and> y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4797 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4798 | have x1: "x \<le> 1" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4799 | using assms | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4800 | by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2) | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4801 | moreover with assms have ax: "0 \<le> arccos x" "cos(arccos x) = x" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4802 | by (auto simp: arccos) | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4803 | moreover have "y = sqrt (1 - x\<^sup>2)" using assms | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4804 | by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4805 | ultimately show ?thesis using assms arccos_le_pi2 [of x] | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4806 | by (rule_tac x="arccos x" in exI) (auto simp: sin_arccos) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4807 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4808 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4809 | lemma sincos_total_pi: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4810 | assumes "0 \<le> y" and "x\<^sup>2 + y\<^sup>2 = 1" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4811 | shows "\<exists>t. 0 \<le> t \<and> t \<le> pi \<and> x = cos t \<and> y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4812 | proof (cases rule: le_cases [of 0 x]) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4813 | case le from sincos_total_pi_half [OF le] | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4814 | show ?thesis | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4815 | by (metis pi_ge_two pi_half_le_two add.commute add_le_cancel_left add_mono assms) | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4816 | next | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4817 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4818 | then have "0 \<le> -x" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4819 | by simp | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4820 | then obtain t where "t\<ge>0" "t \<le> pi/2" "-x = cos t" "y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4821 | using sincos_total_pi_half assms | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4822 | apply auto | 
| 60758 | 4823 | by (metis \<open>0 \<le> - x\<close> power2_minus) | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4824 | then show ?thesis | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4825 | by (rule_tac x="pi-t" in exI, auto) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4826 | qed | 
| 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4827 | |
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4828 | lemma sincos_total_2pi_le: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4829 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4830 | shows "\<exists>t. 0 \<le> t \<and> t \<le> 2*pi \<and> x = cos t \<and> y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4831 | proof (cases rule: le_cases [of 0 y]) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4832 | case le from sincos_total_pi [OF le] | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4833 | show ?thesis | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4834 | by (metis assms le_add_same_cancel1 mult.commute mult_2_right order.trans) | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4835 | next | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4836 | case ge | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4837 | then have "0 \<le> -y" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4838 | by simp | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4839 | then obtain t where "t\<ge>0" "t \<le> pi" "x = cos t" "-y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4840 | using sincos_total_pi assms | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4841 | apply auto | 
| 60758 | 4842 | by (metis \<open>0 \<le> - y\<close> power2_minus) | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4843 | then show ?thesis | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4844 | by (rule_tac x="2*pi-t" in exI, auto) | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4845 | qed | 
| 59746 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4846 | |
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4847 | lemma sincos_total_2pi: | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4848 | assumes "x\<^sup>2 + y\<^sup>2 = 1" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4849 | obtains t where "0 \<le> t" "t < 2*pi" "x = cos t" "y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4850 | proof - | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4851 | from sincos_total_2pi_le [OF assms] | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4852 | obtain t where t: "0 \<le> t" "t \<le> 2*pi" "x = cos t" "y = sin t" | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4853 | by blast | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4854 | show ?thesis | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4855 | apply (cases "t = 2*pi") | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4856 | using t that | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4857 | apply force+ | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4858 | done | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4859 | qed | 
| 
ddae5727c5a9
new HOL Light material about exp, sin, cos
 paulson <lp15@cam.ac.uk> parents: 
59741diff
changeset | 4860 | |
| 61944 | 4861 | lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y" | 
| 59869 | 4862 | apply (rule trans [OF sin_mono_less_eq [symmetric]]) | 
| 4863 | using arcsin_ubound arcsin_lbound | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 4864 | apply auto | 
| 59869 | 4865 | done | 
| 4866 | ||
| 61944 | 4867 | lemma arcsin_le_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y \<longleftrightarrow> x \<le> y" | 
| 59869 | 4868 | using arcsin_less_mono not_le by blast | 
| 4869 | ||
| 4870 | lemma arcsin_less_arcsin: "-1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y" | |
| 4871 | using arcsin_less_mono by auto | |
| 4872 | ||
| 4873 | lemma arcsin_le_arcsin: "-1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y" | |
| 4874 | using arcsin_le_mono by auto | |
| 4875 | ||
| 61944 | 4876 | lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arccos x < arccos y \<longleftrightarrow> y < x)" | 
| 59869 | 4877 | apply (rule trans [OF cos_mono_less_eq [symmetric]]) | 
| 4878 | using arccos_ubound arccos_lbound | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 4879 | apply auto | 
| 59869 | 4880 | done | 
| 4881 | ||
| 61944 | 4882 | lemma arccos_le_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x \<le> arccos y \<longleftrightarrow> y \<le> x" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4883 | using arccos_less_mono [of y x] | 
| 59869 | 4884 | by (simp add: not_le [symmetric]) | 
| 4885 | ||
| 4886 | lemma arccos_less_arccos: "-1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x" | |
| 4887 | using arccos_less_mono by auto | |
| 4888 | ||
| 4889 | lemma arccos_le_arccos: "-1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x" | |
| 4890 | using arccos_le_mono by auto | |
| 4891 | ||
| 61944 | 4892 | lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 & \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arccos x = arccos y \<longleftrightarrow> x = y)" | 
| 59869 | 4893 | using cos_arccos_abs by fastforce | 
| 4894 | ||
| 60758 | 4895 | subsection \<open>Machins formula\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4896 | |
| 44746 | 4897 | lemma arctan_one: "arctan 1 = pi / 4" | 
| 4898 | by (rule arctan_unique, simp_all add: tan_45 m2pi_less_pi) | |
| 4899 | ||
| 53079 | 4900 | lemma tan_total_pi4: | 
| 4901 | assumes "\<bar>x\<bar> < 1" | |
| 4902 | shows "\<exists>z. - (pi / 4) < z \<and> z < pi / 4 \<and> tan z = x" | |
| 44746 | 4903 | proof | 
| 4904 | show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x" | |
| 4905 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 59869 | 4906 | unfolding arctan_less_iff using assms by (auto simp add: arctan) | 
| 4907 | ||
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4908 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4909 | |
| 53079 | 4910 | lemma arctan_add: | 
| 4911 | 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 | 4912 | shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))" | 
| 44746 | 4913 | proof (rule arctan_unique [symmetric]) | 
| 4914 | have "- (pi / 4) \<le> arctan x" and "- (pi / 4) < arctan y" | |
| 4915 | unfolding arctan_one [symmetric] arctan_minus [symmetric] | |
| 4916 | unfolding arctan_le_iff arctan_less_iff using assms by auto | |
| 4917 | from add_le_less_mono [OF this] | |
| 4918 | show 1: "- (pi / 2) < arctan x + arctan y" by simp | |
| 4919 | have "arctan x \<le> pi / 4" and "arctan y < pi / 4" | |
| 4920 | unfolding arctan_one [symmetric] | |
| 4921 | unfolding arctan_le_iff arctan_less_iff using assms by auto | |
| 4922 | from add_le_less_mono [OF this] | |
| 4923 | show 2: "arctan x + arctan y < pi / 2" by simp | |
| 4924 | show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)" | |
| 59869 | 4925 | using cos_gt_zero_pi [OF 1 2] by (simp add: arctan tan_add) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4926 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4927 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4928 | lemma arctan_double: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4929 | assumes "\<bar>x\<bar> < 1" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4930 | shows "2 * arctan x = arctan ((2*x) / (1 - x\<^sup>2))" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4931 | by (metis assms arctan_add linear mult_2 not_less power2_eq_square) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4932 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4933 | 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 | 4934 | proof - | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4935 | 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 | 4936 | 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 | 4937 | 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 | 4938 | moreover | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4939 | 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 | 4940 | 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 | 4941 | have "2 * arctan (5 / 12) = arctan (120 / 119)" by auto | 
| 41970 | 4942 | moreover | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4943 | 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 | 4944 | 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 | 4945 | 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 | 4946 | ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)" by auto | 
| 44746 | 4947 | 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 | 4948 | qed | 
| 44746 | 4949 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4950 | lemma machin_Euler: "5 * arctan(1/7) + 2 * arctan(3/79) = pi/4" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4951 | proof - | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4952 | have 17: "\<bar>1/7\<bar> < (1 :: real)" by auto | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4953 | with arctan_double have "2 * arctan (1/7) = arctan (7/24)" | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4954 | by simp (simp add: field_simps) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4955 | moreover have "\<bar>7/24\<bar> < (1 :: real)" by auto | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4956 | with arctan_double have "2 * arctan (7/24) = arctan (336/527)" by simp (simp add: field_simps) | 
| 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4957 | moreover have "\<bar>336/527\<bar> < (1 :: real)" by auto | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4958 | from arctan_add[OF less_imp_le[OF 17] this] | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 4959 | have "arctan(1/7) + arctan (336/527) = arctan (2879/3353)" by auto | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4960 | ultimately have I: "5 * arctan(1/7) = arctan (2879/3353)" by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4961 | have 379: "\<bar>3/79\<bar> < (1 :: real)" by auto | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 4962 | with arctan_double have II: "2 * arctan (3/79) = arctan (237/3116)" by simp (simp add: field_simps) | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4963 | have *: "\<bar>2879/3353\<bar> < (1 :: real)" by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4964 | have "\<bar>237/3116\<bar> < (1 :: real)" by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4965 | from arctan_add[OF less_imp_le[OF *] this] | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4966 | have "arctan (2879/3353) + arctan (237/3116) = pi/4" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4967 | by (simp add: arctan_one) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4968 | then show ?thesis using I II | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4969 | by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4970 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4971 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4972 | (*But could also prove MACHIN_GAUSS: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4973 | 12 * arctan(1/18) + 8 * arctan(1/57) - 5 * arctan(1/239) = pi/4*) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 4974 | |
| 53079 | 4975 | |
| 60758 | 4976 | subsection \<open>Introducing the inverse tangent power series\<close> | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4977 | |
| 53079 | 4978 | lemma monoseq_arctan_series: | 
| 4979 | fixes x :: real | |
| 4980 | assumes "\<bar>x\<bar> \<le> 1" | |
| 4981 | shows "monoseq (\<lambda> n. 1 / real (n*2+1) * x^(n*2+1))" (is "monoseq ?a") | |
| 4982 | proof (cases "x = 0") | |
| 4983 | case True | |
| 4984 | 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 | 4985 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4986 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4987 | 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 | 4988 | show "monoseq ?a" | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 4989 | proof - | 
| 53079 | 4990 |     {
 | 
| 4991 | fix n | |
| 4992 | fix x :: real | |
| 4993 | assume "0 \<le> x" and "x \<le> 1" | |
| 4994 | have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le> | |
| 4995 | 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 | 4996 | proof (rule mult_mono) | 
| 53079 | 4997 | show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))" | 
| 4998 | by (rule frac_le) simp_all | |
| 4999 | show "0 \<le> 1 / real (Suc (n * 2))" | |
| 5000 | by auto | |
| 5001 | show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)" | |
| 60758 | 5002 | by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>) | 
| 53079 | 5003 | show "0 \<le> x ^ Suc (Suc n * 2)" | 
| 60758 | 5004 | by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5005 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5006 | } note mono = this | 
| 41970 | 5007 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5008 | show ?thesis | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5009 | proof (cases "0 \<le> x") | 
| 60758 | 5010 | case True from mono[OF this \<open>x \<le> 1\<close>, THEN allI] | 
| 53079 | 5011 | show ?thesis unfolding Suc_eq_plus1[symmetric] | 
| 5012 | 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 | 5013 | next | 
| 53079 | 5014 | case False | 
| 60758 | 5015 | hence "0 \<le> -x" and "-x \<le> 1" using \<open>-1 \<le> x\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5016 | from mono[OF this] | 
| 53079 | 5017 | have "\<And>n. 1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge> | 
| 60758 | 5018 | 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" using \<open>0 \<le> -x\<close> by auto | 
| 31790 | 5019 | 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 | 5020 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5021 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5022 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5023 | |
| 53079 | 5024 | lemma zeroseq_arctan_series: | 
| 5025 | fixes x :: real | |
| 5026 | assumes "\<bar>x\<bar> \<le> 1" | |
| 61969 | 5027 | shows "(\<lambda> n. 1 / real (n*2+1) * x^(n*2+1)) \<longlonglongrightarrow> 0" (is "?a \<longlonglongrightarrow> 0") | 
| 53079 | 5028 | proof (cases "x = 0") | 
| 5029 | case True | |
| 5030 | thus ?thesis | |
| 58729 
e8ecc79aee43
add tendsto_const and tendsto_ident_at as simp and intro rules
 hoelzl parents: 
58710diff
changeset | 5031 | 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 | 5032 | next | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5033 | case False | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5034 | have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" using assms by auto | 
| 61969 | 5035 | show "?a \<longlonglongrightarrow> 0" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5036 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5037 | case True | 
| 5038 | hence "norm x < 1" by auto | |
| 60758 | 5039 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]] | 
| 61969 | 5040 | have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0" | 
| 31790 | 5041 | 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 | 5042 | 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 | 5043 | next | 
| 53079 | 5044 | case False | 
| 60758 | 5045 | hence "x = -1 \<or> x = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | 
| 53079 | 5046 | hence n_eq: "\<And> n. x ^ (n * 2 + 1) = x" | 
| 5047 | 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 | 5048 | from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]] | 
| 31790 | 5049 | 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 | 5050 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5051 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5052 | |
| 53079 | 5053 | lemma summable_arctan_series: | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 5054 | fixes n :: nat | 
| 53079 | 5055 | assumes "\<bar>x\<bar> \<le> 1" | 
| 5056 | shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 5057 | (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 | 5058 | 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 | 5059 | |
| 53079 | 5060 | lemma DERIV_arctan_series: | 
| 5061 | assumes "\<bar> x \<bar> < 1" | |
| 5062 | 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))" | |
| 5063 | (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 | 5064 | proof - | 
| 53079 | 5065 | let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0" | 
| 5066 | ||
| 5067 | have n_even: "\<And>n :: nat. even n \<Longrightarrow> 2 * (n div 2) = n" | |
| 5068 | by presburger | |
| 5069 | then have if_eq: "\<And>n x'. ?f n * real (Suc n) * x'^n = | |
| 5070 | (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)" | |
| 5071 | by auto | |
| 5072 | ||
| 5073 |   {
 | |
| 5074 | fix x :: real | |
| 5075 | assume "\<bar>x\<bar> < 1" | |
| 59865 
8a20dd967385
rationalised and generalised some theorems concerning abs and x^2.
 paulson <lp15@cam.ac.uk> parents: 
59862diff
changeset | 5076 | hence "x\<^sup>2 < 1" by (simp add: abs_square_less_1) | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5077 | have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)" | 
| 60758 | 5078 | by (rule summable_Leibniz(1), auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>]) | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5079 | hence "summable (\<lambda> n. (- 1) ^ n * x^(2*n))" unfolding power_mult . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5080 | } 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 | 5081 | |
| 53079 | 5082 |   {
 | 
| 5083 | fix f :: "nat \<Rightarrow> real" | |
| 5084 | 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 | 5085 | proof | 
| 53079 | 5086 | fix x :: real | 
| 5087 | 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 | 5088 | from sums_if[OF sums_zero this] | 
| 53079 | 5089 | show "(\<lambda>n. if even n then f (n div 2) else 0) sums x" | 
| 5090 | by auto | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5091 | next | 
| 53079 | 5092 | fix x :: real | 
| 5093 | assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 5094 | from LIMSEQ_linear[OF this[unfolded sums_def] pos2, unfolded sum_split_even_odd[unfolded mult.commute]] | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5095 | 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 | 5096 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5097 | 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 | 5098 | } 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 | 5099 | |
| 53079 | 5100 | have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int" | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5101 | 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 | 5102 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5103 | |
| 53079 | 5104 |   {
 | 
| 5105 | fix x :: real | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5106 | have if_eq': "\<And>n. (if even n then (- 1) ^ (n div 2) * 1 / real (Suc n) else 0) * x ^ Suc n = | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5107 | (if even n then (- 1) ^ (n div 2) * (1 / real (Suc (2 * (n div 2))) * x ^ Suc (2 * (n div 2))) else 0)" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5108 | using n_even by auto | 
| 53079 | 5109 | have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" by auto | 
| 5110 | have "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5111 | 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 | 5112 | by auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5113 | } 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 | 5114 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5115 | 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 | 5116 | proof (rule DERIV_power_series') | 
| 60758 | 5117 |     show "x \<in> {- 1 <..< 1}" using \<open>\<bar> x \<bar> < 1\<close> by auto
 | 
| 53079 | 5118 |     {
 | 
| 5119 | fix x' :: real | |
| 5120 |       assume x'_bounds: "x' \<in> {- 1 <..< 1}"
 | |
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5121 | then have "\<bar>x'\<bar> < 1" by auto | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5122 | then | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5123 | have *: "summable (\<lambda>n. (- 1) ^ n * x' ^ (2 * n))" | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5124 | by (rule summable_Integral) | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5125 | 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 | 5126 | show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" unfolding if_eq | 
| 58410 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5127 | apply (rule sums_summable [where l="0 + ?S"]) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5128 | apply (rule sums_if) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5129 | apply (rule sums_zero) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5130 | apply (rule summable_sums) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5131 | apply (rule *) | 
| 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 haftmann parents: 
57514diff
changeset | 5132 | done | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5133 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5134 | qed auto | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5135 | 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 | 5136 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5137 | |
| 53079 | 5138 | lemma arctan_series: | 
| 5139 | assumes "\<bar> x \<bar> \<le> 1" | |
| 5140 | shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))" | |
| 5141 | (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 | 5142 | proof - | 
| 53079 | 5143 | let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)" | 
| 5144 | ||
| 5145 |   {
 | |
| 5146 | fix r x :: real | |
| 5147 | assume "0 < r" and "r < 1" and "\<bar> x \<bar> < r" | |
| 60758 | 5148 | have "\<bar>x\<bar> < 1" using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto | 
| 53079 | 5149 | 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 | 5150 | } 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 | 5151 | |
| 53079 | 5152 |   {
 | 
| 5153 | fix x :: real | |
| 5154 | assume "\<bar>x\<bar> \<le> 1" | |
| 5155 | note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]] | |
| 5156 | } note arctan_series_borders = this | |
| 5157 | ||
| 5158 |   {
 | |
| 5159 | fix x :: real | |
| 5160 | assume "\<bar>x\<bar> < 1" | |
| 5161 | 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 | 5162 | proof - | 
| 53079 | 5163 | obtain r where "\<bar>x\<bar> < r" and "r < 1" | 
| 60758 | 5164 | using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast | 
| 53079 | 5165 | hence "0 < r" and "-r < x" and "x < r" by auto | 
| 5166 | ||
| 5167 | have suminf_eq_arctan_bounded: "\<And>x a b. \<lbrakk> -r < a ; b < r ; a < b ; a \<le> x ; x \<le> b \<rbrakk> \<Longrightarrow> | |
| 5168 | suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5169 | proof - | |
| 5170 | fix x a b | |
| 5171 | assume "-r < a" and "b < r" and "a < b" and "a \<le> x" and "x \<le> b" | |
| 5172 | hence "\<bar>x\<bar> < r" by auto | |
| 5173 | show "suminf (?c x) - arctan x = suminf (?c a) - arctan a" | |
| 5174 | proof (rule DERIV_isconst2[of "a" "b"]) | |
| 5175 | show "a < b" and "a \<le> x" and "x \<le> b" | |
| 60758 | 5176 | using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto | 
| 53079 | 5177 | have "\<forall>x. -r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0" | 
| 5178 | proof (rule allI, rule impI) | |
| 5179 | fix x | |
| 5180 | assume "-r < x \<and> x < r" | |
| 5181 | hence "\<bar>x\<bar> < r" by auto | |
| 60758 | 5182 | hence "\<bar>x\<bar> < 1" using \<open>r < 1\<close> by auto | 
| 53079 | 5183 | have "\<bar> - (x\<^sup>2) \<bar> < 1" | 
| 60758 | 5184 | using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto | 
| 53079 | 5185 | hence "(\<lambda> n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))" | 
| 5186 | unfolding real_norm_def[symmetric] by (rule geometric_sums) | |
| 5187 | hence "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57492diff
changeset | 5188 | unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto | 
| 53079 | 5189 | hence suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)" | 
| 5190 | using sums_unique unfolding inverse_eq_divide by auto | |
| 5191 | have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))" | |
| 5192 | unfolding suminf_c'_eq_geom | |
| 60758 | 5193 | by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>]) | 
| 56261 | 5194 | from DERIV_diff [OF this DERIV_arctan] | 
| 53079 | 5195 | 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 | 5196 | by auto | 
| 53079 | 5197 | qed | 
| 5198 | hence DERIV_in_rball: "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0" | |
| 60758 | 5199 | using \<open>-r < a\<close> \<open>b < r\<close> by auto | 
| 53079 | 5200 | thus "\<forall> y. a < y \<and> y < b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0" | 
| 60758 | 5201 | using \<open>\<bar>x\<bar> < r\<close> by auto | 
| 53079 | 5202 | show "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> isCont (\<lambda> x. suminf (?c x) - arctan x) y" | 
| 5203 | 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 | 5204 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5205 | qed | 
| 53079 | 5206 | |
| 5207 | have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0" | |
| 5208 | unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero | |
| 5209 | by auto | |
| 5210 | ||
| 5211 | have "suminf (?c x) - arctan x = 0" | |
| 5212 | proof (cases "x = 0") | |
| 5213 | case True | |
| 5214 | thus ?thesis using suminf_arctan_zero by auto | |
| 5215 | next | |
| 5216 | case False | |
| 5217 | hence "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" by auto | |
| 5218 | have "suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>) = suminf (?c 0) - arctan 0" | |
| 59647 
c6f413b660cf
clarified Drule.gen_all: observe context more carefully;
 wenzelm parents: 
59613diff
changeset | 5219 | by (rule suminf_eq_arctan_bounded[where x1="0" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric]) | 
| 60758 | 5220 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 53079 | 5221 | moreover | 
| 5222 | have "suminf (?c x) - arctan x = suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>)" | |
| 59647 
c6f413b660cf
clarified Drule.gen_all: observe context more carefully;
 wenzelm parents: 
59613diff
changeset | 5223 | by (rule suminf_eq_arctan_bounded[where x1="x" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>"]) | 
| 60758 | 5224 | (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less) | 
| 53079 | 5225 | ultimately | 
| 5226 | show ?thesis using suminf_arctan_zero by auto | |
| 5227 | qed | |
| 5228 | 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 | 5229 | qed | 
| 53079 | 5230 | } 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 | 5231 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5232 | 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 | 5233 | proof (cases "\<bar>x\<bar> < 1") | 
| 53079 | 5234 | case True | 
| 5235 | thus ?thesis by (rule when_less_one) | |
| 5236 | next | |
| 5237 | case False | |
| 60758 | 5238 | hence "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto | 
| 53079 | 5239 | let ?a = "\<lambda>x n. \<bar>1 / real (n*2+1) * x^(n*2+1)\<bar>" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 5240 | let ?diff = "\<lambda> x n. \<bar> arctan x - (\<Sum> i<n. ?c x i)\<bar>" | 
| 53079 | 5241 |     {
 | 
| 5242 | 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 | 5243 | 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 | 5244 | moreover | 
| 53079 | 5245 |       {
 | 
| 5246 | fix x :: real | |
| 5247 | assume "0 < x" and "x < 1" | |
| 5248 | hence "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" by auto | |
| 60758 | 5249 | from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)" | 
| 53079 | 5250 | by auto | 
| 60758 | 5251 | note bounds = mp[OF arctan_series_borders(2)[OF \<open>\<bar>x\<bar> \<le> 1\<close>] this, unfolded when_less_one[OF \<open>\<bar>x\<bar> < 1\<close>, symmetric], THEN spec] | 
| 53079 | 5252 | have "0 < 1 / real (n*2+1) * x^(n*2+1)" | 
| 60758 | 5253 | by (rule mult_pos_pos, auto simp only: zero_less_power[OF \<open>0 < x\<close>], auto) | 
| 53079 | 5254 | hence a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)" | 
| 5255 | 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 | 5256 | 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 | 5257 | proof (cases "even n") | 
| 53079 | 5258 | case True | 
| 5259 | hence sgn_pos: "(-1)^n = (1::real)" by auto | |
| 60758 | 5260 | from \<open>even n\<close> obtain m where "n = 2 * m" .. | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 5261 | then have "2 * m = n" .. | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5262 | from bounds[of m, unfolded this atLeastAtMost_iff] | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 5263 | have "\<bar>arctan x - (\<Sum>i<n. (?c x i))\<bar> \<le> (\<Sum>i<n + 1. (?c x i)) - (\<Sum>i<n. (?c x i))" | 
| 53079 | 5264 | by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5265 | 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 | 5266 | 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 | 5267 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5268 | next | 
| 53079 | 5269 | case False | 
| 5270 | hence sgn_neg: "(-1)^n = (-1::real)" by auto | |
| 60758 | 5271 | from \<open>odd n\<close> obtain m where "n = 2 * m + 1" .. | 
| 58709 
efdc6c533bd3
prefer generic elimination rules for even/odd over specialized unfold rules for nat
 haftmann parents: 
58656diff
changeset | 5272 | then have m_def: "2 * m + 1 = n" .. | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5273 | 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 | 5274 | from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2] | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
56181diff
changeset | 5275 | have "\<bar>arctan x - (\<Sum>i<n. (?c x i))\<bar> \<le> (\<Sum>i<n. (?c x i)) - (\<Sum>i<n+1. (?c x i))" | 
| 53079 | 5276 | by auto | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5277 | 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 | 5278 | 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 | 5279 | finally show ?thesis . | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32047diff
changeset | 5280 | qed | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5281 | 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 | 5282 | } | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5283 |       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 | 5284 | 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 | 5285 | unfolding diff_conv_add_uminus divide_inverse | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5286 | by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5287 | isCont_inverse isCont_mult isCont_power continuous_const isCont_setsum | 
| 54230 
b1d955791529
more simplification rules on unary and binary minus
 haftmann parents: 
53602diff
changeset | 5288 | simp del: add_uminus_conv_diff) | 
| 53079 | 5289 | ultimately have "0 \<le> ?a 1 n - ?diff 1 n" | 
| 5290 | 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 | 5291 | 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 | 5292 | } | 
| 61969 | 5293 | have "?a 1 \<longlonglongrightarrow> 0" | 
| 44568 
e6f291cb5810
discontinue many legacy theorems about LIM and LIMSEQ, in favor of tendsto theorems
 huffman parents: 
44319diff
changeset | 5294 | unfolding tendsto_rabs_zero_iff power_one divide_inverse One_nat_def | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5295 | by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc) | 
| 61969 | 5296 | have "?diff 1 \<longlonglongrightarrow> 0" | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5297 | proof (rule LIMSEQ_I) | 
| 53079 | 5298 | fix r :: real | 
| 5299 | assume "0 < r" | |
| 5300 | obtain N :: nat where N_I: "\<And>n. N \<le> n \<Longrightarrow> ?a 1 n < r" | |
| 61969 | 5301 | using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto | 
| 53079 | 5302 |       {
 | 
| 5303 | fix n | |
| 60758 | 5304 | assume "N \<le> n" from \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF this] | 
| 53079 | 5305 | have "norm (?diff 1 n - 0) < r" by auto | 
| 5306 | } | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5307 | 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 | 5308 | qed | 
| 44710 | 5309 | 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 | 5310 | 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 | 5311 | hence "arctan 1 = (\<Sum> i. ?c 1 i)" by (rule sums_unique) | 
| 41970 | 5312 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5313 | show ?thesis | 
| 53079 | 5314 | proof (cases "x = 1") | 
| 5315 | case True | |
| 60758 | 5316 | then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>) | 
| 53079 | 5317 | next | 
| 5318 | case False | |
| 60758 | 5319 | hence "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto | 
| 41970 | 5320 | |
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5321 | 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 | 5322 | have "- (2 * pi) < 0" using pi_gt_zero by auto | 
| 41970 | 5323 | |
| 53079 | 5324 | have c_minus_minus: "\<And>i. ?c (- 1) i = - ?c 1 i" | 
| 5325 | unfolding One_nat_def by auto | |
| 5326 | ||
| 5327 | have "arctan (- 1) = arctan (tan (-(pi / 4)))" | |
| 5328 | unfolding tan_45 tan_minus .. | |
| 5329 | also have "\<dots> = - (pi / 4)" | |
| 60758 | 5330 | by (rule arctan_tan, auto simp add: order_less_trans[OF \<open>- (pi / 2) < 0\<close> pi_gt_zero]) | 
| 53079 | 5331 | also have "\<dots> = - (arctan (tan (pi / 4)))" | 
| 60758 | 5332 | unfolding neg_equal_iff_equal by (rule arctan_tan[symmetric], auto simp add: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero]) | 
| 53079 | 5333 | also have "\<dots> = - (arctan 1)" | 
| 5334 | unfolding tan_45 .. | |
| 5335 | also have "\<dots> = - (\<Sum> i. ?c 1 i)" | |
| 60758 | 5336 | using \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close> by auto | 
| 53079 | 5337 | also have "\<dots> = (\<Sum> i. ?c (- 1) i)" | 
| 60758 | 5338 | using suminf_minus[OF sums_summable[OF \<open>(?c 1) sums (arctan 1)\<close>]] | 
| 53079 | 5339 | unfolding c_minus_minus by auto | 
| 60758 | 5340 | finally show ?thesis using \<open>x = -1\<close> by auto | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5341 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5342 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5343 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5344 | |
| 53079 | 5345 | lemma arctan_half: | 
| 5346 | fixes x :: real | |
| 53076 | 5347 | 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 | 5348 | proof - | 
| 53079 | 5349 | obtain y where low: "- (pi / 2) < y" and high: "y < pi / 2" and y_eq: "tan y = x" | 
| 5350 | using tan_total by blast | |
| 5351 | hence low2: "- (pi / 2) < y / 2" and high2: "y / 2 < pi / 2" | |
| 5352 | by auto | |
| 5353 | ||
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5354 | have "0 < cos y" using cos_gt_zero_pi[OF low high] . | 
| 53079 | 5355 | hence "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y" | 
| 5356 | by auto | |
| 5357 | ||
| 5358 | have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 5359 | unfolding tan_def power_divide .. | |
| 5360 | also have "\<dots> = (cos y)\<^sup>2 / (cos y)\<^sup>2 + (sin y)\<^sup>2 / (cos y)\<^sup>2" | |
| 60758 | 5361 | using \<open>cos y \<noteq> 0\<close> by auto | 
| 53079 | 5362 | also have "\<dots> = 1 / (cos y)\<^sup>2" | 
| 5363 | unfolding add_divide_distrib[symmetric] sin_cos_squared_add2 .. | |
| 53076 | 5364 | 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 | 5365 | |
| 53079 | 5366 | have "sin y / (cos y + 1) = tan y / ((cos y + 1) / cos y)" | 
| 60758 | 5367 | unfolding tan_def using \<open>cos y \<noteq> 0\<close> by (simp add: field_simps) | 
| 53079 | 5368 | also have "\<dots> = tan y / (1 + 1 / cos y)" | 
| 60758 | 5369 | using \<open>cos y \<noteq> 0\<close> unfolding add_divide_distrib by auto | 
| 53079 | 5370 | also have "\<dots> = tan y / (1 + 1 / sqrt ((cos y)\<^sup>2))" | 
| 5371 | unfolding cos_sqrt .. | |
| 5372 | also have "\<dots> = tan y / (1 + sqrt (1 / (cos y)\<^sup>2))" | |
| 5373 | unfolding real_sqrt_divide by auto | |
| 5374 | finally have eq: "sin y / (cos y + 1) = tan y / (1 + sqrt(1 + (tan y)\<^sup>2))" | |
| 60758 | 5375 | unfolding \<open>1 + (tan y)\<^sup>2 = 1 / (cos y)\<^sup>2\<close> . | 
| 53079 | 5376 | |
| 5377 | have "arctan x = y" | |
| 5378 | using arctan_tan low high y_eq by auto | |
| 5379 | also have "\<dots> = 2 * (arctan (tan (y/2)))" | |
| 5380 | using arctan_tan[OF low2 high2] by auto | |
| 5381 | also have "\<dots> = 2 * (arctan (sin y / (cos y + 1)))" | |
| 5382 | unfolding tan_half by auto | |
| 5383 | finally show ?thesis | |
| 60758 | 5384 | unfolding eq \<open>tan y = x\<close> . | 
| 29803 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5385 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5386 | |
| 53079 | 5387 | lemma arctan_monotone: "x < y \<Longrightarrow> arctan x < arctan y" | 
| 5388 | by (simp only: arctan_less_iff) | |
| 5389 | ||
| 5390 | lemma arctan_monotone': "x \<le> y \<Longrightarrow> arctan x \<le> arctan y" | |
| 5391 | by (simp only: arctan_le_iff) | |
| 44746 | 5392 | |
| 5393 | lemma arctan_inverse: | |
| 53079 | 5394 | assumes "x \<noteq> 0" | 
| 5395 | shows "arctan (1 / x) = sgn x * pi / 2 - arctan x" | |
| 44746 | 5396 | proof (rule arctan_unique) | 
| 5397 | show "- (pi / 2) < sgn x * pi / 2 - arctan x" | |
| 5398 | using arctan_bounded [of x] assms | |
| 5399 | unfolding sgn_real_def | |
| 59869 | 5400 | apply (auto simp add: arctan algebra_simps) | 
| 44746 | 5401 | apply (drule zero_less_arctan_iff [THEN iffD2]) | 
| 5402 | apply arith | |
| 5403 | done | |
| 5404 | show "sgn x * pi / 2 - arctan x < pi / 2" | |
| 5405 | using arctan_bounded [of "- x"] assms | |
| 5406 | unfolding sgn_real_def arctan_minus | |
| 54489 
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
 haftmann parents: 
54230diff
changeset | 5407 | by (auto simp add: algebra_simps) | 
| 44746 | 5408 | show "tan (sgn x * pi / 2 - arctan x) = 1 / x" | 
| 5409 | unfolding tan_inverse [of "arctan x", unfolded tan_arctan] | |
| 5410 | unfolding sgn_real_def | |
| 56479 
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
 hoelzl parents: 
56409diff
changeset | 5411 | 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 | 5412 | qed | 
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5413 | |
| 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 hoelzl parents: 
29695diff
changeset | 5414 | 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 | 5415 | proof - | 
| 44746 | 5416 | 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 | 5417 | 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 | 5418 | 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 | 5419 | qed | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5420 | |
| 53079 | 5421 | |
| 60758 | 5422 | subsection \<open>Existence of Polar Coordinates\<close> | 
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5423 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52139diff
changeset | 5424 | lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1" | 
| 53079 | 5425 | apply (rule power2_le_imp_le [OF _ zero_le_one]) | 
| 5426 | apply (simp add: power_divide divide_le_eq not_sum_power2_lt_zero) | |
| 5427 | done | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5428 | |
| 22978 
1cd8cc21a7c3
clean up polar_Ex proofs; remove unnecessary lemmas
 huffman parents: 
22977diff
changeset | 5429 | lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one] | 
| 15228 | 5430 | |
| 23045 
95e04f335940
add lemmas about inverse functions; cleaned up proof of polar_ex
 huffman parents: 
23043diff
changeset | 5431 | 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 | 5432 | |
| 59658 
0cc388370041
sin, cos generalised from type real to any "'a::{real_normed_field,banach}", including complex
 paulson <lp15@cam.ac.uk> parents: 
59647diff
changeset | 5433 | lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a & y = r * sin a" | 
| 54573 | 5434 | proof - | 
| 5435 | have polar_ex1: "\<And>y. 0 < y \<Longrightarrow> \<exists>r a. x = r * cos a & y = r * sin a" | |
| 5436 | apply (rule_tac x = "sqrt (x\<^sup>2 + y\<^sup>2)" in exI) | |
| 5437 | apply (rule_tac x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))" in exI) | |
| 5438 | apply (simp add: cos_arccos_lemma1 sin_arccos_lemma1 power_divide | |
| 5439 | real_sqrt_mult [symmetric] right_diff_distrib) | |
| 5440 | done | |
| 5441 | show ?thesis | |
| 5442 | proof (cases "0::real" y rule: linorder_cases) | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 5443 | case less | 
| 54573 | 5444 | then show ?thesis by (rule polar_ex1) | 
| 5445 | next | |
| 5446 | case equal | |
| 5447 | then show ?thesis | |
| 5448 | by (force simp add: intro!: cos_zero sin_zero) | |
| 5449 | next | |
| 5450 | case greater | |
| 59669 
de7792ea4090
renaming HOL/Fact.thy -> Binomial.thy
 paulson <lp15@cam.ac.uk> parents: 
59658diff
changeset | 5451 | then show ?thesis | 
| 54573 | 5452 | using polar_ex1 [where y="-y"] | 
| 5453 | by auto (metis cos_minus minus_minus minus_mult_right sin_minus) | |
| 5454 | qed | |
| 5455 | qed | |
| 15077 
89840837108e
converting Hyperreal/Transcendental to Isar script
 paulson parents: 
15013diff
changeset | 5456 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5457 | |
| 60758 | 5458 | subsection\<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close> | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5459 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5460 | lemma pairs_le_eq_Sigma: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5461 | fixes m::nat | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5462 |   shows "{(i,j). i+j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m-r))"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5463 | by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5464 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5465 | lemma setsum_up_index_split: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5466 | "(\<Sum>k\<le>m + n. f k) = (\<Sum>k\<le>m. f k) + (\<Sum>k = Suc m..m + n. f k)" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5467 | by (metis atLeast0AtMost Suc_eq_plus1 le0 setsum_ub_add_nat) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5468 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5469 | lemma Sigma_interval_disjoint: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5470 | fixes w :: "'a::order" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5471 |   shows "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5472 | by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5473 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5474 | lemma product_atMost_eq_Un: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5475 | fixes m :: nat | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5476 |   shows "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5477 | by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5478 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5479 | lemma polynomial_product: (*with thanks to Chaitanya Mangla*) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5480 | fixes x:: "'a :: idom" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5481 | assumes m: "\<And>i. i>m \<Longrightarrow> (a i) = 0" and n: "\<And>j. j>n \<Longrightarrow> (b j) = 0" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5482 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5483 | (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5484 | proof - | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5485 | have "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = (\<Sum>i\<le>m. \<Sum>j\<le>n. (a i * x ^ i) * (b j * x ^ j))" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5486 | by (rule setsum_product) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5487 | also have "... = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5488 | using assms by (auto simp: setsum_up_index_split) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5489 | also have "... = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5490 | apply (simp add: add_ac setsum.Sigma product_atMost_eq_Un) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5491 | apply (clarsimp simp add: setsum_Un Sigma_interval_disjoint intro!: setsum.neutral) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5492 | by (metis add_diff_assoc2 add.commute add_lessD1 leD m n nat_le_linear neqE) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5493 |   also have "... = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5494 | by (auto simp: pairs_le_eq_Sigma setsum.Sigma) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5495 | also have "... = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5496 | apply (subst setsum_triangle_reindex_eq) | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5497 | apply (auto simp: algebra_simps setsum_right_distrib intro!: setsum.cong) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5498 | by (metis le_add_diff_inverse power_add) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5499 | finally show ?thesis . | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5500 | qed | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5501 | |
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5502 | lemma polynomial_product_nat: | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5503 | fixes x:: nat | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5504 | assumes m: "\<And>i. i>m \<Longrightarrow> (a i) = 0" and n: "\<And>j. j>n \<Longrightarrow> (b j) = 0" | 
| 61609 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 paulson <lp15@cam.ac.uk> parents: 
61552diff
changeset | 5505 | shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5506 | (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)" | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5507 | using polynomial_product [of m a n b x] assms | 
| 61694 
6571c78c9667
Removed some legacy theorems; minor adjustments to simplification rules; new material on homotopic paths
 paulson <lp15@cam.ac.uk> parents: 
61649diff
changeset | 5508 | by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric] of_nat_eq_iff Int.int_setsum [symmetric]) | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5509 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5510 | lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5511 | fixes x :: "'a::idom" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5512 | assumes "1 \<le> n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5513 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5514 | (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5515 | proof - | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5516 |   have h: "bij_betw (\<lambda>(i,j). (j,i)) ((SIGMA i : atMost n. lessThan i)) (SIGMA j : lessThan n. {Suc j..n})"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5517 | by (auto simp: bij_betw_def inj_on_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5518 | have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5519 | (\<Sum>i\<le>n. a i * (x^i - y^i))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5520 | by (simp add: right_diff_distrib setsum_subtractf) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5521 | also have "... = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5522 | by (simp add: power_diff_sumr2 mult.assoc) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5523 | also have "... = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5524 | by (simp add: setsum_right_distrib) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5525 | also have "... = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5526 | by (simp add: setsum.Sigma) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5527 |   also have "... = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5528 | by (auto simp add: setsum.reindex_bij_betw [OF h, symmetric] intro: setsum.strong_cong) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5529 | also have "... = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5530 | by (simp add: setsum.Sigma) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5531 | also have "... = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5532 | by (simp add: setsum_right_distrib mult_ac) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5533 | finally show ?thesis . | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5534 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5535 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5536 | lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5537 | fixes x :: "'a::idom" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5538 | assumes "1 \<le> n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5539 | shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5540 | (x - y) * ((\<Sum>j<n. \<Sum>k<n-j. a(j+k+1) * y^k * x^j))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5541 | proof - | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5542 |   { fix j::nat
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5543 | assume "j<n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5544 |     have h: "bij_betw (\<lambda>i. i - (j + 1)) {Suc j..n} (lessThan (n-j))"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5545 | apply (auto simp: bij_betw_def inj_on_def) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5546 | apply (rule_tac x="x + Suc j" in image_eqI) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5547 | apply (auto simp: ) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5548 | done | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5549 | have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5550 | by (auto simp add: setsum.reindex_bij_betw [OF h, symmetric] intro: setsum.strong_cong) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5551 | } | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5552 | then show ?thesis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5553 | by (simp add: polyfun_diff [OF assms] setsum_left_distrib) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5554 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5555 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5556 | lemma polyfun_linear_factor: (*COMPLEX_POLYFUN_LINEAR_FACTOR in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5557 | fixes a :: "'a::idom" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5558 | shows "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i) + (\<Sum>i\<le>n. c(i) * a^i)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5559 | proof (cases "n=0") | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5560 | case True then show ?thesis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5561 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5562 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5563 | case False | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5564 | have "(\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i) + (\<Sum>i\<le>n. c(i) * a^i)) = | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5565 | (\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) - (\<Sum>i\<le>n. c(i) * a^i) = (z - a) * (\<Sum>i<n. b(i) * z^i))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5566 | by (simp add: algebra_simps) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5567 | also have "... = (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) = (z - a) * (\<Sum>i<n. b(i) * z^i))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5568 | using False by (simp add: polyfun_diff) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5569 | also have "... = True" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5570 | by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5571 | finally show ?thesis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5572 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5573 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5574 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5575 | lemma polyfun_linear_factor_root: (*COMPLEX_POLYFUN_LINEAR_FACTOR_ROOT in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5576 | fixes a :: "'a::idom" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5577 | assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5578 | obtains b where "\<And>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5579 | using polyfun_linear_factor [of c n a] assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5580 | by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5581 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5582 | (*The material of this section, up until this point, could go into a new theory of polynomials | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5583 | based on Main alone. The remaining material involves limits, continuity, series, etc.*) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60141diff
changeset | 5584 | |
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5585 | lemma isCont_polynom: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5586 | fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5587 | shows "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5588 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5589 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5590 | lemma zero_polynom_imp_zero_coeffs: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5591 |     fixes c :: "nat \<Rightarrow> 'a::{ab_semigroup_mult,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5592 | assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5593 | shows "c k = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5594 | using assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5595 | proof (induction n arbitrary: c k) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5596 | case 0 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5597 | then show ?case | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5598 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5599 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5600 | case (Suc n c k) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5601 | have [simp]: "c 0 = 0" using Suc.prems(1) [of 0] | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5602 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5603 |   { fix w
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5604 | have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5605 | unfolding Set_Interval.setsum_atMost_Suc_shift | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5606 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5607 | also have "... = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" | 
| 60867 | 5608 | by (simp add: setsum_right_distrib ac_simps) | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5609 | finally have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" . | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5610 | } | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5611 | then have wnz: "\<And>w. w \<noteq> 0 \<Longrightarrow> (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5612 | using Suc by auto | 
| 61976 | 5613 | then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0" | 
| 61799 | 5614 |     by (simp cong: LIM_cong)                   \<comment>\<open>the case @{term"w=0"} by continuity\<close>
 | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5615 | then have "(\<Sum>i\<le>n. c (Suc i) * 0^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5616 | using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5617 | by (force simp add: Limits.isCont_iff) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5618 | then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" using wnz | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5619 | by metis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5620 | then have "\<And>i. i\<le>n \<Longrightarrow> c (Suc i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5621 | using Suc.IH [of "\<lambda>i. c (Suc i)"] | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5622 | by blast | 
| 60758 | 5623 | then show ?case using \<open>k \<le> Suc n\<close> | 
| 60017 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5624 | by (cases k) auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5625 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5626 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5627 | lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5628 |     fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5629 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5630 |     shows "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<and>
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5631 |              card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5632 | using assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5633 | proof (induction n arbitrary: c k) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5634 | case 0 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5635 | then show ?case | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5636 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5637 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5638 | case (Suc m c k) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5639 | let ?succase = ?case | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5640 | show ?case | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5641 |   proof (cases "{z. (\<Sum>i\<le>Suc m. c(i) * z^i) = 0} = {}")
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5642 | case True | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5643 | then show ?succase | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5644 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5645 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5646 | case False | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5647 | then obtain z0 where z0: "(\<Sum>i\<le>Suc m. c(i) * z0^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5648 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5649 | then obtain b where b: "\<And>w. (\<Sum>i\<le>Suc m. c i * w^i) = (w - z0) * (\<Sum>i\<le>m. b i * w^i)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5650 | using polyfun_linear_factor_root [OF z0, unfolded lessThan_Suc_atMost] | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5651 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5652 |     then have eq: "{z. (\<Sum>i\<le>Suc m. c(i) * z^i) = 0} = insert z0 {z. (\<Sum>i\<le>m. b(i) * z^i) = 0}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5653 | by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5654 | have "~(\<forall>k\<le>m. b k = 0)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5655 | proof | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5656 | assume [simp]: "\<forall>k\<le>m. b k = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5657 | then have "\<And>w. (\<Sum>i\<le>m. b i * w^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5658 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5659 | then have "\<And>w. (\<Sum>i\<le>Suc m. c i * w^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5660 | using b by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5661 | then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5662 | using zero_polynom_imp_zero_coeffs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5663 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5664 | then show False using Suc.prems | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5665 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5666 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5667 | then obtain k' where bk': "b k' \<noteq> 0" "k' \<le> m" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5668 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5669 | show ?succase | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5670 | using Suc.IH [of b k'] bk' | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5671 | by (simp add: eq card_insert_if del: setsum_atMost_Suc) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5672 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5673 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5674 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5675 | lemma | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5676 |     fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5677 | assumes "c k \<noteq> 0" "k\<le>n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5678 |     shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5679 |       and polyfun_roots_card:   "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5680 | using polyfun_rootbound assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5681 | by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5682 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5683 | lemma polyfun_finite_roots: (*COMPLEX_POLYFUN_FINITE_ROOTS in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5684 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5685 |   shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5686 | (is "?lhs = ?rhs") | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5687 | proof | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5688 | assume ?lhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5689 | moreover | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5690 |   { assume "\<forall>i\<le>n. c i = 0"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5691 | then have "\<And>x. (\<Sum>i\<le>n. c i * x^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5692 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5693 |     then have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5694 | using ex_new_if_finite [OF infinite_UNIV_char_0 [where 'a='a]] | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5695 | by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5696 | } | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5697 | ultimately show ?rhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5698 | by metis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5699 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5700 | assume ?rhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5701 | then show ?lhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5702 | using polyfun_rootbound | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5703 | by blast | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5704 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5705 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5706 | lemma polyfun_eq_0: (*COMPLEX_POLYFUN_EQ_0 in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5707 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5708 | shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5709 | using zero_polynom_imp_zero_coeffs by auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5710 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5711 | lemma polyfun_eq_coeffs: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5712 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5713 | shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = (\<Sum>i\<le>n. d i * x^i)) \<longleftrightarrow> (\<forall>i\<le>n. c i = d i)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5714 | proof - | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5715 | have "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = (\<Sum>i\<le>n. d i * x^i)) \<longleftrightarrow> (\<forall>x. (\<Sum>i\<le>n. (c i - d i) * x^i) = 0)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5716 | by (simp add: left_diff_distrib Groups_Big.setsum_subtractf) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5717 | also have "... \<longleftrightarrow> (\<forall>i\<le>n. c i - d i = 0)" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5718 | by (rule polyfun_eq_0) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5719 | finally show ?thesis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5720 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5721 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5722 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5723 | lemma polyfun_eq_const: (*COMPLEX_POLYFUN_EQ_CONST in HOL Light*) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5724 |   fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5725 |   shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = k) \<longleftrightarrow> c 0 = k \<and> (\<forall>i \<in> {1..n}. c i = 0)"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5726 | (is "?lhs = ?rhs") | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5727 | proof - | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5728 | have *: "\<forall>x. (\<Sum>i\<le>n. (if i=0 then k else 0) * x^i) = k" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5729 | by (induct n) auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5730 | show ?thesis | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5731 | proof | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5732 | assume ?lhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5733 | with * have "(\<forall>i\<le>n. c i = (if i=0 then k else 0))" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5734 | by (simp add: polyfun_eq_coeffs [symmetric]) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5735 | then show ?rhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5736 | by simp | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5737 | next | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5738 | assume ?rhs then show ?lhs | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5739 | by (induct n) auto | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5740 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5741 | qed | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5742 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5743 | lemma root_polyfun: | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5744 | fixes z:: "'a::idom" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5745 | assumes "1 \<le> n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5746 | shows "z^n = a \<longleftrightarrow> (\<Sum>i\<le>n. (if i = 0 then -a else if i=n then 1 else 0) * z^i) = 0" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5747 | using assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5748 | by (cases n; simp add: setsum_head_Suc atLeast0AtMost [symmetric]) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5749 | |
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5750 | lemma | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5751 |     fixes zz :: "'a::{idom,real_normed_div_algebra}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5752 | assumes "1 \<le> n" | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5753 |     shows finite_roots_unity: "finite {z::'a. z^n = 1}"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5754 |       and card_roots_unity:   "card {z::'a. z^n = 1} \<le> n"
 | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5755 | using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5756 | by (auto simp add: root_polyfun [OF assms]) | 
| 
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
 paulson <lp15@cam.ac.uk> parents: 
59869diff
changeset | 5757 | |
| 30082 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 huffman parents: 
29803diff
changeset | 5758 | end |